"use strict";(()=>{var e={};e.id=451,e.ids=[451],e.modules={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")},17702:e=>{e.exports=require("events")},2874:(e,t,a)=>{a.r(t),a.d(t,{originalPathname:()=>y,patchFetch:()=>h,requestAsyncStorage:()=>c,routeModule:()=>p,serverHooks:()=>f,staticGenerationAsyncStorage:()=>m});var r={};a.r(r),a.d(r,{POST:()=>d});var n=a(49303),i=a(88716),o=a(60670),s=a(87070),l=a(8194),_=a(64434),u=a(14709);async function d(e){try{let{tenantSlug:t,storeSlug:a,tableNumber:r,type:n,accessCode:i}=await e.json();if(!t||!a||!r)return s.NextResponse.json({error:"Data tidak lengkap"},{status:400});let o=await l._.tenant.findUnique({where:{slug:t}});if(!o)return s.NextResponse.json({error:"Restoran tidak ditemukan"},{status:404});let d=await l._.store.findFirst({where:{tenantId:o.id,slug:a}});if(!d)return s.NextResponse.json({error:"Cabang tidak ditemukan"},{status:404});let p=await (0,u.fO)(o.id);if("true"===p.order_protection_enabled){if(!i)return s.NextResponse.json({error:"Kode akses diperlukan. Silakan masukkan kode outlet dari pelayan."},{status:403});if(!await l._.accessCode.findFirst({where:{code:i.toUpperCase(),isActive:!0,expiresAt:{gt:new Date},storeId:d.id}}))return s.NextResponse.json({error:"Kode akses tidak valid atau sudah kedaluwarsa. Silakan minta kode baru ke pelayan."},{status:403})}let c="payment"===n?"call_payment":"call_waiter",m="payment"===n?"Minta Tagihan":"Panggil Pelayan",f="payment"===n?`Meja ${r} meminta tagihan / ingin membayar`:`Meja ${r} memanggil pelayan`,y=await l._.notification.create({data:{tenantId:o.id,storeId:d.id,type:c,title:m,message:f,data:JSON.stringify({tableNumber:r})}});return _.d.emit("sse_event",{type:"notification_created",tenantId:o.id,storeId:d.id,data:{type:c,notificationId:y.id,title:m,message:f}}),s.NextResponse.json({notification:y,success:!0},{status:201})}catch(e){return console.error("Call waiter error:",e),s.NextResponse.json({error:"Server error"},{status:500})}}let p=new n.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/public/call-waiter/route",pathname:"/api/public/call-waiter",filename:"route",bundlePath:"app/api/public/call-waiter/route"},resolvedPagePath:"D:\\PROJECT\\resto-saas\\src\\app\\api\\public\\call-waiter\\route.ts",nextConfigOutput:"",userland:r}),{requestAsyncStorage:c,staticGenerationAsyncStorage:m,serverHooks:f}=p,y="/api/public/call-waiter/route";function h(){return(0,o.patchFetch)({serverHooks:f,staticGenerationAsyncStorage:m})}},8194:(e,t,a)=>{a.d(t,{_:()=>n});let r=require("@prisma/client"),n=globalThis.prisma??new r.PrismaClient},64434:(e,t,a)=>{a.d(t,{d:()=>n});var r=a(17702);let n=globalThis.orderEmitter??new r.EventEmitter;n.setMaxListeners(100)},14709:(e,t,a)=>{a.d(t,{C5:()=>i,LK:()=>n,a3:()=>s,fO:()=>o});var r=a(8194);let n={order_protection_enabled:"false",session_duration_hours:"4",rate_limit_enabled:"false",rate_limit_max_orders:"5",online_payment_enabled:"true",bank_name:"",bank_account:"",bank_holder:"",tax_enabled:"true",tax_rate:"11",service_charge_enabled:"false",service_charge_rate:"5",auto_disable_menu_on_stock_out:"false",loyalty_enabled:"false",loyalty_points_per_amount:"1",loyalty_amount_per_point:"10000",loyalty_redemption_value:"500",loyalty_min_redemption:"10",loyalty_max_redemption:"0",reservation_enabled:"false",reservation_slot_duration:"120",reservation_max_advance_days:"30",reservation_min_advance_hours:"2",reservation_auto_confirm:"false",expense_approval_required:"true",expense_approval_min_amount:"0",attendance_clock_in_tolerance_minutes:"15",attendance_auto_clock_out_hours:"12",thermal_printer_enabled:"false",thermal_paper_width:"80mm",thermal_auto_print_receipt:"false",thermal_auto_print_kitchen:"false",receipt_show_browser_popup:"true",dine_in_require_table:"false",pos_order_flow:"default",receipt_header_line1:"",receipt_header_line2:"",receipt_header_line3:"",receipt_footer_line1:"Terima kasih!",receipt_footer_line2:"Silahkan datang lagi",receipt_footer_line3:"",receipt_feedback_qr:"true",menu_primary_color:"#4F46E5",menu_bg_color:"#F9FAFB",menu_card_color:"#FFFFFF",menu_text_color:"#111827",menu_banner_image:"",menu_font:"default",menu_layout:"card"};async function i(e,t){let a=await r._.tenantSetting.findUnique({where:{tenantId_key:{tenantId:e,key:t}}});return a?.value??n[t]??""}async function o(e){let t=await r._.tenantSetting.findMany({where:{tenantId:e}}),a={...n};for(let e of t)a[e.key]=e.value;return a}async function s(e,t){let a=Object.entries(t).map(([t,a])=>r._.tenantSetting.upsert({where:{tenantId_key:{tenantId:e,key:t}},update:{value:a},create:{tenantId:e,key:t,value:a}}));await r._.$transaction(a)}}};var t=require("../../../../webpack-runtime.js");t.C(e);var a=e=>t(t.s=e),r=t.X(0,[8948,5972],()=>a(2874));module.exports=r})();