1import{l as Ge,n as We,a as d,j as n}from"./vendor-react-B138QwH7.js";import{a as X}from"./vendor-data-B5dyDEkI.js";import{T as Fe,E as Ye,t as N}from"./AppPrivate-D86La96B.js";import{supabase as q}from"./supabaseClient-Dg8qU-k4.js";import{u as Ke,v as Qe,I as je,B as $,R as Xe}from"./index-DeLxZwuS.js";import{u as Je,a as Ze,b as en,aB as nn,B as G,ay as tn,n as rn,x as on,w as sn,aC as an,aD as dn}from"./usePlanFeatures-C28YDrt6.js";import{T as ln}from"./textarea-Ch-ZmsBD.js";import{P as Ne}from"./PageHero-BUNIKx4m.js";import{b as _e}from"./ShellHeader-C1AWFlW8.js";import{n as cn,C as un,g as mn,e as pn,f as fn,j as xn}from"./vttConnections-B9jdFl38.js";import{L as ae}from"./link-2-BgOwPpYk.js";import{L as Se}from"./label-V8Vm6spV.js";import{C as gn}from"./circle-check-q4Cny2FW.js";import"./vendor-radix-5UMTW6R-.js";import"./vendor-ui-utils-C_CMQnMN.js";const hn="rollcodex:vtt-pairing-handshake",yn="rollcodex:vtt-pairing-handshake-response",bn="rollcodex:vtt-connection-complete",Be="rollcodex-app",vn="rollcodex-roll20-bridge",Cn="ROLLCODEX_ROLL20_BRIDGE_PING",wn="ROLLCODEX_ROLL20_BRIDGE_READY",jn="ROLLCODEX_ROLL20_CONFIRM",Nn="ROLLCODEX_ROLL20_CONFIRM_RESULT",_n=2200,Sn=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,Oe=/^[a-f0-9]{64}$/i;function b(e,r){return String(e.get(r)||"").trim()}function Me(e){try{const r=new URL(String(e||"").trim()).origin;return r==="null"?"":r}catch{return""}}function ke(e){return String(e??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}function Le(e,r){var s;const l=Array.isArray(e)?e:[],a=ke(r);if(a){const g=l.find(h=>ke((h==null?void 0:h.name)||(h==null?void 0:h.label))===a);if(g!=null&&g.id)return g.id}return l.length===1&&((s=l[0])==null?void 0:s.id)||""}function Ve({state:e,secretHash:r}){return`${String(r||"").slice(0,4)}-${String(e||"").slice(-4)}`.toUpperCase()}function kn(e,r){if(!e||typeof e!="object"||e.type!==yn||e.state!==r.state||e.connectionId!==r.connectionId)return null;const l=String(e.secretHash||e.secret_hash||"").trim().toLowerCase();if(!Oe.test(l))return null;const a=String(e.secretPrefix||e.secret_prefix||"").trim()||null,s=String(e.pairingCode||e.pairing_code||"").trim()||Ve({state:r.state,secretHash:l});return{secretHash:l,secretPrefix:a,pairingCode:s}}function W(e,r,l){return b(e,`${r}_${l}`)||b(e,l)}function Ln(e,r){const l=b(e,"connection_id"),a=b(e,"state"),s=Me(b(e,"source_origin")),g=W(e,r,"game_id")||b(e,"foundry_world_id"),h=W(e,r,"game_title")||b(e,"foundry_world_title"),_=W(e,r,"system_id")||b(e,"foundry_system_id"),V=W(e,r,"system_title")||b(e,"foundry_system_title"),J=W(e,r,"ver
1sion")||b(e,"foundry_version");return{provider:r,state:a,connectionId:l,sourceOrigin:s,gameId:g,gameTitle:h,providerSystemId:_,providerSystemTitle:V,providerVersion:J,moduleVersion:b(e,"module_version"),isValid:!!(a&&Sn.test(l)&&s)}}function In(e){try{return e?new URL(e).origin:"*"}catch{return"*"}}function Ie(e){try{const r=new URL(String(e||"").trim());return["localhost","127.0.0.1","::1","[::1]"].includes(r.hostname.toLowerCase())}catch{return!1}}function En(e){return Me(e)==="https://app.roll20.net"}function Rn(e){var a;if(!e.isValid)return!1;const r=Ie(e.sourceOrigin)&&Ie((a=globalThis.location)==null?void 0:a.origin),l=e.provider==="roll20"&&En(e.sourceOrigin);return r||l}function Tn(e,r){if(!Rn(r))return null;const l=b(e,"local_secret_hash").toLowerCase();if(!Oe.test(l))return null;const a=Ve({state:r.state,secretHash:l}),s=b(e,"local_pairing_code").toUpperCase();return s&&s!==a?null:{secretHash:l,secretPrefix:b(e,"local_secret_prefix")||null,pairingCode:a}}function Bn(e,r){return(e==null?void 0:e.message)||(e==null?void 0:e.details)||r}function On(e){if(typeof e=="boolean")return e;if(typeof e=="number")return e===1;const r=String(e??"").trim().toLowerCase();return["true","1","yes","on"].includes(r)}function Ee(e,r){return e?r?!0:tn(rn(e._workspace_role),!1):!1}function de(e){return(e==null?void 0:e.provider)==="roll20"?`!rollcodex confirm ${JSON.stringify(e)}`:JSON.stringify(e,null,2)}async function Re(e){var r;return!e||!((r=navigator.clipboard)!=null&&r.writeText)?!1:(await navigator.clipboard.writeText(de(e)),!0)}function De(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`roll20-bridge-${Date.now()}-${Math.random().toString(16).slice(2)}`}function Ae(e,r,l=_n){return typeof window>"u"?Promise.resolve({ok:!1,unavailable:!0}):new Promise(a=>{const s=window.setTimeout(()=>{window.removeEventListener("message",g),a({ok:!1,unavailable:!0})},l);function g(h){if(h.source!==window)return;const _=h.data||{};_.source!==vn||_.type!==r||_.requestId!==e||(window.clearTimeout(s),window.removeEventListener("message",g),a({ok:!!_.ok,error:_.error||""}))}window.addEventListener("message",g)})}async function Mn(){if(typeof window>"u")return{ok:!1,unavailable:!0};const e=De(),r=Ae(e,wn,800);return window.postMessage({source:Be,type:Cn,requestId:e},window.location.origin),r}async function Te(e){if(typeof window>"u"||(e==null?void 0:e.provider)!=="roll20")return{ok:!1,unavailable:!0};const r=De(),l=Ae(r,Nn);return window.postMessage({source:Be,type:jn,requestId:r,command:de(e),context:{connectionId:e.connectionId,state:e.state,tableId:e.tableId}},window.location.origin),l}function Vn(e,r){const l=String((e==null?void 0:e.message)||"").trim();return(e==null?void 0:e.code)==="23505"||/idx_vtt_connections_one_active_per_table|duplicate key value/i.test(l)?r("foundryConnect.tableAlreadyLinked"):/row-level security|permission denied|42501/i.test(l)||(e==null?void 0:e.code)==="42501"?r("foundryConnect.toasts.permissionOrPlanError"):Bn(e,r("foundryConnect.toasts.error"))}function Jn(){var ve;const{t:e}=Ke("import"),[r]=Ge(),{provider:l}=We(),a=cn(l||r.get("provider")||"foundry")||"foundry",s=mn(a),{user:g}=Je(),{workspaces:h,activeWorkspaceId:_,isLoadingWorkspaces:V,selectWorkspace:J,effectiveIsSuperAdmin:Z}=Ze(),{activeSystem:ee}=en(),o=d.useMemo(()=>Ln(r,a),[a,r]),L=d.useMemo(()=>Qe(),[]),ne=d.useMemo(()=>{var t;return L.some(i=>i.id===o.providerSystemId)?o.providerSystemId:L.some(i=>i.id===ee)?ee:((t=L[0])==null?void 0:t.id)||"dnd5e"},[ee,o.providerSystemId,L]),[p,le]=d.useState(""),[S,ce]=d.useState(ne),[y,H]=d.useState(""),[v,T]=d.useState(""),[ue,me]=d.useState(!1),[m,qe]=d.useState(null),[He,F]=d.useState(!1),[P,B]=d.useState("unknown"),[Pe,U]=d.useState(""),[Ue,pe]=d.useState(null),[te,D]=d.useState("idle"),Y=a==="roll20",re=d.useMemo(()=>Tn(r,o),[o,r]),c=Ue||re,fe=d.useMemo(()=>m?de(m):"",[m]),I=d.useMemo(()=>h.filter(t=>Ee(t,Z)),[Z,h]);d.useEffect(()=>{var f;if(V||I.some(x=>x.id===p))return;const i=I.some(x=>x.id===_)?_:(f=I[0])==null?void 0:f.id;le(i||""),H(""),T("")},[_,I,V,p]),d.useEffect(()=>{ce(ne)},[ne]),d.useEffect(()=>{if(!Y)return;let t=!0;return Mn().then(i=>{t&&(B(i.ok?"available":"unavailable"),U(""))}),()=>{t=!1}},[Y]),d.useEffect(()=>{if(pe(null),re){D("ready");return}if(D(o.isValid?"pending":"idle"),!o.isValid)return;const t=window.opener;if(!t){D("missing-opener");return}const i=o.sourceOrigin,f=window.setTimeout(()=>{D(k=>k==="ready"?k:"timeout")},8e3);function x(k){if(k.origin!==i)return;const M=kn(k.data,o);M&&(window.clearTimeout(f),pe(M),D("ready"))}window.addEventListener("message",x);try{t.postMessage({type:hn,state:o.state,connectionId:o.connectionId},i)}catch{window.clearTimeout(f),D("failed")}return()=>{window.clearTimeout(f),window.removeEventListener("message",x)}},[re,o]);const u=d.useMemo(()=>I.find(t=>
1t.id===p)||null,[I,p]),O=d.useMemo(()=>L.find(t=>t.id===S)||L[0],[S,L]),C=Ee(u,Z),oe=X({queryKey:["vtt-pairing-connected-vtt-entitlement",a,p],enabled:!!p,queryFn:async()=>{var M;const[t,i]=await Promise.all([q.from("workspace_entitlements").select("key,value,updated_at").eq("workspace_id",p).eq("key","connected_vtt_snapshots").order("updated_at",{ascending:!1}).limit(1),q.from("workspace_subscriptions").select("workspace_id,plan_code,status,created_at").eq("workspace_id",p).order("created_at",{ascending:!1})]);if(t.error)throw t.error;if(i.error)throw i.error;const f=(M=t.data)==null?void 0:M[0];if(f)return{hasConnectedVttSnapshots:On(f.value)};const x=on(i.data||[]),k=sn({workspace:u,subscription:x});return{hasConnectedVttSnapshots:an(x==null?void 0:x.status)&&dn(k)}}}),xe=oe.isLoading||oe.isFetching,se=((ve=oe.data)==null?void 0:ve.hasConnectedVttSnapshots)===!0;C&&se&&(c!=null&&c.secretHash);const ge=nn(),E=X({queryKey:["vtt-pairing-campaigns",a,p,S],enabled:!!(p&&S&&C),queryFn:async()=>{const{data:t,error:i}=await q.from("campaigns").select("id,name,system_id,workspace_id").eq("workspace_id",p).eq("system_id",S).order("name",{ascending:!0});if(i)throw i;return t||[]}}),R=X({queryKey:["vtt-pairing-tables",a,p,y],enabled:!!(p&&y&&C),queryFn:async()=>{const{data:t,error:i}=await q.from("tables").select("id,name,campaign_id,workspace_id").eq("workspace_id",p).eq("campaign_id",y).order("name",{ascending:!0});if(i)throw i;return t||[]}}),K=X({queryKey:["vtt-pairing-active-table-connections",a,p,S],enabled:!!(p&&S&&C),queryFn:async()=>{const{data:t,error:i}=await q.from("vtt_connections").select("id,table_id,label,provider,status").eq("workspace_id",p).eq("system_id",S).eq("status","active").not("table_id","is",null);if(i)throw i;return t||[]}}),w=d.useMemo(()=>(E.data||[]).find(t=>t.id===y)||null,[E.data,y]),j=d.useMemo(()=>(R.data||[]).find(t=>t.id===v)||null,[v,R.data]),Q=d.useMemo(()=>new Map((K.data||[]).map(t=>[t.table_id,t])),[K.data]),he=v?Q.get(v):null,ie=!!(he&&he.id!==o.connectionId);d.useEffect(()=>{if(m||y||E.isLoading||!C)return;const t=Le(E.data||[],o.gameTitle);t&&(H(t),T(""))},[E.data,E.isLoading,C,o.gameTitle,y,m]),d.useEffect(()=>{if(m||!y||v||R.isLoading||K.isLoading||!C)return;const t=(R.data||[]).filter(f=>{const x=Q.get(f.id);return!x||x.id===o.connectionId}),i=Le(t,o.gameTitle);i&&T(i)},[Q,K.isLoading,C,o.connectionId,o.gameTitle,y,v,m,R.data,R.isLoading]);const ye=d.useMemo(()=>[{label:e("foundryConnect.chainWorld"),value:o.gameTitle||e("foundryConnect.unknownWorld",{provider:s})},{label:e("foundryConnect.chainRegistry"),value:(u==null?void 0:u.name)||"-"},{label:e("foundryConnect.chainCampaign"),value:(w==null?void 0:w.name)||e("foundryConnect.noCampaign")},{label:e("foundryConnect.chainTable"),value:(j==null?void 0:j.name)||e("foundryConnect.noTable")}],[o.gameTitle,s,w==null?void 0:w.name,j==null?void 0:j.name,u==null?void 0:u.name,e]);async function ze(){var t;if(!(!o.isValid||!u||!O||!(g!=null&&g.id))){if(!(c!=null&&c.secretHash)){N.error(e("foundryConnect.pairingHandshakeRequired",{provider:s}));return}if(!v){N.error(e("foundryConnect.tableRequired"));return}if(ie){N.error(e("foundryConnect.tableAlreadyLinked"));return}if(!C){N.error(e("foundryConnect.permissionDenied"));return}if(!se){N.error(e("foundryConnect.planDenied",{plan:ge,provider:s}));return}me(!0);try{const i=pn(),f=fn(),x=o.gameTitle?`${s} - ${o.gameTitle}`:s,k=a==="foundry"?{foundry_world_id:o.gameId||null,foundry_world_title:o.gameTitle||null,foundry_system_id:o.providerSystemId||null,foundry_system_title:o.providerSystemTitle||null,foundry_version:o.providerVersion||null}:{},M={id:o.connectionId,...xn({workspaceId:u.id,provider:a,label:x,systemId:O.id,secretHash:c.secretHash,secretPrefix:c.secretPrefix||null,createdBy:g.id}),campaign_id:y||null,table_id:v||null,metadata_json:{source:`${a}_module_pairing`,campaign_id:y||null,table_id:v||null,provider_game_id:o.gameId||null,provider_game_title:o.gameTitle||null,provider_system_id:o.providerSystemId||null,provider_system_title:o.providerSystemTitle||null,provider_version:o.providerVersion||null,module_version:o.moduleVersion||null,...k}},{error:Ce}=await q.from("vtt_connections").upsert(M,{onConflict:"id"});if(Ce)throw Ce;J(u.id,h);const A={type:bn,provider:a,state:o.state,connectionId:o.connectionId,endpoint:i,mappingProfileEndpoint:f,workspaceId:u.id,workspaceLabel:u.name,systemId:O.id,systemLabel:O.label,campaignId:y||null,campaignLabel:(w==null?void 0:w.name)||null,tableId:v||null,tableLabel:(j==null?void 0:j.name)||null},we=In(o.sourceOrigin);(t=window.opener)==null||t.postMessage(A,we),window.parent&&window.parent!==window&&window.parent.postMessage(A,we),qe(A),F(!1),Re(A).then(z=>F(z)).catch(()=>F(!1)),A.provider==="roll20"&&(B("sending"),U(""),Te(A).then(z=>{if(z.ok){B("sent"),N.success(e("foundryConnect.toasts.roll20BridgeSent"));return}B(z.unavailable?"unavailable":"error"),U(z.error||"")})),N.success(e("foundryConnect.toasts.connected",{provider:s}))}catch(i){N.error(Vn(i,e))}finally{me(!1)}}}async function be(){if(m)try{await Re(m),F(!0),N.success(e("foundryConnect.toasts.confirmationCopied",{provider:s}))}catch{N.error(e("foundryConnect.toasts.confirmationCopyError",{provider:s}))}}async function $e(){if(!m)return;B("sending"),U("");const t=await Te(m);if(t.ok){B("sent"),N.success(e("foundryConnect.toasts.roll20BridgeSent"));return}B(t.unavailable?"unavailable":"error"),U(t.error||""),N.error(e("foundryConnect.toasts.roll20BridgeError"))}return o.isValid?n.jsxs("div",{className:"rl-page-shell rl-page-shell--import",children:[n.jsx(_e,{children:n.jsx(Ne,{eyebrow:e("foundryConnect.eyebrow",{provider:s}),title:e("foundryConnect.title",{provider:s}),description:e("foundryConnect.description",{provider:s}),actions:n.jsx(G,{variant:m?"success":"secondary",className:"whitespace-nowrap",children:e(m?"foundryConnect.connectedBadge":"foundryConnect.pendingBadge")}),children:n.jsxs("div",{className:"flex flex-wrap gap-2",children:[o.providerVersion?n.jsx(G,{variant:"outline",children:e("foundryConnect.providerVersion",{provider:s,version:o.providerVersion})}):null,o.moduleVersion?n.jsx(G,{variant:"outline",children:e("foundryConnect.moduleVersion",{version:o.moduleVersion})}):null,n.jsx(G,{variant:"secondary",children:(O==null?void 0:O.label)||S})]})})}),n.jsx("section",{className:"rl-codex-surface rl-mj-workbench p-3 sm:p-4",children:n.jsxs("div",{className:"rl-context-strata",children:[n.jsx("div",{className:"rl-campaign-card border p-4",children:n.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[n.jsx("div",{className:"rl-icon-well h-10 w-10 shrink-0",children:n.jsx(ae,{className:"h-4 w-4"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground",children:e("foundryConnect.world",{provider:s})}),n.jsx("p",{className:"mt-2 truncate text-base font-semibold text-foreground",children:o.gameTitle||e("foundryConnect.unknownWorld",{provider:s})})]})]})}),n.jsxs("div",{className:"rl-table-card border p-4",children:[n.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground",children:e("foundryConnect.chainRegistry")}),n.jsx("p",{className:"mt-2 truncate text-base font-semibold text-foreground",children:(u==null?void 0:u.name)||"-"}),n.jsxs("div",{className:"mt-3 grid gap-2 text-xs text-muted-foreground",children:[n.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[n.jsx("span",{children:e("foundryConnect.chainCampaign")}),n.jsx("span",{className:"truncate text-foreground",children:(w==null?void 0:w.name)||e("foundryConnect.
1noCampaign")})]}),n.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[n.jsx("span",{children:e("foundryConnect.chainTable")}),n.jsx("span",{className:"truncate text-foreground",children:(j==null?void 0:j.name)||e("foundryConnect.noTable")})]})]})]}),n.jsx("div",{className:"rl-stat-well border p-4",children:n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx(je,{className:"mt-0.5 h-4 w-4 shrink-0 text-primary"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground",children:e("foundryConnect.localProofTitle")}),n.jsx("p",{className:"mt-2 break-words text-sm font-semibold text-foreground",children:(c==null?void 0:c.pairingCode)||e(`foundryConnect.handshakeStatus.${te}`,{provider:s})})]})]})})]})}),n.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.08fr)_minmax(20rem,0.92fr)]",children:[n.jsxs("section",{className:"rl-panel p-5 sm:p-6",children:[n.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"rl-icon-well h-10 w-10 shrink-0",children:n.jsx(je,{className:"h-4 w-4"})}),n.jsxs("div",{children:[n.jsx("h2",{className:"text-lg font-semibold text-foreground",children:e("foundryConnect.scopeTitle")}),n.jsx("p",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:e("foundryConnect.workspaceHelper")})]})]}),n.jsx(G,{variant:c!=null&&c.secretHash?"success":"warning",className:"w-fit whitespace-nowrap",children:c!=null&&c.secretHash?e("foundryConnect.connectedBadge"):e("foundryConnect.pendingBadge")})]}),n.jsxs("div",{className:`mb-5 rounded-md border p-3 text-sm ${c!=null&&c.secretHash?"border-success/35 bg-success/10":"border-primary/25 bg-primary/10"}`,children:[n.jsx("p",{className:"font-semibold text-foreground",children:e("foundryConnect.localProofTitle")}),n.jsx("p",{className:"mt-1 leading-6 text-muted-foreground",children:c!=null&&c.secretHash?e("foundryConnect.localProofReady",{code:c.pairingCode,origin:o.sourceOrigin,provider:s}):e(`foundryConnect.handshakeStatus.${te}`,{provider:s})})]}),n.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[n.jsxs("label",{className:"space-y-2",children:[n.jsx("span",{className:"text-sm font-medium text-foreground",children:e("foundryConnect.workspaceLabel")}),n.jsx("select",{value:p,onChange:t=>{le(t.target.value),H(""),T("")},className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground",disabled:V||!!m,children:I.map(t=>n.jsx("option",{value:t.id,children:t.name},t.id))}),n.jsx("span",{className:"block text-xs leading-5 text-muted-foreground",children:e("foundryConnect.workspaceHelper")})]}),n.jsxs("label",{className:"space-y-2",children:[n.jsx("span",{className:"text-sm font-medium text-foreground",children:e("foundryConnect.systemLabel")}),n.jsx("select",{value:S,onChange:t=>{ce(t.target.value),H(""),T("")},className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground",disabled:!!m,children:L.map(t=>n.jsx("option",{value:t.id,children:t.label},t.id))})]}),n.jsxs("label",{className:"space-y-2",children:[n.jsx("span",{className:"text-sm font-medium text-foreground",children:e("foundryConnect.campaignLabel")}),n.jsxs("select",{value:y,onChange:t=>{H(t.target.value),T("")},className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground",disabled:E.isLoading||!!m,children:[n.jsx("option",{value:"",children:e("foundryConnect.noCampaign")}),(E.data||[]).map(t=>n.jsx("option",{value:t.id,children:t.name},t.id))]})]}),n.jsxs("label",{className:"space-y-2",children:[n.jsx("span",{className:"text-sm font-medium text-foreground",children:e("foundryConnect.tableLabel")}),n.jsxs("select",{value:v,onChange:t=>T(t.target.value),className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground",disabled:!y||R.isLoading||!!m,children:[n.jsx("option",{value:"",children:e("foundryConnect.
1noTable")}),(R.data||[]).map(t=>{const i=Q.get(t.id),f=!!(i&&i.id!==o.connectionId);return n.jsx("option",{value:t.id,disabled:f,children:f?e("foundryConnect.tableAlreadyLinkedOption",{table:t.name}):t.name},t.id)})]}),n.jsx("span",{className:"block text-xs leading-5 text-muted-foreground",children:e("foundryConnect.tableOneLinkHelper")})]})]}),!I.length&&!V?n.jsx("p",{className:"mt-4 rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-muted-foreground",children:e("foundryConnect.noEligibleWorkspace")}):null,!C&&u?n.jsx("p",{className:"mt-4 rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-muted-foreground",children:e("foundryConnect.permissionDenied")}):null,C&&u&&!xe&&!se?n.jsx("p",{className:"mt-4 rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-muted-foreground",children:e("foundryConnect.planDenied",{plan:ge,provider:s})}):null,C&&u&&!v?n.jsx("p",{className:"mt-4 rounded-md border border-border/60 bg-background/35 p-3 text-sm text-muted-foreground",children:e("foundryConnect.tableRequired")}):null,ie?n.jsx("p",{className:"mt-4 rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-muted-foreground",children:e("foundryConnect.tableAlreadyLinked")}):null,n.jsxs("div",{className:"mt-5 flex flex-wrap gap-2",children:[n.jsxs($,{type:"button",onClick:ze,disabled:ue||xe||!u||!v||ie||!!m,className:"gap-2",children:[ue?n.jsx(Se,{className:"h-4 w-4 animate-spin"}):n.jsx(ae,{className:"h-4 w-4"}),e("foundryConnect.authorize")]}),n.jsx($,{asChild:!0,type:"button",variant:"outline",className:"gap-2",children:n.jsxs("a",{href:Xe.import,children:[n.jsx(Ye,{className:"h-4 w-4"}),e("foundryConnect.openImport")]})})]})]}),n.jsxs("aside",{className:"space-y-5",children:[n.jsxs("section",{className:"rl-panel p-4",children:[n.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-muted-foreground",children:e("foundryConnect.chainTitle")}),n.jsx("div",{className:"mt-4 grid gap-3",children:ye.map((t,i)=>n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsxs("div",{className:"flex flex-col items-center",children:[n.jsx("span",{className:"flex h-7 w-7 items-center justify-center rounded-md border border-border bg-background text-xs font-semibold tabular-nums text-foreground",children:i+1}),i<ye.length-1?n.jsx("span",{className:"h-5 w-px bg-border","aria-hidden":!0}):null]}),n.jsxs("div",{className:"min-w-0 flex-1 rounded-md border border-border/70 bg-background/50 p-3",children:[n.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:t.label}),n.jsx("p",{className:"mt-1 truncate text-sm font-semibold text-foreground",children:t.value})]})]},t.label))})]}),n.jsxs("section",{className:"rl-panel-muted rl-inset border border-border/60 p-4",children:[n.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-muted-foreground",children:e("foundryConnect.connection")}),n.jsxs("dl",{className:"mt-3 grid gap-3 text-sm",children:[n.jsxs("div",{children:[n.jsx("dt",{className:"text-xs font-semibold text-muted-foreground",children:e("foundryConnect.providerSystem",{provider:s})}),n.jsx("dd",{className:"mt-1 text-foreground",children:o.providerSystemTitle||o.providerSystemId||"-"})]}),n.jsxs("div",{children:[n.jsx("dt",{className:"text-xs font-semibold text-muted-foreground",children:e("foundryConnect.connection")}),n.jsx("dd",{className:"mt-1 break-all font-mono text-xs text-foreground",children:o.connectionId})]}),n.jsxs("div",{children:[n.jsx("dt",{className:"text-xs font-semibold text-muted-foreground",children:e("foundryConnect.pairingCode")}),n.jsx("dd",{className:"mt-1 break-words font-mono text-sm font-semibold text-foreground",children:(c==null?void 0:c.pairingCode)||e(`foundryConnect.handshakeStatus.${te}`,{provider:s})})]})]})]})]})]}),m?n.jsx("section",{className:"rl-panel border-success/40 bg-success/10 p-4",children:n.jsxs("div",{className:"flex gap-3",children:[n.jsx(gn,{className:"mt-0.5 h-5 w-5 shrink-0 text-success"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("h2",{className:"text-base font-semibold text-foreground",children:e("foundryConnect.successTitle")}),n.jsx("p",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:e("foundryConnect.successDescription",{provider:s})}),n.jsx("div",{className:"mt-3 grid gap-2 sm:grid-cols-3",children:["successStepProvider","successStepCapture","successStepReview"].map((t,i)=>n.jsxs("div",{className:"rounded-md border border-success/25 bg-background/45 p-3",children:[n.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:e("foundryConnect.successStepLabel",{index:i+1})}),n.jsx("p",{className:"mt-1 text-xs font-medium leading-5 text-foreground",children:e(`foundryConnect.${t}`,{provider:s})})]},t))}),n.jsx("p",{className:"mt-2 text-xs leading-5 text-muted-foreground",children:He?e("foundryConnect.confirmationCopied",{provider:s}):e("foundryConnect.confirmationFallback",{provider:s})}),Y&&fe?n.jsxs("div",{className:"mt-3 rounded-md border border-success/25 bg-background/55 p-3",children:[n.jsx("p",{className:"text-sm font-semibold text-foreground",children:e("foundryConnect.roll20ManualConfirmTitle")}),n.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:e("foundryConnect.roll20ManualConfirmDescription")}),P==="sent"?n.jsx("p",{className:"mt-2 text-xs font-medium leading-5 text-success",children:e("foundryConnect.roll20BridgeSent")}):null,P==="unavailable"?n.jsx("p",{className:"mt-2 text-xs leading-5 text-muted-foreground",children:e("foundryConnect.roll20BridgeUnavailable")}):null,P==="error"?n.jsx("p",{className:"mt-2 text-xs leading-5 text-destructive",children:e("foundryConnect.roll20BridgeError",{error:Pe||e("foundryConnect.roll20BridgeUnknownError")})}):null,n.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[n.jsxs($,{type:"button",size:"sm",onClick:$e,disabled:P==="sending",className:"gap-2",children:[P==="sending"?n.jsx(Se,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}):n.jsx(ae,{className:"h-4 w-4","aria-hidden":"true"}),e("foundryConnect.sendRoll20Bridge")]}),n.jsxs($,{type:"button",variant:"outline",size:"sm",onClick:be,className:"gap-2",children:[n.jsx(un,{className:"h-4 w-4","aria-hidden":"true"}),e("foundryConnect.copyRoll20Validation")]})]}),n.jsx(ln,{readOnly:!0,value:fe,onFocus:t=>t.currentTarget.select(),className:"mt-2 min-h-[104px] font-mono text-xs leading-5"})]}):null,Y?null:n.jsx($,{type:"button",variant:"outline",size:"sm",onClick:be,className:"mt-3",children:e("foundryConnect.copyConfirmation")})]})]})}):null]}):n.jsxs("div",{className:"rl-page-shell rl-page-shell--import",children:[n.jsx(_e,{children:n.jsx(Ne,{eyebrow:e("foundryConnect.eyebrow",{provider:s}
1),title:e("foundryConnect.invalidTitle",{provider:s}),description:e("foundryConnect.invalidDescription",{provider:s}),size:"default"})}),n.jsx("section",{className:"rl-panel max-w-3xl p-5",children:n.jsxs("div",{className:"flex gap-3",children:[n.jsx(Fe,{className:"mt-1 h-5 w-5 shrink-0 text-destructive"}),n.jsxs("div",{children:[n.jsx("h1",{className:"text-xl font-semibold text-foreground",children:e("foundryConnect.invalidTitle",{provider:s})}),n.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:e("foundryConnect.invalidDescription",{provider:s})})]})]})})]})}export{Jn 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.