1import{r as n,j as H}from"./chunk-EPOLDU6W-B6BK35Gh.js";var ee=({as:o="div",...s},u)=>H.jsx(o,{...s,ref:u}),re=n.forwardRef(ee),te="https://challenges.cloudflare.com/turnstile/v0/api.js",$="cf-turnstile-script",ne="cf-turnstile",A="onloadTurnstileCallback",K=o=>!!document.getElementById(o),oe=({render:o="explicit",onLoadCallbackName:s=A,scriptOptions:{nonce:u="",defer:e=!0,async:m=!0,id:T="",appendTo:E,onError:w,crossOrigin:x=""}={}})=>{let b=T||$;if(K(b))return;let a=document.createElement("script");a.id=b,a.src=`${te}?onload=${s}&render=${o}`,!document.querySelector(`script[src="${a.src}"]`)&&(a.defer=!!e,a.async=!!m,u&&(a.nonce=u),x&&(a.crossOrigin=x),w&&(a.onerror=w,delete window[s]),(E==="body"?document.body:document.getElementsByTagName("head")[0]).appendChild(a))},y={normal:{width:300,height:65},compact:{width:150,height:140},invisible:{width:0,height:0,overflow:"hidden"},flexible:{minWidth:300,width:"100%",height:65},interactionOnly:{width:"fit-content",height:"auto",display:"flex"}};function ie(o){if(o!=="invisible"&&o!=="interactionOnly")return o}function ae(o=$){let[s,u]=n.useState(!1);return n.useEffect(()=>{let e=()=>{K(o)&&u(!0)},m=new MutationObserver(e);return m.observe(document,{childList:!0,subtree:!0}),e(),()=>{m.disconnect()}},[o]),s}var C="unloaded",G,ue=new Promise((o,s)=>{G={resolve:o,reject:s},C==="ready"&&o(void 0)}),q=(o=A)=>(C==="unloaded"&&(C="loading",window[o]=()=>{G.resolve(),C="ready",delete window[o]}),ue),ce=n.forwardRef((o,s)=>{let{scriptOptions:u,options:e={},siteKey:m,onWidgetLoad:T,onSuccess:E,onExpire:w,onError:x,onBeforeInteractive:b,onAfterInteractive:a,onUnsupported:O,onTimeout:N,onLoadScript:P,id:J,style:V,as:X="div",injectScript:U=!0,rerenderOnCallbackChange:i=!1,..._}=o,c=e.size,D=n.useCallback(()=>typeof c>"u"?{}:e.execution==="execute"?y.invisible:e.appearance==="interaction-only"?y.interactionOnly:y[c],[e.execution,c,e.appearance]),[M,k]=n.useState(D()),l=n.useRef(null),[h,F]=n.useState(!1),t=n.useRef(void 0),I=n.useRef(!1),z=J||ne,d=n.useRef({onSuccess:E,onError:x,onExpire:w,onBeforeInteractive:b,onAfterInteractive:a,onUnsupported:O,onTimeout:N});n.useEffect(()=>{i||(d.current={onSuccess:E,onError:x,onExpire:w,onBeforeInteractive:b,onAfterInteractive:a,onUnsupported:O,onTimeout:N})});let B=u?.id||$,j=ae(B),R=u?.onLoadCallbackName||A,Q=e.appearance||"always",S=n.useMemo(()=>({sitekey:m,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:ie(c),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,callback:r=>{I.current=!0,i?E?.(r):d.current.onSuccess?.(r)},"error-callback":i?x:(...r)=>d.current.onError?.(...r),"expired-callback":i?w:(...r)=>d.current.onExpire?.(...r),"before-interactive-callback":i?b:(...r)=>d.current.onBeforeInteractive?.(...r),"after-interactive-callback":i?a:(...r)=>d.current.onAfterInteractive?.(...r),"unsupported-callback":i?O:(...r)=>d.current.onUnsupported?.(...r),"timeout-callback":i?N:(...r)=>d.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.refreshTimeout,m,c,i,i?E:null,i?x:null,i?w:null,i?b:null,i?a:null,i?O:null,i?N:null]),v=n.useCallback(()=>typeof window<"u"&&!!window.turnstile,[]);return n.useEffect(function(){U&&!h&&(q(R),oe({onLoadCallbackName:R,scriptOptions:{...u,id:B}}))},[U,h,u,B,R]),n.useEffect(function(){C!=="ready"&&q(R).then(()=>F(!0)).catch(console.error)},[R]),n.useEffect(function(){if(!l.current||!h)return;let r=!1;return(async()=>{if(r||!l.current)return;let f=window.turnstile.render(l.current,S);t.current=f,t.current&&T?.(t.current)})(),()=>{r=!0,t.current&&(window.turnstile.remove(t.current),I.current=!1)}},[z,h,S]),n.useImperativeHandle(s,()=>{let{turnstile:r}=window;return{getResponse(){if(!r?.getResponse||!t.current||!v()){console.warn("Turnstile has not been loaded");return}return r.getResponse(t.current)},async getResponsePromise(f=3e4,Y=100){return new Promise((Z,L)=>{let p,W=async()=>
1{if(I.current&&window.turnstile&&t.current)try{let g=window.turnstile.getResponse(t.current);return p&&clearTimeout(p),g?Z(g):L(new Error("No response received"))}catch(g){return p&&clearTimeout(p),console.warn("Failed to get response",g),L(new Error("Failed to get response"))}p||(p=setTimeout(()=>{p&&clearTimeout(p),L(new Error("Timeout"))},f)),await new Promise(g=>setTimeout(g,Y)),await W()};W()})},reset(){if(!r?.reset||!t.current||!v()){console.warn("Turnstile has not been loaded");return}e.execution==="execute"&&k(y.invisible);try{I.current=!1,r.reset(t.current)}catch(f){console.warn(`Failed to reset Turnstile widget ${t}`,f)}},remove(){if(!r?.remove||!t.current||!v()){console.warn("Turnstile has not been loaded");return}k(y.invisible),I.current=!1,r.remove(t.current),t.current=null},render(){if(!r?.render||!l.current||!v()||t.current){console.warn("Turnstile has not been loaded or container not found");return}let f=r.render(l.current,S);return t.current=f,t.current&&T?.(t.current),e.execution!=="execute"&&k(c?y[c]:{}),f},execute(){if(e.execution!=="execute"){console.warn('Execution mode is not set to "execute"');return}if(!r?.execute||!l.current||!t.current||!v()){console.warn("Turnstile has not been loaded or container not found");return}r.execute(l.current,S),k(c?y[c]:{})},isExpired(){return!r?.isExpired||!t.current||!v()?(console.warn("Turnstile has not been loaded"),!1):r.isExpired(t.current)}}},[t,e.execution,c,S,l,v,h,T]),n.useEffect(()=>{if(h||!j)return;if(window.turnstile){F(!0);return}let r=setInterval(()=>{window.turnstile&&(F(!0),clearInterval(r))},50);return()=>{clearInterval(r)}},[h,j]),n.useEffect(()=>{k(D())},[e.execution,c,Q]),n.useEffect(()=>{!j||typeof P!="function"||P()},[j]),H.jsx(re,{ref:l,as:X,id:z,style:{...M,...V},..._})});ce.displayName="Turnstile";export{ce as E};
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.