1import{ce as ze,J as Ke,aW as We,ch as Ye,K as Je,x as Qe,r as a,s as h,cw as A,k as p,a9 as ue,cy as F,j as e,B as De,aH as R,W as Ie,a4 as xe,a5 as he,a6 as ge,a7 as pe,a8 as v,aa as Xe,ab as Ze,bT as Be,ac as et,ad as tt,ae as st,ap as Te,aK as Pe,_ as at,a1 as rt,o as I,h as Z,co as ot,b7 as nt,a2 as it,c8 as He,aG as lt,ax as dt,t as X}from"./index-LAef4FAh.js";import{u as ct}from"./use-mobile-Kd5aMTze.js";import{H as mt}from"./HotelAdminLayout-D45NwIyk.js";import{B as ut}from"./BookingStatusBadge-DZit99jJ.js";import{T as xt,a as ht,b as Me,c as D,d as gt,e as M}from"./table-D5-oyEO6.js";import{B as pt}from"./BookingPaymentDialog-C-6LSoY_.js";import{e as ft,B as _t}from"./BookingDetailDialog-C2w8zTQF.js";import{g as bt}from"./bookingStatuses-DDTA3f2u.js";import{C as jt}from"./credit-card-faUH_CEZ.js";import{L as kt}from"./log-in-D7fHSPdv.js";import"./sheet-Cyv-LVly.js";import"./index-JglnD_Uo.js";import"./switch-DU3zvDcN.js";import"./dialog-DMm6owy5.js";import"./ticket-Bcy--bUf.js";import"./ellipsis-D5DDpfqE.js";import"./radio-group-KN44hrBY.js";import"./cashDrawer--FrAlYsT.js";import"./smartphone-D9_nm4m2.js";import"./banknote-CyZ3peR6.js";import"./separator-BCHhsBGf.js";import"./RoomStatusIcon-BQmaOz1x.js";import"./ban-BpXXDwtd.js";import"./alert-dialog-BFMAyDwk.js";import"./checkbox-VFkSkdx5.js";import"./date-field-1iJkJQaI.js";import"./file-text-DUEkAyPG.js";import"./rotate-ccw-DtLyBlal.js";import"./bookingPricing-CwBxZwPc.js";import"./pencil-ERJb917Q.js";import"./arrow-right-left-D7R2m27z.js";const oe={unpaid:{label:"ยัà¸à¹à¸¡à¹à¸à¸³à¸£à¸°",className:"bg-red-100 text-red-700 dark:bg-red-950 dark:text-red-300"},partial:{label:"à¸à¸³à¸£à¸°à¸à¸²à¸à¸ªà¹à¸§à¸",className:"bg-amber-100 text-amber-700 dark:bg-amber-950 dark:text-amber-300"},paid:{label:"à¸à¸³à¸£à¸°à¹à¸¥à¹à¸§",className:"bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300"},deposit:{label:"มัà¸à¸à¸³à¹à¸¥à¹à¸§",className:"bg-blue-100 text-blue-700 dark:bg-blue-950 dark:text-blue-300"}};function fe({booking:s,sourceLabel:q,balance:o,onCheckIn:V,onPayment:ee,onOpenDetail:f,actionLoading:E}){const _=s.status==="checked_in",z=s.check_in<A()&&!_,y=oe[s.payment_status]||oe.unpaid,ne=ot(new Date(s.check_out+"T00:00:00"),new Date(s.check_in+"T00:00:00")),$=()=>{var T,N;const b=s.booking_rooms||[];if(b.length===0){const w=(T=s.rooms)==null?void 0:T.room_number,g=((N=s.room_types)==null?void 0:N.name_th)||"";return w?`${w} (${g})`:"ยัà¸à¹à¸¡à¹à¸à¸±à¸à¸«à¹à¸à¸"}return b.map(w=>{var g,te,P;return(g=w.rooms)!=null&&g.room_number?`${w.rooms.room_number} (${((te=w.room_types)==null?void 0:te.name_th)||""})`:`ยัà¸à¹à¸¡à¹à¸à¸±à¸à¸«à¹à¸à¸ (${((P=w.room_types)==null?void 0:P.name_th)||""})`}).join(", ")},K=()=>{const b=s.booking_rooms||[];return b.length===0||b.some(T=>!T.room_id)};return e.jsxs(R.div,{whileHover:{scale:1.01},whileTap:{scale:.98},className:I("rounded-2xl border bg-white dark:bg-card shadow-sm overflow-hidden transition-all ring-1 ring-border/50",z&&"border-orange-400 dark:border-orange-600 shadow-orange-500/10",_&&"opacity-70 grayscale-[0.2]"),onClick:f,children:[e.jsxs("div",{className:I("flex items-center justify-between px-4 py-3 border-b",_?"bg-emerald-500/5":z?"bg-orange-500/5":"bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[_?e.jsxs(Z,{className:"bg-emerald-500 text-white border-0 text-[10px] h-5 px-2",children:[e.jsx(nt,{className:"h-3 w-3 mr-1"})," à¹à¸à¹à¸à¸à¸´à¸à¹à¸¥à¹à¸§"]}):z?e.jsxs(Z,{className:"bg-orange-500 text-white border-0 text-[10px] h-5 px-2 animate-pulse",children:[e.jsx(Pe,{className:"h-3 w-3 mr-1"})," à¹à¸¥à¸¢à¸à¸³à¸«à¸à¸"]}):e.jsx(Z,{variant:"secondary",className:"text-[10px] h-5 px-2 font-bold uppercase tracking-wider",children:q}),e.jsx("span",{className:"font-mono text-[11px] font-bold text-muted-foreground/60",children:s.booking_ref})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-bold text-muted-foreground uppercase tracking-widest",children:[e.jsx(Ie,{className:"h-3 w-3"}),p(new Date(s.created_at),"HH:mm")]})]}),e.jsxs("div",{className:"px-4 py-4 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"font-black text-lg text-foreground tracking-tight truncate",children:s.guest_name}),s.guest_phone&&e.jsxs("div",{className:"flex items-center gap-1.5 text-primary text-xs font-bold mt-1",children:[e.jsx(it,{className:"h-3.5 w-3.5"}),s.guest_phone]})]}),e.jsxs("div",{className:"flex flex-col items-end",children:[e.jsx("div",{className:I("text-[10px] font-black px-2.5 py-0.5 rounded-lg border shadow-sm",{"bg-red-50 text-red-700 border-red-200 dark:bg-red-950/40 dark:border-red-900":s.payment_status==="unpaid","bg-amber-50 text-amber-700 border-amber-200 dark:bg-amber-950/40 dark:border-amber-900":s.payment_status==="partial","bg-emerald-50 text-emerald-700 border-emerald-200 dark:bg-emerald-950/40 dark:border-emerald-900":s.payment_status==="paid","bg-blue-50 text-blue-700 border-blue-200 dark:bg-blue-950/40 dark:border-blue-900":s.payment_status==="deposit"}),children:y.label}),e.jsxs("p",{className:"font-black text-lg text-foreground mt-1 tabular-nums tracking-tighter",children:[(s.total_price||0).toLocaleStr
1ing()," ",e.jsx("span",{className:"text-xs font-normal opacity-60",children:"฿"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5 bg-muted/20 p-2.5 rounded-xl border border-border/50",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg bg-white dark:bg-card flex items-center justify-center shadow-sm border border-border/40",children:e.jsx(Te,{className:"h-4.5 w-4.5 text-primary"})}),e.jsxs("div",{className:"flex flex-col min-w-0",children:[e.jsx("span",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider",children:"หà¹à¸à¸à¸à¸±à¸"}),e.jsx("span",{className:I("text-xs font-bold truncate leading-tight",K()?"text-orange-500":"text-foreground"),children:$()})]})]}),e.jsxs("div",{className:"flex items-center gap-2.5 bg-muted/20 p-2.5 rounded-xl border border-border/50",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg bg-white dark:bg-card flex items-center justify-center shadow-sm border border-border/40",children:e.jsx(Be,{className:"h-4.5 w-4.5 text-primary"})}),e.jsxs("div",{className:"flex flex-col min-w-0",children:[e.jsx("span",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider",children:"ระยะà¹à¸§à¸¥à¸²"}),e.jsxs("span",{className:"text-xs font-bold truncate leading-tight",children:[ne," à¸à¸·à¸ ",e.jsxs("span",{className:"text-[10px] font-normal opacity-60",children:["(",F(s.check_in),")"]})]})]})]})]})]}),!_&&e.jsxs("div",{className:"px-4 py-3 bg-primary/5 border-t border-primary/10 flex items-center justify-between",children:[e.jsx("span",{className:"text-[11px] font-black text-primary uppercase tracking-widest",children:K()?"â ï¸ à¸à¹à¸à¸à¸£à¸°à¸à¸¸à¸«à¹à¸à¸à¸à¹à¸à¸":"â
à¸à¸£à¹à¸à¸¡à¹à¸à¹à¸à¸à¸´à¸"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-[10px] font-medium text-primary/60",children:"à¸à¸¹à¸£à¸²à¸¢à¸¥à¸°à¹à¸à¸µà¸¢à¸"}),e.jsx(He,{className:"-rotate-90 h-3.5 w-3.5 text-primary"})]})]})]})}function _e({label:s,count:q,colorClass:o,dotClass:V,children:ee,defaultOpen:f=!1}){const[E,_]=a.useState(f);return e.jsxs("div",{className:"rounded-2xl overflow-hidden border border-border/50 shadow-sm bg-white dark:bg-card",children:[e.jsxs("button",{className:I("w-full flex items-center justify-between px-5 py-4 transition-all relative overflow-hidden",o),onClick:()=>_(!E),children:[e.jsxs("div",{className:"flex items-center gap-3 relative z-10",children:[e.jsx("span",{className:I("w-3 h-3 rounded-full flex-shrink-0 shadow-sm ring-2 ring-white/20",V)}),e.jsxs("div",{className:"flex flex-col items-start",children:[e.jsx("span",{className:"font-black text-xs uppercase tracking-widest opacity-80 leading-none mb-1",children:s}),e.jsx("span",{className:"text-2xl font-black tabular-nums leading-none",children:q})]})]}),e.jsx(He,{className:I("h-5 w-5 transition-transform duration-300 relative z-10",E&&"rotate-180")}),e.jsx("div",{className:"absolute top-0 right-0 p-1 opacity-5",children:e.jsx(kt,{className:"h-16 w-16 -mr-4 -mt-4 rotate-12"})})]}),e.jsx(lt,{initial:!1,children:E&&e.jsx(R.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.3,ease:[.23,1,.32,1]},className:"overflow-hidden",children:e.jsx("div",{className:"p-4 space-y-4 bg-muted/5 border-t border-border/30",children:q===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-10 opacity-30",children:[e.jsx(dt,{className:"h-10 w-10 mb-2"}),e.jsx("p",{className:"text-sm font-medium",children:"à¹à¸¡à¹à¸¡à¸µà¸£à¸²à¸¢à¸à¸²à¸£à¹à¸à¸«à¸¡à¸§à¸à¸à¸µà¹"})]}):ee})})})]})}function Zt(){var ye;const{hotelClient:s,isStaff:q}=ze(),{user:o}=Ke(),{isAdmin:V}=We(),{hasPermission:ee}=Ye(),{toast:f}=Je(),E=Qe(),_=ct(),z=V||!q||ee("cancel_bookings"),[y,ne]=a.useState([]),[$,K]=a.useState({}),[b,T]=a.useState(!0),[N,w]=a.useState(new Date),[g,te]=a.useState("today"),[P,Le]=a.useState("all"),[se,Ae]=a.useState("all"),[C,W]=a.useState(null),[Re,be]=a.useState({}),[qe,je]=a.useState({}),[ie,ke]=a.useState(null),[O,Ee]=a.useState([]),[$e,Oe]=a.useState([]),[Ge,Ue]=a.useState([]),[Y,J]=a.useState(null),[ae,le]=a.useState("");a.useEffect(()=>{o!=null&&o.id&&h.from("hotel_staff").select("first_name, last_name").eq("user_id",o.id
1).eq("status","active").maybeSingle().then(({data:t})=>{t&&le(`${t.first_name} ${t.last_name}`.trim())})},[o==null?void 0:o.id]),a.useEffect(()=>{console.log("DEBUG: HotelArrivals - detailBooking state changed:",(Y==null?void 0:Y.id)||"null")},[Y]);const de=a.useCallback(async(t,r,l,n,i,m)=>{if(!s||!o)return;const d=ae||"à¸à¸à¸±à¸à¸à¸²à¸";await h.from("booking_audit_logs").insert({booking_id:t,hotel_client_id:s.id,action:l,old_status:n||null,new_status:i||null,details:m||null,performed_by:o.id,performed_by_name:d,booking_ref:r})},[s,o,ae]);a.useEffect(()=>{s&&(h.from("booking_sources").select("value, label, requires_ref, commission_rate").eq("hotel_client_id",s.id).eq("is_active",!0).order("sort_order").then(({data:t})=>{t&&t.length>0&&Ee(t)}),h.from("room_types").select("id, name_th, base_price").eq("hotel_client_id",s.id).order("sort_order").then(({data:t})=>{Oe(t||[])}),h.from("rooms").select("id, room_number, floor, status, room_type_id").eq("hotel_client_id",s.id).order("room_number").then(({data:t})=>{Ue(t||[])}))},[s]),a.useEffect(()=>{o&&h.from("hotel_staff").select("first_name, last_name").eq("user_id",o.id).eq("status","active").maybeSingle().then(({data:t})=>{le(t?`${t.first_name} ${t.last_name}`.trim():"à¸à¸à¸±à¸à¸à¸²à¸")})},[o]);const re=a.useMemo(()=>{const t={};return O.forEach(r=>{t[r.value]=r.label}),t},[O]),H=a.useMemo(()=>g==="today"?A():g==="tomorrow"?p(ue(new Date,1),"yyyy-MM-dd"):p(N,"yyyy-MM-dd"),[g,N]),ve=a.useMemo(()=>g==="today"?"วัà¸à¸à¸µà¹":g==="tomorrow"?"à¸à¸£à¸¸à¹à¸à¸à¸µà¹":F(p(N,"yyyy-MM-dd")),[g,N]),j=a.useCallback(async()=>{if(!s)return;T(!0);const t=A(),r=new Date(H),l=p(ue(r,1),"yyyy-MM-dd"),n=p(ue(r,-30),"yyyy-MM-dd"),{data:i,error:m}=await h.from("bookings").select("id, booking_ref, booking_type, guest_name, guest_phone, guest_email, guest_address, check_in, check_out, status, payment_status, booking_source, external_booking_ref, ota_collect_method, room_id, room_type_id, total_price, deposit_amount, hotel_client_id, checked_in_at, checked_in_by_name, checked_out_at, checked_out_by_name, created_at, guests_count, extra_bed, has_pets, stay_hours, notes, special_requests, room_types(name_th), rooms(room_number), booking_rooms(room_id, room_types(name_th), rooms(room_number))").eq("hotel_client_id",s.id).not("status","in",'("cancelled","no_show")').gte("check_in",n).lt("check_in",l).order("check_in",{ascending:!0});if(!m&&i){const d=i.filter(c=>{var x,S;return((x=c.check_in)==null?void 0:x.substring(0,10))===H||((S=c.check_in)==null?void 0:S.substring(0,10))<t&&!["checked_in","checked_out","no_show","cancelled"].includes(c.status)});ne(d);const u=d.map(c=>c.id);if(u.length>0){const{data:c}=await h.from("folio_charges").select("booking_id, amount, voided").in("booking_id",u),{data:x}=await h.from("booking_payments").select("booking_id, amount").in("booking_id",u),{data:S}=await h.from("booking_folios").select("id, booking_id").in("booking_id",u),G={},Ne={},we={};for(const U of u){const Ve=(c||[]).filter(k=>k.booking_id===U&&!k.voided).reduce((k,me)=>k+(me.amount||0),0),Ce=(x||[]).filter(k=>k.booking_id===U).reduce((k,me)=>k+(Number(me.amount)||0),0);G[U]=Ve-Ce,Ne[U]=Ce;const Se=(S||[]).find(k=>k.booking_id===U);Se&&(we[U]=Se.id)}K(G),je(Ne),be(we)}else K({}),je({}),be({})}T(!1)},[s,H]);a.useEffect(()=>{j()},[j]),a.useEffect(()=>{const t=()=>{document.visibilityState==="visible"&&(console.log("DEBUG: Page visible, refreshing arrivals..."),j())};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[j]);const L=a.useMemo(()=>{let t=y;return P==="assigned"&&(t=t.filter(r=>{const l=r.booking_rooms||[];return l.length>0&&l.every(n=>n.room_id)})),P==="unassigned"&&(t=t.filter(r=>{const l=r.booking_rooms||[];return l.length===0||l.some(n=>!n.room_id)})),se!=="all"&&(t=t.filter(r=>r.payment_status===se)),[...t].sort((r,l)=>{const n=r.status==="checked_in"?1:0,i=l.status==="checked_in"?1:0;return n-i})},[y,P,se]),Q=a.useMemo(()=>{const t=A(),r=y.filter(d=>{var u;return((u=d.check_in)==null?void 0:u.substring(0,10))===H}),l=r.filter(d=>!["checked_in","checked_out","no_show"].includes(d.status)),n=y.filter(d=>{var u;return(((u=d.check_in)==null?void 0:u.substring(0,10))||"")<t&&!["checked_in","checked_out","no_show"].includes(d.status)}),i=y.filter(d=>{if(d.status==="checked_in")return!1;const u=d.booking_rooms||[];return u.length===0||u.some(c=>
1!c.room_id)}),m=y.filter(d=>d.status!=="checked_in"&&d.payment_status==="unpaid");return{remaining:l.length,total:r.length,overdue:n.length,unassigned:i.length,unpaid:m.length}},[y,H]),B=a.useMemo(()=>{const t=A(),r=L.filter(i=>{var m;return(((m=i.check_in)==null?void 0:m.substring(0,10))||"")<t&&i.status!=="checked_in"}),l=L.filter(i=>{var m;return((m=i.check_in)==null?void 0:m.substring(0,10))===H&&i.status!=="checked_in"}),n=L.filter(i=>i.status==="checked_in");return{overdue:r,pending:l,checkedIn:n}},[L,H]),ce=a.useCallback(async t=>{if(!(!s||!o)){ke(t.id);try{const r=A();if(t.check_in>r){f({title:"ยัà¸à¹à¸¡à¹à¸à¸¶à¸à¸§à¸±à¸à¹à¸à¹à¸à¸à¸´à¸",description:`à¸à¸³à¸«à¸à¸à¹à¸à¹à¸à¸à¸´à¸: ${F(t.check_in)}`,variant:"destructive"});return}const{data:l}=await h.from("booking_rooms").select("room_id").eq("booking_id",t.id),n=(l||[]).map(x=>x.room_id).filter(Boolean);if(t.room_id&&!n.includes(t.room_id)&&n.push(t.room_id),(l||[]).some(x=>!x.room_id)||n.length===0){f({title:"à¸à¸£à¸¸à¸à¸²à¹à¸¥à¸·à¸à¸à¸«à¹à¸à¸à¹à¸«à¹à¸à¸£à¸à¸
1à¹à¸à¸à¹à¸à¹à¸à¸à¸´à¸",description:"à¸à¸à¹à¸à¹à¹à¸à¸à¸²à¸£à¸à¸à¸à¹à¸à¸·à¹à¸à¸à¸³à¸«à¸à¸à¸«à¹à¸à¸à¸à¸±à¸",variant:"destructive"});return}if(n.length>0){const{data:x}=await h.from("rooms").select("id, room_number, status").in("id",n),S=(x||[]).filter(G=>G.status==="out_of_order");if(S.length>0){f({title:"à¹à¸¡à¹à¸ªà¸²à¸¡à¸²à¸£à¸à¹à¸à¹à¸à¸à¸´à¸à¹à¸à¹",description:`หà¹à¸à¸ ${S.map(G=>G.room_number).join(", ")} à¸à¸´à¸à¸à¹à¸à¸¡`,variant:"destructive"});return}}let m="à¸à¸à¸±à¸à¸à¸²à¸";const{data:d}=await h.from("hotel_staff").select("first_name, last_name").eq("user_id",o.id).eq("status","active").maybeSingle();d&&(m=`${d.first_name} ${d.last_name}`.trim()||m);const{error:u}=await h.from("bookings").update({status:"checked_in",checked_in_by:o.id,checked_in_by_name:m,checked_in_at:new Date().toISOString()}).eq("id",t.id);if(u){f({title:"à¹à¸à¹à¸à¸à¸´à¸à¹à¸¡à¹à¸ªà¸³à¹à¸£à¹à¸",variant:"destructive"});return}for(const x of n)await h.from("rooms").update({status:"occupied"}).eq("id",x);await de(t.id,t.booking_ref,"status_changed",t.status,"checked_in");const{data:c}=await h.from("bookings").select("ota_collect_method, total_price, booking_source").eq("id",t.id).single();if(c!=null&&c.ota_collect_method){const x=O.find(S=>S.value===c.booking_source);await ft({hotelClientId:s.id,bookingId:t.id,bookingSource:c.booking_source,otaCollectMethod:c.ota_collect_method,totalPrice:c.total_price||0,commissionRate:x==null?void 0:x.commission_rate})}f({title:"à¹à¸à¹à¸à¸à¸´à¸à¸ªà¸³à¹à¸£à¹à¸"}),j()}finally{ke(null)}}},[s,o,f,j,O,de]),Fe=t=>{var l,n;const r=t.booking_rooms||[];if(r.length===0){const i=(l=t.rooms)==null?void 0:l.room_number,m=((n=t.room_types)==null?void 0:n.name_th)||"";return i?e.jsxs("span",{children:[i," ",e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",m,")"]})]}):e.jsx("span",{className:"text-amber-600 font-medium",children:"ยัà¸à¹à¸¡à¹à¸à¸±à¸à¸«à¹à¸à¸"})}return r.map((i,m)=>{var d,u,c;return e.jsx("div",{children:(d=i.rooms)!=null&&d.room_number?e.jsxs("span",{children:[i.rooms.room_number," ",e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",(u=i.room_types)==null?void 0:u.name_th,")"]})]}):e.jsxs("span",{className:"text-amber-600 font-medium",children:["ยัà¸à¹à¸¡à¹à¸à¸±à¸à¸«à¹à¸à¸ ",e.jsxs("span",{className:"text-xs",children:["(",(c=i.room_types)==null?void 0:c.name_th,")"]})]})},m)})};return e.jsxs(mt,{children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{children:e.jsxs("h1",{className:"text-xl font-bold text-foreground",children:[e.jsxs("span",{className:"hidden sm:inline",children:["à¹à¸à¹à¸à¸à¸´à¸",ve," (Arrivals)"]}),e.jsxs("span",{className:"sm:hidden",children:["à¹à¸à¹à¸à¸à¸´à¸",ve]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{variant:"outline",size:"sm",className:"h-9 w-9 p-0",onClick:()=>j(),disabled:b,title:"รีà¹à¸à¸£à¸à¸à¹à¸à¸¡à¸¹à¸¥",children:e.jsx(R.div,{animate:b?{rotate:360}:{},transition:b?{repeat:1/0,duration:1,ease:"linear"}:{},children:e.jsx(Ie,{className:"h-4 w-4"})})}),e.jsxs(xe,{value:g,onValueChange:t=>{te(t)},children:[e.jsx(he,{className:"w-[110px] sm:w-[130px] h-9",children:e.jsx(ge,{})}),e.jsxs(pe,{children:[e.jsx(v,{value:"today",children:"วัà¸à¸à¸µà¹"}),e.jsx(v,{value:"tomorrow",children:"à¸à¸£à¸¸à¹à¸à¸à¸µà¹"}),e.jsx(v,{value:"custom",children:"à¹à¸¥à¸·à¸à¸à¸§à¸±à¸"})]})]}),g==="custom"&&e.jsxs(Xe,{children:[e.jsx(Ze,{asChild:!0,children:e.jsxs(De,{variant:"outline",size:"sm",className:"h-9 px-2 sm:px-3",children:[e.jsx(Be,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:p(N,"d MMM yy",{locale:X})})]})}),e.jsx(et,{className:"w-auto p-0",children:e.jsx(tt,{mode:"single",selected:N,onSelect:t=>t&&w(t)})})]}),!_&&e.jsxs(e.Fragment,{children:[e.jsxs(xe,{value:P,onValueChange:Le,children:[e.jsx(he,{className:"w-[140px] h-9",children:e.jsx(ge,{placeholder:"หà¹à¸à¸"})}),e.jsxs(pe,{children:[e.jsx(v,{value:"all",children:"หà¹à¸à¸: à¸à¸±à¹à¸à¸«à¸¡à¸"}
1),e.jsx(v,{value:"assigned",children:"à¸à¸±à¸à¸«à¹à¸à¸à¹à¸¥à¹à¸§"}),e.jsx(v,{value:"unassigned",children:"ยัà¸à¹à¸¡à¹à¸à¸±à¸à¸«à¹à¸à¸"})]})]}),e.jsxs(xe,{value:se,onValueChange:Ae,children:[e.jsx(he,{className:"w-[140px] h-9",children:e.jsx(ge,{placeholder:"à¸à¸³à¸£à¸°à¹à¸à¸´à¸"})}),e.jsxs(pe,{children:[e.jsx(v,{value:"all",children:"à¸à¸³à¸£à¸°: à¸à¸±à¹à¸à¸«à¸¡à¸"}),e.jsx(v,{value:"unpaid",children:"ยัà¸à¹à¸¡à¹à¸à¸³à¸£à¸°"}),e.jsx(v,{value:"partial",children:"à¸à¸³à¸£à¸°à¸à¸²à¸à¸ªà¹à¸§à¸"}),e.jsx(v,{value:"paid",children:"à¸à¸³à¸£à¸°à¹à¸¥à¹à¸§"})]})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[e.jsx(R.div,{whileHover:{y:-4},className:"p-4 bg-white dark:bg-card rounded-2xl border border-border/50 shadow-sm shadow-blue-500/5 group",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-blue-500/10 flex items-center justify-center transition-colors group-hover:bg-blue-500/20",children:e.jsx(st,{className:"h-5 w-5 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black text-muted-foreground uppercase tracking-widest",children:"à¹à¸à¹à¸à¸à¸´à¸à¸§à¸±à¸à¸à¸µà¹"}),e.jsxs("p",{className:"text-2xl font-black text-foreground tabular-nums",children:[Q.remaining,e.jsxs("span",{className:"text-sm font-normal text-muted-foreground opacity-60",children:["/",Q.total]})]})]})]})}),e.jsx(R.div,{whileHover:{y:-4},className:"p-4 bg-white dark:bg-card rounded-2xl border border-border/50 shadow-sm shadow-amber-500/5 group",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-amber-500/10 flex items-center justify-center transition-colors group-hover:bg-amber-500/20",children:e.jsx(Te,{className:"h-5 w-5 text-amber-600 dark:text-amber-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black text-muted-foreground uppercase tracking-widest",children:"ยัà¸à¹à¸¡à¹à¸à¸±à¸à¸«à¹à¸à¸"}),e.jsx("p",{className:"text-2xl font-black text-foreground tabular-nums",children:Q.unassigned})]})]})}),e.jsx(R.div,{whileHover:{y:-4},className:"p-4 bg-white dark:bg-card rounded-2xl border border-border/50 shadow-sm shadow-red-500/5 group",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-red-500/10 flex items-center justify-center transition-colors group-hover:bg-red-500/20",children:e.jsx(jt,{className:"h-5 w-5 text-red-600 dark:text-red-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black text-muted-foreground uppercase tracking-widest",children:"ยัà¸à¹à¸¡à¹à¸à¸³à¸£à¸°"}),e.jsx("p",{className:"text-2xl font-black text-foreground tabular-nums",children:Q.unpaid})]})]})}),e.jsx(R.div,{whileHover:{y:-4},className:"p-4 bg-white dark:bg-card rounded-2xl border border-border/50 shadow-sm shadow-orange-500/5 group",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-orange-500/10 flex items-center justify-center transition-colors group-hover:bg-orange-500/20",children:e.jsx(Pe,{className:"h-5 w-5 text-orange-600 dark:text-orange-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black text-muted-foreground uppercase tracking-widest",children:"à¹à¸¥à¸¢à¸à¸³à¸«à¸à¸"}),e.jsx("p",{className:"text-2xl font-black text-orange-600 tabular-nums",children:Q.overdue})]})]})})]}),b?e.jsx("div",{className:"p-8 text-center text-muted-foreground",children:"à¸à¸³à¸¥à¸±à¸à¹à¸«à¸¥à¸..."}):_?e.jsx("div",{className:"space-y-3",children:L.length===0?e.jsx("div",{className:"p-8 text-center text-muted-foreground rounded-xl border bg-card",children:"à¹à¸¡à¹à¸¡à¸µà¸£à¸²à¸¢à¸à¸²à¸£à¹à¸à¹à¸à¸à¸´à¸"}):e.jsxs(e.Fragment,{children:[e.jsx(_e,{label:"à¹à¸¥à¸¢à¸à¸³à¸«à¸à¸",count:B.overdue.length,colorClass:"bg-orange-50 dark:bg-orange-950/30 text-orange-700 dark:text-orange-300",dotClass:"bg-orange-500 animate-pulse",defaultOpen:B.overdue.length>0,children:B.overdue.map(t=>e.jsx(fe,{booking:t,sourceLabel:re[t.booking_source]||t.booking_source,balance:$[t.id]||0,onCheckIn:()=>ce(t),onPayment:()=>W(t),onOpenDetail:()=>J(t),actionLoading:ie===t.id},t.id))}),e.jsx(_e,{label:"รà¸à¹à¸à¹à¸à¸à¸´à¸",count:B.pending.length,colorClass:"bg-blue-50 dark:bg-blue-950/30 text-blue-700 dark:text-blue-300",dotClass:"bg-blue-500",defaultOpen:B.pe
1nding.length>0,children:B.pending.map(t=>e.jsx(fe,{booking:t,sourceLabel:re[t.booking_source]||t.booking_source,balance:$[t.id]||0,onCheckIn:()=>ce(t),onPayment:()=>W(t),onOpenDetail:()=>J(t),actionLoading:ie===t.id},t.id))}),e.jsx(_e,{label:"à¹à¸à¹à¸à¸à¸´à¸à¹à¸¥à¹à¸§",count:B.checkedIn.length,colorClass:"bg-emerald-50 dark:bg-emerald-950/30 text-emerald-700 dark:text-emerald-300",dotClass:"bg-emerald-500",defaultOpen:!1,children:B.checkedIn.map(t=>e.jsx(fe,{booking:t,sourceLabel:re[t.booking_source]||t.booking_source,balance:$[t.id]||0,onCheckIn:()=>ce(t),onPayment:()=>W(t),onOpenDetail:()=>J(t),actionLoading:ie===t.id},t.id))})]})}):e.jsx(at,{children:e.jsx(rt,{className:"p-0",children:L.length===0?e.jsx("div",{className:"p-8 text-center text-muted-foreground",children:"à¹à¸¡à¹à¸¡à¸µà¸£à¸²à¸¢à¸à¸²à¸£à¹à¸à¹à¸à¸à¸´à¸"}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(xt,{children:[e.jsx(ht,{children:e.jsxs(Me,{className:"bg-muted/60",children:[e.jsx(D,{className:"w-[100px]",children:"รหัส"}),e.jsx(D,{children:"à¸à¸£à¸°à¹à¸ à¸"}),e.jsx(D,{children:"à¸à¸¹à¹à¹à¸à¹à¸²à¸à¸±à¸"}),e.jsx(D,{children:"หà¹à¸à¸"}),e.jsx(D,{children:"à¹à¸à¹à¸à¸à¸´à¸"}),e.jsx(D,{children:"à¹à¸à¹à¸à¹à¸à¸²à¸à¹"}),e.jsx(D,{className:"text-right",children:"ราà¸à¸²"}),e.jsx(D,{children:"สà¸à¸²à¸à¸°"}),e.jsx(D,{className:"text-right",children:"วัà¸à¸à¸µà¹à¸à¸³à¸£à¸²à¸¢à¸à¸²à¸£"})]})}),e.jsx(gt,{children:L.map(t=>{$[t.id];const r=t.check_in<A()&&t.status!=="checked_in",l=t.status==="checked_in",n=oe[t.payment_status]||oe.unpaid;return bt(t.status),e.jsxs(Me,{className:I("cursor-pointer hover:bg-muted/50",r&&"bg-orange-50/50 dark:bg-orange-950/20",l&&"opacity-50"),onClick:()=>{console.log("DEBUG: TableRow click:",t.id),J(t)},children:[e.jsxs(M,{children:[e.jsx("div",{className:"font-mono text-xs",children:t.booking_ref}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:re[t.booking_source]||t.booking_source}),r&&e.jsx(Z,{variant:"outline",className:"text-[10px] border-orange-400 text-orange-600 mt-0.5",children:"à¹à¸¥à¸¢à¸à¸³à¸«à¸à¸"})]}),e.jsx(M,{children:e.jsx(Z,{variant:"outline",className:"text-[10px]",children:t.booking_type==="dayuse"?"รายà¸à¸±à¹à¸§à¹à¸¡à¸":"à¸à¹à¸²à¸à¸à¸·à¸"})}),e.jsxs(M,{children:[e.jsx("div",{className:"font-medium text-sm",children:t.guest_name}),t.guest_phone&&e.jsx("div",{className:"text-xs text-muted-foreground",children:t.guest_phone})]}),e.jsx(M,{className:"text-sm",children:Fe(t)}),e.jsxs(M,{className:"text-sm",children:[e.jsx("div",{children:F(t.check_in)}),t.checked_in_at&&e.jsx("div",{className:"text-[10px] text-muted-foreground",children:p(new Date(t.checked_in_at),"HH:mm",{locale:X})})]}),e.jsxs(M,{className:"text-sm",children:[e.jsx("div",{children:F(t.check_out)}),t.checked_out_at&&e.jsx("div",{className:"text-[10px] text-muted-foreground",children:p(new Date(t.checked_out_at),"HH:mm",{locale:X})})]}),e.jsxs(M,{className:"text-right",children:[e.jsx("div",{className:"font-medium text-sm",children:(t.total_price||0).toLocaleString()}),e.jsx("div",{className:I("text-[10px] mt-0.5",n.className.replace(/bg-\S+/g,"").trim()),children:n.label})]}),e.jsxs(M,{children:[e.jsx(ut,{status:t.status}),l&&t.checked_in_at&&e.jsx("div",{className:"text-[10px] text-muted-foreground mt-0.5",children:F(t.checked_in_at,!0)})]}),e.jsxs(M,{className:"text-right text-xs text-muted-foreground",children:[e.jsx("div",{children:p(new Date(t.created_at),"d MMM yy",{locale:X})}),e.jsx("div",{children:p(new Date(t.created_at),"HH:mm",{locale:X})})]})]},t.id)})})]})})})})]}),C&&e.jsx(pt,{bookingId:C.id,hotelClientId:(s==null?void 0:s.id)||"",bookingRef:C.booking_ref,totalPrice:C.total_price||0,currentPaid:qe[C.id]||0,userId:(o==null?void 0:o.id)||"",userName:ae||"à¸à¸à¸±à¸à¸à¸²à¸",folioId:Re[C.id]||null,bookingSource:C.booking_source,commissionRate:((ye=O.find(t=>t.value===C.booking_source))==null?void 0:ye.commission_rate)??null,open:!!C,onOpenChange:t=>{t||(W(null),j())},onSuccess:()=>{W(null),j()}}),e.jsx(_t,{booking:Y,onClose:()=>J(null),onRefresh:j,hotelClient:s,user:o?{id:o.id,email:o.email}:null,staffName:ae||"à¸à¸à¸±à¸à¸à¸²à¸",bookingSources:O,roomTypes:$e,allRooms:Ge,canDeleteBooking:z,onEditBooking:t=>E(`/h/bookings?detail=${t.id}`),insertAuditLog:de,isSuperAdmin:V})]})}export{Zt as default};
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.