simplify-captcha
Version:
A modern React CAPTCHA component library with advanced human verification
340 lines (291 loc) • 23.3 kB
JavaScript
(function(M,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],l):(M=typeof globalThis<"u"?globalThis:M||self,l(M.SimplifyCaptcha={},M.React))})(this,function(M,l){"use strict";var G={exports:{}},I={};/**
* @license React
* react-jsx-runtime.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var q;function re(){if(q)return I;q=1;var u=Symbol.for("react.transitional.element"),v=Symbol.for("react.fragment");function d(x,h,p){var m=null;if(p!==void 0&&(m=""+p),h.key!==void 0&&(m=""+h.key),"key"in h){p={};for(var j in h)j!=="key"&&(p[j]=h[j])}else p=h;return h=p.ref,{$$typeof:u,type:x,key:m,ref:h!==void 0?h:null,props:p}}return I.Fragment=v,I.jsx=d,I.jsxs=d,I}var L={};/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var ee;function ae(){return ee||(ee=1,process.env.NODE_ENV!=="production"&&function(){function u(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===F?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case O:return"Fragment";case T:return"Profiler";case W:return"StrictMode";case Y:return"Suspense";case U:return"SuspenseList";case K:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case X:return"Portal";case z:return(e.displayName||"Context")+".Provider";case Q:return(e._context.displayName||"Context")+".Consumer";case Z:var a=e.render;return e=e.displayName,e||(e=a.displayName||a.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case D:return a=e.displayName||null,a!==null?a:u(e.type)||"Memo";case w:a=e._payload,e=e._init;try{return u(e(a))}catch{}}return null}function v(e){return""+e}function d(e){try{v(e);var a=!1}catch{a=!0}if(a){a=console;var r=a.error,n=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return r.call(a,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",n),v(e)}}function x(e){if(e===O)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===w)return"<...>";try{var a=u(e);return a?"<"+a+">":"<...>"}catch{return"<...>"}}function h(){var e=B.A;return e===null?null:e.getOwner()}function p(){return Error("react-stack-top-frame")}function m(e){if(H.call(e,"key")){var a=Object.getOwnPropertyDescriptor(e,"key").get;if(a&&a.isReactWarning)return!1}return e.key!==void 0}function j(e,a){function r(){J||(J=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",a))}r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}function P(){var e=u(this.type);return s[e]||(s[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function R(e,a,r,n,t,c,f,E){return r=c.ref,e={$$typeof:C,type:e,key:a,props:c,_owner:t},(r!==void 0?r:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:P}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:f}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:E}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function _(e,a,r,n,t,c,f,E){var i=a.children;if(i!==void 0)if(n)if($(i)){for(n=0;n<i.length;n++)N(i[n]);Object.freeze&&Object.freeze(i)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else N(i);if(H.call(a,"key")){i=u(e);var b=Object.keys(a).filter(function(de){return de!=="key"});n=0<b.length?"{key: someKey, "+b.join(": ..., ")+": ...}":"{key: someKey}",A[i+n]||(b=0<b.length?"{"+b.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
let props = %s;
<%s {...props} />
React keys must be passed directly to JSX without using spread:
let props = %s;
<%s key={someKey} {...props} />`,n,i,b,i),A[i+n]=!0)}if(i=null,r!==void 0&&(d(r),i=""+r),m(a)&&(d(a.key),i=""+a.key),"key"in a){r={};for(var S in a)S!=="key"&&(r[S]=a[S])}else r=a;return i&&j(r,typeof e=="function"?e.displayName||e.name||"Unknown":e),R(e,i,c,t,h(),r,f,E)}function N(e){typeof e=="object"&&e!==null&&e.$$typeof===C&&e._store&&(e._store.validated=1)}var y=l,C=Symbol.for("react.transitional.element"),X=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),W=Symbol.for("react.strict_mode"),T=Symbol.for("react.profiler"),Q=Symbol.for("react.consumer"),z=Symbol.for("react.context"),Z=Symbol.for("react.forward_ref"),Y=Symbol.for("react.suspense"),U=Symbol.for("react.suspense_list"),D=Symbol.for("react.memo"),w=Symbol.for("react.lazy"),K=Symbol.for("react.activity"),F=Symbol.for("react.client.reference"),B=y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,H=Object.prototype.hasOwnProperty,$=Array.isArray,V=console.createTask?console.createTask:function(){return null};y={"react-stack-bottom-frame":function(e){return e()}};var J,s={},k=y["react-stack-bottom-frame"].bind(y,p)(),g=V(x(p)),A={};L.Fragment=O,L.jsx=function(e,a,r,n,t){var c=1e4>B.recentlyCreatedOwnerStacks++;return _(e,a,r,!1,n,t,c?Error("react-stack-top-frame"):k,c?V(x(e)):g)},L.jsxs=function(e,a,r,n,t){var c=1e4>B.recentlyCreatedOwnerStacks++;return _(e,a,r,!0,n,t,c?Error("react-stack-top-frame"):k,c?V(x(e)):g)}}()),L}var te;function ce(){return te||(te=1,process.env.NODE_ENV==="production"?G.exports=re():G.exports=ae()),G.exports}var o=ce();const ie=`
/* SimplifyCaptcha Styles */
.sc-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.7);
display: flex;
justify-content: center;
align-items: flex-start;
padding-top: 50px;
z-index: 9999;
}
.sc-container {
background-color: #1a1a1a;
border-radius: 15px;
padding: 20px;
width: 85%;
max-width: 400px;
border: 1px solid #48d1cc;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.sc-text-captcha-container {
display: flex;
flex-direction: column;
align-items: stretch;
}
.sc-title {
font-size: 18px;
font-weight: bold;
color: #ffffff;
margin-bottom: 8px;
text-align: center;
}
.sc-subtitle {
font-size: 14px;
color: #b0b0b0;
margin-bottom: 20px;
text-align: center;
}
.sc-captcha-container {
margin-bottom: 20px;
position: relative;
}
.sc-captcha-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
}
.sc-captcha-text {
font-family: 'Courier New', monospace;
font-size: 28px;
font-weight: bold;
color: #48d1cc;
text-decoration: line-through;
letter-spacing: 8px;
text-align: center;
user-select: none;
background: linear-gradient(45deg, #48d1cc, #20b2aa);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
flex: 1;
padding: 10px 0;
}
.sc-refresh-button {
background: none;
border: none;
cursor: pointer;
padding: 8px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
transition: background-color 0.2s;
}
.sc-refresh-button:hover {
background-color: rgba(72, 209, 204, 0.1);
}
.sc-refresh-button:active {
transform: scale(0.95);
}
.sc-input-section {
margin-bottom: 20px;
}
.sc-input-label {
font-size: 14px;
color: #ffffff;
margin-bottom: 8px;
display: block;
}
.sc-input {
width: 100%;
padding: 12px;
font-size: 16px;
border: 2px solid #333;
border-radius: 8px;
background-color: #2a2a2a;
color: #ffffff;
transition: border-color 0.2s;
box-sizing: border-box;
}
.sc-input:focus {
outline: none;
border-color: #48d1cc;
}
.sc-button-container {
display: flex;
gap: 10px;
justify-content: flex-end;
}
.sc-button {
padding: 10px 20px;
font-size: 14px;
border: none;
border-radius: 8px;
cursor: pointer;
font-weight: bold;
transition: background-color 0.2s, transform 0.1s;
}
.sc-button:active {
transform: scale(0.98);
}
.sc-verify-button {
background-color: #48d1cc;
color: #000000;
}
.sc-verify-button:hover {
background-color: #40c7c4;
}
.sc-verify-button:disabled {
background-color: #666;
color: #999;
cursor: not-allowed;
}
.sc-verify-button:disabled:hover {
background-color: #666;
}
.sc-cancel-button {
background-color: #666;
color: #ffffff;
}
.sc-cancel-button:hover {
background-color: #777;
}
.sc-attempts-text {
font-size: 12px;
color: #ff6b6b;
text-align: center;
margin-top: 10px;
}
/* Animation classes */
.sc-fade-in {
animation: scFadeIn 0.3s ease-out;
}
.sc-fade-out {
animation: scFadeOut 0.3s ease-in;
}
@keyframes scFadeIn {
from {
opacity: 0;
transform: scale(0.9);
}
to {
opacity: 1;
transform: scale(1);
}
}
@keyframes scFadeOut {
from {
opacity: 1;
transform: scale(1);
}
to {
opacity: 0;
transform: scale(0.9);
}
}
/* Responsive design */
@media (max-width: 480px) {
.sc-container {
width: 95%;
padding: 15px;
}
.sc-title {
font-size: 16px;
}
.sc-captcha-text {
font-size: 24px;
letter-spacing: 6px;
}
.sc-input {
font-size: 14px;
padding: 10px;
}
.sc-button {
padding: 8px 16px;
font-size: 13px;
}
}
/* Accessibility improvements */
.sc-button:focus,
.sc-input:focus,
.sc-refresh-button:focus {
outline: 2px solid #48d1cc;
outline-offset: 2px;
}
/* High contrast mode support */
@media (prefers-contrast: high) {
.sc-container {
border: 2px solid #48d1cc;
}
.sc-captcha-text {
-webkit-text-fill-color: #48d1cc;
color: #48d1cc;
}
}
/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
.sc-fade-in,
.sc-fade-out {
animation: none;
}
.sc-button,
.sc-refresh-button {
transition: none;
}
}
/* Dark mode adjustments */
@media (prefers-color-scheme: light) {
.sc-overlay {
background-color: rgba(255, 255, 255, 0.9);
}
.sc-container {
background-color: #ffffff;
border: 1px solid #48d1cc;
color: #000000;
}
.sc-title {
color: #000000;
}
.sc-subtitle {
color: #666666;
}
.sc-input-label {
color: #000000;
}
.sc-input {
background-color: #f5f5f5;
border: 2px solid #ddd;
color: #000000;
}
.sc-cancel-button {
background-color: #e0e0e0;
color: #000000;
}
.sc-cancel-button:hover {
background-color: #d0d0d0;
}
}
/* Print styles */
@media print {
.sc-overlay {
display: none !important;
}
}
`;let ne=!1;const oe=()=>{if(ne||typeof document>"u")return;const u=document.createElement("style");u.id="simplify-captcha-styles",u.textContent=ie,document.getElementById("simplify-captcha-styles")||(document.head.appendChild(u),ne=!0)},le=()=>o.jsxs("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",children:[o.jsx("path",{d:"M4 12a8 8 0 018-8V2.5L14 4.5 12 6.5V5a7 7 0 00-7 7h2z",fill:"#48D1CC"}),o.jsx("path",{d:"M20 12a8 8 0 01-8 8v1.5L10 19.5 12 17.5V19a7 7 0 007-7h-2z",fill:"#48D1CC"})]}),ue=l.memo(({text:u})=>{const v=l.useMemo(()=>{const d=()=>{const y=["#2C3E50","#34495E","#7F8C8D","#95A5A6","#BDC3C7","#E74C3C","#C0392B","#E67E22","#D35400","#F39C12","#F1C40F","#27AE60","#2ECC71","#16A085","#1ABC9C","#3498DB","#2980B9","#9B59B6","#8E44AD"];return y[Math.floor(Math.random()*y.length)]},x=()=>Math.random()*30-15,h=()=>.8+Math.random()*.4,p=()=>Math.random()*10-5,m=()=>{const y=[];for(let C=0;C<50;C++)y.push({x:Math.random()*280,y:Math.random()*80,radius:Math.random()*2+1});return y},j=u.split("").map(()=>({color:d(),rotation:x(),scale:h(),offsetY:p()})),P=m(),R=Math.floor(Math.random()*100),_=[{path:`M${Math.random()*50},${20+Math.random()*40} Q${70+Math.random()*50},${10+Math.random()*60} ${150+Math.random()*50},${30+Math.random()*20}`},{path:`M${200+Math.random()*30},${15+Math.random()*50} Q${230+Math.random()*20},${40+Math.random()*20} ${260+Math.random()*15},${25+Math.random()*30}`}],N={circle:{cx:50+Math.random()*180,cy:20+Math.random()*40},rect:{x:100+Math.random()*80,y:55+Math.random()*15,rotation:Math.random()*60-30}};return{characterConfigs:j,noisePoints:P,turbulenceSeed:R,distractionLines:_,distractionElements:N}},[u]);return o.jsxs("svg",{width:"280",height:"80",viewBox:"0 0 280 80",className:"sc-svg-captcha",style:{userSelect:"none"},onContextMenu:d=>d.preventDefault(),onDragStart:d=>d.preventDefault(),children:[o.jsxs("defs",{children:[o.jsxs("linearGradient",{id:"bgGradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[o.jsx("stop",{offset:"0%",stopColor:"#f8f9fa",stopOpacity:"0.8"}),o.jsx("stop",{offset:"50%",stopColor:"#e9ecef",stopOpacity:"0.6"}),o.jsx("stop",{offset:"100%",stopColor:"#dee2e6",stopOpacity:"0.4"})]}),o.jsxs("filter",{id:"distortion",x:"-20%",y:"-20%",width:"140%",height:"140%",children:[o.jsx("feTurbulence",{baseFrequency:"0.02 0.03",numOctaves:"2",result:"turbulence",seed:v.turbulenceSeed}),o.jsx("feDisplacementMap",{in:"SourceGraphic",in2:"turbulence",scale:"3"})]}),o.jsx("filter",{id:"shadow",x:"-50%",y:"-50%",width:"200%",height:"200%",children:o.jsx("feDropShadow",{dx:"1",dy:"1",stdDeviation:"1",floodColor:"rgba(0,0,0,0.3)"})}),o.jsxs("pattern",{id:"linePattern",patternUnits:"userSpaceOnUse",width:"4",height:"4",children:[o.jsx("rect",{width:"4",height:"4",fill:"none"}),o.jsx("path",{d:"M0,4 L4,0",stroke:"rgba(0,0,0,0.1)",strokeWidth:"0.5"})]})]}),o.jsx("rect",{width:"280",height:"80",fill:"url(#bgGradient)"}),o.jsx("rect",{width:"280",height:"80",fill:"url(#linePattern)",opacity:"0.5"}),v.noisePoints.map((d,x)=>o.jsx("circle",{cx:d.x,cy:d.y,r:d.radius,fill:"rgba(0,0,0,0.1)",opacity:"0.3"},`noise-${x}`)),v.distractionLines.map((d,x)=>o.jsx("path",{d:d.path,stroke:"rgba(0,0,0,0.2)",strokeWidth:"1.5",fill:"none",opacity:"0.6"},`line-${x}`)),u.split("").map((d,x)=>{const h=35+x*45,p=45,m=v.characterConfigs[x];return o.jsxs("g",{children:[o.jsx("text",{x:h+1,y:p+m.offsetY+1,fontSize:"32",fontFamily:"Arial, sans-serif",fontWeight:"bold",fill:"rgba(0,0,0,0.3)",textAnchor:"middle",dominantBaseline:"middle",transform:`rotate(${m.rotation} ${h} ${p+m.offsetY}) scale(${m.scale})`,filter:"url(#distortion)",children:d}),o.jsx("text",{x:h,y:p+m.offsetY,fontSize:"32",fontFamily:"Arial, sans-serif",fontWeight:"bold",fill:m.color,textAnchor:"middle",dominantBaseline:"middle",transform:`rotate(${m.rotation} ${h} ${p+m.offsetY}) scale(${m.scale})`,filter:"url(#distortion)",children:d})]},`char-${x}`)}),o.jsx("circle",{cx:v.distractionElements.circle.cx,cy:v.distractionElements.circle.cy,r:"2",fill:"rgba(0,0,0,0.2)",opacity:"0.5"}),o.jsx("rect",{x:v.distractionElements.rect.x,y:v.distractionElements.rect.y,width:"3",height:"8",fill:"rgba(0,0,0,0.15)",transform:`rotate(${v.distractionElements.rect.rotation})`,opacity:"0.4"})]})}),se=l.forwardRef(({onMessage:u,style:v,className:d},x)=>{l.useEffect(()=>{oe()},[]);const[h,p]=l.useState(!1),[m,j]=l.useState(""),[P,R]=l.useState(""),[_,N]=l.useState(0),[y,C]=l.useState(!1),[X,O]=l.useState(!1),W=30,T=l.useRef({mountTime:Date.now(),mouseMovements:[],mouseTotalDistance:0,mouseVelocityChanges:0,clickCount:0,clickTimings:[],touchPoints:[],touchGestures:0,multiTouchEvents:0,scrollEvents:0,scrollDirection:{up:0,down:0,left:0,right:0},keystrokeCount:0,keystrokeTiming:[],totalInteractions:0,userActive:!1,lastActivityTime:Date.now(),interactionPattern:0,naturalBehaviorScore:0,hasTouch:"ontouchstart"in window,hasMouse:!0,devicePixelRatio:window.devicePixelRatio||1});l.useEffect(()=>{T.current.mountTime=Date.now(),T.current.lastActivityTime=Date.now();const s=r=>{const n=Date.now(),t=T.current,c={x:r.clientX,y:r.clientY,timestamp:n};if(t.mouseMovements.push(c),t.mouseMovements.length>50&&t.mouseMovements.shift(),t.mouseMovements.length>1){const f=t.mouseMovements[t.mouseMovements.length-2],E=Math.sqrt(Math.pow(c.x-f.x,2)+Math.pow(c.y-f.y,2));if(t.mouseTotalDistance+=E,t.mouseMovements.length>2){const i=t.mouseMovements[t.mouseMovements.length-3],b=Math.sqrt(Math.pow(f.x-i.x,2)+Math.pow(f.y-i.y,2))/(f.timestamp-i.timestamp),S=E/(n-f.timestamp);Math.abs(S-b)>.1&&t.mouseVelocityChanges++}}t.userActive=!0,t.lastActivityTime=n,t.totalInteractions++,t.hasMouse=!0},k=()=>{const r=Date.now(),n=T.current;if(n.clickCount++,n.clickTimings.push(r),n.clickTimings.length>10&&n.clickTimings.shift(),n.userActive=!0,n.lastActivityTime=r,n.totalInteractions++,n.clickTimings.length>1){const t=r-n.clickTimings[n.clickTimings.length-2];t>100&&t<2e3&&(n.naturalBehaviorScore+=1)}},g=r=>{const n=Date.now(),t=T.current;t.touchGestures++,t.userActive=!0,t.lastActivityTime=n,t.totalInteractions++,r.touches.length>1&&t.multiTouchEvents++,Array.from(r.touches).forEach(c=>{t.touchPoints.push({x:c.clientX,y:c.clientY,timestamp:n,pressure:c.force||1})}),t.touchPoints.length>20&&t.touchPoints.shift(),t.hasMouse=!1},A=r=>{const n=Date.now(),t=T.current;if(t.userActive=!0,t.lastActivityTime=n,t.totalInteractions++,r.touches.length===1&&t.touchPoints.length>0){const c=r.touches[0],f=t.touchPoints[t.touchPoints.length-1],E=Math.sqrt(Math.pow(c.clientX-f.x,2)+Math.pow(c.clientY-f.y,2));E>5&&E<100&&(t.naturalBehaviorScore+=.5)}},e=()=>{const r=Date.now(),n=T.current;n.scrollEvents++,n.userActive=!0,n.lastActivityTime=r,n.totalInteractions++,n.naturalBehaviorScore+=.2},a=()=>{const r=Date.now(),n=T.current;if(n.keystrokeCount++,n.keystrokeTiming.push(r),n.keystrokeTiming.length>20&&n.keystrokeTiming.shift(),n.userActive=!0,n.lastActivityTime=r,n.totalInteractions++,n.keystrokeTiming.length>1){const t=r-n.keystrokeTiming[n.keystrokeTiming.length-2];t>50&&t<500&&(n.naturalBehaviorScore+=.3)}};return document.addEventListener("mousemove",s,{passive:!0}),document.addEventListener("click",k,{passive:!0}),document.addEventListener("touchstart",g,{passive:!0}),document.addEventListener("touchmove",A,{passive:!0}),document.addEventListener("scroll",e,{passive:!0}),document.addEventListener("keydown",a,{passive:!0}),()=>{document.removeEventListener("mousemove",s),document.removeEventListener("click",k),document.removeEventListener("touchstart",g),document.removeEventListener("touchmove",A),document.removeEventListener("scroll",e),document.removeEventListener("keydown",a)}},[]);const[Q,z]=l.useState(!1),[Z,Y]=l.useState(!1),U=l.useCallback(()=>{const s=T.current,k=Date.now();let g=0;const A=k-s.mountTime,e=Math.min(Math.max((A-2e3)/1e3,0),15);if(g+=e,s.hasMouse&&s.mouseMovements.length>5){const t=Math.min(s.mouseTotalDistance/100,15),c=Math.min(s.mouseVelocityChanges/5,10);g+=t+c}if(s.hasTouch&&s.touchGestures>0){const t=Math.min(s.touchGestures*3,15),c=Math.min(s.multiTouchEvents*5,10);g+=t+c}if(s.clickCount>0){const t=Math.min(s.clickCount*2,10);let c=0;if(s.clickTimings.length>2){const f=[];for(let b=1;b<s.clickTimings.length;b++)f.push(s.clickTimings[b]-s.clickTimings[b-1]);const E=f.reduce((b,S)=>b+S,0)/f.length,i=f.reduce((b,S)=>b+Math.pow(S-E,2),0)/f.length;c=Math.min(Math.sqrt(i)/100,5)}g+=t+c}if(s.keystrokeCount>0){const t=Math.min(s.keystrokeCount*.5,5);let c=0;if(s.keystrokeTiming.length>3){const f=[];for(let i=1;i<s.keystrokeTiming.length;i++)f.push(s.keystrokeTiming[i]-s.keystrokeTiming[i-1]);c=f.some(i=>i>80&&i<400)?5:0}g+=t+c}if(s.scrollEvents>0){const t=Math.min(s.scrollEvents*1,10);g+=t}const a=Math.min(s.naturalBehaviorScore,15);g+=a;let r=0;return s.hasTouch&&s.touchGestures>0?r=3:!s.hasTouch&&s.mouseMovements.length>0&&(r=5),g+=r,A<1e3?g*=.3:s.totalInteractions===0&&(g*=.1),Math.min(Math.round(g),100)},[]),D=l.useCallback(()=>{const s="ABCDEFGHIJKLMNPQRSTUVWXYZ123456789";let k="";for(let g=0;g<5;g++)k+=s.charAt(Math.floor(Math.random()*s.length));return k},[]),w=l.useCallback(()=>{p(!1),R(""),O(!1),C(!1),z(!1),Y(!1)},[]),K=l.useCallback(()=>{const s=D();j(s),R(""),N(0),p(!0),O(!1),C(!0),z(!0),Y(!0),setTimeout(()=>{const k=U();z(!1),Y(!1),k>=80?(C(!1),w(),u({nativeEvent:{data:"verified"}})):(C(!1),O(!0))},1500)},[D,U,w,u]),F=l.useCallback(()=>{const s=D();j(s),R("")},[D]),B=l.useCallback(()=>{w(),u({nativeEvent:{data:"cancel"}})},[w,u]),H=l.useCallback(()=>{if(P.toUpperCase()===m.toUpperCase())w(),u({nativeEvent:{data:"verified"}});else{const s=_+1;N(s),s>=W?(w(),u({nativeEvent:{data:"error"}})):(alert(`Incorrect Captcha. Please try again. ${W-s} attempts remaining.`),F())}},[P,m,_,w,u,F]),$=()=>o.jsxs("div",{className:"sc-gesture-container",children:[o.jsx("h3",{className:"sc-gesture-title",children:"Human Verification"}),o.jsx("p",{className:"sc-gesture-subtitle",children:"We've been analyzing your natural interaction patterns"}),o.jsx("div",{className:"sc-gesture-area",children:o.jsx("div",{className:"sc-gesture-instructions",children:o.jsx("p",{className:"sc-gesture-instruction-text",children:"Analyzing your interaction patterns..."})})}),o.jsx("p",{className:"sc-gesture-hint",children:"This helps us verify you're human without additional steps"})]}),V=()=>o.jsxs("div",{className:"sc-checking-container",children:[o.jsx("h3",{className:"sc-checking-title",children:"Analyzing..."}),o.jsxs("div",{className:"sc-checking-content",children:[o.jsx("div",{className:`sc-checking-spinner ${Q?"sc-rotating":""}`,children:o.jsx("div",{className:`sc-spinner-dot ${Z?"sc-pulsing":""}`})}),o.jsx("p",{className:"sc-checking-text",children:"Verifying you are a Human"})]})]}),J=()=>o.jsxs("div",{className:"sc-text-captcha-container",children:[o.jsx("h3",{className:"sc-title",children:"Humanity Verification"}),o.jsx("p",{className:"sc-subtitle",children:"Please enter the text shown below"}),o.jsx("div",{className:"sc-captcha-container",children:o.jsxs("div",{className:"sc-captcha-svg-container",children:[o.jsx(ue,{text:m}),o.jsx("button",{className:"sc-refresh-button",onClick:F,type:"button",children:o.jsx(le,{})})]})}),o.jsx("input",{className:"sc-input",value:P,onChange:s=>R(s.target.value),placeholder:"Enter the text above",maxLength:5,autoComplete:"off"}),o.jsxs("div",{className:"sc-button-container",children:[o.jsx("button",{className:"sc-button sc-cancel-button",onClick:B,type:"button",children:"Cancel"}),o.jsx("button",{className:"sc-button sc-submit-button",onClick:H,type:"button",children:"Verify"})]})]});return l.useImperativeHandle(x,()=>({show:K,hide:w})),h?o.jsx("div",{className:"sc-overlay",children:o.jsx("div",{className:`sc-container ${d||""}`,style:v,children:y?V():X?J():$()})}):null});se.displayName="SimplifyCaptcha",M.SimplifyCaptcha=se,M.injectStyles=oe,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});