1import{j as e}from"./ui-CRfrqFYg.js";import{h as d,u as k,r as u}from"./vendor-BWGWb13B.js";import{s as x,L as h}from"./index-DL2CIW7t.js";import"./query-BfS8OGlq.js";import"./motion-dpBNAuY6.js";import"./dates-CYSaORGK.js";function N(){const[t]=d(),o=k(),[s,r]=u.useState(null);return u.useEffect(()=>{const n=t.get("code"),i=t.get("state"),c=t.get("error");if(c){r(t.get("error_description")||c);return}if(!n){r("No authorization code received from TikTok");return}const m=localStorage.getItem("tiktok_oauth_state");if(m&&i!==m){r("OAuth state mismatch. Please try connecting again."),localStorage.removeItem("tiktok_oauth_state");return}localStorage.removeItem("tiktok_oauth_state"),(async()=>{try{const{data:a,error:l}=await x.functions.invoke("tiktok-auth/callback",{body:{code:n,state:i}});if(l)throw l;if(a?.error)throw new Error(a.error);o("/admin/integrations/tiktok?connected=true",{replace:!0})}catch(a){r(a.message||"Failed to connect TikTok account")}})()},[t,o]),s?e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:e.jsxs("div",{className:"text-center space-y-4 max-w-md",children:[e.jsx("h2",{className:"text-xl font-semibold text-destructive",children:"Connection Failed"}),e.jsx("p",{className:"text-muted-foreground",children:s}),e.jsx("button",{onClick:()=>o("/admin/integrations/tiktok"),className:"underline text-primary",children:"Back to TikTok Settings"})]})}):e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx(h,{className:"h-8 w-8 animate-spin mx-auto text-primary"}),e.jsx("p",{className:"text-muted-foreground",children:"Connecting your TikTok account..."})]})})}export{N as default};
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.