exports.id=855,exports.ids=[855],exports.modules={182:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{A:()=>k});var e=c(8732),f=c(2015),g=c(8462),h=c(6659),i=c(3622),j=a([g,h,i]);[g,h,i]=j.then?(await j)():j;let k=()=>{let a=(0,g.useQueryClient)(),[b,c]=(0,f.useState)(!1),[d,j]=(0,f.useState)(null),[k,l]=(0,f.useState)({search:"",game:"",isFavorite:!1}),[m,n]=(0,f.useState)("grid"),{data:o=[],isLoading:p}=(0,g.useQuery)({queryKey:["collections",k],queryFn:()=>h.LO.collections.getCollections(k)}),q=(0,g.useMutation)({mutationFn:h.LO.collections.deleteCollection,onSuccess:()=>{a.invalidateQueries({queryKey:["collections"]})}}),r=(0,g.useMutation)({mutationFn:({id:a,isFavorite:b})=>h.LO.collections.updateCollection(a,{isFavorite:b}),onSuccess:()=>{a.invalidateQueries({queryKey:["collections"]})}}),s=o.filter(a=>{let b=!k.search||a.name.toLowerCase().includes(k.search.toLowerCase())||a.description?.toLowerCase().includes(k.search.toLowerCase()),c=!k.game||a.game===k.game,d=!k.isFavorite||a.isFavorite;return b&&c&&d});return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h1",{className:"text-2xl font-bold text-surface-900 dark:text-white",children:"Collections"}),(0,e.jsx)("p",{className:"text-surface-600 dark:text-surface-400 mt-1",children:"Organize and manage your card collections"})]}),(0,e.jsxs)("button",{onClick:()=>c(!0),className:"bg-gradient-to-r from-primary-500 to-accent-500 hover:from-primary-600 hover:to-accent-600 text-white px-4 py-2 rounded-xl font-medium transition-all duration-200 shadow-md hover:shadow-lg transform hover:-translate-y-0.5",children:[(0,e.jsx)("svg",{className:"w-4 h-4 mr-2 inline",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),"New Collection"]})]}),(0,e.jsx)("div",{className:"bg-white dark:bg-surface-800 rounded-xl border border-surface-200 dark:border-surface-700 p-4",children:(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:(0,e.jsx)("svg",{className:"h-5 w-5 text-surface-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),(0,e.jsx)("input",{type:"text",value:k.search,onChange:a=>l(b=>({...b,search:a.target.value})),placeholder:"Search collections...",className:"w-full pl-10 pr-4 py-3 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-xl text-surface-900 dark:text-white placeholder-surface-500 dark:placeholder-surface-400 focus:outline-none focus:ring-2 focus:ring-primary-500 transition-colors"})]}),(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"flex space-x-2 overflow-x-auto pb-2",children:[(0,e.jsxs)("select",{value:k.game,onChange:a=>l(b=>({...b,game:a.target.value})),className:"px-3 py-2 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-primary-500 transition-colors whitespace-nowrap",children:[(0,e.jsx)("option",{value:"",children:"All Games"}),(0,e.jsx)("option",{value:"MTG",children:"Magic: The Gathering"}),(0,e.jsx)("option",{value:"POKEMON",children:"Pok\xe9mon"}),(0,e.jsx)("option",{value:"LORCANA",children:"Disney Lorcana"}),(0,e.jsx)("option",{value:"YUGIOH",children:"Yu-Gi-Oh!"}),(0,e.jsx)("option",{value:"OTHER",children:"Other"})]}),(0,e.jsx)("button",{onClick:()=>l(a=>({...a,isFavorite:!a.isFavorite})),className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors whitespace-nowrap ${k.isFavorite?"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300":"bg-surface-50 dark:bg-surface-700 text-surface-700 dark:text-surface-300 border border-surface-300 dark:border-surface-600"}`,children:"⭐ Favorites"})]}),(0,e.jsxs)("div",{className:"flex bg-surface-100 dark:bg-surface-700 rounded-lg p-1",children:[(0,e.jsx)("button",{onClick:()=>n("grid"),className:`p-2 rounded-md transition-colors ${"grid"===m?"bg-white dark:bg-surface-600 text-surface-900 dark:text-white shadow-sm":"text-surface-600 dark:text-surface-400 hover:text-surface-900 dark:hover:text-white"}`,children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zM14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6zM4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zM14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z"})})}),(0,e.jsx)("button",{onClick:()=>n("list"),className:`p-2 rounded-md transition-colors ${"list"===m?"bg-white dark:bg-surface-600 text-surface-900 dark:text-white shadow-sm":"text-surface-600 dark:text-surface-400 hover:text-surface-900 dark:hover:text-white"}`,children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 10h16M4 14h16M4 18h16"})})})]})]})]})}),p?(0,e.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,e.jsxs)("div",{className:"flex flex-col items-center",children:[(0,e.jsx)("div",{className:"w-8 h-8 bg-gradient-to-r from-primary-500 to-accent-500 rounded-full flex items-center justify-center animate-bounce-subtle mb-3",children:(0,e.jsx)("svg",{className:"w-4 h-4 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:(0,e.jsx)("path",{d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),(0,e.jsx)("p",{className:"text-surface-600 dark:text-surface-400 text-sm",children:"Loading collections..."})]})}):0===s.length?(0,e.jsx)("div",{className:"bg-white dark:bg-surface-800 rounded-xl border border-surface-200 dark:border-surface-700 p-8",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("div",{className:"w-16 h-16 bg-surface-100 dark:bg-surface-700 rounded-2xl flex items-center justify-center mx-auto mb-6",children:(0,e.jsx)("svg",{className:"w-8 h-8 text-surface-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),(0,e.jsx)("h3",{className:"text-xl font-semibold text-surface-900 dark:text-white mb-2",children:0===o.length?"No collections yet":"No matching collections"}),(0,e.jsx)("p",{className:"text-surface-600 dark:text-surface-400 mb-6",children:0===o.length?"Create your first collection to start organizing your cards":"Try adjusting your search or filters"}),0===o.length&&(0,e.jsx)("button",{onClick:()=>c(!0),className:"bg-gradient-to-r from-primary-500 to-accent-500 hover:from-primary-600 hover:to-accent-600 text-white px-6 py-3 rounded-xl font-medium transition-all duration-200 shadow-md hover:shadow-lg transform hover:-translate-y-0.5",children:"Create Collection"})]})}):(0,e.jsx)("div",{className:"grid"===m?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4":"space-y-4",children:s.map(a=>(0,e.jsxs)("div",{className:"bg-white dark:bg-surface-800 rounded-xl border border-surface-200 dark:border-surface-700 p-4 transition-all duration-200 hover:shadow-md",children:[(0,e.jsxs)("div",{className:"flex items-start justify-between mb-4",children:[(0,e.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,e.jsx)("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center text-white text-xl font-semibold shadow-md",style:{backgroundColor:a.color||"#8b5cf6"},children:a.icon||"\uD83D\uDCDA"}),(0,e.jsxs)("div",{className:"flex-1",children:[(0,e.jsx)("h3",{className:"font-semibold text-surface-900 dark:text-white",children:a.name}),a.description&&(0,e.jsx)("p",{className:"text-sm text-surface-600 dark:text-surface-400 line-clamp-2",children:a.description})]})]}),(0,e.jsx)("button",{onClick:()=>(a=>{r.mutate({id:a.id,isFavorite:!a.isFavorite})})(a),className:`p-2 rounded-lg transition-colors ${a.isFavorite?"text-yellow-500 hover:text-yellow-600":"text-surface-400 hover:text-yellow-500"}`,children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:a.isFavorite?"currentColor":"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"})})})]}),(0,e.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,e.jsxs)("div",{className:"flex items-center space-x-4 text-sm text-surface-600 dark:text-surface-400",children:[(0,e.jsxs)("span",{children:[a.cardCount||0," cards"]}),a.totalValue&&(0,e.jsxs)("span",{className:"text-green-600 dark:text-green-400 font-medium",children:["$",a.totalValue.toFixed(2)]})]}),a.game&&(0,e.jsx)("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${(a=>{switch(a){case"MTG":return"bg-orange-100 text-orange-800 dark:bg-orange-900/30 dark:text-orange-300";case"POKEMON":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300";case"LORCANA":return"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300";case"YUGIOH":return"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300";default:return"bg-surface-100 text-surface-800 dark:bg-surface-700 dark:text-surface-300"}})(a.game)}`,children:a.game})]}),(0,e.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,e.jsx)("button",{onClick:()=>{},className:"flex-1 bg-primary-50 dark:bg-primary-900/20 text-primary-700 dark:text-primary-300 py-2 px-3 rounded-lg text-sm font-medium hover:bg-primary-100 dark:hover:bg-primary-900/30 transition-colors",children:"View Cards"}),(0,e.jsx)("button",{onClick:()=>j(a.id),className:"p-2 text-surface-400 hover:text-surface-600 dark:hover:text-surface-300 rounded-lg transition-colors",children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,e.jsx)("button",{onClick:()=>{var b,c;return b=a.id,c=a.name,void(window.confirm(`Are you sure you want to delete "${c}"? This action cannot be undone.`)&&q.mutate(b))},className:"p-2 text-red-400 hover:text-red-600 rounded-lg transition-colors",disabled:q.isPending,children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})]},a.id))}),(0,e.jsx)(i.A,{isOpen:b||!!d,onClose:()=>{c(!1),j(null)},collectionId:d||void 0})]})};d()}catch(a){d(a)}})},231:(a,b,c)=>{"use strict";c.d(b,{A:()=>h});var d=c(8732),e=c(2015),f=c(4822),g=c(4670);let h=()=>{let{login:a}=(0,g.A)(),[b,c]=(0,e.useState)({email:"",password:""}),[h,i]=(0,e.useState)(!1),[j,k]=(0,e.useState)(null),[l,m]=(0,e.useState)(!1),n=async c=>{c.preventDefault(),i(!0),k(null);try{await a(b.email,b.password)}catch(a){k(a instanceof Error?a.message:"Login failed")}finally{i(!1)}},o=a=>{c(b=>({...b,[a.target.name]:a.target.value}))};return(0,d.jsxs)("div",{className:"bg-white dark:bg-surface-800 p-8 rounded-2xl shadow-xl border border-surface-200 dark:border-surface-700 transition-colors",children:[(0,d.jsxs)("div",{className:"text-center mb-8",children:[(0,d.jsx)("div",{className:"w-16 h-16 bg-gradient-to-r from-primary-500 to-accent-500 rounded-2xl flex items-center justify-center mx-auto mb-4 shadow-lg",children:(0,d.jsx)("svg",{className:"w-8 h-8 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:(0,d.jsx)("path",{d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),(0,d.jsx)("h1",{className:"text-2xl font-bold text-surface-900 dark:text-white mb-2",children:"Welcome Back"}),(0,d.jsx)("p",{className:"text-surface-600 dark:text-surface-400",children:"Sign in to your TCG Vault"})]}),j&&(0,d.jsx)("div",{className:"mb-6 p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-xl",children:(0,d.jsxs)("div",{className:"flex items-center",children:[(0,d.jsx)("svg",{className:"w-5 h-5 text-red-500 mr-2",fill:"currentColor",viewBox:"0 0 20 20",children:(0,d.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})}),(0,d.jsx)("span",{className:"text-red-700 dark:text-red-400 text-sm",children:j})]})}),(0,d.jsxs)("form",{onSubmit:n,className:"space-y-6",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{htmlFor:"email",className:"block text-sm font-medium text-surface-700 dark:text-surface-300 mb-2",children:"Email Address"}),(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("input",{type:"email",id:"email",name:"email",value:b.email,onChange:o,className:"w-full px-4 py-3 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-xl text-surface-900 dark:text-white placeholder-surface-500 dark:placeholder-surface-400 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent transition-colors",placeholder:"Enter your email",required:!0}),(0,d.jsx)("svg",{className:"absolute right-3 top-1/2 transform -translate-y-1/2 w-5 h-5 text-surface-400 dark:text-surface-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 12a4 4 0 10-8 0 4 4 0 008 0zm0 0v1.5a2.5 2.5 0 005 0V12a9 9 0 10-9 9m4.5-1.206a8.959 8.959 0 01-4.5 1.207"})})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{htmlFor:"password",className:"block text-sm font-medium text-surface-700 dark:text-surface-300 mb-2",children:"Password"}),(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("input",{type:l?"text":"password",id:"password",name:"password",value:b.password,onChange:o,className:"w-full px-4 py-3 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-xl text-surface-900 dark:text-white placeholder-surface-500 dark:placeholder-surface-400 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent transition-colors pr-12",placeholder:"Enter your password",required:!0}),(0,d.jsx)("button",{type:"button",onClick:()=>m(!l),className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-surface-400 dark:text-surface-500 hover:text-surface-600 dark:hover:text-surface-300 transition-colors",children:l?(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.878 9.878L3 3m6.878 6.878L21 21"})}):(0,d.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]})})]})]}),(0,d.jsx)("button",{type:"submit",disabled:h,className:"w-full bg-gradient-to-r from-primary-500 to-accent-500 hover:from-primary-600 hover:to-accent-600 disabled:from-surface-400 disabled:to-surface-400 text-white font-semibold py-3 px-4 rounded-xl transition-all duration-200 shadow-lg hover:shadow-xl disabled:shadow-none transform hover:-translate-y-0.5 disabled:transform-none",children:h?(0,d.jsxs)("div",{className:"flex items-center justify-center",children:[(0,d.jsxs)("svg",{className:"animate-spin -ml-1 mr-3 h-5 w-5 text-white",fill:"none",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,d.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Signing In..."]}):"Sign In"}),(0,d.jsx)("div",{className:"text-center",children:(0,d.jsxs)("p",{className:"text-surface-600 dark:text-surface-400",children:["Don't have an account?"," ",(0,d.jsx)(f.Link,{to:"/register",className:"text-primary-600 dark:text-primary-400 hover:text-primary-700 dark:hover:text-primary-300 font-medium transition-colors",children:"Sign up"})]})})]})]})}},367:(a,b,c)=>{"use strict";function d(a){return a}Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"removeBasePath",{enumerable:!0,get:function(){return d}}),c(617),("function"==typeof b.default||"object"==typeof b.default&&null!==b.default)&&void 0===b.default.__esModule&&(Object.defineProperty(b.default,"__esModule",{value:!0}),Object.assign(b.default,b),a.exports=b.default)},452:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{A:()=>o});var e=c(8732),f=c(2015),g=c(8462),h=c(6659),i=c(5891),j=c(7594),k=c(1862),l=c(4937),m=c(5678),n=a([g,h,i,j,k]);[g,h,i,j,k]=n.then?(await n)():n;let o=()=>{let[a,b]=(0,f.useState)(""),[c,d]=(0,f.useState)({game:"",rarity:"",status:"all",search:""}),[n,o]=(0,f.useState)("card"),[p,q]=(0,f.useState)(!1),[r,s]=(0,f.useState)(!1),[t,u]=(0,f.useState)(null),{data:v=[],isLoading:w,error:x}=(0,g.useQuery)({queryKey:["user-cards",{...c,search:a}],queryFn:()=>h.LO.cards.getUserCards({...c,search:a})}),y=v.filter(a=>{let b=a.card;return!!b&&(!c.rarity||b.rarity===c.rarity)&&(!c.game||b.game===c.game)&&(!c.status||"all"===c.status||a.status===c.status)}),z=a=>{switch(a){case"MTG":return"bg-orange-100 text-orange-800 dark:bg-orange-900/30 dark:text-orange-300";case"POKEMON":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300";case"LORCANA":return"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300";case"YUGIOH":return"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300";default:return"bg-surface-100 text-surface-800 dark:bg-surface-700 dark:text-surface-300"}},A=a=>{switch(a.toLowerCase()){case"common":default:return"bg-surface-100 text-surface-800 dark:bg-surface-700 dark:text-surface-300";case"uncommon":return"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300";case"rare":return"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300";case"super rare":return"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300";case"legendary":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300";case"mythic":return"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300"}},B=a=>{switch(a){case"owned":return"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300";case"wanted":return"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300";default:return"bg-surface-100 text-surface-800 dark:bg-surface-700 dark:text-surface-300"}};return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h1",{className:"text-2xl font-bold text-surface-900 dark:text-white",children:"My Cards"}),(0,e.jsxs)("p",{className:"text-surface-600 dark:text-surface-400 mt-1",children:[y.length," cards in your collection"]})]}),(0,e.jsxs)("div",{className:"flex space-x-3",children:[(0,e.jsxs)("button",{onClick:()=>q(!0),className:"bg-gradient-to-r from-primary-500 to-accent-500 hover:from-primary-600 hover:to-accent-600 text-white px-4 py-2 rounded-xl font-medium transition-all duration-200 shadow-md hover:shadow-lg transform hover:-translate-y-0.5",children:[(0,e.jsx)("svg",{className:"w-4 h-4 mr-2 inline",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),"Add Cards"]}),(0,e.jsxs)("button",{onClick:()=>s(!0),className:"bg-gradient-to-r from-accent-500 to-primary-500 hover:from-accent-600 hover:to-primary-600 text-white px-4 py-2 rounded-xl font-medium transition-all duration-200 shadow-md hover:shadow-lg transform hover:-translate-y-0.5",children:[(0,e.jsx)("svg",{className:"w-4 h-4 mr-2 inline",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),"Browse Database"]})]})]}),(0,e.jsx)("div",{className:"bg-white dark:bg-surface-800 rounded-xl border border-surface-200 dark:border-surface-700 p-4",children:(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:(0,e.jsx)("svg",{className:"h-5 w-5 text-surface-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),(0,e.jsx)("input",{type:"text",value:a,onChange:a=>b(a.target.value),placeholder:"Search your cards...",className:"w-full pl-10 pr-4 py-3 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-xl text-surface-900 dark:text-white placeholder-surface-500 dark:placeholder-surface-400 focus:outline-none focus:ring-2 focus:ring-primary-500 transition-colors"})]}),(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"flex space-x-2 overflow-x-auto pb-2",children:[(0,e.jsxs)("select",{value:c.game,onChange:a=>d(b=>({...b,game:a.target.value})),className:"px-3 py-2 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-primary-500 transition-colors whitespace-nowrap",children:[(0,e.jsx)("option",{value:"",children:"All Games"}),(0,e.jsx)("option",{value:"MTG",children:"Magic: The Gathering"}),(0,e.jsx)("option",{value:"POKEMON",children:"Pok\xe9mon"}),(0,e.jsx)("option",{value:"LORCANA",children:"Disney Lorcana"}),(0,e.jsx)("option",{value:"YUGIOH",children:"Yu-Gi-Oh!"})]}),(0,e.jsxs)("select",{value:c.rarity,onChange:a=>d(b=>({...b,rarity:a.target.value})),className:"px-3 py-2 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-primary-500 transition-colors whitespace-nowrap",children:[(0,e.jsx)("option",{value:"",children:"All Rarities"}),(0,e.jsx)("option",{value:"Common",children:"Common"}),(0,e.jsx)("option",{value:"Uncommon",children:"Uncommon"}),(0,e.jsx)("option",{value:"Rare",children:"Rare"}),(0,e.jsx)("option",{value:"Super Rare",children:"Super Rare"}),(0,e.jsx)("option",{value:"Legendary",children:"Legendary"}),(0,e.jsx)("option",{value:"Mythic",children:"Mythic"})]}),(0,e.jsxs)("select",{value:c.status,onChange:a=>d(b=>({...b,status:a.target.value})),className:"px-3 py-2 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-primary-500 transition-colors whitespace-nowrap",children:[(0,e.jsx)("option",{value:"all",children:"All Cards"}),(0,e.jsx)("option",{value:"owned",children:"Owned"}),(0,e.jsx)("option",{value:"wanted",children:"Wanted"})]})]}),(0,e.jsxs)("div",{className:"flex bg-surface-100 dark:bg-surface-700 rounded-lg p-1",children:[(0,e.jsx)("button",{onClick:()=>o("card"),className:`p-2 rounded-md transition-colors ${"card"===n?"bg-white dark:bg-surface-600 text-surface-900 dark:text-white shadow-sm":"text-surface-600 dark:text-surface-400 hover:text-surface-900 dark:hover:text-white"}`,children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zM14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6zM4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zM14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z"})})}),(0,e.jsx)("button",{onClick:()=>o("list"),className:`p-2 rounded-md transition-colors ${"list"===n?"bg-white dark:bg-surface-600 text-surface-900 dark:text-white shadow-sm":"text-surface-600 dark:text-surface-400 hover:text-surface-900 dark:hover:text-white"}`,children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 10h16M4 14h16M4 18h16"})})})]})]})]})}),w&&(0,e.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,e.jsxs)("div",{className:"flex flex-col items-center",children:[(0,e.jsx)("div",{className:"w-8 h-8 bg-gradient-to-r from-primary-500 to-accent-500 rounded-full flex items-center justify-center animate-bounce-subtle mb-3",children:(0,e.jsx)("svg",{className:"w-4 h-4 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:(0,e.jsx)("path",{d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),(0,e.jsx)("p",{className:"text-surface-600 dark:text-surface-400 text-sm",children:"Loading your cards..."})]})}),x&&(0,e.jsx)("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-xl p-4 mb-6",children:(0,e.jsx)("p",{className:"text-red-800 dark:text-red-400",children:"Error loading cards. Please try again."})}),!w&&!x&&(0,e.jsx)(e.Fragment,{children:0===y.length?(0,e.jsx)("div",{className:"bg-white dark:bg-surface-800 rounded-xl border border-surface-200 dark:border-surface-700 p-8",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("div",{className:"w-16 h-16 bg-surface-100 dark:bg-surface-700 rounded-2xl flex items-center justify-center mx-auto mb-6",children:(0,e.jsx)("svg",{className:"w-8 h-8 text-surface-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),(0,e.jsx)("h3",{className:"text-xl font-semibold text-surface-900 dark:text-white mb-2",children:0===v.length?"No cards yet":"No matching cards"}),(0,e.jsx)("p",{className:"text-surface-600 dark:text-surface-400 mb-6",children:0===v.length?"Start building your collection by adding cards":"Try adjusting your search or filters"}),0===v.length&&(0,e.jsxs)("div",{className:"flex flex-col sm:flex-row gap-3 items-center justify-center",children:[(0,e.jsx)("button",{onClick:()=>q(!0),className:"bg-gradient-to-r from-primary-500 to-accent-500 hover:from-primary-600 hover:to-accent-600 text-white px-6 py-3 rounded-xl font-medium transition-all duration-200 shadow-md hover:shadow-lg transform hover:-translate-y-0.5",children:"Browse Cards"}),(0,e.jsx)("button",{className:"bg-surface-100 dark:bg-surface-700 hover:bg-surface-200 dark:hover:bg-surface-600 text-surface-800 dark:text-surface-300 px-6 py-3 rounded-xl font-medium transition-colors",children:"Scan Cards"})]})]})}):"card"===n?(0,e.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:y.map(a=>{let b=a.card;return b?(0,e.jsxs)(m.A,{rarity:b.rarity,className:"bg-white dark:bg-surface-800 rounded-xl shadow overflow-hidden hover:shadow-lg transition-all duration-200",children:[(0,e.jsx)("div",{className:"flex justify-center p-4 bg-surface-50 dark:bg-surface-700/50",children:(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)(l.A,{card:b,size:"large",className:"mx-auto"}),(0,e.jsx)("div",{className:"absolute -top-2 -right-2",children:(0,e.jsx)("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${B(a.status)}`,children:"owned"===a.status?"✅":"❤️"})}),a.quantity>1&&(0,e.jsx)("div",{className:"absolute -bottom-2 -right-2",children:(0,e.jsxs)("span",{className:"bg-surface-800 dark:bg-surface-200 text-white dark:text-surface-900 text-xs font-bold px-2 py-1 rounded-full",children:[a.quantity,"x"]})})]})}),(0,e.jsxs)("div",{className:"p-4",children:[(0,e.jsxs)("div",{className:"flex justify-between items-start mb-3",children:[(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsx)("h3",{className:"font-semibold text-surface-900 dark:text-white truncate",title:b.name,children:b.name}),(0,e.jsx)("p",{className:"text-sm text-surface-600 dark:text-surface-400 truncate",children:b.set_name})]}),(0,e.jsx)("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${z(b.game)}`,children:b.game})]}),(0,e.jsxs)("div",{className:"space-y-1 mb-3",children:[b.card_type&&(0,e.jsx)("p",{className:"text-xs text-surface-600 dark:text-surface-400 truncate",title:b.card_type,children:b.card_type}),(0,e.jsxs)("div",{className:"flex justify-between items-center",children:[b.mana_cost&&(0,e.jsxs)("span",{className:"text-xs text-surface-600 dark:text-surface-400",children:["Cost: ",b.mana_cost]}),b.power&&b.toughness&&(0,e.jsxs)("span",{className:"text-xs text-surface-600 dark:text-surface-400",children:[b.power,"/",b.toughness]})]})]}),(0,e.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,e.jsx)("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${A(b.rarity)}`,children:b.rarity}),b.current_price&&(0,e.jsxs)("span",{className:"text-sm font-medium text-green-600 dark:text-green-400",children:["$",b.current_price.toFixed(2)]})]}),a.condition&&"owned"===a.status&&(0,e.jsx)("div",{className:"mb-3",children:(0,e.jsx)("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${(a=>{switch(a){case"mint":return"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/30 dark:text-emerald-300";case"near_mint":return"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300";case"excellent":return"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300";case"good":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300";case"light_played":return"bg-orange-100 text-orange-800 dark:bg-orange-900/30 dark:text-orange-300";case"played":return"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300";case"poor":return"bg-gray-100 text-gray-800 dark:bg-gray-900/30 dark:text-gray-300";default:return"bg-surface-100 text-surface-800 dark:bg-surface-700 dark:text-surface-300"}})(a.condition)}`,children:a.condition.replace("_"," ").toUpperCase()})}),(0,e.jsx)("button",{onClick:()=>u(a.id),className:"w-full bg-surface-100 dark:bg-surface-700 hover:bg-surface-200 dark:hover:bg-surface-600 text-surface-800 dark:text-surface-300 py-2 px-3 rounded-lg text-sm font-medium transition-colors",children:"Edit Card"})]})]},a.id):null})}):(0,e.jsx)("div",{className:"bg-white dark:bg-surface-800 rounded-xl border border-surface-200 dark:border-surface-700 overflow-hidden",children:(0,e.jsx)("div",{className:"space-y-1",children:y.map(a=>{let b=a.card;return b?(0,e.jsxs)("div",{className:"flex items-center p-4 hover:bg-surface-50 dark:hover:bg-surface-700/50 transition-colors",children:[(0,e.jsx)("div",{className:"w-12 h-16 bg-surface-200 dark:bg-surface-700 rounded-lg flex items-center justify-center flex-shrink-0 mr-4",children:b.image_url?(0,e.jsx)("img",{src:b.image_url,alt:b.name,className:"w-full h-full object-cover rounded-lg"}):(0,e.jsx)("svg",{className:"w-4 h-4 text-surface-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsx)("h3",{className:"font-semibold text-surface-900 dark:text-white truncate",children:b.name}),(0,e.jsx)("p",{className:"text-sm text-surface-600 dark:text-surface-400 truncate",children:b.set_name}),(0,e.jsxs)("div",{className:"flex items-center space-x-2 mt-1",children:[(0,e.jsx)("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${z(b.game)}`,children:b.game}),(0,e.jsx)("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${A(b.rarity)}`,children:b.rarity}),(0,e.jsx)("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${B(a.status)}`,children:a.status})]})]}),(0,e.jsxs)("div",{className:"text-right mr-4",children:[(0,e.jsxs)("div",{className:"text-sm font-medium text-surface-900 dark:text-white",children:[a.quantity,"x"]}),b.current_price&&(0,e.jsxs)("div",{className:"text-sm text-green-600 dark:text-green-400",children:["$",(b.current_price*a.quantity).toFixed(2)]})]}),(0,e.jsx)("button",{onClick:()=>u(a.id),className:"p-2 text-surface-400 hover:text-surface-600 dark:hover:text-surface-300 rounded-lg transition-colors",children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})})]},a.id):null})})})}),(0,e.jsx)(i.A,{isOpen:p,onClose:()=>q(!1)}),t&&(0,e.jsx)(k.A,{isOpen:!!t,onClose:()=>u(null),cardId:t}),(0,e.jsx)(j.A,{isOpen:r,onClose:()=>s(!1),onCardSelect:a=>{console.log("Selected card from database:",a),s(!1)}})]})};d()}catch(a){d(a)}})},617:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"hasBasePath",{enumerable:!0,get:function(){return e}});let d=c(9596);function e(a){return(0,d.pathHasPrefix)(a,"")}("function"==typeof b.default||"object"==typeof b.default&&null!==b.default)&&void 0===b.default.__esModule&&(Object.defineProperty(b.default,"__esModule",{value:!0}),Object.assign(b.default,b),a.exports=b.default)},651:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"isLocalURL",{enumerable:!0,get:function(){return f}});let d=c(4718),e=c(617);function f(a){if(!(0,d.isAbsoluteUrl)(a))return!0;try{let b=(0,d.getLocationOrigin)(),c=new URL(a,b);return c.origin===b&&(0,e.hasBasePath)(c.pathname)}catch(a){return!1}}},717:(a,b,c)=>{"use strict";c.d(b,{A:()=>r});var d=c(8732),e=c(2015),f=c(4822);let g=({onModeSelect:a})=>(0,d.jsx)("div",{className:"min-h-screen bg-gray-50 px-4 py-6 sm:px-6 lg:px-8",children:(0,d.jsxs)("div",{className:"max-w-md mx-auto sm:max-w-2xl",children:[(0,d.jsxs)("div",{className:"text-center mb-8",children:[(0,d.jsx)("h1",{className:"text-2xl sm:text-3xl font-bold text-gray-900 mb-3",children:"Card Scanner"}),(0,d.jsx)("p",{className:"text-gray-600 text-sm sm:text-base px-2",children:"Choose your scanning mode to get started"})]}),(0,d.jsx)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 mb-8",children:[{id:"add-to-database",title:"Add Cards to Database",description:"Scan new cards and add them to your collections",icon:"\uD83D\uDCDA",color:"bg-blue-500 hover:bg-blue-600 active:bg-blue-700"},{id:"search-collections",title:"Search Collections",description:"Find these cards in your existing collections",icon:"\uD83D\uDD0D",color:"bg-green-500 hover:bg-green-600 active:bg-green-700"},{id:"price-check",title:"Price Check",description:"Get real-time pricing for your cards",icon:"\uD83D\uDCB0",color:"bg-yellow-500 hover:bg-yellow-600 active:bg-yellow-700"},{id:"deck-building",title:"Deck Building",description:"Scan cards directly into a deck with legality checks",icon:"\uD83C\uDFAF",color:"bg-purple-500 hover:bg-purple-600 active:bg-purple-700"}].map(b=>(0,d.jsxs)("button",{onClick:()=>a(b.id),className:`${b.color} text-white rounded-xl shadow-lg transition-all duration-200 hover:shadow-xl transform hover:scale-[1.02] active:scale-[0.98] text-left relative overflow-hidden`,style:{minHeight:"120px"},children:[(0,d.jsxs)("div",{className:"p-6 sm:p-6 h-full flex flex-col",children:[(0,d.jsxs)("div",{className:"flex items-start space-x-4 mb-3",children:[(0,d.jsx)("div",{className:"text-3xl sm:text-4xl flex-shrink-0",role:"img","aria-label":b.title,children:b.icon}),(0,d.jsx)("div",{className:"flex-1 min-w-0",children:(0,d.jsx)("h3",{className:"text-lg sm:text-xl font-semibold leading-tight mb-2",children:b.title})})]}),(0,d.jsx)("p",{className:"text-white/90 text-sm sm:text-base leading-relaxed flex-1",children:b.description})]}),(0,d.jsx)("div",{className:"absolute inset-0 bg-gradient-to-br from-white/10 to-transparent pointer-events-none"})]},b.id))}),(0,d.jsxs)("div",{className:"bg-white rounded-xl shadow-sm border border-gray-100 p-5 sm:p-6",children:[(0,d.jsxs)("div",{className:"flex items-center mb-4",children:[(0,d.jsx)("span",{className:"text-2xl mr-3",role:"img","aria-label":"Tips",children:"\uD83D\uDCA1"}),(0,d.jsx)("h2",{className:"font-semibold text-gray-900 text-lg",children:"Pro Tips"})]}),(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsxs)("div",{className:"flex items-start space-x-3",children:[(0,d.jsx)("div",{className:"w-2 h-2 bg-blue-500 rounded-full mt-2 flex-shrink-0"}),(0,d.jsx)("p",{className:"text-gray-700 text-sm sm:text-base",children:"Position cards clearly within the camera frame"})]}),(0,d.jsxs)("div",{className:"flex items-start space-x-3",children:[(0,d.jsx)("div",{className:"w-2 h-2 bg-green-500 rounded-full mt-2 flex-shrink-0"}),(0,d.jsx)("p",{className:"text-gray-700 text-sm sm:text-base",children:"Scanner will auto-detect cards after 2-3 seconds"})]}),(0,d.jsxs)("div",{className:"flex items-start space-x-3",children:[(0,d.jsx)("div",{className:"w-2 h-2 bg-purple-500 rounded-full mt-2 flex-shrink-0"}),(0,d.jsx)("p",{className:"text-gray-700 text-sm sm:text-base",children:"You can scan up to 100 cards in a single session"})]}),(0,d.jsxs)("div",{className:"flex items-start space-x-3",children:[(0,d.jsx)("div",{className:"w-2 h-2 bg-yellow-500 rounded-full mt-2 flex-shrink-0"}),(0,d.jsx)("p",{className:"text-gray-700 text-sm sm:text-base",children:"Duplicates are allowed and will be tracked separately"})]})]})]}),(0,d.jsx)("div",{className:"h-8 sm:h-4"})]})}),h=({isVisible:a,message:b,progress:c,type:e="scanning"})=>a?(0,d.jsx)("div",{className:"fixed top-4 left-4 right-4 z-50 animate-slide-down sm:left-1/2 sm:right-auto sm:transform sm:-translate-x-1/2 sm:w-auto sm:min-w-80 sm:max-w-md",children:(0,d.jsx)("div",{className:`${(()=>{switch(e){case"scanning":default:return"bg-blue-600 text-white";case"processing":return"bg-purple-600 text-white";case"success":return"bg-green-600 text-white";case"error":return"bg-red-600 text-white"}})()} rounded-xl shadow-lg px-4 py-3 sm:px-5 sm:py-4`,children:(0,d.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,d.jsx)("div",{className:"text-lg sm:text-xl flex-shrink-0",role:"img","aria-label":e,children:(()=>{switch(e){case"scanning":default:return"\uD83D\uDCF7";case"processing":return"\uD83E\uDD16";case"success":return"✅";case"error":return"❌"}})()}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"font-medium text-sm sm:text-base leading-tight",children:b}),void 0!==c&&(0,d.jsx)("div",{className:"mt-2",children:(0,d.jsx)("div",{className:"w-full bg-white/20 rounded-full h-1.5 sm:h-2",children:(0,d.jsx)("div",{className:"bg-white h-1.5 sm:h-2 rounded-full transition-all duration-300 ease-out",style:{width:`${Math.min(100,Math.max(0,c))}%`}})})})]}),("scanning"===e||"processing"===e)&&(0,d.jsx)("div",{className:"w-5 h-5 sm:w-6 sm:h-6 flex-shrink-0",children:(0,d.jsx)("div",{className:"animate-spin rounded-full h-5 w-5 sm:h-6 sm:w-6 border-2 border-white border-t-transparent"})})]})})}):null;class i{constructor(){this.apiKey=null,this.apiKey=process.env.REACT_APP_OPENAI_API_KEY||null}setApiKey(a){this.apiKey=a}async analyzeCard(a){if(!this.apiKey)throw Error("OpenAI API key not configured");try{let b=await fetch("https://api.openai.com/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify({model:"gpt-4o-mini",messages:[{role:"user",content:[{type:"text",text:'Analyze this trading card image and extract information. Respond with ONLY valid JSON, no markdown formatting or code blocks:\n\n{"cardName": "exact card name", "setName": "set name if visible", "setCode": "3-4 letter set code if visible", "cardType": "creature, spell, pokemon, etc", "rarity": "common, uncommon, rare, etc", "hp": "HP value for Pokemon", "attacks": ["attack names"], "abilities": ["ability names"], "rawText": "all visible text on the card", "game": "MTG or POKEMON or LORCANA", "confidence": 95}\n\nIMPORTANT: Return ONLY the JSON object, no markdown code blocks. Focus on accuracy, leave fields empty if unclear. For the cardName, use the exact name as printed on the card.'},{type:"image_url",image_url:{url:a,detail:"high"}}]}],max_tokens:1e3,temperature:.1})});if(!b.ok)throw Error(`OpenAI API error: ${b.status} ${b.statusText}`);let c=await b.json(),d=c.choices[0]?.message?.content;if(!d)throw Error("No content received from OpenAI");try{let a=d.trim();a.startsWith("```json")?a=a.replace(/^```json\s*/,"").replace(/\s*```$/,""):a.startsWith("```")&&(a=a.replace(/^```\s*/,"").replace(/\s*```$/,""));let b=JSON.parse(a);return{cardName:b.cardName||"",setName:b.setName||void 0,setCode:b.setCode||void 0,cardType:b.cardType||void 0,rarity:b.rarity||void 0,hp:b.hp||void 0,attacks:b.attacks||[],abilities:b.abilities||[],rawText:b.rawText||d,confidence:b.confidence||85,game:b.game||"UNKNOWN"}}catch(b){console.log("JSON parsing failed, trying text extraction:",b),console.log("Raw content:",d);let a=this.extractDataFromRawResponse(d);return{cardName:a.cardName||"Unknown Card",setName:a.setName,setCode:a.setCode,cardType:a.cardType,rarity:a.rarity,hp:a.hp,attacks:a.attacks||[],abilities:a.abilities||[],rawText:d,confidence:70,game:a.game||"UNKNOWN"}}}catch(a){throw console.error("AI OCR error:",a),Error(`AI OCR failed: ${a.message}`)}}extractCardNameFromText(a){let b=a.split("\n").map(a=>a.trim()).filter(a=>a.length>0);for(let a of b)if(!a.match(/^(card name|name:|the card|this is)/i)&&a.length>3&&a.length<50)return a;return b[0]||"Unknown Card"}extractDataFromRawResponse(a){let b=a.split("\n").map(a=>a.trim()).filter(a=>a.length>0),c="",d="",e="",f="",g="",h=[],i=[];for(let a of b)!(a.startsWith("```")||a.startsWith("#"))&&(a.match(/card\s*name[:−]?\s*(.+)/i)?c=a.replace(/card\s*name[:−]?\s*/i,"").replace(/['"]/g,""):a.match(/name[:−]?\s*(.+)/i)&&!c?c=a.replace(/name[:−]?\s*/i,"").replace(/['"]/g,""):a.match(/set[:−]?\s*(.+)/i)?d=a.replace(/set[:−]?\s*/i,"").replace(/['"]/g,""):a.match(/hp[:−]?\s*(\d+)/i)?g=a.match(/hp[:−]?\s*(\d+)/i)?.[1]||"":a.match(/type[:−]?\s*(.+)/i)?e=a.replace(/type[:−]?\s*/i,"").replace(/['"]/g,""):a.match(/rarity[:−]?\s*(.+)/i)&&(f=a.replace(/rarity[:−]?\s*/i,"").replace(/['"]/g,"")));return c||(c=this.extractCardNameFromText(a)),{cardName:c||"Unknown Card",setName:d||void 0,setCode:void 0,cardType:e||void 0,rarity:f||void 0,hp:g||void 0,attacks:h.length>0?h:void 0,abilities:i.length>0?i:void 0,game:this.detectGameFromText(a)}}detectGameFromText(a){let b=a.toLowerCase();return b.includes("pokemon")||b.includes("hp")||b.includes("evolves")?"POKEMON":b.includes("mana")||b.includes("creature")||b.includes("instant")?"MTG":b.includes("lorcana")||b.includes("ink")?"LORCANA":"UNKNOWN"}}class j{constructor(a="http://localhost:11434"){this.baseUrl=a}async analyzeCard(a){try{let b=a.split(",")[1],c=await fetch(`${this.baseUrl}/api/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:"llava:latest",prompt:`Analyze this trading card image and extract: 1. Card name (exact spelling) 2. Set name and code 3. Game type (Magic: The Gathering, Pokemon, or Lorcana) 4. All visible text 5. Card type and rarity if visible Provide accurate information only. Format as JSON with fields: cardName, setName, setCode, game, cardType, rarity, rawText`,images:[b],stream:!1})});if(!c.ok)throw Error(`Ollama API error: ${c.status}`);let d=(await c.json()).response;try{let a=JSON.parse(d);return{cardName:a.cardName||"",setName:a.setName,setCode:a.setCode,cardType:a.cardType,rarity:a.rarity,rawText:a.rawText||d,confidence:85,game:a.game?.toUpperCase()||"UNKNOWN"}}catch{return{cardName:this.extractCardNameFromText(d),rawText:d,confidence:75,game:this.detectGameFromText(d)}}}catch(a){throw console.error("Ollama OCR error:",a),Error(`Ollama OCR failed: ${a.message}`)}}extractCardNameFromText(a){return a.split("\n").map(a=>a.trim()).filter(a=>a.length>0).find(a=>a.length>3&&a.length<50)||"Unknown Card"}detectGameFromText(a){let b=a.toLowerCase();return b.includes("pokemon")||b.includes("hp")?"POKEMON":b.includes("mana")||b.includes("creature")?"MTG":b.includes("lorcana")?"LORCANA":"UNKNOWN"}}let k=new i,l=new j,m=({onCardScanned:a,onError:b,isActive:c,maxQueueSize:f=100})=>{let g=(0,e.useRef)(null),i=(0,e.useRef)(null),j=(0,e.useRef)(null),m=(0,e.useRef)(null),n=(0,e.useRef)(0),[o,p]=(0,e.useState)(!1),[q,r]=(0,e.useState)({isScanning:!1,isProcessing:!1,message:"",countdown:0}),[s,t]=(0,e.useState)(0),[u,v]=(0,e.useState)(new Set),[w,x]=(0,e.useState)(!1);(0,e.useEffect)(()=>{(async()=>{try{let a=localStorage.getItem("openai_api_key"),b=localStorage.getItem("tcg_vault_token");if(b)try{let a=await fetch("/api/user/preferences",{headers:{Authorization:`Bearer ${b}`,"Content-Type":"application/json"}});if(a.ok){let b=await a.json(),c=b.preferences?.ocrSettings?.openai_api_key;if(c){k.setApiKey(c),x(!0),console.log("✅ OCR configured with user preferences API key");return}}}catch(a){console.log("Could not load user preferences, checking localStorage...")}a?(k.setApiKey(a),x(!0),console.log("✅ OCR configured with localStorage API key")):(console.log("❌ No OpenAI API key found. OCR scanning will not work."),x(!1))}catch(a){console.error("Error initializing OCR:",a),x(!1)}})()},[]),(0,e.useEffect)(()=>(c?y():z(),()=>{z()}),[c]),(0,e.useEffect)(()=>{if(!o||!c||!w)return;let a=setInterval(()=>{Date.now()-n.current>5e3&&(()=>{if(q.isProcessing||s>=f)return;m.current&&clearTimeout(m.current),r(a=>({...a,isScanning:!0,message:"Card detected, stabilizing...",countdown:3}));let a=3,b=setInterval(()=>{a--,r(b=>({...b,countdown:a,message:a>0?`Scanning in ${a}...`:"Scanning card..."})),a<=0&&(clearInterval(b),B())},1e3);m.current=setTimeout(()=>{clearInterval(b),B()},3e3)})()},2e3);return()=>{clearInterval(a),m.current&&clearTimeout(m.current)}},[o,c,q.isProcessing,s,f,w]);let y=async()=>{try{let a=await navigator.mediaDevices.getUserMedia({video:{facingMode:"environment",width:{ideal:1920},height:{ideal:1080}}});g.current&&(g.current.srcObject=a,j.current=a,g.current.onloadedmetadata=()=>{g.current?.play().then(()=>{p(!0)})})}catch(a){console.error("Camera error:",a),b(`Camera access failed: ${a.message}`)}},z=()=>{j.current&&(j.current.getTracks().forEach(a=>a.stop()),j.current=null),p(!1),r({isScanning:!1,isProcessing:!1,message:"",countdown:0})},A=(0,e.useCallback)(()=>{if(!g.current||!i.current)return null;let a=g.current,b=i.current,c=b.getContext("2d");return c?(b.width=a.videoWidth,b.height=a.videoHeight,c.drawImage(a,0,0,b.width,b.height),b.toDataURL("image/jpeg",.8)):null},[]),B=(0,e.useCallback)(async()=>{if(!q.isProcessing&&!(s>=f)){if(!w){r(a=>({...a,isScanning:!1,isProcessing:!1,message:"OCR not configured - please set up your API key in Settings"})),setTimeout(()=>{r(a=>({...a,message:""}))},4e3);return}r(a=>({...a,isScanning:!1,isProcessing:!0,message:"Processing card with AI...",countdown:0}));try{let b,c=A();if(!c)throw Error("Failed to capture image");try{console.log("\uD83E\uDD16 Trying OpenAI Vision API..."),b=await k.analyzeCard(c),console.log("✅ OpenAI Vision result:",b)}catch(a){console.log("❌ OpenAI failed, trying Ollama:",a);try{b=await l.analyzeCard(c),console.log("✅ Ollama Vision result:",b)}catch(a){throw console.error("❌ All AI OCR methods failed"),Error("AI OCR services unavailable. Please configure OpenAI API key or run Ollama locally.")}}let d=`scan_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,e=(b.cardName||"unknown").toLowerCase().replace(/\s+/g,"");if(u.has(e))r(a=>({...a,isProcessing:!1,message:`Duplicate detected: ${b.cardName||"Unknown Card"}`}));else{v(a=>{let b=new Set(a);if(b.add(e),b.size>10){let a=b.values().next().value;b.delete(a)}return b});let f={id:d,cardData:b,imageDataUrl:c,timestamp:Date.now(),queuePosition:s+1};a(f),t(a=>a+1),n.current=Date.now(),r(a=>({...a,isProcessing:!1,message:`Added: ${b.cardName||"Unknown Card"}`}))}setTimeout(()=>{r(a=>({...a,message:""}))},2e3)}catch(b){console.error("Scan processing error:",b);let a="Scan failed, try again";b.message.includes("OpenAI API key not configured")?a="OpenAI API key not configured - check Settings":b.message.includes("OpenAI API error: 401")?a="Invalid OpenAI API key - check Settings":b.message.includes("OpenAI API error: 429")?a="API rate limit exceeded - wait a moment":b.message.includes("AI OCR services unavailable")&&(a="OCR service unavailable - configure API key"),r(b=>({...b,isProcessing:!1,message:a})),setTimeout(()=>{r(a=>({...a,message:""}))},4e3)}}},[A,a,s,f,u,q.isProcessing,w]);return(0,d.jsxs)("div",{className:"relative px-4 sm:px-0",children:[(0,d.jsx)(h,{isVisible:q.isScanning||q.isProcessing||!!q.message,message:q.message,progress:q.isScanning?(3-q.countdown)/3*100:void 0,type:q.isProcessing?"processing":q.message.includes("Added:")?"success":q.message.includes("not configured")||q.message.includes("unavailable")?"error":"scanning"}),!w&&o&&(0,d.jsx)("div",{className:"mb-4 bg-yellow-50 border border-yellow-200 rounded-xl p-4",children:(0,d.jsxs)("div",{className:"flex items-start",children:[(0,d.jsx)("span",{className:"text-yellow-600 text-xl mr-3 flex-shrink-0 mt-0.5",children:"⚠️"}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("p",{className:"font-medium text-yellow-900 text-sm sm:text-base",children:"OCR Not Configured"}),(0,d.jsx)("p",{className:"text-yellow-700 text-sm mt-1",children:"Please configure your OpenAI API key in Settings to enable card scanning."})]})]})}),(0,d.jsxs)("div",{className:"relative bg-black rounded-xl overflow-hidden shadow-lg",children:[(0,d.jsx)("video",{ref:g,autoPlay:!0,playsInline:!0,muted:!0,className:"w-full h-auto object-cover",style:{minHeight:"280px",maxHeight:"calc(100vh - 300px)",aspectRatio:"4/3"}}),o&&(0,d.jsxs)("div",{className:"absolute inset-0 pointer-events-none",children:[(0,d.jsx)("div",{className:"absolute inset-4 sm:inset-6 border-2 border-white border-dashed rounded-lg flex items-center justify-center",children:(0,d.jsxs)("div",{className:"bg-black bg-opacity-60 text-white px-4 py-3 rounded-xl text-center max-w-xs",children:[(0,d.jsx)("div",{className:"font-medium text-sm sm:text-base mb-1",children:"Position card within this area"}),(0,d.jsx)("div",{className:"text-xs sm:text-sm opacity-90",children:w?"Auto-scan in 2-3 seconds":"Configure OCR in Settings first"})]})}),(0,d.jsxs)("div",{className:"absolute top-3 right-3 sm:top-4 sm:right-4 bg-blue-600 text-white px-3 py-1.5 rounded-full text-xs sm:text-sm font-medium shadow-lg",children:["Queue: ",s,"/",f]}),q.isScanning&&(0,d.jsx)("div",{className:"absolute inset-0 bg-blue-500 bg-opacity-20 border-2 border-blue-500 rounded-xl animate-pulse"}),(0,d.jsx)("div",{className:"absolute bottom-4 left-4 right-4 flex justify-center",children:(0,d.jsx)("div",{className:"bg-black bg-opacity-50 backdrop-blur-sm rounded-full px-4 py-2",children:(0,d.jsxs)("div",{className:"flex items-center space-x-3 text-white text-xs",children:[(0,d.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,d.jsx)("div",{className:"w-2 h-2 bg-green-400 rounded-full animate-pulse"}),(0,d.jsx)("span",{children:"Live"})]}),q.isScanning&&(0,d.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,d.jsx)("div",{className:"w-2 h-2 bg-blue-400 rounded-full animate-pulse"}),(0,d.jsx)("span",{children:"Scanning..."})]})]})})})]}),!o&&(0,d.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,d.jsxs)("div",{className:"text-white text-center",children:[(0,d.jsx)("div",{className:"text-4xl sm:text-5xl mb-3",children:"\uD83D\uDCF9"}),(0,d.jsx)("div",{className:"font-medium text-base sm:text-lg",children:"Starting Camera..."}),(0,d.jsx)("div",{className:"text-sm sm:text-base opacity-75 mt-1",children:"Please allow camera access"})]})})]}),(0,d.jsx)("canvas",{ref:i,className:"hidden"}),o&&(0,d.jsxs)("div",{className:"mt-6 text-center",children:[(0,d.jsx)("button",{onClick:()=>{!q.isProcessing&&s=f||!w,className:"w-full sm:w-auto bg-blue-600 hover:bg-blue-700 disabled:bg-gray-400 text-white px-8 py-4 sm:px-6 sm:py-3 rounded-xl font-medium transition-all duration-200 shadow-lg hover:shadow-xl disabled:shadow-none text-base sm:text-sm",children:q.isProcessing?(0,d.jsxs)("div",{className:"flex items-center justify-center space-x-2",children:[(0,d.jsx)("div",{className:"animate-spin rounded-full h-5 w-5 border-2 border-white border-t-transparent"}),(0,d.jsx)("span",{children:"Processing..."})]}):w?(0,d.jsxs)("div",{className:"flex items-center justify-center space-x-2",children:[(0,d.jsx)("span",{children:"\uD83D\uDCF7"}),(0,d.jsx)("span",{children:"Manual Scan"})]}):"Configure OCR First"}),!w&&(0,d.jsx)("p",{className:"text-sm text-gray-600 mt-3 px-4",children:"Go to Settings → OCR to configure your OpenAI API key"})]})]})},n=({cards:a,onRemoveCard:b,onClearQueue:c,onCardSelect:f,selectedCards:g,onViewCard:h})=>{let[i,j]=(0,e.useState)(!1),k=(0,e.useCallback)(()=>{let b=!i;j(b),a.forEach(a=>{f(a.id,b)})},[i,a,f]);return 0===a.length?(0,d.jsxs)("div",{className:"text-center py-16 px-4",children:[(0,d.jsx)("div",{className:"text-6xl sm:text-7xl mb-4",children:"\uD83D\uDCF7"}),(0,d.jsx)("h3",{className:"text-xl sm:text-2xl font-semibold text-gray-700 mb-2",children:"Queue is Empty"}),(0,d.jsx)("p",{className:"text-gray-500 text-sm sm:text-base",children:"Scanned cards will appear here"})]}):(0,d.jsxs)("div",{className:"space-y-4 px-4 sm:px-0",children:[(0,d.jsx)("div",{className:"bg-white rounded-xl shadow-sm border border-gray-100 p-4 sm:p-6",children:(0,d.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[(0,d.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-3 sm:gap-4",children:[(0,d.jsxs)("h3",{className:"text-lg sm:text-xl font-semibold text-gray-900",children:["Scanned Cards (",a.length,"/100)"]}),(0,d.jsxs)("label",{className:"flex items-center space-x-2 cursor-pointer select-none",children:[(0,d.jsx)("input",{type:"checkbox",checked:i,onChange:k,className:"w-5 h-5 sm:w-4 sm:h-4 text-blue-600 rounded focus:ring-blue-500 focus:ring-2"}),(0,d.jsx)("span",{className:"text-sm sm:text-sm text-gray-700 font-medium",children:"Select All"})]})]}),(0,d.jsxs)("div",{className:"flex items-center justify-between sm:justify-end gap-2",children:[g.size>0&&(0,d.jsxs)("span",{className:"text-xs sm:text-sm text-gray-600 bg-blue-50 px-3 py-1.5 rounded-full font-medium",children:[g.size," selected"]}),(0,d.jsx)("button",{onClick:c,className:"px-4 py-2 text-sm bg-red-50 text-red-700 rounded-lg hover:bg-red-100 active:bg-red-200 transition-colors font-medium",children:"Clear All"})]})]})}),(0,d.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:a.map(a=>(0,d.jsxs)("div",{className:`relative bg-white rounded-xl shadow-sm border-2 transition-all duration-200 hover:shadow-md ${g.has(a.id)?"border-blue-500 bg-blue-50/30":"border-gray-100 hover:border-gray-200"}`,children:[(0,d.jsx)("div",{className:"absolute top-3 left-3 z-10",children:(0,d.jsx)("label",{className:"cursor-pointer",children:(0,d.jsx)("input",{type:"checkbox",checked:g.has(a.id),onChange:b=>f(a.id,b.target.checked),className:"w-5 h-5 text-blue-600 rounded focus:ring-blue-500 focus:ring-2 bg-white shadow-sm"})})}),(0,d.jsx)("button",{onClick:()=>b(a.id),className:"absolute top-3 right-3 z-10 w-8 h-8 bg-red-500 text-white rounded-full text-sm hover:bg-red-600 active:bg-red-700 transition-colors flex items-center justify-center shadow-sm","aria-label":"Remove card",children:"\xd7"}),(0,d.jsx)("div",{className:"aspect-[2.5/3.5] bg-gray-100 cursor-pointer overflow-hidden rounded-t-xl",onClick:()=>h(a),children:(0,d.jsx)("img",{src:a.imageDataUrl,alt:a.cardData.cardName||"Scanned card",className:"w-full h-full object-cover transition-transform duration-200 hover:scale-105"})}),(0,d.jsxs)("div",{className:"p-4 space-y-3",children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("h4",{className:"font-medium text-gray-900 text-sm leading-tight line-clamp-2",children:a.cardData.cardName||"Unknown Card"}),a.cardData.setName&&(0,d.jsx)("p",{className:"text-xs text-gray-500 mt-1 line-clamp-1",children:a.cardData.setName})]}),(0,d.jsx)("div",{className:`px-2 py-1 rounded-full text-xs font-medium text-white flex-shrink-0 ${(a=>a?a>=.9?"bg-green-500":a>=.7?"bg-yellow-500":"bg-red-500":"bg-gray-400")(a.cardData.confidence)}`,children:(a=>a?`${Math.round(100*a)}%`:"Unknown")(a.cardData.confidence)})]}),(0,d.jsxs)("div",{className:"flex items-center justify-between text-xs text-gray-500",children:[(0,d.jsx)("span",{className:"truncate",children:a.cardData.game||"Unknown Game"}),a.cardData.rarity&&(0,d.jsx)("span",{className:"capitalize flex-shrink-0 ml-2",children:a.cardData.rarity})]}),(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"text-xs text-gray-400",children:["#",a.queuePosition]}),(0,d.jsx)("div",{className:"text-xs text-gray-400",children:new Date(a.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})]})]},a.id))}),(0,d.jsx)("div",{className:"bg-white rounded-xl shadow-sm border border-gray-100 p-4 sm:p-6",children:(0,d.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-3 sm:gap-4",children:[(0,d.jsxs)("span",{className:"text-sm font-medium text-gray-900",children:["Total: ",a.length," cards"]}),(0,d.jsxs)("span",{className:"text-sm text-gray-600",children:["Selected: ",g.size]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-3 sm:gap-4",children:[(0,d.jsxs)("span",{className:"flex items-center space-x-1.5 text-xs sm:text-sm",children:[(0,d.jsx)("div",{className:"w-2.5 h-2.5 bg-green-500 rounded-full"}),(0,d.jsx)("span",{className:"text-gray-600",children:"High confidence"})]}),(0,d.jsxs)("span",{className:"flex items-center space-x-1.5 text-xs sm:text-sm",children:[(0,d.jsx)("div",{className:"w-2.5 h-2.5 bg-yellow-500 rounded-full"}),(0,d.jsx)("span",{className:"text-gray-600",children:"Medium"})]}),(0,d.jsxs)("span",{className:"flex items-center space-x-1.5 text-xs sm:text-sm",children:[(0,d.jsx)("div",{className:"w-2.5 h-2.5 bg-red-500 rounded-full"}),(0,d.jsx)("span",{className:"text-gray-600",children:"Low"})]})]})]})})]})},o=({selectedCount:a,onAddToCollection:b,onAddToDeck:c,onAddTags:f,onRemoveSelected:g,collections:h,decks:i,isProcessing:j})=>{let[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(""),[o,p]=(0,e.useState)(!1),[q,r]=(0,e.useState)(""),[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)("");if(0===a)return null;let w=()=>{m.trim()&&(f(m.split(",").map(a=>a.trim()).filter(Boolean)),n(""),l(!1))};return(0,d.jsxs)("div",{className:"bg-white border-t border-gray-200 px-4 py-6 sm:px-6",children:[(0,d.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6",children:[(0,d.jsxs)("h3",{className:"text-lg sm:text-xl font-semibold text-gray-900",children:["Bulk Operations (",a," selected)"]}),(0,d.jsx)("button",{onClick:g,className:"self-start sm:self-auto px-4 py-2 text-sm bg-red-50 text-red-700 rounded-lg hover:bg-red-100 active:bg-red-200 transition-colors font-medium",disabled:j,children:"Remove Selected"})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsx)("h4",{className:"font-medium text-gray-900 text-base",children:"Add to Collection"}),h.length>0&&(0,d.jsxs)("select",{className:"w-full px-4 py-3 border border-gray-300 rounded-xl text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white",onChange:a=>a.target.value&&b(a.target.value),defaultValue:"",disabled:j,children:[(0,d.jsx)("option",{value:"",children:"Select existing collection..."}),h.map(a=>(0,d.jsx)("option",{value:a.id,children:a.name},a.id))]}),o?(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsx)("input",{type:"text",value:q,onChange:a=>r(a.target.value),placeholder:"Collection name...",className:"w-full px-4 py-3 border border-gray-300 rounded-xl text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500",disabled:j}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)("button",{onClick:()=>{q.trim()&&(b("",q.trim()),r(""),p(!1))},className:"flex-1 px-4 py-3 bg-blue-600 text-white rounded-xl text-sm font-medium hover:bg-blue-700 active:bg-blue-800 disabled:bg-gray-400 transition-colors",disabled:!q.trim()||j,children:"Create"}),(0,d.jsx)("button",{onClick:()=>p(!1),className:"px-4 py-3 bg-gray-100 text-gray-700 rounded-xl text-sm font-medium hover:bg-gray-200 active:bg-gray-300 transition-colors",disabled:j,children:"Cancel"})]})]}):(0,d.jsx)("button",{onClick:()=>p(!0),className:"w-full px-4 py-3 border-2 border-dashed border-gray-300 rounded-xl text-sm text-gray-600 hover:border-blue-400 hover:text-blue-600 active:border-blue-500 transition-colors font-medium",disabled:j,children:"+ Create New Collection"})]}),(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsx)("h4",{className:"font-medium text-gray-900 text-base",children:"Add to Deck"}),i.length>0&&(0,d.jsxs)("select",{className:"w-full px-4 py-3 border border-gray-300 rounded-xl text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white",onChange:a=>a.target.value&&c(a.target.value),defaultValue:"",disabled:j,children:[(0,d.jsx)("option",{value:"",children:"Select existing deck..."}),i.map(a=>(0,d.jsx)("option",{value:a.id,children:a.name},a.id))]}),s?(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsx)("input",{type:"text",value:u,onChange:a=>v(a.target.value),placeholder:"Deck name...",className:"w-full px-4 py-3 border border-gray-300 rounded-xl text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500",disabled:j}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)("button",{onClick:()=>{u.trim()&&(c("",u.trim()),v(""),t(!1))},className:"flex-1 px-4 py-3 bg-purple-600 text-white rounded-xl text-sm font-medium hover:bg-purple-700 active:bg-purple-800 disabled:bg-gray-400 transition-colors",disabled:!u.trim()||j,children:"Create"}),(0,d.jsx)("button",{onClick:()=>t(!1),className:"px-4 py-3 bg-gray-100 text-gray-700 rounded-xl text-sm font-medium hover:bg-gray-200 active:bg-gray-300 transition-colors",disabled:j,children:"Cancel"})]})]}):(0,d.jsx)("button",{onClick:()=>t(!0),className:"w-full px-4 py-3 border-2 border-dashed border-gray-300 rounded-xl text-sm text-gray-600 hover:border-purple-400 hover:text-purple-600 active:border-purple-500 transition-colors font-medium",disabled:j,children:"+ Create New Deck"})]}),(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsx)("h4",{className:"font-medium text-gray-900 text-base",children:"Add Tags"}),k?(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsx)("input",{type:"text",value:m,onChange:a=>n(a.target.value),placeholder:"Enter tags (comma-separated)...",className:"w-full px-4 py-3 border border-gray-300 rounded-xl text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500",disabled:j,onKeyPress:a=>"Enter"===a.key&&w()}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)("button",{onClick:w,className:"flex-1 px-4 py-3 bg-green-600 text-white rounded-xl text-sm font-medium hover:bg-green-700 active:bg-green-800 disabled:bg-gray-400 transition-colors",disabled:!m.trim()||j,children:"Add Tags"}),(0,d.jsx)("button",{onClick:()=>l(!1),className:"px-4 py-3 bg-gray-100 text-gray-700 rounded-xl text-sm font-medium hover:bg-gray-200 active:bg-gray-300 transition-colors",disabled:j,children:"Cancel"})]})]}):(0,d.jsx)("button",{onClick:()=>l(!0),className:"w-full px-4 py-3 border-2 border-dashed border-gray-300 rounded-xl text-sm text-gray-600 hover:border-green-400 hover:text-green-600 active:border-green-500 transition-colors font-medium",disabled:j,children:"+ Add Tags"}),(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsx)("p",{className:"text-xs text-gray-500 font-medium",children:"Quick Tags:"}),(0,d.jsx)("div",{className:"flex flex-wrap gap-2",children:["Foil","Mint","Near Mint","Played","Favorite"].map(a=>(0,d.jsx)("button",{onClick:()=>f([a]),className:"px-3 py-2 bg-gray-100 text-gray-700 rounded-lg text-xs font-medium hover:bg-gray-200 active:bg-gray-300 transition-colors",disabled:j,children:a},a))})]})]})]}),j&&(0,d.jsx)("div",{className:"flex items-center justify-center py-8 mt-6 border-t border-gray-100",children:(0,d.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,d.jsx)("div",{className:"animate-spin rounded-full h-6 w-6 border-2 border-blue-600 border-t-transparent"}),(0,d.jsx)("span",{className:"text-sm text-gray-600 font-medium",children:"Processing..."})]})})]})};class p{static generateTags(a){let b=[],c=[];if(a.game){let d=this.normalizeGame(a.game);b.push(d),c.push(`Game: ${d}`)}if(a.rarity){let d=this.normalizeRarity(a.rarity);b.push(d),c.push(`Rarity: ${d}`),this.isHighValueRarity(a.rarity)&&(b.push("High Value"),c.push("High-value rarity detected"))}if(a.setName){let d=this.generateSetTag(a.setName);d&&(b.push(d),c.push(`Set: ${d}`));let e=this.detectSpecialSets(a.setName);b.push(...e),e.length>0&&c.push(`Special sets: ${e.join(", ")}`)}if(a.cardType){let d=this.normalizeCardType(a.cardType);if(d&&(b.push(d),c.push(`Type: ${d}`)),a.power&&a.toughness){b.push("Creature");let d=this.categorizeCreaturePower(a.power,a.toughness);d&&(b.push(d),c.push(`Power level: ${d}`))}}if(a.manaCost){let d=this.analyzeManaColor(a.manaCost);b.push(...d),d.length>0&&c.push(`Mana colors: ${d.join(", ")}`)}if(a.element){let d=this.normalizeElement(a.element);d&&(b.push(d),c.push(`Element: ${d}`))}if(a.cardName){let d=this.analyzeCardName(a.cardName);b.push(...d),d.length>0&&c.push(`Name analysis: ${d.join(", ")}`)}return{tags:Array.from(new Set(b)).filter(a=>a.length>0),confidence:.8,reasoning:c.join("; ")}}static normalizeGame(a){return({"magic the gathering":"MTG",magic:"MTG",mtg:"MTG",pokemon:"Pokemon",pokémon:"Pokemon",lorcana:"Lorcana","disney lorcana":"Lorcana"})[a.toLowerCase()]||a}static normalizeRarity(a){return({c:"Common",common:"Common",u:"Uncommon",uncommon:"Uncommon",r:"Rare",rare:"Rare",m:"Mythic",mythic:"Mythic","mythic rare":"Mythic",sr:"Super Rare","super rare":"Super Rare","ultra rare":"Ultra Rare","secret rare":"Secret Rare",legendary:"Legendary",enchanted:"Enchanted"})[a.toLowerCase()]||a}static isHighValueRarity(a){return["mythic","super rare","ultra rare","secret rare","legendary","enchanted"].some(b=>a.toLowerCase().includes(b))}static generateSetTag(a){return({"dominaria united":"DMU","brothers war":"BRO","phyrexia all will be one":"ONE","march of the machine":"MOM","battle for zendikar":"BFZ","sword shield":"SWSH","sun moon":"SM","the first chapter":"TFC"})[a.toLowerCase()]||null}static detectSpecialSets(a){let b=[],c=a.toLowerCase();return c.includes("promo")&&b.push("Promo"),c.includes("prerelease")&&b.push("Prerelease"),c.includes("foil")&&b.push("Foil"),c.includes("alternate art")&&b.push("Alt Art"),c.includes("full art")&&b.push("Full Art"),c.includes("borderless")&&b.push("Borderless"),c.includes("showcase")&&b.push("Showcase"),c.includes("collector")&&b.push("Collector"),b}static normalizeCardType(a){let b=a.toLowerCase();for(let[a,c]of Object.entries({creature:"Creature",instant:"Instant",sorcery:"Sorcery",artifact:"Artifact",enchantment:"Enchantment",planeswalker:"Planeswalker",land:"Land","basic land":"Basic Land",legendary:"Legendary"}))if(b.includes(a))return c;return null}static categorizeCreaturePower(a,b){let c=parseInt(a),d=parseInt(b);if(isNaN(c)||isNaN(d))return null;let e=c+d;return e>=10?"High Power":e>=6?"Mid Power":e>=3?"Low Power":"Utility"}static analyzeManaColor(a){let b=[];return(a.includes("W")||a.includes("white"))&&b.push("White"),(a.includes("U")||a.includes("blue"))&&b.push("Blue"),(a.includes("B")||a.includes("black"))&&b.push("Black"),(a.includes("R")||a.includes("red"))&&b.push("Red"),(a.includes("G")||a.includes("green"))&&b.push("Green"),b.length>1?b.push("Multicolor"):0===b.length&&a.match(/\d+/)&&b.push("Colorless"),b}static normalizeElement(a){return({fire:"Fire",water:"Water",grass:"Grass",electric:"Electric",psychic:"Psychic",fighting:"Fighting",darkness:"Dark",metal:"Steel",fairy:"Fairy",dragon:"Dragon",colorless:"Colorless"})[a.toLowerCase()]||a}static analyzeCardName(a){let b=[],c=a.toLowerCase();return(c.includes("legendary")||this.isLegendaryName(c))&&b.push("Legendary"),(c.includes("foil")||c.includes("holo"))&&b.push("Foil"),(c.includes("ex")||c.includes("gx")||c.includes("vmax"))&&b.push("Special"),b}static isLegendaryName(a){return[/\b(jace|chandra|garruk|liliana|ajani|elspeth|vraska|nissa|gideon|teferi)\b/,/\b(pikachu|charizard|mewtwo|mew|rayquaza|arceus)\b/,/\b(mickey|minnie|donald|goofy|elsa|anna|simba)\b/].some(b=>b.test(a))}}let q=()=>{let a=(0,f.useNavigate)(),[b,c]=(0,e.useState)("mode-selection"),[h,i]=(0,e.useState)(null),[j,k]=(0,e.useState)([]),[l,q]=(0,e.useState)(new Set),[r,s]=(0,e.useState)(!1),[t]=(0,e.useState)([{id:"1",name:"My Collection"},{id:"2",name:"Trade Binder"},{id:"3",name:"Deck Ideas"}]),[u]=(0,e.useState)([{id:"1",name:"Standard Deck"},{id:"2",name:"Commander"},{id:"3",name:"Draft Picks"}]),[v]=(0,e.useState)(new Map);(0,e.useEffect)(()=>()=>{v.forEach(a=>{a.startsWith("blob:")&&URL.revokeObjectURL(a)}),v.clear()},[v]);let w=(0,e.useCallback)(a=>{i(a),c("scanning")},[]),x=(0,e.useCallback)(a=>{let b=p.generateTags(a.cardData),c={...a,autoTags:b.tags};v.set(a.id,a.imageDataUrl),k(a=>[...a,c]),k(a=>a.length>100?(a.slice(0,a.length-100).forEach(a=>{let b=v.get(a.id);b&&b.startsWith("blob:")&&URL.revokeObjectURL(b),v.delete(a.id)}),a.slice(a.length-100)):a)},[v]),y=(0,e.useCallback)(a=>{k(b=>b.filter(b=>b.id!==a)),q(b=>{let c=new Set(b);return c.delete(a),c});let b=v.get(a);b&&b.startsWith("blob:")&&URL.revokeObjectURL(b),v.delete(a)},[v]),z=(0,e.useCallback)(()=>{j.forEach(a=>{let b=v.get(a.id);b&&b.startsWith("blob:")&&URL.revokeObjectURL(b)}),v.clear(),k([]),q(new Set)},[j,v]),A=(0,e.useCallback)((a,b)=>{q(c=>{let d=new Set(c);return b?d.add(a):d.delete(a),d})},[]),B=(0,e.useCallback)(a=>{console.log("Viewing card:",a)},[]),C=(0,e.useCallback)(async(a,b)=>{if(0!==l.size){s(!0);try{console.log("Adding to collection:",{collectionId:a,newCollectionName:b,cards:Array.from(l)}),await new Promise(a=>setTimeout(a,1e3)),alert(`Added ${l.size} cards to ${b||"collection"}`)}catch(a){console.error("Failed to add to collection:",a),alert("Failed to add cards to collection")}finally{s(!1)}}},[l]),D=(0,e.useCallback)(async(a,b)=>{if(0!==l.size){s(!0);try{console.log("Adding to deck:",{deckId:a,newDeckName:b,cards:Array.from(l)}),await new Promise(a=>setTimeout(a,1e3)),alert(`Added ${l.size} cards to ${b||"deck"}`)}catch(a){console.error("Failed to add to deck:",a),alert("Failed to add cards to deck")}finally{s(!1)}}},[l]),E=(0,e.useCallback)(async a=>{if(0!==l.size){s(!0);try{console.log("Adding tags:",{tags:a,cards:Array.from(l)}),await new Promise(a=>setTimeout(a,1e3)),alert(`Added tags "${a.join(", ")}" to ${l.size} cards`)}catch(a){console.error("Failed to add tags:",a),alert("Failed to add tags")}finally{s(!1)}}},[l]),F=(0,e.useCallback)(()=>{l.forEach(a=>y(a))},[l,y]),G=(0,e.useCallback)(async()=>{if(0===j.length)return void a("/scanner");c("processing"),s(!0);try{switch(h){case"add-to-database":console.log("Adding all cards to database:",j);break;case"search-collections":console.log("Searching collections for:",j);break;case"price-check":console.log("Getting prices for:",j);break;case"deck-building":console.log("Adding to deck:",j)}await new Promise(a=>setTimeout(a,2e3)),c("complete"),setTimeout(()=>{a("/scanner")},3e3)}catch(a){console.error("Failed to process cards:",a),alert("Failed to process cards"),c("review")}finally{s(!1)}},[j,h,a]),H=(0,e.useCallback)(()=>{c("scanning")},[]),I=(0,e.useCallback)(()=>{c("review")},[]),J=(0,e.useCallback)(a=>{console.error("Scanner error:",a),alert(a)},[]);return(0,d.jsx)("div",{className:"min-h-screen bg-gray-50",children:(0,d.jsx)("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4 sm:py-6",children:(()=>{switch(b){case"mode-selection":return(0,d.jsx)(g,{onModeSelect:w});case"scanning":return(0,d.jsxs)("div",{className:"space-y-6",children:[(0,d.jsx)("div",{className:"bg-white rounded-xl shadow-sm border border-gray-100 p-4 sm:p-6",children:(0,d.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsxs)("h2",{className:"text-xl sm:text-2xl font-bold text-gray-900 mb-2",children:["add-to-database"===h&&"\uD83D\uDCDA Adding Cards to Database","search-collections"===h&&"\uD83D\uDD0D Searching Collections","price-check"===h&&"\uD83D\uDCB0 Price Checking Cards","deck-building"===h&&"\uD83C\uDFAF Building Deck"]}),(0,d.jsx)("p",{className:"text-gray-600 text-sm sm:text-base",children:"Position cards clearly within the camera frame"})]}),(0,d.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2",children:[j.length>0&&(0,d.jsx)("button",{onClick:I,className:"w-full sm:w-auto bg-green-600 text-white px-4 py-3 sm:px-6 sm:py-2 rounded-xl font-medium hover:bg-green-700 active:bg-green-800 transition-colors text-sm sm:text-base shadow-lg",children:(0,d.jsxs)("div",{className:"flex items-center justify-center space-x-2",children:[(0,d.jsx)("span",{children:"Review Queue"}),(0,d.jsx)("span",{className:"bg-green-700 px-2 py-0.5 rounded-full text-xs",children:j.length})]})}),(0,d.jsx)("button",{onClick:()=>c("mode-selection"),className:"w-full sm:w-auto bg-gray-100 text-gray-700 px-4 py-3 sm:px-6 sm:py-2 rounded-xl font-medium hover:bg-gray-200 active:bg-gray-300 transition-colors text-sm sm:text-base",children:"Change Mode"})]})]})}),(0,d.jsx)(m,{onCardScanned:x,onError:J,isActive:"scanning"===b,maxQueueSize:100})]});case"review":return(0,d.jsxs)("div",{className:"space-y-6",children:[(0,d.jsx)("div",{className:"bg-white rounded-xl shadow-sm border border-gray-100 p-4 sm:p-6",children:(0,d.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("h2",{className:"text-xl sm:text-2xl font-bold text-gray-900 mb-2",children:"Review Scanned Cards"}),(0,d.jsx)("p",{className:"text-gray-600 text-sm sm:text-base",children:"Select cards and choose where to add them"})]}),(0,d.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2",children:[(0,d.jsx)("button",{onClick:H,className:"w-full sm:w-auto bg-blue-600 text-white px-4 py-3 sm:px-6 sm:py-2 rounded-xl font-medium hover:bg-blue-700 active:bg-blue-800 transition-colors text-sm sm:text-base",children:"Continue Scanning"}),(0,d.jsx)("button",{onClick:G,disabled:0===j.length||r,className:"w-full sm:w-auto bg-green-600 text-white px-4 py-3 sm:px-6 sm:py-2 rounded-xl font-medium hover:bg-green-700 active:bg-green-800 disabled:bg-gray-400 disabled:cursor-not-allowed transition-colors text-sm sm:text-base shadow-lg",children:r?(0,d.jsxs)("div",{className:"flex items-center justify-center space-x-2",children:[(0,d.jsx)("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-white border-t-transparent"}),(0,d.jsx)("span",{children:"Processing..."})]}):"Finish & Process"})]})]})}),(0,d.jsx)(n,{cards:j,onRemoveCard:y,onClearQueue:z,onCardSelect:A,selectedCards:l,onViewCard:B}),(0,d.jsx)(o,{selectedCount:l.size,onAddToCollection:C,onAddToDeck:D,onAddTags:E,onRemoveSelected:F,collections:t,decks:u,isProcessing:r})]});case"processing":return(0,d.jsx)("div",{className:"flex items-center justify-center min-h-[60vh] px-4",children:(0,d.jsxs)("div",{className:"text-center max-w-md mx-auto",children:[(0,d.jsx)("div",{className:"animate-spin rounded-full h-16 w-16 sm:h-20 sm:w-20 border-4 border-blue-600 border-t-transparent mx-auto mb-6"}),(0,d.jsx)("h3",{className:"text-xl sm:text-2xl font-semibold text-gray-900 mb-3",children:"Processing Cards..."}),(0,d.jsxs)("p",{className:"text-gray-600 text-sm sm:text-base mb-4",children:["Adding ",j.length," cards to your collection"]}),(0,d.jsx)("div",{className:"bg-gray-100 rounded-full h-2 w-full max-w-xs mx-auto",children:(0,d.jsx)("div",{className:"bg-blue-600 h-2 rounded-full animate-pulse",style:{width:"60%"}})})]})});case"complete":return(0,d.jsx)("div",{className:"flex items-center justify-center min-h-[60vh] px-4",children:(0,d.jsxs)("div",{className:"text-center max-w-md mx-auto",children:[(0,d.jsx)("div",{className:"text-6xl sm:text-7xl mb-6",children:"✅"}),(0,d.jsx)("h3",{className:"text-xl sm:text-2xl font-semibold text-green-600 mb-3",children:"Success!"}),(0,d.jsxs)("p",{className:"text-gray-600 text-sm sm:text-base mb-6",children:["Successfully processed ",j.length," cards"]}),(0,d.jsx)("div",{className:"bg-green-50 border border-green-200 rounded-xl p-4 mb-6",children:(0,d.jsx)("p",{className:"text-green-800 text-sm font-medium",children:"\uD83C\uDF89 All cards have been added to your collection!"})}),(0,d.jsx)("p",{className:"text-sm text-gray-500",children:"Redirecting to scanner..."})]})});default:return null}})()})})},r=()=>(0,d.jsx)(q,{})},907:(a,b,c)=>{"use strict";c.d(b,{A:()=>g});var d=c(8732);c(2015);var e=c(4670),f=c(4822);let g=()=>{let{user:a}=(0,e.A)(),b=[{title:"Collections",value:"0",icon:(0,d.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),color:"primary"},{title:"Decks",value:"0",icon:(0,d.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),color:"accent"},{title:"Total Cards",value:"0",icon:(0,d.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 4V2a1 1 0 011-1h8a1 1 0 011 1v2M7 4H5a2 2 0 00-2 2v10a2 2 0 002 2h14a2 2 0 002-2V6a2 2 0 00-2-2h-2M7 4v6l2-2 2 2V4"})}),color:"primary"},{title:"Total Value",value:"$0",icon:(0,d.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1"})}),color:"accent"}],c=[{title:"Scan Cards",description:"Use OCR to quickly add cards",href:"/scanner",icon:(0,d.jsxs)("svg",{className:"w-8 h-8",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 9a2 2 0 012-2h.93a2 2 0 001.664-.89l.812-1.22A2 2 0 0110.07 4h3.86a2 2 0 011.664.89l.812 1.22A2 2 0 0018.07 7H19a2 2 0 012 2v9a2 2 0 01-2 2H5a2 2 0 01-2-2V9z"}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 13a3 3 0 11-6 0 3 3 0 016 0z"})]}),gradient:"from-primary-500 to-accent-500"},{title:"Browse Cards",description:"Explore your collection",href:"/cards",icon:(0,d.jsx)("svg",{className:"w-8 h-8",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),gradient:"from-accent-500 to-primary-500"},{title:"Manage Collections",description:"Organize your cards",href:"/collections",icon:(0,d.jsx)("svg",{className:"w-8 h-8",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),gradient:"from-primary-600 to-accent-400"}];return(0,d.jsxs)("div",{className:"space-y-6",children:[(0,d.jsxs)("div",{className:"bg-gradient-to-br from-primary-500 via-primary-600 to-accent-500 p-6 rounded-2xl text-white shadow-lg",children:[(0,d.jsxs)("h1",{className:"text-2xl font-bold mb-2",children:["Welcome back, ",a?.firstName||a?.username,"! \uD83D\uDC4B"]}),(0,d.jsx)("p",{className:"text-primary-100",children:"Ready to manage your card collection?"})]}),(0,d.jsx)("div",{className:"grid grid-cols-2 gap-4",children:b.map((a,b)=>(0,d.jsxs)("div",{className:"bg-white dark:bg-surface-800 p-4 rounded-xl shadow-sm border border-surface-200 dark:border-surface-700 transition-colors",children:[(0,d.jsx)("div",{className:`inline-flex items-center justify-center w-10 h-10 rounded-lg mb-3 ${"primary"===a.color?"bg-primary-100 text-primary-600 dark:bg-primary-900/30 dark:text-primary-400":"bg-accent-100 text-accent-600 dark:bg-accent-900/30 dark:text-accent-400"}`,children:a.icon}),(0,d.jsx)("p",{className:"text-2xl font-bold text-surface-900 dark:text-white",children:a.value}),(0,d.jsx)("p",{className:"text-sm text-surface-600 dark:text-surface-400",children:a.title})]},a.title))}),(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsx)("h2",{className:"text-lg font-semibold text-surface-900 dark:text-white",children:"Quick Actions"}),c.map((a,b)=>(0,d.jsx)(f.Link,{to:a.href,className:"block bg-white dark:bg-surface-800 p-4 rounded-xl shadow-sm border border-surface-200 dark:border-surface-700 hover:shadow-md transition-all duration-200 active:scale-98",children:(0,d.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,d.jsx)("div",{className:`w-12 h-12 bg-gradient-to-r ${a.gradient} rounded-xl flex items-center justify-center text-white shadow-md`,children:a.icon}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("h3",{className:"font-semibold text-surface-900 dark:text-white",children:a.title}),(0,d.jsx)("p",{className:"text-sm text-surface-600 dark:text-surface-400",children:a.description})]}),(0,d.jsx)("svg",{className:"w-5 h-5 text-surface-400 dark:text-surface-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})},a.title))]}),(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsx)("h2",{className:"text-lg font-semibold text-surface-900 dark:text-white",children:"Recent Activity"}),(0,d.jsx)("div",{className:"bg-white dark:bg-surface-800 p-6 rounded-xl shadow-sm border border-surface-200 dark:border-surface-700 transition-colors",children:(0,d.jsxs)("div",{className:"text-center",children:[(0,d.jsx)("div",{className:"w-16 h-16 bg-surface-100 dark:bg-surface-700 rounded-2xl flex items-center justify-center mx-auto mb-4",children:(0,d.jsx)("svg",{className:"w-8 h-8 text-surface-400 dark:text-surface-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})})}),(0,d.jsx)("p",{className:"text-surface-600 dark:text-surface-400 mb-4",children:"No recent activity yet"}),(0,d.jsx)("p",{className:"text-sm text-surface-500 dark:text-surface-500",children:"Start by scanning some cards or creating a collection!"})]})})]})]})}},1025:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"warnOnce",{enumerable:!0,get:function(){return c}});let c=a=>{}},1169:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"addLocale",{enumerable:!0,get:function(){return d}}),c(7779);let d=function(a){for(var b=arguments.length,c=Array(b>1?b-1:0),d=1;d{"use strict";function c(){let a=Object.create(null);return{on(b,c){(a[b]||(a[b]=[])).push(c)},off(b,c){a[b]&&a[b].splice(a[b].indexOf(c)>>>0,1)},emit(b){for(var c=arguments.length,d=Array(c>1?c-1:0),e=1;e{a(...d)})}}}Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"default",{enumerable:!0,get:function(){return c}})},1219:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"BloomFilter",{enumerable:!0,get:function(){return d}});class d{static from(a,b){void 0===b&&(b=1e-4);let c=new d(a.length,b);for(let b of a)c.add(b);return c}export(){let a={numItems:this.numItems,errorRate:this.errorRate,numBits:this.numBits,numHashes:this.numHashes,bitArray:this.bitArray};if(this.errorRate<1e-4){let b=JSON.stringify(a),d=c(8550).sync(b);d>1024&&console.warn("Creating filter with error rate less than 0.1% (0.001) can increase the size dramatically proceed with caution. Received error rate "+this.errorRate+" resulted in size "+b.length+" bytes, "+d+" bytes (gzip)")}return a}import(a){this.numItems=a.numItems,this.errorRate=a.errorRate,this.numBits=a.numBits,this.numHashes=a.numHashes,this.bitArray=a.bitArray}add(a){this.getHashValues(a).forEach(a=>{this.bitArray[a]=1})}contains(a){return this.getHashValues(a).every(a=>this.bitArray[a])}getHashValues(a){let b=[];for(let c=1;c<=this.numHashes;c++){let d=function(a){let b=0;for(let c=0;c>>13,b=Math.imul(b,0x5bd1e995);return b>>>0}(""+a+c)%this.numBits;b.push(d)}return b}constructor(a,b=1e-4){this.numItems=a,this.errorRate=b,this.numBits=Math.ceil(-(a*Math.log(b))/(Math.log(2)*Math.log(2))),this.numHashes=Math.ceil(this.numBits/a*Math.log(2)),this.bitArray=Array(this.numBits).fill(0)}}},1484:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),!function(a,b){for(var c in b)Object.defineProperty(a,c,{enumerable:!0,get:b[c]})}(b,{default:function(){return r},handleClientScriptLoad:function(){return o},initScriptLoader:function(){return p}});let d=c(7020),e=c(3147),f=c(8732),g=d._(c(2326)),h=e._(c(2015)),i=c(1523),j=c(8941),k=c(4841),l=new Map,m=new Set,n=a=>{let{src:b,id:c,onLoad:d=()=>{},onReady:e=null,dangerouslySetInnerHTML:f,children:h="",strategy:i="afterInteractive",onError:k,stylesheets:n}=a,o=c||b;if(o&&m.has(o))return;if(l.has(b)){m.add(o),l.get(b).then(d,k);return}let p=()=>{e&&e(),m.add(o)},q=document.createElement("script"),r=new Promise((a,b)=>{q.addEventListener("load",function(b){a(),d&&d.call(this,b),p()}),q.addEventListener("error",function(a){b(a)})}).catch(function(a){k&&k(a)});f?(q.innerHTML=f.__html||"",p()):h?(q.textContent="string"==typeof h?h:Array.isArray(h)?h.join(""):"",p()):b&&(q.src=b,l.set(b,r)),(0,j.setAttributesFromProps)(q,a),"worker"===i&&q.setAttribute("type","text/partytown"),q.setAttribute("data-nscript",i),n&&(a=>{if(g.default.preinit)return a.forEach(a=>{g.default.preinit(a,{as:"style"})})})(n),document.body.appendChild(q)};function o(a){let{strategy:b="afterInteractive"}=a;"lazyOnload"===b?window.addEventListener("load",()=>{(0,k.requestIdleCallback)(()=>n(a))}):n(a)}function p(a){a.forEach(o),[...document.querySelectorAll('[data-nscript="beforeInteractive"]'),...document.querySelectorAll('[data-nscript="beforePageRender"]')].forEach(a=>{let b=a.id||a.getAttribute("src");m.add(b)})}function q(a){let{id:b,src:c="",onLoad:d=()=>{},onReady:e=null,strategy:j="afterInteractive",onError:l,stylesheets:o,...p}=a,{updateScripts:q,scripts:r,getIsSsr:s,appDir:t,nonce:u}=(0,h.useContext)(i.HeadManagerContext);u=p.nonce||u;let v=(0,h.useRef)(!1);(0,h.useEffect)(()=>{let a=b||c;v.current||(e&&a&&m.has(a)&&e(),v.current=!0)},[e,b,c]);let w=(0,h.useRef)(!1);if((0,h.useEffect)(()=>{if(!w.current){if("afterInteractive"===j)n(a);else"lazyOnload"===j&&("complete"===document.readyState?(0,k.requestIdleCallback)(()=>n(a)):window.addEventListener("load",()=>{(0,k.requestIdleCallback)(()=>n(a))}));w.current=!0}},[a,j]),("beforeInteractive"===j||"worker"===j)&&(q?(r[j]=(r[j]||[]).concat([{id:b,src:c,onLoad:d,onReady:e,onError:l,...p,nonce:u}]),q(r)):s&&s()?m.add(b||c):s&&!s()&&n({...a,nonce:u})),t){if(o&&o.forEach(a=>{g.default.preinit(a,{as:"style"})}),"beforeInteractive"===j)if(!c)return p.dangerouslySetInnerHTML&&(p.children=p.dangerouslySetInnerHTML.__html,delete p.dangerouslySetInnerHTML),(0,f.jsx)("script",{nonce:u,dangerouslySetInnerHTML:{__html:"(self.__next_s=self.__next_s||[]).push("+JSON.stringify([0,{...p,id:b}])+")"}});else return g.default.preload(c,p.integrity?{as:"script",integrity:p.integrity,nonce:u,crossOrigin:p.crossOrigin}:{as:"script",nonce:u,crossOrigin:p.crossOrigin}),(0,f.jsx)("script",{nonce:u,dangerouslySetInnerHTML:{__html:"(self.__next_s=self.__next_s||[]).push("+JSON.stringify([c,{...p,id:b}])+")"}});"afterInteractive"===j&&c&&g.default.preload(c,p.integrity?{as:"script",integrity:p.integrity,nonce:u,crossOrigin:p.crossOrigin}:{as:"script",nonce:u,crossOrigin:p.crossOrigin})}return null}Object.defineProperty(q,"__nextScript",{value:!0});let r=q;("function"==typeof b.default||"object"==typeof b.default&&null!==b.default)&&void 0===b.default.__esModule&&(Object.defineProperty(b.default,"__esModule",{value:!0}),Object.assign(b.default,b),a.exports=b.default)},1523:(a,b,c)=>{"use strict";a.exports=c(3885).vendored.contexts.HeadManagerContext},1735:(a,b,c)=>{"use strict";c.d(b,{Ay:()=>p});let d="https://api.scryfall.com",e="https://api.lorcast.com/v0",f="https://api.lorcana-api.com",g="https://tcg-vault.vercel.app/api/proxy/lorcana";class h{constructor(a,b){this.requests=[],this.maxRequests=a,this.timeWindow=b}async waitForSlot(){let a=Date.now();if(this.requests=this.requests.filter(b=>a-b=this.maxRequests){let b=this.requests[0],c=this.timeWindow-(a-b);await new Promise(a=>setTimeout(a,c))}this.requests.push(a)}}let i=new h(10,1e3),j=new h(5,1e3),k=new h(10,1e3),l={async searchCards(a,b=1){await i.waitForSlot();try{let c=await fetch(`${d}/cards/search?q=${encodeURIComponent(a)}&page=${b}`);if(!c.ok)throw Error(`Scryfall API error: ${c.status}`);return(await c.json()).data.map(a=>({id:a.id,name:a.name,set_name:a.set_name,set_code:a.set,card_number:a.collector_number,rarity:a.rarity,game:"MTG",mana_cost:a.mana_cost,cmc:a.cmc,card_type:a.type_line,colors:a.colors,oracle_text:a.oracle_text,power:a.power,toughness:a.toughness,image_url:a.image_uris?.normal,stock_image_url:a.image_uris?.normal,current_price:a.prices?.usd?parseFloat(a.prices.usd):void 0,market_price:a.prices?.usd_foil?parseFloat(a.prices.usd_foil):void 0,verified:!0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}))}catch(a){return console.error("Error fetching MTG cards:",a),[]}},async getCardByName(a){await i.waitForSlot();try{let b=await fetch(`${d}/cards/named?fuzzy=${encodeURIComponent(a)}`);if(!b.ok)return null;let c=await b.json();return{id:c.id,name:c.name,set_name:c.set_name,set_code:c.set,card_number:c.collector_number,rarity:c.rarity,game:"MTG",mana_cost:c.mana_cost,cmc:c.cmc,card_type:c.type_line,colors:c.colors,oracle_text:c.oracle_text,power:c.power,toughness:c.toughness,image_url:c.image_uris?.normal,stock_image_url:c.image_uris?.normal,current_price:c.prices?.usd?parseFloat(c.prices.usd):void 0,market_price:c.prices?.usd_foil?parseFloat(c.prices.usd_foil):void 0,verified:!0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}}catch(a){return console.error("Error fetching MTG card:",a),null}},async getRandomCards(a=20){await i.waitForSlot();try{let b=await fetch(`${d}/cards/random?q=game:paper&page_size=${a}`);if(!b.ok)throw Error(`Scryfall API error: ${b.status}`);let c=await b.json();return(Array.isArray(c)?c:[c]).map(a=>({id:a.id,name:a.name,set_name:a.set_name,set_code:a.set,card_number:a.collector_number,rarity:a.rarity,game:"MTG",mana_cost:a.mana_cost,cmc:a.cmc,card_type:a.type_line,colors:a.colors,oracle_text:a.oracle_text,power:a.power,toughness:a.toughness,image_url:a.image_uris?.normal,stock_image_url:a.image_uris?.normal,current_price:a.prices?.usd?parseFloat(a.prices.usd):void 0,market_price:a.prices?.usd_foil?parseFloat(a.prices.usd_foil):void 0,verified:!0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}))}catch(a){return console.error("Error fetching random MTG cards:",a),[]}}},m={async searchCards(a,b=1){await j.waitForSlot();try{let c=await fetch(`https://api.pokemontcg.io/v2/cards?q=name:${encodeURIComponent(a)}&page=${b}&pageSize=20`);if(!c.ok)throw Error(`Pok\xe9mon API error: ${c.status}`);return(await c.json()).data.map(a=>({id:a.id,name:a.name,set_name:a.set.name,set_code:a.set.id,card_number:a.number,rarity:a.rarity,game:"POKEMON",mana_cost:a.convertedRetreatCost?.toString(),cmc:a.convertedRetreatCost,card_type:a.supertype,colors:a.types||[],oracle_text:a.attacks?.map(a=>`${a.name}: ${a.text}`).join("\n"),power:a.hp,toughness:null,image_url:a.images.small,stock_image_url:a.images.large,current_price:a.cardmarket?.prices?.averageSellPrice||void 0,market_price:a.cardmarket?.prices?.lowPrice||void 0,verified:!0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}))}catch(a){return console.error("Error fetching Pok\xe9mon cards:",a),[]}},async getCardByName(a){let b=await this.searchCards(a,1);return b.length>0?b[0]:null}},n={async searchCards(a){try{let b=await fetch(`https://db.ygoprodeck.com/api/v7/cardinfo.php?fname=${encodeURIComponent(a)}`);if(!b.ok)throw Error(`Yu-Gi-Oh! API error: ${b.status}`);return(await b.json()).data.map(a=>({id:a.id,name:a.name,set_name:a.set_name,set_code:a.set_code,card_number:a.num,rarity:a.rarity,game:"YUGIOH",mana_cost:a.level?.toString(),cmc:a.level,card_type:a.type,colors:[a.attribute],oracle_text:a.desc,power:a.atk?.toString(),toughness:a.def?.toString(),image_url:a.card_images?.[0]?.image_url,stock_image_url:a.card_images?.[0]?.image_url_small,current_price:a.card_prices?.[0]?.amazon_price?parseFloat(a.card_prices[0].amazon_price):void 0,market_price:a.card_prices?.[0]?.cardmarket_price?parseFloat(a.card_prices[0].cardmarket_price):void 0,verified:!0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}))}catch(a){return console.error("Error fetching Yu-Gi-Oh! cards:",a),[]}},async getCardByName(a){let b=await this.searchCards(a);return b.length>0?b[0]:null}},o={async searchCards(a){await k.waitForSlot();try{try{let b=await fetch(`${g}?search=${encodeURIComponent(a)}&api=lorcana`);if(b.ok){let a=await b.json();if(console.log("\uD83D\uDD0D Proxy API response:",JSON.stringify(a,null,2)),a.success&&a.data){let b=a.data.cards||a.data.data||a.data||[];if(b.length>0)return console.log(`✅ Found ${b.length} Lorcana cards via proxy (${a.source})`),console.log("\uD83D\uDD0D First card structure:",JSON.stringify(b[0],null,2)),b.map(a=>({id:a.id||a.uuid||a.card_id||`lorcana-${Math.random()}`,name:a.name||a.card_name||a.title||"",set_name:a.set?.name||a.set_name||a.set_name||"",set_code:a.set?.code||a.set_code||a.set_code||"",card_number:a.number||a.card_number||a.card_num||"",rarity:a.rarity||a.rarity_name||"",game:"LORCANA",mana_cost:a.cost?.toString()||a.mana_cost||a.ink_cost?.toString()||"",cmc:a.cost||a.cmc||a.ink_cost||0,card_type:a.type||a.card_type||a.type_name||"",colors:a.colors||a.ink||[],oracle_text:a.text||a.oracle_text||a.description||a.effect||"",power:a.strength?.toString()||a.power||a.attack?.toString()||"",toughness:a.willpower?.toString()||a.toughness||a.defense?.toString()||"",image_url:a.image_url||a.images?.small||a.images?.png||a.image||"",stock_image_url:a.image_url||a.images?.small||a.images?.png||a.image||"",current_price:a.price?.market||a.current_price||void 0,market_price:a.price?.low||a.market_price||void 0,verified:!0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}))}}}catch(a){console.log("❌ Proxy API failed, trying direct APIs")}try{let b=await fetch(`${f}/cards/fetch?search=name~${encodeURIComponent(a)}`);if(b.ok){let a=await b.json();console.log("\uD83D\uDD0D Direct API response:",JSON.stringify(a,null,2));let c=a.cards||a.data||a||[];if(c.length>0)return console.log(`✅ Found ${c.length} Lorcana cards from direct Lorcana API`),console.log("\uD83D\uDD0D First card structure:",JSON.stringify(c[0],null,2)),c.map(a=>({id:a.id||a.uuid||a.card_id||`lorcana-${Math.random()}`,name:a.name||a.card_name||a.title||"",set_name:a.set?.name||a.set_name||a.set_name||"",set_code:a.set?.code||a.set_code||a.set_code||"",card_number:a.number||a.card_number||a.card_num||"",rarity:a.rarity||a.rarity_name||"",game:"LORCANA",mana_cost:a.cost?.toString()||a.mana_cost||a.ink_cost?.toString()||"",cmc:a.cost||a.cmc||a.ink_cost||0,card_type:a.type||a.card_type||a.type_name||"",colors:a.colors||a.ink||[],oracle_text:a.text||a.oracle_text||a.description||a.effect||"",power:a.strength?.toString()||a.power||a.attack?.toString()||"",toughness:a.willpower?.toString()||a.toughness||a.defense?.toString()||"",image_url:a.image_url||a.images?.small||a.images?.png||a.image||"",stock_image_url:a.image_url||a.images?.small||a.images?.png||a.image||"",current_price:a.price?.market||a.current_price||void 0,market_price:a.price?.low||a.market_price||void 0,verified:!0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}))}}catch(a){console.log("❌ Direct Lorcana API failed")}for(let b of[`/cards?q=${encodeURIComponent(a)}`,`/cards?search=${encodeURIComponent(a)}`,`/cards?query=${encodeURIComponent(a)}`])try{let a=await fetch(`${e}${b}`);if(a.ok){let c=await a.json();console.log(`🔍 Lorcast API response from ${b}:`,JSON.stringify(c,null,2));let d=c.cards||c.data||c||[];if(d.length>0)return console.log(`✅ Found ${d.length} Lorcana cards from Lorcast ${b}`),console.log("\uD83D\uDD0D First card structure:",JSON.stringify(d[0],null,2)),d.map(a=>({id:a.id||a.uuid||a.card_id||`lorcana-${Math.random()}`,name:a.name||a.card_name||a.title||"",set_name:a.set?.name||a.set_name||a.set_name||"",set_code:a.set?.code||a.set_code||a.set_code||"",card_number:a.number||a.card_number||a.card_num||"",rarity:a.rarity||a.rarity_name||"",game:"LORCANA",mana_cost:a.cost?.toString()||a.mana_cost||a.ink_cost?.toString()||"",cmc:a.cost||a.cmc||a.ink_cost||0,card_type:a.type||a.card_type||a.type_name||"",colors:a.colors||a.ink||[],oracle_text:a.text||a.oracle_text||a.description||a.effect||"",power:a.strength?.toString()||a.power||a.attack?.toString()||"",toughness:a.willpower?.toString()||a.toughness||a.defense?.toString()||"",image_url:a.image_url||a.images?.small||a.images?.png||a.image||"",stock_image_url:a.image_url||a.images?.small||a.images?.png||a.image||"",current_price:a.price?.market||a.current_price||void 0,market_price:a.price?.low||a.market_price||void 0,verified:!0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}))}}catch(a){console.log(`❌ Failed to search from Lorcast ${b}:`,a);continue}return console.log("⚠️ No Lorcana cards found from any API"),[]}catch(a){return console.error("Error searching Lorcana cards:",a),[]}},async getCardByName(a){await k.waitForSlot();try{try{let b=await fetch(`${g}?search=${encodeURIComponent(a)}&api=lorcana`);if(b.ok){let c=await b.json();if(c.success&&c.data){let b=c.data.cards||c.data.data||c.data||[];if(b.length>0){let d=b[0];return console.log(`✅ Found Lorcana card "${a}" via proxy (${c.source})`),{id:d.id||d.uuid||d.card_id||`lorcana-${Math.random()}`,name:d.name||d.card_name||d.title||"",set_name:d.set?.name||d.set_name||d.set_name||"",set_code:d.set?.code||d.set_code||d.set_code||"",card_number:d.number||d.card_number||d.card_num||"",rarity:d.rarity||d.rarity_name||"",game:"LORCANA",mana_cost:d.cost?.toString()||d.mana_cost||d.ink_cost?.toString()||"",cmc:d.cost||d.cmc||d.ink_cost||0,card_type:d.type||d.card_type||d.type_name||"",colors:d.colors||d.ink||[],oracle_text:d.text||d.oracle_text||d.description||d.effect||"",power:d.strength?.toString()||d.power||d.attack?.toString()||"",toughness:d.willpower?.toString()||d.toughness||d.defense?.toString()||"",image_url:d.image_url||d.images?.small||d.images?.png||d.image||"",stock_image_url:d.image_url||d.images?.small||d.images?.png||d.image||"",current_price:d.price?.market||d.current_price||void 0,market_price:d.price?.low||d.market_price||void 0,verified:!0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}}}}}catch(a){console.log("❌ Proxy API failed for card lookup, trying direct APIs")}try{let b=await fetch(`${f}/cards/fetch?search=name~${encodeURIComponent(a)}`);if(b.ok){let c=await b.json(),d=c.cards||c.data||c||[];if(d.length>0){let b=d[0];return console.log(`✅ Found Lorcana card "${a}" from direct Lorcana API`),{id:b.id||b.uuid||b.card_id||`lorcana-${Math.random()}`,name:b.name||b.card_name||b.title||"",set_name:b.set?.name||b.set_name||b.set_name||"",set_code:b.set?.code||b.set_code||b.set_code||"",card_number:b.number||b.card_number||b.card_num||"",rarity:b.rarity||b.rarity_name||"",game:"LORCANA",mana_cost:b.cost?.toString()||b.mana_cost||b.ink_cost?.toString()||"",cmc:b.cost||b.cmc||b.ink_cost||0,card_type:b.type||b.card_type||b.type_name||"",colors:b.colors||b.ink||[],oracle_text:b.text||b.oracle_text||b.description||b.effect||"",power:b.strength?.toString()||b.power||b.attack?.toString()||"",toughness:b.willpower?.toString()||b.toughness||b.defense?.toString()||"",image_url:b.image_url||b.images?.small||b.images?.png||b.image||"",stock_image_url:b.image_url||b.images?.small||b.images?.png||b.image||"",current_price:b.price?.market||b.current_price||void 0,market_price:b.price?.low||b.market_price||void 0,verified:!0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}}}}catch(a){console.log("❌ Direct Lorcana API failed for card lookup")}for(let b of[`/cards?q=name:${encodeURIComponent(a)}`,`/cards?search=${encodeURIComponent(a)}`,`/cards?query=${encodeURIComponent(a)}`])try{let c=await fetch(`${e}${b}`);if(c.ok){let d=await c.json(),e=d.cards||d.data||d||[];if(e.length>0){let c=e[0];return console.log(`✅ Found Lorcana card "${a}" from Lorcast ${b}`),{id:c.id||c.uuid||c.card_id||`lorcana-${Math.random()}`,name:c.name||c.card_name||c.title||"",set_name:c.set?.name||c.set_name||c.set_name||"",set_code:c.set?.code||c.set_code||c.set_code||"",card_number:c.number||c.card_number||c.card_num||"",rarity:c.rarity||c.rarity_name||"",game:"LORCANA",mana_cost:c.cost?.toString()||c.mana_cost||c.ink_cost?.toString()||"",cmc:c.cost||c.cmc||c.ink_cost||0,card_type:c.type||c.card_type||c.type_name||"",colors:c.colors||c.ink||[],oracle_text:c.text||c.oracle_text||c.description||c.effect||"",power:c.strength?.toString()||c.power||c.attack?.toString()||"",toughness:c.willpower?.toString()||c.toughness||c.defense?.toString()||"",image_url:c.image_url||c.images?.small||c.images?.png||c.image||"",stock_image_url:c.image_url||c.images?.small||c.images?.png||c.image||"",current_price:c.price?.market||c.current_price||void 0,market_price:c.price?.low||c.market_price||void 0,verified:!0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}}}}catch(a){console.log(`❌ Failed to fetch card from Lorcast ${b}:`,a);continue}return console.log(`⚠️ Lorcana card "${a}" not found from any API`),null}catch(a){return console.error("Error fetching Lorcana card:",a),null}},async getRandomCards(a=20){await k.waitForSlot();try{try{let b=await fetch(`${g}?limit=${a}&api=lorcana`);if(b.ok){let c=await b.json();if(c.success&&c.data){let b=c.data.cards||c.data.data||c.data||[];if(b.length>0)return console.log(`✅ Found ${b.length} cards via proxy (${c.source})`),b.sort(()=>.5-Math.random()).slice(0,a).map(a=>({id:a.id||a.uuid||`lorcana-${Math.random()}`,name:a.name,set_name:a.set?.name||a.set_name||"",set_code:a.set?.code||a.set_code||"",card_number:a.number||a.card_number||"",rarity:a.rarity,game:"LORCANA",mana_cost:a.cost?.toString()||a.mana_cost,cmc:a.cost||a.cmc,card_type:a.type||a.card_type,colors:a.colors||[],oracle_text:a.text||a.oracle_text||"",power:a.strength?.toString()||a.power,toughness:a.willpower?.toString()||a.toughness,image_url:a.image_url||a.images?.small||a.images?.png,stock_image_url:a.image_url||a.images?.small||a.images?.png,current_price:a.price?.market||a.current_price||void 0,market_price:a.price?.low||a.market_price||void 0,verified:!0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}))}}}catch(a){console.log("❌ Proxy API failed for random cards, trying direct APIs")}try{let b=await fetch(`${f}/cards/fetch?pagesize=${a}`);if(b.ok){let c=await b.json(),d=c.cards||c.data||c||[];if(d.length>0)return console.log(`✅ Found ${d.length} cards from direct Lorcana API`),d.sort(()=>.5-Math.random()).slice(0,a).map(a=>({id:a.id||a.uuid||`lorcana-${Math.random()}`,name:a.name,set_name:a.set?.name||a.set_name||"",set_code:a.set?.code||a.set_code||"",card_number:a.number||a.card_number||"",rarity:a.rarity,game:"LORCANA",mana_cost:a.cost?.toString()||a.mana_cost,cmc:a.cost||a.cmc,card_type:a.type||a.card_type,colors:a.colors||[],oracle_text:a.text||a.oracle_text||"",power:a.strength?.toString()||a.power,toughness:a.willpower?.toString()||a.toughness,image_url:a.image_url||a.images?.small||a.images?.png,stock_image_url:a.image_url||a.images?.small||a.images?.png,current_price:a.price?.market||a.current_price||void 0,market_price:a.price?.low||a.market_price||void 0,verified:!0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}))}}catch(a){console.log("❌ Direct Lorcana API failed for random cards")}let b=[];for(let a of["/cards","/api/cards","/v0/cards"])try{let c=await fetch(`${e}${a}`);if(c.ok){let d=await c.json();b=d.cards||d.data||d||[],console.log(`✅ Found ${b.length} cards from Lorcast ${a}`);break}}catch(b){console.log(`❌ Failed to fetch from Lorcast ${a}:`,b);continue}if(0===b.length)return console.log("⚠️ No cards found from any endpoint, returning empty array"),[];return b.sort(()=>.5-Math.random()).slice(0,a).map(a=>({id:a.id||a.uuid||`lorcana-${Math.random()}`,name:a.name,set_name:a.set?.name||a.set_name||"",set_code:a.set?.code||a.set_code||"",card_number:a.number||a.card_number||"",rarity:a.rarity,game:"LORCANA",mana_cost:a.cost?.toString()||a.mana_cost,cmc:a.cost||a.cmc,card_type:a.type||a.card_type,colors:a.colors||[],oracle_text:a.text||a.oracle_text||"",power:a.strength?.toString()||a.power,toughness:a.willpower?.toString()||a.toughness,image_url:a.image_url||a.images?.small||a.images?.png,stock_image_url:a.image_url||a.images?.small||a.images?.png,current_price:a.price?.market||a.current_price||void 0,market_price:a.price?.low||a.market_price||void 0,verified:!0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}))}catch(a){return console.error("Error fetching random Lorcana cards:",a),[]}}},p={async searchCards(a,b){console.log(`🔍 Database search: "${a}" for game: "${b}"`);try{let c=new URLSearchParams({q:a,limit:"50"});b&&"ALL"!==b&&c.append("game",b);let d=await fetch(`https://tcg-vault.vercel.app/api/cards?${c}`);if(!d.ok)throw Error(`Database search failed: ${d.status}`);let e=await d.json();if(e.success&&e.data)return console.log(`✅ Found ${e.data.length} cards from database`),e.data.map(a=>({id:a.id,name:a.name,set_name:a.set_name,set_code:a.set_code,card_number:a.card_number,rarity:a.rarity,game:a.game,mana_cost:a.mana_cost,cmc:a.cmc,card_type:a.card_type,colors:a.colors||[],oracle_text:a.oracle_text,power:a.power,toughness:a.toughness,image_url:a.image_url,stock_image_url:a.stock_image_url,current_price:a.current_price,market_price:a.market_price,verified:a.verified,createdAt:a.createdAt,updatedAt:a.updatedAt}));return[]}catch(a){return console.error("Error in database card search:",a),[]}},async getCardByName(a,b){try{if("MTG"===b)return await l.getCardByName(a);if("POKEMON"===b)return await m.getCardByName(a);if("YUGIOH"===b)return await n.getCardByName(a);if("LORCANA"===b)return await o.getCardByName(a);let c=await l.getCardByName(a);if(c)return c;let d=await m.getCardByName(a);if(d)return d;let e=await n.getCardByName(a);if(e)return e;let f=await o.getCardByName(a);if(f)return f;return null}catch(a){return console.error("Error in unified card search by name:",a),null}},async getRandomCards(a=20,b){let c=[];console.log(`🎲 Getting ${a} random cards for game: "${b}"`);try{if(!b||"MTG"===b){console.log("\uD83C\uDFB2 Getting random MTG cards...");let b=await l.getRandomCards(Math.ceil(a/4));console.log(`✅ Found ${b.length} random MTG cards`),c.push(...b)}if(!b||"LORCANA"===b){console.log("\uD83C\uDFB2 Getting random Lorcana cards...");let b=await o.getRandomCards(Math.ceil(a/4));console.log(`✅ Found ${b.length} random Lorcana cards`),c.push(...b)}let d=c.slice(0,a);return console.log(`🎯 Returning ${d.length} random cards`),d}catch(a){return console.error("Error getting random cards:",a),[]}}}},1862:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{A:()=>j});var e=c(8732),f=c(2015),g=c(8462),h=c(6659),i=a([g,h]);[g,h]=i.then?(await i)():i;let j=({isOpen:a,onClose:b,cardId:c,initialCardData:d})=>{let i=(0,g.useQueryClient)(),[j,k]=(0,f.useState)({cardId:d?.id||"",status:"owned",quantity:1,condition:"near_mint",notes:"",tags:[],collectionIds:[],deckIds:[]}),[l,m]=(0,f.useState)([]),[n,o]=(0,f.useState)([]),{data:p}=(0,g.useQuery)({queryKey:["user-card",c],queryFn:()=>h.LO.cards.getUserCard(c),enabled:!!c}),{data:q}=(0,g.useQuery)({queryKey:["card-info",j.cardId],queryFn:()=>h.LO.cards.getCard(j.cardId),enabled:!!j.cardId}),{data:r=[]}=(0,g.useQuery)({queryKey:["tags"],queryFn:()=>h.LO.tags.getTags()}),{data:s=[]}=(0,g.useQuery)({queryKey:["collections"],queryFn:()=>h.LO.collections.getCollections()}),t=(0,g.useMutation)({mutationFn:h.LO.cards.addCard,onSuccess:()=>{i.invalidateQueries({queryKey:["user-cards"]}),i.invalidateQueries({queryKey:["collections"]}),b()}}),u=(0,g.useMutation)({mutationFn:({id:a,data:b})=>h.LO.cards.updateCard(a,b),onSuccess:()=>{i.invalidateQueries({queryKey:["user-cards"]}),i.invalidateQueries({queryKey:["user-card",c]}),b()}});(0,f.useEffect)(()=>{p&&(k({cardId:p.cardId,status:p.status,quantity:p.quantity,condition:p.condition||"near_mint",notes:p.notes||"",tags:p.tags,collectionIds:p.collectionIds}),m(p.tags),o(p.collectionIds))},[p]);let v=async a=>{a.preventDefault();let b={...j,tags:l,collectionIds:n};c&&p?u.mutate({id:c,data:b}):t.mutate(b)};return a?(0,e.jsx)("div",{className:"fixed inset-0 z-50 bg-black/50",onClick:b,children:(0,e.jsx)("div",{className:"fixed bottom-0 left-0 right-0 bg-white dark:bg-surface-900 rounded-t-3xl max-h-[90vh] overflow-hidden animate-slide-up",children:(0,e.jsxs)("div",{className:"p-6",children:[(0,e.jsx)("div",{className:"w-12 h-1.5 bg-surface-300 dark:bg-surface-600 rounded-full mx-auto mb-6"}),(0,e.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,e.jsx)("h2",{className:"text-xl font-bold text-surface-900 dark:text-white",children:c?"Edit Card":"Add Card"}),(0,e.jsx)("button",{onClick:b,className:"p-2 rounded-xl text-surface-400 hover:text-surface-600 dark:hover:text-surface-300 transition-colors",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsxs)("div",{className:"max-h-[calc(90vh-8rem)] overflow-y-auto",children:[q&&(0,e.jsx)("div",{className:"mb-6 p-4 bg-surface-50 dark:bg-surface-800 rounded-2xl",children:(0,e.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,e.jsx)("div",{className:"w-16 h-20 bg-surface-200 dark:bg-surface-700 rounded-lg flex items-center justify-center",children:q.image_url?(0,e.jsx)("img",{src:q.image_url,alt:q.name,className:"w-full h-full object-cover rounded-lg"}):(0,e.jsx)("svg",{className:"w-6 h-6 text-surface-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),(0,e.jsxs)("div",{className:"flex-1",children:[(0,e.jsx)("h3",{className:"font-semibold text-surface-900 dark:text-white",children:q.name}),(0,e.jsx)("p",{className:"text-sm text-surface-600 dark:text-surface-400",children:q.set_name}),(0,e.jsxs)("div",{className:"flex items-center space-x-2 mt-2",children:[(0,e.jsx)("span",{className:"px-2 py-1 bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-300 rounded-full text-xs font-medium",children:q.game}),(0,e.jsx)("span",{className:"px-2 py-1 bg-accent-100 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300 rounded-full text-xs font-medium",children:q.rarity})]})]})]})}),(0,e.jsxs)("form",{onSubmit:v,className:"space-y-6",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-surface-700 dark:text-surface-300 mb-3",children:"Ownership Status"}),(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,e.jsx)("button",{type:"button",onClick:()=>k(a=>({...a,status:"owned"})),className:`p-4 rounded-xl border-2 transition-all ${"owned"===j.status?"border-primary-500 bg-primary-50 dark:bg-primary-900/20":"border-surface-200 dark:border-surface-700"}`,children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("div",{className:"text-2xl mb-2",children:"✅"}),(0,e.jsx)("div",{className:"font-medium text-surface-900 dark:text-white",children:"Owned"}),(0,e.jsx)("div",{className:"text-sm text-surface-600 dark:text-surface-400",children:"Cards you own"})]})}),(0,e.jsx)("button",{type:"button",onClick:()=>k(a=>({...a,status:"wanted"})),className:`p-4 rounded-xl border-2 transition-all ${"wanted"===j.status?"border-accent-500 bg-accent-50 dark:bg-accent-900/20":"border-surface-200 dark:border-surface-700"}`,children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("div",{className:"text-2xl mb-2",children:"❤️"}),(0,e.jsx)("div",{className:"font-medium text-surface-900 dark:text-white",children:"Wanted"}),(0,e.jsx)("div",{className:"text-sm text-surface-600 dark:text-surface-400",children:"Wishlist cards"})]})})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-surface-700 dark:text-surface-300 mb-2",children:"Quantity"}),(0,e.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,e.jsx)("button",{type:"button",onClick:()=>k(a=>({...a,quantity:Math.max(1,a.quantity-1)})),className:"w-10 h-10 bg-surface-100 dark:bg-surface-700 rounded-lg flex items-center justify-center text-surface-600 dark:text-surface-300 hover:bg-surface-200 dark:hover:bg-surface-600 transition-colors",children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})}),(0,e.jsx)("span",{className:"text-xl font-semibold text-surface-900 dark:text-white min-w-[3rem] text-center",children:j.quantity}),(0,e.jsx)("button",{type:"button",onClick:()=>k(a=>({...a,quantity:a.quantity+1})),className:"w-10 h-10 bg-surface-100 dark:bg-surface-700 rounded-lg flex items-center justify-center text-surface-600 dark:text-surface-300 hover:bg-surface-200 dark:hover:bg-surface-600 transition-colors",children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})})})]})]}),"owned"===j.status&&(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-surface-700 dark:text-surface-300 mb-2",children:"Condition"}),(0,e.jsxs)("select",{value:j.condition,onChange:a=>k(b=>({...b,condition:a.target.value})),className:"w-full px-4 py-3 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-xl text-surface-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 transition-colors",children:[(0,e.jsx)("option",{value:"mint",children:"Mint (M)"}),(0,e.jsx)("option",{value:"near_mint",children:"Near Mint (NM)"}),(0,e.jsx)("option",{value:"excellent",children:"Excellent (EX)"}),(0,e.jsx)("option",{value:"good",children:"Good (G)"}),(0,e.jsx)("option",{value:"light_played",children:"Light Played (LP)"}),(0,e.jsx)("option",{value:"played",children:"Played (P)"}),(0,e.jsx)("option",{value:"poor",children:"Poor (PO)"})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-surface-700 dark:text-surface-300 mb-2",children:"Tags"}),(0,e.jsx)("div",{className:"flex flex-wrap gap-2",children:r.map(a=>(0,e.jsx)("button",{type:"button",onClick:()=>{m(b=>b.includes(a.id)?b.filter(b=>b!==a.id):[...b,a.id])},className:`px-3 py-2 rounded-full text-sm font-medium transition-colors ${l.includes(a.id)?"text-white":"bg-surface-100 dark:bg-surface-700 text-surface-700 dark:text-surface-300"}`,style:{backgroundColor:l.includes(a.id)?a.color:void 0},children:a.name},a.id))})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-surface-700 dark:text-surface-300 mb-2",children:"Collections"}),(0,e.jsx)("div",{className:"space-y-2 max-h-32 overflow-y-auto",children:s.map(a=>(0,e.jsxs)("label",{className:"flex items-center space-x-3",children:[(0,e.jsx)("input",{type:"checkbox",checked:n.includes(a.id),onChange:b=>{o(c=>b.target.checked?[...c,a.id]:c.filter(b=>b!==a.id))},className:"w-4 h-4 text-primary-600 bg-surface-50 border-surface-300 rounded focus:ring-primary-500 dark:focus:ring-primary-600 dark:ring-offset-surface-800 dark:bg-surface-700 dark:border-surface-600"}),(0,e.jsx)("span",{className:"text-sm text-surface-700 dark:text-surface-300",children:a.name})]},a.id))})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-surface-700 dark:text-surface-300 mb-2",children:"Notes"}),(0,e.jsx)("textarea",{value:j.notes,onChange:a=>k(b=>({...b,notes:a.target.value})),rows:3,placeholder:"Add any notes about this card...",className:"w-full px-4 py-3 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-xl text-surface-900 dark:text-white placeholder-surface-500 dark:placeholder-surface-400 focus:outline-none focus:ring-2 focus:ring-primary-500 transition-colors resize-none"})]}),(0,e.jsx)("button",{type:"submit",disabled:!j.cardId||t.isPending||u.isPending,className:"w-full bg-gradient-to-r from-primary-500 to-accent-500 hover:from-primary-600 hover:to-accent-600 disabled:from-surface-400 disabled:to-surface-400 text-white font-semibold py-4 px-6 rounded-xl transition-all duration-200 shadow-lg hover:shadow-xl disabled:shadow-none transform hover:-translate-y-0.5 disabled:transform-none",children:t.isPending||u.isPending?(0,e.jsxs)("div",{className:"flex items-center justify-center",children:[(0,e.jsxs)("svg",{className:"animate-spin -ml-1 mr-3 h-5 w-5 text-white",fill:"none",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,e.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),c?"Updating...":"Adding..."]}):c?"Update Card":"Add Card"})]})]})]})})}):null};d()}catch(a){d(a)}})},1918:(a,b)=>{"use strict";function c(a){return"/api"===a||!!(null==a?void 0:a.startsWith("/api/"))}Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"isAPIRoute",{enumerable:!0,get:function(){return c}})},2088:(a,b,c)=>{"use strict";a.exports=c(3885).vendored.contexts.RouterContext},2417:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"getRouteMatcher",{enumerable:!0,get:function(){return e}});let d=c(4718);function e(a){let{re:b,groups:c}=a;return a=>{let e=b.exec(a);if(!e)return!1;let f=a=>{try{return decodeURIComponent(a)}catch(a){throw Object.defineProperty(new d.DecodeError("failed to decode param"),"__NEXT_ERROR_CODE",{value:"E528",enumerable:!1,configurable:!0})}},g={};for(let[a,b]of Object.entries(c)){let c=e[b.pos];void 0!==c&&(b.repeat?g[a]=c.split("/").map(a=>f(a)):g[a]=f(c))}return g}}},2848:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),!function(a,b){for(var c in b)Object.defineProperty(a,c,{enumerable:!0,get:b[c]})}(b,{formatUrl:function(){return f},formatWithValidation:function(){return h},urlObjectKeys:function(){return g}});let d=c(3147)._(c(7536)),e=/https?|ftp|gopher|file/;function f(a){let{auth:b,hostname:c}=a,f=a.protocol||"",g=a.pathname||"",h=a.hash||"",i=a.query||"",j=!1;b=b?encodeURIComponent(b).replace(/%3A/i,":")+"@":"",a.host?j=b+a.host:c&&(j=b+(~c.indexOf(":")?"["+c+"]":c),a.port&&(j+=":"+a.port)),i&&"object"==typeof i&&(i=String(d.urlQueryToSearchParams(i)));let k=a.search||i&&"?"+i||"";return f&&!f.endsWith(":")&&(f+=":"),a.slashes||(!f||e.test(f))&&!1!==j?(j="//"+(j||""),g&&"/"!==g[0]&&(g="/"+g)):j||(j=""),h&&"#"!==h[0]&&(h="#"+h),k&&"?"!==k[0]&&(k="?"+k),""+f+j+(g=g.replace(/[?#]/g,encodeURIComponent))+(k=k.replace("#","%23"))+h}let g=["auth","hash","host","hostname","href","path","pathname","port","protocol","query","search","slashes"];function h(a){return f(a)}},3147:(a,b)=>{"use strict";function c(a){if("function"!=typeof WeakMap)return null;var b=new WeakMap,d=new WeakMap;return(c=function(a){return a?d:b})(a)}b._=function(a,b){if(!b&&a&&a.__esModule)return a;if(null===a||"object"!=typeof a&&"function"!=typeof a)return{default:a};var d=c(b);if(d&&d.has(a))return d.get(a);var e={__proto__:null},f=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var g in a)if("default"!==g&&Object.prototype.hasOwnProperty.call(a,g)){var h=f?Object.getOwnPropertyDescriptor(a,g):null;h&&(h.get||h.set)?Object.defineProperty(e,g,h):e[g]=a[g]}return e.default=a,d&&d.set(a,e),e}},3448:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"detectDomainLocale",{enumerable:!0,get:function(){return c}});let c=function(){for(var a=arguments.length,b=Array(a),c=0;c{"use strict";c.d(b,{A:()=>i});var d=c(8732),e=c(2015),f=c(4822),g=c(4670),h=c(5533);let i=({children:a})=>{let{user:b,logout:c,isAdmin:i}=(0,g.A)(),{toggleTheme:j,effectiveTheme:k}=(0,h.DP)(),l=(0,f.useLocation)(),m=(0,f.useNavigate)(),[n,o]=(0,e.useState)(!1),[p,q]=(0,e.useState)(!1),r=()=>{c(),o(!1),q(!1),m("/login")},s=[{name:"Dashboard",href:"/dashboard",icon:"\uD83D\uDCCA",mobileIcon:"\uD83C\uDFE0"},{name:"Cards",href:"/cards",icon:"\uD83C\uDCCF",mobileIcon:"\uD83C\uDCCF"},{name:"Collections",href:"/collections",icon:"\uD83D\uDCDA",mobileIcon:"\uD83D\uDCDA"},{name:"Decks",href:"/decks",icon:"\uD83C\uDFAF",mobileIcon:"\uD83C\uDFAF"},{name:"Scanner",href:"/scanner",icon:"\uD83D\uDCF7",mobileIcon:"\uD83D\uDCF7"}];return(0,d.jsxs)("div",{className:"min-h-screen bg-surface-50 dark:bg-surface-900 transition-colors",children:[(0,d.jsxs)("div",{className:"hidden lg:flex h-screen",children:[(0,d.jsxs)("div",{className:"w-64 bg-white dark:bg-surface-800 border-r border-surface-200 dark:border-surface-700 flex flex-col",children:[(0,d.jsx)("div",{className:"p-6 border-b border-surface-200 dark:border-surface-700",children:(0,d.jsxs)(f.Link,{to:"/dashboard",className:"flex items-center space-x-3",children:[(0,d.jsx)("div",{className:"bg-gradient-to-r from-primary-500 to-accent-500 text-white p-3 rounded-xl",children:(0,d.jsx)("svg",{className:"w-6 h-6",fill:"currentColor",viewBox:"0 0 20 20",children:(0,d.jsx)("path",{d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),(0,d.jsxs)("div",{children:[(0,d.jsx)("h1",{className:"text-xl font-bold text-surface-900 dark:text-white",children:"TCG Vault"}),(0,d.jsxs)("p",{className:"text-sm text-surface-600 dark:text-surface-400",children:["Hi, ",b?.firstName||b?.username]})]})]})}),(0,d.jsx)("nav",{className:"flex-1 p-4 space-y-2",children:s.map(a=>{let b;return(0,d.jsxs)(f.Link,{to:a.href,className:`flex items-center space-x-3 px-4 py-3 rounded-xl text-sm font-medium transition-all duration-200 ${(b=a.href,l.pathname===b)?"bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-300":"text-surface-600 dark:text-surface-400 hover:text-surface-900 dark:hover:text-white hover:bg-surface-100 dark:hover:bg-surface-700"}`,children:[(0,d.jsx)("span",{className:"text-lg",children:a.icon}),(0,d.jsx)("span",{children:a.name})]},a.name)})}),(0,d.jsxs)("div",{className:"p-4 border-t border-surface-200 dark:border-surface-700",children:[(0,d.jsxs)("div",{className:"flex items-center space-x-3 p-3 rounded-xl bg-surface-50 dark:bg-surface-700",children:[(0,d.jsx)("div",{className:"w-10 h-10 bg-gradient-to-r from-primary-500 to-accent-500 rounded-xl flex items-center justify-center text-white font-semibold",children:b?.firstName?.[0]||b?.username?.[0]?.toUpperCase()||"U"}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-surface-900 dark:text-white truncate",children:b?.firstName&&b?.lastName?`${b.firstName} ${b.lastName}`:b?.username}),(0,d.jsx)("p",{className:"text-xs text-surface-600 dark:text-surface-400 truncate",children:b?.email})]}),(0,d.jsx)("button",{onClick:()=>o(!n),className:"p-1 rounded-lg hover:bg-surface-200 dark:hover:bg-surface-600 transition-colors",children:(0,d.jsx)("svg",{className:"w-4 h-4 text-surface-600 dark:text-surface-400",fill:"currentColor",viewBox:"0 0 20 20",children:(0,d.jsx)("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})})})]}),n&&(0,d.jsx)("div",{className:"absolute bottom-20 left-4 w-56 bg-white dark:bg-surface-800 rounded-xl shadow-lg ring-1 ring-black ring-opacity-5 border border-surface-200 dark:border-surface-700",children:(0,d.jsxs)("div",{className:"py-2",children:[(0,d.jsxs)(f.Link,{to:"/settings",onClick:()=>o(!1),className:"flex items-center space-x-3 px-4 py-2 text-sm text-surface-700 dark:text-surface-300 hover:bg-surface-100 dark:hover:bg-surface-700",children:[(0,d.jsx)("span",{children:"⚙️"}),(0,d.jsx)("span",{children:"Settings"})]}),i()&&(0,d.jsxs)(f.Link,{to:"/admin",onClick:()=>o(!1),className:"flex items-center space-x-3 px-4 py-2 text-sm text-yellow-700 dark:text-yellow-300 hover:bg-yellow-50 dark:hover:bg-yellow-900/20",children:[(0,d.jsx)("span",{children:"\uD83D\uDC51"}),(0,d.jsx)("span",{children:"Admin Panel"})]}),(0,d.jsx)("div",{className:"border-t border-surface-200 dark:border-surface-700 my-1"}),(0,d.jsxs)("button",{onClick:r,className:"flex items-center space-x-3 px-4 py-2 text-sm text-red-700 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 w-full text-left",children:[(0,d.jsx)("span",{children:"\uD83D\uDEAA"}),(0,d.jsx)("span",{children:"Sign Out"})]})]})})]})]}),(0,d.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,d.jsx)("header",{className:"bg-white dark:bg-surface-800 border-b border-surface-200 dark:border-surface-700 px-6 py-4",children:(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,d.jsx)("h2",{className:"text-2xl font-bold text-surface-900 dark:text-white",children:s.find(a=>{let b;return b=a.href,l.pathname===b})?.name||"TCG Vault"}),i()&&(0,d.jsx)("span",{className:"px-3 py-1 bg-yellow-100 dark:bg-yellow-900/30 text-yellow-800 dark:text-yellow-200 text-xs font-medium rounded-full",children:"⚡ Admin"})]}),(0,d.jsx)("div",{className:"flex items-center space-x-3",children:(0,d.jsx)("button",{onClick:j,className:"p-2 rounded-xl bg-surface-100 dark:bg-surface-700 text-surface-600 dark:text-surface-300 hover:bg-surface-200 dark:hover:bg-surface-600 transition-colors",children:"dark"===k?(0,d.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20",children:(0,d.jsx)("path",{fillRule:"evenodd",d:"M10 2a1 1 0 011 1v1a1 1 0 11-2 0V3a1 1 0 011-1zm4 8a4 4 0 11-8 0 4 4 0 018 0zm-.464 4.95l.707.707a1 1 0 001.414-1.414l-.707-.707a1 1 0 00-1.414 1.414zm2.12-10.607a1 1 0 010 1.414l-.706.707a1 1 0 11-1.414-1.414l.707-.707a1 1 0 011.414 0zM17 11a1 1 0 100-2h-1a1 1 0 100 2h1zm-7 4a1 1 0 011 1v1a1 1 0 11-2 0v-1a1 1 0 011-1zM5.05 6.464A1 1 0 106.465 5.05l-.708-.707a1 1 0 00-1.414 1.414l.707.707zm1.414 8.486l-.707.707a1 1 0 01-1.414-1.414l.707-.707a1 1 0 011.414 1.414zM4 11a1 1 0 100-2H3a1 1 0 000 2h1z",clipRule:"evenodd"})}):(0,d.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20",children:(0,d.jsx)("path",{d:"M17.293 13.293A8 8 0 016.707 2.707a8.001 8.001 0 1010.586 10.586z"})})})})]})}),(0,d.jsx)("main",{className:"flex-1 overflow-auto p-6",children:(0,d.jsx)("div",{className:"max-w-7xl mx-auto",children:a})})]})]}),(0,d.jsxs)("div",{className:"lg:hidden",children:[(0,d.jsx)("header",{className:"fixed top-0 left-0 right-0 z-40 bg-white dark:bg-surface-900 border-b border-surface-200 dark:border-surface-700 px-4 py-3 safe-area-inset-top",children:(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,d.jsx)("button",{onClick:()=>q(!p),className:"p-2 rounded-xl bg-surface-100 dark:bg-surface-800 text-surface-600 dark:text-surface-300 hover:bg-surface-200 dark:hover:bg-surface-700 transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),(0,d.jsx)("div",{className:"bg-gradient-to-r from-primary-500 to-accent-500 text-white p-2 rounded-xl",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20",children:(0,d.jsx)("path",{d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),(0,d.jsxs)("div",{children:[(0,d.jsx)("h1",{className:"text-lg font-bold text-surface-900 dark:text-white",children:"TCG Vault"}),(0,d.jsxs)("p",{className:"text-xs text-surface-600 dark:text-surface-400",children:["Hi, ",b?.firstName||b?.username]})]})]}),(0,d.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,d.jsx)("button",{onClick:j,className:"p-2 rounded-xl bg-surface-100 dark:bg-surface-800 text-surface-600 dark:text-surface-300 hover:bg-surface-200 dark:hover:bg-surface-700 transition-colors",children:"dark"===k?(0,d.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20",children:(0,d.jsx)("path",{fillRule:"evenodd",d:"M10 2a1 1 0 011 1v1a1 1 0 11-2 0V3a1 1 0 011-1zm4 8a4 4 0 11-8 0 4 4 0 018 0zm-.464 4.95l.707.707a1 1 0 001.414-1.414l-.707-.707a1 1 0 00-1.414 1.414zm2.12-10.607a1 1 0 010 1.414l-.706.707a1 1 0 11-1.414-1.414l.707-.707a1 1 0 011.414 0zM17 11a1 1 0 100-2h-1a1 1 0 100 2h1zm-7 4a1 1 0 011 1v1a1 1 0 11-2 0v-1a1 1 0 011-1zM5.05 6.464A1 1 0 106.465 5.05l-.708-.707a1 1 0 00-1.414 1.414l.707.707zm1.414 8.486l-.707.707a1 1 0 01-1.414-1.414l.707-.707a1 1 0 011.414 1.414zM4 11a1 1 0 100-2H3a1 1 0 000 2h1z",clipRule:"evenodd"})}):(0,d.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20",children:(0,d.jsx)("path",{d:"M17.293 13.293A8 8 0 016.707 2.707a8.001 8.001 0 1010.586 10.586z"})})}),(0,d.jsxs)("button",{onClick:()=>o(!0),className:"relative p-1",children:[(0,d.jsx)("div",{className:"w-8 h-8 bg-gradient-to-r from-primary-500 to-accent-500 rounded-xl flex items-center justify-center text-white font-semibold text-sm",children:b?.firstName?.[0]||b?.username?.[0]?.toUpperCase()||"U"}),i()&&(0,d.jsx)("div",{className:"absolute -top-1 -right-1 w-3 h-3 bg-yellow-400 rounded-full border border-white dark:border-surface-900"})]})]})]})}),p&&(0,d.jsxs)("div",{className:"fixed inset-0 z-50 lg:hidden",children:[(0,d.jsx)("div",{className:"fixed inset-0 bg-black/50",onClick:()=>q(!1)}),(0,d.jsxs)("div",{className:"fixed left-0 top-0 bottom-0 w-64 bg-white dark:bg-surface-800 border-r border-surface-200 dark:border-surface-700 transform transition-transform duration-300 ease-in-out",children:[(0,d.jsx)("div",{className:"p-6 border-b border-surface-200 dark:border-surface-700",children:(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)(f.Link,{to:"/dashboard",className:"flex items-center space-x-3",onClick:()=>q(!1),children:[(0,d.jsx)("div",{className:"bg-gradient-to-r from-primary-500 to-accent-500 text-white p-3 rounded-xl",children:(0,d.jsx)("svg",{className:"w-6 h-6",fill:"currentColor",viewBox:"0 0 20 20",children:(0,d.jsx)("path",{d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),(0,d.jsxs)("div",{children:[(0,d.jsx)("h1",{className:"text-xl font-bold text-surface-900 dark:text-white",children:"TCG Vault"}),(0,d.jsxs)("p",{className:"text-sm text-surface-600 dark:text-surface-400",children:["Hi, ",b?.firstName||b?.username]})]})]}),(0,d.jsx)("button",{onClick:()=>q(!1),className:"p-2 rounded-xl bg-surface-100 dark:bg-surface-800 text-surface-600 dark:text-surface-300 hover:bg-surface-200 dark:hover:bg-surface-700 transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),(0,d.jsx)("nav",{className:"flex-1 p-4 space-y-2",children:s.map(a=>{let b;return(0,d.jsxs)(f.Link,{to:a.href,onClick:()=>q(!1),className:`flex items-center space-x-3 px-4 py-3 rounded-xl text-sm font-medium transition-all duration-200 ${(b=a.href,l.pathname===b)?"bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-300":"text-surface-600 dark:text-surface-400 hover:text-surface-900 dark:hover:text-white hover:bg-surface-100 dark:hover:bg-surface-700"}`,children:[(0,d.jsx)("span",{className:"text-lg",children:a.icon}),(0,d.jsx)("span",{children:a.name})]},a.name)})}),(0,d.jsx)("div",{className:"p-4 border-t border-surface-200 dark:border-surface-700",children:(0,d.jsxs)("div",{className:"flex items-center space-x-3 p-3 rounded-xl bg-surface-50 dark:bg-surface-700",children:[(0,d.jsx)("div",{className:"w-10 h-10 bg-gradient-to-r from-primary-500 to-accent-500 rounded-xl flex items-center justify-center text-white font-semibold",children:b?.firstName?.[0]||b?.username?.[0]?.toUpperCase()||"U"}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-surface-900 dark:text-white truncate",children:b?.firstName&&b?.lastName?`${b.firstName} ${b.lastName}`:b?.username}),(0,d.jsx)("p",{className:"text-xs text-surface-600 dark:text-surface-400 truncate",children:b?.email})]})]})})]})]}),(0,d.jsx)("nav",{className:"fixed bottom-0 left-0 right-0 z-50 bg-white dark:bg-surface-900 border-t border-surface-200 dark:border-surface-700 safe-area-inset-bottom",children:(0,d.jsxs)("div",{className:"relative flex items-end justify-around px-4 py-2",children:[(0,d.jsxs)(f.Link,{to:"/dashboard",className:`flex flex-col items-center justify-center p-2 rounded-xl transition-all duration-200 ${"/dashboard"===l.pathname?"text-primary-600 dark:text-primary-400":"text-surface-600 dark:text-surface-400 hover:text-surface-900 dark:hover:text-white"}`,children:[(0,d.jsx)("div",{className:"mb-1",children:"/dashboard"===l.pathname?(0,d.jsx)("svg",{className:"w-6 h-6",fill:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{d:"M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"})}):(0,d.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"})})}),(0,d.jsx)("span",{className:"text-xs font-medium",children:"Home"})]}),(0,d.jsxs)(f.Link,{to:"/cards",className:`flex flex-col items-center justify-center p-2 rounded-xl transition-all duration-200 ${"/cards"===l.pathname?"text-primary-600 dark:text-primary-400":"text-surface-600 dark:text-surface-400 hover:text-surface-900 dark:hover:text-white"}`,children:[(0,d.jsx)("div",{className:"mb-1",children:"/cards"===l.pathname?(0,d.jsx)("svg",{className:"w-6 h-6",fill:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}):(0,d.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),(0,d.jsx)("span",{className:"text-xs font-medium",children:"Cards"})]}),(0,d.jsxs)(f.Link,{to:"/scanner",className:"relative flex flex-col items-center justify-center -mt-6 mb-2",children:[(0,d.jsx)("div",{className:`w-14 h-14 rounded-full shadow-lg transition-all duration-200 flex items-center justify-center ${"/scanner"===l.pathname?"bg-gradient-to-r from-primary-600 to-accent-600 shadow-primary-500/25 shadow-xl":"bg-gradient-to-r from-primary-500 to-accent-500 hover:from-primary-600 hover:to-accent-600 shadow-primary-500/20 hover:shadow-xl"}`,children:(0,d.jsxs)("svg",{className:"w-8 h-8 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 9a2 2 0 012-2h.93a2 2 0 001.664-.89l.812-1.22A2 2 0 0110.07 4h3.86a2 2 0 011.664.89l.812 1.22A2 2 0 0018.07 7H19a2 2 0 012 2v9a2 2 0 01-2 2H5a2 2 0 01-2-2V9z"}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 13a3 3 0 11-6 0 3 3 0 016 0z"})]})}),(0,d.jsx)("span",{className:"text-xs font-medium text-primary-600 dark:text-primary-400 mt-1",children:"Scanner"})]}),(0,d.jsxs)(f.Link,{to:"/collections",className:`flex flex-col items-center justify-center p-2 rounded-xl transition-all duration-200 ${"/collections"===l.pathname?"text-primary-600 dark:text-primary-400":"text-surface-600 dark:text-surface-400 hover:text-surface-900 dark:hover:text-white"}`,children:[(0,d.jsx)("div",{className:"mb-1",children:"/collections"===l.pathname?(0,d.jsx)("svg",{className:"w-6 h-6",fill:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{d:"M7 4V2a1 1 0 011-1h8a1 1 0 011 1v2h3a1 1 0 110 2h-1v10a2 2 0 01-2 2H7a2 2 0 01-2-2V6H4a1 1 0 010-2h3zM9 4h6V3H9v1zm8 2H7v10h10V6z"})}):(0,d.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),(0,d.jsx)("span",{className:"text-xs font-medium",children:"Collections"})]}),(0,d.jsxs)("button",{onClick:()=>o(!0),className:"flex flex-col items-center justify-center p-2 rounded-xl transition-all duration-200 text-surface-600 dark:text-surface-400 hover:text-surface-900 dark:hover:text-white",children:[(0,d.jsx)("div",{className:"mb-1",children:(0,d.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),(0,d.jsx)("span",{className:"text-xs font-medium",children:"More"})]})]})}),(0,d.jsx)("main",{className:"pt-16 pb-20 px-4 max-w-md mx-auto",children:(0,d.jsx)("div",{className:"animate-fade-in",children:a})}),n&&(0,d.jsx)("div",{className:"fixed inset-0 z-50 bg-black/50",onClick:()=>o(!1),children:(0,d.jsxs)("div",{className:"fixed bottom-0 left-0 right-0 bg-white dark:bg-surface-900 rounded-t-3xl p-6 safe-area-inset-bottom animate-slide-up",children:[(0,d.jsx)("div",{className:"w-12 h-1.5 bg-surface-300 dark:bg-surface-600 rounded-full mx-auto mb-6"}),(0,d.jsxs)("div",{className:"flex items-center space-x-4 mb-6 p-4 bg-surface-50 dark:bg-surface-800 rounded-2xl",children:[(0,d.jsx)("div",{className:"w-12 h-12 bg-gradient-to-r from-primary-500 to-accent-500 rounded-xl flex items-center justify-center text-white font-semibold text-lg",children:b?.firstName?.[0]||b?.username?.[0]?.toUpperCase()||"U"}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"font-semibold text-surface-900 dark:text-white",children:b?.firstName&&b?.lastName?`${b.firstName} ${b.lastName}`:b?.username}),(0,d.jsx)("p",{className:"text-sm text-surface-600 dark:text-surface-400",children:b?.email}),(0,d.jsx)("div",{className:"flex gap-1 mt-1",children:b?.roles.map(a=>(0,d.jsx)("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${"admin"===a?"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200":"bg-primary-100 text-primary-800 dark:bg-primary-900 dark:text-primary-200"}`,children:a},a))})]})]}),(0,d.jsxs)("div",{className:"space-y-2 mb-6",children:[(0,d.jsxs)(f.Link,{to:"/decks",onClick:()=>o(!1),className:"flex items-center space-x-3 p-3 rounded-xl hover:bg-surface-100 dark:hover:bg-surface-800 transition-colors",children:[(0,d.jsx)("svg",{className:"w-5 h-5 text-surface-600 dark:text-surface-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),(0,d.jsx)("span",{className:"text-surface-900 dark:text-white font-medium",children:"Decks"})]}),(0,d.jsxs)(f.Link,{to:"/settings",onClick:()=>o(!1),className:"flex items-center space-x-3 p-3 rounded-xl hover:bg-surface-100 dark:hover:bg-surface-800 transition-colors",children:[(0,d.jsxs)("svg",{className:"w-5 h-5 text-surface-600 dark:text-surface-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),(0,d.jsx)("span",{className:"text-surface-900 dark:text-white font-medium",children:"Settings"})]}),i()&&(0,d.jsxs)(f.Link,{to:"/admin",onClick:()=>o(!1),className:"flex items-center space-x-3 p-3 rounded-xl hover:bg-yellow-50 dark:hover:bg-yellow-900/20 transition-colors",children:[(0,d.jsx)("svg",{className:"w-5 h-5 text-yellow-600 dark:text-yellow-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})}),(0,d.jsx)("span",{className:"text-yellow-700 dark:text-yellow-300 font-medium",children:"Admin Panel"})]})]}),(0,d.jsxs)("button",{onClick:r,className:"w-full flex items-center justify-center space-x-2 p-3 bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 rounded-xl hover:bg-red-100 dark:hover:bg-red-900/30 transition-colors font-medium",children:[(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"})}),(0,d.jsx)("span",{children:"Sign Out"})]})]})})]}),(n||p)&&(0,d.jsx)("div",{className:"fixed inset-0 z-40",onClick:()=>{o(!1),q(!1)}})]})}},3563:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"interpolateAs",{enumerable:!0,get:function(){return f}});let d=c(2417),e=c(3898);function f(a,b,c){let f="",g=(0,e.getRouteRegex)(a),h=g.groups,i=(b!==a?(0,d.getRouteMatcher)(g)(b):"")||c;f=a;let j=Object.keys(h);return j.every(a=>{let b=i[a]||"",{repeat:c,optional:d}=h[a],e="["+(c?"...":"")+a+"]";return d&&(e=(b?"":"/")+"["+e+"]"),c&&!Array.isArray(b)&&(b=[b]),(d||a in i)&&(f=f.replace(e,c?b.map(a=>encodeURIComponent(a)).join("/"):encodeURIComponent(b))||"/")})||(f=""),{params:j,result:f}}},3622:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{A:()=>j});var e=c(8732),f=c(2015),g=c(8462),h=c(6659),i=a([g,h]);[g,h]=i.then?(await i)():i;let j=({isOpen:a,onClose:b,collectionId:c})=>{let d=(0,g.useQueryClient)(),[i,j]=(0,f.useState)({name:"",description:"",game:"",tags:[],color:"#8b5cf6",icon:"\uD83D\uDCDA",isPublic:!1}),[k,l]=(0,f.useState)([]),[m,n]=(0,f.useState)(!1),{data:o}=(0,g.useQuery)({queryKey:["collection",c],queryFn:()=>h.LO.collections.getCollection(c,!1),enabled:!!c}),{data:p=[]}=(0,g.useQuery)({queryKey:["tags"],queryFn:()=>h.LO.tags.getTags()}),q=(0,g.useMutation)({mutationFn:h.LO.collections.createCollection,onSuccess:()=>{d.invalidateQueries({queryKey:["collections"]}),b()}}),r=(0,g.useMutation)({mutationFn:({id:a,data:b})=>h.LO.collections.updateCollection(a,b),onSuccess:()=>{d.invalidateQueries({queryKey:["collections"]}),d.invalidateQueries({queryKey:["collection",c]}),b()}});(0,f.useEffect)(()=>{o&&(j({name:o.name,description:o.description||"",game:o.game||"",tags:o.tags,color:o.color||"#8b5cf6",icon:o.icon||"\uD83D\uDCDA",isPublic:o.isPublic}),l(o.tags))},[o]);let s=async a=>{a.preventDefault();let b={...i,tags:k};c&&o?r.mutate({id:c,data:b}):q.mutate(b)};return a?(0,e.jsx)("div",{className:"fixed inset-0 z-50 bg-black/50",onClick:b,children:(0,e.jsx)("div",{className:"fixed bottom-0 left-0 right-0 bg-white dark:bg-surface-900 rounded-t-3xl max-h-[90vh] overflow-hidden animate-slide-up",children:(0,e.jsxs)("div",{className:"p-6",children:[(0,e.jsx)("div",{className:"w-12 h-1.5 bg-surface-300 dark:bg-surface-600 rounded-full mx-auto mb-6"}),(0,e.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,e.jsx)("h2",{className:"text-xl font-bold text-surface-900 dark:text-white",children:c?"Edit Collection":"New Collection"}),(0,e.jsx)("button",{onClick:b,className:"p-2 rounded-xl text-surface-400 hover:text-surface-600 dark:hover:text-surface-300 transition-colors",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("div",{className:"max-h-[calc(90vh-8rem)] overflow-y-auto",children:(0,e.jsxs)("form",{onSubmit:s,className:"space-y-6",onClick:a=>a.stopPropagation(),children:[(0,e.jsx)("div",{className:"p-4 bg-surface-50 dark:bg-surface-800 rounded-2xl",children:(0,e.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,e.jsx)("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center text-white text-xl font-semibold shadow-md",style:{backgroundColor:i.color},children:i.icon}),(0,e.jsxs)("div",{className:"flex-1",children:[(0,e.jsx)("h3",{className:"font-semibold text-surface-900 dark:text-white",children:i.name||"Collection Name"}),i.description&&(0,e.jsx)("p",{className:"text-sm text-surface-600 dark:text-surface-400",children:i.description}),i.game&&(0,e.jsx)("span",{className:`inline-block mt-2 px-2 py-1 rounded-full text-xs font-medium ${(a=>{switch(a){case"MTG":return"bg-orange-100 text-orange-800 dark:bg-orange-900/30 dark:text-orange-300";case"POKEMON":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300";case"LORCANA":return"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300";case"YUGIOH":return"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300";default:return"bg-surface-100 text-surface-800 dark:bg-surface-700 dark:text-surface-300"}})(i.game)}`,children:i.game})]})]})}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-surface-700 dark:text-surface-300 mb-2",children:"Collection Name *"}),(0,e.jsx)("input",{type:"text",value:i.name,onChange:a=>j(b=>({...b,name:a.target.value})),placeholder:"Enter collection name...",className:"w-full px-4 py-3 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-xl text-surface-900 dark:text-white placeholder-surface-500 dark:placeholder-surface-400 focus:outline-none focus:ring-2 focus:ring-primary-500 transition-colors",required:!0})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-surface-700 dark:text-surface-300 mb-2",children:"Description"}),(0,e.jsx)("textarea",{value:i.description,onChange:a=>j(b=>({...b,description:a.target.value})),rows:3,placeholder:"Describe your collection...",className:"w-full px-4 py-3 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-xl text-surface-900 dark:text-white placeholder-surface-500 dark:placeholder-surface-400 focus:outline-none focus:ring-2 focus:ring-primary-500 transition-colors resize-none"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-surface-700 dark:text-surface-300 mb-2",children:"Game (Optional)"}),(0,e.jsxs)("select",{value:i.game,onChange:a=>j(b=>({...b,game:a.target.value})),className:"w-full px-4 py-3 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-xl text-surface-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 transition-colors",children:[(0,e.jsx)("option",{value:"",children:"All Games"}),(0,e.jsx)("option",{value:"MTG",children:"Magic: The Gathering"}),(0,e.jsx)("option",{value:"POKEMON",children:"Pok\xe9mon"}),(0,e.jsx)("option",{value:"LORCANA",children:"Disney Lorcana"}),(0,e.jsx)("option",{value:"YUGIOH",children:"Yu-Gi-Oh!"}),(0,e.jsx)("option",{value:"OTHER",children:"Other"})]})]}),(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-surface-700 dark:text-surface-300 mb-2",children:"Icon"}),(0,e.jsx)("button",{type:"button",onClick:()=>n(!m),className:"w-full p-3 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-xl flex items-center justify-center text-2xl hover:bg-surface-100 dark:hover:bg-surface-600 transition-colors",children:i.icon}),m&&(0,e.jsx)("div",{className:"mt-2 p-3 bg-white dark:bg-surface-800 border border-surface-200 dark:border-surface-700 rounded-xl",children:(0,e.jsx)("div",{className:"grid grid-cols-5 gap-2",children:["\uD83D\uDCDA","\uD83C\uDFB4","⚡","\uD83D\uDD25","\uD83D\uDCA7","\uD83C\uDF3F","⚫","\uD83D\uDFE4","\uD83D\uDFE1","\uD83D\uDD34","\uD83D\uDFE2","\uD83D\uDD35","\uD83D\uDFE3","⚪","\uD83C\uDF1F","\uD83D\uDC8E","\uD83D\uDC51","\uD83C\uDFC6","\uD83C\uDFAF","\uD83D\uDE80"].map(a=>(0,e.jsx)("button",{type:"button",onClick:()=>{j(b=>({...b,icon:a})),n(!1)},className:`p-2 rounded-lg text-xl hover:bg-surface-100 dark:hover:bg-surface-700 transition-colors ${i.icon===a?"bg-primary-100 dark:bg-primary-900/30":""}`,children:a},a))})})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-surface-700 dark:text-surface-300 mb-2",children:"Color"}),(0,e.jsx)("div",{className:"grid grid-cols-5 gap-2",children:["#8b5cf6","#3b82f6","#10b981","#f59e0b","#ef4444","#ec4899","#8b5cf6","#6366f1","#06b6d4","#84cc16"].map(a=>(0,e.jsx)("button",{type:"button",onClick:()=>j(b=>({...b,color:a})),className:`w-full h-10 rounded-lg transition-all ${i.color===a?"ring-2 ring-surface-400 ring-offset-2 dark:ring-offset-surface-900":""}`,style:{backgroundColor:a}},a))})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-surface-700 dark:text-surface-300 mb-2",children:"Tags"}),(0,e.jsx)("div",{className:"flex flex-wrap gap-2",children:p.map(a=>(0,e.jsx)("button",{type:"button",onClick:()=>{l(b=>b.includes(a.id)?b.filter(b=>b!==a.id):[...b,a.id])},className:`px-3 py-2 rounded-full text-sm font-medium transition-colors ${k.includes(a.id)?"text-white":"bg-surface-100 dark:bg-surface-700 text-surface-700 dark:text-surface-300"}`,style:{backgroundColor:k.includes(a.id)?a.color:void 0},children:a.name},a.id))})]}),(0,e.jsx)("div",{children:(0,e.jsxs)("label",{className:"flex items-center justify-between",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:"text-sm font-medium text-surface-700 dark:text-surface-300",children:"Public Collection"}),(0,e.jsx)("p",{className:"text-xs text-surface-600 dark:text-surface-400 mt-1",children:"Allow others to view your collection"})]}),(0,e.jsx)("button",{type:"button",onClick:()=>j(a=>({...a,isPublic:!a.isPublic})),className:`relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 ${i.isPublic?"bg-primary-600":"bg-surface-200 dark:bg-surface-700"}`,children:(0,e.jsx)("span",{className:`pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out ${i.isPublic?"translate-x-5":"translate-x-0"}`})})]})}),(0,e.jsx)("button",{type:"submit",disabled:!i.name.trim()||q.isPending||r.isPending,className:"w-full bg-gradient-to-r from-primary-500 to-accent-500 hover:from-primary-600 hover:to-accent-600 disabled:from-surface-400 disabled:to-surface-400 text-white font-semibold py-4 px-6 rounded-xl transition-all duration-200 shadow-lg hover:shadow-xl disabled:shadow-none transform hover:-translate-y-0.5 disabled:transform-none",children:q.isPending||r.isPending?(0,e.jsxs)("div",{className:"flex items-center justify-center",children:[(0,e.jsxs)("svg",{className:"animate-spin -ml-1 mr-3 h-5 w-5 text-white",fill:"none",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,e.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),c?"Updating...":"Creating..."]}):c?"Update Collection":"Create Collection"})]})})]})})}):null};d()}catch(a){d(a)}})},3771:(a,b,c)=>{"use strict";c.d(b,{A:()=>h});var d=c(8732),e=c(2015),f=c(4822),g=c(4670);let h=()=>{let{register:a}=(0,g.A)(),[b,c]=(0,e.useState)({firstName:"",lastName:"",username:"",email:"",password:"",confirmPassword:""}),[h,i]=(0,e.useState)(!1),[j,k]=(0,e.useState)(null),[l,m]=(0,e.useState)(!1),[n,o]=(0,e.useState)(!1),p=async c=>{if(c.preventDefault(),i(!0),k(null),b.password!==b.confirmPassword){k("Passwords do not match"),i(!1);return}try{await a(b)}catch(a){k(a instanceof Error?a.message:"Registration failed")}finally{i(!1)}},q=a=>{c(b=>({...b,[a.target.name]:a.target.value}))};return(0,d.jsxs)("div",{className:"bg-white dark:bg-surface-800 p-8 rounded-2xl shadow-xl border border-surface-200 dark:border-surface-700 transition-colors",children:[(0,d.jsxs)("div",{className:"text-center mb-8",children:[(0,d.jsx)("div",{className:"w-16 h-16 bg-gradient-to-r from-primary-500 to-accent-500 rounded-2xl flex items-center justify-center mx-auto mb-4 shadow-lg",children:(0,d.jsx)("svg",{className:"w-8 h-8 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:(0,d.jsx)("path",{d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),(0,d.jsx)("h1",{className:"text-2xl font-bold text-surface-900 dark:text-white mb-2",children:"Join TCG Vault"}),(0,d.jsx)("p",{className:"text-surface-600 dark:text-surface-400",children:"Create your account to get started"})]}),j&&(0,d.jsx)("div",{className:"mb-6 p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-xl",children:(0,d.jsxs)("div",{className:"flex items-center",children:[(0,d.jsx)("svg",{className:"w-5 h-5 text-red-500 mr-2",fill:"currentColor",viewBox:"0 0 20 20",children:(0,d.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})}),(0,d.jsx)("span",{className:"text-red-700 dark:text-red-400 text-sm",children:j})]})}),(0,d.jsxs)("form",{onSubmit:p,className:"space-y-4",children:[(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{htmlFor:"firstName",className:"block text-sm font-medium text-surface-700 dark:text-surface-300 mb-2",children:"First Name"}),(0,d.jsx)("input",{type:"text",id:"firstName",name:"firstName",value:b.firstName,onChange:q,className:"w-full px-4 py-3 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-xl text-surface-900 dark:text-white placeholder-surface-500 dark:placeholder-surface-400 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent transition-colors",placeholder:"John",required:!0})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{htmlFor:"lastName",className:"block text-sm font-medium text-surface-700 dark:text-surface-300 mb-2",children:"Last Name"}),(0,d.jsx)("input",{type:"text",id:"lastName",name:"lastName",value:b.lastName,onChange:q,className:"w-full px-4 py-3 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-xl text-surface-900 dark:text-white placeholder-surface-500 dark:placeholder-surface-400 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent transition-colors",placeholder:"Doe",required:!0})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{htmlFor:"username",className:"block text-sm font-medium text-surface-700 dark:text-surface-300 mb-2",children:"Username"}),(0,d.jsx)("input",{type:"text",id:"username",name:"username",value:b.username,onChange:q,className:"w-full px-4 py-3 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-xl text-surface-900 dark:text-white placeholder-surface-500 dark:placeholder-surface-400 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent transition-colors",placeholder:"johndoe",required:!0})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{htmlFor:"email",className:"block text-sm font-medium text-surface-700 dark:text-surface-300 mb-2",children:"Email Address"}),(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("input",{type:"email",id:"email",name:"email",value:b.email,onChange:q,className:"w-full px-4 py-3 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-xl text-surface-900 dark:text-white placeholder-surface-500 dark:placeholder-surface-400 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent transition-colors",placeholder:"john@example.com",required:!0}),(0,d.jsx)("svg",{className:"absolute right-3 top-1/2 transform -translate-y-1/2 w-5 h-5 text-surface-400 dark:text-surface-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 12a4 4 0 10-8 0 4 4 0 008 0zm0 0v1.5a2.5 2.5 0 005 0V12a9 9 0 10-9 9m4.5-1.206a8.959 8.959 0 01-4.5 1.207"})})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{htmlFor:"password",className:"block text-sm font-medium text-surface-700 dark:text-surface-300 mb-2",children:"Password"}),(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("input",{type:l?"text":"password",id:"password",name:"password",value:b.password,onChange:q,className:"w-full px-4 py-3 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-xl text-surface-900 dark:text-white placeholder-surface-500 dark:placeholder-surface-400 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent transition-colors pr-12",placeholder:"Create a strong password",required:!0}),(0,d.jsx)("button",{type:"button",onClick:()=>m(!l),className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-surface-400 dark:text-surface-500 hover:text-surface-600 dark:hover:text-surface-300 transition-colors",children:l?(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.878 9.878L3 3m6.878 6.878L21 21"})}):(0,d.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]})})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{htmlFor:"confirmPassword",className:"block text-sm font-medium text-surface-700 dark:text-surface-300 mb-2",children:"Confirm Password"}),(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("input",{type:n?"text":"password",id:"confirmPassword",name:"confirmPassword",value:b.confirmPassword,onChange:q,className:"w-full px-4 py-3 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-xl text-surface-900 dark:text-white placeholder-surface-500 dark:placeholder-surface-400 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent transition-colors pr-12",placeholder:"Confirm your password",required:!0}),(0,d.jsx)("button",{type:"button",onClick:()=>o(!n),className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-surface-400 dark:text-surface-500 hover:text-surface-600 dark:hover:text-surface-300 transition-colors",children:n?(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.878 9.878L3 3m6.878 6.878L21 21"})}):(0,d.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]})})]})]}),(0,d.jsx)("button",{type:"submit",disabled:h,className:"w-full bg-gradient-to-r from-primary-500 to-accent-500 hover:from-primary-600 hover:to-accent-600 disabled:from-surface-400 disabled:to-surface-400 text-white font-semibold py-3 px-4 rounded-xl transition-all duration-200 shadow-lg hover:shadow-xl disabled:shadow-none transform hover:-translate-y-0.5 disabled:transform-none",children:h?(0,d.jsxs)("div",{className:"flex items-center justify-center",children:[(0,d.jsxs)("svg",{className:"animate-spin -ml-1 mr-3 h-5 w-5 text-white",fill:"none",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,d.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Creating Account..."]}):"Create Account"}),(0,d.jsx)("div",{className:"text-center",children:(0,d.jsxs)("p",{className:"text-surface-600 dark:text-surface-400",children:["Already have an account?"," ",(0,d.jsx)(f.Link,{to:"/login",className:"text-primary-600 dark:text-primary-400 hover:text-primary-700 dark:hover:text-primary-300 font-medium transition-colors",children:"Sign in"})]})})]})]})}},3898:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),!function(a,b){for(var c in b)Object.defineProperty(a,c,{enumerable:!0,get:b[c]})}(b,{getNamedMiddlewareRegex:function(){return p},getNamedRouteRegex:function(){return o},getRouteRegex:function(){return l},parseParameter:function(){return i}});let d=c(2072),e=c(6580),f=c(8900),g=c(1730),h=/^([^[]*)\[((?:\[[^\]]*\])|[^\]]+)\](.*)$/;function i(a){let b=a.match(h);return b?j(b[2]):j(a)}function j(a){let b=a.startsWith("[")&&a.endsWith("]");b&&(a=a.slice(1,-1));let c=a.startsWith("...");return c&&(a=a.slice(3)),{key:a,repeat:c,optional:b}}function k(a,b,c){let d={},i=1,k=[];for(let l of(0,g.removeTrailingSlash)(a).slice(1).split("/")){let a=e.INTERCEPTION_ROUTE_MARKERS.find(a=>l.startsWith(a)),g=l.match(h);if(a&&g&&g[2]){let{key:b,optional:c,repeat:e}=j(g[2]);d[b]={pos:i++,repeat:e,optional:c},k.push("/"+(0,f.escapeStringRegexp)(a)+"([^/]+?)")}else if(g&&g[2]){let{key:a,repeat:b,optional:e}=j(g[2]);d[a]={pos:i++,repeat:b,optional:e},c&&g[1]&&k.push("/"+(0,f.escapeStringRegexp)(g[1]));let h=b?e?"(?:/(.+?))?":"/(.+?)":"/([^/]+?)";c&&g[1]&&(h=h.substring(1)),k.push(h)}else k.push("/"+(0,f.escapeStringRegexp)(l));b&&g&&g[3]&&k.push((0,f.escapeStringRegexp)(g[3]))}return{parameterizedRoute:k.join(""),groups:d}}function l(a,b){let{includeSuffix:c=!1,includePrefix:d=!1,excludeOptionalTrailingSlash:e=!1}=void 0===b?{}:b,{parameterizedRoute:f,groups:g}=k(a,c,d),h=f;return e||(h+="(?:/)?"),{re:RegExp("^"+h+"$"),groups:g}}function m(a){let b,{interceptionMarker:c,getSafeRouteKey:d,segment:e,routeKeys:g,keyPrefix:h,backreferenceDuplicateKeys:i}=a,{key:k,optional:l,repeat:m}=j(e),n=k.replace(/\W/g,"");h&&(n=""+h+n);let o=!1;(0===n.length||n.length>30)&&(o=!0),isNaN(parseInt(n.slice(0,1)))||(o=!0),o&&(n=d());let p=n in g;h?g[n]=""+h+k:g[n]=k;let q=c?(0,f.escapeStringRegexp)(c):"";return b=p&&i?"\\k<"+n+">":m?"(?<"+n+">.+?)":"(?<"+n+">[^/]+?)",l?"(?:/"+q+b+")?":"/"+q+b}function n(a,b,c,i,j){let k,l=(k=0,()=>{let a="",b=++k;for(;b>0;)a+=String.fromCharCode(97+(b-1)%26),b=Math.floor((b-1)/26);return a}),n={},o=[];for(let k of(0,g.removeTrailingSlash)(a).slice(1).split("/")){let a=e.INTERCEPTION_ROUTE_MARKERS.some(a=>k.startsWith(a)),g=k.match(h);if(a&&g&&g[2])o.push(m({getSafeRouteKey:l,interceptionMarker:g[1],segment:g[2],routeKeys:n,keyPrefix:b?d.NEXT_INTERCEPTION_MARKER_PREFIX:void 0,backreferenceDuplicateKeys:j}));else if(g&&g[2]){i&&g[1]&&o.push("/"+(0,f.escapeStringRegexp)(g[1]));let a=m({getSafeRouteKey:l,segment:g[2],routeKeys:n,keyPrefix:b?d.NEXT_QUERY_PARAM_PREFIX:void 0,backreferenceDuplicateKeys:j});i&&g[1]&&(a=a.substring(1)),o.push(a)}else o.push("/"+(0,f.escapeStringRegexp)(k));c&&g&&g[3]&&o.push((0,f.escapeStringRegexp)(g[3]))}return{namedParameterizedRoute:o.join(""),routeKeys:n}}function o(a,b){var c,d,e;let f=n(a,b.prefixRouteKeys,null!=(c=b.includeSuffix)&&c,null!=(d=b.includePrefix)&&d,null!=(e=b.backreferenceDuplicateKeys)&&e),g=f.namedParameterizedRoute;return b.excludeOptionalTrailingSlash||(g+="(?:/)?"),{...l(a,b),namedRegex:"^"+g+"$",routeKeys:f.routeKeys}}function p(a,b){let{parameterizedRoute:c}=k(a,!1,!1),{catchAll:d=!0}=b;if("/"===c)return{namedRegex:"^/"+(d?".*":"")+"$"};let{namedParameterizedRoute:e}=n(a,!1,!1,!1,!1);return{namedRegex:"^"+e+(d?"(?:(/.*)?)":"")+"$"}}},3949:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"default",{enumerable:!0,get:function(){return f}}),c(7020);let d=c(8732);c(2015);let e=c(5306);function f(a){function b(b){return(0,d.jsx)(a,{router:(0,e.useRouter)(),...b})}return b.getInitialProps=a.getInitialProps,b.origGetInitialProps=a.origGetInitialProps,b}("function"==typeof b.default||"object"==typeof b.default&&null!==b.default)&&void 0===b.default.__esModule&&(Object.defineProperty(b.default,"__esModule",{value:!0}),Object.assign(b.default,b),a.exports=b.default)},4233:(a,b,c)=>{a.exports=c(5306)},4587:(a,b,c)=>{"use strict";c.d(b,{A:()=>k});var d=c(8732),e=c(2015),f=c(4670),g=c(4822);let h=()=>{let{token:a}=(0,f.A)(),[b,c]=(0,e.useState)([]),[g,h]=(0,e.useState)(!0),[i,j]=(0,e.useState)(""),[k,l]=(0,e.useState)(""),[m,n]=(0,e.useState)(1),[o,p]=(0,e.useState)(1),[q,r]=(0,e.useState)(null),s=async(b=1,d="")=>{try{h(!0);let e=await fetch(`/api/admin/users?page=${b}&limit=20&search=${encodeURIComponent(d)}`,{headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json"}});if(!e.ok)throw Error("Failed to fetch users");let f=await e.json();c(f.users),n(f.pagination.page),p(f.pagination.totalPages),j("")}catch(a){j(a.message)}finally{h(!1)}};(0,e.useEffect)(()=>{s(m,k)},[m,a]);let t=async(b,c)=>{try{if(!(await fetch(`/api/admin/users?id=${b}`,{method:"PUT",headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json"},body:JSON.stringify(c)})).ok)throw Error("Failed to update user");s(m,k),r(null)}catch(a){j(a.message)}},u=a=>new Date(a).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});return g&&0===b.length?(0,d.jsx)("div",{className:"p-6 flex justify-center items-center",children:(0,d.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-indigo-600"})}):(0,d.jsxs)("div",{className:"p-6",children:[(0,d.jsxs)("div",{className:"mb-6",children:[(0,d.jsx)("h2",{className:"text-xl font-semibold text-gray-900 mb-2",children:"User Management"}),(0,d.jsx)("p",{className:"text-sm text-gray-600",children:"Manage user accounts, roles, and permissions."})]}),(0,d.jsx)("form",{onSubmit:a=>{a.preventDefault(),n(1),s(1,k)},className:"mb-6",children:(0,d.jsxs)("div",{className:"flex gap-4",children:[(0,d.jsx)("div",{className:"flex-1",children:(0,d.jsx)("input",{type:"text",placeholder:"Search users by username, email, or name...",value:k,onChange:a=>l(a.target.value),className:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"})}),(0,d.jsx)("button",{type:"submit",className:"px-6 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500",children:"Search"})]})}),i&&(0,d.jsx)("div",{className:"mb-4 bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg",children:i}),(0,d.jsx)("div",{className:"overflow-x-auto",children:(0,d.jsxs)("table",{className:"min-w-full divide-y divide-gray-200",children:[(0,d.jsx)("thead",{className:"bg-gray-50",children:(0,d.jsxs)("tr",{children:[(0,d.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"User"}),(0,d.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Roles"}),(0,d.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Status"}),(0,d.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Created"}),(0,d.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Last Login"}),(0,d.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Actions"})]})}),(0,d.jsx)("tbody",{className:"bg-white divide-y divide-gray-200",children:b.map(a=>(0,d.jsxs)("tr",{className:"hover:bg-gray-50",children:[(0,d.jsx)("td",{className:"px-6 py-4 whitespace-nowrap",children:(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-sm font-medium text-gray-900",children:a.first_name||a.last_name?`${a.first_name||""} ${a.last_name||""}`.trim():a.username}),(0,d.jsx)("div",{className:"text-sm text-gray-500",children:a.email}),(a.first_name||a.last_name)&&(0,d.jsxs)("div",{className:"text-xs text-gray-400",children:["@",a.username]})]})}),(0,d.jsx)("td",{className:"px-6 py-4 whitespace-nowrap",children:(0,d.jsx)("div",{className:"flex flex-wrap gap-1",children:a.roles.map(a=>(0,d.jsx)("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${(a=>{switch(a){case"admin":return"bg-purple-100 text-purple-800";case"user":return"bg-blue-100 text-blue-800";default:return"bg-gray-100 text-gray-800"}})(a)}`,children:a},a))})}),(0,d.jsx)("td",{className:"px-6 py-4 whitespace-nowrap",children:(0,d.jsx)("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${a.is_active?"bg-green-100 text-green-800":"bg-red-100 text-red-800"}`,children:a.is_active?"Active":"Inactive"})}),(0,d.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:u(a.created_at)}),(0,d.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:a.last_login?u(a.last_login):"Never"}),(0,d.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:(0,d.jsxs)("div",{className:"flex space-x-2",children:[(0,d.jsx)("button",{onClick:()=>r(a),className:"text-indigo-600 hover:text-indigo-900",children:"Edit"}),(0,d.jsx)("button",{onClick:()=>t(a.id,{isActive:!a.is_active}),className:a.is_active?"text-red-600 hover:text-red-900":"text-green-600 hover:text-green-900",children:a.is_active?"Deactivate":"Activate"})]})})]},a.id))})]})}),o>1&&(0,d.jsx)("div",{className:"mt-6 flex justify-center",children:(0,d.jsxs)("nav",{className:"flex space-x-2",children:[(0,d.jsx)("button",{onClick:()=>n(Math.max(1,m-1)),disabled:1===m,className:"px-3 py-2 text-sm border border-gray-300 rounded-md disabled:opacity-50",children:"Previous"}),(0,d.jsxs)("span",{className:"px-3 py-2 text-sm",children:["Page ",m," of ",o]}),(0,d.jsx)("button",{onClick:()=>n(Math.min(o,m+1)),disabled:m===o,className:"px-3 py-2 text-sm border border-gray-300 rounded-md disabled:opacity-50",children:"Next"})]})}),q&&(0,d.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:(0,d.jsxs)("div",{className:"bg-white rounded-lg p-6 w-full max-w-md",children:[(0,d.jsx)("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Edit User"}),(0,d.jsx)("div",{className:"space-y-4",children:(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-gray-700",children:"Roles"}),(0,d.jsx)("div",{className:"mt-2 space-y-2",children:["user","admin"].map(a=>(0,d.jsxs)("label",{className:"flex items-center",children:[(0,d.jsx)("input",{type:"checkbox",checked:q.roles.includes(a),onChange:b=>{let c=b.target.checked?[...q.roles,a]:q.roles.filter(b=>b!==a);r({...q,roles:c})},className:"mr-2"}),(0,d.jsx)("span",{className:"capitalize",children:a})]},a))})]})}),(0,d.jsxs)("div",{className:"mt-6 flex justify-end space-x-3",children:[(0,d.jsx)("button",{onClick:()=>r(null),className:"px-4 py-2 text-sm font-medium text-gray-700 bg-gray-100 rounded-md hover:bg-gray-200",children:"Cancel"}),(0,d.jsx)("button",{onClick:()=>t(q.id,{roles:q.roles}),className:"px-4 py-2 text-sm font-medium text-white bg-indigo-600 rounded-md hover:bg-indigo-700",children:"Save Changes"})]})]})})]})},i=()=>(0,d.jsxs)("div",{className:"p-6",children:[(0,d.jsxs)("div",{className:"mb-6",children:[(0,d.jsx)("h2",{className:"text-xl font-semibold text-gray-900 mb-2",children:"System Dashboard"}),(0,d.jsx)("p",{className:"text-sm text-gray-600",children:"Overview of system statistics and health."})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8",children:[(0,d.jsx)("div",{className:"bg-gradient-to-r from-blue-500 to-blue-600 rounded-lg p-6 text-white",children:(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-blue-100 text-sm",children:"Total Users"}),(0,d.jsx)("p",{className:"text-3xl font-bold",children:"-"})]}),(0,d.jsx)("div",{className:"bg-blue-400 bg-opacity-30 rounded-full p-3",children:(0,d.jsx)("svg",{className:"w-8 h-8",fill:"currentColor",viewBox:"0 0 20 20",children:(0,d.jsx)("path",{d:"M9 6a3 3 0 11-6 0 3 3 0 016 0zM17 6a3 3 0 11-6 0 3 3 0 016 0zM12.93 17c.046-.327.07-.66.07-1a6.97 6.97 0 00-1.5-4.33A5 5 0 0119 16v1h-6.07zM6 11a5 5 0 015 5v1H1v-1a5 5 0 015-5z"})})})]})}),(0,d.jsx)("div",{className:"bg-gradient-to-r from-green-500 to-green-600 rounded-lg p-6 text-white",children:(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-green-100 text-sm",children:"Total Cards"}),(0,d.jsx)("p",{className:"text-3xl font-bold",children:"-"})]}),(0,d.jsx)("div",{className:"bg-green-400 bg-opacity-30 rounded-full p-3",children:(0,d.jsx)("svg",{className:"w-8 h-8",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})})]})}),(0,d.jsx)("div",{className:"bg-gradient-to-r from-purple-500 to-purple-600 rounded-lg p-6 text-white",children:(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-purple-100 text-sm",children:"Active Sessions"}),(0,d.jsx)("p",{className:"text-3xl font-bold",children:"-"})]}),(0,d.jsx)("div",{className:"bg-purple-400 bg-opacity-30 rounded-full p-3",children:(0,d.jsx)("svg",{className:"w-8 h-8",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})})]})}),(0,d.jsx)("div",{className:"bg-gradient-to-r from-orange-500 to-orange-600 rounded-lg p-6 text-white",children:(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-orange-100 text-sm",children:"Collections"}),(0,d.jsx)("p",{className:"text-3xl font-bold",children:"-"})]}),(0,d.jsx)("div",{className:"bg-orange-400 bg-opacity-30 rounded-full p-3",children:(0,d.jsx)("svg",{className:"w-8 h-8",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})})]})})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6 mb-8",children:[(0,d.jsxs)("div",{className:"bg-white border border-gray-200 rounded-lg p-6",children:[(0,d.jsx)("h3",{className:"text-lg font-semibold text-gray-900 mb-4",children:"System Health"}),(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-sm text-gray-600",children:"Database Status"}),(0,d.jsx)("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800",children:"● Online"})]}),(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-sm text-gray-600",children:"API Status"}),(0,d.jsx)("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800",children:"● Operational"})]}),(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-sm text-gray-600",children:"Storage"}),(0,d.jsx)("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-yellow-100 text-yellow-800",children:"● 75% Used"})]})]})]}),(0,d.jsxs)("div",{className:"bg-white border border-gray-200 rounded-lg p-6",children:[(0,d.jsx)("h3",{className:"text-lg font-semibold text-gray-900 mb-4",children:"Recent Activity"}),(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsxs)("div",{className:"flex items-start",children:[(0,d.jsx)("div",{className:"bg-blue-100 rounded-full p-1 mr-3 mt-0.5",children:(0,d.jsx)("svg",{className:"w-4 h-4 text-blue-600",fill:"currentColor",viewBox:"0 0 20 20",children:(0,d.jsx)("path",{d:"M9 6a3 3 0 11-6 0 3 3 0 016 0zM17 6a3 3 0 11-6 0 3 3 0 016 0z"})})}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm text-gray-900",children:"New user registration"}),(0,d.jsx)("p",{className:"text-xs text-gray-500",children:"2 minutes ago"})]})]}),(0,d.jsxs)("div",{className:"flex items-start",children:[(0,d.jsx)("div",{className:"bg-green-100 rounded-full p-1 mr-3 mt-0.5",children:(0,d.jsx)("svg",{className:"w-4 h-4 text-green-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm text-gray-900",children:"Card database updated"}),(0,d.jsx)("p",{className:"text-xs text-gray-500",children:"15 minutes ago"})]})]}),(0,d.jsxs)("div",{className:"flex items-start",children:[(0,d.jsx)("div",{className:"bg-purple-100 rounded-full p-1 mr-3 mt-0.5",children:(0,d.jsx)("svg",{className:"w-4 h-4 text-purple-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm text-gray-900",children:"System backup completed"}),(0,d.jsx)("p",{className:"text-xs text-gray-500",children:"1 hour ago"})]})]})]})]})]}),(0,d.jsxs)("div",{className:"bg-white border border-gray-200 rounded-lg p-6",children:[(0,d.jsx)("h3",{className:"text-lg font-semibold text-gray-900 mb-4",children:"Quick Actions"}),(0,d.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[(0,d.jsxs)("button",{className:"p-4 text-center border border-gray-200 rounded-lg hover:bg-gray-50 transition-colors",children:[(0,d.jsx)("div",{className:"text-indigo-600 mb-2",children:(0,d.jsx)("svg",{className:"w-8 h-8 mx-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),(0,d.jsx)("p",{className:"text-sm font-medium text-gray-900",children:"Add User"})]}),(0,d.jsxs)("button",{className:"p-4 text-center border border-gray-200 rounded-lg hover:bg-gray-50 transition-colors",children:[(0,d.jsx)("div",{className:"text-green-600 mb-2",children:(0,d.jsx)("svg",{className:"w-8 h-8 mx-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})})}),(0,d.jsx)("p",{className:"text-sm font-medium text-gray-900",children:"Import Cards"})]}),(0,d.jsxs)("button",{className:"p-4 text-center border border-gray-200 rounded-lg hover:bg-gray-50 transition-colors",children:[(0,d.jsx)("div",{className:"text-orange-600 mb-2",children:(0,d.jsx)("svg",{className:"w-8 h-8 mx-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),(0,d.jsx)("p",{className:"text-sm font-medium text-gray-900",children:"View Reports"})]}),(0,d.jsxs)("button",{className:"p-4 text-center border border-gray-200 rounded-lg hover:bg-gray-50 transition-colors",children:[(0,d.jsx)("div",{className:"text-red-600 mb-2",children:(0,d.jsxs)("svg",{className:"w-8 h-8 mx-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}),(0,d.jsx)("p",{className:"text-sm font-medium text-gray-900",children:"Settings"})]})]})]})]}),j=()=>{let{user:a,token:b}=(0,f.A)(),[c,g]=(0,e.useState)({}),[h,i]=(0,e.useState)(!1),[j,k]=(0,e.useState)({}),[l,m]=(0,e.useState)("ALL"),[n,o]=(0,e.useState)(""),p=async()=>{try{let a=await fetch("https://tcg-vault.vercel.app/api/admin?action=card-counts",{headers:{Authorization:`Bearer ${b}`}});if(a.ok){let b=await a.json();g(b.counts||{})}}catch(a){console.error("Error fetching card counts:",a)}};(0,e.useEffect)(()=>{p()},[]);let q=async a=>{i(!0),o(`Loading ${a} cards...`),k({});try{let c=await fetch("https://tcg-vault.vercel.app/api/admin?action=load-cards",{method:"POST",headers:{Authorization:`Bearer ${b}`,"Content-Type":"application/json"},body:JSON.stringify({game:a})});if(c.ok){let a=await c.json();k(a.results||{}),o(`Successfully loaded cards! ${a.message}`),setTimeout(()=>{p()},1e3)}else{let a=await c.json();o(`Error loading cards: ${a.error}`)}}catch(a){console.error("Error loading cards:",a),o("Error loading cards. Please try again.")}finally{i(!1)}};return(0,d.jsxs)("div",{className:"bg-white rounded-lg shadow-md p-6",children:[(0,d.jsx)("h2",{className:"text-2xl font-bold text-gray-800 mb-6",children:"Card Database Loader"}),(0,d.jsxs)("div",{className:"mb-6",children:[(0,d.jsx)("h3",{className:"text-lg font-semibold text-gray-700 mb-3",children:"Current Database Status"}),(0,d.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[(0,d.jsxs)("div",{className:"bg-blue-50 p-4 rounded-lg",children:[(0,d.jsx)("div",{className:"text-2xl font-bold text-blue-600",children:c.MTG||0}),(0,d.jsx)("div",{className:"text-sm text-blue-500",children:"MTG Cards"})]}),(0,d.jsxs)("div",{className:"bg-yellow-50 p-4 rounded-lg",children:[(0,d.jsx)("div",{className:"text-2xl font-bold text-yellow-600",children:c.POKEMON||0}),(0,d.jsx)("div",{className:"text-sm text-yellow-500",children:"Pok\xe9mon Cards"})]}),(0,d.jsxs)("div",{className:"bg-purple-50 p-4 rounded-lg",children:[(0,d.jsx)("div",{className:"text-2xl font-bold text-purple-600",children:c.LORCANA||0}),(0,d.jsx)("div",{className:"text-sm text-purple-500",children:"Lorcana Cards"})]}),(0,d.jsxs)("div",{className:"bg-green-50 p-4 rounded-lg",children:[(0,d.jsx)("div",{className:"text-2xl font-bold text-green-600",children:c.total||0}),(0,d.jsx)("div",{className:"text-sm text-green-500",children:"Total Cards"})]})]})]}),(0,d.jsxs)("div",{className:"mb-6",children:[(0,d.jsx)("h3",{className:"text-lg font-semibold text-gray-700 mb-3",children:"Load Cards from External APIs"}),(0,d.jsxs)("div",{className:"flex flex-col sm:flex-row gap-4 mb-4",children:[(0,d.jsxs)("select",{value:l,onChange:a=>m(a.target.value),className:"px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent",children:[(0,d.jsx)("option",{value:"ALL",children:"All Games (MTG, Pok\xe9mon, Lorcana)"}),(0,d.jsx)("option",{value:"MTG",children:"Magic: The Gathering"}),(0,d.jsx)("option",{value:"POKEMON",children:"Pok\xe9mon"}),(0,d.jsx)("option",{value:"LORCANA",children:"Disney Lorcana"})]}),(0,d.jsx)("button",{onClick:()=>{q(l)},disabled:h,className:"px-6 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:bg-gray-400 disabled:cursor-not-allowed transition-colors",children:h?"Loading...":"Load Cards"})]}),Object.keys(j).length>0&&(0,d.jsxs)("div",{className:"bg-gray-50 p-4 rounded-lg",children:[(0,d.jsx)("h4",{className:"font-semibold text-gray-700 mb-2",children:"Loading Results:"}),(0,d.jsxs)("div",{className:"space-y-2",children:[void 0!==j.mtg&&(0,d.jsxs)("div",{className:"text-blue-600",children:["MTG: ",j.mtg," cards loaded"]}),void 0!==j.pokemon&&(0,d.jsxs)("div",{className:"text-yellow-600",children:["Pok\xe9mon: ",j.pokemon," cards loaded"]}),void 0!==j.lorcana&&(0,d.jsxs)("div",{className:"text-purple-600",children:["Lorcana: ",j.lorcana," cards loaded"]})]})]}),n&&(0,d.jsx)("div",{className:`mt-4 p-3 rounded-lg ${n.includes("Error")?"bg-red-50 text-red-700 border border-red-200":"bg-green-50 text-green-700 border border-green-200"}`,children:n})]}),(0,d.jsxs)("div",{className:"bg-gray-50 p-4 rounded-lg",children:[(0,d.jsx)("h3",{className:"text-lg font-semibold text-gray-700 mb-2",children:"Instructions"}),(0,d.jsxs)("ul",{className:"text-sm text-gray-600 space-y-1",children:[(0,d.jsx)("li",{children:"• This will load cards from external APIs into your database"}),(0,d.jsx)("li",{children:"• MTG cards come from Scryfall API"}),(0,d.jsx)("li",{children:"• Pok\xe9mon cards come from Pok\xe9mon TCG API"}),(0,d.jsx)("li",{children:"• Lorcana cards come from Lorcana API and Lorcast API"}),(0,d.jsx)("li",{children:"• Loading may take several minutes for large datasets"}),(0,d.jsx)("li",{children:"• Cards are deduplicated automatically"})]})]})]})},k=()=>{let{user:a,isAdmin:b}=(0,f.A)(),[c,k]=(0,e.useState)("dashboard");return b()?(0,d.jsxs)("div",{className:"min-h-screen bg-gray-50",children:[(0,d.jsx)("div",{className:"bg-white shadow-sm border-b border-gray-200",children:(0,d.jsx)("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:(0,d.jsxs)("div",{className:"flex justify-between items-center py-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("h1",{className:"text-2xl font-bold text-gray-900",children:"Admin Panel"}),(0,d.jsxs)("p",{className:"text-sm text-gray-600",children:["Welcome back, ",a?.firstName||a?.username]})]}),(0,d.jsx)("div",{className:"flex items-center space-x-4",children:(0,d.jsx)("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-purple-100 text-purple-800",children:"Admin"})})]})})}),(0,d.jsx)("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:(0,d.jsxs)("div",{className:"flex flex-col lg:flex-row gap-8",children:[(0,d.jsxs)("div",{className:"lg:w-64 flex-shrink-0",children:[(0,d.jsxs)("nav",{className:"bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden",children:[(0,d.jsx)("div",{className:"p-4 bg-gray-50 border-b border-gray-200",children:(0,d.jsx)("h2",{className:"text-sm font-semibold text-gray-900 uppercase tracking-wide",children:"Administration"})}),(0,d.jsx)("div",{className:"p-2",children:[{id:"dashboard",name:"Dashboard",icon:"\uD83D\uDCCA"},{id:"users",name:"Users",icon:"\uD83D\uDC65"},{id:"cards",name:"Cards",icon:"\uD83C\uDCCF"},{id:"decks",name:"Decks",icon:"\uD83D\uDCDA"},{id:"settings",name:"Settings",icon:"⚙️"}].map(a=>(0,d.jsxs)("button",{onClick:()=>k(a.id),className:`w-full flex items-center px-3 py-2 text-sm font-medium rounded-md mb-1 transition-colors duration-200 ${c===a.id?"bg-indigo-100 text-indigo-700 border-r-2 border-indigo-500":"text-gray-600 hover:bg-gray-50 hover:text-gray-900"}`,children:[(0,d.jsx)("span",{className:"mr-3 text-lg",children:a.icon}),a.name]},a.id))})]}),(0,d.jsxs)("div",{className:"mt-6 bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-gray-900 mb-3",children:"Quick Stats"}),(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,d.jsx)("span",{className:"text-gray-600",children:"Total Users"}),(0,d.jsx)("span",{className:"font-medium text-gray-900",children:"-"})]}),(0,d.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,d.jsx)("span",{className:"text-gray-600",children:"Total Cards"}),(0,d.jsx)("span",{className:"font-medium text-gray-900",children:"-"})]}),(0,d.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,d.jsx)("span",{className:"text-gray-600",children:"Active Sessions"}),(0,d.jsx)("span",{className:"font-medium text-gray-900",children:"-"})]})]})]})]}),(0,d.jsx)("div",{className:"flex-1",children:(0,d.jsx)("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 min-h-[600px]",children:(()=>{switch(c){case"dashboard":default:return(0,d.jsx)(i,{});case"users":return(0,d.jsx)(h,{});case"cards":return(0,d.jsx)(j,{});case"decks":return(0,d.jsx)("div",{className:"p-6",children:"Deck Management - Coming Soon"});case"settings":return(0,d.jsx)("div",{className:"p-6",children:"System Settings - Coming Soon"})}})()})})]})})]}):(0,d.jsx)(g.Navigate,{to:"/dashboard",replace:!0})}},4828:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),!function(a,b){for(var c in b)Object.defineProperty(a,c,{enumerable:!0,get:b[c]})}(b,{createKey:function(){return R},default:function(){return U},matchesMiddleware:function(){return J}});let d=c(7020),e=c(3147),f=c(1730),g=c(9320),h=c(1484),i=e._(c(1644)),j=c(1749),k=c(2746),l=d._(c(1217)),m=c(4718),n=c(229),o=c(5939),p=c(2417),q=c(3898),r=c(2848);c(3448);let s=c(6290),t=c(1169),u=c(7980),v=c(367),w=c(6092),x=c(617),y=c(6231),z=c(1918),A=c(9705),B=c(2620),C=c(7145),D=c(651);c(7825);let E=c(8410),F=c(3563),G=c(8652),H=c(2072);function I(){return Object.assign(Object.defineProperty(Error("Route Cancelled"),"__NEXT_ERROR_CODE",{value:"E315",enumerable:!1,configurable:!0}),{cancelled:!0})}async function J(a){let b=await Promise.resolve(a.router.pageLoader.getMiddleware());if(!b)return!1;let{pathname:c}=(0,s.parsePath)(a.asPath),d=(0,x.hasBasePath)(c)?(0,v.removeBasePath)(c):c,e=(0,w.addBasePath)((0,t.addLocale)(d,a.locale));return b.some(a=>new RegExp(a.regexp).test(e))}function K(a){let b=(0,m.getLocationOrigin)();return a.startsWith(b)?a.substring(b.length):a}function L(a,b,c){let[d,e]=(0,y.resolveHref)(a,b,!0),f=(0,m.getLocationOrigin)(),g=d.startsWith(f),h=e&&e.startsWith(f);d=K(d),e=e?K(e):e;let i=g?d:(0,w.addBasePath)(d),j=c?K((0,y.resolveHref)(a,c)):e||d;return{url:i,as:h?j:(0,w.addBasePath)(j)}}function M(a,b){let c=(0,f.removeTrailingSlash)((0,j.denormalizePagePath)(a));return"/404"===c||"/_error"===c?a:(b.includes(c)||b.some(b=>{if((0,n.isDynamicRoute)(b)&&(0,q.getRouteRegex)(b).re.test(c))return a=b,!0}),(0,f.removeTrailingSlash)(a))}async function N(a){if(!await J(a)||!a.fetchData)return null;let b=await a.fetchData(),c=await function(a,b,c){let d={basePath:c.router.basePath,i18n:{locales:c.router.locales},trailingSlash:!1},e=b.headers.get("x-nextjs-rewrite"),h=e||b.headers.get("x-nextjs-matched-path"),i=b.headers.get(H.MATCHED_PATH_HEADER);if(!i||h||i.includes("__next_data_catchall")||i.includes("/_error")||i.includes("/404")||(h=i),h){if(h.startsWith("/")){let b=(0,o.parseRelativeUrl)(h),i=(0,A.getNextPathnameInfo)(b.pathname,{nextConfig:d,parseData:!0}),j=(0,f.removeTrailingSlash)(i.pathname);return Promise.all([c.router.pageLoader.getPageList(),(0,g.getClientBuildManifest)()]).then(f=>{let[g,{__rewrites:h}]=f,l=(0,t.addLocale)(i.pathname,i.locale);if((0,n.isDynamicRoute)(l)||!e&&g.includes((0,k.normalizeLocalePath)((0,v.removeBasePath)(l),c.router.locales).pathname)){let c=(0,A.getNextPathnameInfo)((0,o.parseRelativeUrl)(a).pathname,{nextConfig:d,parseData:!0});b.pathname=l=(0,w.addBasePath)(c.pathname)}if(!g.includes(j)){let a=M(j,g);a!==j&&(j=a)}let m=g.includes(j)?j:M((0,k.normalizeLocalePath)((0,v.removeBasePath)(b.pathname),c.router.locales).pathname,g);if((0,n.isDynamicRoute)(m)){let a=(0,p.getRouteMatcher)((0,q.getRouteRegex)(m))(l);Object.assign(b.query,a||{})}return{type:"rewrite",parsedAs:b,resolvedHref:m}})}let b=(0,s.parsePath)(a);return Promise.resolve({type:"redirect-external",destination:""+(0,B.formatNextPathnameInfo)({...(0,A.getNextPathnameInfo)(b.pathname,{nextConfig:d,parseData:!0}),defaultLocale:c.router.defaultLocale,buildId:""})+b.query+b.hash})}let j=b.headers.get("x-nextjs-redirect");if(j){if(j.startsWith("/")){let a=(0,s.parsePath)(j),b=(0,B.formatNextPathnameInfo)({...(0,A.getNextPathnameInfo)(a.pathname,{nextConfig:d,parseData:!0}),defaultLocale:c.router.defaultLocale,buildId:""});return Promise.resolve({type:"redirect-internal",newAs:""+b+a.query+a.hash,newUrl:""+b+a.query+a.hash})}return Promise.resolve({type:"redirect-external",destination:j})}return Promise.resolve({type:"next"})}(b.dataHref,b.response,a);return{dataHref:b.dataHref,json:b.json,response:b.response,text:b.text,cacheKey:b.cacheKey,effect:c}}let O=Symbol("SSG_DATA_NOT_FOUND");function P(a){try{return JSON.parse(a)}catch(a){return null}}function Q(a){let{dataHref:b,inflightCache:c,isPrefetch:d,hasMiddleware:e,isServerRender:f,parseJSON:h,persistCache:i,isBackground:j,unstable_skipClientCache:k}=a,{href:l}=new URL(b,window.location.href),m=a=>{var j;return(function a(b,c,d){return fetch(b,{credentials:"same-origin",method:d.method||"GET",headers:Object.assign({},d.headers,{"x-nextjs-data":"1"})}).then(e=>!e.ok&&c>1&&e.status>=500?a(b,c-1,d):e)})(b,f?3:1,{headers:Object.assign({},d?{purpose:"prefetch"}:{},d&&e?{"x-middleware-prefetch":"1"}:{},{}),method:null!=(j=null==a?void 0:a.method)?j:"GET"}).then(c=>c.ok&&(null==a?void 0:a.method)==="HEAD"?{dataHref:b,response:c,text:"",json:{},cacheKey:l}:c.text().then(a=>{if(!c.ok){if(e&&[301,302,307,308].includes(c.status))return{dataHref:b,response:c,text:a,json:{},cacheKey:l};if(404===c.status){var d;if(null==(d=P(a))?void 0:d.notFound)return{dataHref:b,json:{notFound:O},response:c,text:a,cacheKey:l}}let h=Object.defineProperty(Error("Failed to load static props"),"__NEXT_ERROR_CODE",{value:"E124",enumerable:!1,configurable:!0});throw f||(0,g.markAssetError)(h),h}return{dataHref:b,json:h?P(a):null,response:c,text:a,cacheKey:l}})).then(a=>(i&&"no-cache"!==a.response.headers.get("x-middleware-cache")||delete c[l],a)).catch(a=>{throw k||delete c[l],("Failed to fetch"===a.message||"NetworkError when attempting to fetch resource."===a.message||"Load failed"===a.message)&&(0,g.markAssetError)(a),a})};return k&&i?m({}).then(a=>("no-cache"!==a.response.headers.get("x-middleware-cache")&&(c[l]=Promise.resolve(a)),a)):void 0!==c[l]?c[l]:c[l]=m(j?{method:"HEAD"}:{})}function R(){return Math.random().toString(36).slice(2,10)}function S(a){let{url:b,router:c}=a;if(b===(0,w.addBasePath)((0,t.addLocale)(c.asPath,c.locale)))throw Object.defineProperty(Error("Invariant: attempted to hard navigate to the same URL "+b+" "+location.href),"__NEXT_ERROR_CODE",{value:"E282",enumerable:!1,configurable:!0});window.location.href=b}let T=a=>{let{route:b,router:c}=a,d=!1,e=c.clc=()=>{d=!0};return()=>{if(d){let a=Object.defineProperty(Error('Abort fetching component for route: "'+b+'"'),"__NEXT_ERROR_CODE",{value:"E483",enumerable:!1,configurable:!0});throw a.cancelled=!0,a}e===c.clc&&(c.clc=null)}};class U{reload(){window.location.reload()}back(){window.history.back()}forward(){window.history.forward()}push(a,b,c){return void 0===c&&(c={}),{url:a,as:b}=L(this,a,b),this.change("pushState",a,b,c)}replace(a,b,c){return void 0===c&&(c={}),{url:a,as:b}=L(this,a,b),this.change("replaceState",a,b,c)}async _bfl(a,b,d,e){{if(!this._bfl_s&&!this._bfl_d){let b,f,{BloomFilter:h}=c(1219);try{({__routerFilterStatic:b,__routerFilterDynamic:f}=await (0,g.getClientBuildManifest)())}catch(b){if(console.error(b),e)return!0;return S({url:(0,w.addBasePath)((0,t.addLocale)(a,d||this.locale,this.defaultLocale)),router:this}),new Promise(()=>{})}(null==b?void 0:b.numHashes)&&(this._bfl_s=new h(b.numItems,b.errorRate),this._bfl_s.import(b)),(null==f?void 0:f.numHashes)&&(this._bfl_d=new h(f.numItems,f.errorRate),this._bfl_d.import(f))}let k=!1,l=!1;for(let{as:c,allowMatchCurrent:g}of[{as:a},{as:b}])if(c){let b=(0,f.removeTrailingSlash)(new URL(c,"http://n").pathname),m=(0,w.addBasePath)((0,t.addLocale)(b,d||this.locale));if(g||b!==(0,f.removeTrailingSlash)(new URL(this.asPath,"http://n").pathname)){var h,i,j;for(let a of(k=k||!!(null==(h=this._bfl_s)?void 0:h.contains(b))||!!(null==(i=this._bfl_s)?void 0:i.contains(m)),[b,m])){let b=a.split("/");for(let a=0;!l&&a{})}}}}return!1}async change(a,b,c,d,e){var j,k,l,y,z,A,B,G,H;let K,N;if(!(0,D.isLocalURL)(b))return S({url:b,router:this}),!1;let P=1===d._h;P||d.shallow||await this._bfl(c,void 0,d.locale);let Q=P||d._shouldResolveHref||(0,s.parsePath)(b).pathname===(0,s.parsePath)(c).pathname,R={...this.state},T=!0!==this.isReady;this.isReady=!0;let V=this.isSsr;if(P||(this.isSsr=!1),P&&this.clc)return!1;let W=R.locale;m.ST&&performance.mark("routeChange");let{shallow:X=!1,scroll:Y=!0}=d,Z={shallow:X};this._inFlightRoute&&this.clc&&(V||U.events.emit("routeChangeError",I(),this._inFlightRoute,Z),this.clc(),this.clc=null),c=(0,w.addBasePath)((0,t.addLocale)((0,x.hasBasePath)(c)?(0,v.removeBasePath)(c):c,d.locale,this.defaultLocale));let $=(0,u.removeLocale)((0,x.hasBasePath)(c)?(0,v.removeBasePath)(c):c,R.locale);this._inFlightRoute=c;let _=W!==R.locale;if(!P&&this.onlyAHashChange($)&&!_){R.asPath=$,U.events.emit("hashChangeStart",c,Z),this.changeState(a,b,c,{...d,scroll:!1}),Y&&this.scrollToHash($);try{await this.set(R,this.components[R.route],null)}catch(a){throw(0,i.default)(a)&&a.cancelled&&U.events.emit("routeChangeError",a,$,Z),a}return U.events.emit("hashChangeComplete",c,Z),!0}let aa=(0,o.parseRelativeUrl)(b),{pathname:ab,query:ac}=aa;try{[K,{__rewrites:N}]=await Promise.all([this.pageLoader.getPageList(),(0,g.getClientBuildManifest)(),this.pageLoader.getMiddleware()])}catch(a){return S({url:c,router:this}),!1}this.urlIsNew($)||_||(a="replaceState");let ad=c;ab=ab?(0,f.removeTrailingSlash)((0,v.removeBasePath)(ab)):ab;let ae=(0,f.removeTrailingSlash)(ab),af=c.startsWith("/")&&(0,o.parseRelativeUrl)(c).pathname;if(null==(j=this.components[ab])?void 0:j.__appRouter)return S({url:c,router:this}),new Promise(()=>{});let ag=!!(af&&ae!==af&&(!(0,n.isDynamicRoute)(ae)||!(0,p.getRouteMatcher)((0,q.getRouteRegex)(ae))(af))),ah=!d.shallow&&await J({asPath:c,locale:R.locale,router:this});if(P&&ah&&(Q=!1),Q&&"/_error"!==ab&&(d._shouldResolveHref=!0,aa.pathname=M(ab,K),aa.pathname!==ab&&(ab=aa.pathname,aa.pathname=(0,w.addBasePath)(ab),ah||(b=(0,r.formatWithValidation)(aa)))),!(0,D.isLocalURL)(c))return S({url:c,router:this}),!1;ad=(0,u.removeLocale)((0,v.removeBasePath)(ad),R.locale),ae=(0,f.removeTrailingSlash)(ab);let ai=!1;if((0,n.isDynamicRoute)(ae)){let a=(0,o.parseRelativeUrl)(ad),d=a.pathname,e=(0,q.getRouteRegex)(ae);ai=(0,p.getRouteMatcher)(e)(d);let f=ae===d,g=f?(0,F.interpolateAs)(ae,d,ac):{};if(ai&&(!f||g.result))f?c=(0,r.formatWithValidation)(Object.assign({},a,{pathname:g.result,query:(0,E.omit)(ac,g.params)})):Object.assign(ac,ai);else{let a=Object.keys(e.groups).filter(a=>!ac[a]&&!e.groups[a].optional);if(a.length>0&&!ah)throw Object.defineProperty(Error((f?"The provided `href` ("+b+") value is missing query values ("+a.join(", ")+") to be interpolated properly. ":"The provided `as` value ("+d+") is incompatible with the `href` value ("+ae+"). ")+"Read more: https://nextjs.org/docs/messages/"+(f?"href-interpolation-failed":"incompatible-href-as")),"__NEXT_ERROR_CODE",{value:"E344",enumerable:!1,configurable:!0})}}P||U.events.emit("routeChangeStart",c,Z);let aj="/404"===this.pathname||"/_error"===this.pathname;try{let f=await this.getRouteInfo({route:ae,pathname:ab,query:ac,as:c,resolvedAs:ad,routeProps:Z,locale:R.locale,isPreview:R.isPreview,hasMiddleware:ah,unstable_skipClientCache:d.unstable_skipClientCache,isQueryUpdating:P&&!this.isFallback,isMiddlewareRewrite:ag});if(P||d.shallow||await this._bfl(c,"resolvedAs"in f?f.resolvedAs:void 0,R.locale),"route"in f&&ah){ae=ab=f.route||ae,Z.shallow||(ac=Object.assign({},f.query||{},ac));let a=(0,x.hasBasePath)(aa.pathname)?(0,v.removeBasePath)(aa.pathname):aa.pathname;if(ai&&ab!==a&&Object.keys(ai).forEach(a=>{ai&&ac[a]===ai[a]&&delete ac[a]}),(0,n.isDynamicRoute)(ab)){let a=!Z.shallow&&f.resolvedAs?f.resolvedAs:(0,w.addBasePath)((0,t.addLocale)(new URL(c,location.href).pathname,R.locale),!0);(0,x.hasBasePath)(a)&&(a=(0,v.removeBasePath)(a));let b=(0,q.getRouteRegex)(ab),d=(0,p.getRouteMatcher)(b)(new URL(a,location.href).pathname);d&&Object.assign(ac,d)}}if("type"in f)if("redirect-internal"===f.type)return this.change(a,f.newUrl,f.newAs,d);else return S({url:f.destination,router:this}),new Promise(()=>{});let g=f.Component;if(g&&g.unstable_scriptLoader&&[].concat(g.unstable_scriptLoader()).forEach(a=>{(0,h.handleClientScriptLoad)(a.props)}),(f.__N_SSG||f.__N_SSP)&&f.props){if(f.props.pageProps&&f.props.pageProps.__N_REDIRECT){d.locale=!1;let b=f.props.pageProps.__N_REDIRECT;if(b.startsWith("/")&&!1!==f.props.pageProps.__N_REDIRECT_BASE_PATH){let c=(0,o.parseRelativeUrl)(b);c.pathname=M(c.pathname,K);let{url:e,as:f}=L(this,b,b);return this.change(a,e,f,d)}return S({url:b,router:this}),new Promise(()=>{})}if(R.isPreview=!!f.props.__N_PREVIEW,f.props.notFound===O){let a;try{await this.fetchComponent("/404"),a="/404"}catch(b){a="/_error"}if(f=await this.getRouteInfo({route:a,pathname:a,query:ac,as:c,resolvedAs:ad,routeProps:{shallow:!1},locale:R.locale,isPreview:R.isPreview,isNotFound:!0}),"type"in f)throw Object.defineProperty(Error("Unexpected middleware effect on /404"),"__NEXT_ERROR_CODE",{value:"E158",enumerable:!1,configurable:!0})}}P&&"/_error"===this.pathname&&(null==(l=self.__NEXT_DATA__.props)||null==(k=l.pageProps)?void 0:k.statusCode)===500&&(null==(y=f.props)?void 0:y.pageProps)&&(f.props.pageProps.statusCode=500);let j=d.shallow&&R.route===(null!=(z=f.route)?z:ae),m=null!=(A=d.scroll)?A:!P&&!j,r=null!=e?e:m?{x:0,y:0}:null,s={...R,route:ae,pathname:ab,query:ac,asPath:$,isFallback:!1};if(P&&aj){if(f=await this.getRouteInfo({route:this.pathname,pathname:this.pathname,query:ac,as:c,resolvedAs:ad,routeProps:{shallow:!1},locale:R.locale,isPreview:R.isPreview,isQueryUpdating:P&&!this.isFallback}),"type"in f)throw Object.defineProperty(Error("Unexpected middleware effect on "+this.pathname),"__NEXT_ERROR_CODE",{value:"E225",enumerable:!1,configurable:!0});"/_error"===this.pathname&&(null==(G=self.__NEXT_DATA__.props)||null==(B=G.pageProps)?void 0:B.statusCode)===500&&(null==(H=f.props)?void 0:H.pageProps)&&(f.props.pageProps.statusCode=500);try{await this.set(s,f,r)}catch(a){throw(0,i.default)(a)&&a.cancelled&&U.events.emit("routeChangeError",a,$,Z),a}return!0}if(U.events.emit("beforeHistoryChange",c,Z),this.changeState(a,b,c,d),!(P&&!r&&!T&&!_&&(0,C.compareRouterStates)(s,this.state))){try{await this.set(s,f,r)}catch(a){if(a.cancelled)f.error=f.error||a;else throw a}if(f.error)throw P||U.events.emit("routeChangeError",f.error,$,Z),f.error;P||U.events.emit("routeChangeComplete",c,Z),m&&/#.+$/.test(c)&&this.scrollToHash(c)}return!0}catch(a){if((0,i.default)(a)&&a.cancelled)return!1;throw a}}changeState(a,b,c,d){void 0===d&&(d={}),("pushState"!==a||(0,m.getURL)()!==c)&&(this._shallow=d.shallow,window.history[a]({url:b,as:c,options:d,__N:!0,key:this._key="pushState"!==a?this._key:R()},"",c))}async handleRouteInfoError(a,b,c,d,e,f){if(a.cancelled)throw a;if((0,g.isAssetError)(a)||f)throw U.events.emit("routeChangeError",a,d,e),S({url:d,router:this}),I();console.error(a);try{let d,{page:e,styleSheets:f}=await this.fetchComponent("/_error"),g={props:d,Component:e,styleSheets:f,err:a,error:a};if(!g.props)try{g.props=await this.getInitialProps(e,{err:a,pathname:b,query:c})}catch(a){console.error("Error in error page `getInitialProps`: ",a),g.props={}}return g}catch(a){return this.handleRouteInfoError((0,i.default)(a)?a:Object.defineProperty(Error(a+""),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0}),b,c,d,e,!0)}}async getRouteInfo(a){let{route:b,pathname:c,query:d,as:e,resolvedAs:g,routeProps:h,locale:j,hasMiddleware:l,isPreview:m,unstable_skipClientCache:n,isQueryUpdating:o,isMiddlewareRewrite:p,isNotFound:q}=a,s=b;try{var t,u,w,x;let a=this.components[s];if(h.shallow&&a&&this.route===s)return a;let b=T({route:s,router:this});l&&(a=void 0);let i=!a||"initial"in a?void 0:a,y={dataHref:this.pageLoader.getDataHref({href:(0,r.formatWithValidation)({pathname:c,query:d}),skipInterpolation:!0,asPath:q?"/404":g,locale:j}),hasMiddleware:!0,isServerRender:this.isSsr,parseJSON:!0,inflightCache:o?this.sbc:this.sdc,persistCache:!m,isPrefetch:!1,unstable_skipClientCache:n,isBackground:o},A=o&&!p?null:await N({fetchData:()=>Q(y),asPath:q?"/404":g,locale:j,router:this}).catch(a=>{if(o)return null;throw a});if(A&&("/_error"===c||"/404"===c)&&(A.effect=void 0),o&&(A?A.json=self.__NEXT_DATA__.props:A={json:self.__NEXT_DATA__.props}),b(),(null==A||null==(t=A.effect)?void 0:t.type)==="redirect-internal"||(null==A||null==(u=A.effect)?void 0:u.type)==="redirect-external")return A.effect;if((null==A||null==(w=A.effect)?void 0:w.type)==="rewrite"){let b=(0,f.removeTrailingSlash)(A.effect.resolvedHref),e=await this.pageLoader.getPageList();if((!o||e.includes(b))&&(s=b,c=A.effect.resolvedHref,d={...d,...A.effect.parsedAs.query},g=(0,v.removeBasePath)((0,k.normalizeLocalePath)(A.effect.parsedAs.pathname,this.locales).pathname),a=this.components[s],h.shallow&&a&&this.route===s&&!l))return{...a,route:s}}if((0,z.isAPIRoute)(s))return S({url:e,router:this}),new Promise(()=>{});let B=i||await this.fetchComponent(s).then(a=>({Component:a.page,styleSheets:a.styleSheets,__N_SSG:a.mod.__N_SSG,__N_SSP:a.mod.__N_SSP})),C=null==A||null==(x=A.response)?void 0:x.headers.get("x-middleware-skip"),D=B.__N_SSG||B.__N_SSP;C&&(null==A?void 0:A.dataHref)&&delete this.sdc[A.dataHref];let{props:E,cacheKey:F}=await this._getData(async()=>{if(D){if((null==A?void 0:A.json)&&!C)return{cacheKey:A.cacheKey,props:A.json};let a=(null==A?void 0:A.dataHref)?A.dataHref:this.pageLoader.getDataHref({href:(0,r.formatWithValidation)({pathname:c,query:d}),asPath:g,locale:j}),b=await Q({dataHref:a,isServerRender:this.isSsr,parseJSON:!0,inflightCache:C?{}:this.sdc,persistCache:!m,isPrefetch:!1,unstable_skipClientCache:n});return{cacheKey:b.cacheKey,props:b.json||{}}}return{headers:{},props:await this.getInitialProps(B.Component,{pathname:c,query:d,asPath:e,locale:j,locales:this.locales,defaultLocale:this.defaultLocale})}});return B.__N_SSP&&y.dataHref&&F&&delete this.sdc[F],this.isPreview||!B.__N_SSG||o||Q(Object.assign({},y,{isBackground:!0,persistCache:!1,inflightCache:this.sbc})).catch(()=>{}),E.pageProps=Object.assign({},E.pageProps),B.props=E,B.route=s,B.query=d,B.resolvedAs=g,this.components[s]=B,B}catch(a){return this.handleRouteInfoError((0,i.getProperError)(a),c,d,e,h)}}set(a,b,c){return this.state=a,this.sub(b,this.components["/_app"].Component,c)}beforePopState(a){this._bps=a}onlyAHashChange(a){if(!this.asPath)return!1;let[b,c]=this.asPath.split("#",2),[d,e]=a.split("#",2);return!!e&&b===d&&c===e||b===d&&c!==e}scrollToHash(a){let[,b=""]=a.split("#",2);(0,G.disableSmoothScrollDuringRouteTransition)(()=>{if(""===b||"top"===b)return void window.scrollTo(0,0);let a=decodeURIComponent(b),c=document.getElementById(a);if(c)return void c.scrollIntoView();let d=document.getElementsByName(a)[0];d&&d.scrollIntoView()},{onlyHashChange:this.onlyAHashChange(a)})}urlIsNew(a){return this.asPath!==a}async prefetch(a,b,c){void 0===b&&(b=a),void 0===c&&(c={});let d=(0,o.parseRelativeUrl)(a),e=d.pathname,{pathname:g,query:h}=d,i=g,j=await this.pageLoader.getPageList(),k=b,l=void 0!==c.locale?c.locale||void 0:this.locale,m=await J({asPath:b,locale:l,router:this});d.pathname=M(d.pathname,j),(0,n.isDynamicRoute)(d.pathname)&&(g=d.pathname,d.pathname=g,Object.assign(h,(0,p.getRouteMatcher)((0,q.getRouteRegex)(d.pathname))((0,s.parsePath)(b).pathname)||{}),m||(a=(0,r.formatWithValidation)(d)));let t=await N({fetchData:()=>Q({dataHref:this.pageLoader.getDataHref({href:(0,r.formatWithValidation)({pathname:i,query:h}),skipInterpolation:!0,asPath:k,locale:l}),hasMiddleware:!0,isServerRender:!1,parseJSON:!0,inflightCache:this.sdc,persistCache:!this.isPreview,isPrefetch:!0}),asPath:b,locale:l,router:this});if((null==t?void 0:t.effect.type)==="rewrite"&&(d.pathname=t.effect.resolvedHref,g=t.effect.resolvedHref,h={...h,...t.effect.parsedAs.query},k=t.effect.parsedAs.pathname,a=(0,r.formatWithValidation)(d)),(null==t?void 0:t.effect.type)==="redirect-external")return;let u=(0,f.removeTrailingSlash)(g);await this._bfl(b,k,c.locale,!0)&&(this.components[e]={__appRouter:!0}),await Promise.all([this.pageLoader._isSsg(u).then(b=>!!b&&Q({dataHref:(null==t?void 0:t.json)?null==t?void 0:t.dataHref:this.pageLoader.getDataHref({href:a,asPath:k,locale:l}),isServerRender:!1,parseJSON:!0,inflightCache:this.sdc,persistCache:!this.isPreview,isPrefetch:!0,unstable_skipClientCache:c.unstable_skipClientCache||c.priority&&!0}).then(()=>!1).catch(()=>!1)),this.pageLoader[c.priority?"loadPage":"prefetch"](u)])}async fetchComponent(a){let b=T({route:a,router:this});try{let c=await this.pageLoader.loadPage(a);return b(),c}catch(a){throw b(),a}}_getData(a){let b=!1,c=()=>{b=!0};return this.clc=c,a().then(a=>{if(c===this.clc&&(this.clc=null),b){let a=Object.defineProperty(Error("Loading initial props cancelled"),"__NEXT_ERROR_CODE",{value:"E405",enumerable:!1,configurable:!0});throw a.cancelled=!0,a}return a})}getInitialProps(a,b){let{Component:c}=this.components["/_app"],d=this._wrapApp(c);return b.AppTree=d,(0,m.loadGetInitialProps)(c,{AppTree:d,Component:a,router:this,ctx:b})}get route(){return this.state.route}get pathname(){return this.state.pathname}get query(){return this.state.query}get asPath(){return this.state.asPath}get locale(){return this.state.locale}get isFallback(){return this.state.isFallback}get isPreview(){return this.state.isPreview}constructor(a,b,c,{initialProps:d,pageLoader:e,App:g,wrapApp:h,Component:i,err:j,subscription:k,isFallback:l,locale:p,locales:q,defaultLocale:s,domainLocales:t,isPreview:u}){this.sdc={},this.sbc={},this.isFirstPopStateEvent=!0,this._key=R(),this.onPopState=a=>{let b,{isFirstPopStateEvent:c}=this;this.isFirstPopStateEvent=!1;let d=a.state;if(!d){let{pathname:a,query:b}=this;this.changeState("replaceState",(0,r.formatWithValidation)({pathname:(0,w.addBasePath)(a),query:b}),(0,m.getURL)());return}if(d.__NA)return void window.location.reload();if(!d.__N||c&&this.locale===d.options.locale&&d.as===this.asPath)return;let{url:e,as:f,options:g,key:h}=d;this._key=h;let{pathname:i}=(0,o.parseRelativeUrl)(e);(!this.isSsr||f!==(0,w.addBasePath)(this.asPath)||i!==(0,w.addBasePath)(this.pathname))&&(!this._bps||this._bps(d))&&this.change("replaceState",e,f,Object.assign({},g,{shallow:g.shallow&&this._shallow,locale:g.locale||this.defaultLocale,_h:0}),b)};let v=(0,f.removeTrailingSlash)(a);this.components={},"/_error"!==a&&(this.components[v]={Component:i,initial:!0,props:d,err:j,__N_SSG:d&&d.__N_SSG,__N_SSP:d&&d.__N_SSP}),this.components["/_app"]={Component:g,styleSheets:[]},this.events=U.events,this.pageLoader=e;let x=(0,n.isDynamicRoute)(a)&&self.__NEXT_DATA__.autoExport;this.basePath="",this.sub=k,this.clc=null,this._wrapApp=h,this.isSsr=!0,this.isLocaleDomain=!1,this.isReady=!!(self.__NEXT_DATA__.gssp||self.__NEXT_DATA__.gip||self.__NEXT_DATA__.isExperimentalCompile||self.__NEXT_DATA__.appGip&&!self.__NEXT_DATA__.gsp||!x&&!self.location.search),this.state={route:v,pathname:a,query:b,asPath:x?a:c,isPreview:!!u,locale:void 0,isFallback:l},this._initialMatchesMiddlewarePromise=Promise.resolve(!1)}}U.events=(0,l.default)()},4841:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),!function(a,b){for(var c in b)Object.defineProperty(a,c,{enumerable:!0,get:b[c]})}(b,{cancelIdleCallback:function(){return d},requestIdleCallback:function(){return c}});let c="undefined"!=typeof self&&self.requestIdleCallback&&self.requestIdleCallback.bind(window)||function(a){let b=Date.now();return self.setTimeout(function(){a({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-b))}})},1)},d="undefined"!=typeof self&&self.cancelIdleCallback&&self.cancelIdleCallback.bind(window)||function(a){return clearTimeout(a)};("function"==typeof b.default||"object"==typeof b.default&&null!==b.default)&&void 0===b.default.__esModule&&(Object.defineProperty(b.default,"__esModule",{value:!0}),Object.assign(b.default,b),a.exports=b.default)},4937:(a,b,c)=>{"use strict";c.d(b,{A:()=>f});var d=c(8732),e=c(2015);let f=({card:a,userImages:b=[],size:c="medium",showUserPhotos:f=!1,className:g=""})=>{let[h,i]=(0,e.useState)(!1),[j,k]=(0,e.useState)(0),[l,m]=(0,e.useState)(f),{ref:n,tiltStyles:o}=((a={})=>{let{maxTilt:b=15,perspective:c=1e3,scale:d=1.05,speed:f=600,reset:g=!0,easing:h="cubic-bezier(0.25, 0.46, 0.45, 0.94)"}=a,i=(0,e.useRef)(null),[j,k]=(0,e.useState)({tiltX:0,tiltY:0,scale:1,transform:""}),l=(0,e.useCallback)((a,e,f)=>{let g=f.left+f.width/2,h=(e-(f.top+f.height/2))/(f.height/2)*b,i=(g-a)/(f.width/2)*b,j=`perspective(${c}px) rotateX(${h}deg) rotateY(${i}deg) scale(${d})`;k({tiltX:h,tiltY:i,scale:d,transform:j})},[b,c,d]),m=(0,e.useCallback)(()=>{k({tiltX:0,tiltY:0,scale:1,transform:`perspective(${c}px) rotateX(0deg) rotateY(0deg) scale(1)`})},[c]),n=(0,e.useCallback)(a=>{if(!i.current)return;let b=i.current.getBoundingClientRect();l(a.clientX,a.clientY,b)},[l]),o=(0,e.useCallback)(()=>{i.current&&i.current.addEventListener("mousemove",n)},[n]),p=(0,e.useCallback)(()=>{i.current&&(i.current.removeEventListener("mousemove",n),g&&m())},[n,g,m]);(0,e.useEffect)(()=>{let a=i.current;if(a)return a.addEventListener("mouseenter",o),a.addEventListener("mouseleave",p),()=>{a.removeEventListener("mouseenter",o),a.removeEventListener("mouseleave",p),a.removeEventListener("mousemove",n)}},[o,p,n]);let q={transform:j.transform,transformStyle:"preserve-3d",transition:g?`transform ${f}ms ${h}`:"none"};return{ref:i,tiltState:j,tiltStyles:q,resetTilt:m}})({maxTilt:"large"===c?15:10,scale:1,speed:400,easing:"cubic-bezier(0.23, 1, 0.320, 1)"}),p=()=>["super rare","legendary","mythic"].includes(a.rarity.toLowerCase()),q=()=>{let b=a.rarity.toLowerCase().replace(/\s+/g,"");return`rarity-border-${b}`},r={small:"w-16 h-22",medium:"w-24 h-32",large:"w-48 h-64"},s=l&&b.length>0?b[j]:a.stock_image_url||a.image_url;if(!s||h)return(()=>{let b={MTG:"from-orange-400 to-red-500",POKEMON:"from-yellow-400 to-red-500",LORCANA:"from-purple-400 to-pink-500"}[a.game]||"from-gray-400 to-gray-600",e=q(),f=p()?"foil-rainbow":"";return(0,d.jsxs)("div",{ref:n,style:o,className:`${r[c]} bg-gradient-to-br ${b} rounded-lg flex flex-col items-center justify-center text-white shadow-md card-transition card-depth ${e} ${f} ${g}`,children:[(0,d.jsx)("div",{className:"text-lg font-bold mb-1",children:"\uD83C\uDCCF"}),(0,d.jsx)("div",{className:"text-xs text-center px-2 leading-tight",children:a.name.split(" ").slice(0,2).join(" ")}),(0,d.jsx)("div",{className:"text-xs opacity-75 mt-1",children:a.game})]})})();let t=q(),u=p()?"foil-card":"",v="legendary"===a.rarity.toLowerCase()||"mythic"===a.rarity.toLowerCase()?"holographic":"";return(0,d.jsxs)("div",{className:`relative ${g}`,children:[(0,d.jsx)("div",{ref:n,style:o,className:`card-transition card-depth ${t} ${u} ${v} rounded-lg`,children:(0,d.jsx)("img",{src:s,alt:a.name,className:`${r[c]} object-cover rounded-lg`,onError:()=>i(!0)})}),l&&b.length>0&&(0,d.jsxs)("div",{className:"absolute top-1 left-1 bg-blue-500 text-white text-xs px-1 py-0.5 rounded",children:["\uD83D\uDCF8 ",j+1,"/",b.length]}),b.length>0&&(0,d.jsx)("div",{className:"absolute bottom-1 right-1",children:(0,d.jsx)("button",{onClick:()=>m(!l),className:"bg-black bg-opacity-50 text-white text-xs px-1 py-0.5 rounded hover:bg-opacity-75",title:l?"Show stock image":"Show your photos",children:l?"\uD83D\uDCCB":"\uD83D\uDCF8"})}),l&&b.length>1&&(0,d.jsxs)("div",{className:"absolute bottom-1 left-1 flex gap-1",children:[(0,d.jsx)("button",{onClick:()=>k(a=>Math.max(0,a-1)),disabled:0===j,className:"bg-black bg-opacity-50 text-white text-xs px-1 py-0.5 rounded disabled:opacity-50",children:"‹"}),(0,d.jsx)("button",{onClick:()=>k(a=>Math.min(b.length-1,a+1)),disabled:j===b.length-1,className:"bg-black bg-opacity-50 text-white text-xs px-1 py-0.5 rounded disabled:opacity-50",children:"›"})]}),(0,d.jsx)("div",{className:"absolute top-1 right-1",children:l?(0,d.jsx)("span",{className:"bg-blue-500 text-white text-xs px-1 py-0.5 rounded",title:"Your card photo",children:"\uD83D\uDC64"}):(0,d.jsx)("span",{className:"bg-green-500 text-white text-xs px-1 py-0.5 rounded",title:"Stock image",children:"✓"})})]})}},5306:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),!function(a,b){for(var c in b)Object.defineProperty(a,c,{enumerable:!0,get:b[c]})}(b,{Router:function(){return f.default},createRouter:function(){return p},default:function(){return n},makePublicRouterInstance:function(){return q},useRouter:function(){return o},withRouter:function(){return i.default}});let d=c(7020),e=d._(c(2015)),f=d._(c(4828)),g=c(2088),h=d._(c(1644)),i=d._(c(3949)),j={router:null,readyCallbacks:[],ready(a){if(this.router)return a()}},k=["pathname","route","query","asPath","components","isFallback","basePath","locale","locales","defaultLocale","isReady","isPreview","isLocaleDomain","domainLocales"],l=["push","replace","reload","back","prefetch","beforePopState"];function m(){if(!j.router)throw Object.defineProperty(Error('No router instance found.\nYou should only use "next/router" on the client side of your app.\n'),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return j.router}Object.defineProperty(j,"events",{get:()=>f.default.events}),k.forEach(a=>{Object.defineProperty(j,a,{get:()=>m()[a]})}),l.forEach(a=>{j[a]=function(){for(var b=arguments.length,c=Array(b),d=0;d{j.ready(()=>{f.default.events.on(a,function(){for(var b=arguments.length,c=Array(b),d=0;da()),j.readyCallbacks=[],j.router}function q(a){let b={};for(let c of k){if("object"==typeof a[c]){b[c]=Object.assign(Array.isArray(a[c])?[]:{},a[c]);continue}b[c]=a[c]}return b.events=f.default.events,l.forEach(c=>{b[c]=function(){for(var b=arguments.length,d=Array(b),e=0;e{"use strict";c.d(b,{DP:()=>g,NP:()=>h});var d=c(8732),e=c(2015);let f=(0,e.createContext)(void 0),g=()=>{let a=(0,e.useContext)(f);if(void 0===a)throw Error("useTheme must be used within a ThemeProvider");return a},h=({children:a})=>{let[b,c]=(0,e.useState)(()=>localStorage.getItem("tcg-vault-theme")||"system"),[g,h]=(0,e.useState)("light");return(0,e.useEffect)(()=>{let a=()=>{"system"===b?h(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"):h(b)};a();let c=window.matchMedia("(prefers-color-scheme: dark)"),d=()=>{"system"===b&&a()};return c.addEventListener("change",d),()=>c.removeEventListener("change",d)},[b]),(0,e.useEffect)(()=>{let a=document.documentElement;"dark"===g?a.classList.add("dark"):a.classList.remove("dark");let c=document.querySelector('meta[name="theme-color"]');c&&c.setAttribute("content","dark"===g?"#0f172a":"#8b5cf6"),localStorage.setItem("tcg-vault-theme",b)},[b,g]),(0,d.jsx)(f.Provider,{value:{theme:b,effectiveTheme:g,setTheme:a=>{c(a)},toggleTheme:()=>{"light"===b?c("dark"):"dark"===b?c("system"):c("light")}},children:a})}},5678:(a,b,c)=>{"use strict";c.d(b,{A:()=>e});var d=c(8732);c(2015);let e=({children:a,rarity:b,className:c=""})=>(0,d.jsx)("div",{className:`${(()=>{let a=b.toLowerCase().replace(/\s+/g,"");return`rarity-border-${a}`})()} ${(()=>{switch(b.toLowerCase()){case"mythic":return"mythic-expansion premium-card-animation";case"legendary":case"super rare":return"premium-card-animation";default:return"card-expansion-organic"}})()} ${c}`,children:a})},5855:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{default:()=>z});var e=c(8732);c(2015);var f=c(4233),g=c(9846),h=c(4589),i=c(4670),j=c(5533),k=c(3557),l=c(907),m=c(182),n=c(8249),o=c(452),p=c(717),q=c(9456),r=c(231),s=c(3771),t=c(4587),u=a([g,h,m,n,o]);[g,h,m,n,o]=u.then?(await u)():u;let v=({children:a})=>{let{user:b,isLoading:c}=(0,i.A)(),d=(0,f.useRouter)();return c?(0,e.jsx)("div",{className:"min-h-screen-safe flex items-center justify-center bg-white dark:bg-surface-900",children:(0,e.jsxs)("div",{className:"flex flex-col items-center space-y-4",children:[(0,e.jsx)("div",{className:"w-12 h-12 bg-gradient-to-r from-primary-500 to-accent-500 rounded-xl flex items-center justify-center animate-bounce-subtle",children:(0,e.jsx)("svg",{className:"w-6 h-6 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:(0,e.jsx)("path",{d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),(0,e.jsx)("p",{className:"text-surface-600 dark:text-surface-400 text-sm",children:"Loading TCG Vault..."})]})}):b?(0,e.jsx)(e.Fragment,{children:a}):(d.push("/login"),null)},w=({children:a})=>{let{user:b,isLoading:c}=(0,i.A)(),d=(0,f.useRouter)();return c?(0,e.jsx)("div",{className:"min-h-screen-safe flex items-center justify-center bg-white dark:bg-surface-900",children:(0,e.jsxs)("div",{className:"flex flex-col items-center space-y-4",children:[(0,e.jsx)("div",{className:"w-12 h-12 bg-gradient-to-r from-primary-500 to-accent-500 rounded-xl flex items-center justify-center animate-bounce-subtle",children:(0,e.jsx)("svg",{className:"w-6 h-6 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:(0,e.jsx)("path",{d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),(0,e.jsx)("p",{className:"text-surface-600 dark:text-surface-400 text-sm",children:"Loading TCG Vault..."})]})}):b?(d.push("/dashboard"),null):(0,e.jsx)(e.Fragment,{children:a})},x=({children:a})=>(0,e.jsx)(k.A,{children:a}),y=({children:a})=>(0,e.jsx)("div",{className:"min-h-screen-safe bg-gradient-to-br from-primary-50 via-white to-accent-50 dark:from-surface-900 dark:via-surface-800 dark:to-surface-900 flex items-center justify-center px-4 transition-colors",children:(0,e.jsx)("div",{className:"w-full max-w-sm animate-slide-up",children:a})}),z=function(){let a=(0,f.useRouter)(),{pathname:b}=a;return(0,e.jsxs)(j.NP,{children:["/login"===b&&(0,e.jsx)(w,{children:(0,e.jsx)(y,{children:(0,e.jsx)(r.A,{})})}),"/register"===b&&(0,e.jsx)(w,{children:(0,e.jsx)(y,{children:(0,e.jsx)(s.A,{})})}),"/dashboard"===b&&(0,e.jsx)(v,{children:(0,e.jsx)(x,{children:(0,e.jsx)(l.A,{})})}),"/collections"===b&&(0,e.jsx)(v,{children:(0,e.jsx)(x,{children:(0,e.jsx)(m.A,{})})}),"/decks"===b&&(0,e.jsx)(v,{children:(0,e.jsx)(x,{children:(0,e.jsx)(n.A,{})})}),"/cards"===b&&(0,e.jsx)(v,{children:(0,e.jsx)(x,{children:(0,e.jsx)(o.A,{})})}),"/scanner"===b&&(0,e.jsx)(v,{children:(0,e.jsx)(x,{children:(0,e.jsx)(p.A,{})})}),"/settings"===b&&(0,e.jsx)(v,{children:(0,e.jsx)(x,{children:(0,e.jsx)(q.A,{})})}),"/admin"===b&&(0,e.jsx)(v,{children:(0,e.jsx)(x,{children:(0,e.jsx)(t.A,{})})}),"/"===b&&(0,e.jsx)(v,{children:(0,e.jsx)(x,{children:(0,e.jsx)(l.A,{})})}),!["/login","/register","/dashboard","/collections","/decks","/cards","/scanner","/settings","/admin","/"].includes(b)&&(0,e.jsx)(x,{children:(0,e.jsxs)("div",{className:"text-center py-12",children:[(0,e.jsx)("div",{className:"w-16 h-16 bg-surface-200 dark:bg-surface-700 rounded-2xl flex items-center justify-center mx-auto mb-6",children:(0,e.jsx)("svg",{className:"w-8 h-8 text-surface-500 dark:text-surface-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.172 16.172a4 4 0 015.656 0M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),(0,e.jsx)("h1",{className:"text-2xl font-bold text-surface-900 dark:text-white mb-2",children:"Page Not Found"}),(0,e.jsx)("p",{className:"text-surface-600 dark:text-surface-400 mb-6",children:"The page you're looking for doesn't exist."}),(0,e.jsx)("button",{onClick:()=>a.back(),className:"bg-primary-600 hover:bg-primary-700 text-white px-6 py-3 rounded-xl font-medium transition-colors",children:"Go Back"})]})}),(0,e.jsx)(g.Analytics,{}),(0,e.jsx)(h.SpeedInsights,{})]})};d()}catch(a){d(a)}})},5891:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{A:()=>k});var e=c(8732),f=c(2015),g=c(8462),h=c(6659),i=c(1862),j=a([g,h,i]);[g,h,i]=j.then?(await j)():j;let k=({isOpen:a,onClose:b,onCardSelect:c})=>{let[d,j]=(0,f.useState)(""),[k,l]=(0,f.useState)(""),[m,n]=(0,f.useState)({game:"",rarity:"",status:"all"}),[o,p]=(0,f.useState)(null),[q,r]=(0,f.useState)(!1);(0,f.useEffect)(()=>{let a=setTimeout(()=>{l(d)},300);return()=>clearTimeout(a)},[d]);let{data:s=[],isLoading:t}=(0,g.useQuery)({queryKey:["card-search",k,m],queryFn:()=>k.trim()?h.LO.cards.searchCards(k,m):h.LO.cards.getAllCards(m),enabled:a});return a?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"fixed inset-0 z-50 bg-black/50",onClick:b,children:(0,e.jsxs)("div",{className:"fixed bottom-0 left-0 right-0 bg-white dark:bg-surface-900 rounded-t-3xl h-[90vh] overflow-hidden animate-slide-up",children:[(0,e.jsxs)("div",{className:"p-4 pb-0",children:[(0,e.jsx)("div",{className:"w-12 h-1.5 bg-surface-300 dark:bg-surface-600 rounded-full mx-auto mb-4"}),(0,e.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,e.jsx)("h2",{className:"text-xl font-bold text-surface-900 dark:text-white",children:"Browse Cards"}),(0,e.jsx)("button",{onClick:b,className:"p-2 rounded-xl text-surface-400 hover:text-surface-600 dark:hover:text-surface-300 transition-colors",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsxs)("div",{className:"relative mb-4",children:[(0,e.jsx)("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:(0,e.jsx)("svg",{className:"h-5 w-5 text-surface-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),(0,e.jsx)("input",{type:"text",value:d,onChange:a=>j(a.target.value),placeholder:"Search cards...",className:"w-full pl-10 pr-4 py-3 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-xl text-surface-900 dark:text-white placeholder-surface-500 dark:placeholder-surface-400 focus:outline-none focus:ring-2 focus:ring-primary-500 transition-colors"})]}),(0,e.jsxs)("div",{className:"flex space-x-2 mb-4 overflow-x-auto pb-2",children:[(0,e.jsxs)("select",{value:m.game,onChange:a=>n(b=>({...b,game:a.target.value})),className:"px-3 py-2 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-primary-500 transition-colors whitespace-nowrap",children:[(0,e.jsx)("option",{value:"",children:"All Games"}),(0,e.jsx)("option",{value:"MTG",children:"Magic: The Gathering"}),(0,e.jsx)("option",{value:"POKEMON",children:"Pok\xe9mon"}),(0,e.jsx)("option",{value:"LORCANA",children:"Disney Lorcana"}),(0,e.jsx)("option",{value:"YUGIOH",children:"Yu-Gi-Oh!"})]}),(0,e.jsxs)("select",{value:m.rarity,onChange:a=>n(b=>({...b,rarity:a.target.value})),className:"px-3 py-2 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-primary-500 transition-colors whitespace-nowrap",children:[(0,e.jsx)("option",{value:"",children:"All Rarities"}),(0,e.jsx)("option",{value:"Common",children:"Common"}),(0,e.jsx)("option",{value:"Uncommon",children:"Uncommon"}),(0,e.jsx)("option",{value:"Rare",children:"Rare"}),(0,e.jsx)("option",{value:"Super Rare",children:"Super Rare"}),(0,e.jsx)("option",{value:"Legendary",children:"Legendary"}),(0,e.jsx)("option",{value:"Mythic",children:"Mythic"})]})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto px-4 pb-4",onClick:a=>a.stopPropagation(),children:t?(0,e.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,e.jsxs)("div",{className:"flex flex-col items-center",children:[(0,e.jsx)("div",{className:"w-8 h-8 bg-gradient-to-r from-primary-500 to-accent-500 rounded-full flex items-center justify-center animate-bounce-subtle mb-3",children:(0,e.jsx)("svg",{className:"w-4 h-4 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:(0,e.jsx)("path",{d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),(0,e.jsx)("p",{className:"text-surface-600 dark:text-surface-400 text-sm",children:"Searching cards..."})]})}):0===s.length?(0,e.jsxs)("div",{className:"text-center py-12",children:[(0,e.jsx)("div",{className:"w-16 h-16 bg-surface-100 dark:bg-surface-700 rounded-2xl flex items-center justify-center mx-auto mb-4",children:(0,e.jsx)("svg",{className:"w-8 h-8 text-surface-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.172 16.172a4 4 0 015.656 0M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),(0,e.jsx)("h3",{className:"text-lg font-semibold text-surface-900 dark:text-white mb-2",children:"No cards found"}),(0,e.jsx)("p",{className:"text-surface-600 dark:text-surface-400",children:"Try adjusting your search or filters"})]}):(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("p",{className:"text-sm text-surface-600 dark:text-surface-400 mb-4",children:[s.length," cards found"]}),s.map(a=>(0,e.jsxs)("div",{className:"bg-white dark:bg-surface-800 rounded-xl border border-surface-200 dark:border-surface-700 p-4 transition-colors",children:[(0,e.jsxs)("div",{className:"flex items-start space-x-4",children:[(0,e.jsx)("div",{className:"w-12 h-16 bg-surface-200 dark:bg-surface-700 rounded-lg flex items-center justify-center flex-shrink-0",children:a.image_url?(0,e.jsx)("img",{src:a.image_url,alt:a.name,className:"w-full h-full object-cover rounded-lg"}):(0,e.jsx)("svg",{className:"w-4 h-4 text-surface-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsx)("h3",{className:"font-semibold text-surface-900 dark:text-white truncate",children:a.name}),(0,e.jsx)("p",{className:"text-sm text-surface-600 dark:text-surface-400 truncate",children:a.set_name}),(0,e.jsx)("p",{className:"text-xs text-surface-500 dark:text-surface-500 mt-1",children:a.card_type}),(0,e.jsxs)("div",{className:"flex items-center space-x-2 mt-2",children:[(0,e.jsx)("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${(a=>{switch(a){case"MTG":return"bg-orange-100 text-orange-800 dark:bg-orange-900/30 dark:text-orange-300";case"POKEMON":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300";case"LORCANA":return"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300";case"YUGIOH":return"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300";default:return"bg-surface-100 text-surface-800 dark:bg-surface-700 dark:text-surface-300"}})(a.game)}`,children:a.game}),(0,e.jsx)("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${(a=>{switch(a.toLowerCase()){case"common":default:return"bg-surface-100 text-surface-800 dark:bg-surface-700 dark:text-surface-300";case"uncommon":return"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300";case"rare":return"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300";case"super rare":return"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300";case"legendary":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300";case"mythic":return"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300"}})(a.rarity)}`,children:a.rarity})]}),a.current_price&&(0,e.jsxs)("p",{className:"text-sm font-medium text-green-600 dark:text-green-400 mt-2",children:["$",a.current_price.toFixed(2)]})]}),(0,e.jsx)("button",{onClick:()=>{p(a),r(!0)},className:"bg-gradient-to-r from-primary-500 to-accent-500 hover:from-primary-600 hover:to-accent-600 text-white p-2 rounded-xl transition-all duration-200 shadow-md hover:shadow-lg transform hover:-translate-y-0.5 flex-shrink-0",children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})})})]}),(a.mana_cost||a.power&&a.toughness)&&(0,e.jsxs)("div",{className:"flex items-center justify-between mt-3 pt-3 border-t border-surface-200 dark:border-surface-700",children:[a.mana_cost&&(0,e.jsxs)("span",{className:"text-xs text-surface-600 dark:text-surface-400",children:["Mana Cost: ",a.mana_cost]}),a.power&&a.toughness&&(0,e.jsxs)("span",{className:"text-xs text-surface-600 dark:text-surface-400",children:[a.power,"/",a.toughness]})]})]},a.id))]})})]})}),q&&o&&(0,e.jsx)(i.A,{isOpen:q,onClose:()=>{r(!1),p(null)},initialCardData:o})]}):null};d()}catch(a){d(a)}})},5939:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"parseRelativeUrl",{enumerable:!0,get:function(){return e}}),c(4718);let d=c(7536);function e(a,b,c){void 0===c&&(c=!0);let e=new URL("http://n"),f=b?new URL(b,e):a.startsWith(".")?new URL("http://n"):e,{pathname:g,searchParams:h,search:i,hash:j,href:k,origin:l}=new URL(a,f);if(l!==e.origin)throw Object.defineProperty(Error("invariant: invalid relative URL, router received "+a),"__NEXT_ERROR_CODE",{value:"E159",enumerable:!1,configurable:!0});return{pathname:g,query:c?(0,d.searchParamsToUrlQuery)(h):void 0,search:i,hash:j,href:k.slice(l.length),slashes:void 0}}},6092:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"addBasePath",{enumerable:!0,get:function(){return f}});let d=c(6655),e=c(7779);function f(a,b){return(0,e.normalizePathTrailingSlash)((0,d.addPathPrefix)(a,""))}("function"==typeof b.default||"object"==typeof b.default&&null!==b.default)&&void 0===b.default.__esModule&&(Object.defineProperty(b.default,"__esModule",{value:!0}),Object.assign(b.default,b),a.exports=b.default)},6231:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"resolveHref",{enumerable:!0,get:function(){return l}});let d=c(7536),e=c(2848),f=c(8410),g=c(4718),h=c(7779),i=c(651),j=c(6275),k=c(3563);function l(a,b,c){let l,m="string"==typeof b?b:(0,e.formatWithValidation)(b),n=m.match(/^[a-z][a-z0-9+.-]*:\/\//i),o=n?m.slice(n[0].length):m;if((o.split("?",1)[0]||"").match(/(\/\/|\\)/)){console.error("Invalid href '"+m+"' passed to next/router in page: '"+a.pathname+"'. Repeated forward-slashes (//) or backslashes \\ are not valid in the href.");let b=(0,g.normalizeRepeatedSlashes)(o);m=(n?n[0]:"")+b}if(!(0,i.isLocalURL)(m))return c?[m]:m;try{l=new URL(m.startsWith("#")?a.asPath:a.pathname,"http://n")}catch(a){l=new URL("/","http://n")}try{let a=new URL(m,l);a.pathname=(0,h.normalizePathTrailingSlash)(a.pathname);let b="";if((0,j.isDynamicRoute)(a.pathname)&&a.searchParams&&c){let c=(0,d.searchParamsToUrlQuery)(a.searchParams),{result:g,params:h}=(0,k.interpolateAs)(a.pathname,a.pathname,c);g&&(b=(0,e.formatWithValidation)({pathname:g,hash:a.hash,query:(0,f.omit)(c,h)}))}let g=a.origin===l.origin?a.href.slice(a.origin.length):a.href;return c?[g,b||g]:g}catch(a){return c?[m]:m}}("function"==typeof b.default||"object"==typeof b.default&&null!==b.default)&&void 0===b.default.__esModule&&(Object.defineProperty(b.default,"__esModule",{value:!0}),Object.assign(b.default,b),a.exports=b.default)},6659:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{LO:()=>i});var e=c(1428),f=a([e]);e=(f.then?(await f)():f)[0];let g=process.env.REACT_APP_API_URL||"https://tcg-vault.vercel.app",h=e.default.create({baseURL:g,timeout:1e4,headers:{"Content-Type":"application/json"}});h.interceptors.request.use(a=>{let b=localStorage.getItem("tcg-vault-token");return b&&(a.headers.Authorization=`Bearer ${b}`),a}),h.interceptors.response.use(a=>a,a=>(a.response?.status===401&&(localStorage.removeItem("tcg-vault-token"),window.location.href="/login"),Promise.reject(a)));let i={cards:{getAllCards:async a=>(await h.get("/api/cards",{params:a})).data.data,getCard:async a=>(await h.get(`/api/cards/${a}`)).data.data,searchCards:async(a,b)=>(await h.get("/api/cards/search",{params:{q:a,...b}})).data.data,getUserCards:async a=>(await h.get("/api/user-cards",{params:a})).data.data,getUserCard:async a=>(await h.get(`/api/user-cards/${a}`)).data.data,addCard:async a=>(await h.post("/api/user-cards",a)).data.data,updateCard:async(a,b)=>(await h.put(`/api/user-cards/${a}`,b)).data.data,deleteCard:async a=>{await h.delete(`/api/user-cards/${a}`)},bulkAddCards:async a=>(await h.post("/api/user-cards/bulk",{cards:a})).data.data,bulkUpdateCards:async a=>(await h.put("/api/user-cards/bulk",{updates:a})).data.data,bulkDeleteCards:async a=>{await h.delete("/api/user-cards/bulk",{data:{ids:a}})},moveCardsToCollection:async(a,b)=>{await h.post("/api/user-cards/move-to-collection",{cardIds:a,collectionId:b})},moveCardsToDeck:async(a,b)=>{await h.post("/api/user-cards/move-to-deck",{cardIds:a,deckId:b})}},collections:{getCollections:async a=>(await h.get("/api/collections",{params:a})).data.data,getCollection:async(a,b=!0)=>(await h.get(`/api/collections/${a}`,{params:{include_cards:b}})).data.data,createCollection:async a=>(await h.post("/api/collections",a)).data.data,updateCollection:async(a,b)=>(await h.put(`/api/collections/${a}`,b)).data.data,deleteCollection:async a=>{await h.delete(`/api/collections/${a}`)},addCardsToCollection:async(a,b)=>{await h.post(`/api/collections/${a}/cards`,{cardIds:b})},removeCardsFromCollection:async(a,b)=>{await h.delete(`/api/collections/${a}/cards`,{data:{cardIds:b}})},getCollectionStats:async a=>(await h.get(`/api/collections/${a}/stats`)).data.data,duplicateCollection:async(a,b)=>(await h.post(`/api/collections/${a}/duplicate`,{name:b})).data.data,exportCollection:async(a,b)=>(await h.get(`/api/collections/${a}/export`,{params:{format:b},responseType:"blob"})).data},decks:{getDecks:async a=>(await h.get("/api/decks",{params:a})).data.data,getDeck:async a=>(await h.get(`/api/decks/${a}`)).data.data,createDeck:async a=>(await h.post("/api/decks",a)).data.data,updateDeck:async(a,b)=>(await h.put(`/api/decks/${a}`,b)).data.data,deleteDeck:async a=>{await h.delete(`/api/decks/${a}`)},addCardToDeck:async(a,b,c,d="mainboard")=>{await h.post(`/api/decks/${a}/cards`,{cardId:b,quantity:c,board:d})},updateDeckCard:async(a,b,c,d="mainboard")=>{await h.put(`/api/decks/${a}/cards/${b}`,{quantity:c,board:d})},removeDeckCard:async(a,b)=>{await h.delete(`/api/decks/${a}/cards/${b}`)},validateDeck:async a=>(await h.get(`/api/decks/${a}/validate`)).data.data,getDeckStats:async a=>(await h.get(`/api/decks/${a}/stats`)).data.data,importDeck:async a=>(await h.post("/api/decks/import",a)).data.data,exportDeck:async(a,b)=>(await h.get(`/api/decks/${a}/export`,{params:{format:b}})).data.data,duplicateDeck:async(a,b)=>(await h.post(`/api/decks/${a}/duplicate`,{name:b})).data.data},tags:{getTags:async()=>(await h.get("/api/tags")).data.data,createTag:async a=>(await h.post("/api/tags",a)).data.data,updateTag:async(a,b)=>(await h.put(`/api/tags/${a}`,b)).data.data,deleteTag:async a=>{await h.delete(`/api/tags/${a}`)},getEntitiesByTag:async a=>(await h.get(`/api/tags/${a}/entities`)).data.data},stats:{getUserStats:async()=>(await h.get("/api/stats")).data.data,getPriceAlerts:async()=>(await h.get("/api/stats/price-alerts")).data.data},scanner:{processOCR:async a=>(await h.post("/api/scanner/ocr",{imageData:a})).data.data,addScannedCards:async a=>(await h.post("/api/scanner/add-cards",{cards:a})).data.data},utils:{healthCheck:async()=>(await h.get("/api/health")).data,uploadImage:async a=>{let b=new FormData;return b.append("image",a),(await h.post("/api/upload",b,{headers:{"Content-Type":"multipart/form-data"}})).data.data}}};d()}catch(a){d(a)}})},7145:(a,b)=>{"use strict";function c(a,b){let c=Object.keys(a);if(c.length!==Object.keys(b).length)return!1;for(let d=c.length;d--;){let e=c[d];if("query"===e){let c=Object.keys(a.query);if(c.length!==Object.keys(b.query).length)return!1;for(let d=c.length;d--;){let e=c[d];if(!b.query.hasOwnProperty(e)||a.query[e]!==b.query[e])return!1}}else if(!b.hasOwnProperty(e)||a[e]!==b[e])return!1}return!0}Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"compareRouterStates",{enumerable:!0,get:function(){return c}})},7536:(a,b)=>{"use strict";function c(a){let b={};for(let[c,d]of a.entries()){let a=b[c];void 0===a?b[c]=d:Array.isArray(a)?a.push(d):b[c]=[a,d]}return b}function d(a){return"string"==typeof a?a:("number"!=typeof a||isNaN(a))&&"boolean"!=typeof a?"":String(a)}function e(a){let b=new URLSearchParams;for(let[c,e]of Object.entries(a))if(Array.isArray(e))for(let a of e)b.append(c,d(a));else b.set(c,d(e));return b}function f(a){for(var b=arguments.length,c=Array(b>1?b-1:0),d=1;d{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{A:()=>j});var e=c(8732),f=c(2015),g=c(8462),h=c(1735),i=a([g]);g=(i.then?(await i)():i)[0];let j=({isOpen:a,onClose:b,onCardSelect:c})=>{let[d,i]=(0,f.useState)(""),[j,k]=(0,f.useState)(""),[l,m]=(0,f.useState)(""),[n,o]=(0,f.useState)(null),[p,q]=(0,f.useState)(!1),[r,s]=(0,f.useState)(!1),[t,u]=(0,f.useState)("cards"),v=(0,g.useQueryClient)();(0,f.useEffect)(()=>{let a=setTimeout(()=>{k(d)},500);return()=>clearTimeout(a)},[d]);let{data:w=[],isLoading:x}=(0,g.useQuery)({queryKey:["external-cards",j,l],queryFn:async()=>{if(!j.trim())return[];s(!0);try{let a=await h.Ay.searchCards(j,l||void 0);return console.log(`Found ${a.length} cards for search "${j}" in game "${l}"`),a}catch(a){return console.error("Error searching external cards:",a),[]}finally{s(!1)}},enabled:!!j.trim()&&a,staleTime:3e5,retry:2}),{data:y=[]}=(0,g.useQuery)({queryKey:["random-cards",l],queryFn:async()=>{try{let a=await h.Ay.getRandomCards(20,l||void 0);return console.log(`Found ${a.length} random cards for game "${l}"`),a}catch(a){return console.error("Error fetching random cards:",a),[]}},enabled:a&&!j.trim(),staleTime:6e5,retry:2}),z=(0,g.useMutation)({mutationFn:async a=>{let b=await fetch("/api/cards/find-or-create",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("tcg-vault-token")}`},body:JSON.stringify({name:a.name,game:a.game,setName:a.set_name,setCode:a.set_code,rarity:a.rarity,cardType:a.card_type,manaCost:a.mana_cost,imageUrl:a.stock_image_url})});if(!b.ok)throw Error("Failed to add card to database");return(await b.json()).card},onSuccess:()=>{v.invalidateQueries({queryKey:["cards"]})}}),A=async a=>{c?(c(a),b()):(o(a),q(!0))},B=async a=>{try{await z.mutateAsync(a),alert(`${a.name} has been added to the database!`)}catch(a){console.error("Error adding card to database:",a),alert("Failed to add card to database. Please try again.")}},C=a=>{switch(a){case"MTG":return"bg-orange-100 text-orange-800 dark:bg-orange-900/30 dark:text-orange-300";case"POKEMON":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300";case"LORCANA":return"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300";case"YUGIOH":return"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300";default:return"bg-surface-100 text-surface-800 dark:bg-surface-700 dark:text-surface-300"}},D=a=>{switch(a?.toLowerCase()){case"common":default:return"bg-surface-100 text-surface-800 dark:bg-surface-700 dark:text-surface-300";case"uncommon":return"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300";case"rare":return"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300";case"super rare":return"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300";case"legendary":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300";case"mythic":return"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300"}};if(!a)return null;let E=j.trim()?w:y,F=x||r;return console.log("CardDatabaseBrowser state:",{isOpen:a,searchTerm:d,debouncedSearch:j,selectedGame:l,externalCards:w.length,randomCards:y.length,displayCards:E.length,isLoading:F}),(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"fixed inset-0 z-50 bg-black/50",onClick:b,children:(0,e.jsx)("div",{className:"fixed bottom-0 left-0 right-0 bg-white dark:bg-surface-900 rounded-t-3xl h-[90vh] overflow-hidden animate-slide-up",onClick:a=>a.stopPropagation(),children:(0,e.jsxs)("div",{className:"p-4 pb-0",children:[(0,e.jsx)("div",{className:"w-12 h-1.5 bg-surface-300 dark:bg-surface-600 rounded-full mx-auto mb-4"}),(0,e.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,e.jsx)("h2",{className:"text-xl font-bold text-surface-900 dark:text-white",children:"Card Database Browser"}),(0,e.jsx)("button",{type:"button",onClick:a=>{a.preventDefault(),a.stopPropagation(),b()},className:"p-2 rounded-xl text-surface-400 hover:text-surface-600 dark:hover:text-surface-300 transition-colors",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsxs)("div",{className:"relative mb-4",children:[(0,e.jsx)("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:(0,e.jsx)("svg",{className:"h-5 w-5 text-surface-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),(0,e.jsx)("input",{type:"text",value:d,onChange:a=>i(a.target.value),onKeyDown:a=>a.stopPropagation(),onClick:a=>a.stopPropagation(),placeholder:"Search cards from external databases...",className:"w-full pl-10 pr-4 py-3 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-xl text-surface-900 dark:text-white placeholder-surface-500 dark:placeholder-surface-400 focus:outline-none focus:ring-2 focus:ring-primary-500 transition-colors"})]}),(0,e.jsxs)("div",{className:"flex space-x-2 mb-4 overflow-x-auto pb-2",children:[(0,e.jsx)("button",{type:"button",onClick:a=>{a.preventDefault(),a.stopPropagation(),m("")},className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors whitespace-nowrap ${!l?"bg-primary-500 text-white":"bg-surface-100 dark:bg-surface-700 text-surface-700 dark:text-surface-300"}`,children:"All Games"}),(0,e.jsx)("button",{type:"button",onClick:a=>{a.preventDefault(),a.stopPropagation(),m("MTG")},className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors whitespace-nowrap ${"MTG"===l?"bg-orange-500 text-white":"bg-surface-100 dark:bg-surface-700 text-surface-700 dark:text-surface-300"}`,children:"Magic: The Gathering"}),(0,e.jsx)("button",{type:"button",onClick:a=>{a.preventDefault(),a.stopPropagation(),m("POKEMON")},className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors whitespace-nowrap ${"POKEMON"===l?"bg-yellow-500 text-white":"bg-surface-100 dark:bg-surface-700 text-surface-700 dark:text-surface-300"}`,children:"Pok\xe9mon"}),(0,e.jsx)("button",{type:"button",onClick:a=>{a.preventDefault(),a.stopPropagation(),m("YUGIOH")},className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors whitespace-nowrap ${"YUGIOH"===l?"bg-blue-500 text-white":"bg-surface-100 dark:bg-surface-700 text-surface-700 dark:text-surface-300"}`,children:"Yu-Gi-Oh!"}),(0,e.jsx)("button",{type:"button",onClick:a=>{a.preventDefault(),a.stopPropagation(),m("LORCANA")},className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors whitespace-nowrap ${"LORCANA"===l?"bg-purple-500 text-white":"bg-surface-100 dark:bg-surface-700 text-surface-700 dark:text-surface-300"}`,children:"Disney Lorcana"})]}),(0,e.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,e.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-surface-700 dark:text-surface-300",children:"View:"}),(0,e.jsxs)("button",{type:"button",onClick:a=>{a.preventDefault(),a.stopPropagation(),u("cards")},className:`px-3 py-1.5 rounded-lg text-sm font-medium transition-colors ${"cards"===t?"bg-primary-500 text-white":"bg-surface-100 dark:bg-surface-700 text-surface-700 dark:text-surface-300 hover:bg-surface-200 dark:hover:bg-surface-600"}`,children:[(0,e.jsx)("svg",{className:"w-4 h-4 inline mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zM14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6zM4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zM14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z"})}),"Cards"]}),(0,e.jsxs)("button",{type:"button",onClick:a=>{a.preventDefault(),a.stopPropagation(),u("table")},className:`px-3 py-1.5 rounded-lg text-sm font-medium transition-colors ${"table"===t?"bg-primary-500 text-white":"bg-surface-100 dark:bg-surface-700 text-surface-700 dark:text-surface-300 hover:bg-surface-200 dark:hover:bg-surface-600"}`,children:[(0,e.jsx)("svg",{className:"w-4 h-4 inline mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h18M3 14h18m-9-4v8m-7 0h14a2 2 0 002-2V8a2 2 0 00-2-2H6a2 2 0 00-2 2v8a2 2 0 002 2z"})}),"Table"]})]}),E.length>0&&(0,e.jsxs)("span",{className:"text-sm text-surface-600 dark:text-surface-400",children:[E.length," card",1!==E.length?"s":""]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto pb-20",children:F?(0,e.jsxs)("div",{className:"flex items-center justify-center py-8",children:[(0,e.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary-500"}),(0,e.jsx)("span",{className:"ml-3 text-surface-600 dark:text-surface-400",children:"Searching external databases..."})]}):0===E.length?(0,e.jsxs)("div",{className:"text-center py-8",children:[(0,e.jsx)("div",{className:"text-6xl mb-4",children:"\uD83D\uDD0D"}),(0,e.jsx)("h3",{className:"text-lg font-semibold text-surface-900 dark:text-white mb-2",children:j.trim()?"No cards found":"Discover Cards"}),(0,e.jsx)("p",{className:"text-surface-600 dark:text-surface-400",children:j.trim()?"Try adjusting your search terms or game filter":"Search for cards to see results from external databases"})]}):(0,e.jsxs)(e.Fragment,{children:["cards"===t&&(0,e.jsx)("div",{className:"grid grid-cols-1 gap-4",children:E.map(a=>(0,e.jsx)("div",{className:"bg-white dark:bg-surface-800 rounded-xl border border-surface-200 dark:border-surface-700 p-4 transition-all duration-200 hover:shadow-md",children:(0,e.jsxs)("div",{className:"flex items-start space-x-4",children:[(0,e.jsx)("div",{className:"w-16 h-20 bg-surface-200 dark:bg-surface-700 rounded-lg flex items-center justify-center flex-shrink-0",children:a.stock_image_url?(0,e.jsx)("img",{src:a.stock_image_url,alt:a.name,className:"w-full h-full object-cover rounded-lg"}):(0,e.jsx)("svg",{className:"w-6 h-6 text-surface-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsx)("h3",{className:"font-semibold text-surface-900 dark:text-white truncate",children:a.name}),(0,e.jsxs)("p",{className:"text-sm text-surface-600 dark:text-surface-400",children:[a.set_name," • ",a.card_number]}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-2 mt-2",children:[(0,e.jsx)("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${C(a.game)}`,children:a.game}),a.rarity&&(0,e.jsx)("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${D(a.rarity)}`,children:a.rarity}),a.current_price&&(0,e.jsxs)("span",{className:"px-2 py-1 bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300 rounded-full text-xs font-medium",children:["$",a.current_price]})]})]}),(0,e.jsxs)("div",{className:"flex flex-col space-y-2",children:[(0,e.jsx)("button",{type:"button",onClick:b=>{b.preventDefault(),b.stopPropagation(),A(a)},className:"px-3 py-1 bg-primary-500 hover:bg-primary-600 text-white text-xs font-medium rounded-lg transition-colors",children:"Add to Collection"}),(0,e.jsx)("button",{type:"button",onClick:b=>{b.preventDefault(),b.stopPropagation(),B(a)},disabled:z.isPending,className:"px-3 py-1 bg-surface-100 dark:bg-surface-700 hover:bg-surface-200 dark:hover:bg-surface-600 text-surface-700 dark:text-surface-300 text-xs font-medium rounded-lg transition-colors disabled:opacity-50",children:z.isPending?"Adding...":"Add to DB"})]})]})},`${a.game}-${a.id}`))}),"table"===t&&(0,e.jsx)("div",{className:"bg-white dark:bg-surface-800 rounded-xl border border-surface-200 dark:border-surface-700 overflow-hidden",children:(0,e.jsx)("div",{className:"overflow-x-auto",children:(0,e.jsxs)("table",{className:"w-full",children:[(0,e.jsx)("thead",{className:"bg-surface-50 dark:bg-surface-700",children:(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-surface-600 dark:text-surface-400 uppercase tracking-wider",children:"Card"}),(0,e.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-surface-600 dark:text-surface-400 uppercase tracking-wider",children:"Set"}),(0,e.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-surface-600 dark:text-surface-400 uppercase tracking-wider",children:"Game"}),(0,e.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-surface-600 dark:text-surface-400 uppercase tracking-wider",children:"Rarity"}),(0,e.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-surface-600 dark:text-surface-400 uppercase tracking-wider",children:"Price"}),(0,e.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-surface-600 dark:text-surface-400 uppercase tracking-wider",children:"Actions"})]})}),(0,e.jsx)("tbody",{className:"divide-y divide-surface-200 dark:divide-surface-700",children:E.map(a=>(0,e.jsxs)("tr",{className:"hover:bg-surface-50 dark:hover:bg-surface-700 transition-colors",children:[(0,e.jsx)("td",{className:"px-4 py-3",children:(0,e.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,e.jsx)("div",{className:"w-10 h-12 bg-surface-200 dark:bg-surface-700 rounded flex items-center justify-center flex-shrink-0",children:a.stock_image_url?(0,e.jsx)("img",{src:a.stock_image_url,alt:a.name,className:"w-full h-full object-cover rounded"}):(0,e.jsx)("svg",{className:"w-4 h-4 text-surface-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-surface-900 dark:text-white truncate",children:a.name}),(0,e.jsxs)("div",{className:"text-xs text-surface-500 dark:text-surface-400",children:["#",a.card_number]})]})]})}),(0,e.jsx)("td",{className:"px-4 py-3 text-sm text-surface-900 dark:text-white",children:a.set_name}),(0,e.jsx)("td",{className:"px-4 py-3",children:(0,e.jsx)("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${C(a.game)}`,children:a.game})}),(0,e.jsx)("td",{className:"px-4 py-3",children:a.rarity&&(0,e.jsx)("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${D(a.rarity)}`,children:a.rarity})}),(0,e.jsx)("td",{className:"px-4 py-3 text-sm text-surface-900 dark:text-white",children:a.current_price?`$${a.current_price}`:"-"}),(0,e.jsx)("td",{className:"px-4 py-3",children:(0,e.jsxs)("div",{className:"flex space-x-2",children:[(0,e.jsx)("button",{type:"button",onClick:b=>{b.preventDefault(),b.stopPropagation(),A(a)},className:"px-2 py-1 bg-primary-500 hover:bg-primary-600 text-white text-xs font-medium rounded transition-colors",children:"Add"}),(0,e.jsx)("button",{type:"button",onClick:b=>{b.preventDefault(),b.stopPropagation(),B(a)},disabled:z.isPending,className:"px-2 py-1 bg-surface-100 dark:bg-surface-700 hover:bg-surface-200 dark:hover:bg-surface-600 text-surface-700 dark:text-surface-300 text-xs font-medium rounded transition-colors disabled:opacity-50",children:"DB"})]})})]},`${a.game}-${a.id}`))})]})})})]})})]})})}),n&&p&&(0,e.jsx)("div",{className:"fixed inset-0 z-60",children:(0,e.jsx)("div",{className:"fixed inset-0 bg-black/50",onClick:()=>q(!1),children:(0,e.jsx)("div",{className:"fixed bottom-0 left-0 right-0 bg-white dark:bg-surface-900 rounded-t-3xl p-6 max-h-[80vh] overflow-y-auto",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsxs)("h3",{className:"text-lg font-semibold text-surface-900 dark:text-white mb-4",children:["Add ",n.name," to your collection"]}),(0,e.jsx)("p",{className:"text-surface-600 dark:text-surface-400 mb-6",children:"This card will be added to your collection with the details you specify."}),(0,e.jsxs)("div",{className:"flex space-x-4",children:[(0,e.jsx)("button",{onClick:()=>{A(n),q(!1)},className:"flex-1 bg-primary-500 hover:bg-primary-600 text-white font-medium py-3 px-6 rounded-xl transition-colors",children:"Continue"}),(0,e.jsx)("button",{onClick:()=>q(!1),className:"flex-1 bg-surface-100 dark:bg-surface-700 hover:bg-surface-200 dark:hover:bg-surface-600 text-surface-700 dark:text-surface-300 font-medium py-3 px-6 rounded-xl transition-colors",children:"Cancel"})]})]})})})})]})};d()}catch(a){d(a)}})},7779:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"normalizePathTrailingSlash",{enumerable:!0,get:function(){return f}});let d=c(1730),e=c(6290),f=a=>{if(!a.startsWith("/"))return a;let{pathname:b,query:c,hash:f}=(0,e.parsePath)(a);return""+(0,d.removeTrailingSlash)(b)+c+f};("function"==typeof b.default||"object"==typeof b.default&&null!==b.default)&&void 0===b.default.__esModule&&(Object.defineProperty(b.default,"__esModule",{value:!0}),Object.assign(b.default,b),a.exports=b.default)},7825:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),!function(a,b){for(var c in b)Object.defineProperty(a,c,{enumerable:!0,get:b[c]})}(b,{HTML_LIMITED_BOT_UA_RE:function(){return d.HTML_LIMITED_BOT_UA_RE},HTML_LIMITED_BOT_UA_RE_STRING:function(){return f},getBotType:function(){return i},isBot:function(){return h}});let d=c(8537),e=/google/i,f=d.HTML_LIMITED_BOT_UA_RE.source;function g(a){return d.HTML_LIMITED_BOT_UA_RE.test(a)}function h(a){return e.test(a)||g(a)}function i(a){return e.test(a)?"dom":g(a)?"html":void 0}},7980:(a,b,c)=>{"use strict";function d(a,b){return a}Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"removeLocale",{enumerable:!0,get:function(){return d}}),c(6290),("function"==typeof b.default||"object"==typeof b.default&&null!==b.default)&&void 0===b.default.__esModule&&(Object.defineProperty(b.default,"__esModule",{value:!0}),Object.assign(b.default,b),a.exports=b.default)},8249:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{A:()=>k});var e=c(8732),f=c(2015),g=c(8462),h=c(6659),i=c(9582),j=a([g,h,i]);[g,h,i]=j.then?(await j)():j;let k=()=>{let a=(0,g.useQueryClient)(),[b,c]=(0,f.useState)(!1),[d,j]=(0,f.useState)(null),[k,l]=(0,f.useState)({search:"",game:"",format:"",isFavorite:!1}),[m,n]=(0,f.useState)("grid"),{data:o=[],isLoading:p}=(0,g.useQuery)({queryKey:["decks",k],queryFn:()=>h.LO.decks.getDecks(k)}),q=(0,g.useMutation)({mutationFn:h.LO.decks.deleteDeck,onSuccess:()=>{a.invalidateQueries({queryKey:["decks"]})}}),r=(0,g.useMutation)({mutationFn:({id:a,isFavorite:b})=>h.LO.decks.updateDeck(a,{isFavorite:b}),onSuccess:()=>{a.invalidateQueries({queryKey:["decks"]})}}),s=o.filter(a=>{let b=!k.search||a.name.toLowerCase().includes(k.search.toLowerCase())||a.description?.toLowerCase().includes(k.search.toLowerCase()),c=!k.game||a.game===k.game,d=!k.format||a.format===k.format,e=!k.isFavorite||a.isFavorite;return b&&c&&d&&e});return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h1",{className:"text-2xl font-bold text-surface-900 dark:text-white",children:"My Decks"}),(0,e.jsx)("p",{className:"text-surface-600 dark:text-surface-400 mt-1",children:"Build and manage your card decks"})]}),(0,e.jsxs)("button",{onClick:()=>c(!0),className:"bg-gradient-to-r from-primary-500 to-accent-500 hover:from-primary-600 hover:to-accent-600 text-white px-4 py-2 rounded-xl font-medium transition-all duration-200 shadow-md hover:shadow-lg transform hover:-translate-y-0.5",children:[(0,e.jsx)("svg",{className:"w-4 h-4 mr-2 inline",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),"New Deck"]})]}),(0,e.jsx)("div",{className:"bg-white dark:bg-surface-800 rounded-xl border border-surface-200 dark:border-surface-700 p-4",children:(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:(0,e.jsx)("svg",{className:"h-5 w-5 text-surface-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),(0,e.jsx)("input",{type:"text",value:k.search,onChange:a=>l(b=>({...b,search:a.target.value})),placeholder:"Search decks...",className:"w-full pl-10 pr-4 py-3 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-xl text-surface-900 dark:text-white placeholder-surface-500 dark:placeholder-surface-400 focus:outline-none focus:ring-2 focus:ring-primary-500 transition-colors"})]}),(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"flex space-x-2 overflow-x-auto pb-2",children:[(0,e.jsxs)("select",{value:k.game,onChange:a=>l(b=>({...b,game:a.target.value})),className:"px-3 py-2 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-primary-500 transition-colors whitespace-nowrap",children:[(0,e.jsx)("option",{value:"",children:"All Games"}),(0,e.jsx)("option",{value:"MTG",children:"Magic: The Gathering"}),(0,e.jsx)("option",{value:"POKEMON",children:"Pok\xe9mon"}),(0,e.jsx)("option",{value:"LORCANA",children:"Disney Lorcana"}),(0,e.jsx)("option",{value:"YUGIOH",children:"Yu-Gi-Oh!"})]}),(0,e.jsxs)("select",{value:k.format,onChange:a=>l(b=>({...b,format:a.target.value})),className:"px-3 py-2 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-primary-500 transition-colors whitespace-nowrap",children:[(0,e.jsx)("option",{value:"",children:"All Formats"}),(0,e.jsx)("option",{value:"standard",children:"Standard"}),(0,e.jsx)("option",{value:"modern",children:"Modern"}),(0,e.jsx)("option",{value:"commander",children:"Commander"}),(0,e.jsx)("option",{value:"pioneer",children:"Pioneer"}),(0,e.jsx)("option",{value:"legacy",children:"Legacy"}),(0,e.jsx)("option",{value:"vintage",children:"Vintage"})]}),(0,e.jsx)("button",{onClick:()=>l(a=>({...a,isFavorite:!a.isFavorite})),className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors whitespace-nowrap ${k.isFavorite?"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300":"bg-surface-50 dark:bg-surface-700 text-surface-700 dark:text-surface-300 border border-surface-300 dark:border-surface-600"}`,children:"⭐ Favorites"})]}),(0,e.jsxs)("div",{className:"flex bg-surface-100 dark:bg-surface-700 rounded-lg p-1",children:[(0,e.jsx)("button",{onClick:()=>n("grid"),className:`p-2 rounded-md transition-colors ${"grid"===m?"bg-white dark:bg-surface-600 text-surface-900 dark:text-white shadow-sm":"text-surface-600 dark:text-surface-400 hover:text-surface-900 dark:hover:text-white"}`,children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zM14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6zM4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zM14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z"})})}),(0,e.jsx)("button",{onClick:()=>n("list"),className:`p-2 rounded-md transition-colors ${"list"===m?"bg-white dark:bg-surface-600 text-surface-900 dark:text-white shadow-sm":"text-surface-600 dark:text-surface-400 hover:text-surface-900 dark:hover:text-white"}`,children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 10h16M4 14h16M4 18h16"})})})]})]})]})}),p?(0,e.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,e.jsxs)("div",{className:"flex flex-col items-center",children:[(0,e.jsx)("div",{className:"w-8 h-8 bg-gradient-to-r from-primary-500 to-accent-500 rounded-full flex items-center justify-center animate-bounce-subtle mb-3",children:(0,e.jsx)("svg",{className:"w-4 h-4 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:(0,e.jsx)("path",{d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),(0,e.jsx)("p",{className:"text-surface-600 dark:text-surface-400 text-sm",children:"Loading decks..."})]})}):0===s.length?(0,e.jsx)("div",{className:"bg-white dark:bg-surface-800 rounded-xl border border-surface-200 dark:border-surface-700 p-8",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("div",{className:"w-16 h-16 bg-surface-100 dark:bg-surface-700 rounded-2xl flex items-center justify-center mx-auto mb-6",children:(0,e.jsx)("svg",{className:"w-8 h-8 text-surface-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),(0,e.jsx)("h3",{className:"text-xl font-semibold text-surface-900 dark:text-white mb-2",children:0===o.length?"No decks yet":"No matching decks"}),(0,e.jsx)("p",{className:"text-surface-600 dark:text-surface-400 mb-6",children:0===o.length?"Start building your first deck from your collection":"Try adjusting your search or filters"}),0===o.length&&(0,e.jsx)("button",{onClick:()=>c(!0),className:"bg-gradient-to-r from-primary-500 to-accent-500 hover:from-primary-600 hover:to-accent-600 text-white px-6 py-3 rounded-xl font-medium transition-all duration-200 shadow-md hover:shadow-lg transform hover:-translate-y-0.5",children:"Create Deck"})]})}):(0,e.jsx)("div",{className:"grid"===m?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4":"space-y-4",children:s.map(a=>(0,e.jsxs)("div",{className:"bg-white dark:bg-surface-800 rounded-xl border border-surface-200 dark:border-surface-700 p-4 transition-all duration-200 hover:shadow-md",children:[(0,e.jsxs)("div",{className:"flex items-start justify-between mb-4",children:[(0,e.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,e.jsx)("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center text-white text-xl font-semibold shadow-md",style:{backgroundColor:a.color||"#8b5cf6"},children:"\uD83C\uDFB4"}),(0,e.jsxs)("div",{className:"flex-1",children:[(0,e.jsx)("h3",{className:"font-semibold text-surface-900 dark:text-white",children:a.name}),a.description&&(0,e.jsx)("p",{className:"text-sm text-surface-600 dark:text-surface-400 line-clamp-2",children:a.description})]})]}),(0,e.jsx)("button",{onClick:()=>(a=>{r.mutate({id:a.id,isFavorite:!a.isFavorite})})(a),className:`p-2 rounded-lg transition-colors ${a.isFavorite?"text-yellow-500 hover:text-yellow-600":"text-surface-400 hover:text-yellow-500"}`,children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:a.isFavorite?"currentColor":"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"})})})]}),(0,e.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,e.jsxs)("div",{className:"flex items-center space-x-4 text-sm text-surface-600 dark:text-surface-400",children:[(0,e.jsxs)("span",{children:[a.totalCards||0," cards"]}),a.totalValue&&(0,e.jsxs)("span",{className:"text-green-600 dark:text-green-400 font-medium",children:["$",a.totalValue.toFixed(2)]})]}),(0,e.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,e.jsx)("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${(a=>{switch(a){case"MTG":return"bg-orange-100 text-orange-800 dark:bg-orange-900/30 dark:text-orange-300";case"POKEMON":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300";case"LORCANA":return"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300";case"YUGIOH":return"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300";default:return"bg-surface-100 text-surface-800 dark:bg-surface-700 dark:text-surface-300"}})(a.game)}`,children:a.game}),a.format&&(0,e.jsx)("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${(a=>{switch(a.toLowerCase()){case"standard":return"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300";case"modern":return"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300";case"commander":return"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300";case"pioneer":return"bg-orange-100 text-orange-800 dark:bg-orange-900/30 dark:text-orange-300";case"legacy":return"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300";case"vintage":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300";default:return"bg-surface-100 text-surface-800 dark:bg-surface-700 dark:text-surface-300"}})(a.format)}`,children:a.format})]})]}),(0,e.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,e.jsxs)("div",{className:"flex items-center space-x-2",children:[void 0!==a.isLegal&&(0,e.jsx)("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${a.isLegal?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300":"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300"}`,children:a.isLegal?"✅ Legal":"❌ Illegal"}),a.averageManaValue&&(0,e.jsxs)("span",{className:"px-2 py-1 bg-surface-100 dark:bg-surface-700 text-surface-700 dark:text-surface-300 rounded-full text-xs font-medium",children:[a.averageManaValue.toFixed(1)," CMC"]})]})}),(0,e.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,e.jsx)("button",{onClick:()=>{},className:"flex-1 bg-primary-50 dark:bg-primary-900/20 text-primary-700 dark:text-primary-300 py-2 px-3 rounded-lg text-sm font-medium hover:bg-primary-100 dark:hover:bg-primary-900/30 transition-colors",children:"View Deck"}),(0,e.jsx)("button",{onClick:()=>j(a.id),className:"p-2 text-surface-400 hover:text-surface-600 dark:hover:text-surface-300 rounded-lg transition-colors",children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,e.jsx)("button",{onClick:()=>{var b,c;return b=a.id,c=a.name,void(window.confirm(`Are you sure you want to delete "${c}"? This action cannot be undone.`)&&q.mutate(b))},className:"p-2 text-red-400 hover:text-red-600 rounded-lg transition-colors",disabled:q.isPending,children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})]},a.id))}),(0,e.jsx)(i.A,{isOpen:b||!!d,onClose:()=>{c(!1),j(null)},deckId:d||void 0})]})};d()}catch(a){d(a)}})},8333:(a,b)=>{"use strict";function c(a,b){return void 0===b&&(b=""),("/"===a?"/index":/^\/index(\/|$)/.test(a)?"/index"+a:a)+b}Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"default",{enumerable:!0,get:function(){return c}})},8410:(a,b)=>{"use strict";function c(a,b){let c={};return Object.keys(a).forEach(d=>{b.includes(d)||(c[d]=a[d])}),c}Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"omit",{enumerable:!0,get:function(){return c}})},8537:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"HTML_LIMITED_BOT_UA_RE",{enumerable:!0,get:function(){return c}});let c=/Mediapartners-Google|Chrome-Lighthouse|Slurp|DuckDuckBot|baiduspider|yandex|sogou|bitlybot|tumblr|vkShare|quora link preview|redditbot|ia_archiver|Bingbot|BingPreview|applebot|facebookexternalhit|facebookcatalog|Twitterbot|LinkedInBot|Slackbot|Discordbot|WhatsApp|SkypeUriPreview|Yeti/i},8542:(a,b)=>{"use strict";let c;function d(a){return(null==c?void 0:c.createScriptURL(a))||a}Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"__unsafeCreateTrustedScriptURL",{enumerable:!0,get:function(){return d}}),("function"==typeof b.default||"object"==typeof b.default&&null!==b.default)&&void 0===b.default.__esModule&&(Object.defineProperty(b.default,"__esModule",{value:!0}),Object.assign(b.default,b),a.exports=b.default)},8550:(a,b,c)=>{(()=>{var b={154:(a,b,c)=>{var d=c(781),e=["write","end","destroy"],f=["resume","pause"],g=["data","close"],h=Array.prototype.slice;function i(a,b){if(a.forEach)return a.forEach(b);for(var c=0;c{"use strict";let d=c(147),e=c(781),f=c(796),g=c(154),h=c(530),i=a=>Object.assign({level:9},a);a.exports=(a,b)=>a?h(f.gzip)(a,i(b)).then(a=>a.length).catch(a=>0):Promise.resolve(0),a.exports.sync=(a,b)=>f.gzipSync(a,i(b)).length,a.exports.stream=a=>{let b=new e.PassThrough,c=new e.PassThrough,d=g(b,c),h=0,j=f.createGzip(i(a)).on("data",a=>{h+=a.length}).on("error",()=>{d.gzipSize=0}).on("end",()=>{d.gzipSize=h,d.emit("gzip-size",h),c.end()});return b.pipe(j),b.pipe(c,{end:!1}),d},a.exports.file=(b,c)=>new Promise((e,f)=>{let g=d.createReadStream(b);g.on("error",f);let h=g.pipe(a.exports.stream(c));h.on("error",f),h.on("gzip-size",e)}),a.exports.fileSync=(b,c)=>a.exports.sync(d.readFileSync(b),c)},530:a=>{"use strict";let b=(a,b)=>function(...c){return new b.promiseModule((d,e)=>{b.multiArgs?c.push((...a)=>{b.errorFirst?a[0]?e(a):(a.shift(),d(a)):d(a)}):b.errorFirst?c.push((a,b)=>{a?e(a):d(b)}):c.push(d),a.apply(this,c)})};a.exports=(a,c)=>{let d;c=Object.assign({exclude:[/.+(Sync|Stream)$/],errorFirst:!0,promiseModule:Promise},c);let e=typeof a;if(null===a||"object"!==e&&"function"!==e)throw TypeError(`Expected \`input\` to be a \`Function\` or \`Object\`, got \`${null===a?"null":e}\``);let f=a=>{let b=b=>"string"==typeof b?a===b:b.test(a);return c.include?c.include.some(b):!c.exclude.some(b)};for(let g in d="function"===e?function(...d){return c.excludeMain?a(...d):b(a,c).apply(this,d)}:Object.create(Object.getPrototypeOf(a)),a){let e=a[g];d[g]="function"==typeof e&&f(g)?b(e,c):e}return d}},147:a=>{"use strict";a.exports=c(9021)},781:a=>{"use strict";a.exports=c(7910)},796:a=>{"use strict";a.exports=c(4075)}},d={};function e(a){var c=d[a];if(void 0!==c)return c.exports;var f=d[a]={exports:{}},g=!0;try{b[a](f,f.exports,e),g=!1}finally{g&&delete d[a]}return f.exports}e.ab=__dirname+"/",a.exports=e(349)})()},8652:(a,b,c)=>{"use strict";function d(a,b){if(void 0===b&&(b={}),b.onlyHashChange)return void a();let c=document.documentElement;c.dataset.scrollBehavior;let d=c.style.scrollBehavior;c.style.scrollBehavior="auto",b.dontForceLayout||c.getClientRects(),a(),c.style.scrollBehavior=d}Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"disableSmoothScrollDuringRouteTransition",{enumerable:!0,get:function(){return d}}),c(1025)},8900:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"escapeStringRegexp",{enumerable:!0,get:function(){return e}});let c=/[|\\{}()[\]^$+*?.-]/,d=/[|\\{}()[\]^$+*?.-]/g;function e(a){return c.test(a)?a.replace(d,"\\$&"):a}},8941:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"setAttributesFromProps",{enumerable:!0,get:function(){return f}});let c={acceptCharset:"accept-charset",className:"class",htmlFor:"for",httpEquiv:"http-equiv",noModule:"noModule"},d=["onLoad","onReady","dangerouslySetInnerHTML","children","onError","strategy","stylesheets"];function e(a){return["async","defer","noModule"].includes(a)}function f(a,b){for(let[f,g]of Object.entries(b)){if(!b.hasOwnProperty(f)||d.includes(f)||void 0===g)continue;let h=c[f]||f.toLowerCase();"SCRIPT"===a.tagName&&e(h)?a[h]=!!g:a.setAttribute(h,String(g)),(!1===g||"SCRIPT"===a.tagName&&e(h)&&(!g||"false"===g))&&(a.setAttribute(h,""),a.removeAttribute(h))}}("function"==typeof b.default||"object"==typeof b.default&&null!==b.default)&&void 0===b.default.__esModule&&(Object.defineProperty(b.default,"__esModule",{value:!0}),Object.assign(b.default,b),a.exports=b.default)},9007:(a,b)=>{"use strict";function c(){return""}Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"getDeploymentIdQueryOrEmptyString",{enumerable:!0,get:function(){return c}})},9320:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),!function(a,b){for(var c in b)Object.defineProperty(a,c,{enumerable:!0,get:b[c]})}(b,{createRouteLoader:function(){return q},getClientBuildManifest:function(){return o},isAssetError:function(){return k},markAssetError:function(){return j}}),c(7020),c(8333);let d=c(8542),e=c(4841),f=c(9007),g=c(5296);function h(a,b,c){let d,e=b.get(a);if(e)return"future"in e?e.future:Promise.resolve(e);let f=new Promise(a=>{d=a});return b.set(a,{resolve:d,future:f}),c?c().then(a=>(d(a),a)).catch(c=>{throw b.delete(a),c}):f}let i=Symbol("ASSET_LOAD_ERROR");function j(a){return Object.defineProperty(a,i,{})}function k(a){return a&&i in a}let l=function(a){try{return a=document.createElement("link"),!!window.MSInputMethodContext&&!!document.documentMode||a.relList.supports("prefetch")}catch(a){return!1}}(),m=()=>(0,f.getDeploymentIdQueryOrEmptyString)();function n(a,b,c){return new Promise((d,f)=>{let g=!1;a.then(a=>{g=!0,d(a)}).catch(f),(0,e.requestIdleCallback)(()=>setTimeout(()=>{g||f(c)},b))})}function o(){return self.__BUILD_MANIFEST?Promise.resolve(self.__BUILD_MANIFEST):n(new Promise(a=>{let b=self.__BUILD_MANIFEST_CB;self.__BUILD_MANIFEST_CB=()=>{a(self.__BUILD_MANIFEST),b&&b()}}),3800,j(Object.defineProperty(Error("Failed to load client build manifest"),"__NEXT_ERROR_CODE",{value:"E273",enumerable:!1,configurable:!0})))}function p(a,b){return o().then(c=>{if(!(b in c))throw j(Object.defineProperty(Error("Failed to lookup route: "+b),"__NEXT_ERROR_CODE",{value:"E446",enumerable:!1,configurable:!0}));let e=c[b].map(b=>a+"/_next/"+(0,g.encodeURIPath)(b));return{scripts:e.filter(a=>a.endsWith(".js")).map(a=>(0,d.__unsafeCreateTrustedScriptURL)(a)+m()),css:e.filter(a=>a.endsWith(".css")).map(a=>a+m())}})}function q(a){let b=new Map,c=new Map,d=new Map,f=new Map;function g(a){{var b;let d=c.get(a.toString());return d?d:document.querySelector('script[src^="'+a+'"]')?Promise.resolve():(c.set(a.toString(),d=new Promise((c,d)=>{(b=document.createElement("script")).onload=c,b.onerror=()=>d(j(Object.defineProperty(Error("Failed to load script: "+a),"__NEXT_ERROR_CODE",{value:"E74",enumerable:!1,configurable:!0}))),b.crossOrigin=void 0,b.src=a,document.body.appendChild(b)})),d)}}function i(a){let b=d.get(a);return b||d.set(a,b=fetch(a,{credentials:"same-origin"}).then(b=>{if(!b.ok)throw Object.defineProperty(Error("Failed to load stylesheet: "+a),"__NEXT_ERROR_CODE",{value:"E189",enumerable:!1,configurable:!0});return b.text().then(b=>({href:a,content:b}))}).catch(a=>{throw j(a)})),b}return{whenEntrypoint:a=>h(a,b),onEntrypoint(a,c){(c?Promise.resolve().then(()=>c()).then(a=>({component:a&&a.default||a,exports:a}),a=>({error:a})):Promise.resolve(void 0)).then(c=>{let d=b.get(a);d&&"resolve"in d?c&&(b.set(a,c),d.resolve(c)):(c?b.set(a,c):b.delete(a),f.delete(a))})},loadRoute(c,d){return h(c,f,()=>{let e;return n(p(a,c).then(a=>{let{scripts:d,css:e}=a;return Promise.all([b.has(c)?[]:Promise.all(d.map(g)),Promise.all(e.map(i))])}).then(a=>this.whenEntrypoint(c).then(b=>({entrypoint:b,styles:a[1]}))),3800,j(Object.defineProperty(Error("Route did not complete loading: "+c),"__NEXT_ERROR_CODE",{value:"E12",enumerable:!1,configurable:!0}))).then(a=>{let{entrypoint:b,styles:c}=a,d=Object.assign({styles:c},b);return"error"in b?b:d}).catch(a=>{if(d)throw a;return{error:a}}).finally(()=>null==e?void 0:e())})},prefetch(b){let c;return(c=navigator.connection)&&(c.saveData||/2g/.test(c.effectiveType))?Promise.resolve():p(a,b).then(a=>Promise.all(l?a.scripts.map(a=>{var b,c,d;return b=a.toString(),c="script",new Promise((a,e)=>{let f='\n link[rel="prefetch"][href^="'+b+'"],\n link[rel="preload"][href^="'+b+'"],\n script[src^="'+b+'"]';if(document.querySelector(f))return a();d=document.createElement("link"),c&&(d.as=c),d.rel="prefetch",d.crossOrigin=void 0,d.onload=a,d.onerror=()=>e(j(Object.defineProperty(Error("Failed to prefetch: "+b),"__NEXT_ERROR_CODE",{value:"E268",enumerable:!1,configurable:!0}))),d.href=b,document.head.appendChild(d)})}):[])).then(()=>{(0,e.requestIdleCallback)(()=>this.loadRoute(b,!0).catch(()=>{}))}).catch(()=>{})}}}("function"==typeof b.default||"object"==typeof b.default&&null!==b.default)&&void 0===b.default.__esModule&&(Object.defineProperty(b.default,"__esModule",{value:!0}),Object.assign(b.default,b),a.exports=b.default)},9456:(a,b,c)=>{"use strict";c.d(b,{A:()=>g});var d=c(8732),e=c(2015),f=c(4670);let g=()=>{let{user:a}=(0,f.A)(),[b,c]=(0,e.useState)(null),[g,h]=(0,e.useState)(!0),[i,j]=(0,e.useState)(!1),[k,l]=(0,e.useState)(null),[m,n]=(0,e.useState)("general"),[o,p]=(0,e.useState)(!1),[q,r]=(0,e.useState)(!1),[s,t]=(0,e.useState)({});(0,e.useEffect)(()=>{u()},[a]);let u=async()=>{if(a)try{let a=localStorage.getItem("tcg_vault_token"),b=await fetch("/api/user/preferences",{headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json"}});if(b.ok){let a=await b.json();c(a.preferences)}else l({type:"error",text:"Failed to load preferences"})}catch(a){console.error("Error loading preferences:",a),l({type:"error",text:"Error loading preferences"})}finally{h(!1)}},v=async()=>{if(b){j(!0);try{let a=localStorage.getItem("tcg_vault_token"),d=await fetch("/api/user/preferences",{method:"PUT",headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json"},body:JSON.stringify(b)}),e=await d.json();d.ok?(l({type:"success",text:"Settings saved successfully!"}),c(e.preferences)):l({type:"error",text:e.error||"Failed to save settings"})}catch(a){console.error("Error saving preferences:",a),l({type:"error",text:"Error saving settings"})}finally{j(!1)}}},w=async()=>{if(!b?.ocrSettings.openai_api_key)return void t(a=>({...a,openai:"❌ API key required"}));p(!0);try{let a=await fetch("https://api.openai.com/v1/models",{headers:{Authorization:`Bearer ${b.ocrSettings.openai_api_key}`}});a.ok?t(a=>({...a,openai:"✅ API key valid"})):t(b=>({...b,openai:`❌ API error: ${a.status}`}))}catch(a){t(b=>({...b,openai:`❌ Connection failed: ${a.message}`}))}finally{p(!1)}},x=async()=>{if(b?.ocrSettings.ollama_url){r(!0);try{let a=await fetch(`${b.ocrSettings.ollama_url}/api/tags`);if(a.ok){let b=await a.json();b.models?.some(a=>a.name.includes("llava")||a.name.includes("vision"))?t(a=>({...a,ollama:"✅ Ollama with vision models available"})):t(a=>({...a,ollama:"⚠️ Ollama running but no vision models found"}))}else t(b=>({...b,ollama:`❌ Ollama error: ${a.status}`}))}catch(a){t(b=>({...b,ollama:`❌ Cannot reach Ollama: ${a.message}`}))}finally{r(!1)}}},y=(a,d)=>{b&&c({...b,[a]:d})},z=(a,d)=>{b&&c({...b,ocrSettings:{...b.ocrSettings,[a]:d}})};return g?(0,d.jsx)("div",{className:"flex items-center justify-center min-h-screen",children:(0,d.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-indigo-600"})}):b?(0,d.jsxs)("div",{className:"max-w-4xl mx-auto p-6",children:[(0,d.jsxs)("div",{className:"mb-8",children:[(0,d.jsx)("h1",{className:"text-3xl font-bold text-gray-900 mb-2",children:"Settings"}),(0,d.jsx)("p",{className:"text-gray-600",children:"Manage your account preferences and OCR configuration"})]}),k&&(0,d.jsx)("div",{className:`mb-6 p-4 rounded-lg ${"success"===k.type?"bg-green-50 text-green-800 border border-green-200":"bg-red-50 text-red-800 border border-red-200"}`,children:k.text}),(0,d.jsx)("div",{className:"border-b border-gray-200 mb-6",children:(0,d.jsx)("nav",{className:"-mb-px flex space-x-8",children:[{id:"general",label:"General",icon:"⚙️"},{id:"ocr",label:"AI OCR",icon:"\uD83E\uDD16"},{id:"privacy",label:"Privacy",icon:"\uD83D\uDD12"}].map(a=>(0,d.jsxs)("button",{onClick:()=>n(a.id),className:`py-2 px-1 border-b-2 font-medium text-sm ${m===a.id?"border-indigo-500 text-indigo-600":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"}`,children:[(0,d.jsx)("span",{className:"mr-2",children:a.icon}),a.label]},a.id))})}),(0,d.jsxs)("div",{className:"space-y-6",children:["general"===m&&(0,d.jsxs)("div",{className:"bg-white rounded-lg border border-gray-200 p-6",children:[(0,d.jsx)("h3",{className:"text-lg font-medium mb-4",children:"General Preferences"}),(0,d.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Default View"}),(0,d.jsxs)("select",{value:b.defaultView,onChange:a=>y("defaultView",a.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-indigo-500 focus:border-indigo-500",children:[(0,d.jsx)("option",{value:"card",children:"Card View"}),(0,d.jsx)("option",{value:"table",children:"Table View"})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Items per Page"}),(0,d.jsxs)("select",{value:b.itemsPerPage,onChange:a=>y("itemsPerPage",parseInt(a.target.value)),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-indigo-500 focus:border-indigo-500",children:[(0,d.jsx)("option",{value:10,children:"10"}),(0,d.jsx)("option",{value:20,children:"20"}),(0,d.jsx)("option",{value:50,children:"50"}),(0,d.jsx)("option",{value:100,children:"100"})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Theme"}),(0,d.jsxs)("select",{value:b.theme,onChange:a=>y("theme",a.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-indigo-500 focus:border-indigo-500",children:[(0,d.jsx)("option",{value:"light",children:"Light"}),(0,d.jsx)("option",{value:"dark",children:"Dark"}),(0,d.jsx)("option",{value:"system",children:"System"})]})]}),(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsxs)("label",{className:"flex items-center",children:[(0,d.jsx)("input",{type:"checkbox",checked:b.enableAnimations,onChange:a=>y("enableAnimations",a.target.checked),className:"rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"}),(0,d.jsx)("span",{className:"ml-2 text-sm text-gray-700",children:"Enable animations"})]}),(0,d.jsxs)("label",{className:"flex items-center",children:[(0,d.jsx)("input",{type:"checkbox",checked:b.enableOcr,onChange:a=>y("enableOcr",a.target.checked),className:"rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"}),(0,d.jsx)("span",{className:"ml-2 text-sm text-gray-700",children:"Enable OCR scanning"})]})]})]})]}),"ocr"===m&&(0,d.jsxs)("div",{className:"bg-white rounded-lg border border-gray-200 p-6",children:[(0,d.jsx)("h3",{className:"text-lg font-medium mb-4",children:"AI OCR Configuration"}),(0,d.jsxs)("div",{className:"mb-6",children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-3",children:"Preferred OCR Service"}),(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsxs)("label",{className:"flex items-center",children:[(0,d.jsx)("input",{type:"radio",value:"openai",checked:"openai"===b.ocrSettings.preferred_service,onChange:a=>z("preferred_service",a.target.value),className:"text-indigo-600 focus:ring-indigo-500"}),(0,d.jsx)("span",{className:"ml-2 text-sm text-gray-700",children:"OpenAI Vision API (Recommended)"})]}),(0,d.jsxs)("label",{className:"flex items-center",children:[(0,d.jsx)("input",{type:"radio",value:"ollama",checked:"ollama"===b.ocrSettings.preferred_service,onChange:a=>z("preferred_service",a.target.value),className:"text-indigo-600 focus:ring-indigo-500"}),(0,d.jsx)("span",{className:"ml-2 text-sm text-gray-700",children:"Ollama (Local/Private)"})]})]})]}),(0,d.jsxs)("div",{className:"border rounded-lg p-4 mb-6",children:[(0,d.jsx)("h4",{className:"font-medium text-gray-900 mb-3",children:"OpenAI Configuration"}),(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"API Key"}),(0,d.jsx)("input",{type:"password",value:b.ocrSettings.openai_api_key,onChange:a=>z("openai_api_key",a.target.value),placeholder:"sk-...",className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-indigo-500 focus:border-indigo-500"}),(0,d.jsxs)("p",{className:"text-xs text-gray-500 mt-1",children:["Get your API key from"," ",(0,d.jsx)("a",{href:"https://platform.openai.com/api-keys",target:"_blank",rel:"noopener noreferrer",className:"text-indigo-600 hover:underline",children:"OpenAI Platform"})]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{onClick:w,disabled:o||!b.ocrSettings.openai_api_key,className:"bg-blue-600 text-white px-3 py-1 rounded text-sm disabled:bg-gray-400 hover:bg-blue-700",children:o?"Testing...":"Test API Key"}),s.openai&&(0,d.jsx)("span",{className:"text-sm",children:s.openai})]})]})]}),(0,d.jsxs)("div",{className:"border rounded-lg p-4 mb-6",children:[(0,d.jsx)("h4",{className:"font-medium text-gray-900 mb-3",children:"Ollama Configuration"}),(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Ollama URL"}),(0,d.jsx)("input",{type:"text",value:b.ocrSettings.ollama_url,onChange:a=>z("ollama_url",a.target.value),placeholder:"http://localhost:11434",className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-indigo-500 focus:border-indigo-500"}),(0,d.jsxs)("p",{className:"text-xs text-gray-500 mt-1",children:["Requires LLaVA or similar vision model:"," ",(0,d.jsx)("code",{className:"bg-gray-100 px-1 rounded",children:"ollama pull llava"})]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{onClick:x,disabled:q,className:"bg-green-600 text-white px-3 py-1 rounded text-sm disabled:bg-gray-400 hover:bg-green-700",children:q?"Testing...":"Test Ollama"}),s.ollama&&(0,d.jsx)("span",{className:"text-sm",children:s.ollama})]})]})]}),(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsxs)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:["Confidence Threshold (",b.ocrSettings.confidence_threshold,"%)"]}),(0,d.jsx)("input",{type:"range",min:"0",max:"100",value:b.ocrSettings.confidence_threshold,onChange:a=>z("confidence_threshold",parseInt(a.target.value)),className:"w-full"}),(0,d.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:"Minimum confidence required to accept OCR results"})]}),(0,d.jsxs)("label",{className:"flex items-center",children:[(0,d.jsx)("input",{type:"checkbox",checked:b.ocrSettings.auto_add_to_collection,onChange:a=>z("auto_add_to_collection",a.target.checked),className:"rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"}),(0,d.jsx)("span",{className:"ml-2 text-sm text-gray-700",children:"Automatically add scanned cards to selected collection"})]})]})]}),"privacy"===m&&(0,d.jsxs)("div",{className:"bg-white rounded-lg border border-gray-200 p-6",children:[(0,d.jsx)("h3",{className:"text-lg font-medium mb-4",children:"Privacy Settings"}),(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsxs)("label",{className:"flex items-center",children:[(0,d.jsx)("input",{type:"checkbox",checked:b.privacySettings.collections_public,onChange:a=>y("privacySettings",{...b.privacySettings,collections_public:a.target.checked}),className:"rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"}),(0,d.jsx)("span",{className:"ml-2 text-sm text-gray-700",children:"Make collections public by default"})]}),(0,d.jsxs)("label",{className:"flex items-center",children:[(0,d.jsx)("input",{type:"checkbox",checked:b.privacySettings.decks_public,onChange:a=>y("privacySettings",{...b.privacySettings,decks_public:a.target.checked}),className:"rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"}),(0,d.jsx)("span",{className:"ml-2 text-sm text-gray-700",children:"Make decks public by default"})]})]})]})]}),(0,d.jsx)("div",{className:"mt-8 flex justify-end",children:(0,d.jsxs)("button",{onClick:v,disabled:i,className:"bg-indigo-600 text-white px-6 py-2 rounded-lg hover:bg-indigo-700 disabled:bg-gray-400 flex items-center gap-2",children:[i&&(0,d.jsx)("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),i?"Saving...":"Save Settings"]})})]}):(0,d.jsxs)("div",{className:"text-center py-8",children:[(0,d.jsx)("p",{className:"text-red-600",children:"Failed to load preferences"}),(0,d.jsx)("button",{onClick:u,className:"mt-4 text-indigo-600 hover:underline",children:"Try Again"})]})}},9582:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{A:()=>j});var e=c(8732),f=c(2015),g=c(8462),h=c(6659),i=a([g,h]);[g,h]=i.then?(await i)():i;let j=({isOpen:a,onClose:b,deckId:c})=>{let d=(0,g.useQueryClient)(),[i,j]=(0,f.useState)({name:"",description:"",game:"MTG",format:"",tags:[],color:"#8b5cf6",isPublic:!1}),[k,l]=(0,f.useState)([]),{data:m}=(0,g.useQuery)({queryKey:["deck",c],queryFn:()=>h.LO.decks.getDeck(c),enabled:!!c}),{data:n=[]}=(0,g.useQuery)({queryKey:["tags"],queryFn:()=>h.LO.tags.getTags()}),o=(0,g.useMutation)({mutationFn:h.LO.decks.createDeck,onSuccess:()=>{d.invalidateQueries({queryKey:["decks"]}),b()}}),p=(0,g.useMutation)({mutationFn:({id:a,data:b})=>h.LO.decks.updateDeck(a,b),onSuccess:()=>{d.invalidateQueries({queryKey:["decks"]}),d.invalidateQueries({queryKey:["deck",c]}),b()}});(0,f.useEffect)(()=>{m&&(j({name:m.name,description:m.description||"",game:m.game,format:m.format||"",tags:m.tags,color:m.color||"#8b5cf6",isPublic:m.isPublic}),l(m.tags))},[m]);let q=async a=>{a.preventDefault();let b={...i,tags:k};c&&m?p.mutate({id:c,data:b}):o.mutate(b)};return a?(0,e.jsx)("div",{className:"fixed inset-0 z-50 bg-black/50",onClick:b,children:(0,e.jsx)("div",{className:"fixed bottom-0 left-0 right-0 bg-white dark:bg-surface-900 rounded-t-3xl max-h-[90vh] overflow-hidden animate-slide-up",children:(0,e.jsxs)("div",{className:"p-6",children:[(0,e.jsx)("div",{className:"w-12 h-1.5 bg-surface-300 dark:bg-surface-600 rounded-full mx-auto mb-6"}),(0,e.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,e.jsx)("h2",{className:"text-xl font-bold text-surface-900 dark:text-white",children:c?"Edit Deck":"New Deck"}),(0,e.jsx)("button",{onClick:b,className:"p-2 rounded-xl text-surface-400 hover:text-surface-600 dark:hover:text-surface-300 transition-colors",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("div",{className:"max-h-[calc(90vh-8rem)] overflow-y-auto",children:(0,e.jsxs)("form",{onSubmit:q,className:"space-y-6",onClick:a=>a.stopPropagation(),children:[(0,e.jsx)("div",{className:"p-4 bg-surface-50 dark:bg-surface-800 rounded-2xl",children:(0,e.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,e.jsx)("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center text-white text-xl font-semibold shadow-md",style:{backgroundColor:i.color},children:"\uD83C\uDFB4"}),(0,e.jsxs)("div",{className:"flex-1",children:[(0,e.jsx)("h3",{className:"font-semibold text-surface-900 dark:text-white",children:i.name||"Deck Name"}),i.description&&(0,e.jsx)("p",{className:"text-sm text-surface-600 dark:text-surface-400",children:i.description}),(0,e.jsxs)("div",{className:"flex items-center space-x-2 mt-2",children:[(0,e.jsx)("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${(a=>{switch(a){case"MTG":return"bg-orange-100 text-orange-800 dark:bg-orange-900/30 dark:text-orange-300";case"POKEMON":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300";case"LORCANA":return"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300";case"YUGIOH":return"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300";default:return"bg-surface-100 text-surface-800 dark:bg-surface-700 dark:text-surface-300"}})(i.game)}`,children:i.game}),i.format&&(0,e.jsx)("span",{className:"px-2 py-1 bg-surface-100 dark:bg-surface-700 text-surface-700 dark:text-surface-300 rounded-full text-xs font-medium",children:i.format})]})]})]})}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-surface-700 dark:text-surface-300 mb-2",children:"Deck Name *"}),(0,e.jsx)("input",{type:"text",value:i.name,onChange:a=>j(b=>({...b,name:a.target.value})),placeholder:"Enter deck name...",className:"w-full px-4 py-3 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-xl text-surface-900 dark:text-white placeholder-surface-500 dark:placeholder-surface-400 focus:outline-none focus:ring-2 focus:ring-primary-500 transition-colors",required:!0})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-surface-700 dark:text-surface-300 mb-2",children:"Description"}),(0,e.jsx)("textarea",{value:i.description,onChange:a=>j(b=>({...b,description:a.target.value})),rows:3,placeholder:"Describe your deck...",className:"w-full px-4 py-3 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-xl text-surface-900 dark:text-white placeholder-surface-500 dark:placeholder-surface-400 focus:outline-none focus:ring-2 focus:ring-primary-500 transition-colors resize-none"})]}),(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-surface-700 dark:text-surface-300 mb-2",children:"Game *"}),(0,e.jsxs)("select",{value:i.game,onChange:a=>j(b=>({...b,game:a.target.value,format:""})),className:"w-full px-4 py-3 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-xl text-surface-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 transition-colors",children:[(0,e.jsx)("option",{value:"MTG",children:"Magic: The Gathering"}),(0,e.jsx)("option",{value:"POKEMON",children:"Pok\xe9mon"}),(0,e.jsx)("option",{value:"LORCANA",children:"Disney Lorcana"}),(0,e.jsx)("option",{value:"YUGIOH",children:"Yu-Gi-Oh!"})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-surface-700 dark:text-surface-300 mb-2",children:"Format"}),(0,e.jsxs)("select",{value:i.format,onChange:a=>j(b=>({...b,format:a.target.value})),className:"w-full px-4 py-3 bg-surface-50 dark:bg-surface-700 border border-surface-300 dark:border-surface-600 rounded-xl text-surface-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 transition-colors",children:[(0,e.jsx)("option",{value:"",children:"Select Format"}),(a=>{switch(a){case"MTG":return[{value:"standard",label:"Standard"},{value:"modern",label:"Modern"},{value:"commander",label:"Commander"},{value:"pioneer",label:"Pioneer"},{value:"legacy",label:"Legacy"},{value:"vintage",label:"Vintage"},{value:"draft",label:"Draft"},{value:"sealed",label:"Sealed"}];case"POKEMON":return[{value:"standard",label:"Standard"},{value:"expanded",label:"Expanded"},{value:"unlimited",label:"Unlimited"}];case"LORCANA":return[{value:"standard",label:"Standard"},{value:"constructed",label:"Constructed"}];case"YUGIOH":return[{value:"advanced",label:"Advanced"},{value:"traditional",label:"Traditional"}];default:return[]}})(i.game).map(a=>(0,e.jsx)("option",{value:a.value,children:a.label},a.value))]})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-surface-700 dark:text-surface-300 mb-2",children:"Color"}),(0,e.jsx)("div",{className:"grid grid-cols-5 gap-2",children:["#8b5cf6","#3b82f6","#10b981","#f59e0b","#ef4444","#ec4899","#6366f1","#06b6d4","#84cc16","#f97316"].map(a=>(0,e.jsx)("button",{type:"button",onClick:()=>j(b=>({...b,color:a})),className:`w-full h-12 rounded-lg transition-all ${i.color===a?"ring-2 ring-surface-400 ring-offset-2 dark:ring-offset-surface-900":""}`,style:{backgroundColor:a}},a))})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-surface-700 dark:text-surface-300 mb-2",children:"Tags"}),(0,e.jsx)("div",{className:"flex flex-wrap gap-2",children:n.map(a=>(0,e.jsx)("button",{type:"button",onClick:()=>{l(b=>b.includes(a.id)?b.filter(b=>b!==a.id):[...b,a.id])},className:`px-3 py-2 rounded-full text-sm font-medium transition-colors ${k.includes(a.id)?"text-white":"bg-surface-100 dark:bg-surface-700 text-surface-700 dark:text-surface-300"}`,style:{backgroundColor:k.includes(a.id)?a.color:void 0},children:a.name},a.id))})]}),(0,e.jsx)("div",{children:(0,e.jsxs)("label",{className:"flex items-center justify-between",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:"text-sm font-medium text-surface-700 dark:text-surface-300",children:"Public Deck"}),(0,e.jsx)("p",{className:"text-xs text-surface-600 dark:text-surface-400 mt-1",children:"Allow others to view your deck"})]}),(0,e.jsx)("button",{type:"button",onClick:()=>j(a=>({...a,isPublic:!a.isPublic})),className:`relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 ${i.isPublic?"bg-primary-600":"bg-surface-200 dark:bg-surface-700"}`,children:(0,e.jsx)("span",{className:`pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out ${i.isPublic?"translate-x-5":"translate-x-0"}`})})]})}),c&&m&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"mb-4",children:(0,e.jsxs)("h3",{className:"text-lg font-semibold text-surface-900 dark:text-white",children:["Deck Cards (",m.mainboard?.length||0,")"]})}),(0,e.jsx)("div",{className:"space-y-2 max-h-48 overflow-y-auto",children:m.mainboard?.map((a,b)=>(0,e.jsxs)("div",{className:"flex items-center justify-between p-3 bg-surface-50 dark:bg-surface-700 rounded-lg",children:[(0,e.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,e.jsxs)("span",{className:"text-sm font-medium text-surface-900 dark:text-white",children:[a.quantity,"x"]}),(0,e.jsx)("span",{className:"text-sm text-surface-700 dark:text-surface-300",children:a.card?.name||"Unknown Card"})]}),(0,e.jsx)("button",{type:"button",onClick:()=>{},className:"p-1 text-red-400 hover:text-red-600 rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},b))})]}),(0,e.jsx)("button",{type:"submit",disabled:!i.name.trim()||o.isPending||p.isPending,className:"w-full bg-gradient-to-r from-primary-500 to-accent-500 hover:from-primary-600 hover:to-accent-600 disabled:from-surface-400 disabled:to-surface-400 text-white font-semibold py-4 px-6 rounded-xl transition-all duration-200 shadow-lg hover:shadow-xl disabled:shadow-none transform hover:-translate-y-0.5 disabled:transform-none",children:o.isPending||p.isPending?(0,e.jsxs)("div",{className:"flex items-center justify-center",children:[(0,e.jsxs)("svg",{className:"animate-spin -ml-1 mr-3 h-5 w-5 text-white",fill:"none",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,e.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),c?"Updating...":"Creating..."]}):c?"Update Deck":"Create Deck"})]})})]})})}):null};d()}catch(a){d(a)}})}};