"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),l=require("react"),f=require("react-router"),g=require("./internalTrafficUtils.js"),x=({token:c})=>{const[a]=f.useSearchParams(),d=f.useNavigate(),[e,s]=l.useState("validating"),[u,n]=l.useState("Processing...");l.useEffect(()=>{const o=a.get("enable"),v=a.get("k");if(!g.validateToken(v,c)){s("error"),n("Invalid or missing token. Access denied."),console.error("Invalid token provided for internal traffic toggle");return}if(o!=="0"&&o!=="1"){s("error"),n("Invalid enable parameter. Use ?enable=0 or ?enable=1"),console.error("Invalid enable parameter:",o);return}try{const r=o==="1";g.setInternalTrafficCookie(r),s("success"),n(r?"✓ Internal traffic enabled. GA4 events will be tagged as internal.":"✓ Internal traffic disabled. GA4 events will be tagged as external."),console.log(`Internal traffic ${r?"enabled":"disabled"} successfully`),setTimeout(()=>{d("/")},3e3)}catch(r){s("error"),n(`Error: ${r instanceof Error?r.message:"Unknown error"}`),console.error("Error setting internal traffic cookie:",r)}},[a,c,d]);const b={display:"flex",justifyContent:"center",alignItems:"center",minHeight:"100vh",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'},i={textAlign:"center",padding:"2rem",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.1)",maxWidth:"500px"},m=e==="success"?{...i,backgroundColor:"#f0f9ff",borderLeft:"4px solid #10b981"}:e==="error"?{...i,backgroundColor:"#fef2f2",borderLeft:"4px solid #ef4444"}:{...i,backgroundColor:"#f3f4f6",borderLeft:"4px solid #3b82f6"},p={fontSize:"1.5rem",fontWeight:"600",margin:"0 0 1rem 0",color:e==="success"?"#059669":e==="error"?"#dc2626":"#1f2937"},y={fontSize:"1rem",margin:"1rem 0",color:e==="success"?"#047857":e==="error"?"#991b1b":"#374151",lineHeight:"1.5"},S={fontSize:"0.875rem",color:"#6b7280",marginTop:"1.5rem",fontStyle:"italic"};return t.jsx("div",{style:b,children:t.jsxs("div",{style:m,children:[t.jsx("h1",{style:p,children:e==="success"?"Success":e==="error"?"Error":"Processing"}),t.jsx("p",{style:y,children:u}),e==="success"&&t.jsx("p",{style:S,children:"Redirecting to home page in 3 seconds..."})]})})};exports.default=x;
