import{d as S,u as E,r as s,b as G,a as i,j as e,H as O,m as P,c as $}from"./app-vYFZLebK.js";import{A as M}from"./AuthenticatedLayout-dsnBHnD2.js";import{P as H}from"./ProBackground-HBykvu3f.js";import{T as N}from"./TextInput-BXnk3iOU.js";import{I as w}from"./InputLabel-B7-VnScM.js";import{P as V}from"./PrimaryButton-Byh_hOgr.js";import{L as U}from"./link-Cl8-yVed.js";import{S as k,D as B}from"./NotificationDropdown-hhsBJy8C.js";import{C as q}from"./cloud-off-DuKIDZvN.js";import{R as u}from"./refresh-cw-BlFaEAut.js";import{C as _}from"./ThemeSwitcher-C0dt0hQX.js";import{E as C}from"./external-link-BCJ81ubv.js";import{T as z}from"./trash-2-BGObRuXj.js";import{Z}from"./zap-bQXiQpqs.js";import{C as K}from"./circle-check-3mYnficx.js";import{a as W}from"./x-5fjm0jEE.js";import{S as X}from"./search-DsXnzbTV.js";import{L as Y}from"./layout-grid-Ay3pGy7V.js";import{L as J}from"./list-BXGFkwwy.js";import"./transition-6I0c9VKA.js";import"./mail-CgMp0qFW.js";const Q=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]],ee=S("file-braces",Q);const te=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],ae=S("key",te);function se({file:a}){const[r,c]=s.useState(null);s.useEffect(()=>{(async()=>{try{const o=await i.get(`/api/google-drive/fetch/${a.id}`);c(o.data)}catch{}})()},[a.id]);const n=s.useMemo(()=>r?.code?`
            <!DOCTYPE html>
            <html>
            <head>
                <style>
                    html, body { background: #1d1e22; margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; }
                    ${r.code.css||""}
                </style>
            </head>
            <body>${r.code.html||""}</body>
            </html>
        `:"",[r]);return e.jsx("div",{className:"w-full h-full bg-[#1d1e22] relative overflow-hidden",children:r?e.jsx("div",{className:"absolute inset-0 w-full h-full group-hover:scale-110 transition-transform duration-[2s]",children:e.jsx("iframe",{srcDoc:n,title:"t",className:"border-none pointer-events-none absolute",style:{width:"400%",height:"400%",transform:"scale(0.25)",transformOrigin:"0 0"},sandbox:"allow-scripts"})}):e.jsx("div",{className:"w-full h-full flex items-center justify-center bg-white/5",children:e.jsx("div",{className:"w-4 h-4 border-2 border-cyan-500/20 border-t-cyan-500 rounded-full animate-spin"})})})}function _e(){const{auth:a}=E().props,[r,c]=s.useState([]),[n,d]=s.useState(!0),[o,D]=s.useState(""),[x,g]=s.useState(null),[p,b]=s.useState("grid"),{data:v,setData:f,post:L,processing:I}=G({google_client_id:a.user.personal_google_client_id||"",google_client_secret:a.user.personal_google_client_secret||""}),m=s.useCallback(async()=>{if(!a.user.google_drive_token){d(!1);return}d(!0);try{const t=await i.get("/api/google-drive/list");c(t.data)}catch{console.error("Cloud_Uplink_Refused")}finally{d(!1)}},[a.user.google_drive_token]);s.useEffect(()=>{m()},[m]);const F=t=>{t.preventDefault(),L(route("google-drive.save-config"),{preserveScroll:!0,onSuccess:()=>alert("Personal_API_Ciphers_Stored")})},A=async()=>{if(!a.user.personal_google_client_id)return alert("Config_Required");try{const t=await i.get("/api/google-drive/auth");window.location.href=t.data.url}catch{alert("Auth_Failed")}},R=async()=>{if(confirm("Terminate satellite link? Access tokens will be purged."))try{await i.post("/api/google-drive/disconnect"),$.reload()}catch{alert("Disconnect_Failed")}},j=async t=>{g(t);try{const l=await i.get(`/api/google-drive/fetch/${t}`),T=await i.post("/api/projects",{title:l.data.title+" (Imported)",code:l.data.code,is_public:!1,is_private:!0});alert("Node_Replicated: Redirecting to local instance."),window.location.href=`/editor/${T.data.slug}`}catch{alert("Replication_Failed")}finally{g(null)}},y=async t=>{if(confirm("Destroy remote node permanently?"))try{await i.delete(`/api/google-drive/delete/${t}`),c(r.filter(l=>l.id!==t))}catch{alert("Deletion_Failed")}},h=r.filter(t=>t.name.toLowerCase().includes(o.toLowerCase()));return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)] font-sans selection:bg-cyan-500/30 relative overflow-hidden transition-colors duration-300",children:[e.jsx(H,{}),e.jsxs(M,{header:e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-start md:items-center w-full gap-6 relative z-10 text-left",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-2 bg-cyan-500/10 border border-cyan-500/20 rounded shadow-sm",children:e.jsx(W,{className:"text-cyan-500",size:20})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-black text-[var(--text-main)] uppercase italic leading-none",children:"Cloud Sync"}),e.jsx("p",{className:"text-[8px] text-cyan-500 font-bold uppercase tracking-[0.4em] mt-1",children:"Google Drive Integration"})]})]}),e.jsxs("div",{className:"flex items-center gap-4 w-full md:w-auto",children:[e.jsxs("div",{className:"relative flex-1 md:w-64",children:[e.jsx(X,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-muted)]",size:14}),e.jsx("input",{type:"text",placeholder:"Search Remote Array...",value:o,onChange:t=>D(t.target.value),className:"bg-[var(--bg-surface)] border border-[var(--border)] rounded pl-10 pr-4 py-2 text-[10px] font-bold uppercase tracking-widest focus:border-cyan-500/50 focus:ring-0 w-full"})]}),e.jsxs("div",{className:"flex bg-[var(--bg-surface)] p-1 rounded border border-[var(--border)]",children:[e.jsx("button",{onClick:()=>b("grid"),className:`p-2 rounded ${p==="grid"?"bg-[var(--bg-elevated)] text-[var(--text-main)] shadow-sm":"text-[var(--text-muted)]"}`,children:e.jsx(Y,{size:16})}),e.jsx("button",{onClick:()=>b("list"),className:`p-2 rounded ${p==="list"?"bg-[var(--bg-elevated)] text-[var(--text-main)] shadow-sm":"text-[var(--text-muted)]"}`,children:e.jsx(J,{size:16})})]}),e.jsx("button",{onClick:m,className:"p-2.5 bg-[var(--bg-surface)] border border-[var(--border)] rounded hover:border-cyan-500/30 transition-all",children:e.jsx(u,{size:14,className:n?"animate-spin text-cyan-500":"text-[var(--text-muted)]"})})]})]}),children:[e.jsx(O,{title:"Cloud Hub // Advanced Sync"}),e.jsx("div",{className:"relative min-h-screen p-6 md:p-12 overflow-y-auto text-left",children:e.jsxs("div",{className:"max-w-7xl mx-auto relative z-10 space-y-12",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-12",children:[e.jsxs("div",{className:"lg:col-span-1 space-y-8",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 text-purple-500 font-black text-[10px] uppercase tracking-widest italic",children:[e.jsx(U,{size:14})," Connection Settings"]}),e.jsxs("form",{onSubmit:F,className:"bg-[var(--bg-surface)] border border-[var(--border)] rounded-[2rem] p-8 space-y-6 shadow-xl relative overflow-hidden group",children:[e.jsx("div",{className:"absolute top-0 left-0 w-1 h-full bg-purple-500/20 group-hover:bg-purple-500 transition-all"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{value:"Client_ID"}),e.jsx(N,{value:v.google_client_id,onChange:t=>f("google_client_id",t.target.value),className:"bg-[var(--bg-elevated)] font-mono text-[10px]"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{value:"Client_Secret"}),e.jsx(N,{type:"password",value:v.google_client_secret,onChange:t=>f("google_client_secret",t.target.value),className:"bg-[var(--bg-elevated)] font-mono text-[10px]"})]})]}),e.jsx(V,{disabled:I,className:"w-full justify-center py-4 text-[10px] tracking-[0.2em]",children:"Save Settings"})]})]}),e.jsxs("div",{className:"p-8 bg-[var(--bg-surface)] border border-[var(--border)] rounded-[2rem] space-y-6 relative overflow-hidden group",children:[e.jsx("div",{className:"absolute top-0 left-0 w-1 h-full bg-emerald-500/20 group-hover:bg-emerald-500 transition-all"}),e.jsxs("div",{className:"flex items-center gap-3 text-emerald-500",children:[e.jsx(k,{size:16}),e.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest",children:"Connection Status"})]}),e.jsxs("div",{className:"space-y-4 text-[9px] font-bold uppercase tracking-widest",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"State:"}),e.jsx("span",{className:a.user.google_drive_token?"text-emerald-500":"text-rose-500",children:a.user.google_drive_token?"ACTIVE":"OFFLINE"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"Root Folder:"}),e.jsxs("span",{className:"text-cyan-500 truncate ml-4",children:["ID_",a.user.google_drive_folder_id||"N/A"]})]})]}),a.user.google_drive_token?e.jsx("button",{onClick:R,className:"w-full py-3 bg-rose-500/10 border border-rose-500/20 rounded text-[9px] font-black uppercase tracking-widest text-rose-500 hover:bg-rose-500 hover:text-white transition-all",children:"Disconnect"}):e.jsx("button",{onClick:A,className:"w-full py-4 bg-white text-black font-black uppercase text-[10px] tracking-widest rounded-xl hover:bg-cyan-500 transition-all italic",children:"Connect Google Drive"})]})]}),e.jsx("div",{className:"lg:col-span-2 space-y-8 text-left",children:e.jsxs("div",{className:"bg-[var(--bg-surface)] border border-[var(--border)] rounded-[2.5rem] overflow-hidden shadow-2xl flex flex-col h-full min-h-[600px]",children:[e.jsxs("div",{className:"p-8 border-b border-[var(--border)] flex justify-between items-center bg-[var(--bg-elevated)]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(B,{size:16,className:"text-cyan-500"}),e.jsx("h3",{className:"text-[11px] font-black uppercase tracking-[0.3em] text-[var(--text-main)] italic",children:"Cloud Files"})]}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsx("div",{className:"px-3 py-1 bg-cyan-500/10 border border-cyan-500/20 rounded text-[8px] font-black text-cyan-500 uppercase tracking-widest",children:"Folder: /HOACodeLab_Nodes"})})]}),e.jsx("div",{className:"flex-1 overflow-x-auto p-6",children:n?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 gap-4",children:[e.jsx("div",{className:"w-8 h-8 border-2 border-cyan-500/20 border-t-cyan-500 rounded-full animate-spin"}),e.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest animate-pulse text-cyan-500 italic",children:"Loading Files..."})]}):a.user.google_drive_token?h.length===0?e.jsx("div",{className:"flex flex-col items-center justify-center py-32 text-[var(--text-muted)] italic",children:e.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest",children:"No files found."})}):p==="grid"?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:h.map((t,l)=>e.jsxs(P.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:l*.05},className:"group bg-[var(--bg-elevated)] border border-[var(--border)] rounded-xl overflow-hidden hover:border-cyan-500/30 transition-all shadow-lg text-left",children:[e.jsxs("div",{className:"aspect-video bg-black relative border-b border-[var(--border)] overflow-hidden",children:[e.jsx(se,{file:t}),e.jsx("div",{className:"absolute top-3 right-3 px-2 py-0.5 rounded border text-[8px] font-bold uppercase tracking-widest z-20 bg-cyan-500/10 border-cyan-500/30 text-cyan-500",children:"Cloud"})]}),e.jsxs("div",{className:"p-4",children:[e.jsx("h3",{className:"text-sm font-black text-[var(--text-main)] uppercase italic tracking-tight group-hover:text-cyan-500 transition-colors mb-4 truncate",children:t.name.replace(".hoa.json","")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:()=>j(t.id),disabled:x===t.id,className:"flex-1 py-2 bg-cyan-500 text-black rounded font-black text-[10px] uppercase tracking-widest hover:bg-white transition-colors flex items-center justify-center gap-2",children:[x===t.id?e.jsx(u,{size:12,className:"animate-spin"}):e.jsx(_,{size:12})," Open"]}),e.jsx("a",{href:t.webViewLink,target:"_blank",className:"p-2 bg-[var(--bg-main)] border border-[var(--border)] rounded text-[var(--text-muted)] hover:text-white transition-colors",children:e.jsx(C,{size:14})}),e.jsx("button",{onClick:()=>y(t.id),className:"p-2 bg-rose-500/10 border border-rose-500/20 rounded text-rose-500 hover:bg-rose-500 hover:text-white transition-colors",children:e.jsx(z,{size:14})})]})]})]},t.id))}):e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{className:"bg-[var(--bg-main)]/50 border-b border-[var(--border)] text-[8px] font-black uppercase tracking-[0.3em] text-[var(--text-muted)]",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-8 py-5",children:"File Name"}),e.jsx("th",{className:"px-8 py-5 text-right",children:"Operations"})]})}),e.jsx("tbody",{className:"divide-y divide-[var(--border)]",children:h.map(t=>e.jsxs("tr",{className:"hover:bg-white/[0.02] transition-colors group",children:[e.jsx("td",{className:"px-8 py-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 bg-white/5 rounded-2xl text-cyan-500 group-hover:bg-cyan-500 group-hover:text-black transition-all duration-500",children:e.jsx(ee,{size:18})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-black uppercase tracking-tighter block leading-none",children:t.name.replace(".hoa.json","")}),e.jsxs("span",{className:"text-[8px] text-[var(--text-muted)] font-mono uppercase italic",children:["Synced: ",new Date(t.modifiedTime).toLocaleString()]})]})]})}),e.jsx("td",{className:"px-8 py-6 text-right",children:e.jsxs("div",{className:"flex justify-end gap-3 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:()=>j(t.id),disabled:x===t.id,className:"p-3 bg-cyan-500/10 rounded-xl text-cyan-500 hover:bg-cyan-500 hover:text-black transition-all",title:"Load Remote Node",children:e.jsx(_,{size:16,className:x===t.id?"animate-spin":""})}),e.jsx("a",{href:t.webViewLink,target:"_blank",className:"p-3 bg-white/5 rounded-xl text-[var(--text-muted)] hover:text-white transition-all",children:e.jsx(C,{size:16})}),e.jsx("button",{onClick:()=>y(t.id),className:"p-3 bg-rose-500/10 rounded-xl text-rose-500/50 hover:bg-rose-500 hover:text-white transition-all",children:e.jsx(z,{size:16})})]})})]},t.id))})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-32 opacity-40 italic space-y-4",children:[e.jsx(q,{size:48,className:"mx-auto"}),e.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest block",children:"Connect Google Drive to view files."})]})})]})})]}),e.jsx("div",{className:"mt-20 pt-20 border-t border-[var(--border)]",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-16",children:[e.jsxs("div",{className:"text-center space-y-4",children:[e.jsxs("div",{className:"inline-flex items-center gap-3 px-4 py-1.5 bg-cyan-500/5 border border-cyan-500/10 rounded-full",children:[e.jsx(Z,{size:12,className:"text-cyan-500"}),e.jsx("span",{className:"text-[10px] font-black uppercase tracking-[0.4em] text-cyan-500 italic",children:"Setup Instructions"})]}),e.jsx("h3",{className:"text-4xl font-black uppercase italic tracking-tighter",children:"Easy Setup Guide"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)] font-bold uppercase tracking-[0.2em]",children:"Follow the signal path to establish your decentralized node."})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-12 relative",children:[e.jsx("div",{className:"absolute left-[19px] top-4 bottom-4 w-px bg-gradient-to-b from-cyan-500 via-purple-500 to-emerald-500 opacity-20 hidden md:block"}),e.jsxs("div",{className:"flex flex-col md:flex-row gap-8 relative z-10",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[var(--bg-surface)] border border-cyan-500/30 flex items-center justify-center shrink-0 shadow-[0_0_15px_rgba(6,182,212,0.2)]",children:e.jsx(ae,{size:18,className:"text-cyan-500"})}),e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsx("h4",{className:"text-lg font-black uppercase italic tracking-tight text-white",children:"01. Enable Google Drive API"}),e.jsx("span",{className:"text-[8px] font-black uppercase px-2 py-1 bg-cyan-500/10 text-cyan-500 border border-cyan-500/20 rounded-md",children:"Google Cloud Console"})]}),e.jsxs("div",{className:"bg-[var(--bg-surface)] border border-[var(--border)] rounded-2xl p-6 text-[10px] font-bold uppercase tracking-widest leading-loose text-[var(--text-muted)] italic",children:["Open the ",e.jsx("a",{href:"https://console.cloud.google.com",target:"_blank",className:"text-cyan-400 underline",children:"Google_Cloud_Dashboard"})," and create a project. In the ",e.jsx("span",{className:"text-white",children:"Library"}),", enable the ",e.jsx("span",{className:"text-white underline",children:"Google_Drive_API"}),". This grants the kernel permission to interact with satellite storage."]})]})]}),e.jsxs("div",{className:"flex flex-col md:flex-row gap-8 relative z-10",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[var(--bg-surface)] border border-purple-500/30 flex items-center justify-center shrink-0 shadow-[0_0_15px_rgba(168,85,247,0.2)]",children:e.jsx(k,{size:18,className:"text-purple-500"})}),e.jsxs("div",{className:"flex-1 space-y-4 text-left",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4 text-left",children:[e.jsx("h4",{className:"text-lg font-black uppercase italic tracking-tight text-white",children:"02. Create Credentials"}),e.jsx("span",{className:"text-[8px] font-black uppercase px-2 py-1 bg-purple-500/10 text-purple-500 border border-purple-500/20 rounded-md text-left",children:"OAuth Client ID"})]}),e.jsxs("div",{className:"bg-[var(--bg-surface)] border border-[var(--border)] rounded-2xl p-6 space-y-6",children:[e.jsxs("p",{className:"text-[10px] font-bold uppercase tracking-widest leading-loose text-[var(--text-muted)] italic",children:["Create an ",e.jsx("span",{className:"text-white font-black",children:"OAuth_2.0_Client_ID"})," (Web Application). Inject the following URI into the ",e.jsx("span",{className:"text-white",children:"Authorized Redirect URIs"})," field:"]}),e.jsxs("div",{className:"group relative",children:[e.jsxs("code",{className:"block bg-black px-4 py-3 rounded-xl text-emerald-500 lowercase text-[11px] font-mono border border-white/5 break-all leading-normal group-hover:border-emerald-500/30 transition-all",children:[window.location.origin,"/api/google-drive/callback"]}),e.jsx("div",{className:"absolute top-1/2 -right-2 -translate-y-1/2 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx("span",{className:"bg-emerald-500 text-black text-[8px] font-black px-2 py-1 rounded shadow-xl uppercase",children:"Callback URL"})})]})]})]})]}),e.jsxs("div",{className:"flex flex-col md:flex-row gap-8 relative z-10",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[var(--bg-surface)] border border-emerald-500/30 flex items-center justify-center shrink-0 shadow-[0_0_15px_rgba(16,185,129,0.2)]",children:e.jsx(u,{size:18,className:"text-emerald-500"})}),e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsx("h4",{className:"text-lg font-black uppercase italic tracking-tight text-white",children:"03. Connect Account"}),e.jsx("span",{className:"text-[8px] font-black uppercase px-2 py-1 bg-emerald-500/10 text-emerald-500 border border-emerald-500/20 rounded-md",children:"Final Step"})]}),e.jsx("div",{className:"bg-black border border-white/5 rounded-2xl p-8 space-y-6 text-left",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(K,{className:"text-emerald-500 shrink-0",size:16}),e.jsxs("p",{className:"text-[10px] font-bold uppercase tracking-[0.1em] leading-relaxed text-slate-400 italic",children:["Commit your Client ID and Secret in the ",e.jsx("span",{className:"text-white",children:"Connection Settings"})," panel. Click ",e.jsx("span",{className:"text-cyan-500",children:"'Connect Google Drive'"})," to perform the handshake. The platform will autonomousely create a ",e.jsx("span",{className:"text-white",children:"/HOACodeLab_Nodes"})," directory in your Drive root."]})]})})]})]})]})]})})]})})]})]})}export{_e as default};
