PageSourceSearch

https://bowtiesports.com/assets/UploadHubContent-D90zdmmU.js

js bowtiesports.com collected 2026-10-07 02:29:36 UTC 9,929 bytes, 1 lines download raw bytes

1import{r as i,j as e}from"./react-vendor-DUhHROXo.js";import{c as F}from"./router-vendor-Dz9PdDzH.js";import{C as p,a as u,b,c as v,d as A}from"./card-9IoFUltb.js";import{l as ee,af as E,o as l,a5 as w,X as se,a3 as te,O}from"./index-BLtzf0SR.js";import{I as ae}from"./input-RFokm5kN.js";import{T as re}from"./textarea-Da4-oaTC.js";import{B as k}from"./badge-BsE4KYIf.js";import{T as ie,a as ne,b as C,c as U}from"./tabs-B9G-WuXr.js";import{P as oe}from"./progress-DQIGmiuZ.js";import{s as d}from"./client-DTel1CZI.js";import{Q as le,_ as ce}from"./index-Bx33a51L.js";import{U as _}from"./upload-TDghJ2vl.js";import{F as G}from"./folder-open-CIWhCFhy.js";import{C as de}from"./circle-check-PV1EE3Kr.js";import{R as me}from"./refresh-cw-BBiwQZvS.js";import{F as pe}from"./file-video-BRu0kST6.js";import{F as ue}from"./file-audio-C_6eZAST.js";import{F as xe}from"./file-image-BaqwBIvX.js";import"./index-f8ec2rGh.js";function he(x){const n=x.type;return n.startsWith("video/")?{category:"video",bucket:"videos"}:n.startsWith("audio/")?{category:"audio",bucket:"podcast-audio"}:n.startsWith("image/")?{category:"image",bucket:"articles"}:{category:"document",bucket:"documents"}}const H={video:pe,audio:ue,image:xe,document:O},M={video:"text-blue-500",audio:"text-purple-500",image:"text-green-500",document:"text-orange-500"};function Be(){const[x]=F();x.get("episodeId");const[n,h]=i.useState([]),[f,g]=i.useState(!1),[D,R]=i.useState(!1),[T,$]=i.useState(null),[z,I]=i.useState(!1),[Q,V]=i.useState([]),[j,S]=i.useState(!1),{toast:B}=ee(),N=i.useCallback(async()=>{S(!0);const{data:s}=await d.from("media_assets").select("id, filename, original_filename, file_type, file_size_kb, storage_url, tags, created_at").order("created_at",{ascending:!1}).limit(20);V(s||[]),S(!1)},[]);i.useEffect(()=>{N()},[N]);const m=i.useCallback(s=>{const r=Array.from(s).map(a=>{const{category:t,bucket:c}=he(a);return{file:a,id:crypto.randomUUID(),category:t,bucket:c,title:a.name.replace(/\.[^.]+$/,""),description:"",progress:0,status:"pending"}});h(a=>[...a,...r])},[]),W=i.useCallback(s=>{s.preventDefault(),g(!1),s.dataTransfer.files.length>0&&m(s.dataTransfer.files)},[m]),q=i.useCallback(s=>{s.target.files&&s.target.files.length>0&&m(s.target.files)},[m]),X=s=>{h(r=>r.filter(a=>a.id!==s))},o=(s,r)=>{h(a=>a.map(t=>t.id===s?{...t,...r}:t))},J=async()=>{const s=n.filter(t=>t.status==="pending");if(s.length===0)return;R(!0);const{data:{user:r}}=await d.auth.getUser();for(const t of s){o(t.id,{status:"uploading",progress:10});try{const c=t.file.name.split(".").pop(),L=`${t.category==="image"?"editorial":"uploads"}/${Date.now()}-${crypto.randomUUID()}.${c}`;o(t.id,{progress:30});const{error:P}=await d.storage.from(t.bucket).upload(L,t.file,{cacheControl:"3600",upsert:!1});if(P)throw P;o(t.id,{progress:80});const Z=`${t.bucket}/${L}`;await d.from("media_assets").insert({filename:t.title||t.file.name,original_filename:t.file.name,file_type:t.category,mime_type:t.file.type,file_size_kb:Math.round(t.file.size/1024),storage_url:Z,description:t.description||null,tags:[t.category],uploaded_by:(r==null?void 0:r.id)||null}),o(t.id,{status:"complete",progress:100})}catch(c){o(t.id,{status:"error",error:c.message||"Upload failed",progress:0})}}R(!1);const a=n.filter(t=>t.status!=="error").length;B({title:"Upload complete",description:`${a} file(s) uploaded successfully.`})},K=async()=>{I(!0);try{const{data:s,error:r}=await d.functions.invoke("generate-upload-token",{body:{maxUses:5,expiryHours:2}});if(r)throw r;const a=window.location.origin;$(`${a}/mobile-upload?upload_token=${s.token}`)}catch(s){B({title:"Error generating QR",description:s.message,variant:"destructive"})}I(!1)},y=n.filter(s=>s.status==="pending").length,Y=n.filter(s=>s.status==="complete").length;return e.jsx("div",{className:"space-y-6",children:e.jsxs(ie,{defaultValue:"upload",className:"space-y-6",children:[e.jsxs(ne,{children:[e.jsxs(C,{value:"upload",className:"gap-2",children:[e.jsx(_,{className:"h-4 w-4"})," Quick Upload"]}),e.jsxs(C,{value:"mobile",className:"gap-2",children:[e.jsx(E,{className:"h-4 w-4"})," Mobile Upload"]}),e.jsxs(C,{value:"recent",className:"gap-2",children:[e.jsx(G,{className:"h-4 w-4"})," Recent Uploads"]})]}),e.jsxs(U,{value:"upload",className:"space-y-6",children:[e.jsx(p,{className:`border-2 border-dashed transition-colors cursor-pointer ${f?"border-primary bg-primary/5":"border-border hover:border-primary/50"}`,onDragOver:s=>{s.preventDefault(),g(!0)},onDragLeave:()=>g(!1),onDrop:W,onClick:()=>{var s;return(s=document.getElementById("upload-hub-file-input"))==null?void 0:s.click()},children:e.jsxs(u,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(_,{className:`h-12 w-12 mb-4 ${f?"text-primary":"text-muted-foreground"}`}),e.jsx("h3",{className:"text-lg font-semibold mb-1",children:f?"Drop files here":"Drag & drop files"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Videos, audio, images, documents — we'll auto-categorize them"}),e.jsx(l,{variant:"outline",size:"sm",type:"button",children:"Browse Files"}),e.jsx("input",{id:"upload-hub-file-input",type:"file",multiple:!0,className:"hidden",accept:"video/*,audio/*,image/*,.pdf,.doc,.docx,.md,.txt",onCh
1ange:q})]})}),n.length>0&&e.jsxs(p,{children:[e.jsx(b,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(v,{className:"text-lg",children:["Upload Queue",e.jsxs(k,{variant:"outline",className:"ml-2",children:[y," pending · ",Y," done"]})]}),e.jsxs(l,{onClick:J,disabled:D||y===0,size:"sm",children:[D?e.jsx(w,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(_,{className:"h-4 w-4 mr-2"}),"Upload All (",y,")"]})]})}),e.jsx(u,{className:"space-y-4",children:n.map(s=>{const r=H[s.category];return e.jsxs("div",{className:"border rounded-lg p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx(r,{className:`h-5 w-5 shrink-0 ${M[s.category]}`}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(ae,{value:s.title,onChange:a=>o(s.id,{title:a.target.value}),className:"font-medium text-sm h-8",placeholder:"Title",disabled:s.status!=="pending"})}),e.jsx(k,{variant:"outline",className:"shrink-0 text-xs capitalize",children:s.category})]}),s.status==="pending"&&e.jsx(l,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>X(s.id),children:e.jsx(se,{className:"h-4 w-4"})}),s.status==="complete"&&e.jsx(de,{className:"h-5 w-5 text-green-500 shrink-0"})]}),s.status==="pending"&&e.jsx(re,{value:s.description,onChange:a=>o(s.id,{description:a.target.value}),placeholder:"Description (optional)",className:"text-sm resize-none",rows:2}),(s.status==="uploading"||s.status==="complete")&&e.jsx(oe,{value:s.progress,className:"h-2"}),s.status==="error"&&e.jsx("p",{className:"text-sm text-destructive",children:s.error}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s.file.name," · ",(s.file.size/1024/1024).toFixed(1)," MB · Bucket: ",s.bucket]})]},s.id)})})]})]}),e.jsx(U,{value:"mobile",className:"space-y-6",children:e.jsxs(p,{children:[e.jsxs(b,{children:[e.jsxs(v,{className:"flex items-center gap-2",children:[e.jsx(E,{className:"h-5 w-5"}),"Upload from iPhone"]}),e.jsx(A,{children:"Generate a QR code to open a mobile upload page on your phone. No login required."})]}),e.jsx(u,{className:"space-y-6",children:T?e.jsxs("div",{className:"flex flex-col items-center gap-6",children:[e.jsxs("div",{className:"bg-white p-6 rounded-xl shadow-md relative",children:[e.jsx(ce,{value:T,size:220,level:"H"}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:e.jsx("div",{className:"bg-white rounded-full p-1.5",children:e.jsx(te,{className:"h-10 w-10"})})})]}),e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Scan with your iPhone camera"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This code expires in 2 hours · Up to 5 uploads"}),e.jsx(l,{variant:"outline",size:"sm",onClick:()=>$(null),children:"Generate New Code"})]})]}):e.jsxs(l,{onClick:K,disabled:z,size:"lg",children:[z?e.jsx(w,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(le,{className:"h-4 w-4 mr-2"}),"Generate Upload QR Code"]})})]})}),e.jsx(U,{value:"recent",className:"space-y-6",children:e.jsxs(p,{children:[e.jsx(b,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(v,{className:"flex items-center gap-2",children:[e.jsx(G,{className:"h-5 w-5"}),"Recent Uploads"]}),e.jsx(A,{children:"All files uploaded via desktop or mobile"})]}),e.jsxs(l,{variant:"outline",size:"sm",onClick:N,disabled:j,children:[e.jsx(me,{className:`h-4 w-4 mr-2 ${j?"animate-spin":""}`}),"Refresh"]})]})}),e.jsx(u,{children:j?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(w,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):Q.length===0?e.jsx("p",{className:"text-center py-8 text-muted-foreground",children:"No uploads found yet."}):e.jsx("div",{className:"space-y-3",children:Q.map(s=>{var t;const r=H[s.file_type]||O,a=((t=s.storage_url)==null?void 0:t.split("/")[0])||"unknown";return e.jsxs("div",{className:"flex items-center gap-3 p-3 border rounded-lg",children:[e.jsx(r,{className:`h-4 w-4 shrink-0 ${M[s.file_type]||""}`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:s.filename}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.original_filename})]}),e.jsx(k,{variant:"outline",className:"text-[10px] shrink-0",children:a}),e.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:new Date(s.created_at).toLocaleDateString()})]},s.id)})})})]})})]})})}export{Be 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.