"use strict";(()=>{var e={};e.id=7891,e.ids=[7891],e.modules={53524:e=>{e.exports=require("@prisma/client")},98432:e=>{e.exports=require("bcryptjs")},72934:e=>{e.exports=require("next/dist/client/components/action-async-storage.external.js")},54580:e=>{e.exports=require("next/dist/client/components/request-async-storage.external.js")},45869:e=>{e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},20399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},27790:e=>{e.exports=require("assert")},78893:e=>{e.exports=require("buffer")},61282:e=>{e.exports=require("child_process")},84770:e=>{e.exports=require("crypto")},80665:e=>{e.exports=require("dns")},17702:e=>{e.exports=require("events")},92048:e=>{e.exports=require("fs")},32615:e=>{e.exports=require("http")},35240:e=>{e.exports=require("https")},98216:e=>{e.exports=require("net")},19801:e=>{e.exports=require("os")},55315:e=>{e.exports=require("path")},86624:e=>{e.exports=require("querystring")},76162:e=>{e.exports=require("stream")},82452:e=>{e.exports=require("tls")},17360:e=>{e.exports=require("url")},21764:e=>{e.exports=require("util")},71568:e=>{e.exports=require("zlib")},12677:(e,a,r)=>{r.r(a),r.d(a,{originalPathname:()=>w,patchFetch:()=>b,requestAsyncStorage:()=>g,routeModule:()=>f,serverHooks:()=>y,staticGenerationAsyncStorage:()=>x});var o={};r.r(o),r.d(o,{POST:()=>h});var t=r(73278),n=r(45002),s=r(54877),i=r(71309),l=r(18445),c=r(73275),p=r(82208),d=r(36384),u=r(84770),m=r.n(u);async function h(){try{let e=await (0,l.getServerSession)(c.Lz);if(!e?.user?.id)return i.NextResponse.json({error:"Unauthorized"},{status:401});let a=await p._.user.findUnique({where:{id:e.user.id},select:{id:!0,firstName:!0,lastName:!0,email:!0,emailVerified:!0,passwordResetToken:!0,passwordResetExpires:!0}});if(!a)return i.NextResponse.json({error:"User not found"},{status:404});if(a.emailVerified)return i.NextResponse.json({error:"Email is already verified"},{status:400});let r=m().randomBytes(32).toString("hex"),o=new Date(Date.now()+864e5);await p._.user.update({where:{id:a.id},data:{passwordResetToken:r,passwordResetExpires:o}});let t=`${process.env.NEXTAUTH_URL}/verify-email?token=${r}`,n=`
      <!DOCTYPE html>
      <html lang="en">
      <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Verify Your Email - PropMaster</title>
        <style>
          body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            line-height: 1.6;
            color: #1f2937;
            background-color: #f9fafb;
            margin: 0;
            padding: 0;
          }
          .container {
            max-width: 600px;
            margin: 0 auto;
            background-color: #ffffff;
            border-radius: 12px;
            overflow: hidden;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
          }
          .header {
            background: linear-gradient(135deg, #a855f7 0%, #0ea5e9 100%);
            padding: 40px 30px;
            text-align: center;
            color: white;
          }
          .header h1 {
            margin: 0;
            font-size: 28px;
            font-weight: 700;
            letter-spacing: -0.025em;
          }
          .header p {
            margin: 8px 0 0 0;
            font-size: 16px;
            opacity: 0.9;
          }
          .content {
            padding: 40px 30px;
          }
          .verification-box {
            background: linear-gradient(135deg, rgba(168, 85, 247, 0.1) 0%, rgba(14, 165, 233, 0.1) 100%);
            border-radius: 8px;
            padding: 24px;
            margin: 24px 0;
            text-align: center;
            border-left: 4px solid #a855f7;
          }
          .verification-code {
            background-color: #f3f4f6;
            border: 1px solid #d1d5db;
            border-radius: 6px;
            padding: 16px;
            font-family: 'Courier New', monospace;
            font-size: 18px;
            font-weight: bold;
            color: #374151;
            word-break: break-all;
            margin: 16px 0;
          }
          .warning-box {
            background-color: #fef3c7;
            border: 1px solid #f59e0b;
            border-radius: 8px;
            padding: 16px;
            margin: 20px 0;
            text-align: center;
          }
          .warning-text {
            color: #92400e;
            font-weight: 500;
            margin: 0;
          }
          .footer {
            background-color: #f9fafb;
            padding: 30px;
            text-align: center;
            border-top: 1px solid #e5e7eb;
          }
          .footer p {
            margin: 0;
            color: #6b7280;
            font-size: 14px;
          }
          .footer a {
            color: #7c3aed;
            text-decoration: none;
            font-weight: 500;
          }
          .footer a:hover {
            text-decoration: underline;
          }
          .button {
            display: inline-block;
            background: linear-gradient(135deg, #a855f7 0%, #0ea5e9 100%);
            color: white;
            text-decoration: none;
            padding: 14px 28px;
            border-radius: 8px;
            font-weight: 600;
            font-size: 16px;
            margin: 16px 0;
            transition: transform 0.2s ease;
            box-shadow: 0 4px 15px rgba(168, 85, 247, 0.3);
          }
          .button:hover {
            transform: translateY(-1px);
            box-shadow: 0 8px 25px rgba(168, 85, 247, 0.4);
          }
          .secondary-button {
            display: inline-block;
            background: transparent;
            color: #7c3aed;
            border: 2px solid #7c3aed;
            text-decoration: none;
            padding: 12px 24px;
            border-radius: 8px;
            font-weight: 600;
            font-size: 16px;
            margin: 16px 8px;
            transition: all 0.3s ease;
          }
          .secondary-button:hover {
            background: #7c3aed;
            color: white;
            transform: translateY(-1px);
          }
          @media (max-width: 600px) {
            .container {
              margin: 10px;
              border-radius: 8px;
            }
            .header {
              padding: 30px 20px;
            }
            .header h1 {
              font-size: 24px;
            }
            .content {
              padding: 30px 20px;
            }
          }
        </style>
      </head>
      <body>
        <div class="container">
          <div class="header">
            <h1>🔐 Verify Your Email</h1>
            <p>Complete your PropMaster account setup</p>
          </div>

          <div class="content">
            <p>Hello ${a.firstName||"User"},</p>

            <p>Thank you for signing up with PropMaster! To complete your account setup and ensure the security of your account, please verify your email address.</p>

            <div class="verification-box">
              <p style="margin: 0 0 16px 0; font-weight: 600; color: #374151;">Click the button below to verify your email:</p>
              <a href="${t}" class="button">
                Verify My Email Address
              </a>
              <p style="margin: 16px 0 0 0; font-size: 14px; color: #6b7280;">
                This link will expire in 24 hours for security reasons.
              </p>
            </div>

            <div class="warning-box">
              <p class="warning-text">⚠️ If you didn't create an account with PropMaster, please ignore this email.</p>
            </div>

            <p>If the button above doesn't work, you can also copy and paste this link into your browser:</p>
            <p style="word-break: break-all; background-color: #f3f4f6; padding: 12px; border-radius: 6px; font-family: 'Courier New', monospace; font-size: 14px; color: #374151;">
              ${t}
            </p>

            <p>If you have any questions or need assistance, don't hesitate to contact our support team.</p>

            <p>Best regards,<br>The PropMaster Team</p>
          </div>

          <div class="footer">
            <p>
              This is an automated verification email from PropMaster.<br>
              Need help? <a href="mailto:support@propmaster.io">Contact our support team</a>
            </p>
            <p style="margin-top: 10px; font-size: 12px; color: #9ca3af;">
              \xa9 ${new Date().getFullYear()} PropMaster. All rights reserved.
            </p>
          </div>
        </div>
      </body>
      </html>
    `;return await (0,d.Cz)({to:a.email,subject:"Verify Your Email Address - PropMaster",html:n}),i.NextResponse.json({message:"Verification email sent successfully"})}catch(e){return console.error("Error sending verification email:",e),i.NextResponse.json({error:"Internal server error"},{status:500})}}let f=new t.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/user/send-verification-email/route",pathname:"/api/user/send-verification-email",filename:"route",bundlePath:"app/api/user/send-verification-email/route"},resolvedPagePath:"c:\\xampp\\htdocs\\propmaster.io\\src\\app\\api\\user\\send-verification-email\\route.ts",nextConfigOutput:"standalone",userland:o}),{requestAsyncStorage:g,staticGenerationAsyncStorage:x,serverHooks:y}=f,w="/api/user/send-verification-email/route";function b(){return(0,s.patchFetch)({serverHooks:y,staticGenerationAsyncStorage:x})}},73275:(e,a,r)=>{r.d(a,{Gv:()=>c,Lz:()=>i,c_:()=>l});var o=r(76214),t=r(98432),n=r.n(t),s=r(82208);let i={providers:[(0,o.Z)({name:"credentials",credentials:{email:{label:"Email",type:"email"},password:{label:"Password",type:"password"}},async authorize(e){if(console.log("Auth: Starting authentication for email:",e?.email),!e?.email||!e?.password)return console.log("Auth: Missing credentials"),null;try{console.log("Auth: Checking users table for:",e.email);let a=await s._.user.findUnique({where:{email:e.email},include:{company:{include:{subscriptionPlan:!0}}}});console.log("Auth: User lookup result:",a?`Found user with role: ${a.role}`:"No user found");let r=!1,o=!1;if(a&&"tenant"===a.role){console.log("Auth: User has tenant role, checking tenants table first");try{let o=await s._.tenant.findFirst({where:{email:e.email},include:{company:{include:{subscriptionPlan:!0}},unit:{include:{property:{include:{estate:!0}}}}}});if(console.log("Auth: Tenant lookup result:",o?"Found tenant":"No tenant found"),!o||!o.passwordHash)return console.log("Auth: No tenant found or no password hash, cannot authenticate"),null;{console.log("Auth: Tenant has password hash, verifying password");let t=await n().compare(e.password,o.passwordHash);if(console.log("Auth: Tenant password verification result:",t),!t)return console.log("Auth: Tenant password verification failed"),null;a={id:o.id,email:o.email,passwordHash:o.passwordHash,firstName:o.firstName,lastName:o.lastName,phone:o.phone,role:"tenant",companyId:o.companyId,company:o.company,avatarUrl:null,commissionRate:null,commissionDueDay:null,agreementDocument:null,emailVerified:!0,emailVerifiedAt:null,lastLoginAt:null,passwordResetToken:null,passwordResetExpires:null,preferences:{},timezone:"Africa/Kampala",createdAt:o.createdAt,updatedAt:o.updatedAt,deletedAt:null},r=!0,console.log("Auth: Tenant authentication successful")}}catch(e){return console.error("Auth: Error querying tenants table:",e),null}}else if(!a){console.log("Auth: User not found in users table, checking tenants table for:",e.email);try{let o=await s._.tenant.findFirst({where:{email:e.email},include:{company:{include:{subscriptionPlan:!0}},unit:{include:{property:{include:{estate:!0}}}}}});if(console.log("Auth: Tenant lookup result:",o?"Found tenant":"No tenant found"),o&&o.passwordHash){console.log("Auth: Tenant has password hash, verifying password");let t=await n().compare(e.password,o.passwordHash);console.log("Auth: Password verification result:",t),t?(a={id:o.id,email:o.email,passwordHash:o.passwordHash,firstName:o.firstName,lastName:o.lastName,phone:o.phone,role:"tenant",companyId:o.companyId,company:o.company,avatarUrl:null,commissionRate:null,commissionDueDay:null,agreementDocument:null,emailVerified:!0,emailVerifiedAt:null,lastLoginAt:null,passwordResetToken:null,passwordResetExpires:null,preferences:{},timezone:"Africa/Kampala",createdAt:o.createdAt,updatedAt:o.updatedAt,deletedAt:null},r=!0,console.log("Auth: Tenant authentication successful")):console.log("Auth: Tenant password verification failed")}else o&&console.log("Auth: Tenant found but no password hash")}catch(e){console.error("Auth: Error querying tenants table:",e)}}if(!a){console.log("Auth: User not found in users or tenants table, checking technicians table for:",e.email);try{let r=await s._.technician.findUnique({where:{email:e.email},include:{company:{include:{subscriptionPlan:!0}}}});if(console.log("Auth: Technician lookup result:",r?"Found technician":"No technician found"),r&&r.passwordHash){console.log("Auth: Technician has password hash, verifying password");let t=await n().compare(e.password,r.passwordHash);console.log("Auth: Technician password verification result:",t),t?(a={id:r.id,email:r.email,passwordHash:r.passwordHash,firstName:r.firstName,lastName:r.lastName,phone:r.phone,role:"technician",companyId:r.companyId,company:r.company,avatarUrl:r.avatarUrl,commissionRate:null,commissionDueDay:null,agreementDocument:null,emailVerified:!0,emailVerifiedAt:null,lastLoginAt:null,passwordResetToken:null,passwordResetExpires:null,preferences:{},timezone:"Africa/Kampala",createdAt:r.createdAt,updatedAt:r.updatedAt,deletedAt:null},o=!0,console.log("Auth: Technician authentication successful")):console.log("Auth: Technician password verification failed")}else r&&console.log("Auth: Technician found but no password hash")}catch(e){console.error("Auth: Error querying technicians table:",e)}}if(!a||!a.passwordHash)return console.log("Auth: No user found or no password hash"),null;if(!r&&!await n().compare(e.password,a.passwordHash))return null;return r||o||await s._.user.update({where:{id:a.id},data:{lastLoginAt:new Date}}),console.log("Auth: User company data:",{userId:a.id,companyId:a.companyId,company:a.company,isTenant:r}),{id:a.id,email:a.email,name:`${a.firstName||""} ${a.lastName||""}`.trim(),role:a.role,companyId:a.companyId,company:a.company,firstName:a.firstName,lastName:a.lastName,phone:a.phone,avatarUrl:a.avatarUrl,commissionRate:a.commissionRate,commissionDueDay:a.commissionDueDay,isTenant:r,isTechnician:o}}catch(e){return console.error("Auth error:",e),console.log("Auth: Authentication failed due to error"),null}}})],session:{strategy:"jwt",maxAge:2592e3},jwt:{maxAge:2592e3},callbacks:{jwt:async({token:e,user:a})=>(a&&(e.role=a.role,e.companyId=a.companyId,e.company=a.company,e.firstName=a.firstName,e.lastName=a.lastName,e.phone=a.phone,e.avatarUrl=a.avatarUrl,e.commissionRate=a.commissionRate,e.commissionDueDay=a.commissionDueDay,e.isTenant=a.isTenant,e.isTechnician=a.isTechnician),e),session:async({session:e,token:a})=>(a&&(e.user.id=a.sub,e.user.role=a.role,e.user.companyId=a.companyId,e.user.company=a.company,e.user.firstName=a.firstName,e.user.lastName=a.lastName,e.user.phone=a.phone,e.user.avatarUrl=a.avatarUrl,e.user.commissionRate=a.commissionRate,e.user.commissionDueDay=a.commissionDueDay,e.user.isTenant=a.isTenant,e.user.isTechnician=a.isTechnician,console.log("Auth Session Callback: companyId =",a.companyId)),e)},pages:{signIn:"/auth/login"},secret:process.env.NEXTAUTH_SECRET};async function l(e){return n().hash(e,12)}async function c(e,a){return n().compare(e,a)}},82208:(e,a,r)=>{r.d(a,{_:()=>t});var o=r(53524);let t=globalThis.prisma??new o.PrismaClient({log:["error"]})}};var a=require("../../../../webpack-runtime.js");a.C(e);var r=e=>a(a.s=e),o=a.X(0,[7787,9121,4833,6742,6384],()=>r(12677));module.exports=o})();