@voltom.io/sdk 1.0.3 → 1.0.5

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.
Files changed (39) hide show
  1. package/dist/assets/locales/ar.json +57 -9
  2. package/dist/assets/locales/ch.json +57 -9
  3. package/dist/assets/locales/de.json +57 -9
  4. package/dist/assets/locales/en.json +30 -5
  5. package/dist/assets/locales/es.json +56 -8
  6. package/dist/assets/locales/fr.json +56 -8
  7. package/dist/assets/locales/it.json +55 -7
  8. package/dist/assets/locales/ja.json +57 -9
  9. package/dist/assets/locales/pt.json +57 -9
  10. package/dist/assets/locales/ru.json +124 -0
  11. package/dist/assets/locales/zh.json +57 -9
  12. package/dist/sdk/PoseSilhouette-Bbwmry4Z.js +2 -0
  13. package/dist/sdk/PoseSuccess-C3aBF88E.js +2 -0
  14. package/dist/sdk/eyeLevelCamera-DY4onSBz.js +65 -0
  15. package/dist/sdk/facegate/global.d.ts +5 -0
  16. package/dist/sdk/facegate.d.ts +55 -0
  17. package/dist/sdk/facegate.dist.js +56 -0
  18. package/dist/sdk/facegate.js +2 -0
  19. package/dist/sdk/facekey.browser-CVJiBw1f.js +2 -0
  20. package/dist/sdk/facekey.d.ts +13 -17
  21. package/dist/sdk/facekey.dist.js +5 -4
  22. package/dist/sdk/facekey.js +1 -1
  23. package/dist/sdk/media-BRKPXpu3.js +2 -0
  24. package/dist/sdk/presentation-B-TOKUZ3.js +8 -0
  25. package/dist/sdk/presentation-BsnbDv0i.js +2 -0
  26. package/dist/sdk/verify.d.ts +30 -32
  27. package/dist/sdk/verify.dist.js +18 -18
  28. package/dist/sdk/verify.js +1 -1
  29. package/dist/sdk/view-Bfg8u_hZ.js +2 -0
  30. package/dist/sdk/view-CHSkN6gO.js +3 -0
  31. package/dist/sdk/view-DmGKdc3M.js +3 -0
  32. package/package.json +25 -16
  33. package/dist/sdk/DebugPanel-BJqGy2Dp.js +0 -2
  34. package/dist/sdk/faceMatch.shared-D6B1I2T0.js +0 -65
  35. package/dist/sdk/feedback-Cs09W_hs.js +0 -2
  36. package/dist/sdk/presentation-BrCGZT1u.js +0 -8
  37. package/dist/sdk/presentation-Jz2euuHa.js +0 -2
  38. package/dist/sdk/view-usv6rHIE.js +0 -3
  39. package/dist/sdk/view-vxhVZZc1.js +0 -2
