@neofaceid/web-sdk 1.15.0 → 1.15.2
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react"),require("react-dom"),require("face-api.js")):"function"==typeof define&&define.amd?define(["exports","react","react-dom","face-api.js"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).NeoFaceIdSdk={},e.React,e.ReactDOM,e.faceapi)}(this,(function(e,n,t,o){"use strict";var a=Object.defineProperty,r=(e,n,t)=>((e,n,t)=>n in e?a(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t)(e,"symbol"!=typeof n?n+"":n,t),i="undefined"!=typeof document?document.currentScript:null;function s(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const t in e)if("default"!==t){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>e[t]})}return n.default=e,Object.freeze(n)}const c=s(o);var d,l={};var u,p=function(){if(d)return l;d=1;var e=t;if("production"===process.env.NODE_ENV)l.createRoot=e.createRoot,l.hydrateRoot=e.hydrateRoot;else{var n=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;l.createRoot=function(t,o){n.usingClientEntryPoint=!0;try{return e.createRoot(t,o)}finally{n.usingClientEntryPoint=!1}},l.hydrateRoot=function(t,o,a){n.usingClientEntryPoint=!0;try{return e.hydrateRoot(t,o,a)}finally{n.usingClientEntryPoint=!1}}}return l}(),f={exports:{}},h={};var m,g,
|
|
1
|
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react"),require("react-dom"),require("face-api.js")):"function"==typeof define&&define.amd?define(["exports","react","react-dom","face-api.js"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).NeoFaceIdSdk={},e.React,e.ReactDOM,e.faceapi)}(this,(function(e,n,t,o){"use strict";var a=Object.defineProperty,r=(e,n,t)=>((e,n,t)=>n in e?a(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t)(e,"symbol"!=typeof n?n+"":n,t),i="undefined"!=typeof document?document.currentScript:null;function s(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const t in e)if("default"!==t){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>e[t]})}return n.default=e,Object.freeze(n)}const c=s(o);var d,l={};var u,p=function(){if(d)return l;d=1;var e=t;if("production"===process.env.NODE_ENV)l.createRoot=e.createRoot,l.hydrateRoot=e.hydrateRoot;else{var n=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;l.createRoot=function(t,o){n.usingClientEntryPoint=!0;try{return e.createRoot(t,o)}finally{n.usingClientEntryPoint=!1}},l.hydrateRoot=function(t,o,a){n.usingClientEntryPoint=!0;try{return e.hydrateRoot(t,o,a)}finally{n.usingClientEntryPoint=!1}}}return l}(),f={exports:{}},h={};var m,g,b={};
|
|
2
2
|
/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.development.js
|
|
@@ -7,5 +7,5 @@
|
|
|
7
7
|
*
|
|
8
8
|
* This source code is licensed under the MIT license found in the
|
|
9
9
|
* LICENSE file in the root directory of this source tree.
|
|
10
|
-
*/function v(){return m||(m=1,"production"!==process.env.NODE_ENV&&function(){var e=n,t=Symbol.for("react.element"),o=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),h=Symbol.for("react.offscreen"),m=Symbol.iterator;var g=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function v(e){for(var n=arguments.length,t=new Array(n>1?n-1:0),o=1;o<n;o++)t[o-1]=arguments[o];!function(e,n,t){var o=g.ReactDebugCurrentFrame.getStackAddendum();""!==o&&(n+="%s",t=t.concat([o]));var a=t.map((function(e){return String(e)}));a.unshift("Warning: "+n),Function.prototype.apply.call(console[e],console,a)}("error",e,t)}var b;function y(e){return e.displayName||"Context"}function x(e){if(null==e)return null;if("number"==typeof e.tag&&v("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),"function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case a:return"Fragment";case o:return"Portal";case i:return"Profiler";case r:return"StrictMode";case l:return"Suspense";case u:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case c:return y(e)+".Consumer";case s:return y(e._context)+".Provider";case d:return function(e,n,t){var o=e.displayName;if(o)return o;var a=n.displayName||n.name||"";return""!==a?t+"("+a+")":t}(e,e.render,"ForwardRef");case p:var n=e.displayName||null;return null!==n?n:x(e.type)||"Memo";case f:var t=e,h=t._payload,m=t._init;try{return x(m(h))}catch(g){return null}}return null}b=Symbol.for("react.module.reference");var E,R,k,T,O,_,I,S=Object.assign,N=0;function C(){}C.__reactDisabledLog=!0;var A,j=g.ReactCurrentDispatcher;function P(e,n,t){if(void 0===A)try{throw Error()}catch(a){var o=a.stack.trim().match(/\n( *(at )?)/);A=o&&o[1]||""}return"\n"+A+e}var D,L=!1,F="function"==typeof WeakMap?WeakMap:Map;function M(e,n){if(!e||L)return"";var t,o=D.get(e);if(void 0!==o)return o;L=!0;var a,r=Error.prepareStackTrace;Error.prepareStackTrace=void 0,a=j.current,j.current=null,function(){if(0===N){E=console.log,R=console.info,k=console.warn,T=console.error,O=console.group,_=console.groupCollapsed,I=console.groupEnd;var e={configurable:!0,enumerable:!0,value:C,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}N++}();try{if(n){var i=function(){throw Error()};if(Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(i,[])}catch(h){t=h}Reflect.construct(e,[],i)}else{try{i.call()}catch(h){t=h}e.call(i.prototype)}}else{try{throw Error()}catch(h){t=h}e()}}catch(m){if(m&&t&&"string"==typeof m.stack){for(var s=m.stack.split("\n"),c=t.stack.split("\n"),d=s.length-1,l=c.length-1;d>=1&&l>=0&&s[d]!==c[l];)l--;for(;d>=1&&l>=0;d--,l--)if(s[d]!==c[l]){if(1!==d||1!==l)do{if(d--,--l<0||s[d]!==c[l]){var u="\n"+s[d].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),"function"==typeof e&&D.set(e,u),u}}while(d>=1&&l>=0);break}}}finally{L=!1,j.current=a,function(){if(0==--N){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:S({},e,{value:E}),info:S({},e,{value:R}),warn:S({},e,{value:k}),error:S({},e,{value:T}),group:S({},e,{value:O}),groupCollapsed:S({},e,{value:_}),groupEnd:S({},e,{value:I})})}N<0&&v("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=r}var p=e?e.displayName||e.name:"",f=p?P(p):"";return"function"==typeof e&&D.set(e,f),f}function U(e,n,t){if(null==e)return"";if("function"==typeof e)return M(e,!(!(o=e.prototype)||!o.isReactComponent));var o;if("string"==typeof e)return P(e);switch(e){case l:return P("Suspense");case u:return P("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case d:return M(e.render,!1);case p:return U(e.type,n,t);case f:var a=e,r=a._payload,i=a._init;try{return U(i(r),n,t)}catch(s){}}return""}D=new F;var $=Object.prototype.hasOwnProperty,B={},W=g.ReactDebugCurrentFrame;function q(e){if(e){var n=e._owner,t=U(e.type,e._source,n?n.type:null);W.setExtraStackFrame(t)}else W.setExtraStackFrame(null)}var z=Array.isArray;function K(e){return z(e)}function V(e){return""+e}function G(e){if(function(e){try{return V(e),!1}catch(n){return!0}}(e))return v("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",function(e){return"function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object"}(e)),V(e)}var H,X,Y=g.ReactCurrentOwner,J={key:!0,ref:!0,__self:!0,__source:!0};function Z(e,n,o,a,r){var i,s={},c=null,d=null;for(i in void 0!==o&&(G(o),c=""+o),function(e){if($.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return void 0!==e.key}(n)&&(G(n.key),c=""+n.key),function(e){if($.call(e,"ref")){var n=Object.getOwnPropertyDescriptor(e,"ref").get;if(n&&n.isReactWarning)return!1}return void 0!==e.ref}(n)&&(d=n.ref,function(e){"string"==typeof e.ref&&Y.current}(n)),n)$.call(n,i)&&!J.hasOwnProperty(i)&&(s[i]=n[i]);if(e&&e.defaultProps){var l=e.defaultProps;for(i in l)void 0===s[i]&&(s[i]=l[i])}if(c||d){var u="function"==typeof e?e.displayName||e.name||"Unknown":e;c&&function(e,n){var t=function(){H||(H=!0,v("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",n))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}(s,u),d&&function(e,n){var t=function(){X||(X=!0,v("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",n))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}(s,u)}return function(e,n,o,a,r,i,s){var c={$$typeof:t,type:e,key:n,ref:o,props:s,_owner:i,_store:{}};return Object.defineProperty(c._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(c,"_self",{configurable:!1,enumerable:!1,writable:!1,value:a}),Object.defineProperty(c,"_source",{configurable:!1,enumerable:!1,writable:!1,value:r}),Object.freeze&&(Object.freeze(c.props),Object.freeze(c)),c}(e,c,d,r,a,Y.current,s)}var Q,ee=g.ReactCurrentOwner,ne=g.ReactDebugCurrentFrame;function te(e){if(e){var n=e._owner,t=U(e.type,e._source,n?n.type:null);ne.setExtraStackFrame(t)}else ne.setExtraStackFrame(null)}function oe(e){return"object"==typeof e&&null!==e&&e.$$typeof===t}function ae(){if(ee.current){var e=x(ee.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}Q=!1;var re={};function ie(e,n){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var t=function(e){var n=ae();if(!n){var t="string"==typeof e?e:e.displayName||e.name;t&&(n="\n\nCheck the top-level render call using <"+t+">.")}return n}(n);if(!re[t]){re[t]=!0;var o="";e&&e._owner&&e._owner!==ee.current&&(o=" It was passed a child from "+x(e._owner.type)+"."),te(e),v('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,o),te(null)}}}function se(e,n){if("object"==typeof e)if(K(e))for(var t=0;t<e.length;t++){var o=e[t];oe(o)&&ie(o,n)}else if(oe(e))e._store&&(e._store.validated=!0);else if(e){var a=function(e){if(null===e||"object"!=typeof e)return null;var n=m&&e[m]||e["@@iterator"];return"function"==typeof n?n:null}(e);if("function"==typeof a&&a!==e.entries)for(var r,i=a.call(e);!(r=i.next()).done;)oe(r.value)&&ie(r.value,n)}}function ce(e){var n,t=e.type;if(null!=t&&"string"!=typeof t){if("function"==typeof t)n=t.propTypes;else{if("object"!=typeof t||t.$$typeof!==d&&t.$$typeof!==p)return;n=t.propTypes}if(n){var o=x(t);!function(e,n,t,o,a){var r=Function.call.bind($);for(var i in e)if(r(e,i)){var s=void 0;try{if("function"!=typeof e[i]){var c=Error((o||"React class")+": "+t+" type `"+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[i]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw c.name="Invariant Violation",c}s=e[i](n,i,o,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(d){s=d}!s||s instanceof Error||(q(a),v("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",o||"React class",t,i,typeof s),q(null)),s instanceof Error&&!(s.message in B)&&(B[s.message]=!0,q(a),v("Failed %s type: %s",t,s.message),q(null))}}(n,e.props,"prop",o,e)}else if(void 0!==t.PropTypes&&!Q){Q=!0,v("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",x(t)||"Unknown")}"function"!=typeof t.getDefaultProps||t.getDefaultProps.isReactClassApproved||v("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}var de={};function le(e,n,o,m,g,w){var y=function(e){return"string"==typeof e||"function"==typeof e||e===a||e===i||e===r||e===l||e===u||e===h||"object"==typeof e&&null!==e&&(e.$$typeof===f||e.$$typeof===p||e.$$typeof===s||e.$$typeof===c||e.$$typeof===d||e.$$typeof===b||void 0!==e.getModuleId)}(e);if(!y){var E="";(void 0===e||"object"==typeof e&&null!==e&&0===Object.keys(e).length)&&(E+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var R;E+=ae(),null===e?R="null":K(e)?R="array":void 0!==e&&e.$$typeof===t?(R="<"+(x(e.type)||"Unknown")+" />",E=" Did you accidentally export a JSX literal instead of a component?"):R=typeof e,v("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",R,E)}var k=Z(e,n,o,g,w);if(null==k)return k;if(y){var T=n.children;if(void 0!==T)if(m)if(K(T)){for(var O=0;O<T.length;O++)se(T[O],e);Object.freeze&&Object.freeze(T)}else v("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else se(T,e)}if($.call(n,"key")){var _=x(e),I=Object.keys(n).filter((function(e){return"key"!==e})),S=I.length>0?"{key: someKey, "+I.join(": ..., ")+": ...}":"{key: someKey}";if(!de[_+S])v('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',S,_,I.length>0?"{"+I.join(": ..., ")+": ...}":"{}",_),de[_+S]=!0}return e===a?function(e){for(var n=Object.keys(e.props),t=0;t<n.length;t++){var o=n[t];if("children"!==o&&"key"!==o){te(e),v("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",o),te(null);break}}null!==e.ref&&(te(e),v("Invalid attribute `ref` supplied to `React.Fragment`."),te(null))}(k):ce(k),k}var ue=function(e,n,t){return le(e,n,t,!1)},pe=function(e,n,t){return le(e,n,t,!0)};w.Fragment=a,w.jsx=ue,w.jsxs=pe}()),w}var b=(g||(g=1,"production"===process.env.NODE_ENV?f.exports=function(){if(u)return h;u=1;var e=n,t=Symbol.for("react.element"),o=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,r=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function s(e,n,o){var s,c={},d=null,l=null;for(s in void 0!==o&&(d=""+o),void 0!==n.key&&(d=""+n.key),void 0!==n.ref&&(l=n.ref),n)a.call(n,s)&&!i.hasOwnProperty(s)&&(c[s]=n[s]);if(e&&e.defaultProps)for(s in n=e.defaultProps)void 0===c[s]&&(c[s]=n[s]);return{$$typeof:t,type:e,key:d,ref:l,props:c,_owner:r.current}}return h.Fragment=o,h.jsx=s,h.jsxs=s,h}():f.exports=v()),f.exports);class y extends Error{constructor(e){super(e),this.name="CameraPermissionDenied"}}class x{constructor(e){r(this,"stream"),this.stream=e}getStream(){return this.stream}stop(){this.stream.getTracks().forEach((e=>e.stop()))}}const E=()=>{const e=n.useRef(null),[t,o]=n.useState(!1),a=n.useRef(!1);return{startCamera:n.useCallback((async n=>{const t=e.current;if(t)return t.getStream();if(a.current){await new Promise((e=>setTimeout(e,100)));const n=e.current;if(n)return n.getStream()}a.current=!0;try{const t=n||(()=>{const e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);return{video:{facingMode:"user",width:{ideal:e?640:1280},height:{ideal:e?480:720},aspectRatio:{ideal:1.777777778}},audio:!1}})(),r=await navigator.mediaDevices.getUserMedia(t),i=new x(r);return e.current=i,o(!0),a.current=!1,r}catch(r){if(a.current=!1,r instanceof Error){if("NotAllowedError"===r.name||"PermissionDeniedError"===r.name)throw new y("Permissão para acessar a câmera foi negada pelo usuário");if("NotFoundError"===r.name||"DevicesNotFoundError"===r.name)throw new Error("Nenhuma câmera foi encontrada no dispositivo");if("NotReadableError"===r.name||"TrackStartError"===r.name)throw new Error("A câmera já está sendo usada por outro aplicativo");if("OverconstrainedError"===r.name||"ConstraintNotSatisfiedError"===r.name)throw new Error("As configurações solicitadas não são suportadas pela câmera")}throw new Error(`Erro ao inicializar câmera: ${r instanceof Error?r.message:String(r)}`)}}),[]),stopCamera:n.useCallback((n=>{const t=e.current;t&&t.getStream()===n&&(t.stop(),e.current=null,o(!1),a.current=!1)}),[]),cleanup:n.useCallback((()=>{e.current&&(e.current.stop(),e.current=null,o(!1),a.current=!1)}),[]),isActive:t}};var R=(e=>(e.NETWORK="NetworkError",e.NETWORK_ERROR="NetworkError",e.INVALID_TOKEN="InvalidTokenError",e.RECOGNITION_FAILED="RecognitionFailedError",e.LOGIN_FAILED="LoginFailedError",e.VALIDATION_ERROR="ValidationError",e.API_ERROR="ApiError",e.PERSON_NOT_FOUND="PersonNotFoundError",e.INITIALIZATION_ERROR="InitializationError",e.CAMERA_ERROR="CameraError",e.NO_CAMERA="NoCameraError",e.CAPTURE_ERROR="CaptureError",e.NOT_FOUND="NotFoundError",e.UNKNOWN="UnknownError",e))(R||{});class k extends Error{constructor(e,n){super(e),r(this,"type"),this.name=n,this.type=n}getFriendlyMessage(){if(/[áéíóúãõç]/i.test(this.message))return this.message;switch(this.type){case"NetworkError":return this.message.includes("timeout")?"A conexão demorou muito. Tente novamente.":"Não foi possível conectar ao servidor. Verifique sua internet.";case"InvalidTokenError":return"Falha na autenticação do aplicativo. Entre em contato com o suporte.";case"CameraError":case"NoCameraError":return"Não conseguimos acessar sua câmera. Verifique as permissões do navegador.";case"LoginFailedError":case"RecognitionFailedError":return"Não foi possível reconhecer seu rosto. Tente se posicionar em um local mais iluminado.";case"ValidationError":return"Dados inválidos ou rosto não detectado corretamente.";case"ApiError":return this.message.includes("400")?"Requisição inválida. Tente novamente.":this.message.includes("500")?"Ocorreu um erro interno no sistema. Tente mais tarde.":"O serviço encontrou um problema inesperado.";default:return"Ocorreu um erro inesperado. Por favor, tente novamente."}}}const T={},O={development:"http://localhost:8000",sandbox:"https://sandbox-core.neofaceid.com",production:"https://core.neofaceid.com.br"};let _={baseUrl:O.sandbox,applicationToken:null,environment:"sandbox",initialized:!1};function I(){return _.initialized,_.baseUrl}const S=()=>I(),N=()=>{const e="localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname||""===window.location.hostname;if(!window.isSecureContext&&!e)throw new k("Secure context (HTTPS) is required for this operation",R.NETWORK)},C=()=>{const e=new AbortController,n=setTimeout((()=>e.abort()),1e4);return e.signal.addEventListener("abort",(()=>clearTimeout(n))),e},A=async e=>new Promise(((n,t)=>{const o=new Image;o.onload=()=>{const e=document.createElement("canvas");e.width=o.width,e.height=o.height;const a=e.getContext("2d");a?(a.drawImage(o,0,0),e.toBlob((e=>{e?n(e):t(new Error("Failed to compress image"))}),"image/jpeg",.7)):t(new Error("Failed to get canvas context"))},o.onerror=()=>{t(new Error("Failed to load image"))},o.src=URL.createObjectURL(e)})),j=async e=>new Promise(((n,t)=>{const o=new Image;o.onload=()=>{const e=1280;let a=o.width,r=o.height;a>r&&a>e?(r=r*e/a,a=e):r>e&&(a=a*e/r,r=e);const i=document.createElement("canvas");i.width=a,i.height=r;const s=i.getContext("2d");s?(s.drawImage(o,0,0,a,r),i.toBlob((e=>{e?n(e):t(new Error("Failed to compress document image"))}),"image/jpeg",.75)):t(new Error("Failed to get canvas context"))},o.onerror=()=>{t(new Error("Failed to load document image"))},o.src=URL.createObjectURL(e)})),P=async e=>{N();const n=C();try{const t=await fetch(`${S()}/api/v1/auth/application/validate_token/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":e},body:JSON.stringify({}),signal:n.signal});if(!t.ok)throw new k(`API Error ${t.status}`,R.INVALID_TOKEN);return t.ok}catch(t){if(t instanceof Error){if("AbortError"===t.name)throw new k("Request timeout",R.NETWORK_ERROR);throw new k(t.message,R.NETWORK_ERROR)}throw new k("Unknown error",R.NETWORK_ERROR)}},D=async(e,n,t,o)=>{N();const a=C(),r=await A(t),i=await A(o);try{const t=new FormData;t.append("face_image",r,"face.jpg"),t.append("document_image",i,"document.jpg");const o=await fetch(`${S()}/api/v1/onboardings/${encodeURIComponent(n)}/complete`,{method:"POST",headers:{"X-App-Token":e},body:t,signal:a.signal}),s=await o.json();if(!o.ok){if(401===o.status||403===o.status)throw new k("Token de aplicação inválido ou expirado",R.INVALID_TOKEN);if(404===o.status)throw new k("Link de onboarding não encontrado",R.NOT_FOUND);throw new k((null==s?void 0:s.error)||(null==s?void 0:s.message)||"Falha ao concluir onboarding",R.NETWORK)}return{success:!!s.success,message:s.message||"Onboarding concluído",person_id:s.person_id,identity_data_id:s.identity_data_id,confidence_score:s.confidence_score,processing_time:s.processing_time}}catch(s){if(s instanceof Error){if("AbortError"===s.name)throw new k("Tempo de requisição excedido",R.NETWORK);if(s instanceof k)throw s;throw new k(s.message,R.NETWORK)}throw new k("Erro desconhecido",R.NETWORK_ERROR)}},L=async(e,n)=>{N();const t=C(),o=await A(e);try{const e=new FormData;e.append("face_frames",o);const a=await fetch(`${S()}/api/v1/external/recognition/face/`,{method:"POST",headers:{"X-App-Token":n},body:e,signal:t.signal});if(!a.ok){if(401===a.status||403===a.status)throw new k("Invalid or expired application token",R.INVALID_TOKEN);throw new k(`Server returned status ${a.status}`,R.NETWORK)}const r=await a.json();if(!r.success)throw new k(r.message||"Recognition failed",R.RECOGNITION_FAILED);return{accessToken:r.accessToken,payload:r.payload}}catch(a){if(a instanceof Error){if("AbortError"===a.name)throw new k("Request timed out",R.NETWORK);if(a instanceof k)throw a;throw new k(a.message,R.NETWORK)}throw new k("Unknown error occurred",R.NETWORK_ERROR)}},F=async(e,n)=>{var t,o,a,r,i;N();const s=C(),c=await A(e);try{const e=await c.arrayBuffer(),d=btoa(new Uint8Array(e).reduce(((e,n)=>e+String.fromCharCode(n)),"")),l=await fetch(`${S()}/api/v1/login/donor/face/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({image:d,biometric_type:"FACE"}),signal:s.signal});if(!l.ok){if(401===l.status||403===l.status)throw new k("Invalid application token",R.INVALID_TOKEN);if(l.status>=500)throw new k(`Server Error ${l.status}`,R.API_ERROR);throw new k(`API Error ${l.status}`,R.API_ERROR)}const u=await l.json();if(!u.success)throw new k(u.message||"Login failed",R.LOGIN_FAILED);return{success:!0,accessToken:u.accessToken,alias:u.alias,user:{id:(null==(t=u.user)?void 0:t.id)||"",email:(null==(o=u.user)?void 0:o.email)||"",role:(null==(a=u.user)?void 0:a.role)||"",validated:(null==(r=u.user)?void 0:r.validated)||!1,active:(null==(i=u.user)?void 0:i.active)||!1},person:u.person?{name:u.person.name||"",birth_date:u.person.birth_date||""}:void 0,confidence_score:u.confidence_score,recognition_id:u.recognition_id}}catch(d){if(d instanceof Error){if("AbortError"===d.name)throw new k("Request timed out",R.NETWORK);if(d instanceof k)throw d;throw new k(d.message,R.NETWORK)}throw new k("Unknown error occurred",R.NETWORK_ERROR)}},M=async(e,n,t,o=.8,a,r)=>{var i;N();const s=C(),c=await A(e),d=await new Promise(((e,n)=>{const t=new FileReader;t.onload=()=>{const n=t.result;e(n.split(",")[1])},t.onerror=n,t.readAsDataURL(c)}));try{const e={biometric_data:d,type_of_identification:"FACE",purpose:t,confidence_threshold:o};a&&(e.signature=a);const c=await fetch(`${S()}/api/v1/external/recognition/purpose/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify(e),signal:s.signal});if(!c.ok){if(401===c.status||403===c.status)throw new k("Invalid or expired application token",R.INVALID_TOKEN);throw new k(`Server returned status ${c.status}`,R.NETWORK)}const l=await c.json();return{success:l.success,personName:l.person_name||(null==(i=l.person)?void 0:i.name),email:l.email||(null==r?void 0:r.email),cpf:l.cpf||(null==r?void 0:r.cpf),confidenceScore:l.confidence_score,accessToken:l.access_token,payload:l.payload,signature:a,sessionId:null==r?void 0:r.sessionId}}catch(l){if(l instanceof Error){if("AbortError"===l.name)throw new k("Request timed out",R.NETWORK);if(l instanceof k)throw l;throw new k(l.message,R.NETWORK)}throw new k("Unknown error occurred",R.NETWORK_ERROR)}},U=async(e,n,t,o)=>{var a,r,i,s,c,d,l,u;if(N(),!n||0===n.length)throw new k("At least one face photo is required for biometric registration",R.VALIDATION_ERROR);if(n.length>5)throw new k("Maximum of 5 face photos allowed",R.VALIDATION_ERROR);const p=C();try{const h=await Promise.all(n.map((async e=>{const n=await A(e);return new Promise(((e,t)=>{const o=new FileReader;o.onload=()=>{const n=o.result;e(n)},o.onerror=t,o.readAsDataURL(n)}))})));let m,g;if(null==o?void 0:o.documentFront){const e=await j(o.documentFront);m=await new Promise(((n,t)=>{const o=new FileReader;o.onload=()=>n(o.result),o.onerror=t,o.readAsDataURL(e)}))}if(null==o?void 0:o.documentBack){const e=await j(o.documentBack);g=await new Promise(((n,t)=>{const o=new FileReader;o.onload=()=>n(o.result),o.onerror=t,o.readAsDataURL(e)}))}const w={name:e.name,birth_date:e.birth_date,cpf:e.cpf,email:e.email,password:e.password,password_confirm:e.password,face_photos:h};m&&(w.document_images=[{front:m,back:g||void 0,type:(null==o?void 0:o.documentType)||"RG"}]);const v=await fetch(`${S()}/api/v1/signup/donor/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":t},body:JSON.stringify(w),signal:p.signal});if(!v.ok){if(401===v.status||403===v.status)throw new k("Invalid or expired application token",R.INVALID_TOKEN);try{const e=await v.json();if(e.errors){const n=Object.entries(e.errors).map((([e,n])=>`${"password"===e?"senha":"password_confirm"===e?"confirmação de senha":e}: ${Array.isArray(n)?n.join(", "):String(n)}`)).join("; ");throw new k(`Erro de validação: ${n}`,R.VALIDATION_ERROR)}if("fraud_detected"===e.error)throw new k("Fraud detected in biometric images. Registration blocked.",R.VALIDATION_ERROR);if("user_exists"===e.error||"ALREADY_EXISTS"===e.error_code)throw new k("User with this email already exists",R.VALIDATION_ERROR);if("person_exists"===e.error)throw new k("Person with this CPF already exists",R.VALIDATION_ERROR);const n=e.message||e.error||`Server returned status ${v.status}`;throw new k(n,R.VALIDATION_ERROR)}catch(f){if(f instanceof k)throw f;throw new k(`Server returned status ${v.status}`,R.NETWORK)}}const b=await v.json();return 202===v.status&&(null==(a=b.data)?void 0:a.task_id)?{success:b.success,message:b.message||"Registration is being processed. You will receive an email when completed.",task_id:b.data.task_id,status:b.data.status||"processing",person_id:void 0,user_id:void 0,person_validated:void 0,face_processing:void 0,onboarding_link:void 0}:{success:b.success,message:b.message,person_id:(null==(r=b.data)?void 0:r.person_id)||b.person_id,user_id:(null==(i=b.data)?void 0:i.user_id)||b.user_id,person_validated:(null==(s=b.data)?void 0:s.person_validated)||b.person_validated,face_processing:(null==(c=b.data)?void 0:c.face_processing)||b.face_processing,onboarding_link:(null==(d=b.data)?void 0:d.onboarding_link)||b.onboarding_link,task_id:null==(l=b.data)?void 0:l.task_id,status:null==(u=b.data)?void 0:u.status}}catch(h){if(h instanceof Error){if("AbortError"===h.name)throw new k("Request timed out",R.NETWORK);if(h instanceof k)throw h;throw new k(h.message,R.NETWORK)}throw new k("Unknown error occurred",R.NETWORK_ERROR)}},$=async(e,n,t)=>{N();const o=C();try{const a=await fetch(`${S()}/api/v1/auth/login/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":t},body:JSON.stringify({email:e,password:n}),signal:o.signal});if(!a.ok){if(401===a.status||403===a.status)throw new k("Email ou senha inválidos",R.INVALID_TOKEN);throw new k(`API Error ${a.status}`,R.API_ERROR)}const r=await a.json();return{success:!0,accessToken:r.access_token||r.access,alias:r.user&&r.user.alias||r.alias,user:{id:r.user&&r.user.id||"",email:r.user&&r.user.email||"",role:r.user&&r.user.role||"",validated:r.user&&r.user.validated||!1,active:r.user&&r.user.active||!1}}}catch(a){if(a instanceof Error){if("AbortError"===a.name)throw new k("Request timed out",R.NETWORK);if(a instanceof k)throw a;throw new k(a.message,R.NETWORK)}throw new k("Unknown error occurred",R.NETWORK_ERROR)}},B=async(e={})=>{N();const{durationMs:n=3e3,onProgress:t}=e;return new Promise((async(e,o)=>{let a=null;const r=[];try{a=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:{ideal:640},height:{ideal:480}},audio:!1});const i=(()=>{const e=["video/mp4;codecs=avc1","video/mp4","video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"];for(const n of e)if(MediaRecorder.isTypeSupported(n))return n;return""})();let s;try{s=i?new MediaRecorder(a,{mimeType:i,videoBitsPerSecond:1e6}):new MediaRecorder(a,{videoBitsPerSecond:1e6})}catch{s=new MediaRecorder(a)}const c=s.mimeType||i;if(s.ondataavailable=e=>{e.data.size>0&&r.push(e.data)},s.onstop=()=>{a&&a.getTracks().forEach((e=>e.stop()));const n=new Blob(r,{type:c});e(n)},s.onerror=e=>{a&&a.getTracks().forEach((e=>e.stop())),o(new k(`Recording error: ${e}`,R.CAPTURE_ERROR))},s.start(100),t){const e=100;let o=0;const a=setInterval((()=>{o+=e;const r=Math.min(100,o/n*100);t(r),o>=n&&clearInterval(a)}),e)}setTimeout((()=>{s&&"recording"===s.state&&s.stop()}),n)}catch(i){a&&a.getTracks().forEach((e=>e.stop())),i instanceof Error?"NotAllowedError"===i.name?o(new k("Camera permission denied",R.CAMERA_ERROR)):"NotFoundError"===i.name?o(new k("No camera found",R.NO_CAMERA)):o(new k(i.message,R.CAPTURE_ERROR)):o(new k("Failed to record video",R.CAPTURE_ERROR))}}))},W=async(e,n,t)=>{var o,a;if(N(),!e)throw new k("personId is required",R.VALIDATION_ERROR);if(!n)throw new k("jwtToken is required",R.VALIDATION_ERROR);if(!t||0===t.length)throw new k("At least one document image is required",R.VALIDATION_ERROR);const r=await Promise.all(t.map((async e=>{const n=await j(e);return t=n,new Promise(((e,n)=>{const o=new FileReader;o.onload=()=>{const n=o.result;e(n.includes(",")?n.split(",")[1]:n)},o.onerror=()=>n(new k("Failed to convert image to base64",R.CAPTURE_ERROR)),o.readAsDataURL(t)}));var t}))),i=C();try{const t=await fetch(`${S()}/api/v1/donors/${e}/documents/`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({document_images:r}),signal:i.signal}),s=await t.json();if(!t.ok)throw new k((null==s?void 0:s.message)||`API Error ${t.status}`,R.NETWORK_ERROR);return{success:!0,taskId:(null==(o=s.data)?void 0:o.task_id)??"",status:(null==(a=s.data)?void 0:a.status)??"processing",message:s.message??"Documents submitted for processing"}}catch(s){if(s instanceof k)throw s;if(s instanceof Error){if("AbortError"===s.name)throw new k("Request timeout",R.NETWORK_ERROR);throw new k(s.message,R.NETWORK_ERROR)}throw new k("Unknown error occurred",R.NETWORK_ERROR)}},q=(e,n)=>{switch(n.type){case"PERMISSION_GRANTED":case"RESET":return{status:"ready"};case"PERMISSION_DENIED":return{status:"error",message:"Permissão para acessar a câmera foi negada"};case"START_CAPTURE":return{status:"capturing"};case"UPLOAD_START":return{status:"uploading"};case"UPLOAD_SUCCESS":return{status:"success"};case"UPLOAD_ERROR":case"SET_ERROR":return{status:"error",message:n.message};default:return e}},z={overlay:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.8)",display:"flex",justifyContent:"center",alignItems:"center",zIndex:1e3},modal:{backgroundColor:"#000",borderRadius:"12px",overflow:"hidden",position:"relative",width:"60%",maxWidth:"600px",maxHeight:"80vh"},video:{width:"100%",height:"auto",display:"block"},canvas:{display:"none"},guide:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"200px",height:"200px",border:"2px solid rgba(255, 255, 255, 0.5)",borderRadius:"50%",pointerEvents:"none"},controls:{position:"absolute",bottom:"20px",left:0,right:0,display:"flex",justifyContent:"center",gap:"10px"},button:{padding:"12px 24px",borderRadius:"24px",border:"none",backgroundColor:"#007AFF",color:"white",fontSize:"16px",fontWeight:"bold",cursor:"pointer"},message:{position:"absolute",top:"20px",left:0,right:0,textAlign:"center",color:"white",fontSize:"18px",fontWeight:"bold"},spinner:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"40px",height:"40px",border:"4px solid rgba(255, 255, 255, 0.3)",borderRadius:"50%",borderTopColor:"white",animation:"spin 1s linear infinite"},closeButton:{position:"absolute",top:"20px",right:"20px",backgroundColor:"transparent",border:"none",color:"white",fontSize:"24px",cursor:"pointer"}};function K({accessToken:e,onClose:t,onSuccess:o}){const a=n.useRef(null),r=n.useRef(null),i=n.useRef(null),s=n.useRef(null),d=n.useRef(null),[l,u]=n.useReducer(q,{status:"requestingPermission"}),[p,f]=n.useState(!1),[h,m]=n.useState(0),{startCamera:g,stopCamera:w}=E(),v=()=>{if(!a.current)return;const e=async()=>{if(a.current&&"ready"===l.status){try{const e=await c.detectAllFaces(a.current,new c.TinyFaceDetectorOptions),n=1===e.length,t=n&&(e=>{if(!a.current)return!1;const{box:n}=e,{videoWidth:t,videoHeight:o}=a.current,r=t/2,i=o/2,s=.4*t,c=.4*o;return n.x+n.width/2>r-s/2&&n.x+n.width/2<r+s/2&&n.y+n.height/2>i-c/2&&n.y+n.height/2<i+c/2})(e[0]);f(n&&t),n&&t&&0===h&&(d.current=window.setTimeout((()=>{"ready"===l.status&&(m((e=>e+1)),u({type:"START_CAPTURE"}))}),3e3))}catch(n){}s.current=window.setTimeout(e,100)}};e()};n.useEffect((()=>((async()=>{try{await Promise.all([c.nets.tinyFaceDetector.loadFromUri("./models"),c.nets.faceLandmark68Net.loadFromUri("./models")])}catch(e){}})(),()=>{s.current&&window.clearTimeout(s.current),d.current&&window.clearInterval(d.current)})),[]),n.useEffect((()=>((async()=>{try{const e=await g();i.current=e,a.current&&(a.current.srcObject=e),u({type:"PERMISSION_GRANTED"}),v()}catch(e){u({type:"PERMISSION_DENIED"})}})(),()=>{i.current&&w(i.current)})),[g,w]);const y=async()=>{if(r.current&&a.current)try{u({type:"START_CAPTURE"});const i=r.current.getContext("2d");if(!i)return void u({type:"SET_ERROR",message:"Failed to get canvas context"});r.current.width=a.current.videoWidth,r.current.height=a.current.videoHeight,i.drawImage(a.current,0,0,r.current.width,r.current.height);const s=await new Promise(((e,n)=>{var t;null==(t=r.current)||t.toBlob((t=>{t?e(t):n(new Error("Failed to convert canvas to blob"))}),"image/jpeg",.95)}));try{const n=await L(s,e);o({success:!0,data:{faceId:n.payload.documentId,confidence:1}}),u({type:"UPLOAD_SUCCESS"}),setTimeout(t,1500)}catch(n){u({type:"SET_ERROR",message:"Face recognition failed"})}}catch(n){u({type:"SET_ERROR",message:"Failed to capture image"})}};return b.jsxs("div",{style:z.overlay,children:[b.jsx("style",{children:"\n @keyframes spin {\n 0% { transform: translate(-50%, -50%) rotate(0deg); }\n 100% { transform: translate(-50%, -50%) rotate(360deg); }\n }\n"}),b.jsx("style",{children:"\n @media (max-width: 768px) {\n .modal {\n width: 100%;\n height: 100%;\n max-height: 100vh;\n border-radius: 0;\n }\n .button {\n padding: 16px 32px;\n font-size: 18px;\n }\n }\n"}),b.jsxs("div",{style:z.modal,className:"modal",children:[b.jsx("button",{type:"button",style:z.closeButton,onClick:t,children:"×"}),b.jsx("video",{ref:a,style:z.video,autoPlay:!0,playsInline:!0,muted:!0}),b.jsx("canvas",{ref:r,style:z.canvas}),b.jsx("div",{style:z.guide}),"ready"===l.status&&!p&&b.jsx("div",{style:z.message,children:"Centralize seu rosto no círculo"}),"capturing"===l.status&&b.jsx("div",{style:z.message,children:"Por favor, pisque os olhos"}),"uploading"===l.status&&b.jsx("div",{style:z.spinner}),"success"===l.status&&b.jsx("div",{style:z.message,children:"Autenticado!"}),"error"===l.status&&b.jsx("div",{style:z.message,children:l.message}),b.jsxs("div",{style:z.controls,children:["ready"===l.status&&p&&b.jsx("button",{type:"button",style:z.button,onClick:y,children:"Capturar"}),"capturing"===l.status&&b.jsx("button",{type:"button",style:z.button,onClick:y,children:"Capturar"}),"error"===l.status&&b.jsx("button",{type:"button",style:z.button,onClick:()=>{u({type:"RESET"}),m(0)},children:"Tentar Novamente"})]})]})]})}const V=(e,n)=>{switch(n.type){case"START_LIVENESS":return{status:"liveness",step:n.stepSequence[0],capturedPhotos:[],stepSequence:n.stepSequence,currentStepIndex:0,stepProgress:0};case"NEXT_STEP":if("liveness"===e.status){const t=n.photo?[...e.capturedPhotos,n.photo]:e.capturedPhotos;return{status:"liveness",step:n.step,capturedPhotos:t,stepSequence:e.stepSequence,currentStepIndex:e.currentStepIndex+1,stepProgress:0}}return e;case"UPDATE_PROGRESS":return"liveness"===e.status?{...e,stepProgress:n.progress}:e;case"CAMERA_LOADING":return{status:"camera-loading"};case"START_PROCESSING":return{status:"processing"};case"SUCCESS":return{status:"success"};case"ERROR":return{status:"error",message:n.message,retryable:n.retryable??!0};case"RESET":return H;default:return e}},G={center:"Posicione seu rosto no centro",up:"Incline a cabeça para cima",down:"Incline a cabeça para baixo",left:"Vire o rosto para a esquerda",right:"Vire o rosto para a direita",complete:"Processando..."},H=(()=>{const e=["center","up","down","left","right","complete"];return{status:"liveness",step:e[0],capturedPhotos:[],stepSequence:e,currentStepIndex:0,stepProgress:0}})(),X=8,Y=10,J=26,Z=8,Q=-8,ee=15,ne=-15,te=1500,oe=200;function ae({personData:e,applicationToken:t,onClose:o,onSuccess:a,onPhotosCaptured:r,onError:i}){const s=n.useRef(null),d=n.useRef(null),l=n.useRef(null),u=n.useRef(null),p=n.useRef(null),f=n.useRef(!1),h=n.useRef("center"),m=n.useRef(null),g=n.useRef(!1),w=n.useRef(null),[v,y]=n.useReducer(V,H),[x,E]=n.useState(!1),[R,k]=n.useState("ok");n.useEffect((()=>{if("liveness"===v.status){const e=v.step;h.current!==e&&(h.current=e,f.current||(u.current&&(u.current=null),p.current&&(clearInterval(p.current),p.current=null),y({type:"UPDATE_PROGRESS",progress:0}))),w.current={stepSequence:v.stepSequence,currentStepIndex:v.currentStepIndex,capturedPhotos:v.capturedPhotos}}}),[v.status,"liveness"===v.status&&v.step,"liveness"===v.status&&v.currentStepIndex]);n.useEffect((()=>{(async()=>{try{const e="https://cdn.jsdelivr.net/npm/@vladmandic/face-api/model",n=new Promise(((e,n)=>setTimeout((()=>n(new Error("Timeout ao carregar modelos"))),1e4)));await Promise.race([Promise.all([c.nets.tinyFaceDetector.loadFromUri(e),c.nets.faceLandmark68Net.loadFromUri(e)]),n])}catch(e){y({type:"ERROR",message:"Não foi possível carregar os modelos de IA. Verifique sua conexão e tente novamente.",retryable:!0})}})()}),[]),n.useEffect((()=>()=>{l.current&&(l.current.getTracks().forEach((e=>{e.stop()})),l.current=null),s.current&&(s.current.srcObject=null),m.current&&(clearTimeout(m.current),m.current=null),p.current&&(clearInterval(p.current),p.current=null)}),[]),n.useEffect((()=>{let e=!0;return(async()=>{if("liveness"===v.status&&!l.current){g.current=!1,m.current&&(clearTimeout(m.current),m.current=null),m.current=window.setTimeout((()=>{e&&!1===g.current&&y({type:"ERROR",message:"A câmera não respondeu a tempo. Verifique se ela está disponível e tente novamente.",retryable:!0})}),2e4);try{const n=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"}});if(!e)return void n.getTracks().forEach((e=>e.stop()));const t=async()=>{let e=0;for(;!s.current&&e<50;)await new Promise((e=>setTimeout(e,100))),e++;return s.current},o=await t();if(!o)throw new Error("Elemento de vídeo não encontrado");o.srcObject=n,l.current=n,await o.play()}catch(n){if(!e)return;m.current&&(clearTimeout(m.current),m.current=null);let t=n instanceof Error?n.message:"Erro ao acessar câmera";n instanceof DOMException&&("NotAllowedError"===n.name||"PermissionDeniedError"===n.name?t="Permissão de câmera negada. Permita o acesso à câmera nas configurações do navegador e tente novamente.":"NotFoundError"===n.name||"DevicesNotFoundError"===n.name?t="Nenhuma câmera encontrada. Conecte uma câmera e tente novamente.":"NotReadableError"===n.name&&(t="A câmera está sendo usada por outro programa. Feche-o e tente novamente.")),y({type:"ERROR",message:t,retryable:!0})}}})(),()=>{e=!1,m.current&&(clearTimeout(m.current),m.current=null),l.current&&(l.current.getTracks().forEach((e=>e.stop())),l.current=null),p.current&&(clearInterval(p.current),p.current=null),u.current=null}}),[v.status]),n.useEffect((()=>{if("liveness"!==v.status||!s.current)return;let e=!0,n=0;const t=async()=>{if(!e||"liveness"!==v.status)return;if(f.current||"complete"===h.current)return void requestAnimationFrame(t);const o=Date.now();if(o-n<oe)requestAnimationFrame(t);else{n=o;try{const n=await c.detectSingleFace(s.current,new c.TinyFaceDetectorOptions({inputSize:160,scoreThreshold:.4})).withFaceLandmarks();if(!e)return;const t=!!n;if(E(t),t&&n.detection){const e=n.detection.box.width;k(e>250?"too-close":e<120?"too-far":"ok")}if(t&&n.landmarks){const e=(e=>{try{const n=e.positions||e._positions;if(!Array.isArray(n)||n.length<68)return null;const t=e=>{const t=n[e];return{x:void 0!==t._x?t._x:t.x,y:void 0!==t._y?t._y:t.y}},o=t(30),a=t(8),r=t(36),i=t(45),s=(r.x+i.x)/2,c=(o.x-s)/Math.abs(i.x-r.x)*90,d=(r.y+i.y)/2,l=o.y-d,u=-l/Math.abs(a.y-d)*90+J;return{pitch:Math.round(u),yaw:Math.round(c)}}catch(n){return null}})(n.landmarks);if(e){(e=>{if(f.current||"complete"===h.current)return;const n=Date.now();e?u.current||(u.current=n,p.current&&clearInterval(p.current),p.current=window.setInterval((()=>{if(!u.current)return;const e=Date.now()-u.current,n=Math.min(e/te*100,100);y({type:"UPDATE_PROGRESS",progress:n}),n>=100&&(clearInterval(p.current),p.current=null,T())}),50)):u.current&&(u.current=null,p.current&&(clearInterval(p.current),p.current=null),y({type:"UPDATE_PROGRESS",progress:0}))})(((e,n,t)=>{switch(t){case"center":return Math.abs(e)<X&&Math.abs(n)<Y;case"up":return e>Z;case"down":return e<Q;case"left":return n>ee;case"right":return n<ne;default:return!1}})(e.pitch,e.yaw,h.current))}}else u.current&&(u.current=null,p.current&&(clearInterval(p.current),p.current=null),y({type:"UPDATE_PROGRESS",progress:0}))}catch(a){}e&&"liveness"===v.status&&requestAnimationFrame(t)}},o=()=>{e&&s.current&&(g.current=!0,m.current&&(clearTimeout(m.current),m.current=null),t())},a=s.current;if(a&&a.readyState>=2){const n=setTimeout(o,200);return()=>{e=!1,clearTimeout(n),p.current&&(clearInterval(p.current),p.current=null),u.current=null}}{const n=()=>{e&&o()};let t=0;const r=50,i=window.setInterval((()=>{t++,e?s.current&&s.current.readyState>=2?(clearInterval(i),s.current.removeEventListener("canplay",n),o()):t>=r&&clearInterval(i):clearInterval(i)}),300);return null==a||a.addEventListener("canplay",n,{once:!0}),()=>{e=!1,clearInterval(i),null==a||a.removeEventListener("canplay",n),p.current&&(clearInterval(p.current),p.current=null),u.current=null}}}),[v.status]);const T=async()=>{if(!s.current||!d.current||f.current)return;f.current=!0,u.current=null;const e=w.current;if(!e)return void(f.current=!1);const n=d.current,t=s.current,o=n.getContext("2d");o?(n.width=t.videoWidth,n.height=t.videoHeight,o.scale(-1,1),o.drawImage(t,-n.width,0,n.width,n.height),n.toBlob((n=>{if(!n)return void(f.current=!1);const t=e.currentStepIndex+1,o=e.stepSequence[t];if("complete"===o){const t=[...e.capturedPhotos,n];y({type:"START_PROCESSING"}),O(t)}else setTimeout((()=>{f.current=!1,y({type:"NEXT_STEP",step:o,photo:n})}),100)}),"image/jpeg",.85)):f.current=!1},O=async n=>{try{if(r)return y({type:"SUCCESS"}),void r(n);if(!e||!t)throw new Error("Dados de registro não fornecidos");const o=await U(e,n,t),i={success:o.success,message:o.message,person_id:o.person_id,user_id:o.user_id,person_validated:o.person_validated,face_processing:o.face_processing,onboarding_link:o.onboarding_link};y({type:"SUCCESS"}),a&&a(i)}catch(o){const e=o instanceof Error?o.message:"Erro desconhecido";y({type:"ERROR",message:e}),i(e)}};return b.jsxs(b.Fragment,{children:[b.jsx("style",{children:"\n @keyframes fadeIn {\n from { opacity: 0; transform: scale(0.95); }\n to { opacity: 1; transform: scale(1); }\n }\n\n @keyframes slideUp {\n from { opacity: 0; transform: translateY(20px); }\n to { opacity: 1; transform: translateY(0); }\n }\n\n @keyframes slideDown {\n from { opacity: 0; transform: translateY(-10px); }\n to { opacity: 1; transform: translateY(0); }\n }\n\n @keyframes spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n }\n\n @keyframes pulseRing {\n 0%, 100% { \n box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.8), 0 0 40px rgba(16, 185, 129, 0.4);\n }\n 50% { \n box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.9), 0 0 50px rgba(16, 185, 129, 0.5);\n }\n }\n\n @keyframes checkmark {\n 0% {\n stroke-dashoffset: 100;\n }\n 100% {\n stroke-dashoffset: 0;\n }\n }\n\n @keyframes scaleIn {\n 0% {\n transform: scale(0);\n opacity: 0;\n }\n 50% {\n transform: scale(1.1);\n }\n 100% {\n transform: scale(1);\n opacity: 1;\n }\n }\n\n @keyframes scanRing {\n 0%, 100% { transform: scale(1); opacity: 0.3; }\n 50% { transform: scale(1.1); opacity: 0.6; }\n }\n\n @keyframes cornerBlink {\n 0%, 100% { opacity: 0.3; }\n 50% { opacity: 1; }\n }\n\n .modal-overlay {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.92);\n backdrop-filter: blur(8px);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 9999;\n padding: 20px;\n }\n\n .modal-content {\n background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);\n border-radius: 24px;\n width: 100%;\n max-width: 420px;\n max-height: 90vh;\n overflow: hidden;\n box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);\n animation: fadeIn 0.3s ease-out;\n position: relative;\n }\n\n .close-button {\n position: absolute;\n top: 20px;\n right: 20px;\n width: 32px;\n height: 32px;\n background: transparent;\n border: none;\n color: rgba(255, 255, 255, 0.6);\n font-size: 28px;\n font-weight: 300;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s;\n z-index: 10;\n line-height: 1;\n }\n\n .close-button:hover {\n color: rgba(255, 255, 255, 0.9);\n transform: rotate(90deg);\n }\n\n /* Instructions Screen */\n .instructions-container {\n padding: 60px 40px 40px;\n color: white;\n text-align: center;\n animation: slideUp 0.4s ease-out;\n }\n\n .instructions-header {\n margin-bottom: 40px;\n }\n\n .icon-wrapper {\n display: inline-block;\n color: #7c3aed;\n margin-bottom: 24px;\n }\n\n .icon-wrapper .scan-ring {\n animation: scanRing 2s ease-in-out infinite;\n }\n\n .icon-wrapper .corner {\n animation: cornerBlink 2s ease-in-out infinite;\n }\n\n .icon-wrapper .corner.tl { animation-delay: 0s; }\n .icon-wrapper .corner.tr { animation-delay: 0.5s; }\n .icon-wrapper .corner.bl { animation-delay: 1s; }\n .icon-wrapper .corner.br { animation-delay: 1.5s; }\n\n .instructions-header h2 {\n font-size: 28px;\n font-weight: 700;\n margin: 0 0 12px 0;\n background: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);\n -webkit-background-clip: text;\n -webkit-text-fill-color: transparent;\n background-clip: text;\n }\n\n .subtitle {\n font-size: 15px;\n color: rgba(255, 255, 255, 0.7);\n margin: 0;\n line-height: 1.5;\n }\n\n .requirements-list {\n text-align: left;\n margin: 0 auto 40px;\n max-width: 360px;\n }\n\n .requirement-item {\n display: flex;\n align-items: center;\n gap: 16px;\n padding: 14px 0;\n font-size: 15px;\n color: rgba(255, 255, 255, 0.9);\n border-bottom: 1px solid rgba(255, 255, 255, 0.05);\n }\n\n .requirement-item:last-child {\n border-bottom: none;\n }\n\n .req-icon {\n width: 32px;\n height: 32px;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n }\n\n .req-icon.success {\n background: rgba(16, 185, 129, 0.15);\n color: #10b981;\n border: 1.5px solid rgba(16, 185, 129, 0.3);\n }\n\n .primary-button {\n width: 100%;\n padding: 16px 32px;\n border-radius: 12px;\n border: none;\n background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);\n color: white;\n font-size: 16px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.3s;\n box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);\n }\n\n .primary-button:hover {\n transform: translateY(-2px);\n box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4);\n }\n\n .primary-button:active {\n transform: translateY(0);\n }\n\n .branding {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n margin-top: 32px;\n padding-top: 24px;\n border-top: 1px solid rgba(255, 255, 255, 0.1);\n font-size: 13px;\n color: rgba(255, 255, 255, 0.5);\n }\n\n .brand-logo {\n height: 20px;\n width: auto;\n }\n\n .brand-name {\n font-weight: 600;\n font-family: 'SF Pro Display', -apple-system, system-ui, sans-serif;\n color: #ffffff;\n letter-spacing: 0.3px;\n }\n\n /* Liveness Detection */\n .liveness-container {\n height: 100%;\n min-height: 520px;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 70px 20px 80px;\n position: relative;\n animation: fadeIn 0.3s ease-out;\n }\n\n .progress-indicator {\n position: absolute;\n top: 20px;\n left: 50%;\n transform: translateX(-50%);\n background: rgba(255, 255, 255, 0.08);\n backdrop-filter: blur(12px);\n border-radius: 20px;\n padding: 8px 20px;\n border: 1px solid rgba(255, 255, 255, 0.12);\n z-index: 5;\n }\n\n .progress-text {\n font-size: 14px;\n font-weight: 600;\n color: white;\n }\n\n .video-wrapper {\n position: relative;\n margin: 20px 0;\n }\n\n .video-circle {\n width: 320px;\n height: 400px;\n border-radius: 50%;\n overflow: hidden;\n position: relative;\n transition: all 0.3s ease;\n box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.3);\n }\n\n .video-circle.face-detected {\n box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.5), 0 0 40px rgba(16, 185, 129, 0.3);\n }\n\n .video-circle.capturing {\n box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.9), 0 0 40px rgba(16, 185, 129, 0.5);\n transition: box-shadow 0.3s ease;\n }\n\n .video-feed {\n width: 100%;\n height: 100%;\n object-fit: cover;\n transform: scaleX(-1);\n }\n\n .face-badge {\n position: absolute;\n top: 20px;\n left: 50%;\n transform: translateX(-50%);\n background: rgba(16, 185, 129, 0.95);\n backdrop-filter: blur(10px);\n border-radius: 20px;\n padding: 8px 16px;\n display: flex;\n align-items: center;\n gap: 8px;\n color: white;\n font-size: 13px;\n font-weight: 600;\n border: 1px solid rgba(255, 255, 255, 0.3);\n box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);\n animation: slideDown 0.3s ease-out;\n }\n\n .face-badge.warning {\n background: rgba(251, 191, 36, 0.95);\n border: 1px solid rgba(255, 255, 255, 0.3);\n box-shadow: 0 4px 12px rgba(251, 191, 36, 0.3);\n color: #78350f;\n }\n\n .face-badge.error {\n background: rgba(239, 68, 68, 0.95);\n border: 1px solid rgba(255, 255, 255, 0.3);\n box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);\n color: white;\n }\n\n .instruction-box {\n background: rgba(255, 255, 255, 0.08);\n backdrop-filter: blur(12px);\n border-radius: 16px;\n padding: 16px 24px;\n margin-top: 20px;\n border: 1px solid rgba(255, 255, 255, 0.12);\n max-width: 320px;\n animation: slideUp 0.3s ease-out;\n }\n\n .instruction-text {\n font-size: 18px;\n font-weight: 600;\n color: white;\n margin: 0 0 12px 0;\n text-align: center;\n }\n\n .progress-bar {\n height: 4px;\n background: rgba(255, 255, 255, 0.2);\n border-radius: 2px;\n overflow: hidden;\n }\n\n .progress-fill {\n height: 100%;\n background: linear-gradient(90deg, #7c3aed 0%, #10b981 100%);\n border-radius: 2px;\n transition: width 0.05s linear;\n }\n\n .branding-small {\n position: absolute;\n bottom: 24px;\n left: 50%;\n transform: translateX(-50%);\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 5px;\n font-size: 12px;\n color: rgba(255, 255, 255, 0.5);\n }\n\n .brand-logo-small {\n height: 18px;\n width: 18px;\n }\n\n /* Processing */\n .processing-container {\n padding: 80px 40px;\n text-align: center;\n color: white;\n animation: fadeIn 0.3s ease-out;\n }\n\n .spinner-wrapper {\n position: relative;\n width: 80px;\n height: 80px;\n margin: 0 auto 32px;\n }\n\n .spinner {\n position: absolute;\n inset: 0;\n border: 4px solid rgba(124, 58, 237, 0.2);\n border-top-color: #7c3aed;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n }\n\n .spinner-ring {\n position: absolute;\n inset: -10px;\n border: 2px solid rgba(124, 58, 237, 0.1);\n border-radius: 50%;\n animation: pulseSpinner 2s ease-in-out infinite;\n }\n\n @keyframes pulseSpinner {\n 0%, 100% { transform: scale(1); opacity: 1; }\n 50% { transform: scale(1.1); opacity: 0.5; }\n }\n\n .processing-container h3 {\n font-size: 24px;\n font-weight: 700;\n margin: 0 0 12px 0;\n }\n\n .processing-container p {\n font-size: 15px;\n color: rgba(255, 255, 255, 0.7);\n margin: 0;\n }\n\n /* Result Screens */\n .result-container {\n padding: 80px 40px 40px;\n text-align: center;\n color: white;\n animation: slideUp 0.4s ease-out;\n }\n\n .result-icon {\n display: inline-flex;\n margin-bottom: 24px;\n }\n\n .success-icon {\n color: #10b981;\n animation: scaleIn 0.6s ease-out;\n }\n\n .success-icon svg circle {\n animation: scaleIn 0.5s ease-out;\n }\n\n .success-icon svg path {\n stroke-dasharray: 100;\n stroke-dashoffset: 100;\n animation: checkmark 0.6s ease-out 0.3s forwards;\n }\n\n .error-icon {\n color: #ef4444;\n animation: fadeIn 0.5s ease-out;\n }\n\n .result-container h3 {\n font-size: 26px;\n font-weight: 700;\n margin: 0 0 12px 0;\n }\n\n .result-container p {\n font-size: 15px;\n color: rgba(255, 255, 255, 0.7);\n margin: 0 0 32px 0;\n line-height: 1.5;\n }\n\n .button-group {\n display: flex;\n gap: 12px;\n margin-top: 32px;\n }\n\n .secondary-button {\n flex: 1;\n padding: 14px 24px;\n border-radius: 12px;\n border: 1px solid rgba(255, 255, 255, 0.2);\n background: rgba(255, 255, 255, 0.1);\n color: white;\n font-size: 15px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s;\n }\n\n .secondary-button:hover {\n background: rgba(255, 255, 255, 0.15);\n border-color: rgba(255, 255, 255, 0.3);\n }\n\n .ghost-button {\n flex: 1;\n padding: 14px 24px;\n border-radius: 12px;\n border: none;\n background: transparent;\n color: rgba(255, 255, 255, 0.7);\n font-size: 15px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s;\n }\n\n .ghost-button:hover {\n color: white;\n background: rgba(255, 255, 255, 0.05);\n }\n\n /* Canvas */\n canvas {\n display: none;\n }\n\n /* Responsive */\n @media (max-width: 640px) {\n .modal-content {\n max-width: 100%;\n border-radius: 0;\n max-height: 100vh;\n }\n\n .instructions-container {\n padding: 50px 24px 24px;\n }\n\n .instructions-header h2 {\n font-size: 24px;\n }\n\n .video-circle {\n width: 280px;\n height: 350px;\n }\n\n .liveness-container {\n min-height: 100vh;\n }\n }\n "}),b.jsx("div",{className:"modal-overlay",children:b.jsxs("div",{className:"modal-content",children:[b.jsx("button",{className:"close-button",onClick:o,children:"×"}),"liveness"===v.status&&(()=>{if("liveness"!==v.status)return null;const e=`${v.currentStepIndex+1}/${v.stepSequence.length-1}`,n=v.stepProgress;return b.jsxs("div",{className:"liveness-container",children:[b.jsx("div",{className:"progress-indicator",children:b.jsx("span",{className:"progress-text",children:e})}),b.jsx("div",{className:"video-wrapper",children:b.jsxs("div",{className:`video-circle ${x?"face-detected":""} ${n>0?"capturing":""}`,children:[b.jsx("video",{ref:s,className:"video-feed",autoPlay:!0,muted:!0,playsInline:!0}),x&&b.jsxs("div",{className:"face-badge",children:[b.jsx("svg",{width:"16",height:"16",viewBox:"0 0 20 20",fill:"none",children:b.jsx("path",{d:"M5 10 L8 13 L15 6",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})}),b.jsx("span",{children:"Rosto detectado"})]})]})}),b.jsxs("div",{className:"instruction-box",children:[b.jsx("p",{className:"instruction-text",children:G[v.step]}),n>0&&b.jsx("div",{className:"progress-bar",children:b.jsx("div",{className:"progress-fill",style:{width:`${n}%`}})})]}),b.jsxs("div",{className:"branding-small",children:[b.jsx("img",{src:"/logo-icone.png",alt:"NeoFaceId",className:"brand-logo-small"}),b.jsx("span",{children:"NeoFaceId by"}),b.jsx("span",{className:"brand-name",children:"OCTA"})]})]})})(),"camera-loading"===v.status&&b.jsxs("div",{className:"processing-container",children:[b.jsxs("div",{className:"spinner-wrapper",children:[b.jsx("div",{className:"spinner"}),b.jsx("div",{className:"spinner-ring"})]}),b.jsx("h3",{children:"Inicializando câmera"}),b.jsx("p",{children:"Aguarde enquanto preparamos a câmera..."}),b.jsxs("div",{className:"branding",style:{marginTop:"40px",paddingTop:"24px",borderTop:"1px solid rgba(255, 255, 255, 0.1)"},children:[b.jsx("span",{children:"NeoFaceId by"}),b.jsx("span",{className:"brand-name",children:"OCTA"})]})]}),"processing"===v.status&&b.jsxs("div",{className:"processing-container",children:[b.jsxs("div",{className:"spinner-wrapper",children:[b.jsx("div",{className:"spinner"}),b.jsx("div",{className:"spinner-ring"})]}),b.jsx("h3",{children:"Processando biometria"}),b.jsx("p",{children:"Analisando suas capturas faciais..."}),b.jsxs("div",{className:"branding",style:{marginTop:"40px",paddingTop:"24px",borderTop:"1px solid rgba(255, 255, 255, 0.1)"},children:[b.jsx("span",{children:"NeoFaceId by"}),b.jsx("span",{className:"brand-name",children:"OCTA"})]})]}),"error"===v.status&&("error"!==v.status?null:b.jsxs("div",{className:"result-container error",children:[b.jsx("div",{className:"result-icon error-icon",children:b.jsxs("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",children:[b.jsx("circle",{cx:"30",cy:"30",r:"28",stroke:"currentColor",strokeWidth:"3"}),b.jsx("path",{d:"M20 20 L40 40 M40 20 L20 40",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}),b.jsx("h3",{children:"Não foi possível processar"}),b.jsx("p",{children:v.message}),b.jsxs("div",{className:"button-group",children:[v.retryable&&b.jsx("button",{className:"secondary-button",onClick:()=>y({type:"RESET"}),children:"Tentar Novamente"}),b.jsx("button",{className:"ghost-button",onClick:o,children:"Cancelar"})]})]})),"success"===v.status&&b.jsxs("div",{className:"result-container success",children:[b.jsx("div",{className:"result-icon success-icon",children:b.jsxs("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",children:[b.jsx("circle",{cx:"30",cy:"30",r:"28",stroke:"currentColor",strokeWidth:"3"}),b.jsx("path",{d:"M15 30 L25 40 L45 20",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"})]})}),b.jsx("h3",{children:r?"Captura concluída!":"Verificação concluída!"}),b.jsx("p",{children:r?"Suas capturas faciais foram realizadas":"Sua biometria foi registrada com sucesso"}),b.jsx("button",{className:"primary-button",onClick:o,children:"Continuar"})]})]})}),b.jsx("canvas",{ref:d})]})}class re{constructor(e){r(this,"modal",null),r(this,"video",null),r(this,"canvas",null),r(this,"stream",null),r(this,"options"),r(this,"countdownInterval",null),r(this,"isCapturing",!1),this.options=e}async open(){try{await this.createModal(),await this.initializeCamera(),this.startCountdown()}catch(e){this.options.onError(new k("Erro ao inicializar câmera: "+e.message,R.CAMERA_ERROR))}}close(){this.cleanup(),this.modal&&(document.body.removeChild(this.modal),this.modal=null)}async createModal(){this.modal=document.createElement("div"),this.modal.className="neofaceid-biometric-modal";const e=this.options.title||this.getDefaultTitle(),n=this.options.subtitle||this.getDefaultSubtitle();this.modal.innerHTML=`\n <div class="neofaceid-modal-overlay">\n <div class="neofaceid-modal-content">\n <div class="neofaceid-modal-header">\n <h2>${e}</h2>\n <button class="neofaceid-close-btn" type="button">×</button>\n </div>\n <div class="neofaceid-modal-body">\n <p class="neofaceid-subtitle">${n}</p>\n <div class="neofaceid-camera-container">\n <video class="neofaceid-video" autoplay muted playsinline></video>\n <canvas class="neofaceid-canvas" style="display: none;"></canvas>\n <div class="neofaceid-overlay">\n <div class="neofaceid-frame"></div>\n <div class="neofaceid-countdown">\n <span class="neofaceid-countdown-number">${this.options.countdown||3}</span>\n </div>\n </div>\n </div>\n <div class="neofaceid-status">\n <p class="neofaceid-status-text">Posicione-se na frente da câmera</p>\n </div>\n </div>\n <div class="neofaceid-modal-footer">\n <button class="neofaceid-cancel-btn" type="button">Cancelar</button>\n <button class="neofaceid-capture-btn" type="button" disabled>Capturar</button>\n </div>\n </div>\n </div>\n `,this.addStyles(),this.addEventListeners(),document.body.appendChild(this.modal)}async initializeCamera(){if(!this.modal)throw new Error("Modal não inicializado");if(this.video=this.modal.querySelector(".neofaceid-video"),this.canvas=this.modal.querySelector(".neofaceid-canvas"),!this.video||!this.canvas)throw new Error("Elementos de vídeo ou canvas não encontrados");try{this.stream=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"},audio:!1}),this.video.srcObject=this.stream,await this.video.play(),this.canvas.width=this.video.videoWidth,this.canvas.height=this.video.videoHeight}catch(e){throw new Error("Não foi possível acessar a câmera: "+e.message)}}startCountdown(){if(!this.modal)return;const e=this.modal.querySelector(".neofaceid-countdown-number"),n=this.modal.querySelector(".neofaceid-capture-btn"),t=this.modal.querySelector(".neofaceid-status-text");let o=this.options.countdown||3;e&&(e.textContent=o.toString()),this.countdownInterval=window.setInterval((()=>{o--,e&&(e.textContent=o.toString()),o<=0&&(this.countdownInterval&&(clearInterval(this.countdownInterval),this.countdownInterval=null),e&&(e.style.display="none"),n&&(n.disabled=!1,n.textContent="Capturar Agora"),t&&(t.textContent="Pronto para capturar!"),"auto"===this.options.mode&&setTimeout((()=>this.captureImage()),500))}),1e3)}async captureImage(){if(!this.isCapturing&&this.video&&this.canvas){this.isCapturing=!0;try{const e=this.canvas.getContext("2d");if(!e)throw new Error("Não foi possível obter contexto do canvas");e.drawImage(this.video,0,0,this.canvas.width,this.canvas.height);const n=this.canvas.toDataURL("image/jpeg",.8).split(",")[1],t=`data:image/jpeg;base64,${n}`;let o="auto"===this.options.mode?await this.detectBiometricType(n):this.options.mode;this.close(),this.options.onSuccess(t,o)}catch(e){this.options.onError(new k("Erro ao capturar imagem: "+e.message,R.CAPTURE_ERROR))}finally{this.isCapturing=!1}}}async detectBiometricType(e){try{const{detectBiometricType:n}=await Promise.resolve().then((()=>ke)),t=await n(e);return"unknown"!==t.type&&t.confidence>.6?t.type:"face"}catch(n){return"face"}}addEventListeners(){if(!this.modal)return;const e=this.modal.querySelector(".neofaceid-close-btn"),n=this.modal.querySelector(".neofaceid-cancel-btn"),t=this.modal.querySelector(".neofaceid-capture-btn");null==e||e.addEventListener("click",(()=>{var e,n;this.close(),null==(n=(e=this.options).onCancel)||n.call(e)})),null==n||n.addEventListener("click",(()=>{var e,n;this.close(),null==(n=(e=this.options).onCancel)||n.call(e)})),null==t||t.addEventListener("click",(()=>{this.captureImage()})),this.modal.addEventListener("click",(e=>{var n,t,o;e.target===(null==(n=this.modal)?void 0:n.querySelector(".neofaceid-modal-overlay"))&&(this.close(),null==(o=(t=this.options).onCancel)||o.call(t))}))}cleanup(){this.stream&&(this.stream.getTracks().forEach((e=>e.stop())),this.stream=null),this.countdownInterval&&(clearInterval(this.countdownInterval),this.countdownInterval=null),this.video=null,this.canvas=null,this.isCapturing=!1}getDefaultTitle(){switch(this.options.mode){case"face":return"Autenticação Facial";case"hand":return"Autenticação por Mão";case"auto":return"Autenticação Biométrica";default:return"Captura Biométrica"}}getDefaultSubtitle(){switch(this.options.mode){case"face":return"Posicione seu rosto dentro do quadro e aguarde a captura automática.";case"hand":return"Posicione sua mão dentro do quadro e aguarde a captura automática.";case"auto":return"Posicione seu rosto ou mão dentro do quadro para autenticação automática.";default:return"Posicione-se dentro do quadro para captura."}}addStyles(){const e="neofaceid-biometric-modal-styles",n=document.getElementById(e);n&&n.remove();const t=document.createElement("style");t.id=e,t.textContent="\n .neofaceid-biometric-modal {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 10000;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n }\n\n .neofaceid-modal-overlay {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.8);\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 20px;\n box-sizing: border-box;\n }\n\n .neofaceid-modal-content {\n background: white;\n border-radius: 12px;\n max-width: 600px;\n width: 100%;\n max-height: 90vh;\n overflow: hidden;\n box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);\n }\n\n .neofaceid-modal-header {\n padding: 20px;\n border-bottom: 1px solid #e0e0e0;\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n\n .neofaceid-modal-header h2 {\n margin: 0;\n font-size: 24px;\n font-weight: 600;\n color: #333;\n }\n\n .neofaceid-close-btn {\n background: none;\n border: none;\n font-size: 28px;\n cursor: pointer;\n color: #666;\n padding: 0;\n width: 32px;\n height: 32px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 50%;\n transition: background-color 0.2s;\n }\n\n .neofaceid-close-btn:hover {\n background-color: #f0f0f0;\n }\n\n .neofaceid-modal-body {\n padding: 20px;\n }\n\n .neofaceid-subtitle {\n margin: 0 0 20px 0;\n color: #666;\n font-size: 16px;\n line-height: 1.4;\n }\n\n .neofaceid-camera-container {\n position: relative;\n background: #000;\n border-radius: 8px;\n overflow: hidden;\n aspect-ratio: 4/3;\n margin-bottom: 20px;\n }\n\n .neofaceid-video {\n width: 100%;\n height: 100%;\n object-fit: cover;\n }\n\n .neofaceid-canvas {\n position: absolute;\n top: 0;\n left: 0;\n }\n\n .neofaceid-overlay {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .neofaceid-frame {\n width: 200px;\n height: 200px;\n border: 3px solid #4CAF50;\n border-radius: 50%;\n box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3);\n animation: pulse 2s infinite;\n }\n\n .neofaceid-countdown {\n position: absolute;\n top: 20px;\n right: 20px;\n background: rgba(0, 0, 0, 0.7);\n color: white;\n padding: 10px;\n border-radius: 50%;\n width: 50px;\n height: 50px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .neofaceid-countdown-number {\n font-size: 24px;\n font-weight: bold;\n }\n\n .neofaceid-status {\n text-align: center;\n margin-bottom: 20px;\n }\n\n .neofaceid-status-text {\n margin: 0;\n color: #666;\n font-size: 16px;\n }\n\n .neofaceid-modal-footer {\n padding: 20px;\n border-top: 1px solid #e0e0e0;\n display: flex;\n gap: 12px;\n justify-content: flex-end;\n }\n\n .neofaceid-cancel-btn,\n .neofaceid-capture-btn {\n padding: 12px 24px;\n border: none;\n border-radius: 6px;\n font-size: 16px;\n font-weight: 500;\n cursor: pointer;\n transition: all 0.2s;\n }\n\n .neofaceid-cancel-btn {\n background: #f5f5f5;\n color: #666;\n }\n\n .neofaceid-cancel-btn:hover {\n background: #e0e0e0;\n }\n\n .neofaceid-capture-btn {\n background: #4CAF50;\n color: white;\n }\n\n .neofaceid-capture-btn:hover:not(:disabled) {\n background: #45a049;\n }\n\n .neofaceid-capture-btn:disabled {\n background: #ccc;\n cursor: not-allowed;\n }\n\n @keyframes pulse {\n 0% { box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3); }\n 50% { box-shadow: 0 0 0 10px rgba(76, 175, 80, 0.1); }\n 100% { box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3); }\n }\n\n @media (max-width: 640px) {\n .neofaceid-modal-overlay {\n padding: 10px;\n }\n \n .neofaceid-modal-header,\n .neofaceid-modal-body,\n .neofaceid-modal-footer {\n padding: 15px;\n }\n \n .neofaceid-frame {\n width: 150px;\n height: 150px;\n }\n }\n ",document.head.appendChild(t)}}class ie{constructor(){r(this,"container",null),r(this,"currentStatus","preparing")}getStyles(){return"\n @keyframes neofaceid-fadeIn {\n from { opacity: 0; transform: scale(0.9); }\n to { opacity: 1; transform: scale(1); }\n }\n\n @keyframes neofaceid-fadeOut {\n from { opacity: 1; transform: scale(1); }\n to { opacity: 0; transform: scale(0.9); }\n }\n\n @keyframes neofaceid-pulse {\n 0%, 100% { \n transform: scale(1);\n opacity: 1;\n }\n 50% { \n transform: scale(1.05);\n opacity: 0.9;\n }\n }\n\n @keyframes neofaceid-scaleIn {\n 0% { transform: scale(0); opacity: 0; }\n 50% { transform: scale(1.1); }\n 100% { transform: scale(1); opacity: 1; }\n }\n\n @keyframes neofaceid-errorShake {\n 0%, 100% { transform: translateX(0); }\n 10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }\n 20%, 40%, 60%, 80% { transform: translateX(4px); }\n }\n\n .neofaceid-overlay-container {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10000;\n pointer-events: none;\n animation: neofaceid-fadeIn 0.3s ease-out;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;\n }\n\n .neofaceid-overlay-container.fade-out {\n animation: neofaceid-fadeOut 0.3s ease-out forwards;\n }\n\n .neofaceid-overlay-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 24px;\n pointer-events: auto;\n }\n\n .neofaceid-visual-wrapper {\n position: relative;\n width: 100px;\n height: 100px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .neofaceid-logo {\n width: 80px;\n height: 80px;\n object-fit: contain;\n transition: all 0.5s ease;\n filter: drop-shadow(0 4px 12px rgba(124, 58, 237, 0.3));\n }\n\n /* Cores por estado */\n .neofaceid-state-preparing .neofaceid-logo { filter: drop-shadow(0 0 15px rgba(124, 58, 237, 0.4)); }\n .neofaceid-state-detecting .neofaceid-logo { filter: hue-rotate(180deg) drop-shadow(0 0 15px rgba(59, 130, 246, 0.6)); }\n .neofaceid-state-capturing .neofaceid-logo { filter: hue-rotate(45deg) drop-shadow(0 0 15px rgba(245, 158, 11, 0.6)); }\n .neofaceid-state-verifying .neofaceid-logo { filter: hue-rotate(90deg) drop-shadow(0 0 15px rgba(34, 197, 94, 0.6)); }\n\n .neofaceid-logo.pulsing {\n animation: neofaceid-pulse 2s ease-in-out infinite;\n }\n\n @keyframes neofaceid-dots {\n 0%, 20% { opacity: 0; transform: translateY(0); }\n 50% { opacity: 1; transform: translateY(-2px); }\n 80%, 100% { opacity: 0; transform: translateY(0); }\n }\n\n .neofaceid-status-text {\n font-size: 15px;\n font-weight: 500;\n color: #ffffff;\n text-align: center;\n padding: 10px 24px;\n background: rgba(15, 23, 42, 0.8);\n backdrop-filter: blur(8px);\n border-radius: 100px;\n box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);\n border: 1px solid rgba(255, 255, 255, 0.1);\n text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);\n animation: neofaceid-fadeIn 0.3s ease-out;\n display: flex;\n align-items: center;\n gap: 2px;\n }\n\n .neofaceid-dots {\n display: inline-flex;\n margin-left: 2px;\n }\n\n .neofaceid-dot {\n animation: neofaceid-dots 1.5s infinite;\n opacity: 0;\n }\n\n .neofaceid-dot:nth-child(2) { animation-delay: 0.2s; }\n .neofaceid-dot:nth-child(3) { animation-delay: 0.4s; }\n\n .neofaceid-status-icon {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .neofaceid-success-icon {\n width: 80px;\n height: 80px;\n color: #10b981;\n animation: neofaceid-scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);\n }\n\n .neofaceid-error-icon {\n width: 80px;\n height: 80px;\n color: #ef4444;\n animation: neofaceid-errorShake 0.5s linear, neofaceid-scaleIn 0.4s ease-out;\n }\n "}getStatusText(){switch(this.currentStatus){case"preparing":return"Iniciando câmera";case"detecting":return"Posicione seu rosto";case"capturing":return"Capturando";case"verifying":return"Verificando identidade";case"success":return"Identificado!";case"error":return"Falha na identificação";default:return""}}renderContent(){const e=["detecting","verifying"].includes(this.currentStatus),n=!["success","error"].includes(this.currentStatus),t="success"===this.currentStatus,o="error"===this.currentStatus,a=this.getStatusText(),r=["preparing","detecting","capturing","verifying"].includes(this.currentStatus);return`\n <style>${this.getStyles()}</style>\n <div class="neofaceid-overlay-container neofaceid-state-${this.currentStatus}">\n <div class="neofaceid-overlay-content">\n <div class="neofaceid-visual-wrapper">\n ${n?`\n <img\n src="/logo-icone-no-background.png"\n alt="NeoFaceId"\n class="neofaceid-logo ${e?"pulsing":""}"\n onerror="this.style.display='none'"\n />\n `:""}\n \n ${t?'\n <div class="neofaceid-status-icon">\n <svg class="neofaceid-success-icon" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="30" cy="30" r="28" stroke="currentColor" stroke-width="3" fill="none"/>\n <path d="M15 30 L25 40 L45 20" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" fill="none"/>\n </svg>\n </div>\n ':""}\n \n ${o?'\n <div class="neofaceid-status-icon">\n <svg class="neofaceid-error-icon" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="30" cy="30" r="28" stroke="currentColor" stroke-width="3" fill="none"/>\n <path d="M20 20 L40 40 M40 20 L20 40" stroke="currentColor" stroke-width="3" stroke-linecap="round"/>\n </svg>\n </div>\n ':""}\n </div>\n \n ${a?`\n <div class="neofaceid-status-text">\n ${a}${r?'\n <span class="neofaceid-dots">\n <span class="neofaceid-dot">.</span>\n <span class="neofaceid-dot">.</span>\n <span class="neofaceid-dot">.</span>\n </span>\n ':""}\n </div>\n `:""}\n </div>\n </div>\n `}show(e="preparing"){this.container?this.updateStatus(e):(this.container=document.createElement("div"),this.container.id="neofaceid-status-overlay",this.currentStatus=e,this.container.innerHTML=this.renderContent(),document.body.appendChild(this.container))}updateStatus(e){this.currentStatus=e,this.container&&(this.container.innerHTML=this.renderContent())}close(){if(this.container){const e=this.container.querySelector(".neofaceid-overlay-container");e&&e.classList.add("fade-out"),setTimeout((()=>{this.container&&document.body.contains(this.container)&&document.body.removeChild(this.container),this.container=null}),300)}}}function se({error:e,onRetry:n,onCredentials:t,onCancel:o}){return b.jsxs(b.Fragment,{children:[b.jsx("style",{children:"\n @keyframes slideUp {\n from {\n opacity: 0;\n transform: translateY(20px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n\n @keyframes fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n\n .neofaceid-fallback-overlay {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.6);\n backdrop-filter: blur(8px);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10001;\n padding: 20px;\n animation: fadeIn 0.3s ease-out;\n }\n\n .neofaceid-fallback-prompt {\n background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);\n border-radius: 20px;\n padding: 32px;\n max-width: 400px;\n width: 100%;\n box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);\n animation: slideUp 0.4s ease-out;\n text-align: center;\n }\n\n .neofaceid-fallback-icon {\n width: 64px;\n height: 64px;\n margin: 0 auto 20px;\n color: #ef4444;\n animation: scaleIn 0.4s ease-out;\n }\n\n @keyframes scaleIn {\n 0% {\n transform: scale(0);\n opacity: 0;\n }\n 50% {\n transform: scale(1.1);\n }\n 100% {\n transform: scale(1);\n opacity: 1;\n }\n }\n\n .neofaceid-fallback-title {\n font-size: 22px;\n font-weight: 700;\n color: white;\n margin: 0 0 12px 0;\n }\n\n .neofaceid-fallback-message {\n font-size: 15px;\n color: rgba(255, 255, 255, 0.7);\n margin: 0 0 28px 0;\n line-height: 1.5;\n }\n\n .neofaceid-fallback-actions {\n display: flex;\n flex-direction: column;\n gap: 12px;\n }\n\n .neofaceid-fallback-button {\n padding: 14px 24px;\n border-radius: 12px;\n border: none;\n font-size: 16px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n }\n\n .neofaceid-fallback-button-primary {\n background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);\n color: white;\n box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);\n }\n\n .neofaceid-fallback-button-primary:hover {\n transform: translateY(-2px);\n box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4);\n }\n\n .neofaceid-fallback-button-primary:active {\n transform: translateY(0);\n }\n\n .neofaceid-fallback-button-secondary {\n background: rgba(255, 255, 255, 0.1);\n color: white;\n border: 1px solid rgba(255, 255, 255, 0.2);\n }\n\n .neofaceid-fallback-button-secondary:hover {\n background: rgba(255, 255, 255, 0.15);\n border-color: rgba(255, 255, 255, 0.3);\n }\n\n .neofaceid-fallback-button-ghost {\n background: transparent;\n color: rgba(255, 255, 255, 0.7);\n padding: 10px;\n }\n\n .neofaceid-fallback-button-ghost:hover {\n color: white;\n background: rgba(255, 255, 255, 0.05);\n }\n\n @media (max-width: 640px) {\n .neofaceid-fallback-prompt {\n padding: 24px;\n border-radius: 16px;\n }\n\n .neofaceid-fallback-title {\n font-size: 20px;\n }\n }\n "}),b.jsx("div",{className:"neofaceid-fallback-overlay",children:b.jsxs("div",{className:"neofaceid-fallback-prompt",children:[b.jsx("div",{className:"neofaceid-fallback-icon",children:b.jsxs("svg",{viewBox:"0 0 64 64",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("circle",{cx:"32",cy:"32",r:"30",stroke:"currentColor",strokeWidth:"3",fill:"none"}),b.jsx("path",{d:"M20 20 L44 44 M44 20 L20 44",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}),b.jsx("h3",{className:"neofaceid-fallback-title",children:"Não foi possível reconhecer"}),b.jsx("p",{className:"neofaceid-fallback-message",children:(null==e?void 0:e.getFriendlyMessage())||"Não conseguimos reconhecer sua face. Tente novamente ou use email e senha."}),b.jsxs("div",{className:"neofaceid-fallback-actions",children:[b.jsx("button",{type:"button",className:"neofaceid-fallback-button neofaceid-fallback-button-primary",onClick:n,children:"Tentar Novamente"}),b.jsx("button",{type:"button",className:"neofaceid-fallback-button neofaceid-fallback-button-secondary",onClick:t,children:"Entrar com Email e Senha"}),o&&b.jsx("button",{type:"button",className:"neofaceid-fallback-button neofaceid-fallback-button-ghost",onClick:o,children:"Cancelar"})]})]})})]})}class ce{constructor(){r(this,"container",null),r(this,"root",null)}show(e,n,t,o){this.container||(this.container=document.createElement("div"),this.container.id="neofaceid-fallback-prompt",document.body.appendChild(this.container),this.root=p.createRoot(this.container),this.render(e,n,t,o))}close(){this.container&&document.body.contains(this.container)&&(this.root&&this.root.unmount(),document.body.removeChild(this.container),this.container=null,this.root=null)}render(e,n,t,o){this.root&&this.container&&this.root.render(b.jsx(se,{error:e,onRetry:()=>{this.close(),n()},onCredentials:()=>{this.close(),t()},onCancel:()=>{this.close(),null==o||o()}}))}}class de{constructor(e){r(this,"options"),r(this,"modalElement",null),this.options=e}async open(){this.createModal(),document.body.appendChild(this.modalElement)}close(){this.modalElement&&(document.body.removeChild(this.modalElement),this.modalElement=null),this.options.onCancel&&this.options.onCancel()}createModal(){this.addStyles(),this.modalElement=document.createElement("div"),this.modalElement.className="neoface-email-password-modal",this.modalElement.innerHTML=`\n <div class="neoface-email-modal-overlay">\n <div class="neoface-email-modal-content">\n <h2>${this.options.title||"Login com Email e Senha"}</h2>\n <p>${this.options.subtitle||"Informe seus dados para login."}</p>\n <div id="login-error" class="neoface-email-error" style="display:none"></div>\n <form id="email-password-form">\n <input type="email" id="email" placeholder="Email" required />\n <input type="password" id="password" placeholder="Senha" required />\n <button type="submit" class="neoface-email-submit-btn">Entrar</button>\n </form>\n <button class="neoface-email-cancel-btn">Cancelar</button>\n \n \x3c!-- Branding --\x3e\n <div class="neoface-email-branding">\n <img src="/logo-icone-no-background.png" alt="NeoFaceId" class="neoface-email-brand-logo" onerror="this.style.display='none'" />\n <span>NeoFaceId by</span>\n <span class="neoface-email-brand-name">OCTA</span>\n </div>\n </div>\n </div>\n `;this.modalElement.querySelector("#email-password-form").addEventListener("submit",this.handleSubmit.bind(this));this.modalElement.querySelector(".neoface-email-cancel-btn").addEventListener("click",this.close.bind(this))}addStyles(){const e="neoface-email-password-modal-styles";if(document.getElementById(e))return;const n=document.createElement("style");n.id=e,n.textContent="\n .neoface-email-password-modal {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 10002;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n }\n\n .neoface-email-modal-overlay {\n position: absolute;\n inset: 0;\n background: rgba(0, 0, 0, 0.6);\n backdrop-filter: blur(8px);\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 20px;\n animation: fadeIn 0.3s ease-out;\n }\n\n @keyframes fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n\n @keyframes slideUp {\n from {\n opacity: 0;\n transform: translateY(20px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n\n .neoface-email-modal-content {\n background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);\n border-radius: 20px;\n padding: 32px;\n max-width: 400px;\n width: 100%;\n box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);\n animation: slideUp 0.4s ease-out;\n }\n\n .neoface-email-modal-content h2 {\n font-size: 24px;\n font-weight: 700;\n color: white;\n margin: 0 0 12px 0;\n text-align: center;\n }\n\n .neoface-email-modal-content p {\n font-size: 15px;\n color: rgba(255, 255, 255, 0.7);\n margin: 0 0 24px 0;\n text-align: center;\n line-height: 1.5;\n }\n\n .neoface-email-modal-content form {\n display: flex;\n flex-direction: column;\n gap: 16px;\n margin-bottom: 16px;\n }\n\n .neoface-email-modal-content input {\n width: 100%;\n padding: 14px 16px;\n border: 2px solid rgba(255, 255, 255, 0.2);\n border-radius: 12px;\n font-size: 15px;\n background: rgba(255, 255, 255, 0.1);\n color: white;\n font-family: inherit;\n transition: all 0.2s;\n box-sizing: border-box;\n }\n\n .neoface-email-modal-content input::placeholder {\n color: rgba(255, 255, 255, 0.5);\n }\n\n .neoface-email-modal-content input:focus {\n outline: none;\n border-color: #7c3aed;\n box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);\n background: rgba(255, 255, 255, 0.15);\n }\n\n .neoface-email-submit-btn {\n width: 100%;\n padding: 14px 24px;\n border-radius: 12px;\n border: none;\n background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);\n color: white;\n font-size: 16px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s;\n box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);\n font-family: inherit;\n }\n\n .neoface-email-submit-btn:hover {\n transform: translateY(-2px);\n box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4);\n }\n\n .neoface-email-submit-btn:active {\n transform: translateY(0);\n }\n\n .neoface-email-submit-btn:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n transform: none;\n }\n\n .neoface-email-cancel-btn {\n width: 100%;\n padding: 12px 24px;\n border-radius: 12px;\n border: 1px solid rgba(255, 255, 255, 0.2);\n background: transparent;\n color: rgba(255, 255, 255, 0.7);\n font-size: 15px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s;\n font-family: inherit;\n }\n\n .neoface-email-cancel-btn:hover {\n background: rgba(255, 255, 255, 0.1);\n color: white;\n border-color: rgba(255, 255, 255, 0.3);\n }\n\n .neoface-email-branding {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n margin-top: 32px;\n padding-top: 24px;\n border-top: 1px solid rgba(255, 255, 255, 0.1);\n font-size: 13px;\n color: rgba(255, 255, 255, 0.5);\n }\n\n .neoface-email-brand-logo {\n height: 20px;\n width: auto;\n }\n\n .neoface-email-brand-name {\n font-weight: 600;\n font-family: 'SF Pro Display', -apple-system, system-ui, sans-serif;\n color: #ffffff;\n letter-spacing: 0.3px;\n }\n\n .neoface-email-error {\n background: rgba(239, 68, 68, 0.15);\n border: 1px solid rgba(239, 68, 68, 0.4);\n border-radius: 10px;\n color: #fca5a5;\n font-size: 14px;\n padding: 12px 16px;\n margin-bottom: 16px;\n text-align: center;\n animation: fadeIn 0.2s ease-out;\n }\n\n @media (max-width: 640px) {\n .neoface-email-modal-content {\n padding: 24px;\n border-radius: 16px;\n }\n\n .neoface-email-modal-content h2 {\n font-size: 20px;\n }\n }\n ",document.head.appendChild(n)}async handleSubmit(e){e.preventDefault();const n=this.modalElement.querySelector("#email"),t=this.modalElement.querySelector("#password"),o=this.modalElement.querySelector(".neoface-email-submit-btn"),a=this.modalElement.querySelector("#login-error"),r=e=>{a.textContent=e,a.style.display="block"};a.style.display="none",a.textContent="";const i=n.value.trim(),s=t.value.trim();if(i&&s){o.disabled=!0,o.textContent="Entrando...";try{const e=await $(i,s,this.options.applicationToken);this.options.onSuccess(e),this.close()}catch(c){o.disabled=!1,o.textContent="Entrar";c instanceof k&&(c.type===R.INVALID_TOKEN||c.type===R.API_ERROR&&c.message.includes("400"))?(r("Email ou senha incorretos. Verifique seus dados e tente novamente."),t.value="",t.focus()):(r("Ocorreu um erro inesperado. Tente novamente mais tarde."),this.options.onError(c))}}else r("Preencha o email e a senha para continuar.")}}let le=!1,ue=null;async function pe(){if(!le)return ue||(ue=(async()=>{try{const e="https://cdn.jsdelivr.net/npm/@vladmandic/face-api/model";await c.nets.tinyFaceDetector.loadFromUri(e),le=!0}catch(e){}})(),ue)}async function fe(e,n,t=!1,o=!1){o?n.updateStatus("detecting"):n.updateStatus("preparing");const a=document.createElement("video");a.style.position="fixed",a.style.top="-9999px",a.style.left="-9999px",a.style.width="1px",a.style.height="1px",a.style.opacity="0",a.muted=!0,a.playsInline=!0,a.setAttribute("autoplay",""),a.setAttribute("playsinline",""),document.body.appendChild(a);let r=null;try{try{r=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"},audio:!1})}catch{r=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user"},audio:!1})}a.srcObject=r,await new Promise((e=>{if(a.readyState>=1)e();else{const n=()=>{a.removeEventListener("loadedmetadata",n),e()};a.addEventListener("loadedmetadata",n),setTimeout(e,2e3)}})),await a.play(),await new Promise((e=>{if(a.videoWidth&&a.videoHeight)e();else{const n=()=>{a.videoWidth&&a.videoHeight?e():setTimeout(n,100)};setTimeout(e,3e3),n()}})),n.updateStatus("detecting"),await new Promise((e=>setTimeout(e,100)));let o=!0;if(t||(o=await async function(e,n=5e3,t=100){return new Promise((o=>{let a=0;const r=Math.ceil(n/t);let i=null,s=!1;const d=e=>{s||(s=!0,i&&clearTimeout(i),o(e))},l=async()=>{if(!s)if(a++,le)try{if(await c.detectSingleFace(e,new c.TinyFaceDetectorOptions({inputSize:160,scoreThreshold:.3})))return void d(!0);if(a>=r)return void d(!1);i=window.setTimeout(l,t)}catch(n){d(!0)}else d(!0)};window.setTimeout((()=>{s||d(!0)}),n+500),l()}))}(a)),!o)throw r&&r.getTracks().forEach((e=>e.stop())),a.parentElement&&a.parentElement.removeChild(a),new k("Rosto não detectado. Posicione seu rosto na frente da câmera.",R.VALIDATION_ERROR);n.updateStatus("capturing");const i=document.createElement("canvas");i.width=a.videoWidth,i.height=a.videoHeight;const s=i.getContext("2d");if(!s)throw r&&r.getTracks().forEach((e=>e.stop())),a.parentElement&&a.parentElement.removeChild(a),new k("Erro ao capturar imagem",R.CAPTURE_ERROR);s.drawImage(a,0,0,i.width,i.height),r&&r.getTracks().forEach((e=>e.stop())),a.parentElement&&a.parentElement.removeChild(a);const d=await new Promise(((e,n)=>{i.toBlob((t=>{i.remove(),t?e(t):n(new Error("Failed to capture image"))}),"image/jpeg",.85)}));n.updateStatus("verifying");const l=await(async(e,n)=>{var t;N();const o=await A(e),a=await o.arrayBuffer(),r=btoa(new Uint8Array(a).reduce(((e,n)=>e+String.fromCharCode(n)),"")),i=C();let s;try{s=await fetch(`${S()}/api/v1/auth/recognition/face/external/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({image:r,purpose:"LOGIN"}),signal:i.signal})}catch(l){if(l instanceof Error){if("AbortError"===l.name)throw new k("Request timed out",R.NETWORK);if(l instanceof k)throw l;throw new k(l.message,R.NETWORK)}throw new k("Unknown error occurred",R.NETWORK_ERROR)}if(!s.ok){if(401===s.status||403===s.status)throw new k("Invalid application token",R.INVALID_TOKEN);throw new k(`API Error ${s.status}`,R.API_ERROR)}const c=await s.json();if(!c.success||!(null==(t=c.data)?void 0:t.task_id))throw new k(c.message||"Failed to start login",R.LOGIN_FAILED);const d=c.data.task_id;return new Promise(((e,n)=>{const t=`${S()}/api/v1/auth/recognition/face/external/login/events/${d}/`,o=new EventSource(t),a=setTimeout((()=>{o.close(),n(new k("Login timeout",R.NETWORK))}),31e4),r=()=>{clearTimeout(a),o.close()};o.addEventListener("success",(t=>{var o,a,i,s,c,d;r();try{const n=JSON.parse(t.data);e({success:!0,accessToken:n.token||n.access_token||"",alias:(null==(o=n.user)?void 0:o.alias)||n.alias||"",user:{id:(null==(a=n.user)?void 0:a.id)||"",email:(null==(i=n.user)?void 0:i.email)||"",role:(null==(s=n.user)?void 0:s.role)||"",validated:(null==(c=n.user)?void 0:c.validated)??!1,active:(null==(d=n.user)?void 0:d.active)??!1},person:n.person?{name:n.person.name||"",birth_date:n.person.birth_date||""}:void 0,confidence_score:n.confidence_score,recognition_id:n.recognition_id??n.history_id})}catch{n(new k("Erro ao processar resposta de login",R.API_ERROR))}})),o.addEventListener("failed",(e=>{r();try{const t=JSON.parse(e.data);n(new k(t.message||"Login failed",R.LOGIN_FAILED))}catch{n(new k("Login failed",R.LOGIN_FAILED))}})),o.addEventListener("error",(e=>{r();try{const t=JSON.parse(e.data||"{}");n(new k(t.message||"Processing error",R.API_ERROR))}catch{n(new k("Processing error",R.API_ERROR))}})),o.addEventListener("timeout",(()=>{r(),n(new k("Login timeout",R.NETWORK))})),o.onerror=()=>{r(),n(new k("SSE connection error",R.NETWORK))}}))})(d,e);if(!l.success)throw new k("Login falhou",R.LOGIN_FAILED);return l}catch(i){if(r&&r.getTracks().forEach((e=>e.stop())),a.parentElement&&a.parentElement.removeChild(a),i instanceof k)throw i;throw new k(i instanceof Error?i.message:"Erro desconhecido",R.UNKNOWN)}}async function he(e){const{applicationToken:n,onSuccess:t,onError:o,onFallbackRequest:a,onCancel:r,fastMode:i=!1}=e,s=new ie,c=new ce;let d,l=0;le||i||pe().catch((()=>{})),s.show("preparing");const u=async()=>{try{l++;const e=await fe(n,s,i,l>1);s.updateStatus("success"),setTimeout((()=>{s.close(),t(e)}),200)}catch(e){d=e instanceof k?e:new k(e instanceof Error?e.message:"Erro desconhecido",R.UNKNOWN),s.updateStatus("error"),l<2?setTimeout((()=>{u()}),500):setTimeout((()=>{s.close(),c.show(d,(()=>{l=0,s.show("preparing"),setTimeout((()=>u()),500)}),(()=>{a?a():o(new k("Por favor, use email e senha para fazer login",R.LOGIN_FAILED))}),r)}),500)}};u()}const me=Object.freeze(Object.defineProperty({__proto__:null,captureFaceSilently:async function(){return new Promise(((e,n)=>{const t=document.createElement("video");t.style.position="fixed",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.opacity="0",t.muted=!0,t.playsInline=!0,t.setAttribute("autoplay",""),t.setAttribute("playsinline","");const o=document.createElement("canvas");o.style.display="none";let a=null,r=0;const i=()=>{a&&a.getTracks().forEach((e=>e.stop())),t.parentElement&&t.parentElement.removeChild(t),o.parentElement&&o.parentElement.removeChild(o)};document.body.appendChild(t),document.body.appendChild(o);const s=e=>e?navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"},audio:!1}):navigator.mediaDevices.getUserMedia({video:{facingMode:"user"},audio:!1});s(!0).catch((()=>s(!1))).then((s=>{a=s,t.srcObject=a;const d=()=>{if(!t.videoWidth||!t.videoHeight)return r<30?(r++,void setTimeout(d,150)):(i(),void n(new k("Câmera não está pronta",R.CAMERA_ERROR)));o.width=t.videoWidth,o.height=t.videoHeight;const a=o.getContext("2d");if(!a)return i(),void n(new Error("Failed to get canvas context"));(async()=>{if(!le)return!0;try{return!!(await c.detectSingleFace(t,new c.TinyFaceDetectorOptions({inputSize:160,scoreThreshold:.3})))}catch{return!0}})().then((s=>{if(!s&&r<30)return r++,void setTimeout(d,150);a.drawImage(t,0,0,o.width,o.height),o.toBlob((t=>{i(),t?e(t):n(new Error("Failed to capture image"))}),"image/jpeg",.85)}))},l=t.play();void 0!==l?l.then((()=>{t.videoWidth&&t.videoHeight?setTimeout(d,200):(t.onloadedmetadata=()=>setTimeout(d,200),setTimeout((()=>{t.videoWidth&&t.videoHeight&&d()}),1500))})).catch((e=>{i(),n(new k("Erro ao reproduzir câmera: "+e.message,R.CAMERA_ERROR))})):t.onloadedmetadata=()=>setTimeout(d,200),t.onerror=()=>{i(),n(new k("Erro ao acessar câmera",R.CAMERA_ERROR))}})).catch((e=>{i(),n(new k("Não foi possível acessar a câmera: "+e.message,R.CAMERA_ERROR))}))}))},executeBiometricLoginFlow:he,preloadFaceDetectionModels:pe},Symbol.toStringTag,{value:"Module"}));async function ge(e){try{if(!(await P(e.applicationToken)))return void e.onError(new k("Token de aplicação inválido",R.INVALID_TOKEN));await he({applicationToken:e.applicationToken,onSuccess:e.onSuccess,onError:e.onError,onFallbackRequest:e.onFallbackRequest||(()=>{const n={applicationToken:e.applicationToken,onSuccess:e.onSuccess,onError:e.onError,title:"Login Alternativo",subtitle:"Biometria não reconhecida. Por favor, informe email e senha."};new de(n).open()}),onCancel:e.onCancel})}catch(n){e.onError(new k("Erro ao inicializar login facial: "+n.message,R.INITIALIZATION_ERROR))}}async function we(e){try{if(!(await P(e.applicationToken)))return void e.onError(new k("Token de aplicação inválido",R.INVALID_TOKEN));const n={mode:"hand",onSuccess:async(n,t)=>{try{const t=await fetch(n).then((e=>e.blob())),o=await F(t,e.applicationToken);e.onSuccess(o)}catch(o){e.onError(o)}},onError:e.onError,onCancel:e.onCancel,countdown:e.countdown,title:e.title||"Login por Mão",subtitle:e.subtitle||"Posicione sua mão dentro do quadro para fazer login."},t=new re(n);await t.open()}catch(n){e.onError(new k("Erro ao inicializar login por mão: "+n.message,R.INITIALIZATION_ERROR))}}async function ve(e){try{if(!(await P(e.applicationToken)))return void e.onError(new k("Token de aplicação inválido",R.INVALID_TOKEN));const n={mode:"auto",onSuccess:async(n,t)=>{try{const t=await fetch(n).then((e=>e.blob())),o=await F(t,e.applicationToken);e.onSuccess(o)}catch(o){e.onError(o)}},onError:e.onError,onCancel:e.onCancel,countdown:e.countdown,title:e.title||"Login Biométrico",subtitle:e.subtitle||"Posicione seu rosto ou mão dentro do quadro para login automático."},t=new re(n);await t.open()}catch(n){e.onError(new k("Erro ao inicializar login automático: "+n.message,R.INITIALIZATION_ERROR))}}async function be(e){try{const t=await(n=e,new Promise(((e,t)=>{const o=new Image;o.onload=()=>e(o),o.onerror=()=>t(new Error("Erro ao carregar imagem"));const a=n.startsWith("data:")?n:`data:image/jpeg;base64,${n}`;o.src=a}))),o=await async function(e){try{if("undefined"!=typeof window&&window.faceapi){const n=window.faceapi;await xe();const t=new n.TinyFaceDetectorOptions({inputSize:320,scoreThreshold:.5}),o=await n.detectAllFaces(e,t).withFaceLandmarks();if(o&&o.length>0){const e=o.reduce(((e,n)=>n.detection.score>e.detection.score?n:e));return{confidence:e.detection.score,details:{faces:o.length,landmarks:e.landmarks,box:e.detection.box}}}}return{confidence:0}}catch(n){return{confidence:0}}}(t);if(o.confidence>.7)return{type:"face",confidence:o.confidence,details:o.details};const a=await async function(e){try{const n=document.createElement("canvas"),t=n.getContext("2d");if(!t)return{confidence:0};n.width=e.width,n.height=e.height,t.drawImage(e,0,0);const o=function(e){const{data:n,width:t,height:o}=e;let a=0,r=0;for(let l=0;l<n.length;l+=4){ye(n[l],n[l+1],n[l+2])&&a++,r++}const i=a/r,s=t/o;let c=0;i>.15&&i<.7&&(c+=i/.7*.4);s>.6&&s<1.8&&(c+=.3);const d=t*o;d>1e4&&d<5e5&&(c+=.3);return{confidence:Math.min(c,.8),skinRatio:i,aspectRatio:s,imageSize:d,skinPixels:a,totalPixels:r}}(t.getImageData(0,0,n.width,n.height));return{confidence:o.confidence,details:o}}catch(n){return{confidence:0}}}(t);return a.confidence>.6?{type:"hand",confidence:a.confidence,details:a.details}:{type:"unknown",confidence:Math.max(o.confidence,a.confidence)}}catch(t){return{type:"face",confidence:.5}}var n}function ye(e,n,t){const o=.299*e+.587*n+.114*t,a=-.169*e-.331*n+.5*t+128,r=.5*e-.419*n-.081*t+128;return o>80&&o<255&&a>85&&a<135&&r>135&&r<180}async function xe(){if("undefined"==typeof window||!window.faceapi)return;const e=window.faceapi;if(!e.nets.tinyFaceDetector.isLoaded)try{await Promise.all([e.nets.tinyFaceDetector.loadFromUri("./models"),e.nets.faceLandmark68Net.loadFromUri("./models")])}catch(n){}}async function Ee(){try{"undefined"!=typeof window&&await xe()}catch(e){}}function Re(){return"undefined"!=typeof window&&window.faceapi&&window.faceapi.nets.tinyFaceDetector.isLoaded}const ke=Object.freeze(Object.defineProperty({__proto__:null,detectBiometricType:be,initializeBiometricDetection:Ee,isAdvancedDetectionAvailable:Re},Symbol.toStringTag,{value:"Module"}));class Te{constructor(e){r(this,"overlay",null),r(this,"video",null),r(this,"canvas",null),r(this,"stream",null),r(this,"step","face"),r(this,"countdownSeconds"),r(this,"title"),r(this,"subtitle"),r(this,"faceBlob",null),r(this,"documentBlob",null),this.countdownSeconds=(null==e?void 0:e.countdown)??3,this.title=null==e?void 0:e.title,this.subtitle=null==e?void 0:e.subtitle}async open(){if(await this.createDom(),await this.startCamera(),await this.runFaceCaptureCountdown(),this.faceBlob=await this.captureFrame(),this.step="document",this.updateTexts("Captura do Documento",'Posicione seu documento visível e clique em "Capturar"'),await this.waitForUserCaptureClick(),this.documentBlob=await this.captureFrame(),await this.close(),!this.faceBlob||!this.documentBlob)throw new Error("Falha na captura das imagens de onboarding");return{face:this.faceBlob,document:this.documentBlob}}async createDom(){const e=document.createElement("div");e.className="neofaceid-modal-overlay",e.innerHTML=`\n <div class="neofaceid-modal">\n <div class="neofaceid-modal-header">\n <h2 class="neofaceid-title">${this.title??"Onboarding NeoFaceID"}</h2>\n <button class="neofaceid-close-btn" aria-label="Fechar">×</button>\n </div>\n <div class="neofaceid-modal-body">\n <p class="neofaceid-subtitle">${this.subtitle??"Vamos capturar sua face e documento"}</p>\n <div class="neofaceid-camera-container">\n <video class="neofaceid-video" autoplay muted playsinline></video>\n <canvas class="neofaceid-canvas"></canvas>\n <div class="neofaceid-overlay">\n <div class="neofaceid-frame"></div>\n <div class="neofaceid-countdown" style="display:none"><span class="neofaceid-countdown-number">${this.countdownSeconds}</span></div>\n </div>\n </div>\n <div class="neofaceid-status"><p class="neofaceid-status-text">Posicione seu rosto no quadro</p></div>\n </div>\n <div class="neofaceid-modal-footer">\n <button class="neofaceid-cancel-btn">Cancelar</button>\n <button class="neofaceid-capture-btn" disabled>Capturar</button>\n </div>\n </div>\n `;const n=document.createElement("style");n.textContent="\n .neofaceid-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display:flex; align-items:center; justify-content:center; z-index: 9999; }\n .neofaceid-modal { background:#fff; border-radius:12px; width: 92%; max-width: 640px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); overflow:hidden; }\n .neofaceid-modal-header { padding: 16px 20px; border-bottom: 1px solid #eee; display:flex; align-items:center; justify-content:space-between; }\n .neofaceid-title { margin:0; font-size: 20px; color:#333; }\n .neofaceid-close-btn { background:none; border:none; font-size:24px; cursor:pointer; color:#666; }\n .neofaceid-modal-body { padding: 16px 20px; }\n .neofaceid-subtitle { margin: 0 0 12px 0; color:#666; }\n .neofaceid-camera-container { position: relative; background:#000; border-radius:8px; overflow:hidden; aspect-ratio: 4/3; margin-bottom: 12px; }\n .neofaceid-video { width:100%; height:100%; object-fit: cover; }\n .neofaceid-canvas { position:absolute; top:0; left:0; }\n .neofaceid-overlay { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; }\n .neofaceid-frame { width: 200px; height: 200px; border: 3px solid #4CAF50; border-radius: 50%; box-shadow: 0 0 0 2px rgba(76,175,80,0.3); }\n .neofaceid-countdown { position:absolute; top:16px; right:16px; background: rgba(0,0,0,0.7); color:#fff; width: 48px; height:48px; display:flex; align-items:center; justify-content:center; border-radius:50%; }\n .neofaceid-modal-footer { padding: 16px 20px; border-top: 1px solid #eee; display:flex; gap: 8px; justify-content:flex-end; }\n .neofaceid-cancel-btn { background:#f5f5f5; color:#666; border:none; border-radius:6px; padding:10px 18px; cursor:pointer; }\n .neofaceid-capture-btn { background:#4CAF50; color:#fff; border:none; border-radius:6px; padding:10px 18px; cursor:pointer; }\n .neofaceid-capture-btn:disabled { background:#ccc; cursor:not-allowed; }\n ",document.head.appendChild(n),document.body.appendChild(e),this.overlay=e,this.video=this.overlay.querySelector(".neofaceid-video"),this.canvas=this.overlay.querySelector(".neofaceid-canvas");const t=this.overlay.querySelector(".neofaceid-close-btn"),o=this.overlay.querySelector(".neofaceid-cancel-btn");t.onclick=()=>this.close(),o.onclick=()=>this.close();this.overlay.querySelector(".neofaceid-capture-btn").disabled=!0}async startCamera(){if(!this.video)throw new Error("Elemento de vídeo não encontrado");this.video.muted=!0,this.video.playsInline=!0;try{this.stream=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:{ideal:1280},height:{ideal:720}},audio:!1})}catch{this.stream=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user"},audio:!1})}this.video.srcObject=this.stream,await this.video.play()}async runFaceCaptureCountdown(){if(!this.overlay)return;const e=this.overlay.querySelector(".neofaceid-countdown"),n=this.overlay.querySelector(".neofaceid-countdown-number"),t=this.overlay.querySelector(".neofaceid-status-text");e.style.display="flex",t.textContent="Prepare-se! Capturando seu rosto...";let o=this.countdownSeconds;n.textContent=String(o),await new Promise((t=>{const a=setInterval((()=>{o-=1,n.textContent=String(o),o<=0&&(clearInterval(a),e.style.display="none",t())}),1e3)}))}async waitForUserCaptureClick(){if(!this.overlay)return;const e=this.overlay.querySelector(".neofaceid-capture-btn"),n=this.overlay.querySelector(".neofaceid-status-text");e.disabled=!1,n.textContent='Clique em "Capturar" quando o documento estiver visível',await new Promise((n=>{const t=()=>{e.removeEventListener("click",t),n()};e.addEventListener("click",t)})),e.disabled=!0}async captureFrame(){if(!this.video||!this.canvas)throw new Error("Elementos de captura não encontrados");const e=this.canvas.getContext("2d");if(!e)throw new Error("Falha ao obter contexto do canvas");this.canvas.width=this.video.videoWidth,this.canvas.height=this.video.videoHeight,e.drawImage(this.video,0,0,this.canvas.width,this.canvas.height);return await new Promise(((e,n)=>{this.canvas.toBlob((t=>t?e(t):n(new Error("Falha ao gerar imagem"))),"image/jpeg",.92)}))}updateTexts(e,n){if(!this.overlay)return;const t=this.overlay.querySelector(".neofaceid-title"),o=this.overlay.querySelector(".neofaceid-subtitle"),a=this.overlay.querySelector(".neofaceid-frame");t.textContent=e,o.textContent=n,"document"===this.step&&(a.style.borderRadius="8px",a.style.width="280px",a.style.height="180px")}async close(){this.stream&&(this.stream.getTracks().forEach((e=>e.stop())),this.stream=null),this.overlay&&(this.overlay.remove(),this.overlay=null)}}const Oe=["Olhe diretamente para a câmera","Vire levemente a cabeça para a esquerda","Vire levemente a cabeça para a direita","Mostre o polegar para cima (👍) e olhe para a câmera"],_e={RG:{name:"RG / Carteira de Identidade",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="4" width="18" height="16" rx="2"/><circle cx="9" cy="10" r="2"/><path d="M15 8h2M15 12h2M7 16h10"/></svg>',hasBack:!0,frontLabel:"Frente do RG",backLabel:"Verso do RG"},CNH:{name:"CNH / Carteira de Motorista",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="6" width="18" height="12" rx="2"/><circle cx="8" cy="12" r="2"/><path d="M13 10h5M13 14h3"/></svg>',hasBack:!0,frontLabel:"Frente da CNH",backLabel:"Verso da CNH"},CPF:{name:"CPF",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6M16 13H8M16 17H8M10 9H8"/></svg>',hasBack:!1,frontLabel:"Cartão CPF"}};class Ie{constructor(e){r(this,"overlay",null),r(this,"video",null),r(this,"canvas",null),r(this,"stream",null),r(this,"resolvePromise",null),r(this,"options"),r(this,"selectedDocument",null),r(this,"currentStep","select"),r(this,"frontBlob",null),r(this,"backBlob",null),this.options={title:(null==e?void 0:e.title)??"Validação de Identidade",subtitle:(null==e?void 0:e.subtitle)??"Selecione o tipo de documento",useBackCamera:(null==e?void 0:e.useBackCamera)??!0,onCancel:null==e?void 0:e.onCancel,preSelectedDocument:null==e?void 0:e.preSelectedDocument}}async open(){return new Promise((e=>{this.resolvePromise=e,this.options.preSelectedDocument&&(this.selectedDocument=this.options.preSelectedDocument,this.currentStep="front"),this.render()}))}render(){var e;this.overlay||this.createOverlay();const n=null==(e=this.overlay)?void 0:e.querySelector(".neoface-doc-content");if(n)switch(this.currentStep){case"select":n.innerHTML=this.renderSelectStep(),this.bindSelectEvents();break;case"front":case"back":n.innerHTML=this.renderCaptureStep(),this.bindCaptureEvents(),this.startCamera();break;case"preview-front":case"preview-back":n.innerHTML=this.renderPreviewStep(),this.bindPreviewEvents()}}createOverlay(){const e=document.createElement("div");if(e.className="neoface-doc-overlay",e.innerHTML='\n <div class="neoface-doc-modal">\n <div class="neoface-doc-content"></div>\n </div>\n ',!document.getElementById("neoface-doc-styles-v2")){const e=document.createElement("style");e.id="neoface-doc-styles-v2",e.textContent=this.getStyles(),document.head.appendChild(e)}document.body.appendChild(e),this.overlay=e}renderSelectStep(){return`\n <div class="neoface-doc-header">\n <div class="neoface-doc-header-left">\n <h2 class="neoface-doc-title">${this.options.title}</h2>\n <p class="neoface-doc-subtitle">${this.options.subtitle}</p>\n </div>\n <button class="neoface-doc-close-btn" aria-label="Fechar">\n <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M18 6L6 18M6 6l12 12"/>\n </svg>\n </button>\n </div>\n \n <div class="neoface-doc-body">\n <div class="neoface-doc-select-grid">\n ${Object.entries(_e).map((([e,n])=>`\n <button class="neoface-doc-select-option" data-type="${e}">\n <span class="neoface-doc-select-icon">${n.icon}</span>\n <span class="neoface-doc-select-name">${n.name}</span>\n <svg class="neoface-doc-select-arrow" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg>\n </button>\n `)).join("")}\n </div>\n \n <div class="neoface-doc-tips">\n <div class="neoface-doc-tip">\n <span>Garanta boa iluminação e que todos os dados estejam legíveis</span>\n </div>\n </div>\n </div>\n \n ${this.renderBranding()}\n `}renderCaptureStep(){const e=this.selectedDocument?_e[this.selectedDocument]:null;if(!e)return"";const n="back"===this.currentStep,t=n?e.backLabel:e.frontLabel;return`\n <div class="neoface-doc-header">\n <div class="neoface-doc-header-left">\n <div class="neoface-doc-step-indicator">\n <span class="neoface-doc-step-badge">${n?2:1}/${e.hasBack?2:1}</span>\n <span class="neoface-doc-step-label">${t}</span>\n </div>\n </div>\n <button class="neoface-doc-close-btn" aria-label="Fechar">\n <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M18 6L6 18M6 6l12 12"/>\n </svg>\n </button>\n </div>\n \n <div class="neoface-doc-body">\n <div class="neoface-doc-camera-container">\n <video class="neoface-doc-video" autoplay muted playsinline></video>\n <canvas class="neoface-doc-canvas"></canvas>\n \n <div class="neoface-doc-guide">\n <div class="neoface-doc-frame">\n <div class="neoface-doc-corner neoface-doc-corner-tl"></div>\n <div class="neoface-doc-corner neoface-doc-corner-tr"></div>\n <div class="neoface-doc-corner neoface-doc-corner-bl"></div>\n <div class="neoface-doc-corner neoface-doc-corner-br"></div>\n <div class="neoface-doc-frame-label">${t}</div>\n </div>\n </div>\n \n <div class="neoface-doc-loading" style="display:none">\n <div class="neoface-doc-spinner"></div>\n </div>\n </div>\n \n <div class="neoface-doc-instructions">\n <div class="neoface-doc-instruction">\n <svg class="neoface-doc-instruction-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18M9 21V9"/></svg>\n <span>Posicione o documento dentro do quadro</span>\n </div>\n <div class="neoface-doc-instruction">\n <svg class="neoface-doc-instruction-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="5"/><path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"/></svg>\n <span>Evite reflexos e sombras</span>\n </div>\n </div>\n </div>\n \n <div class="neoface-doc-footer">\n <button class="neoface-doc-btn neoface-doc-btn-secondary neoface-doc-back-btn">\n ← Voltar\n </button>\n <input type="file" accept="image/*" class="neoface-doc-file-input" style="display:none" />\n <button class="neoface-doc-btn neoface-doc-btn-secondary neoface-doc-upload-btn">\n <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>\n <polyline points="17,8 12,3 7,8"/>\n <line x1="12" y1="3" x2="12" y2="15"/>\n </svg>\n Anexar\n </button>\n <button class="neoface-doc-btn neoface-doc-btn-primary neoface-doc-capture-btn">\n <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <circle cx="12" cy="12" r="10"/>\n <circle cx="12" cy="12" r="4"/>\n </svg>\n Capturar\n </button>\n </div>\n \n ${this.renderBranding()}\n `}renderPreviewStep(){const e=this.selectedDocument?_e[this.selectedDocument]:null;if(!e)return"";const n="preview-front"===this.currentStep,t=n?e.frontLabel:e.backLabel,o=!e.hasBack||"preview-back"===this.currentStep;return`\n <div class="neoface-doc-header">\n <div class="neoface-doc-header-left">\n <div class="neoface-doc-step-indicator">\n <span class="neoface-doc-step-badge">${n?1:2}/${e.hasBack?2:1}</span>\n <span class="neoface-doc-step-label">Confirmar ${t}</span>\n </div>\n </div>\n <button class="neoface-doc-close-btn" aria-label="Fechar">\n <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M18 6L6 18M6 6l12 12"/>\n </svg>\n </button>\n </div>\n \n <div class="neoface-doc-body">\n <div class="neoface-doc-preview-single">\n <span class="neoface-doc-preview-label">${t}</span>\n <img class="neoface-doc-preview-img neoface-doc-preview-current" />\n </div>\n \n <div class="neoface-doc-preview-hint">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4M12 8h.01"/></svg>\n <span>Verifique se todos os dados estão legíveis</span>\n </div>\n </div>\n \n <div class="neoface-doc-footer">\n <button class="neoface-doc-btn neoface-doc-btn-secondary neoface-doc-retake-btn">\n <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M1 4v6h6M23 20v-6h-6"/>\n <path d="M20.49 9A9 9 0 0 0 5.64 5.64L1 10m22 4l-4.64 4.36A9 9 0 0 1 3.51 15"/>\n </svg>\n Refazer\n </button>\n <button class="neoface-doc-btn neoface-doc-btn-success neoface-doc-confirm-btn">\n <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M20 6L9 17l-5-5"/>\n </svg>\n ${o?"Confirmar e Enviar":"Próximo"}\n </button>\n </div>\n \n ${this.renderBranding()}\n `}renderBranding(){return'\n <div class="neoface-doc-branding">\n <img src="/logo-icone-no-background.png" \n alt="NeoFaceId" class="neoface-doc-brand-icon" \n onerror="this.style.display=\'none\'" />\n <span class="neoface-doc-brand-name-text">NeoFaceId</span>\n <span class="neoface-doc-brand-text">by</span>\n <span class="neoface-doc-brand-name">OCTA</span>\n </div>\n '}bindSelectEvents(){var e;const n=null==(e=this.overlay)?void 0:e.querySelectorAll(".neoface-doc-select-option");null==n||n.forEach((e=>{e.addEventListener("click",(()=>{const n=e.getAttribute("data-type");this.selectedDocument=n,this.currentStep="front",this.render()}))})),this.bindCloseEvent()}bindCaptureEvents(){var e,n,t,o;const a=null==(e=this.overlay)?void 0:e.querySelector(".neoface-doc-capture-btn"),r=null==(n=this.overlay)?void 0:n.querySelector(".neoface-doc-back-btn"),i=null==(t=this.overlay)?void 0:t.querySelector(".neoface-doc-upload-btn"),s=null==(o=this.overlay)?void 0:o.querySelector(".neoface-doc-file-input");null==a||a.addEventListener("click",(()=>this.handleCapture())),null==r||r.addEventListener("click",(()=>this.handleBack())),null==i||i.addEventListener("click",(()=>null==s?void 0:s.click())),null==s||s.addEventListener("change",(e=>this.handleFileUpload(e))),this.bindCloseEvent()}async handleFileUpload(e){var n,t;const o=null==(n=e.target.files)?void 0:n[0];if(!o)return;const a=null==(t=this.overlay)?void 0:t.querySelector(".neoface-doc-loading");a&&(a.style.display="flex");try{const e=await this.compressUploadedImage(o);"front"===this.currentStep?(this.frontBlob=e,this.currentStep="preview-front"):"back"===this.currentStep&&(this.backBlob=e,this.currentStep="preview-back"),this.stopCamera(),this.render()}catch(r){const e=new Blob([o],{type:o.type});"front"===this.currentStep?(this.frontBlob=e,this.currentStep="preview-front"):"back"===this.currentStep&&(this.backBlob=e,this.currentStep="preview-back"),this.stopCamera(),this.render()}}compressUploadedImage(e){return new Promise(((n,t)=>{const o=new Image;o.onload=()=>{const e=1280;let a=o.width,r=o.height;a>r&&a>e?(r=r*e/a,a=e):r>e&&(a=a*e/r,r=e);const i=document.createElement("canvas");i.width=a,i.height=r;const s=i.getContext("2d");s?(s.drawImage(o,0,0,a,r),i.toBlob((e=>{e?n(e):t(new Error("Failed to compress image"))}),"image/jpeg",.75)):t(new Error("Failed to get canvas context"))},o.onerror=()=>t(new Error("Failed to load image")),o.src=URL.createObjectURL(e)}))}bindPreviewEvents(){var e,n,t;const o=null==(e=this.overlay)?void 0:e.querySelector(".neoface-doc-confirm-btn"),a=null==(n=this.overlay)?void 0:n.querySelector(".neoface-doc-retake-btn");null==o||o.addEventListener("click",(()=>this.handleConfirm())),null==a||a.addEventListener("click",(()=>this.handleRetake()));const r=null==(t=this.overlay)?void 0:t.querySelector(".neoface-doc-preview-current");if(r){const e="preview-front"===this.currentStep?this.frontBlob:this.backBlob;e&&(r.src=URL.createObjectURL(e))}this.bindCloseEvent()}bindCloseEvent(){var e;const n=null==(e=this.overlay)?void 0:e.querySelector(".neoface-doc-close-btn");null==n||n.addEventListener("click",(()=>this.handleCancel()))}async startCamera(){var e,n,t;try{const t={video:{facingMode:this.options.useBackCamera?"environment":"user",width:{ideal:1920},height:{ideal:1080}},audio:!1};this.stream=await navigator.mediaDevices.getUserMedia(t),this.video=null==(e=this.overlay)?void 0:e.querySelector(".neoface-doc-video"),this.canvas=null==(n=this.overlay)?void 0:n.querySelector(".neoface-doc-canvas"),this.video&&(this.video.muted=!0,this.video.playsInline=!0,this.video.srcObject=this.stream,await this.video.play())}catch(o){if(this.options.useBackCamera)try{this.stream=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user"},audio:!1}),this.video&&(this.video.srcObject=this.stream,await this.video.play())}catch(a){null==(t=this.resolvePromise)||t.call(this,{success:!1,frontImage:null,backImage:null,error:"Não foi possível acessar a câmera"}),this.close()}}}stopCamera(){this.stream&&(this.stream.getTracks().forEach((e=>e.stop())),this.stream=null)}async handleCapture(){var e;if(!this.video||!this.canvas)return;const n=null==(e=this.overlay)?void 0:e.querySelector(".neoface-doc-loading");n&&(n.style.display="flex");const t=this.canvas.getContext("2d");if(!t)return;const o=this.video.videoWidth,a=this.video.videoHeight,r=Math.floor(.75*o),i=Math.floor(.65*a),s=Math.floor((o-r)/2),c=Math.floor((a-i)/2);this.canvas.width=r,this.canvas.height=i,t.drawImage(this.video,s,c,r,i,0,0,r,i);try{const e=await new Promise(((e,n)=>{this.canvas.toBlob((t=>t?e(t):n(new Error("Capture failed"))),"image/jpeg",.92)}));"front"===this.currentStep?(this.frontBlob=e,this.stopCamera(),this.currentStep="preview-front",this.render()):"back"===this.currentStep&&(this.backBlob=e,this.stopCamera(),this.currentStep="preview-back",this.render())}catch(d){}finally{n&&(n.style.display="none")}}handleBack(){this.stopCamera(),"back"===this.currentStep?(this.currentStep="front",this.frontBlob=null):"front"===this.currentStep&&(this.currentStep="select",this.selectedDocument=null),this.render()}handleRetake(){"preview-front"===this.currentStep?(this.frontBlob=null,this.currentStep="front"):"preview-back"===this.currentStep&&(this.backBlob=null,this.currentStep="back"),this.render()}handleConfirm(){var e,n;const t=this.selectedDocument?_e[this.selectedDocument]:null;"preview-front"===this.currentStep?(null==t?void 0:t.hasBack)?(this.currentStep="back",this.render()):(null==(e=this.resolvePromise)||e.call(this,{success:!0,documentType:this.selectedDocument||void 0,frontImage:this.frontBlob,backImage:null}),this.close()):"preview-back"===this.currentStep&&(null==(n=this.resolvePromise)||n.call(this,{success:!0,documentType:this.selectedDocument||void 0,frontImage:this.frontBlob,backImage:this.backBlob}),this.close())}handleCancel(){var e,n,t;null==(n=(e=this.options).onCancel)||n.call(e),null==(t=this.resolvePromise)||t.call(this,{success:!1,frontImage:null,backImage:null,error:"cancelled"}),this.close()}close(){this.stopCamera(),this.overlay&&(this.overlay.remove(),this.overlay=null)}getStyles(){return"\n .neoface-doc-overlay {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.85);\n backdrop-filter: blur(8px);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10000;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n padding: 16px;\n }\n \n .neoface-doc-modal {\n background: linear-gradient(145deg, #1a1a2e 0%, #16213e 100%);\n border-radius: 24px;\n width: 100%;\n max-width: 520px;\n box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255,255,255,0.1);\n overflow: hidden;\n animation: neoface-doc-slideIn 0.3s ease;\n }\n \n @keyframes neoface-doc-slideIn {\n from { transform: translateY(20px) scale(0.98); opacity: 0; }\n to { transform: translateY(0) scale(1); opacity: 1; }\n }\n \n .neoface-doc-header {\n padding: 20px 24px;\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n border-bottom: 1px solid rgba(255, 255, 255, 0.08);\n }\n \n .neoface-doc-title {\n margin: 0 0 4px 0;\n font-size: 20px;\n font-weight: 600;\n color: #fff;\n }\n \n .neoface-doc-subtitle {\n margin: 0;\n font-size: 14px;\n color: rgba(255, 255, 255, 0.6);\n }\n \n .neoface-doc-step-indicator {\n display: flex;\n align-items: center;\n gap: 12px;\n }\n \n .neoface-doc-step-badge {\n background: linear-gradient(135deg, #00c8ff, #0099cc);\n color: #fff;\n font-size: 12px;\n font-weight: 600;\n padding: 4px 10px;\n border-radius: 20px;\n }\n \n .neoface-doc-step-label {\n font-size: 16px;\n font-weight: 500;\n color: #fff;\n }\n \n .neoface-doc-close-btn {\n background: transparent;\n border: none;\n padding: 4px;\n cursor: pointer;\n color: rgba(255, 255, 255, 0.5);\n transition: all 0.2s;\n }\n \n .neoface-doc-close-btn:hover {\n color: #fff;\n }\n \n .neoface-doc-body {\n padding: 20px 24px;\n }\n \n /* Select Step */\n .neoface-doc-select-grid {\n display: flex;\n flex-direction: column;\n gap: 12px;\n }\n \n .neoface-doc-select-option {\n display: flex;\n align-items: center;\n gap: 16px;\n padding: 16px 20px;\n background: rgba(255, 255, 255, 0.05);\n border: 2px solid rgba(255, 255, 255, 0.1);\n border-radius: 14px;\n cursor: pointer;\n transition: all 0.2s;\n text-align: left;\n }\n \n .neoface-doc-select-option:hover {\n background: rgba(0, 200, 255, 0.1);\n border-color: rgba(0, 200, 255, 0.4);\n transform: translateX(4px);\n }\n \n .neoface-doc-select-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 44px;\n height: 44px;\n background: rgba(0, 200, 255, 0.15);\n border-radius: 12px;\n color: #00c8ff;\n }\n \n .neoface-doc-select-icon svg {\n width: 24px;\n height: 24px;\n }\n \n .neoface-doc-select-name {\n flex: 1;\n font-size: 15px;\n font-weight: 500;\n color: #fff;\n }\n \n .neoface-doc-select-arrow {\n color: rgba(255, 255, 255, 0.4);\n transition: transform 0.2s;\n }\n \n .neoface-doc-select-option:hover .neoface-doc-select-arrow {\n color: #00c8ff;\n transform: translateX(4px);\n }\n \n .neoface-doc-tips {\n margin-top: 20px;\n }\n \n .neoface-doc-tip {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 14px 16px;\n background: rgba(0, 200, 255, 0.08);\n border: 1px solid rgba(0, 200, 255, 0.15);\n border-radius: 10px;\n color: rgba(255, 255, 255, 0.8);\n font-size: 13px;\n line-height: 1;\n text-align: center;\n }\n \n .neoface-doc-tip span {\n transform: translateY(-2px);\n }\n \n .neoface-doc-tip-icon {\n color: #00c8ff;\n flex-shrink: 0;\n }\n \n /* Camera */\n .neoface-doc-camera-container {\n position: relative;\n background: #000;\n border-radius: 16px;\n overflow: hidden;\n aspect-ratio: 4/3;\n }\n \n .neoface-doc-video {\n width: 100%;\n height: 100%;\n object-fit: cover;\n }\n \n .neoface-doc-canvas {\n display: none;\n }\n \n .neoface-doc-guide {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n pointer-events: none;\n }\n \n .neoface-doc-frame {\n width: 75%;\n height: 65%;\n position: relative;\n border: 2px dashed rgba(0, 200, 255, 0.5);\n border-radius: 12px;\n background: rgba(0, 200, 255, 0.03);\n }\n \n .neoface-doc-corner {\n position: absolute;\n width: 28px;\n height: 28px;\n border-color: #00c8ff;\n border-style: solid;\n }\n \n .neoface-doc-corner-tl { top: -2px; left: -2px; border-width: 4px 0 0 4px; border-radius: 10px 0 0 0; }\n .neoface-doc-corner-tr { top: -2px; right: -2px; border-width: 4px 4px 0 0; border-radius: 0 10px 0 0; }\n .neoface-doc-corner-bl { bottom: -2px; left: -2px; border-width: 0 0 4px 4px; border-radius: 0 0 0 10px; }\n .neoface-doc-corner-br { bottom: -2px; right: -2px; border-width: 0 4px 4px 0; border-radius: 0 0 10px 0; }\n \n .neoface-doc-frame-label {\n position: absolute;\n bottom: -30px;\n left: 50%;\n transform: translateX(-50%);\n background: rgba(0, 0, 0, 0.7);\n color: #00c8ff;\n font-size: 12px;\n font-weight: 500;\n padding: 6px 14px;\n border-radius: 20px;\n white-space: nowrap;\n }\n \n .neoface-doc-loading {\n position: absolute;\n inset: 0;\n background: rgba(0, 0, 0, 0.7);\n display: none;\n align-items: center;\n justify-content: center;\n }\n \n .neoface-doc-spinner {\n width: 48px;\n height: 48px;\n border: 4px solid rgba(255, 255, 255, 0.2);\n border-top-color: #00c8ff;\n border-radius: 50%;\n animation: neoface-doc-spin 0.8s linear infinite;\n }\n \n @keyframes neoface-doc-spin {\n to { transform: rotate(360deg); }\n }\n \n .neoface-doc-instructions {\n display: flex;\n flex-direction: column;\n gap: 8px;\n margin-top: 16px;\n }\n \n .neoface-doc-instruction {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 10px 14px;\n background: rgba(255, 255, 255, 0.04);\n border-radius: 10px;\n font-size: 13px;\n color: rgba(255, 255, 255, 0.75);\n }\n \n .neoface-doc-instruction-icon {\n color: rgba(255, 255, 255, 0.5);\n flex-shrink: 0;\n }\n \n /* Preview */\n .neoface-doc-preview-single {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 12px;\n }\n \n .neoface-doc-preview-label {\n font-size: 12px;\n font-weight: 500;\n color: rgba(255, 255, 255, 0.6);\n text-transform: uppercase;\n letter-spacing: 0.5px;\n text-align: center;\n }\n \n .neoface-doc-preview-img {\n width: 75%;\n height: auto;\n border-radius: 12px;\n border: 2px solid rgba(0, 200, 255, 0.3);\n box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);\n }\n \n .neoface-doc-preview-hint {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 12px 16px;\n background: rgba(0, 200, 255, 0.08);\n border: 1px solid rgba(0, 200, 255, 0.15);\n border-radius: 10px;\n font-size: 13px;\n color: rgba(255, 255, 255, 0.8);\n margin-top: 8px;\n }\n \n .neoface-doc-preview-hint svg {\n color: #00c8ff;\n flex-shrink: 0;\n }\n \n /* Footer */\n .neoface-doc-footer {\n padding: 16px 24px;\n display: flex;\n gap: 12px;\n justify-content: flex-end;\n border-top: 1px solid rgba(255, 255, 255, 0.08);\n }\n \n .neoface-doc-btn {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 12px 20px;\n border-radius: 12px;\n font-size: 14px;\n font-weight: 500;\n cursor: pointer;\n transition: all 0.2s;\n border: none;\n }\n \n .neoface-doc-btn-primary {\n background: linear-gradient(135deg, #00c8ff 0%, #0099cc 100%);\n color: #fff;\n }\n \n .neoface-doc-btn-primary:hover {\n transform: translateY(-2px);\n box-shadow: 0 6px 20px rgba(0, 200, 255, 0.4);\n }\n \n .neoface-doc-btn-success {\n background: linear-gradient(135deg, #10b981 0%, #059669 100%);\n color: #fff;\n }\n \n .neoface-doc-btn-success:hover {\n transform: translateY(-2px);\n box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);\n }\n \n .neoface-doc-btn-secondary {\n background: rgba(255, 255, 255, 0.08);\n color: rgba(255, 255, 255, 0.8);\n }\n \n .neoface-doc-btn-secondary:hover {\n background: rgba(255, 255, 255, 0.12);\n color: #fff;\n }\n \n /* Branding */\n .neoface-doc-branding {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 16px 24px;\n border-top: 1px solid rgba(255, 255, 255, 0.06);\n }\n \n .neoface-doc-brand-icon {\n height: 22px;\n width: auto;\n }\n \n .neoface-doc-brand-name-text {\n font-size: 13px;\n font-weight: 600;\n color: rgba(255, 255, 255, 0.9);\n }\n \n .neoface-doc-brand-text {\n font-size: 12px;\n color: rgba(255, 255, 255, 0.5);\n }\n \n .neoface-doc-brand-name {\n font-size: 13px;\n font-weight: 700;\n color: #00c8ff;\n letter-spacing: 1px;\n }\n \n /* Mobile */\n @media (max-width: 500px) {\n .neoface-doc-modal {\n border-radius: 20px;\n }\n \n .neoface-doc-header,\n .neoface-doc-body,\n .neoface-doc-footer {\n padding: 16px 18px;\n }\n \n .neoface-doc-preview-grid.has-back {\n grid-template-columns: 1fr;\n }\n }\n "}}const Se=async e=>new Ie(e).open(),Ne=Object.freeze(Object.defineProperty({__proto__:null,DocumentCaptureModal:Ie,startDocumentCapture:Se},Symbol.toStringTag,{value:"Module"}));e.BiometricCaptureModal=re,e.BiometricRegistrationModal=ae,e.BiometricStatusOverlay=ie,e.DocumentCaptureModal=Ie,e.ENVIRONMENT_URLS=O,e.EmailPasswordModal=de,e.ErrorType=R,e.FaceCaptureModal=K,e.FallbackPrompt=ce,e.NeoFaceError=k,e.NeoFaceID=class{constructor(e){if(r(this,"appToken"),r(this,"signature"),r(this,"sessionData"),this.appToken=e.appToken,this.signature=e.signature,this.sessionData=e.sessionData,this.signature&&!this.validateSignatureFormat(this.signature))throw new k("Invalid signature format. Expected HMAC-SHA256 hex string (minimum 64 characters)",R.VALIDATION_ERROR);if(this.sessionData&&(!this.sessionData.email||!this.sessionData.cpf||!this.sessionData.sessionId))throw new k("Session data must include email, cpf, and sessionId",R.VALIDATION_ERROR)}validateSignatureFormat(e){return/^[a-f0-9]{64,}$/i.test(e)}async captureFaceFrames(e){const{numFrames:n,livenessCheck:t}=e;if(n<1||n>10)throw new k("Number of frames must be between 1 and 10",R.VALIDATION_ERROR);const o=[];try{const{captureFaceSilently:e}=await Promise.resolve().then((()=>me));for(let a=0;a<n;a++){const r=await e();o.push(r),t&&a<n-1&&await new Promise((e=>setTimeout(e,300)))}return o}catch(a){if(a instanceof k)throw a;throw new k(`Failed to capture face frames: ${a instanceof Error?a.message:"Unknown error"}`,R.CAPTURE_ERROR)}}async loginRecognition(e){const{biometricData:n,purpose:t,confidenceThreshold:o=.8}=e,a=Array.isArray(n)?n:[n];if(0===a.length)throw new k("At least one biometric data frame is required",R.VALIDATION_ERROR);const r=a[0];try{const e=await M(r,this.appToken,t,o,this.signature,this.sessionData);if(!e.success)throw new k("Recognition failed",R.RECOGNITION_FAILED);if(!e.personName||!e.email||!e.cpf)throw new k("Incomplete recognition result: missing personName, email, or cpf",R.RECOGNITION_FAILED);return{success:!0,personName:e.personName,email:e.email,cpf:e.cpf,signature:e.signature,sessionId:e.sessionId,confidenceScore:e.confidenceScore,accessToken:e.accessToken}}catch(i){if(i instanceof k)throw i;throw new k(`Login recognition failed: ${i instanceof Error?i.message:"Unknown error"}`,R.RECOGNITION_FAILED)}}async registerApplication(e,n,t){try{const o=await(async(e,n,t)=>{N();const o=C();try{const r=await fetch(`${S()}/api/v1/applications/`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({consumer:n,application_name:t.applicationName,domain:t.domain,accept_only_email_with_same_domain:t.acceptOnlyEmailWithSameDomain}),signal:o.signal});if(!r.ok){if(401===r.status)throw new k("Invalid or expired JWT token",R.INVALID_TOKEN);if(403===r.status)throw new k("Insufficient permissions to create application",R.INVALID_TOKEN);if(400===r.status)try{const e=await r.json(),n=e.message||e.error||"Invalid application data";throw new k(n,R.VALIDATION_ERROR)}catch(a){if(a instanceof k)throw a;throw new k("Invalid application data",R.VALIDATION_ERROR)}throw new k(`Server returned status ${r.status}`,R.NETWORK)}const i=await r.json();return{success:!0,application:{id:i.id,application_name:i.application_name,domain:i.domain,accept_only_email_with_same_domain:i.accept_only_email_with_same_domain,app_token:i.app_token,is_active:i.is_active,created_at:i.created_at},message:"Application registered successfully"}}catch(r){if(r instanceof Error){if("AbortError"===r.name)throw new k("Request timed out",R.NETWORK);if(r instanceof k)throw r;throw new k(r.message,R.NETWORK)}throw new k("Unknown error occurred",R.NETWORK_ERROR)}})(e,n,t);return o}catch(o){if(o instanceof k)throw o;throw new k(`Application registration failed: ${o instanceof Error?o.message:"Unknown error"}`,R.VALIDATION_ERROR)}}async registerDocumentByImage(e,n,t={}){const{DocumentCaptureModal:o}=await Promise.resolve().then((()=>Ne)),a=new o({useBackCamera:t.useBackCamera??!0,preSelectedDocument:t.preSelectedDocument}),r=await a.open();if(!r.success||!r.frontImage)throw new k("cancelled"===r.error?"Document capture was cancelled by the user":`Document capture failed: ${r.error??"unknown error"}`,R.CAPTURE_ERROR);const i=[r.frontImage];return r.backImage&&i.push(r.backImage),W(e,n,i)}async proofOfLife(e={}){const{videoDurationMs:n=3e3,maxPollingAttempts:t=60,pollingIntervalMs:o=1e3,onRecordingProgress:a,onTaskStatusChange:r}=e;try{const e=await B({durationMs:n,onProgress:a}),i=await(async e=>new Promise(((n,t)=>{const o=new FileReader;o.onload=()=>{const e=o.result,t=e.includes(",")?e.split(",")[1]:e;n(t)},o.onerror=()=>t(new k("Failed to convert video to base64",R.CAPTURE_ERROR)),o.readAsDataURL(e)})))(e),s=await(async(e,n)=>{var t;N();const o=C();try{const a=await fetch(`${S()}/api/v1/auth/recognition/face/external/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({video:e,purpose:"PROOF_OF_LIFE"}),signal:o.signal});if(!a.ok){if(401===a.status||403===a.status)throw new k("Invalid or expired application token",R.INVALID_TOKEN);if(400===a.status){const e=await a.json();throw new k(e.message||"Invalid request data",R.VALIDATION_ERROR)}throw new k(`Server returned status ${a.status}`,R.NETWORK)}const r=await a.json();if(!r.success||!(null==(t=r.data)?void 0:t.task_id))throw new k(r.message||"Failed to start proof of life",R.RECOGNITION_FAILED);return{taskId:r.data.task_id,historyId:r.data.history_id,status:r.data.status,message:r.message||"Recognition started successfully"}}catch(a){if(a instanceof Error){if("AbortError"===a.name)throw new k("Request timed out",R.NETWORK);if(a instanceof k)throw a;throw new k(a.message,R.NETWORK)}throw new k("Unknown error occurred",R.NETWORK_ERROR)}})(i,this.appToken);r&&r("processing",0);const c=await(async(e,n,t={})=>{var o,a,r,i,s,c;const{maxAttempts:d=60,intervalMs:l=1e3,onStatusChange:u}=t;let p=0;for(;p<d;){p++;try{const t=await fetch(`${S()}/api/v1/tasks/status/?task_id=${e}`,{method:"GET",headers:{Accept:"application/json","X-App-Token":n}});if(!t.ok)throw new k(`Task status check failed: ${t.status}`,R.NETWORK);const d=await t.json(),p=(null==(o=d.data)?void 0:o.status)||"unknown";if(u&&u(p,null==(r=null==(a=d.data)?void 0:a.progress)?void 0:r.percentage),"success"===p)return d.data.result;if("failure"===p){const e=(null==(s=null==(i=d.data)?void 0:i.result)?void 0:s.message)||(null==(c=d.data)?void 0:c.error)||"Task failed";throw new k(e,R.RECOGNITION_FAILED)}if("revoked"===p)throw new k("Task was cancelled",R.RECOGNITION_FAILED);await new Promise((e=>setTimeout(e,l)))}catch(f){if(f instanceof k)throw f;throw new k(`Polling error: ${f instanceof Error?f.message:"Unknown error"}`,R.NETWORK)}}throw new k("Task status polling timed out",R.NETWORK)})(s.taskId,this.appToken,{maxAttempts:t,intervalMs:o,onStatusChange:r});return c&&c.success?{success:!0,isLive:c.is_live||!1,livenessScore:c.liveness_score||0,faceRecognitionScore:c.face_recognition_score||0,combinedConfidence:c.combined_confidence||0,personId:c.person_id,personalData:c.personal_data||[],processingTime:c.processing_time||0,historyId:s.historyId,taskId:s.taskId,message:"Proof of life verification successful"}:{success:!1,isLive:(null==c?void 0:c.is_live)||!1,livenessScore:(null==c?void 0:c.liveness_score)||0,faceRecognitionScore:(null==c?void 0:c.face_recognition_score)||0,combinedConfidence:(null==c?void 0:c.combined_confidence)||0,personId:null==c?void 0:c.person_id,personalData:(null==c?void 0:c.personal_data)||[],processingTime:(null==c?void 0:c.processing_time)||0,historyId:s.historyId,taskId:s.taskId,error:(null==c?void 0:c.error)||"Verification failed",message:(null==c?void 0:c.message)||"Proof of life verification failed"}}catch(i){if(i instanceof k)throw i;throw new k(`Proof of life failed: ${i instanceof Error?i.message:"Unknown error"}`,R.RECOGNITION_FAILED)}}},e.RELEASE_DATE="2026-03-04",e.VERSION="1.15.0",e.authorizeOperation=async(e,n,t)=>{if(!e)throw new k("Application token is required",R.VALIDATION_ERROR);if(!n)throw new k("CPF is required",R.VALIDATION_ERROR);const o=n.replace(/\D/g,"");if(11!==o.length)throw new k("Invalid CPF format",R.VALIDATION_ERROR);const a=[],r=(null==t?void 0:t.captureDelay)||2e3;try{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new k("Camera not available",R.NO_CAMERA);const n=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:{ideal:1280},height:{ideal:720}}}),i=document.createElement("video");i.srcObject=n,i.autoplay=!0,i.playsInline=!0,await new Promise((e=>{i.onloadedmetadata=()=>{i.play(),e()}}));const s=document.createElement("canvas");s.width=i.videoWidth,s.height=i.videoHeight;const c=s.getContext("2d");if(!c)throw new k("Failed to get canvas context",R.CAPTURE_ERROR);for(let e=0;e<4;e++){const n=Oe[e];(null==t?void 0:t.onProgress)&&t.onProgress(e+1,4,n),e>0&&await new Promise((e=>setTimeout(e,r))),c.drawImage(i,0,0,s.width,s.height);const o=await new Promise(((e,n)=>{s.toBlob((t=>{t?e(t):n(new Error("Failed to capture photo"))}),"image/jpeg",.9)}));a.push(o),(null==t?void 0:t.onPhotoTaken)&&t.onPhotoTaken(e+1,o)}n.getTracks().forEach((e=>e.stop()));const d=a[3],l={cpf:o,email:"",sessionId:`auth_${Date.now()}_${Math.random().toString(36).substring(7)}`},u=await M(d,e,"AUTHORIZATION",.8,void 0,l);if(!u.success)throw new k("Authorization failed: Person not recognized",R.RECOGNITION_FAILED);return{success:!0,authorizationHash:l.sessionId,name:u.personName,birthDate:void 0,cpf:u.cpf||o,confidenceScore:u.confidenceScore,message:"Authorization successful"}}catch(i){if(i instanceof k)throw i;if(i instanceof Error)throw new k(i.message,R.CAPTURE_ERROR);throw new k("Unknown error during authorization",R.UNKNOWN)}},e.biometricLogin=function(e,n="auto"){return new Promise(((t,o)=>{const a={applicationToken:e,onSuccess:t,onError:o};switch(n){case"face":ge(a);break;case"hand":we(a);break;case"auto":ve(a);break;default:o(new k("Modo de login inválido",R.VALIDATION_ERROR))}}))},e.biometricLoginWithFallback=function(e,n="auto"){return new Promise(((t,o)=>{const a={applicationToken:e,onSuccess:t,onError:n=>{if(n.type===R.LOGIN_FAILED){new de({applicationToken:e,onSuccess:t,onError:o,title:"Login Alternativo",subtitle:"Biometria não reconhecida. Por favor, informe email e senha."}).open()}else o(n)}};switch(n){case"face":ge(a);break;case"hand":we(a);break;case"auto":ve(a);break;default:o(new k("Modo de login inválido",R.VALIDATION_ERROR))}}))},e.completeOnboarding=D,e.completeOnboardingWithData=async(e,n,t,o,a)=>{if(N(),!o||0===o.length)throw new k("Pelo menos uma imagem da pessoa é obrigatória",R.VALIDATION_ERROR);const r=C();try{const i=await Promise.all(o.map((e=>A(e)))),s=await A(a),c=new FormData;i.forEach(((e,n)=>{c.append("person_images",e,`person_${n+1}.jpg`)})),c.append("document_image",s,"document.jpg"),t.name&&c.append("name",t.name),t.birth_date&&c.append("birth_date",t.birth_date),t.cpf&&c.append("cpf",t.cpf),t.cnpj&&c.append("cnpj",t.cnpj),t.email&&c.append("email",t.email);const d=await fetch(`${S()}/api/v1/onboardings/${encodeURIComponent(n)}/complete`,{method:"POST",headers:{"X-App-Token":e},body:c,signal:r.signal}),l=await d.json();if(!d.ok){if(401===d.status||403===d.status)throw new k("Token de aplicação inválido ou expirado",R.INVALID_TOKEN);if(404===d.status)throw new k("Link de onboarding não encontrado",R.NOT_FOUND);throw new k((null==l?void 0:l.error)||(null==l?void 0:l.message)||"Falha ao concluir onboarding",R.NETWORK)}return{success:!!l.success,message:l.message||"Onboarding concluído com sucesso",person_id:l.person_id,identity_data_id:l.identity_data_id,confidence_score:l.confidence_score,processing_time:l.processing_time,liveness_passed:l.liveness_passed,document_verified:l.document_verified,person_created:l.person_created}}catch(i){if(i instanceof Error){if("AbortError"===i.name)throw new k("Tempo de requisição excedido",R.NETWORK);if(i instanceof k)throw i;throw new k(i.message,R.NETWORK)}throw new k("Erro desconhecido",R.NETWORK_ERROR)}},e.detectBiometricType=be,e.getApplicationToken=function(){return _.applicationToken},e.getBaseUrl=I,e.getConfig=function(){return{..._}},e.getEnvironment=function(){return _.environment},e.identifyPerson=async(e,n)=>{var t,o;N();const a=C(),r=await A(e),i=await new Promise(((e,n)=>{const t=new FileReader;t.onload=()=>{const n=t.result;e(n.split(",")[1])},t.onerror=n,t.readAsDataURL(r)}));try{const e=await fetch(`${S()}/api/v1/external/recognition/face/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({image:i,purpose:"SIMPLE_IDENTIFICATION_F"}),signal:a.signal});if(!e.ok){if(401===e.status||403===e.status)throw new k("Invalid or expired application token",R.INVALID_TOKEN);throw new k(`Server returned status ${e.status}`,R.NETWORK)}const r=await e.json();if(!r.success)throw new k(r.message||"Person identification failed",R.RECOGNITION_FAILED);const s=(null==(t=r.person)?void 0:t.name)||"",c=null==(o=r.person)?void 0:o.birth_date;if(!s)throw new k("Person name not found in response",R.PERSON_NOT_FOUND);if(!c)throw new k("Birth date not found in response",R.PERSON_NOT_FOUND);const d=new Date(c),l=new Date;let u=l.getFullYear()-d.getFullYear();const p=l.getMonth()-d.getMonth();return(p<0||0===p&&l.getDate()<d.getDate())&&u--,{name:s,age:u}}catch(s){if(s instanceof Error){if("AbortError"===s.name)throw new k("Request timed out",R.NETWORK);if(s instanceof k)throw s;throw new k(s.message,R.NETWORK)}throw new k("Unknown error occurred",R.NETWORK_ERROR)}},e.init=function(e={}){const{environment:n,baseUrl:t,applicationToken:o}=e;if(t)_.baseUrl=t,_.environment="custom";else if(n)O[n]?(_.baseUrl=O[n],_.environment=n):(_.baseUrl=O.sandbox,_.environment="sandbox");else{const e=void 0!=={url:"undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:i&&"SCRIPT"===i.tagName.toUpperCase()&&i.src||new URL("neoface-id-sdk.umd.js",document.baseURI).href}&&(null==T?void 0:T.VITE_API_BASE_URL);e&&(_.baseUrl=e,_.environment="custom")}o&&(_.applicationToken=o),_.initialized=!0},e.initializeBiometricDetection=Ee,e.isAdvancedDetectionAvailable=Re,e.isInitialized=function(){return _.initialized},e.loginWithBiometric=F,e.loginWithEmail=$,e.preloadFaceDetectionModels=pe,e.recognize=L,e.recognizeBiometric=async(e,n,t=!0,o=.8)=>{N();const a=C(),r=await A(e);try{const e=new FormData;e.append("face_frames",r),e.append("liveness_check",t.toString()),e.append("confidence_threshold",o.toString());const i=await fetch(`${S()}/api/v1/external/recognition/biometric/`,{method:"POST",headers:{"X-App-Token":n},body:e,signal:a.signal});if(!i.ok){if(401===i.status||403===i.status)throw new k("Invalid or expired application token",R.INVALID_TOKEN);throw new k(`Server returned status ${i.status}`,R.NETWORK)}const s=await i.json();return{success:s.success,confidenceScore:s.confidence_score,accessToken:s.access_token,payload:s.payload}}catch(i){if(i instanceof Error){if("AbortError"===i.name)throw new k("Request timed out",R.NETWORK);if(i instanceof k)throw i;throw new k(i.message,R.NETWORK)}throw new k("Unknown error occurred",R.NETWORK_ERROR)}},e.recognizeByPurpose=M,e.registerBiometric=async(e,n,t)=>{if(N(),!e)throw new k("Person ID is required",R.VALIDATION_ERROR);if(!n)throw new k("Face image is required",R.VALIDATION_ERROR);const o=C(),a=await A(n),r=await new Promise(((e,n)=>{const t=new FileReader;t.onload=()=>{const n=t.result;e(n.split(",")[1])},t.onerror=n,t.readAsDataURL(a)}));try{const n=await fetch(`${S()}/api/v1/identity-data/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":t},body:JSON.stringify({person:e,type_of_identification:"FACE",biometric_data:r}),signal:o.signal});if(!n.ok){if(401===n.status||403===n.status)throw new k("Invalid or expired application token, or insufficient permissions",R.INVALID_TOKEN);if(400===n.status)try{const e=await n.json(),t=e.message||e.error||"Invalid biometric data";throw new k(t,R.VALIDATION_ERROR)}catch(i){if(i instanceof k)throw i;throw new k("Invalid biometric data",R.VALIDATION_ERROR)}throw new k(`Server returned status ${n.status}`,R.NETWORK)}const a=await n.json();return{success:!0,message:"Biometric data registered successfully",identity_data_id:a.id,type_of_identification:a.type_of_identification,have_biometric_data:a.have_biometric_data,created_at:a.created_at}}catch(s){if(s instanceof Error){if("AbortError"===s.name)throw new k("Request timed out",R.NETWORK);if(s instanceof k)throw s;throw new k(s.message,R.NETWORK)}throw new k("Unknown error occurred",R.NETWORK_ERROR)}},e.registerPersonWithBiometric=U,e.registerPersonWithoutFace=async(e,n,t)=>{N();const o=C();try{let a,r;if(null==t?void 0:t.documentFront){const e=await j(t.documentFront);a=await new Promise(((n,t)=>{const o=new FileReader;o.onload=()=>n(o.result),o.onerror=t,o.readAsDataURL(e)}))}if(null==t?void 0:t.documentBack){const e=await j(t.documentBack);r=await new Promise(((n,t)=>{const o=new FileReader;o.onload=()=>n(o.result),o.onerror=t,o.readAsDataURL(e)}))}const i={name:e.name,birth_date:e.birth_date,cpf:e.cpf,email:e.email,password:e.password,password_confirm:e.password};a&&(i.document_images=[{front:a,back:r||void 0,type:(null==t?void 0:t.documentType)||"RG"}]);const s=await fetch(`${S()}/api/v1/signup/donor/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify(i),signal:o.signal});if(!s.ok){if(401===s.status||403===s.status)throw new k("Invalid or expired application token",R.INVALID_TOKEN);throw new k(`Server returned status ${s.status}`,R.NETWORK)}return await s.json()}catch(a){if(a instanceof Error){if("AbortError"===a.name)throw new k("Request timed out",R.NETWORK);if(a instanceof k)throw a;throw new k(a.message,R.NETWORK)}throw new k("Unknown error occurred",R.NETWORK)}},e.simpleIdentification=async(e,n,t,o="LOGIN")=>{N();const a=C();try{const r=await fetch(`${S()}/api/v1/external/recognition/simple/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":t},body:JSON.stringify({document_type:e,document_number:n,purpose:o}),signal:a.signal});if(!r.ok){if(401===r.status||403===r.status)throw new k("Invalid or expired application token",R.INVALID_TOKEN);throw new k(`Server returned status ${r.status}`,R.NETWORK)}const i=await r.json();if(!i.success)throw new k(i.message||"Identification failed",R.RECOGNITION_FAILED);return{success:i.success,personId:i.person_id,accessToken:i.access_token,payload:i.payload}}catch(r){if(r instanceof Error){if("AbortError"===r.name)throw new k("Request timed out",R.NETWORK);if(r instanceof k)throw r;throw new k(r.message,R.NETWORK)}throw new k("Unknown error occurred",R.NETWORK_ERROR)}},e.start=function(e,t){const o=document.createElement("div");o.id="neoface-modal-container",document.body.appendChild(o);const a=()=>{document.body.contains(o)&&document.body.removeChild(o)};P(e).then((()=>{const r=n.createElement(K,{accessToken:e,onClose:a,onSuccess:e=>{a(),t.onSuccess({name:e.data.faceId,email:e.data.faceId,documentId:e.data.faceId})}});p.createRoot(o).render(r)})).catch((e=>{a(),t.onError("TOKEN_VALIDATION_ERROR",e.message||"Failed to validate token")}))},e.startAutoLogin=ve,e.startBiometricRegistration=function(e,t,o,a){const r=document.createElement("div");r.id="neoface-biometric-registration-container",document.body.appendChild(r);let i=null;const s=()=>{i&&(i.unmount(),i=null),document.body.contains(r)&&document.body.removeChild(r)};P(t).then((()=>{const c=n.createElement(ae,{personData:e,applicationToken:t,useRealApi:(null==a?void 0:a.useRealApi)??!0,onClose:s,onSuccess:e=>{s(),o.onSuccess(e)},onError:e=>{s(),o.onError("BIOMETRIC_REGISTRATION_ERROR",e)}});i=p.createRoot(r),i.render(c)})).catch((e=>{s(),o.onError("TOKEN_VALIDATION_ERROR",e.message||"Failed to validate token")}))},e.startDocumentCapture=Se,e.startFaceLogin=ge,e.startHandLogin=we,e.startLivenessCapture=function(e,t){const o=document.createElement("div");o.id="neoface-liveness-capture-container",document.body.appendChild(o);let a=!1,r=null;const i=()=>{r&&(r.unmount(),r=null),document.body.contains(o)&&document.body.removeChild(o)},s=()=>{i(),!a&&t.onCancel&&t.onCancel()};P(e).then((()=>{const c=n.createElement(ae,{applicationToken:e,onClose:s,onPhotosCaptured:e=>{a=!0,t.onSuccess(e)},onError:e=>{i(),t.onError("LIVENESS_CAPTURE_ERROR",e)}});r=p.createRoot(o),r.render(c)})).catch((e=>{i(),t.onError("TOKEN_VALIDATION_ERROR",e.message||"Failed to validate token")}))},e.startOnboarding=async e=>{const{applicationToken:n,onboardingToken:t,countdown:o,title:a,subtitle:r,onSuccess:i,onError:s}=e;try{const e=await(async(e,n)=>{N();const t=C();try{const o=await fetch(`${S()}/api/v1/onboardings/${encodeURIComponent(n)}/`,{method:"GET",headers:{"X-App-Token":e},signal:t.signal});if(!o.ok){if(401===o.status||403===o.status)throw new k("Token de aplicação inválido ou expirado",R.INVALID_TOKEN);if(404===o.status)throw new k("Link de onboarding não encontrado",R.NOT_FOUND);throw new k(`Falha ao obter detalhes (${o.status})`,R.NETWORK)}return await o.json()}catch(o){if(o instanceof Error){if("AbortError"===o.name)throw new k("Tempo de requisição excedido",R.NETWORK);if(o instanceof k)throw o;throw new k(o.message,R.NETWORK)}throw new k("Erro desconhecido",R.NETWORK_ERROR)}})(n,t);if(!(null==e?void 0:e.is_valid))throw new k("Link de onboarding inválido ou expirado",R.VALIDATION_ERROR);const s=new Te({countdown:o,title:a,subtitle:r}),{face:c,document:d}=await s.open();i({...await D(n,t,c,d),details:e})}catch(c){if(c instanceof k)return void s(c);const e=(null==c?void 0:c.message)||"Erro desconhecido no onboarding";s(new k(e,R.UNKNOWN))}},e.validateOnboardingToken=async(e,n)=>{N();const t=C();try{const o=await fetch(`${S()}/api/v1/onboardings/${encodeURIComponent(n)}/`,{method:"GET",headers:{"X-App-Token":e},signal:t.signal});if(!o.ok){if(401===o.status||403===o.status)throw new k("Token de aplicação inválido ou expirado",R.INVALID_TOKEN);if(404===o.status)return!1;throw new k(`Falha ao validar token (${o.status})`,R.NETWORK)}const a=await o.json();return!0===(null==a?void 0:a.is_valid)}catch(o){if(o instanceof Error){if("AbortError"===o.name)throw new k("Tempo de requisição excedido",R.NETWORK);if(o instanceof k)throw o;throw new k(o.message,R.NETWORK)}throw new k("Erro desconhecido",R.NETWORK_ERROR)}},e.validateToken=P,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
|
|
10
|
+
*/function w(){return m||(m=1,"production"!==process.env.NODE_ENV&&function(){var e=n,t=Symbol.for("react.element"),o=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),h=Symbol.for("react.offscreen"),m=Symbol.iterator;var g=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(e){for(var n=arguments.length,t=new Array(n>1?n-1:0),o=1;o<n;o++)t[o-1]=arguments[o];!function(e,n,t){var o=g.ReactDebugCurrentFrame.getStackAddendum();""!==o&&(n+="%s",t=t.concat([o]));var a=t.map((function(e){return String(e)}));a.unshift("Warning: "+n),Function.prototype.apply.call(console[e],console,a)}("error",e,t)}var v;function y(e){return e.displayName||"Context"}function x(e){if(null==e)return null;if("number"==typeof e.tag&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),"function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case a:return"Fragment";case o:return"Portal";case i:return"Profiler";case r:return"StrictMode";case l:return"Suspense";case u:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case c:return y(e)+".Consumer";case s:return y(e._context)+".Provider";case d:return function(e,n,t){var o=e.displayName;if(o)return o;var a=n.displayName||n.name||"";return""!==a?t+"("+a+")":t}(e,e.render,"ForwardRef");case p:var n=e.displayName||null;return null!==n?n:x(e.type)||"Memo";case f:var t=e,h=t._payload,m=t._init;try{return x(m(h))}catch(g){return null}}return null}v=Symbol.for("react.module.reference");var E,R,k,T,O,_,I,S=Object.assign,N=0;function C(){}C.__reactDisabledLog=!0;var A,j=g.ReactCurrentDispatcher;function P(e,n,t){if(void 0===A)try{throw Error()}catch(a){var o=a.stack.trim().match(/\n( *(at )?)/);A=o&&o[1]||""}return"\n"+A+e}var D,L=!1,F="function"==typeof WeakMap?WeakMap:Map;function M(e,n){if(!e||L)return"";var t,o=D.get(e);if(void 0!==o)return o;L=!0;var a,r=Error.prepareStackTrace;Error.prepareStackTrace=void 0,a=j.current,j.current=null,function(){if(0===N){E=console.log,R=console.info,k=console.warn,T=console.error,O=console.group,_=console.groupCollapsed,I=console.groupEnd;var e={configurable:!0,enumerable:!0,value:C,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}N++}();try{if(n){var i=function(){throw Error()};if(Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(i,[])}catch(h){t=h}Reflect.construct(e,[],i)}else{try{i.call()}catch(h){t=h}e.call(i.prototype)}}else{try{throw Error()}catch(h){t=h}e()}}catch(m){if(m&&t&&"string"==typeof m.stack){for(var s=m.stack.split("\n"),c=t.stack.split("\n"),d=s.length-1,l=c.length-1;d>=1&&l>=0&&s[d]!==c[l];)l--;for(;d>=1&&l>=0;d--,l--)if(s[d]!==c[l]){if(1!==d||1!==l)do{if(d--,--l<0||s[d]!==c[l]){var u="\n"+s[d].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),"function"==typeof e&&D.set(e,u),u}}while(d>=1&&l>=0);break}}}finally{L=!1,j.current=a,function(){if(0==--N){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:S({},e,{value:E}),info:S({},e,{value:R}),warn:S({},e,{value:k}),error:S({},e,{value:T}),group:S({},e,{value:O}),groupCollapsed:S({},e,{value:_}),groupEnd:S({},e,{value:I})})}N<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=r}var p=e?e.displayName||e.name:"",f=p?P(p):"";return"function"==typeof e&&D.set(e,f),f}function U(e,n,t){if(null==e)return"";if("function"==typeof e)return M(e,!(!(o=e.prototype)||!o.isReactComponent));var o;if("string"==typeof e)return P(e);switch(e){case l:return P("Suspense");case u:return P("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case d:return M(e.render,!1);case p:return U(e.type,n,t);case f:var a=e,r=a._payload,i=a._init;try{return U(i(r),n,t)}catch(s){}}return""}D=new F;var B=Object.prototype.hasOwnProperty,$={},q=g.ReactDebugCurrentFrame;function W(e){if(e){var n=e._owner,t=U(e.type,e._source,n?n.type:null);q.setExtraStackFrame(t)}else q.setExtraStackFrame(null)}var z=Array.isArray;function K(e){return z(e)}function V(e){return""+e}function H(e){if(function(e){try{return V(e),!1}catch(n){return!0}}(e))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",function(e){return"function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object"}(e)),V(e)}var G,X,Y=g.ReactCurrentOwner,J={key:!0,ref:!0,__self:!0,__source:!0};function Z(e,n,o,a,r){var i,s={},c=null,d=null;for(i in void 0!==o&&(H(o),c=""+o),function(e){if(B.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return void 0!==e.key}(n)&&(H(n.key),c=""+n.key),function(e){if(B.call(e,"ref")){var n=Object.getOwnPropertyDescriptor(e,"ref").get;if(n&&n.isReactWarning)return!1}return void 0!==e.ref}(n)&&(d=n.ref,function(e){"string"==typeof e.ref&&Y.current}(n)),n)B.call(n,i)&&!J.hasOwnProperty(i)&&(s[i]=n[i]);if(e&&e.defaultProps){var l=e.defaultProps;for(i in l)void 0===s[i]&&(s[i]=l[i])}if(c||d){var u="function"==typeof e?e.displayName||e.name||"Unknown":e;c&&function(e,n){var t=function(){G||(G=!0,w("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",n))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}(s,u),d&&function(e,n){var t=function(){X||(X=!0,w("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",n))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}(s,u)}return function(e,n,o,a,r,i,s){var c={$$typeof:t,type:e,key:n,ref:o,props:s,_owner:i,_store:{}};return Object.defineProperty(c._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(c,"_self",{configurable:!1,enumerable:!1,writable:!1,value:a}),Object.defineProperty(c,"_source",{configurable:!1,enumerable:!1,writable:!1,value:r}),Object.freeze&&(Object.freeze(c.props),Object.freeze(c)),c}(e,c,d,r,a,Y.current,s)}var Q,ee=g.ReactCurrentOwner,ne=g.ReactDebugCurrentFrame;function te(e){if(e){var n=e._owner,t=U(e.type,e._source,n?n.type:null);ne.setExtraStackFrame(t)}else ne.setExtraStackFrame(null)}function oe(e){return"object"==typeof e&&null!==e&&e.$$typeof===t}function ae(){if(ee.current){var e=x(ee.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}Q=!1;var re={};function ie(e,n){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var t=function(e){var n=ae();if(!n){var t="string"==typeof e?e:e.displayName||e.name;t&&(n="\n\nCheck the top-level render call using <"+t+">.")}return n}(n);if(!re[t]){re[t]=!0;var o="";e&&e._owner&&e._owner!==ee.current&&(o=" It was passed a child from "+x(e._owner.type)+"."),te(e),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,o),te(null)}}}function se(e,n){if("object"==typeof e)if(K(e))for(var t=0;t<e.length;t++){var o=e[t];oe(o)&&ie(o,n)}else if(oe(e))e._store&&(e._store.validated=!0);else if(e){var a=function(e){if(null===e||"object"!=typeof e)return null;var n=m&&e[m]||e["@@iterator"];return"function"==typeof n?n:null}(e);if("function"==typeof a&&a!==e.entries)for(var r,i=a.call(e);!(r=i.next()).done;)oe(r.value)&&ie(r.value,n)}}function ce(e){var n,t=e.type;if(null!=t&&"string"!=typeof t){if("function"==typeof t)n=t.propTypes;else{if("object"!=typeof t||t.$$typeof!==d&&t.$$typeof!==p)return;n=t.propTypes}if(n){var o=x(t);!function(e,n,t,o,a){var r=Function.call.bind(B);for(var i in e)if(r(e,i)){var s=void 0;try{if("function"!=typeof e[i]){var c=Error((o||"React class")+": "+t+" type `"+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[i]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw c.name="Invariant Violation",c}s=e[i](n,i,o,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(d){s=d}!s||s instanceof Error||(W(a),w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",o||"React class",t,i,typeof s),W(null)),s instanceof Error&&!(s.message in $)&&($[s.message]=!0,W(a),w("Failed %s type: %s",t,s.message),W(null))}}(n,e.props,"prop",o,e)}else if(void 0!==t.PropTypes&&!Q){Q=!0,w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",x(t)||"Unknown")}"function"!=typeof t.getDefaultProps||t.getDefaultProps.isReactClassApproved||w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}var de={};function le(e,n,o,m,g,b){var y=function(e){return"string"==typeof e||"function"==typeof e||e===a||e===i||e===r||e===l||e===u||e===h||"object"==typeof e&&null!==e&&(e.$$typeof===f||e.$$typeof===p||e.$$typeof===s||e.$$typeof===c||e.$$typeof===d||e.$$typeof===v||void 0!==e.getModuleId)}(e);if(!y){var E="";(void 0===e||"object"==typeof e&&null!==e&&0===Object.keys(e).length)&&(E+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var R;E+=ae(),null===e?R="null":K(e)?R="array":void 0!==e&&e.$$typeof===t?(R="<"+(x(e.type)||"Unknown")+" />",E=" Did you accidentally export a JSX literal instead of a component?"):R=typeof e,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",R,E)}var k=Z(e,n,o,g,b);if(null==k)return k;if(y){var T=n.children;if(void 0!==T)if(m)if(K(T)){for(var O=0;O<T.length;O++)se(T[O],e);Object.freeze&&Object.freeze(T)}else w("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else se(T,e)}if(B.call(n,"key")){var _=x(e),I=Object.keys(n).filter((function(e){return"key"!==e})),S=I.length>0?"{key: someKey, "+I.join(": ..., ")+": ...}":"{key: someKey}";if(!de[_+S])w('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',S,_,I.length>0?"{"+I.join(": ..., ")+": ...}":"{}",_),de[_+S]=!0}return e===a?function(e){for(var n=Object.keys(e.props),t=0;t<n.length;t++){var o=n[t];if("children"!==o&&"key"!==o){te(e),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",o),te(null);break}}null!==e.ref&&(te(e),w("Invalid attribute `ref` supplied to `React.Fragment`."),te(null))}(k):ce(k),k}var ue=function(e,n,t){return le(e,n,t,!1)},pe=function(e,n,t){return le(e,n,t,!0)};b.Fragment=a,b.jsx=ue,b.jsxs=pe}()),b}var v=(g||(g=1,"production"===process.env.NODE_ENV?f.exports=function(){if(u)return h;u=1;var e=n,t=Symbol.for("react.element"),o=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,r=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function s(e,n,o){var s,c={},d=null,l=null;for(s in void 0!==o&&(d=""+o),void 0!==n.key&&(d=""+n.key),void 0!==n.ref&&(l=n.ref),n)a.call(n,s)&&!i.hasOwnProperty(s)&&(c[s]=n[s]);if(e&&e.defaultProps)for(s in n=e.defaultProps)void 0===c[s]&&(c[s]=n[s]);return{$$typeof:t,type:e,key:d,ref:l,props:c,_owner:r.current}}return h.Fragment=o,h.jsx=s,h.jsxs=s,h}():f.exports=w()),f.exports);class y extends Error{constructor(e){super(e),this.name="CameraPermissionDenied"}}class x{constructor(e){r(this,"stream"),this.stream=e}getStream(){return this.stream}stop(){this.stream.getTracks().forEach((e=>e.stop()))}}const E=()=>{const e=n.useRef(null),[t,o]=n.useState(!1),a=n.useRef(!1);return{startCamera:n.useCallback((async n=>{const t=e.current;if(t)return t.getStream();if(a.current){await new Promise((e=>setTimeout(e,100)));const n=e.current;if(n)return n.getStream()}a.current=!0;try{const t=n||(()=>{const e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);return{video:{facingMode:"user",width:{ideal:e?640:1280},height:{ideal:e?480:720},aspectRatio:{ideal:1.777777778}},audio:!1}})(),r=await navigator.mediaDevices.getUserMedia(t),i=new x(r);return e.current=i,o(!0),a.current=!1,r}catch(r){if(a.current=!1,r instanceof Error){if("NotAllowedError"===r.name||"PermissionDeniedError"===r.name)throw new y("Permissão para acessar a câmera foi negada pelo usuário");if("NotFoundError"===r.name||"DevicesNotFoundError"===r.name)throw new Error("Nenhuma câmera foi encontrada no dispositivo");if("NotReadableError"===r.name||"TrackStartError"===r.name)throw new Error("A câmera já está sendo usada por outro aplicativo");if("OverconstrainedError"===r.name||"ConstraintNotSatisfiedError"===r.name)throw new Error("As configurações solicitadas não são suportadas pela câmera")}throw new Error(`Erro ao inicializar câmera: ${r instanceof Error?r.message:String(r)}`)}}),[]),stopCamera:n.useCallback((n=>{const t=e.current;t&&t.getStream()===n&&(t.stop(),e.current=null,o(!1),a.current=!1)}),[]),cleanup:n.useCallback((()=>{e.current&&(e.current.stop(),e.current=null,o(!1),a.current=!1)}),[]),isActive:t}};var R=(e=>(e.NETWORK="NetworkError",e.NETWORK_ERROR="NetworkError",e.INVALID_TOKEN="InvalidTokenError",e.RECOGNITION_FAILED="RecognitionFailedError",e.LOGIN_FAILED="LoginFailedError",e.VALIDATION_ERROR="ValidationError",e.API_ERROR="ApiError",e.PERSON_NOT_FOUND="PersonNotFoundError",e.INITIALIZATION_ERROR="InitializationError",e.CAMERA_ERROR="CameraError",e.NO_CAMERA="NoCameraError",e.CAPTURE_ERROR="CaptureError",e.NOT_FOUND="NotFoundError",e.UNKNOWN="UnknownError",e))(R||{});class k extends Error{constructor(e,n){super(e),r(this,"type"),this.name=n,this.type=n}getFriendlyMessage(){if(/[áéíóúãõç]/i.test(this.message))return this.message;switch(this.type){case"NetworkError":return this.message.includes("timeout")?"A conexão demorou muito. Tente novamente.":"Não foi possível conectar ao servidor. Verifique sua internet.";case"InvalidTokenError":return"Falha na autenticação do aplicativo. Entre em contato com o suporte.";case"CameraError":case"NoCameraError":return"Não conseguimos acessar sua câmera. Verifique as permissões do navegador.";case"LoginFailedError":case"RecognitionFailedError":return"Não foi possível reconhecer seu rosto. Tente se posicionar em um local mais iluminado.";case"ValidationError":return"Dados inválidos ou rosto não detectado corretamente.";case"ApiError":return this.message.includes("400")?"Requisição inválida. Tente novamente.":this.message.includes("500")?"Ocorreu um erro interno no sistema. Tente mais tarde.":"O serviço encontrou um problema inesperado.";default:return"Ocorreu um erro inesperado. Por favor, tente novamente."}}}const T={},O={development:"http://localhost:8000",sandbox:"https://sandbox-core.neofaceid.com",production:"https://core.neofaceid.com.br"};let _={baseUrl:O.sandbox,applicationToken:null,environment:"sandbox",initialized:!1};function I(){return _.initialized,_.baseUrl}const S=()=>I(),N=()=>{const e="localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname||""===window.location.hostname;if(!window.isSecureContext&&!e)throw new k("Secure context (HTTPS) is required for this operation",R.NETWORK)},C=()=>{const e=new AbortController,n=setTimeout((()=>e.abort()),1e4);return e.signal.addEventListener("abort",(()=>clearTimeout(n))),e},A=async e=>new Promise(((n,t)=>{const o=new Image;o.onload=()=>{const e=document.createElement("canvas");e.width=o.width,e.height=o.height;const a=e.getContext("2d");a?(a.drawImage(o,0,0),e.toBlob((e=>{e?n(e):t(new Error("Failed to compress image"))}),"image/jpeg",.7)):t(new Error("Failed to get canvas context"))},o.onerror=()=>{t(new Error("Failed to load image"))},o.src=URL.createObjectURL(e)})),j=async e=>new Promise(((n,t)=>{const o=new Image;o.onload=()=>{const e=1280;let a=o.width,r=o.height;a>r&&a>e?(r=r*e/a,a=e):r>e&&(a=a*e/r,r=e);const i=document.createElement("canvas");i.width=a,i.height=r;const s=i.getContext("2d");s?(s.drawImage(o,0,0,a,r),i.toBlob((e=>{e?n(e):t(new Error("Failed to compress document image"))}),"image/jpeg",.75)):t(new Error("Failed to get canvas context"))},o.onerror=()=>{t(new Error("Failed to load document image"))},o.src=URL.createObjectURL(e)})),P=async e=>{N();const n=C();try{const t=await fetch(`${S()}/api/v1/auth/application/validate_token/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":e},body:JSON.stringify({}),signal:n.signal});if(!t.ok)throw new k(`API Error ${t.status}`,R.INVALID_TOKEN);return t.ok}catch(t){if(t instanceof Error){if("AbortError"===t.name)throw new k("Request timeout",R.NETWORK_ERROR);throw new k(t.message,R.NETWORK_ERROR)}throw new k("Unknown error",R.NETWORK_ERROR)}},D=async(e,n,t,o)=>{N();const a=C(),r=await A(t),i=await A(o);try{const t=new FormData;t.append("face_image",r,"face.jpg"),t.append("document_image",i,"document.jpg");const o=await fetch(`${S()}/api/v1/onboardings/${encodeURIComponent(n)}/complete`,{method:"POST",headers:{"X-App-Token":e},body:t,signal:a.signal}),s=await o.json();if(!o.ok){if(401===o.status||403===o.status)throw new k("Token de aplicação inválido ou expirado",R.INVALID_TOKEN);if(404===o.status)throw new k("Link de onboarding não encontrado",R.NOT_FOUND);throw new k((null==s?void 0:s.error)||(null==s?void 0:s.message)||"Falha ao concluir onboarding",R.NETWORK)}return{success:!!s.success,message:s.message||"Onboarding concluído",person_id:s.person_id,identity_data_id:s.identity_data_id,confidence_score:s.confidence_score,processing_time:s.processing_time}}catch(s){if(s instanceof Error){if("AbortError"===s.name)throw new k("Tempo de requisição excedido",R.NETWORK);if(s instanceof k)throw s;throw new k(s.message,R.NETWORK)}throw new k("Erro desconhecido",R.NETWORK_ERROR)}},L=async(e,n)=>{N();const t=C(),o=await A(e);try{const e=new FormData;e.append("face_frames",o);const a=await fetch(`${S()}/api/v1/external/recognition/face/`,{method:"POST",headers:{"X-App-Token":n},body:e,signal:t.signal});if(!a.ok){if(401===a.status||403===a.status)throw new k("Invalid or expired application token",R.INVALID_TOKEN);throw new k(`Server returned status ${a.status}`,R.NETWORK)}const r=await a.json();if(!r.success)throw new k(r.message||"Recognition failed",R.RECOGNITION_FAILED);return{accessToken:r.accessToken,payload:r.payload}}catch(a){if(a instanceof Error){if("AbortError"===a.name)throw new k("Request timed out",R.NETWORK);if(a instanceof k)throw a;throw new k(a.message,R.NETWORK)}throw new k("Unknown error occurred",R.NETWORK_ERROR)}},F=async(e,n)=>{var t,o,a,r,i;N();const s=C(),c=await A(e);try{const e=await c.arrayBuffer(),d=btoa(new Uint8Array(e).reduce(((e,n)=>e+String.fromCharCode(n)),"")),l=await fetch(`${S()}/api/v1/login/donor/face/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({image:d,biometric_type:"FACE"}),signal:s.signal});if(!l.ok){if(401===l.status||403===l.status)throw new k("Invalid application token",R.INVALID_TOKEN);if(l.status>=500)throw new k(`Server Error ${l.status}`,R.API_ERROR);throw new k(`API Error ${l.status}`,R.API_ERROR)}const u=await l.json();if(!u.success)throw new k(u.message||"Login failed",R.LOGIN_FAILED);return{success:!0,accessToken:u.accessToken,alias:u.alias,user:{id:(null==(t=u.user)?void 0:t.id)||"",email:(null==(o=u.user)?void 0:o.email)||"",role:(null==(a=u.user)?void 0:a.role)||"",validated:(null==(r=u.user)?void 0:r.validated)||!1,active:(null==(i=u.user)?void 0:i.active)||!1},person:u.person?{name:u.person.name||"",birth_date:u.person.birth_date||""}:void 0,confidence_score:u.confidence_score,recognition_id:u.recognition_id}}catch(d){if(d instanceof Error){if("AbortError"===d.name)throw new k("Request timed out",R.NETWORK);if(d instanceof k)throw d;throw new k(d.message,R.NETWORK)}throw new k("Unknown error occurred",R.NETWORK_ERROR)}},M=async(e,n,t,o=.8,a,r)=>{var i;N();const s=C(),c=await A(e),d=await new Promise(((e,n)=>{const t=new FileReader;t.onload=()=>{const n=t.result;e(n.split(",")[1])},t.onerror=n,t.readAsDataURL(c)}));try{const e={biometric_data:d,type_of_identification:"FACE",purpose:t,confidence_threshold:o};a&&(e.signature=a);const c=await fetch(`${S()}/api/v1/external/recognition/purpose/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify(e),signal:s.signal});if(!c.ok){if(401===c.status||403===c.status)throw new k("Invalid or expired application token",R.INVALID_TOKEN);throw new k(`Server returned status ${c.status}`,R.NETWORK)}const l=await c.json();return{success:l.success,personName:l.person_name||(null==(i=l.person)?void 0:i.name),email:l.email||(null==r?void 0:r.email),cpf:l.cpf||(null==r?void 0:r.cpf),confidenceScore:l.confidence_score,accessToken:l.access_token,payload:l.payload,signature:a,sessionId:null==r?void 0:r.sessionId}}catch(l){if(l instanceof Error){if("AbortError"===l.name)throw new k("Request timed out",R.NETWORK);if(l instanceof k)throw l;throw new k(l.message,R.NETWORK)}throw new k("Unknown error occurred",R.NETWORK_ERROR)}},U=async(e,n,t,o)=>{var a,r,i,s,c,d,l,u;if(N(),!n||0===n.length)throw new k("At least one face photo is required for biometric registration",R.VALIDATION_ERROR);if(n.length>5)throw new k("Maximum of 5 face photos allowed",R.VALIDATION_ERROR);const p=C();try{const h=await Promise.all(n.map((async e=>{const n=await A(e);return new Promise(((e,t)=>{const o=new FileReader;o.onload=()=>{const n=o.result;e(n)},o.onerror=t,o.readAsDataURL(n)}))})));let m,g;if(null==o?void 0:o.documentFront){const e=await j(o.documentFront);m=await new Promise(((n,t)=>{const o=new FileReader;o.onload=()=>n(o.result),o.onerror=t,o.readAsDataURL(e)}))}if(null==o?void 0:o.documentBack){const e=await j(o.documentBack);g=await new Promise(((n,t)=>{const o=new FileReader;o.onload=()=>n(o.result),o.onerror=t,o.readAsDataURL(e)}))}const b={name:e.name,birth_date:e.birth_date,cpf:e.cpf,email:e.email,password:e.password,password_confirm:e.password,face_photos:h};m&&(b.document_images=[{front:m,back:g||void 0,type:(null==o?void 0:o.documentType)||"RG"}]);const w=await fetch(`${S()}/api/v1/signup/donor/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":t},body:JSON.stringify(b),signal:p.signal});if(!w.ok){if(401===w.status||403===w.status)throw new k("Invalid or expired application token",R.INVALID_TOKEN);try{const e=await w.json();if(e.errors){const n=Object.entries(e.errors).map((([e,n])=>`${"password"===e?"senha":"password_confirm"===e?"confirmação de senha":e}: ${Array.isArray(n)?n.join(", "):String(n)}`)).join("; ");throw new k(`Erro de validação: ${n}`,R.VALIDATION_ERROR)}if("fraud_detected"===e.error)throw new k("Fraud detected in biometric images. Registration blocked.",R.VALIDATION_ERROR);if("user_exists"===e.error||"ALREADY_EXISTS"===e.error_code)throw new k("User with this email already exists",R.VALIDATION_ERROR);if("person_exists"===e.error)throw new k("Person with this CPF already exists",R.VALIDATION_ERROR);const n=e.message||e.error||`Server returned status ${w.status}`;throw new k(n,R.VALIDATION_ERROR)}catch(f){if(f instanceof k)throw f;throw new k(`Server returned status ${w.status}`,R.NETWORK)}}const v=await w.json();return 202===w.status&&(null==(a=v.data)?void 0:a.task_id)?{success:v.success,message:v.message||"Registration is being processed. You will receive an email when completed.",task_id:v.data.task_id,status:v.data.status||"processing",person_id:void 0,user_id:void 0,person_validated:void 0,face_processing:void 0,onboarding_link:void 0}:{success:v.success,message:v.message,person_id:(null==(r=v.data)?void 0:r.person_id)||v.person_id,user_id:(null==(i=v.data)?void 0:i.user_id)||v.user_id,person_validated:(null==(s=v.data)?void 0:s.person_validated)||v.person_validated,face_processing:(null==(c=v.data)?void 0:c.face_processing)||v.face_processing,onboarding_link:(null==(d=v.data)?void 0:d.onboarding_link)||v.onboarding_link,task_id:null==(l=v.data)?void 0:l.task_id,status:null==(u=v.data)?void 0:u.status}}catch(h){if(h instanceof Error){if("AbortError"===h.name)throw new k("Request timed out",R.NETWORK);if(h instanceof k)throw h;throw new k(h.message,R.NETWORK)}throw new k("Unknown error occurred",R.NETWORK_ERROR)}},B=async(e,n,t)=>{N();const o=C();try{const a=await fetch(`${S()}/api/v1/auth/login/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":t},body:JSON.stringify({email:e,password:n}),signal:o.signal});if(!a.ok){if(401===a.status||403===a.status)throw new k("Email ou senha inválidos",R.INVALID_TOKEN);throw new k(`API Error ${a.status}`,R.API_ERROR)}const r=await a.json();return{success:!0,accessToken:r.access_token||r.access,alias:r.user&&r.user.alias||r.alias,user:{id:r.user&&r.user.id||"",email:r.user&&r.user.email||"",role:r.user&&r.user.role||"",validated:r.user&&r.user.validated||!1,active:r.user&&r.user.active||!1}}}catch(a){if(a instanceof Error){if("AbortError"===a.name)throw new k("Request timed out",R.NETWORK);if(a instanceof k)throw a;throw new k(a.message,R.NETWORK)}throw new k("Unknown error occurred",R.NETWORK_ERROR)}},$=async(e={})=>{N();const{durationMs:n=3e3,onProgress:t}=e;return new Promise((async(e,o)=>{let a=null;const r=[];try{a=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:{ideal:640},height:{ideal:480}},audio:!1});const i=(()=>{const e=["video/mp4;codecs=avc1","video/mp4","video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"];for(const n of e)if(MediaRecorder.isTypeSupported(n))return n;return""})();let s;try{s=i?new MediaRecorder(a,{mimeType:i,videoBitsPerSecond:1e6}):new MediaRecorder(a,{videoBitsPerSecond:1e6})}catch{s=new MediaRecorder(a)}const c=s.mimeType||i;if(s.ondataavailable=e=>{e.data.size>0&&r.push(e.data)},s.onstop=()=>{a&&a.getTracks().forEach((e=>e.stop()));const n=new Blob(r,{type:c});e(n)},s.onerror=e=>{a&&a.getTracks().forEach((e=>e.stop())),o(new k(`Recording error: ${e}`,R.CAPTURE_ERROR))},s.start(100),t){const e=100;let o=0;const a=setInterval((()=>{o+=e;const r=Math.min(100,o/n*100);t(r),o>=n&&clearInterval(a)}),e)}setTimeout((()=>{s&&"recording"===s.state&&s.stop()}),n)}catch(i){a&&a.getTracks().forEach((e=>e.stop())),i instanceof Error?"NotAllowedError"===i.name?o(new k("Camera permission denied",R.CAMERA_ERROR)):"NotFoundError"===i.name?o(new k("No camera found",R.NO_CAMERA)):o(new k(i.message,R.CAPTURE_ERROR)):o(new k("Failed to record video",R.CAPTURE_ERROR))}}))},q=async(e,n,t)=>{var o,a;if(N(),!e)throw new k("personId is required",R.VALIDATION_ERROR);if(!n)throw new k("jwtToken is required",R.VALIDATION_ERROR);if(!t||0===t.length)throw new k("At least one document image is required",R.VALIDATION_ERROR);const r=await Promise.all(t.map((async e=>{const n=await j(e);return t=n,new Promise(((e,n)=>{const o=new FileReader;o.onload=()=>{const n=o.result;e(n.includes(",")?n.split(",")[1]:n)},o.onerror=()=>n(new k("Failed to convert image to base64",R.CAPTURE_ERROR)),o.readAsDataURL(t)}));var t}))),i=C();try{const t=await fetch(`${S()}/api/v1/donors/${e}/documents/`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({document_images:r}),signal:i.signal}),s=await t.json();if(!t.ok)throw new k((null==s?void 0:s.message)||`API Error ${t.status}`,R.NETWORK_ERROR);return{success:!0,taskId:(null==(o=s.data)?void 0:o.task_id)??"",status:(null==(a=s.data)?void 0:a.status)??"processing",message:s.message??"Documents submitted for processing"}}catch(s){if(s instanceof k)throw s;if(s instanceof Error){if("AbortError"===s.name)throw new k("Request timeout",R.NETWORK_ERROR);throw new k(s.message,R.NETWORK_ERROR)}throw new k("Unknown error occurred",R.NETWORK_ERROR)}},W=(e,n)=>{switch(n.type){case"PERMISSION_GRANTED":case"RESET":return{status:"ready"};case"PERMISSION_DENIED":return{status:"error",message:"Permissão para acessar a câmera foi negada"};case"START_CAPTURE":return{status:"capturing"};case"UPLOAD_START":return{status:"uploading"};case"UPLOAD_SUCCESS":return{status:"success"};case"UPLOAD_ERROR":case"SET_ERROR":return{status:"error",message:n.message};default:return e}},z={overlay:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.8)",display:"flex",justifyContent:"center",alignItems:"center",zIndex:1e3},modal:{backgroundColor:"#000",borderRadius:"12px",overflow:"hidden",position:"relative",width:"60%",maxWidth:"600px",maxHeight:"80vh"},video:{width:"100%",height:"auto",display:"block"},canvas:{display:"none"},guide:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"200px",height:"200px",border:"2px solid rgba(255, 255, 255, 0.5)",borderRadius:"50%",pointerEvents:"none"},controls:{position:"absolute",bottom:"20px",left:0,right:0,display:"flex",justifyContent:"center",gap:"10px"},button:{padding:"12px 24px",borderRadius:"24px",border:"none",backgroundColor:"#007AFF",color:"white",fontSize:"16px",fontWeight:"bold",cursor:"pointer"},message:{position:"absolute",top:"20px",left:0,right:0,textAlign:"center",color:"white",fontSize:"18px",fontWeight:"bold"},spinner:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"40px",height:"40px",border:"4px solid rgba(255, 255, 255, 0.3)",borderRadius:"50%",borderTopColor:"white",animation:"spin 1s linear infinite"},closeButton:{position:"absolute",top:"20px",right:"20px",backgroundColor:"transparent",border:"none",color:"white",fontSize:"24px",cursor:"pointer"}};function K({accessToken:e,onClose:t,onSuccess:o}){const a=n.useRef(null),r=n.useRef(null),i=n.useRef(null),s=n.useRef(null),d=n.useRef(null),[l,u]=n.useReducer(W,{status:"requestingPermission"}),[p,f]=n.useState(!1),[h,m]=n.useState(0),{startCamera:g,stopCamera:b}=E(),w=()=>{if(!a.current)return;const e=async()=>{if(a.current&&"ready"===l.status){try{const e=await c.detectAllFaces(a.current,new c.TinyFaceDetectorOptions),n=1===e.length,t=n&&(e=>{if(!a.current)return!1;const{box:n}=e,{videoWidth:t,videoHeight:o}=a.current,r=t/2,i=o/2,s=.4*t,c=.4*o;return n.x+n.width/2>r-s/2&&n.x+n.width/2<r+s/2&&n.y+n.height/2>i-c/2&&n.y+n.height/2<i+c/2})(e[0]);f(n&&t),n&&t&&0===h&&(d.current=window.setTimeout((()=>{"ready"===l.status&&(m((e=>e+1)),u({type:"START_CAPTURE"}))}),3e3))}catch(n){}s.current=window.setTimeout(e,100)}};e()};n.useEffect((()=>((async()=>{try{await Promise.all([c.nets.tinyFaceDetector.loadFromUri("./models"),c.nets.faceLandmark68Net.loadFromUri("./models")])}catch(e){}})(),()=>{s.current&&window.clearTimeout(s.current),d.current&&window.clearInterval(d.current)})),[]),n.useEffect((()=>((async()=>{try{const e=await g();i.current=e,a.current&&(a.current.srcObject=e),u({type:"PERMISSION_GRANTED"}),w()}catch(e){u({type:"PERMISSION_DENIED"})}})(),()=>{i.current&&b(i.current)})),[g,b]);const y=async()=>{if(r.current&&a.current)try{u({type:"START_CAPTURE"});const i=r.current.getContext("2d");if(!i)return void u({type:"SET_ERROR",message:"Failed to get canvas context"});r.current.width=a.current.videoWidth,r.current.height=a.current.videoHeight,i.drawImage(a.current,0,0,r.current.width,r.current.height);const s=await new Promise(((e,n)=>{var t;null==(t=r.current)||t.toBlob((t=>{t?e(t):n(new Error("Failed to convert canvas to blob"))}),"image/jpeg",.95)}));try{const n=await L(s,e);o({success:!0,data:{faceId:n.payload.documentId,confidence:1}}),u({type:"UPLOAD_SUCCESS"}),setTimeout(t,1500)}catch(n){u({type:"SET_ERROR",message:"Face recognition failed"})}}catch(n){u({type:"SET_ERROR",message:"Failed to capture image"})}};return v.jsxs("div",{style:z.overlay,children:[v.jsx("style",{children:"\n @keyframes spin {\n 0% { transform: translate(-50%, -50%) rotate(0deg); }\n 100% { transform: translate(-50%, -50%) rotate(360deg); }\n }\n"}),v.jsx("style",{children:"\n @media (max-width: 768px) {\n .modal {\n width: 100%;\n height: 100%;\n max-height: 100vh;\n border-radius: 0;\n }\n .button {\n padding: 16px 32px;\n font-size: 18px;\n }\n }\n"}),v.jsxs("div",{style:z.modal,className:"modal",children:[v.jsx("button",{type:"button",style:z.closeButton,onClick:t,children:"×"}),v.jsx("video",{ref:a,style:z.video,autoPlay:!0,playsInline:!0,muted:!0}),v.jsx("canvas",{ref:r,style:z.canvas}),v.jsx("div",{style:z.guide}),"ready"===l.status&&!p&&v.jsx("div",{style:z.message,children:"Centralize seu rosto no círculo"}),"capturing"===l.status&&v.jsx("div",{style:z.message,children:"Por favor, pisque os olhos"}),"uploading"===l.status&&v.jsx("div",{style:z.spinner}),"success"===l.status&&v.jsx("div",{style:z.message,children:"Autenticado!"}),"error"===l.status&&v.jsx("div",{style:z.message,children:l.message}),v.jsxs("div",{style:z.controls,children:["ready"===l.status&&p&&v.jsx("button",{type:"button",style:z.button,onClick:y,children:"Capturar"}),"capturing"===l.status&&v.jsx("button",{type:"button",style:z.button,onClick:y,children:"Capturar"}),"error"===l.status&&v.jsx("button",{type:"button",style:z.button,onClick:()=>{u({type:"RESET"}),m(0)},children:"Tentar Novamente"})]})]})]})}const V=(e,n)=>{switch(n.type){case"START_LIVENESS":return{status:"liveness",step:n.stepSequence[0],capturedPhotos:[],stepSequence:n.stepSequence,currentStepIndex:0,stepProgress:0};case"NEXT_STEP":if("liveness"===e.status){const t=n.photo?[...e.capturedPhotos,n.photo]:e.capturedPhotos;return{status:"liveness",step:n.step,capturedPhotos:t,stepSequence:e.stepSequence,currentStepIndex:e.currentStepIndex+1,stepProgress:0}}return e;case"UPDATE_PROGRESS":return"liveness"===e.status?{...e,stepProgress:n.progress}:e;case"CAMERA_LOADING":return{status:"camera-loading"};case"START_PROCESSING":return{status:"processing"};case"SUCCESS":return{status:"success"};case"ERROR":return{status:"error",message:n.message,retryable:n.retryable??!0};case"RESET":return G;default:return e}},H={center:"Posicione seu rosto no centro",up:"Incline a cabeça para cima",down:"Incline a cabeça para baixo",left:"Vire o rosto para a esquerda",right:"Vire o rosto para a direita",complete:"Processando..."},G=(()=>{const e=["center","up","down","left","right","complete"];return{status:"liveness",step:e[0],capturedPhotos:[],stepSequence:e,currentStepIndex:0,stepProgress:0}})(),X=8,Y=10,J=26,Z=8,Q=-8,ee=15,ne=-15,te=1500,oe=200;function ae({personData:e,applicationToken:t,onClose:o,onSuccess:a,onPhotosCaptured:r,onError:i}){const s=n.useRef(null),d=n.useRef(null),l=n.useRef(null),u=n.useRef(null),p=n.useRef(null),f=n.useRef(!1),h=n.useRef("center"),m=n.useRef(null),g=n.useRef(!1),b=n.useRef(null),[w,y]=n.useReducer(V,G),[x,E]=n.useState(!1),[R,k]=n.useState("ok");n.useEffect((()=>{if("liveness"===w.status){const e=w.step;h.current!==e&&(h.current=e,f.current||(u.current&&(u.current=null),p.current&&(clearInterval(p.current),p.current=null),y({type:"UPDATE_PROGRESS",progress:0}))),b.current={stepSequence:w.stepSequence,currentStepIndex:w.currentStepIndex,capturedPhotos:w.capturedPhotos}}}),[w.status,"liveness"===w.status&&w.step,"liveness"===w.status&&w.currentStepIndex]);n.useEffect((()=>{(async()=>{try{const e="https://cdn.jsdelivr.net/npm/@vladmandic/face-api/model",n=new Promise(((e,n)=>setTimeout((()=>n(new Error("Timeout ao carregar modelos"))),1e4)));await Promise.race([Promise.all([c.nets.tinyFaceDetector.loadFromUri(e),c.nets.faceLandmark68Net.loadFromUri(e)]),n])}catch(e){y({type:"ERROR",message:"Não foi possível carregar os modelos de IA. Verifique sua conexão e tente novamente.",retryable:!0})}})()}),[]),n.useEffect((()=>()=>{l.current&&(l.current.getTracks().forEach((e=>{e.stop()})),l.current=null),s.current&&(s.current.srcObject=null),m.current&&(clearTimeout(m.current),m.current=null),p.current&&(clearInterval(p.current),p.current=null)}),[]),n.useEffect((()=>{let e=!0;return(async()=>{if("liveness"===w.status&&!l.current){g.current=!1,m.current&&(clearTimeout(m.current),m.current=null),m.current=window.setTimeout((()=>{e&&!1===g.current&&y({type:"ERROR",message:"A câmera não respondeu a tempo. Verifique se ela está disponível e tente novamente.",retryable:!0})}),2e4);try{const n=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"}});if(!e)return void n.getTracks().forEach((e=>e.stop()));const t=async()=>{let e=0;for(;!s.current&&e<50;)await new Promise((e=>setTimeout(e,100))),e++;return s.current},o=await t();if(!o)throw new Error("Elemento de vídeo não encontrado");o.srcObject=n,l.current=n,await o.play()}catch(n){if(!e)return;m.current&&(clearTimeout(m.current),m.current=null);let t=n instanceof Error?n.message:"Erro ao acessar câmera";n instanceof DOMException&&("NotAllowedError"===n.name||"PermissionDeniedError"===n.name?t="Permissão de câmera negada. Permita o acesso à câmera nas configurações do navegador e tente novamente.":"NotFoundError"===n.name||"DevicesNotFoundError"===n.name?t="Nenhuma câmera encontrada. Conecte uma câmera e tente novamente.":"NotReadableError"===n.name&&(t="A câmera está sendo usada por outro programa. Feche-o e tente novamente.")),y({type:"ERROR",message:t,retryable:!0})}}})(),()=>{e=!1,m.current&&(clearTimeout(m.current),m.current=null),l.current&&(l.current.getTracks().forEach((e=>e.stop())),l.current=null),p.current&&(clearInterval(p.current),p.current=null),u.current=null}}),[w.status]),n.useEffect((()=>{if("liveness"!==w.status||!s.current)return;let e=!0,n=0;const t=async()=>{if(!e||"liveness"!==w.status)return;if(f.current||"complete"===h.current)return void requestAnimationFrame(t);const o=Date.now();if(o-n<oe)requestAnimationFrame(t);else{n=o;try{const n=await c.detectSingleFace(s.current,new c.TinyFaceDetectorOptions({inputSize:160,scoreThreshold:.4})).withFaceLandmarks();if(!e)return;const t=!!n;if(E(t),t&&n.detection){const e=n.detection.box.width;k(e>250?"too-close":e<120?"too-far":"ok")}if(t&&n.landmarks){const e=(e=>{try{const n=e.positions||e._positions;if(!Array.isArray(n)||n.length<68)return null;const t=e=>{const t=n[e];return{x:void 0!==t._x?t._x:t.x,y:void 0!==t._y?t._y:t.y}},o=t(30),a=t(8),r=t(36),i=t(45),s=(r.x+i.x)/2,c=(o.x-s)/Math.abs(i.x-r.x)*90,d=(r.y+i.y)/2,l=o.y-d,u=-l/Math.abs(a.y-d)*90+J;return{pitch:Math.round(u),yaw:Math.round(c)}}catch(n){return null}})(n.landmarks);if(e){(e=>{if(f.current||"complete"===h.current)return;const n=Date.now();e?u.current||(u.current=n,p.current&&clearInterval(p.current),p.current=window.setInterval((()=>{if(!u.current)return;const e=Date.now()-u.current,n=Math.min(e/te*100,100);y({type:"UPDATE_PROGRESS",progress:n}),n>=100&&(clearInterval(p.current),p.current=null,T())}),50)):u.current&&(u.current=null,p.current&&(clearInterval(p.current),p.current=null),y({type:"UPDATE_PROGRESS",progress:0}))})(((e,n,t)=>{switch(t){case"center":return Math.abs(e)<X&&Math.abs(n)<Y;case"up":return e>Z;case"down":return e<Q;case"left":return n>ee;case"right":return n<ne;default:return!1}})(e.pitch,e.yaw,h.current))}}else u.current&&(u.current=null,p.current&&(clearInterval(p.current),p.current=null),y({type:"UPDATE_PROGRESS",progress:0}))}catch(a){}e&&"liveness"===w.status&&requestAnimationFrame(t)}},o=()=>{e&&s.current&&(g.current=!0,m.current&&(clearTimeout(m.current),m.current=null),t())},a=s.current;if(a&&a.readyState>=2){const n=setTimeout(o,200);return()=>{e=!1,clearTimeout(n),p.current&&(clearInterval(p.current),p.current=null),u.current=null}}{const n=()=>{e&&o()};let t=0;const r=50,i=window.setInterval((()=>{t++,e?s.current&&s.current.readyState>=2?(clearInterval(i),s.current.removeEventListener("canplay",n),o()):t>=r&&clearInterval(i):clearInterval(i)}),300);return null==a||a.addEventListener("canplay",n,{once:!0}),()=>{e=!1,clearInterval(i),null==a||a.removeEventListener("canplay",n),p.current&&(clearInterval(p.current),p.current=null),u.current=null}}}),[w.status]);const T=async()=>{if(!s.current||!d.current||f.current)return;f.current=!0,u.current=null;const e=b.current;if(!e)return void(f.current=!1);const n=d.current,t=s.current,o=n.getContext("2d");o?(n.width=t.videoWidth,n.height=t.videoHeight,o.scale(-1,1),o.drawImage(t,-n.width,0,n.width,n.height),n.toBlob((n=>{if(!n)return void(f.current=!1);const t=e.currentStepIndex+1,o=e.stepSequence[t];if("complete"===o){const t=[...e.capturedPhotos,n];y({type:"START_PROCESSING"}),O(t)}else setTimeout((()=>{f.current=!1,y({type:"NEXT_STEP",step:o,photo:n})}),100)}),"image/jpeg",.85)):f.current=!1},O=async n=>{try{if(r)return y({type:"SUCCESS"}),void r(n);if(!e||!t)throw new Error("Dados de registro não fornecidos");const o=await U(e,n,t),i={success:o.success,message:o.message,person_id:o.person_id,user_id:o.user_id,person_validated:o.person_validated,face_processing:o.face_processing,onboarding_link:o.onboarding_link};y({type:"SUCCESS"}),a&&a(i)}catch(o){const e=o instanceof Error?o.message:"Erro desconhecido";y({type:"ERROR",message:e}),i(e)}};return v.jsxs(v.Fragment,{children:[v.jsx("style",{children:"\n @keyframes fadeIn {\n from { opacity: 0; transform: scale(0.95); }\n to { opacity: 1; transform: scale(1); }\n }\n\n @keyframes slideUp {\n from { opacity: 0; transform: translateY(20px); }\n to { opacity: 1; transform: translateY(0); }\n }\n\n @keyframes slideDown {\n from { opacity: 0; transform: translateY(-10px); }\n to { opacity: 1; transform: translateY(0); }\n }\n\n @keyframes spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n }\n\n @keyframes pulseRing {\n 0%, 100% { \n box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.8), 0 0 40px rgba(16, 185, 129, 0.4);\n }\n 50% { \n box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.9), 0 0 50px rgba(16, 185, 129, 0.5);\n }\n }\n\n @keyframes checkmark {\n 0% {\n stroke-dashoffset: 100;\n }\n 100% {\n stroke-dashoffset: 0;\n }\n }\n\n @keyframes scaleIn {\n 0% {\n transform: scale(0);\n opacity: 0;\n }\n 50% {\n transform: scale(1.1);\n }\n 100% {\n transform: scale(1);\n opacity: 1;\n }\n }\n\n @keyframes scanRing {\n 0%, 100% { transform: scale(1); opacity: 0.3; }\n 50% { transform: scale(1.1); opacity: 0.6; }\n }\n\n @keyframes cornerBlink {\n 0%, 100% { opacity: 0.3; }\n 50% { opacity: 1; }\n }\n\n .modal-overlay {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.92);\n backdrop-filter: blur(8px);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 9999;\n padding: 20px;\n }\n\n .modal-content {\n background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);\n border-radius: 24px;\n width: 100%;\n max-width: 420px;\n max-height: 90vh;\n overflow: hidden;\n box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);\n animation: fadeIn 0.3s ease-out;\n position: relative;\n }\n\n .close-button {\n position: absolute;\n top: 20px;\n right: 20px;\n width: 32px;\n height: 32px;\n background: transparent;\n border: none;\n color: rgba(255, 255, 255, 0.6);\n font-size: 28px;\n font-weight: 300;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s;\n z-index: 10;\n line-height: 1;\n }\n\n .close-button:hover {\n color: rgba(255, 255, 255, 0.9);\n transform: rotate(90deg);\n }\n\n /* Instructions Screen */\n .instructions-container {\n padding: 60px 40px 40px;\n color: white;\n text-align: center;\n animation: slideUp 0.4s ease-out;\n }\n\n .instructions-header {\n margin-bottom: 40px;\n }\n\n .icon-wrapper {\n display: inline-block;\n color: #7c3aed;\n margin-bottom: 24px;\n }\n\n .icon-wrapper .scan-ring {\n animation: scanRing 2s ease-in-out infinite;\n }\n\n .icon-wrapper .corner {\n animation: cornerBlink 2s ease-in-out infinite;\n }\n\n .icon-wrapper .corner.tl { animation-delay: 0s; }\n .icon-wrapper .corner.tr { animation-delay: 0.5s; }\n .icon-wrapper .corner.bl { animation-delay: 1s; }\n .icon-wrapper .corner.br { animation-delay: 1.5s; }\n\n .instructions-header h2 {\n font-size: 28px;\n font-weight: 700;\n margin: 0 0 12px 0;\n background: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);\n -webkit-background-clip: text;\n -webkit-text-fill-color: transparent;\n background-clip: text;\n }\n\n .subtitle {\n font-size: 15px;\n color: rgba(255, 255, 255, 0.7);\n margin: 0;\n line-height: 1.5;\n }\n\n .requirements-list {\n text-align: left;\n margin: 0 auto 40px;\n max-width: 360px;\n }\n\n .requirement-item {\n display: flex;\n align-items: center;\n gap: 16px;\n padding: 14px 0;\n font-size: 15px;\n color: rgba(255, 255, 255, 0.9);\n border-bottom: 1px solid rgba(255, 255, 255, 0.05);\n }\n\n .requirement-item:last-child {\n border-bottom: none;\n }\n\n .req-icon {\n width: 32px;\n height: 32px;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n }\n\n .req-icon.success {\n background: rgba(16, 185, 129, 0.15);\n color: #10b981;\n border: 1.5px solid rgba(16, 185, 129, 0.3);\n }\n\n .primary-button {\n width: 100%;\n padding: 16px 32px;\n border-radius: 12px;\n border: none;\n background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);\n color: white;\n font-size: 16px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.3s;\n box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);\n }\n\n .primary-button:hover {\n transform: translateY(-2px);\n box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4);\n }\n\n .primary-button:active {\n transform: translateY(0);\n }\n\n .branding {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n margin-top: 32px;\n padding-top: 24px;\n border-top: 1px solid rgba(255, 255, 255, 0.1);\n font-size: 13px;\n color: rgba(255, 255, 255, 0.5);\n }\n\n .brand-logo {\n height: 20px;\n width: auto;\n }\n\n .brand-name {\n font-weight: 600;\n font-family: 'SF Pro Display', -apple-system, system-ui, sans-serif;\n color: #ffffff;\n letter-spacing: 0.3px;\n }\n\n /* Liveness Detection */\n .liveness-container {\n height: 100%;\n min-height: 520px;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 70px 20px 80px;\n position: relative;\n animation: fadeIn 0.3s ease-out;\n }\n\n .progress-indicator {\n position: absolute;\n top: 20px;\n left: 50%;\n transform: translateX(-50%);\n background: rgba(255, 255, 255, 0.08);\n backdrop-filter: blur(12px);\n border-radius: 20px;\n padding: 8px 20px;\n border: 1px solid rgba(255, 255, 255, 0.12);\n z-index: 5;\n }\n\n .progress-text {\n font-size: 14px;\n font-weight: 600;\n color: white;\n }\n\n .video-wrapper {\n position: relative;\n margin: 20px 0;\n }\n\n .video-circle {\n width: 320px;\n height: 400px;\n border-radius: 50%;\n overflow: hidden;\n position: relative;\n transition: all 0.3s ease;\n box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.3);\n }\n\n .video-circle.face-detected {\n box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.5), 0 0 40px rgba(16, 185, 129, 0.3);\n }\n\n .video-circle.capturing {\n box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.9), 0 0 40px rgba(16, 185, 129, 0.5);\n transition: box-shadow 0.3s ease;\n }\n\n .video-feed {\n width: 100%;\n height: 100%;\n object-fit: cover;\n transform: scaleX(-1);\n }\n\n .face-badge {\n position: absolute;\n top: 20px;\n left: 50%;\n transform: translateX(-50%);\n background: rgba(16, 185, 129, 0.95);\n backdrop-filter: blur(10px);\n border-radius: 20px;\n padding: 8px 16px;\n display: flex;\n align-items: center;\n gap: 8px;\n color: white;\n font-size: 13px;\n font-weight: 600;\n border: 1px solid rgba(255, 255, 255, 0.3);\n box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);\n animation: slideDown 0.3s ease-out;\n }\n\n .face-badge.warning {\n background: rgba(251, 191, 36, 0.95);\n border: 1px solid rgba(255, 255, 255, 0.3);\n box-shadow: 0 4px 12px rgba(251, 191, 36, 0.3);\n color: #78350f;\n }\n\n .face-badge.error {\n background: rgba(239, 68, 68, 0.95);\n border: 1px solid rgba(255, 255, 255, 0.3);\n box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);\n color: white;\n }\n\n .instruction-box {\n background: rgba(255, 255, 255, 0.08);\n backdrop-filter: blur(12px);\n border-radius: 16px;\n padding: 16px 24px;\n margin-top: 20px;\n border: 1px solid rgba(255, 255, 255, 0.12);\n max-width: 320px;\n animation: slideUp 0.3s ease-out;\n }\n\n .instruction-text {\n font-size: 18px;\n font-weight: 600;\n color: white;\n margin: 0 0 12px 0;\n text-align: center;\n }\n\n .progress-bar {\n height: 4px;\n background: rgba(255, 255, 255, 0.2);\n border-radius: 2px;\n overflow: hidden;\n }\n\n .progress-fill {\n height: 100%;\n background: linear-gradient(90deg, #7c3aed 0%, #10b981 100%);\n border-radius: 2px;\n transition: width 0.05s linear;\n }\n\n .branding-small {\n position: absolute;\n bottom: 24px;\n left: 50%;\n transform: translateX(-50%);\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 5px;\n font-size: 12px;\n color: rgba(255, 255, 255, 0.5);\n }\n\n .brand-logo-small {\n height: 18px;\n width: 18px;\n }\n\n /* Processing */\n .processing-container {\n padding: 80px 40px;\n text-align: center;\n color: white;\n animation: fadeIn 0.3s ease-out;\n }\n\n .spinner-wrapper {\n position: relative;\n width: 80px;\n height: 80px;\n margin: 0 auto 32px;\n }\n\n .spinner {\n position: absolute;\n inset: 0;\n border: 4px solid rgba(124, 58, 237, 0.2);\n border-top-color: #7c3aed;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n }\n\n .spinner-ring {\n position: absolute;\n inset: -10px;\n border: 2px solid rgba(124, 58, 237, 0.1);\n border-radius: 50%;\n animation: pulseSpinner 2s ease-in-out infinite;\n }\n\n @keyframes pulseSpinner {\n 0%, 100% { transform: scale(1); opacity: 1; }\n 50% { transform: scale(1.1); opacity: 0.5; }\n }\n\n .processing-container h3 {\n font-size: 24px;\n font-weight: 700;\n margin: 0 0 12px 0;\n }\n\n .processing-container p {\n font-size: 15px;\n color: rgba(255, 255, 255, 0.7);\n margin: 0;\n }\n\n /* Result Screens */\n .result-container {\n padding: 80px 40px 40px;\n text-align: center;\n color: white;\n animation: slideUp 0.4s ease-out;\n }\n\n .result-icon {\n display: inline-flex;\n margin-bottom: 24px;\n }\n\n .success-icon {\n color: #10b981;\n animation: scaleIn 0.6s ease-out;\n }\n\n .success-icon svg circle {\n animation: scaleIn 0.5s ease-out;\n }\n\n .success-icon svg path {\n stroke-dasharray: 100;\n stroke-dashoffset: 100;\n animation: checkmark 0.6s ease-out 0.3s forwards;\n }\n\n .error-icon {\n color: #ef4444;\n animation: fadeIn 0.5s ease-out;\n }\n\n .result-container h3 {\n font-size: 26px;\n font-weight: 700;\n margin: 0 0 12px 0;\n }\n\n .result-container p {\n font-size: 15px;\n color: rgba(255, 255, 255, 0.7);\n margin: 0 0 32px 0;\n line-height: 1.5;\n }\n\n .button-group {\n display: flex;\n gap: 12px;\n margin-top: 32px;\n }\n\n .secondary-button {\n flex: 1;\n padding: 14px 24px;\n border-radius: 12px;\n border: 1px solid rgba(255, 255, 255, 0.2);\n background: rgba(255, 255, 255, 0.1);\n color: white;\n font-size: 15px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s;\n }\n\n .secondary-button:hover {\n background: rgba(255, 255, 255, 0.15);\n border-color: rgba(255, 255, 255, 0.3);\n }\n\n .ghost-button {\n flex: 1;\n padding: 14px 24px;\n border-radius: 12px;\n border: none;\n background: transparent;\n color: rgba(255, 255, 255, 0.7);\n font-size: 15px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s;\n }\n\n .ghost-button:hover {\n color: white;\n background: rgba(255, 255, 255, 0.05);\n }\n\n /* Canvas */\n canvas {\n display: none;\n }\n\n /* Responsive */\n @media (max-width: 640px) {\n .modal-content {\n max-width: 100%;\n border-radius: 0;\n max-height: 100vh;\n }\n\n .instructions-container {\n padding: 50px 24px 24px;\n }\n\n .instructions-header h2 {\n font-size: 24px;\n }\n\n .video-circle {\n width: 280px;\n height: 350px;\n }\n\n .liveness-container {\n min-height: 100vh;\n }\n }\n "}),v.jsx("div",{className:"modal-overlay",children:v.jsxs("div",{className:"modal-content",children:[v.jsx("button",{className:"close-button",onClick:o,children:"×"}),"liveness"===w.status&&(()=>{if("liveness"!==w.status)return null;const e=`${w.currentStepIndex+1}/${w.stepSequence.length-1}`,n=w.stepProgress;return v.jsxs("div",{className:"liveness-container",children:[v.jsx("div",{className:"progress-indicator",children:v.jsx("span",{className:"progress-text",children:e})}),v.jsx("div",{className:"video-wrapper",children:v.jsxs("div",{className:`video-circle ${x?"face-detected":""} ${n>0?"capturing":""}`,children:[v.jsx("video",{ref:s,className:"video-feed",autoPlay:!0,muted:!0,playsInline:!0}),x&&v.jsxs("div",{className:"face-badge",children:[v.jsx("svg",{width:"16",height:"16",viewBox:"0 0 20 20",fill:"none",children:v.jsx("path",{d:"M5 10 L8 13 L15 6",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})}),v.jsx("span",{children:"Rosto detectado"})]})]})}),v.jsxs("div",{className:"instruction-box",children:[v.jsx("p",{className:"instruction-text",children:H[w.step]}),n>0&&v.jsx("div",{className:"progress-bar",children:v.jsx("div",{className:"progress-fill",style:{width:`${n}%`}})})]}),v.jsxs("div",{className:"branding-small",children:[v.jsx("img",{src:"/logo-icone.png",alt:"NeoFaceId",className:"brand-logo-small"}),v.jsx("span",{children:"NeoFaceId by"}),v.jsx("span",{className:"brand-name",children:"OCTA"})]})]})})(),"camera-loading"===w.status&&v.jsxs("div",{className:"processing-container",children:[v.jsxs("div",{className:"spinner-wrapper",children:[v.jsx("div",{className:"spinner"}),v.jsx("div",{className:"spinner-ring"})]}),v.jsx("h3",{children:"Inicializando câmera"}),v.jsx("p",{children:"Aguarde enquanto preparamos a câmera..."}),v.jsxs("div",{className:"branding",style:{marginTop:"40px",paddingTop:"24px",borderTop:"1px solid rgba(255, 255, 255, 0.1)"},children:[v.jsx("span",{children:"NeoFaceId by"}),v.jsx("span",{className:"brand-name",children:"OCTA"})]})]}),"processing"===w.status&&v.jsxs("div",{className:"processing-container",children:[v.jsxs("div",{className:"spinner-wrapper",children:[v.jsx("div",{className:"spinner"}),v.jsx("div",{className:"spinner-ring"})]}),v.jsx("h3",{children:"Processando biometria"}),v.jsx("p",{children:"Analisando suas capturas faciais..."}),v.jsxs("div",{className:"branding",style:{marginTop:"40px",paddingTop:"24px",borderTop:"1px solid rgba(255, 255, 255, 0.1)"},children:[v.jsx("span",{children:"NeoFaceId by"}),v.jsx("span",{className:"brand-name",children:"OCTA"})]})]}),"error"===w.status&&("error"!==w.status?null:v.jsxs("div",{className:"result-container error",children:[v.jsx("div",{className:"result-icon error-icon",children:v.jsxs("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",children:[v.jsx("circle",{cx:"30",cy:"30",r:"28",stroke:"currentColor",strokeWidth:"3"}),v.jsx("path",{d:"M20 20 L40 40 M40 20 L20 40",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}),v.jsx("h3",{children:"Não foi possível processar"}),v.jsx("p",{children:w.message}),v.jsxs("div",{className:"button-group",children:[w.retryable&&v.jsx("button",{className:"secondary-button",onClick:()=>y({type:"RESET"}),children:"Tentar Novamente"}),v.jsx("button",{className:"ghost-button",onClick:o,children:"Cancelar"})]})]})),"success"===w.status&&v.jsxs("div",{className:"result-container success",children:[v.jsx("div",{className:"result-icon success-icon",children:v.jsxs("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",children:[v.jsx("circle",{cx:"30",cy:"30",r:"28",stroke:"currentColor",strokeWidth:"3"}),v.jsx("path",{d:"M15 30 L25 40 L45 20",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"})]})}),v.jsx("h3",{children:r?"Captura concluída!":"Verificação concluída!"}),v.jsx("p",{children:r?"Suas capturas faciais foram realizadas":"Sua biometria foi registrada com sucesso"}),v.jsx("button",{className:"primary-button",onClick:o,children:"Continuar"})]})]})}),v.jsx("canvas",{ref:d})]})}class re{constructor(e){r(this,"modal",null),r(this,"video",null),r(this,"canvas",null),r(this,"stream",null),r(this,"options"),r(this,"countdownInterval",null),r(this,"isCapturing",!1),this.options=e}async open(){try{await this.createModal(),await this.initializeCamera(),this.startCountdown()}catch(e){this.options.onError(new k("Erro ao inicializar câmera: "+e.message,R.CAMERA_ERROR))}}close(){this.cleanup(),this.modal&&(document.body.removeChild(this.modal),this.modal=null)}async createModal(){this.modal=document.createElement("div"),this.modal.className="neofaceid-biometric-modal";const e=this.options.title||this.getDefaultTitle(),n=this.options.subtitle||this.getDefaultSubtitle();this.modal.innerHTML=`\n <div class="neofaceid-modal-overlay">\n <div class="neofaceid-modal-content">\n <div class="neofaceid-modal-header">\n <h2>${e}</h2>\n <button class="neofaceid-close-btn" type="button">×</button>\n </div>\n <div class="neofaceid-modal-body">\n <p class="neofaceid-subtitle">${n}</p>\n <div class="neofaceid-camera-container">\n <video class="neofaceid-video" autoplay muted playsinline></video>\n <canvas class="neofaceid-canvas" style="display: none;"></canvas>\n <div class="neofaceid-overlay">\n <div class="neofaceid-frame"></div>\n <div class="neofaceid-countdown">\n <span class="neofaceid-countdown-number">${this.options.countdown||3}</span>\n </div>\n </div>\n </div>\n <div class="neofaceid-status">\n <p class="neofaceid-status-text">Posicione-se na frente da câmera</p>\n </div>\n </div>\n <div class="neofaceid-modal-footer">\n <button class="neofaceid-cancel-btn" type="button">Cancelar</button>\n <button class="neofaceid-capture-btn" type="button" disabled>Capturar</button>\n </div>\n </div>\n </div>\n `,this.addStyles(),this.addEventListeners(),document.body.appendChild(this.modal)}async initializeCamera(){if(!this.modal)throw new Error("Modal não inicializado");if(this.video=this.modal.querySelector(".neofaceid-video"),this.canvas=this.modal.querySelector(".neofaceid-canvas"),!this.video||!this.canvas)throw new Error("Elementos de vídeo ou canvas não encontrados");try{this.stream=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"},audio:!1}),this.video.srcObject=this.stream,await this.video.play(),this.canvas.width=this.video.videoWidth,this.canvas.height=this.video.videoHeight}catch(e){throw new Error("Não foi possível acessar a câmera: "+e.message)}}startCountdown(){if(!this.modal)return;const e=this.modal.querySelector(".neofaceid-countdown-number"),n=this.modal.querySelector(".neofaceid-capture-btn"),t=this.modal.querySelector(".neofaceid-status-text");let o=this.options.countdown||3;e&&(e.textContent=o.toString()),this.countdownInterval=window.setInterval((()=>{o--,e&&(e.textContent=o.toString()),o<=0&&(this.countdownInterval&&(clearInterval(this.countdownInterval),this.countdownInterval=null),e&&(e.style.display="none"),n&&(n.disabled=!1,n.textContent="Capturar Agora"),t&&(t.textContent="Pronto para capturar!"),"auto"===this.options.mode&&setTimeout((()=>this.captureImage()),500))}),1e3)}async captureImage(){if(!this.isCapturing&&this.video&&this.canvas){this.isCapturing=!0;try{const e=this.canvas.getContext("2d");if(!e)throw new Error("Não foi possível obter contexto do canvas");e.drawImage(this.video,0,0,this.canvas.width,this.canvas.height);const n=this.canvas.toDataURL("image/jpeg",.8).split(",")[1],t=`data:image/jpeg;base64,${n}`;let o="auto"===this.options.mode?await this.detectBiometricType(n):this.options.mode;this.close(),this.options.onSuccess(t,o)}catch(e){this.options.onError(new k("Erro ao capturar imagem: "+e.message,R.CAPTURE_ERROR))}finally{this.isCapturing=!1}}}async detectBiometricType(e){try{const{detectBiometricType:n}=await Promise.resolve().then((()=>ke)),t=await n(e);return"unknown"!==t.type&&t.confidence>.6?t.type:"face"}catch(n){return"face"}}addEventListeners(){if(!this.modal)return;const e=this.modal.querySelector(".neofaceid-close-btn"),n=this.modal.querySelector(".neofaceid-cancel-btn"),t=this.modal.querySelector(".neofaceid-capture-btn");null==e||e.addEventListener("click",(()=>{var e,n;this.close(),null==(n=(e=this.options).onCancel)||n.call(e)})),null==n||n.addEventListener("click",(()=>{var e,n;this.close(),null==(n=(e=this.options).onCancel)||n.call(e)})),null==t||t.addEventListener("click",(()=>{this.captureImage()})),this.modal.addEventListener("click",(e=>{var n,t,o;e.target===(null==(n=this.modal)?void 0:n.querySelector(".neofaceid-modal-overlay"))&&(this.close(),null==(o=(t=this.options).onCancel)||o.call(t))}))}cleanup(){this.stream&&(this.stream.getTracks().forEach((e=>e.stop())),this.stream=null),this.countdownInterval&&(clearInterval(this.countdownInterval),this.countdownInterval=null),this.video=null,this.canvas=null,this.isCapturing=!1}getDefaultTitle(){switch(this.options.mode){case"face":return"Autenticação Facial";case"hand":return"Autenticação por Mão";case"auto":return"Autenticação Biométrica";default:return"Captura Biométrica"}}getDefaultSubtitle(){switch(this.options.mode){case"face":return"Posicione seu rosto dentro do quadro e aguarde a captura automática.";case"hand":return"Posicione sua mão dentro do quadro e aguarde a captura automática.";case"auto":return"Posicione seu rosto ou mão dentro do quadro para autenticação automática.";default:return"Posicione-se dentro do quadro para captura."}}addStyles(){const e="neofaceid-biometric-modal-styles",n=document.getElementById(e);n&&n.remove();const t=document.createElement("style");t.id=e,t.textContent="\n .neofaceid-biometric-modal {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 10000;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n }\n\n .neofaceid-modal-overlay {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.8);\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 20px;\n box-sizing: border-box;\n }\n\n .neofaceid-modal-content {\n background: white;\n border-radius: 12px;\n max-width: 600px;\n width: 100%;\n max-height: 90vh;\n overflow: hidden;\n box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);\n }\n\n .neofaceid-modal-header {\n padding: 20px;\n border-bottom: 1px solid #e0e0e0;\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n\n .neofaceid-modal-header h2 {\n margin: 0;\n font-size: 24px;\n font-weight: 600;\n color: #333;\n }\n\n .neofaceid-close-btn {\n background: none;\n border: none;\n font-size: 28px;\n cursor: pointer;\n color: #666;\n padding: 0;\n width: 32px;\n height: 32px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 50%;\n transition: background-color 0.2s;\n }\n\n .neofaceid-close-btn:hover {\n background-color: #f0f0f0;\n }\n\n .neofaceid-modal-body {\n padding: 20px;\n }\n\n .neofaceid-subtitle {\n margin: 0 0 20px 0;\n color: #666;\n font-size: 16px;\n line-height: 1.4;\n }\n\n .neofaceid-camera-container {\n position: relative;\n background: #000;\n border-radius: 8px;\n overflow: hidden;\n aspect-ratio: 4/3;\n margin-bottom: 20px;\n }\n\n .neofaceid-video {\n width: 100%;\n height: 100%;\n object-fit: cover;\n }\n\n .neofaceid-canvas {\n position: absolute;\n top: 0;\n left: 0;\n }\n\n .neofaceid-overlay {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .neofaceid-frame {\n width: 200px;\n height: 200px;\n border: 3px solid #4CAF50;\n border-radius: 50%;\n box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3);\n animation: pulse 2s infinite;\n }\n\n .neofaceid-countdown {\n position: absolute;\n top: 20px;\n right: 20px;\n background: rgba(0, 0, 0, 0.7);\n color: white;\n padding: 10px;\n border-radius: 50%;\n width: 50px;\n height: 50px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .neofaceid-countdown-number {\n font-size: 24px;\n font-weight: bold;\n }\n\n .neofaceid-status {\n text-align: center;\n margin-bottom: 20px;\n }\n\n .neofaceid-status-text {\n margin: 0;\n color: #666;\n font-size: 16px;\n }\n\n .neofaceid-modal-footer {\n padding: 20px;\n border-top: 1px solid #e0e0e0;\n display: flex;\n gap: 12px;\n justify-content: flex-end;\n }\n\n .neofaceid-cancel-btn,\n .neofaceid-capture-btn {\n padding: 12px 24px;\n border: none;\n border-radius: 6px;\n font-size: 16px;\n font-weight: 500;\n cursor: pointer;\n transition: all 0.2s;\n }\n\n .neofaceid-cancel-btn {\n background: #f5f5f5;\n color: #666;\n }\n\n .neofaceid-cancel-btn:hover {\n background: #e0e0e0;\n }\n\n .neofaceid-capture-btn {\n background: #4CAF50;\n color: white;\n }\n\n .neofaceid-capture-btn:hover:not(:disabled) {\n background: #45a049;\n }\n\n .neofaceid-capture-btn:disabled {\n background: #ccc;\n cursor: not-allowed;\n }\n\n @keyframes pulse {\n 0% { box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3); }\n 50% { box-shadow: 0 0 0 10px rgba(76, 175, 80, 0.1); }\n 100% { box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3); }\n }\n\n @media (max-width: 640px) {\n .neofaceid-modal-overlay {\n padding: 10px;\n }\n \n .neofaceid-modal-header,\n .neofaceid-modal-body,\n .neofaceid-modal-footer {\n padding: 15px;\n }\n \n .neofaceid-frame {\n width: 150px;\n height: 150px;\n }\n }\n ",document.head.appendChild(t)}}class ie{constructor(){r(this,"container",null),r(this,"currentStatus","preparing")}getStyles(){return"\n @keyframes neofaceid-fadeIn {\n from { opacity: 0; transform: scale(0.9); }\n to { opacity: 1; transform: scale(1); }\n }\n\n @keyframes neofaceid-fadeOut {\n from { opacity: 1; transform: scale(1); }\n to { opacity: 0; transform: scale(0.9); }\n }\n\n @keyframes neofaceid-pulse {\n 0%, 100% { \n transform: scale(1);\n opacity: 1;\n }\n 50% { \n transform: scale(1.05);\n opacity: 0.9;\n }\n }\n\n @keyframes neofaceid-scaleIn {\n 0% { transform: scale(0); opacity: 0; }\n 50% { transform: scale(1.1); }\n 100% { transform: scale(1); opacity: 1; }\n }\n\n @keyframes neofaceid-errorShake {\n 0%, 100% { transform: translateX(0); }\n 10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }\n 20%, 40%, 60%, 80% { transform: translateX(4px); }\n }\n\n .neofaceid-overlay-container {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10000;\n pointer-events: none;\n animation: neofaceid-fadeIn 0.3s ease-out;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;\n }\n\n .neofaceid-overlay-container.fade-out {\n animation: neofaceid-fadeOut 0.3s ease-out forwards;\n }\n\n .neofaceid-overlay-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 24px;\n pointer-events: auto;\n }\n\n .neofaceid-visual-wrapper {\n position: relative;\n width: 100px;\n height: 100px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .neofaceid-logo {\n width: 80px;\n height: 80px;\n object-fit: contain;\n transition: all 0.5s ease;\n filter: drop-shadow(0 4px 12px rgba(124, 58, 237, 0.3));\n }\n\n /* Cores por estado */\n .neofaceid-state-preparing .neofaceid-logo { filter: drop-shadow(0 0 15px rgba(124, 58, 237, 0.4)); }\n .neofaceid-state-detecting .neofaceid-logo { filter: hue-rotate(180deg) drop-shadow(0 0 15px rgba(59, 130, 246, 0.6)); }\n .neofaceid-state-capturing .neofaceid-logo { filter: hue-rotate(45deg) drop-shadow(0 0 15px rgba(245, 158, 11, 0.6)); }\n .neofaceid-state-verifying .neofaceid-logo { filter: hue-rotate(90deg) drop-shadow(0 0 15px rgba(34, 197, 94, 0.6)); }\n\n .neofaceid-logo.pulsing {\n animation: neofaceid-pulse 2s ease-in-out infinite;\n }\n\n @keyframes neofaceid-dots {\n 0%, 20% { opacity: 0; transform: translateY(0); }\n 50% { opacity: 1; transform: translateY(-2px); }\n 80%, 100% { opacity: 0; transform: translateY(0); }\n }\n\n .neofaceid-status-text {\n font-size: 15px;\n font-weight: 500;\n color: #ffffff;\n text-align: center;\n padding: 10px 24px;\n background: rgba(15, 23, 42, 0.8);\n backdrop-filter: blur(8px);\n border-radius: 100px;\n box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);\n border: 1px solid rgba(255, 255, 255, 0.1);\n text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);\n animation: neofaceid-fadeIn 0.3s ease-out;\n display: flex;\n align-items: center;\n gap: 2px;\n }\n\n .neofaceid-dots {\n display: inline-flex;\n margin-left: 2px;\n }\n\n .neofaceid-dot {\n animation: neofaceid-dots 1.5s infinite;\n opacity: 0;\n }\n\n .neofaceid-dot:nth-child(2) { animation-delay: 0.2s; }\n .neofaceid-dot:nth-child(3) { animation-delay: 0.4s; }\n\n .neofaceid-status-icon {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .neofaceid-success-icon {\n width: 80px;\n height: 80px;\n color: #10b981;\n animation: neofaceid-scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);\n }\n\n .neofaceid-error-icon {\n width: 80px;\n height: 80px;\n color: #ef4444;\n animation: neofaceid-errorShake 0.5s linear, neofaceid-scaleIn 0.4s ease-out;\n }\n "}getStatusText(){switch(this.currentStatus){case"preparing":return"Iniciando câmera";case"detecting":return"Posicione seu rosto";case"capturing":return"Capturando";case"verifying":return"Verificando identidade";case"success":return"Identificado!";case"error":return"Falha na identificação";default:return""}}renderContent(){const e=["detecting","verifying"].includes(this.currentStatus),n=!["success","error"].includes(this.currentStatus),t="success"===this.currentStatus,o="error"===this.currentStatus,a=this.getStatusText(),r=["preparing","detecting","capturing","verifying"].includes(this.currentStatus);return`\n <style>${this.getStyles()}</style>\n <div class="neofaceid-overlay-container neofaceid-state-${this.currentStatus}">\n <div class="neofaceid-overlay-content">\n <div class="neofaceid-visual-wrapper">\n ${n?`\n <img\n src="/logo-icone-no-background.png"\n alt="NeoFaceId"\n class="neofaceid-logo ${e?"pulsing":""}"\n onerror="this.style.display='none'"\n />\n `:""}\n \n ${t?'\n <div class="neofaceid-status-icon">\n <svg class="neofaceid-success-icon" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="30" cy="30" r="28" stroke="currentColor" stroke-width="3" fill="none"/>\n <path d="M15 30 L25 40 L45 20" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" fill="none"/>\n </svg>\n </div>\n ':""}\n \n ${o?'\n <div class="neofaceid-status-icon">\n <svg class="neofaceid-error-icon" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="30" cy="30" r="28" stroke="currentColor" stroke-width="3" fill="none"/>\n <path d="M20 20 L40 40 M40 20 L20 40" stroke="currentColor" stroke-width="3" stroke-linecap="round"/>\n </svg>\n </div>\n ':""}\n </div>\n \n ${a?`\n <div class="neofaceid-status-text">\n ${a}${r?'\n <span class="neofaceid-dots">\n <span class="neofaceid-dot">.</span>\n <span class="neofaceid-dot">.</span>\n <span class="neofaceid-dot">.</span>\n </span>\n ':""}\n </div>\n `:""}\n </div>\n </div>\n `}show(e="preparing"){this.container?this.updateStatus(e):(this.container=document.createElement("div"),this.container.id="neofaceid-status-overlay",this.currentStatus=e,this.container.innerHTML=this.renderContent(),document.body.appendChild(this.container))}updateStatus(e){this.currentStatus=e,this.container&&(this.container.innerHTML=this.renderContent())}close(){if(this.container){const e=this.container.querySelector(".neofaceid-overlay-container");e&&e.classList.add("fade-out"),setTimeout((()=>{this.container&&document.body.contains(this.container)&&document.body.removeChild(this.container),this.container=null}),300)}}}function se({error:e,onRetry:n,onCredentials:t,onCancel:o}){return v.jsxs(v.Fragment,{children:[v.jsx("style",{children:"\n @keyframes slideUp {\n from {\n opacity: 0;\n transform: translateY(20px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n\n @keyframes fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n\n .neofaceid-fallback-overlay {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.6);\n backdrop-filter: blur(8px);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10001;\n padding: 20px;\n animation: fadeIn 0.3s ease-out;\n }\n\n .neofaceid-fallback-prompt {\n background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);\n border-radius: 20px;\n padding: 32px;\n max-width: 400px;\n width: 100%;\n box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);\n animation: slideUp 0.4s ease-out;\n text-align: center;\n }\n\n .neofaceid-fallback-icon {\n width: 64px;\n height: 64px;\n margin: 0 auto 20px;\n color: #ef4444;\n animation: scaleIn 0.4s ease-out;\n }\n\n @keyframes scaleIn {\n 0% {\n transform: scale(0);\n opacity: 0;\n }\n 50% {\n transform: scale(1.1);\n }\n 100% {\n transform: scale(1);\n opacity: 1;\n }\n }\n\n .neofaceid-fallback-title {\n font-size: 22px;\n font-weight: 700;\n color: white;\n margin: 0 0 12px 0;\n }\n\n .neofaceid-fallback-message {\n font-size: 15px;\n color: rgba(255, 255, 255, 0.7);\n margin: 0 0 28px 0;\n line-height: 1.5;\n }\n\n .neofaceid-fallback-actions {\n display: flex;\n flex-direction: column;\n gap: 12px;\n }\n\n .neofaceid-fallback-button {\n padding: 14px 24px;\n border-radius: 12px;\n border: none;\n font-size: 16px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n }\n\n .neofaceid-fallback-button-primary {\n background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);\n color: white;\n box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);\n }\n\n .neofaceid-fallback-button-primary:hover {\n transform: translateY(-2px);\n box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4);\n }\n\n .neofaceid-fallback-button-primary:active {\n transform: translateY(0);\n }\n\n .neofaceid-fallback-button-secondary {\n background: rgba(255, 255, 255, 0.1);\n color: white;\n border: 1px solid rgba(255, 255, 255, 0.2);\n }\n\n .neofaceid-fallback-button-secondary:hover {\n background: rgba(255, 255, 255, 0.15);\n border-color: rgba(255, 255, 255, 0.3);\n }\n\n .neofaceid-fallback-button-ghost {\n background: transparent;\n color: rgba(255, 255, 255, 0.7);\n padding: 10px;\n }\n\n .neofaceid-fallback-button-ghost:hover {\n color: white;\n background: rgba(255, 255, 255, 0.05);\n }\n\n @media (max-width: 640px) {\n .neofaceid-fallback-prompt {\n padding: 24px;\n border-radius: 16px;\n }\n\n .neofaceid-fallback-title {\n font-size: 20px;\n }\n }\n "}),v.jsx("div",{className:"neofaceid-fallback-overlay",children:v.jsxs("div",{className:"neofaceid-fallback-prompt",children:[v.jsx("div",{className:"neofaceid-fallback-icon",children:v.jsxs("svg",{viewBox:"0 0 64 64",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[v.jsx("circle",{cx:"32",cy:"32",r:"30",stroke:"currentColor",strokeWidth:"3",fill:"none"}),v.jsx("path",{d:"M20 20 L44 44 M44 20 L20 44",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}),v.jsx("h3",{className:"neofaceid-fallback-title",children:"Não foi possível reconhecer"}),v.jsx("p",{className:"neofaceid-fallback-message",children:(null==e?void 0:e.getFriendlyMessage())||"Não conseguimos reconhecer sua face. Tente novamente ou use email e senha."}),v.jsxs("div",{className:"neofaceid-fallback-actions",children:[v.jsx("button",{type:"button",className:"neofaceid-fallback-button neofaceid-fallback-button-primary",onClick:n,children:"Tentar Novamente"}),v.jsx("button",{type:"button",className:"neofaceid-fallback-button neofaceid-fallback-button-secondary",onClick:t,children:"Entrar com Email e Senha"}),o&&v.jsx("button",{type:"button",className:"neofaceid-fallback-button neofaceid-fallback-button-ghost",onClick:o,children:"Cancelar"})]})]})})]})}class ce{constructor(){r(this,"container",null),r(this,"root",null)}show(e,n,t,o){this.container||(this.container=document.createElement("div"),this.container.id="neofaceid-fallback-prompt",document.body.appendChild(this.container),this.root=p.createRoot(this.container),this.render(e,n,t,o))}close(){this.container&&document.body.contains(this.container)&&(this.root&&this.root.unmount(),document.body.removeChild(this.container),this.container=null,this.root=null)}render(e,n,t,o){this.root&&this.container&&this.root.render(v.jsx(se,{error:e,onRetry:()=>{this.close(),n()},onCredentials:()=>{this.close(),t()},onCancel:()=>{this.close(),null==o||o()}}))}}class de{constructor(e){r(this,"options"),r(this,"modalElement",null),this.options=e}async open(){this.createModal(),document.body.appendChild(this.modalElement)}close(){this.modalElement&&(document.body.removeChild(this.modalElement),this.modalElement=null),this.options.onCancel&&this.options.onCancel()}createModal(){this.addStyles(),this.modalElement=document.createElement("div"),this.modalElement.className="neoface-email-password-modal",this.modalElement.innerHTML=`\n <div class="neoface-email-modal-overlay">\n <div class="neoface-email-modal-content">\n <h2>${this.options.title||"Login com Email e Senha"}</h2>\n <p>${this.options.subtitle||"Informe seus dados para login."}</p>\n <div id="login-error" class="neoface-email-error" style="display:none"></div>\n <form id="email-password-form">\n <input type="email" id="email" placeholder="Email" required />\n <input type="password" id="password" placeholder="Senha" required />\n <button type="submit" class="neoface-email-submit-btn">Entrar</button>\n </form>\n <button class="neoface-email-cancel-btn">Cancelar</button>\n \n \x3c!-- Branding --\x3e\n <div class="neoface-email-branding">\n <img src="/logo-icone-no-background.png" alt="NeoFaceId" class="neoface-email-brand-logo" onerror="this.style.display='none'" />\n <span>NeoFaceId by</span>\n <span class="neoface-email-brand-name">OCTA</span>\n </div>\n </div>\n </div>\n `;this.modalElement.querySelector("#email-password-form").addEventListener("submit",this.handleSubmit.bind(this));this.modalElement.querySelector(".neoface-email-cancel-btn").addEventListener("click",this.close.bind(this))}addStyles(){const e="neoface-email-password-modal-styles";if(document.getElementById(e))return;const n=document.createElement("style");n.id=e,n.textContent="\n .neoface-email-password-modal {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 10002;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n }\n\n .neoface-email-modal-overlay {\n position: absolute;\n inset: 0;\n background: rgba(0, 0, 0, 0.6);\n backdrop-filter: blur(8px);\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 20px;\n animation: fadeIn 0.3s ease-out;\n }\n\n @keyframes fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n\n @keyframes slideUp {\n from {\n opacity: 0;\n transform: translateY(20px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n\n .neoface-email-modal-content {\n background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);\n border-radius: 20px;\n padding: 32px;\n max-width: 400px;\n width: 100%;\n box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);\n animation: slideUp 0.4s ease-out;\n }\n\n .neoface-email-modal-content h2 {\n font-size: 24px;\n font-weight: 700;\n color: white;\n margin: 0 0 12px 0;\n text-align: center;\n }\n\n .neoface-email-modal-content p {\n font-size: 15px;\n color: rgba(255, 255, 255, 0.7);\n margin: 0 0 24px 0;\n text-align: center;\n line-height: 1.5;\n }\n\n .neoface-email-modal-content form {\n display: flex;\n flex-direction: column;\n gap: 16px;\n margin-bottom: 16px;\n }\n\n .neoface-email-modal-content input {\n width: 100%;\n padding: 14px 16px;\n border: 2px solid rgba(255, 255, 255, 0.2);\n border-radius: 12px;\n font-size: 15px;\n background: rgba(255, 255, 255, 0.1);\n color: white;\n font-family: inherit;\n transition: all 0.2s;\n box-sizing: border-box;\n }\n\n .neoface-email-modal-content input::placeholder {\n color: rgba(255, 255, 255, 0.5);\n }\n\n .neoface-email-modal-content input:focus {\n outline: none;\n border-color: #7c3aed;\n box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);\n background: rgba(255, 255, 255, 0.15);\n }\n\n .neoface-email-submit-btn {\n width: 100%;\n padding: 14px 24px;\n border-radius: 12px;\n border: none;\n background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);\n color: white;\n font-size: 16px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s;\n box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);\n font-family: inherit;\n }\n\n .neoface-email-submit-btn:hover {\n transform: translateY(-2px);\n box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4);\n }\n\n .neoface-email-submit-btn:active {\n transform: translateY(0);\n }\n\n .neoface-email-submit-btn:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n transform: none;\n }\n\n .neoface-email-cancel-btn {\n width: 100%;\n padding: 12px 24px;\n border-radius: 12px;\n border: 1px solid rgba(255, 255, 255, 0.2);\n background: transparent;\n color: rgba(255, 255, 255, 0.7);\n font-size: 15px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s;\n font-family: inherit;\n }\n\n .neoface-email-cancel-btn:hover {\n background: rgba(255, 255, 255, 0.1);\n color: white;\n border-color: rgba(255, 255, 255, 0.3);\n }\n\n .neoface-email-branding {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n margin-top: 32px;\n padding-top: 24px;\n border-top: 1px solid rgba(255, 255, 255, 0.1);\n font-size: 13px;\n color: rgba(255, 255, 255, 0.5);\n }\n\n .neoface-email-brand-logo {\n height: 20px;\n width: auto;\n }\n\n .neoface-email-brand-name {\n font-weight: 600;\n font-family: 'SF Pro Display', -apple-system, system-ui, sans-serif;\n color: #ffffff;\n letter-spacing: 0.3px;\n }\n\n .neoface-email-error {\n background: rgba(239, 68, 68, 0.15);\n border: 1px solid rgba(239, 68, 68, 0.4);\n border-radius: 10px;\n color: #fca5a5;\n font-size: 14px;\n padding: 12px 16px;\n margin-bottom: 16px;\n text-align: center;\n animation: fadeIn 0.2s ease-out;\n }\n\n @media (max-width: 640px) {\n .neoface-email-modal-content {\n padding: 24px;\n border-radius: 16px;\n }\n\n .neoface-email-modal-content h2 {\n font-size: 20px;\n }\n }\n ",document.head.appendChild(n)}async handleSubmit(e){e.preventDefault();const n=this.modalElement.querySelector("#email"),t=this.modalElement.querySelector("#password"),o=this.modalElement.querySelector(".neoface-email-submit-btn"),a=this.modalElement.querySelector("#login-error"),r=e=>{a.textContent=e,a.style.display="block"};a.style.display="none",a.textContent="";const i=n.value.trim(),s=t.value.trim();if(i&&s){o.disabled=!0,o.textContent="Entrando...";try{const e=await B(i,s,this.options.applicationToken);this.options.onSuccess(e),this.close()}catch(c){o.disabled=!1,o.textContent="Entrar";c instanceof k&&(c.type===R.INVALID_TOKEN||c.type===R.API_ERROR&&c.message.includes("400"))?(r("Email ou senha incorretos. Verifique seus dados e tente novamente."),t.value="",t.focus()):(r("Ocorreu um erro inesperado. Tente novamente mais tarde."),this.options.onError(c))}}else r("Preencha o email e a senha para continuar.")}}let le=!1,ue=null;async function pe(){if(!le)return ue||(ue=(async()=>{try{const e="https://cdn.jsdelivr.net/npm/@vladmandic/face-api/model";await c.nets.tinyFaceDetector.loadFromUri(e),le=!0}catch(e){}})(),ue)}async function fe(e,n,t=!1,o=!1){o?n.updateStatus("detecting"):n.updateStatus("preparing");const a=document.createElement("video");a.style.position="fixed",a.style.top="-9999px",a.style.left="-9999px",a.style.width="1px",a.style.height="1px",a.style.opacity="0",a.muted=!0,a.playsInline=!0,a.setAttribute("autoplay",""),a.setAttribute("playsinline",""),document.body.appendChild(a);let r=null;try{try{r=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"},audio:!1})}catch{r=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user"},audio:!1})}a.srcObject=r,await new Promise((e=>{if(a.readyState>=1)e();else{const n=()=>{a.removeEventListener("loadedmetadata",n),e()};a.addEventListener("loadedmetadata",n),setTimeout(e,2e3)}})),await a.play(),await new Promise((e=>{if(a.videoWidth&&a.videoHeight)e();else{const n=()=>{a.videoWidth&&a.videoHeight?e():setTimeout(n,100)};setTimeout(e,3e3),n()}})),n.updateStatus("detecting"),await new Promise((e=>setTimeout(e,100)));let o=!0;if(t||(o=await async function(e,n=5e3,t=100){return new Promise((o=>{let a=0;const r=Math.ceil(n/t);let i=null,s=!1;const d=e=>{s||(s=!0,i&&clearTimeout(i),o(e))},l=async()=>{if(!s)if(a++,le)try{if(await c.detectSingleFace(e,new c.TinyFaceDetectorOptions({inputSize:160,scoreThreshold:.3})))return void d(!0);if(a>=r)return void d(!1);i=window.setTimeout(l,t)}catch(n){d(!0)}else d(!0)};window.setTimeout((()=>{s||d(!0)}),n+500),l()}))}(a)),!o)throw r&&r.getTracks().forEach((e=>e.stop())),a.parentElement&&a.parentElement.removeChild(a),new k("Rosto não detectado. Posicione seu rosto na frente da câmera.",R.VALIDATION_ERROR);n.updateStatus("capturing");const i=document.createElement("canvas");i.width=a.videoWidth,i.height=a.videoHeight;const s=i.getContext("2d");if(!s)throw r&&r.getTracks().forEach((e=>e.stop())),a.parentElement&&a.parentElement.removeChild(a),new k("Erro ao capturar imagem",R.CAPTURE_ERROR);s.drawImage(a,0,0,i.width,i.height),r&&r.getTracks().forEach((e=>e.stop())),a.parentElement&&a.parentElement.removeChild(a);const d=await new Promise(((e,n)=>{i.toBlob((t=>{i.remove(),t?e(t):n(new Error("Failed to capture image"))}),"image/jpeg",.85)}));n.updateStatus("verifying");const l=await F(d,e);if(!l.success)throw new k("Login falhou",R.LOGIN_FAILED);return l}catch(i){if(r&&r.getTracks().forEach((e=>e.stop())),a.parentElement&&a.parentElement.removeChild(a),i instanceof k)throw i;throw new k(i instanceof Error?i.message:"Erro desconhecido",R.UNKNOWN)}}async function he(e){const{applicationToken:n,onSuccess:t,onError:o,onFallbackRequest:a,onCancel:r,fastMode:i=!1}=e,s=new ie,c=new ce;let d,l=0;le||i||pe().catch((()=>{})),s.show("preparing");const u=async()=>{try{l++;const e=await fe(n,s,i,l>1);s.updateStatus("success"),setTimeout((()=>{s.close(),t(e)}),200)}catch(e){d=e instanceof k?e:new k(e instanceof Error?e.message:"Erro desconhecido",R.UNKNOWN),s.updateStatus("error"),l<2?setTimeout((()=>{u()}),500):setTimeout((()=>{s.close(),c.show(d,(()=>{l=0,s.show("preparing"),setTimeout((()=>u()),500)}),(()=>{a?a():o(new k("Por favor, use email e senha para fazer login",R.LOGIN_FAILED))}),r)}),500)}};u()}const me=Object.freeze(Object.defineProperty({__proto__:null,captureFaceSilently:async function(){return new Promise(((e,n)=>{const t=document.createElement("video");t.style.position="fixed",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.opacity="0",t.muted=!0,t.playsInline=!0,t.setAttribute("autoplay",""),t.setAttribute("playsinline","");const o=document.createElement("canvas");o.style.display="none";let a=null,r=0;const i=()=>{a&&a.getTracks().forEach((e=>e.stop())),t.parentElement&&t.parentElement.removeChild(t),o.parentElement&&o.parentElement.removeChild(o)};document.body.appendChild(t),document.body.appendChild(o);const s=e=>e?navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"},audio:!1}):navigator.mediaDevices.getUserMedia({video:{facingMode:"user"},audio:!1});s(!0).catch((()=>s(!1))).then((s=>{a=s,t.srcObject=a;const d=()=>{if(!t.videoWidth||!t.videoHeight)return r<30?(r++,void setTimeout(d,150)):(i(),void n(new k("Câmera não está pronta",R.CAMERA_ERROR)));o.width=t.videoWidth,o.height=t.videoHeight;const a=o.getContext("2d");if(!a)return i(),void n(new Error("Failed to get canvas context"));(async()=>{if(!le)return!0;try{return!!(await c.detectSingleFace(t,new c.TinyFaceDetectorOptions({inputSize:160,scoreThreshold:.3})))}catch{return!0}})().then((s=>{if(!s&&r<30)return r++,void setTimeout(d,150);a.drawImage(t,0,0,o.width,o.height),o.toBlob((t=>{i(),t?e(t):n(new Error("Failed to capture image"))}),"image/jpeg",.85)}))},l=t.play();void 0!==l?l.then((()=>{t.videoWidth&&t.videoHeight?setTimeout(d,200):(t.onloadedmetadata=()=>setTimeout(d,200),setTimeout((()=>{t.videoWidth&&t.videoHeight&&d()}),1500))})).catch((e=>{i(),n(new k("Erro ao reproduzir câmera: "+e.message,R.CAMERA_ERROR))})):t.onloadedmetadata=()=>setTimeout(d,200),t.onerror=()=>{i(),n(new k("Erro ao acessar câmera",R.CAMERA_ERROR))}})).catch((e=>{i(),n(new k("Não foi possível acessar a câmera: "+e.message,R.CAMERA_ERROR))}))}))},executeBiometricLoginFlow:he,preloadFaceDetectionModels:pe},Symbol.toStringTag,{value:"Module"}));async function ge(e){try{await he({applicationToken:e.applicationToken,onSuccess:e.onSuccess,onError:e.onError,onFallbackRequest:e.onFallbackRequest||(()=>{const n={applicationToken:e.applicationToken,onSuccess:e.onSuccess,onError:e.onError,title:"Login Alternativo",subtitle:"Biometria não reconhecida. Por favor, informe email e senha."};new de(n).open()}),onCancel:e.onCancel})}catch(n){e.onError(new k("Erro ao inicializar login facial: "+n.message,R.INITIALIZATION_ERROR))}}async function be(e){try{const n={mode:"hand",onSuccess:async(n,t)=>{try{const t=await fetch(n).then((e=>e.blob())),o=await F(t,e.applicationToken);e.onSuccess(o)}catch(o){e.onError(o)}},onError:e.onError,onCancel:e.onCancel,countdown:e.countdown,title:e.title||"Login por Mão",subtitle:e.subtitle||"Posicione sua mão dentro do quadro para fazer login."},t=new re(n);await t.open()}catch(n){e.onError(new k("Erro ao inicializar login por mão: "+n.message,R.INITIALIZATION_ERROR))}}async function we(e){try{const n={mode:"auto",onSuccess:async(n,t)=>{try{const t=await fetch(n).then((e=>e.blob())),o=await F(t,e.applicationToken);e.onSuccess(o)}catch(o){e.onError(o)}},onError:e.onError,onCancel:e.onCancel,countdown:e.countdown,title:e.title||"Login Biométrico",subtitle:e.subtitle||"Posicione seu rosto ou mão dentro do quadro para login automático."},t=new re(n);await t.open()}catch(n){e.onError(new k("Erro ao inicializar login automático: "+n.message,R.INITIALIZATION_ERROR))}}async function ve(e){try{const t=await(n=e,new Promise(((e,t)=>{const o=new Image;o.onload=()=>e(o),o.onerror=()=>t(new Error("Erro ao carregar imagem"));const a=n.startsWith("data:")?n:`data:image/jpeg;base64,${n}`;o.src=a}))),o=await async function(e){try{if("undefined"!=typeof window&&window.faceapi){const n=window.faceapi;await xe();const t=new n.TinyFaceDetectorOptions({inputSize:320,scoreThreshold:.5}),o=await n.detectAllFaces(e,t).withFaceLandmarks();if(o&&o.length>0){const e=o.reduce(((e,n)=>n.detection.score>e.detection.score?n:e));return{confidence:e.detection.score,details:{faces:o.length,landmarks:e.landmarks,box:e.detection.box}}}}return{confidence:0}}catch(n){return{confidence:0}}}(t);if(o.confidence>.7)return{type:"face",confidence:o.confidence,details:o.details};const a=await async function(e){try{const n=document.createElement("canvas"),t=n.getContext("2d");if(!t)return{confidence:0};n.width=e.width,n.height=e.height,t.drawImage(e,0,0);const o=function(e){const{data:n,width:t,height:o}=e;let a=0,r=0;for(let l=0;l<n.length;l+=4){ye(n[l],n[l+1],n[l+2])&&a++,r++}const i=a/r,s=t/o;let c=0;i>.15&&i<.7&&(c+=i/.7*.4);s>.6&&s<1.8&&(c+=.3);const d=t*o;d>1e4&&d<5e5&&(c+=.3);return{confidence:Math.min(c,.8),skinRatio:i,aspectRatio:s,imageSize:d,skinPixels:a,totalPixels:r}}(t.getImageData(0,0,n.width,n.height));return{confidence:o.confidence,details:o}}catch(n){return{confidence:0}}}(t);return a.confidence>.6?{type:"hand",confidence:a.confidence,details:a.details}:{type:"unknown",confidence:Math.max(o.confidence,a.confidence)}}catch(t){return{type:"face",confidence:.5}}var n}function ye(e,n,t){const o=.299*e+.587*n+.114*t,a=-.169*e-.331*n+.5*t+128,r=.5*e-.419*n-.081*t+128;return o>80&&o<255&&a>85&&a<135&&r>135&&r<180}async function xe(){if("undefined"==typeof window||!window.faceapi)return;const e=window.faceapi;if(!e.nets.tinyFaceDetector.isLoaded)try{await Promise.all([e.nets.tinyFaceDetector.loadFromUri("./models"),e.nets.faceLandmark68Net.loadFromUri("./models")])}catch(n){}}async function Ee(){try{"undefined"!=typeof window&&await xe()}catch(e){}}function Re(){return"undefined"!=typeof window&&window.faceapi&&window.faceapi.nets.tinyFaceDetector.isLoaded}const ke=Object.freeze(Object.defineProperty({__proto__:null,detectBiometricType:ve,initializeBiometricDetection:Ee,isAdvancedDetectionAvailable:Re},Symbol.toStringTag,{value:"Module"}));class Te{constructor(e){r(this,"overlay",null),r(this,"video",null),r(this,"canvas",null),r(this,"stream",null),r(this,"step","face"),r(this,"countdownSeconds"),r(this,"title"),r(this,"subtitle"),r(this,"faceBlob",null),r(this,"documentBlob",null),this.countdownSeconds=(null==e?void 0:e.countdown)??3,this.title=null==e?void 0:e.title,this.subtitle=null==e?void 0:e.subtitle}async open(){if(await this.createDom(),await this.startCamera(),await this.runFaceCaptureCountdown(),this.faceBlob=await this.captureFrame(),this.step="document",this.updateTexts("Captura do Documento",'Posicione seu documento visível e clique em "Capturar"'),await this.waitForUserCaptureClick(),this.documentBlob=await this.captureFrame(),await this.close(),!this.faceBlob||!this.documentBlob)throw new Error("Falha na captura das imagens de onboarding");return{face:this.faceBlob,document:this.documentBlob}}async createDom(){const e=document.createElement("div");e.className="neofaceid-modal-overlay",e.innerHTML=`\n <div class="neofaceid-modal">\n <div class="neofaceid-modal-header">\n <h2 class="neofaceid-title">${this.title??"Onboarding NeoFaceID"}</h2>\n <button class="neofaceid-close-btn" aria-label="Fechar">×</button>\n </div>\n <div class="neofaceid-modal-body">\n <p class="neofaceid-subtitle">${this.subtitle??"Vamos capturar sua face e documento"}</p>\n <div class="neofaceid-camera-container">\n <video class="neofaceid-video" autoplay muted playsinline></video>\n <canvas class="neofaceid-canvas"></canvas>\n <div class="neofaceid-overlay">\n <div class="neofaceid-frame"></div>\n <div class="neofaceid-countdown" style="display:none"><span class="neofaceid-countdown-number">${this.countdownSeconds}</span></div>\n </div>\n </div>\n <div class="neofaceid-status"><p class="neofaceid-status-text">Posicione seu rosto no quadro</p></div>\n </div>\n <div class="neofaceid-modal-footer">\n <button class="neofaceid-cancel-btn">Cancelar</button>\n <button class="neofaceid-capture-btn" disabled>Capturar</button>\n </div>\n </div>\n `;const n=document.createElement("style");n.textContent="\n .neofaceid-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display:flex; align-items:center; justify-content:center; z-index: 9999; }\n .neofaceid-modal { background:#fff; border-radius:12px; width: 92%; max-width: 640px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); overflow:hidden; }\n .neofaceid-modal-header { padding: 16px 20px; border-bottom: 1px solid #eee; display:flex; align-items:center; justify-content:space-between; }\n .neofaceid-title { margin:0; font-size: 20px; color:#333; }\n .neofaceid-close-btn { background:none; border:none; font-size:24px; cursor:pointer; color:#666; }\n .neofaceid-modal-body { padding: 16px 20px; }\n .neofaceid-subtitle { margin: 0 0 12px 0; color:#666; }\n .neofaceid-camera-container { position: relative; background:#000; border-radius:8px; overflow:hidden; aspect-ratio: 4/3; margin-bottom: 12px; }\n .neofaceid-video { width:100%; height:100%; object-fit: cover; }\n .neofaceid-canvas { position:absolute; top:0; left:0; }\n .neofaceid-overlay { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; }\n .neofaceid-frame { width: 200px; height: 200px; border: 3px solid #4CAF50; border-radius: 50%; box-shadow: 0 0 0 2px rgba(76,175,80,0.3); }\n .neofaceid-countdown { position:absolute; top:16px; right:16px; background: rgba(0,0,0,0.7); color:#fff; width: 48px; height:48px; display:flex; align-items:center; justify-content:center; border-radius:50%; }\n .neofaceid-modal-footer { padding: 16px 20px; border-top: 1px solid #eee; display:flex; gap: 8px; justify-content:flex-end; }\n .neofaceid-cancel-btn { background:#f5f5f5; color:#666; border:none; border-radius:6px; padding:10px 18px; cursor:pointer; }\n .neofaceid-capture-btn { background:#4CAF50; color:#fff; border:none; border-radius:6px; padding:10px 18px; cursor:pointer; }\n .neofaceid-capture-btn:disabled { background:#ccc; cursor:not-allowed; }\n ",document.head.appendChild(n),document.body.appendChild(e),this.overlay=e,this.video=this.overlay.querySelector(".neofaceid-video"),this.canvas=this.overlay.querySelector(".neofaceid-canvas");const t=this.overlay.querySelector(".neofaceid-close-btn"),o=this.overlay.querySelector(".neofaceid-cancel-btn");t.onclick=()=>this.close(),o.onclick=()=>this.close();this.overlay.querySelector(".neofaceid-capture-btn").disabled=!0}async startCamera(){if(!this.video)throw new Error("Elemento de vídeo não encontrado");this.video.muted=!0,this.video.playsInline=!0;try{this.stream=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:{ideal:1280},height:{ideal:720}},audio:!1})}catch{this.stream=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user"},audio:!1})}this.video.srcObject=this.stream,await this.video.play()}async runFaceCaptureCountdown(){if(!this.overlay)return;const e=this.overlay.querySelector(".neofaceid-countdown"),n=this.overlay.querySelector(".neofaceid-countdown-number"),t=this.overlay.querySelector(".neofaceid-status-text");e.style.display="flex",t.textContent="Prepare-se! Capturando seu rosto...";let o=this.countdownSeconds;n.textContent=String(o),await new Promise((t=>{const a=setInterval((()=>{o-=1,n.textContent=String(o),o<=0&&(clearInterval(a),e.style.display="none",t())}),1e3)}))}async waitForUserCaptureClick(){if(!this.overlay)return;const e=this.overlay.querySelector(".neofaceid-capture-btn"),n=this.overlay.querySelector(".neofaceid-status-text");e.disabled=!1,n.textContent='Clique em "Capturar" quando o documento estiver visível',await new Promise((n=>{const t=()=>{e.removeEventListener("click",t),n()};e.addEventListener("click",t)})),e.disabled=!0}async captureFrame(){if(!this.video||!this.canvas)throw new Error("Elementos de captura não encontrados");const e=this.canvas.getContext("2d");if(!e)throw new Error("Falha ao obter contexto do canvas");this.canvas.width=this.video.videoWidth,this.canvas.height=this.video.videoHeight,e.drawImage(this.video,0,0,this.canvas.width,this.canvas.height);return await new Promise(((e,n)=>{this.canvas.toBlob((t=>t?e(t):n(new Error("Falha ao gerar imagem"))),"image/jpeg",.92)}))}updateTexts(e,n){if(!this.overlay)return;const t=this.overlay.querySelector(".neofaceid-title"),o=this.overlay.querySelector(".neofaceid-subtitle"),a=this.overlay.querySelector(".neofaceid-frame");t.textContent=e,o.textContent=n,"document"===this.step&&(a.style.borderRadius="8px",a.style.width="280px",a.style.height="180px")}async close(){this.stream&&(this.stream.getTracks().forEach((e=>e.stop())),this.stream=null),this.overlay&&(this.overlay.remove(),this.overlay=null)}}const Oe=["Olhe diretamente para a câmera","Vire levemente a cabeça para a esquerda","Vire levemente a cabeça para a direita","Mostre o polegar para cima (👍) e olhe para a câmera"],_e={RG:{name:"RG / Carteira de Identidade",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="4" width="18" height="16" rx="2"/><circle cx="9" cy="10" r="2"/><path d="M15 8h2M15 12h2M7 16h10"/></svg>',hasBack:!0,frontLabel:"Frente do RG",backLabel:"Verso do RG"},CNH:{name:"CNH / Carteira de Motorista",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="6" width="18" height="12" rx="2"/><circle cx="8" cy="12" r="2"/><path d="M13 10h5M13 14h3"/></svg>',hasBack:!0,frontLabel:"Frente da CNH",backLabel:"Verso da CNH"},CPF:{name:"CPF",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6M16 13H8M16 17H8M10 9H8"/></svg>',hasBack:!1,frontLabel:"Cartão CPF"}};class Ie{constructor(e){r(this,"overlay",null),r(this,"video",null),r(this,"canvas",null),r(this,"stream",null),r(this,"resolvePromise",null),r(this,"options"),r(this,"selectedDocument",null),r(this,"currentStep","select"),r(this,"frontBlob",null),r(this,"backBlob",null),this.options={title:(null==e?void 0:e.title)??"Validação de Identidade",subtitle:(null==e?void 0:e.subtitle)??"Selecione o tipo de documento",useBackCamera:(null==e?void 0:e.useBackCamera)??!0,onCancel:null==e?void 0:e.onCancel,preSelectedDocument:null==e?void 0:e.preSelectedDocument}}async open(){return new Promise((e=>{this.resolvePromise=e,this.options.preSelectedDocument&&(this.selectedDocument=this.options.preSelectedDocument,this.currentStep="front"),this.render()}))}render(){var e;this.overlay||this.createOverlay();const n=null==(e=this.overlay)?void 0:e.querySelector(".neoface-doc-content");if(n)switch(this.currentStep){case"select":n.innerHTML=this.renderSelectStep(),this.bindSelectEvents();break;case"front":case"back":n.innerHTML=this.renderCaptureStep(),this.bindCaptureEvents(),this.startCamera();break;case"preview-front":case"preview-back":n.innerHTML=this.renderPreviewStep(),this.bindPreviewEvents()}}createOverlay(){const e=document.createElement("div");if(e.className="neoface-doc-overlay",e.innerHTML='\n <div class="neoface-doc-modal">\n <div class="neoface-doc-content"></div>\n </div>\n ',!document.getElementById("neoface-doc-styles-v2")){const e=document.createElement("style");e.id="neoface-doc-styles-v2",e.textContent=this.getStyles(),document.head.appendChild(e)}document.body.appendChild(e),this.overlay=e}renderSelectStep(){return`\n <div class="neoface-doc-header">\n <div class="neoface-doc-header-left">\n <h2 class="neoface-doc-title">${this.options.title}</h2>\n <p class="neoface-doc-subtitle">${this.options.subtitle}</p>\n </div>\n <button class="neoface-doc-close-btn" aria-label="Fechar">\n <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M18 6L6 18M6 6l12 12"/>\n </svg>\n </button>\n </div>\n \n <div class="neoface-doc-body">\n <div class="neoface-doc-select-grid">\n ${Object.entries(_e).map((([e,n])=>`\n <button class="neoface-doc-select-option" data-type="${e}">\n <span class="neoface-doc-select-icon">${n.icon}</span>\n <span class="neoface-doc-select-name">${n.name}</span>\n <svg class="neoface-doc-select-arrow" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg>\n </button>\n `)).join("")}\n </div>\n \n <div class="neoface-doc-tips">\n <div class="neoface-doc-tip">\n <span>Garanta boa iluminação e que todos os dados estejam legíveis</span>\n </div>\n </div>\n </div>\n \n ${this.renderBranding()}\n `}renderCaptureStep(){const e=this.selectedDocument?_e[this.selectedDocument]:null;if(!e)return"";const n="back"===this.currentStep,t=n?e.backLabel:e.frontLabel;return`\n <div class="neoface-doc-header">\n <div class="neoface-doc-header-left">\n <div class="neoface-doc-step-indicator">\n <span class="neoface-doc-step-badge">${n?2:1}/${e.hasBack?2:1}</span>\n <span class="neoface-doc-step-label">${t}</span>\n </div>\n </div>\n <button class="neoface-doc-close-btn" aria-label="Fechar">\n <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M18 6L6 18M6 6l12 12"/>\n </svg>\n </button>\n </div>\n \n <div class="neoface-doc-body">\n <div class="neoface-doc-camera-container">\n <video class="neoface-doc-video" autoplay muted playsinline></video>\n <canvas class="neoface-doc-canvas"></canvas>\n \n <div class="neoface-doc-guide">\n <div class="neoface-doc-frame">\n <div class="neoface-doc-corner neoface-doc-corner-tl"></div>\n <div class="neoface-doc-corner neoface-doc-corner-tr"></div>\n <div class="neoface-doc-corner neoface-doc-corner-bl"></div>\n <div class="neoface-doc-corner neoface-doc-corner-br"></div>\n <div class="neoface-doc-frame-label">${t}</div>\n </div>\n </div>\n \n <div class="neoface-doc-loading" style="display:none">\n <div class="neoface-doc-spinner"></div>\n </div>\n </div>\n \n <div class="neoface-doc-instructions">\n <div class="neoface-doc-instruction">\n <svg class="neoface-doc-instruction-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18M9 21V9"/></svg>\n <span>Posicione o documento dentro do quadro</span>\n </div>\n <div class="neoface-doc-instruction">\n <svg class="neoface-doc-instruction-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="5"/><path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"/></svg>\n <span>Evite reflexos e sombras</span>\n </div>\n </div>\n </div>\n \n <div class="neoface-doc-footer">\n <button class="neoface-doc-btn neoface-doc-btn-secondary neoface-doc-back-btn">\n ← Voltar\n </button>\n <input type="file" accept="image/*" class="neoface-doc-file-input" style="display:none" />\n <button class="neoface-doc-btn neoface-doc-btn-secondary neoface-doc-upload-btn">\n <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>\n <polyline points="17,8 12,3 7,8"/>\n <line x1="12" y1="3" x2="12" y2="15"/>\n </svg>\n Anexar\n </button>\n <button class="neoface-doc-btn neoface-doc-btn-primary neoface-doc-capture-btn">\n <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <circle cx="12" cy="12" r="10"/>\n <circle cx="12" cy="12" r="4"/>\n </svg>\n Capturar\n </button>\n </div>\n \n ${this.renderBranding()}\n `}renderPreviewStep(){const e=this.selectedDocument?_e[this.selectedDocument]:null;if(!e)return"";const n="preview-front"===this.currentStep,t=n?e.frontLabel:e.backLabel,o=!e.hasBack||"preview-back"===this.currentStep;return`\n <div class="neoface-doc-header">\n <div class="neoface-doc-header-left">\n <div class="neoface-doc-step-indicator">\n <span class="neoface-doc-step-badge">${n?1:2}/${e.hasBack?2:1}</span>\n <span class="neoface-doc-step-label">Confirmar ${t}</span>\n </div>\n </div>\n <button class="neoface-doc-close-btn" aria-label="Fechar">\n <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M18 6L6 18M6 6l12 12"/>\n </svg>\n </button>\n </div>\n \n <div class="neoface-doc-body">\n <div class="neoface-doc-preview-single">\n <span class="neoface-doc-preview-label">${t}</span>\n <img class="neoface-doc-preview-img neoface-doc-preview-current" />\n </div>\n \n <div class="neoface-doc-preview-hint">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4M12 8h.01"/></svg>\n <span>Verifique se todos os dados estão legíveis</span>\n </div>\n </div>\n \n <div class="neoface-doc-footer">\n <button class="neoface-doc-btn neoface-doc-btn-secondary neoface-doc-retake-btn">\n <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M1 4v6h6M23 20v-6h-6"/>\n <path d="M20.49 9A9 9 0 0 0 5.64 5.64L1 10m22 4l-4.64 4.36A9 9 0 0 1 3.51 15"/>\n </svg>\n Refazer\n </button>\n <button class="neoface-doc-btn neoface-doc-btn-success neoface-doc-confirm-btn">\n <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M20 6L9 17l-5-5"/>\n </svg>\n ${o?"Confirmar e Enviar":"Próximo"}\n </button>\n </div>\n \n ${this.renderBranding()}\n `}renderBranding(){return'\n <div class="neoface-doc-branding">\n <img src="/logo-icone-no-background.png" \n alt="NeoFaceId" class="neoface-doc-brand-icon" \n onerror="this.style.display=\'none\'" />\n <span class="neoface-doc-brand-name-text">NeoFaceId</span>\n <span class="neoface-doc-brand-text">by</span>\n <span class="neoface-doc-brand-name">OCTA</span>\n </div>\n '}bindSelectEvents(){var e;const n=null==(e=this.overlay)?void 0:e.querySelectorAll(".neoface-doc-select-option");null==n||n.forEach((e=>{e.addEventListener("click",(()=>{const n=e.getAttribute("data-type");this.selectedDocument=n,this.currentStep="front",this.render()}))})),this.bindCloseEvent()}bindCaptureEvents(){var e,n,t,o;const a=null==(e=this.overlay)?void 0:e.querySelector(".neoface-doc-capture-btn"),r=null==(n=this.overlay)?void 0:n.querySelector(".neoface-doc-back-btn"),i=null==(t=this.overlay)?void 0:t.querySelector(".neoface-doc-upload-btn"),s=null==(o=this.overlay)?void 0:o.querySelector(".neoface-doc-file-input");null==a||a.addEventListener("click",(()=>this.handleCapture())),null==r||r.addEventListener("click",(()=>this.handleBack())),null==i||i.addEventListener("click",(()=>null==s?void 0:s.click())),null==s||s.addEventListener("change",(e=>this.handleFileUpload(e))),this.bindCloseEvent()}async handleFileUpload(e){var n,t;const o=null==(n=e.target.files)?void 0:n[0];if(!o)return;const a=null==(t=this.overlay)?void 0:t.querySelector(".neoface-doc-loading");a&&(a.style.display="flex");try{const e=await this.compressUploadedImage(o);"front"===this.currentStep?(this.frontBlob=e,this.currentStep="preview-front"):"back"===this.currentStep&&(this.backBlob=e,this.currentStep="preview-back"),this.stopCamera(),this.render()}catch(r){const e=new Blob([o],{type:o.type});"front"===this.currentStep?(this.frontBlob=e,this.currentStep="preview-front"):"back"===this.currentStep&&(this.backBlob=e,this.currentStep="preview-back"),this.stopCamera(),this.render()}}compressUploadedImage(e){return new Promise(((n,t)=>{const o=new Image;o.onload=()=>{const e=1280;let a=o.width,r=o.height;a>r&&a>e?(r=r*e/a,a=e):r>e&&(a=a*e/r,r=e);const i=document.createElement("canvas");i.width=a,i.height=r;const s=i.getContext("2d");s?(s.drawImage(o,0,0,a,r),i.toBlob((e=>{e?n(e):t(new Error("Failed to compress image"))}),"image/jpeg",.75)):t(new Error("Failed to get canvas context"))},o.onerror=()=>t(new Error("Failed to load image")),o.src=URL.createObjectURL(e)}))}bindPreviewEvents(){var e,n,t;const o=null==(e=this.overlay)?void 0:e.querySelector(".neoface-doc-confirm-btn"),a=null==(n=this.overlay)?void 0:n.querySelector(".neoface-doc-retake-btn");null==o||o.addEventListener("click",(()=>this.handleConfirm())),null==a||a.addEventListener("click",(()=>this.handleRetake()));const r=null==(t=this.overlay)?void 0:t.querySelector(".neoface-doc-preview-current");if(r){const e="preview-front"===this.currentStep?this.frontBlob:this.backBlob;e&&(r.src=URL.createObjectURL(e))}this.bindCloseEvent()}bindCloseEvent(){var e;const n=null==(e=this.overlay)?void 0:e.querySelector(".neoface-doc-close-btn");null==n||n.addEventListener("click",(()=>this.handleCancel()))}async startCamera(){var e,n,t;try{const t={video:{facingMode:this.options.useBackCamera?"environment":"user",width:{ideal:1920},height:{ideal:1080}},audio:!1};this.stream=await navigator.mediaDevices.getUserMedia(t),this.video=null==(e=this.overlay)?void 0:e.querySelector(".neoface-doc-video"),this.canvas=null==(n=this.overlay)?void 0:n.querySelector(".neoface-doc-canvas"),this.video&&(this.video.muted=!0,this.video.playsInline=!0,this.video.srcObject=this.stream,await this.video.play())}catch(o){if(this.options.useBackCamera)try{this.stream=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user"},audio:!1}),this.video&&(this.video.srcObject=this.stream,await this.video.play())}catch(a){null==(t=this.resolvePromise)||t.call(this,{success:!1,frontImage:null,backImage:null,error:"Não foi possível acessar a câmera"}),this.close()}}}stopCamera(){this.stream&&(this.stream.getTracks().forEach((e=>e.stop())),this.stream=null)}async handleCapture(){var e;if(!this.video||!this.canvas)return;const n=null==(e=this.overlay)?void 0:e.querySelector(".neoface-doc-loading");n&&(n.style.display="flex");const t=this.canvas.getContext("2d");if(!t)return;const o=this.video.videoWidth,a=this.video.videoHeight,r=Math.floor(.75*o),i=Math.floor(.65*a),s=Math.floor((o-r)/2),c=Math.floor((a-i)/2);this.canvas.width=r,this.canvas.height=i,t.drawImage(this.video,s,c,r,i,0,0,r,i);try{const e=await new Promise(((e,n)=>{this.canvas.toBlob((t=>t?e(t):n(new Error("Capture failed"))),"image/jpeg",.92)}));"front"===this.currentStep?(this.frontBlob=e,this.stopCamera(),this.currentStep="preview-front",this.render()):"back"===this.currentStep&&(this.backBlob=e,this.stopCamera(),this.currentStep="preview-back",this.render())}catch(d){}finally{n&&(n.style.display="none")}}handleBack(){this.stopCamera(),"back"===this.currentStep?(this.currentStep="front",this.frontBlob=null):"front"===this.currentStep&&(this.currentStep="select",this.selectedDocument=null),this.render()}handleRetake(){"preview-front"===this.currentStep?(this.frontBlob=null,this.currentStep="front"):"preview-back"===this.currentStep&&(this.backBlob=null,this.currentStep="back"),this.render()}handleConfirm(){var e,n;const t=this.selectedDocument?_e[this.selectedDocument]:null;"preview-front"===this.currentStep?(null==t?void 0:t.hasBack)?(this.currentStep="back",this.render()):(null==(e=this.resolvePromise)||e.call(this,{success:!0,documentType:this.selectedDocument||void 0,frontImage:this.frontBlob,backImage:null}),this.close()):"preview-back"===this.currentStep&&(null==(n=this.resolvePromise)||n.call(this,{success:!0,documentType:this.selectedDocument||void 0,frontImage:this.frontBlob,backImage:this.backBlob}),this.close())}handleCancel(){var e,n,t;null==(n=(e=this.options).onCancel)||n.call(e),null==(t=this.resolvePromise)||t.call(this,{success:!1,frontImage:null,backImage:null,error:"cancelled"}),this.close()}close(){this.stopCamera(),this.overlay&&(this.overlay.remove(),this.overlay=null)}getStyles(){return"\n .neoface-doc-overlay {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.85);\n backdrop-filter: blur(8px);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10000;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n padding: 16px;\n }\n \n .neoface-doc-modal {\n background: linear-gradient(145deg, #1a1a2e 0%, #16213e 100%);\n border-radius: 24px;\n width: 100%;\n max-width: 520px;\n box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255,255,255,0.1);\n overflow: hidden;\n animation: neoface-doc-slideIn 0.3s ease;\n }\n \n @keyframes neoface-doc-slideIn {\n from { transform: translateY(20px) scale(0.98); opacity: 0; }\n to { transform: translateY(0) scale(1); opacity: 1; }\n }\n \n .neoface-doc-header {\n padding: 20px 24px;\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n border-bottom: 1px solid rgba(255, 255, 255, 0.08);\n }\n \n .neoface-doc-title {\n margin: 0 0 4px 0;\n font-size: 20px;\n font-weight: 600;\n color: #fff;\n }\n \n .neoface-doc-subtitle {\n margin: 0;\n font-size: 14px;\n color: rgba(255, 255, 255, 0.6);\n }\n \n .neoface-doc-step-indicator {\n display: flex;\n align-items: center;\n gap: 12px;\n }\n \n .neoface-doc-step-badge {\n background: linear-gradient(135deg, #00c8ff, #0099cc);\n color: #fff;\n font-size: 12px;\n font-weight: 600;\n padding: 4px 10px;\n border-radius: 20px;\n }\n \n .neoface-doc-step-label {\n font-size: 16px;\n font-weight: 500;\n color: #fff;\n }\n \n .neoface-doc-close-btn {\n background: transparent;\n border: none;\n padding: 4px;\n cursor: pointer;\n color: rgba(255, 255, 255, 0.5);\n transition: all 0.2s;\n }\n \n .neoface-doc-close-btn:hover {\n color: #fff;\n }\n \n .neoface-doc-body {\n padding: 20px 24px;\n }\n \n /* Select Step */\n .neoface-doc-select-grid {\n display: flex;\n flex-direction: column;\n gap: 12px;\n }\n \n .neoface-doc-select-option {\n display: flex;\n align-items: center;\n gap: 16px;\n padding: 16px 20px;\n background: rgba(255, 255, 255, 0.05);\n border: 2px solid rgba(255, 255, 255, 0.1);\n border-radius: 14px;\n cursor: pointer;\n transition: all 0.2s;\n text-align: left;\n }\n \n .neoface-doc-select-option:hover {\n background: rgba(0, 200, 255, 0.1);\n border-color: rgba(0, 200, 255, 0.4);\n transform: translateX(4px);\n }\n \n .neoface-doc-select-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 44px;\n height: 44px;\n background: rgba(0, 200, 255, 0.15);\n border-radius: 12px;\n color: #00c8ff;\n }\n \n .neoface-doc-select-icon svg {\n width: 24px;\n height: 24px;\n }\n \n .neoface-doc-select-name {\n flex: 1;\n font-size: 15px;\n font-weight: 500;\n color: #fff;\n }\n \n .neoface-doc-select-arrow {\n color: rgba(255, 255, 255, 0.4);\n transition: transform 0.2s;\n }\n \n .neoface-doc-select-option:hover .neoface-doc-select-arrow {\n color: #00c8ff;\n transform: translateX(4px);\n }\n \n .neoface-doc-tips {\n margin-top: 20px;\n }\n \n .neoface-doc-tip {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 14px 16px;\n background: rgba(0, 200, 255, 0.08);\n border: 1px solid rgba(0, 200, 255, 0.15);\n border-radius: 10px;\n color: rgba(255, 255, 255, 0.8);\n font-size: 13px;\n line-height: 1;\n text-align: center;\n }\n \n .neoface-doc-tip span {\n transform: translateY(-2px);\n }\n \n .neoface-doc-tip-icon {\n color: #00c8ff;\n flex-shrink: 0;\n }\n \n /* Camera */\n .neoface-doc-camera-container {\n position: relative;\n background: #000;\n border-radius: 16px;\n overflow: hidden;\n aspect-ratio: 4/3;\n }\n \n .neoface-doc-video {\n width: 100%;\n height: 100%;\n object-fit: cover;\n }\n \n .neoface-doc-canvas {\n display: none;\n }\n \n .neoface-doc-guide {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n pointer-events: none;\n }\n \n .neoface-doc-frame {\n width: 75%;\n height: 65%;\n position: relative;\n border: 2px dashed rgba(0, 200, 255, 0.5);\n border-radius: 12px;\n background: rgba(0, 200, 255, 0.03);\n }\n \n .neoface-doc-corner {\n position: absolute;\n width: 28px;\n height: 28px;\n border-color: #00c8ff;\n border-style: solid;\n }\n \n .neoface-doc-corner-tl { top: -2px; left: -2px; border-width: 4px 0 0 4px; border-radius: 10px 0 0 0; }\n .neoface-doc-corner-tr { top: -2px; right: -2px; border-width: 4px 4px 0 0; border-radius: 0 10px 0 0; }\n .neoface-doc-corner-bl { bottom: -2px; left: -2px; border-width: 0 0 4px 4px; border-radius: 0 0 0 10px; }\n .neoface-doc-corner-br { bottom: -2px; right: -2px; border-width: 0 4px 4px 0; border-radius: 0 0 10px 0; }\n \n .neoface-doc-frame-label {\n position: absolute;\n bottom: -30px;\n left: 50%;\n transform: translateX(-50%);\n background: rgba(0, 0, 0, 0.7);\n color: #00c8ff;\n font-size: 12px;\n font-weight: 500;\n padding: 6px 14px;\n border-radius: 20px;\n white-space: nowrap;\n }\n \n .neoface-doc-loading {\n position: absolute;\n inset: 0;\n background: rgba(0, 0, 0, 0.7);\n display: none;\n align-items: center;\n justify-content: center;\n }\n \n .neoface-doc-spinner {\n width: 48px;\n height: 48px;\n border: 4px solid rgba(255, 255, 255, 0.2);\n border-top-color: #00c8ff;\n border-radius: 50%;\n animation: neoface-doc-spin 0.8s linear infinite;\n }\n \n @keyframes neoface-doc-spin {\n to { transform: rotate(360deg); }\n }\n \n .neoface-doc-instructions {\n display: flex;\n flex-direction: column;\n gap: 8px;\n margin-top: 16px;\n }\n \n .neoface-doc-instruction {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 10px 14px;\n background: rgba(255, 255, 255, 0.04);\n border-radius: 10px;\n font-size: 13px;\n color: rgba(255, 255, 255, 0.75);\n }\n \n .neoface-doc-instruction-icon {\n color: rgba(255, 255, 255, 0.5);\n flex-shrink: 0;\n }\n \n /* Preview */\n .neoface-doc-preview-single {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 12px;\n }\n \n .neoface-doc-preview-label {\n font-size: 12px;\n font-weight: 500;\n color: rgba(255, 255, 255, 0.6);\n text-transform: uppercase;\n letter-spacing: 0.5px;\n text-align: center;\n }\n \n .neoface-doc-preview-img {\n width: 75%;\n height: auto;\n border-radius: 12px;\n border: 2px solid rgba(0, 200, 255, 0.3);\n box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);\n }\n \n .neoface-doc-preview-hint {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 12px 16px;\n background: rgba(0, 200, 255, 0.08);\n border: 1px solid rgba(0, 200, 255, 0.15);\n border-radius: 10px;\n font-size: 13px;\n color: rgba(255, 255, 255, 0.8);\n margin-top: 8px;\n }\n \n .neoface-doc-preview-hint svg {\n color: #00c8ff;\n flex-shrink: 0;\n }\n \n /* Footer */\n .neoface-doc-footer {\n padding: 16px 24px;\n display: flex;\n gap: 12px;\n justify-content: flex-end;\n border-top: 1px solid rgba(255, 255, 255, 0.08);\n }\n \n .neoface-doc-btn {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 12px 20px;\n border-radius: 12px;\n font-size: 14px;\n font-weight: 500;\n cursor: pointer;\n transition: all 0.2s;\n border: none;\n }\n \n .neoface-doc-btn-primary {\n background: linear-gradient(135deg, #00c8ff 0%, #0099cc 100%);\n color: #fff;\n }\n \n .neoface-doc-btn-primary:hover {\n transform: translateY(-2px);\n box-shadow: 0 6px 20px rgba(0, 200, 255, 0.4);\n }\n \n .neoface-doc-btn-success {\n background: linear-gradient(135deg, #10b981 0%, #059669 100%);\n color: #fff;\n }\n \n .neoface-doc-btn-success:hover {\n transform: translateY(-2px);\n box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);\n }\n \n .neoface-doc-btn-secondary {\n background: rgba(255, 255, 255, 0.08);\n color: rgba(255, 255, 255, 0.8);\n }\n \n .neoface-doc-btn-secondary:hover {\n background: rgba(255, 255, 255, 0.12);\n color: #fff;\n }\n \n /* Branding */\n .neoface-doc-branding {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 16px 24px;\n border-top: 1px solid rgba(255, 255, 255, 0.06);\n }\n \n .neoface-doc-brand-icon {\n height: 22px;\n width: auto;\n }\n \n .neoface-doc-brand-name-text {\n font-size: 13px;\n font-weight: 600;\n color: rgba(255, 255, 255, 0.9);\n }\n \n .neoface-doc-brand-text {\n font-size: 12px;\n color: rgba(255, 255, 255, 0.5);\n }\n \n .neoface-doc-brand-name {\n font-size: 13px;\n font-weight: 700;\n color: #00c8ff;\n letter-spacing: 1px;\n }\n \n /* Mobile */\n @media (max-width: 500px) {\n .neoface-doc-modal {\n border-radius: 20px;\n }\n \n .neoface-doc-header,\n .neoface-doc-body,\n .neoface-doc-footer {\n padding: 16px 18px;\n }\n \n .neoface-doc-preview-grid.has-back {\n grid-template-columns: 1fr;\n }\n }\n "}}const Se=async e=>new Ie(e).open(),Ne=Object.freeze(Object.defineProperty({__proto__:null,DocumentCaptureModal:Ie,startDocumentCapture:Se},Symbol.toStringTag,{value:"Module"}));e.BiometricCaptureModal=re,e.BiometricRegistrationModal=ae,e.BiometricStatusOverlay=ie,e.DocumentCaptureModal=Ie,e.ENVIRONMENT_URLS=O,e.EmailPasswordModal=de,e.ErrorType=R,e.FaceCaptureModal=K,e.FallbackPrompt=ce,e.NeoFaceError=k,e.NeoFaceID=class{constructor(e){if(r(this,"appToken"),r(this,"signature"),r(this,"sessionData"),this.appToken=e.appToken,this.signature=e.signature,this.sessionData=e.sessionData,this.signature&&!this.validateSignatureFormat(this.signature))throw new k("Invalid signature format. Expected HMAC-SHA256 hex string (minimum 64 characters)",R.VALIDATION_ERROR);if(this.sessionData&&(!this.sessionData.email||!this.sessionData.cpf||!this.sessionData.sessionId))throw new k("Session data must include email, cpf, and sessionId",R.VALIDATION_ERROR)}validateSignatureFormat(e){return/^[a-f0-9]{64,}$/i.test(e)}async captureFaceFrames(e){const{numFrames:n,livenessCheck:t}=e;if(n<1||n>10)throw new k("Number of frames must be between 1 and 10",R.VALIDATION_ERROR);const o=[];try{const{captureFaceSilently:e}=await Promise.resolve().then((()=>me));for(let a=0;a<n;a++){const r=await e();o.push(r),t&&a<n-1&&await new Promise((e=>setTimeout(e,300)))}return o}catch(a){if(a instanceof k)throw a;throw new k(`Failed to capture face frames: ${a instanceof Error?a.message:"Unknown error"}`,R.CAPTURE_ERROR)}}async loginRecognition(e){const{biometricData:n,purpose:t,confidenceThreshold:o=.8}=e,a=Array.isArray(n)?n:[n];if(0===a.length)throw new k("At least one biometric data frame is required",R.VALIDATION_ERROR);const r=a[0];try{const e=await M(r,this.appToken,t,o,this.signature,this.sessionData);if(!e.success)throw new k("Recognition failed",R.RECOGNITION_FAILED);if(!e.personName||!e.email||!e.cpf)throw new k("Incomplete recognition result: missing personName, email, or cpf",R.RECOGNITION_FAILED);return{success:!0,personName:e.personName,email:e.email,cpf:e.cpf,signature:e.signature,sessionId:e.sessionId,confidenceScore:e.confidenceScore,accessToken:e.accessToken}}catch(i){if(i instanceof k)throw i;throw new k(`Login recognition failed: ${i instanceof Error?i.message:"Unknown error"}`,R.RECOGNITION_FAILED)}}async registerApplication(e,n,t){try{const o=await(async(e,n,t)=>{N();const o=C();try{const r=await fetch(`${S()}/api/v1/applications/`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({consumer:n,application_name:t.applicationName,domain:t.domain,accept_only_email_with_same_domain:t.acceptOnlyEmailWithSameDomain}),signal:o.signal});if(!r.ok){if(401===r.status)throw new k("Invalid or expired JWT token",R.INVALID_TOKEN);if(403===r.status)throw new k("Insufficient permissions to create application",R.INVALID_TOKEN);if(400===r.status)try{const e=await r.json(),n=e.message||e.error||"Invalid application data";throw new k(n,R.VALIDATION_ERROR)}catch(a){if(a instanceof k)throw a;throw new k("Invalid application data",R.VALIDATION_ERROR)}throw new k(`Server returned status ${r.status}`,R.NETWORK)}const i=await r.json();return{success:!0,application:{id:i.id,application_name:i.application_name,domain:i.domain,accept_only_email_with_same_domain:i.accept_only_email_with_same_domain,app_token:i.app_token,is_active:i.is_active,created_at:i.created_at},message:"Application registered successfully"}}catch(r){if(r instanceof Error){if("AbortError"===r.name)throw new k("Request timed out",R.NETWORK);if(r instanceof k)throw r;throw new k(r.message,R.NETWORK)}throw new k("Unknown error occurred",R.NETWORK_ERROR)}})(e,n,t);return o}catch(o){if(o instanceof k)throw o;throw new k(`Application registration failed: ${o instanceof Error?o.message:"Unknown error"}`,R.VALIDATION_ERROR)}}async registerDocumentByImage(e,n,t={}){const{DocumentCaptureModal:o}=await Promise.resolve().then((()=>Ne)),a=new o({useBackCamera:t.useBackCamera??!0,preSelectedDocument:t.preSelectedDocument}),r=await a.open();if(!r.success||!r.frontImage)throw new k("cancelled"===r.error?"Document capture was cancelled by the user":`Document capture failed: ${r.error??"unknown error"}`,R.CAPTURE_ERROR);const i=[r.frontImage];return r.backImage&&i.push(r.backImage),q(e,n,i)}async proofOfLife(e={}){const{videoDurationMs:n=3e3,maxPollingAttempts:t=60,pollingIntervalMs:o=1e3,onRecordingProgress:a,onTaskStatusChange:r}=e;try{const e=await $({durationMs:n,onProgress:a}),i=await(async e=>new Promise(((n,t)=>{const o=new FileReader;o.onload=()=>{const e=o.result,t=e.includes(",")?e.split(",")[1]:e;n(t)},o.onerror=()=>t(new k("Failed to convert video to base64",R.CAPTURE_ERROR)),o.readAsDataURL(e)})))(e),s=await(async(e,n)=>{var t;N();const o=C();try{const a=await fetch(`${S()}/api/v1/auth/recognition/face/external/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({video:e,purpose:"PROOF_OF_LIFE"}),signal:o.signal});if(!a.ok){if(401===a.status||403===a.status)throw new k("Invalid or expired application token",R.INVALID_TOKEN);if(400===a.status){const e=await a.json();throw new k(e.message||"Invalid request data",R.VALIDATION_ERROR)}throw new k(`Server returned status ${a.status}`,R.NETWORK)}const r=await a.json();if(!r.success||!(null==(t=r.data)?void 0:t.task_id))throw new k(r.message||"Failed to start proof of life",R.RECOGNITION_FAILED);return{taskId:r.data.task_id,historyId:r.data.history_id,status:r.data.status,message:r.message||"Recognition started successfully"}}catch(a){if(a instanceof Error){if("AbortError"===a.name)throw new k("Request timed out",R.NETWORK);if(a instanceof k)throw a;throw new k(a.message,R.NETWORK)}throw new k("Unknown error occurred",R.NETWORK_ERROR)}})(i,this.appToken);r&&r("processing",0);const c=await(async(e,n,t={})=>{var o,a,r,i,s,c;const{maxAttempts:d=60,intervalMs:l=1e3,onStatusChange:u}=t;let p=0;for(;p<d;){p++;try{const t=await fetch(`${S()}/api/v1/tasks/status/?task_id=${e}`,{method:"GET",headers:{Accept:"application/json","X-App-Token":n}});if(!t.ok)throw new k(`Task status check failed: ${t.status}`,R.NETWORK);const d=await t.json(),p=(null==(o=d.data)?void 0:o.status)||"unknown";if(u&&u(p,null==(r=null==(a=d.data)?void 0:a.progress)?void 0:r.percentage),"success"===p)return d.data.result;if("failure"===p){const e=(null==(s=null==(i=d.data)?void 0:i.result)?void 0:s.message)||(null==(c=d.data)?void 0:c.error)||"Task failed";throw new k(e,R.RECOGNITION_FAILED)}if("revoked"===p)throw new k("Task was cancelled",R.RECOGNITION_FAILED);await new Promise((e=>setTimeout(e,l)))}catch(f){if(f instanceof k)throw f;throw new k(`Polling error: ${f instanceof Error?f.message:"Unknown error"}`,R.NETWORK)}}throw new k("Task status polling timed out",R.NETWORK)})(s.taskId,this.appToken,{maxAttempts:t,intervalMs:o,onStatusChange:r});return c&&c.success?{success:!0,isLive:c.is_live||!1,livenessScore:c.liveness_score||0,faceRecognitionScore:c.face_recognition_score||0,combinedConfidence:c.combined_confidence||0,personId:c.person_id,personalData:c.personal_data||[],processingTime:c.processing_time||0,historyId:s.historyId,taskId:s.taskId,message:"Proof of life verification successful"}:{success:!1,isLive:(null==c?void 0:c.is_live)||!1,livenessScore:(null==c?void 0:c.liveness_score)||0,faceRecognitionScore:(null==c?void 0:c.face_recognition_score)||0,combinedConfidence:(null==c?void 0:c.combined_confidence)||0,personId:null==c?void 0:c.person_id,personalData:(null==c?void 0:c.personal_data)||[],processingTime:(null==c?void 0:c.processing_time)||0,historyId:s.historyId,taskId:s.taskId,error:(null==c?void 0:c.error)||"Verification failed",message:(null==c?void 0:c.message)||"Proof of life verification failed"}}catch(i){if(i instanceof k)throw i;throw new k(`Proof of life failed: ${i instanceof Error?i.message:"Unknown error"}`,R.RECOGNITION_FAILED)}}},e.RELEASE_DATE="2026-03-04",e.VERSION="1.15.2",e.authorizeOperation=async(e,n,t)=>{if(!e)throw new k("Application token is required",R.VALIDATION_ERROR);if(!n)throw new k("CPF is required",R.VALIDATION_ERROR);const o=n.replace(/\D/g,"");if(11!==o.length)throw new k("Invalid CPF format",R.VALIDATION_ERROR);const a=[],r=(null==t?void 0:t.captureDelay)||2e3;try{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new k("Camera not available",R.NO_CAMERA);const n=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:{ideal:1280},height:{ideal:720}}}),i=document.createElement("video");i.srcObject=n,i.autoplay=!0,i.playsInline=!0,await new Promise((e=>{i.onloadedmetadata=()=>{i.play(),e()}}));const s=document.createElement("canvas");s.width=i.videoWidth,s.height=i.videoHeight;const c=s.getContext("2d");if(!c)throw new k("Failed to get canvas context",R.CAPTURE_ERROR);for(let e=0;e<4;e++){const n=Oe[e];(null==t?void 0:t.onProgress)&&t.onProgress(e+1,4,n),e>0&&await new Promise((e=>setTimeout(e,r))),c.drawImage(i,0,0,s.width,s.height);const o=await new Promise(((e,n)=>{s.toBlob((t=>{t?e(t):n(new Error("Failed to capture photo"))}),"image/jpeg",.9)}));a.push(o),(null==t?void 0:t.onPhotoTaken)&&t.onPhotoTaken(e+1,o)}n.getTracks().forEach((e=>e.stop()));const d=a[3],l={cpf:o,email:"",sessionId:`auth_${Date.now()}_${Math.random().toString(36).substring(7)}`},u=await M(d,e,"AUTHORIZATION",.8,void 0,l);if(!u.success)throw new k("Authorization failed: Person not recognized",R.RECOGNITION_FAILED);return{success:!0,authorizationHash:l.sessionId,name:u.personName,birthDate:void 0,cpf:u.cpf||o,confidenceScore:u.confidenceScore,message:"Authorization successful"}}catch(i){if(i instanceof k)throw i;if(i instanceof Error)throw new k(i.message,R.CAPTURE_ERROR);throw new k("Unknown error during authorization",R.UNKNOWN)}},e.biometricLogin=function(e,n="auto"){return new Promise(((t,o)=>{const a={applicationToken:e,onSuccess:t,onError:o};switch(n){case"face":ge(a);break;case"hand":be(a);break;case"auto":we(a);break;default:o(new k("Modo de login inválido",R.VALIDATION_ERROR))}}))},e.biometricLoginWithFallback=function(e,n="auto"){return new Promise(((t,o)=>{const a={applicationToken:e,onSuccess:t,onError:n=>{if(n.type===R.LOGIN_FAILED){new de({applicationToken:e,onSuccess:t,onError:o,title:"Login Alternativo",subtitle:"Biometria não reconhecida. Por favor, informe email e senha."}).open()}else o(n)}};switch(n){case"face":ge(a);break;case"hand":be(a);break;case"auto":we(a);break;default:o(new k("Modo de login inválido",R.VALIDATION_ERROR))}}))},e.completeOnboarding=D,e.completeOnboardingWithData=async(e,n,t,o,a)=>{if(N(),!o||0===o.length)throw new k("Pelo menos uma imagem da pessoa é obrigatória",R.VALIDATION_ERROR);const r=C();try{const i=await Promise.all(o.map((e=>A(e)))),s=await A(a),c=new FormData;i.forEach(((e,n)=>{c.append("person_images",e,`person_${n+1}.jpg`)})),c.append("document_image",s,"document.jpg"),t.name&&c.append("name",t.name),t.birth_date&&c.append("birth_date",t.birth_date),t.cpf&&c.append("cpf",t.cpf),t.cnpj&&c.append("cnpj",t.cnpj),t.email&&c.append("email",t.email);const d=await fetch(`${S()}/api/v1/onboardings/${encodeURIComponent(n)}/complete`,{method:"POST",headers:{"X-App-Token":e},body:c,signal:r.signal}),l=await d.json();if(!d.ok){if(401===d.status||403===d.status)throw new k("Token de aplicação inválido ou expirado",R.INVALID_TOKEN);if(404===d.status)throw new k("Link de onboarding não encontrado",R.NOT_FOUND);throw new k((null==l?void 0:l.error)||(null==l?void 0:l.message)||"Falha ao concluir onboarding",R.NETWORK)}return{success:!!l.success,message:l.message||"Onboarding concluído com sucesso",person_id:l.person_id,identity_data_id:l.identity_data_id,confidence_score:l.confidence_score,processing_time:l.processing_time,liveness_passed:l.liveness_passed,document_verified:l.document_verified,person_created:l.person_created}}catch(i){if(i instanceof Error){if("AbortError"===i.name)throw new k("Tempo de requisição excedido",R.NETWORK);if(i instanceof k)throw i;throw new k(i.message,R.NETWORK)}throw new k("Erro desconhecido",R.NETWORK_ERROR)}},e.detectBiometricType=ve,e.getApplicationToken=function(){return _.applicationToken},e.getBaseUrl=I,e.getConfig=function(){return{..._}},e.getEnvironment=function(){return _.environment},e.identifyPerson=async(e,n)=>{var t,o;N();const a=C(),r=await A(e),i=await new Promise(((e,n)=>{const t=new FileReader;t.onload=()=>{const n=t.result;e(n.split(",")[1])},t.onerror=n,t.readAsDataURL(r)}));try{const e=await fetch(`${S()}/api/v1/external/recognition/face/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({image:i,purpose:"SIMPLE_IDENTIFICATION_F"}),signal:a.signal});if(!e.ok){if(401===e.status||403===e.status)throw new k("Invalid or expired application token",R.INVALID_TOKEN);throw new k(`Server returned status ${e.status}`,R.NETWORK)}const r=await e.json();if(!r.success)throw new k(r.message||"Person identification failed",R.RECOGNITION_FAILED);const s=(null==(t=r.person)?void 0:t.name)||"",c=null==(o=r.person)?void 0:o.birth_date;if(!s)throw new k("Person name not found in response",R.PERSON_NOT_FOUND);if(!c)throw new k("Birth date not found in response",R.PERSON_NOT_FOUND);const d=new Date(c),l=new Date;let u=l.getFullYear()-d.getFullYear();const p=l.getMonth()-d.getMonth();return(p<0||0===p&&l.getDate()<d.getDate())&&u--,{name:s,age:u}}catch(s){if(s instanceof Error){if("AbortError"===s.name)throw new k("Request timed out",R.NETWORK);if(s instanceof k)throw s;throw new k(s.message,R.NETWORK)}throw new k("Unknown error occurred",R.NETWORK_ERROR)}},e.init=function(e={}){const{environment:n,baseUrl:t,applicationToken:o}=e;if(t)_.baseUrl=t,_.environment="custom";else if(n)O[n]?(_.baseUrl=O[n],_.environment=n):(_.baseUrl=O.sandbox,_.environment="sandbox");else{const e=void 0!=={url:"undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:i&&"SCRIPT"===i.tagName.toUpperCase()&&i.src||new URL("neoface-id-sdk.umd.js",document.baseURI).href}&&(null==T?void 0:T.VITE_API_BASE_URL);e&&(_.baseUrl=e,_.environment="custom")}o&&(_.applicationToken=o),_.initialized=!0},e.initializeBiometricDetection=Ee,e.isAdvancedDetectionAvailable=Re,e.isInitialized=function(){return _.initialized},e.loginWithBiometric=F,e.loginWithEmail=B,e.preloadFaceDetectionModels=pe,e.recognize=L,e.recognizeBiometric=async(e,n,t=!0,o=.8)=>{N();const a=C(),r=await A(e);try{const e=new FormData;e.append("face_frames",r),e.append("liveness_check",t.toString()),e.append("confidence_threshold",o.toString());const i=await fetch(`${S()}/api/v1/external/recognition/biometric/`,{method:"POST",headers:{"X-App-Token":n},body:e,signal:a.signal});if(!i.ok){if(401===i.status||403===i.status)throw new k("Invalid or expired application token",R.INVALID_TOKEN);throw new k(`Server returned status ${i.status}`,R.NETWORK)}const s=await i.json();return{success:s.success,confidenceScore:s.confidence_score,accessToken:s.access_token,payload:s.payload}}catch(i){if(i instanceof Error){if("AbortError"===i.name)throw new k("Request timed out",R.NETWORK);if(i instanceof k)throw i;throw new k(i.message,R.NETWORK)}throw new k("Unknown error occurred",R.NETWORK_ERROR)}},e.recognizeByPurpose=M,e.registerBiometric=async(e,n,t)=>{if(N(),!e)throw new k("Person ID is required",R.VALIDATION_ERROR);if(!n)throw new k("Face image is required",R.VALIDATION_ERROR);const o=C(),a=await A(n),r=await new Promise(((e,n)=>{const t=new FileReader;t.onload=()=>{const n=t.result;e(n.split(",")[1])},t.onerror=n,t.readAsDataURL(a)}));try{const n=await fetch(`${S()}/api/v1/identity-data/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":t},body:JSON.stringify({person:e,type_of_identification:"FACE",biometric_data:r}),signal:o.signal});if(!n.ok){if(401===n.status||403===n.status)throw new k("Invalid or expired application token, or insufficient permissions",R.INVALID_TOKEN);if(400===n.status)try{const e=await n.json(),t=e.message||e.error||"Invalid biometric data";throw new k(t,R.VALIDATION_ERROR)}catch(i){if(i instanceof k)throw i;throw new k("Invalid biometric data",R.VALIDATION_ERROR)}throw new k(`Server returned status ${n.status}`,R.NETWORK)}const a=await n.json();return{success:!0,message:"Biometric data registered successfully",identity_data_id:a.id,type_of_identification:a.type_of_identification,have_biometric_data:a.have_biometric_data,created_at:a.created_at}}catch(s){if(s instanceof Error){if("AbortError"===s.name)throw new k("Request timed out",R.NETWORK);if(s instanceof k)throw s;throw new k(s.message,R.NETWORK)}throw new k("Unknown error occurred",R.NETWORK_ERROR)}},e.registerPersonWithBiometric=U,e.registerPersonWithoutFace=async(e,n,t)=>{N();const o=C();try{let a,r;if(null==t?void 0:t.documentFront){const e=await j(t.documentFront);a=await new Promise(((n,t)=>{const o=new FileReader;o.onload=()=>n(o.result),o.onerror=t,o.readAsDataURL(e)}))}if(null==t?void 0:t.documentBack){const e=await j(t.documentBack);r=await new Promise(((n,t)=>{const o=new FileReader;o.onload=()=>n(o.result),o.onerror=t,o.readAsDataURL(e)}))}const i={name:e.name,birth_date:e.birth_date,cpf:e.cpf,email:e.email,password:e.password,password_confirm:e.password};a&&(i.document_images=[{front:a,back:r||void 0,type:(null==t?void 0:t.documentType)||"RG"}]);const s=await fetch(`${S()}/api/v1/signup/donor/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify(i),signal:o.signal});if(!s.ok){if(401===s.status||403===s.status)throw new k("Invalid or expired application token",R.INVALID_TOKEN);throw new k(`Server returned status ${s.status}`,R.NETWORK)}return await s.json()}catch(a){if(a instanceof Error){if("AbortError"===a.name)throw new k("Request timed out",R.NETWORK);if(a instanceof k)throw a;throw new k(a.message,R.NETWORK)}throw new k("Unknown error occurred",R.NETWORK)}},e.simpleIdentification=async(e,n,t,o="LOGIN")=>{N();const a=C();try{const r=await fetch(`${S()}/api/v1/external/recognition/simple/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":t},body:JSON.stringify({document_type:e,document_number:n,purpose:o}),signal:a.signal});if(!r.ok){if(401===r.status||403===r.status)throw new k("Invalid or expired application token",R.INVALID_TOKEN);throw new k(`Server returned status ${r.status}`,R.NETWORK)}const i=await r.json();if(!i.success)throw new k(i.message||"Identification failed",R.RECOGNITION_FAILED);return{success:i.success,personId:i.person_id,accessToken:i.access_token,payload:i.payload}}catch(r){if(r instanceof Error){if("AbortError"===r.name)throw new k("Request timed out",R.NETWORK);if(r instanceof k)throw r;throw new k(r.message,R.NETWORK)}throw new k("Unknown error occurred",R.NETWORK_ERROR)}},e.start=function(e,t){const o=document.createElement("div");o.id="neoface-modal-container",document.body.appendChild(o);const a=()=>{document.body.contains(o)&&document.body.removeChild(o)};P(e).then((()=>{const r=n.createElement(K,{accessToken:e,onClose:a,onSuccess:e=>{a(),t.onSuccess({name:e.data.faceId,email:e.data.faceId,documentId:e.data.faceId})}});p.createRoot(o).render(r)})).catch((e=>{a(),t.onError("TOKEN_VALIDATION_ERROR",e.message||"Failed to validate token")}))},e.startAutoLogin=we,e.startBiometricRegistration=function(e,t,o,a){const r=document.createElement("div");r.id="neoface-biometric-registration-container",document.body.appendChild(r);let i=null;const s=()=>{i&&(i.unmount(),i=null),document.body.contains(r)&&document.body.removeChild(r)};P(t).then((()=>{const c=n.createElement(ae,{personData:e,applicationToken:t,useRealApi:(null==a?void 0:a.useRealApi)??!0,onClose:s,onSuccess:e=>{s(),o.onSuccess(e)},onError:e=>{s(),o.onError("BIOMETRIC_REGISTRATION_ERROR",e)}});i=p.createRoot(r),i.render(c)})).catch((e=>{s(),o.onError("TOKEN_VALIDATION_ERROR",e.message||"Failed to validate token")}))},e.startDocumentCapture=Se,e.startFaceLogin=ge,e.startHandLogin=be,e.startLivenessCapture=function(e,t){const o=document.createElement("div");o.id="neoface-liveness-capture-container",document.body.appendChild(o);let a=!1,r=null;const i=()=>{r&&(r.unmount(),r=null),document.body.contains(o)&&document.body.removeChild(o)},s=()=>{i(),!a&&t.onCancel&&t.onCancel()};P(e).then((()=>{const c=n.createElement(ae,{applicationToken:e,onClose:s,onPhotosCaptured:e=>{a=!0,t.onSuccess(e)},onError:e=>{i(),t.onError("LIVENESS_CAPTURE_ERROR",e)}});r=p.createRoot(o),r.render(c)})).catch((e=>{i(),t.onError("TOKEN_VALIDATION_ERROR",e.message||"Failed to validate token")}))},e.startOnboarding=async e=>{const{applicationToken:n,onboardingToken:t,countdown:o,title:a,subtitle:r,onSuccess:i,onError:s}=e;try{const e=await(async(e,n)=>{N();const t=C();try{const o=await fetch(`${S()}/api/v1/onboardings/${encodeURIComponent(n)}/`,{method:"GET",headers:{"X-App-Token":e},signal:t.signal});if(!o.ok){if(401===o.status||403===o.status)throw new k("Token de aplicação inválido ou expirado",R.INVALID_TOKEN);if(404===o.status)throw new k("Link de onboarding não encontrado",R.NOT_FOUND);throw new k(`Falha ao obter detalhes (${o.status})`,R.NETWORK)}return await o.json()}catch(o){if(o instanceof Error){if("AbortError"===o.name)throw new k("Tempo de requisição excedido",R.NETWORK);if(o instanceof k)throw o;throw new k(o.message,R.NETWORK)}throw new k("Erro desconhecido",R.NETWORK_ERROR)}})(n,t);if(!(null==e?void 0:e.is_valid))throw new k("Link de onboarding inválido ou expirado",R.VALIDATION_ERROR);const s=new Te({countdown:o,title:a,subtitle:r}),{face:c,document:d}=await s.open();i({...await D(n,t,c,d),details:e})}catch(c){if(c instanceof k)return void s(c);const e=(null==c?void 0:c.message)||"Erro desconhecido no onboarding";s(new k(e,R.UNKNOWN))}},e.validateOnboardingToken=async(e,n)=>{N();const t=C();try{const o=await fetch(`${S()}/api/v1/onboardings/${encodeURIComponent(n)}/`,{method:"GET",headers:{"X-App-Token":e},signal:t.signal});if(!o.ok){if(401===o.status||403===o.status)throw new k("Token de aplicação inválido ou expirado",R.INVALID_TOKEN);if(404===o.status)return!1;throw new k(`Falha ao validar token (${o.status})`,R.NETWORK)}const a=await o.json();return!0===(null==a?void 0:a.is_valid)}catch(o){if(o instanceof Error){if("AbortError"===o.name)throw new k("Tempo de requisição excedido",R.NETWORK);if(o instanceof k)throw o;throw new k(o.message,R.NETWORK)}throw new k("Erro desconhecido",R.NETWORK_ERROR)}},e.validateToken=P,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
|
|
11
11
|
//# sourceMappingURL=neoface-id-sdk.umd.js.map
|