@neofaceid/web-sdk 2.1.2 → 2.1.3

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 +1 @@
1
- !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react"),require("react-dom/client"),require("react/jsx-runtime"),require("@tensorflow/tfjs-core/dist/public/chained_ops/register_all_chained_ops"),require("@tensorflow/tfjs-backend-cpu"),require("@tensorflow/tfjs-core"),require("@tensorflow/tfjs-backend-webgl/dist/index.js")):"function"==typeof define&&define.amd?define(["exports","react","react-dom/client","react/jsx-runtime","@tensorflow/tfjs-core/dist/public/chained_ops/register_all_chained_ops","@tensorflow/tfjs-backend-cpu","@tensorflow/tfjs-core","@tensorflow/tfjs-backend-webgl/dist/index.js"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).NeoFaceIdSdk={},e.React,e.ReactDOM,e.jsxRuntime,null,e.tf,e.tf,e.pn)}(this,(function(e,n,t,o,r,a,i,s){"use strict";var c=Object.defineProperty,l=(e,n,t)=>((e,n,t)=>n in e?c(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t)(e,"symbol"!=typeof n?n+"":n,t),d="undefined"!=typeof document?document.currentScript:null;function u(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)}function p(e,n){for(var t=0;t<n.length;t++){const o=n[t];if("string"!=typeof o&&!Array.isArray(o))for(const n in o)if("default"!==n&&!(n in e)){const t=Object.getOwnPropertyDescriptor(o,n);t&&Object.defineProperty(e,n,t.get?t:{enumerable:!0,get:()=>o[n]})}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}const f=u(i),h=u(s),m=p({__proto__:null},[f]),g=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));var v,w=Object.defineProperty,b=Object.getOwnPropertyDescriptor,x=Object.getOwnPropertyNames,y=Object.prototype.hasOwnProperty,_=(v=function(e){if("undefined"!=typeof require)return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')},"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(v,{get:(e,n)=>("undefined"!=typeof require?require:e)[n]}):v),k=(e,n)=>{for(var t in n)w(e,t,{get:n[t],enumerable:!0})},E=(e,n,t)=>(((e,n,t,o)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let r of x(n))!y.call(e,r)&&r!==t&&w(e,r,{get:()=>n[r],enumerable:!(o=b(n,r))||o.enumerable})})(e,n,"default"),t),T={};k(T,{version:()=>S}),E(T,m),E(T,h),E(T,g);var N="4.22.0",S={tfjs:N,"tfjs-core":N,"tfjs-converter":"4.22.0","tfjs-backend-cpu":"4.22.0","tfjs-backend-webgl":"4.22.0","tfjs-backend-wasm":"4.22.0"},C={};function I(e,n,t=!1){if(e.beginPath(),n.slice(1).forEach((({x:t,y:o},r)=>{let a=n[r];e.moveTo(a.x,a.y),e.lineTo(t,o)})),t){let t=n[n.length-1],o=n[0];if(!t||!o)return;e.moveTo(t.x,t.y),e.lineTo(o.x,o.y)}e.stroke()}k(C,{AnchorPosition:()=>ke,DrawBox:()=>Se,DrawBoxOptions:()=>Ne,DrawFaceLandmarks:()=>_n,DrawFaceLandmarksOptions:()=>yn,DrawTextField:()=>Te,DrawTextFieldOptions:()=>Ee,drawContour:()=>I,drawDetections:()=>Ce,drawFaceExpressions:()=>wn,drawFaceLandmarks:()=>kn});var R={};k(R,{computeReshapedDimensions:()=>B,getCenterPoint:()=>W,isDimensions:()=>L,isEven:()=>D,isFloat:()=>$,isTensor:()=>j,isTensor1D:()=>A,isTensor2D:()=>P,isTensor3D:()=>F,isTensor4D:()=>z,isValidNumber:()=>U,isValidProbablitiy:()=>V,range:()=>q,round:()=>M});var O=class e{constructor(e,n){if(!U(e)||!U(n))throw new Error(`Dimensions.constructor - expected width and height to be valid numbers, instead have ${JSON.stringify({width:e,height:n})}`);this._width=e,this._height=n}get width(){return this._width}get height(){return this._height}reverse(){return new e(1/this.width,1/this.height)}};function j(e,n){return e instanceof T.Tensor&&e.shape.length===n}function A(e){return j(e,1)}function P(e){return j(e,2)}function F(e){return j(e,3)}function z(e){return j(e,4)}function $(e){return e%1!=0}function D(e){return e%2==0}function M(e,n=2){let t=10**n;return Math.floor(e*t)/t}function L(e){return e&&e.width&&e.height}function B({width:e,height:n},t){let o=t/Math.max(n,e);return new O(Math.round(e*o),Math.round(n*o))}function W(e){return e.reduce(((e,n)=>e.add(n)),new K(0,0)).div(new K(e.length,e.length))}function q(e,n,t){return Array(e).fill(0).map(((e,o)=>n+o*t))}function U(e){return!!e&&e!==1/0&&e!==-1/0&&!Number.isNaN(e)||0===e}function V(e){return U(e)&&e>=0&&e<=1}var K=class e{constructor(e,n){this._x=e,this._y=n}get x(){return this._x}get y(){return this._y}add(n){return new e(this.x+n.x,this.y+n.y)}sub(n){return new e(this.x-n.x,this.y-n.y)}mul(n){return new e(this.x*n.x,this.y*n.y)}div(n){return new e(this.x/n.x,this.y/n.y)}abs(){return new e(Math.abs(this.x),Math.abs(this.y))}magnitude(){return Math.sqrt(this.x**2+this.y**2)}floor(){return new e(Math.floor(this.x),Math.floor(this.y))}},Z=class e{static isRect(e){return!!e&&[e.x,e.y,e.width,e.height].every(U)}static assertIsValidBox(n,t,o=!1){if(!e.isRect(n))throw new Error(`${t} - invalid box: ${JSON.stringify(n)}, expected object with properties x, y, width, height`);if(!o&&(n.width<0||n.height<0))throw new Error(`${t} - width (${n.width}) and height (${n.height}) must be positive numbers`)}constructor(n,t=!0){let o=n||{},r=[o.left,o.top,o.right,o.bottom].every(U),a=[o.x,o.y,o.width,o.height].every(U);if(!a&&!r)throw new Error(`Box.constructor - expected box to be IBoundingBox | IRect, instead have ${JSON.stringify(o)}`);let[i,s,c,l]=a?[o.x,o.y,o.width,o.height]:[o.left,o.top,o.right-o.left,o.bottom-o.top];e.assertIsValidBox({x:i,y:s,width:c,height:l},"Box.constructor",t),this._x=i,this._y=s,this._width=c,this._height=l}get x(){return this._x}get y(){return this._y}get width(){return this._width}get height(){return this._height}get left(){return this.x}get top(){return this.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}get area(){return this.width*this.height}get topLeft(){return new K(this.left,this.top)}get topRight(){return new K(this.right,this.top)}get bottomLeft(){return new K(this.left,this.bottom)}get bottomRight(){return new K(this.right,this.bottom)}round(){let[n,t,o,r]=[this.x,this.y,this.width,this.height].map((e=>Math.round(e)));return new e({x:n,y:t,width:o,height:r})}floor(){let[n,t,o,r]=[this.x,this.y,this.width,this.height].map((e=>Math.floor(e)));return new e({x:n,y:t,width:o,height:r})}toSquare(){let{x:n,y:t,width:o,height:r}=this,a=Math.abs(o-r);return o<r&&(n-=a/2,o+=a),r<o&&(t-=a/2,r+=a),new e({x:n,y:t,width:o,height:r})}rescale(n){let t=L(n)?n.width:n,o=L(n)?n.height:n;return new e({x:this.x*t,y:this.y*o,width:this.width*t,height:this.height*o})}pad(n,t){let[o,r,a,i]=[this.x-n/2,this.y-t/2,this.width+n,this.height+t];return new e({x:o,y:r,width:a,height:i})}clipAtImageBorders(n,t){let{x:o,y:r,right:a,bottom:i}=this,s=Math.max(o,0),c=Math.max(r,0),l=a-s,d=i-c,u=Math.min(l,n-s),p=Math.min(d,t-c);return new e({x:s,y:c,width:u,height:p}).floor()}shift(n,t){let{width:o,height:r}=this,a=this.x+n,i=this.y+t;return new e({x:a,y:i,width:o,height:r})}padAtBorders(e,n){let t=this.width+1,o=this.height+1,r=t,a=o,i=this.left,s=this.top,c=this.right,l=this.bottom;return c>n&&(r=-c+n+t,c=n),l>e&&(a=-l+e+o,l=e),i<1&&(a=2-i,i=1),s<1&&(a=2-s,s=1),{dy:1,edy:a,dx:1,edx:r,y:s,ey:l,x:i,ex:c,w:t,h:o}}calibrate(n){return new e({left:this.left+n.left*this.width,top:this.top+n.top*this.height,right:this.right+n.right*this.width,bottom:this.bottom+n.bottom*this.height}).toSquare().round()}},H=class extends Z{constructor(e,n,t,o,r=!1){super({left:e,top:n,right:t,bottom:o},r)}},G=class e{constructor(e,n,t,o,r){this._imageDims=new O(r.width,r.height),this._score=e,this._classScore=n,this._className=t,this._box=new Z(o).rescale(this._imageDims)}get score(){return this._score}get classScore(){return this._classScore}get className(){return this._className}get box(){return this._box}get imageDims(){return this._imageDims}get imageWidth(){return this.imageDims.width}get imageHeight(){return this.imageDims.height}get relativeBox(){return new Z(this._box).rescale(this.imageDims.reverse())}forSize(n,t){return new e(this.score,this.classScore,this.className,this.relativeBox,{width:n,height:t})}},J=class e extends G{constructor(e,n,t){super(e,e,"",n,t)}forSize(n,t){let{score:o,relativeBox:r,imageDims:a}=super.forSize(n,t);return new e(o,r,a)}};function X(e,n,t=!0){let o=Math.max(0,Math.min(e.right,n.right)-Math.max(e.left,n.left))*Math.max(0,Math.min(e.bottom,n.bottom)-Math.max(e.top,n.top));return t?o/(e.area+n.area-o):o/Math.min(e.area,n.area)}function Y(e){let n=e.map((e=>e.x)),t=e.map((e=>e.y)),o=n.reduce(((e,n)=>n<e?n:e),1/0),r=t.reduce(((e,n)=>n<e?n:e),1/0),a=n.reduce(((e,n)=>e<n?n:e),0),i=t.reduce(((e,n)=>e<n?n:e),0);return new H(o,r,a,i)}function Q(e,n,t,o=!0){let r=n.map(((e,n)=>({score:e,boxIndex:n}))).sort(((e,n)=>e.score-n.score)).map((e=>e.boxIndex)),a=[];for(;r.length>0;){let n=r.pop();a.push(n);let i=r,s=[];for(let t=0;t<i.length;t++){let r=i[t],a=e[n],c=e[r];s.push(X(a,c,o))}r=r.filter(((e,n)=>s[n]<=t))}return a}function ee(e,n){return T.tidy((()=>{let[t,o,r]=n,a=T.fill([...e.shape.slice(0,3),1],t,"float32"),i=T.fill([...e.shape.slice(0,3),1],o,"float32"),s=T.fill([...e.shape.slice(0,3),1],r,"float32"),c=T.concat([a,i,s],3);return T.sub(e,c)}))}function ne(e,n=!1){return T.tidy((()=>{let[t,o]=e.shape.slice(1);if(t===o)return e;let r=Math.abs(t-o),a=Math.round(r*(n?.5:1)),i=t>o?2:1,s=n=>{let t=e.shape.slice();return t[i]=n,T.fill(t,0,"float32")},c=s(a),l=r-c.shape[i],d=[n&&l?s(l):null,e,c].filter((e=>!!e)).map((e=>T.cast(e,"float32")));return T.concat(d,i)}))}function te(e){return 1/(1+Math.exp(-e))}var oe,re=class extends Z{constructor(e,n,t,o,r=!1){super({x:e,y:n,width:t,height:o},r)}},ae=class{constructor(e,n,t=new K(0,0)){let{width:o,height:r}=n;this._imgDims=new O(o,r),this._shift=t,this._positions=e.map((e=>e.mul(new K(o,r)).add(t)))}get shift(){return new K(this._shift.x,this._shift.y)}get imageWidth(){return this._imgDims.width}get imageHeight(){return this._imgDims.height}get positions(){return this._positions}get relativePositions(){return this._positions.map((e=>e.sub(this._shift).div(new K(this.imageWidth,this.imageHeight))))}forSize(e,n){return new this.constructor(this.relativePositions,{width:e,height:n})}shiftBy(e,n){return new this.constructor(this.relativePositions,this._imgDims,new K(e,n))}shiftByPoint(e){return this.shiftBy(e.x,e.y)}align(e,n={}){if(e){let t=e instanceof J?e.box.floor():new Z(e);return this.shiftBy(t.x,t.y).align(null,n)}let{useDlibAlignment:t,minBoxPadding:o}={useDlibAlignment:!1,minBoxPadding:.2,...n};return t?this.alignDlib():this.alignMinBbox(o)}alignDlib(){let e=this.getRefPointsForAlignment(),[n,t,o]=e,r=e=>o.sub(e).magnitude(),a=(r(n)+r(t))/2,i=Math.floor(a/.45),s=W(e),c=Math.floor(Math.max(0,s.x-.5*i)),l=Math.floor(Math.max(0,s.y-.43*i));return new re(c,l,Math.min(i,this.imageWidth+c),Math.min(i,this.imageHeight+l))}alignMinBbox(e){let n=Y(this.positions);return n.pad(n.width*e,n.height*e)}getRefPointsForAlignment(){throw new Error("getRefPointsForAlignment not implemented by base class")}},ie=class extends ae{getJawOutline(){return this.positions.slice(0,17)}getLeftEyeBrow(){return this.positions.slice(17,22)}getRightEyeBrow(){return this.positions.slice(22,27)}getNose(){return this.positions.slice(27,36)}getLeftEye(){return this.positions.slice(36,42)}getRightEye(){return this.positions.slice(42,48)}getMouth(){return this.positions.slice(48,68)}getRefPointsForAlignment(){return[this.getLeftEye(),this.getRightEye(),this.getMouth()].map(W)}},se=class{constructor(e,n){this._label=e,this._distance=n}get label(){return this._label}get distance(){return this._distance}toString(e=!0){return`${this.label}${e?` (${M(this.distance)})`:""}`}},ce=class extends Z{static assertIsValidLabeledBox(e,n){if(Z.assertIsValidBox(e,n),!U(e.label))throw new Error(`${n} - expected property label (${e.label}) to be a number`)}constructor(e,n){super(e),this._label=n}get label(){return this._label}},le=class e{constructor(e,n){if("string"!=typeof e)throw new Error("LabeledFaceDescriptors - constructor expected label to be a string");if(!Array.isArray(n)||n.some((e=>!(e instanceof Float32Array))))throw new Error("LabeledFaceDescriptors - constructor expected descriptors to be an array of Float32Array");this._label=e,this._descriptors=n}get label(){return this._label}get descriptors(){return this._descriptors}toJSON(){return{label:this.label,descriptors:this.descriptors.map((e=>Array.from(e)))}}static fromJSON(n){let t=n.descriptors.map((e=>new Float32Array(e)));return new e(n.label,t)}};function de(e){return e.detection instanceof J}function ue(e,n){return{...e,detection:n}}function pe(){let e=window.fetch;if(!e)throw new Error("fetch - missing fetch implementation for browser environment");return{Canvas:HTMLCanvasElement,CanvasRenderingContext2D:CanvasRenderingContext2D,Image:HTMLImageElement,ImageData:ImageData,Video:HTMLVideoElement,createCanvasElement:()=>document.createElement("canvas"),createImageElement:()=>document.createElement("img"),createVideoElement:()=>document.createElement("video"),fetch:e,readFile:()=>{throw new Error("readFile - filesystem not available for browser environment")}}}function fe(){return"object"==typeof global&&"undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node}function he(e){let n="";if(!e&&fe())try{e=_("fs")}catch(t){n=t.toString()}return{readFile:e?n=>new Promise(((t,o)=>{e.readFile(n,((e,n)=>e?o(e):t(n)))})):()=>{throw new Error(`readFile - failed to require fs in nodejs environment with error: ${n}`)}}}function me(){let e=global.Canvas||global.HTMLCanvasElement,n=global.Image||global.HTMLImageElement,t=global.Video||global.HTMLVideoElement,o=global.fetch,r=he();return{Canvas:e||class{},CanvasRenderingContext2D:global.CanvasRenderingContext2D||class{},Image:n||class{},ImageData:global.ImageData||class{},Video:global.HTMLVideoElement||class{},createCanvasElement:()=>{if(e)return new e;throw new Error("createCanvasElement - missing Canvas implementation for nodejs environment")},createImageElement:()=>{if(n)return new n;throw new Error("createImageElement - missing Image implementation for nodejs environment")},createVideoElement:()=>{if(t)return new t;throw new Error("createVideoElement - missing Video implementation for nodejs environment")},fetch:o,...r}}function ge(){return"object"==typeof window&&"undefined"!=typeof document&&"undefined"!=typeof HTMLImageElement&&"undefined"!=typeof HTMLCanvasElement&&"undefined"!=typeof HTMLVideoElement&&"undefined"!=typeof ImageData&&"undefined"!=typeof CanvasRenderingContext2D}function ve(e){oe=e}function we(){return ge()?ve(pe()):fe()?ve(me()):null}var be={getEnv:function(){if(!oe)throw new Error("getEnv - environment is not defined, check isNodejs() and isBrowser()");return oe},setEnv:ve,initialize:we,createBrowserEnv:pe,createFileSystem:he,createNodejsEnv:me,monkeyPatch:function(e){if(oe||we(),!oe)throw new Error("monkeyPatch - environment is not defined, check isNodejs() and isBrowser()");let{Canvas:n=oe.Canvas,Image:t=oe.Image}=e;oe.Canvas=n,oe.Image=t,oe.createCanvasElement=e.createCanvasElement||(()=>new n),oe.createImageElement=e.createImageElement||(()=>new t),oe.ImageData=e.ImageData||oe.ImageData,oe.Video=e.Video||oe.Video,oe.fetch=e.fetch||oe.fetch,oe.readFile=e.readFile||oe.readFile},isBrowser:ge,isNodejs:fe};function xe(e){return be.isNodejs()||"string"!=typeof e?e:document.getElementById(e)}function ye(e){let{Canvas:n,CanvasRenderingContext2D:t}=be.getEnv();if(e instanceof t)return e;let o=xe(e);if(!(o instanceof n))throw new Error("resolveContext2d - expected canvas to be of instance of Canvas");let r=o.getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("resolveContext2d - canvas 2d context is null");return r}we();var _e,ke=((_e=ke||{}).TOP_LEFT="TOP_LEFT",_e.TOP_RIGHT="TOP_RIGHT",_e.BOTTOM_LEFT="BOTTOM_LEFT",_e.BOTTOM_RIGHT="BOTTOM_RIGHT",_e),Ee=class{constructor(e={}){let{anchorPosition:n,backgroundColor:t,fontColor:o,fontSize:r,fontStyle:a,padding:i}=e;this.anchorPosition=n||"TOP_LEFT",this.backgroundColor=t||"rgba(0, 0, 0, 0.5)",this.fontColor=o||"rgba(255, 255, 255, 1)",this.fontSize=r||14,this.fontStyle=a||"Georgia",this.padding=i||4}},Te=class e{constructor(n,t,o={}){this.text="string"==typeof n?[n]:n instanceof e?n.text:n,this.anchor=t,this.options=new Ee(o)}measureWidth(e){let{padding:n}=this.options;return this.text.map((n=>e.measureText(n).width)).reduce(((e,n)=>e<n?n:e),0)+2*n}measureHeight(){let{fontSize:e,padding:n}=this.options;return this.text.length*e+2*n}getUpperLeft(e,n){let{anchorPosition:t}=this.options,o="BOTTOM_RIGHT"===t||"TOP_RIGHT"===t,r="BOTTOM_LEFT"===t||"BOTTOM_RIGHT"===t,a=this.measureWidth(e),i=this.measureHeight(),s=o?this.anchor.x-a:this.anchor.x,c=r?this.anchor.y-i:this.anchor.y;if(n){let{width:e,height:t}=n;return{x:Math.max(Math.min(s,e-a),0),y:Math.max(Math.min(c,t-i),0)}}return{x:s,y:c}}draw(e){let n=xe(e),t=ye(n),{backgroundColor:o,fontColor:r,fontSize:a,fontStyle:i,padding:s}=this.options;t.font=`${a}px ${i}`;let c=this.measureWidth(t),l=this.measureHeight();t.fillStyle=o;let d=this.getUpperLeft(t,n);t.fillRect(d.x,d.y,c,l),t.fillStyle=r,this.text.forEach(((e,n)=>{let o=s+d.x,r=s+d.y+(n+1)*a;t.fillText(e,o,r)}))}},Ne=class{constructor(e={}){let{boxColor:n,lineWidth:t,label:o,drawLabelOptions:r}=e;this.boxColor=n||"rgba(0, 0, 255, 1)",this.lineWidth=t||2,this.label=o;let a={anchorPosition:"BOTTOM_LEFT",backgroundColor:this.boxColor};this.drawLabelOptions=new Ee({...a,...r})}},Se=class{constructor(e,n={}){this.box=new Z(e),this.options=new Ne(n)}draw(e){let n=ye(e),{boxColor:t,lineWidth:o}=this.options,{x:r,y:a,width:i,height:s}=this.box;n.strokeStyle=t,n.lineWidth=o,n.strokeRect(r,a,i,s);let{label:c}=this.options;c&&new Te([c],{x:r-o/2,y:a},this.options.drawLabelOptions).draw(e)}};function Ce(e,n){(Array.isArray(n)?n:[n]).forEach((n=>{let t=n instanceof J?n.score:de(n)?n.detection.score:void 0,o=n instanceof J?n.box:de(n)?n.detection.box:new Z(n),r=t?`${M(t)}`:void 0;new Se(o,{label:r}).draw(e)}))}function Ie(e){let{Image:n,Video:t}=be.getEnv();return e instanceof n&&e.complete||e instanceof t&&e.readyState>=3}function Re(e){return new Promise(((n,t)=>{function o(e){e.currentTarget&&(e.currentTarget.removeEventListener("load",r),e.currentTarget.removeEventListener("error",o),t(e))}function r(e){e.currentTarget&&(e.currentTarget.removeEventListener("load",r),e.currentTarget.removeEventListener("error",o),n(e))}e instanceof be.getEnv().Canvas||Ie(e)?n(null):(e.addEventListener("load",r),e.addEventListener("error",o))}))}function Oe(e){return new Promise(((n,t)=>{e instanceof Blob||t(new Error("bufferToImage - expected buf to be of type: Blob"));let o=new FileReader;o.onload=()=>{"string"!=typeof o.result&&t(new Error("bufferToImage - expected reader.result to be a string, in onload"));let e=be.getEnv().createImageElement();e.onload=()=>n(e),e.onerror=t,e.src=o.result},o.onerror=t,o.readAsDataURL(e)}))}function je(e){let{Image:n,Video:t}=be.getEnv();return e instanceof n?new O(e.naturalWidth,e.naturalHeight):e instanceof t?new O(e.videoWidth,e.videoHeight):new O(e.width,e.height)}function Ae({width:e,height:n}){let{createCanvasElement:t}=be.getEnv(),o=t();return o.width=e,o.height=n,o}function Pe(e,n){let{ImageData:t}=be.getEnv();if(!(e instanceof t||Ie(e)))throw new Error("createCanvasFromMedia - media has not finished loading yet");let{width:o,height:r}=n||je(e),a=Ae({width:o,height:r});return e instanceof t?ye(a).putImageData(e,0,0):ye(a).drawImage(e,0,0,o,r),a}async function Fe(e,n){let t=n||be.getEnv().createCanvasElement(),[o,r,a]=e.shape.slice(z(e)?1:0),i=T.tidy((()=>e.as3D(o,r,a).toInt()));return await T.browser.toPixels(i,t),i.dispose(),t}function ze(e){let{Image:n,Canvas:t,Video:o}=be.getEnv();return e instanceof n||e instanceof t||e instanceof o}function $e(e,n,t=!1){let{Image:o,Canvas:r}=be.getEnv();if(!(e instanceof o||e instanceof r))throw new Error("imageToSquare - expected arg0 to be HTMLImageElement | HTMLCanvasElement");if(n<=0)return Ae({width:1,height:1});let a=je(e),i=n/Math.max(a.height,a.width),s=i*a.width,c=i*a.height,l=Ae({width:n,height:n}),d=e instanceof r?e:Pe(e),u=Math.abs(s-c)/2,p=t&&s<c?u:0,f=t&&c<s?u:0;return d.width>0&&d.height>0&&ye(l).drawImage(d,p,f,s,c),l}var De=class{constructor(e,n=!1){if(this._imageTensors=[],this._canvases=[],this._treatAsBatchInput=!1,this._inputDimensions=[],this._inputSize=0,!Array.isArray(e))throw new Error(`NetInput.constructor - expected inputs to be an Array of TResolvedNetInput or to be instanceof tf.Tensor4D, instead have ${e}`);this._treatAsBatchInput=n,this._batchSize=e.length,e.forEach(((e,n)=>{if(F(e))return this._imageTensors[n]=e,void(this._inputDimensions[n]=e.shape);if(z(e)){let t=e.shape[0];if(1!==t)throw new Error(`NetInput - tf.Tensor4D with batchSize ${t} passed, but not supported in input array`);return this._imageTensors[n]=e,void(this._inputDimensions[n]=e.shape.slice(1))}let t=e instanceof be.getEnv().Canvas?e:Pe(e);this._canvases[n]=t,this._inputDimensions[n]=[t.height,t.width,3]}))}get imageTensors(){return this._imageTensors}get canvases(){return this._canvases}get isBatchInput(){return this.batchSize>1||this._treatAsBatchInput}get batchSize(){return this._batchSize}get inputDimensions(){return this._inputDimensions}get inputSize(){return this._inputSize}get reshapedInputDimensions(){return q(this.batchSize,0,1).map(((e,n)=>this.getReshapedInputDimensions(n)))}getInput(e){return this.canvases[e]||this.imageTensors[e]}getInputDimensions(e){return this._inputDimensions[e]}getInputHeight(e){return this._inputDimensions[e][0]}getInputWidth(e){return this._inputDimensions[e][1]}getReshapedInputDimensions(e){if("number"!=typeof this.inputSize)throw new Error("getReshapedInputDimensions - inputSize not set, toBatchTensor has not been called yet");return B({width:this.getInputWidth(e),height:this.getInputHeight(e)},this.inputSize)}toBatchTensor(e,n=!0){return this._inputSize=e,T.tidy((()=>{let t=q(this.batchSize,0,1).map((t=>{let o=this.getInput(t);if(o instanceof T.Tensor){let t=z(o)?o:T.expandDims(o);return t=ne(t,n),(t.shape[1]!==e||t.shape[2]!==e)&&(t=T.image.resizeBilinear(t,[e,e],!1,!1)),t.as3D(e,e,3)}if(o instanceof be.getEnv().Canvas)return T.browser.fromPixels($e(o,e,n));throw new Error(`toBatchTensor - at batchIdx ${t}, expected input to be instanceof tf.Tensor or instanceof HTMLCanvasElement, instead have ${o}`)}));return T.stack(t.map((e=>T.cast(e,"float32")))).as4D(this.batchSize,e,e,3)}))}};async function Me(e){if(e instanceof De)return e;let n=Array.isArray(e)?e:[e];if(!n.length)throw new Error("toNetInput - empty array passed as input");let t=n=>Array.isArray(e)?` at input index ${n}:`:"",o=n.map(xe);return o.forEach(((e,o)=>{if(!ze(e)&&!F(e)&&!z(e))throw"string"==typeof n[o]?new Error(`toNetInput -${t(o)} string passed, but could not resolve HTMLElement for element id ${n[o]}`):new Error(`toNetInput -${t(o)} expected media to be of type HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | tf.Tensor3D, or to be an element id`);if(z(e)){let n=e.shape[0];if(1!==n)throw new Error(`toNetInput -${t(o)} tf.Tensor4D with batchSize ${n} passed, but not supported in input array`)}})),await Promise.all(o.map((e=>ze(e)&&Re(e)))),new De(o,Array.isArray(e))}async function Le(e,n){let{Canvas:t}=be.getEnv(),o=e;if(!(e instanceof t)){let n=await Me(e);if(n.batchSize>1)throw new Error("extractFaces - batchSize > 1 not supported");let r=n.getInput(0);o=r instanceof t?r:await Fe(r)}let r=ye(o);return n.map((e=>e instanceof J?e.forSize(o.width,o.height).box.floor():e)).map((e=>e.clipAtImageBorders(o.width,o.height))).map((({x:e,y:n,width:t,height:o})=>{let a=Ae({width:t,height:o});return t>0&&o>0&&ye(a).putImageData(r.getImageData(e,n,t,o),0,0),a}))}async function Be(e,n){if(!F(e)&&!z(e))throw new Error("extractFaceTensors - expected image tensor to be 3D or 4D");if(z(e)&&e.shape[0]>1)throw new Error("extractFaceTensors - batchSize > 1 not supported");return T.tidy((()=>{let[t,o,r]=e.shape.slice(z(e)?1:0);return n.map((e=>e instanceof J?e.forSize(o,t).box:e)).map((e=>e.clipAtImageBorders(o,t))).filter((e=>e.width>0&&e.height>0)).map((({x:n,y:a,width:i,height:s})=>T.slice3d(e.as3D(t,o,r),[a,n,0],[s,i,r])))}))}async function We(e,n){let{fetch:t}=be.getEnv(),o=await t(e,n);if(!(o.status<400))throw new Error(`failed to fetch: (${o.status}) ${o.statusText}, from url: ${o.url}`);return o}async function qe(e){return(await We(e)).json()}function Ue(e,n){let t=`${n}-weights_manifest.json`;if(!e)return{modelBaseUri:"",manifestUri:t};if("/"===e)return{modelBaseUri:"/",manifestUri:`/${t}`};let o=e.startsWith("http://")?"http://":e.startsWith("https://")?"https://":"",r=(e=e.replace(o,"")).split("/").filter((e=>e)),a=e.endsWith(".json")?r[r.length-1]:t,i=o+(e.endsWith(".json")?r.slice(0,r.length-1):r).join("/");return i=e.startsWith("/")?`/${i}`:i,{modelBaseUri:i,manifestUri:"/"===i?`/${a}`:`${i}/${a}`}}async function Ve(e,n){let{manifestUri:t,modelBaseUri:o}=Ue(e,n),r=await qe(t);return T.io.loadWeights(r,o)}var Ke=class{constructor(e){this._params=void 0,this._paramMappings=[],this._name=e}get params(){return this._params}get paramMappings(){return this._paramMappings}get isLoaded(){return!!this.params}getParamFromPath(e){let{obj:n,objProp:t}=this.traversePropertyPath(e);return n[t]}reassignParamFromPath(e,n){let{obj:t,objProp:o}=this.traversePropertyPath(e);t[o].dispose(),t[o]=n}getParamList(){return this._paramMappings.map((({paramPath:e})=>({path:e,tensor:this.getParamFromPath(e)})))}getTrainableParams(){return this.getParamList().filter((e=>e.tensor instanceof T.Variable))}getFrozenParams(){return this.getParamList().filter((e=>!(e.tensor instanceof T.Variable)))}variable(){this.getFrozenParams().forEach((({path:e,tensor:n})=>{this.reassignParamFromPath(e,n.variable())}))}freeze(){this.getTrainableParams().forEach((({path:e,tensor:n})=>{let t=T.tensor(n.dataSync());n.dispose(),this.reassignParamFromPath(e,t)}))}dispose(e=!0){this.getParamList().forEach((n=>{if(e&&n.tensor.isDisposed)throw new Error(`param tensor has already been disposed for path ${n.path}`);n.tensor.dispose()})),this._params=void 0}serializeParams(){return new Float32Array(this.getParamList().map((({tensor:e})=>Array.from(e.dataSync()))).reduce(((e,n)=>e.concat(n))))}async load(e){e instanceof Float32Array?this.extractWeights(e):await this.loadFromUri(e)}async loadFromUri(e){if(e&&"string"!=typeof e)throw new Error(`${this._name}.loadFromUri - expected model uri`);let n=await Ve(e,this.getDefaultModelName());this.loadFromWeightMap(n)}async loadFromDisk(e){if(e&&"string"!=typeof e)throw new Error(`${this._name}.loadFromDisk - expected model file path`);let{readFile:n}=be.getEnv(),{manifestUri:t,modelBaseUri:o}=Ue(e,this.getDefaultModelName()),r=T.io.weightsLoaderFactory((e=>Promise.all(e.map((e=>n(e).then((e=>"string"==typeof e?Buffer.from(e):e.buffer))))))),a=JSON.parse((await n(t)).toString()),i=await r(a,o);this.loadFromWeightMap(i)}loadFromWeightMap(e){let{paramMappings:n,params:t}=this.extractParamsFromWeightMap(e);this._paramMappings=n,this._params=t}extractWeights(e){let{paramMappings:n,params:t}=this.extractParams(e);this._paramMappings=n,this._params=t}traversePropertyPath(e){if(!this.params)throw new Error("traversePropertyPath - model has no loaded params");let n=e.split("/").reduce(((n,t)=>{if(!n.nextObj.hasOwnProperty(t))throw new Error(`traversePropertyPath - object does not have property ${t}, for path ${e}`);return{obj:n.nextObj,objProp:t,nextObj:n.nextObj[t]}}),{nextObj:this.params}),{obj:t,objProp:o}=n;if(!(t&&o&&t[o]instanceof T.Tensor))throw new Error(`traversePropertyPath - parameter is not a tensor, for path ${e}`);return{obj:t,objProp:o}}};function Ze(e,n,t){return T.tidy((()=>{let o=T.separableConv2d(e,n.depthwise_filter,n.pointwise_filter,t,"same");return o=T.add(o,n.bias),o}))}function He(e,n,t=!1){return T.tidy((()=>{let o=T.relu(t?T.add(T.conv2d(e,n.conv0.filters,[2,2],"same"),n.conv0.bias):Ze(e,n.conv0,[2,2])),r=Ze(o,n.conv1,[1,1]),a=Ze(T.relu(T.add(o,r)),n.conv2,[1,1]);return T.relu(T.add(o,T.add(r,a)))}))}function Ge(e,n,t=!1,o=!0){return T.tidy((()=>{let r=T.relu(t?T.add(T.conv2d(e,n.conv0.filters,o?[2,2]:[1,1],"same"),n.conv0.bias):Ze(e,n.conv0,o?[2,2]:[1,1])),a=Ze(r,n.conv1,[1,1]),i=Ze(T.relu(T.add(r,a)),n.conv2,[1,1]),s=Ze(T.relu(T.add(r,T.add(a,i))),n.conv3,[1,1]);return T.relu(T.add(r,T.add(a,T.add(i,s))))}))}function Je(e,n,t="same",o=!1){return T.tidy((()=>{let r=T.add(T.conv2d(e,n.filters,[1,1],t),n.bias);return o?T.relu(r):r}))}function Xe(e,n){Object.keys(e).forEach((t=>{n.some((e=>e.originalPath===t))||e[t].dispose()}))}function Ye(e,n){return(t,o,r,a)=>{let i=T.tensor4d(e(t*o*r*r),[r,r,t,o]),s=T.tensor1d(e(o));return n.push({paramPath:`${a}/filters`},{paramPath:`${a}/bias`}),{filters:i,bias:s}}}function Qe(e,n){return(t,o,r)=>{let a=T.tensor2d(e(t*o),[t,o]),i=T.tensor1d(e(o));return n.push({paramPath:`${r}/weights`},{paramPath:`${r}/bias`}),{weights:a,bias:i}}}var en=class{constructor(e,n,t){this.depthwise_filter=e,this.pointwise_filter=n,this.bias=t}};function nn(e,n){return(t,o,r)=>{let a=T.tensor4d(e(9*t),[3,3,t,1]),i=T.tensor4d(e(t*o),[1,1,t,o]),s=T.tensor1d(e(o));return n.push({paramPath:`${r}/depthwise_filter`},{paramPath:`${r}/pointwise_filter`},{paramPath:`${r}/bias`}),new en(a,i,s)}}function tn(e){return n=>{let t=e(`${n}/depthwise_filter`,4),o=e(`${n}/pointwise_filter`,4),r=e(`${n}/bias`,1);return new en(t,o,r)}}function on(e,n){return(t,o,r)=>{let a=e[t];if(!j(a,o))throw new Error(`expected weightMap[${t}] to be a Tensor${o}D, instead have ${a}`);return n.push({originalPath:t,paramPath:r||t}),a}}function rn(e){let n=e;return{extractWeights:function(e){let t=n.slice(0,e);return n=n.slice(e),t},getRemainingWeights:function(){return n}}}function an(e,n){let t=Ye(e,n),o=nn(e,n);function r(e,n,r,a=!1){return{conv0:a?t(e,n,3,`${r}/conv0`):o(e,n,`${r}/conv0`),conv1:o(n,n,`${r}/conv1`),conv2:o(n,n,`${r}/conv2`)}}return{extractDenseBlock3Params:r,extractDenseBlock4Params:function(e,n,t,a=!1){let{conv0:i,conv1:s,conv2:c}=r(e,n,t,a);return{conv0:i,conv1:s,conv2:c,conv3:o(n,n,`${t}/conv3`)}}}}function sn(e){return n=>({filters:e(`${n}/filters`,4),bias:e(`${n}/bias`,1)})}function cn(e,n){let t=on(e,n),o=sn(t),r=tn(t);return{extractDenseBlock3Params:function(e,n=!1){return{conv0:n?o(`${e}/conv0`):r(`${e}/conv0`),conv1:r(`${e}/conv1`),conv2:r(`${e}/conv2`)}},extractDenseBlock4Params:function(e,n=!1){return{conv0:n?o(`${e}/conv0`):r(`${e}/conv0`),conv1:r(`${e}/conv1`),conv2:r(`${e}/conv2`),conv3:r(`${e}/conv3`)}}}}var ln=class extends Ke{constructor(){super("FaceFeatureExtractor")}forwardInput(e){let{params:n}=this;if(!n)throw new Error("FaceFeatureExtractor - load model before inference");return T.tidy((()=>{let t=Ge(ee(T.cast(e.toBatchTensor(112,!0),"float32"),[122.782,117.001,104.298]).div(255),n.dense0,!0);return t=Ge(t,n.dense1),t=Ge(t,n.dense2),t=Ge(t,n.dense3),t=T.avgPool(t,[7,7],[2,2],"valid"),t}))}async forward(e){return this.forwardInput(await Me(e))}getDefaultModelName(){return"face_feature_extractor_model"}extractParamsFromWeightMap(e){return function(e){let n=[],{extractDenseBlock4Params:t}=cn(e,n),o={dense0:t("dense0",!0),dense1:t("dense1"),dense2:t("dense2"),dense3:t("dense3")};return Xe(e,n),{params:o,paramMappings:n}}(e)}extractParams(e){return function(e){let n=[],{extractWeights:t,getRemainingWeights:o}=rn(e),{extractDenseBlock4Params:r}=an(t,n),a=r(3,32,"dense0",!0),i=r(32,64,"dense1"),s=r(64,128,"dense2"),c=r(128,256,"dense3");if(0!==o().length)throw new Error(`weights remaing after extract: ${o().length}`);return{paramMappings:n,params:{dense0:a,dense1:i,dense2:s,dense3:c}}}(e)}};function dn(e,n){return T.tidy((()=>T.add(T.matMul(e,n.weights),n.bias)))}function un(e){let n={},t={};return Object.keys(e).forEach((o=>{(o.startsWith("fc")?t:n)[o]=e[o]})),{featureExtractorMap:n,classifierMap:t}}var pn=class extends Ke{constructor(e,n){super(e),this._faceFeatureExtractor=n}get faceFeatureExtractor(){return this._faceFeatureExtractor}runNet(e){let{params:n}=this;if(!n)throw new Error(`${this._name} - load model before inference`);return T.tidy((()=>{let t=e instanceof De?this.faceFeatureExtractor.forwardInput(e):e;return dn(t.as2D(t.shape[0],-1),n.fc)}))}dispose(e=!0){this.faceFeatureExtractor.dispose(e),super.dispose(e)}loadClassifierParams(e){let{params:n,paramMappings:t}=this.extractClassifierParams(e);this._params=n,this._paramMappings=t}extractClassifierParams(e){return function(e,n,t){let o=[],{extractWeights:r,getRemainingWeights:a}=rn(e),i=Qe(r,o)(n,t,"fc");if(0!==a().length)throw new Error(`weights remaing after extract: ${a().length}`);return{paramMappings:o,params:{fc:i}}}(e,this.getClassifierChannelsIn(),this.getClassifierChannelsOut())}extractParamsFromWeightMap(e){let{featureExtractorMap:n,classifierMap:t}=un(e);return this.faceFeatureExtractor.loadFromWeightMap(n),function(e){let n=[],t=on(e,n),o={fc:(r="fc",{weights:t(`${r}/weights`,2),bias:t(`${r}/bias`,1)})};var r;return Xe(e,n),{params:o,paramMappings:n}}(t)}extractParams(e){let n=this.getClassifierChannelsIn(),t=this.getClassifierChannelsOut(),o=t*n+t,r=e.slice(0,e.length-o),a=e.slice(e.length-o);return this.faceFeatureExtractor.extractWeights(r),this.extractClassifierParams(a)}},fn=["neutral","happy","sad","angry","fearful","disgusted","surprised"],hn=class{constructor(e){if(this.neutral=0,this.happy=0,this.sad=0,this.angry=0,this.fearful=0,this.disgusted=0,this.surprised=0,7!==e.length)throw new Error(`FaceExpressions.constructor - expected probabilities.length to be 7, have: ${e.length}`);fn.forEach(((n,t)=>{this[n]=e[t]}))}asSortedArray(){return fn.map((e=>({expression:e,probability:this[e]}))).sort(((e,n)=>n.probability-e.probability))}},mn=class extends pn{constructor(e=new ln){super("FaceExpressionNet",e)}forwardInput(e){return T.tidy((()=>T.softmax(this.runNet(e))))}async forward(e){return this.forwardInput(await Me(e))}async predictExpressions(e){let n=await Me(e),t=await this.forwardInput(n),o=await Promise.all(T.unstack(t).map((async e=>{let n=e.dataSync();return e.dispose(),n})));t.dispose();let r=o.map((e=>new hn(e)));return n.isBatchInput?r:r[0]}getDefaultModelName(){return"face_expression_model"}getClassifierChannelsIn(){return 256}getClassifierChannelsOut(){return 7}};function gn(e){return e.expressions instanceof hn}function vn(e,n){return{...e,expressions:n}}function wn(e,n,t=.1,o){(Array.isArray(n)?n:[n]).forEach((n=>{let r=n instanceof hn?n:gn(n)?n.expressions:void 0;if(!r)throw new Error("drawFaceExpressions - expected faceExpressions to be FaceExpressions | WithFaceExpressions<{}> or array thereof");let a=r.asSortedArray().filter((e=>e.probability>t)),i=de(n)?n.detection.box.bottomLeft:o||new K(0,0);new Te(a.map((e=>`${e.expression} (${M(e.probability)})`)),i).draw(e)}))}function bn(e){return de(e)&&e.landmarks instanceof ae&&e.unshiftedLandmarks instanceof ae&&e.alignedRect instanceof J}function xn(e,n){let{box:t}=e.detection,o=n.shiftBy(t.x,t.y),r=o.align(),{imageDims:a}=e.detection,i=new J(e.detection.score,r.rescale(a.reverse()),a),s=function(e){let n=e=>180*e/Math.PI,t=(e,n)=>Math.sqrt((e.x-n.x)**2+(e.y-n.y)**2),o={roll:void 0,pitch:void 0,yaw:void 0};if(!e||!e.positions||68!==e.positions.length)return o;let r=e.positions;return o.roll=((e,t)=>{let o=Math.hypot(t.x-e.x,t.y-e.y),r=t.y-e.y,a=Math.asin(r/o),i=n(a);return Math.floor(90-i)*(t.x-e.x<0?-1:1)})(r[27],r[66]),o.pitch=((e,o,r)=>{let a=t(e,r),i=new K((e.x+r.x)/2,(e.y+r.y)/2),s=t(o,i),c=Math.atan(s/a);return Math.floor(n(c))*(i.y-o.y<0?-1:1)})(r[14],r[30],r[2]),o.yaw=(a=r[14],i=r[33],s=r[2],Math.floor(a.x-i.x)-Math.floor(i.x-s.x)),o;var a,i,s}(n);return{...e,landmarks:o,unshiftedLandmarks:n,alignedRect:i,angle:s}}var yn=class{constructor(e={}){let{drawLines:n=!0,drawPoints:t=!0,lineWidth:o,lineColor:r,pointSize:a,pointColor:i}=e;this.drawLines=n,this.drawPoints=t,this.lineWidth=o||1,this.pointSize=a||2,this.lineColor=r||"rgba(0, 255, 255, 1)",this.pointColor=i||"rgba(255, 0, 255, 1)"}},_n=class{constructor(e,n={}){this.faceLandmarks=e,this.options=new yn(n)}draw(e){let n=ye(e),{drawLines:t,drawPoints:o,lineWidth:r,lineColor:a,pointSize:i,pointColor:s}=this.options;if(t&&this.faceLandmarks instanceof ie&&(n.strokeStyle=a,n.lineWidth=r,I(n,this.faceLandmarks.getJawOutline()),I(n,this.faceLandmarks.getLeftEyeBrow()),I(n,this.faceLandmarks.getRightEyeBrow()),I(n,this.faceLandmarks.getNose()),I(n,this.faceLandmarks.getLeftEye(),!0),I(n,this.faceLandmarks.getRightEye(),!0),I(n,this.faceLandmarks.getMouth(),!0)),o){n.strokeStyle=s,n.fillStyle=s;let e=e=>{n.beginPath(),n.arc(e.x,e.y,i,0,2*Math.PI),n.fill()};this.faceLandmarks.positions.forEach(e)}}};function kn(e,n){(Array.isArray(n)?n:[n]).forEach((n=>{let t=n instanceof ae?n:bn(n)?n.landmarks:void 0;if(!t)throw new Error("drawFaceLandmarks - expected faceExpressions to be FaceLandmarks | WithFaceLandmarks<WithFaceDetection<{}>> or array thereof");new _n(t).draw(e)}))}function En(e,n){let t=[],{extractWeights:o,getRemainingWeights:r}=rn(e),{extractConvParams:a,extractSeparableConvParams:i,extractReductionBlockParams:s,extractMainBlockParams:c}=function(e,n){let t=Ye(e,n),o=nn(e,n);return{extractConvParams:t,extractSeparableConvParams:o,extractReductionBlockParams:function(e,n,r){return{separable_conv0:o(e,n,`${r}/separable_conv0`),separable_conv1:o(n,n,`${r}/separable_conv1`),expansion_conv:t(e,n,1,`${r}/expansion_conv`)}},extractMainBlockParams:function(e,n){return{separable_conv0:o(e,e,`${n}/separable_conv0`),separable_conv1:o(e,e,`${n}/separable_conv1`),separable_conv2:o(e,e,`${n}/separable_conv2`)}}}}(o,t),l={conv_in:a(3,32,3,"entry_flow/conv_in"),reduction_block_0:s(32,64,"entry_flow/reduction_block_0"),reduction_block_1:s(64,128,"entry_flow/reduction_block_1")},d={};q(n,0,1).forEach((e=>{d[`main_block_${e}`]=c(128,`middle_flow/main_block_${e}`)}));let u={reduction_block:s(128,256,"exit_flow/reduction_block"),separable_conv:i(256,512,"exit_flow/separable_conv")};if(0!==r().length)throw new Error(`weights remaing after extract: ${r().length}`);return{paramMappings:t,params:{entry_flow:l,middle_flow:d,exit_flow:u}}}function Tn(e,n){let t=[],{extractConvParams:o,extractSeparableConvParams:r,extractReductionBlockParams:a,extractMainBlockParams:i}=function(e,n){let t=on(e,n),o=sn(t),r=tn(t);return{extractConvParams:o,extractSeparableConvParams:r,extractReductionBlockParams:function(e){return{separable_conv0:r(`${e}/separable_conv0`),separable_conv1:r(`${e}/separable_conv1`),expansion_conv:o(`${e}/expansion_conv`)}},extractMainBlockParams:function(e){return{separable_conv0:r(`${e}/separable_conv0`),separable_conv1:r(`${e}/separable_conv1`),separable_conv2:r(`${e}/separable_conv2`)}}}}(e,t),s={conv_in:o("entry_flow/conv_in"),reduction_block_0:a("entry_flow/reduction_block_0"),reduction_block_1:a("entry_flow/reduction_block_1")},c={};q(n,0,1).forEach((e=>{c[`main_block_${e}`]=i(`middle_flow/main_block_${e}`)}));let l={reduction_block:a("exit_flow/reduction_block"),separable_conv:r("exit_flow/separable_conv")};return Xe(e,t),{params:{entry_flow:s,middle_flow:c,exit_flow:l},paramMappings:t}}function Nn(e,n,t){return T.add(T.conv2d(e,n.filters,t,"same"),n.bias)}function Sn(e,n,t=!0){let o=t?T.relu(e):e;return o=Ze(o,n.separable_conv0,[1,1]),o=Ze(T.relu(o),n.separable_conv1,[1,1]),o=T.maxPool(o,[3,3],[2,2],"same"),o=T.add(o,Nn(e,n.expansion_conv,[2,2])),o}var Cn=class extends Ke{constructor(e){super("TinyXception"),this._numMainBlocks=e}forwardInput(e){let{params:n}=this;if(!n)throw new Error("TinyXception - load model before inference");return T.tidy((()=>{let t=ee(T.cast(e.toBatchTensor(112,!0),"float32"),[122.782,117.001,104.298]).div(255),o=T.relu(Nn(t,n.entry_flow.conv_in,[2,2]));return o=Sn(o,n.entry_flow.reduction_block_0,!1),o=Sn(o,n.entry_flow.reduction_block_1),q(this._numMainBlocks,0,1).forEach((e=>{o=function(e,n){let t=Ze(T.relu(e),n.separable_conv0,[1,1]);return t=Ze(T.relu(t),n.separable_conv1,[1,1]),t=Ze(T.relu(t),n.separable_conv2,[1,1]),t=T.add(t,e),t}(o,n.middle_flow[`main_block_${e}`])})),o=Sn(o,n.exit_flow.reduction_block),o=T.relu(Ze(o,n.exit_flow.separable_conv,[1,1])),o}))}async forward(e){return this.forwardInput(await Me(e))}getDefaultModelName(){return"tiny_xception_model"}extractParamsFromWeightMap(e){return Tn(e,this._numMainBlocks)}extractParams(e){return En(e,this._numMainBlocks)}};var In,Rn=((In=Rn||{}).FEMALE="female",In.MALE="male",In),On=class extends Ke{constructor(e=new Cn(2)){super("AgeGenderNet"),this._faceFeatureExtractor=e}get faceFeatureExtractor(){return this._faceFeatureExtractor}runNet(e){let{params:n}=this;if(!n)throw new Error(`${this._name} - load model before inference`);return T.tidy((()=>{let t=e instanceof De?this.faceFeatureExtractor.forwardInput(e):e,o=T.avgPool(t,[7,7],[2,2],"valid").as2D(t.shape[0],-1);return{age:dn(o,n.fc.age).as1D(),gender:dn(o,n.fc.gender)}}))}forwardInput(e){return T.tidy((()=>{let{age:n,gender:t}=this.runNet(e);return{age:n,gender:T.softmax(t)}}))}async forward(e){return this.forwardInput(await Me(e))}async predictAgeAndGender(e){let n=await Me(e),t=await this.forwardInput(n),o=T.unstack(t.age),r=T.unstack(t.gender),a=o.map(((e,n)=>({ageTensor:e,genderTensor:r[n]}))),i=await Promise.all(a.map((async({ageTensor:e,genderTensor:n})=>{let t=e.dataSync()[0],o=n.dataSync()[0],r=o>.5,a=r?"male":"female",i=r?o:1-o;return e.dispose(),n.dispose(),{age:t,gender:a,genderProbability:i}})));return t.age.dispose(),t.gender.dispose(),n.isBatchInput?i:i[0]}getDefaultModelName(){return"age_gender_model"}dispose(e=!0){this.faceFeatureExtractor.dispose(e),super.dispose(e)}loadClassifierParams(e){let{params:n,paramMappings:t}=this.extractClassifierParams(e);this._params=n,this._paramMappings=t}extractClassifierParams(e){return function(e){let n=[],{extractWeights:t,getRemainingWeights:o}=rn(e),r=Qe(t,n),a=r(512,1,"fc/age"),i=r(512,2,"fc/gender");if(0!==o().length)throw new Error(`weights remaing after extract: ${o().length}`);return{paramMappings:n,params:{fc:{age:a,gender:i}}}}(e)}extractParamsFromWeightMap(e){let{featureExtractorMap:n,classifierMap:t}=un(e);return this.faceFeatureExtractor.loadFromWeightMap(n),function(e){let n=[],t=on(e,n);function o(e){return{weights:t(`${e}/weights`,2),bias:t(`${e}/bias`,1)}}let r={fc:{age:o("fc/age"),gender:o("fc/gender")}};return Xe(e,n),{params:r,paramMappings:n}}(t)}extractParams(e){let n=e.slice(0,e.length-1539),t=e.slice(e.length-1539);return this.faceFeatureExtractor.extractWeights(n),this.extractClassifierParams(t)}},jn=class extends pn{postProcess(e,n,t){let o=t.map((({width:e,height:t})=>{let o=n/Math.max(t,e);return{width:e*o,height:t*o}})),r=o.length;return T.tidy((()=>{let t=(e,n)=>T.stack([T.fill([68],e,"float32"),T.fill([68],n,"float32")],1).as2D(1,136).as1D(),a=(e,n)=>{let{width:t,height:r}=o[e];return n(t,r)?Math.abs(t-r)/2:0};return e.mul(T.fill([r,136],n,"float32")).sub(T.stack(Array.from(Array(r),((e,n)=>t((e=>a(e,((e,n)=>e<n)))(n),(e=>a(e,((e,n)=>n<e)))(n)))))).div(T.stack(Array.from(Array(r),((e,n)=>t(o[n].width,o[n].height)))))}))}forwardInput(e){return T.tidy((()=>{let n=this.runNet(e);return this.postProcess(n,e.inputSize,e.inputDimensions.map((([e,n])=>({height:e,width:n}))))}))}async forward(e){return this.forwardInput(await Me(e))}async detectLandmarks(e){let n=await Me(e),t=T.tidy((()=>T.unstack(this.forwardInput(n)))),o=await Promise.all(t.map((async(e,t)=>{let o=Array.from(e.dataSync()),r=o.filter(((e,n)=>D(n))),a=o.filter(((e,n)=>!D(n)));return new ie(Array(68).fill(0).map(((e,n)=>new K(r[n],a[n]))),{height:n.getInputHeight(t),width:n.getInputWidth(t)})})));return t.forEach((e=>e.dispose())),n.isBatchInput?o:o[0]}getClassifierChannelsOut(){return 136}},An=class extends jn{constructor(e=new ln){super("FaceLandmark68Net",e)}getDefaultModelName(){return"face_landmark_68_model"}getClassifierChannelsIn(){return 256}};var Pn=class extends Ke{constructor(){super("TinyFaceFeatureExtractor")}forwardInput(e){let{params:n}=this;if(!n)throw new Error("TinyFaceFeatureExtractor - load model before inference");return T.tidy((()=>{let t=He(ee(T.cast(e.toBatchTensor(112,!0),"float32"),[122.782,117.001,104.298]).div(255),n.dense0,!0);return t=He(t,n.dense1),t=He(t,n.dense2),t=T.avgPool(t,[14,14],[2,2],"valid"),t}))}async forward(e){return this.forwardInput(await Me(e))}getDefaultModelName(){return"face_feature_extractor_tiny_model"}extractParamsFromWeightMap(e){return function(e){let n=[],{extractDenseBlock3Params:t}=cn(e,n),o={dense0:t("dense0",!0),dense1:t("dense1"),dense2:t("dense2")};return Xe(e,n),{params:o,paramMappings:n}}(e)}extractParams(e){return function(e){let n=[],{extractWeights:t,getRemainingWeights:o}=rn(e),{extractDenseBlock3Params:r}=an(t,n),a=r(3,32,"dense0",!0),i=r(32,64,"dense1"),s=r(64,128,"dense2");if(0!==o().length)throw new Error(`weights remaing after extract: ${o().length}`);return{paramMappings:n,params:{dense0:a,dense1:i,dense2:s}}}(e)}},Fn=class extends jn{constructor(e=new Pn){super("FaceLandmark68TinyNet",e)}getDefaultModelName(){return"face_landmark_68_tiny_model"}getClassifierChannelsIn(){return 128}};function zn(e,n,t,o,r="same"){let{filters:a,bias:i}=n.conv,s=T.conv2d(e,a,t,r);return s=T.add(s,i),s=function(e,n){return T.add(T.mul(e,n.weights),n.biases)}(s,n.scale),o?T.relu(s):s}function $n(e,n){return zn(e,n,[1,1],!1)}function Dn(e,n){return zn(e,n,[2,2],!0,"valid")}function Mn(e,n){function t(t,o,r,a){let i=function(n,t,o){let r=e(n),a=r.length/(t*o*o);if($(a))throw new Error(`depth has to be an integer: ${a}, weights.length: ${r.length}, numFilters: ${t}, filterSize: ${o}`);return T.tidy((()=>T.transpose(T.tensor4d(r,[t,a,o,o]),[2,3,1,0])))}(t,o,r),s=T.tensor1d(e(o));return n.push({paramPath:`${a}/filters`},{paramPath:`${a}/bias`}),{filters:i,bias:s}}function o(o,r,a,i){let s=t(o,r,a,`${i}/conv`),c=function(t,o){let r=T.tensor1d(e(t)),a=T.tensor1d(e(t));return n.push({paramPath:`${o}/weights`},{paramPath:`${o}/biases`}),{weights:r,biases:a}}(r,`${i}/scale`);return{conv:s,scale:c}}return{extractConvLayerParams:o,extractResidualLayerParams:function(e,n,t,r,a=!1){return{conv1:o((a?.5:1)*e,n,t,`${r}/conv1`),conv2:o(e,n,t,`${r}/conv2`)}}}}function Ln(e,n){let t=on(e,n);function o(e){let n=t(`${e}/conv/filters`,4),o=t(`${e}/conv/bias`,1),r=function(e){return{weights:t(`${e}/scale/weights`,1),biases:t(`${e}/scale/biases`,1)}}(e);return{conv:{filters:n,bias:o},scale:r}}return{extractConvLayerParams:o,extractResidualLayerParams:function(e){return{conv1:o(`${e}/conv1`),conv2:o(`${e}/conv2`)}}}}function Bn(e,n){let t=function(e,n){return zn(e,n,[1,1],!0)}(e,n.conv1);return t=$n(t,n.conv2),t=T.add(t,e),t=T.relu(t),t}function Wn(e,n){let t=Dn(e,n.conv1);t=$n(t,n.conv2);let o=T.avgPool(e,2,2,"valid"),r=T.zeros(o.shape),a=o.shape[3]!==t.shape[3];if(o.shape[1]!==t.shape[1]||o.shape[2]!==t.shape[2]){let e=[...t.shape];e[1]=1;let n=T.zeros(e);t=T.concat([t,n],1);let o=[...t.shape];o[2]=1;let r=T.zeros(o);t=T.concat([t,r],2)}return o=a?T.concat([o,r],3):o,t=T.add(o,t),t=T.relu(t),t}var qn=class extends Ke{constructor(){super("FaceRecognitionNet")}forwardInput(e){let{params:n}=this;if(!n)throw new Error("FaceRecognitionNet - load model before inference");return T.tidy((()=>{let t=Dn(ee(T.cast(e.toBatchTensor(150,!0),"float32"),[122.782,117.001,104.298]).div(255),n.conv32_down);t=T.maxPool(t,3,2,"valid"),t=Bn(t,n.conv32_1),t=Bn(t,n.conv32_2),t=Bn(t,n.conv32_3),t=Wn(t,n.conv64_down),t=Bn(t,n.conv64_1),t=Bn(t,n.conv64_2),t=Bn(t,n.conv64_3),t=Wn(t,n.conv128_down),t=Bn(t,n.conv128_1),t=Bn(t,n.conv128_2),t=Wn(t,n.conv256_down),t=Bn(t,n.conv256_1),t=Bn(t,n.conv256_2),t=Wn(t,n.conv256_down_out);let o=t.mean([1,2]);return T.matMul(o,n.fc)}))}async forward(e){return this.forwardInput(await Me(e))}async computeFaceDescriptor(e){var n;if(null!=(n=null==e?void 0:e.shape)&&n.some((e=>e<=0)))return new Float32Array(128);let t=await Me(e),o=T.tidy((()=>T.unstack(this.forwardInput(t)))),r=await Promise.all(o.map((e=>e.data())));return o.forEach((e=>e.dispose())),t.isBatchInput?r:r[0]}getDefaultModelName(){return"face_recognition_model"}extractParamsFromWeightMap(e){return function(e){let n=[],{extractConvLayerParams:t,extractResidualLayerParams:o}=Ln(e,n),r=t("conv32_down"),a=o("conv32_1"),i=o("conv32_2"),s=o("conv32_3"),c=o("conv64_down"),l=o("conv64_1"),d=o("conv64_2"),u=o("conv64_3"),p=o("conv128_down"),f=o("conv128_1"),h=o("conv128_2"),m=o("conv256_down"),g=o("conv256_1"),v=o("conv256_2"),w=o("conv256_down_out"),{fc:b}=e;if(n.push({originalPath:"fc",paramPath:"fc"}),!P(b))throw new Error(`expected weightMap[fc] to be a Tensor2D, instead have ${b}`);let x={conv32_down:r,conv32_1:a,conv32_2:i,conv32_3:s,conv64_down:c,conv64_1:l,conv64_2:d,conv64_3:u,conv128_down:p,conv128_1:f,conv128_2:h,conv256_down:m,conv256_1:g,conv256_2:v,conv256_down_out:w,fc:b};return Xe(e,n),{params:x,paramMappings:n}}(e)}extractParams(e){return function(e){let{extractWeights:n,getRemainingWeights:t}=rn(e),o=[],{extractConvLayerParams:r,extractResidualLayerParams:a}=Mn(n,o),i=r(4704,32,7,"conv32_down"),s=a(9216,32,3,"conv32_1"),c=a(9216,32,3,"conv32_2"),l=a(9216,32,3,"conv32_3"),d=a(36864,64,3,"conv64_down",!0),u=a(36864,64,3,"conv64_1"),p=a(36864,64,3,"conv64_2"),f=a(36864,64,3,"conv64_3"),h=a(147456,128,3,"conv128_down",!0),m=a(147456,128,3,"conv128_1"),g=a(147456,128,3,"conv128_2"),v=a(589824,256,3,"conv256_down",!0),w=a(589824,256,3,"conv256_1"),b=a(589824,256,3,"conv256_2"),x=a(589824,256,3,"conv256_down_out"),y=T.tidy((()=>T.transpose(T.tensor2d(n(32768),[128,256]),[1,0])));if(o.push({paramPath:"fc"}),0!==t().length)throw new Error(`weights remaing after extract: ${t().length}`);return{params:{conv32_down:i,conv32_1:s,conv32_2:c,conv32_3:l,conv64_down:d,conv64_1:u,conv64_2:p,conv64_3:f,conv128_down:h,conv128_1:m,conv128_2:g,conv256_down:v,conv256_1:w,conv256_2:b,conv256_down_out:x,fc:y},paramMappings:o}}(e)}};function Un(e,n){return{...e,descriptor:n}}function Vn(e,n){return{...e,age:n}}function Kn(e,n,t){return{...e,gender:n,genderProbability:t}}function Zn(e,n){function t(t,o,r,a,i){let s=T.tensor4d(e(t*o*r*r),[r,r,t,o]),c=T.tensor1d(e(o));return n.push({paramPath:`${a}/filters`},{paramPath:`${a}/${i?"batch_norm_offset":"bias"}`}),{filters:s,bias:c}}function o(e,n,o,r){let{filters:a,bias:i}=t(e,n,o,r,!0);return{filters:a,batch_norm_offset:i}}function r(t,r,a){let i=function(t,o){let r=T.tensor4d(e(9*t),[3,3,t,1]),a=T.tensor1d(e(t)),i=T.tensor1d(e(t)),s=T.tensor1d(e(t)),c=T.tensor1d(e(t));return n.push({paramPath:`${o}/filters`},{paramPath:`${o}/batch_norm_scale`},{paramPath:`${o}/batch_norm_offset`},{paramPath:`${o}/batch_norm_mean`},{paramPath:`${o}/batch_norm_variance`}),{filters:r,batch_norm_scale:a,batch_norm_offset:i,batch_norm_mean:s,batch_norm_variance:c}}(t,`${a}/depthwise_conv`);return{depthwise_conv:i,pointwise_conv:o(t,r,1,`${a}/pointwise_conv`)}}return{extractMobilenetV1Params:function(){return{conv_0:o(3,32,3,"mobilenetv1/conv_0"),conv_1:r(32,64,"mobilenetv1/conv_1"),conv_2:r(64,128,"mobilenetv1/conv_2"),conv_3:r(128,128,"mobilenetv1/conv_3"),conv_4:r(128,256,"mobilenetv1/conv_4"),conv_5:r(256,256,"mobilenetv1/conv_5"),conv_6:r(256,512,"mobilenetv1/conv_6"),conv_7:r(512,512,"mobilenetv1/conv_7"),conv_8:r(512,512,"mobilenetv1/conv_8"),conv_9:r(512,512,"mobilenetv1/conv_9"),conv_10:r(512,512,"mobilenetv1/conv_10"),conv_11:r(512,512,"mobilenetv1/conv_11"),conv_12:r(512,1024,"mobilenetv1/conv_12"),conv_13:r(1024,1024,"mobilenetv1/conv_13")}},extractPredictionLayerParams:function(){return{conv_0:o(1024,256,1,"prediction_layer/conv_0"),conv_1:o(256,512,3,"prediction_layer/conv_1"),conv_2:o(512,128,1,"prediction_layer/conv_2"),conv_3:o(128,256,3,"prediction_layer/conv_3"),conv_4:o(256,128,1,"prediction_layer/conv_4"),conv_5:o(128,256,3,"prediction_layer/conv_5"),conv_6:o(256,64,1,"prediction_layer/conv_6"),conv_7:o(64,128,3,"prediction_layer/conv_7"),box_predictor_0:{box_encoding_predictor:t(512,12,1,"prediction_layer/box_predictor_0/box_encoding_predictor"),class_predictor:t(512,9,1,"prediction_layer/box_predictor_0/class_predictor")},box_predictor_1:{box_encoding_predictor:t(1024,24,1,"prediction_layer/box_predictor_1/box_encoding_predictor"),class_predictor:t(1024,18,1,"prediction_layer/box_predictor_1/class_predictor")},box_predictor_2:{box_encoding_predictor:t(512,24,1,"prediction_layer/box_predictor_2/box_encoding_predictor"),class_predictor:t(512,18,1,"prediction_layer/box_predictor_2/class_predictor")},box_predictor_3:{box_encoding_predictor:t(256,24,1,"prediction_layer/box_predictor_3/box_encoding_predictor"),class_predictor:t(256,18,1,"prediction_layer/box_predictor_3/class_predictor")},box_predictor_4:{box_encoding_predictor:t(256,24,1,"prediction_layer/box_predictor_4/box_encoding_predictor"),class_predictor:t(256,18,1,"prediction_layer/box_predictor_4/class_predictor")},box_predictor_5:{box_encoding_predictor:t(128,24,1,"prediction_layer/box_predictor_5/box_encoding_predictor"),class_predictor:t(128,18,1,"prediction_layer/box_predictor_5/class_predictor")}}}}}function Hn(e){let n=[],{extractMobilenetV1Params:t,extractPredictionLayerParams:o}=function(e,n){let t=on(e,n);function o(e,n,o){return{filters:t(`${e}/Conv2d_${n}_pointwise/weights`,4,`${o}/filters`),batch_norm_offset:t(`${e}/Conv2d_${n}_pointwise/convolution_bn_offset`,1,`${o}/batch_norm_offset`)}}function r(e){let n=`mobilenetv1/conv_${e}`,r=`MobilenetV1/Conv2d_${e}_depthwise`,a=`${n}/depthwise_conv`,i=`${n}/pointwise_conv`;return{depthwise_conv:{filters:t(`${r}/depthwise_weights`,4,`${a}/filters`),batch_norm_scale:t(`${r}/BatchNorm/gamma`,1,`${a}/batch_norm_scale`),batch_norm_offset:t(`${r}/BatchNorm/beta`,1,`${a}/batch_norm_offset`),batch_norm_mean:t(`${r}/BatchNorm/moving_mean`,1,`${a}/batch_norm_mean`),batch_norm_variance:t(`${r}/BatchNorm/moving_variance`,1,`${a}/batch_norm_variance`)},pointwise_conv:o("MobilenetV1",e,i)}}function a(e,n){return{filters:t(`${e}/weights`,4,`${n}/filters`),bias:t(`${e}/biases`,1,`${n}/bias`)}}function i(e){return{box_encoding_predictor:a(`Prediction/BoxPredictor_${e}/BoxEncodingPredictor`,`prediction_layer/box_predictor_${e}/box_encoding_predictor`),class_predictor:a(`Prediction/BoxPredictor_${e}/ClassPredictor`,`prediction_layer/box_predictor_${e}/class_predictor`)}}return{extractMobilenetV1Params:function(){return{conv_0:o("MobilenetV1",0,"mobilenetv1/conv_0"),conv_1:r(1),conv_2:r(2),conv_3:r(3),conv_4:r(4),conv_5:r(5),conv_6:r(6),conv_7:r(7),conv_8:r(8),conv_9:r(9),conv_10:r(10),conv_11:r(11),conv_12:r(12),conv_13:r(13)}},extractPredictionLayerParams:function(){return{conv_0:o("Prediction",0,"prediction_layer/conv_0"),conv_1:o("Prediction",1,"prediction_layer/conv_1"),conv_2:o("Prediction",2,"prediction_layer/conv_2"),conv_3:o("Prediction",3,"prediction_layer/conv_3"),conv_4:o("Prediction",4,"prediction_layer/conv_4"),conv_5:o("Prediction",5,"prediction_layer/conv_5"),conv_6:o("Prediction",6,"prediction_layer/conv_6"),conv_7:o("Prediction",7,"prediction_layer/conv_7"),box_predictor_0:i(0),box_predictor_1:i(1),box_predictor_2:i(2),box_predictor_3:i(3),box_predictor_4:i(4),box_predictor_5:i(5)}}}}(e,n),r=e["Output/extra_dim"];if(n.push({originalPath:"Output/extra_dim",paramPath:"output_layer/extra_dim"}),!F(r))throw new Error(`expected weightMap['Output/extra_dim'] to be a Tensor3D, instead have ${r}`);let a={mobilenetv1:t(),prediction_layer:o(),output_layer:{extra_dim:r}};return Xe(e,n),{params:a,paramMappings:n}}function Gn(e,n,t){return T.tidy((()=>{let o=T.conv2d(e,n.filters,t,"same");return o=T.add(o,n.batch_norm_offset),T.clipByValue(o,0,6)}))}function Jn(e,n){return T.tidy((()=>{let t,o=Gn(e,n.conv_0,[2,2]);if([n.conv_1,n.conv_2,n.conv_3,n.conv_4,n.conv_5,n.conv_6,n.conv_7,n.conv_8,n.conv_9,n.conv_10,n.conv_11,n.conv_12,n.conv_13].forEach(((e,n)=>{let r=n+1,a=function(e){return[2,4,6,12].some((n=>n===e))?[2,2]:[1,1]}(r);o=function(e,n,t){return T.tidy((()=>{let o=T.depthwiseConv2d(e,n.filters,t,"same");return o=T.batchNorm(o,n.batch_norm_mean,n.batch_norm_variance,n.batch_norm_offset,n.batch_norm_scale,.0010000000474974513),T.clipByValue(o,0,6)}))}(o,e.depthwise_conv,a),o=Gn(o,e.pointwise_conv,[1,1]),11===r&&(t=o)})),null===t)throw new Error("mobileNetV1 - output of conv layer 11 is null");return{out:o,conv11:t}}))}function Xn(e,n,t){let o=e.arraySync(),r=Math.min(o[n][0],o[n][2]),a=Math.min(o[n][1],o[n][3]),i=Math.max(o[n][0],o[n][2]),s=Math.max(o[n][1],o[n][3]),c=Math.min(o[t][0],o[t][2]),l=Math.min(o[t][1],o[t][3]),d=Math.max(o[t][0],o[t][2]),u=Math.max(o[t][1],o[t][3]),p=(i-r)*(s-a),f=(d-c)*(u-l);if(p<=0||f<=0)return 0;let h=Math.max(r,c),m=Math.max(a,l),g=Math.min(i,d),v=Math.min(s,u),w=Math.max(g-h,0)*Math.max(v-m,0);return w/(p+f-w)}function Yn(e,n){let{sizes:t,centers:o}=function(e){let n=T.unstack(T.transpose(e,[1,0])),t=[T.sub(n[2],n[0]),T.sub(n[3],n[1])];return{sizes:t,centers:[T.add(n[0],T.div(t[0],2)),T.add(n[1],T.div(t[1],2))]}}(e),r=T.unstack(T.transpose(n,[1,0])),a=T.div(T.mul(T.exp(T.div(r[2],5)),t[0]),2),i=T.add(T.mul(T.div(r[0],10),t[0]),o[0]),s=T.div(T.mul(T.exp(T.div(r[3],5)),t[1]),2),c=T.add(T.mul(T.div(r[1],10),t[1]),o[1]);return T.transpose(T.stack([T.sub(i,a),T.sub(c,s),T.add(i,a),T.add(c,s)]),[1,0])}function Qn(e,n){return T.tidy((()=>{let t=e.shape[0];return{boxPredictionEncoding:T.reshape(Je(e,n.box_encoding_predictor),[t,-1,1,4]),classPrediction:T.reshape(Je(e,n.class_predictor),[t,-1,3])}}))}var et=class{constructor({minConfidence:e,maxResults:n}={}){if(this._name="SsdMobilenetv1Options",this._minConfidence=e||.5,this._maxResults=n||100,"number"!=typeof this._minConfidence||this._minConfidence<=0||this._minConfidence>=1)throw new Error(`${this._name} - expected minConfidence to be a number between 0 and 1`);if("number"!=typeof this._maxResults)throw new Error(`${this._name} - expected maxResults to be a number`)}get minConfidence(){return this._minConfidence}get maxResults(){return this._maxResults}},nt=class extends Ke{constructor(){super("SsdMobilenetv1")}forwardInput(e){let{params:n}=this;if(!n)throw new Error("SsdMobilenetv1 - load model before inference");return T.tidy((()=>{let t=T.cast(e.toBatchTensor(512,!1),"float32"),o=Jn(T.sub(T.div(t,127.5),1),n.mobilenetv1),{boxPredictions:r,classPredictions:a}=function(e,n,t){return T.tidy((()=>{let o=Gn(e,t.conv_0,[1,1]),r=Gn(o,t.conv_1,[2,2]),a=Gn(r,t.conv_2,[1,1]),i=Gn(a,t.conv_3,[2,2]),s=Gn(i,t.conv_4,[1,1]),c=Gn(s,t.conv_5,[2,2]),l=Gn(c,t.conv_6,[1,1]),d=Gn(l,t.conv_7,[2,2]),u=Qn(n,t.box_predictor_0),p=Qn(e,t.box_predictor_1),f=Qn(r,t.box_predictor_2),h=Qn(i,t.box_predictor_3),m=Qn(c,t.box_predictor_4),g=Qn(d,t.box_predictor_5);return{boxPredictions:T.concat([u.boxPredictionEncoding,p.boxPredictionEncoding,f.boxPredictionEncoding,h.boxPredictionEncoding,m.boxPredictionEncoding,g.boxPredictionEncoding],1),classPredictions:T.concat([u.classPrediction,p.classPrediction,f.classPrediction,h.classPrediction,m.classPrediction,g.classPrediction],1)}}))}(o.out,o.conv11,n.prediction_layer);return function(e,n,t){return T.tidy((()=>{let o=e.shape[0],r=Yn(T.reshape(T.tile(t.extra_dim,[o,1,1]),[-1,4]),T.reshape(e,[-1,4]));r=T.reshape(r,[o,r.shape[0]/o,4]);let a=T.sigmoid(T.slice(n,[0,0,1],[-1,-1,-1])),i=T.slice(a,[0,0,0],[-1,-1,1]);return i=T.reshape(i,[o,i.shape[1]]),{boxes:T.unstack(r),scores:T.unstack(i)}}))}(r,a,n.output_layer)}))}async forward(e){return this.forwardInput(await Me(e))}async locateFaces(e,n={}){let{maxResults:t,minConfidence:o}=new et(n),r=await Me(e),{boxes:a,scores:i}=this.forwardInput(r),s=a[0],c=i[0];for(let v=1;v<a.length;v++)a[v].dispose(),i[v].dispose();let l=Array.from(c.dataSync()),d=function(e,n,t,o,r){let a=e.shape[0],i=Math.min(t,a),s=n.map(((e,n)=>({score:e,boxIndex:n}))).filter((e=>e.score>r)).sort(((e,n)=>n.score-e.score)),c=e=>e<=o?1:0,l=[];return s.forEach((n=>{if(l.length>=i)return;let t=n.score;for(let o=l.length-1;o>=0;--o){let t=Xn(e,n.boxIndex,l[o]);if(0!==t&&(n.score*=c(t),n.score<=r))break}t===n.score&&l.push(n.boxIndex)})),l}(s,l,t,.5,o),u=r.getReshapedInputDimensions(0),p=r.inputSize,f=p/u.width,h=p/u.height,m=s.arraySync(),g=d.map((e=>{let[n,t]=[Math.max(0,m[e][0]),Math.min(1,m[e][2])].map((e=>e*h)),[o,a]=[Math.max(0,m[e][1]),Math.min(1,m[e][3])].map((e=>e*f));return new J(l[e],new re(o,n,a-o,t-n),{height:r.getInputHeight(0),width:r.getInputWidth(0)})}));return s.dispose(),c.dispose(),g}getDefaultModelName(){return"ssd_mobilenetv1_model"}extractParamsFromWeightMap(e){return Hn(e)}extractParams(e){return function(e){let n=[],{extractWeights:t,getRemainingWeights:o}=rn(e),{extractMobilenetV1Params:r,extractPredictionLayerParams:a}=Zn(t,n),i=r(),s=a(),c={extra_dim:T.tensor3d(t(20472),[1,5118,4])};if(n.push({paramPath:"output_layer/extra_dim"}),0!==o().length)throw new Error(`weights remaing after extract: ${o().length}`);return{params:{mobilenetv1:i,prediction_layer:s,output_layer:c},paramMappings:n}}(e)}};function tt(e){let n=new nt;return n.extractWeights(e),n}var ot=[new K(.738768,.874946),new K(2.42204,2.65704),new K(4.30971,7.04493),new K(10.246,4.59428),new K(12.6868,11.8741)],rt=[new K(1.603231,2.094468),new K(6.041143,7.080126),new K(2.882459,3.518061),new K(4.266906,5.178857),new K(9.041765,10.66308)],at=[117.001,114.697,97.404],it=e=>"number"==typeof e;function st(e){if(!e)throw new Error(`invalid config: ${e}`);if("boolean"!=typeof e.withSeparableConvs)throw new Error(`config.withSeparableConvs has to be a boolean, have: ${e.withSeparableConvs}`);if(!it(e.iouThreshold)||e.iouThreshold<0||e.iouThreshold>1)throw new Error(`config.iouThreshold has to be a number between [0, 1], have: ${e.iouThreshold}`);if(!Array.isArray(e.classes)||!e.classes.length||!e.classes.every((e=>"string"==typeof e)))throw new Error(`config.classes has to be an array class names: string[], have: ${JSON.stringify(e.classes)}`);if(!Array.isArray(e.anchors)||!e.anchors.length||!e.anchors.map((e=>e||{})).every((e=>it(e.x)&&it(e.y))))throw new Error(`config.anchors has to be an array of { x: number, y: number }, have: ${JSON.stringify(e.anchors)}`);if(e.meanRgb&&(!Array.isArray(e.meanRgb)||3!==e.meanRgb.length||!e.meanRgb.every(it)))throw new Error(`config.meanRgb has to be an array of shape [number, number, number], have: ${JSON.stringify(e.meanRgb)}`)}function ct(e){return T.tidy((()=>{let n=T.mul(e,T.scalar(.10000000149011612));return T.add(T.relu(T.sub(e,n)),n)}))}function lt(e,n){return T.tidy((()=>{let t=T.pad(e,[[0,0],[1,1],[1,1],[0,0]]);return t=T.conv2d(t,n.conv.filters,[1,1],"valid"),t=T.sub(t,n.bn.sub),t=T.mul(t,n.bn.truediv),t=T.add(t,n.conv.bias),ct(t)}))}function dt(e,n){return T.tidy((()=>{let t=T.pad(e,[[0,0],[1,1],[1,1],[0,0]]);return t=T.separableConv2d(t,n.depthwise_filter,n.pointwise_filter,[1,1],"valid"),t=T.add(t,n.bias),ct(t)}))}function ut(e,n){let t=Ye(e,n);let o=nn(e,n);return{extractConvParams:t,extractConvWithBatchNormParams:function(o,r,a){let i=t(o,r,3,`${a}/conv`),s=function(t,o){let r=T.tensor1d(e(t)),a=T.tensor1d(e(t));return n.push({paramPath:`${o}/sub`},{paramPath:`${o}/truediv`}),{sub:r,truediv:a}}(r,`${a}/bn`);return{conv:i,bn:s}},extractSeparableConvParams:o}}function pt(e,n){let t=on(e,n);function o(e){return{filters:t(`${e}/filters`,4),bias:t(`${e}/bias`,1)}}return{extractConvParams:o,extractConvWithBatchNormParams:function(e){let n=o(`${e}/conv`),r=function(e){return{sub:t(`${e}/sub`,1),truediv:t(`${e}/truediv`,1)}}(`${e}/bn`);return{conv:n,bn:r}},extractSeparableConvParams:tn(t)}}var ft=class{constructor({inputSize:e,scoreThreshold:n}={}){if(this._name="TinyYolov2Options",this._inputSize=e||416,this._scoreThreshold=n||.5,"number"!=typeof this._inputSize||this._inputSize%32!=0)throw new Error(`${this._name} - expected inputSize to be a number divisible by 32`);if("number"!=typeof this._scoreThreshold||this._scoreThreshold<=0||this._scoreThreshold>=1)throw new Error(`${this._name} - expected scoreThreshold to be a number between 0 and 1`)}get inputSize(){return this._inputSize}get scoreThreshold(){return this._scoreThreshold}},ht=class e extends Ke{constructor(e){super("TinyYolov2"),st(e),this._config=e}get config(){return this._config}get withClassScores(){return this.config.withClassScores||this.config.classes.length>1}get boxEncodingSize(){return 5+(this.withClassScores?this.config.classes.length:0)}runTinyYolov2(e,n){let t=lt(e,n.conv0);return t=T.maxPool(t,[2,2],[2,2],"same"),t=lt(t,n.conv1),t=T.maxPool(t,[2,2],[2,2],"same"),t=lt(t,n.conv2),t=T.maxPool(t,[2,2],[2,2],"same"),t=lt(t,n.conv3),t=T.maxPool(t,[2,2],[2,2],"same"),t=lt(t,n.conv4),t=T.maxPool(t,[2,2],[2,2],"same"),t=lt(t,n.conv5),t=T.maxPool(t,[2,2],[1,1],"same"),t=lt(t,n.conv6),t=lt(t,n.conv7),Je(t,n.conv8,"valid",!1)}runMobilenet(e,n){let t=this.config.isFirstLayerConv2d?ct(Je(e,n.conv0,"valid",!1)):dt(e,n.conv0);return t=T.maxPool(t,[2,2],[2,2],"same"),t=dt(t,n.conv1),t=T.maxPool(t,[2,2],[2,2],"same"),t=dt(t,n.conv2),t=T.maxPool(t,[2,2],[2,2],"same"),t=dt(t,n.conv3),t=T.maxPool(t,[2,2],[2,2],"same"),t=dt(t,n.conv4),t=T.maxPool(t,[2,2],[2,2],"same"),t=dt(t,n.conv5),t=T.maxPool(t,[2,2],[1,1],"same"),t=n.conv6?dt(t,n.conv6):t,t=n.conv7?dt(t,n.conv7):t,Je(t,n.conv8,"valid",!1)}forwardInput(e,n){let{params:t}=this;if(!t)throw new Error("TinyYolov2 - load model before inference");return T.tidy((()=>{let o=T.cast(e.toBatchTensor(n,!1),"float32");return o=this.config.meanRgb?ee(o,this.config.meanRgb):o,o=o.div(255),this.config.withSeparableConvs?this.runMobilenet(o,t):this.runTinyYolov2(o,t)}))}async forward(e,n){return this.forwardInput(await Me(e),n)}async detect(e,n={}){let{inputSize:t,scoreThreshold:o}=new ft(n),r=await Me(e),a=await this.forwardInput(r,t),i=T.tidy((()=>T.unstack(a)[0].expandDims())),s={width:r.getInputWidth(0),height:r.getInputHeight(0)},c=await this.extractBoxes(i,r.getReshapedInputDimensions(0),o);a.dispose(),i.dispose();let l=c.map((e=>e.box)),d=c.map((e=>e.score)),u=c.map((e=>e.classScore)),p=c.map((e=>this.config.classes[e.label]));return Q(l.map((e=>e.rescale(t))),d,this.config.iouThreshold,!0).map((e=>new G(d[e],u[e],p[e],l[e],s)))}getDefaultModelName(){return""}extractParamsFromWeightMap(e){return function(e,n){let t,o=[],{extractConvParams:r,extractConvWithBatchNormParams:a,extractSeparableConvParams:i}=pt(e,o);if(n.withSeparableConvs){let e=n.filterSizes&&n.filterSizes.length||9;t={conv0:n.isFirstLayerConv2d?r("conv0"):i("conv0"),conv1:i("conv1"),conv2:i("conv2"),conv3:i("conv3"),conv4:i("conv4"),conv5:i("conv5"),conv6:e>7?i("conv6"):void 0,conv7:e>8?i("conv7"):void 0,conv8:r("conv8")}}else t={conv0:a("conv0"),conv1:a("conv1"),conv2:a("conv2"),conv3:a("conv3"),conv4:a("conv4"),conv5:a("conv5"),conv6:a("conv6"),conv7:a("conv7"),conv8:r("conv8")};return Xe(e,o),{params:t,paramMappings:o}}(e,this.config)}extractParams(n){let t=this.config.filterSizes||e.DEFAULT_FILTER_SIZES,o=t?t.length:void 0;if(7!==o&&8!==o&&9!==o)throw new Error(`TinyYolov2 - expected 7 | 8 | 9 convolutional filters, but found ${o} filterSizes in config`);return function(e,n,t,o){let r,{extractWeights:a,getRemainingWeights:i}=rn(e),s=[],{extractConvParams:c,extractConvWithBatchNormParams:l,extractSeparableConvParams:d}=ut(a,s);if(n.withSeparableConvs){let[e,a,i,s,l,u,p,f,h]=o;r={conv0:n.isFirstLayerConv2d?c(e,a,3,"conv0"):d(e,a,"conv0"),conv1:d(a,i,"conv1"),conv2:d(i,s,"conv2"),conv3:d(s,l,"conv3"),conv4:d(l,u,"conv4"),conv5:d(u,p,"conv5"),conv6:f?d(p,f,"conv6"):void 0,conv7:h?d(f,h,"conv7"):void 0,conv8:c(h||f||p,5*t,1,"conv8")}}else{let[e,n,a,i,s,d,u,p,f]=o;r={conv0:l(e,n,"conv0"),conv1:l(n,a,"conv1"),conv2:l(a,i,"conv2"),conv3:l(i,s,"conv3"),conv4:l(s,d,"conv4"),conv5:l(d,u,"conv5"),conv6:l(u,p,"conv6"),conv7:l(p,f,"conv7"),conv8:c(f,5*t,1,"conv8")}}if(0!==i().length)throw new Error(`weights remaing after extract: ${i().length}`);return{params:r,paramMappings:s}}(n,this.config,this.boxEncodingSize,t)}async extractBoxes(e,n,t){let{width:o,height:r}=n,a=Math.max(o,r),i=a/o,s=a/r,c=e.shape[1],l=this.config.anchors.length,[d,u,p]=T.tidy((()=>{let n=e.reshape([c,c,l,this.boxEncodingSize]);return[n.slice([0,0,0,0],[c,c,l,4]),n.slice([0,0,0,4],[c,c,l,1]),this.withClassScores?T.softmax(n.slice([0,0,0,5],[c,c,l,this.config.classes.length]),3):T.scalar(0)]})),f=[],h=await u.array(),m=await d.array();for(let g=0;g<c;g++)for(let e=0;e<c;e++)for(let n=0;n<l;n++){let o=te(h[g][e][n][0]);if(!t||o>t){let t=(e+te(m[g][e][n][0]))/c*i,r=(g+te(m[g][e][n][1]))/c*s,a=Math.exp(m[g][e][n][2])*this.config.anchors[n].x/c*i,l=Math.exp(m[g][e][n][3])*this.config.anchors[n].y/c*s,d=t-a/2,u=r-l/2,h={row:g,col:e,anchor:n},{classScore:v,label:w}=this.withClassScores?await this.extractPredictedClass(p,h):{classScore:1,label:0};f.push({box:new H(d,u,d+a,u+l),score:o,classScore:o*v,label:w,...h})}}return d.dispose(),u.dispose(),p.dispose(),f}async extractPredictedClass(e,n){let{row:t,col:o,anchor:r}=n,a=await e.array();return Array(this.config.classes.length).fill(0).map(((e,n)=>a[t][o][r][n])).map(((e,n)=>({classScore:e,label:n}))).reduce(((e,n)=>e.classScore>n.classScore?e:n))}};ht.DEFAULT_FILTER_SIZES=[3,16,32,64,128,256,512,1024,1024];var mt=ht,gt=class extends mt{constructor(e=!0){super({withSeparableConvs:e,iouThreshold:.4,classes:["face"],...e?{anchors:rt,meanRgb:at}:{anchors:ot,withClassScores:!0}})}get withSeparableConvs(){return this.config.withSeparableConvs}get anchors(){return this.config.anchors}async locateFaces(e,n){return(await this.detect(e,n)).map((e=>new J(e.score,e.relativeBox,{width:e.imageWidth,height:e.imageHeight})))}getDefaultModelName(){return this.withSeparableConvs?"tiny_yolov2_separable_conv_model":"tiny_yolov2_model"}extractParamsFromWeightMap(e){return super.extractParamsFromWeightMap(e)}};var vt=class extends ft{constructor(){super(...arguments),this._name="TinyFaceDetectorOptions"}},wt=class{async then(e){return e(await this.run())}async run(){throw new Error("ComposableTask - run is not implemented")}};async function bt(e,n,t,o,r=({alignedRect:e})=>e){let a=e.map((e=>bn(e)?r(e):e.detection)),i=o||(n instanceof T.Tensor?await Be(n,a):await Le(n,a)),s=await t(i);return i.forEach((e=>e instanceof T.Tensor&&e.dispose())),s}async function xt(e,n,t,o,r){return bt([e],n,(async e=>t(e[0])),o,r)}var yt=[new K(1.603231,2.094468),new K(6.041143,7.080126),new K(2.882459,3.518061),new K(4.266906,5.178857),new K(9.041765,10.66308)],_t=[117.001,114.697,97.404],kt=class extends mt{constructor(){super({withSeparableConvs:!0,iouThreshold:.4,classes:["face"],anchors:yt,meanRgb:_t,isFirstLayerConv2d:!0,filterSizes:[3,16,32,64,128,256,512]})}get anchors(){return this.config.anchors}async locateFaces(e,n){return(await this.detect(e,n)).map((e=>new J(e.score,e.relativeBox,{width:e.imageWidth,height:e.imageHeight})))}getDefaultModelName(){return"tiny_face_detector_model"}extractParamsFromWeightMap(e){return super.extractParamsFromWeightMap(e)}},Et={ssdMobilenetv1:new nt,tinyFaceDetector:new kt,tinyYolov2:new gt,faceLandmark68Net:new An,faceLandmark68TinyNet:new Fn,faceRecognitionNet:new qn,faceExpressionNet:new mn,ageGenderNet:new On},Tt=(e,n)=>Et.ssdMobilenetv1.locateFaces(e,n),Nt=e=>Et.faceLandmark68Net.detectLandmarks(e),St=e=>Et.ssdMobilenetv1.load(e),Ct=St,It=Tt,Rt=Nt,Ot=class extends wt{constructor(e,n,t){super(),this.parentTask=e,this.input=n,this.extractedFaces=t}},jt=class extends Ot{async run(){let e=await this.parentTask,n=await bt(e,this.input,(async e=>Promise.all(e.map((e=>Et.faceExpressionNet.predictExpressions(e))))),this.extractedFaces);return e.map(((e,t)=>vn(e,n[t])))}withAgeAndGender(){return new $t(this,this.input)}},At=class extends Ot{async run(){let e=await this.parentTask;if(e)return vn(e,await xt(e,this.input,(e=>Et.faceExpressionNet.predictExpressions(e)),this.extractedFaces))}withAgeAndGender(){return new Dt(this,this.input)}},Pt=class extends jt{withAgeAndGender(){return new Mt(this,this.input)}withFaceDescriptors(){return new Wt(this,this.input)}},Ft=class extends At{withAgeAndGender(){return new Lt(this,this.input)}withFaceDescriptor(){return new qt(this,this.input)}},zt=class extends wt{constructor(e,n,t){super(),this.parentTask=e,this.input=n,this.extractedFaces=t}},$t=class extends zt{async run(){let e=await this.parentTask,n=await bt(e,this.input,(async e=>Promise.all(e.map((e=>Et.ageGenderNet.predictAgeAndGender(e))))),this.extractedFaces);return e.map(((e,t)=>{let{age:o,gender:r,genderProbability:a}=n[t];return Vn(Kn(e,r,a),o)}))}withFaceExpressions(){return new jt(this,this.input)}},Dt=class extends zt{async run(){let e=await this.parentTask;if(!e)return;let{age:n,gender:t,genderProbability:o}=await xt(e,this.input,(e=>Et.ageGenderNet.predictAgeAndGender(e)),this.extractedFaces);return Vn(Kn(e,t,o),n)}withFaceExpressions(){return new At(this,this.input)}},Mt=class extends $t{withFaceExpressions(){return new Pt(this,this.input)}withFaceDescriptors(){return new Wt(this,this.input)}},Lt=class extends Dt{withFaceExpressions(){return new Ft(this,this.input)}withFaceDescriptor(){return new qt(this,this.input)}},Bt=class extends wt{constructor(e,n){super(),this.parentTask=e,this.input=n}},Wt=class extends Bt{async run(){let e=await this.parentTask;return(await bt(e,this.input,(e=>Promise.all(e.map((e=>Et.faceRecognitionNet.computeFaceDescriptor(e))))),null,(e=>e.landmarks.align(null,{useDlibAlignment:!0})))).map(((n,t)=>Un(e[t],n)))}withFaceExpressions(){return new Pt(this,this.input)}withAgeAndGender(){return new Mt(this,this.input)}},qt=class extends Bt{async run(){let e=await this.parentTask;if(e)return Un(e,await xt(e,this.input,(e=>Et.faceRecognitionNet.computeFaceDescriptor(e)),null,(e=>e.landmarks.align(null,{useDlibAlignment:!0}))))}withFaceExpressions(){return new Ft(this,this.input)}withAgeAndGender(){return new Lt(this,this.input)}},Ut=class extends wt{constructor(e,n,t){super(),this.parentTask=e,this.input=n,this.useTinyLandmarkNet=t}get landmarkNet(){return this.useTinyLandmarkNet?Et.faceLandmark68TinyNet:Et.faceLandmark68Net}},Vt=class extends Ut{async run(){let e=await this.parentTask,n=e.map((e=>e.detection)),t=this.input instanceof T.Tensor?await Be(this.input,n):await Le(this.input,n),o=await Promise.all(t.map((e=>this.landmarkNet.detectLandmarks(e))));return t.forEach((e=>e instanceof T.Tensor&&e.dispose())),e.filter(((e,n)=>o[n])).map(((e,n)=>xn(e,o[n])))}withFaceExpressions(){return new Pt(this,this.input)}withAgeAndGender(){return new Mt(this,this.input)}withFaceDescriptors(){return new Wt(this,this.input)}},Kt=class extends Ut{async run(){let e=await this.parentTask;if(!e)return;let{detection:n}=e,t=this.input instanceof T.Tensor?await Be(this.input,[n]):await Le(this.input,[n]),o=await this.landmarkNet.detectLandmarks(t[0]);return t.forEach((e=>e instanceof T.Tensor&&e.dispose())),xn(e,o)}withFaceExpressions(){return new Ft(this,this.input)}withAgeAndGender(){return new Lt(this,this.input)}withFaceDescriptor(){return new qt(this,this.input)}},Zt=class extends wt{constructor(e,n=new et){super(),this.input=e,this.options=n}},Ht=class extends Zt{async run(){let e,{input:n,options:t}=this;if(t instanceof vt)e=Et.tinyFaceDetector.locateFaces(n,t);else if(t instanceof et)e=Et.ssdMobilenetv1.locateFaces(n,t);else{if(!(t instanceof ft))throw new Error("detectFaces - expected options to be instance of TinyFaceDetectorOptions | SsdMobilenetv1Options | TinyYolov2Options");e=Et.tinyYolov2.locateFaces(n,t)}return e}runAndExtendWithFaceDetections(){return new Promise(((e,n)=>{this.run().then((n=>e(n.map((e=>ue({},e)))))).catch((e=>n(e)))}))}withFaceLandmarks(e=!1){return new Vt(this.runAndExtendWithFaceDetections(),this.input,e)}withFaceExpressions(){return new jt(this.runAndExtendWithFaceDetections(),this.input)}withAgeAndGender(){return new $t(this.runAndExtendWithFaceDetections(),this.input)}},Gt=class extends Zt{async run(){let e=await new Ht(this.input,this.options),n=e[0];return e.forEach((e=>{e.score>n.score&&(n=e)})),n}runAndExtendWithFaceDetection(){return new Promise((async e=>{let n=await this.run();e(n?ue({},n):void 0)}))}withFaceLandmarks(e=!1){return new Kt(this.runAndExtendWithFaceDetection(),this.input,e)}withFaceExpressions(){return new At(this.runAndExtendWithFaceDetection(),this.input)}withAgeAndGender(){return new Dt(this.runAndExtendWithFaceDetection(),this.input)}};function Jt(e,n=new et){return new Gt(e,n)}function Xt(e,n=new et){return new Ht(e,n)}async function Yt(e,n){return Xt(e,new et(n?{minConfidence:n}:{})).withFaceLandmarks().withFaceDescriptors()}var Qt=Yt;function eo(e,n){if(e.length!==n.length)throw new Error("euclideanDistance: arr1.length !== arr2.length");let t=Array.from(e),o=Array.from(n);return Math.sqrt(t.map(((e,n)=>e-o[n])).reduce(((e,n)=>e+n*n),0))}const no=Object.freeze(Object.defineProperty({__proto__:null,AgeGenderNet:On,BoundingBox:H,Box:Z,ComposableTask:wt,ComputeAllFaceDescriptorsTask:Wt,ComputeFaceDescriptorsTaskBase:Bt,ComputeSingleFaceDescriptorTask:qt,DetectAllFaceLandmarksTask:Vt,DetectAllFacesTask:Ht,DetectFaceLandmarksTaskBase:Ut,DetectFacesTaskBase:Zt,DetectSingleFaceLandmarksTask:Kt,DetectSingleFaceTask:Gt,Dimensions:O,FACE_EXPRESSION_LABELS:fn,FaceDetection:J,FaceDetectionNet:class extends nt{},FaceExpressionNet:mn,FaceExpressions:hn,FaceLandmark68Net:An,FaceLandmark68TinyNet:Fn,FaceLandmarkNet:class extends An{},FaceLandmarks:ae,FaceLandmarks5:class extends ae{getRefPointsForAlignment(){let e=this.positions;return[e[0],e[1],W([e[3],e[4]])]}},FaceLandmarks68:ie,FaceMatch:se,FaceMatcher:class e{constructor(e,n=.6){this._distanceThreshold=n;let t=Array.isArray(e)?e:[e];if(!t.length)throw new Error("FaceRecognizer.constructor - expected atleast one input");let o=1,r=()=>"person "+o++;this._labeledDescriptors=t.map((e=>{if(e instanceof le)return e;if(e instanceof Float32Array)return new le(r(),[e]);if(e.descriptor&&e.descriptor instanceof Float32Array)return new le(r(),[e.descriptor]);throw new Error("FaceRecognizer.constructor - expected inputs to be of type LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array | Array<LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array>")}))}get labeledDescriptors(){return this._labeledDescriptors}get distanceThreshold(){return this._distanceThreshold}computeMeanDistance(e,n){return n.map((n=>eo(n,e))).reduce(((e,n)=>e+n),0)/(n.length||1)}matchDescriptor(e){return this.labeledDescriptors.map((({descriptors:n,label:t})=>new se(t,this.computeMeanDistance(e,n)))).reduce(((e,n)=>e.distance<n.distance?e:n))}findBestMatch(e){let n=this.matchDescriptor(e);return n.distance<this._distanceThreshold?n:new se("unknown",n.distance)}toJSON(){return{distanceThreshold:this._distanceThreshold,labeledDescriptors:this._labeledDescriptors.map((e=>e.toJSON()))}}static fromJSON(n){let t=n.labeledDescriptors.map((e=>le.fromJSON(e)));return new e(t,n.distanceThreshold)}},FaceRecognitionNet:qn,Gender:Rn,LabeledBox:ce,LabeledFaceDescriptors:le,NetInput:De,NeuralNetwork:Ke,ObjectDetection:G,Point:K,PredictedBox:class extends ce{static assertIsValidPredictedBox(e,n){if(ce.assertIsValidLabeledBox(e,n),!V(e.score)||!V(e.classScore))throw new Error(`${n} - expected properties score (${e.score}) and (${e.classScore}) to be a number between [0, 1]`)}constructor(e,n,t,o){super(e,n),this._score=t,this._classScore=o}get score(){return this._score}get classScore(){return this._classScore}},Rect:re,SsdMobilenetv1:nt,SsdMobilenetv1Options:et,TinyFaceDetector:kt,TinyFaceDetectorOptions:vt,TinyYolov2:gt,TinyYolov2Options:ft,allFaces:Qt,allFacesSsdMobilenetv1:Yt,allFacesTinyYolov2:async function(e,n={}){return Xt(e,new ft(n)).withFaceLandmarks().withFaceDescriptors()},awaitMediaLoaded:Re,bufferToImage:Oe,computeFaceDescriptor:e=>Et.faceRecognitionNet.computeFaceDescriptor(e),createCanvas:Ae,createCanvasFromMedia:Pe,createFaceDetectionNet:function(e){return tt(e)},createFaceRecognitionNet:function(e){let n=new qn;return n.extractWeights(e),n},createSsdMobilenetv1:tt,createTinyFaceDetector:function(e){let n=new kt;return n.extractWeights(e),n},createTinyYolov2:function(e,n=!0){let t=new gt(n);return t.extractWeights(e),t},detectAllFaces:Xt,detectFaceLandmarks:Nt,detectFaceLandmarksTiny:e=>Et.faceLandmark68TinyNet.detectLandmarks(e),detectLandmarks:Rt,detectSingleFace:Jt,draw:C,env:be,euclideanDistance:eo,extendWithAge:Vn,extendWithFaceDescriptor:Un,extendWithFaceDetection:ue,extendWithFaceExpressions:vn,extendWithFaceLandmarks:xn,extendWithGender:Kn,extractFaceTensors:Be,extractFaces:Le,fetchImage:async function(e){let n=await We(e),t=await n.blob();if(!t.type.startsWith("image/"))throw new Error(`fetchImage - expected blob type to be of type image/*, instead have: ${t.type}, for url: ${n.url}`);return Oe(t)},fetchJson:qe,fetchNetWeights:async function(e){return new Float32Array(await(await We(e)).arrayBuffer())},fetchOrThrow:We,fetchVideo:async function(e){let n=await We(e),t=await n.blob();if(!t.type.startsWith("video/"))throw new Error(`fetchVideo - expected blob type to be of type video/*, instead have: ${t.type}, for url: ${n.url}`);return function(e){return new Promise(((n,t)=>{e instanceof Blob||t(new Error("bufferToVideo - expected buf to be of type: Blob"));let o=be.getEnv().createVideoElement();o.oncanplay=()=>n(o),o.onerror=t,o.playsInline=!0,o.muted=!0,o.src=URL.createObjectURL(e),o.play()}))}(t)},getContext2dOrThrow:ye,getMediaDimensions:je,imageTensorToCanvas:Fe,imageToSquare:$e,inverseSigmoid:function(e){return Math.log(e/(1-e))},iou:X,isMediaElement:ze,isMediaLoaded:Ie,isWithAge:function(e){return"number"==typeof e.age},isWithFaceDetection:de,isWithFaceExpressions:gn,isWithFaceLandmarks:bn,isWithGender:function(e){return("male"===e.gender||"female"===e.gender)&&V(e.genderProbability)},loadAgeGenderModel:e=>Et.ageGenderNet.load(e),loadFaceDetectionModel:Ct,loadFaceExpressionModel:e=>Et.faceExpressionNet.load(e),loadFaceLandmarkModel:e=>Et.faceLandmark68Net.load(e),loadFaceLandmarkTinyModel:e=>Et.faceLandmark68TinyNet.load(e),loadFaceRecognitionModel:e=>Et.faceRecognitionNet.load(e),loadSsdMobilenetv1Model:St,loadTinyFaceDetectorModel:e=>Et.tinyFaceDetector.load(e),loadTinyYolov2Model:e=>Et.tinyYolov2.load(e),loadWeightMap:Ve,locateFaces:It,matchDimensions:function(e,n,t=!1){let{width:o,height:r}=t?je(n):n;return e.width=o,e.height=r,{width:o,height:r}},minBbox:Y,nets:Et,nonMaxSuppression:Q,normalize:ee,padToSquare:ne,predictAgeAndGender:e=>Et.ageGenderNet.predictAgeAndGender(e),recognizeFaceExpressions:e=>Et.faceExpressionNet.predictExpressions(e),resizeResults:function e(n,t){let{width:o,height:r}=new O(t.width,t.height);if(o<=0||r<=0)throw new Error(`resizeResults - invalid dimensions: ${JSON.stringify({width:o,height:r})}`);if(Array.isArray(n))return n.map((n=>e(n,{width:o,height:r})));if(bn(n)){let e=n.detection.forSize(o,r),t=n.unshiftedLandmarks.forSize(e.box.width,e.box.height);return xn(ue(n,e),t)}return de(n)?ue(n,n.detection.forSize(o,r)):n instanceof ae||n instanceof J?n.forSize(o,r):n},resolveInput:xe,shuffleArray:function(e){let n=e.slice();for(let t=n.length-1;t>0;t--){let e=Math.floor(Math.random()*(t+1)),o=n[t];n[t]=n[e],n[e]=o}return n},sigmoid:te,ssdMobilenetv1:Tt,tf:T,tinyFaceDetector:(e,n)=>Et.tinyFaceDetector.locateFaces(e,n),tinyYolov2:(e,n)=>Et.tinyYolov2.locateFaces(e,n),toNetInput:Me,utils:R,validateConfig:st,version:"1.7.15"},Symbol.toStringTag,{value:"Module"}));class to extends Error{constructor(e){super(e),this.name="CameraPermissionDenied"}}class oo{constructor(e){l(this,"stream"),this.stream=e}getStream(){return this.stream}stop(){this.stream.getTracks().forEach((e=>e.stop()))}}const ro=()=>{const e=n.useRef(null),[t,o]=n.useState(!1),r=n.useRef(!1);return{startCamera:n.useCallback((async n=>{const t=e.current;if(t)return t.getStream();if(r.current){await new Promise((e=>setTimeout(e,100)));const n=e.current;if(n)return n.getStream()}r.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}})(),a=await navigator.mediaDevices.getUserMedia(t),i=new oo(a);return e.current=i,o(!0),r.current=!1,a}catch(a){if(r.current=!1,a instanceof Error){if("NotAllowedError"===a.name||"PermissionDeniedError"===a.name)throw new to("Permissão para acessar a câmera foi negada pelo usuário");if("NotFoundError"===a.name||"DevicesNotFoundError"===a.name)throw new Error("Nenhuma câmera foi encontrada no dispositivo");if("NotReadableError"===a.name||"TrackStartError"===a.name)throw new Error("A câmera já está sendo usada por outro aplicativo");if("OverconstrainedError"===a.name||"ConstraintNotSatisfiedError"===a.name)throw new Error("As configurações solicitadas não são suportadas pela câmera")}throw new Error(`Erro ao inicializar câmera: ${a instanceof Error?a.message:String(a)}`)}}),[]),stopCamera:n.useCallback((n=>{const t=e.current;t&&t.getStream()===n&&(t.stop(),e.current=null,o(!1),r.current=!1)}),[]),cleanup:n.useCallback((()=>{e.current&&(e.current.stop(),e.current=null,o(!1),r.current=!1)}),[]),isActive:t}};var ao=(e=>(e.NETWORK="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.CONSENT_DENIED="ConsentDeniedError",e.LIVENESS_BLINK_MISSING="LivenessBlinkMissingError",e.GESTURE_NOT_DETECTED="GestureNotDetectedError",e))(ao||{});class io extends Error{constructor(e,n){super(e),l(this,"type"),this.name=n,this.type=n}getFriendlyMessage(){if(/[áéíóúãõç]/i.test(this.message))return this.message;switch(this.type){case"NetworkError":return this.message.includes("timeout")?"A conexão demorou muito. Tente novamente.":"Não foi possível conectar ao servidor. Verifique sua internet.";case"InvalidTokenError":return"Falha na autenticação do aplicativo. Entre em contato com o suporte.";case"CameraError":case"NoCameraError":return"Não conseguimos acessar sua câmera. Verifique as permissões do navegador.";case"LoginFailedError":case"RecognitionFailedError":return"Não foi possível reconhecer seu rosto. Tente se posicionar em um local mais iluminado.";case"ValidationError":return"Dados inválidos ou rosto não detectado corretamente.";case"ConsentDeniedError":return"É necessário aceitar o uso do seu rosto para continuar.";case"LivenessBlinkMissingError":return"Não detectamos uma piscada. Pisque os olhos naturalmente e tente novamente.";case"GestureNotDetectedError":return"Não detectamos o polegar para cima. Mostre o gesto claramente para a câmera e tente novamente.";case"ApiError":return this.message.includes("400")?"Requisição inválida. Tente novamente.":this.message.includes("500")?"Ocorreu um erro interno no sistema. Tente mais tarde.":"O serviço encontrou um problema inesperado.";default:return"Ocorreu um erro inesperado. Por favor, tente novamente."}}}function so(e,n,t){function o(t,o){if(t._zod||Object.defineProperty(t,"_zod",{value:{def:o,constr:i,traits:new Set},enumerable:!1}),t._zod.traits.has(e))return;t._zod.traits.add(e),n(t,o);const r=i.prototype,a=Object.keys(r);for(let e=0;e<a.length;e++){const n=a[e];n in t||(t[n]=r[n].bind(t))}}const r=(null==t?void 0:t.Parent)??Object;class a extends r{}function i(e){var n;const r=(null==t?void 0:t.Parent)?new a:this;o(r,e),(n=r._zod).deferred??(n.deferred=[]);for(const t of r._zod.deferred)t();return r}return Object.defineProperty(a,"name",{value:e}),Object.defineProperty(i,"init",{value:o}),Object.defineProperty(i,Symbol.hasInstance,{value:n=>{var o,r;return!!((null==t?void 0:t.Parent)&&n instanceof t.Parent)||(null==(r=null==(o=null==n?void 0:n._zod)?void 0:o.traits)?void 0:r.has(e))}}),Object.defineProperty(i,"name",{value:e}),i}class co extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class lo extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const uo={};function po(e){return uo}function fo(e){const n=Object.values(e).filter((e=>"number"==typeof e));return Object.entries(e).filter((([e,t])=>-1===n.indexOf(+e))).map((([e,n])=>n))}function ho(e,n){return"bigint"==typeof n?n.toString():n}function mo(e){return{get value(){{const n=e();return Object.defineProperty(this,"value",{value:n}),n}}}}function go(e){return null==e}function vo(e){const n=e.startsWith("^")?1:0,t=e.endsWith("$")?e.length-1:e.length;return e.slice(n,t)}const wo=Symbol("evaluating");function bo(e,n,t){let o;Object.defineProperty(e,n,{get(){if(o!==wo)return void 0===o&&(o=wo,o=t()),o},set(t){Object.defineProperty(e,n,{value:t})},configurable:!0})}function xo(e,n,t){Object.defineProperty(e,n,{value:t,writable:!0,enumerable:!0,configurable:!0})}function yo(...e){const n={};for(const t of e){const e=Object.getOwnPropertyDescriptors(t);Object.assign(n,e)}return Object.defineProperties({},n)}function _o(e){return JSON.stringify(e)}const ko="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Eo(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const To=mo((()=>{var e;if("undefined"!=typeof navigator&&(null==(e=null==navigator?void 0:navigator.userAgent)?void 0:e.includes("Cloudflare")))return!1;try{return new Function(""),!0}catch(n){return!1}}));function No(e){if(!1===Eo(e))return!1;const n=e.constructor;if(void 0===n)return!0;if("function"!=typeof n)return!0;const t=n.prototype;return!1!==Eo(t)&&!1!==Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")}function So(e){return No(e)?{...e}:Array.isArray(e)?[...e]:e}const Co=new Set(["string","number","symbol"]);function Io(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ro(e,n,t){const o=new e._zod.constr(n??e._zod.def);return n&&!(null==t?void 0:t.parent)||(o._zod.parent=e),o}function Oo(e){const n=e;if(!n)return{};if("string"==typeof n)return{error:()=>n};if(void 0!==(null==n?void 0:n.message)){if(void 0!==(null==n?void 0:n.error))throw new Error("Cannot specify both `message` and `error` params");n.error=n.message}return delete n.message,"string"==typeof n.error?{...n,error:()=>n.error}:n}const jo={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Ao(e,n=0){var t;if(!0===e.aborted)return!0;for(let o=n;o<e.issues.length;o++)if(!0!==(null==(t=e.issues[o])?void 0:t.continue))return!0;return!1}function Po(e,n){return n.map((n=>{var t;return(t=n).path??(t.path=[]),n.path.unshift(e),n}))}function Fo(e){return"string"==typeof e?e:null==e?void 0:e.message}function zo(e,n,t){var o,r,a,i,s,c;const l={...e,path:e.path??[]};if(!e.message){const d=Fo(null==(a=null==(r=null==(o=e.inst)?void 0:o._zod.def)?void 0:r.error)?void 0:a.call(r,e))??Fo(null==(i=null==n?void 0:n.error)?void 0:i.call(n,e))??Fo(null==(s=t.customError)?void 0:s.call(t,e))??Fo(null==(c=t.localeError)?void 0:c.call(t,e))??"Invalid input";l.message=d}return delete l.inst,delete l.continue,(null==n?void 0:n.reportInput)||delete l.input,l}function $o(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function Do(...e){const[n,t,o]=e;return"string"==typeof n?{message:n,code:"custom",input:t,inst:o}:{...n}}const Mo=(e,n)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:n,enumerable:!1}),e.message=JSON.stringify(n,ho,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Lo=so("$ZodError",Mo),Bo=so("$ZodError",Mo,{Parent:Error});const Wo=e=>(n,t,o,r)=>{const a=o?Object.assign(o,{async:!1}):{async:!1},i=n._zod.run({value:t,issues:[]},a);if(i instanceof Promise)throw new co;if(i.issues.length){const n=new((null==r?void 0:r.Err)??e)(i.issues.map((e=>zo(e,a,po()))));throw ko(n,null==r?void 0:r.callee),n}return i.value},qo=e=>async(n,t,o,r)=>{const a=o?Object.assign(o,{async:!0}):{async:!0};let i=n._zod.run({value:t,issues:[]},a);if(i instanceof Promise&&(i=await i),i.issues.length){const n=new((null==r?void 0:r.Err)??e)(i.issues.map((e=>zo(e,a,po()))));throw ko(n,null==r?void 0:r.callee),n}return i.value},Uo=e=>(n,t,o)=>{const r=o?{...o,async:!1}:{async:!1},a=n._zod.run({value:t,issues:[]},r);if(a instanceof Promise)throw new co;return a.issues.length?{success:!1,error:new(e??Lo)(a.issues.map((e=>zo(e,r,po()))))}:{success:!0,data:a.value}},Vo=Uo(Bo),Ko=e=>async(n,t,o)=>{const r=o?Object.assign(o,{async:!0}):{async:!0};let a=n._zod.run({value:t,issues:[]},r);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map((e=>zo(e,r,po()))))}:{success:!0,data:a.value}},Zo=Ko(Bo),Ho=e=>(n,t,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return Wo(e)(n,t,r)},Go=e=>(n,t,o)=>Wo(e)(n,t,o),Jo=e=>async(n,t,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return qo(e)(n,t,r)},Xo=e=>async(n,t,o)=>qo(e)(n,t,o),Yo=e=>(n,t,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return Uo(e)(n,t,r)},Qo=e=>(n,t,o)=>Uo(e)(n,t,o),er=e=>async(n,t,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return Ko(e)(n,t,r)},nr=e=>async(n,t,o)=>Ko(e)(n,t,o),tr=/^[cC][^\s-]{8,}$/,or=/^[0-9a-z]+$/,rr=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ar=/^[0-9a-vA-V]{20}$/,ir=/^[A-Za-z0-9]{27}$/,sr=/^[a-zA-Z0-9_-]{21}$/,cr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,lr=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,dr=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,ur=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const pr=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,fr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,hr=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,mr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,gr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,vr=/^[A-Za-z0-9_-]*$/,wr=/^\+[1-9]\d{6,14}$/,br="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",xr=new RegExp(`^${br}$`);function yr(e){const n="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${n}`:0===e.precision?`${n}:[0-5]\\d`:`${n}:[0-5]\\d\\.\\d{${e.precision}}`:`${n}(?::[0-5]\\d(?:\\.\\d+)?)?`}const _r=/^-?\d+$/,kr=/^-?\d+(?:\.\d+)?$/,Er=/^(?:true|false)$/i,Tr=/^[^A-Z]*$/,Nr=/^[^a-z]*$/,Sr=so("$ZodCheck",((e,n)=>{var t;e._zod??(e._zod={}),e._zod.def=n,(t=e._zod).onattach??(t.onattach=[])})),Cr={number:"number",bigint:"bigint",object:"date"},Ir=so("$ZodCheckLessThan",((e,n)=>{Sr.init(e,n);const t=Cr[typeof n.value];e._zod.onattach.push((e=>{const t=e._zod.bag,o=(n.inclusive?t.maximum:t.exclusiveMaximum)??Number.POSITIVE_INFINITY;n.value<o&&(n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value)})),e._zod.check=o=>{(n.inclusive?o.value<=n.value:o.value<n.value)||o.issues.push({origin:t,code:"too_big",maximum:"object"==typeof n.value?n.value.getTime():n.value,input:o.value,inclusive:n.inclusive,inst:e,continue:!n.abort})}})),Rr=so("$ZodCheckGreaterThan",((e,n)=>{Sr.init(e,n);const t=Cr[typeof n.value];e._zod.onattach.push((e=>{const t=e._zod.bag,o=(n.inclusive?t.minimum:t.exclusiveMinimum)??Number.NEGATIVE_INFINITY;n.value>o&&(n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value)})),e._zod.check=o=>{(n.inclusive?o.value>=n.value:o.value>n.value)||o.issues.push({origin:t,code:"too_small",minimum:"object"==typeof n.value?n.value.getTime():n.value,input:o.value,inclusive:n.inclusive,inst:e,continue:!n.abort})}})),Or=so("$ZodCheckMultipleOf",((e,n)=>{Sr.init(e,n),e._zod.onattach.push((e=>{var t;(t=e._zod.bag).multipleOf??(t.multipleOf=n.value)})),e._zod.check=t=>{if(typeof t.value!=typeof n.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof t.value?t.value%n.value===BigInt(0):0===function(e,n){const t=(e.toString().split(".")[1]||"").length,o=n.toString();let r=(o.split(".")[1]||"").length;if(0===r&&/\d?e-\d?/.test(o)){const e=o.match(/\d?e-(\d?)/);(null==e?void 0:e[1])&&(r=Number.parseInt(e[1]))}const a=t>r?t:r;return Number.parseInt(e.toFixed(a).replace(".",""))%Number.parseInt(n.toFixed(a).replace(".",""))/10**a}(t.value,n.value))||t.issues.push({origin:typeof t.value,code:"not_multiple_of",divisor:n.value,input:t.value,inst:e,continue:!n.abort})}})),jr=so("$ZodCheckNumberFormat",((e,n)=>{var t;Sr.init(e,n),n.format=n.format||"float64";const o=null==(t=n.format)?void 0:t.includes("int"),r=o?"int":"number",[a,i]=jo[n.format];e._zod.onattach.push((e=>{const t=e._zod.bag;t.format=n.format,t.minimum=a,t.maximum=i,o&&(t.pattern=_r)})),e._zod.check=t=>{const s=t.value;if(o){if(!Number.isInteger(s))return void t.issues.push({expected:r,format:n.format,code:"invalid_type",continue:!1,input:s,inst:e});if(!Number.isSafeInteger(s))return void(s>0?t.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!n.abort}):t.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!n.abort}))}s<a&&t.issues.push({origin:"number",input:s,code:"too_small",minimum:a,inclusive:!0,inst:e,continue:!n.abort}),s>i&&t.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!n.abort})}})),Ar=so("$ZodCheckMaxLength",((e,n)=>{var t;Sr.init(e,n),(t=e._zod.def).when??(t.when=e=>{const n=e.value;return!go(n)&&void 0!==n.length}),e._zod.onattach.push((e=>{const t=e._zod.bag.maximum??Number.POSITIVE_INFINITY;n.maximum<t&&(e._zod.bag.maximum=n.maximum)})),e._zod.check=t=>{const o=t.value;if(o.length<=n.maximum)return;const r=$o(o);t.issues.push({origin:r,code:"too_big",maximum:n.maximum,inclusive:!0,input:o,inst:e,continue:!n.abort})}})),Pr=so("$ZodCheckMinLength",((e,n)=>{var t;Sr.init(e,n),(t=e._zod.def).when??(t.when=e=>{const n=e.value;return!go(n)&&void 0!==n.length}),e._zod.onattach.push((e=>{const t=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;n.minimum>t&&(e._zod.bag.minimum=n.minimum)})),e._zod.check=t=>{const o=t.value;if(o.length>=n.minimum)return;const r=$o(o);t.issues.push({origin:r,code:"too_small",minimum:n.minimum,inclusive:!0,input:o,inst:e,continue:!n.abort})}})),Fr=so("$ZodCheckLengthEquals",((e,n)=>{var t;Sr.init(e,n),(t=e._zod.def).when??(t.when=e=>{const n=e.value;return!go(n)&&void 0!==n.length}),e._zod.onattach.push((e=>{const t=e._zod.bag;t.minimum=n.length,t.maximum=n.length,t.length=n.length})),e._zod.check=t=>{const o=t.value,r=o.length;if(r===n.length)return;const a=$o(o),i=r>n.length;t.issues.push({origin:a,...i?{code:"too_big",maximum:n.length}:{code:"too_small",minimum:n.length},inclusive:!0,exact:!0,input:t.value,inst:e,continue:!n.abort})}})),zr=so("$ZodCheckStringFormat",((e,n)=>{var t,o;Sr.init(e,n),e._zod.onattach.push((e=>{const t=e._zod.bag;t.format=n.format,n.pattern&&(t.patterns??(t.patterns=new Set),t.patterns.add(n.pattern))})),n.pattern?(t=e._zod).check??(t.check=t=>{n.pattern.lastIndex=0,n.pattern.test(t.value)||t.issues.push({origin:"string",code:"invalid_format",format:n.format,input:t.value,...n.pattern?{pattern:n.pattern.toString()}:{},inst:e,continue:!n.abort})}):(o=e._zod).check??(o.check=()=>{})})),$r=so("$ZodCheckRegex",((e,n)=>{zr.init(e,n),e._zod.check=t=>{n.pattern.lastIndex=0,n.pattern.test(t.value)||t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:n.pattern.toString(),inst:e,continue:!n.abort})}})),Dr=so("$ZodCheckLowerCase",((e,n)=>{n.pattern??(n.pattern=Tr),zr.init(e,n)})),Mr=so("$ZodCheckUpperCase",((e,n)=>{n.pattern??(n.pattern=Nr),zr.init(e,n)})),Lr=so("$ZodCheckIncludes",((e,n)=>{Sr.init(e,n);const t=Io(n.includes),o=new RegExp("number"==typeof n.position?`^.{${n.position}}${t}`:t);n.pattern=o,e._zod.onattach.push((e=>{const n=e._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(o)})),e._zod.check=t=>{t.value.includes(n.includes,n.position)||t.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:n.includes,input:t.value,inst:e,continue:!n.abort})}})),Br=so("$ZodCheckStartsWith",((e,n)=>{Sr.init(e,n);const t=new RegExp(`^${Io(n.prefix)}.*`);n.pattern??(n.pattern=t),e._zod.onattach.push((e=>{const n=e._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(t)})),e._zod.check=t=>{t.value.startsWith(n.prefix)||t.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:n.prefix,input:t.value,inst:e,continue:!n.abort})}})),Wr=so("$ZodCheckEndsWith",((e,n)=>{Sr.init(e,n);const t=new RegExp(`.*${Io(n.suffix)}$`);n.pattern??(n.pattern=t),e._zod.onattach.push((e=>{const n=e._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(t)})),e._zod.check=t=>{t.value.endsWith(n.suffix)||t.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:n.suffix,input:t.value,inst:e,continue:!n.abort})}})),qr=so("$ZodCheckOverwrite",((e,n)=>{Sr.init(e,n),e._zod.check=e=>{e.value=n.tx(e.value)}}));class Ur{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const n=e.split("\n").filter((e=>e)),t=Math.min(...n.map((e=>e.length-e.trimStart().length))),o=n.map((e=>e.slice(t))).map((e=>" ".repeat(2*this.indent)+e));for(const r of o)this.content.push(r)}compile(){return new Function(...null==this?void 0:this.args,[...((null==this?void 0:this.content)??[""]).map((e=>` ${e}`))].join("\n"))}}const Vr={major:4,minor:3,patch:6},Kr=so("$ZodType",((e,n)=>{var t,o;e??(e={}),e._zod.def=n,e._zod.bag=e._zod.bag||{},e._zod.version=Vr;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const a of r)for(const n of a._zod.onattach)n(e);if(0===r.length)(o=e._zod).deferred??(o.deferred=[]),null==(t=e._zod.deferred)||t.push((()=>{e._zod.run=e._zod.parse}));else{const n=(e,n,t)=>{let o,r=Ao(e);for(const a of n){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;const n=e.issues.length,i=a._zod.check(e);if(i instanceof Promise&&!1===(null==t?void 0:t.async))throw new co;if(o||i instanceof Promise)o=(o??Promise.resolve()).then((async()=>{await i;e.issues.length!==n&&(r||(r=Ao(e,n)))}));else{if(e.issues.length===n)continue;r||(r=Ao(e,n))}}return o?o.then((()=>e)):e},t=(t,o,a)=>{if(Ao(t))return t.aborted=!0,t;const i=n(o,r,a);if(i instanceof Promise){if(!1===a.async)throw new co;return i.then((n=>e._zod.parse(n,a)))}return e._zod.parse(i,a)};e._zod.run=(o,a)=>{if(a.skipChecks)return e._zod.parse(o,a);if("backward"===a.direction){const n=e._zod.parse({value:o.value,issues:[]},{...a,skipChecks:!0});return n instanceof Promise?n.then((e=>t(e,o,a))):t(n,o,a)}const i=e._zod.parse(o,a);if(i instanceof Promise){if(!1===a.async)throw new co;return i.then((e=>n(e,r,a)))}return n(i,r,a)}}bo(e,"~standard",(()=>({validate:n=>{var t;try{const o=Vo(e,n);return o.success?{value:o.data}:{issues:null==(t=o.error)?void 0:t.issues}}catch(o){return Zo(e,n).then((e=>{var n;return e.success?{value:e.data}:{issues:null==(n=e.error)?void 0:n.issues}}))}},vendor:"zod",version:1})))})),Zr=so("$ZodString",((e,n)=>{var t;Kr.init(e,n),e._zod.pattern=[...(null==(t=null==e?void 0:e._zod.bag)?void 0:t.patterns)??[]].pop()??(e=>{const n=e?`[\\s\\S]{${(null==e?void 0:e.minimum)??0},${(null==e?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${n}$`)})(e._zod.bag),e._zod.parse=(t,o)=>{if(n.coerce)try{t.value=String(t.value)}catch(r){}return"string"==typeof t.value||t.issues.push({expected:"string",code:"invalid_type",input:t.value,inst:e}),t}})),Hr=so("$ZodStringFormat",((e,n)=>{zr.init(e,n),Zr.init(e,n)})),Gr=so("$ZodGUID",((e,n)=>{n.pattern??(n.pattern=lr),Hr.init(e,n)})),Jr=so("$ZodUUID",((e,n)=>{if(n.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[n.version];if(void 0===e)throw new Error(`Invalid UUID version: "${n.version}"`);n.pattern??(n.pattern=dr(e))}else n.pattern??(n.pattern=dr());Hr.init(e,n)})),Xr=so("$ZodEmail",((e,n)=>{n.pattern??(n.pattern=ur),Hr.init(e,n)})),Yr=so("$ZodURL",((e,n)=>{Hr.init(e,n),e._zod.check=t=>{try{const o=t.value.trim(),r=new URL(o);return n.hostname&&(n.hostname.lastIndex=0,n.hostname.test(r.hostname)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:n.hostname.source,input:t.value,inst:e,continue:!n.abort})),n.protocol&&(n.protocol.lastIndex=0,n.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:n.protocol.source,input:t.value,inst:e,continue:!n.abort})),void(n.normalize?t.value=r.href:t.value=o)}catch(o){t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:e,continue:!n.abort})}}})),Qr=so("$ZodEmoji",((e,n)=>{n.pattern??(n.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Hr.init(e,n)})),ea=so("$ZodNanoID",((e,n)=>{n.pattern??(n.pattern=sr),Hr.init(e,n)})),na=so("$ZodCUID",((e,n)=>{n.pattern??(n.pattern=tr),Hr.init(e,n)})),ta=so("$ZodCUID2",((e,n)=>{n.pattern??(n.pattern=or),Hr.init(e,n)})),oa=so("$ZodULID",((e,n)=>{n.pattern??(n.pattern=rr),Hr.init(e,n)})),ra=so("$ZodXID",((e,n)=>{n.pattern??(n.pattern=ar),Hr.init(e,n)})),aa=so("$ZodKSUID",((e,n)=>{n.pattern??(n.pattern=ir),Hr.init(e,n)})),ia=so("$ZodISODateTime",((e,n)=>{n.pattern??(n.pattern=function(e){const n=yr({precision:e.precision}),t=["Z"];e.local&&t.push(""),e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const o=`${n}(?:${t.join("|")})`;return new RegExp(`^${br}T(?:${o})$`)}(n)),Hr.init(e,n)})),sa=so("$ZodISODate",((e,n)=>{n.pattern??(n.pattern=xr),Hr.init(e,n)})),ca=so("$ZodISOTime",((e,n)=>{n.pattern??(n.pattern=new RegExp(`^${yr(n)}$`)),Hr.init(e,n)})),la=so("$ZodISODuration",((e,n)=>{n.pattern??(n.pattern=cr),Hr.init(e,n)})),da=so("$ZodIPv4",((e,n)=>{n.pattern??(n.pattern=pr),Hr.init(e,n),e._zod.bag.format="ipv4"})),ua=so("$ZodIPv6",((e,n)=>{n.pattern??(n.pattern=fr),Hr.init(e,n),e._zod.bag.format="ipv6",e._zod.check=t=>{try{new URL(`http://[${t.value}]`)}catch{t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:e,continue:!n.abort})}}})),pa=so("$ZodCIDRv4",((e,n)=>{n.pattern??(n.pattern=hr),Hr.init(e,n)})),fa=so("$ZodCIDRv6",((e,n)=>{n.pattern??(n.pattern=mr),Hr.init(e,n),e._zod.check=t=>{const o=t.value.split("/");try{if(2!==o.length)throw new Error;const[e,n]=o;if(!n)throw new Error;const t=Number(n);if(`${t}`!==n)throw new Error;if(t<0||t>128)throw new Error;new URL(`http://[${e}]`)}catch{t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:e,continue:!n.abort})}}}));function ha(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const ma=so("$ZodBase64",((e,n)=>{n.pattern??(n.pattern=gr),Hr.init(e,n),e._zod.bag.contentEncoding="base64",e._zod.check=t=>{ha(t.value)||t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:e,continue:!n.abort})}}));const ga=so("$ZodBase64URL",((e,n)=>{n.pattern??(n.pattern=vr),Hr.init(e,n),e._zod.bag.contentEncoding="base64url",e._zod.check=t=>{(function(e){if(!vr.test(e))return!1;const n=e.replace(/[-_]/g,(e=>"-"===e?"+":"/"));return ha(n.padEnd(4*Math.ceil(n.length/4),"="))})(t.value)||t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:e,continue:!n.abort})}})),va=so("$ZodE164",((e,n)=>{n.pattern??(n.pattern=wr),Hr.init(e,n)}));const wa=so("$ZodJWT",((e,n)=>{Hr.init(e,n),e._zod.check=t=>{(function(e,n=null){try{const t=e.split(".");if(3!==t.length)return!1;const[o]=t;if(!o)return!1;const r=JSON.parse(atob(o));return!("typ"in r&&"JWT"!==(null==r?void 0:r.typ)||!r.alg||n&&(!("alg"in r)||r.alg!==n))}catch{return!1}})(t.value,n.alg)||t.issues.push({code:"invalid_format",format:"jwt",input:t.value,inst:e,continue:!n.abort})}})),ba=so("$ZodNumber",((e,n)=>{Kr.init(e,n),e._zod.pattern=e._zod.bag.pattern??kr,e._zod.parse=(t,o)=>{if(n.coerce)try{t.value=Number(t.value)}catch(i){}const r=t.value;if("number"==typeof r&&!Number.isNaN(r)&&Number.isFinite(r))return t;const a="number"==typeof r?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return t.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...a?{received:a}:{}}),t}})),xa=so("$ZodNumberFormat",((e,n)=>{jr.init(e,n),ba.init(e,n)})),ya=so("$ZodBoolean",((e,n)=>{Kr.init(e,n),e._zod.pattern=Er,e._zod.parse=(t,o)=>{if(n.coerce)try{t.value=Boolean(t.value)}catch(a){}const r=t.value;return"boolean"==typeof r||t.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),t}})),_a=so("$ZodAny",((e,n)=>{Kr.init(e,n),e._zod.parse=e=>e})),ka=so("$ZodUnknown",((e,n)=>{Kr.init(e,n),e._zod.parse=e=>e})),Ea=so("$ZodNever",((e,n)=>{Kr.init(e,n),e._zod.parse=(n,t)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}));function Ta(e,n,t){e.issues.length&&n.issues.push(...Po(t,e.issues)),n.value[t]=e.value}const Na=so("$ZodArray",((e,n)=>{Kr.init(e,n),e._zod.parse=(t,o)=>{const r=t.value;if(!Array.isArray(r))return t.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),t;t.value=Array(r.length);const a=[];for(let e=0;e<r.length;e++){const i=r[e],s=n.element._zod.run({value:i,issues:[]},o);s instanceof Promise?a.push(s.then((n=>Ta(n,t,e)))):Ta(s,t,e)}return a.length?Promise.all(a).then((()=>t)):t}}));function Sa(e,n,t,o,r){if(e.issues.length){if(r&&!(t in o))return;n.issues.push(...Po(t,e.issues))}void 0===e.value?t in o&&(n.value[t]=void 0):n.value[t]=e.value}function Ca(e){var n,t,o,r;const a=Object.keys(e.shape);for(const c of a)if(!(null==(r=null==(o=null==(t=null==(n=e.shape)?void 0:n[c])?void 0:t._zod)?void 0:o.traits)?void 0:r.has("$ZodType")))throw new Error(`Invalid element at key "${c}": expected a Zod schema`);const i=(s=e.shape,Object.keys(s).filter((e=>"optional"===s[e]._zod.optin&&"optional"===s[e]._zod.optout)));var s;return{...e,keys:a,keySet:new Set(a),numKeys:a.length,optionalKeys:new Set(i)}}function Ia(e,n,t,o,r,a){const i=[],s=r.keySet,c=r.catchall._zod,l=c.def.type,d="optional"===c.optout;for(const u in n){if(s.has(u))continue;if("never"===l){i.push(u);continue}const r=c.run({value:n[u],issues:[]},o);r instanceof Promise?e.push(r.then((e=>Sa(e,t,u,n,d)))):Sa(r,t,u,n,d)}return i.length&&t.issues.push({code:"unrecognized_keys",keys:i,input:n,inst:a}),e.length?Promise.all(e).then((()=>t)):t}const Ra=so("$ZodObject",((e,n)=>{Kr.init(e,n);const t=Object.getOwnPropertyDescriptor(n,"shape");if(!(null==t?void 0:t.get)){const e=n.shape;Object.defineProperty(n,"shape",{get:()=>{const t={...e};return Object.defineProperty(n,"shape",{value:t}),t}})}const o=mo((()=>Ca(n)));bo(e._zod,"propValues",(()=>{const e=n.shape,t={};for(const n in e){const o=e[n]._zod;if(o.values){t[n]??(t[n]=new Set);for(const e of o.values)t[n].add(e)}}return t}));const r=Eo,a=n.catchall;let i;e._zod.parse=(n,t)=>{i??(i=o.value);const s=n.value;if(!r(s))return n.issues.push({expected:"object",code:"invalid_type",input:s,inst:e}),n;n.value={};const c=[],l=i.shape;for(const e of i.keys){const o=l[e],r="optional"===o._zod.optout,a=o._zod.run({value:s[e],issues:[]},t);a instanceof Promise?c.push(a.then((t=>Sa(t,n,e,s,r)))):Sa(a,n,e,s,r)}return a?Ia(c,s,n,t,o.value,e):c.length?Promise.all(c).then((()=>n)):n}})),Oa=so("$ZodObjectJIT",((e,n)=>{Ra.init(e,n);const t=e._zod.parse,o=mo((()=>Ca(n)));let r;const a=Eo,i=!uo.jitless,s=i&&To.value,c=n.catchall;let l;e._zod.parse=(d,u)=>{l??(l=o.value);const p=d.value;return a(p)?i&&s&&!1===(null==u?void 0:u.async)&&!0!==u.jitless?(r||(r=(e=>{var n;const t=new Ur(["shape","payload","ctx"]),r=o.value,a=e=>{const n=_o(e);return`shape[${n}]._zod.run({ value: input[${n}], issues: [] }, ctx)`};t.write("const input = payload.value;");const i=Object.create(null);let s=0;for(const o of r.keys)i[o]="key_"+s++;t.write("const newResult = {};");for(const o of r.keys){const r=i[o],s=_o(o),c=e[o],l="optional"===(null==(n=null==c?void 0:c._zod)?void 0:n.optout);t.write(`const ${r} = ${a(o)};`),l?t.write(`\n if (${r}.issues.length) {\n if (${s} in input) {\n payload.issues = payload.issues.concat(${r}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n }\n \n if (${r}.value === undefined) {\n if (${s} in input) {\n newResult[${s}] = undefined;\n }\n } else {\n newResult[${s}] = ${r}.value;\n }\n \n `):t.write(`\n if (${r}.issues.length) {\n payload.issues = payload.issues.concat(${r}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n \n if (${r}.value === undefined) {\n if (${s} in input) {\n newResult[${s}] = undefined;\n }\n } else {\n newResult[${s}] = ${r}.value;\n }\n \n `)}t.write("payload.value = newResult;"),t.write("return payload;");const c=t.compile();return(n,t)=>c(e,n,t)})(n.shape)),d=r(d,u),c?Ia([],p,d,u,l,e):d):t(d,u):(d.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),d)}}));function ja(e,n,t,o){for(const a of e)if(0===a.issues.length)return n.value=a.value,n;const r=e.filter((e=>!Ao(e)));return 1===r.length?(n.value=r[0].value,r[0]):(n.issues.push({code:"invalid_union",input:n.value,inst:t,errors:e.map((e=>e.issues.map((e=>zo(e,o,po())))))}),n)}const Aa=so("$ZodUnion",((e,n)=>{Kr.init(e,n),bo(e._zod,"optin",(()=>n.options.some((e=>"optional"===e._zod.optin))?"optional":void 0)),bo(e._zod,"optout",(()=>n.options.some((e=>"optional"===e._zod.optout))?"optional":void 0)),bo(e._zod,"values",(()=>{if(n.options.every((e=>e._zod.values)))return new Set(n.options.flatMap((e=>Array.from(e._zod.values))))})),bo(e._zod,"pattern",(()=>{if(n.options.every((e=>e._zod.pattern))){const e=n.options.map((e=>e._zod.pattern));return new RegExp(`^(${e.map((e=>vo(e.source))).join("|")})$`)}}));const t=1===n.options.length,o=n.options[0]._zod.run;e._zod.parse=(r,a)=>{if(t)return o(r,a);let i=!1;const s=[];for(const e of n.options){const n=e._zod.run({value:r.value,issues:[]},a);if(n instanceof Promise)s.push(n),i=!0;else{if(0===n.issues.length)return n;s.push(n)}}return i?Promise.all(s).then((n=>ja(n,r,e,a))):ja(s,r,e,a)}})),Pa=so("$ZodIntersection",((e,n)=>{Kr.init(e,n),e._zod.parse=(e,t)=>{const o=e.value,r=n.left._zod.run({value:o,issues:[]},t),a=n.right._zod.run({value:o,issues:[]},t);return r instanceof Promise||a instanceof Promise?Promise.all([r,a]).then((([n,t])=>za(e,n,t))):za(e,r,a)}}));function Fa(e,n){if(e===n)return{valid:!0,data:e};if(e instanceof Date&&n instanceof Date&&+e==+n)return{valid:!0,data:e};if(No(e)&&No(n)){const t=Object.keys(n),o=Object.keys(e).filter((e=>-1!==t.indexOf(e))),r={...e,...n};for(const a of o){const t=Fa(e[a],n[a]);if(!t.valid)return{valid:!1,mergeErrorPath:[a,...t.mergeErrorPath]};r[a]=t.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return{valid:!1,mergeErrorPath:[]};const t=[];for(let o=0;o<e.length;o++){const r=Fa(e[o],n[o]);if(!r.valid)return{valid:!1,mergeErrorPath:[o,...r.mergeErrorPath]};t.push(r.data)}return{valid:!0,data:t}}return{valid:!1,mergeErrorPath:[]}}function za(e,n,t){const o=new Map;let r;for(const s of n.issues)if("unrecognized_keys"===s.code){r??(r=s);for(const e of s.keys)o.has(e)||o.set(e,{}),o.get(e).l=!0}else e.issues.push(s);for(const s of t.issues)if("unrecognized_keys"===s.code)for(const e of s.keys)o.has(e)||o.set(e,{}),o.get(e).r=!0;else e.issues.push(s);const a=[...o].filter((([,e])=>e.l&&e.r)).map((([e])=>e));if(a.length&&r&&e.issues.push({...r,keys:a}),Ao(e))return e;const i=Fa(n.value,t.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const $a=so("$ZodEnum",((e,n)=>{Kr.init(e,n);const t=fo(n.entries),o=new Set(t);e._zod.values=o,e._zod.pattern=new RegExp(`^(${t.filter((e=>Co.has(typeof e))).map((e=>"string"==typeof e?Io(e):e.toString())).join("|")})$`),e._zod.parse=(n,r)=>{const a=n.value;return o.has(a)||n.issues.push({code:"invalid_value",values:t,input:a,inst:e}),n}})),Da=so("$ZodTransform",((e,n)=>{Kr.init(e,n),e._zod.parse=(t,o)=>{if("backward"===o.direction)throw new lo(e.constructor.name);const r=n.transform(t.value,t);if(o.async){return(r instanceof Promise?r:Promise.resolve(r)).then((e=>(t.value=e,t)))}if(r instanceof Promise)throw new co;return t.value=r,t}}));function Ma(e,n){return e.issues.length&&void 0===n?{issues:[],value:void 0}:e}const La=so("$ZodOptional",((e,n)=>{Kr.init(e,n),e._zod.optin="optional",e._zod.optout="optional",bo(e._zod,"values",(()=>n.innerType._zod.values?new Set([...n.innerType._zod.values,void 0]):void 0)),bo(e._zod,"pattern",(()=>{const e=n.innerType._zod.pattern;return e?new RegExp(`^(${vo(e.source)})?$`):void 0})),e._zod.parse=(e,t)=>{if("optional"===n.innerType._zod.optin){const o=n.innerType._zod.run(e,t);return o instanceof Promise?o.then((n=>Ma(n,e.value))):Ma(o,e.value)}return void 0===e.value?e:n.innerType._zod.run(e,t)}})),Ba=so("$ZodExactOptional",((e,n)=>{La.init(e,n),bo(e._zod,"values",(()=>n.innerType._zod.values)),bo(e._zod,"pattern",(()=>n.innerType._zod.pattern)),e._zod.parse=(e,t)=>n.innerType._zod.run(e,t)})),Wa=so("$ZodNullable",((e,n)=>{Kr.init(e,n),bo(e._zod,"optin",(()=>n.innerType._zod.optin)),bo(e._zod,"optout",(()=>n.innerType._zod.optout)),bo(e._zod,"pattern",(()=>{const e=n.innerType._zod.pattern;return e?new RegExp(`^(${vo(e.source)}|null)$`):void 0})),bo(e._zod,"values",(()=>n.innerType._zod.values?new Set([...n.innerType._zod.values,null]):void 0)),e._zod.parse=(e,t)=>null===e.value?e:n.innerType._zod.run(e,t)})),qa=so("$ZodDefault",((e,n)=>{Kr.init(e,n),e._zod.optin="optional",bo(e._zod,"values",(()=>n.innerType._zod.values)),e._zod.parse=(e,t)=>{if("backward"===t.direction)return n.innerType._zod.run(e,t);if(void 0===e.value)return e.value=n.defaultValue,e;const o=n.innerType._zod.run(e,t);return o instanceof Promise?o.then((e=>Ua(e,n))):Ua(o,n)}}));function Ua(e,n){return void 0===e.value&&(e.value=n.defaultValue),e}const Va=so("$ZodPrefault",((e,n)=>{Kr.init(e,n),e._zod.optin="optional",bo(e._zod,"values",(()=>n.innerType._zod.values)),e._zod.parse=(e,t)=>("backward"===t.direction||void 0===e.value&&(e.value=n.defaultValue),n.innerType._zod.run(e,t))})),Ka=so("$ZodNonOptional",((e,n)=>{Kr.init(e,n),bo(e._zod,"values",(()=>{const e=n.innerType._zod.values;return e?new Set([...e].filter((e=>void 0!==e))):void 0})),e._zod.parse=(t,o)=>{const r=n.innerType._zod.run(t,o);return r instanceof Promise?r.then((n=>Za(n,e))):Za(r,e)}}));function Za(e,n){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:n}),e}const Ha=so("$ZodCatch",((e,n)=>{Kr.init(e,n),bo(e._zod,"optin",(()=>n.innerType._zod.optin)),bo(e._zod,"optout",(()=>n.innerType._zod.optout)),bo(e._zod,"values",(()=>n.innerType._zod.values)),e._zod.parse=(e,t)=>{if("backward"===t.direction)return n.innerType._zod.run(e,t);const o=n.innerType._zod.run(e,t);return o instanceof Promise?o.then((o=>(e.value=o.value,o.issues.length&&(e.value=n.catchValue({...e,error:{issues:o.issues.map((e=>zo(e,t,po())))},input:e.value}),e.issues=[]),e))):(e.value=o.value,o.issues.length&&(e.value=n.catchValue({...e,error:{issues:o.issues.map((e=>zo(e,t,po())))},input:e.value}),e.issues=[]),e)}})),Ga=so("$ZodPipe",((e,n)=>{Kr.init(e,n),bo(e._zod,"values",(()=>n.in._zod.values)),bo(e._zod,"optin",(()=>n.in._zod.optin)),bo(e._zod,"optout",(()=>n.out._zod.optout)),bo(e._zod,"propValues",(()=>n.in._zod.propValues)),e._zod.parse=(e,t)=>{if("backward"===t.direction){const o=n.out._zod.run(e,t);return o instanceof Promise?o.then((e=>Ja(e,n.in,t))):Ja(o,n.in,t)}const o=n.in._zod.run(e,t);return o instanceof Promise?o.then((e=>Ja(e,n.out,t))):Ja(o,n.out,t)}}));function Ja(e,n,t){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:e.value,issues:e.issues},t)}const Xa=so("$ZodReadonly",((e,n)=>{Kr.init(e,n),bo(e._zod,"propValues",(()=>n.innerType._zod.propValues)),bo(e._zod,"values",(()=>n.innerType._zod.values)),bo(e._zod,"optin",(()=>{var e,t;return null==(t=null==(e=n.innerType)?void 0:e._zod)?void 0:t.optin})),bo(e._zod,"optout",(()=>{var e,t;return null==(t=null==(e=n.innerType)?void 0:e._zod)?void 0:t.optout})),e._zod.parse=(e,t)=>{if("backward"===t.direction)return n.innerType._zod.run(e,t);const o=n.innerType._zod.run(e,t);return o instanceof Promise?o.then(Ya):Ya(o)}}));function Ya(e){return e.value=Object.freeze(e.value),e}const Qa=so("$ZodCustom",((e,n)=>{Sr.init(e,n),Kr.init(e,n),e._zod.parse=(e,n)=>e,e._zod.check=t=>{const o=t.value,r=n.fn(o);if(r instanceof Promise)return r.then((n=>ei(n,t,o,e)));ei(r,t,o,e)}}));function ei(e,n,t,o){if(!e){const e={code:"custom",input:t,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(e.params=o._zod.def.params),n.issues.push(Do(e))}}var ni;class ti{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...n){const t=n[0];return this._map.set(e,t),t&&"object"==typeof t&&"id"in t&&this._idmap.set(t.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const n=this._map.get(e);return n&&"object"==typeof n&&"id"in n&&this._idmap.delete(n.id),this._map.delete(e),this}get(e){const n=e._zod.parent;if(n){const t={...this.get(n)??{}};delete t.id;const o={...t,...this._map.get(e)};return Object.keys(o).length?o:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}(ni=globalThis).__zod_globalRegistry??(ni.__zod_globalRegistry=new ti);const oi=globalThis.__zod_globalRegistry;function ri(e,n){return new e({type:"string",...Oo(n)})}function ai(e,n){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Oo(n)})}function ii(e,n){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Oo(n)})}function si(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Oo(n)})}function ci(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Oo(n)})}function li(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Oo(n)})}function di(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Oo(n)})}function ui(e,n){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Oo(n)})}function pi(e,n){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Oo(n)})}function fi(e,n){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Oo(n)})}function hi(e,n){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Oo(n)})}function mi(e,n){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Oo(n)})}function gi(e,n){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Oo(n)})}function vi(e,n){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Oo(n)})}function wi(e,n){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Oo(n)})}function bi(e,n){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Oo(n)})}function xi(e,n){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Oo(n)})}function yi(e,n){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Oo(n)})}function _i(e,n){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Oo(n)})}function ki(e,n){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Oo(n)})}function Ei(e,n){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Oo(n)})}function Ti(e,n){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Oo(n)})}function Ni(e,n){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Oo(n)})}function Si(e,n){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Oo(n)})}function Ci(e,n){return new e({type:"string",format:"date",check:"string_format",...Oo(n)})}function Ii(e,n){return new e({type:"string",format:"time",check:"string_format",precision:null,...Oo(n)})}function Ri(e,n){return new e({type:"string",format:"duration",check:"string_format",...Oo(n)})}function Oi(e,n){return new e({type:"number",checks:[],...Oo(n)})}function ji(e,n){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Oo(n)})}function Ai(e,n){return new e({type:"boolean",...Oo(n)})}function Pi(e){return new e({type:"any"})}function Fi(e){return new e({type:"unknown"})}function zi(e,n){return new e({type:"never",...Oo(n)})}function $i(e,n){return new Ir({check:"less_than",...Oo(n),value:e,inclusive:!1})}function Di(e,n){return new Ir({check:"less_than",...Oo(n),value:e,inclusive:!0})}function Mi(e,n){return new Rr({check:"greater_than",...Oo(n),value:e,inclusive:!1})}function Li(e,n){return new Rr({check:"greater_than",...Oo(n),value:e,inclusive:!0})}function Bi(e,n){return new Or({check:"multiple_of",...Oo(n),value:e})}function Wi(e,n){return new Ar({check:"max_length",...Oo(n),maximum:e})}function qi(e,n){return new Pr({check:"min_length",...Oo(n),minimum:e})}function Ui(e,n){return new Fr({check:"length_equals",...Oo(n),length:e})}function Vi(e,n){return new $r({check:"string_format",format:"regex",...Oo(n),pattern:e})}function Ki(e){return new Dr({check:"string_format",format:"lowercase",...Oo(e)})}function Zi(e){return new Mr({check:"string_format",format:"uppercase",...Oo(e)})}function Hi(e,n){return new Lr({check:"string_format",format:"includes",...Oo(n),includes:e})}function Gi(e,n){return new Br({check:"string_format",format:"starts_with",...Oo(n),prefix:e})}function Ji(e,n){return new Wr({check:"string_format",format:"ends_with",...Oo(n),suffix:e})}function Xi(e){return new qr({check:"overwrite",tx:e})}function Yi(e){return Xi((n=>n.normalize(e)))}function Qi(){return Xi((e=>e.trim()))}function es(){return Xi((e=>e.toLowerCase()))}function ns(){return Xi((e=>e.toUpperCase()))}function ts(){return Xi((e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}function os(e,n,t){return new e({type:"array",element:n,...Oo(t)})}function rs(e,n,t){return new e({type:"custom",check:"custom",fn:n,...Oo(t)})}function as(e){const n=is((t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(Do(e,t.value,n._zod.def));else{const o=e;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=t.value),o.inst??(o.inst=n),o.continue??(o.continue=!n._zod.def.abort),t.issues.push(Do(o))}},e(t.value,t))));return n}function is(e,n){const t=new Sr({check:"custom",...Oo(n)});return t._zod.check=e,t}function ss(e){let n=(null==e?void 0:e.target)??"draft-2020-12";return"draft-4"===n&&(n="draft-04"),"draft-7"===n&&(n="draft-07"),{processors:e.processors??{},metadataRegistry:(null==e?void 0:e.metadata)??oi,target:n,unrepresentable:(null==e?void 0:e.unrepresentable)??"throw",override:(null==e?void 0:e.override)??(()=>{}),io:(null==e?void 0:e.io)??"output",counter:0,seen:new Map,cycles:(null==e?void 0:e.cycles)??"ref",reused:(null==e?void 0:e.reused)??"inline",external:(null==e?void 0:e.external)??void 0}}function cs(e,n,t={path:[],schemaPath:[]}){var o,r,a;const i=e._zod.def,s=n.seen.get(e);if(s){s.count++;return t.schemaPath.includes(e)&&(s.cycle=t.path),s.schema}const c={schema:{},count:1,cycle:void 0,path:t.path};n.seen.set(e,c);const l=null==(r=(o=e._zod).toJSONSchema)?void 0:r.call(o);if(l)c.schema=l;else{const o={...t,schemaPath:[...t.schemaPath,e],path:t.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(n,c.schema,o);else{const t=c.schema,r=n.processors[i.type];if(!r)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);r(e,n,t,o)}const r=e._zod.parent;r&&(c.ref||(c.ref=r),cs(r,n,o),n.seen.get(r).isParent=!0)}const d=n.metadataRegistry.get(e);d&&Object.assign(c.schema,d),"input"===n.io&&us(e)&&(delete c.schema.examples,delete c.schema.default),"input"===n.io&&c.schema._prefault&&((a=c.schema).default??(a.default=c.schema._prefault)),delete c.schema._prefault;return n.seen.get(e).schema}function ls(e,n){var t,o,r,a;const i=e.seen.get(n);if(!i)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=new Map;for(const l of e.seen.entries()){const n=null==(t=e.metadataRegistry.get(l[0]))?void 0:t.id;if(n){const e=s.get(n);if(e&&e!==l[0])throw new Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);s.set(n,l[0])}}const c=n=>{if(n[1].schema.$ref)return;const t=n[1],{ref:o,defId:r}=(n=>{var t;const o="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const r=null==(t=e.external.registry.get(n[0]))?void 0:t.id,a=e.external.uri??(e=>e);if(r)return{ref:a(r)};const i=n[1].defId??n[1].schema.id??"schema"+e.counter++;return n[1].defId=i,{defId:i,ref:`${a("__shared")}#/${o}/${i}`}}if(n[1]===i)return{ref:"#"};const r=`#/${o}/`,a=n[1].schema.id??"__schema"+e.counter++;return{defId:a,ref:r+a}})(n);t.def={...t.schema},r&&(t.defId=r);const a=t.schema;for(const e in a)delete a[e];a.$ref=o};if("throw"===e.cycles)for(const l of e.seen.entries()){const e=l[1];if(e.cycle)throw new Error(`Cycle detected: #/${null==(o=e.cycle)?void 0:o.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const l of e.seen.entries()){const t=l[1];if(n===l[0]){c(l);continue}if(e.external){const t=null==(r=e.external.registry.get(l[0]))?void 0:r.id;if(n!==l[0]&&t){c(l);continue}}(null==(a=e.metadataRegistry.get(l[0]))?void 0:a.id)?c(l):(t.cycle||t.count>1&&"ref"===e.reused)&&c(l)}}function ds(e,n){var t,o,r;const a=e.seen.get(n);if(!a)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=n=>{const t=e.seen.get(n);if(null===t.ref)return;const o=t.def??t.schema,r={...o},a=t.ref;if(t.ref=null,a){i(a);const t=e.seen.get(a),s=t.schema;!s.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?Object.assign(o,s):(o.allOf=o.allOf??[],o.allOf.push(s)),Object.assign(o,r);if(n._zod.parent===a)for(const e in o)"$ref"!==e&&"allOf"!==e&&(e in r||delete o[e]);if(s.$ref&&t.def)for(const e in o)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(o[e])===JSON.stringify(t.def[e])&&delete o[e]}const s=n._zod.parent;if(s&&s!==a){i(s);const n=e.seen.get(s);if((null==n?void 0:n.schema.$ref)&&(o.$ref=n.schema.$ref,n.def))for(const e in o)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(o[e])===JSON.stringify(n.def[e])&&delete o[e]}e.override({zodSchema:n,jsonSchema:o,path:t.path??[]})};for(const d of[...e.seen.entries()].reverse())i(d[0]);const s={};if("draft-2020-12"===e.target?s.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?s.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?s.$schema="http://json-schema.org/draft-04/schema#":e.target,null==(t=e.external)?void 0:t.uri){const t=null==(o=e.external.registry.get(n))?void 0:o.id;if(!t)throw new Error("Schema is missing an `id` property");s.$id=e.external.uri(t)}Object.assign(s,a.def??a.schema);const c=(null==(r=e.external)?void 0:r.defs)??{};for(const d of e.seen.entries()){const e=d[1];e.def&&e.defId&&(c[e.defId]=e.def)}e.external||Object.keys(c).length>0&&("draft-2020-12"===e.target?s.$defs=c:s.definitions=c);try{const t=JSON.parse(JSON.stringify(s));return Object.defineProperty(t,"~standard",{value:{...n["~standard"],jsonSchema:{input:ps(n,"input",e.processors),output:ps(n,"output",e.processors)}},enumerable:!1,writable:!1}),t}catch(l){throw new Error("Error converting schema to JSON.")}}function us(e,n){const t=n??{seen:new Set};if(t.seen.has(e))return!1;t.seen.add(e);const o=e._zod.def;if("transform"===o.type)return!0;if("array"===o.type)return us(o.element,t);if("set"===o.type)return us(o.valueType,t);if("lazy"===o.type)return us(o.getter(),t);if("promise"===o.type||"optional"===o.type||"nonoptional"===o.type||"nullable"===o.type||"readonly"===o.type||"default"===o.type||"prefault"===o.type)return us(o.innerType,t);if("intersection"===o.type)return us(o.left,t)||us(o.right,t);if("record"===o.type||"map"===o.type)return us(o.keyType,t)||us(o.valueType,t);if("pipe"===o.type)return us(o.in,t)||us(o.out,t);if("object"===o.type){for(const e in o.shape)if(us(o.shape[e],t))return!0;return!1}if("union"===o.type){for(const e of o.options)if(us(e,t))return!0;return!1}if("tuple"===o.type){for(const e of o.items)if(us(e,t))return!0;return!(!o.rest||!us(o.rest,t))}return!1}const ps=(e,n,t={})=>o=>{const{libraryOptions:r,target:a}=o??{},i=ss({...r??{},target:a,io:n,processors:t});return cs(e,i),ls(i,e),ds(i,e)},fs={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},hs=(e,n,t,o)=>{const r=e._zod.def;cs(r.innerType,n,o);n.seen.get(e).ref=r.innerType},ms=so("ZodISODateTime",((e,n)=>{ia.init(e,n),zs.init(e,n)}));const gs=so("ZodISODate",((e,n)=>{sa.init(e,n),zs.init(e,n)}));const vs=so("ZodISOTime",((e,n)=>{ca.init(e,n),zs.init(e,n)}));const ws=so("ZodISODuration",((e,n)=>{la.init(e,n),zs.init(e,n)}));const bs=so("ZodError",((e,n)=>{Lo.init(e,n),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>function(e,n=e=>e.message){const t={_errors:[]},o=e=>{for(const r of e.issues)if("invalid_union"===r.code&&r.errors.length)r.errors.map((e=>o({issues:e})));else if("invalid_key"===r.code)o({issues:r.issues});else if("invalid_element"===r.code)o({issues:r.issues});else if(0===r.path.length)t._errors.push(n(r));else{let e=t,o=0;for(;o<r.path.length;){const t=r.path[o];o===r.path.length-1?(e[t]=e[t]||{_errors:[]},e[t]._errors.push(n(r))):e[t]=e[t]||{_errors:[]},e=e[t],o++}}};return o(e),t}(e,n)},flatten:{value:n=>function(e,n=e=>e.message){const t={},o=[];for(const r of e.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(n(r))):o.push(n(r));return{formErrors:o,fieldErrors:t}}(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,ho,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,ho,2)}},isEmpty:{get:()=>0===e.issues.length}})}),{Parent:Error}),xs=Wo(bs),ys=qo(bs),_s=Uo(bs),ks=Ko(bs),Es=Ho(bs),Ts=Go(bs),Ns=Jo(bs),Ss=Xo(bs),Cs=Yo(bs),Is=Qo(bs),Rs=er(bs),Os=nr(bs),js=so("ZodType",((e,n)=>(Kr.init(e,n),Object.assign(e["~standard"],{jsonSchema:{input:ps(e,"input"),output:ps(e,"output")}}),e.toJSONSchema=((e,n={})=>t=>{const o=ss({...t,processors:n});return cs(e,o),ls(o,e),ds(o,e)})(e,{}),e.def=n,e.type=n.type,Object.defineProperty(e,"_def",{value:n}),e.check=(...t)=>e.clone(yo(n,{checks:[...n.checks??[],...t.map((e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e))]}),{parent:!0}),e.with=e.check,e.clone=(n,t)=>Ro(e,n,t),e.brand=()=>e,e.register=(n,t)=>(n.add(e,t),e),e.parse=(n,t)=>xs(e,n,t,{callee:e.parse}),e.safeParse=(n,t)=>_s(e,n,t),e.parseAsync=async(n,t)=>ys(e,n,t,{callee:e.parseAsync}),e.safeParseAsync=async(n,t)=>ks(e,n,t),e.spa=e.safeParseAsync,e.encode=(n,t)=>Es(e,n,t),e.decode=(n,t)=>Ts(e,n,t),e.encodeAsync=async(n,t)=>Ns(e,n,t),e.decodeAsync=async(n,t)=>Ss(e,n,t),e.safeEncode=(n,t)=>Cs(e,n,t),e.safeDecode=(n,t)=>Is(e,n,t),e.safeEncodeAsync=async(n,t)=>Rs(e,n,t),e.safeDecodeAsync=async(n,t)=>Os(e,n,t),e.refine=(n,t)=>e.check(function(e,n={}){return rs(Oc,e,n)}(n,t)),e.superRefine=n=>e.check(as(n)),e.overwrite=n=>e.check(Xi(n)),e.optional=()=>xc(e),e.exactOptional=()=>new yc({type:"optional",innerType:e}),e.nullable=()=>kc(e),e.nullish=()=>xc(kc(e)),e.nonoptional=n=>function(e,n){return new Nc({type:"nonoptional",innerType:e,...Oo(n)})}(e,n),e.array=()=>{return os(uc,e,n);var n},e.or=n=>{return new hc({type:"union",options:[e,n],...Oo(t)});var t},e.and=n=>new mc({type:"intersection",left:e,right:n}),e.transform=n=>Ic(e,new wc({type:"transform",transform:n})),e.default=n=>{return t=n,new Ec({type:"default",innerType:e,get defaultValue(){return"function"==typeof t?t():So(t)}});var t},e.prefault=n=>{return t=n,new Tc({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof t?t():So(t)}});var t},e.catch=n=>{return new Sc({type:"catch",innerType:e,catchValue:"function"==typeof(t=n)?t:()=>t});var t},e.pipe=n=>Ic(e,n),e.readonly=()=>new Rc({type:"readonly",innerType:e}),e.describe=n=>{const t=e.clone();return oi.add(t,{description:n}),t},Object.defineProperty(e,"description",{get(){var n;return null==(n=oi.get(e))?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(0===n.length)return oi.get(e);const t=e.clone();return oi.add(t,n[0]),t},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e))),As=so("_ZodString",((e,n)=>{Zr.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t)=>{const o=t;o.type="string";const{minimum:r,maximum:a,format:i,patterns:s,contentEncoding:c}=e._zod.bag;if("number"==typeof r&&(o.minLength=r),"number"==typeof a&&(o.maxLength=a),i&&(o.format=fs[i]??i,""===o.format&&delete o.format,"time"===i&&delete o.format),c&&(o.contentEncoding=c),s&&s.size>0){const e=[...s];1===e.length?o.pattern=e[0].source:e.length>1&&(o.allOf=[...e.map((e=>({..."draft-07"===n.target||"draft-04"===n.target||"openapi-3.0"===n.target?{type:"string"}:{},pattern:e.source})))])}})(e,n,t);const t=e._zod.bag;e.format=t.format??null,e.minLength=t.minimum??null,e.maxLength=t.maximum??null,e.regex=(...n)=>e.check(Vi(...n)),e.includes=(...n)=>e.check(Hi(...n)),e.startsWith=(...n)=>e.check(Gi(...n)),e.endsWith=(...n)=>e.check(Ji(...n)),e.min=(...n)=>e.check(qi(...n)),e.max=(...n)=>e.check(Wi(...n)),e.length=(...n)=>e.check(Ui(...n)),e.nonempty=(...n)=>e.check(qi(1,...n)),e.lowercase=n=>e.check(Ki(n)),e.uppercase=n=>e.check(Zi(n)),e.trim=()=>e.check(Qi()),e.normalize=(...n)=>e.check(Yi(...n)),e.toLowerCase=()=>e.check(es()),e.toUpperCase=()=>e.check(ns()),e.slugify=()=>e.check(ts())})),Ps=so("ZodString",((e,n)=>{Zr.init(e,n),As.init(e,n),e.email=n=>e.check(ai($s,n)),e.url=n=>e.check(ui(Ls,n)),e.jwt=n=>e.check(Ni(nc,n)),e.emoji=n=>e.check(pi(Bs,n)),e.guid=n=>e.check(ii(Ds,n)),e.uuid=n=>e.check(si(Ms,n)),e.uuidv4=n=>e.check(ci(Ms,n)),e.uuidv6=n=>e.check(li(Ms,n)),e.uuidv7=n=>e.check(di(Ms,n)),e.nanoid=n=>e.check(fi(Ws,n)),e.guid=n=>e.check(ii(Ds,n)),e.cuid=n=>e.check(hi(qs,n)),e.cuid2=n=>e.check(mi(Us,n)),e.ulid=n=>e.check(gi(Vs,n)),e.base64=n=>e.check(ki(Ys,n)),e.base64url=n=>e.check(Ei(Qs,n)),e.xid=n=>e.check(vi(Ks,n)),e.ksuid=n=>e.check(wi(Zs,n)),e.ipv4=n=>e.check(bi(Hs,n)),e.ipv6=n=>e.check(xi(Gs,n)),e.cidrv4=n=>e.check(yi(Js,n)),e.cidrv6=n=>e.check(_i(Xs,n)),e.e164=n=>e.check(Ti(ec,n)),e.datetime=n=>e.check(function(e){return Si(ms,e)}(n)),e.date=n=>e.check(function(e){return Ci(gs,e)}(n)),e.time=n=>e.check(function(e){return Ii(vs,e)}(n)),e.duration=n=>e.check(function(e){return Ri(ws,e)}(n))}));function Fs(e){return ri(Ps,e)}const zs=so("ZodStringFormat",((e,n)=>{Hr.init(e,n),As.init(e,n)})),$s=so("ZodEmail",((e,n)=>{Xr.init(e,n),zs.init(e,n)})),Ds=so("ZodGUID",((e,n)=>{Gr.init(e,n),zs.init(e,n)})),Ms=so("ZodUUID",((e,n)=>{Jr.init(e,n),zs.init(e,n)})),Ls=so("ZodURL",((e,n)=>{Yr.init(e,n),zs.init(e,n)})),Bs=so("ZodEmoji",((e,n)=>{Qr.init(e,n),zs.init(e,n)})),Ws=so("ZodNanoID",((e,n)=>{ea.init(e,n),zs.init(e,n)})),qs=so("ZodCUID",((e,n)=>{na.init(e,n),zs.init(e,n)})),Us=so("ZodCUID2",((e,n)=>{ta.init(e,n),zs.init(e,n)})),Vs=so("ZodULID",((e,n)=>{oa.init(e,n),zs.init(e,n)})),Ks=so("ZodXID",((e,n)=>{ra.init(e,n),zs.init(e,n)})),Zs=so("ZodKSUID",((e,n)=>{aa.init(e,n),zs.init(e,n)})),Hs=so("ZodIPv4",((e,n)=>{da.init(e,n),zs.init(e,n)})),Gs=so("ZodIPv6",((e,n)=>{ua.init(e,n),zs.init(e,n)})),Js=so("ZodCIDRv4",((e,n)=>{pa.init(e,n),zs.init(e,n)})),Xs=so("ZodCIDRv6",((e,n)=>{fa.init(e,n),zs.init(e,n)})),Ys=so("ZodBase64",((e,n)=>{ma.init(e,n),zs.init(e,n)})),Qs=so("ZodBase64URL",((e,n)=>{ga.init(e,n),zs.init(e,n)})),ec=so("ZodE164",((e,n)=>{va.init(e,n),zs.init(e,n)})),nc=so("ZodJWT",((e,n)=>{wa.init(e,n),zs.init(e,n)})),tc=so("ZodNumber",((e,n)=>{ba.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t)=>{const o=t,{minimum:r,maximum:a,format:i,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l}=e._zod.bag;"string"==typeof i&&i.includes("int")?o.type="integer":o.type="number","number"==typeof l&&("draft-04"===n.target||"openapi-3.0"===n.target?(o.minimum=l,o.exclusiveMinimum=!0):o.exclusiveMinimum=l),"number"==typeof r&&(o.minimum=r,"number"==typeof l&&"draft-04"!==n.target&&(l>=r?delete o.minimum:delete o.exclusiveMinimum)),"number"==typeof c&&("draft-04"===n.target||"openapi-3.0"===n.target?(o.maximum=c,o.exclusiveMaximum=!0):o.exclusiveMaximum=c),"number"==typeof a&&(o.maximum=a,"number"==typeof c&&"draft-04"!==n.target&&(c<=a?delete o.maximum:delete o.exclusiveMaximum)),"number"==typeof s&&(o.multipleOf=s)})(e,n,t),e.gt=(n,t)=>e.check(Mi(n,t)),e.gte=(n,t)=>e.check(Li(n,t)),e.min=(n,t)=>e.check(Li(n,t)),e.lt=(n,t)=>e.check($i(n,t)),e.lte=(n,t)=>e.check(Di(n,t)),e.max=(n,t)=>e.check(Di(n,t)),e.int=n=>e.check(rc(n)),e.safe=n=>e.check(rc(n)),e.positive=n=>e.check(Mi(0,n)),e.nonnegative=n=>e.check(Li(0,n)),e.negative=n=>e.check($i(0,n)),e.nonpositive=n=>e.check(Di(0,n)),e.multipleOf=(n,t)=>e.check(Bi(n,t)),e.step=(n,t)=>e.check(Bi(n,t)),e.finite=()=>e;const t=e._zod.bag;e.minValue=Math.max(t.minimum??Number.NEGATIVE_INFINITY,t.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(t.maximum??Number.POSITIVE_INFINITY,t.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(t.format??"").includes("int")||Number.isSafeInteger(t.multipleOf??.5),e.isFinite=!0,e.format=t.format??null}));const oc=so("ZodNumberFormat",((e,n)=>{xa.init(e,n),tc.init(e,n)}));function rc(e){return ji(oc,e)}const ac=so("ZodBoolean",((e,n)=>{ya.init(e,n),js.init(e,n),e._zod.processJSONSchema=(e,n,t)=>((e,n,t)=>{t.type="boolean"})(0,0,n)}));function ic(e){return Ai(ac,e)}const sc=so("ZodAny",((e,n)=>{_a.init(e,n),js.init(e,n),e._zod.processJSONSchema=(e,n,t)=>{}}));const cc=so("ZodUnknown",((e,n)=>{ka.init(e,n),js.init(e,n),e._zod.processJSONSchema=(e,n,t)=>{}}));function lc(){return Fi(cc)}const dc=so("ZodNever",((e,n)=>{Ea.init(e,n),js.init(e,n),e._zod.processJSONSchema=(e,n,t)=>((e,n,t)=>{t.not={}})(0,0,n)}));const uc=so("ZodArray",((e,n)=>{Na.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t,o)=>{const r=t,a=e._zod.def,{minimum:i,maximum:s}=e._zod.bag;"number"==typeof i&&(r.minItems=i),"number"==typeof s&&(r.maxItems=s),r.type="array",r.items=cs(a.element,n,{...o,path:[...o.path,"items"]})})(e,n,t,o),e.element=n.element,e.min=(n,t)=>e.check(qi(n,t)),e.nonempty=n=>e.check(qi(1,n)),e.max=(n,t)=>e.check(Wi(n,t)),e.length=(n,t)=>e.check(Ui(n,t)),e.unwrap=()=>e.element}));const pc=so("ZodObject",((e,n)=>{Oa.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t,o)=>{var r;const a=t,i=e._zod.def;a.type="object",a.properties={};const s=i.shape;for(const d in s)a.properties[d]=cs(s[d],n,{...o,path:[...o.path,"properties",d]});const c=new Set(Object.keys(s)),l=new Set([...c].filter((e=>{const t=i.shape[e]._zod;return"input"===n.io?void 0===t.optin:void 0===t.optout})));l.size>0&&(a.required=Array.from(l)),"never"===(null==(r=i.catchall)?void 0:r._zod.def.type)?a.additionalProperties=!1:i.catchall?i.catchall&&(a.additionalProperties=cs(i.catchall,n,{...o,path:[...o.path,"additionalProperties"]})):"output"===n.io&&(a.additionalProperties=!1)})(e,n,t,o),bo(e,"shape",(()=>n.shape)),e.keyof=()=>vc(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:lc()}),e.loose=()=>e.clone({...e._zod.def,catchall:lc()}),e.strict=()=>{return e.clone({...e._zod.def,catchall:zi(dc,n)});var n},e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>function(e,n){if(!No(n))throw new Error("Invalid input to extend: expected a plain object");const t=e._zod.def.checks;if(t&&t.length>0){const t=e._zod.def.shape;for(const e in n)if(void 0!==Object.getOwnPropertyDescriptor(t,e))throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=yo(e._zod.def,{get shape(){const t={...e._zod.def.shape,...n};return xo(this,"shape",t),t}});return Ro(e,o)}(e,n),e.safeExtend=n=>function(e,n){if(!No(n))throw new Error("Invalid input to safeExtend: expected a plain object");const t=yo(e._zod.def,{get shape(){const t={...e._zod.def.shape,...n};return xo(this,"shape",t),t}});return Ro(e,t)}(e,n),e.merge=n=>function(e,n){const t=yo(e._zod.def,{get shape(){const t={...e._zod.def.shape,...n._zod.def.shape};return xo(this,"shape",t),t},get catchall(){return n._zod.def.catchall},checks:[]});return Ro(e,t)}(e,n),e.pick=n=>function(e,n){const t=e._zod.def,o=t.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return Ro(e,yo(e._zod.def,{get shape(){const e={};for(const o in n){if(!(o in t.shape))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(e[o]=t.shape[o])}return xo(this,"shape",e),e},checks:[]}))}(e,n),e.omit=n=>function(e,n){const t=e._zod.def,o=t.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const r=yo(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const e in n){if(!(e in t.shape))throw new Error(`Unrecognized key: "${e}"`);n[e]&&delete o[e]}return xo(this,"shape",o),o},checks:[]});return Ro(e,r)}(e,n),e.partial=(...n)=>function(e,n,t){const o=n._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const r=yo(n._zod.def,{get shape(){const o=n._zod.def.shape,r={...o};if(t)for(const n in t){if(!(n in o))throw new Error(`Unrecognized key: "${n}"`);t[n]&&(r[n]=e?new e({type:"optional",innerType:o[n]}):o[n])}else for(const n in o)r[n]=e?new e({type:"optional",innerType:o[n]}):o[n];return xo(this,"shape",r),r},checks:[]});return Ro(n,r)}(bc,e,n[0]),e.required=(...n)=>function(e,n,t){const o=yo(n._zod.def,{get shape(){const o=n._zod.def.shape,r={...o};if(t)for(const n in t){if(!(n in r))throw new Error(`Unrecognized key: "${n}"`);t[n]&&(r[n]=new e({type:"nonoptional",innerType:o[n]}))}else for(const n in o)r[n]=new e({type:"nonoptional",innerType:o[n]});return xo(this,"shape",r),r}});return Ro(n,o)}(Nc,e,n[0])}));function fc(e,n){const t={type:"object",shape:e??{},...Oo(n)};return new pc(t)}const hc=so("ZodUnion",((e,n)=>{Aa.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t,o)=>{const r=e._zod.def,a=!1===r.inclusive,i=r.options.map(((e,t)=>cs(e,n,{...o,path:[...o.path,a?"oneOf":"anyOf",t]})));a?t.oneOf=i:t.anyOf=i})(e,n,t,o),e.options=n.options}));const mc=so("ZodIntersection",((e,n)=>{Pa.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t,o)=>{const r=e._zod.def,a=cs(r.left,n,{...o,path:[...o.path,"allOf",0]}),i=cs(r.right,n,{...o,path:[...o.path,"allOf",1]}),s=e=>"allOf"in e&&1===Object.keys(e).length,c=[...s(a)?a.allOf:[a],...s(i)?i.allOf:[i]];t.allOf=c})(e,n,t,o)}));const gc=so("ZodEnum",((e,n)=>{$a.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t)=>{const o=fo(e._zod.def.entries);o.every((e=>"number"==typeof e))&&(t.type="number"),o.every((e=>"string"==typeof e))&&(t.type="string"),t.enum=o})(e,0,t),e.enum=n.entries,e.options=Object.values(n.entries);const t=new Set(Object.keys(n.entries));e.extract=(e,o)=>{const r={};for(const a of e){if(!t.has(a))throw new Error(`Key ${a} not found in enum`);r[a]=n.entries[a]}return new gc({...n,checks:[],...Oo(o),entries:r})},e.exclude=(e,o)=>{const r={...n.entries};for(const n of e){if(!t.has(n))throw new Error(`Key ${n} not found in enum`);delete r[n]}return new gc({...n,checks:[],...Oo(o),entries:r})}}));function vc(e,n){const t=Array.isArray(e)?Object.fromEntries(e.map((e=>[e,e]))):e;return new gc({type:"enum",entries:t,...Oo(n)})}const wc=so("ZodTransform",((e,n)=>{Da.init(e,n),js.init(e,n),e._zod.processJSONSchema=(e,n,t)=>((e,n)=>{if("throw"===n.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")})(0,e),e._zod.parse=(t,o)=>{if("backward"===o.direction)throw new lo(e.constructor.name);t.addIssue=o=>{if("string"==typeof o)t.issues.push(Do(o,t.value,n));else{const n=o;n.fatal&&(n.continue=!1),n.code??(n.code="custom"),n.input??(n.input=t.value),n.inst??(n.inst=e),t.issues.push(Do(n))}};const r=n.transform(t.value,t);return r instanceof Promise?r.then((e=>(t.value=e,t))):(t.value=r,t)}}));const bc=so("ZodOptional",((e,n)=>{La.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>hs(e,n,0,o),e.unwrap=()=>e._zod.def.innerType}));function xc(e){return new bc({type:"optional",innerType:e})}const yc=so("ZodExactOptional",((e,n)=>{Ba.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>hs(e,n,0,o),e.unwrap=()=>e._zod.def.innerType}));const _c=so("ZodNullable",((e,n)=>{Wa.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t,o)=>{const r=e._zod.def,a=cs(r.innerType,n,o),i=n.seen.get(e);"openapi-3.0"===n.target?(i.ref=r.innerType,t.nullable=!0):t.anyOf=[a,{type:"null"}]})(e,n,t,o),e.unwrap=()=>e._zod.def.innerType}));function kc(e){return new _c({type:"nullable",innerType:e})}const Ec=so("ZodDefault",((e,n)=>{qa.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t,o)=>{const r=e._zod.def;cs(r.innerType,n,o),n.seen.get(e).ref=r.innerType,t.default=JSON.parse(JSON.stringify(r.defaultValue))})(e,n,t,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}));const Tc=so("ZodPrefault",((e,n)=>{Va.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t,o)=>{const r=e._zod.def;cs(r.innerType,n,o),n.seen.get(e).ref=r.innerType,"input"===n.io&&(t._prefault=JSON.parse(JSON.stringify(r.defaultValue)))})(e,n,t,o),e.unwrap=()=>e._zod.def.innerType}));const Nc=so("ZodNonOptional",((e,n)=>{Ka.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t,o)=>{const r=e._zod.def;cs(r.innerType,n,o),n.seen.get(e).ref=r.innerType})(e,n,0,o),e.unwrap=()=>e._zod.def.innerType}));const Sc=so("ZodCatch",((e,n)=>{Ha.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t,o)=>{const r=e._zod.def;let a;cs(r.innerType,n,o),n.seen.get(e).ref=r.innerType;try{a=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}t.default=a})(e,n,t,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}));const Cc=so("ZodPipe",((e,n)=>{Ga.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t,o)=>{const r=e._zod.def,a="input"===n.io?"transform"===r.in._zod.def.type?r.out:r.in:r.out;cs(a,n,o),n.seen.get(e).ref=a})(e,n,0,o),e.in=n.in,e.out=n.out}));function Ic(e,n){return new Cc({type:"pipe",in:e,out:n})}const Rc=so("ZodReadonly",((e,n)=>{Xa.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t,o)=>{const r=e._zod.def;cs(r.innerType,n,o),n.seen.get(e).ref=r.innerType,t.readOnly=!0})(e,n,t,o),e.unwrap=()=>e._zod.def.innerType}));const Oc=so("ZodCustom",((e,n)=>{Qa.init(e,n),js.init(e,n),e._zod.processJSONSchema=(e,n,t)=>((e,n)=>{if("throw"===n.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")})(0,e)}));const jc=vc(["face","password"]),Ac=fc({success:ic(),accessToken:Fs().optional(),refreshToken:Fs().optional(),method:jc.optional(),alias:Fs().optional(),user:fc({id:Fs(),email:Fs(),role:Fs(),validated:ic(),active:ic()}).optional(),person:fc({id:Fs(),name:Fs(),birth_date:Fs()}).optional(),confidence_score:Oi(tc,Pc).optional(),recognition_id:Fs().optional(),task_id:Fs().optional(),status:Fs().optional(),message:Fs().optional()});var Pc;const Fc=fc({success:ic(),message:Fs(),person_id:Fs().optional(),user_id:Fs().optional(),person_validated:ic().optional(),face_processing:Pi(sc).optional(),onboarding_link:Fs().optional(),task_id:Fs().optional(),status:Fs().optional()}),zc="#0059C4",$c="#F1BE00",Dc="#0A1320",Mc={success:{fg:"#046C4E",bg:"#E7F7F0",solid:"#0E9F6E"},attention:{fg:"#6E5600",bg:"#FFF6D9",solid:"#F1BE00"},critical:{fg:"#9B1C1C",bg:"#FDEAEA",solid:"#E02424"},info:{fg:"#00449A",bg:"#EBF6FE",solid:"#0073F4"}},Lc={ground:"#F7F9FC",surface:"#FFFFFF",surfaceMuted:"#F1F5FA",line:"#E6ECF4",text:Dc,textMuted:"#48586B",textSubtle:"#617489",action:zc,actionText:"#FFFFFF",accent:$c,overlay:"rgba(10,19,32,.55)",focusRing:zc},Bc={ground:Dc,surface:"#111C2B",surfaceMuted:"#1E2B3C",line:"#22334D",text:"#EEF3F9",textMuted:"#AFBDCE",textSubtle:"#8496AD",action:"#0091F6",actionText:"#FFFFFF",accent:$c,overlay:"rgba(10,19,32,.72)",focusRing:"#00B0F8"};function Wc(e){const[n,t,o]=function(e){let n=e.trim().replace("#","");3===n.length&&(n=n.split("").map((e=>e+e)).join(""));return/^[0-9a-fA-F]{6}$/.test(n)?[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)]:[0,0,0]}(e).map((e=>{const n=e/255;return n<=.03928?n/12.92:((n+.055)/1.055)**2.4}));return.2126*n+.7152*t+.0722*o}const qc=[8,16,24];function Uc(e={}){const n=function(e){if("dark"===e)return"dark";if("light"===e)return"light";if("undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches)return"dark";return"light"}(e.theme),t="dark"===n?{...Bc}:{...Lc};let o=16;void 0!==e.radius&&qc.includes(e.radius)&&(o=e.radius);let r=t.action,a=!1;if(e.accent){(function(e,n){const t=Wc(e),o=Wc(n),[r,a]=t>o?[t,o]:[o,t];return(r+.05)/(a+.05)})(e.accent,"#FFFFFF")>=4.5?r=e.accent:(a=!0,r=zc)}return{mode:n,tokens:{...t,action:r},radius:o,accent:r,accentFellBack:a}}const Vc="--nfid-ground",Kc="--nfid-surface",Zc="--nfid-surface-muted",Hc="--nfid-line",Gc="--nfid-text",Jc="--nfid-text-muted",Xc="--nfid-text-subtle",Yc="--nfid-action",Qc="--nfid-action-text",el="--nfid-accent",nl="--nfid-overlay",tl="--nfid-focus-ring",ol="--nfid-radius",rl="neofaceid-focus-frame-tokens";function al(e={}){const n=Uc(e);if("undefined"==typeof document)return n;const t=function(e){const n=e.tokens;return`.neofaceid-root {\n ${Vc}: ${n.ground};\n ${Kc}: ${n.surface};\n ${Zc}: ${n.surfaceMuted};\n ${Hc}: ${n.line};\n ${Gc}: ${n.text};\n ${Jc}: ${n.textMuted};\n ${Xc}: ${n.textSubtle};\n ${Yc}: ${n.action};\n ${Qc}: ${n.actionText};\n ${el}: ${n.accent};\n ${nl}: ${n.overlay};\n ${tl}: ${n.focusRing};\n ${ol}: ${e.radius}px;\n color: var(${Gc});\n font-family: inherit;\n}\n.neofaceid-root :focus-visible {\n outline: 2px solid var(${tl});\n outline-offset: 2px;\n}\n@media (prefers-reduced-motion: reduce) {\n .neofaceid-root,\n .neofaceid-root * {\n animation-duration: 0.001ms !important;\n animation-iteration-count: 1 !important;\n transition-duration: 0.001ms !important;\n scroll-behavior: auto !important;\n }\n}`}(n),o=document.getElementById(rl);if(o)return o.textContent!==t&&(o.textContent=t),n;const r=document.createElement("style");return r.id=rl,r.textContent=t,document.head.appendChild(r),n}function il(e,n){if("undefined"==typeof document)return;const t=document.getElementById(e);if(t)return void(t.textContent!==n&&(t.textContent=n));const o=document.createElement("style");o.id=e,o.textContent=n,document.head.appendChild(o)}const sl={},cl={purpose:"authentication",legalBasis:"fraud_prevention",privacyPolicyUrl:"",retentionDays:0},ll={development:"http://localhost:8000",sandbox:"https://sandbox-core.neofaceid.com",production:"https://core.neofaceid.com.br"},dl={toPhone:!1,toPassword:!0},ul=[8,16,24];let pl={baseUrl:ll.sandbox,applicationToken:null,environment:"sandbox",initialized:!1,appName:null,accent:null,radius:16,theme:"light",locale:"pt-BR",resolvedTheme:null,consent:{...cl},autoFallback:{...dl}},fl=!1;function hl(){return pl.initialized,pl.baseUrl}function ml(){return pl.applicationToken}function gl(){return pl.appName}function vl(){return{...pl.autoFallback}}function wl(){return pl.locale}function bl(){return{...pl.consent}}async function xl(e,n){const t=URL.createObjectURL(e);try{return await n(t)}finally{URL.revokeObjectURL(t)}}const yl=()=>hl(),_l=()=>{const e="localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname||""===window.location.hostname;if(!window.isSecureContext&&!e)throw new io("Secure context (HTTPS) is required for this operation",ao.NETWORK)},kl=()=>{const e=new AbortController,n=setTimeout((()=>e.abort()),1e4);return e.signal.addEventListener("abort",(()=>clearTimeout(n))),e},El=async e=>xl(e,(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 r=e.getContext("2d");r?(r.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=e})))),Tl=async e=>xl(e,(e=>new Promise(((n,t)=>{const o=new Image;o.onload=()=>{const e=1280;let{width:r}=o,{height:a}=o;r>a&&r>e?(a=a*e/r,r=e):a>e&&(r=r*e/a,a=e);const i=document.createElement("canvas");i.width=r,i.height=a;const s=i.getContext("2d");s?(s.drawImage(o,0,0,r,a),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=e})))),Nl=async e=>{_l();const n=kl();try{const t=await fetch(`${yl()}/api/v1/auth/application/validate_token/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":e},body:JSON.stringify({}),signal:n.signal});if(!t.ok)throw new io(`API Error ${t.status}`,ao.INVALID_TOKEN);return t.ok}catch(t){if(t instanceof Error){if("AbortError"===t.name)throw new io("Request timeout",ao.NETWORK);if(t instanceof io)throw t;throw new io(t.message,ao.NETWORK)}throw new io("Unknown error",ao.NETWORK)}},Sl=async(e,n)=>{_l();const t=kl();try{const o=await fetch(`${yl()}/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 io("Token de aplicação inválido ou expirado",ao.INVALID_TOKEN);if(404===o.status)throw new io("Link de onboarding não encontrado",ao.NOT_FOUND);throw new io(`Falha ao obter detalhes (${o.status})`,ao.NETWORK)}return await o.json()}catch(o){if(o instanceof Error){if("AbortError"===o.name)throw new io("Tempo de requisição excedido",ao.NETWORK);if(o instanceof io)throw o;throw new io(o.message,ao.NETWORK)}throw new io("Erro desconhecido",ao.NETWORK)}},Cl=async(e,n)=>{_l();const t=kl();try{const o=await fetch(`${yl()}/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 io("Token de aplicação inválido ou expirado",ao.INVALID_TOKEN);if(404===o.status)return!1;throw new io(`Falha ao validar token (${o.status})`,ao.NETWORK)}const r=await o.json();return!0===(null==r?void 0:r.is_valid)}catch(o){if(o instanceof Error){if("AbortError"===o.name)throw new io("Tempo de requisição excedido",ao.NETWORK);if(o instanceof io)throw o;throw new io(o.message,ao.NETWORK)}throw new io("Erro desconhecido",ao.NETWORK)}},Il=async(e,n,t,o)=>{_l();const r=kl(),a=await El(t),i=await El(o);try{const t=await new Promise(((e,n)=>{const t=new FileReader;t.onload=()=>e(t.result),t.onerror=n,t.readAsDataURL(a)})),o=await new Promise(((e,n)=>{const t=new FileReader;t.onload=()=>e(t.result),t.onerror=n,t.readAsDataURL(i)})),s=await fetch(`${yl()}/api/v1/onboardings/${encodeURIComponent(n)}/complete/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":e},body:JSON.stringify({face_image:t,document_image:o}),signal:r.signal}),c=await s.json();if(!s.ok){if(401===s.status||403===s.status)throw new io("Token de aplicação inválido ou expirado",ao.INVALID_TOKEN);if(404===s.status)throw new io("Link de onboarding não encontrado",ao.NOT_FOUND);throw new io((null==c?void 0:c.error)||(null==c?void 0:c.message)||"Falha ao concluir onboarding",ao.NETWORK)}return{success:!!c.success,message:c.message||"Onboarding concluído",person_id:c.person_id,identity_data_id:c.identity_data_id,confidence_score:c.confidence_score,processing_time:c.processing_time}}catch(s){if(s instanceof Error){if("AbortError"===s.name)throw new io("Tempo de requisição excedido",ao.NETWORK);if(s instanceof io)throw s;throw new io(s.message,ao.NETWORK)}throw new io("Erro desconhecido",ao.NETWORK)}},Rl=async(e,n,t,o,r)=>{if(_l(),!o||0===o.length)throw new io("Pelo menos uma imagem da pessoa é obrigatória",ao.VALIDATION_ERROR);const a=kl();try{const i=await Promise.all(o.map((async e=>{const n=await El(e);return new Promise(((e,t)=>{const o=new FileReader;o.onload=()=>e(o.result),o.onerror=t,o.readAsDataURL(n)}))}))),s=await El(r),c={person_images:i,document_image:await new Promise(((e,n)=>{const t=new FileReader;t.onload=()=>e(t.result),t.onerror=n,t.readAsDataURL(s)})),name:t.name,birth_date:t.birth_date,cpf:t.cpf,cnpj:t.cnpj,email:t.email},l=await fetch(`${yl()}/api/v1/onboardings/${encodeURIComponent(n)}/complete/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":e},body:JSON.stringify(c),signal:a.signal}),d=await l.json();if(!l.ok){if(401===l.status||403===l.status)throw new io("Token de aplicação inválido ou expirado",ao.INVALID_TOKEN);if(404===l.status)throw new io("Link de onboarding não encontrado",ao.NOT_FOUND);throw new io((null==d?void 0:d.error)||(null==d?void 0:d.message)||"Falha ao concluir onboarding",ao.NETWORK)}return{success:!!d.success,message:d.message||"Onboarding concluído com sucesso",person_id:d.person_id,identity_data_id:d.identity_data_id,confidence_score:d.confidence_score,processing_time:d.processing_time,liveness_passed:d.liveness_passed,document_verified:d.document_verified,person_created:d.person_created}}catch(i){if(i instanceof Error){if("AbortError"===i.name)throw new io("Tempo de requisição excedido",ao.NETWORK);if(i instanceof io)throw i;throw new io(i.message,ao.NETWORK)}throw new io("Erro desconhecido",ao.NETWORK)}},Ol=async(e,n)=>{_l();const t=kl(),o=await El(e);try{const e=await new Promise(((e,n)=>{const t=new FileReader;t.onload=()=>{const n=t.result;e(n.split(",")[1])},t.onerror=n,t.readAsDataURL(o)})),r=await fetch(`${yl()}/api/v1/auth/recognition/face/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({face_frames:e}),signal:t.signal});if(!r.ok){if(401===r.status||403===r.status)throw new io("Invalid or expired application token",ao.INVALID_TOKEN);throw new io(`Server returned status ${r.status}`,ao.NETWORK)}const a=await r.json();if(!a.success)throw new io(a.message||"Recognition failed",ao.RECOGNITION_FAILED);return{accessToken:a.accessToken,payload:a.payload}}catch(r){if(r instanceof Error){if("AbortError"===r.name)throw new io("Request timed out",ao.NETWORK);if(r instanceof io)throw r;throw new io(r.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},jl=async(e,n)=>{var t,o,r,a,i;_l();const s=kl(),c=await El(e);try{const e=await c.arrayBuffer(),l=btoa(new Uint8Array(e).reduce(((e,n)=>e+String.fromCharCode(n)),"")),d=await fetch(`${yl()}/api/v1/login/donor/face/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({image:l,biometric_type:"FACE"}),signal:s.signal});if(!d.ok){if(401===d.status||403===d.status)throw new io("Invalid application token",ao.INVALID_TOKEN);if(d.status>=500)throw new io(`Server Error ${d.status}`,ao.API_ERROR);throw new io(`API Error ${d.status}`,ao.API_ERROR)}const u=await d.json();if(!u.success)throw new io(u.message||"Login failed",ao.LOGIN_FAILED);return{success:!0,accessToken:u.accessToken||u.access_token||"",refreshToken:u.refreshToken||u.refresh_token||void 0,method:"face",alias:u.alias,user:{id:(null==(t=u.user)?void 0:t.id)||"",email:(null==(o=u.user)?void 0:o.email)||"",role:(null==(r=u.user)?void 0:r.role)||"",validated:(null==(a=u.user)?void 0:a.validated)||!1,active:(null==(i=u.user)?void 0:i.active)||!1},person:u.person?{id:u.person.id||"",name:u.person.name||"",birth_date:u.person.birth_date||""}:void 0,confidence_score:u.confidence_score,recognition_id:u.recognition_id}}catch(l){if(l instanceof Error){if("AbortError"===l.name)throw new io("Request timed out",ao.NETWORK);if(l instanceof io)throw l;throw new io(l.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},Al=async(e,n,t=!0,o=.8)=>{_l();const r=kl(),a=await El(e);try{const e=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)})),i=await fetch(`${yl()}/api/v1/auth/recognition/face/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({face_frames:e,liveness_check:t,confidence_threshold:o}),signal:r.signal});if(!i.ok){if(401===i.status||403===i.status)throw new io("Invalid or expired application token",ao.INVALID_TOKEN);throw new io(`Server returned status ${i.status}`,ao.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 io("Request timed out",ao.NETWORK);if(i instanceof io)throw i;throw new io(i.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},Pl=async(e,n,t,o="LOGIN")=>{_l();const r=kl();try{const a=await fetch(`${yl()}/api/v1/auth/recognition/face/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":t},body:JSON.stringify({document_type:e,document_number:n,purpose:o}),signal:r.signal});if(!a.ok){if(401===a.status||403===a.status)throw new io("Invalid or expired application token",ao.INVALID_TOKEN);throw new io(`Server returned status ${a.status}`,ao.NETWORK)}const i=await a.json();if(!i.success)throw new io(i.message||"Identification failed",ao.RECOGNITION_FAILED);return{success:i.success,personId:i.person_id,accessToken:i.access_token,payload:i.payload}}catch(a){if(a instanceof Error){if("AbortError"===a.name)throw new io("Request timed out",ao.NETWORK);if(a instanceof io)throw a;throw new io(a.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},Fl=async(e,n,t,o=.8,r,a)=>{var i;_l();const s=kl(),c=await El(e),l=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:l,type_of_identification:"FACE",purpose:t,confidence_threshold:o};r&&(e.signature=r);const c=await fetch(`${yl()}/api/v1/auth/recognition/face/`,{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 io("Invalid or expired application token",ao.INVALID_TOKEN);throw new io(`Server returned status ${c.status}`,ao.NETWORK)}const d=await c.json();return{success:d.success,personName:d.person_name||(null==(i=d.person)?void 0:i.name),email:d.email||(null==a?void 0:a.email),cpf:d.cpf||(null==a?void 0:a.cpf),confidenceScore:d.confidence_score,accessToken:d.access_token,payload:d.payload,signature:r,sessionId:null==a?void 0:a.sessionId}}catch(d){if(d instanceof Error){if("AbortError"===d.name)throw new io("Request timed out",ao.NETWORK);if(d instanceof io)throw d;throw new io(d.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},zl=async(e,n,t)=>{_l();const o=kl();try{let r,a;if(null==t?void 0:t.documentFront){const e=await Tl(t.documentFront);r=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 Tl(t.documentBack);a=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,is_pep:e.is_pep??!1};r&&(i.document_images=[{front:r,back:a||void 0,type:(null==t?void 0:t.documentType)||"RG"}]);const s=await fetch(`${yl()}/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 io("Invalid or expired application token",ao.INVALID_TOKEN);throw new io(`Server returned status ${s.status}`,ao.NETWORK)}return await s.json()}catch(r){if(r instanceof Error){if("AbortError"===r.name)throw new io("Request timed out",ao.NETWORK);if(r instanceof io)throw r;throw new io(r.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},$l=async e=>{const n=kl(),t=new URLSearchParams;e.email&&t.append("email",e.email),e.cpf&&t.append("cpf",e.cpf);try{const e=await fetch(`${yl()}/api/v1/verify/user/?${t.toString()}`,{method:"GET",headers:{"Content-Type":"application/json"},signal:n.signal});if(!e.ok){const n=await e.json().catch((()=>({})));throw new io(n.message||`Server returned status ${e.status}`,ao.NETWORK)}return await e.json()}catch(o){if(o instanceof Error){if("AbortError"===o.name)throw new io("Request timed out",ao.NETWORK);if(o instanceof io)throw o;throw new io(o.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},Dl=async(e,n,t,o)=>{var r,a,i,s,c,l,d,u;if(_l(),!n||0===n.length)throw new io("At least one face photo is required for biometric registration",ao.VALIDATION_ERROR);if(n.length>5)throw new io("Maximum of 5 face photos allowed",ao.VALIDATION_ERROR);const p=kl();try{const h=await Promise.all(n.map((async e=>{const n=await El(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 Tl(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 Tl(o.documentBack);g=await new Promise(((n,t)=>{const o=new FileReader;o.onload=()=>n(o.result),o.onerror=t,o.readAsDataURL(e)}))}const v={name:e.name,birth_date:e.birth_date,cpf:e.cpf,email:e.email,password:e.password,password_confirm:e.password,face_photos:h,is_pep:e.is_pep??!1};m&&(v.document_images=[{front:m,back:g||void 0,type:(null==o?void 0:o.documentType)||"RG"}]);const w=await fetch(`${yl()}/api/v1/signup/donor/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":t},body:JSON.stringify(v),signal:p.signal});if(!w.ok){if(401===w.status||403===w.status)throw new io("Invalid or expired application token",ao.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 io(`Erro de validação: ${n}`,ao.VALIDATION_ERROR)}if("fraud_detected"===e.error)throw new io("Fraud detected in biometric images. Registration blocked.",ao.VALIDATION_ERROR);if("user_exists"===e.error||"ALREADY_EXISTS"===e.error_code)throw new io("User with this email already exists",ao.VALIDATION_ERROR);if("person_exists"===e.error)throw new io("Person with this CPF already exists",ao.VALIDATION_ERROR);const n=e.message||e.error||`Server returned status ${w.status}`;throw new io(n,ao.VALIDATION_ERROR)}catch(f){if(f instanceof io)throw f;throw new io(`Server returned status ${w.status}`,ao.NETWORK)}}const b=await w.json();return 202===w.status&&(null==(r=b.data)?void 0:r.task_id)?{success:b.success,message:b.message||"Registration is being processed. You will receive an email when completed.",task_id:b.data.task_id,status:b.data.status||"processing",person_id:void 0,user_id:void 0,person_validated:void 0,face_processing:void 0,onboarding_link:void 0}:{success:b.success,message:b.message,person_id:(null==(a=b.data)?void 0:a.person_id)||b.person_id,user_id:(null==(i=b.data)?void 0:i.user_id)||b.user_id,person_validated:(null==(s=b.data)?void 0:s.person_validated)||b.person_validated,face_processing:(null==(c=b.data)?void 0:c.face_processing)||b.face_processing,onboarding_link:(null==(l=b.data)?void 0:l.onboarding_link)||b.onboarding_link,task_id:null==(d=b.data)?void 0:d.task_id,status:null==(u=b.data)?void 0:u.status}}catch(h){if(h instanceof Error){if("AbortError"===h.name)throw new io("Request timed out",ao.NETWORK);if(h instanceof io)throw h;throw new io(h.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},Ml=async(e,n,t)=>{const o=kl();try{const r=await fetch(`${yl()}/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(!r.ok){if(401===r.status||403===r.status)throw new io("Email ou senha inválidos",ao.INVALID_TOKEN);throw new io(`API Error ${r.status}`,ao.API_ERROR)}const a=await r.json();return{success:!0,accessToken:a.access_token||a.access,refreshToken:a.refresh_token||a.refresh||void 0,method:"password",alias:a.user&&a.user.alias||a.alias,user:{id:a.user&&a.user.id||"",email:a.user&&a.user.email||"",role:a.user&&a.user.role||"",validated:a.user&&a.user.validated||!1,active:a.user&&a.user.active||!1}}}catch(r){if(r instanceof Error){if("AbortError"===r.name)throw new io("Request timed out",ao.NETWORK);if(r instanceof io)throw r;throw new io(r.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},Ll=async(e,n)=>{if(!e)throw new io("Inscrição de aparelho exige um usuário autenticado (access token ausente).",ao.INVALID_TOKEN);const t=kl();try{const o=await fetch(`${yl()}/api/v1/devices/enrollment-token/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n,Authorization:`Bearer ${e}`},signal:t.signal});if(!o.ok){if(401===o.status)throw new io("Sua sessão expirou. Entre novamente para inscrever o aparelho.",ao.INVALID_TOKEN);if(403===o.status)throw new io("Esta conta não pode inscrever aparelhos. Procure o suporte.",ao.INVALID_TOKEN);throw new io(`API Error ${o.status}`,ao.API_ERROR)}const r=await o.json(),a=r.data??r,i=a.token,s=a.handle;if(!i||!s)throw new io("Resposta de inscrição incompleta (token ou handle ausente)",ao.API_ERROR);return{handle:s,jti:a.jti??"",token:i,expiresIn:a.expires_in??300,purpose:a.purpose??"device-enrollment"}}catch(o){if(o instanceof io)throw o;if(o instanceof Error){if("AbortError"===o.name)throw new io("Request timed out",ao.NETWORK);throw new io(o.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},Bl=async(e,n)=>{const t=kl();try{const o=await fetch(`${yl()}/api/v1/token/refresh/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({refresh:e}),signal:t.signal});if(!o.ok){if(401===o.status||403===o.status)throw new io("Sessão expirada — faça login novamente",ao.INVALID_TOKEN);throw new io(`API Error ${o.status}`,ao.API_ERROR)}const r=await o.json(),a=r.access??r.access_token;if(!a)throw new io("Resposta de refresh sem access token",ao.API_ERROR);return{accessToken:a,refreshToken:r.refresh??r.refresh_token??e}}catch(o){if(o instanceof io)throw o;if(o instanceof Error){if("AbortError"===o.name)throw new io("Request timed out",ao.NETWORK);throw new io(o.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},Wl=async(e,n)=>{var t,o,r,a;_l();const i=kl(),s=await Tl(e),c=await new Promise(((e,n)=>{const t=new FileReader;t.onload=()=>{const n=t.result;e(n.split(",")[1])},t.onerror=n,t.readAsDataURL(s)}));try{const e=await fetch(`${yl()}/api/v1/auth/recognition/face/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({image:c,purpose:"SIMPLE_IDENTIFICATION_F"}),signal:i.signal});if(!e.ok){if(401===e.status||403===e.status)throw new io("Invalid or expired application token",ao.INVALID_TOKEN);throw new io(`Server returned status ${e.status}`,ao.NETWORK)}const s=await e.json();if(202===e.status||s.data&&s.data.task_id)return{success:!0,taskId:(null==(t=s.data)?void 0:t.task_id)||s.task_id,status:(null==(o=s.data)?void 0:o.status)||"processing",message:s.message||"Identification scheduled"};if(!s.success)throw new io(s.message||"Person identification failed",ao.RECOGNITION_FAILED);return{success:!0,person:{name:(null==(r=s.person)?void 0:r.name)||"",birth_date:(null==(a=s.person)?void 0:a.birth_date)||""}}}catch(l){if(l instanceof Error){if("AbortError"===l.name)throw new io("Request timed out",ao.NETWORK);if(l instanceof io)throw l;throw new io(l.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},ql=async(e,n,t)=>{if(_l(),!e)throw new io("Person ID is required",ao.VALIDATION_ERROR);if(!n)throw new io("Face image is required",ao.VALIDATION_ERROR);const o=kl(),r=await El(n),a=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 n=await fetch(`${yl()}/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:a}),signal:o.signal});if(!n.ok){if(401===n.status||403===n.status)throw new io("Invalid or expired application token, or insufficient permissions",ao.INVALID_TOKEN);if(400===n.status)try{const e=await n.json(),t=e.message||e.error||"Invalid biometric data";throw new io(t,ao.VALIDATION_ERROR)}catch(i){if(i instanceof io)throw i;throw new io("Invalid biometric data",ao.VALIDATION_ERROR)}throw new io(`Server returned status ${n.status}`,ao.NETWORK)}const r=await n.json();return{success:!0,message:"Biometric data registered successfully",identity_data_id:r.id,type_of_identification:r.type_of_identification,have_biometric_data:r.have_biometric_data,created_at:r.created_at}}catch(s){if(s instanceof Error){if("AbortError"===s.name)throw new io("Request timed out",ao.NETWORK);if(s instanceof io)throw s;throw new io(s.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},Ul=async(e,n,t)=>{_l();const o=kl();try{const a=await fetch(`${yl()}/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(!a.ok){if(401===a.status)throw new io("Invalid or expired JWT token",ao.INVALID_TOKEN);if(403===a.status)throw new io("Insufficient permissions to create application",ao.INVALID_TOKEN);if(400===a.status)try{const e=await a.json(),n=e.message||e.error||"Invalid application data";throw new io(n,ao.VALIDATION_ERROR)}catch(r){if(r instanceof io)throw r;throw new io("Invalid application data",ao.VALIDATION_ERROR)}throw new io(`Server returned status ${a.status}`,ao.NETWORK)}const i=await a.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(a){if(a instanceof Error){if("AbortError"===a.name)throw new io("Request timed out",ao.NETWORK);if(a instanceof io)throw a;throw new io(a.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},Vl=async(e={})=>{_l();const{durationMs:n=3e3,onProgress:t}=e;return new Promise((async(e,o)=>{let r=null;const a=[];try{r=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:{ideal:640},height:{ideal:480}},audio:!1});const i=(()=>{const e=["video/mp4;codecs=avc1","video/mp4","video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"];for(const n of e)if(MediaRecorder.isTypeSupported(n))return n;return""})();let s;try{s=i?new MediaRecorder(r,{mimeType:i,videoBitsPerSecond:1e6}):new MediaRecorder(r,{videoBitsPerSecond:1e6})}catch{s=new MediaRecorder(r)}const c=s.mimeType||i;if(s.ondataavailable=e=>{e.data.size>0&&a.push(e.data)},s.onstop=()=>{r&&r.getTracks().forEach((e=>e.stop()));const n=new Blob(a,{type:c});e(n)},s.onerror=e=>{r&&r.getTracks().forEach((e=>e.stop())),o(new io(`Recording error: ${e}`,ao.CAPTURE_ERROR))},s.start(100),t){const e=100;let o=0;const r=setInterval((()=>{o+=e;const a=Math.min(100,o/n*100);t(a),o>=n&&clearInterval(r)}),e)}setTimeout((()=>{s&&"recording"===s.state&&s.stop()}),n)}catch(i){r&&r.getTracks().forEach((e=>e.stop())),i instanceof Error?"NotAllowedError"===i.name?o(new io("Camera permission denied",ao.CAMERA_ERROR)):"NotFoundError"===i.name?o(new io("No camera found",ao.NO_CAMERA)):o(new io(i.message,ao.CAPTURE_ERROR)):o(new io("Failed to record video",ao.CAPTURE_ERROR))}}))},Kl=async(e,n,t={})=>{var o,r,a,i,s,c,l,d,u,p;const{maxAttempts:f=60,intervalMs:h=1e3,onStatusChange:m}=t,g=(e=h)=>new Promise((n=>{setTimeout(n,e)})),v=e=>{var n,t;const o=null==(t=null==(n=e.headers)?void 0:n.get)?void 0:t.call(n,"Retry-After");if(!o)return h;const r=Number(o);if(Number.isFinite(r)&&r>0)return 1e3*r;const a=Date.parse(o);if(Number.isFinite(a)){const e=a-Date.now();if(e>0)return e}return h};let w=0,b="";for(;w<f;){w++;try{const t=await fetch(`${yl()}/api/v1/tasks/status/?task_id=${e}`,{method:"GET",headers:{Accept:"application/json","X-App-Token":n}});if(404===t.status)throw new io("Não foi possível recuperar o andamento deste processo. Ele pode já ter sido concluído há algum tempo, ou nunca ter existido.",ao.NOT_FOUND);if(t.status>=500){b=`HTTP ${t.status}`,await g();continue}if(429===t.status){b="HTTP 429",await g(v(t));continue}if(401===t.status||403===t.status)throw new io("Invalid application token",ao.INVALID_TOKEN);if(!t.ok)throw new io(`Task status check failed: ${t.status}`,ao.API_ERROR);const f=await t.json(),h=(null==(o=f.data)?void 0:o.status)||"unknown";if(m){m(h,null==(a=null==(r=f.data)?void 0:r.progress)?void 0:a.percentage)}if("success"===h)return f.data.result;if("failure"===h){const e=(null==(s=null==(i=f.data)?void 0:i.result)?void 0:s.message)||(null==(c=f.data)?void 0:c.error)||"Task failed";throw new io(e,ao.RECOGNITION_FAILED)}if("revoked"===h)throw new io("Task was cancelled",ao.RECOGNITION_FAILED);if(!1===f.success){const e=(null==(d=null==(l=f.data)?void 0:l.result)?void 0:d.message)||(null==(u=f.data)?void 0:u.error)||(null==(p=f.data)?void 0:p.message)||f.message||"Task failed";throw new io(e,ao.RECOGNITION_FAILED)}await g()}catch(x){if(x instanceof io)throw x;b=x instanceof Error?x.message:"erro desconhecido",await g()}}throw new io(b?`Task status polling timed out (última falha transitória: ${b})`:"Task status polling timed out",ao.NETWORK)},Zl=async(e,n)=>{var t;_l();const o=kl();try{const r=await fetch(`${yl()}/api/v1/auth/recognition/face/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({video:e,purpose:"PROOF_OF_LIFE"}),signal:o.signal});if(!r.ok){if(401===r.status||403===r.status)throw new io("Invalid or expired application token",ao.INVALID_TOKEN);if(400===r.status){const e=await r.json();throw new io(e.message||"Invalid request data",ao.VALIDATION_ERROR)}throw new io(`Server returned status ${r.status}`,ao.NETWORK)}const a=await r.json();if(!a.success||!(null==(t=a.data)?void 0:t.task_id))throw new io(a.message||"Failed to start proof of life",ao.RECOGNITION_FAILED);return{taskId:a.data.task_id,historyId:a.data.history_id,status:a.data.status,message:a.message||"Recognition started successfully"}}catch(r){if(r instanceof Error){if("AbortError"===r.name)throw new io("Request timed out",ao.NETWORK);if(r instanceof io)throw r;throw new io(r.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},Hl=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 io("Failed to convert video to base64",ao.CAPTURE_ERROR)),o.readAsDataURL(e)})),Gl=async(e,n,t)=>{var o,r;if(_l(),!e)throw new io("personId is required",ao.VALIDATION_ERROR);if(!n)throw new io("jwtToken is required",ao.VALIDATION_ERROR);if(!t||0===t.length)throw new io("At least one document image is required",ao.VALIDATION_ERROR);const a=await Promise.all(t.map((async e=>{const n=await Tl(e);return t=n,new Promise(((e,n)=>{const o=new FileReader;o.onload=()=>{const n=o.result;e(n.includes(",")?n.split(",")[1]:n)},o.onerror=()=>n(new io("Failed to convert image to base64",ao.CAPTURE_ERROR)),o.readAsDataURL(t)}));var t}))),i=kl();try{const t=await fetch(`${yl()}/api/v1/donors/${e}/documents/`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({document_images:a}),signal:i.signal}),s=await t.json();if(!t.ok)throw new io((null==s?void 0:s.message)||`API Error ${t.status}`,ao.NETWORK);return{success:!0,taskId:(null==(o=s.data)?void 0:o.task_id)??"",status:(null==(r=s.data)?void 0:r.status)??"processing",message:s.message??"Documents submitted for processing"}}catch(s){if(s instanceof io)throw s;if(s instanceof Error){if("AbortError"===s.name)throw new io("Request timeout",ao.NETWORK);throw new io(s.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},Jl=async(e,n)=>{const t=kl();try{const o=await fetch(`${yl()}/api/v1/tasks/status/?task_id=${e}`,{method:"GET",headers:{"Content-Type":"application/json",...n?{"X-App-Token":n}:{}},signal:t.signal}),r=await o.json();if(!o.ok)throw new io((null==r?void 0:r.message)||`API Error ${o.status}`,ao.NETWORK);return{success:r.success,status:r.data.status,result:r.data.result,error:r.data.error}}catch(o){if(o instanceof io)throw o;throw new io("Failed to fetch task status",ao.NETWORK)}},Xl=async(e,n,t={})=>{var o,r;const{maxRetries:a=30,interval:i=2e3}=t,s=await Wl(e,n);if(s.person)return{personFound:!0,person:s.person};const{taskId:c}=s;if(!c)return{personFound:!1};for(let l=0;l<a;l++){const e=await Jl(c);if("success"===e.status)return e.result&&e.result.success?{personFound:!0,person:{name:(null==(o=e.result.person)?void 0:o.name)||"Pessoa identificada",birth_date:(null==(r=e.result.person)?void 0:r.birth_date)||""}}:{personFound:!1};if("failure"===e.status)return{personFound:!1};await new Promise((e=>setTimeout(e,i)))}throw new io("Timed out waiting for identification",ao.NETWORK)};async function Yl(e,n){const t=hl(),o=await fetch(`${t}/api/v1/user/password/reset/request/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({email:e})});if(!o.ok){const e=await o.json();throw new io(e.message||"Erro ao solicitar recuperação de senha",ao.API_ERROR)}return o.json()}async function Ql(e,n){const t=hl(),o=await fetch(`${t}/api/v1/user/password/reset/confirm/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:e,new_password:n})});if(!o.ok){const e=await o.json();throw new io(e.error||e.message||"Erro ao redefinir senha",ao.API_ERROR)}return o.json()}const ed=Object.freeze(Object.defineProperty({__proto__:null,BiometricLoginResultSchema:Ac,RegistrationResultSchema:Fc,checkUserExistence:$l,completeOnboarding:Il,completeOnboardingWithData:Rl,confirmPasswordReset:Ql,getOnboardingDetails:Sl,getTaskStatus:Jl,identifyPerson:Wl,identifyPersonAsync:Xl,loginWithBiometric:jl,loginWithBiometricSSE:async(e,n)=>{var t,o;_l();const r=await El(e),a=await r.arrayBuffer(),i=btoa(new Uint8Array(a).reduce(((e,n)=>e+String.fromCharCode(n)),"")),s=kl();let c;try{c=await fetch(`${yl()}/api/v1/auth/recognition/face/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({image:i,purpose:"LOGIN"}),signal:s.signal})}catch(m){if(m instanceof Error){if("AbortError"===m.name)throw new io("Request timed out",ao.NETWORK);if(m instanceof io)throw m;throw new io(m.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}if(!c.ok){if(401===c.status||403===c.status)throw new io("Invalid application token",ao.INVALID_TOKEN);throw new io(`API Error ${c.status}`,ao.API_ERROR)}const l=await c.json();if(!l.success||!(null==(t=l.data)?void 0:t.task_id))throw new io(l.message||"Failed to start login",ao.LOGIN_FAILED);const d=l.data.task_id,u=`${yl()}/api/v1/auth/recognition/face/login/events/${d}/ticket/`,p=await fetch(u,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n}});if(!p.ok)throw new io(`SSE ticket request failed: ${p.status}`,ao.NETWORK);const f=await p.json(),h=(null==(o=null==f?void 0:f.data)?void 0:o.ticket)??(null==f?void 0:f.ticket);if(!h)throw new io("SSE ticket ausente na resposta",ao.API_ERROR);return new Promise(((e,n)=>{const t=`${yl()}/api/v1/auth/recognition/face/login/events/${d}/?ticket=${encodeURIComponent(h)}`,o=new EventSource(t),r=setTimeout((()=>{o.close(),n(new io("Login timeout",ao.NETWORK))}),31e4),a=()=>{clearTimeout(r),o.close()};o.addEventListener("success",(t=>{var o,r,i,s,c,l;a();try{const n=JSON.parse(t.data);e({success:!0,accessToken:n.token||n.access_token||"",alias:(null==(o=n.user)?void 0:o.alias)||n.alias||"",user:{id:(null==(r=n.user)?void 0:r.id)||"",email:(null==(i=n.user)?void 0:i.email)||"",role:(null==(s=n.user)?void 0:s.role)||"",validated:(null==(c=n.user)?void 0:c.validated)??!1,active:(null==(l=n.user)?void 0:l.active)??!1},person:n.person?{id:n.person.id||"",name:n.person.name||"",birth_date:n.person.birth_date||""}:void 0,confidence_score:n.confidence_score,recognition_id:n.recognition_id??n.history_id})}catch{n(new io("Erro ao processar resposta de login",ao.API_ERROR))}})),o.addEventListener("failed",(e=>{a();try{const t=JSON.parse(e.data);n(new io(t.message||"Login failed",ao.LOGIN_FAILED))}catch{n(new io("Login failed",ao.LOGIN_FAILED))}})),o.addEventListener("error",(e=>{a();try{const t=JSON.parse(e.data||"{}");n(new io(t.message||"Processing error",ao.API_ERROR))}catch{n(new io("Processing error",ao.API_ERROR))}})),o.addEventListener("timeout",(()=>{a(),n(new io("Login timeout",ao.NETWORK))})),o.onerror=()=>{a(),n(new io("SSE connection error",ao.NETWORK))}}))},loginWithEmail:Ml,pollTaskStatus:Kl,recognize:Ol,recognizeBiometric:Al,recognizeByPurpose:Fl,recordFaceVideo:Vl,refreshSession:Bl,registerApplication:Ul,registerBiometric:ql,registerDocumentByImage:Gl,registerPersonWithBiometric:Dl,registerPersonWithoutFace:zl,requestDeviceEnrollmentToken:Ll,requestPasswordReset:Yl,simpleIdentification:Pl,startProofOfLife:Zl,validateOnboardingToken:Cl,validateToken:Nl,videoToBase64:Hl},Symbol.toStringTag,{value:"Module"}));function nd(e,n={}){if(!e||0===e.videoWidth||0===e.videoHeight)return 0;const t=n.sample??64,o=e.videoWidth,r=e.videoHeight,a=n.roi??function(e,n,t){const o=Math.round(e*t),r=Math.round(n*t);return{x:Math.round((e-o)/2),y:Math.round((n-r)/2),width:o,height:r}}(o,r,.4),i=n.scratch??document.createElement("canvas");i.width=t,i.height=t;const s=i.getContext("2d",{willReadFrequently:!0});if(!s)return 0;try{s.drawImage(e,a.x,a.y,a.width,a.height,0,0,t,t);return function(e){const n=e.length;if(0===n)return 0;let t=0,o=0;for(let r=0;r<n;r+=4){t+=.2126*e[r]+.7152*e[r+1]+.0722*e[r+2],o+=1}return 0===o?0:t/(255*o)}(s.getImageData(0,0,t,t).data)}catch{return 0}}function td(e,t={}){const o=t.enabled??!0,r=t.darkThreshold??.235,a=t.improvementTarget??.12,i=t.sampleIntervalMs??600,s=t.minToggleMs??3e3,[c,l]=n.useState(!1),[d,u]=n.useState(0),p=n.useRef(0),f=n.useRef(0),h=n.useRef(null),m=n.useRef(!1),g=n.useRef(null);return n.useEffect((()=>{m.current=c}),[c]),n.useEffect((()=>{if(!o)return l(!1),()=>{};"undefined"==typeof document||g.current||(g.current=document.createElement("canvas"));let n=null,t=null,c=!1;const d=()=>{if(c)return;const n=nd(e.current,{scratch:g.current??void 0});u(n);const o=Date.now();m.current||(n>0&&n<r?p.current+=1:p.current=0,p.current>=2&&o-f.current>=s&&(h.current=n,f.current=o,m.current=!0,l(!0),p.current=0,t=setTimeout((()=>{if(c)return;nd(e.current,{scratch:g.current??void 0})-(h.current??0)<a&&(f.current=Date.now(),m.current=!1,l(!1)),h.current=null}),600)))};return n=setInterval(d,i),d(),()=>{c=!0,n&&clearInterval(n),t&&clearTimeout(t)}}),[o,r,a,i,s,e]),{flashOn:c,lastBrightness:d}}function od({active:e,zIndex:n=10001,onDismiss:t}){if(!e)return null;const r={position:"fixed",inset:0,background:"#FFFFFF",zIndex:n,pointerEvents:"none",animation:"nfid-flash-in 200ms ease-out"},a={position:"fixed",top:12,left:"50%",transform:"translateX(-50%)",zIndex:n+1,background:"rgba(10,19,32,.72)",color:"#FFFFFF",fontSize:12,fontWeight:600,letterSpacing:.2,padding:"6px 12px",borderRadius:999,pointerEvents:t?"auto":"none",display:"flex",alignItems:"center",gap:8};return o.jsxs(o.Fragment,{children:[o.jsx("style",{children:"\n @keyframes nfid-flash-in { from { opacity: 0 } to { opacity: 1 } }\n @media (prefers-reduced-motion: reduce) {\n .nfid-screen-flash { animation: none !important; }\n }\n "}),o.jsx("div",{className:"nfid-screen-flash",style:r,"aria-hidden":"true"}),o.jsxs("div",{className:"nfid-screen-flash-hint",style:a,role:"status",children:["Aumentando a luz da tela",t&&o.jsx("button",{type:"button",onClick:t,"aria-label":"Desligar iluminação assistiva",style:{background:"transparent",border:"none",color:"#FFFFFF",cursor:"pointer",fontSize:14,lineHeight:1,padding:"0 4px"},children:"×"})]})]})}function rd(e,n){return Math.hypot(e.x-n.x,e.y-n.y)}function ad(e){if(6!==e.length)throw new Error(`calculateEAR espera exatamente 6 pontos do olho, recebeu ${e.length}`);const[n,t,o,r,a,i]=e,s=rd(t,i),c=rd(o,a),l=rd(n,r);return l<1e-6?0:(s+c)/(2*l)}const id=(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}},sd={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:"#0059C4",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 cd({accessToken:e,onClose:t,onSuccess:r,onCannotGesture:a,autoLighting:i=!0}){const s=n.useRef(null),c=n.useRef(null),l=n.useRef(null),d=n.useRef(null),u=n.useRef(!1),p=n.useRef(null),[f,h]=n.useReducer(id,{status:"requestingPermission"}),[m,g]=n.useState(!1),{startCamera:v,stopCamera:w}=ro(),b=()=>{if(!s.current)return;const e=async()=>{if(s.current&&"ready"===f.status){try{const e=await Xt(s.current,new vt),n=1===e.length,t=n&&(e=>{if(!s.current)return!1;const{box:n}=e,{videoWidth:t,videoHeight:o}=s.current,r=t/2,a=o/2,i=.4*t,c=.4*o;return n.x+n.width/2>r-i/2&&n.x+n.width/2<r+i/2&&n.y+n.height/2>a-c/2&&n.y+n.height/2<a+c/2})(e[0]);g(n&&t)}catch(n){}d.current=window.setTimeout(e,100)}};e()};n.useEffect((()=>{al()}),[]),n.useEffect((()=>()=>{var e;null==(e=p.current)||e.abort()}),[]);const x=i&&("ready"===f.status||"capturing"===f.status),{flashOn:y}=td(s,{enabled:x});n.useEffect((()=>((async()=>{try{await Promise.all([Et.tinyFaceDetector.loadFromUri("/models"),Et.faceLandmark68Net.loadFromUri("/models")])}catch(e){}})(),()=>{d.current&&window.clearTimeout(d.current)})),[]),n.useEffect((()=>((async()=>{try{const e=await v();l.current=e,s.current&&(s.current.srcObject=e),h({type:"PERMISSION_GRANTED"}),b()}catch(e){h({type:"PERMISSION_DENIED"})}})(),()=>{l.current&&w(l.current)})),[v,w]);const _=async()=>{if(!c.current||!s.current)return;if(u.current)return;u.current=!0;const n=s.current,o=c.current,a=new AbortController;p.current=a;try{h({type:"START_CAPTURE"});const s=await function(e,n,t=3e3,o=.2,r){return new Promise((a=>{const i=Date.now()+t;let s=!1,c=!1;const l=e=>{c||(c=!0,a(e))},d=()=>{c||((null==r?void 0:r.aborted)||Date.now()>=i?l(!1):e.detectSingleFace(n,new e.TinyFaceDetectorOptions).withFaceLandmarks().then((e=>{if(e)if((ad(e.landmarks.getLeftEye())+ad(e.landmarks.getRightEye()))/2<o)s=!0;else if(s)return void l(!0);setTimeout(d,50)})).catch((()=>{setTimeout(d,50)})))};d()}))}(no,n,void 0,void 0,a.signal);if(a.signal.aborted)return;if(!s){const e=new io("Blink not detected within window",ao.LIVENESS_BLINK_MISSING);return void h({type:"SET_ERROR",message:e.getFriendlyMessage()})}const c=o.getContext("2d");if(!c)return void h({type:"SET_ERROR",message:"Failed to get canvas context"});o.width=n.videoWidth,o.height=n.videoHeight,c.drawImage(n,0,0,o.width,o.height);const l=await new Promise(((e,n)=>{o.toBlob((t=>{t?e(t):n(new Error("Failed to convert canvas to blob"))}),"image/jpeg",.95)}));try{const n=await Ol(l,e);r({success:!0,data:{faceId:n.payload.documentId,confidence:1}}),h({type:"UPLOAD_SUCCESS"}),setTimeout(t,1500)}catch(i){h({type:"SET_ERROR",message:"Face recognition failed"})}}catch(i){h({type:"SET_ERROR",message:"Failed to capture image"})}finally{u.current=!1}};return o.jsxs("div",{className:"neofaceid-root",style:sd.overlay,children:[o.jsx(od,{active:y}),o.jsx("style",{children:"\n @keyframes spin {\n 0% { transform: translate(-50%, -50%) rotate(0deg); }\n 100% { transform: translate(-50%, -50%) rotate(360deg); }\n }\n"}),o.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"}),o.jsxs("div",{style:sd.modal,className:"modal",children:[o.jsx("button",{type:"button",style:sd.closeButton,onClick:t,children:"×"}),o.jsx("video",{ref:s,style:sd.video,autoPlay:!0,playsInline:!0,muted:!0}),o.jsx("canvas",{ref:c,style:sd.canvas}),o.jsx("div",{style:sd.guide}),"ready"===f.status&&!m&&o.jsx("div",{style:sd.message,"aria-live":"assertive",children:"Centralize seu rosto no círculo"}),"capturing"===f.status&&o.jsx("div",{style:sd.message,"aria-live":"assertive",children:"Por favor, pisque os olhos"}),("ready"===f.status||"capturing"===f.status)&&o.jsx("button",{type:"button",className:"neofaceid-face-cannot-gesture",onClick:()=>{a?a():t()},"aria-label":"Não consigo fazer esse movimento — buscar alternativa",style:{position:"absolute",bottom:100,left:"50%",transform:"translateX(-50%)",minHeight:44,minWidth:44,padding:"10px 20px",background:"transparent",border:"1px solid rgba(255, 255, 255, 0.32)",borderRadius:22,color:"rgba(255, 255, 255, 0.9)",fontSize:14,fontWeight:500,fontFamily:"inherit",cursor:"pointer",zIndex:10},children:"Não consigo fazer esse movimento"}),"uploading"===f.status&&o.jsx("div",{style:sd.spinner}),"success"===f.status&&o.jsx("div",{style:sd.message,children:"Autenticado!"}),"error"===f.status&&o.jsx("div",{style:sd.message,children:f.message}),o.jsxs("div",{style:sd.controls,children:["ready"===f.status&&m&&o.jsx("button",{type:"button",style:sd.button,onClick:_,children:"Capturar"}),"capturing"===f.status&&o.jsx("button",{type:"button",style:sd.button,onClick:_,children:"Capturar"}),"error"===f.status&&o.jsx("button",{type:"button",style:sd.button,onClick:()=>{h({type:"RESET"})},children:"Tentar Novamente"})]})]})]})}const ld='<svg xmlns="http://www.w3.org/2000/svg" aria-label="NeoFaceID" viewBox="-43.1 -71.1 1318.2 1318.2"><g fill="currentColor"><path d="M138.1 2a10 10 0 0 1-5.8 2c-1.9 0-6.1 1.3-9.2 2.8a94 94 0 0 1-11.1 4.7c-3 1-8.1 3.4-11.2 5.2a33 33 0 0 1-6.7 3.3c-.5 0-1.4.6-1.8 1.4s-2.4 2.1-4.3 3a39 39 0 0 0-11.7 7.8 18 18 0 0 1-5.6 3.8c-1.8 0-33.9 32.3-35.3 35.5a27 27 0 0 1-4.5 6.3c-2 2-4.6 5.4-5.8 7.4-1.3 2.1-2.6 3.8-3.1 3.8s-1.2 1-1.5 2.2c-1.1 3.6-9.6 20.7-10.6 21.4-.5.3-.9 1.6-.9 2.8 0 1.3-.6 3.9-1.4 5.7s-1.2 4.6-.9 6q.4 2.5-1.1 3.8-1.6 1.4-1.6 6.2c0 3.8-.4 5.2-2 6.1-2.6 1.7-3.2 211.1-.6 212.1.8.3 2.6 3.1 4.1 6.3 3 6.3 5.3 8.7 10.2 11 1.8.8 3.3 1.9 3.3 2.4 0 1.4 6 4.2 7.7 3.6.8-.3 2.7.1 4.3.9 3.5 1.8 10.3 2 13.3.3 1.2-.6 3.8-1 5.8-1 2.2.1 4.2-.4 5-1.4.7-.8 3.2-2.7 5.6-4.1 3.9-2.2 6.8-5.6 10.8-12.2l2.7-4.3c1.7-2.6 1.8-7.8 1.8-91.1 0-87.1 0-88.4 2-90.2 1.6-1.5 2-3.1 2-8.7 0-4.2.6-8 1.5-9.8.8-1.6 1.2-3.5.9-4.3-1.2-3.3 6.7-21.9 12.4-29.2 1.2-1.5 2.2-3.3 2.2-4 0-2.1 23.3-24 27.5-25.9a192 192 0 0 0 11.6-5.7c4.2-2.1 8.8-3.9 10.1-3.9a10 10 0 0 0 5.1-2q2.5-2 7-2c2.7 0 4.9-.6 5.7-1.5 1.1-1.3 13.8-1.5 98.4-1.8 107-.4 111.3-.7 118.2-6.8 1.1-1.1 2.7-1.9 3.5-1.9 2.7 0 11.7-10.4 15.8-18.3 4.9-9.4 5.8-18.8 2.1-22.2-1.1-1-2-2.8-2-4.1 0-2-3.5-8.6-5.7-10.6-4-3.7-8.7-7.1-11.7-8.3-2-.9-3.9-2.2-4.2-3-1.1-2.7-237.1-2.1-240.3.5m718.4 0c-1 1.1-2.7 2-3.7 2-2.4 0-12.8 9.7-12.8 12 0 1-.8 2.8-1.8 4.1-8.3 11.1-4.5 32.8 7.8 44.3a27 27 0 0 0 5.9 4.6 26 26 0 0 1 5.9 2.9c7.2 4.2 8.1 4.3 109.3 4.7 79.6.4 91.8.6 92.9 1.9.7.9 2.9 1.5 5.5 1.5q4.2 0 6.5 2c1.3 1.1 3.6 2 5.1 2s3.1.4 3.4 1 1.7 1 3.1 1c1.3 0 3.2.4 4.2 1s2.8 1.5 4.2 2c2.7 1.1 7.2 3.8 14.4 8.6 5.7 3.9 22.6 20.8 22.6 22.7 0 .8.9 2.2 2 3.2a57 57 0 0 1 9 16c.6 1.8 1.8 3.9 2.6 4.5.7.7 1.4 2.7 1.4 4.5s.7 3.8 1.5 4.5q1.5 1.3 1.5 6.7c0 3 .5 6.3 1.1 7.4.7 1.3 1 29.4.9 87.7 0 74.6.1 86 1.4 87.7.9 1.1 1.6 3.7 1.6 5.9 0 2.1 1 5.5 2.2 7.5 5.6 9.4 8.2 13.1 9.3 13.1.7 0 2 .9 3 2 8.7 9.7 33.6 11 42.3 2.4.7-.8 2-1.4 2.7-1.4 2.2 0 11.4-10.1 12.6-14a20 20 0 0 1 2.7-5.3q1.7-1.8 1.4-6.4c-.1-2.5.4-5.5 1-6.6a8 8 0 0 0 .9-4.5q-.1-2 .8-2.2c2 0 1.2-6.4-.9-7.8-1.9-1.1-2-2.3-2-16.7s.1-15.5 2-16.5c2.1-1.1 2.8-4 1-4q-.9-.1-1-1.5.1-1.4 1-1.5c2 0 1.1-7.4-1.1-8.8-2.9-1.8-2.6-38.5.4-40.6 2.1-1.6 2.2-5.5.1-7.1-2.6-1.9-3-9.8-.6-12.1 2.9-2.8 3-12 .2-12.7-2.6-.7-2.6-3.7 0-4.4 2-.5 2.9-3.3 1-3.3q-.9-.1-1-1.5.1-1.4 1-1.5c2.1 0 1.2-13.4-1-15.3-1.9-1.6-2.1-2.8-1.9-17.3.1-12.5-.2-15.9-1.4-17.2-.8-.9-1.7-3.7-2.1-6.2-1-8.8-1.8-11.9-3.2-13.1-.8-.6-1.4-2.6-1.4-4.5s-.4-3.5-.9-3.9-4.3-7.4-8.5-15.9a87 87 0 0 0-9-15.9 3 3 0 0 1-1.6-2.6c0-1-2.7-4.7-6-8.2s-6-6.8-6-7.4a177 177 0 0 0-23.9-23.5c-.7 0-3.5-2.3-6.3-5a31 31 0 0 0-5.8-5c-.5 0-3-1.7-5.7-3.9a32 32 0 0 0-7.1-4.5c-1.2-.4-2.2-1.2-2.2-1.7s-2.9-2.3-6.5-4a28 28 0 0 1-7-4 14 14 0 0 0-5-2c-2.5-.6-5-1.7-5.6-2.5S1110.5 8 1109 8s-3.9-.9-5.3-2q-2.5-2-7.1-2c-3.5 0-4.9-.5-5.8-2-2-3.1-231.4-3.2-234.3 0m-283 111.3c-1.8 1.1-8.2 1.8-31.4 3.3-4.9.3-9.4 1.2-10.5 2-1.2.8-4.5 1.4-7.9 1.4-4.3 0-6.5.5-8.4 2a6 6 0 0 1-5.4 1.3q-2.9-.5-5.4 1.1a10 10 0 0 1-4.5 1.6c-1.1 0-3.2.7-4.5 1.6q-2.6 1.6-5.4 1.1-3-.6-5.4 1.3c-1.4 1.1-3.9 2-5.5 2s-3.5.7-4.2 1.5-2.2 1.5-3.4 1.5-4.5 1.1-7.4 2.5-6.3 2.5-7.4 2.5-3.1.9-4.5 2-3.8 2-5.3 2-3.3.6-3.9 1.4-3.5 2-6.4 2.6a47 47 0 0 0-13.7 5.9c-.8.5-4.6 2.4-8.5 4.1a54 54 0 0 0-10 6 15 15 0 0 1-5.9 3.4c-1.7.4-5.2 2.5-7.9 4.7a25 25 0 0 1-6.1 3.9c-.7 0-2.5 1.4-4.2 3.1a30 30 0 0 1-6.4 4.9c-1.9 1-6.4 4.8-10 8.4a33 33 0 0 1-7.8 6.6 211 211 0 0 0-28.2 27.7c0 .8-2.6 4.2-5.7 7.7-3.2 3.5-7.7 9.5-10.1 13.3a54 54 0 0 1-6.2 8.8q-1.8 1.7-2 2.8a69 69 0 0 1-8.9 17c-1 .6-2.1 2.7-2.4 4.6-.6 2.9-4.2 11-7.5 17.1a27 27 0 0 0-4.2 10.5c0 1.3-.4 2.7-1 3s-1 1.9-1 3.5-.7 3.5-1.5 4.4c-.8.8-1.5 2.8-1.5 4.4s-.6 3.5-1.4 4.1a9 9 0 0 0-2.1 4.4c-.4 1.8-1.8 6.4-3.1 10.4a47 47 0 0 0-2.4 10c0 1.6-.7 3.8-1.5 4.9a17 17 0 0 0-1.5 7.5q0 5.7-1.5 6.9c-.9.7-1.5 2.9-1.5 5.2a18 18 0 0 1-1.6 7 14 14 0 0 0-1.1 8.4c.4 3.9.1 5.8-1.1 7.5s-1.7 4.8-1.7 12.6c-.1 8.2-.4 10.5-1.8 12.1s-1.7 4.1-1.7 16.4c0 12-.3 14.8-1.6 15.8-1.3 1.2-1.5 4.5-1.3 23.8.2 25.1.5 24.2-7.2 24.2q-4.5 0-5.9 1.5c-.7.8-2.4 1.5-3.8 1.5-6.1 0-29.2 19.2-29.2 24.3 0 .9-.9 2.3-2.1 3.1-2 1.4-5.9 11-5.9 14.6 0 .9-.7 2.5-1.5 3.6-1 1.3-1.4 4.5-1.5 10.5 0 7.1-.4 9.1-2 11.2-2.8 3.5-2.8 13.4 0 17 1.8 2.3 2 4 2 20.9 0 13.4.3 18.7 1.3 19.6.6.7 1.5 5.6 2 11 1.5 19.4 1.9 22.1 3.3 23.3.8.7 1.4 3 1.4 5.6q0 4.4 2 7.1 2.1 2.5 1.5 5.1-.5 2.6 1.5 6.4c1.1 2.1 1.8 4.3 1.4 4.9a39 39 0 0 0 4.3 15.3 10 10 0 0 1 1.3 4.6c0 1.5.6 3.2 1.4 3.8.8.7 2.6 4.8 4 9.3 1.5 4.4 3.5 9.2 4.6 10.5s2 3.1 2 3.8c0 2.8 22.8 28.5 25.4 28.5.5 0 1.7.6 2.5 1.3 2.6 2.1 10.9 3.9 13.1 2.7 1-.5 3.7-1 5.9-1s4.3-.5 4.6-1c1.6-2.6 3.3-.8 3.8 4.2.9 9.1 2.3 15.8 3.5 17 .7.7 1.2 3.7 1.2 6.7q0 5.5 1.7 7.3c.9 1 1.6 3.3 1.5 5.1 0 1.7.6 4.8 1.3 6.7s2.3 6.7 3.5 10.7c1.1 4 2.5 7.5 3 7.8s1 2.1 1 3.9c0 1.9.7 3.9 1.5 4.6s1.5 2.5 1.5 4.1.4 3.1 1 3.4 1 1.7 1 3c0 1.9 3.7 10 9 19.5l7.5 15c3.7 7.4 7.2 13.8 7.8 14.2a10 10 0 0 1 2.6 3.5 83 83 0 0 0 8.9 13.5c1.7 2.2 3.2 4.5 3.2 5.2s1.8 3 4 5.1 4 4.6 4 5.5c0 2 54.1 56 56.1 56 .8 0 3.1 1.6 5 3.6a86 86 0 0 0 16.8 12.3 43 43 0 0 1 5.9 4.3 15 15 0 0 0 4.2 2.8c.4 0 2.1 1.1 3.7 2.4 1.5 1.3 3.9 2.7 5.2 3.1a71 71 0 0 1 10.5 6.1c4.4 3 8.6 5.4 9.5 5.4 1.4 0 9 4.6 10.2 6.3.8 1 7.6 4.4 11.5 5.7a11 11 0 0 1 4.4 2.6c.7.7 2.2 1.4 3.3 1.4 1.9 0 9.3 2.9 12.7 5.1l5 2.5 6.2 3c1.4.8 3.7 1.4 5 1.4 1.4 0 3.3.9 4.3 2 1.1 1.2 3.1 2 5.1 2 1.8 0 3.6.4 3.9 1s1.8 1 3.3 1 3.6.7 4.6 1.5c1.1.8 3.9 1.5 6.2 1.5 2.5 0 4.7.6 5.4 1.5q1.3 1.4 6 1.5 4.6 0 6 1.5c1 1.1 3.6 1.5 11.4 1.5q10.2 0 12.6 1.5c3.7 2.1 47.3 2.1 51.4 0q2.8-1.5 11.1-1.5c6.1 0 8.6-.4 9.5-1.5q1.3-1.4 6-1.5 4.6 0 6-1.5c.7-.8 2.9-1.5 4.9-1.5s4.9-.7 6.5-1.5 3.9-1.5 5.2-1.5c1.2 0 2.6-.5 2.9-1s1.9-1 3.4-1 3.8-.9 5.1-2 3.3-2 4.4-2 3.9-.9 6.1-2 5.5-2.3 7.4-2.6a35 35 0 0 0 8.2-3.4c2.5-1.5 5.7-3.1 7-3.5a13 13 0 0 0 3.9-2c.8-.7 4.4-2.5 8-4.1s7.6-3.6 8.9-4.6 3.1-1.8 4.1-1.8 3.7-1.5 6.1-3.4 6.6-4.6 9.3-6a52 52 0 0 0 9.2-6.6c2.4-2.2 5-4 5.7-4s2.2-.9 3.2-2 2.5-2 3.2-2 4.3-2.7 7.7-6 6.8-6 7.5-6 6.8-5.4 13.6-12 13-12 13.9-12 2.6-1.6 3.8-3.6c1.1-1.9 3.2-4 4.4-4.5s2.4-1.7 2.4-2.6 5.4-7.2 12.1-13.8S877 941.9 878 940s3.3-4.9 5-6.5c1.8-1.7 4.7-5.3 6.4-8s4-5.6 4.9-6.4c1-.7 1.7-2.1 1.7-3 0-1 1.1-2.8 2.5-4.1s2.5-2.9 2.5-3.6a13 13 0 0 1 2.8-4.6 97 97 0 0 0 8.9-13.3c.7-1.1 3.5-6.7 6.3-12.5a180 180 0 0 1 6.1-12 84 84 0 0 0 7.9-18.6c0-1.2.5-2.6 1.1-2.9a43 43 0 0 0 5.9-12.6c0-1.6 1.9-7.8 3.2-10.3.5-1 1.1-3.8 1.3-6.3a12 12 0 0 1 1.9-6.2c.9-1 1.6-3.1 1.6-4.8s.7-3.6 1.6-4.4q1.6-1.3 1.1-4.8a20 20 0 0 1 1-7.5c.7-2.1 1.3-5.2 1.3-6.8q.1-8.7 9.6-8.8 12.4 0 28-15.8a56 56 0 0 0 14.3-21.2c.6-1.4 2.4-4.8 4-7.5a22 22 0 0 0 3-7.7c.1-1.5.6-3 1.1-3.3s1-1.9 1-3.4.7-3.6 1.5-4.7c.8-1 1.5-3.1 1.5-4.5 0-1.5.7-3.2 1.5-3.9q1.5-1.2 1.5-7.2c0-4.5.5-6.6 2-8.5s1.9-3.4 1.4-6q-.6-3.4 1.1-8a20 20 0 0 0 1.1-10.5c-.4-4.6-.2-6.5 1.1-8.4s1.6-5 1.6-14.7c-.1-10.3.2-12.7 1.8-15.3 3-4.9 2.9-48.9-.1-52.7-1.7-2.2-2-3.6-1.5-8.4.4-4.3.1-6.4-1-7.9a8 8 0 0 1-1.5-4.2c-.1-11.9-25.4-37-37.5-37.2-1.1 0-2.9-.7-3.9-1.5a9 9 0 0 0-4.7-1.5c-3.9 0-4-1.1-3.8-25 .1-18.7-.1-22-1.5-24.9-1.5-2.7-1.7-5.6-1.5-16q.3-12.7-.9-14.8a44 44 0 0 1-1.2-13c0-8.1-.4-11.4-1.5-12.9a17 17 0 0 1-1.5-7.5q0-5.7-1.5-6.9t-1.5-6.9c0-3.2-.6-6.5-1.4-7.6s-1.6-4.7-1.9-8c-1.1-10.7-2.3-16-4-18.5-.9-1.3-1.7-3.6-1.7-5s-.7-3.4-1.5-4.4a9 9 0 0 1-1.5-4.7c0-1.5-.4-3.1-1-3.4s-1-1.7-1-3-1.4-4.7-3.1-7.6a36 36 0 0 1-3.6-8.3c-.3-1.7-2.3-6.5-4.4-10.7a53 53 0 0 1-3.9-8.4 59 59 0 0 1-5.6-10.5 53 53 0 0 0-4.6-8.9 9 9 0 0 1-1.8-4.2c0-1-.9-2.3-1.9-2.9-1.1-.5-2.3-2-2.7-3.2s-1.8-3.7-3.3-5.4a59 59 0 0 1-4.6-6.5l-3.8-6.4c-1-1.6-5-6.2-8.8-10a36 36 0 0 1-6.9-8.5c0-1.9-14-16-15.9-16-.7 0-5.3-3.8-10-8.5a69 69 0 0 0-9.7-8.5c-.5 0-3.4-2.2-6.5-4.8a81 81 0 0 0-14.8-10.1q-2.5-1.4-3.1-2.2c-.9-1.4-7.7-5.7-10.1-6.4-1.3-.4-3.5-1.8-4.9-3a32 32 0 0 0-7.3-4.5c-2.6-1.2-5-2.6-5.3-3.1q-.6-.8-2.3-.9c-1 0-3-.9-4.4-2s-3.9-2-5.5-2a7 7 0 0 1-4.2-1.4c-.6-.8-3.4-2.2-6.1-3.1s-5.1-2.1-5.4-2.6-1.9-.9-3.4-.9-3.8-.9-5.1-2a9 9 0 0 0-4.7-2c-1.3 0-3.1-.4-4.1-.9a54 54 0 0 0-7.7-2.6c-3.3-.9-7.3-2.3-8.8-3.1s-3.8-1.4-5-1.4-3.5-.9-5.2-2c-1.6-1.1-4.2-2-5.7-2s-3-.5-3.3-1-1.7-1-3.1-1-3.6-.7-4.9-1.6q-2.6-1.6-5.4-1.1-3 .6-5.4-1.3-2.5-2-7.7-2c-2.8 0-6.1-.6-7.3-1.2-2.4-1.4-13.5-2.6-32.4-3.4-8.8-.4-12.5-1-13.4-2-1.6-1.9-67.3-2-70.4-.1m85.7 55.8c.9.5 4.5.9 8 .9 3.9.1 7 .6 8.2 1.5s4.2 1.5 7 1.5c2.9 0 5.9.7 7 1.5s3.8 1.5 6.1 1.5 4.6.5 5.3 1.2c1.1 1.1 7.2 2.4 16.4 3.5 2.6.2 5.2 1.1 5.9 1.9.6.8 2.2 1.4 3.6 1.4s4.1.9 6.1 1.9a59 59 0 0 0 20 7.1c1.1 0 2.3.4 2.6.8.7 1.2 15.1 8.2 16.7 8.2 2 0 10.9 4.3 10.9 5.2 0 .5 2.8 2.3 6.3 3.9 6 2.9 10.8 5.6 15.8 9 6.6 4.4 8.4 5.6 11.4 7.4 9.8 6 15.6 11 31 26.7S872 280.6 872 283c0 .5 1.1 2.2 2.5 3.8s3.4 5.1 4.5 7.7 2.7 5.3 3.5 5.9a67 67 0 0 1 9.5 18.9c0 1.3.8 3.4 1.7 4.7a42 42 0 0 1 6.3 14.5c0 1.2.9 3.4 2 4.8s2 3.9 2 5.5.6 3.5 1.4 4.1c.8.7 1.7 3.3 2 5.9.9 8.6 1.8 12.1 3.2 13.3.8.7 1.4 3 1.4 5.7q0 4.4 1.8 6.5c1.2 1.3 1.7 3.6 1.7 7.7.1 3.5.7 6.5 1.5 7.5 1 1.2 1.3 3.8 1.1 9s.2 8.2 1.4 10.5c1.3 2.5 1.6 5.5 1.4 13.5-.3 8.7-.1 10.7 1.4 12.3 1.6 1.7 1.7 6.4 1.7 61.6 0 69.2-.3 66.6 9.1 71.9 5.5 3.1 7.9 3.3 11.7 1.3 1.5-.8 3.9-1.7 5.4-2s6.4-4.3 11.4-9.1c4.8-4.7 9.4-8.5 10.2-8.5 1.8 0 7.3 4.5 8.9 7.4 2 3.4 1.8 49.5-.2 53.2-1.1 2.1-1.5 6.1-1.5 14 0 8.7-.3 11.4-1.5 12.4s-1.5 3.5-1.5 10.5-.4 9.6-1.5 10.5c-.8.7-1.5 2.8-1.5 4.7s-.7 4.8-1.6 6.5-1.3 4-1 5.1-.2 3.3-1 5c-.9 1.6-1.7 4.8-1.9 7.1-.1 2.5-1.6 6.5-3.7 10.1-2 3.3-3.9 7.1-4.3 8.5-1.7 5.9-7.8 9.7-10.5 6.5a6 6 0 0 0-3.9-1.5c-1.5 0-3.6-.7-4.9-1.5-1.9-1.4-2.4-1.4-5.1 0-1.7.8-4.6 1.5-6.5 1.5-5.7 0-16.5 12.6-16.6 19.3 0 1.2-1.2 4-2.5 6.2a16 16 0 0 0-2.5 8.6q0 4.5-1.5 5.9-1.5 1.2-1.5 7c0 4.1-.5 6.4-1.9 8.1a17 17 0 0 0-2.4 6.9 66 66 0 0 1-4.7 20.7c-.6 2.3-1.5 4.5-2 4.8s-1 1.9-1 3.4c0 1.6-.9 3.9-1.9 5.3a14 14 0 0 0-2.6 5.4 61 61 0 0 1-5.9 14.4c-.7.8-2.5 4.4-4.1 8a52 52 0 0 1-4.1 8.1c-.8.8-1.4 2.2-1.4 3 0 1.4-6.6 12.3-11.9 19.5a56 56 0 0 0-4.6 8c-.9 2.2-3.8 6.1-6.4 8.9a40 40 0 0 0-6.4 8c-.9 1.6-3.6 5-6.1 7.5-2.5 2.4-4.6 5.1-4.6 5.9 0 1.9-41 43.1-42.8 43.1-.8 0-3.9 2.4-7 5.4-3.1 2.9-7 6-8.7 6.9-1.6.8-4.3 2.9-5.9 4.6s-3.4 3.1-3.9 3.1a26 26 0 0 0-5.9 4 28 28 0 0 1-6 4c-.6 0-2.3 1.1-4 2.5-1.6 1.4-3.5 2.5-4.2 2.5s-2.1 1-3.2 2.1c-1 1.2-4.2 3.2-7 4.4a21 21 0 0 0-5.8 3.4 3 3 0 0 1-2.2 1.1c-.9 0-4.2 1.6-7.5 3.5a44 44 0 0 1-8.7 4.1c-1.5.4-3.6 1.4-4.7 2.3q-3.8 3.1-16.5 6.7c-3.6.9-6.9 2.1-7.5 2.6s-2.1.8-3.5.8a9 9 0 0 0-4.9 1.9q-2.2 2-6.7 1.8c-2.8 0-5.1.6-6 1.5-1.2 1.2-3.1 1.4-8.4 1-5-.3-7.6 0-10 1.2-4.7 2.3-40.6 2.4-47.1.1a30 30 0 0 0-10.4-1.3c-3.3.1-7-.4-8.2-1s-3.7-1.2-5.5-1.2-5-.9-7.1-2-4.8-2-6.2-2c-3.3 0-17.6-4.8-19.6-6.6-.8-.8-2.9-1.4-4.6-1.4a7 7 0 0 1-4.7-1.9c-.9-1-3-2.1-4.5-2.4s-5.5-2.2-8.9-4.1c-3.3-2-7.2-3.6-8.6-3.6s-3.4-.8-4.4-1.8-3.6-2.7-5.7-3.9a110 110 0 0 1-16.1-9.2 10 10 0 0 0-3.7-2.1c-.5 0-2.4-1.2-4.2-2.7-3-2.6-6.6-5-12.4-8.2-1.5-.8-2.8-1.7-3.1-2a39 39 0 0 0-8.7-6.1c-.5 0-2.2-1.4-3.9-3.1a24 24 0 0 0-5.9-4.6 156 156 0 0 1-18.2-15.6c-10.8-11-22.4-24-24.1-26.7a51 51 0 0 0-6.6-8c-2.5-2.4-4.6-5.2-4.6-6.1s-.9-2.4-2-3.4-3.9-4.9-6.2-8.7c-2.4-3.9-5.6-8.5-7.1-10.3a29 29 0 0 1-4.3-7.9c-.9-2.4-2.2-5-3-5.7-.8-.6-1.4-1.7-1.4-2.4a19 19 0 0 0-3.5-5.6c-1.9-2.4-3.8-6-4.1-7.9a50 50 0 0 0-3.8-9.5 54 54 0 0 1-4.6-12 54 54 0 0 0-2.7-8.5c-.7-1.4-1.3-3.4-1.3-4.5a12 12 0 0 0-2-5q-1.8-2.9-1.4-5.2c.3-1.2-.1-3.6-1-5.4s-1.6-4.4-1.6-5.9-.7-4.5-1.6-6.5c-1-2.4-1.3-5.1-.9-7.2.4-2.5.1-4-1.4-6q-2.1-2.6-2.1-6.8c0-2.6-.6-4.8-1.5-5.5s-1.5-2.7-1.5-4.6-.4-3.6-1-3.9-1-1.9-1-3.4c0-1.7-1.3-4.3-3.3-6.7a20 20 0 0 1-4.1-6.8c-1.2-4.9-10.4-13.1-16.3-14.5a29 29 0 0 1-7-2.6c-2.6-2-6.7-1.8-11 .5-2.1 1.1-4.8 2-6 2s-2.5.4-2.8 1c-.9 1.5-4.5 1.2-4.5-.4 0-.7-.9-2.5-2-3.9s-2-3.8-2-5.3-.6-3.5-1.4-4.3a75 75 0 0 1-6.3-17.6c-.3-1.7-1.4-4-2.4-5.3a6 6 0 0 1-1.3-5.1c.4-1.7-.1-4.1-1-5.9-.9-1.7-1.6-4.4-1.6-6s-.7-4.6-1.5-6.6c-1-2.3-1.3-5-1-6.9.5-2.4.1-3.9-1.4-5.9-1.6-2-2.1-4.1-2.1-8.6q0-6-1.4-7.2c-2.3-1.8-4.1-57.3-2.1-66 1.9-8.9 10.6-10.9 15.2-3.7.5.7 3.6 3.1 7.1 5.4 11.5 7.8 33.2 5.3 33.2-3.7 0-.9.9-2.5 2-3.5 2-1.8 2-3 2-29.1-.1-17.4.3-28 .9-29.3.7-1.2 1.1-11.7 1.1-28.1 0-21.5.3-26.6 1.5-29.1 1.2-2.2 1.5-5.7 1.4-13.5-.1-8.4.2-10.8 1.5-12.3 1.1-1.3 1.6-3.7 1.6-8.7 0-5.2.5-7.6 2-9.9a8 8 0 0 0 1.4-6.2c-.4-2 0-4.9 1-7.4.9-2.3 1.4-4.9 1.1-5.8s.4-3.4 1.4-5.4c1.3-2.6 1.7-4.9 1.4-7.8-.5-3.1-.1-4.7 1.6-6.9 1.1-1.6 2.1-3.9 2.1-5.2a8 8 0 0 1 1.5-4.2 9 9 0 0 0 1.5-4.7c0-1.5.5-3.1 1-3.4s1-1.7 1-2.9a33 33 0 0 1 3.5-9c1.9-3.7 3.5-7.5 3.5-8.5a244 244 0 0 1 29.7-52.3c2.4-2.7 4.3-5.4 4.3-6 0-1.6 23.2-24.8 24.8-24.8.7 0 4.8-3.3 9.1-7.3 4.2-3.9 9-8 10.6-8.9l9.7-6c1.5-1 3.3-1.8 4.1-1.8s2.2-.9 3.2-2 4.1-3.1 6.9-4.5 5.8-2.9 6.6-3.5l11.5-5.6a139 139 0 0 0 11.5-5.9c.8-.7 2.9-1.5 4.5-1.8a53 53 0 0 0 16.6-5.6c3.4-1.7 7.7-3.1 9.5-3.1a16 16 0 0 0 6.1-1.4 36 36 0 0 1 12-3.6 5 5 0 0 0 3.3-1.5q1.2-1.5 6.9-1.5c3.5 0 6.5-.6 7.7-1.5 1-.8 4.1-1.5 6.7-1.5s5.8-.6 7-1.2c3.7-2.1 18.4-3 63.7-3.6 43.8-.7 48.1-.6 51.2.9"/><path d="M752.5 559.1c-2.7 1.6-6.2 3.5-7.7 4.2a42 42 0 0 0-14.3 14.5c-.3 1.5-1.2 4-2 5.5-2.8 5.5-2.1 30 1 33.3 1.4 1.5 2.5 3.1 2.5 3.7 0 3 6.7 8.6 16 13.4 5.7 2.9 30.7 3.5 33 .8.7-.8 1.9-1.5 2.7-1.5 3 0 12.3-10.4 16.3-18.3 4.5-8.9 5.8-22.7 2.5-28.5-.8-1.5-1.9-4.6-2.5-7-1.2-4.8-8.3-13.8-11.7-14.7-1.2-.4-2.9-1.5-3.9-2.6-.9-1-3-1.9-4.5-1.9-1.6 0-4.3-.9-6.1-2-5.2-3.2-14.9-2.7-21.3 1.1m-296.1 7.1a8 8 0 0 1-4.2 1.8c-1.2 0-2.4.5-2.7 1s-2.4 1.9-4.5 3-4.3 3.1-4.9 4.7c-.6 1.5-2.7 5-4.6 7.8-3.1 4.4-3.5 5.7-3.5 11.1 0 4.8-.4 6.5-2 7.9-1.5 1.3-2 3.1-2 6.6 0 3.8.4 5.1 2 5.9q2 1 2 4.5c0 6 8.1 16.2 17.8 22.3 5.4 3.4 28.3 3 33.1-.6 1.7-1.2 3.7-2.2 4.5-2.2s2.3-1.1 3.3-2.5l5.3-7.3c6.6-8.9 7-10.4 7-24.3 0-10-.3-12.9-1.5-13.9a6 6 0 0 1-1.5-3.9c0-3.6-16.4-20.1-19.9-20.1-1.4 0-3.2-.6-4-1.4-2.6-2.3-16.9-2.6-19.7-.4M597.5 601c-11.1 1-12.2 1.7-17 12l-3.1 6.3a19 19 0 0 0-1.4 7.1q0 4.3-2 6.9-2 2.5-2 6.9c0 2.4-.6 5.3-1.4 6.4-1.6 2.2-2.3 11.4-3.2 38.4-.5 16.2-.4 16.6 2.2 23 3 7.2 9.9 14.6 14.6 15.6 1.5.4 3.3 1.3 3.9 2 2.6 3.2 12.1 6.6 16.7 6.1 2.7-.3 6.2.1 8.5.9 4.8 1.7 12 1.8 14.9.3 1.2-.6 3.9-1.1 6.2-1.1 11.1.2 21.1-15.1 16.1-24.7-3.7-7.3-6-8.1-23.6-8.1-15.9 0-15.9 0-18.9-4.2-3.8-5.2-4.3-14.3-1-18.5 1.6-2.1 2-4.1 2-10.7 0-5.2.5-8.7 1.2-9.4a21 21 0 0 0 2-8c1.3-12.3 2.4-18.2 3.6-19.4.8-.8 1.2-4.6 1.2-10.5 0-9.2 0-9.2-4.5-13-5.7-4.8-6.5-5-15-4.3m138.9 189.1c-.9 1-2.4 1.9-3.3 1.9s-4.1 2.5-7.1 5.5-6 5.5-6.6 5.5c-.7 0-2.6 1.1-4.2 2.5a14 14 0 0 1-3.7 2.5c-.5 0-2.7 1.6-5.1 3.5-2.4 2-5.8 4.1-7.6 4.7s-5.4 2.4-7.9 3.9-5.7 3-7 3.4a13 13 0 0 0-3.9 2c-1.4 1.2-3.4 1.7-11.7 3.2-1.8.3-3.8 1.1-4.4 1.9s-3 1.4-5.6 1.4a11 11 0 0 0-6.8 1.9c-1.9 1.4-3.5 1.7-7.2 1.4q-4.9-.4-8.7 1.1c-5.5 2.3-56.5 2.4-61.9.1-2-.8-6.5-1.5-10-1.5q-6.5 0-7.7-1.5c-.7-.9-2.9-1.5-5.4-1.5-2.3 0-5.1-.7-6.2-1.5-1-.8-3.1-1.5-4.6-1.5s-3-.5-3.3-1-2-1-3.7-1c-1.6 0-4.1-.9-5.5-2a9 9 0 0 0-3.8-2c-.6 0-2-1-3.1-2.1-1-1.2-4.2-3.2-7-4.4a54 54 0 0 1-14.1-11.3 66 66 0 0 0-14.3-11.7q-1.3-1.5-6.5-1.5c-7.1 0-18.5 11.1-18.5 17.9 0 3.8 4 13.3 6 14.6.6.4 1.9 2.3 2.9 4.4 2.3 4.3 15.8 17.9 22.8 22.6 6.6 4.5 30.6 16.5 33 16.5 1.2 0 2.6.6 3.2 1.4 1.2 1.4 4.7 2.3 13.3 3.2 2.6.3 5.2 1.2 5.9 2q1.2 1.4 6.6 1.4c3.4 0 6.8.7 9.3 2 6.1 3.1 76.3 3.1 80.3 0 2-1.6 4-2 9.5-2q7 0 8.1-1.4c.7-.8 3.3-1.6 5.9-1.9 7.5-.9 11.6-1.8 13.2-3.2.8-.7 2.9-1.5 4.5-1.8a130 130 0 0 0 35.5-16.2 32 32 0 0 1 7.1-4c1.4-.3 3.9-1.9 5.4-3.5s3.5-3 4.4-3c2.3 0 22.1-20.8 24.2-25.4 3.9-8.6.4-19.7-8-25.3-3.9-2.5-14.5-2.7-16.7-.2M29 793.5c-1.4.8-3.5 1.4-4.8 1.5-1.2 0-3.2 1.1-4.4 2.5s-2.9 2.5-3.7 2.5c-2.7.1-7.6 5.4-10.7 11.5a22 22 0 0 1-4.1 6.2c-2.5 1-1.8 217 .7 218.3 1.6.8 2 2.1 2 5.9q0 4.8 1.5 6.1c.8.7 1.5 2.7 1.5 4.4 0 1.9 1.1 4.7 2.5 6.6s2.5 4.4 2.5 5.5c0 2.9 7.2 17.1 9.9 19.6 1.2 1.1 2.1 2.6 2.1 3.3 0 1.2 1.9 4 8.2 12 1.3 1.7 2.8 4 3.3 5.3 1.4 3.3 32.4 34.2 36 35.9 3.3 1.6 8.5 5.1 12.9 8.9 1.5 1.4 3.4 2.5 4 2.5a158 158 0 0 1 20.6 10.2c1.4.8 6.6 2.7 11.5 4.3s10.2 3.3 11.7 4.1c1.4.8 4.8 1.4 7.5 1.4q4.8 0 7.8 2c4.7 3.1 225.2 3.1 228 0 1-1.1 2.9-2 4.2-2 4.8 0 13.9-8 20.9-18.5 4.7-6.9 5.1-22.7.7-30.3a47 47 0 0 0-29.3-22.8c-2.5-.4-48.2-.8-101.6-1.1-84.6-.3-97.3-.5-98.4-1.8q-1.2-1.5-7.6-1.5c-4.1 0-7.9-.7-10.6-1.9-2.4-1.1-7.7-2.9-11.8-4.2-4.1-1.2-8.6-3-9.9-4a8 8 0 0 0-4.1-1.9c-.9 0-2.6-1.1-3.8-2.5s-2.9-2.5-3.7-2.5c-1.8 0-23.5-20.8-23.5-22.6 0-.7-1-2.5-2.3-4.1a37 37 0 0 1-3.5-5.3l-3.7-7a37 37 0 0 1-3.1-8.3c-.4-2-1.1-4-1.5-4.3-.5-.3-.9-1.8-.9-3.3s-.5-3.2-1.1-3.8a51 51 0 0 1-1-15c.2-12.6 0-14.2-1.9-16.5-2-2.6-2-3.6-2-85.7 0-83.1 0-83.1-3.5-90.1-4.8-9.6-16-18-24-18-1.2 0-2.8-.7-3.5-1.5-1.6-2-12.6-2-16 0m1154 5c-1.4.8-3.6 1.4-5 1.5-2.8 0-12.5 5.9-15.3 9.3a37 37 0 0 0-6.7 11c0 .8-.9 2.2-2 3.2-1.6 1.4-2 3.1-2 7.9 0 3.8-.6 7-1.5 8.3-1.3 1.8-1.5 13.4-1.4 87.7 0 58.2-.3 86.2-1 87.5-.6 1.1-1.1 4.4-1.1 7.4q0 5.5-1.5 6.7c-.8.7-1.5 1.9-1.5 2.7s-.9 2.6-2 4c-1.2 1.5-1.8 3.4-1.5 4.4q.5 1.8-1.4 3.8a21 21 0 0 0-3.6 5.3l-3.3 6.5a72 72 0 0 1-16.4 16.3c-.7 0-3.1 1.7-5.2 3.7a47 47 0 0 1-9.2 6.4 68 68 0 0 0-6.6 3.6c-.7.6-3 1.6-5 2.2s-4.2 1.9-4.8 2.7c-.8.8-3.1 1.4-6 1.4q-4.8 0-7 2c-1.7 1.5-3.7 2-8 2-3.4 0-6.4.6-7.6 1.5-1.6 1.2-15.2 1.4-98.7 1.5-105.6 0-104.7 0-110.8 5.6-1.4 1.3-3 2.4-3.6 2.4-2.2 0-7.9 6.6-10.6 12.2-1.5 3.1-3.2 6-3.7 6.3-2.5 1.5-1.2 22.4 1.7 27.3 3.7 6.5 14 16.9 18.4 18.6 2 .8 3.9 2.2 4.2 3 1.1 2.8 231.7 2.3 234.2-.4q1.8-2 5.7-2c2.1 0 5.5-.9 7.5-2 2.1-1.1 4.3-2 5-2 1.8 0 16.6-5 17.9-6.1 2-1.6 18.8-9.9 20.1-9.9.7 0 2.1-.9 3.1-2.1.9-1.1 3.3-2.9 5.2-3.9s5.1-3.4 6.9-5.4 4.1-3.6 4.9-3.6c2.2 0 23.9-21.6 27.8-27.7 1.9-2.8 3.8-5.4 4.4-5.8a42 42 0 0 0 4.6-6.3l5.5-8.4a10 10 0 0 0 1.9-4.3c0-.8 1-2.5 2.3-3.7a31 31 0 0 0 6.7-13.5c0-1.2.5-2.5 1-2.8 2.6-1.6 5.4-11.2 6.7-22.7.2-2.6 1.1-5.2 1.9-5.9 1.1-.9 1.4-4 1.4-13 0-10.8.2-12 2-13.1 2.4-1.5 3.1-18.2.8-19.1q-1.5-.3-.1-2.5c1-1.6.9-2.3-.2-3.2-1.9-1.5-1.9-4.9-.2-5.6s2.2-13 .7-13.9q-.9-.6.2-2.5c.9-1.4.9-2.2-.1-3.4s-1.1-1.9-.2-3q1.4-1.3-.4-2.6c-1.9-1.6-1.9-5.9 0-6.6 2.6-1 2.2-26.5-.5-28.2q-1.8-1.2-2-2.2c0-.6.9-1.8 2-2.7 2.2-1.9 3.1-19.3 1-19.3-.5 0-1-1.1-1-2.4 0-1.4.5-2.8 1-3.1 2-1.2 1.2-12.9-1-14.3-1.9-1.2-2-2.3-2-26.1 0-15.8-.4-25.2-1-25.6s-1.7-2.2-2.5-4.1-1.8-3.4-2.4-3.4-1.4-1.5-2-3.3q-1.1-3.2-5.8-6.1a42 42 0 0 1-6.6-4.8c-1-1-2.8-1.8-4.1-1.8s-3.7-.7-5.2-1.5a22 22 0 0 0-15.4 0"/></g></svg>',dd=ld;const ud={display:"flex",alignItems:"center",justifyContent:"center",gap:6,color:"var(--nfid-text-subtle)",fontFamily:"inherit",lineHeight:1},pd={display:"inline-flex",alignItems:"center",justifyContent:"center",color:"currentColor"},fd={fontSize:12,fontWeight:600,letterSpacing:.2,color:"var(--nfid-text-muted)"},hd={fontSize:9,fontWeight:400,color:"var(--nfid-text-subtle)",opacity:.75},md={fontSize:9,fontWeight:500,color:"var(--nfid-text-subtle)",opacity:.75};function gd({size:e=16,style:n}){return o.jsxs("div",{className:"neofaceid-brand-footer",style:{...ud,...n},children:[o.jsx("span",{"aria-hidden":"true",style:{...pd,width:e,height:e},dangerouslySetInnerHTML:{__html:dd}}),o.jsx("span",{style:fd,children:"NeoFaceID"}),o.jsx("span",{style:hd,children:"by"}),o.jsx("span",{style:md,children:"Octa"})]})}function vd(e=16){return`<div class="neofaceid-brand-footer" style="display:flex;align-items:center;justify-content:center;gap:6px;color:var(--nfid-text-subtle);font-family:inherit;line-height:1;"><span aria-hidden="true" style="${`display:inline-flex;align-items:center;justify-content:center;color:currentColor;width:${e}px;height:${e}px;`}">${dd}</span><span style="font-size:12px;font-weight:600;letter-spacing:0.2px;color:var(--nfid-text-muted);">NeoFaceID</span><span style="font-size:9px;font-weight:400;color:var(--nfid-text-subtle);opacity:0.75;">by</span><span style="font-size:9px;font-weight:500;color:var(--nfid-text-subtle);opacity:0.75;">Octa</span></div>`}class wd{constructor(e){l(this,"applicationToken"),l(this,"modalElement",null),this.applicationToken=e}open(){this.modalElement||(al(),this.addStyles(),this.modalElement=document.createElement("div"),this.modalElement.className="neofaceid-root neoface-forgot-modal",this.renderEmailForm(),document.body.appendChild(this.modalElement))}close(){this.modalElement&&document.body.contains(this.modalElement)&&(document.body.removeChild(this.modalElement),this.modalElement=null)}renderEmailForm(){if(!this.modalElement)return;this.modalElement.innerHTML=`\n <div class="neoface-forgot-overlay">\n <div class="neoface-forgot-content">\n <div class="neoface-forgot-icon">\n <svg viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="32" cy="32" r="28" stroke="#0059C4" stroke-width="3" fill="none"/>\n <rect x="22" y="28" width="20" height="16" rx="3" stroke="#0059C4" stroke-width="2.5" fill="none"/>\n <path d="M26 28v-4a6 6 0 0 1 12 0v4" stroke="#0059C4" stroke-width="2.5" stroke-linecap="round"/>\n <circle cx="32" cy="36" r="2" fill="#0059C4"/>\n </svg>\n </div>\n\n <h2 class="neoface-forgot-title">Recuperar senha</h2>\n <p class="neoface-forgot-subtitle">Informe seu email e enviaremos um link para redefinir sua senha.</p>\n\n <div id="neoface-forgot-error" class="neoface-forgot-error" style="display:none"></div>\n\n <form id="neoface-forgot-form">\n <input\n type="email"\n id="neoface-forgot-email"\n class="neoface-forgot-input"\n placeholder="seu@email.com"\n autocomplete="email"\n required\n />\n <button type="submit" class="neoface-forgot-btn-primary">\n Enviar link\n </button>\n </form>\n\n <button class="neoface-forgot-btn-ghost neoface-forgot-back">\n Voltar\n </button>\n\n <div class="neoface-forgot-branding">\n ${vd()}\n </div>\n </div>\n </div>\n `;this.modalElement.querySelector("#neoface-forgot-form").addEventListener("submit",this.handleSubmit.bind(this));this.modalElement.querySelector(".neoface-forgot-back").addEventListener("click",this.close.bind(this))}renderSuccess(){if(!this.modalElement)return;const e=this.modalElement.querySelector(".neoface-forgot-content");e.innerHTML=`\n <div class="neoface-forgot-success-icon">\n <svg viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="32" cy="32" r="28" stroke="#0E9F6E" stroke-width="3" fill="none"/>\n <path d="M20 32 L28 40 L44 24" stroke="#0E9F6E" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>\n </div>\n\n <h2 class="neoface-forgot-title">Email enviado!</h2>\n <p class="neoface-forgot-subtitle">\n Verifique sua caixa de entrada e siga as instruções para redefinir sua senha.\n <br/><br/>\n <span style="color: rgba(255,255,255,0.5); font-size: 13px;">Não recebeu? Verifique também sua pasta de spam.</span>\n </p>\n\n <button class="neoface-forgot-btn-primary neoface-forgot-close-success" style="margin-top: 8px;">\n Fechar\n </button>\n\n <div class="neoface-forgot-branding">\n ${vd()}\n </div>\n `;e.querySelector(".neoface-forgot-close-success").addEventListener("click",this.close.bind(this))}async handleSubmit(e){var n,t,o,r;e.preventDefault();const a=null==(n=this.modalElement)?void 0:n.querySelector("#neoface-forgot-email"),i=null==(t=this.modalElement)?void 0:t.querySelector(".neoface-forgot-btn-primary"),s=null==(o=this.modalElement)?void 0:o.querySelector("#neoface-forgot-error"),c=null==(r=null==a?void 0:a.value)?void 0:r.trim();if(c){i.disabled=!0,i.textContent="Enviando...",s.style.display="none";try{await Yl(c,this.applicationToken),this.renderSuccess()}catch(l){i.disabled=!1,i.textContent="Enviar link",s.style.display="block",s.textContent=l instanceof io?l.message:"Erro ao enviar email. Tente novamente."}}}addStyles(){const e="neoface-forgot-password-modal-styles";document.getElementById(e)||il(e,"\n .neoface-forgot-modal {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 10003;\n font-family: inherit;\n }\n\n .neoface-forgot-overlay {\n position: absolute;\n inset: 0;\n background: rgba(0, 0, 0, 0.65);\n backdrop-filter: blur(8px);\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 20px;\n animation: neoface-forgot-fadeIn 0.3s ease-out;\n }\n\n @keyframes neoface-forgot-fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n\n @keyframes neoface-forgot-slideUp {\n from { opacity: 0; transform: translateY(20px); }\n to { opacity: 1; transform: translateY(0); }\n }\n\n .neoface-forgot-content {\n background: linear-gradient(135deg, #0A1320 0%, #111C2B 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: neoface-forgot-slideUp 0.4s ease-out;\n text-align: center;\n }\n\n .neoface-forgot-icon {\n width: 64px;\n height: 64px;\n margin: 0 auto 20px;\n }\n\n .neoface-forgot-success-icon {\n width: 64px;\n height: 64px;\n margin: 0 auto 20px;\n animation: neoface-forgot-scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);\n }\n\n @keyframes neoface-forgot-scaleIn {\n 0% { transform: scale(0); opacity: 0; }\n 50% { transform: scale(1.1); }\n 100% { transform: scale(1); opacity: 1; }\n }\n\n .neoface-forgot-title {\n font-size: 22px;\n font-weight: 700;\n color: white;\n margin: 0 0 10px 0;\n }\n\n .neoface-forgot-subtitle {\n font-size: 15px;\n color: rgba(255, 255, 255, 0.7);\n margin: 0 0 24px 0;\n line-height: 1.5;\n }\n\n .neoface-forgot-error {\n background: rgba(239, 68, 68, 0.15);\n border: 1px solid rgba(239, 68, 68, 0.4);\n color: #fca5a5;\n border-radius: 10px;\n padding: 10px 14px;\n font-size: 14px;\n margin-bottom: 16px;\n text-align: left;\n }\n\n #neoface-forgot-form {\n display: flex;\n flex-direction: column;\n gap: 14px;\n margin-bottom: 12px;\n }\n\n .neoface-forgot-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.08);\n color: white;\n font-family: inherit;\n transition: all 0.2s;\n box-sizing: border-box;\n }\n\n .neoface-forgot-input::placeholder {\n color: rgba(255, 255, 255, 0.4);\n }\n\n .neoface-forgot-input:focus {\n outline: none;\n border-color: #0059C4;\n box-shadow: 0 0 0 3px rgba(0, 89, 196, 0.2);\n background: rgba(255, 255, 255, 0.12);\n }\n\n .neoface-forgot-btn-primary {\n width: 100%;\n padding: 14px 24px;\n border-radius: 12px;\n border: none;\n background: linear-gradient(135deg, #0059C4 0%, #00449A 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(0, 89, 196, 0.3);\n font-family: inherit;\n }\n\n .neoface-forgot-btn-primary:hover:not(:disabled) {\n transform: translateY(-2px);\n box-shadow: 0 8px 24px rgba(0, 89, 196, 0.4);\n }\n\n .neoface-forgot-btn-primary:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n }\n\n .neoface-forgot-btn-ghost {\n background: transparent;\n border: none;\n color: rgba(255, 255, 255, 0.5);\n font-size: 14px;\n font-weight: 500;\n cursor: pointer;\n padding: 10px 16px;\n border-radius: 8px;\n transition: all 0.2s;\n font-family: inherit;\n width: 100%;\n }\n\n .neoface-forgot-btn-ghost:hover {\n color: white;\n background: rgba(255, 255, 255, 0.05);\n }\n\n .neoface-forgot-branding {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n margin-top: 20px;\n color: rgba(255, 255, 255, 0.3);\n font-size: 12px;\n }\n\n .neoface-forgot-brand-logo {\n width: 18px;\n height: 18px;\n object-fit: contain;\n opacity: 0.5;\n }\n\n .neoface-forgot-brand-name {\n font-weight: 700;\n letter-spacing: 0.05em;\n }\n\n @media (max-width: 640px) {\n .neoface-forgot-content {\n padding: 24px;\n border-radius: 16px;\n }\n\n .neoface-forgot-title {\n font-size: 20px;\n }\n }\n ")}}const bd=(e,n)=>{switch(n.type){case"START_LIVENESS":return{status:"liveness",step:n.stepSequence[0],capturedPhotos:[],stepSequence:n.stepSequence,currentStepIndex:0,stepProgress:0};case"NEXT_STEP":if("liveness"===e.status){const t=n.photo?[...e.capturedPhotos,n.photo]:e.capturedPhotos;return{status:"liveness",step:n.step,capturedPhotos:t,stepSequence:e.stepSequence,currentStepIndex:e.currentStepIndex+1,stepProgress:0}}return e;case"UPDATE_PROGRESS":return"liveness"===e.status?{...e,stepProgress:n.progress}:e;case"CAMERA_LOADING":return{status:"camera-loading"};case"SUCCESS":return{status:"success"};case"DUPLICATE":return{status:"duplicate",personName:n.personName};case"ERROR":return{status:"error",message:n.message,retryable:n.retryable??!0};case"RESET":return yd();default:return e}},xd={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..."},yd=()=>{const e=(()=>{const e=["up","down","left","right"];for(let n=e.length-1;n>0;n--){const t=Math.floor(Math.random()*(n+1));[e[n],e[t]]=[e[t],e[n]]}return["center",...e,"complete"]})();return{status:"liveness",step:e[0],capturedPhotos:[],stepSequence:e,currentStepIndex:0,stepProgress:0}},_d=8,kd=10,Ed=26,Td=8,Nd=-8,Sd=15,Cd=-15,Id=1500,Rd=150,Od=.35,jd=.65,Ad=.18,Pd=.22,Fd=2e4;function zd({personData:e,applicationToken:t,onClose:r,onSuccess:a,onPhotosCaptured:i,onError:s,onCannotGesture:c,autoLighting:l=!0}){const d=n.useRef(null),u=n.useRef(null),p=n.useRef(null),f=n.useRef(null),h=n.useRef(null),m=n.useRef(!1),g=n.useRef("center"),v=n.useRef(null),w=n.useRef(null),b=n.useRef(!1),x=n.useRef(null),[y,_]=n.useReducer(bd,void 0,yd),[k,E]=n.useState(!1),[T,N]=n.useState("ok"),[S,C]=n.useState(!1);n.useEffect((()=>{al()}),[]);const I=l&&("liveness"===y.status||"camera-loading"===y.status),{flashOn:R}=td(d,{enabled:I});n.useEffect((()=>{if("liveness"===y.status){const e=y.step;g.current!==e&&(g.current=e,m.current||(f.current&&(f.current=null),h.current&&(clearInterval(h.current),h.current=null),_({type:"UPDATE_PROGRESS",progress:0}))),x.current={stepSequence:y.stepSequence,currentStepIndex:y.currentStepIndex,capturedPhotos:y.capturedPhotos},w.current&&clearTimeout(w.current),"complete"!==y.step&&(w.current=window.setTimeout((()=>{_({type:"ERROR",message:"Tempo limite atingido para o movimento. Por favor, tente novamente em um ambiente bem iluminado.",retryable:!0})}),Fd))}}),[y.status,"liveness"===y.status&&y.step,"liveness"===y.status&&y.currentStepIndex]);const O=e=>{if(m.current||"complete"===g.current)return;const n=Date.now();e?f.current||(f.current=n,h.current&&clearInterval(h.current),h.current=window.setInterval((()=>{if(!f.current)return;const e=Date.now()-f.current,n=Math.min(e/Id*100,100);_({type:"UPDATE_PROGRESS",progress:n}),n>=100&&(clearInterval(h.current),h.current=null,j())}),50)):f.current&&(f.current=null,h.current&&(clearInterval(h.current),h.current=null),_({type:"UPDATE_PROGRESS",progress:0}))};n.useEffect((()=>{(async()=>{try{const e="/models",n=new Promise(((e,n)=>setTimeout((()=>n(new Error("Timeout ao carregar modelos"))),1e4)));await Promise.race([Promise.all([Et.tinyFaceDetector.loadFromUri(e),Et.faceLandmark68Net.loadFromUri(e)]),n])}catch(e){_({type:"ERROR",message:"Não foi possível carregar os modelos de IA. Verifique sua conexão e tente novamente.",retryable:!0})}})()}),[]),n.useEffect((()=>()=>{p.current&&(p.current.getTracks().forEach((e=>{e.stop()})),p.current=null),d.current&&(d.current.srcObject=null),v.current&&(clearTimeout(v.current),v.current=null),h.current&&(clearInterval(h.current),h.current=null),w.current&&(clearTimeout(w.current),w.current=null)}),[]),n.useEffect((()=>{let e=!0;return(async()=>{if("liveness"===y.status&&!p.current){b.current=!1,v.current&&(clearTimeout(v.current),v.current=null),v.current=window.setTimeout((()=>{e&&!1===b.current&&_({type:"ERROR",message:"A câmera não respondeu a tempo. Verifique se ela está disponível e tente novamente.",retryable:!0})}),2e4);try{const n=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"}});if(!e)return void n.getTracks().forEach((e=>e.stop()));const t=async()=>{let e=0;for(;!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,p.current=n,o.onloadedmetadata=()=>{o.play().then((()=>{e&&C(!0)}))}}catch(n){if(!e)return;v.current&&(clearTimeout(v.current),v.current=null);let t=n instanceof Error?n.message:"Erro ao acessar câmera";n instanceof DOMException&&("NotAllowedError"===n.name||"PermissionDeniedError"===n.name?t="Permissão de câmera negada. Permita o acesso à câmera nas configurações do navegador e tente novamente.":"NotFoundError"===n.name||"DevicesNotFoundError"===n.name?t="Nenhuma câmera encontrada. Conecte uma câmera e tente novamente.":"NotReadableError"===n.name&&(t="A câmera está sendo usada por outro programa. Feche-o e tente novamente.")),_({type:"ERROR",message:t,retryable:!0})}}})(),()=>{e=!1,v.current&&(clearTimeout(v.current),v.current=null),p.current&&(p.current.getTracks().forEach((e=>e.stop())),p.current=null),h.current&&(clearInterval(h.current),h.current=null),f.current=null}}),[y.status]),n.useEffect((()=>{if("liveness"!==y.status||!d.current)return;let e=!0,n=0;const t=async()=>{if(!e||"liveness"!==y.status)return;if(m.current||"complete"===g.current)return void requestAnimationFrame(t);const o=Date.now();if(o-n<Rd)requestAnimationFrame(t);else{n=o;try{const n=await Jt(d.current,new vt({inputSize:224,scoreThreshold:.35})).withFaceLandmarks();if(!e)return;const o=!!n;if(E(o),o&&n.detection){const e=(e=>{if(!e||!d.current)return"not-detected";const{box:n}=e.detection,t=d.current.videoWidth||640,o=d.current.videoHeight||480,r=n.width/t;if(r<Od)return"too-far";if(r>jd)return"too-close";const a=n.x+n.width/2,i=n.y+n.height/2,s=Math.abs(a-t/2)/t,c=Math.abs(i-o/2)/o;return s>Ad||c>Pd?"not-centered":"ok"})(n);if("not-detected"!==e&&N(e),"ok"!==e)return O(!1),void requestAnimationFrame(t)}if(o&&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),r=t(8),a=t(36),i=t(45),s=(a.x+i.x)/2,c=(o.x-s)/Math.abs(i.x-a.x)*90,l=(a.y+i.y)/2,d=o.y-l,u=-d/Math.abs(r.y-l)*90+Ed;return{pitch:Math.round(u),yaw:Math.round(c)}}catch(n){return null}})(n.landmarks);if(e){const n=((e,n,t)=>{switch(t){case"center":return Math.abs(e)<_d&&Math.abs(n)<kd;case"up":return e>Td;case"down":return e<Nd;case"left":return n>Sd;case"right":return n<Cd;default:return!1}})(e.pitch,e.yaw,g.current);O(n)}}else f.current&&(f.current=null,h.current&&(clearInterval(h.current),h.current=null),_({type:"UPDATE_PROGRESS",progress:0}))}catch(r){}e&&"liveness"===y.status&&requestAnimationFrame(t)}},o=()=>{e&&d.current&&(b.current=!0,v.current&&(clearTimeout(v.current),v.current=null),t())},r=d.current;if(r&&r.readyState>=2){const n=setTimeout(o,200);return()=>{e=!1,clearTimeout(n),h.current&&(clearInterval(h.current),h.current=null),f.current=null}}const a=()=>{e&&o()};let i=0;const s=window.setInterval((()=>{i++,e?d.current&&d.current.readyState>=2?(clearInterval(s),d.current.removeEventListener("canplay",a),o()):i>=50&&clearInterval(s):clearInterval(s)}),300);return null==r||r.addEventListener("canplay",a,{once:!0}),()=>{e=!1,clearInterval(s),null==r||r.removeEventListener("canplay",a),h.current&&(clearInterval(h.current),h.current=null),f.current=null}}),[y.status]);const j=async()=>{if(!d.current||!u.current||m.current)return;m.current=!0,f.current=null;const e=x.current;if(!e)return void(m.current=!1);const n=u.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(m.current=!1);const t=e.currentStepIndex+1,o=e.stepSequence[t];if("complete"===o){const t=[...e.capturedPhotos,n];_({type:"START_PROCESSING"}),A(t)}else setTimeout((()=>{m.current=!1,_({type:"NEXT_STEP",step:o,photo:n})}),100)}),"image/jpeg",.85)):m.current=!1},A=async n=>{var o;try{if(_({type:"START_PROCESSING"}),t&&n.length>0)try{const{identifyPersonAsync:e}=await Promise.resolve().then((()=>ed)),r=new Promise((e=>setTimeout((()=>e(null)),5e3))),a=await Promise.race([e(n[0],t,{maxRetries:3,interval:1e3}),r]);if(a&&a.personFound)return void _({type:"DUPLICATE",personName:(null==(o=a.person)?void 0:o.name)||"Pessoa identificada"})}catch(r){}if(i)return _({type:"SUCCESS"}),i(n),void(n.length=0);if(!e||!t)throw new Error("Dados de registro não fornecidos");const s=await Dl(e,n,t),c={success:s.success,message:s.message,person_id:s.person_id,user_id:s.user_id,person_validated:s.person_validated,face_processing:s.face_processing,onboarding_link:s.onboarding_link};_({type:"SUCCESS"}),a&&(a(c),n.length=0)}catch(c){const e=c instanceof Error?c.message:"Erro desconhecido";_({type:"ERROR",message:e}),s(e)}};return o.jsxs(o.Fragment,{children:[o.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, #0A1320 0%, #111C2B 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: #0059C4;\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, #0059C4 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: #0E9F6E;\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, #0059C4 0%, #00449A 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(0, 89, 196, 0.3);\n }\n\n .primary-button:hover {\n transform: translateY(-2px);\n box-shadow: 0 8px 24px rgba(0, 89, 196, 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: inherit;\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 /* Removida transição 'all' para evitar salto de zoom no início */\n box-shadow: 0 0 0 4px rgba(0, 89, 196, 0.3);\n background: #000;\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 opacity: 0;\n transition: opacity 0.4s ease;\n }\n\n .video-feed.ready {\n opacity: 1;\n }\n\n .face-badge {\n display: none; /* Removido por ser redundante com o oval verde */\n }\n\n .status-badge {\n position: absolute;\n top: 72px; /* Logo abaixo do progress-indicator */\n left: 50%;\n transform: translateX(-50%);\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(0, 0, 0, 0.2);\n animation: slideDown 0.3s ease-out;\n z-index: 10;\n white-space: nowrap;\n }\n\n .status-badge.info {\n background: rgba(255, 255, 255, 0.15);\n color: white;\n border-color: rgba(255, 255, 255, 0.1);\n }\n\n .status-badge.warning {\n background: rgba(251, 191, 36, 0.95);\n color: #78350f;\n border-color: rgba(0, 0, 0, 0.1);\n box-shadow: 0 4px 15px rgba(251, 191, 36, 0.2);\n }\n\n .status-badge.error {\n background: rgba(239, 68, 68, 0.95);\n color: white;\n border-color: rgba(255, 255, 255, 0.2);\n box-shadow: 0 4px 15px rgba(239, 68, 68, 0.2);\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, #0059C4 0%, #0E9F6E 100%);\n border-radius: 2px;\n transition: width 0.05s linear;\n }\n\n /* NEO-410 · US14.3 — botão \"Não consigo fazer esse movimento\" */\n .cannot-gesture-button {\n margin-top: 16px;\n min-height: 44px;\n min-width: 44px;\n padding: 10px 20px;\n background: transparent;\n border: 1px solid rgba(255, 255, 255, 0.28);\n border-radius: 22px;\n color: rgba(255, 255, 255, 0.85);\n font-size: 14px;\n font-weight: 500;\n font-family: inherit;\n cursor: pointer;\n transition: background 120ms ease-out, border-color 120ms ease-out;\n }\n .cannot-gesture-button:hover {\n background: rgba(255, 255, 255, 0.08);\n border-color: rgba(255, 255, 255, 0.42);\n }\n .cannot-gesture-button:focus-visible {\n outline: 2px solid #0059C4;\n outline-offset: 2px;\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(0, 89, 196, 0.2);\n border-top-color: #0059C4;\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(0, 89, 196, 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: #0E9F6E;\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 /* Duplicate Screen Styles */\n .profile-icon-wrapper {\n position: relative;\n display: inline-block;\n margin-bottom: 24px;\n }\n\n .profile-main-icon {\n background: rgba(0, 89, 196, 0.1);\n color: #0059C4;\n padding: 20px;\n border-radius: 50%;\n border: 2px solid rgba(0, 89, 196, 0.2);\n box-shadow: 0 0 30px rgba(0, 89, 196, 0.2);\n }\n\n .profile-main-icon svg {\n width: 48px;\n height: 48px;\n }\n\n .verified-badge {\n position: absolute;\n bottom: -4px;\n right: -4px;\n background: #0E9F6E;\n border-radius: 50%;\n padding: 4px;\n border: 3px solid #111C2B;\n width: 24px;\n height: 24px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .button-group-vertical {\n display: flex;\n flex-direction: column;\n width: 100%;\n gap: 8px;\n }\n\n .support-section {\n margin-top: 24px;\n padding-top: 16px;\n border-top: 1px solid rgba(255, 255, 255, 0.05);\n }\n\n .support-section p {\n font-size: 13px;\n color: rgba(255, 255, 255, 0.4);\n margin-bottom: 8px;\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 "}),o.jsx(od,{active:R}),o.jsx("div",{className:"neofaceid-root modal-overlay",children:o.jsxs("div",{className:"modal-content",children:[o.jsx("button",{type:"button",className:"close-button",onClick:r,children:"×"}),"liveness"===y.status&&(()=>{if("liveness"!==y.status)return null;const e=`${y.currentStepIndex+1}/${y.stepSequence.length-1}`,{stepProgress:n}=y;return o.jsxs("div",{className:"liveness-container",children:[o.jsx("div",{className:"progress-indicator",children:o.jsx("span",{className:"progress-text",children:e})}),k&&"ok"!==T&&o.jsxs("div",{className:"status-badge "+("not-centered"===T?"warning":"error"),children:["too-far"===T&&"Aproxime-se mais","too-close"===T&&"Afaste-se um pouco","not-centered"===T&&"Centralize seu rosto"]}),o.jsx("div",{className:"video-wrapper",children:o.jsx("div",{className:`video-circle ${k&&"ok"===T?"face-detected":""} ${n>0?"capturing":""}`,children:o.jsx("video",{ref:d,className:"video-feed "+(S?"ready":""),autoPlay:!0,muted:!0,playsInline:!0})})}),o.jsxs("div",{className:"instruction-box",children:[o.jsx("p",{className:"instruction-text","aria-live":"assertive",children:xd[y.step]}),n>0&&o.jsx("div",{className:"progress-bar",children:o.jsx("div",{className:"progress-fill",style:{width:`${n}%`}})})]}),o.jsx("button",{type:"button",className:"cannot-gesture-button",onClick:()=>{c?c():r()},"aria-label":"Não consigo fazer esse movimento — buscar alternativa",children:"Não consigo fazer esse movimento"}),o.jsx("div",{className:"branding-small",children:o.jsx(gd,{})})]})})(),"camera-loading"===y.status&&o.jsxs("div",{className:"processing-container",children:[o.jsxs("div",{className:"spinner-wrapper",children:[o.jsx("div",{className:"spinner"}),o.jsx("div",{className:"spinner-ring"})]}),o.jsx("h3",{children:"Inicializando câmera"}),o.jsx("p",{children:"Aguarde enquanto preparamos a câmera..."}),o.jsx("div",{className:"branding",style:{marginTop:"40px",paddingTop:"24px",borderTop:"1px solid rgba(255, 255, 255, 0.1)"},children:o.jsx(gd,{})})]}),"processing"===y.status&&o.jsxs("div",{className:"processing-container",children:[o.jsxs("div",{className:"spinner-wrapper",children:[o.jsx("div",{className:"spinner"}),o.jsx("div",{className:"spinner-ring"})]}),o.jsx("h3",{children:"Processando biometria"}),o.jsx("p",{children:"Analisando suas capturas faciais..."}),o.jsx("div",{className:"branding",style:{marginTop:"40px",paddingTop:"24px",borderTop:"1px solid rgba(255, 255, 255, 0.1)"},children:o.jsx(gd,{})})]}),"error"===y.status&&("error"!==y.status?null:o.jsxs("div",{className:"result-container error",children:[o.jsx("div",{className:"result-icon error-icon",children:o.jsxs("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",children:[o.jsx("circle",{cx:"30",cy:"30",r:"28",stroke:"currentColor",strokeWidth:"3"}),o.jsx("path",{d:"M20 20 L40 40 M40 20 L20 40",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}),o.jsx("h3",{children:"Não foi possível processar"}),o.jsx("p",{children:y.message}),o.jsxs("div",{className:"button-group",children:[y.retryable&&o.jsx("button",{type:"button",className:"secondary-button",onClick:()=>_({type:"RESET"}),children:"Tentar Novamente"}),o.jsx("button",{type:"button",className:"ghost-button",onClick:r,children:"Cancelar"})]})]})),"success"===y.status&&o.jsxs("div",{className:"result-container success",children:[o.jsx("div",{className:"result-icon success-icon",children:o.jsxs("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",children:[o.jsx("circle",{cx:"30",cy:"30",r:"28",stroke:"currentColor",strokeWidth:"3"}),o.jsx("path",{d:"M15 30 L25 40 L45 20",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"})]})}),o.jsx("h3",{children:i?"Captura concluída!":"Verificação concluída!"}),o.jsx("p",{children:i?"Suas capturas faciais foram realizadas":"Sua biometria foi registrada com sucesso"}),o.jsx("button",{type:"button",className:"primary-button",onClick:r,children:"Continuar"})]}),"duplicate"===y.status&&(()=>{if("duplicate"!==y.status)return null;const e=y.personName&&"Pessoa identificada"!==y.personName?`Olá, ${y.personName.split(" ")[0]}!`:"Olá!";return o.jsxs("div",{className:"result-container duplicate scale-in",children:[o.jsx("h3",{style:{marginTop:"0px"},children:e}),o.jsx("p",{style:{marginBottom:"32px",fontSize:"15px"},children:"Identificamos seu cadastro biométrico em nossa rede. Você já faz parte da NeoFaceId!"}),o.jsxs("div",{className:"button-group-vertical",children:[o.jsx("button",{type:"button",className:"primary-button",onClick:()=>{r(),window.location.href="/"},children:"Ir para o Login"}),o.jsx("button",{type:"button",className:"secondary-button",style:{marginTop:"12px"},onClick:()=>{r(),new wd(t??"").open()},children:"Esqueci minha senha"}),o.jsxs("div",{className:"support-section",children:[o.jsx("p",{children:"Não reconhece esta conta?"}),o.jsx("button",{type:"button",className:"ghost-button",onClick:()=>window.open("https://support.neofaceid.com","_blank"),children:"Falar com Suporte"})]})]}),o.jsx("div",{className:"branding",style:{marginTop:"32px",paddingTop:"20px",borderTop:"1px solid rgba(255, 255, 255, 0.08)",width:"100%"},children:o.jsx(gd,{})})]})})()]})}),o.jsx("canvas",{ref:u})]})}const $d="2.1.2",Dd="neoface_consent_trail_v1";function Md(){try{if("undefined"==typeof window||!window.localStorage)return[];const e=window.localStorage.getItem(Dd);if(!e)return[];const n=JSON.parse(e);return Array.isArray(n)?n:[]}catch{return[]}}async function Ld(e){try{const n=bl(),t=(null==e?void 0:e.purpose)??n.purpose??"authentication",o=(null==e?void 0:e.legalBasis)??n.legalBasis??"fraud_prevention",r=(new Date).toISOString(),a="undefined"!=typeof navigator?navigator.userAgent:"",i=$d,s={hash:await async function(e){try{if("undefined"!=typeof crypto&&crypto.subtle&&"function"==typeof crypto.subtle.digest){const n=new TextEncoder,t=await crypto.subtle.digest("SHA-256",n.encode(e));return Array.from(new Uint8Array(t)).map((e=>e.toString(16).padStart(2,"0"))).join("")}}catch{}return"sha256-unavailable"}(`${a}${t}${r}`),timestamp:r,purpose:t,legalBasis:o,sdkVersion:i},c=Md();c.push(s);const l=c.slice(-100);return"undefined"!=typeof window&&window.localStorage&&window.localStorage.setItem(Dd,JSON.stringify(l)),s}catch{return null}}const Bd="https://neofaceid.com/privacidade",Wd={verification:{title:"Vamos confirmar que é você",duration:"Leva cerca de 20 segundos e usa a câmera do seu dispositivo.",bullet1Title:"Sua câmera liga agora",bullet1Body:"Você vê a imagem o tempo todo e pode encerrar quando quiser.",bullet2Title:"Pediremos dois movimentos simples",bullet2Body:"Virar o rosto ou piscar — é assim que sabemos que há alguém ali.",primary:"Começar verificação"},registration:{title:"Vamos cadastrar seu rosto",duration:"Leva cerca de 20 segundos e usa a câmera do seu dispositivo.",bullet1Title:"Sua câmera liga agora",bullet1Body:"Você vê a imagem o tempo todo e pode encerrar quando quiser.",bullet2Title:"Pediremos dois movimentos simples",bullet2Body:"Virar o rosto ou piscar — é assim que sabemos que há alguém ali.",primary:"Começar cadastro"}},qd=e=>1===e?"dia":"dias";const Ud=()=>o.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3Z"}),o.jsx("circle",{cx:"12",cy:"13",r:"4"})]}),Vd=()=>o.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("circle",{cx:"12",cy:"12",r:"9"}),o.jsx("path",{d:"M4 12h16"}),o.jsx("path",{d:"M15 8l4 4-4 4"})]}),Kd=()=>o.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("path",{d:"M12 2 4 5v7c0 5 3.5 8.5 8 10 4.5-1.5 8-5 8-10V5l-8-3Z"}),o.jsx("path",{d:"m9 12 2 2 4-4"})]});function Zd({appName:e,flow:n,privacyPolicyUrl:t=Bd,retentionDays:r=90,onAccept:a,onDecline:i}){const s=Wd[n],c=function(e,n){const t=Number.isFinite(n)&&n>0;return"registration"===e?{title:"Guardamos um vetor matemático do seu rosto",body:t?`Não a foto. A imagem fica guardada por até ${n} ${qd(n)} e é apagada no fim desse prazo.`:"Não a foto. O prazo de guarda da imagem está na política de privacidade."}:t?{title:`A imagem fica guardada por até ${n} ${qd(n)}`,body:"Ela é usada para a verificação e apagada no fim desse prazo."}:{title:"A imagem é tratada conforme a política de privacidade",body:"Ela é usada para a verificação; o prazo de guarda está descrito lá."}}(n,r),l=Number.isFinite(r)&&r>0;return o.jsxs(o.Fragment,{children:[o.jsx("style",{children:"\n @keyframes neofaceidConsentFadeIn { from { opacity: 0 } to { opacity: 1 } }\n @keyframes neofaceidConsentSlideUp {\n from { opacity: 0; transform: translateY(12px) }\n to { opacity: 1; transform: translateY(0) }\n }\n .neofaceid-consent-overlay {\n position: fixed; inset: 0;\n background: var(--nfid-overlay);\n backdrop-filter: blur(3px);\n -webkit-backdrop-filter: blur(3px);\n display: flex; align-items: center; justify-content: center;\n z-index: 10001; padding: 20px;\n animation: neofaceidConsentFadeIn 200ms ease-out;\n font-family: inherit;\n color: var(--nfid-text);\n }\n .neofaceid-consent-modal {\n background: var(--nfid-surface);\n border-radius: var(--nfid-radius, 16px);\n padding: 28px;\n max-width: 440px;\n width: 100%;\n box-shadow: 0 1px 3px rgba(10, 19, 32, 0.08);\n animation: neofaceidConsentSlideUp 320ms cubic-bezier(.2,0,0,1);\n box-sizing: border-box;\n }\n .neofaceid-consent-header {\n display: flex;\n align-items: baseline;\n gap: 10px;\n margin-bottom: 20px;\n }\n .neofaceid-consent-appname {\n font-size: 17px;\n font-weight: 700;\n color: var(--nfid-text);\n line-height: 1.2;\n }\n .neofaceid-consent-brand-caption {\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.09em;\n text-transform: uppercase;\n color: var(--nfid-text-subtle);\n }\n .neofaceid-consent-title {\n font-size: 22px;\n font-weight: 700;\n color: var(--nfid-text);\n margin: 0 0 8px;\n line-height: 1.25;\n letter-spacing: -0.015em;\n }\n .neofaceid-consent-duration {\n font-size: 14px;\n color: var(--nfid-text-muted);\n margin: 0 0 20px;\n line-height: 1.5;\n }\n .neofaceid-consent-bullets {\n display: flex;\n flex-direction: column;\n gap: 14px;\n margin-bottom: 20px;\n }\n .neofaceid-consent-bullet {\n display: flex;\n gap: 12px;\n align-items: flex-start;\n }\n .neofaceid-consent-bullet-icon {\n flex-shrink: 0;\n color: var(--nfid-action);\n margin-top: 2px;\n }\n .neofaceid-consent-bullet-title {\n font-size: 14px;\n font-weight: 600;\n color: var(--nfid-text);\n margin: 0 0 2px;\n line-height: 1.35;\n }\n .neofaceid-consent-bullet-body {\n font-size: 13px;\n color: var(--nfid-text-muted);\n margin: 0;\n line-height: 1.45;\n }\n .neofaceid-consent-link {\n display: inline-block;\n font-size: 13px;\n color: var(--nfid-action);\n text-decoration: underline;\n margin-bottom: 20px;\n }\n .neofaceid-consent-link:hover { opacity: 0.85; }\n .neofaceid-consent-actions {\n display: flex;\n flex-direction: column;\n gap: 10px;\n }\n .neofaceid-consent-button {\n min-height: 44px;\n padding: 12px 20px;\n border-radius: var(--nfid-radius, 16px);\n border: none;\n font-size: 15px;\n font-weight: 600;\n cursor: pointer;\n transition: background 120ms ease-out, transform 120ms ease-out;\n font-family: inherit;\n }\n .neofaceid-consent-button-primary {\n background: var(--nfid-action);\n color: var(--nfid-action-text);\n }\n .neofaceid-consent-button-primary:hover { opacity: 0.92; }\n .neofaceid-consent-button-primary:focus-visible {\n outline: 2px solid var(--nfid-focus-ring);\n outline-offset: 2px;\n }\n .neofaceid-consent-button-ghost {\n background: transparent;\n color: var(--nfid-text-muted);\n }\n .neofaceid-consent-button-ghost:hover { background: var(--nfid-surface-muted); }\n .neofaceid-consent-footer {\n display: flex;\n justify-content: center;\n margin-top: 20px;\n padding-top: 16px;\n border-top: 1px solid var(--nfid-line);\n }\n .neofaceid-consent-seal {\n font-size: 10px;\n font-weight: 500;\n letter-spacing: 0.06em;\n text-transform: uppercase;\n color: var(--nfid-text-subtle);\n }\n @media (max-width: 640px) {\n .neofaceid-consent-modal { padding: 22px; border-radius: 16px; }\n .neofaceid-consent-title { font-size: 20px; }\n }\n @media (prefers-reduced-motion: reduce) {\n .neofaceid-consent-overlay,\n .neofaceid-consent-modal { animation: none; }\n }\n "}),o.jsx("div",{className:"neofaceid-root neofaceid-consent-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"neofaceid-consent-title",children:o.jsxs("div",{className:"neofaceid-consent-modal",children:[o.jsxs("div",{className:"neofaceid-consent-header",children:[o.jsx("span",{className:"neofaceid-consent-appname",children:e}),o.jsx("span",{className:"neofaceid-consent-brand-caption",children:"NeoFaceID"})]}),o.jsx("h1",{id:"neofaceid-consent-title",className:"neofaceid-consent-title",children:s.title}),o.jsx("p",{className:"neofaceid-consent-duration",children:s.duration}),o.jsxs("div",{className:"neofaceid-consent-bullets",children:[o.jsxs("div",{className:"neofaceid-consent-bullet",children:[o.jsx("div",{className:"neofaceid-consent-bullet-icon",children:o.jsx(Ud,{})}),o.jsxs("div",{children:[o.jsx("p",{className:"neofaceid-consent-bullet-title",children:s.bullet1Title}),o.jsx("p",{className:"neofaceid-consent-bullet-body",children:s.bullet1Body})]})]}),o.jsxs("div",{className:"neofaceid-consent-bullet",children:[o.jsx("div",{className:"neofaceid-consent-bullet-icon",children:o.jsx(Vd,{})}),o.jsxs("div",{children:[o.jsx("p",{className:"neofaceid-consent-bullet-title",children:s.bullet2Title}),o.jsx("p",{className:"neofaceid-consent-bullet-body",children:s.bullet2Body})]})]}),o.jsxs("div",{className:"neofaceid-consent-bullet",children:[o.jsx("div",{className:"neofaceid-consent-bullet-icon",children:o.jsx(Kd,{})}),o.jsxs("div",{children:[o.jsx("p",{className:"neofaceid-consent-bullet-title",children:c.title}),o.jsx("p",{className:"neofaceid-consent-bullet-body",children:c.body})]})]})]}),o.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"neofaceid-consent-link",children:l?`Ver política de privacidade (retenção de até ${r} ${qd(r)})`:"Ver política de privacidade"}),o.jsxs("div",{className:"neofaceid-consent-actions",children:[o.jsx("button",{type:"button",className:"neofaceid-consent-button neofaceid-consent-button-primary",onClick:()=>{Ld().catch((()=>{})),a()},children:s.primary}),o.jsx("button",{type:"button",className:"neofaceid-consent-button neofaceid-consent-button-ghost",onClick:i,children:"Agora não"})]}),o.jsx("div",{className:"neofaceid-consent-footer",children:o.jsx(gd,{})})]})})]})}class Hd{constructor(){l(this,"container",null),l(this,"root",null)}show(e){this.container||(al(),this.container=document.createElement("div"),this.container.id="neofaceid-consent-modal-container",document.body.appendChild(this.container),this.root=t.createRoot(this.container),this.root.render(o.jsx(Zd,{...e,onAccept:()=>{this.close(),e.onAccept()},onDecline:()=>{this.close(),e.onDecline()}})))}close(){this.container&&document.body.contains(this.container)&&(this.root&&this.root.unmount(),document.body.removeChild(this.container),this.container=null,this.root=null)}}function Gd(e={}){const n=gl(),t=e.appName??n??"sua aplicação";e.appName;const o=e.flow??"verification";return new Promise((n=>{(new Hd).show({appName:t,flow:o,privacyPolicyUrl:e.privacyPolicyUrl??Bd,retentionDays:e.retentionDays??90,onAccept:()=>n(!0),onDecline:()=>n(!1)})}))}const Jd={flow:"verification",privacyPolicyUrl:Bd,retentionDays:90};function Xd({open:e,onDismiss:t,dismissOnOverlay:r=!0,ariaLabel:a,ariaLabelledBy:i,children:s,className:c,style:l}){if(n.useEffect((()=>{al()}),[]),!e)return null;return o.jsx("div",{className:"neofaceid-root",role:"presentation",style:{position:"fixed",inset:0,zIndex:10001,display:"flex",alignItems:"center",justifyContent:"center",padding:20,background:`var(${nl})`,backdropFilter:"blur(3px)",WebkitBackdropFilter:"blur(3px)"},onClick:()=>{r&&t&&t()},children:o.jsx("div",{role:"dialog","aria-modal":"true","aria-label":a,"aria-labelledby":i,className:c,onClick:e=>e.stopPropagation(),style:{background:`var(${Kc})`,color:`var(${Gc})`,borderRadius:`var(${ol}, 16px)`,padding:28,maxWidth:440,width:"100%",boxShadow:"0 1px 3px rgba(10,19,32,.08)",boxSizing:"border-box",...l},children:s})})}const Yd=new Set(["connected","heartbeat","processing"]),Qd=31e4,eu=5;function nu(e,n){return new Promise((t=>{const o=setTimeout(t,e);null==n||n.addEventListener("abort",(()=>{clearTimeout(o),t()}),{once:!0})}))}async function tu(e){const{requestTicket:n,buildUrl:t,classify:o,timeoutMs:r=Qd,maxReconnects:a=eu,signal:i,eventSourceFactory:s,onProgress:c}=e,l=s??(e=>{const n=globalThis.EventSource;if(!n)throw new io("EventSource indisponível neste ambiente",ao.INITIALIZATION_ERROR);return new n(e)}),d=Date.now();let u=0;for(;;){if(null==i?void 0:i.aborted)throw new io("Fluxo cancelado",ao.UNKNOWN);const e=r-(Date.now()-d);if(e<=0)throw new io("Tempo esgotado aguardando resposta",ao.NETWORK);const s=await n(),p=await new Promise(((n,r)=>{let a;try{a=l(t(s))}catch(h){return void r(h)}let d,u,p=!1;const f=()=>{void 0!==d&&clearTimeout(d),u&&(null==i||i.removeEventListener("abort",u)),a.close()};d=setTimeout((()=>{p||(p=!0,f(),r(new io("Tempo esgotado aguardando resposta",ao.NETWORK)))}),e),u=()=>{p||(p=!0,f(),r(new io("Fluxo cancelado",ao.UNKNOWN)))},null==i||i.addEventListener("abort",u,{once:!0}),a.onmessage=e=>{if(p)return;let t;try{t=JSON.parse(e.data)}catch{return}if(t.status&&Yd.has(t.status))return void(c&&c(t));const r=o(t);"pending"!==r.kind?(p=!0,f(),n({type:"settled",verdict:r})):c&&c(t)},a.onerror=()=>{p||(p=!0,f(),n({type:"transport"}))}}));if("settled"===p.type){const{verdict:e}=p;if("resolve"===e.kind)return e.value;throw e.error}if(u+=1,u>a)throw new io(`Conexão perdida após ${a} tentativas de reconexão`,ao.NETWORK);const f=Math.min(500*2**(u-1),8e3);await nu(f,i)}}const ou={minHeight:44,minWidth:44,padding:"12px 20px",borderRadius:16,border:"none",fontSize:15,fontWeight:600,fontFamily:"inherit",cursor:"pointer",transition:"background 120ms ease-out",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:8},ru=n.forwardRef((({variant:e="primary",style:n,type:t="button",...r},a)=>{const i="primary"===e?{background:`var(${Yc})`,color:`var(${Qc})`}:"secondary"===e?{background:`var(${Zc})`,color:`var(${Gc})`}:{background:"transparent",color:`var(${Jc})`};return o.jsx("button",{ref:a,type:t,...r,style:{...ou,...i,...n}})}));function au({tone:e,children:n,icon:t,className:r}){const a=Mc[e];return o.jsxs("span",{className:r,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"4px 10px",borderRadius:9999,background:a.bg,color:a.fg,fontSize:13,fontWeight:600,fontFamily:"inherit",lineHeight:1.3},children:[t,n]})}ru.displayName="Button";const iu="neofaceid-awaiting-push-styles",su="\n.neofaceid-root .nfid-push {\n display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;\n padding: 8px 8px 4px;\n}\n.neofaceid-root .nfid-push h2 {\n margin: 6px 0 0; font-size: 20px; font-weight: 700; color: var(--nfid-text); line-height: 1.25;\n letter-spacing: -0.015em;\n}\n.neofaceid-root .nfid-push p {\n margin: 0; font-size: 14px; color: var(--nfid-text-muted); line-height: 1.5;\n}\n.neofaceid-root .nfid-push-phone-icon {\n width: 56px; height: 56px; color: var(--nfid-action);\n}\n.neofaceid-root .nfid-push-code {\n display: flex; flex-direction: column; align-items: center; gap: 6px;\n margin-top: 14px; padding: 16px 28px;\n background: var(--nfid-surface-muted); border-radius: 16px; width: 100%;\n}\n.neofaceid-root .nfid-push-code-label {\n font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;\n color: var(--nfid-text-subtle);\n}\n.neofaceid-root .nfid-push-code-value {\n font-size: 52px; font-weight: 800; line-height: 1; letter-spacing: 0.08em;\n color: var(--nfid-text); font-variant-numeric: tabular-nums;\n}\n.neofaceid-root .nfid-push-countdown {\n font-size: 13px; color: var(--nfid-text-muted); font-variant-numeric: tabular-nums;\n margin-top: 12px;\n}\n.neofaceid-root .nfid-push-actions {\n display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 16px;\n}\n.neofaceid-root .nfid-push-footer {\n display: flex; justify-content: center; margin-top: 16px; padding-top: 12px;\n border-top: 1px solid var(--nfid-line);\n width: 100%;\n}\n.neofaceid-root .nfid-push-pulse {\n animation: nfidPushPulse 1.8s ease-in-out infinite;\n}\n@keyframes nfidPushPulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.45; }\n}\n@media (prefers-reduced-motion: reduce) {\n .neofaceid-root .nfid-push-pulse { animation: none; }\n}\n";function cu(e){const n=Math.max(0,e);return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function lu({appName:e,numericCode:t,remainingSeconds:r,onCancel:a}){return n.useEffect((()=>{al(),il(iu,su)}),[]),o.jsxs("div",{className:"nfid-push",role:"status","aria-live":"polite",children:[o.jsx(au,{tone:"attention",children:"Aguardando confirmação"}),o.jsxs("svg",{className:"nfid-push-phone-icon nfid-push-pulse",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("rect",{x:"6",y:"2",width:"12",height:"20",rx:"3"}),o.jsx("path",{d:"M11 18h2"})]}),o.jsx("h2",{children:"Confirme no seu celular"}),o.jsxs("p",{children:["Enviamos um pedido de confirmação para o seu aparelho. Abra o NeoFaceID Push e confirme com o seu rosto para continuar no ",e,"."]}),t&&o.jsxs("div",{className:"nfid-push-code",children:[o.jsx("span",{className:"nfid-push-code-label",children:"Digite este número no celular"}),o.jsx("span",{className:"nfid-push-code-value","aria-label":`Código de confirmação: ${t.split("").join(" ")}`,children:t})]}),o.jsxs("p",{className:"nfid-push-countdown",children:["Expira em ",cu(r)]}),o.jsx("div",{className:"nfid-push-actions",children:o.jsx(ru,{variant:"ghost",onClick:a,children:"Cancelar"})}),o.jsx("div",{className:"nfid-push-footer",children:o.jsx(gd,{})})]})}function du({onFallback:e,onCancel:t}){return n.useEffect((()=>{al(),il(iu,su)}),[]),o.jsxs("div",{className:"nfid-push",role:"alert","aria-live":"assertive",children:[o.jsxs("svg",{className:"nfid-push-phone-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{color:"var(--nfid-text-muted)"},children:[o.jsx("circle",{cx:"12",cy:"12",r:"9"}),o.jsx("path",{d:"M12 7v5l3 2"})]}),o.jsx("h2",{children:"O tempo esgotou"}),o.jsx("p",{children:"Não recebemos a confirmação do seu celular a tempo."}),o.jsx("div",{className:"nfid-push-actions",children:e?o.jsxs(o.Fragment,{children:[o.jsx(ru,{variant:"primary",onClick:e,children:"Entrar de outro jeito"}),o.jsx(ru,{variant:"ghost",onClick:t,children:"Agora não"})]}):o.jsx(ru,{variant:"primary",onClick:t,children:"Entendi"})}),o.jsx("div",{className:"nfid-push-footer",children:o.jsx(gd,{})})]})}function uu({appName:e,onFallback:t,onCancel:r}){return n.useEffect((()=>{al(),il(iu,su)}),[]),o.jsxs("div",{className:"nfid-push",role:"alert","aria-live":"assertive",children:[o.jsxs("svg",{className:"nfid-push-phone-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{color:"var(--nfid-text-muted)"},children:[o.jsx("circle",{cx:"12",cy:"12",r:"9"}),o.jsx("path",{d:"M8 12h8"})]}),o.jsx("h2",{children:"Solicitação cancelada"}),o.jsxs("p",{children:["O pedido de confirmação foi cancelado antes de ser respondido. Você pode tentar de novo pelo"," ",e,"."]}),o.jsx("div",{className:"nfid-push-actions",children:t?o.jsxs(o.Fragment,{children:[o.jsx(ru,{variant:"primary",onClick:t,children:"Entrar de outro jeito"}),o.jsx(ru,{variant:"ghost",onClick:r,children:"Agora não"})]}):o.jsx(ru,{variant:"primary",onClick:r,children:"Entendi"})}),o.jsx("div",{className:"nfid-push-footer",children:o.jsx(gd,{})})]})}function pu({appName:e,onCancel:t}){return n.useEffect((()=>{al(),il(iu,su)}),[]),o.jsxs("div",{className:"nfid-push",role:"alert","aria-live":"assertive",children:[o.jsxs("svg",{className:"nfid-push-phone-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{color:"#D64545"},children:[o.jsx("circle",{cx:"12",cy:"12",r:"9"}),o.jsx("path",{d:"M15 9l-6 6M9 9l6 6"})]}),o.jsx("h2",{children:"Confirmação recusada"}),o.jsxs("p",{children:["O pedido foi recusado no celular. Se não foi você, procure o suporte do ",e,"."]}),o.jsx("div",{className:"nfid-push-actions",children:o.jsx(ru,{variant:"primary",onClick:t,children:"Entendi"})}),o.jsx("div",{className:"nfid-push-footer",children:o.jsx(gd,{})})]})}function fu(e){var n,t,o;switch(e.status){case"approved":case"success":return{kind:"resolve",value:{status:"approved",data:e.data??{}}};case"denied":return{kind:"resolve",value:{status:"denied",reason:(null==(n=e.data)?void 0:n.reason)??e.message}};case"expired":return{kind:"resolve",value:{status:"expired"}};case"cancelled":return{kind:"resolve",value:{status:"cancelled",source:"server",reason:(null==(t=e.data)?void 0:t.reason)??e.message}};case"failed":case"error":return{kind:"reject",error:new io(e.message??(null==(o=e.data)?void 0:o.message)??"Falha na confirmação",ao.API_ERROR)};default:return{kind:"pending"}}}function hu({requestId:e,applicationToken:t,expiresIn:r,numericCode:a,appName:i,onFallback:s,onSettle:c}){const l=i??gl()??"sua aplicação",[d,u]=n.useState(r),[p,f]=n.useState({kind:"waiting"});return n.useEffect((()=>{if("waiting"!==p.kind)return;const e=setInterval((()=>{u((e=>e>0?e-1:0))}),1e3);return()=>clearInterval(e)}),[p.kind]),n.useEffect((()=>{const n=new AbortController;let o=!1;const a=hl(),i=`${a}/api/v1/authorization/events/${encodeURIComponent(e)}/ticket/`;return tu({signal:n.signal,timeoutMs:1e3*(r+30),requestTicket:async()=>{var e;const n=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":t}});if(!n.ok)throw new io(`Falha ao abrir canal de confirmação: ${n.status}`,401===n.status||403===n.status?ao.INVALID_TOKEN:ao.NETWORK);const o=await n.json(),r=(null==(e=null==o?void 0:o.data)?void 0:e.ticket)??(null==o?void 0:o.ticket);if(!r)throw new io("Canal de confirmação sem ticket",ao.API_ERROR);return r},buildUrl:n=>`${a}/api/v1/authorization/events/${encodeURIComponent(e)}/?ticket=${encodeURIComponent(n)}`,classify:fu}).then((e=>{o||(o=!0,"denied"!==e.status?"expired"!==e.status?"cancelled"!==e.status?c(e):f({kind:"cancelled",reason:e.reason}):f({kind:"expired"}):f({kind:"denied"}))})).catch((()=>{o||n.signal.aborted||(o=!0,f({kind:"expired"}))})),()=>{o=!0,n.abort()}}),[e]),"denied"===p.kind?o.jsx(Xd,{open:!0,dismissOnOverlay:!1,ariaLabel:"Confirmação recusada",children:o.jsx(pu,{appName:l,onCancel:()=>c({status:"denied"})})}):"cancelled"===p.kind?o.jsx(Xd,{open:!0,dismissOnOverlay:!1,ariaLabel:"Solicitação cancelada",children:o.jsx(uu,{appName:l,onFallback:s?()=>{s(),c({status:"cancelled",source:"server",reason:p.reason})}:void 0,onCancel:()=>c({status:"cancelled",source:"server",reason:p.reason})})}):"expired"===p.kind?o.jsx(Xd,{open:!0,dismissOnOverlay:!1,ariaLabel:"Tempo esgotado",children:o.jsx(du,{onFallback:s?()=>{s(),c({status:"expired"})}:void 0,onCancel:()=>c({status:"expired"})})}):o.jsx(Xd,{open:!0,dismissOnOverlay:!1,ariaLabel:"Aguardando confirmação no celular",children:o.jsx(lu,{appName:l,numericCode:a,remainingSeconds:d,onCancel:()=>c({status:"cancelled",source:"user"})})})}const mu="neofaceid-device-enrollment-styles",gu="\n.neofaceid-root .nfid-enroll {\n display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;\n padding: 8px 8px 4px;\n}\n.neofaceid-root .nfid-enroll h2 {\n margin: 6px 0 0; font-size: 20px; font-weight: 700; color: var(--nfid-text); line-height: 1.25;\n letter-spacing: -0.015em;\n}\n.neofaceid-root .nfid-enroll p {\n margin: 0; font-size: 14px; color: var(--nfid-text-muted); line-height: 1.5;\n}\n/* O QR é sempre escuro sobre branco, independente do tema: leitor de código\n falha com contraste invertido, e a moldura clara faz a zona de silêncio. */\n.neofaceid-root .nfid-enroll-qr {\n background: #FFFFFF; padding: 14px; border-radius: 16px; margin-top: 12px;\n line-height: 0; box-shadow: 0 0 0 1px var(--nfid-line);\n}\n.neofaceid-root .nfid-enroll-qr svg { display: block; width: 184px; height: 184px; }\n.neofaceid-root .nfid-enroll-handle {\n display: flex; flex-direction: column; align-items: center; gap: 4px;\n margin-top: 14px; padding: 12px 24px;\n background: var(--nfid-surface-muted); border-radius: 12px; width: 100%;\n}\n.neofaceid-root .nfid-enroll-handle-label {\n font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;\n color: var(--nfid-text-subtle);\n}\n.neofaceid-root .nfid-enroll-handle-value {\n font-size: 26px; font-weight: 800; line-height: 1.1; letter-spacing: 0.12em;\n color: var(--nfid-text); font-variant-numeric: tabular-nums;\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n}\n.neofaceid-root .nfid-enroll-countdown {\n font-size: 13px; color: var(--nfid-text-muted); font-variant-numeric: tabular-nums;\n margin-top: 10px;\n}\n.neofaceid-root .nfid-enroll-actions {\n display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 16px;\n}\n.neofaceid-root .nfid-enroll-note {\n font-size: 12px; line-height: 1.45; color: var(--nfid-text-muted);\n background: var(--nfid-surface-muted); border-radius: 10px;\n padding: 10px 14px; margin-top: 12px; text-align: left; width: 100%;\n}\n.neofaceid-root .nfid-enroll-icon { width: 56px; height: 56px; }\n.neofaceid-root .nfid-enroll-footer {\n display: flex; justify-content: center; margin-top: 16px; padding-top: 12px;\n border-top: 1px solid var(--nfid-line); width: 100%;\n}\n";function vu(e){const n=Math.max(0,e);return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function wu({value:e}){const[t,r]=n.useState(null);return n.useEffect((()=>{let n=!1;return Promise.resolve().then((()=>Kp)).then((t=>{if(n)return;const o=(t.default??t)(0,"M");o.addData(e),o.make();const a=o.getModuleCount(),i=[];for(let e=0;e<a;e+=1)for(let n=0;n<a;n+=1)o.isDark(e,n)&&i.push(`M${n} ${e}h1v1h-1z`);r({d:i.join(""),count:a})})).catch((()=>{n||r(null)})),()=>{n=!0}}),[e]),t?o.jsx("svg",{viewBox:`0 0 ${t.count} ${t.count}`,shapeRendering:"crispEdges",role:"img","aria-label":`Código para inscrição do aparelho: ${e.split("").join(" ")}`,children:o.jsx("path",{d:t.d,fill:"#000000"})}):o.jsx("svg",{viewBox:"0 0 21 21","aria-hidden":"true"})}function bu({appName:e,handle:t,remainingSeconds:r,onCancel:a}){return n.useEffect((()=>{al(),il(mu,gu)}),[]),o.jsxs("div",{className:"nfid-enroll",role:"status","aria-live":"polite",children:[o.jsx(au,{tone:"attention",children:"Aguardando o aparelho"}),o.jsx("h2",{children:"Vincule seu celular"}),o.jsxs("p",{children:["Abra o NeoFaceID Push no celular e aponte para este código para vinculá-lo à sua conta no"," ",e,"."]}),o.jsx("div",{className:"nfid-enroll-qr",children:o.jsx(wu,{value:t})}),o.jsxs("div",{className:"nfid-enroll-handle",children:[o.jsx("span",{className:"nfid-enroll-handle-label",children:"Ou digite este código"}),o.jsx("span",{className:"nfid-enroll-handle-value",children:t})]}),o.jsxs("p",{className:"nfid-enroll-countdown",children:["O código expira em ",vu(r)]}),o.jsx("div",{className:"nfid-enroll-actions",children:o.jsx(ru,{variant:"ghost",onClick:a,children:"Cancelar"})}),o.jsx("div",{className:"nfid-enroll-footer",children:o.jsx(gd,{})})]})}function xu({deviceLabel:e,onDone:t}){return n.useEffect((()=>{al(),il(mu,gu)}),[]),o.jsxs("div",{className:"nfid-enroll",role:"alert","aria-live":"assertive",children:[o.jsxs("svg",{className:"nfid-enroll-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{color:"#1E9E6A"},children:[o.jsx("circle",{cx:"12",cy:"12",r:"9"}),o.jsx("path",{d:"M8.5 12.5l2.5 2.5 4.5-5"})]}),o.jsx("h2",{children:"Aparelho vinculado"}),e?o.jsxs("p",{children:[o.jsx("strong",{children:e})," agora pode confirmar suas operações."]}):o.jsx("p",{children:"Um aparelho acabou de ser vinculado à sua conta."}),o.jsx("div",{className:"nfid-enroll-note",children:e?o.jsx(o.Fragment,{children:"Se este não é o seu aparelho, procure o suporte agora — alguém pode ter vinculado um celular à sua conta."}):o.jsxs(o.Fragment,{children:[o.jsx("strong",{children:"Não conseguimos identificar qual aparelho foi vinculado."})," Se não foi você quem acabou de fazer isso, procure o suporte agora — alguém pode ter vinculado um celular à sua conta."]})}),o.jsx("div",{className:"nfid-enroll-actions",children:o.jsx(ru,{variant:"primary",onClick:t,children:"Entendi"})}),o.jsx("div",{className:"nfid-enroll-footer",children:o.jsx(gd,{})})]})}function yu({onRetry:e,onCancel:t}){return n.useEffect((()=>{al(),il(mu,gu)}),[]),o.jsxs("div",{className:"nfid-enroll",role:"alert","aria-live":"assertive",children:[o.jsxs("svg",{className:"nfid-enroll-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{color:"var(--nfid-text-muted)"},children:[o.jsx("circle",{cx:"12",cy:"12",r:"9"}),o.jsx("path",{d:"M12 7v5l3 2"})]}),o.jsx("h2",{children:"O código expirou"}),o.jsx("p",{children:"Códigos de vinculação valem poucos minutos, por segurança. Gere um novo para tentar."}),o.jsxs("div",{className:"nfid-enroll-actions",children:[o.jsx(ru,{variant:"primary",onClick:e,children:"Gerar novo código"}),o.jsx(ru,{variant:"ghost",onClick:t,children:"Agora não"})]}),o.jsx("div",{className:"nfid-enroll-footer",children:o.jsx(gd,{})})]})}function _u(e){var n,t,o;switch(e.status){case"enrolled":return{kind:"resolve",value:{status:"enrolled",deviceLabel:(null==(n=e.data)?void 0:n.device_label)??null,enrolledAt:null==(t=e.data)?void 0:t.enrolled_at}};case"expired":return{kind:"resolve",value:{status:"expired"}};case"error":case"failed":return{kind:"reject",error:new io(e.message??(null==(o=e.data)?void 0:o.message)??"Falha ao inscrever o aparelho",ao.API_ERROR)};default:return{kind:"pending"}}}function ku({userAccessToken:e,applicationToken:t,appName:r,attempt:a,onSettle:i,onRetry:s,onFatal:c}){const l=r??gl()??"sua aplicação",[d,u]=n.useState({kind:"loading"}),[p,f]=n.useState(0);return n.useEffect((()=>{const n=new AbortController;let o=!1;return(async()=>{let r;try{r=await Ll(e,t)}catch(i){return void(o||c(i))}if(o)return;u({kind:"waiting",handle:r.handle,jti:r.jti,expiresIn:r.expiresIn}),f(r.expiresIn);const a=`${hl()}/api/v1/devices/enrollment/${encodeURIComponent(r.jti)}/events/`;try{const e=await tu({signal:n.signal,timeoutMs:1e3*(r.expiresIn+30),requestTicket:async()=>{var e;const n=await fetch(`${a}ticket/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":t}});if(!n.ok)throw new io(`Falha ao abrir o canal de inscrição: ${n.status}`,401===n.status||403===n.status?ao.INVALID_TOKEN:ao.NETWORK);const o=await n.json(),r=(null==(e=null==o?void 0:o.data)?void 0:e.ticket)??(null==o?void 0:o.ticket);if(!r)throw new io("Canal de inscrição sem ticket",ao.API_ERROR);return r},buildUrl:e=>`${a}?ticket=${encodeURIComponent(e)}`,classify:_u});if(o)return;if("enrolled"===e.status)return void u({kind:"enrolled",deviceLabel:e.deviceLabel,enrolledAt:e.enrolledAt});u({kind:"expired"})}catch{if(o||n.signal.aborted)return;u({kind:"expired"})}})(),()=>{o=!0,n.abort()}}),[a]),n.useEffect((()=>{if("waiting"!==d.kind)return;const e=setInterval((()=>f((e=>e>0?e-1:0))),1e3);return()=>clearInterval(e)}),[d.kind]),"loading"===d.kind?null:"enrolled"===d.kind?o.jsx(Xd,{open:!0,dismissOnOverlay:!1,ariaLabel:"Aparelho vinculado",children:o.jsx(xu,{deviceLabel:d.deviceLabel,onDone:()=>i({status:"enrolled",deviceLabel:d.deviceLabel,enrolledAt:d.enrolledAt})})}):"expired"===d.kind?o.jsx(Xd,{open:!0,dismissOnOverlay:!1,ariaLabel:"Código expirado",children:o.jsx(yu,{onRetry:s,onCancel:()=>i({status:"expired"})})}):o.jsx(Xd,{open:!0,dismissOnOverlay:!1,ariaLabel:"Vincular aparelho",children:o.jsx(bu,{appName:l,handle:d.handle,remainingSeconds:p,onCancel:()=>i({status:"cancelled"})})})}function Eu(e={}){const n=document.createElement("div");n.className="neofaceid-camera-oval-guide-overlay-root",Object.assign(n.style,{position:"fixed",top:"0",left:"0",width:"100vw",height:"100vh",backgroundColor:"rgba(0, 0, 0, 0.85)",backdropFilter:"blur(8px)",zIndex:"99999",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"}),document.body.appendChild(n);let r=t.createRoot(n),a=e.stream||null,i=e.faceState||"searching",s=e.instruction||"Centralize o rosto";const c=(n,t,a)=>{r&&r.render(o.jsxs("div",{style:{position:"relative",width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:[e.onCancel&&o.jsx("button",{onClick:()=>{var n;l.close(),null==(n=e.onCancel)||n.call(e)},style:{position:"absolute",top:"20px",right:"20px",background:"rgba(255, 255, 255, 0.2)",border:"none",color:"#fff",fontSize:"24px",width:"40px",height:"40px",borderRadius:"50%",cursor:"pointer",zIndex:10,display:"flex",alignItems:"center",justifyContent:"center"},"aria-label":"Cancelar",children:"✕"}),o.jsx(Tu,{stream:n,faceState:t,instruction:a})]}))};c(a,i,s);const l={update:(e,n,t)=>{a=e,i=n,s=t,c(e,n,t)},close:()=>{r&&(r.unmount(),r=null),n.parentElement&&n.parentElement.removeChild(n)}};return l}function Tu({stream:e,faceState:t,instruction:r,className:a="",style:i={}}){const s=n.useRef(null);n.useEffect((()=>{const n=s.current;if(n)return e?(n.srcObject=e,n.play().catch((()=>{}))):n.srcObject=null,()=>{e&&e.getTracks().forEach((e=>e.stop())),n&&(n.srcObject=null)}}),[e]);const c=function(e){switch(e){case"centered":return{borderColor:"#0E9F6E",boxShadow:"0 0 0 4px rgba(14, 159, 110, 0.8), 0 0 45px rgba(14, 159, 110, 0.45)",svgStroke:"#0E9F6E",badgeBg:"rgba(14, 159, 110, 0.95)",badgeColor:"#FFFFFF"};case"too-far":case"too-close":case"off-center":return{borderColor:"#F59E0B",boxShadow:"0 0 0 4px rgba(245, 158, 11, 0.7), 0 0 35px rgba(245, 158, 11, 0.35)",svgStroke:"#F59E0B",badgeBg:"rgba(245, 158, 11, 0.95)",badgeColor:"#1F2937"};default:return{borderColor:"rgba(156, 163, 175, 0.5)",boxShadow:"0 0 0 4px rgba(156, 163, 175, 0.3), 0 0 20px rgba(156, 163, 175, 0.15)",svgStroke:"#9CA3AF",badgeBg:"rgba(55, 65, 81, 0.9)",badgeColor:"#FFFFFF"}}}(t);return o.jsxs("div",{className:`neofaceid-camera-oval-guide-container ${a}`,style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",position:"relative",width:"100%",maxHeight:"100%",padding:"16px",boxSizing:"border-box",...i},children:[o.jsx("style",{children:"\n .neofaceid-oval-frame {\n width: 320px;\n height: 400px;\n border-radius: 50%;\n overflow: hidden;\n position: relative;\n background: #000000;\n transition: box-shadow 0.3s ease, border-color 0.3s ease;\n }\n\n .neofaceid-oval-video {\n width: 100%;\n height: 100%;\n object-fit: cover;\n transform: scaleX(-1);\n display: block;\n }\n\n .neofaceid-oval-svg-overlay {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n z-index: 2;\n }\n\n .neofaceid-oval-instruction-badge {\n margin-top: 20px;\n padding: 10px 20px;\n border-radius: 20px;\n font-size: 15px;\n font-weight: 600;\n text-align: center;\n max-width: 320px;\n box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);\n backdrop-filter: blur(8px);\n transition: background-color 0.3s ease, color 0.3s ease;\n z-index: 5;\n }\n\n @media (max-width: 640px) {\n .neofaceid-oval-frame {\n width: 280px;\n height: 350px;\n }\n }\n "}),o.jsxs("div",{className:"neofaceid-oval-frame",style:{boxShadow:c.boxShadow,borderColor:c.borderColor},children:[o.jsx("video",{ref:s,className:"neofaceid-oval-video",autoPlay:!0,playsInline:!0,muted:!0,"data-testid":"camera-oval-video"}),o.jsx("svg",{className:"neofaceid-oval-svg-overlay",viewBox:"0 0 320 400",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:o.jsx("ellipse",{cx:"160",cy:"200",rx:"140",ry:"180",stroke:c.svgStroke,strokeWidth:"3",strokeDasharray:"searching"===t?"8 8":"none",style:{transition:"stroke 0.3s ease"}})})]}),r&&o.jsx("div",{className:"neofaceid-oval-instruction-badge","aria-live":"assertive",style:{backgroundColor:c.badgeBg,color:c.badgeColor},"data-testid":"camera-oval-instruction",children:r})]})}function Nu({error:e,onRetry:n,onCredentials:t,onCancel:r,applicationToken:a}){return o.jsxs(o.Fragment,{children:[o.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: var(--nfid-overlay);\n backdrop-filter: blur(3px);\n -webkit-backdrop-filter: blur(3px);\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 font-family: inherit;\n }\n\n .neofaceid-fallback-prompt {\n background: var(--nfid-surface);\n border-radius: var(--nfid-radius, 16px);\n padding: 28px;\n max-width: 400px;\n width: 100%;\n box-shadow: 0 1px 3px rgba(10, 19, 32, 0.08);\n animation: slideUp 0.32s cubic-bezier(.2,0,0,1);\n text-align: center;\n box-sizing: border-box;\n }\n\n /* Falha de captura é atenção (dourado), nunca crítico (vermelho). */\n .neofaceid-fallback-icon {\n width: 56px;\n height: 56px;\n margin: 0 auto 20px;\n color: #F1BE00;\n }\n\n .neofaceid-fallback-title {\n font-size: 20px;\n font-weight: 700;\n color: var(--nfid-text);\n margin: 0 0 8px 0;\n line-height: 1.25;\n }\n\n .neofaceid-fallback-message {\n font-size: 14px;\n color: var(--nfid-text-muted);\n margin: 0 0 24px 0;\n line-height: 1.5;\n }\n\n .neofaceid-fallback-actions {\n display: flex;\n flex-direction: column;\n gap: 10px;\n }\n\n .neofaceid-fallback-button {\n min-height: 44px;\n padding: 12px 20px;\n border-radius: var(--nfid-radius, 16px);\n border: none;\n font-size: 15px;\n font-weight: 600;\n cursor: pointer;\n transition: background 120ms ease-out;\n font-family: inherit;\n }\n\n .neofaceid-fallback-button-primary {\n background: var(--nfid-action);\n color: var(--nfid-action-text);\n }\n .neofaceid-fallback-button-primary:hover { opacity: 0.92; }\n .neofaceid-fallback-button-primary:focus-visible {\n outline: 2px solid var(--nfid-focus-ring);\n outline-offset: 2px;\n }\n\n .neofaceid-fallback-button-secondary {\n background: var(--nfid-surface-muted);\n color: var(--nfid-text);\n border: 1px solid var(--nfid-line);\n }\n .neofaceid-fallback-button-secondary:hover { opacity: 0.9; }\n\n .neofaceid-fallback-button-ghost {\n background: transparent;\n color: var(--nfid-text-muted);\n min-height: 44px;\n padding: 10px;\n }\n .neofaceid-fallback-button-ghost:hover {\n background: var(--nfid-surface-muted);\n }\n\n @media (max-width: 640px) {\n .neofaceid-fallback-prompt {\n padding: 22px;\n }\n .neofaceid-fallback-title {\n font-size: 18px;\n }\n }\n "}),o.jsx("div",{className:"neofaceid-root neofaceid-fallback-overlay",role:"dialog","aria-modal":"true",children:o.jsxs("div",{className:"neofaceid-fallback-prompt",children:[o.jsx("div",{className:"neofaceid-fallback-icon","aria-hidden":"true",children:o.jsxs("svg",{viewBox:"0 0 64 64",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("path",{d:"M32 8 L58 54 H6 Z",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),o.jsx("path",{d:"M32 26 V38",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"}),o.jsx("circle",{cx:"32",cy:"45",r:"2",fill:"currentColor"})]})}),o.jsx("h3",{className:"neofaceid-fallback-title",children:"Vamos tentar de outro jeito"}),o.jsx("p",{className:"neofaceid-fallback-message",children:(null==e?void 0:e.getFriendlyMessage())||"Não conseguimos reconhecer sua face. Tente novamente ou use email e senha."}),o.jsxs("div",{className:"neofaceid-fallback-actions",children:[o.jsx("button",{type:"button",className:"neofaceid-fallback-button neofaceid-fallback-button-primary",onClick:n,children:"Tentar Novamente"}),o.jsx("button",{type:"button",className:"neofaceid-fallback-button neofaceid-fallback-button-secondary",onClick:t,children:"Entrar com Email e Senha"}),a&&o.jsx("button",{type:"button",className:"neofaceid-fallback-button neofaceid-fallback-button-ghost",onClick:()=>{new wd(a).open()},children:"Esqueceu sua senha?"}),r&&o.jsx("button",{type:"button",className:"neofaceid-fallback-button neofaceid-fallback-button-ghost",onClick:r,children:"Cancelar"})]})]})})]})}class Su{constructor(){l(this,"container",null),l(this,"root",null)}show(e,n,o,r,a){this.container||(al(),this.container=document.createElement("div"),this.container.id="neofaceid-fallback-prompt",document.body.appendChild(this.container),this.root=t.createRoot(this.container),this.render(e,n,o,r,a))}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,r,a){this.root&&this.container&&this.root.render(o.jsx(Nu,{error:e,onRetry:()=>{this.close(),n()},onCredentials:()=>{this.close(),t()},applicationToken:a??"",onCancel:()=>{this.close(),null==r||r()}}))}}class Cu{constructor(e){l(this,"options"),l(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(){al(),this.addStyles(),this.modalElement=document.createElement("div"),this.modalElement.className="neofaceid-root neoface-email-password-modal",this.modalElement.innerHTML=`\n <div class="neoface-email-modal-overlay">\n <div class="neoface-email-modal-content">\n <h2>${this.options.title||"Login com Email e Senha"}</h2>\n <p>${this.options.subtitle||"Informe seus dados para login."}</p>\n <div id="login-error" class="neoface-email-error" style="display:none"></div>\n <form id="email-password-form">\n <input type="email" id="email" placeholder="Email" required />\n <input type="password" id="password" placeholder="Senha" required />\n <button type="submit" class="neoface-email-submit-btn">Entrar</button>\n </form>\n <button class="neoface-email-cancel-btn">Cancelar</button>\n \n \x3c!-- Branding --\x3e\n <div class="neoface-email-branding">\n ${vd()}\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";document.getElementById(e)||il(e,"\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: inherit;\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, #0A1320 0%, #111C2B 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: #0059C4;\n box-shadow: 0 0 0 3px rgba(0, 89, 196, 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, #0059C4 0%, #00449A 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(0, 89, 196, 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(0, 89, 196, 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: inherit;\n color: #ffffff;\n letter-spacing: 0.3px;\n }\n\n .neoface-email-error {\n background: rgba(239, 68, 68, 0.15);\n border: 1px solid rgba(239, 68, 68, 0.4);\n border-radius: 10px;\n color: #fca5a5;\n font-size: 14px;\n padding: 12px 16px;\n margin-bottom: 16px;\n text-align: center;\n animation: fadeIn 0.2s ease-out;\n }\n\n @media (max-width: 640px) {\n .neoface-email-modal-content {\n padding: 24px;\n border-radius: 16px;\n }\n\n .neoface-email-modal-content h2 {\n font-size: 20px;\n }\n }\n ")}async handleSubmit(e){e.preventDefault();const n=this.modalElement.querySelector("#email"),t=this.modalElement.querySelector("#password"),o=this.modalElement.querySelector(".neoface-email-submit-btn"),r=this.modalElement.querySelector("#login-error"),a=e=>{r.textContent=e,r.style.display="block"};r.style.display="none",r.textContent="";const i=n.value.trim(),s=t.value.trim();if(i&&s){o.disabled=!0,o.textContent="Entrando...";try{const e=await Ml(i,s,this.options.applicationToken);this.options.onSuccess(e),this.close()}catch(c){o.disabled=!1,o.textContent="Entrar";c instanceof io&&(c.type===ao.INVALID_TOKEN||c.type===ao.API_ERROR&&c.message.includes("400"))?(a("Email ou senha incorretos. Verifique seus dados e tente novamente."),t.value="",t.focus()):(a("Ocorreu um erro inesperado. Tente novamente mais tarde."),this.options.onError(c))}}else a("Preencha o email e a senha para continuar.")}}let Iu=!1,Ru=null;async function Ou(){if(!Iu)return Ru||(Ru=(async()=>{try{const e="/models";await Et.tinyFaceDetector.loadFromUri(e),Iu=!0}catch(e){}})(),Ru)}async function ju(e,n,t,o=5e3,r=100){return new Promise((a=>{let i=0;const s=Math.ceil(o/r);let c=null,l=!1,d=0;const u=e=>{l||(l=!0,c&&clearTimeout(c),a(e))},p=async()=>{if(!l){if(i++,!Iu)return t.update(n,"searching","Carregando modelos de detecção..."),i>=s?void u(!1):void(c=window.setTimeout(p,r));try{const o=await Jt(e,new vt({inputSize:160,scoreThreshold:.3})),{faceState:a,instruction:l}=function(e,n,t){if(!e||!n||!t)return{faceState:"searching",instruction:"Centralize o rosto"};const o=e.x+e.width/2,r=e.y+e.height/2,a=n/2,i=t/2,s=Math.abs(o-a)/n,c=Math.abs(r-i)/t,l=e.width*e.height/(n*t);return l<.08?{faceState:"too-far",instruction:"Aproxime-se"}:l>.45?{faceState:"too-close",instruction:"Afaste-se"}:s>.18||c>.18?{faceState:"off-center",instruction:"Centralize o rosto"}:{faceState:"centered",instruction:"Perfeito, mantenha"}}(o?o.box:null,e.videoWidth,e.videoHeight);if(t.update(n,a,l),"centered"===a){if(d+=r,d>=1e3)return void u(!0)}else d=0;if(i>=s)return void u(!1);c=window.setTimeout(p,r)}catch(o){if(i>=s)return void u(!1);c=window.setTimeout(p,r)}}};window.setTimeout((()=>{l||u(!1)}),o+500),p()}))}async function Au(e){const{applicationToken:n,onSuccess:t,onError:o,onFallbackRequest:r,onCancel:a,fastMode:i=!1}=e,s=new Su;let c,l=0;Iu||i||Ou().catch((()=>{}));const d=async()=>{try{l++;const e=await async function(e,n=!1,t){const o=Eu({stream:null,faceState:"searching",instruction:"Iniciando câmera...",onCancel:t}),r=document.createElement("video");r.style.position="fixed",r.style.top="-9999px",r.style.left="-9999px",r.style.width="1px",r.style.height="1px",r.style.opacity="0",r.muted=!0,r.playsInline=!0,r.setAttribute("autoplay",""),r.setAttribute("playsinline",""),document.body.appendChild(r);let a=null;try{try{a=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"},audio:!1})}catch{a=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user"},audio:!1})}r.srcObject=a,o.update(a,"searching","Centralize o rosto"),await new Promise((e=>{if(r.readyState>=1)e();else{const n=()=>{r.removeEventListener("loadedmetadata",n),e()};r.addEventListener("loadedmetadata",n),setTimeout(e,2e3)}})),await r.play(),await new Promise((e=>{if(r.videoWidth&&r.videoHeight)e();else{const n=()=>{r.videoWidth&&r.videoHeight?e():setTimeout(n,100)};setTimeout(e,3e3),n()}})),await new Promise((e=>setTimeout(e,100)));let t=!0;if(n||(t=await ju(r,a,o,5e3,100)),!t)throw o.close(),a&&a.getTracks().forEach((e=>e.stop())),r.parentElement&&r.parentElement.removeChild(r),new io("Nenhum rosto centralizado detectado. Por favor, tente novamente.",ao.VALIDATION_ERROR);o.update(a,"centered","Capturando imagem...");const i=document.createElement("canvas");i.width=r.videoWidth,i.height=r.videoHeight;const s=i.getContext("2d");if(!s)throw o.close(),a&&a.getTracks().forEach((e=>e.stop())),r.parentElement&&r.parentElement.removeChild(r),new io("Erro ao capturar imagem",ao.CAPTURE_ERROR);s.drawImage(r,0,0,i.width,i.height);const c=await new Promise(((e,n)=>{i.toBlob((t=>{i.remove(),t?e(t):n(new Error("Failed to capture image"))}),"image/jpeg",.85)}));o.update(a,"centered","Verificando com o servidor...");const l=await jl(c,e);if(o.close(),a&&a.getTracks().forEach((e=>e.stop())),r.parentElement&&r.parentElement.removeChild(r),!l.success)throw new io("Login falhou",ao.LOGIN_FAILED);return l}catch(i){if(o.close(),a&&a.getTracks().forEach((e=>e.stop())),r.parentElement&&r.parentElement.removeChild(r),i instanceof io)throw i;throw new io(i instanceof Error?i.message:"Erro desconhecido",ao.UNKNOWN)}}(n,i,a);t(e)}catch(e){c=e instanceof io?e:new io(e instanceof Error?e.message:"Erro desconhecido",ao.UNKNOWN),l<2?setTimeout((()=>{d()}),500):setTimeout((()=>{s.show(c,(()=>{l=0,setTimeout((()=>d()),500)}),(()=>{r?r():o(new io("Por favor, use email e senha para fazer login",ao.LOGIN_FAILED))}),a,n)}),500)}};d()}const Pu=Object.freeze(Object.defineProperty({__proto__:null,captureFaceSilently:async function(){return new Promise(((e,n)=>{const t=document.createElement("video");t.style.position="fixed",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.opacity="0",t.muted=!0,t.playsInline=!0,t.setAttribute("autoplay",""),t.setAttribute("playsinline","");const o=document.createElement("canvas");o.style.display="none";let r=null,a=0;const i=()=>{r&&r.getTracks().forEach((e=>e.stop())),t.parentElement&&t.parentElement.removeChild(t),o.parentElement&&o.parentElement.removeChild(o)};document.body.appendChild(t),document.body.appendChild(o);const s=e=>e?navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"},audio:!1}):navigator.mediaDevices.getUserMedia({video:{facingMode:"user"},audio:!1});s(!0).catch((()=>s(!1))).then((s=>{r=s,t.srcObject=r;const c=()=>{if(!t.videoWidth||!t.videoHeight)return a<30?(a++,void setTimeout(c,150)):(i(),void n(new io("Câmera não está pronta",ao.CAMERA_ERROR)));o.width=t.videoWidth,o.height=t.videoHeight;const r=o.getContext("2d");if(!r)return i(),void n(new Error("Failed to get canvas context"));(async()=>{if(!Iu)return!0;try{return!!(await Jt(t,new vt({inputSize:160,scoreThreshold:.3})))}catch{return!0}})().then((s=>{if(!s&&a<30)return a++,void setTimeout(c,150);r.drawImage(t,0,0,o.width,o.height),o.toBlob((t=>{i(),t?e(t):n(new Error("Failed to capture image"))}),"image/jpeg",.85)}))},l=t.play();void 0!==l?l.then((()=>{t.videoWidth&&t.videoHeight?setTimeout(c,200):(t.onloadedmetadata=()=>setTimeout(c,200),setTimeout((()=>{t.videoWidth&&t.videoHeight&&c()}),1500))})).catch((e=>{i(),n(new io(`Erro ao reproduzir câmera: ${e.message}`,ao.CAMERA_ERROR))})):t.onloadedmetadata=()=>setTimeout(c,200),t.onerror=()=>{i(),n(new io("Erro ao acessar câmera",ao.CAMERA_ERROR))}})).catch((e=>{i(),n(new io(`Não foi possível acessar a câmera: ${e.message}`,ao.CAMERA_ERROR))}))}))},executeBiometricLoginFlow:Au,preloadFaceDetectionModels:Ou},Symbol.toStringTag,{value:"Module"}));function Fu(e,n={}){const t=n.darkThreshold??.235,o=n.improvementTarget??.12,r=n.sampleIntervalMs??600,a=n.minToggleMs??3e3,i=n.zIndex??10001,s=`nfid-flash-${Math.random().toString(36).slice(2,9)}`;let c=null,l=null,d=!1,u=0,p=0,f=0,h=null,m=null,g=null;const v=e=>{d!==e&&(d=e,e?m||"undefined"==typeof document||(m=document.createElement("div"),m.id=s,m.setAttribute("aria-hidden","true"),m.style.cssText=`\n position: fixed; inset: 0; background: #FFFFFF;\n z-index: ${i}; pointer-events: none;\n opacity: 0; transition: opacity 200ms ease-out;\n `,document.body.appendChild(m),requestAnimationFrame((()=>{m&&(m.style.opacity="1")}))):(()=>{if(!m)return;const e=m;m=null,e.style.opacity="0",setTimeout((()=>{e.parentNode&&e.parentNode.removeChild(e)}),220)})(),n.onChange&&n.onChange(e,u))},w=()=>{"undefined"==typeof document||g||(g=document.createElement("canvas"));const n=nd(e(),{scratch:g??void 0});u=n;const r=Date.now();d||(n>0&&n<t?p+=1:p=0,p>=2&&r-f>=a&&(h=n,f=r,p=0,v(!0),l=setTimeout((()=>{nd(e(),{scratch:g??void 0})-(h??0)<o&&(f=Date.now(),v(!1)),h=null}),600)))};return{start(){!1!==n.enabled&&(c||(w(),c=setInterval(w,r)))},stop(){c&&(clearInterval(c),c=null),l&&(clearTimeout(l),l=null),v(!1),p=0,h=null},destroy(){this.stop(),g=null},get flashOn(){return d},get lastBrightness(){return u}}}class zu{constructor(e){l(this,"modal",null),l(this,"video",null),l(this,"canvas",null),l(this,"stream",null),l(this,"options"),l(this,"countdownInterval",null),l(this,"isCapturing",!1),l(this,"flashController",null),this.options=e}async open(){try{await this.createModal(),await this.initializeCamera(),this.enableCaptureButton(),!1!==this.options.autoLighting&&(this.flashController=Fu((()=>this.video)),this.flashController.start())}catch(e){this.options.onError(new io(`Erro ao inicializar câmera: ${e.message}`,ao.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-root 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" aria-label="Fechar">&times;</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>\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 class="neofaceid-seal-row">\n ${vd()}\n </div>\n </div>\n </div>\n `,al(),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}`)}}enableCaptureButton(){if(!this.modal)return;const e=this.modal.querySelector(".neofaceid-capture-btn"),n=this.modal.querySelector(".neofaceid-status-text");e&&(e.disabled=!1,e.textContent="Capturar"),n&&(n.textContent="Pronto para capturar"),"auto"===this.options.mode&&setTimeout((()=>this.captureImage()),300)}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}`,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 io(`Erro ao capturar imagem: ${e.message}`,ao.CAPTURE_ERROR))}finally{this.isCapturing=!1}}}async detectBiometricType(e){try{const{detectBiometricType:n}=await Promise.resolve().then((()=>Gp)),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.flashController&&(this.flashController.destroy(),this.flashController=null),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(),il(e,"\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: inherit;\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: 22px;\n cursor: pointer;\n color: #666;\n padding: 0;\n min-width: 44px;\n min-height: 44px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 22px;\n transition: background-color 0.2s;\n }\n .neofaceid-close-btn:focus-visible {\n outline: 2px solid var(--nfid-focus-ring);\n outline-offset: 2px;\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 #0E9F6E;\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-seal-row {\n display: flex;\n justify-content: center;\n padding: 12px 20px 16px;\n border-top: 1px solid var(--nfid-line, #E6ECF4);\n }\n .neofaceid-seal {\n font-size: 10px;\n font-weight: 500;\n letter-spacing: 0.06em;\n text-transform: uppercase;\n color: var(--nfid-text-subtle, #617489);\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: #0E9F6E;\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 ")}}const $u="Consentimento recusado pelo usuário.";let Du=null;function Mu(){Du=null}async function Lu({applicationToken:e,purpose:n}){if(!e)throw new io("applicationToken é obrigatório para abrir sessão de captura",ao.INVALID_TOKEN);const t=`${hl()}/api/v1/auth/capture/session/`;let o;try{o=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":e},body:JSON.stringify({purpose:String(n).toUpperCase()})})}catch(c){const e=c instanceof Error?c.message:"Erro de rede";throw new io(`Falha de rede ao abrir sessão: ${e}`,ao.NETWORK)}if(401===o.status||403===o.status)throw new io("Token de aplicação inválido ou expirado",ao.INVALID_TOKEN);if(!o.ok)throw new io(`Falha ao abrir sessão de captura (${o.status})`,ao.API_ERROR);const r=await o.json().catch((()=>null)),a=(null==r?void 0:r.data)??r,i=null==a?void 0:a.session_id;if(!i)throw new io("Resposta inválida ao abrir sessão de captura (session_id ausente)",ao.API_ERROR);const s="string"==typeof(null==a?void 0:a.expires_at)&&a.expires_at.length>0?a.expires_at:function(e){const n="number"==typeof e&&Number.isFinite(e)?e:0;return new Date(Date.now()+1e3*n).toISOString()}(null==a?void 0:a.expires_in);return Du={session_id:i,expires_at:s},Du}async function Bu({sessionId:e,applicationToken:n}){if(!n)throw new io("applicationToken é obrigatório para solicitar desafio de liveness",ao.INVALID_TOKEN);if(!e)throw new io("session_id é obrigatório para solicitar desafio de liveness",ao.VALIDATION_ERROR);const t=`${hl()}/api/v1/auth/liveness/challenge/`;let o;try{o=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({session_id:e})})}catch(p){const e=p instanceof Error?p.message:"Erro de rede";throw new io(`Falha de rede ao solicitar desafio: ${e}`,ao.NETWORK)}if(401===o.status||403===o.status)throw new io("Token de aplicação inválido ou expirado",ao.INVALID_TOKEN);if(410===o.status)throw new io("Sessão de captura expirada (410) — reabrir sessão",ao.API_ERROR);if(!o.ok)throw new io(`Falha ao solicitar desafio de liveness (${o.status})`,ao.API_ERROR);const r=await o.json().catch((()=>null)),a=(null==r?void 0:r.data)??r,i=null==a?void 0:a.steps,s=null==a?void 0:a.gestures,c=Array.isArray(i)?i:Array.isArray(s)?s:void 0;if(!c||0===c.length)throw new io("Resposta inválida ao solicitar desafio (steps/gestures ausentes)",ao.API_ERROR);const l=c.map(((e,n)=>{const t=e,o=t.gesture??t.gesture_key;return{index:"number"==typeof t.order?t.order:"number"==typeof t.index?t.index:n+1,gesture_key:o??"",instruction:"string"==typeof t.instruction?t.instruction:void 0,instruction_i18n:t.instruction_i18n&&"object"==typeof t.instruction_i18n?t.instruction_i18n:void 0}})),d="number"==typeof(null==a?void 0:a.expires_in)?a.expires_in:void 0,u="string"==typeof(null==a?void 0:a.expires_at)&&a.expires_at.length>0?a.expires_at:void 0!==d?new Date(Date.now()+1e3*d).toISOString():void 0;return{challenge_id:"string"==typeof(null==a?void 0:a.challenge_id)?a.challenge_id:void 0,gestures:l,expires_at:u,expires_in:d,language:"string"==typeof(null==a?void 0:a.language)?a.language:void 0}}async function Wu({applicationToken:e,purpose:n,collectFramesForGesture:t,retryOnSessionExpired:o=!0}){const r=async()=>{const o=await Lu({applicationToken:e,purpose:n}),r=await Bu({sessionId:o.session_id,applicationToken:e}),a=[];for(let e=0;e<r.gestures.length;e+=1){const n=r.gestures[e],o=await t(n,e,r.gestures.length);a.push({gesture_key:String(n.gesture_key),images:o})}return{sessionId:o.session_id,challenge:r,capturedGestures:a}};try{return await r()}catch(a){if(o&&a instanceof io&&a.message.includes("410"))return Mu(),r();throw a}}class qu{constructor(e){l(this,"overlay",null),l(this,"video",null),l(this,"canvas",null),l(this,"stream",null),l(this,"step","face"),l(this,"countdownSeconds"),l(this,"title"),l(this,"subtitle"),l(this,"faceBlob",null),l(this,"documentBlob",null),l(this,"autoLighting"),l(this,"flashController",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,this.autoLighting=!1!==(null==e?void 0:e.autoLighting)}async open(){if(await this.createDom(),await this.startCamera(),await this.runFaceCaptureCountdown(),this.faceBlob=await this.captureFrame(),this.step="document",this.updateTexts("Captura do Documento",'Posicione seu documento visível e clique em "Capturar"'),await this.waitForUserCaptureClick(),this.documentBlob=await this.captureFrame(),await this.close(),!this.faceBlob||!this.documentBlob)throw new Error("Falha na captura das imagens de onboarding");return{face:this.faceBlob,document:this.documentBlob}}async createDom(){const e=document.createElement("div");e.className="neofaceid-modal-overlay",e.innerHTML=`\n <div class="neofaceid-modal">\n <div class="neofaceid-modal-header">\n <h2 class="neofaceid-title">${this.title??"Onboarding NeoFaceID"}</h2>\n <button class="neofaceid-close-btn" aria-label="Fechar">×</button>\n </div>\n <div class="neofaceid-modal-body">\n <p class="neofaceid-subtitle">${this.subtitle??"Vamos capturar sua face e documento"}</p>\n <div class="neofaceid-camera-container">\n <video class="neofaceid-video" autoplay muted playsinline></video>\n <canvas class="neofaceid-canvas"></canvas>\n <div class="neofaceid-overlay">\n <div class="neofaceid-frame"></div>\n <div class="neofaceid-countdown" style="display:none"><span class="neofaceid-countdown-number">${this.countdownSeconds}</span></div>\n </div>\n </div>\n <div class="neofaceid-status"><p class="neofaceid-status-text">Posicione seu rosto no quadro</p></div>\n </div>\n <div class="neofaceid-modal-footer">\n <button class="neofaceid-cancel-btn">Cancelar</button>\n <button class="neofaceid-capture-btn" disabled>Capturar</button>\n </div>\n <div class="neofaceid-seal-row">\n ${vd()}\n </div>\n </div>\n `,al(),il("neofaceid-onboarding-capture-styles","\n .neofaceid-root .neofaceid-modal-overlay { position: fixed; inset: 0; background: var(--nfid-overlay); display:flex; align-items:center; justify-content:center; z-index: 9999; }\n .neofaceid-root .neofaceid-modal { background: var(--nfid-surface); border-radius: var(--nfid-radius, 16px); width: 92%; max-width: 640px; box-shadow: 0 1px 3px rgba(10,19,32,.08); overflow:hidden; }\n .neofaceid-root .neofaceid-modal-header { padding: 16px 20px; border-bottom: 1px solid var(--nfid-line); display:flex; align-items:center; justify-content:space-between; }\n .neofaceid-root .neofaceid-title { margin:0; font-size: 20px; color: var(--nfid-text); }\n .neofaceid-root .neofaceid-close-btn { background:none; border:none; font-size:24px; cursor:pointer; color: var(--nfid-text-muted); min-width: 44px; min-height: 44px; }\n .neofaceid-root .neofaceid-modal-body { padding: 16px 20px; }\n .neofaceid-root .neofaceid-subtitle { margin: 0 0 12px 0; color: var(--nfid-text-muted); }\n .neofaceid-root .neofaceid-camera-container { position: relative; background:#000; border-radius:8px; overflow:hidden; aspect-ratio: 4/3; margin-bottom: 12px; }\n .neofaceid-root .neofaceid-video { width:100%; height:100%; object-fit: cover; }\n .neofaceid-root .neofaceid-canvas { position:absolute; top:0; left:0; }\n .neofaceid-root .neofaceid-overlay { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; }\n .neofaceid-root .neofaceid-frame { width: 200px; height: 200px; border: 3px solid #0E9F6E; border-radius: 50%; box-shadow: 0 0 0 2px rgba(14,159,110,0.3); }\n .neofaceid-root .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-root .neofaceid-modal-footer { padding: 16px 20px; border-top: 1px solid var(--nfid-line); display:flex; gap: 8px; justify-content:flex-end; }\n .neofaceid-root .neofaceid-cancel-btn { background: var(--nfid-surface-muted); color: var(--nfid-text-muted); border:none; border-radius:8px; padding:10px 18px; cursor:pointer; min-height: 44px; }\n .neofaceid-root .neofaceid-capture-btn { background: var(--nfid-action); color: var(--nfid-action-text); border:none; border-radius:8px; padding:10px 18px; cursor:pointer; min-height: 44px; }\n .neofaceid-root .neofaceid-capture-btn:disabled { background: var(--nfid-line); cursor:not-allowed; }\n .neofaceid-root .neofaceid-seal-row { display:flex; justify-content:center; padding:12px 20px 14px; border-top: 1px solid var(--nfid-line); }\n .neofaceid-root .neofaceid-seal { font-size:10px; font-weight:500; letter-spacing:0.06em; text-transform:uppercase; color: var(--nfid-text-subtle); }\n "),e.classList.add("neofaceid-root"),document.body.appendChild(e),this.overlay=e,this.video=this.overlay.querySelector(".neofaceid-video"),this.canvas=this.overlay.querySelector(".neofaceid-canvas");const n=this.overlay.querySelector(".neofaceid-close-btn"),t=this.overlay.querySelector(".neofaceid-cancel-btn");n.onclick=()=>this.close(),t.onclick=()=>this.close();this.overlay.querySelector(".neofaceid-capture-btn").disabled=!0}async startCamera(){if(!this.video)throw new Error("Elemento de vídeo não encontrado");this.video.muted=!0,this.video.playsInline=!0;try{this.stream=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:{ideal:1280},height:{ideal:720}},audio:!1})}catch{this.stream=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user"},audio:!1})}this.video.srcObject=this.stream,await this.video.play(),this.autoLighting&&!this.flashController&&(this.flashController=Fu((()=>this.video)),this.flashController.start())}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 r=setInterval((()=>{o-=1,n.textContent=String(o),o<=0&&(clearInterval(r),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"),r=this.overlay.querySelector(".neofaceid-frame");t.textContent=e,o.textContent=n,"document"===this.step&&(r.style.borderRadius="8px",r.style.width="280px",r.style.height="180px")}async close(){this.flashController&&(this.flashController.destroy(),this.flashController=null),this.stream&&(this.stream.getTracks().forEach((e=>e.stop())),this.stream=null),this.overlay&&(this.overlay.remove(),this.overlay=null)}}const Uu=[{tip:8,pip:6},{tip:12,pip:10},{tip:16,pip:14},{tip:20,pip:18}],Vu=(e,n)=>Math.hypot(e.x-n.x,e.y-n.y);function Ku(e){if(e.length<21)return!1;const n=e[0],t=e[2],o=e[4];return!!(Vu(o,n)>1.3*Vu(t,n))&&Uu.every((({tip:t,pip:o})=>{const r=e[t],a=e[o];return Vu(r,n)<Vu(a,n)}))}let Zu=null;function Hu(){return Zu||(Zu=async function(){const e=await import("@tensorflow-models/hand-pose-detection");return e.createDetector(e.SupportedModels.MediaPipeHands,{runtime:"mediapipe",modelType:"lite",maxHands:1,solutionPath:"https://cdn.jsdelivr.net/npm/@mediapipe/hands@0.4.1675469240"})}()),Zu}const Gu=e=>new Promise((n=>{setTimeout(n,e)}));async function Ju(e,n){const t=await Hu(),o=Date.now()+n;for(;Date.now()<o;){const n=await t.estimateHands(e,{flipHorizontal:!0});if(n.length>0&&Ku(n[0].keypoints))return!0;await Gu(150)}return!1}const Xu=["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"];function Yu({size:e=96,color:n,strokeWidth:t,glow:r=!1,className:a,style:i}){const s=t??function(e){return e<=24?2:e<=48?2.5:3.4}(e),c=.28*e,l=s/2,d=[{x:l,y:l,dx:1,dy:1},{x:e-l,y:l,dx:-1,dy:1},{x:l,y:e-l,dx:1,dy:-1},{x:e-l,y:e-l,dx:-1,dy:-1}];return o.jsx("svg",{width:e,height:e,viewBox:`0 0 ${e} ${e}`,xmlns:"http://www.w3.org/2000/svg",className:a,style:{color:n??`var(${Yc})`,filter:r?"drop-shadow(0 0 6px rgba(0,176,248,.5))":void 0,...i},"aria-hidden":"true",children:d.map(((e,n)=>o.jsx("path",{d:`M ${e.x+e.dx*c} ${e.y} L ${e.x} ${e.y} L ${e.x} ${e.y+e.dy*c}`,fill:"none",stroke:"currentColor",strokeWidth:s,strokeLinecap:"round"},n)))})}function Qu({progress:e,size:n=268,children:t,className:r,style:a}){const i=Math.max(0,Math.min(1,Number.isFinite(e)?e:0)),s=n/2-4.2,c=2*Math.PI*s,l=c*(1-i),d=n+24;return o.jsxs("div",{className:r,style:{position:"relative",width:d,height:d,display:"inline-flex",alignItems:"center",justifyContent:"center",...a},children:[o.jsx("div",{style:{position:"absolute",inset:0},children:o.jsx(Yu,{size:d,glow:!0})}),o.jsx("div",{style:{position:"relative",width:n,height:n,borderRadius:"50%",overflow:"hidden",background:"linear-gradient(160deg, #274B6E, #0F2438, #05080F)"},children:t}),o.jsxs("svg",{width:n,height:n,viewBox:`0 0 ${n} ${n}`,style:{position:"absolute",top:(d-n)/2,left:(d-n)/2,transform:"rotate(-90deg)",pointerEvents:"none"},"aria-hidden":"true",children:[o.jsx("defs",{children:o.jsxs("linearGradient",{id:"nfid-challenge-arc",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[o.jsx("stop",{offset:"0%",stopColor:"#00B0F8"}),o.jsx("stop",{offset:"100%",stopColor:"#0073F4"})]})}),o.jsx("circle",{cx:n/2,cy:n/2,r:s,stroke:"rgba(255,255,255,0.18)",strokeWidth:4.2,fill:"none"}),o.jsx("circle",{cx:n/2,cy:n/2,r:s,stroke:`var(${Yc}, url(#nfid-challenge-arc))`,strokeWidth:4.2,strokeLinecap:"round",strokeDasharray:c,strokeDashoffset:l,fill:"none",style:{transition:"stroke-dashoffset 200ms ease-out"}})]})]})}function ep({gesture:e,size:n=48,color:t,className:r,style:a}){return o.jsxs("svg",{width:n,height:n,viewBox:"0 0 48 48",xmlns:"http://www.w3.org/2000/svg",className:r,style:{color:t??`var(${Yc})`,...a},role:"img","aria-label":np[e],children:["blink"===e?o.jsx(op,{stroke:3.4}):o.jsx(tp,{stroke:3.4}),"blink"!==e&&"center"!==e&&o.jsx(rp,{gesture:e,stroke:3.4})]})}const np={center:"Centralize o rosto",turn_right:"Vire o rosto para a direita",turn_left:"Vire o rosto para a esquerda",look_up:"Olhe para cima",look_down:"Olhe para baixo",blink:"Pisque os olhos",move_closer:"Aproxime-se da câmera"};function tp({stroke:e}){return o.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:e,strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M14 20c0-5.5 4.5-10 10-10s10 4.5 10 10v4c0 5.5-4.5 10-10 10s-10-4.5-10-10v-4z"}),o.jsx("circle",{cx:"20",cy:"22",r:"1.2",fill:"currentColor",stroke:"none"}),o.jsx("circle",{cx:"28",cy:"22",r:"1.2",fill:"currentColor",stroke:"none"}),o.jsx("path",{d:"M21 28c1 1 2 1.5 3 1.5s2-.5 3-1.5"})]})}function op({stroke:e}){return o.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:e,strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M8 24c4-4 8-6 16-6s12 2 16 6"}),o.jsx("path",{d:"M12 26v3"}),o.jsx("path",{d:"M18 27v3.5"}),o.jsx("path",{d:"M24 27.5v4"}),o.jsx("path",{d:"M30 27v3.5"}),o.jsx("path",{d:"M36 26v3"})]})}function rp({gesture:e,stroke:n}){const[t,r,a]=function(e){switch(e){case"turn_right":return["40 18","44 24","40 30"];case"turn_left":return["8 18","4 24","8 30"];case"look_up":return["18 8","24 4","30 8"];case"look_down":case"move_closer":return["18 40","24 44","30 40"];default:return["24 24","24 24","24 24"]}}(e);return o.jsx("path",{d:`M ${t} L ${r} L ${a}`,fill:"none",stroke:"currentColor",strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round"})}const ap={title:"Não deu certo desta vez",hint:"Tente se posicionar em um ambiente mais estável.",actions:["Segure o dispositivo firme","Fique de frente para uma luz suave"]},ip={LIVENESS_LOW:{title:"Precisamos ver com mais nitidez",hint:"A prova de vida veio abaixo do esperado.",actions:["Faça o movimento com calma até o fim","Aproxime o rosto sem cortar as bordas"]},NO_FACE_DETECTED:{title:"Não vi seu rosto",hint:"A câmera não conseguiu identificar um rosto na moldura.",actions:["Centralize o rosto no oval","Afaste-se um pouco se estiver muito próximo"]},LOW_LIGHT:{title:"A luz está baixa demais",hint:"Falta contraste para o algoritmo distinguir seu rosto.",actions:["Fique de frente para uma janela ou lâmpada","Evite luz vindo por trás — deixa o rosto em sombra"]},LOOK_STRAIGHT:{title:"Olhe direto para a câmera",hint:"O rosto está um pouco de lado para reconhecimento facial.",actions:["Fique de frente para a câmera","Mantenha o queixo paralelo ao chão"]},RECOGNITION_FAILED:{title:"Não consegui confirmar",hint:"A imagem não bate com o cadastro que temos.",actions:["Retire óculos ou máscara temporariamente","Faça em um lugar mais iluminado"]},INVALID_TOKEN:{title:"Sessão expirada",hint:"A conexão com o serviço perdeu validade.",actions:["Volte à tela anterior e tente novamente","Se persistir, entre em contato com o suporte"]},NETWORK:{title:"A conexão está oscilando",hint:"A imagem não chegou até nosso servidor.",actions:["Verifique a rede do dispositivo","Repita a captura em alguns segundos"]}};const sp={chrome:"Clique no cadeado da barra de endereço → Configurações do site → Câmera → Permitir. Recarregue a página.",edge:"Clique no cadeado da barra de endereço → Permissões do site → Câmera → Permitir. Recarregue a página.",firefox:'Clique no ícone da câmera bloqueada na barra de endereço e escolha "Permitir". Recarregue a página.',safari:"Menu Safari → Configurações → Sites → Câmera → Permitir para este site. Recarregue a página.",unknown:'Abra as configurações do navegador, procure por "câmera" e permita o acesso para este site. Depois recarregue a página.'};function cp(){n.useEffect((()=>{al(),il("neofaceid-state-views-styles",'\n.neofaceid-root .nfid-state {\n display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;\n padding: 8px 8px 4px;\n}\n.neofaceid-root .nfid-state h2 {\n margin: 6px 0 0; font-size: 20px; font-weight: 700; color: var(--nfid-text); line-height: 1.25;\n letter-spacing: -0.015em;\n}\n.neofaceid-root .nfid-state p {\n margin: 0; font-size: 14px; color: var(--nfid-text-muted); line-height: 1.5;\n}\n.neofaceid-root .nfid-state-actions {\n display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 12px;\n}\n.neofaceid-root .nfid-state-actions--row {\n flex-direction: row; justify-content: center;\n}\n.neofaceid-root .nfid-state-icon-success {\n width: 64px; height: 64px; color: #0E9F6E;\n animation: nfidCelebrate 500ms cubic-bezier(.2,1.4,.4,1) both;\n}\n@keyframes nfidCelebrate {\n 0% { transform: scale(0.6); opacity: 0; }\n 60% { transform: scale(1.08); opacity: 1; }\n 100% { transform: scale(1); }\n}\n.neofaceid-root .nfid-state-warn-icon { width: 56px; height: 56px; color: #F1BE00; }\n.neofaceid-root .nfid-state-cameraoff-icon { width: 56px; height: 56px; color: var(--nfid-text-muted); }\n.neofaceid-root .nfid-state-hints {\n display: flex; flex-direction: column; gap: 6px; margin-top: 8px; text-align: left; width: 100%;\n}\n.neofaceid-root .nfid-state-hint {\n display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--nfid-text);\n padding: 8px 12px; background: var(--nfid-surface-muted); border-radius: 12px;\n}\n.neofaceid-root .nfid-state-hint::before { content: "•"; color: var(--nfid-action); font-weight: 700; }\n.neofaceid-root .nfid-state-attempt {\n font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;\n color: var(--nfid-text-subtle);\n}\n.neofaceid-root .nfid-state-techcode {\n font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n font-size: 11px; color: var(--nfid-text-subtle); margin-top: 8px;\n}\n')}),[])}function lp({appName:e,onContinue:n}){return cp(),o.jsxs("div",{className:"nfid-state",role:"status","aria-live":"polite",children:[o.jsxs("svg",{className:"nfid-state-icon-success",viewBox:"0 0 64 64",fill:"none",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("circle",{cx:"32",cy:"32",r:"28"}),o.jsx("path",{d:"M20 33 L28 41 L44 24"})]}),o.jsx("h2",{children:"Identidade confirmada"}),o.jsxs("p",{children:["Você já pode continuar no ",e,"."]}),o.jsx("div",{className:"nfid-state-actions",children:o.jsx(ru,{variant:"primary",onClick:n,children:"Continuar"})})]})}function dp({errorCode:e,attempt:n,maxAttempts:t,timestamp:r,onRetry:a,onFallback:i}){cp();const s=function(e){if(!e)return ap;const n=e.toUpperCase();return ip[n]??ap}(e),c=r??new Date;return o.jsxs("div",{className:"nfid-state",role:"alert","aria-live":"assertive",children:[o.jsxs(au,{tone:"attention",children:["Tentativa ",n," de ",t]}),o.jsxs("svg",{className:"nfid-state-warn-icon",viewBox:"0 0 64 64",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("path",{d:"M32 8 L58 54 H6 Z"}),o.jsx("path",{d:"M32 26 V38"}),o.jsx("circle",{cx:"32",cy:"45",r:"2",fill:"currentColor"})]}),o.jsx("h2",{children:s.title}),o.jsx("p",{children:s.hint}),o.jsxs("div",{className:"nfid-state-hints","aria-label":"O que fazer",children:[o.jsx("div",{className:"nfid-state-hint",children:s.actions[0]}),o.jsx("div",{className:"nfid-state-hint",children:s.actions[1]})]}),o.jsxs("div",{className:"nfid-state-actions",children:[o.jsx(ru,{variant:"primary",onClick:a,children:"Tentar de novo"}),o.jsx(ru,{variant:"ghost",onClick:i,children:"Verificar de outro jeito"})]}),o.jsxs("p",{className:"nfid-state-techcode",children:[(e??"UNKNOWN").toUpperCase()," · ",(l=c,`${String(l.getHours()).padStart(2,"0")}:${String(l.getMinutes()).padStart(2,"0")}:${String(l.getSeconds()).padStart(2,"0")}`)]})]});var l}function up({browser:e,onFallback:n,onCancel:t}){cp();const r=function(e){return sp[e]}(e??function(e=navigator.userAgent){const n=e.toLowerCase();return n.includes("edg/")?"edge":n.includes("firefox")?"firefox":n.includes("chrome")&&!n.includes("edg/")?"chrome":n.includes("safari")&&!n.includes("chrome")?"safari":"unknown"}());return o.jsxs("div",{className:"nfid-state",role:"alert","aria-live":"assertive",children:[o.jsxs("svg",{className:"nfid-state-cameraoff-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("path",{d:"m3 3 18 18"}),o.jsx("path",{d:"M20.66 15.34A2 2 0 0 0 22 13.5V7.5a2 2 0 0 0-3.13-1.65L15 8.5"}),o.jsx("path",{d:"M9 6H4a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-1"})]}),o.jsx("h2",{children:"Câmera bloqueada"}),o.jsx("p",{children:"Precisamos da câmera para confirmar que é você."}),o.jsx("p",{style:{marginTop:8},children:r}),o.jsxs("div",{className:"nfid-state-actions",children:[o.jsx(ru,{variant:"primary",onClick:n,children:"Verificar de outro jeito"}),o.jsx(ru,{variant:"ghost",onClick:t,children:"Agora não"})]})]})}const pp={center:"center",turn_right:"turn_right",turn_left:"turn_left",look_up:"look_up",look_down:"look_down",blink:"blink",move_closer:"move_closer",smile:"blink",open_mouth:"blink"},fp={center:"Centralize seu rosto no oval",turn_right:"Vire lentamente o rosto para a direita",turn_left:"Vire lentamente o rosto para a esquerda",look_up:"Olhe para cima",look_down:"Olhe para baixo",blink:"Pisque os olhos",move_closer:"Aproxime-se da câmera",smile:"Sorria para a câmera",open_mouth:"Abra a boca"};function hp({applicationToken:e,appName:t,amount:r,onChallengeStart:a,onChallengeComplete:i,onSuccess:s,onError:c,onCancel:l,autoLighting:d=!0,onClose:u}){const p=n.useRef(null),[f,h]=n.useState(0),[m,g]=n.useState(null),[v,w]=n.useState("preparing"),[b,x]=n.useState(1),[y,_]=n.useState(void 0),[k,E]=n.useState(void 0),[T,N]=n.useState(0),S=n.useRef(!1),[C,I]=n.useState(!1),{flashOn:R}=td(p,{enabled:d&&!C&&"challenging"===v}),O=wl(),j=t??gl()??"sua aplicação",A="number"==typeof r&&Number.isFinite(r)?function(e,n){try{return new Intl.NumberFormat(n,{style:"currency",currency:"BRL"}).format(e)}catch{return`R$ ${e.toFixed(2)}`}}(r,O):null;n.useEffect((()=>{al(),il("neofaceid-authorize-styles","\n .neofaceid-root .nfid-authorize-header { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }\n .neofaceid-root .nfid-authorize-appname { font-size: 15px; font-weight: 700; color: var(--nfid-text); line-height: 1.2; }\n .neofaceid-root .nfid-authorize-amount { font-size: 13px; color: var(--nfid-text-muted); }\n .neofaceid-root .nfid-authorize-brand { font-size: 10px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--nfid-text-subtle); }\n .neofaceid-root .nfid-authorize-video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }\n .neofaceid-root .nfid-authorize-instruction { margin: 20px 0 0; font-size: 17px; font-weight: 600; color: var(--nfid-text); text-align: center; line-height: 1.3; }\n .neofaceid-root .nfid-authorize-support { margin: 6px 0 0; font-size: 13px; color: var(--nfid-text-muted); text-align: center; }\n .neofaceid-root .nfid-authorize-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; align-items: center; }\n .neofaceid-root .nfid-authorize-footer { display: flex; justify-content: center; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--nfid-line); }\n .neofaceid-root .nfid-authorize-seal { font-size: 10px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--nfid-text-subtle); }\n .neofaceid-root .nfid-authorize-close {\n position: absolute; top: 8px; right: 8px;\n min-width: 44px; min-height: 44px;\n background: transparent; border: none;\n display: inline-flex; align-items: center; justify-content: center;\n color: var(--nfid-text-muted); cursor: pointer; border-radius: 22px;\n }\n .neofaceid-root .nfid-authorize-close:hover { background: var(--nfid-surface-muted); }\n .neofaceid-root .nfid-authorize-close:focus-visible { outline: 2px solid var(--nfid-focus-ring); outline-offset: 2px; }\n @media (prefers-reduced-motion: reduce) {\n .neofaceid-root svg circle { transition: none !important; }\n }\n ")}),[]),n.useEffect((()=>{let n=null;return S.current=!1,w("preparing"),h(0),g(null),async function(){try{try{n=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:{ideal:1280},height:{ideal:720}}})}catch(t){const e=function(e){if(!e||"object"!=typeof e)return"UNKNOWN";const n=(e.name??"").toString();return"NotAllowedError"===n||"SecurityError"===n?"PERMISSION_DENIED":"NotFoundError"===n||"OverconstrainedError"===n?"NO_CAMERA":"NotReadableError"===n||"TrackStartError"===n?"IN_USE":"UNKNOWN"}(t);if("PERMISSION_DENIED"===e)return void w("permission-denied");throw new io("NO_CAMERA"===e?"Câmera não encontrada":"IN_USE"===e?"Câmera em uso por outro app":"Falha ao acessar a câmera",ao.CAMERA_ERROR)}p.current&&(p.current.srcObject=n,p.current.play().catch((()=>{}))),w("challenging");const o=await Wu({applicationToken:e,purpose:"authorization",collectFramesForGesture:async(e,n,t)=>{if(S.current)throw new io("Cancelado",ao.UNKNOWN);g(e),h(0),a&&a(e,n,t),await async function(e){const n=1500,t=Date.now();return new Promise((o=>{const r=()=>{const a=Date.now()-t,i=Math.min(1,a/n);e(i),a>=n?o():setTimeout(r,50)};r()}))}(h),i&&i(e,n,t);const o=await async function(e){if(!e||0===e.videoWidth)return null;const n=document.createElement("canvas");n.width=e.videoWidth,n.height=e.videoHeight;const t=n.getContext("2d");return t?(t.drawImage(e,0,0),n.toDataURL("image/jpeg",.85)):null}(p.current);return o?[o]:[]}});n&&n.getTracks().forEach((e=>e.stop())),n=null,w("success"),s&&s(o)}catch(o){if(S.current)return;const e=o instanceof io?o:new io(o instanceof Error?o.message:"Falha",ao.UNKNOWN);_(e.type),E(new Date),w("failure"),c&&c(e)}finally{n&&n.getTracks().forEach((e=>e.stop()))}}(),()=>{S.current=!0,n&&n.getTracks().forEach((e=>e.stop()))}}),[T]);const P=()=>{S.current=!0,l&&l(),u()},F=()=>{b>=3?P():(x((e=>e+1)),_(void 0),E(void 0),N((e=>e+1)))},z=()=>{S.current=!0,c&&c(new io("Fluxo alternativo solicitado pelo usuário",ao.CONSENT_DENIED)),u()},$=m?pp[m.gesture_key]??"center":"center",D=m?fp[m.gesture_key]??"Siga a instrução":"Preparando a câmera…";return"success"===v?o.jsx(Xd,{open:!0,dismissOnOverlay:!1,ariaLabel:"Identidade confirmada",children:o.jsx(lp,{appName:j,onContinue:u})}):"permission-denied"===v?o.jsx(Xd,{open:!0,dismissOnOverlay:!1,ariaLabel:"Câmera bloqueada",children:o.jsx(up,{onFallback:z,onCancel:P})}):"failure"===v?o.jsx(Xd,{open:!0,dismissOnOverlay:!1,ariaLabel:"Não foi possível confirmar",children:o.jsx(dp,{errorCode:y,attempt:b,maxAttempts:3,timestamp:k,onRetry:F,onFallback:z})}):o.jsxs(Xd,{open:!0,onDismiss:void 0,dismissOnOverlay:!1,ariaLabel:"Autorização por biometria",children:[o.jsx(od,{active:R,onDismiss:()=>I(!0)}),o.jsxs("div",{style:{position:"relative"},children:[o.jsx("button",{type:"button",className:"nfid-authorize-close",onClick:P,"aria-label":"Cancelar autorização",children:o.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:o.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})}),o.jsxs("div",{className:"nfid-authorize-header",children:[o.jsx("span",{className:"nfid-authorize-appname",children:j}),A&&o.jsxs("span",{className:"nfid-authorize-amount",children:["Autorizando ",A]}),o.jsx("span",{className:"nfid-authorize-brand",children:"NeoFaceID"})]}),o.jsx("div",{style:{display:"flex",justifyContent:"center"},children:o.jsx(Qu,{progress:f,size:220,children:o.jsx("video",{ref:p,className:"nfid-authorize-video",autoPlay:!0,muted:!0,playsInline:!0})})}),o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:12,marginTop:16},children:[o.jsx(ep,{gesture:$,size:40}),o.jsx("p",{className:"nfid-authorize-instruction","aria-live":"assertive",style:{margin:0},children:D})]}),"preparing"===v&&o.jsx("p",{className:"nfid-authorize-support",children:"Ligando sua câmera…"}),o.jsx("div",{className:"nfid-authorize-actions",children:o.jsx(ru,{variant:"ghost",onClick:P,children:"Não consigo fazer esse movimento"})}),o.jsx("div",{className:"nfid-authorize-footer",children:o.jsx(gd,{})})]})]})}const mp={RG:{name:"Documento de Identidade (RG / CIN / CPF)",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 Documento",backLabel:"Verso do Documento"},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:"Cartão CPF (Apenas Frente)",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 gp{constructor(e){l(this,"overlay",null),l(this,"video",null),l(this,"canvas",null),l(this,"stream",null),l(this,"resolvePromise",null),l(this,"options"),l(this,"selectedDocument",null),l(this,"currentStep","select"),l(this,"flashController",null),l(this,"frontBlob",null),l(this,"backBlob",null),l(this,"_previewObjectUrl",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(){if(!this.options.skipConsent){if(!(await Gd({appName:this.options.appName,flow:"verification"})))throw new io("Consentimento recusado pelo usuário.",ao.CONSENT_DENIED)}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");e.className="neoface-doc-overlay",e.innerHTML='\n <div class="neoface-doc-modal">\n <div class="neoface-doc-content"></div>\n </div>\n ',al(),il("neoface-doc-styles-v2",this.getStyles()),e.classList.add("neofaceid-root"),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(mp).filter((([e])=>"CPF"!==e)).map((([e,n])=>`\n <button class="neoface-doc-select-option" data-type="${e}">\n <span class="neoface-doc-select-icon">${n.icon}</span>\n <span class="neoface-doc-select-name">${n.name}</span>\n <svg class="neoface-doc-select-arrow" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg>\n </button>\n `)).join("")}\n </div>\n \n <div class="neoface-doc-tips">\n <div class="neoface-doc-tip">\n <span>Garanta boa iluminação e que todos os dados estejam legíveis</span>\n </div>\n </div>\n </div>\n \n ${this.renderBranding()}\n `}renderCaptureStep(){const e=this.selectedDocument?mp[this.selectedDocument]:null;if(!e)return"";const n="back"===this.currentStep,t=n?e.backLabel:e.frontLabel;return`\n <div class="neoface-doc-header">\n <div class="neoface-doc-header-left">\n <div class="neoface-doc-step-indicator">\n <span class="neoface-doc-step-badge">${n?2:1}/${e.hasBack?2:1}</span>\n <span class="neoface-doc-step-label">${t}</span>\n </div>\n </div>\n <button class="neoface-doc-close-btn" aria-label="Fechar">\n <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M18 6L6 18M6 6l12 12"/>\n </svg>\n </button>\n </div>\n \n <div class="neoface-doc-body">\n <div class="neoface-doc-camera-container">\n <video class="neoface-doc-video" autoplay muted playsinline></video>\n <canvas class="neoface-doc-canvas"></canvas>\n \n <div class="neoface-doc-guide">\n <div class="neoface-doc-frame">\n <div class="neoface-doc-corner neoface-doc-corner-tl"></div>\n <div class="neoface-doc-corner neoface-doc-corner-tr"></div>\n <div class="neoface-doc-corner neoface-doc-corner-bl"></div>\n <div class="neoface-doc-corner neoface-doc-corner-br"></div>\n <div class="neoface-doc-frame-label">${t}</div>\n </div>\n </div>\n \n <div class="neoface-doc-loading" style="display:none">\n <div class="neoface-doc-spinner"></div>\n </div>\n </div>\n \n <div class="neoface-doc-instructions">\n <div class="neoface-doc-instruction">\n <svg class="neoface-doc-instruction-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18M9 21V9"/></svg>\n <span>Posicione o documento dentro do quadro</span>\n </div>\n <div class="neoface-doc-instruction">\n <svg class="neoface-doc-instruction-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="5"/><path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"/></svg>\n <span>Sem reflexo do flash sobre o texto</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?mp[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" alt="Prévia do documento capturado" />\n </div>\n\n <h3 class="neoface-doc-preview-question" id="neoface-doc-preview-question">Está legível?</h3>\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>Confira se dá para ler nome, número e data sem esforço.</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-primary 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?"Sim, enviar":"Sim, próximo"}\n </button>\n </div>\n \n ${this.renderBranding()}\n `}renderBranding(){return`\n <div class="neoface-doc-branding">\n ${vd()}\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 r=null==(e=this.overlay)?void 0:e.querySelector(".neoface-doc-capture-btn"),a=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==r||r.addEventListener("click",(()=>this.handleCapture())),null==a||a.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 r=null==(t=this.overlay)?void 0:t.querySelector(".neoface-doc-loading");r&&(r.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(a){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 xl(e,(e=>new Promise(((n,t)=>{const o=new Image;o.onload=()=>{const e=1280;let{width:r}=o,{height:a}=o;r>a&&r>e?(a=a*e/r,r=e):a>e&&(r=r*e/a,a=e);const i=document.createElement("canvas");i.width=r,i.height=a;const s=i.getContext("2d");s?(s.drawImage(o,0,0,r,a),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=e}))))}bindPreviewEvents(){var e,n,t;const o=null==(e=this.overlay)?void 0:e.querySelector(".neoface-doc-confirm-btn"),r=null==(n=this.overlay)?void 0:n.querySelector(".neoface-doc-retake-btn");null==o||o.addEventListener("click",(()=>this.handleConfirm())),null==r||r.addEventListener("click",(()=>this.handleRetake()));const a=null==(t=this.overlay)?void 0:t.querySelector(".neoface-doc-preview-current");if(a){const e="preview-front"===this.currentStep?this.frontBlob:this.backBlob;e&&(this._previewObjectUrl&&(URL.revokeObjectURL(this._previewObjectUrl),this._previewObjectUrl=null),this._previewObjectUrl=URL.createObjectURL(e),a.src=this._previewObjectUrl)}this.bindCloseEvent()}bindCloseEvent(){var e;const n=null==(e=this.overlay)?void 0:e.querySelector(".neoface-doc-close-btn");null==n||n.addEventListener("click",(()=>this.handleCancel()))}async startCamera(){var e,n,t;try{const t={video:{facingMode:this.options.useBackCamera?"environment":"user",width:{ideal:1920},height:{ideal:1080}},audio:!1};this.stream=await navigator.mediaDevices.getUserMedia(t),this.video=null==(e=this.overlay)?void 0:e.querySelector(".neoface-doc-video"),this.canvas=null==(n=this.overlay)?void 0:n.querySelector(".neoface-doc-canvas"),this.video&&(this.video.muted=!0,this.video.playsInline=!0,this.video.srcObject=this.stream,await this.video.play(),this.startScreenFlash())}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(),this.startScreenFlash())}catch(r){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.flashController&&(this.flashController.destroy(),this.flashController=null),this.stream&&(this.stream.getTracks().forEach((e=>e.stop())),this.stream=null)}startScreenFlash(){!1!==this.options.autoLighting&&(this.flashController||(this.flashController=Fu((()=>this.video)),this.flashController.start()))}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{videoWidth:o}=this.video,{videoHeight:r}=this.video,a=Math.floor(.75*o),i=Math.floor(.65*r),s=Math.floor((o-a)/2),c=Math.floor((r-i)/2);this.canvas.width=a,this.canvas.height=i,t.drawImage(this.video,s,c,a,i,0,0,a,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(l){}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?mp[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._previewObjectUrl&&(URL.revokeObjectURL(this._previewObjectUrl),this._previewObjectUrl=null),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: inherit;\n padding: 16px;\n }\n \n .neoface-doc-modal {\n background: linear-gradient(145deg, #0A1320 0%, #111C2B 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, #0091F6, #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, 145, 246, 0.1);\n border-color: rgba(0, 145, 246, 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, 145, 246, 0.15);\n border-radius: 12px;\n color: #0091F6;\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: #0091F6;\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, 145, 246, 0.08);\n border: 1px solid rgba(0, 145, 246, 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: #0091F6;\n flex-shrink: 0;\n }\n \n /* Camera — ISO/IEC 7810 ID-1 (85.60 × 53.98 mm ≈ 1.586:1) */\n .neoface-doc-camera-container {\n position: relative;\n background: #000;\n border-radius: 16px;\n overflow: hidden;\n aspect-ratio: 1.586 / 1;\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 /* Moldura Focus Frame — proporção ID-1 (1.586:1), sem borda contínua. */\n .neoface-doc-frame {\n width: 82%;\n aspect-ratio: 1.586 / 1;\n position: relative;\n border-radius: 12px;\n }\n\n .neoface-doc-corner {\n position: absolute;\n width: 28px;\n height: 28px;\n border-color: var(--nfid-action, #0059C4);\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: #0091F6;\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: #0091F6;\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, 145, 246, 0.3);\n box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);\n }\n \n .neoface-doc-preview-question {\n margin: 12px 0 4px;\n font-size: 17px;\n font-weight: 700;\n color: var(--nfid-text, #0A1320);\n text-align: center;\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, 145, 246, 0.08);\n border: 1px solid rgba(0, 145, 246, 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: #0091F6;\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, #0091F6 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, 145, 246, 0.4);\n }\n \n .neoface-doc-btn-success {\n background: linear-gradient(135deg, #0E9F6E 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: #0091F6;\n letter-spacing: 1px;\n }\n \n /* Mobile */\n @media (max-width: 500px) {\n .neoface-doc-modal {\n border-radius: 20px;\n }\n \n .neoface-doc-header,\n .neoface-doc-body,\n .neoface-doc-footer {\n padding: 16px 18px;\n }\n \n .neoface-doc-preview-grid.has-back {\n grid-template-columns: 1fr;\n }\n }\n "}}const vp=async e=>new gp(e).open(),wp=Object.freeze(Object.defineProperty({__proto__:null,DocumentCaptureModal:gp,startDocumentCapture:vp},Symbol.toStringTag,{value:"Module"})),bp="Consentimento recusado pelo usuário.";const xp=function(e,n){let t=e;const o=Tp[n];let r=null,a=0,i=null;const s=[],c={},l=function(e,n){a=4*t+17,r=function(e){const n=new Array(e);for(let t=0;t<e;t+=1){n[t]=new Array(e);for(let o=0;o<e;o+=1)n[t][o]=null}return n}(a),d(0,0),d(a-7,0),d(0,a-7),p(),u(),h(e,n),t>=7&&f(e),null==i&&(i=g(t,o,s)),m(i,n)},d=function(e,n){for(let t=-1;t<=7;t+=1)if(!(e+t<=-1||a<=e+t))for(let o=-1;o<=7;o+=1)n+o<=-1||a<=n+o||(r[e+t][n+o]=0<=t&&t<=6&&(0==o||6==o)||0<=o&&o<=6&&(0==t||6==t)||2<=t&&t<=4&&2<=o&&o<=4)},u=function(){for(let e=8;e<a-8;e+=1)null==r[e][6]&&(r[e][6]=e%2==0);for(let e=8;e<a-8;e+=1)null==r[6][e]&&(r[6][e]=e%2==0)},p=function(){const e=Pp.getPatternPosition(t);for(let n=0;n<e.length;n+=1)for(let t=0;t<e.length;t+=1){const o=e[n],a=e[t];if(null==r[o][a])for(let e=-2;e<=2;e+=1)for(let n=-2;n<=2;n+=1)r[o+e][a+n]=-2==e||2==e||-2==n||2==n||0==e&&0==n}},f=function(e){const n=Pp.getBCHTypeNumber(t);for(let t=0;t<18;t+=1){const o=!e&&1==(n>>t&1);r[Math.floor(t/3)][t%3+a-8-3]=o}for(let t=0;t<18;t+=1){const o=!e&&1==(n>>t&1);r[t%3+a-8-3][Math.floor(t/3)]=o}},h=function(e,n){const t=o<<3|n,i=Pp.getBCHTypeInfo(t);for(let o=0;o<15;o+=1){const n=!e&&1==(i>>o&1);o<6?r[o][8]=n:o<8?r[o+1][8]=n:r[a-15+o][8]=n}for(let o=0;o<15;o+=1){const n=!e&&1==(i>>o&1);o<8?r[8][a-o-1]=n:o<9?r[8][15-o-1+1]=n:r[8][15-o-1]=n}r[a-8][8]=!e},m=function(e,n){let t=-1,o=a-1,i=7,s=0;const c=Pp.getMaskFunction(n);for(let l=a-1;l>0;l-=2)for(6==l&&(l-=1);;){for(let n=0;n<2;n+=1)if(null==r[o][l-n]){let t=!1;s<e.length&&(t=1==(e[s]>>>i&1));c(o,l-n)&&(t=!t),r[o][l-n]=t,i-=1,-1==i&&(s+=1,i=7)}if(o+=t,o<0||a<=o){o-=t,t=-t;break}}},g=function(e,n,t){const o=$p.getRSBlocks(e,n),r=Dp();for(let i=0;i<t.length;i+=1){const n=t[i];r.put(n.getMode(),4),r.put(n.getLength(),Pp.getLengthInBits(n.getMode(),e)),n.write(r)}let a=0;for(let i=0;i<o.length;i+=1)a+=o[i].dataCount;if(r.getLengthInBits()>8*a)throw"code length overflow. ("+r.getLengthInBits()+">"+8*a+")";for(r.getLengthInBits()+4<=8*a&&r.put(0,4);r.getLengthInBits()%8!=0;)r.putBit(!1);for(;!(r.getLengthInBits()>=8*a||(r.put(236,8),r.getLengthInBits()>=8*a));)r.put(17,8);return function(e,n){let t=0,o=0,r=0;const a=new Array(n.length),i=new Array(n.length);for(let d=0;d<n.length;d+=1){const s=n[d].dataCount,c=n[d].totalCount-s;o=Math.max(o,s),r=Math.max(r,c),a[d]=new Array(s);for(let n=0;n<a[d].length;n+=1)a[d][n]=255&e.getBuffer()[n+t];t+=s;const l=Pp.getErrorCorrectPolynomial(c),u=zp(a[d],l.getLength()-1).mod(l);i[d]=new Array(l.getLength()-1);for(let e=0;e<i[d].length;e+=1){const n=e+u.getLength()-i[d].length;i[d][e]=n>=0?u.getAt(n):0}}let s=0;for(let d=0;d<n.length;d+=1)s+=n[d].totalCount;const c=new Array(s);let l=0;for(let d=0;d<o;d+=1)for(let e=0;e<n.length;e+=1)d<a[e].length&&(c[l]=a[e][d],l+=1);for(let d=0;d<r;d+=1)for(let e=0;e<n.length;e+=1)d<i[e].length&&(c[l]=i[e][d],l+=1);return c}(r,o)};c.addData=function(e,n){let t=null;switch(n=n||"Byte"){case"Numeric":t=Mp(e);break;case"Alphanumeric":t=Lp(e);break;case"Byte":t=Bp(e);break;case"Kanji":t=Wp(e);break;default:throw"mode:"+n}s.push(t),i=null},c.isDark=function(e,n){if(e<0||a<=e||n<0||a<=n)throw e+","+n;return r[e][n]},c.getModuleCount=function(){return a},c.make=function(){if(t<1){let e=1;for(;e<40;e++){const n=$p.getRSBlocks(e,o),t=Dp();for(let o=0;o<s.length;o++){const n=s[o];t.put(n.getMode(),4),t.put(n.getLength(),Pp.getLengthInBits(n.getMode(),e)),n.write(t)}let r=0;for(let e=0;e<n.length;e++)r+=n[e].dataCount;if(t.getLengthInBits()<=8*r)break}t=e}l(!1,function(){let e=0,n=0;for(let t=0;t<8;t+=1){l(!0,t);const o=Pp.getLostPoint(c);(0==t||e>o)&&(e=o,n=t)}return n}())},c.createTableTag=function(e,n){e=e||2;let t="";t+='<table style="',t+=" border-width: 0px; border-style: none;",t+=" border-collapse: collapse;",t+=" padding: 0px; margin: "+(n=void 0===n?4*e:n)+"px;",t+='">',t+="<tbody>";for(let o=0;o<c.getModuleCount();o+=1){t+="<tr>";for(let n=0;n<c.getModuleCount();n+=1)t+='<td style="',t+=" border-width: 0px; border-style: none;",t+=" border-collapse: collapse;",t+=" padding: 0px; margin: 0px;",t+=" width: "+e+"px;",t+=" height: "+e+"px;",t+=" background-color: ",t+=c.isDark(o,n)?"#000000":"#ffffff",t+=";",t+='"/>';t+="</tr>"}return t+="</tbody>",t+="</table>",t},c.createSvgTag=function(e,n,t,o){let r={};"object"==typeof arguments[0]&&(r=arguments[0],e=r.cellSize,n=r.margin,t=r.alt,o=r.title),e=e||2,n=void 0===n?4*e:n,(t="string"==typeof t?{text:t}:t||{}).text=t.text||null,t.id=t.text?t.id||"qrcode-description":null,(o="string"==typeof o?{text:o}:o||{}).text=o.text||null,o.id=o.text?o.id||"qrcode-title":null;const a=c.getModuleCount()*e+2*n;let i,s,l,d,u,p="";for(u="l"+e+",0 0,"+e+" -"+e+",0 0,-"+e+"z ",p+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',p+=r.scalable?"":' width="'+a+'px" height="'+a+'px"',p+=' viewBox="0 0 '+a+" "+a+'" ',p+=' preserveAspectRatio="xMinYMin meet"',p+=o.text||t.text?' role="img" aria-labelledby="'+v([o.id,t.id].join(" ").trim())+'"':"",p+=">",p+=o.text?'<title id="'+v(o.id)+'">'+v(o.text)+"</title>":"",p+=t.text?'<description id="'+v(t.id)+'">'+v(t.text)+"</description>":"",p+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',p+='<path d="',l=0;l<c.getModuleCount();l+=1)for(d=l*e+n,i=0;i<c.getModuleCount();i+=1)c.isDark(l,i)&&(s=i*e+n,p+="M"+s+","+d+u);return p+='" stroke="transparent" fill="black"/>',p+="</svg>",p},c.createDataURL=function(e,n){e=e||2,n=void 0===n?4*e:n;const t=c.getModuleCount()*e+2*n,o=n,r=t-n;return Vp(t,t,(function(n,t){if(o<=n&&n<r&&o<=t&&t<r){const r=Math.floor((n-o)/e),a=Math.floor((t-o)/e);return c.isDark(a,r)?0:1}return 1}))},c.createImgTag=function(e,n,t){e=e||2,n=void 0===n?4*e:n;const o=c.getModuleCount()*e+2*n;let r="";return r+="<img",r+=' src="',r+=c.createDataURL(e,n),r+='"',r+=' width="',r+=o,r+='"',r+=' height="',r+=o,r+='"',t&&(r+=' alt="',r+=v(t),r+='"'),r+="/>",r};const v=function(e){let n="";for(let t=0;t<e.length;t+=1){const o=e.charAt(t);switch(o){case"<":n+="&lt;";break;case">":n+="&gt;";break;case"&":n+="&amp;";break;case'"':n+="&quot;";break;default:n+=o}}return n};return c.createASCII=function(e,n){if((e=e||1)<2)return function(e){e=void 0===e?2:e;const n=1*c.getModuleCount()+2*e,t=e,o=n-e;let r,a,i,s,l;const d={"██":"█","█ ":"▀"," █":"▄"," ":" "},u={"██":"▀","█ ":"▀"," █":" "," ":" "};let p="";for(r=0;r<n;r+=2){for(i=Math.floor((r-t)/1),s=Math.floor((r+1-t)/1),a=0;a<n;a+=1)l="█",t<=a&&a<o&&t<=r&&r<o&&c.isDark(i,Math.floor((a-t)/1))&&(l=" "),t<=a&&a<o&&t<=r+1&&r+1<o&&c.isDark(s,Math.floor((a-t)/1))?l+=" ":l+="█",p+=e<1&&r+1>=o?u[l]:d[l];p+="\n"}return n%2&&e>0?p.substring(0,p.length-n-1)+Array(n+1).join("▀"):p.substring(0,p.length-1)}(n);e-=1,n=void 0===n?2*e:n;const t=c.getModuleCount()*e+2*n,o=n,r=t-n;let a,i,s,l;const d=Array(e+1).join("██"),u=Array(e+1).join(" ");let p="",f="";for(a=0;a<t;a+=1){for(s=Math.floor((a-o)/e),f="",i=0;i<t;i+=1)l=1,o<=i&&i<r&&o<=a&&a<r&&c.isDark(s,Math.floor((i-o)/e))&&(l=0),f+=l?d:u;for(s=0;s<e;s+=1)p+=f+"\n"}return p.substring(0,p.length-1)},c.renderTo2dContext=function(e,n){n=n||2;const t=c.getModuleCount();for(let o=0;o<t;o++)for(let r=0;r<t;r++)e.fillStyle=c.isDark(o,r)?"black":"white",e.fillRect(r*n,o*n,n,n)},c};xp.stringToBytes=function(e){const n=[];for(let t=0;t<e.length;t+=1){const o=e.charCodeAt(t);n.push(255&o)}return n},xp.createStringToBytes=function(e,n){const t=function(){const t=Up(e),o=function(){const e=t.read();if(-1==e)throw"eof";return e};let r=0;const a={};for(;;){const e=t.read();if(-1==e)break;const n=o(),i=o()<<8|o();a[String.fromCharCode(e<<8|n)]=i,r+=1}if(r!=n)throw r+" != "+n;return a}(),o="?".charCodeAt(0);return function(e){const n=[];for(let r=0;r<e.length;r+=1){const a=e.charCodeAt(r);if(a<128)n.push(a);else{const a=t[e.charAt(r)];"number"==typeof a?(255&a)==a?n.push(a):(n.push(a>>>8),n.push(255&a)):n.push(o)}}return n}};const yp=1,_p=2,kp=4,Ep=8,Tp={L:1,M:0,Q:3,H:2},Np=0,Sp=1,Cp=2,Ip=3,Rp=4,Op=5,jp=6,Ap=7,Pp=function(){const e=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],n=1335,t=7973,o={},r=function(e){let n=0;for(;0!=e;)n+=1,e>>>=1;return n};return o.getBCHTypeInfo=function(e){let t=e<<10;for(;r(t)-r(n)>=0;)t^=n<<r(t)-r(n);return 21522^(e<<10|t)},o.getBCHTypeNumber=function(e){let n=e<<12;for(;r(n)-r(t)>=0;)n^=t<<r(n)-r(t);return e<<12|n},o.getPatternPosition=function(n){return e[n-1]},o.getMaskFunction=function(e){switch(e){case Np:return function(e,n){return(e+n)%2==0};case Sp:return function(e,n){return e%2==0};case Cp:return function(e,n){return n%3==0};case Ip:return function(e,n){return(e+n)%3==0};case Rp:return function(e,n){return(Math.floor(e/2)+Math.floor(n/3))%2==0};case Op:return function(e,n){return e*n%2+e*n%3==0};case jp:return function(e,n){return(e*n%2+e*n%3)%2==0};case Ap:return function(e,n){return(e*n%3+(e+n)%2)%2==0};default:throw"bad maskPattern:"+e}},o.getErrorCorrectPolynomial=function(e){let n=zp([1],0);for(let t=0;t<e;t+=1)n=n.multiply(zp([1,Fp.gexp(t)],0));return n},o.getLengthInBits=function(e,n){if(1<=n&&n<10)switch(e){case yp:return 10;case _p:return 9;case kp:case Ep:return 8;default:throw"mode:"+e}else if(n<27)switch(e){case yp:return 12;case _p:return 11;case kp:return 16;case Ep:return 10;default:throw"mode:"+e}else{if(!(n<41))throw"type:"+n;switch(e){case yp:return 14;case _p:return 13;case kp:return 16;case Ep:return 12;default:throw"mode:"+e}}},o.getLostPoint=function(e){const n=e.getModuleCount();let t=0;for(let r=0;r<n;r+=1)for(let o=0;o<n;o+=1){let a=0;const i=e.isDark(r,o);for(let t=-1;t<=1;t+=1)if(!(r+t<0||n<=r+t))for(let s=-1;s<=1;s+=1)o+s<0||n<=o+s||0==t&&0==s||i==e.isDark(r+t,o+s)&&(a+=1);a>5&&(t+=3+a-5)}for(let r=0;r<n-1;r+=1)for(let o=0;o<n-1;o+=1){let n=0;e.isDark(r,o)&&(n+=1),e.isDark(r+1,o)&&(n+=1),e.isDark(r,o+1)&&(n+=1),e.isDark(r+1,o+1)&&(n+=1),0!=n&&4!=n||(t+=3)}for(let r=0;r<n;r+=1)for(let o=0;o<n-6;o+=1)e.isDark(r,o)&&!e.isDark(r,o+1)&&e.isDark(r,o+2)&&e.isDark(r,o+3)&&e.isDark(r,o+4)&&!e.isDark(r,o+5)&&e.isDark(r,o+6)&&(t+=40);for(let r=0;r<n;r+=1)for(let o=0;o<n-6;o+=1)e.isDark(o,r)&&!e.isDark(o+1,r)&&e.isDark(o+2,r)&&e.isDark(o+3,r)&&e.isDark(o+4,r)&&!e.isDark(o+5,r)&&e.isDark(o+6,r)&&(t+=40);let o=0;for(let r=0;r<n;r+=1)for(let t=0;t<n;t+=1)e.isDark(t,r)&&(o+=1);return t+=10*(Math.abs(100*o/n/n-50)/5),t},o}(),Fp=function(){const e=new Array(256),n=new Array(256);for(let o=0;o<8;o+=1)e[o]=1<<o;for(let o=8;o<256;o+=1)e[o]=e[o-4]^e[o-5]^e[o-6]^e[o-8];for(let o=0;o<255;o+=1)n[e[o]]=o;const t={glog:function(e){if(e<1)throw"glog("+e+")";return n[e]},gexp:function(n){for(;n<0;)n+=255;for(;n>=256;)n-=255;return e[n]}};return t}(),zp=function(e,n){if(void 0===e.length)throw e.length+"/"+n;const t=function(){let t=0;for(;t<e.length&&0==e[t];)t+=1;const o=new Array(e.length-t+n);for(let n=0;n<e.length-t;n+=1)o[n]=e[n+t];return o}(),o={getAt:function(e){return t[e]},getLength:function(){return t.length},multiply:function(e){const n=new Array(o.getLength()+e.getLength()-1);for(let t=0;t<o.getLength();t+=1)for(let r=0;r<e.getLength();r+=1)n[t+r]^=Fp.gexp(Fp.glog(o.getAt(t))+Fp.glog(e.getAt(r)));return zp(n,0)},mod:function(e){if(o.getLength()-e.getLength()<0)return o;const n=Fp.glog(o.getAt(0))-Fp.glog(e.getAt(0)),t=new Array(o.getLength());for(let r=0;r<o.getLength();r+=1)t[r]=o.getAt(r);for(let o=0;o<e.getLength();o+=1)t[o]^=Fp.gexp(Fp.glog(e.getAt(o))+n);return zp(t,0).mod(e)}};return o},$p=function(){const e=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],n=function(e,n){const t={};return t.totalCount=e,t.dataCount=n,t},t={};return t.getRSBlocks=function(t,o){const r=function(n,t){switch(t){case Tp.L:return e[4*(n-1)+0];case Tp.M:return e[4*(n-1)+1];case Tp.Q:return e[4*(n-1)+2];case Tp.H:return e[4*(n-1)+3];default:return}}(t,o);if(void 0===r)throw"bad rs block @ typeNumber:"+t+"/errorCorrectionLevel:"+o;const a=r.length/3,i=[];for(let e=0;e<a;e+=1){const t=r[3*e+0],o=r[3*e+1],a=r[3*e+2];for(let e=0;e<t;e+=1)i.push(n(o,a))}return i},t}(),Dp=function(){const e=[];let n=0;const t={getBuffer:function(){return e},getAt:function(n){const t=Math.floor(n/8);return 1==(e[t]>>>7-n%8&1)},put:function(e,n){for(let o=0;o<n;o+=1)t.putBit(1==(e>>>n-o-1&1))},getLengthInBits:function(){return n},putBit:function(t){const o=Math.floor(n/8);e.length<=o&&e.push(0),t&&(e[o]|=128>>>n%8),n+=1}};return t},Mp=function(e){const n=yp,t=e,o={getMode:function(){return n},getLength:function(e){return t.length},write:function(e){const n=t;let o=0;for(;o+2<n.length;)e.put(r(n.substring(o,o+3)),10),o+=3;o<n.length&&(n.length-o==1?e.put(r(n.substring(o,o+1)),4):n.length-o==2&&e.put(r(n.substring(o,o+2)),7))}},r=function(e){let n=0;for(let t=0;t<e.length;t+=1)n=10*n+a(e.charAt(t));return n},a=function(e){if("0"<=e&&e<="9")return e.charCodeAt(0)-"0".charCodeAt(0);throw"illegal char :"+e};return o},Lp=function(e){const n=_p,t=e,o={getMode:function(){return n},getLength:function(e){return t.length},write:function(e){const n=t;let o=0;for(;o+1<n.length;)e.put(45*r(n.charAt(o))+r(n.charAt(o+1)),11),o+=2;o<n.length&&e.put(r(n.charAt(o)),6)}},r=function(e){if("0"<=e&&e<="9")return e.charCodeAt(0)-"0".charCodeAt(0);if("A"<=e&&e<="Z")return e.charCodeAt(0)-"A".charCodeAt(0)+10;switch(e){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+e}};return o},Bp=function(e){const n=kp,t=xp.stringToBytes(e),o={getMode:function(){return n},getLength:function(e){return t.length},write:function(e){for(let n=0;n<t.length;n+=1)e.put(t[n],8)}};return o},Wp=function(e){const n=Ep,t=xp.stringToBytes;!function(){const e=t("友");if(2!=e.length||38726!=(e[0]<<8|e[1]))throw"sjis not supported."}();const o=t(e),r={getMode:function(){return n},getLength:function(e){return~~(o.length/2)},write:function(e){const n=o;let t=0;for(;t+1<n.length;){let o=(255&n[t])<<8|255&n[t+1];if(33088<=o&&o<=40956)o-=33088;else{if(!(57408<=o&&o<=60351))throw"illegal char at "+(t+1)+"/"+o;o-=49472}o=192*(o>>>8&255)+(255&o),e.put(o,13),t+=2}if(t<n.length)throw"illegal char at "+(t+1)}};return r},qp=function(){const e=[],n={writeByte:function(n){e.push(255&n)},writeShort:function(e){n.writeByte(e),n.writeByte(e>>>8)},writeBytes:function(e,t,o){t=t||0,o=o||e.length;for(let r=0;r<o;r+=1)n.writeByte(e[r+t])},writeString:function(e){for(let t=0;t<e.length;t+=1)n.writeByte(e.charCodeAt(t))},toByteArray:function(){return e},toString:function(){let n="";n+="[";for(let t=0;t<e.length;t+=1)t>0&&(n+=","),n+=e[t];return n+="]",n}};return n},Up=function(e){const n=e;let t=0,o=0,r=0;const a={read:function(){for(;r<8;){if(t>=n.length){if(0==r)return-1;throw"unexpected end of file./"+r}const e=n.charAt(t);if(t+=1,"="==e)return r=0,-1;e.match(/^\s$/)||(o=o<<6|i(e.charCodeAt(0)),r+=6)}const e=o>>>r-8&255;return r-=8,e}},i=function(e){if(65<=e&&e<=90)return e-65;if(97<=e&&e<=122)return e-97+26;if(48<=e&&e<=57)return e-48+52;if(43==e)return 62;if(47==e)return 63;throw"c:"+e};return a},Vp=function(e,n,t){const o=function(e,n){const t=e,o=n,r=new Array(e*n),a={setPixel:function(e,n,o){r[n*t+e]=o},write:function(e){e.writeString("GIF87a"),e.writeShort(t),e.writeShort(o),e.writeByte(128),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(255),e.writeByte(255),e.writeByte(255),e.writeString(","),e.writeShort(0),e.writeShort(0),e.writeShort(t),e.writeShort(o),e.writeByte(0);const n=i(2);e.writeByte(2);let r=0;for(;n.length-r>255;)e.writeByte(255),e.writeBytes(n,r,255),r+=255;e.writeByte(n.length-r),e.writeBytes(n,r,n.length-r),e.writeByte(0),e.writeString(";")}},i=function(e){const n=1<<e,t=1+(1<<e);let o=e+1;const a=s();for(let r=0;r<n;r+=1)a.add(String.fromCharCode(r));a.add(String.fromCharCode(n)),a.add(String.fromCharCode(t));const i=qp(),c=function(e){const n=e;let t=0,o=0;return{write:function(e,r){if(e>>>r!=0)throw"length over";for(;t+r>=8;)n.writeByte(255&(e<<t|o)),r-=8-t,e>>>=8-t,o=0,t=0;o|=e<<t,t+=r},flush:function(){t>0&&n.writeByte(o)}}}(i);c.write(n,o);let l=0,d=String.fromCharCode(r[l]);for(l+=1;l<r.length;){const e=String.fromCharCode(r[l]);l+=1,a.contains(d+e)?d+=e:(c.write(a.indexOf(d),o),a.size()<4095&&(a.size()==1<<o&&(o+=1),a.add(d+e)),d=e)}return c.write(a.indexOf(d),o),c.write(t,o),c.flush(),i.toByteArray()},s=function(){const e={};let n=0;const t={add:function(o){if(t.contains(o))throw"dup key:"+o;e[o]=n,n+=1},size:function(){return n},indexOf:function(n){return e[n]},contains:function(n){return void 0!==e[n]}};return t};return a}(e,n);for(let s=0;s<n;s+=1)for(let n=0;n<e;n+=1)o.setPixel(n,s,t(n,s));const r=qp();o.write(r);const a=function(){let e=0,n=0,t=0,o="";const r={},a=function(e){o+=String.fromCharCode(i(63&e))},i=function(e){if(e<0)throw"n:"+e;if(e<26)return 65+e;if(e<52)return e-26+97;if(e<62)return e-52+48;if(62==e)return 43;if(63==e)return 47;throw"n:"+e};return r.writeByte=function(o){for(e=e<<8|255&o,n+=8,t+=1;n>=6;)a(e>>>n-6),n-=6},r.flush=function(){if(n>0&&(a(e<<6-n),e=0,n=0),t%3!=0){const e=3-t%3;for(let n=0;n<e;n+=1)o+="="}},r.toString=function(){return o},r}(),i=r.toByteArray();for(let s=0;s<i.length;s+=1)a.writeByte(i[s]);return a.flush(),"data:image/gif;base64,"+a},Kp=Object.freeze(Object.defineProperty({__proto__:null,default:xp,qrcode:xp},Symbol.toStringTag,{value:"Module"}));function Zp(e,n,t){const o=.299*e+.587*n+.114*t,r=-.169*e-.331*n+.5*t+128,a=.5*e-.419*n-.081*t+128;return o>80&&o<255&&r>85&&r<135&&a>135&&a<180}async function Hp(){if("undefined"==typeof window||!window.faceapi)return;const{faceapi:e}=window;if(!e.nets.tinyFaceDetector.isLoaded)try{await Promise.all([e.nets.tinyFaceDetector.loadFromUri("/models"),e.nets.faceLandmark68Net.loadFromUri("/models")])}catch(n){}}const Gp=Object.freeze(Object.defineProperty({__proto__:null,detectBiometricType:async function(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 r=n.startsWith("data:")?n:`data:image/jpeg;base64,${n}`;o.src=r}))),o=await async function(e){try{if("undefined"!=typeof window&&window.faceapi){const{faceapi:n}=window;await Hp();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 r=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 r=0,a=0;for(let d=0;d<n.length;d+=4){Zp(n[d],n[d+1],n[d+2])&&r++,a++}const i=r/a,s=t/o;let c=0;i>.15&&i<.7&&(c+=i/.7*.4);s>.6&&s<1.8&&(c+=.3);const l=t*o;l>1e4&&l<5e5&&(c+=.3);return{confidence:Math.min(c,.8),skinRatio:i,aspectRatio:s,imageSize:l,skinPixels:r,totalPixels:a}}(t.getImageData(0,0,n.width,n.height));return{confidence:o.confidence,details:o}}catch(n){return{confidence:0}}}(t);return r.confidence>.6?{type:"hand",confidence:r.confidence,details:r.details}:{type:"unknown",confidence:Math.max(o.confidence,r.confidence)}}catch(t){return{type:"face",confidence:.5}}var n},initializeBiometricDetection:async function(){try{"undefined"!=typeof window&&await Hp()}catch(e){}},isAdvancedDetectionAvailable:function(){return"undefined"!=typeof window&&window.faceapi&&window.faceapi.nets.tinyFaceDetector.isLoaded}},Symbol.toStringTag,{value:"Module"}));e.BiometricRegistrationModal=zd,e.BiometricStatusOverlay=class{constructor(){l(this,"container",null),l(this,"currentStatus","preparing")}getStyles(){return"\n @keyframes neofaceid-fadeIn {\n from { opacity: 0; transform: scale(0.9); }\n to { opacity: 1; transform: scale(1); }\n }\n\n @keyframes neofaceid-fadeOut {\n from { opacity: 1; transform: scale(1); }\n to { opacity: 0; transform: scale(0.9); }\n }\n\n @keyframes neofaceid-pulse {\n 0%, 100% { \n transform: scale(1);\n opacity: 1;\n }\n 50% { \n transform: scale(1.05);\n opacity: 0.9;\n }\n }\n\n @keyframes neofaceid-scaleIn {\n 0% { transform: scale(0); opacity: 0; }\n 50% { transform: scale(1.1); }\n 100% { transform: scale(1); opacity: 1; }\n }\n\n @keyframes neofaceid-errorShake {\n 0%, 100% { transform: translateX(0); }\n 10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }\n 20%, 40%, 60%, 80% { transform: translateX(4px); }\n }\n\n .neofaceid-overlay-container {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10000;\n pointer-events: none;\n animation: neofaceid-fadeIn 0.3s ease-out;\n font-family: inherit;\n }\n\n .neofaceid-overlay-container.fade-out {\n animation: neofaceid-fadeOut 0.3s ease-out forwards;\n }\n\n .neofaceid-overlay-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 24px;\n pointer-events: auto;\n }\n\n .neofaceid-visual-wrapper {\n position: relative;\n width: 100px;\n height: 100px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .neofaceid-logo {\n width: 80px;\n height: 80px;\n object-fit: contain;\n transition: all 0.5s ease;\n filter: drop-shadow(0 4px 12px rgba(0, 89, 196, 0.3));\n }\n\n /* Cores por estado */\n .neofaceid-state-preparing .neofaceid-logo { filter: drop-shadow(0 0 15px rgba(0, 89, 196, 0.4)); }\n .neofaceid-state-detecting .neofaceid-logo { filter: hue-rotate(180deg) drop-shadow(0 0 15px rgba(59, 130, 246, 0.6)); }\n .neofaceid-state-waiting-for-face .neofaceid-logo { filter: hue-rotate(30deg) drop-shadow(0 0 15px rgba(251, 146, 60, 0.6)); }\n .neofaceid-state-capturing .neofaceid-logo { filter: hue-rotate(45deg) drop-shadow(0 0 15px rgba(245, 158, 11, 0.6)); }\n .neofaceid-state-verifying .neofaceid-logo { filter: hue-rotate(90deg) drop-shadow(0 0 15px rgba(34, 197, 94, 0.6)); }\n\n .neofaceid-logo.pulsing {\n animation: neofaceid-pulse 2s ease-in-out infinite;\n }\n\n @keyframes neofaceid-dots {\n 0%, 20% { opacity: 0; transform: translateY(0); }\n 50% { opacity: 1; transform: translateY(-2px); }\n 80%, 100% { opacity: 0; transform: translateY(0); }\n }\n\n .neofaceid-status-text {\n font-size: 15px;\n font-weight: 500;\n color: #ffffff;\n text-align: center;\n padding: 10px 24px;\n background: rgba(15, 23, 42, 0.8);\n backdrop-filter: blur(8px);\n border-radius: 100px;\n box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);\n border: 1px solid rgba(255, 255, 255, 0.1);\n text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);\n animation: neofaceid-fadeIn 0.3s ease-out;\n display: flex;\n align-items: center;\n gap: 2px;\n }\n\n .neofaceid-dots {\n display: inline-flex;\n margin-left: 2px;\n }\n\n .neofaceid-dot {\n animation: neofaceid-dots 1.5s infinite;\n opacity: 0;\n }\n\n .neofaceid-dot:nth-child(2) { animation-delay: 0.2s; }\n .neofaceid-dot:nth-child(3) { animation-delay: 0.4s; }\n\n .neofaceid-status-icon {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .neofaceid-success-icon {\n width: 80px;\n height: 80px;\n color: #0E9F6E;\n animation: neofaceid-scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);\n }\n\n .neofaceid-error-icon {\n width: 80px;\n height: 80px;\n color: #ef4444;\n animation: neofaceid-errorShake 0.5s linear, neofaceid-scaleIn 0.4s ease-out;\n }\n "}getStatusText(){switch(this.currentStatus){case"preparing":return"Iniciando câmera";case"detecting":return"Posicione seu rosto";case"waiting-for-face":return"Aguardando rosto";case"capturing":return"Capturando";case"verifying":return"Verificando identidade";case"success":return"Identificado!";case"error":return"Falha na identificação";default:return""}}renderContent(){const e=["detecting","waiting-for-face","verifying"].includes(this.currentStatus),n=!["success","error"].includes(this.currentStatus),t="success"===this.currentStatus,o="error"===this.currentStatus,r=this.getStatusText(),a=["preparing","detecting","waiting-for-face","capturing","verifying"].includes(this.currentStatus);return`\n <style>${this.getStyles()}</style>\n <div class="neofaceid-overlay-container neofaceid-state-${this.currentStatus}">\n <div class="neofaceid-overlay-content">\n <div class="neofaceid-visual-wrapper">\n ${n?`<span class="neofaceid-logo ${e?"pulsing":""}" style="display:inline-flex;align-items:center;justify-content:center;color:currentColor;">${function(e=18){return`<span class="neoface-brand-mark" style="display:inline-flex;align-items:center;justify-content:center;width:${e}px;height:${e}px;color:currentColor;">${ld}</span>`}(48).replace("width:18px;height:18px","width:100%;height:100%")}</span>`:""}\n \n ${t?'\n <div class="neofaceid-status-icon">\n <svg class="neofaceid-success-icon" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="30" cy="30" r="28" stroke="currentColor" stroke-width="3" fill="none"/>\n <path d="M15 30 L25 40 L45 20" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" fill="none"/>\n </svg>\n </div>\n ':""}\n \n ${o?'\n <div class="neofaceid-status-icon">\n <svg class="neofaceid-error-icon" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="30" cy="30" r="28" stroke="currentColor" stroke-width="3" fill="none"/>\n <path d="M20 20 L40 40 M40 20 L20 40" stroke="currentColor" stroke-width="3" stroke-linecap="round"/>\n </svg>\n </div>\n ':""}\n </div>\n \n ${r?`\n <div class="neofaceid-status-text">\n ${r}${a?'\n <span class="neofaceid-dots">\n <span class="neofaceid-dot">.</span>\n <span class="neofaceid-dot">.</span>\n <span class="neofaceid-dot">.</span>\n </span>\n ':""}\n </div>\n `:""}\n </div>\n </div>\n `}show(e="preparing"){this.container?this.updateStatus(e):(this.container=document.createElement("div"),this.container.id="neofaceid-status-overlay",this.currentStatus=e,this.container.innerHTML=this.renderContent(),document.body.appendChild(this.container))}updateStatus(e){this.currentStatus=e,this.container&&(this.container.innerHTML=this.renderContent())}close(){if(this.container){const e=this.container.querySelector(".neofaceid-overlay-container");e&&e.classList.add("fade-out"),setTimeout((()=>{this.container&&document.body.contains(this.container)&&document.body.removeChild(this.container),this.container=null}),300)}}},e.CameraOvalGuide=Tu,e.ConsentModal=Hd,e.DEFAULT_CONSENT_INFO=Jd,e.DocumentCaptureModal=gp,e.ENVIRONMENT_URLS=ll,e.EmailPasswordModal=Cu,e.ErrorType=ao,e.FaceCaptureModal=cd,e.FallbackPrompt=Su,e.ForgotPasswordModal=wd,e.NeoFaceError=io,e.RELEASE_DATE="2026-09-23",e.VERSION=$d,e.authorize=async function(e){if(!(await Gd({appName:e.appName,flow:"verification"})))return void(e.onError&&e.onError(new io("Consentimento recusado",ao.CONSENT_DENIED)));const n=document.createElement("div");n.id="neofaceid-authorize-container",document.body.appendChild(n);const r=t.createRoot(n);r.render(o.jsx(hp,{...e,onClose:()=>{r.unmount(),document.body.contains(n)&&document.body.removeChild(n)}}))},e.authorizeOperation=async(e,n,t)=>{if(!e)throw new io("Application token is required",ao.VALIDATION_ERROR);if(!n)throw new io("CPF is required",ao.VALIDATION_ERROR);const o=n.replace(/\D/g,"");if(11!==o.length)throw new io("Invalid CPF format",ao.VALIDATION_ERROR);const r=[],a=(null==t?void 0:t.captureDelay)||2e3;if(!(await Gd({appName:null==t?void 0:t.appName,flow:"verification"})))throw new io("Consentimento recusado pelo usuário.",ao.CONSENT_DENIED);try{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new io("Camera not available",ao.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()}})),async function(e){const n=await Hu();try{await n.estimateHands(e,{})}catch{}}(i).catch((()=>{}));const s=Eu({stream:n,faceState:"centered",instruction:Xu[0]}),c=document.createElement("canvas");c.width=i.videoWidth,c.height=i.videoHeight;const l=c.getContext("2d");if(!l)throw s.close(),n.getTracks().forEach((e=>e.stop())),new io("Failed to get canvas context",ao.CAPTURE_ERROR);for(let e=0;e<4;e++){const o=Xu[e];s.update(n,"centered",o),(null==t?void 0:t.onProgress)&&t.onProgress(e+1,4,o);if(3===e){if(!(await Ju(i,5e3)))throw s.close(),n.getTracks().forEach((e=>e.stop())),r.length=0,new io("Polegar para cima não detectado dentro do tempo limite.",ao.GESTURE_NOT_DETECTED)}else e>0&&await new Promise((e=>setTimeout(e,a)));l.drawImage(i,0,0,c.width,c.height);const d=await new Promise(((e,n)=>{c.toBlob((t=>{t?e(t):n(new Error("Failed to capture photo"))}),"image/jpeg",.9)}));r.push(d),(null==t?void 0:t.onPhotoTaken)&&t.onPhotoTaken(e+1,d)}s.close(),n.getTracks().forEach((e=>e.stop()));const d=r[3],u={cpf:o,email:"",sessionId:`auth_${Date.now()}_${Math.random().toString(36).substring(7)}`},p=await Fl(d,e,"AUTHORIZATION",.8,void 0,u);if(!p.success)throw r.length=0,new io("Authorization failed: Person not recognized",ao.RECOGNITION_FAILED);return r.length=0,{success:!0,authorizationHash:u.sessionId,name:p.personName,birthDate:void 0,cpf:p.cpf||o,confidenceScore:p.confidenceScore,message:"Authorization successful"}}catch(i){if(i instanceof io)throw i;if(i instanceof Error)throw new io(i.message,ao.CAPTURE_ERROR);throw new io("Unknown error during authorization",ao.UNKNOWN)}},e.awaitPushApproval=function(e){return new Promise((n=>{const r=document.createElement("div");r.id="neofaceid-push-approval-container",document.body.appendChild(r);const a=t.createRoot(r);a.render(o.jsx(hu,{...e,onSettle:e=>{a.unmount(),document.body.contains(r)&&document.body.removeChild(r),n(e)}}))}))},e.captureFaceFrames=async function(e){const{numFrames:n,livenessCheck:t}=e;if(n<1||n>10)throw new io("Number of frames must be between 1 and 10",ao.VALIDATION_ERROR);try{const{captureFaceSilently:e}=await Promise.resolve().then((()=>Pu)),o=[];for(let r=0;r<n;r+=1)o.push(await e()),t&&r<n-1&&await new Promise((e=>{setTimeout(e,300)}));return o}catch(o){if(o instanceof io)throw o;throw new io(`Failed to capture face frames: ${o instanceof Error?o.message:"Unknown error"}`,ao.CAPTURE_ERROR)}},e.checkUserExistence=$l,e.clearConsentTrail=function(){try{"undefined"!=typeof window&&window.localStorage&&window.localStorage.removeItem(Dd)}catch{}},e.completeOnboarding=Il,e.completeOnboardingWithData=Rl,e.confirmPasswordReset=Ql,e.consumeSseStream=tu,e.getAccent=function(){return pl.accent},e.getAppName=gl,e.getApplicationToken=ml,e.getAutoFallback=vl,e.getBaseUrl=hl,e.getCachedCaptureSession=function(){return Du},e.getConfig=function(){return{...pl}},e.getConsent=bl,e.getConsentTrail=Md,e.getEnvironment=function(){return pl.environment},e.getLocale=wl,e.getRadius=function(){return pl.radius},e.getResolvedThemeMode=function(){var e;return(null==(e=pl.resolvedTheme)?void 0:e.mode)??("dark"===pl.theme?"dark":"light")},e.getTheme=function(){return pl.theme},e.identifyPerson=Wl,e.identifyPersonAsync=Xl,e.init=function(e={}){const{environment:n,baseUrl:t,applicationToken:o,appName:r,accent:a,radius:i,theme:s,locale:c,consent:l,autoFallback:u}=e;if(u&&(pl.autoFallback={toPhone:u.toPhone??dl.toPhone,toPassword:u.toPassword??dl.toPassword}),l?pl.consent=l:(pl.consent={...cl},fl||(fl=!0)),t)pl.baseUrl=t,pl.environment="custom";else if(n)ll[n]?(pl.baseUrl=ll[n],pl.environment=n):(pl.baseUrl=ll.sandbox,pl.environment="sandbox");else{const e=void 0!=={url:"undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:d&&"SCRIPT"===d.tagName.toUpperCase()&&d.src||new URL("neoface-id-sdk.umd.js",document.baseURI).href}&&(null==sl?void 0:sl.VITE_API_BASE_URL);e&&(pl.baseUrl=e,pl.environment="custom")}o&&(pl.applicationToken=o),r&&r.trim()&&(pl.appName=r.trim()),void 0!==i&&(ul.includes(i)?pl.radius=i:pl.radius=16),s&&(pl.theme=s),c&&(pl.locale=c),void 0!==a&&(pl.accent=a);const p=Uc({accent:pl.accent??void 0,radius:pl.radius,theme:pl.theme});pl.resolvedTheme=p,al({accent:pl.accent??void 0,radius:pl.radius,theme:pl.theme}),pl.initialized=!0},e.isInitialized=function(){return pl.initialized},e.loginWithBiometric=jl,e.loginWithEmail=Ml,e.openCaptureSession=Lu,e.preloadFaceDetectionModels=Ou,e.proofOfLife=async function(e={}){const{videoDurationMs:n=3e3,maxPollingAttempts:t=60,pollingIntervalMs:o=1e3,onRecordingProgress:r,onTaskStatusChange:a}=e,i=e.applicationToken??ml();if(!i)throw new io("proofOfLife exige applicationToken — passe nas opções ou em init({ applicationToken }).",ao.INVALID_TOKEN);try{const e=await Vl({durationMs:n,onProgress:r}),s=await Hl(e),c=await Zl(s,i);a&&a("processing",0);const l=await Kl(c.taskId,i,{maxAttempts:t,intervalMs:o,onStatusChange:a}),d={isLive:(null==l?void 0:l.is_live)||!1,livenessScore:(null==l?void 0:l.liveness_score)||0,faceRecognitionScore:(null==l?void 0:l.face_recognition_score)||0,combinedConfidence:(null==l?void 0:l.combined_confidence)||0,personId:null==l?void 0:l.person_id,personalData:(null==l?void 0:l.personal_data)||[],processingTime:(null==l?void 0:l.processing_time)||0,historyId:c.historyId,taskId:c.taskId};return l&&l.success?{...d,success:!0,message:"Proof of life verification successful"}:{...d,success:!1,error:(null==l?void 0:l.error)||"Verification failed",message:(null==l?void 0:l.message)||"Proof of life verification failed"}}catch(s){if(s instanceof io)throw s;throw new io(`Proof of life failed: ${s instanceof Error?s.message:"Unknown error"}`,ao.RECOGNITION_FAILED)}},e.recognize=Ol,e.recognizeBiometric=Al,e.recognizeByPurpose=Fl,e.recordConsent=Ld,e.refreshSession=Bl,e.registerApplication=Ul,e.registerBiometric=ql,e.registerDocumentByImage=async function(e,n,t={}){const{DocumentCaptureModal:o}=await Promise.resolve().then((()=>wp)),r=new o({useBackCamera:t.useBackCamera??!0,preSelectedDocument:t.preSelectedDocument}),a=await r.open();if(!a.success||!a.frontImage)throw new io("cancelled"===a.error?"Document capture was cancelled by the user":`Document capture failed: ${a.error??"unknown error"}`,ao.CAPTURE_ERROR);const i=[a.frontImage];return a.backImage&&i.push(a.backImage),Gl(e,n,i)},e.registerPersonWithBiometric=Dl,e.registerPersonWithoutFace=zl,e.requestConsent=Gd,e.requestDeviceEnrollmentToken=Ll,e.requestLivenessChallenge=Bu,e.requestLivenessChallengeWithSession=async function({applicationToken:e,purpose:n,sessionId:t}){let o=t??(await Lu({applicationToken:e,purpose:n})).session_id;try{return await Bu({sessionId:o,applicationToken:e})}catch(r){if(r instanceof io&&r.message.includes("410"))return Mu(),o=(await Lu({applicationToken:e,purpose:n})).session_id,Bu({sessionId:o,applicationToken:e});throw r}},e.requestPasswordReset=Yl,e.resetCaptureSession=Mu,e.runLivenessChallenge=Wu,e.simpleIdentification=Pl,e.start=function(e,o,r){Gd({appName:null==r?void 0:r.appName,flow:"verification"}).then((a=>{if(!a)return void o.onError(new io(bp,ao.CONSENT_DENIED));const i=document.createElement("div");i.id="neoface-modal-container",document.body.appendChild(i);const s=()=>{document.body.contains(i)&&document.body.removeChild(i)};Nl(e).then((()=>{const a=n.createElement(cd,{accessToken:e,onClose:s,onSuccess:e=>{s(),o.onSuccess({name:e.data.faceId,email:e.data.faceId,documentId:e.data.faceId})},onCannotGesture:null==r?void 0:r.onCannotGesture});t.createRoot(i).render(a)})).catch((e=>{s(),o.onError(e instanceof io?e:new io(e.message||"Failed to validate token",ao.INVALID_TOKEN))}))}))},e.startAutoLogin=async function(e){if(await Gd({appName:e.appName,flow:"verification"}))try{const n={mode:"auto",onSuccess:async(n,t)=>{try{const t=await fetch(n).then((e=>e.blob())),o=await jl(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 zu(n);await t.open()}catch(n){e.onError(new io(`Erro ao inicializar login automático: ${n.message}`,ao.INITIALIZATION_ERROR))}else e.onError(new io($u,ao.CONSENT_DENIED))},e.startBiometricRegistration=function(e,o,r,a){Gd({appName:null==a?void 0:a.appName,flow:"registration"}).then((i=>{if(!i)return void r.onError(new io(bp,ao.CONSENT_DENIED));const s=document.createElement("div");s.id="neoface-biometric-registration-container",document.body.appendChild(s);let c=null;const l=()=>{c&&(c.unmount(),c=null),document.body.contains(s)&&document.body.removeChild(s)};Nl(o).then((()=>{const i=n.createElement(zd,{personData:e,applicationToken:o,useRealApi:(null==a?void 0:a.useRealApi)??!0,onClose:l,onSuccess:e=>{l(),r.onSuccess(e)},onError:e=>{l(),r.onError(new io(e,ao.UNKNOWN))},onCannotGesture:null==a?void 0:a.onCannotGesture});c=t.createRoot(s),c.render(i)})).catch((e=>{l(),r.onError(e instanceof io?e:new io(e.message||"Failed to validate token",ao.INVALID_TOKEN))}))}))},e.startDeviceEnrollment=function(e){return new Promise(((n,r)=>{const a=document.createElement("div");a.id="neofaceid-device-enrollment-container",document.body.appendChild(a);const i=t.createRoot(a);let s=0;const c=()=>{i.unmount(),document.body.contains(a)&&document.body.removeChild(a)},l=()=>{i.render(o.jsx(ku,{...e,attempt:s,onSettle:e=>{c(),n(e)},onRetry:()=>{s+=1,l()},onFatal:e=>{c(),r(e)}}))};l()}))},e.startDocumentCapture=vp,e.startFaceLogin=async function(e){if(await Gd({appName:e.appName,flow:"verification"}))try{await Au({applicationToken:e.applicationToken,onSuccess:e.onSuccess,onError:e.onError,onFallbackRequest:e.onFallbackRequest||(()=>function(e){if(!vl().toPassword)return void e.onError(new io("Biometria não reconhecida e a queda automática para senha está desligada.",ao.LOGIN_FAILED));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 Cu(n).open()}(e)),onCancel:e.onCancel})}catch(n){e.onError(new io(`Erro ao inicializar login facial: ${n.message}`,ao.INITIALIZATION_ERROR))}else e.onError(new io($u,ao.CONSENT_DENIED))},e.startHandLogin=async function(e){if(await Gd({appName:e.appName,flow:"verification"}))try{const n={mode:"hand",onSuccess:async(n,t)=>{try{const t=await fetch(n).then((e=>e.blob())),o=await jl(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 zu(n);await t.open()}catch(n){e.onError(new io(`Erro ao inicializar login por mão: ${n.message}`,ao.INITIALIZATION_ERROR))}else e.onError(new io($u,ao.CONSENT_DENIED))},e.startLivenessCapture=function(e,o,r){Gd({appName:null==r?void 0:r.appName,flow:"verification"}).then((a=>{if(!a)return void o.onError(new io(bp,ao.CONSENT_DENIED));const i=document.createElement("div");i.id="neoface-liveness-capture-container",document.body.appendChild(i);let s=!1,c=null;const l=()=>{c&&(c.unmount(),c=null),document.body.contains(i)&&document.body.removeChild(i)},d=()=>{l(),!s&&o.onCancel&&o.onCancel()};Nl(e).then((()=>{const a=n.createElement(zd,{applicationToken:e,onClose:d,onPhotosCaptured:e=>{s=!0,o.onSuccess(e)},onError:e=>{l(),o.onError(new io(e,ao.UNKNOWN))},onCannotGesture:null==r?void 0:r.onCannotGesture});c=t.createRoot(i),c.render(a)})).catch((e=>{l(),o.onError(e instanceof io?e:new io(e.message||"Failed to validate token",ao.INVALID_TOKEN))}))}))},e.startOnboarding=async e=>{const{applicationToken:n,onboardingToken:t,countdown:o,title:r,subtitle:a,onSuccess:i,onError:s}=e;try{if(!(await Gd({appName:e.appName,flow:"registration"})))return void s(new io("Consentimento recusado pelo usuário.",ao.CONSENT_DENIED));const c=await Sl(n,t);if(!(null==c?void 0:c.is_valid))throw new io("Link de onboarding inválido ou expirado",ao.VALIDATION_ERROR);const l=new qu({countdown:o,title:r,subtitle:a}),{face:d,document:u}=await l.open();i({...await Il(n,t,d,u),details:c})}catch(c){if(c instanceof io)return void s(c);const e=(null==c?void 0:c.message)||"Erro desconhecido no onboarding";s(new io(e,ao.UNKNOWN))}},e.submitLivenessChallenge=async function({challengeId:e,sessionId:n,applicationToken:t,gestures:o}){if(!t)throw new io("applicationToken é obrigatório para submeter desafio",ao.INVALID_TOKEN);if(!n)throw new io("session_id é obrigatório para submeter desafio",ao.VALIDATION_ERROR);if(!Array.isArray(o)||0===o.length)throw new io("gestures[] vazio — nada para submeter",ao.VALIDATION_ERROR);const r=e?`${encodeURIComponent(e)}/submit/`:"submit/",a=`${hl()}/api/v1/auth/liveness/challenge/${r}`;let i;try{i=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":t},body:JSON.stringify({session_id:n,gestures:o})})}catch(l){const e=l instanceof Error?l.message:"Erro de rede";throw new io(`Falha de rede ao submeter desafio: ${e}`,ao.NETWORK)}if(401===i.status||403===i.status)throw new io("Token de aplicação inválido ou expirado",ao.INVALID_TOKEN);if(410===i.status)throw new io("Sessão ou desafio expirado (410) — reabrir sessão",ao.API_ERROR);if(!i.ok)throw new io(`Falha ao submeter desafio de liveness (${i.status})`,ao.API_ERROR);const s=await i.json().catch((()=>null)),c=(null==s?void 0:s.data)??s??{};return{success:(null==c?void 0:c.success)??!0,liveness_passed:null==c?void 0:c.liveness_passed,score:null==c?void 0:c.score,raw:s}},e.validateOnboardingToken=Cl,e.validateToken=Nl,e.withCaptureSession=async function(e,n){const t=Du??await Lu(e);try{return await n(t.session_id)}catch(o){if(o instanceof io&&o.message.includes("410")){Mu();return n((await Lu(e)).session_id)}throw o}},e.withSessionId=function(e){const n=Du;return n?{...e,session_id:n.session_id}:e},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
1
+ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react"),require("react-dom/client"),require("react/jsx-runtime"),require("@tensorflow/tfjs-core/dist/public/chained_ops/register_all_chained_ops"),require("@tensorflow/tfjs-backend-cpu"),require("@tensorflow/tfjs-core"),require("@tensorflow/tfjs-backend-webgl/dist/index.js")):"function"==typeof define&&define.amd?define(["exports","react","react-dom/client","react/jsx-runtime","@tensorflow/tfjs-core/dist/public/chained_ops/register_all_chained_ops","@tensorflow/tfjs-backend-cpu","@tensorflow/tfjs-core","@tensorflow/tfjs-backend-webgl/dist/index.js"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).NeoFaceIdSdk={},e.React,e.ReactDOM,e.jsxRuntime,null,e.tf,e.tf,e.pn)}(this,(function(e,n,t,o,r,a,i,s){"use strict";var c=Object.defineProperty,l=(e,n,t)=>((e,n,t)=>n in e?c(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t)(e,"symbol"!=typeof n?n+"":n,t),d="undefined"!=typeof document?document.currentScript:null;function u(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)}function p(e,n){for(var t=0;t<n.length;t++){const o=n[t];if("string"!=typeof o&&!Array.isArray(o))for(const n in o)if("default"!==n&&!(n in e)){const t=Object.getOwnPropertyDescriptor(o,n);t&&Object.defineProperty(e,n,t.get?t:{enumerable:!0,get:()=>o[n]})}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}const f=u(i),h=u(s),m=p({__proto__:null},[f]),g=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));var v,w=Object.defineProperty,b=Object.getOwnPropertyDescriptor,x=Object.getOwnPropertyNames,y=Object.prototype.hasOwnProperty,_=(v=function(e){if("undefined"!=typeof require)return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')},"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(v,{get:(e,n)=>("undefined"!=typeof require?require:e)[n]}):v),k=(e,n)=>{for(var t in n)w(e,t,{get:n[t],enumerable:!0})},E=(e,n,t)=>(((e,n,t,o)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let r of x(n))!y.call(e,r)&&r!==t&&w(e,r,{get:()=>n[r],enumerable:!(o=b(n,r))||o.enumerable})})(e,n,"default"),t),T={};k(T,{version:()=>S}),E(T,m),E(T,h),E(T,g);var N="4.22.0",S={tfjs:N,"tfjs-core":N,"tfjs-converter":"4.22.0","tfjs-backend-cpu":"4.22.0","tfjs-backend-webgl":"4.22.0","tfjs-backend-wasm":"4.22.0"},C={};function I(e,n,t=!1){if(e.beginPath(),n.slice(1).forEach((({x:t,y:o},r)=>{let a=n[r];e.moveTo(a.x,a.y),e.lineTo(t,o)})),t){let t=n[n.length-1],o=n[0];if(!t||!o)return;e.moveTo(t.x,t.y),e.lineTo(o.x,o.y)}e.stroke()}k(C,{AnchorPosition:()=>ke,DrawBox:()=>Se,DrawBoxOptions:()=>Ne,DrawFaceLandmarks:()=>_n,DrawFaceLandmarksOptions:()=>yn,DrawTextField:()=>Te,DrawTextFieldOptions:()=>Ee,drawContour:()=>I,drawDetections:()=>Ce,drawFaceExpressions:()=>wn,drawFaceLandmarks:()=>kn});var R={};k(R,{computeReshapedDimensions:()=>B,getCenterPoint:()=>W,isDimensions:()=>L,isEven:()=>D,isFloat:()=>$,isTensor:()=>j,isTensor1D:()=>A,isTensor2D:()=>P,isTensor3D:()=>F,isTensor4D:()=>z,isValidNumber:()=>U,isValidProbablitiy:()=>V,range:()=>q,round:()=>M});var O=class e{constructor(e,n){if(!U(e)||!U(n))throw new Error(`Dimensions.constructor - expected width and height to be valid numbers, instead have ${JSON.stringify({width:e,height:n})}`);this._width=e,this._height=n}get width(){return this._width}get height(){return this._height}reverse(){return new e(1/this.width,1/this.height)}};function j(e,n){return e instanceof T.Tensor&&e.shape.length===n}function A(e){return j(e,1)}function P(e){return j(e,2)}function F(e){return j(e,3)}function z(e){return j(e,4)}function $(e){return e%1!=0}function D(e){return e%2==0}function M(e,n=2){let t=10**n;return Math.floor(e*t)/t}function L(e){return e&&e.width&&e.height}function B({width:e,height:n},t){let o=t/Math.max(n,e);return new O(Math.round(e*o),Math.round(n*o))}function W(e){return e.reduce(((e,n)=>e.add(n)),new K(0,0)).div(new K(e.length,e.length))}function q(e,n,t){return Array(e).fill(0).map(((e,o)=>n+o*t))}function U(e){return!!e&&e!==1/0&&e!==-1/0&&!Number.isNaN(e)||0===e}function V(e){return U(e)&&e>=0&&e<=1}var K=class e{constructor(e,n){this._x=e,this._y=n}get x(){return this._x}get y(){return this._y}add(n){return new e(this.x+n.x,this.y+n.y)}sub(n){return new e(this.x-n.x,this.y-n.y)}mul(n){return new e(this.x*n.x,this.y*n.y)}div(n){return new e(this.x/n.x,this.y/n.y)}abs(){return new e(Math.abs(this.x),Math.abs(this.y))}magnitude(){return Math.sqrt(this.x**2+this.y**2)}floor(){return new e(Math.floor(this.x),Math.floor(this.y))}},Z=class e{static isRect(e){return!!e&&[e.x,e.y,e.width,e.height].every(U)}static assertIsValidBox(n,t,o=!1){if(!e.isRect(n))throw new Error(`${t} - invalid box: ${JSON.stringify(n)}, expected object with properties x, y, width, height`);if(!o&&(n.width<0||n.height<0))throw new Error(`${t} - width (${n.width}) and height (${n.height}) must be positive numbers`)}constructor(n,t=!0){let o=n||{},r=[o.left,o.top,o.right,o.bottom].every(U),a=[o.x,o.y,o.width,o.height].every(U);if(!a&&!r)throw new Error(`Box.constructor - expected box to be IBoundingBox | IRect, instead have ${JSON.stringify(o)}`);let[i,s,c,l]=a?[o.x,o.y,o.width,o.height]:[o.left,o.top,o.right-o.left,o.bottom-o.top];e.assertIsValidBox({x:i,y:s,width:c,height:l},"Box.constructor",t),this._x=i,this._y=s,this._width=c,this._height=l}get x(){return this._x}get y(){return this._y}get width(){return this._width}get height(){return this._height}get left(){return this.x}get top(){return this.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}get area(){return this.width*this.height}get topLeft(){return new K(this.left,this.top)}get topRight(){return new K(this.right,this.top)}get bottomLeft(){return new K(this.left,this.bottom)}get bottomRight(){return new K(this.right,this.bottom)}round(){let[n,t,o,r]=[this.x,this.y,this.width,this.height].map((e=>Math.round(e)));return new e({x:n,y:t,width:o,height:r})}floor(){let[n,t,o,r]=[this.x,this.y,this.width,this.height].map((e=>Math.floor(e)));return new e({x:n,y:t,width:o,height:r})}toSquare(){let{x:n,y:t,width:o,height:r}=this,a=Math.abs(o-r);return o<r&&(n-=a/2,o+=a),r<o&&(t-=a/2,r+=a),new e({x:n,y:t,width:o,height:r})}rescale(n){let t=L(n)?n.width:n,o=L(n)?n.height:n;return new e({x:this.x*t,y:this.y*o,width:this.width*t,height:this.height*o})}pad(n,t){let[o,r,a,i]=[this.x-n/2,this.y-t/2,this.width+n,this.height+t];return new e({x:o,y:r,width:a,height:i})}clipAtImageBorders(n,t){let{x:o,y:r,right:a,bottom:i}=this,s=Math.max(o,0),c=Math.max(r,0),l=a-s,d=i-c,u=Math.min(l,n-s),p=Math.min(d,t-c);return new e({x:s,y:c,width:u,height:p}).floor()}shift(n,t){let{width:o,height:r}=this,a=this.x+n,i=this.y+t;return new e({x:a,y:i,width:o,height:r})}padAtBorders(e,n){let t=this.width+1,o=this.height+1,r=t,a=o,i=this.left,s=this.top,c=this.right,l=this.bottom;return c>n&&(r=-c+n+t,c=n),l>e&&(a=-l+e+o,l=e),i<1&&(a=2-i,i=1),s<1&&(a=2-s,s=1),{dy:1,edy:a,dx:1,edx:r,y:s,ey:l,x:i,ex:c,w:t,h:o}}calibrate(n){return new e({left:this.left+n.left*this.width,top:this.top+n.top*this.height,right:this.right+n.right*this.width,bottom:this.bottom+n.bottom*this.height}).toSquare().round()}},H=class extends Z{constructor(e,n,t,o,r=!1){super({left:e,top:n,right:t,bottom:o},r)}},G=class e{constructor(e,n,t,o,r){this._imageDims=new O(r.width,r.height),this._score=e,this._classScore=n,this._className=t,this._box=new Z(o).rescale(this._imageDims)}get score(){return this._score}get classScore(){return this._classScore}get className(){return this._className}get box(){return this._box}get imageDims(){return this._imageDims}get imageWidth(){return this.imageDims.width}get imageHeight(){return this.imageDims.height}get relativeBox(){return new Z(this._box).rescale(this.imageDims.reverse())}forSize(n,t){return new e(this.score,this.classScore,this.className,this.relativeBox,{width:n,height:t})}},J=class e extends G{constructor(e,n,t){super(e,e,"",n,t)}forSize(n,t){let{score:o,relativeBox:r,imageDims:a}=super.forSize(n,t);return new e(o,r,a)}};function X(e,n,t=!0){let o=Math.max(0,Math.min(e.right,n.right)-Math.max(e.left,n.left))*Math.max(0,Math.min(e.bottom,n.bottom)-Math.max(e.top,n.top));return t?o/(e.area+n.area-o):o/Math.min(e.area,n.area)}function Y(e){let n=e.map((e=>e.x)),t=e.map((e=>e.y)),o=n.reduce(((e,n)=>n<e?n:e),1/0),r=t.reduce(((e,n)=>n<e?n:e),1/0),a=n.reduce(((e,n)=>e<n?n:e),0),i=t.reduce(((e,n)=>e<n?n:e),0);return new H(o,r,a,i)}function Q(e,n,t,o=!0){let r=n.map(((e,n)=>({score:e,boxIndex:n}))).sort(((e,n)=>e.score-n.score)).map((e=>e.boxIndex)),a=[];for(;r.length>0;){let n=r.pop();a.push(n);let i=r,s=[];for(let t=0;t<i.length;t++){let r=i[t],a=e[n],c=e[r];s.push(X(a,c,o))}r=r.filter(((e,n)=>s[n]<=t))}return a}function ee(e,n){return T.tidy((()=>{let[t,o,r]=n,a=T.fill([...e.shape.slice(0,3),1],t,"float32"),i=T.fill([...e.shape.slice(0,3),1],o,"float32"),s=T.fill([...e.shape.slice(0,3),1],r,"float32"),c=T.concat([a,i,s],3);return T.sub(e,c)}))}function ne(e,n=!1){return T.tidy((()=>{let[t,o]=e.shape.slice(1);if(t===o)return e;let r=Math.abs(t-o),a=Math.round(r*(n?.5:1)),i=t>o?2:1,s=n=>{let t=e.shape.slice();return t[i]=n,T.fill(t,0,"float32")},c=s(a),l=r-c.shape[i],d=[n&&l?s(l):null,e,c].filter((e=>!!e)).map((e=>T.cast(e,"float32")));return T.concat(d,i)}))}function te(e){return 1/(1+Math.exp(-e))}var oe,re=class extends Z{constructor(e,n,t,o,r=!1){super({x:e,y:n,width:t,height:o},r)}},ae=class{constructor(e,n,t=new K(0,0)){let{width:o,height:r}=n;this._imgDims=new O(o,r),this._shift=t,this._positions=e.map((e=>e.mul(new K(o,r)).add(t)))}get shift(){return new K(this._shift.x,this._shift.y)}get imageWidth(){return this._imgDims.width}get imageHeight(){return this._imgDims.height}get positions(){return this._positions}get relativePositions(){return this._positions.map((e=>e.sub(this._shift).div(new K(this.imageWidth,this.imageHeight))))}forSize(e,n){return new this.constructor(this.relativePositions,{width:e,height:n})}shiftBy(e,n){return new this.constructor(this.relativePositions,this._imgDims,new K(e,n))}shiftByPoint(e){return this.shiftBy(e.x,e.y)}align(e,n={}){if(e){let t=e instanceof J?e.box.floor():new Z(e);return this.shiftBy(t.x,t.y).align(null,n)}let{useDlibAlignment:t,minBoxPadding:o}={useDlibAlignment:!1,minBoxPadding:.2,...n};return t?this.alignDlib():this.alignMinBbox(o)}alignDlib(){let e=this.getRefPointsForAlignment(),[n,t,o]=e,r=e=>o.sub(e).magnitude(),a=(r(n)+r(t))/2,i=Math.floor(a/.45),s=W(e),c=Math.floor(Math.max(0,s.x-.5*i)),l=Math.floor(Math.max(0,s.y-.43*i));return new re(c,l,Math.min(i,this.imageWidth+c),Math.min(i,this.imageHeight+l))}alignMinBbox(e){let n=Y(this.positions);return n.pad(n.width*e,n.height*e)}getRefPointsForAlignment(){throw new Error("getRefPointsForAlignment not implemented by base class")}},ie=class extends ae{getJawOutline(){return this.positions.slice(0,17)}getLeftEyeBrow(){return this.positions.slice(17,22)}getRightEyeBrow(){return this.positions.slice(22,27)}getNose(){return this.positions.slice(27,36)}getLeftEye(){return this.positions.slice(36,42)}getRightEye(){return this.positions.slice(42,48)}getMouth(){return this.positions.slice(48,68)}getRefPointsForAlignment(){return[this.getLeftEye(),this.getRightEye(),this.getMouth()].map(W)}},se=class{constructor(e,n){this._label=e,this._distance=n}get label(){return this._label}get distance(){return this._distance}toString(e=!0){return`${this.label}${e?` (${M(this.distance)})`:""}`}},ce=class extends Z{static assertIsValidLabeledBox(e,n){if(Z.assertIsValidBox(e,n),!U(e.label))throw new Error(`${n} - expected property label (${e.label}) to be a number`)}constructor(e,n){super(e),this._label=n}get label(){return this._label}},le=class e{constructor(e,n){if("string"!=typeof e)throw new Error("LabeledFaceDescriptors - constructor expected label to be a string");if(!Array.isArray(n)||n.some((e=>!(e instanceof Float32Array))))throw new Error("LabeledFaceDescriptors - constructor expected descriptors to be an array of Float32Array");this._label=e,this._descriptors=n}get label(){return this._label}get descriptors(){return this._descriptors}toJSON(){return{label:this.label,descriptors:this.descriptors.map((e=>Array.from(e)))}}static fromJSON(n){let t=n.descriptors.map((e=>new Float32Array(e)));return new e(n.label,t)}};function de(e){return e.detection instanceof J}function ue(e,n){return{...e,detection:n}}function pe(){let e=window.fetch;if(!e)throw new Error("fetch - missing fetch implementation for browser environment");return{Canvas:HTMLCanvasElement,CanvasRenderingContext2D:CanvasRenderingContext2D,Image:HTMLImageElement,ImageData:ImageData,Video:HTMLVideoElement,createCanvasElement:()=>document.createElement("canvas"),createImageElement:()=>document.createElement("img"),createVideoElement:()=>document.createElement("video"),fetch:e,readFile:()=>{throw new Error("readFile - filesystem not available for browser environment")}}}function fe(){return"object"==typeof global&&"undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node}function he(e){let n="";if(!e&&fe())try{e=_("fs")}catch(t){n=t.toString()}return{readFile:e?n=>new Promise(((t,o)=>{e.readFile(n,((e,n)=>e?o(e):t(n)))})):()=>{throw new Error(`readFile - failed to require fs in nodejs environment with error: ${n}`)}}}function me(){let e=global.Canvas||global.HTMLCanvasElement,n=global.Image||global.HTMLImageElement,t=global.Video||global.HTMLVideoElement,o=global.fetch,r=he();return{Canvas:e||class{},CanvasRenderingContext2D:global.CanvasRenderingContext2D||class{},Image:n||class{},ImageData:global.ImageData||class{},Video:global.HTMLVideoElement||class{},createCanvasElement:()=>{if(e)return new e;throw new Error("createCanvasElement - missing Canvas implementation for nodejs environment")},createImageElement:()=>{if(n)return new n;throw new Error("createImageElement - missing Image implementation for nodejs environment")},createVideoElement:()=>{if(t)return new t;throw new Error("createVideoElement - missing Video implementation for nodejs environment")},fetch:o,...r}}function ge(){return"object"==typeof window&&"undefined"!=typeof document&&"undefined"!=typeof HTMLImageElement&&"undefined"!=typeof HTMLCanvasElement&&"undefined"!=typeof HTMLVideoElement&&"undefined"!=typeof ImageData&&"undefined"!=typeof CanvasRenderingContext2D}function ve(e){oe=e}function we(){return ge()?ve(pe()):fe()?ve(me()):null}var be={getEnv:function(){if(!oe)throw new Error("getEnv - environment is not defined, check isNodejs() and isBrowser()");return oe},setEnv:ve,initialize:we,createBrowserEnv:pe,createFileSystem:he,createNodejsEnv:me,monkeyPatch:function(e){if(oe||we(),!oe)throw new Error("monkeyPatch - environment is not defined, check isNodejs() and isBrowser()");let{Canvas:n=oe.Canvas,Image:t=oe.Image}=e;oe.Canvas=n,oe.Image=t,oe.createCanvasElement=e.createCanvasElement||(()=>new n),oe.createImageElement=e.createImageElement||(()=>new t),oe.ImageData=e.ImageData||oe.ImageData,oe.Video=e.Video||oe.Video,oe.fetch=e.fetch||oe.fetch,oe.readFile=e.readFile||oe.readFile},isBrowser:ge,isNodejs:fe};function xe(e){return be.isNodejs()||"string"!=typeof e?e:document.getElementById(e)}function ye(e){let{Canvas:n,CanvasRenderingContext2D:t}=be.getEnv();if(e instanceof t)return e;let o=xe(e);if(!(o instanceof n))throw new Error("resolveContext2d - expected canvas to be of instance of Canvas");let r=o.getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("resolveContext2d - canvas 2d context is null");return r}we();var _e,ke=((_e=ke||{}).TOP_LEFT="TOP_LEFT",_e.TOP_RIGHT="TOP_RIGHT",_e.BOTTOM_LEFT="BOTTOM_LEFT",_e.BOTTOM_RIGHT="BOTTOM_RIGHT",_e),Ee=class{constructor(e={}){let{anchorPosition:n,backgroundColor:t,fontColor:o,fontSize:r,fontStyle:a,padding:i}=e;this.anchorPosition=n||"TOP_LEFT",this.backgroundColor=t||"rgba(0, 0, 0, 0.5)",this.fontColor=o||"rgba(255, 255, 255, 1)",this.fontSize=r||14,this.fontStyle=a||"Georgia",this.padding=i||4}},Te=class e{constructor(n,t,o={}){this.text="string"==typeof n?[n]:n instanceof e?n.text:n,this.anchor=t,this.options=new Ee(o)}measureWidth(e){let{padding:n}=this.options;return this.text.map((n=>e.measureText(n).width)).reduce(((e,n)=>e<n?n:e),0)+2*n}measureHeight(){let{fontSize:e,padding:n}=this.options;return this.text.length*e+2*n}getUpperLeft(e,n){let{anchorPosition:t}=this.options,o="BOTTOM_RIGHT"===t||"TOP_RIGHT"===t,r="BOTTOM_LEFT"===t||"BOTTOM_RIGHT"===t,a=this.measureWidth(e),i=this.measureHeight(),s=o?this.anchor.x-a:this.anchor.x,c=r?this.anchor.y-i:this.anchor.y;if(n){let{width:e,height:t}=n;return{x:Math.max(Math.min(s,e-a),0),y:Math.max(Math.min(c,t-i),0)}}return{x:s,y:c}}draw(e){let n=xe(e),t=ye(n),{backgroundColor:o,fontColor:r,fontSize:a,fontStyle:i,padding:s}=this.options;t.font=`${a}px ${i}`;let c=this.measureWidth(t),l=this.measureHeight();t.fillStyle=o;let d=this.getUpperLeft(t,n);t.fillRect(d.x,d.y,c,l),t.fillStyle=r,this.text.forEach(((e,n)=>{let o=s+d.x,r=s+d.y+(n+1)*a;t.fillText(e,o,r)}))}},Ne=class{constructor(e={}){let{boxColor:n,lineWidth:t,label:o,drawLabelOptions:r}=e;this.boxColor=n||"rgba(0, 0, 255, 1)",this.lineWidth=t||2,this.label=o;let a={anchorPosition:"BOTTOM_LEFT",backgroundColor:this.boxColor};this.drawLabelOptions=new Ee({...a,...r})}},Se=class{constructor(e,n={}){this.box=new Z(e),this.options=new Ne(n)}draw(e){let n=ye(e),{boxColor:t,lineWidth:o}=this.options,{x:r,y:a,width:i,height:s}=this.box;n.strokeStyle=t,n.lineWidth=o,n.strokeRect(r,a,i,s);let{label:c}=this.options;c&&new Te([c],{x:r-o/2,y:a},this.options.drawLabelOptions).draw(e)}};function Ce(e,n){(Array.isArray(n)?n:[n]).forEach((n=>{let t=n instanceof J?n.score:de(n)?n.detection.score:void 0,o=n instanceof J?n.box:de(n)?n.detection.box:new Z(n),r=t?`${M(t)}`:void 0;new Se(o,{label:r}).draw(e)}))}function Ie(e){let{Image:n,Video:t}=be.getEnv();return e instanceof n&&e.complete||e instanceof t&&e.readyState>=3}function Re(e){return new Promise(((n,t)=>{function o(e){e.currentTarget&&(e.currentTarget.removeEventListener("load",r),e.currentTarget.removeEventListener("error",o),t(e))}function r(e){e.currentTarget&&(e.currentTarget.removeEventListener("load",r),e.currentTarget.removeEventListener("error",o),n(e))}e instanceof be.getEnv().Canvas||Ie(e)?n(null):(e.addEventListener("load",r),e.addEventListener("error",o))}))}function Oe(e){return new Promise(((n,t)=>{e instanceof Blob||t(new Error("bufferToImage - expected buf to be of type: Blob"));let o=new FileReader;o.onload=()=>{"string"!=typeof o.result&&t(new Error("bufferToImage - expected reader.result to be a string, in onload"));let e=be.getEnv().createImageElement();e.onload=()=>n(e),e.onerror=t,e.src=o.result},o.onerror=t,o.readAsDataURL(e)}))}function je(e){let{Image:n,Video:t}=be.getEnv();return e instanceof n?new O(e.naturalWidth,e.naturalHeight):e instanceof t?new O(e.videoWidth,e.videoHeight):new O(e.width,e.height)}function Ae({width:e,height:n}){let{createCanvasElement:t}=be.getEnv(),o=t();return o.width=e,o.height=n,o}function Pe(e,n){let{ImageData:t}=be.getEnv();if(!(e instanceof t||Ie(e)))throw new Error("createCanvasFromMedia - media has not finished loading yet");let{width:o,height:r}=n||je(e),a=Ae({width:o,height:r});return e instanceof t?ye(a).putImageData(e,0,0):ye(a).drawImage(e,0,0,o,r),a}async function Fe(e,n){let t=n||be.getEnv().createCanvasElement(),[o,r,a]=e.shape.slice(z(e)?1:0),i=T.tidy((()=>e.as3D(o,r,a).toInt()));return await T.browser.toPixels(i,t),i.dispose(),t}function ze(e){let{Image:n,Canvas:t,Video:o}=be.getEnv();return e instanceof n||e instanceof t||e instanceof o}function $e(e,n,t=!1){let{Image:o,Canvas:r}=be.getEnv();if(!(e instanceof o||e instanceof r))throw new Error("imageToSquare - expected arg0 to be HTMLImageElement | HTMLCanvasElement");if(n<=0)return Ae({width:1,height:1});let a=je(e),i=n/Math.max(a.height,a.width),s=i*a.width,c=i*a.height,l=Ae({width:n,height:n}),d=e instanceof r?e:Pe(e),u=Math.abs(s-c)/2,p=t&&s<c?u:0,f=t&&c<s?u:0;return d.width>0&&d.height>0&&ye(l).drawImage(d,p,f,s,c),l}var De=class{constructor(e,n=!1){if(this._imageTensors=[],this._canvases=[],this._treatAsBatchInput=!1,this._inputDimensions=[],this._inputSize=0,!Array.isArray(e))throw new Error(`NetInput.constructor - expected inputs to be an Array of TResolvedNetInput or to be instanceof tf.Tensor4D, instead have ${e}`);this._treatAsBatchInput=n,this._batchSize=e.length,e.forEach(((e,n)=>{if(F(e))return this._imageTensors[n]=e,void(this._inputDimensions[n]=e.shape);if(z(e)){let t=e.shape[0];if(1!==t)throw new Error(`NetInput - tf.Tensor4D with batchSize ${t} passed, but not supported in input array`);return this._imageTensors[n]=e,void(this._inputDimensions[n]=e.shape.slice(1))}let t=e instanceof be.getEnv().Canvas?e:Pe(e);this._canvases[n]=t,this._inputDimensions[n]=[t.height,t.width,3]}))}get imageTensors(){return this._imageTensors}get canvases(){return this._canvases}get isBatchInput(){return this.batchSize>1||this._treatAsBatchInput}get batchSize(){return this._batchSize}get inputDimensions(){return this._inputDimensions}get inputSize(){return this._inputSize}get reshapedInputDimensions(){return q(this.batchSize,0,1).map(((e,n)=>this.getReshapedInputDimensions(n)))}getInput(e){return this.canvases[e]||this.imageTensors[e]}getInputDimensions(e){return this._inputDimensions[e]}getInputHeight(e){return this._inputDimensions[e][0]}getInputWidth(e){return this._inputDimensions[e][1]}getReshapedInputDimensions(e){if("number"!=typeof this.inputSize)throw new Error("getReshapedInputDimensions - inputSize not set, toBatchTensor has not been called yet");return B({width:this.getInputWidth(e),height:this.getInputHeight(e)},this.inputSize)}toBatchTensor(e,n=!0){return this._inputSize=e,T.tidy((()=>{let t=q(this.batchSize,0,1).map((t=>{let o=this.getInput(t);if(o instanceof T.Tensor){let t=z(o)?o:T.expandDims(o);return t=ne(t,n),(t.shape[1]!==e||t.shape[2]!==e)&&(t=T.image.resizeBilinear(t,[e,e],!1,!1)),t.as3D(e,e,3)}if(o instanceof be.getEnv().Canvas)return T.browser.fromPixels($e(o,e,n));throw new Error(`toBatchTensor - at batchIdx ${t}, expected input to be instanceof tf.Tensor or instanceof HTMLCanvasElement, instead have ${o}`)}));return T.stack(t.map((e=>T.cast(e,"float32")))).as4D(this.batchSize,e,e,3)}))}};async function Me(e){if(e instanceof De)return e;let n=Array.isArray(e)?e:[e];if(!n.length)throw new Error("toNetInput - empty array passed as input");let t=n=>Array.isArray(e)?` at input index ${n}:`:"",o=n.map(xe);return o.forEach(((e,o)=>{if(!ze(e)&&!F(e)&&!z(e))throw"string"==typeof n[o]?new Error(`toNetInput -${t(o)} string passed, but could not resolve HTMLElement for element id ${n[o]}`):new Error(`toNetInput -${t(o)} expected media to be of type HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | tf.Tensor3D, or to be an element id`);if(z(e)){let n=e.shape[0];if(1!==n)throw new Error(`toNetInput -${t(o)} tf.Tensor4D with batchSize ${n} passed, but not supported in input array`)}})),await Promise.all(o.map((e=>ze(e)&&Re(e)))),new De(o,Array.isArray(e))}async function Le(e,n){let{Canvas:t}=be.getEnv(),o=e;if(!(e instanceof t)){let n=await Me(e);if(n.batchSize>1)throw new Error("extractFaces - batchSize > 1 not supported");let r=n.getInput(0);o=r instanceof t?r:await Fe(r)}let r=ye(o);return n.map((e=>e instanceof J?e.forSize(o.width,o.height).box.floor():e)).map((e=>e.clipAtImageBorders(o.width,o.height))).map((({x:e,y:n,width:t,height:o})=>{let a=Ae({width:t,height:o});return t>0&&o>0&&ye(a).putImageData(r.getImageData(e,n,t,o),0,0),a}))}async function Be(e,n){if(!F(e)&&!z(e))throw new Error("extractFaceTensors - expected image tensor to be 3D or 4D");if(z(e)&&e.shape[0]>1)throw new Error("extractFaceTensors - batchSize > 1 not supported");return T.tidy((()=>{let[t,o,r]=e.shape.slice(z(e)?1:0);return n.map((e=>e instanceof J?e.forSize(o,t).box:e)).map((e=>e.clipAtImageBorders(o,t))).filter((e=>e.width>0&&e.height>0)).map((({x:n,y:a,width:i,height:s})=>T.slice3d(e.as3D(t,o,r),[a,n,0],[s,i,r])))}))}async function We(e,n){let{fetch:t}=be.getEnv(),o=await t(e,n);if(!(o.status<400))throw new Error(`failed to fetch: (${o.status}) ${o.statusText}, from url: ${o.url}`);return o}async function qe(e){return(await We(e)).json()}function Ue(e,n){let t=`${n}-weights_manifest.json`;if(!e)return{modelBaseUri:"",manifestUri:t};if("/"===e)return{modelBaseUri:"/",manifestUri:`/${t}`};let o=e.startsWith("http://")?"http://":e.startsWith("https://")?"https://":"",r=(e=e.replace(o,"")).split("/").filter((e=>e)),a=e.endsWith(".json")?r[r.length-1]:t,i=o+(e.endsWith(".json")?r.slice(0,r.length-1):r).join("/");return i=e.startsWith("/")?`/${i}`:i,{modelBaseUri:i,manifestUri:"/"===i?`/${a}`:`${i}/${a}`}}async function Ve(e,n){let{manifestUri:t,modelBaseUri:o}=Ue(e,n),r=await qe(t);return T.io.loadWeights(r,o)}var Ke=class{constructor(e){this._params=void 0,this._paramMappings=[],this._name=e}get params(){return this._params}get paramMappings(){return this._paramMappings}get isLoaded(){return!!this.params}getParamFromPath(e){let{obj:n,objProp:t}=this.traversePropertyPath(e);return n[t]}reassignParamFromPath(e,n){let{obj:t,objProp:o}=this.traversePropertyPath(e);t[o].dispose(),t[o]=n}getParamList(){return this._paramMappings.map((({paramPath:e})=>({path:e,tensor:this.getParamFromPath(e)})))}getTrainableParams(){return this.getParamList().filter((e=>e.tensor instanceof T.Variable))}getFrozenParams(){return this.getParamList().filter((e=>!(e.tensor instanceof T.Variable)))}variable(){this.getFrozenParams().forEach((({path:e,tensor:n})=>{this.reassignParamFromPath(e,n.variable())}))}freeze(){this.getTrainableParams().forEach((({path:e,tensor:n})=>{let t=T.tensor(n.dataSync());n.dispose(),this.reassignParamFromPath(e,t)}))}dispose(e=!0){this.getParamList().forEach((n=>{if(e&&n.tensor.isDisposed)throw new Error(`param tensor has already been disposed for path ${n.path}`);n.tensor.dispose()})),this._params=void 0}serializeParams(){return new Float32Array(this.getParamList().map((({tensor:e})=>Array.from(e.dataSync()))).reduce(((e,n)=>e.concat(n))))}async load(e){e instanceof Float32Array?this.extractWeights(e):await this.loadFromUri(e)}async loadFromUri(e){if(e&&"string"!=typeof e)throw new Error(`${this._name}.loadFromUri - expected model uri`);let n=await Ve(e,this.getDefaultModelName());this.loadFromWeightMap(n)}async loadFromDisk(e){if(e&&"string"!=typeof e)throw new Error(`${this._name}.loadFromDisk - expected model file path`);let{readFile:n}=be.getEnv(),{manifestUri:t,modelBaseUri:o}=Ue(e,this.getDefaultModelName()),r=T.io.weightsLoaderFactory((e=>Promise.all(e.map((e=>n(e).then((e=>"string"==typeof e?Buffer.from(e):e.buffer))))))),a=JSON.parse((await n(t)).toString()),i=await r(a,o);this.loadFromWeightMap(i)}loadFromWeightMap(e){let{paramMappings:n,params:t}=this.extractParamsFromWeightMap(e);this._paramMappings=n,this._params=t}extractWeights(e){let{paramMappings:n,params:t}=this.extractParams(e);this._paramMappings=n,this._params=t}traversePropertyPath(e){if(!this.params)throw new Error("traversePropertyPath - model has no loaded params");let n=e.split("/").reduce(((n,t)=>{if(!n.nextObj.hasOwnProperty(t))throw new Error(`traversePropertyPath - object does not have property ${t}, for path ${e}`);return{obj:n.nextObj,objProp:t,nextObj:n.nextObj[t]}}),{nextObj:this.params}),{obj:t,objProp:o}=n;if(!(t&&o&&t[o]instanceof T.Tensor))throw new Error(`traversePropertyPath - parameter is not a tensor, for path ${e}`);return{obj:t,objProp:o}}};function Ze(e,n,t){return T.tidy((()=>{let o=T.separableConv2d(e,n.depthwise_filter,n.pointwise_filter,t,"same");return o=T.add(o,n.bias),o}))}function He(e,n,t=!1){return T.tidy((()=>{let o=T.relu(t?T.add(T.conv2d(e,n.conv0.filters,[2,2],"same"),n.conv0.bias):Ze(e,n.conv0,[2,2])),r=Ze(o,n.conv1,[1,1]),a=Ze(T.relu(T.add(o,r)),n.conv2,[1,1]);return T.relu(T.add(o,T.add(r,a)))}))}function Ge(e,n,t=!1,o=!0){return T.tidy((()=>{let r=T.relu(t?T.add(T.conv2d(e,n.conv0.filters,o?[2,2]:[1,1],"same"),n.conv0.bias):Ze(e,n.conv0,o?[2,2]:[1,1])),a=Ze(r,n.conv1,[1,1]),i=Ze(T.relu(T.add(r,a)),n.conv2,[1,1]),s=Ze(T.relu(T.add(r,T.add(a,i))),n.conv3,[1,1]);return T.relu(T.add(r,T.add(a,T.add(i,s))))}))}function Je(e,n,t="same",o=!1){return T.tidy((()=>{let r=T.add(T.conv2d(e,n.filters,[1,1],t),n.bias);return o?T.relu(r):r}))}function Xe(e,n){Object.keys(e).forEach((t=>{n.some((e=>e.originalPath===t))||e[t].dispose()}))}function Ye(e,n){return(t,o,r,a)=>{let i=T.tensor4d(e(t*o*r*r),[r,r,t,o]),s=T.tensor1d(e(o));return n.push({paramPath:`${a}/filters`},{paramPath:`${a}/bias`}),{filters:i,bias:s}}}function Qe(e,n){return(t,o,r)=>{let a=T.tensor2d(e(t*o),[t,o]),i=T.tensor1d(e(o));return n.push({paramPath:`${r}/weights`},{paramPath:`${r}/bias`}),{weights:a,bias:i}}}var en=class{constructor(e,n,t){this.depthwise_filter=e,this.pointwise_filter=n,this.bias=t}};function nn(e,n){return(t,o,r)=>{let a=T.tensor4d(e(9*t),[3,3,t,1]),i=T.tensor4d(e(t*o),[1,1,t,o]),s=T.tensor1d(e(o));return n.push({paramPath:`${r}/depthwise_filter`},{paramPath:`${r}/pointwise_filter`},{paramPath:`${r}/bias`}),new en(a,i,s)}}function tn(e){return n=>{let t=e(`${n}/depthwise_filter`,4),o=e(`${n}/pointwise_filter`,4),r=e(`${n}/bias`,1);return new en(t,o,r)}}function on(e,n){return(t,o,r)=>{let a=e[t];if(!j(a,o))throw new Error(`expected weightMap[${t}] to be a Tensor${o}D, instead have ${a}`);return n.push({originalPath:t,paramPath:r||t}),a}}function rn(e){let n=e;return{extractWeights:function(e){let t=n.slice(0,e);return n=n.slice(e),t},getRemainingWeights:function(){return n}}}function an(e,n){let t=Ye(e,n),o=nn(e,n);function r(e,n,r,a=!1){return{conv0:a?t(e,n,3,`${r}/conv0`):o(e,n,`${r}/conv0`),conv1:o(n,n,`${r}/conv1`),conv2:o(n,n,`${r}/conv2`)}}return{extractDenseBlock3Params:r,extractDenseBlock4Params:function(e,n,t,a=!1){let{conv0:i,conv1:s,conv2:c}=r(e,n,t,a);return{conv0:i,conv1:s,conv2:c,conv3:o(n,n,`${t}/conv3`)}}}}function sn(e){return n=>({filters:e(`${n}/filters`,4),bias:e(`${n}/bias`,1)})}function cn(e,n){let t=on(e,n),o=sn(t),r=tn(t);return{extractDenseBlock3Params:function(e,n=!1){return{conv0:n?o(`${e}/conv0`):r(`${e}/conv0`),conv1:r(`${e}/conv1`),conv2:r(`${e}/conv2`)}},extractDenseBlock4Params:function(e,n=!1){return{conv0:n?o(`${e}/conv0`):r(`${e}/conv0`),conv1:r(`${e}/conv1`),conv2:r(`${e}/conv2`),conv3:r(`${e}/conv3`)}}}}var ln=class extends Ke{constructor(){super("FaceFeatureExtractor")}forwardInput(e){let{params:n}=this;if(!n)throw new Error("FaceFeatureExtractor - load model before inference");return T.tidy((()=>{let t=Ge(ee(T.cast(e.toBatchTensor(112,!0),"float32"),[122.782,117.001,104.298]).div(255),n.dense0,!0);return t=Ge(t,n.dense1),t=Ge(t,n.dense2),t=Ge(t,n.dense3),t=T.avgPool(t,[7,7],[2,2],"valid"),t}))}async forward(e){return this.forwardInput(await Me(e))}getDefaultModelName(){return"face_feature_extractor_model"}extractParamsFromWeightMap(e){return function(e){let n=[],{extractDenseBlock4Params:t}=cn(e,n),o={dense0:t("dense0",!0),dense1:t("dense1"),dense2:t("dense2"),dense3:t("dense3")};return Xe(e,n),{params:o,paramMappings:n}}(e)}extractParams(e){return function(e){let n=[],{extractWeights:t,getRemainingWeights:o}=rn(e),{extractDenseBlock4Params:r}=an(t,n),a=r(3,32,"dense0",!0),i=r(32,64,"dense1"),s=r(64,128,"dense2"),c=r(128,256,"dense3");if(0!==o().length)throw new Error(`weights remaing after extract: ${o().length}`);return{paramMappings:n,params:{dense0:a,dense1:i,dense2:s,dense3:c}}}(e)}};function dn(e,n){return T.tidy((()=>T.add(T.matMul(e,n.weights),n.bias)))}function un(e){let n={},t={};return Object.keys(e).forEach((o=>{(o.startsWith("fc")?t:n)[o]=e[o]})),{featureExtractorMap:n,classifierMap:t}}var pn=class extends Ke{constructor(e,n){super(e),this._faceFeatureExtractor=n}get faceFeatureExtractor(){return this._faceFeatureExtractor}runNet(e){let{params:n}=this;if(!n)throw new Error(`${this._name} - load model before inference`);return T.tidy((()=>{let t=e instanceof De?this.faceFeatureExtractor.forwardInput(e):e;return dn(t.as2D(t.shape[0],-1),n.fc)}))}dispose(e=!0){this.faceFeatureExtractor.dispose(e),super.dispose(e)}loadClassifierParams(e){let{params:n,paramMappings:t}=this.extractClassifierParams(e);this._params=n,this._paramMappings=t}extractClassifierParams(e){return function(e,n,t){let o=[],{extractWeights:r,getRemainingWeights:a}=rn(e),i=Qe(r,o)(n,t,"fc");if(0!==a().length)throw new Error(`weights remaing after extract: ${a().length}`);return{paramMappings:o,params:{fc:i}}}(e,this.getClassifierChannelsIn(),this.getClassifierChannelsOut())}extractParamsFromWeightMap(e){let{featureExtractorMap:n,classifierMap:t}=un(e);return this.faceFeatureExtractor.loadFromWeightMap(n),function(e){let n=[],t=on(e,n),o={fc:(r="fc",{weights:t(`${r}/weights`,2),bias:t(`${r}/bias`,1)})};var r;return Xe(e,n),{params:o,paramMappings:n}}(t)}extractParams(e){let n=this.getClassifierChannelsIn(),t=this.getClassifierChannelsOut(),o=t*n+t,r=e.slice(0,e.length-o),a=e.slice(e.length-o);return this.faceFeatureExtractor.extractWeights(r),this.extractClassifierParams(a)}},fn=["neutral","happy","sad","angry","fearful","disgusted","surprised"],hn=class{constructor(e){if(this.neutral=0,this.happy=0,this.sad=0,this.angry=0,this.fearful=0,this.disgusted=0,this.surprised=0,7!==e.length)throw new Error(`FaceExpressions.constructor - expected probabilities.length to be 7, have: ${e.length}`);fn.forEach(((n,t)=>{this[n]=e[t]}))}asSortedArray(){return fn.map((e=>({expression:e,probability:this[e]}))).sort(((e,n)=>n.probability-e.probability))}},mn=class extends pn{constructor(e=new ln){super("FaceExpressionNet",e)}forwardInput(e){return T.tidy((()=>T.softmax(this.runNet(e))))}async forward(e){return this.forwardInput(await Me(e))}async predictExpressions(e){let n=await Me(e),t=await this.forwardInput(n),o=await Promise.all(T.unstack(t).map((async e=>{let n=e.dataSync();return e.dispose(),n})));t.dispose();let r=o.map((e=>new hn(e)));return n.isBatchInput?r:r[0]}getDefaultModelName(){return"face_expression_model"}getClassifierChannelsIn(){return 256}getClassifierChannelsOut(){return 7}};function gn(e){return e.expressions instanceof hn}function vn(e,n){return{...e,expressions:n}}function wn(e,n,t=.1,o){(Array.isArray(n)?n:[n]).forEach((n=>{let r=n instanceof hn?n:gn(n)?n.expressions:void 0;if(!r)throw new Error("drawFaceExpressions - expected faceExpressions to be FaceExpressions | WithFaceExpressions<{}> or array thereof");let a=r.asSortedArray().filter((e=>e.probability>t)),i=de(n)?n.detection.box.bottomLeft:o||new K(0,0);new Te(a.map((e=>`${e.expression} (${M(e.probability)})`)),i).draw(e)}))}function bn(e){return de(e)&&e.landmarks instanceof ae&&e.unshiftedLandmarks instanceof ae&&e.alignedRect instanceof J}function xn(e,n){let{box:t}=e.detection,o=n.shiftBy(t.x,t.y),r=o.align(),{imageDims:a}=e.detection,i=new J(e.detection.score,r.rescale(a.reverse()),a),s=function(e){let n=e=>180*e/Math.PI,t=(e,n)=>Math.sqrt((e.x-n.x)**2+(e.y-n.y)**2),o={roll:void 0,pitch:void 0,yaw:void 0};if(!e||!e.positions||68!==e.positions.length)return o;let r=e.positions;return o.roll=((e,t)=>{let o=Math.hypot(t.x-e.x,t.y-e.y),r=t.y-e.y,a=Math.asin(r/o),i=n(a);return Math.floor(90-i)*(t.x-e.x<0?-1:1)})(r[27],r[66]),o.pitch=((e,o,r)=>{let a=t(e,r),i=new K((e.x+r.x)/2,(e.y+r.y)/2),s=t(o,i),c=Math.atan(s/a);return Math.floor(n(c))*(i.y-o.y<0?-1:1)})(r[14],r[30],r[2]),o.yaw=(a=r[14],i=r[33],s=r[2],Math.floor(a.x-i.x)-Math.floor(i.x-s.x)),o;var a,i,s}(n);return{...e,landmarks:o,unshiftedLandmarks:n,alignedRect:i,angle:s}}var yn=class{constructor(e={}){let{drawLines:n=!0,drawPoints:t=!0,lineWidth:o,lineColor:r,pointSize:a,pointColor:i}=e;this.drawLines=n,this.drawPoints=t,this.lineWidth=o||1,this.pointSize=a||2,this.lineColor=r||"rgba(0, 255, 255, 1)",this.pointColor=i||"rgba(255, 0, 255, 1)"}},_n=class{constructor(e,n={}){this.faceLandmarks=e,this.options=new yn(n)}draw(e){let n=ye(e),{drawLines:t,drawPoints:o,lineWidth:r,lineColor:a,pointSize:i,pointColor:s}=this.options;if(t&&this.faceLandmarks instanceof ie&&(n.strokeStyle=a,n.lineWidth=r,I(n,this.faceLandmarks.getJawOutline()),I(n,this.faceLandmarks.getLeftEyeBrow()),I(n,this.faceLandmarks.getRightEyeBrow()),I(n,this.faceLandmarks.getNose()),I(n,this.faceLandmarks.getLeftEye(),!0),I(n,this.faceLandmarks.getRightEye(),!0),I(n,this.faceLandmarks.getMouth(),!0)),o){n.strokeStyle=s,n.fillStyle=s;let e=e=>{n.beginPath(),n.arc(e.x,e.y,i,0,2*Math.PI),n.fill()};this.faceLandmarks.positions.forEach(e)}}};function kn(e,n){(Array.isArray(n)?n:[n]).forEach((n=>{let t=n instanceof ae?n:bn(n)?n.landmarks:void 0;if(!t)throw new Error("drawFaceLandmarks - expected faceExpressions to be FaceLandmarks | WithFaceLandmarks<WithFaceDetection<{}>> or array thereof");new _n(t).draw(e)}))}function En(e,n){let t=[],{extractWeights:o,getRemainingWeights:r}=rn(e),{extractConvParams:a,extractSeparableConvParams:i,extractReductionBlockParams:s,extractMainBlockParams:c}=function(e,n){let t=Ye(e,n),o=nn(e,n);return{extractConvParams:t,extractSeparableConvParams:o,extractReductionBlockParams:function(e,n,r){return{separable_conv0:o(e,n,`${r}/separable_conv0`),separable_conv1:o(n,n,`${r}/separable_conv1`),expansion_conv:t(e,n,1,`${r}/expansion_conv`)}},extractMainBlockParams:function(e,n){return{separable_conv0:o(e,e,`${n}/separable_conv0`),separable_conv1:o(e,e,`${n}/separable_conv1`),separable_conv2:o(e,e,`${n}/separable_conv2`)}}}}(o,t),l={conv_in:a(3,32,3,"entry_flow/conv_in"),reduction_block_0:s(32,64,"entry_flow/reduction_block_0"),reduction_block_1:s(64,128,"entry_flow/reduction_block_1")},d={};q(n,0,1).forEach((e=>{d[`main_block_${e}`]=c(128,`middle_flow/main_block_${e}`)}));let u={reduction_block:s(128,256,"exit_flow/reduction_block"),separable_conv:i(256,512,"exit_flow/separable_conv")};if(0!==r().length)throw new Error(`weights remaing after extract: ${r().length}`);return{paramMappings:t,params:{entry_flow:l,middle_flow:d,exit_flow:u}}}function Tn(e,n){let t=[],{extractConvParams:o,extractSeparableConvParams:r,extractReductionBlockParams:a,extractMainBlockParams:i}=function(e,n){let t=on(e,n),o=sn(t),r=tn(t);return{extractConvParams:o,extractSeparableConvParams:r,extractReductionBlockParams:function(e){return{separable_conv0:r(`${e}/separable_conv0`),separable_conv1:r(`${e}/separable_conv1`),expansion_conv:o(`${e}/expansion_conv`)}},extractMainBlockParams:function(e){return{separable_conv0:r(`${e}/separable_conv0`),separable_conv1:r(`${e}/separable_conv1`),separable_conv2:r(`${e}/separable_conv2`)}}}}(e,t),s={conv_in:o("entry_flow/conv_in"),reduction_block_0:a("entry_flow/reduction_block_0"),reduction_block_1:a("entry_flow/reduction_block_1")},c={};q(n,0,1).forEach((e=>{c[`main_block_${e}`]=i(`middle_flow/main_block_${e}`)}));let l={reduction_block:a("exit_flow/reduction_block"),separable_conv:r("exit_flow/separable_conv")};return Xe(e,t),{params:{entry_flow:s,middle_flow:c,exit_flow:l},paramMappings:t}}function Nn(e,n,t){return T.add(T.conv2d(e,n.filters,t,"same"),n.bias)}function Sn(e,n,t=!0){let o=t?T.relu(e):e;return o=Ze(o,n.separable_conv0,[1,1]),o=Ze(T.relu(o),n.separable_conv1,[1,1]),o=T.maxPool(o,[3,3],[2,2],"same"),o=T.add(o,Nn(e,n.expansion_conv,[2,2])),o}var Cn=class extends Ke{constructor(e){super("TinyXception"),this._numMainBlocks=e}forwardInput(e){let{params:n}=this;if(!n)throw new Error("TinyXception - load model before inference");return T.tidy((()=>{let t=ee(T.cast(e.toBatchTensor(112,!0),"float32"),[122.782,117.001,104.298]).div(255),o=T.relu(Nn(t,n.entry_flow.conv_in,[2,2]));return o=Sn(o,n.entry_flow.reduction_block_0,!1),o=Sn(o,n.entry_flow.reduction_block_1),q(this._numMainBlocks,0,1).forEach((e=>{o=function(e,n){let t=Ze(T.relu(e),n.separable_conv0,[1,1]);return t=Ze(T.relu(t),n.separable_conv1,[1,1]),t=Ze(T.relu(t),n.separable_conv2,[1,1]),t=T.add(t,e),t}(o,n.middle_flow[`main_block_${e}`])})),o=Sn(o,n.exit_flow.reduction_block),o=T.relu(Ze(o,n.exit_flow.separable_conv,[1,1])),o}))}async forward(e){return this.forwardInput(await Me(e))}getDefaultModelName(){return"tiny_xception_model"}extractParamsFromWeightMap(e){return Tn(e,this._numMainBlocks)}extractParams(e){return En(e,this._numMainBlocks)}};var In,Rn=((In=Rn||{}).FEMALE="female",In.MALE="male",In),On=class extends Ke{constructor(e=new Cn(2)){super("AgeGenderNet"),this._faceFeatureExtractor=e}get faceFeatureExtractor(){return this._faceFeatureExtractor}runNet(e){let{params:n}=this;if(!n)throw new Error(`${this._name} - load model before inference`);return T.tidy((()=>{let t=e instanceof De?this.faceFeatureExtractor.forwardInput(e):e,o=T.avgPool(t,[7,7],[2,2],"valid").as2D(t.shape[0],-1);return{age:dn(o,n.fc.age).as1D(),gender:dn(o,n.fc.gender)}}))}forwardInput(e){return T.tidy((()=>{let{age:n,gender:t}=this.runNet(e);return{age:n,gender:T.softmax(t)}}))}async forward(e){return this.forwardInput(await Me(e))}async predictAgeAndGender(e){let n=await Me(e),t=await this.forwardInput(n),o=T.unstack(t.age),r=T.unstack(t.gender),a=o.map(((e,n)=>({ageTensor:e,genderTensor:r[n]}))),i=await Promise.all(a.map((async({ageTensor:e,genderTensor:n})=>{let t=e.dataSync()[0],o=n.dataSync()[0],r=o>.5,a=r?"male":"female",i=r?o:1-o;return e.dispose(),n.dispose(),{age:t,gender:a,genderProbability:i}})));return t.age.dispose(),t.gender.dispose(),n.isBatchInput?i:i[0]}getDefaultModelName(){return"age_gender_model"}dispose(e=!0){this.faceFeatureExtractor.dispose(e),super.dispose(e)}loadClassifierParams(e){let{params:n,paramMappings:t}=this.extractClassifierParams(e);this._params=n,this._paramMappings=t}extractClassifierParams(e){return function(e){let n=[],{extractWeights:t,getRemainingWeights:o}=rn(e),r=Qe(t,n),a=r(512,1,"fc/age"),i=r(512,2,"fc/gender");if(0!==o().length)throw new Error(`weights remaing after extract: ${o().length}`);return{paramMappings:n,params:{fc:{age:a,gender:i}}}}(e)}extractParamsFromWeightMap(e){let{featureExtractorMap:n,classifierMap:t}=un(e);return this.faceFeatureExtractor.loadFromWeightMap(n),function(e){let n=[],t=on(e,n);function o(e){return{weights:t(`${e}/weights`,2),bias:t(`${e}/bias`,1)}}let r={fc:{age:o("fc/age"),gender:o("fc/gender")}};return Xe(e,n),{params:r,paramMappings:n}}(t)}extractParams(e){let n=e.slice(0,e.length-1539),t=e.slice(e.length-1539);return this.faceFeatureExtractor.extractWeights(n),this.extractClassifierParams(t)}},jn=class extends pn{postProcess(e,n,t){let o=t.map((({width:e,height:t})=>{let o=n/Math.max(t,e);return{width:e*o,height:t*o}})),r=o.length;return T.tidy((()=>{let t=(e,n)=>T.stack([T.fill([68],e,"float32"),T.fill([68],n,"float32")],1).as2D(1,136).as1D(),a=(e,n)=>{let{width:t,height:r}=o[e];return n(t,r)?Math.abs(t-r)/2:0};return e.mul(T.fill([r,136],n,"float32")).sub(T.stack(Array.from(Array(r),((e,n)=>t((e=>a(e,((e,n)=>e<n)))(n),(e=>a(e,((e,n)=>n<e)))(n)))))).div(T.stack(Array.from(Array(r),((e,n)=>t(o[n].width,o[n].height)))))}))}forwardInput(e){return T.tidy((()=>{let n=this.runNet(e);return this.postProcess(n,e.inputSize,e.inputDimensions.map((([e,n])=>({height:e,width:n}))))}))}async forward(e){return this.forwardInput(await Me(e))}async detectLandmarks(e){let n=await Me(e),t=T.tidy((()=>T.unstack(this.forwardInput(n)))),o=await Promise.all(t.map((async(e,t)=>{let o=Array.from(e.dataSync()),r=o.filter(((e,n)=>D(n))),a=o.filter(((e,n)=>!D(n)));return new ie(Array(68).fill(0).map(((e,n)=>new K(r[n],a[n]))),{height:n.getInputHeight(t),width:n.getInputWidth(t)})})));return t.forEach((e=>e.dispose())),n.isBatchInput?o:o[0]}getClassifierChannelsOut(){return 136}},An=class extends jn{constructor(e=new ln){super("FaceLandmark68Net",e)}getDefaultModelName(){return"face_landmark_68_model"}getClassifierChannelsIn(){return 256}};var Pn=class extends Ke{constructor(){super("TinyFaceFeatureExtractor")}forwardInput(e){let{params:n}=this;if(!n)throw new Error("TinyFaceFeatureExtractor - load model before inference");return T.tidy((()=>{let t=He(ee(T.cast(e.toBatchTensor(112,!0),"float32"),[122.782,117.001,104.298]).div(255),n.dense0,!0);return t=He(t,n.dense1),t=He(t,n.dense2),t=T.avgPool(t,[14,14],[2,2],"valid"),t}))}async forward(e){return this.forwardInput(await Me(e))}getDefaultModelName(){return"face_feature_extractor_tiny_model"}extractParamsFromWeightMap(e){return function(e){let n=[],{extractDenseBlock3Params:t}=cn(e,n),o={dense0:t("dense0",!0),dense1:t("dense1"),dense2:t("dense2")};return Xe(e,n),{params:o,paramMappings:n}}(e)}extractParams(e){return function(e){let n=[],{extractWeights:t,getRemainingWeights:o}=rn(e),{extractDenseBlock3Params:r}=an(t,n),a=r(3,32,"dense0",!0),i=r(32,64,"dense1"),s=r(64,128,"dense2");if(0!==o().length)throw new Error(`weights remaing after extract: ${o().length}`);return{paramMappings:n,params:{dense0:a,dense1:i,dense2:s}}}(e)}},Fn=class extends jn{constructor(e=new Pn){super("FaceLandmark68TinyNet",e)}getDefaultModelName(){return"face_landmark_68_tiny_model"}getClassifierChannelsIn(){return 128}};function zn(e,n,t,o,r="same"){let{filters:a,bias:i}=n.conv,s=T.conv2d(e,a,t,r);return s=T.add(s,i),s=function(e,n){return T.add(T.mul(e,n.weights),n.biases)}(s,n.scale),o?T.relu(s):s}function $n(e,n){return zn(e,n,[1,1],!1)}function Dn(e,n){return zn(e,n,[2,2],!0,"valid")}function Mn(e,n){function t(t,o,r,a){let i=function(n,t,o){let r=e(n),a=r.length/(t*o*o);if($(a))throw new Error(`depth has to be an integer: ${a}, weights.length: ${r.length}, numFilters: ${t}, filterSize: ${o}`);return T.tidy((()=>T.transpose(T.tensor4d(r,[t,a,o,o]),[2,3,1,0])))}(t,o,r),s=T.tensor1d(e(o));return n.push({paramPath:`${a}/filters`},{paramPath:`${a}/bias`}),{filters:i,bias:s}}function o(o,r,a,i){let s=t(o,r,a,`${i}/conv`),c=function(t,o){let r=T.tensor1d(e(t)),a=T.tensor1d(e(t));return n.push({paramPath:`${o}/weights`},{paramPath:`${o}/biases`}),{weights:r,biases:a}}(r,`${i}/scale`);return{conv:s,scale:c}}return{extractConvLayerParams:o,extractResidualLayerParams:function(e,n,t,r,a=!1){return{conv1:o((a?.5:1)*e,n,t,`${r}/conv1`),conv2:o(e,n,t,`${r}/conv2`)}}}}function Ln(e,n){let t=on(e,n);function o(e){let n=t(`${e}/conv/filters`,4),o=t(`${e}/conv/bias`,1),r=function(e){return{weights:t(`${e}/scale/weights`,1),biases:t(`${e}/scale/biases`,1)}}(e);return{conv:{filters:n,bias:o},scale:r}}return{extractConvLayerParams:o,extractResidualLayerParams:function(e){return{conv1:o(`${e}/conv1`),conv2:o(`${e}/conv2`)}}}}function Bn(e,n){let t=function(e,n){return zn(e,n,[1,1],!0)}(e,n.conv1);return t=$n(t,n.conv2),t=T.add(t,e),t=T.relu(t),t}function Wn(e,n){let t=Dn(e,n.conv1);t=$n(t,n.conv2);let o=T.avgPool(e,2,2,"valid"),r=T.zeros(o.shape),a=o.shape[3]!==t.shape[3];if(o.shape[1]!==t.shape[1]||o.shape[2]!==t.shape[2]){let e=[...t.shape];e[1]=1;let n=T.zeros(e);t=T.concat([t,n],1);let o=[...t.shape];o[2]=1;let r=T.zeros(o);t=T.concat([t,r],2)}return o=a?T.concat([o,r],3):o,t=T.add(o,t),t=T.relu(t),t}var qn=class extends Ke{constructor(){super("FaceRecognitionNet")}forwardInput(e){let{params:n}=this;if(!n)throw new Error("FaceRecognitionNet - load model before inference");return T.tidy((()=>{let t=Dn(ee(T.cast(e.toBatchTensor(150,!0),"float32"),[122.782,117.001,104.298]).div(255),n.conv32_down);t=T.maxPool(t,3,2,"valid"),t=Bn(t,n.conv32_1),t=Bn(t,n.conv32_2),t=Bn(t,n.conv32_3),t=Wn(t,n.conv64_down),t=Bn(t,n.conv64_1),t=Bn(t,n.conv64_2),t=Bn(t,n.conv64_3),t=Wn(t,n.conv128_down),t=Bn(t,n.conv128_1),t=Bn(t,n.conv128_2),t=Wn(t,n.conv256_down),t=Bn(t,n.conv256_1),t=Bn(t,n.conv256_2),t=Wn(t,n.conv256_down_out);let o=t.mean([1,2]);return T.matMul(o,n.fc)}))}async forward(e){return this.forwardInput(await Me(e))}async computeFaceDescriptor(e){var n;if(null!=(n=null==e?void 0:e.shape)&&n.some((e=>e<=0)))return new Float32Array(128);let t=await Me(e),o=T.tidy((()=>T.unstack(this.forwardInput(t)))),r=await Promise.all(o.map((e=>e.data())));return o.forEach((e=>e.dispose())),t.isBatchInput?r:r[0]}getDefaultModelName(){return"face_recognition_model"}extractParamsFromWeightMap(e){return function(e){let n=[],{extractConvLayerParams:t,extractResidualLayerParams:o}=Ln(e,n),r=t("conv32_down"),a=o("conv32_1"),i=o("conv32_2"),s=o("conv32_3"),c=o("conv64_down"),l=o("conv64_1"),d=o("conv64_2"),u=o("conv64_3"),p=o("conv128_down"),f=o("conv128_1"),h=o("conv128_2"),m=o("conv256_down"),g=o("conv256_1"),v=o("conv256_2"),w=o("conv256_down_out"),{fc:b}=e;if(n.push({originalPath:"fc",paramPath:"fc"}),!P(b))throw new Error(`expected weightMap[fc] to be a Tensor2D, instead have ${b}`);let x={conv32_down:r,conv32_1:a,conv32_2:i,conv32_3:s,conv64_down:c,conv64_1:l,conv64_2:d,conv64_3:u,conv128_down:p,conv128_1:f,conv128_2:h,conv256_down:m,conv256_1:g,conv256_2:v,conv256_down_out:w,fc:b};return Xe(e,n),{params:x,paramMappings:n}}(e)}extractParams(e){return function(e){let{extractWeights:n,getRemainingWeights:t}=rn(e),o=[],{extractConvLayerParams:r,extractResidualLayerParams:a}=Mn(n,o),i=r(4704,32,7,"conv32_down"),s=a(9216,32,3,"conv32_1"),c=a(9216,32,3,"conv32_2"),l=a(9216,32,3,"conv32_3"),d=a(36864,64,3,"conv64_down",!0),u=a(36864,64,3,"conv64_1"),p=a(36864,64,3,"conv64_2"),f=a(36864,64,3,"conv64_3"),h=a(147456,128,3,"conv128_down",!0),m=a(147456,128,3,"conv128_1"),g=a(147456,128,3,"conv128_2"),v=a(589824,256,3,"conv256_down",!0),w=a(589824,256,3,"conv256_1"),b=a(589824,256,3,"conv256_2"),x=a(589824,256,3,"conv256_down_out"),y=T.tidy((()=>T.transpose(T.tensor2d(n(32768),[128,256]),[1,0])));if(o.push({paramPath:"fc"}),0!==t().length)throw new Error(`weights remaing after extract: ${t().length}`);return{params:{conv32_down:i,conv32_1:s,conv32_2:c,conv32_3:l,conv64_down:d,conv64_1:u,conv64_2:p,conv64_3:f,conv128_down:h,conv128_1:m,conv128_2:g,conv256_down:v,conv256_1:w,conv256_2:b,conv256_down_out:x,fc:y},paramMappings:o}}(e)}};function Un(e,n){return{...e,descriptor:n}}function Vn(e,n){return{...e,age:n}}function Kn(e,n,t){return{...e,gender:n,genderProbability:t}}function Zn(e,n){function t(t,o,r,a,i){let s=T.tensor4d(e(t*o*r*r),[r,r,t,o]),c=T.tensor1d(e(o));return n.push({paramPath:`${a}/filters`},{paramPath:`${a}/${i?"batch_norm_offset":"bias"}`}),{filters:s,bias:c}}function o(e,n,o,r){let{filters:a,bias:i}=t(e,n,o,r,!0);return{filters:a,batch_norm_offset:i}}function r(t,r,a){let i=function(t,o){let r=T.tensor4d(e(9*t),[3,3,t,1]),a=T.tensor1d(e(t)),i=T.tensor1d(e(t)),s=T.tensor1d(e(t)),c=T.tensor1d(e(t));return n.push({paramPath:`${o}/filters`},{paramPath:`${o}/batch_norm_scale`},{paramPath:`${o}/batch_norm_offset`},{paramPath:`${o}/batch_norm_mean`},{paramPath:`${o}/batch_norm_variance`}),{filters:r,batch_norm_scale:a,batch_norm_offset:i,batch_norm_mean:s,batch_norm_variance:c}}(t,`${a}/depthwise_conv`);return{depthwise_conv:i,pointwise_conv:o(t,r,1,`${a}/pointwise_conv`)}}return{extractMobilenetV1Params:function(){return{conv_0:o(3,32,3,"mobilenetv1/conv_0"),conv_1:r(32,64,"mobilenetv1/conv_1"),conv_2:r(64,128,"mobilenetv1/conv_2"),conv_3:r(128,128,"mobilenetv1/conv_3"),conv_4:r(128,256,"mobilenetv1/conv_4"),conv_5:r(256,256,"mobilenetv1/conv_5"),conv_6:r(256,512,"mobilenetv1/conv_6"),conv_7:r(512,512,"mobilenetv1/conv_7"),conv_8:r(512,512,"mobilenetv1/conv_8"),conv_9:r(512,512,"mobilenetv1/conv_9"),conv_10:r(512,512,"mobilenetv1/conv_10"),conv_11:r(512,512,"mobilenetv1/conv_11"),conv_12:r(512,1024,"mobilenetv1/conv_12"),conv_13:r(1024,1024,"mobilenetv1/conv_13")}},extractPredictionLayerParams:function(){return{conv_0:o(1024,256,1,"prediction_layer/conv_0"),conv_1:o(256,512,3,"prediction_layer/conv_1"),conv_2:o(512,128,1,"prediction_layer/conv_2"),conv_3:o(128,256,3,"prediction_layer/conv_3"),conv_4:o(256,128,1,"prediction_layer/conv_4"),conv_5:o(128,256,3,"prediction_layer/conv_5"),conv_6:o(256,64,1,"prediction_layer/conv_6"),conv_7:o(64,128,3,"prediction_layer/conv_7"),box_predictor_0:{box_encoding_predictor:t(512,12,1,"prediction_layer/box_predictor_0/box_encoding_predictor"),class_predictor:t(512,9,1,"prediction_layer/box_predictor_0/class_predictor")},box_predictor_1:{box_encoding_predictor:t(1024,24,1,"prediction_layer/box_predictor_1/box_encoding_predictor"),class_predictor:t(1024,18,1,"prediction_layer/box_predictor_1/class_predictor")},box_predictor_2:{box_encoding_predictor:t(512,24,1,"prediction_layer/box_predictor_2/box_encoding_predictor"),class_predictor:t(512,18,1,"prediction_layer/box_predictor_2/class_predictor")},box_predictor_3:{box_encoding_predictor:t(256,24,1,"prediction_layer/box_predictor_3/box_encoding_predictor"),class_predictor:t(256,18,1,"prediction_layer/box_predictor_3/class_predictor")},box_predictor_4:{box_encoding_predictor:t(256,24,1,"prediction_layer/box_predictor_4/box_encoding_predictor"),class_predictor:t(256,18,1,"prediction_layer/box_predictor_4/class_predictor")},box_predictor_5:{box_encoding_predictor:t(128,24,1,"prediction_layer/box_predictor_5/box_encoding_predictor"),class_predictor:t(128,18,1,"prediction_layer/box_predictor_5/class_predictor")}}}}}function Hn(e){let n=[],{extractMobilenetV1Params:t,extractPredictionLayerParams:o}=function(e,n){let t=on(e,n);function o(e,n,o){return{filters:t(`${e}/Conv2d_${n}_pointwise/weights`,4,`${o}/filters`),batch_norm_offset:t(`${e}/Conv2d_${n}_pointwise/convolution_bn_offset`,1,`${o}/batch_norm_offset`)}}function r(e){let n=`mobilenetv1/conv_${e}`,r=`MobilenetV1/Conv2d_${e}_depthwise`,a=`${n}/depthwise_conv`,i=`${n}/pointwise_conv`;return{depthwise_conv:{filters:t(`${r}/depthwise_weights`,4,`${a}/filters`),batch_norm_scale:t(`${r}/BatchNorm/gamma`,1,`${a}/batch_norm_scale`),batch_norm_offset:t(`${r}/BatchNorm/beta`,1,`${a}/batch_norm_offset`),batch_norm_mean:t(`${r}/BatchNorm/moving_mean`,1,`${a}/batch_norm_mean`),batch_norm_variance:t(`${r}/BatchNorm/moving_variance`,1,`${a}/batch_norm_variance`)},pointwise_conv:o("MobilenetV1",e,i)}}function a(e,n){return{filters:t(`${e}/weights`,4,`${n}/filters`),bias:t(`${e}/biases`,1,`${n}/bias`)}}function i(e){return{box_encoding_predictor:a(`Prediction/BoxPredictor_${e}/BoxEncodingPredictor`,`prediction_layer/box_predictor_${e}/box_encoding_predictor`),class_predictor:a(`Prediction/BoxPredictor_${e}/ClassPredictor`,`prediction_layer/box_predictor_${e}/class_predictor`)}}return{extractMobilenetV1Params:function(){return{conv_0:o("MobilenetV1",0,"mobilenetv1/conv_0"),conv_1:r(1),conv_2:r(2),conv_3:r(3),conv_4:r(4),conv_5:r(5),conv_6:r(6),conv_7:r(7),conv_8:r(8),conv_9:r(9),conv_10:r(10),conv_11:r(11),conv_12:r(12),conv_13:r(13)}},extractPredictionLayerParams:function(){return{conv_0:o("Prediction",0,"prediction_layer/conv_0"),conv_1:o("Prediction",1,"prediction_layer/conv_1"),conv_2:o("Prediction",2,"prediction_layer/conv_2"),conv_3:o("Prediction",3,"prediction_layer/conv_3"),conv_4:o("Prediction",4,"prediction_layer/conv_4"),conv_5:o("Prediction",5,"prediction_layer/conv_5"),conv_6:o("Prediction",6,"prediction_layer/conv_6"),conv_7:o("Prediction",7,"prediction_layer/conv_7"),box_predictor_0:i(0),box_predictor_1:i(1),box_predictor_2:i(2),box_predictor_3:i(3),box_predictor_4:i(4),box_predictor_5:i(5)}}}}(e,n),r=e["Output/extra_dim"];if(n.push({originalPath:"Output/extra_dim",paramPath:"output_layer/extra_dim"}),!F(r))throw new Error(`expected weightMap['Output/extra_dim'] to be a Tensor3D, instead have ${r}`);let a={mobilenetv1:t(),prediction_layer:o(),output_layer:{extra_dim:r}};return Xe(e,n),{params:a,paramMappings:n}}function Gn(e,n,t){return T.tidy((()=>{let o=T.conv2d(e,n.filters,t,"same");return o=T.add(o,n.batch_norm_offset),T.clipByValue(o,0,6)}))}function Jn(e,n){return T.tidy((()=>{let t,o=Gn(e,n.conv_0,[2,2]);if([n.conv_1,n.conv_2,n.conv_3,n.conv_4,n.conv_5,n.conv_6,n.conv_7,n.conv_8,n.conv_9,n.conv_10,n.conv_11,n.conv_12,n.conv_13].forEach(((e,n)=>{let r=n+1,a=function(e){return[2,4,6,12].some((n=>n===e))?[2,2]:[1,1]}(r);o=function(e,n,t){return T.tidy((()=>{let o=T.depthwiseConv2d(e,n.filters,t,"same");return o=T.batchNorm(o,n.batch_norm_mean,n.batch_norm_variance,n.batch_norm_offset,n.batch_norm_scale,.0010000000474974513),T.clipByValue(o,0,6)}))}(o,e.depthwise_conv,a),o=Gn(o,e.pointwise_conv,[1,1]),11===r&&(t=o)})),null===t)throw new Error("mobileNetV1 - output of conv layer 11 is null");return{out:o,conv11:t}}))}function Xn(e,n,t){let o=e.arraySync(),r=Math.min(o[n][0],o[n][2]),a=Math.min(o[n][1],o[n][3]),i=Math.max(o[n][0],o[n][2]),s=Math.max(o[n][1],o[n][3]),c=Math.min(o[t][0],o[t][2]),l=Math.min(o[t][1],o[t][3]),d=Math.max(o[t][0],o[t][2]),u=Math.max(o[t][1],o[t][3]),p=(i-r)*(s-a),f=(d-c)*(u-l);if(p<=0||f<=0)return 0;let h=Math.max(r,c),m=Math.max(a,l),g=Math.min(i,d),v=Math.min(s,u),w=Math.max(g-h,0)*Math.max(v-m,0);return w/(p+f-w)}function Yn(e,n){let{sizes:t,centers:o}=function(e){let n=T.unstack(T.transpose(e,[1,0])),t=[T.sub(n[2],n[0]),T.sub(n[3],n[1])];return{sizes:t,centers:[T.add(n[0],T.div(t[0],2)),T.add(n[1],T.div(t[1],2))]}}(e),r=T.unstack(T.transpose(n,[1,0])),a=T.div(T.mul(T.exp(T.div(r[2],5)),t[0]),2),i=T.add(T.mul(T.div(r[0],10),t[0]),o[0]),s=T.div(T.mul(T.exp(T.div(r[3],5)),t[1]),2),c=T.add(T.mul(T.div(r[1],10),t[1]),o[1]);return T.transpose(T.stack([T.sub(i,a),T.sub(c,s),T.add(i,a),T.add(c,s)]),[1,0])}function Qn(e,n){return T.tidy((()=>{let t=e.shape[0];return{boxPredictionEncoding:T.reshape(Je(e,n.box_encoding_predictor),[t,-1,1,4]),classPrediction:T.reshape(Je(e,n.class_predictor),[t,-1,3])}}))}var et=class{constructor({minConfidence:e,maxResults:n}={}){if(this._name="SsdMobilenetv1Options",this._minConfidence=e||.5,this._maxResults=n||100,"number"!=typeof this._minConfidence||this._minConfidence<=0||this._minConfidence>=1)throw new Error(`${this._name} - expected minConfidence to be a number between 0 and 1`);if("number"!=typeof this._maxResults)throw new Error(`${this._name} - expected maxResults to be a number`)}get minConfidence(){return this._minConfidence}get maxResults(){return this._maxResults}},nt=class extends Ke{constructor(){super("SsdMobilenetv1")}forwardInput(e){let{params:n}=this;if(!n)throw new Error("SsdMobilenetv1 - load model before inference");return T.tidy((()=>{let t=T.cast(e.toBatchTensor(512,!1),"float32"),o=Jn(T.sub(T.div(t,127.5),1),n.mobilenetv1),{boxPredictions:r,classPredictions:a}=function(e,n,t){return T.tidy((()=>{let o=Gn(e,t.conv_0,[1,1]),r=Gn(o,t.conv_1,[2,2]),a=Gn(r,t.conv_2,[1,1]),i=Gn(a,t.conv_3,[2,2]),s=Gn(i,t.conv_4,[1,1]),c=Gn(s,t.conv_5,[2,2]),l=Gn(c,t.conv_6,[1,1]),d=Gn(l,t.conv_7,[2,2]),u=Qn(n,t.box_predictor_0),p=Qn(e,t.box_predictor_1),f=Qn(r,t.box_predictor_2),h=Qn(i,t.box_predictor_3),m=Qn(c,t.box_predictor_4),g=Qn(d,t.box_predictor_5);return{boxPredictions:T.concat([u.boxPredictionEncoding,p.boxPredictionEncoding,f.boxPredictionEncoding,h.boxPredictionEncoding,m.boxPredictionEncoding,g.boxPredictionEncoding],1),classPredictions:T.concat([u.classPrediction,p.classPrediction,f.classPrediction,h.classPrediction,m.classPrediction,g.classPrediction],1)}}))}(o.out,o.conv11,n.prediction_layer);return function(e,n,t){return T.tidy((()=>{let o=e.shape[0],r=Yn(T.reshape(T.tile(t.extra_dim,[o,1,1]),[-1,4]),T.reshape(e,[-1,4]));r=T.reshape(r,[o,r.shape[0]/o,4]);let a=T.sigmoid(T.slice(n,[0,0,1],[-1,-1,-1])),i=T.slice(a,[0,0,0],[-1,-1,1]);return i=T.reshape(i,[o,i.shape[1]]),{boxes:T.unstack(r),scores:T.unstack(i)}}))}(r,a,n.output_layer)}))}async forward(e){return this.forwardInput(await Me(e))}async locateFaces(e,n={}){let{maxResults:t,minConfidence:o}=new et(n),r=await Me(e),{boxes:a,scores:i}=this.forwardInput(r),s=a[0],c=i[0];for(let v=1;v<a.length;v++)a[v].dispose(),i[v].dispose();let l=Array.from(c.dataSync()),d=function(e,n,t,o,r){let a=e.shape[0],i=Math.min(t,a),s=n.map(((e,n)=>({score:e,boxIndex:n}))).filter((e=>e.score>r)).sort(((e,n)=>n.score-e.score)),c=e=>e<=o?1:0,l=[];return s.forEach((n=>{if(l.length>=i)return;let t=n.score;for(let o=l.length-1;o>=0;--o){let t=Xn(e,n.boxIndex,l[o]);if(0!==t&&(n.score*=c(t),n.score<=r))break}t===n.score&&l.push(n.boxIndex)})),l}(s,l,t,.5,o),u=r.getReshapedInputDimensions(0),p=r.inputSize,f=p/u.width,h=p/u.height,m=s.arraySync(),g=d.map((e=>{let[n,t]=[Math.max(0,m[e][0]),Math.min(1,m[e][2])].map((e=>e*h)),[o,a]=[Math.max(0,m[e][1]),Math.min(1,m[e][3])].map((e=>e*f));return new J(l[e],new re(o,n,a-o,t-n),{height:r.getInputHeight(0),width:r.getInputWidth(0)})}));return s.dispose(),c.dispose(),g}getDefaultModelName(){return"ssd_mobilenetv1_model"}extractParamsFromWeightMap(e){return Hn(e)}extractParams(e){return function(e){let n=[],{extractWeights:t,getRemainingWeights:o}=rn(e),{extractMobilenetV1Params:r,extractPredictionLayerParams:a}=Zn(t,n),i=r(),s=a(),c={extra_dim:T.tensor3d(t(20472),[1,5118,4])};if(n.push({paramPath:"output_layer/extra_dim"}),0!==o().length)throw new Error(`weights remaing after extract: ${o().length}`);return{params:{mobilenetv1:i,prediction_layer:s,output_layer:c},paramMappings:n}}(e)}};function tt(e){let n=new nt;return n.extractWeights(e),n}var ot=[new K(.738768,.874946),new K(2.42204,2.65704),new K(4.30971,7.04493),new K(10.246,4.59428),new K(12.6868,11.8741)],rt=[new K(1.603231,2.094468),new K(6.041143,7.080126),new K(2.882459,3.518061),new K(4.266906,5.178857),new K(9.041765,10.66308)],at=[117.001,114.697,97.404],it=e=>"number"==typeof e;function st(e){if(!e)throw new Error(`invalid config: ${e}`);if("boolean"!=typeof e.withSeparableConvs)throw new Error(`config.withSeparableConvs has to be a boolean, have: ${e.withSeparableConvs}`);if(!it(e.iouThreshold)||e.iouThreshold<0||e.iouThreshold>1)throw new Error(`config.iouThreshold has to be a number between [0, 1], have: ${e.iouThreshold}`);if(!Array.isArray(e.classes)||!e.classes.length||!e.classes.every((e=>"string"==typeof e)))throw new Error(`config.classes has to be an array class names: string[], have: ${JSON.stringify(e.classes)}`);if(!Array.isArray(e.anchors)||!e.anchors.length||!e.anchors.map((e=>e||{})).every((e=>it(e.x)&&it(e.y))))throw new Error(`config.anchors has to be an array of { x: number, y: number }, have: ${JSON.stringify(e.anchors)}`);if(e.meanRgb&&(!Array.isArray(e.meanRgb)||3!==e.meanRgb.length||!e.meanRgb.every(it)))throw new Error(`config.meanRgb has to be an array of shape [number, number, number], have: ${JSON.stringify(e.meanRgb)}`)}function ct(e){return T.tidy((()=>{let n=T.mul(e,T.scalar(.10000000149011612));return T.add(T.relu(T.sub(e,n)),n)}))}function lt(e,n){return T.tidy((()=>{let t=T.pad(e,[[0,0],[1,1],[1,1],[0,0]]);return t=T.conv2d(t,n.conv.filters,[1,1],"valid"),t=T.sub(t,n.bn.sub),t=T.mul(t,n.bn.truediv),t=T.add(t,n.conv.bias),ct(t)}))}function dt(e,n){return T.tidy((()=>{let t=T.pad(e,[[0,0],[1,1],[1,1],[0,0]]);return t=T.separableConv2d(t,n.depthwise_filter,n.pointwise_filter,[1,1],"valid"),t=T.add(t,n.bias),ct(t)}))}function ut(e,n){let t=Ye(e,n);let o=nn(e,n);return{extractConvParams:t,extractConvWithBatchNormParams:function(o,r,a){let i=t(o,r,3,`${a}/conv`),s=function(t,o){let r=T.tensor1d(e(t)),a=T.tensor1d(e(t));return n.push({paramPath:`${o}/sub`},{paramPath:`${o}/truediv`}),{sub:r,truediv:a}}(r,`${a}/bn`);return{conv:i,bn:s}},extractSeparableConvParams:o}}function pt(e,n){let t=on(e,n);function o(e){return{filters:t(`${e}/filters`,4),bias:t(`${e}/bias`,1)}}return{extractConvParams:o,extractConvWithBatchNormParams:function(e){let n=o(`${e}/conv`),r=function(e){return{sub:t(`${e}/sub`,1),truediv:t(`${e}/truediv`,1)}}(`${e}/bn`);return{conv:n,bn:r}},extractSeparableConvParams:tn(t)}}var ft=class{constructor({inputSize:e,scoreThreshold:n}={}){if(this._name="TinyYolov2Options",this._inputSize=e||416,this._scoreThreshold=n||.5,"number"!=typeof this._inputSize||this._inputSize%32!=0)throw new Error(`${this._name} - expected inputSize to be a number divisible by 32`);if("number"!=typeof this._scoreThreshold||this._scoreThreshold<=0||this._scoreThreshold>=1)throw new Error(`${this._name} - expected scoreThreshold to be a number between 0 and 1`)}get inputSize(){return this._inputSize}get scoreThreshold(){return this._scoreThreshold}},ht=class e extends Ke{constructor(e){super("TinyYolov2"),st(e),this._config=e}get config(){return this._config}get withClassScores(){return this.config.withClassScores||this.config.classes.length>1}get boxEncodingSize(){return 5+(this.withClassScores?this.config.classes.length:0)}runTinyYolov2(e,n){let t=lt(e,n.conv0);return t=T.maxPool(t,[2,2],[2,2],"same"),t=lt(t,n.conv1),t=T.maxPool(t,[2,2],[2,2],"same"),t=lt(t,n.conv2),t=T.maxPool(t,[2,2],[2,2],"same"),t=lt(t,n.conv3),t=T.maxPool(t,[2,2],[2,2],"same"),t=lt(t,n.conv4),t=T.maxPool(t,[2,2],[2,2],"same"),t=lt(t,n.conv5),t=T.maxPool(t,[2,2],[1,1],"same"),t=lt(t,n.conv6),t=lt(t,n.conv7),Je(t,n.conv8,"valid",!1)}runMobilenet(e,n){let t=this.config.isFirstLayerConv2d?ct(Je(e,n.conv0,"valid",!1)):dt(e,n.conv0);return t=T.maxPool(t,[2,2],[2,2],"same"),t=dt(t,n.conv1),t=T.maxPool(t,[2,2],[2,2],"same"),t=dt(t,n.conv2),t=T.maxPool(t,[2,2],[2,2],"same"),t=dt(t,n.conv3),t=T.maxPool(t,[2,2],[2,2],"same"),t=dt(t,n.conv4),t=T.maxPool(t,[2,2],[2,2],"same"),t=dt(t,n.conv5),t=T.maxPool(t,[2,2],[1,1],"same"),t=n.conv6?dt(t,n.conv6):t,t=n.conv7?dt(t,n.conv7):t,Je(t,n.conv8,"valid",!1)}forwardInput(e,n){let{params:t}=this;if(!t)throw new Error("TinyYolov2 - load model before inference");return T.tidy((()=>{let o=T.cast(e.toBatchTensor(n,!1),"float32");return o=this.config.meanRgb?ee(o,this.config.meanRgb):o,o=o.div(255),this.config.withSeparableConvs?this.runMobilenet(o,t):this.runTinyYolov2(o,t)}))}async forward(e,n){return this.forwardInput(await Me(e),n)}async detect(e,n={}){let{inputSize:t,scoreThreshold:o}=new ft(n),r=await Me(e),a=await this.forwardInput(r,t),i=T.tidy((()=>T.unstack(a)[0].expandDims())),s={width:r.getInputWidth(0),height:r.getInputHeight(0)},c=await this.extractBoxes(i,r.getReshapedInputDimensions(0),o);a.dispose(),i.dispose();let l=c.map((e=>e.box)),d=c.map((e=>e.score)),u=c.map((e=>e.classScore)),p=c.map((e=>this.config.classes[e.label]));return Q(l.map((e=>e.rescale(t))),d,this.config.iouThreshold,!0).map((e=>new G(d[e],u[e],p[e],l[e],s)))}getDefaultModelName(){return""}extractParamsFromWeightMap(e){return function(e,n){let t,o=[],{extractConvParams:r,extractConvWithBatchNormParams:a,extractSeparableConvParams:i}=pt(e,o);if(n.withSeparableConvs){let e=n.filterSizes&&n.filterSizes.length||9;t={conv0:n.isFirstLayerConv2d?r("conv0"):i("conv0"),conv1:i("conv1"),conv2:i("conv2"),conv3:i("conv3"),conv4:i("conv4"),conv5:i("conv5"),conv6:e>7?i("conv6"):void 0,conv7:e>8?i("conv7"):void 0,conv8:r("conv8")}}else t={conv0:a("conv0"),conv1:a("conv1"),conv2:a("conv2"),conv3:a("conv3"),conv4:a("conv4"),conv5:a("conv5"),conv6:a("conv6"),conv7:a("conv7"),conv8:r("conv8")};return Xe(e,o),{params:t,paramMappings:o}}(e,this.config)}extractParams(n){let t=this.config.filterSizes||e.DEFAULT_FILTER_SIZES,o=t?t.length:void 0;if(7!==o&&8!==o&&9!==o)throw new Error(`TinyYolov2 - expected 7 | 8 | 9 convolutional filters, but found ${o} filterSizes in config`);return function(e,n,t,o){let r,{extractWeights:a,getRemainingWeights:i}=rn(e),s=[],{extractConvParams:c,extractConvWithBatchNormParams:l,extractSeparableConvParams:d}=ut(a,s);if(n.withSeparableConvs){let[e,a,i,s,l,u,p,f,h]=o;r={conv0:n.isFirstLayerConv2d?c(e,a,3,"conv0"):d(e,a,"conv0"),conv1:d(a,i,"conv1"),conv2:d(i,s,"conv2"),conv3:d(s,l,"conv3"),conv4:d(l,u,"conv4"),conv5:d(u,p,"conv5"),conv6:f?d(p,f,"conv6"):void 0,conv7:h?d(f,h,"conv7"):void 0,conv8:c(h||f||p,5*t,1,"conv8")}}else{let[e,n,a,i,s,d,u,p,f]=o;r={conv0:l(e,n,"conv0"),conv1:l(n,a,"conv1"),conv2:l(a,i,"conv2"),conv3:l(i,s,"conv3"),conv4:l(s,d,"conv4"),conv5:l(d,u,"conv5"),conv6:l(u,p,"conv6"),conv7:l(p,f,"conv7"),conv8:c(f,5*t,1,"conv8")}}if(0!==i().length)throw new Error(`weights remaing after extract: ${i().length}`);return{params:r,paramMappings:s}}(n,this.config,this.boxEncodingSize,t)}async extractBoxes(e,n,t){let{width:o,height:r}=n,a=Math.max(o,r),i=a/o,s=a/r,c=e.shape[1],l=this.config.anchors.length,[d,u,p]=T.tidy((()=>{let n=e.reshape([c,c,l,this.boxEncodingSize]);return[n.slice([0,0,0,0],[c,c,l,4]),n.slice([0,0,0,4],[c,c,l,1]),this.withClassScores?T.softmax(n.slice([0,0,0,5],[c,c,l,this.config.classes.length]),3):T.scalar(0)]})),f=[],h=await u.array(),m=await d.array();for(let g=0;g<c;g++)for(let e=0;e<c;e++)for(let n=0;n<l;n++){let o=te(h[g][e][n][0]);if(!t||o>t){let t=(e+te(m[g][e][n][0]))/c*i,r=(g+te(m[g][e][n][1]))/c*s,a=Math.exp(m[g][e][n][2])*this.config.anchors[n].x/c*i,l=Math.exp(m[g][e][n][3])*this.config.anchors[n].y/c*s,d=t-a/2,u=r-l/2,h={row:g,col:e,anchor:n},{classScore:v,label:w}=this.withClassScores?await this.extractPredictedClass(p,h):{classScore:1,label:0};f.push({box:new H(d,u,d+a,u+l),score:o,classScore:o*v,label:w,...h})}}return d.dispose(),u.dispose(),p.dispose(),f}async extractPredictedClass(e,n){let{row:t,col:o,anchor:r}=n,a=await e.array();return Array(this.config.classes.length).fill(0).map(((e,n)=>a[t][o][r][n])).map(((e,n)=>({classScore:e,label:n}))).reduce(((e,n)=>e.classScore>n.classScore?e:n))}};ht.DEFAULT_FILTER_SIZES=[3,16,32,64,128,256,512,1024,1024];var mt=ht,gt=class extends mt{constructor(e=!0){super({withSeparableConvs:e,iouThreshold:.4,classes:["face"],...e?{anchors:rt,meanRgb:at}:{anchors:ot,withClassScores:!0}})}get withSeparableConvs(){return this.config.withSeparableConvs}get anchors(){return this.config.anchors}async locateFaces(e,n){return(await this.detect(e,n)).map((e=>new J(e.score,e.relativeBox,{width:e.imageWidth,height:e.imageHeight})))}getDefaultModelName(){return this.withSeparableConvs?"tiny_yolov2_separable_conv_model":"tiny_yolov2_model"}extractParamsFromWeightMap(e){return super.extractParamsFromWeightMap(e)}};var vt=class extends ft{constructor(){super(...arguments),this._name="TinyFaceDetectorOptions"}},wt=class{async then(e){return e(await this.run())}async run(){throw new Error("ComposableTask - run is not implemented")}};async function bt(e,n,t,o,r=({alignedRect:e})=>e){let a=e.map((e=>bn(e)?r(e):e.detection)),i=o||(n instanceof T.Tensor?await Be(n,a):await Le(n,a)),s=await t(i);return i.forEach((e=>e instanceof T.Tensor&&e.dispose())),s}async function xt(e,n,t,o,r){return bt([e],n,(async e=>t(e[0])),o,r)}var yt=[new K(1.603231,2.094468),new K(6.041143,7.080126),new K(2.882459,3.518061),new K(4.266906,5.178857),new K(9.041765,10.66308)],_t=[117.001,114.697,97.404],kt=class extends mt{constructor(){super({withSeparableConvs:!0,iouThreshold:.4,classes:["face"],anchors:yt,meanRgb:_t,isFirstLayerConv2d:!0,filterSizes:[3,16,32,64,128,256,512]})}get anchors(){return this.config.anchors}async locateFaces(e,n){return(await this.detect(e,n)).map((e=>new J(e.score,e.relativeBox,{width:e.imageWidth,height:e.imageHeight})))}getDefaultModelName(){return"tiny_face_detector_model"}extractParamsFromWeightMap(e){return super.extractParamsFromWeightMap(e)}},Et={ssdMobilenetv1:new nt,tinyFaceDetector:new kt,tinyYolov2:new gt,faceLandmark68Net:new An,faceLandmark68TinyNet:new Fn,faceRecognitionNet:new qn,faceExpressionNet:new mn,ageGenderNet:new On},Tt=(e,n)=>Et.ssdMobilenetv1.locateFaces(e,n),Nt=e=>Et.faceLandmark68Net.detectLandmarks(e),St=e=>Et.ssdMobilenetv1.load(e),Ct=St,It=Tt,Rt=Nt,Ot=class extends wt{constructor(e,n,t){super(),this.parentTask=e,this.input=n,this.extractedFaces=t}},jt=class extends Ot{async run(){let e=await this.parentTask,n=await bt(e,this.input,(async e=>Promise.all(e.map((e=>Et.faceExpressionNet.predictExpressions(e))))),this.extractedFaces);return e.map(((e,t)=>vn(e,n[t])))}withAgeAndGender(){return new $t(this,this.input)}},At=class extends Ot{async run(){let e=await this.parentTask;if(e)return vn(e,await xt(e,this.input,(e=>Et.faceExpressionNet.predictExpressions(e)),this.extractedFaces))}withAgeAndGender(){return new Dt(this,this.input)}},Pt=class extends jt{withAgeAndGender(){return new Mt(this,this.input)}withFaceDescriptors(){return new Wt(this,this.input)}},Ft=class extends At{withAgeAndGender(){return new Lt(this,this.input)}withFaceDescriptor(){return new qt(this,this.input)}},zt=class extends wt{constructor(e,n,t){super(),this.parentTask=e,this.input=n,this.extractedFaces=t}},$t=class extends zt{async run(){let e=await this.parentTask,n=await bt(e,this.input,(async e=>Promise.all(e.map((e=>Et.ageGenderNet.predictAgeAndGender(e))))),this.extractedFaces);return e.map(((e,t)=>{let{age:o,gender:r,genderProbability:a}=n[t];return Vn(Kn(e,r,a),o)}))}withFaceExpressions(){return new jt(this,this.input)}},Dt=class extends zt{async run(){let e=await this.parentTask;if(!e)return;let{age:n,gender:t,genderProbability:o}=await xt(e,this.input,(e=>Et.ageGenderNet.predictAgeAndGender(e)),this.extractedFaces);return Vn(Kn(e,t,o),n)}withFaceExpressions(){return new At(this,this.input)}},Mt=class extends $t{withFaceExpressions(){return new Pt(this,this.input)}withFaceDescriptors(){return new Wt(this,this.input)}},Lt=class extends Dt{withFaceExpressions(){return new Ft(this,this.input)}withFaceDescriptor(){return new qt(this,this.input)}},Bt=class extends wt{constructor(e,n){super(),this.parentTask=e,this.input=n}},Wt=class extends Bt{async run(){let e=await this.parentTask;return(await bt(e,this.input,(e=>Promise.all(e.map((e=>Et.faceRecognitionNet.computeFaceDescriptor(e))))),null,(e=>e.landmarks.align(null,{useDlibAlignment:!0})))).map(((n,t)=>Un(e[t],n)))}withFaceExpressions(){return new Pt(this,this.input)}withAgeAndGender(){return new Mt(this,this.input)}},qt=class extends Bt{async run(){let e=await this.parentTask;if(e)return Un(e,await xt(e,this.input,(e=>Et.faceRecognitionNet.computeFaceDescriptor(e)),null,(e=>e.landmarks.align(null,{useDlibAlignment:!0}))))}withFaceExpressions(){return new Ft(this,this.input)}withAgeAndGender(){return new Lt(this,this.input)}},Ut=class extends wt{constructor(e,n,t){super(),this.parentTask=e,this.input=n,this.useTinyLandmarkNet=t}get landmarkNet(){return this.useTinyLandmarkNet?Et.faceLandmark68TinyNet:Et.faceLandmark68Net}},Vt=class extends Ut{async run(){let e=await this.parentTask,n=e.map((e=>e.detection)),t=this.input instanceof T.Tensor?await Be(this.input,n):await Le(this.input,n),o=await Promise.all(t.map((e=>this.landmarkNet.detectLandmarks(e))));return t.forEach((e=>e instanceof T.Tensor&&e.dispose())),e.filter(((e,n)=>o[n])).map(((e,n)=>xn(e,o[n])))}withFaceExpressions(){return new Pt(this,this.input)}withAgeAndGender(){return new Mt(this,this.input)}withFaceDescriptors(){return new Wt(this,this.input)}},Kt=class extends Ut{async run(){let e=await this.parentTask;if(!e)return;let{detection:n}=e,t=this.input instanceof T.Tensor?await Be(this.input,[n]):await Le(this.input,[n]),o=await this.landmarkNet.detectLandmarks(t[0]);return t.forEach((e=>e instanceof T.Tensor&&e.dispose())),xn(e,o)}withFaceExpressions(){return new Ft(this,this.input)}withAgeAndGender(){return new Lt(this,this.input)}withFaceDescriptor(){return new qt(this,this.input)}},Zt=class extends wt{constructor(e,n=new et){super(),this.input=e,this.options=n}},Ht=class extends Zt{async run(){let e,{input:n,options:t}=this;if(t instanceof vt)e=Et.tinyFaceDetector.locateFaces(n,t);else if(t instanceof et)e=Et.ssdMobilenetv1.locateFaces(n,t);else{if(!(t instanceof ft))throw new Error("detectFaces - expected options to be instance of TinyFaceDetectorOptions | SsdMobilenetv1Options | TinyYolov2Options");e=Et.tinyYolov2.locateFaces(n,t)}return e}runAndExtendWithFaceDetections(){return new Promise(((e,n)=>{this.run().then((n=>e(n.map((e=>ue({},e)))))).catch((e=>n(e)))}))}withFaceLandmarks(e=!1){return new Vt(this.runAndExtendWithFaceDetections(),this.input,e)}withFaceExpressions(){return new jt(this.runAndExtendWithFaceDetections(),this.input)}withAgeAndGender(){return new $t(this.runAndExtendWithFaceDetections(),this.input)}},Gt=class extends Zt{async run(){let e=await new Ht(this.input,this.options),n=e[0];return e.forEach((e=>{e.score>n.score&&(n=e)})),n}runAndExtendWithFaceDetection(){return new Promise((async e=>{let n=await this.run();e(n?ue({},n):void 0)}))}withFaceLandmarks(e=!1){return new Kt(this.runAndExtendWithFaceDetection(),this.input,e)}withFaceExpressions(){return new At(this.runAndExtendWithFaceDetection(),this.input)}withAgeAndGender(){return new Dt(this.runAndExtendWithFaceDetection(),this.input)}};function Jt(e,n=new et){return new Gt(e,n)}function Xt(e,n=new et){return new Ht(e,n)}async function Yt(e,n){return Xt(e,new et(n?{minConfidence:n}:{})).withFaceLandmarks().withFaceDescriptors()}var Qt=Yt;function eo(e,n){if(e.length!==n.length)throw new Error("euclideanDistance: arr1.length !== arr2.length");let t=Array.from(e),o=Array.from(n);return Math.sqrt(t.map(((e,n)=>e-o[n])).reduce(((e,n)=>e+n*n),0))}const no=Object.freeze(Object.defineProperty({__proto__:null,AgeGenderNet:On,BoundingBox:H,Box:Z,ComposableTask:wt,ComputeAllFaceDescriptorsTask:Wt,ComputeFaceDescriptorsTaskBase:Bt,ComputeSingleFaceDescriptorTask:qt,DetectAllFaceLandmarksTask:Vt,DetectAllFacesTask:Ht,DetectFaceLandmarksTaskBase:Ut,DetectFacesTaskBase:Zt,DetectSingleFaceLandmarksTask:Kt,DetectSingleFaceTask:Gt,Dimensions:O,FACE_EXPRESSION_LABELS:fn,FaceDetection:J,FaceDetectionNet:class extends nt{},FaceExpressionNet:mn,FaceExpressions:hn,FaceLandmark68Net:An,FaceLandmark68TinyNet:Fn,FaceLandmarkNet:class extends An{},FaceLandmarks:ae,FaceLandmarks5:class extends ae{getRefPointsForAlignment(){let e=this.positions;return[e[0],e[1],W([e[3],e[4]])]}},FaceLandmarks68:ie,FaceMatch:se,FaceMatcher:class e{constructor(e,n=.6){this._distanceThreshold=n;let t=Array.isArray(e)?e:[e];if(!t.length)throw new Error("FaceRecognizer.constructor - expected atleast one input");let o=1,r=()=>"person "+o++;this._labeledDescriptors=t.map((e=>{if(e instanceof le)return e;if(e instanceof Float32Array)return new le(r(),[e]);if(e.descriptor&&e.descriptor instanceof Float32Array)return new le(r(),[e.descriptor]);throw new Error("FaceRecognizer.constructor - expected inputs to be of type LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array | Array<LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array>")}))}get labeledDescriptors(){return this._labeledDescriptors}get distanceThreshold(){return this._distanceThreshold}computeMeanDistance(e,n){return n.map((n=>eo(n,e))).reduce(((e,n)=>e+n),0)/(n.length||1)}matchDescriptor(e){return this.labeledDescriptors.map((({descriptors:n,label:t})=>new se(t,this.computeMeanDistance(e,n)))).reduce(((e,n)=>e.distance<n.distance?e:n))}findBestMatch(e){let n=this.matchDescriptor(e);return n.distance<this._distanceThreshold?n:new se("unknown",n.distance)}toJSON(){return{distanceThreshold:this._distanceThreshold,labeledDescriptors:this._labeledDescriptors.map((e=>e.toJSON()))}}static fromJSON(n){let t=n.labeledDescriptors.map((e=>le.fromJSON(e)));return new e(t,n.distanceThreshold)}},FaceRecognitionNet:qn,Gender:Rn,LabeledBox:ce,LabeledFaceDescriptors:le,NetInput:De,NeuralNetwork:Ke,ObjectDetection:G,Point:K,PredictedBox:class extends ce{static assertIsValidPredictedBox(e,n){if(ce.assertIsValidLabeledBox(e,n),!V(e.score)||!V(e.classScore))throw new Error(`${n} - expected properties score (${e.score}) and (${e.classScore}) to be a number between [0, 1]`)}constructor(e,n,t,o){super(e,n),this._score=t,this._classScore=o}get score(){return this._score}get classScore(){return this._classScore}},Rect:re,SsdMobilenetv1:nt,SsdMobilenetv1Options:et,TinyFaceDetector:kt,TinyFaceDetectorOptions:vt,TinyYolov2:gt,TinyYolov2Options:ft,allFaces:Qt,allFacesSsdMobilenetv1:Yt,allFacesTinyYolov2:async function(e,n={}){return Xt(e,new ft(n)).withFaceLandmarks().withFaceDescriptors()},awaitMediaLoaded:Re,bufferToImage:Oe,computeFaceDescriptor:e=>Et.faceRecognitionNet.computeFaceDescriptor(e),createCanvas:Ae,createCanvasFromMedia:Pe,createFaceDetectionNet:function(e){return tt(e)},createFaceRecognitionNet:function(e){let n=new qn;return n.extractWeights(e),n},createSsdMobilenetv1:tt,createTinyFaceDetector:function(e){let n=new kt;return n.extractWeights(e),n},createTinyYolov2:function(e,n=!0){let t=new gt(n);return t.extractWeights(e),t},detectAllFaces:Xt,detectFaceLandmarks:Nt,detectFaceLandmarksTiny:e=>Et.faceLandmark68TinyNet.detectLandmarks(e),detectLandmarks:Rt,detectSingleFace:Jt,draw:C,env:be,euclideanDistance:eo,extendWithAge:Vn,extendWithFaceDescriptor:Un,extendWithFaceDetection:ue,extendWithFaceExpressions:vn,extendWithFaceLandmarks:xn,extendWithGender:Kn,extractFaceTensors:Be,extractFaces:Le,fetchImage:async function(e){let n=await We(e),t=await n.blob();if(!t.type.startsWith("image/"))throw new Error(`fetchImage - expected blob type to be of type image/*, instead have: ${t.type}, for url: ${n.url}`);return Oe(t)},fetchJson:qe,fetchNetWeights:async function(e){return new Float32Array(await(await We(e)).arrayBuffer())},fetchOrThrow:We,fetchVideo:async function(e){let n=await We(e),t=await n.blob();if(!t.type.startsWith("video/"))throw new Error(`fetchVideo - expected blob type to be of type video/*, instead have: ${t.type}, for url: ${n.url}`);return function(e){return new Promise(((n,t)=>{e instanceof Blob||t(new Error("bufferToVideo - expected buf to be of type: Blob"));let o=be.getEnv().createVideoElement();o.oncanplay=()=>n(o),o.onerror=t,o.playsInline=!0,o.muted=!0,o.src=URL.createObjectURL(e),o.play()}))}(t)},getContext2dOrThrow:ye,getMediaDimensions:je,imageTensorToCanvas:Fe,imageToSquare:$e,inverseSigmoid:function(e){return Math.log(e/(1-e))},iou:X,isMediaElement:ze,isMediaLoaded:Ie,isWithAge:function(e){return"number"==typeof e.age},isWithFaceDetection:de,isWithFaceExpressions:gn,isWithFaceLandmarks:bn,isWithGender:function(e){return("male"===e.gender||"female"===e.gender)&&V(e.genderProbability)},loadAgeGenderModel:e=>Et.ageGenderNet.load(e),loadFaceDetectionModel:Ct,loadFaceExpressionModel:e=>Et.faceExpressionNet.load(e),loadFaceLandmarkModel:e=>Et.faceLandmark68Net.load(e),loadFaceLandmarkTinyModel:e=>Et.faceLandmark68TinyNet.load(e),loadFaceRecognitionModel:e=>Et.faceRecognitionNet.load(e),loadSsdMobilenetv1Model:St,loadTinyFaceDetectorModel:e=>Et.tinyFaceDetector.load(e),loadTinyYolov2Model:e=>Et.tinyYolov2.load(e),loadWeightMap:Ve,locateFaces:It,matchDimensions:function(e,n,t=!1){let{width:o,height:r}=t?je(n):n;return e.width=o,e.height=r,{width:o,height:r}},minBbox:Y,nets:Et,nonMaxSuppression:Q,normalize:ee,padToSquare:ne,predictAgeAndGender:e=>Et.ageGenderNet.predictAgeAndGender(e),recognizeFaceExpressions:e=>Et.faceExpressionNet.predictExpressions(e),resizeResults:function e(n,t){let{width:o,height:r}=new O(t.width,t.height);if(o<=0||r<=0)throw new Error(`resizeResults - invalid dimensions: ${JSON.stringify({width:o,height:r})}`);if(Array.isArray(n))return n.map((n=>e(n,{width:o,height:r})));if(bn(n)){let e=n.detection.forSize(o,r),t=n.unshiftedLandmarks.forSize(e.box.width,e.box.height);return xn(ue(n,e),t)}return de(n)?ue(n,n.detection.forSize(o,r)):n instanceof ae||n instanceof J?n.forSize(o,r):n},resolveInput:xe,shuffleArray:function(e){let n=e.slice();for(let t=n.length-1;t>0;t--){let e=Math.floor(Math.random()*(t+1)),o=n[t];n[t]=n[e],n[e]=o}return n},sigmoid:te,ssdMobilenetv1:Tt,tf:T,tinyFaceDetector:(e,n)=>Et.tinyFaceDetector.locateFaces(e,n),tinyYolov2:(e,n)=>Et.tinyYolov2.locateFaces(e,n),toNetInput:Me,utils:R,validateConfig:st,version:"1.7.15"},Symbol.toStringTag,{value:"Module"}));class to extends Error{constructor(e){super(e),this.name="CameraPermissionDenied"}}class oo{constructor(e){l(this,"stream"),this.stream=e}getStream(){return this.stream}stop(){this.stream.getTracks().forEach((e=>e.stop()))}}const ro=()=>{const e=n.useRef(null),[t,o]=n.useState(!1),r=n.useRef(!1);return{startCamera:n.useCallback((async n=>{const t=e.current;if(t)return t.getStream();if(r.current){await new Promise((e=>setTimeout(e,100)));const n=e.current;if(n)return n.getStream()}r.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}})(),a=await navigator.mediaDevices.getUserMedia(t),i=new oo(a);return e.current=i,o(!0),r.current=!1,a}catch(a){if(r.current=!1,a instanceof Error){if("NotAllowedError"===a.name||"PermissionDeniedError"===a.name)throw new to("Permissão para acessar a câmera foi negada pelo usuário");if("NotFoundError"===a.name||"DevicesNotFoundError"===a.name)throw new Error("Nenhuma câmera foi encontrada no dispositivo");if("NotReadableError"===a.name||"TrackStartError"===a.name)throw new Error("A câmera já está sendo usada por outro aplicativo");if("OverconstrainedError"===a.name||"ConstraintNotSatisfiedError"===a.name)throw new Error("As configurações solicitadas não são suportadas pela câmera")}throw new Error(`Erro ao inicializar câmera: ${a instanceof Error?a.message:String(a)}`)}}),[]),stopCamera:n.useCallback((n=>{const t=e.current;t&&t.getStream()===n&&(t.stop(),e.current=null,o(!1),r.current=!1)}),[]),cleanup:n.useCallback((()=>{e.current&&(e.current.stop(),e.current=null,o(!1),r.current=!1)}),[]),isActive:t}};var ao=(e=>(e.NETWORK="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.CONSENT_DENIED="ConsentDeniedError",e.LIVENESS_BLINK_MISSING="LivenessBlinkMissingError",e.GESTURE_NOT_DETECTED="GestureNotDetectedError",e))(ao||{});class io extends Error{constructor(e,n){super(e),l(this,"type"),l(this,"retryAfterMs"),this.name=n,this.type=n}getFriendlyMessage(){if(/[áéíóúãõç]/i.test(this.message))return this.message;switch(this.type){case"NetworkError":return this.message.includes("timeout")?"A conexão demorou muito. Tente novamente.":"Não foi possível conectar ao servidor. Verifique sua internet.";case"InvalidTokenError":return"Falha na autenticação do aplicativo. Entre em contato com o suporte.";case"CameraError":case"NoCameraError":return"Não conseguimos acessar sua câmera. Verifique as permissões do navegador.";case"LoginFailedError":case"RecognitionFailedError":return"Não foi possível reconhecer seu rosto. Tente se posicionar em um local mais iluminado.";case"ValidationError":return"Dados inválidos ou rosto não detectado corretamente.";case"ConsentDeniedError":return"É necessário aceitar o uso do seu rosto para continuar.";case"LivenessBlinkMissingError":return"Não detectamos uma piscada. Pisque os olhos naturalmente e tente novamente.";case"GestureNotDetectedError":return"Não detectamos o polegar para cima. Mostre o gesto claramente para a câmera e tente novamente.";case"ApiError":return void 0!==this.retryAfterMs?this.message:this.message.includes("400")?"Requisição inválida. Tente novamente.":this.message.includes("500")?"Ocorreu um erro interno no sistema. Tente mais tarde.":"O serviço encontrou um problema inesperado.";default:return"Ocorreu um erro inesperado. Por favor, tente novamente."}}}function so(e,n,t){function o(t,o){if(t._zod||Object.defineProperty(t,"_zod",{value:{def:o,constr:i,traits:new Set},enumerable:!1}),t._zod.traits.has(e))return;t._zod.traits.add(e),n(t,o);const r=i.prototype,a=Object.keys(r);for(let e=0;e<a.length;e++){const n=a[e];n in t||(t[n]=r[n].bind(t))}}const r=(null==t?void 0:t.Parent)??Object;class a extends r{}function i(e){var n;const r=(null==t?void 0:t.Parent)?new a:this;o(r,e),(n=r._zod).deferred??(n.deferred=[]);for(const t of r._zod.deferred)t();return r}return Object.defineProperty(a,"name",{value:e}),Object.defineProperty(i,"init",{value:o}),Object.defineProperty(i,Symbol.hasInstance,{value:n=>{var o,r;return!!((null==t?void 0:t.Parent)&&n instanceof t.Parent)||(null==(r=null==(o=null==n?void 0:n._zod)?void 0:o.traits)?void 0:r.has(e))}}),Object.defineProperty(i,"name",{value:e}),i}class co extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class lo extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const uo={};function po(e){return uo}function fo(e){const n=Object.values(e).filter((e=>"number"==typeof e));return Object.entries(e).filter((([e,t])=>-1===n.indexOf(+e))).map((([e,n])=>n))}function ho(e,n){return"bigint"==typeof n?n.toString():n}function mo(e){return{get value(){{const n=e();return Object.defineProperty(this,"value",{value:n}),n}}}}function go(e){return null==e}function vo(e){const n=e.startsWith("^")?1:0,t=e.endsWith("$")?e.length-1:e.length;return e.slice(n,t)}const wo=Symbol("evaluating");function bo(e,n,t){let o;Object.defineProperty(e,n,{get(){if(o!==wo)return void 0===o&&(o=wo,o=t()),o},set(t){Object.defineProperty(e,n,{value:t})},configurable:!0})}function xo(e,n,t){Object.defineProperty(e,n,{value:t,writable:!0,enumerable:!0,configurable:!0})}function yo(...e){const n={};for(const t of e){const e=Object.getOwnPropertyDescriptors(t);Object.assign(n,e)}return Object.defineProperties({},n)}function _o(e){return JSON.stringify(e)}const ko="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Eo(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const To=mo((()=>{var e;if("undefined"!=typeof navigator&&(null==(e=null==navigator?void 0:navigator.userAgent)?void 0:e.includes("Cloudflare")))return!1;try{return new Function(""),!0}catch(n){return!1}}));function No(e){if(!1===Eo(e))return!1;const n=e.constructor;if(void 0===n)return!0;if("function"!=typeof n)return!0;const t=n.prototype;return!1!==Eo(t)&&!1!==Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")}function So(e){return No(e)?{...e}:Array.isArray(e)?[...e]:e}const Co=new Set(["string","number","symbol"]);function Io(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ro(e,n,t){const o=new e._zod.constr(n??e._zod.def);return n&&!(null==t?void 0:t.parent)||(o._zod.parent=e),o}function Oo(e){const n=e;if(!n)return{};if("string"==typeof n)return{error:()=>n};if(void 0!==(null==n?void 0:n.message)){if(void 0!==(null==n?void 0:n.error))throw new Error("Cannot specify both `message` and `error` params");n.error=n.message}return delete n.message,"string"==typeof n.error?{...n,error:()=>n.error}:n}const jo={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Ao(e,n=0){var t;if(!0===e.aborted)return!0;for(let o=n;o<e.issues.length;o++)if(!0!==(null==(t=e.issues[o])?void 0:t.continue))return!0;return!1}function Po(e,n){return n.map((n=>{var t;return(t=n).path??(t.path=[]),n.path.unshift(e),n}))}function Fo(e){return"string"==typeof e?e:null==e?void 0:e.message}function zo(e,n,t){var o,r,a,i,s,c;const l={...e,path:e.path??[]};if(!e.message){const d=Fo(null==(a=null==(r=null==(o=e.inst)?void 0:o._zod.def)?void 0:r.error)?void 0:a.call(r,e))??Fo(null==(i=null==n?void 0:n.error)?void 0:i.call(n,e))??Fo(null==(s=t.customError)?void 0:s.call(t,e))??Fo(null==(c=t.localeError)?void 0:c.call(t,e))??"Invalid input";l.message=d}return delete l.inst,delete l.continue,(null==n?void 0:n.reportInput)||delete l.input,l}function $o(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function Do(...e){const[n,t,o]=e;return"string"==typeof n?{message:n,code:"custom",input:t,inst:o}:{...n}}const Mo=(e,n)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:n,enumerable:!1}),e.message=JSON.stringify(n,ho,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Lo=so("$ZodError",Mo),Bo=so("$ZodError",Mo,{Parent:Error});const Wo=e=>(n,t,o,r)=>{const a=o?Object.assign(o,{async:!1}):{async:!1},i=n._zod.run({value:t,issues:[]},a);if(i instanceof Promise)throw new co;if(i.issues.length){const n=new((null==r?void 0:r.Err)??e)(i.issues.map((e=>zo(e,a,po()))));throw ko(n,null==r?void 0:r.callee),n}return i.value},qo=e=>async(n,t,o,r)=>{const a=o?Object.assign(o,{async:!0}):{async:!0};let i=n._zod.run({value:t,issues:[]},a);if(i instanceof Promise&&(i=await i),i.issues.length){const n=new((null==r?void 0:r.Err)??e)(i.issues.map((e=>zo(e,a,po()))));throw ko(n,null==r?void 0:r.callee),n}return i.value},Uo=e=>(n,t,o)=>{const r=o?{...o,async:!1}:{async:!1},a=n._zod.run({value:t,issues:[]},r);if(a instanceof Promise)throw new co;return a.issues.length?{success:!1,error:new(e??Lo)(a.issues.map((e=>zo(e,r,po()))))}:{success:!0,data:a.value}},Vo=Uo(Bo),Ko=e=>async(n,t,o)=>{const r=o?Object.assign(o,{async:!0}):{async:!0};let a=n._zod.run({value:t,issues:[]},r);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map((e=>zo(e,r,po()))))}:{success:!0,data:a.value}},Zo=Ko(Bo),Ho=e=>(n,t,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return Wo(e)(n,t,r)},Go=e=>(n,t,o)=>Wo(e)(n,t,o),Jo=e=>async(n,t,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return qo(e)(n,t,r)},Xo=e=>async(n,t,o)=>qo(e)(n,t,o),Yo=e=>(n,t,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return Uo(e)(n,t,r)},Qo=e=>(n,t,o)=>Uo(e)(n,t,o),er=e=>async(n,t,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return Ko(e)(n,t,r)},nr=e=>async(n,t,o)=>Ko(e)(n,t,o),tr=/^[cC][^\s-]{8,}$/,or=/^[0-9a-z]+$/,rr=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ar=/^[0-9a-vA-V]{20}$/,ir=/^[A-Za-z0-9]{27}$/,sr=/^[a-zA-Z0-9_-]{21}$/,cr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,lr=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,dr=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,ur=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const pr=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,fr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,hr=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,mr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,gr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,vr=/^[A-Za-z0-9_-]*$/,wr=/^\+[1-9]\d{6,14}$/,br="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",xr=new RegExp(`^${br}$`);function yr(e){const n="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${n}`:0===e.precision?`${n}:[0-5]\\d`:`${n}:[0-5]\\d\\.\\d{${e.precision}}`:`${n}(?::[0-5]\\d(?:\\.\\d+)?)?`}const _r=/^-?\d+$/,kr=/^-?\d+(?:\.\d+)?$/,Er=/^(?:true|false)$/i,Tr=/^[^A-Z]*$/,Nr=/^[^a-z]*$/,Sr=so("$ZodCheck",((e,n)=>{var t;e._zod??(e._zod={}),e._zod.def=n,(t=e._zod).onattach??(t.onattach=[])})),Cr={number:"number",bigint:"bigint",object:"date"},Ir=so("$ZodCheckLessThan",((e,n)=>{Sr.init(e,n);const t=Cr[typeof n.value];e._zod.onattach.push((e=>{const t=e._zod.bag,o=(n.inclusive?t.maximum:t.exclusiveMaximum)??Number.POSITIVE_INFINITY;n.value<o&&(n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value)})),e._zod.check=o=>{(n.inclusive?o.value<=n.value:o.value<n.value)||o.issues.push({origin:t,code:"too_big",maximum:"object"==typeof n.value?n.value.getTime():n.value,input:o.value,inclusive:n.inclusive,inst:e,continue:!n.abort})}})),Rr=so("$ZodCheckGreaterThan",((e,n)=>{Sr.init(e,n);const t=Cr[typeof n.value];e._zod.onattach.push((e=>{const t=e._zod.bag,o=(n.inclusive?t.minimum:t.exclusiveMinimum)??Number.NEGATIVE_INFINITY;n.value>o&&(n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value)})),e._zod.check=o=>{(n.inclusive?o.value>=n.value:o.value>n.value)||o.issues.push({origin:t,code:"too_small",minimum:"object"==typeof n.value?n.value.getTime():n.value,input:o.value,inclusive:n.inclusive,inst:e,continue:!n.abort})}})),Or=so("$ZodCheckMultipleOf",((e,n)=>{Sr.init(e,n),e._zod.onattach.push((e=>{var t;(t=e._zod.bag).multipleOf??(t.multipleOf=n.value)})),e._zod.check=t=>{if(typeof t.value!=typeof n.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof t.value?t.value%n.value===BigInt(0):0===function(e,n){const t=(e.toString().split(".")[1]||"").length,o=n.toString();let r=(o.split(".")[1]||"").length;if(0===r&&/\d?e-\d?/.test(o)){const e=o.match(/\d?e-(\d?)/);(null==e?void 0:e[1])&&(r=Number.parseInt(e[1]))}const a=t>r?t:r;return Number.parseInt(e.toFixed(a).replace(".",""))%Number.parseInt(n.toFixed(a).replace(".",""))/10**a}(t.value,n.value))||t.issues.push({origin:typeof t.value,code:"not_multiple_of",divisor:n.value,input:t.value,inst:e,continue:!n.abort})}})),jr=so("$ZodCheckNumberFormat",((e,n)=>{var t;Sr.init(e,n),n.format=n.format||"float64";const o=null==(t=n.format)?void 0:t.includes("int"),r=o?"int":"number",[a,i]=jo[n.format];e._zod.onattach.push((e=>{const t=e._zod.bag;t.format=n.format,t.minimum=a,t.maximum=i,o&&(t.pattern=_r)})),e._zod.check=t=>{const s=t.value;if(o){if(!Number.isInteger(s))return void t.issues.push({expected:r,format:n.format,code:"invalid_type",continue:!1,input:s,inst:e});if(!Number.isSafeInteger(s))return void(s>0?t.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!n.abort}):t.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!n.abort}))}s<a&&t.issues.push({origin:"number",input:s,code:"too_small",minimum:a,inclusive:!0,inst:e,continue:!n.abort}),s>i&&t.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!n.abort})}})),Ar=so("$ZodCheckMaxLength",((e,n)=>{var t;Sr.init(e,n),(t=e._zod.def).when??(t.when=e=>{const n=e.value;return!go(n)&&void 0!==n.length}),e._zod.onattach.push((e=>{const t=e._zod.bag.maximum??Number.POSITIVE_INFINITY;n.maximum<t&&(e._zod.bag.maximum=n.maximum)})),e._zod.check=t=>{const o=t.value;if(o.length<=n.maximum)return;const r=$o(o);t.issues.push({origin:r,code:"too_big",maximum:n.maximum,inclusive:!0,input:o,inst:e,continue:!n.abort})}})),Pr=so("$ZodCheckMinLength",((e,n)=>{var t;Sr.init(e,n),(t=e._zod.def).when??(t.when=e=>{const n=e.value;return!go(n)&&void 0!==n.length}),e._zod.onattach.push((e=>{const t=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;n.minimum>t&&(e._zod.bag.minimum=n.minimum)})),e._zod.check=t=>{const o=t.value;if(o.length>=n.minimum)return;const r=$o(o);t.issues.push({origin:r,code:"too_small",minimum:n.minimum,inclusive:!0,input:o,inst:e,continue:!n.abort})}})),Fr=so("$ZodCheckLengthEquals",((e,n)=>{var t;Sr.init(e,n),(t=e._zod.def).when??(t.when=e=>{const n=e.value;return!go(n)&&void 0!==n.length}),e._zod.onattach.push((e=>{const t=e._zod.bag;t.minimum=n.length,t.maximum=n.length,t.length=n.length})),e._zod.check=t=>{const o=t.value,r=o.length;if(r===n.length)return;const a=$o(o),i=r>n.length;t.issues.push({origin:a,...i?{code:"too_big",maximum:n.length}:{code:"too_small",minimum:n.length},inclusive:!0,exact:!0,input:t.value,inst:e,continue:!n.abort})}})),zr=so("$ZodCheckStringFormat",((e,n)=>{var t,o;Sr.init(e,n),e._zod.onattach.push((e=>{const t=e._zod.bag;t.format=n.format,n.pattern&&(t.patterns??(t.patterns=new Set),t.patterns.add(n.pattern))})),n.pattern?(t=e._zod).check??(t.check=t=>{n.pattern.lastIndex=0,n.pattern.test(t.value)||t.issues.push({origin:"string",code:"invalid_format",format:n.format,input:t.value,...n.pattern?{pattern:n.pattern.toString()}:{},inst:e,continue:!n.abort})}):(o=e._zod).check??(o.check=()=>{})})),$r=so("$ZodCheckRegex",((e,n)=>{zr.init(e,n),e._zod.check=t=>{n.pattern.lastIndex=0,n.pattern.test(t.value)||t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:n.pattern.toString(),inst:e,continue:!n.abort})}})),Dr=so("$ZodCheckLowerCase",((e,n)=>{n.pattern??(n.pattern=Tr),zr.init(e,n)})),Mr=so("$ZodCheckUpperCase",((e,n)=>{n.pattern??(n.pattern=Nr),zr.init(e,n)})),Lr=so("$ZodCheckIncludes",((e,n)=>{Sr.init(e,n);const t=Io(n.includes),o=new RegExp("number"==typeof n.position?`^.{${n.position}}${t}`:t);n.pattern=o,e._zod.onattach.push((e=>{const n=e._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(o)})),e._zod.check=t=>{t.value.includes(n.includes,n.position)||t.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:n.includes,input:t.value,inst:e,continue:!n.abort})}})),Br=so("$ZodCheckStartsWith",((e,n)=>{Sr.init(e,n);const t=new RegExp(`^${Io(n.prefix)}.*`);n.pattern??(n.pattern=t),e._zod.onattach.push((e=>{const n=e._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(t)})),e._zod.check=t=>{t.value.startsWith(n.prefix)||t.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:n.prefix,input:t.value,inst:e,continue:!n.abort})}})),Wr=so("$ZodCheckEndsWith",((e,n)=>{Sr.init(e,n);const t=new RegExp(`.*${Io(n.suffix)}$`);n.pattern??(n.pattern=t),e._zod.onattach.push((e=>{const n=e._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(t)})),e._zod.check=t=>{t.value.endsWith(n.suffix)||t.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:n.suffix,input:t.value,inst:e,continue:!n.abort})}})),qr=so("$ZodCheckOverwrite",((e,n)=>{Sr.init(e,n),e._zod.check=e=>{e.value=n.tx(e.value)}}));class Ur{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const n=e.split("\n").filter((e=>e)),t=Math.min(...n.map((e=>e.length-e.trimStart().length))),o=n.map((e=>e.slice(t))).map((e=>" ".repeat(2*this.indent)+e));for(const r of o)this.content.push(r)}compile(){return new Function(...null==this?void 0:this.args,[...((null==this?void 0:this.content)??[""]).map((e=>` ${e}`))].join("\n"))}}const Vr={major:4,minor:3,patch:6},Kr=so("$ZodType",((e,n)=>{var t,o;e??(e={}),e._zod.def=n,e._zod.bag=e._zod.bag||{},e._zod.version=Vr;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const a of r)for(const n of a._zod.onattach)n(e);if(0===r.length)(o=e._zod).deferred??(o.deferred=[]),null==(t=e._zod.deferred)||t.push((()=>{e._zod.run=e._zod.parse}));else{const n=(e,n,t)=>{let o,r=Ao(e);for(const a of n){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;const n=e.issues.length,i=a._zod.check(e);if(i instanceof Promise&&!1===(null==t?void 0:t.async))throw new co;if(o||i instanceof Promise)o=(o??Promise.resolve()).then((async()=>{await i;e.issues.length!==n&&(r||(r=Ao(e,n)))}));else{if(e.issues.length===n)continue;r||(r=Ao(e,n))}}return o?o.then((()=>e)):e},t=(t,o,a)=>{if(Ao(t))return t.aborted=!0,t;const i=n(o,r,a);if(i instanceof Promise){if(!1===a.async)throw new co;return i.then((n=>e._zod.parse(n,a)))}return e._zod.parse(i,a)};e._zod.run=(o,a)=>{if(a.skipChecks)return e._zod.parse(o,a);if("backward"===a.direction){const n=e._zod.parse({value:o.value,issues:[]},{...a,skipChecks:!0});return n instanceof Promise?n.then((e=>t(e,o,a))):t(n,o,a)}const i=e._zod.parse(o,a);if(i instanceof Promise){if(!1===a.async)throw new co;return i.then((e=>n(e,r,a)))}return n(i,r,a)}}bo(e,"~standard",(()=>({validate:n=>{var t;try{const o=Vo(e,n);return o.success?{value:o.data}:{issues:null==(t=o.error)?void 0:t.issues}}catch(o){return Zo(e,n).then((e=>{var n;return e.success?{value:e.data}:{issues:null==(n=e.error)?void 0:n.issues}}))}},vendor:"zod",version:1})))})),Zr=so("$ZodString",((e,n)=>{var t;Kr.init(e,n),e._zod.pattern=[...(null==(t=null==e?void 0:e._zod.bag)?void 0:t.patterns)??[]].pop()??(e=>{const n=e?`[\\s\\S]{${(null==e?void 0:e.minimum)??0},${(null==e?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${n}$`)})(e._zod.bag),e._zod.parse=(t,o)=>{if(n.coerce)try{t.value=String(t.value)}catch(r){}return"string"==typeof t.value||t.issues.push({expected:"string",code:"invalid_type",input:t.value,inst:e}),t}})),Hr=so("$ZodStringFormat",((e,n)=>{zr.init(e,n),Zr.init(e,n)})),Gr=so("$ZodGUID",((e,n)=>{n.pattern??(n.pattern=lr),Hr.init(e,n)})),Jr=so("$ZodUUID",((e,n)=>{if(n.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[n.version];if(void 0===e)throw new Error(`Invalid UUID version: "${n.version}"`);n.pattern??(n.pattern=dr(e))}else n.pattern??(n.pattern=dr());Hr.init(e,n)})),Xr=so("$ZodEmail",((e,n)=>{n.pattern??(n.pattern=ur),Hr.init(e,n)})),Yr=so("$ZodURL",((e,n)=>{Hr.init(e,n),e._zod.check=t=>{try{const o=t.value.trim(),r=new URL(o);return n.hostname&&(n.hostname.lastIndex=0,n.hostname.test(r.hostname)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:n.hostname.source,input:t.value,inst:e,continue:!n.abort})),n.protocol&&(n.protocol.lastIndex=0,n.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:n.protocol.source,input:t.value,inst:e,continue:!n.abort})),void(n.normalize?t.value=r.href:t.value=o)}catch(o){t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:e,continue:!n.abort})}}})),Qr=so("$ZodEmoji",((e,n)=>{n.pattern??(n.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Hr.init(e,n)})),ea=so("$ZodNanoID",((e,n)=>{n.pattern??(n.pattern=sr),Hr.init(e,n)})),na=so("$ZodCUID",((e,n)=>{n.pattern??(n.pattern=tr),Hr.init(e,n)})),ta=so("$ZodCUID2",((e,n)=>{n.pattern??(n.pattern=or),Hr.init(e,n)})),oa=so("$ZodULID",((e,n)=>{n.pattern??(n.pattern=rr),Hr.init(e,n)})),ra=so("$ZodXID",((e,n)=>{n.pattern??(n.pattern=ar),Hr.init(e,n)})),aa=so("$ZodKSUID",((e,n)=>{n.pattern??(n.pattern=ir),Hr.init(e,n)})),ia=so("$ZodISODateTime",((e,n)=>{n.pattern??(n.pattern=function(e){const n=yr({precision:e.precision}),t=["Z"];e.local&&t.push(""),e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const o=`${n}(?:${t.join("|")})`;return new RegExp(`^${br}T(?:${o})$`)}(n)),Hr.init(e,n)})),sa=so("$ZodISODate",((e,n)=>{n.pattern??(n.pattern=xr),Hr.init(e,n)})),ca=so("$ZodISOTime",((e,n)=>{n.pattern??(n.pattern=new RegExp(`^${yr(n)}$`)),Hr.init(e,n)})),la=so("$ZodISODuration",((e,n)=>{n.pattern??(n.pattern=cr),Hr.init(e,n)})),da=so("$ZodIPv4",((e,n)=>{n.pattern??(n.pattern=pr),Hr.init(e,n),e._zod.bag.format="ipv4"})),ua=so("$ZodIPv6",((e,n)=>{n.pattern??(n.pattern=fr),Hr.init(e,n),e._zod.bag.format="ipv6",e._zod.check=t=>{try{new URL(`http://[${t.value}]`)}catch{t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:e,continue:!n.abort})}}})),pa=so("$ZodCIDRv4",((e,n)=>{n.pattern??(n.pattern=hr),Hr.init(e,n)})),fa=so("$ZodCIDRv6",((e,n)=>{n.pattern??(n.pattern=mr),Hr.init(e,n),e._zod.check=t=>{const o=t.value.split("/");try{if(2!==o.length)throw new Error;const[e,n]=o;if(!n)throw new Error;const t=Number(n);if(`${t}`!==n)throw new Error;if(t<0||t>128)throw new Error;new URL(`http://[${e}]`)}catch{t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:e,continue:!n.abort})}}}));function ha(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const ma=so("$ZodBase64",((e,n)=>{n.pattern??(n.pattern=gr),Hr.init(e,n),e._zod.bag.contentEncoding="base64",e._zod.check=t=>{ha(t.value)||t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:e,continue:!n.abort})}}));const ga=so("$ZodBase64URL",((e,n)=>{n.pattern??(n.pattern=vr),Hr.init(e,n),e._zod.bag.contentEncoding="base64url",e._zod.check=t=>{(function(e){if(!vr.test(e))return!1;const n=e.replace(/[-_]/g,(e=>"-"===e?"+":"/"));return ha(n.padEnd(4*Math.ceil(n.length/4),"="))})(t.value)||t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:e,continue:!n.abort})}})),va=so("$ZodE164",((e,n)=>{n.pattern??(n.pattern=wr),Hr.init(e,n)}));const wa=so("$ZodJWT",((e,n)=>{Hr.init(e,n),e._zod.check=t=>{(function(e,n=null){try{const t=e.split(".");if(3!==t.length)return!1;const[o]=t;if(!o)return!1;const r=JSON.parse(atob(o));return!("typ"in r&&"JWT"!==(null==r?void 0:r.typ)||!r.alg||n&&(!("alg"in r)||r.alg!==n))}catch{return!1}})(t.value,n.alg)||t.issues.push({code:"invalid_format",format:"jwt",input:t.value,inst:e,continue:!n.abort})}})),ba=so("$ZodNumber",((e,n)=>{Kr.init(e,n),e._zod.pattern=e._zod.bag.pattern??kr,e._zod.parse=(t,o)=>{if(n.coerce)try{t.value=Number(t.value)}catch(i){}const r=t.value;if("number"==typeof r&&!Number.isNaN(r)&&Number.isFinite(r))return t;const a="number"==typeof r?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return t.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...a?{received:a}:{}}),t}})),xa=so("$ZodNumberFormat",((e,n)=>{jr.init(e,n),ba.init(e,n)})),ya=so("$ZodBoolean",((e,n)=>{Kr.init(e,n),e._zod.pattern=Er,e._zod.parse=(t,o)=>{if(n.coerce)try{t.value=Boolean(t.value)}catch(a){}const r=t.value;return"boolean"==typeof r||t.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),t}})),_a=so("$ZodAny",((e,n)=>{Kr.init(e,n),e._zod.parse=e=>e})),ka=so("$ZodUnknown",((e,n)=>{Kr.init(e,n),e._zod.parse=e=>e})),Ea=so("$ZodNever",((e,n)=>{Kr.init(e,n),e._zod.parse=(n,t)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}));function Ta(e,n,t){e.issues.length&&n.issues.push(...Po(t,e.issues)),n.value[t]=e.value}const Na=so("$ZodArray",((e,n)=>{Kr.init(e,n),e._zod.parse=(t,o)=>{const r=t.value;if(!Array.isArray(r))return t.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),t;t.value=Array(r.length);const a=[];for(let e=0;e<r.length;e++){const i=r[e],s=n.element._zod.run({value:i,issues:[]},o);s instanceof Promise?a.push(s.then((n=>Ta(n,t,e)))):Ta(s,t,e)}return a.length?Promise.all(a).then((()=>t)):t}}));function Sa(e,n,t,o,r){if(e.issues.length){if(r&&!(t in o))return;n.issues.push(...Po(t,e.issues))}void 0===e.value?t in o&&(n.value[t]=void 0):n.value[t]=e.value}function Ca(e){var n,t,o,r;const a=Object.keys(e.shape);for(const c of a)if(!(null==(r=null==(o=null==(t=null==(n=e.shape)?void 0:n[c])?void 0:t._zod)?void 0:o.traits)?void 0:r.has("$ZodType")))throw new Error(`Invalid element at key "${c}": expected a Zod schema`);const i=(s=e.shape,Object.keys(s).filter((e=>"optional"===s[e]._zod.optin&&"optional"===s[e]._zod.optout)));var s;return{...e,keys:a,keySet:new Set(a),numKeys:a.length,optionalKeys:new Set(i)}}function Ia(e,n,t,o,r,a){const i=[],s=r.keySet,c=r.catchall._zod,l=c.def.type,d="optional"===c.optout;for(const u in n){if(s.has(u))continue;if("never"===l){i.push(u);continue}const r=c.run({value:n[u],issues:[]},o);r instanceof Promise?e.push(r.then((e=>Sa(e,t,u,n,d)))):Sa(r,t,u,n,d)}return i.length&&t.issues.push({code:"unrecognized_keys",keys:i,input:n,inst:a}),e.length?Promise.all(e).then((()=>t)):t}const Ra=so("$ZodObject",((e,n)=>{Kr.init(e,n);const t=Object.getOwnPropertyDescriptor(n,"shape");if(!(null==t?void 0:t.get)){const e=n.shape;Object.defineProperty(n,"shape",{get:()=>{const t={...e};return Object.defineProperty(n,"shape",{value:t}),t}})}const o=mo((()=>Ca(n)));bo(e._zod,"propValues",(()=>{const e=n.shape,t={};for(const n in e){const o=e[n]._zod;if(o.values){t[n]??(t[n]=new Set);for(const e of o.values)t[n].add(e)}}return t}));const r=Eo,a=n.catchall;let i;e._zod.parse=(n,t)=>{i??(i=o.value);const s=n.value;if(!r(s))return n.issues.push({expected:"object",code:"invalid_type",input:s,inst:e}),n;n.value={};const c=[],l=i.shape;for(const e of i.keys){const o=l[e],r="optional"===o._zod.optout,a=o._zod.run({value:s[e],issues:[]},t);a instanceof Promise?c.push(a.then((t=>Sa(t,n,e,s,r)))):Sa(a,n,e,s,r)}return a?Ia(c,s,n,t,o.value,e):c.length?Promise.all(c).then((()=>n)):n}})),Oa=so("$ZodObjectJIT",((e,n)=>{Ra.init(e,n);const t=e._zod.parse,o=mo((()=>Ca(n)));let r;const a=Eo,i=!uo.jitless,s=i&&To.value,c=n.catchall;let l;e._zod.parse=(d,u)=>{l??(l=o.value);const p=d.value;return a(p)?i&&s&&!1===(null==u?void 0:u.async)&&!0!==u.jitless?(r||(r=(e=>{var n;const t=new Ur(["shape","payload","ctx"]),r=o.value,a=e=>{const n=_o(e);return`shape[${n}]._zod.run({ value: input[${n}], issues: [] }, ctx)`};t.write("const input = payload.value;");const i=Object.create(null);let s=0;for(const o of r.keys)i[o]="key_"+s++;t.write("const newResult = {};");for(const o of r.keys){const r=i[o],s=_o(o),c=e[o],l="optional"===(null==(n=null==c?void 0:c._zod)?void 0:n.optout);t.write(`const ${r} = ${a(o)};`),l?t.write(`\n if (${r}.issues.length) {\n if (${s} in input) {\n payload.issues = payload.issues.concat(${r}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n }\n \n if (${r}.value === undefined) {\n if (${s} in input) {\n newResult[${s}] = undefined;\n }\n } else {\n newResult[${s}] = ${r}.value;\n }\n \n `):t.write(`\n if (${r}.issues.length) {\n payload.issues = payload.issues.concat(${r}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n \n if (${r}.value === undefined) {\n if (${s} in input) {\n newResult[${s}] = undefined;\n }\n } else {\n newResult[${s}] = ${r}.value;\n }\n \n `)}t.write("payload.value = newResult;"),t.write("return payload;");const c=t.compile();return(n,t)=>c(e,n,t)})(n.shape)),d=r(d,u),c?Ia([],p,d,u,l,e):d):t(d,u):(d.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),d)}}));function ja(e,n,t,o){for(const a of e)if(0===a.issues.length)return n.value=a.value,n;const r=e.filter((e=>!Ao(e)));return 1===r.length?(n.value=r[0].value,r[0]):(n.issues.push({code:"invalid_union",input:n.value,inst:t,errors:e.map((e=>e.issues.map((e=>zo(e,o,po())))))}),n)}const Aa=so("$ZodUnion",((e,n)=>{Kr.init(e,n),bo(e._zod,"optin",(()=>n.options.some((e=>"optional"===e._zod.optin))?"optional":void 0)),bo(e._zod,"optout",(()=>n.options.some((e=>"optional"===e._zod.optout))?"optional":void 0)),bo(e._zod,"values",(()=>{if(n.options.every((e=>e._zod.values)))return new Set(n.options.flatMap((e=>Array.from(e._zod.values))))})),bo(e._zod,"pattern",(()=>{if(n.options.every((e=>e._zod.pattern))){const e=n.options.map((e=>e._zod.pattern));return new RegExp(`^(${e.map((e=>vo(e.source))).join("|")})$`)}}));const t=1===n.options.length,o=n.options[0]._zod.run;e._zod.parse=(r,a)=>{if(t)return o(r,a);let i=!1;const s=[];for(const e of n.options){const n=e._zod.run({value:r.value,issues:[]},a);if(n instanceof Promise)s.push(n),i=!0;else{if(0===n.issues.length)return n;s.push(n)}}return i?Promise.all(s).then((n=>ja(n,r,e,a))):ja(s,r,e,a)}})),Pa=so("$ZodIntersection",((e,n)=>{Kr.init(e,n),e._zod.parse=(e,t)=>{const o=e.value,r=n.left._zod.run({value:o,issues:[]},t),a=n.right._zod.run({value:o,issues:[]},t);return r instanceof Promise||a instanceof Promise?Promise.all([r,a]).then((([n,t])=>za(e,n,t))):za(e,r,a)}}));function Fa(e,n){if(e===n)return{valid:!0,data:e};if(e instanceof Date&&n instanceof Date&&+e==+n)return{valid:!0,data:e};if(No(e)&&No(n)){const t=Object.keys(n),o=Object.keys(e).filter((e=>-1!==t.indexOf(e))),r={...e,...n};for(const a of o){const t=Fa(e[a],n[a]);if(!t.valid)return{valid:!1,mergeErrorPath:[a,...t.mergeErrorPath]};r[a]=t.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return{valid:!1,mergeErrorPath:[]};const t=[];for(let o=0;o<e.length;o++){const r=Fa(e[o],n[o]);if(!r.valid)return{valid:!1,mergeErrorPath:[o,...r.mergeErrorPath]};t.push(r.data)}return{valid:!0,data:t}}return{valid:!1,mergeErrorPath:[]}}function za(e,n,t){const o=new Map;let r;for(const s of n.issues)if("unrecognized_keys"===s.code){r??(r=s);for(const e of s.keys)o.has(e)||o.set(e,{}),o.get(e).l=!0}else e.issues.push(s);for(const s of t.issues)if("unrecognized_keys"===s.code)for(const e of s.keys)o.has(e)||o.set(e,{}),o.get(e).r=!0;else e.issues.push(s);const a=[...o].filter((([,e])=>e.l&&e.r)).map((([e])=>e));if(a.length&&r&&e.issues.push({...r,keys:a}),Ao(e))return e;const i=Fa(n.value,t.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const $a=so("$ZodEnum",((e,n)=>{Kr.init(e,n);const t=fo(n.entries),o=new Set(t);e._zod.values=o,e._zod.pattern=new RegExp(`^(${t.filter((e=>Co.has(typeof e))).map((e=>"string"==typeof e?Io(e):e.toString())).join("|")})$`),e._zod.parse=(n,r)=>{const a=n.value;return o.has(a)||n.issues.push({code:"invalid_value",values:t,input:a,inst:e}),n}})),Da=so("$ZodTransform",((e,n)=>{Kr.init(e,n),e._zod.parse=(t,o)=>{if("backward"===o.direction)throw new lo(e.constructor.name);const r=n.transform(t.value,t);if(o.async){return(r instanceof Promise?r:Promise.resolve(r)).then((e=>(t.value=e,t)))}if(r instanceof Promise)throw new co;return t.value=r,t}}));function Ma(e,n){return e.issues.length&&void 0===n?{issues:[],value:void 0}:e}const La=so("$ZodOptional",((e,n)=>{Kr.init(e,n),e._zod.optin="optional",e._zod.optout="optional",bo(e._zod,"values",(()=>n.innerType._zod.values?new Set([...n.innerType._zod.values,void 0]):void 0)),bo(e._zod,"pattern",(()=>{const e=n.innerType._zod.pattern;return e?new RegExp(`^(${vo(e.source)})?$`):void 0})),e._zod.parse=(e,t)=>{if("optional"===n.innerType._zod.optin){const o=n.innerType._zod.run(e,t);return o instanceof Promise?o.then((n=>Ma(n,e.value))):Ma(o,e.value)}return void 0===e.value?e:n.innerType._zod.run(e,t)}})),Ba=so("$ZodExactOptional",((e,n)=>{La.init(e,n),bo(e._zod,"values",(()=>n.innerType._zod.values)),bo(e._zod,"pattern",(()=>n.innerType._zod.pattern)),e._zod.parse=(e,t)=>n.innerType._zod.run(e,t)})),Wa=so("$ZodNullable",((e,n)=>{Kr.init(e,n),bo(e._zod,"optin",(()=>n.innerType._zod.optin)),bo(e._zod,"optout",(()=>n.innerType._zod.optout)),bo(e._zod,"pattern",(()=>{const e=n.innerType._zod.pattern;return e?new RegExp(`^(${vo(e.source)}|null)$`):void 0})),bo(e._zod,"values",(()=>n.innerType._zod.values?new Set([...n.innerType._zod.values,null]):void 0)),e._zod.parse=(e,t)=>null===e.value?e:n.innerType._zod.run(e,t)})),qa=so("$ZodDefault",((e,n)=>{Kr.init(e,n),e._zod.optin="optional",bo(e._zod,"values",(()=>n.innerType._zod.values)),e._zod.parse=(e,t)=>{if("backward"===t.direction)return n.innerType._zod.run(e,t);if(void 0===e.value)return e.value=n.defaultValue,e;const o=n.innerType._zod.run(e,t);return o instanceof Promise?o.then((e=>Ua(e,n))):Ua(o,n)}}));function Ua(e,n){return void 0===e.value&&(e.value=n.defaultValue),e}const Va=so("$ZodPrefault",((e,n)=>{Kr.init(e,n),e._zod.optin="optional",bo(e._zod,"values",(()=>n.innerType._zod.values)),e._zod.parse=(e,t)=>("backward"===t.direction||void 0===e.value&&(e.value=n.defaultValue),n.innerType._zod.run(e,t))})),Ka=so("$ZodNonOptional",((e,n)=>{Kr.init(e,n),bo(e._zod,"values",(()=>{const e=n.innerType._zod.values;return e?new Set([...e].filter((e=>void 0!==e))):void 0})),e._zod.parse=(t,o)=>{const r=n.innerType._zod.run(t,o);return r instanceof Promise?r.then((n=>Za(n,e))):Za(r,e)}}));function Za(e,n){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:n}),e}const Ha=so("$ZodCatch",((e,n)=>{Kr.init(e,n),bo(e._zod,"optin",(()=>n.innerType._zod.optin)),bo(e._zod,"optout",(()=>n.innerType._zod.optout)),bo(e._zod,"values",(()=>n.innerType._zod.values)),e._zod.parse=(e,t)=>{if("backward"===t.direction)return n.innerType._zod.run(e,t);const o=n.innerType._zod.run(e,t);return o instanceof Promise?o.then((o=>(e.value=o.value,o.issues.length&&(e.value=n.catchValue({...e,error:{issues:o.issues.map((e=>zo(e,t,po())))},input:e.value}),e.issues=[]),e))):(e.value=o.value,o.issues.length&&(e.value=n.catchValue({...e,error:{issues:o.issues.map((e=>zo(e,t,po())))},input:e.value}),e.issues=[]),e)}})),Ga=so("$ZodPipe",((e,n)=>{Kr.init(e,n),bo(e._zod,"values",(()=>n.in._zod.values)),bo(e._zod,"optin",(()=>n.in._zod.optin)),bo(e._zod,"optout",(()=>n.out._zod.optout)),bo(e._zod,"propValues",(()=>n.in._zod.propValues)),e._zod.parse=(e,t)=>{if("backward"===t.direction){const o=n.out._zod.run(e,t);return o instanceof Promise?o.then((e=>Ja(e,n.in,t))):Ja(o,n.in,t)}const o=n.in._zod.run(e,t);return o instanceof Promise?o.then((e=>Ja(e,n.out,t))):Ja(o,n.out,t)}}));function Ja(e,n,t){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:e.value,issues:e.issues},t)}const Xa=so("$ZodReadonly",((e,n)=>{Kr.init(e,n),bo(e._zod,"propValues",(()=>n.innerType._zod.propValues)),bo(e._zod,"values",(()=>n.innerType._zod.values)),bo(e._zod,"optin",(()=>{var e,t;return null==(t=null==(e=n.innerType)?void 0:e._zod)?void 0:t.optin})),bo(e._zod,"optout",(()=>{var e,t;return null==(t=null==(e=n.innerType)?void 0:e._zod)?void 0:t.optout})),e._zod.parse=(e,t)=>{if("backward"===t.direction)return n.innerType._zod.run(e,t);const o=n.innerType._zod.run(e,t);return o instanceof Promise?o.then(Ya):Ya(o)}}));function Ya(e){return e.value=Object.freeze(e.value),e}const Qa=so("$ZodCustom",((e,n)=>{Sr.init(e,n),Kr.init(e,n),e._zod.parse=(e,n)=>e,e._zod.check=t=>{const o=t.value,r=n.fn(o);if(r instanceof Promise)return r.then((n=>ei(n,t,o,e)));ei(r,t,o,e)}}));function ei(e,n,t,o){if(!e){const e={code:"custom",input:t,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(e.params=o._zod.def.params),n.issues.push(Do(e))}}var ni;class ti{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...n){const t=n[0];return this._map.set(e,t),t&&"object"==typeof t&&"id"in t&&this._idmap.set(t.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const n=this._map.get(e);return n&&"object"==typeof n&&"id"in n&&this._idmap.delete(n.id),this._map.delete(e),this}get(e){const n=e._zod.parent;if(n){const t={...this.get(n)??{}};delete t.id;const o={...t,...this._map.get(e)};return Object.keys(o).length?o:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}(ni=globalThis).__zod_globalRegistry??(ni.__zod_globalRegistry=new ti);const oi=globalThis.__zod_globalRegistry;function ri(e,n){return new e({type:"string",...Oo(n)})}function ai(e,n){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Oo(n)})}function ii(e,n){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Oo(n)})}function si(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Oo(n)})}function ci(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Oo(n)})}function li(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Oo(n)})}function di(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Oo(n)})}function ui(e,n){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Oo(n)})}function pi(e,n){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Oo(n)})}function fi(e,n){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Oo(n)})}function hi(e,n){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Oo(n)})}function mi(e,n){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Oo(n)})}function gi(e,n){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Oo(n)})}function vi(e,n){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Oo(n)})}function wi(e,n){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Oo(n)})}function bi(e,n){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Oo(n)})}function xi(e,n){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Oo(n)})}function yi(e,n){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Oo(n)})}function _i(e,n){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Oo(n)})}function ki(e,n){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Oo(n)})}function Ei(e,n){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Oo(n)})}function Ti(e,n){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Oo(n)})}function Ni(e,n){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Oo(n)})}function Si(e,n){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Oo(n)})}function Ci(e,n){return new e({type:"string",format:"date",check:"string_format",...Oo(n)})}function Ii(e,n){return new e({type:"string",format:"time",check:"string_format",precision:null,...Oo(n)})}function Ri(e,n){return new e({type:"string",format:"duration",check:"string_format",...Oo(n)})}function Oi(e,n){return new e({type:"number",checks:[],...Oo(n)})}function ji(e,n){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Oo(n)})}function Ai(e,n){return new e({type:"boolean",...Oo(n)})}function Pi(e){return new e({type:"any"})}function Fi(e){return new e({type:"unknown"})}function zi(e,n){return new e({type:"never",...Oo(n)})}function $i(e,n){return new Ir({check:"less_than",...Oo(n),value:e,inclusive:!1})}function Di(e,n){return new Ir({check:"less_than",...Oo(n),value:e,inclusive:!0})}function Mi(e,n){return new Rr({check:"greater_than",...Oo(n),value:e,inclusive:!1})}function Li(e,n){return new Rr({check:"greater_than",...Oo(n),value:e,inclusive:!0})}function Bi(e,n){return new Or({check:"multiple_of",...Oo(n),value:e})}function Wi(e,n){return new Ar({check:"max_length",...Oo(n),maximum:e})}function qi(e,n){return new Pr({check:"min_length",...Oo(n),minimum:e})}function Ui(e,n){return new Fr({check:"length_equals",...Oo(n),length:e})}function Vi(e,n){return new $r({check:"string_format",format:"regex",...Oo(n),pattern:e})}function Ki(e){return new Dr({check:"string_format",format:"lowercase",...Oo(e)})}function Zi(e){return new Mr({check:"string_format",format:"uppercase",...Oo(e)})}function Hi(e,n){return new Lr({check:"string_format",format:"includes",...Oo(n),includes:e})}function Gi(e,n){return new Br({check:"string_format",format:"starts_with",...Oo(n),prefix:e})}function Ji(e,n){return new Wr({check:"string_format",format:"ends_with",...Oo(n),suffix:e})}function Xi(e){return new qr({check:"overwrite",tx:e})}function Yi(e){return Xi((n=>n.normalize(e)))}function Qi(){return Xi((e=>e.trim()))}function es(){return Xi((e=>e.toLowerCase()))}function ns(){return Xi((e=>e.toUpperCase()))}function ts(){return Xi((e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}function os(e,n,t){return new e({type:"array",element:n,...Oo(t)})}function rs(e,n,t){return new e({type:"custom",check:"custom",fn:n,...Oo(t)})}function as(e){const n=is((t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(Do(e,t.value,n._zod.def));else{const o=e;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=t.value),o.inst??(o.inst=n),o.continue??(o.continue=!n._zod.def.abort),t.issues.push(Do(o))}},e(t.value,t))));return n}function is(e,n){const t=new Sr({check:"custom",...Oo(n)});return t._zod.check=e,t}function ss(e){let n=(null==e?void 0:e.target)??"draft-2020-12";return"draft-4"===n&&(n="draft-04"),"draft-7"===n&&(n="draft-07"),{processors:e.processors??{},metadataRegistry:(null==e?void 0:e.metadata)??oi,target:n,unrepresentable:(null==e?void 0:e.unrepresentable)??"throw",override:(null==e?void 0:e.override)??(()=>{}),io:(null==e?void 0:e.io)??"output",counter:0,seen:new Map,cycles:(null==e?void 0:e.cycles)??"ref",reused:(null==e?void 0:e.reused)??"inline",external:(null==e?void 0:e.external)??void 0}}function cs(e,n,t={path:[],schemaPath:[]}){var o,r,a;const i=e._zod.def,s=n.seen.get(e);if(s){s.count++;return t.schemaPath.includes(e)&&(s.cycle=t.path),s.schema}const c={schema:{},count:1,cycle:void 0,path:t.path};n.seen.set(e,c);const l=null==(r=(o=e._zod).toJSONSchema)?void 0:r.call(o);if(l)c.schema=l;else{const o={...t,schemaPath:[...t.schemaPath,e],path:t.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(n,c.schema,o);else{const t=c.schema,r=n.processors[i.type];if(!r)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);r(e,n,t,o)}const r=e._zod.parent;r&&(c.ref||(c.ref=r),cs(r,n,o),n.seen.get(r).isParent=!0)}const d=n.metadataRegistry.get(e);d&&Object.assign(c.schema,d),"input"===n.io&&us(e)&&(delete c.schema.examples,delete c.schema.default),"input"===n.io&&c.schema._prefault&&((a=c.schema).default??(a.default=c.schema._prefault)),delete c.schema._prefault;return n.seen.get(e).schema}function ls(e,n){var t,o,r,a;const i=e.seen.get(n);if(!i)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=new Map;for(const l of e.seen.entries()){const n=null==(t=e.metadataRegistry.get(l[0]))?void 0:t.id;if(n){const e=s.get(n);if(e&&e!==l[0])throw new Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);s.set(n,l[0])}}const c=n=>{if(n[1].schema.$ref)return;const t=n[1],{ref:o,defId:r}=(n=>{var t;const o="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const r=null==(t=e.external.registry.get(n[0]))?void 0:t.id,a=e.external.uri??(e=>e);if(r)return{ref:a(r)};const i=n[1].defId??n[1].schema.id??"schema"+e.counter++;return n[1].defId=i,{defId:i,ref:`${a("__shared")}#/${o}/${i}`}}if(n[1]===i)return{ref:"#"};const r=`#/${o}/`,a=n[1].schema.id??"__schema"+e.counter++;return{defId:a,ref:r+a}})(n);t.def={...t.schema},r&&(t.defId=r);const a=t.schema;for(const e in a)delete a[e];a.$ref=o};if("throw"===e.cycles)for(const l of e.seen.entries()){const e=l[1];if(e.cycle)throw new Error(`Cycle detected: #/${null==(o=e.cycle)?void 0:o.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const l of e.seen.entries()){const t=l[1];if(n===l[0]){c(l);continue}if(e.external){const t=null==(r=e.external.registry.get(l[0]))?void 0:r.id;if(n!==l[0]&&t){c(l);continue}}(null==(a=e.metadataRegistry.get(l[0]))?void 0:a.id)?c(l):(t.cycle||t.count>1&&"ref"===e.reused)&&c(l)}}function ds(e,n){var t,o,r;const a=e.seen.get(n);if(!a)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=n=>{const t=e.seen.get(n);if(null===t.ref)return;const o=t.def??t.schema,r={...o},a=t.ref;if(t.ref=null,a){i(a);const t=e.seen.get(a),s=t.schema;!s.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?Object.assign(o,s):(o.allOf=o.allOf??[],o.allOf.push(s)),Object.assign(o,r);if(n._zod.parent===a)for(const e in o)"$ref"!==e&&"allOf"!==e&&(e in r||delete o[e]);if(s.$ref&&t.def)for(const e in o)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(o[e])===JSON.stringify(t.def[e])&&delete o[e]}const s=n._zod.parent;if(s&&s!==a){i(s);const n=e.seen.get(s);if((null==n?void 0:n.schema.$ref)&&(o.$ref=n.schema.$ref,n.def))for(const e in o)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(o[e])===JSON.stringify(n.def[e])&&delete o[e]}e.override({zodSchema:n,jsonSchema:o,path:t.path??[]})};for(const d of[...e.seen.entries()].reverse())i(d[0]);const s={};if("draft-2020-12"===e.target?s.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?s.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?s.$schema="http://json-schema.org/draft-04/schema#":e.target,null==(t=e.external)?void 0:t.uri){const t=null==(o=e.external.registry.get(n))?void 0:o.id;if(!t)throw new Error("Schema is missing an `id` property");s.$id=e.external.uri(t)}Object.assign(s,a.def??a.schema);const c=(null==(r=e.external)?void 0:r.defs)??{};for(const d of e.seen.entries()){const e=d[1];e.def&&e.defId&&(c[e.defId]=e.def)}e.external||Object.keys(c).length>0&&("draft-2020-12"===e.target?s.$defs=c:s.definitions=c);try{const t=JSON.parse(JSON.stringify(s));return Object.defineProperty(t,"~standard",{value:{...n["~standard"],jsonSchema:{input:ps(n,"input",e.processors),output:ps(n,"output",e.processors)}},enumerable:!1,writable:!1}),t}catch(l){throw new Error("Error converting schema to JSON.")}}function us(e,n){const t=n??{seen:new Set};if(t.seen.has(e))return!1;t.seen.add(e);const o=e._zod.def;if("transform"===o.type)return!0;if("array"===o.type)return us(o.element,t);if("set"===o.type)return us(o.valueType,t);if("lazy"===o.type)return us(o.getter(),t);if("promise"===o.type||"optional"===o.type||"nonoptional"===o.type||"nullable"===o.type||"readonly"===o.type||"default"===o.type||"prefault"===o.type)return us(o.innerType,t);if("intersection"===o.type)return us(o.left,t)||us(o.right,t);if("record"===o.type||"map"===o.type)return us(o.keyType,t)||us(o.valueType,t);if("pipe"===o.type)return us(o.in,t)||us(o.out,t);if("object"===o.type){for(const e in o.shape)if(us(o.shape[e],t))return!0;return!1}if("union"===o.type){for(const e of o.options)if(us(e,t))return!0;return!1}if("tuple"===o.type){for(const e of o.items)if(us(e,t))return!0;return!(!o.rest||!us(o.rest,t))}return!1}const ps=(e,n,t={})=>o=>{const{libraryOptions:r,target:a}=o??{},i=ss({...r??{},target:a,io:n,processors:t});return cs(e,i),ls(i,e),ds(i,e)},fs={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},hs=(e,n,t,o)=>{const r=e._zod.def;cs(r.innerType,n,o);n.seen.get(e).ref=r.innerType},ms=so("ZodISODateTime",((e,n)=>{ia.init(e,n),zs.init(e,n)}));const gs=so("ZodISODate",((e,n)=>{sa.init(e,n),zs.init(e,n)}));const vs=so("ZodISOTime",((e,n)=>{ca.init(e,n),zs.init(e,n)}));const ws=so("ZodISODuration",((e,n)=>{la.init(e,n),zs.init(e,n)}));const bs=so("ZodError",((e,n)=>{Lo.init(e,n),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>function(e,n=e=>e.message){const t={_errors:[]},o=e=>{for(const r of e.issues)if("invalid_union"===r.code&&r.errors.length)r.errors.map((e=>o({issues:e})));else if("invalid_key"===r.code)o({issues:r.issues});else if("invalid_element"===r.code)o({issues:r.issues});else if(0===r.path.length)t._errors.push(n(r));else{let e=t,o=0;for(;o<r.path.length;){const t=r.path[o];o===r.path.length-1?(e[t]=e[t]||{_errors:[]},e[t]._errors.push(n(r))):e[t]=e[t]||{_errors:[]},e=e[t],o++}}};return o(e),t}(e,n)},flatten:{value:n=>function(e,n=e=>e.message){const t={},o=[];for(const r of e.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(n(r))):o.push(n(r));return{formErrors:o,fieldErrors:t}}(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,ho,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,ho,2)}},isEmpty:{get:()=>0===e.issues.length}})}),{Parent:Error}),xs=Wo(bs),ys=qo(bs),_s=Uo(bs),ks=Ko(bs),Es=Ho(bs),Ts=Go(bs),Ns=Jo(bs),Ss=Xo(bs),Cs=Yo(bs),Is=Qo(bs),Rs=er(bs),Os=nr(bs),js=so("ZodType",((e,n)=>(Kr.init(e,n),Object.assign(e["~standard"],{jsonSchema:{input:ps(e,"input"),output:ps(e,"output")}}),e.toJSONSchema=((e,n={})=>t=>{const o=ss({...t,processors:n});return cs(e,o),ls(o,e),ds(o,e)})(e,{}),e.def=n,e.type=n.type,Object.defineProperty(e,"_def",{value:n}),e.check=(...t)=>e.clone(yo(n,{checks:[...n.checks??[],...t.map((e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e))]}),{parent:!0}),e.with=e.check,e.clone=(n,t)=>Ro(e,n,t),e.brand=()=>e,e.register=(n,t)=>(n.add(e,t),e),e.parse=(n,t)=>xs(e,n,t,{callee:e.parse}),e.safeParse=(n,t)=>_s(e,n,t),e.parseAsync=async(n,t)=>ys(e,n,t,{callee:e.parseAsync}),e.safeParseAsync=async(n,t)=>ks(e,n,t),e.spa=e.safeParseAsync,e.encode=(n,t)=>Es(e,n,t),e.decode=(n,t)=>Ts(e,n,t),e.encodeAsync=async(n,t)=>Ns(e,n,t),e.decodeAsync=async(n,t)=>Ss(e,n,t),e.safeEncode=(n,t)=>Cs(e,n,t),e.safeDecode=(n,t)=>Is(e,n,t),e.safeEncodeAsync=async(n,t)=>Rs(e,n,t),e.safeDecodeAsync=async(n,t)=>Os(e,n,t),e.refine=(n,t)=>e.check(function(e,n={}){return rs(Oc,e,n)}(n,t)),e.superRefine=n=>e.check(as(n)),e.overwrite=n=>e.check(Xi(n)),e.optional=()=>xc(e),e.exactOptional=()=>new yc({type:"optional",innerType:e}),e.nullable=()=>kc(e),e.nullish=()=>xc(kc(e)),e.nonoptional=n=>function(e,n){return new Nc({type:"nonoptional",innerType:e,...Oo(n)})}(e,n),e.array=()=>{return os(uc,e,n);var n},e.or=n=>{return new hc({type:"union",options:[e,n],...Oo(t)});var t},e.and=n=>new mc({type:"intersection",left:e,right:n}),e.transform=n=>Ic(e,new wc({type:"transform",transform:n})),e.default=n=>{return t=n,new Ec({type:"default",innerType:e,get defaultValue(){return"function"==typeof t?t():So(t)}});var t},e.prefault=n=>{return t=n,new Tc({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof t?t():So(t)}});var t},e.catch=n=>{return new Sc({type:"catch",innerType:e,catchValue:"function"==typeof(t=n)?t:()=>t});var t},e.pipe=n=>Ic(e,n),e.readonly=()=>new Rc({type:"readonly",innerType:e}),e.describe=n=>{const t=e.clone();return oi.add(t,{description:n}),t},Object.defineProperty(e,"description",{get(){var n;return null==(n=oi.get(e))?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(0===n.length)return oi.get(e);const t=e.clone();return oi.add(t,n[0]),t},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e))),As=so("_ZodString",((e,n)=>{Zr.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t)=>{const o=t;o.type="string";const{minimum:r,maximum:a,format:i,patterns:s,contentEncoding:c}=e._zod.bag;if("number"==typeof r&&(o.minLength=r),"number"==typeof a&&(o.maxLength=a),i&&(o.format=fs[i]??i,""===o.format&&delete o.format,"time"===i&&delete o.format),c&&(o.contentEncoding=c),s&&s.size>0){const e=[...s];1===e.length?o.pattern=e[0].source:e.length>1&&(o.allOf=[...e.map((e=>({..."draft-07"===n.target||"draft-04"===n.target||"openapi-3.0"===n.target?{type:"string"}:{},pattern:e.source})))])}})(e,n,t);const t=e._zod.bag;e.format=t.format??null,e.minLength=t.minimum??null,e.maxLength=t.maximum??null,e.regex=(...n)=>e.check(Vi(...n)),e.includes=(...n)=>e.check(Hi(...n)),e.startsWith=(...n)=>e.check(Gi(...n)),e.endsWith=(...n)=>e.check(Ji(...n)),e.min=(...n)=>e.check(qi(...n)),e.max=(...n)=>e.check(Wi(...n)),e.length=(...n)=>e.check(Ui(...n)),e.nonempty=(...n)=>e.check(qi(1,...n)),e.lowercase=n=>e.check(Ki(n)),e.uppercase=n=>e.check(Zi(n)),e.trim=()=>e.check(Qi()),e.normalize=(...n)=>e.check(Yi(...n)),e.toLowerCase=()=>e.check(es()),e.toUpperCase=()=>e.check(ns()),e.slugify=()=>e.check(ts())})),Ps=so("ZodString",((e,n)=>{Zr.init(e,n),As.init(e,n),e.email=n=>e.check(ai($s,n)),e.url=n=>e.check(ui(Ls,n)),e.jwt=n=>e.check(Ni(nc,n)),e.emoji=n=>e.check(pi(Bs,n)),e.guid=n=>e.check(ii(Ds,n)),e.uuid=n=>e.check(si(Ms,n)),e.uuidv4=n=>e.check(ci(Ms,n)),e.uuidv6=n=>e.check(li(Ms,n)),e.uuidv7=n=>e.check(di(Ms,n)),e.nanoid=n=>e.check(fi(Ws,n)),e.guid=n=>e.check(ii(Ds,n)),e.cuid=n=>e.check(hi(qs,n)),e.cuid2=n=>e.check(mi(Us,n)),e.ulid=n=>e.check(gi(Vs,n)),e.base64=n=>e.check(ki(Ys,n)),e.base64url=n=>e.check(Ei(Qs,n)),e.xid=n=>e.check(vi(Ks,n)),e.ksuid=n=>e.check(wi(Zs,n)),e.ipv4=n=>e.check(bi(Hs,n)),e.ipv6=n=>e.check(xi(Gs,n)),e.cidrv4=n=>e.check(yi(Js,n)),e.cidrv6=n=>e.check(_i(Xs,n)),e.e164=n=>e.check(Ti(ec,n)),e.datetime=n=>e.check(function(e){return Si(ms,e)}(n)),e.date=n=>e.check(function(e){return Ci(gs,e)}(n)),e.time=n=>e.check(function(e){return Ii(vs,e)}(n)),e.duration=n=>e.check(function(e){return Ri(ws,e)}(n))}));function Fs(e){return ri(Ps,e)}const zs=so("ZodStringFormat",((e,n)=>{Hr.init(e,n),As.init(e,n)})),$s=so("ZodEmail",((e,n)=>{Xr.init(e,n),zs.init(e,n)})),Ds=so("ZodGUID",((e,n)=>{Gr.init(e,n),zs.init(e,n)})),Ms=so("ZodUUID",((e,n)=>{Jr.init(e,n),zs.init(e,n)})),Ls=so("ZodURL",((e,n)=>{Yr.init(e,n),zs.init(e,n)})),Bs=so("ZodEmoji",((e,n)=>{Qr.init(e,n),zs.init(e,n)})),Ws=so("ZodNanoID",((e,n)=>{ea.init(e,n),zs.init(e,n)})),qs=so("ZodCUID",((e,n)=>{na.init(e,n),zs.init(e,n)})),Us=so("ZodCUID2",((e,n)=>{ta.init(e,n),zs.init(e,n)})),Vs=so("ZodULID",((e,n)=>{oa.init(e,n),zs.init(e,n)})),Ks=so("ZodXID",((e,n)=>{ra.init(e,n),zs.init(e,n)})),Zs=so("ZodKSUID",((e,n)=>{aa.init(e,n),zs.init(e,n)})),Hs=so("ZodIPv4",((e,n)=>{da.init(e,n),zs.init(e,n)})),Gs=so("ZodIPv6",((e,n)=>{ua.init(e,n),zs.init(e,n)})),Js=so("ZodCIDRv4",((e,n)=>{pa.init(e,n),zs.init(e,n)})),Xs=so("ZodCIDRv6",((e,n)=>{fa.init(e,n),zs.init(e,n)})),Ys=so("ZodBase64",((e,n)=>{ma.init(e,n),zs.init(e,n)})),Qs=so("ZodBase64URL",((e,n)=>{ga.init(e,n),zs.init(e,n)})),ec=so("ZodE164",((e,n)=>{va.init(e,n),zs.init(e,n)})),nc=so("ZodJWT",((e,n)=>{wa.init(e,n),zs.init(e,n)})),tc=so("ZodNumber",((e,n)=>{ba.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t)=>{const o=t,{minimum:r,maximum:a,format:i,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l}=e._zod.bag;"string"==typeof i&&i.includes("int")?o.type="integer":o.type="number","number"==typeof l&&("draft-04"===n.target||"openapi-3.0"===n.target?(o.minimum=l,o.exclusiveMinimum=!0):o.exclusiveMinimum=l),"number"==typeof r&&(o.minimum=r,"number"==typeof l&&"draft-04"!==n.target&&(l>=r?delete o.minimum:delete o.exclusiveMinimum)),"number"==typeof c&&("draft-04"===n.target||"openapi-3.0"===n.target?(o.maximum=c,o.exclusiveMaximum=!0):o.exclusiveMaximum=c),"number"==typeof a&&(o.maximum=a,"number"==typeof c&&"draft-04"!==n.target&&(c<=a?delete o.maximum:delete o.exclusiveMaximum)),"number"==typeof s&&(o.multipleOf=s)})(e,n,t),e.gt=(n,t)=>e.check(Mi(n,t)),e.gte=(n,t)=>e.check(Li(n,t)),e.min=(n,t)=>e.check(Li(n,t)),e.lt=(n,t)=>e.check($i(n,t)),e.lte=(n,t)=>e.check(Di(n,t)),e.max=(n,t)=>e.check(Di(n,t)),e.int=n=>e.check(rc(n)),e.safe=n=>e.check(rc(n)),e.positive=n=>e.check(Mi(0,n)),e.nonnegative=n=>e.check(Li(0,n)),e.negative=n=>e.check($i(0,n)),e.nonpositive=n=>e.check(Di(0,n)),e.multipleOf=(n,t)=>e.check(Bi(n,t)),e.step=(n,t)=>e.check(Bi(n,t)),e.finite=()=>e;const t=e._zod.bag;e.minValue=Math.max(t.minimum??Number.NEGATIVE_INFINITY,t.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(t.maximum??Number.POSITIVE_INFINITY,t.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(t.format??"").includes("int")||Number.isSafeInteger(t.multipleOf??.5),e.isFinite=!0,e.format=t.format??null}));const oc=so("ZodNumberFormat",((e,n)=>{xa.init(e,n),tc.init(e,n)}));function rc(e){return ji(oc,e)}const ac=so("ZodBoolean",((e,n)=>{ya.init(e,n),js.init(e,n),e._zod.processJSONSchema=(e,n,t)=>((e,n,t)=>{t.type="boolean"})(0,0,n)}));function ic(e){return Ai(ac,e)}const sc=so("ZodAny",((e,n)=>{_a.init(e,n),js.init(e,n),e._zod.processJSONSchema=(e,n,t)=>{}}));const cc=so("ZodUnknown",((e,n)=>{ka.init(e,n),js.init(e,n),e._zod.processJSONSchema=(e,n,t)=>{}}));function lc(){return Fi(cc)}const dc=so("ZodNever",((e,n)=>{Ea.init(e,n),js.init(e,n),e._zod.processJSONSchema=(e,n,t)=>((e,n,t)=>{t.not={}})(0,0,n)}));const uc=so("ZodArray",((e,n)=>{Na.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t,o)=>{const r=t,a=e._zod.def,{minimum:i,maximum:s}=e._zod.bag;"number"==typeof i&&(r.minItems=i),"number"==typeof s&&(r.maxItems=s),r.type="array",r.items=cs(a.element,n,{...o,path:[...o.path,"items"]})})(e,n,t,o),e.element=n.element,e.min=(n,t)=>e.check(qi(n,t)),e.nonempty=n=>e.check(qi(1,n)),e.max=(n,t)=>e.check(Wi(n,t)),e.length=(n,t)=>e.check(Ui(n,t)),e.unwrap=()=>e.element}));const pc=so("ZodObject",((e,n)=>{Oa.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t,o)=>{var r;const a=t,i=e._zod.def;a.type="object",a.properties={};const s=i.shape;for(const d in s)a.properties[d]=cs(s[d],n,{...o,path:[...o.path,"properties",d]});const c=new Set(Object.keys(s)),l=new Set([...c].filter((e=>{const t=i.shape[e]._zod;return"input"===n.io?void 0===t.optin:void 0===t.optout})));l.size>0&&(a.required=Array.from(l)),"never"===(null==(r=i.catchall)?void 0:r._zod.def.type)?a.additionalProperties=!1:i.catchall?i.catchall&&(a.additionalProperties=cs(i.catchall,n,{...o,path:[...o.path,"additionalProperties"]})):"output"===n.io&&(a.additionalProperties=!1)})(e,n,t,o),bo(e,"shape",(()=>n.shape)),e.keyof=()=>vc(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:lc()}),e.loose=()=>e.clone({...e._zod.def,catchall:lc()}),e.strict=()=>{return e.clone({...e._zod.def,catchall:zi(dc,n)});var n},e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>function(e,n){if(!No(n))throw new Error("Invalid input to extend: expected a plain object");const t=e._zod.def.checks;if(t&&t.length>0){const t=e._zod.def.shape;for(const e in n)if(void 0!==Object.getOwnPropertyDescriptor(t,e))throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=yo(e._zod.def,{get shape(){const t={...e._zod.def.shape,...n};return xo(this,"shape",t),t}});return Ro(e,o)}(e,n),e.safeExtend=n=>function(e,n){if(!No(n))throw new Error("Invalid input to safeExtend: expected a plain object");const t=yo(e._zod.def,{get shape(){const t={...e._zod.def.shape,...n};return xo(this,"shape",t),t}});return Ro(e,t)}(e,n),e.merge=n=>function(e,n){const t=yo(e._zod.def,{get shape(){const t={...e._zod.def.shape,...n._zod.def.shape};return xo(this,"shape",t),t},get catchall(){return n._zod.def.catchall},checks:[]});return Ro(e,t)}(e,n),e.pick=n=>function(e,n){const t=e._zod.def,o=t.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return Ro(e,yo(e._zod.def,{get shape(){const e={};for(const o in n){if(!(o in t.shape))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(e[o]=t.shape[o])}return xo(this,"shape",e),e},checks:[]}))}(e,n),e.omit=n=>function(e,n){const t=e._zod.def,o=t.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const r=yo(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const e in n){if(!(e in t.shape))throw new Error(`Unrecognized key: "${e}"`);n[e]&&delete o[e]}return xo(this,"shape",o),o},checks:[]});return Ro(e,r)}(e,n),e.partial=(...n)=>function(e,n,t){const o=n._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const r=yo(n._zod.def,{get shape(){const o=n._zod.def.shape,r={...o};if(t)for(const n in t){if(!(n in o))throw new Error(`Unrecognized key: "${n}"`);t[n]&&(r[n]=e?new e({type:"optional",innerType:o[n]}):o[n])}else for(const n in o)r[n]=e?new e({type:"optional",innerType:o[n]}):o[n];return xo(this,"shape",r),r},checks:[]});return Ro(n,r)}(bc,e,n[0]),e.required=(...n)=>function(e,n,t){const o=yo(n._zod.def,{get shape(){const o=n._zod.def.shape,r={...o};if(t)for(const n in t){if(!(n in r))throw new Error(`Unrecognized key: "${n}"`);t[n]&&(r[n]=new e({type:"nonoptional",innerType:o[n]}))}else for(const n in o)r[n]=new e({type:"nonoptional",innerType:o[n]});return xo(this,"shape",r),r}});return Ro(n,o)}(Nc,e,n[0])}));function fc(e,n){const t={type:"object",shape:e??{},...Oo(n)};return new pc(t)}const hc=so("ZodUnion",((e,n)=>{Aa.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t,o)=>{const r=e._zod.def,a=!1===r.inclusive,i=r.options.map(((e,t)=>cs(e,n,{...o,path:[...o.path,a?"oneOf":"anyOf",t]})));a?t.oneOf=i:t.anyOf=i})(e,n,t,o),e.options=n.options}));const mc=so("ZodIntersection",((e,n)=>{Pa.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t,o)=>{const r=e._zod.def,a=cs(r.left,n,{...o,path:[...o.path,"allOf",0]}),i=cs(r.right,n,{...o,path:[...o.path,"allOf",1]}),s=e=>"allOf"in e&&1===Object.keys(e).length,c=[...s(a)?a.allOf:[a],...s(i)?i.allOf:[i]];t.allOf=c})(e,n,t,o)}));const gc=so("ZodEnum",((e,n)=>{$a.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t)=>{const o=fo(e._zod.def.entries);o.every((e=>"number"==typeof e))&&(t.type="number"),o.every((e=>"string"==typeof e))&&(t.type="string"),t.enum=o})(e,0,t),e.enum=n.entries,e.options=Object.values(n.entries);const t=new Set(Object.keys(n.entries));e.extract=(e,o)=>{const r={};for(const a of e){if(!t.has(a))throw new Error(`Key ${a} not found in enum`);r[a]=n.entries[a]}return new gc({...n,checks:[],...Oo(o),entries:r})},e.exclude=(e,o)=>{const r={...n.entries};for(const n of e){if(!t.has(n))throw new Error(`Key ${n} not found in enum`);delete r[n]}return new gc({...n,checks:[],...Oo(o),entries:r})}}));function vc(e,n){const t=Array.isArray(e)?Object.fromEntries(e.map((e=>[e,e]))):e;return new gc({type:"enum",entries:t,...Oo(n)})}const wc=so("ZodTransform",((e,n)=>{Da.init(e,n),js.init(e,n),e._zod.processJSONSchema=(e,n,t)=>((e,n)=>{if("throw"===n.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")})(0,e),e._zod.parse=(t,o)=>{if("backward"===o.direction)throw new lo(e.constructor.name);t.addIssue=o=>{if("string"==typeof o)t.issues.push(Do(o,t.value,n));else{const n=o;n.fatal&&(n.continue=!1),n.code??(n.code="custom"),n.input??(n.input=t.value),n.inst??(n.inst=e),t.issues.push(Do(n))}};const r=n.transform(t.value,t);return r instanceof Promise?r.then((e=>(t.value=e,t))):(t.value=r,t)}}));const bc=so("ZodOptional",((e,n)=>{La.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>hs(e,n,0,o),e.unwrap=()=>e._zod.def.innerType}));function xc(e){return new bc({type:"optional",innerType:e})}const yc=so("ZodExactOptional",((e,n)=>{Ba.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>hs(e,n,0,o),e.unwrap=()=>e._zod.def.innerType}));const _c=so("ZodNullable",((e,n)=>{Wa.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t,o)=>{const r=e._zod.def,a=cs(r.innerType,n,o),i=n.seen.get(e);"openapi-3.0"===n.target?(i.ref=r.innerType,t.nullable=!0):t.anyOf=[a,{type:"null"}]})(e,n,t,o),e.unwrap=()=>e._zod.def.innerType}));function kc(e){return new _c({type:"nullable",innerType:e})}const Ec=so("ZodDefault",((e,n)=>{qa.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t,o)=>{const r=e._zod.def;cs(r.innerType,n,o),n.seen.get(e).ref=r.innerType,t.default=JSON.parse(JSON.stringify(r.defaultValue))})(e,n,t,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}));const Tc=so("ZodPrefault",((e,n)=>{Va.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t,o)=>{const r=e._zod.def;cs(r.innerType,n,o),n.seen.get(e).ref=r.innerType,"input"===n.io&&(t._prefault=JSON.parse(JSON.stringify(r.defaultValue)))})(e,n,t,o),e.unwrap=()=>e._zod.def.innerType}));const Nc=so("ZodNonOptional",((e,n)=>{Ka.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t,o)=>{const r=e._zod.def;cs(r.innerType,n,o),n.seen.get(e).ref=r.innerType})(e,n,0,o),e.unwrap=()=>e._zod.def.innerType}));const Sc=so("ZodCatch",((e,n)=>{Ha.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t,o)=>{const r=e._zod.def;let a;cs(r.innerType,n,o),n.seen.get(e).ref=r.innerType;try{a=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}t.default=a})(e,n,t,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}));const Cc=so("ZodPipe",((e,n)=>{Ga.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t,o)=>{const r=e._zod.def,a="input"===n.io?"transform"===r.in._zod.def.type?r.out:r.in:r.out;cs(a,n,o),n.seen.get(e).ref=a})(e,n,0,o),e.in=n.in,e.out=n.out}));function Ic(e,n){return new Cc({type:"pipe",in:e,out:n})}const Rc=so("ZodReadonly",((e,n)=>{Xa.init(e,n),js.init(e,n),e._zod.processJSONSchema=(n,t,o)=>((e,n,t,o)=>{const r=e._zod.def;cs(r.innerType,n,o),n.seen.get(e).ref=r.innerType,t.readOnly=!0})(e,n,t,o),e.unwrap=()=>e._zod.def.innerType}));const Oc=so("ZodCustom",((e,n)=>{Qa.init(e,n),js.init(e,n),e._zod.processJSONSchema=(e,n,t)=>((e,n)=>{if("throw"===n.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")})(0,e)}));const jc=vc(["face","password"]),Ac=fc({success:ic(),accessToken:Fs().optional(),refreshToken:Fs().optional(),method:jc.optional(),alias:Fs().optional(),user:fc({id:Fs(),email:Fs(),role:Fs(),validated:ic(),active:ic()}).optional(),person:fc({id:Fs(),name:Fs(),birth_date:Fs()}).optional(),confidence_score:Oi(tc,Pc).optional(),recognition_id:Fs().optional(),task_id:Fs().optional(),status:Fs().optional(),message:Fs().optional()});var Pc;const Fc=fc({success:ic(),message:Fs(),person_id:Fs().optional(),user_id:Fs().optional(),person_validated:ic().optional(),face_processing:Pi(sc).optional(),onboarding_link:Fs().optional(),task_id:Fs().optional(),status:Fs().optional()}),zc="#0059C4",$c="#F1BE00",Dc="#0A1320",Mc={success:{fg:"#046C4E",bg:"#E7F7F0",solid:"#0E9F6E"},attention:{fg:"#6E5600",bg:"#FFF6D9",solid:"#F1BE00"},critical:{fg:"#9B1C1C",bg:"#FDEAEA",solid:"#E02424"},info:{fg:"#00449A",bg:"#EBF6FE",solid:"#0073F4"}},Lc={ground:"#F7F9FC",surface:"#FFFFFF",surfaceMuted:"#F1F5FA",line:"#E6ECF4",text:Dc,textMuted:"#48586B",textSubtle:"#617489",action:zc,actionText:"#FFFFFF",accent:$c,overlay:"rgba(10,19,32,.55)",focusRing:zc},Bc={ground:Dc,surface:"#111C2B",surfaceMuted:"#1E2B3C",line:"#22334D",text:"#EEF3F9",textMuted:"#AFBDCE",textSubtle:"#8496AD",action:"#0091F6",actionText:"#FFFFFF",accent:$c,overlay:"rgba(10,19,32,.72)",focusRing:"#00B0F8"};function Wc(e){const[n,t,o]=function(e){let n=e.trim().replace("#","");3===n.length&&(n=n.split("").map((e=>e+e)).join(""));return/^[0-9a-fA-F]{6}$/.test(n)?[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)]:[0,0,0]}(e).map((e=>{const n=e/255;return n<=.03928?n/12.92:((n+.055)/1.055)**2.4}));return.2126*n+.7152*t+.0722*o}const qc=[8,16,24];function Uc(e={}){const n=function(e){if("dark"===e)return"dark";if("light"===e)return"light";if("undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches)return"dark";return"light"}(e.theme),t="dark"===n?{...Bc}:{...Lc};let o=16;void 0!==e.radius&&qc.includes(e.radius)&&(o=e.radius);let r=t.action,a=!1;if(e.accent){(function(e,n){const t=Wc(e),o=Wc(n),[r,a]=t>o?[t,o]:[o,t];return(r+.05)/(a+.05)})(e.accent,"#FFFFFF")>=4.5?r=e.accent:(a=!0,r=zc)}return{mode:n,tokens:{...t,action:r},radius:o,accent:r,accentFellBack:a}}const Vc="--nfid-ground",Kc="--nfid-surface",Zc="--nfid-surface-muted",Hc="--nfid-line",Gc="--nfid-text",Jc="--nfid-text-muted",Xc="--nfid-text-subtle",Yc="--nfid-action",Qc="--nfid-action-text",el="--nfid-accent",nl="--nfid-overlay",tl="--nfid-focus-ring",ol="--nfid-radius",rl="neofaceid-focus-frame-tokens";function al(e={}){const n=Uc(e);if("undefined"==typeof document)return n;const t=function(e){const n=e.tokens;return`.neofaceid-root {\n ${Vc}: ${n.ground};\n ${Kc}: ${n.surface};\n ${Zc}: ${n.surfaceMuted};\n ${Hc}: ${n.line};\n ${Gc}: ${n.text};\n ${Jc}: ${n.textMuted};\n ${Xc}: ${n.textSubtle};\n ${Yc}: ${n.action};\n ${Qc}: ${n.actionText};\n ${el}: ${n.accent};\n ${nl}: ${n.overlay};\n ${tl}: ${n.focusRing};\n ${ol}: ${e.radius}px;\n color: var(${Gc});\n font-family: inherit;\n}\n.neofaceid-root :focus-visible {\n outline: 2px solid var(${tl});\n outline-offset: 2px;\n}\n@media (prefers-reduced-motion: reduce) {\n .neofaceid-root,\n .neofaceid-root * {\n animation-duration: 0.001ms !important;\n animation-iteration-count: 1 !important;\n transition-duration: 0.001ms !important;\n scroll-behavior: auto !important;\n }\n}`}(n),o=document.getElementById(rl);if(o)return o.textContent!==t&&(o.textContent=t),n;const r=document.createElement("style");return r.id=rl,r.textContent=t,document.head.appendChild(r),n}function il(e,n){if("undefined"==typeof document)return;const t=document.getElementById(e);if(t)return void(t.textContent!==n&&(t.textContent=n));const o=document.createElement("style");o.id=e,o.textContent=n,document.head.appendChild(o)}const sl={},cl={purpose:"authentication",legalBasis:"fraud_prevention",privacyPolicyUrl:"",retentionDays:0},ll={development:"http://localhost:8000",sandbox:"https://sandbox-core.neofaceid.com",production:"https://core.neofaceid.com.br"},dl={toPhone:!1,toPassword:!0},ul=[8,16,24];let pl={baseUrl:ll.sandbox,applicationToken:null,environment:"sandbox",initialized:!1,appName:null,accent:null,radius:16,theme:"light",locale:"pt-BR",resolvedTheme:null,consent:{...cl},autoFallback:{...dl}},fl=!1;function hl(){return pl.initialized,pl.baseUrl}function ml(){return pl.applicationToken}function gl(){return pl.appName}function vl(){return{...pl.autoFallback}}function wl(){return pl.locale}function bl(){return{...pl.consent}}async function xl(e,n){const t=URL.createObjectURL(e);try{return await n(t)}finally{URL.revokeObjectURL(t)}}const yl=()=>hl(),_l=()=>{const e="localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname||""===window.location.hostname;if(!window.isSecureContext&&!e)throw new io("Secure context (HTTPS) is required for this operation",ao.NETWORK)},kl=()=>{const e=new AbortController,n=setTimeout((()=>e.abort()),1e4);return e.signal.addEventListener("abort",(()=>clearTimeout(n))),e},El=async e=>xl(e,(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 r=e.getContext("2d");r?(r.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=e})))),Tl=async e=>xl(e,(e=>new Promise(((n,t)=>{const o=new Image;o.onload=()=>{const e=1280;let{width:r}=o,{height:a}=o;r>a&&r>e?(a=a*e/r,r=e):a>e&&(r=r*e/a,a=e);const i=document.createElement("canvas");i.width=r,i.height=a;const s=i.getContext("2d");s?(s.drawImage(o,0,0,r,a),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=e})))),Nl=async e=>{_l();const n=kl();try{const t=await fetch(`${yl()}/api/v1/auth/application/validate_token/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":e},body:JSON.stringify({}),signal:n.signal});if(!t.ok)throw new io(`API Error ${t.status}`,ao.INVALID_TOKEN);return t.ok}catch(t){if(t instanceof Error){if("AbortError"===t.name)throw new io("Request timeout",ao.NETWORK);if(t instanceof io)throw t;throw new io(t.message,ao.NETWORK)}throw new io("Unknown error",ao.NETWORK)}},Sl=async(e,n)=>{_l();const t=kl();try{const o=await fetch(`${yl()}/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 io("Token de aplicação inválido ou expirado",ao.INVALID_TOKEN);if(404===o.status)throw new io("Link de onboarding não encontrado",ao.NOT_FOUND);throw new io(`Falha ao obter detalhes (${o.status})`,ao.NETWORK)}return await o.json()}catch(o){if(o instanceof Error){if("AbortError"===o.name)throw new io("Tempo de requisição excedido",ao.NETWORK);if(o instanceof io)throw o;throw new io(o.message,ao.NETWORK)}throw new io("Erro desconhecido",ao.NETWORK)}},Cl=async(e,n)=>{_l();const t=kl();try{const o=await fetch(`${yl()}/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 io("Token de aplicação inválido ou expirado",ao.INVALID_TOKEN);if(404===o.status)return!1;throw new io(`Falha ao validar token (${o.status})`,ao.NETWORK)}const r=await o.json();return!0===(null==r?void 0:r.is_valid)}catch(o){if(o instanceof Error){if("AbortError"===o.name)throw new io("Tempo de requisição excedido",ao.NETWORK);if(o instanceof io)throw o;throw new io(o.message,ao.NETWORK)}throw new io("Erro desconhecido",ao.NETWORK)}},Il=async(e,n,t,o)=>{_l();const r=kl(),a=await El(t),i=await El(o);try{const t=await new Promise(((e,n)=>{const t=new FileReader;t.onload=()=>e(t.result),t.onerror=n,t.readAsDataURL(a)})),o=await new Promise(((e,n)=>{const t=new FileReader;t.onload=()=>e(t.result),t.onerror=n,t.readAsDataURL(i)})),s=await fetch(`${yl()}/api/v1/onboardings/${encodeURIComponent(n)}/complete/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":e},body:JSON.stringify({face_image:t,document_image:o}),signal:r.signal}),c=await s.json();if(!s.ok){if(401===s.status||403===s.status)throw new io("Token de aplicação inválido ou expirado",ao.INVALID_TOKEN);if(404===s.status)throw new io("Link de onboarding não encontrado",ao.NOT_FOUND);throw new io((null==c?void 0:c.error)||(null==c?void 0:c.message)||"Falha ao concluir onboarding",ao.NETWORK)}return{success:!!c.success,message:c.message||"Onboarding concluído",person_id:c.person_id,identity_data_id:c.identity_data_id,confidence_score:c.confidence_score,processing_time:c.processing_time}}catch(s){if(s instanceof Error){if("AbortError"===s.name)throw new io("Tempo de requisição excedido",ao.NETWORK);if(s instanceof io)throw s;throw new io(s.message,ao.NETWORK)}throw new io("Erro desconhecido",ao.NETWORK)}},Rl=async(e,n,t,o,r)=>{if(_l(),!o||0===o.length)throw new io("Pelo menos uma imagem da pessoa é obrigatória",ao.VALIDATION_ERROR);const a=kl();try{const i=await Promise.all(o.map((async e=>{const n=await El(e);return new Promise(((e,t)=>{const o=new FileReader;o.onload=()=>e(o.result),o.onerror=t,o.readAsDataURL(n)}))}))),s=await El(r),c={person_images:i,document_image:await new Promise(((e,n)=>{const t=new FileReader;t.onload=()=>e(t.result),t.onerror=n,t.readAsDataURL(s)})),name:t.name,birth_date:t.birth_date,cpf:t.cpf,cnpj:t.cnpj,email:t.email},l=await fetch(`${yl()}/api/v1/onboardings/${encodeURIComponent(n)}/complete/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":e},body:JSON.stringify(c),signal:a.signal}),d=await l.json();if(!l.ok){if(401===l.status||403===l.status)throw new io("Token de aplicação inválido ou expirado",ao.INVALID_TOKEN);if(404===l.status)throw new io("Link de onboarding não encontrado",ao.NOT_FOUND);throw new io((null==d?void 0:d.error)||(null==d?void 0:d.message)||"Falha ao concluir onboarding",ao.NETWORK)}return{success:!!d.success,message:d.message||"Onboarding concluído com sucesso",person_id:d.person_id,identity_data_id:d.identity_data_id,confidence_score:d.confidence_score,processing_time:d.processing_time,liveness_passed:d.liveness_passed,document_verified:d.document_verified,person_created:d.person_created}}catch(i){if(i instanceof Error){if("AbortError"===i.name)throw new io("Tempo de requisição excedido",ao.NETWORK);if(i instanceof io)throw i;throw new io(i.message,ao.NETWORK)}throw new io("Erro desconhecido",ao.NETWORK)}},Ol=async(e,n)=>{_l();const t=kl(),o=await El(e);try{const e=await new Promise(((e,n)=>{const t=new FileReader;t.onload=()=>{const n=t.result;e(n.split(",")[1])},t.onerror=n,t.readAsDataURL(o)})),r=await fetch(`${yl()}/api/v1/auth/recognition/face/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({face_frames:e}),signal:t.signal});if(!r.ok){if(401===r.status||403===r.status)throw new io("Invalid or expired application token",ao.INVALID_TOKEN);throw new io(`Server returned status ${r.status}`,ao.NETWORK)}const a=await r.json();if(!a.success)throw new io(a.message||"Recognition failed",ao.RECOGNITION_FAILED);return{accessToken:a.accessToken,payload:a.payload}}catch(r){if(r instanceof Error){if("AbortError"===r.name)throw new io("Request timed out",ao.NETWORK);if(r instanceof io)throw r;throw new io(r.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},jl=async(e,n)=>{var t,o,r,a,i;_l();const s=kl(),c=await El(e);try{const e=await c.arrayBuffer(),l=btoa(new Uint8Array(e).reduce(((e,n)=>e+String.fromCharCode(n)),"")),d=await fetch(`${yl()}/api/v1/login/donor/face/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({image:l,biometric_type:"FACE"}),signal:s.signal});if(!d.ok){if(401===d.status||403===d.status)throw new io("Invalid application token",ao.INVALID_TOKEN);if(429===d.status){const e=d.headers.get("Retry-After");let n=6e4;if(e){const t=Number(e);if(Number.isFinite(t)&&t>0)n=1e3*t;else{const t=Date.parse(e);if(Number.isFinite(t)){const e=t-Date.now();e>0&&(n=e)}}}const t=new io(`Muitas tentativas. Aguarde ${Math.ceil(n/1e3)} segundo(s) antes de tentar novamente.`,ao.API_ERROR);throw t.retryAfterMs=n,t}if(d.status>=500)throw new io(`Server Error ${d.status}`,ao.API_ERROR);throw new io(`API Error ${d.status}`,ao.API_ERROR)}const u=await d.json();if(!u.success)throw new io(u.message||"Login failed",ao.LOGIN_FAILED);return{success:!0,accessToken:u.accessToken||u.access_token||"",refreshToken:u.refreshToken||u.refresh_token||void 0,method:"face",alias:u.alias,user:{id:(null==(t=u.user)?void 0:t.id)||"",email:(null==(o=u.user)?void 0:o.email)||"",role:(null==(r=u.user)?void 0:r.role)||"",validated:(null==(a=u.user)?void 0:a.validated)||!1,active:(null==(i=u.user)?void 0:i.active)||!1},person:u.person?{id:u.person.id||"",name:u.person.name||"",birth_date:u.person.birth_date||""}:void 0,confidence_score:u.confidence_score,recognition_id:u.recognition_id}}catch(l){if(l instanceof Error){if("AbortError"===l.name)throw new io("Request timed out",ao.NETWORK);if(l instanceof io)throw l;throw new io(l.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},Al=async(e,n,t=!0,o=.8)=>{_l();const r=kl(),a=await El(e);try{const e=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)})),i=await fetch(`${yl()}/api/v1/auth/recognition/face/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({face_frames:e,liveness_check:t,confidence_threshold:o}),signal:r.signal});if(!i.ok){if(401===i.status||403===i.status)throw new io("Invalid or expired application token",ao.INVALID_TOKEN);throw new io(`Server returned status ${i.status}`,ao.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 io("Request timed out",ao.NETWORK);if(i instanceof io)throw i;throw new io(i.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},Pl=async(e,n,t,o="LOGIN")=>{_l();const r=kl();try{const a=await fetch(`${yl()}/api/v1/auth/recognition/face/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":t},body:JSON.stringify({document_type:e,document_number:n,purpose:o}),signal:r.signal});if(!a.ok){if(401===a.status||403===a.status)throw new io("Invalid or expired application token",ao.INVALID_TOKEN);throw new io(`Server returned status ${a.status}`,ao.NETWORK)}const i=await a.json();if(!i.success)throw new io(i.message||"Identification failed",ao.RECOGNITION_FAILED);return{success:i.success,personId:i.person_id,accessToken:i.access_token,payload:i.payload}}catch(a){if(a instanceof Error){if("AbortError"===a.name)throw new io("Request timed out",ao.NETWORK);if(a instanceof io)throw a;throw new io(a.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},Fl=async(e,n,t,o=.8,r,a)=>{var i;_l();const s=kl(),c=await El(e),l=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:l,type_of_identification:"FACE",purpose:t,confidence_threshold:o};r&&(e.signature=r);const c=await fetch(`${yl()}/api/v1/auth/recognition/face/`,{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 io("Invalid or expired application token",ao.INVALID_TOKEN);throw new io(`Server returned status ${c.status}`,ao.NETWORK)}const d=await c.json();return{success:d.success,personName:d.person_name||(null==(i=d.person)?void 0:i.name),email:d.email||(null==a?void 0:a.email),cpf:d.cpf||(null==a?void 0:a.cpf),confidenceScore:d.confidence_score,accessToken:d.access_token,payload:d.payload,signature:r,sessionId:null==a?void 0:a.sessionId}}catch(d){if(d instanceof Error){if("AbortError"===d.name)throw new io("Request timed out",ao.NETWORK);if(d instanceof io)throw d;throw new io(d.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},zl=async(e,n,t)=>{_l();const o=kl();try{let r,a;if(null==t?void 0:t.documentFront){const e=await Tl(t.documentFront);r=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 Tl(t.documentBack);a=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,is_pep:e.is_pep??!1};r&&(i.document_images=[{front:r,back:a||void 0,type:(null==t?void 0:t.documentType)||"RG"}]);const s=await fetch(`${yl()}/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 io("Invalid or expired application token",ao.INVALID_TOKEN);throw new io(`Server returned status ${s.status}`,ao.NETWORK)}return await s.json()}catch(r){if(r instanceof Error){if("AbortError"===r.name)throw new io("Request timed out",ao.NETWORK);if(r instanceof io)throw r;throw new io(r.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},$l=async e=>{const n=kl(),t=new URLSearchParams;e.email&&t.append("email",e.email),e.cpf&&t.append("cpf",e.cpf);try{const e=await fetch(`${yl()}/api/v1/verify/user/?${t.toString()}`,{method:"GET",headers:{"Content-Type":"application/json"},signal:n.signal});if(!e.ok){const n=await e.json().catch((()=>({})));throw new io(n.message||`Server returned status ${e.status}`,ao.NETWORK)}return await e.json()}catch(o){if(o instanceof Error){if("AbortError"===o.name)throw new io("Request timed out",ao.NETWORK);if(o instanceof io)throw o;throw new io(o.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},Dl=async(e,n,t,o)=>{var r,a,i,s,c,l,d,u;if(_l(),!n||0===n.length)throw new io("At least one face photo is required for biometric registration",ao.VALIDATION_ERROR);if(n.length>5)throw new io("Maximum of 5 face photos allowed",ao.VALIDATION_ERROR);const p=kl();try{const h=await Promise.all(n.map((async e=>{const n=await El(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 Tl(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 Tl(o.documentBack);g=await new Promise(((n,t)=>{const o=new FileReader;o.onload=()=>n(o.result),o.onerror=t,o.readAsDataURL(e)}))}const v={name:e.name,birth_date:e.birth_date,cpf:e.cpf,email:e.email,password:e.password,password_confirm:e.password,face_photos:h,is_pep:e.is_pep??!1};m&&(v.document_images=[{front:m,back:g||void 0,type:(null==o?void 0:o.documentType)||"RG"}]);const w=await fetch(`${yl()}/api/v1/signup/donor/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":t},body:JSON.stringify(v),signal:p.signal});if(!w.ok){if(401===w.status||403===w.status)throw new io("Invalid or expired application token",ao.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 io(`Erro de validação: ${n}`,ao.VALIDATION_ERROR)}if("fraud_detected"===e.error)throw new io("Fraud detected in biometric images. Registration blocked.",ao.VALIDATION_ERROR);if("user_exists"===e.error||"ALREADY_EXISTS"===e.error_code)throw new io("User with this email already exists",ao.VALIDATION_ERROR);if("person_exists"===e.error)throw new io("Person with this CPF already exists",ao.VALIDATION_ERROR);const n=e.message||e.error||`Server returned status ${w.status}`;throw new io(n,ao.VALIDATION_ERROR)}catch(f){if(f instanceof io)throw f;throw new io(`Server returned status ${w.status}`,ao.NETWORK)}}const b=await w.json();return 202===w.status&&(null==(r=b.data)?void 0:r.task_id)?{success:b.success,message:b.message||"Registration is being processed. You will receive an email when completed.",task_id:b.data.task_id,status:b.data.status||"processing",person_id:void 0,user_id:void 0,person_validated:void 0,face_processing:void 0,onboarding_link:void 0}:{success:b.success,message:b.message,person_id:(null==(a=b.data)?void 0:a.person_id)||b.person_id,user_id:(null==(i=b.data)?void 0:i.user_id)||b.user_id,person_validated:(null==(s=b.data)?void 0:s.person_validated)||b.person_validated,face_processing:(null==(c=b.data)?void 0:c.face_processing)||b.face_processing,onboarding_link:(null==(l=b.data)?void 0:l.onboarding_link)||b.onboarding_link,task_id:null==(d=b.data)?void 0:d.task_id,status:null==(u=b.data)?void 0:u.status}}catch(h){if(h instanceof Error){if("AbortError"===h.name)throw new io("Request timed out",ao.NETWORK);if(h instanceof io)throw h;throw new io(h.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},Ml=async(e,n,t)=>{const o=kl();try{const r=await fetch(`${yl()}/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(!r.ok){if(401===r.status||403===r.status)throw new io("Email ou senha inválidos",ao.INVALID_TOKEN);throw new io(`API Error ${r.status}`,ao.API_ERROR)}const a=await r.json();return{success:!0,accessToken:a.access_token||a.access,refreshToken:a.refresh_token||a.refresh||void 0,method:"password",alias:a.user&&a.user.alias||a.alias,user:{id:a.user&&a.user.id||"",email:a.user&&a.user.email||"",role:a.user&&a.user.role||"",validated:a.user&&a.user.validated||!1,active:a.user&&a.user.active||!1}}}catch(r){if(r instanceof Error){if("AbortError"===r.name)throw new io("Request timed out",ao.NETWORK);if(r instanceof io)throw r;throw new io(r.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},Ll=async(e,n)=>{if(!e)throw new io("Inscrição de aparelho exige um usuário autenticado (access token ausente).",ao.INVALID_TOKEN);const t=kl();try{const o=await fetch(`${yl()}/api/v1/devices/enrollment-token/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n,Authorization:`Bearer ${e}`},signal:t.signal});if(!o.ok){if(401===o.status)throw new io("Sua sessão expirou. Entre novamente para inscrever o aparelho.",ao.INVALID_TOKEN);if(403===o.status)throw new io("Esta conta não pode inscrever aparelhos. Procure o suporte.",ao.INVALID_TOKEN);throw new io(`API Error ${o.status}`,ao.API_ERROR)}const r=await o.json(),a=r.data??r,i=a.token,s=a.handle;if(!i||!s)throw new io("Resposta de inscrição incompleta (token ou handle ausente)",ao.API_ERROR);return{handle:s,jti:a.jti??"",token:i,expiresIn:a.expires_in??300,purpose:a.purpose??"device-enrollment"}}catch(o){if(o instanceof io)throw o;if(o instanceof Error){if("AbortError"===o.name)throw new io("Request timed out",ao.NETWORK);throw new io(o.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},Bl=async(e,n)=>{const t=kl();try{const o=await fetch(`${yl()}/api/v1/token/refresh/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({refresh:e}),signal:t.signal});if(!o.ok){if(401===o.status||403===o.status)throw new io("Sessão expirada — faça login novamente",ao.INVALID_TOKEN);throw new io(`API Error ${o.status}`,ao.API_ERROR)}const r=await o.json(),a=r.access??r.access_token;if(!a)throw new io("Resposta de refresh sem access token",ao.API_ERROR);return{accessToken:a,refreshToken:r.refresh??r.refresh_token??e}}catch(o){if(o instanceof io)throw o;if(o instanceof Error){if("AbortError"===o.name)throw new io("Request timed out",ao.NETWORK);throw new io(o.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},Wl=async(e,n)=>{var t,o,r,a;_l();const i=kl(),s=await Tl(e),c=await new Promise(((e,n)=>{const t=new FileReader;t.onload=()=>{const n=t.result;e(n.split(",")[1])},t.onerror=n,t.readAsDataURL(s)}));try{const e=await fetch(`${yl()}/api/v1/auth/recognition/face/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({image:c,purpose:"SIMPLE_IDENTIFICATION_F"}),signal:i.signal});if(!e.ok){if(401===e.status||403===e.status)throw new io("Invalid or expired application token",ao.INVALID_TOKEN);throw new io(`Server returned status ${e.status}`,ao.NETWORK)}const s=await e.json();if(202===e.status||s.data&&s.data.task_id)return{success:!0,taskId:(null==(t=s.data)?void 0:t.task_id)||s.task_id,status:(null==(o=s.data)?void 0:o.status)||"processing",message:s.message||"Identification scheduled"};if(!s.success)throw new io(s.message||"Person identification failed",ao.RECOGNITION_FAILED);return{success:!0,person:{name:(null==(r=s.person)?void 0:r.name)||"",birth_date:(null==(a=s.person)?void 0:a.birth_date)||""}}}catch(l){if(l instanceof Error){if("AbortError"===l.name)throw new io("Request timed out",ao.NETWORK);if(l instanceof io)throw l;throw new io(l.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},ql=async(e,n,t)=>{if(_l(),!e)throw new io("Person ID is required",ao.VALIDATION_ERROR);if(!n)throw new io("Face image is required",ao.VALIDATION_ERROR);const o=kl(),r=await El(n),a=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 n=await fetch(`${yl()}/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:a}),signal:o.signal});if(!n.ok){if(401===n.status||403===n.status)throw new io("Invalid or expired application token, or insufficient permissions",ao.INVALID_TOKEN);if(400===n.status)try{const e=await n.json(),t=e.message||e.error||"Invalid biometric data";throw new io(t,ao.VALIDATION_ERROR)}catch(i){if(i instanceof io)throw i;throw new io("Invalid biometric data",ao.VALIDATION_ERROR)}throw new io(`Server returned status ${n.status}`,ao.NETWORK)}const r=await n.json();return{success:!0,message:"Biometric data registered successfully",identity_data_id:r.id,type_of_identification:r.type_of_identification,have_biometric_data:r.have_biometric_data,created_at:r.created_at}}catch(s){if(s instanceof Error){if("AbortError"===s.name)throw new io("Request timed out",ao.NETWORK);if(s instanceof io)throw s;throw new io(s.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},Ul=async(e,n,t)=>{_l();const o=kl();try{const a=await fetch(`${yl()}/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(!a.ok){if(401===a.status)throw new io("Invalid or expired JWT token",ao.INVALID_TOKEN);if(403===a.status)throw new io("Insufficient permissions to create application",ao.INVALID_TOKEN);if(400===a.status)try{const e=await a.json(),n=e.message||e.error||"Invalid application data";throw new io(n,ao.VALIDATION_ERROR)}catch(r){if(r instanceof io)throw r;throw new io("Invalid application data",ao.VALIDATION_ERROR)}throw new io(`Server returned status ${a.status}`,ao.NETWORK)}const i=await a.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(a){if(a instanceof Error){if("AbortError"===a.name)throw new io("Request timed out",ao.NETWORK);if(a instanceof io)throw a;throw new io(a.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},Vl=async(e={})=>{_l();const{durationMs:n=3e3,onProgress:t}=e;return new Promise((async(e,o)=>{let r=null;const a=[];try{r=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:{ideal:640},height:{ideal:480}},audio:!1});const i=(()=>{const e=["video/mp4;codecs=avc1","video/mp4","video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"];for(const n of e)if(MediaRecorder.isTypeSupported(n))return n;return""})();let s;try{s=i?new MediaRecorder(r,{mimeType:i,videoBitsPerSecond:1e6}):new MediaRecorder(r,{videoBitsPerSecond:1e6})}catch{s=new MediaRecorder(r)}const c=s.mimeType||i;if(s.ondataavailable=e=>{e.data.size>0&&a.push(e.data)},s.onstop=()=>{r&&r.getTracks().forEach((e=>e.stop()));const n=new Blob(a,{type:c});e(n)},s.onerror=e=>{r&&r.getTracks().forEach((e=>e.stop())),o(new io(`Recording error: ${e}`,ao.CAPTURE_ERROR))},s.start(100),t){const e=100;let o=0;const r=setInterval((()=>{o+=e;const a=Math.min(100,o/n*100);t(a),o>=n&&clearInterval(r)}),e)}setTimeout((()=>{s&&"recording"===s.state&&s.stop()}),n)}catch(i){r&&r.getTracks().forEach((e=>e.stop())),i instanceof Error?"NotAllowedError"===i.name?o(new io("Camera permission denied",ao.CAMERA_ERROR)):"NotFoundError"===i.name?o(new io("No camera found",ao.NO_CAMERA)):o(new io(i.message,ao.CAPTURE_ERROR)):o(new io("Failed to record video",ao.CAPTURE_ERROR))}}))},Kl=async(e,n,t={})=>{var o,r,a,i,s,c,l,d,u,p;const{maxAttempts:f=60,intervalMs:h=1e3,onStatusChange:m}=t,g=(e=h)=>new Promise((n=>{setTimeout(n,e)})),v=e=>{var n,t;const o=null==(t=null==(n=e.headers)?void 0:n.get)?void 0:t.call(n,"Retry-After");if(!o)return h;const r=Number(o);if(Number.isFinite(r)&&r>0)return 1e3*r;const a=Date.parse(o);if(Number.isFinite(a)){const e=a-Date.now();if(e>0)return e}return h};let w=0,b="";for(;w<f;){w++;try{const t=await fetch(`${yl()}/api/v1/tasks/status/?task_id=${e}`,{method:"GET",headers:{Accept:"application/json","X-App-Token":n}});if(404===t.status)throw new io("Não foi possível recuperar o andamento deste processo. Ele pode já ter sido concluído há algum tempo, ou nunca ter existido.",ao.NOT_FOUND);if(t.status>=500){b=`HTTP ${t.status}`,await g();continue}if(429===t.status){b="HTTP 429",await g(v(t));continue}if(401===t.status||403===t.status)throw new io("Invalid application token",ao.INVALID_TOKEN);if(!t.ok)throw new io(`Task status check failed: ${t.status}`,ao.API_ERROR);const f=await t.json(),h=(null==(o=f.data)?void 0:o.status)||"unknown";if(m){m(h,null==(a=null==(r=f.data)?void 0:r.progress)?void 0:a.percentage)}if("success"===h)return f.data.result;if("failure"===h){const e=(null==(s=null==(i=f.data)?void 0:i.result)?void 0:s.message)||(null==(c=f.data)?void 0:c.error)||"Task failed";throw new io(e,ao.RECOGNITION_FAILED)}if("revoked"===h)throw new io("Task was cancelled",ao.RECOGNITION_FAILED);if(!1===f.success){const e=(null==(d=null==(l=f.data)?void 0:l.result)?void 0:d.message)||(null==(u=f.data)?void 0:u.error)||(null==(p=f.data)?void 0:p.message)||f.message||"Task failed";throw new io(e,ao.RECOGNITION_FAILED)}await g()}catch(x){if(x instanceof io)throw x;b=x instanceof Error?x.message:"erro desconhecido",await g()}}throw new io(b?`Task status polling timed out (última falha transitória: ${b})`:"Task status polling timed out",ao.NETWORK)},Zl=async(e,n)=>{var t;_l();const o=kl();try{const r=await fetch(`${yl()}/api/v1/auth/recognition/face/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({video:e,purpose:"PROOF_OF_LIFE"}),signal:o.signal});if(!r.ok){if(401===r.status||403===r.status)throw new io("Invalid or expired application token",ao.INVALID_TOKEN);if(400===r.status){const e=await r.json();throw new io(e.message||"Invalid request data",ao.VALIDATION_ERROR)}throw new io(`Server returned status ${r.status}`,ao.NETWORK)}const a=await r.json();if(!a.success||!(null==(t=a.data)?void 0:t.task_id))throw new io(a.message||"Failed to start proof of life",ao.RECOGNITION_FAILED);return{taskId:a.data.task_id,historyId:a.data.history_id,status:a.data.status,message:a.message||"Recognition started successfully"}}catch(r){if(r instanceof Error){if("AbortError"===r.name)throw new io("Request timed out",ao.NETWORK);if(r instanceof io)throw r;throw new io(r.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},Hl=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 io("Failed to convert video to base64",ao.CAPTURE_ERROR)),o.readAsDataURL(e)})),Gl=async(e,n,t)=>{var o,r;if(_l(),!e)throw new io("personId is required",ao.VALIDATION_ERROR);if(!n)throw new io("jwtToken is required",ao.VALIDATION_ERROR);if(!t||0===t.length)throw new io("At least one document image is required",ao.VALIDATION_ERROR);const a=await Promise.all(t.map((async e=>{const n=await Tl(e);return t=n,new Promise(((e,n)=>{const o=new FileReader;o.onload=()=>{const n=o.result;e(n.includes(",")?n.split(",")[1]:n)},o.onerror=()=>n(new io("Failed to convert image to base64",ao.CAPTURE_ERROR)),o.readAsDataURL(t)}));var t}))),i=kl();try{const t=await fetch(`${yl()}/api/v1/donors/${e}/documents/`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({document_images:a}),signal:i.signal}),s=await t.json();if(!t.ok)throw new io((null==s?void 0:s.message)||`API Error ${t.status}`,ao.NETWORK);return{success:!0,taskId:(null==(o=s.data)?void 0:o.task_id)??"",status:(null==(r=s.data)?void 0:r.status)??"processing",message:s.message??"Documents submitted for processing"}}catch(s){if(s instanceof io)throw s;if(s instanceof Error){if("AbortError"===s.name)throw new io("Request timeout",ao.NETWORK);throw new io(s.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}},Jl=async(e,n)=>{const t=kl();try{const o=await fetch(`${yl()}/api/v1/tasks/status/?task_id=${e}`,{method:"GET",headers:{"Content-Type":"application/json",...n?{"X-App-Token":n}:{}},signal:t.signal}),r=await o.json();if(!o.ok)throw new io((null==r?void 0:r.message)||`API Error ${o.status}`,ao.NETWORK);return{success:r.success,status:r.data.status,result:r.data.result,error:r.data.error}}catch(o){if(o instanceof io)throw o;throw new io("Failed to fetch task status",ao.NETWORK)}},Xl=async(e,n,t={})=>{var o,r;const{maxRetries:a=30,interval:i=2e3}=t,s=await Wl(e,n);if(s.person)return{personFound:!0,person:s.person};const{taskId:c}=s;if(!c)return{personFound:!1};for(let l=0;l<a;l++){const e=await Jl(c);if("success"===e.status)return e.result&&e.result.success?{personFound:!0,person:{name:(null==(o=e.result.person)?void 0:o.name)||"Pessoa identificada",birth_date:(null==(r=e.result.person)?void 0:r.birth_date)||""}}:{personFound:!1};if("failure"===e.status)return{personFound:!1};await new Promise((e=>setTimeout(e,i)))}throw new io("Timed out waiting for identification",ao.NETWORK)};async function Yl(e,n){const t=hl(),o=await fetch(`${t}/api/v1/user/password/reset/request/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({email:e})});if(!o.ok){const e=await o.json();throw new io(e.message||"Erro ao solicitar recuperação de senha",ao.API_ERROR)}return o.json()}async function Ql(e,n){const t=hl(),o=await fetch(`${t}/api/v1/user/password/reset/confirm/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:e,new_password:n})});if(!o.ok){const e=await o.json();throw new io(e.error||e.message||"Erro ao redefinir senha",ao.API_ERROR)}return o.json()}const ed=Object.freeze(Object.defineProperty({__proto__:null,BiometricLoginResultSchema:Ac,RegistrationResultSchema:Fc,checkUserExistence:$l,completeOnboarding:Il,completeOnboardingWithData:Rl,confirmPasswordReset:Ql,getOnboardingDetails:Sl,getTaskStatus:Jl,identifyPerson:Wl,identifyPersonAsync:Xl,loginWithBiometric:jl,loginWithBiometricSSE:async(e,n)=>{var t,o;_l();const r=await El(e),a=await r.arrayBuffer(),i=btoa(new Uint8Array(a).reduce(((e,n)=>e+String.fromCharCode(n)),"")),s=kl();let c;try{c=await fetch(`${yl()}/api/v1/auth/recognition/face/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({image:i,purpose:"LOGIN"}),signal:s.signal})}catch(m){if(m instanceof Error){if("AbortError"===m.name)throw new io("Request timed out",ao.NETWORK);if(m instanceof io)throw m;throw new io(m.message,ao.NETWORK)}throw new io("Unknown error occurred",ao.NETWORK)}if(!c.ok){if(401===c.status||403===c.status)throw new io("Invalid application token",ao.INVALID_TOKEN);throw new io(`API Error ${c.status}`,ao.API_ERROR)}const l=await c.json();if(!l.success||!(null==(t=l.data)?void 0:t.task_id))throw new io(l.message||"Failed to start login",ao.LOGIN_FAILED);const d=l.data.task_id,u=`${yl()}/api/v1/auth/recognition/face/login/events/${d}/ticket/`,p=await fetch(u,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n}});if(!p.ok)throw new io(`SSE ticket request failed: ${p.status}`,ao.NETWORK);const f=await p.json(),h=(null==(o=null==f?void 0:f.data)?void 0:o.ticket)??(null==f?void 0:f.ticket);if(!h)throw new io("SSE ticket ausente na resposta",ao.API_ERROR);return new Promise(((e,n)=>{const t=`${yl()}/api/v1/auth/recognition/face/login/events/${d}/?ticket=${encodeURIComponent(h)}`,o=new EventSource(t),r=setTimeout((()=>{o.close(),n(new io("Login timeout",ao.NETWORK))}),31e4),a=()=>{clearTimeout(r),o.close()};o.addEventListener("success",(t=>{var o,r,i,s,c,l;a();try{const n=JSON.parse(t.data);e({success:!0,accessToken:n.token||n.access_token||"",alias:(null==(o=n.user)?void 0:o.alias)||n.alias||"",user:{id:(null==(r=n.user)?void 0:r.id)||"",email:(null==(i=n.user)?void 0:i.email)||"",role:(null==(s=n.user)?void 0:s.role)||"",validated:(null==(c=n.user)?void 0:c.validated)??!1,active:(null==(l=n.user)?void 0:l.active)??!1},person:n.person?{id:n.person.id||"",name:n.person.name||"",birth_date:n.person.birth_date||""}:void 0,confidence_score:n.confidence_score,recognition_id:n.recognition_id??n.history_id})}catch{n(new io("Erro ao processar resposta de login",ao.API_ERROR))}})),o.addEventListener("failed",(e=>{a();try{const t=JSON.parse(e.data);n(new io(t.message||"Login failed",ao.LOGIN_FAILED))}catch{n(new io("Login failed",ao.LOGIN_FAILED))}})),o.addEventListener("error",(e=>{a();try{const t=JSON.parse(e.data||"{}");n(new io(t.message||"Processing error",ao.API_ERROR))}catch{n(new io("Processing error",ao.API_ERROR))}})),o.addEventListener("timeout",(()=>{a(),n(new io("Login timeout",ao.NETWORK))})),o.onerror=()=>{a(),n(new io("SSE connection error",ao.NETWORK))}}))},loginWithEmail:Ml,pollTaskStatus:Kl,recognize:Ol,recognizeBiometric:Al,recognizeByPurpose:Fl,recordFaceVideo:Vl,refreshSession:Bl,registerApplication:Ul,registerBiometric:ql,registerDocumentByImage:Gl,registerPersonWithBiometric:Dl,registerPersonWithoutFace:zl,requestDeviceEnrollmentToken:Ll,requestPasswordReset:Yl,simpleIdentification:Pl,startProofOfLife:Zl,validateOnboardingToken:Cl,validateToken:Nl,videoToBase64:Hl},Symbol.toStringTag,{value:"Module"}));function nd(e,n={}){if(!e||0===e.videoWidth||0===e.videoHeight)return 0;const t=n.sample??64,o=e.videoWidth,r=e.videoHeight,a=n.roi??function(e,n,t){const o=Math.round(e*t),r=Math.round(n*t);return{x:Math.round((e-o)/2),y:Math.round((n-r)/2),width:o,height:r}}(o,r,.4),i=n.scratch??document.createElement("canvas");i.width=t,i.height=t;const s=i.getContext("2d",{willReadFrequently:!0});if(!s)return 0;try{s.drawImage(e,a.x,a.y,a.width,a.height,0,0,t,t);return function(e){const n=e.length;if(0===n)return 0;let t=0,o=0;for(let r=0;r<n;r+=4){t+=.2126*e[r]+.7152*e[r+1]+.0722*e[r+2],o+=1}return 0===o?0:t/(255*o)}(s.getImageData(0,0,t,t).data)}catch{return 0}}function td(e,t={}){const o=t.enabled??!0,r=t.darkThreshold??.235,a=t.improvementTarget??.12,i=t.sampleIntervalMs??600,s=t.minToggleMs??3e3,[c,l]=n.useState(!1),[d,u]=n.useState(0),p=n.useRef(0),f=n.useRef(0),h=n.useRef(null),m=n.useRef(!1),g=n.useRef(null);return n.useEffect((()=>{m.current=c}),[c]),n.useEffect((()=>{if(!o)return l(!1),()=>{};"undefined"==typeof document||g.current||(g.current=document.createElement("canvas"));let n=null,t=null,c=!1;const d=()=>{if(c)return;const n=nd(e.current,{scratch:g.current??void 0});u(n);const o=Date.now();m.current||(n>0&&n<r?p.current+=1:p.current=0,p.current>=2&&o-f.current>=s&&(h.current=n,f.current=o,m.current=!0,l(!0),p.current=0,t=setTimeout((()=>{if(c)return;nd(e.current,{scratch:g.current??void 0})-(h.current??0)<a&&(f.current=Date.now(),m.current=!1,l(!1)),h.current=null}),600)))};return n=setInterval(d,i),d(),()=>{c=!0,n&&clearInterval(n),t&&clearTimeout(t)}}),[o,r,a,i,s,e]),{flashOn:c,lastBrightness:d}}function od({active:e,zIndex:n=10001,onDismiss:t}){if(!e)return null;const r={position:"fixed",inset:0,background:"#FFFFFF",zIndex:n,pointerEvents:"none",animation:"nfid-flash-in 200ms ease-out"},a={position:"fixed",top:12,left:"50%",transform:"translateX(-50%)",zIndex:n+1,background:"rgba(10,19,32,.72)",color:"#FFFFFF",fontSize:12,fontWeight:600,letterSpacing:.2,padding:"6px 12px",borderRadius:999,pointerEvents:t?"auto":"none",display:"flex",alignItems:"center",gap:8};return o.jsxs(o.Fragment,{children:[o.jsx("style",{children:"\n @keyframes nfid-flash-in { from { opacity: 0 } to { opacity: 1 } }\n @media (prefers-reduced-motion: reduce) {\n .nfid-screen-flash { animation: none !important; }\n }\n "}),o.jsx("div",{className:"nfid-screen-flash",style:r,"aria-hidden":"true"}),o.jsxs("div",{className:"nfid-screen-flash-hint",style:a,role:"status",children:["Aumentando a luz da tela",t&&o.jsx("button",{type:"button",onClick:t,"aria-label":"Desligar iluminação assistiva",style:{background:"transparent",border:"none",color:"#FFFFFF",cursor:"pointer",fontSize:14,lineHeight:1,padding:"0 4px"},children:"×"})]})]})}function rd(e,n){return Math.hypot(e.x-n.x,e.y-n.y)}function ad(e){if(6!==e.length)throw new Error(`calculateEAR espera exatamente 6 pontos do olho, recebeu ${e.length}`);const[n,t,o,r,a,i]=e,s=rd(t,i),c=rd(o,a),l=rd(n,r);return l<1e-6?0:(s+c)/(2*l)}const id=(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}},sd={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:"#0059C4",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 cd({accessToken:e,onClose:t,onSuccess:r,onCannotGesture:a,autoLighting:i=!0}){const s=n.useRef(null),c=n.useRef(null),l=n.useRef(null),d=n.useRef(null),u=n.useRef(!1),p=n.useRef(null),[f,h]=n.useReducer(id,{status:"requestingPermission"}),[m,g]=n.useState(!1),{startCamera:v,stopCamera:w}=ro(),b=()=>{if(!s.current)return;const e=async()=>{if(s.current&&"ready"===f.status){try{const e=await Xt(s.current,new vt),n=1===e.length,t=n&&(e=>{if(!s.current)return!1;const{box:n}=e,{videoWidth:t,videoHeight:o}=s.current,r=t/2,a=o/2,i=.4*t,c=.4*o;return n.x+n.width/2>r-i/2&&n.x+n.width/2<r+i/2&&n.y+n.height/2>a-c/2&&n.y+n.height/2<a+c/2})(e[0]);g(n&&t)}catch(n){}d.current=window.setTimeout(e,100)}};e()};n.useEffect((()=>{al()}),[]),n.useEffect((()=>()=>{var e;null==(e=p.current)||e.abort()}),[]);const x=i&&("ready"===f.status||"capturing"===f.status),{flashOn:y}=td(s,{enabled:x});n.useEffect((()=>((async()=>{try{await Promise.all([Et.tinyFaceDetector.loadFromUri("/models"),Et.faceLandmark68Net.loadFromUri("/models")])}catch(e){}})(),()=>{d.current&&window.clearTimeout(d.current)})),[]),n.useEffect((()=>((async()=>{try{const e=await v();l.current=e,s.current&&(s.current.srcObject=e),h({type:"PERMISSION_GRANTED"}),b()}catch(e){h({type:"PERMISSION_DENIED"})}})(),()=>{l.current&&w(l.current)})),[v,w]);const _=async()=>{if(!c.current||!s.current)return;if(u.current)return;u.current=!0;const n=s.current,o=c.current,a=new AbortController;p.current=a;try{h({type:"START_CAPTURE"});const s=await function(e,n,t=3e3,o=.2,r){return new Promise((a=>{const i=Date.now()+t;let s=!1,c=!1;const l=e=>{c||(c=!0,a(e))},d=()=>{c||((null==r?void 0:r.aborted)||Date.now()>=i?l(!1):e.detectSingleFace(n,new e.TinyFaceDetectorOptions).withFaceLandmarks().then((e=>{if(e)if((ad(e.landmarks.getLeftEye())+ad(e.landmarks.getRightEye()))/2<o)s=!0;else if(s)return void l(!0);setTimeout(d,50)})).catch((()=>{setTimeout(d,50)})))};d()}))}(no,n,void 0,void 0,a.signal);if(a.signal.aborted)return;if(!s){const e=new io("Blink not detected within window",ao.LIVENESS_BLINK_MISSING);return void h({type:"SET_ERROR",message:e.getFriendlyMessage()})}const c=o.getContext("2d");if(!c)return void h({type:"SET_ERROR",message:"Failed to get canvas context"});o.width=n.videoWidth,o.height=n.videoHeight,c.drawImage(n,0,0,o.width,o.height);const l=await new Promise(((e,n)=>{o.toBlob((t=>{t?e(t):n(new Error("Failed to convert canvas to blob"))}),"image/jpeg",.95)}));try{const n=await Ol(l,e);r({success:!0,data:{faceId:n.payload.documentId,confidence:1}}),h({type:"UPLOAD_SUCCESS"}),setTimeout(t,1500)}catch(i){h({type:"SET_ERROR",message:"Face recognition failed"})}}catch(i){h({type:"SET_ERROR",message:"Failed to capture image"})}finally{u.current=!1}};return o.jsxs("div",{className:"neofaceid-root",style:sd.overlay,children:[o.jsx(od,{active:y}),o.jsx("style",{children:"\n @keyframes spin {\n 0% { transform: translate(-50%, -50%) rotate(0deg); }\n 100% { transform: translate(-50%, -50%) rotate(360deg); }\n }\n"}),o.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"}),o.jsxs("div",{style:sd.modal,className:"modal",children:[o.jsx("button",{type:"button",style:sd.closeButton,onClick:t,children:"×"}),o.jsx("video",{ref:s,style:sd.video,autoPlay:!0,playsInline:!0,muted:!0}),o.jsx("canvas",{ref:c,style:sd.canvas}),o.jsx("div",{style:sd.guide}),"ready"===f.status&&!m&&o.jsx("div",{style:sd.message,"aria-live":"assertive",children:"Centralize seu rosto no círculo"}),"capturing"===f.status&&o.jsx("div",{style:sd.message,"aria-live":"assertive",children:"Por favor, pisque os olhos"}),("ready"===f.status||"capturing"===f.status)&&o.jsx("button",{type:"button",className:"neofaceid-face-cannot-gesture",onClick:()=>{a?a():t()},"aria-label":"Não consigo fazer esse movimento — buscar alternativa",style:{position:"absolute",bottom:100,left:"50%",transform:"translateX(-50%)",minHeight:44,minWidth:44,padding:"10px 20px",background:"transparent",border:"1px solid rgba(255, 255, 255, 0.32)",borderRadius:22,color:"rgba(255, 255, 255, 0.9)",fontSize:14,fontWeight:500,fontFamily:"inherit",cursor:"pointer",zIndex:10},children:"Não consigo fazer esse movimento"}),"uploading"===f.status&&o.jsx("div",{style:sd.spinner}),"success"===f.status&&o.jsx("div",{style:sd.message,children:"Autenticado!"}),"error"===f.status&&o.jsx("div",{style:sd.message,children:f.message}),o.jsxs("div",{style:sd.controls,children:["ready"===f.status&&m&&o.jsx("button",{type:"button",style:sd.button,onClick:_,children:"Capturar"}),"capturing"===f.status&&o.jsx("button",{type:"button",style:sd.button,onClick:_,children:"Capturar"}),"error"===f.status&&o.jsx("button",{type:"button",style:sd.button,onClick:()=>{h({type:"RESET"})},children:"Tentar Novamente"})]})]})]})}const ld='<svg xmlns="http://www.w3.org/2000/svg" aria-label="NeoFaceID" viewBox="-43.1 -71.1 1318.2 1318.2"><g fill="currentColor"><path d="M138.1 2a10 10 0 0 1-5.8 2c-1.9 0-6.1 1.3-9.2 2.8a94 94 0 0 1-11.1 4.7c-3 1-8.1 3.4-11.2 5.2a33 33 0 0 1-6.7 3.3c-.5 0-1.4.6-1.8 1.4s-2.4 2.1-4.3 3a39 39 0 0 0-11.7 7.8 18 18 0 0 1-5.6 3.8c-1.8 0-33.9 32.3-35.3 35.5a27 27 0 0 1-4.5 6.3c-2 2-4.6 5.4-5.8 7.4-1.3 2.1-2.6 3.8-3.1 3.8s-1.2 1-1.5 2.2c-1.1 3.6-9.6 20.7-10.6 21.4-.5.3-.9 1.6-.9 2.8 0 1.3-.6 3.9-1.4 5.7s-1.2 4.6-.9 6q.4 2.5-1.1 3.8-1.6 1.4-1.6 6.2c0 3.8-.4 5.2-2 6.1-2.6 1.7-3.2 211.1-.6 212.1.8.3 2.6 3.1 4.1 6.3 3 6.3 5.3 8.7 10.2 11 1.8.8 3.3 1.9 3.3 2.4 0 1.4 6 4.2 7.7 3.6.8-.3 2.7.1 4.3.9 3.5 1.8 10.3 2 13.3.3 1.2-.6 3.8-1 5.8-1 2.2.1 4.2-.4 5-1.4.7-.8 3.2-2.7 5.6-4.1 3.9-2.2 6.8-5.6 10.8-12.2l2.7-4.3c1.7-2.6 1.8-7.8 1.8-91.1 0-87.1 0-88.4 2-90.2 1.6-1.5 2-3.1 2-8.7 0-4.2.6-8 1.5-9.8.8-1.6 1.2-3.5.9-4.3-1.2-3.3 6.7-21.9 12.4-29.2 1.2-1.5 2.2-3.3 2.2-4 0-2.1 23.3-24 27.5-25.9a192 192 0 0 0 11.6-5.7c4.2-2.1 8.8-3.9 10.1-3.9a10 10 0 0 0 5.1-2q2.5-2 7-2c2.7 0 4.9-.6 5.7-1.5 1.1-1.3 13.8-1.5 98.4-1.8 107-.4 111.3-.7 118.2-6.8 1.1-1.1 2.7-1.9 3.5-1.9 2.7 0 11.7-10.4 15.8-18.3 4.9-9.4 5.8-18.8 2.1-22.2-1.1-1-2-2.8-2-4.1 0-2-3.5-8.6-5.7-10.6-4-3.7-8.7-7.1-11.7-8.3-2-.9-3.9-2.2-4.2-3-1.1-2.7-237.1-2.1-240.3.5m718.4 0c-1 1.1-2.7 2-3.7 2-2.4 0-12.8 9.7-12.8 12 0 1-.8 2.8-1.8 4.1-8.3 11.1-4.5 32.8 7.8 44.3a27 27 0 0 0 5.9 4.6 26 26 0 0 1 5.9 2.9c7.2 4.2 8.1 4.3 109.3 4.7 79.6.4 91.8.6 92.9 1.9.7.9 2.9 1.5 5.5 1.5q4.2 0 6.5 2c1.3 1.1 3.6 2 5.1 2s3.1.4 3.4 1 1.7 1 3.1 1c1.3 0 3.2.4 4.2 1s2.8 1.5 4.2 2c2.7 1.1 7.2 3.8 14.4 8.6 5.7 3.9 22.6 20.8 22.6 22.7 0 .8.9 2.2 2 3.2a57 57 0 0 1 9 16c.6 1.8 1.8 3.9 2.6 4.5.7.7 1.4 2.7 1.4 4.5s.7 3.8 1.5 4.5q1.5 1.3 1.5 6.7c0 3 .5 6.3 1.1 7.4.7 1.3 1 29.4.9 87.7 0 74.6.1 86 1.4 87.7.9 1.1 1.6 3.7 1.6 5.9 0 2.1 1 5.5 2.2 7.5 5.6 9.4 8.2 13.1 9.3 13.1.7 0 2 .9 3 2 8.7 9.7 33.6 11 42.3 2.4.7-.8 2-1.4 2.7-1.4 2.2 0 11.4-10.1 12.6-14a20 20 0 0 1 2.7-5.3q1.7-1.8 1.4-6.4c-.1-2.5.4-5.5 1-6.6a8 8 0 0 0 .9-4.5q-.1-2 .8-2.2c2 0 1.2-6.4-.9-7.8-1.9-1.1-2-2.3-2-16.7s.1-15.5 2-16.5c2.1-1.1 2.8-4 1-4q-.9-.1-1-1.5.1-1.4 1-1.5c2 0 1.1-7.4-1.1-8.8-2.9-1.8-2.6-38.5.4-40.6 2.1-1.6 2.2-5.5.1-7.1-2.6-1.9-3-9.8-.6-12.1 2.9-2.8 3-12 .2-12.7-2.6-.7-2.6-3.7 0-4.4 2-.5 2.9-3.3 1-3.3q-.9-.1-1-1.5.1-1.4 1-1.5c2.1 0 1.2-13.4-1-15.3-1.9-1.6-2.1-2.8-1.9-17.3.1-12.5-.2-15.9-1.4-17.2-.8-.9-1.7-3.7-2.1-6.2-1-8.8-1.8-11.9-3.2-13.1-.8-.6-1.4-2.6-1.4-4.5s-.4-3.5-.9-3.9-4.3-7.4-8.5-15.9a87 87 0 0 0-9-15.9 3 3 0 0 1-1.6-2.6c0-1-2.7-4.7-6-8.2s-6-6.8-6-7.4a177 177 0 0 0-23.9-23.5c-.7 0-3.5-2.3-6.3-5a31 31 0 0 0-5.8-5c-.5 0-3-1.7-5.7-3.9a32 32 0 0 0-7.1-4.5c-1.2-.4-2.2-1.2-2.2-1.7s-2.9-2.3-6.5-4a28 28 0 0 1-7-4 14 14 0 0 0-5-2c-2.5-.6-5-1.7-5.6-2.5S1110.5 8 1109 8s-3.9-.9-5.3-2q-2.5-2-7.1-2c-3.5 0-4.9-.5-5.8-2-2-3.1-231.4-3.2-234.3 0m-283 111.3c-1.8 1.1-8.2 1.8-31.4 3.3-4.9.3-9.4 1.2-10.5 2-1.2.8-4.5 1.4-7.9 1.4-4.3 0-6.5.5-8.4 2a6 6 0 0 1-5.4 1.3q-2.9-.5-5.4 1.1a10 10 0 0 1-4.5 1.6c-1.1 0-3.2.7-4.5 1.6q-2.6 1.6-5.4 1.1-3-.6-5.4 1.3c-1.4 1.1-3.9 2-5.5 2s-3.5.7-4.2 1.5-2.2 1.5-3.4 1.5-4.5 1.1-7.4 2.5-6.3 2.5-7.4 2.5-3.1.9-4.5 2-3.8 2-5.3 2-3.3.6-3.9 1.4-3.5 2-6.4 2.6a47 47 0 0 0-13.7 5.9c-.8.5-4.6 2.4-8.5 4.1a54 54 0 0 0-10 6 15 15 0 0 1-5.9 3.4c-1.7.4-5.2 2.5-7.9 4.7a25 25 0 0 1-6.1 3.9c-.7 0-2.5 1.4-4.2 3.1a30 30 0 0 1-6.4 4.9c-1.9 1-6.4 4.8-10 8.4a33 33 0 0 1-7.8 6.6 211 211 0 0 0-28.2 27.7c0 .8-2.6 4.2-5.7 7.7-3.2 3.5-7.7 9.5-10.1 13.3a54 54 0 0 1-6.2 8.8q-1.8 1.7-2 2.8a69 69 0 0 1-8.9 17c-1 .6-2.1 2.7-2.4 4.6-.6 2.9-4.2 11-7.5 17.1a27 27 0 0 0-4.2 10.5c0 1.3-.4 2.7-1 3s-1 1.9-1 3.5-.7 3.5-1.5 4.4c-.8.8-1.5 2.8-1.5 4.4s-.6 3.5-1.4 4.1a9 9 0 0 0-2.1 4.4c-.4 1.8-1.8 6.4-3.1 10.4a47 47 0 0 0-2.4 10c0 1.6-.7 3.8-1.5 4.9a17 17 0 0 0-1.5 7.5q0 5.7-1.5 6.9c-.9.7-1.5 2.9-1.5 5.2a18 18 0 0 1-1.6 7 14 14 0 0 0-1.1 8.4c.4 3.9.1 5.8-1.1 7.5s-1.7 4.8-1.7 12.6c-.1 8.2-.4 10.5-1.8 12.1s-1.7 4.1-1.7 16.4c0 12-.3 14.8-1.6 15.8-1.3 1.2-1.5 4.5-1.3 23.8.2 25.1.5 24.2-7.2 24.2q-4.5 0-5.9 1.5c-.7.8-2.4 1.5-3.8 1.5-6.1 0-29.2 19.2-29.2 24.3 0 .9-.9 2.3-2.1 3.1-2 1.4-5.9 11-5.9 14.6 0 .9-.7 2.5-1.5 3.6-1 1.3-1.4 4.5-1.5 10.5 0 7.1-.4 9.1-2 11.2-2.8 3.5-2.8 13.4 0 17 1.8 2.3 2 4 2 20.9 0 13.4.3 18.7 1.3 19.6.6.7 1.5 5.6 2 11 1.5 19.4 1.9 22.1 3.3 23.3.8.7 1.4 3 1.4 5.6q0 4.4 2 7.1 2.1 2.5 1.5 5.1-.5 2.6 1.5 6.4c1.1 2.1 1.8 4.3 1.4 4.9a39 39 0 0 0 4.3 15.3 10 10 0 0 1 1.3 4.6c0 1.5.6 3.2 1.4 3.8.8.7 2.6 4.8 4 9.3 1.5 4.4 3.5 9.2 4.6 10.5s2 3.1 2 3.8c0 2.8 22.8 28.5 25.4 28.5.5 0 1.7.6 2.5 1.3 2.6 2.1 10.9 3.9 13.1 2.7 1-.5 3.7-1 5.9-1s4.3-.5 4.6-1c1.6-2.6 3.3-.8 3.8 4.2.9 9.1 2.3 15.8 3.5 17 .7.7 1.2 3.7 1.2 6.7q0 5.5 1.7 7.3c.9 1 1.6 3.3 1.5 5.1 0 1.7.6 4.8 1.3 6.7s2.3 6.7 3.5 10.7c1.1 4 2.5 7.5 3 7.8s1 2.1 1 3.9c0 1.9.7 3.9 1.5 4.6s1.5 2.5 1.5 4.1.4 3.1 1 3.4 1 1.7 1 3c0 1.9 3.7 10 9 19.5l7.5 15c3.7 7.4 7.2 13.8 7.8 14.2a10 10 0 0 1 2.6 3.5 83 83 0 0 0 8.9 13.5c1.7 2.2 3.2 4.5 3.2 5.2s1.8 3 4 5.1 4 4.6 4 5.5c0 2 54.1 56 56.1 56 .8 0 3.1 1.6 5 3.6a86 86 0 0 0 16.8 12.3 43 43 0 0 1 5.9 4.3 15 15 0 0 0 4.2 2.8c.4 0 2.1 1.1 3.7 2.4 1.5 1.3 3.9 2.7 5.2 3.1a71 71 0 0 1 10.5 6.1c4.4 3 8.6 5.4 9.5 5.4 1.4 0 9 4.6 10.2 6.3.8 1 7.6 4.4 11.5 5.7a11 11 0 0 1 4.4 2.6c.7.7 2.2 1.4 3.3 1.4 1.9 0 9.3 2.9 12.7 5.1l5 2.5 6.2 3c1.4.8 3.7 1.4 5 1.4 1.4 0 3.3.9 4.3 2 1.1 1.2 3.1 2 5.1 2 1.8 0 3.6.4 3.9 1s1.8 1 3.3 1 3.6.7 4.6 1.5c1.1.8 3.9 1.5 6.2 1.5 2.5 0 4.7.6 5.4 1.5q1.3 1.4 6 1.5 4.6 0 6 1.5c1 1.1 3.6 1.5 11.4 1.5q10.2 0 12.6 1.5c3.7 2.1 47.3 2.1 51.4 0q2.8-1.5 11.1-1.5c6.1 0 8.6-.4 9.5-1.5q1.3-1.4 6-1.5 4.6 0 6-1.5c.7-.8 2.9-1.5 4.9-1.5s4.9-.7 6.5-1.5 3.9-1.5 5.2-1.5c1.2 0 2.6-.5 2.9-1s1.9-1 3.4-1 3.8-.9 5.1-2 3.3-2 4.4-2 3.9-.9 6.1-2 5.5-2.3 7.4-2.6a35 35 0 0 0 8.2-3.4c2.5-1.5 5.7-3.1 7-3.5a13 13 0 0 0 3.9-2c.8-.7 4.4-2.5 8-4.1s7.6-3.6 8.9-4.6 3.1-1.8 4.1-1.8 3.7-1.5 6.1-3.4 6.6-4.6 9.3-6a52 52 0 0 0 9.2-6.6c2.4-2.2 5-4 5.7-4s2.2-.9 3.2-2 2.5-2 3.2-2 4.3-2.7 7.7-6 6.8-6 7.5-6 6.8-5.4 13.6-12 13-12 13.9-12 2.6-1.6 3.8-3.6c1.1-1.9 3.2-4 4.4-4.5s2.4-1.7 2.4-2.6 5.4-7.2 12.1-13.8S877 941.9 878 940s3.3-4.9 5-6.5c1.8-1.7 4.7-5.3 6.4-8s4-5.6 4.9-6.4c1-.7 1.7-2.1 1.7-3 0-1 1.1-2.8 2.5-4.1s2.5-2.9 2.5-3.6a13 13 0 0 1 2.8-4.6 97 97 0 0 0 8.9-13.3c.7-1.1 3.5-6.7 6.3-12.5a180 180 0 0 1 6.1-12 84 84 0 0 0 7.9-18.6c0-1.2.5-2.6 1.1-2.9a43 43 0 0 0 5.9-12.6c0-1.6 1.9-7.8 3.2-10.3.5-1 1.1-3.8 1.3-6.3a12 12 0 0 1 1.9-6.2c.9-1 1.6-3.1 1.6-4.8s.7-3.6 1.6-4.4q1.6-1.3 1.1-4.8a20 20 0 0 1 1-7.5c.7-2.1 1.3-5.2 1.3-6.8q.1-8.7 9.6-8.8 12.4 0 28-15.8a56 56 0 0 0 14.3-21.2c.6-1.4 2.4-4.8 4-7.5a22 22 0 0 0 3-7.7c.1-1.5.6-3 1.1-3.3s1-1.9 1-3.4.7-3.6 1.5-4.7c.8-1 1.5-3.1 1.5-4.5 0-1.5.7-3.2 1.5-3.9q1.5-1.2 1.5-7.2c0-4.5.5-6.6 2-8.5s1.9-3.4 1.4-6q-.6-3.4 1.1-8a20 20 0 0 0 1.1-10.5c-.4-4.6-.2-6.5 1.1-8.4s1.6-5 1.6-14.7c-.1-10.3.2-12.7 1.8-15.3 3-4.9 2.9-48.9-.1-52.7-1.7-2.2-2-3.6-1.5-8.4.4-4.3.1-6.4-1-7.9a8 8 0 0 1-1.5-4.2c-.1-11.9-25.4-37-37.5-37.2-1.1 0-2.9-.7-3.9-1.5a9 9 0 0 0-4.7-1.5c-3.9 0-4-1.1-3.8-25 .1-18.7-.1-22-1.5-24.9-1.5-2.7-1.7-5.6-1.5-16q.3-12.7-.9-14.8a44 44 0 0 1-1.2-13c0-8.1-.4-11.4-1.5-12.9a17 17 0 0 1-1.5-7.5q0-5.7-1.5-6.9t-1.5-6.9c0-3.2-.6-6.5-1.4-7.6s-1.6-4.7-1.9-8c-1.1-10.7-2.3-16-4-18.5-.9-1.3-1.7-3.6-1.7-5s-.7-3.4-1.5-4.4a9 9 0 0 1-1.5-4.7c0-1.5-.4-3.1-1-3.4s-1-1.7-1-3-1.4-4.7-3.1-7.6a36 36 0 0 1-3.6-8.3c-.3-1.7-2.3-6.5-4.4-10.7a53 53 0 0 1-3.9-8.4 59 59 0 0 1-5.6-10.5 53 53 0 0 0-4.6-8.9 9 9 0 0 1-1.8-4.2c0-1-.9-2.3-1.9-2.9-1.1-.5-2.3-2-2.7-3.2s-1.8-3.7-3.3-5.4a59 59 0 0 1-4.6-6.5l-3.8-6.4c-1-1.6-5-6.2-8.8-10a36 36 0 0 1-6.9-8.5c0-1.9-14-16-15.9-16-.7 0-5.3-3.8-10-8.5a69 69 0 0 0-9.7-8.5c-.5 0-3.4-2.2-6.5-4.8a81 81 0 0 0-14.8-10.1q-2.5-1.4-3.1-2.2c-.9-1.4-7.7-5.7-10.1-6.4-1.3-.4-3.5-1.8-4.9-3a32 32 0 0 0-7.3-4.5c-2.6-1.2-5-2.6-5.3-3.1q-.6-.8-2.3-.9c-1 0-3-.9-4.4-2s-3.9-2-5.5-2a7 7 0 0 1-4.2-1.4c-.6-.8-3.4-2.2-6.1-3.1s-5.1-2.1-5.4-2.6-1.9-.9-3.4-.9-3.8-.9-5.1-2a9 9 0 0 0-4.7-2c-1.3 0-3.1-.4-4.1-.9a54 54 0 0 0-7.7-2.6c-3.3-.9-7.3-2.3-8.8-3.1s-3.8-1.4-5-1.4-3.5-.9-5.2-2c-1.6-1.1-4.2-2-5.7-2s-3-.5-3.3-1-1.7-1-3.1-1-3.6-.7-4.9-1.6q-2.6-1.6-5.4-1.1-3 .6-5.4-1.3-2.5-2-7.7-2c-2.8 0-6.1-.6-7.3-1.2-2.4-1.4-13.5-2.6-32.4-3.4-8.8-.4-12.5-1-13.4-2-1.6-1.9-67.3-2-70.4-.1m85.7 55.8c.9.5 4.5.9 8 .9 3.9.1 7 .6 8.2 1.5s4.2 1.5 7 1.5c2.9 0 5.9.7 7 1.5s3.8 1.5 6.1 1.5 4.6.5 5.3 1.2c1.1 1.1 7.2 2.4 16.4 3.5 2.6.2 5.2 1.1 5.9 1.9.6.8 2.2 1.4 3.6 1.4s4.1.9 6.1 1.9a59 59 0 0 0 20 7.1c1.1 0 2.3.4 2.6.8.7 1.2 15.1 8.2 16.7 8.2 2 0 10.9 4.3 10.9 5.2 0 .5 2.8 2.3 6.3 3.9 6 2.9 10.8 5.6 15.8 9 6.6 4.4 8.4 5.6 11.4 7.4 9.8 6 15.6 11 31 26.7S872 280.6 872 283c0 .5 1.1 2.2 2.5 3.8s3.4 5.1 4.5 7.7 2.7 5.3 3.5 5.9a67 67 0 0 1 9.5 18.9c0 1.3.8 3.4 1.7 4.7a42 42 0 0 1 6.3 14.5c0 1.2.9 3.4 2 4.8s2 3.9 2 5.5.6 3.5 1.4 4.1c.8.7 1.7 3.3 2 5.9.9 8.6 1.8 12.1 3.2 13.3.8.7 1.4 3 1.4 5.7q0 4.4 1.8 6.5c1.2 1.3 1.7 3.6 1.7 7.7.1 3.5.7 6.5 1.5 7.5 1 1.2 1.3 3.8 1.1 9s.2 8.2 1.4 10.5c1.3 2.5 1.6 5.5 1.4 13.5-.3 8.7-.1 10.7 1.4 12.3 1.6 1.7 1.7 6.4 1.7 61.6 0 69.2-.3 66.6 9.1 71.9 5.5 3.1 7.9 3.3 11.7 1.3 1.5-.8 3.9-1.7 5.4-2s6.4-4.3 11.4-9.1c4.8-4.7 9.4-8.5 10.2-8.5 1.8 0 7.3 4.5 8.9 7.4 2 3.4 1.8 49.5-.2 53.2-1.1 2.1-1.5 6.1-1.5 14 0 8.7-.3 11.4-1.5 12.4s-1.5 3.5-1.5 10.5-.4 9.6-1.5 10.5c-.8.7-1.5 2.8-1.5 4.7s-.7 4.8-1.6 6.5-1.3 4-1 5.1-.2 3.3-1 5c-.9 1.6-1.7 4.8-1.9 7.1-.1 2.5-1.6 6.5-3.7 10.1-2 3.3-3.9 7.1-4.3 8.5-1.7 5.9-7.8 9.7-10.5 6.5a6 6 0 0 0-3.9-1.5c-1.5 0-3.6-.7-4.9-1.5-1.9-1.4-2.4-1.4-5.1 0-1.7.8-4.6 1.5-6.5 1.5-5.7 0-16.5 12.6-16.6 19.3 0 1.2-1.2 4-2.5 6.2a16 16 0 0 0-2.5 8.6q0 4.5-1.5 5.9-1.5 1.2-1.5 7c0 4.1-.5 6.4-1.9 8.1a17 17 0 0 0-2.4 6.9 66 66 0 0 1-4.7 20.7c-.6 2.3-1.5 4.5-2 4.8s-1 1.9-1 3.4c0 1.6-.9 3.9-1.9 5.3a14 14 0 0 0-2.6 5.4 61 61 0 0 1-5.9 14.4c-.7.8-2.5 4.4-4.1 8a52 52 0 0 1-4.1 8.1c-.8.8-1.4 2.2-1.4 3 0 1.4-6.6 12.3-11.9 19.5a56 56 0 0 0-4.6 8c-.9 2.2-3.8 6.1-6.4 8.9a40 40 0 0 0-6.4 8c-.9 1.6-3.6 5-6.1 7.5-2.5 2.4-4.6 5.1-4.6 5.9 0 1.9-41 43.1-42.8 43.1-.8 0-3.9 2.4-7 5.4-3.1 2.9-7 6-8.7 6.9-1.6.8-4.3 2.9-5.9 4.6s-3.4 3.1-3.9 3.1a26 26 0 0 0-5.9 4 28 28 0 0 1-6 4c-.6 0-2.3 1.1-4 2.5-1.6 1.4-3.5 2.5-4.2 2.5s-2.1 1-3.2 2.1c-1 1.2-4.2 3.2-7 4.4a21 21 0 0 0-5.8 3.4 3 3 0 0 1-2.2 1.1c-.9 0-4.2 1.6-7.5 3.5a44 44 0 0 1-8.7 4.1c-1.5.4-3.6 1.4-4.7 2.3q-3.8 3.1-16.5 6.7c-3.6.9-6.9 2.1-7.5 2.6s-2.1.8-3.5.8a9 9 0 0 0-4.9 1.9q-2.2 2-6.7 1.8c-2.8 0-5.1.6-6 1.5-1.2 1.2-3.1 1.4-8.4 1-5-.3-7.6 0-10 1.2-4.7 2.3-40.6 2.4-47.1.1a30 30 0 0 0-10.4-1.3c-3.3.1-7-.4-8.2-1s-3.7-1.2-5.5-1.2-5-.9-7.1-2-4.8-2-6.2-2c-3.3 0-17.6-4.8-19.6-6.6-.8-.8-2.9-1.4-4.6-1.4a7 7 0 0 1-4.7-1.9c-.9-1-3-2.1-4.5-2.4s-5.5-2.2-8.9-4.1c-3.3-2-7.2-3.6-8.6-3.6s-3.4-.8-4.4-1.8-3.6-2.7-5.7-3.9a110 110 0 0 1-16.1-9.2 10 10 0 0 0-3.7-2.1c-.5 0-2.4-1.2-4.2-2.7-3-2.6-6.6-5-12.4-8.2-1.5-.8-2.8-1.7-3.1-2a39 39 0 0 0-8.7-6.1c-.5 0-2.2-1.4-3.9-3.1a24 24 0 0 0-5.9-4.6 156 156 0 0 1-18.2-15.6c-10.8-11-22.4-24-24.1-26.7a51 51 0 0 0-6.6-8c-2.5-2.4-4.6-5.2-4.6-6.1s-.9-2.4-2-3.4-3.9-4.9-6.2-8.7c-2.4-3.9-5.6-8.5-7.1-10.3a29 29 0 0 1-4.3-7.9c-.9-2.4-2.2-5-3-5.7-.8-.6-1.4-1.7-1.4-2.4a19 19 0 0 0-3.5-5.6c-1.9-2.4-3.8-6-4.1-7.9a50 50 0 0 0-3.8-9.5 54 54 0 0 1-4.6-12 54 54 0 0 0-2.7-8.5c-.7-1.4-1.3-3.4-1.3-4.5a12 12 0 0 0-2-5q-1.8-2.9-1.4-5.2c.3-1.2-.1-3.6-1-5.4s-1.6-4.4-1.6-5.9-.7-4.5-1.6-6.5c-1-2.4-1.3-5.1-.9-7.2.4-2.5.1-4-1.4-6q-2.1-2.6-2.1-6.8c0-2.6-.6-4.8-1.5-5.5s-1.5-2.7-1.5-4.6-.4-3.6-1-3.9-1-1.9-1-3.4c0-1.7-1.3-4.3-3.3-6.7a20 20 0 0 1-4.1-6.8c-1.2-4.9-10.4-13.1-16.3-14.5a29 29 0 0 1-7-2.6c-2.6-2-6.7-1.8-11 .5-2.1 1.1-4.8 2-6 2s-2.5.4-2.8 1c-.9 1.5-4.5 1.2-4.5-.4 0-.7-.9-2.5-2-3.9s-2-3.8-2-5.3-.6-3.5-1.4-4.3a75 75 0 0 1-6.3-17.6c-.3-1.7-1.4-4-2.4-5.3a6 6 0 0 1-1.3-5.1c.4-1.7-.1-4.1-1-5.9-.9-1.7-1.6-4.4-1.6-6s-.7-4.6-1.5-6.6c-1-2.3-1.3-5-1-6.9.5-2.4.1-3.9-1.4-5.9-1.6-2-2.1-4.1-2.1-8.6q0-6-1.4-7.2c-2.3-1.8-4.1-57.3-2.1-66 1.9-8.9 10.6-10.9 15.2-3.7.5.7 3.6 3.1 7.1 5.4 11.5 7.8 33.2 5.3 33.2-3.7 0-.9.9-2.5 2-3.5 2-1.8 2-3 2-29.1-.1-17.4.3-28 .9-29.3.7-1.2 1.1-11.7 1.1-28.1 0-21.5.3-26.6 1.5-29.1 1.2-2.2 1.5-5.7 1.4-13.5-.1-8.4.2-10.8 1.5-12.3 1.1-1.3 1.6-3.7 1.6-8.7 0-5.2.5-7.6 2-9.9a8 8 0 0 0 1.4-6.2c-.4-2 0-4.9 1-7.4.9-2.3 1.4-4.9 1.1-5.8s.4-3.4 1.4-5.4c1.3-2.6 1.7-4.9 1.4-7.8-.5-3.1-.1-4.7 1.6-6.9 1.1-1.6 2.1-3.9 2.1-5.2a8 8 0 0 1 1.5-4.2 9 9 0 0 0 1.5-4.7c0-1.5.5-3.1 1-3.4s1-1.7 1-2.9a33 33 0 0 1 3.5-9c1.9-3.7 3.5-7.5 3.5-8.5a244 244 0 0 1 29.7-52.3c2.4-2.7 4.3-5.4 4.3-6 0-1.6 23.2-24.8 24.8-24.8.7 0 4.8-3.3 9.1-7.3 4.2-3.9 9-8 10.6-8.9l9.7-6c1.5-1 3.3-1.8 4.1-1.8s2.2-.9 3.2-2 4.1-3.1 6.9-4.5 5.8-2.9 6.6-3.5l11.5-5.6a139 139 0 0 0 11.5-5.9c.8-.7 2.9-1.5 4.5-1.8a53 53 0 0 0 16.6-5.6c3.4-1.7 7.7-3.1 9.5-3.1a16 16 0 0 0 6.1-1.4 36 36 0 0 1 12-3.6 5 5 0 0 0 3.3-1.5q1.2-1.5 6.9-1.5c3.5 0 6.5-.6 7.7-1.5 1-.8 4.1-1.5 6.7-1.5s5.8-.6 7-1.2c3.7-2.1 18.4-3 63.7-3.6 43.8-.7 48.1-.6 51.2.9"/><path d="M752.5 559.1c-2.7 1.6-6.2 3.5-7.7 4.2a42 42 0 0 0-14.3 14.5c-.3 1.5-1.2 4-2 5.5-2.8 5.5-2.1 30 1 33.3 1.4 1.5 2.5 3.1 2.5 3.7 0 3 6.7 8.6 16 13.4 5.7 2.9 30.7 3.5 33 .8.7-.8 1.9-1.5 2.7-1.5 3 0 12.3-10.4 16.3-18.3 4.5-8.9 5.8-22.7 2.5-28.5-.8-1.5-1.9-4.6-2.5-7-1.2-4.8-8.3-13.8-11.7-14.7-1.2-.4-2.9-1.5-3.9-2.6-.9-1-3-1.9-4.5-1.9-1.6 0-4.3-.9-6.1-2-5.2-3.2-14.9-2.7-21.3 1.1m-296.1 7.1a8 8 0 0 1-4.2 1.8c-1.2 0-2.4.5-2.7 1s-2.4 1.9-4.5 3-4.3 3.1-4.9 4.7c-.6 1.5-2.7 5-4.6 7.8-3.1 4.4-3.5 5.7-3.5 11.1 0 4.8-.4 6.5-2 7.9-1.5 1.3-2 3.1-2 6.6 0 3.8.4 5.1 2 5.9q2 1 2 4.5c0 6 8.1 16.2 17.8 22.3 5.4 3.4 28.3 3 33.1-.6 1.7-1.2 3.7-2.2 4.5-2.2s2.3-1.1 3.3-2.5l5.3-7.3c6.6-8.9 7-10.4 7-24.3 0-10-.3-12.9-1.5-13.9a6 6 0 0 1-1.5-3.9c0-3.6-16.4-20.1-19.9-20.1-1.4 0-3.2-.6-4-1.4-2.6-2.3-16.9-2.6-19.7-.4M597.5 601c-11.1 1-12.2 1.7-17 12l-3.1 6.3a19 19 0 0 0-1.4 7.1q0 4.3-2 6.9-2 2.5-2 6.9c0 2.4-.6 5.3-1.4 6.4-1.6 2.2-2.3 11.4-3.2 38.4-.5 16.2-.4 16.6 2.2 23 3 7.2 9.9 14.6 14.6 15.6 1.5.4 3.3 1.3 3.9 2 2.6 3.2 12.1 6.6 16.7 6.1 2.7-.3 6.2.1 8.5.9 4.8 1.7 12 1.8 14.9.3 1.2-.6 3.9-1.1 6.2-1.1 11.1.2 21.1-15.1 16.1-24.7-3.7-7.3-6-8.1-23.6-8.1-15.9 0-15.9 0-18.9-4.2-3.8-5.2-4.3-14.3-1-18.5 1.6-2.1 2-4.1 2-10.7 0-5.2.5-8.7 1.2-9.4a21 21 0 0 0 2-8c1.3-12.3 2.4-18.2 3.6-19.4.8-.8 1.2-4.6 1.2-10.5 0-9.2 0-9.2-4.5-13-5.7-4.8-6.5-5-15-4.3m138.9 189.1c-.9 1-2.4 1.9-3.3 1.9s-4.1 2.5-7.1 5.5-6 5.5-6.6 5.5c-.7 0-2.6 1.1-4.2 2.5a14 14 0 0 1-3.7 2.5c-.5 0-2.7 1.6-5.1 3.5-2.4 2-5.8 4.1-7.6 4.7s-5.4 2.4-7.9 3.9-5.7 3-7 3.4a13 13 0 0 0-3.9 2c-1.4 1.2-3.4 1.7-11.7 3.2-1.8.3-3.8 1.1-4.4 1.9s-3 1.4-5.6 1.4a11 11 0 0 0-6.8 1.9c-1.9 1.4-3.5 1.7-7.2 1.4q-4.9-.4-8.7 1.1c-5.5 2.3-56.5 2.4-61.9.1-2-.8-6.5-1.5-10-1.5q-6.5 0-7.7-1.5c-.7-.9-2.9-1.5-5.4-1.5-2.3 0-5.1-.7-6.2-1.5-1-.8-3.1-1.5-4.6-1.5s-3-.5-3.3-1-2-1-3.7-1c-1.6 0-4.1-.9-5.5-2a9 9 0 0 0-3.8-2c-.6 0-2-1-3.1-2.1-1-1.2-4.2-3.2-7-4.4a54 54 0 0 1-14.1-11.3 66 66 0 0 0-14.3-11.7q-1.3-1.5-6.5-1.5c-7.1 0-18.5 11.1-18.5 17.9 0 3.8 4 13.3 6 14.6.6.4 1.9 2.3 2.9 4.4 2.3 4.3 15.8 17.9 22.8 22.6 6.6 4.5 30.6 16.5 33 16.5 1.2 0 2.6.6 3.2 1.4 1.2 1.4 4.7 2.3 13.3 3.2 2.6.3 5.2 1.2 5.9 2q1.2 1.4 6.6 1.4c3.4 0 6.8.7 9.3 2 6.1 3.1 76.3 3.1 80.3 0 2-1.6 4-2 9.5-2q7 0 8.1-1.4c.7-.8 3.3-1.6 5.9-1.9 7.5-.9 11.6-1.8 13.2-3.2.8-.7 2.9-1.5 4.5-1.8a130 130 0 0 0 35.5-16.2 32 32 0 0 1 7.1-4c1.4-.3 3.9-1.9 5.4-3.5s3.5-3 4.4-3c2.3 0 22.1-20.8 24.2-25.4 3.9-8.6.4-19.7-8-25.3-3.9-2.5-14.5-2.7-16.7-.2M29 793.5c-1.4.8-3.5 1.4-4.8 1.5-1.2 0-3.2 1.1-4.4 2.5s-2.9 2.5-3.7 2.5c-2.7.1-7.6 5.4-10.7 11.5a22 22 0 0 1-4.1 6.2c-2.5 1-1.8 217 .7 218.3 1.6.8 2 2.1 2 5.9q0 4.8 1.5 6.1c.8.7 1.5 2.7 1.5 4.4 0 1.9 1.1 4.7 2.5 6.6s2.5 4.4 2.5 5.5c0 2.9 7.2 17.1 9.9 19.6 1.2 1.1 2.1 2.6 2.1 3.3 0 1.2 1.9 4 8.2 12 1.3 1.7 2.8 4 3.3 5.3 1.4 3.3 32.4 34.2 36 35.9 3.3 1.6 8.5 5.1 12.9 8.9 1.5 1.4 3.4 2.5 4 2.5a158 158 0 0 1 20.6 10.2c1.4.8 6.6 2.7 11.5 4.3s10.2 3.3 11.7 4.1c1.4.8 4.8 1.4 7.5 1.4q4.8 0 7.8 2c4.7 3.1 225.2 3.1 228 0 1-1.1 2.9-2 4.2-2 4.8 0 13.9-8 20.9-18.5 4.7-6.9 5.1-22.7.7-30.3a47 47 0 0 0-29.3-22.8c-2.5-.4-48.2-.8-101.6-1.1-84.6-.3-97.3-.5-98.4-1.8q-1.2-1.5-7.6-1.5c-4.1 0-7.9-.7-10.6-1.9-2.4-1.1-7.7-2.9-11.8-4.2-4.1-1.2-8.6-3-9.9-4a8 8 0 0 0-4.1-1.9c-.9 0-2.6-1.1-3.8-2.5s-2.9-2.5-3.7-2.5c-1.8 0-23.5-20.8-23.5-22.6 0-.7-1-2.5-2.3-4.1a37 37 0 0 1-3.5-5.3l-3.7-7a37 37 0 0 1-3.1-8.3c-.4-2-1.1-4-1.5-4.3-.5-.3-.9-1.8-.9-3.3s-.5-3.2-1.1-3.8a51 51 0 0 1-1-15c.2-12.6 0-14.2-1.9-16.5-2-2.6-2-3.6-2-85.7 0-83.1 0-83.1-3.5-90.1-4.8-9.6-16-18-24-18-1.2 0-2.8-.7-3.5-1.5-1.6-2-12.6-2-16 0m1154 5c-1.4.8-3.6 1.4-5 1.5-2.8 0-12.5 5.9-15.3 9.3a37 37 0 0 0-6.7 11c0 .8-.9 2.2-2 3.2-1.6 1.4-2 3.1-2 7.9 0 3.8-.6 7-1.5 8.3-1.3 1.8-1.5 13.4-1.4 87.7 0 58.2-.3 86.2-1 87.5-.6 1.1-1.1 4.4-1.1 7.4q0 5.5-1.5 6.7c-.8.7-1.5 1.9-1.5 2.7s-.9 2.6-2 4c-1.2 1.5-1.8 3.4-1.5 4.4q.5 1.8-1.4 3.8a21 21 0 0 0-3.6 5.3l-3.3 6.5a72 72 0 0 1-16.4 16.3c-.7 0-3.1 1.7-5.2 3.7a47 47 0 0 1-9.2 6.4 68 68 0 0 0-6.6 3.6c-.7.6-3 1.6-5 2.2s-4.2 1.9-4.8 2.7c-.8.8-3.1 1.4-6 1.4q-4.8 0-7 2c-1.7 1.5-3.7 2-8 2-3.4 0-6.4.6-7.6 1.5-1.6 1.2-15.2 1.4-98.7 1.5-105.6 0-104.7 0-110.8 5.6-1.4 1.3-3 2.4-3.6 2.4-2.2 0-7.9 6.6-10.6 12.2-1.5 3.1-3.2 6-3.7 6.3-2.5 1.5-1.2 22.4 1.7 27.3 3.7 6.5 14 16.9 18.4 18.6 2 .8 3.9 2.2 4.2 3 1.1 2.8 231.7 2.3 234.2-.4q1.8-2 5.7-2c2.1 0 5.5-.9 7.5-2 2.1-1.1 4.3-2 5-2 1.8 0 16.6-5 17.9-6.1 2-1.6 18.8-9.9 20.1-9.9.7 0 2.1-.9 3.1-2.1.9-1.1 3.3-2.9 5.2-3.9s5.1-3.4 6.9-5.4 4.1-3.6 4.9-3.6c2.2 0 23.9-21.6 27.8-27.7 1.9-2.8 3.8-5.4 4.4-5.8a42 42 0 0 0 4.6-6.3l5.5-8.4a10 10 0 0 0 1.9-4.3c0-.8 1-2.5 2.3-3.7a31 31 0 0 0 6.7-13.5c0-1.2.5-2.5 1-2.8 2.6-1.6 5.4-11.2 6.7-22.7.2-2.6 1.1-5.2 1.9-5.9 1.1-.9 1.4-4 1.4-13 0-10.8.2-12 2-13.1 2.4-1.5 3.1-18.2.8-19.1q-1.5-.3-.1-2.5c1-1.6.9-2.3-.2-3.2-1.9-1.5-1.9-4.9-.2-5.6s2.2-13 .7-13.9q-.9-.6.2-2.5c.9-1.4.9-2.2-.1-3.4s-1.1-1.9-.2-3q1.4-1.3-.4-2.6c-1.9-1.6-1.9-5.9 0-6.6 2.6-1 2.2-26.5-.5-28.2q-1.8-1.2-2-2.2c0-.6.9-1.8 2-2.7 2.2-1.9 3.1-19.3 1-19.3-.5 0-1-1.1-1-2.4 0-1.4.5-2.8 1-3.1 2-1.2 1.2-12.9-1-14.3-1.9-1.2-2-2.3-2-26.1 0-15.8-.4-25.2-1-25.6s-1.7-2.2-2.5-4.1-1.8-3.4-2.4-3.4-1.4-1.5-2-3.3q-1.1-3.2-5.8-6.1a42 42 0 0 1-6.6-4.8c-1-1-2.8-1.8-4.1-1.8s-3.7-.7-5.2-1.5a22 22 0 0 0-15.4 0"/></g></svg>',dd=ld;const ud={display:"flex",alignItems:"center",justifyContent:"center",gap:6,color:"var(--nfid-text-subtle)",fontFamily:"inherit",lineHeight:1},pd={display:"inline-flex",alignItems:"center",justifyContent:"center",color:"currentColor"},fd={fontSize:12,fontWeight:600,letterSpacing:.2,color:"var(--nfid-text-muted)"},hd={fontSize:9,fontWeight:400,color:"var(--nfid-text-subtle)",opacity:.75},md={fontSize:9,fontWeight:500,color:"var(--nfid-text-subtle)",opacity:.75};function gd({size:e=16,style:n}){return o.jsxs("div",{className:"neofaceid-brand-footer",style:{...ud,...n},children:[o.jsx("span",{"aria-hidden":"true",style:{...pd,width:e,height:e},dangerouslySetInnerHTML:{__html:dd}}),o.jsx("span",{style:fd,children:"NeoFaceID"}),o.jsx("span",{style:hd,children:"by"}),o.jsx("span",{style:md,children:"Octa"})]})}function vd(e=16){return`<div class="neofaceid-brand-footer" style="display:flex;align-items:center;justify-content:center;gap:6px;color:var(--nfid-text-subtle);font-family:inherit;line-height:1;"><span aria-hidden="true" style="${`display:inline-flex;align-items:center;justify-content:center;color:currentColor;width:${e}px;height:${e}px;`}">${dd}</span><span style="font-size:12px;font-weight:600;letter-spacing:0.2px;color:var(--nfid-text-muted);">NeoFaceID</span><span style="font-size:9px;font-weight:400;color:var(--nfid-text-subtle);opacity:0.75;">by</span><span style="font-size:9px;font-weight:500;color:var(--nfid-text-subtle);opacity:0.75;">Octa</span></div>`}class wd{constructor(e){l(this,"applicationToken"),l(this,"modalElement",null),this.applicationToken=e}open(){this.modalElement||(al(),this.addStyles(),this.modalElement=document.createElement("div"),this.modalElement.className="neofaceid-root neoface-forgot-modal",this.renderEmailForm(),document.body.appendChild(this.modalElement))}close(){this.modalElement&&document.body.contains(this.modalElement)&&(document.body.removeChild(this.modalElement),this.modalElement=null)}renderEmailForm(){if(!this.modalElement)return;this.modalElement.innerHTML=`\n <div class="neoface-forgot-overlay">\n <div class="neoface-forgot-content">\n <div class="neoface-forgot-icon">\n <svg viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="32" cy="32" r="28" stroke="#0059C4" stroke-width="3" fill="none"/>\n <rect x="22" y="28" width="20" height="16" rx="3" stroke="#0059C4" stroke-width="2.5" fill="none"/>\n <path d="M26 28v-4a6 6 0 0 1 12 0v4" stroke="#0059C4" stroke-width="2.5" stroke-linecap="round"/>\n <circle cx="32" cy="36" r="2" fill="#0059C4"/>\n </svg>\n </div>\n\n <h2 class="neoface-forgot-title">Recuperar senha</h2>\n <p class="neoface-forgot-subtitle">Informe seu email e enviaremos um link para redefinir sua senha.</p>\n\n <div id="neoface-forgot-error" class="neoface-forgot-error" style="display:none"></div>\n\n <form id="neoface-forgot-form">\n <input\n type="email"\n id="neoface-forgot-email"\n class="neoface-forgot-input"\n placeholder="seu@email.com"\n autocomplete="email"\n required\n />\n <button type="submit" class="neoface-forgot-btn-primary">\n Enviar link\n </button>\n </form>\n\n <button class="neoface-forgot-btn-ghost neoface-forgot-back">\n Voltar\n </button>\n\n <div class="neoface-forgot-branding">\n ${vd()}\n </div>\n </div>\n </div>\n `;this.modalElement.querySelector("#neoface-forgot-form").addEventListener("submit",this.handleSubmit.bind(this));this.modalElement.querySelector(".neoface-forgot-back").addEventListener("click",this.close.bind(this))}renderSuccess(){if(!this.modalElement)return;const e=this.modalElement.querySelector(".neoface-forgot-content");e.innerHTML=`\n <div class="neoface-forgot-success-icon">\n <svg viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="32" cy="32" r="28" stroke="#0E9F6E" stroke-width="3" fill="none"/>\n <path d="M20 32 L28 40 L44 24" stroke="#0E9F6E" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>\n </div>\n\n <h2 class="neoface-forgot-title">Email enviado!</h2>\n <p class="neoface-forgot-subtitle">\n Verifique sua caixa de entrada e siga as instruções para redefinir sua senha.\n <br/><br/>\n <span style="color: rgba(255,255,255,0.5); font-size: 13px;">Não recebeu? Verifique também sua pasta de spam.</span>\n </p>\n\n <button class="neoface-forgot-btn-primary neoface-forgot-close-success" style="margin-top: 8px;">\n Fechar\n </button>\n\n <div class="neoface-forgot-branding">\n ${vd()}\n </div>\n `;e.querySelector(".neoface-forgot-close-success").addEventListener("click",this.close.bind(this))}async handleSubmit(e){var n,t,o,r;e.preventDefault();const a=null==(n=this.modalElement)?void 0:n.querySelector("#neoface-forgot-email"),i=null==(t=this.modalElement)?void 0:t.querySelector(".neoface-forgot-btn-primary"),s=null==(o=this.modalElement)?void 0:o.querySelector("#neoface-forgot-error"),c=null==(r=null==a?void 0:a.value)?void 0:r.trim();if(c){i.disabled=!0,i.textContent="Enviando...",s.style.display="none";try{await Yl(c,this.applicationToken),this.renderSuccess()}catch(l){i.disabled=!1,i.textContent="Enviar link",s.style.display="block",s.textContent=l instanceof io?l.message:"Erro ao enviar email. Tente novamente."}}}addStyles(){const e="neoface-forgot-password-modal-styles";document.getElementById(e)||il(e,"\n .neoface-forgot-modal {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 10003;\n font-family: inherit;\n }\n\n .neoface-forgot-overlay {\n position: absolute;\n inset: 0;\n background: rgba(0, 0, 0, 0.65);\n backdrop-filter: blur(8px);\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 20px;\n animation: neoface-forgot-fadeIn 0.3s ease-out;\n }\n\n @keyframes neoface-forgot-fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n\n @keyframes neoface-forgot-slideUp {\n from { opacity: 0; transform: translateY(20px); }\n to { opacity: 1; transform: translateY(0); }\n }\n\n .neoface-forgot-content {\n background: linear-gradient(135deg, #0A1320 0%, #111C2B 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: neoface-forgot-slideUp 0.4s ease-out;\n text-align: center;\n }\n\n .neoface-forgot-icon {\n width: 64px;\n height: 64px;\n margin: 0 auto 20px;\n }\n\n .neoface-forgot-success-icon {\n width: 64px;\n height: 64px;\n margin: 0 auto 20px;\n animation: neoface-forgot-scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);\n }\n\n @keyframes neoface-forgot-scaleIn {\n 0% { transform: scale(0); opacity: 0; }\n 50% { transform: scale(1.1); }\n 100% { transform: scale(1); opacity: 1; }\n }\n\n .neoface-forgot-title {\n font-size: 22px;\n font-weight: 700;\n color: white;\n margin: 0 0 10px 0;\n }\n\n .neoface-forgot-subtitle {\n font-size: 15px;\n color: rgba(255, 255, 255, 0.7);\n margin: 0 0 24px 0;\n line-height: 1.5;\n }\n\n .neoface-forgot-error {\n background: rgba(239, 68, 68, 0.15);\n border: 1px solid rgba(239, 68, 68, 0.4);\n color: #fca5a5;\n border-radius: 10px;\n padding: 10px 14px;\n font-size: 14px;\n margin-bottom: 16px;\n text-align: left;\n }\n\n #neoface-forgot-form {\n display: flex;\n flex-direction: column;\n gap: 14px;\n margin-bottom: 12px;\n }\n\n .neoface-forgot-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.08);\n color: white;\n font-family: inherit;\n transition: all 0.2s;\n box-sizing: border-box;\n }\n\n .neoface-forgot-input::placeholder {\n color: rgba(255, 255, 255, 0.4);\n }\n\n .neoface-forgot-input:focus {\n outline: none;\n border-color: #0059C4;\n box-shadow: 0 0 0 3px rgba(0, 89, 196, 0.2);\n background: rgba(255, 255, 255, 0.12);\n }\n\n .neoface-forgot-btn-primary {\n width: 100%;\n padding: 14px 24px;\n border-radius: 12px;\n border: none;\n background: linear-gradient(135deg, #0059C4 0%, #00449A 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(0, 89, 196, 0.3);\n font-family: inherit;\n }\n\n .neoface-forgot-btn-primary:hover:not(:disabled) {\n transform: translateY(-2px);\n box-shadow: 0 8px 24px rgba(0, 89, 196, 0.4);\n }\n\n .neoface-forgot-btn-primary:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n }\n\n .neoface-forgot-btn-ghost {\n background: transparent;\n border: none;\n color: rgba(255, 255, 255, 0.5);\n font-size: 14px;\n font-weight: 500;\n cursor: pointer;\n padding: 10px 16px;\n border-radius: 8px;\n transition: all 0.2s;\n font-family: inherit;\n width: 100%;\n }\n\n .neoface-forgot-btn-ghost:hover {\n color: white;\n background: rgba(255, 255, 255, 0.05);\n }\n\n .neoface-forgot-branding {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n margin-top: 20px;\n color: rgba(255, 255, 255, 0.3);\n font-size: 12px;\n }\n\n .neoface-forgot-brand-logo {\n width: 18px;\n height: 18px;\n object-fit: contain;\n opacity: 0.5;\n }\n\n .neoface-forgot-brand-name {\n font-weight: 700;\n letter-spacing: 0.05em;\n }\n\n @media (max-width: 640px) {\n .neoface-forgot-content {\n padding: 24px;\n border-radius: 16px;\n }\n\n .neoface-forgot-title {\n font-size: 20px;\n }\n }\n ")}}const bd=(e,n)=>{switch(n.type){case"START_LIVENESS":return{status:"liveness",step:n.stepSequence[0],capturedPhotos:[],stepSequence:n.stepSequence,currentStepIndex:0,stepProgress:0};case"NEXT_STEP":if("liveness"===e.status){const t=n.photo?[...e.capturedPhotos,n.photo]:e.capturedPhotos;return{status:"liveness",step:n.step,capturedPhotos:t,stepSequence:e.stepSequence,currentStepIndex:e.currentStepIndex+1,stepProgress:0}}return e;case"UPDATE_PROGRESS":return"liveness"===e.status?{...e,stepProgress:n.progress}:e;case"CAMERA_LOADING":return{status:"camera-loading"};case"SUCCESS":return{status:"success"};case"DUPLICATE":return{status:"duplicate",personName:n.personName};case"ERROR":return{status:"error",message:n.message,retryable:n.retryable??!0};case"RESET":return yd();default:return e}},xd={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..."},yd=()=>{const e=(()=>{const e=["up","down","left","right"];for(let n=e.length-1;n>0;n--){const t=Math.floor(Math.random()*(n+1));[e[n],e[t]]=[e[t],e[n]]}return["center",...e,"complete"]})();return{status:"liveness",step:e[0],capturedPhotos:[],stepSequence:e,currentStepIndex:0,stepProgress:0}},_d=8,kd=10,Ed=26,Td=8,Nd=-8,Sd=15,Cd=-15,Id=1500,Rd=150,Od=.35,jd=.65,Ad=.18,Pd=.22,Fd=2e4;function zd({personData:e,applicationToken:t,onClose:r,onSuccess:a,onPhotosCaptured:i,onError:s,onCannotGesture:c,autoLighting:l=!0}){const d=n.useRef(null),u=n.useRef(null),p=n.useRef(null),f=n.useRef(null),h=n.useRef(null),m=n.useRef(!1),g=n.useRef("center"),v=n.useRef(null),w=n.useRef(null),b=n.useRef(!1),x=n.useRef(null),[y,_]=n.useReducer(bd,void 0,yd),[k,E]=n.useState(!1),[T,N]=n.useState("ok"),[S,C]=n.useState(!1);n.useEffect((()=>{al()}),[]);const I=l&&("liveness"===y.status||"camera-loading"===y.status),{flashOn:R}=td(d,{enabled:I});n.useEffect((()=>{if("liveness"===y.status){const e=y.step;g.current!==e&&(g.current=e,m.current||(f.current&&(f.current=null),h.current&&(clearInterval(h.current),h.current=null),_({type:"UPDATE_PROGRESS",progress:0}))),x.current={stepSequence:y.stepSequence,currentStepIndex:y.currentStepIndex,capturedPhotos:y.capturedPhotos},w.current&&clearTimeout(w.current),"complete"!==y.step&&(w.current=window.setTimeout((()=>{_({type:"ERROR",message:"Tempo limite atingido para o movimento. Por favor, tente novamente em um ambiente bem iluminado.",retryable:!0})}),Fd))}}),[y.status,"liveness"===y.status&&y.step,"liveness"===y.status&&y.currentStepIndex]);const O=e=>{if(m.current||"complete"===g.current)return;const n=Date.now();e?f.current||(f.current=n,h.current&&clearInterval(h.current),h.current=window.setInterval((()=>{if(!f.current)return;const e=Date.now()-f.current,n=Math.min(e/Id*100,100);_({type:"UPDATE_PROGRESS",progress:n}),n>=100&&(clearInterval(h.current),h.current=null,j())}),50)):f.current&&(f.current=null,h.current&&(clearInterval(h.current),h.current=null),_({type:"UPDATE_PROGRESS",progress:0}))};n.useEffect((()=>{(async()=>{try{const e="/models",n=new Promise(((e,n)=>setTimeout((()=>n(new Error("Timeout ao carregar modelos"))),1e4)));await Promise.race([Promise.all([Et.tinyFaceDetector.loadFromUri(e),Et.faceLandmark68Net.loadFromUri(e)]),n])}catch(e){_({type:"ERROR",message:"Não foi possível carregar os modelos de IA. Verifique sua conexão e tente novamente.",retryable:!0})}})()}),[]),n.useEffect((()=>()=>{p.current&&(p.current.getTracks().forEach((e=>{e.stop()})),p.current=null),d.current&&(d.current.srcObject=null),v.current&&(clearTimeout(v.current),v.current=null),h.current&&(clearInterval(h.current),h.current=null),w.current&&(clearTimeout(w.current),w.current=null)}),[]),n.useEffect((()=>{let e=!0;return(async()=>{if("liveness"===y.status&&!p.current){b.current=!1,v.current&&(clearTimeout(v.current),v.current=null),v.current=window.setTimeout((()=>{e&&!1===b.current&&_({type:"ERROR",message:"A câmera não respondeu a tempo. Verifique se ela está disponível e tente novamente.",retryable:!0})}),2e4);try{const n=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"}});if(!e)return void n.getTracks().forEach((e=>e.stop()));const t=async()=>{let e=0;for(;!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,p.current=n,o.onloadedmetadata=()=>{o.play().then((()=>{e&&C(!0)}))}}catch(n){if(!e)return;v.current&&(clearTimeout(v.current),v.current=null);let t=n instanceof Error?n.message:"Erro ao acessar câmera";n instanceof DOMException&&("NotAllowedError"===n.name||"PermissionDeniedError"===n.name?t="Permissão de câmera negada. Permita o acesso à câmera nas configurações do navegador e tente novamente.":"NotFoundError"===n.name||"DevicesNotFoundError"===n.name?t="Nenhuma câmera encontrada. Conecte uma câmera e tente novamente.":"NotReadableError"===n.name&&(t="A câmera está sendo usada por outro programa. Feche-o e tente novamente.")),_({type:"ERROR",message:t,retryable:!0})}}})(),()=>{e=!1,v.current&&(clearTimeout(v.current),v.current=null),p.current&&(p.current.getTracks().forEach((e=>e.stop())),p.current=null),h.current&&(clearInterval(h.current),h.current=null),f.current=null}}),[y.status]),n.useEffect((()=>{if("liveness"!==y.status||!d.current)return;let e=!0,n=0;const t=async()=>{if(!e||"liveness"!==y.status)return;if(m.current||"complete"===g.current)return void requestAnimationFrame(t);const o=Date.now();if(o-n<Rd)requestAnimationFrame(t);else{n=o;try{const n=await Jt(d.current,new vt({inputSize:224,scoreThreshold:.35})).withFaceLandmarks();if(!e)return;const o=!!n;if(E(o),o&&n.detection){const e=(e=>{if(!e||!d.current)return"not-detected";const{box:n}=e.detection,t=d.current.videoWidth||640,o=d.current.videoHeight||480,r=n.width/t;if(r<Od)return"too-far";if(r>jd)return"too-close";const a=n.x+n.width/2,i=n.y+n.height/2,s=Math.abs(a-t/2)/t,c=Math.abs(i-o/2)/o;return s>Ad||c>Pd?"not-centered":"ok"})(n);if("not-detected"!==e&&N(e),"ok"!==e)return O(!1),void requestAnimationFrame(t)}if(o&&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),r=t(8),a=t(36),i=t(45),s=(a.x+i.x)/2,c=(o.x-s)/Math.abs(i.x-a.x)*90,l=(a.y+i.y)/2,d=o.y-l,u=-d/Math.abs(r.y-l)*90+Ed;return{pitch:Math.round(u),yaw:Math.round(c)}}catch(n){return null}})(n.landmarks);if(e){const n=((e,n,t)=>{switch(t){case"center":return Math.abs(e)<_d&&Math.abs(n)<kd;case"up":return e>Td;case"down":return e<Nd;case"left":return n>Sd;case"right":return n<Cd;default:return!1}})(e.pitch,e.yaw,g.current);O(n)}}else f.current&&(f.current=null,h.current&&(clearInterval(h.current),h.current=null),_({type:"UPDATE_PROGRESS",progress:0}))}catch(r){}e&&"liveness"===y.status&&requestAnimationFrame(t)}},o=()=>{e&&d.current&&(b.current=!0,v.current&&(clearTimeout(v.current),v.current=null),t())},r=d.current;if(r&&r.readyState>=2){const n=setTimeout(o,200);return()=>{e=!1,clearTimeout(n),h.current&&(clearInterval(h.current),h.current=null),f.current=null}}const a=()=>{e&&o()};let i=0;const s=window.setInterval((()=>{i++,e?d.current&&d.current.readyState>=2?(clearInterval(s),d.current.removeEventListener("canplay",a),o()):i>=50&&clearInterval(s):clearInterval(s)}),300);return null==r||r.addEventListener("canplay",a,{once:!0}),()=>{e=!1,clearInterval(s),null==r||r.removeEventListener("canplay",a),h.current&&(clearInterval(h.current),h.current=null),f.current=null}}),[y.status]);const j=async()=>{if(!d.current||!u.current||m.current)return;m.current=!0,f.current=null;const e=x.current;if(!e)return void(m.current=!1);const n=u.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(m.current=!1);const t=e.currentStepIndex+1,o=e.stepSequence[t];if("complete"===o){const t=[...e.capturedPhotos,n];_({type:"START_PROCESSING"}),A(t)}else setTimeout((()=>{m.current=!1,_({type:"NEXT_STEP",step:o,photo:n})}),100)}),"image/jpeg",.85)):m.current=!1},A=async n=>{var o;try{if(_({type:"START_PROCESSING"}),t&&n.length>0)try{const{identifyPersonAsync:e}=await Promise.resolve().then((()=>ed)),r=new Promise((e=>setTimeout((()=>e(null)),5e3))),a=await Promise.race([e(n[0],t,{maxRetries:3,interval:1e3}),r]);if(a&&a.personFound)return void _({type:"DUPLICATE",personName:(null==(o=a.person)?void 0:o.name)||"Pessoa identificada"})}catch(r){}if(i)return _({type:"SUCCESS"}),i(n),void(n.length=0);if(!e||!t)throw new Error("Dados de registro não fornecidos");const s=await Dl(e,n,t),c={success:s.success,message:s.message,person_id:s.person_id,user_id:s.user_id,person_validated:s.person_validated,face_processing:s.face_processing,onboarding_link:s.onboarding_link};_({type:"SUCCESS"}),a&&(a(c),n.length=0)}catch(c){const e=c instanceof Error?c.message:"Erro desconhecido";_({type:"ERROR",message:e}),s(e)}};return o.jsxs(o.Fragment,{children:[o.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, #0A1320 0%, #111C2B 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: #0059C4;\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, #0059C4 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: #0E9F6E;\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, #0059C4 0%, #00449A 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(0, 89, 196, 0.3);\n }\n\n .primary-button:hover {\n transform: translateY(-2px);\n box-shadow: 0 8px 24px rgba(0, 89, 196, 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: inherit;\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 /* Removida transição 'all' para evitar salto de zoom no início */\n box-shadow: 0 0 0 4px rgba(0, 89, 196, 0.3);\n background: #000;\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 opacity: 0;\n transition: opacity 0.4s ease;\n }\n\n .video-feed.ready {\n opacity: 1;\n }\n\n .face-badge {\n display: none; /* Removido por ser redundante com o oval verde */\n }\n\n .status-badge {\n position: absolute;\n top: 72px; /* Logo abaixo do progress-indicator */\n left: 50%;\n transform: translateX(-50%);\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(0, 0, 0, 0.2);\n animation: slideDown 0.3s ease-out;\n z-index: 10;\n white-space: nowrap;\n }\n\n .status-badge.info {\n background: rgba(255, 255, 255, 0.15);\n color: white;\n border-color: rgba(255, 255, 255, 0.1);\n }\n\n .status-badge.warning {\n background: rgba(251, 191, 36, 0.95);\n color: #78350f;\n border-color: rgba(0, 0, 0, 0.1);\n box-shadow: 0 4px 15px rgba(251, 191, 36, 0.2);\n }\n\n .status-badge.error {\n background: rgba(239, 68, 68, 0.95);\n color: white;\n border-color: rgba(255, 255, 255, 0.2);\n box-shadow: 0 4px 15px rgba(239, 68, 68, 0.2);\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, #0059C4 0%, #0E9F6E 100%);\n border-radius: 2px;\n transition: width 0.05s linear;\n }\n\n /* NEO-410 · US14.3 — botão \"Não consigo fazer esse movimento\" */\n .cannot-gesture-button {\n margin-top: 16px;\n min-height: 44px;\n min-width: 44px;\n padding: 10px 20px;\n background: transparent;\n border: 1px solid rgba(255, 255, 255, 0.28);\n border-radius: 22px;\n color: rgba(255, 255, 255, 0.85);\n font-size: 14px;\n font-weight: 500;\n font-family: inherit;\n cursor: pointer;\n transition: background 120ms ease-out, border-color 120ms ease-out;\n }\n .cannot-gesture-button:hover {\n background: rgba(255, 255, 255, 0.08);\n border-color: rgba(255, 255, 255, 0.42);\n }\n .cannot-gesture-button:focus-visible {\n outline: 2px solid #0059C4;\n outline-offset: 2px;\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(0, 89, 196, 0.2);\n border-top-color: #0059C4;\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(0, 89, 196, 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: #0E9F6E;\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 /* Duplicate Screen Styles */\n .profile-icon-wrapper {\n position: relative;\n display: inline-block;\n margin-bottom: 24px;\n }\n\n .profile-main-icon {\n background: rgba(0, 89, 196, 0.1);\n color: #0059C4;\n padding: 20px;\n border-radius: 50%;\n border: 2px solid rgba(0, 89, 196, 0.2);\n box-shadow: 0 0 30px rgba(0, 89, 196, 0.2);\n }\n\n .profile-main-icon svg {\n width: 48px;\n height: 48px;\n }\n\n .verified-badge {\n position: absolute;\n bottom: -4px;\n right: -4px;\n background: #0E9F6E;\n border-radius: 50%;\n padding: 4px;\n border: 3px solid #111C2B;\n width: 24px;\n height: 24px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .button-group-vertical {\n display: flex;\n flex-direction: column;\n width: 100%;\n gap: 8px;\n }\n\n .support-section {\n margin-top: 24px;\n padding-top: 16px;\n border-top: 1px solid rgba(255, 255, 255, 0.05);\n }\n\n .support-section p {\n font-size: 13px;\n color: rgba(255, 255, 255, 0.4);\n margin-bottom: 8px;\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 "}),o.jsx(od,{active:R}),o.jsx("div",{className:"neofaceid-root modal-overlay",children:o.jsxs("div",{className:"modal-content",children:[o.jsx("button",{type:"button",className:"close-button",onClick:r,children:"×"}),"liveness"===y.status&&(()=>{if("liveness"!==y.status)return null;const e=`${y.currentStepIndex+1}/${y.stepSequence.length-1}`,{stepProgress:n}=y;return o.jsxs("div",{className:"liveness-container",children:[o.jsx("div",{className:"progress-indicator",children:o.jsx("span",{className:"progress-text",children:e})}),k&&"ok"!==T&&o.jsxs("div",{className:"status-badge "+("not-centered"===T?"warning":"error"),children:["too-far"===T&&"Aproxime-se mais","too-close"===T&&"Afaste-se um pouco","not-centered"===T&&"Centralize seu rosto"]}),o.jsx("div",{className:"video-wrapper",children:o.jsx("div",{className:`video-circle ${k&&"ok"===T?"face-detected":""} ${n>0?"capturing":""}`,children:o.jsx("video",{ref:d,className:"video-feed "+(S?"ready":""),autoPlay:!0,muted:!0,playsInline:!0})})}),o.jsxs("div",{className:"instruction-box",children:[o.jsx("p",{className:"instruction-text","aria-live":"assertive",children:xd[y.step]}),n>0&&o.jsx("div",{className:"progress-bar",children:o.jsx("div",{className:"progress-fill",style:{width:`${n}%`}})})]}),o.jsx("button",{type:"button",className:"cannot-gesture-button",onClick:()=>{c?c():r()},"aria-label":"Não consigo fazer esse movimento — buscar alternativa",children:"Não consigo fazer esse movimento"}),o.jsx("div",{className:"branding-small",children:o.jsx(gd,{})})]})})(),"camera-loading"===y.status&&o.jsxs("div",{className:"processing-container",children:[o.jsxs("div",{className:"spinner-wrapper",children:[o.jsx("div",{className:"spinner"}),o.jsx("div",{className:"spinner-ring"})]}),o.jsx("h3",{children:"Inicializando câmera"}),o.jsx("p",{children:"Aguarde enquanto preparamos a câmera..."}),o.jsx("div",{className:"branding",style:{marginTop:"40px",paddingTop:"24px",borderTop:"1px solid rgba(255, 255, 255, 0.1)"},children:o.jsx(gd,{})})]}),"processing"===y.status&&o.jsxs("div",{className:"processing-container",children:[o.jsxs("div",{className:"spinner-wrapper",children:[o.jsx("div",{className:"spinner"}),o.jsx("div",{className:"spinner-ring"})]}),o.jsx("h3",{children:"Processando biometria"}),o.jsx("p",{children:"Analisando suas capturas faciais..."}),o.jsx("div",{className:"branding",style:{marginTop:"40px",paddingTop:"24px",borderTop:"1px solid rgba(255, 255, 255, 0.1)"},children:o.jsx(gd,{})})]}),"error"===y.status&&("error"!==y.status?null:o.jsxs("div",{className:"result-container error",children:[o.jsx("div",{className:"result-icon error-icon",children:o.jsxs("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",children:[o.jsx("circle",{cx:"30",cy:"30",r:"28",stroke:"currentColor",strokeWidth:"3"}),o.jsx("path",{d:"M20 20 L40 40 M40 20 L20 40",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}),o.jsx("h3",{children:"Não foi possível processar"}),o.jsx("p",{children:y.message}),o.jsxs("div",{className:"button-group",children:[y.retryable&&o.jsx("button",{type:"button",className:"secondary-button",onClick:()=>_({type:"RESET"}),children:"Tentar Novamente"}),o.jsx("button",{type:"button",className:"ghost-button",onClick:r,children:"Cancelar"})]})]})),"success"===y.status&&o.jsxs("div",{className:"result-container success",children:[o.jsx("div",{className:"result-icon success-icon",children:o.jsxs("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",children:[o.jsx("circle",{cx:"30",cy:"30",r:"28",stroke:"currentColor",strokeWidth:"3"}),o.jsx("path",{d:"M15 30 L25 40 L45 20",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"})]})}),o.jsx("h3",{children:i?"Captura concluída!":"Verificação concluída!"}),o.jsx("p",{children:i?"Suas capturas faciais foram realizadas":"Sua biometria foi registrada com sucesso"}),o.jsx("button",{type:"button",className:"primary-button",onClick:r,children:"Continuar"})]}),"duplicate"===y.status&&(()=>{if("duplicate"!==y.status)return null;const e=y.personName&&"Pessoa identificada"!==y.personName?`Olá, ${y.personName.split(" ")[0]}!`:"Olá!";return o.jsxs("div",{className:"result-container duplicate scale-in",children:[o.jsx("h3",{style:{marginTop:"0px"},children:e}),o.jsx("p",{style:{marginBottom:"32px",fontSize:"15px"},children:"Identificamos seu cadastro biométrico em nossa rede. Você já faz parte da NeoFaceId!"}),o.jsxs("div",{className:"button-group-vertical",children:[o.jsx("button",{type:"button",className:"primary-button",onClick:()=>{r(),window.location.href="/"},children:"Ir para o Login"}),o.jsx("button",{type:"button",className:"secondary-button",style:{marginTop:"12px"},onClick:()=>{r(),new wd(t??"").open()},children:"Esqueci minha senha"}),o.jsxs("div",{className:"support-section",children:[o.jsx("p",{children:"Não reconhece esta conta?"}),o.jsx("button",{type:"button",className:"ghost-button",onClick:()=>window.open("https://support.neofaceid.com","_blank"),children:"Falar com Suporte"})]})]}),o.jsx("div",{className:"branding",style:{marginTop:"32px",paddingTop:"20px",borderTop:"1px solid rgba(255, 255, 255, 0.08)",width:"100%"},children:o.jsx(gd,{})})]})})()]})}),o.jsx("canvas",{ref:u})]})}const $d="2.1.3",Dd="neoface_consent_trail_v1";function Md(){try{if("undefined"==typeof window||!window.localStorage)return[];const e=window.localStorage.getItem(Dd);if(!e)return[];const n=JSON.parse(e);return Array.isArray(n)?n:[]}catch{return[]}}async function Ld(e){try{const n=bl(),t=(null==e?void 0:e.purpose)??n.purpose??"authentication",o=(null==e?void 0:e.legalBasis)??n.legalBasis??"fraud_prevention",r=(new Date).toISOString(),a="undefined"!=typeof navigator?navigator.userAgent:"",i=$d,s={hash:await async function(e){try{if("undefined"!=typeof crypto&&crypto.subtle&&"function"==typeof crypto.subtle.digest){const n=new TextEncoder,t=await crypto.subtle.digest("SHA-256",n.encode(e));return Array.from(new Uint8Array(t)).map((e=>e.toString(16).padStart(2,"0"))).join("")}}catch{}return"sha256-unavailable"}(`${a}${t}${r}`),timestamp:r,purpose:t,legalBasis:o,sdkVersion:i},c=Md();c.push(s);const l=c.slice(-100);return"undefined"!=typeof window&&window.localStorage&&window.localStorage.setItem(Dd,JSON.stringify(l)),s}catch{return null}}const Bd="https://neofaceid.com/privacidade",Wd={verification:{title:"Vamos confirmar que é você",duration:"Leva cerca de 20 segundos e usa a câmera do seu dispositivo.",bullet1Title:"Sua câmera liga agora",bullet1Body:"Você vê a imagem o tempo todo e pode encerrar quando quiser.",bullet2Title:"Pediremos dois movimentos simples",bullet2Body:"Virar o rosto ou piscar — é assim que sabemos que há alguém ali.",primary:"Começar verificação"},registration:{title:"Vamos cadastrar seu rosto",duration:"Leva cerca de 20 segundos e usa a câmera do seu dispositivo.",bullet1Title:"Sua câmera liga agora",bullet1Body:"Você vê a imagem o tempo todo e pode encerrar quando quiser.",bullet2Title:"Pediremos dois movimentos simples",bullet2Body:"Virar o rosto ou piscar — é assim que sabemos que há alguém ali.",primary:"Começar cadastro"}},qd=e=>1===e?"dia":"dias";const Ud=()=>o.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3Z"}),o.jsx("circle",{cx:"12",cy:"13",r:"4"})]}),Vd=()=>o.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("circle",{cx:"12",cy:"12",r:"9"}),o.jsx("path",{d:"M4 12h16"}),o.jsx("path",{d:"M15 8l4 4-4 4"})]}),Kd=()=>o.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("path",{d:"M12 2 4 5v7c0 5 3.5 8.5 8 10 4.5-1.5 8-5 8-10V5l-8-3Z"}),o.jsx("path",{d:"m9 12 2 2 4-4"})]});function Zd({appName:e,flow:n,privacyPolicyUrl:t=Bd,retentionDays:r=90,onAccept:a,onDecline:i}){const s=Wd[n],c=function(e,n){const t=Number.isFinite(n)&&n>0;return"registration"===e?{title:"Guardamos um vetor matemático do seu rosto",body:t?`Não a foto. A imagem fica guardada por até ${n} ${qd(n)} e é apagada no fim desse prazo.`:"Não a foto. O prazo de guarda da imagem está na política de privacidade."}:t?{title:`A imagem fica guardada por até ${n} ${qd(n)}`,body:"Ela é usada para a verificação e apagada no fim desse prazo."}:{title:"A imagem é tratada conforme a política de privacidade",body:"Ela é usada para a verificação; o prazo de guarda está descrito lá."}}(n,r),l=Number.isFinite(r)&&r>0;return o.jsxs(o.Fragment,{children:[o.jsx("style",{children:"\n @keyframes neofaceidConsentFadeIn { from { opacity: 0 } to { opacity: 1 } }\n @keyframes neofaceidConsentSlideUp {\n from { opacity: 0; transform: translateY(12px) }\n to { opacity: 1; transform: translateY(0) }\n }\n .neofaceid-consent-overlay {\n position: fixed; inset: 0;\n background: var(--nfid-overlay);\n backdrop-filter: blur(3px);\n -webkit-backdrop-filter: blur(3px);\n display: flex; align-items: center; justify-content: center;\n z-index: 10001; padding: 20px;\n animation: neofaceidConsentFadeIn 200ms ease-out;\n font-family: inherit;\n color: var(--nfid-text);\n }\n .neofaceid-consent-modal {\n background: var(--nfid-surface);\n border-radius: var(--nfid-radius, 16px);\n padding: 28px;\n max-width: 440px;\n width: 100%;\n box-shadow: 0 1px 3px rgba(10, 19, 32, 0.08);\n animation: neofaceidConsentSlideUp 320ms cubic-bezier(.2,0,0,1);\n box-sizing: border-box;\n }\n .neofaceid-consent-header {\n display: flex;\n align-items: baseline;\n gap: 10px;\n margin-bottom: 20px;\n }\n .neofaceid-consent-appname {\n font-size: 17px;\n font-weight: 700;\n color: var(--nfid-text);\n line-height: 1.2;\n }\n .neofaceid-consent-brand-caption {\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.09em;\n text-transform: uppercase;\n color: var(--nfid-text-subtle);\n }\n .neofaceid-consent-title {\n font-size: 22px;\n font-weight: 700;\n color: var(--nfid-text);\n margin: 0 0 8px;\n line-height: 1.25;\n letter-spacing: -0.015em;\n }\n .neofaceid-consent-duration {\n font-size: 14px;\n color: var(--nfid-text-muted);\n margin: 0 0 20px;\n line-height: 1.5;\n }\n .neofaceid-consent-bullets {\n display: flex;\n flex-direction: column;\n gap: 14px;\n margin-bottom: 20px;\n }\n .neofaceid-consent-bullet {\n display: flex;\n gap: 12px;\n align-items: flex-start;\n }\n .neofaceid-consent-bullet-icon {\n flex-shrink: 0;\n color: var(--nfid-action);\n margin-top: 2px;\n }\n .neofaceid-consent-bullet-title {\n font-size: 14px;\n font-weight: 600;\n color: var(--nfid-text);\n margin: 0 0 2px;\n line-height: 1.35;\n }\n .neofaceid-consent-bullet-body {\n font-size: 13px;\n color: var(--nfid-text-muted);\n margin: 0;\n line-height: 1.45;\n }\n .neofaceid-consent-link {\n display: inline-block;\n font-size: 13px;\n color: var(--nfid-action);\n text-decoration: underline;\n margin-bottom: 20px;\n }\n .neofaceid-consent-link:hover { opacity: 0.85; }\n .neofaceid-consent-actions {\n display: flex;\n flex-direction: column;\n gap: 10px;\n }\n .neofaceid-consent-button {\n min-height: 44px;\n padding: 12px 20px;\n border-radius: var(--nfid-radius, 16px);\n border: none;\n font-size: 15px;\n font-weight: 600;\n cursor: pointer;\n transition: background 120ms ease-out, transform 120ms ease-out;\n font-family: inherit;\n }\n .neofaceid-consent-button-primary {\n background: var(--nfid-action);\n color: var(--nfid-action-text);\n }\n .neofaceid-consent-button-primary:hover { opacity: 0.92; }\n .neofaceid-consent-button-primary:focus-visible {\n outline: 2px solid var(--nfid-focus-ring);\n outline-offset: 2px;\n }\n .neofaceid-consent-button-ghost {\n background: transparent;\n color: var(--nfid-text-muted);\n }\n .neofaceid-consent-button-ghost:hover { background: var(--nfid-surface-muted); }\n .neofaceid-consent-footer {\n display: flex;\n justify-content: center;\n margin-top: 20px;\n padding-top: 16px;\n border-top: 1px solid var(--nfid-line);\n }\n .neofaceid-consent-seal {\n font-size: 10px;\n font-weight: 500;\n letter-spacing: 0.06em;\n text-transform: uppercase;\n color: var(--nfid-text-subtle);\n }\n @media (max-width: 640px) {\n .neofaceid-consent-modal { padding: 22px; border-radius: 16px; }\n .neofaceid-consent-title { font-size: 20px; }\n }\n @media (prefers-reduced-motion: reduce) {\n .neofaceid-consent-overlay,\n .neofaceid-consent-modal { animation: none; }\n }\n "}),o.jsx("div",{className:"neofaceid-root neofaceid-consent-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"neofaceid-consent-title",children:o.jsxs("div",{className:"neofaceid-consent-modal",children:[o.jsxs("div",{className:"neofaceid-consent-header",children:[o.jsx("span",{className:"neofaceid-consent-appname",children:e}),o.jsx("span",{className:"neofaceid-consent-brand-caption",children:"NeoFaceID"})]}),o.jsx("h1",{id:"neofaceid-consent-title",className:"neofaceid-consent-title",children:s.title}),o.jsx("p",{className:"neofaceid-consent-duration",children:s.duration}),o.jsxs("div",{className:"neofaceid-consent-bullets",children:[o.jsxs("div",{className:"neofaceid-consent-bullet",children:[o.jsx("div",{className:"neofaceid-consent-bullet-icon",children:o.jsx(Ud,{})}),o.jsxs("div",{children:[o.jsx("p",{className:"neofaceid-consent-bullet-title",children:s.bullet1Title}),o.jsx("p",{className:"neofaceid-consent-bullet-body",children:s.bullet1Body})]})]}),o.jsxs("div",{className:"neofaceid-consent-bullet",children:[o.jsx("div",{className:"neofaceid-consent-bullet-icon",children:o.jsx(Vd,{})}),o.jsxs("div",{children:[o.jsx("p",{className:"neofaceid-consent-bullet-title",children:s.bullet2Title}),o.jsx("p",{className:"neofaceid-consent-bullet-body",children:s.bullet2Body})]})]}),o.jsxs("div",{className:"neofaceid-consent-bullet",children:[o.jsx("div",{className:"neofaceid-consent-bullet-icon",children:o.jsx(Kd,{})}),o.jsxs("div",{children:[o.jsx("p",{className:"neofaceid-consent-bullet-title",children:c.title}),o.jsx("p",{className:"neofaceid-consent-bullet-body",children:c.body})]})]})]}),o.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"neofaceid-consent-link",children:l?`Ver política de privacidade (retenção de até ${r} ${qd(r)})`:"Ver política de privacidade"}),o.jsxs("div",{className:"neofaceid-consent-actions",children:[o.jsx("button",{type:"button",className:"neofaceid-consent-button neofaceid-consent-button-primary",onClick:()=>{Ld().catch((()=>{})),a()},children:s.primary}),o.jsx("button",{type:"button",className:"neofaceid-consent-button neofaceid-consent-button-ghost",onClick:i,children:"Agora não"})]}),o.jsx("div",{className:"neofaceid-consent-footer",children:o.jsx(gd,{})})]})})]})}class Hd{constructor(){l(this,"container",null),l(this,"root",null)}show(e){this.container||(al(),this.container=document.createElement("div"),this.container.id="neofaceid-consent-modal-container",document.body.appendChild(this.container),this.root=t.createRoot(this.container),this.root.render(o.jsx(Zd,{...e,onAccept:()=>{this.close(),e.onAccept()},onDecline:()=>{this.close(),e.onDecline()}})))}close(){this.container&&document.body.contains(this.container)&&(this.root&&this.root.unmount(),document.body.removeChild(this.container),this.container=null,this.root=null)}}function Gd(e={}){const n=gl(),t=e.appName??n??"sua aplicação";e.appName;const o=e.flow??"verification";return new Promise((n=>{(new Hd).show({appName:t,flow:o,privacyPolicyUrl:e.privacyPolicyUrl??Bd,retentionDays:e.retentionDays??90,onAccept:()=>n(!0),onDecline:()=>n(!1)})}))}const Jd={flow:"verification",privacyPolicyUrl:Bd,retentionDays:90};function Xd({open:e,onDismiss:t,dismissOnOverlay:r=!0,ariaLabel:a,ariaLabelledBy:i,children:s,className:c,style:l}){if(n.useEffect((()=>{al()}),[]),!e)return null;return o.jsx("div",{className:"neofaceid-root",role:"presentation",style:{position:"fixed",inset:0,zIndex:10001,display:"flex",alignItems:"center",justifyContent:"center",padding:20,background:`var(${nl})`,backdropFilter:"blur(3px)",WebkitBackdropFilter:"blur(3px)"},onClick:()=>{r&&t&&t()},children:o.jsx("div",{role:"dialog","aria-modal":"true","aria-label":a,"aria-labelledby":i,className:c,onClick:e=>e.stopPropagation(),style:{background:`var(${Kc})`,color:`var(${Gc})`,borderRadius:`var(${ol}, 16px)`,padding:28,maxWidth:440,width:"100%",boxShadow:"0 1px 3px rgba(10,19,32,.08)",boxSizing:"border-box",...l},children:s})})}const Yd=new Set(["connected","heartbeat","processing"]),Qd=31e4,eu=5;function nu(e,n){return new Promise((t=>{const o=setTimeout(t,e);null==n||n.addEventListener("abort",(()=>{clearTimeout(o),t()}),{once:!0})}))}async function tu(e){const{requestTicket:n,buildUrl:t,classify:o,timeoutMs:r=Qd,maxReconnects:a=eu,signal:i,eventSourceFactory:s,onProgress:c}=e,l=s??(e=>{const n=globalThis.EventSource;if(!n)throw new io("EventSource indisponível neste ambiente",ao.INITIALIZATION_ERROR);return new n(e)}),d=Date.now();let u=0;for(;;){if(null==i?void 0:i.aborted)throw new io("Fluxo cancelado",ao.UNKNOWN);const e=r-(Date.now()-d);if(e<=0)throw new io("Tempo esgotado aguardando resposta",ao.NETWORK);const s=await n(),p=await new Promise(((n,r)=>{let a;try{a=l(t(s))}catch(h){return void r(h)}let d,u,p=!1;const f=()=>{void 0!==d&&clearTimeout(d),u&&(null==i||i.removeEventListener("abort",u)),a.close()};d=setTimeout((()=>{p||(p=!0,f(),r(new io("Tempo esgotado aguardando resposta",ao.NETWORK)))}),e),u=()=>{p||(p=!0,f(),r(new io("Fluxo cancelado",ao.UNKNOWN)))},null==i||i.addEventListener("abort",u,{once:!0}),a.onmessage=e=>{if(p)return;let t;try{t=JSON.parse(e.data)}catch{return}if(t.status&&Yd.has(t.status))return void(c&&c(t));const r=o(t);"pending"!==r.kind?(p=!0,f(),n({type:"settled",verdict:r})):c&&c(t)},a.onerror=()=>{p||(p=!0,f(),n({type:"transport"}))}}));if("settled"===p.type){const{verdict:e}=p;if("resolve"===e.kind)return e.value;throw e.error}if(u+=1,u>a)throw new io(`Conexão perdida após ${a} tentativas de reconexão`,ao.NETWORK);const f=Math.min(500*2**(u-1),8e3);await nu(f,i)}}const ou={minHeight:44,minWidth:44,padding:"12px 20px",borderRadius:16,border:"none",fontSize:15,fontWeight:600,fontFamily:"inherit",cursor:"pointer",transition:"background 120ms ease-out",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:8},ru=n.forwardRef((({variant:e="primary",style:n,type:t="button",...r},a)=>{const i="primary"===e?{background:`var(${Yc})`,color:`var(${Qc})`}:"secondary"===e?{background:`var(${Zc})`,color:`var(${Gc})`}:{background:"transparent",color:`var(${Jc})`};return o.jsx("button",{ref:a,type:t,...r,style:{...ou,...i,...n}})}));function au({tone:e,children:n,icon:t,className:r}){const a=Mc[e];return o.jsxs("span",{className:r,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"4px 10px",borderRadius:9999,background:a.bg,color:a.fg,fontSize:13,fontWeight:600,fontFamily:"inherit",lineHeight:1.3},children:[t,n]})}ru.displayName="Button";const iu="neofaceid-awaiting-push-styles",su="\n.neofaceid-root .nfid-push {\n display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;\n padding: 8px 8px 4px;\n}\n.neofaceid-root .nfid-push h2 {\n margin: 6px 0 0; font-size: 20px; font-weight: 700; color: var(--nfid-text); line-height: 1.25;\n letter-spacing: -0.015em;\n}\n.neofaceid-root .nfid-push p {\n margin: 0; font-size: 14px; color: var(--nfid-text-muted); line-height: 1.5;\n}\n.neofaceid-root .nfid-push-phone-icon {\n width: 56px; height: 56px; color: var(--nfid-action);\n}\n.neofaceid-root .nfid-push-code {\n display: flex; flex-direction: column; align-items: center; gap: 6px;\n margin-top: 14px; padding: 16px 28px;\n background: var(--nfid-surface-muted); border-radius: 16px; width: 100%;\n}\n.neofaceid-root .nfid-push-code-label {\n font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;\n color: var(--nfid-text-subtle);\n}\n.neofaceid-root .nfid-push-code-value {\n font-size: 52px; font-weight: 800; line-height: 1; letter-spacing: 0.08em;\n color: var(--nfid-text); font-variant-numeric: tabular-nums;\n}\n.neofaceid-root .nfid-push-countdown {\n font-size: 13px; color: var(--nfid-text-muted); font-variant-numeric: tabular-nums;\n margin-top: 12px;\n}\n.neofaceid-root .nfid-push-actions {\n display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 16px;\n}\n.neofaceid-root .nfid-push-footer {\n display: flex; justify-content: center; margin-top: 16px; padding-top: 12px;\n border-top: 1px solid var(--nfid-line);\n width: 100%;\n}\n.neofaceid-root .nfid-push-pulse {\n animation: nfidPushPulse 1.8s ease-in-out infinite;\n}\n@keyframes nfidPushPulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.45; }\n}\n@media (prefers-reduced-motion: reduce) {\n .neofaceid-root .nfid-push-pulse { animation: none; }\n}\n";function cu(e){const n=Math.max(0,e);return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function lu({appName:e,numericCode:t,remainingSeconds:r,onCancel:a}){return n.useEffect((()=>{al(),il(iu,su)}),[]),o.jsxs("div",{className:"nfid-push",role:"status","aria-live":"polite",children:[o.jsx(au,{tone:"attention",children:"Aguardando confirmação"}),o.jsxs("svg",{className:"nfid-push-phone-icon nfid-push-pulse",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("rect",{x:"6",y:"2",width:"12",height:"20",rx:"3"}),o.jsx("path",{d:"M11 18h2"})]}),o.jsx("h2",{children:"Confirme no seu celular"}),o.jsxs("p",{children:["Enviamos um pedido de confirmação para o seu aparelho. Abra o NeoFaceID Push e confirme com o seu rosto para continuar no ",e,"."]}),t&&o.jsxs("div",{className:"nfid-push-code",children:[o.jsx("span",{className:"nfid-push-code-label",children:"Digite este número no celular"}),o.jsx("span",{className:"nfid-push-code-value","aria-label":`Código de confirmação: ${t.split("").join(" ")}`,children:t})]}),o.jsxs("p",{className:"nfid-push-countdown",children:["Expira em ",cu(r)]}),o.jsx("div",{className:"nfid-push-actions",children:o.jsx(ru,{variant:"ghost",onClick:a,children:"Cancelar"})}),o.jsx("div",{className:"nfid-push-footer",children:o.jsx(gd,{})})]})}function du({onFallback:e,onCancel:t}){return n.useEffect((()=>{al(),il(iu,su)}),[]),o.jsxs("div",{className:"nfid-push",role:"alert","aria-live":"assertive",children:[o.jsxs("svg",{className:"nfid-push-phone-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{color:"var(--nfid-text-muted)"},children:[o.jsx("circle",{cx:"12",cy:"12",r:"9"}),o.jsx("path",{d:"M12 7v5l3 2"})]}),o.jsx("h2",{children:"O tempo esgotou"}),o.jsx("p",{children:"Não recebemos a confirmação do seu celular a tempo."}),o.jsx("div",{className:"nfid-push-actions",children:e?o.jsxs(o.Fragment,{children:[o.jsx(ru,{variant:"primary",onClick:e,children:"Entrar de outro jeito"}),o.jsx(ru,{variant:"ghost",onClick:t,children:"Agora não"})]}):o.jsx(ru,{variant:"primary",onClick:t,children:"Entendi"})}),o.jsx("div",{className:"nfid-push-footer",children:o.jsx(gd,{})})]})}function uu({appName:e,onFallback:t,onCancel:r}){return n.useEffect((()=>{al(),il(iu,su)}),[]),o.jsxs("div",{className:"nfid-push",role:"alert","aria-live":"assertive",children:[o.jsxs("svg",{className:"nfid-push-phone-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{color:"var(--nfid-text-muted)"},children:[o.jsx("circle",{cx:"12",cy:"12",r:"9"}),o.jsx("path",{d:"M8 12h8"})]}),o.jsx("h2",{children:"Solicitação cancelada"}),o.jsxs("p",{children:["O pedido de confirmação foi cancelado antes de ser respondido. Você pode tentar de novo pelo"," ",e,"."]}),o.jsx("div",{className:"nfid-push-actions",children:t?o.jsxs(o.Fragment,{children:[o.jsx(ru,{variant:"primary",onClick:t,children:"Entrar de outro jeito"}),o.jsx(ru,{variant:"ghost",onClick:r,children:"Agora não"})]}):o.jsx(ru,{variant:"primary",onClick:r,children:"Entendi"})}),o.jsx("div",{className:"nfid-push-footer",children:o.jsx(gd,{})})]})}function pu({appName:e,onCancel:t}){return n.useEffect((()=>{al(),il(iu,su)}),[]),o.jsxs("div",{className:"nfid-push",role:"alert","aria-live":"assertive",children:[o.jsxs("svg",{className:"nfid-push-phone-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{color:"#D64545"},children:[o.jsx("circle",{cx:"12",cy:"12",r:"9"}),o.jsx("path",{d:"M15 9l-6 6M9 9l6 6"})]}),o.jsx("h2",{children:"Confirmação recusada"}),o.jsxs("p",{children:["O pedido foi recusado no celular. Se não foi você, procure o suporte do ",e,"."]}),o.jsx("div",{className:"nfid-push-actions",children:o.jsx(ru,{variant:"primary",onClick:t,children:"Entendi"})}),o.jsx("div",{className:"nfid-push-footer",children:o.jsx(gd,{})})]})}function fu(e){var n,t,o;switch(e.status){case"approved":case"success":return{kind:"resolve",value:{status:"approved",data:e.data??{}}};case"denied":return{kind:"resolve",value:{status:"denied",reason:(null==(n=e.data)?void 0:n.reason)??e.message}};case"expired":return{kind:"resolve",value:{status:"expired"}};case"cancelled":return{kind:"resolve",value:{status:"cancelled",source:"server",reason:(null==(t=e.data)?void 0:t.reason)??e.message}};case"failed":case"error":return{kind:"reject",error:new io(e.message??(null==(o=e.data)?void 0:o.message)??"Falha na confirmação",ao.API_ERROR)};default:return{kind:"pending"}}}function hu({requestId:e,applicationToken:t,expiresIn:r,numericCode:a,appName:i,onFallback:s,onSettle:c}){const l=i??gl()??"sua aplicação",[d,u]=n.useState(r),[p,f]=n.useState({kind:"waiting"});return n.useEffect((()=>{if("waiting"!==p.kind)return;const e=setInterval((()=>{u((e=>e>0?e-1:0))}),1e3);return()=>clearInterval(e)}),[p.kind]),n.useEffect((()=>{const n=new AbortController;let o=!1;const a=hl(),i=`${a}/api/v1/authorization/events/${encodeURIComponent(e)}/ticket/`;return tu({signal:n.signal,timeoutMs:1e3*(r+30),requestTicket:async()=>{var e;const n=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":t}});if(!n.ok)throw new io(`Falha ao abrir canal de confirmação: ${n.status}`,401===n.status||403===n.status?ao.INVALID_TOKEN:ao.NETWORK);const o=await n.json(),r=(null==(e=null==o?void 0:o.data)?void 0:e.ticket)??(null==o?void 0:o.ticket);if(!r)throw new io("Canal de confirmação sem ticket",ao.API_ERROR);return r},buildUrl:n=>`${a}/api/v1/authorization/events/${encodeURIComponent(e)}/?ticket=${encodeURIComponent(n)}`,classify:fu}).then((e=>{o||(o=!0,"denied"!==e.status?"expired"!==e.status?"cancelled"!==e.status?c(e):f({kind:"cancelled",reason:e.reason}):f({kind:"expired"}):f({kind:"denied"}))})).catch((()=>{o||n.signal.aborted||(o=!0,f({kind:"expired"}))})),()=>{o=!0,n.abort()}}),[e]),"denied"===p.kind?o.jsx(Xd,{open:!0,dismissOnOverlay:!1,ariaLabel:"Confirmação recusada",children:o.jsx(pu,{appName:l,onCancel:()=>c({status:"denied"})})}):"cancelled"===p.kind?o.jsx(Xd,{open:!0,dismissOnOverlay:!1,ariaLabel:"Solicitação cancelada",children:o.jsx(uu,{appName:l,onFallback:s?()=>{s(),c({status:"cancelled",source:"server",reason:p.reason})}:void 0,onCancel:()=>c({status:"cancelled",source:"server",reason:p.reason})})}):"expired"===p.kind?o.jsx(Xd,{open:!0,dismissOnOverlay:!1,ariaLabel:"Tempo esgotado",children:o.jsx(du,{onFallback:s?()=>{s(),c({status:"expired"})}:void 0,onCancel:()=>c({status:"expired"})})}):o.jsx(Xd,{open:!0,dismissOnOverlay:!1,ariaLabel:"Aguardando confirmação no celular",children:o.jsx(lu,{appName:l,numericCode:a,remainingSeconds:d,onCancel:()=>c({status:"cancelled",source:"user"})})})}const mu="neofaceid-device-enrollment-styles",gu="\n.neofaceid-root .nfid-enroll {\n display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;\n padding: 8px 8px 4px;\n}\n.neofaceid-root .nfid-enroll h2 {\n margin: 6px 0 0; font-size: 20px; font-weight: 700; color: var(--nfid-text); line-height: 1.25;\n letter-spacing: -0.015em;\n}\n.neofaceid-root .nfid-enroll p {\n margin: 0; font-size: 14px; color: var(--nfid-text-muted); line-height: 1.5;\n}\n/* O QR é sempre escuro sobre branco, independente do tema: leitor de código\n falha com contraste invertido, e a moldura clara faz a zona de silêncio. */\n.neofaceid-root .nfid-enroll-qr {\n background: #FFFFFF; padding: 14px; border-radius: 16px; margin-top: 12px;\n line-height: 0; box-shadow: 0 0 0 1px var(--nfid-line);\n}\n.neofaceid-root .nfid-enroll-qr svg { display: block; width: 184px; height: 184px; }\n.neofaceid-root .nfid-enroll-handle {\n display: flex; flex-direction: column; align-items: center; gap: 4px;\n margin-top: 14px; padding: 12px 24px;\n background: var(--nfid-surface-muted); border-radius: 12px; width: 100%;\n}\n.neofaceid-root .nfid-enroll-handle-label {\n font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;\n color: var(--nfid-text-subtle);\n}\n.neofaceid-root .nfid-enroll-handle-value {\n font-size: 26px; font-weight: 800; line-height: 1.1; letter-spacing: 0.12em;\n color: var(--nfid-text); font-variant-numeric: tabular-nums;\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n}\n.neofaceid-root .nfid-enroll-countdown {\n font-size: 13px; color: var(--nfid-text-muted); font-variant-numeric: tabular-nums;\n margin-top: 10px;\n}\n.neofaceid-root .nfid-enroll-actions {\n display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 16px;\n}\n.neofaceid-root .nfid-enroll-note {\n font-size: 12px; line-height: 1.45; color: var(--nfid-text-muted);\n background: var(--nfid-surface-muted); border-radius: 10px;\n padding: 10px 14px; margin-top: 12px; text-align: left; width: 100%;\n}\n.neofaceid-root .nfid-enroll-icon { width: 56px; height: 56px; }\n.neofaceid-root .nfid-enroll-footer {\n display: flex; justify-content: center; margin-top: 16px; padding-top: 12px;\n border-top: 1px solid var(--nfid-line); width: 100%;\n}\n";function vu(e){const n=Math.max(0,e);return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function wu({value:e}){const[t,r]=n.useState(null);return n.useEffect((()=>{let n=!1;return Promise.resolve().then((()=>Kp)).then((t=>{if(n)return;const o=(t.default??t)(0,"M");o.addData(e),o.make();const a=o.getModuleCount(),i=[];for(let e=0;e<a;e+=1)for(let n=0;n<a;n+=1)o.isDark(e,n)&&i.push(`M${n} ${e}h1v1h-1z`);r({d:i.join(""),count:a})})).catch((()=>{n||r(null)})),()=>{n=!0}}),[e]),t?o.jsx("svg",{viewBox:`0 0 ${t.count} ${t.count}`,shapeRendering:"crispEdges",role:"img","aria-label":`Código para inscrição do aparelho: ${e.split("").join(" ")}`,children:o.jsx("path",{d:t.d,fill:"#000000"})}):o.jsx("svg",{viewBox:"0 0 21 21","aria-hidden":"true"})}function bu({appName:e,handle:t,remainingSeconds:r,onCancel:a}){return n.useEffect((()=>{al(),il(mu,gu)}),[]),o.jsxs("div",{className:"nfid-enroll",role:"status","aria-live":"polite",children:[o.jsx(au,{tone:"attention",children:"Aguardando o aparelho"}),o.jsx("h2",{children:"Vincule seu celular"}),o.jsxs("p",{children:["Abra o NeoFaceID Push no celular e aponte para este código para vinculá-lo à sua conta no"," ",e,"."]}),o.jsx("div",{className:"nfid-enroll-qr",children:o.jsx(wu,{value:t})}),o.jsxs("div",{className:"nfid-enroll-handle",children:[o.jsx("span",{className:"nfid-enroll-handle-label",children:"Ou digite este código"}),o.jsx("span",{className:"nfid-enroll-handle-value",children:t})]}),o.jsxs("p",{className:"nfid-enroll-countdown",children:["O código expira em ",vu(r)]}),o.jsx("div",{className:"nfid-enroll-actions",children:o.jsx(ru,{variant:"ghost",onClick:a,children:"Cancelar"})}),o.jsx("div",{className:"nfid-enroll-footer",children:o.jsx(gd,{})})]})}function xu({deviceLabel:e,onDone:t}){return n.useEffect((()=>{al(),il(mu,gu)}),[]),o.jsxs("div",{className:"nfid-enroll",role:"alert","aria-live":"assertive",children:[o.jsxs("svg",{className:"nfid-enroll-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{color:"#1E9E6A"},children:[o.jsx("circle",{cx:"12",cy:"12",r:"9"}),o.jsx("path",{d:"M8.5 12.5l2.5 2.5 4.5-5"})]}),o.jsx("h2",{children:"Aparelho vinculado"}),e?o.jsxs("p",{children:[o.jsx("strong",{children:e})," agora pode confirmar suas operações."]}):o.jsx("p",{children:"Um aparelho acabou de ser vinculado à sua conta."}),o.jsx("div",{className:"nfid-enroll-note",children:e?o.jsx(o.Fragment,{children:"Se este não é o seu aparelho, procure o suporte agora — alguém pode ter vinculado um celular à sua conta."}):o.jsxs(o.Fragment,{children:[o.jsx("strong",{children:"Não conseguimos identificar qual aparelho foi vinculado."})," Se não foi você quem acabou de fazer isso, procure o suporte agora — alguém pode ter vinculado um celular à sua conta."]})}),o.jsx("div",{className:"nfid-enroll-actions",children:o.jsx(ru,{variant:"primary",onClick:t,children:"Entendi"})}),o.jsx("div",{className:"nfid-enroll-footer",children:o.jsx(gd,{})})]})}function yu({onRetry:e,onCancel:t}){return n.useEffect((()=>{al(),il(mu,gu)}),[]),o.jsxs("div",{className:"nfid-enroll",role:"alert","aria-live":"assertive",children:[o.jsxs("svg",{className:"nfid-enroll-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{color:"var(--nfid-text-muted)"},children:[o.jsx("circle",{cx:"12",cy:"12",r:"9"}),o.jsx("path",{d:"M12 7v5l3 2"})]}),o.jsx("h2",{children:"O código expirou"}),o.jsx("p",{children:"Códigos de vinculação valem poucos minutos, por segurança. Gere um novo para tentar."}),o.jsxs("div",{className:"nfid-enroll-actions",children:[o.jsx(ru,{variant:"primary",onClick:e,children:"Gerar novo código"}),o.jsx(ru,{variant:"ghost",onClick:t,children:"Agora não"})]}),o.jsx("div",{className:"nfid-enroll-footer",children:o.jsx(gd,{})})]})}function _u(e){var n,t,o;switch(e.status){case"enrolled":return{kind:"resolve",value:{status:"enrolled",deviceLabel:(null==(n=e.data)?void 0:n.device_label)??null,enrolledAt:null==(t=e.data)?void 0:t.enrolled_at}};case"expired":return{kind:"resolve",value:{status:"expired"}};case"error":case"failed":return{kind:"reject",error:new io(e.message??(null==(o=e.data)?void 0:o.message)??"Falha ao inscrever o aparelho",ao.API_ERROR)};default:return{kind:"pending"}}}function ku({userAccessToken:e,applicationToken:t,appName:r,attempt:a,onSettle:i,onRetry:s,onFatal:c}){const l=r??gl()??"sua aplicação",[d,u]=n.useState({kind:"loading"}),[p,f]=n.useState(0);return n.useEffect((()=>{const n=new AbortController;let o=!1;return(async()=>{let r;try{r=await Ll(e,t)}catch(i){return void(o||c(i))}if(o)return;u({kind:"waiting",handle:r.handle,jti:r.jti,expiresIn:r.expiresIn}),f(r.expiresIn);const a=`${hl()}/api/v1/devices/enrollment/${encodeURIComponent(r.jti)}/events/`;try{const e=await tu({signal:n.signal,timeoutMs:1e3*(r.expiresIn+30),requestTicket:async()=>{var e;const n=await fetch(`${a}ticket/`,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":t}});if(!n.ok)throw new io(`Falha ao abrir o canal de inscrição: ${n.status}`,401===n.status||403===n.status?ao.INVALID_TOKEN:ao.NETWORK);const o=await n.json(),r=(null==(e=null==o?void 0:o.data)?void 0:e.ticket)??(null==o?void 0:o.ticket);if(!r)throw new io("Canal de inscrição sem ticket",ao.API_ERROR);return r},buildUrl:e=>`${a}?ticket=${encodeURIComponent(e)}`,classify:_u});if(o)return;if("enrolled"===e.status)return void u({kind:"enrolled",deviceLabel:e.deviceLabel,enrolledAt:e.enrolledAt});u({kind:"expired"})}catch{if(o||n.signal.aborted)return;u({kind:"expired"})}})(),()=>{o=!0,n.abort()}}),[a]),n.useEffect((()=>{if("waiting"!==d.kind)return;const e=setInterval((()=>f((e=>e>0?e-1:0))),1e3);return()=>clearInterval(e)}),[d.kind]),"loading"===d.kind?null:"enrolled"===d.kind?o.jsx(Xd,{open:!0,dismissOnOverlay:!1,ariaLabel:"Aparelho vinculado",children:o.jsx(xu,{deviceLabel:d.deviceLabel,onDone:()=>i({status:"enrolled",deviceLabel:d.deviceLabel,enrolledAt:d.enrolledAt})})}):"expired"===d.kind?o.jsx(Xd,{open:!0,dismissOnOverlay:!1,ariaLabel:"Código expirado",children:o.jsx(yu,{onRetry:s,onCancel:()=>i({status:"expired"})})}):o.jsx(Xd,{open:!0,dismissOnOverlay:!1,ariaLabel:"Vincular aparelho",children:o.jsx(bu,{appName:l,handle:d.handle,remainingSeconds:p,onCancel:()=>i({status:"cancelled"})})})}function Eu(e={}){const n=document.createElement("div");n.className="neofaceid-camera-oval-guide-overlay-root",Object.assign(n.style,{position:"fixed",top:"0",left:"0",width:"100vw",height:"100vh",backgroundColor:"rgba(0, 0, 0, 0.85)",backdropFilter:"blur(8px)",zIndex:"99999",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"}),document.body.appendChild(n);let r=t.createRoot(n),a=e.stream||null,i=e.faceState||"searching",s=e.instruction||"Centralize o rosto";const c=(n,t,a)=>{r&&r.render(o.jsxs("div",{style:{position:"relative",width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:[e.onCancel&&o.jsx("button",{onClick:()=>{var n;l.close(),null==(n=e.onCancel)||n.call(e)},style:{position:"absolute",top:"20px",right:"20px",background:"rgba(255, 255, 255, 0.2)",border:"none",color:"#fff",fontSize:"24px",width:"40px",height:"40px",borderRadius:"50%",cursor:"pointer",zIndex:10,display:"flex",alignItems:"center",justifyContent:"center"},"aria-label":"Cancelar",children:"✕"}),o.jsx(Tu,{stream:n,faceState:t,instruction:a})]}))};c(a,i,s);const l={update:(e,n,t)=>{a=e,i=n,s=t,c(e,n,t)},close:()=>{r&&(r.unmount(),r=null),n.parentElement&&n.parentElement.removeChild(n)}};return l}function Tu({stream:e,faceState:t,instruction:r,className:a="",style:i={}}){const s=n.useRef(null);n.useEffect((()=>{const n=s.current;if(n)return e?(n.srcObject=e,n.play().catch((()=>{}))):n.srcObject=null,()=>{e&&e.getTracks().forEach((e=>e.stop())),n&&(n.srcObject=null)}}),[e]);const c=function(e){switch(e){case"centered":return{borderColor:"#0E9F6E",boxShadow:"0 0 0 4px rgba(14, 159, 110, 0.8), 0 0 45px rgba(14, 159, 110, 0.45)",svgStroke:"#0E9F6E",badgeBg:"rgba(14, 159, 110, 0.95)",badgeColor:"#FFFFFF"};case"too-far":case"too-close":case"off-center":return{borderColor:"#F59E0B",boxShadow:"0 0 0 4px rgba(245, 158, 11, 0.7), 0 0 35px rgba(245, 158, 11, 0.35)",svgStroke:"#F59E0B",badgeBg:"rgba(245, 158, 11, 0.95)",badgeColor:"#1F2937"};default:return{borderColor:"rgba(156, 163, 175, 0.5)",boxShadow:"0 0 0 4px rgba(156, 163, 175, 0.3), 0 0 20px rgba(156, 163, 175, 0.15)",svgStroke:"#9CA3AF",badgeBg:"rgba(55, 65, 81, 0.9)",badgeColor:"#FFFFFF"}}}(t);return o.jsxs("div",{className:`neofaceid-camera-oval-guide-container ${a}`,style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",position:"relative",width:"100%",maxHeight:"100%",padding:"16px",boxSizing:"border-box",...i},children:[o.jsx("style",{children:"\n .neofaceid-oval-frame {\n width: 320px;\n height: 400px;\n border-radius: 50%;\n overflow: hidden;\n position: relative;\n background: #000000;\n transition: box-shadow 0.3s ease, border-color 0.3s ease;\n }\n\n .neofaceid-oval-video {\n width: 100%;\n height: 100%;\n object-fit: cover;\n transform: scaleX(-1);\n display: block;\n }\n\n .neofaceid-oval-svg-overlay {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n z-index: 2;\n }\n\n .neofaceid-oval-instruction-badge {\n margin-top: 20px;\n padding: 10px 20px;\n border-radius: 20px;\n font-size: 15px;\n font-weight: 600;\n text-align: center;\n max-width: 320px;\n box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);\n backdrop-filter: blur(8px);\n transition: background-color 0.3s ease, color 0.3s ease;\n z-index: 5;\n }\n\n @media (max-width: 640px) {\n .neofaceid-oval-frame {\n width: 280px;\n height: 350px;\n }\n }\n "}),o.jsxs("div",{className:"neofaceid-oval-frame",style:{boxShadow:c.boxShadow,borderColor:c.borderColor},children:[o.jsx("video",{ref:s,className:"neofaceid-oval-video",autoPlay:!0,playsInline:!0,muted:!0,"data-testid":"camera-oval-video"}),o.jsx("svg",{className:"neofaceid-oval-svg-overlay",viewBox:"0 0 320 400",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:o.jsx("ellipse",{cx:"160",cy:"200",rx:"140",ry:"180",stroke:c.svgStroke,strokeWidth:"3",strokeDasharray:"searching"===t?"8 8":"none",style:{transition:"stroke 0.3s ease"}})})]}),r&&o.jsx("div",{className:"neofaceid-oval-instruction-badge","aria-live":"assertive",style:{backgroundColor:c.badgeBg,color:c.badgeColor},"data-testid":"camera-oval-instruction",children:r})]})}function Nu({error:e,onRetry:t,onCredentials:r,onCancel:a,applicationToken:i}){const[s,c]=n.useState(0),[l,d]=n.useState(!1),u=n.useRef(null),p=n.useCallback((()=>{u.current&&(clearInterval(u.current),u.current=null)}),[]);n.useEffect((()=>p),[p]);const f=n.useCallback((()=>{if(l)return;d(!0);const n=Math.max((null==e?void 0:e.retryAfterMs)??0,3e3),o=Math.ceil(n/1e3);c(o);let r=o;u.current=setInterval((()=>{r-=1,c(r),r<=0&&(p(),d(!1),t())}),1e3)}),[l,e,t,p]),h=n.useCallback((()=>{p(),r()}),[p,r]),m=n.useCallback((()=>{p(),null==a||a()}),[p,a]);return o.jsxs(o.Fragment,{children:[o.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: var(--nfid-overlay);\n backdrop-filter: blur(3px);\n -webkit-backdrop-filter: blur(3px);\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 font-family: inherit;\n }\n\n .neofaceid-fallback-prompt {\n background: var(--nfid-surface);\n border-radius: var(--nfid-radius, 16px);\n padding: 28px;\n max-width: 400px;\n width: 100%;\n box-shadow: 0 1px 3px rgba(10, 19, 32, 0.08);\n animation: slideUp 0.32s cubic-bezier(.2,0,0,1);\n text-align: center;\n box-sizing: border-box;\n }\n\n /* Falha de captura é atenção (dourado), nunca crítico (vermelho). */\n .neofaceid-fallback-icon {\n width: 56px;\n height: 56px;\n margin: 0 auto 20px;\n color: #F1BE00;\n }\n\n .neofaceid-fallback-title {\n font-size: 20px;\n font-weight: 700;\n color: var(--nfid-text);\n margin: 0 0 8px 0;\n line-height: 1.25;\n }\n\n .neofaceid-fallback-message {\n font-size: 14px;\n color: var(--nfid-text-muted);\n margin: 0 0 24px 0;\n line-height: 1.5;\n }\n\n .neofaceid-fallback-actions {\n display: flex;\n flex-direction: column;\n gap: 10px;\n }\n\n .neofaceid-fallback-button {\n min-height: 44px;\n padding: 12px 20px;\n border-radius: var(--nfid-radius, 16px);\n border: none;\n font-size: 15px;\n font-weight: 600;\n cursor: pointer;\n transition: background 120ms ease-out;\n font-family: inherit;\n }\n\n .neofaceid-fallback-button-primary {\n background: var(--nfid-action);\n color: var(--nfid-action-text);\n }\n .neofaceid-fallback-button-primary:hover { opacity: 0.92; }\n .neofaceid-fallback-button-primary:focus-visible {\n outline: 2px solid var(--nfid-focus-ring);\n outline-offset: 2px;\n }\n .neofaceid-fallback-button-primary:disabled {\n opacity: 0.55;\n cursor: not-allowed;\n }\n\n .neofaceid-fallback-button-secondary {\n background: var(--nfid-surface-muted);\n color: var(--nfid-text);\n border: 1px solid var(--nfid-line);\n }\n .neofaceid-fallback-button-secondary:hover { opacity: 0.9; }\n\n .neofaceid-fallback-button-ghost {\n background: transparent;\n color: var(--nfid-text-muted);\n min-height: 44px;\n padding: 10px;\n }\n .neofaceid-fallback-button-ghost:hover {\n background: var(--nfid-surface-muted);\n }\n\n @media (max-width: 640px) {\n .neofaceid-fallback-prompt {\n padding: 22px;\n }\n .neofaceid-fallback-title {\n font-size: 18px;\n }\n }\n "}),o.jsx("div",{className:"neofaceid-root neofaceid-fallback-overlay",role:"dialog","aria-modal":"true",children:o.jsxs("div",{className:"neofaceid-fallback-prompt",children:[o.jsx("div",{className:"neofaceid-fallback-icon","aria-hidden":"true",children:o.jsxs("svg",{viewBox:"0 0 64 64",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("path",{d:"M32 8 L58 54 H6 Z",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),o.jsx("path",{d:"M32 26 V38",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"}),o.jsx("circle",{cx:"32",cy:"45",r:"2",fill:"currentColor"})]})}),o.jsx("h3",{className:"neofaceid-fallback-title",children:"Vamos tentar de outro jeito"}),o.jsx("p",{className:"neofaceid-fallback-message",children:(null==e?void 0:e.getFriendlyMessage())||"Não conseguimos reconhecer sua face. Tente novamente ou use email e senha."}),o.jsxs("div",{className:"neofaceid-fallback-actions",children:[o.jsx("button",{type:"button",className:"neofaceid-fallback-button neofaceid-fallback-button-primary",onClick:f,disabled:l,"aria-disabled":l,children:l?`Aguarde ${s}s...`:"Tentar Novamente"}),o.jsx("button",{type:"button",className:"neofaceid-fallback-button neofaceid-fallback-button-secondary",onClick:h,children:"Entrar com Email e Senha"}),i&&o.jsx("button",{type:"button",className:"neofaceid-fallback-button neofaceid-fallback-button-ghost",onClick:()=>{new wd(i).open()},children:"Esqueceu sua senha?"}),a&&o.jsx("button",{type:"button",className:"neofaceid-fallback-button neofaceid-fallback-button-ghost",onClick:m,children:"Cancelar"})]})]})})]})}class Su{constructor(){l(this,"container",null),l(this,"root",null)}show(e,n,o,r,a){this.container||(al(),this.container=document.createElement("div"),this.container.id="neofaceid-fallback-prompt",document.body.appendChild(this.container),this.root=t.createRoot(this.container),this.render(e,n,o,r,a))}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,r,a){this.root&&this.container&&this.root.render(o.jsx(Nu,{error:e,onRetry:()=>{this.close(),n()},onCredentials:()=>{this.close(),t()},applicationToken:a??"",onCancel:()=>{this.close(),null==r||r()}}))}}class Cu{constructor(e){l(this,"options"),l(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(){al(),this.addStyles(),this.modalElement=document.createElement("div"),this.modalElement.className="neofaceid-root neoface-email-password-modal",this.modalElement.innerHTML=`\n <div class="neoface-email-modal-overlay">\n <div class="neoface-email-modal-content">\n <h2>${this.options.title||"Login com Email e Senha"}</h2>\n <p>${this.options.subtitle||"Informe seus dados para login."}</p>\n <div id="login-error" class="neoface-email-error" style="display:none"></div>\n <form id="email-password-form">\n <input type="email" id="email" placeholder="Email" required />\n <input type="password" id="password" placeholder="Senha" required />\n <button type="submit" class="neoface-email-submit-btn">Entrar</button>\n </form>\n <button class="neoface-email-cancel-btn">Cancelar</button>\n \n \x3c!-- Branding --\x3e\n <div class="neoface-email-branding">\n ${vd()}\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";document.getElementById(e)||il(e,"\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: inherit;\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, #0A1320 0%, #111C2B 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: #0059C4;\n box-shadow: 0 0 0 3px rgba(0, 89, 196, 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, #0059C4 0%, #00449A 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(0, 89, 196, 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(0, 89, 196, 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: inherit;\n color: #ffffff;\n letter-spacing: 0.3px;\n }\n\n .neoface-email-error {\n background: rgba(239, 68, 68, 0.15);\n border: 1px solid rgba(239, 68, 68, 0.4);\n border-radius: 10px;\n color: #fca5a5;\n font-size: 14px;\n padding: 12px 16px;\n margin-bottom: 16px;\n text-align: center;\n animation: fadeIn 0.2s ease-out;\n }\n\n @media (max-width: 640px) {\n .neoface-email-modal-content {\n padding: 24px;\n border-radius: 16px;\n }\n\n .neoface-email-modal-content h2 {\n font-size: 20px;\n }\n }\n ")}async handleSubmit(e){e.preventDefault();const n=this.modalElement.querySelector("#email"),t=this.modalElement.querySelector("#password"),o=this.modalElement.querySelector(".neoface-email-submit-btn"),r=this.modalElement.querySelector("#login-error"),a=e=>{r.textContent=e,r.style.display="block"};r.style.display="none",r.textContent="";const i=n.value.trim(),s=t.value.trim();if(i&&s){o.disabled=!0,o.textContent="Entrando...";try{const e=await Ml(i,s,this.options.applicationToken);this.options.onSuccess(e),this.close()}catch(c){o.disabled=!1,o.textContent="Entrar";c instanceof io&&(c.type===ao.INVALID_TOKEN||c.type===ao.API_ERROR&&c.message.includes("400"))?(a("Email ou senha incorretos. Verifique seus dados e tente novamente."),t.value="",t.focus()):(a("Ocorreu um erro inesperado. Tente novamente mais tarde."),this.options.onError(c))}}else a("Preencha o email e a senha para continuar.")}}let Iu=!1,Ru=null;async function Ou(){if(!Iu)return Ru||(Ru=(async()=>{try{const e="/models";await Et.tinyFaceDetector.loadFromUri(e),Iu=!0}catch(e){}})(),Ru)}async function ju(e,n,t,o=5e3,r=100){return new Promise((a=>{let i=0;const s=Math.ceil(o/r);let c=null,l=!1,d=0;const u=e=>{l||(l=!0,c&&clearTimeout(c),a(e))},p=async()=>{if(!l){if(i++,!Iu)return t.update(n,"searching","Carregando modelos de detecção..."),i>=s?void u(!1):void(c=window.setTimeout(p,r));try{const o=await Jt(e,new vt({inputSize:160,scoreThreshold:.3})),{faceState:a,instruction:l}=function(e,n,t){if(!e||!n||!t)return{faceState:"searching",instruction:"Centralize o rosto"};const o=e.x+e.width/2,r=e.y+e.height/2,a=n/2,i=t/2,s=Math.abs(o-a)/n,c=Math.abs(r-i)/t,l=e.width*e.height/(n*t);return l<.08?{faceState:"too-far",instruction:"Aproxime-se"}:l>.45?{faceState:"too-close",instruction:"Afaste-se"}:s>.18||c>.18?{faceState:"off-center",instruction:"Centralize o rosto"}:{faceState:"centered",instruction:"Perfeito, mantenha"}}(o?o.box:null,e.videoWidth,e.videoHeight);if(t.update(n,a,l),"centered"===a){if(d+=r,d>=1e3)return void u(!0)}else d=0;if(i>=s)return void u(!1);c=window.setTimeout(p,r)}catch(o){if(i>=s)return void u(!1);c=window.setTimeout(p,r)}}};window.setTimeout((()=>{l||u(!1)}),o+500),p()}))}async function Au(e){const{applicationToken:n,onSuccess:t,onError:o,onAttemptError:r,onFallbackRequest:a,onCancel:i,fastMode:s=!1}=e,c=new Su;let l,d=0;Iu||s||Ou().catch((()=>{}));const u=async()=>{try{d++;const e=await async function(e,n=!1,t){const o=Eu({stream:null,faceState:"searching",instruction:"Iniciando câmera...",onCancel:t}),r=document.createElement("video");r.style.position="fixed",r.style.top="-9999px",r.style.left="-9999px",r.style.width="1px",r.style.height="1px",r.style.opacity="0",r.muted=!0,r.playsInline=!0,r.setAttribute("autoplay",""),r.setAttribute("playsinline",""),document.body.appendChild(r);let a=null;try{try{a=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"},audio:!1})}catch{a=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user"},audio:!1})}r.srcObject=a,o.update(a,"searching","Centralize o rosto"),await new Promise((e=>{if(r.readyState>=1)e();else{const n=()=>{r.removeEventListener("loadedmetadata",n),e()};r.addEventListener("loadedmetadata",n),setTimeout(e,2e3)}})),await r.play(),await new Promise((e=>{if(r.videoWidth&&r.videoHeight)e();else{const n=()=>{r.videoWidth&&r.videoHeight?e():setTimeout(n,100)};setTimeout(e,3e3),n()}})),await new Promise((e=>setTimeout(e,100)));let t=!0;if(n||(t=await ju(r,a,o,5e3,100)),!t)throw o.close(),a&&a.getTracks().forEach((e=>e.stop())),r.parentElement&&r.parentElement.removeChild(r),new io("Nenhum rosto centralizado detectado. Por favor, tente novamente.",ao.VALIDATION_ERROR);o.update(a,"centered","Capturando imagem...");const i=document.createElement("canvas");i.width=r.videoWidth,i.height=r.videoHeight;const s=i.getContext("2d");if(!s)throw o.close(),a&&a.getTracks().forEach((e=>e.stop())),r.parentElement&&r.parentElement.removeChild(r),new io("Erro ao capturar imagem",ao.CAPTURE_ERROR);s.drawImage(r,0,0,i.width,i.height);const c=await new Promise(((e,n)=>{i.toBlob((t=>{i.remove(),t?e(t):n(new Error("Failed to capture image"))}),"image/jpeg",.85)}));o.update(a,"centered","Verificando com o servidor...");const l=await jl(c,e);if(o.close(),a&&a.getTracks().forEach((e=>e.stop())),r.parentElement&&r.parentElement.removeChild(r),!l.success)throw new io("Login falhou",ao.LOGIN_FAILED);return l}catch(i){if(o.close(),a&&a.getTracks().forEach((e=>e.stop())),r.parentElement&&r.parentElement.removeChild(r),i instanceof io)throw i;throw new io(i instanceof Error?i.message:"Erro desconhecido",ao.UNKNOWN)}}(n,s,i);t(e)}catch(e){l=e instanceof io?e:new io(e instanceof Error?e.message:"Erro desconhecido",ao.UNKNOWN),r&&r(l,d),d<2?setTimeout((()=>{u()}),500):setTimeout((()=>{c.show(l,(()=>{d=0,setTimeout((()=>u()),500)}),(()=>{a?a():o(new io("Por favor, use email e senha para fazer login",ao.LOGIN_FAILED))}),i,n)}),500)}};u()}const Pu=Object.freeze(Object.defineProperty({__proto__:null,captureFaceSilently:async function(){return new Promise(((e,n)=>{const t=document.createElement("video");t.style.position="fixed",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.opacity="0",t.muted=!0,t.playsInline=!0,t.setAttribute("autoplay",""),t.setAttribute("playsinline","");const o=document.createElement("canvas");o.style.display="none";let r=null,a=0;const i=()=>{r&&r.getTracks().forEach((e=>e.stop())),t.parentElement&&t.parentElement.removeChild(t),o.parentElement&&o.parentElement.removeChild(o)};document.body.appendChild(t),document.body.appendChild(o);const s=e=>e?navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"},audio:!1}):navigator.mediaDevices.getUserMedia({video:{facingMode:"user"},audio:!1});s(!0).catch((()=>s(!1))).then((s=>{r=s,t.srcObject=r;const c=()=>{if(!t.videoWidth||!t.videoHeight)return a<30?(a++,void setTimeout(c,150)):(i(),void n(new io("Câmera não está pronta",ao.CAMERA_ERROR)));o.width=t.videoWidth,o.height=t.videoHeight;const r=o.getContext("2d");if(!r)return i(),void n(new Error("Failed to get canvas context"));(async()=>{if(!Iu)return!0;try{return!!(await Jt(t,new vt({inputSize:160,scoreThreshold:.3})))}catch{return!0}})().then((s=>{if(!s&&a<30)return a++,void setTimeout(c,150);r.drawImage(t,0,0,o.width,o.height),o.toBlob((t=>{i(),t?e(t):n(new Error("Failed to capture image"))}),"image/jpeg",.85)}))},l=t.play();void 0!==l?l.then((()=>{t.videoWidth&&t.videoHeight?setTimeout(c,200):(t.onloadedmetadata=()=>setTimeout(c,200),setTimeout((()=>{t.videoWidth&&t.videoHeight&&c()}),1500))})).catch((e=>{i(),n(new io(`Erro ao reproduzir câmera: ${e.message}`,ao.CAMERA_ERROR))})):t.onloadedmetadata=()=>setTimeout(c,200),t.onerror=()=>{i(),n(new io("Erro ao acessar câmera",ao.CAMERA_ERROR))}})).catch((e=>{i(),n(new io(`Não foi possível acessar a câmera: ${e.message}`,ao.CAMERA_ERROR))}))}))},executeBiometricLoginFlow:Au,preloadFaceDetectionModels:Ou},Symbol.toStringTag,{value:"Module"}));function Fu(e,n={}){const t=n.darkThreshold??.235,o=n.improvementTarget??.12,r=n.sampleIntervalMs??600,a=n.minToggleMs??3e3,i=n.zIndex??10001,s=`nfid-flash-${Math.random().toString(36).slice(2,9)}`;let c=null,l=null,d=!1,u=0,p=0,f=0,h=null,m=null,g=null;const v=e=>{d!==e&&(d=e,e?m||"undefined"==typeof document||(m=document.createElement("div"),m.id=s,m.setAttribute("aria-hidden","true"),m.style.cssText=`\n position: fixed; inset: 0; background: #FFFFFF;\n z-index: ${i}; pointer-events: none;\n opacity: 0; transition: opacity 200ms ease-out;\n `,document.body.appendChild(m),requestAnimationFrame((()=>{m&&(m.style.opacity="1")}))):(()=>{if(!m)return;const e=m;m=null,e.style.opacity="0",setTimeout((()=>{e.parentNode&&e.parentNode.removeChild(e)}),220)})(),n.onChange&&n.onChange(e,u))},w=()=>{"undefined"==typeof document||g||(g=document.createElement("canvas"));const n=nd(e(),{scratch:g??void 0});u=n;const r=Date.now();d||(n>0&&n<t?p+=1:p=0,p>=2&&r-f>=a&&(h=n,f=r,p=0,v(!0),l=setTimeout((()=>{nd(e(),{scratch:g??void 0})-(h??0)<o&&(f=Date.now(),v(!1)),h=null}),600)))};return{start(){!1!==n.enabled&&(c||(w(),c=setInterval(w,r)))},stop(){c&&(clearInterval(c),c=null),l&&(clearTimeout(l),l=null),v(!1),p=0,h=null},destroy(){this.stop(),g=null},get flashOn(){return d},get lastBrightness(){return u}}}class zu{constructor(e){l(this,"modal",null),l(this,"video",null),l(this,"canvas",null),l(this,"stream",null),l(this,"options"),l(this,"countdownInterval",null),l(this,"isCapturing",!1),l(this,"flashController",null),this.options=e}async open(){try{await this.createModal(),await this.initializeCamera(),this.enableCaptureButton(),!1!==this.options.autoLighting&&(this.flashController=Fu((()=>this.video)),this.flashController.start())}catch(e){this.options.onError(new io(`Erro ao inicializar câmera: ${e.message}`,ao.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-root 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" aria-label="Fechar">&times;</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>\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 class="neofaceid-seal-row">\n ${vd()}\n </div>\n </div>\n </div>\n `,al(),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}`)}}enableCaptureButton(){if(!this.modal)return;const e=this.modal.querySelector(".neofaceid-capture-btn"),n=this.modal.querySelector(".neofaceid-status-text");e&&(e.disabled=!1,e.textContent="Capturar"),n&&(n.textContent="Pronto para capturar"),"auto"===this.options.mode&&setTimeout((()=>this.captureImage()),300)}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}`,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 io(`Erro ao capturar imagem: ${e.message}`,ao.CAPTURE_ERROR))}finally{this.isCapturing=!1}}}async detectBiometricType(e){try{const{detectBiometricType:n}=await Promise.resolve().then((()=>Gp)),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.flashController&&(this.flashController.destroy(),this.flashController=null),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(),il(e,"\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: inherit;\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: 22px;\n cursor: pointer;\n color: #666;\n padding: 0;\n min-width: 44px;\n min-height: 44px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 22px;\n transition: background-color 0.2s;\n }\n .neofaceid-close-btn:focus-visible {\n outline: 2px solid var(--nfid-focus-ring);\n outline-offset: 2px;\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 #0E9F6E;\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-seal-row {\n display: flex;\n justify-content: center;\n padding: 12px 20px 16px;\n border-top: 1px solid var(--nfid-line, #E6ECF4);\n }\n .neofaceid-seal {\n font-size: 10px;\n font-weight: 500;\n letter-spacing: 0.06em;\n text-transform: uppercase;\n color: var(--nfid-text-subtle, #617489);\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: #0E9F6E;\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 ")}}const $u="Consentimento recusado pelo usuário.";let Du=null;function Mu(){Du=null}async function Lu({applicationToken:e,purpose:n}){if(!e)throw new io("applicationToken é obrigatório para abrir sessão de captura",ao.INVALID_TOKEN);const t=`${hl()}/api/v1/auth/capture/session/`;let o;try{o=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":e},body:JSON.stringify({purpose:String(n).toUpperCase()})})}catch(c){const e=c instanceof Error?c.message:"Erro de rede";throw new io(`Falha de rede ao abrir sessão: ${e}`,ao.NETWORK)}if(401===o.status||403===o.status)throw new io("Token de aplicação inválido ou expirado",ao.INVALID_TOKEN);if(!o.ok)throw new io(`Falha ao abrir sessão de captura (${o.status})`,ao.API_ERROR);const r=await o.json().catch((()=>null)),a=(null==r?void 0:r.data)??r,i=null==a?void 0:a.session_id;if(!i)throw new io("Resposta inválida ao abrir sessão de captura (session_id ausente)",ao.API_ERROR);const s="string"==typeof(null==a?void 0:a.expires_at)&&a.expires_at.length>0?a.expires_at:function(e){const n="number"==typeof e&&Number.isFinite(e)?e:0;return new Date(Date.now()+1e3*n).toISOString()}(null==a?void 0:a.expires_in);return Du={session_id:i,expires_at:s},Du}async function Bu({sessionId:e,applicationToken:n}){if(!n)throw new io("applicationToken é obrigatório para solicitar desafio de liveness",ao.INVALID_TOKEN);if(!e)throw new io("session_id é obrigatório para solicitar desafio de liveness",ao.VALIDATION_ERROR);const t=`${hl()}/api/v1/auth/liveness/challenge/`;let o;try{o=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":n},body:JSON.stringify({session_id:e})})}catch(p){const e=p instanceof Error?p.message:"Erro de rede";throw new io(`Falha de rede ao solicitar desafio: ${e}`,ao.NETWORK)}if(401===o.status||403===o.status)throw new io("Token de aplicação inválido ou expirado",ao.INVALID_TOKEN);if(410===o.status)throw new io("Sessão de captura expirada (410) — reabrir sessão",ao.API_ERROR);if(!o.ok)throw new io(`Falha ao solicitar desafio de liveness (${o.status})`,ao.API_ERROR);const r=await o.json().catch((()=>null)),a=(null==r?void 0:r.data)??r,i=null==a?void 0:a.steps,s=null==a?void 0:a.gestures,c=Array.isArray(i)?i:Array.isArray(s)?s:void 0;if(!c||0===c.length)throw new io("Resposta inválida ao solicitar desafio (steps/gestures ausentes)",ao.API_ERROR);const l=c.map(((e,n)=>{const t=e,o=t.gesture??t.gesture_key;return{index:"number"==typeof t.order?t.order:"number"==typeof t.index?t.index:n+1,gesture_key:o??"",instruction:"string"==typeof t.instruction?t.instruction:void 0,instruction_i18n:t.instruction_i18n&&"object"==typeof t.instruction_i18n?t.instruction_i18n:void 0}})),d="number"==typeof(null==a?void 0:a.expires_in)?a.expires_in:void 0,u="string"==typeof(null==a?void 0:a.expires_at)&&a.expires_at.length>0?a.expires_at:void 0!==d?new Date(Date.now()+1e3*d).toISOString():void 0;return{challenge_id:"string"==typeof(null==a?void 0:a.challenge_id)?a.challenge_id:void 0,gestures:l,expires_at:u,expires_in:d,language:"string"==typeof(null==a?void 0:a.language)?a.language:void 0}}async function Wu({applicationToken:e,purpose:n,collectFramesForGesture:t,retryOnSessionExpired:o=!0}){const r=async()=>{const o=await Lu({applicationToken:e,purpose:n}),r=await Bu({sessionId:o.session_id,applicationToken:e}),a=[];for(let e=0;e<r.gestures.length;e+=1){const n=r.gestures[e],o=await t(n,e,r.gestures.length);a.push({gesture_key:String(n.gesture_key),images:o})}return{sessionId:o.session_id,challenge:r,capturedGestures:a}};try{return await r()}catch(a){if(o&&a instanceof io&&a.message.includes("410"))return Mu(),r();throw a}}class qu{constructor(e){l(this,"overlay",null),l(this,"video",null),l(this,"canvas",null),l(this,"stream",null),l(this,"step","face"),l(this,"countdownSeconds"),l(this,"title"),l(this,"subtitle"),l(this,"faceBlob",null),l(this,"documentBlob",null),l(this,"autoLighting"),l(this,"flashController",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,this.autoLighting=!1!==(null==e?void 0:e.autoLighting)}async open(){if(await this.createDom(),await this.startCamera(),await this.runFaceCaptureCountdown(),this.faceBlob=await this.captureFrame(),this.step="document",this.updateTexts("Captura do Documento",'Posicione seu documento visível e clique em "Capturar"'),await this.waitForUserCaptureClick(),this.documentBlob=await this.captureFrame(),await this.close(),!this.faceBlob||!this.documentBlob)throw new Error("Falha na captura das imagens de onboarding");return{face:this.faceBlob,document:this.documentBlob}}async createDom(){const e=document.createElement("div");e.className="neofaceid-modal-overlay",e.innerHTML=`\n <div class="neofaceid-modal">\n <div class="neofaceid-modal-header">\n <h2 class="neofaceid-title">${this.title??"Onboarding NeoFaceID"}</h2>\n <button class="neofaceid-close-btn" aria-label="Fechar">×</button>\n </div>\n <div class="neofaceid-modal-body">\n <p class="neofaceid-subtitle">${this.subtitle??"Vamos capturar sua face e documento"}</p>\n <div class="neofaceid-camera-container">\n <video class="neofaceid-video" autoplay muted playsinline></video>\n <canvas class="neofaceid-canvas"></canvas>\n <div class="neofaceid-overlay">\n <div class="neofaceid-frame"></div>\n <div class="neofaceid-countdown" style="display:none"><span class="neofaceid-countdown-number">${this.countdownSeconds}</span></div>\n </div>\n </div>\n <div class="neofaceid-status"><p class="neofaceid-status-text">Posicione seu rosto no quadro</p></div>\n </div>\n <div class="neofaceid-modal-footer">\n <button class="neofaceid-cancel-btn">Cancelar</button>\n <button class="neofaceid-capture-btn" disabled>Capturar</button>\n </div>\n <div class="neofaceid-seal-row">\n ${vd()}\n </div>\n </div>\n `,al(),il("neofaceid-onboarding-capture-styles","\n .neofaceid-root .neofaceid-modal-overlay { position: fixed; inset: 0; background: var(--nfid-overlay); display:flex; align-items:center; justify-content:center; z-index: 9999; }\n .neofaceid-root .neofaceid-modal { background: var(--nfid-surface); border-radius: var(--nfid-radius, 16px); width: 92%; max-width: 640px; box-shadow: 0 1px 3px rgba(10,19,32,.08); overflow:hidden; }\n .neofaceid-root .neofaceid-modal-header { padding: 16px 20px; border-bottom: 1px solid var(--nfid-line); display:flex; align-items:center; justify-content:space-between; }\n .neofaceid-root .neofaceid-title { margin:0; font-size: 20px; color: var(--nfid-text); }\n .neofaceid-root .neofaceid-close-btn { background:none; border:none; font-size:24px; cursor:pointer; color: var(--nfid-text-muted); min-width: 44px; min-height: 44px; }\n .neofaceid-root .neofaceid-modal-body { padding: 16px 20px; }\n .neofaceid-root .neofaceid-subtitle { margin: 0 0 12px 0; color: var(--nfid-text-muted); }\n .neofaceid-root .neofaceid-camera-container { position: relative; background:#000; border-radius:8px; overflow:hidden; aspect-ratio: 4/3; margin-bottom: 12px; }\n .neofaceid-root .neofaceid-video { width:100%; height:100%; object-fit: cover; }\n .neofaceid-root .neofaceid-canvas { position:absolute; top:0; left:0; }\n .neofaceid-root .neofaceid-overlay { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; }\n .neofaceid-root .neofaceid-frame { width: 200px; height: 200px; border: 3px solid #0E9F6E; border-radius: 50%; box-shadow: 0 0 0 2px rgba(14,159,110,0.3); }\n .neofaceid-root .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-root .neofaceid-modal-footer { padding: 16px 20px; border-top: 1px solid var(--nfid-line); display:flex; gap: 8px; justify-content:flex-end; }\n .neofaceid-root .neofaceid-cancel-btn { background: var(--nfid-surface-muted); color: var(--nfid-text-muted); border:none; border-radius:8px; padding:10px 18px; cursor:pointer; min-height: 44px; }\n .neofaceid-root .neofaceid-capture-btn { background: var(--nfid-action); color: var(--nfid-action-text); border:none; border-radius:8px; padding:10px 18px; cursor:pointer; min-height: 44px; }\n .neofaceid-root .neofaceid-capture-btn:disabled { background: var(--nfid-line); cursor:not-allowed; }\n .neofaceid-root .neofaceid-seal-row { display:flex; justify-content:center; padding:12px 20px 14px; border-top: 1px solid var(--nfid-line); }\n .neofaceid-root .neofaceid-seal { font-size:10px; font-weight:500; letter-spacing:0.06em; text-transform:uppercase; color: var(--nfid-text-subtle); }\n "),e.classList.add("neofaceid-root"),document.body.appendChild(e),this.overlay=e,this.video=this.overlay.querySelector(".neofaceid-video"),this.canvas=this.overlay.querySelector(".neofaceid-canvas");const n=this.overlay.querySelector(".neofaceid-close-btn"),t=this.overlay.querySelector(".neofaceid-cancel-btn");n.onclick=()=>this.close(),t.onclick=()=>this.close();this.overlay.querySelector(".neofaceid-capture-btn").disabled=!0}async startCamera(){if(!this.video)throw new Error("Elemento de vídeo não encontrado");this.video.muted=!0,this.video.playsInline=!0;try{this.stream=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:{ideal:1280},height:{ideal:720}},audio:!1})}catch{this.stream=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user"},audio:!1})}this.video.srcObject=this.stream,await this.video.play(),this.autoLighting&&!this.flashController&&(this.flashController=Fu((()=>this.video)),this.flashController.start())}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 r=setInterval((()=>{o-=1,n.textContent=String(o),o<=0&&(clearInterval(r),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"),r=this.overlay.querySelector(".neofaceid-frame");t.textContent=e,o.textContent=n,"document"===this.step&&(r.style.borderRadius="8px",r.style.width="280px",r.style.height="180px")}async close(){this.flashController&&(this.flashController.destroy(),this.flashController=null),this.stream&&(this.stream.getTracks().forEach((e=>e.stop())),this.stream=null),this.overlay&&(this.overlay.remove(),this.overlay=null)}}const Uu=[{tip:8,pip:6},{tip:12,pip:10},{tip:16,pip:14},{tip:20,pip:18}],Vu=(e,n)=>Math.hypot(e.x-n.x,e.y-n.y);function Ku(e){if(e.length<21)return!1;const n=e[0],t=e[2],o=e[4];return!!(Vu(o,n)>1.3*Vu(t,n))&&Uu.every((({tip:t,pip:o})=>{const r=e[t],a=e[o];return Vu(r,n)<Vu(a,n)}))}let Zu=null;function Hu(){return Zu||(Zu=async function(){const e=await import("@tensorflow-models/hand-pose-detection");return e.createDetector(e.SupportedModels.MediaPipeHands,{runtime:"mediapipe",modelType:"lite",maxHands:1,solutionPath:"https://cdn.jsdelivr.net/npm/@mediapipe/hands@0.4.1675469240"})}()),Zu}const Gu=e=>new Promise((n=>{setTimeout(n,e)}));async function Ju(e,n){const t=await Hu(),o=Date.now()+n;for(;Date.now()<o;){const n=await t.estimateHands(e,{flipHorizontal:!0});if(n.length>0&&Ku(n[0].keypoints))return!0;await Gu(150)}return!1}const Xu=["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"];function Yu({size:e=96,color:n,strokeWidth:t,glow:r=!1,className:a,style:i}){const s=t??function(e){return e<=24?2:e<=48?2.5:3.4}(e),c=.28*e,l=s/2,d=[{x:l,y:l,dx:1,dy:1},{x:e-l,y:l,dx:-1,dy:1},{x:l,y:e-l,dx:1,dy:-1},{x:e-l,y:e-l,dx:-1,dy:-1}];return o.jsx("svg",{width:e,height:e,viewBox:`0 0 ${e} ${e}`,xmlns:"http://www.w3.org/2000/svg",className:a,style:{color:n??`var(${Yc})`,filter:r?"drop-shadow(0 0 6px rgba(0,176,248,.5))":void 0,...i},"aria-hidden":"true",children:d.map(((e,n)=>o.jsx("path",{d:`M ${e.x+e.dx*c} ${e.y} L ${e.x} ${e.y} L ${e.x} ${e.y+e.dy*c}`,fill:"none",stroke:"currentColor",strokeWidth:s,strokeLinecap:"round"},n)))})}function Qu({progress:e,size:n=268,children:t,className:r,style:a}){const i=Math.max(0,Math.min(1,Number.isFinite(e)?e:0)),s=n/2-4.2,c=2*Math.PI*s,l=c*(1-i),d=n+24;return o.jsxs("div",{className:r,style:{position:"relative",width:d,height:d,display:"inline-flex",alignItems:"center",justifyContent:"center",...a},children:[o.jsx("div",{style:{position:"absolute",inset:0},children:o.jsx(Yu,{size:d,glow:!0})}),o.jsx("div",{style:{position:"relative",width:n,height:n,borderRadius:"50%",overflow:"hidden",background:"linear-gradient(160deg, #274B6E, #0F2438, #05080F)"},children:t}),o.jsxs("svg",{width:n,height:n,viewBox:`0 0 ${n} ${n}`,style:{position:"absolute",top:(d-n)/2,left:(d-n)/2,transform:"rotate(-90deg)",pointerEvents:"none"},"aria-hidden":"true",children:[o.jsx("defs",{children:o.jsxs("linearGradient",{id:"nfid-challenge-arc",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[o.jsx("stop",{offset:"0%",stopColor:"#00B0F8"}),o.jsx("stop",{offset:"100%",stopColor:"#0073F4"})]})}),o.jsx("circle",{cx:n/2,cy:n/2,r:s,stroke:"rgba(255,255,255,0.18)",strokeWidth:4.2,fill:"none"}),o.jsx("circle",{cx:n/2,cy:n/2,r:s,stroke:`var(${Yc}, url(#nfid-challenge-arc))`,strokeWidth:4.2,strokeLinecap:"round",strokeDasharray:c,strokeDashoffset:l,fill:"none",style:{transition:"stroke-dashoffset 200ms ease-out"}})]})]})}function ep({gesture:e,size:n=48,color:t,className:r,style:a}){return o.jsxs("svg",{width:n,height:n,viewBox:"0 0 48 48",xmlns:"http://www.w3.org/2000/svg",className:r,style:{color:t??`var(${Yc})`,...a},role:"img","aria-label":np[e],children:["blink"===e?o.jsx(op,{stroke:3.4}):o.jsx(tp,{stroke:3.4}),"blink"!==e&&"center"!==e&&o.jsx(rp,{gesture:e,stroke:3.4})]})}const np={center:"Centralize o rosto",turn_right:"Vire o rosto para a direita",turn_left:"Vire o rosto para a esquerda",look_up:"Olhe para cima",look_down:"Olhe para baixo",blink:"Pisque os olhos",move_closer:"Aproxime-se da câmera"};function tp({stroke:e}){return o.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:e,strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M14 20c0-5.5 4.5-10 10-10s10 4.5 10 10v4c0 5.5-4.5 10-10 10s-10-4.5-10-10v-4z"}),o.jsx("circle",{cx:"20",cy:"22",r:"1.2",fill:"currentColor",stroke:"none"}),o.jsx("circle",{cx:"28",cy:"22",r:"1.2",fill:"currentColor",stroke:"none"}),o.jsx("path",{d:"M21 28c1 1 2 1.5 3 1.5s2-.5 3-1.5"})]})}function op({stroke:e}){return o.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:e,strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M8 24c4-4 8-6 16-6s12 2 16 6"}),o.jsx("path",{d:"M12 26v3"}),o.jsx("path",{d:"M18 27v3.5"}),o.jsx("path",{d:"M24 27.5v4"}),o.jsx("path",{d:"M30 27v3.5"}),o.jsx("path",{d:"M36 26v3"})]})}function rp({gesture:e,stroke:n}){const[t,r,a]=function(e){switch(e){case"turn_right":return["40 18","44 24","40 30"];case"turn_left":return["8 18","4 24","8 30"];case"look_up":return["18 8","24 4","30 8"];case"look_down":case"move_closer":return["18 40","24 44","30 40"];default:return["24 24","24 24","24 24"]}}(e);return o.jsx("path",{d:`M ${t} L ${r} L ${a}`,fill:"none",stroke:"currentColor",strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round"})}const ap={title:"Não deu certo desta vez",hint:"Tente se posicionar em um ambiente mais estável.",actions:["Segure o dispositivo firme","Fique de frente para uma luz suave"]},ip={LIVENESS_LOW:{title:"Precisamos ver com mais nitidez",hint:"A prova de vida veio abaixo do esperado.",actions:["Faça o movimento com calma até o fim","Aproxime o rosto sem cortar as bordas"]},NO_FACE_DETECTED:{title:"Não vi seu rosto",hint:"A câmera não conseguiu identificar um rosto na moldura.",actions:["Centralize o rosto no oval","Afaste-se um pouco se estiver muito próximo"]},LOW_LIGHT:{title:"A luz está baixa demais",hint:"Falta contraste para o algoritmo distinguir seu rosto.",actions:["Fique de frente para uma janela ou lâmpada","Evite luz vindo por trás — deixa o rosto em sombra"]},LOOK_STRAIGHT:{title:"Olhe direto para a câmera",hint:"O rosto está um pouco de lado para reconhecimento facial.",actions:["Fique de frente para a câmera","Mantenha o queixo paralelo ao chão"]},RECOGNITION_FAILED:{title:"Não consegui confirmar",hint:"A imagem não bate com o cadastro que temos.",actions:["Retire óculos ou máscara temporariamente","Faça em um lugar mais iluminado"]},INVALID_TOKEN:{title:"Sessão expirada",hint:"A conexão com o serviço perdeu validade.",actions:["Volte à tela anterior e tente novamente","Se persistir, entre em contato com o suporte"]},NETWORK:{title:"A conexão está oscilando",hint:"A imagem não chegou até nosso servidor.",actions:["Verifique a rede do dispositivo","Repita a captura em alguns segundos"]}};const sp={chrome:"Clique no cadeado da barra de endereço → Configurações do site → Câmera → Permitir. Recarregue a página.",edge:"Clique no cadeado da barra de endereço → Permissões do site → Câmera → Permitir. Recarregue a página.",firefox:'Clique no ícone da câmera bloqueada na barra de endereço e escolha "Permitir". Recarregue a página.',safari:"Menu Safari → Configurações → Sites → Câmera → Permitir para este site. Recarregue a página.",unknown:'Abra as configurações do navegador, procure por "câmera" e permita o acesso para este site. Depois recarregue a página.'};function cp(){n.useEffect((()=>{al(),il("neofaceid-state-views-styles",'\n.neofaceid-root .nfid-state {\n display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;\n padding: 8px 8px 4px;\n}\n.neofaceid-root .nfid-state h2 {\n margin: 6px 0 0; font-size: 20px; font-weight: 700; color: var(--nfid-text); line-height: 1.25;\n letter-spacing: -0.015em;\n}\n.neofaceid-root .nfid-state p {\n margin: 0; font-size: 14px; color: var(--nfid-text-muted); line-height: 1.5;\n}\n.neofaceid-root .nfid-state-actions {\n display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 12px;\n}\n.neofaceid-root .nfid-state-actions--row {\n flex-direction: row; justify-content: center;\n}\n.neofaceid-root .nfid-state-icon-success {\n width: 64px; height: 64px; color: #0E9F6E;\n animation: nfidCelebrate 500ms cubic-bezier(.2,1.4,.4,1) both;\n}\n@keyframes nfidCelebrate {\n 0% { transform: scale(0.6); opacity: 0; }\n 60% { transform: scale(1.08); opacity: 1; }\n 100% { transform: scale(1); }\n}\n.neofaceid-root .nfid-state-warn-icon { width: 56px; height: 56px; color: #F1BE00; }\n.neofaceid-root .nfid-state-cameraoff-icon { width: 56px; height: 56px; color: var(--nfid-text-muted); }\n.neofaceid-root .nfid-state-hints {\n display: flex; flex-direction: column; gap: 6px; margin-top: 8px; text-align: left; width: 100%;\n}\n.neofaceid-root .nfid-state-hint {\n display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--nfid-text);\n padding: 8px 12px; background: var(--nfid-surface-muted); border-radius: 12px;\n}\n.neofaceid-root .nfid-state-hint::before { content: "•"; color: var(--nfid-action); font-weight: 700; }\n.neofaceid-root .nfid-state-attempt {\n font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;\n color: var(--nfid-text-subtle);\n}\n.neofaceid-root .nfid-state-techcode {\n font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n font-size: 11px; color: var(--nfid-text-subtle); margin-top: 8px;\n}\n')}),[])}function lp({appName:e,onContinue:n}){return cp(),o.jsxs("div",{className:"nfid-state",role:"status","aria-live":"polite",children:[o.jsxs("svg",{className:"nfid-state-icon-success",viewBox:"0 0 64 64",fill:"none",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("circle",{cx:"32",cy:"32",r:"28"}),o.jsx("path",{d:"M20 33 L28 41 L44 24"})]}),o.jsx("h2",{children:"Identidade confirmada"}),o.jsxs("p",{children:["Você já pode continuar no ",e,"."]}),o.jsx("div",{className:"nfid-state-actions",children:o.jsx(ru,{variant:"primary",onClick:n,children:"Continuar"})})]})}function dp({errorCode:e,attempt:n,maxAttempts:t,timestamp:r,onRetry:a,onFallback:i}){cp();const s=function(e){if(!e)return ap;const n=e.toUpperCase();return ip[n]??ap}(e),c=r??new Date;return o.jsxs("div",{className:"nfid-state",role:"alert","aria-live":"assertive",children:[o.jsxs(au,{tone:"attention",children:["Tentativa ",n," de ",t]}),o.jsxs("svg",{className:"nfid-state-warn-icon",viewBox:"0 0 64 64",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("path",{d:"M32 8 L58 54 H6 Z"}),o.jsx("path",{d:"M32 26 V38"}),o.jsx("circle",{cx:"32",cy:"45",r:"2",fill:"currentColor"})]}),o.jsx("h2",{children:s.title}),o.jsx("p",{children:s.hint}),o.jsxs("div",{className:"nfid-state-hints","aria-label":"O que fazer",children:[o.jsx("div",{className:"nfid-state-hint",children:s.actions[0]}),o.jsx("div",{className:"nfid-state-hint",children:s.actions[1]})]}),o.jsxs("div",{className:"nfid-state-actions",children:[o.jsx(ru,{variant:"primary",onClick:a,children:"Tentar de novo"}),o.jsx(ru,{variant:"ghost",onClick:i,children:"Verificar de outro jeito"})]}),o.jsxs("p",{className:"nfid-state-techcode",children:[(e??"UNKNOWN").toUpperCase()," · ",(l=c,`${String(l.getHours()).padStart(2,"0")}:${String(l.getMinutes()).padStart(2,"0")}:${String(l.getSeconds()).padStart(2,"0")}`)]})]});var l}function up({browser:e,onFallback:n,onCancel:t}){cp();const r=function(e){return sp[e]}(e??function(e=navigator.userAgent){const n=e.toLowerCase();return n.includes("edg/")?"edge":n.includes("firefox")?"firefox":n.includes("chrome")&&!n.includes("edg/")?"chrome":n.includes("safari")&&!n.includes("chrome")?"safari":"unknown"}());return o.jsxs("div",{className:"nfid-state",role:"alert","aria-live":"assertive",children:[o.jsxs("svg",{className:"nfid-state-cameraoff-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("path",{d:"m3 3 18 18"}),o.jsx("path",{d:"M20.66 15.34A2 2 0 0 0 22 13.5V7.5a2 2 0 0 0-3.13-1.65L15 8.5"}),o.jsx("path",{d:"M9 6H4a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-1"})]}),o.jsx("h2",{children:"Câmera bloqueada"}),o.jsx("p",{children:"Precisamos da câmera para confirmar que é você."}),o.jsx("p",{style:{marginTop:8},children:r}),o.jsxs("div",{className:"nfid-state-actions",children:[o.jsx(ru,{variant:"primary",onClick:n,children:"Verificar de outro jeito"}),o.jsx(ru,{variant:"ghost",onClick:t,children:"Agora não"})]})]})}const pp={center:"center",turn_right:"turn_right",turn_left:"turn_left",look_up:"look_up",look_down:"look_down",blink:"blink",move_closer:"move_closer",smile:"blink",open_mouth:"blink"},fp={center:"Centralize seu rosto no oval",turn_right:"Vire lentamente o rosto para a direita",turn_left:"Vire lentamente o rosto para a esquerda",look_up:"Olhe para cima",look_down:"Olhe para baixo",blink:"Pisque os olhos",move_closer:"Aproxime-se da câmera",smile:"Sorria para a câmera",open_mouth:"Abra a boca"};function hp({applicationToken:e,appName:t,amount:r,onChallengeStart:a,onChallengeComplete:i,onSuccess:s,onError:c,onCancel:l,autoLighting:d=!0,onClose:u}){const p=n.useRef(null),[f,h]=n.useState(0),[m,g]=n.useState(null),[v,w]=n.useState("preparing"),[b,x]=n.useState(1),[y,_]=n.useState(void 0),[k,E]=n.useState(void 0),[T,N]=n.useState(0),S=n.useRef(!1),[C,I]=n.useState(!1),{flashOn:R}=td(p,{enabled:d&&!C&&"challenging"===v}),O=wl(),j=t??gl()??"sua aplicação",A="number"==typeof r&&Number.isFinite(r)?function(e,n){try{return new Intl.NumberFormat(n,{style:"currency",currency:"BRL"}).format(e)}catch{return`R$ ${e.toFixed(2)}`}}(r,O):null;n.useEffect((()=>{al(),il("neofaceid-authorize-styles","\n .neofaceid-root .nfid-authorize-header { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }\n .neofaceid-root .nfid-authorize-appname { font-size: 15px; font-weight: 700; color: var(--nfid-text); line-height: 1.2; }\n .neofaceid-root .nfid-authorize-amount { font-size: 13px; color: var(--nfid-text-muted); }\n .neofaceid-root .nfid-authorize-brand { font-size: 10px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--nfid-text-subtle); }\n .neofaceid-root .nfid-authorize-video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }\n .neofaceid-root .nfid-authorize-instruction { margin: 20px 0 0; font-size: 17px; font-weight: 600; color: var(--nfid-text); text-align: center; line-height: 1.3; }\n .neofaceid-root .nfid-authorize-support { margin: 6px 0 0; font-size: 13px; color: var(--nfid-text-muted); text-align: center; }\n .neofaceid-root .nfid-authorize-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; align-items: center; }\n .neofaceid-root .nfid-authorize-footer { display: flex; justify-content: center; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--nfid-line); }\n .neofaceid-root .nfid-authorize-seal { font-size: 10px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--nfid-text-subtle); }\n .neofaceid-root .nfid-authorize-close {\n position: absolute; top: 8px; right: 8px;\n min-width: 44px; min-height: 44px;\n background: transparent; border: none;\n display: inline-flex; align-items: center; justify-content: center;\n color: var(--nfid-text-muted); cursor: pointer; border-radius: 22px;\n }\n .neofaceid-root .nfid-authorize-close:hover { background: var(--nfid-surface-muted); }\n .neofaceid-root .nfid-authorize-close:focus-visible { outline: 2px solid var(--nfid-focus-ring); outline-offset: 2px; }\n @media (prefers-reduced-motion: reduce) {\n .neofaceid-root svg circle { transition: none !important; }\n }\n ")}),[]),n.useEffect((()=>{let n=null;return S.current=!1,w("preparing"),h(0),g(null),async function(){try{try{n=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:{ideal:1280},height:{ideal:720}}})}catch(t){const e=function(e){if(!e||"object"!=typeof e)return"UNKNOWN";const n=(e.name??"").toString();return"NotAllowedError"===n||"SecurityError"===n?"PERMISSION_DENIED":"NotFoundError"===n||"OverconstrainedError"===n?"NO_CAMERA":"NotReadableError"===n||"TrackStartError"===n?"IN_USE":"UNKNOWN"}(t);if("PERMISSION_DENIED"===e)return void w("permission-denied");throw new io("NO_CAMERA"===e?"Câmera não encontrada":"IN_USE"===e?"Câmera em uso por outro app":"Falha ao acessar a câmera",ao.CAMERA_ERROR)}p.current&&(p.current.srcObject=n,p.current.play().catch((()=>{}))),w("challenging");const o=await Wu({applicationToken:e,purpose:"authorization",collectFramesForGesture:async(e,n,t)=>{if(S.current)throw new io("Cancelado",ao.UNKNOWN);g(e),h(0),a&&a(e,n,t),await async function(e){const n=1500,t=Date.now();return new Promise((o=>{const r=()=>{const a=Date.now()-t,i=Math.min(1,a/n);e(i),a>=n?o():setTimeout(r,50)};r()}))}(h),i&&i(e,n,t);const o=await async function(e){if(!e||0===e.videoWidth)return null;const n=document.createElement("canvas");n.width=e.videoWidth,n.height=e.videoHeight;const t=n.getContext("2d");return t?(t.drawImage(e,0,0),n.toDataURL("image/jpeg",.85)):null}(p.current);return o?[o]:[]}});n&&n.getTracks().forEach((e=>e.stop())),n=null,w("success"),s&&s(o)}catch(o){if(S.current)return;const e=o instanceof io?o:new io(o instanceof Error?o.message:"Falha",ao.UNKNOWN);_(e.type),E(new Date),w("failure"),c&&c(e)}finally{n&&n.getTracks().forEach((e=>e.stop()))}}(),()=>{S.current=!0,n&&n.getTracks().forEach((e=>e.stop()))}}),[T]);const P=()=>{S.current=!0,l&&l(),u()},F=()=>{b>=3?P():(x((e=>e+1)),_(void 0),E(void 0),N((e=>e+1)))},z=()=>{S.current=!0,c&&c(new io("Fluxo alternativo solicitado pelo usuário",ao.CONSENT_DENIED)),u()},$=m?pp[m.gesture_key]??"center":"center",D=m?fp[m.gesture_key]??"Siga a instrução":"Preparando a câmera…";return"success"===v?o.jsx(Xd,{open:!0,dismissOnOverlay:!1,ariaLabel:"Identidade confirmada",children:o.jsx(lp,{appName:j,onContinue:u})}):"permission-denied"===v?o.jsx(Xd,{open:!0,dismissOnOverlay:!1,ariaLabel:"Câmera bloqueada",children:o.jsx(up,{onFallback:z,onCancel:P})}):"failure"===v?o.jsx(Xd,{open:!0,dismissOnOverlay:!1,ariaLabel:"Não foi possível confirmar",children:o.jsx(dp,{errorCode:y,attempt:b,maxAttempts:3,timestamp:k,onRetry:F,onFallback:z})}):o.jsxs(Xd,{open:!0,onDismiss:void 0,dismissOnOverlay:!1,ariaLabel:"Autorização por biometria",children:[o.jsx(od,{active:R,onDismiss:()=>I(!0)}),o.jsxs("div",{style:{position:"relative"},children:[o.jsx("button",{type:"button",className:"nfid-authorize-close",onClick:P,"aria-label":"Cancelar autorização",children:o.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:o.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})}),o.jsxs("div",{className:"nfid-authorize-header",children:[o.jsx("span",{className:"nfid-authorize-appname",children:j}),A&&o.jsxs("span",{className:"nfid-authorize-amount",children:["Autorizando ",A]}),o.jsx("span",{className:"nfid-authorize-brand",children:"NeoFaceID"})]}),o.jsx("div",{style:{display:"flex",justifyContent:"center"},children:o.jsx(Qu,{progress:f,size:220,children:o.jsx("video",{ref:p,className:"nfid-authorize-video",autoPlay:!0,muted:!0,playsInline:!0})})}),o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:12,marginTop:16},children:[o.jsx(ep,{gesture:$,size:40}),o.jsx("p",{className:"nfid-authorize-instruction","aria-live":"assertive",style:{margin:0},children:D})]}),"preparing"===v&&o.jsx("p",{className:"nfid-authorize-support",children:"Ligando sua câmera…"}),o.jsx("div",{className:"nfid-authorize-actions",children:o.jsx(ru,{variant:"ghost",onClick:P,children:"Não consigo fazer esse movimento"})}),o.jsx("div",{className:"nfid-authorize-footer",children:o.jsx(gd,{})})]})]})}const mp={RG:{name:"Documento de Identidade (RG / CIN / CPF)",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 Documento",backLabel:"Verso do Documento"},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:"Cartão CPF (Apenas Frente)",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 gp{constructor(e){l(this,"overlay",null),l(this,"video",null),l(this,"canvas",null),l(this,"stream",null),l(this,"resolvePromise",null),l(this,"options"),l(this,"selectedDocument",null),l(this,"currentStep","select"),l(this,"flashController",null),l(this,"frontBlob",null),l(this,"backBlob",null),l(this,"_previewObjectUrl",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(){if(!this.options.skipConsent){if(!(await Gd({appName:this.options.appName,flow:"verification"})))throw new io("Consentimento recusado pelo usuário.",ao.CONSENT_DENIED)}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");e.className="neoface-doc-overlay",e.innerHTML='\n <div class="neoface-doc-modal">\n <div class="neoface-doc-content"></div>\n </div>\n ',al(),il("neoface-doc-styles-v2",this.getStyles()),e.classList.add("neofaceid-root"),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(mp).filter((([e])=>"CPF"!==e)).map((([e,n])=>`\n <button class="neoface-doc-select-option" data-type="${e}">\n <span class="neoface-doc-select-icon">${n.icon}</span>\n <span class="neoface-doc-select-name">${n.name}</span>\n <svg class="neoface-doc-select-arrow" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg>\n </button>\n `)).join("")}\n </div>\n \n <div class="neoface-doc-tips">\n <div class="neoface-doc-tip">\n <span>Garanta boa iluminação e que todos os dados estejam legíveis</span>\n </div>\n </div>\n </div>\n \n ${this.renderBranding()}\n `}renderCaptureStep(){const e=this.selectedDocument?mp[this.selectedDocument]:null;if(!e)return"";const n="back"===this.currentStep,t=n?e.backLabel:e.frontLabel;return`\n <div class="neoface-doc-header">\n <div class="neoface-doc-header-left">\n <div class="neoface-doc-step-indicator">\n <span class="neoface-doc-step-badge">${n?2:1}/${e.hasBack?2:1}</span>\n <span class="neoface-doc-step-label">${t}</span>\n </div>\n </div>\n <button class="neoface-doc-close-btn" aria-label="Fechar">\n <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M18 6L6 18M6 6l12 12"/>\n </svg>\n </button>\n </div>\n \n <div class="neoface-doc-body">\n <div class="neoface-doc-camera-container">\n <video class="neoface-doc-video" autoplay muted playsinline></video>\n <canvas class="neoface-doc-canvas"></canvas>\n \n <div class="neoface-doc-guide">\n <div class="neoface-doc-frame">\n <div class="neoface-doc-corner neoface-doc-corner-tl"></div>\n <div class="neoface-doc-corner neoface-doc-corner-tr"></div>\n <div class="neoface-doc-corner neoface-doc-corner-bl"></div>\n <div class="neoface-doc-corner neoface-doc-corner-br"></div>\n <div class="neoface-doc-frame-label">${t}</div>\n </div>\n </div>\n \n <div class="neoface-doc-loading" style="display:none">\n <div class="neoface-doc-spinner"></div>\n </div>\n </div>\n \n <div class="neoface-doc-instructions">\n <div class="neoface-doc-instruction">\n <svg class="neoface-doc-instruction-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18M9 21V9"/></svg>\n <span>Posicione o documento dentro do quadro</span>\n </div>\n <div class="neoface-doc-instruction">\n <svg class="neoface-doc-instruction-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="5"/><path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"/></svg>\n <span>Sem reflexo do flash sobre o texto</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?mp[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" alt="Prévia do documento capturado" />\n </div>\n\n <h3 class="neoface-doc-preview-question" id="neoface-doc-preview-question">Está legível?</h3>\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>Confira se dá para ler nome, número e data sem esforço.</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-primary 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?"Sim, enviar":"Sim, próximo"}\n </button>\n </div>\n \n ${this.renderBranding()}\n `}renderBranding(){return`\n <div class="neoface-doc-branding">\n ${vd()}\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 r=null==(e=this.overlay)?void 0:e.querySelector(".neoface-doc-capture-btn"),a=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==r||r.addEventListener("click",(()=>this.handleCapture())),null==a||a.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 r=null==(t=this.overlay)?void 0:t.querySelector(".neoface-doc-loading");r&&(r.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(a){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 xl(e,(e=>new Promise(((n,t)=>{const o=new Image;o.onload=()=>{const e=1280;let{width:r}=o,{height:a}=o;r>a&&r>e?(a=a*e/r,r=e):a>e&&(r=r*e/a,a=e);const i=document.createElement("canvas");i.width=r,i.height=a;const s=i.getContext("2d");s?(s.drawImage(o,0,0,r,a),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=e}))))}bindPreviewEvents(){var e,n,t;const o=null==(e=this.overlay)?void 0:e.querySelector(".neoface-doc-confirm-btn"),r=null==(n=this.overlay)?void 0:n.querySelector(".neoface-doc-retake-btn");null==o||o.addEventListener("click",(()=>this.handleConfirm())),null==r||r.addEventListener("click",(()=>this.handleRetake()));const a=null==(t=this.overlay)?void 0:t.querySelector(".neoface-doc-preview-current");if(a){const e="preview-front"===this.currentStep?this.frontBlob:this.backBlob;e&&(this._previewObjectUrl&&(URL.revokeObjectURL(this._previewObjectUrl),this._previewObjectUrl=null),this._previewObjectUrl=URL.createObjectURL(e),a.src=this._previewObjectUrl)}this.bindCloseEvent()}bindCloseEvent(){var e;const n=null==(e=this.overlay)?void 0:e.querySelector(".neoface-doc-close-btn");null==n||n.addEventListener("click",(()=>this.handleCancel()))}async startCamera(){var e,n,t;try{const t={video:{facingMode:this.options.useBackCamera?"environment":"user",width:{ideal:1920},height:{ideal:1080}},audio:!1};this.stream=await navigator.mediaDevices.getUserMedia(t),this.video=null==(e=this.overlay)?void 0:e.querySelector(".neoface-doc-video"),this.canvas=null==(n=this.overlay)?void 0:n.querySelector(".neoface-doc-canvas"),this.video&&(this.video.muted=!0,this.video.playsInline=!0,this.video.srcObject=this.stream,await this.video.play(),this.startScreenFlash())}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(),this.startScreenFlash())}catch(r){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.flashController&&(this.flashController.destroy(),this.flashController=null),this.stream&&(this.stream.getTracks().forEach((e=>e.stop())),this.stream=null)}startScreenFlash(){!1!==this.options.autoLighting&&(this.flashController||(this.flashController=Fu((()=>this.video)),this.flashController.start()))}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{videoWidth:o}=this.video,{videoHeight:r}=this.video,a=Math.floor(.75*o),i=Math.floor(.65*r),s=Math.floor((o-a)/2),c=Math.floor((r-i)/2);this.canvas.width=a,this.canvas.height=i,t.drawImage(this.video,s,c,a,i,0,0,a,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(l){}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?mp[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._previewObjectUrl&&(URL.revokeObjectURL(this._previewObjectUrl),this._previewObjectUrl=null),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: inherit;\n padding: 16px;\n }\n \n .neoface-doc-modal {\n background: linear-gradient(145deg, #0A1320 0%, #111C2B 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, #0091F6, #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, 145, 246, 0.1);\n border-color: rgba(0, 145, 246, 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, 145, 246, 0.15);\n border-radius: 12px;\n color: #0091F6;\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: #0091F6;\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, 145, 246, 0.08);\n border: 1px solid rgba(0, 145, 246, 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: #0091F6;\n flex-shrink: 0;\n }\n \n /* Camera — ISO/IEC 7810 ID-1 (85.60 × 53.98 mm ≈ 1.586:1) */\n .neoface-doc-camera-container {\n position: relative;\n background: #000;\n border-radius: 16px;\n overflow: hidden;\n aspect-ratio: 1.586 / 1;\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 /* Moldura Focus Frame — proporção ID-1 (1.586:1), sem borda contínua. */\n .neoface-doc-frame {\n width: 82%;\n aspect-ratio: 1.586 / 1;\n position: relative;\n border-radius: 12px;\n }\n\n .neoface-doc-corner {\n position: absolute;\n width: 28px;\n height: 28px;\n border-color: var(--nfid-action, #0059C4);\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: #0091F6;\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: #0091F6;\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, 145, 246, 0.3);\n box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);\n }\n \n .neoface-doc-preview-question {\n margin: 12px 0 4px;\n font-size: 17px;\n font-weight: 700;\n color: var(--nfid-text, #0A1320);\n text-align: center;\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, 145, 246, 0.08);\n border: 1px solid rgba(0, 145, 246, 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: #0091F6;\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, #0091F6 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, 145, 246, 0.4);\n }\n \n .neoface-doc-btn-success {\n background: linear-gradient(135deg, #0E9F6E 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: #0091F6;\n letter-spacing: 1px;\n }\n \n /* Mobile */\n @media (max-width: 500px) {\n .neoface-doc-modal {\n border-radius: 20px;\n }\n \n .neoface-doc-header,\n .neoface-doc-body,\n .neoface-doc-footer {\n padding: 16px 18px;\n }\n \n .neoface-doc-preview-grid.has-back {\n grid-template-columns: 1fr;\n }\n }\n "}}const vp=async e=>new gp(e).open(),wp=Object.freeze(Object.defineProperty({__proto__:null,DocumentCaptureModal:gp,startDocumentCapture:vp},Symbol.toStringTag,{value:"Module"})),bp="Consentimento recusado pelo usuário.";const xp=function(e,n){let t=e;const o=Tp[n];let r=null,a=0,i=null;const s=[],c={},l=function(e,n){a=4*t+17,r=function(e){const n=new Array(e);for(let t=0;t<e;t+=1){n[t]=new Array(e);for(let o=0;o<e;o+=1)n[t][o]=null}return n}(a),d(0,0),d(a-7,0),d(0,a-7),p(),u(),h(e,n),t>=7&&f(e),null==i&&(i=g(t,o,s)),m(i,n)},d=function(e,n){for(let t=-1;t<=7;t+=1)if(!(e+t<=-1||a<=e+t))for(let o=-1;o<=7;o+=1)n+o<=-1||a<=n+o||(r[e+t][n+o]=0<=t&&t<=6&&(0==o||6==o)||0<=o&&o<=6&&(0==t||6==t)||2<=t&&t<=4&&2<=o&&o<=4)},u=function(){for(let e=8;e<a-8;e+=1)null==r[e][6]&&(r[e][6]=e%2==0);for(let e=8;e<a-8;e+=1)null==r[6][e]&&(r[6][e]=e%2==0)},p=function(){const e=Pp.getPatternPosition(t);for(let n=0;n<e.length;n+=1)for(let t=0;t<e.length;t+=1){const o=e[n],a=e[t];if(null==r[o][a])for(let e=-2;e<=2;e+=1)for(let n=-2;n<=2;n+=1)r[o+e][a+n]=-2==e||2==e||-2==n||2==n||0==e&&0==n}},f=function(e){const n=Pp.getBCHTypeNumber(t);for(let t=0;t<18;t+=1){const o=!e&&1==(n>>t&1);r[Math.floor(t/3)][t%3+a-8-3]=o}for(let t=0;t<18;t+=1){const o=!e&&1==(n>>t&1);r[t%3+a-8-3][Math.floor(t/3)]=o}},h=function(e,n){const t=o<<3|n,i=Pp.getBCHTypeInfo(t);for(let o=0;o<15;o+=1){const n=!e&&1==(i>>o&1);o<6?r[o][8]=n:o<8?r[o+1][8]=n:r[a-15+o][8]=n}for(let o=0;o<15;o+=1){const n=!e&&1==(i>>o&1);o<8?r[8][a-o-1]=n:o<9?r[8][15-o-1+1]=n:r[8][15-o-1]=n}r[a-8][8]=!e},m=function(e,n){let t=-1,o=a-1,i=7,s=0;const c=Pp.getMaskFunction(n);for(let l=a-1;l>0;l-=2)for(6==l&&(l-=1);;){for(let n=0;n<2;n+=1)if(null==r[o][l-n]){let t=!1;s<e.length&&(t=1==(e[s]>>>i&1));c(o,l-n)&&(t=!t),r[o][l-n]=t,i-=1,-1==i&&(s+=1,i=7)}if(o+=t,o<0||a<=o){o-=t,t=-t;break}}},g=function(e,n,t){const o=$p.getRSBlocks(e,n),r=Dp();for(let i=0;i<t.length;i+=1){const n=t[i];r.put(n.getMode(),4),r.put(n.getLength(),Pp.getLengthInBits(n.getMode(),e)),n.write(r)}let a=0;for(let i=0;i<o.length;i+=1)a+=o[i].dataCount;if(r.getLengthInBits()>8*a)throw"code length overflow. ("+r.getLengthInBits()+">"+8*a+")";for(r.getLengthInBits()+4<=8*a&&r.put(0,4);r.getLengthInBits()%8!=0;)r.putBit(!1);for(;!(r.getLengthInBits()>=8*a||(r.put(236,8),r.getLengthInBits()>=8*a));)r.put(17,8);return function(e,n){let t=0,o=0,r=0;const a=new Array(n.length),i=new Array(n.length);for(let d=0;d<n.length;d+=1){const s=n[d].dataCount,c=n[d].totalCount-s;o=Math.max(o,s),r=Math.max(r,c),a[d]=new Array(s);for(let n=0;n<a[d].length;n+=1)a[d][n]=255&e.getBuffer()[n+t];t+=s;const l=Pp.getErrorCorrectPolynomial(c),u=zp(a[d],l.getLength()-1).mod(l);i[d]=new Array(l.getLength()-1);for(let e=0;e<i[d].length;e+=1){const n=e+u.getLength()-i[d].length;i[d][e]=n>=0?u.getAt(n):0}}let s=0;for(let d=0;d<n.length;d+=1)s+=n[d].totalCount;const c=new Array(s);let l=0;for(let d=0;d<o;d+=1)for(let e=0;e<n.length;e+=1)d<a[e].length&&(c[l]=a[e][d],l+=1);for(let d=0;d<r;d+=1)for(let e=0;e<n.length;e+=1)d<i[e].length&&(c[l]=i[e][d],l+=1);return c}(r,o)};c.addData=function(e,n){let t=null;switch(n=n||"Byte"){case"Numeric":t=Mp(e);break;case"Alphanumeric":t=Lp(e);break;case"Byte":t=Bp(e);break;case"Kanji":t=Wp(e);break;default:throw"mode:"+n}s.push(t),i=null},c.isDark=function(e,n){if(e<0||a<=e||n<0||a<=n)throw e+","+n;return r[e][n]},c.getModuleCount=function(){return a},c.make=function(){if(t<1){let e=1;for(;e<40;e++){const n=$p.getRSBlocks(e,o),t=Dp();for(let o=0;o<s.length;o++){const n=s[o];t.put(n.getMode(),4),t.put(n.getLength(),Pp.getLengthInBits(n.getMode(),e)),n.write(t)}let r=0;for(let e=0;e<n.length;e++)r+=n[e].dataCount;if(t.getLengthInBits()<=8*r)break}t=e}l(!1,function(){let e=0,n=0;for(let t=0;t<8;t+=1){l(!0,t);const o=Pp.getLostPoint(c);(0==t||e>o)&&(e=o,n=t)}return n}())},c.createTableTag=function(e,n){e=e||2;let t="";t+='<table style="',t+=" border-width: 0px; border-style: none;",t+=" border-collapse: collapse;",t+=" padding: 0px; margin: "+(n=void 0===n?4*e:n)+"px;",t+='">',t+="<tbody>";for(let o=0;o<c.getModuleCount();o+=1){t+="<tr>";for(let n=0;n<c.getModuleCount();n+=1)t+='<td style="',t+=" border-width: 0px; border-style: none;",t+=" border-collapse: collapse;",t+=" padding: 0px; margin: 0px;",t+=" width: "+e+"px;",t+=" height: "+e+"px;",t+=" background-color: ",t+=c.isDark(o,n)?"#000000":"#ffffff",t+=";",t+='"/>';t+="</tr>"}return t+="</tbody>",t+="</table>",t},c.createSvgTag=function(e,n,t,o){let r={};"object"==typeof arguments[0]&&(r=arguments[0],e=r.cellSize,n=r.margin,t=r.alt,o=r.title),e=e||2,n=void 0===n?4*e:n,(t="string"==typeof t?{text:t}:t||{}).text=t.text||null,t.id=t.text?t.id||"qrcode-description":null,(o="string"==typeof o?{text:o}:o||{}).text=o.text||null,o.id=o.text?o.id||"qrcode-title":null;const a=c.getModuleCount()*e+2*n;let i,s,l,d,u,p="";for(u="l"+e+",0 0,"+e+" -"+e+",0 0,-"+e+"z ",p+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',p+=r.scalable?"":' width="'+a+'px" height="'+a+'px"',p+=' viewBox="0 0 '+a+" "+a+'" ',p+=' preserveAspectRatio="xMinYMin meet"',p+=o.text||t.text?' role="img" aria-labelledby="'+v([o.id,t.id].join(" ").trim())+'"':"",p+=">",p+=o.text?'<title id="'+v(o.id)+'">'+v(o.text)+"</title>":"",p+=t.text?'<description id="'+v(t.id)+'">'+v(t.text)+"</description>":"",p+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',p+='<path d="',l=0;l<c.getModuleCount();l+=1)for(d=l*e+n,i=0;i<c.getModuleCount();i+=1)c.isDark(l,i)&&(s=i*e+n,p+="M"+s+","+d+u);return p+='" stroke="transparent" fill="black"/>',p+="</svg>",p},c.createDataURL=function(e,n){e=e||2,n=void 0===n?4*e:n;const t=c.getModuleCount()*e+2*n,o=n,r=t-n;return Vp(t,t,(function(n,t){if(o<=n&&n<r&&o<=t&&t<r){const r=Math.floor((n-o)/e),a=Math.floor((t-o)/e);return c.isDark(a,r)?0:1}return 1}))},c.createImgTag=function(e,n,t){e=e||2,n=void 0===n?4*e:n;const o=c.getModuleCount()*e+2*n;let r="";return r+="<img",r+=' src="',r+=c.createDataURL(e,n),r+='"',r+=' width="',r+=o,r+='"',r+=' height="',r+=o,r+='"',t&&(r+=' alt="',r+=v(t),r+='"'),r+="/>",r};const v=function(e){let n="";for(let t=0;t<e.length;t+=1){const o=e.charAt(t);switch(o){case"<":n+="&lt;";break;case">":n+="&gt;";break;case"&":n+="&amp;";break;case'"':n+="&quot;";break;default:n+=o}}return n};return c.createASCII=function(e,n){if((e=e||1)<2)return function(e){e=void 0===e?2:e;const n=1*c.getModuleCount()+2*e,t=e,o=n-e;let r,a,i,s,l;const d={"██":"█","█ ":"▀"," █":"▄"," ":" "},u={"██":"▀","█ ":"▀"," █":" "," ":" "};let p="";for(r=0;r<n;r+=2){for(i=Math.floor((r-t)/1),s=Math.floor((r+1-t)/1),a=0;a<n;a+=1)l="█",t<=a&&a<o&&t<=r&&r<o&&c.isDark(i,Math.floor((a-t)/1))&&(l=" "),t<=a&&a<o&&t<=r+1&&r+1<o&&c.isDark(s,Math.floor((a-t)/1))?l+=" ":l+="█",p+=e<1&&r+1>=o?u[l]:d[l];p+="\n"}return n%2&&e>0?p.substring(0,p.length-n-1)+Array(n+1).join("▀"):p.substring(0,p.length-1)}(n);e-=1,n=void 0===n?2*e:n;const t=c.getModuleCount()*e+2*n,o=n,r=t-n;let a,i,s,l;const d=Array(e+1).join("██"),u=Array(e+1).join(" ");let p="",f="";for(a=0;a<t;a+=1){for(s=Math.floor((a-o)/e),f="",i=0;i<t;i+=1)l=1,o<=i&&i<r&&o<=a&&a<r&&c.isDark(s,Math.floor((i-o)/e))&&(l=0),f+=l?d:u;for(s=0;s<e;s+=1)p+=f+"\n"}return p.substring(0,p.length-1)},c.renderTo2dContext=function(e,n){n=n||2;const t=c.getModuleCount();for(let o=0;o<t;o++)for(let r=0;r<t;r++)e.fillStyle=c.isDark(o,r)?"black":"white",e.fillRect(r*n,o*n,n,n)},c};xp.stringToBytes=function(e){const n=[];for(let t=0;t<e.length;t+=1){const o=e.charCodeAt(t);n.push(255&o)}return n},xp.createStringToBytes=function(e,n){const t=function(){const t=Up(e),o=function(){const e=t.read();if(-1==e)throw"eof";return e};let r=0;const a={};for(;;){const e=t.read();if(-1==e)break;const n=o(),i=o()<<8|o();a[String.fromCharCode(e<<8|n)]=i,r+=1}if(r!=n)throw r+" != "+n;return a}(),o="?".charCodeAt(0);return function(e){const n=[];for(let r=0;r<e.length;r+=1){const a=e.charCodeAt(r);if(a<128)n.push(a);else{const a=t[e.charAt(r)];"number"==typeof a?(255&a)==a?n.push(a):(n.push(a>>>8),n.push(255&a)):n.push(o)}}return n}};const yp=1,_p=2,kp=4,Ep=8,Tp={L:1,M:0,Q:3,H:2},Np=0,Sp=1,Cp=2,Ip=3,Rp=4,Op=5,jp=6,Ap=7,Pp=function(){const e=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],n=1335,t=7973,o={},r=function(e){let n=0;for(;0!=e;)n+=1,e>>>=1;return n};return o.getBCHTypeInfo=function(e){let t=e<<10;for(;r(t)-r(n)>=0;)t^=n<<r(t)-r(n);return 21522^(e<<10|t)},o.getBCHTypeNumber=function(e){let n=e<<12;for(;r(n)-r(t)>=0;)n^=t<<r(n)-r(t);return e<<12|n},o.getPatternPosition=function(n){return e[n-1]},o.getMaskFunction=function(e){switch(e){case Np:return function(e,n){return(e+n)%2==0};case Sp:return function(e,n){return e%2==0};case Cp:return function(e,n){return n%3==0};case Ip:return function(e,n){return(e+n)%3==0};case Rp:return function(e,n){return(Math.floor(e/2)+Math.floor(n/3))%2==0};case Op:return function(e,n){return e*n%2+e*n%3==0};case jp:return function(e,n){return(e*n%2+e*n%3)%2==0};case Ap:return function(e,n){return(e*n%3+(e+n)%2)%2==0};default:throw"bad maskPattern:"+e}},o.getErrorCorrectPolynomial=function(e){let n=zp([1],0);for(let t=0;t<e;t+=1)n=n.multiply(zp([1,Fp.gexp(t)],0));return n},o.getLengthInBits=function(e,n){if(1<=n&&n<10)switch(e){case yp:return 10;case _p:return 9;case kp:case Ep:return 8;default:throw"mode:"+e}else if(n<27)switch(e){case yp:return 12;case _p:return 11;case kp:return 16;case Ep:return 10;default:throw"mode:"+e}else{if(!(n<41))throw"type:"+n;switch(e){case yp:return 14;case _p:return 13;case kp:return 16;case Ep:return 12;default:throw"mode:"+e}}},o.getLostPoint=function(e){const n=e.getModuleCount();let t=0;for(let r=0;r<n;r+=1)for(let o=0;o<n;o+=1){let a=0;const i=e.isDark(r,o);for(let t=-1;t<=1;t+=1)if(!(r+t<0||n<=r+t))for(let s=-1;s<=1;s+=1)o+s<0||n<=o+s||0==t&&0==s||i==e.isDark(r+t,o+s)&&(a+=1);a>5&&(t+=3+a-5)}for(let r=0;r<n-1;r+=1)for(let o=0;o<n-1;o+=1){let n=0;e.isDark(r,o)&&(n+=1),e.isDark(r+1,o)&&(n+=1),e.isDark(r,o+1)&&(n+=1),e.isDark(r+1,o+1)&&(n+=1),0!=n&&4!=n||(t+=3)}for(let r=0;r<n;r+=1)for(let o=0;o<n-6;o+=1)e.isDark(r,o)&&!e.isDark(r,o+1)&&e.isDark(r,o+2)&&e.isDark(r,o+3)&&e.isDark(r,o+4)&&!e.isDark(r,o+5)&&e.isDark(r,o+6)&&(t+=40);for(let r=0;r<n;r+=1)for(let o=0;o<n-6;o+=1)e.isDark(o,r)&&!e.isDark(o+1,r)&&e.isDark(o+2,r)&&e.isDark(o+3,r)&&e.isDark(o+4,r)&&!e.isDark(o+5,r)&&e.isDark(o+6,r)&&(t+=40);let o=0;for(let r=0;r<n;r+=1)for(let t=0;t<n;t+=1)e.isDark(t,r)&&(o+=1);return t+=10*(Math.abs(100*o/n/n-50)/5),t},o}(),Fp=function(){const e=new Array(256),n=new Array(256);for(let o=0;o<8;o+=1)e[o]=1<<o;for(let o=8;o<256;o+=1)e[o]=e[o-4]^e[o-5]^e[o-6]^e[o-8];for(let o=0;o<255;o+=1)n[e[o]]=o;const t={glog:function(e){if(e<1)throw"glog("+e+")";return n[e]},gexp:function(n){for(;n<0;)n+=255;for(;n>=256;)n-=255;return e[n]}};return t}(),zp=function(e,n){if(void 0===e.length)throw e.length+"/"+n;const t=function(){let t=0;for(;t<e.length&&0==e[t];)t+=1;const o=new Array(e.length-t+n);for(let n=0;n<e.length-t;n+=1)o[n]=e[n+t];return o}(),o={getAt:function(e){return t[e]},getLength:function(){return t.length},multiply:function(e){const n=new Array(o.getLength()+e.getLength()-1);for(let t=0;t<o.getLength();t+=1)for(let r=0;r<e.getLength();r+=1)n[t+r]^=Fp.gexp(Fp.glog(o.getAt(t))+Fp.glog(e.getAt(r)));return zp(n,0)},mod:function(e){if(o.getLength()-e.getLength()<0)return o;const n=Fp.glog(o.getAt(0))-Fp.glog(e.getAt(0)),t=new Array(o.getLength());for(let r=0;r<o.getLength();r+=1)t[r]=o.getAt(r);for(let o=0;o<e.getLength();o+=1)t[o]^=Fp.gexp(Fp.glog(e.getAt(o))+n);return zp(t,0).mod(e)}};return o},$p=function(){const e=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],n=function(e,n){const t={};return t.totalCount=e,t.dataCount=n,t},t={};return t.getRSBlocks=function(t,o){const r=function(n,t){switch(t){case Tp.L:return e[4*(n-1)+0];case Tp.M:return e[4*(n-1)+1];case Tp.Q:return e[4*(n-1)+2];case Tp.H:return e[4*(n-1)+3];default:return}}(t,o);if(void 0===r)throw"bad rs block @ typeNumber:"+t+"/errorCorrectionLevel:"+o;const a=r.length/3,i=[];for(let e=0;e<a;e+=1){const t=r[3*e+0],o=r[3*e+1],a=r[3*e+2];for(let e=0;e<t;e+=1)i.push(n(o,a))}return i},t}(),Dp=function(){const e=[];let n=0;const t={getBuffer:function(){return e},getAt:function(n){const t=Math.floor(n/8);return 1==(e[t]>>>7-n%8&1)},put:function(e,n){for(let o=0;o<n;o+=1)t.putBit(1==(e>>>n-o-1&1))},getLengthInBits:function(){return n},putBit:function(t){const o=Math.floor(n/8);e.length<=o&&e.push(0),t&&(e[o]|=128>>>n%8),n+=1}};return t},Mp=function(e){const n=yp,t=e,o={getMode:function(){return n},getLength:function(e){return t.length},write:function(e){const n=t;let o=0;for(;o+2<n.length;)e.put(r(n.substring(o,o+3)),10),o+=3;o<n.length&&(n.length-o==1?e.put(r(n.substring(o,o+1)),4):n.length-o==2&&e.put(r(n.substring(o,o+2)),7))}},r=function(e){let n=0;for(let t=0;t<e.length;t+=1)n=10*n+a(e.charAt(t));return n},a=function(e){if("0"<=e&&e<="9")return e.charCodeAt(0)-"0".charCodeAt(0);throw"illegal char :"+e};return o},Lp=function(e){const n=_p,t=e,o={getMode:function(){return n},getLength:function(e){return t.length},write:function(e){const n=t;let o=0;for(;o+1<n.length;)e.put(45*r(n.charAt(o))+r(n.charAt(o+1)),11),o+=2;o<n.length&&e.put(r(n.charAt(o)),6)}},r=function(e){if("0"<=e&&e<="9")return e.charCodeAt(0)-"0".charCodeAt(0);if("A"<=e&&e<="Z")return e.charCodeAt(0)-"A".charCodeAt(0)+10;switch(e){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+e}};return o},Bp=function(e){const n=kp,t=xp.stringToBytes(e),o={getMode:function(){return n},getLength:function(e){return t.length},write:function(e){for(let n=0;n<t.length;n+=1)e.put(t[n],8)}};return o},Wp=function(e){const n=Ep,t=xp.stringToBytes;!function(){const e=t("友");if(2!=e.length||38726!=(e[0]<<8|e[1]))throw"sjis not supported."}();const o=t(e),r={getMode:function(){return n},getLength:function(e){return~~(o.length/2)},write:function(e){const n=o;let t=0;for(;t+1<n.length;){let o=(255&n[t])<<8|255&n[t+1];if(33088<=o&&o<=40956)o-=33088;else{if(!(57408<=o&&o<=60351))throw"illegal char at "+(t+1)+"/"+o;o-=49472}o=192*(o>>>8&255)+(255&o),e.put(o,13),t+=2}if(t<n.length)throw"illegal char at "+(t+1)}};return r},qp=function(){const e=[],n={writeByte:function(n){e.push(255&n)},writeShort:function(e){n.writeByte(e),n.writeByte(e>>>8)},writeBytes:function(e,t,o){t=t||0,o=o||e.length;for(let r=0;r<o;r+=1)n.writeByte(e[r+t])},writeString:function(e){for(let t=0;t<e.length;t+=1)n.writeByte(e.charCodeAt(t))},toByteArray:function(){return e},toString:function(){let n="";n+="[";for(let t=0;t<e.length;t+=1)t>0&&(n+=","),n+=e[t];return n+="]",n}};return n},Up=function(e){const n=e;let t=0,o=0,r=0;const a={read:function(){for(;r<8;){if(t>=n.length){if(0==r)return-1;throw"unexpected end of file./"+r}const e=n.charAt(t);if(t+=1,"="==e)return r=0,-1;e.match(/^\s$/)||(o=o<<6|i(e.charCodeAt(0)),r+=6)}const e=o>>>r-8&255;return r-=8,e}},i=function(e){if(65<=e&&e<=90)return e-65;if(97<=e&&e<=122)return e-97+26;if(48<=e&&e<=57)return e-48+52;if(43==e)return 62;if(47==e)return 63;throw"c:"+e};return a},Vp=function(e,n,t){const o=function(e,n){const t=e,o=n,r=new Array(e*n),a={setPixel:function(e,n,o){r[n*t+e]=o},write:function(e){e.writeString("GIF87a"),e.writeShort(t),e.writeShort(o),e.writeByte(128),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(255),e.writeByte(255),e.writeByte(255),e.writeString(","),e.writeShort(0),e.writeShort(0),e.writeShort(t),e.writeShort(o),e.writeByte(0);const n=i(2);e.writeByte(2);let r=0;for(;n.length-r>255;)e.writeByte(255),e.writeBytes(n,r,255),r+=255;e.writeByte(n.length-r),e.writeBytes(n,r,n.length-r),e.writeByte(0),e.writeString(";")}},i=function(e){const n=1<<e,t=1+(1<<e);let o=e+1;const a=s();for(let r=0;r<n;r+=1)a.add(String.fromCharCode(r));a.add(String.fromCharCode(n)),a.add(String.fromCharCode(t));const i=qp(),c=function(e){const n=e;let t=0,o=0;return{write:function(e,r){if(e>>>r!=0)throw"length over";for(;t+r>=8;)n.writeByte(255&(e<<t|o)),r-=8-t,e>>>=8-t,o=0,t=0;o|=e<<t,t+=r},flush:function(){t>0&&n.writeByte(o)}}}(i);c.write(n,o);let l=0,d=String.fromCharCode(r[l]);for(l+=1;l<r.length;){const e=String.fromCharCode(r[l]);l+=1,a.contains(d+e)?d+=e:(c.write(a.indexOf(d),o),a.size()<4095&&(a.size()==1<<o&&(o+=1),a.add(d+e)),d=e)}return c.write(a.indexOf(d),o),c.write(t,o),c.flush(),i.toByteArray()},s=function(){const e={};let n=0;const t={add:function(o){if(t.contains(o))throw"dup key:"+o;e[o]=n,n+=1},size:function(){return n},indexOf:function(n){return e[n]},contains:function(n){return void 0!==e[n]}};return t};return a}(e,n);for(let s=0;s<n;s+=1)for(let n=0;n<e;n+=1)o.setPixel(n,s,t(n,s));const r=qp();o.write(r);const a=function(){let e=0,n=0,t=0,o="";const r={},a=function(e){o+=String.fromCharCode(i(63&e))},i=function(e){if(e<0)throw"n:"+e;if(e<26)return 65+e;if(e<52)return e-26+97;if(e<62)return e-52+48;if(62==e)return 43;if(63==e)return 47;throw"n:"+e};return r.writeByte=function(o){for(e=e<<8|255&o,n+=8,t+=1;n>=6;)a(e>>>n-6),n-=6},r.flush=function(){if(n>0&&(a(e<<6-n),e=0,n=0),t%3!=0){const e=3-t%3;for(let n=0;n<e;n+=1)o+="="}},r.toString=function(){return o},r}(),i=r.toByteArray();for(let s=0;s<i.length;s+=1)a.writeByte(i[s]);return a.flush(),"data:image/gif;base64,"+a},Kp=Object.freeze(Object.defineProperty({__proto__:null,default:xp,qrcode:xp},Symbol.toStringTag,{value:"Module"}));function Zp(e,n,t){const o=.299*e+.587*n+.114*t,r=-.169*e-.331*n+.5*t+128,a=.5*e-.419*n-.081*t+128;return o>80&&o<255&&r>85&&r<135&&a>135&&a<180}async function Hp(){if("undefined"==typeof window||!window.faceapi)return;const{faceapi:e}=window;if(!e.nets.tinyFaceDetector.isLoaded)try{await Promise.all([e.nets.tinyFaceDetector.loadFromUri("/models"),e.nets.faceLandmark68Net.loadFromUri("/models")])}catch(n){}}const Gp=Object.freeze(Object.defineProperty({__proto__:null,detectBiometricType:async function(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 r=n.startsWith("data:")?n:`data:image/jpeg;base64,${n}`;o.src=r}))),o=await async function(e){try{if("undefined"!=typeof window&&window.faceapi){const{faceapi:n}=window;await Hp();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 r=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 r=0,a=0;for(let d=0;d<n.length;d+=4){Zp(n[d],n[d+1],n[d+2])&&r++,a++}const i=r/a,s=t/o;let c=0;i>.15&&i<.7&&(c+=i/.7*.4);s>.6&&s<1.8&&(c+=.3);const l=t*o;l>1e4&&l<5e5&&(c+=.3);return{confidence:Math.min(c,.8),skinRatio:i,aspectRatio:s,imageSize:l,skinPixels:r,totalPixels:a}}(t.getImageData(0,0,n.width,n.height));return{confidence:o.confidence,details:o}}catch(n){return{confidence:0}}}(t);return r.confidence>.6?{type:"hand",confidence:r.confidence,details:r.details}:{type:"unknown",confidence:Math.max(o.confidence,r.confidence)}}catch(t){return{type:"face",confidence:.5}}var n},initializeBiometricDetection:async function(){try{"undefined"!=typeof window&&await Hp()}catch(e){}},isAdvancedDetectionAvailable:function(){return"undefined"!=typeof window&&window.faceapi&&window.faceapi.nets.tinyFaceDetector.isLoaded}},Symbol.toStringTag,{value:"Module"}));e.BiometricRegistrationModal=zd,e.BiometricStatusOverlay=class{constructor(){l(this,"container",null),l(this,"currentStatus","preparing")}getStyles(){return"\n @keyframes neofaceid-fadeIn {\n from { opacity: 0; transform: scale(0.9); }\n to { opacity: 1; transform: scale(1); }\n }\n\n @keyframes neofaceid-fadeOut {\n from { opacity: 1; transform: scale(1); }\n to { opacity: 0; transform: scale(0.9); }\n }\n\n @keyframes neofaceid-pulse {\n 0%, 100% { \n transform: scale(1);\n opacity: 1;\n }\n 50% { \n transform: scale(1.05);\n opacity: 0.9;\n }\n }\n\n @keyframes neofaceid-scaleIn {\n 0% { transform: scale(0); opacity: 0; }\n 50% { transform: scale(1.1); }\n 100% { transform: scale(1); opacity: 1; }\n }\n\n @keyframes neofaceid-errorShake {\n 0%, 100% { transform: translateX(0); }\n 10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }\n 20%, 40%, 60%, 80% { transform: translateX(4px); }\n }\n\n .neofaceid-overlay-container {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10000;\n pointer-events: none;\n animation: neofaceid-fadeIn 0.3s ease-out;\n font-family: inherit;\n }\n\n .neofaceid-overlay-container.fade-out {\n animation: neofaceid-fadeOut 0.3s ease-out forwards;\n }\n\n .neofaceid-overlay-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 24px;\n pointer-events: auto;\n }\n\n .neofaceid-visual-wrapper {\n position: relative;\n width: 100px;\n height: 100px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .neofaceid-logo {\n width: 80px;\n height: 80px;\n object-fit: contain;\n transition: all 0.5s ease;\n filter: drop-shadow(0 4px 12px rgba(0, 89, 196, 0.3));\n }\n\n /* Cores por estado */\n .neofaceid-state-preparing .neofaceid-logo { filter: drop-shadow(0 0 15px rgba(0, 89, 196, 0.4)); }\n .neofaceid-state-detecting .neofaceid-logo { filter: hue-rotate(180deg) drop-shadow(0 0 15px rgba(59, 130, 246, 0.6)); }\n .neofaceid-state-waiting-for-face .neofaceid-logo { filter: hue-rotate(30deg) drop-shadow(0 0 15px rgba(251, 146, 60, 0.6)); }\n .neofaceid-state-capturing .neofaceid-logo { filter: hue-rotate(45deg) drop-shadow(0 0 15px rgba(245, 158, 11, 0.6)); }\n .neofaceid-state-verifying .neofaceid-logo { filter: hue-rotate(90deg) drop-shadow(0 0 15px rgba(34, 197, 94, 0.6)); }\n\n .neofaceid-logo.pulsing {\n animation: neofaceid-pulse 2s ease-in-out infinite;\n }\n\n @keyframes neofaceid-dots {\n 0%, 20% { opacity: 0; transform: translateY(0); }\n 50% { opacity: 1; transform: translateY(-2px); }\n 80%, 100% { opacity: 0; transform: translateY(0); }\n }\n\n .neofaceid-status-text {\n font-size: 15px;\n font-weight: 500;\n color: #ffffff;\n text-align: center;\n padding: 10px 24px;\n background: rgba(15, 23, 42, 0.8);\n backdrop-filter: blur(8px);\n border-radius: 100px;\n box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);\n border: 1px solid rgba(255, 255, 255, 0.1);\n text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);\n animation: neofaceid-fadeIn 0.3s ease-out;\n display: flex;\n align-items: center;\n gap: 2px;\n }\n\n .neofaceid-dots {\n display: inline-flex;\n margin-left: 2px;\n }\n\n .neofaceid-dot {\n animation: neofaceid-dots 1.5s infinite;\n opacity: 0;\n }\n\n .neofaceid-dot:nth-child(2) { animation-delay: 0.2s; }\n .neofaceid-dot:nth-child(3) { animation-delay: 0.4s; }\n\n .neofaceid-status-icon {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .neofaceid-success-icon {\n width: 80px;\n height: 80px;\n color: #0E9F6E;\n animation: neofaceid-scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);\n }\n\n .neofaceid-error-icon {\n width: 80px;\n height: 80px;\n color: #ef4444;\n animation: neofaceid-errorShake 0.5s linear, neofaceid-scaleIn 0.4s ease-out;\n }\n "}getStatusText(){switch(this.currentStatus){case"preparing":return"Iniciando câmera";case"detecting":return"Posicione seu rosto";case"waiting-for-face":return"Aguardando rosto";case"capturing":return"Capturando";case"verifying":return"Verificando identidade";case"success":return"Identificado!";case"error":return"Falha na identificação";default:return""}}renderContent(){const e=["detecting","waiting-for-face","verifying"].includes(this.currentStatus),n=!["success","error"].includes(this.currentStatus),t="success"===this.currentStatus,o="error"===this.currentStatus,r=this.getStatusText(),a=["preparing","detecting","waiting-for-face","capturing","verifying"].includes(this.currentStatus);return`\n <style>${this.getStyles()}</style>\n <div class="neofaceid-overlay-container neofaceid-state-${this.currentStatus}">\n <div class="neofaceid-overlay-content">\n <div class="neofaceid-visual-wrapper">\n ${n?`<span class="neofaceid-logo ${e?"pulsing":""}" style="display:inline-flex;align-items:center;justify-content:center;color:currentColor;">${function(e=18){return`<span class="neoface-brand-mark" style="display:inline-flex;align-items:center;justify-content:center;width:${e}px;height:${e}px;color:currentColor;">${ld}</span>`}(48).replace("width:18px;height:18px","width:100%;height:100%")}</span>`:""}\n \n ${t?'\n <div class="neofaceid-status-icon">\n <svg class="neofaceid-success-icon" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="30" cy="30" r="28" stroke="currentColor" stroke-width="3" fill="none"/>\n <path d="M15 30 L25 40 L45 20" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" fill="none"/>\n </svg>\n </div>\n ':""}\n \n ${o?'\n <div class="neofaceid-status-icon">\n <svg class="neofaceid-error-icon" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="30" cy="30" r="28" stroke="currentColor" stroke-width="3" fill="none"/>\n <path d="M20 20 L40 40 M40 20 L20 40" stroke="currentColor" stroke-width="3" stroke-linecap="round"/>\n </svg>\n </div>\n ':""}\n </div>\n \n ${r?`\n <div class="neofaceid-status-text">\n ${r}${a?'\n <span class="neofaceid-dots">\n <span class="neofaceid-dot">.</span>\n <span class="neofaceid-dot">.</span>\n <span class="neofaceid-dot">.</span>\n </span>\n ':""}\n </div>\n `:""}\n </div>\n </div>\n `}show(e="preparing"){this.container?this.updateStatus(e):(this.container=document.createElement("div"),this.container.id="neofaceid-status-overlay",this.currentStatus=e,this.container.innerHTML=this.renderContent(),document.body.appendChild(this.container))}updateStatus(e){this.currentStatus=e,this.container&&(this.container.innerHTML=this.renderContent())}close(){if(this.container){const e=this.container.querySelector(".neofaceid-overlay-container");e&&e.classList.add("fade-out"),setTimeout((()=>{this.container&&document.body.contains(this.container)&&document.body.removeChild(this.container),this.container=null}),300)}}},e.CameraOvalGuide=Tu,e.ConsentModal=Hd,e.DEFAULT_CONSENT_INFO=Jd,e.DocumentCaptureModal=gp,e.ENVIRONMENT_URLS=ll,e.EmailPasswordModal=Cu,e.ErrorType=ao,e.FaceCaptureModal=cd,e.FallbackPrompt=Su,e.ForgotPasswordModal=wd,e.NeoFaceError=io,e.RELEASE_DATE="2026-09-23",e.VERSION=$d,e.authorize=async function(e){if(!(await Gd({appName:e.appName,flow:"verification"})))return void(e.onError&&e.onError(new io("Consentimento recusado",ao.CONSENT_DENIED)));const n=document.createElement("div");n.id="neofaceid-authorize-container",document.body.appendChild(n);const r=t.createRoot(n);r.render(o.jsx(hp,{...e,onClose:()=>{r.unmount(),document.body.contains(n)&&document.body.removeChild(n)}}))},e.authorizeOperation=async(e,n,t)=>{if(!e)throw new io("Application token is required",ao.VALIDATION_ERROR);if(!n)throw new io("CPF is required",ao.VALIDATION_ERROR);const o=n.replace(/\D/g,"");if(11!==o.length)throw new io("Invalid CPF format",ao.VALIDATION_ERROR);const r=[],a=(null==t?void 0:t.captureDelay)||2e3;if(!(await Gd({appName:null==t?void 0:t.appName,flow:"verification"})))throw new io("Consentimento recusado pelo usuário.",ao.CONSENT_DENIED);try{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new io("Camera not available",ao.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()}})),async function(e){const n=await Hu();try{await n.estimateHands(e,{})}catch{}}(i).catch((()=>{}));const s=Eu({stream:n,faceState:"centered",instruction:Xu[0]}),c=document.createElement("canvas");c.width=i.videoWidth,c.height=i.videoHeight;const l=c.getContext("2d");if(!l)throw s.close(),n.getTracks().forEach((e=>e.stop())),new io("Failed to get canvas context",ao.CAPTURE_ERROR);for(let e=0;e<4;e++){const o=Xu[e];s.update(n,"centered",o),(null==t?void 0:t.onProgress)&&t.onProgress(e+1,4,o);if(3===e){if(!(await Ju(i,5e3)))throw s.close(),n.getTracks().forEach((e=>e.stop())),r.length=0,new io("Polegar para cima não detectado dentro do tempo limite.",ao.GESTURE_NOT_DETECTED)}else e>0&&await new Promise((e=>setTimeout(e,a)));l.drawImage(i,0,0,c.width,c.height);const d=await new Promise(((e,n)=>{c.toBlob((t=>{t?e(t):n(new Error("Failed to capture photo"))}),"image/jpeg",.9)}));r.push(d),(null==t?void 0:t.onPhotoTaken)&&t.onPhotoTaken(e+1,d)}s.close(),n.getTracks().forEach((e=>e.stop()));const d=r[3],u={cpf:o,email:"",sessionId:`auth_${Date.now()}_${Math.random().toString(36).substring(7)}`},p=await Fl(d,e,"AUTHORIZATION",.8,void 0,u);if(!p.success)throw r.length=0,new io("Authorization failed: Person not recognized",ao.RECOGNITION_FAILED);return r.length=0,{success:!0,authorizationHash:u.sessionId,name:p.personName,birthDate:void 0,cpf:p.cpf||o,confidenceScore:p.confidenceScore,message:"Authorization successful"}}catch(i){if(i instanceof io)throw i;if(i instanceof Error)throw new io(i.message,ao.CAPTURE_ERROR);throw new io("Unknown error during authorization",ao.UNKNOWN)}},e.awaitPushApproval=function(e){return new Promise((n=>{const r=document.createElement("div");r.id="neofaceid-push-approval-container",document.body.appendChild(r);const a=t.createRoot(r);a.render(o.jsx(hu,{...e,onSettle:e=>{a.unmount(),document.body.contains(r)&&document.body.removeChild(r),n(e)}}))}))},e.captureFaceFrames=async function(e){const{numFrames:n,livenessCheck:t}=e;if(n<1||n>10)throw new io("Number of frames must be between 1 and 10",ao.VALIDATION_ERROR);try{const{captureFaceSilently:e}=await Promise.resolve().then((()=>Pu)),o=[];for(let r=0;r<n;r+=1)o.push(await e()),t&&r<n-1&&await new Promise((e=>{setTimeout(e,300)}));return o}catch(o){if(o instanceof io)throw o;throw new io(`Failed to capture face frames: ${o instanceof Error?o.message:"Unknown error"}`,ao.CAPTURE_ERROR)}},e.checkUserExistence=$l,e.clearConsentTrail=function(){try{"undefined"!=typeof window&&window.localStorage&&window.localStorage.removeItem(Dd)}catch{}},e.completeOnboarding=Il,e.completeOnboardingWithData=Rl,e.confirmPasswordReset=Ql,e.consumeSseStream=tu,e.getAccent=function(){return pl.accent},e.getAppName=gl,e.getApplicationToken=ml,e.getAutoFallback=vl,e.getBaseUrl=hl,e.getCachedCaptureSession=function(){return Du},e.getConfig=function(){return{...pl}},e.getConsent=bl,e.getConsentTrail=Md,e.getEnvironment=function(){return pl.environment},e.getLocale=wl,e.getRadius=function(){return pl.radius},e.getResolvedThemeMode=function(){var e;return(null==(e=pl.resolvedTheme)?void 0:e.mode)??("dark"===pl.theme?"dark":"light")},e.getTheme=function(){return pl.theme},e.identifyPerson=Wl,e.identifyPersonAsync=Xl,e.init=function(e={}){const{environment:n,baseUrl:t,applicationToken:o,appName:r,accent:a,radius:i,theme:s,locale:c,consent:l,autoFallback:u}=e;if(u&&(pl.autoFallback={toPhone:u.toPhone??dl.toPhone,toPassword:u.toPassword??dl.toPassword}),l?pl.consent=l:(pl.consent={...cl},fl||(fl=!0)),t)pl.baseUrl=t,pl.environment="custom";else if(n)ll[n]?(pl.baseUrl=ll[n],pl.environment=n):(pl.baseUrl=ll.sandbox,pl.environment="sandbox");else{const e=void 0!=={url:"undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:d&&"SCRIPT"===d.tagName.toUpperCase()&&d.src||new URL("neoface-id-sdk.umd.js",document.baseURI).href}&&(null==sl?void 0:sl.VITE_API_BASE_URL);e&&(pl.baseUrl=e,pl.environment="custom")}o&&(pl.applicationToken=o),r&&r.trim()&&(pl.appName=r.trim()),void 0!==i&&(ul.includes(i)?pl.radius=i:pl.radius=16),s&&(pl.theme=s),c&&(pl.locale=c),void 0!==a&&(pl.accent=a);const p=Uc({accent:pl.accent??void 0,radius:pl.radius,theme:pl.theme});pl.resolvedTheme=p,al({accent:pl.accent??void 0,radius:pl.radius,theme:pl.theme}),pl.initialized=!0},e.isInitialized=function(){return pl.initialized},e.loginWithBiometric=jl,e.loginWithEmail=Ml,e.openCaptureSession=Lu,e.preloadFaceDetectionModels=Ou,e.proofOfLife=async function(e={}){const{videoDurationMs:n=3e3,maxPollingAttempts:t=60,pollingIntervalMs:o=1e3,onRecordingProgress:r,onTaskStatusChange:a}=e,i=e.applicationToken??ml();if(!i)throw new io("proofOfLife exige applicationToken — passe nas opções ou em init({ applicationToken }).",ao.INVALID_TOKEN);try{const e=await Vl({durationMs:n,onProgress:r}),s=await Hl(e),c=await Zl(s,i);a&&a("processing",0);const l=await Kl(c.taskId,i,{maxAttempts:t,intervalMs:o,onStatusChange:a}),d={isLive:(null==l?void 0:l.is_live)||!1,livenessScore:(null==l?void 0:l.liveness_score)||0,faceRecognitionScore:(null==l?void 0:l.face_recognition_score)||0,combinedConfidence:(null==l?void 0:l.combined_confidence)||0,personId:null==l?void 0:l.person_id,personalData:(null==l?void 0:l.personal_data)||[],processingTime:(null==l?void 0:l.processing_time)||0,historyId:c.historyId,taskId:c.taskId};return l&&l.success?{...d,success:!0,message:"Proof of life verification successful"}:{...d,success:!1,error:(null==l?void 0:l.error)||"Verification failed",message:(null==l?void 0:l.message)||"Proof of life verification failed"}}catch(s){if(s instanceof io)throw s;throw new io(`Proof of life failed: ${s instanceof Error?s.message:"Unknown error"}`,ao.RECOGNITION_FAILED)}},e.recognize=Ol,e.recognizeBiometric=Al,e.recognizeByPurpose=Fl,e.recordConsent=Ld,e.refreshSession=Bl,e.registerApplication=Ul,e.registerBiometric=ql,e.registerDocumentByImage=async function(e,n,t={}){const{DocumentCaptureModal:o}=await Promise.resolve().then((()=>wp)),r=new o({useBackCamera:t.useBackCamera??!0,preSelectedDocument:t.preSelectedDocument}),a=await r.open();if(!a.success||!a.frontImage)throw new io("cancelled"===a.error?"Document capture was cancelled by the user":`Document capture failed: ${a.error??"unknown error"}`,ao.CAPTURE_ERROR);const i=[a.frontImage];return a.backImage&&i.push(a.backImage),Gl(e,n,i)},e.registerPersonWithBiometric=Dl,e.registerPersonWithoutFace=zl,e.requestConsent=Gd,e.requestDeviceEnrollmentToken=Ll,e.requestLivenessChallenge=Bu,e.requestLivenessChallengeWithSession=async function({applicationToken:e,purpose:n,sessionId:t}){let o=t??(await Lu({applicationToken:e,purpose:n})).session_id;try{return await Bu({sessionId:o,applicationToken:e})}catch(r){if(r instanceof io&&r.message.includes("410"))return Mu(),o=(await Lu({applicationToken:e,purpose:n})).session_id,Bu({sessionId:o,applicationToken:e});throw r}},e.requestPasswordReset=Yl,e.resetCaptureSession=Mu,e.runLivenessChallenge=Wu,e.simpleIdentification=Pl,e.start=function(e,o,r){Gd({appName:null==r?void 0:r.appName,flow:"verification"}).then((a=>{if(!a)return void o.onError(new io(bp,ao.CONSENT_DENIED));const i=document.createElement("div");i.id="neoface-modal-container",document.body.appendChild(i);const s=()=>{document.body.contains(i)&&document.body.removeChild(i)};Nl(e).then((()=>{const a=n.createElement(cd,{accessToken:e,onClose:s,onSuccess:e=>{s(),o.onSuccess({name:e.data.faceId,email:e.data.faceId,documentId:e.data.faceId})},onCannotGesture:null==r?void 0:r.onCannotGesture});t.createRoot(i).render(a)})).catch((e=>{s(),o.onError(e instanceof io?e:new io(e.message||"Failed to validate token",ao.INVALID_TOKEN))}))}))},e.startAutoLogin=async function(e){if(await Gd({appName:e.appName,flow:"verification"}))try{const n={mode:"auto",onSuccess:async(n,t)=>{try{const t=await fetch(n).then((e=>e.blob())),o=await jl(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 zu(n);await t.open()}catch(n){e.onError(new io(`Erro ao inicializar login automático: ${n.message}`,ao.INITIALIZATION_ERROR))}else e.onError(new io($u,ao.CONSENT_DENIED))},e.startBiometricRegistration=function(e,o,r,a){Gd({appName:null==a?void 0:a.appName,flow:"registration"}).then((i=>{if(!i)return void r.onError(new io(bp,ao.CONSENT_DENIED));const s=document.createElement("div");s.id="neoface-biometric-registration-container",document.body.appendChild(s);let c=null;const l=()=>{c&&(c.unmount(),c=null),document.body.contains(s)&&document.body.removeChild(s)};Nl(o).then((()=>{const i=n.createElement(zd,{personData:e,applicationToken:o,useRealApi:(null==a?void 0:a.useRealApi)??!0,onClose:l,onSuccess:e=>{l(),r.onSuccess(e)},onError:e=>{l(),r.onError(new io(e,ao.UNKNOWN))},onCannotGesture:null==a?void 0:a.onCannotGesture});c=t.createRoot(s),c.render(i)})).catch((e=>{l(),r.onError(e instanceof io?e:new io(e.message||"Failed to validate token",ao.INVALID_TOKEN))}))}))},e.startDeviceEnrollment=function(e){return new Promise(((n,r)=>{const a=document.createElement("div");a.id="neofaceid-device-enrollment-container",document.body.appendChild(a);const i=t.createRoot(a);let s=0;const c=()=>{i.unmount(),document.body.contains(a)&&document.body.removeChild(a)},l=()=>{i.render(o.jsx(ku,{...e,attempt:s,onSettle:e=>{c(),n(e)},onRetry:()=>{s+=1,l()},onFatal:e=>{c(),r(e)}}))};l()}))},e.startDocumentCapture=vp,e.startFaceLogin=async function(e){if(await Gd({appName:e.appName,flow:"verification"}))try{await Au({applicationToken:e.applicationToken,onSuccess:e.onSuccess,onError:e.onError,onAttemptError:e.onAttemptError,onFallbackRequest:e.onFallbackRequest||(()=>function(e){if(!vl().toPassword)return void e.onError(new io("Biometria não reconhecida e a queda automática para senha está desligada.",ao.LOGIN_FAILED));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 Cu(n).open()}(e)),onCancel:e.onCancel})}catch(n){e.onError(new io(`Erro ao inicializar login facial: ${n.message}`,ao.INITIALIZATION_ERROR))}else e.onError(new io($u,ao.CONSENT_DENIED))},e.startHandLogin=async function(e){if(await Gd({appName:e.appName,flow:"verification"}))try{const n={mode:"hand",onSuccess:async(n,t)=>{try{const t=await fetch(n).then((e=>e.blob())),o=await jl(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 zu(n);await t.open()}catch(n){e.onError(new io(`Erro ao inicializar login por mão: ${n.message}`,ao.INITIALIZATION_ERROR))}else e.onError(new io($u,ao.CONSENT_DENIED))},e.startLivenessCapture=function(e,o,r){Gd({appName:null==r?void 0:r.appName,flow:"verification"}).then((a=>{if(!a)return void o.onError(new io(bp,ao.CONSENT_DENIED));const i=document.createElement("div");i.id="neoface-liveness-capture-container",document.body.appendChild(i);let s=!1,c=null;const l=()=>{c&&(c.unmount(),c=null),document.body.contains(i)&&document.body.removeChild(i)},d=()=>{l(),!s&&o.onCancel&&o.onCancel()};Nl(e).then((()=>{const a=n.createElement(zd,{applicationToken:e,onClose:d,onPhotosCaptured:e=>{s=!0,o.onSuccess(e)},onError:e=>{l(),o.onError(new io(e,ao.UNKNOWN))},onCannotGesture:null==r?void 0:r.onCannotGesture});c=t.createRoot(i),c.render(a)})).catch((e=>{l(),o.onError(e instanceof io?e:new io(e.message||"Failed to validate token",ao.INVALID_TOKEN))}))}))},e.startOnboarding=async e=>{const{applicationToken:n,onboardingToken:t,countdown:o,title:r,subtitle:a,onSuccess:i,onError:s}=e;try{if(!(await Gd({appName:e.appName,flow:"registration"})))return void s(new io("Consentimento recusado pelo usuário.",ao.CONSENT_DENIED));const c=await Sl(n,t);if(!(null==c?void 0:c.is_valid))throw new io("Link de onboarding inválido ou expirado",ao.VALIDATION_ERROR);const l=new qu({countdown:o,title:r,subtitle:a}),{face:d,document:u}=await l.open();i({...await Il(n,t,d,u),details:c})}catch(c){if(c instanceof io)return void s(c);const e=(null==c?void 0:c.message)||"Erro desconhecido no onboarding";s(new io(e,ao.UNKNOWN))}},e.submitLivenessChallenge=async function({challengeId:e,sessionId:n,applicationToken:t,gestures:o}){if(!t)throw new io("applicationToken é obrigatório para submeter desafio",ao.INVALID_TOKEN);if(!n)throw new io("session_id é obrigatório para submeter desafio",ao.VALIDATION_ERROR);if(!Array.isArray(o)||0===o.length)throw new io("gestures[] vazio — nada para submeter",ao.VALIDATION_ERROR);const r=e?`${encodeURIComponent(e)}/submit/`:"submit/",a=`${hl()}/api/v1/auth/liveness/challenge/${r}`;let i;try{i=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json","X-App-Token":t},body:JSON.stringify({session_id:n,gestures:o})})}catch(l){const e=l instanceof Error?l.message:"Erro de rede";throw new io(`Falha de rede ao submeter desafio: ${e}`,ao.NETWORK)}if(401===i.status||403===i.status)throw new io("Token de aplicação inválido ou expirado",ao.INVALID_TOKEN);if(410===i.status)throw new io("Sessão ou desafio expirado (410) — reabrir sessão",ao.API_ERROR);if(!i.ok)throw new io(`Falha ao submeter desafio de liveness (${i.status})`,ao.API_ERROR);const s=await i.json().catch((()=>null)),c=(null==s?void 0:s.data)??s??{};return{success:(null==c?void 0:c.success)??!0,liveness_passed:null==c?void 0:c.liveness_passed,score:null==c?void 0:c.score,raw:s}},e.validateOnboardingToken=Cl,e.validateToken=Nl,e.withCaptureSession=async function(e,n){const t=Du??await Lu(e);try{return await n(t.session_id)}catch(o){if(o instanceof io&&o.message.includes("410")){Mu();return n((await Lu(e)).session_id)}throw o}},e.withSessionId=function(e){const n=Du;return n?{...e,session_id:n.session_id}:e},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));