@@ -1,65 +0,0 @@
1
- /*! Copyright (c) 2026 VOLTOM. All rights reserved. Proprietary software. See LICENSE at https://voltom.io/license. */
2
- var e=Object.defineProperty,t=(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},n=(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('Calling `require` for "'+e+"\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.")}),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},a,o,s,c,l,u,d,f,p,m,h,g=Symbol.for(`pv`),_={},v=[],y=/^m(i|n|o|s|text|space)$/,b=Array.isArray,x=v.slice,S=Object.assign;function C(e){e&&e.parentNode&&e.remove()}function w(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?x.call(arguments,2):n),T(e,o,r,i,null)}function T(e,t,n,r,i){var s={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:g,__v:i||++o,__i:-1,__u:0};return!i&&a.vnode&&a.vnode(s),s}function E(){return{current:null}}function D(e){return e.children}function ee(e,t){this.props=e,this.context=t,this.__g=0}function te(e,t){if(t==null)return e.__&&te(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:te(e)}function ne(e){if((e=e.__)&&e.__c&&!e.props.__P)return e.__e=null,e.__k.some(function(t){return t&&(e.__e=t.__e)}),ne(e)}function re(e){(8&e.__g||(e.__g|=8,c.push(e),u++))&&l==a.debounceRendering||((l=a.debounceRendering)||queueMicrotask)(ie)}function ie(){var e,t,n,r,i,o,s,f,p;try{for(t=1;c.length;)c.length>t&&c.sort(d),e=c.shift(),t=c.length,8&e.__g&&(r=void 0,i=void 0,o=(i=(n=e).__v).__e,s=[],f=[],(p=n.__P)&&((r=S({constructor:g},i)).__v=i.__v+1,a.vnode&&a.vnode(r),fe(p,r,i,n.__n,p.namespaceURI,32&i.__u?[o]:null,s,o||te(i),32&i.__u,f),r.__v=i.__v,r.__.__k[r.__i]=r,he(s,r,f),i.__=i.__e=null,r.__e!=o&&ne(r)))}finally{(u=c.length)&&(l||queueMicrotask)(ie)}}function ae(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,y=r.__k||v,b=t.length;for(c=oe(n,t,y,c,b),d=0;d<b;d++)(p=n.__k[d])!=null&&(f=~p.__i&&y[p.__i]||_,p.__i=d,g=fe(e,p,f,i,a,o,s,c,l,u),m=p.__e,(f.ref!=p.ref||8&f.__u)&&(f.ref&&_e(f.ref,null,p,f),p.ref&&u.push(p.ref,p.__c||m,p)),h||=m,4&p.__u?(c=se(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 oe(e,t,n,r,i){var a,o,s,c,l,u,d,f,p,m=n.length,h=m,_=0,v=0,y=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=y[a]=T(null,o):b(o)?o=y[a]=T(D,{children:o}):o.constructor===g&&o.__b?o=y[a]=T(o.type,o.props,o.key,o.ref,o.__v):y[a]=o,c=a+_,o.__=e,o.__b=e.__b+1,s=null,~(l=o.__i=ce(o,n,c,h))&&(h--,(s=n[l])&&(s.__u|=2)),s&&s.__v?(o.__u|=16,l==c-1?_--:l==c+1?_++:l!=c&&(l>c?_--:_++,v=1)):(~l||(i>m?_--:i<m&&_++),typeof o.type!=`function`&&(o.__u|=4))):y[a]=null;if(v){for(u=[],d=[],a=0;a<i;a++)if((o=y[a])&&16&o.__u){for(_=0,f=u.length;_<f;)u[p=_+f>>1]<o.__i?_=p+1:f=p;u[_]=o.__i,d[a]=_+1}for(_=u.length;a--;)d[a]&&(d[a]==_?_--:y[a].__u|=4)}if(h)for(a=0;a<m;a++)!(s=n[a])||2&s.__u||(s.__e==r&&(r=te(s)),ve(s,s));return r}function se(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=se(i[a],t,n,!1));return t}for(t&&!t.parentNode&&(t=te(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 ce(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 le(e,t,n){n??=``,t[0]==`-`?e.setProperty(t,n):e[t]=n}function ue(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||le(e.style,t);if(n)for(t in n)r&&n[t]==r[t]||le(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)(e.__e||={})[t]=n,n&&r||(o=h[t]||(h[t]=de(t)),(e.__a||={})[t]=m,a=t!=(t=t.replace(p,`$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 de(e){return function(t){var n=this.__e;if(n){if(n=n[e],t[f]==null)t[f]=m++;else if(t[f]<this.__a[e])return;return n(a.event?a.event(t):t)}}}function fe(e,t,n,r,i,o,s,c,l,u){var d,f,p,m,h,_,y,x,w,T,E,ne,re,ie,oe,se,ce,le,ue=t.type;if(t.constructor!==g)return null;128&n.__u&&(l=32&n.__u,d=n.__c.__z)&&(t.__u|=l,f=o=[],d.nodeType==8?c=pe(d,o):o.push(d),c=o[0]||c),(d=a.__b)&&d(t);n:if(typeof ue==`function`){p=s.length;try{if(x=t.props,w=(d=ue.prototype)&&d.render,T=(d=ue.contextType)&&r[d.__c],E=d?T?T.props.value:d.__:r,(m=n.__c)?(t.__c=m,2&m.__g&&(m.__g|=1)):(w?t.__c=m=new ue(x,E):(t.__c=m=new ee(x,E),m.constructor=ue,m.render=ye),T&&T.sub(m),m.state||(m.state={}),m.__n=r,m.__g|=8,m.__h=[],m.__k=[]),w&&(m.__s||(m.__s=m.state),ue.getDerivedStateFromProps&&(m.__s==m.state&&(m.__s=S({},m.__s)),S(m.__s,ue.getDerivedStateFromProps(x,m.__s)))),h=m.props,_=m.state,m.__v=t,n.__c){if(x!==h&&w&&!ue.getDerivedStateFromProps&&m.componentWillReceiveProps&&m.componentWillReceiveProps(x,E),t.__v==n.__v&&!(8&m.__g)||!(4&m.__g)&&m.shouldComponentUpdate&&!1===m.shouldComponentUpdate(x,m.__s,E)){t.__v!=n.__v&&(m.props=x,m.state=m.__s,m.__g&=-9),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),v.push.apply(m.__h,m.__k),m.__k=[],m.__h.length&&s.push(m),c=te(n);break n}m.componentWillUpdate&&m.componentWillUpdate(x,m.__s,E),w&&m.componentDidUpdate&&m.__h.push(function(){m.componentDidUpdate(h,_,y)})}else w&&!ue.getDerivedStateFromProps&&m.componentWillMount&&m.componentWillMount(),w&&m.componentDidMount&&m.__h.push(m.componentDidMount);if(m.context=E,m.props=x,m.__P=e,m.__g&=-5,ne=a.__r,re=0,w)m.state=m.__s,m.__g&=-9,ne&&ne(t),d=m.render(m.props,m.state,m.context),v.push.apply(m.__h,m.__k),m.__k=[];else do m.__g&=-9,ne&&ne(t),d=m.render(m.props,m.state,m.context),m.state=m.__s;while(8&m.__g&&++re<25);m.state=m.__s,m.getChildContext&&(r=S({},r,m.getChildContext())),w&&n.__c&&m.getSnapshotBeforeUpdate&&(y=m.getSnapshotBeforeUpdate(h,_)),ie=d&&d.type===D&&d.key==null?d.props.children:d,x.__P&&(d=c,i=(e=x.__P).namespaceURI,l=o=null,n.props&&n.props.__P!=e&&(n.__k.some(function(e){e&&ve(e,e)}),n.__k=null),c=n.__k?te(n,0):null),c=ae(e,b(ie)?ie:[ie],t,n,r,i,o,s,c,l,u),x.__P&&(t.__e=null,c=d),t.__u&=-161,f&&f.some(C),m.__h.length&&s.push(m),1&m.__g&&(m.__g&=-4)}catch(e){if(s.length=p,t.__v=null,l||o){if(e.then){if(oe=0,t.__u|=128|l,o){for(~(ce=o.indexOf(c||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(;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;se=c}(d=pe(se=t.__c.__z||(t.__c.__z=se)))?(t.__e=se,c=d):t.__e=c,c&&=c.nextSibling}else o&&o.some(C)}else t.__e=n.__e;t.__k||=n.__k||[],e.then||me(t),a.__e(e,t,n)}}else c=t.__e=ge(n.__e,t,n,r,i,o,s,l,u,e);return(d=a.diffed)&&d(t),c}function pe(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 me(e){e&&(e.__c&&(e.__c.__g|=4),e.__k&&e.__k.some(me))}function he(e,t,n){for(var r=0;r<n.length;)_e(n[r++],n[r++],n[r++]);a.__c&&a.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){a.__e(e,t.__v)}})}function ge(e,t,n,r,i,o,s,c,l,u){var d,f,p,m,h,g,v,S,w,T=n.props||_,E=t.props,D=t.type;if(D==`svg`?i=`http://www.w3.org/2000/svg`:D==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,o){for(d=0;d<o.length;d++)if((h=o[d])&&(D?h.localName==D:h.nodeType==3)){e=h,o[d]=null;break}}if(!e){if(S=u.ownerDocument||document,!D)return S.createTextNode(E);e=S.createElementNS(i,D,E.is&&E),c&&=(a.__m&&a.__m(t,o),!1),o=null}if(D){if(u=D==`template`?e.content:e,o=D==`textarea`&&E.defaultValue!=null?null:o&&x.call(u.childNodes),!c&&o)for(T={},d=0;d<e.attributes.length;d++)T[(h=e.attributes[d]).name]=h.value;for(d in T)h=T[d],d==`dangerouslySetInnerHTML`?p=h:d==`children`||d in E||d==`value`&&`defaultValue`in E||d==`checked`&&`defaultChecked`in E||ue(e,d,null,h,i);for(d in w=1&n.__u,E)h=E[d],d==`children`?m=h:d==`dangerouslySetInnerHTML`?f=h:d==`value`?g=h:d==`checked`?v=h:c&&typeof h!=`function`||!(T[d]!==h||w&&h!=null)||ue(e,d,h,T[d],i);f?(c||p&&(f.__html==p.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[]):(p&&(e.textContent=``),(D==`foreignObject`||i==`http://www.w3.org/1998/Math/MathML`&&y.test(D))&&(i=`http://www.w3.org/1999/xhtml`),ae(u,b(m)?m:[m],t,n,r,i,o,s,o?o[0]:n.__k&&te(n,0),c,l),o&&o.some(C)),c&&D!=`textarea`||(d=`value`,D==`progress`&&g==null?e.removeAttribute(d):g==null||g===e[d]&&(D!=`progress`||g)||ue(e,d,g,T[d],i),d=`checked`,v!=null&&v!=e[d]&&ue(e,d,v,T[d],i))}else T===E||c&&e.data==E||(e.data=E);return e}function _e(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){a.__e(e,n)}}function ve(e,t,n){var r,i,o,s;if(a.unmount&&a.unmount(e),!(r=e.ref)||r.current&&r.current!=e.__e||_e(r,null,t,e),r=e.__c){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){a.__e(e,t)}r.__P=r.__n=null}if(r=e.__k)for(s=0;s<r.length;s++)r[s]&&ve(r[s],t,typeof e.type!=`function`||n&&!e.props.__P);!n&&(r=e.__c)&&(r=r.__z)&&(i=pe(r,o=[]))&&(r==e.__e&&o.some(C),C(i),C(r)),(r=e.__e)&&(n||C(r),r.__e&&(r.__e=null)),e.__e=e.__c=e.__=null}function ye(e,t,n){return this.constructor(e,n)}function be(e,t){var n,r,i,o;a.__&&a.__(e,t),t.nodeType==9&&(t=t.documentElement),r=(n=e&&32&e.__u)?null:t.__k,t.__k=T(D,{children:[e]}),i=[],o=[],fe(t,t.__k,r||_,_,t.namespaceURI,r?null:t.firstChild?x.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,o),he(i,t.__k,o),t.__k.props.children=null}a={__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 u=0,e}},o=0,s=function(e){return e!=null&&e.constructor===g},ee.prototype.setState=function(e,t){var n=this.__s;n&&n!=this.state||(n=this.__s=S({},this.state)),typeof e==`function`&&(e=e(S({},n),this.props)),e&&(S(n,e),this.__v&&(t&&this.__k.push(t),re(this)))},ee.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),re(this))},ee.prototype.render=D,c=[],u=0,d=function(e,t){return e.__v.__b-t.__v.__b},f=Symbol(),p=/(PointerCapture)$|Capture$/i,m=0,h={};var xe,O,Se,Ce,we=Object.is,Te=0,Ee=[],De=[],k=a,Oe=k.__b,ke=k.__r,Ae=k.diffed,je=k.__c,Me=k.unmount,Ne=k.__;function Pe(e,t){k.__h&&k.__h(O,e,Te||t),Te=0;var n=O.__H||(O.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Fe(e){return Te=1,Ie(Ke,e)}function Ie(e,t,n){var r=Pe(xe++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Ke(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);we(t,n)||(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=O,!O.__f)){O.__f=!0;var i=O.shouldComponentUpdate;O.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,we(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 Le(e,t){var n=Pe(xe++,4);!k.__s&&Ge(n.__H,t)&&(n.__P=!1,n.__=e,n.u=t,O.__h.push(n))}function Re(e,t){var n=Pe(xe++,7);return Ge(n.__H,t)&&(n.__=e(),n.__H=t),n.__}function ze(){var e;do{for(;e=De.shift();)try{Ue(e)}catch(t){k.__e(t,{__:(e=e.__P)&&e.__v})}for(;e=Ee.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Ue),t.__h.some(We),t.__h=[]}catch(n){t.__h=[],k.__e(n,e.__v)}}}while(De.length)}k.__b=function(e){O=null,Oe&&Oe(e)},k.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Ne&&Ne(e,t)},k.__r=function(e){ke&&ke(e),xe=0;var t=(O=e.__c).__H;t&&(Se==O?O.__h=[]:(t.__h.some(Ue),t.__h.some(We),xe=0),t.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})),Se=O},k.diffed=function(e){Ae&&Ae(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&He(Ee.push(t)),t.__H.__.some(function(e){e.u&&(e.__H=e.u)})),Se=O=null},k.__c=function(e,t){t.some(function(e){try{e.__h.some(Ue),e.__h=e.__h.filter(function(e){return!e.__||We(e)})}catch(t){e.__h=[function(){throw t}]}}),je&&je(e,t)},k.unmount=function(e){Me&&Me(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,He(De.push(r))}else Ue(r)}catch(e){t=e}}),r.__H=void 0,t&&k.__e(t,r.__v))};var Be=typeof requestAnimationFrame==`function`;function Ve(e){var t,n=function(){clearTimeout(r),Be&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Be&&(t=requestAnimationFrame(n))}function He(e){e!=1&&Ce==k.requestAnimationFrame||((Ce=k.requestAnimationFrame)||Ve)(ze)}function Ue(e){var t=O,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),O=t}function We(e){var t=O;e.__c=e.__(),O=t}function Ge(e,t){return!e||e.length!=t.length||t.some(function(t,n){return!we(t,e[n])})}function Ke(e,t){return typeof t==`function`?t(e):t}var qe=Symbol.for(`preact-signals`);function Je(){if($e>1)$e--;else{var e,t=!1;for((function(){var e=rt;for(rt=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}})();Qe!==void 0;){var n=Qe;for(Qe=void 0,et++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&st(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(et=0,$e--,t)throw e}}function Ye(e){if($e>0)return e();nt=++tt,$e++;try{return e()}finally{Je()}}var Xe,A=void 0;function Ze(e){var t=A,n=Xe;A=void 0,Xe=void 0;try{return e()}finally{A=t,Xe=n}}var Qe=void 0,$e=0,et=0,tt=0,nt=0,rt=void 0,it=0;function at(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 j(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}j.prototype.brand=qe,j.prototype.h=function(){return!0},j.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?Ze(function(){var e;(e=t.W)==null||e.call(t)}):n.e=e)},j.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&&Ze(function(){var e;(e=t.Z)==null||e.call(t)}))}},j.prototype.subscribe=function(e){var t=this;return gt(function(){var n=t.value;Ze(function(){return e(n)})},{name:`sub`})},j.prototype.valueOf=function(){return this.value},j.prototype.toString=function(){return this.value+``},j.prototype.toJSON=function(){return this.value},j.prototype.peek=function(){var e=this;return Ze(function(){return e.value})},Object.defineProperty(j.prototype,"value",{get:function(){var e=at(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(et>100)throw Error(`Cycle detected`);(function(e){$e!==0&&et===0&&e.l!==nt&&(e.l=nt,rt={S:e,v:e.v,i:e.i,o:rt})})(this),this.v=e,this.i++,it++,$e++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Je()}}}});function ot(e,t){return new j(e,t)}function st(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 ct(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 lt(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 ut(e,t){j.call(this,void 0,t),this.x=e,this.s=void 0,this.g=it-1,this.f=4}ut.prototype=new j,ut.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===it))return!0;if(this.g=it,this.f|=1,this.i>0&&!st(this))return this.f&=-2,!0;var e=A;try{ct(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,lt(this),this.f&=-2,!0},ut.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)}j.prototype.S.call(this,e)},ut.prototype.U=function(e){if(this.t!==void 0&&(j.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)}},ut.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(ut.prototype,"value",{get:function(){if(1&this.f)throw Error(`Cycle detected`);var e=at(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function dt(e,t){return new ut(e,t)}function ft(e){var t=e.j;if(e.j=void 0,typeof t==`function`){$e++;var n=A;A=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,pt(e),t}finally{A=n,Je()}}}function pt(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,ft(e)}function mt(e){if(A!==this)throw Error(`Out-of-order effect`);lt(this),A=e,this.f&=-2;try{8&this.f&&pt(this)}finally{Je()}}function ht(e,t){this.x=e,this.j=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Xe&&Xe.push(this)}ht.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()}},ht.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,ft(this),ct(this),$e++;var e=A;return A=this,mt.bind(this,e)},ht.prototype.N=function(){2&this.f||(this.f|=2,this.u=Qe,Qe=this)},ht.prototype.d=function(){this.f|=8,1&this.f||pt(this)},ht.prototype.dispose=function(){this.d()};function gt(e,t){var n=new ht(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var _t,vt,yt=typeof window<`u`&&!!window.__PREACT_SIGNALS_DEVTOOLS__,bt=[];gt(function(){_t=this.N})();function xt(e,t){a[e]=t.bind(null,a[e]||function(){})}function St(e){if(vt){var t=vt;vt=void 0,t()}vt=e&&e.S()}function Ct(e){var t=this,n=e.data,r=Tt(n);r.name=`ReactiveDom`,r.value=n;var i=Re(function(){for(var e=t,n=t.__v;n=n.__;)if(n.__c){n.__c.__$f|=4;break}var i=dt(function(){var e=r.value.value;return e===0?0:!0===e?``:e||``}),a=dt(function(){return!Array.isArray(i.value)&&!s(i.value)}),o=gt(function(){if(this.N=Ot,a.value){var t=i.value;e.__v&&e.__v.__e&&e.__v.__e.nodeType===3&&(e.__v.__e.data=t)}}),c=t.__$u.d;return t.__$u.d=function(){o(),c.call(this)},[a,i]},[]),a=i[0],o=i[1];return a.value?o.peek():o.value}Ct.displayName=`ReactiveTextNode`,Object.defineProperties(j.prototype,{constructor:{configurable:!0,value:w(D,null).constructor},type:{configurable:!0,value:Ct},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}}),xt(`__b`,function(e,t){if(St(),typeof t.type==`string`){var n,r=t.props;for(var i in r)if(i!==`children`){var a=r[i];a instanceof j&&(n||(t.__np=n={}),n[i]=a,r[i]=a.peek())}}e(t)}),xt(`__r`,function(e,t){if(e(t),t.type!==D){St();var n,r=t.__c;r&&(r.__$f&=-2,(n=r.__$u)===void 0&&(r.__$u=n=function(e,t){var n;return gt(function(){n=this},{name:t}),n.c=e,n}(function(e){return function(){var t;yt&&((t=this.y)==null||t.call(this)),e.__$f|=1,e.setState({})}}(r),typeof t.type==`function`?t.type.displayName||t.type.name:``))),St(n)}}),xt(`__e`,function(e,t,n,r){St(),e(t,n,r)}),xt(`diffed`,function(e,t){St();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=wt(n,c,u,i),a[c]=l):l.o(u,i)}}e(t)});function wt(e,t,n,r){var i=t in e&&e.ownerSVGElement===void 0,a=ot(n);return{o:function(e,t){a.value=e,r=t},d:gt(function(){this.N=Ot;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))})}}xt(`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)}),xt(`__h`,function(e,t,n,r){r<3&&(t.__$f|=2),e(t,n,r)}),ee.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};function Tt(e,t){return Re(function(){return ot(e,t)},[])}var Et=function(e){queueMicrotask(function(){queueMicrotask(e)})};function Dt(){Ye(function(){for(var e;e=bt.shift();)_t.call(e)})}function Ot(){bt.push(this)===1&&(a.requestAnimationFrame||Et)(Dt)}var M={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`,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`},kt=new Set(Object.values(M)),At=e=>typeof e==`string`&&kt.has(e),jt=({error:e,fallback:t=M.INVALID_SERVICE_RESPONSE})=>typeof e==`object`&&e&&`code`in e&&At(e.code)?e.code:e instanceof Error&&At(e.message)?e.message:At(e)?e:t,Mt=[`ar`,`ch`,`de`,`en`,`es`,`fr`,`it`,`ja`,`pt`,`zh`],Nt=new Map,Pt=new Map,Ft=async({language:e})=>{if(Nt.has(e))return;let t=Pt.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()}),Pt.set(e,t));try{Nt.set(e,await t)}finally{Pt.delete(e)}},It=async({language:e})=>{let t=e??Lt();await Promise.all([Ft({language:t}),...t===`en`?[]:[Ft({language:`en`})]])},Lt=()=>{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(Mt.includes(n))return n}return`en`},Rt={[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.CLIENT_KEY_REQUIRED]:`clientKeyRequired`,[M.VERIFICATION_SAVE_FAILED]:`verificationSaveFailed`},zt=({language:e})=>{let t=e??Lt(),n=e=>{let n=Nt.get(t),r=Nt.get(`en`);return n?.[e]??r?.[e]??e};return{translate:n,translateError:({error:e})=>{let t=Rt[jt({error:e})]??`verificationFailed`;return n(t)}}},Bt=new WeakMap,Vt=async({video:e,signal:t})=>{t?.throwIfAborted();let n=Promise.withResolvers(),r=e,i=Bt.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||Bt.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),Bt.set(e,i),t?.addEventListener(`abort`,u,{once:!0}),r.requestVideoFrameCallback?a=r.requestVideoFrameCallback(()=>c()):o=requestAnimationFrame(()=>c()),await n.promise},Ht=()=>{let e=/Android|iPhone|iPad|iPod|Mobile/i.test(navigator.userAgent),t=navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1;return e||t},Ut=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}},Wt=({video:e})=>{for(let t of Bt.get(e)??[])t();let t=e.srcObject;if(t instanceof MediaStream)for(let e of t.getTracks())e.stop();e.srcObject=null},Gt=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}};Ht()||(r.width={ideal:1280},r.height={ideal:720});let i=()=>Wt({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(Wt({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)}},Kt=({element:e})=>{let t=e.getContext(`2d`);if(!t)throw Error(M.IMAGE_PROCESSING_FAILED);t.clearRect(0,0,e.width,e.height)},qt=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})}},Jt=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 qt({canvas:t})},Yt=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 qt({canvas:n,quality:.85})}finally{t.close()}},Xt=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})},Zt=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 Qt(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 $t(e,t=`|`){return e.map(e=>Tn(e)).join(t)}function en(e,t){return typeof t==`bigint`?t.toString():t}var tn=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}};function nn(e){return new tn(e)}function rn(e){return e==null}function an(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function on(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 sn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function cn(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function ln(e){return cn(e._zod.def)??e._zod.def.shape}function un(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return sn(this,t,e),e},enumerable:!0,configurable:!0})}function dn(e,t,n){t in e?sn(e,t,n):e[t]=n}function fn(e,t,n,r){let i=ln(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?un(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):dn(e,a,r?r(n.value,a):n.value))}}function pn(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?un(e,n,()=>t[n]):dn(e,n,r.value))}}function mn(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function hn(e){return JSON.stringify(e)}function gn(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var _n=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function vn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var yn=nn(()=>{if(mr.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function bn(e){if(vn(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return vn(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function xn(e){return bn(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Sn=new Set([`string`,`number`,`symbol`]);function Cn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function wn(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 Tn(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function En(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var Dn={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},On={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function kn(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 fn(i,e,An(e,t)),wn(e,mn(n,{shape:i,checks:[]}))}function An(e,t){let n=ln(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 jn(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(An(e,t)),a={};return fn(a,e,Reflect.ownKeys(ln(e)).filter(e=>!i.has(e))),wn(e,mn(n,{shape:a,checks:[]}))}function Mn(e,t){if(!bn(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=ln(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 wn(e,mn(e._zod.def,{shape:Nn(e,t)}))}function Nn(e,t){let n={};return fn(n,e,Reflect.ownKeys(ln(e))),pn(n,t),n}function Pn(e,t){if(!bn(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return wn(e,mn(e._zod.def,{shape:Nn(e,t)}))}function Fn(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 fn(n,e,Reflect.ownKeys(ln(e))),fn(n,t,Reflect.ownKeys(ln(t))),wn(e,mn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function In(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(An(t,n)):void 0,o={};return fn(o,t,Reflect.ownKeys(ln(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),wn(t,mn(t._zod.def,{shape:o,checks:[]}))}function Ln(e,t,n){let r=n?new Set(An(t,n)):void 0,i={};return fn(i,t,Reflect.ownKeys(ln(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),wn(t,mn(t._zod.def,{shape:i}))}function Rn(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 zn(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 Bn(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Vn(e){return typeof e==`string`?e:e?.message}function Hn(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 Un(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Wn(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:Vn(e.inst?._zod.def?.error?.(e))??Vn(a?.(e))??Vn(t?.error?.(e))??Vn(n.customError?.(e))??Vn(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}var Gn=/[\uD800-\uDBFF]/;function Kn(e){let t=e.length;if(!Gn.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 qn(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Jn(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 Yn(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Xn(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):er(e,n,r.value)}}function Zn(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Qn(e,t,n){return Zn(e,t,n,!1)}function $n(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Zn(this,n,r(this))},set(e){Zn(this,n,e)}})}return t}function er(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Zn(this,t,n.bind(this))},set(e){Zn(this,t,e)}})}function tr(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var nr,rr=!1,ir={configurable:!0,get(){rr=!0}};function P(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&nr!==e._zod?nr=void 0:(nr=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,ir);let e=rr;rr=!1;try{let r=n(this);return rr?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),rr||=e,r}catch(n){throw delete this[t],rr||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function ar(e,t,n,r){let i=tr(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})}})}var or=`~constantCatch`;function sr(e){let t=()=>e;return t[or]=!0,t}var cr,lr={value:void 0,enumerable:!1},ur=`captureStackTrace`in Error?Error:null;function dr(e){let t=ur;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return ur=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){lr.value=new a(r);try{Object.defineProperty(n,"_zod",lr)}finally{lr.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),Xn(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?dr(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}var fr=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},pr=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(cr=globalThis).__zod_globalConfig??(cr.__zod_globalConfig={});var mr=globalThis.__zod_globalConfig;function hr(e){return e&&Object.assign(mr,e),mr}function gr(){let e=this._zod;return e.message??=JSON.stringify(e.def,en,2),e.message}function _r(e){this._zod.message=e}var vr={get:gr,set:_r,enumerable:!0,configurable:!0},yr={value:void 0,enumerable:!1},br=new WeakSet([Object.prototype,Error.prototype]),xr=F(`$ZodError`,(e,t)=>{e.name=`$ZodError`,yr.value=t,Object.defineProperty(e,"issues",yr),yr.value=void 0,Object.defineProperty(e,"message",vr);let n=Object.getPrototypeOf(e);br.has(n)||(br.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})}}))});function Sr(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 Cr(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?Sr(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function wr(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}function Tr(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Er=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 fr;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>Wn(e,o,hr())));throw _n(n,a?.callee??t),n}return s.value};return t},Dr=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=>Wn(e,o,hr())));throw _n(n,a?.callee??t),n}return s.value};return t},Or=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 fr;return a.issues.length?kr(e,a.issues,i):{success:!0,data:a.value}};function kr(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>Wn(e,n,hr()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var Ar=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?kr(e,a.issues,i):{success:!0,data:a.value}},jr=Symbol.for(`zod.compile.invalid`),Mr=Symbol.for(`zod.compile.fallback`),Nr=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==jr)return!0;if(r.definite===!0&&n===void 0)return!1}return Pr(e,t,n)});function Pr(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[Mr]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new fr;return a.issues.length===0}var Fr=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},Ir=e=>{let t=Er(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,Tr(n,a))};return n},Lr=e=>{let t=Er(e),n=(e,r,i,a)=>t(e,r,i,Tr(n,a));return n},Rr=e=>{let t=Dr(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,Tr(n,a))};return n},zr=e=>{let t=Dr(e),n=async(e,r,i,a)=>await t(e,r,i,Tr(n,a));return n},Br=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Or(e)(t,n,i)},Vr=e=>(t,n,r)=>Or(e)(t,n,r),Hr=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ar(e)(t,n,i)},Ur=e=>async(t,n,r)=>Ar(e)(t,n,r),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}$/;function Xr(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Zr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Qr=/^([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})$/,$r=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)$/,ei=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,ti=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function ni(){return new RegExp(ti,`u`)}var 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])$/,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}|:))$/,ai=/^((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])$/,oi=/^(([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])$/,si=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ci=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,li=/^https?$/,ui=/^\+[1-9]\d{6,14}$/,di=`(?:(?:\\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])))`;function fi(e){return RegExp(`^${e}$`)}var pi=fi(di);function mi(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 hi(e){return RegExp(`^${mi(e)}$`)}function gi(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${mi({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${mi({precision:e.precision})}`:n;return RegExp(`^${di}T(?:${r})$`)}var _i=/^[\s\S]{0,}$/,vi=/^-?\d+$/,yi=/^-?\d+(?:\.\d+)?$/,bi=/^(?:true|false)$/i,xi=/^[^A-Z]*$/,Si=/^[^a-z]*$/,Ci=F(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),wi=e=>{let t=e.value;return!rn(t)&&t.length!==void 0},Ti={number:`number`,bigint:`bigint`,object:`date`},Ei=F(`$ZodCheckLessThan`,(e,t)=>{Ci.init(e,t);let n=Ti[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:Ti[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})}}),Di=F(`$ZodCheckGreaterThan`,(e,t)=>{Ci.init(e,t);let n=Ti[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Ti[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})}}),Oi=F(`$ZodCheckMultipleOf`,(e,t)=>{Ci.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):on(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})}}),ki=F(`$ZodCheckNumberFormat`,(e,t)=>{Ci.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Dn[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})}}),Ai=F(`$ZodCheckMaxLength`,(e,t)=>{var n;Ci.init(e,t),(n=e._zod.def).when??(n.when=wi),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?Kn(r):i)<=t.maximum)return;let a=qn(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ji=F(`$ZodCheckMinLength`,(e,t)=>{var n;Ci.init(e,t),(n=e._zod.def).when??(n.when=wi),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?Kn(r):i)>=t.minimum)return;let a=qn(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Mi=F(`$ZodCheckLengthEquals`,(e,t)=>{var n;Ci.init(e,t),(n=e._zod.def).when??(n.when=wi),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?Kn(r):i;if(a===t.length)return;let o=qn(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})}}),Ni=F(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Ci.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=()=>{})}),Pi=F(`$ZodCheckRegex`,(e,t)=>{Ni.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})}}),Fi=F(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=xi,Ni.init(e,t)}),Ii=F(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Si,Ni.init(e,t)}),Li=F(`$ZodCheckIncludes`,(e,t)=>{Ci.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})}}),Ri=F(`$ZodCheckStartsWith`,(e,t)=>{Ci.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})}}),zi=F(`$ZodCheckEndsWith`,(e,t)=>{Ci.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})}}),Bi=F(`$ZodCheckOverwrite`,(e,t)=>{Ci.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Vi=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
- `).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))}},Hi={major:4,minor:6,patch:7},I=F(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Hi;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=Rn(t),a;for(let o of n){if(o._zod.def.when){if(zn(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 fr;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(Un(t.issues,n,e),i||=Rn(t,n))});else{if(t.issues.length===n)continue;Un(t.issues,n,e),i||=Rn(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(Rn(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new fr;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 fr;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return Qn(this,`~standard`,Gi(this))},set"~standard"(e){Zn(this,`~standard`,e)}}),Ui=(e,t)=>e.issues.length?{issues:e.issues.map(e=>Wn(e,t,hr()))}:{value:e.value};async function Wi(e,t){let n={async:!0};return Ui(await e._zod.run({value:t,issues:[]},n),n)}function Gi(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Ui(r,n)}catch{}return Wi(e,t)},vendor:`zod`,version:1}}var Ki=F(`$ZodString`,(e,t)=>{I.init(e,t),e._zod.pattern=t.pattern??_i,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)=>{Ni.init(e,t),Ki.init(e,t)}),qi=F(`$ZodGUID`,(e,t)=>{t.pattern??=Qr,L.init(e,t)}),Ji=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??=$r(e)}else t.pattern??=$r();L.init(e,t)}),Yi=F(`$ZodEmail`,(e,t)=>{t.pattern??=ei,L.init(e,t)});function Xi(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Zi(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?Xi(e)||2:Qi(e,t)}function Qi(e,t){if(!t.normalize&&t.protocol?.source===li.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}}var $i=/[\t\n\r]/g;function ea(e){return e.replace($i,``)}function ta(e,t){return t.lastIndex=0,t.test(e.hostname)}function na(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var ra=F(`$ZodURL`,(e,t)=>{L.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=Zi(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=ea(r);return}t.hostname&&!ta(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&&!na(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:ea(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),ia=F(`$ZodEmoji`,(e,t)=>{t.pattern??=ni(),L.init(e,t)}),aa=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:Xr(t.length),L.init(e,t)}),oa=F(`$ZodCUID`,(e,t)=>{t.pattern??=Wr,L.init(e,t)}),sa=F(`$ZodCUID2`,(e,t)=>{t.pattern??=Gr,L.init(e,t)}),ca=F(`$ZodULID`,(e,t)=>{t.pattern??=Kr,L.init(e,t)}),la=F(`$ZodXID`,(e,t)=>{t.pattern??=qr,L.init(e,t)}),ua=F(`$ZodKSUID`,(e,t)=>{t.pattern??=Jr,L.init(e,t)}),da=F(`$ZodISODateTime`,(e,t)=>{t.pattern??=gi(t),L.init(e,t)}),fa=F(`$ZodISODate`,(e,t)=>{t.pattern??=pi,L.init(e,t)}),pa=F(`$ZodISOTime`,(e,t)=>{t.pattern??=hi(t),L.init(e,t)}),ma=F(`$ZodISODuration`,(e,t)=>{t.pattern??=Zr,L.init(e,t)}),ha=F(`$ZodIPv4`,(e,t)=>{t.pattern??=ri,L.init(e,t)}),ga=/^[0-9a-fA-F:.]+$/;function _a(e){return ga.test(e)?Xi(`http://[${e}]`):!1}var va=F(`$ZodIPv6`,(e,t)=>{t.pattern??=ii,L.init(e,t),e._zod.check=n=>{_a(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),ya=F(`$ZodCIDRv4`,(e,t)=>{t.pattern??=ai,L.init(e,t)});function ba(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:_a(n)}var xa=F(`$ZodCIDRv6`,(e,t)=>{t.pattern??=oi,L.init(e,t),e._zod.check=n=>{ba(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function Sa(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Ca=/^[0-9a-zA-Z+/]*={0,2}$/,wa=F(`$ZodBase64`,(e,t)=>{t.pattern??=Ca,L.init(e,t),e._zod.check=n=>{Sa(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),Ta=/^[A-Za-z0-9_-]*$/;function Ea(e){if(!Ta.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Sa(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var Da=F(`$ZodBase64URL`,(e,t)=>{t.pattern??=Ta,L.init(e,t),e._zod.check=n=>{Ea(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Oa=F(`$ZodE164`,(e,t)=>{t.pattern??=ui,L.init(e,t)});function ka(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}}var Aa=F(`$ZodJWT`,(e,t)=>{L.init(e,t),e._zod.check=n=>{ka(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),ja=F(`$ZodNumber`,(e,t)=>{I.init(e,t),e._zod.pattern=yi,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}}),Ma=F(`$ZodNumberFormat`,(e,t)=>{ki.init(e,t),ja.init(e,t)}),Na=F(`$ZodBoolean`,(e,t)=>{I.init(e,t),e._zod.pattern=bi,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}}),Pa=F(`$ZodUnknown`,(e,t)=>{I.init(e,t),e._zod.parse=e=>e}),Fa=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)});function Ia(e,t){let n=Hn(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 Hn(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,Un(n.issues,t,e),n}}return i(n,a)}}var La=e=>Array.isArray(e)?e.length:-1;function Ra(e,t,n){e.issues.length&&t.issues.push(...Bn(n,e.issues)),t.value[n]=e.value}var za=F(`$ZodArray`,(e,t)=>{I.init(e,t);let n=mr.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=>Ra(t,r,e)));else if(Ra(c,r,e),s&&c.issues.length!==0&&Rn(c))break}return o.length?Promise.all(o).then(()=>r):r},Ia(e,La)});function Ba(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(...Bn(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}}var Va=[];function Ha(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Va,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=En(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Ua(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(Rn(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=>Ba(e,n,i,t,d,f))):Ba(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}var Wa=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=nn(()=>Ha(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)||sn(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=vn,o=t.catchall,s,c=mr.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(Rn(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=>Ba(n,t,e,r,a,o))):Ba(s,t,e,r,a,o)}return o?Ua(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),Ga=F(`$ZodObjectJIT`,(e,t)=>{Wa.init(e,t);let n=e._zod.parse,r=nn(()=>Ha(t)),i=mr.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new Vi([`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
- let ${e}_ab = false;
6
- for (let i = 0; i < ${e}.issues.length; i++) {
7
- const iss = ${e}.issues[i];
8
- iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
9
- payload.issues.push(iss);
10
- if (iss.continue !== true) ${e}_ab = true;
11
- }
12
- if (${e}_ab && ctx && ctx.abortEarly) {
13
- payload.value = newResult;
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)}]`:hn(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
- const ${n}_present = ${i};
17
- if (!${n}.issues.length || ${n}_present) {
18
- if (${n}.issues.length) {${c(n,r)}
19
- }
20
-
21
- if (${e}) {
22
- newResult[${r}] = ${n}.value;
23
- }
24
- }
25
-
26
- `)}else f?(o.write(`
27
- if (${n}.issues.length) {${c(n,r)}
28
- }
29
- `),d===`defaulted`?o.write(`newResult[${r}] = ${n}.value;`):o.write(`
30
- if (${n}.value !== undefined || ${i}) {
31
- newResult[${r}] = ${n}.value;
32
- }
33
- `)):o.write(`
34
- const ${n}_present = ${i};
35
- if (${n}.issues.length) {${c(n,r)}
36
- }
37
- if (!${n}_present && !${n}.issues.length) {
38
- payload.issues.push({
39
- code: "invalid_type",
40
- expected: "nonoptional",
41
- input: undefined,
42
- path: [${r}]
43
- });
44
- if (ctx && ctx.abortEarly) {
45
- payload.value = newResult;
46
- return payload;
47
- }
48
- }
49
-
50
- if (${n}_present) {
51
- newResult[${r}] = ${n}.value;
52
- }
53
-
54
- `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=vn,c=!mr.jitless,l=c&&yn.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?Ua([],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)}});function Ka(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=>!Rn(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=>Wn(e,r,hr())))}),t)}var qa=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=>an(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=>Ka(t,r,e,i)):Ka(o,r,e,i)}}),Ja=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])=>Xa(e,t,n)):Xa(e,i,a)}});function Ya(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(bn(e)&&bn(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=Ya(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=Ya(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 Xa(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=Ya(t.value,n.value);if(!c.valid){if(Rn(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Za=F(`$ZodRecord`,(e,t)=>{I.init(e,t);let n=mr.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!bn(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=>Wn(e,i,hr())),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(...Bn(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...Bn(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`&&yi.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=>Wn(e,i,hr())),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(...Bn(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...Bn(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}}),Qa=F(`$ZodEnum`,(e,t)=>{I.init(e,t);let n=Qt(t.entries),r=new Set(n);e._zod.values=r,P(e,`pattern`,e=>{let t=Qt(e.def.entries).filter(e=>Sn.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}}),$a=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}}),eo=F(`$ZodTransform`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,mr.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new pr(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 fr;return n.value=i,n}});function to(e,t){return e.value=t.issues.length?void 0:t.value,e}var no=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(`^(${an(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=>to(e,t)):to(e,r)}return t.innerType._zod.run(e,n)}}),ro=F(`$ZodExactOptional`,(e,t)=>{no.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)}),io=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(`^(${an(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)}),ao=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=>oo(e,t)):oo(r,t)}});function oo(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var so=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))}),co=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=>lo(t,e)):lo(i,e)}});function lo(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 uo(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>Wn(e,r,hr()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var fo=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=>uo(e,r,t,n)):uo(e,r,t,n)}}),po=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=>mo(e,t.in,n)):mo(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>mo(e,t.out,n)):mo(r,t.out,n)}});function mo(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)}var ho=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(go):go(r)}});function go(e){return e.memo||(e.value=Object.freeze(e.value)),e}var _o=F(`$ZodCustom`,(e,t)=>{Ci.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=>vo(t,n,r,e));vo(i,n,r,e)}});function vo(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(Yn(e))}}var yo=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},bo=`~memo`,xo=[];function So(e){return typeof e==`object`&&!!e}function Co(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var wo=new WeakMap,To=0,Eo=1,Do=2;function Oo(e,t,n){let r=wo.get(e);if(r!==void 0)return r?Do:To;if(t.has(e))return Do;t.add(e);let i=To,a=e=>{if(i!==Do&&e?._zod){let r=Oo(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=To;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?Eo:o.value?._zod?Oo(o.value,t,n):To;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=cn(c);s(e?o(e,!0):Eo),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?Oo(r,t,!1):Eo);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),ko(e,i)}function ko(e,t){return t!==Eo&&wo.set(e,t===Do),t}function Ao(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var jo,Mo=[],No={alloc(e,t,n){let r=jo;if(!r)return n;jo=void 0;let i={value:n,issues:null};return r.set(t.value,i),Mo.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`&&Fo(n,e.value))throw new yo;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=Oo(e,new Set,!1);if(i===To)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===Do||r?n=!0:r=!0}let l=s.value;if(!So(l))return t(s,c);let u=c[bo];u||(u={buckets:new WeakMap,backEdges:void 0},c[bo]=u);let d;i===c?d=a:(d=Ao(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(...Co(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;jo=d;let p=Mo.length,m=t(s,c);jo=void 0;let h=Mo.length>p?Mo.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?Co(e.issues):xo),e)):(h&&(h.issues=m.issues.length?Co(m.issues):xo),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function Po(){return No}function Fo(e,t){let n=e[bo]?.backEdges;return n!==void 0&&So(t)&&n.has(t)}var Io=()=>{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(Jn(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${Tn(e.values[0])}`:`Invalid option: expected one of ${$t(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`:``}: ${$t(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 Lo(){return{localeError:Io()}}var Ro,zo=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)}};function Bo(){return new zo}(Ro=globalThis).__zod_globalRegistry??(Ro.__zod_globalRegistry=Bo());var Vo=globalThis.__zod_globalRegistry;function Ho(e){return e.checks&&=[...e.checks],e}function Uo(e,t){return new e(Ho({type:`string`,...N(t)}))}function Wo(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...N(t)})}function Go(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...N(t)})}function Ko(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...N(t)})}function qo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...N(t)})}function Jo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...N(t)})}function Yo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...N(t)})}function Xo(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...N(t)})}function Zo(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...N(t)})}function Qo(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...N(t)})}function $o(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...N(t)})}function es(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...N(t)})}function ts(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...N(t)})}function ns(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...N(t)})}function rs(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...N(t)})}function is(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...N(t)})}function as(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 ss(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...N(t)})}function cs(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...N(t)})}function ls(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...N(t)})}function us(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...N(t)})}function ds(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...N(t)})}function fs(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...N(t)})}function ps(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...N(t)})}function ms(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...N(t)})}function hs(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...N(t)})}function gs(e,t){return new e(Ho({type:`number`,checks:[],...N(t)}))}function _s(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...N(t)})}function vs(e,t){return new e({type:`boolean`,...N(t)})}function ys(e){return new e({type:`unknown`})}function bs(e,t){return new e({type:`never`,...N(t)})}function xs(e,t){return new Ei({check:`less_than`,...N(t),value:e,inclusive:!1})}function Ss(e,t){return new Ei({check:`less_than`,...N(t),value:e,inclusive:!0})}function Cs(e,t){return new Di({check:`greater_than`,...N(t),value:e,inclusive:!1})}function ws(e,t){return new Di({check:`greater_than`,...N(t),value:e,inclusive:!0})}function Ts(e,t){return new Oi({check:`multiple_of`,...N(t),value:e})}function Es(e,t){return new Ai({check:`max_length`,...N(t),maximum:e})}function Ds(e,t){return new ji({check:`min_length`,...N(t),minimum:e})}function Os(e,t){return new Mi({check:`length_equals`,...N(t),length:e})}function ks(e,t){return new Pi({check:`string_format`,format:`regex`,...N(t),pattern:e})}function As(e){return new Fi({check:`string_format`,format:`lowercase`,...N(e)})}function js(e){return new Ii({check:`string_format`,format:`uppercase`,...N(e)})}function Ms(e,t){return new Li({check:`string_format`,format:`includes`,...N(t),includes:e})}function Ns(e,t){return new Ri({check:`string_format`,format:`starts_with`,...N(t),prefix:e})}function Ps(e,t){return new zi({check:`string_format`,format:`ends_with`,...N(t),suffix:e})}function Fs(e){return new Bi({check:`overwrite`,tx:e})}function Is(e){return Fs(t=>t.normalize(e))}function Ls(){return Fs(e=>e.trim())}function Rs(){return Fs(e=>e.toLowerCase())}function zs(){return Fs(e=>e.toUpperCase())}function Bs(){return Fs(e=>gn(e))}function Vs(e,t,n){return new e({type:`array`,element:t,...N(n)})}function Hs(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...N(n)})}function Us(e,t){let n=Ws(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Yn(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(Yn(r))}},e(t.value,t)),t);return n}function Ws(e,t){let n=new Ci({check:`custom`,...N(t)});return n._zod.check=e,n}function Gs(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&sn(e,t,n[t]);return e}function Ks(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??Vo,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&&Gs(o.schema,c),t.io===`input`&&z(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 Js(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Ys(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}/${Js(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+Js(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
-
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 Xs(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;Xs(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}var Zs=new Set([`type`,`properties`,`required`,`additionalProperties`]),Qs=[`oneOf`,`anyOf`];function $s(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function ec(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Zs.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]??$s(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}sn(n,r,e.length===1?e[0]:ec(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=$s(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 tc(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Zs)if(t in e)return;let n=t.filter(e=>Qs.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=ec(t);else{let e=n[0],i=Qs.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=>ec([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Gs(e,r))}function nc(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)):Gs(i,s),Gs(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())Xs(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)??[])tc(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)}Gs(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,sn(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:ic(t,`input`,e.processors),output:ic(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function z(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 z(r.element,n);if(r.type===`set`)return z(r.valueType,n);if(r.type===`lazy`)return z(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 z(r.innerType,n);if(r.type===`intersection`)return z(r.left,n)||z(r.right,n);if(r.type===`record`||r.type===`map`)return z(r.keyType,n)||z(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:z(r.in,n)||z(r.out,n);if(r.type===`object`){for(let e in r.shape)if(z(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(z(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(z(e,n))return!0;return!!(r.rest&&z(r.rest,n))}return!1}var rc=(e,t={})=>n=>{let r=Ks({...n,processors:t});return R(e,r),Ys(r,e),nc(r,e)},ic=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Ks({...i??{},target:a,io:t,processors:n});return R(e,o),Ys(o,e),nc(o,e)},ac=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},oc=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},sc=(e,t)=>{ac(e,`minimum`,t),oc(e,`maximum`,t)},cc=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},lc=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},uc=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},dc=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},fc=(e,t)=>ac(e,`minimum`,t.minimum),pc=(e,t)=>oc(e,`maximum`,t.maximum),mc=e=>(t,n)=>{dc(t,n.format);let[r,i]=e[n.format];ac(t,`minimum`,r),oc(t,`maximum`,i)},hc={greater_than:(e,t)=>ac(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>oc(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>cc(e,t.value),number_format:mc(Dn),bigint_format:mc(On),min_length:fc,max_length:pc,length_equals:(e,t)=>sc(e,t.length),min_size:fc,max_size:pc,size_equals:(e,t)=>sc(e,t.size),string_format:(e,t)=>{dc(e,t.format),t.pattern&&lc(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)=>uc(e,t.mime)};function gc(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)hc[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&ac(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&ac(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&oc(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&oc(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&cc(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&uc(t,i.mime);for(let e of i.patterns??[])lc(t,e);return t}var _c={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},vc=new Map([[Ca,si],[Ta,ci]]),yc=e=>vc.get(e)??e,bc=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=gc(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=_c[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(yc);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}=gc(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}))])}},Sc=(e,t,n,r)=>{n.type=`boolean`},Cc=(e,t,n,r)=>{n.not={}},wc=(e,t,n,r)=>{let i=e._zod.def,a=Qt(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)},Tc=(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}},Ec=(e,t,n,r)=>{qs(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},Dc=(e,t,n,r)=>{qs(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},Oc=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=gc(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`]})};function kc(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?kc(t.out):t.type===`catch`?kc(t.innerType):e._zod.optin}var Ac=(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)sn(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`?kc(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)},jc=(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},Mc=(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)};function Nc(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=Nc(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=>Nc(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`)?yi:vi).source)),p}var Pc=new WeakMap;function Fc(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 Pc.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=Nc(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)}}var Ic=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=gc(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)sn(i.patternProperties,yc(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=Pc.get(t);n||(n=[],Pc.set(t,n),t.deferred.push(()=>Fc(t))),n.push(e)}i.additionalProperties=R(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&kc(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))}},Lc=(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`}]},Rc=(e,t,n,r)=>{let i=e._zod.def;R(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},zc=Symbol();function Bc(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`),zc):JSON.parse(o)}var Vc=(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=Bc(i.defaultValue,e,t,n,r);o!==zc&&(n.default=o)},Hc=(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=Bc(i.defaultValue,e,t,n,r);o!==zc&&(n._prefault=o)},Uc=(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},Wc=(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},Gc=(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},Kc=(e,t,n,r)=>{let i=e._zod.def;R(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},qc=new WeakSet([Object.prototype,Error.prototype]);function Jc(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 Yc=F(`ZodError`,(e,t)=>{xr.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);qc.has(n)||(qc.add(n),Jc(n,`format`,e=>t=>wr(e,t)),Jc(n,`flatten`,e=>t=>Cr(e,t)),Jc(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,en,2)}),Jc(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,en,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Xc=Er(Yc),Zc=Dr(Yc),Qc=Or(Yc),$c=Ar(Yc),el=Ir(Yc),tl=Lr(Yc),nl=Rr(Yc),rl=zr(Yc),il=Br(Yc),al=Vr(Yc),ol=Hr(Yc),sl=Ur(Yc);function cl(){mr.localeError||hr(Lo())}function ll(){mr.memoizer||hr({memoizer:Po()})}var B=F(`ZodType`,(e,t)=>(cl(),I.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(mn(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 wn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Eu(e,t))},superRefine(e,t){return this.check(Du(e,t))},overwrite(e){return this.check(Fs(e))},optional(){return cu(this)},exactOptional(){return uu(this)},nullable(){return fu(this)},nullish(){return cu(fu(this))},nonoptional(e){return vu(this,e)},array(){return Gl(this)},or(e){return Yl([this,e])},and(e){return Zl(this,e)},transform(e){return Su(this,ou(e))},default(e){return mu(this,e)},prefault(e){return gu(this,e)},catch(e){return bu(this,e)},pipe(e){return Su(this,e)},readonly(){return wu(this)},describe(e){let t=this.clone();return Vo.add(t,{description:e}),t},meta(...e){if(e.length===0)return Vo.get(this);let t=this.clone();return Vo.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 Qn(this,`~standard`,{...Gi(this),jsonSchema:{input:ic(this,`input`),output:ic(this,`output`)}})},set"~standard"(e){Zn(this,`~standard`,e)},parse:function e(t,n){return Xc(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Zc(this,t,n,{callee:e})},safeParse(e,t){return Qc(this,e,t)},async safeParseAsync(e,t){return $c(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Zn(this,`spa`,e)},validate(e,t){return Nr(this,e,t)},validateAsync(e,t){return Fr(this,e,t)},encode:function e(t,n){return el(this,t,n,{callee:e})},decode:function e(t,n){return tl(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 rl(this,t,n,{callee:e})},safeEncode(e,t){return il(this,e,t)},safeDecode(e,t){return al(this,e,t)},async safeEncodeAsync(e,t){return ol(this,e,t)},async safeDecodeAsync(e,t){return sl(this,e,t)},toJSONSchema(e){return rc(this,{})(e)},get description(){return Vo.get(this)?.description},get _def(){return this._zod.def}}),ul=F(`_ZodString`,(e,t)=>{Ki.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bc(e,t,n,r)},$n({format:e=>gc(e).format??null,minLength:e=>gc(e).minimum??null,maxLength:e=>gc(e).maximum??null},{regex(...e){return this.check(ks(...e))},includes(...e){return this.check(Ms(...e))},startsWith(...e){return this.check(Ns(...e))},endsWith(...e){return this.check(Ps(...e))},min(...e){return this.check(Ds(...e))},max(...e){return this.check(Es(...e))},length(...e){return this.check(Os(...e))},nonempty(...e){return this.check(Ds(1,...e))},lowercase(e){return this.check(As(e))},uppercase(e){return this.check(js(e))},trim(){return this.check(Ls())},normalize(...e){return this.check(Is(...e))},toLowerCase(){return this.check(Rs())},toUpperCase(){return this.check(zs())},slugify(){return this.check(Bs())}})),dl=F(`ZodString`,(e,t)=>{Ki.init(e,t),ul.init(e,t)},{email(e){return this.check(Wo(gl,e))},url(e){return this.check(Xo(yl,e))},jwt(e){return this.check(ds(Pl,e))},emoji(e){return this.check(Zo(bl,e))},guid(e){return this.check(Go(_l,e))},uuid(e){return this.check(Ko(vl,e))},uuidv4(e){return this.check(qo(vl,e))},uuidv6(e){return this.check(Jo(vl,e))},uuidv7(e){return this.check(Yo(vl,e))},nanoid(e){return this.check(Qo(xl,e))},cuid(e){return this.check($o(Sl,e))},cuid2(e){return this.check(es(Cl,e))},ulid(e){return this.check(ts(wl,e))},base64(e){return this.check(cs(jl,e))},base64url(e){return this.check(ls(Ml,e))},xid(e){return this.check(ns(Tl,e))},ksuid(e){return this.check(rs(El,e))},ipv4(e){return this.check(is(Dl,e))},ipv6(e){return this.check(as(Ol,e))},cidrv4(e){return this.check(os(kl,e))},cidrv6(e){return this.check(ss(Al,e))},e164(e){return this.check(us(Nl,e))},datetime(e){return this.check(fs(fl,e))},date(e){return this.check(ps(pl,e))},time(e){return this.check(ms(ml,e))},duration(e){return this.check(hs(hl,e))}});function V(e){return Uo(dl,e)}var H=F(`ZodStringFormat`,(e,t)=>{L.init(e,t),ul.init(e,t)}),fl=F(`ZodISODateTime`,(e,t)=>{da.init(e,t),H.init(e,t)}),pl=F(`ZodISODate`,(e,t)=>{fa.init(e,t),H.init(e,t)}),ml=F(`ZodISOTime`,(e,t)=>{pa.init(e,t),H.init(e,t)}),hl=F(`ZodISODuration`,(e,t)=>{ma.init(e,t),H.init(e,t)}),gl=F(`ZodEmail`,(e,t)=>{Yi.init(e,t),H.init(e,t)}),_l=F(`ZodGUID`,(e,t)=>{qi.init(e,t),H.init(e,t)}),vl=F(`ZodUUID`,(e,t)=>{Ji.init(e,t),H.init(e,t)}),yl=F(`ZodURL`,(e,t)=>{ra.init(e,t),H.init(e,t)}),bl=F(`ZodEmoji`,(e,t)=>{ia.init(e,t),H.init(e,t)}),xl=F(`ZodNanoID`,(e,t)=>{aa.init(e,t),H.init(e,t)}),Sl=F(`ZodCUID`,(e,t)=>{oa.init(e,t),H.init(e,t)}),Cl=F(`ZodCUID2`,(e,t)=>{sa.init(e,t),H.init(e,t)}),wl=F(`ZodULID`,(e,t)=>{ca.init(e,t),H.init(e,t)}),Tl=F(`ZodXID`,(e,t)=>{la.init(e,t),H.init(e,t)}),El=F(`ZodKSUID`,(e,t)=>{ua.init(e,t),H.init(e,t)}),Dl=F(`ZodIPv4`,(e,t)=>{ha.init(e,t),H.init(e,t)}),Ol=F(`ZodIPv6`,(e,t)=>{va.init(e,t),H.init(e,t)}),kl=F(`ZodCIDRv4`,(e,t)=>{ya.init(e,t),H.init(e,t)}),Al=F(`ZodCIDRv6`,(e,t)=>{xa.init(e,t),H.init(e,t)}),jl=F(`ZodBase64`,(e,t)=>{wa.init(e,t),H.init(e,t)}),Ml=F(`ZodBase64URL`,(e,t)=>{Da.init(e,t),H.init(e,t)}),Nl=F(`ZodE164`,(e,t)=>{Oa.init(e,t),H.init(e,t)}),Pl=F(`ZodJWT`,(e,t)=>{Aa.init(e,t),H.init(e,t)}),Fl=F(`ZodNumber`,(e,t)=>{ja.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xc(e,t,n,r),e.isFinite=!0},$n({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=gc(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=gc(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=gc(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>gc(e).format??null},{gt(e,t){return this.check(Cs(e,t))},gte(e,t){return this.check(ws(e,t))},min(e,t){return this.check(ws(e,t))},lt(e,t){return this.check(xs(e,t))},lte(e,t){return this.check(Ss(e,t))},max(e,t){return this.check(Ss(e,t))},int(e){return this.check(Ll(e))},safe(e){return this.check(Ll(e))},positive(e){return this.check(Cs(0,e))},nonnegative(e){return this.check(ws(0,e))},negative(e){return this.check(xs(0,e))},nonpositive(e){return this.check(Ss(0,e))},multipleOf(e,t){return this.check(Ts(e,t))},step(e,t){return this.check(Ts(e,t))},finite(){return this}}));function U(e){return gs(Fl,e)}var Il=F(`ZodNumberFormat`,(e,t)=>{Ma.init(e,t),Fl.init(e,t)});function Ll(e){return _s(Il,e)}var Rl=F(`ZodBoolean`,(e,t)=>{Na.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sc(e,t,n,r)});function zl(e){return vs(Rl,e)}var Bl=F(`ZodUnknown`,(e,t)=>{Pa.init(e,t),B.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Vl(){return ys(Bl)}var Hl=F(`ZodNever`,(e,t)=>{Fa.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cc(e,t,n,r)});function Ul(e){return bs(Hl,e)}var Wl=F(`ZodArray`,(e,t)=>{ll(),za.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oc(e,t,n,r),e.element=t.element},{min(e,t){return this.check(Ds(e,t))},nonempty(e){return this.check(Ds(1,e))},max(e,t){return this.check(Es(e,t))},length(e,t){return this.check(Os(e,t))},unwrap(){return this.element}});function Gl(e,t){return Vs(Wl,e,t)}var Kl=F(`ZodObject`,(e,t)=>{ll(),Ga.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ac(e,t,n,r),ar(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return nu(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(mn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(mn(this._zod.def,{catchall:Vl()}))},loose(){return this.clone(mn(this._zod.def,{catchall:Vl()}))},strict(){return this.clone(mn(this._zod.def,{catchall:Ul()}))},strip(){return this.clone(mn(this._zod.def,{catchall:void 0}))},extend(e){return Mn(this,e)},safeExtend(e){return Pn(this,e)},merge(e){return Fn(this,e)},pick(e){return kn(this,e)},omit(e){return jn(this,e)},partial(...e){return In(su,this,e[0])},exactPartial(...e){return In(lu,this,e[0],`exactPartial`)},required(...e){return Ln(_u,this,e[0])}});function ql(e,t){return new Kl({type:`object`,shape:e??{},...N(t)})}var Jl=F(`ZodUnion`,(e,t)=>{qa.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jc(e,t,n,r),e.options=t.options});function Yl(e,t){return new Jl({type:`union`,options:e,...N(t)})}var Xl=F(`ZodIntersection`,(e,t)=>{Ja.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mc(e,t,n,r)});function Zl(e,t){return new Xl({type:`intersection`,left:e,right:t})}var Ql=F(`ZodRecord`,(e,t)=>{ll(),Za.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ic(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function $l(e,t,n){return!t||!t._zod?new Ql({type:`record`,keyType:V(),valueType:e,...N(t)}):new Ql({type:`record`,keyType:e,valueType:t,...N(n)})}function eu(e,t,n){return new Ql({type:`record`,keyType:e,valueType:t,...N(n),partial:!0})}var tu=F(`ZodEnum`,(e,t)=>{Qa.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wc(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 tu({...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 tu({...t,checks:[],...N(r),entries:i})}});function nu(e,t){return new tu({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...N(t)})}var ru=F(`ZodLiteral`,(e,t)=>{$a.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Tc(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]}})});function iu(e,t){return new ru({type:`literal`,values:Array.isArray(e)?e:[e],...N(t)})}var au=F(`ZodTransform`,(e,t)=>{ll(),eo.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Dc(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new pr(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Yn(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(Yn(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function ou(e){return new au({type:`transform`,transform:e})}var su=F(`ZodOptional`,(e,t)=>{no.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function cu(e){return new su({type:`optional`,innerType:e})}var lu=F(`ZodExactOptional`,(e,t)=>{ro.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function uu(e){return new lu({type:`optional`,innerType:e})}var du=F(`ZodNullable`,(e,t)=>{io.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function fu(e){return new du({type:`nullable`,innerType:e})}var pu=F(`ZodDefault`,(e,t)=>{ao.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function mu(e,t){return new pu({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():xn(t)}})}var hu=F(`ZodPrefault`,(e,t)=>{so.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function gu(e,t){return new hu({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():xn(t)}})}var _u=F(`ZodNonOptional`,(e,t)=>{co.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function vu(e,t){return new _u({type:`nonoptional`,innerType:e,...N(t)})}var yu=F(`ZodCatch`,(e,t)=>{fo.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function bu(e,t){return new yu({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:sr(t)})}var xu=F(`ZodPipe`,(e,t)=>{po.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wc(e,t,n,r),e.in=t.in,e.out=t.out});function Su(e,t){return new xu({type:`pipe`,in:e,out:t})}var Cu=F(`ZodReadonly`,(e,t)=>{ho.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function wu(e){return new Cu({type:`readonly`,innerType:e})}var Tu=F(`ZodCustom`,(e,t)=>{_o.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ec(e,t,n,r)});function Eu(e,t={}){return Hs(Tu,e,t)}function Du(e,t){return Us(e,t)}function Ou(e){return ps(pl,e)}var W={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`,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`},ku=nu(W),Au=({error:e,fallback:t=W.INTERNAL_ERROR})=>{let n=typeof e==`object`&&e&&`code`in e?ku.safeParse(e.code):null;if(n!==null&&n.success)return n.data;let r=e instanceof Error?e.message:e,i=ku.safeParse(r);return i.success?i.data:t};ql({code:ku,message:V(),payload:$l(V(),Vl()).optional()});var ju=t({InferenceSession:()=>kd,TRACE:()=>bd,TRACE_EVENT_BEGIN:()=>wd,TRACE_EVENT_END:()=>Td,TRACE_FUNC_BEGIN:()=>Sd,TRACE_FUNC_END:()=>Cd,Tensor:()=>vd,default:()=>Ep,env:()=>q,registerBackend:()=>Hu}),Mu=Object.defineProperty,Nu=Object.getOwnPropertyDescriptor,Pu=Object.getOwnPropertyNames,Fu=Object.prototype.hasOwnProperty,Iu=(e=>typeof n<`u`?n:typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(typeof n<`u`?n:e)[t]}):e)(function(e){if(typeof n<`u`)return n.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}},Lu=(e,t)=>{for(var n in t)Mu(e,n,{get:t[n],enumerable:!0})},Ru=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of Pu(t))!Fu.call(e,i)&&i!==n&&Mu(e,i,{get:()=>t[i],enumerable:!(r=Nu(t,i))||r.enumerable});return e},zu=e=>Ru(Mu({},`__esModule`,{value:!0}),e),Bu,Vu,Hu,Uu,Wu,Gu=G(()=>{Bu=new Map,Vu=[],Hu=(e,t,n)=>{if(t&&typeof t.init==`function`&&typeof t.createInferenceSessionHandler==`function`){let r=Bu.get(e);if(r===void 0)Bu.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=Vu.indexOf(e);t!==-1&&Vu.splice(t,1);for(let t=0;t<Vu.length;t++)if(Bu.get(Vu[t]).priority<=n){Vu.splice(t,0,e);return}Vu.push(e)}}else throw TypeError(`not a valid backend`)},Uu=async e=>{let t=Bu.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}}},Wu=async e=>{let t=e.executionProviders||[],n=t.map(e=>typeof e==`string`?e:e.name),r=n.length===0?Vu:n,i,a=[],o=new Set;for(let e of r){let t=await Uu(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)})]}}),Ku=G(()=>{Gu()}),qu,Ju=G(()=>{qu=`1.30.0`}),Yu,K,Xu=G(()=>{Ju(),Yu=`warning`,K={wasm:{},webgl:{},webgpu:{},versions:{common:qu},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}`);Yu=e}},get logLevel(){return Yu}},Object.defineProperty(K,"logLevel",{enumerable:!0})}),q,Zu=G(()=>{Xu(),q=K}),Qu,$u,ed=G(()=>{Qu=(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`)},$u=(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}}),td,nd,rd,id,ad,od,sd=G(()=>{_d(),td=(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 gd(`float32`,u,[1,4,n,r]):new gd(`float32`,u,[1,3,n,r])},nd=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,td(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(td(e.data,s))}});throw Error(`Input data provided is not supported - aborted tensor creation`)}if(o!==void 0)return td(o,s);throw Error(`Input data provided is not supported - aborted tensor creation`)},rd=(e,t)=>{let{width:n,height:r,download:i,dispose:a}=t;return new gd({location:`texture`,type:`float32`,texture:e,dims:[1,r,n,4],download:i,dispose:a})},id=(e,t)=>{let{dataType:n,dims:r,download:i,dispose:a}=t;return new gd({location:`gpu-buffer`,type:n??`float32`,gpuBuffer:e,dims:r,download:i,dispose:a})},ad=(e,t)=>{let{dataType:n,dims:r,download:i,dispose:a}=t;return new gd({location:`ml-tensor`,type:n??`float32`,mlTensor:e,dims:r,download:i,dispose:a})},od=(e,t,n)=>new gd({location:`cpu-pinned`,type:e,data:t,dims:n??[t.length]})}),cd,ld,ud,dd,fd=G(()=>{cd=new Map([[`float32`,Float32Array],[`uint8`,Uint8Array],[`int8`,Int8Array],[`uint16`,Uint16Array],[`int16`,Int16Array],[`int32`,Int32Array],[`bool`,Uint8Array],[`float64`,Float64Array],[`uint32`,Uint32Array],[`int4`,Uint8Array],[`uint4`,Uint8Array]]),ld=new Map([[Float32Array,`float32`],[Uint8Array,`uint8`],[Int8Array,`int8`],[Uint16Array,`uint16`],[Int16Array,`int16`],[Int32Array,`int32`],[Float64Array,`float64`],[Uint32Array,`uint32`]]),ud=!1,dd=()=>{if(!ud){ud=!0;let e=typeof BigInt64Array<`u`&&BigInt64Array.from,t=typeof BigUint64Array<`u`&&BigUint64Array.from,n=globalThis.Float16Array,r=typeof n<`u`&&n.from;e&&(cd.set(`int64`,BigInt64Array),ld.set(BigInt64Array,`int64`)),t&&(cd.set(`uint64`,BigUint64Array),ld.set(BigUint64Array,`uint64`)),r?(cd.set(`float16`,n),ld.set(n,`float16`)):cd.set(`float16`,Uint16Array)}}}),pd,md,hd=G(()=>{_d(),pd=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},md=(e,t)=>{switch(e.location){case`cpu`:return new gd(e.type,e.data,t);case`cpu-pinned`:return new gd({location:`cpu-pinned`,data:e.data,type:e.type,dims:t});case`texture`:return new gd({location:`texture`,texture:e.texture,type:e.type,dims:t});case`gpu-buffer`:return new gd({location:`gpu-buffer`,gpuBuffer:e.gpuBuffer,type:e.type,dims:t});case`ml-tensor`:return new gd({location:`ml-tensor`,mlTensor:e.mlTensor,type:e.type,dims:t});default:throw Error(`tensorReshape: tensor location ${e.location} is not supported`)}}}),gd,_d=G(()=>{ed(),sd(),fd(),hd(),gd=class{constructor(e,t,n){dd();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=cd.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=cd.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=ld.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=pd(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 nd(e,t)}static fromTexture(e,t){return rd(e,t)}static fromGpuBuffer(e,t){return id(e,t)}static fromMLTensor(e,t){return ad(e,t)}static fromPinnedBuffer(e,t,n){return od(e,t,n)}toDataURL(e){return Qu(this,e)}toImageData(e){return $u(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 md(this,e)}}}),vd,yd=G(()=>{_d(),vd=gd}),bd,xd,Sd,Cd,wd,Td,Ed=G(()=>{Xu(),bd=(e,t)=>{(typeof K.trace>`u`?!K.wasm.trace:!K.trace)||console.timeStamp(`${e}::ORT::${t}`)},xd=(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}`),bd(`CPU`,r);return}n[i].includes(`TRACE_FUNC`)&&(r=!0)}},Sd=e=>{(typeof K.trace>`u`?!K.wasm.trace:!K.trace)||xd(`BEGIN`,e)},Cd=e=>{(typeof K.trace>`u`?!K.wasm.trace:!K.trace)||xd(`END`,e)},wd=e=>{(typeof K.trace>`u`?!K.wasm.trace:!K.trace)||console.time(`ORT::${e}`)},Td=e=>{(typeof K.trace>`u`?!K.wasm.trace:!K.trace)||console.timeEnd(`ORT::${e}`)}}),Dd,Od=G(()=>{Gu(),yd(),Ed(),Dd=class e{constructor(e){this.handler=e}async run(e,t,n){Sd(),wd(`InferenceSession.run`);let r={},i={};if(typeof e!=`object`||!e||e instanceof vd||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 vd)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 vd)&&(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 vd?t:new vd(t.type,t.data,t.dims)}return Td(`InferenceSession.run`),Cd(),s}async release(){return this.handler.dispose()}static async create(t,n,r,i){Sd(),wd(`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 Wu(o),l=await s.createInferenceSessionHandler(a,c);return Td(`InferenceSession.create`),Cd(),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}}}),kd,Ad=G(()=>{Od(),kd=Dd}),jd=G(()=>{}),Md=G(()=>{}),Nd=G(()=>{}),Pd=G(()=>{}),Fd={};Lu(Fd,{InferenceSession:()=>kd,TRACE:()=>bd,TRACE_EVENT_BEGIN:()=>wd,TRACE_EVENT_END:()=>Td,TRACE_FUNC_BEGIN:()=>Sd,TRACE_FUNC_END:()=>Cd,Tensor:()=>vd,env:()=>q,registerBackend:()=>Hu});var Id=G(()=>{Ku(),Zu(),Ad(),yd(),jd(),Md(),Ed(),Nd(),Pd()}),Ld=G(()=>{}),Rd={};Lu(Rd,{default:()=>Vd});var zd,Bd,Vd,Hd=G(()=>{Xf(),pf(),rf(),zd=`ort-wasm-proxy-worker`,Bd=globalThis.self?.name===zd,Bd&&(self.onmessage=e=>{let{type:t,in:n}=e.data;try{switch(t){case`init-wasm`:ff(n.wasm).then(()=>{Rf(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;zf(r,e).then(()=>{postMessage({type:t})},e=>{postMessage({type:t,err:e})});break}case`copy-from`:{let{buffer:e}=n,r=Uf(e);postMessage({type:t,out:r});break}case`create`:{let{model:e,options:r}=n;Wf(e,r).then(e=>{postMessage({type:t,out:e})},e=>{postMessage({type:t,err:e})});break}case`release`:Gf(n),postMessage({type:t});break;case`run`:{let{sessionId:e,inputIndices:r,inputs:i,outputIndices:a,options:o}=n;qf(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},Yf([...i,...e]))},e=>{postMessage({type:t,err:e})});break}case`end-profiling`:Jf(n),postMessage({type:t})}}catch(e){postMessage({type:t,err:e})}}),Vd=Bd?null:e=>new Worker(e??Kd,{type:`module`,name:zd})}),Ud,Wd,Gd,Kd,qd,Jd,Yd,Xd,Zd,Qd,$d,ef,tf,nf,rf=G(()=>{Ld(),Ud=typeof location>`u`?void 0:location.origin,Wd=import.meta.url>`file:`&&import.meta.url<`file;`,Gd=()=>Wd?new URL(new URL(`ort.wasm.min.mjs`,import.meta.url).href,Ud).href:import.meta.url,Kd=Gd(),qd=()=>{if(Kd&&!Kd.startsWith(`blob:`))return Kd.substring(0,Kd.lastIndexOf(`/`)+1)},Jd=(e,t)=>{try{let n=t??Kd;return(n?new URL(e,n):new URL(e)).origin===Ud}catch{return!1}},Yd=(e,t)=>{let n=t??Kd;try{return(n?new URL(e,n):new URL(e)).href}catch{return}},Xd=(e,t)=>`${t??`./`}${e}`,Zd=async e=>{let t=await(await fetch(e,{credentials:`same-origin`})).blob();return URL.createObjectURL(t)},Qd=async e=>(await import(e)).default,$d=(Hd(),zu(Rd)).default,ef=async()=>{if(!Kd)throw Error(`Failed to load proxy worker: cannot determine the script source URL.`);if(Jd(Kd))return[void 0,$d()];let e=await Zd(Kd);return[e,$d(e)]},tf=void 0,nf=async(e,t,n,r)=>{let i=tf&&!(e||t);if(i){if(Kd)i=Jd(Kd)||r&&!n;else if(r&&!n)i=!0;else throw Error(`cannot determine the script source URL.`)}if(i)return[void 0,tf];{let r=`ort-wasm-simd-threaded.mjs`,i=e??Yd(r,t),a=n&&i&&!Jd(i,t),o=a?await Zd(i):i??Xd(r,t);return[a?o:void 0,await Qd(o)]}}}),af,of,sf,cf,lf,uf,df,ff,J,pf=G(()=>{rf(),of=!1,sf=!1,cf=!1,lf=()=>{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}},uf=()=>{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}},df=()=>{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}},ff=async e=>{if(of)return Promise.resolve();if(sf)throw Error(`multiple calls to 'initializeWebAssembly()' detected.`);if(cf)throw Error(`previous call to 'initializeWebAssembly()' failed.`);sf=!0;let t=e.initTimeout,n=e.numThreads;if(e.simd!==!1){if(e.simd===`relaxed`){if(!df())throw Error(`Relaxed WebAssembly SIMD is not supported in the current environment.`)}else if(!uf())throw Error(`WebAssembly SIMD is not supported in the current environment.`)}let r=lf();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 nf(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=qd();e&&(r.locateFile=t=>e+t)}f(r).then(t=>{sf=!1,of=!0,af=t,e(),d&&URL.revokeObjectURL(d)},e=>{sf=!1,cf=!0,t(e)})})),await Promise.race(m),p)throw Error(`WebAssembly backend initializing failed due to timeout: ${t}ms`)},J=()=>{if(of&&af)return af;throw Error(`WebAssembly is not initialized yet.`)}}),mf,hf,Y,gf=G(()=>{pf(),mf=(e,t)=>{let n=J(),r=n.lengthBytesUTF8(e)+1,i=n._malloc(r);return n.stringToUTF8(e,i,r),t.push(i),i},hf=(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`)hf(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)}}}),_f,vf=G(()=>{pf(),gf(),_f=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=mf(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&&hf(e.extra,``,new WeakSet,(e,i)=>{let a=mf(e,r),o=mf(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}}}),yf,bf,xf,Sf,Cf,wf,Tf=G(()=>{pf(),gf(),yf=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}`)}},bf=e=>{switch(e){case`sequential`:return 0;case`parallel`:return 1;default:throw Error(`unsupported execution mode: ${e}`)}},xf=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)},Sf=(e,t,n,r)=>{let i=mf(t,r),a=mf(n,r);J()._OrtAddSessionConfigEntry(e,i,a)!==0&&Y(`Can't set a session config entry: ${t} - ${n}.`)},Cf=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`,Sf(e,`session.disable_quant_qdq`,`1`,n),Sf(e,`session.disable_qdq_constant_folding`,`1`,n),typeof t!=`string`){let r=t?.deviceType;r&&Sf(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}`);Sf(e,`preferredLayout`,r.preferredLayout,n)}}break;case`wasm`:case`cpu`:continue;default:throw Error(`not supported execution provider: ${r}`)}let a=mf(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}.`)}},wf=async e=>{let t=J(),n=0,r=[],i=e||{};xf(i);try{let e=yf(i.graphOptimizationLevel??`all`),a=bf(i.executionMode??`sequential`),o=typeof i.logId==`string`?mf(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`?mf(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 Cf(n,i,r),i.enableGraphCapture!==void 0){if(typeof i.enableGraphCapture!=`boolean`)throw Error(`enableGraphCapture must be a boolean value: ${i.enableGraphCapture}`);Sf(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=mf(e,r);t._OrtAddFreeDimensionOverride(n,i,a)!==0&&Y(`Can't set a free dimension override: ${e} - ${a}.`)}return i.extra!==void 0&&hf(i.extra,``,new WeakSet,(e,t)=>{Sf(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}}}),Ef,Df,Of,kf,Af,jf,Mf,Nf,Pf=G(()=>{Ef=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}`)}},Df=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}`)}},Of=(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},kf=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}`)}},Af=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}`)}},jf=e=>e===`float32`||e===`float16`||e===`int32`||e===`int64`||e===`uint32`||e===`uint8`||e===`bool`||e===`uint4`||e===`int4`,Mf=e=>e===`float32`||e===`float16`||e===`int32`||e===`int64`||e===`uint32`||e===`uint64`||e===`int8`||e===`uint8`||e===`bool`||e===`uint4`||e===`int4`,Nf=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}`)}}}),Ff,If=G(()=>{Ld(),Ff=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)}}),Lf,Rf,zf,Bf,Vf,Hf,Uf,Wf,Gf,Kf,qf,Jf,Yf,Xf=G(()=>{Id(),vf(),Tf(),Pf(),pf(),gf(),If(),Lf=(e,t)=>{J()._OrtInit(e,t)!==0&&Y(`Can't initialize onnxruntime.`)},Rf=async e=>{Lf(e.wasm.numThreads,Af(e.logLevel))},zf=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`)},Bf=new Map,Vf=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)}},Hf=(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)}},Uf=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]},Wf=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]=Uf(e);let a=0,o=0,s=[],c=[],l=[];try{if([o,s]=await wf(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(Ff(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]=Vf(a),d=!!t?.enableGraphCapture,f=[],p=[],m=[],h=[];for(let t=0;t<e;t++){let[e,n,r]=Hf(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:Df(n),shape:r})}for(let t=0;t<u;t++){let[n,r,o]=Hf(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:Df(r),shape:o})}return Bf.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?.()}},Gf=e=>{let t=J(),n=Bf.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.`),Bf.delete(e)},Kf=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=Of(Ef(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=Of(Ef(l),u);let n=s.webnnRegisterMLTensor;if(!n)throw Error(`Tensor location "ml-tensor" is not supported without using WebNN.`);p=n(r,t,Ef(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,mf(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=Ef(l);m=Of(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(Ef(l),p,m,g,u.length,Nf(f));e===0&&Y(`Can't create tensor for input/output. session=${r}, index=${a}.`),t.push(e)}finally{s.stackRestore(h)}},qf=async(e,t,n,r,i,a)=>{let o=J(),s=o.PTR_SIZE,c=Bf.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,_]=_f(a),wd(`wasm prepareInputOutputTensor`);for(let r=0;r<m;r++)await Kf(n[r],v,b,e,u[t[r]],t[r],p);for(let t=0;t<h;t++)await Kf(i[t],y,b,e,d[r[t]],m+r[t],p);Td(`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=[],D=[];wd(`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=Df(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=Of(a,g);if(r===void 0||!jf(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(Of(a,g)===void 0||!Mf(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,D.push((async()=>{let r=[t,await e];return o.webnnReleaseTensorId(d),o._OrtReleaseTensor(n),r})()),S.push([u,h,[],`cpu`])}else{let e=new(kf(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.`),Bf.set(e,[l,u,d,f,p,!1]));for(let[e,t]of await Promise.all(D))S[e][2]=t;return Td(`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))}},Jf=e=>{let t=J(),n=Bf.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)},Yf=e=>{let t=[];for(let n of e){let e=n[2];!Array.isArray(e)&&`buffer`in e&&t.push(e.buffer)}return t}}),Zf,Qf,$f,ep,tp,np,rp,ip,ap,op,sp,cp,lp,up,dp,fp,pp,mp,hp=G(()=>{Id(),Xf(),pf(),rf(),Zf=()=>!!q.wasm.proxy&&typeof document<`u`,$f=!1,ep=!1,tp=!1,ip=new Map,ap=(e,t)=>{let n=ip.get(e);n?n.push(t):ip.set(e,[t])},op=()=>{if($f||!ep||tp||!Qf)throw Error(`worker not ready`)},sp=e=>{switch(e.data.type){case`init-wasm`:$f=!1,e.data.err?(tp=!0,rp[1](e.data.err)):(ep=!0,rp[0]()),np&&=(URL.revokeObjectURL(np),void 0);break;case`init-ep`:case`copy-from`:case`create`:case`release`:case`run`:case`end-profiling`:{let t=ip.get(e.data.type);e.data.err?t.shift()[1](e.data.err):t.shift()[0](e.data.out);break}}},cp=async()=>{if(!ep){if($f)throw Error(`multiple calls to 'initWasm()' detected.`);if(tp)throw Error(`previous call to 'initWasm()' failed.`);if($f=!0,Zf())return new Promise((e,t)=>{Qf?.terminate(),ef().then(([n,r])=>{try{Qf=r,Qf.onerror=e=>t(e),Qf.onmessage=sp,rp=[e,t];let i={type:`init-wasm`,in:q};if(!i.in.wasm.wasmPaths&&n){let e=qd();e&&(i.in.wasm.wasmPaths=e)}Qf.postMessage(i),np=n}catch(e){t(e)}},t)});try{await ff(q.wasm),await Rf(q),ep=!0}catch(e){throw tp=!0,e}finally{$f=!1}}},lp=async e=>{if(Zf())return op(),new Promise((t,n)=>{ap(`init-ep`,[t,n]);let r={type:`init-ep`,in:{epName:e,env:q}};Qf.postMessage(r)});await zf(q,e)},up=async e=>Zf()?(op(),new Promise((t,n)=>{ap(`copy-from`,[t,n]);let r={type:`copy-from`,in:{buffer:e}};Qf.postMessage(r,[e.buffer])})):Uf(e),dp=async(e,t)=>{if(Zf()){if(t?.preferredOutputLocation)throw Error(`session option "preferredOutputLocation" is not supported for proxy.`);return op(),new Promise((n,r)=>{ap(`create`,[n,r]);let i={type:`create`,in:{model:e,options:{...t}}},a=[];e instanceof Uint8Array&&a.push(e.buffer),Qf.postMessage(i,a)})}return Wf(e,t)},fp=async e=>{if(Zf())return op(),new Promise((t,n)=>{ap(`release`,[t,n]);let r={type:`release`,in:e};Qf.postMessage(r)});Gf(e)},pp=async(e,t,n,r,i,a)=>{if(Zf()){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 op(),new Promise((i,o)=>{ap(`run`,[i,o]);let s=n,c={type:`run`,in:{sessionId:e,inputIndices:t,inputs:s,outputIndices:r,options:a}};Qf.postMessage(c,Yf(s))})}return qf(e,t,n,r,i,a)},mp=async e=>{if(Zf())return op(),new Promise((t,n)=>{ap(`end-profiling`,[t,n]);let r={type:`end-profiling`,in:e};Qf.postMessage(r)});Jf(e)}}),gp,_p,vp,yp=G(()=>{Id(),hp(),Pf(),Ld(),If(),gp=(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()}`)}},_p=e=>{switch(e[3]){case`cpu`:return new vd(e[0],e[2],e[1]);case`gpu-buffer`:{let t=e[0];if(!jf(t))throw Error(`not supported data type: ${t} for deserializing GPU tensor`);let{gpuBuffer:n,download:r,dispose:i}=e[2];return vd.fromGpuBuffer(n,{dataType:t,dims:e[1],download:r,dispose:i})}case`ml-tensor`:{let t=e[0];if(!Mf(t))throw Error(`not supported data type: ${t} for deserializing MLTensor tensor`);let{mlTensor:n,download:r,dispose:i}=e[2];return vd.fromMLTensor(n,{dataType:t,dims:e[1],download:r,dispose:i})}default:throw Error(`invalid data location: ${e[3]}`)}},vp=class{async fetchModelAndCopyToWasmMemory(e){return up(await Ff(e))}async loadModel(e,t){Sd();let n;n=typeof e==`string`?await this.fetchModelAndCopyToWasmMemory(e):e,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await dp(n,t),Cd()}async dispose(){return fp(this.sessionId)}async run(e,t,n){Sd();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)=>gp(e,()=>`input "${this.inputNames[i[t]]}"`)),c=a.map((e,t)=>e?gp(e,()=>`output "${this.outputNames[o[t]]}"`):null),l=await pp(this.sessionId,i,s,o,c,n),u={};for(let e=0;e<l.length;e++)u[this.outputNames[o[e]]]=a[e]??_p(l[e]);return Cd(),u}startProfiling(){}endProfiling(){mp(this.sessionId)}}}),bp={};Lu(bp,{OnnxruntimeWebAssemblyBackend:()=>Sp,initializeFlags:()=>xp,wasmBackend:()=>Cp});var xp,Sp,Cp,wp=G(()=>{Id(),hp(),yp(),xp=()=>{(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`?Iu(`node:os`).cpus().length:navigator.hardwareConcurrency;q.wasm.numThreads=Math.min(4,Math.ceil((e||1)/2))}}},Sp=class{async init(e){xp(),await cp(),await lp(e)}async createInferenceSessionHandler(e,t){let n=new vp;return await n.loadModel(e,t),n}},Cp=new Sp});Id(),Id(),Id();var Tp=`1.30.0`,Ep=Fd;{let e=(wp(),zu(bp)).wasmBackend;Hu(`cpu`,e,10),Hu(`wasm`,e,10)}Object.defineProperty(q.versions,"web",{value:Tp,enumerable:!0});var Dp={"dd.ort":`259d860d37e4d12055a63e17685992265ad7d07e656e7ceb564d6e97464f5066`,"do.ort":`d77468ab16b74fd8268cb9d2179aa7fc7d45a5658d3684128d516b1729fd5776`,"fd.ort":`328a81c28493a21cf65b7be4322b1c16d726c485c59615a916dd2090ae1cedec`,"fdl.ort":`d1367545b14a23ec8f827e00580f06f13467f08bbd7399230f1d44bb423c8e10`,"fdh.ort":`5315c6b22309439a3ba1e853133e3ef7ffd43a8d34910bd35e9eacc3c6cacdd0`,"fl.ort":`fa9272923b5f12d61809ceee5611c698c6527e8603857c108891fa4ec41385bf`,"fe.ort":`d1a3c6d54a24b696e88ee12856624c2ea92b9f014f1c4483eb47788c8a6f1f33`,"fm.ort":`34652e9faf44e8a092aad1613d4c67d6775de3f212f3c68f865059ee2b40876d`,"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`},Op=globalThis.document?.currentScript,kp=globalThis.HTMLScriptElement&&Op instanceof globalThis.HTMLScriptElement?Op.src:``,Ap=typeof import.meta.url==`string`?import.meta.url:``,jp=()=>globalThis.__VOLTOM_ASSET_BASE_URL__,Mp=()=>jp()||kp||globalThis.location?.href||Ap||`http://localhost/`,Np=({filename:e})=>{let t=Dp[e];if(!t&&/\.(onnx|ort|txt)$/.test(e))throw Error(W.MODEL_LOAD_FAILED);let n=new URL(`./${t?`models`:`assets`}/${e}`,Mp());return t&&n.searchParams.set(`v`,t),n.href},Pp=({category:e,duration:t,key:n})=>{},Fp=async({key:e,operation:t})=>{let n=performance.now();try{return await t()}finally{Pp({category:`stages`,duration:performance.now()-n,key:e})}},Ip={high:`fdh.ort`,standard:`fd.ort`,low:`fdl.ort`},Lp=new Map,Rp=!1,zp,Bp=ju,Vp=()=>[`wasm`],Hp=()=>globalThis.crossOriginIsolated&&!!globalThis.SharedArrayBuffer,Up=()=>Math.min(Math.max(Math.floor((navigator.hardwareConcurrency||1)/2),1),4),Wp=()=>({inference:`CPU (WASM SIMD)`,isolation:globalThis.crossOriginIsolated?`cross origin isolated`:`not isolated`,models:`ORT fixed optimized`,threading:Hp()?`multi thread (auto, up to ${Up()})`:`single thread`}),Gp=async()=>(Rp||=(Bp.env.wasm.numThreads=+!Hp(),Bp.env.wasm.wasmPaths={mjs:Np({filename:`ort-wasm-simd-threaded.mjs`}),wasm:Np({filename:`ort-wasm-simd-threaded.wasm`})},!0),Bp),Kp=async({filename:e})=>{let t=Lp.get(e);try{return t||(t=(async()=>{let t=await(await Gp()).InferenceSession.create(Np({filename:e}),{executionProviders:Vp(),extra:{session:{load_model_format:`ORT`}},graphOptimizationLevel:`disabled`});return{inputNames:t.inputNames,outputNames:t.outputNames,run:async e=>{let n=zp,r=Promise.withResolvers();zp=r.promise,await n;try{return await t.run(e)}finally{r.resolve(),zp===r.promise&&(zp=void 0)}}}})(),Lp.set(e,t)),await t}catch(n){throw t&&Lp.get(e)===t&&Lp.delete(e),Error(W.MODEL_LOAD_FAILED,{cause:n})}},qp=({canvas:e})=>{e.width=1,e.height=1},Jp=({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(W.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{qp({canvas:a})}},Yp=ju,Xp={environment:`browser`,createCanvas:(e,t)=>new OffscreenCanvas(e,t),createImageData:(e,t)=>new ImageData(e,t),createImageBitmap:(async(...e)=>{try{return await createImageBitmap(...e)}catch(e){throw Error(W.IMAGE_DECODE_FAILED,{cause:e})}}),session:Kp,tensor:(e,t,n)=>new Yp.Tensor(e,t,n)},Zp=Jp({runtime:Xp}),Qp=[`PASSPORT`,`PASSAPORTO`,`PASSEPORT`,`PASAPORTE`,`REISEPASS`,`PASZPORT`],$p=[`VISA`],em=[`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`],tm=[`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`],nm=({text:e})=>e.toUpperCase().normalize(`NFKC`),rm=({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,``)))},im=({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},am=({image:e,text:t,codes:n})=>{let r=nm({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(rm({labels:$p,text:r}))return{document:`visa`,europeanDrivingLicense:!1};if(rm({labels:Qp,text:r}))return{document:`passport`,europeanDrivingLicense:!1};if(rm({labels:tm,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=im({...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=im({...e,predicate:i,xEnd:.35,yEnd:.4}),o=im({...e,predicate:i,xStart:.65,yEnd:.4});return{document:`driving_license`,europeanDrivingLicense:n&&r>=.008&&Math.max(a,o)>=.008}}return rm({labels:em,text:r})?{document:`id`,europeanDrivingLicense:!1}:null},om=({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),sm=({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))},cm=({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}},lm=2,um=70,dm=.6,fm=({first:e,second:t})=>Math.hypot(t.x-e.x,t.y-e.y),pm=({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)},mm=({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=pm({matrix:n,values:r});return i?[...i,1]:null},hm=({image:e,polygon:t,sourceOrientation:n})=>{let[r,i,a,o]=sm({polygon:t,sourceOrientation:n});if(!r||!i||!a||!o)throw Error(W.DOCUMENT_NOT_FOUND);let s=Math.max(1,Math.round((fm({first:r,second:i})+fm({first:o,second:a}))/2)),c=Math.max(1,Math.round((fm({first:i,second:a})+fm({first:r,second:o}))/2)),l=mm({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(W.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(W.DOCUMENT_NOT_FOUND);let y=s*lm,b=c*lm,x=new Uint8ClampedArray(y*b*4),S=new Uint8ClampedArray(y*b),C=new Float64Array(e.width*e.height);for(let t=0;t<C.length;t+=1){let n=t*4;C[t]=(e.data[n]??0)*.299+(e.data[n+1]??0)*.587+(e.data[n+2]??0)*.114}for(let t=0;t<b;t+=1)for(let n=0;n<y;n+=1){let r=n/lm,i=t/lm,a=g*r+_*i+v,o=(u*r+d*i+f)/a,s=(p*r+m*i+h)/a,c=Math.max(0,Math.min(e.width-1,o)),l=Math.max(0,Math.min(e.height-1,s)),b=Math.floor(c),x=Math.floor(l),w=Math.min(e.width-1,b+1),T=Math.min(e.height-1,x+1),E=c-b,D=l-x,ee=x*e.width,te=T*e.width,ne=C[ee+b]*(1-E)+C[ee+w]*E,re=C[te+b]*(1-E)+C[te+w]*E,ie=ne*(1-D)+re*D;S[t*y+n]=Math.max(0,Math.min(255,Math.round((ie-um)*255/140)))}let w=new Uint16Array(y*3),T=({y:e})=>{let t=e*y,n=e%3*y;for(let e=0;e<y;e+=1){let r=Math.max(0,e-1),i=Math.min(y-1,e+1);w[n+e]=(S[t+r]??0)+(S[t+e]??0)+(S[t+i]??0)}};T({y:0});for(let e=0;e<b;e+=1){e+1<b&&T({y:e+1});let t=Math.max(0,e-1)%3*y,n=e%3*y,r=Math.min(b-1,e+1)%3*y;for(let i=0;i<y;i+=1){let a=(w[t+i]??0)+(w[n+i]??0)+(w[r+i]??0),o=S[e*y+i]??0,s=Math.max(0,Math.min(255,Math.round(o+dm*(o-a/9)))),c=(e*y+i)*4;x[c]=s,x[c+1]=s,x[c+2]=s,x[c+3]=255}}return{data:x,height:b,width:y}},gm=({document:e})=>e!==`passport`&&e!==`visa`,_m=({identity:e})=>!!(e?.holder.last_name&&e.holder.first_name&&e.holder.birth_date&&e.document.number),vm=({classification:e,front:t,back:n})=>{let r=[],i=e.document===`passport`,a=e.document===`visa`,o=gm(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(W.DOCUMENT_TEXT_NOT_READABLE),o&&r.push(W.DOCUMENT_BACK_REQUIRED),i&&!c.length&&r.push(W.INVALID_PASSPORT_MRZ),a&&!l.length&&r.push(W.INVALID_DOCUMENT_MRZ),!i&&n&&(e.document===`id`&&!u.length&&r.push(W.INVALID_DOCUMENT_MRZ),e.document===`driving_license`&&(e.europeanDrivingLicense?(om(n.ocr)||r.push(W.EUROPEAN_LICENCE_BACK_MARKER_REQUIRED),_m({identity:e.identity})||r.push(W.DOCUMENT_VALIDATION_FAILED)):d.length||r.push(W.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(W.DOCUMENT_CODE_TYPE_MISMATCH),{valid:r.length===0,reasons:r,codes:s}},X=V().trim().min(1).nullable(),ym=Ou().nullable(),bm=nu([`MRZ`,`AAMVA`,`OCR`]),xm=nu([`PASSPORT`,`ID`,`VISA`,`DRV`,`PERMIT`]),Sm=nu([`M`,`F`,`X`]),Cm=ql({source:bm,type:xm.nullable(),issuing_country:X,number:X,issuing_authority:X.default(null),issue_date:ym,expiry_date:ym,optional_data:X}),wm=ql({first_name:X,last_name:X,middle_name:X,birth_place:X.default(null),birth_date:ym,sex:Sm.nullable(),nationality:X,personal_number:X}),Tm=ql({full:X,street:X,city:X,state_province:X,postal_code:X}),Em=ql({mrz_lines:Gl(V().min(1)),aamva_version:X}),Dm=ql({document:Cm,holder:wm,address:Tm.nullable(),raw_data:Em}),Om={TD1:`TD1`,TD2:`TD2`,TD3:`TD3`,SWISS_DRIVING_LICENSE:`SWISS_DRIVING_LICENSE`,FRENCH_NATIONAL_ID:`FRENCH_NATIONAL_ID`,FRENCH_DRIVING_LICENSE:`FRENCH_DRIVING_LICENSE`},km={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(km);function Am(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 jm=[`A`,`B`,`D`];function Mm(e){if(e.length!==2)throw Error(`invalid document code: ${e}. must be 2 char length`);let[t,n]=e;return Nm(t,e),Pm(n,e),`${t}${n}`}function Nm(e,t){if(!jm.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(jm)}`)}}function Pm(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`)}function Fm(e){return e.replaceAll(/<+$/g,``).replaceAll(`<`,` `)}function Im(e){if(!e.match(/^[A-Z<]+$/))throw Error(`invalid text: ${e}. Must be only alphabetical with <`);return Fm(e)}function Lm(e,t,n=/^[0-9A-Z<]+$/){let r=Fm(e);if(!n.test(e))throw new Rm(`invalid text: ${e}. Must match the following regular expression: ${n.toString()}`,r,t,t+r.length);return r}var Rm=class extends Error{value;start;end;constructor(e,t,n,r){super(e),this.value=t,this.start=n,this.end=r}},zm={8:`B`,6:`G`,0:`O`,1:`I`,5:`S`,2:`Z`},Bm={B:`8`,G:`6`,O:`0`,I:`1`,S:`5`,Z:`2`};function Vm(e){return Bm[e]?Bm[e]:e}function Hm(e){return zm[e]?zm[e]:e}function Um(e,t){let n=``,r=[],i=e.split(``);for(let[e,a]of i.entries())if(t.type===Z.ALPHABETIC){let i=Hm(a);i!==a&&r.push({line:t.line,column:t.start+e,original:a,corrected:i}),n+=i}else if(t.type===Z.NUMERIC){let i=Vm(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 Z={NUMERIC:`NUMERIC`,ALPHABETIC:`ALPHABETIC`,ALPHANUMERIC:`ALPHANUMERIC`};function Wm(e){Km(e,`label`,`string`),e.field!==null&&Km(e,`field`,`string`),Km(e,`line`,`number`),Km(e,`start`,`number`),Km(e,`end`,`number`),Km(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)Km(t,`line`,`number`),Km(t,`start`,`number`),Km(t,`end`,`number`),n.push(t);return{parser:(t,r)=>{let i=Gm(t,e),a=(e.related||[]).map(e=>Gm(t,e)),o={label:e.label,field:e.field,value:null,valid:!1,ranges:n.map(e=>({...e,raw:Gm(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 Rm&&(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=>({...Um(Gm(n,e),e),range:t})}}function Gm(e,t){return e[t.line].slice(t.start,t.end)}function Km(e,t,n){if(typeof e[t]!==n)throw TypeError(`${String(t)} must be a ${n}`)}function qm(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 Jm(e,t){let n=qm(e),r=n===Number(t);return{valid:r,error:r?null:`invalid check digit: ${t}. Must be ${n}`}}function Ym(e,...t){return{value:e,...Jm(t.join(``),e)}}function Xm(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}function Zm(e,t){return{value:e,...Jm(t,e)}}function Qm(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=Fm(e),r=i.length;return{value:i,start:0,end:r}}function $m(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=Jm(`${t}<${r}`,i);return o.valid||(o=Jm(`${t}${r}`,i)),{...a,...o}}return{value:e,...Jm(t,e)}}function eh(e){let t=e.replace(/.*?<{2}/,``),n=Lm(t,e.length-t.length,/^[A-Z<]+<*$/),r=e.length-t.length;return{value:n,start:r,end:r+n.length}}function th(e){let t=Lm(e.replace(/<{2}.*$/,``),0,/^[A-Z<]*<*$/);return{value:t,start:0,end:t.length}}function nh(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 <.`)}}function rh(e){if(e=Fm(e),!km[e])throw Error(`invalid state code: ${e}`);return{value:e,start:0,end:e.length}}var ih={label:`Document number`,field:`documentNumber`,parser:Qm,type:Z.ALPHANUMERIC},ah={label:`Document number check digit`,field:`documentNumberCheckDigit`,parser:$m,type:Z.NUMERIC},oh={label:`Document code`,field:`documentCode`,type:Z.ALPHABETIC},sh={label:`Document code`,field:`documentCode`,type:Z.ALPHANUMERIC},ch={label:`Nationality`,field:`nationality`,parser:rh,type:Z.ALPHABETIC},lh={label:`Sex`,field:`sex`,parser:nh,type:Z.ALPHABETIC},uh={label:`Expiration date`,field:`expirationDate`,parser:Xm,type:Z.NUMERIC},dh={label:`Expiration date check digit`,field:`expirationDateCheckDigit`,parser:Zm,type:Z.NUMERIC},fh={label:`Composite check digit`,field:`compositeCheckDigit`,parser:Ym,type:Z.NUMERIC},ph={label:`Birth date`,field:`birthDate`,parser:Xm,type:Z.NUMERIC},mh={label:`Birth date check digit`,field:`birthDateCheckDigit`,parser:Zm,type:Z.NUMERIC},hh={label:`Issue date`,field:`issueDate`,parser:Xm,type:Z.NUMERIC},gh={label:`First name`,field:`firstName`,parser:eh,type:Z.ALPHABETIC},_h={label:`Last name`,field:`lastName`,parser:th,type:Z.ALPHABETIC},vh={label:`Issuing state`,field:`issuingState`,parser:rh,type:Z.ALPHABETIC},yh=[{...sh,line:0,start:0,end:2,parser:Mm},{...vh,line:0,start:2,end:5},{...ih,line:0,start:5,end:14},{...ah,line:0,start:14,end:15,related:[{line:0,start:0,end:14}]},{...uh,line:0,start:15,end:21},{..._h,line:0,start:21,end:29,parser:Im},{...fh,line:0,start:29,end:30,related:[{line:0,start:0,end:29}]}].map(Wm);function bh(e,t){switch(e){case`TD1`:case`TD2`:case`TD3`:case`FRENCH_DRIVING_LICENSE`:return xh(t.documentNumber);case`FRENCH_NATIONAL_ID`:return xh(t.issueDate,t.administrativeCode2,t.documentNumber);case`SWISS_DRIVING_LICENSE`:return xh(t.pinCode,t.versionNumber);default:Sh(e)}}function xh(...e){let t=``;for(let n of e){if(!n)return null;t+=n}return t}function Sh(e){throw Error(`unrecognized format: ${e}`)}function Ch(e,t,n){let r=[];for(let[i,{parser:a}]of t.entries())r.push(a(e,n[i]));return r}function wh(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 Th(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 Eh(e,t,n,r){let{autocorrect:i=!1}=r,{corrected:a,autocorrectArray:o}=Th(t,n,i),s=Ch(a,n,o),c=wh(s);return{format:e,details:s,fields:c.fields,documentNumber:bh(e,c.fields),valid:c.allValid}}var Dh=Om.FRENCH_DRIVING_LICENSE;function Oh(e,t){if(e.length!==1)throw Error(`invalid number of lines: ${e.length}: Must be 1 for ${Dh}`);if(e[0].length!==30)throw Error(`invalid number of characters for line 1: ${e[0].length}. Must be 30 for ${Dh}`);return Eh(Dh,e,yh,t)}function kh(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}function Ah(e){let t=Lm(e,0);return{value:t,start:0,end:t.length}}var jh=[{...oh,line:0,start:0,end:2,parser:kh},{...vh,line:0,start:2,end:5},{..._h,line:0,start:5,end:30,parser:Im},{label:`Administrative code`,field:`administrativeCode`,line:0,start:30,end:36,parser:Ah},{...hh,line:1,start:0,end:4},{label:`Administrative code 2`,field:`administrativeCode2`,line:1,start:4,end:7,parser:Ah},{...ih,line:1,start:7,end:12},{...ah,line:1,start:12,end:13,related:[{line:1,start:0,end:12}]},{...gh,line:1,start:13,end:27,parser:Im},{...ph,line:1,start:27,end:33},{...mh,line:1,start:33,end:34,related:[{line:1,start:27,end:33}]},{...lh,line:1,start:34,end:35},{...fh,line:1,start:35,end:36,related:[{line:0,start:0,end:36},{line:1,start:0,end:35}]}].map(Wm),Mh=Om.FRENCH_NATIONAL_ID;function Nh(e,t){if(e.length!==2)throw Error(`invalid number of lines: ${e.length}: Must be 2 for ${Mh}`);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 ${Mh}`);return Eh(Mh,e,jh,t)}function Ph(e){if(!e.match(/^[0-9]+$/))throw Error(`invalid number: ${e}`);return e}function Fh(e){if(!e.match(/^<*$/))throw Error(`invalid separator: ${e}. Must be composed only of "<"`);return e}function Ih(e){if(e!==`FA`)throw Error(`invalid document code: ${e}. Must be FA`);return e}function Lh(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`)}}function Rh(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 Lh(r),{value:e.slice(0,7),start:0,end:7}}function zh(e){if(e!==`CHE`&&e!==`LIE`)throw Error(`invalid state code: ${e}. Must be CHE or LIE`);return e}var Bh=[{...ih,line:0,start:0,end:9,parser:Rh},{label:`Language code`,field:`languageCode`,line:0,start:6,end:7,parser:Lh,type:Z.ALPHABETIC},{...oh,line:1,start:0,end:2,parser:Ih},{...vh,line:1,start:2,end:5,parser:zh},{label:`PIN code`,field:`pinCode`,line:1,start:5,end:14,parser:Ph,type:Z.NUMERIC},{label:`Version number`,field:`versionNumber`,line:1,start:14,end:17,parser:Ph,type:Z.NUMERIC},{label:`Separator 1`,field:null,line:1,start:17,end:19,parser:Fh},{...ph,line:1,start:19,end:25},{label:`Separator 2`,field:null,line:1,start:25,end:30,parser:Fh},{..._h,line:2,start:0,end:30},{...gh,line:2,start:0,end:30}].map(Wm),Vh=Om.SWISS_DRIVING_LICENSE;function Hh(e,t){if(e.length!==3)throw Error(`invalid number of lines: ${e.length}: Must be 3 for ${Vh}`);if(e[0].length!==9)throw Error(`invalid number of characters for line 1: ${e[0].length}. Must be 9 for ${Vh}`);if(e[1].length!==30)throw Error(`invalid number of characters for line 2: ${e[1].length}. Must be 30 for ${Vh}`);if(e[2].length!==30)throw Error(`invalid number of characters for line 3: ${e[2].length}. Must be 30 for ${Vh}`);return Eh(Vh,e,Bh,t)}function Uh(e){let t=Lm(e,0);return{value:t,start:0,end:t.length}}var Wh=[{...oh,line:0,start:0,end:2,parser:kh},{...vh,line:0,start:2,end:5},{...ih,line:0,start:5,end:14,related:[{line:0,start:14,end:15},{line:0,start:15,end:30}]},{...ah,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:Uh},{...ph,start:0,end:6,line:1},{...mh,line:1,start:6,end:7,related:[{line:1,start:0,end:6}]},{...lh,line:1,start:7,end:8},{...uh,line:1,start:8,end:14},{...dh,line:1,start:14,end:15,related:[{line:1,start:8,end:14}]},{...ch,line:1,start:15,end:18},{label:`Optional field 2`,field:`optional2`,line:1,start:18,end:29,parser:Ah},{...fh,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}]},{..._h,line:2,start:0,end:30},{...gh,line:2,start:0,end:30}].map(Wm),Gh=Om.TD1;function Kh(e,t){if(e.length!==3)throw Error(`invalid number of lines: ${e.length}: Must be 3 for ${Gh}`);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 ${Gh}`);return Eh(Gh,e,Wh,t)}var qh=[{...oh,line:0,start:0,end:2,parser:kh},{...vh,line:0,start:2,end:5},{..._h,line:0,start:5,end:36},{...gh,line:0,start:5,end:36},{...ih,line:1,start:0,end:9,related:[{line:1,start:9,end:10},{line:1,start:28,end:35}]},{...ah,line:1,start:9,end:10,related:[{line:1,start:0,end:9},{line:1,start:28,end:35}]},{...ch,line:1,start:10,end:13},{...ph,line:1,start:13,end:19},{...mh,line:1,start:19,end:20,related:[{line:1,start:13,end:19}]},{...lh,line:1,start:20,end:21},{...uh,line:1,start:21,end:27},{...dh,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:Ah},{...fh,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}]}].map(Wm),Jh=Om.TD2;function Yh(e,t){if(e.length!==2)throw Error(`invalid number of lines: ${e.length}: Must be 2 for ${Jh}`);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 Eh(Jh,e,qh,t)}function Xh(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}function Zh(e){let t=Lm(e,0,/^[A-Z0-9<]+<*$/);return{value:t,start:0,end:t.length}}function Qh(e,t){return Fm(t)===``?e!==`<`&&e!==`0`?{value:e,valid:!1,error:`invalid check digit ${e}: must be 0 or <`}:e:{value:e,...Jm(t,e)}}var $h=[{...oh,line:0,start:0,end:2,parser:Xh},{...vh,line:0,start:2,end:5},{..._h,line:0,start:5,end:44},{...gh,line:0,start:5,end:44},{...ih,line:1,start:0,end:9},{...ah,line:1,start:9,end:10,related:[{line:1,start:0,end:9}]},{...ch,line:1,start:10,end:13},{...ph,line:1,start:13,end:19},{...mh,line:1,start:19,end:20,related:[{line:1,start:13,end:19}]},{...lh,line:1,start:20,end:21},{...uh,line:1,start:21,end:27},{...dh,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:Zh},{label:`Personal number check digit`,field:`personalNumberCheckDigit`,line:1,start:42,end:43,related:[{line:1,start:28,end:42}],parser:Qh},{...fh,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}]}].map(Wm),eg=Om.TD3;function tg(e,t){if(e.length!==2)throw Error(`invalid number of lines: ${e.length}: Must be 2 for ${eg}`);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 Eh(eg,e,$h,t)}var ng={td1:Kh,td2:Yh,td3:tg,swissDrivingLicense:Hh,frenchNationalId:Nh,frenchDrivingLicense:Oh};function rg(e,t={}){let n=Am(e);switch(n.length){case 1:switch(n[0].length){case 30:return ng.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 ng.td1(n,t);case 36:return n[0].slice(30,35).match(/[0-9]/)||n[0].match(/^IDFRA/)?ng.frenchNationalId(n,t):ng.td2(n,t);case 44:return ng.td3(n,t);case 9:return ng.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 ig=Ou(),ag=({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 ig.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=>ig.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},Q=e=>(e?e.replaceAll(`<`,` `).trim():``)||null,og=e=>{if(!e)return null;try{let t=rg(e.split(`
57
- `)),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(Q).filter(Boolean).join(` `);return Dm.parse({document:{source:`MRZ`,type:i,issuing_country:Q(n.issuingState),number:Q(t.documentNumber),issue_date:ag({value:n.issueDate,source:`MRZ`,kind:`issue`}),expiry_date:ag({value:n.expirationDate,source:`MRZ`,kind:`expiry`}),optional_data:Q(a)},holder:{first_name:Q(n.firstName),last_name:Q(n.lastName),middle_name:null,birth_date:ag({value:n.birthDate,source:`MRZ`,kind:`birth`}),sex:n.sex===`male`?`M`:n.sex===`female`?`F`:null,nationality:Q(n.nationality),personal_number:Q(n.personalNumber)},address:null,raw_data:{mrz_lines:e.split(`
58
- `),aamva_version:null}})}catch{return null}},sg=e=>{let t=e.replace(/<LF>|<CR>|<RS>/gi,`
59
- `).replace(/\r\n|\r/g,`
60
- `).replaceAll(``,`
61
- `),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(W.INVALID_DOCUMENT_AAMVA);let s=Q(o.DCG),c=Q(o.DAG),l=Q(o.DAI),u=Q(o.DAJ),d=Q(o.DAK),f=[c,l,[u,d].filter(Boolean).join(` `)].filter(Boolean).join(`, `);return Dm.parse({document:{source:`AAMVA`,type:i===`ID`?`ID`:`DRV`,issuing_country:s,number:Q(o.DAQ),issue_date:ag({value:o.DBD,country:s,source:`AAMVA`,kind:`issue`}),expiry_date:ag({value:o.DBA,country:s,source:`AAMVA`,kind:`expiry`}),optional_data:null},holder:{first_name:Q(o.DAC),last_name:Q(o.DCS),middle_name:Q(o.DAD),birth_date:ag({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}})},cg=[{format:`TD1`,lineCount:3,lineLength:30},{format:`TD2`,lineCount:2,lineLength:36},{format:`TD3`,lineCount:2,lineLength:44}],lg={0:`O`,1:`I`,8:`B`,B:`8`,I:`1`,O:`0`},ug=4096,dg=4,fg=`ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789<`,pg=e=>/^[A-Z0-9<]$/u.test(e),mg=e=>e.map(e=>e.normalize(`NFKC`).toUpperCase().replace(/\s+/gu,``)),hg=({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`},gg=(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===`<`:pg(t),_g=({character:e,type:t,necessaryOnly:n})=>{let r=new Set;if(gg(t,e)){if(n)return[e];r.add(e)}let i=lg[e];return i&&gg(t,i)&&r.add(i),[...r]},vg=({format:e,line:t,text:n,necessaryOnly:r})=>{let i=[``];for(let[a,o]of[...n].entries()){let n=_g({character:o,type:hg({format:e,line:t,position:a}),necessaryOnly:r});if(!n.length||(i=i.flatMap(e=>n.map(t=>`${e}${t}`)),i.length>ug))return[]}return i},yg=({text:e,length:t,first:n})=>{let r=[],i=e=>{!e.split(``).every(pg)||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&&fg.includes(n)&&i(`${e.slice(0,t)}${n}${e.slice(t)}`)}return r},bg=({lines:e,spec:t})=>{let n=[],r=e.map(e=>yg({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>dg)continue;let s=r[n]??[],c=o.length===0?yg({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},xg=({group:e,spec:t,necessaryOnly:n=!1})=>{let r=e.map((e,r)=>vg({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(`
62
- `));else for(let n of r[e]??[])a(e+1,[...t,n])};return a(0,[]),i},Sg=e=>{try{return rg(e.split(`
63
- `)).valid}catch{return!1}},Cg=e=>{let t=new Set,n=new Set,r=new Set,i=mg(e);for(let e of cg)for(let a of bg({lines:i,spec:e})){let i=a.join(`
64
- `);Sg(i)&&t.add(i);for(let t of xg({group:a,spec:e,necessaryOnly:!0}))Sg(t)&&n.add(t);for(let t of xg({group:a,spec:e}))Sg(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},wg=({result:e})=>{let t=Cg(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)));if(!t)return null;try{if(!rg(t.split(`
65
- `)).valid)return null;let e=og(t);return e?{type:`mrz`,code:t,payload:e}:null}catch{return null}},$={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};ql({language:V().default($.language),ocrEngine:nu([`auto`,`tiny`,`small`,`japanese`,`chinese-simplified`,`chinese-traditional`,`cyrillic`,`arabic`]).default($.ocrEngine),alignment:iu(`eyes-nose-mouth`).default($.alignment),maxPitch:U().positive().max(90).default($.maxPitch),minPitch:U().negative().min(-90).default($.minPitch),maxYaw:U().positive().max(90).default($.maxYaw),minYaw:U().negative().min(-90).default($.minYaw),maxRoll:U().positive().max(90).default($.maxRoll),minDocumentFaceAreaRatio:U().min(0).max(1).default($.minDocumentFaceAreaRatio),maxDocumentFaceAreaRatio:U().min(0).max(1).default($.maxDocumentFaceAreaRatio),minDocumentFaceWidthRatio:U().min(0).max(1).default($.minDocumentFaceWidthRatio),maxDocumentFaceWidthRatio:U().min(0).max(1).default($.maxDocumentFaceWidthRatio),minDocumentFaceHeightRatio:U().min(0).max(1).default($.minDocumentFaceHeightRatio),maxDocumentFaceHeightRatio:U().min(0).max(1).default($.maxDocumentFaceHeightRatio),minDocumentBoxRatio:U().min(0).max(1).default($.minDocumentBoxRatio),maxDocumentTextAngleDifference:U().min(0).max(90).default($.maxDocumentTextAngleDifference)}).refine(e=>e.minDocumentFaceAreaRatio<=e.maxDocumentFaceAreaRatio&&e.minDocumentFaceWidthRatio<=e.maxDocumentFaceWidthRatio&&e.minDocumentFaceHeightRatio<=e.maxDocumentFaceHeightRatio,W.INVALID_OPTIONS);var Tg=({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},Eg=({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)},Dg=({detections:e,threshold:t})=>e.toSorted((e,t)=>t.score-e.score).filter((e,n,r)=>!r.slice(0,n).some(n=>Eg({first:n.boundingRect,second:e.boundingRect})>t)),Og=({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}))}}),kg=({faces:e})=>{let t=[];for(let n of e)t.some(e=>Eg({first:e.boundingRect,second:n.boundingRect})>.3)||t.push(n);return t},Ag=({frameSize:e,tileSize:t})=>[...new Set([0,Math.round((e-t)/2),e-t])],jg=({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}),Mg=({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 Dg({detections:r,threshold:.4})},Ng=128,Pg=.1,Fg=4,Ig=({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},Lg=({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))},Rg=({heatmap:e,height:t,width:n})=>{if(e.length!==512*Ng)throw Error(W.INVALID_MODEL_OUTPUT);let r=[],i=1;for(let a=0;a<4;a+=1){let o=a*Ng*Ng,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<Pg)throw Error(W.DOCUMENT_NOT_FOUND);i=Math.min(i,s);let l=c%Ng,u=Math.floor(c/Ng),d=s*.3,f=0,p=0,m=0;for(let t=Math.max(0,u-Fg);t<=Math.min(127,u+Fg);t+=1)for(let n=Math.max(0,l-Fg);n<=Math.min(127,l+Fg);n+=1){let r=e[o+t*Ng+n]??0;r<d||(f+=r,p+=r*n,m+=r*t)}r.push({x:(f?p/f:l)*n/Ng,y:(f?m/f:u)*t/Ng})}if(i<Pg)throw Error(W.DOCUMENT_NOT_FOUND);return Lg({polygon:r})},zg=({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},Bg=V().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`}),Vg=[`faceStraight`,`faceUp`,`faceLeft`,`faceRight`,`faceSmile`],Hg=.5,Ug=.5,Wg=.7,Gg={faceDown:{pitch:20},faceLeft:{yaw:30},faceRight:{yaw:-30},faceTiltLeft:{roll:15},faceTiltRight:{roll:-15},faceUp:{pitch:-20}},Kg=nu(Vg),qg=V().min(1).max(255),Jg=nu([`enroll`,`unlock`,`forget`]);ql({token:V().min(32).max(128),userId:qg.optional()}).extend({poses:Gl(Kg).min(1).max(Vg.length),faces:Gl(Bg).min(1).max(Vg.length)});var Yg=Gl(U().finite()).length(512).refine(e=>Math.abs(Math.hypot(...e)-1)<.001);eu(Kg,Yg).and(ql({faceStraight:Yg}));var Xg=ql({pose:Kg,matched:zl(),score:U().min(-1).max(1)}),Zg=Gl(Kg).min(1).max(Vg.length).refine(e=>e[0]===`faceStraight`&&new Set(e).size===e.length);ql({operation:Jg,userId:qg.optional(),poses:Zg.optional()}).refine(e=>e.operation===`enroll`||e.userId!==void 0&&e.poses===void 0);var Qg=ql({userId:qg});Qg.extend({operation:Jg,poses:Gl(Kg).max(Vg.length),expiresAt:V()});var $g=Qg.extend({matched:zl(),matches:Gl(Xg).max(2),reason:ku.nullable()});ql({vectors:Gl(ql({pose:Kg,vector:Yg})).max(Vg.length),reason:ku.nullable()}),$g.extend({complete:zl(),token:V().optional()}),Qg.extend({token:V()}),ql({origin:V().nullable(),ip:V().nullable(),user_agent:V().nullable(),language:V().nullable()});var e_=.5,t_=.35,n_=.25,r_=({blendshapes:e,pose:t})=>{let n=e.eyeBlinkLeft??0,r=e.eyeBlinkRight??0,i=n,a=r;return i>=.5&&a<=.35&&i>=a+.25},i_=({axis:e,target:t,value:n})=>n>=t-5&&n<=t+5?null:e===`yaw`?t>0?n<t?`FACEKEY_TURN_HEAD_LEFT`:`FACEKEY_TURN_HEAD_LESS`:n>t?`FACEKEY_TURN_HEAD_RIGHT`:`FACEKEY_TURN_HEAD_LESS`:e===`pitch`?t>0?n<t?`FACEKEY_LOWER_HEAD`:`FACEKEY_LOWER_HEAD_LESS`:n>t?`FACEKEY_RAISE_HEAD`:`FACEKEY_RAISE_HEAD_LESS`:t>0?n<t?`FACEKEY_TILT_HEAD_LEFT`:`FACEKEY_TILT_HEAD_LESS`:n>t?`FACEKEY_TILT_HEAD_RIGHT`:`FACEKEY_TILT_HEAD_LESS`,a_=({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,o_=({blendshapes:e,pitch:t,yaw:n,roll:r,pose:i,options:a})=>{if(i===`faceSmile`)return a_({pitch:t,yaw:n,roll:r,options:a})||((e.mouthSmileLeft??0)>=.5&&(e.mouthSmileRight??0)>=.5?null:`FACEKEY_SMILE_REQUIRED`);if(i===`faceWinkLeft`)return a_({pitch:t,yaw:n,roll:r,options:a})||(r_({blendshapes:e,pose:i})?null:`FACEKEY_WINK_LEFT_REQUIRED`);let o=Gg[i];if(!o)return a_({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`}return o.roll===void 0?o.yaw===void 0?o.pitch===void 0?null:i_({axis:`pitch`,target:o.pitch,value:t}):i_({axis:`yaw`,target:o.yaw,value:n}):i_({axis:`roll`,target:o.roll,value:r})},s_=.6,c_=({first:e,second:t})=>{if(e.length!==t.length||e.length===0)throw Error(W.INVALID_MODEL_OUTPUT);let n=e.reduce((e,n,r)=>e+n*t[r],0);return Math.max(-1,Math.min(1,n))},l_=({score:e,threshold:t=s_})=>({matched:e>t,score:Math.round(e*100)/100}),u_=({first:e,second:t})=>Math.max(c_({first:e.rgb,second:t.rgb}),c_({first:e.grayscale,second:t.grayscale})),d_=({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}},f_=({outputs:e})=>{for(let t of new Set(Object.values(e)))t.dispose()},p_=async({label:e,session:t,feeds:n})=>{let r=performance.now();try{return await t.run(n)}catch(e){throw Error(Au({error:e,fallback:W.INFERENCE_FAILED}),{cause:e})}finally{for(let e of new Set(Object.values(n)))e.dispose();Pp({category:`inference`,duration:performance.now()-r,key:e})}},m_=224,h_=256,g_=[0,90,180,270],__=[.485,.456,.406],v_=[.229,.224,.225],y_=({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(W.IMAGE_PROCESSING_FAILED);let s=h_/Math.min(a,o),c=Math.round(a*s),l=Math.round(o*s),u=e.createCanvas(m_,m_),d=u.getContext(`2d`,{willReadFrequently:!0});if(!d)throw Error(W.IMAGE_PROCESSING_FAILED);d.drawImage(t,r,i,a,o,-Math.floor((c-m_)/2),-Math.floor((l-m_)/2),c,l);let{data:f}=d.getImageData(0,0,m_,m_);qp({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-__[e])/v_[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 p_({label:`document.orientation`,session:i,feeds:{x:e.tensor(`float32`,a,[1,3,m_,m_])}});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(W.INVALID_MODEL_OUTPUT);let t={0:e[0],90:e[1],180:e[2],270:e[3]},n=g_.reduce((e,n)=>t[n]>t[e]?n:e);return{rotation:n,confidence:t[n],scores:t}}finally{f_({outputs:o})}},loadDocumentOrientationDetector:t}},b_=({runtime:e})=>{let{detectDocumentOrientation:t,loadDocumentOrientationDetector:n}=y_({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(W.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);qp({canvas:i});let s=Ig({image:{data:o.data,height:256,width:256}}),c=await p_({label:`document.box`,session:await e.session({filename:r}),feeds:{img:e.tensor(`float32`,s,[1,3,256,256])}});try{let e=c.heatmap?.data;if(!(e instanceof Float32Array))throw Error(W.INVALID_MODEL_OUTPUT);try{let r=n%180?t.height:t.width;return{confidence:null,polygon:Rg({heatmap:e,height:n%180?t.width:t.height,width:r})}}catch(e){if(e instanceof Error&&e.message===W.DOCUMENT_NOT_FOUND)return null;throw e}}finally{f_({outputs:c})}},f=async({frame:e})=>{let n=await d({frame:e}),r=null;if(n){let i=cm({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=sm({polygon: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})});return{polygon:r,boundingRect:cm({polygon:r}),...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(W.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(W.IMAGE_PROCESSING_FAILED);let a=r.getImageData(0,0,n.width,n.height),o=n.width,s=n.height;qp({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}}},x_=({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)))}},S_=({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 Dg({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=Tg({data:a({frame:t,height:s,width:i}),height:s,width:i,normalize:e=>(e-127.5)/128}),l=new Float32Array(1228800);for(let e=0;e<3;e+=1)for(let t=0;t<s;t+=1)l.set(c.subarray(e*i*s+t*i,e*i*s+(t+1)*i),e*640*640+t*640);let u=await e.session({filename:Ip[n]}),d=await p_({label:`face.detector`,session:u,feeds:{[u.inputNames[0]]:e.tensor(`float32`,l,[1,3,640,640])}});try{return n===`standard`?Mg({outputs:jg({outputs:d}),scale:r,threshold:.5}):o({outputs:d,scale:r,threshold:.5})}finally{f_({outputs:d})}},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:Ip.low}),o=await p_({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 Dg({detections:r,threshold:.3})}finally{f_({outputs:o})}},l=async({detection:i,frame:a})=>{let{size:o,x:s,y:c}=x_({detection:i,frame:a}),l=t({frame:a,height:256,width:256,sourceRect:{x:s,y:c,width:o,height:o}}).data,u=await e.session({filename:`fl.ort`}),d=await p_({label:`face.landmarks`,session:u,feeds:{[u.inputNames[0]]:e.tensor(`float32`,Tg({data:l,height:256,width:256,normalize:e=>e/255}),[1,3,256,256])}});try{if(d.score.data[0]<.5)return null;let t=d.landmarks.data,l=Array.from({length:478},(e,n)=>({x:s+t[n*3]*o/256,y:c+t[n*3+1]*o/256,z:t[n*3+2]*o/256})),u=new Float32Array(292);for(let e=0;e<r.length;e+=1){let t=l[r[e]];u[e*2]=t.x,u[e*2+1]=t.y}let f=await e.session({filename:`fe.ort`}),p=await p_({label:`face.blendshape`,session:f,feeds:{[f.inputNames[0]]:e.tensor(`float32`,u,[1,146,2])}});try{let e=p[f.outputNames[0]].data,t=l[33],r=l[263],o=l[1],s=(o.y-(t.y+r.y)/2)/Math.abs(r.x-t.x)*100,c=(o.x-(t.x+r.x)/2)/Math.abs(r.x-t.x)*100;return{blendshapes:Object.fromEntries(n.map((t,n)=>[t,e[n]??0])),pitch:s-54,yaw:c-5,roll:Math.atan2(r.y-t.y,r.x-t.x)*180/Math.PI,boundingRect:i.boundingRect,mesh:{height:a.height,landmarks:l,width:a.width}}}finally{f_({outputs:p})}}finally{f_({outputs:d})}},u=async({faceDetector:t=`standard`}={})=>{i=t,await Promise.all([e.session({filename:Ip[t]}),e.session({filename:`fl.ort`}),e.session({filename:`fe.ort`})])},d=async({frame:e})=>{let t=i===`low`?await c({frame:e}):await s({frame:e,faceDetector:i});return(await Promise.all(t.map(t=>l({detection:t,frame:e})))).filter(e=>e!==null)},f=async e=>(await d({frame:e}))[0]??null,p=async({frame:t,tileHeight:n,tileWidth:r})=>{let i=[];for(let a of Ag({frameSize:t.height,tileSize:n}))for(let o of Ag({frameSize:t.width,tileSize:r})){let s=await e.createImageBitmap(t,o,a,r,n);try{let e=await d({frame:s});i.push(...e.map(e=>Og({face:e,x:o,y:a})))}finally{s.close()}}return i},m=async({frame:e})=>await p({frame:e,tileHeight:Math.ceil(e.height/2),tileWidth:Math.ceil(e.width/2)}),h=async({frame:e})=>{let t=await d({frame:e}),n=await p({frame:e,tileHeight:Math.ceil(e.height*.4),tileWidth:Math.ceil(e.width*.4)});return kg({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 Ag({frameSize:t.height,tileSize:n}))for(let o of Ag({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 Dg({detections:[...t,...n],threshold:.3})},y=async(e,t={})=>{let n=await d({frame:e});if(i!==`low`)return n;let r=await m({frame:e});return kg({faces:[...n,...r]})},b=({detection:e,face:t})=>zg({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)).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()}}}},C_=({runtime:e})=>{let{detectDocumentOrientation:t}=y_({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=d_,o=({frame:t,polygon:n,rotation:r=0})=>{let a=cm({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(W.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:cm({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`}}}},w_=({runtime:e,orientDocumentFrame:t,detectDocument:n,faceDetection:r,detectFace:i,detectPictureFaces:a})=>{let o=Jp({runtime:e}),s=[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],c={"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]]}},l=({points:e})=>[e.reduce((e,[t])=>e+t,0)/e.length,e.reduce((e,[,t])=>e+t,0)/e.length],u=({source:e,target:t})=>{if(e.length<2||e.length!==t.length)return null;let[n,r]=l({points:e}),[i,a]=l({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 u=s/o,d=c/o;return u*u+d*d<1e-8?null:[u,-d,i-u*n+d*r,d,u,a-d*n-u*r]},d=({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},f=({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},p=({alignment:t,face:n,frame:r})=>{let i=s.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(W.IMAGE_PROCESSING_FAILED);let o=c[t],s=o.landmarks.map(e=>{let t=e.map(e=>{let t=n.mesh.landmarks[e];return[t.x,t.y]});return l({points:t})}),p=u({source:s,target:o.target});if(!p||!p.every(Number.isFinite))return null;e.fillStyle=`rgb(128, 128, 128)`,e.fillRect(0,0,112,112),e.setTransform(p[0],p[3],p[1],p[4],p[2],p[5]),e.drawImage(r,0,0),e.setTransform(1,0,0,1,0,0);let m=i.map(([e,t])=>[p[0]*e+p[1]*t+p[2],p[3]*e+p[4]*t+p[5]]),h=d({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},_=f({face:g,grayscale:!1});if(!_)return null;let v=f({face:g,grayscale:!0});return v?{...g,normalized:{rgb:_,greyscale:v}}:null}finally{qp({canvas:a})}},m=async()=>await e.session({filename:`fm.ort`}),h=async({normalized:t})=>{let n=new Float32Array(37632);for(let e=0;e<12544;e+=1){let r=e*4;n[e*3]=(t[r]-127.5)/127.5,n[e*3+1]=(t[r+1]-127.5)/127.5,n[e*3+2]=(t[r+2]-127.5)/127.5}let r=await m(),i=await p_({label:`face.embedding`,session:r,feeds:{[r.inputNames[0]]:e.tensor(`float32`,n,[1,112,112,3])}});try{let e=i[r.outputNames[0]].data;if(!(e instanceof Float32Array))throw Error(W.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(W.INVALID_MODEL_OUTPUT);return Array.from(t,e=>e/n)}finally{f_({outputs:i})}},g=async({blob:t})=>{try{return await e.createImageBitmap(t)}catch(e){throw Error(W.IMAGE_DECODE_FAILED,{cause:e})}},_=async({face:e})=>{let t=await h({normalized:e.normalized.rgb});return{grayscale:await h({normalized:e.normalized.greyscale}),rgb:t}},v=async({face:e})=>{try{return await _({face:e})}catch(e){if(e instanceof Error&&e.message===W.INVALID_MODEL_OUTPUT)return null;throw e}},y=async()=>{let e=new Uint8ClampedArray(50176).fill(127);if(!await v({face:{normalized:{rgb:e,greyscale:e}}}))throw Error(W.INVALID_MODEL_OUTPUT)},b=async({pixels:t})=>{let n=e.createCanvas(112,112);try{let e=n.getContext(`2d`);if(!e)throw Error(W.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(W.IMAGE_ENCODE_FAILED);return i}finally{qp({canvas:n})}},x=async({face:e})=>{let t=await v({face:e});if(!t)return null;let[n,r]=await Promise.all([b({pixels:e.normalized.rgb}),b({pixels:e.normalized.greyscale})]);return{embeddings:t,images:{rgb:n,greyscale:r}}},S=async({alignment:e,face:t,frame:n})=>{let r=p({alignment:e,face:t,frame:n});return r?await v({face:r}):null},C=async({alignment:e,frame:t})=>{let n=await i(t);if(!n)throw Error(W.FACE_NOT_FOUND);let r=await S({alignment:e,face:n,frame:t});if(!r)throw Error(W.FACE_NOT_USABLE);return r},w=async({alignment:e,frame:t})=>{let n=await a(t,{forMatch:!0}),r=[];for(let i of n){let n=await S({alignment:e,face:i,frame:t});n&&r.push(n)}return r},T=async({alignment:e,frame:i})=>{let a=await n(i);if(!a)throw Error(W.DOCUMENT_NOT_FOUND);let o=await t({frame:i,polygon:a.polygon,orientation:a.orientation});if(!o)throw Error(W.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(W.DOCUMENT_FACE_NOT_FOUND);for(let t of n){let n=await S({alignment:e,face:t,frame:o.frame});if(n)return n}}finally{o.frame.close()}throw Error(W.FACE_NOT_USABLE)};return{prepareFace:p,loadFaceMatch:m,warmupFaceMatch:y,imageBitmap:g,readImage:o,preparedFaceEmbeddings:v,preparedFaceArtifacts:x,matchFaceWithDocument:async({document:e,documentFaceEmbeddings:t,referenceFaceEmbeddings:n,options:r,reference:i})=>{let a=null,o=null;try{let s=t;s||=(o=await g({blob:e}),await T({alignment:r.alignment,frame:o,language:r.language,ocrEngine:r.ocrEngine}));let c=n;return c||=(a=await g({blob:i}),await C({alignment:r.alignment,frame:a})),l_({score:u_({first:c,second:s}),threshold:r.threshold})}finally{a&&a.close(),o&&o.close()}},matchPictureWithFaces:async({options:e,picture:t,references:n,referenceFaceEmbeddings:r})=>{let i=await g({blob:t}),a=[];try{if(!r)for(let e of n){let t=await g({blob:e});a.push(t)}let t=await w({alignment:e.alignment,frame:i});if(!t.length)throw Error(W.NO_USABLE_CANDIDATES);let o=r?[...r]:[];for(let t of a)try{let n=await C({alignment:e.alignment,frame:t});o.push(n)}catch(e){if(!(e instanceof Error)||e.message!==W.FACE_NOT_FOUND&&e.message!==W.FACE_NOT_USABLE)throw e}let s=-1/0;for(let e of o)for(let n of t){let t=u_({first:n,second:e});s=Math.max(s,t)}if(!Number.isFinite(s))throw Error(W.NO_USABLE_REFERENCES);return l_({score:s,threshold:e.threshold})}finally{i.close();for(let e of a)e.close()}}}};export{It as $,Zp as A,Au as B,_m as C,im as D,am as E,Fp as F,Jt as G,Ut as H,Pp as I,Wt as J,Zt as K,Np as L,qp as M,Wp as N,om as O,Kp as P,Lt as Q,ju as R,gm as S,hm as T,Kt as U,nu as V,Yt as W,Vt as X,Xt as Y,zt as Z,zg as _,s_ as a,Le as at,sg as b,o_ as c,be as ct,e_ as d,r as dt,M as et,r_ as f,i as ft,Wg as g,Hg as h,b_ as i,ot as it,Jp as j,Xp as k,n_ as l,D as lt,Gg as m,C_ as n,Ye as nt,u_ as o,Fe as ot,Ug as p,Gt as q,S_ as r,gt as rt,c_ as s,E as st,w_ as t,jt as tt,t_ as u,a as ut,$ as v,vm as w,Dm as x,wg as y,W as z};