"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("react/jsx-runtime"),l=require("react"),g=require("react-router"),u=require("./internalTrafficUtils.js"),h=({token:c,redirectTo:d="/"})=>{const[a]=g.useSearchParams(),f=g.useNavigate(),[e,t]=l.useState("validating"),[b,n]=l.useState("Processing...");l.useEffect(()=>{const o=a.get("enable"),x=a.get("k");if(!u.validateToken(x,c)){t("error"),n("Invalid or missing token. Access denied."),console.error("Invalid token provided for internal traffic toggle");return}if(o!=="0"&&o!=="1"){t("error"),n("Invalid enable parameter. Use ?enable=0 or ?enable=1"),console.error("Invalid enable parameter:",o);return}try{const r=o==="1";u.setInternalTrafficCookie(r),t("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(()=>{f(d)},3e3)}catch(r){t("error"),n(`Error: ${r instanceof Error?r.message:"Unknown error"}`),console.error("Error setting internal traffic cookie:",r)}},[a,c,f,d]);const m={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"},p=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"},y={fontSize:"1.5rem",fontWeight:"600",margin:"0 0 1rem 0",color:e==="success"?"#059669":e==="error"?"#dc2626":"#1f2937"},S={fontSize:"1rem",margin:"1rem 0",color:e==="success"?"#047857":e==="error"?"#991b1b":"#374151",lineHeight:"1.5"},v={fontSize:"0.875rem",color:"#6b7280",marginTop:"1.5rem",fontStyle:"italic"};return s.jsx("div",{style:m,children:s.jsxs("div",{style:p,children:[s.jsx("h1",{style:y,children:e==="success"?"Success":e==="error"?"Error":"Processing"}),s.jsx("p",{style:S,children:b}),e==="success"&&s.jsx("p",{style:v,children:"Redirecting to home page in 3 seconds..."})]})})};exports.default=h;
