1import{j as e}from"./vendor-query-CsHYnmF8.js";import{r as n}from"./vendor-i18n-FzC2q7WE.js";import{u as v,Q as w,q as y,L as j,v as C,B as o,F as S}from"./index-wKN3roZE.js";import{u as A}from"./usePageMeta-h8XNEFq-.js";import{e as q,L as h}from"./vendor-react-CmGg2B8n.js";import{C as B}from"./circle-check-Rl5s-96j.js";import{C as L}from"./circle-x-D-NsqnPB.js";import{U as P}from"./user-BitbI_GZ.js";import{S as T}from"./scan-search-E2rRicG5.js";import{F as U}from"./folder-kanban-DxvpepV9.js";import"./vendor-supabase-DinKeC8L.js";import"./vendor-ui-CakNjGXO.js";const E="https://ivxepyunbfkmfjoylrkh.supabase.co/functions/v1/figma-plugin-api",K=()=>{A({title:"Connect Fleck to Figma â Fleck",description:"Approve or cancel the Fleck AI Figma plugin's request to connect to your Fleck account.",canonical:"/figma/connect",noindex:!0});const[p]=q(),d=p.get("request")??"",u=p.get("approval")??"",{user:r,session:i,loading:g}=v(),[c,s]=n.useState("loading"),[k,l]=n.useState(null),[x,f]=n.useState(!1),N=n.useMemo(()=>"This request expires 10 minutes after it was created in Figma.",[]);n.useEffect(()=>{if(!g){if(!d||!u){l("This connection link is incomplete. Please start again from the Figma plugin."),s("error");return}if(!r){window.location.href=w(`/figma/connect${window.location.search}`);return}s("review")}},[g,r,d,u]);const b=async m=>{if(i!=null&&i.access_token){f(!0),l(null);try{const a=await fetch(`${E}?action=auth-complete`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i.access_token}`},body:JSON.stringify({requestId:d,approvalSecret:u,decision:m})}),t=await a.json().catch(()=>null);if(!a.ok||!(t!=null&&t.ok)){l((t==null?void 0:t.error)??"We couldn't complete this request. Please try again from Figma."),s("error");return}s(m==="approve"?"approved":"denied")}catch{l("Network error. Please check your connection and try again."),s("error")}finally{f(!1)}}},F=[{icon:P,label:"View basic Fleck account information"},{icon:S,label:"View your available credit balance"},{icon:T,label:"Submit selected Figma frames for UX Audit"},{icon:U,label:"Connect selected frames to Fleck projects"}];return e.jsx("main",{className:"min-h-screen bg-background flex items-center justify-center px-4 py-10",children:e.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-border bg-card shadow-sm p-6 sm:p-8",children:[e.jsx("div",{className:"flex items-center justify-center w-12 h-12 rounded-xl bg-primary/10 mb-4",children:e.jsx(y,{className:"w-6 h-6 text-primary"})}),c==="loading"?e.jsxs("div",{className:"flex items-center justify-center py-10 text-muted-foreground text-sm gap-2",children:[e.jsx(j,{className:"w-4 h-4 animate-spin"})," Checking your Fleck account..."]}):c==="error"?e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground mb-2",children:"We couldn't load this request"}),e.jsxs("div",{className:"flex gap-2 items-start text-sm text-muted-foreground rounded-lg border border-destructive/20 bg-destructive/5 p-3 mb-6",children:[e.jsx(C,{className:"w-4 h-4 text-destructive mt-0.5 shrink-0"}),e.jsx("span",{children:k??"Something went wrong."})]}),e.jsx(o,{asChild:!0,variant:"outline",className:"w-full",children:e.jsx(h,{to:"/",children:"Back to Fleck"})})]}):c==="approved"?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-6 h-6 text-primary mb-3"}),e.jsx("h1",{className:"text-lg font-semibold text-foreground mb-2",children:"Fleck is connected to Figma"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-6",children:"You can return to the Figma app."}),e.jsx(o,{asChild:!0,variant:"outline",className:"w-full",children:e.jsx(h,{to:"/",children:"Back to Fleck"})})]}):c==="denied"?e.jsxs(e.Fragment,{children:[e.jsx(L,{className:"w-6 h-6 text-muted-foreground mb-3"}),e.jsx("h1",{className:"text-lg font-semibold text-foreground mb-2",children:"Connection cancelled"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-6",children:"You can return to Figma."}),e.jsx(o,{asChild:!0,variant:"outline",className:"w-full",children:e.jsx(h,{to:"/",children:"Back to Fleck"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground mb-1",children:"Connect Fleck to Figma?"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-5",children:"The Fleck AI Figma plugin is asking to connect to your Fleck account."}),e.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 p-4 mb-5 space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground mb-1",children:"Signed in as"}),e.jsx("div",{className:"text-foreground truncate",children:r==null?void 0:r.email})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground mb-1",children:"The plugin will be able to"}),e.jsx("ul",{className:"space-y-2 text-foreground",children:F.map(({icon:m,label:a})=>e.jsxs("li",{className:"flex gap-2 items-start",children:[e.jsx(m,{className:"w-4 h-4 text-primary mt-0.5 shrink-0"}),e.jsx("span",{children:a})]},a))})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(o,{onClick:()=>b("approve"),disabled:x,className:"w-full h-10",children:x?e.jsx(j,{className:"w-4 h-4 animate-spin"}):"Approve"}),e.jsx(o,{onClick:()=>b("deny"),disabled:x,variant:"ghost",className:"w-full h-10 text-muted-foreground hover:text-foreground",children:"Cancel"})]}),e.jsxs("p",{className:"text-[11px] text-muted-foreground text-center mt-4 leading-relaxed",children:[N," You can revoke access any time from the plugin."]})]})]})})};export{K 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.