@neofaceid/web-sdk 1.9.0 → 1.10.0
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);function
|
|
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 b(){return h||(h=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 b=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=b.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,k,R,T,_,O,S,I=Object.assign,N=0;function C(){}C.__reactDisabledLog=!0;var A,j=b.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,k=console.info,R=console.warn,T=console.error,_=console.group,O=console.groupCollapsed,S=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:I({},e,{value:E}),info:I({},e,{value:k}),warn:I({},e,{value:R}),error:I({},e,{value:T}),group:I({},e,{value:_}),groupCollapsed:I({},e,{value:O}),groupEnd:I({},e,{value:S})})}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,W={},$=b.ReactDebugCurrentFrame;function q(e){if(e){var n=e._owner,t=U(e.type,e._source,n?n.type:null);$.setExtraStackFrame(t)}else $.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 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 H,X,Y=b.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(B.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(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(){H||(H=!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=b.ReactCurrentOwner,ne=b.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||(q(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),q(null)),s instanceof Error&&!(s.message in W)&&(W[s.message]=!0,q(a),w("Failed %s type: %s",t,s.message),q(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 k;E+=ae(),null===e?k="null":K(e)?k="array":void 0!==e&&e.$$typeof===t?(k="<"+(x(e.type)||"Unknown")+" />",E=" Did you accidentally export a JSX literal instead of a component?"):k=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",k,E)}var R=Z(e,n,o,g,b);if(null==R)return R;if(y){var T=n.children;if(void 0!==T)if(m)if(K(T)){for(var _=0;_<T.length;_++)se(T[_],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 O=x(e),S=Object.keys(n).filter((function(e){return"key"!==e})),I=S.length>0?"{key: someKey, "+S.join(": ..., ")+": ...}":"{key: someKey}";if(!de[O+I])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} />',I,O,S.length>0?"{"+S.join(": ..., ")+": ...}":"{}",O),de[O+I]=!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))}(R):ce(R),R}var ue=function(e,n,t){return le(e,n,t,!1)},pe=function(e,n,t){return le(e,n,t,!0)};g.Fragment=a,g.jsx=ue,g.jsxs=pe}()),g}var w=(m||(m=1,"production"===process.env.NODE_ENV?p.exports=function(){if(l)return f;l=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 f.Fragment=o,f.jsx=s,f.jsxs=s,f}():p.exports=b()),p.exports);class v extends Error{constructor(e){super(e),this.name="CameraPermissionDenied"}}class y{constructor(e){r(this,"stream"),this.stream=e}getStream(){return this.stream}stop(){this.stream.getTracks().forEach((e=>e.stop()))}}const x=()=>{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 y(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 v("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 E=(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))(E||{});class k extends Error{constructor(e,n){super(e),r(this,"type"),this.name=n,this.type=n}}const R={},T=null==R?void 0:R.VITE_API_BASE_URL,_=()=>{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",E.NETWORK)},O=()=>{const e=new AbortController,n=setTimeout((()=>e.abort()),1e4);return e.signal.addEventListener("abort",(()=>clearTimeout(n))),e},S=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)})),I=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)})),N=async e=>{_();const n=O();try{return(await fetch(`${T}/api/v1/auth/application/validate_token/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":e},body:JSON.stringify({}),signal:n.signal})).ok}catch(t){if(t instanceof Error){if("AbortError"===t.name)throw new k("Request timed out",E.NETWORK_ERROR);throw new k(t.message,E.NETWORK_ERROR)}throw new k("Unknown error occurred",E.NETWORK_ERROR)}},C=async(e,n,t,o)=>{_();const a=O(),r=await S(t),i=await S(o);try{const t=new FormData;t.append("face_image",r,"face.jpg"),t.append("document_image",i,"document.jpg");const o=await fetch(`${T}/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",E.INVALID_TOKEN);if(404===o.status)throw new k("Link de onboarding não encontrado",E.NOT_FOUND);throw new k((null==s?void 0:s.error)||(null==s?void 0:s.message)||"Falha ao concluir onboarding",E.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",E.NETWORK);if(s instanceof k)throw s;throw new k(s.message,E.NETWORK)}throw new k("Erro desconhecido",E.NETWORK_ERROR)}},A=async(e,n)=>{_();const t=O(),o=await S(e);try{const e=new FormData;e.append("face_frames",o);const a=await fetch(`${T}/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",E.INVALID_TOKEN);throw new k(`Server returned status ${a.status}`,E.NETWORK)}const r=await a.json();if(!r.success)throw new k(r.message||"Recognition failed",E.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",E.NETWORK);if(a instanceof k)throw a;throw new k(a.message,E.NETWORK)}throw new k("Unknown error occurred",E.NETWORK_ERROR)}},j=async(e,n)=>{var t,o,a,r,i;_();const s=O(),c=await S(e);try{const e=await c.arrayBuffer(),d=btoa(new Uint8Array(e).reduce(((e,n)=>e+String.fromCharCode(n)),"")),l=await fetch(`${T}/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 or expired application token",E.INVALID_TOKEN);throw new k(`Server returned status ${l.status}`,E.NETWORK)}const u=await l.json();if(!u.success)throw new k(u.message||"Login failed",E.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",E.NETWORK);if(d instanceof k)throw d;throw new k(d.message,E.NETWORK)}throw new k("Unknown error occurred",E.NETWORK_ERROR)}},P=async(e,n,t,o=.8,a,r)=>{var i;_();const s=O(),c=await S(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(`${T}/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",E.INVALID_TOKEN);throw new k(`Server returned status ${c.status}`,E.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",E.NETWORK);if(l instanceof k)throw l;throw new k(l.message,E.NETWORK)}throw new k("Unknown error occurred",E.NETWORK_ERROR)}},D=async(e,n,t,o)=>{var a,r,i,s,c,d,l,u;if(_(),!n||0===n.length)throw new k("At least one face photo is required for biometric registration",E.VALIDATION_ERROR);if(n.length>5)throw new k("Maximum of 5 face photos allowed",E.VALIDATION_ERROR);const p=O();try{const h=await Promise.all(n.map((async e=>{const n=await S(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 I(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 I(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(`${T}/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",E.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}`,E.VALIDATION_ERROR)}if("fraud_detected"===e.error)throw new k("Fraud detected in biometric images. Registration blocked.",E.VALIDATION_ERROR);if("user_exists"===e.error||"ALREADY_EXISTS"===e.error_code)throw new k("User with this email already exists",E.VALIDATION_ERROR);if("person_exists"===e.error)throw new k("Person with this CPF already exists",E.VALIDATION_ERROR);const n=e.message||e.error||`Server returned status ${w.status}`;throw new k(n,E.VALIDATION_ERROR)}catch(f){if(f instanceof k)throw f;throw new k(`Server returned status ${w.status}`,E.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",E.NETWORK);if(h instanceof k)throw h;throw new k(h.message,E.NETWORK)}throw new k("Unknown error occurred",E.NETWORK_ERROR)}},L=async(e,n,t)=>{_();const o=O();try{const a=await fetch(`${T}/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("Invalid credentials or application token",E.INVALID_TOKEN);throw new k(`Server returned status ${a.status}`,E.NETWORK)}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",E.NETWORK);if(a instanceof k)throw a;throw new k(a.message,E.NETWORK)}throw new k("Unknown error occurred",E.NETWORK_ERROR)}},F=(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}},M={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 U({accessToken:e,onClose:t,onSuccess:o}){const a=n.useRef(null),r=n.useRef(null),i=n.useRef(null),c=n.useRef(null),d=n.useRef(null),[l,u]=n.useReducer(F,{status:"requestingPermission"}),[p,f]=n.useState(!1),[h,m]=n.useState(0),{startCamera:g,stopCamera:b}=x(),v=()=>{if(!a.current)return;const e=async()=>{if(a.current&&"ready"===l.status){try{const e=await s.detectAllFaces(a.current,new s.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){}c.current=window.setTimeout(e,100)}};e()};n.useEffect((()=>((async()=>{try{await Promise.all([s.nets.tinyFaceDetector.loadFromUri("./models"),s.nets.faceLandmark68Net.loadFromUri("./models")])}catch(e){}})(),()=>{c.current&&window.clearTimeout(c.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&&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 A(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 w.jsxs("div",{style:M.overlay,children:[w.jsx("style",{children:"\n @keyframes spin {\n 0% { transform: translate(-50%, -50%) rotate(0deg); }\n 100% { transform: translate(-50%, -50%) rotate(360deg); }\n }\n"}),w.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"}),w.jsxs("div",{style:M.modal,className:"modal",children:[w.jsx("button",{type:"button",style:M.closeButton,onClick:t,children:"×"}),w.jsx("video",{ref:a,style:M.video,autoPlay:!0,playsInline:!0,muted:!0}),w.jsx("canvas",{ref:r,style:M.canvas}),w.jsx("div",{style:M.guide}),"ready"===l.status&&!p&&w.jsx("div",{style:M.message,children:"Centralize seu rosto no círculo"}),"capturing"===l.status&&w.jsx("div",{style:M.message,children:"Por favor, pisque os olhos"}),"uploading"===l.status&&w.jsx("div",{style:M.spinner}),"success"===l.status&&w.jsx("div",{style:M.message,children:"Autenticado!"}),"error"===l.status&&w.jsx("div",{style:M.message,children:l.message}),w.jsxs("div",{style:M.controls,children:["ready"===l.status&&p&&w.jsx("button",{type:"button",style:M.button,onClick:y,children:"Capturar"}),"capturing"===l.status&&w.jsx("button",{type:"button",style:M.button,onClick:y,children:"Capturar"}),"error"===l.status&&w.jsx("button",{type:"button",style:M.button,onClick:()=>{u({type:"RESET"}),m(0)},children:"Tentar Novamente"})]})]})]})}const B=(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"START_PROCESSING":return{status:"processing"};case"SUCCESS":return{status:"success"};case"ERROR":return{status:"error",message:n.message};case"RESET":return $;default:return e}},W={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..."},$=(()=>{const e=["center","up","down","left","right","complete"];return{status:"liveness",step:e[0],capturedPhotos:[],stepSequence:e,currentStepIndex:0,stepProgress:0}})(),q=8,z=10,K=26,V=8,G=-8,H=15,X=-15,Y=1500,J=200;function Z({personData:e,applicationToken:t,onClose:o,onSuccess:a,onPhotosCaptured:r,onError:i,useRealApi:c=!0}){const d=n.useRef(null),l=n.useRef(null),u=n.useRef(null),p=n.useRef(null),f=n.useRef(null),h=n.useRef(!1),m=n.useRef("center"),g=n.useRef(null),[b,v]=n.useReducer(B,$),[y,x]=n.useState(!1),[E,k]=n.useState("ok");n.useEffect((()=>{if("liveness"===b.status){const e=b.step;m.current!==e&&(m.current=e,h.current||(p.current&&(p.current=null),f.current&&(clearInterval(f.current),f.current=null),v({type:"UPDATE_PROGRESS",progress:0}))),g.current={stepSequence:b.stepSequence,currentStepIndex:b.currentStepIndex,capturedPhotos:b.capturedPhotos}}}),[b.status,"liveness"===b.status&&b.step,"liveness"===b.status&&b.currentStepIndex]);n.useEffect((()=>{(async()=>{try{const e="https://cdn.jsdelivr.net/npm/@vladmandic/face-api/model";await Promise.all([s.nets.tinyFaceDetector.loadFromUri(e),s.nets.faceLandmark68Net.loadFromUri(e)])}catch(e){v({type:"ERROR",message:"Erro ao carregar modelos de IA"})}})()}),[]),n.useEffect((()=>{let e=!0;return(async()=>{if("liveness"===b.status&&!u.current)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(;!d.current&&e<50;)await new Promise((e=>setTimeout(e,100))),e++;return d.current},o=await t();if(!o)throw new Error("Elemento de vídeo não encontrado");o.srcObject=n,u.current=n,await o.play()}catch(n){if(!e)return;const t=n instanceof Error?n.message:"Erro ao acessar câmera";v({type:"ERROR",message:t})}})(),()=>{e=!1,u.current&&(u.current.getTracks().forEach((e=>e.stop())),u.current=null),f.current&&(clearInterval(f.current),f.current=null),p.current=null}}),[b.status]),n.useEffect((()=>{if("liveness"!==b.status||!d.current)return;let e=!0,n=0;const t=async()=>{if(!e||"liveness"!==b.status)return;if(h.current||"complete"===m.current)return void requestAnimationFrame(t);const o=Date.now();if(o-n<J)requestAnimationFrame(t);else{n=o;try{const n=await s.detectSingleFace(d.current,new s.TinyFaceDetectorOptions({inputSize:160,scoreThreshold:.4})).withFaceLandmarks();if(!e)return;const t=!!n;if(x(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+K;return{pitch:Math.round(u),yaw:Math.round(c)}}catch(n){return null}})(n.landmarks);if(e){(e=>{if(h.current||"complete"===m.current)return;const n=Date.now();e?p.current||(p.current=n,f.current&&clearInterval(f.current),f.current=window.setInterval((()=>{if(!p.current)return;const e=Date.now()-p.current,n=Math.min(e/Y*100,100);v({type:"UPDATE_PROGRESS",progress:n}),n>=100&&(clearInterval(f.current),f.current=null,R())}),50)):p.current&&(p.current=null,f.current&&(clearInterval(f.current),f.current=null),v({type:"UPDATE_PROGRESS",progress:0}))})(((e,n,t)=>{switch(t){case"center":return Math.abs(e)<q&&Math.abs(n)<z;case"up":return e>V;case"down":return e<G;case"left":return n>H;case"right":return n<X;default:return!1}})(e.pitch,e.yaw,m.current))}}else p.current&&(p.current=null,f.current&&(clearInterval(f.current),f.current=null),v({type:"UPDATE_PROGRESS",progress:0}))}catch(a){}e&&"liveness"===b.status&&requestAnimationFrame(t)}},o=setTimeout((()=>{var n;e&&4===(null==(n=d.current)?void 0:n.readyState)&&t()}),1e3);return()=>{e=!1,clearTimeout(o),f.current&&(clearInterval(f.current),f.current=null),p.current=null}}),[b.status]);const R=async()=>{if(!d.current||!l.current||h.current)return;h.current=!0,p.current=null;const e=g.current;if(!e)return void(h.current=!1);const n=l.current,t=d.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(h.current=!1);const t=e.currentStepIndex+1,o=e.stepSequence[t];if("complete"===o){const t=[...e.capturedPhotos,n];v({type:"START_PROCESSING"}),T(t)}else setTimeout((()=>{h.current=!1,v({type:"NEXT_STEP",step:o,photo:n})}),100)}),"image/jpeg",.85)):h.current=!1},T=async n=>{try{if(r)return v({type:"SUCCESS"}),void r(n);if(!e||!t)throw new Error("Dados de registro não fornecidos");const o=await D(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};v({type:"SUCCESS"}),a&&a(i)}catch(o){const e=o instanceof Error?o.message:"Erro desconhecido";v({type:"ERROR",message:e}),i(e)}};return w.jsxs(w.Fragment,{children:[w.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 "}),w.jsx("div",{className:"modal-overlay",children:w.jsxs("div",{className:"modal-content",children:[w.jsx("button",{className:"close-button",onClick:o,children:"×"}),"liveness"===b.status&&(()=>{if("liveness"!==b.status)return null;const e=`${b.currentStepIndex+1}/${b.stepSequence.length-1}`,n=b.stepProgress;return w.jsxs("div",{className:"liveness-container",children:[w.jsx("div",{className:"progress-indicator",children:w.jsx("span",{className:"progress-text",children:e})}),w.jsx("div",{className:"video-wrapper",children:w.jsxs("div",{className:`video-circle ${y?"face-detected":""} ${n>0?"capturing":""}`,children:[w.jsx("video",{ref:d,className:"video-feed",autoPlay:!0,muted:!0,playsInline:!0}),y&&w.jsxs("div",{className:"face-badge",children:[w.jsx("svg",{width:"16",height:"16",viewBox:"0 0 20 20",fill:"none",children:w.jsx("path",{d:"M5 10 L8 13 L15 6",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})}),w.jsx("span",{children:"Rosto detectado"})]})]})}),w.jsxs("div",{className:"instruction-box",children:[w.jsx("p",{className:"instruction-text",children:W[b.step]}),n>0&&w.jsx("div",{className:"progress-bar",children:w.jsx("div",{className:"progress-fill",style:{width:`${n}%`}})})]}),w.jsxs("div",{className:"branding-small",children:[w.jsx("img",{src:"/logo-icone.png",alt:"NeoFaceId",className:"brand-logo-small"}),w.jsx("span",{children:"NeoFaceId by"}),w.jsx("span",{className:"brand-name",children:"OCTA"})]})]})})(),"processing"===b.status&&w.jsxs("div",{className:"processing-container",children:[w.jsxs("div",{className:"spinner-wrapper",children:[w.jsx("div",{className:"spinner"}),w.jsx("div",{className:"spinner-ring"})]}),w.jsx("h3",{children:"Processando biometria"}),w.jsx("p",{children:"Analisando suas capturas faciais..."}),w.jsxs("div",{className:"branding",style:{marginTop:"40px",paddingTop:"24px",borderTop:"1px solid rgba(255, 255, 255, 0.1)"},children:[w.jsx("span",{children:"NeoFaceId by"}),w.jsx("span",{className:"brand-name",children:"OCTA"})]})]}),"error"===b.status&&("error"!==b.status?null:w.jsxs("div",{className:"result-container error",children:[w.jsx("div",{className:"result-icon error-icon",children:w.jsxs("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",children:[w.jsx("circle",{cx:"30",cy:"30",r:"28",stroke:"currentColor",strokeWidth:"3"}),w.jsx("path",{d:"M20 20 L40 40 M40 20 L20 40",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}),w.jsx("h3",{children:"Não foi possível concluir"}),w.jsx("p",{children:b.message}),w.jsxs("div",{className:"button-group",children:[w.jsx("button",{className:"secondary-button",onClick:()=>v({type:"RESET"}),children:"Tentar Novamente"}),w.jsx("button",{className:"ghost-button",onClick:o,children:"Cancelar"})]})]})),"success"===b.status&&w.jsxs("div",{className:"result-container success",children:[w.jsx("div",{className:"result-icon success-icon",children:w.jsxs("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",children:[w.jsx("circle",{cx:"30",cy:"30",r:"28",stroke:"currentColor",strokeWidth:"3"}),w.jsx("path",{d:"M15 30 L25 40 L45 20",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"})]})}),w.jsx("h3",{children:r?"Captura concluída!":"Verificação concluída!"}),w.jsx("p",{children:r?"Suas capturas faciais foram realizadas":"Sua biometria foi registrada com sucesso"}),w.jsx("button",{className:"primary-button",onClick:o,children:"Continuar"})]})]})}),w.jsx("canvas",{ref:l})]})}class Q{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.1);\n opacity: 0.9;\n }\n }\n\n @keyframes neofaceid-checkmark {\n 0% {\n stroke-dashoffset: 100;\n opacity: 0;\n }\n 50% {\n opacity: 1;\n }\n 100% {\n stroke-dashoffset: 0;\n opacity: 1;\n }\n }\n\n @keyframes neofaceid-errorShake {\n 0%, 100% { transform: translateX(0) scale(1); }\n 10%, 30%, 50%, 70%, 90% { transform: translateX(-4px) scale(1); }\n 20%, 40%, 60%, 80% { transform: translateX(4px) scale(1); }\n }\n\n @keyframes neofaceid-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-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 }\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-logo-wrapper {\n position: relative;\n width: 120px;\n height: 120px;\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 filter: drop-shadow(0 4px 12px rgba(124, 58, 237, 0.3));\n }\n\n .neofaceid-logo.pulsing {\n animation: neofaceid-pulse 2s ease-in-out infinite;\n }\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: 60px;\n height: 60px;\n color: #10b981;\n animation: neofaceid-scaleIn 0.6s ease-out;\n }\n\n .neofaceid-error-icon {\n width: 60px;\n height: 60px;\n color: #ef4444;\n animation: neofaceid-errorShake 0.5s ease-out, neofaceid-scaleIn 0.4s ease-out;\n }\n\n @media (max-width: 640px) {\n .neofaceid-logo-wrapper {\n width: 100px;\n height: 100px;\n }\n\n .neofaceid-logo {\n width: 70px;\n height: 70px;\n }\n }\n "}renderContent(){const e="verifying"===this.currentStatus,n="preparing"===this.currentStatus||"verifying"===this.currentStatus,t="success"===this.currentStatus,o="error"===this.currentStatus;return`\n <style>${this.getStyles()}</style>\n <div class="neofaceid-overlay-container">\n <div class="neofaceid-overlay-content">\n <div class="neofaceid-logo-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 </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 ee({error:e,onRetry:n,onCredentials:t,onCancel:o}){return w.jsxs(w.Fragment,{children:[w.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 "}),w.jsx("div",{className:"neofaceid-fallback-overlay",children:w.jsxs("div",{className:"neofaceid-fallback-prompt",children:[w.jsx("div",{className:"neofaceid-fallback-icon",children:w.jsxs("svg",{viewBox:"0 0 64 64",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[w.jsx("circle",{cx:"32",cy:"32",r:"30",stroke:"currentColor",strokeWidth:"3",fill:"none"}),w.jsx("path",{d:"M20 20 L44 44 M44 20 L20 44",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}),w.jsx("h3",{className:"neofaceid-fallback-title",children:"Não foi possível reconhecer"}),w.jsx("p",{className:"neofaceid-fallback-message",children:(null==e?void 0:e.message)||"Não conseguimos reconhecer sua face. Tente novamente ou use email e senha."}),w.jsxs("div",{className:"neofaceid-fallback-actions",children:[w.jsx("button",{type:"button",className:"neofaceid-fallback-button neofaceid-fallback-button-primary",onClick:n,children:"Tentar Novamente"}),w.jsx("button",{type:"button",className:"neofaceid-fallback-button neofaceid-fallback-button-secondary",onClick:t,children:"Entrar com Email e Senha"}),o&&w.jsx("button",{type:"button",className:"neofaceid-fallback-button neofaceid-fallback-button-ghost",onClick:o,children:"Cancelar"})]})]})})]})}class ne{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=u.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(w.jsx(ee,{error:e,onRetry:()=>{this.close(),n()},onCredentials:()=>{this.close(),t()},onCancel:()=>{this.close(),null==o||o()}}))}}class te{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 <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 @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=n.value.trim(),a=t.value.trim();if(o&&a)try{const e=await L(o,a,this.options.applicationToken);this.options.onSuccess(e),this.close()}catch(r){this.options.onError(r)}else this.options.onError(new k("Email e senha são obrigatórios",E.VALIDATION_ERROR))}}let oe=!1,ae=null;async function re(){if(!oe)return ae||(ae=(async()=>{try{const e="https://cdn.jsdelivr.net/npm/@vladmandic/face-api/model";await s.nets.tinyFaceDetector.loadFromUri(e),oe=!0}catch(e){}})(),ae)}async function ie(e,n,t=!1){n.updateStatus("verifying");const o=document.createElement("video");o.style.position="fixed",o.style.top="-9999px",o.style.left="-9999px",o.style.width="1px",o.style.height="1px",o.style.opacity="0",o.setAttribute("autoplay",""),o.setAttribute("muted",""),o.setAttribute("playsinline",""),document.body.appendChild(o);let a=null;try{a=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"},audio:!1}),o.srcObject=a,await o.play(),await new Promise((e=>{o.readyState>=2?e(void 0):o.onloadedmetadata=()=>e(void 0)})),await new Promise((e=>setTimeout(e,100)));let n=!0;if(t||(n=await async function(e,n=5e3,t=100){return new Promise((o=>{let a=0;const r=Math.ceil(n/t);let i=null,c=!1;const d=e=>{c||(c=!0,i&&clearTimeout(i),o(e))},l=async()=>{if(!c)if(a++,oe)try{if(await s.detectSingleFace(e,new s.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((()=>{c||d(!0)}),n+500),l()}))}(o)),!n)throw a&&a.getTracks().forEach((e=>e.stop())),o.parentElement&&o.parentElement.removeChild(o),new k("Rosto não detectado. Posicione seu rosto na frente da câmera.",E.VALIDATION_ERROR);const r=document.createElement("canvas");r.width=o.videoWidth,r.height=o.videoHeight;const i=r.getContext("2d");if(!i)throw a&&a.getTracks().forEach((e=>e.stop())),o.parentElement&&o.parentElement.removeChild(o),new k("Erro ao capturar imagem",E.CAPTURE_ERROR);i.drawImage(o,0,0,r.width,r.height),a&&a.getTracks().forEach((e=>e.stop())),o.parentElement&&o.parentElement.removeChild(o);const c=await new Promise(((e,n)=>{r.toBlob((t=>{r.remove(),t?e(t):n(new Error("Failed to capture image"))}),"image/jpeg",.85)})),d=await j(c,e);if(!d.success)throw new k("Login falhou",E.LOGIN_FAILED);return d}catch(r){if(a&&a.getTracks().forEach((e=>e.stop())),o.parentElement&&o.parentElement.removeChild(o),r instanceof k)throw r;throw new k(r instanceof Error?r.message:"Erro desconhecido",E.UNKNOWN)}}async function se(e){const{applicationToken:n,onSuccess:t,onError:o,onFallbackRequest:a,onCancel:r,fastMode:i=!1}=e,s=new Q,c=new ne;let d,l=0;oe||i||re().catch((()=>{})),s.show("preparing");const u=async()=>{try{l++;const e=await ie(n,s,i);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",E.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",E.LOGIN_FAILED))}),r)}),500)}};u()}const ce=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.setAttribute("autoplay",""),t.setAttribute("muted",""),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),navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"},audio:!1}).then((c=>{a=c,t.srcObject=a,t.play();const d=()=>{if(!t.videoWidth||!t.videoHeight)return r<10?(r++,void setTimeout(d,100)):(i(),void n(new k("Câmera não está pronta",E.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(!oe)return!0;try{return!!(await s.detectSingleFace(t,new s.TinyFaceDetectorOptions({inputSize:160,scoreThreshold:.3})))}catch{return!0}})().then((s=>{if(!s&&r<10)return r++,void setTimeout(d,100);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)}))};t.onloadedmetadata=()=>{setTimeout(d,200)},t.onerror=()=>{i(),n(new k("Erro ao acessar câmera",E.CAMERA_ERROR))}})).catch((e=>{i(),n(new k("Não foi possível acessar a câmera: "+e.message,E.CAMERA_ERROR))}))}))},executeBiometricLoginFlow:se,preloadFaceDetectionModels:re},Symbol.toStringTag,{value:"Module"}));async function de(e){try{if(!(await N(e.applicationToken)))return void e.onError(new k("Token de aplicação inválido",E.INVALID_TOKEN));await se({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 te(n).open()}),onCancel:e.onCancel})}catch(n){e.onError(new k("Erro ao inicializar login facial: "+n.message,E.INITIALIZATION_ERROR))}}async function le(e){try{if(!(await N(e.applicationToken)))return void e.onError(new k("Token de aplicação inválido",E.INVALID_TOKEN));const n={mode:"hand",onSuccess:async(n,t)=>{try{const t=await fetch(n).then((e=>e.blob())),o=await loginWithBiometric(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 BiometricCaptureModal(n);await t.open()}catch(n){e.onError(new k("Erro ao inicializar login por mão: "+n.message,E.INITIALIZATION_ERROR))}}async function ue(e){try{if(!(await N(e.applicationToken)))return void e.onError(new k("Token de aplicação inválido",E.INVALID_TOKEN));const n={mode:"auto",onSuccess:async(n,t)=>{try{const t=await fetch(n).then((e=>e.blob())),o=await loginWithBiometric(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 BiometricCaptureModal(n);await t.open()}catch(n){e.onError(new k("Erro ao inicializar login automático: "+n.message,E.INITIALIZATION_ERROR))}}async function pe(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 he();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){fe(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 fe(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 he(){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 me(){try{"undefined"!=typeof window&&await he()}catch(e){}}function ge(){return"undefined"!=typeof window&&window.faceapi&&window.faceapi.nets.tinyFaceDetector.isLoaded}const be=Object.freeze(Object.defineProperty({__proto__:null,detectBiometricType:pe,initializeBiometricDetection:me,isAdvancedDetectionAvailable:ge},Symbol.toStringTag,{value:"Module"}));class we{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 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.stream=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:{ideal:1280},height:{ideal:720}},audio:!1}),!this.video)throw new Error("Elemento de vídeo não encontrado");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 ve={};const ye=["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"],xe={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 Ee{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(xe).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?xe[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 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?xe[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.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?xe[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 "}}e.BiometricCaptureModal=class{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,E.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,E.CAPTURE_ERROR))}finally{this.isCapturing=!1}}}async detectBiometricType(e){try{const{detectBiometricType:n}=await Promise.resolve().then((()=>be)),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)}},e.BiometricRegistrationModal=Z,e.BiometricStatusOverlay=Q,e.DocumentCaptureModal=Ee,e.EmailPasswordModal=te,e.ErrorType=E,e.FaceCaptureModal=U,e.FallbackPrompt=ne,e.NeoFaceError=k,e.NeoFaceID=class{constructor(e){if(r(this,"appToken"),r(this,"baseUrl"),r(this,"signature"),r(this,"sessionData"),this.appToken=e.appToken,this.baseUrl=e.baseUrl||(null==ve?void 0:ve.VITE_API_BASE_URL),this.signature=e.signature,this.sessionData=e.sessionData,!this.baseUrl)throw new k("baseUrl não configurado. Passe via config ou configure VITE_API_BASE_URL no .env",E.VALIDATION_ERROR);if(this.signature&&!this.validateSignatureFormat(this.signature))throw new k("Invalid signature format. Expected HMAC-SHA256 hex string (minimum 64 characters)",E.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",E.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",E.VALIDATION_ERROR);const o=[];try{const{captureFaceSilently:e}=await Promise.resolve().then((()=>ce));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"}`,E.CAPTURE_ERROR)}}async loginRecognition(e){const{biometricData:n,typeOfIdentification:t,purpose:o,confidenceThreshold:a=.8}=e,r=Array.isArray(n)?n:[n];if(0===r.length)throw new k("At least one biometric data frame is required",E.VALIDATION_ERROR);const i=r[0];try{const e=await P(i,this.appToken,o,a,this.signature,this.sessionData);if(!e.success)throw new k("Recognition failed",E.RECOGNITION_FAILED);if(!e.personName||!e.email||!e.cpf)throw new k("Incomplete recognition result: missing personName, email, or cpf",E.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(s){if(s instanceof k)throw s;throw new k(`Login recognition failed: ${s instanceof Error?s.message:"Unknown error"}`,E.RECOGNITION_FAILED)}}async registerApplication(e,n,t){try{const o=await(async(e,n,t)=>{_();const o=O();try{const r=await fetch(`${T}/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",E.INVALID_TOKEN);if(403===r.status)throw new k("Insufficient permissions to create application",E.INVALID_TOKEN);if(400===r.status)try{const e=await r.json(),n=e.message||e.error||"Invalid application data";throw new k(n,E.VALIDATION_ERROR)}catch(a){if(a instanceof k)throw a;throw new k("Invalid application data",E.VALIDATION_ERROR)}throw new k(`Server returned status ${r.status}`,E.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",E.NETWORK);if(r instanceof k)throw r;throw new k(r.message,E.NETWORK)}throw new k("Unknown error occurred",E.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"}`,E.VALIDATION_ERROR)}}async proofOfLife(e={}){const{videoDurationMs:n=3e3,maxPollingAttempts:t=60,pollingIntervalMs:o=1e3,onRecordingProgress:a,onTaskStatusChange:r}=e;try{const e=await(async(e={})=>{_();const{durationMs:n=3e3,mimeType:t="video/webm",onProgress:o}=e;return new Promise((async(e,a)=>{let r=null,i=null;const s=[];try{r=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:{ideal:640},height:{ideal:480}},audio:!1});let c=t;const d=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"];for(const e of d)if(MediaRecorder.isTypeSupported(e)){c=e;break}if(i=new MediaRecorder(r,{mimeType:c,videoBitsPerSecond:1e6}),i.ondataavailable=e=>{e.data.size>0&&s.push(e.data)},i.onstop=()=>{r&&r.getTracks().forEach((e=>e.stop()));const n=new Blob(s,{type:c});e(n)},i.onerror=e=>{r&&r.getTracks().forEach((e=>e.stop())),a(new k(`Recording error: ${e}`,E.CAPTURE_ERROR))},i.start(100),o){const e=100;let t=0;const a=setInterval((()=>{t+=e;const r=Math.min(100,t/n*100);o(r),t>=n&&clearInterval(a)}),e)}setTimeout((()=>{i&&"recording"===i.state&&i.stop()}),n)}catch(c){r&&r.getTracks().forEach((e=>e.stop())),c instanceof Error?"NotAllowedError"===c.name?a(new k("Camera permission denied",E.CAMERA_ERROR)):"NotFoundError"===c.name?a(new k("No camera found",E.NO_CAMERA)):a(new k(c.message,E.CAPTURE_ERROR)):a(new k("Failed to record video",E.CAPTURE_ERROR))}}))})({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",E.CAPTURE_ERROR)),o.readAsDataURL(e)})))(e),s=await(async(e,n)=>{var t;_();const o=O();try{const a=await fetch(`${T}/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",E.INVALID_TOKEN);if(400===a.status){const e=await a.json();throw new k(e.message||"Invalid request data",E.VALIDATION_ERROR)}throw new k(`Server returned status ${a.status}`,E.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",E.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",E.NETWORK);if(a instanceof k)throw a;throw new k(a.message,E.NETWORK)}throw new k("Unknown error occurred",E.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(`${T}/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}`,E.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,E.RECOGNITION_FAILED)}if("revoked"===p)throw new k("Task was cancelled",E.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"}`,E.NETWORK)}}throw new k("Task status polling timed out",E.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"}`,E.RECOGNITION_FAILED)}}},e.RELEASE_DATE="2026-01-20",e.VERSION="1.9.0",e.authorizeOperation=async(e,n,t)=>{if(!e)throw new k("Application token is required",E.VALIDATION_ERROR);if(!n)throw new k("CPF is required",E.VALIDATION_ERROR);const o=n.replace(/\D/g,"");if(11!==o.length)throw new k("Invalid CPF format",E.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",E.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",E.CAPTURE_ERROR);for(let e=0;e<4;e++){const n=ye[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 P(d,e,"AUTHORIZATION",.8,void 0,l);if(!u.success)throw new k("Authorization failed: Person not recognized",E.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,E.CAPTURE_ERROR);throw new k("Unknown error during authorization",E.UNKNOWN)}},e.biometricLogin=function(e,n="auto"){return new Promise(((t,o)=>{const a={applicationToken:e,onSuccess:t,onError:o};switch(n){case"face":de(a);break;case"hand":le(a);break;case"auto":ue(a);break;default:o(new k("Modo de login inválido",E.VALIDATION_ERROR))}}))},e.biometricLoginWithFallback=function(e,n="auto"){return new Promise(((t,o)=>{const a={applicationToken:e,onSuccess:t,onError:n=>{if(n.type===E.LOGIN_FAILED){new te({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":de(a);break;case"hand":le(a);break;case"auto":ue(a);break;default:o(new k("Modo de login inválido",E.VALIDATION_ERROR))}}))},e.completeOnboarding=C,e.completeOnboardingWithData=async(e,n,t,o,a)=>{if(_(),!o||0===o.length)throw new k("Pelo menos uma imagem da pessoa é obrigatória",E.VALIDATION_ERROR);const r=O();try{const i=await Promise.all(o.map((e=>S(e)))),s=await S(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(`${T}/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",E.INVALID_TOKEN);if(404===d.status)throw new k("Link de onboarding não encontrado",E.NOT_FOUND);throw new k((null==l?void 0:l.error)||(null==l?void 0:l.message)||"Falha ao concluir onboarding",E.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",E.NETWORK);if(i instanceof k)throw i;throw new k(i.message,E.NETWORK)}throw new k("Erro desconhecido",E.NETWORK_ERROR)}},e.detectBiometricType=pe,e.identifyPerson=async(e,n)=>{var t,o;_();const a=O(),r=await S(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(`${T}/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",E.INVALID_TOKEN);throw new k(`Server returned status ${e.status}`,E.NETWORK)}const r=await e.json();if(!r.success)throw new k(r.message||"Person identification failed",E.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",E.PERSON_NOT_FOUND);if(!c)throw new k("Birth date not found in response",E.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",E.NETWORK);if(s instanceof k)throw s;throw new k(s.message,E.NETWORK)}throw new k("Unknown error occurred",E.NETWORK_ERROR)}},e.initializeBiometricDetection=me,e.isAdvancedDetectionAvailable=ge,e.loginWithBiometric=j,e.loginWithEmail=L,e.preloadFaceDetectionModels=re,e.recognize=A,e.recognizeBiometric=async(e,n,t=!0,o=.8)=>{_();const a=O(),r=await S(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(`${T}/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",E.INVALID_TOKEN);throw new k(`Server returned status ${i.status}`,E.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",E.NETWORK);if(i instanceof k)throw i;throw new k(i.message,E.NETWORK)}throw new k("Unknown error occurred",E.NETWORK_ERROR)}},e.recognizeByPurpose=P,e.registerBiometric=async(e,n,t)=>{if(_(),!e)throw new k("Person ID is required",E.VALIDATION_ERROR);if(!n)throw new k("Face image is required",E.VALIDATION_ERROR);const o=O(),a=await S(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(`${T}/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",E.INVALID_TOKEN);if(400===n.status)try{const e=await n.json(),t=e.message||e.error||"Invalid biometric data";throw new k(t,E.VALIDATION_ERROR)}catch(i){if(i instanceof k)throw i;throw new k("Invalid biometric data",E.VALIDATION_ERROR)}throw new k(`Server returned status ${n.status}`,E.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",E.NETWORK);if(s instanceof k)throw s;throw new k(s.message,E.NETWORK)}throw new k("Unknown error occurred",E.NETWORK_ERROR)}},e.registerPersonWithBiometric=D,e.registerPersonWithoutFace=async(e,n,t)=>{_();const o=O();try{let a,r;if(null==t?void 0:t.documentFront){const e=await I(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 I(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(`${T}/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",E.INVALID_TOKEN);throw new k(`Server returned status ${s.status}`,E.NETWORK)}return await s.json()}catch(a){if(a instanceof Error){if("AbortError"===a.name)throw new k("Request timed out",E.NETWORK);if(a instanceof k)throw a;throw new k(a.message,E.NETWORK)}throw new k("Unknown error occurred",E.NETWORK)}},e.simpleIdentification=async(e,n,t,o="LOGIN")=>{_();const a=O();try{const r=await fetch(`${T}/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",E.INVALID_TOKEN);throw new k(`Server returned status ${r.status}`,E.NETWORK)}const i=await r.json();if(!i.success)throw new k(i.message||"Identification failed",E.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",E.NETWORK);if(r instanceof k)throw r;throw new k(r.message,E.NETWORK)}throw new k("Unknown error occurred",E.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)};N(e).then((()=>{const r=n.createElement(U,{accessToken:e,onClose:a,onSuccess:e=>{a(),t.onSuccess({name:e.data.faceId,email:e.data.faceId,documentId:e.data.faceId})}});u.createRoot(o).render(r)})).catch((e=>{a(),t.onError("TOKEN_VALIDATION_ERROR",e.message||"Failed to validate token")}))},e.startAutoLogin=ue,e.startBiometricRegistration=function(e,t,o,a){const r=document.createElement("div");r.id="neoface-biometric-registration-container",document.body.appendChild(r);const i=()=>{document.body.contains(r)&&document.body.removeChild(r)};N(t).then((()=>{const s=n.createElement(Z,{personData:e,applicationToken:t,useRealApi:(null==a?void 0:a.useRealApi)??!0,onClose:i,onSuccess:e=>{i(),o.onSuccess(e)},onError:e=>{i(),o.onError("BIOMETRIC_REGISTRATION_ERROR",e)}});u.createRoot(r).render(s)})).catch((e=>{i(),o.onError("TOKEN_VALIDATION_ERROR",e.message||"Failed to validate token")}))},e.startDocumentCapture=async e=>new Ee(e).open(),e.startFaceLogin=de,e.startHandLogin=le,e.startLivenessCapture=function(e,t){const o=document.createElement("div");o.id="neoface-liveness-capture-container",document.body.appendChild(o);const a=()=>{document.body.contains(o)&&document.body.removeChild(o)};N(e).then((()=>{const r=n.createElement(Z,{applicationToken:e,onClose:a,onPhotosCaptured:e=>{t.onSuccess(e)},onError:e=>{a(),t.onError("LIVENESS_CAPTURE_ERROR",e)}});u.createRoot(o).render(r)})).catch((e=>{a(),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)=>{_();const t=O();try{const o=await fetch(`${T}/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",E.INVALID_TOKEN);if(404===o.status)throw new k("Link de onboarding não encontrado",E.NOT_FOUND);throw new k(`Falha ao obter detalhes (${o.status})`,E.NETWORK)}return await o.json()}catch(o){if(o instanceof Error){if("AbortError"===o.name)throw new k("Tempo de requisição excedido",E.NETWORK);if(o instanceof k)throw o;throw new k(o.message,E.NETWORK)}throw new k("Erro desconhecido",E.NETWORK_ERROR)}})(n,t);if(!(null==e?void 0:e.is_valid))throw new k("Link de onboarding inválido ou expirado",E.VALIDATION_ERROR);const s=new we({countdown:o,title:a,subtitle:r}),{face:c,document:d}=await s.open();i({...await C(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,E.UNKNOWN))}},e.validateOnboardingToken=async(e,n)=>{_();const t=O();try{const o=await fetch(`${T}/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",E.INVALID_TOKEN);if(404===o.status)return!1;throw new k(`Falha ao validar token (${o.status})`,E.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",E.NETWORK);if(o instanceof k)throw o;throw new k(o.message,E.NETWORK)}throw new k("Erro desconhecido",E.NETWORK_ERROR)}},e.validateToken=N,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,k,R,T,_,O,S,I=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,k=console.info,R=console.warn,T=console.error,_=console.group,O=console.groupCollapsed,S=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:I({},e,{value:E}),info:I({},e,{value:k}),warn:I({},e,{value:R}),error:I({},e,{value:T}),group:I({},e,{value:_}),groupCollapsed:I({},e,{value:O}),groupEnd:I({},e,{value:S})})}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,W={},$=g.ReactDebugCurrentFrame;function z(e){if(e){var n=e._owner,t=U(e.type,e._source,n?n.type:null);$.setExtraStackFrame(t)}else $.setExtraStackFrame(null)}var q=Array.isArray;function K(e){return q(e)}function V(e){return""+e}function G(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 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(B.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(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(){H||(H=!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||(z(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),z(null)),s instanceof Error&&!(s.message in W)&&(W[s.message]=!0,z(a),w("Failed %s type: %s",t,s.message),z(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 k;E+=ae(),null===e?k="null":K(e)?k="array":void 0!==e&&e.$$typeof===t?(k="<"+(x(e.type)||"Unknown")+" />",E=" Did you accidentally export a JSX literal instead of a component?"):k=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",k,E)}var R=Z(e,n,o,g,b);if(null==R)return R;if(y){var T=n.children;if(void 0!==T)if(m)if(K(T)){for(var _=0;_<T.length;_++)se(T[_],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 O=x(e),S=Object.keys(n).filter((function(e){return"key"!==e})),I=S.length>0?"{key: someKey, "+S.join(": ..., ")+": ...}":"{key: someKey}";if(!de[O+I])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} />',I,O,S.length>0?"{"+S.join(": ..., ")+": ...}":"{}",O),de[O+I]=!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))}(R):ce(R),R}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 k=(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))(k||{});class R extends Error{constructor(e,n){super(e),r(this,"type"),this.name=n,this.type=n}}const T={},_={development:"http://localhost:8000",sandbox:"https://sandbox-core.neofaceid.com",production:"https://core.neofaceid.com.br"};let O={baseUrl:_.sandbox,applicationToken:null,environment:"sandbox",initialized:!1};function S(){return O.initialized,O.baseUrl}const I=()=>S(),N=()=>{const e="localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname||""===window.location.hostname;if(!window.isSecureContext&&!e)throw new R("Secure context (HTTPS) is required for this operation",k.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{return(await fetch(`${I()}/api/v1/auth/application/validate_token/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":e},body:JSON.stringify({}),signal:n.signal})).ok}catch(t){if(t instanceof Error){if("AbortError"===t.name)throw new R("Request timed out",k.NETWORK_ERROR);throw new R(t.message,k.NETWORK_ERROR)}throw new R("Unknown error occurred",k.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(`${I()}/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 R("Token de aplicação inválido ou expirado",k.INVALID_TOKEN);if(404===o.status)throw new R("Link de onboarding não encontrado",k.NOT_FOUND);throw new R((null==s?void 0:s.error)||(null==s?void 0:s.message)||"Falha ao concluir onboarding",k.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 R("Tempo de requisição excedido",k.NETWORK);if(s instanceof R)throw s;throw new R(s.message,k.NETWORK)}throw new R("Erro desconhecido",k.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(`${I()}/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 R("Invalid or expired application token",k.INVALID_TOKEN);throw new R(`Server returned status ${a.status}`,k.NETWORK)}const r=await a.json();if(!r.success)throw new R(r.message||"Recognition failed",k.RECOGNITION_FAILED);return{accessToken:r.accessToken,payload:r.payload}}catch(a){if(a instanceof Error){if("AbortError"===a.name)throw new R("Request timed out",k.NETWORK);if(a instanceof R)throw a;throw new R(a.message,k.NETWORK)}throw new R("Unknown error occurred",k.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(`${I()}/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 R("Invalid or expired application token",k.INVALID_TOKEN);throw new R(`Server returned status ${l.status}`,k.NETWORK)}const u=await l.json();if(!u.success)throw new R(u.message||"Login failed",k.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 R("Request timed out",k.NETWORK);if(d instanceof R)throw d;throw new R(d.message,k.NETWORK)}throw new R("Unknown error occurred",k.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(`${I()}/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 R("Invalid or expired application token",k.INVALID_TOKEN);throw new R(`Server returned status ${c.status}`,k.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 R("Request timed out",k.NETWORK);if(l instanceof R)throw l;throw new R(l.message,k.NETWORK)}throw new R("Unknown error occurred",k.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 R("At least one face photo is required for biometric registration",k.VALIDATION_ERROR);if(n.length>5)throw new R("Maximum of 5 face photos allowed",k.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(`${I()}/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 R("Invalid or expired application token",k.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 R(`Erro de validação: ${n}`,k.VALIDATION_ERROR)}if("fraud_detected"===e.error)throw new R("Fraud detected in biometric images. Registration blocked.",k.VALIDATION_ERROR);if("user_exists"===e.error||"ALREADY_EXISTS"===e.error_code)throw new R("User with this email already exists",k.VALIDATION_ERROR);if("person_exists"===e.error)throw new R("Person with this CPF already exists",k.VALIDATION_ERROR);const n=e.message||e.error||`Server returned status ${w.status}`;throw new R(n,k.VALIDATION_ERROR)}catch(f){if(f instanceof R)throw f;throw new R(`Server returned status ${w.status}`,k.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 R("Request timed out",k.NETWORK);if(h instanceof R)throw h;throw new R(h.message,k.NETWORK)}throw new R("Unknown error occurred",k.NETWORK_ERROR)}},B=async(e,n,t)=>{N();const o=C();try{const a=await fetch(`${I()}/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 R("Invalid credentials or application token",k.INVALID_TOKEN);throw new R(`Server returned status ${a.status}`,k.NETWORK)}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 R("Request timed out",k.NETWORK);if(a instanceof R)throw a;throw new R(a.message,k.NETWORK)}throw new R("Unknown error occurred",k.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}},$={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 z({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:$.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:$.modal,className:"modal",children:[v.jsx("button",{type:"button",style:$.closeButton,onClick:t,children:"×"}),v.jsx("video",{ref:a,style:$.video,autoPlay:!0,playsInline:!0,muted:!0}),v.jsx("canvas",{ref:r,style:$.canvas}),v.jsx("div",{style:$.guide}),"ready"===l.status&&!p&&v.jsx("div",{style:$.message,children:"Centralize seu rosto no círculo"}),"capturing"===l.status&&v.jsx("div",{style:$.message,children:"Por favor, pisque os olhos"}),"uploading"===l.status&&v.jsx("div",{style:$.spinner}),"success"===l.status&&v.jsx("div",{style:$.message,children:"Autenticado!"}),"error"===l.status&&v.jsx("div",{style:$.message,children:l.message}),v.jsxs("div",{style:$.controls,children:["ready"===l.status&&p&&v.jsx("button",{type:"button",style:$.button,onClick:y,children:"Capturar"}),"capturing"===l.status&&v.jsx("button",{type:"button",style:$.button,onClick:y,children:"Capturar"}),"error"===l.status&&v.jsx("button",{type:"button",style:$.button,onClick:()=>{u({type:"RESET"}),m(0)},children:"Tentar Novamente"})]})]})]})}const q=(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"START_PROCESSING":return{status:"processing"};case"SUCCESS":return{status:"success"};case"ERROR":return{status:"error",message:n.message};case"RESET":return V;default:return e}},K={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..."},V=(()=>{const e=["center","up","down","left","right","complete"];return{status:"liveness",step:e[0],capturedPhotos:[],stepSequence:e,currentStepIndex:0,stepProgress:0}})(),G=8,H=10,X=26,Y=8,J=-8,Z=15,Q=-15,ee=1500,ne=200;function te({personData:e,applicationToken:t,onClose:o,onSuccess:a,onPhotosCaptured:r,onError:i,useRealApi:s=!0}){const d=n.useRef(null),l=n.useRef(null),u=n.useRef(null),p=n.useRef(null),f=n.useRef(null),h=n.useRef(!1),m=n.useRef("center"),g=n.useRef(null),[b,w]=n.useReducer(q,V),[y,x]=n.useState(!1),[E,k]=n.useState("ok");n.useEffect((()=>{if("liveness"===b.status){const e=b.step;m.current!==e&&(m.current=e,h.current||(p.current&&(p.current=null),f.current&&(clearInterval(f.current),f.current=null),w({type:"UPDATE_PROGRESS",progress:0}))),g.current={stepSequence:b.stepSequence,currentStepIndex:b.currentStepIndex,capturedPhotos:b.capturedPhotos}}}),[b.status,"liveness"===b.status&&b.step,"liveness"===b.status&&b.currentStepIndex]);n.useEffect((()=>{(async()=>{try{const e="https://cdn.jsdelivr.net/npm/@vladmandic/face-api/model";await Promise.all([c.nets.tinyFaceDetector.loadFromUri(e),c.nets.faceLandmark68Net.loadFromUri(e)])}catch(e){w({type:"ERROR",message:"Erro ao carregar modelos de IA"})}})()}),[]),n.useEffect((()=>{let e=!0;return(async()=>{if("liveness"===b.status&&!u.current)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(;!d.current&&e<50;)await new Promise((e=>setTimeout(e,100))),e++;return d.current},o=await t();if(!o)throw new Error("Elemento de vídeo não encontrado");o.srcObject=n,u.current=n,await o.play()}catch(n){if(!e)return;const t=n instanceof Error?n.message:"Erro ao acessar câmera";w({type:"ERROR",message:t})}})(),()=>{e=!1,u.current&&(u.current.getTracks().forEach((e=>e.stop())),u.current=null),f.current&&(clearInterval(f.current),f.current=null),p.current=null}}),[b.status]),n.useEffect((()=>{if("liveness"!==b.status||!d.current)return;let e=!0,n=0;const t=async()=>{if(!e||"liveness"!==b.status)return;if(h.current||"complete"===m.current)return void requestAnimationFrame(t);const o=Date.now();if(o-n<ne)requestAnimationFrame(t);else{n=o;try{const n=await c.detectSingleFace(d.current,new c.TinyFaceDetectorOptions({inputSize:160,scoreThreshold:.4})).withFaceLandmarks();if(!e)return;const t=!!n;if(x(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+X;return{pitch:Math.round(u),yaw:Math.round(c)}}catch(n){return null}})(n.landmarks);if(e){(e=>{if(h.current||"complete"===m.current)return;const n=Date.now();e?p.current||(p.current=n,f.current&&clearInterval(f.current),f.current=window.setInterval((()=>{if(!p.current)return;const e=Date.now()-p.current,n=Math.min(e/ee*100,100);w({type:"UPDATE_PROGRESS",progress:n}),n>=100&&(clearInterval(f.current),f.current=null,R())}),50)):p.current&&(p.current=null,f.current&&(clearInterval(f.current),f.current=null),w({type:"UPDATE_PROGRESS",progress:0}))})(((e,n,t)=>{switch(t){case"center":return Math.abs(e)<G&&Math.abs(n)<H;case"up":return e>Y;case"down":return e<J;case"left":return n>Z;case"right":return n<Q;default:return!1}})(e.pitch,e.yaw,m.current))}}else p.current&&(p.current=null,f.current&&(clearInterval(f.current),f.current=null),w({type:"UPDATE_PROGRESS",progress:0}))}catch(a){}e&&"liveness"===b.status&&requestAnimationFrame(t)}},o=setTimeout((()=>{var n;e&&4===(null==(n=d.current)?void 0:n.readyState)&&t()}),1e3);return()=>{e=!1,clearTimeout(o),f.current&&(clearInterval(f.current),f.current=null),p.current=null}}),[b.status]);const R=async()=>{if(!d.current||!l.current||h.current)return;h.current=!0,p.current=null;const e=g.current;if(!e)return void(h.current=!1);const n=l.current,t=d.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(h.current=!1);const t=e.currentStepIndex+1,o=e.stepSequence[t];if("complete"===o){const t=[...e.capturedPhotos,n];w({type:"START_PROCESSING"}),T(t)}else setTimeout((()=>{h.current=!1,w({type:"NEXT_STEP",step:o,photo:n})}),100)}),"image/jpeg",.85)):h.current=!1},T=async n=>{try{if(r)return w({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};w({type:"SUCCESS"}),a&&a(i)}catch(o){const e=o instanceof Error?o.message:"Erro desconhecido";w({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"===b.status&&(()=>{if("liveness"!==b.status)return null;const e=`${b.currentStepIndex+1}/${b.stepSequence.length-1}`,n=b.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 ${y?"face-detected":""} ${n>0?"capturing":""}`,children:[v.jsx("video",{ref:d,className:"video-feed",autoPlay:!0,muted:!0,playsInline:!0}),y&&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:K[b.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"})]})]})})(),"processing"===b.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"===b.status&&("error"!==b.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 concluir"}),v.jsx("p",{children:b.message}),v.jsxs("div",{className:"button-group",children:[v.jsx("button",{className:"secondary-button",onClick:()=>w({type:"RESET"}),children:"Tentar Novamente"}),v.jsx("button",{className:"ghost-button",onClick:o,children:"Cancelar"})]})]})),"success"===b.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:l})]})}class oe{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.1);\n opacity: 0.9;\n }\n }\n\n @keyframes neofaceid-checkmark {\n 0% {\n stroke-dashoffset: 100;\n opacity: 0;\n }\n 50% {\n opacity: 1;\n }\n 100% {\n stroke-dashoffset: 0;\n opacity: 1;\n }\n }\n\n @keyframes neofaceid-errorShake {\n 0%, 100% { transform: translateX(0) scale(1); }\n 10%, 30%, 50%, 70%, 90% { transform: translateX(-4px) scale(1); }\n 20%, 40%, 60%, 80% { transform: translateX(4px) scale(1); }\n }\n\n @keyframes neofaceid-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-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 }\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-logo-wrapper {\n position: relative;\n width: 120px;\n height: 120px;\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 filter: drop-shadow(0 4px 12px rgba(124, 58, 237, 0.3));\n }\n\n .neofaceid-logo.pulsing {\n animation: neofaceid-pulse 2s ease-in-out infinite;\n }\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: 60px;\n height: 60px;\n color: #10b981;\n animation: neofaceid-scaleIn 0.6s ease-out;\n }\n\n .neofaceid-error-icon {\n width: 60px;\n height: 60px;\n color: #ef4444;\n animation: neofaceid-errorShake 0.5s ease-out, neofaceid-scaleIn 0.4s ease-out;\n }\n\n @media (max-width: 640px) {\n .neofaceid-logo-wrapper {\n width: 100px;\n height: 100px;\n }\n\n .neofaceid-logo {\n width: 70px;\n height: 70px;\n }\n }\n "}renderContent(){const e="verifying"===this.currentStatus,n="preparing"===this.currentStatus||"verifying"===this.currentStatus,t="success"===this.currentStatus,o="error"===this.currentStatus;return`\n <style>${this.getStyles()}</style>\n <div class="neofaceid-overlay-container">\n <div class="neofaceid-overlay-content">\n <div class="neofaceid-logo-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 </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 ae({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.message)||"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 re{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(ae,{error:e,onRetry:()=>{this.close(),n()},onCredentials:()=>{this.close(),t()},onCancel:()=>{this.close(),null==o||o()}}))}}class ie{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 <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 @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=n.value.trim(),a=t.value.trim();if(o&&a)try{const e=await B(o,a,this.options.applicationToken);this.options.onSuccess(e),this.close()}catch(r){this.options.onError(r)}else this.options.onError(new R("Email e senha são obrigatórios",k.VALIDATION_ERROR))}}let se=!1,ce=null;async function de(){if(!se)return ce||(ce=(async()=>{try{const e="https://cdn.jsdelivr.net/npm/@vladmandic/face-api/model";await c.nets.tinyFaceDetector.loadFromUri(e),se=!0}catch(e){}})(),ce)}async function le(e,n,t=!1){n.updateStatus("verifying");const o=document.createElement("video");o.style.position="fixed",o.style.top="-9999px",o.style.left="-9999px",o.style.width="1px",o.style.height="1px",o.style.opacity="0",o.setAttribute("autoplay",""),o.setAttribute("muted",""),o.setAttribute("playsinline",""),document.body.appendChild(o);let a=null;try{a=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"},audio:!1}),o.srcObject=a,await o.play(),await new Promise((e=>{o.readyState>=2?e(void 0):o.onloadedmetadata=()=>e(void 0)})),await new Promise((e=>setTimeout(e,100)));let n=!0;if(t||(n=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++,se)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()}))}(o)),!n)throw a&&a.getTracks().forEach((e=>e.stop())),o.parentElement&&o.parentElement.removeChild(o),new R("Rosto não detectado. Posicione seu rosto na frente da câmera.",k.VALIDATION_ERROR);const r=document.createElement("canvas");r.width=o.videoWidth,r.height=o.videoHeight;const i=r.getContext("2d");if(!i)throw a&&a.getTracks().forEach((e=>e.stop())),o.parentElement&&o.parentElement.removeChild(o),new R("Erro ao capturar imagem",k.CAPTURE_ERROR);i.drawImage(o,0,0,r.width,r.height),a&&a.getTracks().forEach((e=>e.stop())),o.parentElement&&o.parentElement.removeChild(o);const s=await new Promise(((e,n)=>{r.toBlob((t=>{r.remove(),t?e(t):n(new Error("Failed to capture image"))}),"image/jpeg",.85)})),d=await F(s,e);if(!d.success)throw new R("Login falhou",k.LOGIN_FAILED);return d}catch(r){if(a&&a.getTracks().forEach((e=>e.stop())),o.parentElement&&o.parentElement.removeChild(o),r instanceof R)throw r;throw new R(r instanceof Error?r.message:"Erro desconhecido",k.UNKNOWN)}}async function ue(e){const{applicationToken:n,onSuccess:t,onError:o,onFallbackRequest:a,onCancel:r,fastMode:i=!1}=e,s=new oe,c=new re;let d,l=0;se||i||de().catch((()=>{})),s.show("preparing");const u=async()=>{try{l++;const e=await le(n,s,i);s.updateStatus("success"),setTimeout((()=>{s.close(),t(e)}),200)}catch(e){d=e instanceof R?e:new R(e instanceof Error?e.message:"Erro desconhecido",k.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 R("Por favor, use email e senha para fazer login",k.LOGIN_FAILED))}),r)}),500)}};u()}const pe=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.setAttribute("autoplay",""),t.setAttribute("muted",""),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),navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"},audio:!1}).then((s=>{a=s,t.srcObject=a,t.play();const d=()=>{if(!t.videoWidth||!t.videoHeight)return r<10?(r++,void setTimeout(d,100)):(i(),void n(new R("Câmera não está pronta",k.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(!se)return!0;try{return!!(await c.detectSingleFace(t,new c.TinyFaceDetectorOptions({inputSize:160,scoreThreshold:.3})))}catch{return!0}})().then((s=>{if(!s&&r<10)return r++,void setTimeout(d,100);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)}))};t.onloadedmetadata=()=>{setTimeout(d,200)},t.onerror=()=>{i(),n(new R("Erro ao acessar câmera",k.CAMERA_ERROR))}})).catch((e=>{i(),n(new R("Não foi possível acessar a câmera: "+e.message,k.CAMERA_ERROR))}))}))},executeBiometricLoginFlow:ue,preloadFaceDetectionModels:de},Symbol.toStringTag,{value:"Module"}));async function fe(e){try{if(!(await P(e.applicationToken)))return void e.onError(new R("Token de aplicação inválido",k.INVALID_TOKEN));await ue({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 ie(n).open()}),onCancel:e.onCancel})}catch(n){e.onError(new R("Erro ao inicializar login facial: "+n.message,k.INITIALIZATION_ERROR))}}async function he(e){try{if(!(await P(e.applicationToken)))return void e.onError(new R("Token de aplicação inválido",k.INVALID_TOKEN));const n={mode:"hand",onSuccess:async(n,t)=>{try{const t=await fetch(n).then((e=>e.blob())),o=await loginWithBiometric(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 BiometricCaptureModal(n);await t.open()}catch(n){e.onError(new R("Erro ao inicializar login por mão: "+n.message,k.INITIALIZATION_ERROR))}}async function me(e){try{if(!(await P(e.applicationToken)))return void e.onError(new R("Token de aplicação inválido",k.INVALID_TOKEN));const n={mode:"auto",onSuccess:async(n,t)=>{try{const t=await fetch(n).then((e=>e.blob())),o=await loginWithBiometric(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 BiometricCaptureModal(n);await t.open()}catch(n){e.onError(new R("Erro ao inicializar login automático: "+n.message,k.INITIALIZATION_ERROR))}}async function ge(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 we();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){be(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 be(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 we(){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 ve(){try{"undefined"!=typeof window&&await we()}catch(e){}}function ye(){return"undefined"!=typeof window&&window.faceapi&&window.faceapi.nets.tinyFaceDetector.isLoaded}const xe=Object.freeze(Object.defineProperty({__proto__:null,detectBiometricType:ge,initializeBiometricDetection:ve,isAdvancedDetectionAvailable:ye},Symbol.toStringTag,{value:"Module"}));class Ee{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 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.stream=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:{ideal:1280},height:{ideal:720}},audio:!1}),!this.video)throw new Error("Elemento de vídeo não encontrado");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 ke=["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"],Re={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 Te{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(Re).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?Re[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 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?Re[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.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?Re[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 "}}e.BiometricCaptureModal=class{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 R("Erro ao inicializar câmera: "+e.message,k.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 R("Erro ao capturar imagem: "+e.message,k.CAPTURE_ERROR))}finally{this.isCapturing=!1}}}async detectBiometricType(e){try{const{detectBiometricType:n}=await Promise.resolve().then((()=>xe)),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)}},e.BiometricRegistrationModal=te,e.BiometricStatusOverlay=oe,e.DocumentCaptureModal=Te,e.ENVIRONMENT_URLS=_,e.EmailPasswordModal=ie,e.ErrorType=k,e.FaceCaptureModal=z,e.FallbackPrompt=re,e.NeoFaceError=R,e.NeoFaceID=class{constructor(e){if(r(this,"appToken"),r(this,"baseUrl"),r(this,"signature"),r(this,"sessionData"),this.appToken=e.appToken,this.baseUrl=e.baseUrl||S(),this.signature=e.signature,this.sessionData=e.sessionData,this.signature&&!this.validateSignatureFormat(this.signature))throw new R("Invalid signature format. Expected HMAC-SHA256 hex string (minimum 64 characters)",k.VALIDATION_ERROR);if(this.sessionData&&(!this.sessionData.email||!this.sessionData.cpf||!this.sessionData.sessionId))throw new R("Session data must include email, cpf, and sessionId",k.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 R("Number of frames must be between 1 and 10",k.VALIDATION_ERROR);const o=[];try{const{captureFaceSilently:e}=await Promise.resolve().then((()=>pe));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 R)throw a;throw new R(`Failed to capture face frames: ${a instanceof Error?a.message:"Unknown error"}`,k.CAPTURE_ERROR)}}async loginRecognition(e){const{biometricData:n,typeOfIdentification:t,purpose:o,confidenceThreshold:a=.8}=e,r=Array.isArray(n)?n:[n];if(0===r.length)throw new R("At least one biometric data frame is required",k.VALIDATION_ERROR);const i=r[0];try{const e=await M(i,this.appToken,o,a,this.signature,this.sessionData);if(!e.success)throw new R("Recognition failed",k.RECOGNITION_FAILED);if(!e.personName||!e.email||!e.cpf)throw new R("Incomplete recognition result: missing personName, email, or cpf",k.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(s){if(s instanceof R)throw s;throw new R(`Login recognition failed: ${s instanceof Error?s.message:"Unknown error"}`,k.RECOGNITION_FAILED)}}async registerApplication(e,n,t){try{const o=await(async(e,n,t)=>{N();const o=C();try{const r=await fetch(`${I()}/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 R("Invalid or expired JWT token",k.INVALID_TOKEN);if(403===r.status)throw new R("Insufficient permissions to create application",k.INVALID_TOKEN);if(400===r.status)try{const e=await r.json(),n=e.message||e.error||"Invalid application data";throw new R(n,k.VALIDATION_ERROR)}catch(a){if(a instanceof R)throw a;throw new R("Invalid application data",k.VALIDATION_ERROR)}throw new R(`Server returned status ${r.status}`,k.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 R("Request timed out",k.NETWORK);if(r instanceof R)throw r;throw new R(r.message,k.NETWORK)}throw new R("Unknown error occurred",k.NETWORK_ERROR)}})(e,n,t);return o}catch(o){if(o instanceof R)throw o;throw new R(`Application registration failed: ${o instanceof Error?o.message:"Unknown error"}`,k.VALIDATION_ERROR)}}async proofOfLife(e={}){const{videoDurationMs:n=3e3,maxPollingAttempts:t=60,pollingIntervalMs:o=1e3,onRecordingProgress:a,onTaskStatusChange:r}=e;try{const e=await(async(e={})=>{N();const{durationMs:n=3e3,mimeType:t="video/webm",onProgress:o}=e;return new Promise((async(e,a)=>{let r=null,i=null;const s=[];try{r=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:{ideal:640},height:{ideal:480}},audio:!1});let c=t;const d=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"];for(const e of d)if(MediaRecorder.isTypeSupported(e)){c=e;break}if(i=new MediaRecorder(r,{mimeType:c,videoBitsPerSecond:1e6}),i.ondataavailable=e=>{e.data.size>0&&s.push(e.data)},i.onstop=()=>{r&&r.getTracks().forEach((e=>e.stop()));const n=new Blob(s,{type:c});e(n)},i.onerror=e=>{r&&r.getTracks().forEach((e=>e.stop())),a(new R(`Recording error: ${e}`,k.CAPTURE_ERROR))},i.start(100),o){const e=100;let t=0;const a=setInterval((()=>{t+=e;const r=Math.min(100,t/n*100);o(r),t>=n&&clearInterval(a)}),e)}setTimeout((()=>{i&&"recording"===i.state&&i.stop()}),n)}catch(c){r&&r.getTracks().forEach((e=>e.stop())),c instanceof Error?"NotAllowedError"===c.name?a(new R("Camera permission denied",k.CAMERA_ERROR)):"NotFoundError"===c.name?a(new R("No camera found",k.NO_CAMERA)):a(new R(c.message,k.CAPTURE_ERROR)):a(new R("Failed to record video",k.CAPTURE_ERROR))}}))})({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 R("Failed to convert video to base64",k.CAPTURE_ERROR)),o.readAsDataURL(e)})))(e),s=await(async(e,n)=>{var t;N();const o=C();try{const a=await fetch(`${I()}/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 R("Invalid or expired application token",k.INVALID_TOKEN);if(400===a.status){const e=await a.json();throw new R(e.message||"Invalid request data",k.VALIDATION_ERROR)}throw new R(`Server returned status ${a.status}`,k.NETWORK)}const r=await a.json();if(!r.success||!(null==(t=r.data)?void 0:t.task_id))throw new R(r.message||"Failed to start proof of life",k.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 R("Request timed out",k.NETWORK);if(a instanceof R)throw a;throw new R(a.message,k.NETWORK)}throw new R("Unknown error occurred",k.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(`${I()}/api/v1/tasks/status/?task_id=${e}`,{method:"GET",headers:{Accept:"application/json","X-App-Token":n}});if(!t.ok)throw new R(`Task status check failed: ${t.status}`,k.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 R(e,k.RECOGNITION_FAILED)}if("revoked"===p)throw new R("Task was cancelled",k.RECOGNITION_FAILED);await new Promise((e=>setTimeout(e,l)))}catch(f){if(f instanceof R)throw f;throw new R(`Polling error: ${f instanceof Error?f.message:"Unknown error"}`,k.NETWORK)}}throw new R("Task status polling timed out",k.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 R)throw i;throw new R(`Proof of life failed: ${i instanceof Error?i.message:"Unknown error"}`,k.RECOGNITION_FAILED)}}},e.RELEASE_DATE="2026-01-21",e.VERSION="1.10.0",e.authorizeOperation=async(e,n,t)=>{if(!e)throw new R("Application token is required",k.VALIDATION_ERROR);if(!n)throw new R("CPF is required",k.VALIDATION_ERROR);const o=n.replace(/\D/g,"");if(11!==o.length)throw new R("Invalid CPF format",k.VALIDATION_ERROR);const a=[],r=(null==t?void 0:t.captureDelay)||2e3;try{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new R("Camera not available",k.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 R("Failed to get canvas context",k.CAPTURE_ERROR);for(let e=0;e<4;e++){const n=ke[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 R("Authorization failed: Person not recognized",k.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 R)throw i;if(i instanceof Error)throw new R(i.message,k.CAPTURE_ERROR);throw new R("Unknown error during authorization",k.UNKNOWN)}},e.biometricLogin=function(e,n="auto"){return new Promise(((t,o)=>{const a={applicationToken:e,onSuccess:t,onError:o};switch(n){case"face":fe(a);break;case"hand":he(a);break;case"auto":me(a);break;default:o(new R("Modo de login inválido",k.VALIDATION_ERROR))}}))},e.biometricLoginWithFallback=function(e,n="auto"){return new Promise(((t,o)=>{const a={applicationToken:e,onSuccess:t,onError:n=>{if(n.type===k.LOGIN_FAILED){new ie({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":fe(a);break;case"hand":he(a);break;case"auto":me(a);break;default:o(new R("Modo de login inválido",k.VALIDATION_ERROR))}}))},e.completeOnboarding=D,e.completeOnboardingWithData=async(e,n,t,o,a)=>{if(N(),!o||0===o.length)throw new R("Pelo menos uma imagem da pessoa é obrigatória",k.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(`${I()}/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 R("Token de aplicação inválido ou expirado",k.INVALID_TOKEN);if(404===d.status)throw new R("Link de onboarding não encontrado",k.NOT_FOUND);throw new R((null==l?void 0:l.error)||(null==l?void 0:l.message)||"Falha ao concluir onboarding",k.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 R("Tempo de requisição excedido",k.NETWORK);if(i instanceof R)throw i;throw new R(i.message,k.NETWORK)}throw new R("Erro desconhecido",k.NETWORK_ERROR)}},e.detectBiometricType=ge,e.getApplicationToken=function(){return O.applicationToken},e.getBaseUrl=S,e.getConfig=function(){return{...O}},e.getEnvironment=function(){return O.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(`${I()}/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 R("Invalid or expired application token",k.INVALID_TOKEN);throw new R(`Server returned status ${e.status}`,k.NETWORK)}const r=await e.json();if(!r.success)throw new R(r.message||"Person identification failed",k.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 R("Person name not found in response",k.PERSON_NOT_FOUND);if(!c)throw new R("Birth date not found in response",k.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 R("Request timed out",k.NETWORK);if(s instanceof R)throw s;throw new R(s.message,k.NETWORK)}throw new R("Unknown error occurred",k.NETWORK_ERROR)}},e.init=function(e={}){const{environment:n,baseUrl:t,applicationToken:o}=e;if(t)O.baseUrl=t,O.environment="custom";else if(n)_[n]?(O.baseUrl=_[n],O.environment=n):(O.baseUrl=_.sandbox,O.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&&(O.baseUrl=e,O.environment="custom")}o&&(O.applicationToken=o),O.initialized=!0},e.initializeBiometricDetection=ve,e.isAdvancedDetectionAvailable=ye,e.isInitialized=function(){return O.initialized},e.loginWithBiometric=F,e.loginWithEmail=B,e.preloadFaceDetectionModels=de,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(`${I()}/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 R("Invalid or expired application token",k.INVALID_TOKEN);throw new R(`Server returned status ${i.status}`,k.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 R("Request timed out",k.NETWORK);if(i instanceof R)throw i;throw new R(i.message,k.NETWORK)}throw new R("Unknown error occurred",k.NETWORK_ERROR)}},e.recognizeByPurpose=M,e.registerBiometric=async(e,n,t)=>{if(N(),!e)throw new R("Person ID is required",k.VALIDATION_ERROR);if(!n)throw new R("Face image is required",k.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(`${I()}/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 R("Invalid or expired application token, or insufficient permissions",k.INVALID_TOKEN);if(400===n.status)try{const e=await n.json(),t=e.message||e.error||"Invalid biometric data";throw new R(t,k.VALIDATION_ERROR)}catch(i){if(i instanceof R)throw i;throw new R("Invalid biometric data",k.VALIDATION_ERROR)}throw new R(`Server returned status ${n.status}`,k.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 R("Request timed out",k.NETWORK);if(s instanceof R)throw s;throw new R(s.message,k.NETWORK)}throw new R("Unknown error occurred",k.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(`${I()}/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 R("Invalid or expired application token",k.INVALID_TOKEN);throw new R(`Server returned status ${s.status}`,k.NETWORK)}return await s.json()}catch(a){if(a instanceof Error){if("AbortError"===a.name)throw new R("Request timed out",k.NETWORK);if(a instanceof R)throw a;throw new R(a.message,k.NETWORK)}throw new R("Unknown error occurred",k.NETWORK)}},e.simpleIdentification=async(e,n,t,o="LOGIN")=>{N();const a=C();try{const r=await fetch(`${I()}/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 R("Invalid or expired application token",k.INVALID_TOKEN);throw new R(`Server returned status ${r.status}`,k.NETWORK)}const i=await r.json();if(!i.success)throw new R(i.message||"Identification failed",k.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 R("Request timed out",k.NETWORK);if(r instanceof R)throw r;throw new R(r.message,k.NETWORK)}throw new R("Unknown error occurred",k.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(z,{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=me,e.startBiometricRegistration=function(e,t,o,a){const r=document.createElement("div");r.id="neoface-biometric-registration-container",document.body.appendChild(r);const i=()=>{document.body.contains(r)&&document.body.removeChild(r)};P(t).then((()=>{const s=n.createElement(te,{personData:e,applicationToken:t,useRealApi:(null==a?void 0:a.useRealApi)??!0,onClose:i,onSuccess:e=>{i(),o.onSuccess(e)},onError:e=>{i(),o.onError("BIOMETRIC_REGISTRATION_ERROR",e)}});p.createRoot(r).render(s)})).catch((e=>{i(),o.onError("TOKEN_VALIDATION_ERROR",e.message||"Failed to validate token")}))},e.startDocumentCapture=async e=>new Te(e).open(),e.startFaceLogin=fe,e.startHandLogin=he,e.startLivenessCapture=function(e,t){const o=document.createElement("div");o.id="neoface-liveness-capture-container",document.body.appendChild(o);const a=()=>{document.body.contains(o)&&document.body.removeChild(o)};P(e).then((()=>{const r=n.createElement(te,{applicationToken:e,onClose:a,onPhotosCaptured:e=>{t.onSuccess(e)},onError:e=>{a(),t.onError("LIVENESS_CAPTURE_ERROR",e)}});p.createRoot(o).render(r)})).catch((e=>{a(),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(`${I()}/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 R("Token de aplicação inválido ou expirado",k.INVALID_TOKEN);if(404===o.status)throw new R("Link de onboarding não encontrado",k.NOT_FOUND);throw new R(`Falha ao obter detalhes (${o.status})`,k.NETWORK)}return await o.json()}catch(o){if(o instanceof Error){if("AbortError"===o.name)throw new R("Tempo de requisição excedido",k.NETWORK);if(o instanceof R)throw o;throw new R(o.message,k.NETWORK)}throw new R("Erro desconhecido",k.NETWORK_ERROR)}})(n,t);if(!(null==e?void 0:e.is_valid))throw new R("Link de onboarding inválido ou expirado",k.VALIDATION_ERROR);const s=new Ee({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 R)return void s(c);const e=(null==c?void 0:c.message)||"Erro desconhecido no onboarding";s(new R(e,k.UNKNOWN))}},e.validateOnboardingToken=async(e,n)=>{N();const t=C();try{const o=await fetch(`${I()}/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 R("Token de aplicação inválido ou expirado",k.INVALID_TOKEN);if(404===o.status)return!1;throw new R(`Falha ao validar token (${o.status})`,k.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 R("Tempo de requisição excedido",k.NETWORK);if(o instanceof R)throw o;throw new R(o.message,k.NETWORK)}throw new R("Erro desconhecido",k.NETWORK_ERROR)}},e.validateToken=P,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
|
|
11
11
|
//# sourceMappingURL=neoface-id-sdk.umd.js.map
|