PageSourceSearch

https://collectyourcards.com/assets/AdminImport-rUa0BbRA.js

js collectyourcards.com collected 2026-10-06 21:55:03 UTC 44,449 bytes, 8 lines download raw bytes

1import{c as Be,r as p,j as e,I as C,R as He,e as B,b as Ve,d as We,h as Ke}from"./index-GGGK6ZTX.js";const Je=({cards:m=[],loading:$=!1,onCardUpdate:h=null,organizationId:F=null,showSearch:M=!0,searchQuery:w="",onSearchChange:_=null,maxHeight:X="600px"})=>{const{showToast:l}=Be(),[R,V]=p.useState("sortOrder"),[O,ae]=p.useState("asc"),[U,D]=p.useState(new Set),[ee,te]=p.useState([]),[ne,x]=p.useState(!0),[A,de]=p.useState(""),[me,Oe]=p.useState(""),[xe,se]=p.useState(""),[Y,G]=p.useState(!1),[re,pe]=p.useState(null),Ne=p.useRef(null),q=p.useRef(null);p.useEffect(()=>{(async()=>{try{const a=await B.get("/api/admin/colors");te(a.data.colors||[])}catch(a){console.error("Error fetching colors:",a),l&&l("Failed to load colors","error")}finally{x(!1)}})()},[l]),p.useEffect(()=>{const s=a=>{Ne.current&&!Ne.current.contains(a.target)&&pe(null)};if(re!==null)return document.addEventListener("mousedown",s),()=>{document.removeEventListener("mousedown",s)}},[re]);const ke=(s,a)=>{if(h){const t=[...m];t[s].notes=a,h(t)}},he=(s,a)=>{if(h){const t=m.findIndex(c=>c.sortOrder===s);if(t===-1)return;const o=[...m];o[t].printRun=a===""?null:parseInt(a)||null,h(o)}},ge=(s,a)=>{if(h){const t=m.findIndex(c=>c.sortOrder===s);if(t===-1)return;const o=[...m];o[t].colorId=a===""?null:parseInt(a)||null,h(o)}},ue=()=>{if(h){const s=A===""?null:parseInt(A)||null,a=m.map(t=>({...t,printRun:s}));h(a),l&&l(`Applied print run ${s||"(none)"} to all cards`,"success"),G(!1)}},Ie=()=>{var s;if(h){const a=me===""?null:parseInt(me)||null,t=m.map(c=>({...c,colorId:a}));h(t);const o=((s=ee.find(c=>c.color_id===a))==null?void 0:s.name)||"(none)";l&&l(`Applied color "${o}" to all cards`,"success"),G(!1)}},le=p.useMemo(()=>{if(!w.trim())return m;const s=w.toLowerCase();return m.filter(a=>{if(a.cardNumber&&String(a.cardNumber).toLowerCase().includes(s))return!0;if(a.playerNames){if(Array.isArray(a.playerNames)){if(a.playerNames.some(t=>t&&String(t).toLowerCase().includes(s)))return!0}else if(String(a.playerNames).toLowerCase().includes(s))return!0}if(a.players&&Array.isArray(a.players)&&a.players.some(t=>t.name&&String(t.name).toLowerCase().includes(s)))return!0;if(a.teamNames){if(Array.isArray(a.teamNames)){if(a.teamNames.some(t=>t&&String(t).toLowerCase().includes(s)))return!0}else if(String(a.teamNames).toLowerCase().includes(s))return!0}return!!(a.notes&&String(a.notes).toLowerCase().includes(s))})},[m,w]),oe=p.useMemo(()=>[...le].sort((a,t)=>{let o=a[R],c=t[R];if(R==="sortOrder")return O==="asc"?o-c:c-o;if(R==="cardNumber"){const r=parseInt(a.cardNumber),y=parseInt(t.cardNumber);if(!isNaN(r)&&!isNaN(y)&&a.cardNumber===r.toString()&&t.cardNumber===y.toString())return O==="asc"?r-y:y-r;o=String(a.cardNumber||"").toLowerCase(),c=String(t.cardNumber||"").toLowerCase()}if(typeof o!="number"){if(o=String(o||"").toLowerCase(),c=String(c||"").toLowerCase(),o<c)return O==="asc"?-1:1;if(o>c)return O==="asc"?1:-1}return 0}),[le,R,O]),ce=s=>{R===s?ae(O==="asc"?"desc":"asc"):(V(s),ae("asc"))},$e=s=>{if(h){const a=m.findIndex(o=>o.sortOrder===s);if(a===-1)return;const t=[...m];t[a].isRC=!t[a].isRC,h(t)}},Me=s=>{if(h){const a=m.findIndex(o=>o.sortOrder===s);if(a===-1)return;const t=[...m];t[a].isAutograph=!t[a].isAutograph,h(t)}},ze=s=>{if(h){const a=m.findIndex(o=>o.sortOrder===s);if(a===-1)return;const t=[...m];t[a].isRelic=!t[a].isRelic,h(t)}},Ae=s=>{if(h){const a=m.findIndex(o=>o.sortOrder===s);if(a===-1)return;const t=[...m];t[a].isShortPrint=!t[a].isShortPrint,h(t)}},ve=()=>{if(h){const s=m.every(t=>t.isRC),a=m.map(t=>({...t,isRC:!s}));h(a)}},Le=()=>{if(h){const s=m.every(t=>t.isAutograph),a=m.map(t=>({...t,isAutograph:!s}));h(a)}},Re=()=>{if(h){const s=m.every(t=>t.isRelic),a=m.map(t=>({...t,isRelic:!s}));h(a)}},Te=()=>{if(h){const s=m.every(t=>t.isShortPrint),a=m.map(t=>({...t,isShortPrint:!s}));h(a)}},Ee=()=>{if(h){const s=m.map(a=>({...a,notes:xe}));h(s),l&&l(`Applied notes to all ${m.length} cards`,"success"),G(!1)}},we=async(s,a,t)=>{var o,c,r,y,N,k,v,E,T;if(h){const P=m.findIndex(j=>j.sortOrder===s);if(P===-1)return;const b=[...m],i=b[P].players[a],n=((c=(o=i.playerMatches)==null?void 0:o.exact)==null?void 0:c.find(j=>j.playerId===t))||((y=(r=i.playerMatches)==null?void 0:r.fuzzy)==null?void 0:y.find(j=>j.playerId===t));b[P].players[a].selectedPlayer=n;const f=((N=i.playerTeamCheckTeams)==null?void 0:N.exact)||((k=i.teamMatches)==null?void 0:k.exact)||[];if(n&&f.length>0){console.log(`🔗 Player selected: ${n.playerName}, checking player_team records for ${f.length} teams...`);const j=[],z=f;for(const u of z){const I=(v=i.playerTeamMatches)==null?void 0:v.some(d=>d.playerId===n.playerId&&d.teamId===u.teamId),S=(E=n.teams)==null?void 0:E.some(d=>d.teamId===u.teamId);if(I){console.log(`✅ Player_team already exists in cache: ${n.playerName} - ${u.teamName}`);continue}if(S){console.log(`✅ Player ${n.playerName} already has team ${u.teamName} - adding to cache`);const d=(T=n.teams)==null?void 0:T.find(g=>g.teamId===u.teamId),L={playerTeamId:(d==null?void 0:d.playerTeamId)||`existing_${n.playerId}_${u.teamId}`,playerId:n.playerId,teamId:u.teamId,playerName:n.playerName,teamName:u.teamName};
1i.playerTeamMatches||(i.playerTeamMatches=[]),i.selectedPlayerTeams||(i.selectedPlayerTeams=[]),i.playerTeamMatches.push(L),i.selectedPlayerTeams.push(L);continue}console.log(`🔍 Checking database for player_team: ${n.playerName} + ${u.teamName}`);const Q=B.post("/api/admin/import/create-player-team",{playerId:n.playerId,teamId:u.teamId}).then(d=>{if(d.data.success)return i.playerTeamMatches||(i.playerTeamMatches=[]),i.selectedPlayerTeams||(i.selectedPlayerTeams=[]),i.playerTeamMatches.push(d.data.playerTeam),i.selectedPlayerTeams.push(d.data.playerTeam),console.log(`✅ Created player_team: ${d.data.playerTeam.playerName} - ${d.data.playerTeam.teamName}`),d.data.playerTeam}).catch(d=>{var L,g,J;if((J=(g=(L=d.response)==null?void 0:L.data)==null?void 0:g.message)!=null&&J.includes("already exists")){console.log(`✅ Player_team already exists in database: ${n.playerName} - ${u.teamName}`);const W={playerTeamId:`existing_${n.playerId}_${u.teamId}`,playerId:n.playerId,teamId:u.teamId,playerName:n.playerName,teamName:u.teamName};return i.playerTeamMatches||(i.playerTeamMatches=[]),i.selectedPlayerTeams||(i.selectedPlayerTeams=[]),i.playerTeamMatches.push(W),i.selectedPlayerTeams.push(W),W}else return console.error("Error checking/creating player_team:",d),null});j.push(Q)}j.length>0?Promise.all(j).then(u=>{const I=u.filter(S=>S!==null);I.length>0&&(console.log(`✅ Auto-created ${I.length} player_team records`),l&&l(`Auto-created ${I.length} player-team combinations`,"success")),h([...b])}):h(b)}else h(b)}},Fe=async(s,a,t)=>{var o,c,r;try{console.log("🔄 Creating new player:",t,"cardSortOrder:",s,"playerIndex:",a);const y=t.split(" "),N=y[0]||"",k=y.slice(1).join(" ")||"";console.log("📤 Sending create player request:",{firstName:N,lastName:k});const v=await B.post("/api/admin/import/create-player",{firstName:N,lastName:k});if(v.data.success){const E=v.data.player.playerId;let T=[];const P=m.findIndex(j=>j.sortOrder===s);if(console.log("🔍 Looking for card with sortOrder:",s),console.log("🔍 Found cardIndex:",P),console.log("🔍 Total cards in array:",m.length),P===-1){console.error("❌ Could not find card with sortOrder:",s),console.log("Available sortOrders:",m.map(j=>j.sortOrder)),l&&l("Error: Card not found for player creation","error");return}const b=m[P].players[a];console.log("🔍 Current player before update:",b);const i=((o=m[P].teamMatches)==null?void 0:o.exact)||[],n=`Created player: ${v.data.player.playerName}`;l&&l(n,"success");const f={playerId:v.data.player.playerId,playerName:v.data.player.playerName,firstName:v.data.player.firstName,lastName:v.data.player.lastName,teams:[]};h(j=>{const z=[...j];let u=0;return z.forEach((I,S)=>{var Q;(Q=I.players)==null||Q.forEach((d,L)=>{var g;((g=d.name)==null?void 0:g.toLowerCase())===t.toLowerCase()&&!d.selectedPlayer&&(console.log(`🔄 Updating player "${d.name}" on card ${I.sortOrder}`),z[S].players[L]={...z[S].players[L],playerMatches:{exact:[f],fuzzy:[]},selectedPlayer:f,playerTeamMatches:[],_renderKey:Date.now()},u++)})}),console.log(`🎯 Updated ${u} instances of player "${t}" across all cards`),z})}}catch(y){console.error("❌ Error creating player:",y),l&&l(((r=(c=y.response)==null?void 0:c.data)==null?void 0:r.message)||"Failed to create player","error")}},Pe=async(s,a,t,o)=>{var c,r;try{if(!F){l&&l("Organization ID not available - cannot create team","error");return}const y=await B.post("/api/admin/import/create-team",{teamName:o.trim(),city:null,abbreviation:null,organizationId:F});if(y.data.success){const N=y.data.team;l&&l(`Created new team: ${N.teamName}`,"success");const k=[...m];let v=0,E=[];k.forEach((T,P)=>{var i;((i=T.teamNames)==null?void 0:i.some(n=>n.toLowerCase()===o.toLowerCase()))&&(T.teamMatches||(T.teamMatches={exact:[],fuzzy:[]}),T.teamMatches.exact||(T.teamMatches.exact=[]),T.teamMatches.exact.some(f=>f.teamId===N.teamId)||(T.teamMatches.exact.push(N),console.log(`✅ Added team ${N.teamName} to card ${P} exact matches`)),T.teamMatches.fuzzy&&(T.teamMatches.fuzzy=T.teamMatches.fuzzy.filter(f=>
1f.teamId!==N.teamId))),T.players.forEach((n,f)=>{var z,u;if(((z=n.teamNames)==null?void 0:z.some(I=>I.toLowerCase()===o.toLowerCase()))&&(n.teamMatches||(n.teamMatches={exact:[],fuzzy:[]}),n.teamMatches.exact||(n.teamMatches.exact=[]),n.teamMatches.exact.some(S=>S.teamId===N.teamId)||(n.teamMatches.exact.push(N),v++),P===s&&f===a&&(n.selectedTeams||(n.selectedTeams=[]),n.selectedTeams[t]=N),n.selectedPlayer&&n.selectedPlayer.playerId)){const S=n.selectedPlayer.playerId,Q=N.teamId;if(!((u=n.playerTeamMatches)==null?void 0:u.some(L=>L.playerId===S&&L.teamId===Q))){console.log(`🔗 Creating player_team: ${n.selectedPlayer.playerName} + ${N.teamName}`);const L=B.post("/api/admin/import/create-player-team",{playerId:S,teamId:Q}).then(g=>{if(g.data.success)return n.playerTeamMatches||(n.playerTeamMatches=[]),n.selectedPlayerTeams||(n.selectedPlayerTeams=[]),n.playerTeamMatches.push(g.data.playerTeam),n.selectedPlayerTeams.push(g.data.playerTeam),console.log(`✅ Created player_team: ${g.data.playerTeam.playerName} - ${g.data.playerTeam.teamName}`),{cardIdx:P,playerIdx:f,playerTeam:g.data.playerTeam}}).catch(g=>(console.error("Error creating player_team:",g),null));E.push(L)}}})}),console.log(`🔄 Updated ${v} player entries with new team: ${N.teamName}`),E.length>0?Promise.all(E).then(T=>{const P=T.filter(b=>b!==null);P.length>0&&(console.log(`✅ Created ${P.length} player_team records`),l&&l(`Created ${P.length} player-team combinations for ${N.teamName}`,"success")),h([...k])}):h(k)}}catch(y){l&&l(((r=(c=y.response)==null?void 0:c.data)==null?void 0:r.message)||"Failed to create team","error")}},Se=s=>{var a,t,o,c;if(!((a=s.players)!=null&&a.every(r=>r.selectedPlayer))||((t=s.teamNames)==null?void 0:t.length)>0&&!s.teamNames.every(y=>{var N,k;return(k=(N=s.teamMatches)==null?void 0:N.exact)==null?void 0:k.some(v=>v.teamName.toLowerCase().includes(y.toLowerCase()))}))return!0;for(const r of s.players||[]){if(!r.selectedPlayer)continue;const y=((o=r.playerTeamCheckTeams)==null?void 0:o.exact)||[];for(const N of y)if(!((c=r.playerTeamMatches)==null?void 0:c.some(v=>v.playerId===r.selectedPlayer.playerId&&v.teamId===N.teamId)))return!0}return!1},_e=()=>{const s=oe.findIndex(a=>Se(a));if(s>=0&&q.current){const a=q.current.querySelector(`tr[data-card-index="${s}"]`);a&&(a.scrollIntoView({behavior:"smooth",block:"center"}),a.classList.add("import-row-highlight"),setTimeout(()=>a.classList.remove("import-row-highlight"),2e3))}},je=({field:s})=>R!==s?null:e.jsx(C,{name:O==="asc"?"chevron-up":"chevron-down",size:14,className:`import-table-sort-icon ${O}`});return $?e.jsxs("div",{className:"import-table-loading",children:[e.jsx("div",{className:"card-icon-spinner"}),e.jsx("p",{children:"Processing import data..."})]}):e.jsxs("div",{className:"import-table-container",children:[Y&&e.jsx("div",{className:"bulk-edit-modal-overlay",onClick:()=>G(!1),children:e.jsxs("div",{className:"bulk-edit-modal",onClick:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"bulk-edit-header",children:[e.jsxs("h3",{children:[Y==="printRun"&&"Set Print Run for All Cards",Y==="color"&&"Set Color for All Cards",Y==="notes"&&"Set Notes for All Cards"]}),e.jsx("button",{className:"modal-close-btn",onClick:()=>G(!1),children:e.jsx(C,{name:"x",size:20})})]}),e.jsxs("div",{className:"bulk-edit-content",children:[Y==="printRun"&&e.jsxs(e.Fragment,{children:[e.jsx("label",{htmlFor:"bulk-print-run",children:"Print Run:"}),e.jsx("input",{id:"bulk-print-run",type:"number",className:"bulk-input",value:A,onChange:s=>de(s.target.value),placeholder:"Enter print run (leave empty for none)",min:"1",autoFocus:!0}),e.jsxs("p",{className:"bulk-help-text",children:["This will apply the same print run to all ",m.length," cards in this import."]})]}),Y==="color"&&e.jsxs(e.Fragment,{children:[e.jsx("label",{htmlFor:"bulk-color",children:"Color:"}),e.jsxs("select",{id:"bulk-color",className:"bulk-select",value:me,onChange:s=>Oe(s.target.value),autoFocus:!0,children:[e.jsx("option",{value:"",children:"— No Color —"}),ee.map(s=>e.jsx("option",{value:s.color_id,children:s.name},s.color_id))]}),e.jsxs("p",{className:"bulk-help-text",children:["This will apply the same color to all ",m.length," cards in this import."]})]}),Y==="notes"&&e.jsxs(e.Fragment,{children:[e.jsx("label",{htmlFor:"bulk-notes",children:"Notes:"}),e.jsx("input",{id:"bulk-notes",type:"text",className:"bulk-input",value:xe,onChange:s=>se(s.target.value),placeholder:"Enter notes to apply to all cards",autoFocus:!0}),e.jsxs("p",{className:"bulk-help-text",children:["This will replace the notes on all ",m.length," cards in this import."]})]})]}),e.jsxs("div",{className:"bulk-edit-actions",children:[e.jsx("button",{className:"bulk-cancel-btn",onClick:()=>G(!1),children:"Cancel"}),e.jsx("button",{className:"bulk-apply-btn",onClick:Y==="printRun"?ue:Y==="color"?Ie:Ee,children:"Apply to All Cards"})]})]})}
1),M&&e.jsx("div",{className:"import-table-controls",children:e.jsx("div",{className:"import-table-search-container",children:e.jsx("input",{type:"text",placeholder:"Search imported cards...",value:w,onChange:s=>_==null?void 0:_(s.target.value),className:"import-table-search-input"})})}),e.jsx("div",{ref:q,className:"import-table-wrapper",style:{maxHeight:X,overflowY:X==="none"?"hidden":"auto"},children:e.jsxs("table",{className:"import-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"sortable sort-order-header",children:e.jsxs("div",{className:"import-table-header-content",onClick:()=>ce("sortOrder"),children:["# ",e.jsx(je,{field:"sortOrder"})]})}),e.jsx("th",{className:"sortable card-number-header",children:e.jsxs("div",{className:"import-table-header-content",onClick:()=>ce("cardNumber"),children:["CARD # ",e.jsx(je,{field:"cardNumber"})]})}),e.jsx("th",{className:"sortable player-header",children:e.jsxs("div",{className:"import-table-header-content",onClick:()=>ce("playerNames"),children:["PLAYER(S) ",e.jsx(je,{field:"playerNames"})]})}),e.jsx("th",{className:"team-header",children:e.jsx("div",{className:"import-table-header-content",children:"TEAM(S)"})}),e.jsx("th",{className:"rc-header",children:e.jsx("div",{className:"import-table-header-content clickable-header",onClick:ve,title:"Click to toggle all RC",children:"RC"})}),e.jsx("th",{className:"auto-header",children:e.jsx("div",{className:"import-table-header-content clickable-header",onClick:Le,title:"Click to toggle all AUTO",children:"AUTO"})}),e.jsx("th",{className:"relic-header",children:e.jsx("div",{className:"import-table-header-content clickable-header",onClick:Re,title:"Click to toggle all RELIC",children:"RELIC"})}),e.jsx("th",{className:"sp-header",children:e.jsx("div",{className:"import-table-header-content clickable-header",onClick:Te,title:"Click to toggle all SP",children:"SP"})}),e.jsx("th",{className:"print-run-header",children:e.jsx("div",{className:"import-table-header-content clickable-header",onClick:()=>G("printRun"),title:"Click to set print run for all cards",children:"PRINT RUN"})}),e.jsx("th",{className:"color-header",children:e.jsx("div",{className:"import-table-header-content clickable-header",onClick:()=>G("color"),title:"Click to set color for all cards",children:"COLOR"})}),e.jsx("th",{className:"player-team-combo-header",children:e.jsx("div",{className:"import-table-header-content",children:"PLAYER TEAM"})}),e.jsx("th",{className:"notes-header",children:e.jsx("div",{className:"import-table-header-content clickable-header",onClick:()=>G("notes"),title:"Click to set notes for all cards",children:"NOTES"})})]})}),e.jsx("tbody",{children:oe.map((s,a)=>{var t,o,c;return U.has(a),e.jsx(He.Fragment,{children:e.jsxs("tr",{className:"import-row","data-card-index":a,children:[e.jsx("td",{className:"sort-order-cell",children:e.jsx("span",{className:"import-sort-order",children:s.sortOrder})}),e.jsx("td",{className:"card-number-cell",children:e.jsx("span",{className:"import-card-number",children:s.cardNumber})}),e.jsx("td",{className:"player-cell",children:e.jsx("div",{className:"import-players-summary",children:(s.players||[]).map((r,y)=>{var N,k,v,E,T,P;return e.jsxs("div",{className:"import-player-entry",children:[!r.selectedPlayer&&e.jsxs("div",{className:"player-name-row",children:[e.jsx("span",{className:"player-name",children:r.name}),e.jsx("button",{className:"add-player-btn",onClick:()=>Fe(s.sortOrder,y,r.name),title:"Create new player",children:"+"})]}),r.selectedPlayer&&e.jsxs("div",{className:"selected-player-box",children:[e.jsx(C,{name:"check",size:14}),e.jsx("span",{className:"selected-player-name",children:r.selectedPlayer.playerName})]}),!r.selectedPlayer&&(((k=(N=r.playerMatches)==null?void 0:N.exact)==null?void 0:k.length)>0||((E=(v=r.playerMatches)==null?void 0:v.fuzzy)==null?void 0:E.length)>0)&&e.jsx("div",{className:"player-matches-list",children:[...((T=r.playerMatches)==null?void 0:T.exact)||[],...((P=r.playerMatches)==null?void 0:P.fuzzy)||[]].slice(0,5).map((b,i)=>{var f,j,z;const n=(j=(f=r.playerMatches)==null?void 0:f.exact)==null?void 0:j.some(u=>u.playerId===b.playerId);return e.jsxs("div",{className:`match-option ${n?"exact":"fuzzy"}`,onClick:()=>we(s.sortOrder,y,b.playerId),children:[e.jsx("span",{className:"match-name",children:b.playerName}),((z=b.teams)==null?void 0:z.length)>0&&e.jsx("div",{className:"match-teams",children:(b.playerName.toLowerCase().includes("realmuto")&&
1console.log(`🔍 Frontend Debug - ${b.playerName} teams:`,b.teams),b.teams.map(u=>{var I,S;return e.jsx("div",{className:"mini-team-circle",style:{"--primary-color":u.primaryColor||"#666","--secondary-color":u.secondaryColor||"#999"},title:`${u.teamName} (Player ID: ${b.playerId})`,children:u.abbreviation||((S=(I=u.teamName)==null?void 0:I.substring(0,3))==null?void 0:S.toUpperCase())},u.teamId)}))})]},b.playerId)})})]},`${y}-${r._renderKey||0}`)})})}),e.jsx("td",{className:"team-cell",children:e.jsx("div",{className:"import-team-validation",children:(t=s.teamNames)==null?void 0:t.map((r,y)=>{var T,P,b,i;const N=n=>n.normalize("NFD").replace(/[\u0300-\u036f]/g,""),k=N(r.toLowerCase()),v=(P=(T=s.teamMatches)==null?void 0:T.exact)==null?void 0:P.find(n=>N(n.teamName.toLowerCase()).includes(k)),E=(i=(b=s.teamMatches)==null?void 0:b.fuzzy)==null?void 0:i.some(n=>N(n.teamName.toLowerCase()).includes(k));if(v)return e.jsxs("div",{className:"team-status found",children:["✓ ",v.teamName]},y);if(E){const n=s.teamMatches.fuzzy.filter(f=>N(f.teamName.toLowerCase()).includes(k));return e.jsxs("div",{className:"team-match-container",children:[e.jsxs("div",{className:"team-status not-found",children:["✗ ",r,e.jsx("button",{className:"inline-create-team-button",onClick:()=>Pe(a,null,y,r),children:"+ Create"})]}),e.jsx("div",{className:"fuzzy-team-suggestions",children:n.slice(0,3).map(f=>{var j,z;return e.jsxs("div",{className:"fuzzy-team-option",onClick:async()=>{var Q;const u=[...m];u[a].teamNames[y]=f.teamName,u[a].teamMatches.exact.push(f),u[a].teamMatches.fuzzy=u[a].teamMatches.fuzzy.filter(d=>d.teamId!==f.teamId);const I=u[a],S=[];(Q=I.players)==null||Q.forEach((d,L)=>{var g;if(d.selectedPlayer){const J=d.selectedPlayer.playerId,W=f.teamId;if(!((g=d.playerTeamMatches)==null?void 0:g.some(ie=>ie.playerId===J&&ie.teamId===W))){const ie=B.post("/api/admin/import/create-player-team",{playerId:J,teamId:W}).then(K=>{if(K.data.success)return d.playerTeamMatches||(d.playerTeamMatches=[]),d.selectedPlayerTeams||(d.selectedPlayerTeams=[]),d.playerTeamMatches.push(K.data.playerTeam),d.selectedPlayerTeams.push(K.data.playerTeam),K.data.playerTeam}).catch(K=>{var H,Ce,be;if((be=(Ce=(H=K.response)==null?void 0:H.data)==null?void 0:Ce.message)!=null&&be.includes("already exists")){const ye={playerTeamId:`existing_${J}_${W}`,playerId:J,teamId:W,playerName:d.selectedPlayer.playerName,teamName:f.teamName};return d.playerTeamMatches||(d.playerTeamMatches=[]),d.selectedPlayerTeams||(d.selectedPlayerTeams=[]),d.playerTeamMatches.push(ye),d.selectedPlayerTeams.push(ye),ye}return null});S.push(ie)}}}),S.length>0&&await Promise.all(S),h(u)},title:`Select ${f.teamName}`,style:{"--primary-color":f.primaryColor||"#666","--secondary-color":f.secondaryColor||"#999"},children:[e.jsx("div",{className:"mini-team-circle",children:f.abbreviation||((z=(j=f.teamName)==null?void 0:j.substring(0,3))==null?void 0:z.toUpperCase())}),e.jsx("span",{className:"team-name-text",children:f.teamName})]},f.teamId)})})]},y)}return e.jsxs("div",{className:"team-status not-found",children:["✗ ",r,e.jsx("button",{className:"inline-create-team-button",onClick:()=>Pe(a,null,y,r),children:"+ Create"})]},y)})})}),e.jsx("td",{className:"rc-cell",children:e.jsx("button",{className:`import-rc-toggle ${s.isRC?"active":""}`,onClick:()=>$e(s.sortOrder),children:s.isRC?"RC":"—"})}),e.jsx("td",{className:"auto-cell",children:e.jsx("button",{className:`import-auto-toggle ${s.isAutograph?"active":""}`,onClick:()=>Me(s.sortOrder),children:s.isAutograph?"AUTO":"—"})}),e.jsx("td",{className:"relic-cell",children:e.jsx("button",{className:`import-relic-toggle ${s.isRelic?"active":""}`,onClick:()=>ze(s.sortOrder),children:s.isRelic?"RELIC":"—"})}),e.jsx("td",{className:"sp-cell",children:e.jsx("button",{className:`import-sp-toggle ${s.isShortPrint?"active":""}`,onClick:()=>Ae(s.sortOrder),children:s.isShortPrint?"SP":"—"})}),e.jsx("td",{className:"print-run-cell",children:e.jsx("input",{type:"number",className:"import-print-run-input",value:s.printRun||"",onChange:r=>he(s.sortOrder,r.target.value),placeholder:"—",min:"1",tabIndex:1e3+a})}),e.jsx("td",{className:"color-cell",children:e.jsxs("div",{className:"import-color-dropdown",ref:re===s.sortOrder?Ne:null,children:[e.jsxs("button",{className:"import-color-trigger",onClick:()=>pe(re===s.sortOrder?null:s.sortOrder),type:"button",children:[s.colorId?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"import-color-dot",style:{backgroundColor:((o=ee.find(r=>r.color_id===s.colorId))==null?void 0:o.hex_value)||"#666"}}),e.jsx("span",{className:"import-color-name",children:((c=ee.find(r=>r.color_id===s.colorId))==null?void 0:c.name)||"—"})]}):e.jsx("span",{className:"import-color-placeholder",children:"—"}),e.jsx(C,{name:"chevron-down",size:12,className:"import-color-chevron"})]}),re===s.sortOrder&&e.jsxs("div",{className:"import-color-dropdown-menu",children:[e.jsx("div",{className:"import-color-option",onClick:()=>{ge(s.sortOrder,""),pe(null)},children:e.jsx("span",{className:"import-color-option-label",children:"No Color"})}),ee.map(r=>e.jsxs("div",{className:`import-color-option ${s.colorId===r.color_id?"selected":""}`,onClick:()=>{ge(s.sortOrder,r.color_id),pe(null)},children:[e.jsx("span",{className:"import-color-dot",style:{backgroundColor:r.hex_value||"#666"}}),e.jsx("span",{className:"import-color-option-label",children:r.name}),s.colorId===r.color_id&&e.jsx(C,{name:"check",size:14,className:"import-color-check"})]},r.color_id))]})]})}),e.jsx("td",{className:"player-team-combo-cell",children:e.jsx("div",{className:"player-team-combos",children:(s.players||[]).map((r,y)=>{var E,T,P,b;if(a===0&&console.log(`🔍 Player ${y} (${r.name}):`,{selectedPlayer:r.selectedPlayer,playerTeamCheckTeams:r.playerTeamCheckTeams,playerTeamMatches:r.playerTeamMatches,cardTeam
1s:(E=s.teamMatches)==null?void 0:E.exact}),!r.selectedPlayer)return e.jsx("div",{className:"incomplete-combo",children:"-"},y);const k=(((P=(T=r.playerTeamCheckTeams)==null?void 0:T.exact)==null?void 0:P.length)>0?r.playerTeamCheckTeams.exact:((b=s.teamMatches)==null?void 0:b.exact)||[]).filter((i,n,f)=>n===f.findIndex(j=>j.teamId===i.teamId));if(k.length===0)return e.jsx("div",{className:"incomplete-combo",children:"-"},y);const v=k.map(i=>{var f,j,z,u,I;return((f=r.playerTeamMatches)==null?void 0:f.some(S=>S.playerId===r.selectedPlayer.playerId&&S.teamId===i.teamId))?e.jsxs("div",{className:"player-team-exists",children:[e.jsx("span",{className:"pt-player-name",children:r.selectedPlayer.playerName}),e.jsx("div",{className:"mini-team-circle",style:{"--primary-color":i.primaryColor||"#666","--secondary-color":i.secondaryColor||"#999"},title:`${i.teamName} (Player ID: ${r.selectedPlayer.playerId})`,children:i.abbreviation||((z=(j=i.teamName)==null?void 0:j.substring(0,3))==null?void 0:z.toUpperCase())})]},`${y}-${i.teamId}`):e.jsxs("button",{className:"player-team-recommendation",onClick:async()=>{var S,Q;try{const d=await B.post("/api/admin/import/create-player-team",{playerId:r.selectedPlayer.playerId,teamId:i.teamId});if(d.data.success){const L=d.data.playerTeam;l&&l(`Created player-team: ${r.selectedPlayer.playerName} - ${i.teamName}`,"success");const g=[...m];let J=0;g.forEach((W,Z)=>{var ie;(ie=W.players)==null||ie.forEach((K,H)=>{var Ce,be,ye,De,qe;if(((Ce=K.selectedPlayer)==null?void 0:Ce.playerId)===r.selectedPlayer.playerId){const Qe=(ye=(be=K.playerTeamCheckTeams)==null?void 0:be.exact)==null?void 0:ye.some(fe=>fe.teamId===i.teamId),Xe=(De=K.playerTeamMatches)==null?void 0:De.some(fe=>fe.playerId===r.selectedPlayer.playerId&&fe.teamId===i.teamId);if(Qe&&!Xe){console.log(`🔄 Adding player_team for "${K.selectedPlayer.playerName}" - "${i.teamName}" on card ${W.sortOrder}`),g[Z].players[H].playerTeamMatches||(g[Z].players[H].playerTeamMatches=[]),g[Z].players[H].playerTeamMatches.push(L),g[Z].players[H].selectedPlayerTeams||(g[Z].players[H].selectedPlayerTeams=[]),g[Z].players[H].selectedPlayerTeams.push(L);const fe=((qe=g[Z].players[H].playerTeamCheckTeams)==null?void 0:qe.exact)||[];g[Z].players[H].playerTeamCheckTeams={exact:fe.filter(Ye=>g[Z].players[H].playerTeamMatches.some(Ge=>Ge.teamId===Ye.teamId)),fuzzy:[]},J++}}})}),console.log(`🎯 Updated ${J} instances of player-team "${r.selectedPlayer.playerName}" - "${i.teamName}" across all cards`),h(g)}}catch(d){console.error("Error creating player_team:",d),l&&l(((Q=(S=d.response)==null?void 0:S.data)==null?void 0:Q.message)||"Failed to create player-team","error")}},title:`Create player-team: ${r.selectedPlayer.playerName} - ${i.teamName} (Player ID: ${r.selectedPlayer.playerId})`,children:[e.jsx("span",{className:"pt-plus",children:"+"}),e.jsx("span",{className:"pt-player-name",children:r.selectedPlayer.playerName}),e.jsx("div",{className:"mini-team-circle",style:{"--primary-color":i.primaryColor||"#666","--secondary-color":i.secondaryColor||"#999"},title:`${i.teamName} (Player ID: ${r.selectedPlayer.playerId})`,children:i.abbreviation||((I=(u=i.teamName)==null?void 0:u.substring(0,3))==null?void 0:I.toUpperCase())})]},`${y}-${i.teamId}`)});return e.jsx("div",{className:"player-team-results",children:v},y)})})}),e.jsx("td",{className:"notes-cell",children:e.jsx("input",{type:"text",className:"import-notes-input",value:s.notes||"",onChange:r=>ke(a,r.target.value),placeholder:"Add notes...",tabIndex:2e3+a})})]})},a)})})]})}),e.jsxs("div",{className:"import-table-footer",children:[e.jsxs("div",{className:"import-table-info",children:["Showing ",oe.length," of ",m.length," cards for import",w&&` (filtered by "${w}")`]}),e.jsx("div",{className:"import-table-stats",children:(()=>{let s=0,a=0;return oe.forEach(t=>{Se(t)?a++:s++}),e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"import-stat-ready",children:[s," Ready"]}),a>0&&e.jsxs("span",{className:"import-stat-needs-work import-stat-clickable",onClick:_e,title:"Click to scroll to first card that needs attention",children:[a," Need Work"]})]})})()})]})]})},Ze=({series:m,onSelect:$,placeholder:h,selectedSeries:F,onSearch:M})=>{const[w,_]=p.useState(""),[X,l]=p.useState(!1),[R,V]=p.useState(-1),O=p.useRef(null),ae=p.useRef(null),U=p.useRef(null);p.useEffect(()=>(w.trim()&&M&&(U.current&&clearTimeout(U.current),U.current=setTimeout(()=>{M(w.trim())},300)),()=>{U.current&&clearTimeout(U.current)}),[w,M]);const D=(m||[]).filter(x=>x.name&&x.name.toLowerCase().includes(w.toLowerCase())||x.set_name&&x.set_name.toLowerCase().includes(w.toLowerCase())||x.year&&x.year.toString().includes(w)),ee=x=>{if(!X&&x.key==="Enter"){l(!0);return}if(X)switch(x.key){case"ArrowDown":x.preventDefault(),V(A=>A<(D||[]).length-1?A+1:A);break;case"ArrowUp":x.preventDefault(),V(A=>A>0?A-1:-1);break;case"Enter":x.preventDefault(),R>=0&&D[R]&&($(D[R]),l(!1),_(""));break;case"Escape":l(!1),V(-1);break}},te=x=>{$(x),l(!1),_(""),V(-1)},ne=()=>{$(null),_(""),l(!1),V(-1)};return p.useEffect(()=>{X&&O.current&&O.current.focus()},[X]),p.useEffect(()=>{const x=A=>{ae.current&&!ae.current.contains(A.target)&&(l(!1),V(-1))};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[]),e.jsxs("div",{className:"searchable-dropdown",ref:ae,children:[e.jsxs("div",{className:"dropdown-input-wrapper",children:[e.jsx("input",{ref:O,type:"text",className:"dropdown-search-input",value:F&&!X?`${F.name} (${F.set_name})`:w,onChange:x=>_(x.target.value),onFocus:()=>
1{l(!0),F&&!w&&_("")},onKeyDown:ee,placeholder:F?`${F.name} (${F.set_name})`:h}),F&&!X&&e.jsx(C,{name:"x",size:16,className:"dropdown-clear-icon",onClick:ne,title:"Clear selection"})]}),X&&e.jsx("div",{className:"dropdown-menu",children:D.length===0?e.jsxs("div",{className:"dropdown-no-results",children:['No series found matching "',w,'"']}):e.jsx("div",{className:"dropdown-results",children:D.map((x,A)=>e.jsxs("div",{className:`dropdown-item ${A===R?"selected":""}`,onClick:()=>te(x),onMouseEnter:()=>V(A),children:[e.jsx("div",{className:"dropdown-item-primary",children:x.name||"Unknown Series"}),e.jsxs("div",{className:"dropdown-item-secondary",children:[x.set_name||"Unknown Set"," ",x.year?`(${x.year})`:""," • ",x.card_count||0," cards"]})]},x.series_id))})})]})},es=()=>{const{user:m}=Ve(),{addToast:$}=Be(),h=We(),[F]=Ke(),[M,w]=p.useState(1),[_,X]=p.useState([]),[l,R]=p.useState(null),[V,O]=p.useState(!0),[ae,U]=p.useState(null),[D,ee]=p.useState(null),[te,ne]=p.useState(!1),[x,A]=p.useState(""),[de,me]=p.useState("paste"),[Oe,xe]=p.useState([]),[se,Y]=p.useState([]),[G,re]=p.useState(!1),[pe,Ne]=p.useState(""),[q,ke]=p.useState({total:0,processed:0,status:null,currentCard:null}),[he,ge]=p.useState(!1),[ue,Ie]=p.useState(""),[le,oe]=p.useState(!1);if(!m||!["admin","superadmin"].includes(m.role))return e.jsx("div",{className:"admin-import-page",children:e.jsxs("div",{className:"access-denied",children:[e.jsx(C,{name:"lock",size:48}),e.jsx("h2",{children:"Access Denied"}),e.jsx("p",{children:"Admin privileges required to access this page."})]})});p.useEffect(()=>{ce()},[]),p.useEffect(()=>{const s=F.get("series");if(s&&!l){const a=parseInt(s),t=_.find(o=>o.series_id===a);t?(R(t),w(2),console.log("Auto-selected series from URL and advanced to Step 2:",t.name)):_.length>0&&ce("",a)}},[F,_,l]),p.useEffect(()=>{M===4&&!ue&&!le&&se.length>0&&Te()},[M,ue,le,se.length]),p.useEffect(()=>{if(l){const s={1:"Select Series",2:"Upload File",3:"Review Cards",4:"Import"};document.title=`Admin Import: ${s[M]} - ${l.name} - Collect Your Cards`}else document.title="Admin Import Card Checklist - Collect Your Cards"},[M,l]);const ce=async(s="",a=null)=>{try{let t="/api/admin/series";const o=new URLSearchParams;a?o.append("series_id",a):s&&o.append("search",s),o.toString()&&(t+="?"+o.toString());const c=await B.get(t);X(c.data.series||[])}catch(t){console.error("Error loading series:",t),$("Failed to load series","error")}finally{O(!1)}},$e=s=>{R(s),w(2)},Me=s=>{const a=s.target.files[0];if(a){if(!a.name.toLowerCase().endsWith(".xlsx")){$("Please select an XLSX file","error");return}ee(a)}},ze=async()=>{var s,a,t,o;if(!(!x.trim()||!l))try{ne(!0),console.log("📋 Processing pasted data..."),console.log("Series:",l.name,"ID:",l.series_id);const c=await B.post("/api/admin/import/parse-pasted",{data:x,seriesId:l.series_id});console.log("📥 API Response:",c.data),console.log("Cards found:",((s=c.data.cards)==null?void 0:s.length)||0),xe(c.data.cards),w(3),c.data.cards&&c.data.cards.length>0?(console.log("🔍 Starting card matching..."),await ve(c.data.cards)):console.log("⚠️ No cards to match")}catch(c){console.error("❌ Error processing pasted data:",c),console.error("Error response:",(a=c.response)==null?void 0:a.data),$(((o=(t=c.response)==null?void 0:t.data)==null?void 0:o.message)||"Failed to process pasted data","error")}finally{ne(!1)}},Ae=async()=>{var s,a,t,o;if(!(!D||!l))try{ne(!0),console.log("📤 Starting file upload..."),console.log("File:",D.name,D.size,"bytes"),console.log("Series:",l.name,"ID:",l.series_id);const c=new FormData;c.append("xlsx",D),c.append("seriesId",l.series_id),console.log("📡 Sending API request...");const r=await B.post("/api/admin/import/parse-xlsx",c,{headers:{"Content-Type":"multipart/form-data"}});console.log("📥 API Response:",r.data),console.log("Cards found:",((s=r.data.cards)==null?void 0:s.length)||0),xe(r.data.cards),w(3),r.data.cards&&r.data.cards.length>0?(console.log("🔍 Starting card matching..."),await ve(r.data.cards)):console.log("⚠️ No cards to match")}catch(c){console.error("❌ Error uploading file:",c),console.error("Error response:",(a=c.response)==null?void 0:a.data),$(((o=(t=c.response)==null?void 0:t.data)==null?void 0:o.message)||"Failed to upload file","error")}finally{ne(!1)}},ve=async s=>{try{re(!0),console.log("🚀 Starting card matching process...");const a=await B.post("/api/admin/import/match-cards",{cards:s,seriesId:l.series_id});a.data.jobId&&(console.log(`📊 Starting progress tracking for job: ${a.data.jobId}`),await Le(a.data.jobId)),a.data.organizationId&&(U(a.data.organizationId),console.log(`🏢 Organization ID: ${a.data.organizationId} (${a.data.organizationName})`)),Y(a.data.matchedCards)}catch(a){console.error("Error matching cards:",a),$("Failed to match cards with database","error")}finally{re(!1)}},Le=async s=>{let a=0;const t=120,o=async()=>{try{const r=(await B.get(`/api/admin/import/match-progress/${s}`)).data;if(console.log(`📊 Progress: ${r.processed}/${r.total} - ${r.status}`),ke({total:r.total,processed:r.processed,status:r.status,currentCard:r.currentCard}),r.currentCard&&console.log(`   Current: ${r.currentCard}`),r.status==="completed"||r.status==="error"){console.log("✅ Matching completed");return}a++,a<t&&setTimeout(o,1e3)}catch(c){console.error("Error checking progress:",c)}};o()},Re=s=>{Y(s)},Te=async()=>{var s,a;try{oe(!0);const t=await B.post("/api/admin/import/preview-sql",{matchedCards:se,seriesId:l.series_id});Ie(t.data.sql)}catch(t){console.error("Error generating SQL preview:",t),$(((a=(s=t.response)==null?void 0:s.data)==null?void 0:a.message)||"Failed to generate SQL preview","error")}finally{oe(!1)}},Ee=async()=>{try{await navigator.clipboard.writeText(ue),$&&$("SQL copied to clipboard!","success")}catch(s){console.error("Failed to copy SQL:",s),$&&$("Failed to copy SQL to clipboard","error")}},we=async()=>{var s,a;try{ge(!0);const t=await B.post("/api/admin/import/create-cards",{matchedCards:se,seriesId:l.series_id});$(`Successfully imported ${t.data.created} cards!`,"success"),setTimeout(()=>{h(`/admin/cards?series=${l.series_id}`)},1500)}catch(t){console.error("Error importing cards:",t),$(((a=(s=t.response)==null?void 0:s.data)==null?void 0:a.message)||"Failed to import cards","error")}finally{ge(!1)}},Fe=()=>e.jsxs("div",{className:"step-indicator",children:[e.jsxs("div",{className:`step ${M>=1?"completed":""}`,children:[e.jsx("div",{className:"step-number",children:"1"}),e.jsx("div",{className:"step-label",children:"Select Series"})]}),e.jsxs("div",{className:`step ${M>=2?"completed":""}`,children:[e.jsx("div",{className:"step-number",children:"2"}),e.jsx("div",{className:"step-label",children:"Upload File"})]}),e.jsxs("div",{className:`step ${M>=3?"completed":""}`,children:[e.jsx("div",{className:"step-number",children:"3"}),e.jsx("div",{className:"step-label",children:"Review & Match"})]}),e.jsxs("div",{className:`step ${M>=4?"completed":""}`,children:[e.jsx("div",{className:"step-number",children:"4"}),e.jsx("div",{className:"step-label",children:"Import"})]})]}),Pe=()=>e.jsxs("div",{className:"step-content",children:[e.jsx("h2",{children:"Step 1: Select Series"}),e.jsx("p",{children:"Choose the series that this card checklist belongs to:"}),V?e.jsxs("div",{className:"loading-state",children:[e.jsx(C,{name:"loader",size:24,className:"spinner"}),e.jsx("span",{children:"Loading series..."})]}):e.jsx(Ze,{series:_,onSelect:$e,placeholder:"Search for a series...",selectedSeries:l,onSearch:s=>ce(s)})]}),Se=()=>e.jsxs("div",{className:"step-content",children:[e.jsx("h2",{children:"Step 2: Import Card Data"}),e.jsxs("p",{children:["Selected Series: ",e.jsx("strong",{children:l==null?void 0:l.name})," (",l==null?void 0:l.set_name," ",l==null?void 0:l.year,")"]}),e.jsxs("div",{className:"input-method-toggle",children:[e.jsxs("button",{className:`method-btn ${de==="file"?"active":""}`,onClick:()=>me("file"),children:[e.jsx(C,{name:"upload",size:16}),"Upload File"]}),e.jsxs("button",{className:`method-btn ${de==="paste"?"active":""}`,onClick:()=>me("paste"),children:[e.jsx(C,{name:"clipboard",size:16}),"Paste Data"]})]}),e.jsxs("div",{className:"upload-section",children:[e.jsxs("div",{className:"file-requirements",children:[e.jsx("h3",{children:"Data Requirements:"}),e.jsx("ul",{children:de==="file"?e.jsxs(e.Fragment,{children:[e.jsx("li",{children:"XLSX format only"}),e.jsx("li",{children:"5 columns: Card Number, Player Name(s), Team Name(s), RC Indicator, Notes"}),e.jsx("li",{children:"First row should contain headers"})]}):e.jsxs(e.Fragment,{children:[e.jsx("li",{children:"Tab-separated data (from Excel, Google Sheets, etc.)"}),e.jsx("li",{children:"5 columns: Card Number, Player Name(s), Team Name(s), RC Indicator, Notes"}),e.jsx("li",{children:"First row should contain headers (will be ignored)"})]})})]}),de==="file"?e.jsxs("div",{className:"file-input-section",children:[e.jsx("input",{type:"file",id:"xlsx-upload",accept:".xlsx",onChange:Me,style:{display:"none"}}),e.jsxs("label",{htmlFor:"xlsx-upload",className:"file-upload-label",children:[e.jsx(C,{name:"upload",size:24}),D?D.name:"Choose XLSX File"]}),D&&e.jsx("div",{className:"file-actions",children:e.jsx("button",{className:"upload-btn",onClick:Ae,disabled:te,children:te?e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"loader",size:16,className:"spinner"}),"Processing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"check",size:16}),"Process File"]})})})]}):e.jsxs("div",{className:"paste-input-section",children:[e.jsx("textarea",{className:"paste-textarea",placeholder:`Paste your card checklist data here (tab-separated)
2
3Example:
4BR-1    Shohei Ohtani    Los Angeles Dodgers
5BR-2    Ronald Acuña Jr.    Atlanta Braves
6BR-3    Juan Soto    New York Mets`,value:x,onChange:s=>A(s.target.value),rows:15}),x.trim()&&e.jsx("div",{className:"file-actions",children:e.jsx("button",{className:"upload-btn",onClick:ze,disabled:te,children:te?e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"loader",size:16,className:"spinner"}),"Processing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"check",size:16}),"Process Data (",x.trim().split(`
7`).length," rows)"]})})})]})]}),e.jsx("div",{className:"step-actions",children:e.jsxs("button",{className:"back-btn",onClick:()=>w(1),children:[e.jsx(C,{name:"arrow-left",size:16}),"Back to Series Selection"]})})]}),_e=()=>e.jsxs("div",{className:"step-content",children:[e.jsx("h2",{children:"Step 3: Review Parsed Cards"}),e.jsx("p",{children:"Review the imported cards and verify player/team matches:"}),G?e.jsxs("div",{className:"processing-state",children:[e.jsx(C,{name:"loader",size:24,className:"spinner"}),e.jsxs("div",{className:"progress-info",children:[e.jsx("h3",{children:"Matching cards with database..."}),q.total>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"progress-bar-container",children:[e.jsx("div",{className:"progress-bar",children:e.jsx("div",{className:"progress-bar-fill",style:{width:`${q.processed/q.total*100}%`}})}),e.jsxs("div",{className:"progress-text",children:[q.processed," / ",q.total," cards processed",q.total>0&&e.jsxs("span",{className:"progress-percentage",children:["(",Math.round(q.processed/q.total*100),"%)"]})]})]}),q.currentCard&&e.jsxs("div",{className:"current-card-info",children:["Currently processing: ",q.currentCard]})]})]})]}):e.jsx(Je,{cards:se||[],loading:!1,onCardUpdate:Re,showSearch:!0,searchQuery:pe,onSearchChange:Ne,maxHeight:"500px",organizationId:ae}),e.jsxs("div",{className:"step-actions",children:[e.jsxs("button",{className:"back-btn",onClick:()=>w(2),children:[e.jsx(C,{name:"arrow-left",size:16}),"Back to Upload"]}),!G&&(se||[]).length>0&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"preview-sql-btn",onClick:async()=>{await Te(),w(4)},disabled:le,children:le?e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"loader",size:16,className:"spinner"}),"Generating SQL..."]}):e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"code",size:16}),"Preview SQL"]})}),e.jsx("button",{className:"import-btn",onClick:we,disabled:he,children:he?e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"loader",size:16,className:"spinner"}),"Importing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"database",size:16}),"Import Cards"]})})]})]})]}),je=()=>e.jsxs("div",{className:"step-content full-screen-sql",children:[e.jsx("h2",{children:"Step 4: SQL Preview - Ready to Import"}),e.jsxs("div",{className:"sql-preview-info",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"⚠️ COPY AND PASTE THIS SQL:"})," This is the exact SQL to import your cards. Copy and paste this into your SQL query tool to execute manually."]}),e.jsxs("div",{className:"sql-stats",children:[e.jsxs("span",{children:["Series: ",l==null?void 0:l.name]}),e.jsxs("span",{children:[(se||[]).length," cards"]}
7),e.jsxs("span",{children:["Generated: ",new Date().toLocaleString()]})]})]}),le?e.jsxs("div",{className:"sql-loading",children:[e.jsx(C,{name:"loader",size:32,className:"spinner"}),e.jsx("p",{children:"Generating SQL statements..."})]}):e.jsxs("div",{className:"sql-display-container",children:[e.jsxs("div",{className:"sql-display-header",children:[e.jsxs("h3",{children:[e.jsx(C,{name:"code",size:20}),"Import SQL"]}),e.jsxs("button",{className:"copy-sql-btn",onClick:Ee,children:[e.jsx(C,{name:"copy",size:16}),"Copy SQL to Clipboard"]})]}),e.jsx("div",{className:"sql-display-content",children:e.jsx("textarea",{className:"sql-display-text",value:ue,readOnly:!0,spellCheck:!1})})]}),e.jsxs("div",{className:"step-actions",children:[e.jsxs("button",{className:"back-btn",onClick:()=>w(3),children:[e.jsx(C,{name:"arrow-left",size:16}),"Back to Review"]}),e.jsx("button",{className:"import-btn",onClick:we,disabled:he,children:he?e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"loader",size:16,className:"spinner"}),"Importing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"database",size:16}),"Import to Database"]})})]})]});return e.jsxs("div",{className:"admin-import-page",children:[e.jsxs("div",{className:"import-header",children:[e.jsx("h1",{children:"Import Card Checklist"}),e.jsx("p",{children:"Import cards from XLSX spreadsheets with automatic player/team matching"})]}),Fe(),e.jsxs("div",{className:"import-content",children:[M===1&&Pe(),M===2&&Se(),M===3&&_e(),M===4&&je()]})]})};export{es as default};
8//# sourceMappingURL=AdminImport-rUa0BbRA.js.map

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.