1import{j as z,W as re}from"./index-q3Gg3hU_.js";import{r as n}from"./react-Ga8F0Dx0.js";import"./solana-7MIGCHC8.js";import"./meteora-Ci9gqm7k.js";var te=n.forwardRef(({as:o="div",...s},c)=>z.jsx(o,{...s,ref:c}));const ne="https://challenges.cloudflare.com/turnstile/v0/api.js",oe="cf-turnstile-script",q="onloadTurnstileCallback",G=o=>!!document.getElementById(o),ie=({render:o="explicit",onLoadCallbackName:s=q,scriptOptions:{nonce:c="",defer:e=!0,async:l=!0,id:b="",appendTo:p,onError:m,crossOrigin:u=""}={}})=>{let d=b||"cf-turnstile-script";if(G(d))return;let i=document.createElement("script");i.id=d,i.src=`${ne}?onload=${s}&render=${o}`,!document.querySelector(`script[src="${i.src}"]`)&&(i.defer=!!e,i.async=!!l,c&&i.setAttribute("nonce",c),u&&(i.crossOrigin=u),m&&(i.onerror=m,delete window[s]),(p==="body"?document.body:document.getElementsByTagName("head")[0]).appendChild(i))},$={normal:{width:300,height:65},compact:{width:150,height:140},invisible:{width:0,height:0,overflow:"hidden"},flexible:{minWidth:300,width:"100%",height:65}};function ae(o){if(o!=="invisible")return o}function ce(o=oe){let[s,c]=n.useState(!1);return n.useEffect(()=>{let e=()=>{G(o)&&c(!0)},l=new MutationObserver(e);return l.observe(document,{childList:!0,subtree:!0}),e(),()=>{l.disconnect()}},[o]),s}let N="unloaded",J;const se=new Promise((o,s)=>{J={resolve:o,reject:s},N==="ready"&&o(void 0)}),_=(o=q)=>(N==="unloaded"&&(N="loading",window[o]=()=>{J.resolve(),N="ready",delete window[o]}),se),V=n.forwardRef((o,s)=>{let{scriptOptions:c,options:e={},siteKey:l,onWidgetLoad:b,onSuccess:p,onExpire:m,onError:u,onBeforeInteractive:d,onAfterInteractive:i,onUnsupported:I,onTimeout:j,onLoadScript:D,id:X,style:Y,as:Z="div",injectScript:H=!0,rerenderOnCallbackChange:a=!1,...Q}=o,S=e.size,P=n.useMemo(()=>{if(S===void 0)return{};let r=$[S];return e.appearance==="interaction-only"?{...r,height:"auto"}:r},[S,e.appearance]),x=e.execution==="execute"?$.invisible:P,[ee,g]=n.useState(x),w=n.useRef(null),[v,U]=n.useState(!1),t=n.useRef(void 0),C=n.useRef(!1),K=X||"cf-turnstile",h=n.useRef({onSuccess:p,onError:u,onExpire:m,onBeforeInteractive:d,onAfterInteractive:i,onUnsupported:I,onTimeout:j});n.useEffect(()=>{a||(h.current={onSuccess:p,onError:u,onExpire:m,onBeforeInteractive:d,onAfterInteractive:i,onUnsupported:I,onTimeout:j})});let A=c?.id||"cf-turnstile-script",O=ce(A),R=c?.onLoadCallbackName||"onloadTurnstileCallback",B=n.useMemo(()=>({sitekey:l,action:e.action,cData:e.cData,theme:e.theme||"auto",language:e.language||"auto",tabindex:e.tabIndex,"response-field":e.responseField,"response-field-name":e.responseFieldName,size:ae(S),retry:e.retry||"auto","retry-interval":e.retryInterval||8e3,"refresh-expired":e.refreshExpired||"auto","refresh-timeout":e.refreshTimeout||"auto",execution:e.execution||"render",appearance:e.appearance||"always","feedback-enabled":e.feedbackEnabled??!0,"offlabel-show-privacy":e.offlabelShowPrivacy??!0,"offlabel-show-help":e.offlabelShowHelp??!0,callback:r=>{C.current=!0,a?p?.(r):h.current.onSuccess?.(r)},"error-callback":a?u:(...r)=>h.current.onError?.(...r),"expired-callback":a?m:(...r)=>h.current.onExpire?.(...r),"before-interactive-callback":a?d:(...r)=>h.current.onBeforeInteractive?.(...r),"after-interactive-callback":a?i:(...r)=>h.current.onAfterInteractive?.(...r),"unsupported-callback":a?I:(...r)=>h.current.onUnsupported?.(...r),"timeout-callback":a?j:(...r)=>h.current.onTimeout?.(...r)}),[e.action,e.appearance,e.cData,e.execution,e.language,e.refreshExpired,e.responseField,e.responseFieldName,e.retry,e.retryInterval,e.tabIndex,e.theme,e.feedbackEnabled,e.offlabelShowPrivacy,e.offlabelShowHelp,e.refreshTimeout,l,S,a,a?p:null,a?u:null,a?m:null,a?d:null,a?i:null,a?I:null,a?j:null]),E=n.useCallback(()=>typeof window<"u"&&!!window.turnstile,[]),F=n.useCallback((r,f)=>{try{return window.turnstile.render(r,f)}catch(T){let L=a?u:h.current.onError;L?L(T instanceof Error?T.message:String(T)):console.error(T);return}},[a,a?u:null]);return n.useEffect(function(){H&&!v&&(_(R),ie({onLoadCallbackName:R,scriptOptions:{...c,id:A}}))},[H,v,c,A,R]),n.useEffect(function(){N!=="ready"&&_(R).then(()=>U(!0)).catch(console.error)},[R]),n.useEffect(function(){if(!w.current||!v)return;let r=!1;return(async()=>
1{if(r||!w.current)return;let f=F(w.current,B);t.current=f,g(x),t.current&&b?.(t.current)})(),()=>{r=!0,t.current&&(window.turnstile.remove(t.current),C.current=!1)}},[K,v,B,x,F]),n.useImperativeHandle(s,()=>{let{turnstile:r}=window;return{getResponse(){if(!r?.getResponse||!t.current||!E()){console.warn("Turnstile has not been loaded");return}return r.getResponse(t.current)},async getResponsePromise(f=3e4,T=100){return new Promise((L,W)=>{let y,M=async()=>{if(C.current&&window.turnstile&&t.current)try{let k=window.turnstile.getResponse(t.current);return y&&clearTimeout(y),k?L(k):W(Error("No response received"))}catch(k){return y&&clearTimeout(y),console.warn("Failed to get response",k),W(Error("Failed to get response"))}y||=setTimeout(()=>{y&&clearTimeout(y),W(Error("Timeout"))},f),await new Promise(k=>setTimeout(k,T)),await M()};M()})},reset(){if(!r?.reset||!t.current||!E()){console.warn("Turnstile has not been loaded");return}g(x);try{C.current=!1,r.reset(t.current)}catch(f){console.warn(`Failed to reset Turnstile widget ${t.current}`,f)}},remove(){if(!r?.remove||!t.current||!E()){console.warn("Turnstile has not been loaded");return}g($.invisible),C.current=!1,r.remove(t.current),t.current=null},render(){if(!r?.render||!w.current||!E()||t.current){console.warn("Turnstile has not been loaded or container not found");return}let f=F(w.current,B);return t.current=f,t.current&&b?.(t.current),g(x),f},execute(){if(e.execution!=="execute"){console.warn('Execution mode is not set to "execute"');return}if(!r?.execute||!w.current||!t.current||!E()){console.warn("Turnstile has not been loaded or container not found");return}r.execute(w.current),g(P)},isExpired(){return!r?.isExpired||!t.current||!E()?(console.warn("Turnstile has not been loaded"),!1):r.isExpired(t.current)}}},[t,e.execution,B,w,E,F,v,b,x,P]),n.useEffect(()=>{if(v||!O)return;if(window.turnstile){U(!0);return}let r=setInterval(()=>{window.turnstile&&(U(!0),clearInterval(r))},50);return()=>{clearInterval(r)}},[v,O]),n.useEffect(()=>{g(x)},[x]),n.useEffect(()=>{!O||typeof D!="function"||D()},[O]),z.jsx(te,{ref:w,as:Z,id:K,style:{...ee,...Y},...Q})});V.displayName="Turnstile";const pe=({delayedExecution:o,captchaContext:s,...c})=>{let{appId:e,setError:l,setToken:b,setExecuting:p,siteKey:m,ref:u}=s,{scriptNonce:d}=re();return z.jsx(V,{...c,ref:u,siteKey:m??"",scriptOptions:d?{nonce:d}:void 0,options:{action:e,size:"invisible",...o?{appearance:"execute",execution:"execute"}:{appearance:"always",execution:"render"}},onUnsupported:()=>{c.onUnsupported?.(),console.warn("Browser does not support Turnstile.")},onError:i=>{c.onError?.(i),l("Captcha failed"),p(!1)},onSuccess:i=>{c.onSuccess?.(i),b(i),p(!1)},onExpire:i=>{c.onExpire?.(i);try{u.current?.reset(),l(void 0),b(void 0)}catch{l("expired_and_failed_reset")}}})};export{pe as TurnstileWrapper,pe as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.