{"version":3,"file":"TurnstileWidget.BiEh0LBg.mjs","names":["useRef","useRef","useState"],"sources":["https:/framerusercontent.com/modules/2CzjwLkflYXkpXGbqWiF/gFPHot0MrkxlC05Rrk65/TurnstileProtection.js","https:/framerusercontent.com/modules/jIRxlOrESklbLfS9Epsl/YePilqvg9mseLehGfiXK/TurnstileWidget.js"],"sourcesContent":["// TurnstileProtection.tsx — Framer Code Override\n// Blocks form submission until the TurnstileWidget component verifies the user.\n// Injects a hidden \"cf-turnstile-response\" field so the token reaches the webhook.\n//\n// How to use in Framer:\n//   1. Go to Assets → Code → New Override File, paste this code\n//   2. Select the Frame that wraps your form\n//   3. In the right panel → Code Overrides → select this file → withTurnstile\n//   4. Make sure TurnstileWidget.tsx (Code Component) is placed in your page\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";// ─── Override ───────────────────────────────────────────────────────────────\nexport function withTurnstile(Component){return props=>{const wrapperRef=useRef(null);const tokenRef=useRef(\"\");const hiddenInputRef=useRef(null);useEffect(()=>{const wrapper=wrapperRef.current;if(!wrapper)return;const form=wrapper.querySelector(\"form\");if(!form)return;// ── Disable submit button until verified ────────────────────\nconst disableSubmit=disabled=>{const buttons=form.querySelectorAll('button[type=\"submit\"], button:not([type])');buttons.forEach(btn=>{btn.disabled=disabled;btn.style.opacity=disabled?\"0.5\":\"1\";btn.style.cursor=disabled?\"not-allowed\":\"pointer\";});};disableSubmit(true);// ── Hidden input for the token ───────────────────────────────\n// Cloudflare's widget auto-injects <input name=\"cf-turnstile-response\"> into\n// the form — we rely on that and skip creating our own to avoid duplicates.\n// Old approach (kept for reference):\n// const hiddenInput = document.createElement(\"input\");\n// hiddenInput.type = \"hidden\";\n// hiddenInput.name = \"cf-turnstile-response\";\n// hiddenInput.value = \"\";\n// form.appendChild(hiddenInput);\n// hiddenInputRef.current = hiddenInput;\n// Wait for Cloudflare to inject its input, then grab a reference to it.\nconst resolveHiddenInput=()=>{const existing=form.querySelector('input[name=\"cf-turnstile-response\"]');if(existing)hiddenInputRef.current=existing;};resolveHiddenInput();// Re-check after verified event fires in case the input wasn't in the DOM yet\nwindow.addEventListener(\"turnstile-verified\",resolveHiddenInput,{once:true});// ── Listen for events from TurnstileWidget component ────────\nconst onVerified=e=>{const token=e.detail.token;tokenRef.current=token;if(hiddenInputRef.current)hiddenInputRef.current.value=token;disableSubmit(false);};const onExpired=()=>{tokenRef.current=\"\";if(hiddenInputRef.current)hiddenInputRef.current.value=\"\";disableSubmit(true);};const onError=()=>{tokenRef.current=\"\";disableSubmit(true);};window.addEventListener(\"turnstile-verified\",onVerified);window.addEventListener(\"turnstile-expired\",onExpired);window.addEventListener(\"turnstile-error\",onError);// ── Block submit if not verified ────────────────────────────\nconst handleSubmit=e=>{if(!tokenRef.current){e.preventDefault();e.stopPropagation();e.stopImmediatePropagation();return false;}};form.addEventListener(\"submit\",handleSubmit,true);// ── Cleanup ─────────────────────────────────────────────────\nreturn()=>{form.removeEventListener(\"submit\",handleSubmit,true);window.removeEventListener(\"turnstile-verified\",onVerified);window.removeEventListener(\"turnstile-expired\",onExpired);window.removeEventListener(\"turnstile-error\",onError);// hiddenInput is owned by Cloudflare's widget — don't remove it\n};},[]);return /*#__PURE__*/_jsx(\"div\",{ref:wrapperRef,children:/*#__PURE__*/_jsx(Component,{...props})});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withTurnstile\":{\"type\":\"reactHoc\",\"name\":\"withTurnstile\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TurnstileProtection.map","// TurnstileWidget.tsx — Framer Code Component\n// Renders a Cloudflare Turnstile widget with a visible placeholder in the editor.\n// Place this component where you want the \"Verify you're human\" challenge to appear.\n//\n// How to use in Framer:\n//   1. Go to Assets → Code → New Component, paste this code\n//   2. Drag the component into your page, position it where you want the widget\n//   3. It shows a placeholder in the editor; in preview/published it renders the real widget\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";// ─── Configuration ──────────────────────────────────────────────────────────\nconst TURNSTILE_SITE_KEY=\"0x4AAAAAACVY1MP0UxuPpp_S\";const TURNSTILE_SCRIPT_URL=\"https://challenges.cloudflare.com/turnstile/v0/api.js\";const WIDGET_WIDTH=300;const WIDGET_HEIGHT=65;export default function TurnstileWidget({theme=\"light\"}){const containerRef=useRef(null);const widgetIdRef=useRef(null);const[isFramerCanvas,setIsFramerCanvas]=useState(false);useEffect(()=>{const isCanvas=RenderTarget.current()===\"CANVAS\";if(isCanvas){setIsFramerCanvas(true);return;}// ── Load and render Turnstile ───────────────────────────────\nconst render=()=>{const turnstile=window.turnstile;if(!turnstile||!containerRef.current)return;// Clean up previous widget if any\nif(widgetIdRef.current){try{turnstile.remove(widgetIdRef.current);}catch{}}widgetIdRef.current=turnstile.render(containerRef.current,{sitekey:TURNSTILE_SITE_KEY,theme,callback:token=>{// Dispatch a custom event so the override can pick up the token\nwindow.dispatchEvent(new CustomEvent(\"turnstile-verified\",{detail:{token}}));},\"expired-callback\":()=>{window.dispatchEvent(new CustomEvent(\"turnstile-expired\"));},\"error-callback\":()=>{window.dispatchEvent(new CustomEvent(\"turnstile-error\"));}});};const existing=document.querySelector(`script[src=\"${TURNSTILE_SCRIPT_URL}\"]`);if(existing){if(window.turnstile){render();}else{existing.addEventListener(\"load\",render);}}else{const script=document.createElement(\"script\");script.src=TURNSTILE_SCRIPT_URL;script.async=true;script.defer=true;script.onload=render;document.head.appendChild(script);}return()=>{const turnstile=window.turnstile;if(turnstile&&widgetIdRef.current){try{turnstile.remove(widgetIdRef.current);}catch{}}};},[theme]);// ── Editor placeholder ──────────────────────────────────────────\nif(isFramerCanvas){return /*#__PURE__*/_jsxs(\"div\",{style:{width:WIDGET_WIDTH,height:WIDGET_HEIGHT,borderRadius:4,border:\"2px dashed #ccc\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",backgroundColor:\"#f9f9f9\",fontFamily:\"Inter, system-ui, sans-serif\",fontSize:13,color:\"#666\",gap:8},children:[/*#__PURE__*/_jsx(\"svg\",{width:\"20\",height:\"20\",viewBox:\"0 0 24 24\",fill:\"none\",stroke:\"#999\",strokeWidth:\"2\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z\"})}),\"Turnstile Widget\"]});}// ── Runtime: real widget renders here ────────────────────────────\nreturn /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{display:\"flex\",justifyContent:\"center\",minHeight:WIDGET_HEIGHT,width:\"100%\"}});}// ─── Framer Property Controls ───────────────────────────────────────────────\naddPropertyControls(TurnstileWidget,{theme:{type:ControlType.Enum,title:\"Theme\",options:[\"light\",\"dark\",\"auto\"],optionTitles:[\"Light\",\"Dark\",\"Auto\"],defaultValue:\"light\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TurnstileWidget\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TurnstileWidget.map"],"mappings":"oNAUA,SAAgB,EAAc,EAAU,CAAC,MAAO,IAAO,CAAC,IAAM,EAAWA,EAAO,KAAK,CAAO,EAASA,EAAO,GAAG,CAAO,EAAeA,EAAO,KAAK,CAiBzI,OAjB0I,MAAc,CAAC,IAAM,EAAQ,EAAW,QAAQ,GAAG,CAAC,EAAQ,OAAO,IAAM,EAAK,EAAQ,cAAc,OAAO,CAAC,GAAG,CAAC,EAAK,OACvQ,IAAM,EAAc,GAAU,CAAe,EAAK,iBAAiB,4CAA4C,CAAS,QAAQ,GAAK,CAAC,EAAI,SAAS,EAAS,EAAI,MAAM,QAAQ,EAAS,MAAM,IAAI,EAAI,MAAM,OAAO,EAAS,cAAc,WAAY,EAAG,EAAc,GAAK,CAW3Q,IAAM,MAAuB,CAAC,I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