PageSourceSearch

https://fitwithpulse.ai/_next/static/chunks/pages/admin/MoveManagement-e3eaa5226a07eb2c.js

js fitwithpulse.ai collected 2026-10-05 13:47:36 UTC 66,669 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[44017],{7223:function(e,t,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/MoveManagement",function(){return r(7981)}])},80279:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(51601).Z)("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]])},82858:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(51601).Z)("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]])},72918:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(51601).Z)("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]])},15614:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(51601).Z)("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]])},69523:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(51601).Z)("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]])},71994:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(51601).Z)("CircleUserRound",[["path",{d:"M18 20a6 6 0 0 0-12 0",key:"1qehca"}],["circle",{cx:"12",cy:"10",r:"4",key:"1h16sb"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]])},11993:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(51601).Z)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},99518:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(51601).Z)("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]])},76419:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(51601).Z)("Dumbbell",[["path",{d:"M14.4 14.4 9.6 9.6",key:"ic80wn"}],["path",{d:"M18.657 21.485a2 2 0 1 1-2.829-2.828l-1.767 1.768a2 2 0 1 1-2.829-2.829l6.364-6.364a2 2 0 1 1 2.829 2.829l-1.768 1.767a2 2 0 1 1 2.828 2.829z",key:"nnl7wr"}],["path",{d:"m21.5 21.5-1.4-1.4",key:"1f1ice"}],["path",{d:"M3.9 3.9 2.5 2.5",key:"1evmna"}],["path",{d:"M6.404 12.768a2 2 0 1 1-2.829-2.829l1.768-1.767a2 2 0 1 1-2.828-2.829l2.828-2.828a2 2 0 1 1 2.829 2.828l1.767-1.768a2 2 0 1 1 2.829 2.829z",key:"yhosts"}]])},90169:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(51601).Z)("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]])},76656:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(51601).Z)("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]])},30274:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(51601).Z)("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},19320:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(51601).Z)("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]])},71578:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(51601).Z)("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]])},32854:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(51601).Z)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},69443:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(51601).Z)("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]])},14386:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(51601).Z)("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]])},60081:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(51601).Z)("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",ke
1y:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]])},87741:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(51601).Z)("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]])},80011:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(51601).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},22787:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(51601).Z)("Video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]])},7981:function(e,t,r){"use strict";r.r(t);var s=r(72646),a=r(32586),o=r(52676),n=r(75271),i=r(60889),l=r.n(i),d=r(39866),c=r(40768),x=r(51929),m=r(66477),u=r(97216),g=r(878),h=r(22787),f=r(30274),p=r(87741),y=r(80444),b=r(69443),v=r(76656),j=r(69523),N=r(11993),w=r(76419),k=r(32854),C=r(15614),M=r(90169),L=r(80279),Z=r(72918),U=r(83883),S=r(82858),I=r(63086),D=r(80011),R=r(49272),A=r(29215);t.default=()=>{let[e,t]=(0,n.useState)("allMoves"),[r,i]=(0,n.useState)([]),[E,F]=(0,n.useState)([]),[_,T]=(0,n.useState)(!0),[V,B]=(0,n.useState)(0),[P,z]=(0,n.useState)(!0),[G,O]=(0,n.useState)([]),[q,H]=(0,n.useState)([]),[W,Y]=(0,n.use
1State)(!0),[J,Q]=(0,n.useState)(0),[X,$]=(0,n.useState)(!0),[K,ee]=(0,n.useState)(null),[et,er]=(0,n.useState)(null),[es,ea]=(0,n.useState)(null),[eo,en]=(0,n.useState)([]),[ei,el]=(0,n.useState)([]),[ed,ec]=(0,n.useState)(!1),[ex,em]=(0,n.useState)(!1),[eu,eg]=(0,n.useState)(null),[eh,ef]=(0,n.useState)({}),[ep,ey]=(0,n.useState)(""),[eb,ev]=(0,n.useState)(""),[ej,eN]=(0,n.useState)(""),[ew,ek]=(0,n.useState)(""),[eC,eM]=(0,n.useState)(""),[eL,eZ]=(0,n.useState)("name-asc"),[eU,eS]=(0,n.useState)(!1),[eI,eD]=(0,n.useState)([]),[eR,eA]=(0,n.useState)([]),[eE,eF]=(0,n.useState)(!1),[e_,eT]=(0,n.useState)(!1),[eV,eB]=(0,n.useState)([]),[eP,ez]=(0,n.useState)([]),[eG,eO]=(0,n.useState)(""),[eq,eH]=(0,n.useState)({}),[eW,eY]=(0,n.useState)([]),[eJ,eQ]=(0,n.useState)([]),[eX,e$]=(0,n.useState)(!0),[eK,e0]=(0,n.useState)([]),[e1,e2]=(0,n.useState)(""),[e4,e5]=(0,n.useState)(!1),[e3,e6]=(0,n.useState)(!1),[e7,e8]=(0,n.useState)({}),[e9,te]=(0,n.useState)({}),[tt,tr]=(0,n.useState)({}),[ts,ta]=(0,n.useState)({}),[to,tn]=(0,n.useState)(!1),[ti,tl]=(0,n.useState)(null);(0,n.useEffect)(()=>{if(et){let e=setTimeout(()=>er(null),5e3);return()=>clearTimeout(e)}},[et]),(0,n.useEffect)(()=>{let e=new Set,t=new Set;r.forEach(r=>{if(r.category){var s,a;let t="string"==typeof r.category?r.category:(null===(s=r.category)||void 0===s?void 0:s.id)||(null===(a=r.category)||void 0===a?void 0:a.type)||"";t&&e.add(t)}r.primaryBodyParts&&Array.isArray(r.primaryBodyParts)&&r.primaryBodyParts.forEach(e=>{e&&"string"==typeof e&&t.add(e)})}),eD(Array.from(e).sort()),eA(Array.from(t).sort())},[r]),(0,n.useEffect)(()=>{let e=r;if(ep&&(e=e.filter(e=>e.name.toLowerCase().includes(ep.toLowerCase())||e.id.toLowerCase().includes(ep.toLowerCase()))),ew&&(e=e.filter(e=>{var t;return("string"==typeof e.category?e.category:(null===(t=e.category)||void 0===t?void 0:t.id)||"").toLowerCase().includes(ew.toLowerCase())})),eC&&(e=e.filter(e=>{var t;return null===(t=e.primaryBodyParts)||void 0===t?void 0:t.some(e=>e.toLowerCase().includes(eC.toLowerCase()))})),eP.length>0){let t=eP.map(e=>e.toLowerCase());e=e.filter(e=>{let r=eq[e.id];if(!r||0===r.size)return!1;for(let e of r)if(t.includes((e||"").toLowerCase()))return!0;return!1})}let t=e=>{if(!e||0===e||"0"===e)return 0;try{let t=(0,A.QW)(e);if(t instanceof Date&&!isNaN(t.getTime())&&t.getFullYear()>=2e3)return t.getTime();return 0}catch(e){return 0}};F([...e].sort((e,r)=>{switch(eL){case"name-asc":return e.name.localeCompare(r.name);case"name-desc":return r.name.localeCompare(e.name);case"date-newest":{let s=t(e.createdAt),a=t(r.createdAt);if(0===s&&0===a)return 0;if(0===s)return 1;if(0===a)return -1;return a-s}case"date-oldest":{let s=t(e.createdAt),a=t(r.createdAt);if(0===s&&0===a)return 0;if(0===s)return 1;if(0===a)return -1;return s-a}default:return 0}}))},[r,ep,ew,eC,eP,eq,eL]),(0,n.useEffect)(()=>{let e=G;eb&&(e=e.filter(e=>{var t,r,s,a;return(null===(t=e.exerciseName)||void 0===t?void 0:t.toLowerCase().includes(eb.toLowerCase()))||(null===(r=e.reporterUsername)||void 0===r?void 0:r.toLowerCase().includes(eb.toLowerCase()))||(null===(s=e.videoOwnerUsername)||void 0===s?void 0:s.toLowerCase().includes(eb.toLowerCase()))||(null===(a=e.message)||void 0===a?void 0:a.toLowerCase().includes(eb.toLowerCase()))})),H(e)},[G,eb]),(0,n.useEffect)(()=>{let e=eo;ej&&(e=e.filter(e=>{var t;return(null===(t=e.username)||void 0===t?void 0:t.toLowerCase().includes(ej.toLowerCase()))||e.id.toLowerCase().includes(ej.toLowerCase())})),el(e)},[eo,ej]),(0,n.useEffect)(()=>{let e=eW;e4&&(e=eK),e3&&(e=e.filter(e=>!e.gifURL)),e1&&(e=e.filter(e=>{var t,r;return(null===(t=e.username)||void 0===t?void 0:t.toLowerCase().includes(e1.toLowerCase()))||e.id.toLowerCase().includes(e1.toLowerCase())||(null===(r=e.exerciseId)||void 0===r?void 0:r.toLowerCase().includes(e1.toLowerCase()))})),eQ(e)},[eW,eK,e1,e4,e3]);let td=(0,n.useCallback)(async()=>{console.log("[MoveManagement] Fetching exercises..."),T(!0),ee(null);try{let e=(0,c.collection)(x.db,"exercises"),t=(0,c.query)(e,(0,c.orderBy)("name")),r=(await (0,c.getDocs)(t)).docs.map(e=>{let t=e.data();return console.log("[MoveManagement] Fetched exercise:",t),{firestoreDocId:e.id,id:t.id||e.id,name:t.name||"Unnamed 
1Exercise",category:t.category,primaryBodyParts:t.primaryBodyParts||[],createdAt:t.createdAt}});i(r),F(r),console.log("[MoveManagement] Fetched ".concat(r.length," exercises."))}catch(e){console.error("[MoveManagement] Error fetching exercises:",e),ee("Failed to load exercises. ".concat(e instanceof Error?e.message:"Unknown error")),i([])}finally{T(!1)}},[]),tc=(0,n.useCallback)(async()=>{console.log("[MoveManagement] Fetching total video count..."),z(!0);try{let e=(0,c.collection)(x.db,"exerciseVideos"),t=await (0,c.getCountFromServer)(e);B(t.data().count),console.log("[MoveManagement] Total video count: ".concat(t.data().count))}catch(e){console.error("[MoveManagement] Error fetching total video count:",e),B(0)}finally{z(!1)}},[]),tx=(0,n.useCallback)(async()=>{console.log("[MoveManagement] Fetching reported exercises..."),Y(!0),$(!0);try{let e=(0,c.collection)(x.db,"reported-exercises"),t=(0,c.query)(e,(0,c.orderBy)("createdAt","desc")),r=await (0,c.getDocs)(t),o=0,n=r.docs.map(e=>{let t=e.data();return"pending"===t.status&&o++,(0,a._)((0,s._)({id:e.id},t),{videoId:t.videoId})});O(n),H(n),Q(o),console.log("[MoveManagement] Fetched ".concat(n.length," reported items, ").concat(o," pending."))}catch(e){console.error("[MoveManagement] Error fetching reported exercises:",e),ee(t=>t?"".concat(t," | Failed to load reported content."):"Failed to load reported content. ".concat(e instanceof Error?e.message:"Unknown error")),O([]),Q(0)}finally{Y(!1),$(!1)}},[]),tm=(0,n.useCallback)(async()=>{console.log("[MoveManagement] Fetching all videos for audit..."),e$(!0);try{let e=(0,c.collection)(x.db,"exerciseVideos"),t=(0,c.query)(e,(0,c.orderBy)("createdAt","desc")),s=(await (0,c.getDocs)(t)).docs.map(e=>{let t=e.data();return{id:e.id,exerciseId:t.exerciseId,gifURL:t.gifURL,videoURL:t.videoURL,thumbnail:t.thumbnail,username:t.username,createdAt:t.createdAt}});eY(s),eQ(s);let a={},o=new Set;for(let e of s){if(!e.exerciseId)continue;a[e.exerciseId]||(a[e.exerciseId]=new Set);let t=(e.username||"").trim();t&&(a[e.exerciseId].add(t),o.add(t))}eH(a),eB(Array.from(o).sort((e,t)=>e.localeCompare(t)));let n=new Set(r.map(e=>e.id)),i=s.filter(e=>e.exerciseId&&!n.has(e.exerciseId));e0(i),console.log("[MoveManagement] Fetched ".concat(s.length," videos, ").concat(i.length," orphaned."))}catch(e){console.error("[MoveManagement] Error fetching all videos:",e),ee(t=>t?"".concat(t," | Failed to load videos for audit."):"Failed to load videos for audit. ".concat(e instanceof Error?e.message:"Unknown error")),eY([]),eQ([]),e0([])}finally{e$(!1)}},[r]);(0,n.useEffect)(()=>{td(),tc(),tx()},[td,tc,tx]),(0,n.useEffect)(()=>{r.length>0&&tm()},[r,tm]);let tu=(0,n.useCallback)(async e=>{if(!e){console.warn("[MoveManagement] fetchExerciseVideos called with invalid exerciseId."),en([]);return}console.log("[MoveManagement] Fetching videos for exercise ID: ".concat(e)),ec(!0);try{let t=(0,c.collection)(x.db,"exerciseVideos"),r=(0,c.query)(t,(0,c.where)("exerciseId","==",e),(0,c.orderBy)("createdAt","desc")),o=(await (0,c.getDocs)(r)).docs.map(e=>{let t=e.data();return{id:e.id,gifURL:t.gifURL,exerciseId:t.exerciseId,videoURL:t.videoURL,thumbnail:t.thumbnail,username:t.username,createdAt:t.createdAt}}),n=await Promise.all(o.map(async e=>{try{if(e.videoURL&&"string"==typeof e.videoURL){try{let t=(0,m.iH)(x.storage,e.videoURL),r=await (0,m.sd)(t);if("number"==typeof r.size)return(0,a._)((0,s._)({},e),{fileSizeBytes:r.size})}catch(e){}if(e.videoURL.startsWith("http")){let t=await tM(e.videoURL);if("number"==typeof t)return(0,a._)((0,s._)({},e),{fileSizeBytes:t})}}}catch(t){console.warn("[MoveManagement] Failed to load metadata for",e.id,t)}return e}));en(n),el(n),i(t=>t.map(t=>t.id===e?(0,a._)((0,s._)({},t),{videoCount:n.length}):t)),console.log("[MoveManagement] Fetched ".concat(n.length," videos for exercise ").concat(e,"."))}catch(t){console.error("[MoveManagement] Error fetching videos for exercise ".concat(e,":"),t),er({type:"error",text:"Failed to load videos. ".concat(t instanceof Error?t.message:"")}),en([])}finally{ec(!1)}},[]),tg=async()=>{if(window.confirm("Are you sure you want to manually set today's Move of the Day? This will over
1write any existing selection for today.")){em(!0),er({type:"info",text:"Setting Move of the Day..."});try{let t=(0,u.getAuth)().currentUser;if(!t)throw Error("No authenticated user found. Please sign in again.");let r=await (0,u.getIdToken)(t);console.log("[MoveManagement] Calling Netlify function 'manualTriggerMoveOfTheDay'...");let s=await fetch("/.netlify/functions/manualTriggerMoveOfTheDay",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(r)}}),a=await s.json();if(console.log("[MoveManagement] Netlify function 'manualTriggerMoveOfTheDay' result:",a),s.ok&&a.success){var e;er({type:"success",text:a.message||(null===(e=a.details)||void 0===e?void 0:e.message)||"Move of the Day set successfully!"})}else throw Error(a.message||a.error||"Failed to set Move of the Day via Netlify function.")}catch(t){console.error("[MoveManagement] Error triggering Move of the Day via Netlify:",t);let e=t instanceof Error?t.message:"Unknown error.";er({type:"error",text:"Failed to set Move of the Day: ".concat(e)})}finally{em(!1)}}},th=async(e,t)=>{if(!e||!t){er({type:"error",text:"Missing exerciseId or videoId"});return}if(window.confirm("Set this video as today's Move of the Day? This will overwrite the current selection.")){eg(t),er({type:"info",text:"Setting Move of the Day..."});try{var r;let s=(0,u.getAuth)().currentUser;if(!s)throw Error("Not signed in");let a=await (0,u.getIdToken)(s),o=await fetch("/.netlify/functions/manualTriggerMoveOfTheDay",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(a)},body:JSON.stringify({exerciseId:e,videoId:t})}),n=await o.json();if(!o.ok||!n.success)throw Error(n.error||n.message||"Failed");er({type:"success",text:(null===(r=n.details)||void 0===r?void 0:r.message)||"Move of the Day updated"})}catch(e){er({type:"error",text:"Failed to set Move of the Day: ".concat((null==e?void 0:e.message)||"Unknown error")})}finally{eg(null)}}},tf=async e=>{ef(t=>(0,a._)((0,s._)({},t),{[e]:!0})),er({type:"info",text:"Updating report status..."});try{let t=(0,c.doc)(x.db,"reported-exercises",e);await (0,c.updateDoc)(t,{status:"completed",updatedAt:(0,c.serverTimestamp)()}),O(t=>t.map(t=>t.id===e?(0,a._)((0,s._)({},t),{status:"completed",updatedAt:new Date}):t)),Q(e=>e>0?e-1:0),er({type:"success",text:"Report status updated to completed."})}catch(t){console.error("[MoveManagement] Error marking report as complete:",t);let e=t instanceof Error?t.message:"Unknown error.";er({type:"error",text:"Failed to update report: ".concat(e)})}finally{ef(t=>(0,a._)((0,s._)({},t),{[e]:!1}))}},tp=async(e,t)=>{if(!t){er({type:"error",text:"Video ID not found for this report. Cannot hide video. Marking report as complete only."}),await tf(e);return}ef(t=>(0,a._)((0,s._)({},t),{[e]:!0})),er({type:"info",text:"Rejecting content and updating report..."});try{let r=(0,c.writeBatch)(x.db),o=(0,c.doc)(x.db,"reported-exercises",e);r.update(o,{status:"completed",updatedAt:(0,c.serverTimestamp)()});let n=(0,c.doc)(x.db,"exerciseVideos",t);r.update(n,{visibility:"rejected",updatedAt:(0,c.serverTimestamp)()}),await r.commit(),O(t=>t.map(t=>t.id===e?(0,a._)((0,s._)({},t),{status:"completed",updatedAt:new Date}):t)),Q(e=>e>0?e-1:0),er({type:"success",text:"Content hidden and report marked as completed."})}catch(t){console.error("[MoveManagement] Error rejecting content:",t);let e=t instanceof Error?t.message:"Unknown error.";er({type:"error",text:"Failed to reject content: ".concat(e)})}finally{ef(t=>(0,a._)((0,s._)({},t),{[e]:!1}))}},ty=async e=>{if(window.confirm("Are you sure you want to permanently delete this video? This action cannot be undone.")){e8(t=>(0,a._)((0,s._)({},t),{[e]:!0})),er({type:"info",text:"Deleting video..."});try{let t=(0,c.doc)(x.db,"exerciseVideos",e),r=await (0,c.getDoc)(t),s=r.exists()?r.data():{},a=async e=>{try{if(e&&"string"==typeof e&&e.trim().length>0){let t=(0,m.iH)(x.storage,e);await (0,m.oq)(t)}}catch(t){console.warn("[MoveManagement] Failed to delete storage object:",e,t)}};await Promise.all([a(s.originalVideoStoragePath||s.originalVideoUrl),a(s.videoURL),a(s.gifURL||s.thumbnail)]),await (0,c.deleteDoc)(t),eY(t=>t.filter(t=>t.id!==e)),eQ(t=>t.filter(t=>t.id!==e)),e0(t=>t.filter(t=>t.id!==e)),B(e=>Math.max(0,e-1)),er({type:"success",text:"Video deleted successfully."})}catch(t){console.error("[MoveManagement] Error deleting video:",t);let e=t instanceof Error?t.message:"Unknown error.";er({type:"error",text:"Failed to delete video: ".concat(e)})}finally{e8(t=>(0,a._)((0,s._)({},t),{[e]:!1}))}}},tb=async e=>{if(window.confirm('Delete exercise "'.concat(e.name,'" and ALL of its videos? This cannot be undone.'))){te(t=>(0,a._)((0,s._)({},t),{[e.firestoreDocId]:!0})),er({type:"info",text:"Deleting exercise and related videos..."});
1try{let t=(0,c.collection)(x.db,"exerciseVideos"),r=(0,c.query)(t,(0,c.where)("exerciseId","==",e.id)),s=await (0,c.getDocs)(r),a=[];s.forEach(e=>{a.push(ty(e.id))}),await Promise.all(a);let o=(0,c.doc)(x.db,"exercises",e.firestoreDocId);await (0,c.deleteDoc)(o),i(t=>t.filter(t=>t.firestoreDocId!==e.firestoreDocId)),F(t=>t.filter(t=>t.firestoreDocId!==e.firestoreDocId)),er({type:"success",text:"Exercise and all related videos deleted."})}catch(t){console.error("[MoveManagement] Error deleting exercise:",t);let e=t instanceof Error?t.message:"Unknown error.";er({type:"error",text:"Failed to delete exercise: ".concat(e)})}finally{te(t=>(0,a._)((0,s._)({},t),{[e.firestoreDocId]:!1}))}}},tv=async(e,t)=>{try{await navigator.clipboard.writeText(e),er({type:"success",text:"".concat(t," copied to clipboard!")})}catch(e){console.error("Failed to copy to clipboard:",e),er({type:"error",text:"Failed to copy ".concat(t.toLowerCase())})}},tj=async e=>{if(e&&window.confirm("Generate (or regenerate) a GIF preview for this video? This may take up to a minute.")){tr(t=>(0,a._)((0,s._)({},t),{[e]:!0})),er({type:"info",text:"Generating GIF for this specific video..."});try{var t,r,o,n;let i=(0,g.$C)(),l=(0,g.V1)(i,"generateGifForExerciseVideo");console.log("[MoveManagement] Calling generateGifForExerciseVideo for video:",e);let d=(await l({videoId:e})).data;if(console.log("[MoveManagement] generateGifForExerciseVideo result:",d),!d||!1===d.success)throw Error((null==d?void 0:d.message)||(null==d?void 0:d.error)||"GIF generation function reported failure.");let c=null!==(r=null!==(t=d.gifUrl)&&void 0!==t?t:d.gifURL)&&void 0!==r?r:null,x=null!==(n=null!==(o=d.thumbnailUrl)&&void 0!==o?o:d.thumbnail)&&void 0!==n?n:null;en(t=>t.map(t=>t.id===e?(0,a._)((0,s._)({},t),{gifURL:(null!=c?c:void 0)||t.gifURL,thumbnail:(null!=x?x:void 0)||t.thumbnail}):t)),el(t=>t.map(t=>t.id===e?(0,a._)((0,s._)({},t),{gifURL:(null!=c?c:void 0)||t.gifURL,thumbnail:(null!=x?x:void 0)||t.thumbnail}):t)),er({type:"success",text:c?"GIF generated for this video.":"Thumbnail updated for this video (GIF may not have been generated)."})}catch(t){console.error("[MoveManagement] Error generating GIF for video:",t);let e=t instanceof Error?t.message:"Unknown error during GIF generation.";er({type:"error",text:"GIF generation failed: ".concat(e)})}finally{tr(t=>(0,a._)((0,s._)({},t),{[e]:!1}))}}},tN=async e=>{if((null==e?void 0:e.id)&&window.confirm("Set this video's backing file name to .mp4 and update its URL on the ExerciseVideo document? This will copy the file in Storage and may delete the old .webm object.")){ta(t=>(0,a._)((0,s._)({},t),{[e.id]:!0})),er({type:"info",text:"Normalizing video file to .mp4..."});try{let t=(0,g.$C)(),r=(0,g.V1)(t,"normalizeExerciseVideoToMp4");console.log("[MoveManagement] Calling normalizeExerciseVideoToMp4 for video:",e.id);let o=(await r({videoId:e.id})).data;if(console.log("[MoveManagement] normalizeExerciseVideoToMp4 result:",o),!o||!1===o.success)throw Error((null==o?void 0:o.message)||(null==o?void 0:o.error)||"Normalization function reported failure.");let n=o.videoURL||e.videoURL;n&&(en(t=>t.map(t=>t.id===e.id?(0,a._)((0,s._)({},t),{videoURL:n}):t)),el(t=>t.map(t=>t.id===e.id?(0,a._)((0,s._)({},t),{videoURL:n}):t))),er({type:"success",text:o.alreadyMp4?"Video was already using an .mp4 file name.":"Video file renamed to .mp4 and URL updated."})}catch(t){console.error("[MoveManagement] Error normalizing video to mp4:",t);let e=t instanceof Error?t.message:"Unknown error during normalization.";er({type:"error",text:"Set as MP4 failed: ".concat(e)})}finally{ta(t=>(0,a._)((0,s._)({},t),{[e.id]:!1}))}}},tw=async(e,t)=>{if(!(null==e?void 0:e.name)){er({type:"error",text:"Exercise name is required for inference"});return}tn(!0),tl(null),er({type:"info",text:"AI is analyzing exercise to infer body parts..."});try{let r=(0,u.getAuth)().currentUser;if(!r)throw Error("Not signed in");let o=await (0,u.getIdToken)(r),n=await fetch("/.netlify/functions/inferExerciseBodyParts",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(o)},body:JSON.stringify({exerciseId:e.firestoreDocId,exerciseName:e.name,thumbnailUrl:t||null,autoUpdate:!0})}),l=await n.json();console.log("[MoveManagement] inferExerciseBodyParts result:",l),l.success&&l.bodyParts?(tl(l.bodyParts),i(t=>t.map(t=>t.firestoreDocId===e.firestoreDocId?(0,a._)((0,s._)({},t),{primaryBodyParts:l.bodyParts}):t)),F(t=>t.map(t=>t.firestoreDocId===e.firestoreDocId?(0,a._)((0,s._)({},t),{primaryBodyParts:l.bodyParts}):t)),(null==es?void 0:es.firestoreDocId)===e.firestoreDocId&&ea((0,a._)((0,s._)({},es),{primaryBodyParts:l.bodyParts})),er({type:"success",text:l.updated?"Body parts updated: ".concat(l.bodyParts.join(", ")):"Suggested body parts: ".concat(l.bodyParts.join(", "))})):er({type:"error",text:l.message||"Failed to infer body parts"})}catch(e){console.error("[MoveManagement] Error inferring body parts:",e),er({type:"error",text:"Failed to infer body parts: ".concat((null==e?void 0:e.message)||"Unknown error")})}finally{tn(!1)}},tk=e=>{if(!e||0===e||"0"===e||0===e)return"N/A";try{let t=(0,A.QW)(e);if(t instanceof Date&&!isNaN(t.getTime())){if(2e3>t.getFullYear())return"N/A";
1return t.toLocaleString()}return"Invalid Date"}catch(e){return"Invalid Date"}},tC=e=>{if(null==e||isNaN(e))return"—";if(0===e)return"0 B";let t=Math.floor(Math.log(e)/Math.log(1024)),r=e/Math.pow(1024,t);return"".concat(r.toFixed(r<10&&t>0?1:0)," ").concat(["B","KB","MB","GB","TB"][t])},tM=async e=>{if(e&&"string"==typeof e)try{let t=(await fetch(e,{method:"HEAD"})).headers.get("content-length");if(t){let e=parseInt(t,10);if(!isNaN(e))return e}}catch(e){}};return(0,o.jsxs)(d.Z,{children:[(0,o.jsxs)(l(),{children:[(0,o.jsx)("title",{children:"Exercise Database | Pulse Admin"}),(0,o.jsx)("style",{children:"\n          @keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }\n          .animate-fade-in-up { animation: fadeInUp 0.3s ease-out forwards; }\n        "})]}),(0,o.jsx)("div",{className:"min-h-screen bg-[#111417] text-white py-10 px-4",children:(0,o.jsxs)("div",{className:"max-w-7xl mx-auto",children:[(0,o.jsxs)("div",{className:"flex justify-between items-center mb-8",children:[(0,o.jsxs)("h1",{className:"text-2xl font-bold flex items-center",children:[(0,o.jsx)(w.Z,{className:"text-[#d7ff00] mr-3 h-7 w-7"}),"Exercise Database"]}),(0,o.jsxs)("button",{onClick:tg,disabled:ex,className:"px-4 py-2 rounded-lg font-medium transition-colors flex items-center gap-2 text-sm ".concat(ex?"bg-gray-600 text-gray-400 cursor-not-allowed":"bg-green-700/80 hover:bg-green-600/80 text-white"),title:"Manually select and set today's Move of the Day",children:[ex?(0,o.jsx)(f.Z,{className:"h-4 w-4 animate-spin"}):(0,o.jsx)(k.Z,{className:"h-4 w-4"}),ex?"Setting MOTD...":"Set Today's Move"]})]}),(0,o.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 mb-8",children:[(0,o.jsxs)("div",{className:"p-6 bg-[#262a30] rounded-xl border border-gray-700 shadow-lg",children:[(0,o.jsxs)("h3",{className:"text-lg font-semibold mb-2 flex items-center gap-2 text-gray-300",children:[(0,o.jsx)(w.Z,{className:"text-[#d7ff00] h-5 w-5"})," Total Unique Exercises"]}),_?(0,o.jsx)("div",{className:"h-10 w-24 bg-gray-700 rounded animate-pulse"}):(0,o.jsx)("p",{className:"text-4xl font-bold text-[#d7ff00]",children:r.length})]}),(0,o.jsxs)("div",{className:"p-6 bg-[#262a30] rounded-xl border border-gray-700 shadow-lg",children:[(0,o.jsxs)("h3",{className:"text-lg font-semibold mb-2 flex items-center gap-2 text-gray-300",children:[(0,o.jsx)(h.Z,{className:"text-[#d7ff00] h-5 w-5"})," Total Videos"]}),P?(0,o.jsx)("div",{className:"h-10 w-24 bg-gray-700 rounded animate-pulse"}):(0,o.jsx)("p",{className:"text-4xl font-bold text-[#d7ff00]",children:V})]}),(0,o.jsxs)("div",{className:"p-6 bg-[#262a30] rounded-xl border border-gray-700 shadow-lg md:col-span-1",children:[" ",(0,o.jsxs)("h3",{className:"text-lg font-semibold mb-2 flex items-center gap-2 text-gray-300",children:[(0,o.jsx)(C.Z,{className:"text-orange-400 h-5 w-5"})," Pending Reports"]}),X?(0,o.jsx)("div",{className:"h-10 w-24 bg-gray-700 rounded animate-pulse"}):(0,o.jsx)("p",{className:"text-4xl font-bold text-orange-400",children:J})]})]}),(0,o.jsx)("div",{className:"mb-6 p-4 bg-[#262a30] rounded-xl border border-gray-700",children:"allMoves"===e?(0,o.jsxs)("div",{className:"space-y-4",children:[(0,o.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,o.jsx)(b.Z,{className:"h-5 w-5 text-[#d7ff00]"}),(0,o.jsx)("h3",{className:"text-lg font-semibold text-white",children:"Search & Filter Exercises"})]}),(0,o.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[(0,o.jsxs)("div",{children:[(0,o.jsx)("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Search by Name or ID"}),(0,o.jsxs)("div",{className:"relative",children:[(0,o.jsx)(b.Z,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),(0,o.jsx)("input",{type:"text",placeholder:"Enter exercise name or ID...",value:ep,onChange:e=>ey(e.target.value),className:"w-full pl-10 pr-4 py-2 bg-[#1a1e24] border border-gray-600 rounded-lg text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#d7ff00] focus:border-transparent"})]})]}),(0,o.jsxs)("div",{children:[(0,o.jsx)("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Filter by Category"}),(0,o.jsxs)("div",{className:"relative",children:[(0,o.jsx)(M.Z,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400 z-10"}),(0,o.jsx)("input",{type:"text",placeholder:"Enter category...",value:ew,onChange:e=>ek(e.target.value),onFocus:()=>eF(!0),onBlur:()=>setTimeout(()=>eF(!1),200),className:"w-full pl-10 pr-4 py-2 bg-[#1a1e24] border border-gray-600 rounded-lg text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#d7ff00] focus:border-transparent"}),(eE||ew)&&(0,o.jsxs)("div",{className:"absolute z-20 mt-1 w-full bg-[#1a1e24] border border-gray-700 rounded-lg max-h-40 overflow-y-auto shadow-lg",children:[eI.filter(e=>!ew||e.toLowerCase().includes(ew.toLowerCase())).slice(0,20).map(e=>(0,o.jsx)("button",{type:"button",onClick:()=>{ek(e),eF(!1)},className:"w-full text-left px-3 py-2 text-sm text-gray-200 hover:bg-[#262a30] focus:bg-[#262a30] focus:outline-none",children:e},e)),0===eI.filter(e=>!ew||e.toLowerCase().includes(ew.toLowerCase())).length&&(0,o.jsx)("div",{className:"px-3 py-2 text-sm text-gray-500",children:"No categories found"})]})]})]}),(0,o.jsxs)("div",{children:[(0,o.jsx)("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Filter by Body Part"}),(0,o.jsxs)("div",{className:"relative",children:[(0,o.jsx)(M.Z,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400 z-10"}),(0,o.jsx)("input",{type:"text",placeholder:"Enter body part...",value:eC,onChange:e=>eM(e.target.value),onFocus:()=>eT(!0),onBlur:()=>setTimeout(()=>eT(!1),200),className:"w-full pl-10 pr-4 py-2 bg-[#1a1e24] border border-gray-600 rounded-lg text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#d7ff00] focus:border-transparent"}),(e_||eC)&&(0,o.jsxs)("div",{className:"absolute z-20 mt-1 w-full bg-[#1a1e24] border border-gray-700 rounded-lg max-h-40 overflow-y-auto shadow-lg",children:[eR.filter(e=>!eC||e.toLowerCase().includes(eC.toLowerCase())).slice(0,20).map(e=>(0,o.jsx)("button",{type:"button",onClick:()=>{eM(e),eT(!1)},className:"w-full text-left px-3 py-2 text-sm text-gray-200 hover:bg-[#262a30] focus:bg-[#262a30] focus:outline-none",children:e},e)),0===eR.filter(e=>!eC||e.toLowerCase().includes(eC.toLowerCase())).length&&(0,o.jsx)("div",{className:"px-3 py-2 text-sm text-gray-500",children:"No body parts found"})]})]})]}),(0,o.jsxs)("div",{children:[(0,o.jsx)("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Filter by Creator"}),(0,o.jsxs)("div",{className:"relative",children:[(0,o.jsx)(b.Z,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),(0,o.jsx)("input",{type:"text",placeholder:"Search creators...",value:eG,onChange:e=>eO(e.target.value),className:"w-full pl-10 pr-4 py-2 bg-[#1a1e24] border border-gray-600 rounded-lg text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#d7ff00] focus:border-transparent"}),eG&&(0,o.jsxs)("div",{className:"absolute z-10 mt-1 w-full bg-[#1a1e24] border border-gray-700 rounded-lg max-h-40 overflow-y-auto",children:[eV.filter(e=>e.toLowerCase().includes(eG.toLowerCase())).filter(e=>!eP.includes(e)).slice(0,20).map(e=>(0,o.jsx)("button",{onClick:()=>{ez(t=>[...t,e]),eO("")},className:"w-full text-left px-3 py-2 text-sm text-gray-200 hover:bg-[#262a30]",children:e},e)),0===eV.filter(e=>e.toLowerCase().includes(eG.toLowerCase())).length&&(0,o.jsx)("div",{className:"px-3 py-2 text-sm text-gray-500",children:"No creators found"})]})]}),eP.length>0&&(0,o.jsx)("div",{className:"flex flex-wrap gap-2 mt-2",children:eP.map(e=>(0,o.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs rounded bg-blue-900/40 text-blue-300 border border-blue-800",children:[e,(0,o.jsx)("button",{onClick:()=>ez(t=>t.filter(t=>t!==e)),className:"hover:text-[#d7ff00]",title:"Remove",children:"\xd7"})]},e))})]})]}),(0,o.jsx)("div",{className:"mt-4 pt-4 border-t border-gray-600",children:(0,o.jsxs)("div",{className:"flex items-center gap-4",children:[(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[(0,o.jsx)(L.Z,{className:"h-4 w-4 text-[#d7ff00]"}),(0,o.jsx)("span",{className:"text-sm font-medium text-gray-300",children:"Sort by:"})]}),(0,o.jsxs)("div",{className:"relative",children:[(0,o.jsxs)("button",{onClick:()=>eS(!eU),className:"flex items-center gap-2 px-4 py-2 bg-[#1a1e24] border border-gray-600 rounded-lg text-white hover:border-[#d7ff00] transition-colors focus:outline-none focus:ring-2 focus:ring-[#d7ff00] focus:border-transparent",children:[(0,o.jsxs)("span",{children:["name-asc"===eL&&"Name (A-Z)","name-desc"===eL&&"Name (Z-A)","date-ne
1west"===eL&&"Date (Newest)","date-oldest"===eL&&"Date (Oldest)"]}),(0,o.jsx)(Z.Z,{className:"h-4 w-4 transition-transform ".concat(eU?"rotate-180":"")})]}),eU&&(0,o.jsxs)("div",{className:"absolute z-20 mt-1 w-48 bg-[#1a1e24] border border-gray-700 rounded-lg overflow-hidden shadow-lg",children:[(0,o.jsx)("button",{onClick:()=>{eZ("name-asc"),eS(!1)},className:"w-full text-left px-4 py-2 text-sm hover:bg-[#262a30] transition-colors ".concat("name-asc"===eL?"text-[#d7ff00] bg-[#262a30]":"text-gray-200"),children:"Name (A-Z)"}),(0,o.jsx)("button",{onClick:()=>{eZ("name-desc"),eS(!1)},className:"w-full text-left px-4 py-2 text-sm hover:bg-[#262a30] transition-colors ".concat("name-desc"===eL?"text-[#d7ff00] bg-[#262a30]":"text-gray-200"),children:"Name (Z-A)"}),(0,o.jsx)("button",{onClick:()=>{eZ("date-newest"),eS(!1)},className:"w-full text-left px-4 py-2 text-sm hover:bg-[#262a30] transition-colors ".concat("date-newest"===eL?"text-[#d7ff00] bg-[#262a30]":"text-gray-200"),children:"Date (Newest)"}),(0,o.jsx)("button",{onClick:()=>{eZ("date-oldest"),eS(!1)},className:"w-full text-left px-4 py-2 text-sm hover:bg-[#262a30] transition-colors ".concat("date-oldest"===eL?"text-[#d7ff00] bg-[#262a30]":"text-gray-200"),children:"Date (Oldest)"})]})]})]})}),(ep||ew||eC||eP.length>0)&&(0,o.jsxs)("div",{className:"flex items-center justify-between pt-2 border-t border-gray-600",children:[(0,o.jsxs)("p",{className:"text-sm text-gray-400",children:["Showing ",E.length," of ",r.length," exercises"]}),(0,o.jsx)("button",{onClick:()=>{ey(""),ek(""),eM(""),ez([]),eO("")},className:"text-sm text-[#d7ff00] hover:text-[#b8d400] transition-colors",children:"Clear all filters"})]})]}):"reportedContent"===e?(0,o.jsxs)("div",{className:"space-y-4",children:[(0,o.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,o.jsx)(b.Z,{className:"h-5 w-5 text-[#d7ff00]"}),(0,o.jsx)("h3",{className:"text-lg font-semibold text-white",children:"Search Reported Content"})]}),(0,o.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-1 gap-4",children:(0,o.jsxs)("div",{children:[(0,o.jsx)("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Search Reports"}),(0,o.jsxs)("div",{className:"relative",children:[(0,o.jsx)(b.Z,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),(0,o.jsx)("input",{type:"text",placeholder:"Search by exercise name, reporter, video owner, or reason...",value:eb,onChange:e=>ev(e.target.value),className:"w-full pl-10 pr-4 py-2 bg-[#1a1e24] border border-gray-600 rounded-lg text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#d7ff00] focus:border-transparent"})]})]})}),eb&&(0,o.jsxs)("div",{className:"flex items-center justify-between pt-2 border-t border-gray-600",children:[(0,o.jsxs)("p",{className:"text-sm text-gray-400",children:["Showing ",q.length," of ",G.length," reports"]}),(0,o.jsx)("button",{onClick:()=>ev(""),className:"text-sm text-[#d7ff00] hover:text-[#b8d400] transition-colors",children:"Clear search"})]})]}):(0,o.jsxs)("div",{className:"space-y-4",children:[(0,o.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,o.jsx)(b.Z,{className:"h-5 w-5 text-[#d7ff00]"}),(0,o.jsx)("h3",{className:"text-lg font-semibold text-white",children:"Search & Filter Videos"})]}),(0,o.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,o.jsxs)("div",{children:[(0,o.jsx)("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Search Videos"}),(0,o.jsxs)("div",{className:"relative",children:[(0,o.jsx)(b.Z,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),(0,o.jsx)("input",{type:"text",placeholder:"Search by username, video ID, or exercise ID...",value:e1,onChange:e=>e2(e.target.value),className:"w-full pl-10 pr-4 py-2 bg-[#1a1e24] border border-gray-600 rounded-lg text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#d7ff00] focus:border-transparent"})]})]}),(0,o.jsxs)("div",{children:[(0,o.jsx)("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Filter Options"}),(0,o.jsxs)("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-4",children:[(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("input",{type:"checkbox",id:"showOrphanedOnly",checked:e4,onCh
1ange:e=>e5(e.target.checked),className:"mr-2 h-4 w-4 text-[#d7ff00] bg-[#1a1e24] border-gray-600 rounded focus:ring-[#d7ff00] focus:ring-2"}),(0,o.jsxs)("label",{htmlFor:"showOrphanedOnly",className:"text-sm text-gray-300",children:["Show orphaned videos only (",eK.length,")"]})]}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("input",{type:"checkbox",id:"showMissingGifOnly",checked:e3,onChange:e=>e6(e.target.checked),className:"mr-2 h-4 w-4 text-[#d7ff00] bg-[#1a1e24] border-gray-600 rounded focus:ring-[#d7ff00] focus:ring-2"}),(0,o.jsxs)("label",{htmlFor:"showMissingGifOnly",className:"text-sm text-gray-300",children:["Show videos without GIFs (",eW.filter(e=>!e.gifURL).length,")"]})]})]})]})]}),(e1||e4||e3)&&(0,o.jsxs)("div",{className:"flex items-center justify-between pt-2 border-t border-gray-600",children:[(0,o.jsxs)("p",{className:"text-sm text-gray-400",children:["Showing ",eJ.length," of ",eW.length," videos"]}),(0,o.jsx)("button",{onClick:()=>{e2(""),e5(!1),e6(!1)},className:"text-sm text-[#d7ff00] hover:text-[#b8d400] transition-colors",children:"Clear all filters"})]})]})}),(0,o.jsxs)("div",{className:"mb-6 border-b border-gray-700 flex space-x-1",children:[(0,o.jsxs)("button",{onClick:()=>{t("allMoves"),e6(!1)},className:"py-2 px-4 text-sm font-medium transition-colors rounded-t-md flex items-center gap-2 ".concat("allMoves"===e?"bg-[#262a30] text-[#d7ff00] border-x border-t border-gray-700":"text-gray-400 hover:text-gray-200 hover:bg-gray-700/30"),children:[(0,o.jsx)(w.Z,{className:"h-4 w-4"})," All Exercises"]}),(0,o.jsxs)("button",{onClick:()=>{t("reportedContent"),e6(!1)},className:"py-2 px-4 text-sm font-medium transition-colors rounded-t-md flex items-center gap-2 ".concat("reportedContent"===e?"bg-[#262a30] text-[#d7ff00] border-x border-t border-gray-700":"text-gray-400 hover:text-gray-200 hover:bg-gray-700/30"),children:[(0,o.jsx)(C.Z,{className:"h-4 w-4"})," Reported Content",!X&&J>0&&(0,o.jsx)("span",{className:"ml-1.5 px-2 py-0.5 rounded-full text-xs bg-orange-500/80 text-white font-semibold",children:J})]}),(0,o.jsxs)("button",{onClick:()=>{t("videoAudit"),e6(!1)},className:"py-2 px-4 text-sm font-medium transition-colors rounded-t-md flex items-center gap-2 ".concat("videoAudit"===e?"bg-[#262a30] text-[#d7ff00] border-x border-t border-gray-700":"text-gray-400 hover:text-gray-200 hover:bg-gray-700/30"),children:[(0,o.jsx)(h.Z,{className:"h-4 w-4"})," Video Audit",!eX&&eK.length>0&&(0,o.jsx)("span",{className:"ml-1.5 px-2 py-0.5 rounded-full text-xs bg-red-500/80 text-white font-semibold",children:eK.length})]}),(0,o.jsxs)("button",{onClick:()=>{t("missingGifs"),e6(!0)},className:"py-2 px-4 text-sm font-medium transition-colors rounded-t-md flex items-center gap-2 ".concat("missingGifs"===e?"bg-[#262a30] text-[#d7ff00] border-x border-t border-gray-700":"text-gray-400 hover:text-gray-200 hover:bg-gray-700/30"),children:[(0,o.jsx)(v.Z,{className:"h-4 w-4"})," Missing GIFs"]})]}),K&&(0,o.jsxs)("div",{className:"bg-red-900/20 p-4 rounded-lg border border-red-800 text-red-300 flex items-center gap-3 mb-6",children:[(0,o.jsx)(C.Z,{className:"h-5 w-5 flex-shrink-0"}),(0,o.jsx)("p",{children:K})]}),"allMoves"===e&&(_?(0,o.jsx)("div",{className:"flex justify-center items-center py-20",children:(0,o.jsx)(f.Z,{className:"h-10 w-10 text-[#d7ff00] animate-spin"})}):0!==E.length||0!==r.length||K?0===E.length&&r.length>0?(0,o.jsxs)("div",{className:"bg-[#1a1e24] p-8 rounded-lg border border-gray-700 text-center",children:[(0,o.jsx)(b.Z,{className:"h-12 w-12 mx-auto mb-4 text-gray-600"}),(0,o.jsx)("p",{className:"text-gray-400 text-lg",children:"No exercises match your search criteria."}),(0,o.jsx)("p",{className:"text-gray-500 text-sm mt-2",children:"Try adjusting your search terms or filters."})]}):(0,o.jsxs)("div",{className:"overflow-x-auto bg-[#1a1e24] rounded-xl shadow-xl border border-gray-800 rounded-t-none",children:[" ",(0,o.jsxs)("table",{className:"min-w-full",children:[(0,o.jsx)("thead",{children:(0,o.jsxs)("tr",{className:"border-b border-gray-700",children:[(0,o.jsx)("th",{className:"py-3 px-5 text-left text-xs text-gray-400 font-semibold uppercase tracking-wider",children:"Name"}),(0,o.jsx)("th",{className:"py-3 px-5 text-left text-xs text-gray-400 font-semibold uppercase tracking-wider",children:"Category"}),(0,o.jsx)("th",{className:"py-3 px-5 text-left text-xs text-gray-400 font-semibold uppercase tracking-wider",children:"Primary Body Parts"}),(0,o.jsx)("th",{className:"py-3 px-5 text-left text-xs text-gray-400 font-semibold uppercase tracking-wider",children:"Created At"}),(0,o.jsx)("th",{className:"py-3 px-5 text-center text-xs text-gray-400 font-semibold uppercase tracking-wider",children:"Videos"}),(0,o.jsx)("th",{className:"py-3 px-5 text-left text-xs text-gray-400 font-semibold uppercase tracking-wider",children:"Exercise ID"})]})}),(0,o.jsx)("tbody",{className:"divide-y divide-gray-700",children:E.map(e=>{var t;return(0,o.jsxs)("tr",{className:"hover:bg-[#20252c] transition-colors",children:[(0,o.jsx)("td",{className:"py-4 px-5 text-sm text-white font-medium",children:e.name}),(0,o.jsx)("td",{className:"py-4 px-5 text-sm text-gray-300",children:"string"==typeof e.category?e.category:(null===(t=e.category)||void 0===t?void 0:t.id)||"N/A"}),(0,o.jsx)("td",{className:"py-4 px-5 text-sm text-gray-300",children:e.primaryBodyParts&&e.primaryBodyParts.length>0?e.primaryBodyParts.join(", "):"N/A"}),(0,o.jsx)("td",{className:"py-4 px-5 text-sm text-gray-400",children:e.createdAt?tk(e.createdAt):"N/A"}),(0,o.jsx)("td",{className:"py-4 px-5 text-center",children:(0,o.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,o.jsxs)("button",{onClick:()=>{ea(e),tu(e.id)},className:"px-2.5 py-1.5 rounded-md text-xs font-medium border bg-blue-900/40 text-blue-300 border-blue-800 hover:bg-blue-800/60 transition-colors flex items-center gap-1.5",title:"View associated videos",children:[(0,o.jsx)(U.Z,{className:"h-3.5 w-3.5"}),"View","number"==typeof e.videoCount&&(0,o.jsx)("span",{className:"ml-1.5 px-1.5 py-0.5 rounded-full text-xs ".concat(e.videoCount>0?"bg-green-700/50 text-green-300":"bg-gray-600 text-gray-300"),children:e.videoCount})]}),(0,o.jsx)("button",{onClick:()=>tb(e),disabled:!!e9[e.firestoreDocId],className:"px-2.5 py-1.5 rounded-md text-xs font-medium border ".concat(e9[e.firestoreDocId]?"bg-gray-700/50 text-gray-400 border-gray-700 cursor-not-allowed":"bg-red-900/40 text-red-300 border-red-800 hover:bg-red-800/60"," transition-colors"),title:"Delete exercise and all videos",children:e9[e.firestoreDocId]?"Deleting...":"Delete"})]})}),(0,o.jsx)("td",{className:"py-4 px-5 text-xs text-gray-500 font-mono",children:e.id})]},e.firestoreDocId)})})]})]}):(0,o.jsxs)("div",{className:"bg-[#1a1e24] p-8 rounded-lg border border-gray-700 text-center",children:[(0,o.jsx)(w.Z,{className:"h-12 w-12 mx-auto mb-4 text-gray-600"}),(0,o.jsx)("p",{className:"text-gray-400 text-lg",children:"No exercises found in the database."})]})),"reportedContent"===e&&(W?(0,o.jsx)("div",{className:"flex justify-center items-center py-20",children:(0,o.jsx)(f.Z,{className:"h-10 w-10 text-[#d7ff00] animate-spin"})}):0!==q.length||0!==G.length||K?0===q.length&&G.length>0?(0,o.jsxs)("div",{className:"bg-[#1a1e24] p-8 rounded-lg border border-gray-700 text-center rounded-t-none",children:[(0,o.jsx)(b.Z,{className:"h-12 w-12 mx-auto mb-4 text-gray-600"}),(0,o.jsx)("p",{className:"text-gray-400 text-lg",children:"No reports match your search criteria."}),(0,o.jsx)("p",{className:"text-gray-500 text-sm mt-2",children:"Try adjusting your search terms."})]}):(0,o.jsx)("div",{className:"overflow-x-auto bg-[#1a1e24] rounded-xl shadow-xl border border-gray-800 rounded-t-none",children:(0,o.jsxs)("table",{className:"min-w-full",children:[(0,o.jsx)("thead",{children:(0,o.jsxs)("tr",{className:"border-b border-gray-700",children:[(0,o.jsx)("th",{className:"py-3 px-5 text-left text-xs text-gray-400 font-semibold uppercase tracking-wider",children:"Exercise Name"}),(0,o.jsx)("th",{className:"py-3 px-5 text-left text-xs text-gray-400 font-semibold uppercase tracking-wider",children:"Reported By"}),(0,o.jsx)("th",{className:"py-3 px-5 text-left text-xs text-gray-400 font-semibold uppercase tracking-wider",children:"Reason"}),(0,o.jsx)("th",{className:"py-3 px-5 text-left text-xs text-gray-400 font-semibold uppercase tracking-wider",children:"Status"}),(0,o.jsx)("th",{className:"py-3 px-5 text-left text-xs text-gray-400 font-semibold uppercase tracking-wider",children:"Date Reported"}),(0,o.jsx)("th",{className:"py-3 px-5 text-left text-xs text-gray-400 font-semibold uppercase tracking-wider",children:"Video Owner"}),(0,o.jsx)("th",{className:"py-3 px-5 text-center text-xs text-gray-400 font-semibold uppercase tracking-wider",children:"Video"}),(0,o.jsx)("th",{className:"py-3 px-5 text-center text-xs text-gray-400 font-semibold uppercase tracking-wider",children:"Actions"})]})}),(0,o.jsx)("tbody",{className:"divide-y divide-gray-700",children:q.map(e=>(0,o.jsxs)("tr",{className:"hover:bg-[#20252c] transition-colors ".concat("pending"===e.status?"bg-orange-800/10":""),children:[(0,o.jsx)("td",{className:"py-4 px-5 text-sm text-white font-medium",children:e.exerciseName||"N/A"}),(0,o.jsx)("td",{className:"py-4 px-5 text-sm text-gray-300",children:e.reporterUsername||e.reportedBy||"N/A"}),(0,o.jsx)("td",{className:"py-4 px-5 text-sm text-gray-300 truncate max-w-xs",title:e.message,children:e.message||"N/A"}),(0,o.jsx)("td",{className:"py-4 px-5 text-sm",children:(0,o.jsx)("span",{className:"px-2 py-1 text-xs font-semibold rounded-full ".concat("pending"===e.status?"bg-orange-500/80 text-white":"resolved"===e.status?"bg-green-500/80 text-white":"bg-gray-500/80 text-gray-100"),children:e.status||"N/A"})}),(0,o.jsx)("td",{className:"py-4 px-5 text-sm text-gray-400",children:e.createdAt?tk(e.createdAt):"N/A"}),(0,o.jsx)("td",{className:"py-4 px-5 text-sm text-gray-300",children:e.videoOwnerUsername||e.videoOwnerUserId||"N/A"}),(0,o.jsx)("td",{className:"py-4 px-5 text-center",children:e.videoURL?(0,o.jsxs)("a",{href:e.videoURL,target:"_blank",rel:"noopener noreferrer",className:"px-2.5 py-1.5 rounded-md text-xs font-medium border bg-blue-900/40 text-blue-300 border-blue-800 hover:bg-blue-800/60 transition-colors flex items-center mx-auto gap-1.5",children:[(0,o.jsx)(j.Z,{className:"h-3.5 w-3.5"})," View Video"]}):(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"No URL"})}),(0,o.jsx)("td",{className:"py-4 px-5 text-center",children:(0,o.jsxs)("div",{className:"flex items-center justify-center space-x-2",children:[(0,o.jsx)("button",{onClick:()=>tf(e.id),disabled:eh[e.id]||"completed"===e.status,className:"p-1.5 rounded-md transition-colors ".concat(eh[e.id]?"bg-gray-600 text-gray-400 cursor-not-allowed":"completed"===e.status?"bg-green-700/30 text-green-500 cursor-not-allowed":"bg-green-700/80 hover:bg-green-600/80 text-white"),title:"completed"===e.status?"Report already completed":"Mark as completed",children:eh[e.id]?(0,o.jsx)(f.Z,{className:"h-4 w-4 animate-spin"}):(0,o.jsx)(S.Z,{className:"h-4 w-4"})}),(0,o.jsx)("button",{onClick:()=>tp(e.id,e.videoId),disabled:eh[e.id]||"completed"===e.status,className:"p-1.5 rounded-md transition-colors ".concat(eh[e.id]?"bg-gray-600 text-gray-400 cursor-not-allowed":"completed"===e.status?"bg-red-700/30 text-red-500 cursor-not-allowed":"bg-red-700/80 hover:bg-red-600/80 text-white"),title:"completed"===e.status?"Report already completed (Content rejection should be done before marking complete if needed)":"Hide video & mark report as completed",children:eh[e.id]?(0,o.jsx)(f.Z,{className:"h-4 w-4 animate-spin"}):(0,o.jsx)(I.Z,{className:"h-4 w-4"})})]})})]},e.id))})]})}):(0,o.jsxs)("div",{className:"bg-[#1a1e24] p-8 rounded-lg border border-gray-700 text-center rounded-t-none",children:[(0,o.jsx)(C.Z,{className:"h-12 w-12 mx-auto mb-4 text-gray-600"}),(0,o.jsx)("p",{className:"text-gray-400 text-lg",children:"No reported content found."})]})),("videoAudit"===e||"missingGifs"===e)&&(eX?(0,o.jsx)("div",{className:"flex justify-center items-center py-20",children:(0,o.jsx)(f.Z,{className:"h-10 w-10 text-[#d7ff00] animate-spin"})}):0!==eJ.length||0!==eW.length||K?0===eJ.length&&eW.length>0?(0,o.jsxs)("div",{className:"bg-[#1a1e24] p-8 rounded-lg border border-gray-700 text-center rounded-t-none",children:[(0,o.jsx)(b.Z,{className:"h-12 w-12 mx-auto mb-4 text-gray-600"}),(0,o.jsx)("p",{className:"text-gray-400 text-lg",children:"No videos match your search criteria."}),(0,o.jsx)("p",{className:"text-gray-500 text-sm mt-2",children:"Try adjusting your search terms or filters."})]}):(0,o.jsx)("div",{className:"overflow-x-auto bg-[#1a1e24] rounded-xl shadow-xl border border-gray-800 rounded-t-none",children:(0,o.jsxs)("table",{className:"min-w-full",children:[(0,o.jsx)("thead",{children:(0,o.jsxs)("tr",{className:"border-b border-gray-700",children:[(0,o.jsx)("th",{className:"py-3 px-5 text-left text-xs text-gray-400 font-semibold uppercase tracking-wider",children:"Thumbnail"}),(0,o.jsx)("th",{className:"py-3 px-5 text-left text-xs text-gray-400 font-semibold uppercase tracking-wider",children:"Video ID"}),(0,o.jsx)("th",{className:"py-3 px-5 text-left text-xs text-gray-400 font-semibold uppercase tracking-wider",children:"Exercise ID"}),(0,o.jsx)("th",{className:"py-3 px-5 text-left text-xs text-gray-400 font-semibold uppercase tracking-wider",children:"Username"}),(0,o.jsx)("th",{className:"py-3 px-5 text-left text-xs text-gray-400 font-semibold uppercase tracking-wider",children:"Status"}),(0,o.jsx)("th",{className:"py-3 px-5 text-left text-xs text-gray-400 font-semibold uppercase tracking-wider",children:"Created At"}),(0,o.jsx)("th",{className:"py-3 px-5 text-center text-xs text-gray-400 font-semibold uppercase tracking-wider",children:"Video"}),(0,o.jsx)("th",{className:"py-3 px-5 text-center text-xs text-gray-400 font-semibold uppercase tracking-wider",children:"Actions"})]})}),(0,o.jsx)("tbody",{className:"divide-y divide-gray-700",children:eJ.map(e=>{let t=eK.some(t=>t.id===e.id);return(0,o.jsxs)("tr",{className:"hover:bg-[#20252c] transition-colors ".concat(t?"bg-red-800/10":""),children:[(0,o.jsx)("td",{className:"py-4 px-5",children:(0,o.jsx)("div",{className:"w-16 h-12 bg-black rounded flex items-center justify-center overflow-hidden",children:e.thumbnail?(0,o.jsx)("img",{src:e.thumbnail,alt:"Video thumbnail",className:"object-cover w-full h-full"}):(0,o.jsx)(v.Z,{className:"h-6 w-6 text-gray-500"})})}),(0,o.jsx)("td",{className:"py-4 px-5",children:(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[(0,o.jsxs)("span",{className:"text-xs text-gray-300 font-mono",children:[e.id.substring(0,12),"..."]}),(0,o.jsx)("button",{onClick:()=>tv(e.id,"Video ID"),className:"p-1 text-gray-400 hover:text-[#d7ff00] transition-colors",title:"Copy full video ID: ".concat(e.id),children:(0,o.jsx)(N.Z,{className:"h-3 w-3"})})]})}),(0,o.jsx)("td",{className:"py-4 px-5",children:e.exerciseId?(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[(0,o.jsx)("span",{className:"text-sm ".concat(t?"text-red-400":"text-gray-300"),children:e.exerciseId}),(0,o.jsx)("button",{onClick:()=>tv(e.exerciseId,"Exercise ID"),className:"p-1 text-gray-400 hover:text-[#d7ff00] transition-colors",title:"Copy exercise ID: ".concat(e.exerciseId),children:(0,o.jsx)(N.Z,{className:"h-3 w-3"})})]}):(0,o.jsx)("span",{className:"text-gray-500 text-sm",children:"N/A"})}),(0,o.jsx)("td",{className:"py-4 px-5 text-sm text-gray-300",children:e.username||"N/A"}),(0,o.jsx)("td",{className:"py-4 px-5 text-sm",children:t?(0,o.jsx)("span",{className:"px-2 py-1 text-xs font-semibold rounded-full bg-red-500/80 text-white",children:"Orphaned"}):(0,o.jsx)("span",{className:"px-2 py-1 text-xs font-semibold rounded-full bg-green-500/80 text-white",children:"Linked"})}),(0,o.jsx)("td",{className:"py-4 px-5 text-sm text-gray-400",children:e.createdAt?tk(e.createdAt):"N/A"}),(0,o.jsx)("td",{className:"py-4 px-5 text-center",children:e.videoURL?(0,o.jsxs)("button",{type:"button",onClick:()=>
1{if(e.exerciseId){let t=r.find(t=>t.id===e.exerciseId);t?(ea(t),tu(t.id)):window.open(e.videoURL,"_blank","noopener,noreferrer")}else window.open(e.videoURL,"_blank","noopener,noreferrer")},className:"px-2.5 py-1.5 rounded-md text-xs font-medium border bg-blue-900/40 text-blue-300 border-blue-800 hover:bg-blue-800/60 transition-colors flex items-center mx-auto gap-1.5",children:[(0,o.jsx)(j.Z,{className:"h-3.5 w-3.5"})," View"]}):(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"No URL"})}),(0,o.jsx)("td",{className:"py-4 px-5 text-center",children:(0,o.jsx)("button",{onClick:()=>ty(e.id),disabled:e7[e.id],className:"p-1.5 rounded-md transition-colors ".concat(e7[e.id]?"bg-gray-600 text-gray-400 cursor-not-allowed":"bg-red-700/80 hover:bg-red-600/80 text-white"),title:"Delete video permanently",children:e7[e.id]?(0,o.jsx)(f.Z,{className:"h-4 w-4 animate-spin"}):(0,o.jsx)(D.Z,{className:"h-4 w-4"})})})]},e.id)})})]})}):(0,o.jsxs)("div",{className:"bg-[#1a1e24] p-8 rounded-lg border border-gray-700 text-center rounded-t-none",children:[(0,o.jsx)(h.Z,{className:"h-12 w-12 mx-auto mb-4 text-gray-600"}),(0,o.jsx)("p",{className:"text-gray-400 text-lg",children:"No videos found in the database."})]}))]})}),es&&(es?(0,o.jsx)("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4 animate-fade-in-up",children:(0,o.jsxs)("div",{className:"bg-[#1a1e24] rounded-xl p-6 shadow-xl border border-[#d7ff00]/30 max-w-4xl w-full max-h-[90vh] flex flex-col",children:[(0,o.jsxs)("div",{className:"flex justify-between items-center mb-4 pb-4 border-b border-gray-700",children:[(0,o.jsxs)("div",{className:"flex items-center gap-3",children:[(0,o.jsx)(h.Z,{className:"h-6 w-6 text-[#d7ff00]"}),(0,o.jsxs)("div",{children:[(0,o.jsxs)("h3",{className:"text-xl font-semibold text-white",children:["Videos for: ",es.name]}),(0,o.jsxs)("p",{className:"text-sm text-gray-400",children:["(",ei.length," of ",eo.length," video",1!==eo.length?"s":""," shown)"]}),es.primaryBodyParts&&es.primaryBodyParts.length>0?(0,o.jsxs)("p",{className:"text-xs text-green-400 mt-1",children:["Body parts: ",es.primaryBodyParts.join(", ")]}):(0,o.jsx)("p",{className:"text-xs text-orange-400 mt-1",children:"No body parts assigned"})]})]}),(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[(0,o.jsx)("button",{onClick:()=>{var e;tw(es,null===(e=eo[0])||void 0===e?void 0:e.thumbnail)},disabled:to,className:"px-3 py-1.5 rounded-lg text-xs font-medium transition-colors flex items-center gap-1.5 ".concat(to?"bg-purple-900/30 text-purple-400 cursor-wait":"bg-purple-900/50 text-purple-200 border border-purple-700 hover:bg-purple-800/70"),title:"Use AI to infer and update the primary body parts for this exercise",children:to?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(f.Z,{className:"h-3.5 w-3.5 animate-spin"}),"Inferring..."]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(p.Z,{className:"h-3.5 w-3.5"}),"Infer Body Parts"]})}),(0,o.jsx)("button",{onClick:()=>{ea(null),eN(""),tl(null)},className:"p-1 text-gray-400 hover:text-white transition",title:"Close video view",children:(0,o.jsx)(y.Z,{className:"h-6 w-6"})})]})]}),(0,o.jsx)("div",{className:"mb-4",children:(0,o.jsxs)("div",{className:"relative",children:[(0,o.jsx)(b.Z,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),(0,o.jsx)("input",{type:"text",placeholder:"Search videos by username or ID...",value:ej,onChange:e=>eN(e.target.value),className:"w-full pl-10 pr-4 py-2 bg-[#262a30] border border-gray-600 rounded-lg text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#d7ff00] focus:border-transparent text-sm"})]})}),(0,o.jsx)("div",{className:"flex-grow overflow-y-auto pr-2",children:ed?(0,o.jsx)("div",{className:"flex justify-center items-center py-10",children:(0,o.jsx)(f.Z,{className:"h-8 w-8 text-[#d7ff00] animate-spin"})}):0===ei.length&&0===eo.length?(0,o.jsxs)("div",{className:"text-center py-10 text-gray-400",children:[(0,o.jsx)(h.Z,{className:"h-10 w-10 mx-auto mb-3 text-gray-600"}),(0,o.jsx)("p",{children:"No videos found for this exercise."})]}):0===ei.length&&eo.length>0?(0,o.jsxs)("div",{className:"text-center py-10 text-gray-400",children:[(0,o.jsx)(b.Z,{className:"h-10 w-10 mx-auto mb-3 text-gray-600"}),(0,o.jsx)("p",{children:"No videos match your search criteria."}),(0,o.jsx)("p",{className:"text-gray-500 text-sm mt-2",children:"Try adjusting your search terms."})]}):(0,o.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:ei.map(e=>(0,o.jsxs)("div",{className:"bg-[#262a30] rounded-lg overflow-hidden border border-gray-700 group",children:[(0,o.jsxs)("div",{className:"aspect-video bg-black relative flex items-center justify-center",children:[e.thumbnail?(0,o.jsx)("img",{src:e.thumbnail,alt:"Thumbn
1ail for ".concat(es.name),className:"object-cover w-full h-full transition-transform group-hover:scale-105"}):(0,o.jsxs)("div",{className:"text-gray-500 flex flex-col items-center",children:[(0,o.jsx)(v.Z,{className:"h-10 w-10 mb-1"}),(0,o.jsx)("span",{className:"text-xs",children:"No thumbnail"})]}),(0,o.jsx)("a",{href:e.videoURL&&!e.videoURL.startsWith("gs://")?e.videoURL:"#",target:"_blank",rel:"noopener noreferrer",className:"absolute inset-0 bg-black/40 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity ".concat(!e.videoURL||e.videoURL.startsWith("gs://")?"cursor-not-allowed":""),title:e.videoURL&&!e.videoURL.startsWith("gs://")?"Watch video":"Video URL not public",children:(0,o.jsx)(j.Z,{className:"h-12 w-12 text-white/80"})})]}),(0,o.jsxs)("div",{className:"p-3",children:[(0,o.jsxs)("p",{className:"text-xs text-gray-400 mb-2",children:["Uploaded by: ",e.username||"Unknown"]}),(0,o.jsxs)("p",{className:"text-xs text-gray-400 mb-2",children:["File size: ",tC(e.fileSizeBytes)]}),(0,o.jsxs)("div",{className:"mb-2",children:[(0,o.jsx)("p",{className:"text-xs text-gray-500 mb-1",children:"Video ID:"}),(0,o.jsxs)("div",{className:"flex items-center gap-2 p-2 bg-[#1a1e24] rounded border border-gray-600",children:[(0,o.jsx)("p",{className:"text-xs text-gray-300 font-mono flex-1 break-all",children:e.id}),(0,o.jsx)("button",{onClick:()=>tv(e.id,"Video ID"),className:"p-1 text-gray-400 hover:text-[#d7ff00] transition-colors flex-shrink-0",title:"Copy video ID",children:(0,o.jsx)(N.Z,{className:"h-3 w-3"})})]})]}),(0,o.jsxs)("div",{className:"mb-2",children:[(0,o.jsx)("p",{className:"text-xs text-gray-500 mb-1",children:"GIF URL:"}),(0,o.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,o.jsxs)("div",{className:"flex items-center gap-2 p-2 bg-[#1a1e24] rounded border border-gray-600",children:[(0,o.jsx)("p",{className:"text-xs text-gray-300 font-mono flex-1 break-all",children:e.gifURL||"No GIF URL set"}),e.gifURL?(0,o.jsx)("button",{onClick:()=>tv(e.gifURL||"","GIF URL"),className:"p-1 text-gray-400 hover:text-[#d7ff00] transition-colors flex-shrink-0",title:"Copy GIF URL",children:(0,o.jsx)(N.Z,{className:"h-3 w-3"})}):null]}),!e.gifURL&&(0,o.jsx)("button",{onClick:()=>tj(e.id),disabled:!!tt[e.id],className:"inline-flex items-center justify-center px-2.5 py-1.5 rounded-md text-[11px] font-medium border transition-colors ".concat(tt[e.id]?"bg-gray-700/60 text-gray-400 border-gray-600 cursor-wait":"bg-purple-900/50 text-purple-200 border-purple-700 hover:bg-purple-800/70"),title:"Manually generate a GIF preview for this video",children:tt[e.id]?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(f.Z,{className:"h-3 w-3 mr-1 animate-spin"}),"Generating GIF..."]}):"Generate GIF"})]})]}),(0,o.jsxs)("div",{className:"mb-2",children:[(0,o.jsx)("p",{className:"text-xs text-gray-500 mb-1",children:"Video URL:"}),(0,o.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,o.jsxs)("div",{className:"flex items-center gap-2 p-2 bg-[#1a1e24] rounded border border-gray-600",children:[(0,o.jsx)("p",{className:"text-xs text-gray-300 font-mono flex-1 break-all",children:e.videoURL||"No video URL set"}),e.videoURL&&(0,o.jsx)("button",{onClick:()=>tv(e.videoURL||"","Video URL"),className:"p-1 text-gray-400 hover:text-[#d7ff00] transition-colors flex-shrink-0",title:"Copy video URL",children:(0,o.jsx)(N.Z,{className:"h-3 w-3"})})]}),e.videoURL&&e.videoURL.includes(".webm")&&(0,o.jsx)("button",{onClick:()=>tN(e),disabled:!!ts[e.id],className:"inline-flex items-center justify-center px-2.5 py-1.5 rounded-md text-[11px] font-medium border transition-colors ".concat(ts[e.id]?"bg-gray-700/60 text-gray-400 border-gray-600 cursor-wait":"bg-indigo-900/50 text-indigo-200 border-indigo-700 hover:bg-indigo-800/70"),title:"Rename backing file to .mp4 and update ExerciseVideo URL",children:ts[e.id]?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(f.Z,{className:"h-3 w-3 mr-1 animate-spin"}),"Setting as MP4..."]}):"Set as MP4"})]})]}),(0,o.jsxs)("div",{className:"mb-2",children:[(0,o.jsx)("p",{className:"text-xs text-gray-500 mb-1",children:"Thumbnail URL:"}),(0,o.jsxs)("div",{className:"flex items-center gap-2 p-2 bg-[#1a1e24] rounded border border-gray-600",children:[(0,o.jsx)("p",{className:"text-xs text-gray-300 font-mono flex-1 break-all",children:e.thumbnail||"No thumbnail URL set"}),e.thumbnail&&(0,o.jsx)("button",{onClick:()=>tv(e.thumbnail||"","Thumbnail URL"),className:"p-1 text-gray-400 hover:text-[#d7ff00] transition-colors flex-shrink-0",title:"Copy thumbnail URL",children:(0,o.jsx)(N.Z,{className:"h-3 w-3"})})]})]}),!e.thumbnail&&(0,o.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,o.jsx)("p",{className:"text-xs text-orange-400 italic",children:"Thumbnail pending"}),(0,o.jsx)("button",{onClick:()=>tj(e.id),disabled:!!tt[e.id],className:"px-2 py-1 rounded text-xs font-medium transition-colors ".concat(tt[e.id]?"bg-gray-700/50 text-gray-400 cursor-wait":"bg-orange-900/40 text-orange-300 border border-orange-800 hover:bg-orange-800/60"),title:"Generate thumbnail and GIF for this video",children:tt[e.id]?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(f.Z,{className:"h-3 w-3 inline mr-1 animate-spin"}),"Generating..."]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(p.Z,{className:"h-3 w-3 inline mr-1"}),"Generate Thumbnail"]})})]}),(0,o.jsx)("div",{className:"mt-3",children:(0,o.jsx)("button",{onClick:()=>th(e.exerciseId,e.id),disabled:eu===e.id,className:"w-full px-2.5 py-1.5 rounded-md text-xs font-medium border transition-colors ".concat(eu===e.id?"bg-gray-700/50 text-gray-400 border-gray-700 cursor-wait":"bg-green-900/40 text-green-300 border-green-800 hover:bg-green-800/60"),title:"Set this as today\\'s Move of the Day",children:eu===e.id?"Setting...":"Set Move of the Day"})})]})]},e.id))})}),(0,o.jsx)("div",{className:"mt-6 pt-4 border-t border-gray-700 flex justify-end",children:(0,o.jsx)("button",{onClick:()=>{ea(null),eN(""),tl(null)},className:"px-4 py-2 bg-gray-700/30 text-gray-300 rounded-lg text-sm font-medium border border-gray-700 hover:bg-gray-700/50 transition flex items-center",children:"Close"})})]})}):null),et&&(0,o.jsxs)("div",{className:"fixed bottom-5 right-5 py-2.5 px-5 rounded-lg shadow-xl flex items-center gap-2.5 animate-fade-in-up z-[100] ".concat("success"===et.type?"bg-green-700/95 border border-green-600 text-white":"error"===et.type?"bg-red-700/95 border border-red-600 text-white":"bg-blue-700/95 border border-blue-600 text-white"),children:["success"===et.type?(0,o.jsx)(R.Z,{className:"h-5 w-5"}):"error"===et.type?(0,o.jsx)(C.Z,{className:"h-5 w-5"}):(0,o.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:[" ",(0,o.jsx)("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2h-1V9a1 1 0 00-1-1z",clipRule:"evenodd"})," "]}),(0,o.jsx)("span",{className:"text-sm font-medium",children:et.text})]})]})}}},function(e){e.O(0,[31095,878,95196,39866,92888,49774,40179],function(){return e(e.s=7223)}),_N_E=e.O()}]);

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.