"use strict";(()=>{var e={};e.id=800,e.ids=[800],e.modules={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")},78893:e=>{e.exports=require("buffer")},84770:e=>{e.exports=require("crypto")},76162:e=>{e.exports=require("stream")},21764:e=>{e.exports=require("util")},77435:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>k,patchFetch:()=>g,requestAsyncStorage:()=>l,routeModule:()=>p,serverHooks:()=>x,staticGenerationAsyncStorage:()=>m});var s={};r.r(s),r.d(s,{GET:()=>c});var n=r(49303),i=r(88716),a=r(60670),u=r(87070),o=r(8194),d=r(95456);async function c(e,{params:t}){try{let e=await (0,d.ts)();if(!e)return u.NextResponse.json({error:"Anda belum login"},{status:401});let{id:r}=await t,s=await o._.ticket.findUnique({where:{id:r},include:{user:{select:{id:!0,name:!0,email:!0}},messages:{include:{user:{select:{id:!0,name:!0,email:!0}},superAdmin:{select:{id:!0,name:!0}}},orderBy:{createdAt:"asc"}}}});if(!s)return u.NextResponse.json({error:"Tiket tidak ditemukan"},{status:404});if(s.tenantId!==e.tenantId)return u.NextResponse.json({error:"Anda tidak memiliki akses ke tiket ini"},{status:403});let n=s.messages.map(e=>{let t="Tidak diketahui";return"tenant_user"===e.senderType&&e.user?t=e.user.name:"super_admin"===e.senderType&&e.superAdmin&&(t=e.superAdmin.name),{id:e.id,senderType:e.senderType,senderName:t,message:e.message,createdAt:e.createdAt}});return u.NextResponse.json({ticket:{id:s.id,subject:s.subject,status:s.status,priority:s.priority,category:s.category,createdAt:s.createdAt,updatedAt:s.updatedAt,user:s.user,messages:n}})}catch{return u.NextResponse.json({error:"Terjadi kesalahan server"},{status:500})}}let p=new n.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/tickets/[id]/route",pathname:"/api/tickets/[id]",filename:"route",bundlePath:"app/api/tickets/[id]/route"},resolvedPagePath:"D:\\PROJECT\\resto-saas\\src\\app\\api\\tickets\\[id]\\route.ts",nextConfigOutput:"",userland:s}),{requestAsyncStorage:l,staticGenerationAsyncStorage:m,serverHooks:x}=p,k="/api/tickets/[id]/route";function g(){return(0,a.patchFetch)({serverHooks:x,staticGenerationAsyncStorage:m})}},95456:(e,t,r)=>{r.d(t,{Gv:()=>p,MH:()=>k,PT:()=>g,RA:()=>l,WX:()=>m,c_:()=>c,ts:()=>x});var s=r(41482),n=r.n(s),i=r(42023),a=r.n(i),u=r(71615),o=r(8194);let d=process.env.JWT_SECRET||"fallback-secret-change-me";async function c(e){return a().hash(e,12)}async function p(e,t){return a().compare(e,t)}function l(e){return n().sign(e,d,{expiresIn:"7d"})}function m(e){try{return n().verify(e,d)}catch{return null}}async function x(){let e=await (0,u.cookies)(),t=e.get("token")?.value;if(!t)return null;let r=m(t);return r?await o._.user.findUnique({where:{id:r.userId},include:{tenant:!0,store:!0}}):null}function k(e,t){return t.includes(e)}function g(e){return!["owner","admin"].includes(e.role)&&!!e.storeId&&!!e.store&&!e.store.isActive}},8194:(e,t,r)=>{r.d(t,{_:()=>n});let s=require("@prisma/client"),n=globalThis.prisma??new s.PrismaClient}};var t=require("../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[8948,5972,4261,2023],()=>r(77435));module.exports=s})();