1"use strict";(self.webpackChunkstudent_management_app=self.webpackChunkstudent_management_app||[]).push([[9093],{19093:(e,t,s)=>{s.r(t),s.d(t,{default:()=>o});var a=s(9950),l=s(73814),r=s(23849),n=s(39751),i=s(56600),d=s(44414);const o=()=>{const{token:e}=(0,l.g)(),[t,s]=(0,a.useState)(null),[o,c]=(0,a.useState)(!0),[u,x]=(0,a.useState)(""),[h,m]=(0,a.useState)(null),[p,b]=(0,a.useState)(!1),[f,g]=(0,a.useState)(!1),[j,v]=(0,a.useState)(!1),w=(0,a.useRef)(null),N=(0,a.useRef)(null),k=(0,a.useRef)(null),y=(0,a.useCallback)(()=>{k.current&&(k.current.getTracks().forEach(e=>e.stop()),k.current=null),v(!1)},[]);(0,a.useEffect)(()=>((async()=>{try{var t,a;const l=await(0,r.x7)((0,r.H9)(i.db,"photoTokens",e));if(!l.exists())return x("Invalid or expired link."),void c(!1);const n=l.data();if(((null===(t=n.expiresAt)||void 0===t||null===(a=t.toDate)||void 0===a?void 0:a.call(t))||new Date(n.expiresAt))<new Date)return x("This link has expired. Please request a new QR code."),void c(!1);const d=await(0,r.x7)((0,r.H9)(i.db,"students",n.studentId));if(!d.exists())return x("Student not found."),void c(!1);s({id:d.id,...d.data()})}catch(l){console.error("Token verification:",l),x("Something went wrong. Please try again.")}finally{c(!1)}})(),()=>y()),[e,y]);const C=async()=>{try{const e=await navigator.mediaDevices.getUserMedia({video:{facingMode:"environment",width:{ideal:1280},height:{ideal:960}},audio:!1});k.current=e,w.current&&(w.current.srcObject=e),v(!0),m(null)}catch(e){console.error("Camera error:",e),x("Could not access camera. Please allow camera permission and try again.")}},L=t?t.fullName||[t.firstName,t.lastName].filter(Boolean).join(" "):"";return o?(0,d.jsx)("div",{className:"min-h-screen bg-slate-50 flex items-center justify-center",children:(0,d.jsx)("div",{className:"animate-spin w-8 h-8 border-4 border-blue-600 border-t-transparent rounded-full"})}):u&&!t?(0,d.jsx)("div",{className:"min-h-screen bg-slate-50 flex items-center justify-center p-4",children:(0,d.jsxs)("div",{className:"bg-white rounded-xl shadow-sm border p-6 text-center max-w-sm",children:[(0,d.jsx)("div",{className:"w-12 h-12 bg-red-100 rounded-full flex items-center justify-center mx-auto mb-4",children:(0,d.jsx)("svg",{className:"w-6 h-6 text-red-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),(0,d.jsx)("h2",{className:"text-lg font-semibold text-slate-900 mb-2",children:"Link Error"}),(0,d.jsx)("p",{className:"text-slate-600",children:u})]})}):f?(0,d.jsx)("div",{className:"min-h-screen bg-slate-50 flex items-center justify-center p-4",children:(0,d.jsxs)("div",{className:"bg-white rounded-xl shadow-sm border p-6 text-center max-w-sm",children:[(0,d.jsx)("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-4",children:(0,d.jsx)("svg",{className:"w-8 h-8 text-green-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),(0,d.jsx)("h2",{className:"text-xl font-bold text-slate-900 mb-2",children:"Photo Uploaded!"}),(0,d.jsxs)("p",{className:"text-slate-600",children:["Profile photo for ",(0,d.jsx)("strong",{children:L})," has been saved successfully."]}),(0,d.jsx)("p",{className:"text-sm text-slate-400 mt-4",children:"You can close this page."})]})}):(0,d.jsx)("div",{className:"min-h-screen bg-slate-50",children:(0,d.jsxs)("div",{className:"max-w-md mx-auto px-4 py-6",children:[(0,d.jsxs)("div",{className:"bg-white rounded-xl shadow-sm border p-5 mb-4",children:[(0,d.jsx)("h1",{className:"text-lg font-bold text-slate-900 text-center",children:"Student Photo"}),(0,d.jsxs)("p",{className:"text-sm text-slate-600 text-center mt-1",children:["Take a photo for ",(0,d.jsx)("strong",{children:L})]})]}),u&&(0,d.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-lg p-3 mb-4",children:(0,d.jsx)("p",{className:"text-sm text-red-700",children:u})}),(0,d.jsxs)("div",{className:"bg-white rounded-xl shadow-sm border p-4",children:[!j&&!h&&(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsxs)("button",{onClick:C,className:"w-full flex items-center justify-center gap-2 px-4 py-4 bg-blue-600 text-white rounded-lg hover:bg-blue-700 text-lg font-medium",children:[(0,d.jsxs)("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",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.
1664.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"})]}),"Open Camera"]}),(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("div",{className:"absolute inset-0 flex items-center",children:(0,d.jsx)("div",{className:"w-full border-t border-slate-200"})}),(0,d.jsx)("div",{className:"relative flex justify-center text-sm",children:(0,d.jsx)("span",{className:"px-2 bg-white text-slate-400",children:"or"})})]}),(0,d.jsxs)("label",{className:"w-full flex items-center justify-center gap-2 px-4 py-4 border-2 border-dashed border-slate-300 text-slate-600 rounded-lg hover:border-blue-400 hover:text-blue-600 cursor-pointer text-lg font-medium",children:[(0,d.jsx)("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),"Choose from Gallery",(0,d.jsx)("input",{type:"file",accept:"image/*",onChange:e=>{var t;const s=null===(t=e.target.files)||void 0===t?void 0:t[0];if(!s)return;if(!s.type.startsWith("image/"))return void x("Please select an image file.");const a=new FileReader;a.onloadend=()=>m(a.result),a.readAsDataURL(s)},className:"hidden"})]})]}),j&&(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsx)("div",{className:"relative rounded-lg overflow-hidden bg-black aspect-[3/4]",children:(0,d.jsx)("video",{ref:w,autoPlay:!0,playsInline:!0,muted:!0,className:"w-full h-full object-cover"})}),(0,d.jsxs)("div",{className:"flex gap-3",children:[(0,d.jsx)("button",{onClick:y,className:"flex-1 px-4 py-3 border border-slate-300 text-slate-700 rounded-lg hover:bg-slate-50 font-medium",children:"Cancel"}),(0,d.jsx)("button",{onClick:()=>{if(!w.current||!N.current)return;const e=w.current,t=N.current;t.width=e.videoWidth,t.height=e.videoHeight;t.getContext("2d").drawImage(e,0,0);const s=t.toDataURL("image/jpeg",.85);m(s),y()},className:"flex-1 px-4 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 font-medium",children:"Capture"})]})]}),h&&(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsx)("div",{className:"relative rounded-lg overflow-hidden bg-black aspect-[3/4]",children:(0,d.jsx)("img",{src:h,alt:"Captured",className:"w-full h-full object-cover"})}),(0,d.jsxs)("div",{className:"flex gap-3",children:[(0,d.jsx)("button",{onClick:()=>{m(null),x(""),C()},disabled:p,className:"flex-1 px-4 py-3 border border-slate-300 text-slate-700 rounded-lg hover:bg-slate-50 font-medium disabled:opacity-50",children:"Retake"}),(0,d.jsx)("button",{onClick:async()=>{if(h&&t){b(!0);try{const s=await fetch(h),a=await s.blob(),l=`students/${t.id}/profile-photo`,d=(0,n.KR)(i.IG,l);await(0,n.D)(d,a);const o=await(0,n.qk)(d);await(0,r.mZ)((0,r.H9)(i.db,"students",t.id),{profilePhoto:o,updatedAt:(0,r.O5)()}),await(0,r.mZ)((0,r.H9)(i.db,"photoTokens",e),{usedAt:(0,r.O5)(),expiresAt:new Date}),g(!0)}catch(s){console.error("Upload error:",s),x("Failed to upload photo. Please try again.")}finally{b(!1)}}},disabled:p,className:"flex-1 px-4 py-3 bg-green-600 text-white rounded-lg hover:bg-green-700 font-medium disabled:opacity-50",children:p?"Uploading...":"Submit Photo"})]})]})]}),(0,d.jsx)("canvas",{ref:N,className:"hidden"}),(0,d.jsxs)("div",{className:"mt-4 bg-blue-50 border border-blue-200 rounded-lg p-3",children:[(0,d.jsx)("p",{className:"text-xs text-blue-700 font-medium mb-1",children:"Photo Tips:"}),(0,d.jsxs)("ul",{className:"text-xs text-blue-600 space-y-0.5 list-disc list-inside",children:[(0,d.jsx)("li",{children:"Clear, well-lit photo of the student's face"}),(0,d.jsx)("li",{children:"Looking directly at the camera"}),(0,d.jsx)("li",{children:"No sunglasses or hats"})]})]})]})})}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.