@voltom.io/sdk 1.0.5 → 1.0.7
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/assets/locales/ar.json +34 -2
- package/dist/assets/locales/ch.json +34 -2
- package/dist/assets/locales/de.json +34 -2
- package/dist/assets/locales/en.json +34 -2
- package/dist/assets/locales/es.json +34 -2
- package/dist/assets/locales/fr.json +34 -2
- package/dist/assets/locales/it.json +34 -2
- package/dist/assets/locales/ja.json +34 -2
- package/dist/assets/locales/pt.json +34 -2
- package/dist/assets/locales/ru.json +34 -2
- package/dist/assets/locales/zh.json +34 -2
- package/dist/sdk/PoseSilhouette-D2pGu7Lh.js +2 -0
- package/dist/sdk/PoseSuccess-R_8JYo--.js +2 -0
- package/dist/sdk/errors.d.ts +121 -0
- package/dist/sdk/facegate/global.d.ts +1 -1
- package/dist/sdk/facegate.d.ts +42 -19
- package/dist/sdk/facegate.dist.js +4 -4
- package/dist/sdk/facegate.js +1 -1
- package/dist/sdk/facekey.browser-VlDa2K-w.js +2 -0
- package/dist/sdk/facekey.d.ts +50 -26
- package/dist/sdk/facekey.dist.js +6 -6
- package/dist/sdk/facekey.js +1 -1
- package/dist/sdk/presentation-COhoAxj3.js +8 -0
- package/dist/sdk/presentation-ye0KVm6U.js +2 -0
- package/dist/sdk/requests-DW8zDX51.js +65 -0
- package/dist/sdk/verify.d.ts +58 -22
- package/dist/sdk/verify.dist.js +18 -18
- package/dist/sdk/verify.js +1 -1
- package/dist/sdk/view-CF_YOVly.js +3 -0
- package/dist/sdk/view-Cb4XCb-z.js +3 -0
- package/dist/sdk/view-DcbwHph_.js +2 -0
- package/package.json +7 -5
- package/dist/sdk/PoseSilhouette-Bbwmry4Z.js +0 -2
- package/dist/sdk/PoseSuccess-C3aBF88E.js +0 -2
- package/dist/sdk/eyeLevelCamera-DY4onSBz.js +0 -65
- package/dist/sdk/facekey.browser-CVJiBw1f.js +0 -2
- package/dist/sdk/media-BRKPXpu3.js +0 -2
- package/dist/sdk/presentation-B-TOKUZ3.js +0 -8
- package/dist/sdk/presentation-BsnbDv0i.js +0 -2
- package/dist/sdk/view-Bfg8u_hZ.js +0 -2
- package/dist/sdk/view-CHSkN6gO.js +0 -3
- package/dist/sdk/view-DmGKdc3M.js +0 -3
package/dist/sdk/verify.dist.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! Copyright (c) 2026 VOLTOM. All rights reserved. Proprietary software. See LICENSE at https://voltom.io/license. */
|
|
2
|
-
(function(){var e=Object.defineProperty,t=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},n=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},r,i,a=t((()=>{r=({moduleUrl:e})=>{let t=globalThis;t.__VOLTOM_ASSET_BASE_URL__||=new URL(`../`,e).href},i=({filename:e})=>{let t=globalThis.__VOLTOM_ASSET_BASE_URL__||globalThis.location?.href;if(!t)throw Error(`SDK_ASSET_BASE_URL_UNAVAILABLE`);return new URL(`assets/${e}`,t).href}}));function o(e){e&&e.parentNode&&e.remove()}function s(e,t,n){var r,i,a,o={},s=arguments.length;for(a in t)a==`key`?r=t[a]:a==`ref`&&typeof e!=`function`?i=t[a]:o[a]=t[a];return s>2&&(o.children=s>3?ye.call(arguments,2):n),c(e,o,r,i,null)}function c(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:me,__v:i||++ie,__i:-1,__u:0};return!i&&O.vnode&&O.vnode(a),a}function l(){return{current:null}}function u(e){return e.children}function d(e,t){this.props=e,this.context=t,this.__g=0}function f(e,t){if(t==null)return e.__&&f(e.__,e.__i+1);for(var n;t<e.__k.length;t++)if((n=e.__k[t])&&n.__e)return n.__e;return typeof e.type!=`function`||e.props.__P?null:f(e)}function p(e){if((e=e.__)&&e.__c&&!e.props.__P)return e.__e=null,e.__k.some(function(t){return t&&(e.__e=t.__e)}),p(e)}function m(e){(8&e.__g||(e.__g|=8,oe.push(e),ce++))&&se==O.debounceRendering||((se=O.debounceRendering)||queueMicrotask)(h)}function h(){var e,t,n,r,i,a,o,s,c;try{for(t=1;oe.length;)oe.length>t&&oe.sort(le),e=oe.shift(),t=oe.length,8&e.__g&&(r=void 0,i=void 0,a=(i=(n=e).__v).__e,o=[],s=[],(c=n.__P)&&((r=be({constructor:me},i)).__v=i.__v+1,O.vnode&&O.vnode(r),C(c,r,i,n.__n,c.namespaceURI,32&i.__u?[a]:null,o,a||f(i),32&i.__u,s),r.__v=i.__v,r.__.__k[r.__i]=r,E(o,r,s),i.__=i.__e=null,r.__e!=a&&p(r)))}finally{(ce=oe.length)&&(se||queueMicrotask)(h)}}function g(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,y=r.__k||ge,b=t.length;for(c=_(n,t,y,c,b),d=0;d<b;d++)(p=n.__k[d])!=null&&(f=~p.__i&&y[p.__i]||he,p.__i=d,g=C(e,p,f,i,a,o,s,c,l,u),m=p.__e,(f.ref!=p.ref||8&f.__u)&&(f.ref&&D(f.ref,null,p,f),p.ref&&u.push(p.ref,p.__c||m,p)),h||=m,4&p.__u?(c=v(p,c,e,!f.__v),f.__e&&(f.__e=null)):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-21);return n.__e=h,c}function _(e,t,n,r,i){var a,o,s,l,d,p,m,h,g,_=n.length,v=_,b=0,x=0,S=e.__k=Array(i);for(a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o!=`object`||o.constructor===String?o=S[a]=c(null,o):ve(o)?o=S[a]=c(u,{children:o}):o.constructor===me&&o.__b?o=S[a]=c(o.type,o.props,o.key,o.ref,o.__v):S[a]=o,l=a+b,o.__=e,o.__b=e.__b+1,s=null,~(d=o.__i=y(o,n,l,v))&&(v--,(s=n[d])&&(s.__u|=2)),s&&s.__v?(o.__u|=16,d==l-1?b--:d==l+1?b++:d!=l&&(d>l?b--:b++,x=1)):(~d||(i>_?b--:i<_&&b++),typeof o.type!=`function`&&(o.__u|=4))):S[a]=null;if(x){for(p=[],m=[],a=0;a<i;a++)if((o=S[a])&&16&o.__u){for(b=0,h=p.length;b<h;)p[g=b+h>>1]<o.__i?b=g+1:h=g;p[b]=o.__i,m[a]=b+1}for(b=p.length;a--;)m[a]&&(m[a]==b?b--:S[a].__u|=4)}if(v)for(a=0;a<_;a++)!(s=n[a])||2&s.__u||(s.__e==r&&(r=f(s)),te(s,s));return r}function v(e,t,n,r){var i,a,o,s;if(typeof e.type==`function`){if(e.props.__P)return t;if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&(i[a].__=e,t=v(i[a],t,n,!1));return t}for(t&&!t.parentNode&&(t=f(e))&&!t.parentNode&&(t=null),o=e.__e,s=t;s&&s.nodeType==8;)s=s.nextSibling;for(o!=s&&(!r&&n.moveBefore&&o.parentNode?n.moveBefore(o,t):n.insertBefore(o,t||null)),t=o;(t&&=t.nextSibling)&&t.nodeType==8&&!t.data.startsWith(`$s`););return t}function y(e,t,n,r){var i,a=e.key,o=e.type,s=t[n],c=s&&!(2&s.__u);if(s===null&&a==null||c&&a==s.key&&o==s.type)return n;if(r>+!!c){for(i=n-1;i>=0;i--)if((s=t[i])&&!(2&s.__u)&&a==s.key&&o==s.type)return i;for(i=n+1;i<t.length;i++)if((s=t[i])&&!(2&s.__u)&&a==s.key&&o==s.type)return i}return-1}function b(e,t,n){n??=``,t[0]==`-`?e.setProperty(t,n):e[t]=n}function x(e,t,n,r,i){var a,o;if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||b(e.style,t);if(n)for(t in n)r&&n[t]==r[t]||b(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)(e.__e||={})[t]=n,n&&r||(o=pe[t]||(pe[t]=S(t)),(e.__a||={})[t]=fe,a=t!=(t=t.replace(de,`$1`)),(t=t.slice(2))[0]<`a`&&(t=t.toLowerCase()),n?e.addEventListener(t,o,a):e.removeEventListener(t,o,a));else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;return}catch{}if(typeof n==`function`)return;n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n)}}function S(e){return function(t){var n=this.__e;if(n){if(n=n[e],t[ue]==null)t[ue]=fe++;else if(t[ue]<this.__a[e])return;return n(O.event?O.event(t):t)}}}function C(e,t,n,r,i,a,s,c,l,p){var m,h,_,v,y,b,x,S,C,E,D,re,ie,ae,oe,se,ce,le,ue=t.type;if(t.constructor!==me)return null;128&n.__u&&(l=32&n.__u,m=n.__c.__z)&&(t.__u|=l,h=a=[],m.nodeType==8?c=w(m,a):a.push(m),c=a[0]||c),(m=O.__b)&&m(t);n:if(typeof ue==`function`){_=s.length;try{if(S=t.props,C=(m=ue.prototype)&&m.render,E=(m=ue.contextType)&&r[m.__c],D=m?E?E.props.value:m.__:r,(v=n.__c)?(t.__c=v,2&v.__g&&(v.__g|=1)):(C?t.__c=v=new ue(S,D):(t.__c=v=new d(S,D),v.constructor=ue,v.render=ne),E&&E.sub(v),v.state||(v.state={}),v.__n=r,v.__g|=8,v.__h=[],v.__k=[]),C&&(v.__s||(v.__s=v.state),ue.getDerivedStateFromProps&&(v.__s==v.state&&(v.__s=be({},v.__s)),be(v.__s,ue.getDerivedStateFromProps(S,v.__s)))),y=v.props,b=v.state,v.__v=t,n.__c){if(S!==y&&C&&!ue.getDerivedStateFromProps&&v.componentWillReceiveProps&&v.componentWillReceiveProps(S,D),t.__v==n.__v&&!(8&v.__g)||!(4&v.__g)&&v.shouldComponentUpdate&&!1===v.shouldComponentUpdate(S,v.__s,D)){t.__v!=n.__v&&(v.props=S,v.state=v.__s,v.__g&=-9),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),ge.push.apply(v.__h,v.__k),v.__k=[],v.__h.length&&s.push(v),c=f(n);break n}v.componentWillUpdate&&v.componentWillUpdate(S,v.__s,D),C&&v.componentDidUpdate&&v.__h.push(function(){v.componentDidUpdate(y,b,x)})}else C&&!ue.getDerivedStateFromProps&&v.componentWillMount&&v.componentWillMount(),C&&v.componentDidMount&&v.__h.push(v.componentDidMount);if(v.context=D,v.props=S,v.__P=e,v.__g&=-5,re=O.__r,ie=0,C)v.state=v.__s,v.__g&=-9,re&&re(t),m=v.render(v.props,v.state,v.context),ge.push.apply(v.__h,v.__k),v.__k=[];else do v.__g&=-9,re&&re(t),m=v.render(v.props,v.state,v.context),v.state=v.__s;while(8&v.__g&&++ie<25);v.state=v.__s,v.getChildContext&&(r=be({},r,v.getChildContext())),C&&n.__c&&v.getSnapshotBeforeUpdate&&(x=v.getSnapshotBeforeUpdate(y,b)),ae=m&&m.type===u&&m.key==null?m.props.children:m,S.__P&&(m=c,i=(e=S.__P).namespaceURI,l=a=null,n.props&&n.props.__P!=e&&(n.__k.some(function(e){e&&te(e,e)}),n.__k=null),c=n.__k?f(n,0):null),c=g(e,ve(ae)?ae:[ae],t,n,r,i,a,s,c,l,p),S.__P&&(t.__e=null,c=m),t.__u&=-161,h&&h.some(o),v.__h.length&&s.push(v),1&v.__g&&(v.__g&=-4)}catch(e){if(s.length=_,t.__v=null,l||a){if(e.then){if(oe=0,t.__u|=128|l,a){for(~(ce=a.indexOf(c||void 0))||(ce=a.length);(le=a[ce-1])&&le.nodeType==8;)ce--;for(;ce<a.length;ce++)if(le=a[ce]){if(a[ce]=null,le.nodeType==8){if(le.data.startsWith(`$s`))oe++||(se=le);else if(oe&&le.data.startsWith(`/$s`)&&!--oe)break}else if(!oe)break}}if(!se){for(;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;se=c}(m=w(se=t.__c.__z||(t.__c.__z=se)))?(t.__e=se,c=m):t.__e=c,c&&=c.nextSibling}else a&&a.some(o)}else t.__e=n.__e;t.__k||=n.__k||[],e.then||T(t),O.__e(e,t,n)}}else c=t.__e=ee(n.__e,t,n,r,i,a,s,l,p,e);return(m=O.diffed)&&m(t),c}function w(e,t){if(e&&e.nodeType==8&&e.data.startsWith(`$s`))for(var n=1;e=e.nextSibling;){if(e.nodeType==8){if(e.data.startsWith(`$s`))n++;else if(e.data.startsWith(`/$s`)&&!--n)return e}t&&t.push(e)}}function T(e){e&&(e.__c&&(e.__c.__g|=4),e.__k&&e.__k.some(T))}function E(e,t,n){for(var r=0;r<n.length;)D(n[r++],n[r++],n[r++]);O.__c&&O.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){O.__e(e,t.__v)}})}function ee(e,t,n,r,i,a,s,c,l,u){var d,p,m,h,_,v,y,b,S,C=n.props||he,w=t.props,T=t.type;if(T==`svg`?i=`http://www.w3.org/2000/svg`:T==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a){for(d=0;d<a.length;d++)if((_=a[d])&&(T?_.localName==T:_.nodeType==3)){e=_,a[d]=null;break}}if(!e){if(b=u.ownerDocument||document,!T)return b.createTextNode(w);e=b.createElementNS(i,T,w.is&&w),c&&=(O.__m&&O.__m(t,a),!1),a=null}if(T){if(u=T==`template`&&e.content||e,a=T==`textarea`&&w.defaultValue!=null?null:a&&ye.call(u.childNodes),!c&&a)for(C={},d=0;d<e.attributes.length;d++)C[(_=e.attributes[d]).name]=_.value;for(d in C)_=C[d],d==`dangerouslySetInnerHTML`?m=_:d==`children`||d in w||d==`value`&&`defaultValue`in w||d==`checked`&&`defaultChecked`in w||x(e,d,null,_,i);for(d in S=1&n.__u,w)_=w[d],d==`children`?h=_:d==`dangerouslySetInnerHTML`?p=_:d==`value`?v=_:d==`checked`?y=_:c&&typeof _!=`function`||!(C[d]!==_||S&&_!=null)||x(e,d,_,C[d],i);p?(c||m&&(p.__html==m.__html||p.__html==e.innerHTML)||(e.innerHTML=p.__html),t.__k=[]):(m&&(e.textContent=``),(T==`foreignObject`||i==`http://www.w3.org/1998/Math/MathML`&&_e.test(T))&&(i=`http://www.w3.org/1999/xhtml`),g(u,ve(h)?h:[h],t,n,r,i,a,s,a?a[0]:n.__k&&f(n,0),c,l),a&&a.some(o)),c&&T!=`textarea`||(d=`value`,T==`progress`&&v==null?e.removeAttribute(d):v==null||v===e[d]&&(T!=`progress`||v)||x(e,d,v,C[d],i),d=`checked`,y!=null&&y!=e[d]&&x(e,d,y,C[d],i))}else C===w||c&&e.data==w||(e.data=w);return e}function D(e,t,n,r){try{typeof e==`function`?t?t.__x=e(t)||1:(r&&=r.__c||r.__e)&&(t=r.__x)&&(r.__x=null,typeof t==`function`?t():e(null)):e.current=t}catch(e){O.__e(e,n)}}function te(e,t,n){var r,i,a,s;if(O.unmount&&O.unmount(e),!(r=e.ref)||r.current&&r.current!=e.__e||D(r,null,t,e),r=e.__c){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){O.__e(e,t)}r.__P=r.__n=null}if(r=e.__k)for(s=0;s<r.length;s++)r[s]&&te(r[s],t,typeof e.type!=`function`||n&&!e.props.__P);!n&&(r=e.__c)&&(r=r.__z)&&(i=w(r,a=[]))&&(r==e.__e&&a.some(o),o(i),o(r)),(r=e.__e)&&(n||o(r),r.__e&&(r.__e=null)),e.__e=e.__c=e.__=null}function ne(e,t,n){return this.constructor(e,n)}function re(e,t){var n,r,i,a;O.__&&O.__(e,t),t.nodeType==9&&(t=t.documentElement),r=(n=e&&32&e.__u)?null:t.__k,t.__k=c(u,{children:[e]}),i=[],a=[],C(t,t.__k,r||he,he,t.namespaceURI,r?null:t.firstChild?ye.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,a),E(i,t.__k,a),t.__k.props.children=null}var O,ie,ae,oe,se,ce,le,ue,de,fe,pe,me,he,ge,_e,ve,ye,be,xe=t((()=>{me=Symbol.for(`pv`),he={},ge=[],_e=/^m(i|n|o|s|text|space)$/,ve=Array.isArray,ye=ge.slice,be=Object.assign,O={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!(1&i.__g)){i.__g|=4;try{if((o=(a=i.constructor)&&a.getDerivedStateFromError)&&i.setState(a.getDerivedStateFromError(e)),i.componentDidCatch&&(i.componentDidCatch(e,r||{}),o=1),o&&8&i.__g)return void(i.__g|=2)}catch(t){e=t}}throw ce=0,e}},ie=0,ae=function(e){return e!=null&&e.constructor===me},d.prototype.setState=function(e,t){var n=this.__s;n&&n!=this.state||(n=this.__s=be({},this.state)),typeof e==`function`&&(e=e(be({},n),this.props)),e&&(be(n,e),this.__v&&(t&&this.__k.push(t),m(this)))},d.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),m(this))},d.prototype.render=u,oe=[],ce=0,le=function(e,t){return e.__v.__b-t.__v.__b},ue=Symbol(),de=/(PointerCapture)$|Capture$/i,fe=0,pe={}}));function Se(e,t){A.__h&&A.__h(k,e,Le||t),Le=0;var n=k.__H||(k.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Ce(e){return Le=1,we(Me,e)}function we(e,t,n){var r=Se(Ne++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Me(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);Ie(t,n)||(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=k,!k.__f)){k.__f=!0;var i=k.shouldComponentUpdate;k.shouldComponentUpdate=function(e,t,n){var r=this.__H;if(!r)return!0;var a=!1,o=this.props!=e;if(r.__.some(function(e){e.__N&&(a=!0,Ie(e.__[0],e.__N[0])||(o=!0))}),i){var s=i.call(this,e,t,n);return a?s||o:s}return!a||o}}return r.__}function Te(e,t){var n=Se(Ne++,7);return je(n.__H,t)&&(n.__=e(),n.__H=t),n.__}function Ee(){var e;do{for(;e=ze.shift();)try{ke(e)}catch(t){A.__e(t,{__:(e=e.__P)&&e.__v})}for(;e=Re.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(ke),t.__h.some(Ae),t.__h=[]}catch(n){t.__h=[],A.__e(n,e.__v)}}}while(ze.length)}function De(e){var t,n=function(){clearTimeout(r),Ke&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Ke&&(t=requestAnimationFrame(n))}function Oe(e){e!=1&&Fe==A.requestAnimationFrame||((Fe=A.requestAnimationFrame)||De)(Ee)}function ke(e){var t=k,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),k=t}function Ae(e){var t=k;e.__c=e.__(),k=t}function je(e,t){return!e||e.length!=t.length||t.some(function(t,n){return!Ie(t,e[n])})}function Me(e,t){return typeof t==`function`?t(e):t}var Ne,k,Pe,Fe,Ie,Le,Re,ze,A,Be,Ve,He,Ue,We,Ge,Ke,qe=t((()=>{xe(),Ie=Object.is,Le=0,Re=[],ze=[],A=O,Be=A.__b,Ve=A.__r,He=A.diffed,Ue=A.__c,We=A.unmount,Ge=A.__,A.__b=function(e){k=null,Be&&Be(e)},A.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Ge&&Ge(e,t)},A.__r=function(e){Ve&&Ve(e),Ne=0;var t=(k=e.__c).__H;t&&(Pe==k?k.__h=[]:(t.__h.some(ke),t.__h.some(Ae),Ne=0),t.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})),Pe=k},A.diffed=function(e){He&&He(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&Oe(Re.push(t)),t.__H.__.some(function(e){e.u&&(e.__H=e.u)})),Pe=k=null},A.__c=function(e,t){t.some(function(e){try{e.__h.some(ke),e.__h=e.__h.filter(function(e){return!e.__||Ae(e)})}catch(t){e.__h=[function(){throw t}]}}),Ue&&Ue(e,t)},A.unmount=function(e){We&&We(e);var t,n,r=e.__c;r&&r.__H&&(r.__H.__.some(function(r){try{if(r.__P&&r.__c){if(n===void 0){for(n=e.__;n&&(!n.__c||!n.__c.__P);)n=n.__;n&&=n.__c}r.__P=n,Oe(ze.push(r))}else ke(r)}catch(e){t=e}}),r.__H=void 0,t&&A.__e(t,r.__v))},Ke=typeof requestAnimationFrame==`function`}));function Je(){if(pt>1)pt--;else{var e,t=!1;for((function(){var e=_t;for(_t=void 0;e!==void 0;){var t=e.S;if(t.v===e.v)for(var n=t.t;n!==void 0;n=n.x)n.i===e.i&&(n.i=t.i);e=e.o}})();ft!==void 0;){var n=ft;for(ft=void 0,mt++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&et(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(mt=0,pt--,t)throw e}}function Ye(e){if(pt>0)return e();gt=++ht,pt++;try{return e()}finally{Je()}}function Xe(e){var t=j,n=dt;j=void 0,dt=void 0;try{return e()}finally{j=t,dt=n}}function Ze(e){if(j!==void 0){var t=e.n;if(t===void 0||t.t!==j)return t={i:0,S:e,p:j.s,n:void 0,t:j,e:void 0,x:void 0,r:t},j.s!==void 0&&(j.s.n=t),j.s=t,e.n=t,32&j.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=j.s,t.n=void 0,j.s.n=t,j.s=t),t}}function Qe(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}function $e(e,t){return new Qe(e,t)}function et(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function tt(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function nt(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function rt(e,t){Qe.call(this,void 0,t),this.x=e,this.s=void 0,this.g=vt-1,this.f=4}function it(e,t){return new rt(e,t)}function at(e){var t=e.j;if(e.j=void 0,typeof t==`function`){pt++;var n=j;j=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,ot(e),t}finally{j=n,Je()}}}function ot(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,at(e)}function st(e){if(j!==this)throw Error(`Out-of-order effect`);nt(this),j=e,this.f&=-2;try{8&this.f&&ot(this)}finally{Je()}}function ct(e,t){this.x=e,this.j=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,dt&&dt.push(this)}function lt(e,t){var n=new ct(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var ut,dt,j,ft,pt,mt,ht,gt,_t,vt,yt=t((()=>{ut=Symbol.for(`preact-signals`),j=void 0,ft=void 0,pt=0,mt=0,ht=0,gt=0,_t=void 0,vt=0,Qe.prototype.brand=ut,Qe.prototype.h=function(){return!0},Qe.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n===void 0?Xe(function(){var e;(e=t.W)==null||e.call(t)}):n.e=e)},Qe.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&Xe(function(){var e;(e=t.Z)==null||e.call(t)}))}},Qe.prototype.subscribe=function(e){var t=this;return lt(function(){var n=t.value;Xe(function(){return e(n)})},{name:`sub`})},Qe.prototype.valueOf=function(){return this.value},Qe.prototype.toString=function(){return this.value+``},Qe.prototype.toJSON=function(){return this.value},Qe.prototype.peek=function(){var e=this;return Xe(function(){return e.value})},Object.defineProperty(Qe.prototype,"value",{get:function(){var e=Ze(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(mt>100)throw Error(`Cycle detected`);(function(e){pt!==0&&mt===0&&e.l!==gt&&(e.l=gt,_t={S:e,v:e.v,i:e.i,o:_t})})(this),this.v=e,this.i++,vt++,pt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Je()}}}}),rt.prototype=new Qe,rt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===vt))return!0;if(this.g=vt,this.f|=1,this.i>0&&!et(this))return this.f&=-2,!0;var e=j;try{tt(this),j=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return j=e,nt(this),this.f&=-2,!0},rt.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}Qe.prototype.S.call(this,e)},rt.prototype.U=function(e){if(this.t!==void 0&&(Qe.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}},rt.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(rt.prototype,"value",{get:function(){if(1&this.f)throw Error(`Cycle detected`);var e=Ze(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),ct.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t==`function`&&(this.j=t)}finally{e()}},ct.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,at(this),tt(this),pt++;var e=j;return j=this,st.bind(this,e)},ct.prototype.N=function(){2&this.f||(this.f|=2,this.u=ft,ft=this)},ct.prototype.d=function(){this.f|=8,1&this.f||ot(this)},ct.prototype.dispose=function(){this.d()}}));function bt(e,t){O[e]=t.bind(null,O[e]||function(){})}function xt(e){if(Ot){var t=Ot;Ot=void 0,t()}Ot=e&&e.S()}function St(e){var t=this,n=e.data,r=wt(n);r.name=`ReactiveDom`,r.value=n;var i=Te(function(){for(var e=t,n=t.__v;n=n.__;)if(n.__c){n.__c.__$f|=4;break}var i=it(function(){var e=r.value.value;return e===0?0:!0===e?``:e||``}),a=it(function(){return!Array.isArray(i.value)&&!ae(i.value)}),o=lt(function(){if(this.N=Et,a.value){var t=i.value;e.__v&&e.__v.__e&&e.__v.__e.nodeType===3&&(e.__v.__e.data=t)}}),s=t.__$u.d;return t.__$u.d=function(){o(),s.call(this)},[a,i]},[]),a=i[0],o=i[1];return a.value?o.peek():o.value}function Ct(e,t,n,r){var i=t in e&&e.ownerSVGElement===void 0,a=$e(n);return{o:function(e,t){a.value=e,r=t},d:lt(function(){this.N=Et;var n=a.value.value;r[t]!==n&&(r[t]=n,i?e[t]=n:n!=null&&(!1!==n||t[4]===`-`)?e.setAttribute(t,n):e.removeAttribute(t))})}}function wt(e,t){return Te(function(){return $e(e,t)},[])}function Tt(){Ye(function(){for(var e;e=At.shift();)Dt.call(e)})}function Et(){At.push(this)===1&&(O.requestAnimationFrame||jt)(Tt)}var Dt,Ot,kt,At,jt,Mt=t((()=>{xe(),qe(),yt(),kt=typeof window<`u`&&!!window.__PREACT_SIGNALS_DEVTOOLS__,At=[],lt(function(){Dt=this.N})(),St.displayName=`ReactiveTextNode`,Object.defineProperties(Qe.prototype,{constructor:{configurable:!0,value:s(u,null).constructor},type:{configurable:!0,value:St},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}}),bt(`__b`,function(e,t){if(xt(),typeof t.type==`string`){var n,r=t.props;for(var i in r)if(i!==`children`){var a=r[i];a instanceof Qe&&(n||(t.__np=n={}),n[i]=a,r[i]=a.peek())}}e(t)}),bt(`__r`,function(e,t){if(e(t),t.type!==u){xt();var n,r=t.__c;r&&(r.__$f&=-2,(n=r.__$u)===void 0&&(r.__$u=n=function(e,t){var n;return lt(function(){n=this},{name:t}),n.c=e,n}(function(e){return function(){var t;kt&&((t=this.y)==null||t.call(this)),e.__$f|=1,e.setState({})}}(r),typeof t.type==`function`?t.type.displayName||t.type.name:``))),xt(n)}}),bt(`__e`,function(e,t,n,r){xt(),e(t,n,r)}),bt(`diffed`,function(e,t){xt();var n;if(typeof t.type==`string`&&(n=t.__e)){var r=t.__np,i=t.props,a=n.U;if(a)for(var o in a){var s=a[o];s===void 0||r&&o in r||(s.d(),a[o]=void 0)}if(r)for(var c in a||(a={},n.U=a),r){var l=a[c],u=r[c];l===void 0?(l=Ct(n,c,u,i),a[c]=l):l.o(u,i)}}e(t)}),bt(`unmount`,function(e,t){if(typeof t.type==`string`){var n=t.__e;if(n){var r=n.U;if(r)for(var i in n.U=void 0,r){var a=r[i];a&&a.d()}}var o=t.__np;if(o){var s=t.props;for(var c in o)s[c]=o[c]}t.__np=void 0}else{var l=t.__c;if(l){l.__$f|=8;var u=l.__$u;u&&(l.__$u=void 0,u.d())}}e(t)}),bt(`__h`,function(e,t,n,r){r<3&&(t.__$f|=2),e(t,n,r)}),d.prototype.shouldComponentUpdate=function(e,t){if(this.__R)return!0;var n=this.__$u,r=n&&n.s!==void 0;for(var i in t)return!0;if(this.__f||typeof this.u==`boolean`&&!0===this.u){var a=2&this.__$f;if(!(r||a||4&this.__$f)||1&this.__$f)return!0}else if(!(r||4&this.__$f)||3&this.__$f)return!0;for(var o in e)if(o!==`__source`&&e[o]!==this.props[o])return!0;for(var s in this.props)if(!(s in e))return!0;return!1},jt=function(e){queueMicrotask(function(){queueMicrotask(e)})}})),M,Nt,Pt,Ft,It=t((()=>{M={INVALID_PDF:`INVALID_PDF`,PDF_PASSWORD_REQUIRED:`PDF_PASSWORD_REQUIRED`,PDF_LOAD_FAILED:`PDF_LOAD_FAILED`,CLIENT_KEY_REQUIRED:`CLIENT_KEY_REQUIRED`,CAMERA_INTERRUPTED:`CAMERA_INTERRUPTED`,CAMERA_NOT_FOUND:`CAMERA_NOT_FOUND`,CAMERA_PERMISSION_DENIED:`CAMERA_PERMISSION_DENIED`,CAMERA_UNAVAILABLE:`CAMERA_UNAVAILABLE`,CAMERA_UNSUPPORTED:`CAMERA_UNSUPPORTED`,CAPTURES_INCOMPLETE:`CAPTURES_INCOMPLETE`,DOCUMENT_BACK_CONTAINS_FACE:`DOCUMENT_BACK_CONTAINS_FACE`,DOCUMENT_BACK_NOT_DISTINCT:`DOCUMENT_BACK_NOT_DISTINCT`,DOCUMENT_BACK_REQUIRED:`DOCUMENT_BACK_REQUIRED`,DOCUMENT_BLURRY:`DOCUMENT_BLURRY`,DOCUMENT_FACE_GEOMETRY_INVALID:`DOCUMENT_FACE_GEOMETRY_INVALID`,DOCUMENT_FACE_NOT_CONTAINED:`DOCUMENT_FACE_NOT_CONTAINED`,DOCUMENT_FACE_NOT_FOUND:`DOCUMENT_FACE_NOT_FOUND`,DOCUMENT_NOT_FOUND:`DOCUMENT_NOT_FOUND`,DOCUMENT_NOT_RECOGNIZED:`DOCUMENT_NOT_RECOGNIZED`,DOCUMENT_TEXT_ALIGNMENT_INVALID:`DOCUMENT_TEXT_ALIGNMENT_INVALID`,DOCUMENT_TEXT_NOT_READABLE:`DOCUMENT_TEXT_NOT_READABLE`,DOCUMENT_VALIDATION_FAILED:`DOCUMENT_VALIDATION_FAILED`,FACEKEY_TOKEN_INVALID:`FACEKEY_TOKEN_INVALID`,FACEGATE_TOKEN_INVALID:`FACEGATE_TOKEN_INVALID`,FACEGATE_ABORTED:`FACEGATE_ABORTED`,FACEGATE_TIMEOUT:`FACEGATE_TIMEOUT`,FACE_NOT_FOUND:`FACE_NOT_FOUND`,FACE_MISMATCH:`FACE_MISMATCH`,FACE_NOT_USABLE:`FACE_NOT_USABLE`,IMAGE_ENCODE_FAILED:`IMAGE_ENCODE_FAILED`,IMAGE_PROCESSING_FAILED:`IMAGE_PROCESSING_FAILED`,INVALID_IMAGE:`INVALID_IMAGE`,INVALID_MODEL_OUTPUT:`INVALID_MODEL_OUTPUT`,INVALID_OPTIONS:`INVALID_OPTIONS`,INVALID_POSES:`INVALID_POSES`,INVALID_CLIENT_KEY:`INVALID_CLIENT_KEY`,INVALID_SERVICE_RESPONSE:`INVALID_SERVICE_RESPONSE`,MODEL_LOAD_FAILED:`MODEL_LOAD_FAILED`,NETWORK_ERROR:`NETWORK_ERROR`,REQUEST_TOO_LARGE:`REQUEST_TOO_LARGE`,NO_USABLE_CANDIDATES:`NO_USABLE_CANDIDATES`,NO_USABLE_REFERENCES:`NO_USABLE_REFERENCES`,POSE_BACKGROUND_MISMATCH:`POSE_BACKGROUND_MISMATCH`,POSE_IDENTITY_MISMATCH:`POSE_IDENTITY_MISMATCH`,SERVICE_UNAVAILABLE:`SERVICE_UNAVAILABLE`,SDK_NOT_READY:`SDK_NOT_READY`,SDK_CAPABILITY_NOT_CONFIGURED:`SDK_CAPABILITY_NOT_CONFIGURED`,UI_ELEMENT_NOT_FOUND:`UI_ELEMENT_NOT_FOUND`,VERIFICATION_CANCELLED:`VERIFICATION_CANCELLED`,VERIFICATION_SAVE_FAILED:`VERIFICATION_SAVE_FAILED`},Nt=new Set(Object.values(M)),Pt=e=>typeof e==`string`&&Nt.has(e),Ft=({error:e,fallback:t=M.INVALID_SERVICE_RESPONSE})=>typeof e==`object`&&e&&`code`in e&&Pt(e.code)?e.code:e instanceof Error&&Pt(e.message)?e.message:Pt(e)?e:t})),Lt,Rt,zt,Bt,Vt,Ht,Ut,Wt,Gt,Kt=t((()=>{a(),It(),Lt=[`ar`,`ch`,`de`,`en`,`es`,`fr`,`it`,`ja`,`pt`,`ru`,`zh`],Rt=new Map,zt=new Map,Bt=async({language:e})=>{if(Rt.has(e))return;let t=zt.get(e);t||(t=fetch(i({filename:`locales/${e}.json`})).then(async e=>{if(!e.ok)throw Error(M.INVALID_SERVICE_RESPONSE);return await e.json()}),zt.set(e,t));try{Rt.set(e,await t)}finally{zt.delete(e)}},Vt=async({language:e})=>{let t=e??Ht();await Promise.all([Bt({language:t}),...t===`en`?[]:[Bt({language:`en`})]])},Ht=()=>{let e=[navigator.language,...navigator.languages];for(let t of e){let e=t.toLowerCase();if(/^zh-(hk|mo|tw)\b/u.test(e))return`ch`;let n=e.split(`-`)[0];if(Lt.includes(n))return n}return`en`},Ut={[M.CAMERA_PERMISSION_DENIED]:`cameraPermissionDenied`,[M.CAMERA_NOT_FOUND]:`cameraNotFound`,[M.CAMERA_UNAVAILABLE]:`cameraUnavailable`,[M.CAMERA_UNSUPPORTED]:`cameraUnavailable`,[M.CAMERA_INTERRUPTED]:`cameraUnavailable`,[M.NETWORK_ERROR]:`networkError`,[M.SERVICE_UNAVAILABLE]:`serviceUnavailable`,[M.MODEL_LOAD_FAILED]:`modelLoadFailed`,[M.FACE_NOT_FOUND]:`faceNotFound`,[M.NO_USABLE_CANDIDATES]:`faceNotFound`,[M.FACE_NOT_USABLE]:`faceNotUsable`,[M.NO_USABLE_REFERENCES]:`faceNotUsable`,[M.DOCUMENT_NOT_FOUND]:`frameDocument`,[M.DOCUMENT_NOT_RECOGNIZED]:`invalidDocument`,[M.DOCUMENT_TEXT_NOT_READABLE]:`documentNotReadable`,[M.DOCUMENT_BLURRY]:`documentBlurry`,[M.DOCUMENT_FACE_NOT_FOUND]:`faceNotVisibleInDocument`,[M.DOCUMENT_FACE_NOT_CONTAINED]:`documentAlignmentInvalid`,[M.DOCUMENT_FACE_GEOMETRY_INVALID]:`documentAlignmentInvalid`,[M.DOCUMENT_TEXT_ALIGNMENT_INVALID]:`documentAlignmentInvalid`,[M.DOCUMENT_BACK_REQUIRED]:`frameDocumentBack`,[M.CAPTURES_INCOMPLETE]:`capturesIncomplete`,[M.DOCUMENT_VALIDATION_FAILED]:`documentValidationFailed`,[M.INVALID_OPTIONS]:`invalidOptions`,[M.INVALID_POSES]:`invalidPoses`,[M.INVALID_SERVICE_RESPONSE]:`invalidServiceResponse`,[M.POSE_BACKGROUND_MISMATCH]:`poseBackgroundMismatch`,[M.POSE_IDENTITY_MISMATCH]:`poseIdentityMismatch`,[M.IMAGE_ENCODE_FAILED]:`imageEncodeFailed`,[M.IMAGE_PROCESSING_FAILED]:`imageProcessingFailed`,[M.INVALID_IMAGE]:`invalidImage`,[M.INVALID_PDF]:`invalidPdf`,[M.PDF_PASSWORD_REQUIRED]:`pdfPasswordRequired`,[M.PDF_LOAD_FAILED]:`pdfLoadFailed`,[M.CLIENT_KEY_REQUIRED]:`clientKeyRequired`,[M.VERIFICATION_SAVE_FAILED]:`verificationSaveFailed`,[M.FACEGATE_ABORTED]:`verificationCancelled`,[M.VERIFICATION_CANCELLED]:`verificationCancelled`},Wt=({language:e})=>{let t=e??Ht(),n=e=>{let n=Rt.get(t),r=Rt.get(`en`);return n?.[e]??r?.[e]??e};return{translate:n,translateError:({error:e})=>{let t=Ft({error:e}),r=Ut[t]??`verificationFailed`;return n(r)}}},Gt=async({milliseconds:e})=>{let t=Promise.withResolvers();setTimeout(()=>t.resolve(),e),await t.promise}})),qt,Jt,Yt,Xt,Zt,Qt,$t,en,tn,nn,rn,an,on=t((()=>{It(),qt=new WeakMap,Jt=async({video:e,signal:t})=>{t?.throwIfAborted();let n=Promise.withResolvers(),r=e,i=qt.get(e)??new Set,a=null,o=null,s=!1,c=c=>{s||(s=!0,a!==null&&r.cancelVideoFrameCallback?.(a),o!==null&&cancelAnimationFrame(o),t?.removeEventListener(`abort`,u),i.delete(l),i.size||qt.delete(e),c?n.reject(c):n.resolve())},l=()=>c(new DOMException(M.VERIFICATION_CANCELLED,`AbortError`)),u=()=>c(new DOMException(M.VERIFICATION_CANCELLED,`AbortError`));i.add(l),qt.set(e,i),t?.addEventListener(`abort`,u,{once:!0}),r.requestVideoFrameCallback?a=r.requestVideoFrameCallback(()=>c()):o=requestAnimationFrame(()=>c()),await n.promise},Yt=()=>{let e=/Android|iPhone|iPad|iPod|Mobile/i.test(navigator.userAgent),t=navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1;return e||t},Xt=async()=>{let e=[],t=(t,n)=>{n||e.push(t)};if(t(`navigator.mediaDevices.getUserMedia`,typeof navigator.mediaDevices==`object`&&typeof navigator.mediaDevices.getUserMedia==`function`),t(`navigator.mediaDevices.enumerateDevices`,typeof navigator.mediaDevices==`object`&&typeof navigator.mediaDevices.enumerateDevices==`function`),t(`MediaStream`,typeof MediaStream<`u`),t(`MediaStreamTrack`,typeof MediaStreamTrack<`u`),t(`HTMLVideoElement`,typeof HTMLVideoElement<`u`),t(`createImageBitmap`,typeof createImageBitmap==`function`),t(`OffscreenCanvas`,typeof OffscreenCanvas<`u`),t(`OffscreenCanvas.getContext`,typeof OffscreenCanvas<`u`&&typeof OffscreenCanvas.prototype.getContext==`function`),t(`OffscreenCanvas.convertToBlob`,typeof OffscreenCanvas<`u`&&typeof OffscreenCanvas.prototype.convertToBlob==`function`),t(`WebAssembly`,typeof WebAssembly<`u`),t(`fetch`,typeof fetch==`function`),t(`Blob`,typeof Blob<`u`),t(`File`,typeof File<`u`),t(`URL.createObjectURL`,typeof URL.createObjectURL==`function`),t(`URL.revokeObjectURL`,typeof URL.revokeObjectURL==`function`),!e.includes(`OffscreenCanvas`)&&!e.includes(`OffscreenCanvas.getContext`)&&!e.includes(`OffscreenCanvas.convertToBlob`))try{let e=new OffscreenCanvas(1,1),n=e.getContext(`2d`);if(t(`OffscreenCanvas 2D context`,n!==null),n&&typeof createImageBitmap==`function`){let n=await e.convertToBlob({type:`image/jpeg`});t(`JPEG encoding`,n.type===`image/jpeg`),n.type===`image/jpeg`&&((await createImageBitmap(n)).close(),t(`JPEG decoding`,!0))}else t(`JPEG encoding`,!1),t(`JPEG decoding`,!1)}catch{e.includes(`JPEG encoding`)||t(`JPEG encoding`,!1),t(`JPEG decoding`,!1)}else t(`JPEG encoding`,!1),t(`JPEG decoding`,!1);return{supported:e.length===0,unsupportedFeatures:e}},Zt=({video:e})=>{for(let t of qt.get(e)??[])t();let t=e.srcObject;if(t instanceof MediaStream)for(let e of t.getTracks())e.stop();e.srcObject=null},Qt=async({facingMode:e,video:t,signal:n})=>{if(!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!=`function`)throw Error(M.CAMERA_UNSUPPORTED);let r={facingMode:{ideal:e}};Yt()||(r.width={ideal:1280},r.height={ideal:720});let i=()=>Zt({video:t});n?.addEventListener(`abort`,i,{once:!0});try{let i=await navigator.mediaDevices.getUserMedia({video:r,audio:!1});if(n?.aborted){for(let e of i.getTracks())e.stop();n.throwIfAborted()}t.srcObject=i;let a=(await navigator.mediaDevices.enumerateDevices()).filter(({kind:e})=>e===`videoinput`).length>1?e:`user`;return await t.play(),n?.throwIfAborted(),a}catch(e){if(Zt({video:t}),n?.aborted)throw new DOMException(M.VERIFICATION_CANCELLED,`AbortError`);let r=e instanceof Error?e.name:``,i=M.CAMERA_UNAVAILABLE;throw(r===`NotAllowedError`||r===`SecurityError`)&&(i=M.CAMERA_PERMISSION_DENIED),r===`NotFoundError`&&(i=M.CAMERA_NOT_FOUND),r===`AbortError`&&(i=M.CAMERA_INTERRUPTED),Error(i,{cause:e})}finally{n?.removeEventListener(`abort`,i)}},$t=({element:e})=>{let t=e.getContext(`2d`);if(!t)throw Error(M.IMAGE_PROCESSING_FAILED);t.clearRect(0,0,e.width,e.height)},en=async({canvas:e,quality:t})=>{try{let n=await e.convertToBlob({type:`image/jpeg`,quality:t});if(n.type!==`image/jpeg`)throw Error(M.IMAGE_ENCODE_FAILED);return n}catch(e){throw Error(M.IMAGE_ENCODE_FAILED,{cause:e})}},tn=async({frame:e})=>{let t=new OffscreenCanvas(e.width,e.height),n=t.getContext(`2d`);if(!n)throw Error(M.IMAGE_PROCESSING_FAILED);return n.drawImage(e,0,0),await en({canvas:t})},nn=async({blob:e})=>{let t;try{t=await createImageBitmap(e)}catch(e){throw Error(M.INVALID_IMAGE,{cause:e})}try{let e=Math.min(1,900/Math.max(t.width,t.height)),n=new OffscreenCanvas(Math.max(1,Math.round(t.width*e)),Math.max(1,Math.round(t.height*e))),r=n.getContext(`2d`);if(!r)throw Error(M.IMAGE_PROCESSING_FAILED);return r.drawImage(t,0,0,n.width,n.height),await en({canvas:n,quality:.85})}finally{t.close()}},rn=async({frame:e})=>{let t=Math.min(1,960/Math.max(e.width,e.height)),n=Math.max(1,Math.round(e.width*t)),r=Math.max(1,Math.round(e.height*t));return await createImageBitmap(e,{resizeWidth:n,resizeHeight:r})},an=async({image:e})=>{let t=new Uint8Array(await e.arrayBuffer()),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));return`data:image/jpeg;base64,${btoa(n)}`}}));function sn(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function cn(e,t=`|`){return e.map(e=>kn(e)).join(t)}function ln(e,t){return typeof t==`bigint`?t.toString():t}function un(e){return new ar(e)}function dn(e){return e==null}function fn(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function pn(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function mn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function hn(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function gn(e){return hn(e._zod.def)??e._zod.def.shape}function _n(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return mn(this,t,e),e},enumerable:!0,configurable:!0})}function vn(e,t,n){t in e?mn(e,t,n):e[t]=n}function yn(e,t,n,r){let i=gn(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?_n(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):vn(e,a,r?r(n.value,a):n.value))}}function bn(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?_n(e,n,()=>t[n]):vn(e,n,r.value))}}function xn(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Sn(e){return JSON.stringify(e)}function Cn(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}function wn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Tn(e){if(wn(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return wn(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function En(e){return Tn(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function Dn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function On(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function N(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function kn(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function An(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}function jn(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return yn(i,e,Mn(e,t)),On(e,xn(n,{shape:i,checks:[]}))}function Mn(e,t){let n=gn(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function Nn(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(Mn(e,t)),a={};return yn(a,e,Reflect.ownKeys(gn(e)).filter(e=>!i.has(e))),On(e,xn(n,{shape:a,checks:[]}))}function Pn(e,t){if(!Tn(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=gn(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return On(e,xn(e._zod.def,{shape:Fn(e,t)}))}function Fn(e,t){let n={};return yn(n,e,Reflect.ownKeys(gn(e))),bn(n,t),n}function In(e,t){if(!Tn(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return On(e,xn(e._zod.def,{shape:Fn(e,t)}))}function Ln(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return yn(n,e,Reflect.ownKeys(gn(e))),yn(n,t,Reflect.ownKeys(gn(t))),On(e,xn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Rn(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(Mn(t,n)):void 0,o={};return yn(o,t,Reflect.ownKeys(gn(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),On(t,xn(t._zod.def,{shape:o,checks:[]}))}function zn(e,t,n){let r=n?new Set(Mn(t,n)):void 0,i={};return yn(i,t,Reflect.ownKeys(gn(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),On(t,xn(t._zod.def,{shape:i}))}function Bn(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Vn(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Hn(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Un(e){return typeof e==`string`?e:e?.message}function Wn(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function Gn(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Kn(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:Un(e.inst?._zod.def?.error?.(e))??Un(a?.(e))??Un(t?.error?.(e))??Un(n.customError?.(e))??Un(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}function qn(e){let t=e.length;if(!dr.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function Jn(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Yn(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function Xn(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Zn(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):tr(e,n,r.value)}}function Qn(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function $n(e,t,n){return Qn(e,t,n,!1)}function er(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Qn(this,n,r(this))},set(e){Qn(this,n,e)}})}return t}function tr(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Qn(this,t,n.bind(this))},set(e){Qn(this,t,e)}})}function nr(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}function P(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&fr!==e._zod?fr=void 0:(fr=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,mr);let e=pr;pr=!1;try{let r=n(this);return pr?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),pr||=e,r}catch(n){throw delete this[t],pr||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function rr(e,t,n,r){let i=nr(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}function ir(e){let t=()=>e;return t[hr]=!0,t}var ar,or,sr,cr,lr,ur,dr,fr,pr,mr,hr,gr=t((()=>{Tr(),ar=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}},or=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{},sr=un(()=>{if(wr.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}}),cr=new Set([`string`,`number`,`symbol`]),lr={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ur={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]},dr=/[\uD800-\uDBFF]/,pr=!1,mr={configurable:!0,get(){pr=!0}},hr=`~constantCatch`}));function _r(e){let t=xr;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return xr=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function F(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){br.value=new a(r);try{Object.defineProperty(n,"_zod",br)}finally{br.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),Zn(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?_r(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}function vr(e){return e&&Object.assign(wr,e),wr}var yr,br,xr,Sr,Cr,wr,Tr=t((()=>{gr(),br={value:void 0,enumerable:!1},xr=`captureStackTrace`in Error?Error:null,Sr=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Cr=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},(yr=globalThis).__zod_globalConfig??(yr.__zod_globalConfig={}),wr=globalThis.__zod_globalConfig}));function Er(){let e=this._zod;return e.message??=JSON.stringify(e.def,ln,2),e.message}function Dr(e){this._zod.message=e}function Or(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function kr(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?Or(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Ar(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}var jr,Mr,Nr,Pr,Fr,Ir=t((()=>{Tr(),gr(),jr={get:Er,set:Dr,enumerable:!0,configurable:!0},Mr={value:void 0,enumerable:!1},Nr=new WeakSet([Object.prototype,Error.prototype]),Pr=(e,t)=>{e.name=`$ZodError`,Mr.value=t,Object.defineProperty(e,"issues",Mr),Mr.value=void 0,Object.defineProperty(e,"message",jr);let n=Object.getPrototypeOf(e);Nr.has(n)||(Nr.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},Fr=F(`$ZodError`,Pr)}));function Lr(e,t){return{callee:t?.callee??e,Err:t?.Err}}function Rr(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>Kn(e,n,vr()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}function zr(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[Gr]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new Sr;return a.issues.length===0}var Br,Vr,Hr,Ur,Wr,Gr,Kr,qr,Jr,Yr,Xr,Zr,Qr,$r,ei,ti,ni=t((()=>{Tr(),gr(),Br=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Sr;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>Kn(e,o,vr())));throw or(n,a?.callee??t),n}return s.value};return t},Vr=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>Kn(e,o,vr())));throw or(n,a?.callee??t),n}return s.value};return t},Hr=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Sr;return a.issues.length?Rr(e,a.issues,i):{success:!0,data:a.value}},Ur=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?Rr(e,a.issues,i):{success:!0,data:a.value}},Wr=Symbol.for(`zod.compile.invalid`),Gr=Symbol.for(`zod.compile.fallback`),Kr=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Wr)return!0;if(r.definite===!0&&n===void 0)return!1}return zr(e,t,n)}),qr=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},Jr=e=>{let t=Br(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,Lr(n,a))};return n},Yr=e=>{let t=Br(e),n=(e,r,i,a)=>t(e,r,i,Lr(n,a));return n},Xr=e=>{let t=Vr(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,Lr(n,a))};return n},Zr=e=>{let t=Vr(e),n=async(e,r,i,a)=>await t(e,r,i,Lr(n,a));return n},Qr=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Hr(e)(t,n,i)},$r=e=>(t,n,r)=>Hr(e)(t,n,r),ei=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ur(e)(t,n,i)},ti=e=>async(t,n,r)=>Ur(e)(t,n,r)}));function ri(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}function ii(){return new RegExp(yi,`u`)}function ai(e){return RegExp(`^${e}$`)}function oi(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function si(e){return RegExp(`^${oi(e)}$`)}function ci(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${oi({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${oi({precision:e.precision})}`:n;return RegExp(`^${Oi}T(?:${r})$`)}var li,ui,di,fi,pi,mi,hi,gi,_i,vi,yi,bi,xi,Si,Ci,wi,Ti,Ei,Di,Oi,ki,Ai,ji,Mi,Ni,Pi,Fi,Ii=t((()=>{li=/^[cC][0-9a-z]{6,}$/,ui=/^[0-9a-z]+$/,di=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,fi=/^[0-9a-vA-V]{20}$/,pi=/^[A-Za-z0-9]{27}$/,mi=/^[a-zA-Z0-9_-]{21}$/,hi=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,gi=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,_i=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,vi=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,yi=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,bi=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,xi=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Si=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Ci=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,wi=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ti=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Ei=/^https?$/,Di=/^\+[1-9]\d{6,14}$/,Oi=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,ki=ai(Oi),Ai=/^[\s\S]{0,}$/,ji=/^-?\d+$/,Mi=/^-?\d+(?:\.\d+)?$/,Ni=/^(?:true|false)$/i,Pi=/^[^A-Z]*$/,Fi=/^[^a-z]*$/})),Li,Ri,zi,Bi,Vi,Hi,Ui,Wi,Gi,Ki,qi,Ji,Yi,Xi,Zi,Qi,$i,ea,ta=t((()=>{Tr(),Ii(),gr(),Li=F(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Ri=e=>{let t=e.value;return!dn(t)&&t.length!==void 0},zi={number:`number`,bigint:`bigint`,object:`date`},Bi=F(`$ZodCheckLessThan`,(e,t)=>{Li.init(e,t);let n=zi[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:zi[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Vi=F(`$ZodCheckGreaterThan`,(e,t)=>{Li.init(e,t);let n=zi[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:zi[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Hi=F(`$ZodCheckMultipleOf`,(e,t)=>{Li.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):pn(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Ui=F(`$ZodCheckNumberFormat`,(e,t)=>{Li.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=lr[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Wi=F(`$ZodCheckMaxLength`,(e,t)=>{var n;Li.init(e,t),(n=e._zod.def).when??(n.when=Ri),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?qn(r):i)<=t.maximum)return;let a=Jn(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Gi=F(`$ZodCheckMinLength`,(e,t)=>{var n;Li.init(e,t),(n=e._zod.def).when??(n.when=Ri),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?qn(r):i)>=t.minimum)return;let a=Jn(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Ki=F(`$ZodCheckLengthEquals`,(e,t)=>{var n;Li.init(e,t),(n=e._zod.def).when??(n.when=Ri),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?qn(r):i;if(a===t.length)return;let o=Jn(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),qi=F(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Li.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Ji=F(`$ZodCheckRegex`,(e,t)=>{qi.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Yi=F(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Pi,qi.init(e,t)}),Xi=F(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Fi,qi.init(e,t)}),Zi=F(`$ZodCheckIncludes`,(e,t)=>{Li.init(e,t);let n=Dn(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Qi=F(`$ZodCheckStartsWith`,(e,t)=>{Li.init(e,t);let n=RegExp(`^${Dn(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),$i=F(`$ZodCheckEndsWith`,(e,t)=>{Li.init(e,t);let n=RegExp(`.*${Dn(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),ea=F(`$ZodCheckOverwrite`,(e,t)=>{Li.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}})})),na,ra=t((()=>{na=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
2
|
+
(function(){var e=Object.defineProperty,t=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},n=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};function r(e){e&&e.parentNode&&e.remove()}function i(e,t,n){var r,i,o,s={},c=arguments.length;for(o in t)o==`key`?r=t[o]:o==`ref`&&typeof e!=`function`?i=t[o]:s[o]=t[o];return c>2&&(s.children=c>3?ge.call(arguments,2):n),a(e,s,r,i,null)}function a(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:de,__v:i||++te,__i:-1,__u:0};return!i&&O.vnode&&O.vnode(a),a}function o(){return{current:null}}function s(e){return e.children}function c(e,t){this.props=e,this.context=t,this.__g=0}function l(e,t){if(t==null)return e.__&&l(e.__,e.__i+1);for(var n;t<e.__k.length;t++)if((n=e.__k[t])&&n.__e)return n.__e;return typeof e.type!=`function`||e.props.__P?null:l(e)}function u(e){if((e=e.__)&&e.__c&&!e.props.__P)return e.__e=null,e.__k.some(function(t){return t&&(e.__e=t.__e)}),u(e)}function d(e){(8&e.__g||(e.__g|=8,re.push(e),ae++))&&ie==O.debounceRendering||((ie=O.debounceRendering)||queueMicrotask)(f)}function f(){var e,t,n,r,i,a,o,s,c;try{for(t=1;re.length;)re.length>t&&re.sort(oe),e=re.shift(),t=re.length,8&e.__g&&(r=void 0,i=void 0,a=(i=(n=e).__v).__e,o=[],s=[],(c=n.__P)&&((r=_e({constructor:de},i)).__v=i.__v+1,O.vnode&&O.vnode(r),b(c,r,i,n.__n,c.namespaceURI,32&i.__u?[a]:null,o,a||l(i),32&i.__u,s),r.__v=i.__v,r.__.__k[r.__i]=r,C(o,r,s),i.__=i.__e=null,r.__e!=a&&u(r)))}finally{(ae=re.length)&&(ie||queueMicrotask)(f)}}function p(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,g,_,v,y=r.__k||pe,x=t.length;for(c=m(n,t,y,c,x),d=0;d<x;d++)(p=n.__k[d])!=null&&(f=~p.__i&&y[p.__i]||fe,p.__i=d,v=b(e,p,f,i,a,o,s,c,l,u),g=p.__e,(f.ref!=p.ref||8&f.__u)&&(f.ref&&T(f.ref,null,p,f),p.ref&&u.push(p.ref,p.__c||g,p)),_||=g,4&p.__u?(c=h(p,c,e,!f.__v),f.__e&&(f.__e=null)):typeof p.type==`function`&&v!==void 0?c=v:g&&(c=g.nextSibling),p.__u&=-21);return n.__e=_,c}function m(e,t,n,r,i){var o,c,u,d,f,p,m,h,_,v=n.length,y=v,b=0,x=0,S=e.__k=Array(i);for(o=0;o<i;o++)(c=t[o])!=null&&typeof c!=`boolean`&&typeof c!=`function`?(typeof c!=`object`||c.constructor===String?c=S[o]=a(null,c):he(c)?c=S[o]=a(s,{children:c}):c.constructor===de&&c.__b?c=S[o]=a(c.type,c.props,c.key,c.ref,c.__v):S[o]=c,d=o+b,c.__=e,c.__b=e.__b+1,u=null,~(f=c.__i=g(c,n,d,y))&&(y--,(u=n[f])&&(u.__u|=2)),u&&u.__v?(c.__u|=16,f==d-1?b--:f==d+1?b++:f!=d&&(f>d?b--:b++,x=1)):(~f||(i>v?b--:i<v&&b++),typeof c.type!=`function`&&(c.__u|=4))):S[o]=null;if(x){for(p=[],m=[],o=0;o<i;o++)if((c=S[o])&&16&c.__u){for(b=0,h=p.length;b<h;)p[_=b+h>>1]<c.__i?b=_+1:h=_;p[b]=c.__i,m[o]=b+1}for(b=p.length;o--;)m[o]&&(m[o]==b?b--:S[o].__u|=4)}if(y)for(o=0;o<v;o++)!(u=n[o])||2&u.__u||(u.__e==r&&(r=l(u)),E(u,u));return r}function h(e,t,n,r){var i,a,o,s;if(typeof e.type==`function`){if(e.props.__P)return t;if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&(i[a].__=e,t=h(i[a],t,n,!1));return t}for(t&&!t.parentNode&&(t=l(e))&&!t.parentNode&&(t=null),o=e.__e,s=t;s&&s.nodeType==8;)s=s.nextSibling;for(o!=s&&(!r&&n.moveBefore&&o.parentNode?n.moveBefore(o,t):n.insertBefore(o,t||null)),t=o;(t&&=t.nextSibling)&&t.nodeType==8&&!t.data.startsWith(`$s`););return t}function g(e,t,n,r){var i,a=e.key,o=e.type,s=t[n],c=s&&!(2&s.__u);if(s===null&&a==null||c&&a==s.key&&o==s.type)return n;if(r>+!!c){for(i=n-1;i>=0;i--)if((s=t[i])&&!(2&s.__u)&&a==s.key&&o==s.type)return i;for(i=n+1;i<t.length;i++)if((s=t[i])&&!(2&s.__u)&&a==s.key&&o==s.type)return i}return-1}function _(e,t,n){n??=``,t[0]==`-`?e.setProperty(t,n):e[t]=n}function v(e,t,n,r,i){var a,o;if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||_(e.style,t);if(n)for(t in n)r&&n[t]==r[t]||_(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)(e.__e||={})[t]=n,n&&r||(o=ue[t]||(ue[t]=y(t)),(e.__a||={})[t]=le,a=t!=(t=t.replace(ce,`$1`)),(t=t.slice(2))[0]<`a`&&(t=t.toLowerCase()),n?e.addEventListener(t,o,a):e.removeEventListener(t,o,a));else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;return}catch{}if(typeof n==`function`)return;n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n)}}function y(e){return function(t){var n=this.__e;if(n){if(n=n[e],t[se]==null)t[se]=le++;else if(t[se]<this.__a[e])return;return n(O.event?O.event(t):t)}}}function b(e,t,n,i,a,o,u,d,f,m){var h,g,_,v,y,b,C,T,D,te,ne,re,ie,ae,oe,se,ce,le,ue=t.type;if(t.constructor!==de)return null;128&n.__u&&(f=32&n.__u,h=n.__c.__z)&&(t.__u|=f,g=o=[],h.nodeType==8?d=x(h,o):o.push(h),d=o[0]||d),(h=O.__b)&&h(t);n:if(typeof ue==`function`){_=u.length;try{if(T=t.props,D=(h=ue.prototype)&&h.render,te=(h=ue.contextType)&&i[h.__c],ne=h?te?te.props.value:h.__:i,(v=n.__c)?(t.__c=v,2&v.__g&&(v.__g|=1)):(D?t.__c=v=new ue(T,ne):(t.__c=v=new c(T,ne),v.constructor=ue,v.render=ee),te&&te.sub(v),v.state||(v.state={}),v.__n=i,v.__g|=8,v.__h=[],v.__k=[]),D&&(v.__s||(v.__s=v.state),ue.getDerivedStateFromProps&&(v.__s==v.state&&(v.__s=_e({},v.__s)),_e(v.__s,ue.getDerivedStateFromProps(T,v.__s)))),y=v.props,b=v.state,v.__v=t,n.__c){if(T!==y&&D&&!ue.getDerivedStateFromProps&&v.componentWillReceiveProps&&v.componentWillReceiveProps(T,ne),t.__v==n.__v&&!(8&v.__g)||!(4&v.__g)&&v.shouldComponentUpdate&&!1===v.shouldComponentUpdate(T,v.__s,ne)){t.__v!=n.__v&&(v.props=T,v.state=v.__s,v.__g&=-9),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),pe.push.apply(v.__h,v.__k),v.__k=[],v.__h.length&&u.push(v),d=l(n);break n}v.componentWillUpdate&&v.componentWillUpdate(T,v.__s,ne),D&&v.componentDidUpdate&&v.__h.push(function(){v.componentDidUpdate(y,b,C)})}else D&&!ue.getDerivedStateFromProps&&v.componentWillMount&&v.componentWillMount(),D&&v.componentDidMount&&v.__h.push(v.componentDidMount);if(v.context=ne,v.props=T,v.__P=e,v.__g&=-5,re=O.__r,ie=0,D)v.state=v.__s,v.__g&=-9,re&&re(t),h=v.render(v.props,v.state,v.context),pe.push.apply(v.__h,v.__k),v.__k=[];else do v.__g&=-9,re&&re(t),h=v.render(v.props,v.state,v.context),v.state=v.__s;while(8&v.__g&&++ie<25);v.state=v.__s,v.getChildContext&&(i=_e({},i,v.getChildContext())),D&&n.__c&&v.getSnapshotBeforeUpdate&&(C=v.getSnapshotBeforeUpdate(y,b)),ae=h&&h.type===s&&h.key==null?h.props.children:h,T.__P&&(h=d,a=(e=T.__P).namespaceURI,f=o=null,n.props&&n.props.__P!=e&&(n.__k.some(function(e){e&&E(e,e)}),n.__k=null),d=n.__k?l(n,0):null),d=p(e,he(ae)?ae:[ae],t,n,i,a,o,u,d,f,m),T.__P&&(t.__e=null,d=h),t.__u&=-161,g&&g.some(r),v.__h.length&&u.push(v),1&v.__g&&(v.__g&=-4)}catch(e){if(u.length=_,t.__v=null,f||o){if(e.then){if(oe=0,t.__u|=128|f,o){for(~(ce=o.indexOf(d||void 0))||(ce=o.length);(le=o[ce-1])&&le.nodeType==8;)ce--;for(;ce<o.length;ce++)if(le=o[ce]){if(o[ce]=null,le.nodeType==8){if(le.data.startsWith(`$s`))oe++||(se=le);else if(oe&&le.data.startsWith(`/$s`)&&!--oe)break}else if(!oe)break}}if(!se){for(;d&&d.nodeType==8&&d.nextSibling;)d=d.nextSibling;se=d}(h=x(se=t.__c.__z||(t.__c.__z=se)))?(t.__e=se,d=h):t.__e=d,d&&=d.nextSibling}else o&&o.some(r)}else t.__e=n.__e;t.__k||=n.__k||[],e.then||S(t),O.__e(e,t,n)}}else d=t.__e=w(n.__e,t,n,i,a,o,u,f,m,e);return(h=O.diffed)&&h(t),d}function x(e,t){if(e&&e.nodeType==8&&e.data.startsWith(`$s`))for(var n=1;e=e.nextSibling;){if(e.nodeType==8){if(e.data.startsWith(`$s`))n++;else if(e.data.startsWith(`/$s`)&&!--n)return e}t&&t.push(e)}}function S(e){e&&(e.__c&&(e.__c.__g|=4),e.__k&&e.__k.some(S))}function C(e,t,n){for(var r=0;r<n.length;)T(n[r++],n[r++],n[r++]);O.__c&&O.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){O.__e(e,t.__v)}})}function w(e,t,n,i,a,o,s,c,u,d){var f,m,h,g,_,y,b,x,S,C=n.props||fe,w=t.props,T=t.type;if(T==`svg`?a=`http://www.w3.org/2000/svg`:T==`math`?a=`http://www.w3.org/1998/Math/MathML`:a||=`http://www.w3.org/1999/xhtml`,o){for(f=0;f<o.length;f++)if((_=o[f])&&(T?_.localName==T:_.nodeType==3)){e=_,o[f]=null;break}}if(!e){if(x=d.ownerDocument||document,!T)return x.createTextNode(w);e=x.createElementNS(a,T,w.is&&w),c&&=(O.__m&&O.__m(t,o),!1),o=null}if(T){if(d=T==`template`&&e.content||e,o=T==`textarea`&&w.defaultValue!=null?null:o&&ge.call(d.childNodes),!c&&o)for(C={},f=0;f<e.attributes.length;f++)C[(_=e.attributes[f]).name]=_.value;for(f in C)_=C[f],f==`dangerouslySetInnerHTML`?h=_:f==`children`||f in w||f==`value`&&`defaultValue`in w||f==`checked`&&`defaultChecked`in w||v(e,f,null,_,a);for(f in S=1&n.__u,w)_=w[f],f==`children`?g=_:f==`dangerouslySetInnerHTML`?m=_:f==`value`?y=_:f==`checked`?b=_:c&&typeof _!=`function`||!(C[f]!==_||S&&_!=null)||v(e,f,_,C[f],a);m?(c||h&&(m.__html==h.__html||m.__html==e.innerHTML)||(e.innerHTML=m.__html),t.__k=[]):(h&&(e.textContent=``),(T==`foreignObject`||a==`http://www.w3.org/1998/Math/MathML`&&me.test(T))&&(a=`http://www.w3.org/1999/xhtml`),p(d,he(g)?g:[g],t,n,i,a,o,s,o?o[0]:n.__k&&l(n,0),c,u),o&&o.some(r)),c&&T!=`textarea`||(f=`value`,T==`progress`&&y==null?e.removeAttribute(f):y==null||y===e[f]&&(T!=`progress`||y)||v(e,f,y,C[f],a),f=`checked`,b!=null&&b!=e[f]&&v(e,f,b,C[f],a))}else C===w||c&&e.data==w||(e.data=w);return e}function T(e,t,n,r){try{typeof e==`function`?t?t.__x=e(t)||1:(r&&=r.__c||r.__e)&&(t=r.__x)&&(r.__x=null,typeof t==`function`?t():e(null)):e.current=t}catch(e){O.__e(e,n)}}function E(e,t,n){var i,a,o,s;if(O.unmount&&O.unmount(e),!(i=e.ref)||i.current&&i.current!=e.__e||T(i,null,t,e),i=e.__c){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){O.__e(e,t)}i.__P=i.__n=null}if(i=e.__k)for(s=0;s<i.length;s++)i[s]&&E(i[s],t,typeof e.type!=`function`||n&&!e.props.__P);!n&&(i=e.__c)&&(i=i.__z)&&(a=x(i,o=[]))&&(i==e.__e&&o.some(r),r(a),r(i)),(i=e.__e)&&(n||r(i),i.__e&&(i.__e=null)),e.__e=e.__c=e.__=null}function ee(e,t,n){return this.constructor(e,n)}function D(e,t){var n,r,i,o;O.__&&O.__(e,t),t.nodeType==9&&(t=t.documentElement),r=(n=e&&32&e.__u)?null:t.__k,t.__k=a(s,{children:[e]}),i=[],o=[],b(t,t.__k,r||fe,fe,t.namespaceURI,r?null:t.firstChild?ge.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,o),C(i,t.__k,o),t.__k.props.children=null}var O,te,ne,re,ie,ae,oe,se,ce,le,ue,de,fe,pe,me,he,ge,_e,ve=t((()=>{de=Symbol.for(`pv`),fe={},pe=[],me=/^m(i|n|o|s|text|space)$/,he=Array.isArray,ge=pe.slice,_e=Object.assign,O={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!(1&i.__g)){i.__g|=4;try{if((o=(a=i.constructor)&&a.getDerivedStateFromError)&&i.setState(a.getDerivedStateFromError(e)),i.componentDidCatch&&(i.componentDidCatch(e,r||{}),o=1),o&&8&i.__g)return void(i.__g|=2)}catch(t){e=t}}throw ae=0,e}},te=0,ne=function(e){return e!=null&&e.constructor===de},c.prototype.setState=function(e,t){var n=this.__s;n&&n!=this.state||(n=this.__s=_e({},this.state)),typeof e==`function`&&(e=e(_e({},n),this.props)),e&&(_e(n,e),this.__v&&(t&&this.__k.push(t),d(this)))},c.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),d(this))},c.prototype.render=s,re=[],ae=0,oe=function(e,t){return e.__v.__b-t.__v.__b},se=Symbol(),ce=/(PointerCapture)$|Capture$/i,le=0,ue={}}));function ye(e,t){k.__h&&k.__h(ke,e,Ne||t),Ne=0;var n=ke.__H||(ke.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function be(e,t){var n=ye(Oe++,7);return De(n.__H,t)&&(n.__=e(),n.__H=t),n.__}function xe(){var e=ye(Oe++,11);if(!e.__){for(var t=ke.__v;!t.__m&&t.__;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__=`P`+n[0]+`-`+n[1]++}return e.__}function Se(){var e;do{for(;e=Fe.shift();)try{Te(e)}catch(t){k.__e(t,{__:(e=e.__P)&&e.__v})}for(;e=Pe.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Te),t.__h.some(Ee),t.__h=[]}catch(n){t.__h=[],k.__e(n,e.__v)}}}while(Fe.length)}function Ce(e){var t,n=function(){clearTimeout(r),He&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);He&&(t=requestAnimationFrame(n))}function we(e){e!=1&&je==k.requestAnimationFrame||((je=k.requestAnimationFrame)||Ce)(Se)}function Te(e){var t=ke,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),ke=t}function Ee(e){var t=ke;e.__c=e.__(),ke=t}function De(e,t){return!e||e.length!=t.length||t.some(function(t,n){return!Me(t,e[n])})}var Oe,ke,Ae,je,Me,Ne,Pe,Fe,k,Ie,Le,Re,ze,Be,Ve,He,Ue=t((()=>{ve(),Me=Object.is,Ne=0,Pe=[],Fe=[],k=O,Ie=k.__b,Le=k.__r,Re=k.diffed,ze=k.__c,Be=k.unmount,Ve=k.__,k.__b=function(e){ke=null,Ie&&Ie(e)},k.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Ve&&Ve(e,t)},k.__r=function(e){Le&&Le(e),Oe=0;var t=(ke=e.__c).__H;t&&(Ae==ke?ke.__h=[]:(t.__h.some(Te),t.__h.some(Ee),Oe=0),t.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})),Ae=ke},k.diffed=function(e){Re&&Re(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&we(Pe.push(t)),t.__H.__.some(function(e){e.u&&(e.__H=e.u)})),Ae=ke=null},k.__c=function(e,t){t.some(function(e){try{e.__h.some(Te),e.__h=e.__h.filter(function(e){return!e.__||Ee(e)})}catch(t){e.__h=[function(){throw t}]}}),ze&&ze(e,t)},k.unmount=function(e){Be&&Be(e);var t,n,r=e.__c;r&&r.__H&&(r.__H.__.some(function(r){try{if(r.__P&&r.__c){if(n===void 0){for(n=e.__;n&&(!n.__c||!n.__c.__P);)n=n.__;n&&=n.__c}r.__P=n,we(Fe.push(r))}else Te(r)}catch(e){t=e}}),r.__H=void 0,t&&k.__e(t,r.__v))},He=typeof requestAnimationFrame==`function`}));function We(){if(lt>1)lt--;else{var e,t=!1;for((function(){var e=pt;for(pt=void 0;e!==void 0;){var t=e.S;if(t.v===e.v)for(var n=t.t;n!==void 0;n=n.x)n.i===e.i&&(n.i=t.i);e=e.o}})();ct!==void 0;){var n=ct;for(ct=void 0,ut++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Xe(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(ut=0,lt--,t)throw e}}function Ge(e){if(lt>0)return e();ft=++dt,lt++;try{return e()}finally{We()}}function Ke(e){var t=A,n=st;A=void 0,st=void 0;try{return e()}finally{A=t,st=n}}function qe(e){if(A!==void 0){var t=e.n;if(t===void 0||t.t!==A)return t={i:0,S:e,p:A.s,n:void 0,t:A,e:void 0,x:void 0,r:t},A.s!==void 0&&(A.s.n=t),A.s=t,e.n=t,32&A.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=A.s,t.n=void 0,A.s.n=t,A.s=t),t}}function Je(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}function Ye(e,t){return new Je(e,t)}function Xe(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Ze(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function Qe(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function $e(e,t){Je.call(this,void 0,t),this.x=e,this.s=void 0,this.g=mt-1,this.f=4}function et(e,t){return new $e(e,t)}function tt(e){var t=e.j;if(e.j=void 0,typeof t==`function`){lt++;var n=A;A=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,nt(e),t}finally{A=n,We()}}}function nt(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,tt(e)}function rt(e){if(A!==this)throw Error(`Out-of-order effect`);Qe(this),A=e,this.f&=-2;try{8&this.f&&nt(this)}finally{We()}}function it(e,t){this.x=e,this.j=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,st&&st.push(this)}function at(e,t){var n=new it(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var ot,st,A,ct,lt,ut,dt,ft,pt,mt,ht=t((()=>{ot=Symbol.for(`preact-signals`),A=void 0,ct=void 0,lt=0,ut=0,dt=0,ft=0,pt=void 0,mt=0,Je.prototype.brand=ot,Je.prototype.h=function(){return!0},Je.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n===void 0?Ke(function(){var e;(e=t.W)==null||e.call(t)}):n.e=e)},Je.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&Ke(function(){var e;(e=t.Z)==null||e.call(t)}))}},Je.prototype.subscribe=function(e){var t=this;return at(function(){var n=t.value;Ke(function(){return e(n)})},{name:`sub`})},Je.prototype.valueOf=function(){return this.value},Je.prototype.toString=function(){return this.value+``},Je.prototype.toJSON=function(){return this.value},Je.prototype.peek=function(){var e=this;return Ke(function(){return e.value})},Object.defineProperty(Je.prototype,"value",{get:function(){var e=qe(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(ut>100)throw Error(`Cycle detected`);(function(e){lt!==0&&ut===0&&e.l!==ft&&(e.l=ft,pt={S:e,v:e.v,i:e.i,o:pt})})(this),this.v=e,this.i++,mt++,lt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{We()}}}}),$e.prototype=new Je,$e.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===mt))return!0;if(this.g=mt,this.f|=1,this.i>0&&!Xe(this))return this.f&=-2,!0;var e=A;try{Ze(this),A=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return A=e,Qe(this),this.f&=-2,!0},$e.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}Je.prototype.S.call(this,e)},$e.prototype.U=function(e){if(this.t!==void 0&&(Je.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}},$e.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty($e.prototype,"value",{get:function(){if(1&this.f)throw Error(`Cycle detected`);var e=qe(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),it.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t==`function`&&(this.j=t)}finally{e()}},it.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,tt(this),Ze(this),lt++;var e=A;return A=this,rt.bind(this,e)},it.prototype.N=function(){2&this.f||(this.f|=2,this.u=ct,ct=this)},it.prototype.d=function(){this.f|=8,1&this.f||nt(this)},it.prototype.dispose=function(){this.d()}}));function gt(e,t){O[e]=t.bind(null,O[e]||function(){})}function _t(e){if(wt){var t=wt;wt=void 0,t()}wt=e&&e.S()}function vt(e){var t=this,n=e.data,r=bt(n);r.name=`ReactiveDom`,r.value=n;var i=be(function(){for(var e=t,n=t.__v;n=n.__;)if(n.__c){n.__c.__$f|=4;break}var i=et(function(){var e=r.value.value;return e===0?0:!0===e?``:e||``}),a=et(function(){return!Array.isArray(i.value)&&!ne(i.value)}),o=at(function(){if(this.N=St,a.value){var t=i.value;e.__v&&e.__v.__e&&e.__v.__e.nodeType===3&&(e.__v.__e.data=t)}}),s=t.__$u.d;return t.__$u.d=function(){o(),s.call(this)},[a,i]},[]),a=i[0],o=i[1];return a.value?o.peek():o.value}function yt(e,t,n,r){var i=t in e&&e.ownerSVGElement===void 0,a=Ye(n);return{o:function(e,t){a.value=e,r=t},d:at(function(){this.N=St;var n=a.value.value;r[t]!==n&&(r[t]=n,i?e[t]=n:n!=null&&(!1!==n||t[4]===`-`)?e.setAttribute(t,n):e.removeAttribute(t))})}}function bt(e,t){return be(function(){return Ye(e,t)},[])}function xt(){Ge(function(){for(var e;e=Et.shift();)Ct.call(e)})}function St(){Et.push(this)===1&&(O.requestAnimationFrame||Dt)(xt)}var Ct,wt,Tt,Et,Dt,Ot=t((()=>{ve(),Ue(),ht(),Tt=typeof window<`u`&&!!window.__PREACT_SIGNALS_DEVTOOLS__,Et=[],at(function(){Ct=this.N})(),vt.displayName=`ReactiveTextNode`,Object.defineProperties(Je.prototype,{constructor:{configurable:!0,value:i(s,null).constructor},type:{configurable:!0,value:vt},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}}),gt(`__b`,function(e,t){if(_t(),typeof t.type==`string`){var n,r=t.props;for(var i in r)if(i!==`children`){var a=r[i];a instanceof Je&&(n||(t.__np=n={}),n[i]=a,r[i]=a.peek())}}e(t)}),gt(`__r`,function(e,t){if(e(t),t.type!==s){_t();var n,r=t.__c;r&&(r.__$f&=-2,(n=r.__$u)===void 0&&(r.__$u=n=function(e,t){var n;return at(function(){n=this},{name:t}),n.c=e,n}(function(e){return function(){var t;Tt&&((t=this.y)==null||t.call(this)),e.__$f|=1,e.setState({})}}(r),typeof t.type==`function`?t.type.displayName||t.type.name:``))),_t(n)}}),gt(`__e`,function(e,t,n,r){_t(),e(t,n,r)}),gt(`diffed`,function(e,t){_t();var n;if(typeof t.type==`string`&&(n=t.__e)){var r=t.__np,i=t.props,a=n.U;if(a)for(var o in a){var s=a[o];s===void 0||r&&o in r||(s.d(),a[o]=void 0)}if(r)for(var c in a||(a={},n.U=a),r){var l=a[c],u=r[c];l===void 0?(l=yt(n,c,u,i),a[c]=l):l.o(u,i)}}e(t)}),gt(`unmount`,function(e,t){if(typeof t.type==`string`){var n=t.__e;if(n){var r=n.U;if(r)for(var i in n.U=void 0,r){var a=r[i];a&&a.d()}}var o=t.__np;if(o){var s=t.props;for(var c in o)s[c]=o[c]}t.__np=void 0}else{var l=t.__c;if(l){l.__$f|=8;var u=l.__$u;u&&(l.__$u=void 0,u.d())}}e(t)}),gt(`__h`,function(e,t,n,r){r<3&&(t.__$f|=2),e(t,n,r)}),c.prototype.shouldComponentUpdate=function(e,t){if(this.__R)return!0;var n=this.__$u,r=n&&n.s!==void 0;for(var i in t)return!0;if(this.__f||typeof this.u==`boolean`&&!0===this.u){var a=2&this.__$f;if(!(r||a||4&this.__$f)||1&this.__$f)return!0}else if(!(r||4&this.__$f)||3&this.__$f)return!0;for(var o in e)if(o!==`__source`&&e[o]!==this.props[o])return!0;for(var s in this.props)if(!(s in e))return!0;return!1},Dt=function(e){queueMicrotask(function(){queueMicrotask(e)})}}));Ot();var kt=async({operation:e,signal:t})=>{let n=Promise.withResolvers(),r=()=>n.reject(t.reason);t.addEventListener(`abort`,r,{once:!0}),t.aborted&&r();try{return await Promise.race([e,n.promise])}finally{t.removeEventListener(`abort`,r)}},j,At,jt,Mt,Nt,Pt,Ft=t((()=>{j={INTENT_TOKEN_INVALID:`INTENT_TOKEN_INVALID`,FACEKEY_ALREADY_ENROLLED:`FACEKEY_ALREADY_ENROLLED`,FACEKEY_NOT_ENROLLED:`FACEKEY_NOT_ENROLLED`,FACEKEY_VERSION_MISMATCH:`FACEKEY_VERSION_MISMATCH`,FACEKEY_KEY_UNAVAILABLE:`FACEKEY_KEY_UNAVAILABLE`,FACEKEY_TEMPLATE_INVALID:`FACEKEY_TEMPLATE_INVALID`,OPERATION_CANCELLED:`OPERATION_CANCELLED`,OPERATION_TIMEOUT:`OPERATION_TIMEOUT`,CLIENT_KEY_REQUIRED:`CLIENT_KEY_REQUIRED`,API_KEY_FORBIDDEN:`API_KEY_FORBIDDEN`,CAMERA_INTERRUPTED:`CAMERA_INTERRUPTED`,CAMERA_NOT_FOUND:`CAMERA_NOT_FOUND`,CAMERA_PERMISSION_DENIED:`CAMERA_PERMISSION_DENIED`,CAMERA_UNAVAILABLE:`CAMERA_UNAVAILABLE`,CAMERA_UNSUPPORTED:`CAMERA_UNSUPPORTED`,CAPTURES_INCOMPLETE:`CAPTURES_INCOMPLETE`,CLIENT_ASSET_NOT_FOUND:`CLIENT_ASSET_NOT_FOUND`,CLIENT_NOT_AVAILABLE:`CLIENT_NOT_AVAILABLE`,CONTACT_RATE_LIMITED:`CONTACT_RATE_LIMITED`,DOCUMENT_BACK_CONTAINS_FACE:`DOCUMENT_BACK_CONTAINS_FACE`,DOCUMENT_BACK_NOT_DISTINCT:`DOCUMENT_BACK_NOT_DISTINCT`,DOCUMENT_BACK_REQUIRED:`DOCUMENT_BACK_REQUIRED`,DOCUMENT_BLURRY:`DOCUMENT_BLURRY`,DOCUMENT_CODE_TYPE_MISMATCH:`DOCUMENT_CODE_TYPE_MISMATCH`,DOCUMENT_FACE_GEOMETRY_INVALID:`DOCUMENT_FACE_GEOMETRY_INVALID`,DOCUMENT_FACE_NOT_CONTAINED:`DOCUMENT_FACE_NOT_CONTAINED`,DOCUMENT_FACE_NOT_FOUND:`DOCUMENT_FACE_NOT_FOUND`,DOCUMENT_NOT_FOUND:`DOCUMENT_NOT_FOUND`,DOCUMENT_NOT_RECOGNIZED:`DOCUMENT_NOT_RECOGNIZED`,DOCUMENT_TEXT_ALIGNMENT_INVALID:`DOCUMENT_TEXT_ALIGNMENT_INVALID`,DOCUMENT_TEXT_NOT_READABLE:`DOCUMENT_TEXT_NOT_READABLE`,DOCUMENT_VALIDATION_FAILED:`DOCUMENT_VALIDATION_FAILED`,EMAIL_ALREADY_REGISTERED:`EMAIL_ALREADY_REGISTERED`,EMAIL_DELIVERY_FAILED:`EMAIL_DELIVERY_FAILED`,EUROPEAN_LICENCE_BACK_MARKER_REQUIRED:`EUROPEAN_LICENCE_BACK_MARKER_REQUIRED`,FACE_AGE_MISMATCH:`FACE_AGE_MISMATCH`,FACE_ALIGNMENT_FAILED:`FACE_ALIGNMENT_FAILED`,FACE_ATTRIBUTES_UNAVAILABLE:`FACE_ATTRIBUTES_UNAVAILABLE`,FACE_GENDER_MISMATCH:`FACE_GENDER_MISMATCH`,FACE_LIGHTING_INVALID:`FACE_LIGHTING_INVALID`,FACE_MISMATCH:`FACE_MISMATCH`,FACE_NOT_FOUND:`FACE_NOT_FOUND`,FACE_NOT_STABLE:`FACE_NOT_STABLE`,FACE_NOT_USABLE:`FACE_NOT_USABLE`,FACE_OUT_OF_FRAME:`FACE_OUT_OF_FRAME`,FACE_POSE_INVALID:`FACE_POSE_INVALID`,FACE_SPOOF_DETECTED:`FACE_SPOOF_DETECTED`,GEO_DATABASE_DOWNLOAD_EMPTY:`GEO_DATABASE_DOWNLOAD_EMPTY`,GEO_DATABASE_DOWNLOAD_FAILED:`GEO_DATABASE_DOWNLOAD_FAILED`,IMAGE_DECODE_FAILED:`IMAGE_DECODE_FAILED`,IMAGE_ENCODE_FAILED:`IMAGE_ENCODE_FAILED`,IMAGE_PROCESSING_FAILED:`IMAGE_PROCESSING_FAILED`,IMAGE_TOO_LARGE:`IMAGE_TOO_LARGE`,INFERENCE_FAILED:`INFERENCE_FAILED`,INFERENCE_QUEUE_FULL:`INFERENCE_QUEUE_FULL`,INFERENCE_TIMEOUT:`INFERENCE_TIMEOUT`,VALIDATION_ERROR:`VALIDATION_ERROR`,RESPONSE_VALIDATION_ERROR:`RESPONSE_VALIDATION_ERROR`,RESOURCE_NOT_FOUND:`RESOURCE_NOT_FOUND`,RESOURCE_NOT_FOUND_IN_VIEW:`RESOURCE_NOT_FOUND_IN_VIEW`,REQUEST_TOO_LARGE:`REQUEST_TOO_LARGE`,INTERNAL_ERROR:`INTERNAL_ERROR`,INVALID_CREDENTIALS:`INVALID_CREDENTIALS`,BILLING_DETAILS_REQUIRED:`BILLING_DETAILS_REQUIRED`,PAYMENT_METHOD_NOT_FOUND:`PAYMENT_METHOD_NOT_FOUND`,PAYMENT_NOT_FOUND:`PAYMENT_NOT_FOUND`,RECOVERY_SENT:`RECOVERY_SENT`,INVALID_DOCUMENT_AAMVA:`INVALID_DOCUMENT_AAMVA`,INVALID_DOCUMENT_MRZ:`INVALID_DOCUMENT_MRZ`,INVALID_FACE_MATCH_INPUT:`INVALID_FACE_MATCH_INPUT`,INVALID_IMAGE:`INVALID_IMAGE`,INVALID_KEY_LABEL:`INVALID_KEY_LABEL`,INVALID_MODEL_OUTPUT:`INVALID_MODEL_OUTPUT`,INVALID_OPTIONS:`INVALID_OPTIONS`,INVALID_PASSPORT_MRZ:`INVALID_PASSPORT_MRZ`,INVALID_POSES:`INVALID_POSES`,INVALID_CLIENT_KEY:`INVALID_CLIENT_KEY`,INVALID_REGISTRATION:`INVALID_REGISTRATION`,INVALID_SERVICE_RESPONSE:`INVALID_SERVICE_RESPONSE`,INVALID_VERIFICATION_FEEDBACK:`INVALID_VERIFICATION_FEEDBACK`,INVALID_VERIFICATION_INPUT:`INVALID_VERIFICATION_INPUT`,KEY_NOT_FOUND:`KEY_NOT_FOUND`,MODEL_LOAD_FAILED:`MODEL_LOAD_FAILED`,MULTIPLE_FACES:`MULTIPLE_FACES`,NETWORK_ERROR:`NETWORK_ERROR`,NO_USABLE_CANDIDATES:`NO_USABLE_CANDIDATES`,NO_USABLE_REFERENCES:`NO_USABLE_REFERENCES`,OCR_DICTIONARY_MISMATCH:`OCR_DICTIONARY_MISMATCH`,OCR_ENVIRONMENT_MISMATCH:`OCR_ENVIRONMENT_MISMATCH`,OCR_LANGUAGE_UNSUPPORTED:`OCR_LANGUAGE_UNSUPPORTED`,OCR_MODEL_UNSUPPORTED:`OCR_MODEL_UNSUPPORTED`,PAYMENT_FAILED:`PAYMENT_FAILED`,BILLING_ACCOUNT_BLOCKED:`BILLING_ACCOUNT_BLOCKED`,ACCOUNT_HAS_UNBILLED_USAGE:`ACCOUNT_HAS_UNBILLED_USAGE`,POSE_IDENTITY_MISMATCH:`POSE_IDENTITY_MISMATCH`,POSE_BACKGROUND_MISMATCH:`POSE_BACKGROUND_MISMATCH`,SERVICE_UNAVAILABLE:`SERVICE_UNAVAILABLE`,SUPERADMIN_REQUIRED:`SUPERADMIN_REQUIRED`,UI_ELEMENT_NOT_FOUND:`UI_ELEMENT_NOT_FOUND`,UNAUTHORIZED:`UNAUTHORIZED`,USER_ACCESS_REQUIRED:`USER_ACCESS_REQUIRED`,USER_NOT_FOUND:`USER_NOT_FOUND`,VERIFICATION_SAVE_FAILED:`VERIFICATION_SAVE_FAILED`,INVALID_PDF:`INVALID_PDF`,PDF_LOAD_FAILED:`PDF_LOAD_FAILED`,PDF_PASSWORD_REQUIRED:`PDF_PASSWORD_REQUIRED`,SDK_CAPABILITY_NOT_CONFIGURED:`SDK_CAPABILITY_NOT_CONFIGURED`,SDK_DISPOSED:`SDK_DISPOSED`,OPERATION_IN_PROGRESS:`OPERATION_IN_PROGRESS`,AUTHORIZATION_FAILED:`AUTHORIZATION_FAILED`},At=new Set(Object.values(j)),jt=e=>typeof e==`string`&&At.has(e),Mt={FACEKEY_TOKEN_INVALID:j.INTENT_TOKEN_INVALID,FACEGATE_TOKEN_INVALID:j.INTENT_TOKEN_INVALID,FACEGATE_ABORTED:j.OPERATION_CANCELLED,VERIFICATION_CANCELLED:j.OPERATION_CANCELLED,FACEGATE_TIMEOUT:j.OPERATION_TIMEOUT,SDK_NOT_READY:j.SDK_DISPOSED},Nt=e=>typeof e==`string`&&Object.hasOwn(Mt,e)?Mt[e]:e,Pt=({error:e,fallback:t=j.INTERNAL_ERROR})=>{if(typeof e==`object`&&e&&`code`in e&&jt(e.code))return e.code;let n=e instanceof Error?e.message:e;return jt(n)?n:t}})),It,Lt=t((()=>{It={INTENT_TOKEN_INVALID:`The intent token is invalid, expired, or already used.`,FACEKEY_ALREADY_ENROLLED:`This subject already has a FaceKey.`,FACEKEY_NOT_ENROLLED:`This subject does not have a FaceKey.`,FACEKEY_VERSION_MISMATCH:`The FaceKey version is incompatible. Enroll again.`,FACEKEY_KEY_UNAVAILABLE:`The FaceKey encryption key is unavailable.`,FACEKEY_TEMPLATE_INVALID:`The stored FaceKey template is invalid.`,OPERATION_CANCELLED:`The operation was cancelled.`,OPERATION_TIMEOUT:`The operation exceeded its time limit.`,CLIENT_KEY_REQUIRED:`A client key is required.`,API_KEY_FORBIDDEN:`This API key cannot access this resource.`,CAMERA_INTERRUPTED:`Camera capture was interrupted.`,CAMERA_NOT_FOUND:`No camera was found.`,CAMERA_PERMISSION_DENIED:`Camera permission was denied.`,CAMERA_UNAVAILABLE:`The camera is unavailable.`,CAMERA_UNSUPPORTED:`This browser does not support camera access.`,CAPTURES_INCOMPLETE:`Some required captures are missing.`,CLIENT_ASSET_NOT_FOUND:`The requested client asset was not found.`,CLIENT_NOT_AVAILABLE:`The client is unavailable.`,CONTACT_RATE_LIMITED:`Too many contact requests were sent. Try again later.`,DOCUMENT_BACK_CONTAINS_FACE:`The document back contains a face. Show the back of the document.`,DOCUMENT_BACK_NOT_DISTINCT:`The document back must differ from the front.`,DOCUMENT_BACK_REQUIRED:`The document back is required.`,DOCUMENT_BLURRY:`The document image is blurry.`,DOCUMENT_CODE_TYPE_MISMATCH:`The document code does not match the document type.`,DOCUMENT_FACE_GEOMETRY_INVALID:`The document photo size or position is invalid.`,DOCUMENT_FACE_NOT_CONTAINED:`The document photo is not fully visible.`,DOCUMENT_FACE_NOT_FOUND:`No face was found on the document.`,DOCUMENT_NOT_FOUND:`No document was found.`,DOCUMENT_NOT_RECOGNIZED:`The document could not be recognized.`,DOCUMENT_TEXT_ALIGNMENT_INVALID:`The document text alignment is invalid.`,DOCUMENT_TEXT_NOT_READABLE:`The document text is not readable.`,DOCUMENT_VALIDATION_FAILED:`The document could not be validated.`,EMAIL_ALREADY_REGISTERED:`This email address is already registered.`,EMAIL_DELIVERY_FAILED:`The email could not be sent.`,EUROPEAN_LICENCE_BACK_MARKER_REQUIRED:`The licence back marker is missing.`,FACE_AGE_MISMATCH:`The detected age is outside the requested range.`,FACE_ALIGNMENT_FAILED:`The face could not be aligned.`,FACE_ATTRIBUTES_UNAVAILABLE:`The face attributes could not be detected.`,FACE_GENDER_MISMATCH:`The detected gender does not match the requested gender.`,FACE_LIGHTING_INVALID:`The face lighting is unsuitable.`,FACE_MISMATCH:`The faces do not match.`,FACE_NOT_FOUND:`No face was found.`,FACE_NOT_STABLE:`The face did not remain still.`,FACE_NOT_USABLE:`The face image is unsuitable for analysis.`,FACE_OUT_OF_FRAME:`The face is outside the frame.`,FACE_POSE_INVALID:`The face pose is invalid.`,FACE_SPOOF_DETECTED:`A spoof attempt was detected. Present a live face.`,GEO_DATABASE_DOWNLOAD_EMPTY:`The location database download was empty.`,GEO_DATABASE_DOWNLOAD_FAILED:`The location database could not be downloaded.`,IMAGE_DECODE_FAILED:`The image could not be decoded.`,IMAGE_ENCODE_FAILED:`The image could not be encoded.`,IMAGE_PROCESSING_FAILED:`The image could not be processed.`,IMAGE_TOO_LARGE:`The image exceeds the size limit.`,INFERENCE_FAILED:`Image analysis failed.`,INFERENCE_QUEUE_FULL:`Image analysis capacity is full. Try again later.`,INFERENCE_TIMEOUT:`Image analysis exceeded its time limit.`,VALIDATION_ERROR:`The request data is invalid.`,RESPONSE_VALIDATION_ERROR:`The service response failed validation.`,RESOURCE_NOT_FOUND:`The requested resource was not found.`,RESOURCE_NOT_FOUND_IN_VIEW:`The requested resource is not available in this view.`,REQUEST_TOO_LARGE:`The request exceeds the size limit.`,INTERNAL_ERROR:`An internal error occurred.`,INVALID_CREDENTIALS:`The credentials are invalid.`,BILLING_DETAILS_REQUIRED:`Billing details are required.`,PAYMENT_METHOD_NOT_FOUND:`No payment method was found.`,PAYMENT_NOT_FOUND:`The payment was not found.`,RECOVERY_SENT:`A recovery email was sent.`,INVALID_DOCUMENT_AAMVA:`The document barcode is invalid.`,INVALID_DOCUMENT_MRZ:`The document machine readable zone is invalid.`,INVALID_FACE_MATCH_INPUT:`The face matching input is invalid.`,INVALID_IMAGE:`The image is invalid.`,INVALID_KEY_LABEL:`The key label is invalid.`,INVALID_MODEL_OUTPUT:`Image analysis returned invalid output.`,INVALID_OPTIONS:`The SDK options are invalid.`,INVALID_PASSPORT_MRZ:`The passport machine readable zone is invalid.`,INVALID_POSES:`The face pose sequence is invalid.`,INVALID_CLIENT_KEY:`The client key is invalid.`,INVALID_REGISTRATION:`The registration data is invalid.`,INVALID_SERVICE_RESPONSE:`The service returned an invalid response.`,INVALID_VERIFICATION_FEEDBACK:`The verification feedback is invalid.`,INVALID_VERIFICATION_INPUT:`The verification input is invalid.`,KEY_NOT_FOUND:`The key was not found.`,MODEL_LOAD_FAILED:`The analysis assets could not be loaded.`,MULTIPLE_FACES:`More than one face was found.`,NETWORK_ERROR:`The network request failed.`,NO_USABLE_CANDIDATES:`No usable candidate face was found.`,NO_USABLE_REFERENCES:`No usable reference face was found.`,OCR_DICTIONARY_MISMATCH:`The text recognition dictionary is incompatible.`,OCR_ENVIRONMENT_MISMATCH:`The text recognition environment is incompatible.`,OCR_LANGUAGE_UNSUPPORTED:`The text recognition language is unsupported.`,OCR_MODEL_UNSUPPORTED:`The text recognition model is unsupported.`,PAYMENT_FAILED:`The payment failed.`,BILLING_ACCOUNT_BLOCKED:`The billing account is blocked.`,ACCOUNT_HAS_UNBILLED_USAGE:`The account has unbilled usage.`,POSE_IDENTITY_MISMATCH:`The face images show different identities.`,POSE_BACKGROUND_MISMATCH:`The face images show different backgrounds.`,SERVICE_UNAVAILABLE:`The service is unavailable.`,SUPERADMIN_REQUIRED:`Administrator access is required.`,UI_ELEMENT_NOT_FOUND:`A required SDK UI element was not found.`,UNAUTHORIZED:`Authentication is required.`,USER_ACCESS_REQUIRED:`User access is required.`,USER_NOT_FOUND:`The user was not found.`,VERIFICATION_SAVE_FAILED:`The verification could not be saved.`,INVALID_PDF:`The PDF is invalid.`,PDF_LOAD_FAILED:`PDF support could not be loaded.`,PDF_PASSWORD_REQUIRED:`Password protected PDFs are not supported.`,SDK_CAPABILITY_NOT_CONFIGURED:`This SDK capability is not configured.`,SDK_DISPOSED:`This SDK instance was disposed.`,OPERATION_IN_PROGRESS:`An SDK operation is already in progress.`,AUTHORIZATION_FAILED:`The authorization callback failed.`}})),M,Rt,zt,Bt=t((()=>{Ft(),Lt(),M=({code:e,cause:t,status:n,resultId:r})=>Object.assign(Error(It[e],{cause:t}),{name:`VoltomSdkError`,code:e,...n===void 0?{}:{status:n},...r===void 0?{}:{resultId:r}}),Rt=e=>typeof e==`object`&&!!e&&`name`in e&&e.name===`VoltomSdkError`&&`message`in e&&typeof e.message==`string`&&`code`in e&&jt(e.code),zt=({error:e,fallback:t=j.INTERNAL_ERROR,signal:n})=>{if(n?.aborted){let t=Pt({error:n.reason,fallback:j.OPERATION_CANCELLED})===j.OPERATION_TIMEOUT?j.OPERATION_TIMEOUT:j.OPERATION_CANCELLED;return M({code:t,cause:e})}if(Rt(e))return e;let r=typeof e==`object`&&e&&`status`in e&&typeof e.status==`number`?e.status:void 0,i=typeof e==`object`&&e&&`resultId`in e&&typeof e.resultId==`string`?e.resultId:void 0;return M({code:Pt({error:e,fallback:t}),cause:e,status:r,resultId:i})}}));function Vt(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function Ht(e,t=`|`){return e.map(e=>un(e)).join(t)}function Ut(e,t){return typeof t==`bigint`?t.toString():t}function Wt(e){return new Bn(e)}function Gt(e){return e==null}function Kt(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function qt(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function Jt(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Yt(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function Xt(e){return Yt(e._zod.def)??e._zod.def.shape}function Zt(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return Jt(this,t,e),e},enumerable:!0,configurable:!0})}function Qt(e,t,n){t in e?Jt(e,t,n):e[t]=n}function $t(e,t,n,r){let i=Xt(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?Zt(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):Qt(e,a,r?r(n.value,a):n.value))}}function en(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?Zt(e,n,()=>t[n]):Qt(e,n,r.value))}}function tn(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function nn(e){return JSON.stringify(e)}function rn(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}function an(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function on(e){if(an(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return an(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function sn(e){return on(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function cn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function ln(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function N(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function un(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function dn(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}function fn(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return $t(i,e,pn(e,t)),ln(e,tn(n,{shape:i,checks:[]}))}function pn(e,t){let n=Xt(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function mn(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(pn(e,t)),a={};return $t(a,e,Reflect.ownKeys(Xt(e)).filter(e=>!i.has(e))),ln(e,tn(n,{shape:a,checks:[]}))}function hn(e,t){if(!on(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=Xt(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return ln(e,tn(e._zod.def,{shape:gn(e,t)}))}function gn(e,t){let n={};return $t(n,e,Reflect.ownKeys(Xt(e))),en(n,t),n}function _n(e,t){if(!on(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return ln(e,tn(e._zod.def,{shape:gn(e,t)}))}function vn(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return $t(n,e,Reflect.ownKeys(Xt(e))),$t(n,t,Reflect.ownKeys(Xt(t))),ln(e,tn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function yn(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(pn(t,n)):void 0,o={};return $t(o,t,Reflect.ownKeys(Xt(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),ln(t,tn(t._zod.def,{shape:o,checks:[]}))}function bn(e,t,n){let r=n?new Set(pn(t,n)):void 0,i={};return $t(i,t,Reflect.ownKeys(Xt(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),ln(t,tn(t._zod.def,{shape:i}))}function xn(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Sn(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Cn(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function wn(e){return typeof e==`string`?e:e?.message}function Tn(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function En(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Dn(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:wn(e.inst?._zod.def?.error?.(e))??wn(a?.(e))??wn(t?.error?.(e))??wn(n.customError?.(e))??wn(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}function On(e){let t=e.length;if(!Kn.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function kn(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function An(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function jn(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Mn(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):In(e,n,r.value)}}function Nn(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Pn(e,t,n){return Nn(e,t,n,!1)}function Fn(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Nn(this,n,r(this))},set(e){Nn(this,n,e)}})}return t}function In(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Nn(this,t,n.bind(this))},set(e){Nn(this,t,e)}})}function Ln(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}function P(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&qn!==e._zod?qn=void 0:(qn=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Yn);let e=Jn;Jn=!1;try{let r=n(this);return Jn?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Jn||=e,r}catch(n){throw delete this[t],Jn||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function Rn(e,t,n,r){let i=Ln(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}function zn(e){let t=()=>e;return t[Xn]=!0,t}var Bn,Vn,Hn,Un,Wn,Gn,Kn,qn,Jn,Yn,Xn,Zn=t((()=>{or(),Bn=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}},Vn=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{},Hn=Wt(()=>{if(ar.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}}),Un=new Set([`string`,`number`,`symbol`]),Wn={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Gn={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]},Kn=/[\uD800-\uDBFF]/,Jn=!1,Yn={configurable:!0,get(){Jn=!0}},Xn=`~constantCatch`}));function Qn(e){let t=nr;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return nr=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function F(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){tr.value=new a(r);try{Object.defineProperty(n,"_zod",tr)}finally{tr.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),Mn(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?Qn(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}function $n(e){return e&&Object.assign(ar,e),ar}var er,tr,nr,rr,ir,ar,or=t((()=>{Zn(),tr={value:void 0,enumerable:!1},nr=`captureStackTrace`in Error?Error:null,rr=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},ir=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},(er=globalThis).__zod_globalConfig??(er.__zod_globalConfig={}),ar=globalThis.__zod_globalConfig}));function sr(){let e=this._zod;return e.message??=JSON.stringify(e.def,Ut,2),e.message}function cr(e){this._zod.message=e}function lr(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function ur(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?lr(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function dr(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}var fr,pr,mr,hr,gr,_r=t((()=>{or(),Zn(),fr={get:sr,set:cr,enumerable:!0,configurable:!0},pr={value:void 0,enumerable:!1},mr=new WeakSet([Object.prototype,Error.prototype]),hr=(e,t)=>{e.name=`$ZodError`,pr.value=t,Object.defineProperty(e,"issues",pr),pr.value=void 0,Object.defineProperty(e,"message",fr);let n=Object.getPrototypeOf(e);mr.has(n)||(mr.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},gr=F(`$ZodError`,hr)}));function vr(e,t){return{callee:t?.callee??e,Err:t?.Err}}function yr(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>Dn(e,n,$n()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}function br(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[Er]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new rr;return a.issues.length===0}var xr,Sr,Cr,wr,Tr,Er,Dr,Or,kr,Ar,jr,Mr,Nr,Pr,Fr,Ir,Lr=t((()=>{or(),Zn(),xr=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new rr;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>Dn(e,o,$n())));throw Vn(n,a?.callee??t),n}return s.value};return t},Sr=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>Dn(e,o,$n())));throw Vn(n,a?.callee??t),n}return s.value};return t},Cr=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new rr;return a.issues.length?yr(e,a.issues,i):{success:!0,data:a.value}},wr=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?yr(e,a.issues,i):{success:!0,data:a.value}},Tr=Symbol.for(`zod.compile.invalid`),Er=Symbol.for(`zod.compile.fallback`),Dr=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Tr)return!0;if(r.definite===!0&&n===void 0)return!1}return br(e,t,n)}),Or=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},kr=e=>{let t=xr(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,vr(n,a))};return n},Ar=e=>{let t=xr(e),n=(e,r,i,a)=>t(e,r,i,vr(n,a));return n},jr=e=>{let t=Sr(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,vr(n,a))};return n},Mr=e=>{let t=Sr(e),n=async(e,r,i,a)=>await t(e,r,i,vr(n,a));return n},Nr=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Cr(e)(t,n,i)},Pr=e=>(t,n,r)=>Cr(e)(t,n,r),Fr=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return wr(e)(t,n,i)},Ir=e=>async(t,n,r)=>wr(e)(t,n,r)}));function Rr(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}function zr(){return new RegExp(ei,`u`)}function Br(e){return RegExp(`^${e}$`)}function Vr(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Hr(e){return RegExp(`^${Vr(e)}$`)}function Ur(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${Vr({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${Vr({precision:e.precision})}`:n;return RegExp(`^${li}T(?:${r})$`)}var Wr,Gr,Kr,qr,Jr,Yr,Xr,Zr,Qr,$r,ei,ti,ni,ri,ii,ai,oi,si,ci,li,ui,di,fi,pi,mi,hi,gi,_i=t((()=>{Wr=/^[cC][0-9a-z]{6,}$/,Gr=/^[0-9a-z]+$/,Kr=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,qr=/^[0-9a-vA-V]{20}$/,Jr=/^[A-Za-z0-9]{27}$/,Yr=/^[a-zA-Z0-9_-]{21}$/,Xr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Zr=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Qr=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,$r=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,ei=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,ti=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ni=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,ri=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,ii=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ai=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,oi=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,si=/^https?$/,ci=/^\+[1-9]\d{6,14}$/,li=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,ui=Br(li),di=/^[\s\S]{0,}$/,fi=/^-?\d+$/,pi=/^-?\d+(?:\.\d+)?$/,mi=/^(?:true|false)$/i,hi=/^[^A-Z]*$/,gi=/^[^a-z]*$/})),vi,yi,bi,xi,Si,Ci,wi,Ti,Ei,Di,Oi,ki,Ai,ji,Mi,Ni,Pi,Fi,Ii=t((()=>{or(),_i(),Zn(),vi=F(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),yi=e=>{let t=e.value;return!Gt(t)&&t.length!==void 0},bi={number:`number`,bigint:`bigint`,object:`date`},xi=F(`$ZodCheckLessThan`,(e,t)=>{vi.init(e,t);let n=bi[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:bi[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Si=F(`$ZodCheckGreaterThan`,(e,t)=>{vi.init(e,t);let n=bi[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:bi[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ci=F(`$ZodCheckMultipleOf`,(e,t)=>{vi.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):qt(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),wi=F(`$ZodCheckNumberFormat`,(e,t)=>{vi.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Wn[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Ti=F(`$ZodCheckMaxLength`,(e,t)=>{var n;vi.init(e,t),(n=e._zod.def).when??(n.when=yi),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?On(r):i)<=t.maximum)return;let a=kn(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Ei=F(`$ZodCheckMinLength`,(e,t)=>{var n;vi.init(e,t),(n=e._zod.def).when??(n.when=yi),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?On(r):i)>=t.minimum)return;let a=kn(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Di=F(`$ZodCheckLengthEquals`,(e,t)=>{var n;vi.init(e,t),(n=e._zod.def).when??(n.when=yi),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?On(r):i;if(a===t.length)return;let o=kn(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Oi=F(`$ZodCheckStringFormat`,(e,t)=>{var n,r;vi.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),ki=F(`$ZodCheckRegex`,(e,t)=>{Oi.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ai=F(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=hi,Oi.init(e,t)}),ji=F(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=gi,Oi.init(e,t)}),Mi=F(`$ZodCheckIncludes`,(e,t)=>{vi.init(e,t);let n=cn(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Ni=F(`$ZodCheckStartsWith`,(e,t)=>{vi.init(e,t);let n=RegExp(`^${cn(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Pi=F(`$ZodCheckEndsWith`,(e,t)=>{vi.init(e,t);let n=RegExp(`.*${cn(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Fi=F(`$ZodCheckOverwrite`,(e,t)=>{vi.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}})})),Li,Ri=t((()=>{Li=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
3
3
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
|
|
4
|
-
`)}\n};`)(...Object.values(this.closed))}}})),ia,aa=t((()=>{ia={major:4,minor:6,patch:7}}));async function oa(e,t){let n={async:!0};return Pa(await e._zod.run({value:t,issues:[]},n),n)}function sa(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Pa(r,n)}catch{}return oa(e,t)},vendor:`zod`,version:1}}function ca(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function la(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?ca(e)||2:ua(e,t)}function ua(e,t){if(!t.normalize&&t.protocol?.source===Ei.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}function da(e){return e.replace(za,``)}function fa(e,t){return t.lastIndex=0,t.test(e.hostname)}function pa(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}function ma(e){return $a.test(e)?ca(`http://[${e}]`):!1}function ha(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:ma(n)}function ga(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}function _a(e){if(!ao.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return ga(t.padEnd(Math.ceil(t.length/4)*4,`=`))}function va(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}function ya(e,t){let n=Wn(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of Wn(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,Gn(n.issues,t,e),n}}return i(n,a)}}function ba(e,t,n){e.issues.length&&t.issues.push(...Hn(n,e.issues)),t.value[n]=e.value}function xa(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...Hn(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}function Sa(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:_o,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=An(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Ca(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(Bn(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>xa(e,n,i,t,d,f))):xa(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}function wa(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Bn(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Kn(e,r,vr())))}),t)}function Ta(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Tn(e)&&Tn(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=Ta(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Ta(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ea(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=Ta(t.value,n.value);if(!c.valid){if(Bn(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}function Da(e,t){return e.value=t.issues.length?void 0:t.value,e}function Oa(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}function ka(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function Aa(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>Kn(e,r,vr()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}function ja(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}function Ma(e){return e.memo||(e.value=Object.freeze(e.value)),e}function Na(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Xn(e))}}var I,Pa,Fa,L,Ia,La,Ra,za,Ba,Va,Ha,Ua,Wa,Ga,Ka,qa,Ja,Ya,Xa,Za,Qa,$a,eo,to,no,ro,io,ao,oo,so,co,lo,uo,fo,po,mo,ho,go,_o,vo,yo,bo,xo,So,Co,wo,To,Eo,Do,Oo,ko,Ao,jo,Mo,No,Po,Fo,Io=t((()=>{ta(),Tr(),ra(),Ii(),gr(),aa(),I=F(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ia;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=Bn(t),a;for(let o of n){if(o._zod.def.when){if(Vn(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new Sr;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(Gn(t.issues,n,e),i||=Bn(t,n))});else{if(t.issues.length===n)continue;Gn(t.issues,n,e),i||=Bn(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(Bn(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new Sr;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new Sr;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return $n(this,`~standard`,sa(this))},set"~standard"(e){Qn(this,`~standard`,e)}}),Pa=(e,t)=>e.issues.length?{issues:e.issues.map(e=>Kn(e,t,vr()))}:{value:e.value},Fa=F(`$ZodString`,(e,t)=>{I.init(e,t),e._zod.pattern=t.pattern??Ai,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),L=F(`$ZodStringFormat`,(e,t)=>{qi.init(e,t),Fa.init(e,t)}),Ia=F(`$ZodGUID`,(e,t)=>{t.pattern??=gi,L.init(e,t)}),La=F(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=_i(e)}else t.pattern??=_i();L.init(e,t)}),Ra=F(`$ZodEmail`,(e,t)=>{t.pattern??=vi,L.init(e,t)}),za=/[\t\n\r]/g,Ba=F(`$ZodURL`,(e,t)=>{L.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=la(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=da(r);return}t.hostname&&!fa(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!pa(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:da(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Va=F(`$ZodEmoji`,(e,t)=>{t.pattern??=ii(),L.init(e,t)}),Ha=F(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?mi:ri(t.length),L.init(e,t)}),Ua=F(`$ZodCUID`,(e,t)=>{t.pattern??=li,L.init(e,t)}),Wa=F(`$ZodCUID2`,(e,t)=>{t.pattern??=ui,L.init(e,t)}),Ga=F(`$ZodULID`,(e,t)=>{t.pattern??=di,L.init(e,t)}),Ka=F(`$ZodXID`,(e,t)=>{t.pattern??=fi,L.init(e,t)}),qa=F(`$ZodKSUID`,(e,t)=>{t.pattern??=pi,L.init(e,t)}),Ja=F(`$ZodISODateTime`,(e,t)=>{t.pattern??=ci(t),L.init(e,t)}),Ya=F(`$ZodISODate`,(e,t)=>{t.pattern??=ki,L.init(e,t)}),Xa=F(`$ZodISOTime`,(e,t)=>{t.pattern??=si(t),L.init(e,t)}),Za=F(`$ZodISODuration`,(e,t)=>{t.pattern??=hi,L.init(e,t)}),Qa=F(`$ZodIPv4`,(e,t)=>{t.pattern??=bi,L.init(e,t)}),$a=/^[0-9a-fA-F:.]+$/,eo=F(`$ZodIPv6`,(e,t)=>{t.pattern??=xi,L.init(e,t),e._zod.check=n=>{ma(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),to=F(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Si,L.init(e,t)}),no=F(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Ci,L.init(e,t),e._zod.check=n=>{ha(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}),ro=/^[0-9a-zA-Z+/]*={0,2}$/,io=F(`$ZodBase64`,(e,t)=>{t.pattern??=ro,L.init(e,t),e._zod.check=n=>{ga(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),ao=/^[A-Za-z0-9_-]*$/,oo=F(`$ZodBase64URL`,(e,t)=>{t.pattern??=ao,L.init(e,t),e._zod.check=n=>{_a(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),so=F(`$ZodE164`,(e,t)=>{t.pattern??=Di,L.init(e,t)}),co=F(`$ZodJWT`,(e,t)=>{L.init(e,t),e._zod.check=n=>{va(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),lo=F(`$ZodNumber`,(e,t)=>{I.init(e,t),e._zod.pattern=Mi,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),uo=F(`$ZodNumberFormat`,(e,t)=>{Ui.init(e,t),lo.init(e,t)}),fo=F(`$ZodBoolean`,(e,t)=>{I.init(e,t),e._zod.pattern=Ni,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),po=F(`$ZodUnknown`,(e,t)=>{I.init(e,t),e._zod.parse=e=>e}),mo=F(`$ZodNever`,(e,t)=>{I.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)}),ho=e=>Array.isArray(e)?e.length:-1,go=F(`$ZodArray`,(e,t)=>{I.init(e,t);let n=wr.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>ba(t,r,e)));else if(ba(c,r,e),s&&c.issues.length!==0&&Bn(c))break}return o.length?Promise.all(o).then(()=>r):r},ya(e,ho)}),_o=[],vo=F(`$ZodObject`,(e,t)=>{I.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=un(()=>Sa(t));P(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||mn(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=wn,o=t.catchall,s,c=wr.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(Bn(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>xa(n,t,e,r,a,o))):xa(s,t,e,r,a,o)}return o?Ca(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),yo=F(`$ZodObjectJIT`,(e,t)=>{vo.init(e,t);let n=e._zod.parse,r=un(()=>Sa(t)),i=wr.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new na([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
|
|
4
|
+
`)}\n};`)(...Object.values(this.closed))}}})),zi,Bi=t((()=>{zi={major:4,minor:6,patch:7}}));async function Vi(e,t){let n={async:!0};return ha(await e._zod.run({value:t,issues:[]},n),n)}function Hi(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return ha(r,n)}catch{}return Vi(e,t)},vendor:`zod`,version:1}}function Ui(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Wi(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?Ui(e)||2:Gi(e,t)}function Gi(e,t){if(!t.normalize&&t.protocol?.source===si.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}function Ki(e){return e.replace(ba,``)}function qi(e,t){return t.lastIndex=0,t.test(e.hostname)}function Ji(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}function Yi(e){return Pa.test(e)?Ui(`http://[${e}]`):!1}function Xi(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:Yi(n)}function Zi(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}function Qi(e){if(!Ba.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Zi(t.padEnd(Math.ceil(t.length/4)*4,`=`))}function $i(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}function ea(e,t){let n=Tn(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of Tn(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,En(n.issues,t,e),n}}return i(n,a)}}function ta(e,t,n){e.issues.length&&t.issues.push(...Cn(n,e.issues)),t.value[n]=e.value}function na(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...Cn(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}function ra(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Za,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=dn(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function ia(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(xn(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>na(e,n,i,t,d,f))):na(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}function aa(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!xn(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Dn(e,r,$n())))}),t)}function oa(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(on(e)&&on(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=oa(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=oa(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function sa(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=oa(t.value,n.value);if(!c.valid){if(xn(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}function ca(e,t){return e.value=t.issues.length?void 0:t.value,e}function la(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}function ua(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function da(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>Dn(e,r,$n()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}function fa(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}function pa(e){return e.memo||(e.value=Object.freeze(e.value)),e}function ma(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(jn(e))}}var I,ha,ga,L,_a,va,ya,ba,xa,Sa,Ca,wa,Ta,Ea,Da,Oa,ka,Aa,ja,Ma,Na,Pa,Fa,Ia,La,Ra,za,Ba,Va,Ha,Ua,Wa,Ga,Ka,qa,Ja,Ya,Xa,Za,Qa,$a,eo,to,no,ro,io,ao,oo,so,co,lo,uo,fo,po,mo,ho,go,_o,vo=t((()=>{Ii(),or(),Ri(),_i(),Zn(),Bi(),I=F(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=zi;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=xn(t),a;for(let o of n){if(o._zod.def.when){if(Sn(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new rr;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(En(t.issues,n,e),i||=xn(t,n))});else{if(t.issues.length===n)continue;En(t.issues,n,e),i||=xn(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(xn(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new rr;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new rr;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return Pn(this,`~standard`,Hi(this))},set"~standard"(e){Nn(this,`~standard`,e)}}),ha=(e,t)=>e.issues.length?{issues:e.issues.map(e=>Dn(e,t,$n()))}:{value:e.value},ga=F(`$ZodString`,(e,t)=>{I.init(e,t),e._zod.pattern=t.pattern??di,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),L=F(`$ZodStringFormat`,(e,t)=>{Oi.init(e,t),ga.init(e,t)}),_a=F(`$ZodGUID`,(e,t)=>{t.pattern??=Zr,L.init(e,t)}),va=F(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Qr(e)}else t.pattern??=Qr();L.init(e,t)}),ya=F(`$ZodEmail`,(e,t)=>{t.pattern??=$r,L.init(e,t)}),ba=/[\t\n\r]/g,xa=F(`$ZodURL`,(e,t)=>{L.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=Wi(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=Ki(r);return}t.hostname&&!qi(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!Ji(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:Ki(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Sa=F(`$ZodEmoji`,(e,t)=>{t.pattern??=zr(),L.init(e,t)}),Ca=F(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?Yr:Rr(t.length),L.init(e,t)}),wa=F(`$ZodCUID`,(e,t)=>{t.pattern??=Wr,L.init(e,t)}),Ta=F(`$ZodCUID2`,(e,t)=>{t.pattern??=Gr,L.init(e,t)}),Ea=F(`$ZodULID`,(e,t)=>{t.pattern??=Kr,L.init(e,t)}),Da=F(`$ZodXID`,(e,t)=>{t.pattern??=qr,L.init(e,t)}),Oa=F(`$ZodKSUID`,(e,t)=>{t.pattern??=Jr,L.init(e,t)}),ka=F(`$ZodISODateTime`,(e,t)=>{t.pattern??=Ur(t),L.init(e,t)}),Aa=F(`$ZodISODate`,(e,t)=>{t.pattern??=ui,L.init(e,t)}),ja=F(`$ZodISOTime`,(e,t)=>{t.pattern??=Hr(t),L.init(e,t)}),Ma=F(`$ZodISODuration`,(e,t)=>{t.pattern??=Xr,L.init(e,t)}),Na=F(`$ZodIPv4`,(e,t)=>{t.pattern??=ti,L.init(e,t)}),Pa=/^[0-9a-fA-F:.]+$/,Fa=F(`$ZodIPv6`,(e,t)=>{t.pattern??=ni,L.init(e,t),e._zod.check=n=>{Yi(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),Ia=F(`$ZodCIDRv4`,(e,t)=>{t.pattern??=ri,L.init(e,t)}),La=F(`$ZodCIDRv6`,(e,t)=>{t.pattern??=ii,L.init(e,t),e._zod.check=n=>{Xi(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}),Ra=/^[0-9a-zA-Z+/]*={0,2}$/,za=F(`$ZodBase64`,(e,t)=>{t.pattern??=Ra,L.init(e,t),e._zod.check=n=>{Zi(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),Ba=/^[A-Za-z0-9_-]*$/,Va=F(`$ZodBase64URL`,(e,t)=>{t.pattern??=Ba,L.init(e,t),e._zod.check=n=>{Qi(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Ha=F(`$ZodE164`,(e,t)=>{t.pattern??=ci,L.init(e,t)}),Ua=F(`$ZodJWT`,(e,t)=>{L.init(e,t),e._zod.check=n=>{$i(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Wa=F(`$ZodNumber`,(e,t)=>{I.init(e,t),e._zod.pattern=pi,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Ga=F(`$ZodNumberFormat`,(e,t)=>{wi.init(e,t),Wa.init(e,t)}),Ka=F(`$ZodBoolean`,(e,t)=>{I.init(e,t),e._zod.pattern=mi,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),qa=F(`$ZodUnknown`,(e,t)=>{I.init(e,t),e._zod.parse=e=>e}),Ja=F(`$ZodNever`,(e,t)=>{I.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)}),Ya=e=>Array.isArray(e)?e.length:-1,Xa=F(`$ZodArray`,(e,t)=>{I.init(e,t);let n=ar.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>ta(t,r,e)));else if(ta(c,r,e),s&&c.issues.length!==0&&xn(c))break}return o.length?Promise.all(o).then(()=>r):r},ea(e,Ya)}),Za=[],Qa=F(`$ZodObject`,(e,t)=>{I.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=Wt(()=>ra(t));P(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||Jt(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=an,o=t.catchall,s,c=ar.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(xn(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>na(n,t,e,r,a,o))):na(s,t,e,r,a,o)}return o?ia(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),$a=F(`$ZodObjectJIT`,(e,t)=>{Qa.init(e,t);let n=e._zod.parse,r=Wt(()=>ra(t)),i=ar.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new Li([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
|
|
5
5
|
let ${e}_ab = false;
|
|
6
6
|
for (let i = 0; i < ${e}.issues.length; i++) {
|
|
7
7
|
const iss = ${e}.issues[i];
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
if (${e}_ab && ctx && ctx.abortEarly) {
|
|
13
13
|
payload.value = newResult;
|
|
14
14
|
return payload;
|
|
15
|
-
}`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:
|
|
15
|
+
}`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:nn(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
|
|
16
16
|
const ${n}_present = ${i};
|
|
17
17
|
if (!${n}.issues.length || ${n}_present) {
|
|
18
18
|
if (${n}.issues.length) {${c(n,r)}
|
|
@@ -51,22 +51,22 @@
|
|
|
51
51
|
newResult[${r}] = ${n}.value;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=wn,c=!wr.jitless,l=c&&sr.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?Ca([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}}),bo=F(`$ZodUnion`,(e,t)=>{I.init(e,t),P(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),P(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),P(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),P(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>fn(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>wa(t,r,e,i)):wa(o,r,e,i)}}),xo=F(`$ZodIntersection`,(e,t)=>{I.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Ea(e,t,n)):Ea(e,i,a)}}),So=F(`$ZodRecord`,(e,t)=>{I.init(e,t);let n=wr.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Tn(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Kn(e,i,vr())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...Hn(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...Hn(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&Mi.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>Kn(e,i,vr())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...Hn(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...Hn(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),Co=F(`$ZodEnum`,(e,t)=>{I.init(e,t);let n=sn(t.entries),r=new Set(n);e._zod.values=r,P(e,`pattern`,e=>{let t=sn(e.def.entries).filter(e=>cr.has(typeof e));return RegExp(t.length?`^(${t.map(e=>Dn(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),wo=F(`$ZodLiteral`,(e,t)=>{I.init(e,t);let n=new Set(t.values);e._zod.values=n,P(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?Dn(e):e?Dn(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),To=F(`$ZodTransform`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,wr.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Cr(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new Sr;return n.value=i,n}}),Eo=F(`$ZodOptional`,(e,t)=>{I.init(e,t),P(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,P(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),P(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${fn(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Da(e,t)):Da(e,r)}return t.innerType._zod.run(e,n)}}),Do=F(`$ZodExactOptional`,(e,t)=>{Eo.init(e,t),P(e,`values`,e=>e.def.innerType._zod.values),P(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Oo=F(`$ZodNullable`,(e,t)=>{I.init(e,t),P(e,`optin`,e=>e.def.innerType._zod.optin),P(e,`optout`,e=>e.def.innerType._zod.optout),P(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${fn(t.source)}|null)$`):void 0}),P(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),ko=F(`$ZodDefault`,(e,t)=>{I.init(e,t),e._zod.optin=`defaulted`,P(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Oa(e,t)):Oa(r,t)}}),Ao=F(`$ZodPrefault`,(e,t)=>{I.init(e,t),e._zod.optin=`defaulted`,P(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),jo=F(`$ZodNonOptional`,(e,t)=>{I.init(e,t),P(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>ka(t,e)):ka(i,e)}}),Mo=F(`$ZodCatch`,(e,t)=>{I.init(e,t),P(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),P(e,`optout`,e=>e.def.innerType._zod.optout),P(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Aa(e,r,t,n)):Aa(e,r,t,n)}}),No=F(`$ZodPipe`,(e,t)=>{I.init(e,t),P(e,`values`,e=>e.def.in._zod.values),P(e,`optin`,e=>e.def.in._zod.optin),P(e,`optout`,e=>e.def.out._zod.optout),P(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>ja(e,t.in,n)):ja(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>ja(e,t.out,n)):ja(r,t.out,n)}}),Po=F(`$ZodReadonly`,(e,t)=>{I.init(e,t),P(e,`propValues`,e=>e.def.innerType._zod.propValues),P(e,`values`,e=>e.def.innerType._zod.values),P(e,`optin`,e=>e.def.innerType?._zod?.optin),P(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Ma):Ma(r)}}),Fo=F(`$ZodCustom`,(e,t)=>{Li.init(e,t),I.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Na(t,n,r,e));Na(i,n,r,e)}})}));function Lo(e){return typeof e==`object`&&!!e}function Ro(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}function zo(e,t,n){let r=qo.get(e);if(r!==void 0)return r?Xo:Jo;if(t.has(e))return Xo;t.add(e);let i=Jo,a=e=>{if(i!==Xo&&e?._zod){let r=zo(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=Jo;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?Yo:o.value?._zod?zo(o.value,t,n):Jo;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=hn(c);s(e?o(e,!0):Yo),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?zo(r,t,!1):Yo);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),Bo(e,i)}function Bo(e,t){return t!==Yo&&qo.set(e,t===Xo),t}function Vo(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}function Ho(){return $o}function Uo(e,t){let n=e[Go]?.backEdges;return n!==void 0&&Lo(t)&&n.has(t)}var Wo,Go,Ko,qo,Jo,Yo,Xo,Zo,Qo,$o,es=t((()=>{gr(),Wo=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},Go=`~memo`,Ko=[],qo=new WeakMap,Jo=0,Yo=1,Xo=2,Qo=[],$o={alloc(e,t,n){let r=Zo;if(!r)return n;Zo=void 0;let i={value:n,issues:null};return r.set(t.value,i),Qo.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&Uo(n,e.value))throw new Wo;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=zo(e,new Set,!1);if(i===Jo)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===Xo||r?n=!0:r=!0}let l=s.value;if(!Lo(l))return t(s,c);let u=c[Go];u||(u={buckets:new WeakMap,backEdges:void 0},c[Go]=u);let d;i===c?d=a:(d=Vo(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...Ro(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;Zo=d;let p=Qo.length,m=t(s,c);Zo=void 0;let h=Qo.length>p?Qo.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?Ro(e.issues):Ko),e)):(h&&(h.issues=m.issues.length?Ro(m.issues):Ko),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}}}));function ts(){return{localeError:ns()}}var ns,rs=t((()=>{gr(),ns=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(Yn(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${kn(e.values[0])}`:`Invalid option: expected one of ${cn(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${cn(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}}}));function is(){return new os}var as,os,ss,cs=t((()=>{os=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}},(as=globalThis).__zod_globalRegistry??(as.__zod_globalRegistry=is()),ss=globalThis.__zod_globalRegistry})),ls=t((()=>{}));function us(e){return e.checks&&=[...e.checks],e}function ds(e,t){return new e(us({type:`string`,...N(t)}))}function fs(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...N(t)})}function ps(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...N(t)})}function ms(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...N(t)})}function hs(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...N(t)})}function gs(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...N(t)})}function _s(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...N(t)})}function vs(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...N(t)})}function ys(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...N(t)})}function bs(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...N(t)})}function xs(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...N(t)})}function Ss(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...N(t)})}function Cs(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...N(t)})}function ws(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...N(t)})}function Ts(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...N(t)})}function Es(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...N(t)})}function Ds(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...N(t)})}function Os(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...N(t)})}function ks(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...N(t)})}function As(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...N(t)})}function js(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...N(t)})}function Ms(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...N(t)})}function Ns(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...N(t)})}function Ps(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...N(t)})}function Fs(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...N(t)})}function Is(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...N(t)})}function Ls(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...N(t)})}function Rs(e,t){return new e(us({type:`number`,checks:[],...N(t)}))}function zs(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...N(t)})}function Bs(e,t){return new e({type:`boolean`,...N(t)})}function Vs(e){return new e({type:`unknown`})}function Hs(e,t){return new e({type:`never`,...N(t)})}function Us(e,t){return new Bi({check:`less_than`,...N(t),value:e,inclusive:!1})}function Ws(e,t){return new Bi({check:`less_than`,...N(t),value:e,inclusive:!0})}function Gs(e,t){return new Vi({check:`greater_than`,...N(t),value:e,inclusive:!1})}function Ks(e,t){return new Vi({check:`greater_than`,...N(t),value:e,inclusive:!0})}function qs(e,t){return new Hi({check:`multiple_of`,...N(t),value:e})}function Js(e,t){return new Wi({check:`max_length`,...N(t),maximum:e})}function Ys(e,t){return new Gi({check:`min_length`,...N(t),minimum:e})}function Xs(e,t){return new Ki({check:`length_equals`,...N(t),length:e})}function Zs(e,t){return new Ji({check:`string_format`,format:`regex`,...N(t),pattern:e})}function Qs(e){return new Yi({check:`string_format`,format:`lowercase`,...N(e)})}function $s(e){return new Xi({check:`string_format`,format:`uppercase`,...N(e)})}function ec(e,t){return new Zi({check:`string_format`,format:`includes`,...N(t),includes:e})}function tc(e,t){return new Qi({check:`string_format`,format:`starts_with`,...N(t),prefix:e})}function nc(e,t){return new $i({check:`string_format`,format:`ends_with`,...N(t),suffix:e})}function rc(e){return new ea({check:`overwrite`,tx:e})}function ic(e){return rc(t=>t.normalize(e))}function ac(){return rc(e=>e.trim())}function oc(){return rc(e=>e.toLowerCase())}function sc(){return rc(e=>e.toUpperCase())}function cc(){return rc(e=>Cn(e))}function lc(e,t,n){return new e({type:`array`,element:t,...N(n)})}function uc(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...N(n)})}function dc(e,t){let n=fc(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Xn(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Xn(r))}},e(t.value,t)),t);return n}function fc(e,t){let n=new Li({check:`custom`,...N(t)});return n._zod.check=e,n}var pc=t((()=>{ta(),gr()}));function mc(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&mn(e,t,n[t]);return e}function hc(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??ss,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function gc(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function R(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,R(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&mc(o.schema,c),t.io===`input`&&wc(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function _c(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function vc(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${_c(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+_c(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
54
|
+
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=an,c=!ar.jitless,l=c&&Hn.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?ia([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}}),eo=F(`$ZodUnion`,(e,t)=>{I.init(e,t),P(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),P(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),P(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),P(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>Kt(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>aa(t,r,e,i)):aa(o,r,e,i)}}),to=F(`$ZodIntersection`,(e,t)=>{I.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>sa(e,t,n)):sa(e,i,a)}}),no=F(`$ZodRecord`,(e,t)=>{I.init(e,t);let n=ar.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!on(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Dn(e,i,$n())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...Cn(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...Cn(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&pi.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>Dn(e,i,$n())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...Cn(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...Cn(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),ro=F(`$ZodEnum`,(e,t)=>{I.init(e,t);let n=Vt(t.entries),r=new Set(n);e._zod.values=r,P(e,`pattern`,e=>{let t=Vt(e.def.entries).filter(e=>Un.has(typeof e));return RegExp(t.length?`^(${t.map(e=>cn(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),io=F(`$ZodLiteral`,(e,t)=>{I.init(e,t);let n=new Set(t.values);e._zod.values=n,P(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?cn(e):e?cn(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),ao=F(`$ZodTransform`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,ar.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ir(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new rr;return n.value=i,n}}),oo=F(`$ZodOptional`,(e,t)=>{I.init(e,t),P(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,P(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),P(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Kt(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>ca(e,t)):ca(e,r)}return t.innerType._zod.run(e,n)}}),so=F(`$ZodExactOptional`,(e,t)=>{oo.init(e,t),P(e,`values`,e=>e.def.innerType._zod.values),P(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),co=F(`$ZodNullable`,(e,t)=>{I.init(e,t),P(e,`optin`,e=>e.def.innerType._zod.optin),P(e,`optout`,e=>e.def.innerType._zod.optout),P(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Kt(t.source)}|null)$`):void 0}),P(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),lo=F(`$ZodDefault`,(e,t)=>{I.init(e,t),e._zod.optin=`defaulted`,P(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>la(e,t)):la(r,t)}}),uo=F(`$ZodPrefault`,(e,t)=>{I.init(e,t),e._zod.optin=`defaulted`,P(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),fo=F(`$ZodNonOptional`,(e,t)=>{I.init(e,t),P(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>ua(t,e)):ua(i,e)}}),po=F(`$ZodCatch`,(e,t)=>{I.init(e,t),P(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),P(e,`optout`,e=>e.def.innerType._zod.optout),P(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>da(e,r,t,n)):da(e,r,t,n)}}),mo=F(`$ZodPipe`,(e,t)=>{I.init(e,t),P(e,`values`,e=>e.def.in._zod.values),P(e,`optin`,e=>e.def.in._zod.optin),P(e,`optout`,e=>e.def.out._zod.optout),P(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>fa(e,t.in,n)):fa(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>fa(e,t.out,n)):fa(r,t.out,n)}}),ho=F(`$ZodPreprocess`,(e,t)=>{mo.init(e,t)}),go=F(`$ZodReadonly`,(e,t)=>{I.init(e,t),P(e,`propValues`,e=>e.def.innerType._zod.propValues),P(e,`values`,e=>e.def.innerType._zod.values),P(e,`optin`,e=>e.def.innerType?._zod?.optin),P(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(pa):pa(r)}}),_o=F(`$ZodCustom`,(e,t)=>{vi.init(e,t),I.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>ma(t,n,r,e));ma(i,n,r,e)}})}));function yo(e){return typeof e==`object`&&!!e}function bo(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}function xo(e,t,n){let r=ko.get(e);if(r!==void 0)return r?Mo:Ao;if(t.has(e))return Mo;t.add(e);let i=Ao,a=e=>{if(i!==Mo&&e?._zod){let r=xo(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=Ao;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?jo:o.value?._zod?xo(o.value,t,n):Ao;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=Yt(c);s(e?o(e,!0):jo),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?xo(r,t,!1):jo);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),So(e,i)}function So(e,t){return t!==jo&&ko.set(e,t===Mo),t}function Co(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}function wo(){return Fo}function To(e,t){let n=e[Do]?.backEdges;return n!==void 0&&yo(t)&&n.has(t)}var Eo,Do,Oo,ko,Ao,jo,Mo,No,Po,Fo,Io=t((()=>{Zn(),Eo=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},Do=`~memo`,Oo=[],ko=new WeakMap,Ao=0,jo=1,Mo=2,Po=[],Fo={alloc(e,t,n){let r=No;if(!r)return n;No=void 0;let i={value:n,issues:null};return r.set(t.value,i),Po.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&To(n,e.value))throw new Eo;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=xo(e,new Set,!1);if(i===Ao)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===Mo||r?n=!0:r=!0}let l=s.value;if(!yo(l))return t(s,c);let u=c[Do];u||(u={buckets:new WeakMap,backEdges:void 0},c[Do]=u);let d;i===c?d=a:(d=Co(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...bo(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;No=d;let p=Po.length,m=t(s,c);No=void 0;let h=Po.length>p?Po.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?bo(e.issues):Oo),e)):(h&&(h.issues=m.issues.length?bo(m.issues):Oo),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}}}));function Lo(){return{localeError:Ro()}}var Ro,zo=t((()=>{Zn(),Ro=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(An(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${un(e.values[0])}`:`Invalid option: expected one of ${Ht(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${Ht(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}}}));function Bo(){return new Ho}var Vo,Ho,Uo,Wo=t((()=>{Ho=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}},(Vo=globalThis).__zod_globalRegistry??(Vo.__zod_globalRegistry=Bo()),Uo=globalThis.__zod_globalRegistry})),Go=t((()=>{}));function Ko(e){return e.checks&&=[...e.checks],e}function qo(e,t){return new e(Ko({type:`string`,...N(t)}))}function Jo(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...N(t)})}function Yo(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...N(t)})}function Xo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...N(t)})}function Zo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...N(t)})}function Qo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...N(t)})}function $o(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...N(t)})}function es(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...N(t)})}function ts(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...N(t)})}function ns(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...N(t)})}function rs(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...N(t)})}function is(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...N(t)})}function as(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...N(t)})}function os(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...N(t)})}function ss(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...N(t)})}function cs(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...N(t)})}function ls(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...N(t)})}function us(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...N(t)})}function ds(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...N(t)})}function fs(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...N(t)})}function ps(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...N(t)})}function ms(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...N(t)})}function hs(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...N(t)})}function gs(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...N(t)})}function _s(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...N(t)})}function vs(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...N(t)})}function ys(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...N(t)})}function bs(e,t){return new e(Ko({type:`number`,checks:[],...N(t)}))}function xs(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...N(t)})}function Ss(e,t){return new e({type:`boolean`,...N(t)})}function Cs(e){return new e({type:`unknown`})}function ws(e,t){return new e({type:`never`,...N(t)})}function Ts(e,t){return new xi({check:`less_than`,...N(t),value:e,inclusive:!1})}function Es(e,t){return new xi({check:`less_than`,...N(t),value:e,inclusive:!0})}function Ds(e,t){return new Si({check:`greater_than`,...N(t),value:e,inclusive:!1})}function Os(e,t){return new Si({check:`greater_than`,...N(t),value:e,inclusive:!0})}function ks(e,t){return new Ci({check:`multiple_of`,...N(t),value:e})}function As(e,t){return new Ti({check:`max_length`,...N(t),maximum:e})}function js(e,t){return new Ei({check:`min_length`,...N(t),minimum:e})}function Ms(e,t){return new Di({check:`length_equals`,...N(t),length:e})}function Ns(e,t){return new ki({check:`string_format`,format:`regex`,...N(t),pattern:e})}function Ps(e){return new Ai({check:`string_format`,format:`lowercase`,...N(e)})}function Fs(e){return new ji({check:`string_format`,format:`uppercase`,...N(e)})}function Is(e,t){return new Mi({check:`string_format`,format:`includes`,...N(t),includes:e})}function Ls(e,t){return new Ni({check:`string_format`,format:`starts_with`,...N(t),prefix:e})}function Rs(e,t){return new Pi({check:`string_format`,format:`ends_with`,...N(t),suffix:e})}function zs(e){return new Fi({check:`overwrite`,tx:e})}function Bs(e){return zs(t=>t.normalize(e))}function Vs(){return zs(e=>e.trim())}function Hs(){return zs(e=>e.toLowerCase())}function Us(){return zs(e=>e.toUpperCase())}function Ws(){return zs(e=>rn(e))}function Gs(e,t,n){return new e({type:`array`,element:t,...N(n)})}function Ks(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...N(n)})}function qs(e,t){let n=Js(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(jn(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(jn(r))}},e(t.value,t)),t);return n}function Js(e,t){let n=new vi({check:`custom`,...N(t)});return n._zod.check=e,n}var Ys=t((()=>{Ii(),Zn()}));function Xs(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&Jt(e,t,n[t]);return e}function Zs(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Uo,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function Qs(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function R(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,R(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Xs(o.schema,c),t.io===`input`&&oc(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function $s(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function ec(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${$s(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+$s(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
55
55
|
|
|
56
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function yc(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;yc(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}function bc(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function xc(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Tc.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??bc(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}mn(n,r,e.length===1?e[0]:xc(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=bc(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Sc(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Tc)if(t in e)return;let n=t.filter(e=>Ec.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=xc(t);else{let e=n[0],i=Ec.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>xc([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,mc(e,r))}function Cc(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):mc(i,s),mc(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())yc(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Sc(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}mc(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,mn(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Oc(t,`input`,e.processors),output:Oc(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function wc(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return wc(r.element,n);if(r.type===`set`)return wc(r.valueType,n);if(r.type===`lazy`)return wc(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return wc(r.innerType,n);if(r.type===`intersection`)return wc(r.left,n)||wc(r.right,n);if(r.type===`record`||r.type===`map`)return wc(r.keyType,n)||wc(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:wc(r.in,n)||wc(r.out,n);if(r.type===`object`){for(let e in r.shape)if(wc(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(wc(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(wc(e,n))return!0;return!!(r.rest&&wc(r.rest,n))}return!1}var Tc,Ec,Dc,Oc,kc=t((()=>{cs(),gr(),Tc=new Set([`type`,`properties`,`required`,`additionalProperties`]),Ec=[`oneOf`,`anyOf`],Dc=(e,t={})=>n=>{let r=hc({...n,processors:t});return R(e,r),vc(r,e),Cc(r,e)},Oc=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=hc({...i??{},target:a,io:t,processors:n});return R(e,o),vc(o,e),Cc(o,e)}}));function Ac(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Gc[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Fc(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Fc(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Ic(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Ic(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Rc(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Bc(t,i.mime);for(let e of i.patterns??[])zc(t,e);return t}function jc(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?jc(t.out):t.type===`catch`?jc(t.innerType):e._zod.optin}function Mc(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=Mc(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>Mc(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i&&(p.type=`string`,a||(p.pattern=(r.includes(`number`)?Mi:ji).source)),p}function Nc(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of cl.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=Mc(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}function Pc(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(gc(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),fl):JSON.parse(o)}var Fc,Ic,Lc,Rc,zc,Bc,Vc,Hc,Uc,Wc,Gc,Kc,qc,Jc,Yc,Xc,Zc,Qc,$c,el,tl,nl,rl,il,al,ol,sl,cl,ll,ul,dl,fl,pl,ml,hl,gl,_l,vl,yl=t((()=>{Ii(),Io(),kc(),gr(),Fc=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Ic=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Lc=(e,t)=>{Fc(e,`minimum`,t),Ic(e,`maximum`,t)},Rc=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},zc=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},Bc=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Vc=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Hc=(e,t)=>Fc(e,`minimum`,t.minimum),Uc=(e,t)=>Ic(e,`maximum`,t.maximum),Wc=e=>(t,n)=>{Vc(t,n.format);let[r,i]=e[n.format];Fc(t,`minimum`,r),Ic(t,`maximum`,i)},Gc={greater_than:(e,t)=>Fc(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Ic(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Rc(e,t.value),number_format:Wc(lr),bigint_format:Wc(ur),min_length:Hc,max_length:Uc,length_equals:(e,t)=>Lc(e,t.length),min_size:Hc,max_size:Uc,size_equals:(e,t)=>Lc(e,t.size),string_format:(e,t)=>{Vc(e,t.format),t.pattern&&zc(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Bc(e,t.mime)},Kc={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},qc=new Map([[ro,wi],[ao,Ti]]),Jc=e=>qc.get(e)??e,Yc=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Ac(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Kc[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(Jc);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Xc=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Ac(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):gc(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},Zc=(e,t,n,r)=>{n.type=`boolean`},Qc=(e,t,n,r)=>{n.not={}},$c=(e,t,n,r)=>{},el=(e,t,n,r)=>{let i=e._zod.def,a=sn(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},tl=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(gc(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(gc(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},nl=(e,t,n,r)=>{gc(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},rl=(e,t,n,r)=>{gc(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},il=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=Ac(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=R(a.element,t,{...r,path:[...r.path,`items`]})},al=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&gc(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)mn(i.properties,e,R(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?jc(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=R(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},ol=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>R(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},sl=(e,t,n,r)=>{let i=e._zod.def,a=R(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=R(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},cl=new WeakMap,ll=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=Ac(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=R(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)mn(i.patternProperties,Jc(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=R(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=cl.get(t);n||(n=[],cl.set(t,n),t.deferred.push(()=>Nc(t))),n.push(e)}i.additionalProperties=R(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&jc(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},ul=(e,t,n,r)=>{let i=e._zod.def,a=R(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},dl=(e,t,n,r)=>{let i=e._zod.def;R(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},fl=Symbol(),pl=(e,t,n,r)=>{let i=e._zod.def;R(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Pc(i.defaultValue,e,t,n,r);o!==fl&&(n.default=o)},ml=(e,t,n,r)=>{let i=e._zod.def;R(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Pc(i.defaultValue,e,t,n,r);o!==fl&&(n._prefault=o)},hl=(e,t,n,r)=>{let i=e._zod.def;R(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{gc(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},gl=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;R(o,t,r);let s=t.seen.get(e);s.ref=o},_l=(e,t,n,r)=>{let i=e._zod.def;R(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},vl=(e,t,n,r)=>{let i=e._zod.def;R(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType}})),bl=t((()=>{Tr(),ni(),Ir(),Io(),es(),ta(),aa(),gr(),Ii(),rs(),cs(),ra(),ls(),pc(),kc(),yl(),kc()})),xl=t((()=>{bl()}));function Sl(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var Cl,wl,Tl,El=t((()=>{bl(),gr(),Cl=new WeakSet([Object.prototype,Error.prototype]),wl=(e,t)=>{Fr.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);Cl.has(n)||(Cl.add(n),Sl(n,`format`,e=>t=>Ar(e,t)),Sl(n,`flatten`,e=>t=>kr(e,t)),Sl(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,ln,2)}),Sl(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,ln,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Tl=F(`ZodError`,wl,void 0,{Parent:Error})})),Dl,Ol,kl,Al,jl,Ml,Nl,Pl,Fl,Il,Ll,Rl,zl=t((()=>{bl(),El(),Dl=Br(Tl),Ol=Vr(Tl),kl=Hr(Tl),Al=Ur(Tl),jl=Jr(Tl),Ml=Yr(Tl),Nl=Xr(Tl),Pl=Zr(Tl),Fl=Qr(Tl),Il=$r(Tl),Ll=ei(Tl),Rl=ti(Tl)}));function Bl(){wr.localeError||vr(ts())}function Vl(){wr.memoizer||vr({memoizer:Ho()})}function z(e){return ds(pu,e)}function Hl(e){return Rs(Lu,e)}function Ul(e){return zs(Ru,e)}function Wl(e){return Bs(zu,e)}function Gl(){return Vs(Bu)}function Kl(e){return Hs(Vu,e)}function ql(e,t){return lc(Hu,e,t)}function B(e,t){let n={type:`object`,shape:e??{},...N(t)};return new Uu(n)}function Jl(e,t){return new Wu({type:`union`,options:e,...N(t)})}function Yl(e,t){return new Gu({type:`intersection`,left:e,right:t})}function Xl(e,t,n){return!t||!t._zod?new Ku({type:`record`,keyType:z(),valueType:e,...N(t)}):new Ku({type:`record`,keyType:e,valueType:t,...N(n)})}function Zl(e,t,n){return new Ku({type:`record`,keyType:e,valueType:t,...N(n),partial:!0})}function Ql(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new qu({type:`enum`,entries:n,...N(t)})}function $l(e,t){return new Ju({type:`literal`,values:Array.isArray(e)?e:[e],...N(t)})}function eu(e){return new Yu({type:`transform`,transform:e})}function tu(e){return new Xu({type:`optional`,innerType:e})}function nu(e){return new Zu({type:`optional`,innerType:e})}function ru(e){return new Qu({type:`nullable`,innerType:e})}function iu(e,t){return new $u({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():En(t)}})}function au(e,t){return new ed({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():En(t)}})}function ou(e,t){return new td({type:`nonoptional`,innerType:e,...N(t)})}function su(e,t){return new nd({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:ir(t)})}function cu(e,t){return new rd({type:`pipe`,in:e,out:t})}function lu(e){return new id({type:`readonly`,innerType:e})}function uu(e,t={}){return uc(ad,e,t)}function du(e,t){return dc(e,t)}var V,fu,pu,H,mu,hu,gu,_u,vu,yu,bu,xu,Su,Cu,wu,Tu,Eu,Du,Ou,ku,Au,ju,Mu,Nu,Pu,Fu,Iu,Lu,Ru,zu,Bu,Vu,Hu,Uu,Wu,Gu,Ku,qu,Ju,Yu,Xu,Zu,Qu,$u,ed,td,nd,rd,id,ad,od=t((()=>{bl(),yl(),kc(),rs(),xl(),zl(),V=F(`ZodType`,(e,t)=>(Bl(),I.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(xn(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return On(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(uu(e,t))},superRefine(e,t){return this.check(du(e,t))},overwrite(e){return this.check(rc(e))},optional(){return tu(this)},exactOptional(){return nu(this)},nullable(){return ru(this)},nullish(){return tu(ru(this))},nonoptional(e){return ou(this,e)},array(){return ql(this)},or(e){return Jl([this,e])},and(e){return Yl(this,e)},transform(e){return cu(this,eu(e))},default(e){return iu(this,e)},prefault(e){return au(this,e)},catch(e){return su(this,e)},pipe(e){return cu(this,e)},readonly(){return lu(this)},describe(e){let t=this.clone();return ss.add(t,{description:e}),t},meta(...e){if(e.length===0)return ss.get(this);let t=this.clone();return ss.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return $n(this,`~standard`,{...sa(this),jsonSchema:{input:Oc(this,`input`),output:Oc(this,`output`)}})},set"~standard"(e){Qn(this,`~standard`,e)},parse:function e(t,n){return Dl(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Ol(this,t,n,{callee:e})},safeParse(e,t){return kl(this,e,t)},async safeParseAsync(e,t){return Al(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Qn(this,`spa`,e)},validate(e,t){return Kr(this,e,t)},validateAsync(e,t){return qr(this,e,t)},encode:function e(t,n){return jl(this,t,n,{callee:e})},decode:function e(t,n){return Ml(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Nl(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Pl(this,t,n,{callee:e})},safeEncode(e,t){return Fl(this,e,t)},safeDecode(e,t){return Il(this,e,t)},async safeEncodeAsync(e,t){return Ll(this,e,t)},async safeDecodeAsync(e,t){return Rl(this,e,t)},toJSONSchema(e){return Dc(this,{})(e)},get description(){return ss.get(this)?.description},get _def(){return this._zod.def}}),fu=F(`_ZodString`,(e,t)=>{Fa.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yc(e,t,n,r)},er({format:e=>Ac(e).format??null,minLength:e=>Ac(e).minimum??null,maxLength:e=>Ac(e).maximum??null},{regex(...e){return this.check(Zs(...e))},includes(...e){return this.check(ec(...e))},startsWith(...e){return this.check(tc(...e))},endsWith(...e){return this.check(nc(...e))},min(...e){return this.check(Ys(...e))},max(...e){return this.check(Js(...e))},length(...e){return this.check(Xs(...e))},nonempty(...e){return this.check(Ys(1,...e))},lowercase(e){return this.check(Qs(e))},uppercase(e){return this.check($s(e))},trim(){return this.check(ac())},normalize(...e){return this.check(ic(...e))},toLowerCase(){return this.check(oc())},toUpperCase(){return this.check(sc())},slugify(){return this.check(cc())}})),pu=F(`ZodString`,(e,t)=>{Fa.init(e,t),fu.init(e,t)},{email(e){return this.check(fs(vu,e))},url(e){return this.check(vs(xu,e))},jwt(e){return this.check(Ns(Iu,e))},emoji(e){return this.check(ys(Su,e))},guid(e){return this.check(ps(yu,e))},uuid(e){return this.check(ms(bu,e))},uuidv4(e){return this.check(hs(bu,e))},uuidv6(e){return this.check(gs(bu,e))},uuidv7(e){return this.check(_s(bu,e))},nanoid(e){return this.check(bs(Cu,e))},cuid(e){return this.check(xs(wu,e))},cuid2(e){return this.check(Ss(Tu,e))},ulid(e){return this.check(Cs(Eu,e))},base64(e){return this.check(As(Nu,e))},base64url(e){return this.check(js(Pu,e))},xid(e){return this.check(ws(Du,e))},ksuid(e){return this.check(Ts(Ou,e))},ipv4(e){return this.check(Es(ku,e))},ipv6(e){return this.check(Ds(Au,e))},cidrv4(e){return this.check(Os(ju,e))},cidrv6(e){return this.check(ks(Mu,e))},e164(e){return this.check(Ms(Fu,e))},datetime(e){return this.check(Ps(mu,e))},date(e){return this.check(Fs(hu,e))},time(e){return this.check(Is(gu,e))},duration(e){return this.check(Ls(_u,e))}}),H=F(`ZodStringFormat`,(e,t)=>{L.init(e,t),fu.init(e,t)}),mu=F(`ZodISODateTime`,(e,t)=>{Ja.init(e,t),H.init(e,t)}),hu=F(`ZodISODate`,(e,t)=>{Ya.init(e,t),H.init(e,t)}),gu=F(`ZodISOTime`,(e,t)=>{Xa.init(e,t),H.init(e,t)}),_u=F(`ZodISODuration`,(e,t)=>{Za.init(e,t),H.init(e,t)}),vu=F(`ZodEmail`,(e,t)=>{Ra.init(e,t),H.init(e,t)}),yu=F(`ZodGUID`,(e,t)=>{Ia.init(e,t),H.init(e,t)}),bu=F(`ZodUUID`,(e,t)=>{La.init(e,t),H.init(e,t)}),xu=F(`ZodURL`,(e,t)=>{Ba.init(e,t),H.init(e,t)}),Su=F(`ZodEmoji`,(e,t)=>{Va.init(e,t),H.init(e,t)}),Cu=F(`ZodNanoID`,(e,t)=>{Ha.init(e,t),H.init(e,t)}),wu=F(`ZodCUID`,(e,t)=>{Ua.init(e,t),H.init(e,t)}),Tu=F(`ZodCUID2`,(e,t)=>{Wa.init(e,t),H.init(e,t)}),Eu=F(`ZodULID`,(e,t)=>{Ga.init(e,t),H.init(e,t)}),Du=F(`ZodXID`,(e,t)=>{Ka.init(e,t),H.init(e,t)}),Ou=F(`ZodKSUID`,(e,t)=>{qa.init(e,t),H.init(e,t)}),ku=F(`ZodIPv4`,(e,t)=>{Qa.init(e,t),H.init(e,t)}),Au=F(`ZodIPv6`,(e,t)=>{eo.init(e,t),H.init(e,t)}),ju=F(`ZodCIDRv4`,(e,t)=>{to.init(e,t),H.init(e,t)}),Mu=F(`ZodCIDRv6`,(e,t)=>{no.init(e,t),H.init(e,t)}),Nu=F(`ZodBase64`,(e,t)=>{io.init(e,t),H.init(e,t)}),Pu=F(`ZodBase64URL`,(e,t)=>{oo.init(e,t),H.init(e,t)}),Fu=F(`ZodE164`,(e,t)=>{so.init(e,t),H.init(e,t)}),Iu=F(`ZodJWT`,(e,t)=>{co.init(e,t),H.init(e,t)}),Lu=F(`ZodNumber`,(e,t)=>{lo.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xc(e,t,n,r),e.isFinite=!0},er({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=Ac(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=Ac(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=Ac(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Ac(e).format??null},{gt(e,t){return this.check(Gs(e,t))},gte(e,t){return this.check(Ks(e,t))},min(e,t){return this.check(Ks(e,t))},lt(e,t){return this.check(Us(e,t))},lte(e,t){return this.check(Ws(e,t))},max(e,t){return this.check(Ws(e,t))},int(e){return this.check(Ul(e))},safe(e){return this.check(Ul(e))},positive(e){return this.check(Gs(0,e))},nonnegative(e){return this.check(Ks(0,e))},negative(e){return this.check(Us(0,e))},nonpositive(e){return this.check(Ws(0,e))},multipleOf(e,t){return this.check(qs(e,t))},step(e,t){return this.check(qs(e,t))},finite(){return this}})),Ru=F(`ZodNumberFormat`,(e,t)=>{uo.init(e,t),Lu.init(e,t)}),zu=F(`ZodBoolean`,(e,t)=>{fo.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zc(e,t,n,r)}),Bu=F(`ZodUnknown`,(e,t)=>{po.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$c(e,t,n,r)}),Vu=F(`ZodNever`,(e,t)=>{mo.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qc(e,t,n,r)}),Hu=F(`ZodArray`,(e,t)=>{Vl(),go.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>il(e,t,n,r),e.element=t.element},{min(e,t){return this.check(Ys(e,t))},nonempty(e){return this.check(Ys(1,e))},max(e,t){return this.check(Js(e,t))},length(e,t){return this.check(Xs(e,t))},unwrap(){return this.element}}),Uu=F(`ZodObject`,(e,t)=>{Vl(),yo.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>al(e,t,n,r),rr(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Ql(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(xn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(xn(this._zod.def,{catchall:Gl()}))},loose(){return this.clone(xn(this._zod.def,{catchall:Gl()}))},strict(){return this.clone(xn(this._zod.def,{catchall:Kl()}))},strip(){return this.clone(xn(this._zod.def,{catchall:void 0}))},extend(e){return Pn(this,e)},safeExtend(e){return In(this,e)},merge(e){return Ln(this,e)},pick(e){return jn(this,e)},omit(e){return Nn(this,e)},partial(...e){return Rn(Xu,this,e[0])},exactPartial(...e){return Rn(Zu,this,e[0],`exactPartial`)},required(...e){return zn(td,this,e[0])}}),Wu=F(`ZodUnion`,(e,t)=>{bo.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ol(e,t,n,r),e.options=t.options}),Gu=F(`ZodIntersection`,(e,t)=>{xo.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sl(e,t,n,r)}),Ku=F(`ZodRecord`,(e,t)=>{Vl(),So.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ll(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType}),qu=F(`ZodEnum`,(e,t)=>{Co.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>el(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new qu({...t,checks:[],...N(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new qu({...t,checks:[],...N(r),entries:i})}}),Ju=F(`ZodLiteral`,(e,t)=>{wo.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tl(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})}),Yu=F(`ZodTransform`,(e,t)=>{Vl(),To.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rl(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Cr(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Xn(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(Xn(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}}),Xu=F(`ZodOptional`,(e,t)=>{Eo.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),Zu=F(`ZodExactOptional`,(e,t)=>{Do.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),Qu=F(`ZodNullable`,(e,t)=>{Oo.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ul(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),$u=F(`ZodDefault`,(e,t)=>{ko.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}),ed=F(`ZodPrefault`,(e,t)=>{Ao.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ml(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),td=F(`ZodNonOptional`,(e,t)=>{jo.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),nd=F(`ZodCatch`,(e,t)=>{Mo.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}),rd=F(`ZodPipe`,(e,t)=>{No.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gl(e,t,n,r),e.in=t.in,e.out=t.out}),id=F(`ZodReadonly`,(e,t)=>{Po.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_l(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),ad=F(`ZodCustom`,(e,t)=>{Fo.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nl(e,t,n,r)})})),sd=t((()=>{bl()}));function cd(e){return Fs(hu,e)}var ld=t((()=>{bl(),od()})),ud=t((()=>{bl(),od(),xl(),El(),zl(),sd(),yl(),cs(),gr(),xl(),ld(),od(),Io(),rs()})),dd=t((()=>{ud(),ud()})),U,fd,pd,W=t((()=>{dd(),U={FACEKEY_TOKEN_INVALID:`FACEKEY_TOKEN_INVALID`,FACEKEY_ALREADY_ENROLLED:`FACEKEY_ALREADY_ENROLLED`,FACEKEY_NOT_ENROLLED:`FACEKEY_NOT_ENROLLED`,FACEKEY_VERSION_MISMATCH:`FACEKEY_VERSION_MISMATCH`,FACEKEY_KEY_UNAVAILABLE:`FACEKEY_KEY_UNAVAILABLE`,FACEKEY_TEMPLATE_INVALID:`FACEKEY_TEMPLATE_INVALID`,FACEGATE_TOKEN_INVALID:`FACEGATE_TOKEN_INVALID`,FACEGATE_ABORTED:`FACEGATE_ABORTED`,FACEGATE_TIMEOUT:`FACEGATE_TIMEOUT`,CLIENT_KEY_REQUIRED:`CLIENT_KEY_REQUIRED`,API_KEY_FORBIDDEN:`API_KEY_FORBIDDEN`,CAMERA_INTERRUPTED:`CAMERA_INTERRUPTED`,CAMERA_NOT_FOUND:`CAMERA_NOT_FOUND`,CAMERA_PERMISSION_DENIED:`CAMERA_PERMISSION_DENIED`,CAMERA_UNAVAILABLE:`CAMERA_UNAVAILABLE`,CAMERA_UNSUPPORTED:`CAMERA_UNSUPPORTED`,CAPTURES_INCOMPLETE:`CAPTURES_INCOMPLETE`,CLIENT_ASSET_NOT_FOUND:`CLIENT_ASSET_NOT_FOUND`,CLIENT_NOT_AVAILABLE:`CLIENT_NOT_AVAILABLE`,CONTACT_RATE_LIMITED:`CONTACT_RATE_LIMITED`,DOCUMENT_BACK_CONTAINS_FACE:`DOCUMENT_BACK_CONTAINS_FACE`,DOCUMENT_BACK_NOT_DISTINCT:`DOCUMENT_BACK_NOT_DISTINCT`,DOCUMENT_BACK_REQUIRED:`DOCUMENT_BACK_REQUIRED`,DOCUMENT_BLURRY:`DOCUMENT_BLURRY`,DOCUMENT_CODE_TYPE_MISMATCH:`DOCUMENT_CODE_TYPE_MISMATCH`,DOCUMENT_FACE_GEOMETRY_INVALID:`DOCUMENT_FACE_GEOMETRY_INVALID`,DOCUMENT_FACE_NOT_CONTAINED:`DOCUMENT_FACE_NOT_CONTAINED`,DOCUMENT_FACE_NOT_FOUND:`DOCUMENT_FACE_NOT_FOUND`,DOCUMENT_NOT_FOUND:`DOCUMENT_NOT_FOUND`,DOCUMENT_NOT_RECOGNIZED:`DOCUMENT_NOT_RECOGNIZED`,DOCUMENT_TEXT_ALIGNMENT_INVALID:`DOCUMENT_TEXT_ALIGNMENT_INVALID`,DOCUMENT_TEXT_NOT_READABLE:`DOCUMENT_TEXT_NOT_READABLE`,DOCUMENT_VALIDATION_FAILED:`DOCUMENT_VALIDATION_FAILED`,EMAIL_ALREADY_REGISTERED:`EMAIL_ALREADY_REGISTERED`,EMAIL_DELIVERY_FAILED:`EMAIL_DELIVERY_FAILED`,EUROPEAN_LICENCE_BACK_MARKER_REQUIRED:`EUROPEAN_LICENCE_BACK_MARKER_REQUIRED`,FACE_ALIGNMENT_FAILED:`FACE_ALIGNMENT_FAILED`,FACE_LIGHTING_INVALID:`FACE_LIGHTING_INVALID`,FACE_MISMATCH:`FACE_MISMATCH`,FACE_NOT_FOUND:`FACE_NOT_FOUND`,FACE_NOT_STABLE:`FACE_NOT_STABLE`,FACE_NOT_USABLE:`FACE_NOT_USABLE`,FACE_OUT_OF_FRAME:`FACE_OUT_OF_FRAME`,FACE_POSE_INVALID:`FACE_POSE_INVALID`,GEO_DATABASE_DOWNLOAD_EMPTY:`GEO_DATABASE_DOWNLOAD_EMPTY`,GEO_DATABASE_DOWNLOAD_FAILED:`GEO_DATABASE_DOWNLOAD_FAILED`,IMAGE_DECODE_FAILED:`IMAGE_DECODE_FAILED`,IMAGE_ENCODE_FAILED:`IMAGE_ENCODE_FAILED`,IMAGE_PROCESSING_FAILED:`IMAGE_PROCESSING_FAILED`,IMAGE_TOO_LARGE:`IMAGE_TOO_LARGE`,INFERENCE_FAILED:`INFERENCE_FAILED`,INFERENCE_QUEUE_FULL:`INFERENCE_QUEUE_FULL`,INFERENCE_TIMEOUT:`INFERENCE_TIMEOUT`,VALIDATION_ERROR:`VALIDATION_ERROR`,RESPONSE_VALIDATION_ERROR:`RESPONSE_VALIDATION_ERROR`,RESOURCE_NOT_FOUND:`RESOURCE_NOT_FOUND`,RESOURCE_NOT_FOUND_IN_VIEW:`RESOURCE_NOT_FOUND_IN_VIEW`,REQUEST_TOO_LARGE:`REQUEST_TOO_LARGE`,INTERNAL_ERROR:`INTERNAL_ERROR`,INVALID_CREDENTIALS:`INVALID_CREDENTIALS`,BILLING_DETAILS_REQUIRED:`BILLING_DETAILS_REQUIRED`,PAYMENT_METHOD_NOT_FOUND:`PAYMENT_METHOD_NOT_FOUND`,PAYMENT_NOT_FOUND:`PAYMENT_NOT_FOUND`,RECOVERY_SENT:`RECOVERY_SENT`,INVALID_DOCUMENT_AAMVA:`INVALID_DOCUMENT_AAMVA`,INVALID_DOCUMENT_MRZ:`INVALID_DOCUMENT_MRZ`,INVALID_FACE_MATCH_INPUT:`INVALID_FACE_MATCH_INPUT`,INVALID_IMAGE:`INVALID_IMAGE`,INVALID_KEY_LABEL:`INVALID_KEY_LABEL`,INVALID_MODEL_OUTPUT:`INVALID_MODEL_OUTPUT`,INVALID_OPTIONS:`INVALID_OPTIONS`,INVALID_PASSPORT_MRZ:`INVALID_PASSPORT_MRZ`,INVALID_POSES:`INVALID_POSES`,INVALID_CLIENT_KEY:`INVALID_CLIENT_KEY`,INVALID_REGISTRATION:`INVALID_REGISTRATION`,INVALID_SERVICE_RESPONSE:`INVALID_SERVICE_RESPONSE`,INVALID_VERIFICATION_FEEDBACK:`INVALID_VERIFICATION_FEEDBACK`,INVALID_VERIFICATION_INPUT:`INVALID_VERIFICATION_INPUT`,KEY_NOT_FOUND:`KEY_NOT_FOUND`,MODEL_LOAD_FAILED:`MODEL_LOAD_FAILED`,MULTIPLE_FACES:`MULTIPLE_FACES`,NETWORK_ERROR:`NETWORK_ERROR`,NO_USABLE_CANDIDATES:`NO_USABLE_CANDIDATES`,NO_USABLE_REFERENCES:`NO_USABLE_REFERENCES`,OCR_DICTIONARY_MISMATCH:`OCR_DICTIONARY_MISMATCH`,OCR_ENVIRONMENT_MISMATCH:`OCR_ENVIRONMENT_MISMATCH`,OCR_LANGUAGE_UNSUPPORTED:`OCR_LANGUAGE_UNSUPPORTED`,OCR_MODEL_UNSUPPORTED:`OCR_MODEL_UNSUPPORTED`,PAYMENT_FAILED:`PAYMENT_FAILED`,BILLING_ACCOUNT_BLOCKED:`BILLING_ACCOUNT_BLOCKED`,ACCOUNT_HAS_UNBILLED_USAGE:`ACCOUNT_HAS_UNBILLED_USAGE`,POSE_IDENTITY_MISMATCH:`POSE_IDENTITY_MISMATCH`,POSE_BACKGROUND_MISMATCH:`POSE_BACKGROUND_MISMATCH`,SERVICE_UNAVAILABLE:`SERVICE_UNAVAILABLE`,SUPERADMIN_REQUIRED:`SUPERADMIN_REQUIRED`,UI_ELEMENT_NOT_FOUND:`UI_ELEMENT_NOT_FOUND`,UNAUTHORIZED:`UNAUTHORIZED`,USER_ACCESS_REQUIRED:`USER_ACCESS_REQUIRED`,USER_NOT_FOUND:`USER_NOT_FOUND`,VERIFICATION_CANCELLED:`VERIFICATION_CANCELLED`,VERIFICATION_SAVE_FAILED:`VERIFICATION_SAVE_FAILED`},fd=Ql(U),pd=({error:e,fallback:t=U.INTERNAL_ERROR})=>{let n=typeof e==`object`&&e&&`code`in e?fd.safeParse(e.code):null;if(n!==null&&n.success)return n.data;let r=e instanceof Error?e.message:e,i=fd.safeParse(r);return i.success?i.data:t},B({code:fd,message:z(),payload:Xl(z(),Gl()).optional()})})),md=n({InferenceSession:()=>pf,TRACE:()=>rf,TRACE_EVENT_BEGIN:()=>cf,TRACE_EVENT_END:()=>lf,TRACE_FUNC_BEGIN:()=>of,TRACE_FUNC_END:()=>sf,Tensor:()=>tf,default:()=>lm,env:()=>q,registerBackend:()=>Td}),hd,gd,_d,vd,yd,G,bd,xd,Sd,Cd,wd,Td,Ed,Dd,Od,kd,Ad,jd,Md,K,Nd,q,Pd,Fd,Id,Ld,Rd,zd,Bd,Vd,Hd,Ud,Wd,Gd,Kd,qd,Jd,Yd,Xd,Zd,Qd,$d,ef,tf,nf,rf,af,of,sf,cf,lf,uf,df,ff,pf,mf,hf,gf,_f,vf,yf,bf,xf,Sf,Cf,wf,Tf,Ef,Df,Of,kf,Af,jf,Mf,Nf,Pf,Ff,If,Lf,Rf,zf,Bf,Vf,Hf,Uf,Wf,Gf,Kf,qf,Jf,Yf,J,Xf,Zf,Qf,Y,$f,ep,tp,np,rp,ip,ap,op,sp,cp,lp,up,dp,fp,pp,mp,hp,gp,_p,vp,yp,bp,xp,Sp,Cp,wp,Tp,Ep,Dp,Op,kp,Ap,jp,Mp,Np,Pp,Fp,Ip,Lp,Rp,zp,Bp,Vp,Hp,Up,Wp,Gp,Kp,qp,Jp,Yp,Xp,Zp,Qp,$p,em,tm,nm,rm,im,am,om,sm,cm,lm,um=t((()=>{hd=Object.defineProperty,gd=Object.getOwnPropertyDescriptor,_d=Object.getOwnPropertyNames,vd=Object.prototype.hasOwnProperty,yd=(e=>typeof require<`u`?require:typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(typeof require<`u`?require:e)[t]}):e)(function(e){if(typeof require<`u`)return require.apply(this,arguments);throw Error(`Dynamic require of "`+e+`" is not supported`)}),G=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},bd=(e,t)=>{for(var n in t)hd(e,n,{get:t[n],enumerable:!0})},xd=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of _d(t))!vd.call(e,i)&&i!==n&&hd(e,i,{get:()=>t[i],enumerable:!(r=gd(t,i))||r.enumerable});return e},Sd=e=>xd(hd({},`__esModule`,{value:!0}),e),Od=G(()=>{"use strict";Cd=new Map,wd=[],Td=(e,t,n)=>{if(t&&typeof t.init==`function`&&typeof t.createInferenceSessionHandler==`function`){let r=Cd.get(e);if(r===void 0)Cd.set(e,{backend:t,priority:n});else{if(r.priority>n)return;if(r.priority===n&&r.backend!==t)throw Error(`cannot register backend "${e}" using priority ${n}`)}if(n>=0){let t=wd.indexOf(e);t!==-1&&wd.splice(t,1);for(let t=0;t<wd.length;t++)if(Cd.get(wd[t]).priority<=n){wd.splice(t,0,e);return}wd.push(e)}}else throw TypeError(`not a valid backend`)},Ed=async e=>{let t=Cd.get(e);if(!t)return`backend not found.`;if(t.initialized)return t.backend;if(t.aborted)return t.error;{let n=!!t.initPromise;try{return n||(t.initPromise=t.backend.init(e)),await t.initPromise,t.initialized=!0,t.backend}catch(e){return n||(t.error=`${e}`,t.aborted=!0),t.error}finally{delete t.initPromise}}},Dd=async e=>{let t=e.executionProviders||[],n=t.map(e=>typeof e==`string`?e:e.name),r=n.length===0?wd:n,i,a=[],o=new Set;for(let e of r){let t=await Ed(e);typeof t==`string`?a.push({name:e,err:t}):(i||=t,i===t&&o.add(e))}if(!i)throw Error(`no available backend found. ERR: ${a.map(e=>`[${e.name}] ${e.err}`).join(`, `)}`);for(let{name:e,err:t}of a)n.includes(e)&&console.warn(`removing requested execution provider "${e}" from session options because it is not available: ${t}`);let s=t.filter(e=>o.has(typeof e==`string`?e:e.name));return[i,new Proxy(e,{get:(e,t)=>t===`executionProviders`?s:Reflect.get(e,t)})]}}),kd=G(()=>{"use strict";Od()}),jd=G(()=>{"use strict";Ad=`1.30.0`}),Nd=G(()=>{"use strict";jd(),Md=`warning`,K={wasm:{},webgl:{},webgpu:{},versions:{common:Ad},set logLevel(e){if(e!==void 0){if(typeof e!=`string`||[`verbose`,`info`,`warning`,`error`,`fatal`].indexOf(e)===-1)throw Error(`Unsupported logging level: ${e}`);Md=e}},get logLevel(){return Md}},Object.defineProperty(K,"logLevel",{enumerable:!0})}),Pd=G(()=>{"use strict";Nd(),q=K}),Ld=G(()=>{"use strict";Fd=(e,t)=>{let n=typeof document<`u`?document.createElement(`canvas`):new OffscreenCanvas(1,1);n.width=e.dims[3],n.height=e.dims[2];let r=n.getContext(`2d`);if(r!=null){let i,a;t?.tensorLayout!==void 0&&t.tensorLayout===`NHWC`?(i=e.dims[2],a=e.dims[3]):(i=e.dims[3],a=e.dims[2]);let o=t?.format===void 0?`RGB`:t.format,s=t?.norm,c,l;s===void 0||s.mean===void 0?c=[255,255,255,255]:typeof s.mean==`number`?c=[s.mean,s.mean,s.mean,s.mean]:(c=[s.mean[0],s.mean[1],s.mean[2],0],s.mean[3]!==void 0&&(c[3]=s.mean[3])),s===void 0||s.bias===void 0?l=[0,0,0,0]:typeof s.bias==`number`?l=[s.bias,s.bias,s.bias,s.bias]:(l=[s.bias[0],s.bias[1],s.bias[2],0],s.bias[3]!==void 0&&(l[3]=s.bias[3]));let u=a*i,d=0,f=u,p=u*2,m=-1;o===`RGBA`?(d=0,f=u,p=u*2,m=u*3):o===`RGB`?(d=0,f=u,p=u*2):o===`RBG`&&(d=0,p=u,f=u*2);for(let t=0;t<a;t++)for(let n=0;n<i;n++){let i=(e.data[d++]-l[0])*c[0],a=(e.data[f++]-l[1])*c[1],o=(e.data[p++]-l[2])*c[2],s=m===-1?255:(e.data[m++]-l[3])*c[3];r.fillStyle=`rgba(`+i+`,`+a+`,`+o+`,`+s+`)`,r.fillRect(n,t,1,1)}if(`toDataURL`in n)return n.toDataURL();throw Error(`toDataURL is not supported`)}throw Error(`Can not access image data`)},Id=(e,t)=>{let n=typeof document<`u`?document.createElement(`canvas`).getContext(`2d`):new OffscreenCanvas(1,1).getContext(`2d`),r;if(n!=null){let i,a,o;t?.tensorLayout!==void 0&&t.tensorLayout===`NHWC`?(i=e.dims[2],a=e.dims[1],o=e.dims[3]):(i=e.dims[3],a=e.dims[2],o=e.dims[1]);let s=t!==void 0&&t.format!==void 0?t.format:`RGB`,c=t?.norm,l,u;c===void 0||c.mean===void 0?l=[255,255,255,255]:typeof c.mean==`number`?l=[c.mean,c.mean,c.mean,c.mean]:(l=[c.mean[0],c.mean[1],c.mean[2],255],c.mean[3]!==void 0&&(l[3]=c.mean[3])),c===void 0||c.bias===void 0?u=[0,0,0,0]:typeof c.bias==`number`?u=[c.bias,c.bias,c.bias,c.bias]:(u=[c.bias[0],c.bias[1],c.bias[2],0],c.bias[3]!==void 0&&(u[3]=c.bias[3]));let d=a*i;if(t!==void 0&&(t.format!==void 0&&o===4&&t.format!==`RGBA`||o===3&&t.format!==`RGB`&&t.format!==`BGR`))throw Error(`Tensor format doesn't match input tensor dims`);let f=0,p=1,m=2,h=3,g=0,_=d,v=d*2,y=-1;s===`RGBA`?(g=0,_=d,v=d*2,y=d*3):s===`RGB`?(g=0,_=d,v=d*2):s===`RBG`&&(g=0,v=d,_=d*2),r=n.createImageData(i,a);for(let t=0;t<a*i;f+=4,p+=4,m+=4,h+=4,t++)r.data[f]=(e.data[g++]-u[0])*l[0],r.data[p]=(e.data[_++]-u[1])*l[1],r.data[m]=(e.data[v++]-u[2])*l[2],r.data[h]=y===-1?255:(e.data[y++]-u[3])*l[3]}else throw Error(`Can not access image data`);return r}}),Wd=G(()=>{"use strict";ef(),Rd=(e,t)=>{if(e===void 0)throw Error(`Image buffer must be defined`);if(t.height===void 0||t.width===void 0)throw Error(`Image height and width must be defined`);if(t.tensorLayout===`NHWC`)throw Error(`NHWC Tensor layout is not supported yet`);let{height:n,width:r}=t,i=t.norm??{mean:255,bias:0},a,o;a=typeof i.mean==`number`?[i.mean,i.mean,i.mean,i.mean]:[i.mean[0],i.mean[1],i.mean[2],i.mean[3]??255],o=typeof i.bias==`number`?[i.bias,i.bias,i.bias,i.bias]:[i.bias[0],i.bias[1],i.bias[2],i.bias[3]??0];let s=t.format===void 0?`RGBA`:t.format,c=t.tensorFormat!==void 0&&t.tensorFormat!==void 0?t.tensorFormat:`RGB`,l=n*r,u=c===`RGBA`?new Float32Array(l*4):new Float32Array(l*3),d=4,f=0,p=1,m=2,h=3,g=0,_=l,v=l*2,y=-1;s===`RGB`&&(d=3,f=0,p=1,m=2,h=-1),c===`RGBA`?y=l*3:c===`RBG`?(g=0,v=l,_=l*2):c===`BGR`&&(v=0,_=l,g=l*2);for(let t=0;t<l;t++,f+=d,m+=d,p+=d,h+=d)u[g++]=(e[f]+o[0])/a[0],u[_++]=(e[p]+o[1])/a[1],u[v++]=(e[m]+o[2])/a[2],y!==-1&&h!==-1&&(u[y++]=(e[h]+o[3])/a[3]);return c===`RGBA`?new $d(`float32`,u,[1,4,n,r]):new $d(`float32`,u,[1,3,n,r])},zd=async(e,t)=>{let n=typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement,r=typeof ImageData<`u`&&e instanceof ImageData,i=typeof ImageBitmap<`u`&&e instanceof ImageBitmap,a=typeof e==`string`,o,s=t??{},c=()=>{if(typeof document<`u`)return document.createElement(`canvas`);if(typeof OffscreenCanvas<`u`)return new OffscreenCanvas(1,1);throw Error(`Canvas is not supported`)},l=e=>typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||e instanceof OffscreenCanvas?e.getContext(`2d`):null;if(n){let n=c();n.width=e.width,n.height=e.height;let r=l(n);if(r!=null){let n=e.height,i=e.width;if(t!==void 0&&t.resizedHeight!==void 0&&t.resizedWidth!==void 0&&(n=t.resizedHeight,i=t.resizedWidth),t!==void 0){if(s=t,t.tensorFormat!==void 0)throw Error(`Image input config format must be RGBA for HTMLImageElement`);s.tensorFormat=`RGBA`,s.height=n,s.width=i}else s.tensorFormat=`RGBA`,s.height=n,s.width=i;r.drawImage(e,0,0),o=r.getImageData(0,0,i,n).data}else throw Error(`Can not access image data`)}else if(r){let n,r;if(t!==void 0&&t.resizedWidth!==void 0&&t.resizedHeight!==void 0?(n=t.resizedHeight,r=t.resizedWidth):(n=e.height,r=e.width),t!==void 0&&(s=t),s.format=`RGBA`,s.height=n,s.width=r,t!==void 0){let t=c();t.width=r,t.height=n;let i=l(t);if(i!=null)i.putImageData(e,0,0),o=i.getImageData(0,0,r,n).data;else throw Error(`Can not access image data`)}else o=e.data}else if(i){if(t===void 0)throw Error(`Please provide image config with format for Imagebitmap`);let n=c();n.width=e.width,n.height=e.height;let r=l(n);if(r!=null){let t=e.height,n=e.width;return r.drawImage(e,0,0,n,t),o=r.getImageData(0,0,n,t).data,s.height=t,s.width=n,Rd(o,s)}throw Error(`Can not access image data`)}else{if(a)return new Promise((t,n)=>{let r=c(),i=l(r);if(!e||!i)return n();let a=new Image;a.crossOrigin=`Anonymous`,a.src=e,a.onload=()=>{r.width=a.width,r.height=a.height,i.drawImage(a,0,0,r.width,r.height);let e=i.getImageData(0,0,r.width,r.height);s.height=r.height,s.width=r.width,t(Rd(e.data,s))}});throw Error(`Input data provided is not supported - aborted tensor creation`)}if(o!==void 0)return Rd(o,s);throw Error(`Input data provided is not supported - aborted tensor creation`)},Bd=(e,t)=>{let{width:n,height:r,download:i,dispose:a}=t;return new $d({location:`texture`,type:`float32`,texture:e,dims:[1,r,n,4],download:i,dispose:a})},Vd=(e,t)=>{let{dataType:n,dims:r,download:i,dispose:a}=t;return new $d({location:`gpu-buffer`,type:n??`float32`,gpuBuffer:e,dims:r,download:i,dispose:a})},Hd=(e,t)=>{let{dataType:n,dims:r,download:i,dispose:a}=t;return new $d({location:`ml-tensor`,type:n??`float32`,mlTensor:e,dims:r,download:i,dispose:a})},Ud=(e,t,n)=>new $d({location:`cpu-pinned`,type:e,data:t,dims:n??[t.length]})}),Yd=G(()=>{"use strict";Gd=new Map([[`float32`,Float32Array],[`uint8`,Uint8Array],[`int8`,Int8Array],[`uint16`,Uint16Array],[`int16`,Int16Array],[`int32`,Int32Array],[`bool`,Uint8Array],[`float64`,Float64Array],[`uint32`,Uint32Array],[`int4`,Uint8Array],[`uint4`,Uint8Array]]),Kd=new Map([[Float32Array,`float32`],[Uint8Array,`uint8`],[Int8Array,`int8`],[Uint16Array,`uint16`],[Int16Array,`int16`],[Int32Array,`int32`],[Float64Array,`float64`],[Uint32Array,`uint32`]]),qd=!1,Jd=()=>{if(!qd){qd=!0;let e=typeof BigInt64Array<`u`&&BigInt64Array.from,t=typeof BigUint64Array<`u`&&BigUint64Array.from,n=globalThis.Float16Array,r=typeof n<`u`&&n.from;e&&(Gd.set(`int64`,BigInt64Array),Kd.set(BigInt64Array,`int64`)),t&&(Gd.set(`uint64`,BigUint64Array),Kd.set(BigUint64Array,`uint64`)),r?(Gd.set(`float16`,n),Kd.set(n,`float16`)):Gd.set(`float16`,Uint16Array)}}}),Qd=G(()=>{"use strict";ef(),Xd=e=>{let t=1;for(let n=0;n<e.length;n++){let r=e[n];if(typeof r!=`number`||!Number.isSafeInteger(r))throw TypeError(`dims[${n}] must be an integer, got: ${r}`);if(r<0)throw RangeError(`dims[${n}] must be a non-negative integer, got: ${r}`);t*=r}return t},Zd=(e,t)=>{switch(e.location){case`cpu`:return new $d(e.type,e.data,t);case`cpu-pinned`:return new $d({location:`cpu-pinned`,data:e.data,type:e.type,dims:t});case`texture`:return new $d({location:`texture`,texture:e.texture,type:e.type,dims:t});case`gpu-buffer`:return new $d({location:`gpu-buffer`,gpuBuffer:e.gpuBuffer,type:e.type,dims:t});case`ml-tensor`:return new $d({location:`ml-tensor`,mlTensor:e.mlTensor,type:e.type,dims:t});default:throw Error(`tensorReshape: tensor location ${e.location} is not supported`)}}}),ef=G(()=>{"use strict";Ld(),Wd(),Yd(),Qd(),$d=class{constructor(e,t,n){Jd();let r,i;if(typeof e==`object`&&`location`in e)switch(this.dataLocation=e.location,r=e.type,i=e.dims,e.location){case`cpu-pinned`:{let t=Gd.get(r);if(!t)throw TypeError(`unsupported type "${r}" to create tensor from pinned buffer`);if(!(e.data instanceof t))throw TypeError(`buffer should be of type ${t.name}`);this.cpuData=e.data;break}case`texture`:if(r!==`float32`)throw TypeError(`unsupported type "${r}" to create tensor from texture`);this.gpuTextureData=e.texture,this.downloader=e.download,this.disposer=e.dispose;break;case`gpu-buffer`:if(r!==`float32`&&r!==`float16`&&r!==`int32`&&r!==`int64`&&r!==`uint32`&&r!==`uint8`&&r!==`bool`&&r!==`uint4`&&r!==`int4`)throw TypeError(`unsupported type "${r}" to create tensor from gpu buffer`);this.gpuBufferData=e.gpuBuffer,this.downloader=e.download,this.disposer=e.dispose;break;case`ml-tensor`:if(r!==`float32`&&r!==`float16`&&r!==`int32`&&r!==`int64`&&r!==`uint32`&&r!==`uint64`&&r!==`int8`&&r!==`uint8`&&r!==`bool`&&r!==`uint4`&&r!==`int4`)throw TypeError(`unsupported type "${r}" to create tensor from MLTensor`);this.mlTensorData=e.mlTensor,this.downloader=e.download,this.disposer=e.dispose;break;default:throw Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let a,o;if(typeof e==`string`){if(r=e,o=n,e===`string`){if(!Array.isArray(t))throw TypeError(`A string tensor's data must be a string array.`);a=t}else{let n=Gd.get(e);if(n===void 0)throw TypeError(`Unsupported tensor type: ${e}.`);if(Array.isArray(t)){if(e===`float16`&&n===Uint16Array||e===`uint4`||e===`int4`)throw TypeError(`Creating a ${e} tensor from number array is not supported. Please use ${n.name} as data.`);a=e===`uint64`||e===`int64`?n.from(t,BigInt):n.from(t)}else if(t instanceof n)a=t;else if(t instanceof Uint8ClampedArray){if(e===`uint8`)a=Uint8Array.from(t);else throw TypeError(`A Uint8ClampedArray tensor's data must be type of uint8`)}else if(e===`float16`&&t instanceof Uint16Array&&n!==Uint16Array)a=new globalThis.Float16Array(t.buffer,t.byteOffset,t.length);else throw TypeError(`A ${r} tensor's data must be type of ${n}`)}}else if(o=t,Array.isArray(e)){if(e.length===0)throw TypeError(`Tensor type cannot be inferred from an empty array.`);let t=typeof e[0];if(t===`string`)r=`string`,a=e;else if(t===`boolean`)r=`bool`,a=Uint8Array.from(e);else throw TypeError(`Invalid element type of data array: ${t}.`)}else if(e instanceof Uint8ClampedArray)r=`uint8`,a=Uint8Array.from(e);else{let t=Kd.get(e.constructor);if(t===void 0)throw TypeError(`Unsupported type for tensor data: ${e.constructor}.`);r=t,a=e}if(o===void 0)o=[a.length];else if(!Array.isArray(o))throw TypeError(`A tensor's dims must be a number array`);i=o,this.cpuData=a,this.dataLocation=`cpu`}let a=Xd(i);if(this.cpuData&&a!==this.cpuData.length&&(r!==`uint4`&&r!==`int4`||Math.ceil(a/2)!==this.cpuData.length))throw Error(`Tensor's size(${a}) does not match data length(${this.cpuData.length}).`);this.type=r,this.dims=i,this.size=a}static async fromImage(e,t){return zd(e,t)}static fromTexture(e,t){return Bd(e,t)}static fromGpuBuffer(e,t){return Vd(e,t)}static fromMLTensor(e,t){return Hd(e,t)}static fromPinnedBuffer(e,t,n){return Ud(e,t,n)}toDataURL(e){return Fd(this,e)}toImageData(e){return Id(this,e)}get data(){if(this.ensureValid(),!this.cpuData)throw Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw Error(`The data is not stored as a WebGL texture.`);return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw Error(`The data is not stored as a WebGPU buffer.`);return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw Error(`The data is not stored as a WebNN MLTensor.`);return this.mlTensorData}async getData(e){switch(this.ensureValid(),this.dataLocation){case`cpu`:case`cpu-pinned`:return this.data;case`texture`:case`gpu-buffer`:case`ml-tensor`:if(!this.downloader)throw Error(`The current tensor is not created with a specified data downloader.`);if(this.isDownloading)throw Error(`The current tensor is being downloaded.`);try{this.isDownloading=!0;let t=await this.downloader();return this.downloader=void 0,this.dataLocation=`cpu`,this.cpuData=t,e&&this.disposer&&(this.disposer(),this.disposer=void 0),t}finally{this.isDownloading=!1}default:throw Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw Error(`The current tensor is being downloaded.`);this.disposer&&=(this.disposer(),void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation=`none`}ensureValid(){if(this.dataLocation===`none`)throw Error(`The tensor is disposed.`)}reshape(e){if(this.ensureValid(),this.downloader||this.disposer)throw Error(`Cannot reshape a tensor that owns GPU resource.`);return Zd(this,e)}}}),nf=G(()=>{"use strict";ef(),tf=$d}),uf=G(()=>{"use strict";Nd(),rf=(e,t)=>{(typeof K.trace>`u`?!K.wasm.trace:!K.trace)||console.timeStamp(`${e}::ORT::${t}`)},af=(e,t)=>{let n=Error().stack?.split(/\r\n|\r|\n/g)||[],r=!1;for(let i=0;i<n.length;i++){if(r&&!n[i].includes(`TRACE_FUNC`)){let r=`FUNC_${e}::${n[i].trim().split(` `)[1]}`;t&&(r+=`::${t}`),rf(`CPU`,r);return}n[i].includes(`TRACE_FUNC`)&&(r=!0)}},of=e=>{(typeof K.trace>`u`?!K.wasm.trace:!K.trace)||af(`BEGIN`,e)},sf=e=>{(typeof K.trace>`u`?!K.wasm.trace:!K.trace)||af(`END`,e)},cf=e=>{(typeof K.trace>`u`?!K.wasm.trace:!K.trace)||console.time(`ORT::${e}`)},lf=e=>{(typeof K.trace>`u`?!K.wasm.trace:!K.trace)||console.timeEnd(`ORT::${e}`)}}),ff=G(()=>{"use strict";Od(),nf(),uf(),df=class e{constructor(e){this.handler=e}async run(e,t,n){of(),cf(`InferenceSession.run`);let r={},i={};if(typeof e!=`object`||!e||e instanceof tf||Array.isArray(e))throw TypeError(`'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.`);let a=!0;if(typeof t==`object`){if(t===null)throw TypeError(`Unexpected argument[1]: cannot be null.`);if(t instanceof tf)throw TypeError(`'fetches' cannot be a Tensor`);if(Array.isArray(t)){if(t.length===0)throw TypeError(`'fetches' cannot be an empty array.`);a=!1;for(let e of t){if(typeof e!=`string`)throw TypeError(`'fetches' must be a string array or an object.`);if(this.outputNames.indexOf(e)===-1)throw RangeError(`'fetches' contains invalid output name: ${e}.`);r[e]=null}if(typeof n==`object`&&n)i=n;else if(typeof n<`u`)throw TypeError(`'options' must be an object.`)}else{let e=!1,o=Object.getOwnPropertyNames(t);for(let n of this.outputNames)if(o.indexOf(n)!==-1){let i=t[n];(i===null||i instanceof tf)&&(e=!0,a=!1,r[n]=i)}if(e){if(typeof n==`object`&&n)i=n;else if(typeof n<`u`)throw TypeError(`'options' must be an object.`)}else i=t}}else if(typeof t<`u`)throw TypeError(`Unexpected argument[1]: must be 'fetches' or 'options'.`);for(let t of this.inputNames)if(typeof e[t]>`u`)throw Error(`input '${t}' is missing in 'feeds'.`);if(a)for(let e of this.outputNames)r[e]=null;let o=await this.handler.run(e,r,i),s={};for(let e in o)if(Object.hasOwnProperty.call(o,e)){let t=o[e];s[e]=t instanceof tf?t:new tf(t.type,t.data,t.dims)}return lf(`InferenceSession.run`),sf(),s}async release(){return this.handler.dispose()}static async create(t,n,r,i){of(),cf(`InferenceSession.create`);let a,o={};if(typeof t==`string`){if(a=t,typeof n==`object`&&n)o=n;else if(typeof n<`u`)throw TypeError(`'options' must be an object.`)}else if(t instanceof Uint8Array){if(a=t,typeof n==`object`&&n)o=n;else if(typeof n<`u`)throw TypeError(`'options' must be an object.`)}else if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&t instanceof SharedArrayBuffer){let e=t,s=0,c=t.byteLength;if(typeof n==`object`&&n)o=n;else if(typeof n==`number`){if(s=n,!Number.isSafeInteger(s))throw RangeError(`'byteOffset' must be an integer.`);if(s<0||s>=e.byteLength)throw RangeError(`'byteOffset' is out of range [0, ${e.byteLength}).`);if(c=t.byteLength-s,typeof r==`number`){if(c=r,!Number.isSafeInteger(c))throw RangeError(`'byteLength' must be an integer.`);if(c<=0||s+c>e.byteLength)throw RangeError(`'byteLength' is out of range (0, ${e.byteLength-s}].`);if(typeof i==`object`&&i)o=i;else if(typeof i<`u`)throw TypeError(`'options' must be an object.`)}else if(typeof r<`u`)throw TypeError(`'byteLength' must be a number.`)}else if(typeof n<`u`)throw TypeError(`'options' must be an object.`);a=new Uint8Array(e,s,c)}else throw TypeError(`Unexpected argument[0]: must be 'path' or 'buffer'.`);let[s,c]=await Dd(o),l=await s.createInferenceSessionHandler(a,c);return lf(`InferenceSession.create`),sf(),new e(l)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}get inputMetadata(){return this.handler.inputMetadata}get outputMetadata(){return this.handler.outputMetadata}}}),mf=G(()=>{"use strict";ff(),pf=df}),hf=G(()=>{"use strict";}),gf=G(()=>{"use strict";}),_f=G(()=>{"use strict";}),vf=G(()=>{"use strict";}),yf={},bd(yf,{InferenceSession:()=>pf,TRACE:()=>rf,TRACE_EVENT_BEGIN:()=>cf,TRACE_EVENT_END:()=>lf,TRACE_FUNC_BEGIN:()=>of,TRACE_FUNC_END:()=>sf,Tensor:()=>tf,env:()=>q,registerBackend:()=>Td}),bf=G(()=>{"use strict";kd(),Pd(),mf(),nf(),hf(),gf(),uf(),_f(),vf()}),xf=G(()=>{"use strict";}),Sf={},bd(Sf,{default:()=>Tf}),Ef=G(()=>{"use strict";Np(),Xf(),Vf(),Cf=`ort-wasm-proxy-worker`,wf=globalThis.self?.name===Cf,wf&&(self.onmessage=e=>{let{type:t,in:n}=e.data;try{switch(t){case`init-wasm`:Yf(n.wasm).then(()=>{xp(n).then(()=>{postMessage({type:t})},e=>{postMessage({type:t,err:e})})},e=>{postMessage({type:t,err:e})});break;case`init-ep`:{let{epName:e,env:r}=n;Sp(r,e).then(()=>{postMessage({type:t})},e=>{postMessage({type:t,err:e})});break}case`copy-from`:{let{buffer:e}=n,r=Ep(e);postMessage({type:t,out:r});break}case`create`:{let{model:e,options:r}=n;Dp(e,r).then(e=>{postMessage({type:t,out:e})},e=>{postMessage({type:t,err:e})});break}case`release`:Op(n),postMessage({type:t});break;case`run`:{let{sessionId:e,inputIndices:r,inputs:i,outputIndices:a,options:o}=n;Ap(e,r,i,a,Array(a.length).fill(null),o).then(e=>{e.some(e=>e[3]!==`cpu`)?postMessage({type:t,err:`Proxy does not support non-cpu tensor location.`}):postMessage({type:t,out:e},Mp([...i,...e]))},e=>{postMessage({type:t,err:e})});break}case`end-profiling`:jp(n),postMessage({type:t})}}catch(e){postMessage({type:t,err:e})}}),Tf=wf?null:e=>new Worker(e??Af,{type:`module`,name:Cf})}),Vf=G(()=>{"use strict";xf(),Df=typeof location>`u`?void 0:location.origin,Of={}.url>`file:`&&{}.url<`file;`,kf=()=>Of?new URL(new URL(`ort.wasm.min.mjs`,{}.url).href,Df).href:{}.url,Af=kf(),jf=()=>{if(Af&&!Af.startsWith(`blob:`))return Af.substring(0,Af.lastIndexOf(`/`)+1)},Mf=(e,t)=>{try{let n=t??Af;return(n?new URL(e,n):new URL(e)).origin===Df}catch{return!1}},Nf=(e,t)=>{let n=t??Af;try{return(n?new URL(e,n):new URL(e)).href}catch{return}},Pf=(e,t)=>`${t??`./`}${e}`,Ff=async e=>{let t=await(await fetch(e,{credentials:`same-origin`})).blob();return URL.createObjectURL(t)},If=async e=>(await import(e)).default,Lf=(Ef(),Sd(Sf)).default,Rf=async()=>{if(!Af)throw Error(`Failed to load proxy worker: cannot determine the script source URL.`);if(Mf(Af))return[void 0,Lf()];let e=await Ff(Af);return[e,Lf(e)]},zf=void 0,Bf=async(e,t,n,r)=>{let i=zf&&!(e||t);if(i){if(Af)i=Mf(Af)||r&&!n;else if(r&&!n)i=!0;else throw Error(`cannot determine the script source URL.`)}if(i)return[void 0,zf];{let r=`ort-wasm-simd-threaded.mjs`,i=e??Nf(r,t),a=n&&i&&!Mf(i,t),o=a?await Ff(i):i??Pf(r,t);return[a?o:void 0,await If(o)]}}}),Xf=G(()=>{"use strict";Vf(),Uf=!1,Wf=!1,Gf=!1,Kf=()=>{if(typeof SharedArrayBuffer>`u`)return!1;try{return typeof MessageChannel<`u`&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}},qf=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}},Jf=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,19,1,17,0,65,1,253,15,65,2,253,15,65,3,253,15,253,147,2,11]))}catch{return!1}},Yf=async e=>{if(Uf)return Promise.resolve();if(Wf)throw Error(`multiple calls to 'initializeWebAssembly()' detected.`);if(Gf)throw Error(`previous call to 'initializeWebAssembly()' failed.`);Wf=!0;let t=e.initTimeout,n=e.numThreads;if(e.simd!==!1){if(e.simd===`relaxed`){if(!Jf())throw Error(`Relaxed WebAssembly SIMD is not supported in the current environment.`)}else if(!qf())throw Error(`WebAssembly SIMD is not supported in the current environment.`)}let r=Kf();n>1&&!r&&(typeof self<`u`&&!self.crossOriginIsolated&&console.warn(`env.wasm.numThreads is set to `+n+`, but this will not work unless you enable crossOriginIsolated mode. See https://web.dev/cross-origin-isolation-guide/ for more info.`),console.warn(`WebAssembly multi-threading is not supported in the current environment. Falling back to single-threading.`),e.numThreads=n=1);let i=e.wasmPaths,a=typeof i==`string`?i:void 0,o=i?.mjs,s=o?.href??o,c=i?.wasm,l=c?.href??c,u=e.wasmBinary,[d,f]=await Bf(s,a,n>1,!!u||!!l),p=!1,m=[];if(t>0&&m.push(new Promise(e=>{setTimeout(()=>{p=!0,e()},t)})),m.push(new Promise((e,t)=>{let r={numThreads:n};if(u)r.wasmBinary=u,r.locateFile=e=>e;else if(l||a)r.locateFile=e=>l??a+e;else if(s&&s.indexOf(`blob:`)!==0)r.locateFile=e=>new URL(e,s).href;else if(d){let e=jf();e&&(r.locateFile=t=>e+t)}f(r).then(t=>{Wf=!1,Uf=!0,Hf=t,e(),d&&URL.revokeObjectURL(d)},e=>{Wf=!1,Gf=!0,t(e)})})),await Promise.race(m),p)throw Error(`WebAssembly backend initializing failed due to timeout: ${t}ms`)},J=()=>{if(Uf&&Hf)return Hf;throw Error(`WebAssembly is not initialized yet.`)}}),$f=G(()=>{"use strict";Xf(),Zf=(e,t)=>{let n=J(),r=n.lengthBytesUTF8(e)+1,i=n._malloc(r);return n.stringToUTF8(e,i,r),t.push(i),i},Qf=(e,t,n,r)=>{if(typeof e==`object`&&e){if(n.has(e))throw Error(`Circular reference in options`);n.add(e)}Object.entries(e).forEach(([e,i])=>{let a=t?t+e:e;if(typeof i==`object`)Qf(i,a+`.`,n,r);else if(typeof i==`string`||typeof i==`number`)r(a,i.toString());else if(typeof i==`boolean`)r(a,i?`1`:`0`);else throw Error(`Can't handle extra config type: ${typeof i}`)})},Y=e=>{let t=J(),n=t.stackSave();try{let n=t.PTR_SIZE,r=t.stackAlloc(2*n);t._OrtGetLastError(r,r+n);let i=Number(t.getValue(r,n===4?`i32`:`i64`)),a=t.getValue(r+n,`*`),o=a?t.UTF8ToString(a):``;throw Error(`${e} ERROR_CODE: ${i}, ERROR_MESSAGE: ${o}`)}finally{t.stackRestore(n)}}}),tp=G(()=>{"use strict";Xf(),$f(),ep=e=>{let t=J(),n=0,r=[],i=e||{};try{if(e?.logSeverityLevel===void 0)i.logSeverityLevel=2;else if(typeof e.logSeverityLevel!=`number`||!Number.isInteger(e.logSeverityLevel)||e.logSeverityLevel<0||e.logSeverityLevel>4)throw Error(`log severity level is not valid: ${e.logSeverityLevel}`);if(e?.logVerbosityLevel===void 0)i.logVerbosityLevel=0;else if(typeof e.logVerbosityLevel!=`number`||!Number.isInteger(e.logVerbosityLevel))throw Error(`log verbosity level is not valid: ${e.logVerbosityLevel}`);e?.terminate===void 0&&(i.terminate=!1);let a=0;return e?.tag!==void 0&&(a=Zf(e.tag,r)),n=t._OrtCreateRunOptions(i.logSeverityLevel,i.logVerbosityLevel,!!i.terminate,a),n===0&&Y(`Can't create run options.`),e?.extra!==void 0&&Qf(e.extra,``,new WeakSet,(e,i)=>{let a=Zf(e,r),o=Zf(i,r);t._OrtAddRunConfigEntry(n,a,o)!==0&&Y(`Can't set a run config entry: ${e} - ${i}.`)}),[n,r]}catch(e){throw n!==0&&t._OrtReleaseRunOptions(n),r.forEach(e=>t._free(e)),e}}}),cp=G(()=>{"use strict";Xf(),$f(),np=e=>{switch(e){case`disabled`:return 0;case`basic`:return 1;case`extended`:return 2;case`layout`:return 3;case`all`:return 99;default:throw Error(`unsupported graph optimization level: ${e}`)}},rp=e=>{switch(e){case`sequential`:return 0;case`parallel`:return 1;default:throw Error(`unsupported execution mode: ${e}`)}},ip=e=>{e.extra||={},e.extra.session||(e.extra.session={});let t=e.extra.session;t.use_ort_model_bytes_directly||=`1`,e.executionProviders&&e.executionProviders.some(e=>(typeof e==`string`?e:e.name)===`webgpu`)&&(e.enableMemPattern=!1)},ap=(e,t,n,r)=>{let i=Zf(t,r),a=Zf(n,r);J()._OrtAddSessionConfigEntry(e,i,a)!==0&&Y(`Can't set a session config entry: ${t} - ${n}.`)},op=async(e,t,n)=>{let r=t.executionProviders;for(let t of r){let r=typeof t==`string`?t:t.name,i=[];switch(r){case`webnn`:if(r=`WEBNN`,ap(e,`session.disable_quant_qdq`,`1`,n),ap(e,`session.disable_qdq_constant_folding`,`1`,n),typeof t!=`string`){let r=t?.deviceType;r&&ap(e,`deviceType`,r,n)}break;case`webgpu`:if(r=`JS`,typeof t!=`string`){let r=t;if(r?.preferredLayout){if(r.preferredLayout!==`NCHW`&&r.preferredLayout!==`NHWC`)throw Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${r.preferredLayout}`);ap(e,`preferredLayout`,r.preferredLayout,n)}}break;case`wasm`:case`cpu`:continue;default:throw Error(`not supported execution provider: ${r}`)}let a=Zf(r,n),o=i.length,s=0,c=0;if(o>0){s=J()._malloc(o*J().PTR_SIZE),n.push(s),c=J()._malloc(o*J().PTR_SIZE),n.push(c);for(let e=0;e<o;e++)J().setValue(s+e*J().PTR_SIZE,i[e][0],`*`),J().setValue(c+e*J().PTR_SIZE,i[e][1],`*`)}await J()._OrtAppendExecutionProvider(e,a,s,c,o)!==0&&Y(`Can't append execution provider: ${r}.`)}},sp=async e=>{let t=J(),n=0,r=[],i=e||{};ip(i);try{let e=np(i.graphOptimizationLevel??`all`),a=rp(i.executionMode??`sequential`),o=typeof i.logId==`string`?Zf(i.logId,r):0,s=i.logSeverityLevel??2;if(!Number.isInteger(s)||s<0||s>4)throw Error(`log severity level is not valid: ${s}`);let c=i.logVerbosityLevel??0;if(!Number.isInteger(c)||c<0||c>4)throw Error(`log verbosity level is not valid: ${c}`);let l=typeof i.optimizedModelFilePath==`string`?Zf(i.optimizedModelFilePath,r):0;if(n=t._OrtCreateSessionOptions(e,!!i.enableCpuMemArena,!!i.enableMemPattern,a,!!i.enableProfiling,0,o,s,c,l),n===0&&Y(`Can't create session options.`),i.executionProviders&&await op(n,i,r),i.enableGraphCapture!==void 0){if(typeof i.enableGraphCapture!=`boolean`)throw Error(`enableGraphCapture must be a boolean value: ${i.enableGraphCapture}`);ap(n,`enableGraphCapture`,i.enableGraphCapture.toString(),r)}if(i.freeDimensionOverrides)for(let[e,a]of Object.entries(i.freeDimensionOverrides)){if(typeof e!=`string`)throw Error(`free dimension override name must be a string: ${e}`);if(typeof a!=`number`||!Number.isInteger(a)||a<0)throw Error(`free dimension override value must be a non-negative integer: ${a}`);let i=Zf(e,r);t._OrtAddFreeDimensionOverride(n,i,a)!==0&&Y(`Can't set a free dimension override: ${e} - ${a}.`)}return i.extra!==void 0&&Qf(i.extra,``,new WeakSet,(e,t)=>{ap(n,e,t,r)}),[n,r]}catch(e){throw n!==0&&t._OrtReleaseSessionOptions(n)!==0&&Y(`Can't release session options.`),r.forEach(e=>t._free(e)),e}}}),_p=G(()=>{"use strict";lp=e=>{switch(e){case`int8`:return 3;case`uint8`:return 2;case`bool`:return 9;case`int16`:return 5;case`uint16`:return 4;case`int32`:return 6;case`uint32`:return 12;case`float16`:return 10;case`float32`:return 1;case`float64`:return 11;case`string`:return 8;case`int64`:return 7;case`uint64`:return 13;case`int4`:return 22;case`uint4`:return 21;default:throw Error(`unsupported data type: ${e}`)}},up=e=>{switch(e){case 3:return`int8`;case 2:return`uint8`;case 9:return`bool`;case 5:return`int16`;case 4:return`uint16`;case 6:return`int32`;case 12:return`uint32`;case 10:return`float16`;case 1:return`float32`;case 11:return`float64`;case 8:return`string`;case 7:return`int64`;case 13:return`uint64`;case 22:return`int4`;case 21:return`uint4`;default:throw Error(`unsupported data type: ${e}`)}},dp=(e,t)=>{let n=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][e],r=typeof t==`number`?t:t.reduce((e,t)=>e*t,1);return n>0?Math.ceil(r*n):void 0},fp=e=>{switch(e){case`float16`:return typeof Float16Array<`u`?Float16Array:Uint16Array;case`float32`:return Float32Array;case`uint8`:return Uint8Array;case`int8`:return Int8Array;case`uint16`:return Uint16Array;case`int16`:return Int16Array;case`int32`:return Int32Array;case`bool`:return Uint8Array;case`float64`:return Float64Array;case`uint32`:return Uint32Array;case`int64`:return BigInt64Array;case`uint64`:return BigUint64Array;default:throw Error(`unsupported type: ${e}`)}},pp=e=>{switch(e){case`verbose`:return 0;case`info`:return 1;case`warning`:return 2;case`error`:return 3;case`fatal`:return 4;default:throw Error(`unsupported logging level: ${e}`)}},mp=e=>e===`float32`||e===`float16`||e===`int32`||e===`int64`||e===`uint32`||e===`uint8`||e===`bool`||e===`uint4`||e===`int4`,hp=e=>e===`float32`||e===`float16`||e===`int32`||e===`int64`||e===`uint32`||e===`uint64`||e===`int8`||e===`uint8`||e===`bool`||e===`uint4`||e===`int4`,gp=e=>{switch(e){case`none`:return 0;case`cpu`:return 1;case`cpu-pinned`:return 2;case`texture`:return 3;case`gpu-buffer`:return 4;case`ml-tensor`:return 5;default:throw Error(`unsupported data location: ${e}`)}}}),yp=G(()=>{"use strict";xf(),vp=async e=>{if(typeof e==`string`){let t=await fetch(e);if(!t.ok)throw Error(`failed to load external data file: ${e}`);let n=t.headers.get(`Content-Length`),r=n?parseInt(n,10):0;if(r<1073741824)return new Uint8Array(await t.arrayBuffer());{if(!t.body)throw Error(`failed to load external data file: ${e}, no response body.`);let n=t.body.getReader(),i;try{i=new ArrayBuffer(r)}catch(e){if(e instanceof RangeError){let e=Math.ceil(r/65536);i=new WebAssembly.Memory({initial:e,maximum:e}).buffer}else throw e}let a=0;for(;;){let{done:e,value:t}=await n.read();if(e)break;let r=t.byteLength;new Uint8Array(i,a,r).set(t),a+=r}return new Uint8Array(i,0,r)}}return e instanceof Blob?new Uint8Array(await e.arrayBuffer()):e instanceof Uint8Array?e:new Uint8Array(e)}}),Np=G(()=>{"use strict";bf(),tp(),cp(),_p(),Xf(),$f(),yp(),bp=(e,t)=>{J()._OrtInit(e,t)!==0&&Y(`Can't initialize onnxruntime.`)},xp=async e=>{bp(e.wasm.numThreads,pp(e.logLevel))},Sp=async(e,t)=>{J().asyncInit?.();let n=e.webgpu.adapter;if(t===`webgpu`){if(typeof navigator>`u`||!navigator.gpu)throw Error(`WebGPU is not supported in current environment`);if(n){if(typeof n.limits!=`object`||typeof n.features!=`object`||typeof n.requestDevice!=`function`)throw Error("Invalid GPU adapter set in `env.webgpu.adapter`. It must be a GPUAdapter object.")}else{let t=e.webgpu.powerPreference;if(t!==void 0&&t!==`low-power`&&t!==`high-performance`)throw Error(`Invalid powerPreference setting: "${t}"`);let r=e.webgpu.forceFallbackAdapter;if(r!==void 0&&typeof r!=`boolean`)throw Error(`Invalid forceFallbackAdapter setting: "${r}"`);if(n=await navigator.gpu.requestAdapter({powerPreference:t,forceFallbackAdapter:r}),!n)throw Error(`Failed to get GPU adapter. You may need to enable flag "--enable-unsafe-webgpu" if you are using Chrome.`)}}if(t===`webnn`&&(typeof navigator>`u`||!navigator.ml))throw Error(`WebNN is not supported in current environment`)},Cp=new Map,wp=e=>{let t=J(),n=t.stackSave();try{let n=t.PTR_SIZE,r=t.stackAlloc(2*n);t._OrtGetInputOutputCount(e,r,r+n)!==0&&Y(`Can't get session input/output count.`);let i=n===4?`i32`:`i64`;return[Number(t.getValue(r,i)),Number(t.getValue(r+n,i))]}finally{t.stackRestore(n)}},Tp=(e,t)=>{let n=J(),r=n.stackSave(),i=0;try{let r=n.PTR_SIZE,a=n.stackAlloc(2*r);n._OrtGetInputOutputMetadata(e,t,a,a+r)!==0&&Y(`Can't get session input/output metadata.`);let o=Number(n.getValue(a,`*`));i=Number(n.getValue(a+r,`*`));let s=n.HEAP32[i/4];if(s===0)return[o,0];let c=n.HEAPU32[i/4+1],l=[];for(let e=0;e<c;e++){let t=Number(n.getValue(i+8+e*r,`*`));l.push(t===0?Number(n.getValue(i+8+(e+c)*r,`*`)):n.UTF8ToString(t))}return[o,s,l]}finally{n.stackRestore(r),i!==0&&n._OrtFree(i)}},Ep=e=>{let t=J(),n=t._malloc(e.byteLength);if(n===0)throw Error(`Can't create a session. failed to allocate a buffer of size ${e.byteLength}.`);return t.HEAPU8.set(e,n),[n,e.byteLength]},Dp=async(e,t)=>{let n,r,i=J();Array.isArray(e)?[n,r]=e:e.buffer===i.HEAPU8.buffer?[n,r]=[e.byteOffset,e.byteLength]:[n,r]=Ep(e);let a=0,o=0,s=[],c=[],l=[];try{if([o,s]=await sp(t),t?.externalData&&i.mountExternalData){let e=[];for(let n of t.externalData){let t=typeof n==`string`?n:n.path,r=typeof n==`string`?n:n.data;e.push(vp(r).then(e=>{i.mountExternalData(t,e)}))}await Promise.all(e)}for(let e of t?.executionProviders??[])if((typeof e==`string`?e:e.name)===`webnn`){if(i.shouldTransferToMLTensor=!1,typeof e!=`string`){let t=e,n=t?.context,r=t?.gpuDevice,a=t?.deviceType,o=t?.powerPreference;i.currentContext=n||(r?await i.webnnCreateMLContext(r):await i.webnnCreateMLContext({deviceType:a,powerPreference:o}))}else i.currentContext=await i.webnnCreateMLContext();break}a=await i._OrtCreateSession(n,r,o),i.webgpuOnCreateSession?.(a),a===0&&Y(`Can't create a session.`),i.jsepOnCreateSession?.(),i.currentContext&&(i.webnnRegisterMLContext(a,i.currentContext),i.currentContext=void 0,i.shouldTransferToMLTensor=!0);let[e,u]=wp(a),d=!!t?.enableGraphCapture,f=[],p=[],m=[],h=[];for(let t=0;t<e;t++){let[e,n,r]=Tp(a,t);e===0&&Y(`Can't get an input name.`),c.push(e);let o=i.UTF8ToString(e);f.push(o),m.push(n===0?{name:o,isTensor:!1}:{name:o,isTensor:!0,type:up(n),shape:r})}for(let t=0;t<u;t++){let[n,r,o]=Tp(a,t+e);n===0&&Y(`Can't get an output name.`),l.push(n);let s=i.UTF8ToString(n);p.push(s),h.push(r===0?{name:s,isTensor:!1}:{name:s,isTensor:!0,type:up(r),shape:o})}return Cp.set(a,[a,c,l,null,d,!1]),[a,f,p,m,h]}catch(e){throw c.forEach(e=>i._OrtFree(e)),l.forEach(e=>i._OrtFree(e)),a!==0&&i._OrtReleaseSession(a)!==0&&Y(`Can't release session.`),e}finally{i._free(n),o!==0&&i._OrtReleaseSessionOptions(o)!==0&&Y(`Can't release session options.`),s.forEach(e=>i._free(e)),i.unmountExternalData?.()}},Op=e=>{let t=J(),n=Cp.get(e);if(!n)throw Error(`cannot release session. invalid session id: ${e}`);let[r,i,a,o,s]=n;o&&(s&&t._OrtClearBoundOutputs(o.handle)!==0&&Y(`Can't clear bound outputs.`),t._OrtReleaseBinding(o.handle)!==0&&Y(`Can't release IO binding.`)),t.jsepOnReleaseSession?.(e),t.webnnOnReleaseSession?.(e),t.webgpuOnReleaseSession?.(e),i.forEach(e=>t._OrtFree(e)),a.forEach(e=>t._OrtFree(e)),t._OrtReleaseSession(r)!==0&&Y(`Can't release session.`),Cp.delete(e)},kp=async(e,t,n,r,i,a,o=!1)=>{if(!e){t.push(0);return}let s=J(),c=s.PTR_SIZE,l=e[0],u=e[1],d=e[3],f=d,p,m;if(l===`string`&&(d===`gpu-buffer`||d===`ml-tensor`))throw Error(`String tensor is not supported on GPU.`);if(o&&d!==`gpu-buffer`)throw Error(`External buffer must be provided for input/output index ${a} when enableGraphCapture is true.`);if(d===`gpu-buffer`){let t=e[2].gpuBuffer;m=dp(lp(l),u);{let e=s.jsepRegisterBuffer;if(!e)throw Error(`Tensor location "gpu-buffer" is not supported without using WebGPU.`);p=e(r,a,t,m)}}else if(d===`ml-tensor`){let t=e[2].mlTensor;m=dp(lp(l),u);let n=s.webnnRegisterMLTensor;if(!n)throw Error(`Tensor location "ml-tensor" is not supported without using WebNN.`);p=n(r,t,lp(l),u)}else{let t=e[2];if(Array.isArray(t)){m=c*t.length,p=s._malloc(m),n.push(p);for(let e=0;e<t.length;e++){if(typeof t[e]!=`string`)throw TypeError(`tensor data at index ${e} is not a string`);s.setValue(p+e*c,Zf(t[e],n),`*`)}}else{let e=s.webnnIsGraphInput,a=s.webnnIsGraphOutput;if(l!==`string`&&e&&a){let o=s.UTF8ToString(i);if(e(r,o)||a(r,o)){let e=lp(l);m=dp(e,u),f=`ml-tensor`;let n=s.webnnCreateTemporaryTensor,i=s.webnnUploadTensor;if(!n||!i)throw Error(`Tensor location "ml-tensor" is not supported without using WebNN.`);let a=await n(r,e,u);i(a,new Uint8Array(t.buffer,t.byteOffset,t.byteLength)),p=a}else m=t.byteLength,p=s._malloc(m),n.push(p),s.HEAPU8.set(new Uint8Array(t.buffer,t.byteOffset,m),p)}else m=t.byteLength,p=s._malloc(m),n.push(p),s.HEAPU8.set(new Uint8Array(t.buffer,t.byteOffset,m),p)}}let h=s.stackSave(),g=s.stackAlloc(4*u.length);try{u.forEach((e,t)=>s.setValue(g+t*c,e,c===4?`i32`:`i64`));let e=s._OrtCreateTensor(lp(l),p,m,g,u.length,gp(f));e===0&&Y(`Can't create tensor for input/output. session=${r}, index=${a}.`),t.push(e)}finally{s.stackRestore(h)}},Ap=async(e,t,n,r,i,a)=>{let o=J(),s=o.PTR_SIZE,c=Cp.get(e);if(!c)throw Error(`cannot run inference. invalid session id: ${e}`);let l=c[0],u=c[1],d=c[2],f=c[3],p=c[4];c[5];let m=t.length,h=r.length,g=0,_=[],v=[],y=[],b=[],x=[],S=o.stackSave(),C=o.stackAlloc(m*s),w=o.stackAlloc(m*s),T=o.stackAlloc(h*s),E=o.stackAlloc(h*s);try{[g,_]=ep(a),cf(`wasm prepareInputOutputTensor`);for(let r=0;r<m;r++)await kp(n[r],v,b,e,u[t[r]],t[r],p);for(let t=0;t<h;t++)await kp(i[t],y,b,e,d[r[t]],m+r[t],p);lf(`wasm prepareInputOutputTensor`);for(let e=0;e<m;e++)o.setValue(C+e*s,v[e],`*`),o.setValue(w+e*s,u[t[e]],`*`);for(let e=0;e<h;e++)o.setValue(T+e*s,y[e],`*`),o.setValue(E+e*s,d[r[e]],`*`);o.jsepOnRunStart?.(l),o.webnnOnRunStart?.(l);let c;c=await o._OrtRun(l,w,C,m,E,h,T,g),c!==0&&Y(`failed to call OrtRun().`);let S=[],ee=[];cf(`wasm ProcessOutputTensor`);for(let t=0;t<h;t++){let n=Number(o.getValue(T+t*s,`*`));if(n===y[t]||x.includes(y[t])){S.push(i[t]),n!==y[t]&&o._OrtReleaseTensor(n)!==0&&Y(`Can't release tensor.`);continue}let a=o.stackSave(),c=o.stackAlloc(4*s),l=!1,u,d=0;try{o._OrtGetTensorData(n,c,c+s,c+2*s,c+3*s)!==0&&Y(`Can't access output tensor data on index ${t}.`);let i=s===4?`i32`:`i64`,a=Number(o.getValue(c,i));d=o.getValue(c+s,`*`);let p=o.getValue(c+s*2,`*`),m=Number(o.getValue(c+s*3,i)),h=[];for(let e=0;e<m;e++)h.push(Number(o.getValue(p+e*s,i)));o._OrtFree(p)!==0&&Y(`Can't free memory for tensor dims.`);let g=h.reduce((e,t)=>e*t,1);u=up(a);let _=f?.outputPreferredLocations[r[t]];if(u===`string`){if(_===`gpu-buffer`||_===`ml-tensor`)throw Error(`String tensor is not supported on GPU.`);let e=[];for(let t=0;t<g;t++){let n=o.getValue(d+t*s,`*`),r=o.getValue(d+(t+1)*s,`*`),i=t===g-1?void 0:r-n;e.push(o.UTF8ToString(n,i))}S.push([u,h,e,`cpu`])}else if(_===`gpu-buffer`&&g>0){let e=o.jsepGetBuffer;if(!e)throw Error(`preferredLocation "gpu-buffer" is not supported without using WebGPU.`);let t=e(d),r=dp(a,g);if(r===void 0||!mp(u))throw Error(`Unsupported data type: ${u}`);l=!0,S.push([u,h,{gpuBuffer:t,download:o.jsepCreateDownloader(t,r,u),dispose:()=>{o._OrtReleaseTensor(n)!==0&&Y(`Can't release tensor.`)}},`gpu-buffer`])}else if(_===`ml-tensor`&&g>0){let t=o.webnnEnsureTensor,r=o.webnnIsGraphInputOutputTypeSupported;if(!t||!r)throw Error(`preferredLocation "ml-tensor" is not supported without using WebNN.`);if(dp(a,g)===void 0||!hp(u))throw Error(`Unsupported data type: ${u}`);if(!r(e,u,!1))throw Error(`preferredLocation "ml-tensor" for ${u} output is not supported by current WebNN Context.`);let i=await t(e,d,a,h,!1);l=!0,S.push([u,h,{mlTensor:i,download:o.webnnCreateMLTensorDownloader(d,u),dispose:()=>{o.webnnReleaseTensorId(d),o._OrtReleaseTensor(n)}},`ml-tensor`])}else if(_===`ml-tensor-cpu-output`&&g>0){let e=o.webnnCreateMLTensorDownloader(d,u)(),t=S.length;l=!0,ee.push((async()=>{let r=[t,await e];return o.webnnReleaseTensorId(d),o._OrtReleaseTensor(n),r})()),S.push([u,h,[],`cpu`])}else{let e=new(fp(u))(g);new Uint8Array(e.buffer,e.byteOffset,e.byteLength).set(o.HEAPU8.subarray(d,d+e.byteLength)),S.push([u,h,e,`cpu`])}}finally{o.stackRestore(a),u===`string`&&d&&o._free(d),l||o._OrtReleaseTensor(n)}}f&&!p&&(o._OrtClearBoundOutputs(f.handle)!==0&&Y(`Can't clear bound outputs.`),Cp.set(e,[l,u,d,f,p,!1]));for(let[e,t]of await Promise.all(ee))S[e][2]=t;return lf(`wasm ProcessOutputTensor`),S}finally{o.webnnOnRunEnd?.(l),o.stackRestore(S),v.forEach(e=>o._OrtReleaseTensor(e)),y.forEach(e=>o._OrtReleaseTensor(e)),b.forEach(e=>o._free(e)),g!==0&&o._OrtReleaseRunOptions(g),_.forEach(e=>o._free(e))}},jp=e=>{let t=J(),n=Cp.get(e);if(!n)throw Error(`invalid session id`);let r=n[0],i=t._OrtEndProfiling(r);i===0&&Y(`Can't get an profile file name.`),t._OrtFree(i)},Mp=e=>{let t=[];for(let n of e){let e=n[2];!Array.isArray(e)&&`buffer`in e&&t.push(e.buffer)}return t}}),Qp=G(()=>{"use strict";bf(),Np(),Xf(),Vf(),Pp=()=>!!q.wasm.proxy&&typeof document<`u`,Ip=!1,Lp=!1,Rp=!1,Vp=new Map,Hp=(e,t)=>{let n=Vp.get(e);n?n.push(t):Vp.set(e,[t])},Up=()=>{if(Ip||!Lp||Rp||!Fp)throw Error(`worker not ready`)},Wp=e=>{switch(e.data.type){case`init-wasm`:Ip=!1,e.data.err?(Rp=!0,Bp[1](e.data.err)):(Lp=!0,Bp[0]()),zp&&=(URL.revokeObjectURL(zp),void 0);break;case`init-ep`:case`copy-from`:case`create`:case`release`:case`run`:case`end-profiling`:{let t=Vp.get(e.data.type);e.data.err?t.shift()[1](e.data.err):t.shift()[0](e.data.out);break}}},Gp=async()=>{if(!Lp){if(Ip)throw Error(`multiple calls to 'initWasm()' detected.`);if(Rp)throw Error(`previous call to 'initWasm()' failed.`);if(Ip=!0,Pp())return new Promise((e,t)=>{Fp?.terminate(),Rf().then(([n,r])=>{try{Fp=r,Fp.onerror=e=>t(e),Fp.onmessage=Wp,Bp=[e,t];let i={type:`init-wasm`,in:q};if(!i.in.wasm.wasmPaths&&n){let e=jf();e&&(i.in.wasm.wasmPaths=e)}Fp.postMessage(i),zp=n}catch(e){t(e)}},t)});try{await Yf(q.wasm),await xp(q),Lp=!0}catch(e){throw Rp=!0,e}finally{Ip=!1}}},Kp=async e=>{if(Pp())return Up(),new Promise((t,n)=>{Hp(`init-ep`,[t,n]);let r={type:`init-ep`,in:{epName:e,env:q}};Fp.postMessage(r)});await Sp(q,e)},qp=async e=>Pp()?(Up(),new Promise((t,n)=>{Hp(`copy-from`,[t,n]);let r={type:`copy-from`,in:{buffer:e}};Fp.postMessage(r,[e.buffer])})):Ep(e),Jp=async(e,t)=>{if(Pp()){if(t?.preferredOutputLocation)throw Error(`session option "preferredOutputLocation" is not supported for proxy.`);return Up(),new Promise((n,r)=>{Hp(`create`,[n,r]);let i={type:`create`,in:{model:e,options:{...t}}},a=[];e instanceof Uint8Array&&a.push(e.buffer),Fp.postMessage(i,a)})}return Dp(e,t)},Yp=async e=>{if(Pp())return Up(),new Promise((t,n)=>{Hp(`release`,[t,n]);let r={type:`release`,in:e};Fp.postMessage(r)});Op(e)},Xp=async(e,t,n,r,i,a)=>{if(Pp()){if(n.some(e=>e[3]!==`cpu`))throw Error(`input tensor on GPU is not supported for proxy.`);if(i.some(e=>e))throw Error(`pre-allocated output tensor is not supported for proxy.`);return Up(),new Promise((i,o)=>{Hp(`run`,[i,o]);let s=n,c={type:`run`,in:{sessionId:e,inputIndices:t,inputs:s,outputIndices:r,options:a}};Fp.postMessage(c,Mp(s))})}return Ap(e,t,n,r,i,a)},Zp=async e=>{if(Pp())return Up(),new Promise((t,n)=>{Hp(`end-profiling`,[t,n]);let r={type:`end-profiling`,in:e};Fp.postMessage(r)});jp(e)}}),nm=G(()=>{"use strict";bf(),Qp(),_p(),xf(),yp(),$p=(e,t)=>{switch(e.location){case`cpu`:return[e.type,e.dims,e.data,`cpu`];case`gpu-buffer`:return[e.type,e.dims,{gpuBuffer:e.gpuBuffer},`gpu-buffer`];case`ml-tensor`:return[e.type,e.dims,{mlTensor:e.mlTensor},`ml-tensor`];default:throw Error(`invalid data location: ${e.location} for ${t()}`)}},em=e=>{switch(e[3]){case`cpu`:return new tf(e[0],e[2],e[1]);case`gpu-buffer`:{let t=e[0];if(!mp(t))throw Error(`not supported data type: ${t} for deserializing GPU tensor`);let{gpuBuffer:n,download:r,dispose:i}=e[2];return tf.fromGpuBuffer(n,{dataType:t,dims:e[1],download:r,dispose:i})}case`ml-tensor`:{let t=e[0];if(!hp(t))throw Error(`not supported data type: ${t} for deserializing MLTensor tensor`);let{mlTensor:n,download:r,dispose:i}=e[2];return tf.fromMLTensor(n,{dataType:t,dims:e[1],download:r,dispose:i})}default:throw Error(`invalid data location: ${e[3]}`)}},tm=class{async fetchModelAndCopyToWasmMemory(e){return qp(await vp(e))}async loadModel(e,t){of();let n;n=typeof e==`string`?await this.fetchModelAndCopyToWasmMemory(e):e,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await Jp(n,t),sf()}async dispose(){return Yp(this.sessionId)}async run(e,t,n){of();let r=[],i=[];Object.entries(e).forEach(e=>{let t=e[0],n=e[1],a=this.inputNames.indexOf(t);if(a===-1)throw Error(`invalid input '${t}'`);r.push(n),i.push(a)});let a=[],o=[];Object.entries(t).forEach(e=>{let t=e[0],n=e[1],r=this.outputNames.indexOf(t);if(r===-1)throw Error(`invalid output '${t}'`);a.push(n),o.push(r)});let s=r.map((e,t)=>$p(e,()=>`input "${this.inputNames[i[t]]}"`)),c=a.map((e,t)=>e?$p(e,()=>`output "${this.outputNames[o[t]]}"`):null),l=await Xp(this.sessionId,i,s,o,c,n),u={};for(let e=0;e<l.length;e++)u[this.outputNames[o[e]]]=a[e]??em(l[e]);return sf(),u}startProfiling(){}endProfiling(){Zp(this.sessionId)}}}),rm={},bd(rm,{OnnxruntimeWebAssemblyBackend:()=>am,initializeFlags:()=>im,wasmBackend:()=>om}),sm=G(()=>{"use strict";bf(),Qp(),nm(),im=()=>{(typeof q.wasm.initTimeout!=`number`||q.wasm.initTimeout<0)&&(q.wasm.initTimeout=0);let e=q.wasm.simd;if(typeof e!=`boolean`&&e!==void 0&&e!==`fixed`&&e!==`relaxed`&&(console.warn(`Property "env.wasm.simd" is set to unknown value "${e}". Reset it to \`false\` and ignore SIMD feature checking.`),q.wasm.simd=!1),typeof q.wasm.proxy!=`boolean`&&(q.wasm.proxy=!1),typeof q.wasm.trace!=`boolean`&&(q.wasm.trace=!1),typeof q.wasm.numThreads!=`number`||!Number.isInteger(q.wasm.numThreads)||q.wasm.numThreads<=0){if(typeof self<`u`&&!self.crossOriginIsolated)q.wasm.numThreads=1;else{let e=typeof navigator>`u`?yd(`node:os`).cpus().length:navigator.hardwareConcurrency;q.wasm.numThreads=Math.min(4,Math.ceil((e||1)/2))}}},am=class{async init(e){im(),await Gp(),await Kp(e)}async createInferenceSessionHandler(e,t){let n=new tm;return await n.loadModel(e,t),n}},om=new am}),bf(),bf(),bf(),cm=`1.30.0`,lm=yf;{let e=(sm(),Sd(rm)).wasmBackend;Td(`cpu`,e,10),Td(`wasm`,e,10)}Object.defineProperty(q.versions,"web",{value:cm,enumerable:!0})})),dm,fm=t((()=>{dm={"dd.ort":`259d860d37e4d12055a63e17685992265ad7d07e656e7ceb564d6e97464f5066`,"do.ort":`d77468ab16b74fd8268cb9d2179aa7fc7d45a5658d3684128d516b1729fd5776`,"fd.ort":`328a81c28493a21cf65b7be4322b1c16d726c485c59615a916dd2090ae1cedec`,"fdl.ort":`d1367545b14a23ec8f827e00580f06f13467f08bbd7399230f1d44bb423c8e10`,"fdh.ort":`5315c6b22309439a3ba1e853133e3ef7ffd43a8d34910bd35e9eacc3c6cacdd0`,"fl.ort":`fa9272923b5f12d61809ceee5611c698c6527e8603857c108891fa4ec41385bf`,"fe.ort":`d1a3c6d54a24b696e88ee12856624c2ea92b9f014f1c4483eb47788c8a6f1f33`,"fm.ort":`34652e9faf44e8a092aad1613d4c67d6775de3f212f3c68f865059ee2b40876d`,"fmh.ort":`57211303a9ded4edc6d98eefed051e029fe56377beb3be1d790c29adb234681a`,"fmu.ort":`f29c1f06155166bd9aa3c50cdb479d1a224c180d761a2d9c8102b1a759155d9b`,"od.ort":`f47d2359be464ca55c28c9986f1b8bf7ee8b3e9ff86e8ecb25d8b2f8eaa55c9e`,"or.ort":`4c7818163f775a89bddba87569edef3f2964f05855ee600d3a34d02c53715fc7`,"ods.ort":`062ed9d8d3e1dfeca55c15763c850ba701f642199d294f7e14a4ea6110dcc43b`,"ors.ort":`f7b99bfde9d06e8cd6844c26d2a0b3d2bb3b6d0c005f1c8003aa241ff89dc466`,"odm.ort":`0896849bbddb9e447b4ab2dcc3b7e40a76efb97199b7195d85f325340239d0f9`,"orj.ort":`bc9c51ff695f866dfb167219f5e8891e9c420b08fad427fe447e922ee16c3450`,"orcs.ort":`86be3129de7cd6d363d5d69bfe5cda792c188d144deca0f2f26cc83d1da9cc21`,"orct.ort":`9690a26ecf8f8a38dbcf763cd9b8a496fba361339e55bfaddbdd46f4462d4d81`,"orc.ort":`5d3c49fc3b5c376a2f4162156d1c5009d63fa3990d37fb807f33dd3227b3f445`,"ora.ort":`470417d05cd0a99b3345af0b970dd337084c5b79d3562e58f92c2196360f6bda`,"ot.txt":`c5cbe34ef40c29c4df07ed012bf96569cb69a2d2a01a07027e9f13cb832bd9cd`,"ots.txt":`41557512862dfe31970cf22407742b629725461dd84c0d8771bde9c87c2202c8`,"otj.txt":`1dcfcb41eec90576a945b3084f22ade11ced506e24f14879245b071698f308e8`,"otcs.txt":`28b2362ad4ab2dc38769aa72feb535e3a9ddb3fd2a7585a05920e6393b1dc7f7`,"otct.txt":`832551fee1f2fbc97508772d81ebdc8dba12c00de97a35c71c9ddf43ddac1a83`,"otc.txt":`90822a96058eb83f8e637ace75f90cbd36c41253f9dbdfb88fcf5a2bdd50d669`,"ota.txt":`7f92f7dbb9b75a4787a83bfb4f6d14a8ab515525130c9d40a9036f61cf6999e9`}})),pm,mm,hm,gm,_m,vm,ym,bm,xm,Sm=t((()=>{W(),fm(),pm=dm,mm=new Map,hm=globalThis.document?.currentScript,gm=globalThis.HTMLScriptElement&&hm instanceof globalThis.HTMLScriptElement?hm.src:``,_m=typeof{}.url==`string`?{}.url:``,vm=()=>globalThis.__VOLTOM_ASSET_BASE_URL__,ym=()=>vm()||gm||globalThis.location?.href||_m||`http://localhost/`,bm=({filename:e})=>{let t=pm[e];if(!t&&/\.(onnx|ort|txt)$/.test(e))throw Error(U.MODEL_LOAD_FAILED);let n=new URL(`./${t?`models`:`assets`}/${e}`,ym());return t&&n.searchParams.set(`v`,t),n.href},xm=async({filenames:e})=>{let t=[...new Set(e)];await Promise.all(t.map(async e=>{let t=bm({filename:e}),n=mm.get(t);n||(n=(async()=>{let e=await fetch(t);if(!e.ok)throw Error(U.MODEL_LOAD_FAILED);await e.arrayBuffer()})(),mm.set(t,n));try{await n}catch(e){throw mm.get(t)===n&&mm.delete(t),e}}))}})),Cm,wm,Tm=t((()=>{Cm=({box:e,image:t})=>{let n=Math.max(0,Math.floor(e.left)),r=Math.max(0,Math.floor(e.top)),i=Math.min(t.width,Math.ceil(e.right)),a=Math.min(t.height,Math.ceil(e.bottom)),o=Math.max(1,i-n),s=Math.max(1,a-r),c=new Uint8ClampedArray(o*s*4);for(let e=0;e<s;e+=1){let i=((r+e)*t.width+n)*4,a=e*o*4;c.set(t.data.subarray(i,i+o*4),a)}return{data:c,height:s,width:o}},wm=({height:e,image:t,width:n})=>{let r=new Uint8ClampedArray(n*e*4),i=t.width/n,a=t.height/e;for(let o=0;o<e;o+=1){let e=Math.min(t.height-1,Math.floor((o+.5)*a));for(let a=0;a<n;a+=1){let s=Math.min(t.width-1,Math.floor((a+.5)*i)),c=(e*t.width+s)*4,l=(o*n+a)*4;r[l]=t.data[c]??0,r[l+1]=t.data[c+1]??0,r[l+2]=t.data[c+2]??0,r[l+3]=255}}return{data:r,height:e,width:n}}})),Em,Dm,Om,km=t((()=>{Em=null,Dm=({category:e,duration:t,key:n})=>{if(!Em)return;let r=Em[e];r[n]=(r[n]??0)+t},Om=async({key:e,operation:t})=>{let n=performance.now();try{return await t()}finally{Dm({category:`stages`,duration:performance.now()-n,key:e})}}})),Am,jm,Mm,Nm,Pm,Fm,Im,Lm,Rm,zm,Bm,Vm,Hm,Um,Wm,Gm=t((()=>{W(),Tm(),km(),Am=.3,jm=.6,Mm=12,Nm=3,Pm=async({session:e,tensor:t})=>{let n=performance.now();try{let n=await e.run({[e.inputNames[0]]:t}),r=n[e.outputNames[0]];if(!r){for(let e of Object.values(n))e.dispose();throw Error(U.INVALID_MODEL_OUTPUT)}for(let e of Object.values(n))e!==r&&e.dispose();return r}catch(e){throw Error(pd({error:e,fallback:U.INFERENCE_FAILED}),{cause:e})}finally{Dm({category:`inference`,duration:performance.now()-n,key:`ocr`}),t.dispose()}},Fm=({text:e})=>e.normalize(`NFKC`).replace(/\r\n?/gu,`
|
|
56
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function tc(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;tc(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}function nc(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function rc(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!sc.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??nc(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Jt(n,r,e.length===1?e[0]:rc(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=nc(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function ic(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of sc)if(t in e)return;let n=t.filter(e=>cc.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=rc(t);else{let e=n[0],i=cc.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>rc([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Xs(e,r))}function ac(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Xs(i,s),Xs(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())tc(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])ic(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Xs(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Jt(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:uc(t,`input`,e.processors),output:uc(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function oc(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return oc(r.element,n);if(r.type===`set`)return oc(r.valueType,n);if(r.type===`lazy`)return oc(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return oc(r.innerType,n);if(r.type===`intersection`)return oc(r.left,n)||oc(r.right,n);if(r.type===`record`||r.type===`map`)return oc(r.keyType,n)||oc(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:oc(r.in,n)||oc(r.out,n);if(r.type===`object`){for(let e in r.shape)if(oc(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(oc(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(oc(e,n))return!0;return!!(r.rest&&oc(r.rest,n))}return!1}var sc,cc,lc,uc,dc=t((()=>{Wo(),Zn(),sc=new Set([`type`,`properties`,`required`,`additionalProperties`]),cc=[`oneOf`,`anyOf`],lc=(e,t={})=>n=>{let r=Zs({...n,processors:t});return R(e,r),ec(r,e),ac(r,e)},uc=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Zs({...i??{},target:a,io:t,processors:n});return R(e,o),ec(o,e),ac(o,e)}}));function fc(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Dc[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&_c(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&_c(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&vc(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&vc(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&bc(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Sc(t,i.mime);for(let e of i.patterns??[])xc(t,e);return t}function pc(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?pc(t.out):t.type===`catch`?pc(t.innerType):e._zod.optin}function mc(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=mc(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>mc(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i&&(p.type=`string`,a||(p.pattern=(r.includes(`number`)?pi:fi).source)),p}function hc(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of Wc.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=mc(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}function gc(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Qs(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),Jc):JSON.parse(o)}var _c,vc,yc,bc,xc,Sc,Cc,wc,Tc,Ec,Dc,Oc,kc,Ac,jc,Mc,Nc,Pc,Fc,Ic,Lc,Rc,zc,Bc,Vc,Hc,Uc,Wc,Gc,Kc,qc,Jc,Yc,Xc,Zc,Qc,$c,el,tl=t((()=>{_i(),vo(),dc(),Zn(),_c=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},vc=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},yc=(e,t)=>{_c(e,`minimum`,t),vc(e,`maximum`,t)},bc=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},xc=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},Sc=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Cc=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},wc=(e,t)=>_c(e,`minimum`,t.minimum),Tc=(e,t)=>vc(e,`maximum`,t.maximum),Ec=e=>(t,n)=>{Cc(t,n.format);let[r,i]=e[n.format];_c(t,`minimum`,r),vc(t,`maximum`,i)},Dc={greater_than:(e,t)=>_c(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>vc(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>bc(e,t.value),number_format:Ec(Wn),bigint_format:Ec(Gn),min_length:wc,max_length:Tc,length_equals:(e,t)=>yc(e,t.length),min_size:wc,max_size:Tc,size_equals:(e,t)=>yc(e,t.size),string_format:(e,t)=>{Cc(e,t.format),t.pattern&&xc(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Sc(e,t.mime)},Oc={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},kc=new Map([[Ra,ai],[Ba,oi]]),Ac=e=>kc.get(e)??e,jc=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=fc(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Oc[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(Ac);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Mc=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=fc(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):Qs(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},Nc=(e,t,n,r)=>{n.type=`boolean`},Pc=(e,t,n,r)=>{n.not={}},Fc=(e,t,n,r)=>{},Ic=(e,t,n,r)=>{let i=e._zod.def,a=Vt(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},Lc=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(Qs(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(Qs(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},Rc=(e,t,n,r)=>{Qs(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},zc=(e,t,n,r)=>{Qs(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},Bc=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=fc(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=R(a.element,t,{...r,path:[...r.path,`items`]})},Vc=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Qs(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Jt(i.properties,e,R(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?pc(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=R(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Hc=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>R(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Uc=(e,t,n,r)=>{let i=e._zod.def,a=R(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=R(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},Wc=new WeakMap,Gc=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=fc(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=R(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)Jt(i.patternProperties,Ac(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=R(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=Wc.get(t);n||(n=[],Wc.set(t,n),t.deferred.push(()=>hc(t))),n.push(e)}i.additionalProperties=R(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&pc(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},Kc=(e,t,n,r)=>{let i=e._zod.def,a=R(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},qc=(e,t,n,r)=>{let i=e._zod.def;R(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Jc=Symbol(),Yc=(e,t,n,r)=>{let i=e._zod.def;R(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=gc(i.defaultValue,e,t,n,r);o!==Jc&&(n.default=o)},Xc=(e,t,n,r)=>{let i=e._zod.def;R(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=gc(i.defaultValue,e,t,n,r);o!==Jc&&(n._prefault=o)},Zc=(e,t,n,r)=>{let i=e._zod.def;R(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Qs(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},Qc=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;R(o,t,r);let s=t.seen.get(e);s.ref=o},$c=(e,t,n,r)=>{let i=e._zod.def;R(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},el=(e,t,n,r)=>{let i=e._zod.def;R(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType}})),nl=t((()=>{or(),Lr(),_r(),vo(),Io(),Ii(),Bi(),Zn(),_i(),zo(),Wo(),Ri(),Go(),Ys(),dc(),tl(),dc()})),rl=t((()=>{nl()}));function il(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var al,ol,sl,cl=t((()=>{nl(),Zn(),al=new WeakSet([Object.prototype,Error.prototype]),ol=(e,t)=>{gr.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);al.has(n)||(al.add(n),il(n,`format`,e=>t=>dr(e,t)),il(n,`flatten`,e=>t=>ur(e,t)),il(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ut,2)}),il(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ut,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},sl=F(`ZodError`,ol,void 0,{Parent:Error})})),ll,ul,dl,fl,pl,ml,hl,gl,_l,vl,yl,bl,xl=t((()=>{nl(),cl(),ll=xr(sl),ul=Sr(sl),dl=Cr(sl),fl=wr(sl),pl=kr(sl),ml=Ar(sl),hl=jr(sl),gl=Mr(sl),_l=Nr(sl),vl=Pr(sl),yl=Fr(sl),bl=Ir(sl)}));function Sl(){ar.localeError||$n(Lo())}function Cl(){ar.memoizer||$n({memoizer:wo()})}function z(e){return qo(Xl,e)}function wl(e){return Xo(ru,e)}function B(e){return bs(bu,e)}function Tl(e){return xs(xu,e)}function El(e){return Ss(Su,e)}function Dl(){return Cs(Cu)}function Ol(e){return ws(wu,e)}function kl(e,t){return Gs(Tu,e,t)}function V(e,t){let n={type:`object`,shape:e??{},...N(t)};return new Eu(n)}function Al(e,t){return new Du({type:`union`,options:e,...N(t)})}function jl(e,t){return new Ou({type:`intersection`,left:e,right:t})}function Ml(e,t,n){return!t||!t._zod?new ku({type:`record`,keyType:z(),valueType:e,...N(t)}):new ku({type:`record`,keyType:e,valueType:t,...N(n)})}function Nl(e,t,n){return new ku({type:`record`,keyType:e,valueType:t,...N(n),partial:!0})}function Pl(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Au({type:`enum`,entries:n,...N(t)})}function Fl(e,t){return new ju({type:`literal`,values:Array.isArray(e)?e:[e],...N(t)})}function Il(e){return new Mu({type:`transform`,transform:e})}function Ll(e){return new Nu({type:`optional`,innerType:e})}function Rl(e){return new Pu({type:`optional`,innerType:e})}function zl(e){return new Fu({type:`nullable`,innerType:e})}function Bl(e,t){return new Iu({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():sn(t)}})}function Vl(e,t){return new Lu({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():sn(t)}})}function Hl(e,t){return new Ru({type:`nonoptional`,innerType:e,...N(t)})}function Ul(e,t){return new zu({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:zn(t)})}function Wl(e,t){return new Bu({type:`pipe`,in:e,out:t})}function Gl(e){return new Hu({type:`readonly`,innerType:e})}function Kl(e,t={}){return Ks(Uu,e,t)}function ql(e,t){return qs(e,t)}function Jl(e,t){return new Vu({type:`pipe`,in:Il(e),out:t})}var H,Yl,Xl,U,Zl,Ql,$l,eu,tu,nu,ru,iu,au,ou,su,cu,lu,uu,du,fu,pu,mu,hu,gu,_u,vu,yu,bu,xu,Su,Cu,wu,Tu,Eu,Du,Ou,ku,Au,ju,Mu,Nu,Pu,Fu,Iu,Lu,Ru,zu,Bu,Vu,Hu,Uu,Wu=t((()=>{nl(),tl(),dc(),zo(),rl(),xl(),H=F(`ZodType`,(e,t)=>(Sl(),I.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(tn(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ln(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Kl(e,t))},superRefine(e,t){return this.check(ql(e,t))},overwrite(e){return this.check(zs(e))},optional(){return Ll(this)},exactOptional(){return Rl(this)},nullable(){return zl(this)},nullish(){return Ll(zl(this))},nonoptional(e){return Hl(this,e)},array(){return kl(this)},or(e){return Al([this,e])},and(e){return jl(this,e)},transform(e){return Wl(this,Il(e))},default(e){return Bl(this,e)},prefault(e){return Vl(this,e)},catch(e){return Ul(this,e)},pipe(e){return Wl(this,e)},readonly(){return Gl(this)},describe(e){let t=this.clone();return Uo.add(t,{description:e}),t},meta(...e){if(e.length===0)return Uo.get(this);let t=this.clone();return Uo.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Pn(this,`~standard`,{...Hi(this),jsonSchema:{input:uc(this,`input`),output:uc(this,`output`)}})},set"~standard"(e){Nn(this,`~standard`,e)},parse:function e(t,n){return ll(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await ul(this,t,n,{callee:e})},safeParse(e,t){return dl(this,e,t)},async safeParseAsync(e,t){return fl(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Nn(this,`spa`,e)},validate(e,t){return Dr(this,e,t)},validateAsync(e,t){return Or(this,e,t)},encode:function e(t,n){return pl(this,t,n,{callee:e})},decode:function e(t,n){return ml(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await hl(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await gl(this,t,n,{callee:e})},safeEncode(e,t){return _l(this,e,t)},safeDecode(e,t){return vl(this,e,t)},async safeEncodeAsync(e,t){return yl(this,e,t)},async safeDecodeAsync(e,t){return bl(this,e,t)},toJSONSchema(e){return lc(this,{})(e)},get description(){return Uo.get(this)?.description},get _def(){return this._zod.def}}),Yl=F(`_ZodString`,(e,t)=>{ga.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jc(e,t,n,r)},Fn({format:e=>fc(e).format??null,minLength:e=>fc(e).minimum??null,maxLength:e=>fc(e).maximum??null},{regex(...e){return this.check(Ns(...e))},includes(...e){return this.check(Is(...e))},startsWith(...e){return this.check(Ls(...e))},endsWith(...e){return this.check(Rs(...e))},min(...e){return this.check(js(...e))},max(...e){return this.check(As(...e))},length(...e){return this.check(Ms(...e))},nonempty(...e){return this.check(js(1,...e))},lowercase(e){return this.check(Ps(e))},uppercase(e){return this.check(Fs(e))},trim(){return this.check(Vs())},normalize(...e){return this.check(Bs(...e))},toLowerCase(){return this.check(Hs())},toUpperCase(){return this.check(Us())},slugify(){return this.check(Ws())}})),Xl=F(`ZodString`,(e,t)=>{ga.init(e,t),Yl.init(e,t)},{email(e){return this.check(Jo(tu,e))},url(e){return this.check(es(iu,e))},jwt(e){return this.check(hs(yu,e))},emoji(e){return this.check(ts(au,e))},guid(e){return this.check(Yo(nu,e))},uuid(e){return this.check(Xo(ru,e))},uuidv4(e){return this.check(Zo(ru,e))},uuidv6(e){return this.check(Qo(ru,e))},uuidv7(e){return this.check($o(ru,e))},nanoid(e){return this.check(ns(ou,e))},cuid(e){return this.check(rs(su,e))},cuid2(e){return this.check(is(cu,e))},ulid(e){return this.check(as(lu,e))},base64(e){return this.check(fs(gu,e))},base64url(e){return this.check(ps(_u,e))},xid(e){return this.check(os(uu,e))},ksuid(e){return this.check(ss(du,e))},ipv4(e){return this.check(cs(fu,e))},ipv6(e){return this.check(ls(pu,e))},cidrv4(e){return this.check(us(mu,e))},cidrv6(e){return this.check(ds(hu,e))},e164(e){return this.check(ms(vu,e))},datetime(e){return this.check(gs(Zl,e))},date(e){return this.check(_s(Ql,e))},time(e){return this.check(vs($l,e))},duration(e){return this.check(ys(eu,e))}}),U=F(`ZodStringFormat`,(e,t)=>{L.init(e,t),Yl.init(e,t)}),Zl=F(`ZodISODateTime`,(e,t)=>{ka.init(e,t),U.init(e,t)}),Ql=F(`ZodISODate`,(e,t)=>{Aa.init(e,t),U.init(e,t)}),$l=F(`ZodISOTime`,(e,t)=>{ja.init(e,t),U.init(e,t)}),eu=F(`ZodISODuration`,(e,t)=>{Ma.init(e,t),U.init(e,t)}),tu=F(`ZodEmail`,(e,t)=>{ya.init(e,t),U.init(e,t)}),nu=F(`ZodGUID`,(e,t)=>{_a.init(e,t),U.init(e,t)}),ru=F(`ZodUUID`,(e,t)=>{va.init(e,t),U.init(e,t)}),iu=F(`ZodURL`,(e,t)=>{xa.init(e,t),U.init(e,t)}),au=F(`ZodEmoji`,(e,t)=>{Sa.init(e,t),U.init(e,t)}),ou=F(`ZodNanoID`,(e,t)=>{Ca.init(e,t),U.init(e,t)}),su=F(`ZodCUID`,(e,t)=>{wa.init(e,t),U.init(e,t)}),cu=F(`ZodCUID2`,(e,t)=>{Ta.init(e,t),U.init(e,t)}),lu=F(`ZodULID`,(e,t)=>{Ea.init(e,t),U.init(e,t)}),uu=F(`ZodXID`,(e,t)=>{Da.init(e,t),U.init(e,t)}),du=F(`ZodKSUID`,(e,t)=>{Oa.init(e,t),U.init(e,t)}),fu=F(`ZodIPv4`,(e,t)=>{Na.init(e,t),U.init(e,t)}),pu=F(`ZodIPv6`,(e,t)=>{Fa.init(e,t),U.init(e,t)}),mu=F(`ZodCIDRv4`,(e,t)=>{Ia.init(e,t),U.init(e,t)}),hu=F(`ZodCIDRv6`,(e,t)=>{La.init(e,t),U.init(e,t)}),gu=F(`ZodBase64`,(e,t)=>{za.init(e,t),U.init(e,t)}),_u=F(`ZodBase64URL`,(e,t)=>{Va.init(e,t),U.init(e,t)}),vu=F(`ZodE164`,(e,t)=>{Ha.init(e,t),U.init(e,t)}),yu=F(`ZodJWT`,(e,t)=>{Ua.init(e,t),U.init(e,t)}),bu=F(`ZodNumber`,(e,t)=>{Wa.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mc(e,t,n,r),e.isFinite=!0},Fn({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=fc(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=fc(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=fc(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>fc(e).format??null},{gt(e,t){return this.check(Ds(e,t))},gte(e,t){return this.check(Os(e,t))},min(e,t){return this.check(Os(e,t))},lt(e,t){return this.check(Ts(e,t))},lte(e,t){return this.check(Es(e,t))},max(e,t){return this.check(Es(e,t))},int(e){return this.check(Tl(e))},safe(e){return this.check(Tl(e))},positive(e){return this.check(Ds(0,e))},nonnegative(e){return this.check(Os(0,e))},negative(e){return this.check(Ts(0,e))},nonpositive(e){return this.check(Es(0,e))},multipleOf(e,t){return this.check(ks(e,t))},step(e,t){return this.check(ks(e,t))},finite(){return this}})),xu=F(`ZodNumberFormat`,(e,t)=>{Ga.init(e,t),bu.init(e,t)}),Su=F(`ZodBoolean`,(e,t)=>{Ka.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Nc(e,t,n,r)}),Cu=F(`ZodUnknown`,(e,t)=>{qa.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fc(e,t,n,r)}),wu=F(`ZodNever`,(e,t)=>{Ja.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pc(e,t,n,r)}),Tu=F(`ZodArray`,(e,t)=>{Cl(),Xa.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bc(e,t,n,r),e.element=t.element},{min(e,t){return this.check(js(e,t))},nonempty(e){return this.check(js(1,e))},max(e,t){return this.check(As(e,t))},length(e,t){return this.check(Ms(e,t))},unwrap(){return this.element}}),Eu=F(`ZodObject`,(e,t)=>{Cl(),$a.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vc(e,t,n,r),Rn(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Pl(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(tn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(tn(this._zod.def,{catchall:Dl()}))},loose(){return this.clone(tn(this._zod.def,{catchall:Dl()}))},strict(){return this.clone(tn(this._zod.def,{catchall:Ol()}))},strip(){return this.clone(tn(this._zod.def,{catchall:void 0}))},extend(e){return hn(this,e)},safeExtend(e){return _n(this,e)},merge(e){return vn(this,e)},pick(e){return fn(this,e)},omit(e){return mn(this,e)},partial(...e){return yn(Nu,this,e[0])},exactPartial(...e){return yn(Pu,this,e[0],`exactPartial`)},required(...e){return bn(Ru,this,e[0])}}),Du=F(`ZodUnion`,(e,t)=>{eo.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hc(e,t,n,r),e.options=t.options}),Ou=F(`ZodIntersection`,(e,t)=>{to.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uc(e,t,n,r)}),ku=F(`ZodRecord`,(e,t)=>{Cl(),no.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gc(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType}),Au=F(`ZodEnum`,(e,t)=>{ro.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ic(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Au({...t,checks:[],...N(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Au({...t,checks:[],...N(r),entries:i})}}),ju=F(`ZodLiteral`,(e,t)=>{io.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lc(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})}),Mu=F(`ZodTransform`,(e,t)=>{Cl(),ao.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zc(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ir(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(jn(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(jn(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}}),Nu=F(`ZodOptional`,(e,t)=>{oo.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>el(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),Pu=F(`ZodExactOptional`,(e,t)=>{so.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>el(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),Fu=F(`ZodNullable`,(e,t)=>{co.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),Iu=F(`ZodDefault`,(e,t)=>{lo.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}),Lu=F(`ZodPrefault`,(e,t)=>{uo.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),Ru=F(`ZodNonOptional`,(e,t)=>{fo.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),zu=F(`ZodCatch`,(e,t)=>{po.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}),Bu=F(`ZodPipe`,(e,t)=>{mo.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qc(e,t,n,r),e.in=t.in,e.out=t.out}),Vu=F(`ZodPreprocess`,(e,t)=>{Bu.init(e,t),ho.init(e,t)}),Hu=F(`ZodReadonly`,(e,t)=>{go.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$c(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),Uu=F(`ZodCustom`,(e,t)=>{_o.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rc(e,t,n,r)})})),Gu=t((()=>{nl()}));function Ku(e){return gs(Zl,e)}function qu(e){return _s(Ql,e)}var Ju=t((()=>{nl(),Wu()})),Yu=t((()=>{nl(),Wu(),rl(),cl(),xl(),Gu(),tl(),Wo(),Zn(),rl(),Ju(),Wu(),vo(),zo()})),Xu=t((()=>{Yu(),Yu()})),Zu,Qu,W=t((()=>{Xu(),Ft(),Zu=Jl(Nt,Pl(j)),Qu=V({code:Zu,message:z(),payload:Ml(z(),Dl()).optional()})})),$u,ed=t((()=>{$u={"dd.ort":`259d860d37e4d12055a63e17685992265ad7d07e656e7ceb564d6e97464f5066`,"do.ort":`d77468ab16b74fd8268cb9d2179aa7fc7d45a5658d3684128d516b1729fd5776`,"fd.ort":`328a81c28493a21cf65b7be4322b1c16d726c485c59615a916dd2090ae1cedec`,"fdl.ort":`d1367545b14a23ec8f827e00580f06f13467f08bbd7399230f1d44bb423c8e10`,"fdh.ort":`5315c6b22309439a3ba1e853133e3ef7ffd43a8d34910bd35e9eacc3c6cacdd0`,"fl.ort":`fa9272923b5f12d61809ceee5611c698c6527e8603857c108891fa4ec41385bf`,"fe.ort":`d1a3c6d54a24b696e88ee12856624c2ea92b9f014f1c4483eb47788c8a6f1f33`,"flv.ort":`5c7ce2142d6e6477521985a1983de6b796e0425924a5f1c007fe59db8830e07d`,"flw.ort":`cf970d52d521438c0ef60dfd49a9b7297df2c354e6b2a3df495bbf8f04343df3`,"fa.ort":`bd820d7fef3370ebd6cd0a85dbe5ac3ac398b5034d2d18135b77c08767571120`,"fm.ort":`34652e9faf44e8a092aad1613d4c67d6775de3f212f3c68f865059ee2b40876d`,"fmh.ort":`57211303a9ded4edc6d98eefed051e029fe56377beb3be1d790c29adb234681a`,"fmu.ort":`f29c1f06155166bd9aa3c50cdb479d1a224c180d761a2d9c8102b1a759155d9b`,"od.ort":`f47d2359be464ca55c28c9986f1b8bf7ee8b3e9ff86e8ecb25d8b2f8eaa55c9e`,"or.ort":`4c7818163f775a89bddba87569edef3f2964f05855ee600d3a34d02c53715fc7`,"ods.ort":`062ed9d8d3e1dfeca55c15763c850ba701f642199d294f7e14a4ea6110dcc43b`,"ors.ort":`f7b99bfde9d06e8cd6844c26d2a0b3d2bb3b6d0c005f1c8003aa241ff89dc466`,"odm.ort":`0896849bbddb9e447b4ab2dcc3b7e40a76efb97199b7195d85f325340239d0f9`,"orj.ort":`bc9c51ff695f866dfb167219f5e8891e9c420b08fad427fe447e922ee16c3450`,"orcs.ort":`86be3129de7cd6d363d5d69bfe5cda792c188d144deca0f2f26cc83d1da9cc21`,"orct.ort":`9690a26ecf8f8a38dbcf763cd9b8a496fba361339e55bfaddbdd46f4462d4d81`,"orc.ort":`5d3c49fc3b5c376a2f4162156d1c5009d63fa3990d37fb807f33dd3227b3f445`,"ora.ort":`470417d05cd0a99b3345af0b970dd337084c5b79d3562e58f92c2196360f6bda`,"ot.txt":`c5cbe34ef40c29c4df07ed012bf96569cb69a2d2a01a07027e9f13cb832bd9cd`,"ots.txt":`41557512862dfe31970cf22407742b629725461dd84c0d8771bde9c87c2202c8`,"otj.txt":`1dcfcb41eec90576a945b3084f22ade11ced506e24f14879245b071698f308e8`,"otcs.txt":`28b2362ad4ab2dc38769aa72feb535e3a9ddb3fd2a7585a05920e6393b1dc7f7`,"otct.txt":`832551fee1f2fbc97508772d81ebdc8dba12c00de97a35c71c9ddf43ddac1a83`,"otc.txt":`90822a96058eb83f8e637ace75f90cbd36c41253f9dbdfb88fcf5a2bdd50d669`,"ota.txt":`7f92f7dbb9b75a4787a83bfb4f6d14a8ab515525130c9d40a9036f61cf6999e9`}})),td,nd,rd,id,ad,od,sd,cd,ld,ud,dd,fd=t((()=>{W(),ed(),td=$u,nd=Symbol.for(`voltom.assetCache`),rd=globalThis,id=rd[nd]??{data:new Map,modules:new Map},rd[nd]=id,ad=`https://sdk.voltom.io`,sd=({sdkUrl:e})=>{if(od!==void 0&&od!==e)throw Error(j.INVALID_OPTIONS);od=e},cd=({filename:e})=>{let t=td[e];if(!t&&/\.(onnx|ort|txt)$/.test(e))throw Error(j.MODEL_LOAD_FAILED);let n=t?`models`:`assets`;od??=ad;let r=new URL(`${n}/${e}`,`${od}/`);return t&&r.searchParams.set(`v`,t),r.href},ld=async({filenames:e})=>{let t=[...new Set(e)];await Promise.all(t.map(async e=>{let t=cd({filename:e}),n=id.data.get(t);n||(n=(async()=>{let e=await fetch(t);if(!e.ok)throw Error(j.MODEL_LOAD_FAILED);return new Uint8Array(await e.arrayBuffer())})(),id.data.set(t,n));try{await n}catch(e){throw id.data.get(t)===n&&id.data.delete(t),e}}))},ud=async({filename:e})=>{await ld({filenames:[e]});let t=id.data.get(cd({filename:e}));if(!t)throw Error(j.MODEL_LOAD_FAILED);return await t},dd=async({filename:e,imports:t={}})=>{let n=cd({filename:e}),r=id.modules.get(n);r||(r=(async()=>{let n=await ud({filename:e}),r=new TextDecoder().decode(n);for(let[e,n]of Object.entries(t))r=r.replaceAll(JSON.stringify(e),JSON.stringify(n));return URL.createObjectURL(new Blob([r],{type:`application/javascript`}))})(),id.modules.set(n,r));try{return await r}catch(e){throw id.modules.get(n)===r&&id.modules.delete(n),e}}})),pd,md=t((()=>{pd={INTENT_TOKEN_INVALID:`intentTokenInvalid`,FACEKEY_ALREADY_ENROLLED:`faceKeyAlreadyEnrolled`,FACEKEY_NOT_ENROLLED:`faceKeyNotEnrolled`,FACEKEY_VERSION_MISMATCH:`faceKeyVersionMismatch`,FACEKEY_KEY_UNAVAILABLE:`serviceUnavailable`,FACEKEY_TEMPLATE_INVALID:`serviceUnavailable`,OPERATION_CANCELLED:`verificationCancelled`,OPERATION_TIMEOUT:`operationTimeout`,CLIENT_KEY_REQUIRED:`clientKeyRequired`,API_KEY_FORBIDDEN:`accessDenied`,CAMERA_INTERRUPTED:`cameraInterrupted`,CAMERA_NOT_FOUND:`cameraNotFound`,CAMERA_PERMISSION_DENIED:`cameraPermissionDenied`,CAMERA_UNAVAILABLE:`cameraUnavailable`,CAMERA_UNSUPPORTED:`cameraUnsupported`,CAPTURES_INCOMPLETE:`capturesIncomplete`,CLIENT_ASSET_NOT_FOUND:`verificationFailed`,CLIENT_NOT_AVAILABLE:`verificationFailed`,CONTACT_RATE_LIMITED:`verificationFailed`,DOCUMENT_BACK_CONTAINS_FACE:`documentBackHasFace`,DOCUMENT_BACK_NOT_DISTINCT:`documentBackSameAsFront`,DOCUMENT_BACK_REQUIRED:`frameDocumentBack`,DOCUMENT_BLURRY:`documentBlurry`,DOCUMENT_CODE_TYPE_MISMATCH:`documentNotRecognized`,DOCUMENT_FACE_GEOMETRY_INVALID:`documentAlignmentInvalid`,DOCUMENT_FACE_NOT_CONTAINED:`documentAlignmentInvalid`,DOCUMENT_FACE_NOT_FOUND:`faceNotVisibleInDocument`,DOCUMENT_NOT_FOUND:`documentNotDetected`,DOCUMENT_NOT_RECOGNIZED:`documentNotRecognized`,DOCUMENT_TEXT_ALIGNMENT_INVALID:`documentAlignmentInvalid`,DOCUMENT_TEXT_NOT_READABLE:`documentNotReadable`,DOCUMENT_VALIDATION_FAILED:`documentValidationFailed`,EMAIL_ALREADY_REGISTERED:`verificationFailed`,EMAIL_DELIVERY_FAILED:`verificationFailed`,EUROPEAN_LICENCE_BACK_MARKER_REQUIRED:`frameDocumentBack`,FACE_AGE_MISMATCH:`faceAgeMismatch`,FACE_ALIGNMENT_FAILED:`faceNotUsable`,FACE_ATTRIBUTES_UNAVAILABLE:`faceAttributesUnavailable`,FACE_GENDER_MISMATCH:`faceGenderMismatch`,FACE_LIGHTING_INVALID:`faceNotUsable`,FACE_MISMATCH:`faceMismatch`,FACE_NOT_FOUND:`terminalFaceNotFound`,FACE_NOT_STABLE:`stayStill`,FACE_NOT_USABLE:`faceNotUsable`,FACE_OUT_OF_FRAME:`centerFace`,FACE_POSE_INVALID:`facePoseInvalid`,FACE_SPOOF_DETECTED:`faceSpoofDetected`,GEO_DATABASE_DOWNLOAD_EMPTY:`verificationFailed`,GEO_DATABASE_DOWNLOAD_FAILED:`verificationFailed`,IMAGE_DECODE_FAILED:`invalidImage`,IMAGE_ENCODE_FAILED:`imageEncodeFailed`,IMAGE_PROCESSING_FAILED:`imageProcessingFailed`,IMAGE_TOO_LARGE:`requestTooLarge`,INFERENCE_FAILED:`serviceUnavailable`,INFERENCE_QUEUE_FULL:`rateLimited`,INFERENCE_TIMEOUT:`operationTimeout`,VALIDATION_ERROR:`invalidInput`,RESPONSE_VALIDATION_ERROR:`invalidServiceResponse`,RESOURCE_NOT_FOUND:`verificationFailed`,RESOURCE_NOT_FOUND_IN_VIEW:`verificationFailed`,REQUEST_TOO_LARGE:`requestTooLarge`,INTERNAL_ERROR:`serviceUnavailable`,INVALID_CREDENTIALS:`verificationFailed`,BILLING_DETAILS_REQUIRED:`verificationFailed`,PAYMENT_METHOD_NOT_FOUND:`verificationFailed`,PAYMENT_NOT_FOUND:`verificationFailed`,RECOVERY_SENT:`verificationFailed`,INVALID_DOCUMENT_AAMVA:`documentCodeNotReadable`,INVALID_DOCUMENT_MRZ:`documentCodeNotReadable`,INVALID_FACE_MATCH_INPUT:`invalidInput`,INVALID_IMAGE:`invalidImage`,INVALID_KEY_LABEL:`verificationFailed`,INVALID_MODEL_OUTPUT:`invalidModelOutput`,INVALID_OPTIONS:`invalidOptions`,INVALID_PASSPORT_MRZ:`documentCodeNotReadable`,INVALID_POSES:`invalidPoses`,INVALID_CLIENT_KEY:`invalidClientKey`,INVALID_REGISTRATION:`verificationFailed`,INVALID_SERVICE_RESPONSE:`invalidServiceResponse`,INVALID_VERIFICATION_FEEDBACK:`verificationFailed`,INVALID_VERIFICATION_INPUT:`invalidInput`,KEY_NOT_FOUND:`verificationFailed`,MODEL_LOAD_FAILED:`modelLoadFailed`,MULTIPLE_FACES:`centerFace`,NETWORK_ERROR:`networkError`,NO_USABLE_CANDIDATES:`terminalFaceNotFound`,NO_USABLE_REFERENCES:`faceNotUsable`,OCR_DICTIONARY_MISMATCH:`modelLoadFailed`,OCR_ENVIRONMENT_MISMATCH:`modelLoadFailed`,OCR_LANGUAGE_UNSUPPORTED:`invalidOptions`,OCR_MODEL_UNSUPPORTED:`invalidOptions`,PAYMENT_FAILED:`verificationFailed`,BILLING_ACCOUNT_BLOCKED:`billingAccountBlocked`,ACCOUNT_HAS_UNBILLED_USAGE:`verificationFailed`,POSE_IDENTITY_MISMATCH:`poseIdentityMismatch`,POSE_BACKGROUND_MISMATCH:`poseBackgroundMismatch`,SERVICE_UNAVAILABLE:`serviceUnavailable`,SUPERADMIN_REQUIRED:`verificationFailed`,UI_ELEMENT_NOT_FOUND:`serviceUnavailable`,UNAUTHORIZED:`accessDenied`,USER_ACCESS_REQUIRED:`verificationFailed`,USER_NOT_FOUND:`verificationFailed`,VERIFICATION_SAVE_FAILED:`verificationSaveFailed`,INVALID_PDF:`invalidPdf`,PDF_LOAD_FAILED:`pdfLoadFailed`,PDF_PASSWORD_REQUIRED:`pdfPasswordRequired`,SDK_CAPABILITY_NOT_CONFIGURED:`sdkCapabilityNotConfigured`,SDK_DISPOSED:`sdkDisposed`,OPERATION_IN_PROGRESS:`operationInProgress`,AUTHORIZATION_FAILED:`authorizationFailed`}})),hd,gd,_d,vd,yd,bd,xd,Sd,Cd,wd,Td,Ed,Dd,Od,kd,Ad,jd,Md,Nd,Pd,Fd,Id,Ld,Rd,zd,Bd,Vd,Hd,Ud,Wd,Gd,Kd,qd,Jd,Yd,Xd,Zd,Qd,$d,ef,tf,nf,rf,af,of,sf,cf,lf,uf,df,ff,pf,mf,hf,gf,_f,vf,yf,bf,xf,Sf,Cf,wf,Tf,Ef,Df,Of,kf,Af,jf,Mf,Nf,Pf,Ff,If,Lf,Rf,zf,Bf,Vf,Hf,Uf,Wf,Gf,Kf,qf,Jf,Yf,Xf,Zf,Qf,$f,ep,tp,np,rp,ip,ap,op,sp,cp,lp,up,dp,fp,pp,mp,hp,gp,_p,vp,yp,bp,xp,Sp,Cp,wp,Tp,Ep,Dp,Op,kp,Ap,jp,Mp,Np,Pp,Fp,Ip,Lp,Rp,zp,Bp,Vp,Hp,Up,Wp,Gp,Kp,qp,Jp,Yp,Xp,Zp,Qp,$p,em,tm,nm,rm,im,am,om,sm,cm=t((()=>{hd=`Invalid document`,gd=`Checking face match`,_d=`Checking document`,vd=`Loading verification assets`,yd=`{percent}% · {downloaded} MB of {total} MB`,bd=`About {time} remaining`,xd=`Ready to start`,Sd=`Preparing verification models`,Cd=`Document is not readable`,wd=`The document image is blurry`,Td=`Error: {message}`,Ed=`Face`,Dd=`Center your face in the camera view and keep it fully visible`,Od=`Not a real human. Show your real face.`,kd=`Move closer until your face fills the frame`,Ad=`No face visible in the document`,jd=`Show the front of the document`,Md=`Frame the passport photo page`,Nd=`Make all text visible and well readable`,Pd=`Hold the document straight with the photo and text fully visible`,Fd=`Show the back of the document`,Id=`Stay still`,Ld=`Hold the document still`,Rd=`Lower your chin slightly`,zd=`Turn your head slightly left`,Bd=`Turn your head slightly right`,Vd=`Look straight into the camera`,Hd=`Raise your phone to eye level`,Ud=`Move your face to webcam level`,Wd=`Raise your phone to eye level`,Gd=`Keep your face centered in the camera view`,Kd=`Tilt your screen until you can look straight into the camera`,qd=`Raise your chin slightly`,Jd=`Turn less`,Yd=`Raise less`,Xd=`Lower less`,Zd=`Tilt less`,Qd=`Smile`,$d=`Tilt your head slightly left`,ef=`Tilt your head slightly right`,tf=`Keep left eye closed`,nf=`Keep right eye closed`,rf=`Match ({score}%)`,af=`No match ({score}%)`,of=`Start`,sf=`Stop`,cf=`Straighten your head`,lf=`Verification capture {index}`,uf=`Allow camera access to continue.`,df=`No camera was found.`,ff=`The camera is unavailable.`,pf=`Connection failed.`,mf=`The verification service is unavailable.`,hf=`Verification assets could not be loaded.`,gf=`Use a clear face image with even lighting.`,_f=`Verification could not be completed.`,vf=`The operation was cancelled.`,yf=`Some required captures are missing.`,bf=`The document could not be validated.`,xf=`The verification settings are invalid.`,Sf=`The face verification sequence is invalid.`,Cf=`The verification service returned an invalid response.`,wf=`Keep the same background during face verification.`,Tf=`The face verification images do not match.`,Ef=`The image could not be prepared.`,Df=`The image could not be processed.`,Of=`Select a valid image file.`,kf=`The verification key is missing.`,Af=`The verification could not be saved.`,jf=`Retry`,Mf=`Move your face left until it is centered in the camera view.`,Nf=`Move your face right until it is centered in the camera view.`,Pf=`Move your face up until it is centered in the camera view.`,Ff=`Move your face down until it is centered in the camera view.`,If=`Tilt your head slightly to your left to straighten it.`,Lf=`Tilt your head slightly to your right to straighten it.`,Rf=`Turn your head slightly to your left.`,zf=`Turn your head slightly to your right.`,Bf=`Raise your chin slightly.`,Vf=`Lower your chin slightly.`,Hf=`Smile more clearly.`,Uf=`Close your left eye and keep your right eye open.`,Wf=`Close your right eye and keep your left eye open.`,Gf=`Document not found.`,Kf=`Move the document closer.`,qf=`Move the document farther away.`,Jf=`Move the document slightly farther away.`,Yf=`Frame the whole document.`,Xf=`The document shape is invalid.`,Zf=`The document is not supported.`,Qf=`Make sure the photo on the document is fully visible.`,$f=`Make sure the document photo is fully visible.`,ep=`Make sure the document photo and text are fully visible.`,tp=`Keep the document straight, with the photo on the left and text on the right.`,np=`This document could not be recognized. Use a supported identity document.`,rp=`Make all text and code lines visible and readable.`,ip=`Show the back of the document, not the front.`,ap=`The back must be different from the front.`,op=`The photo on the document is too small.`,sp=`Invalid PDF`,cp=`Password protected PDFs are not supported`,lp=`Could not load PDF support. Try again.`,up=`Preparing camera`,dp=`Checking your face`,fp=`Done`,pp=`Face not recognized`,mp=`Center your face in the circle`,hp=`Set up FaceKey`,gp=`Unlock with FaceKey`,_p=`Camera preview`,vp=`Face capture progress`,yp=`Move your head left`,bp=`Move your head right`,xp=`Raise your head`,Sp=`Lower your head`,Cp=`Tilt your head left`,wp=`Tilt your head right`,Tp=`Cancel`,Ep=`Face not recognized. Try this pose again.`,Dp=`Face does not match. Try this pose again.`,Op=`Face not usable. Try this pose again.`,kp=`The operation took too long. Try again.`,Ap=`This authorization has expired or is invalid. Start again.`,jp=`The client key is invalid.`,Mp=`The file or request is too large.`,Np=`This feature is not enabled.`,Pp=`This SDK instance is no longer available.`,Fp=`An operation is already in progress.`,Ip=`Authorization failed. Try again.`,Lp=`A FaceKey is already registered.`,Rp=`Register a FaceKey before you unlock.`,zp=`Register your FaceKey again to continue.`,Bp=`This account is blocked by a billing issue.`,Vp=`The service is busy. Try again later.`,Hp=`Image analysis returned an invalid result.`,Up=`This browser does not support camera access.`,Wp=`Camera capture was interrupted. Try again.`,Gp=`Access was denied.`,Kp=`The supplied data is invalid.`,qp=`The faces do not match.`,Jp=`No face was found in the image.`,Yp=`The requested face pose could not be verified.`,Xp=`Match the face orientation in your reference`,Zp=`Acquire human`,Qp=`Acquire document`,$p=`Acquire reference`,em=`Match ID`,tm=`Verification steps`,nm=`Preparing reference`,rm=`A spoof attempt was detected. Present a live face.`,im=`The detected age is outside the requested range.`,am=`The face attributes could not be detected.`,om=`The detected gender does not match the requested gender.`,sm={invalidDocument:hd,checkingFaceMatch:gd,checkingDocument:_d,loadingAssets:vd,loadingProgress:yd,loadingRemaining:bd,readyToStart:xd,preparingModels:Sd,document:`Doc`,documentNotReadable:Cd,documentBlurry:wd,error:Td,face:Ed,faceNotFound:Dd,faceInPolygon:Od,faceTooSmall:kd,faceNotVisibleInDocument:Ad,frameDocument:jd,framePassport:Md,passportMrzNotReadable:Nd,documentAlignmentInvalid:Pd,frameDocumentBack:Fd,stayStill:Id,holdDocumentStill:Ld,lookDown:Rd,lookLeft:zd,lookRight:Bd,lookStraight:Vd,alignPhoneWithFace:Hd,alignFaceWithWebcam:Ud,raisePhone:Wd,centerFace:Gd,tiltScreen:Kd,lookUp:qd,turnLess:Jd,raiseLess:Yd,lowerLess:Xd,tiltLess:Zd,smile:Qd,tiltLeft:$d,tiltRight:ef,winkLeft:tf,winkRight:nf,match:rf,noMatch:af,start:of,stop:sf,straightenHead:cf,verificationCapture:lf,cameraPermissionDenied:uf,cameraNotFound:df,cameraUnavailable:ff,networkError:pf,serviceUnavailable:mf,modelLoadFailed:hf,faceNotUsable:gf,verificationFailed:_f,verificationCancelled:vf,capturesIncomplete:yf,documentValidationFailed:bf,invalidOptions:xf,invalidPoses:Sf,invalidServiceResponse:Cf,poseBackgroundMismatch:wf,poseIdentityMismatch:Tf,imageEncodeFailed:Ef,imageProcessingFailed:Df,invalidImage:Of,clientKeyRequired:kf,verificationSaveFailed:Af,retry:jf,faceCenterMoveLeft:Mf,faceCenterMoveRight:Nf,faceCenterMoveUp:Pf,faceCenterMoveDown:Ff,faceTiltMoreLeft:If,faceTiltMoreRight:Lf,faceTurnLeft:Rf,faceTurnRight:zf,faceLookMoreUp:Bf,faceLookMoreDown:Vf,faceSmileRequired:Hf,faceWinkLeftRequired:Uf,faceWinkRightRequired:Wf,documentNotDetected:Gf,documentBoxTooSmall:Kf,documentBoxTooLarge:qf,documentBoxNearEdge:Jf,documentBoxTouchesEdges:Yf,documentShapeInvalid:Xf,documentNotSupported:Zf,documentPhotoNotVisible:Qf,documentPhotoNotContained:$f,documentPhotoSizeInvalid:ep,documentLayoutInvalid:tp,documentNotRecognized:np,documentCodeNotReadable:rp,documentBackHasFace:ip,documentBackSameAsFront:ap,documentPhotoTooSmall:op,invalidPdf:sp,pdfPasswordRequired:cp,pdfLoadFailed:lp,preparingCamera:up,checkingFace:dp,done:fp,faceNotRecognized:pp,faceNotCentered:mp,setUpFaceKey:hp,unlockWithFaceKey:gp,cameraPreview:_p,faceCaptureProgress:vp,moveHeadLeft:yp,moveHeadRight:bp,moveHeadUp:xp,moveHeadDown:Sp,tiltHeadLeft:Cp,tiltHeadRight:wp,cancel:Tp,faceRetryPose:Ep,faceRetryMatch:Dp,faceRetryUsable:Op,operationTimeout:kp,intentTokenInvalid:Ap,invalidClientKey:jp,requestTooLarge:Mp,sdkCapabilityNotConfigured:Np,sdkDisposed:Pp,operationInProgress:Fp,authorizationFailed:Ip,faceKeyAlreadyEnrolled:Lp,faceKeyNotEnrolled:Rp,faceKeyVersionMismatch:zp,billingAccountBlocked:Bp,rateLimited:Vp,invalidModelOutput:Hp,cameraUnsupported:Up,cameraInterrupted:Wp,accessDenied:Gp,invalidInput:Kp,faceMismatch:qp,terminalFaceNotFound:Jp,facePoseInvalid:Yp,matchReferencePose:Xp,acquireHuman:Zp,acquireDocument:Qp,acquireReference:$p,matchId:em,verificationSteps:tm,preparingReference:nm,faceSpoofDetected:rm,faceAgeMismatch:im,faceAttributesUnavailable:am,faceGenderMismatch:om}})),lm,um,dm,fm,pm,mm,hm,gm,_m,vm=t((()=>{fd(),md(),Bt(),cm(),lm=[`ar`,`ch`,`de`,`en`,`es`,`fr`,`it`,`ja`,`pt`,`ru`,`zh`],um=new Map,dm=new Map,fm=async({language:e})=>{if(um.has(e))return;let t=dm.get(e);t||(t=(async()=>{try{let t=await ud({filename:`locales/${e}.json`}),n=JSON.parse(new TextDecoder().decode(t));if(typeof n!=`object`||!n||Array.isArray(n)||Object.values(n).some(e=>typeof e!=`string`))throw M({code:j.MODEL_LOAD_FAILED,cause:n});return n}catch(e){throw zt({error:e,fallback:j.MODEL_LOAD_FAILED})}})(),dm.set(e,t));try{um.set(e,await t)}finally{dm.delete(e)}},pm=async({language:e})=>{let t=e??hm();await Promise.all([fm({language:t}),...t===`en`?[]:[fm({language:`en`})]])},mm=({element:e,theme:t})=>{t&&(e.dataset.theme=t)},hm=()=>{let e=[navigator.language,...navigator.languages];for(let t of e){let e=t.toLowerCase();if(/^zh-(hk|mo|tw)\b/u.test(e))return`ch`;let n=e.split(`-`)[0];if(lm.includes(n))return n}return`en`},gm=({language:e})=>{let t=e??hm(),n=e=>{let n=um.get(t),r=um.get(`en`);return n?.[e]??r?.[e]??sm[e]};return{translate:n,translateError:({error:e})=>{let t=Pt({error:e}),r=pd[t]??`verificationFailed`;return n(r)}}},_m=async({milliseconds:e})=>{let t=Promise.withResolvers();setTimeout(()=>t.resolve(),e),await t.promise}})),ym,bm,xm,Sm,Cm,wm,Tm,Em,Dm,Om,km,Am,jm=t((()=>{Bt(),ym=new WeakMap,bm=async({video:e,signal:t})=>{t?.throwIfAborted();let n=Promise.withResolvers(),r=e,i=ym.get(e)??new Set,a=null,o=null,s=!1,c=c=>{s||(s=!0,a!==null&&r.cancelVideoFrameCallback?.(a),o!==null&&cancelAnimationFrame(o),t?.removeEventListener(`abort`,u),i.delete(l),i.size||ym.delete(e),c?n.reject(c):n.resolve())},l=()=>c(M({code:j.OPERATION_CANCELLED})),u=()=>c(M({code:j.OPERATION_CANCELLED}));i.add(l),ym.set(e,i),t?.addEventListener(`abort`,u,{once:!0}),r.requestVideoFrameCallback?a=r.requestVideoFrameCallback(()=>c()):o=requestAnimationFrame(()=>c()),await n.promise},xm=()=>{let e=/Android|iPhone|iPad|iPod|Mobile/i.test(navigator.userAgent),t=navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1;return e||t},Sm=async()=>{let e=[],t=(t,n)=>{n||e.push(t)};if(t(`navigator.mediaDevices.getUserMedia`,typeof navigator.mediaDevices==`object`&&typeof navigator.mediaDevices.getUserMedia==`function`),t(`navigator.mediaDevices.enumerateDevices`,typeof navigator.mediaDevices==`object`&&typeof navigator.mediaDevices.enumerateDevices==`function`),t(`MediaStream`,typeof MediaStream<`u`),t(`MediaStreamTrack`,typeof MediaStreamTrack<`u`),t(`HTMLVideoElement`,typeof HTMLVideoElement<`u`),t(`createImageBitmap`,typeof createImageBitmap==`function`),t(`OffscreenCanvas`,typeof OffscreenCanvas<`u`),t(`OffscreenCanvas.getContext`,typeof OffscreenCanvas<`u`&&typeof OffscreenCanvas.prototype.getContext==`function`),t(`OffscreenCanvas.convertToBlob`,typeof OffscreenCanvas<`u`&&typeof OffscreenCanvas.prototype.convertToBlob==`function`),t(`WebAssembly`,typeof WebAssembly<`u`),t(`fetch`,typeof fetch==`function`),t(`Blob`,typeof Blob<`u`),t(`File`,typeof File<`u`),t(`URL.createObjectURL`,typeof URL.createObjectURL==`function`),t(`URL.revokeObjectURL`,typeof URL.revokeObjectURL==`function`),!e.includes(`OffscreenCanvas`)&&!e.includes(`OffscreenCanvas.getContext`)&&!e.includes(`OffscreenCanvas.convertToBlob`))try{let e=new OffscreenCanvas(1,1),n=e.getContext(`2d`);if(t(`OffscreenCanvas 2D context`,n!==null),n&&typeof createImageBitmap==`function`){let n=await e.convertToBlob({type:`image/jpeg`});t(`JPEG encoding`,n.type===`image/jpeg`),n.type===`image/jpeg`&&((await createImageBitmap(n)).close(),t(`JPEG decoding`,!0))}else t(`JPEG encoding`,!1),t(`JPEG decoding`,!1)}catch{e.includes(`JPEG encoding`)||t(`JPEG encoding`,!1),t(`JPEG decoding`,!1)}else t(`JPEG encoding`,!1),t(`JPEG decoding`,!1);return{supported:e.length===0,unsupportedFeatures:e}},Cm=({video:e})=>{for(let t of ym.get(e)??[])t();let t=e.srcObject;if(t instanceof MediaStream)for(let e of t.getTracks())e.stop();e.srcObject=null},wm=async({facingMode:e,video:t,signal:n})=>{if(!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!=`function`)throw M({code:j.CAMERA_UNSUPPORTED});let r={facingMode:{ideal:e}};xm()||(r.width={ideal:1280},r.height={ideal:720});let i=()=>Cm({video:t});n?.addEventListener(`abort`,i,{once:!0});try{let i=await navigator.mediaDevices.getUserMedia({video:r,audio:!1});if(n?.aborted){for(let e of i.getTracks())e.stop();n.throwIfAborted()}t.srcObject=i;let a=(await navigator.mediaDevices.enumerateDevices()).filter(({kind:e})=>e===`videoinput`).length>1?e:`user`;return await t.play(),n?.throwIfAborted(),a}catch(e){if(Cm({video:t}),n?.aborted)throw M({code:j.OPERATION_CANCELLED});let r=e instanceof Error?e.name:``,i=j.CAMERA_UNAVAILABLE;throw(r===`NotAllowedError`||r===`SecurityError`)&&(i=j.CAMERA_PERMISSION_DENIED),r===`NotFoundError`&&(i=j.CAMERA_NOT_FOUND),r===`AbortError`&&(i=j.CAMERA_INTERRUPTED),M({code:i,cause:e})}finally{n?.removeEventListener(`abort`,i)}},Tm=({element:e})=>{let t=e.getContext(`2d`);if(!t)throw M({code:j.IMAGE_PROCESSING_FAILED});t.clearRect(0,0,e.width,e.height)},Em=async({canvas:e,quality:t})=>{try{let n=await e.convertToBlob({type:`image/jpeg`,quality:t});if(n.type!==`image/jpeg`)throw M({code:j.IMAGE_ENCODE_FAILED});return n}catch(e){throw M({code:j.IMAGE_ENCODE_FAILED,cause:e})}},Dm=async({frame:e})=>{let t=new OffscreenCanvas(e.width,e.height),n=t.getContext(`2d`);if(!n)throw M({code:j.IMAGE_PROCESSING_FAILED});return n.drawImage(e,0,0),await Em({canvas:t})},Om=async({blob:e})=>{let t;try{t=await createImageBitmap(e)}catch(e){throw M({code:j.INVALID_IMAGE,cause:e})}try{let e=Math.min(1,900/Math.max(t.width,t.height)),n=new OffscreenCanvas(Math.max(1,Math.round(t.width*e)),Math.max(1,Math.round(t.height*e))),r=n.getContext(`2d`);if(!r)throw M({code:j.IMAGE_PROCESSING_FAILED});return r.drawImage(t,0,0,n.width,n.height),await Em({canvas:n,quality:.85})}finally{t.close()}},km=async({frame:e})=>{let t=Math.min(1,960/Math.max(e.width,e.height)),n=Math.max(1,Math.round(e.width*t)),r=Math.max(1,Math.round(e.height*t));return await createImageBitmap(e,{resizeWidth:n,resizeHeight:r})},Am=async({image:e})=>{let t=new Uint8Array(await e.arrayBuffer()),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));return`data:image/jpeg;base64,${btoa(n)}`}}));vm(),jm(),fd(),Bt();var Mm=`https://api.voltom.io`,Nm={prepare:!0,debug:!1},Pm=({url:e})=>{if(typeof e!=`string`)throw M({code:j.INVALID_OPTIONS});let t;try{t=new URL(e)}catch{throw M({code:j.INVALID_OPTIONS})}if(![`http:`,`https:`].includes(t.protocol)||t.username||t.password||t.search||t.hash)throw M({code:j.INVALID_OPTIONS});return t.href.replace(/\/+$/u,``)},Fm=({apiUrl:e=Mm,sdkUrl:t=ad})=>{let n={apiUrl:Pm({url:e}),sdkUrl:Pm({url:t})};try{sd({sdkUrl:n.sdkUrl})}catch(e){throw zt({error:e,fallback:j.INVALID_OPTIONS})}return n},Im=e=>Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0)),Lm=({options:e,capabilities:t,authorizeRequired:n=!1})=>{if(typeof e!=`object`||!e)throw M({code:j.INVALID_OPTIONS});if(!(`clientKey`in e)||e.clientKey===``)throw M({code:j.CLIENT_KEY_REQUIRED});if(typeof e.clientKey!=`string`)throw M({code:j.INVALID_CLIENT_KEY});if(n&&!(`authorize`in e)||`authorize`in e&&e.authorize!==void 0&&typeof e.authorize!=`function`)throw M({code:j.INVALID_OPTIONS});for(let t of[`prepare`,`debug`,`requireEyeLevelCamera`,`ui`])if(t in e&&e[t]!==void 0&&typeof e[t]!=`boolean`)throw M({code:j.INVALID_OPTIONS});if(`capabilities`in e&&e.capabilities!==void 0&&(!Array.isArray(e.capabilities)||e.capabilities.some(e=>!t.includes(e))))throw M({code:j.INVALID_OPTIONS})},Rm=({options:e})=>{if(typeof e!=`object`||!e||Array.isArray(e)||`debug`in e&&e.debug!==void 0&&typeof e.debug!=`boolean`)throw M({code:j.INVALID_OPTIONS});if(!(`signal`in e)||e.signal===void 0)return;let t=e.signal;if(typeof t!=`object`||!t||!(`aborted`in t)||typeof t.aborted!=`boolean`||!(`addEventListener`in t)||typeof t.addEventListener!=`function`||!(`removeEventListener`in t)||typeof t.removeEventListener!=`function`||!(`throwIfAborted`in t)||typeof t.throwIfAborted!=`function`)throw M({code:j.INVALID_OPTIONS})},zm=n({InferenceSession:()=>Lh,TRACE:()=>Oh,TRACE_EVENT_BEGIN:()=>Mh,TRACE_EVENT_END:()=>Nh,TRACE_FUNC_BEGIN:()=>Ah,TRACE_FUNC_END:()=>jh,Tensor:()=>Eh,default:()=>N_,env:()=>q,registerBackend:()=>Xm}),Bm,Vm,Hm,Um,Wm,G,Gm,Km,qm,Jm,Ym,Xm,Zm,Qm,$m,eh,th,nh,rh,K,ih,q,ah,oh,sh,ch,lh,uh,dh,fh,ph,mh,hh,gh,_h,vh,yh,bh,xh,Sh,Ch,wh,Th,Eh,Dh,Oh,kh,Ah,jh,Mh,Nh,Ph,Fh,Ih,Lh,Rh,zh,Bh,Vh,Hh,Uh,Wh,Gh,Kh,qh,Jh,Yh,Xh,Zh,Qh,$h,eg,tg,ng,rg,ig,ag,og,sg,cg,lg,ug,dg,fg,pg,mg,hg,gg,_g,vg,yg,J,bg,xg,Sg,Y,Cg,wg,Tg,Eg,Dg,Og,kg,Ag,jg,Mg,Ng,Pg,Fg,Ig,Lg,Rg,zg,Bg,Vg,Hg,Ug,Wg,Gg,Kg,qg,Jg,Yg,Xg,Zg,Qg,$g,e_,t_,n_,r_,i_,a_,o_,s_,c_,l_,u_,d_,f_,p_,m_,h_,g_,__,v_,y_,b_,x_,S_,C_,w_,T_,E_,D_,O_,k_,A_,j_,M_,N_,P_=t((()=>{Bm=Object.defineProperty,Vm=Object.getOwnPropertyDescriptor,Hm=Object.getOwnPropertyNames,Um=Object.prototype.hasOwnProperty,Wm=(e=>typeof require<`u`?require:typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(typeof require<`u`?require:e)[t]}):e)(function(e){if(typeof require<`u`)return require.apply(this,arguments);throw Error(`Dynamic require of "`+e+`" is not supported`)}),G=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},Gm=(e,t)=>{for(var n in t)Bm(e,n,{get:t[n],enumerable:!0})},Km=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of Hm(t))!Um.call(e,i)&&i!==n&&Bm(e,i,{get:()=>t[i],enumerable:!(r=Vm(t,i))||r.enumerable});return e},qm=e=>Km(Bm({},`__esModule`,{value:!0}),e),$m=G(()=>{"use strict";Jm=new Map,Ym=[],Xm=(e,t,n)=>{if(t&&typeof t.init==`function`&&typeof t.createInferenceSessionHandler==`function`){let r=Jm.get(e);if(r===void 0)Jm.set(e,{backend:t,priority:n});else{if(r.priority>n)return;if(r.priority===n&&r.backend!==t)throw Error(`cannot register backend "${e}" using priority ${n}`)}if(n>=0){let t=Ym.indexOf(e);t!==-1&&Ym.splice(t,1);for(let t=0;t<Ym.length;t++)if(Jm.get(Ym[t]).priority<=n){Ym.splice(t,0,e);return}Ym.push(e)}}else throw TypeError(`not a valid backend`)},Zm=async e=>{let t=Jm.get(e);if(!t)return`backend not found.`;if(t.initialized)return t.backend;if(t.aborted)return t.error;{let n=!!t.initPromise;try{return n||(t.initPromise=t.backend.init(e)),await t.initPromise,t.initialized=!0,t.backend}catch(e){return n||(t.error=`${e}`,t.aborted=!0),t.error}finally{delete t.initPromise}}},Qm=async e=>{let t=e.executionProviders||[],n=t.map(e=>typeof e==`string`?e:e.name),r=n.length===0?Ym:n,i,a=[],o=new Set;for(let e of r){let t=await Zm(e);typeof t==`string`?a.push({name:e,err:t}):(i||=t,i===t&&o.add(e))}if(!i)throw Error(`no available backend found. ERR: ${a.map(e=>`[${e.name}] ${e.err}`).join(`, `)}`);for(let{name:e,err:t}of a)n.includes(e)&&console.warn(`removing requested execution provider "${e}" from session options because it is not available: ${t}`);let s=t.filter(e=>o.has(typeof e==`string`?e:e.name));return[i,new Proxy(e,{get:(e,t)=>t===`executionProviders`?s:Reflect.get(e,t)})]}}),eh=G(()=>{"use strict";$m()}),nh=G(()=>{"use strict";th=`1.30.0`}),ih=G(()=>{"use strict";nh(),rh=`warning`,K={wasm:{},webgl:{},webgpu:{},versions:{common:th},set logLevel(e){if(e!==void 0){if(typeof e!=`string`||[`verbose`,`info`,`warning`,`error`,`fatal`].indexOf(e)===-1)throw Error(`Unsupported logging level: ${e}`);rh=e}},get logLevel(){return rh}},Object.defineProperty(K,"logLevel",{enumerable:!0})}),ah=G(()=>{"use strict";ih(),q=K}),ch=G(()=>{"use strict";oh=(e,t)=>{let n=typeof document<`u`?document.createElement(`canvas`):new OffscreenCanvas(1,1);n.width=e.dims[3],n.height=e.dims[2];let r=n.getContext(`2d`);if(r!=null){let i,a;t?.tensorLayout!==void 0&&t.tensorLayout===`NHWC`?(i=e.dims[2],a=e.dims[3]):(i=e.dims[3],a=e.dims[2]);let o=t?.format===void 0?`RGB`:t.format,s=t?.norm,c,l;s===void 0||s.mean===void 0?c=[255,255,255,255]:typeof s.mean==`number`?c=[s.mean,s.mean,s.mean,s.mean]:(c=[s.mean[0],s.mean[1],s.mean[2],0],s.mean[3]!==void 0&&(c[3]=s.mean[3])),s===void 0||s.bias===void 0?l=[0,0,0,0]:typeof s.bias==`number`?l=[s.bias,s.bias,s.bias,s.bias]:(l=[s.bias[0],s.bias[1],s.bias[2],0],s.bias[3]!==void 0&&(l[3]=s.bias[3]));let u=a*i,d=0,f=u,p=u*2,m=-1;o===`RGBA`?(d=0,f=u,p=u*2,m=u*3):o===`RGB`?(d=0,f=u,p=u*2):o===`RBG`&&(d=0,p=u,f=u*2);for(let t=0;t<a;t++)for(let n=0;n<i;n++){let i=(e.data[d++]-l[0])*c[0],a=(e.data[f++]-l[1])*c[1],o=(e.data[p++]-l[2])*c[2],s=m===-1?255:(e.data[m++]-l[3])*c[3];r.fillStyle=`rgba(`+i+`,`+a+`,`+o+`,`+s+`)`,r.fillRect(n,t,1,1)}if(`toDataURL`in n)return n.toDataURL();throw Error(`toDataURL is not supported`)}throw Error(`Can not access image data`)},sh=(e,t)=>{let n=typeof document<`u`?document.createElement(`canvas`).getContext(`2d`):new OffscreenCanvas(1,1).getContext(`2d`),r;if(n!=null){let i,a,o;t?.tensorLayout!==void 0&&t.tensorLayout===`NHWC`?(i=e.dims[2],a=e.dims[1],o=e.dims[3]):(i=e.dims[3],a=e.dims[2],o=e.dims[1]);let s=t!==void 0&&t.format!==void 0?t.format:`RGB`,c=t?.norm,l,u;c===void 0||c.mean===void 0?l=[255,255,255,255]:typeof c.mean==`number`?l=[c.mean,c.mean,c.mean,c.mean]:(l=[c.mean[0],c.mean[1],c.mean[2],255],c.mean[3]!==void 0&&(l[3]=c.mean[3])),c===void 0||c.bias===void 0?u=[0,0,0,0]:typeof c.bias==`number`?u=[c.bias,c.bias,c.bias,c.bias]:(u=[c.bias[0],c.bias[1],c.bias[2],0],c.bias[3]!==void 0&&(u[3]=c.bias[3]));let d=a*i;if(t!==void 0&&(t.format!==void 0&&o===4&&t.format!==`RGBA`||o===3&&t.format!==`RGB`&&t.format!==`BGR`))throw Error(`Tensor format doesn't match input tensor dims`);let f=0,p=1,m=2,h=3,g=0,_=d,v=d*2,y=-1;s===`RGBA`?(g=0,_=d,v=d*2,y=d*3):s===`RGB`?(g=0,_=d,v=d*2):s===`RBG`&&(g=0,v=d,_=d*2),r=n.createImageData(i,a);for(let t=0;t<a*i;f+=4,p+=4,m+=4,h+=4,t++)r.data[f]=(e.data[g++]-u[0])*l[0],r.data[p]=(e.data[_++]-u[1])*l[1],r.data[m]=(e.data[v++]-u[2])*l[2],r.data[h]=y===-1?255:(e.data[y++]-u[3])*l[3]}else throw Error(`Can not access image data`);return r}}),hh=G(()=>{"use strict";Th(),lh=(e,t)=>{if(e===void 0)throw Error(`Image buffer must be defined`);if(t.height===void 0||t.width===void 0)throw Error(`Image height and width must be defined`);if(t.tensorLayout===`NHWC`)throw Error(`NHWC Tensor layout is not supported yet`);let{height:n,width:r}=t,i=t.norm??{mean:255,bias:0},a,o;a=typeof i.mean==`number`?[i.mean,i.mean,i.mean,i.mean]:[i.mean[0],i.mean[1],i.mean[2],i.mean[3]??255],o=typeof i.bias==`number`?[i.bias,i.bias,i.bias,i.bias]:[i.bias[0],i.bias[1],i.bias[2],i.bias[3]??0];let s=t.format===void 0?`RGBA`:t.format,c=t.tensorFormat!==void 0&&t.tensorFormat!==void 0?t.tensorFormat:`RGB`,l=n*r,u=c===`RGBA`?new Float32Array(l*4):new Float32Array(l*3),d=4,f=0,p=1,m=2,h=3,g=0,_=l,v=l*2,y=-1;s===`RGB`&&(d=3,f=0,p=1,m=2,h=-1),c===`RGBA`?y=l*3:c===`RBG`?(g=0,v=l,_=l*2):c===`BGR`&&(v=0,_=l,g=l*2);for(let t=0;t<l;t++,f+=d,m+=d,p+=d,h+=d)u[g++]=(e[f]+o[0])/a[0],u[_++]=(e[p]+o[1])/a[1],u[v++]=(e[m]+o[2])/a[2],y!==-1&&h!==-1&&(u[y++]=(e[h]+o[3])/a[3]);return c===`RGBA`?new wh(`float32`,u,[1,4,n,r]):new wh(`float32`,u,[1,3,n,r])},uh=async(e,t)=>{let n=typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement,r=typeof ImageData<`u`&&e instanceof ImageData,i=typeof ImageBitmap<`u`&&e instanceof ImageBitmap,a=typeof e==`string`,o,s=t??{},c=()=>{if(typeof document<`u`)return document.createElement(`canvas`);if(typeof OffscreenCanvas<`u`)return new OffscreenCanvas(1,1);throw Error(`Canvas is not supported`)},l=e=>typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||e instanceof OffscreenCanvas?e.getContext(`2d`):null;if(n){let n=c();n.width=e.width,n.height=e.height;let r=l(n);if(r!=null){let n=e.height,i=e.width;if(t!==void 0&&t.resizedHeight!==void 0&&t.resizedWidth!==void 0&&(n=t.resizedHeight,i=t.resizedWidth),t!==void 0){if(s=t,t.tensorFormat!==void 0)throw Error(`Image input config format must be RGBA for HTMLImageElement`);s.tensorFormat=`RGBA`,s.height=n,s.width=i}else s.tensorFormat=`RGBA`,s.height=n,s.width=i;r.drawImage(e,0,0),o=r.getImageData(0,0,i,n).data}else throw Error(`Can not access image data`)}else if(r){let n,r;if(t!==void 0&&t.resizedWidth!==void 0&&t.resizedHeight!==void 0?(n=t.resizedHeight,r=t.resizedWidth):(n=e.height,r=e.width),t!==void 0&&(s=t),s.format=`RGBA`,s.height=n,s.width=r,t!==void 0){let t=c();t.width=r,t.height=n;let i=l(t);if(i!=null)i.putImageData(e,0,0),o=i.getImageData(0,0,r,n).data;else throw Error(`Can not access image data`)}else o=e.data}else if(i){if(t===void 0)throw Error(`Please provide image config with format for Imagebitmap`);let n=c();n.width=e.width,n.height=e.height;let r=l(n);if(r!=null){let t=e.height,n=e.width;return r.drawImage(e,0,0,n,t),o=r.getImageData(0,0,n,t).data,s.height=t,s.width=n,lh(o,s)}throw Error(`Can not access image data`)}else{if(a)return new Promise((t,n)=>{let r=c(),i=l(r);if(!e||!i)return n();let a=new Image;a.crossOrigin=`Anonymous`,a.src=e,a.onload=()=>{r.width=a.width,r.height=a.height,i.drawImage(a,0,0,r.width,r.height);let e=i.getImageData(0,0,r.width,r.height);s.height=r.height,s.width=r.width,t(lh(e.data,s))}});throw Error(`Input data provided is not supported - aborted tensor creation`)}if(o!==void 0)return lh(o,s);throw Error(`Input data provided is not supported - aborted tensor creation`)},dh=(e,t)=>{let{width:n,height:r,download:i,dispose:a}=t;return new wh({location:`texture`,type:`float32`,texture:e,dims:[1,r,n,4],download:i,dispose:a})},fh=(e,t)=>{let{dataType:n,dims:r,download:i,dispose:a}=t;return new wh({location:`gpu-buffer`,type:n??`float32`,gpuBuffer:e,dims:r,download:i,dispose:a})},ph=(e,t)=>{let{dataType:n,dims:r,download:i,dispose:a}=t;return new wh({location:`ml-tensor`,type:n??`float32`,mlTensor:e,dims:r,download:i,dispose:a})},mh=(e,t,n)=>new wh({location:`cpu-pinned`,type:e,data:t,dims:n??[t.length]})}),bh=G(()=>{"use strict";gh=new Map([[`float32`,Float32Array],[`uint8`,Uint8Array],[`int8`,Int8Array],[`uint16`,Uint16Array],[`int16`,Int16Array],[`int32`,Int32Array],[`bool`,Uint8Array],[`float64`,Float64Array],[`uint32`,Uint32Array],[`int4`,Uint8Array],[`uint4`,Uint8Array]]),_h=new Map([[Float32Array,`float32`],[Uint8Array,`uint8`],[Int8Array,`int8`],[Uint16Array,`uint16`],[Int16Array,`int16`],[Int32Array,`int32`],[Float64Array,`float64`],[Uint32Array,`uint32`]]),vh=!1,yh=()=>{if(!vh){vh=!0;let e=typeof BigInt64Array<`u`&&BigInt64Array.from,t=typeof BigUint64Array<`u`&&BigUint64Array.from,n=globalThis.Float16Array,r=typeof n<`u`&&n.from;e&&(gh.set(`int64`,BigInt64Array),_h.set(BigInt64Array,`int64`)),t&&(gh.set(`uint64`,BigUint64Array),_h.set(BigUint64Array,`uint64`)),r?(gh.set(`float16`,n),_h.set(n,`float16`)):gh.set(`float16`,Uint16Array)}}}),Ch=G(()=>{"use strict";Th(),xh=e=>{let t=1;for(let n=0;n<e.length;n++){let r=e[n];if(typeof r!=`number`||!Number.isSafeInteger(r))throw TypeError(`dims[${n}] must be an integer, got: ${r}`);if(r<0)throw RangeError(`dims[${n}] must be a non-negative integer, got: ${r}`);t*=r}return t},Sh=(e,t)=>{switch(e.location){case`cpu`:return new wh(e.type,e.data,t);case`cpu-pinned`:return new wh({location:`cpu-pinned`,data:e.data,type:e.type,dims:t});case`texture`:return new wh({location:`texture`,texture:e.texture,type:e.type,dims:t});case`gpu-buffer`:return new wh({location:`gpu-buffer`,gpuBuffer:e.gpuBuffer,type:e.type,dims:t});case`ml-tensor`:return new wh({location:`ml-tensor`,mlTensor:e.mlTensor,type:e.type,dims:t});default:throw Error(`tensorReshape: tensor location ${e.location} is not supported`)}}}),Th=G(()=>{"use strict";ch(),hh(),bh(),Ch(),wh=class{constructor(e,t,n){yh();let r,i;if(typeof e==`object`&&`location`in e)switch(this.dataLocation=e.location,r=e.type,i=e.dims,e.location){case`cpu-pinned`:{let t=gh.get(r);if(!t)throw TypeError(`unsupported type "${r}" to create tensor from pinned buffer`);if(!(e.data instanceof t))throw TypeError(`buffer should be of type ${t.name}`);this.cpuData=e.data;break}case`texture`:if(r!==`float32`)throw TypeError(`unsupported type "${r}" to create tensor from texture`);this.gpuTextureData=e.texture,this.downloader=e.download,this.disposer=e.dispose;break;case`gpu-buffer`:if(r!==`float32`&&r!==`float16`&&r!==`int32`&&r!==`int64`&&r!==`uint32`&&r!==`uint8`&&r!==`bool`&&r!==`uint4`&&r!==`int4`)throw TypeError(`unsupported type "${r}" to create tensor from gpu buffer`);this.gpuBufferData=e.gpuBuffer,this.downloader=e.download,this.disposer=e.dispose;break;case`ml-tensor`:if(r!==`float32`&&r!==`float16`&&r!==`int32`&&r!==`int64`&&r!==`uint32`&&r!==`uint64`&&r!==`int8`&&r!==`uint8`&&r!==`bool`&&r!==`uint4`&&r!==`int4`)throw TypeError(`unsupported type "${r}" to create tensor from MLTensor`);this.mlTensorData=e.mlTensor,this.downloader=e.download,this.disposer=e.dispose;break;default:throw Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let a,o;if(typeof e==`string`){if(r=e,o=n,e===`string`){if(!Array.isArray(t))throw TypeError(`A string tensor's data must be a string array.`);a=t}else{let n=gh.get(e);if(n===void 0)throw TypeError(`Unsupported tensor type: ${e}.`);if(Array.isArray(t)){if(e===`float16`&&n===Uint16Array||e===`uint4`||e===`int4`)throw TypeError(`Creating a ${e} tensor from number array is not supported. Please use ${n.name} as data.`);a=e===`uint64`||e===`int64`?n.from(t,BigInt):n.from(t)}else if(t instanceof n)a=t;else if(t instanceof Uint8ClampedArray){if(e===`uint8`)a=Uint8Array.from(t);else throw TypeError(`A Uint8ClampedArray tensor's data must be type of uint8`)}else if(e===`float16`&&t instanceof Uint16Array&&n!==Uint16Array)a=new globalThis.Float16Array(t.buffer,t.byteOffset,t.length);else throw TypeError(`A ${r} tensor's data must be type of ${n}`)}}else if(o=t,Array.isArray(e)){if(e.length===0)throw TypeError(`Tensor type cannot be inferred from an empty array.`);let t=typeof e[0];if(t===`string`)r=`string`,a=e;else if(t===`boolean`)r=`bool`,a=Uint8Array.from(e);else throw TypeError(`Invalid element type of data array: ${t}.`)}else if(e instanceof Uint8ClampedArray)r=`uint8`,a=Uint8Array.from(e);else{let t=_h.get(e.constructor);if(t===void 0)throw TypeError(`Unsupported type for tensor data: ${e.constructor}.`);r=t,a=e}if(o===void 0)o=[a.length];else if(!Array.isArray(o))throw TypeError(`A tensor's dims must be a number array`);i=o,this.cpuData=a,this.dataLocation=`cpu`}let a=xh(i);if(this.cpuData&&a!==this.cpuData.length&&(r!==`uint4`&&r!==`int4`||Math.ceil(a/2)!==this.cpuData.length))throw Error(`Tensor's size(${a}) does not match data length(${this.cpuData.length}).`);this.type=r,this.dims=i,this.size=a}static async fromImage(e,t){return uh(e,t)}static fromTexture(e,t){return dh(e,t)}static fromGpuBuffer(e,t){return fh(e,t)}static fromMLTensor(e,t){return ph(e,t)}static fromPinnedBuffer(e,t,n){return mh(e,t,n)}toDataURL(e){return oh(this,e)}toImageData(e){return sh(this,e)}get data(){if(this.ensureValid(),!this.cpuData)throw Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw Error(`The data is not stored as a WebGL texture.`);return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw Error(`The data is not stored as a WebGPU buffer.`);return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw Error(`The data is not stored as a WebNN MLTensor.`);return this.mlTensorData}async getData(e){switch(this.ensureValid(),this.dataLocation){case`cpu`:case`cpu-pinned`:return this.data;case`texture`:case`gpu-buffer`:case`ml-tensor`:if(!this.downloader)throw Error(`The current tensor is not created with a specified data downloader.`);if(this.isDownloading)throw Error(`The current tensor is being downloaded.`);try{this.isDownloading=!0;let t=await this.downloader();return this.downloader=void 0,this.dataLocation=`cpu`,this.cpuData=t,e&&this.disposer&&(this.disposer(),this.disposer=void 0),t}finally{this.isDownloading=!1}default:throw Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw Error(`The current tensor is being downloaded.`);this.disposer&&=(this.disposer(),void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation=`none`}ensureValid(){if(this.dataLocation===`none`)throw Error(`The tensor is disposed.`)}reshape(e){if(this.ensureValid(),this.downloader||this.disposer)throw Error(`Cannot reshape a tensor that owns GPU resource.`);return Sh(this,e)}}}),Dh=G(()=>{"use strict";Th(),Eh=wh}),Ph=G(()=>{"use strict";ih(),Oh=(e,t)=>{(typeof K.trace>`u`?!K.wasm.trace:!K.trace)||console.timeStamp(`${e}::ORT::${t}`)},kh=(e,t)=>{let n=Error().stack?.split(/\r\n|\r|\n/g)||[],r=!1;for(let i=0;i<n.length;i++){if(r&&!n[i].includes(`TRACE_FUNC`)){let r=`FUNC_${e}::${n[i].trim().split(` `)[1]}`;t&&(r+=`::${t}`),Oh(`CPU`,r);return}n[i].includes(`TRACE_FUNC`)&&(r=!0)}},Ah=e=>{(typeof K.trace>`u`?!K.wasm.trace:!K.trace)||kh(`BEGIN`,e)},jh=e=>{(typeof K.trace>`u`?!K.wasm.trace:!K.trace)||kh(`END`,e)},Mh=e=>{(typeof K.trace>`u`?!K.wasm.trace:!K.trace)||console.time(`ORT::${e}`)},Nh=e=>{(typeof K.trace>`u`?!K.wasm.trace:!K.trace)||console.timeEnd(`ORT::${e}`)}}),Ih=G(()=>{"use strict";$m(),Dh(),Ph(),Fh=class e{constructor(e){this.handler=e}async run(e,t,n){Ah(),Mh(`InferenceSession.run`);let r={},i={};if(typeof e!=`object`||!e||e instanceof Eh||Array.isArray(e))throw TypeError(`'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.`);let a=!0;if(typeof t==`object`){if(t===null)throw TypeError(`Unexpected argument[1]: cannot be null.`);if(t instanceof Eh)throw TypeError(`'fetches' cannot be a Tensor`);if(Array.isArray(t)){if(t.length===0)throw TypeError(`'fetches' cannot be an empty array.`);a=!1;for(let e of t){if(typeof e!=`string`)throw TypeError(`'fetches' must be a string array or an object.`);if(this.outputNames.indexOf(e)===-1)throw RangeError(`'fetches' contains invalid output name: ${e}.`);r[e]=null}if(typeof n==`object`&&n)i=n;else if(typeof n<`u`)throw TypeError(`'options' must be an object.`)}else{let e=!1,o=Object.getOwnPropertyNames(t);for(let n of this.outputNames)if(o.indexOf(n)!==-1){let i=t[n];(i===null||i instanceof Eh)&&(e=!0,a=!1,r[n]=i)}if(e){if(typeof n==`object`&&n)i=n;else if(typeof n<`u`)throw TypeError(`'options' must be an object.`)}else i=t}}else if(typeof t<`u`)throw TypeError(`Unexpected argument[1]: must be 'fetches' or 'options'.`);for(let t of this.inputNames)if(typeof e[t]>`u`)throw Error(`input '${t}' is missing in 'feeds'.`);if(a)for(let e of this.outputNames)r[e]=null;let o=await this.handler.run(e,r,i),s={};for(let e in o)if(Object.hasOwnProperty.call(o,e)){let t=o[e];s[e]=t instanceof Eh?t:new Eh(t.type,t.data,t.dims)}return Nh(`InferenceSession.run`),jh(),s}async release(){return this.handler.dispose()}static async create(t,n,r,i){Ah(),Mh(`InferenceSession.create`);let a,o={};if(typeof t==`string`){if(a=t,typeof n==`object`&&n)o=n;else if(typeof n<`u`)throw TypeError(`'options' must be an object.`)}else if(t instanceof Uint8Array){if(a=t,typeof n==`object`&&n)o=n;else if(typeof n<`u`)throw TypeError(`'options' must be an object.`)}else if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&t instanceof SharedArrayBuffer){let e=t,s=0,c=t.byteLength;if(typeof n==`object`&&n)o=n;else if(typeof n==`number`){if(s=n,!Number.isSafeInteger(s))throw RangeError(`'byteOffset' must be an integer.`);if(s<0||s>=e.byteLength)throw RangeError(`'byteOffset' is out of range [0, ${e.byteLength}).`);if(c=t.byteLength-s,typeof r==`number`){if(c=r,!Number.isSafeInteger(c))throw RangeError(`'byteLength' must be an integer.`);if(c<=0||s+c>e.byteLength)throw RangeError(`'byteLength' is out of range (0, ${e.byteLength-s}].`);if(typeof i==`object`&&i)o=i;else if(typeof i<`u`)throw TypeError(`'options' must be an object.`)}else if(typeof r<`u`)throw TypeError(`'byteLength' must be a number.`)}else if(typeof n<`u`)throw TypeError(`'options' must be an object.`);a=new Uint8Array(e,s,c)}else throw TypeError(`Unexpected argument[0]: must be 'path' or 'buffer'.`);let[s,c]=await Qm(o),l=await s.createInferenceSessionHandler(a,c);return Nh(`InferenceSession.create`),jh(),new e(l)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}get inputMetadata(){return this.handler.inputMetadata}get outputMetadata(){return this.handler.outputMetadata}}}),Rh=G(()=>{"use strict";Ih(),Lh=Fh}),zh=G(()=>{"use strict";}),Bh=G(()=>{"use strict";}),Vh=G(()=>{"use strict";}),Hh=G(()=>{"use strict";}),Uh={},Gm(Uh,{InferenceSession:()=>Lh,TRACE:()=>Oh,TRACE_EVENT_BEGIN:()=>Mh,TRACE_EVENT_END:()=>Nh,TRACE_FUNC_BEGIN:()=>Ah,TRACE_FUNC_END:()=>jh,Tensor:()=>Eh,env:()=>q,registerBackend:()=>Xm}),Wh=G(()=>{"use strict";eh(),ah(),Rh(),Dh(),zh(),Bh(),Ph(),Vh(),Hh()}),Gh=G(()=>{"use strict";}),Kh={},Gm(Kh,{default:()=>Yh}),Xh=G(()=>{"use strict";r_(),bg(),dg(),qh=`ort-wasm-proxy-worker`,Jh=globalThis.self?.name===qh,Jh&&(self.onmessage=e=>{let{type:t,in:n}=e.data;try{switch(t){case`init-wasm`:yg(n.wasm).then(()=>{Gg(n).then(()=>{postMessage({type:t})},e=>{postMessage({type:t,err:e})})},e=>{postMessage({type:t,err:e})});break;case`init-ep`:{let{epName:e,env:r}=n;Kg(r,e).then(()=>{postMessage({type:t})},e=>{postMessage({type:t,err:e})});break}case`copy-from`:{let{buffer:e}=n,r=Xg(e);postMessage({type:t,out:r});break}case`create`:{let{model:e,options:r}=n;Zg(e,r).then(e=>{postMessage({type:t,out:e})},e=>{postMessage({type:t,err:e})});break}case`release`:Qg(n),postMessage({type:t});break;case`run`:{let{sessionId:e,inputIndices:r,inputs:i,outputIndices:a,options:o}=n;e_(e,r,i,a,Array(a.length).fill(null),o).then(e=>{e.some(e=>e[3]!==`cpu`)?postMessage({type:t,err:`Proxy does not support non-cpu tensor location.`}):postMessage({type:t,out:e},n_([...i,...e]))},e=>{postMessage({type:t,err:e})});break}case`end-profiling`:t_(n),postMessage({type:t})}}catch(e){postMessage({type:t,err:e})}}),Yh=Jh?null:e=>new Worker(e??eg,{type:`module`,name:qh})}),dg=G(()=>{"use strict";Gh(),Zh=typeof location>`u`?void 0:location.origin,Qh={}.url>`file:`&&{}.url<`file;`,$h=()=>Qh?new URL(new URL(`ort.wasm.min.mjs`,{}.url).href,Zh).href:{}.url,eg=$h(),tg=()=>{if(eg&&!eg.startsWith(`blob:`))return eg.substring(0,eg.lastIndexOf(`/`)+1)},ng=(e,t)=>{try{let n=t??eg;return(n?new URL(e,n):new URL(e)).origin===Zh}catch{return!1}},rg=(e,t)=>{let n=t??eg;try{return(n?new URL(e,n):new URL(e)).href}catch{return}},ig=(e,t)=>`${t??`./`}${e}`,ag=async e=>{let t=await(await fetch(e,{credentials:`same-origin`})).blob();return URL.createObjectURL(t)},og=async e=>(await import(e)).default,sg=(Xh(),qm(Kh)).default,cg=async()=>{if(!eg)throw Error(`Failed to load proxy worker: cannot determine the script source URL.`);if(ng(eg))return[void 0,sg()];let e=await ag(eg);return[e,sg(e)]},lg=void 0,ug=async(e,t,n,r)=>{let i=lg&&!(e||t);if(i){if(eg)i=ng(eg)||r&&!n;else if(r&&!n)i=!0;else throw Error(`cannot determine the script source URL.`)}if(i)return[void 0,lg];{let r=`ort-wasm-simd-threaded.mjs`,i=e??rg(r,t),a=n&&i&&!ng(i,t),o=a?await ag(i):i??ig(r,t);return[a?o:void 0,await og(o)]}}}),bg=G(()=>{"use strict";dg(),pg=!1,mg=!1,hg=!1,gg=()=>{if(typeof SharedArrayBuffer>`u`)return!1;try{return typeof MessageChannel<`u`&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}},_g=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}},vg=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,19,1,17,0,65,1,253,15,65,2,253,15,65,3,253,15,253,147,2,11]))}catch{return!1}},yg=async e=>{if(pg)return Promise.resolve();if(mg)throw Error(`multiple calls to 'initializeWebAssembly()' detected.`);if(hg)throw Error(`previous call to 'initializeWebAssembly()' failed.`);mg=!0;let t=e.initTimeout,n=e.numThreads;if(e.simd!==!1){if(e.simd===`relaxed`){if(!vg())throw Error(`Relaxed WebAssembly SIMD is not supported in the current environment.`)}else if(!_g())throw Error(`WebAssembly SIMD is not supported in the current environment.`)}let r=gg();n>1&&!r&&(typeof self<`u`&&!self.crossOriginIsolated&&console.warn(`env.wasm.numThreads is set to `+n+`, but this will not work unless you enable crossOriginIsolated mode. See https://web.dev/cross-origin-isolation-guide/ for more info.`),console.warn(`WebAssembly multi-threading is not supported in the current environment. Falling back to single-threading.`),e.numThreads=n=1);let i=e.wasmPaths,a=typeof i==`string`?i:void 0,o=i?.mjs,s=o?.href??o,c=i?.wasm,l=c?.href??c,u=e.wasmBinary,[d,f]=await ug(s,a,n>1,!!u||!!l),p=!1,m=[];if(t>0&&m.push(new Promise(e=>{setTimeout(()=>{p=!0,e()},t)})),m.push(new Promise((e,t)=>{let r={numThreads:n};if(u)r.wasmBinary=u,r.locateFile=e=>e;else if(l||a)r.locateFile=e=>l??a+e;else if(s&&s.indexOf(`blob:`)!==0)r.locateFile=e=>new URL(e,s).href;else if(d){let e=tg();e&&(r.locateFile=t=>e+t)}f(r).then(t=>{mg=!1,pg=!0,fg=t,e(),d&&URL.revokeObjectURL(d)},e=>{mg=!1,hg=!0,t(e)})})),await Promise.race(m),p)throw Error(`WebAssembly backend initializing failed due to timeout: ${t}ms`)},J=()=>{if(pg&&fg)return fg;throw Error(`WebAssembly is not initialized yet.`)}}),Cg=G(()=>{"use strict";bg(),xg=(e,t)=>{let n=J(),r=n.lengthBytesUTF8(e)+1,i=n._malloc(r);return n.stringToUTF8(e,i,r),t.push(i),i},Sg=(e,t,n,r)=>{if(typeof e==`object`&&e){if(n.has(e))throw Error(`Circular reference in options`);n.add(e)}Object.entries(e).forEach(([e,i])=>{let a=t?t+e:e;if(typeof i==`object`)Sg(i,a+`.`,n,r);else if(typeof i==`string`||typeof i==`number`)r(a,i.toString());else if(typeof i==`boolean`)r(a,i?`1`:`0`);else throw Error(`Can't handle extra config type: ${typeof i}`)})},Y=e=>{let t=J(),n=t.stackSave();try{let n=t.PTR_SIZE,r=t.stackAlloc(2*n);t._OrtGetLastError(r,r+n);let i=Number(t.getValue(r,n===4?`i32`:`i64`)),a=t.getValue(r+n,`*`),o=a?t.UTF8ToString(a):``;throw Error(`${e} ERROR_CODE: ${i}, ERROR_MESSAGE: ${o}`)}finally{t.stackRestore(n)}}}),Tg=G(()=>{"use strict";bg(),Cg(),wg=e=>{let t=J(),n=0,r=[],i=e||{};try{if(e?.logSeverityLevel===void 0)i.logSeverityLevel=2;else if(typeof e.logSeverityLevel!=`number`||!Number.isInteger(e.logSeverityLevel)||e.logSeverityLevel<0||e.logSeverityLevel>4)throw Error(`log severity level is not valid: ${e.logSeverityLevel}`);if(e?.logVerbosityLevel===void 0)i.logVerbosityLevel=0;else if(typeof e.logVerbosityLevel!=`number`||!Number.isInteger(e.logVerbosityLevel))throw Error(`log verbosity level is not valid: ${e.logVerbosityLevel}`);e?.terminate===void 0&&(i.terminate=!1);let a=0;return e?.tag!==void 0&&(a=xg(e.tag,r)),n=t._OrtCreateRunOptions(i.logSeverityLevel,i.logVerbosityLevel,!!i.terminate,a),n===0&&Y(`Can't create run options.`),e?.extra!==void 0&&Sg(e.extra,``,new WeakSet,(e,i)=>{let a=xg(e,r),o=xg(i,r);t._OrtAddRunConfigEntry(n,a,o)!==0&&Y(`Can't set a run config entry: ${e} - ${i}.`)}),[n,r]}catch(e){throw n!==0&&t._OrtReleaseRunOptions(n),r.forEach(e=>t._free(e)),e}}}),Mg=G(()=>{"use strict";bg(),Cg(),Eg=e=>{switch(e){case`disabled`:return 0;case`basic`:return 1;case`extended`:return 2;case`layout`:return 3;case`all`:return 99;default:throw Error(`unsupported graph optimization level: ${e}`)}},Dg=e=>{switch(e){case`sequential`:return 0;case`parallel`:return 1;default:throw Error(`unsupported execution mode: ${e}`)}},Og=e=>{e.extra||={},e.extra.session||(e.extra.session={});let t=e.extra.session;t.use_ort_model_bytes_directly||=`1`,e.executionProviders&&e.executionProviders.some(e=>(typeof e==`string`?e:e.name)===`webgpu`)&&(e.enableMemPattern=!1)},kg=(e,t,n,r)=>{let i=xg(t,r),a=xg(n,r);J()._OrtAddSessionConfigEntry(e,i,a)!==0&&Y(`Can't set a session config entry: ${t} - ${n}.`)},Ag=async(e,t,n)=>{let r=t.executionProviders;for(let t of r){let r=typeof t==`string`?t:t.name,i=[];switch(r){case`webnn`:if(r=`WEBNN`,kg(e,`session.disable_quant_qdq`,`1`,n),kg(e,`session.disable_qdq_constant_folding`,`1`,n),typeof t!=`string`){let r=t?.deviceType;r&&kg(e,`deviceType`,r,n)}break;case`webgpu`:if(r=`JS`,typeof t!=`string`){let r=t;if(r?.preferredLayout){if(r.preferredLayout!==`NCHW`&&r.preferredLayout!==`NHWC`)throw Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${r.preferredLayout}`);kg(e,`preferredLayout`,r.preferredLayout,n)}}break;case`wasm`:case`cpu`:continue;default:throw Error(`not supported execution provider: ${r}`)}let a=xg(r,n),o=i.length,s=0,c=0;if(o>0){s=J()._malloc(o*J().PTR_SIZE),n.push(s),c=J()._malloc(o*J().PTR_SIZE),n.push(c);for(let e=0;e<o;e++)J().setValue(s+e*J().PTR_SIZE,i[e][0],`*`),J().setValue(c+e*J().PTR_SIZE,i[e][1],`*`)}await J()._OrtAppendExecutionProvider(e,a,s,c,o)!==0&&Y(`Can't append execution provider: ${r}.`)}},jg=async e=>{let t=J(),n=0,r=[],i=e||{};Og(i);try{let e=Eg(i.graphOptimizationLevel??`all`),a=Dg(i.executionMode??`sequential`),o=typeof i.logId==`string`?xg(i.logId,r):0,s=i.logSeverityLevel??2;if(!Number.isInteger(s)||s<0||s>4)throw Error(`log severity level is not valid: ${s}`);let c=i.logVerbosityLevel??0;if(!Number.isInteger(c)||c<0||c>4)throw Error(`log verbosity level is not valid: ${c}`);let l=typeof i.optimizedModelFilePath==`string`?xg(i.optimizedModelFilePath,r):0;if(n=t._OrtCreateSessionOptions(e,!!i.enableCpuMemArena,!!i.enableMemPattern,a,!!i.enableProfiling,0,o,s,c,l),n===0&&Y(`Can't create session options.`),i.executionProviders&&await Ag(n,i,r),i.enableGraphCapture!==void 0){if(typeof i.enableGraphCapture!=`boolean`)throw Error(`enableGraphCapture must be a boolean value: ${i.enableGraphCapture}`);kg(n,`enableGraphCapture`,i.enableGraphCapture.toString(),r)}if(i.freeDimensionOverrides)for(let[e,a]of Object.entries(i.freeDimensionOverrides)){if(typeof e!=`string`)throw Error(`free dimension override name must be a string: ${e}`);if(typeof a!=`number`||!Number.isInteger(a)||a<0)throw Error(`free dimension override value must be a non-negative integer: ${a}`);let i=xg(e,r);t._OrtAddFreeDimensionOverride(n,i,a)!==0&&Y(`Can't set a free dimension override: ${e} - ${a}.`)}return i.extra!==void 0&&Sg(i.extra,``,new WeakSet,(e,t)=>{kg(n,e,t,r)}),[n,r]}catch(e){throw n!==0&&t._OrtReleaseSessionOptions(n)!==0&&Y(`Can't release session options.`),r.forEach(e=>t._free(e)),e}}}),Vg=G(()=>{"use strict";Ng=e=>{switch(e){case`int8`:return 3;case`uint8`:return 2;case`bool`:return 9;case`int16`:return 5;case`uint16`:return 4;case`int32`:return 6;case`uint32`:return 12;case`float16`:return 10;case`float32`:return 1;case`float64`:return 11;case`string`:return 8;case`int64`:return 7;case`uint64`:return 13;case`int4`:return 22;case`uint4`:return 21;default:throw Error(`unsupported data type: ${e}`)}},Pg=e=>{switch(e){case 3:return`int8`;case 2:return`uint8`;case 9:return`bool`;case 5:return`int16`;case 4:return`uint16`;case 6:return`int32`;case 12:return`uint32`;case 10:return`float16`;case 1:return`float32`;case 11:return`float64`;case 8:return`string`;case 7:return`int64`;case 13:return`uint64`;case 22:return`int4`;case 21:return`uint4`;default:throw Error(`unsupported data type: ${e}`)}},Fg=(e,t)=>{let n=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][e],r=typeof t==`number`?t:t.reduce((e,t)=>e*t,1);return n>0?Math.ceil(r*n):void 0},Ig=e=>{switch(e){case`float16`:return typeof Float16Array<`u`?Float16Array:Uint16Array;case`float32`:return Float32Array;case`uint8`:return Uint8Array;case`int8`:return Int8Array;case`uint16`:return Uint16Array;case`int16`:return Int16Array;case`int32`:return Int32Array;case`bool`:return Uint8Array;case`float64`:return Float64Array;case`uint32`:return Uint32Array;case`int64`:return BigInt64Array;case`uint64`:return BigUint64Array;default:throw Error(`unsupported type: ${e}`)}},Lg=e=>{switch(e){case`verbose`:return 0;case`info`:return 1;case`warning`:return 2;case`error`:return 3;case`fatal`:return 4;default:throw Error(`unsupported logging level: ${e}`)}},Rg=e=>e===`float32`||e===`float16`||e===`int32`||e===`int64`||e===`uint32`||e===`uint8`||e===`bool`||e===`uint4`||e===`int4`,zg=e=>e===`float32`||e===`float16`||e===`int32`||e===`int64`||e===`uint32`||e===`uint64`||e===`int8`||e===`uint8`||e===`bool`||e===`uint4`||e===`int4`,Bg=e=>{switch(e){case`none`:return 0;case`cpu`:return 1;case`cpu-pinned`:return 2;case`texture`:return 3;case`gpu-buffer`:return 4;case`ml-tensor`:return 5;default:throw Error(`unsupported data location: ${e}`)}}}),Ug=G(()=>{"use strict";Gh(),Hg=async e=>{if(typeof e==`string`){let t=await fetch(e);if(!t.ok)throw Error(`failed to load external data file: ${e}`);let n=t.headers.get(`Content-Length`),r=n?parseInt(n,10):0;if(r<1073741824)return new Uint8Array(await t.arrayBuffer());{if(!t.body)throw Error(`failed to load external data file: ${e}, no response body.`);let n=t.body.getReader(),i;try{i=new ArrayBuffer(r)}catch(e){if(e instanceof RangeError){let e=Math.ceil(r/65536);i=new WebAssembly.Memory({initial:e,maximum:e}).buffer}else throw e}let a=0;for(;;){let{done:e,value:t}=await n.read();if(e)break;let r=t.byteLength;new Uint8Array(i,a,r).set(t),a+=r}return new Uint8Array(i,0,r)}}return e instanceof Blob?new Uint8Array(await e.arrayBuffer()):e instanceof Uint8Array?e:new Uint8Array(e)}}),r_=G(()=>{"use strict";Wh(),Tg(),Mg(),Vg(),bg(),Cg(),Ug(),Wg=(e,t)=>{J()._OrtInit(e,t)!==0&&Y(`Can't initialize onnxruntime.`)},Gg=async e=>{Wg(e.wasm.numThreads,Lg(e.logLevel))},Kg=async(e,t)=>{J().asyncInit?.();let n=e.webgpu.adapter;if(t===`webgpu`){if(typeof navigator>`u`||!navigator.gpu)throw Error(`WebGPU is not supported in current environment`);if(n){if(typeof n.limits!=`object`||typeof n.features!=`object`||typeof n.requestDevice!=`function`)throw Error("Invalid GPU adapter set in `env.webgpu.adapter`. It must be a GPUAdapter object.")}else{let t=e.webgpu.powerPreference;if(t!==void 0&&t!==`low-power`&&t!==`high-performance`)throw Error(`Invalid powerPreference setting: "${t}"`);let r=e.webgpu.forceFallbackAdapter;if(r!==void 0&&typeof r!=`boolean`)throw Error(`Invalid forceFallbackAdapter setting: "${r}"`);if(n=await navigator.gpu.requestAdapter({powerPreference:t,forceFallbackAdapter:r}),!n)throw Error(`Failed to get GPU adapter. You may need to enable flag "--enable-unsafe-webgpu" if you are using Chrome.`)}}if(t===`webnn`&&(typeof navigator>`u`||!navigator.ml))throw Error(`WebNN is not supported in current environment`)},qg=new Map,Jg=e=>{let t=J(),n=t.stackSave();try{let n=t.PTR_SIZE,r=t.stackAlloc(2*n);t._OrtGetInputOutputCount(e,r,r+n)!==0&&Y(`Can't get session input/output count.`);let i=n===4?`i32`:`i64`;return[Number(t.getValue(r,i)),Number(t.getValue(r+n,i))]}finally{t.stackRestore(n)}},Yg=(e,t)=>{let n=J(),r=n.stackSave(),i=0;try{let r=n.PTR_SIZE,a=n.stackAlloc(2*r);n._OrtGetInputOutputMetadata(e,t,a,a+r)!==0&&Y(`Can't get session input/output metadata.`);let o=Number(n.getValue(a,`*`));i=Number(n.getValue(a+r,`*`));let s=n.HEAP32[i/4];if(s===0)return[o,0];let c=n.HEAPU32[i/4+1],l=[];for(let e=0;e<c;e++){let t=Number(n.getValue(i+8+e*r,`*`));l.push(t===0?Number(n.getValue(i+8+(e+c)*r,`*`)):n.UTF8ToString(t))}return[o,s,l]}finally{n.stackRestore(r),i!==0&&n._OrtFree(i)}},Xg=e=>{let t=J(),n=t._malloc(e.byteLength);if(n===0)throw Error(`Can't create a session. failed to allocate a buffer of size ${e.byteLength}.`);return t.HEAPU8.set(e,n),[n,e.byteLength]},Zg=async(e,t)=>{let n,r,i=J();Array.isArray(e)?[n,r]=e:e.buffer===i.HEAPU8.buffer?[n,r]=[e.byteOffset,e.byteLength]:[n,r]=Xg(e);let a=0,o=0,s=[],c=[],l=[];try{if([o,s]=await jg(t),t?.externalData&&i.mountExternalData){let e=[];for(let n of t.externalData){let t=typeof n==`string`?n:n.path,r=typeof n==`string`?n:n.data;e.push(Hg(r).then(e=>{i.mountExternalData(t,e)}))}await Promise.all(e)}for(let e of t?.executionProviders??[])if((typeof e==`string`?e:e.name)===`webnn`){if(i.shouldTransferToMLTensor=!1,typeof e!=`string`){let t=e,n=t?.context,r=t?.gpuDevice,a=t?.deviceType,o=t?.powerPreference;i.currentContext=n||(r?await i.webnnCreateMLContext(r):await i.webnnCreateMLContext({deviceType:a,powerPreference:o}))}else i.currentContext=await i.webnnCreateMLContext();break}a=await i._OrtCreateSession(n,r,o),i.webgpuOnCreateSession?.(a),a===0&&Y(`Can't create a session.`),i.jsepOnCreateSession?.(),i.currentContext&&(i.webnnRegisterMLContext(a,i.currentContext),i.currentContext=void 0,i.shouldTransferToMLTensor=!0);let[e,u]=Jg(a),d=!!t?.enableGraphCapture,f=[],p=[],m=[],h=[];for(let t=0;t<e;t++){let[e,n,r]=Yg(a,t);e===0&&Y(`Can't get an input name.`),c.push(e);let o=i.UTF8ToString(e);f.push(o),m.push(n===0?{name:o,isTensor:!1}:{name:o,isTensor:!0,type:Pg(n),shape:r})}for(let t=0;t<u;t++){let[n,r,o]=Yg(a,t+e);n===0&&Y(`Can't get an output name.`),l.push(n);let s=i.UTF8ToString(n);p.push(s),h.push(r===0?{name:s,isTensor:!1}:{name:s,isTensor:!0,type:Pg(r),shape:o})}return qg.set(a,[a,c,l,null,d,!1]),[a,f,p,m,h]}catch(e){throw c.forEach(e=>i._OrtFree(e)),l.forEach(e=>i._OrtFree(e)),a!==0&&i._OrtReleaseSession(a)!==0&&Y(`Can't release session.`),e}finally{i._free(n),o!==0&&i._OrtReleaseSessionOptions(o)!==0&&Y(`Can't release session options.`),s.forEach(e=>i._free(e)),i.unmountExternalData?.()}},Qg=e=>{let t=J(),n=qg.get(e);if(!n)throw Error(`cannot release session. invalid session id: ${e}`);let[r,i,a,o,s]=n;o&&(s&&t._OrtClearBoundOutputs(o.handle)!==0&&Y(`Can't clear bound outputs.`),t._OrtReleaseBinding(o.handle)!==0&&Y(`Can't release IO binding.`)),t.jsepOnReleaseSession?.(e),t.webnnOnReleaseSession?.(e),t.webgpuOnReleaseSession?.(e),i.forEach(e=>t._OrtFree(e)),a.forEach(e=>t._OrtFree(e)),t._OrtReleaseSession(r)!==0&&Y(`Can't release session.`),qg.delete(e)},$g=async(e,t,n,r,i,a,o=!1)=>{if(!e){t.push(0);return}let s=J(),c=s.PTR_SIZE,l=e[0],u=e[1],d=e[3],f=d,p,m;if(l===`string`&&(d===`gpu-buffer`||d===`ml-tensor`))throw Error(`String tensor is not supported on GPU.`);if(o&&d!==`gpu-buffer`)throw Error(`External buffer must be provided for input/output index ${a} when enableGraphCapture is true.`);if(d===`gpu-buffer`){let t=e[2].gpuBuffer;m=Fg(Ng(l),u);{let e=s.jsepRegisterBuffer;if(!e)throw Error(`Tensor location "gpu-buffer" is not supported without using WebGPU.`);p=e(r,a,t,m)}}else if(d===`ml-tensor`){let t=e[2].mlTensor;m=Fg(Ng(l),u);let n=s.webnnRegisterMLTensor;if(!n)throw Error(`Tensor location "ml-tensor" is not supported without using WebNN.`);p=n(r,t,Ng(l),u)}else{let t=e[2];if(Array.isArray(t)){m=c*t.length,p=s._malloc(m),n.push(p);for(let e=0;e<t.length;e++){if(typeof t[e]!=`string`)throw TypeError(`tensor data at index ${e} is not a string`);s.setValue(p+e*c,xg(t[e],n),`*`)}}else{let e=s.webnnIsGraphInput,a=s.webnnIsGraphOutput;if(l!==`string`&&e&&a){let o=s.UTF8ToString(i);if(e(r,o)||a(r,o)){let e=Ng(l);m=Fg(e,u),f=`ml-tensor`;let n=s.webnnCreateTemporaryTensor,i=s.webnnUploadTensor;if(!n||!i)throw Error(`Tensor location "ml-tensor" is not supported without using WebNN.`);let a=await n(r,e,u);i(a,new Uint8Array(t.buffer,t.byteOffset,t.byteLength)),p=a}else m=t.byteLength,p=s._malloc(m),n.push(p),s.HEAPU8.set(new Uint8Array(t.buffer,t.byteOffset,m),p)}else m=t.byteLength,p=s._malloc(m),n.push(p),s.HEAPU8.set(new Uint8Array(t.buffer,t.byteOffset,m),p)}}let h=s.stackSave(),g=s.stackAlloc(4*u.length);try{u.forEach((e,t)=>s.setValue(g+t*c,e,c===4?`i32`:`i64`));let e=s._OrtCreateTensor(Ng(l),p,m,g,u.length,Bg(f));e===0&&Y(`Can't create tensor for input/output. session=${r}, index=${a}.`),t.push(e)}finally{s.stackRestore(h)}},e_=async(e,t,n,r,i,a)=>{let o=J(),s=o.PTR_SIZE,c=qg.get(e);if(!c)throw Error(`cannot run inference. invalid session id: ${e}`);let l=c[0],u=c[1],d=c[2],f=c[3],p=c[4];c[5];let m=t.length,h=r.length,g=0,_=[],v=[],y=[],b=[],x=[],S=o.stackSave(),C=o.stackAlloc(m*s),w=o.stackAlloc(m*s),T=o.stackAlloc(h*s),E=o.stackAlloc(h*s);try{[g,_]=wg(a),Mh(`wasm prepareInputOutputTensor`);for(let r=0;r<m;r++)await $g(n[r],v,b,e,u[t[r]],t[r],p);for(let t=0;t<h;t++)await $g(i[t],y,b,e,d[r[t]],m+r[t],p);Nh(`wasm prepareInputOutputTensor`);for(let e=0;e<m;e++)o.setValue(C+e*s,v[e],`*`),o.setValue(w+e*s,u[t[e]],`*`);for(let e=0;e<h;e++)o.setValue(T+e*s,y[e],`*`),o.setValue(E+e*s,d[r[e]],`*`);o.jsepOnRunStart?.(l),o.webnnOnRunStart?.(l);let c;c=await o._OrtRun(l,w,C,m,E,h,T,g),c!==0&&Y(`failed to call OrtRun().`);let S=[],ee=[];Mh(`wasm ProcessOutputTensor`);for(let t=0;t<h;t++){let n=Number(o.getValue(T+t*s,`*`));if(n===y[t]||x.includes(y[t])){S.push(i[t]),n!==y[t]&&o._OrtReleaseTensor(n)!==0&&Y(`Can't release tensor.`);continue}let a=o.stackSave(),c=o.stackAlloc(4*s),l=!1,u,d=0;try{o._OrtGetTensorData(n,c,c+s,c+2*s,c+3*s)!==0&&Y(`Can't access output tensor data on index ${t}.`);let i=s===4?`i32`:`i64`,a=Number(o.getValue(c,i));d=o.getValue(c+s,`*`);let p=o.getValue(c+s*2,`*`),m=Number(o.getValue(c+s*3,i)),h=[];for(let e=0;e<m;e++)h.push(Number(o.getValue(p+e*s,i)));o._OrtFree(p)!==0&&Y(`Can't free memory for tensor dims.`);let g=h.reduce((e,t)=>e*t,1);u=Pg(a);let _=f?.outputPreferredLocations[r[t]];if(u===`string`){if(_===`gpu-buffer`||_===`ml-tensor`)throw Error(`String tensor is not supported on GPU.`);let e=[];for(let t=0;t<g;t++){let n=o.getValue(d+t*s,`*`),r=o.getValue(d+(t+1)*s,`*`),i=t===g-1?void 0:r-n;e.push(o.UTF8ToString(n,i))}S.push([u,h,e,`cpu`])}else if(_===`gpu-buffer`&&g>0){let e=o.jsepGetBuffer;if(!e)throw Error(`preferredLocation "gpu-buffer" is not supported without using WebGPU.`);let t=e(d),r=Fg(a,g);if(r===void 0||!Rg(u))throw Error(`Unsupported data type: ${u}`);l=!0,S.push([u,h,{gpuBuffer:t,download:o.jsepCreateDownloader(t,r,u),dispose:()=>{o._OrtReleaseTensor(n)!==0&&Y(`Can't release tensor.`)}},`gpu-buffer`])}else if(_===`ml-tensor`&&g>0){let t=o.webnnEnsureTensor,r=o.webnnIsGraphInputOutputTypeSupported;if(!t||!r)throw Error(`preferredLocation "ml-tensor" is not supported without using WebNN.`);if(Fg(a,g)===void 0||!zg(u))throw Error(`Unsupported data type: ${u}`);if(!r(e,u,!1))throw Error(`preferredLocation "ml-tensor" for ${u} output is not supported by current WebNN Context.`);let i=await t(e,d,a,h,!1);l=!0,S.push([u,h,{mlTensor:i,download:o.webnnCreateMLTensorDownloader(d,u),dispose:()=>{o.webnnReleaseTensorId(d),o._OrtReleaseTensor(n)}},`ml-tensor`])}else if(_===`ml-tensor-cpu-output`&&g>0){let e=o.webnnCreateMLTensorDownloader(d,u)(),t=S.length;l=!0,ee.push((async()=>{let r=[t,await e];return o.webnnReleaseTensorId(d),o._OrtReleaseTensor(n),r})()),S.push([u,h,[],`cpu`])}else{let e=new(Ig(u))(g);new Uint8Array(e.buffer,e.byteOffset,e.byteLength).set(o.HEAPU8.subarray(d,d+e.byteLength)),S.push([u,h,e,`cpu`])}}finally{o.stackRestore(a),u===`string`&&d&&o._free(d),l||o._OrtReleaseTensor(n)}}f&&!p&&(o._OrtClearBoundOutputs(f.handle)!==0&&Y(`Can't clear bound outputs.`),qg.set(e,[l,u,d,f,p,!1]));for(let[e,t]of await Promise.all(ee))S[e][2]=t;return Nh(`wasm ProcessOutputTensor`),S}finally{o.webnnOnRunEnd?.(l),o.stackRestore(S),v.forEach(e=>o._OrtReleaseTensor(e)),y.forEach(e=>o._OrtReleaseTensor(e)),b.forEach(e=>o._free(e)),g!==0&&o._OrtReleaseRunOptions(g),_.forEach(e=>o._free(e))}},t_=e=>{let t=J(),n=qg.get(e);if(!n)throw Error(`invalid session id`);let r=n[0],i=t._OrtEndProfiling(r);i===0&&Y(`Can't get an profile file name.`),t._OrtFree(i)},n_=e=>{let t=[];for(let n of e){let e=n[2];!Array.isArray(e)&&`buffer`in e&&t.push(e.buffer)}return t}}),S_=G(()=>{"use strict";Wh(),r_(),bg(),dg(),i_=()=>!!q.wasm.proxy&&typeof document<`u`,o_=!1,s_=!1,c_=!1,d_=new Map,f_=(e,t)=>{let n=d_.get(e);n?n.push(t):d_.set(e,[t])},p_=()=>{if(o_||!s_||c_||!a_)throw Error(`worker not ready`)},m_=e=>{switch(e.data.type){case`init-wasm`:o_=!1,e.data.err?(c_=!0,u_[1](e.data.err)):(s_=!0,u_[0]()),l_&&=(URL.revokeObjectURL(l_),void 0);break;case`init-ep`:case`copy-from`:case`create`:case`release`:case`run`:case`end-profiling`:{let t=d_.get(e.data.type);e.data.err?t.shift()[1](e.data.err):t.shift()[0](e.data.out);break}}},h_=async()=>{if(!s_){if(o_)throw Error(`multiple calls to 'initWasm()' detected.`);if(c_)throw Error(`previous call to 'initWasm()' failed.`);if(o_=!0,i_())return new Promise((e,t)=>{a_?.terminate(),cg().then(([n,r])=>{try{a_=r,a_.onerror=e=>t(e),a_.onmessage=m_,u_=[e,t];let i={type:`init-wasm`,in:q};if(!i.in.wasm.wasmPaths&&n){let e=tg();e&&(i.in.wasm.wasmPaths=e)}a_.postMessage(i),l_=n}catch(e){t(e)}},t)});try{await yg(q.wasm),await Gg(q),s_=!0}catch(e){throw c_=!0,e}finally{o_=!1}}},g_=async e=>{if(i_())return p_(),new Promise((t,n)=>{f_(`init-ep`,[t,n]);let r={type:`init-ep`,in:{epName:e,env:q}};a_.postMessage(r)});await Kg(q,e)},__=async e=>i_()?(p_(),new Promise((t,n)=>{f_(`copy-from`,[t,n]);let r={type:`copy-from`,in:{buffer:e}};a_.postMessage(r,[e.buffer])})):Xg(e),v_=async(e,t)=>{if(i_()){if(t?.preferredOutputLocation)throw Error(`session option "preferredOutputLocation" is not supported for proxy.`);return p_(),new Promise((n,r)=>{f_(`create`,[n,r]);let i={type:`create`,in:{model:e,options:{...t}}},a=[];e instanceof Uint8Array&&a.push(e.buffer),a_.postMessage(i,a)})}return Zg(e,t)},y_=async e=>{if(i_())return p_(),new Promise((t,n)=>{f_(`release`,[t,n]);let r={type:`release`,in:e};a_.postMessage(r)});Qg(e)},b_=async(e,t,n,r,i,a)=>{if(i_()){if(n.some(e=>e[3]!==`cpu`))throw Error(`input tensor on GPU is not supported for proxy.`);if(i.some(e=>e))throw Error(`pre-allocated output tensor is not supported for proxy.`);return p_(),new Promise((i,o)=>{f_(`run`,[i,o]);let s=n,c={type:`run`,in:{sessionId:e,inputIndices:t,inputs:s,outputIndices:r,options:a}};a_.postMessage(c,n_(s))})}return e_(e,t,n,r,i,a)},x_=async e=>{if(i_())return p_(),new Promise((t,n)=>{f_(`end-profiling`,[t,n]);let r={type:`end-profiling`,in:e};a_.postMessage(r)});t_(e)}}),E_=G(()=>{"use strict";Wh(),S_(),Vg(),Gh(),Ug(),C_=(e,t)=>{switch(e.location){case`cpu`:return[e.type,e.dims,e.data,`cpu`];case`gpu-buffer`:return[e.type,e.dims,{gpuBuffer:e.gpuBuffer},`gpu-buffer`];case`ml-tensor`:return[e.type,e.dims,{mlTensor:e.mlTensor},`ml-tensor`];default:throw Error(`invalid data location: ${e.location} for ${t()}`)}},w_=e=>{switch(e[3]){case`cpu`:return new Eh(e[0],e[2],e[1]);case`gpu-buffer`:{let t=e[0];if(!Rg(t))throw Error(`not supported data type: ${t} for deserializing GPU tensor`);let{gpuBuffer:n,download:r,dispose:i}=e[2];return Eh.fromGpuBuffer(n,{dataType:t,dims:e[1],download:r,dispose:i})}case`ml-tensor`:{let t=e[0];if(!zg(t))throw Error(`not supported data type: ${t} for deserializing MLTensor tensor`);let{mlTensor:n,download:r,dispose:i}=e[2];return Eh.fromMLTensor(n,{dataType:t,dims:e[1],download:r,dispose:i})}default:throw Error(`invalid data location: ${e[3]}`)}},T_=class{async fetchModelAndCopyToWasmMemory(e){return __(await Hg(e))}async loadModel(e,t){Ah();let n;n=typeof e==`string`?await this.fetchModelAndCopyToWasmMemory(e):e,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await v_(n,t),jh()}async dispose(){return y_(this.sessionId)}async run(e,t,n){Ah();let r=[],i=[];Object.entries(e).forEach(e=>{let t=e[0],n=e[1],a=this.inputNames.indexOf(t);if(a===-1)throw Error(`invalid input '${t}'`);r.push(n),i.push(a)});let a=[],o=[];Object.entries(t).forEach(e=>{let t=e[0],n=e[1],r=this.outputNames.indexOf(t);if(r===-1)throw Error(`invalid output '${t}'`);a.push(n),o.push(r)});let s=r.map((e,t)=>C_(e,()=>`input "${this.inputNames[i[t]]}"`)),c=a.map((e,t)=>e?C_(e,()=>`output "${this.outputNames[o[t]]}"`):null),l=await b_(this.sessionId,i,s,o,c,n),u={};for(let e=0;e<l.length;e++)u[this.outputNames[o[e]]]=a[e]??w_(l[e]);return jh(),u}startProfiling(){}endProfiling(){x_(this.sessionId)}}}),D_={},Gm(D_,{OnnxruntimeWebAssemblyBackend:()=>k_,initializeFlags:()=>O_,wasmBackend:()=>A_}),j_=G(()=>{"use strict";Wh(),S_(),E_(),O_=()=>{(typeof q.wasm.initTimeout!=`number`||q.wasm.initTimeout<0)&&(q.wasm.initTimeout=0);let e=q.wasm.simd;if(typeof e!=`boolean`&&e!==void 0&&e!==`fixed`&&e!==`relaxed`&&(console.warn(`Property "env.wasm.simd" is set to unknown value "${e}". Reset it to \`false\` and ignore SIMD feature checking.`),q.wasm.simd=!1),typeof q.wasm.proxy!=`boolean`&&(q.wasm.proxy=!1),typeof q.wasm.trace!=`boolean`&&(q.wasm.trace=!1),typeof q.wasm.numThreads!=`number`||!Number.isInteger(q.wasm.numThreads)||q.wasm.numThreads<=0){if(typeof self<`u`&&!self.crossOriginIsolated)q.wasm.numThreads=1;else{let e=typeof navigator>`u`?Wm(`node:os`).cpus().length:navigator.hardwareConcurrency;q.wasm.numThreads=Math.min(4,Math.ceil((e||1)/2))}}},k_=class{async init(e){O_(),await h_(),await g_(e)}async createInferenceSessionHandler(e,t){let n=new T_;return await n.loadModel(e,t),n}},A_=new k_}),Wh(),Wh(),Wh(),M_=`1.30.0`,N_=Uh;{let e=(j_(),qm(D_)).wasmBackend;Xm(`cpu`,e,10),Xm(`wasm`,e,10)}Object.defineProperty(q.versions,"web",{value:M_,enumerable:!0})})),F_,I_,L_=t((()=>{F_=({box:e,image:t})=>{let n=Math.max(0,Math.floor(e.left)),r=Math.max(0,Math.floor(e.top)),i=Math.min(t.width,Math.ceil(e.right)),a=Math.min(t.height,Math.ceil(e.bottom)),o=Math.max(1,i-n),s=Math.max(1,a-r),c=new Uint8ClampedArray(o*s*4);for(let e=0;e<s;e+=1){let i=((r+e)*t.width+n)*4,a=e*o*4;c.set(t.data.subarray(i,i+o*4),a)}return{data:c,height:s,width:o}},I_=({height:e,image:t,width:n})=>{let r=new Uint8ClampedArray(n*e*4),i=t.width/n,a=t.height/e;for(let o=0;o<e;o+=1){let e=Math.min(t.height-1,Math.floor((o+.5)*a));for(let a=0;a<n;a+=1){let s=Math.min(t.width-1,Math.floor((a+.5)*i)),c=(e*t.width+s)*4,l=(o*n+a)*4;r[l]=t.data[c]??0,r[l+1]=t.data[c+1]??0,r[l+2]=t.data[c+2]??0,r[l+3]=255}}return{data:r,height:e,width:n}}})),R_,z_,B_,V_=t((()=>{R_=null,z_=({category:e,duration:t,key:n})=>{if(!R_)return;let r=R_[e];r[n]=(r[n]??0)+t},B_=async({key:e,operation:t})=>{let n=performance.now();try{return await t()}finally{z_({category:`stages`,duration:performance.now()-n,key:e})}}})),H_,U_,W_,G_,K_,q_,J_,Y_,X_,Z_,Q_,$_,ev,tv,nv,rv=t((()=>{W(),L_(),V_(),H_=.3,U_=.6,W_=12,G_=3,K_=async({session:e,tensor:t})=>{let n=performance.now();try{let n=await e.run({[e.inputNames[0]]:t}),r=n[e.outputNames[0]];if(!r){for(let e of Object.values(n))e.dispose();throw Error(j.INVALID_MODEL_OUTPUT)}for(let e of Object.values(n))e!==r&&e.dispose();return r}catch(e){throw Error(Pt({error:e,fallback:j.INFERENCE_FAILED}),{cause:e})}finally{z_({category:`inference`,duration:performance.now()-n,key:`ocr`}),t.dispose()}},q_=({text:e})=>e.normalize(`NFKC`).replace(/\r\n?/gu,`
|
|
57
57
|
`).replace(/[\t\f\v ]+/gu,` `).replace(/ *\n */gu,`
|
|
58
|
-
`).trim(),
|
|
59
|
-
`);for(;a.at(-1)===``;)a.pop();return{model:t.id,assets:[t.detection,t.recognition,t.dictionary],recognize:async({image:i})=>{let o=await e.decode(i),s=await
|
|
60
|
-
`)});return{engine:t.id,height:o.height,lines:l,text:u,width:o.width}}}}})),
|
|
61
|
-
`).map(e=>e.replace(/\s+/g,``)),n=t.findIndex(e=>e.startsWith(`P<`)&&e.length>=44&&(e.match(/</g)||[]).length>=2);if(n>=0&&t.slice(n+1).find(e=>/^[A-Z0-9<]{44}$/u.test(e)))return!0;let r=t.findIndex(e=>/^[A-Z0-9]<[A-Z]{3}/u.test(e)&&e.length>=30);return r<0?!1:t.slice(r+1).filter(e=>/^[A-Z0-9<]{30}$/u.test(e)).length>=2}})),Jh,Yh,Xh=t((()=>{Jh=({polygon:e,sourceOrientation:t=0})=>{let n=e.reduce((t,n)=>({x:t.x+n.x/e.length,y:t.y+n.y/e.length}),{x:0,y:0}),r=[...e].sort((e,t)=>Math.atan2(e.y-n.y,e.x-n.x)-Math.atan2(t.y-n.y,t.x-n.x)),i=(r.reduce((e,t,n)=>t.x+t.y<r[e].x+r[e].y?n:e,0)+t/90)%4;return r.slice(i).concat(r.slice(0,i))},Yh=({polygon:e})=>{let t=e.map(e=>e.x),n=e.map(e=>e.y),r=Math.min(...t),i=Math.min(...n);return{x:r,y:i,width:Math.max(...t)-r,height:Math.max(...n)-i}}})),Zh,Qh,$h,eg,tg,ng,rg,ig,ag=t((()=>{W(),Xh(),Zh=2,Qh=2048,$h=70,eg=.6,tg=({first:e,second:t})=>Math.hypot(t.x-e.x,t.y-e.y),ng=({matrix:e,values:t})=>{let n=e.map((e,n)=>[...e,t[n]??0]);for(let e=0;e<n.length;e+=1){let t=e;for(let r=e+1;r<n.length;r+=1)Math.abs(n[r][e]??0)>Math.abs(n[t][e]??0)&&(t=r);if(Math.abs(n[t][e]??0)<1e-8)return null;[n[e],n[t]]=[n[t],n[e]];let r=n[e][e]??1;for(let t=e;t<=n.length;t+=1)n[e][t]=(n[e][t]??0)/r;for(let t=0;t<n.length;t+=1){if(t===e)continue;let r=n[t][e]??0;for(let i=e;i<=n.length;i+=1)n[t][i]=(n[t][i]??0)-r*(n[e][i]??0)}}return n.map(e=>e[n.length]??0)},rg=({from:e,to:t})=>{let n=[],r=[];for(let[i,a]of e.entries()){let e=t[i];if(!e)return null;n.push([a.x,a.y,1,0,0,0,-e.x*a.x,-e.x*a.y]),r.push(e.x),n.push([0,0,0,a.x,a.y,1,-e.y*a.x,-e.y*a.y]),r.push(e.y)}let i=ng({matrix:n,values:r});return i?[...i,1]:null},ig=({image:e,polygon:t,sourceOrientation:n})=>{let[r,i,a,o]=Jh({polygon:t,sourceOrientation:n});if(!r||!i||!a||!o)throw Error(U.DOCUMENT_NOT_FOUND);let s=Math.max(1,Math.round((tg({first:r,second:i})+tg({first:o,second:a}))/2)),c=Math.max(1,Math.round((tg({first:i,second:a})+tg({first:r,second:o}))/2)),l=rg({from:[{x:0,y:0},{x:s,y:0},{x:s,y:c},{x:0,y:c}],to:[r,i,a,o]});if(!l)throw Error(U.DOCUMENT_NOT_FOUND);let[u,d,f,p,m,h,g,_,v]=l;if([u,d,f,p,m,h,g,_,v].some(e=>e===void 0))throw Error(U.DOCUMENT_NOT_FOUND);let y=Math.min(Zh,Qh/Math.max(s,c)),b=Math.max(1,Math.round(s*y)),x=Math.max(1,Math.round(c*y)),S=new Uint8ClampedArray(b*x*4),C=new Uint8ClampedArray(b*x),w=new Float64Array(e.width*e.height);for(let t=0;t<w.length;t+=1){let n=t*4;w[t]=(e.data[n]??0)*.299+(e.data[n+1]??0)*.587+(e.data[n+2]??0)*.114}for(let t=0;t<x;t+=1)for(let n=0;n<b;n+=1){let r=n*s/b,i=t*c/x,a=g*r+_*i+v,o=(u*r+d*i+f)/a,l=(p*r+m*i+h)/a,y=Math.max(0,Math.min(e.width-1,o)),S=Math.max(0,Math.min(e.height-1,l)),T=Math.floor(y),E=Math.floor(S),ee=Math.min(e.width-1,T+1),D=Math.min(e.height-1,E+1),te=y-T,ne=S-E,re=E*e.width,O=D*e.width,ie=w[re+T]*(1-te)+w[re+ee]*te,ae=w[O+T]*(1-te)+w[O+ee]*te,oe=ie*(1-ne)+ae*ne;C[t*b+n]=Math.max(0,Math.min(255,Math.round((oe-$h)*255/140)))}let T=new Uint16Array(b*3),E=({y:e})=>{let t=e*b,n=e%3*b;for(let e=0;e<b;e+=1){let r=Math.max(0,e-1),i=Math.min(b-1,e+1);T[n+e]=(C[t+r]??0)+(C[t+e]??0)+(C[t+i]??0)}};E({y:0});for(let e=0;e<x;e+=1){e+1<x&&E({y:e+1});let t=Math.max(0,e-1)%3*b,n=e%3*b,r=Math.min(x-1,e+1)%3*b;for(let i=0;i<b;i+=1){let a=(T[t+i]??0)+(T[n+i]??0)+(T[r+i]??0),o=C[e*b+i]??0,s=Math.max(0,Math.min(255,Math.round(o+eg*(o-a/9)))),c=(e*b+i)*4;S[c]=s,S[c+1]=s,S[c+2]=s,S[c+3]=255}}return{data:S,height:x,width:b}}})),og,sg,cg,lg=t((()=>{W(),zh(),og=({document:e})=>e!==`passport`&&e!==`visa`,sg=({identity:e})=>!!(e?.holder.last_name&&e.holder.first_name&&e.holder.birth_date&&e.document.number),cg=({classification:e,front:t,back:n})=>{let r=[],i=e.document===`passport`,a=e.document===`visa`,o=og(e)&&!n,s=i?t.codes:[...t.codes,...n?n.codes:[]],c=s.filter(e=>e.type===`mrz`&&e.payload.document.type===`PASSPORT`&&e.code.startsWith(`P<`)),l=s.filter(e=>e.type===`mrz`&&e.payload.document.type===`VISA`),u=s.filter(e=>e.type===`mrz`&&e.payload.document.type===`ID`),d=s.filter(e=>e.type===`aamva`);return(!t.ocr.text.trim()||n&&!n.ocr.text.trim())&&r.push(U.DOCUMENT_TEXT_NOT_READABLE),o&&r.push(U.DOCUMENT_BACK_REQUIRED),i&&!c.length&&r.push(U.INVALID_PASSPORT_MRZ),a&&!l.length&&r.push(U.INVALID_DOCUMENT_MRZ),!i&&n&&(e.document===`id`&&!u.length&&r.push(U.INVALID_DOCUMENT_MRZ),e.document===`driving_license`&&(e.europeanDrivingLicense?(Rh(n.ocr)||r.push(U.EUROPEAN_LICENCE_BACK_MARKER_REQUIRED),sg({identity:e.identity})||r.push(U.DOCUMENT_VALIDATION_FAILED)):d.length||r.push(U.INVALID_DOCUMENT_AAMVA))),(i&&(l.length||u.length||d.length)||a&&(c.length||u.length||d.length)||e.document===`id`&&(c.length||l.length||d.length)||e.document===`driving_license`&&(c.length||l.length||u.length))&&r.push(U.DOCUMENT_CODE_TYPE_MISMATCH),{valid:r.length===0,reasons:r,codes:s}}})),ug,dg,fg,pg,mg,hg,gg,_g,vg,yg,bg=t((()=>{dd(),ug=z().trim().min(1).nullable(),dg=cd().nullable(),fg=Ql([`MRZ`,`AAMVA`,`OCR`]),pg=Ql([`PASSPORT`,`ID`,`VISA`,`DRV`,`PERMIT`]),mg=Ql([`M`,`F`,`X`]),hg=B({source:fg,type:pg.nullable(),issuing_country:ug,number:ug,issuing_authority:ug.default(null),issue_date:dg,expiry_date:dg,optional_data:ug}),gg=B({first_name:ug,last_name:ug,middle_name:ug,birth_place:ug.default(null),birth_date:dg,sex:mg.nullable(),nationality:ug,personal_number:ug}),_g=B({full:ug,street:ug,city:ug,state_province:ug,postal_code:ug}),vg=B({mrz_lines:ql(z().min(1)),aamva_version:ug}),yg=B({document:hg,holder:gg,address:_g.nullable(),raw_data:vg})})),xg,Sg,Cg,wg,Tg,Eg,Dg,Og=t((()=>{bg(),zh(),xg={A:`AUT`,B:`BEL`,BG:`BGR`,CY:`CYP`,CZ:`CZE`,D:`DEU`,DK:`DNK`,E:`ESP`,EST:`EST`,F:`FRA`,FIN:`FIN`,GR:`GRC`,H:`HUN`,HR:`HRV`,I:`ITA`,IRL:`IRL`,L:`LUX`,LT:`LTU`,LV:`LVA`,M:`MLT`,NL:`NLD`,P:`PRT`,PL:`POL`,RO:`ROU`,S:`SWE`,SK:`SVK`,SLO:`SVN`},Sg=({line:e,start:t,end:n})=>{let r=[],i=0;for(let a of e.words){let o=e.text.indexOf(a.text,i);if(o<0||!a.text.length)continue;i=o+a.text.length;let s=Math.max(t,o),c=Math.min(n,i);c<=s||r.push({...a.box,x:a.box.x+a.box.width*(s-o)/a.text.length,width:a.box.width*(c-s)/a.text.length})}if(!r.length)return{...e.box,x:e.box.x+e.box.width*t/e.text.length,width:e.box.width*(n-t)/e.text.length};let a=Math.min(...r.map(e=>e.x)),o=Math.min(...r.map(e=>e.y));return{x:a,y:o,width:Math.max(...r.map(e=>e.x+e.width))-a,height:Math.max(...r.map(e=>e.y+e.height))-o}},Cg=({line:e})=>{let t=e.text;if(!t.trim()||e.confidence!==null&&e.confidence<=0)return[];if(/^\s*\d{1,2}[./-]\d{1,2}[./-]\d{2,4}\s*$/u.test(t))return[{text:t.trim(),box:e.box,label:null}];let n=[...t.matchAll(/(?:^|\s)(4[a-d]|1[0-4]|[1-9])(?:[.:)]\s*|\s+|$|(?=\d{1,2}[./-]\d))/giu)];if(!n.length)return[{text:t,box:e.box,label:null}];let r=[],i=n[0].index;i>0&&r.push({text:t.slice(0,i).trim(),box:Sg({line:e,start:0,end:i}),label:null});for(let[i,a]of n.entries()){let o=a.index+a[0].indexOf(a[1]),s=n[i+1]?.index??t.length,c=t.slice(a.index+a[0].length,s).trim(),l=Sg({line:e,start:o,end:s});r.push({text:c,box:l,label:a[1].toLowerCase()})}return r},wg=({label:e,fragments:t})=>{let n=t.filter(t=>t.label===e);if(n.length!==1)return null;let r=n[0],i=r.box.height,a=r.text?[r]:[],o=t.filter(e=>e.label&&e!==r);for(let e of t){if(e.label||!e.text)continue;let t=e.box.y-r.box.y,n=Math.abs(t)<Math.max(i,e.box.height)*.5,s=t>=i*.5&&t<=i*2.5;(n||s)&&(e.box.x<r.box.x-i*.5||n&&r.text||o.some(t=>{let n=Math.abs(t.box.y-r.box.y)<i*.5&&t.box.x>r.box.x&&e.box.x>=t.box.x-i*.25,a=t.box.y>r.box.y+i*.5&&t.box.y<=e.box.y+e.box.height*.5&&Math.abs(t.box.x-r.box.x)<i*3;return n||a})||o.some(n=>{let a=e.box.y-n.box.y,o=a>=-i*.5&&a<=i*2.5&&e.box.x>=n.box.x-i*.5,s=Math.abs(t)+Math.abs(e.box.x-r.box.x),c=Math.abs(a)+Math.abs(e.box.x-n.box.x);return o&&c<=s})||a.push(e))}return a.sort((e,t)=>Math.abs(e.box.y-t.box.y)<i*.5?e.box.x-t.box.x:e.box.y-t.box.y),a.map(e=>e.text).join(` `).trim()||null},Tg=({text:e,allowTwoDigitYear:t=!1})=>{if(!e)return null;let n=e.match(/^(?:(\d{1,2})([./-])(\d{1,2})\2(\d{2,4})|(\d{4})-(\d{2})-(\d{2}))$/u);if(!n)return null;let r=n[4]??n[5],i=Number(n[3]??n[6]),a=Number(n[1]??n[7]),o=Number(r);if(r.length===2){if(!t)return null;let e=new Date,n=e.getUTCFullYear(),r=e.getUTCMonth()+1,s=e.getUTCDate(),c=[1900+o,2e3+o].filter(e=>{let t=n-e-+(r<i||r===i&&s<a);return t>=16&&t<=100});if(c.length!==1)return null;o=c[0]}return o<1e3||i<1||i>12||a<1||a>new Date(Date.UTC(o,i,0)).getUTCDate()?null:`${o}-${String(i).padStart(2,`0`)}-${String(a).padStart(2,`0`)}`},Eg=({ocr:e,image:t})=>{let n=new Set;for(let r of e.lines)for(let e of r.words.length?r.words:[r]){let r=e.text.trim().toUpperCase(),i=xg[r],{x:a,y:o,width:s,height:c}=e.box;if(e.confidence!==null&&e.confidence<=0||!i||a<0||o<0||a+s>t.width*.3||o+c>t.height*.35)continue;let l=Math.max(s,c);Ih({...t,xStart:Math.max(0,a-l)/t.width,xEnd:Math.min(t.width,a+s+l)/t.width,yStart:Math.max(0,o-l)/t.height,yEnd:Math.min(t.height,o+c+l)/t.height,predicate:(e,t,n)=>n>45&&n>e*1.08&&n>t*1.04})>=.15&&n.add(i)}return n.size===1?[...n][0]:null},Dg=({ocr:e,image:t})=>{if(Rh(e))return null;let n=e.lines.flatMap(e=>Cg({line:e})),r=new Set(n.map(e=>e.label));if(!(r.has(`1`)||r.has(`2`))||![`3`,`4a`,`4b`,`5`].some(e=>r.has(e)))return null;let i=wg({label:`1`,fragments:n}),a=wg({label:`2`,fragments:n}),o=i&&/\p{L}/u.test(i)?i:null,s=a&&/\p{L}/u.test(a)?a:null,c=wg({label:`3`,fragments:n})?.match(/^(\d{1,2}[./-]\d{1,2}[./-]\d{2,4}|\d{4}-\d{2}-\d{2})(?:\s+(.+))?$/u),l=Tg({allowTwoDigitYear:!0,text:c?c[1]:null}),u=c&&c[2]?.trim()||null,d=Tg({text:wg({label:`4a`,fragments:n})}),f=Tg({text:wg({label:`4b`,fragments:n})}),p=wg({label:`4c`,fragments:n}),m=wg({label:`5`,fragments:n}),h=Eg({ocr:e,image:t});return[o,s,l,u,d,f,p,m,h].some(Boolean)?yg.parse({document:{source:`OCR`,type:`DRV`,issuing_country:h,issuing_authority:p,number:m,issue_date:d,expiry_date:f,optional_data:null},holder:{first_name:s,last_name:o,middle_name:null,birth_date:l,birth_place:u,sex:null,nationality:null,personal_number:null},address:null,raw_data:{mrz_lines:[],aamva_version:null}}):null}})),kg=t((()=>{})),Ag,jg=t((()=>{Ag={TD1:`TD1`,TD2:`TD2`,TD3:`TD3`,SWISS_DRIVING_LICENSE:`SWISS_DRIVING_LICENSE`,FRENCH_NATIONAL_ID:`FRENCH_NATIONAL_ID`,FRENCH_DRIVING_LICENSE:`FRENCH_DRIVING_LICENSE`}})),Mg,Ng=t((()=>{Mg={AFG:`Afghanistan`,ALB:`Albania`,DZA:`Algeria`,ASM:`American Samoa`,AND:`Andorra`,AGO:`Angola`,AIA:`Anguilla`,ATA:`Antarctica`,ATG:`Antigua and Barbuda`,ARG:`Argentina`,ARM:`Armenia`,ABW:`Aruba`,AUS:`Australia`,AUT:`Austria`,AZE:`Azerbaijan`,BHS:`Bahamas (the)`,BHR:`Bahrain`,BGD:`Bangladesh`,BRB:`Barbados`,BLR:`Belarus`,BEL:`Belgium`,BLZ:`Belize`,BEN:`Benin`,BMU:`Bermuda`,BTN:`Bhutan`,BOL:`Bolivia (Plurinational State of)`,BES:`Bonaire, Sint Eustatius and Saba`,BIH:`Bosnia and Herzegovina`,BWA:`Botswana`,BVT:`Bouvet Island`,BRA:`Brazil`,IOT:`British Indian Ocean Territory (the)`,BRN:`Brunei Darussalam`,BGR:`Bulgaria`,BFA:`Burkina Faso`,BDI:`Burundi`,CPV:`Cabo Verde`,KHM:`Cambodia`,CMR:`Cameroon`,CAN:`Canada`,CYM:`Cayman Islands (the)`,CAF:`Central African Republic (the)`,TCD:`Chad`,CHL:`Chile`,CHN:`China`,CXR:`Christmas Island`,CCK:`Cocos (Keeling) Islands (the)`,COL:`Colombia`,COM:`Comoros (the)`,COD:`Congo (the Democratic Republic of the)`,COG:`Congo (the)`,COK:`Cook Islands (the)`,CRI:`Costa Rica`,HRV:`Croatia`,CUB:`Cuba`,CUW:`Curaçao`,CYP:`Cyprus`,CZE:`Czechia`,CIV:`Côte d'Ivoire`,DNK:`Denmark`,DJI:`Djibouti`,DMA:`Dominica`,DOM:`Dominican Republic (the)`,ECU:`Ecuador`,EGY:`Egypt`,SLV:`El Salvador`,GNQ:`Equatorial Guinea`,ERI:`Eritrea`,EST:`Estonia`,SWZ:`Eswatini`,ETH:`Ethiopia`,FLK:`Falkland Islands (the) [Malvinas]`,FRO:`Faroe Islands (the)`,FJI:`Fiji`,FIN:`Finland`,FRA:`France`,GUF:`French Guiana`,PYF:`French Polynesia`,ATF:`French Southern Territories (the)`,GAB:`Gabon`,GMB:`Gambia (the)`,GEO:`Georgia`,DEU:`Germany`,GHA:`Ghana`,GIB:`Gibraltar`,GRC:`Greece`,GRL:`Greenland`,GRD:`Grenada`,GLP:`Guadeloupe`,GUM:`Guam`,GTM:`Guatemala`,GGY:`Guernsey`,GIN:`Guinea`,GNB:`Guinea-Bissau`,GUY:`Guyana`,HTI:`Haiti`,HMD:`Heard Island and McDonald Islands`,VAT:`Holy See (the)`,HND:`Honduras`,HKG:`Hong Kong`,HUN:`Hungary`,ISL:`Iceland`,IND:`India`,IDN:`Indonesia`,IRN:`Iran (Islamic Republic of)`,IRQ:`Iraq`,IRL:`Ireland`,IMN:`Isle of Man`,ISR:`Israel`,ITA:`Italy`,JAM:`Jamaica`,JPN:`Japan`,JEY:`Jersey`,JOR:`Jordan`,KAZ:`Kazakhstan`,KEN:`Kenya`,KIR:`Kiribati`,PRK:`Korea (the Democratic People's Republic of)`,KOR:`Korea (the Republic of)`,KWT:`Kuwait`,KGZ:`Kyrgyzstan`,LAO:`Lao People's Democratic Republic (the)`,LVA:`Latvia`,LBN:`Lebanon`,LSO:`Lesotho`,LBR:`Liberia`,LBY:`Libya`,LIE:`Liechtenstein`,LTU:`Lithuania`,LUX:`Luxembourg`,MAC:`Macao`,MDG:`Madagascar`,MWI:`Malawi`,MYS:`Malaysia`,MDV:`Maldives`,MLI:`Mali`,MLT:`Malta`,MHL:`Marshall Islands (the)`,MTQ:`Martinique`,MRT:`Mauritania`,MUS:`Mauritius`,MYT:`Mayotte`,MEX:`Mexico`,FSM:`Micronesia (Federated States of)`,MDA:`Moldova (the Republic of)`,MCO:`Monaco`,MNG:`Mongolia`,MNE:`Montenegro`,MSR:`Montserrat`,MAR:`Morocco`,MOZ:`Mozambique`,MMR:`Myanmar`,NAM:`Namibia`,NRU:`Nauru`,NPL:`Nepal`,NLD:`Netherlands (the)`,NCL:`New Caledonia`,NZL:`New Zealand`,NIC:`Nicaragua`,NER:`Niger (the)`,NGA:`Nigeria`,NIU:`Niue`,NFK:`Norfolk Island`,MKD:`North Macedonia`,MNP:`Northern Mariana Islands (the)`,NOR:`Norway`,OMN:`Oman`,PAK:`Pakistan`,PLW:`Palau`,PSE:`Palestine, State of`,PAN:`Panama`,PNG:`Papua New Guinea`,PRY:`Paraguay`,PER:`Peru`,PHL:`Philippines (the)`,PCN:`Pitcairn`,POL:`Poland`,PRT:`Portugal`,PRI:`Puerto Rico`,QAT:`Qatar`,ROU:`Romania`,RUS:`Russian Federation (the)`,RWA:`Rwanda`,REU:`Réunion`,BLM:`Saint Barthélemy`,SHN:`Saint Helena, Ascension and Tristan da Cunha`,KNA:`Saint Kitts and Nevis`,LCA:`Saint Lucia`,MAF:`Saint Martin (French part)`,SPM:`Saint Pierre and Miquelon`,VCT:`Saint Vincent and the Grenadines`,WSM:`Samoa`,SMR:`San Marino`,STP:`Sao Tome and Principe`,SAU:`Saudi Arabia`,SEN:`Senegal`,SRB:`Serbia`,SYC:`Seychelles`,SLE:`Sierra Leone`,SGP:`Singapore`,SXM:`Sint Maarten (Dutch part)`,SVK:`Slovakia`,SVN:`Slovenia`,SLB:`Solomon Islands`,SOM:`Somalia`,ZAF:`South Africa`,SGS:`South Georgia and the South Sandwich Islands`,SSD:`South Sudan`,ESP:`Spain`,LKA:`Sri Lanka`,SDN:`Sudan (the)`,SUR:`Suriname`,SJM:`Svalbard and Jan Mayen`,SWE:`Sweden`,CHE:`Switzerland`,SYR:`Syrian Arab Republic (the)`,TWN:`Taiwan (Province of China)`,TJK:`Tajikistan`,TZA:`Tanzania, the United Republic of`,THA:`Thailand`,TLS:`Timor-Leste`,TGO:`Togo`,TKL:`Tokelau`,TON:`Tonga`,TTO:`Trinidad and Tobago`,TUN:`Tunisia`,TUR:`Turkey`,TKM:`Turkmenistan`,TCA:`Turks and Caicos Islands (the)`,TUV:`Tuvalu`,UGA:`Uganda`,UKR:`Ukraine`,ARE:`United Arab Emirates (the)`,GBR:`United Kingdom of Great Britain and Northern Ireland (the)`,UMI:`United States Minor Outlying Islands (the)`,USA:`United States of America (the)`,URY:`Uruguay`,UZB:`Uzbekistan`,VUT:`Vanuatu`,VEN:`Venezuela (Bolivarian Republic of)`,VNM:`Viet Nam`,VGB:`Virgin Islands (British)`,VIR:`Virgin Islands (U.S.)`,WLF:`Wallis and Futuna`,ESH:`Western Sahara*`,YEM:`Yemen`,ZMB:`Zambia`,ZWE:`Zimbabwe`,ALA:`Åland Islands`,GBD:`British Overseas Territories Citizen`,GBN:`British National (Overseas)`,GBO:`British Overseas Citizen`,GBS:`British Subject`,GBP:`British Protected Person`,RKS:`Republic of Kosovo`,D:`Germany`,XXK:`Kosovo`,EUE:`European Union (EU)`,UNO:`United Nations Organization or one of its officials`,UNA:`United Nations specialized agency or one of its officials`,UNK:`Resident of Kosovo to whom a travel document has been issued by the United Nations Interim Administration Mission in Kosovo (UNMIK)`,XBA:`African Development Bank (ADB)`,XIM:`African Export-Import Bank (AFREXIM bank)`,XCC:`Caribbean Community or one of its emissaries (CARICOM)`,XCE:`Council of Europe`,XCO:`Common Market for Eastern and Southern Africa (COMESA)`,XEC:`Economic Community of West African States (ECOWAS)`,XPO:`International Criminal Police Organization (INTERPOL)`,XES:`Organization of Eastern Caribbean States (OECS)`,XOM:`Sovereign Military Order of Malta or one of its emissaries`,XDC:`Southern African Development Community`,XXA:`Stateless person, as defined in Article 1 of the 1954 Convention Relating to the Status of Stateless Persons`,XXB:`Refugee, as defined in Article 1 of the 1951 Convention Relating to the Status of Refugees as amended by the 1967 Protocol`,XXC:`Refugee, other than as defined under the code XXB above`,XXX:`Person of unspecified nationality, for whom issuing State does not consider it necessary to specify any of the codes XXA, XXB or XXC above, whatever that person’s status may be. This category may include a person who is neither stateless nor a refugee but who is of unknown nationality and legally residing in the State of issue.`,ANT:`Netherlands Antilles`,NTZ:`Neutral Zone`},Object.freeze(Mg)}));function Pg(e){if(typeof e==`string`&&(e=e.split(/[\r\n]+/)),!Array.isArray(e))throw TypeError(`input must be an array or string`);for(let t of e)if(!t.match(/[A-Z0-9<]+/))throw TypeError(`lines must be composed of only alphanumerical characters and "<"`);return e}var Fg=t((()=>{}));function Ig(e){if(e.length!==2)throw Error(`invalid document code: ${e}. must be 2 char length`);let[t,n]=e;return Lg(t,e),Rg(n,e),`${t}${n}`}function Lg(e,t){if(!zg.includes(e)){let e=new Intl.ListFormat(`en-US`,{style:`short`,type:`disjunction`});throw Error(`invalid document code: ${t}. First character must be ${e.format(zg)}`)}}function Rg(e,t){let n=Number.parseInt(e,10);if(Number.isNaN(n))throw Error(`invalid document code number: ${t}. Second character must be a number`)}var zg,Bg=t((()=>{zg=[`A`,`B`,`D`]}));function Vg(e){return e.replaceAll(/<+$/g,``).replaceAll(`<`,` `)}var Hg=t((()=>{}));function Ug(e){if(!e.match(/^[A-Z<]+$/))throw Error(`invalid text: ${e}. Must be only alphabetical with <`);return Vg(e)}var Wg=t((()=>{Hg()}));function Gg(e,t,n=/^[0-9A-Z<]+$/){let r=Vg(e);if(!n.test(e))throw new Kg(`invalid text: ${e}. Must match the following regular expression: ${n.toString()}`,r,t,t+r.length);return r}var Kg,qg=t((()=>{Hg(),Kg=class extends Error{value;start;end;constructor(e,t,n,r){super(e),this.value=t,this.start=n,this.end=r}}}));function Jg(e){return Qg[e]?Qg[e]:e}function Yg(e){return Zg[e]?Zg[e]:e}function Xg(e,t){let n=``,r=[],i=e.split(``);for(let[e,a]of i.entries())if(t.type===X.ALPHABETIC){let i=Yg(a);i!==a&&r.push({line:t.line,column:t.start+e,original:a,corrected:i}),n+=i}else if(t.type===X.NUMERIC){let i=Jg(a);i!==a&&r.push({line:t.line,column:t.start+e,original:a,corrected:i}),n+=i}else n+=a;return{correctedText:n,autocorrect:r}}var Zg,Qg,$g=t((()=>{r_(),Zg={8:`B`,6:`G`,0:`O`,1:`I`,5:`S`,2:`Z`},Qg={B:`8`,G:`6`,O:`0`,I:`1`,S:`5`,Z:`2`}}));function e_(e){n_(e,`label`,`string`),e.field!==null&&n_(e,`field`,`string`),n_(e,`line`,`number`),n_(e,`start`,`number`),n_(e,`end`,`number`),n_(e,`parser`,`function`);let t={line:e.line,start:e.start,end:e.end},n=[t];if(Array.isArray(e.related))for(let t of e.related)n_(t,`line`,`number`),n_(t,`start`,`number`),n_(t,`end`,`number`),n.push(t);return{parser:(t,r)=>{let i=t_(t,e),a=(e.related||[]).map(e=>t_(t,e)),o={label:e.label,field:e.field,value:null,valid:!1,ranges:n.map(e=>({...e,raw:t_(t,e)})),line:0,start:0,end:0,autocorrect:[]},s=o.ranges[0];o.line=s.line,o.start=s.start,o.end=s.end;try{let t=e.parser(i,...a);typeof t==`object`?(o.value=t.value,o.valid=t.valid??!0,t.start!==void 0&&(o.start=s.start+t.start),t.end!==void 0&&(o.end=s.start+t.end),t.valid===!1&&t.error&&(o.error=t.error)):(o.value=t,o.valid=!0)}catch(e){o.error=e.message,e instanceof Kg&&(o.value=e.value,o.start=s.start+e.start,o.end=s.start+e.end)}for(let e of r)e.line===o.line&&e.column>=o.start&&e.column<o.end&&o.autocorrect.push(e);return o},autocorrector:n=>({...Xg(t_(n,e),e),range:t})}}function t_(e,t){return e[t.line].slice(t.start,t.end)}function n_(e,t,n){if(typeof e[t]!==n)throw TypeError(`${String(t)} must be a ${n}`)}var X,r_=t((()=>{qg(),$g(),X={NUMERIC:`NUMERIC`,ALPHABETIC:`ALPHABETIC`,ALPHANUMERIC:`ALPHANUMERIC`}}));function i_(e){let t=0,n=[7,3,1];for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);i===60&&(i=0),i>=65&&(i-=55),i>=48&&(i-=48),i*=n[r%3],t+=i}return t%10}function a_(e,t){let n=i_(e),r=n===Number(t);return{valid:r,error:r?null:`invalid check digit: ${t}. Must be ${n}`}}var o_=t((()=>{}));function s_(e,...t){return{value:e,...a_(t.join(``),e)}}var c_=t((()=>{o_()}));function l_(e){if(!e.match(/^[0-9<]{4,6}$/))throw Error(`invalid date: ${e}`);let t=e.slice(2,4);if(t!==`<<`&&(Number.parseInt(t,10)<1||Number.parseInt(t,10)>12))throw Error(`invalid date month: ${t}`);if(e.length===6){let t=e.slice(4,6);if(t!==`<<`&&(Number.parseInt(t,10)<1||Number.parseInt(t,10)>31))throw Error(`invalid date day: ${t}`)}return e}var u_=t((()=>{}));function d_(e,t){return{value:e,...a_(t,e)}}var f_=t((()=>{o_()}));function p_(e,t,n){let r,i;if(t===`<`&&n){let t=n.indexOf(`<`);i=e+n.slice(0,t-1),r=i.length+1}else i=Vg(e),r=i.length;return{value:i,start:0,end:r}}var m_=t((()=>{Hg()}));function h_(e,t,n){if(e===`<`&&n){let e=n.indexOf(`<`),r=n.slice(0,e-1),i=n.charAt(e-1),a={value:i,start:e,end:e+1},o=a_(`${t}<${r}`,i);return o.valid||(o=a_(`${t}${r}`,i)),{...a,...o}}return{value:e,...a_(t,e)}}var g_=t((()=>{o_()}));function __(e){let t=e.replace(/.*?<{2}/,``),n=Gg(t,e.length-t.length,/^[A-Z<]+<*$/),r=e.length-t.length;return{value:n,start:r,end:r+n.length}}var v_=t((()=>{qg()}));function y_(e){let t=Gg(e.replace(/<{2}.*$/,``),0,/^[A-Z<]*<*$/);return{value:t,start:0,end:t.length}}var b_=t((()=>{qg()}));function x_(e){switch(e){case`M`:return`male`;case`F`:return`female`;case`<`:return`nonspecified`;default:throw Error(`invalid sex: ${e}. Must be M, F or <.`)}}var S_=t((()=>{}));function C_(e){if(e=Vg(e),!Mg[e])throw Error(`invalid state code: ${e}`);return{value:e,start:0,end:e.length}}var w_=t((()=>{Ng(),Hg()})),T_,E_,D_,O_,k_,A_,j_,M_,N_,P_,F_,I_,L_,R_,z_,B_=t((()=>{c_(),u_(),f_(),m_(),g_(),v_(),b_(),S_(),w_(),r_(),T_={label:`Document number`,field:`documentNumber`,parser:p_,type:X.ALPHANUMERIC},E_={label:`Document number check digit`,field:`documentNumberCheckDigit`,parser:h_,type:X.NUMERIC},D_={label:`Document code`,field:`documentCode`,type:X.ALPHABETIC},O_={label:`Document code`,field:`documentCode`,type:X.ALPHANUMERIC},k_={label:`Nationality`,field:`nationality`,parser:C_,type:X.ALPHABETIC},A_={label:`Sex`,field:`sex`,parser:x_,type:X.ALPHABETIC},j_={label:`Expiration date`,field:`expirationDate`,parser:l_,type:X.NUMERIC},M_={label:`Expiration date check digit`,field:`expirationDateCheckDigit`,parser:d_,type:X.NUMERIC},N_={label:`Composite check digit`,field:`compositeCheckDigit`,parser:s_,type:X.NUMERIC},P_={label:`Birth date`,field:`birthDate`,parser:l_,type:X.NUMERIC},F_={label:`Birth date check digit`,field:`birthDateCheckDigit`,parser:d_,type:X.NUMERIC},I_={label:`Issue date`,field:`issueDate`,parser:l_,type:X.NUMERIC},L_={label:`First name`,field:`firstName`,parser:__,type:X.ALPHABETIC},R_={label:`Last name`,field:`lastName`,parser:y_,type:X.ALPHABETIC},z_={label:`Issuing state`,field:`issuingState`,parser:C_,type:X.ALPHABETIC}})),V_,H_,U_=t((()=>{Bg(),Wg(),r_(),B_(),V_=[{...O_,line:0,start:0,end:2,parser:Ig},{...z_,line:0,start:2,end:5},{...T_,line:0,start:5,end:14},{...E_,line:0,start:14,end:15,related:[{line:0,start:0,end:14}]},{...j_,line:0,start:15,end:21},{...R_,line:0,start:21,end:29,parser:Ug},{...N_,line:0,start:29,end:30,related:[{line:0,start:0,end:29}]}],H_=V_.map(e_)}));function W_(e,t){switch(e){case`TD1`:case`TD2`:case`TD3`:case`FRENCH_DRIVING_LICENSE`:return G_(t.documentNumber);case`FRENCH_NATIONAL_ID`:return G_(t.issueDate,t.administrativeCode2,t.documentNumber);case`SWISS_DRIVING_LICENSE`:return G_(t.pinCode,t.versionNumber);default:K_(e)}}function G_(...e){let t=``;for(let n of e){if(!n)return null;t+=n}return t}function K_(e){throw Error(`unrecognized format: ${e}`)}var q_=t((()=>{}));function J_(e,t,n){let r=[];for(let[i,{parser:a}]of t.entries())r.push(a(e,n[i]));return r}function Y_(e){let t={},n=!0;for(let r of e)r.valid||(n=!1),r.field&&(t[r.field]=r.valid?r.value:null);return{fields:t,allValid:n}}function X_(e,t,n){let r=e.slice(),i=[];if(n)for(let{autocorrector:n}of t){let{autocorrect:t,correctedText:a,range:o}=n(e);i.push(t);let s=r[o.line];r[o.line]=s.slice(0,o.start)+a+s.slice(o.end)}else i=Array(t.length).fill([]);return{corrected:r,autocorrectArray:i}}function Z_(e,t,n,r){let{autocorrect:i=!1}=r,{corrected:a,autocorrectArray:o}=X_(t,n,i),s=J_(a,n,o),c=Y_(s);return{format:e,details:s,fields:c.fields,documentNumber:W_(e,c.fields),valid:c.allValid}}var Q_=t((()=>{q_()}));function $_(e,t){if(e.length!==1)throw Error(`invalid number of lines: ${e.length}: Must be 1 for ${ev}`);if(e[0].length!==30)throw Error(`invalid number of characters for line 1: ${e[0].length}. Must be 30 for ${ev}`);return Z_(ev,e,H_,t)}var ev,tv=t((()=>{jg(),U_(),Q_(),ev=Ag.FRENCH_DRIVING_LICENSE}));function nv(e){let t=e.charAt(0);if(t!==`A`&&t!==`C`&&t!==`I`)throw Error(`invalid document code: ${e}. First character must be A, C or I`);let n=e.charAt(1);if(n===`V`)throw Error(`invalid document code: ${e}. Second character may not be V`);return n===`<`?{value:t,start:0,end:1}:e}var rv=t((()=>{}));function iv(e){let t=Gg(e,0);return{value:t,start:0,end:t.length}}var av=t((()=>{qg()})),ov,sv,cv=t((()=>{Wg(),rv(),av(),r_(),B_(),ov=[{...D_,line:0,start:0,end:2,parser:nv},{...z_,line:0,start:2,end:5},{...R_,line:0,start:5,end:30,parser:Ug},{label:`Administrative code`,field:`administrativeCode`,line:0,start:30,end:36,parser:iv},{...I_,line:1,start:0,end:4},{label:`Administrative code 2`,field:`administrativeCode2`,line:1,start:4,end:7,parser:iv},{...T_,line:1,start:7,end:12},{...E_,line:1,start:12,end:13,related:[{line:1,start:0,end:12}]},{...L_,line:1,start:13,end:27,parser:Ug},{...P_,line:1,start:27,end:33},{...F_,line:1,start:33,end:34,related:[{line:1,start:27,end:33}]},{...A_,line:1,start:34,end:35},{...N_,line:1,start:35,end:36,related:[{line:0,start:0,end:36},{line:1,start:0,end:35}]}],sv=ov.map(e_)}));function lv(e,t){if(e.length!==2)throw Error(`invalid number of lines: ${e.length}: Must be 2 for ${uv}`);for(let[t,n]of e.entries())if(n.length!==36)throw Error(`invalid number of characters for line ${t+1}: ${n.length}. Must be 36 for ${uv}`);return Z_(uv,e,sv,t)}var uv,dv=t((()=>{jg(),cv(),Q_(),uv=Ag.FRENCH_NATIONAL_ID}));function fv(e){if(!e.match(/^[0-9]+$/))throw Error(`invalid number: ${e}`);return e}var pv=t((()=>{}));function mv(e){if(!e.match(/^<*$/))throw Error(`invalid separator: ${e}. Must be composed only of "<"`);return e}var hv=t((()=>{}));function gv(e){if(e!==`FA`)throw Error(`invalid document code: ${e}. Must be FA`);return e}var _v=t((()=>{}));function vv(e){switch(e){case`D`:case`F`:case`I`:case`R`:return e;default:throw Error(`invalid languageCode code: ${e}. Must be D, F, I or R`)}}var yv=t((()=>{}));function bv(e){let t=e.slice(0,3),n=e.slice(3,6),r=e.charAt(6),i=e.slice(7);if(!t.match(/^[A-Z0-9]{3}$/))throw Error(`invalid document number: ${e}. Must start with three alphanumeric digits`);if(!n.match(/^[0-9]{3}$/))throw Error(`invalid document number: ${e}. Must have numeric digits in positions 4, 5 and 6`);if(i!==`<<`)throw Error(`invalid document number: ${e}. Must end with <<`);return vv(r),{value:e.slice(0,7),start:0,end:7}}var xv=t((()=>{yv()}));function Sv(e){if(e!==`CHE`&&e!==`LIE`)throw Error(`invalid state code: ${e}. Must be CHE or LIE`);return e}var Cv=t((()=>{})),wv,Tv,Ev=t((()=>{pv(),hv(),_v(),xv(),Cv(),yv(),r_(),B_(),wv=[{...T_,line:0,start:0,end:9,parser:bv},{label:`Language code`,field:`languageCode`,line:0,start:6,end:7,parser:vv,type:X.ALPHABETIC},{...D_,line:1,start:0,end:2,parser:gv},{...z_,line:1,start:2,end:5,parser:Sv},{label:`PIN code`,field:`pinCode`,line:1,start:5,end:14,parser:fv,type:X.NUMERIC},{label:`Version number`,field:`versionNumber`,line:1,start:14,end:17,parser:fv,type:X.NUMERIC},{label:`Separator 1`,field:null,line:1,start:17,end:19,parser:mv},{...P_,line:1,start:19,end:25},{label:`Separator 2`,field:null,line:1,start:25,end:30,parser:mv},{...R_,line:2,start:0,end:30},{...L_,line:2,start:0,end:30}],Tv=wv.map(e_)}));function Dv(e,t){if(e.length!==3)throw Error(`invalid number of lines: ${e.length}: Must be 3 for ${Ov}`);if(e[0].length!==9)throw Error(`invalid number of characters for line 1: ${e[0].length}. Must be 9 for ${Ov}`);if(e[1].length!==30)throw Error(`invalid number of characters for line 2: ${e[1].length}. Must be 30 for ${Ov}`);if(e[2].length!==30)throw Error(`invalid number of characters for line 3: ${e[2].length}. Must be 30 for ${Ov}`);return Z_(Ov,e,Tv,t)}var Ov,kv=t((()=>{jg(),Q_(),Ev(),Ov=Ag.SWISS_DRIVING_LICENSE}));function Av(e){let t=Gg(e,0);return{value:t,start:0,end:t.length}}var jv=t((()=>{qg()})),Mv,Nv,Pv=t((()=>{rv(),jv(),av(),r_(),B_(),Mv=[{...D_,line:0,start:0,end:2,parser:nv},{...z_,line:0,start:2,end:5},{...T_,line:0,start:5,end:14,related:[{line:0,start:14,end:15},{line:0,start:15,end:30}]},{...E_,line:0,start:14,end:15,related:[{line:0,start:5,end:14},{line:0,start:15,end:30}]},{label:`Optional field 1`,field:`optional1`,line:0,start:15,end:30,related:[],parser:Av},{...P_,start:0,end:6,line:1},{...F_,line:1,start:6,end:7,related:[{line:1,start:0,end:6}]},{...A_,line:1,start:7,end:8},{...j_,line:1,start:8,end:14},{...M_,line:1,start:14,end:15,related:[{line:1,start:8,end:14}]},{...k_,line:1,start:15,end:18},{label:`Optional field 2`,field:`optional2`,line:1,start:18,end:29,parser:iv},{...N_,line:1,start:29,end:30,related:[{line:0,start:5,end:30},{line:1,start:0,end:7},{line:1,start:8,end:15},{line:1,start:18,end:29}]},{...R_,line:2,start:0,end:30},{...L_,line:2,start:0,end:30}],Nv=Mv.map(e_)}));function Fv(e,t){if(e.length!==3)throw Error(`invalid number of lines: ${e.length}: Must be 3 for ${Iv}`);for(let[t,n]of e.entries())if(n.length!==30)throw Error(`invalid number of characters for line ${t+1}: ${n.length}. Must be 30 for ${Iv}`);return Z_(Iv,e,Nv,t)}var Iv,Lv=t((()=>{jg(),Q_(),Pv(),Iv=Ag.TD1})),Rv,zv,Bv=t((()=>{rv(),av(),r_(),B_(),Rv=[{...D_,line:0,start:0,end:2,parser:nv},{...z_,line:0,start:2,end:5},{...R_,line:0,start:5,end:36},{...L_,line:0,start:5,end:36},{...T_,line:1,start:0,end:9,related:[{line:1,start:9,end:10},{line:1,start:28,end:35}]},{...E_,line:1,start:9,end:10,related:[{line:1,start:0,end:9},{line:1,start:28,end:35}]},{...k_,line:1,start:10,end:13},{...P_,line:1,start:13,end:19},{...F_,line:1,start:19,end:20,related:[{line:1,start:13,end:19}]},{...A_,line:1,start:20,end:21},{...j_,line:1,start:21,end:27},{...M_,line:1,start:27,end:28,related:[{line:1,start:21,end:27}]},{label:`Optional field`,field:`optional`,line:1,start:28,end:35,parser:iv},{...N_,line:1,start:35,end:36,related:[{line:1,start:0,end:10},{line:1,start:13,end:20},{line:1,start:21,end:35}]}],zv=Rv.map(e_)}));function Vv(e,t){if(e.length!==2)throw Error(`invalid number of lines: ${e.length}: Must be 2 for ${Hv}`);for(let[t,n]of e.entries())if(n.length!==36)throw Error(`invalid number of characters for line ${t+1}: ${n.length}. Must be 36 for TD2`);return Z_(Hv,e,zv,t)}var Hv,Uv=t((()=>{jg(),Q_(),Bv(),Hv=Ag.TD2}));function Wv(e){let t=e.charAt(0);if(t!==`P`)throw Error(`invalid document code: ${e}. First character must be P`);let n=e.charAt(1);if(!n.match(/[A-Z<]/))throw Error(`invalid document code: ${e}. Second character must be a letter or <`);return n===`<`?{value:t,start:0,end:1}:e}var Gv=t((()=>{}));function Kv(e){let t=Gg(e,0,/^[A-Z0-9<]+<*$/);return{value:t,start:0,end:t.length}}var qv=t((()=>{qg()}));function Jv(e,t){return Vg(t)===``?e!==`<`&&e!==`0`?{value:e,valid:!1,error:`invalid check digit ${e}: must be 0 or <`}:e:{value:e,...a_(t,e)}}var Yv=t((()=>{o_(),Hg()})),Xv,Zv,Qv=t((()=>{Gv(),qv(),Yv(),r_(),B_(),Xv=[{...D_,line:0,start:0,end:2,parser:Wv},{...z_,line:0,start:2,end:5},{...R_,line:0,start:5,end:44},{...L_,line:0,start:5,end:44},{...T_,line:1,start:0,end:9},{...E_,line:1,start:9,end:10,related:[{line:1,start:0,end:9}]},{...k_,line:1,start:10,end:13},{...P_,line:1,start:13,end:19},{...F_,line:1,start:19,end:20,related:[{line:1,start:13,end:19}]},{...A_,line:1,start:20,end:21},{...j_,line:1,start:21,end:27},{...M_,line:1,start:27,end:28,related:[{line:1,start:21,end:27}]},{label:`Personal number`,field:`personalNumber`,line:1,start:28,end:42,parser:Kv},{label:`Personal number check digit`,field:`personalNumberCheckDigit`,line:1,start:42,end:43,related:[{line:1,start:28,end:42}],parser:Jv},{...N_,line:1,start:43,end:44,related:[{line:1,start:0,end:10},{line:1,start:13,end:20},{line:1,start:21,end:43}]}],Zv=Xv.map(e_)}));function $v(e,t){if(e.length!==2)throw Error(`invalid number of lines: ${e.length}: Must be 2 for ${ey}`);for(let[t,n]of e.entries())if(n.length!==44)throw Error(`invalid number of characters for line ${t+1}: ${n.length}. Must be 44 for TD3`);return Z_(ey,e,Zv,t)}var ey,ty=t((()=>{jg(),Q_(),Qv(),ey=Ag.TD3})),ny,ry=t((()=>{tv(),dv(),kv(),Lv(),Uv(),ty(),ny={td1:Fv,td2:Vv,td3:$v,swissDrivingLicense:Dv,frenchNationalId:lv,frenchDrivingLicense:$_}}));function iy(e,t={}){let n=Pg(e);switch(n.length){case 1:switch(n[0].length){case 30:return ny.frenchDrivingLicense(n,t);default:throw Error(`unrecognized document format. First line of input must have 30 (French Driving License) characters and it has a length of ${n[0].length}`)}case 2:case 3:switch(n[0].length){case 30:return ny.td1(n,t);case 36:return n[0].slice(30,35).match(/[0-9]/)||n[0].match(/^IDFRA/)?ny.frenchNationalId(n,t):ny.td2(n,t);case 44:return ny.td3(n,t);case 9:return ny.swissDrivingLicense(n,t);default:throw Error(`unrecognized document format. First line of input must have 30 (TD1), 36 (TD2 or French National Id), 44 (TD3) or 9 (Swiss Driving License) characters and it has a length of ${n[0].length}`)}default:throw Error(`unrecognized document format. Input must have one, two or three lines, found ${n.length}`)}}var ay=t((()=>{Fg(),ry()})),oy=t((()=>{kg(),jg(),Ng(),ay()})),sy,cy,ly=t((()=>{dd(),sy=cd(),cy=({value:e,country:t,kind:n,source:r,reference:i=new Date})=>{if(!e)return null;if(r===`AAMVA`){if(!/^\d{8}$/u.test(e))return null;let n;if(t===`CAN`)n=`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`;else if(t===`USA`)n=`${e.slice(4,8)}-${e.slice(0,2)}-${e.slice(2,4)}`;else return null;return sy.safeParse(n).success?n:null}if(!/^\d{6}$/u.test(e))return null;let a=i.toISOString().slice(0,10),o=Math.floor(i.getUTCFullYear()/100)*100,s=[o-100,o,o+100].map(t=>`${String(t+Number(e.slice(0,2))).padStart(4,`0`)}-${e.slice(2,4)}-${e.slice(4,6)}`).filter(e=>sy.safeParse(e).success);if(n===`birth`||n===`issue`)return s.filter(e=>e<=a).sort().at(-1)??null;let c=Date.parse(a);return s.sort((e,t)=>Math.abs(Date.parse(e)-c)-Math.abs(Date.parse(t)-c)||t.localeCompare(e))[0]??null}})),Z,uy,dy,fy=t((()=>{oy(),W(),bg(),ly(),Z=e=>(e?e.replaceAll(`<`,` `).trim():``)||null,uy=e=>{if(!e)return null;try{let t=iy(e.split(`
|
|
62
|
-
`)),n=t.fields,r=n.documentCode??``,i=t.format.includes(`DRIVING_LICENSE`)?`DRV`:r.startsWith(`P`)?`PASSPORT`:r.startsWith(`V`)?`VISA`:/^[IAC]/u.test(r)?`ID`:null,a=[n.optional,n.optional1,n.optional2].map(Z).filter(Boolean).join(` `);return
|
|
63
|
-
`),aamva_version:null}})}catch{return null}},
|
|
58
|
+
`).trim(),J_=({pixels:e,runtime:t})=>{let n=Math.max(32,Math.ceil(e.width/32)*32),r=Math.max(32,Math.ceil(e.height/32)*32),i=new Float32Array(3*n*r),a=[.485,.456,.406],o=[.229,.224,.225];for(let e=0;e<3;e+=1)i.fill((1-(a[e]??0))/(o[e]??1),e*n*r,(e+1)*n*r);for(let t=0;t<e.height;t+=1)for(let s=0;s<e.width;s+=1){let c=(t*e.width+s)*4,l=t*n+s;for(let t=0;t<3;t+=1){let s=(e.data[c+t]??0)/255;i[t*n*r+l]=(s-(a[t]??0))/(o[t]??1)}}return{height:r,tensor:new t.Tensor(`float32`,i,[1,3,r,n]),width:n}},Y_=({height:e,scores:t,width:n})=>{let r=new Uint8Array(n*e),i=[],a=new Int32Array(n*e);for(let o=0;o<t.length;o+=1){if(r[o]||(t[o]??0)<H_)continue;let s=0,c=1,l=o%n,u=l,d=Math.floor(o/n),f=d,p=0,m=0;for(a[0]=o,r[o]=1;s<c;){let i=a[s]??0;s+=1;let o=i%n,h=Math.floor(i/n);l=Math.min(l,o),u=Math.max(u,o),d=Math.min(d,h),f=Math.max(f,h),p+=t[i]??0,m+=1;for(let i=-1;i<=1;i+=1)for(let s=-1;s<=1;s+=1){let l=o+s,u=h+i;if(l<0||l>=n||u<0||u>=e)continue;let d=u*n+l;r[d]||(t[d]??0)<H_||(r[d]=1,a[c]=d,c+=1)}}let h=u-l+1,g=f-d+1;if(m<W_||h<G_||g<G_||p/m<U_)continue;let _=h*.25,v=g*.35;i.push({bottom:f+1+v,left:l-_,right:u+1+_,score:p/m,top:d-v})}return i},X_=({boxes:e})=>e.sort((e,t)=>{let n=e.bottom-e.top,r=t.bottom-t.top,i=Math.max(n,r)*.6;return Math.abs(e.top-t.top)<=i?e.left-t.left:e.top-t.top}),Z_=async({pixels:e,runtime:t,session:n})=>{let r=J_({pixels:e,runtime:t}),i=await K_({session:n,tensor:r.tensor});try{let e=Number(i.dims.at(-2)),t=Number(i.dims.at(-1)),n=Y_({height:e,scores:i.data,width:t}),a=r.width/t,o=r.height/e,s=n.map(({bottom:e,left:t,right:n,top:r})=>({bottom:e*o,left:t*a,right:n*a,top:r*o}));return X_({boxes:s})}finally{i.dispose()}},Q_=({pixels:e,runtime:t,model:n})=>{let r=n.recognitionHeight,i=Math.max(1,Math.round(e.width/e.height*r)),a=Math.max(32,Math.ceil(i/32)*32),o=I_({height:r,image:e,width:i}),s=new Float32Array(3*a*r);for(let e=0;e<r;e+=1)for(let t=0;t<i;t+=1){let c=(e*i+t)*4,l=e*a+t,u=o.data[c],d=o.data[c+1],f=o.data[c+2],p=u*.299+d*.587+f*.114;s[l]=((n.channels===`grayscale`?p:f)/255-.5)/.5,s[a*r+l]=((n.channels===`grayscale`?p:d)/255-.5)/.5,s[2*a*r+l]=((n.channels===`grayscale`?p:u)/255-.5)/.5}return new t.Tensor(`float32`,s,[1,3,r,a])},$_=({text:e})=>{let t=[],n=``;for(let r of e)/[a-zA-Z0-9 :*./%+-]/u.test(r)?n+=r:(n&&t.push(n),t.push(r),n=``);return n&&t.push(n),t.reverse().join(``)},ev=({dictionary:e,output:t,reverse:n})=>{let r=Number(t.dims.at(-1)),i=Number(t.dims.at(-2)),a=e[0]===``?[...e]:[``,...e];if(a.length===r-1&&a.push(` `),a.length!==r)throw Error(j.OCR_DICTIONARY_MISMATCH);let o=-1,s=``;for(let e=0;e<i;e+=1){let n=e*r,i=0,c=t.data[n]??-1/0;for(let e=1;e<r;e+=1){let r=t.data[n+e]??-1/0;r<=c||(i=e,c=r)}i!==0&&i!==o&&(s+=a[i]??``),o=i}let c=s.trim();return n?$_({text:c}):c},tv=({lines:e})=>e.filter((t,n)=>{let r=t.box.width*t.box.height;return!e.some((e,i)=>{if(i===n||!e.text.endsWith(t.text))return!1;let a=e.box.width*e.box.height;if(a<r||e.text.length===t.text.length&&a===r&&i>n)return!1;let o=Math.max(0,Math.min(t.box.x+t.box.width,e.box.x+e.box.width)-Math.max(t.box.x,e.box.x)),s=Math.max(0,Math.min(t.box.y+t.box.height,e.box.y+e.box.height)-Math.max(t.box.y,e.box.y));return r>0&&o*s>=r*.95})}),nv=async({adapter:e,model:t})=>{let[n,r,i]=await Promise.all([e.session(t.detection),e.session(t.recognition),e.load(t.dictionary)]),a=new TextDecoder().decode(i).replace(/\r/gu,``).split(`
|
|
59
|
+
`);for(;a.at(-1)===``;)a.pop();return{model:t.id,assets:[t.detection,t.recognition,t.dictionary],recognize:async({image:i})=>{let o=await e.decode(i),s=await Z_({pixels:o,runtime:e.runtime,session:n}),c=[];for(let n of s){let i=F_({box:n,image:o}),s=Q_({pixels:i,runtime:e.runtime,model:t}),l=await K_({session:r,tensor:s}),u;try{u=ev({dictionary:a,output:l,reverse:t.reverseArabic})}finally{l.dispose()}if(!u)continue;let d={height:Math.max(0,Math.min(o.height,n.bottom)-Math.max(0,n.top)),width:Math.max(0,Math.min(o.width,n.right)-Math.max(0,n.left)),x:Math.max(0,n.left),y:Math.max(0,n.top)};c.push({angle:0,box:d,confidence:null,text:u,words:[{box:d,confidence:null,text:u}]})}let l=tv({lines:c}),u=q_({text:l.map(e=>e.text).join(`
|
|
60
|
+
`)});return{engine:t.id,height:o.height,lines:l,text:u,width:o.width}}}}})),iv,av,ov,sv,cv,lv,uv,dv=t((()=>{W(),iv=`odm.ort`,av={tiny:{id:`tiny`,detection:`od.ort`,recognition:`or.ort`,dictionary:`ot.txt`,recognitionHeight:48,channels:`grayscale`,reverseArabic:!1},small:{id:`small`,detection:`ods.ort`,recognition:`ors.ort`,dictionary:`ots.txt`,recognitionHeight:48,channels:`grayscale`,reverseArabic:!1},japanese:{id:`japanese`,detection:iv,recognition:`orj.ort`,dictionary:`otj.txt`,recognitionHeight:48,channels:`bgr`,reverseArabic:!1},"chinese-simplified":{id:`chinese-simplified`,detection:iv,recognition:`orcs.ort`,dictionary:`otcs.txt`,recognitionHeight:48,channels:`bgr`,reverseArabic:!1},"chinese-traditional":{id:`chinese-traditional`,detection:iv,recognition:`orct.ort`,dictionary:`otct.txt`,recognitionHeight:48,channels:`bgr`,reverseArabic:!1},cyrillic:{id:`cyrillic`,detection:iv,recognition:`orc.ort`,dictionary:`otc.txt`,recognitionHeight:48,channels:`bgr`,reverseArabic:!1},arabic:{id:`arabic`,detection:iv,recognition:`ora.ort`,dictionary:`ota.txt`,recognitionHeight:48,channels:`bgr`,reverseArabic:!0}},ov={eng:`eng`,en:`eng`,english:`eng`,latin:`latin`,deu:`latin`,de:`latin`,fra:`latin`,fr:`latin`,ita:`latin`,it:`latin`,por:`latin`,pt:`latin`,spa:`latin`,es:`latin`,jpn:`jpn`,ja:`jpn`,japan:`jpn`,chi_sim:`chi_sim`,zh:`chi_sim`,"zh-cn":`chi_sim`,"zh-hans":`chi_sim`,chi_tra:`chi_tra`,ch:`chi_tra`,"zh-tw":`chi_tra`,"zh-hant":`chi_tra`,rus:`rus`,ru:`rus`,ara:`ara`,ar:`ara`},sv=({language:e})=>{let t=ov[e.trim().toLowerCase()];if(!t)throw Error(j.OCR_LANGUAGE_UNSUPPORTED);return t},cv={eng:`tiny`,latin:`tiny`,jpn:`japanese`,chi_sim:`chinese-simplified`,chi_tra:`chinese-traditional`,rus:`cyrillic`,ara:`arabic`},lv=({language:e,engine:t=`auto`})=>{let n=sv({language:e}),r=t===`auto`?cv[n]:t,i=av[r];if(!i)throw Error(j.OCR_MODEL_UNSUPPORTED);return i},uv=({language:e,engine:t})=>{let n=lv({environment:`browser`,language:e,engine:t});return[n.detection,n.recognition,n.dictionary]}})),fv,pv,mv=t((()=>{W(),rv(),dv(),fv=({adapter:e,environment:t})=>{let n=new Map,r=async r=>{if(r.environment!==t)throw Error(j.OCR_ENVIRONMENT_MISMATCH);let i=lv(r),a=n.get(i.id);a||(a=nv({adapter:e,model:i}),n.set(i.id,a));try{return await a}catch(e){throw n.get(i.id)===a&&n.delete(i.id),e}};return{getOcr:r,ocr:async({image:e,language:n=`eng`,engine:i})=>await(await r({environment:t,language:n,engine:i})).recognize({image:e})}},pv=async({cache:e,key:t,load:n})=>{let r=e.get(t);r||(r=n(),e.set(t,r));try{return await r}catch(n){throw e.get(t)===r&&e.delete(t),n}}})),hv,gv,_v,vv=t((()=>{hv={high:`fdh.ort`,standard:`fd.ort`,low:`fdl.ort`},gv={ageGender:`fa.ort`},_v={standard:`flv.ort`,wide:`flw.ort`}})),yv,bv,xv,Sv,Cv,wv,Tv,Ev,Dv,Ov,kv=t((()=>{W(),P_(),fd(),vv(),yv=new Map,bv=!1,Sv=zm,Cv=()=>[`wasm`],wv=()=>globalThis.crossOriginIsolated&&!!globalThis.SharedArrayBuffer,Tv=()=>Math.min(Math.max(Math.floor((navigator.hardwareConcurrency||1)/2),1),4),Ev=()=>({inference:`CPU (WASM SIMD)`,isolation:globalThis.crossOriginIsolated?`cross origin isolated`:`not isolated`,models:`ORT fixed optimized`,threading:wv()?`multi thread (auto, up to ${Tv()})`:`single thread`}),Dv=async()=>{if(bv)return Sv;Sv.env.wasm.numThreads=+!wv();let[e,t]=await Promise.all([dd({filename:`ort-wasm-simd-threaded.mjs`}),ud({filename:`ort-wasm-simd-threaded.wasm`})]);return Sv.env.wasm.wasmPaths={mjs:e},Sv.env.wasm.wasmBinary=t,bv=!0,Sv},Ov=async({filename:e})=>{let t=yv.get(e);try{return t||(t=(async()=>{let t=await Dv(),n=await ud({filename:e}),r=await t.InferenceSession.create(n,{executionProviders:Cv(),extra:{session:{load_model_format:`ORT`}},graphOptimizationLevel:`disabled`});return{inputNames:r.inputNames,outputNames:r.outputNames,run:async e=>{let t=xv,n=Promise.withResolvers();xv=n.promise,await t;try{return await r.run(e)}finally{n.resolve(),xv===n.promise&&(xv=void 0)}}}})(),yv.set(e,t)),await t}catch(n){throw t&&yv.get(e)===t&&yv.delete(e),Error(j.MODEL_LOAD_FAILED,{cause:n})}}})),Av,jv=t((()=>{Av=({canvas:e})=>{e.width=1,e.height=1}})),Mv,Nv=t((()=>{W(),jv(),Mv=({runtime:e})=>({frame:t,height:n=t.height,width:r=t.width,sourceRect:i})=>{let a=e.createCanvas(r,n);try{let e=a.getContext(`2d`,{willReadFrequently:!0});if(!e)throw Error(j.IMAGE_PROCESSING_FAILED);return i?e.drawImage(t,i.x,i.y,i.width,i.height,0,0,r,n):e.drawImage(t,0,0,r,n),{data:e.getImageData(0,0,r,n).data,height:n,width:r}}finally{Av({canvas:a})}}})),Pv,Fv,Iv,Lv,Rv=t((()=>{W(),P_(),kv(),Nv(),Pv=zm,Fv=(async(...e)=>{try{return await createImageBitmap(...e)}catch(e){throw Error(j.IMAGE_DECODE_FAILED,{cause:e})}}),Iv={environment:`browser`,createCanvas:(e,t)=>new OffscreenCanvas(e,t),createImageData:(e,t)=>new ImageData(e,t),createImageBitmap:Fv,session:Ov,tensor:(e,t,n)=>new Pv.Tensor(e,t,n)},Lv=Mv({runtime:Iv})})),zv,Bv,Vv,Hv,Uv=t((()=>{W(),P_(),fd(),mv(),kv(),Rv(),zv=new Map,Bv={decode:async e=>{if(!(e instanceof Blob)&&!(e instanceof Uint8Array))return e;let t=e instanceof Uint8Array?new Blob([e]):e,n=await Iv.createImageBitmap(t);try{return Lv({frame:n})}finally{n.close()}},load:async e=>await pv({cache:zv,key:e,load:async()=>{try{return await ud({filename:e})}catch(e){throw Error(j.MODEL_LOAD_FAILED,{cause:e})}}}),session:async e=>await Ov({filename:e}),runtime:zm},{getOcr:Vv,ocr:Hv}=fv({adapter:Bv,environment:`browser`})})),Wv,Gv,Kv,qv,Jv,Yv,Xv,Zv,Qv,$v=t((()=>{Wv=[`PASSPORT`,`PASSAPORTO`,`PASSEPORT`,`PASAPORTE`,`REISEPASS`,`PASZPORT`],Gv=[`VISA`],Kv=[`REPUBBLICA ITALIANA`,`IDENTITY CARD`,`IDENTIFICATION CARD`,`NATIONAL ID`,`CARTA D'IDENTITÀ`,`CARTA D'IDENTITA`,`CARTA DI IDENTITÀ`,`CARTA DI IDENTITA`,`ID CARD`,`CARTE NATIONALE`,`CARTE D’IDENTITÉ`,`CARTE D'IDENTITÉ`,`PERSONALAUSWEIS`,`DOCUMENTO NACIONAL DE IDENTIDAD`,`BILHETE DE IDENTIDADE`,`CARTÃO DE CIDADÃO`],qv=[`PATENTE`,`PERMIS DE CONDUIRE`,`PERMISO DE CONDUCCIÓN`,`PERMIS DE CONDUIR`,`FÜHRERSCHEIN`,`FAHRERLAUBNIS`,`DRIVING LICENCE`,`DRIVING LICENSE`,`CONDUÇÃO`,`ŘIDIČSKÝ PRŮKAZ`,`VOZNIŠKO DOVOLJENJE`,`VOZNE DOVOLENIE`,`UDSTEDT KØREKORT`,`KÖRKORT`,`AJOKORTTI`,`JUHILUBA`,`VADĪTĀJA APLIECĪBA`,`VAIRUOTOJO PAŽYMĖJIMAS`,`VEZETŐI ENGEDÉLY`],Jv=({text:e})=>e.toUpperCase().normalize(`NFKC`),Yv=({labels:e,text:t})=>{let n=t.normalize(`NFKD`).replace(/[^\p{L}\p{N}]/gu,``);return e.some(e=>n.includes(e.normalize(`NFKD`).replace(/[^\p{L}\p{N}]/gu,``)))},Xv=({data:e,height:t,predicate:n,width:r,xEnd:i=1,xStart:a=0,yEnd:o=1,yStart:s=0})=>{let c=0,l=0,u=Math.floor(r*a),d=Math.ceil(r*i),f=Math.floor(t*s),p=Math.ceil(t*o);for(let t=f;t<p;t+=4)for(let i=u;i<d;i+=4){let a=(t*r+i)*4;n(e[a]??0,e[a+1]??0,e[a+2]??0)&&(c+=1),l+=1}return l?c/l:0},Zv=({image:e,text:t,codes:n})=>{let r=Jv({text:t}),i=n.some(e=>e.type===`mrz`&&e.payload.document.type===`PASSPORT`&&e.code.startsWith(`P<`)),a=n.some(e=>e.type===`mrz`&&e.payload.document.type===`VISA`),o=n.some(e=>e.type===`aamva`),s=n.some(e=>e.type===`mrz`&&e.payload.document.type===`ID`);if(a)return{document:`visa`,europeanDrivingLicense:!1};if(i)return{document:`passport`,europeanDrivingLicense:!1};if(o)return{document:`driving_license`,europeanDrivingLicense:!1};if(s)return{document:`id`,europeanDrivingLicense:!1};if(Yv({labels:Gv,text:r}))return{document:`visa`,europeanDrivingLicense:!1};if(Yv({labels:Wv,text:r}))return{document:`passport`,europeanDrivingLicense:!1};if(Yv({labels:qv,text:r})){let t=Math.max(e.width,e.height)/Math.min(e.width,e.height),n=Math.abs(t-86/54)/(86/54)<=.05+2**-52,r=Xv({...e,predicate:(e,t,n)=>e>80&&e>t*1.12&&n>t*1.04}),i=(e,t,n)=>n>45&&n>e*1.08&&n>t*1.04,a=Xv({...e,predicate:i,xEnd:.35,yEnd:.4}),o=Xv({...e,predicate:i,xStart:.65,yEnd:.4});return{document:`driving_license`,europeanDrivingLicense:n&&r>=.008&&Math.max(a,o)>=.008}}return Yv({labels:Kv,text:r})?{document:`id`,europeanDrivingLicense:!1}:null},Qv=({lines:e,width:t,height:n})=>e.some(e=>/^13\s*\./u.test(e.text.trim())&&e.box.x<t*.35&&e.box.y<n*.4)})),ey,ty,ny,ry,iy,ay,oy,sy=t((()=>{ey=.24,ty=.7,ny=.16,ry=({data:e,height:t,text:n,width:r})=>{let i=new Uint8Array(r*t);for(let t=0;t<i.length;t+=1){let n=t*4;i[t]=Math.round((e[n]??0)*.299+(e[n+1]??0)*.587+(e[n+2]??0)*.114)}let a=[];for(let e=0;e<t;e+=1)for(let n=0;n<r;n+=1){let o=e*r+n,s=i[o]??0;n+1<r&&a.push(s>=(i[o+1]??0)),e+1<t&&a.push(s>=(i[o+r]??0))}let o=new Uint8Array(Math.ceil(a.length/8));for(let[e,t]of a.entries())t&&(o[Math.floor(e/8)]|=1<<e%8);let s=[];for(let e=0;e<8;e+=1)for(let n=0;n<8;n+=1){let a=0,o=0;for(let s=Math.floor(e*t/8);s<Math.floor((e+1)*t/8);s+=1)for(let e=Math.floor(n*r/8);e<Math.floor((n+1)*r/8);e+=1)a+=i[s*r+e]??0,o+=1;s.push(o?a/o:0)}let c=s.reduce((e,t)=>e+t,0)/s.length,l=new Uint8Array(Math.ceil(s.length/8));for(let[e,t]of s.entries())t>=c&&(l[Math.floor(e/8)]|=1<<e%8);return{edgeHash:o,appearanceHash:l,textTokens:[...new Set(n.toUpperCase().normalize(`NFKC`).split(/[^\p{L}\d]+/u).filter(e=>e.length>=3))]}},iy=({value:e})=>{let t=0,n=e;for(;n;)t+=n&1,n>>>=1;return t},ay=({front:e,current:t})=>{if(!e||!t||e.edgeHash.length!==t.edgeHash.length||e.appearanceHash.length!==t.appearanceHash.length)return{distinct:!1,imageDistance:null,textOverlap:null};let n=e.edgeHash.reduce((e,n,r)=>e+iy({value:n^(t.edgeHash[r]??0)}),0)/(e.edgeHash.length*8),r=e.appearanceHash.reduce((e,n,r)=>e+iy({value:n^(t.appearanceHash[r]??0)}),0)/(e.appearanceHash.length*8),i=t.textTokens.filter(t=>e.textTokens.includes(t)).length,a=Math.min(e.textTokens.length,t.textTokens.length),o=e.textTokens.length>=3&&t.textTokens.length>=3?i/a:null;return{distinct:n>=ey&&r>=ny&&(o===null||o<ty),imageDistance:n,textOverlap:o}},oy=({text:e})=>{let t=e.toUpperCase().normalize(`NFKC`).split(`
|
|
61
|
+
`).map(e=>e.replace(/\s+/g,``)),n=t.findIndex(e=>e.startsWith(`P<`)&&e.length>=44&&(e.match(/</g)||[]).length>=2);if(n>=0&&t.slice(n+1).find(e=>/^[A-Z0-9<]{44}$/u.test(e)))return!0;let r=t.findIndex(e=>/^[A-Z0-9]<[A-Z]{3}/u.test(e)&&e.length>=30);return r<0?!1:t.slice(r+1).filter(e=>/^[A-Z0-9<]{30}$/u.test(e)).length>=2}})),cy,ly,uy=t((()=>{cy=({polygon:e,sourceOrientation:t=0})=>{let n=e.reduce((t,n)=>({x:t.x+n.x/e.length,y:t.y+n.y/e.length}),{x:0,y:0}),r=[...e].sort((e,t)=>Math.atan2(e.y-n.y,e.x-n.x)-Math.atan2(t.y-n.y,t.x-n.x)),i=(r.reduce((e,t,n)=>t.x+t.y<r[e].x+r[e].y?n:e,0)+t/90)%4;return r.slice(i).concat(r.slice(0,i))},ly=({polygon:e})=>{let t=e.map(e=>e.x),n=e.map(e=>e.y),r=Math.min(...t),i=Math.min(...n);return{x:r,y:i,width:Math.max(...t)-r,height:Math.max(...n)-i}}})),dy,fy,py,my,hy,gy,_y,vy,yy=t((()=>{W(),uy(),dy=2,fy=2048,py=70,my=.6,hy=({first:e,second:t})=>Math.hypot(t.x-e.x,t.y-e.y),gy=({matrix:e,values:t})=>{let n=e.map((e,n)=>[...e,t[n]??0]);for(let e=0;e<n.length;e+=1){let t=e;for(let r=e+1;r<n.length;r+=1)Math.abs(n[r][e]??0)>Math.abs(n[t][e]??0)&&(t=r);if(Math.abs(n[t][e]??0)<1e-8)return null;[n[e],n[t]]=[n[t],n[e]];let r=n[e][e]??1;for(let t=e;t<=n.length;t+=1)n[e][t]=(n[e][t]??0)/r;for(let t=0;t<n.length;t+=1){if(t===e)continue;let r=n[t][e]??0;for(let i=e;i<=n.length;i+=1)n[t][i]=(n[t][i]??0)-r*(n[e][i]??0)}}return n.map(e=>e[n.length]??0)},_y=({from:e,to:t})=>{let n=[],r=[];for(let[i,a]of e.entries()){let e=t[i];if(!e)return null;n.push([a.x,a.y,1,0,0,0,-e.x*a.x,-e.x*a.y]),r.push(e.x),n.push([0,0,0,a.x,a.y,1,-e.y*a.x,-e.y*a.y]),r.push(e.y)}let i=gy({matrix:n,values:r});return i?[...i,1]:null},vy=({image:e,polygon:t,sourceOrientation:n})=>{let[r,i,a,o]=cy({polygon:t,sourceOrientation:n});if(!r||!i||!a||!o)throw Error(j.DOCUMENT_NOT_FOUND);let s=Math.max(1,Math.round((hy({first:r,second:i})+hy({first:o,second:a}))/2)),c=Math.max(1,Math.round((hy({first:i,second:a})+hy({first:r,second:o}))/2)),l=_y({from:[{x:0,y:0},{x:s,y:0},{x:s,y:c},{x:0,y:c}],to:[r,i,a,o]});if(!l)throw Error(j.DOCUMENT_NOT_FOUND);let[u,d,f,p,m,h,g,_,v]=l;if([u,d,f,p,m,h,g,_,v].some(e=>e===void 0))throw Error(j.DOCUMENT_NOT_FOUND);let y=Math.min(dy,fy/Math.max(s,c)),b=Math.max(1,Math.round(s*y)),x=Math.max(1,Math.round(c*y)),S=new Uint8ClampedArray(b*x*4),C=new Uint8ClampedArray(b*x),w=new Float64Array(e.width*e.height);for(let t=0;t<w.length;t+=1){let n=t*4;w[t]=(e.data[n]??0)*.299+(e.data[n+1]??0)*.587+(e.data[n+2]??0)*.114}for(let t=0;t<x;t+=1)for(let n=0;n<b;n+=1){let r=n*s/b,i=t*c/x,a=g*r+_*i+v,o=(u*r+d*i+f)/a,l=(p*r+m*i+h)/a,y=Math.max(0,Math.min(e.width-1,o)),S=Math.max(0,Math.min(e.height-1,l)),T=Math.floor(y),E=Math.floor(S),ee=Math.min(e.width-1,T+1),D=Math.min(e.height-1,E+1),O=y-T,te=S-E,ne=E*e.width,re=D*e.width,ie=w[ne+T]*(1-O)+w[ne+ee]*O,ae=w[re+T]*(1-O)+w[re+ee]*O,oe=ie*(1-te)+ae*te;C[t*b+n]=Math.max(0,Math.min(255,Math.round((oe-py)*255/140)))}let T=new Uint16Array(b*3),E=({y:e})=>{let t=e*b,n=e%3*b;for(let e=0;e<b;e+=1){let r=Math.max(0,e-1),i=Math.min(b-1,e+1);T[n+e]=(C[t+r]??0)+(C[t+e]??0)+(C[t+i]??0)}};E({y:0});for(let e=0;e<x;e+=1){e+1<x&&E({y:e+1});let t=Math.max(0,e-1)%3*b,n=e%3*b,r=Math.min(x-1,e+1)%3*b;for(let i=0;i<b;i+=1){let a=(T[t+i]??0)+(T[n+i]??0)+(T[r+i]??0),o=C[e*b+i]??0,s=Math.max(0,Math.min(255,Math.round(o+my*(o-a/9)))),c=(e*b+i)*4;S[c]=s,S[c+1]=s,S[c+2]=s,S[c+3]=255}}return{data:S,height:x,width:b}}})),by,xy,Sy,Cy=t((()=>{W(),$v(),by=({document:e})=>e!==`passport`&&e!==`visa`,xy=({identity:e})=>!!(e?.holder.last_name&&e.holder.first_name&&e.holder.birth_date&&e.document.number),Sy=({classification:e,front:t,back:n})=>{let r=[],i=e.document===`passport`,a=e.document===`visa`,o=by(e)&&!n,s=i?t.codes:[...t.codes,...n?n.codes:[]],c=s.filter(e=>e.type===`mrz`&&e.payload.document.type===`PASSPORT`&&e.code.startsWith(`P<`)),l=s.filter(e=>e.type===`mrz`&&e.payload.document.type===`VISA`),u=s.filter(e=>e.type===`mrz`&&e.payload.document.type===`ID`),d=s.filter(e=>e.type===`aamva`);return(!t.ocr.text.trim()||n&&!n.ocr.text.trim())&&r.push(j.DOCUMENT_TEXT_NOT_READABLE),o&&r.push(j.DOCUMENT_BACK_REQUIRED),i&&!c.length&&r.push(j.INVALID_PASSPORT_MRZ),a&&!l.length&&r.push(j.INVALID_DOCUMENT_MRZ),!i&&n&&(e.document===`id`&&!u.length&&r.push(j.INVALID_DOCUMENT_MRZ),e.document===`driving_license`&&(e.europeanDrivingLicense?(Qv(n.ocr)||r.push(j.EUROPEAN_LICENCE_BACK_MARKER_REQUIRED),xy({identity:e.identity})||r.push(j.DOCUMENT_VALIDATION_FAILED)):d.length||r.push(j.INVALID_DOCUMENT_AAMVA))),(i&&(l.length||u.length||d.length)||a&&(c.length||u.length||d.length)||e.document===`id`&&(c.length||l.length||d.length)||e.document===`driving_license`&&(c.length||l.length||u.length))&&r.push(j.DOCUMENT_CODE_TYPE_MISMATCH),{valid:r.length===0,reasons:r,codes:s}}})),wy,Ty,Ey,Dy,Oy,ky,Ay,jy,My,Ny,Py=t((()=>{Xu(),wy=z().trim().min(1).nullable(),Ty=qu().nullable(),Ey=Pl([`MRZ`,`AAMVA`,`OCR`]),Dy=Pl([`PASSPORT`,`ID`,`VISA`,`DRV`,`PERMIT`]),Oy=Pl([`M`,`F`,`X`]),ky=V({source:Ey,type:Dy.nullable(),issuing_country:wy,number:wy,issuing_authority:wy.default(null),issue_date:Ty,expiry_date:Ty,optional_data:wy}),Ay=V({first_name:wy,last_name:wy,middle_name:wy,birth_place:wy.default(null),birth_date:Ty,sex:Oy.nullable(),nationality:wy,personal_number:wy}),jy=V({full:wy,street:wy,city:wy,state_province:wy,postal_code:wy}),My=V({mrz_lines:kl(z().min(1)),aamva_version:wy}),Ny=V({document:ky,holder:Ay,address:jy.nullable(),raw_data:My})})),Fy,Iy,Ly,Ry,zy,By,Vy,Hy=t((()=>{Py(),$v(),Fy={A:`AUT`,B:`BEL`,BG:`BGR`,CY:`CYP`,CZ:`CZE`,D:`DEU`,DK:`DNK`,E:`ESP`,EST:`EST`,F:`FRA`,FIN:`FIN`,GR:`GRC`,H:`HUN`,HR:`HRV`,I:`ITA`,IRL:`IRL`,L:`LUX`,LT:`LTU`,LV:`LVA`,M:`MLT`,NL:`NLD`,P:`PRT`,PL:`POL`,RO:`ROU`,S:`SWE`,SK:`SVK`,SLO:`SVN`},Iy=({line:e,start:t,end:n})=>{let r=[],i=0;for(let a of e.words){let o=e.text.indexOf(a.text,i);if(o<0||!a.text.length)continue;i=o+a.text.length;let s=Math.max(t,o),c=Math.min(n,i);c<=s||r.push({...a.box,x:a.box.x+a.box.width*(s-o)/a.text.length,width:a.box.width*(c-s)/a.text.length})}if(!r.length)return{...e.box,x:e.box.x+e.box.width*t/e.text.length,width:e.box.width*(n-t)/e.text.length};let a=Math.min(...r.map(e=>e.x)),o=Math.min(...r.map(e=>e.y));return{x:a,y:o,width:Math.max(...r.map(e=>e.x+e.width))-a,height:Math.max(...r.map(e=>e.y+e.height))-o}},Ly=({line:e})=>{let t=e.text;if(!t.trim()||e.confidence!==null&&e.confidence<=0)return[];if(/^\s*\d{1,2}[./-]\d{1,2}[./-]\d{2,4}\s*$/u.test(t))return[{text:t.trim(),box:e.box,label:null}];let n=[...t.matchAll(/(?:^|\s)(4[a-d]|1[0-4]|[1-9])(?:[.:)]\s*|\s+|$|(?=\d{1,2}[./-]\d))/giu)];if(!n.length)return[{text:t,box:e.box,label:null}];let r=[],i=n[0].index;i>0&&r.push({text:t.slice(0,i).trim(),box:Iy({line:e,start:0,end:i}),label:null});for(let[i,a]of n.entries()){let o=a.index+a[0].indexOf(a[1]),s=n[i+1]?.index??t.length,c=t.slice(a.index+a[0].length,s).trim(),l=Iy({line:e,start:o,end:s});r.push({text:c,box:l,label:a[1].toLowerCase()})}return r},Ry=({label:e,fragments:t})=>{let n=t.filter(t=>t.label===e);if(n.length!==1)return null;let r=n[0],i=r.box.height,a=r.text?[r]:[],o=t.filter(e=>e.label&&e!==r);for(let e of t){if(e.label||!e.text)continue;let t=e.box.y-r.box.y,n=Math.abs(t)<Math.max(i,e.box.height)*.5,s=t>=i*.5&&t<=i*2.5;(n||s)&&(e.box.x<r.box.x-i*.5||n&&r.text||o.some(t=>{let n=Math.abs(t.box.y-r.box.y)<i*.5&&t.box.x>r.box.x&&e.box.x>=t.box.x-i*.25,a=t.box.y>r.box.y+i*.5&&t.box.y<=e.box.y+e.box.height*.5&&Math.abs(t.box.x-r.box.x)<i*3;return n||a})||o.some(n=>{let a=e.box.y-n.box.y,o=a>=-i*.5&&a<=i*2.5&&e.box.x>=n.box.x-i*.5,s=Math.abs(t)+Math.abs(e.box.x-r.box.x),c=Math.abs(a)+Math.abs(e.box.x-n.box.x);return o&&c<=s})||a.push(e))}return a.sort((e,t)=>Math.abs(e.box.y-t.box.y)<i*.5?e.box.x-t.box.x:e.box.y-t.box.y),a.map(e=>e.text).join(` `).trim()||null},zy=({text:e,allowTwoDigitYear:t=!1})=>{if(!e)return null;let n=e.match(/^(?:(\d{1,2})([./-])(\d{1,2})\2(\d{2,4})|(\d{4})-(\d{2})-(\d{2}))$/u);if(!n)return null;let r=n[4]??n[5],i=Number(n[3]??n[6]),a=Number(n[1]??n[7]),o=Number(r);if(r.length===2){if(!t)return null;let e=new Date,n=e.getUTCFullYear(),r=e.getUTCMonth()+1,s=e.getUTCDate(),c=[1900+o,2e3+o].filter(e=>{let t=n-e-+(r<i||r===i&&s<a);return t>=16&&t<=100});if(c.length!==1)return null;o=c[0]}return o<1e3||i<1||i>12||a<1||a>new Date(Date.UTC(o,i,0)).getUTCDate()?null:`${o}-${String(i).padStart(2,`0`)}-${String(a).padStart(2,`0`)}`},By=({ocr:e,image:t})=>{let n=new Set;for(let r of e.lines)for(let e of r.words.length?r.words:[r]){let r=e.text.trim().toUpperCase(),i=Fy[r],{x:a,y:o,width:s,height:c}=e.box;if(e.confidence!==null&&e.confidence<=0||!i||a<0||o<0||a+s>t.width*.3||o+c>t.height*.35)continue;let l=Math.max(s,c);Xv({...t,xStart:Math.max(0,a-l)/t.width,xEnd:Math.min(t.width,a+s+l)/t.width,yStart:Math.max(0,o-l)/t.height,yEnd:Math.min(t.height,o+c+l)/t.height,predicate:(e,t,n)=>n>45&&n>e*1.08&&n>t*1.04})>=.15&&n.add(i)}return n.size===1?[...n][0]:null},Vy=({ocr:e,image:t})=>{if(Qv(e))return null;let n=e.lines.flatMap(e=>Ly({line:e})),r=new Set(n.map(e=>e.label));if(!(r.has(`1`)||r.has(`2`))||![`3`,`4a`,`4b`,`5`].some(e=>r.has(e)))return null;let i=Ry({label:`1`,fragments:n}),a=Ry({label:`2`,fragments:n}),o=i&&/\p{L}/u.test(i)?i:null,s=a&&/\p{L}/u.test(a)?a:null,c=Ry({label:`3`,fragments:n})?.match(/^(\d{1,2}[./-]\d{1,2}[./-]\d{2,4}|\d{4}-\d{2}-\d{2})(?:\s+(.+))?$/u),l=zy({allowTwoDigitYear:!0,text:c?c[1]:null}),u=c&&c[2]?.trim()||null,d=zy({text:Ry({label:`4a`,fragments:n})}),f=zy({text:Ry({label:`4b`,fragments:n})}),p=Ry({label:`4c`,fragments:n}),m=Ry({label:`5`,fragments:n}),h=By({ocr:e,image:t});return[o,s,l,u,d,f,p,m,h].some(Boolean)?Ny.parse({document:{source:`OCR`,type:`DRV`,issuing_country:h,issuing_authority:p,number:m,issue_date:d,expiry_date:f,optional_data:null},holder:{first_name:s,last_name:o,middle_name:null,birth_date:l,birth_place:u,sex:null,nationality:null,personal_number:null},address:null,raw_data:{mrz_lines:[],aamva_version:null}}):null}})),Uy=t((()=>{})),Wy,Gy=t((()=>{Wy={TD1:`TD1`,TD2:`TD2`,TD3:`TD3`,SWISS_DRIVING_LICENSE:`SWISS_DRIVING_LICENSE`,FRENCH_NATIONAL_ID:`FRENCH_NATIONAL_ID`,FRENCH_DRIVING_LICENSE:`FRENCH_DRIVING_LICENSE`}})),Ky,qy=t((()=>{Ky={AFG:`Afghanistan`,ALB:`Albania`,DZA:`Algeria`,ASM:`American Samoa`,AND:`Andorra`,AGO:`Angola`,AIA:`Anguilla`,ATA:`Antarctica`,ATG:`Antigua and Barbuda`,ARG:`Argentina`,ARM:`Armenia`,ABW:`Aruba`,AUS:`Australia`,AUT:`Austria`,AZE:`Azerbaijan`,BHS:`Bahamas (the)`,BHR:`Bahrain`,BGD:`Bangladesh`,BRB:`Barbados`,BLR:`Belarus`,BEL:`Belgium`,BLZ:`Belize`,BEN:`Benin`,BMU:`Bermuda`,BTN:`Bhutan`,BOL:`Bolivia (Plurinational State of)`,BES:`Bonaire, Sint Eustatius and Saba`,BIH:`Bosnia and Herzegovina`,BWA:`Botswana`,BVT:`Bouvet Island`,BRA:`Brazil`,IOT:`British Indian Ocean Territory (the)`,BRN:`Brunei Darussalam`,BGR:`Bulgaria`,BFA:`Burkina Faso`,BDI:`Burundi`,CPV:`Cabo Verde`,KHM:`Cambodia`,CMR:`Cameroon`,CAN:`Canada`,CYM:`Cayman Islands (the)`,CAF:`Central African Republic (the)`,TCD:`Chad`,CHL:`Chile`,CHN:`China`,CXR:`Christmas Island`,CCK:`Cocos (Keeling) Islands (the)`,COL:`Colombia`,COM:`Comoros (the)`,COD:`Congo (the Democratic Republic of the)`,COG:`Congo (the)`,COK:`Cook Islands (the)`,CRI:`Costa Rica`,HRV:`Croatia`,CUB:`Cuba`,CUW:`Curaçao`,CYP:`Cyprus`,CZE:`Czechia`,CIV:`Côte d'Ivoire`,DNK:`Denmark`,DJI:`Djibouti`,DMA:`Dominica`,DOM:`Dominican Republic (the)`,ECU:`Ecuador`,EGY:`Egypt`,SLV:`El Salvador`,GNQ:`Equatorial Guinea`,ERI:`Eritrea`,EST:`Estonia`,SWZ:`Eswatini`,ETH:`Ethiopia`,FLK:`Falkland Islands (the) [Malvinas]`,FRO:`Faroe Islands (the)`,FJI:`Fiji`,FIN:`Finland`,FRA:`France`,GUF:`French Guiana`,PYF:`French Polynesia`,ATF:`French Southern Territories (the)`,GAB:`Gabon`,GMB:`Gambia (the)`,GEO:`Georgia`,DEU:`Germany`,GHA:`Ghana`,GIB:`Gibraltar`,GRC:`Greece`,GRL:`Greenland`,GRD:`Grenada`,GLP:`Guadeloupe`,GUM:`Guam`,GTM:`Guatemala`,GGY:`Guernsey`,GIN:`Guinea`,GNB:`Guinea-Bissau`,GUY:`Guyana`,HTI:`Haiti`,HMD:`Heard Island and McDonald Islands`,VAT:`Holy See (the)`,HND:`Honduras`,HKG:`Hong Kong`,HUN:`Hungary`,ISL:`Iceland`,IND:`India`,IDN:`Indonesia`,IRN:`Iran (Islamic Republic of)`,IRQ:`Iraq`,IRL:`Ireland`,IMN:`Isle of Man`,ISR:`Israel`,ITA:`Italy`,JAM:`Jamaica`,JPN:`Japan`,JEY:`Jersey`,JOR:`Jordan`,KAZ:`Kazakhstan`,KEN:`Kenya`,KIR:`Kiribati`,PRK:`Korea (the Democratic People's Republic of)`,KOR:`Korea (the Republic of)`,KWT:`Kuwait`,KGZ:`Kyrgyzstan`,LAO:`Lao People's Democratic Republic (the)`,LVA:`Latvia`,LBN:`Lebanon`,LSO:`Lesotho`,LBR:`Liberia`,LBY:`Libya`,LIE:`Liechtenstein`,LTU:`Lithuania`,LUX:`Luxembourg`,MAC:`Macao`,MDG:`Madagascar`,MWI:`Malawi`,MYS:`Malaysia`,MDV:`Maldives`,MLI:`Mali`,MLT:`Malta`,MHL:`Marshall Islands (the)`,MTQ:`Martinique`,MRT:`Mauritania`,MUS:`Mauritius`,MYT:`Mayotte`,MEX:`Mexico`,FSM:`Micronesia (Federated States of)`,MDA:`Moldova (the Republic of)`,MCO:`Monaco`,MNG:`Mongolia`,MNE:`Montenegro`,MSR:`Montserrat`,MAR:`Morocco`,MOZ:`Mozambique`,MMR:`Myanmar`,NAM:`Namibia`,NRU:`Nauru`,NPL:`Nepal`,NLD:`Netherlands (the)`,NCL:`New Caledonia`,NZL:`New Zealand`,NIC:`Nicaragua`,NER:`Niger (the)`,NGA:`Nigeria`,NIU:`Niue`,NFK:`Norfolk Island`,MKD:`North Macedonia`,MNP:`Northern Mariana Islands (the)`,NOR:`Norway`,OMN:`Oman`,PAK:`Pakistan`,PLW:`Palau`,PSE:`Palestine, State of`,PAN:`Panama`,PNG:`Papua New Guinea`,PRY:`Paraguay`,PER:`Peru`,PHL:`Philippines (the)`,PCN:`Pitcairn`,POL:`Poland`,PRT:`Portugal`,PRI:`Puerto Rico`,QAT:`Qatar`,ROU:`Romania`,RUS:`Russian Federation (the)`,RWA:`Rwanda`,REU:`Réunion`,BLM:`Saint Barthélemy`,SHN:`Saint Helena, Ascension and Tristan da Cunha`,KNA:`Saint Kitts and Nevis`,LCA:`Saint Lucia`,MAF:`Saint Martin (French part)`,SPM:`Saint Pierre and Miquelon`,VCT:`Saint Vincent and the Grenadines`,WSM:`Samoa`,SMR:`San Marino`,STP:`Sao Tome and Principe`,SAU:`Saudi Arabia`,SEN:`Senegal`,SRB:`Serbia`,SYC:`Seychelles`,SLE:`Sierra Leone`,SGP:`Singapore`,SXM:`Sint Maarten (Dutch part)`,SVK:`Slovakia`,SVN:`Slovenia`,SLB:`Solomon Islands`,SOM:`Somalia`,ZAF:`South Africa`,SGS:`South Georgia and the South Sandwich Islands`,SSD:`South Sudan`,ESP:`Spain`,LKA:`Sri Lanka`,SDN:`Sudan (the)`,SUR:`Suriname`,SJM:`Svalbard and Jan Mayen`,SWE:`Sweden`,CHE:`Switzerland`,SYR:`Syrian Arab Republic (the)`,TWN:`Taiwan (Province of China)`,TJK:`Tajikistan`,TZA:`Tanzania, the United Republic of`,THA:`Thailand`,TLS:`Timor-Leste`,TGO:`Togo`,TKL:`Tokelau`,TON:`Tonga`,TTO:`Trinidad and Tobago`,TUN:`Tunisia`,TUR:`Turkey`,TKM:`Turkmenistan`,TCA:`Turks and Caicos Islands (the)`,TUV:`Tuvalu`,UGA:`Uganda`,UKR:`Ukraine`,ARE:`United Arab Emirates (the)`,GBR:`United Kingdom of Great Britain and Northern Ireland (the)`,UMI:`United States Minor Outlying Islands (the)`,USA:`United States of America (the)`,URY:`Uruguay`,UZB:`Uzbekistan`,VUT:`Vanuatu`,VEN:`Venezuela (Bolivarian Republic of)`,VNM:`Viet Nam`,VGB:`Virgin Islands (British)`,VIR:`Virgin Islands (U.S.)`,WLF:`Wallis and Futuna`,ESH:`Western Sahara*`,YEM:`Yemen`,ZMB:`Zambia`,ZWE:`Zimbabwe`,ALA:`Åland Islands`,GBD:`British Overseas Territories Citizen`,GBN:`British National (Overseas)`,GBO:`British Overseas Citizen`,GBS:`British Subject`,GBP:`British Protected Person`,RKS:`Republic of Kosovo`,D:`Germany`,XXK:`Kosovo`,EUE:`European Union (EU)`,UNO:`United Nations Organization or one of its officials`,UNA:`United Nations specialized agency or one of its officials`,UNK:`Resident of Kosovo to whom a travel document has been issued by the United Nations Interim Administration Mission in Kosovo (UNMIK)`,XBA:`African Development Bank (ADB)`,XIM:`African Export-Import Bank (AFREXIM bank)`,XCC:`Caribbean Community or one of its emissaries (CARICOM)`,XCE:`Council of Europe`,XCO:`Common Market for Eastern and Southern Africa (COMESA)`,XEC:`Economic Community of West African States (ECOWAS)`,XPO:`International Criminal Police Organization (INTERPOL)`,XES:`Organization of Eastern Caribbean States (OECS)`,XOM:`Sovereign Military Order of Malta or one of its emissaries`,XDC:`Southern African Development Community`,XXA:`Stateless person, as defined in Article 1 of the 1954 Convention Relating to the Status of Stateless Persons`,XXB:`Refugee, as defined in Article 1 of the 1951 Convention Relating to the Status of Refugees as amended by the 1967 Protocol`,XXC:`Refugee, other than as defined under the code XXB above`,XXX:`Person of unspecified nationality, for whom issuing State does not consider it necessary to specify any of the codes XXA, XXB or XXC above, whatever that person’s status may be. This category may include a person who is neither stateless nor a refugee but who is of unknown nationality and legally residing in the State of issue.`,ANT:`Netherlands Antilles`,NTZ:`Neutral Zone`},Object.freeze(Ky)}));function Jy(e){if(typeof e==`string`&&(e=e.split(/[\r\n]+/)),!Array.isArray(e))throw TypeError(`input must be an array or string`);for(let t of e)if(!t.match(/[A-Z0-9<]+/))throw TypeError(`lines must be composed of only alphanumerical characters and "<"`);return e}var Yy=t((()=>{}));function Xy(e){if(e.length!==2)throw Error(`invalid document code: ${e}. must be 2 char length`);let[t,n]=e;return Zy(t,e),Qy(n,e),`${t}${n}`}function Zy(e,t){if(!$y.includes(e)){let e=new Intl.ListFormat(`en-US`,{style:`short`,type:`disjunction`});throw Error(`invalid document code: ${t}. First character must be ${e.format($y)}`)}}function Qy(e,t){let n=Number.parseInt(e,10);if(Number.isNaN(n))throw Error(`invalid document code number: ${t}. Second character must be a number`)}var $y,eb=t((()=>{$y=[`A`,`B`,`D`]}));function tb(e){return e.replaceAll(/<+$/g,``).replaceAll(`<`,` `)}var nb=t((()=>{}));function rb(e){if(!e.match(/^[A-Z<]+$/))throw Error(`invalid text: ${e}. Must be only alphabetical with <`);return tb(e)}var ib=t((()=>{nb()}));function ab(e,t,n=/^[0-9A-Z<]+$/){let r=tb(e);if(!n.test(e))throw new ob(`invalid text: ${e}. Must match the following regular expression: ${n.toString()}`,r,t,t+r.length);return r}var ob,sb=t((()=>{nb(),ob=class extends Error{value;start;end;constructor(e,t,n,r){super(e),this.value=t,this.start=n,this.end=r}}}));function cb(e){return fb[e]?fb[e]:e}function lb(e){return db[e]?db[e]:e}function ub(e,t){let n=``,r=[],i=e.split(``);for(let[e,a]of i.entries())if(t.type===X.ALPHABETIC){let i=lb(a);i!==a&&r.push({line:t.line,column:t.start+e,original:a,corrected:i}),n+=i}else if(t.type===X.NUMERIC){let i=cb(a);i!==a&&r.push({line:t.line,column:t.start+e,original:a,corrected:i}),n+=i}else n+=a;return{correctedText:n,autocorrect:r}}var db,fb,pb=t((()=>{_b(),db={8:`B`,6:`G`,0:`O`,1:`I`,5:`S`,2:`Z`},fb={B:`8`,G:`6`,O:`0`,I:`1`,S:`5`,Z:`2`}}));function mb(e){gb(e,`label`,`string`),e.field!==null&&gb(e,`field`,`string`),gb(e,`line`,`number`),gb(e,`start`,`number`),gb(e,`end`,`number`),gb(e,`parser`,`function`);let t={line:e.line,start:e.start,end:e.end},n=[t];if(Array.isArray(e.related))for(let t of e.related)gb(t,`line`,`number`),gb(t,`start`,`number`),gb(t,`end`,`number`),n.push(t);return{parser:(t,r)=>{let i=hb(t,e),a=(e.related||[]).map(e=>hb(t,e)),o={label:e.label,field:e.field,value:null,valid:!1,ranges:n.map(e=>({...e,raw:hb(t,e)})),line:0,start:0,end:0,autocorrect:[]},s=o.ranges[0];o.line=s.line,o.start=s.start,o.end=s.end;try{let t=e.parser(i,...a);typeof t==`object`?(o.value=t.value,o.valid=t.valid??!0,t.start!==void 0&&(o.start=s.start+t.start),t.end!==void 0&&(o.end=s.start+t.end),t.valid===!1&&t.error&&(o.error=t.error)):(o.value=t,o.valid=!0)}catch(e){o.error=e.message,e instanceof ob&&(o.value=e.value,o.start=s.start+e.start,o.end=s.start+e.end)}for(let e of r)e.line===o.line&&e.column>=o.start&&e.column<o.end&&o.autocorrect.push(e);return o},autocorrector:n=>({...ub(hb(n,e),e),range:t})}}function hb(e,t){return e[t.line].slice(t.start,t.end)}function gb(e,t,n){if(typeof e[t]!==n)throw TypeError(`${String(t)} must be a ${n}`)}var X,_b=t((()=>{sb(),pb(),X={NUMERIC:`NUMERIC`,ALPHABETIC:`ALPHABETIC`,ALPHANUMERIC:`ALPHANUMERIC`}}));function vb(e){let t=0,n=[7,3,1];for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);i===60&&(i=0),i>=65&&(i-=55),i>=48&&(i-=48),i*=n[r%3],t+=i}return t%10}function yb(e,t){let n=vb(e),r=n===Number(t);return{valid:r,error:r?null:`invalid check digit: ${t}. Must be ${n}`}}var bb=t((()=>{}));function xb(e,...t){return{value:e,...yb(t.join(``),e)}}var Sb=t((()=>{bb()}));function Cb(e){if(!e.match(/^[0-9<]{4,6}$/))throw Error(`invalid date: ${e}`);let t=e.slice(2,4);if(t!==`<<`&&(Number.parseInt(t,10)<1||Number.parseInt(t,10)>12))throw Error(`invalid date month: ${t}`);if(e.length===6){let t=e.slice(4,6);if(t!==`<<`&&(Number.parseInt(t,10)<1||Number.parseInt(t,10)>31))throw Error(`invalid date day: ${t}`)}return e}var wb=t((()=>{}));function Tb(e,t){return{value:e,...yb(t,e)}}var Eb=t((()=>{bb()}));function Db(e,t,n){let r,i;if(t===`<`&&n){let t=n.indexOf(`<`);i=e+n.slice(0,t-1),r=i.length+1}else i=tb(e),r=i.length;return{value:i,start:0,end:r}}var Ob=t((()=>{nb()}));function kb(e,t,n){if(e===`<`&&n){let e=n.indexOf(`<`),r=n.slice(0,e-1),i=n.charAt(e-1),a={value:i,start:e,end:e+1},o=yb(`${t}<${r}`,i);return o.valid||(o=yb(`${t}${r}`,i)),{...a,...o}}return{value:e,...yb(t,e)}}var Ab=t((()=>{bb()}));function jb(e){let t=e.replace(/.*?<{2}/,``),n=ab(t,e.length-t.length,/^[A-Z<]+<*$/),r=e.length-t.length;return{value:n,start:r,end:r+n.length}}var Mb=t((()=>{sb()}));function Nb(e){let t=ab(e.replace(/<{2}.*$/,``),0,/^[A-Z<]*<*$/);return{value:t,start:0,end:t.length}}var Pb=t((()=>{sb()}));function Fb(e){switch(e){case`M`:return`male`;case`F`:return`female`;case`<`:return`nonspecified`;default:throw Error(`invalid sex: ${e}. Must be M, F or <.`)}}var Ib=t((()=>{}));function Lb(e){if(e=tb(e),!Ky[e])throw Error(`invalid state code: ${e}`);return{value:e,start:0,end:e.length}}var Rb=t((()=>{qy(),nb()})),zb,Bb,Vb,Hb,Ub,Wb,Gb,Kb,qb,Jb,Yb,Xb,Zb,Qb,$b,ex=t((()=>{Sb(),wb(),Eb(),Ob(),Ab(),Mb(),Pb(),Ib(),Rb(),_b(),zb={label:`Document number`,field:`documentNumber`,parser:Db,type:X.ALPHANUMERIC},Bb={label:`Document number check digit`,field:`documentNumberCheckDigit`,parser:kb,type:X.NUMERIC},Vb={label:`Document code`,field:`documentCode`,type:X.ALPHABETIC},Hb={label:`Document code`,field:`documentCode`,type:X.ALPHANUMERIC},Ub={label:`Nationality`,field:`nationality`,parser:Lb,type:X.ALPHABETIC},Wb={label:`Sex`,field:`sex`,parser:Fb,type:X.ALPHABETIC},Gb={label:`Expiration date`,field:`expirationDate`,parser:Cb,type:X.NUMERIC},Kb={label:`Expiration date check digit`,field:`expirationDateCheckDigit`,parser:Tb,type:X.NUMERIC},qb={label:`Composite check digit`,field:`compositeCheckDigit`,parser:xb,type:X.NUMERIC},Jb={label:`Birth date`,field:`birthDate`,parser:Cb,type:X.NUMERIC},Yb={label:`Birth date check digit`,field:`birthDateCheckDigit`,parser:Tb,type:X.NUMERIC},Xb={label:`Issue date`,field:`issueDate`,parser:Cb,type:X.NUMERIC},Zb={label:`First name`,field:`firstName`,parser:jb,type:X.ALPHABETIC},Qb={label:`Last name`,field:`lastName`,parser:Nb,type:X.ALPHABETIC},$b={label:`Issuing state`,field:`issuingState`,parser:Lb,type:X.ALPHABETIC}})),tx,nx,rx=t((()=>{eb(),ib(),_b(),ex(),tx=[{...Hb,line:0,start:0,end:2,parser:Xy},{...$b,line:0,start:2,end:5},{...zb,line:0,start:5,end:14},{...Bb,line:0,start:14,end:15,related:[{line:0,start:0,end:14}]},{...Gb,line:0,start:15,end:21},{...Qb,line:0,start:21,end:29,parser:rb},{...qb,line:0,start:29,end:30,related:[{line:0,start:0,end:29}]}],nx=tx.map(mb)}));function ix(e,t){switch(e){case`TD1`:case`TD2`:case`TD3`:case`FRENCH_DRIVING_LICENSE`:return ax(t.documentNumber);case`FRENCH_NATIONAL_ID`:return ax(t.issueDate,t.administrativeCode2,t.documentNumber);case`SWISS_DRIVING_LICENSE`:return ax(t.pinCode,t.versionNumber);default:ox(e)}}function ax(...e){let t=``;for(let n of e){if(!n)return null;t+=n}return t}function ox(e){throw Error(`unrecognized format: ${e}`)}var sx=t((()=>{}));function cx(e,t,n){let r=[];for(let[i,{parser:a}]of t.entries())r.push(a(e,n[i]));return r}function lx(e){let t={},n=!0;for(let r of e)r.valid||(n=!1),r.field&&(t[r.field]=r.valid?r.value:null);return{fields:t,allValid:n}}function ux(e,t,n){let r=e.slice(),i=[];if(n)for(let{autocorrector:n}of t){let{autocorrect:t,correctedText:a,range:o}=n(e);i.push(t);let s=r[o.line];r[o.line]=s.slice(0,o.start)+a+s.slice(o.end)}else i=Array(t.length).fill([]);return{corrected:r,autocorrectArray:i}}function dx(e,t,n,r){let{autocorrect:i=!1}=r,{corrected:a,autocorrectArray:o}=ux(t,n,i),s=cx(a,n,o),c=lx(s);return{format:e,details:s,fields:c.fields,documentNumber:ix(e,c.fields),valid:c.allValid}}var fx=t((()=>{sx()}));function px(e,t){if(e.length!==1)throw Error(`invalid number of lines: ${e.length}: Must be 1 for ${mx}`);if(e[0].length!==30)throw Error(`invalid number of characters for line 1: ${e[0].length}. Must be 30 for ${mx}`);return dx(mx,e,nx,t)}var mx,hx=t((()=>{Gy(),rx(),fx(),mx=Wy.FRENCH_DRIVING_LICENSE}));function gx(e){let t=e.charAt(0);if(t!==`A`&&t!==`C`&&t!==`I`)throw Error(`invalid document code: ${e}. First character must be A, C or I`);let n=e.charAt(1);if(n===`V`)throw Error(`invalid document code: ${e}. Second character may not be V`);return n===`<`?{value:t,start:0,end:1}:e}var _x=t((()=>{}));function vx(e){let t=ab(e,0);return{value:t,start:0,end:t.length}}var yx=t((()=>{sb()})),bx,xx,Sx=t((()=>{ib(),_x(),yx(),_b(),ex(),bx=[{...Vb,line:0,start:0,end:2,parser:gx},{...$b,line:0,start:2,end:5},{...Qb,line:0,start:5,end:30,parser:rb},{label:`Administrative code`,field:`administrativeCode`,line:0,start:30,end:36,parser:vx},{...Xb,line:1,start:0,end:4},{label:`Administrative code 2`,field:`administrativeCode2`,line:1,start:4,end:7,parser:vx},{...zb,line:1,start:7,end:12},{...Bb,line:1,start:12,end:13,related:[{line:1,start:0,end:12}]},{...Zb,line:1,start:13,end:27,parser:rb},{...Jb,line:1,start:27,end:33},{...Yb,line:1,start:33,end:34,related:[{line:1,start:27,end:33}]},{...Wb,line:1,start:34,end:35},{...qb,line:1,start:35,end:36,related:[{line:0,start:0,end:36},{line:1,start:0,end:35}]}],xx=bx.map(mb)}));function Cx(e,t){if(e.length!==2)throw Error(`invalid number of lines: ${e.length}: Must be 2 for ${wx}`);for(let[t,n]of e.entries())if(n.length!==36)throw Error(`invalid number of characters for line ${t+1}: ${n.length}. Must be 36 for ${wx}`);return dx(wx,e,xx,t)}var wx,Tx=t((()=>{Gy(),Sx(),fx(),wx=Wy.FRENCH_NATIONAL_ID}));function Ex(e){if(!e.match(/^[0-9]+$/))throw Error(`invalid number: ${e}`);return e}var Dx=t((()=>{}));function Ox(e){if(!e.match(/^<*$/))throw Error(`invalid separator: ${e}. Must be composed only of "<"`);return e}var kx=t((()=>{}));function Ax(e){if(e!==`FA`)throw Error(`invalid document code: ${e}. Must be FA`);return e}var jx=t((()=>{}));function Mx(e){switch(e){case`D`:case`F`:case`I`:case`R`:return e;default:throw Error(`invalid languageCode code: ${e}. Must be D, F, I or R`)}}var Nx=t((()=>{}));function Px(e){let t=e.slice(0,3),n=e.slice(3,6),r=e.charAt(6),i=e.slice(7);if(!t.match(/^[A-Z0-9]{3}$/))throw Error(`invalid document number: ${e}. Must start with three alphanumeric digits`);if(!n.match(/^[0-9]{3}$/))throw Error(`invalid document number: ${e}. Must have numeric digits in positions 4, 5 and 6`);if(i!==`<<`)throw Error(`invalid document number: ${e}. Must end with <<`);return Mx(r),{value:e.slice(0,7),start:0,end:7}}var Fx=t((()=>{Nx()}));function Ix(e){if(e!==`CHE`&&e!==`LIE`)throw Error(`invalid state code: ${e}. Must be CHE or LIE`);return e}var Lx=t((()=>{})),Rx,zx,Bx=t((()=>{Dx(),kx(),jx(),Fx(),Lx(),Nx(),_b(),ex(),Rx=[{...zb,line:0,start:0,end:9,parser:Px},{label:`Language code`,field:`languageCode`,line:0,start:6,end:7,parser:Mx,type:X.ALPHABETIC},{...Vb,line:1,start:0,end:2,parser:Ax},{...$b,line:1,start:2,end:5,parser:Ix},{label:`PIN code`,field:`pinCode`,line:1,start:5,end:14,parser:Ex,type:X.NUMERIC},{label:`Version number`,field:`versionNumber`,line:1,start:14,end:17,parser:Ex,type:X.NUMERIC},{label:`Separator 1`,field:null,line:1,start:17,end:19,parser:Ox},{...Jb,line:1,start:19,end:25},{label:`Separator 2`,field:null,line:1,start:25,end:30,parser:Ox},{...Qb,line:2,start:0,end:30},{...Zb,line:2,start:0,end:30}],zx=Rx.map(mb)}));function Vx(e,t){if(e.length!==3)throw Error(`invalid number of lines: ${e.length}: Must be 3 for ${Hx}`);if(e[0].length!==9)throw Error(`invalid number of characters for line 1: ${e[0].length}. Must be 9 for ${Hx}`);if(e[1].length!==30)throw Error(`invalid number of characters for line 2: ${e[1].length}. Must be 30 for ${Hx}`);if(e[2].length!==30)throw Error(`invalid number of characters for line 3: ${e[2].length}. Must be 30 for ${Hx}`);return dx(Hx,e,zx,t)}var Hx,Ux=t((()=>{Gy(),fx(),Bx(),Hx=Wy.SWISS_DRIVING_LICENSE}));function Wx(e){let t=ab(e,0);return{value:t,start:0,end:t.length}}var Gx=t((()=>{sb()})),Kx,qx,Jx=t((()=>{_x(),Gx(),yx(),_b(),ex(),Kx=[{...Vb,line:0,start:0,end:2,parser:gx},{...$b,line:0,start:2,end:5},{...zb,line:0,start:5,end:14,related:[{line:0,start:14,end:15},{line:0,start:15,end:30}]},{...Bb,line:0,start:14,end:15,related:[{line:0,start:5,end:14},{line:0,start:15,end:30}]},{label:`Optional field 1`,field:`optional1`,line:0,start:15,end:30,related:[],parser:Wx},{...Jb,start:0,end:6,line:1},{...Yb,line:1,start:6,end:7,related:[{line:1,start:0,end:6}]},{...Wb,line:1,start:7,end:8},{...Gb,line:1,start:8,end:14},{...Kb,line:1,start:14,end:15,related:[{line:1,start:8,end:14}]},{...Ub,line:1,start:15,end:18},{label:`Optional field 2`,field:`optional2`,line:1,start:18,end:29,parser:vx},{...qb,line:1,start:29,end:30,related:[{line:0,start:5,end:30},{line:1,start:0,end:7},{line:1,start:8,end:15},{line:1,start:18,end:29}]},{...Qb,line:2,start:0,end:30},{...Zb,line:2,start:0,end:30}],qx=Kx.map(mb)}));function Yx(e,t){if(e.length!==3)throw Error(`invalid number of lines: ${e.length}: Must be 3 for ${Xx}`);for(let[t,n]of e.entries())if(n.length!==30)throw Error(`invalid number of characters for line ${t+1}: ${n.length}. Must be 30 for ${Xx}`);return dx(Xx,e,qx,t)}var Xx,Zx=t((()=>{Gy(),fx(),Jx(),Xx=Wy.TD1})),Qx,$x,eS=t((()=>{_x(),yx(),_b(),ex(),Qx=[{...Vb,line:0,start:0,end:2,parser:gx},{...$b,line:0,start:2,end:5},{...Qb,line:0,start:5,end:36},{...Zb,line:0,start:5,end:36},{...zb,line:1,start:0,end:9,related:[{line:1,start:9,end:10},{line:1,start:28,end:35}]},{...Bb,line:1,start:9,end:10,related:[{line:1,start:0,end:9},{line:1,start:28,end:35}]},{...Ub,line:1,start:10,end:13},{...Jb,line:1,start:13,end:19},{...Yb,line:1,start:19,end:20,related:[{line:1,start:13,end:19}]},{...Wb,line:1,start:20,end:21},{...Gb,line:1,start:21,end:27},{...Kb,line:1,start:27,end:28,related:[{line:1,start:21,end:27}]},{label:`Optional field`,field:`optional`,line:1,start:28,end:35,parser:vx},{...qb,line:1,start:35,end:36,related:[{line:1,start:0,end:10},{line:1,start:13,end:20},{line:1,start:21,end:35}]}],$x=Qx.map(mb)}));function tS(e,t){if(e.length!==2)throw Error(`invalid number of lines: ${e.length}: Must be 2 for ${nS}`);for(let[t,n]of e.entries())if(n.length!==36)throw Error(`invalid number of characters for line ${t+1}: ${n.length}. Must be 36 for TD2`);return dx(nS,e,$x,t)}var nS,rS=t((()=>{Gy(),fx(),eS(),nS=Wy.TD2}));function iS(e){let t=e.charAt(0);if(t!==`P`)throw Error(`invalid document code: ${e}. First character must be P`);let n=e.charAt(1);if(!n.match(/[A-Z<]/))throw Error(`invalid document code: ${e}. Second character must be a letter or <`);return n===`<`?{value:t,start:0,end:1}:e}var aS=t((()=>{}));function oS(e){let t=ab(e,0,/^[A-Z0-9<]+<*$/);return{value:t,start:0,end:t.length}}var sS=t((()=>{sb()}));function cS(e,t){return tb(t)===``?e!==`<`&&e!==`0`?{value:e,valid:!1,error:`invalid check digit ${e}: must be 0 or <`}:e:{value:e,...yb(t,e)}}var lS=t((()=>{bb(),nb()})),uS,dS,fS=t((()=>{aS(),sS(),lS(),_b(),ex(),uS=[{...Vb,line:0,start:0,end:2,parser:iS},{...$b,line:0,start:2,end:5},{...Qb,line:0,start:5,end:44},{...Zb,line:0,start:5,end:44},{...zb,line:1,start:0,end:9},{...Bb,line:1,start:9,end:10,related:[{line:1,start:0,end:9}]},{...Ub,line:1,start:10,end:13},{...Jb,line:1,start:13,end:19},{...Yb,line:1,start:19,end:20,related:[{line:1,start:13,end:19}]},{...Wb,line:1,start:20,end:21},{...Gb,line:1,start:21,end:27},{...Kb,line:1,start:27,end:28,related:[{line:1,start:21,end:27}]},{label:`Personal number`,field:`personalNumber`,line:1,start:28,end:42,parser:oS},{label:`Personal number check digit`,field:`personalNumberCheckDigit`,line:1,start:42,end:43,related:[{line:1,start:28,end:42}],parser:cS},{...qb,line:1,start:43,end:44,related:[{line:1,start:0,end:10},{line:1,start:13,end:20},{line:1,start:21,end:43}]}],dS=uS.map(mb)}));function pS(e,t){if(e.length!==2)throw Error(`invalid number of lines: ${e.length}: Must be 2 for ${mS}`);for(let[t,n]of e.entries())if(n.length!==44)throw Error(`invalid number of characters for line ${t+1}: ${n.length}. Must be 44 for TD3`);return dx(mS,e,dS,t)}var mS,hS=t((()=>{Gy(),fx(),fS(),mS=Wy.TD3})),gS,_S=t((()=>{hx(),Tx(),Ux(),Zx(),rS(),hS(),gS={td1:Yx,td2:tS,td3:pS,swissDrivingLicense:Vx,frenchNationalId:Cx,frenchDrivingLicense:px}}));function vS(e,t={}){let n=Jy(e);switch(n.length){case 1:switch(n[0].length){case 30:return gS.frenchDrivingLicense(n,t);default:throw Error(`unrecognized document format. First line of input must have 30 (French Driving License) characters and it has a length of ${n[0].length}`)}case 2:case 3:switch(n[0].length){case 30:return gS.td1(n,t);case 36:return n[0].slice(30,35).match(/[0-9]/)||n[0].match(/^IDFRA/)?gS.frenchNationalId(n,t):gS.td2(n,t);case 44:return gS.td3(n,t);case 9:return gS.swissDrivingLicense(n,t);default:throw Error(`unrecognized document format. First line of input must have 30 (TD1), 36 (TD2 or French National Id), 44 (TD3) or 9 (Swiss Driving License) characters and it has a length of ${n[0].length}`)}default:throw Error(`unrecognized document format. Input must have one, two or three lines, found ${n.length}`)}}var yS=t((()=>{Yy(),_S()})),bS=t((()=>{Uy(),Gy(),qy(),yS()})),xS,SS,CS=t((()=>{Xu(),xS=qu(),SS=({value:e,country:t,kind:n,source:r,reference:i=new Date})=>{if(!e)return null;if(r===`AAMVA`){if(!/^\d{8}$/u.test(e))return null;let n;if(t===`CAN`)n=`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`;else if(t===`USA`)n=`${e.slice(4,8)}-${e.slice(0,2)}-${e.slice(2,4)}`;else return null;return xS.safeParse(n).success?n:null}if(!/^\d{6}$/u.test(e))return null;let a=i.toISOString().slice(0,10),o=Math.floor(i.getUTCFullYear()/100)*100,s=[o-100,o,o+100].map(t=>`${String(t+Number(e.slice(0,2))).padStart(4,`0`)}-${e.slice(2,4)}-${e.slice(4,6)}`).filter(e=>xS.safeParse(e).success);if(n===`birth`||n===`issue`)return s.filter(e=>e<=a).sort().at(-1)??null;let c=Date.parse(a);return s.sort((e,t)=>Math.abs(Date.parse(e)-c)-Math.abs(Date.parse(t)-c)||t.localeCompare(e))[0]??null}})),Z,wS,TS,ES=t((()=>{bS(),W(),Py(),CS(),Z=e=>(e?e.replaceAll(`<`,` `).trim():``)||null,wS=e=>{if(!e)return null;try{let t=vS(e.split(`
|
|
62
|
+
`)),n=t.fields,r=n.documentCode??``,i=t.format.includes(`DRIVING_LICENSE`)?`DRV`:r.startsWith(`P`)?`PASSPORT`:r.startsWith(`V`)?`VISA`:/^[IAC]/u.test(r)?`ID`:null,a=[n.optional,n.optional1,n.optional2].map(Z).filter(Boolean).join(` `);return Ny.parse({document:{source:`MRZ`,type:i,issuing_country:Z(n.issuingState),number:Z(t.documentNumber),issue_date:SS({value:n.issueDate,source:`MRZ`,kind:`issue`}),expiry_date:SS({value:n.expirationDate,source:`MRZ`,kind:`expiry`}),optional_data:Z(a)},holder:{first_name:Z(n.firstName),last_name:Z(n.lastName),middle_name:null,birth_date:SS({value:n.birthDate,source:`MRZ`,kind:`birth`}),sex:n.sex===`male`?`M`:n.sex===`female`?`F`:null,nationality:Z(n.nationality),personal_number:Z(n.personalNumber)},address:null,raw_data:{mrz_lines:e.split(`
|
|
63
|
+
`),aamva_version:null}})}catch{return null}},TS=e=>{let t=e.replace(/<LF>|<CR>|<RS>/gi,`
|
|
64
64
|
`).replace(/\r\n|\r/g,`
|
|
65
65
|
`).replaceAll(``,`
|
|
66
|
-
`),n=t.match(/ANSI\s+\d{6}(\d{2})\d{2}(\d{2})/u),r=n?(n.index??0)+n[0].length:0,i=n?t.slice(r,r+2):null,a=(n?t.slice(r+Number(n[2])*10):t).replace(/^(?:DL|ID)(?=D[A-Z]{2})/u,``),o={};for(let e of a.matchAll(/(?:^|\n)([A-Z]{3})([^\n]*)/g)){let[,t,n]=e;o[t]=n.trim()}if(!o.DCS&&!o.DAC)throw Error(
|
|
67
|
-
`));else for(let n of r[e]??[])a(e+1,[...t,n])};return a(0,[]),i},
|
|
68
|
-
`)).valid}catch{return!1}},
|
|
69
|
-
`);
|
|
70
|
-
`)).valid)return null;let e=uy(n);return e?{type:`mrz`,code:n,payload:e}:null}catch{return null}}})),My,Ny,Py,Fy,Iy,Ly,Ry=t((()=>{Sm(),fy(),My=null,Ny=()=>globalThis.window===void 0?`zxing-wasm/reader`:bm({filename:`zxing-wasm/reader/index.js`}),Py=async()=>{let e=await import(Ny());return globalThis.window!==void 0&&e.setZXingModuleOverrides({locateFile:e=>bm({filename:`zxing-wasm/reader/${e}`})}),e},Fy=async()=>{My??=Py();try{return await My}catch(e){throw My=null,e}},Iy=async()=>{await(await Fy()).prepareZXingModule({fireImmediately:!0})},Ly=async({image:e})=>{let t=await(await Fy()).readBarcodes(e,{formats:[`PDF417`],tryHarder:!0});for(let e of t)try{let t=dy(e.text);return{type:`aamva`,code:e.text,payload:t}}catch{}return null}})),zy,By=t((()=>{W(),zh(),qh(),ag(),lg(),Og(),jy(),Ry(),zy=({runtime:e,detector:t,alignment:n,text:r,readImage:i})=>{let a=async({image:a,language:o,engine:s,scanBarcodes:c=!1})=>{let l=a instanceof Blob?a:new Blob([a]),u=await e.createImageBitmap(l);try{let a=await t.analyzeDocument({frame:u});if(!a.detection)throw Error(U.DOCUMENT_NOT_FOUND);let l=await n.orientDocumentFrame({frame:u,polygon:a.detection.polygon,orientation:a.detection.orientation});if(!l)throw Error(U.IMAGE_PROCESSING_FAILED);try{let t=ig({image:i({frame:u}),polygon:a.detection.polygon,sourceOrientation:l.orientation.rotation}),n=await r.readRectifiedText({frame:l.frame,language:o,engine:s,image:t});if(!n)throw Error(U.DOCUMENT_TEXT_NOT_READABLE);let d=i({frame:l.frame}),f=null;if(c){let t=e.createImageData(d.width,d.height);t.data.set(d.data),f=await Ly({image:t})}let p=[Ay({result:n}),f].filter(e=>e!==null),m=i({frame:l.frame,width:32,height:32});return{ocr:n,codes:p,pixels:d,signature:Uh({...m,text:n.text}),blurry:a.isBlurry}}finally{l.frame.close()}}finally{u.close()}};return{classifyDocument:async({document_front:e,document_back:t,language:n,engine:r})=>{let i=await a({image:e,language:n,engine:r}),o=Lh({image:i.pixels,text:i.ocr.text,codes:i.codes});if(!o)throw Error(U.DOCUMENT_NOT_RECOGNIZED);let s=o.europeanDrivingLicense?Dg({ocr:i.ocr,image:i.pixels}):null,c=og({document:o.document})&&t?await a({image:t,language:o.europeanDrivingLicense?`latin`:n,engine:o.europeanDrivingLicense?`tiny`:r,scanBarcodes:!0}):null,l=cg({classification:{...o,identity:s},front:i,back:c}),u=[...l.reasons],d=c?c.blurry:!1;return(i.blurry||d)&&u.push(U.DOCUMENT_BLURRY),c&&!Gh({front:i.signature,current:c.signature}).distinct&&u.push(U.DOCUMENT_BACK_NOT_DISTINCT),{identity:s,...o,...l,reasons:u,valid:u.length===0,document_front:i.ocr,document_back:c?c.ocr:null}},detectDocument:async({image:e,language:t})=>{let n=await a({image:e,language:t,scanBarcodes:!0}),r=Lh({image:n.pixels,text:n.ocr.text,codes:n.codes});if(!r)throw Error(U.DOCUMENT_NOT_RECOGNIZED);let i=n.codes.find(e=>e.type===`mrz`),o=n.codes.find(e=>e.type===`aamva`),s=!!o||r.document===`id`&&!!i;return{identity:!s&&r.europeanDrivingLicense?Dg({ocr:n.ocr,image:n.pixels}):null,document_type:r.document===`driving_license`?`drv`:r.document,document_side:s?`back`:`front`,mrz_code:i?i.code:null,ammva_code:o?o.code:null}},extractDocumentCodes:async({images:e})=>{let t=[];for(let n of e){let e=await a({image:n,scanBarcodes:!0});t.push(...e.codes)}return[...new Map(t.map(e=>[`${e.type}:${e.code}`,e])).values()]}}}})),Q,Vy=t((()=>{dd(),W(),Q={language:`en`,ocrEngine:`auto`,alignment:`eyes-nose-mouth`,maxPitch:8,minPitch:-20,maxYaw:12,minYaw:-12,maxRoll:8,minDocumentFaceAreaRatio:.02,maxDocumentFaceAreaRatio:.3,minDocumentFaceWidthRatio:.075,maxDocumentFaceWidthRatio:.4,minDocumentFaceHeightRatio:.1,maxDocumentFaceHeightRatio:.65,minDocumentBoxRatio:.33,maxDocumentTextAngleDifference:16},B({language:z().default(Q.language),ocrEngine:Ql([`auto`,`tiny`,`small`,`japanese`,`chinese-simplified`,`chinese-traditional`,`cyrillic`,`arabic`]).default(Q.ocrEngine),alignment:$l(`eyes-nose-mouth`).default(Q.alignment),maxPitch:Hl().positive().max(90).default(Q.maxPitch),minPitch:Hl().negative().min(-90).default(Q.minPitch),maxYaw:Hl().positive().max(90).default(Q.maxYaw),minYaw:Hl().negative().min(-90).default(Q.minYaw),maxRoll:Hl().positive().max(90).default(Q.maxRoll),minDocumentFaceAreaRatio:Hl().min(0).max(1).default(Q.minDocumentFaceAreaRatio),maxDocumentFaceAreaRatio:Hl().min(0).max(1).default(Q.maxDocumentFaceAreaRatio),minDocumentFaceWidthRatio:Hl().min(0).max(1).default(Q.minDocumentFaceWidthRatio),maxDocumentFaceWidthRatio:Hl().min(0).max(1).default(Q.maxDocumentFaceWidthRatio),minDocumentFaceHeightRatio:Hl().min(0).max(1).default(Q.minDocumentFaceHeightRatio),maxDocumentFaceHeightRatio:Hl().min(0).max(1).default(Q.maxDocumentFaceHeightRatio),minDocumentBoxRatio:Hl().min(0).max(1).default(Q.minDocumentBoxRatio),maxDocumentTextAngleDifference:Hl().min(0).max(90).default(Q.maxDocumentTextAngleDifference)}).refine(e=>e.minDocumentFaceAreaRatio<=e.maxDocumentFaceAreaRatio&&e.minDocumentFaceWidthRatio<=e.maxDocumentFaceWidthRatio&&e.minDocumentFaceHeightRatio<=e.maxDocumentFaceHeightRatio,U.INVALID_OPTIONS)})),Hy,Uy,Wy,Gy,Ky,qy,Jy=t((()=>{Hy=({data:e,height:t,normalize:n,width:r})=>{let i=new Float32Array(r*t*3),a=r*t;for(let t=0;t<a;t+=1)for(let r=0;r<3;r+=1)i[r*a+t]=n(e[t*4+r]);return i},Uy=({first:e,second:t})=>{let n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return n*r/(e.width*e.height+t.width*t.height-n*r||1)},Wy=({detections:e,threshold:t})=>e.toSorted((e,t)=>t.score-e.score).filter((e,n,r)=>!r.slice(0,n).some(n=>Uy({first:n.boundingRect,second:e.boundingRect})>t)),Gy=({face:e,x:t,y:n})=>({...e,boundingRect:{...e.boundingRect,x:e.boundingRect.x+t,y:e.boundingRect.y+n},mesh:{...e.mesh,landmarks:e.mesh.landmarks.map(e=>({...e,x:e.x+t,y:e.y+n}))}}),Ky=({faces:e})=>{let t=[];for(let n of e)t.some(e=>Uy({first:e.boundingRect,second:n.boundingRect})>.3)||t.push(n);return t},qy=({frameSize:e,tileSize:t})=>[...new Set([0,Math.round((e-t)/2),e-t])]})),Yy,Xy,Zy=t((()=>{Jy(),Yy=({outputs:e})=>({score_8:e.out0,score_16:e.out1,score_32:e.out2,bbox_8:e.out3,bbox_16:e.out4,bbox_32:e.out5,kps_8:e.out6,kps_16:e.out7,kps_32:e.out8}),Xy=({outputs:e,scale:t,threshold:n=.5})=>{let r=[];for(let i of[8,16,32]){let a=e[`score_${i}`]?.data,o=e[`bbox_${i}`]?.data,s=e[`kps_${i}`]?.data;if(!a||!o||!s)continue;let c=640/i;for(let e=0;e<a.length;e+=1){let l=a[e];if(l<n)continue;let u=Math.floor(e/2),d=u%c*i,f=Math.floor(u/c)*i,p=e*4,m=e*10,h=e=>({x:(d+s[m+e*2]*i)/t,y:(f+s[m+e*2+1]*i)/t});r.push({boundingRect:{x:(d-o[p]*i)/t,y:(f-o[p+1]*i)/t,width:(o[p]+o[p+2])*i/t,height:(o[p+1]+o[p+3])*i/t},score:l,keypoints:{leftEye:h(0),rightEye:h(1),nose:h(2),mouthLeft:h(3),mouthRight:h(4)}})}}return Wy({detections:r,threshold:.4})}})),Qy,$y,eb,tb,nb,rb,ib=t((()=>{W(),Qy=128,$y=.1,eb=4,tb=({image:e})=>{let t=65536,n=new Float32Array(t*3);for(let r=0,i=0;r<e.data.length;r+=4,i+=1)n[i]=(e.data[r]??0)/255,n[i+t]=(e.data[r+1]??0)/255,n[i+t*2]=(e.data[r+2]??0)/255;return n},nb=({polygon:e})=>{let t=e.reduce((t,n)=>({x:t.x+n.x/e.length,y:t.y+n.y/e.length}),{x:0,y:0}),n=[...e].sort((e,n)=>Math.atan2(e.y-t.y,e.x-t.x)-Math.atan2(n.y-t.y,n.x-t.x)),r=n.reduce((e,t,r)=>t.x+t.y<n[e].x+n[e].y?r:e,0);return n.slice(r).concat(n.slice(0,r))},rb=({heatmap:e,height:t,width:n})=>{if(e.length!==512*Qy)throw Error(U.INVALID_MODEL_OUTPUT);let r=[],i=1;for(let a=0;a<4;a+=1){let o=a*Qy*Qy,s=-1/0,c=0;for(let t=0;t<16384;t+=1){let n=e[o+t]??-1/0;n>s&&(s=n,c=t)}if(s<$y)throw Error(U.DOCUMENT_NOT_FOUND);i=Math.min(i,s);let l=c%Qy,u=Math.floor(c/Qy),d=s*.3,f=0,p=0,m=0;for(let t=Math.max(0,u-eb);t<=Math.min(127,u+eb);t+=1)for(let n=Math.max(0,l-eb);n<=Math.min(127,l+eb);n+=1){let r=e[o+t*Qy+n]??0;r<d||(f+=r,p+=r*n,m+=r*t)}r.push({x:(f?p/f:l)*n/Qy,y:(f?m/f:u)*t/Qy})}if(i<$y)throw Error(U.DOCUMENT_NOT_FOUND);return nb({polygon:r})}})),ab,ob=t((()=>{ab=({face:e,polygon:t})=>{if(!e)return!1;let n={x:e.boundingRect.x+e.boundingRect.width/2,y:e.boundingRect.y+e.boundingRect.height/2},r=!1;for(let e=0,i=t.length-1;e<t.length;i=e++){let a=t[e],o=t[i];a.y>n.y!=o.y>n.y&&n.x<(o.x-a.x)*(n.y-a.y)/(o.y-a.y)+a.x&&(r=!r)}return r}})),sb,cb=t((()=>{dd(),sb=z().regex(/^data:image\/jpeg;base64,(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/).meta({format:`data-url`,contentEncoding:`base64`,contentMediaType:`image/jpeg`})})),lb,ub,db,fb,pb,mb,hb,gb,_b,vb,yb,bb,xb,Sb=t((()=>{dd(),W(),cb(),lb=[`faceStraight`,`faceUp`,`faceLeft`,`faceRight`,`faceSmile`],ub={faceDown:{pitch:20},faceLeft:{yaw:30},faceRight:{yaw:-30},faceTiltLeft:{roll:15},faceTiltRight:{roll:-15},faceUp:{pitch:-20}},db=Ql(lb),fb=z().min(1).max(255),pb=Ql([`enroll`,`unlock`,`forget`]),mb=Ql([`enroll`,`unlock`]),hb=Ql([`pending`,`started`,`failed`,`completed`]),gb=B({token:z().min(32).max(128),userId:fb.optional()}),gb.extend({poses:ql(db).min(1).max(lb.length),faces:ql(sb).min(1).max(lb.length)}),_b=ql(Hl().finite()).length(512).refine(e=>Math.abs(Math.hypot(...e)-1)<.001),Zl(db,_b).and(B({faceStraight:_b})),vb=B({pose:db,matched:Wl(),score:Hl().min(-1).max(1)}),yb=ql(db).min(1).max(lb.length).refine(e=>e[0]===`faceStraight`&&new Set(e).size===e.length),B({operation:mb,userId:fb.optional(),poses:yb.optional()}).refine(e=>e.operation===`enroll`||e.userId!==void 0&&e.poses===void 0),B({userId:fb}).strict(),bb=B({userId:fb}),bb.extend({operation:pb,poses:ql(db).max(lb.length),expiresAt:z()}),xb=bb.extend({matched:Wl(),matches:ql(vb).max(2),reason:fd.nullable()}),B({vectors:ql(B({pose:db,vector:_b})).max(lb.length),reason:fd.nullable()}),B({search:z().default(``)}),xb.extend({complete:Wl(),token:z().optional()}),bb.extend({token:z(),operationId:z().uuid()}),B({operationId:z().uuid(),operation:pb,userId:fb,status:hb}),B({origin:z().nullable(),ip:z().nullable(),user_agent:z().nullable(),language:z().nullable()})})),Cb,wb=t((()=>{Cb=({blendshapes:e})=>{let t=e.eyeBlinkLeft??0,n=e.eyeBlinkRight??0;return t>=.5&&n<=.35&&t>=n+.15}})),Tb,Eb,Db,Ob=t((()=>{Sb(),wb(),Tb=({axis:e,target:t,tolerance:n,value:r})=>r>=t-n&&r<=t+n?null:e===`yaw`?t>0?r<t?`FACEKEY_TURN_HEAD_LEFT`:`FACEKEY_TURN_HEAD_LESS`:r>t?`FACEKEY_TURN_HEAD_RIGHT`:`FACEKEY_TURN_HEAD_LESS`:e===`pitch`?t>0?r<t?`FACEKEY_LOWER_HEAD`:`FACEKEY_LOWER_HEAD_LESS`:r>t?`FACEKEY_RAISE_HEAD`:`FACEKEY_RAISE_HEAD_LESS`:t>0?r<t?`FACEKEY_TILT_HEAD_LEFT`:`FACEKEY_TILT_HEAD_LESS`:r>t?`FACEKEY_TILT_HEAD_RIGHT`:`FACEKEY_TILT_HEAD_LESS`,Eb=({pitch:e,yaw:t,roll:n,options:r})=>n<-r.maxRoll?`FACEKEY_TILT_HEAD_LEFT`:n>r.maxRoll?`FACEKEY_TILT_HEAD_RIGHT`:t<r.minYaw?`FACEKEY_TURN_HEAD_LEFT`:t>r.maxYaw?`FACEKEY_TURN_HEAD_RIGHT`:e<r.minPitch?`FACEKEY_LOWER_HEAD`:e>r.maxPitch?`FACEKEY_RAISE_HEAD`:null,Db=({blendshapes:e,pitch:t,yaw:n,roll:r,pose:i,options:a})=>{if(i===`faceSmile`)return Eb({pitch:t,yaw:n,roll:r,options:a})||((e.mouthSmileLeft??0)>=.5&&(e.mouthSmileRight??0)>=.5?null:`FACEKEY_SMILE_REQUIRED`);if(i===`faceWinkLeft`)return Eb({pitch:t,yaw:n,roll:r,options:a})||(Cb({blendshapes:e,pose:i})?null:`FACEKEY_WINK_LEFT_REQUIRED`);let o=ub[i];if(!o)return Eb({pitch:t,yaw:n,roll:r,options:a});if(o.roll===void 0){if(r<-a.maxRoll)return`FACEKEY_TILT_HEAD_LEFT`;if(r>a.maxRoll)return`FACEKEY_TILT_HEAD_RIGHT`}if(o.yaw===void 0){if(n<a.minYaw)return`FACEKEY_TURN_HEAD_LEFT`;if(n>a.maxYaw)return`FACEKEY_TURN_HEAD_RIGHT`}if(o.pitch===void 0){if(t<a.minPitch)return`FACEKEY_LOWER_HEAD`;if(t>a.maxPitch)return`FACEKEY_RAISE_HEAD`}let s=a.tolerance??15;return o.roll===void 0?o.yaw===void 0?o.pitch===void 0?null:Tb({axis:`pitch`,target:o.pitch,tolerance:s,value:t}):Tb({axis:`yaw`,target:o.yaw,tolerance:s,value:n}):o.roll>0&&r<=a.maxRoll?`FACEKEY_TILT_HEAD_LEFT`:o.roll<0&&r>=-a.maxRoll?`FACEKEY_TILT_HEAD_RIGHT`:Tb({axis:`roll`,target:o.roll,tolerance:s,value:r})}})),kb,Ab,jb,Mb,Nb=t((()=>{W(),kb=.6,Ab=({first:e,second:t})=>{if(e.length!==t.length||e.length===0)throw Error(U.INVALID_MODEL_OUTPUT);let n=e.reduce((e,n,r)=>e+n*t[r],0);return Math.max(-1,Math.min(1,n))},jb=({score:e,threshold:t=kb})=>({matched:e>t,score:Math.round(e*100)/100}),Mb=({first:e,second:t})=>Math.max(Ab({first:e.rgb,second:t.rgb}),Ab({first:e.grayscale,second:t.grayscale}))})),Pb,Fb=t((()=>{Pb=({homography:e,point:t})=>{let n=e[6]*t.x+e[7]*t.y+e[8];return{x:(e[0]*t.x+e[1]*t.y+e[2])/n,y:(e[3]*t.x+e[4]*t.y+e[5])/n}}})),Ib=t((()=>{Ob(),wb()})),Lb,Rb,zb,Bb,Vb,Hb,Ub=t((()=>{Lb=8,Rb=.16,zb=({x:e,y:t,width:n,height:r})=>{let i=e/n,a=t/r;return i<.2||i>=.8||a<.2||a>=.8},Bb=({value:e})=>{let t=0,n=e;for(;n;)t+=n&1,n>>>=1;return t},Vb=({image:e})=>{let t=[];for(let n=0;n<Lb;n+=1)for(let r=0;r<Lb;r+=1){let i=0,a=0,o=Math.floor(n*e.height/Lb),s=Math.floor((n+1)*e.height/Lb),c=Math.floor(r*e.width/Lb),l=Math.floor((r+1)*e.width/Lb);for(let t=o;t<s;t+=1)for(let n=c;n<l;n+=1){if(!zb({height:e.height,width:e.width,x:n,y:t}))continue;let r=(t*e.width+n)*4;i+=(e.data[r]??0)*.299+(e.data[r+1]??0)*.587+(e.data[r+2]??0)*.114,a+=1}t.push(a?i/a:0)}let n=t.reduce((e,t)=>e+t,0)/t.length,r=new Uint8Array(Math.ceil(t.length/8));for(let[e,i]of t.entries())i>=n&&(r[Math.floor(e/8)]|=1<<e%8);return{appearanceHash:r}},Hb=({first:e,second:t})=>{if(e.appearanceHash.length!==t.appearanceHash.length)return{distance:1,matched:!1};let n=e.appearanceHash.reduce((e,n,r)=>e+Bb({value:n^(t.appearanceHash[r]??0)}),0)/(e.appearanceHash.length*8);return{distance:n,matched:n<=Rb}}})),Wb=t((()=>{bg(),Vy(),Zy(),ib(),zh(),fy(),qh(),ag(),lg(),ob(),Jy(),Ob(),Nb(),Fb(),Ib(),Tm(),ky(),Ub(),jy()})),Gb,Kb,qb=t((()=>{W(),km(),Gb=({outputs:e})=>{for(let t of new Set(Object.values(e)))t.dispose()},Kb=async({label:e,session:t,feeds:n})=>{let r=performance.now();try{return await t.run(n)}catch(e){throw Error(pd({error:e,fallback:U.INFERENCE_FAILED}),{cause:e})}finally{for(let e of new Set(Object.values(n)))e.dispose();Dm({category:`inference`,duration:performance.now()-r,key:e})}}})),Jb,Yb,Xb,Zb,Qb,$b,ex=t((()=>{W(),_h(),qb(),Jb=224,Yb=256,Xb=[0,90,180,270],Zb=[.485,.456,.406],Qb=[.229,.224,.225],$b=({runtime:e})=>{let t=async()=>{await e.session({filename:`do.ort`})},n=({frame:t,boundingRect:n={x:0,y:0,width:t.width,height:t.height}})=>{let r=Math.max(0,Math.floor(n.x)),i=Math.max(0,Math.floor(n.y)),a=Math.min(t.width,Math.ceil(n.x+n.width))-r,o=Math.min(t.height,Math.ceil(n.y+n.height))-i;if(a<=0||o<=0)throw Error(U.IMAGE_PROCESSING_FAILED);let s=Yb/Math.min(a,o),c=Math.round(a*s),l=Math.round(o*s),u=e.createCanvas(Jb,Jb),d=u.getContext(`2d`,{willReadFrequently:!0});if(!d)throw Error(U.IMAGE_PROCESSING_FAILED);d.drawImage(t,r,i,a,o,-Math.floor((c-Jb)/2),-Math.floor((l-Jb)/2),c,l);let{data:f}=d.getImageData(0,0,Jb,Jb);gh({canvas:u});let p=50176,m=new Float32Array(p*3);for(let e=0;e<3;e+=1)for(let t=0;t<p;t+=1)m[e*p+t]=(f[t*4+e]/255-Zb[e])/Qb[e];return m};return{detectDocumentOrientation:async({frame:t,boundingRect:r})=>{let i=await e.session({filename:`do.ort`}),a=n({frame:t,boundingRect:r}),o=await Kb({label:`document.orientation`,session:i,feeds:{x:e.tensor(`float32`,a,[1,3,Jb,Jb])}});try{let e=o.fetch_name_0?.data;if(!(e instanceof Float32Array)||e.length!==4||e.some(e=>!Number.isFinite(e)||e<0||e>1))throw Error(U.INVALID_MODEL_OUTPUT);let t={0:e[0],90:e[1],180:e[2],270:e[3]},n=Xb.reduce((e,n)=>t[n]>t[e]?n:e);return{rotation:n,confidence:t[n],scores:t}}finally{Gb({outputs:o})}},loadDocumentOrientationDetector:t}}})),tx,nx=t((()=>{W(),Xh(),Wb(),ex(),_h(),qb(),tx=({runtime:e})=>{let{detectDocumentOrientation:t,loadDocumentOrientationDetector:n}=$b({runtime:e}),r=`dd.ort`,i=.15,a=.75,o=.03,s=.8,c=({from:e,to:t})=>Math.hypot(t.x-e.x,t.y-e.y),l=({origin:e,first:t,second:n})=>(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x),u=({polygon:e})=>{let t=0;for(let n=0;n<e.length;n+=1){let r=e[n],i=e[(n+1)%e.length];t+=r.x*i.y-i.x*r.y}return Math.abs(t/2)},d=async({frame:t,sourceOrientation:n=0})=>{let i=e.createCanvas(256,256),a=i.getContext(`2d`);if(!a)throw Error(U.IMAGE_PROCESSING_FAILED);a.translate(128,128),a.rotate(-n*Math.PI/180),a.drawImage(t,-128,-128,256,256);let o=a.getImageData(0,0,256,256);gh({canvas:i});let s=tb({image:{data:o.data,height:256,width:256}}),c=await e.session({filename:r}),l=await Kb({label:`document.box`,session:c,feeds:{img:e.tensor(`float32`,s,[1,3,256,256])}});try{let e=l.heatmap?.data;if(!(e instanceof Float32Array))throw Error(U.INVALID_MODEL_OUTPUT);try{let r=n%180?t.height:t.width,i=n%180?t.width:t.height;return{confidence:null,polygon:rb({heatmap:e,height:i,width:r})}}catch(e){if(e instanceof Error&&e.message===U.DOCUMENT_NOT_FOUND)return null;throw e}}finally{Gb({outputs:l})}},f=async({frame:e})=>{let n=await d({frame:e}),r=null;if(n){let i=Yh({polygon:n.polygon});i.width>0&&i.height>0&&(r=await t({frame:e,boundingRect:i}),r.rotation&&(n=await d({frame:e,sourceOrientation:r.rotation})))}let i=r!==null&&r.rotation%180!=0;return{detected:n,orientation:r,width:i?e.height:e.width,height:i?e.width:e.height}},p=({detection:e,frame:t,orientation:n})=>{let r=e.polygon.map(({x:e,y:r})=>n?.rotation===90?{x:t.width-1-r,y:e}:n?.rotation===180?{x:t.width-1-e,y:t.height-1-r}:n?.rotation===270?{x:r,y:t.height-1-e}:{x:e,y:r}),i=Jh({polygon:r});return{polygon:i,boundingRect:Yh({polygon:i}),...n?{orientation:n}:{}}},m=({frame:t})=>{let n=Math.min(1,480/Math.max(t.width,t.height)),r=e.createCanvas(Math.max(1,Math.round(t.width*n)),Math.max(1,Math.round(t.height*n))),i=r.getContext(`2d`,{willReadFrequently:!0});if(!i)throw Error(U.IMAGE_PROCESSING_FAILED);return i.drawImage(t,0,0,r.width,r.height),{canvas:r,scale:n}},h=({data:e})=>{let t=new Uint8Array(e.length/4);for(let n=0;n<t.length;n+=1){let r=n*4;t[n]=Math.round(e[r]*.299+e[r+1]*.587+e[r+2]*.114)}return t},g=({pixels:e,width:t,height:n})=>{let r=0,i=0,a=0;for(let o=1;o<n-1;o+=1)for(let n=1;n<t-1;n+=1){let s=e[o*t+n]*8-(e[(o-1)*t+n]+e[(o+1)*t+n]+e[o*t+n-1]+e[o*t+n+1]+e[(o-1)*t+n-1]+e[(o-1)*t+n+1]+e[(o+1)*t+n-1]+e[(o+1)*t+n+1]);i+=s,a+=s*s,r+=1}if(!r)return 0;let o=i/r;return Math.max(0,a/r-o*o)},_=({previous:e,current:t,next:n})=>{let r=e.x-t.x,i=e.y-t.y,a=n.x-t.x,o=n.y-t.y,s=Math.hypot(r,i)*Math.hypot(a,o);return s?Math.acos(Math.max(-1,Math.min(1,(r*a+i*o)/s)))*180/Math.PI:0},v=({first:e,second:t})=>{let n=Math.hypot(e.x,e.y),r=Math.hypot(t.x,t.y);if(!n||!r)return 90;let i=Math.abs(e.x*t.y-e.y*t.x)/(n*r);return Math.asin(Math.min(1,i))*180/Math.PI},y=({first:e,second:t})=>Math.min(e,t)/Math.max(e,t),b=({polygon:e})=>{if(e.length!==4||e.some(e=>!Number.isFinite(e.x)||!Number.isFinite(e.y)))return!1;let t=e.map((t,n)=>c({from:t,to:e[(n+1)%e.length]}));if(t.some(e=>e<=0))return!1;let n=e.map((t,n)=>l({origin:t,first:e[(n+1)%e.length],second:e[(n+2)%e.length]}));if(!n.every(e=>e>0)&&!n.every(e=>e<0))return!1;let r=e.map((t,n)=>{let r=e[(n+1)%e.length];return{x:r.x-t.x,y:r.y-t.y}}),i=v({first:r[0],second:r[2]})<=36&&v({first:r[1],second:r[3]})<=36,a=y({first:t[0],second:t[2]})>=s&&y({first:t[1],second:t[3]})>=s;return i&&a},x=({height:e,minDocumentBoxRatio:t,polygon:n,width:r})=>{if(n.length!==4)return{detection:null,rejection:`polygon_invalid`};if(!b({polygon:n}))return{detection:null,rejection:`geometry`};let i=r,s=e;if(n.map((e,t)=>_({previous:n[(t-1+n.length)%n.length],current:e,next:n[(t+1)%n.length]})).some(e=>e<35||e>145))return{detection:null,rejection:`corner_angle`};let l=[c({from:n[0],to:n[1]}),c({from:n[2],to:n[3]})],d=[c({from:n[1],to:n[2]}),c({from:n[3],to:n[0]})],f=(l[0]+l[1])/2,p=(d[0]+d[1])/2,m=Math.max(f,p)/Math.min(f,p),h=u({polygon:n})/(i*s);if(m<1.25||m>2.4)return{detection:null,rejection:`aspect_ratio`};if(h<t)return{detection:null,rejection:`coverage_low`};if(h>.99)return{detection:null,rejection:`coverage_high`};let g=n.some(e=>e.x<i*o||e.y<s*o||e.x>i*.97||e.y>s*.97);if(h>a&&g)return{detection:null,rejection:`edge_proximity`};let v=n.some(e=>e.y<s*o)&&n.some(e=>e.y>s*.97)||n.some(e=>e.x<i*o)&&n.some(e=>e.x>i*.97);if(i>s&&v&&h<a)return{detection:null,rejection:`opposite_edges`};let y=n,x=y.map(e=>e.x),S=y.map(e=>e.y),C=Math.min(...x),w=Math.min(...S),T=Math.max(...x),E=Math.max(...S);return{detection:{polygon:y,boundingRect:{x:C,y:w,width:T-C,height:E-w}},rejection:null}},S=async()=>{await e.session({filename:r})},C=async({frame:e,minDocumentBoxRatio:t=i})=>{let{canvas:n}=m({frame:e}),r=n.getContext(`2d`,{willReadFrequently:!0});if(!r)throw Error(U.IMAGE_PROCESSING_FAILED);let a=r.getImageData(0,0,n.width,n.height),o=n.width,s=n.height;gh({canvas:n});let c=h({data:a.data}),l=g({pixels:c,width:o,height:s}),{detected:u,orientation:d,width:_,height:v}=await f({frame:e}),y=u?x({height:v,minDocumentBoxRatio:t,polygon:u.polygon,width:_}):{detection:null,rejection:null},b={};return y.rejection&&(b[y.rejection]=1),{detection:y.detection?p({detection:y.detection,frame:e,orientation:d}):null,diagnostics:{accepted:+!!y.detection,confidence:u?.confidence??null,rejected:b},isBlurry:l<1e3,sharpness:l}};return{loadDocumentBoxDetector:S,detectDocumentOrientation:t,loadDocumentOrientationDetector:n,analyzeDocument:C,detectDocument:async e=>(await C({frame:e})).detection,detectDocumentBox:async e=>{let t=await d({frame:e});if(!t)return null;let n=x({height:e.height,minDocumentBoxRatio:i,polygon:t.polygon,width:e.width});return n.detection?p({detection:n.detection,frame:e,orientation:null}):null}}}})),rx,ix,ax=t((()=>{Wb(),ih(),qb(),rx=({detection:e,frame:t})=>{let n=Math.max(e.boundingRect.width,e.boundingRect.height)*1.1,r=Math.max(1,Math.min(Math.ceil(n),t.width,t.height)),i=e.boundingRect.x+e.boundingRect.width/2,a=e.boundingRect.y+e.boundingRect.height/2;return{size:r,x:Math.max(0,Math.min(t.width-r,Math.round(i-r/2))),y:Math.max(0,Math.min(t.height-r,Math.round(a-r/2)))}},ix=({runtime:e,imageFromImageBitmap:t})=>{let n=`_neutral.browDownLeft.browDownRight.browInnerUp.browOuterUpLeft.browOuterUpRight.cheekPuff.cheekSquintLeft.cheekSquintRight.eyeBlinkLeft.eyeBlinkRight.eyeLookDownLeft.eyeLookDownRight.eyeLookInLeft.eyeLookInRight.eyeLookOutLeft.eyeLookOutRight.eyeLookUpLeft.eyeLookUpRight.eyeSquintLeft.eyeSquintRight.eyeWideLeft.eyeWideRight.jawForward.jawLeft.jawOpen.jawRight.mouthClose.mouthDimpleLeft.mouthDimpleRight.mouthFrownLeft.mouthFrownRight.mouthFunnel.mouthLeft.mouthLowerDownLeft.mouthLowerDownRight.mouthPressLeft.mouthPressRight.mouthPucker.mouthRight.mouthRollLower.mouthRollUpper.mouthShrugLower.mouthShrugUpper.mouthSmileLeft.mouthSmileRight.mouthStretchLeft.mouthStretchRight.mouthUpperUpLeft.mouthUpperUpRight.noseSneerLeft.noseSneerRight`.split(`.`),r=[0,1,4,5,6,7,8,10,13,14,17,21,33,37,39,40,46,52,53,54,55,58,61,63,65,66,67,70,78,80,81,82,84,87,88,91,93,95,103,105,107,109,127,132,133,136,144,145,146,148,149,150,152,153,154,155,157,158,159,160,161,162,163,168,172,173,176,178,181,185,191,195,197,234,246,249,251,263,267,269,270,276,282,283,284,285,288,291,293,295,296,297,300,308,310,311,312,314,317,318,321,323,324,332,334,336,338,356,361,362,365,373,374,375,377,378,379,380,381,382,384,385,386,387,388,389,390,397,398,400,402,405,409,415,454,466,468,469,470,471,472,473,474,475,476,477],i=`standard`,a=({frame:e,height:n,width:r})=>t({frame:e,height:n,width:r}).data,o=({outputs:e,scale:t,threshold:n})=>{let r=[];for(let i of[8,16,32]){let a=e[`score_${i}`]??e[`cls_${i}`],o=e[`bbox_${i}`],s=e[`kps_${i}`],c=e[`obj_${i}`];if(!a||!o||!s)continue;let l=a.data,u=c?.data,d=o.data,f=s.data,p=640/i;for(let e=0;e<l.length;e+=1){let a=l[e]*(u?u[e]:1);if(a<n)continue;let o=Math.floor(e/2),s=(o%p+.5)*i,c=(Math.floor(o/p)+.5)*i,m=e*4,h=e*10,g=e=>({x:(s+f[h+e*2]*i)/t,y:(c+f[h+e*2+1]*i)/t});r.push({boundingRect:{x:(s-d[m]*i)/t,y:(c-d[m+1]*i)/t,width:(d[m]+d[m+2])*i/t,height:(d[m+1]+d[m+3])*i/t},score:a,keypoints:{leftEye:g(0),rightEye:g(1),nose:g(2),mouthLeft:g(3),mouthRight:g(4)}})}}return Wy({detections:r,threshold:.4})},s=async({frame:t,faceDetector:n})=>{let r=640/Math.max(t.width,t.height),i=Math.round(t.width*r),s=Math.round(t.height*r),c=a({frame:t,height:s,width:i}),l=Hy({data:c,height:s,width:i,normalize:e=>(e-127.5)/128}),u=new Float32Array(1228800);for(let e=0;e<3;e+=1)for(let t=0;t<s;t+=1)u.set(l.subarray(e*i*s+t*i,e*i*s+(t+1)*i),e*640*640+t*640);let d=await e.session({filename:rh[n]}),f=await Kb({label:`face.detector`,session:d,feeds:{[d.inputNames[0]]:e.tensor(`float32`,u,[1,3,640,640])}});try{return n===`standard`?Xy({outputs:Yy({outputs:f}),scale:r,threshold:.5}):o({outputs:f,scale:r,threshold:.5})}finally{Gb({outputs:f})}},c=async({frame:t})=>{let n=a({frame:t,height:128,width:128}),r=new Float32Array(49152);for(let e=0;e<49152;e+=1)r[e]=n[Math.floor(e/3)*4+e%3]/127.5-1;let i=await e.session({filename:rh.low}),o=await Kb({label:`face.detector`,session:i,feeds:{[i.inputNames[0]]:e.tensor(`float32`,r,[1,128,128,3])}});try{let e=o.regressors.data,n=o.classificators.data,r=[],i=[];for(let{count:e,copies:t}of[{count:16,copies:2},{count:8,copies:6}])for(let n=0;n<e;n+=1)for(let r=0;r<e;r+=1)for(let a=0;a<t;a+=1)i.push({x:(r+.5)/e,y:(n+.5)/e});for(let a=0;a<n.length;a+=1){let o=1/(1+Math.exp(-n[a]));if(o<.5)continue;let s=a*16,c=i[a];if(!c)continue;let l=n=>({x:(e[s+5+n*2]+c.x*128)*(t.width/128),y:(e[s+4+n*2]+c.y*128)*(t.height/128)}),u=e[s+3]*(t.width/128),d=e[s+2]*(t.height/128),f=(e[s+1]+c.x*128)*(t.width/128),p=(e[s]+c.y*128)*(t.height/128);r.push({boundingRect:{x:f-u/2,y:p-d/2,width:u,height:d},score:o,keypoints:{leftEye:l(0),rightEye:l(1),nose:l(2),mouthLeft:l(3),mouthRight:l(4)}})}return Wy({detections:r,threshold:.3})}finally{Gb({outputs:o})}},l=async({blendshapes:i=!0,detection:a,frame:o})=>{let{size:s,x:c,y:l}=rx({detection:a,frame:o}),u=t({frame:o,height:256,width:256,sourceRect:{x:c,y:l,width:s,height:s}}).data,d=await e.session({filename:`fl.ort`}),f=await Kb({label:`face.landmarks`,session:d,feeds:{[d.inputNames[0]]:e.tensor(`float32`,Hy({data:u,height:256,width:256,normalize:e=>e/255}),[1,3,256,256])}});try{if(f.score.data[0]<.5)return null;let t=f.landmarks.data,u=Array.from({length:478},(e,n)=>({x:c+t[n*3]*s/256,y:l+t[n*3+1]*s/256,z:t[n*3+2]*s/256})),d=u[33],p=u[263],m=u[1],h=(m.y-(d.y+p.y)/2)/Math.abs(p.x-d.x)*100,g=(m.x-(d.x+p.x)/2)/Math.abs(p.x-d.x)*100,_=new Float32Array(n.length);if(i){let t=new Float32Array(292);for(let e=0;e<r.length;e+=1){let n=u[r[e]];t[e*2]=n.x,t[e*2+1]=n.y}let n=await e.session({filename:`fe.ort`}),i=await Kb({label:`face.blendshape`,session:n,feeds:{[n.inputNames[0]]:e.tensor(`float32`,t,[1,146,2])}});try{_=i[n.outputNames[0]].data}finally{Gb({outputs:i})}}return{blendshapes:Object.fromEntries(n.map((e,t)=>[e,_[t]??0])),pitch:h-54,yaw:g-5,roll:Math.atan2(p.y-d.y,p.x-d.x)*180/Math.PI,boundingRect:a.boundingRect,mesh:{height:o.height,landmarks:u,width:o.width}}}finally{Gb({outputs:f})}},u=async({faceDetector:t=`standard`}={})=>{i=t,await Promise.all([e.session({filename:rh[t]}),e.session({filename:`fl.ort`}),e.session({filename:`fe.ort`})])},d=async({blendshapes:e=!0,frame:t})=>{let n=i===`low`?await c({frame:t}):await s({frame:t,faceDetector:i});return(await Promise.all(n.map(n=>l({blendshapes:e,detection:n,frame:t})))).filter(e=>e!==null)},f=async e=>(await d({frame:e}))[0]??null,p=async({blendshapes:t=!0,frame:n,tileHeight:r,tileWidth:i})=>{let a=[];for(let o of qy({frameSize:n.height,tileSize:r}))for(let s of qy({frameSize:n.width,tileSize:i})){let c=await e.createImageBitmap(n,s,o,i,r);try{let e=await d({blendshapes:t,frame:c});a.push(...e.map(e=>Gy({face:e,x:s,y:o})))}finally{c.close()}}return a},m=async({blendshapes:e=!0,frame:t})=>await p({blendshapes:e,frame:t,tileHeight:Math.ceil(t.height/2),tileWidth:Math.ceil(t.width/2)}),h=async({frame:e})=>{let t=await d({blendshapes:!1,frame:e}),n=await p({blendshapes:!1,frame:e,tileHeight:Math.ceil(e.height*.4),tileWidth:Math.ceil(e.width*.4)});return Ky({faces:[...t,...n]})},g=({detection:e,x:t,y:n})=>({...e,boundingRect:{...e.boundingRect,x:e.boundingRect.x+t,y:e.boundingRect.y+n},keypoints:Object.fromEntries(Object.entries(e.keypoints).map(([e,r])=>[e,{x:r.x+t,y:r.y+n}]))}),_=async({frame:t,tileHeight:n,tileWidth:r})=>{let i=[];for(let a of qy({frameSize:t.height,tileSize:n}))for(let o of qy({frameSize:t.width,tileSize:r})){let s=await e.createImageBitmap(t,o,a,r,n);try{let e=await c({frame:s});i.push(...e.map(e=>g({detection:e,x:o,y:a})))}finally{s.close()}}return i},v=async({frame:e})=>{let t=await c({frame:e}),n=await _({frame:e,tileHeight:Math.ceil(e.height*.4),tileWidth:Math.ceil(e.width*.4)});return Wy({detections:[...t,...n],threshold:.3})},y=async(e,t={})=>{let n=await d({blendshapes:t.blendshapes,frame:e});if(i!==`low`)return n;let r=await m({blendshapes:t.blendshapes,frame:e});return Ky({faces:[...n,...r]})},b=({detection:e,face:t})=>ab({face:t,polygon:e.polygon});return{loadFaceDetector:u,detectFace:f,detectPictureFaces:y,faceIsInsideDocument:b,detectDocumentFaces:async({detection:t,frame:n})=>{let r=await e.createImageBitmap(n,0,0,Math.ceil(n.width/2),n.height),a;try{a=(i===`low`?await h({frame:r}):await y(r,{blendshapes:!1})).map(e=>({...e,mesh:{...e.mesh,height:n.height,width:n.width}}))}finally{r.close()}return{faces:a.filter(e=>b({detection:t,face:e})).sort((e,t)=>t.boundingRect.width*t.boundingRect.height-e.boundingRect.width*e.boundingRect.height),hasPictureFace:a.length>0,pictureFaces:a}},detectDocumentFacePresence:async({detection:t,frame:n})=>{let r=await e.createImageBitmap(n,0,0,Math.ceil(n.width/2),n.height);try{return(i===`low`?await v({frame:r}):await s({frame:r,faceDetector:i})).some(e=>b({detection:t,face:e}))}finally{r.close()}}}}})),ox,sx,cx=t((()=>{zh(),ag(),lg(),Og(),jy(),$m(),yh(),ox=({candidate:e,identity:t})=>[{missing:!t?.holder.last_name,pattern:/^\s*1[.:)]\s+\p{L}/u},{missing:!t?.holder.first_name,pattern:/^\s*2[.:)]\s+\p{L}/u},{missing:!t?.holder.birth_date,pattern:/^\s*3[.:)]\s+\d{1,2}[./-]\d{1,2}[./-]\d{2,4}/u},{missing:!t?.document.number,pattern:/^\s*5[.:)]\s+[A-Z0-9]/u}].flatMap(({missing:t,pattern:n})=>{if(!t)return[];let r=e.lines.find(e=>n.test(e.text));return r?[r]:[]}),sx=({runtime:e,orientDocumentFrame:t,getOcr:n})=>{let r=`auto`,i=vh({runtime:e}),a=async({engine:t=r,language:i=`eng`}={})=>{await n({environment:e.environment,engine:t,language:i})},o=async({classificationImage:t,engine:a=r,frame:o,language:s,image:c})=>{if(o.width<200||o.height<100)return null;let l=c??ig({image:i({frame:o}),polygon:[{x:0,y:0},{x:o.width,y:0},{x:o.width,y:o.height},{x:0,y:o.height}]}),u=await(await n({environment:e.environment,engine:`tiny`,language:`latin`})).recognize({image:l}),d=Ay({result:u}),f=t??i({frame:o}),p=Lh({image:f,text:u.text,codes:d?[d]:[]}),m=p&&(p.document===`passport`||p.europeanDrivingLicense);if(p?.europeanDrivingLicense){let t=Dg({ocr:u,image:f});if(!sg({identity:t})){let r=await(await n({environment:e.environment,engine:`small`,language:`latin`})).recognize({image:l}),i=Dg({ocr:r,image:f}),a=Lh({image:f,text:r.text,codes:[]});if(a?.europeanDrivingLicense&&sg({identity:i}))u=r;else if(a?.europeanDrivingLicense){let e=ox({candidate:r,identity:t});if(e.length){let t=[...u.lines,...e];u={...u,lines:t,text:t.map(e=>e.text).join(`
|
|
71
|
-
`)}}}}}else if(!m){let t=Ym({language:s??`eng`}),r=await n({environment:e.environment,engine:a,language:t});r.model!==`tiny`&&(u=await r.recognize({image:l}))}let h=o.width/u.width,g=o.height/u.height,_=({x:e,y:t,width:n,height:r})=>({x:e*h,y:t*g,width:n*h,height:r*g});return{...u,width:o.width,height:o.height,lines:u.lines.map(e=>({...e,box:_(e.box),words:e.words.map(e=>({...e,box:_(e.box)}))}))}},s=async e=>await o(e)??{height:e.frame.height,lines:[],text:``,width:e.frame.width};return{loadTextDetector:a,readRectifiedText:o,detectRectifiedText:s,detectDocumentText:async({engine:e=r,frame:n,language:i,polygon:a})=>{let o=await t({frame:n,polygon:a});if(!o)return{height:0,lines:[],rotation:0,text:``,width:0};try{return{...await s({engine:e,frame:o.frame,language:i}),rotation:o.orientation.rotation}}finally{o.frame.close()}}}}})),lx,ux=t((()=>{W(),Xh(),Wb(),ex(),lx=({runtime:e})=>{let{detectDocumentOrientation:t}=$b({runtime:e}),n={left:[33,133],right:[263,362]},r=({matrix:e,values:t})=>{let n=e.map((e,n)=>[...e,t[n]]);for(let e=0;e<n.length;e+=1){let t=e;for(let r=e+1;r<n.length;r+=1)Math.abs(n[r][e])>Math.abs(n[t][e])&&(t=r);if(Math.abs(n[t][e])<1e-8)return null;[n[e],n[t]]=[n[t],n[e]];let r=n[e][e];for(let t=e;t<=n.length;t+=1)n[e][t]/=r;for(let t=0;t<n.length;t+=1){if(t===e)continue;let r=n[t][e];for(let i=e;i<=n.length;i+=1)n[t][i]-=r*n[e][i]}}return n.map(e=>e[n.length])},i=({from:e,to:t})=>{let n=[],i=[];for(let[r,a]of e.entries()){let e=t[r];n.push([a.x,a.y,1,0,0,0,-e.x*a.x,-e.x*a.y]),i.push(e.x),n.push([0,0,0,a.x,a.y,1,-e.y*a.x,-e.y*a.y]),i.push(e.y)}let a=r({matrix:n,values:i});return a?[...a,1]:null},a=Pb,o=({frame:t,polygon:n,rotation:r=0})=>{let a=Yh({polygon:n}),o=Math.max(0,Math.floor(a.x)),s=Math.max(0,Math.floor(a.y)),c=Math.max(1,Math.min(t.width-o,Math.ceil(a.width))),l=Math.max(1,Math.min(t.height-s,Math.ceil(a.height))),u=r%180?l:c,d=r%180?c:l,f=e.createCanvas(u,d),p=f.getContext(`2d`);if(!p)throw Error(U.IMAGE_PROCESSING_FAILED);r===90?(p.translate(0,d),p.rotate(-Math.PI/2)):r===180?(p.translate(u,d),p.rotate(Math.PI)):r===270&&(p.translate(u,0),p.rotate(Math.PI/2)),p.drawImage(t,o,s,c,l,0,0,c,l);let m=o+c,h=s+l,g=i({from:[{x:0,y:0},{x:u,y:0},{x:u,y:d},{x:0,y:d}],to:r===90?[{x:m,y:s},{x:m,y:h},{x:o,y:h},{x:o,y:s}]:r===180?[{x:m,y:h},{x:o,y:h},{x:o,y:s},{x:m,y:s}]:r===270?[{x:o,y:h},{x:o,y:s},{x:m,y:s},{x:m,y:h}]:[{x:o,y:s},{x:m,y:s},{x:m,y:h},{x:o,y:h}]});return g?{frame:f.transferToImageBitmap(),height:d,sourceHeight:t.height,sourceWidth:t.width,toSource:g,width:u}:null},s=async({frame:e,polygon:n,orientation:r})=>{if(n.length!==4)return null;let i=r??await t({frame:e,boundingRect:Yh({polygon:n})}),a=o({frame:e,polygon:n,rotation:i.rotation});return a?{...a,orientation:i}:null},c=({document:e,face:t})=>{let n=t.mesh.landmarks.map(({x:t,y:n,z:r})=>({...a({homography:e.toSource,point:{x:t,y:n}}),z:r})),r=[{x:t.boundingRect.x,y:t.boundingRect.y},{x:t.boundingRect.x+t.boundingRect.width,y:t.boundingRect.y},{x:t.boundingRect.x+t.boundingRect.width,y:t.boundingRect.y+t.boundingRect.height},{x:t.boundingRect.x,y:t.boundingRect.y+t.boundingRect.height}].map(t=>a({homography:e.toSource,point:t})),i=r.map(({x:e})=>e),o=r.map(({y:e})=>e),s={x:Math.min(...i),y:Math.min(...o),width:Math.max(...i)-Math.min(...i),height:Math.max(...o)-Math.min(...o)};return{...t,boundingRect:s,mesh:{...t.mesh,height:e.sourceHeight,landmarks:n,width:e.sourceWidth}}},l=({face:e})=>{let t=e.mesh.landmarks,r=n.left.map(e=>t[e]).filter(Boolean).map(({x:e,y:t})=>({x:e,y:t})),i=n.right.map(e=>t[e]).filter(Boolean).map(({x:e,y:t})=>({x:e,y:t})),a=[13,14].map(e=>t[e]).filter(Boolean).map(({x:e,y:t})=>({x:e,y:t}));return r.length!==2||i.length!==2||a.length!==2?null:{boundingRect:e.boundingRect,mouth:{x:(a[0].x+a[1].x)/2,y:(a[0].y+a[1].y)/2},leftEye:{x:(r[0].x+r[1].x)/2,y:(r[0].y+r[1].y)/2},rightEye:{x:(i[0].x+i[1].x)/2,y:(i[0].y+i[1].y)/2}}},u=({face:e,lines:t,maxAngleDifference:n})=>{let r=Math.atan2(e.rightEye.y-e.leftEye.y,e.rightEye.x-e.leftEye.x)*180/Math.PI,i=0;for(let a of t){let t=Math.abs(a.angle-r)%180,o=Math.min(t,180-t),s=a.box;!(s.y>=e.boundingRect.y&&s.y+s.height<=e.boundingRect.y+e.boundingRect.height)||o>n||s.x>e.boundingRect.x+e.boundingRect.width&&(i+=1)}return i};return{transformPoint:a,orientDocumentFrame:s,restoreRectifiedFace:c,rectifiedDocumentFace:l,documentAlignment:({face:e,lines:t,maxAngleDifference:n,maxFaceAreaRatio:r,maxFaceHeightRatio:i,maxFaceWidthRatio:a,minFaceAreaRatio:o,minFaceHeightRatio:s,minFaceWidthRatio:c,documentSize:l})=>{if(!e)return{faceAdjacentTextLineCount:0,angleDifference:null,eyesAngle:null,faceAreaRatio:0,faceAreaValid:!1,faceDimensionsValid:!1,faceHeightRatio:0,faceWidthRatio:0,textAngle:null,textParallel:!1,textSide:`unknown`};let d=e.boundingRect.width*e.boundingRect.height/(l.width*l.height),f=d>=o&&d<=r,p=e.boundingRect.width/l.width,m=e.boundingRect.height/l.height,h=p>=c&&p<=a&&m>=s&&m<=i,g=Math.atan2(e.rightEye.y-e.leftEye.y,e.rightEye.x-e.leftEye.x)*180/Math.PI,_=t.filter(t=>{let n=t.box;return n.y>=e.boundingRect.y&&n.y+n.height<=e.boundingRect.y+e.boundingRect.height&&n.x>e.boundingRect.x+e.boundingRect.width}),v=_.length?_.reduce((e,t)=>e+t.angle,0)/_.length:null,y=v===null?null:Math.abs(v-g)%180,b=y===null?null:Math.min(y,180-y),x=b!==null&&b<=n;return{faceAdjacentTextLineCount:u({face:e,lines:t,maxAngleDifference:n}),angleDifference:b,eyesAngle:g,faceAreaRatio:d,faceAreaValid:f,faceDimensionsValid:h,faceHeightRatio:m,faceWidthRatio:p,textAngle:v,textParallel:x,textSide:_.length?`right`:`unknown`}}}}})),dx,fx=t((()=>{W(),zh(),ag(),lg(),Og(),Wb(),Ry(),km(),_h(),yh(),dx=({runtime:e,documentAlignment:t,rectifiedDocumentFace:n,orientDocumentFrame:r,restoreRectifiedFace:i,analyzeDocument:a,faceDetection:o,faceMatch:s,textDetection:c})=>{let l=vh({runtime:e}),u=({frame:t,text:n})=>{let r=e.createCanvas(32,32),i=r.getContext(`2d`,{willReadFrequently:!0});if(!i)throw Error(U.IMAGE_PROCESSING_FAILED);i.drawImage(t,0,0,r.width,r.height);let{data:a}=i.getImageData(0,0,r.width,r.height);return gh({canvas:r}),Uh({data:a,height:32,text:n,width:32})},d=({current:e,front:t})=>{let n=Gh({current:e.signature,front:t}),r=[],i=e.signature?.textTokens.length??0,a=Kh({text:e.text.text})||e.text.lines.length>=2&&i>=2;return e.detection||r.push(U.DOCUMENT_NOT_FOUND),e.documentAnalysis.isBlurry&&r.push(U.DOCUMENT_BLURRY),e.hasPictureFace&&r.push(U.DOCUMENT_BACK_CONTAINS_FACE),a||r.push(U.DOCUMENT_TEXT_NOT_READABLE),n.distinct||r.push(U.DOCUMENT_BACK_NOT_DISTINCT),{distinct:n.distinct,imageDistance:n.imageDistance,reasons:r,textOverlap:n.textOverlap,valid:r.length===0}},f=({alignment:e,detection:t,documentAnalysis:n,faceContained:r,requiresFace:i,text:a})=>{let o=[];return t||o.push(U.DOCUMENT_NOT_FOUND),n.isBlurry&&o.push(U.DOCUMENT_BLURRY),i&&!r&&o.push(U.DOCUMENT_FACE_NOT_CONTAINED),(!a.text||a.lines.length<2)&&o.push(U.DOCUMENT_TEXT_NOT_READABLE),!i||e.faceAreaValid&&e.faceDimensionsValid||o.push(U.DOCUMENT_FACE_GEOMETRY_INVALID),i&&(e.faceAdjacentTextLineCount<2||!e.textParallel||e.textSide!==`right`)&&o.push(U.DOCUMENT_TEXT_ALIGNMENT_INVALID),o},p=async({classification:e,codes:r,ocr:a,options:c,documentAnalysis:l,document:d,text:p,prepareForMatch:m})=>{let h=l.detection,g=c.requiresFace??!0,_={boundingRect:{height:d.height,width:d.width,x:0,y:0},polygon:[{x:0,y:0},{x:d.width,y:0},{x:d.width,y:d.height},{x:0,y:d.height}]},v=g?await o.detectDocumentFaces({detection:_,frame:d.frame}):{faces:[],pictureFaces:[],hasPictureFace:await o.detectDocumentFacePresence({detection:_,frame:d.frame})},y=v.pictureFaces.map(e=>i({document:d,face:e})),b=u({frame:d.frame,text:p.text}),x=r.find(e=>e.type===`mrz`)??null,S=null;for(let u of v.faces.length?v.faces:[null]){let _=u?i({document:d,face:u}):null,C=u?n({face:u}):null,w=g&&h?o.faceIsInsideDocument({detection:h,face:_})&&y.every(e=>o.faceIsInsideDocument({detection:h,face:e})):!1,T=t({documentSize:{height:p.height,width:p.width},face:C,lines:p.lines,maxAngleDifference:c.maxDocumentTextAngleDifference,maxFaceAreaRatio:c.maxDocumentFaceAreaRatio,maxFaceHeightRatio:c.maxDocumentFaceHeightRatio,maxFaceWidthRatio:c.maxDocumentFaceWidthRatio,minFaceAreaRatio:c.minDocumentFaceAreaRatio,minFaceHeightRatio:c.minDocumentFaceHeightRatio,minFaceWidthRatio:c.minDocumentFaceWidthRatio}),E=f({alignment:T,detection:h,documentAnalysis:l,faceContained:w,requiresFace:g,text:p});g&&!e&&E.push(U.DOCUMENT_NOT_RECOGNIZED),e?.europeanDrivingLicense&&!sg({identity:e.identity})&&E.push(U.DOCUMENT_VALIDATION_FAILED);let ee=E.length===0,D=null,te=null;if(g&&ee&&u){let e=s.prepareFace({alignment:c.alignment??`eyes-nose-mouth`,face:u,frame:d.frame});if(!e)ee=!1,E.push(U.FACE_NOT_USABLE);else if(m){let t=await s.preparedFaceArtifacts({face:e});D=t?.embeddings??null,te=t?.images??null,t||(ee=!1,E.push(U.INVALID_MODEL_OUTPUT))}}let ne={identity:e?e.identity:null,orientation:d.orientation,ocr:a,mrz:x,alignment:T,detection:h,documentAnalysis:l,documentKind:e?e.document:null,europeanDrivingLicense:e?e.europeanDrivingLicense:!1,codes:r,documentToSource:d.toSource,embeddings:D,images:te,face:_,faceContained:w,hasPictureFace:v.hasPictureFace??y.length>0,failureReasons:E,pictureFaces:y,signature:b,text:p,valid:ee};if(ne.valid)return ne;S??=ne}if(!S)throw Error(U.INTERNAL_ERROR);return S},m=async({frame:n,options:i,documentAnalysis:a,prepareForMatch:o=!1})=>{let s=a.detection;if(!s){let e={height:0,lines:[],text:``,width:0},n=t({documentSize:{height:e.height,width:e.width},face:null,lines:e.lines,maxAngleDifference:i.maxDocumentTextAngleDifference,maxFaceAreaRatio:i.maxDocumentFaceAreaRatio,maxFaceHeightRatio:i.maxDocumentFaceHeightRatio,maxFaceWidthRatio:i.maxDocumentFaceWidthRatio,minFaceAreaRatio:i.minDocumentFaceAreaRatio,minFaceHeightRatio:i.minDocumentFaceHeightRatio,minFaceWidthRatio:i.minDocumentFaceWidthRatio});return{identity:null,orientation:null,ocr:null,mrz:null,codes:[],europeanDrivingLicense:!1,alignment:n,detection:s,documentAnalysis:a,documentKind:null,documentToSource:null,embeddings:null,face:null,faceContained:!1,failureReasons:f({alignment:n,detection:s,documentAnalysis:a,faceContained:!1,requiresFace:i.requiresFace??!0,text:e}),images:null,pictureFaces:[],hasPictureFace:!1,signature:null,text:e,valid:!1}}let u=await r({frame:n,polygon:s.polygon,orientation:s.orientation});if(!u)throw Error(U.IMAGE_PROCESSING_FAILED);try{let t=performance.now(),r=ig({image:l({frame:n}),polygon:s.polygon,sourceOrientation:u.orientation.rotation}),d=i.requiresFace===!1?`back`:`front`;Dm({category:`stages`,key:`ocr.prepare.${d}`,duration:performance.now()-t});let f=l({frame:u.frame}),m=await c.readRectifiedText({classificationImage:f,engine:i.ocrEngine,frame:u.frame,language:i.language,image:r}),h=m??{height:u.height,lines:[],text:``,width:u.width},g=m?Ay({result:m}):null,_=null;if(i.requiresFace===!1){let t=e.createImageData(f.width,f.height);t.data.set(f.data),_=await Om({key:`barcode.back`,operation:()=>Ly({image:t})})}let v=[g,_].filter(e=>e!==null),y=Lh({image:f,text:h.text,codes:v}),b=i.requiresFace!==!1&&y?.europeanDrivingLicense&&m?Dg({ocr:m,image:f}):null,x=y?{...y,identity:b}:null;return await p({ocr:m,classification:x,codes:v,options:i,documentAnalysis:a,document:u,prepareForMatch:o,text:h})}finally{u.frame.close()}},h=async({frame:e,options:t,prepareForMatch:n=!1})=>{let r=await a({frame:e,minDocumentBoxRatio:t.minDocumentBoxRatio});return await m({frame:e,options:t,documentAnalysis:r,prepareForMatch:n})},g=({analysis:e,isBack:t,front:n})=>{if(!e.ocr)return[U.DOCUMENT_TEXT_NOT_READABLE];if(t&&!n)return[U.CAPTURES_INCOMPLETE];if(!t&&!e.documentKind)return[U.DOCUMENT_NOT_RECOGNIZED];let r={ocr:e.ocr,codes:e.codes},i=t&&n?n:{document:e.documentKind,europeanDrivingLicense:e.europeanDrivingLicense,identity:e.identity};return cg({classification:i,front:t&&n?n:r,back:t?r:null}).reasons.filter(e=>t||e!==U.DOCUMENT_BACK_REQUIRED)};return{validateDocumentBack:d,analyzeDocumentFrame:h,hasValidDocumentSideData:e=>g(e).length===0,documentSideFailureReasons:g}}})),px,mx,hx=t((()=>{W(),Wb(),qb(),_h(),yh(),px={standard:{filename:`fm.ort`,layout:`nhwc`},high:{filename:`fmh.ort`,layout:`nhwc`},ultra:{filename:`fmu.ort`,layout:`nchw`}},mx=({runtime:e,orientDocumentFrame:t,detectDocument:n,faceDetection:r,detectFace:i,detectPictureFaces:a,faceMatcher:o=`ultra`})=>{let s=vh({runtime:e}),c=[10,338,297,332,284,251,389,356,454,323,361,288,397,365,379,378,400,377,152,148,176,149,150,136,172,58,132,93,234,127,162,21,54,103,67,109],l={"eyes-nose-mouth":{landmarks:[[33,133],[263,362],[1],[61],[291]],target:[[38.2946,51.6963],[73.5318,51.5014],[56.0252,71.7366],[41.5493,92.3655],[70.7299,92.2041]]}},u=({points:e})=>[e.reduce((e,[t])=>e+t,0)/e.length,e.reduce((e,[,t])=>e+t,0)/e.length],d=({source:e,target:t})=>{if(e.length<2||e.length!==t.length)return null;let[n,r]=u({points:e}),[i,a]=u({points:t}),o=0,s=0,c=0;for(let[l,[u,d]]of e.entries()){let[e,f]=t[l],p=u-n,m=d-r,h=e-i,g=f-a;o+=p*p+m*m,s+=p*h+m*g,c+=p*g-m*h}if(o<1e-8)return null;let l=s/o,d=c/o;return l*l+d*d<1e-8?null:[l,-d,i-l*n+d*r,d,l,a-d*n-l*r]},f=({height:e,minimumArea:t,polygon:n,width:r})=>{if(Math.abs(n.reduce((e,t,r)=>{let i=n[(r+1)%n.length];return e+t[0]*i[1]-i[0]*t[1]},0))/2<t)return null;let i=new Float32Array(r*e),a=Math.max(0,Math.ceil(Math.min(...n.map(([,e])=>e))-.5)),o=Math.min(e,Math.ceil(Math.max(...n.map(([,e])=>e))-.5));for(let e=a;e<o;e+=1){let t=[],a=e+.5;for(let e=0,r=n.length-1;e<n.length;r=e++){let[i,o]=n[r],[s,c]=n[e];o>a!=c>a&&t.push((s-i)*(a-o)/(c-o)+i)}t.sort((e,t)=>e-t);for(let n=0;n+1<t.length;n+=2){let a=Math.min(r,Math.max(0,Math.ceil(t[n]-.5))),o=Math.max(0,Math.min(r,Math.ceil(t[n+1]-.5)));i.fill(1,e*r+a,e*r+o)}}return i},p=({face:e,grayscale:t})=>{let{image:n,weights:r}=e,i=0,a=0,o=0,s=0;for(let e=0;e<r.length;e+=1){let t=r[e];if(!t)continue;let c=e*4,l=n[c]*.299+n[c+1]*.587+n[c+2]*.114;i+=l*t,a+=l*l*t,o+=t,(l<8||l>247)&&(s+=t)}if(o<r.length*.1)return null;let c=i/o;if(c<25||c>230||s/o>.4)return null;let l=Math.sqrt(Math.max(1,a/o-c*c)),u=Math.min(1.8,Math.max(.55,58/(127.5/c*l)))*(127.5/c),d=new Uint8ClampedArray(n.length);for(let e=0;e<r.length;e+=1){let i=e*4,a=r[e],o=n[i]*.299+n[i+1]*.587+n[i+2]*.114,s=(o-c)*u+127.5,l=s/Math.max(o,1);for(let e=0;e<3;e+=1)d[i+e]=Math.max(0,Math.min(255,t?s:n[i+e]*l))*a+127.5*(1-a);d[i+3]=255}return d},m=({alignment:t,face:n,frame:r})=>{let i=c.map(e=>{let t=n.mesh.landmarks[e];return[t.x,t.y]});if(i.some(([e,t])=>!Number.isFinite(e)||!Number.isFinite(t)||e<0||t<0||e>=r.width||t>=r.height))return null;let a=e.createCanvas(112,112);try{let e=a.getContext(`2d`,{willReadFrequently:!0});if(!e)throw Error(U.IMAGE_PROCESSING_FAILED);let o=l[t],s=o.landmarks.map(e=>{let t=e.map(e=>{let t=n.mesh.landmarks[e];return[t.x,t.y]});return u({points:t})}),c=d({source:s,target:o.target});if(!c||!c.every(Number.isFinite))return null;e.fillStyle=`rgb(128, 128, 128)`,e.fillRect(0,0,112,112),e.setTransform(c[0],c[3],c[1],c[4],c[2],c[5]),e.drawImage(r,0,0),e.setTransform(1,0,0,1,0,0);let m=i.map(([e,t])=>[c[0]*e+c[1]*t+c[2],c[3]*e+c[4]*t+c[5]]),h=f({height:112,minimumArea:1254.4,polygon:m,width:112});if(!h)return null;let g={image:e.getImageData(0,0,112,112).data,weights:h},_=p({face:g,grayscale:!1});if(!_)return null;let v=p({face:g,grayscale:!0});return v?{...g,normalized:{rgb:_,greyscale:v}}:null}finally{gh({canvas:a})}},h=async({faceMatcher:t=o}={})=>await e.session({filename:px[t].filename}),g=({layout:e,normalized:t})=>{let n=12544,r=new Float32Array(n*3);for(let i=0;i<n;i+=1){let a=i*4;for(let o=0;o<3;o+=1){let s=(t[a+o]-127.5)/127.5,c=e===`nhwc`?i*3+o:o*n+i;r[c]=s}}return r},_=async({normalized:t})=>{let{layout:n}=px[o],r=g({layout:n,normalized:t}),i=n===`nhwc`?[1,112,112,3]:[1,3,112,112],a=await h(),s=await Kb({label:`face.embedding`,session:a,feeds:{[a.inputNames[0]]:e.tensor(`float32`,r,i)}});try{let e=s[a.outputNames[0]].data;if(!(e instanceof Float32Array))throw Error(U.INVALID_MODEL_OUTPUT);let t=e,n=Math.hypot(...t);if(t.length!==512||!t.every(Number.isFinite)||!Number.isFinite(n)||n<1e-8)throw Error(U.INVALID_MODEL_OUTPUT);return Array.from(t,e=>e/n)}finally{Gb({outputs:s})}},v=async({blob:t})=>{try{return await e.createImageBitmap(t)}catch(e){throw Error(U.IMAGE_DECODE_FAILED,{cause:e})}},y=async({normalized:e})=>{try{return await _({normalized:e})}catch(e){if(e instanceof Error&&e.message===U.INVALID_MODEL_OUTPUT)return null;throw e}},b=async({face:e})=>{let t=await y({normalized:e.normalized.rgb});if(!t)return null;let n=await y({normalized:e.normalized.greyscale});return n?{grayscale:n,rgb:t}:null},x=async({face:e})=>await y({normalized:e.normalized.greyscale}),S=async()=>{let e=new Uint8ClampedArray(50176).fill(127);if(!await b({face:{normalized:{rgb:e,greyscale:e}}}))throw Error(U.INVALID_MODEL_OUTPUT)},C=async({pixels:t})=>{let n=e.createCanvas(112,112);try{let e=n.getContext(`2d`);if(!e)throw Error(U.IMAGE_PROCESSING_FAILED);let r=e.createImageData(112,112);r.data.set(t),e.putImageData(r,0,0);let i=await n.convertToBlob({type:`image/jpeg`,quality:1});if(i.type!==`image/jpeg`)throw Error(U.IMAGE_ENCODE_FAILED);return i}finally{gh({canvas:n})}},w=async({face:e})=>{let t=await b({face:e});if(!t)return null;let[n,r]=await Promise.all([C({pixels:e.normalized.rgb}),C({pixels:e.normalized.greyscale})]);return{embeddings:t,images:{rgb:n,greyscale:r}}},T=async({alignment:e,face:t,frame:n})=>{let r=m({alignment:e,face:t,frame:n});return r?await b({face:r}):null},E=async({alignment:e,frame:t})=>{let n=await i(t);if(!n)throw Error(U.FACE_NOT_FOUND);let r=await T({alignment:e,face:n,frame:t});if(!r)throw Error(U.FACE_NOT_USABLE);return r},ee=async({alignment:e,frame:t})=>{let n=await a(t,{forMatch:!0}),r=[];for(let i of n){let n=await T({alignment:e,face:i,frame:t});n&&r.push(n)}return r},D=async({alignment:e,frame:i})=>{let a=await n(i);if(!a)throw Error(U.DOCUMENT_NOT_FOUND);let o=await t({frame:i,polygon:a.polygon,orientation:a.orientation});if(!o)throw Error(U.DOCUMENT_NOT_FOUND);try{let t={boundingRect:{height:o.height,width:o.width,x:0,y:0},polygon:[{x:0,y:0},{x:o.width,y:0},{x:o.width,y:o.height},{x:0,y:o.height}]},{faces:n}=await r.detectDocumentFaces({detection:t,frame:o.frame});if(!n.length)throw Error(U.DOCUMENT_FACE_NOT_FOUND);for(let t of n){let n=await T({alignment:e,face:t,frame:o.frame});if(n)return n}}finally{o.frame.close()}throw Error(U.FACE_NOT_USABLE)};return{prepareFace:m,loadFaceMatch:h,warmupFaceMatch:S,imageBitmap:v,readImage:s,preparedFaceEmbeddings:b,preparedFaceGrayscaleEmbedding:x,preparedFaceArtifacts:w,matchFaceWithDocument:async({document:e,documentFaceEmbeddings:t,referenceFaceEmbeddings:n,options:r,reference:i})=>{let a=null,o=null;try{let s=t;s||=(o=await v({blob:e}),await D({alignment:r.alignment,frame:o,language:r.language,ocrEngine:r.ocrEngine}));let c=n;c||=(a=await v({blob:i}),await E({alignment:r.alignment,frame:a}));let l=Mb({first:c,second:s});return jb({score:l,threshold:r.threshold})}finally{a&&a.close(),o&&o.close()}},matchPictureWithFaces:async({options:e,picture:t,references:n,referenceFaceEmbeddings:r})=>{let i=await v({blob:t}),a=[];try{if(!r)for(let e of n){let t=await v({blob:e});a.push(t)}let t=await ee({alignment:e.alignment,frame:i});if(!t.length)throw Error(U.NO_USABLE_CANDIDATES);let o=r?[...r]:[];for(let t of a)try{let n=await E({alignment:e.alignment,frame:t});o.push(n)}catch(e){if(!(e instanceof Error)||e.message!==U.FACE_NOT_FOUND&&e.message!==U.FACE_NOT_USABLE)throw e}let s=-1/0;for(let e of o)for(let n of t){let t=Mb({first:n,second:e});s=Math.max(s,t)}if(!Number.isFinite(s))throw Error(U.NO_USABLE_REFERENCES);return jb({score:s,threshold:e.threshold})}finally{i.close();for(let e of a)e.close()}}}}})),gx,_x=t((()=>{W(),ag(),_h(),gx=({runtime:e,document:t,readImage:n})=>async({image:r,timings:i})=>{let a=await e.createImageBitmap(new Blob([r]));try{let r=performance.now(),o=await t.analyzeDocument({frame:a});if(i&&(i.documentBoxDetectionMs=performance.now()-r),!o.detection)throw Error(U.DOCUMENT_NOT_FOUND);let{polygon:s,orientation:c}=o.detection,l=ig({image:n({frame:a}),polygon:s,sourceOrientation:c?.rotation}),u=e.createCanvas(l.width,l.height);try{let t=u.getContext(`2d`);if(!t)throw Error(U.IMAGE_PROCESSING_FAILED);let n=e.createImageData(l.width,l.height);n.data.set(l.data),t.putImageData(n,0,0);let r=await u.convertToBlob({type:`image/png`});return new Uint8Array(await r.arrayBuffer())}finally{gh({canvas:u})}}finally{a.close()}}})),vx,yx=t((()=>{By(),nx(),ax(),cx(),ux(),Ry(),fx(),hx(),_x(),yh(),vx=({runtime:e,getOcr:t,faceMatcher:n})=>{let r=vh({runtime:e}),i=lx({runtime:e}),a=tx({runtime:e}),o=ix({runtime:e,imageFromImageBitmap:r}),s=sx({runtime:e,getOcr:t,...i}),c=mx({runtime:e,...i,...a,...o,faceDetection:o,faceMatcher:n});return{alignment:i,document:a,face:o,text:s,match:c,flow:dx({runtime:e,...i,...a,faceDetection:o,faceMatch:c,textDetection:s}),classify:zy({runtime:e,detector:a,alignment:i,text:s,readImage:r}),prepareOcrImage:gx({runtime:e,document:a,readImage:r}),warmup:async()=>{await Promise.all([o.loadFaceDetector({faceDetector:`standard`}),c.loadFaceMatch(),a.loadDocumentBoxDetector(),a.loadDocumentOrientationDetector(),s.loadTextDetector({engine:`tiny`,language:`latin`}),Iy()])}}}})),bx,xx,Sx,Cx,wx,Tx,Ex,Dx,Ox,kx,Ax,jx,Mx,Nx,Px=t((()=>{kh(),wh(),yx(),bg(),fy(),lg(),Nb(),ky(),Ry(),$m(),{alignment:bx,document:xx,face:Sx,text:Cx,match:wx,flow:Tx,classify:Ex,prepareOcrImage:Dx,warmup:Ox}=vx({runtime:Sh,getOcr:Dh}),{classifyDocument:kx,detectDocument:Ax,extractDocumentCodes:jx}=Ex,{detectDocumentOrientation:Mx,loadDocumentOrientationDetector:Nx}=xx})),Fx,Ix,Lx,Rx,zx,Bx=t((()=>{dd(),Fx=[`faceStraight`,`faceUp`,`faceDown`,`faceLeft`,`faceRight`],Ix=[`faceStraight`,`faceUp`,`faceLeft`,`faceRight`],Lx=[...Fx,`faceSmile`,`faceWinkLeft`,`faceTiltLeft`,`faceTiltRight`],Ql(Lx),Rx={faceStraight:0,faceLeft:1,faceRight:1,faceUp:2,faceDown:2,faceTiltLeft:3,faceTiltRight:3,faceSmile:4,faceWinkLeft:5},zx={faceStraight:`face_straight`,faceUp:`face_up`,faceDown:`face_down`,faceLeft:`face_left`,faceRight:`face_right`,faceSmile:`face_smile`,faceWinkLeft:`face_wink_left`,faceTiltLeft:`face_tilt_left`,faceTiltRight:`face_tilt_right`},Ql(zx),Fx.map(e=>zx[e]),Ix.map(e=>zx[e])})),Vx,Hx,Ux,Wx=t((()=>{Vx={faceStraight:{primary:`lookStraight`},faceUp:{primary:`lookUp`},faceDown:{primary:`lookDown`},faceLeft:{primary:`lookLeft`},faceRight:{primary:`lookRight`},faceSmile:{primary:`smile`},faceWinkLeft:{primary:`winkLeft`},faceTiltLeft:{primary:`tiltLeft`},faceTiltRight:{primary:`tiltRight`}},Hx={FACE_ROLL_TILT_LEFT:`tiltLeft`,FACE_ROLL_TILT_RIGHT:`tiltRight`,FACE_ROLL_TILT_LESS:`tiltLess`,FACE_YAW_TURN_LEFT:`lookLeft`,FACE_YAW_TURN_RIGHT:`lookRight`,FACE_YAW_TURN_LESS:`turnLess`,FACE_PITCH_LOOK_UP:`lookUp`,FACE_PITCH_LOOK_DOWN:`lookDown`,FACE_PITCH_RAISE_LESS:`raiseLess`,FACE_PITCH_LOWER_LESS:`lowerLess`,FACE_SMILE_REQUIRED:`smile`,FACE_WINK_LEFT_REQUIRED:`winkLeft`,FACEKEY_LOWER_HEAD:`lookDown`,FACEKEY_LOWER_HEAD_LESS:`lowerLess`,FACEKEY_RAISE_HEAD:`lookUp`,FACEKEY_RAISE_HEAD_LESS:`raiseLess`,FACEKEY_SMILE_REQUIRED:`smile`,FACEKEY_TILT_HEAD_LEFT:`tiltLeft`,FACEKEY_TILT_HEAD_LESS:`tiltLess`,FACEKEY_TILT_HEAD_RIGHT:`tiltRight`,FACEKEY_TURN_HEAD_LEFT:`lookLeft`,FACEKEY_TURN_HEAD_LESS:`turnLess`,FACEKEY_TURN_HEAD_RIGHT:`lookRight`,FACEKEY_WINK_LEFT_REQUIRED:`winkLeft`},Ux={facePoses:Vx,poseRejections:Hx}})),Gx,Kx,qx=t((()=>{Wx(),Gx=({pose:e})=>{let t=Ux.facePoses[e];return{...t,primary:t.primary}},Kx=({code:e})=>Ux.poseRejections[e]})),Jx,Yx,Xx,Zx,Qx,$x,eS,tS,nS,rS,iS=t((()=>{Wb(),Sb(),qx(),Jx=1e3,Yx=({pose:e})=>{let t=ub[e];return t?.yaw===void 0?t?.pitch===void 0?t?.roll===void 0?e===`faceStraight`?{axis:`roll`,value:0}:{axis:null,value:null}:{axis:`roll`,value:t.roll}:{axis:`pitch`,value:t.pitch}:{axis:`yaw`,value:t.yaw}},Xx=()=>({published:null,candidate:null,frames:0}),Zx=()=>({label:null,since:0}),Qx=({label:e,now:t,state:n})=>e?n.label===e?n:{label:e,since:t}:Zx(),$x=({delay:e=Jx,label:t,now:n,state:r})=>!t||r.label!==t?null:n-r.since>=e?t:null,eS=({alignment:e,neutral:t})=>t?{pitch:e.pitch-t.pitch,yaw:e.yaw-t.yaw,roll:e.roll-t.roll}:e,tS=({alignment:e,blendshapes:t,neutral:n,pose:r,options:i})=>{let a=eS({alignment:e,neutral:r===`faceStraight`?null:n}),o=Db({...e,blendshapes:t,pose:r,options:i});o===null&&r===`faceUp`&&n&&(o=Db({...e,pitch:a.pitch,blendshapes:t,pose:r,options:i}));let s=Yx({pose:r}),c=s.axis&&s.value!==null?a[s.axis]-s.value:0,l=(i.tolerance??15)+8,u=o===null?`inside`:Math.abs(c)<=l?`approaching`:`outside`;return{pose:r,axis:s.axis,target:s.value,error:c,zone:u,code:o}},nS=({state:e,code:t,requiredFrames:n})=>{if(t===e.published)return{published:e.published,candidate:null,frames:0};if(t===e.candidate){let r=e.frames+1;return r>=n?{published:t,candidate:null,frames:0}:{published:e.published,candidate:t,frames:r}}return{published:e.published,candidate:t,frames:1}},rS=({corrective:e,pose:t})=>{let n=Gx({pose:t}).primary;return{primary:n,corrective:e&&e!==n?e:null}}})),aS,oS,sS,cS,lS,uS,dS,fS,pS=t((()=>{Px(),a(),It(),on(),aS=async()=>{let e=await fetch(i({filename:`faceMeshLines.json`}));if(!e.ok)throw Error(M.INVALID_SERVICE_RESPONSE);return await e.json()},oS=async()=>{await aS()},{transformPoint:sS}=bx,cS=[`tessellation`,`contours`,`faceOval`,`lips`,`leftEye`,`rightEye`,`leftEyebrow`,`rightEyebrow`,`leftIris`,`rightIris`],lS=async({color:e,context:t,result:n})=>{let r=await aS();t.beginPath();for(let e of cS)for(let{start:i,end:a}of r[e]){let e=n.mesh.landmarks[i],r=n.mesh.landmarks[a];e&&r&&(t.moveTo(e.x,e.y),t.lineTo(r.x,r.y))}t.strokeStyle=e,t.lineWidth=1,t.stroke()},uS=({backgroundColor:e,color:t,context:n,line:r,toSource:i})=>{if(!r.text)return;let{x:a,y:o,width:s,height:c}=r.box,l=[{x:a,y:o},{x:a+s,y:o},{x:a+s,y:o+c},{x:a,y:o+c}].map(e=>sS({homography:i,point:e})),u=l[0],d=l[1],f=l[3];if(!u||!d||!f)return;let p=Math.hypot(d.x-u.x,d.y-u.y),m=Math.hypot(f.x-u.x,f.y-u.y),h=Math.max(8,Math.min(16,m*.7)),g=Math.max(0,p-4),_=Math.atan2(d.y-u.y,d.x-u.x);n.beginPath(),n.moveTo(u.x,u.y);for(let e of l.slice(1))n.lineTo(e.x,e.y);n.closePath(),n.strokeStyle=t,n.lineWidth=1,n.stroke(),n.save(),n.clip(),n.translate(u.x+2,u.y+2),n.rotate(_),n.font=`${h}px sans-serif`,n.textBaseline=`top`,n.lineWidth=3,n.strokeStyle=e,n.strokeText(r.text,0,0,g),n.fillStyle=t,n.fillText(r.text,0,0,g),n.restore()},dS=async({element:e,meshLineColor:t,overlayColor:n=`transparent`,result:r})=>{let i=e.getContext(`2d`);if(!i)throw Error(M.IMAGE_PROCESSING_FAILED);let a=r?.mesh.width??e.width,o=r?.mesh.height??e.height;e.width!==a&&(e.width=a),e.height!==o&&(e.height=o),$t({element:e}),n!==`transparent`&&(i.fillStyle=n,i.fillRect(0,0,a,o)),r&&await lS({color:t,context:i,result:r})},fS=async({documentFaceBoxColor:e,documentFaceMeshColor:t,documentBoxColor:n,element:r,detection:i,face:a,height:o,ocrLines:s=[],ocrToSource:c=null,overlayColor:l=`transparent`,textColor:u,width:d})=>{let f=r.getContext(`2d`);if(f&&d&&o){if(r.width!==d&&(r.width=d),r.height!==o&&(r.height=o),$t({element:r}),l!==`transparent`&&(f.fillStyle=l,f.fillRect(0,0,d,o)),i){f.strokeStyle=n,f.lineWidth=3,f.beginPath();for(let[e,t]of i.polygon.entries())e?f.lineTo(t.x,t.y):f.moveTo(t.x,t.y);f.closePath(),f.stroke()}if(a&&(f.strokeStyle=e,f.lineWidth=2,f.strokeRect(a.boundingRect.x,a.boundingRect.y,a.boundingRect.width,a.boundingRect.height),await lS({color:t,context:f,result:a})),c){let e=getComputedStyle(r).color;for(let t of s)uS({backgroundColor:e,color:u,context:f,line:t,toSource:c})}}}}));Mt(),Bx(),Px(),Wb(),Kt(),on(),iS(),pS(),It();var{analyzeDocumentFrame:mS,hasValidDocumentSideData:hS,validateDocumentBack:gS}=Tx,_S=({view:e,display:t,isActive:n,notifyCapturesChanged:r,getVerifyHardOptions:i})=>{let a=e.ref,o=async()=>{t.success.value=!0,await Gt({milliseconds:400}),t.success.value=!1},s=async({frame:s,session:c,state:l,options:u})=>{let d=performance.now(),f=!!l.captures.documentFront,p=u.requiredDocumentStableFrames,m=null,h=null;try{m=await mS({frame:s,prepareForMatch:f||l.documentStableFrames+1>=u.requiredDocumentStableFrames,options:{...i({configuration:u}),alignment:l.matchOptions.alignment,requiresFace:!f}});let{orientation:e,detection:d,face:g}=m;if(!n({flow:`document`,session:c,state:l}))return!1;let _=f?gS({current:m,front:l.documentFrontSignature}):null;h=f?Gh({front:l.documentFrontSignature,current:m.signature}):null;let v=l.document?{...l.document,ocr:l.document.document_front}:void 0,y=hS({analysis:m,isBack:f,front:v}),b=(f?_?.valid===!0:m.valid)&&y,x=e?e.rotation:null;x!==l.documentOrientation&&(l.documentStableFrames=0),l.documentOrientation=x,l.documentStableFrames=b?l.documentStableFrames+1:0,u.showDocumentOverlay?await fS({documentFaceBoxColor:u.documentFaceBoxColor,documentFaceMeshColor:u.documentFaceMeshColor,documentBoxColor:u.documentBoxColor,element:a.mesh,detection:d,face:g,height:s.height,ocrLines:u.showTextOverlay?m.text.lines:[],ocrToSource:u.showTextOverlay?m.documentToSource:null,overlayColor:u.documentOverlayColor,textColor:u.textColor,width:s.width}):$t({element:a.mesh});let S=bS({analysis:m,dataValid:y,isBack:f,minFaceAreaRatio:u.minDocumentFaceAreaRatio,rejectionReasons:_?_.reasons:m.failureReasons,valid:b,stable:l.documentStableFrames>=p});if(t.feedback.value={flow:`document`,...S},l.documentStableFrames<p)return!1;let C=await tn({frame:s});return n({flow:`document`,session:c,state:l})?f?(vS({analysis:m,isBack:!0,state:l}),l.captures.documentBack=C,r({state:l}),await o(),!0):!m.embeddings||!m.images?!1:(vS({analysis:m,isBack:!1,state:l}),l.documentFaceEmbeddings=m.embeddings,l.documentFrontSignature=m.signature,l.preparedCaptures.documentFront=m.images,l.captures.documentFront=C,r({state:l}),await o(),!0):!1}finally{m&&n({flow:`document`,session:c,state:l})&&e.collectDocumentDebug({analysis:m,sideComparison:h,isBack:f,processingTimeMilliseconds:performance.now()-d,state:l})}};return{runDocumentLoop:async({session:e,state:r,options:i})=>{for(;n({flow:`document`,session:e,state:r});){if(await Jt({video:a.video}),!n({flow:`document`,session:e,state:r}))return;let o=await createImageBitmap(a.video);try{let n=await rn({frame:o});try{if(await s({frame:n,session:e,state:r,options:i})){r.flow=null,t.debug.value=[];return}}finally{n.close()}}finally{o.close()}}}}},vS=({analysis:e,isBack:t,state:n})=>{if(!e.ocr)throw Error(M.CAPTURES_INCOMPLETE);let r={ocr:e.ocr,codes:e.codes};if(t){if(!n.document)throw Error(M.CAPTURES_INCOMPLETE);let t=cg({classification:n.document,front:{ocr:n.document.document_front,codes:n.document.codes},back:r});n.document={...n.document,...t,document_back:e.ocr}}else{if(!e.documentKind)throw Error(M.DOCUMENT_NOT_RECOGNIZED);let t={document:e.documentKind,europeanDrivingLicense:e.europeanDrivingLicense,identity:e.identity},i=cg({classification:t,front:r});n.identity=e.identity,n.document={...t,...i,document_front:e.ocr,document_back:null}}n.documentCodes=n.document.codes},yS=({rejection:e})=>e===`coverage_low`?`DOCUMENT_BOX_TOO_SMALL`:e===`coverage_high`?`DOCUMENT_BOX_TOO_LARGE`:e===`edge_proximity`?`DOCUMENT_BOX_NEAR_EDGE`:e===`opposite_edges`?`DOCUMENT_BOX_TOUCHES_EDGES`:e===`aspect_ratio`?`DOCUMENT_NOT_SUPPORTED`:`DOCUMENT_SHAPE_INVALID`,bS=({analysis:e,dataValid:t,isBack:n,minFaceAreaRatio:r,rejectionReasons:i,valid:a,stable:o})=>{let s=`front`;n?s=`back`:e.documentKind===`passport`&&(s=`passport`);let c=Object.keys(e.documentAnalysis.diagnostics.rejected)[0];return c?{target:s,code:yS({rejection:c})}:e.detection?e.documentAnalysis.isBlurry?{target:s,code:`DOCUMENT_BLURRY`}:n&&i.includes(M.DOCUMENT_BACK_CONTAINS_FACE)?{target:s,code:`DOCUMENT_BACK_HAS_FACE`}:n&&i.includes(M.DOCUMENT_BACK_NOT_DISTINCT)?{target:s,code:`DOCUMENT_BACK_SAME_AS_FRONT`}:!n&&!e.face?{target:s,code:`DOCUMENT_FRONT_FACE_NOT_DETECTED`}:!n&&!e.faceContained?{target:s,code:`DOCUMENT_FRONT_FACE_NOT_CONTAINED`}:!n&&!e.alignment.faceAreaValid&&e.alignment.faceAreaRatio<r?{target:s,code:`DOCUMENT_FRONT_FACE_TOO_SMALL`}:!n&&(!e.alignment.faceAreaValid||!e.alignment.faceDimensionsValid)?{target:s,code:`DOCUMENT_FRONT_FACE_SIZE_INVALID`}:!n&&(!e.alignment.textParallel||e.alignment.textSide===`unknown`||e.alignment.faceAdjacentTextLineCount<2)?{target:s,code:`DOCUMENT_FRONT_LAYOUT_INVALID`}:!e.text.text||e.text.lines.length<2?{target:s,code:`DOCUMENT_TEXT_NOT_READABLE`}:!n&&!e.documentKind?{target:s,code:`DOCUMENT_NOT_RECOGNIZED`}:t?a?o?{target:s,code:null}:{target:s,code:`DOCUMENT_STABILITY_REQUIRED`}:{target:s,code:`DOCUMENT_VALIDATION_FAILED`}:{target:s,code:`DOCUMENT_CODE_NOT_READABLE`}:{target:s,code:`DOCUMENT_NOT_DETECTED`}},xS,SS,CS=t((()=>{on(),xS=({pitch:e,pose:t,requireEyeLevelCamera:n=!0,options:r})=>{if(!n||t!==`faceStraight`)return null;let i=Math.max(-8,r.minPitch),a=Math.min(8,r.maxPitch);return!Number.isFinite(e)||e<i||e>a?`FACE_CAMERA_ALIGNMENT_REQUIRED`:null},SS=()=>Yt()?`alignPhoneWithFace`:`alignFaceWithWebcam`})),wS,TS,ES,DS=t((()=>{wS={front:`frameDocument`,back:`frameDocumentBack`,passport:`framePassport`},TS={FACE_NOT_DETECTED:`faceNotFound`,FACE_IN_POLYGON:`faceInPolygon`,FACE_TOO_SMALL:`faceTooSmall`,FACE_CENTER_MOVE_LEFT:`faceCenterMoveLeft`,FACE_CENTER_MOVE_RIGHT:`faceCenterMoveRight`,FACE_CENTER_MOVE_UP:`faceCenterMoveUp`,FACE_CENTER_MOVE_DOWN:`faceCenterMoveDown`,FACE_STABILITY_REQUIRED:`stayStill`,DOCUMENT_NOT_DETECTED:`documentNotDetected`,DOCUMENT_BOX_TOO_SMALL:`documentBoxTooSmall`,DOCUMENT_BOX_TOO_LARGE:`documentBoxTooLarge`,DOCUMENT_BOX_NEAR_EDGE:`documentBoxNearEdge`,DOCUMENT_BOX_TOUCHES_EDGES:`documentBoxTouchesEdges`,DOCUMENT_SHAPE_INVALID:`documentShapeInvalid`,DOCUMENT_NOT_SUPPORTED:`documentNotSupported`,DOCUMENT_BLURRY:`documentBlurry`,DOCUMENT_FRONT_FACE_NOT_DETECTED:`faceNotVisibleInDocument`,DOCUMENT_FRONT_FACE_NOT_CONTAINED:`faceNotVisibleInDocument`,DOCUMENT_FRONT_FACE_TOO_SMALL:`documentPhotoTooSmall`,DOCUMENT_FRONT_FACE_SIZE_INVALID:`documentAlignmentInvalid`,DOCUMENT_FRONT_LAYOUT_INVALID:`documentAlignmentInvalid`,DOCUMENT_TEXT_NOT_READABLE:`documentNotReadable`,DOCUMENT_NOT_RECOGNIZED:`invalidDocument`,DOCUMENT_CODE_NOT_READABLE:`passportMrzNotReadable`,DOCUMENT_BACK_HAS_FACE:`documentBackHasFace`,DOCUMENT_BACK_SAME_AS_FRONT:`documentBackSameAsFront`,DOCUMENT_STABILITY_REQUIRED:`holdDocumentStill`,DOCUMENT_VALIDATION_FAILED:`documentValidationFailed`},ES={documentTargets:wS,rejections:TS}})),OS,kS,AS=t((()=>{CS(),qx(),DS(),OS=({target:e})=>ES.documentTargets[e],kS=({code:e})=>e===`FACE_CAMERA_ALIGNMENT_REQUIRED`?SS():e in ES.rejections?ES.rejections[e]:Kx({code:e})})),jS,MS,NS,PS,FS,IS,LS,RS,zS,BS,VS,HS,US,WS,GS,KS=t((()=>{Px(),Wb(),It(),CS(),Kt(),on(),iS(),AS(),pS(),{detectPictureFaces:jS}=Sx,MS={FACEKEY_LOWER_HEAD:`FACE_PITCH_LOOK_DOWN`,FACEKEY_LOWER_HEAD_LESS:`FACE_PITCH_LOWER_LESS`,FACEKEY_RAISE_HEAD:`FACE_PITCH_LOOK_UP`,FACEKEY_RAISE_HEAD_LESS:`FACE_PITCH_RAISE_LESS`,FACEKEY_TILT_HEAD_LEFT:`FACE_ROLL_TILT_LEFT`,FACEKEY_TILT_HEAD_LESS:`FACE_ROLL_TILT_LESS`,FACEKEY_TILT_HEAD_RIGHT:`FACE_ROLL_TILT_RIGHT`,FACEKEY_TURN_HEAD_LEFT:`FACE_YAW_TURN_LEFT`,FACEKEY_TURN_HEAD_LESS:`FACE_YAW_TURN_LESS`,FACEKEY_TURN_HEAD_RIGHT:`FACE_YAW_TURN_RIGHT`,FACEKEY_SMILE_REQUIRED:`FACE_SMILE_REQUIRED`,FACEKEY_WINK_LEFT_REQUIRED:`FACE_WINK_LEFT_REQUIRED`},NS=({face:e,name:t})=>e.blendshapes[t]??0,PS=({face:e,frame:t})=>e.boundingRect.height/t.height<.4?`FACE_TOO_SMALL`:null,FS=({face:e,pose:t,options:n})=>{let r=Db({...e,pose:t,options:n});return r?MS[r]:null},IS=({face:e,pose:t,options:n})=>FS({face:e,pose:t,options:n})===null,LS=async({capture:e,pose:t,options:n,poseOptions:r,requireEyeLevelCamera:i})=>{let a=await wx.imageBitmap({blob:e});try{let e=await jS(a),o=e.length===1?e[0]:null;if(!o||!IS({face:o,pose:t,options:r})||xS({pitch:o.pitch,pose:t,requireEyeLevelCamera:i,options:r}))return null;let s=wx.prepareFace({alignment:n.alignment,face:o,frame:a});return s?await wx.preparedFaceArtifacts({face:s}):null}finally{a.close()}},{detectDocumentBox:RS}=xx,{detectFace:zS}=Sx,BS=({view:e,display:t,isActive:n,notifyCapturesChanged:r})=>{let i=e.ref,a=({state:e})=>e.faceSequence[e.poseIndex]??`faceStraight`,o=({face:e,frame:n})=>{let r=e.boundingRect.x+e.boundingRect.width/2,i=e.boundingRect.y+e.boundingRect.height/2,a=(t.cameraFacingMode.value===`user`?n.width-r:r)/n.width,o=i/n.height;return a<.4?`FACE_CENTER_MOVE_RIGHT`:a>.6?`FACE_CENTER_MOVE_LEFT`:o<.4?`FACE_CENTER_MOVE_DOWN`:o>.6?`FACE_CENTER_MOVE_UP`:null},s=async({frame:s,session:c,state:l,options:u})=>{let d=performance.now(),f=null,p=!1;try{f=await zS(s);let e=f?await RS(s):null;if(p=!!(f&&e&&ab({face:f,polygon:e.polygon})),!n({flow:`face`,session:c,state:l}))return!1;if(u.showFaceOverlay&&await dS({element:i.mesh,meshLineColor:u.faceMeshColor,overlayColor:u.faceOverlayColor,result:f}),!f){l.poseStableFrames=0;let e=a({state:l});return t.feedback.value={flow:`face`,code:`FACE_NOT_DETECTED`,pose:e},!1}if(p)return l.poseStableFrames=0,t.feedback.value={flow:`face`,code:`FACE_IN_POLYGON`,pose:a({state:l})},!1;let d=a({state:l}),m=PS({face:f,frame:s});if(m)return l.poseStableFrames=0,t.feedback.value={flow:`face`,code:m,pose:d},!1;let h=o({face:f,frame:s});if(h)return l.poseStableFrames=0,t.feedback.value={flow:`face`,code:h,pose:d},!1;let g=xS({pitch:f.pitch,pose:d,requireEyeLevelCamera:u.requireEyeLevelCamera,options:u});if(g)return l.poseStableFrames=0,l.guidanceCodeState=Xx(),l.correctiveState=Zx(),t.guidance.value=null,t.corrective.value=null,t.feedback.value={flow:`face`,code:g,pose:d},!1;let _={pitch:f.pitch,yaw:f.yaw,roll:f.roll},v=tS({alignment:_,blendshapes:f.blendshapes,neutral:l.neutralPose,pose:d,options:u});l.guidanceCodeState=nS({state:l.guidanceCodeState,code:v.code,requiredFrames:3}),t.guidance.value=v;let y=v.code?MS[v.code]:null,b=l.guidanceCodeState.published?MS[l.guidanceCodeState.published]:null,x=rS({pose:d,corrective:b?kS({code:b}):null}).corrective,S=performance.now();if(l.correctiveState=Qx({label:x,now:S,state:l.correctiveState}),t.corrective.value=$x({label:x,now:S,state:l.correctiveState}),y)return l.poseStableFrames=0,t.feedback.value={flow:`face`,code:b,pose:d},!1;if(d===`faceStraight`&&(l.neutralPose=_),l.poseStableFrames+=1,l.poseStableFrames<u.requiredFaceStableFrames)return t.feedback.value={flow:`face`,code:`FACE_STABILITY_REQUIRED`,pose:d},!1;t.feedback.value={flow:`face`,code:null,pose:d};let C=await tn({frame:s}),w=await LS({capture:C,pose:d,options:l.matchOptions,poseOptions:u,requireEyeLevelCamera:u.requireEyeLevelCamera});if(!n({flow:`face`,session:c,state:l}))return!1;if(!w)return l.poseStableFrames=0,t.feedback.value={flow:`face`,code:`FACE_STABILITY_REQUIRED`,pose:d},!1;let T=Vb({image:wx.readImage({frame:s,width:32,height:32})}),E=l.previousPoseBackgroundSignature;if(E&&!Hb({first:E,second:T}).matched)throw Error(M.POSE_BACKGROUND_MISMATCH);let ee=l.faceEmbeddings.faceStraight;if(ee&&Mb({first:ee,second:w.embeddings})<=l.matchOptions.threshold)throw Error(M.POSE_IDENTITY_MISMATCH);let D=d;return l.captures[D]=C,l.preparedCaptures[D]=w.images,l.faceEmbeddings[D]=w.embeddings,l.previousPoseBackgroundSignature=T,r({state:l}),t.success.value=!0,await Gt({milliseconds:400}),t.success.value=!1,n({flow:`face`,session:c,state:l})?(l.poseIndex+=1,l.poseStableFrames=0,l.guidanceCodeState=Xx(),l.correctiveState=Zx(),t.corrective.value=null,t.progress.value={completed:l.poseIndex,total:l.faceSequence.length},l.poseIndex===l.faceSequence.length?(t.feedback.value=null,!0):(t.feedback.value={flow:`face`,pose:a({state:l}),code:null},!1)):!1}finally{n({flow:`face`,session:c,state:l})&&e.collectFaceDebug({face:f,faceInPolygon:p,processingTimeMilliseconds:performance.now()-d,state:l}),s.close()}};return{runFaceLoop:async({session:e,state:r,options:a})=>{for(;n({flow:`face`,session:e,state:r});){if(await Jt({video:i.video}),!n({flow:`face`,session:e,state:r}))return;let o=await createImageBitmap(i.video);if(await s({frame:o,session:e,state:r,options:a})){r.flow=null,t.debug.value=[],t.guidance.value=null;return}}}}},VS=({captures:e,state:t})=>t.faceSequence.every(n=>!!(e[n]&&t.preparedCaptures[n]&&t.faceEmbeddings[n])),HS=({captures:e,state:t})=>{if(!VS({captures:e,state:t}))throw Error(M.CAPTURES_INCOMPLETE);let n=[...t.faceSequence];return{faces:n.map(t=>e[t]).filter(e=>!!e),poses:n,embeddings:n.map(e=>t.faceEmbeddings[e]).filter(e=>!!e)}},US=({sequence:e})=>{let t=[...e];for(let e=t.length-1;e>0;--e){let n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t},WS=({sequence:e})=>[...e].sort((e,t)=>Rx[e]-Rx[t]),GS=({poses:e,randomize:t})=>{let n=e===`all`?[...Lx]:e??Ix;if(!n.length)throw Error(M.INVALID_POSES);let r=[...new Set(n)];if(r.length!==n.length||r.some(e=>!Lx.includes(e))||r[0]!==`faceStraight`||Ix.some(e=>!r.includes(e)))throw Error(M.INVALID_POSES);let i=r.slice(1);return t?[`faceStraight`,...US({sequence:i})]:[`faceStraight`,...WS({sequence:i})]}}));KS(),Bx(),It(),on();var qS=`https://api.voltom.io`,JS=({apiUrl:e})=>{let t=e??qS;return t.endsWith(`/`)?t.slice(0,-1):t},YS=async({apiUrl:e,path:t,method:n=`POST`,body:r,clientKey:i,fallback:a=M.INVALID_SERVICE_RESPONSE,signal:o})=>{let s={};i&&(s.authorization=`Bearer ${i}`),r&&(s[`content-type`]=`application/json`);let c;try{c=await fetch(`${JS({apiUrl:e})}${t}`,{method:n,headers:s,body:r,signal:o})}catch(e){throw o?.aborted?Error(M.VERIFICATION_CANCELLED,{cause:e}):Error(M.NETWORK_ERROR,{cause:e})}if(c.status===413)throw Error(M.REQUEST_TOO_LARGE);let l;try{l=await c.json()}catch(e){throw Error(c.status>=500?M.SERVICE_UNAVAILABLE:a,{cause:e})}if(!c.ok){let e=typeof l==`object`&&l&&`code`in l&&typeof l.code==`string`?l.code:c.status>=500?M.SERVICE_UNAVAILABLE:a;throw Error(e)}return l},XS=async({clientKey:e,apiUrl:t,signal:n})=>{await YS({apiUrl:t,path:`/auth/me`,method:`GET`,clientKey:e,fallback:M.INVALID_CLIENT_KEY,signal:n})},ZS=({apiUrl:e})=>{if(typeof navigator<`u`&&typeof navigator.sendBeacon==`function`)try{navigator.sendBeacon(`${JS({apiUrl:e})}/script-loads`)}catch{return}},QS=async({clientKey:e,apiUrl:t,endpoint:n,documentBack:r,documentFront:i,faces:a=[],options:o,picture:s,poses:c=[],sourceIds:l=[],threshold:u,signal:d})=>{if(!e)throw Error(M.CLIENT_KEY_REQUIRED);let f=JSON.stringify({documentFront:i?await an({image:i}):void 0,documentBack:r?await an({image:r}):void 0,picture:s?await an({image:s}):void 0,faces:await Promise.all(a.map(e=>an({image:e}))),options:o,poses:c.map(e=>zx[e]),source_ids:l,threshold:u});return d?.throwIfAborted(),await YS({apiUrl:t,path:n,body:f,clientKey:e,signal:d})};Px(),Sm(),Wb(),hh(),Bx(),It(),Kt(),on(),iS(),pS();var{loadDocumentBoxDetector:$S,detectDocumentOrientation:eC}=xx,{detectPictureFaces:tC,loadFaceDetector:nC}=Sx,{loadFaceMatch:rC,warmupFaceMatch:iC}=wx,{loadTextDetector:aC}=Cx,oC=({options:e,view:t,display:n})=>{let r=t.ref,i=[...Ix],a=({language:e})=>e??Ht(),o=()=>({identity:null,flow:null,session:0,faceSequence:[...i],faceCaptureConfiguration:null,documentCaptureConfiguration:null,poseIndex:0,poseStableFrames:0,documentStableFrames:0,documentOrientation:null,documentFaceEmbeddings:null,documentFrontSignature:null,documentCodes:[],matchOptions:{alignment:e.alignment,threshold:e.threshold},captures:{},preparedCaptures:{},faceEmbeddings:{},previousPoseBackgroundSignature:null,neutralPose:null,guidanceCodeState:Xx(),correctiveState:Zx(),faceMatchOptions:null,hardHumanVerificationId:null,hardDocumentVerificationId:null,cameraActive:!1,cameraSize:n.cameraSize,cameraFacingMode:n.cameraFacingMode}),s=({active:e,state:t})=>{t.cameraActive!==e&&(t.cameraActive=e,r.root.dispatchEvent(new CustomEvent(`voltom:camera-change`,{detail:{active:e}})))},c=({state:e})=>{Zt({video:r.video}),s({active:!1,state:e}),e.cameraSize.value=null,e.cameraFacingMode.value=null,n.feedback.value=null,n.guidance.value=null,n.corrective.value=null,n.success.value=!1},l=({state:e})=>({identity:e.identity,document:e.document,captures:{...e.captures},documentCodes:[...e.documentCodes],preparedCaptures:{...e.preparedCaptures}}),u=({state:e})=>{let t=l({state:e});r.root.dispatchEvent(new CustomEvent(`voltom:captures-change`,{detail:t}))},d=({state:t,options:r=e})=>{t.faceSequence=y({options:r}),t.poseIndex=0,t.poseStableFrames=0;let i=t.preparedCaptures.documentFront;t.preparedCaptures=i?{documentFront:i}:{},t.faceEmbeddings={},t.previousPoseBackgroundSignature=null,t.neutralPose=null,t.guidanceCodeState=Xx(),t.correctiveState=Zx(),n.corrective.value=null,t.faceMatchOptions=null,t.hardHumanVerificationId=null,t.faceCaptureConfiguration=null;let{documentFront:a,documentBack:o}=t.captures;t.captures={...a?{documentFront:a}:{},...o?{documentBack:o}:{}}},f=({state:e})=>{e.documentStableFrames=0,e.documentOrientation=null,e.documentFaceEmbeddings=null,e.documentFrontSignature=null,e.identity=null,e.documentCodes=[],delete e.document,e.hardDocumentVerificationId=null,e.documentCaptureConfiguration=null,delete e.preparedCaptures.documentFront;let t={...e.captures};delete t.documentFront,delete t.documentBack,e.captures=t},p=({state:e})=>{e.session+=1,e.flow=null,c({state:e}),$t({element:r.mesh}),n.debug.value=[]},m=({state:e})=>{p({state:e}),u({state:e}),n.error.value=null},h=({state:e})=>{let t=r.video.videoWidth,n=r.video.videoHeight;t&&n&&(e.cameraSize.value={width:t,height:n})},g=async({facingMode:e,state:t})=>{c({state:t});let n=t.session,i=await Qt({facingMode:e,video:r.video});if(t.session!==n)throw Zt({video:r.video}),ie();t.cameraFacingMode.value=i,h({state:t}),s({active:!0,state:t})},_=({flow:e,session:t,state:n})=>n.flow===e&&n.session===t,v=({state:e})=>e.faceSequence[e.poseIndex]??`faceStraight`,y=({options:e})=>GS({poses:e.poses,randomize:e.randomizeFaceSequence??!1}),b=({options:e})=>JSON.stringify({requireEyeLevelCamera:e.requireEyeLevelCamera,poses:e.poses,randomizeFaceSequence:e.randomizeFaceSequence,faceDetector:e.faceDetector,alignment:e.alignment,threshold:e.threshold,language:e.language,maxPitch:e.maxPitch,minPitch:e.minPitch,maxYaw:e.maxYaw,minYaw:e.minYaw,maxRoll:e.maxRoll,requiredFaceStableFrames:e.requiredFaceStableFrames}),x=({options:e})=>JSON.stringify({ocrEngine:e.ocrEngine,language:e.language,minDocumentFaceAreaRatio:e.minDocumentFaceAreaRatio,maxDocumentFaceAreaRatio:e.maxDocumentFaceAreaRatio,minDocumentFaceWidthRatio:e.minDocumentFaceWidthRatio,maxDocumentFaceWidthRatio:e.maxDocumentFaceWidthRatio,minDocumentFaceHeightRatio:e.minDocumentFaceHeightRatio,maxDocumentFaceHeightRatio:e.maxDocumentFaceHeightRatio,minDocumentBoxRatio:e.minDocumentBoxRatio,maxDocumentTextAngleDifference:e.maxDocumentTextAngleDifference,requiredDocumentStableFrames:e.requiredDocumentStableFrames}),S=({state:e,options:t})=>e.faceCaptureConfiguration===b({options:t})&&VS({captures:e.captures,state:e}),C=({state:e,options:t})=>{let n=e.document,r=n!==void 0&&n.document!==`passport`,i=!(!e.captures.documentFront||r&&!e.captures.documentBack),a=e.documentCaptureConfiguration===x({options:t});return!!(n?.valid&&i&&a)},w=({configuration:e})=>{let t=Object.fromEntries(Object.keys(Q).map(t=>[t,e[t]]));return t.language=a({language:e.language}),t},T=async({configuration:e,endpoint:t,state:n,picture:r,sourceIds:i=[],signal:a})=>{let o=VS({captures:n.captures,state:n})?HS({captures:n.captures,state:n}):null;return await QS({clientKey:e.clientKey,apiUrl:e.apiUrl,endpoint:t,documentBack:r?void 0:n.captures.documentBack,documentFront:r?void 0:n.captures.documentFront,faces:o?.faces,options:w({configuration:e}),picture:r,poses:o?.poses,sourceIds:i,threshold:e.threshold,signal:a})},E={options:e,view:t,display:n,isActive:_,notifyCapturesChanged:u,getVerifyHardOptions:w},{runFaceLoop:ee}=BS(E),{runDocumentLoop:D}=_S(E),te=async({state:e,options:t})=>{p({state:e}),d({state:e,options:t}),n.progress.value={completed:0,total:e.faceSequence.length},e.faceCaptureConfiguration=b({options:t}),e.matchOptions={alignment:t.alignment,threshold:t.threshold},e.faceMatchOptions={...e.matchOptions},u({state:e});let i=e.session;e.flow=`face`;try{if(n.feedback.value={flow:`face`,pose:v({state:e}),code:null},await g({facingMode:`user`,state:e}),n.feedback.value={flow:`face`,pose:v({state:e}),code:null},await ee({session:i,state:e,options:t}),e.session!==i)throw ie();if(!VS({captures:e.captures,state:e}))throw Error(M.CAPTURES_INCOMPLETE);let a={...e.captures};return c({state:e}),$t({element:r.mesh}),a}finally{e.session===i&&(n.feedback.value=null)}},ne=async({state:t,options:i=e})=>{p({state:t}),f({state:t}),t.documentCaptureConfiguration=x({options:i}),t.matchOptions={alignment:i.alignment,threshold:i.threshold},u({state:t});let a=t.session;t.flow=`document`;try{if(!_({flow:`document`,session:a,state:t})||(await g({facingMode:`environment`,state:t}),n.feedback.value={flow:`document`,code:null,target:`front`},await D({session:a,state:t,options:i}),t.session!==a))throw ie();if(!t.captures.documentFront||!t.document)throw Error(M.CAPTURES_INCOMPLETE);if(t.document.document!==`passport`&&(t.documentStableFrames=0,t.documentOrientation=null,t.flow=`document`,n.feedback.value={flow:`document`,code:null,target:`back`},await D({session:a,state:t,options:i}),t.session!==a))throw ie();if(!t.document.valid)throw Error(M.DOCUMENT_VALIDATION_FAILED);let e={...t.captures};return c({state:t}),$t({element:r.mesh}),e}finally{t.session===a&&(n.feedback.value=null,$t({element:r.mesh}))}},re=async()=>{let t=e.capabilities.some(e=>e===`verifyDocument`||e===`matchID`),n=[$S(),nC({faceDetector:e.faceDetector}),rC(),...t?[Nx(),aC({engine:`tiny`,language:`latin`}),aC({engine:e.ocrEngine,language:a({language:e.language})}),Iy()]:[],...e.showFaceOverlay||e.showDocumentOverlay?[oS()]:[]];await Promise.all(n);let r=document.createElement(`canvas`);r.width=640,r.height=480;let i=await createImageBitmap(r);try{let e=[tC(i),xx.detectDocumentBox(i),iC()];t&&e.push(eC({frame:i,boundingRect:{x:0,y:0,width:i.width,height:i.height}})),await Promise.all(e)}finally{i.close()}},O=async()=>{let t=e.capabilities.some(e=>e===`verifyDocument`||e===`matchID`),n=[`dd.ort`,rh[e.faceDetector],`fl.ort`,`fe.ort`,`fmu.ort`,`ort-wasm-simd-threaded.mjs`,`ort-wasm-simd-threaded.wasm`,...t?[`do.ort`,`zxing-wasm/reader/index.js`,`zxing-wasm/share.js`,`zxing-wasm/reader/zxing_reader.wasm`]:[],...e.showFaceOverlay||e.showDocumentOverlay?[`faceMeshLines.json`]:[]],r=[xm({filenames:n})];t&&(r.push(xm({filenames:Qm({language:`latin`,engine:`tiny`})})),r.push(xm({filenames:Qm({language:a({language:e.language}),engine:e.ocrEngine})}))),await Promise.all(r)},ie=()=>new DOMException(M.VERIFICATION_CANCELLED,`AbortError`);return{createState:o,stop:m,syncCameraSize:h,captureResult:l,resetFaceFlow:d,resetDocumentFlow:f,hasCompatibleFaceCaptures:S,hasCompatibleDocumentCapture:C,notifyCapturesChanged:u,startFaceFlow:te,startDocumentFlow:ne,startPictureFlow:async({picture:e,state:t,options:r,signal:i})=>{n.error.value=null,i?.throwIfAborted();let a=await wx.imageBitmap({blob:e});try{let e=await tC(a,{forMatch:!0});if(i?.throwIfAborted(),!e.length)throw Error(M.NO_USABLE_CANDIDATES)}finally{a.close()}let o=t.faceCaptureConfiguration===b({options:r});S({state:t,options:r})&&o||await te({state:t,options:r}),i?.throwIfAborted();let s=await wx.imageBitmap({blob:e});try{let[e]=await tC(s,{forMatch:!0});i?.throwIfAborted();let n=e?wx.prepareFace({alignment:r.alignment,face:e,frame:s}):null,a=n?await wx.preparedFaceArtifacts({face:n}):null;i?.throwIfAborted(),a&&(t.preparedCaptures.picture=a.images)}finally{s.close()}u({state:t})},submitHardVerification:T,initializeModels:re,preloadModels:O,showError:({error:e,state:t})=>{Ft({error:e})!==M.VERIFICATION_CANCELLED&&p({state:t}),Ye(()=>{n.activity.value=null,Ft({error:e})===M.VERIFICATION_CANCELLED?n.retry.value=null:n.error.value=e})}}};Px(),a(),It();var sC,cC=async()=>{try{sC??=import(i({filename:`pdf/pdf.mjs`}));let e=await sC;return e.GlobalWorkerOptions.workerSrc=i({filename:`pdf/pdf.worker.mjs`}),e}catch{throw sC=void 0,Error(M.PDF_LOAD_FAILED)}},lC=async({blob:e,signal:t})=>{if(new TextDecoder().decode(await e.slice(0,5).arrayBuffer())!==`%PDF-`)return null;if(e.size>1e7)throw Error(M.REQUEST_TOO_LARGE);t.throwIfAborted();let n=await cC();t.throwIfAborted();let r=new Uint8Array(await e.arrayBuffer()),a=n.getDocument({data:r,cMapUrl:i({filename:`pdf/cmaps/`}),cMapPacked:!0,standardFontDataUrl:i({filename:`pdf/standard_fonts/`}),wasmUrl:i({filename:`pdf/wasm/`})}),o=()=>{a.destroy()};t.addEventListener(`abort`,o,{once:!0});let s;try{let e=await a.promise;t.throwIfAborted();let n=await e.getPage(1),r=n.getViewport({scale:1}),i=n.getViewport({scale:Math.min(1,1200/Math.max(r.width,r.height))}),o=window.document.createElement(`canvas`);o.width=Math.ceil(i.width),o.height=Math.ceil(i.height),await n.render({canvas:o,viewport:i,background:`white`}).promise,t.throwIfAborted(),s=await createImageBitmap(o),o.width=0,o.height=0;let c=await Sx.detectPictureFaces(s,{forMatch:!0});t.throwIfAborted();let l=c[0];if(!l)throw Error(M.NO_USABLE_CANDIDATES);let u=l.boundingRect,d=Math.max(0,Math.floor(u.x-u.width*.25)),f=Math.max(0,Math.floor(u.y-u.height*.25)),p=Math.min(s.width-d,Math.ceil(u.width*1.5)),m=Math.min(s.height-f,Math.ceil(u.height*1.5)),h=new OffscreenCanvas(p,m),g=h.getContext(`2d`);if(!g)throw Error(M.IMAGE_PROCESSING_FAILED);g.drawImage(s,d,f,p,m,0,0,p,m);let _=await h.convertToBlob({type:`image/jpeg`,quality:.95});return t.throwIfAborted(),_}catch(e){throw t.throwIfAborted(),e instanceof Error&&Object.values(M).includes(e.message)?e:e instanceof Error&&e.name===`PasswordException`?Error(M.PDF_PASSWORD_REQUIRED):Error(M.INVALID_PDF)}finally{t.removeEventListener(`abort`,o),s?.close(),await a.destroy()}},uC,dC=t((()=>{Mt(),uC=()=>({activity:$e(null),error:$e(null),retry:$e(null),feedback:$e(null),guidance:$e(null),corrective:$e(null),progress:$e({completed:0,total:0}),success:$e(!1),cameraSize:$e(null),cameraFacingMode:$e(null),debug:$e([]),debugEnabled:$e(!1)})}));dC(),Wb();var fC={...Q,faceDetector:`standard`,apiUrl:`https://api.voltom.io`,language:void 0,clientKey:``,threshold:kb,randomizeFaceSequence:!1,requireEyeLevelCamera:!0,requiredFaceStableFrames:2,requiredDocumentStableFrames:2,showFaceOverlay:!1,showDocumentOverlay:!1,showTextOverlay:!1,faceOverlayColor:`transparent`,faceMeshColor:`#38efb0`,documentOverlayColor:`transparent`,documentBoxColor:`#22d3ee`,documentFaceBoxColor:`#22d3ee`,documentFaceMeshColor:`#38efb0`,textColor:`#22d3ee`,debug:!1,capabilities:[`verifyHuman`,`verifyDocument`,`matchID`,`matchPicture`]};function $(e,t,n,r,i,a){t||={};var o,s,c=t;if(`ref`in c&&typeof e!=`function`)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:pC,__v:--mC,__i:-1,__u:0};return(i||a)&&(l.__source=i,l.__self=a),O.vnode&&O.vnode(l),l}var pC,mC,hC=t((()=>{xe(),pC=Symbol.for(`pv`),mC=0,Array.isArray})),gC,_C=t((()=>{hC(),gC=({className:e,entries:t,kind:n})=>$(`div`,{className:t.length?e:`hidden`,[`data-${n}-debug`]:``,children:t.map(({label:e,valid:t,value:n})=>$(`div`,{children:[$(`span`,{children:[e,`: `]}),$(`span`,{"data-valid":t===void 0?void 0:String(t),children:n})]},e))})})),vC,yC,bC,xC,SC,CC=t((()=>{hC(),vC=100,yC=2,bC=({total:e})=>vC/e-(e===1?0:yC),xC=({arc:e,index:t,total:n})=>({dasharray:`${e} ${vC-e}`,offset:`${-t*vC/n}`}),SC=({className:e,completed:t,label:n,total:r,variant:i=`bar`})=>{if(i===`ring`){let i=bC({total:r});return $(`svg`,{className:e,"data-pose-progress":``,"data-variant":`ring`,viewBox:`0 0 100 100`,role:`progressbar`,"aria-label":n,"aria-valuemin":0,"aria-valuemax":r,"aria-valuenow":t,children:$(`g`,{transform:`rotate(-90 50 50)`,children:Array.from({length:r},(e,n)=>{let{dasharray:a,offset:o}=xC({arc:i,index:n,total:r});return $(`circle`,{cx:`50`,cy:`50`,r:`50`,pathLength:vC,ref:e=>{e&&(e.setAttribute(`stroke-dasharray`,a),e.setAttribute(`stroke-dashoffset`,o))},"data-pose-progress-step":``,"data-complete":n<t?``:void 0},n)})})})}return $(`div`,{className:e,"data-pose-progress":``,"data-variant":`bar`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":r,"aria-valuenow":t,children:Array.from({length:r},(e,n)=>$(`span`,{"data-pose-progress-step":``,"data-complete":n<t?``:void 0},n))})}})),wC,TC,EC,DC,OC,kC=t((()=>{hC(),wC={faceLeft:`M 78 50 L 22 50`,faceRight:`M 22 50 L 78 50`,faceUp:`M 50 78 L 50 22`,faceDown:`M 50 22 L 50 78`,faceTiltLeft:`M 68 26 Q 44 34 32 62`,faceTiltRight:`M 32 26 Q 56 34 68 62`},TC=()=>$(`defs`,{children:$(`marker`,{id:`pose-arrowhead`,markerWidth:`6`,markerHeight:`6`,refX:`4.4`,refY:`3`,orient:`auto`,children:$(`path`,{"data-pose-arrowhead":``,d:`M0,0 L6,3 L0,6 Z`})})}),EC=({pose:e})=>{let t=wC[e];return t?$(`path`,{"data-pose-motion":``,d:t,"marker-end":`url(#pose-arrowhead)`}):null},DC=({pose:e})=>e===`faceSmile`?$(`path`,{"data-pose-smile":``,d:`M 15 45 A 35 35 0 0 0 85 45`}):null,OC=({className:e,pose:t})=>$(`svg`,{className:e,"data-pose-arrow":``,"data-pose":t,viewBox:`0 0 100 100`,"aria-hidden":`true`,children:[$(TC,{}),$(EC,{pose:t}),$(DC,{pose:t})]})})),AC,jC=t((()=>{hC(),AC=({className:e,visible:t})=>$(`svg`,{className:e,"data-pose-success":``,"data-visible":t?``:void 0,viewBox:`0 0 100 100`,"aria-hidden":`true`,children:[$(`circle`,{cx:`50`,cy:`50`,r:`44`}),$(`path`,{d:`M29 51 43 65 72 36`,pathLength:`1`})]})})),MC,NC=t((()=>{MC=`/*! tailwindcss v4.3.4 | MIT License | https://tailwindcss.com */
|
|
72
|
-
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:block))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-border-style:solid;--tw-leading:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-font-weight:initial}}}[data-voltom-demo],[data-voltom-root],[data-facekey-root],[data-facegate-root]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light dark;--theme-canvas:var(--lightningcss-light,#fafafa)var(--lightningcss-dark,#0b0b0b);--theme-surface:var(--lightningcss-light,#fff)var(--lightningcss-dark,#202020);--theme-surface-subtle:var(--lightningcss-light,#f5f5f5)var(--lightningcss-dark,#2c2c2c);--theme-text:var(--lightningcss-light,#121212)var(--lightningcss-dark,#f7f7f7);--theme-text-muted:var(--lightningcss-light,#626262)var(--lightningcss-dark,#a3a3a3);--theme-text-inverse:var(--lightningcss-light,#fafafa)var(--lightningcss-dark,#0b0b0b);--theme-border:var(--lightningcss-light,#bfbfbf)var(--lightningcss-dark,#606060);--theme-primary:var(--lightningcss-light,#121212)var(--lightningcss-dark,#f7f7f7);--theme-primary-hover:var(--lightningcss-light,#262626)var(--lightningcss-dark,#e5e5e5);--theme-primary-active:var(--lightningcss-light,#404040)var(--lightningcss-dark,#d4d4d4);--theme-focus:var(--lightningcss-light,#525252)var(--lightningcss-dark,#d4d4d4);--theme-cocoa:var(--lightningcss-light,#6b4423)var(--lightningcss-dark,#d29a63);--theme-mint:var(--lightningcss-light,#116b4c)var(--lightningcss-dark,#38efb0);--theme-cyan:var(--lightningcss-light,#0e7490)var(--lightningcss-dark,#22d3ee);--theme-violet:var(--lightningcss-light,#5b21b6)var(--lightningcss-dark,#b69cff);--theme-berry:var(--lightningcss-light,#a21caf)var(--lightningcss-dark,#e879f9);--theme-danger:var(--lightningcss-light,#b42318)var(--lightningcss-dark,#ff6b6b);--theme-danger-surface:var(--lightningcss-light,#fee2e2)var(--lightningcss-dark,#451a19);--theme-success:var(--lightningcss-light,#087443)var(--lightningcss-dark,#4ade80);--theme-success-surface:var(--lightningcss-light,#e7f6ee)var(--lightningcss-dark,#123c2b);--theme-warning:var(--lightningcss-light,#a16207)var(--lightningcss-dark,#ffc93c);--theme-warning-surface:var(--lightningcss-light,#fef3c7)var(--lightningcss-dark,#422006)}@media (prefers-color-scheme:dark){[data-voltom-demo],[data-voltom-root],[data-facekey-root],[data-facegate-root]{--lightningcss-light: ;--lightningcss-dark:initial}}[data-pose-silhouette],[data-pose-arrow]{display:block;overflow:visible}[data-pose-silhouette] [data-pose-head]{fill:none;stroke:var(--theme-border);stroke-width:1.5px;stroke-dasharray:5 5}[data-pose-silhouette] [data-pose-eye]{fill:var(--theme-text-muted);stroke:none}[data-pose-silhouette] [data-pose-mouth],[data-pose-silhouette] [data-pose-eye-closed],[data-pose-motion]{fill:none;stroke:var(--theme-cyan);stroke-width:2.5px;stroke-linecap:round;stroke-linejoin:round}[data-pose-motion]{stroke-dasharray:6 6;animation:.9s linear infinite pose-motion}[data-pose-arrowhead]{fill:var(--theme-cyan);stroke:none}[data-pose-arrow] [data-pose-motion]{stroke:var(--theme-mint);stroke-width:4px;stroke-dasharray:none;animation:none}[data-pose-arrow] [data-pose-arrowhead]{fill:var(--theme-mint)}[data-pose-arrow] [data-pose-smile]{fill:none;stroke:var(--theme-mint);stroke-width:4px;stroke-linecap:round}[data-pose-progress][data-variant=bar]{gap:4px;width:100%;display:flex}[data-pose-progress][data-variant=bar] [data-pose-progress-step]{background:var(--theme-border);border-radius:9999px;flex:1;height:4px;transition:background .2s}[data-pose-progress][data-variant=bar] [data-pose-progress-step][data-complete]{background:var(--theme-mint)}[data-pose-progress][data-variant=ring]{display:block;overflow:visible}[data-pose-progress][data-variant=ring] [data-pose-progress-step]{fill:none;stroke:var(--theme-border);stroke-width:2px;stroke-linecap:round;transition:stroke .3s}[data-pose-progress][data-variant=ring] [data-pose-progress-step][data-complete]{stroke:var(--theme-mint)}[data-pose-success]{opacity:0;pointer-events:none}[data-pose-success] circle{fill:var(--theme-success-surface);stroke:var(--theme-mint);stroke-width:2px}[data-pose-success] path{fill:none;stroke:var(--theme-mint);stroke-width:5px;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:1;stroke-dashoffset:1px}[data-pose-success][data-visible]{animation:.42s ease-out both pose-success-appear}[data-pose-success][data-visible] path{animation:.24s ease-out 60ms both pose-success-draw}@keyframes pose-motion{to{stroke-dashoffset:-12px}}@keyframes pose-success-appear{0%{opacity:0;transform:scale(.85)}to{opacity:1;transform:scale(1)}}@keyframes pose-success-draw{to{stroke-dashoffset:0}}@media (prefers-reduced-motion:reduce){[data-pose-motion]{animation:none}[data-pose-success][data-visible]{opacity:1}[data-pose-success][data-visible] path{stroke-dashoffset:0}}@layer components{[data-voltom-root]{width:100%;min-height:0;max-width:var(--container-5xl,64rem);padding-block:env(safe-area-inset-top);color:var(--theme-text);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;flex-direction:column;gap:.75rem;margin-inline:auto;display:flex;position:relative;overflow:visible}[data-voltom-camera]{background-color:var(--theme-surface);width:100%;aspect-ratio:var(--voltom-camera-ratio,4 / 3);flex-shrink:0;margin-inline:auto;position:relative;overflow:hidden;container-type:size}[data-voltom-camera]>video,[data-voltom-mesh],[data-voltom-overlay]{object-fit:contain;width:100%;height:100%;position:absolute;inset:0}[data-voltom-mesh],[data-voltom-overlay]{object-fit:fill}[data-voltom-mesh]{color:var(--theme-canvas)}[data-voltom-mesh],[data-voltom-overlay],[data-voltom-guide],[data-voltom-ring],[data-voltom-direction],[data-voltom-challenge],[data-voltom-result],[data-voltom-spinner],[data-voltom-feedback]{pointer-events:none}[data-voltom-feedback]{z-index:10;text-align:center;flex-direction:column;justify-content:center;align-items:center;gap:.75rem;padding-inline:1rem;display:flex;position:absolute;inset:0}[data-voltom-camera][data-mirrored]>video,[data-voltom-camera][data-mirrored] [data-voltom-mesh]{--tw-scale-x:calc(100% * -1);scale:var(--tw-scale-x) var(--tw-scale-y)}[data-voltom-guide-mode=document]{border-style:var(--tw-border-style);--tw-border-style:dashed;border-style:dashed;border-width:2px;border-color:var(--theme-border);height:90cqh;margin:auto;display:block;position:absolute;inset:0}[data-voltom-guide-mode=document][data-voltom-guide-orientation=landscape]{aspect-ratio:4/3}[data-voltom-guide-mode=document][data-voltom-guide-orientation=portrait]{aspect-ratio:3/4}[data-voltom-ring-wrap]{pointer-events:none;z-index:5;width:66cqh;height:66cqh;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}[data-voltom-ring-wrap]:not([data-voltom-ring-mode=face]){display:none}[data-voltom-ring-wrap] [data-pose-progress]{width:100%;height:100%}[data-voltom-direction]{width:36px;height:36px;color:var(--theme-mint);pointer-events:none;z-index:10;position:absolute;bottom:14cqh;left:50%;transform:translate(-50%)}[data-voltom-direction]:not([data-voltom-direction-pose]){display:none}[data-voltom-debug]{pointer-events:none;z-index:10;border-style:var(--tw-border-style);border-width:1px;border-color:var(--theme-border);background-color:var(--theme-surface);border-radius:.375rem;width:200px;display:none;position:absolute;top:.75rem;left:.75rem}@supports (color:color-mix(in lab, red, red)){[data-voltom-debug]{background-color:color-mix(in oklab, var(--theme-surface) 70%, transparent)}}[data-voltom-debug]{font-family:var(--font-mono,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);--tw-leading:calc(.25rem * 4);color:var(--theme-text-muted);--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);--tw-shadow-color:var(--theme-border);padding-block:.25rem;padding-inline:.5rem;font-size:10px;line-height:1rem}@supports (color:color-mix(in lab, red, red)){[data-voltom-debug]{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--theme-border) 30%, transparent) var(--tw-shadow-alpha), transparent)}}[data-voltom-debug]{--tw-backdrop-blur:blur(8px);-webkit-backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, );backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, )}[data-voltom-debug]:not(.hidden){display:block}[data-voltom-camera]>[data-pose-success]{z-index:30;transform-origin:50%;width:96px;height:96px;margin:auto;position:absolute;inset:0}[data-voltom-debug] [data-valid=true]{color:var(--theme-mint)}[data-voltom-debug] [data-valid=false]{color:var(--theme-danger)}[data-voltom-overlay][data-idle]{background-color:var(--theme-canvas);place-items:center;display:grid}@supports (color:color-mix(in lab, red, red)){[data-voltom-overlay][data-idle]{background-color:color-mix(in oklab, var(--theme-canvas) 70%, transparent)}}[data-voltom-overlay][data-idle]:before{background-color:var(--theme-surface);border-radius:.375rem}@supports (color:color-mix(in lab, red, red)){[data-voltom-overlay][data-idle]:before{background-color:color-mix(in oklab, var(--theme-surface) 80%, transparent)}}[data-voltom-overlay][data-idle]:before{text-align:center;font-size:1.25rem;line-height:var(--tw-leading,var(--text-xl--line-height,calc(1.75 / 1.25)));color:var(--theme-cyan);--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);--tw-backdrop-blur:blur(8px);-webkit-backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, );backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, );content:attr(data-voltom-overlay-label);padding-block:.75rem;padding-inline:1rem}[data-voltom-overlay][data-error]:before{content:none}[data-voltom-challenge]{z-index:10;background-color:var(--theme-surface);max-width:calc(100vw - 1.5rem);color:var(--theme-text);--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);--tw-shadow-color:var(--theme-border);inset-inline:.75rem;border-radius:.625rem;justify-content:center;align-items:center;gap:.5rem;padding-block:.5rem;padding-inline:.75rem;display:flex;position:absolute;top:.75rem}@supports (color:color-mix(in lab, red, red)){[data-voltom-challenge]{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--theme-border) 30%, transparent) var(--tw-shadow-alpha), transparent)}}[data-voltom-challengeText]{text-align:center;font-size:1rem;line-height:var(--tw-leading,var(--text-base--line-height,calc(1.5 / 1)));--tw-font-weight:var(--font-weight-semibold,600);font-weight:var(--font-weight-semibold,600);flex-direction:column;display:flex}[data-voltom-challengeReason]{font-size:.875rem;line-height:var(--tw-leading,var(--text-sm--line-height,calc(1.25 / .875)));--tw-font-weight:var(--font-weight-medium,500);font-weight:var(--font-weight-medium,500);color:var(--theme-warning)}[data-voltom-spinner]{z-index:20;background-color:var(--theme-canvas);flex-direction:column;justify-content:center;align-items:center;gap:.75rem;display:flex;position:absolute;inset:0}@supports (color:color-mix(in lab, red, red)){[data-voltom-spinner]{background-color:color-mix(in oklab, var(--theme-canvas) 90%, transparent)}}[data-voltom-spinner]{text-align:center;font-size:1.25rem;line-height:var(--tw-leading,var(--text-xl--line-height,calc(1.75 / 1.25)));--tw-font-weight:var(--font-weight-semibold,600);font-weight:var(--font-weight-semibold,600);color:var(--theme-text);--tw-backdrop-blur:blur(8px);-webkit-backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, );backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, )}[data-voltom-spinner]:before{width:2rem;height:2rem;animation:var(--animate-spin,spin 1s linear infinite);border-style:var(--tw-border-style);border-width:4px;border-color:var(--theme-border);border-radius:2147483647px;display:block}@supports (color:color-mix(in lab, red, red)){[data-voltom-spinner]:before{border-color:color-mix(in oklab, var(--theme-border) 30%, transparent)}}[data-voltom-spinner]:before{border-top-color:var(--theme-cyan)}@media (prefers-reduced-motion:reduce){[data-voltom-spinner]:before{animation:none}}[data-voltom-spinner]:before{content:""}[data-voltom-result]{pointer-events:auto;width:fit-content;max-width:100%;font-size:1.25rem;line-height:var(--tw-leading,var(--text-xl--line-height,calc(1.75 / 1.25)));--tw-font-weight:var(--font-weight-semibold,600);font-weight:var(--font-weight-semibold,600);--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);--tw-backdrop-blur:blur(8px);-webkit-backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, );backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, );border-radius:.375rem;padding-block:.5rem;padding-inline:1rem}[data-voltom-retry]{pointer-events:auto;border-style:var(--tw-border-style);border-width:1px;border-color:var(--theme-border);background-color:var(--theme-surface);border-radius:.375rem}@supports (color:color-mix(in lab, red, red)){[data-voltom-retry]{background-color:color-mix(in oklab, var(--theme-surface) 90%, transparent)}}[data-voltom-retry]{font-size:1.25rem;line-height:var(--tw-leading,var(--text-xl--line-height,calc(1.75 / 1.25)));--tw-font-weight:var(--font-weight-bold,700);font-weight:var(--font-weight-bold,700);color:var(--theme-text);--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);--tw-shadow-color:var(--theme-border);padding-block:.75rem;padding-inline:1rem}@supports (color:color-mix(in lab, red, red)){[data-voltom-retry]{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--theme-border) 30%, transparent) var(--tw-shadow-alpha), transparent)}}[data-voltom-retry]{--tw-backdrop-blur:blur(8px);-webkit-backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, );backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, );transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function,cubic-bezier(.4, 0, .2, 1)));transition-duration:var(--tw-duration,var(--default-transition-duration,.15s))}@media (hover:hover){[data-voltom-retry]:hover{background-color:var(--theme-surface-subtle)}}[data-voltom-result].is-success{border-style:var(--tw-border-style);border-width:1px;border-color:var(--theme-success)}@supports (color:color-mix(in lab, red, red)){[data-voltom-result].is-success{border-color:color-mix(in oklab, var(--theme-success) 50%, transparent)}}[data-voltom-result].is-success{background-color:var(--theme-success-surface);color:var(--theme-success)}[data-voltom-result].is-failure{border-style:var(--tw-border-style);border-width:1px;border-color:var(--theme-danger)}@supports (color:color-mix(in lab, red, red)){[data-voltom-result].is-failure{border-color:color-mix(in oklab, var(--theme-danger) 50%, transparent)}}[data-voltom-result].is-failure{background-color:var(--theme-danger-surface);color:var(--theme-danger)}[data-voltom-root] .hidden{display:none}}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}`})),PC=n({createVerificationDisplay:()=>uC,createVerificationView:()=>LC}),FC,IC,LC,RC=t((()=>{hh(),xe(),qe(),_C(),It(),Kt(),CC(),kC(),jC(),iS(),KS(),AS(),NC(),hC(),FC=new Set([`FACE_NOT_DETECTED`,`FACE_IN_POLYGON`,`FACE_TOO_SMALL`,`FACE_CENTER_MOVE_LEFT`,`FACE_CENTER_MOVE_RIGHT`,`FACE_CENTER_MOVE_UP`,`FACE_CENTER_MOVE_DOWN`,`FACE_CAMERA_ALIGNMENT_REQUIRED`]),IC=({className:e,display:t,elements:n,options:r})=>{let[i,a]=Ce(!0),{translate:o,translateError:s}=Wt({language:r.language}),c=t.feedback.value,l=t.activity.value,d=l&&l!==`matching`?l.message:``,f=l===`matching`?o(`checkingFaceMatch`):d,p=t.error.value,m=t.cameraSize.value,h=c&&c.flow===`face`?c.pose:void 0,g=c&&c.flow===`face`?c.code:null,_=g&&FC.has(g)?g:null;t.guidance.value;let v=t.progress.value,y=t.corrective.value,b=h?rS({pose:h,corrective:y}):null,x=o(`lookStraight`),S=``;if(b&&(x=o(b.primary),S=b.corrective?o(b.corrective):``),_&&(x=o(kS({code:_})),S=``),c&&c.flow===`document`){let e=o(OS({target:c.target}));x=(c.code&&c.code!==`DOCUMENT_NOT_DETECTED`?o(kS({code:c.code})):``)||e}let C=m&&m.width<m.height?`portrait`:`landscape`;return $(u,{children:[$(`style`,{"data-voltom-styles":``,children:MC}),$(`div`,{className:e,ref:n.camera,"data-voltom":``,"data-voltom-camera":``,"data-mirrored":t.cameraFacingMode.value===`user`?``:void 0,style:{"--voltom-camera-ratio":m?`${m.width} / ${m.height}`:void 0},children:[$(`video`,{ref:n.video,"data-voltom-video":``,playsInline:!0,muted:!0,autoPlay:!0,onPlaying:()=>a(!1),onEmptied:()=>a(!0)}),$(`canvas`,{ref:n.mesh,"data-voltom-mesh":``}),$(`div`,{"data-voltom-overlay":``,"data-voltom-overlay-label":o(`readyToStart`),"data-idle":i?``:void 0,"data-error":p?``:void 0}),$(`div`,{"data-voltom-guide":``,"aria-hidden":`true`,"data-voltom-guide-mode":c?.flow,"data-voltom-guide-orientation":c?.flow===`document`?C:void 0}),$(`div`,{"data-voltom-ring-wrap":``,"aria-hidden":`true`,"data-voltom-ring-mode":c?.flow??``,children:$(SC,{completed:v.completed,total:v.total,variant:`ring`})}),!(!h||_)&&$(OC,{"data-voltom-direction":``,"data-voltom-direction-pose":h,pose:h}),$(AC,{visible:t.success.value}),$(gC,{kind:`voltom`,entries:t.debug.value}),$(`div`,{"data-voltom-spinner":``,className:l?void 0:`hidden`,role:`status`,"aria-label":f,children:d}),$(`div`,{"data-voltom-challenge":h??(c?`document`:void 0),className:c?void 0:`hidden`,children:$(`span`,{"data-voltom-challengeText":``,role:`status`,"aria-live":`polite`,children:[$(`span`,{children:x}),!!S&&$(`span`,{"data-voltom-challengeReason":``,children:S})]})}),$(`div`,{"data-voltom-feedback":``,children:[$(`div`,{"data-voltom-result":``,className:p?`is-failure`:`hidden`,role:`status`,children:p?s({error:p}):``}),$(`button`,{"data-voltom-retry":``,className:p&&t.retry.value?void 0:`hidden`,type:`button`,"aria-label":o(`retry`),onClick:async()=>{let e=t.retry.value;if(t.error.value=null,e)try{await e()}catch{return}},children:o(`retry`)})]})]})]})},LC=({root:e,options:t,display:n})=>{let r=({language:e})=>e??Ht(),i=({state:e})=>e.faceSequence[e.poseIndex]??`faceStraight`,a=0,o=({entries:e,state:t})=>{if(!n.debugEnabled.value||!t.flow)return;let r=performance.now();r-a<100||(a=r,n.debug.value=e)},s=()=>n.cameraSize.value?`${n.cameraSize.value.width}x${n.cameraSize.value.height}`:`—`,c=()=>{let e=fh(),t=e.threading.startsWith(`multi`)?`multi`:`single`;return[{label:`Inference`,value:e.inference},{label:`Threading`,value:t}]},u=({face:e,faceInPolygon:a,processingTimeMilliseconds:l,state:u})=>{let d=e?e.pitch:null,f=e?e.yaw:null,p=e?e.roll:null,m=e?NS({face:e,name:`mouthSmileLeft`}):0,h=e?NS({face:e,name:`mouthSmileRight`}):0,g=e?NS({face:e,name:`eyeBlinkLeft`}):0,_=e?NS({face:e,name:`eyeBlinkRight`}):0,v=d!==null&&d>=t.minPitch&&d<=t.maxPitch,y=f!==null&&f>=t.minYaw&&f<=t.maxYaw,b=i({state:u}),x=p!==null&&(b===`faceTiltLeft`?p>t.maxRoll:b===`faceTiltRight`?p<-t.maxRoll:Math.abs(p)<=t.maxRoll),S=e=>e===null?`—`:e.toFixed(2),C=(e,t)=>`${e.toFixed(2)}|${t.toFixed(2)}`;o({state:u,entries:[{label:`Flow`,value:`FACE`},...c(),{label:`Face`,valid:!!e&&!a,value:e?a?`In polygon`:`Yes`:`No`},{label:`Pitch`,valid:v,value:S(d)},{label:`Yaw`,valid:y,value:S(f)},{label:`Roll`,valid:x,value:S(p)},{label:`Smile`,valid:m>=.5&&h>=.5,value:C(m,h)},{label:`Wink left`,valid:g>=.5&&_<=.35&&g>=_+.15,value:C(g,_)},{label:`Stable frames`,valid:u.poseStableFrames>0,value:`${u.poseStableFrames}/${t.requiredFaceStableFrames}`},{label:`Language`,value:r({language:t.language})},{label:`Camera`,value:s()},{label:`Facing mode`,value:n.cameraFacingMode.value??`—`},{label:`Frame time`,value:`${l.toFixed(0)} ms`}]})},d=({analysis:e,sideComparison:i,isBack:a,processingTimeMilliseconds:l,state:u})=>{let{orientation:d,alignment:f,documentKind:p,face:m,faceContained:h,detection:g}=e,{diagnostics:_,isBlurry:v,sharpness:y}=e.documentAnalysis,b=e.text.text,x={label:`Stable frames`,valid:u.documentStableFrames>0,value:`${u.documentStableFrames}/${t.requiredDocumentStableFrames}`},S=_?Object.keys(_.rejected)[0]:void 0,C=[{label:`Sharpness`,valid:v===null?void 0:!v,value:y===null?`—`:String(Math.round(y))},{label:`Rectangle`,valid:g?!0:!S&&void 0,value:g?`yes`:S??`no`},{label:`Orientation`,value:d?`${d.rotation}°`:`—`}],w=[{label:`Text`,valid:!!b,value:b?`yes`:`no`},{label:`Document type`,value:p??``},{label:`Distinct from front`,valid:i?.distinct,value:i?i.distinct?`yes`:`no`:`—`}],T=[{label:`Face`,valid:!!m,value:m?`yes`:`no`},{label:`Face contained`,valid:h,value:h?`yes`:`no`},{label:`Face area`,valid:f.faceAreaValid,value:`${(f.faceAreaRatio*100).toFixed(2)}%`},{label:`Face size`,valid:f.faceDimensionsValid,value:f.faceDimensionsValid?`yes`:`no`},{label:`Text`,valid:!!b,value:b?`yes`:`no`},{label:`Text parallel`,valid:f.textParallel,value:f.textParallel?`yes`:`no`},{label:`Text beside face`,valid:f.faceAdjacentTextLineCount>=2,value:String(f.faceAdjacentTextLineCount)},{label:`Document type`,value:p??``}];o({state:u,entries:[{label:`Flow`,value:a?`DOCUMENT BACK`:`DOCUMENT FRONT`},...c(),...C,...a?w:T,x,{label:`Language`,value:r({language:t.language})},{label:`Camera`,value:s()},{label:`Facing mode`,value:n.cameraFacingMode.value??`—`},{label:`Frame time`,value:`${l.toFixed(0)} ms`}]})},f={camera:l(),video:l(),mesh:l()};if(e.replaceChildren(),e.dataset.voltomRoot=``,re($(IC,{display:n,elements:f,options:t}),e),!f.camera.current||!f.video.current||!f.mesh.current)throw Error(M.UI_ELEMENT_NOT_FOUND);return{ref:{root:e,camera:f.camera.current,video:f.video.current,mesh:f.mesh.current},collectFaceDebug:u,collectDocumentDebug:d}}}));Mt(),xe(),It(),Kt(),on(),dC();var zC=class{options;view;root;useUi;videoElement;resizeListener;display=uC();translator;flows;state;lastPicture;preparation=null;preloading=null;preparationController=null;prepared=!1;disposed=!1;operationController=null;subscriptions=new Set;uiAttached=!1;notifyStatus({status:e}){this.root.dispatchEvent(new CustomEvent(`voltom:${e}`))}showSpinner({message:e=this.translator.translate(`checkingFaceMatch`)}={}){this.display.activity.value={message:e}}hideSpinner(){this.display.activity.value=null}async runWithSpinner({task:e,message:t}){this.showSpinner({message:t});try{return await e()}finally{this.hideSpinner()}}constructor(e){let{root:t,video:n,ui:r,...i}=e,a=r??!!t;if(a&&!t||!a&&!n)throw Error(M.INVALID_OPTIONS);if(!i.clientKey)throw Error(M.CLIENT_KEY_REQUIRED);this.options=Object.freeze({...fC,...i,requireEyeLevelCamera:i.requireEyeLevelCamera??!0,capabilities:Object.freeze([...i.capabilities??fC.capabilities]),poses:Array.isArray(i.poses)?Object.freeze([...i.poses]):i.poses}),this.root=t??document.createElement(`div`),this.useUi=a,this.videoElement=n??document.createElement(`video`),this.translator=Wt({language:this.options.language}),this.view={ref:{root:this.root,camera:document.createElement(`div`),video:this.videoElement,mesh:document.createElement(`canvas`)},collectFaceDebug:()=>{},collectDocumentDebug:()=>{}},this.flows=oC({options:this.options,view:this.view,display:this.display}),this.lastPicture=null,this.state=this.flows.createState(),this.resizeListener=()=>this.flows.syncCameraSize({state:this.state}),this.videoElement.addEventListener(`resize`,this.resizeListener)}async preload(){if(this.disposed)throw Error(M.SDK_NOT_READY);if(this.preloading)return this.preloading;let e=(async()=>{await Vt({language:this.options.language}),await this.flows.preloadModels()})();this.preloading=e;try{if(await e,this.disposed)throw Error(M.SDK_NOT_READY)}catch(t){throw this.preloading===e&&(this.preloading=null),t}}async prepare(){if(this.disposed)throw Error(M.SDK_NOT_READY);if(this.preparation)return this.preparation;let e=new AbortController;this.preparationController=e;let t=(async()=>{await this.preload(),await this.attachUi(),await this.runWithSpinner({task:async()=>{if(await XS({clientKey:this.options.clientKey,apiUrl:this.options.apiUrl,signal:e.signal}),await ZS({apiUrl:this.options.apiUrl}),await this.flows.initializeModels(),e.signal.throwIfAborted(),this.disposed)throw Error(M.SDK_NOT_READY)},message:this.translator.translate(`preparingModels`)})})();this.preparation=t;try{await t,this.prepared=!0,this.preparationController===e&&(this.preparationController=null)}catch(n){throw this.preparation===t&&(this.preparation=null),this.preparationController===e&&(this.preparationController=null),n}}async attachUi(){if(!this.useUi||this.uiAttached)return;let{createVerificationView:e}=await Promise.resolve().then(()=>(RC(),PC));if(this.disposed)throw Error(M.SDK_NOT_READY);let t=e({root:this.root,options:this.options,display:this.display});this.videoElement.removeEventListener(`resize`,this.resizeListener),Object.assign(this.view.ref,t.ref),this.view.collectFaceDebug=t.collectFaceDebug,this.view.collectDocumentDebug=t.collectDocumentDebug,this.videoElement=this.view.ref.video,this.videoElement.addEventListener(`resize`,this.resizeListener),this.uiAttached=!0}async submitHardVerification(e){let t=e.endpoint===`/verification/document`?this.translator.translate(`checkingDocument`):void 0;return await this.runWithSpinner({task:()=>this.flows.submitHardVerification({...e,signal:e.signal??this.operationController?.signal}),message:t})}async caniuse(){return await Xt()}async runOperation({retry:e,task:t,onError:n,capability:r,settings:i}){if(this.disposed||!this.prepared)throw Error(M.SDK_NOT_READY);if(!this.options.capabilities.includes(r))throw Error(M.SDK_CAPABILITY_NOT_CONFIGURED);if(this.operationController)throw Error(M.INVALID_OPTIONS);let{signal:a,...o}=i,s=Object.freeze({...this.options,...o,poses:Array.isArray(o.poses)?Object.freeze([...o.poses]):o.poses??this.options.poses}),c=new AbortController;this.operationController=c;let l=()=>c.abort();a?.addEventListener(`abort`,l,{once:!0}),a?.aborted&&l(),c.signal.addEventListener(`abort`,()=>this.flows.stop({state:this.state}),{once:!0}),this.notifyStatus({status:`in-progress`}),Ye(()=>{this.display.retry.value=e,this.display.error.value=null,this.display.debugEnabled.value=s.debug,s.debug||(this.display.debug.value=[])});try{return c.signal.throwIfAborted(),await t({options:s,signal:c.signal})}catch(e){let t=c.signal.aborted?Error(M.VERIFICATION_CANCELLED,{cause:e}):e;throw n&&await n({error:t,options:s,signal:c.signal}),this.disposed||this.flows.showError({error:t,state:this.state}),t}finally{this.notifyStatus({status:`ready`}),a?.removeEventListener(`abort`,l),this.display.debugEnabled.value=this.options.debug,this.operationController===c&&(this.operationController=null)}}async verifyHuman(e={}){return await this.verifyCapture({flow:`human`,...e})}async verifyDocument(e={}){return await this.verifyCapture({flow:`document`,...e})}async verifyCapture({flow:e,...t}){let n=({options:t})=>{e===`human`?this.flows.resetFaceFlow({state:this.state,options:t}):this.flows.resetDocumentFlow({state:this.state}),this.flows.notifyCapturesChanged({state:this.state})};return await this.runOperation({capability:e===`human`?`verifyHuman`:`verifyDocument`,settings:t,retry:()=>this.verifyCapture({flow:e,...t,signal:void 0}),onError:async({error:t,options:r})=>{(e===`human`?this.state.faceCaptureConfiguration!==null:this.state.documentCaptureConfiguration!==null)&&Ft({error:t})!==M.VERIFICATION_CANCELLED&&n({options:r})},task:async({options:t,signal:r})=>{r.throwIfAborted(),await(e===`human`?this.flows.startFaceFlow:this.flows.startDocumentFlow)({state:this.state,options:t}),r.throwIfAborted();let i=await this.submitHardVerification({configuration:t,endpoint:`/verification/${e}`,state:this.state}),a=e===`human`?`hardHumanVerificationId`:`hardDocumentVerificationId`;return this.state[a]=i.verificationId,i.outcome!==`pass`||i.matched!==!0?(this.state[a]=null,n({options:t}),i):(this.display.retry.value=null,i)}})}async ensureHumanVerification({options:e,signal:t}){if(t?.throwIfAborted(),this.flows.hasCompatibleFaceCaptures({state:this.state,options:e})||await this.flows.startFaceFlow({state:this.state,options:e}),t?.throwIfAborted(),this.state.hardHumanVerificationId)return null;let n=await this.submitHardVerification({configuration:e,endpoint:`/verification/human`,state:this.state}),r=n.outcome===`pass`&&n.matched===!0;return this.state.hardHumanVerificationId=r?n.verificationId:null,r?null:n}async matchID(e={}){return await this.runOperation({capability:`matchID`,settings:e,retry:()=>this.matchID({...e,signal:void 0}),task:async({options:e,signal:t})=>{t.throwIfAborted();let n=await this.ensureHumanVerification({options:e,signal:t});if(n)return n;if(t.throwIfAborted(),this.flows.hasCompatibleDocumentCapture({state:this.state,options:e})||await this.flows.startDocumentFlow({state:this.state,options:e}),!this.state.hardDocumentVerificationId){t.throwIfAborted();let n=await this.submitHardVerification({configuration:e,endpoint:`/verification/document`,state:this.state});if(this.state.hardDocumentVerificationId=n.verificationId,n.outcome!==`pass`||n.matched!==!0)return this.state.hardDocumentVerificationId=null,n}let r=await this.submitHardVerification({configuration:e,endpoint:`/verification/id`,state:this.state,sourceIds:[this.state.hardHumanVerificationId,this.state.hardDocumentVerificationId]});return r.outcome!==`pass`||r.matched!==!0||(this.display.retry.value=null),r}})}async matchPicture(e,t={}){return this.lastPicture=e,await this.runOperation({capability:`matchPicture`,settings:t,retry:async()=>{this.lastPicture&&await this.matchPicture(this.lastPicture,{...t,signal:void 0})},task:async({options:t,signal:n})=>{n.throwIfAborted();let r=await lC({blob:e,signal:n})??await nn({blob:e});if(n.throwIfAborted(),!this.state.hardHumanVerificationId){let e=await this.ensureHumanVerification({options:t,signal:n});if(e)return e}await this.flows.startPictureFlow({picture:r,state:this.state,options:t,signal:n}),n.throwIfAborted();let i=await this.submitHardVerification({configuration:t,endpoint:`/verification/picture`,state:this.state,picture:r,sourceIds:[this.state.hardHumanVerificationId]});return i.outcome!==`pass`||i.matched!==!0||(this.display.retry.value=null),i}})}stop(){this.operationController?.abort(new DOMException(M.VERIFICATION_CANCELLED,`AbortError`)),this.flows.stop({state:this.state}),this.display.retry.value=null,this.notifyStatus({status:`ready`})}dispose(){if(!this.disposed){this.disposed=!0,this.preparationController?.abort(),this.stop();for(let e of this.subscriptions)e();this.subscriptions.clear(),this.videoElement.removeEventListener(`resize`,this.resizeListener),re(null,this.root),this.state.captures={},this.state.preparedCaptures={},this.state.faceEmbeddings={},this.state.documentCodes=[],this.state.identity=null,this.state.hardHumanVerificationId=null,this.state.hardDocumentVerificationId=null,this.state.faceCaptureConfiguration=null,this.state.documentCaptureConfiguration=null,delete this.state.document,this.lastPicture=null}}forgetHuman(){if(this.disposed)throw Error(M.SDK_NOT_READY);this.flows.resetFaceFlow({state:this.state}),this.display.error.value=null,this.flows.notifyCapturesChanged({state:this.state})}forgetDocument(){if(this.disposed)throw Error(M.SDK_NOT_READY);this.flows.resetDocumentFlow({state:this.state}),this.display.error.value=null,this.flows.notifyCapturesChanged({state:this.state})}getState(){return{activity:this.display.activity.value,error:this.display.error.value,retryAvailable:this.display.retry.value!==null,feedback:this.display.feedback.value,debug:this.display.debug.value}}subscribe(e){if(this.disposed)throw Error(M.SDK_NOT_READY);let t=lt(()=>e(this.getState()));return this.subscriptions.add(t),()=>{t(),this.subscriptions.delete(t)}}};a();var BC=globalThis.document?.currentScript,VC=globalThis.HTMLScriptElement&&BC instanceof globalThis.HTMLScriptElement?BC.src:globalThis.location.href;r({moduleUrl:VC}),globalThis.VoltomVerify=zC})();
|
|
66
|
+
`),n=t.match(/ANSI\s+\d{6}(\d{2})\d{2}(\d{2})/u),r=n?(n.index??0)+n[0].length:0,i=n?t.slice(r,r+2):null,a=(n?t.slice(r+Number(n[2])*10):t).replace(/^(?:DL|ID)(?=D[A-Z]{2})/u,``),o={};for(let e of a.matchAll(/(?:^|\n)([A-Z]{3})([^\n]*)/g)){let[,t,n]=e;o[t]=n.trim()}if(!o.DCS&&!o.DAC)throw Error(j.INVALID_DOCUMENT_AAMVA);let s=Z(o.DCG),c=Z(o.DAG),l=Z(o.DAI),u=Z(o.DAJ),d=Z(o.DAK),f=[c,l,[u,d].filter(Boolean).join(` `)].filter(Boolean).join(`, `);return Ny.parse({document:{source:`AAMVA`,type:i===`ID`?`ID`:`DRV`,issuing_country:s,number:Z(o.DAQ),issue_date:SS({value:o.DBD,country:s,source:`AAMVA`,kind:`issue`}),expiry_date:SS({value:o.DBA,country:s,source:`AAMVA`,kind:`expiry`}),optional_data:null},holder:{first_name:Z(o.DAC),last_name:Z(o.DCS),middle_name:Z(o.DAD),birth_date:SS({value:o.DBB,country:s,source:`AAMVA`,kind:`birth`}),sex:o.DBC===`1`?`M`:o.DBC===`2`?`F`:null,nationality:null,personal_number:null},address:f?{full:f,street:c,city:l,state_province:u,postal_code:d}:null,raw_data:{mrz_lines:[],aamva_version:n?n[1]:null}})}})),DS,OS,kS,AS,jS,MS,NS,PS,FS,IS,LS,RS,zS,BS,VS,HS,US=t((()=>{bS(),DS=[{format:`TD1`,lineCount:3,lineLength:30},{format:`TD2`,lineCount:2,lineLength:36},{format:`TD3`,lineCount:2,lineLength:44}],OS={0:`O`,1:`I`,8:`B`,B:`8`,I:`1`,O:`0`},kS=4096,AS=4,jS=`ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789<`,MS=e=>/^[A-Z0-9<]$/u.test(e),NS=e=>e.map(e=>e.normalize(`NFKC`).toUpperCase().replace(/\s+/gu,``)),PS=({format:e,line:t,position:n})=>{if(t===0&&n===1)return`separator`;if(t===0&&n===0)return`alphanumeric`;if(e===`TD1`){if(t===0&&n===14)return`digit`;if(t===0)return n>=2&&n<=4?`alpha`:`alphanumeric`;if(t===1&&(n<=6||n>=8&&n<=14||n===29))return`digit`;if(t===1&&n===7)return`sex`;if(t===1&&n>=15&&n<=17||t===2)return`alpha`}if(e===`TD2`||e===`TD3`){if(t===0)return`alpha`;if(t===1&&(n===9||n===19||n===27||e===`TD2`&&n===35||e===`TD3`&&(n===42||n===43)))return`digit`;if(t===1&&n===20)return`sex`;if(t===1&&n>=10&&n<=12)return`alpha`;if(t===1&&n>=13&&n<=18||n>=21&&n<=26)return`digit`}return`alphanumeric`},FS=(e,t)=>e===`separator`?t===`<`:e===`digit`?/^[0-9]$/u.test(t):e===`alpha`?/^[A-Z<]$/u.test(t):e===`sex`?t===`M`||t===`F`||t===`<`:MS(t),IS=({character:e,type:t,necessaryOnly:n})=>{let r=new Set;if(FS(t,e)){if(n)return[e];r.add(e)}let i=OS[e];return i&&FS(t,i)&&r.add(i),[...r]},LS=({format:e,line:t,text:n,necessaryOnly:r})=>{let i=[``];for(let[a,o]of[...n].entries()){let n=IS({character:o,type:PS({format:e,line:t,position:a}),necessaryOnly:r});if(!n.length||(i=i.flatMap(e=>n.map(t=>`${e}${t}`)),i.length>kS))return[]}return i},RS=({text:e,length:t,first:n})=>{let r=[],i=e=>{!e.split(``).every(MS)||n&&!/^[A-Z0-9]<[A-Z]{3}/u.test(e)||n&&(e.match(/</gu)?.length??0)<2||r.push(e)};for(let n=0;n<=e.length-t;n+=1)i(e.slice(n,n+t));if(e.length===t-1)for(let t=0;t<=e.length;t+=1){let n=e[t-1],r=e[t],a=n&&n===r?[n]:[];for(let n of a)n&&jS.includes(n)&&i(`${e.slice(0,t)}${n}${e.slice(t)}`)}return r},zS=({lines:e,spec:t})=>{let n=[],r=e.map(e=>RS({text:e,length:t.lineLength,first:!1})),i=({index:a,selected:o,start:s})=>{if(o.length===t.lineCount){n.push(o);return}let c=t.lineCount-o.length,l=e.length-c,u=o.length===0?s:a+1;for(let n=u;n<=l;n+=1){if(o.length>0&&n-a>AS)continue;let s=r[n]??[],c=o.length===0?RS({text:e[n]??``,length:t.lineLength,first:!0}):s;for(let e of c)i({index:n,selected:[...o,e],start:n+1})}};return i({index:-4,selected:[],start:0}),n},BS=({group:e,spec:t,necessaryOnly:n=!1})=>{let r=e.map((e,r)=>LS({format:t.format,line:r,text:e,necessaryOnly:n}));if(r.some(e=>e.length===0))return[];let i=[],a=(e,t)=>{if(e===r.length)i.push(t.join(`
|
|
67
|
+
`));else for(let n of r[e]??[])a(e+1,[...t,n])};return a(0,[]),i},VS=e=>{try{return vS(e.split(`
|
|
68
|
+
`)).valid}catch{return!1}},HS=e=>{let t=new Set,n=new Set,r=new Set,i=NS(e);for(let e of DS)for(let a of zS({lines:i,spec:e})){let i=a.join(`
|
|
69
|
+
`);VS(i)&&t.add(i);for(let t of BS({group:a,spec:e,necessaryOnly:!0}))VS(t)&&n.add(t);for(let t of BS({group:a,spec:e}))VS(t)&&r.add(t)}return t.size===1?[...t][0]??null:t.size>1?null:n.size===1?[...n][0]??null:n.size>1?null:r.size===1?[...r][0]??null:null}})),WS,GS=t((()=>{bS(),ES(),US(),WS=({result:e})=>{let t=e.lines.map(e=>e.text.normalize(`NFKC`).toUpperCase().replaceAll(`Π`,`T`).replace(/\s+/gu,``)).filter(e=>e.length>=29&&/^[A-Z0-9<]+$/u.test(e)),n=HS(t);if(!n)return null;try{if(!vS(n.split(`
|
|
70
|
+
`)).valid)return null;let e=wS(n);return e?{type:`mrz`,code:n,payload:e}:null}catch{return null}}})),KS,qS,JS,YS,XS,ZS,QS=t((()=>{fd(),ES(),KS=null,qS=async()=>{if(globalThis.window===void 0)return`zxing-wasm/reader`;let e=await dd({filename:`zxing-wasm/share.js`});return await dd({filename:`zxing-wasm/reader/index.js`,imports:{"../share.js":e}})},JS=async()=>{let e=await import(await qS());return globalThis.window!==void 0&&e.setZXingModuleOverrides({wasmBinary:await ud({filename:`zxing-wasm/reader/zxing_reader.wasm`})}),e},YS=async()=>{KS??=JS();try{return await KS}catch(e){throw KS=null,e}},XS=async()=>{await(await YS()).prepareZXingModule({fireImmediately:!0})},ZS=async({image:e})=>{let t=await(await YS()).readBarcodes(e,{formats:[`PDF417`],tryHarder:!0});for(let e of t)try{let t=TS(e.text);return{type:`aamva`,code:e.text,payload:t}}catch{}return null}})),$S,eC=t((()=>{W(),$v(),sy(),yy(),Cy(),Hy(),GS(),QS(),$S=({runtime:e,detector:t,alignment:n,text:r,readImage:i})=>{let a=async({image:a,language:o,engine:s,scanBarcodes:c=!1})=>{let l=a instanceof Blob?a:new Blob([a]),u=await e.createImageBitmap(l);try{let a=await t.analyzeDocument({frame:u});if(!a.detection)throw Error(j.DOCUMENT_NOT_FOUND);let l=await n.orientDocumentFrame({frame:u,polygon:a.detection.polygon,orientation:a.detection.orientation});if(!l)throw Error(j.IMAGE_PROCESSING_FAILED);try{let t=vy({image:i({frame:u}),polygon:a.detection.polygon,sourceOrientation:l.orientation.rotation}),n=await r.readRectifiedText({frame:l.frame,language:o,engine:s,image:t});if(!n)throw Error(j.DOCUMENT_TEXT_NOT_READABLE);let d=i({frame:l.frame}),f=null;if(c){let t=e.createImageData(d.width,d.height);t.data.set(d.data),f=await ZS({image:t})}let p=[WS({result:n}),f].filter(e=>e!==null),m=i({frame:l.frame,width:32,height:32});return{ocr:n,codes:p,pixels:d,signature:ry({...m,text:n.text}),blurry:a.isBlurry}}finally{l.frame.close()}}finally{u.close()}};return{classifyDocument:async({document_front:e,document_back:t,language:n,engine:r})=>{let i=await a({image:e,language:n,engine:r}),o=Zv({image:i.pixels,text:i.ocr.text,codes:i.codes});if(!o)throw Error(j.DOCUMENT_NOT_RECOGNIZED);let s=o.europeanDrivingLicense?Vy({ocr:i.ocr,image:i.pixels}):null,c=by({document:o.document})&&t?await a({image:t,language:o.europeanDrivingLicense?`latin`:n,engine:o.europeanDrivingLicense?`tiny`:r,scanBarcodes:!0}):null,l=Sy({classification:{...o,identity:s},front:i,back:c}),u=[...l.reasons],d=c?c.blurry:!1;return(i.blurry||d)&&u.push(j.DOCUMENT_BLURRY),c&&!ay({front:i.signature,current:c.signature}).distinct&&u.push(j.DOCUMENT_BACK_NOT_DISTINCT),{identity:s,...o,...l,reasons:u,valid:u.length===0,document_front:i.ocr,document_back:c?c.ocr:null}},detectDocument:async({image:e,language:t})=>{let n=await a({image:e,language:t,scanBarcodes:!0}),r=Zv({image:n.pixels,text:n.ocr.text,codes:n.codes});if(!r)throw Error(j.DOCUMENT_NOT_RECOGNIZED);let i=n.codes.find(e=>e.type===`mrz`),o=n.codes.find(e=>e.type===`aamva`),s=!!o||r.document===`id`&&!!i;return{identity:!s&&r.europeanDrivingLicense?Vy({ocr:n.ocr,image:n.pixels}):null,document_type:r.document===`driving_license`?`drv`:r.document,document_side:s?`back`:`front`,mrz_code:i?i.code:null,ammva_code:o?o.code:null}},extractDocumentCodes:async({images:e})=>{let t=[];for(let n of e){let e=await a({image:n,scanBarcodes:!0});t.push(...e.codes)}return[...new Map(t.map(e=>[`${e.type}:${e.code}`,e])).values()]}}}})),Q,tC=t((()=>{Xu(),W(),Q={language:`en`,ocrEngine:`auto`,alignment:`eyes-nose-mouth`,maxPitch:8,minPitch:-20,maxYaw:12,minYaw:-12,maxRoll:8,minDocumentFaceAreaRatio:.02,maxDocumentFaceAreaRatio:.3,minDocumentFaceWidthRatio:.075,maxDocumentFaceWidthRatio:.4,minDocumentFaceHeightRatio:.1,maxDocumentFaceHeightRatio:.65,minDocumentBoxRatio:.33,maxDocumentTextAngleDifference:16},V({language:z().default(Q.language),ocrEngine:Pl([`auto`,`tiny`,`small`,`japanese`,`chinese-simplified`,`chinese-traditional`,`cyrillic`,`arabic`]).default(Q.ocrEngine),alignment:Fl(`eyes-nose-mouth`).default(Q.alignment),maxPitch:B().positive().max(90).default(Q.maxPitch),minPitch:B().negative().min(-90).default(Q.minPitch),maxYaw:B().positive().max(90).default(Q.maxYaw),minYaw:B().negative().min(-90).default(Q.minYaw),maxRoll:B().positive().max(90).default(Q.maxRoll),minDocumentFaceAreaRatio:B().min(0).max(1).default(Q.minDocumentFaceAreaRatio),maxDocumentFaceAreaRatio:B().min(0).max(1).default(Q.maxDocumentFaceAreaRatio),minDocumentFaceWidthRatio:B().min(0).max(1).default(Q.minDocumentFaceWidthRatio),maxDocumentFaceWidthRatio:B().min(0).max(1).default(Q.maxDocumentFaceWidthRatio),minDocumentFaceHeightRatio:B().min(0).max(1).default(Q.minDocumentFaceHeightRatio),maxDocumentFaceHeightRatio:B().min(0).max(1).default(Q.maxDocumentFaceHeightRatio),minDocumentBoxRatio:B().min(0).max(1).default(Q.minDocumentBoxRatio),maxDocumentTextAngleDifference:B().min(0).max(90).default(Q.maxDocumentTextAngleDifference)}).refine(e=>e.minDocumentFaceAreaRatio<=e.maxDocumentFaceAreaRatio&&e.minDocumentFaceWidthRatio<=e.maxDocumentFaceWidthRatio&&e.minDocumentFaceHeightRatio<=e.maxDocumentFaceHeightRatio,j.INVALID_OPTIONS)})),nC,rC,iC,aC,oC,sC,cC=t((()=>{nC=({data:e,height:t,normalize:n,width:r})=>{let i=new Float32Array(r*t*3),a=r*t;for(let t=0;t<a;t+=1)for(let r=0;r<3;r+=1)i[r*a+t]=n(e[t*4+r]);return i},rC=({first:e,second:t})=>{let n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return n*r/(e.width*e.height+t.width*t.height-n*r||1)},iC=({detections:e,threshold:t})=>e.toSorted((e,t)=>t.score-e.score).filter((e,n,r)=>!r.slice(0,n).some(n=>rC({first:n.boundingRect,second:e.boundingRect})>t)),aC=({face:e,x:t,y:n})=>({...e,boundingRect:{...e.boundingRect,x:e.boundingRect.x+t,y:e.boundingRect.y+n},mesh:{...e.mesh,landmarks:e.mesh.landmarks.map(e=>({...e,x:e.x+t,y:e.y+n}))}}),oC=({faces:e})=>{let t=[];for(let n of e)t.some(e=>rC({first:e.boundingRect,second:n.boundingRect})>.3)||t.push(n);return t},sC=({frameSize:e,tileSize:t})=>[...new Set([0,Math.round((e-t)/2),e-t])]})),lC,uC,dC=t((()=>{cC(),lC=({outputs:e})=>({score_8:e.out0,score_16:e.out1,score_32:e.out2,bbox_8:e.out3,bbox_16:e.out4,bbox_32:e.out5,kps_8:e.out6,kps_16:e.out7,kps_32:e.out8}),uC=({outputs:e,scale:t,threshold:n=.5})=>{let r=[];for(let i of[8,16,32]){let a=e[`score_${i}`]?.data,o=e[`bbox_${i}`]?.data,s=e[`kps_${i}`]?.data;if(!a||!o||!s)continue;let c=640/i;for(let e=0;e<a.length;e+=1){let l=a[e];if(l<n)continue;let u=Math.floor(e/2),d=u%c*i,f=Math.floor(u/c)*i,p=e*4,m=e*10,h=e=>({x:(d+s[m+e*2]*i)/t,y:(f+s[m+e*2+1]*i)/t});r.push({boundingRect:{x:(d-o[p]*i)/t,y:(f-o[p+1]*i)/t,width:(o[p]+o[p+2])*i/t,height:(o[p+1]+o[p+3])*i/t},score:l,keypoints:{leftEye:h(0),rightEye:h(1),nose:h(2),mouthLeft:h(3),mouthRight:h(4)}})}}return iC({detections:r,threshold:.4})}})),fC,pC,mC,hC,gC,_C,vC=t((()=>{W(),fC=128,pC=.1,mC=4,hC=({image:e})=>{let t=65536,n=new Float32Array(t*3);for(let r=0,i=0;r<e.data.length;r+=4,i+=1)n[i]=(e.data[r]??0)/255,n[i+t]=(e.data[r+1]??0)/255,n[i+t*2]=(e.data[r+2]??0)/255;return n},gC=({polygon:e})=>{let t=e.reduce((t,n)=>({x:t.x+n.x/e.length,y:t.y+n.y/e.length}),{x:0,y:0}),n=[...e].sort((e,n)=>Math.atan2(e.y-t.y,e.x-t.x)-Math.atan2(n.y-t.y,n.x-t.x)),r=n.reduce((e,t,r)=>t.x+t.y<n[e].x+n[e].y?r:e,0);return n.slice(r).concat(n.slice(0,r))},_C=({heatmap:e,height:t,width:n})=>{if(e.length!==512*fC)throw Error(j.INVALID_MODEL_OUTPUT);let r=[],i=1;for(let a=0;a<4;a+=1){let o=a*fC*fC,s=-1/0,c=0;for(let t=0;t<16384;t+=1){let n=e[o+t]??-1/0;n>s&&(s=n,c=t)}if(s<pC)throw Error(j.DOCUMENT_NOT_FOUND);i=Math.min(i,s);let l=c%fC,u=Math.floor(c/fC),d=s*.3,f=0,p=0,m=0;for(let t=Math.max(0,u-mC);t<=Math.min(127,u+mC);t+=1)for(let n=Math.max(0,l-mC);n<=Math.min(127,l+mC);n+=1){let r=e[o+t*fC+n]??0;r<d||(f+=r,p+=r*n,m+=r*t)}r.push({x:(f?p/f:l)*n/fC,y:(f?m/f:u)*t/fC})}if(i<pC)throw Error(j.DOCUMENT_NOT_FOUND);return gC({polygon:r})}})),yC,bC=t((()=>{yC=({face:e,polygon:t})=>{if(!e)return!1;let n={x:e.boundingRect.x+e.boundingRect.width/2,y:e.boundingRect.y+e.boundingRect.height/2},r=!1;for(let e=0,i=t.length-1;e<t.length;i=e++){let a=t[e],o=t[i];a.y>n.y!=o.y>n.y&&n.x<(o.x-a.x)*(n.y-a.y)/(o.y-a.y)+a.x&&(r=!r)}return r}})),xC,SC=t((()=>{Xu(),xC=z().regex(/^data:image\/jpeg;base64,(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/).meta({format:`data-url`,contentEncoding:`base64`,contentMediaType:`image/jpeg`})})),CC,wC,TC=t((()=>{Xu(),CC=[`pass`,`fail`,`error`],wC=Pl(CC)})),EC,DC,OC,kC=t((()=>{Xu(),W(),TC(),EC=V({resultId:wl(),token:z().min(32).max(128),action:z().min(1).max(255),expiresAt:Ku({offset:!0})}),DC=Pl([`pending`,`consumed`,`resolved`,`expired`,`failed`]),OC=Ml(z(),Dl()),V({resultId:wl(),product:Pl([`facegate`,`facekey`,`verify`]),subjectId:z().nullable(),action:z(),status:DC,outcome:wC.nullable(),reason:Zu.nullable(),metadata:z().nullable(),documentCode:z().nullable(),createdAt:Ku({offset:!0}),expiresAt:Ku({offset:!0}),consumedAt:Ku({offset:!0}).nullable(),resolvedAt:Ku({offset:!0}).nullable(),result:OC.nullable()})})),AC,jC,MC,NC,PC,FC,IC,LC,RC,zC,BC,VC,HC,UC,WC,GC,KC,qC,JC,YC,XC,ZC,QC,$C=t((()=>{Xu(),W(),SC(),kC(),AC=[`faceStraight`,`faceUp`,`faceLeft`,`faceRight`,`faceSmile`],jC={faceDown:{pitch:20},faceLeft:{yaw:30},faceRight:{yaw:-30},faceTiltLeft:{roll:15},faceTiltRight:{roll:-15},faceUp:{pitch:-20}},MC=Pl(AC),NC=z().min(1).max(255),PC=V({id:wl()}),FC=V({id:NC}),IC=Pl([`enroll`,`unlock`,`forget`]),LC=Pl([`enroll`,`unlock`]),RC=Pl([`pending`,`started`,`failed`,`completed`]),zC=V({token:z().min(32).max(128),subjectId:NC.optional()}),BC=zC.extend({poses:kl(MC).min(1).max(AC.length),faces:kl(xC).min(1).max(AC.length)}),VC=kl(B().finite()).length(512).refine(e=>Math.abs(Math.hypot(...e)-1)<.001),HC=Nl(MC,VC).and(V({faceStraight:VC})),UC=V({pose:MC,matched:El(),score:B().min(-1).max(1)}),WC=kl(MC).min(1).max(AC.length).refine(e=>e[0]===`faceStraight`&&new Set(e).size===e.length),GC=V({action:LC,subjectId:NC.optional(),poses:WC.optional()}).refine(e=>e.action===`enroll`||e.subjectId!==void 0&&e.poses===void 0),KC=V({subjectId:NC}).strict(),qC=V({subjectId:NC}),JC=EC.extend({subjectId:NC,action:LC,poses:kl(MC).max(AC.length)}),YC=qC.extend({matched:El(),matches:kl(UC).max(2),reason:Zu.nullable()}),XC=V({vectors:kl(V({pose:MC,vector:VC})).max(AC.length),reason:Zu.nullable(),attributes:V({age:B(),gender:Pl([`female`,`male`]),genderScore:B()}).nullable().optional()}),ZC={id:PC,identityId:FC,pose:MC,subjectId:NC,action:IC,tokenAction:LC,status:RC,tokenInput:zC,captureInput:BC,vector:VC,vectors:HC,intentInput:GC,forgetInput:KC,listInput:V({search:z().default(``)}),identity:qC,intent:JC,unlock:YC,analysisResult:XC,intentStatus:V({resultId:z().uuid(),action:IC,subjectId:NC,status:RC})},V({subject_id:z(),created_at:z(),operations_count:B().int()}),QC=V({origin:z().nullable(),ip:z().nullable(),user_agent:z().nullable(),timezone:z().nullable(),country:z().nullable(),region:z().nullable(),city:z().nullable()}),V({subject_id:z(),created_at:z(),operations:kl(V({created_at:z(),action:ZC.action})),registration:QC.nullable(),last_unlock:QC.nullable()}),V({enrollments:B().int(),operations:kl(V({created_at:z(),action:ZC.action,status:ZC.status,country:z().nullable()}))})})),ew,tw,nw=t((()=>{ew=.2,tw=({blendshapes:e})=>{let t=e.eyeBlinkLeft??0,n=e.eyeBlinkRight??0;return Math.round((t-n)*100)/100>=ew}})),rw,iw,aw,ow,sw=t((()=>{$C(),nw(),rw=({axis:e,target:t,tolerance:n,value:r})=>r>=t-n&&r<=t+n?null:e===`yaw`?t>0?r<t?`FACEKEY_TURN_HEAD_LEFT`:`FACEKEY_TURN_HEAD_LESS`:r>t?`FACEKEY_TURN_HEAD_RIGHT`:`FACEKEY_TURN_HEAD_LESS`:e===`pitch`?t>0?r<t?`FACEKEY_LOWER_HEAD`:`FACEKEY_LOWER_HEAD_LESS`:r>t?`FACEKEY_RAISE_HEAD`:`FACEKEY_RAISE_HEAD_LESS`:t>0?r<t?`FACEKEY_TILT_HEAD_LEFT`:`FACEKEY_TILT_HEAD_LESS`:r>t?`FACEKEY_TILT_HEAD_RIGHT`:`FACEKEY_TILT_HEAD_LESS`,iw=({pitch:e,yaw:t,roll:n,options:r})=>n<-r.maxRoll?`FACEKEY_TILT_HEAD_LEFT`:n>r.maxRoll?`FACEKEY_TILT_HEAD_RIGHT`:t<r.minYaw?`FACEKEY_TURN_HEAD_LEFT`:t>r.maxYaw?`FACEKEY_TURN_HEAD_RIGHT`:e<r.minPitch?`FACEKEY_LOWER_HEAD`:e>r.maxPitch?`FACEKEY_RAISE_HEAD`:null,aw=({blendshapes:e,pitch:t,yaw:n,roll:r,pose:i,options:a})=>{if(i===`faceSmile`)return iw({pitch:t,yaw:n,roll:r,options:a})||((e.mouthSmileLeft??0)>=.5&&(e.mouthSmileRight??0)>=.5?null:`FACEKEY_SMILE_REQUIRED`);if(i===`faceWinkLeft`)return iw({pitch:t,yaw:n,roll:r,options:a})||(tw({blendshapes:e,pose:i})?null:`FACEKEY_WINK_LEFT_REQUIRED`);let o=jC[i];if(!o)return iw({pitch:t,yaw:n,roll:r,options:a});if(o.roll===void 0){if(r<-a.maxRoll)return`FACEKEY_TILT_HEAD_LEFT`;if(r>a.maxRoll)return`FACEKEY_TILT_HEAD_RIGHT`}if(o.yaw===void 0){if(n<a.minYaw)return`FACEKEY_TURN_HEAD_LEFT`;if(n>a.maxYaw)return`FACEKEY_TURN_HEAD_RIGHT`}if(o.pitch===void 0){if(t<a.minPitch)return`FACEKEY_LOWER_HEAD`;if(t>a.maxPitch)return`FACEKEY_RAISE_HEAD`}let s=a.tolerance??15;return o.roll===void 0?o.yaw===void 0?o.pitch===void 0?null:rw({axis:`pitch`,target:o.pitch,tolerance:s,value:t}):rw({axis:`yaw`,target:o.yaw,tolerance:s,value:n}):o.roll>0&&r<=a.maxRoll?`FACEKEY_TILT_HEAD_LEFT`:o.roll<0&&r>=-a.maxRoll?`FACEKEY_TILT_HEAD_RIGHT`:rw({axis:`roll`,target:o.roll,tolerance:s,value:r})},ow=({alignment:e,target:t})=>{let n=`yaw`;for(let r of[`pitch`,`roll`])Math.abs(e[r]-t[r])>Math.abs(e[n]-t[n])&&(n=r);return rw({axis:n,value:e[n],target:t[n],tolerance:15})}})),cw,lw=t((()=>{cw=.51})),uw,dw,fw,pw=t((()=>{W(),lw(),uw=({first:e,second:t})=>{if(e.length!==t.length||e.length===0)throw Error(j.INVALID_MODEL_OUTPUT);let n=e.reduce((e,n,r)=>e+n*t[r],0);return Math.max(-1,Math.min(1,n))},dw=({score:e,threshold:t=cw})=>({matched:e>t,score:Math.round(e*100)/100}),fw=({first:e,second:t})=>Math.max(uw({first:e.rgb,second:t.rgb}),uw({first:e.grayscale,second:t.grayscale}))})),mw,hw=t((()=>{mw=({homography:e,point:t})=>{let n=e[6]*t.x+e[7]*t.y+e[8];return{x:(e[0]*t.x+e[1]*t.y+e[2])/n,y:(e[3]*t.x+e[4]*t.y+e[5])/n}}})),gw=t((()=>{sw(),nw()})),_w,vw,yw,bw,xw,Sw,Cw=t((()=>{_w=8,vw=.16,yw=({x:e,y:t,width:n,height:r})=>{let i=e/n,a=t/r;return i<.2||i>=.8||a<.2||a>=.8},bw=({value:e})=>{let t=0,n=e;for(;n;)t+=n&1,n>>>=1;return t},xw=({image:e})=>{let t=[];for(let n=0;n<_w;n+=1)for(let r=0;r<_w;r+=1){let i=0,a=0,o=Math.floor(n*e.height/_w),s=Math.floor((n+1)*e.height/_w),c=Math.floor(r*e.width/_w),l=Math.floor((r+1)*e.width/_w);for(let t=o;t<s;t+=1)for(let n=c;n<l;n+=1){if(!yw({height:e.height,width:e.width,x:n,y:t}))continue;let r=(t*e.width+n)*4;i+=(e.data[r]??0)*.299+(e.data[r+1]??0)*.587+(e.data[r+2]??0)*.114,a+=1}t.push(a?i/a:0)}let n=t.reduce((e,t)=>e+t,0)/t.length,r=new Uint8Array(Math.ceil(t.length/8));for(let[e,i]of t.entries())i>=n&&(r[Math.floor(e/8)]|=1<<e%8);return{appearanceHash:r}},Sw=({first:e,second:t})=>{if(e.appearanceHash.length!==t.appearanceHash.length)return{distance:1,matched:!1};let n=e.appearanceHash.reduce((e,n,r)=>e+bw({value:n^(t.appearanceHash[r]??0)}),0)/(e.appearanceHash.length*8);return{distance:n,matched:n<=vw}}})),ww,Tw=t((()=>{$C(),ww=({poses:e})=>{let t=[],n=[`yaw`,`pitch`,`roll`];for(let[r,i]of e.entries()){let a=t.find(t=>t.candidateIndices.every(t=>n.every(n=>Math.abs(e[t][n]-i[n])<=15)));if(!a)t.push({candidateIndices:[r],pose:{...i}});else{a.candidateIndices.push(r);for(let t of n){let n=a.candidateIndices.map(n=>e[n][t]);a.pose[t]=(Math.min(...n)+Math.max(...n))/2}}}return t}})),Ew=t((()=>{Py(),tC(),dC(),vC(),$v(),ES(),sy(),yy(),Cy(),bC(),cC(),sw(),pw(),hw(),gw(),L_(),US(),Cw(),Tw(),GS()})),Dw,Ow,kw=t((()=>{W(),V_(),Dw=({outputs:e})=>{for(let t of new Set(Object.values(e)))t.dispose()},Ow=async({label:e,session:t,feeds:n})=>{let r=performance.now();try{return await t.run(n)}catch(e){throw Error(Pt({error:e,fallback:j.INFERENCE_FAILED}),{cause:e})}finally{for(let e of new Set(Object.values(n)))e.dispose();z_({category:`inference`,duration:performance.now()-r,key:e})}}})),Aw,jw,Mw,Nw,Pw,Fw,Iw=t((()=>{W(),jv(),kw(),Aw=224,jw=256,Mw=[0,90,180,270],Nw=[.485,.456,.406],Pw=[.229,.224,.225],Fw=({runtime:e})=>{let t=async()=>{await e.session({filename:`do.ort`})},n=({frame:t,boundingRect:n={x:0,y:0,width:t.width,height:t.height}})=>{let r=Math.max(0,Math.floor(n.x)),i=Math.max(0,Math.floor(n.y)),a=Math.min(t.width,Math.ceil(n.x+n.width))-r,o=Math.min(t.height,Math.ceil(n.y+n.height))-i;if(a<=0||o<=0)throw Error(j.IMAGE_PROCESSING_FAILED);let s=jw/Math.min(a,o),c=Math.round(a*s),l=Math.round(o*s),u=e.createCanvas(Aw,Aw),d=u.getContext(`2d`,{willReadFrequently:!0});if(!d)throw Error(j.IMAGE_PROCESSING_FAILED);d.drawImage(t,r,i,a,o,-Math.floor((c-Aw)/2),-Math.floor((l-Aw)/2),c,l);let{data:f}=d.getImageData(0,0,Aw,Aw);Av({canvas:u});let p=50176,m=new Float32Array(p*3);for(let e=0;e<3;e+=1)for(let t=0;t<p;t+=1)m[e*p+t]=(f[t*4+e]/255-Nw[e])/Pw[e];return m};return{detectDocumentOrientation:async({frame:t,boundingRect:r})=>{let i=await e.session({filename:`do.ort`}),a=n({frame:t,boundingRect:r}),o=await Ow({label:`document.orientation`,session:i,feeds:{x:e.tensor(`float32`,a,[1,3,Aw,Aw])}});try{let e=o.fetch_name_0?.data;if(!(e instanceof Float32Array)||e.length!==4||e.some(e=>!Number.isFinite(e)||e<0||e>1))throw Error(j.INVALID_MODEL_OUTPUT);let t={0:e[0],90:e[1],180:e[2],270:e[3]},n=Mw.reduce((e,n)=>t[n]>t[e]?n:e);return{rotation:n,confidence:t[n],scores:t}}finally{Dw({outputs:o})}},loadDocumentOrientationDetector:t}}})),Lw,Rw=t((()=>{W(),uy(),Ew(),Iw(),jv(),kw(),Lw=({runtime:e})=>{let{detectDocumentOrientation:t,loadDocumentOrientationDetector:n}=Fw({runtime:e}),r=`dd.ort`,i=.15,a=.75,o=.03,s=.8,c=({from:e,to:t})=>Math.hypot(t.x-e.x,t.y-e.y),l=({origin:e,first:t,second:n})=>(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x),u=({polygon:e})=>{let t=0;for(let n=0;n<e.length;n+=1){let r=e[n],i=e[(n+1)%e.length];t+=r.x*i.y-i.x*r.y}return Math.abs(t/2)},d=async({frame:t,sourceOrientation:n=0})=>{let i=e.createCanvas(256,256),a=i.getContext(`2d`);if(!a)throw Error(j.IMAGE_PROCESSING_FAILED);a.translate(128,128),a.rotate(-n*Math.PI/180),a.drawImage(t,-128,-128,256,256);let o=a.getImageData(0,0,256,256);Av({canvas:i});let s=hC({image:{data:o.data,height:256,width:256}}),c=await e.session({filename:r}),l=await Ow({label:`document.box`,session:c,feeds:{img:e.tensor(`float32`,s,[1,3,256,256])}});try{let e=l.heatmap?.data;if(!(e instanceof Float32Array))throw Error(j.INVALID_MODEL_OUTPUT);try{let r=n%180?t.height:t.width,i=n%180?t.width:t.height;return{confidence:null,polygon:_C({heatmap:e,height:i,width:r})}}catch(e){if(e instanceof Error&&e.message===j.DOCUMENT_NOT_FOUND)return null;throw e}}finally{Dw({outputs:l})}},f=async({frame:e})=>{let n=await d({frame:e}),r=null;if(n){let i=ly({polygon:n.polygon});i.width>0&&i.height>0&&(r=await t({frame:e,boundingRect:i}),r.rotation&&(n=await d({frame:e,sourceOrientation:r.rotation})))}let i=r!==null&&r.rotation%180!=0;return{detected:n,orientation:r,width:i?e.height:e.width,height:i?e.width:e.height}},p=({detection:e,frame:t,orientation:n})=>{let r=e.polygon.map(({x:e,y:r})=>n?.rotation===90?{x:t.width-1-r,y:e}:n?.rotation===180?{x:t.width-1-e,y:t.height-1-r}:n?.rotation===270?{x:r,y:t.height-1-e}:{x:e,y:r}),i=cy({polygon:r});return{polygon:i,boundingRect:ly({polygon:i}),...n?{orientation:n}:{}}},m=({frame:t})=>{let n=Math.min(1,480/Math.max(t.width,t.height)),r=e.createCanvas(Math.max(1,Math.round(t.width*n)),Math.max(1,Math.round(t.height*n))),i=r.getContext(`2d`,{willReadFrequently:!0});if(!i)throw Error(j.IMAGE_PROCESSING_FAILED);return i.drawImage(t,0,0,r.width,r.height),{canvas:r,scale:n}},h=({data:e})=>{let t=new Uint8Array(e.length/4);for(let n=0;n<t.length;n+=1){let r=n*4;t[n]=Math.round(e[r]*.299+e[r+1]*.587+e[r+2]*.114)}return t},g=({pixels:e,width:t,height:n})=>{let r=0,i=0,a=0;for(let o=1;o<n-1;o+=1)for(let n=1;n<t-1;n+=1){let s=e[o*t+n]*8-(e[(o-1)*t+n]+e[(o+1)*t+n]+e[o*t+n-1]+e[o*t+n+1]+e[(o-1)*t+n-1]+e[(o-1)*t+n+1]+e[(o+1)*t+n-1]+e[(o+1)*t+n+1]);i+=s,a+=s*s,r+=1}if(!r)return 0;let o=i/r;return Math.max(0,a/r-o*o)},_=({previous:e,current:t,next:n})=>{let r=e.x-t.x,i=e.y-t.y,a=n.x-t.x,o=n.y-t.y,s=Math.hypot(r,i)*Math.hypot(a,o);return s?Math.acos(Math.max(-1,Math.min(1,(r*a+i*o)/s)))*180/Math.PI:0},v=({first:e,second:t})=>{let n=Math.hypot(e.x,e.y),r=Math.hypot(t.x,t.y);if(!n||!r)return 90;let i=Math.abs(e.x*t.y-e.y*t.x)/(n*r);return Math.asin(Math.min(1,i))*180/Math.PI},y=({first:e,second:t})=>Math.min(e,t)/Math.max(e,t),b=({polygon:e})=>{if(e.length!==4||e.some(e=>!Number.isFinite(e.x)||!Number.isFinite(e.y)))return!1;let t=e.map((t,n)=>c({from:t,to:e[(n+1)%e.length]}));if(t.some(e=>e<=0))return!1;let n=e.map((t,n)=>l({origin:t,first:e[(n+1)%e.length],second:e[(n+2)%e.length]}));if(!n.every(e=>e>0)&&!n.every(e=>e<0))return!1;let r=e.map((t,n)=>{let r=e[(n+1)%e.length];return{x:r.x-t.x,y:r.y-t.y}}),i=v({first:r[0],second:r[2]})<=36&&v({first:r[1],second:r[3]})<=36,a=y({first:t[0],second:t[2]})>=s&&y({first:t[1],second:t[3]})>=s;return i&&a},x=({height:e,minDocumentBoxRatio:t,polygon:n,width:r})=>{if(n.length!==4)return{detection:null,rejection:`polygon_invalid`};if(!b({polygon:n}))return{detection:null,rejection:`geometry`};let i=r,s=e;if(n.map((e,t)=>_({previous:n[(t-1+n.length)%n.length],current:e,next:n[(t+1)%n.length]})).some(e=>e<35||e>145))return{detection:null,rejection:`corner_angle`};let l=[c({from:n[0],to:n[1]}),c({from:n[2],to:n[3]})],d=[c({from:n[1],to:n[2]}),c({from:n[3],to:n[0]})],f=(l[0]+l[1])/2,p=(d[0]+d[1])/2,m=Math.max(f,p)/Math.min(f,p),h=u({polygon:n})/(i*s);if(m<1.25||m>2.4)return{detection:null,rejection:`aspect_ratio`};if(h<t)return{detection:null,rejection:`coverage_low`};if(h>.99)return{detection:null,rejection:`coverage_high`};let g=n.some(e=>e.x<i*o||e.y<s*o||e.x>i*.97||e.y>s*.97);if(h>a&&g)return{detection:null,rejection:`edge_proximity`};let v=n.some(e=>e.y<s*o)&&n.some(e=>e.y>s*.97)||n.some(e=>e.x<i*o)&&n.some(e=>e.x>i*.97);if(i>s&&v&&h<a)return{detection:null,rejection:`opposite_edges`};let y=n,x=y.map(e=>e.x),S=y.map(e=>e.y),C=Math.min(...x),w=Math.min(...S),T=Math.max(...x),E=Math.max(...S);return{detection:{polygon:y,boundingRect:{x:C,y:w,width:T-C,height:E-w}},rejection:null}},S=async()=>{await e.session({filename:r})},C=async({frame:e,minDocumentBoxRatio:t=i})=>{let{canvas:n}=m({frame:e}),r=n.getContext(`2d`,{willReadFrequently:!0});if(!r)throw Error(j.IMAGE_PROCESSING_FAILED);let a=r.getImageData(0,0,n.width,n.height),o=n.width,s=n.height;Av({canvas:n});let c=h({data:a.data}),l=g({pixels:c,width:o,height:s}),{detected:u,orientation:d,width:_,height:v}=await f({frame:e}),y=u?x({height:v,minDocumentBoxRatio:t,polygon:u.polygon,width:_}):{detection:null,rejection:null},b={};return y.rejection&&(b[y.rejection]=1),{detection:y.detection?p({detection:y.detection,frame:e,orientation:d}):null,diagnostics:{accepted:+!!y.detection,confidence:u?.confidence??null,rejected:b},isBlurry:l<1e3,sharpness:l}};return{loadDocumentBoxDetector:S,detectDocumentOrientation:t,loadDocumentOrientationDetector:n,analyzeDocument:C,detectDocument:async e=>(await C({frame:e})).detection,detectDocumentBox:async e=>{let t=await d({frame:e});if(!t)return null;let n=x({height:e.height,minDocumentBoxRatio:i,polygon:t.polygon,width:e.width});return n.detection?p({detection:n.detection,frame:e,orientation:null}):null}}}})),zw,Bw,Vw=t((()=>{Ew(),vv(),kw(),zw=({detection:e,frame:t})=>{let n=Math.max(e.boundingRect.width,e.boundingRect.height)*1.1,r=Math.max(1,Math.min(Math.ceil(n),t.width,t.height)),i=e.boundingRect.x+e.boundingRect.width/2,a=e.boundingRect.y+e.boundingRect.height/2;return{size:r,x:Math.max(0,Math.min(t.width-r,Math.round(i-r/2))),y:Math.max(0,Math.min(t.height-r,Math.round(a-r/2)))}},Bw=({runtime:e,imageFromImageBitmap:t})=>{let n=`_neutral.browDownLeft.browDownRight.browInnerUp.browOuterUpLeft.browOuterUpRight.cheekPuff.cheekSquintLeft.cheekSquintRight.eyeBlinkLeft.eyeBlinkRight.eyeLookDownLeft.eyeLookDownRight.eyeLookInLeft.eyeLookInRight.eyeLookOutLeft.eyeLookOutRight.eyeLookUpLeft.eyeLookUpRight.eyeSquintLeft.eyeSquintRight.eyeWideLeft.eyeWideRight.jawForward.jawLeft.jawOpen.jawRight.mouthClose.mouthDimpleLeft.mouthDimpleRight.mouthFrownLeft.mouthFrownRight.mouthFunnel.mouthLeft.mouthLowerDownLeft.mouthLowerDownRight.mouthPressLeft.mouthPressRight.mouthPucker.mouthRight.mouthRollLower.mouthRollUpper.mouthShrugLower.mouthShrugUpper.mouthSmileLeft.mouthSmileRight.mouthStretchLeft.mouthStretchRight.mouthUpperUpLeft.mouthUpperUpRight.noseSneerLeft.noseSneerRight`.split(`.`),r=[0,1,4,5,6,7,8,10,13,14,17,21,33,37,39,40,46,52,53,54,55,58,61,63,65,66,67,70,78,80,81,82,84,87,88,91,93,95,103,105,107,109,127,132,133,136,144,145,146,148,149,150,152,153,154,155,157,158,159,160,161,162,163,168,172,173,176,178,181,185,191,195,197,234,246,249,251,263,267,269,270,276,282,283,284,285,288,291,293,295,296,297,300,308,310,311,312,314,317,318,321,323,324,332,334,336,338,356,361,362,365,373,374,375,377,378,379,380,381,382,384,385,386,387,388,389,390,397,398,400,402,405,409,415,454,466,468,469,470,471,472,473,474,475,476,477],i=`standard`,a=({frame:e,height:n,width:r})=>t({frame:e,height:n,width:r}).data,o=({outputs:e,scale:t,threshold:n})=>{let r=[];for(let i of[8,16,32]){let a=e[`score_${i}`]??e[`cls_${i}`],o=e[`bbox_${i}`],s=e[`kps_${i}`],c=e[`obj_${i}`];if(!a||!o||!s)continue;let l=a.data,u=c?.data,d=o.data,f=s.data,p=640/i;for(let e=0;e<l.length;e+=1){let a=l[e]*(u?u[e]:1);if(a<n)continue;let o=Math.floor(e/2),s=(o%p+.5)*i,c=(Math.floor(o/p)+.5)*i,m=e*4,h=e*10,g=e=>({x:(s+f[h+e*2]*i)/t,y:(c+f[h+e*2+1]*i)/t});r.push({boundingRect:{x:(s-d[m]*i)/t,y:(c-d[m+1]*i)/t,width:(d[m]+d[m+2])*i/t,height:(d[m+1]+d[m+3])*i/t},score:a,keypoints:{leftEye:g(0),rightEye:g(1),nose:g(2),mouthLeft:g(3),mouthRight:g(4)}})}}return iC({detections:r,threshold:.4})},s=async({frame:t,faceDetector:n})=>{let r=640/Math.max(t.width,t.height),i=Math.round(t.width*r),s=Math.round(t.height*r),c=a({frame:t,height:s,width:i}),l=nC({data:c,height:s,width:i,normalize:e=>(e-127.5)/128}),u=new Float32Array(1228800);for(let e=0;e<3;e+=1)for(let t=0;t<s;t+=1)u.set(l.subarray(e*i*s+t*i,e*i*s+(t+1)*i),e*640*640+t*640);let d=await e.session({filename:hv[n]}),f=await Ow({label:`face.detector`,session:d,feeds:{[d.inputNames[0]]:e.tensor(`float32`,u,[1,3,640,640])}});try{return n===`standard`?uC({outputs:lC({outputs:f}),scale:r,threshold:.5}):o({outputs:f,scale:r,threshold:.5})}finally{Dw({outputs:f})}},c=async({frame:t})=>{let n=a({frame:t,height:128,width:128}),r=new Float32Array(49152);for(let e=0;e<49152;e+=1)r[e]=n[Math.floor(e/3)*4+e%3]/127.5-1;let i=await e.session({filename:hv.low}),o=await Ow({label:`face.detector`,session:i,feeds:{[i.inputNames[0]]:e.tensor(`float32`,r,[1,128,128,3])}});try{let e=o.regressors.data,n=o.classificators.data,r=[],i=[];for(let{count:e,copies:t}of[{count:16,copies:2},{count:8,copies:6}])for(let n=0;n<e;n+=1)for(let r=0;r<e;r+=1)for(let a=0;a<t;a+=1)i.push({x:(r+.5)/e,y:(n+.5)/e});for(let a=0;a<n.length;a+=1){let o=1/(1+Math.exp(-n[a]));if(o<.5)continue;let s=a*16,c=i[a];if(!c)continue;let l=n=>({x:(e[s+5+n*2]+c.x*128)*(t.width/128),y:(e[s+4+n*2]+c.y*128)*(t.height/128)}),u=e[s+3]*(t.width/128),d=e[s+2]*(t.height/128),f=(e[s+1]+c.x*128)*(t.width/128),p=(e[s]+c.y*128)*(t.height/128);r.push({boundingRect:{x:f-u/2,y:p-d/2,width:u,height:d},score:o,keypoints:{leftEye:l(0),rightEye:l(1),nose:l(2),mouthLeft:l(3),mouthRight:l(4)}})}return iC({detections:r,threshold:.3})}finally{Dw({outputs:o})}},l=async({blendshapes:i=!0,detection:a,frame:o})=>{let{size:s,x:c,y:l}=zw({detection:a,frame:o}),u=t({frame:o,height:256,width:256,sourceRect:{x:c,y:l,width:s,height:s}}).data,d=await e.session({filename:`fl.ort`}),f=await Ow({label:`face.landmarks`,session:d,feeds:{[d.inputNames[0]]:e.tensor(`float32`,nC({data:u,height:256,width:256,normalize:e=>e/255}),[1,3,256,256])}});try{if(f.score.data[0]<.5)return null;let t=f.landmarks.data,u=Array.from({length:478},(e,n)=>({x:c+t[n*3]*s/256,y:l+t[n*3+1]*s/256,z:t[n*3+2]*s/256})),d=u[33],p=u[263],m=u[1],h=(m.y-(d.y+p.y)/2)/Math.abs(p.x-d.x)*100,g=(m.x-(d.x+p.x)/2)/Math.abs(p.x-d.x)*100,_=new Float32Array(n.length);if(i){let t=new Float32Array(292);for(let e=0;e<r.length;e+=1){let n=u[r[e]];t[e*2]=n.x,t[e*2+1]=n.y}let n=await e.session({filename:`fe.ort`}),i=await Ow({label:`face.blendshape`,session:n,feeds:{[n.inputNames[0]]:e.tensor(`float32`,t,[1,146,2])}});try{_=i[n.outputNames[0]].data}finally{Dw({outputs:i})}}return{blendshapes:Object.fromEntries(n.map((e,t)=>[e,_[t]??0])),pitch:h-54,yaw:g-5,roll:Math.atan2(p.y-d.y,p.x-d.x)*180/Math.PI,boundingRect:a.boundingRect,mesh:{height:o.height,landmarks:u,width:o.width}}}finally{Dw({outputs:f})}},u=async({faceDetector:t=`standard`}={})=>{i=t,await Promise.all([e.session({filename:hv[t]}),e.session({filename:`fl.ort`}),e.session({filename:`fe.ort`})])},d=async({blendshapes:e=!0,frame:t})=>{let n=i===`low`?await c({frame:t}):await s({frame:t,faceDetector:i});return(await Promise.all(n.map(n=>l({blendshapes:e,detection:n,frame:t})))).filter(e=>e!==null)},f=async e=>(await d({frame:e}))[0]??null,p=async({blendshapes:t=!0,frame:n,tileHeight:r,tileWidth:i})=>{let a=[];for(let o of sC({frameSize:n.height,tileSize:r}))for(let s of sC({frameSize:n.width,tileSize:i})){let c=await e.createImageBitmap(n,s,o,i,r);try{let e=await d({blendshapes:t,frame:c});a.push(...e.map(e=>aC({face:e,x:s,y:o})))}finally{c.close()}}return a},m=async({blendshapes:e=!0,frame:t})=>await p({blendshapes:e,frame:t,tileHeight:Math.ceil(t.height/2),tileWidth:Math.ceil(t.width/2)}),h=async({frame:e})=>{let t=await d({blendshapes:!1,frame:e}),n=await p({blendshapes:!1,frame:e,tileHeight:Math.ceil(e.height*.4),tileWidth:Math.ceil(e.width*.4)});return oC({faces:[...t,...n]})},g=({detection:e,x:t,y:n})=>({...e,boundingRect:{...e.boundingRect,x:e.boundingRect.x+t,y:e.boundingRect.y+n},keypoints:Object.fromEntries(Object.entries(e.keypoints).map(([e,r])=>[e,{x:r.x+t,y:r.y+n}]))}),_=async({frame:t,tileHeight:n,tileWidth:r})=>{let i=[];for(let a of sC({frameSize:t.height,tileSize:n}))for(let o of sC({frameSize:t.width,tileSize:r})){let s=await e.createImageBitmap(t,o,a,r,n);try{let e=await c({frame:s});i.push(...e.map(e=>g({detection:e,x:o,y:a})))}finally{s.close()}}return i},v=async({frame:e})=>{let t=await c({frame:e}),n=await _({frame:e,tileHeight:Math.ceil(e.height*.4),tileWidth:Math.ceil(e.width*.4)});return iC({detections:[...t,...n],threshold:.3})},y=async(e,t={})=>{let n=await d({blendshapes:t.blendshapes,frame:e});if(i!==`low`&&(!t.forMatch||n.length>0))return n;let r=await m({blendshapes:t.blendshapes,frame:e});return oC({faces:[...n,...r]})},b=({detection:e,face:t})=>yC({face:t,polygon:e.polygon});return{loadFaceDetector:u,detectFace:f,detectPictureFaces:y,faceIsInsideDocument:b,detectDocumentFaces:async({detection:t,frame:n})=>{let r=await e.createImageBitmap(n,0,0,Math.ceil(n.width/2),n.height),a;try{a=(i===`low`?await h({frame:r}):await y(r,{blendshapes:!1})).map(e=>({...e,mesh:{...e.mesh,height:n.height,width:n.width}}))}finally{r.close()}return{faces:a.filter(e=>b({detection:t,face:e})).sort((e,t)=>t.boundingRect.width*t.boundingRect.height-e.boundingRect.width*e.boundingRect.height),hasPictureFace:a.length>0,pictureFaces:a}},detectDocumentFacePresence:async({detection:t,frame:n})=>{let r=await e.createImageBitmap(n,0,0,Math.ceil(n.width/2),n.height);try{return(i===`low`?await v({frame:r}):await s({frame:r,faceDetector:i})).some(e=>b({detection:t,face:e}))}finally{r.close()}}}}})),Hw,Uw,Ww,Gw=t((()=>{Hw=({detection:e,frame:t,scale:n})=>{let r=e.boundingRect,i=Math.min((t.height-1)/r.height,(t.width-1)/r.width,n),a=r.width*i,o=r.height*i,s=r.x+r.width/2,c=r.y+r.height/2,l=s-a/2,u=c-o/2,d=s+a/2,f=c+o/2;return l<0&&(d-=l,l=0),u<0&&(f-=u,u=0),d>t.width-1&&(l-=d-t.width+1,d=t.width-1),f>t.height-1&&(u-=f-t.height+1,f=t.height-1),{x:l,y:u,width:d-l,height:f-u}},Uw=({detection:e,frame:t,scale:n})=>{let r=e.boundingRect,i=Math.min((t.height-1)/r.height,(t.width-1)/r.width,n),a=r.width*i,o=r.height*i,s=r.x+r.width/2,c=r.y+r.height/2,l=s-a/2,u=c-o/2,d=s+a/2,f=c+o/2;l<0&&(d-=l,l=0),u<0&&(f-=u,u=0),d>t.width-1&&(l-=d-t.width+1,d=t.width-1),f>t.height-1&&(u-=f-t.height+1,f=t.height-1);let p=Math.trunc(l),m=Math.trunc(u),h=Math.trunc(d),g=Math.trunc(f);return{x:p,y:m,width:h-p+1,height:g-m+1}},Ww=({data:e,height:t,normalize:n,width:r})=>{let i=r*t,a=new Float32Array(i*3);for(let t=0;t<i;t+=1)a[t]=n(e[t*4+2]),a[i+t]=n(e[t*4+1]),a[2*i+t]=n(e[t*4]);return a}})),Kw,qw,Jw=t((()=>{W(),Gw(),Nv(),vv(),kw(),Kw=62,qw=({runtime:e})=>{let t=Mv({runtime:e});return{detectFaceAttributes:async({detection:n,frame:r})=>{let i=await e.session({filename:gv.ageGender}),a=Hw({detection:n,frame:r,scale:1}),o=t({frame:r,height:Kw,width:Kw,sourceRect:a}).data,s=await Ow({label:`face.attributes`,session:i,feeds:{[i.inputNames[0]]:e.tensor(`float32`,Ww({data:o,height:Kw,normalize:e=>e,width:Kw}),[1,3,Kw,Kw])}});try{let e=i.outputNames.map(e=>{let t=s[e];if(!t||!(t.data instanceof Float32Array))throw Error(j.INVALID_MODEL_OUTPUT);let n=t.data;if(n.length!==1&&n.length!==2||!n.every(Number.isFinite))throw Error(j.INVALID_MODEL_OUTPUT);return n}),t=e.find(e=>e.length===2),n=e.find(e=>e.length===1);if(e.length!==2||!t||!n)throw Error(j.INVALID_MODEL_OUTPUT);return{age:n[0]*100,gender:t[0]>=t[1]?`female`:`male`,genderScore:Math.max(t[0],t[1])}}finally{Dw({outputs:s})}},loadFaceAttributes:async()=>{await e.session({filename:gv.ageGender})}}}})),Yw,Xw,Zw,Qw,$w,eT,tT,nT,rT=t((()=>{W(),Gw(),Nv(),vv(),kw(),Yw=80,Xw=3,Zw=1,Qw=[{filename:_v.standard,label:`face.liveness`,scale:2.7},{filename:_v.wide,label:`face.liveness.wide`,scale:4}],$w=({values:e})=>{let t=Math.max(...e),n=Array.from(e,e=>Math.exp(e-t)),r=n.reduce((e,t)=>e+t,0);return n.map(e=>e/r)},eT=({values:e})=>{if(!(e instanceof Float32Array)||e.length!==Xw)throw Error(j.INVALID_MODEL_OUTPUT);for(let t of e)if(!Number.isFinite(t))throw Error(j.INVALID_MODEL_OUTPUT);return e},tT=({values:e})=>{let t=0;for(let n=1;n<e.length;n+=1)e[n]>e[t]&&(t=n);return t},nT=({runtime:e})=>{let t=Mv({runtime:e});return{detectFaceLiveness:async({detection:n,frame:r})=>{let i=[0,0,0];for(let a of Qw){let o=await e.session({filename:a.filename}),s=Uw({detection:n,frame:r,scale:a.scale}),c=t({frame:r,height:Yw,width:Yw,sourceRect:s}).data,l=await Ow({label:a.label,session:o,feeds:{[o.inputNames[0]]:e.tensor(`float32`,Ww({data:c,height:Yw,normalize:e=>e,width:Yw}),[1,3,Yw,Yw])}});try{let e=eT({values:l[o.outputNames[0]]?.data}),t=$w({values:e});for(let e=0;e<i.length;e+=1)i[e]+=t[e]/Qw.length}finally{Dw({outputs:l})}}let a=i[Zw];return{live:tT({values:i})===Zw,score:a}},loadFaceLiveness:async()=>{await Promise.all(Qw.map(t=>e.session({filename:t.filename})))}}}})),iT,aT,oT=t((()=>{$v(),yy(),Cy(),Hy(),GS(),dv(),Nv(),iT=({candidate:e,identity:t})=>[{missing:!t?.holder.last_name,pattern:/^\s*1[.:)]\s+\p{L}/u},{missing:!t?.holder.first_name,pattern:/^\s*2[.:)]\s+\p{L}/u},{missing:!t?.holder.birth_date,pattern:/^\s*3[.:)]\s+\d{1,2}[./-]\d{1,2}[./-]\d{2,4}/u},{missing:!t?.document.number,pattern:/^\s*5[.:)]\s+[A-Z0-9]/u}].flatMap(({missing:t,pattern:n})=>{if(!t)return[];let r=e.lines.find(e=>n.test(e.text));return r?[r]:[]}),aT=({runtime:e,orientDocumentFrame:t,getOcr:n})=>{let r=`auto`,i=Mv({runtime:e}),a=async({engine:t=r,language:i=`eng`}={})=>{await n({environment:e.environment,engine:t,language:i})},o=async({classificationImage:t,engine:a=r,frame:o,language:s,image:c})=>{if(o.width<200||o.height<100)return null;let l=c??vy({image:i({frame:o}),polygon:[{x:0,y:0},{x:o.width,y:0},{x:o.width,y:o.height},{x:0,y:o.height}]}),u=await(await n({environment:e.environment,engine:`tiny`,language:`latin`})).recognize({image:l}),d=WS({result:u}),f=t??i({frame:o}),p=Zv({image:f,text:u.text,codes:d?[d]:[]}),m=p&&(p.document===`passport`||p.europeanDrivingLicense);if(p?.europeanDrivingLicense){let t=Vy({ocr:u,image:f});if(!xy({identity:t})){let r=await(await n({environment:e.environment,engine:`small`,language:`latin`})).recognize({image:l}),i=Vy({ocr:r,image:f}),a=Zv({image:f,text:r.text,codes:[]});if(a?.europeanDrivingLicense&&xy({identity:i}))u=r;else if(a?.europeanDrivingLicense){let e=iT({candidate:r,identity:t});if(e.length){let t=[...u.lines,...e];u={...u,lines:t,text:t.map(e=>e.text).join(`
|
|
71
|
+
`)}}}}}else if(!m){let t=sv({language:s??`eng`}),r=await n({environment:e.environment,engine:a,language:t});r.model!==`tiny`&&(u=await r.recognize({image:l}))}let h=o.width/u.width,g=o.height/u.height,_=({x:e,y:t,width:n,height:r})=>({x:e*h,y:t*g,width:n*h,height:r*g});return{...u,width:o.width,height:o.height,lines:u.lines.map(e=>({...e,box:_(e.box),words:e.words.map(e=>({...e,box:_(e.box)}))}))}},s=async e=>await o(e)??{height:e.frame.height,lines:[],text:``,width:e.frame.width};return{loadTextDetector:a,readRectifiedText:o,detectRectifiedText:s,detectDocumentText:async({engine:e=r,frame:n,language:i,polygon:a})=>{let o=await t({frame:n,polygon:a});if(!o)return{height:0,lines:[],rotation:0,text:``,width:0};try{return{...await s({engine:e,frame:o.frame,language:i}),rotation:o.orientation.rotation}}finally{o.frame.close()}}}}})),sT,cT=t((()=>{W(),uy(),Ew(),Iw(),sT=({runtime:e})=>{let{detectDocumentOrientation:t}=Fw({runtime:e}),n={left:[33,133],right:[263,362]},r=({matrix:e,values:t})=>{let n=e.map((e,n)=>[...e,t[n]]);for(let e=0;e<n.length;e+=1){let t=e;for(let r=e+1;r<n.length;r+=1)Math.abs(n[r][e])>Math.abs(n[t][e])&&(t=r);if(Math.abs(n[t][e])<1e-8)return null;[n[e],n[t]]=[n[t],n[e]];let r=n[e][e];for(let t=e;t<=n.length;t+=1)n[e][t]/=r;for(let t=0;t<n.length;t+=1){if(t===e)continue;let r=n[t][e];for(let i=e;i<=n.length;i+=1)n[t][i]-=r*n[e][i]}}return n.map(e=>e[n.length])},i=({from:e,to:t})=>{let n=[],i=[];for(let[r,a]of e.entries()){let e=t[r];n.push([a.x,a.y,1,0,0,0,-e.x*a.x,-e.x*a.y]),i.push(e.x),n.push([0,0,0,a.x,a.y,1,-e.y*a.x,-e.y*a.y]),i.push(e.y)}let a=r({matrix:n,values:i});return a?[...a,1]:null},a=mw,o=({frame:t,polygon:n,rotation:r=0})=>{let a=ly({polygon:n}),o=Math.max(0,Math.floor(a.x)),s=Math.max(0,Math.floor(a.y)),c=Math.max(1,Math.min(t.width-o,Math.ceil(a.width))),l=Math.max(1,Math.min(t.height-s,Math.ceil(a.height))),u=r%180?l:c,d=r%180?c:l,f=e.createCanvas(u,d),p=f.getContext(`2d`);if(!p)throw Error(j.IMAGE_PROCESSING_FAILED);r===90?(p.translate(0,d),p.rotate(-Math.PI/2)):r===180?(p.translate(u,d),p.rotate(Math.PI)):r===270&&(p.translate(u,0),p.rotate(Math.PI/2)),p.drawImage(t,o,s,c,l,0,0,c,l);let m=o+c,h=s+l,g=i({from:[{x:0,y:0},{x:u,y:0},{x:u,y:d},{x:0,y:d}],to:r===90?[{x:m,y:s},{x:m,y:h},{x:o,y:h},{x:o,y:s}]:r===180?[{x:m,y:h},{x:o,y:h},{x:o,y:s},{x:m,y:s}]:r===270?[{x:o,y:h},{x:o,y:s},{x:m,y:s},{x:m,y:h}]:[{x:o,y:s},{x:m,y:s},{x:m,y:h},{x:o,y:h}]});return g?{frame:f.transferToImageBitmap(),height:d,sourceHeight:t.height,sourceWidth:t.width,toSource:g,width:u}:null},s=async({frame:e,polygon:n,orientation:r})=>{if(n.length!==4)return null;let i=r??await t({frame:e,boundingRect:ly({polygon:n})}),a=o({frame:e,polygon:n,rotation:i.rotation});return a?{...a,orientation:i}:null},c=({document:e,face:t})=>{let n=t.mesh.landmarks.map(({x:t,y:n,z:r})=>({...a({homography:e.toSource,point:{x:t,y:n}}),z:r})),r=[{x:t.boundingRect.x,y:t.boundingRect.y},{x:t.boundingRect.x+t.boundingRect.width,y:t.boundingRect.y},{x:t.boundingRect.x+t.boundingRect.width,y:t.boundingRect.y+t.boundingRect.height},{x:t.boundingRect.x,y:t.boundingRect.y+t.boundingRect.height}].map(t=>a({homography:e.toSource,point:t})),i=r.map(({x:e})=>e),o=r.map(({y:e})=>e),s={x:Math.min(...i),y:Math.min(...o),width:Math.max(...i)-Math.min(...i),height:Math.max(...o)-Math.min(...o)};return{...t,boundingRect:s,mesh:{...t.mesh,height:e.sourceHeight,landmarks:n,width:e.sourceWidth}}},l=({face:e})=>{let t=e.mesh.landmarks,r=n.left.map(e=>t[e]).filter(Boolean).map(({x:e,y:t})=>({x:e,y:t})),i=n.right.map(e=>t[e]).filter(Boolean).map(({x:e,y:t})=>({x:e,y:t})),a=[13,14].map(e=>t[e]).filter(Boolean).map(({x:e,y:t})=>({x:e,y:t}));return r.length!==2||i.length!==2||a.length!==2?null:{boundingRect:e.boundingRect,mouth:{x:(a[0].x+a[1].x)/2,y:(a[0].y+a[1].y)/2},leftEye:{x:(r[0].x+r[1].x)/2,y:(r[0].y+r[1].y)/2},rightEye:{x:(i[0].x+i[1].x)/2,y:(i[0].y+i[1].y)/2}}},u=({face:e,lines:t,maxAngleDifference:n})=>{let r=Math.atan2(e.rightEye.y-e.leftEye.y,e.rightEye.x-e.leftEye.x)*180/Math.PI,i=0;for(let a of t){let t=Math.abs(a.angle-r)%180,o=Math.min(t,180-t),s=a.box;!(s.y>=e.boundingRect.y&&s.y+s.height<=e.boundingRect.y+e.boundingRect.height)||o>n||s.x>e.boundingRect.x+e.boundingRect.width&&(i+=1)}return i};return{transformPoint:a,orientDocumentFrame:s,restoreRectifiedFace:c,rectifiedDocumentFace:l,documentAlignment:({face:e,lines:t,maxAngleDifference:n,maxFaceAreaRatio:r,maxFaceHeightRatio:i,maxFaceWidthRatio:a,minFaceAreaRatio:o,minFaceHeightRatio:s,minFaceWidthRatio:c,documentSize:l})=>{if(!e)return{faceAdjacentTextLineCount:0,angleDifference:null,eyesAngle:null,faceAreaRatio:0,faceAreaValid:!1,faceDimensionsValid:!1,faceHeightRatio:0,faceWidthRatio:0,textAngle:null,textParallel:!1,textSide:`unknown`};let d=e.boundingRect.width*e.boundingRect.height/(l.width*l.height),f=d>=o&&d<=r,p=e.boundingRect.width/l.width,m=e.boundingRect.height/l.height,h=p>=c&&p<=a&&m>=s&&m<=i,g=Math.atan2(e.rightEye.y-e.leftEye.y,e.rightEye.x-e.leftEye.x)*180/Math.PI,_=t.filter(t=>{let n=t.box;return n.y>=e.boundingRect.y&&n.y+n.height<=e.boundingRect.y+e.boundingRect.height&&n.x>e.boundingRect.x+e.boundingRect.width}),v=_.length?_.reduce((e,t)=>e+t.angle,0)/_.length:null,y=v===null?null:Math.abs(v-g)%180,b=y===null?null:Math.min(y,180-y),x=b!==null&&b<=n;return{faceAdjacentTextLineCount:u({face:e,lines:t,maxAngleDifference:n}),angleDifference:b,eyesAngle:g,faceAreaRatio:d,faceAreaValid:f,faceDimensionsValid:h,faceHeightRatio:m,faceWidthRatio:p,textAngle:v,textParallel:x,textSide:_.length?`right`:`unknown`}}}}})),lT,uT=t((()=>{W(),$v(),yy(),Cy(),Hy(),Ew(),QS(),V_(),jv(),Nv(),lT=({runtime:e,documentAlignment:t,rectifiedDocumentFace:n,orientDocumentFrame:r,restoreRectifiedFace:i,analyzeDocument:a,faceDetection:o,faceMatch:s,textDetection:c})=>{let l=Mv({runtime:e}),u=({frame:t,text:n})=>{let r=e.createCanvas(32,32),i=r.getContext(`2d`,{willReadFrequently:!0});if(!i)throw Error(j.IMAGE_PROCESSING_FAILED);i.drawImage(t,0,0,r.width,r.height);let{data:a}=i.getImageData(0,0,r.width,r.height);return Av({canvas:r}),ry({data:a,height:32,text:n,width:32})},d=({current:e,front:t})=>{let n=ay({current:e.signature,front:t}),r=[],i=e.signature?.textTokens.length??0,a=oy({text:e.text.text})||e.text.lines.length>=2&&i>=2;return e.detection||r.push(j.DOCUMENT_NOT_FOUND),e.documentAnalysis.isBlurry&&r.push(j.DOCUMENT_BLURRY),e.hasPictureFace&&r.push(j.DOCUMENT_BACK_CONTAINS_FACE),a||r.push(j.DOCUMENT_TEXT_NOT_READABLE),n.distinct||r.push(j.DOCUMENT_BACK_NOT_DISTINCT),{distinct:n.distinct,imageDistance:n.imageDistance,reasons:r,textOverlap:n.textOverlap,valid:r.length===0}},f=({alignment:e,detection:t,documentAnalysis:n,faceContained:r,requiresFace:i,text:a})=>{let o=[];return t||o.push(j.DOCUMENT_NOT_FOUND),n.isBlurry&&o.push(j.DOCUMENT_BLURRY),i&&!r&&o.push(j.DOCUMENT_FACE_NOT_CONTAINED),(!a.text||a.lines.length<2)&&o.push(j.DOCUMENT_TEXT_NOT_READABLE),!i||e.faceAreaValid&&e.faceDimensionsValid||o.push(j.DOCUMENT_FACE_GEOMETRY_INVALID),i&&(e.faceAdjacentTextLineCount<2||!e.textParallel||e.textSide!==`right`)&&o.push(j.DOCUMENT_TEXT_ALIGNMENT_INVALID),o},p=async({classification:e,codes:r,ocr:a,options:c,documentAnalysis:l,document:d,text:p,prepareForMatch:m})=>{let h=l.detection,g=c.requiresFace??!0,_={boundingRect:{height:d.height,width:d.width,x:0,y:0},polygon:[{x:0,y:0},{x:d.width,y:0},{x:d.width,y:d.height},{x:0,y:d.height}]},v=g?await o.detectDocumentFaces({detection:_,frame:d.frame}):{faces:[],pictureFaces:[],hasPictureFace:await o.detectDocumentFacePresence({detection:_,frame:d.frame})},y=v.pictureFaces.map(e=>i({document:d,face:e})),b=u({frame:d.frame,text:p.text}),x=r.find(e=>e.type===`mrz`)??null,S=null;for(let u of v.faces.length?v.faces:[null]){let _=u?i({document:d,face:u}):null,C=u?n({face:u}):null,w=g&&h?o.faceIsInsideDocument({detection:h,face:_})&&y.every(e=>o.faceIsInsideDocument({detection:h,face:e})):!1,T=t({documentSize:{height:p.height,width:p.width},face:C,lines:p.lines,maxAngleDifference:c.maxDocumentTextAngleDifference,maxFaceAreaRatio:c.maxDocumentFaceAreaRatio,maxFaceHeightRatio:c.maxDocumentFaceHeightRatio,maxFaceWidthRatio:c.maxDocumentFaceWidthRatio,minFaceAreaRatio:c.minDocumentFaceAreaRatio,minFaceHeightRatio:c.minDocumentFaceHeightRatio,minFaceWidthRatio:c.minDocumentFaceWidthRatio}),E=f({alignment:T,detection:h,documentAnalysis:l,faceContained:w,requiresFace:g,text:p});g&&!e&&E.push(j.DOCUMENT_NOT_RECOGNIZED),e?.europeanDrivingLicense&&!xy({identity:e.identity})&&E.push(j.DOCUMENT_VALIDATION_FAILED);let ee=E.length===0,D=null,O=null;if(g&&ee&&u){let e=s.prepareFace({alignment:c.alignment??`eyes-nose-mouth`,face:u,frame:d.frame});if(!e)ee=!1,E.push(j.FACE_NOT_USABLE);else if(m){let t=await s.preparedFaceArtifacts({face:e});D=t?.embeddings??null,O=t?.images??null,t||(ee=!1,E.push(j.INVALID_MODEL_OUTPUT))}}let te={identity:e?e.identity:null,orientation:d.orientation,ocr:a,mrz:x,alignment:T,detection:h,documentAnalysis:l,documentKind:e?e.document:null,europeanDrivingLicense:e?e.europeanDrivingLicense:!1,codes:r,documentToSource:d.toSource,embeddings:D,images:O,face:_,faceContained:w,hasPictureFace:v.hasPictureFace??y.length>0,failureReasons:E,pictureFaces:y,signature:b,text:p,valid:ee};if(te.valid)return te;S??=te}if(!S)throw Error(j.INTERNAL_ERROR);return S},m=async({frame:n,options:i,documentAnalysis:a,prepareForMatch:o=!1})=>{let s=a.detection;if(!s){let e={height:0,lines:[],text:``,width:0},n=t({documentSize:{height:e.height,width:e.width},face:null,lines:e.lines,maxAngleDifference:i.maxDocumentTextAngleDifference,maxFaceAreaRatio:i.maxDocumentFaceAreaRatio,maxFaceHeightRatio:i.maxDocumentFaceHeightRatio,maxFaceWidthRatio:i.maxDocumentFaceWidthRatio,minFaceAreaRatio:i.minDocumentFaceAreaRatio,minFaceHeightRatio:i.minDocumentFaceHeightRatio,minFaceWidthRatio:i.minDocumentFaceWidthRatio});return{identity:null,orientation:null,ocr:null,mrz:null,codes:[],europeanDrivingLicense:!1,alignment:n,detection:s,documentAnalysis:a,documentKind:null,documentToSource:null,embeddings:null,face:null,faceContained:!1,failureReasons:f({alignment:n,detection:s,documentAnalysis:a,faceContained:!1,requiresFace:i.requiresFace??!0,text:e}),images:null,pictureFaces:[],hasPictureFace:!1,signature:null,text:e,valid:!1}}let u=await r({frame:n,polygon:s.polygon,orientation:s.orientation});if(!u)throw Error(j.IMAGE_PROCESSING_FAILED);try{let t=performance.now(),r=vy({image:l({frame:n}),polygon:s.polygon,sourceOrientation:u.orientation.rotation}),d=i.requiresFace===!1?`back`:`front`;z_({category:`stages`,key:`ocr.prepare.${d}`,duration:performance.now()-t});let f=l({frame:u.frame}),m=await c.readRectifiedText({classificationImage:f,engine:i.ocrEngine,frame:u.frame,language:i.language,image:r}),h=m??{height:u.height,lines:[],text:``,width:u.width},g=m?WS({result:m}):null,_=null;if(i.requiresFace===!1){let t=e.createImageData(f.width,f.height);t.data.set(f.data),_=await B_({key:`barcode.back`,operation:()=>ZS({image:t})})}let v=[g,_].filter(e=>e!==null),y=Zv({image:f,text:h.text,codes:v}),b=i.requiresFace!==!1&&y?.europeanDrivingLicense&&m?Vy({ocr:m,image:f}):null,x=y?{...y,identity:b}:null;return await p({ocr:m,classification:x,codes:v,options:i,documentAnalysis:a,document:u,prepareForMatch:o,text:h})}finally{u.frame.close()}},h=async({frame:e,options:t,prepareForMatch:n=!1})=>{let r=await a({frame:e,minDocumentBoxRatio:t.minDocumentBoxRatio});return await m({frame:e,options:t,documentAnalysis:r,prepareForMatch:n})},g=({analysis:e,isBack:t,front:n})=>{if(!e.ocr)return[j.DOCUMENT_TEXT_NOT_READABLE];if(t&&!n)return[j.CAPTURES_INCOMPLETE];if(!t&&!e.documentKind)return[j.DOCUMENT_NOT_RECOGNIZED];let r={ocr:e.ocr,codes:e.codes},i=t&&n?n:{document:e.documentKind,europeanDrivingLicense:e.europeanDrivingLicense,identity:e.identity};return Sy({classification:i,front:t&&n?n:r,back:t?r:null}).reasons.filter(e=>t||e!==j.DOCUMENT_BACK_REQUIRED)};return{validateDocumentBack:d,analyzeDocumentFrame:h,hasValidDocumentSideData:e=>g(e).length===0,documentSideFailureReasons:g}}})),dT,fT,pT=t((()=>{W(),Ew(),kw(),jv(),Nv(),dT={standard:{filename:`fm.ort`,layout:`nhwc`},high:{filename:`fmh.ort`,layout:`nhwc`},ultra:{filename:`fmu.ort`,layout:`nchw`}},fT=({runtime:e,orientDocumentFrame:t,detectDocument:n,faceDetection:r,detectFace:i,detectPictureFaces:a,faceMatcher:o=`ultra`})=>{let s=Mv({runtime:e}),c=[10,338,297,332,284,251,389,356,454,323,361,288,397,365,379,378,400,377,152,148,176,149,150,136,172,58,132,93,234,127,162,21,54,103,67,109],l={"eyes-nose-mouth":{landmarks:[[33,133],[263,362],[1],[61],[291]],target:[[38.2946,51.6963],[73.5318,51.5014],[56.0252,71.7366],[41.5493,92.3655],[70.7299,92.2041]]}},u=({points:e})=>[e.reduce((e,[t])=>e+t,0)/e.length,e.reduce((e,[,t])=>e+t,0)/e.length],d=({source:e,target:t})=>{if(e.length<2||e.length!==t.length)return null;let[n,r]=u({points:e}),[i,a]=u({points:t}),o=0,s=0,c=0;for(let[l,[u,d]]of e.entries()){let[e,f]=t[l],p=u-n,m=d-r,h=e-i,g=f-a;o+=p*p+m*m,s+=p*h+m*g,c+=p*g-m*h}if(o<1e-8)return null;let l=s/o,d=c/o;return l*l+d*d<1e-8?null:[l,-d,i-l*n+d*r,d,l,a-d*n-l*r]},f=({height:e,minimumArea:t,polygon:n,width:r})=>{if(Math.abs(n.reduce((e,t,r)=>{let i=n[(r+1)%n.length];return e+t[0]*i[1]-i[0]*t[1]},0))/2<t)return null;let i=new Float32Array(r*e),a=Math.max(0,Math.ceil(Math.min(...n.map(([,e])=>e))-.5)),o=Math.min(e,Math.ceil(Math.max(...n.map(([,e])=>e))-.5));for(let e=a;e<o;e+=1){let t=[],a=e+.5;for(let e=0,r=n.length-1;e<n.length;r=e++){let[i,o]=n[r],[s,c]=n[e];o>a!=c>a&&t.push((s-i)*(a-o)/(c-o)+i)}t.sort((e,t)=>e-t);for(let n=0;n+1<t.length;n+=2){let a=Math.min(r,Math.max(0,Math.ceil(t[n]-.5))),o=Math.max(0,Math.min(r,Math.ceil(t[n+1]-.5)));i.fill(1,e*r+a,e*r+o)}}return i},p=({face:e,grayscale:t})=>{let{image:n,weights:r}=e,i=0,a=0,o=0,s=0;for(let e=0;e<r.length;e+=1){let t=r[e];if(!t)continue;let c=e*4,l=n[c]*.299+n[c+1]*.587+n[c+2]*.114;i+=l*t,a+=l*l*t,o+=t,(l<8||l>247)&&(s+=t)}if(o<r.length*.1)return null;let c=i/o;if(c<25||c>230||s/o>.4)return null;let l=Math.sqrt(Math.max(1,a/o-c*c)),u=Math.min(1.8,Math.max(.55,58/(127.5/c*l)))*(127.5/c),d=new Uint8ClampedArray(n.length);for(let e=0;e<r.length;e+=1){let i=e*4,a=r[e],o=n[i]*.299+n[i+1]*.587+n[i+2]*.114,s=(o-c)*u+127.5,l=s/Math.max(o,1);for(let e=0;e<3;e+=1)d[i+e]=Math.max(0,Math.min(255,t?s:n[i+e]*l))*a+127.5*(1-a);d[i+3]=255}return d},m=({alignment:t,face:n,frame:r})=>{let i=c.map(e=>{let t=n.mesh.landmarks[e];return[t.x,t.y]});if(i.some(([e,t])=>!Number.isFinite(e)||!Number.isFinite(t)||e<0||t<0||e>=r.width||t>=r.height))return null;let a=e.createCanvas(112,112);try{let e=a.getContext(`2d`,{willReadFrequently:!0});if(!e)throw Error(j.IMAGE_PROCESSING_FAILED);let o=l[t],s=o.landmarks.map(e=>{let t=e.map(e=>{let t=n.mesh.landmarks[e];return[t.x,t.y]});return u({points:t})}),c=d({source:s,target:o.target});if(!c||!c.every(Number.isFinite))return null;e.fillStyle=`rgb(128, 128, 128)`,e.fillRect(0,0,112,112),e.setTransform(c[0],c[3],c[1],c[4],c[2],c[5]),e.drawImage(r,0,0),e.setTransform(1,0,0,1,0,0);let m=i.map(([e,t])=>[c[0]*e+c[1]*t+c[2],c[3]*e+c[4]*t+c[5]]),h=f({height:112,minimumArea:1254.4,polygon:m,width:112});if(!h)return null;let g={image:e.getImageData(0,0,112,112).data,weights:h},_=p({face:g,grayscale:!1});if(!_)return null;let v=p({face:g,grayscale:!0});return v?{...g,normalized:{rgb:_,greyscale:v}}:null}finally{Av({canvas:a})}},h=async({faceMatcher:t=o}={})=>await e.session({filename:dT[t].filename}),g=({layout:e,normalized:t})=>{let n=12544,r=new Float32Array(n*3);for(let i=0;i<n;i+=1){let a=i*4;for(let o=0;o<3;o+=1){let s=(t[a+o]-127.5)/127.5,c=e===`nhwc`?i*3+o:o*n+i;r[c]=s}}return r},_=async({normalized:t})=>{let{layout:n}=dT[o],r=g({layout:n,normalized:t}),i=n===`nhwc`?[1,112,112,3]:[1,3,112,112],a=await h(),s=await Ow({label:`face.embedding`,session:a,feeds:{[a.inputNames[0]]:e.tensor(`float32`,r,i)}});try{let e=s[a.outputNames[0]].data;if(!(e instanceof Float32Array))throw Error(j.INVALID_MODEL_OUTPUT);let t=e,n=Math.hypot(...t);if(t.length!==512||!t.every(Number.isFinite)||!Number.isFinite(n)||n<1e-8)throw Error(j.INVALID_MODEL_OUTPUT);return Array.from(t,e=>e/n)}finally{Dw({outputs:s})}},v=async({blob:t})=>{try{return await e.createImageBitmap(t)}catch(e){throw Error(j.IMAGE_DECODE_FAILED,{cause:e})}},y=async({normalized:e})=>{try{return await _({normalized:e})}catch(e){if(e instanceof Error&&e.message===j.INVALID_MODEL_OUTPUT)return null;throw e}},b=async({face:e})=>{let t=await y({normalized:e.normalized.rgb});if(!t)return null;let n=await y({normalized:e.normalized.greyscale});return n?{grayscale:n,rgb:t}:null},x=async({face:e})=>await y({normalized:e.normalized.greyscale}),S=async()=>{let e=new Uint8ClampedArray(50176).fill(127);if(!await b({face:{normalized:{rgb:e,greyscale:e}}}))throw Error(j.INVALID_MODEL_OUTPUT)},C=async({pixels:t})=>{let n=e.createCanvas(112,112);try{let e=n.getContext(`2d`);if(!e)throw Error(j.IMAGE_PROCESSING_FAILED);let r=e.createImageData(112,112);r.data.set(t),e.putImageData(r,0,0);let i=await n.convertToBlob({type:`image/jpeg`,quality:1});if(i.type!==`image/jpeg`)throw Error(j.IMAGE_ENCODE_FAILED);return i}finally{Av({canvas:n})}},w=async({face:e})=>{let t=await b({face:e});if(!t)return null;let[n,r]=await Promise.all([C({pixels:e.normalized.rgb}),C({pixels:e.normalized.greyscale})]);return{embeddings:t,images:{rgb:n,greyscale:r}}},T=async({alignment:e,face:t,frame:n})=>{let r=m({alignment:e,face:t,frame:n});return r?await b({face:r}):null},E=async({alignment:e,frame:t})=>{let n=await i(t);if(!n)throw Error(j.FACE_NOT_FOUND);let r=await T({alignment:e,face:n,frame:t});if(!r)throw Error(j.FACE_NOT_USABLE);return r},ee=async({alignment:e,frame:t})=>{let n=await a(t,{forMatch:!0}),r=[];for(let i of n){let n=await T({alignment:e,face:i,frame:t});n&&r.push(n)}return r},D=async({alignment:e,frame:i})=>{let a=await n(i);if(!a)throw Error(j.DOCUMENT_NOT_FOUND);let o=await t({frame:i,polygon:a.polygon,orientation:a.orientation});if(!o)throw Error(j.DOCUMENT_NOT_FOUND);try{let t={boundingRect:{height:o.height,width:o.width,x:0,y:0},polygon:[{x:0,y:0},{x:o.width,y:0},{x:o.width,y:o.height},{x:0,y:o.height}]},{faces:n}=await r.detectDocumentFaces({detection:t,frame:o.frame});if(!n.length)throw Error(j.DOCUMENT_FACE_NOT_FOUND);for(let t of n){let n=await T({alignment:e,face:t,frame:o.frame});if(n)return n}}finally{o.frame.close()}throw Error(j.FACE_NOT_USABLE)};return{prepareFace:m,loadFaceMatch:h,warmupFaceMatch:S,imageBitmap:v,readImage:s,preparedFaceEmbeddings:b,preparedFaceGrayscaleEmbedding:x,preparedFaceArtifacts:w,matchFaceWithDocument:async({document:e,documentFaceEmbeddings:t,referenceFaceEmbeddings:n,options:r,reference:i})=>{let a=null,o=null;try{let s=t;s||=(o=await v({blob:e}),await D({alignment:r.alignment,frame:o,language:r.language,ocrEngine:r.ocrEngine}));let c=n;c||=(a=await v({blob:i}),await E({alignment:r.alignment,frame:a}));let l=fw({first:c,second:s});return dw({score:l,threshold:r.threshold})}finally{a&&a.close(),o&&o.close()}},matchReferenceWithFaces:async({options:e,picture:t,references:n,referenceFaceEmbeddings:r})=>{let i=await v({blob:t}),a=[];try{if(!r)for(let e of n){let t=await v({blob:e});a.push(t)}let t=await ee({alignment:e.alignment,frame:i});if(!t.length)throw Error(j.NO_USABLE_CANDIDATES);let o=r?[...r]:[];for(let t of a)try{let n=await E({alignment:e.alignment,frame:t});o.push(n)}catch(e){if(!(e instanceof Error)||e.message!==j.FACE_NOT_FOUND&&e.message!==j.FACE_NOT_USABLE)throw e}let s=-1/0;for(let e of o)for(let n of t){let t=fw({first:n,second:e});s=Math.max(s,t)}if(!Number.isFinite(s))throw Error(j.NO_USABLE_REFERENCES);return dw({score:s,threshold:e.threshold})}finally{i.close();for(let e of a)e.close()}}}}})),mT,hT=t((()=>{W(),yy(),jv(),mT=({runtime:e,document:t,readImage:n})=>async({image:r,timings:i})=>{let a=await e.createImageBitmap(new Blob([r]));try{let r=performance.now(),o=await t.analyzeDocument({frame:a});if(i&&(i.documentBoxDetectionMs=performance.now()-r),!o.detection)throw Error(j.DOCUMENT_NOT_FOUND);let{polygon:s,orientation:c}=o.detection,l=vy({image:n({frame:a}),polygon:s,sourceOrientation:c?.rotation}),u=e.createCanvas(l.width,l.height);try{let t=u.getContext(`2d`);if(!t)throw Error(j.IMAGE_PROCESSING_FAILED);let n=e.createImageData(l.width,l.height);n.data.set(l.data),t.putImageData(n,0,0);let r=await u.convertToBlob({type:`image/png`});return new Uint8Array(await r.arrayBuffer())}finally{Av({canvas:u})}}finally{a.close()}}})),gT,_T=t((()=>{eC(),Rw(),Vw(),Jw(),rT(),oT(),cT(),QS(),uT(),pT(),hT(),Nv(),gT=({runtime:e,getOcr:t,faceMatcher:n})=>{let r=Mv({runtime:e}),i=sT({runtime:e}),a=Lw({runtime:e}),o=Bw({runtime:e,imageFromImageBitmap:r}),s=qw({runtime:e}),c=nT({runtime:e}),l=aT({runtime:e,getOcr:t,...i}),u=fT({runtime:e,...i,...a,...o,faceDetection:o,faceMatcher:n});return{alignment:i,document:a,face:o,attributes:s,liveness:c,text:l,match:u,flow:lT({runtime:e,...i,...a,faceDetection:o,faceMatch:u,textDetection:l}),classify:$S({runtime:e,detector:a,alignment:i,text:l,readImage:r}),prepareOcrImage:mT({runtime:e,document:a,readImage:r}),warmup:async()=>{await Promise.all([o.loadFaceDetector({faceDetector:`standard`}),s.loadFaceAttributes(),c.loadFaceLiveness(),u.loadFaceMatch(),a.loadDocumentBoxDetector(),a.loadDocumentOrientationDetector(),l.loadTextDetector({engine:`tiny`,language:`latin`}),XS()])}}}})),vT,yT,bT,xT,ST,CT,wT,TT,ET,DT,OT,kT,AT,jT,MT,NT,PT=t((()=>{Uv(),Rv(),_T(),Py(),ES(),Cy(),pw(),US(),QS(),dv(),{alignment:vT,document:yT,face:bT,attributes:xT,liveness:ST,text:CT,match:wT,flow:TT,classify:ET,prepareOcrImage:DT,warmup:OT}=gT({runtime:Iv,getOcr:Vv}),{classifyDocument:kT,detectDocument:AT,extractDocumentCodes:jT}=ET,{detectDocumentOrientation:MT,loadDocumentOrientationDetector:NT}=yT})),FT,IT,LT,RT,zT,BT=t((()=>{Xu(),FT=[`faceStraight`,`faceUp`,`faceDown`,`faceLeft`,`faceRight`],IT=[`faceStraight`,`faceUp`,`faceLeft`,`faceRight`],LT=[...FT,`faceSmile`,`faceWinkLeft`,`faceTiltLeft`,`faceTiltRight`,`faceReference`],Pl(LT),RT={faceStraight:0,faceLeft:1,faceRight:1,faceUp:2,faceDown:2,faceTiltLeft:3,faceTiltRight:3,faceReference:6,faceSmile:4,faceWinkLeft:5},zT={faceStraight:`face_straight`,faceUp:`face_up`,faceDown:`face_down`,faceLeft:`face_left`,faceRight:`face_right`,faceSmile:`face_smile`,faceWinkLeft:`face_wink_left`,faceTiltLeft:`face_tilt_left`,faceTiltRight:`face_tilt_right`,faceReference:`face_reference`},Pl(zT),FT.map(e=>zT[e]),IT.map(e=>zT[e]),V({yaw:B().finite().min(-180).max(180),pitch:B().finite().min(-180).max(180),roll:B().finite().min(-180).max(180)})}));PT(),BT(),kC(),Bt();var VT=async({task:e})=>{try{return await e()}catch(e){throw zt({error:e,fallback:j.AUTHORIZATION_FAILED})}},HT=({intent:e,action:t})=>{let n=EC.safeParse(e);if(!n.success)throw M({code:j.INVALID_SERVICE_RESPONSE,cause:e});if(n.data.action!==t||Date.parse(n.data.expiresAt)<=Date.now())throw M({code:j.INTENT_TOKEN_INVALID,resultId:n.data.resultId})},UT,WT,GT,KT=t((()=>{UT={faceReference:{primary:`matchReferencePose`},faceStraight:{primary:`lookStraight`},faceUp:{primary:`lookUp`},faceDown:{primary:`lookDown`},faceLeft:{primary:`lookLeft`},faceRight:{primary:`lookRight`},faceSmile:{primary:`smile`},faceWinkLeft:{primary:`winkLeft`},faceTiltLeft:{primary:`tiltLeft`},faceTiltRight:{primary:`tiltRight`}},WT={FACE_ROLL_TILT_LEFT:`tiltLeft`,FACE_ROLL_TILT_RIGHT:`tiltRight`,FACE_ROLL_TILT_LESS:`tiltLess`,FACE_YAW_TURN_LEFT:`lookLeft`,FACE_YAW_TURN_RIGHT:`lookRight`,FACE_YAW_TURN_LESS:`turnLess`,FACE_PITCH_LOOK_UP:`lookUp`,FACE_PITCH_LOOK_DOWN:`lookDown`,FACE_PITCH_RAISE_LESS:`raiseLess`,FACE_PITCH_LOWER_LESS:`lowerLess`,FACE_SMILE_REQUIRED:`smile`,FACE_WINK_LEFT_REQUIRED:`winkLeft`,FACEKEY_LOWER_HEAD:`lookDown`,FACEKEY_LOWER_HEAD_LESS:`lowerLess`,FACEKEY_RAISE_HEAD:`lookUp`,FACEKEY_RAISE_HEAD_LESS:`raiseLess`,FACEKEY_SMILE_REQUIRED:`smile`,FACEKEY_TILT_HEAD_LEFT:`tiltLeft`,FACEKEY_TILT_HEAD_LESS:`tiltLess`,FACEKEY_TILT_HEAD_RIGHT:`tiltRight`,FACEKEY_TURN_HEAD_LEFT:`lookLeft`,FACEKEY_TURN_HEAD_LESS:`turnLess`,FACEKEY_TURN_HEAD_RIGHT:`lookRight`,FACEKEY_WINK_LEFT_REQUIRED:`winkLeft`},GT={facePoses:UT,poseRejections:WT}})),qT,JT,YT=t((()=>{KT(),qT=({pose:e})=>{let t=GT.facePoses[e];return{...t,primary:t.primary}},JT=({code:e})=>GT.poseRejections[e]})),XT,ZT,QT,$T,eE,tE,nE,rE,iE,aE,oE=t((()=>{Ew(),$C(),YT(),XT=1e3,ZT=({pose:e})=>{let t=jC[e];return t?.yaw===void 0?t?.pitch===void 0?t?.roll===void 0?e===`faceStraight`?{axis:`roll`,value:0}:{axis:null,value:null}:{axis:`roll`,value:t.roll}:{axis:`pitch`,value:t.pitch}:{axis:`yaw`,value:t.yaw}},QT=()=>({published:null,candidate:null,frames:0}),$T=()=>({label:null,since:0}),eE=({label:e,now:t,state:n})=>e?n.label===e?n:{label:e,since:t}:$T(),tE=({delay:e=XT,label:t,now:n,state:r})=>!t||r.label!==t?null:n-r.since>=e?t:null,nE=({alignment:e,neutral:t})=>t?{pitch:e.pitch-t.pitch,yaw:e.yaw-t.yaw,roll:e.roll-t.roll}:e,rE=({alignment:e,blendshapes:t,neutral:n,pose:r,options:i,referencePose:a})=>{if(r===`faceReference`&&a){let t=`yaw`;for(let n of[`pitch`,`roll`])Math.abs(e[n]-a[n])>Math.abs(e[t]-a[t])&&(t=n);let n=e[t]-a[t],i=ow({alignment:e,target:a}),o=i===null?`inside`:Math.abs(n)<=23?`approaching`:`outside`;return{pose:r,referencePose:a,axis:t,target:a[t],error:n,zone:o,code:i}}let o=nE({alignment:e,neutral:r===`faceStraight`?null:n}),s=aw({...e,blendshapes:t,pose:r,options:i});s===null&&r===`faceUp`&&n&&(s=aw({...e,pitch:o.pitch,blendshapes:t,pose:r,options:i}));let c=ZT({pose:r}),l=c.axis&&c.value!==null?o[c.axis]-c.value:0,u=(i.tolerance??15)+8,d=s===null?`inside`:Math.abs(l)<=u?`approaching`:`outside`;return{pose:r,axis:c.axis,target:c.value,error:l,zone:d,code:s}},iE=({state:e,code:t,requiredFrames:n})=>{if(t===e.published)return{published:e.published,candidate:null,frames:0};if(t===e.candidate){let r=e.frames+1;return r>=n?{published:t,candidate:null,frames:0}:{published:e.published,candidate:t,frames:r}}return{published:e.published,candidate:t,frames:1}},aE=({corrective:e,pose:t})=>{let n=qT({pose:t}).primary;return{primary:n,corrective:e&&e!==n?e:null}}})),sE,cE,lE,uE,dE,fE,pE,mE,hE=t((()=>{fd(),Bt(),sE=async()=>{let e=await ud({filename:`faceMeshLines.json`});return JSON.parse(new TextDecoder().decode(e))},cE=async()=>{await sE()},{transformPoint:lE}=vT,uE=[`tessellation`,`contours`,`faceOval`,`lips`,`leftEye`,`rightEye`,`leftEyebrow`,`rightEyebrow`,`leftIris`,`rightIris`],dE=async({color:e,context:t,result:n})=>{let r=await sE();t.beginPath();for(let e of uE)for(let{start:i,end:a}of r[e]){let e=n.mesh.landmarks[i],r=n.mesh.landmarks[a];e&&r&&(t.moveTo(e.x,e.y),t.lineTo(r.x,r.y))}t.strokeStyle=e,t.lineWidth=1,t.stroke()},fE=({backgroundColor:e,color:t,context:n,line:r,toSource:i})=>{if(!r.text)return;let{x:a,y:o,width:s,height:c}=r.box,l=[{x:a,y:o},{x:a+s,y:o},{x:a+s,y:o+c},{x:a,y:o+c}].map(e=>lE({homography:i,point:e})),u=l[0],d=l[1],f=l[3];if(!u||!d||!f)return;let p=Math.hypot(d.x-u.x,d.y-u.y),m=Math.hypot(f.x-u.x,f.y-u.y),h=Math.max(8,Math.min(16,m*.7)),g=Math.max(0,p-4),_=Math.atan2(d.y-u.y,d.x-u.x);n.beginPath(),n.moveTo(u.x,u.y);for(let e of l.slice(1))n.lineTo(e.x,e.y);n.closePath(),n.strokeStyle=t,n.lineWidth=1,n.stroke(),n.save(),n.clip(),n.translate(u.x+2,u.y+2),n.rotate(_),n.font=`${h}px sans-serif`,n.textBaseline=`top`,n.lineWidth=3,n.strokeStyle=e,n.strokeText(r.text,0,0,g),n.fillStyle=t,n.fillText(r.text,0,0,g),n.restore()},pE=async({element:e,meshLineColor:t,overlayColor:n=`transparent`,result:r})=>{let i=e.getContext(`2d`);if(!i)throw M({code:j.IMAGE_PROCESSING_FAILED});let a=r?.mesh.width??e.width,o=r?.mesh.height??e.height;e.width!==a&&(e.width=a),e.height!==o&&(e.height=o),Tm({element:e}),n!==`transparent`&&(i.fillStyle=n,i.fillRect(0,0,a,o)),r&&await dE({color:t,context:i,result:r})},mE=async({documentFaceBoxColor:e,documentFaceMeshColor:t,documentBoxColor:n,element:r,detection:i,face:a,height:o,ocrLines:s=[],ocrToSource:c=null,overlayColor:l=`transparent`,textColor:u,width:d})=>{let f=r.getContext(`2d`);if(f&&d&&o){if(r.width!==d&&(r.width=d),r.height!==o&&(r.height=o),Tm({element:r}),l!==`transparent`&&(f.fillStyle=l,f.fillRect(0,0,d,o)),i){f.strokeStyle=n,f.lineWidth=3,f.beginPath();for(let[e,t]of i.polygon.entries())e?f.lineTo(t.x,t.y):f.moveTo(t.x,t.y);f.closePath(),f.stroke()}if(a&&(f.strokeStyle=e,f.lineWidth=2,f.strokeRect(a.boundingRect.x,a.boundingRect.y,a.boundingRect.width,a.boundingRect.height),await dE({color:t,context:f,result:a})),c){let e=getComputedStyle(r).color;for(let t of s)fE({backgroundColor:e,color:u,context:f,line:t,toSource:c})}}}}));PT(),Ew(),Bt(),jm(),oE(),hE();var{analyzeDocumentFrame:gE,hasValidDocumentSideData:_E,validateDocumentBack:vE}=TT,yE=({view:e,display:t,isActive:n,notifyCapturesChanged:r,getVerifyOptions:i})=>{let a=e.ref,o=async()=>{t.success.value=!0,await _m({milliseconds:400}),t.success.value=!1},s=async({frame:s,session:c,state:l,options:u})=>{let d=performance.now(),f=!!l.captures.documentFront,p=u.requiredDocumentStableFrames,m=null,h=null;try{m=await gE({frame:s,prepareForMatch:f||l.documentStableFrames+1>=u.requiredDocumentStableFrames,options:{...i({configuration:u}),alignment:l.matchOptions.alignment,requiresFace:!f}});let{orientation:e,detection:d,face:g}=m;if(!n({flow:`document`,session:c,state:l}))return!1;let _=f?vE({current:m,front:l.documentFrontSignature}):null;h=f?ay({front:l.documentFrontSignature,current:m.signature}):null;let v=l.document?{...l.document,ocr:l.document.document_front}:void 0,y=_E({analysis:m,isBack:f,front:v}),b=(f?_?.valid===!0:m.valid)&&y,x=e?e.rotation:null;x!==l.documentOrientation&&(l.documentStableFrames=0),l.documentOrientation=x,l.documentStableFrames=b?l.documentStableFrames+1:0,u.showDocumentOverlay?await mE({documentFaceBoxColor:u.documentFaceBoxColor,documentFaceMeshColor:u.documentFaceMeshColor,documentBoxColor:u.documentBoxColor,element:a.mesh,detection:d,face:g,height:s.height,ocrLines:u.showTextOverlay?m.text.lines:[],ocrToSource:u.showTextOverlay?m.documentToSource:null,overlayColor:u.documentOverlayColor,textColor:u.textColor,width:s.width}):Tm({element:a.mesh});let S=SE({analysis:m,dataValid:y,isBack:f,minFaceAreaRatio:u.minDocumentFaceAreaRatio,rejectionReasons:_?_.reasons:m.failureReasons,valid:b,stable:l.documentStableFrames>=p});if(t.feedback.value={flow:`document`,...S},l.documentStableFrames<p)return!1;let C=await Dm({frame:s});return n({flow:`document`,session:c,state:l})?f?(bE({analysis:m,isBack:!0,state:l}),l.captures.documentBack=C,r({state:l}),await o(),!0):!m.embeddings||!m.images?!1:(bE({analysis:m,isBack:!1,state:l}),l.documentFaceEmbeddings=m.embeddings,l.documentFrontSignature=m.signature,l.preparedCaptures.documentFront=m.images,l.captures.documentFront=C,r({state:l}),await o(),!0):!1}finally{m&&n({flow:`document`,session:c,state:l})&&e.collectDocumentDebug({analysis:m,sideComparison:h,isBack:f,processingTimeMilliseconds:performance.now()-d,state:l})}};return{runDocumentLoop:async({session:e,state:r,options:i})=>{for(;n({flow:`document`,session:e,state:r});){if(await bm({video:a.video}),!n({flow:`document`,session:e,state:r}))return;let o=await createImageBitmap(a.video);try{let n=await km({frame:o});try{if(await s({frame:n,session:e,state:r,options:i})){r.flow=null,t.debug.value=[];return}}finally{n.close()}}finally{o.close()}}}}},bE=({analysis:e,isBack:t,state:n})=>{if(!e.ocr)throw M({code:j.CAPTURES_INCOMPLETE});let r={ocr:e.ocr,codes:e.codes};if(t){if(!n.document)throw M({code:j.CAPTURES_INCOMPLETE});let t=Sy({classification:n.document,front:{ocr:n.document.document_front,codes:n.document.codes},back:r});n.document={...n.document,...t,document_back:e.ocr}}else{if(!e.documentKind)throw M({code:j.DOCUMENT_NOT_RECOGNIZED});let t={document:e.documentKind,europeanDrivingLicense:e.europeanDrivingLicense,identity:e.identity},i=Sy({classification:t,front:r});n.identity=e.identity,n.document={...t,...i,document_front:e.ocr,document_back:null}}n.documentCodes=n.document.codes},xE=({rejection:e})=>e===`coverage_low`?`DOCUMENT_BOX_TOO_SMALL`:e===`coverage_high`?`DOCUMENT_BOX_TOO_LARGE`:e===`edge_proximity`?`DOCUMENT_BOX_NEAR_EDGE`:e===`opposite_edges`?`DOCUMENT_BOX_TOUCHES_EDGES`:e===`aspect_ratio`?`DOCUMENT_NOT_SUPPORTED`:`DOCUMENT_SHAPE_INVALID`,SE=({analysis:e,dataValid:t,isBack:n,minFaceAreaRatio:r,rejectionReasons:i,valid:a,stable:o})=>{let s=`front`;n?s=`back`:e.documentKind===`passport`&&(s=`passport`);let c=Object.keys(e.documentAnalysis.diagnostics.rejected)[0];return c?{target:s,code:xE({rejection:c})}:e.detection?e.documentAnalysis.isBlurry?{target:s,code:`DOCUMENT_BLURRY`}:n&&i.includes(j.DOCUMENT_BACK_CONTAINS_FACE)?{target:s,code:`DOCUMENT_BACK_HAS_FACE`}:n&&i.includes(j.DOCUMENT_BACK_NOT_DISTINCT)?{target:s,code:`DOCUMENT_BACK_SAME_AS_FRONT`}:!n&&!e.face?{target:s,code:`DOCUMENT_FRONT_FACE_NOT_DETECTED`}:!n&&!e.faceContained?{target:s,code:`DOCUMENT_FRONT_FACE_NOT_CONTAINED`}:!n&&!e.alignment.faceAreaValid&&e.alignment.faceAreaRatio<r?{target:s,code:`DOCUMENT_FRONT_FACE_TOO_SMALL`}:!n&&(!e.alignment.faceAreaValid||!e.alignment.faceDimensionsValid)?{target:s,code:`DOCUMENT_FRONT_FACE_SIZE_INVALID`}:!n&&(!e.alignment.textParallel||e.alignment.textSide===`unknown`||e.alignment.faceAdjacentTextLineCount<2)?{target:s,code:`DOCUMENT_FRONT_LAYOUT_INVALID`}:!e.text.text||e.text.lines.length<2?{target:s,code:`DOCUMENT_TEXT_NOT_READABLE`}:!n&&!e.documentKind?{target:s,code:`DOCUMENT_NOT_RECOGNIZED`}:t?a?o?{target:s,code:null}:{target:s,code:`DOCUMENT_STABILITY_REQUIRED`}:{target:s,code:`DOCUMENT_VALIDATION_FAILED`}:{target:s,code:`DOCUMENT_CODE_NOT_READABLE`}:{target:s,code:`DOCUMENT_NOT_DETECTED`}},CE,wE,TE=t((()=>{jm(),CE=({pitch:e,pose:t,requireEyeLevelCamera:n=!0,options:r})=>{if(!n||t!==`faceStraight`)return null;let i=Math.max(-8,r.minPitch),a=Math.min(8,r.maxPitch);return!Number.isFinite(e)||e<i||e>a?`FACE_CAMERA_ALIGNMENT_REQUIRED`:null},wE=()=>xm()?`alignPhoneWithFace`:`alignFaceWithWebcam`})),EE,DE,OE,kE=t((()=>{EE={front:`frameDocument`,back:`frameDocumentBack`,passport:`framePassport`},DE={FACE_NOT_DETECTED:`faceNotFound`,FACE_IN_POLYGON:`faceInPolygon`,FACE_TOO_SMALL:`faceTooSmall`,FACE_CENTER_MOVE_LEFT:`faceCenterMoveLeft`,FACE_CENTER_MOVE_RIGHT:`faceCenterMoveRight`,FACE_CENTER_MOVE_UP:`faceCenterMoveUp`,FACE_CENTER_MOVE_DOWN:`faceCenterMoveDown`,FACE_STABILITY_REQUIRED:`stayStill`,DOCUMENT_NOT_DETECTED:`documentNotDetected`,DOCUMENT_BOX_TOO_SMALL:`documentBoxTooSmall`,DOCUMENT_BOX_TOO_LARGE:`documentBoxTooLarge`,DOCUMENT_BOX_NEAR_EDGE:`documentBoxNearEdge`,DOCUMENT_BOX_TOUCHES_EDGES:`documentBoxTouchesEdges`,DOCUMENT_SHAPE_INVALID:`documentShapeInvalid`,DOCUMENT_NOT_SUPPORTED:`documentNotSupported`,DOCUMENT_BLURRY:`documentBlurry`,DOCUMENT_FRONT_FACE_NOT_DETECTED:`faceNotVisibleInDocument`,DOCUMENT_FRONT_FACE_NOT_CONTAINED:`faceNotVisibleInDocument`,DOCUMENT_FRONT_FACE_TOO_SMALL:`documentPhotoTooSmall`,DOCUMENT_FRONT_FACE_SIZE_INVALID:`documentAlignmentInvalid`,DOCUMENT_FRONT_LAYOUT_INVALID:`documentAlignmentInvalid`,DOCUMENT_TEXT_NOT_READABLE:`documentNotReadable`,DOCUMENT_NOT_RECOGNIZED:`invalidDocument`,DOCUMENT_CODE_NOT_READABLE:`passportMrzNotReadable`,DOCUMENT_BACK_HAS_FACE:`documentBackHasFace`,DOCUMENT_BACK_SAME_AS_FRONT:`documentBackSameAsFront`,DOCUMENT_STABILITY_REQUIRED:`holdDocumentStill`,DOCUMENT_VALIDATION_FAILED:`documentValidationFailed`},OE={documentTargets:EE,rejections:DE}})),AE,jE,ME=t((()=>{TE(),YT(),kE(),AE=({target:e})=>OE.documentTargets[e],jE=({code:e})=>e===`FACE_CAMERA_ALIGNMENT_REQUIRED`?wE():e in OE.rejections?OE.rejections[e]:JT({code:e})})),NE,PE,FE,IE,LE,RE,zE,BE,VE,HE,UE,WE,GE,KE,qE,JE,YE,XE,ZE=t((()=>{PT(),Ew(),Bt(),TE(),vm(),jm(),oE(),ME(),hE(),{detectPictureFaces:NE}=bT,PE={FACEKEY_LOWER_HEAD:`FACE_PITCH_LOOK_DOWN`,FACEKEY_LOWER_HEAD_LESS:`FACE_PITCH_LOWER_LESS`,FACEKEY_RAISE_HEAD:`FACE_PITCH_LOOK_UP`,FACEKEY_RAISE_HEAD_LESS:`FACE_PITCH_RAISE_LESS`,FACEKEY_TILT_HEAD_LEFT:`FACE_ROLL_TILT_LEFT`,FACEKEY_TILT_HEAD_LESS:`FACE_ROLL_TILT_LESS`,FACEKEY_TILT_HEAD_RIGHT:`FACE_ROLL_TILT_RIGHT`,FACEKEY_TURN_HEAD_LEFT:`FACE_YAW_TURN_LEFT`,FACEKEY_TURN_HEAD_LESS:`FACE_YAW_TURN_LESS`,FACEKEY_TURN_HEAD_RIGHT:`FACE_YAW_TURN_RIGHT`,FACEKEY_SMILE_REQUIRED:`FACE_SMILE_REQUIRED`,FACEKEY_WINK_LEFT_REQUIRED:`FACE_WINK_LEFT_REQUIRED`},FE=({face:e,name:t})=>e.blendshapes[t]??0,IE=({face:e,frame:t})=>e.boundingRect.height/t.height<.4?`FACE_TOO_SMALL`:null,LE=({face:e,pose:t,options:n})=>{let r=aw({...e,pose:t,options:n});return r?PE[r]:null},RE=({face:e,pose:t,options:n})=>LE({face:e,pose:t,options:n})===null,zE=async({capture:e,pose:t,options:n,poseOptions:r,requireEyeLevelCamera:i,referencePose:a,referencePoses:o})=>{let s=await wT.imageBitmap({blob:e});try{let e=await NE(s),c=e.length===1?e[0]:null;if(!c)return null;if(!(await ST.detectFaceLiveness({detection:c,frame:s})).live)throw M({code:j.FACE_SPOOF_DETECTED});if(t===`faceReference`){let e=o??(a?[a]:[]);if(!e.length||e.some(e=>ow({alignment:c,target:e})))return null}else if(!RE({face:c,pose:t,options:r}))return null;if(CE({pitch:c.pitch,pose:t,requireEyeLevelCamera:i,options:r}))return null;let l=wT.prepareFace({alignment:n.alignment,face:c,frame:s});return l?await wT.preparedFaceArtifacts({face:l}):null}finally{s.close()}},{detectDocumentBox:BE}=yT,{detectFace:VE}=bT,HE=({view:e,display:t,isActive:n,notifyCapturesChanged:r})=>{let i=e.ref,a=({state:e})=>e.faceSequence[e.poseIndex]??`faceStraight`,o=({face:e,frame:n})=>{let r=e.boundingRect.x+e.boundingRect.width/2,i=e.boundingRect.y+e.boundingRect.height/2,a=(t.cameraFacingMode.value===`user`?n.width-r:r)/n.width,o=i/n.height;return a<.4?`FACE_CENTER_MOVE_RIGHT`:a>.6?`FACE_CENTER_MOVE_LEFT`:o<.4?`FACE_CENTER_MOVE_DOWN`:o>.6?`FACE_CENTER_MOVE_UP`:null},s=async({frame:s,session:c,state:l,options:u})=>{let d=performance.now(),f=null,p=!1;try{f=await VE(s);let e=f?await BE(s):null;if(p=!!(f&&e&&yC({face:f,polygon:e.polygon})),!n({flow:`face`,session:c,state:l}))return!1;if(u.showFaceOverlay&&await pE({element:i.mesh,meshLineColor:u.faceMeshColor,overlayColor:u.faceOverlayColor,result:f}),!f){l.poseStableFrames=0;let e=a({state:l});return t.feedback.value={flow:`face`,code:`FACE_NOT_DETECTED`,pose:e},!1}if(p)return l.poseStableFrames=0,t.feedback.value={flow:`face`,code:`FACE_IN_POLYGON`,pose:a({state:l})},!1;let d=a({state:l}),m=IE({face:f,frame:s});if(m)return l.poseStableFrames=0,t.feedback.value={flow:`face`,code:m,pose:d},!1;let h=o({face:f,frame:s});if(h)return l.poseStableFrames=0,t.feedback.value={flow:`face`,code:h,pose:d},!1;let g=CE({pitch:f.pitch,pose:d,requireEyeLevelCamera:u.requireEyeLevelCamera,options:u});if(g)return l.poseStableFrames=0,l.guidanceCodeState=QT(),l.correctiveState=$T(),t.guidance.value=null,t.corrective.value=null,t.feedback.value={flow:`face`,code:g,pose:d},!1;let _={pitch:f.pitch,yaw:f.yaw,roll:f.roll},v=rE({alignment:_,blendshapes:f.blendshapes,neutral:l.neutralPose,referencePose:WE({state:l,alignment:_}),pose:d,options:u});l.guidanceCodeState=iE({state:l.guidanceCodeState,code:v.code,requiredFrames:3}),t.guidance.value=v;let y=v.code?PE[v.code]:null,b=l.guidanceCodeState.published?PE[l.guidanceCodeState.published]:null,x=aE({pose:d,corrective:b?jE({code:b}):null}).corrective,S=performance.now();if(l.correctiveState=eE({label:x,now:S,state:l.correctiveState}),t.corrective.value=tE({label:x,now:S,state:l.correctiveState}),y)return l.poseStableFrames=0,t.feedback.value={flow:`face`,code:b,pose:d},!1;if(d===`faceStraight`&&(l.neutralPose=_),l.poseStableFrames+=1,l.poseStableFrames<u.requiredFaceStableFrames)return t.feedback.value={flow:`face`,code:`FACE_STABILITY_REQUIRED`,pose:d},!1;t.feedback.value={flow:`face`,code:null,pose:d};let C=await Dm({frame:s}),w;try{w=await zE({capture:C,pose:d,options:l.matchOptions,poseOptions:u,requireEyeLevelCamera:u.requireEyeLevelCamera,referencePose:WE({state:l}),referencePoses:GE({state:l})})}catch(e){if(Pt({error:e})===j.FACE_SPOOF_DETECTED&&!n({flow:`face`,session:c,state:l}))return!1;throw e}if(!n({flow:`face`,session:c,state:l}))return!1;if(!w)return l.poseStableFrames=0,t.feedback.value={flow:`face`,code:`FACE_STABILITY_REQUIRED`,pose:d},!1;let T=xw({image:wT.readImage({frame:s,width:32,height:32})}),E=l.previousPoseBackgroundSignature;if(E&&!Sw({first:E,second:T}).matched)throw M({code:j.POSE_BACKGROUND_MISMATCH});let ee=l.faceEmbeddings.faceStraight;if(ee&&fw({first:ee,second:w.embeddings})<=l.matchOptions.threshold)throw M({code:j.POSE_IDENTITY_MISMATCH});let D=UE({pose:d,index:l.poseIndex});return l.captures[D]=C,l.preparedCaptures[D]=w.images,l.faceEmbeddings[D]=w.embeddings,l.previousPoseBackgroundSignature=T,r({state:l}),t.success.value=!0,await _m({milliseconds:400}),t.success.value=!1,n({flow:`face`,session:c,state:l})?(l.poseIndex+=1,t.guidance.value=null,l.poseStableFrames=0,l.guidanceCodeState=QT(),l.correctiveState=$T(),t.corrective.value=null,t.progress.value={completed:l.poseIndex,total:l.faceSequence.length},l.poseIndex===l.faceSequence.length?(t.feedback.value=null,!0):(t.feedback.value={flow:`face`,pose:a({state:l}),code:null},!1)):!1}finally{n({flow:`face`,session:c,state:l})&&e.collectFaceDebug({face:f,faceInPolygon:p,processingTimeMilliseconds:performance.now()-d,state:l}),s.close()}};return{runFaceLoop:async({session:e,state:r,options:a})=>{for(;n({flow:`face`,session:e,state:r});){if(await bm({video:i.video}),!n({flow:`face`,session:e,state:r}))return;let o=await createImageBitmap(i.video);if(await s({frame:o,session:e,state:r,options:a})){r.flow=null,t.debug.value=[],t.guidance.value=null;return}}}}},UE=({pose:e,index:t})=>e===`faceReference`&&t>1?`faceReference_${t-1}`:e,WE=({state:e,alignment:t})=>{let n=GE({state:e});return(t?n?.find(e=>ow({alignment:t,target:e})!==null):void 0)||(e.faceReference?.poseGroups?.[e.poseIndex-1]?.pose??e.faceReference?.pose)},GE=({state:e})=>{let t=e.faceReference,n=t?.poseGroups?.[e.poseIndex-1];if(!t?.candidates||!n)return;let r=t.candidates;return n.candidateIndices.map(e=>r[e].pose)},KE=({captures:e,state:t})=>t.faceSequence.every((n,r)=>{let i=UE({pose:n,index:r});return!!(e[i]&&t.preparedCaptures[i]&&t.faceEmbeddings[i])}),qE=({captures:e,state:t})=>{if(!KE({captures:e,state:t}))throw M({code:j.CAPTURES_INCOMPLETE});let n=[...t.faceSequence];return{faces:n.map((e,t)=>UE({pose:e,index:t})).map(t=>e[t]).filter(e=>!!e),poses:n,embeddings:n.map((e,n)=>t.faceEmbeddings[UE({pose:e,index:n})]).filter(e=>!!e)}},JE=({sequence:e})=>{let t=[...e];for(let e=t.length-1;e>0;--e){let n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t},YE=({sequence:e})=>[...e].sort((e,t)=>RT[e]-RT[t]),XE=({poses:e,randomize:t})=>{let n=e===`all`?LT.filter(e=>e!==`faceReference`):e??IT;if(!n.length)throw M({code:j.INVALID_POSES});let r=[...new Set(n)];if(r.includes(`faceReference`)||r.length!==n.length||r.some(e=>!LT.includes(e))||r[0]!==`faceStraight`||IT.some(e=>!r.includes(e)))throw M({code:j.INVALID_POSES});let i=r.slice(1);return t?[`faceStraight`,...JE({sequence:i})]:[`faceStraight`,...YE({sequence:i})]}}));ZE(),Xu(),W(),Py(),SC(),kC(),TC();var QE=Ku({offset:!0}).nullable(),$E=Pl([`verify_face`,`verify_document`,`match_id`,`match_reference`]),eD=V({id:wl(),user_id:wl().nullable(),ip:z().nullable(),origin:z().nullable(),user_agent:z().nullable(),language:z().nullable(),timezone:z().nullable(),country:z().nullable(),region:z().nullable(),city:z().nullable(),action:$E,source_ids:kl(wl()),document_code:z().nullable(),outcome:wC.nullable(),match:El().nullable(),feedback_match:El().nullable(),feedback_reason:z().nullable(),feedback_created_at:QE,score:B().nullable(),threshold:B().nullable(),token_hash:z(),expires_at:Ku({offset:!0}),consumed_at:QE,resolved_at:QE,started_at:Ku({offset:!0}),completed_at:QE,execution_ms:B().nullable(),error:z().nullable(),created_at:Ku({offset:!0}),updated_at:Ku({offset:!0})}).meta({id:`Verification`}),tD=eD.omit({created_at:!0,updated_at:!0,timezone:!0,country:!0,region:!0,city:!0,feedback_match:!0,feedback_reason:!0,feedback_created_at:!0}).partial({outcome:!0,origin:!0,language:!0,completed_at:!0,consumed_at:!0,resolved_at:!0,document_code:!0,match:!0,score:!0,threshold:!0,execution_ms:!0,error:!0,source_ids:!0}),nD=V({id:wl().meta({param:{in:`path`,name:`id`}})}),rD={action:$E,intentInput:V({action:$E}),intent:EC.extend({action:$E}),row:eD,rowInsert:tD,id:nD,list:kl(eD),captures:Ml(z(),xC).meta({id:`VerificationCaptures`}),update:nD.extend({match:El(),reason:z().min(10).max(2e3)}),public:V({resultId:wl(),action:$E,outcome:wC.nullable(),matched:El().nullable(),score:B().nullable(),threshold:B().nullable(),reason:Zu.nullable(),documentCode:z().nullable(),identity:Ny.nullable(),completedAt:QE,createdAt:Ku({offset:!0})})};W(),Bt();var iD=async({apiUrl:e,path:t,method:n=`POST`,body:r,clientKey:i,signal:a})=>{let o=Pm({url:e??`https://api.voltom.io`}),s={};i&&(s.authorization=`Bearer ${i}`),r&&(s[`content-type`]=`application/json`);let c;try{a?.throwIfAborted(),c=await fetch(`${o}${t}`,{method:n,headers:s,body:r,signal:a})}catch(e){throw zt({error:e,fallback:j.NETWORK_ERROR,signal:a})}if(c.status===413)throw M({code:j.REQUEST_TOO_LARGE,status:c.status});let l;try{l=await c.json(),a?.throwIfAborted()}catch(e){throw zt({error:M({code:j.INVALID_SERVICE_RESPONSE,status:c.status,cause:e}),signal:a})}if(!c.ok){let e=Qu.safeParse(l);throw e.success?M({code:e.data.code,status:c.status,cause:l}):M({code:j.INVALID_SERVICE_RESPONSE,status:c.status,cause:l})}return l};BT(),Bt(),jm();var aD=async({clientKey:e,apiUrl:t,signal:n})=>{await iD({apiUrl:t,path:`/auth/me`,method:`GET`,clientKey:e,signal:n})},oD=({apiUrl:e})=>{if(typeof navigator<`u`&&typeof navigator.sendBeacon==`function`)try{navigator.sendBeacon(`${Pm({url:e??`https://api.voltom.io`})}/script-loads`)}catch{return}},sD=async({clientKey:e,apiUrl:t,endpoint:n,documentBack:r,documentFront:i,faces:a=[],options:o,picture:s,poseReference:c,poseReferences:l,poses:u=[],sourceIds:d=[],threshold:f,token:p,signal:m})=>{if(!e)throw M({code:j.CLIENT_KEY_REQUIRED});let h=JSON.stringify({token:p,documentFront:i?await Am({image:i}):void 0,documentBack:r?await Am({image:r}):void 0,reference:s?await Am({image:s}):void 0,poseReference:c?await Am({image:c}):void 0,poseReferences:l?await Promise.all(l.map(e=>Promise.all(e.map(e=>Am({image:e}))))):void 0,faces:await Promise.all(a.map(e=>Am({image:e}))),options:o,poses:u.map(e=>zT[e]),source_ids:d,threshold:f});m?.throwIfAborted();let g=await iD({apiUrl:t,path:n,body:h,clientKey:e,signal:m}),_=rD.public.safeParse(g);if(!_.success)throw M({code:j.INVALID_SERVICE_RESPONSE,cause:g});let v=_.data,{outcome:y,matched:b}=v;if(y===null||b===null)throw M({code:j.INVALID_SERVICE_RESPONSE,cause:g});if(y===`error`)throw M({code:v.reason??j.INTERNAL_ERROR,resultId:v.resultId,cause:v});if(v.outcome===`pass`!==v.matched||v.outcome===`pass`&&v.reason!==null)throw M({code:j.INVALID_SERVICE_RESPONSE,cause:v});return{...v,outcome:y,matched:b}};PT(),fd(),Ew(),kv(),BT(),Bt(),vm(),jm(),oE(),hE();var{loadDocumentBoxDetector:cD,detectDocumentOrientation:lD}=yT,{detectPictureFaces:uD,loadFaceDetector:dD}=bT,{loadFaceMatch:fD,warmupFaceMatch:pD}=wT,{loadFaceLiveness:mD}=ST,{loadTextDetector:hD}=CT,gD={"/verify/face":`verify_face`,"/verify/document":`verify_document`,"/match/id":`match_id`,"/match/reference":`match_reference`},_D=({options:e,view:t,display:n,events:r})=>{let i=t.ref,a=[...IT],o=({language:e})=>e??hm(),s=()=>({reference:null,faceReference:null,identity:null,flow:null,session:0,faceSequence:[...a],poseIndex:0,poseStableFrames:0,documentStableFrames:0,documentOrientation:null,documentFaceEmbeddings:null,documentFrontSignature:null,documentCodes:[],matchOptions:{alignment:e.alignment,threshold:e.threshold},captures:{},preparedCaptures:{},faceEmbeddings:{},previousPoseBackgroundSignature:null,neutralPose:null,guidanceCodeState:QT(),correctiveState:$T(),faceVerificationId:null,documentVerificationId:null,cameraActive:!1,cameraSize:n.cameraSize,cameraFacingMode:n.cameraFacingMode}),c=({active:e,state:t})=>{t.cameraActive!==e&&(t.cameraActive=e,r.dispatchEvent(new CustomEvent(`voltom:camera-change`,{detail:{active:e}})))},l=({state:e})=>{Cm({video:i.video}),c({active:!1,state:e}),e.cameraSize.value=null,e.cameraFacingMode.value=null,n.feedback.value=null,n.guidance.value=null,n.corrective.value=null,n.success.value=!1},u=({state:e})=>({identity:e.identity,document:e.document,captures:{...e.captures,...e.reference?{reference:e.reference.picture??e.reference.portrait}:{}},documentCodes:[...e.documentCodes],preparedCaptures:{...e.preparedCaptures}}),d=({state:e})=>{let t=u({state:e});r.dispatchEvent(new CustomEvent(`voltom:captures-change`,{detail:t}))},f=({state:t,options:r=e})=>{t.faceReference=t.reference,t.faceSequence=t.faceReference?[`faceStraight`,...(t.faceReference.poseGroups??[null]).map(()=>`faceReference`)]:b({options:r}),t.poseIndex=0,t.poseStableFrames=0;let{documentFront:i,documentBack:a,reference:o}=t.preparedCaptures;t.preparedCaptures={...i?{documentFront:i}:{},...a?{documentBack:a}:{},...o?{reference:o}:{}},t.faceEmbeddings={},t.previousPoseBackgroundSignature=null,t.neutralPose=null,t.guidanceCodeState=QT(),t.correctiveState=$T(),n.corrective.value=null,t.faceVerificationId=null;let{documentFront:s,documentBack:c}=t.captures;t.captures={...s?{documentFront:s}:{},...c?{documentBack:c}:{}}},p=({state:e})=>{e.documentStableFrames=0,e.documentOrientation=null,e.documentFaceEmbeddings=null,e.documentFrontSignature=null,e.identity=null,e.documentCodes=[],delete e.document,e.documentVerificationId=null,delete e.preparedCaptures.documentFront;let t={...e.captures};delete t.documentFront,delete t.documentBack,e.captures=t},m=({state:e})=>{e.session+=1,e.flow=null,l({state:e}),Tm({element:i.mesh}),n.debug.value=[]},h=({state:e})=>{m({state:e}),d({state:e}),n.error.value=null},g=({state:e})=>{let t=i.video.videoWidth,n=i.video.videoHeight;t&&n&&(e.cameraSize.value={width:t,height:n})},_=async({facingMode:e,state:t})=>{l({state:t});let n=t.session,r=await wm({facingMode:e,video:i.video});if(t.session!==n)throw Cm({video:i.video}),te();t.cameraFacingMode.value=r,g({state:t}),c({active:!0,state:t})},v=({flow:e,session:t,state:n})=>n.flow===e&&n.session===t,y=({state:e})=>e.faceSequence[e.poseIndex]??`faceStraight`,b=({options:e})=>XE({poses:e.poses,randomize:e.randomizeFaceSequence??!1}),x=({configuration:e})=>{let t=Object.fromEntries(Object.keys(Q).map(t=>[t,e[t]]));return t.language=o({language:e.language}),t},S=async({configuration:e,endpoint:t,state:n,picture:r,sourceIds:i=[],signal:a})=>{let o=KE({captures:n.captures,state:n})?qE({captures:n.captures,state:n}):null,s=gD[t]??t,c=e.authorize,l=c?await VT({task:()=>c({action:s})}):void 0;return l!==void 0&&HT({intent:l,action:s}),a?.throwIfAborted(),await sD({clientKey:e.clientKey,apiUrl:e.apiUrl,endpoint:t,token:l?.token,documentBack:r?void 0:n.captures.documentBack,documentFront:r?void 0:n.captures.documentFront,faces:o?.faces,options:x({configuration:e}),picture:r,poseReference:n.faceReference?.poseGroups?void 0:n.faceReference?.portrait,poseReferences:n.faceReference?.poseGroups?.map(e=>e.candidateIndices.map(e=>{let t=n.faceReference?.candidates?.[e];if(!t)throw M({code:j.NO_USABLE_CANDIDATES});return t.portrait})),poses:o?.poses,sourceIds:i,threshold:e.threshold,signal:a})},C={options:e,view:t,display:n,isActive:v,notifyCapturesChanged:d,getVerifyOptions:x},{runFaceLoop:w}=HE(C),{runDocumentLoop:T}=yE(C),E=async({state:e,options:t})=>{n.stage.value=`face`,m({state:e}),f({state:e,options:t}),n.progress.value={completed:0,total:e.faceSequence.length},e.matchOptions={alignment:t.alignment,threshold:t.threshold},d({state:e});let r=e.session;e.flow=`face`;try{if(n.feedback.value={flow:`face`,pose:y({state:e}),code:null},await _({facingMode:`user`,state:e}),n.feedback.value={flow:`face`,pose:y({state:e}),code:null},await w({session:r,state:e,options:t}),e.session!==r)throw te();if(!KE({captures:e.captures,state:e}))throw M({code:j.CAPTURES_INCOMPLETE});let a={...e.captures};return l({state:e}),Tm({element:i.mesh}),a}finally{e.session===r&&(n.feedback.value=null)}},ee=async({state:t,options:r=e})=>{n.stage.value=`document`,m({state:t}),p({state:t}),t.matchOptions={alignment:r.alignment,threshold:r.threshold},d({state:t});let a=t.session;t.flow=`document`;try{if(!v({flow:`document`,session:a,state:t})||(await _({facingMode:`environment`,state:t}),n.feedback.value={flow:`document`,code:null,target:`front`},await T({session:a,state:t,options:r}),t.session!==a))throw te();if(!t.captures.documentFront||!t.document)throw M({code:j.CAPTURES_INCOMPLETE});if(t.document.document!==`passport`&&(t.documentStableFrames=0,t.documentOrientation=null,t.flow=`document`,n.feedback.value={flow:`document`,code:null,target:`back`},await T({session:a,state:t,options:r}),t.session!==a))throw te();if(!t.document.valid)throw M({code:j.DOCUMENT_VALIDATION_FAILED});let e={...t.captures};return l({state:t}),Tm({element:i.mesh}),e}finally{t.session===a&&(n.feedback.value=null,Tm({element:i.mesh}))}},D=async()=>{let t=e.capabilities.some(e=>e===`acquireDocument`||e===`matchID`),n=e.capabilities.some(e=>e===`acquireFace`||e===`matchID`||e===`matchReference`),r=[cD(),dD({faceDetector:e.faceDetector}),fD(),...n?[mD()]:[],...t?[NT(),hD({engine:`tiny`,language:`latin`}),hD({engine:e.ocrEngine,language:o({language:e.language})}),XS()]:[],...e.showFaceOverlay||e.showDocumentOverlay?[cE()]:[]];await Promise.all(r);let i=document.createElement(`canvas`);i.width=640,i.height=480;let a=await createImageBitmap(i);try{let e=[uD(a),yT.detectDocumentBox(a),pD()];t&&e.push(lD({frame:a,boundingRect:{x:0,y:0,width:a.width,height:a.height}})),await Promise.all(e)}finally{a.close()}},O=async()=>{let t=e.capabilities.some(e=>e===`acquireDocument`||e===`matchID`),n=e.capabilities.some(e=>e===`acquireFace`||e===`matchID`||e===`matchReference`),r=[`dd.ort`,hv[e.faceDetector],`fl.ort`,`fe.ort`,...n?[`flv.ort`,`flw.ort`]:[],`fmu.ort`,`ort-wasm-simd-threaded.mjs`,`ort-wasm-simd-threaded.wasm`,...t?[`do.ort`,`zxing-wasm/reader/index.js`,`zxing-wasm/share.js`,`zxing-wasm/reader/zxing_reader.wasm`]:[],...e.showFaceOverlay||e.showDocumentOverlay?[`faceMeshLines.json`]:[]],i=[ld({filenames:r})];t&&(i.push(ld({filenames:uv({language:`latin`,engine:`tiny`})})),i.push(ld({filenames:uv({language:o({language:e.language}),engine:e.ocrEngine})}))),await Promise.all(i)},te=()=>M({code:j.OPERATION_CANCELLED}),ne=async({frame:e,face:t,options:n})=>{let r=t.boundingRect,i=Math.max(0,Math.floor(r.x-r.width*.25)),a=Math.max(0,Math.floor(r.y-r.height*.25)),o=Math.min(e.width-i,Math.ceil(r.width*1.5)),s=Math.min(e.height-a,Math.ceil(r.height*1.5)),c=await createImageBitmap(e,i,a,o,s);try{let e=await uD(c,{forMatch:!0}),t=e=>Math.hypot(e.boundingRect.x+e.boundingRect.width/2-(r.x+r.width/2-i),e.boundingRect.y+e.boundingRect.height/2-(r.y+r.height/2-a)),[o]=e.sort((e,n)=>t(e)-t(n));if(!o)return null;let s=wT.prepareFace({alignment:n.alignment,face:o,frame:c}),l=s?await wT.preparedFaceArtifacts({face:s}):null;return l?{portrait:await Dm({frame:c}),pose:{yaw:o.yaw,pitch:o.pitch,roll:o.roll},images:l.images}:null}finally{c.close()}};return{createState:s,stop:h,syncCameraSize:g,captureResult:u,resetFaceFlow:f,resetDocumentFlow:p,notifyCapturesChanged:d,startFaceFlow:E,startDocumentFlow:ee,prepareReference:async({picture:e,digest:t,state:n,options:r,signal:i,multipleFaces:a=!1})=>{let o=await wT.imageBitmap({blob:e});try{let s=await uD(o,{forMatch:!0}),c=[];for(let e of a?s:s.slice(0,1)){i.throwIfAborted();let t=await ne({frame:o,face:e,options:r});t&&c.push(t)}i.throwIfAborted();let l=c[0];if(!l)throw M({code:j.NO_USABLE_CANDIDATES});let u=a?ww({poses:c.map(e=>e.pose)}):void 0;if(u&&u.length+1>LT.length)throw M({code:j.INVALID_POSES});return n.preparedCaptures.reference=l.images,{digest:t,portrait:l.portrait,pose:l.pose,...a?{picture:e,candidates:c.map(({portrait:e,pose:t})=>({portrait:e,pose:t})),poseGroups:u}:{}}}finally{o.close()}},validatePoses:({poses:e})=>{XE({poses:e,randomize:!1})},submitVerification:S,initializeModels:D,preloadModels:O,showError:({error:e,state:t})=>{let r=Pt({error:e});r===j.FACE_SPOOF_DETECTED&&f({state:t}),r!==j.OPERATION_CANCELLED&&m({state:t}),Ge(()=>{n.activity.value=null,r===j.OPERATION_CANCELLED?n.retry.value=null:n.error.value=zt({error:e})})}}};PT(),fd(),Bt();var vD,yD=async()=>{try{vD??=import(cd({filename:`pdf/pdf.mjs`}));let e=await vD;return e.GlobalWorkerOptions.workerSrc=cd({filename:`pdf/pdf.worker.mjs`}),e}catch{throw vD=void 0,M({code:j.PDF_LOAD_FAILED})}},bD=async({blob:e,signal:t})=>{if(new TextDecoder().decode(await e.slice(0,5).arrayBuffer())!==`%PDF-`)return null;if(e.size>1e7)throw M({code:j.REQUEST_TOO_LARGE});t.throwIfAborted();let n=await yD();t.throwIfAborted();let r=new Uint8Array(await e.arrayBuffer()),i=n.getDocument({data:r,cMapUrl:cd({filename:`pdf/cmaps/`}),cMapPacked:!0,standardFontDataUrl:cd({filename:`pdf/standard_fonts/`}),wasmUrl:cd({filename:`pdf/wasm/`})}),a=()=>{i.destroy()};t.addEventListener(`abort`,a,{once:!0});let o;try{let e=await i.promise;t.throwIfAborted();let n=await e.getPage(1),r=n.getViewport({scale:1}),a=n.getViewport({scale:Math.min(1,1200/Math.max(r.width,r.height))}),s=window.document.createElement(`canvas`);s.width=Math.ceil(a.width),s.height=Math.ceil(a.height),await n.render({canvas:s,viewport:a,background:`white`}).promise,t.throwIfAborted(),o=await createImageBitmap(s),s.width=0,s.height=0;let c=await bT.detectPictureFaces(o,{forMatch:!0});t.throwIfAborted();let l=c[0];if(!l)throw M({code:j.NO_USABLE_CANDIDATES});let u=l.boundingRect,d=Math.max(0,Math.floor(u.x-u.width*.25)),f=Math.max(0,Math.floor(u.y-u.height*.25)),p=Math.min(o.width-d,Math.ceil(u.width*1.5)),m=Math.min(o.height-f,Math.ceil(u.height*1.5)),h=new OffscreenCanvas(p,m),g=h.getContext(`2d`);if(!g)throw M({code:j.IMAGE_PROCESSING_FAILED});g.drawImage(o,d,f,p,m,0,0,p,m);let _=await h.convertToBlob({type:`image/jpeg`,quality:.95});return t.throwIfAborted(),_}catch(e){throw t.throwIfAborted(),Rt(e)?e:e instanceof Error&&e.name===`PasswordException`?M({code:j.PDF_PASSWORD_REQUIRED}):M({code:j.INVALID_PDF})}finally{t.removeEventListener(`abort`,a),o?.close(),await i.destroy()}},xD,SD=t((()=>{Ot(),xD=()=>({reference:Ye(!1),stage:Ye(null),activity:Ye(null),error:Ye(null),retry:Ye(null),feedback:Ye(null),guidance:Ye(null),corrective:Ye(null),progress:Ye({completed:0,total:0}),success:Ye(!1),cameraSize:Ye(null),cameraFacingMode:Ye(null),debug:Ye([]),debugEnabled:Ye(!1)})}));SD(),Ew();var CD={...Q,faceDetector:`standard`,language:void 0,clientKey:``,threshold:cw,randomizeFaceSequence:!1,requireEyeLevelCamera:!0,requiredFaceStableFrames:2,requiredDocumentStableFrames:2,showFaceOverlay:!1,showDocumentOverlay:!1,showTextOverlay:!1,faceOverlayColor:`transparent`,faceMeshColor:`#38efb0`,documentOverlayColor:`transparent`,documentBoxColor:`#22d3ee`,documentFaceBoxColor:`#22d3ee`,documentFaceMeshColor:`#38efb0`,textColor:`#22d3ee`,debug:Nm.debug,capabilities:[`acquireFace`,`acquireDocument`,`acquireReference`,`matchID`,`matchReference`]};function $(e,t,n,r,i,a){t||={};var o,s,c=t;if(`ref`in c&&typeof e!=`function`)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:wD,__v:--TD,__i:-1,__u:0};return(i||a)&&(l.__source=i,l.__self=a),O.vnode&&O.vnode(l),l}var wD,TD,ED=t((()=>{ve(),wD=Symbol.for(`pv`),TD=0,Array.isArray})),DD,OD=t((()=>{ED(),DD=({className:e,entries:t,kind:n})=>$(`div`,{className:t.length?e:`hidden`,[`data-${n}-debug`]:``,children:t.map(({label:e,valid:t,value:n})=>$(`div`,{children:[$(`span`,{children:[e,`: `]}),$(`span`,{"data-valid":t===void 0?void 0:String(t),children:n})]},e))})})),kD,AD,jD,MD,ND,PD=t((()=>{ED(),kD=100,AD=2,jD=({total:e})=>kD/e-(e===1?0:AD),MD=({arc:e,index:t,total:n})=>({dasharray:`${e} ${kD-e}`,offset:`${-t*kD/n}`}),ND=({className:e,completed:t,label:n,total:r,variant:i=`bar`})=>{if(i===`ring`){let i=jD({total:r});return $(`svg`,{className:e,"data-pose-progress":``,"data-variant":`ring`,viewBox:`0 0 100 100`,role:`progressbar`,"aria-label":n,"aria-valuemin":0,"aria-valuemax":r,"aria-valuenow":t,children:$(`g`,{transform:`rotate(-90 50 50)`,children:Array.from({length:r},(e,n)=>{let{dasharray:a,offset:o}=MD({arc:i,index:n,total:r});return $(`circle`,{cx:`50`,cy:`50`,r:`50`,pathLength:kD,ref:e=>{e&&(e.setAttribute(`stroke-dasharray`,a),e.setAttribute(`stroke-dashoffset`,o))},"data-pose-progress-step":``,"data-complete":n<t?``:void 0},n)})})})}return $(`div`,{className:e,"data-pose-progress":``,"data-variant":`bar`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":r,"aria-valuenow":t,children:Array.from({length:r},(e,n)=>$(`span`,{"data-pose-progress-step":``,"data-complete":n<t?``:void 0},n))})}})),FD,ID,LD,RD,zD,BD,VD,HD=t((()=>{Ue(),$C(),ED(),FD={faceUp:0,faceRight:90,faceDown:180,faceLeft:270},ID=({rotation:e})=>$(`g`,{transform:`rotate(${e} 50 50)`,children:$(`path`,{"data-pose-solid":``,d:`M 46 82 Q 44 82 44 80 V 42 Q 44 40 42 40 H 33 Q 29 40 32 37 L 48.5 19 Q 50 17 51.5 19 L 68 37 Q 71 40 67 40 H 58 Q 56 40 56 42 V 80 Q 56 82 54 82 Z`})}),LD=()=>$(`path`,{"data-pose-motion":``,d:`M 22 50 H 78`}),RD=({left:e})=>{let t=xe();return $(s,{children:[$(`defs`,{children:$(`marker`,{id:t,viewBox:`0 0 6 6`,markerUnits:`userSpaceOnUse`,markerWidth:`24`,markerHeight:`24`,refX:`4.4`,refY:`3`,orient:`auto`,children:$(`path`,{"data-pose-solid":``,d:`M 0.6 0.3 Q 0 0 0 0.7 V 5.3 Q 0 6 0.6 5.7 L 5.4 3.3 Q 6 3 5.4 2.7 Z`})})}),$(`path`,{"data-pose-motion":``,d:e?`M 68 26 Q 44 34 32 62`:`M 32 26 Q 56 34 68 62`,"marker-end":`url(#${t})`})]})},zD=({referencePose:e})=>{let{yaw:t,pitch:n,roll:r}=e;if(Math.max(Math.abs(t),Math.abs(n))<=15)return Math.abs(r)>=15?$(RD,{left:r>0}):$(LD,{});let i=Math.atan2(-t,-n)*180/Math.PI;return $(ID,{rotation:i})},BD=({pose:e,referencePose:t})=>{let n=FD[e];return n===void 0?e===`faceStraight`?$(LD,{}):e===`faceReference`&&t?$(zD,{referencePose:t}):e===`faceTiltLeft`||e===`faceTiltRight`?$(RD,{left:e===`faceTiltLeft`}):e===`faceSmile`?$(`path`,{"data-pose-smile":``,d:`M 15 45 A 35 35 0 0 0 85 45`}):e===`faceWinkLeft`?$(s,{children:[$(`circle`,{cx:`50`,cy:`50`,r:`33`}),$(`path`,{d:`M 30 46 Q 38 38 46 46`}),$(`circle`,{"data-pose-solid":``,cx:`64`,cy:`44`,r:`4`})]}):null:$(ID,{rotation:n})},VD=({className:e,pose:t,referencePose:n})=>$(`svg`,{className:e,"data-pose-arrow":``,"data-pose":t,viewBox:`0 0 100 100`,"aria-hidden":`true`,children:$(BD,{pose:t,referencePose:n})})})),UD=t((()=>{ED(),HD()})),WD,GD=t((()=>{ED(),WD=({className:e,visible:t})=>$(`svg`,{className:e,"data-pose-success":``,"data-visible":t?``:void 0,viewBox:`0 0 100 100`,"aria-hidden":`true`,children:[$(`circle`,{cx:`50`,cy:`50`,r:`44`}),$(`path`,{d:`M29 51 43 65 72 36`,pathLength:`1`})]})})),KD,qD=t((()=>{KD=`/*! tailwindcss v4.3.4 | MIT License | https://tailwindcss.com */
|
|
72
|
+
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:block))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-border-style:solid;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-font-weight:initial;--tw-outline-style:solid;--tw-leading:initial}}}[data-voltom-demo],[data-voltom-root],[data-facekey-root],[data-facegate-root]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light dark;--theme-canvas:var(--lightningcss-light,#fafafa)var(--lightningcss-dark,#0b0b0b);--theme-surface:var(--lightningcss-light,#fff)var(--lightningcss-dark,#202020);--theme-surface-subtle:var(--lightningcss-light,#f5f5f5)var(--lightningcss-dark,#2c2c2c);--theme-text:var(--lightningcss-light,#121212)var(--lightningcss-dark,#f7f7f7);--theme-text-muted:var(--lightningcss-light,#626262)var(--lightningcss-dark,#a3a3a3);--theme-text-inverse:var(--lightningcss-light,#fafafa)var(--lightningcss-dark,#0b0b0b);--theme-border:var(--lightningcss-light,#bfbfbf)var(--lightningcss-dark,#606060);--theme-primary:var(--lightningcss-light,#121212)var(--lightningcss-dark,#f7f7f7);--theme-primary-hover:var(--lightningcss-light,#262626)var(--lightningcss-dark,#e5e5e5);--theme-primary-active:var(--lightningcss-light,#404040)var(--lightningcss-dark,#d4d4d4);--theme-focus:var(--lightningcss-light,#525252)var(--lightningcss-dark,#d4d4d4);--theme-cocoa:var(--lightningcss-light,#6b4423)var(--lightningcss-dark,#d29a63);--theme-mint:var(--lightningcss-light,#116b4c)var(--lightningcss-dark,#38efb0);--theme-cyan:var(--lightningcss-light,#0e7490)var(--lightningcss-dark,#22d3ee);--theme-violet:var(--lightningcss-light,#5b21b6)var(--lightningcss-dark,#b69cff);--theme-berry:var(--lightningcss-light,#a21caf)var(--lightningcss-dark,#e879f9);--theme-danger:var(--lightningcss-light,#b42318)var(--lightningcss-dark,#ff6b6b);--theme-danger-surface:var(--lightningcss-light,#fee2e2)var(--lightningcss-dark,#451a19);--theme-success:var(--lightningcss-light,#087443)var(--lightningcss-dark,#4ade80);--theme-success-surface:var(--lightningcss-light,#e7f6ee)var(--lightningcss-dark,#123c2b);--theme-warning:var(--lightningcss-light,#a16207)var(--lightningcss-dark,#ffc93c);--theme-warning-surface:var(--lightningcss-light,#fef3c7)var(--lightningcss-dark,#422006)}@media (prefers-color-scheme:dark){[data-voltom-demo],[data-voltom-root],[data-facekey-root],[data-facegate-root]{--lightningcss-light: ;--lightningcss-dark:initial}}:is(.dark,[data-theme=dark]) :is([data-voltom-demo],[data-voltom-root],[data-facekey-root],[data-facegate-root]){--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark}:is(.light,[data-theme=light]) :is([data-voltom-demo],[data-voltom-root],[data-facekey-root],[data-facegate-root]){--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light}:is([data-voltom-demo],[data-voltom-root],[data-facekey-root],[data-facegate-root])[data-theme=dark]{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark}:is([data-voltom-demo],[data-voltom-root],[data-facekey-root],[data-facegate-root])[data-theme=light]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light}[data-pose-silhouette],[data-pose-arrow]{display:block;overflow:visible}[data-pose-arrow]{pointer-events:none;fill:none;width:64px;height:64px;stroke:var(--theme-mint);stroke-width:7px;stroke-linecap:round;stroke-linejoin:round;position:absolute;bottom:4%;left:50%;transform:translate(-50%)}[data-pose-arrow] [data-pose-solid]{fill:var(--theme-mint);stroke:none}[data-pose-silhouette] [data-pose-head]{fill:none;stroke:var(--theme-border);stroke-width:1.5px;stroke-dasharray:5 5}[data-pose-silhouette] [data-pose-eye]{fill:var(--theme-text-muted);stroke:none}[data-pose-silhouette] [data-pose-mouth],[data-pose-silhouette] [data-pose-eye-closed],[data-pose-motion]{fill:none;stroke:var(--theme-cyan);stroke-width:2.5px;stroke-linecap:round;stroke-linejoin:round}[data-pose-motion]{stroke-dasharray:6 6;animation:.9s linear infinite pose-motion}[data-pose-arrowhead]{fill:var(--theme-cyan);stroke:none}[data-pose-arrow] [data-pose-motion]{stroke:var(--theme-mint);stroke-width:8px;stroke-dasharray:none;animation:none}[data-pose-arrow] [data-pose-arrowhead]{fill:var(--theme-mint)}[data-pose-arrow] [data-pose-smile]{fill:none;stroke:var(--theme-mint);stroke-width:8px;stroke-linecap:round}[data-pose-progress][data-variant=bar]{gap:4px;width:100%;display:flex}[data-pose-progress][data-variant=bar] [data-pose-progress-step]{background:var(--theme-border);border-radius:9999px;flex:1;height:4px;transition:background .2s}[data-pose-progress][data-variant=bar] [data-pose-progress-step][data-complete]{background:var(--theme-mint)}[data-pose-progress][data-variant=ring]{display:block;overflow:visible}[data-pose-progress][data-variant=ring] [data-pose-progress-step]{fill:none;stroke:var(--theme-border);stroke-width:2px;stroke-linecap:round;transition:stroke .3s}[data-pose-progress][data-variant=ring] [data-pose-progress-step][data-complete]{stroke:var(--theme-mint)}[data-pose-success]{opacity:0;pointer-events:none}[data-pose-success] circle{fill:var(--theme-success-surface);stroke:var(--theme-mint);stroke-width:2px}[data-pose-success] path{fill:none;stroke:var(--theme-mint);stroke-width:5px;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:1;stroke-dashoffset:1px}[data-pose-success][data-visible]{animation:.42s ease-out both pose-success-appear}[data-pose-success][data-visible] path{animation:.24s ease-out 60ms both pose-success-draw}@keyframes pose-motion{to{stroke-dashoffset:-12px}}@keyframes pose-success-appear{0%{opacity:0;transform:scale(.85)}to{opacity:1;transform:scale(1)}}@keyframes pose-success-draw{to{stroke-dashoffset:0}}@media (prefers-reduced-motion:reduce){[data-pose-motion]{animation:none}[data-pose-success][data-visible]{opacity:1}[data-pose-success][data-visible] path{stroke-dashoffset:0}}@layer components{[data-voltom-dialog]{border-style:var(--tw-border-style);background-color:var(--theme-surface);width:100%;max-width:none;height:100dvh;max-height:none;color:var(--theme-text);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;padding:max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));border-width:0;margin:0;font-family:Inter,ui-sans-serif,system-ui,sans-serif;position:fixed;inset:0;overflow-y:auto}[data-voltom-dialog][open]{flex-direction:column;align-items:center;gap:2rem;display:flex}[data-voltom-dialog]::backdrop{background:var(--theme-canvas)}[data-voltom-stage]{flex-direction:column;flex:1;justify-content:center;align-items:center;gap:1.5rem;width:100%;display:flex;position:relative}[data-voltom-camera]{aspect-ratio:1;flex-shrink:0;width:min(60vw,240px,38dvh);position:relative}[data-voltom-camera]>video,[data-voltom-mesh]{object-fit:cover;border-radius:2147483647px;width:100%;height:100%;position:absolute;inset:0}[data-voltom-camera]>video{background-color:var(--theme-surface-subtle)}[data-voltom-mesh]{pointer-events:none}[data-voltom-camera][data-mirrored]>video,[data-voltom-camera][data-mirrored] [data-voltom-mesh]{--tw-scale-x:calc(100% * -1);scale:var(--tw-scale-x) var(--tw-scale-y)}[data-voltom-ring-wrap]{pointer-events:none;position:absolute;inset:-.875rem}[data-voltom-ring-wrap] [data-pose-progress]{width:100%;height:100%;overflow:visible}[data-voltom-camera]>[data-pose-success]{pointer-events:none;z-index:10;width:7rem;height:7rem;margin:auto;position:absolute;inset:0}[data-voltom-instructions]{max-width:var(--container-lg,32rem);text-align:center;font-size:1rem;line-height:var(--tw-leading,var(--text-base--line-height,calc(1.5 / 1)));--tw-font-weight:var(--font-weight-semibold,600);font-weight:var(--font-weight-semibold,600)}[data-voltom-instructions] p{flex-direction:column;gap:.5rem;margin:0;display:flex}[data-voltom-challengeReason]{font-size:.875rem;line-height:var(--tw-leading,var(--text-sm--line-height,calc(1.25 / .875)));--tw-font-weight:var(--font-weight-normal,400);font-weight:var(--font-weight-normal,400);color:var(--theme-text-muted)}[data-voltom-spinner]{flex-direction:column;align-items:center;gap:1rem;display:flex}[data-voltom-spinner]:before{content:"";width:2rem;height:2rem;animation:var(--animate-spin,spin 1s linear infinite);border-style:var(--tw-border-style);border-width:2px;border-color:var(--theme-border);border-top-color:var(--theme-cyan);border-radius:2147483647px}@media (prefers-reduced-motion:reduce){[data-voltom-spinner]:before{animation:none}}[data-voltom-camera]>[data-voltom-spinner]{z-index:20;background-color:var(--theme-canvas);flex-direction:column;justify-content:center;align-items:center;gap:.75rem;display:flex;position:absolute;inset:0}@supports (color:color-mix(in lab, red, red)){[data-voltom-camera]>[data-voltom-spinner]{background-color:color-mix(in oklab, var(--theme-canvas) 70%, transparent)}}[data-voltom-camera]>[data-voltom-spinner]{text-align:center;font-size:.875rem;line-height:var(--tw-leading,var(--text-sm--line-height,calc(1.25 / .875)));--tw-font-weight:var(--font-weight-semibold,600);font-weight:var(--font-weight-semibold,600);color:var(--theme-text);padding-inline:1rem}[data-voltom-dialog][data-mode=face] [data-voltom-camera]>[data-voltom-spinner]{border-radius:2147483647px}[data-voltom-dialog][data-mode=document] [data-voltom-camera]>[data-voltom-spinner]{border-radius:.375rem}[data-voltom-cancel]{cursor:pointer;border-style:var(--tw-border-style);border-width:1px;border-color:var(--theme-border);background-color:var(--theme-surface);font-size:.875rem;line-height:var(--tw-leading,var(--text-sm--line-height,calc(1.25 / .875)));color:var(--theme-text);border-radius:.375rem;padding-block:.75rem;padding-inline:1.5rem}@media (hover:hover){[data-voltom-cancel]:hover{background-color:var(--theme-surface-subtle)}}[data-voltom-cancel]:focus-visible{outline-style:var(--tw-outline-style);outline-offset:4px;outline-width:2px;outline-color:var(--theme-focus)}[data-voltom-error]{color:var(--theme-danger)}[data-voltom-dialog][data-mode=document] [data-voltom-stage]{min-height:0;max-width:var(--container-4xl,56rem)}[data-voltom-dialog][data-mode=document] [data-voltom-camera]{border-style:var(--tw-border-style);--tw-border-style:dashed;border-style:dashed;border-width:2px;border-color:var(--theme-border);aspect-ratio:1.586;border-radius:.375rem;width:min(88vw,420px,82.472dvh);overflow:hidden}[data-voltom-dialog][data-mode=document] video,[data-voltom-dialog][data-mode=document] [data-voltom-mesh]{object-fit:cover;border-radius:0}[data-voltom-debug]{pointer-events:none;z-index:20;border-style:var(--tw-border-style);border-width:1px;border-color:var(--theme-border);background-color:var(--theme-surface);border-radius:.375rem;width:200px;position:fixed;top:.5rem;left:.5rem}@supports (color:color-mix(in lab, red, red)){[data-voltom-debug]{background-color:color-mix(in oklab, var(--theme-surface) 90%, transparent)}}[data-voltom-debug]{font-family:var(--font-mono,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);--tw-leading:calc(.25rem * 4);color:var(--theme-text-muted);padding-block:.25rem;padding-inline:.5rem;font-size:10px;line-height:1rem}[data-voltom-debug] [data-valid=true]{color:var(--theme-mint)}[data-voltom-debug] [data-valid=false]{color:var(--theme-danger)}[data-voltom-root] [hidden],[data-voltom-root] .hidden{display:none}}@media (width<=639px){[data-voltom-dialog][data-mode=document]{padding:max(12px, env(safe-area-inset-top)) 0 max(0px, env(safe-area-inset-bottom));gap:12px}[data-voltom-dialog][data-mode=document] [data-voltom-camera]{aspect-ratio:1/1.586;width:min(94vw,63.0517dvh - 138.714px)}}@media (width<=600px){[data-voltom-dialog][data-mode=face] [data-voltom-camera]{width:min(82vw,325px)}}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}`})),JD=n({createVerificationDisplay:()=>xD,createVerificationView:()=>ZD}),YD,XD,ZD,QD=t((()=>{kv(),ve(),OD(),Bt(),vm(),jm(),PD(),UD(),GD(),oE(),ZE(),ME(),qD(),ED(),YD=new Set([`FACE_NOT_DETECTED`,`FACE_IN_POLYGON`,`FACE_TOO_SMALL`,`FACE_CENTER_MOVE_LEFT`,`FACE_CENTER_MOVE_RIGHT`,`FACE_CENTER_MOVE_UP`,`FACE_CENTER_MOVE_DOWN`,`FACE_CAMERA_ALIGNMENT_REQUIRED`]),XD=({className:e,display:t,elements:n,options:r,onStop:i})=>{let{translate:a,translateError:o}=gm({language:r.language}),c=t.feedback.value,l=t.activity.value,u=l&&l!==`matching`?l.message:``,d=l===`matching`?a(`checkingFaceMatch`):u,f=t.error.value,p=t.cameraSize.value,m=c&&c.flow===`face`?c.pose:void 0,h=c&&c.flow===`face`?c.code:null,g=h&&YD.has(h)?h:null,_=t.guidance.value,v=_&&_.pose===m?_.referencePose:void 0,y=t.progress.value,b=t.corrective.value,x=m?aE({pose:m,corrective:b}):null,S=a(`lookStraight`),C=``;if(x&&(S=a(x.primary),C=x.corrective?a(x.corrective):``),g&&(S=a(jE({code:g})),C=``),c&&c.flow===`document`){let e=a(AE({target:c.target}));S=(c.code&&c.code!==`DOCUMENT_NOT_DETECTED`?a(jE({code:c.code})):``)||e}let w=t.stage.value,T=w===`document`,E=w===`reference`,ee=t.reference.value?[`acquireReference`,`acquireHuman`]:[`acquireHuman`,`acquireDocument`,`matchId`],D=0;T&&(D=1),w===`matching`&&(D=ee.length-1),t.reference.value&&!E&&(D=1);let O=!!l&&!E&&w!==`matching`;return $(s,{children:[$(`style`,{"data-voltom-styles":``,children:KD}),$(`dialog`,{className:e,ref:n.dialog,"data-voltom-dialog":``,"data-mode":w,"aria-label":a(ee[D]),"aria-describedby":`voltom-instructions`,onCancel:e=>{e.preventDefault(),e.stopPropagation(),i()},children:[$(`div`,{"data-voltom-stage":``,children:[$(`div`,{ref:n.camera,"data-voltom-camera":``,"data-mirrored":t.cameraFacingMode.value===`user`?``:void 0,style:{"--voltom-camera-ratio":p?`${p.width} / ${p.height}`:void 0},hidden:E||w===`matching`,children:[$(`video`,{ref:n.video,"data-voltom-video":``,playsInline:!0,muted:!0,autoPlay:!0,"aria-label":a(`cameraPreview`)}),$(`canvas`,{ref:n.mesh,"data-voltom-mesh":``}),!T&&$(`div`,{"data-voltom-ring-wrap":``,children:$(ND,{completed:y.completed,total:y.total,label:a(`faceCaptureProgress`),variant:`ring`})}),!(w!==`face`||!m||g||l||f||t.success.value)&&$(VD,{pose:m,referencePose:v}),$(WD,{visible:t.success.value}),O&&$(`div`,{"data-voltom-spinner":``,"data-voltom-spinner-overlay":``,"aria-hidden":`true`})]}),$(`div`,{"data-voltom-instructions":``,id:`voltom-instructions`,role:`status`,"aria-live":`polite`,children:[O&&$(`p`,{children:d}),!!l&&!O&&$(`div`,{"data-voltom-spinner":``,"aria-label":d,children:d}),!(l||f)&&$(`p`,{children:[$(`span`,{children:S}),!!C&&$(`span`,{"data-voltom-challengeReason":``,children:C})]}),!!f&&$(`p`,{"data-voltom-error":``,children:o({error:f})})]}),$(`button`,{type:`button`,"data-voltom-cancel":``,onClick:i,autoFocus:!0,children:a(`cancel`)})]}),$(DD,{kind:`voltom`,entries:t.debug.value})]})]})},ZD=({root:e,options:t,display:n,onStop:r})=>{let i=({language:e})=>e??hm(),a=({state:e})=>e.faceSequence[e.poseIndex]??`faceStraight`,s=0,c=({entries:e,state:t})=>{if(!n.debugEnabled.value||!t.flow)return;let r=performance.now();r-s<100||(s=r,n.debug.value=e)},l=()=>n.cameraSize.value?`${n.cameraSize.value.width}x${n.cameraSize.value.height}`:`—`,u=()=>{let e=Ev(),t=e.threading.startsWith(`multi`)?`multi`:`single`;return[{label:`Inference`,value:e.inference},{label:`Threading`,value:t}]},d=({face:e,faceInPolygon:r,processingTimeMilliseconds:o,state:s})=>{let d=e?e.pitch:null,f=e?e.yaw:null,p=e?e.roll:null,m=e?FE({face:e,name:`mouthSmileLeft`}):0,h=e?FE({face:e,name:`mouthSmileRight`}):0,g=e?FE({face:e,name:`eyeBlinkLeft`}):0,_=e?FE({face:e,name:`eyeBlinkRight`}):0,v=d!==null&&d>=t.minPitch&&d<=t.maxPitch,y=f!==null&&f>=t.minYaw&&f<=t.maxYaw,b=a({state:s}),x=p!==null&&(b===`faceTiltLeft`?p>t.maxRoll:b===`faceTiltRight`?p<-t.maxRoll:Math.abs(p)<=t.maxRoll),S=e=>e===null?`—`:e.toFixed(2),C=(e,t)=>`${e.toFixed(2)}|${t.toFixed(2)}`;c({state:s,entries:[{label:`Flow`,value:`FACE`},...u(),{label:`Face`,valid:!!e&&!r,value:e?r?`In polygon`:`Yes`:`No`},{label:`Pitch`,valid:v,value:S(d)},{label:`Yaw`,valid:y,value:S(f)},{label:`Roll`,valid:x,value:S(p)},{label:`Smile`,valid:m>=.5&&h>=.5,value:C(m,h)},{label:`Wink left`,valid:Math.round((g-_)*100)/100>=ew,value:C(g,_)},{label:`Stable frames`,valid:s.poseStableFrames>0,value:`${s.poseStableFrames}/${t.requiredFaceStableFrames}`},{label:`Language`,value:i({language:t.language})},{label:`Camera`,value:l()},{label:`Facing mode`,value:n.cameraFacingMode.value??`—`},{label:`Frame time`,value:`${o.toFixed(0)} ms`}]})},f=({analysis:e,sideComparison:r,isBack:a,processingTimeMilliseconds:o,state:s})=>{let{orientation:d,alignment:f,documentKind:p,face:m,faceContained:h,detection:g}=e,{diagnostics:_,isBlurry:v,sharpness:y}=e.documentAnalysis,b=e.text.text,x={label:`Stable frames`,valid:s.documentStableFrames>0,value:`${s.documentStableFrames}/${t.requiredDocumentStableFrames}`},S=_?Object.keys(_.rejected)[0]:void 0,C=[{label:`Sharpness`,valid:v===null?void 0:!v,value:y===null?`—`:String(Math.round(y))},{label:`Rectangle`,valid:g?!0:!S&&void 0,value:g?`yes`:S??`no`},{label:`Orientation`,value:d?`${d.rotation}°`:`—`}],w=[{label:`Text`,valid:!!b,value:b?`yes`:`no`},{label:`Document type`,value:p??``},{label:`Distinct from front`,valid:r?.distinct,value:r?r.distinct?`yes`:`no`:`—`}],T=[{label:`Face`,valid:!!m,value:m?`yes`:`no`},{label:`Face contained`,valid:h,value:h?`yes`:`no`},{label:`Face area`,valid:f.faceAreaValid,value:`${(f.faceAreaRatio*100).toFixed(2)}%`},{label:`Face size`,valid:f.faceDimensionsValid,value:f.faceDimensionsValid?`yes`:`no`},{label:`Text`,valid:!!b,value:b?`yes`:`no`},{label:`Text parallel`,valid:f.textParallel,value:f.textParallel?`yes`:`no`},{label:`Text beside face`,valid:f.faceAdjacentTextLineCount>=2,value:String(f.faceAdjacentTextLineCount)},{label:`Document type`,value:p??``}];c({state:s,entries:[{label:`Flow`,value:a?`DOCUMENT BACK`:`DOCUMENT FRONT`},...u(),...C,...a?w:T,x,{label:`Language`,value:i({language:t.language})},{label:`Camera`,value:l()},{label:`Facing mode`,value:n.cameraFacingMode.value??`—`},{label:`Frame time`,value:`${o.toFixed(0)} ms`}]})},p={dialog:o(),camera:o(),video:o(),mesh:o()};if(e.replaceChildren(),e.dataset.voltomRoot=``,mm({element:e,theme:t.theme}),D($(XD,{display:n,elements:p,options:t,onStop:r}),e),!p.camera.current||!p.video.current||!p.mesh.current)throw M({code:j.UI_ELEMENT_NOT_FOUND});let m={root:e,camera:p.camera.current,video:p.video.current,mesh:p.mesh.current},h=null,g=``,_=()=>{let t=p.dialog.current;if(t&&!t.open){h=document.activeElement instanceof HTMLElement?document.activeElement:null,g=document.body.style.overflow,document.body.style.overflow=`hidden`,document.body.append(e);try{t.showModal()}catch(t){throw e.remove(),document.body.style.overflow=g,t}}},v=()=>{let t=p.dialog.current;t?.open&&(Cm({video:m.video}),t.close(),e.remove(),document.body.style.overflow=g,h?.isConnected&&h.focus(),h=null)};return{ref:m,collectFaceDebug:d,collectDocumentDebug:f,open:_,close:v,dispose:()=>{v(),D(null,e),e.remove()}}}}));Ot(),Bt(),vm(),jm(),SD(),globalThis.VoltomVerify=class{static Errors=j;static isSdkError=Rt;options;view;root;useUi;videoElement;resizeListener;display=xD();events=new EventTarget;translator;flows;state;preparation=null;preloading=null;preparationController=null;prepared=!1;disposed=!1;operationController=null;subscriptions=new Set;uiAttached=!1;notifyStatus({status:e}){this.events.dispatchEvent(new CustomEvent(`voltom:${e}`))}showSpinner({message:e=this.translator.translate(`checkingFaceMatch`)}={}){this.display.activity.value={message:e}}hideSpinner(){this.display.activity.value=null}async runWithSpinner({task:e,message:t}){this.showSpinner({message:t});try{return await e()}finally{this.hideSpinner()}}constructor(e){if(Lm({options:e,capabilities:[`acquireFace`,`acquireDocument`,`acquireReference`,`matchID`,`matchReference`],authorizeRequired:!1}),`root`in e)throw M({code:j.INVALID_OPTIONS});let{video:t,ui:n=!0,prepare:r=Nm.prepare,...i}=e;if(!n&&!t)throw M({code:j.INVALID_OPTIONS});if(!i.clientKey)throw M({code:j.CLIENT_KEY_REQUIRED});this.options=Object.freeze({...CD,...Im(i),...Fm(i),requireEyeLevelCamera:i.requireEyeLevelCamera??!0,capabilities:Object.freeze([...i.capabilities??CD.capabilities]),poses:Array.isArray(i.poses)?Object.freeze([...i.poses]):i.poses}),this.root=document.createElement(`div`),this.useUi=n,this.videoElement=t??document.createElement(`video`),this.translator=gm({language:this.options.language}),this.view={ref:{root:this.root,camera:document.createElement(`div`),video:this.videoElement,mesh:document.createElement(`canvas`)},collectFaceDebug:()=>{},collectDocumentDebug:()=>{},open:()=>{},close:()=>{},dispose:()=>{}},this.flows=_D({options:this.options,view:this.view,display:this.display,events:this.events}),this.state=this.flows.createState(),this.resizeListener=()=>this.flows.syncCameraSize({state:this.state}),this.videoElement.addEventListener(`resize`,this.resizeListener),r&&this.prepare().catch(e=>console.error(e))}async preload(){try{await this.preloadInternal()}catch(e){throw zt({error:e,fallback:j.MODEL_LOAD_FAILED})}}async preloadInternal(){if(this.disposed)throw M({code:j.SDK_DISPOSED});if(this.preloading)return this.preloading;let e=(async()=>{await pm({language:this.options.language}),await this.flows.preloadModels()})();this.preloading=e;try{if(await e,this.disposed)throw M({code:j.SDK_DISPOSED})}catch(t){throw this.preloading===e&&(this.preloading=null),zt({error:t,fallback:j.MODEL_LOAD_FAILED})}}async prepare(){try{await this.prepareInternal()}catch(e){throw zt({error:e,fallback:j.MODEL_LOAD_FAILED})}}async prepareInternal(){if(this.disposed)throw M({code:j.SDK_DISPOSED});if(this.preparation)return this.preparation;let e=new AbortController;this.preparationController=e;let t=(async()=>{await this.preload(),await this.attachUi(),await this.runWithSpinner({task:async()=>{if(await aD({clientKey:this.options.clientKey,apiUrl:this.options.apiUrl,signal:e.signal}),await oD({apiUrl:this.options.apiUrl}),await this.flows.initializeModels(),e.signal.throwIfAborted(),this.disposed)throw M({code:j.SDK_DISPOSED})},message:this.translator.translate(`preparingModels`)})})();this.preparation=t;try{await t,this.prepared=!0,this.preparationController===e&&(this.preparationController=null)}catch(n){throw this.preparation===t&&(this.preparation=null),this.preparationController===e&&(this.preparationController=null),zt({error:n,fallback:j.MODEL_LOAD_FAILED})}}async attachUi(){if(!this.useUi||this.uiAttached)return;let{createVerificationView:e}=await Promise.resolve().then(()=>(QD(),JD));if(this.disposed)throw M({code:j.SDK_DISPOSED});if(this.uiAttached)return;let t=e({root:this.root,options:this.options,display:this.display,onStop:()=>this.stop()});this.videoElement.removeEventListener(`resize`,this.resizeListener),Object.assign(this.view.ref,t.ref),this.view.collectFaceDebug=t.collectFaceDebug,this.view.collectDocumentDebug=t.collectDocumentDebug,this.view.open=t.open,this.view.close=t.close,this.view.dispose=t.dispose,this.videoElement=this.view.ref.video,this.videoElement.addEventListener(`resize`,this.resizeListener),this.uiAttached=!0}async submitVerification(e){let t=e.endpoint===`/verify/document`?this.translator.translate(`checkingDocument`):void 0;return await this.runWithSpinner({task:()=>this.flows.submitVerification({...e,signal:e.signal??this.operationController?.signal}),message:t})}async caniuse(){return await Sm()}async runOperation({retry:e,task:t,onError:n,capability:r,requiresUi:i=!0}){if(this.disposed)throw M({code:j.SDK_DISPOSED});if(!this.options.capabilities.includes(r))throw M({code:j.SDK_CAPABILITY_NOT_CONFIGURED});if(this.operationController)throw M({code:j.OPERATION_IN_PROGRESS});let a=Object.freeze({...this.options}),o=new AbortController;this.operationController=o,o.signal.addEventListener(`abort`,()=>this.flows.stop({state:this.state}),{once:!0}),this.notifyStatus({status:`in-progress`}),Ge(()=>{this.display.reference.value=!!this.state.reference||r===`acquireReference`||r===`matchReference`,this.display.stage.value=`face`,r===`acquireDocument`&&(this.display.stage.value=`document`),(r===`acquireReference`||r===`matchReference`)&&(this.display.stage.value=`reference`),this.display.retry.value=e,this.display.error.value=null,this.display.debugEnabled.value=a.debug,a.debug||(this.display.debug.value=[])});try{return await this.attachUi(),o.signal.throwIfAborted(),i&&this.view.open(),o.signal.throwIfAborted(),await kt({operation:this.prepare(),signal:o.signal}),o.signal.throwIfAborted(),await t({options:a,signal:o.signal})}catch(e){let t=zt({error:e,signal:o.signal});throw n&&await n({error:t,options:a,signal:o.signal}),this.disposed||this.flows.showError({error:t,state:this.state}),t}finally{this.view.close(),this.notifyStatus({status:`ready`}),this.display.debugEnabled.value=this.options.debug,this.operationController===o&&(this.operationController=null)}}setDebug({enabled:e}){if(this.disposed)throw M({code:j.SDK_DISPOSED});if(typeof e!=`boolean`)throw M({code:j.INVALID_OPTIONS});this.options=Object.freeze({...this.options,debug:e}),this.display.debugEnabled.value=e,e||(this.display.debug.value=[])}configure(e){if(this.disposed)throw M({code:j.SDK_DISPOSED});Rm({options:e});let t=[`poses`,`randomizeFaceSequence`,`showFaceOverlay`,`showDocumentOverlay`,`showTextOverlay`,`debug`];for(let[n,r]of Object.entries(e))if(!t.includes(n)||n!==`poses`&&r!==void 0&&typeof r!=`boolean`)throw M({code:j.INVALID_OPTIONS});if(e.poses!==void 0){if(e.poses!==`all`&&!Array.isArray(e.poses))throw M({code:j.INVALID_OPTIONS});this.flows.validatePoses({poses:e.poses})}this.options=Object.freeze({...this.options,...Im(e),poses:Array.isArray(e.poses)?Object.freeze([...e.poses]):e.poses??this.options.poses})}async acquireFace(){return await this.acquireCapture({flow:`face`})}async acquireDocument(){return await this.acquireCapture({flow:`document`})}async acquireCapture({flow:e}){return await this.runOperation({capability:e===`face`?`acquireFace`:`acquireDocument`,retry:()=>this.acquireCapture({flow:e}),onError:async({error:t,options:n})=>{Pt({error:t})!==j.OPERATION_CANCELLED&&(e===`face`?this.flows.resetFaceFlow({state:this.state,options:n}):this.flows.resetDocumentFlow({state:this.state}),this.flows.notifyCapturesChanged({state:this.state}))},task:async({options:t,signal:n})=>{await(e===`face`?this.flows.startFaceFlow:this.flows.startDocumentFlow)({state:this.state,options:t}),n.throwIfAborted();let r=await this.verifyAcquisition({flow:e,options:t});return r.matched&&(this.display.retry.value=null),r}})}async verifyAcquisition({flow:e,options:t}){let n=await this.submitVerification({configuration:t,endpoint:`/verify/${e}`,state:this.state}),r=e===`face`?`faceVerificationId`:`documentVerificationId`;return this.state[r]=n.matched?n.resultId:null,n.matched||(e===`face`?this.flows.resetFaceFlow({state:this.state,options:t}):this.flows.resetDocumentFlow({state:this.state}),this.flows.notifyCapturesChanged({state:this.state})),n}async ensureFaceVerification({options:e,signal:t}){if(t.throwIfAborted(),this.state.faceVerificationId)return null;await this.flows.startFaceFlow({state:this.state,options:e}),t.throwIfAborted();let n=await this.verifyAcquisition({flow:`face`,options:e});return n.matched?null:n}async prepareReference({file:e,options:t,signal:n}){if(this.display.stage.value=`reference`,!(e instanceof Blob))throw this.clearReference(),M({code:j.INVALID_OPTIONS});if(e.size>1e7)throw this.clearReference(),M({code:j.REQUEST_TOO_LARGE});let r=await e.arrayBuffer();n.throwIfAborted();let i=await crypto.subtle.digest(`SHA-256`,r),a=Array.from(new Uint8Array(i),e=>e.toString(16).padStart(2,`0`)).join(``);if(n.throwIfAborted(),this.state.reference?.digest===a)return this.state.reference;this.clearReference();let o=await bD({blob:e,signal:n}),s=o??await Om({blob:e}),c=await this.flows.prepareReference({picture:s,digest:a,state:this.state,options:t,signal:n,multipleFaces:o===null});return n.throwIfAborted(),this.state.reference=c,this.flows.resetFaceFlow({state:this.state,options:t}),this.flows.notifyCapturesChanged({state:this.state}),c}async acquireReference(e){return await this.runOperation({capability:`acquireReference`,retry:()=>this.acquireReference(e),task:async({options:t,signal:n})=>{let r=await this.runWithSpinner({task:()=>this.prepareReference({file:e,options:t,signal:n}),message:this.translator.translate(`preparingReference`)});return this.display.retry.value=null,r}})}async matchID(){return await this.runOperation({capability:`matchID`,retry:()=>this.matchID(),requiresUi:!this.state.faceVerificationId||!this.state.documentVerificationId,task:async({options:e,signal:t})=>{let n=await this.ensureFaceVerification({options:e,signal:t});if(n)return n;if(!this.state.documentVerificationId){await this.flows.startDocumentFlow({state:this.state,options:e}),t.throwIfAborted();let n=await this.verifyAcquisition({flow:`document`,options:e});if(!n.matched)return n}t.throwIfAborted(),this.display.stage.value=`matching`;let r=await this.submitVerification({configuration:e,endpoint:`/match/id`,state:this.state,sourceIds:[this.state.faceVerificationId,this.state.documentVerificationId]});return r.matched&&(this.display.retry.value=null),r}})}async matchReference(e){return await this.runOperation({capability:`matchReference`,retry:()=>this.matchReference(e),requiresUi:!this.state.faceVerificationId,task:async({options:t,signal:n})=>{let r=await this.runWithSpinner({task:()=>this.prepareReference({file:e,options:t,signal:n}),message:this.translator.translate(`preparingReference`)}),i=await this.ensureFaceVerification({options:t,signal:n});if(i)return i;n.throwIfAborted(),this.display.stage.value=`matching`;let a=await this.submitVerification({configuration:t,endpoint:`/match/reference`,state:this.state,picture:r.picture??r.portrait,sourceIds:[this.state.faceVerificationId]});return a.matched&&(this.display.retry.value=null),a}})}clearReference(){this.state.reference=null,this.display.feedback.value=null,delete this.state.preparedCaptures.reference,this.flows.notifyCapturesChanged({state:this.state})}forgetReference(){if(this.disposed)throw M({code:j.SDK_DISPOSED});if(this.operationController)throw M({code:j.OPERATION_IN_PROGRESS});this.clearReference(),this.display.error.value=null}stop(){this.operationController?.abort(M({code:j.OPERATION_CANCELLED})),this.flows.stop({state:this.state}),this.display.retry.value=null,this.view.close(),this.notifyStatus({status:`ready`})}dispose(){if(!this.disposed){this.disposed=!0,this.preparationController?.abort(),this.stop();for(let e of this.subscriptions)e();this.subscriptions.clear(),this.videoElement.removeEventListener(`resize`,this.resizeListener),this.view.dispose(),this.state.captures={},this.state.preparedCaptures={},this.state.faceEmbeddings={},this.state.documentCodes=[],this.state.identity=null,this.state.faceVerificationId=null,this.state.documentVerificationId=null,delete this.state.document,this.clearReference(),this.state.faceReference=null}}forgetFace(){if(this.disposed)throw M({code:j.SDK_DISPOSED});if(this.operationController)throw M({code:j.OPERATION_IN_PROGRESS});this.flows.resetFaceFlow({state:this.state}),this.display.error.value=null,this.flows.notifyCapturesChanged({state:this.state})}forgetDocument(){if(this.disposed)throw M({code:j.SDK_DISPOSED});if(this.operationController)throw M({code:j.OPERATION_IN_PROGRESS});this.flows.resetDocumentFlow({state:this.state}),this.display.error.value=null,this.flows.notifyCapturesChanged({state:this.state})}getState(){return{activity:this.display.activity.value,error:this.display.error.value,retryAvailable:this.display.retry.value!==null,feedback:this.display.feedback.value,debug:this.display.debug.value}}subscribe(e){if(this.disposed)throw M({code:j.SDK_DISPOSED});let t=at(()=>e(this.getState()));return this.subscriptions.add(t),()=>{t(),this.subscriptions.delete(t)}}}})();
|