1(function(window,document){'use strict';var config=typeof window.bolMarketoTurnstile==='object'&&window.bolMarketoTurnstile?window.bolMarketoTurnstile:{};var siteKey=(config.siteKey||'').trim();if(!siteKey){if(window.console&&typeof window.console.warn==='function'){window.console.warn('[BOL Marketo Turnstile] No site key detected; aborting front-end protection.')} 2return} 3var blockMessage=config.blockMessage||'We could not load this form because Turnstile protection is unavailable. Please refresh and try again.';var submitErrorMessage=config.submitErrorMessage||'Turnstile verification failed. Please refresh and try again.';var debugEnabled=!!config.debug;var endpoints=(config.rest&&typeof config.rest==='object')?config.rest:{};var tokenEndpoint=typeof endpoints.token==='string'?endpoints.token:'';var verifyEndpoint=typeof endpoints.verify==='string'?endpoints.verify:'';function buildRestUrl(path){var root='';if(window.wp&&window.wpApiSettings&&window.wpApiSettings.root){root=window.wpApiSettings.root}else{var origin=window.location.origin||(window.location.protocol+'//'+window.location.host);root=origin.replace(/\/$/,'')+'/wp-json/'} 4if(root.slice(-1)!=='/'){root+='/'} 5path=String(path||'').replace(/^\//,'');return root+'bol-marketo-turnstile/v1/'+path} 6tokenEndpoint=tokenEndpoint||buildRestUrl('token');verifyEndpoint=verifyEndpoint||buildRestUrl('verify');var existingDebug=typeof window.bolMarketoTurnstileDebug==='object'&&window.bolMarketoTurnstileDebug?window.bolMarketoTurnstileDebug:{};var debugHistory=Array.isArray(existingDebug.history)?existingDebug.history:[];function toErrorPayload(value){if(!value){return null} 7if(value instanceof Error){return{name:value.name,message:value.message,stack:value.stack||null}} 8if(typeof value==='object'){var payload={};if(value.message){payload.message=value.message} 9if(value.name){payload.name=value.name} 10return Object.keys(payload).length?payload:{message:String(value)}} 11return{message:String(value)}} 12function emitDebug(level,message,detail){var entry={timestamp:new Date().toISOString(),level:level,message:message,detail:detail||null};debugHistory.push(entry);if(window.console){var consoleMethod=typeof window.console[level]==='function'?window.console[level]:window.console.log;try{if(detail){consoleMethod.call(window.console,'[BOL Marketo Turnstile]',message,detail)}else{consoleMethod.call(window.console,'[BOL Marketo Turnstile]',message)}}catch(consoleError){consoleMethod('[BOL Marketo Turnstile]',message)}} 13return entry} 14existingDebug.history=debugHistory;existingDebug.emit=emitDebug;existingDebug.info=function(message,detail){return emitDebug('info',message,detail)};existingDebug.warn=function(message,detail){return emitDebug('warn',message,detail)};existingDebug.error=function(message,detail){return emitDebug('error',message,detail)};existingDebug.flush=function(){return debugHistory.slice()};existingDebug.setEnabled=function(value){debugEnabled=!!value;existingDebug.enabled=debugEnabled;return debugEnabled};existingDebug.getEnabled=function(){return debugEnabled};existingDebug.enabled=debugEnabled;existingDebug.endpoints={token:tokenEndpoint,verify:verifyEndpoint};window.bolMarketoTurnstileDebug=existingDebug;var debugInfo=existingDebug.info;var debugWarn=existingDebug.warn;var debugError=existingDebug.error;function resolveFormElement(form){if(!form){return null} 15if(typeof form.getFormElem==='function'){var elem=form.getFormElem();if(elem){if(typeof elem.get==='function'){return elem.get(0)||null} 16if(elem instanceof HTMLElement){return elem} 17if(elem.length&&elem[0]){return elem[0]}}} 18if(typeof form.getId==='function'){var id=form.getId();if(id){return document.getElementById('mktoForm_'+id)}} 19return null} 20function setHiddenField(form,name,value){if(!form){return} 21if(typeof form.addHiddenFields==='function'){var payload={};payload[name]=value;try{form.addHiddenFields(payload)}catch(error){debugWarn('MktoForms2.addHiddenFields failed',{name:name,error:toErrorPayload(error)})}} 22var element=resolveFormElement(form);if(!element){return} 23var existingInput=element.querySelector('input[name="'+name+'"]');
23if(!existingInput){existingInput=document.createElement('input');existingInput.type='hidden';existingInput.name=name;element.appendChild(existingInput)} 24existingInput.value=value} 25function showErrorMessage(form,message,detail){var finalMessage=message||submitErrorMessage;if(debugEnabled&&detail&&detail.message){finalMessage+=' ('+detail.message+')'} 26if(typeof form.showErrorMessage==='function'&&typeof form.getFormElem==='function'){try{form.showErrorMessage(finalMessage,form.getFormElem());return}catch(error){debugWarn('MktoForms2.showErrorMessage failed',{error:toErrorPayload(error)})}} 27var element=resolveFormElement(form);if(!element){return} 28var container=element.querySelector('.bol-marketo-turnstile-error');if(!container){container=document.createElement('div');container.className='bol-marketo-turnstile-error';container.setAttribute('role','alert');element.appendChild(container)} 29container.textContent=finalMessage} 30function clearErrorMessage(form){var element=resolveFormElement(form);if(!element){return} 31var container=element.querySelector('.bol-marketo-turnstile-error');if(container&&container.parentNode){container.parentNode.removeChild(container)}} 32var turnstileScriptPromise=null;var turnstileReadyPromise=null;function getTurnstileInstance(){if(typeof window.turnstile!=='undefined'&&window.turnstile&&typeof window.turnstile.render==='function'){return window.turnstile} 33return null} 34function ensureTurnstileScript(){var existingInstance=getTurnstileInstance();if(existingInstance){debugInfo('Turnstile already available');return Promise.resolve(existingInstance)} 35if(turnstileScriptPromise){return turnstileScriptPromise} 36var existingScript=document.querySelector('script[src*="turnstile/v0/api.js"]');if(existingScript){debugInfo('Found existing Turnstile script tag',{src:existingScript.getAttribute('src')||''});turnstileScriptPromise=new Promise(function(resolve,reject){existingScript.addEventListener('load',function(){resolve(getTurnstileInstance())});existingScript.addEventListener('error',function(){reject(new Error('turnstile_script_load_failed'))})});return turnstileScriptPromise} 37turnstileScriptPromise=new Promise(function(resolve,reject){var script=document.createElement('script');script.async=!0;script.defer=!0;script.src='https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit';script.setAttribute('data-bol-turnstile','plugin');var start=Date.now();script.addEventListener('load',function(){debugInfo('Injected Turnstile script',{latencyMs:Date.now()-start});resolve(getTurnstileInstance())});script.addEventListener('error',function(event){debugError('Failed to load Turnstile script',{error:toErrorPayload(event&&event.error)});reject(new Error('turnstile_script_load_failed'))});(document.head||document.getElementsByTagName('head')[0]||document.body).appendChild(script);debugInfo('Appending Turnstile script',{src:script.src})}).catch(function(error){turnstileScriptPromise=null;throw error});return turnstileScriptPromise} 38function waitForTurnstileInstance(timeoutMs){var existing=getTurnstileInstance();if(existing){return Promise.resolve(existing)} 39if(turnstileReadyPromise){return turnstileReadyPromise} 40var timeout=Math.max(1000,timeoutMs||7000);var start=Date.now();turnstileReadyPromise=new Promise(function(resolve,reject){var settled=!1;function finish(callback){if(settled){return} 41settled=!0;window.clearInterval(intervalId);window.clearTimeout(timeoutId);callback()} 42var intervalId=window.setInterval(function(){var candidate=getTurnstileInstance();if(candidate){finish(function(){debugInfo('turnstile ready',{latencyMs:Date.now()-start});resolve(candidate)})}},100);var timeoutId=window.setTimeout(function(){finish(function(){reject(new Error('turnstile_not_loaded'))})},timeout)}).finally(function(){turnstileReadyPromise=null});return turnstileReadyPromise} 43function getTurnstileWidgetState(form){var state=form.__bolTurnstileWidget;if(state&&state.container&&document.body.contains(state.container)){return state} 44var container=document.createElement('div');container.className='bol-marketo-turnstile-widget';container.setAttribute('aria-hidden','true');var formElem=resolveFormElement(form);(formElem||document.body).appendChild(container);state={container:container,widgetId:null,resolve:null,reject:null,revealed:!1};if(typeof window.ResizeObserver==='function'){state.observer=new window.ResizeObserver(function(){var visible=container.offsetWidth>0&&container.offsetHeight>0;if(visible===state.revealed){return} 45state.revealed=visible;if(!visible){container.setAttribute('aria-hidden','true');return} 46container.removeAttribute('aria-hidden');debugInfo('Turnstile challenge became visible',{action:null});try{container.scrollIntoView({block:'center',behavior:'smooth'})}catch(scrollError){container.scrollIntoView()}});state.observer.observe(container)} 47form.__bolTurnstileWidget=state;return state} 48function fetchTurnstileToken(form,action,options){options=options||{};return ensureTurnstileScript().then(function(){return waitForTurnstileInstance(options.timeout||7000)}).then(function(instance){return new Promise(function(resolve,reject){var state=getTurnstileWidgetState(form);function settleResolve(token){var fn=state.resolve;state.resolve=null;state.reject=null;if(fn){fn(token)}} 49function settleReject(error){var fn=state.reject;state.resolve=null;state.reject=null;if(fn){fn(error)}} 50if(state.reject){settleReject(new Error('turnstile_superseded'))} 51state.resolve=resolve;state.reject=reject;if(state.widgetId===null){try{state.widgetId=instance.render(state.container,{sitekey:siteKey,action:action,execution:'execute',callback:function(token){if(!token){debugWarn('Received empty Turnstile token',{action:action});settleReject(new Error('turnstile_empty_token'));return} 52debugInfo('Received Turnstile token',{action:action,tokenLength:token.length});settleResolve(token)}
52,'error-callback':function(code){debugWarn('Turnstile error-callback',{action:action,code:code});settleReject(new Error('turnstile_error'+(code?'_'+code:'')));return!0},'expired-callback':function(){debugWarn('Turnstile token expired before use',{action:action})},'timeout-callback':function(){debugWarn('Turnstile challenge timed out',{action:action})}});debugInfo('Rendered Turnstile widget',{action:action})}catch(renderError){settleReject(renderError instanceof Error?renderError:new Error(String(renderError)));return}}else{try{instance.reset(state.widgetId)}catch(resetError){debugWarn('Turnstile reset failed',{action:action,error:toErrorPayload(resetError)})}} 53try{instance.execute(state.widgetId,{action:action})}catch(executeError){settleReject(executeError instanceof Error?executeError:new Error(String(executeError)))}})})} 54function performFetchJSON(url,options){options=options||{};options.credentials='same-origin';options.cache='no-store';options.headers=options.headers||{};if(!options.headers.Accept){options.headers.Accept='application/json'} 55if(!window.fetch){return Promise.reject(new Error('Fetch API is not available in this browser.'))} 56return window.fetch(url,options).then(function(response){return response.json().catch(function(){return null}).then(function(data){if(!response.ok){var message=data&&data.message?data.message:'Request failed.';var error=new Error(message);error.response=response;error.data=data;throw error} 57return data})})} 58var pageTokenManager=(function(){var state={current:null,pending:null};function isValid(entry){if(!entry||!entry.token){return!1} 59if(!entry.expires){return!1} 60var now=Math.floor(Date.now()/1000);return(entry.expires-now)>15} 61function ensure(force){if(!tokenEndpoint){return Promise.reject(new Error('Token endpoint unavailable.'))} 62if(!force&&isValid(state.current)){return Promise.resolve(state.current)} 63if(state.pending){return state.pending} 64var requestUrl=tokenEndpoint;var requestInit={method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({ts:Date.now()})};if(!window.fetch){requestInit.method='GET';delete requestInit.headers['Content-Type'];delete requestInit.body} 65if(requestInit.method==='GET'){requestUrl+=(requestUrl.indexOf('?')===-1?'?':'&')+'_='+Date.now()} 66debugInfo('Fetching Marketo protection token',{endpoint:requestUrl,force:!!force,method:requestInit.method});state.pending=performFetchJSON(requestUrl,requestInit).then(function(data){state.pending=null;if(!data||!data.token){throw new Error('Token response missing token value.')} 67var issued=data.issued?Number(data.issued):null;var expires=data.expires?Number(data.expires):null;state.current={token:data.token,issued:issued,expires:expires,nonce:data.nonce||null};existingDebug.pageToken=Object.assign({},state.current);debugInfo('Received Marketo protection token',{issued:issued,expires:expires,nonce:state.current.nonce});return state.current}).catch(function(error){state.pending=null;throw error});return state.pending} 68function consume(){state.current=null;existingDebug.pageToken=null} 69return{ensure:ensure,consume:consume,get:function(){return state.current},isValid:function(){return isValid(state.current)}}})();existingDebug.pageTokenManager=pageTokenManager;function verifySubmission(action,formId,pageToken,turnstileToken){if(!verifyEndpoint){return Promise.reject(new Error('Verification endpoint unavailable.'))} 70return performFetchJSON(verifyEndpoint,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({token:pageToken.token,turnstile:turnstileToken,action:action,formId:formId||null})})} 71function normalizeAction(value){if(!value){return''} 72return value.toString().toLowerCase().replace(/[^\w]+/g,'_')} 73function bindTurnstileToForm(form){if(!form||form.__bolTurnstileBound){return} 74form.__bolTurnstileBound=!0;var formId=typeof form.getId==='function'?form.getId():null;var action=formId?'marketo_form_'+formId:'marketo_form';var normalizedAction=normalizeAction(action);var resubmitting=!1;debugInfo('Initializing Turnstile protection for Mkto form',{formId:formId,action:action,normalizedAction:normalizedAction});if(typeof form.submittable==='function'){form.submittable(!1)} 75function refreshPageToken(force){return pageTokenManager.ensure(force===!0).then(function(entry){setHiddenField(form,'bol-marketo-page-token',entry.token);var expiresIn=entry.expires?Math.max(0,entry.expires-Math.floor(Date.now()/1000)):null;var message='Marketo protection token ready';if(expiresIn!==null){message+=' (expires in ~'+expiresIn+'s)'} 76debugInfo(message,{formId:formId,action:normalizedAction,expiresIn:expiresIn,nonce:entry.nonce});if(typeof form.submittable==='function'){form.submittable(!0)} 77return entry}).catch(function(error){var payload=toErrorPayload(error);debugWarn('Unable to fetch page token',{formId:formId,action:normalizedAction,error:payload});if(typeof form.submittable==='function'){form.submittable(!1)} 78throw error})} 79refreshPageToken(!1).catch(function(){});form.onSubmit(function(){if(resubmitting){resubmitting=!1;return!0} 80debugInfo('Verifying Turnstile protection prior to submission',{formId:formId,action:normalizedAction});clearErrorMessage(form);
80if(typeof form.submittable==='function'){form.submittable(!1)} 81var currentTokenInfo=null;refreshPageToken(!0).then(function(tokenInfo){currentTokenInfo=tokenInfo;return fetchTurnstileToken(form,normalizedAction,{timeout:7000})}).then(function(turnstileToken){if(!turnstileToken){throw new Error('turnstile_missing_token')} 82return verifySubmission(normalizedAction,formId,currentTokenInfo,turnstileToken).then(function(verification){return{turnstileToken:turnstileToken,verification:verification,tokenInfo:currentTokenInfo}})}).then(function(payload){setHiddenField(form,'cf-turnstile-response',payload.turnstileToken);setHiddenField(form,'turnstile_action',normalizedAction);pageTokenManager.consume();resubmitting=!0;var verifiedAction=payload.verification&&payload.verification.turnstile?payload.verification.turnstile.action:null;var verifiedHostname=payload.verification&&payload.verification.turnstile?payload.verification.turnstile.hostname:null;debugInfo('Turnstile protection verification passed',{formId:formId,action:normalizedAction,verifiedAction:verifiedAction,verification:payload.verification});debugInfo('Turnstile protection verified',{action:normalizedAction,verifiedAction:verifiedAction,hostname:verifiedHostname});if(typeof form.submittable==='function'){form.submittable(!0)} 83form.submit()}).catch(function(error){var payload=toErrorPayload(error);showErrorMessage(form,submitErrorMessage,payload);debugWarn('Turnstile protection verification failed',{formId:formId,action:normalizedAction,error:payload});pageTokenManager.consume();if(typeof form.submittable==='function'){form.submittable(!0)}});return!1})} 84function bindMktoForms(){if(typeof window.MktoForms2==='undefined'){return!1} 85var mkto=window.MktoForms2;if(typeof mkto.whenReady==='function'){mkto.whenReady(function(form){try{bindTurnstileToForm(form)}catch(error){debugError('Failed to bind Turnstile protection in whenReady',{error:toErrorPayload(error)})}})} 86if(typeof mkto.whenRendered==='function'){mkto.whenRendered(function(form){try{bindTurnstileToForm(form)}catch(error){debugError('Failed to bind Turnstile protection in whenRendered',{error:toErrorPayload(error)})}})} 87if(typeof mkto.loadForm==='function'&&!mkto.loadForm.__bolTurnstileWrapped){var originalLoadForm=mkto.loadForm;mkto.loadForm=function(){var args=Array.prototype.slice.call(arguments);var userCallback=typeof args[3]==='function'?args[3]:null;args[3]=function(form){try{bindTurnstileToForm(form)}catch(error){debugError('Failed to bind Turnstile protection in loadForm callback',{error:toErrorPayload(error)})} 88if(userCallback){return userCallback(form)} 89return undefined};return originalLoadForm.apply(mkto,args)};mkto.loadForm.__bolTurnstileWrapped=!0} 90if(typeof mkto.allForms==='function'){try{var existingForms=mkto.allForms();if(Array.isArray(existingForms)){existingForms.forEach(function(form){try{bindTurnstileToForm(form)}catch(error){debugError('Failed to bind existing Marketo form',{error:toErrorPayload(error)})}})}}catch(error){debugWarn('MktoForms2.allForms failed',{error:toErrorPayload(error)})}} 91return!0} 92ensureTurnstileScript().catch(function(error){debugError('Unable to preload Turnstile script',{error:toErrorPayload(error)})});pageTokenManager.ensure().catch(function(error){debugWarn('Initial page token fetch failed',{error:toErrorPayload(error)})});if(!bindMktoForms()){debugInfo('MktoForms2 not ready; starting detection loop');var attempts=0;var intervalId=window.setInterval(function(){attempts+=1;if(bindMktoForms()){window.clearInterval(intervalId);window.clearTimeout(timeoutId);debugInfo('MktoForms2 binding succeeded after retry',{attempts:attempts})}},200);var timeoutId=window.setTimeout(function(){window.clearInterval(intervalId);debugWarn('MktoForms2 not detected within expected window',{attempts:attempts})},10000)}})(window,document)
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.