import{a as e,c as t,i as n,n as r,o as i,r as a,t as o}from"./app-Cl8XxplU.js";import{C as s,E as c,S as l,d as u,m as d,n as f,t as p}from"./fa-DPOKBqVt.js";import{t as m}from"./PublicLayout-DIH6a5jJ.js";import"./esm-CVrqiTRD.js";var h=t(i(),1),g=o(),_={pool:l,chalet:d,hall:p,conference_building:c,sports_court:u,entry:s},v=`w-full rounded-lg border border-gray-300 px-3 py-2 text-sm shadow-sm focus:border-amber-500 focus:ring-amber-500 focus:outline-none transition-colors`,y=`${v} bg-gray-50 text-gray-500 cursor-not-allowed`,b=v,x=`block text-sm font-medium text-gray-700 mb-1`,S=`mt-1 text-xs text-red-600`;function C({label:e,error:t,required:n,children:r}){return(0,g.jsxs)(`div`,{children:[(0,g.jsxs)(`label`,{className:x,children:[e,n&&(0,g.jsx)(`span`,{className:`text-red-500 ml-0.5`,children:`*`})]}),r,t&&(0,g.jsx)(`p`,{className:S,children:t})]})}function w({label:e,value:t}){return(0,g.jsxs)(`div`,{className:`flex justify-between text-sm py-1 border-b border-gray-100 last:border-0`,children:[(0,g.jsx)(`span`,{className:`text-gray-500`,children:e}),(0,g.jsx)(`span`,{className:`font-medium text-gray-900`,children:t})]})}function T(e,t){if(!e||!t)return 0;let n=new Date(t)-new Date(e);return Math.max(0,Math.floor(n/864e5))}function E(e){return Number(e).toLocaleString(`ar-EG`,{minimumFractionDigits:0,maximumFractionDigits:2})}function D(e){if(!e)return``;let[t,n]=e.split(`:`).map(Number),r=t<12?`ص`:`م`;return`${t%12||12}:${String(n).padStart(2,`0`)} ${r}`}function O({value:e,onChange:t,error:n,instapayEnabled:r,cashEnabled:i=!0}){return(0,g.jsxs)(C,{label:`طريقة الدفع`,error:n,required:!0,children:[(0,g.jsxs)(`select`,{className:b,value:e,onChange:t,children:[i&&(0,g.jsx)(`option`,{value:`cash`,children:`كاش (الدفع عند الوصول)`}),r&&(0,g.jsx)(`option`,{value:`online`,children:`أونلاين — InstaPay`})]}),r&&e===`online`&&(0,g.jsxs)(`div`,{className:`mt-2 rounded-lg bg-blue-50 border border-blue-100 px-3 py-2 text-xs text-blue-700 space-y-0.5`,children:[(0,g.jsx)(`p`,{className:`font-medium`,children:`كيفية الدفع عبر InstaPay`}),(0,g.jsxs)(`p`,{children:[`بعد تأكيد الحجز من الإدارة، ستجد رابط الدفع مع المبلغ المطلوب في صفحة `,(0,g.jsx)(`strong`,{children:`«حسابي»`}),`.`]})]})]})}function k({show:e,whatsapp:t,senderPhone:n,onChange:r,error:i}){return e?(0,g.jsxs)(`div`,{className:`space-y-3`,children:[(0,g.jsxs)(C,{label:`رقم موبايل التحويل`,error:i,required:!0,children:[(0,g.jsx)(`input`,{type:`text`,inputMode:`numeric`,maxLength:11,dir:`rtl`,placeholder:`01xxxxxxxxx`,className:v,value:n,onChange:e=>r(e.target.value.replace(/\D/g,``))}),(0,g.jsx)(`p`,{className:`mt-1 text-xs text-gray-400`,children:`الرقم الذي ستُحوّل منه عبر InstaPay (11 رقماً)`})]}),t&&(0,g.jsxs)(`div`,{className:`rounded-lg bg-green-50 border border-green-200 px-4 py-3 text-sm text-green-800 space-y-1`,children:[(0,g.jsx)(`p`,{className:`font-semibold`,children:`مطلوب: إرسال إثبات التحويل`}),(0,g.jsxs)(`p`,{children:[`يرجى الاحتفاظ بسكرين شوت للتحويل وإرساله عبر واتساب على الرقم:`,(0,g.jsx)(`br`,{}),(0,g.jsx)(`strong`,{dir:`ltr`,className:`text-green-900`,children:t})]}),(0,g.jsx)(`p`,{className:`text-xs text-green-600`,children:`مع ذكر رقم الحجز في الرسالة`})]})]}):null}function A({photos:e,title:t=``,subtitle:n=``,pricePerPerson:r=0,capacity:i=0}){let[a,o]=(0,h.useState)(0),[s,c]=(0,h.useState)(!1),l=(0,h.useRef)(null),u=()=>o(t=>(t+1)%e.length),d=()=>o(t=>(t-1+e.length)%e.length);(0,h.useEffect)(()=>{if(s||e.length<=1)return;let t=setInterval(u,5500);return()=>clearInterval(t)},[a,s,e.length]);function f(e){l.current=e.touches[0].clientX}function p(e){if(l.current===null)return;let t=e.changedTouches[0].clientX-l.current;l.current=null,!(Math.abs(t)<40)&&(t>0?d():u())}function m(){document.getElementById(`booking-form-start`)?.scrollIntoView({behavior:`smooth`,block:`start`})}return e.length?(0,g.jsxs)(`div`,{className:`relative overflow-hidden bg-gray-950`,style:{height:`clamp(220px, 46vw, 520px)`,borderRadius:`0 0 1.75rem 1.75rem`,marginBottom:`2rem`},onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onTouchStart:f,onTouchEnd:p,children:[(0,g.jsx)(`style`,{children:`
                @keyframes heroIn {
                    from { opacity: 0; transform: translateY(22px); }
                    to   { opacity: 1; transform: translateY(0); }
                }
                @keyframes heroBadge {
                    from { opacity: 0; transform: translateY(10px) scale(0.95); }
                    to   { opacity: 1; transform: translateY(0) scale(1); }
                }
                @keyframes dotsGlow {
                    0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
                    50%       { box-shadow: 0 0 6px 2px rgba(255,255,255,0.25); }
                }
            `}),e.map((e,n)=>(0,g.jsxs)(`div`,{className:`absolute inset-0`,style:{opacity:+(n===a),transition:`opacity 1.3s cubic-bezier(0.4, 0, 0.2, 1)`,zIndex:+(n===a)},children:[(0,g.jsx)(`img`,{src:`http://localhost/ElemanClub/aliman-admin/public/storage/${e}`,alt:``,"aria-hidden":`true`,className:`absolute inset-0 w-full h-full object-cover select-none`,draggable:!1,style:{transform:n===a?`scale(1.08)`:`scale(1.14)`,transition:`transform 7s cubic-bezier(0.25, 0.46, 0.45, 0.94)`,filter:`blur(18px) brightness(0.45)`}}),(0,g.jsx)(`img`,{src:`http://localhost/ElemanClub/aliman-admin/public/storage/${e}`,alt:t||`صورة`,className:`absolute inset-0 w-full h-full object-cover select-none`,draggable:!1,style:{transform:n===a?`scale(1.0)`:`scale(1.04)`,transition:`transform 7s cubic-bezier(0.25, 0.46, 0.45, 0.94)`}})]},e)),(0,g.jsxs)(`div`,{className:`absolute inset-0 pointer-events-none`,style:{zIndex:2},children:[(0,g.jsx)(`div`,{style:{position:`absolute`,inset:0,background:`linear-gradient(to top, rgba(0,0,0,0.90) 0%, rgba(0,0,0,0.55) 38%, rgba(0,0,0,0.12) 65%, transparent 100%)`}}),(0,g.jsx)(`div`,{style:{position:`absolute`,inset:0,background:`linear-gradient(to bottom, rgba(0,0,0,0.38) 0%, transparent 42%)`}}),(0,g.jsx)(`div`,{style:{position:`absolute`,inset:0,background:`radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.25) 100%)`}})]}),(0,g.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 px-5 sm:px-10 pb-10 sm:pb-12`,style:{zIndex:3},children:(0,g.jsxs)(`div`,{children:[t&&(0,g.jsx)(`h1`,{className:`text-white font-black leading-tight mb-2`,style:{fontSize:`clamp(1.3rem, 3.2vw, 2.1rem)`,textShadow:`0 2px 28px rgba(0,0,0,0.7), 0 1px 4px rgba(0,0,0,0.5)`,letterSpacing:`-0.015em`,animation:`heroIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) both`},children:t}),n&&(0,g.jsx)(`p`,{className:`text-white/80 mb-4 leading-relaxed`,style:{fontSize:`clamp(0.78rem, 1.5vw, 0.95rem)`,maxWidth:`34rem`,textShadow:`0 1px 8px rgba(0,0,0,0.5)`,animation:`heroIn 0.7s 0.08s cubic-bezier(0.22, 1, 0.36, 1) both`},children:n}),(0,g.jsxs)(`div`,{className:`flex flex-wrap gap-2 items-center`,style:{animation:`heroBadge 0.65s 0.18s cubic-bezier(0.22, 1, 0.36, 1) both`},children:[r>0&&(0,g.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-white font-semibold px-3.5 py-1.5 rounded-full border border-white/20 shadow-lg`,style:{fontSize:`clamp(0.7rem, 1.3vw, 0.8rem)`,background:`rgba(0,0,0,0.35)`,backdropFilter:`blur(12px)`},children:[(0,g.jsx)(`svg`,{className:`w-3.5 h-3.5 opacity-75 shrink-0`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,g.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})}),Number(r).toLocaleString(`ar-EG`),` جنيه / شخص / ساعة`]}),i>0&&(0,g.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-white font-semibold px-3.5 py-1.5 rounded-full border border-white/20 shadow-lg`,style:{fontSize:`clamp(0.7rem, 1.3vw, 0.8rem)`,background:`rgba(0,0,0,0.35)`,backdropFilter:`blur(12px)`},children:[(0,g.jsx)(`svg`,{className:`w-3.5 h-3.5 opacity-75 shrink-0`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,g.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0z`})}),`الطاقة: `,i,` شخص`]}),(0,g.jsxs)(`button`,{type:`button`,onClick:m,className:`inline-flex items-center gap-1.5 text-white font-bold px-4 py-1.5 rounded-full shadow-lg transition-all duration-200 active:scale-95 hover:brightness-110`,style:{fontSize:`clamp(0.72rem, 1.35vw, 0.82rem)`,background:`linear-gradient(135deg, #d97706, #b45309)`,boxShadow:`0 4px 20px rgba(180, 83, 9, 0.45)`},children:[`احجز الآن`,(0,g.jsx)(`svg`,{className:`w-3 h-3`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,strokeWidth:3,children:(0,g.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M19 9l-7 7-7-7`})})]})]})]},a)}),e.length>1&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`button`,{type:`button`,onClick:d,"aria-label":`السابق`,className:`absolute right-3 sm:right-5 top-1/2 -translate-y-1/2 group outline-none`,style:{zIndex:4},children:(0,g.jsx)(`span`,{className:`flex items-center justify-center w-10 h-10 sm:w-11 sm:h-11 rounded-full border border-white/20 text-white transition-all duration-200 group-hover:scale-110 group-hover:border-white/50 group-active:scale-95`,style:{background:`rgba(0,0,0,0.25)`,backdropFilter:`blur(10px)`,boxShadow:`0 2px 16px rgba(0,0,0,0.3)`},children:(0,g.jsx)(`svg`,{className:`w-4 h-4 sm:w-5 sm:h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,strokeWidth:2.5,children:(0,g.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M9 5l7 7-7 7`})})})}),(0,g.jsx)(`button`,{type:`button`,onClick:u,"aria-label":`التالي`,className:`absolute left-3 sm:left-5 top-1/2 -translate-y-1/2 group outline-none`,style:{zIndex:4},children:(0,g.jsx)(`span`,{className:`flex items-center justify-center w-10 h-10 sm:w-11 sm:h-11 rounded-full border border-white/20 text-white transition-all duration-200 group-hover:scale-110 group-hover:border-white/50 group-active:scale-95`,style:{background:`rgba(0,0,0,0.25)`,backdropFilter:`blur(10px)`,boxShadow:`0 2px 16px rgba(0,0,0,0.3)`},children:(0,g.jsx)(`svg`,{className:`w-4 h-4 sm:w-5 sm:h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,strokeWidth:2.5,children:(0,g.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M15 19l-7-7 7-7`})})})})]}),e.length>1&&(0,g.jsx)(`div`,{className:`absolute bottom-3.5 left-1/2 -translate-x-1/2 flex gap-1.5 items-center`,style:{zIndex:4},children:e.map((e,t)=>(0,g.jsx)(`button`,{type:`button`,onClick:()=>o(t),"aria-label":`الشريحة ${t+1}`,style:{width:t===a?`1.75rem`:`0.45rem`,height:`0.35rem`,borderRadius:`9999px`,background:t===a?`rgba(255,255,255,0.95)`:`rgba(255,255,255,0.38)`,transition:`width 0.45s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s`,border:`none`,cursor:`pointer`,padding:0,animation:t===a?`dotsGlow 2s ease-in-out infinite`:`none`}},t))}),e.length>1&&(0,g.jsxs)(`div`,{className:`absolute top-4 left-5 text-white/50 font-mono select-none`,style:{zIndex:4,fontSize:`0.68rem`,letterSpacing:`0.08em`},children:[String(a+1).padStart(2,`0`),` / `,String(e.length).padStart(2,`0`)]})]}):null}function j({number:e,label:t,children:n}){return(0,g.jsxs)(`div`,{className:`rounded-xl border border-gray-100 bg-gray-50/60 p-5`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2.5 mb-4`,children:[(0,g.jsx)(`span`,{className:`w-6 h-6 rounded-full bg-amber-600 text-white text-xs font-bold flex items-center justify-center shrink-0 shadow-sm`,children:e}),(0,g.jsx)(`span`,{className:`text-sm font-semibold text-gray-700`,children:t})]}),n]})}var M={girls:`بنات`,boys:`أولاد`,families:`عائلات`},N={girls:`border-blue-400 bg-blue-50 text-blue-800 hover:bg-blue-100`,boys:`border-green-400 bg-green-50 text-green-800 hover:bg-green-100`,families:`border-purple-400 bg-purple-50 text-purple-800 hover:bg-purple-100`},P={girls:`border-blue-500 bg-blue-500 text-white`,boys:`border-green-500 bg-green-500 text-white`,families:`border-purple-500 bg-purple-500 text-white`},F=[`الأحد`,`الاثنين`,`الثلاثاء`,`الأربعاء`,`الخميس`,`الجمعة`,`السبت`];function I(e){return e?new Date(e+`T00:00:00`).getDay():null}function L(e,t,n){let r=I(n);if(r===null)return null;let i=e.filter(e=>e.visitor_type===t);return i.find(e=>e.day_of_week===r)??i.find(e=>e.day_of_week===7)??null}function R(e){if(!e)return 0;let[t,n]=e.slice(0,5).split(`:`).map(Number);return t*60+n}function z(e){return`${String(Math.floor(e/60)).padStart(2,`0`)}:${String(e%60).padStart(2,`0`)}`}function B(e,t,n){if(!e||!t||!n)return[];let r=[],i=R(e),a=R(t);for(;i+n<=a;)r.push({start:z(i),end:z(i+n)}),i+=n;return r}var V=[`يناير`,`فبراير`,`مارس`,`أبريل`,`مايو`,`يونيو`,`يوليو`,`أغسطس`,`سبتمبر`,`أكتوبر`,`نوفمبر`,`ديسمبر`],H=[`الأحد`,`الإثنين`,`الثلاثاء`,`الأربعاء`,`الخميس`,`الجمعة`,`السبت`],U={girls:`bg-blue-500`,boys:`bg-green-500`,families:`bg-purple-500`},W={all:`bg-gray-800 text-white`,girls:`bg-blue-500 text-white`,boys:`bg-green-500 text-white`,families:`bg-purple-500 text-white`},G={all:`bg-gray-100 text-gray-700 hover:bg-gray-200`,girls:`bg-blue-50 text-blue-700 border border-blue-200 hover:bg-blue-100`,boys:`bg-green-50 text-green-700 border border-green-200 hover:bg-green-100`,families:`bg-purple-50 text-purple-700 border border-purple-200 hover:bg-purple-100`};function K({schedules:e,available:t,selectedDate:n,onDateSelect:r,lockedRanges:i=[]}){let a=new Date,o=a.toISOString().split(`T`)[0];function s(e){return i.some(t=>e>=t.date_from&&e<=t.date_to)}let[c,l]=(0,h.useState)(a.getFullYear()),[u,d]=(0,h.useState)(a.getMonth()),[f,p]=(0,h.useState)(`all`),m=(0,h.useMemo)(()=>{let t={};return e.forEach(e=>{U[e.visitor_type]&&(t[e.day_of_week]||(t[e.day_of_week]=new Set),t[e.day_of_week].add(e.visitor_type))}),t},[e]),_=new Date(c,u+1,0).getDate(),v=new Date(c,u,1).getDay(),y=c===a.getFullYear()&&u===a.getMonth();function b(e,t,n){return`${e}-${String(t+1).padStart(2,`0`)}-${String(n).padStart(2,`0`)}`}function x(){y||(u===0?(l(e=>e-1),d(11)):d(e=>e-1))}function S(){u===11?(l(e=>e+1),d(0)):d(e=>e+1)}function C(n){let r=new Date(n+`T00:00:00`).getDay();return t.some(t=>e.some(e=>e.visitor_type===t&&(e.day_of_week===r||e.day_of_week===7)))}function w(e){let t=new Date(e+`T00:00:00`).getDay(),n=[...new Set([...m[t]??[],...m[7]??[]])];return f===`all`?n:n.filter(e=>e===f)}return(0,g.jsxs)(`div`,{className:`space-y-3`,children:[(0,g.jsx)(`div`,{className:`flex gap-2 flex-wrap`,children:[`all`,`girls`,`boys`,`families`].map(e=>(0,g.jsx)(`button`,{type:`button`,onClick:()=>p(e),className:`rounded-full px-4 py-1.5 text-sm font-medium transition-all ${f===e?W[e]:G[e]}`,children:e===`all`?`الكل`:M[e]},e))}),(0,g.jsxs)(`div`,{className:`rounded-xl border border-gray-200 overflow-hidden select-none`,children:[(0,g.jsxs)(`div`,{className:`flex items-center justify-between bg-gray-50 border-b border-gray-200 px-4 py-3`,children:[(0,g.jsx)(`button`,{type:`button`,onClick:x,disabled:y,className:`w-8 h-8 flex items-center justify-center rounded-lg text-lg transition-colors ${y?`text-gray-300 cursor-default`:`text-gray-600 hover:bg-gray-200`}`,children:`‹`}),(0,g.jsxs)(`span`,{className:`font-semibold text-gray-800 text-sm`,children:[V[u],` `,c]}),(0,g.jsx)(`button`,{type:`button`,onClick:S,className:`w-8 h-8 flex items-center justify-center rounded-lg text-lg text-gray-600 hover:bg-gray-200 transition-colors`,children:`›`})]}),(0,g.jsx)(`div`,{className:`grid grid-cols-7 bg-gray-50 border-b border-gray-100`,children:H.map(e=>(0,g.jsx)(`div`,{className:`py-1.5 text-center text-xs font-medium text-gray-500`,children:e},e))}),(0,g.jsxs)(`div`,{className:`grid grid-cols-7`,children:[Array.from({length:v}).map((e,t)=>(0,g.jsx)(`div`,{className:`h-14 border-b border-r border-gray-100 last:border-r-0 bg-gray-50/50`},`e${t}`)),Array.from({length:_},(e,t)=>t+1).map(e=>{let t=b(c,u,e),i=t<o,a=t===o,l=t===n,d=s(t),f=!i&&!d&&C(t),p=w(t),m=(v+e-1)%7;return(0,g.jsxs)(`button`,{type:`button`,disabled:!f,onClick:()=>f&&r(t),className:`h-14 flex flex-col items-center justify-start pt-1.5 border-b border-r border-gray-100 transition-colors ${m===6?`border-r-0`:``} ${l?`bg-amber-50`:d?`bg-red-50/60`:i?`bg-gray-50/50`:f?`hover:bg-amber-50/60`:`bg-gray-50/50`} ${f?`cursor-pointer`:`cursor-default`}`,children:[(0,g.jsx)(`span`,{className:`text-sm w-7 h-7 flex items-center justify-center rounded-full font-medium ${l?`bg-amber-500 text-white font-bold`:a?`ring-2 ring-amber-400 text-amber-700 font-semibold`:i?`text-gray-300`:d?`text-red-300 line-through`:f?`text-gray-800`:`text-gray-300`}`,children:e}),p.length>0&&!d&&(0,g.jsx)(`div`,{className:`flex flex-col gap-0.5 mt-0.5`,children:p.map(e=>(0,g.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,g.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${U[e]}`}),(0,g.jsx)(`span`,{className:`text-[9px] leading-none text-gray-600`,children:M[e]})]},e))}),d&&(0,g.jsx)(`span`,{className:`text-[9px] leading-none text-red-400 mt-0.5`,children:`مغلق`})]},e)})]})]}),(0,g.jsx)(`div`,{className:`flex items-center gap-4 text-xs text-gray-500`,children:[`girls`,`boys`,`families`].map(e=>(0,g.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,g.jsx)(`span`,{className:`w-2 h-2 rounded-full ${U[e]}`}),(0,g.jsx)(`span`,{children:M[e]})]},e))})]})}function q({pricePerPerson:t,poolMaxCapacity:r,availableVisitorTypes:i,poolSchedules:o,poolBookings:s,instapayEnabled:c,cashEnabled:l=!0,lockedRanges:u=[],instapayWhatsapp:d=``}){let{auth:p}=e().props,m=i??[],_=o??[],b=s??[],{data:T,setData:E,post:A,processing:V,errors:H}=n({date:``,visitor_type:``,time_start:``,time_end:``,persons_count:``,name:p.user?.name??``,phone:p.user?.phone??``,payment_method:`cash`,instapay_sender_phone:``,notes:``}),U=(0,h.useMemo)(()=>{if(!T.date)return[];let e=I(T.date);return m.filter(t=>_.some(n=>n.visitor_type===t&&(n.day_of_week===e||n.day_of_week===7)))},[T.date,_,m]),W=(0,h.useMemo)(()=>L(_,T.visitor_type,T.date),[_,T.visitor_type,T.date]),G=(0,h.useMemo)(()=>B(W?.start_time,W?.end_time,60),[W,60]);function q(e){let t=e+60;return b.filter(n=>n.date!==T.date||n.visitor_type!==T.visitor_type?!1:R(n.time_start)<=e&&R(n.time_end)>=t).reduce((e,t)=>e+(t.persons_count||0),0)}function J(e){let t=q(R(e));return r>0?t>=r:t>0}let Y=(0,h.useMemo)(()=>{if(!T.time_start||!W)return[];let e=R(T.time_start),t=R(W.end_time.slice(0,5)),n=[],i=1;for(;e+i*60<=t;){let t=e+(i-1)*60,a=t+60,o=b.filter(e=>e.date!==T.date||e.visitor_type!==T.visitor_type?!1:R(e.time_start)<=t&&R(e.time_end)>=a).reduce((e,t)=>e+(t.persons_count||0),0);if(r>0?o>=r:o>0)break;n.push({time:z(e+i*60),n:i}),i++}return n},[T.time_start,W,60,b,T.date,T.visitor_type,r]),X=(0,h.useMemo)(()=>{if(!r||!T.time_start)return null;let e=R(T.time_start),t=T.time_end?R(T.time_end):e+60,n=r;for(let i=e;i<t;i+=60){let e=b.filter(e=>e.date!==T.date||e.visitor_type!==T.visitor_type?!1:R(e.time_start)<=i&&R(e.time_end)>=i+60).reduce((e,t)=>e+(t.persons_count||0),0);n=Math.min(n,r-e)}return Math.max(0,n)},[r,T.time_start,T.time_end,b,T.date,T.visitor_type,60]),Z=T.time_end?R(T.time_end)-R(T.time_start):0,ee=Z/60,$=Number(T.persons_count||0)*ee*(t??0);function te(e){E(t=>({...t,date:e,visitor_type:``,time_start:``,time_end:``}))}function ne(e){E(t=>({...t,visitor_type:e,time_start:``,time_end:``}))}function re(e){E(t=>({...t,time_start:e,time_end:``}))}function ie(e){E(`time_end`,e)}function ae(e){e.preventDefault(),A(route(`book.store`,{facility:`pool`}))}return m.length===0?(0,g.jsxs)(`div`,{className:`rounded-xl border border-red-200 bg-red-50 p-6 flex gap-4 items-start`,children:[(0,g.jsx)(`svg`,{className:`h-6 w-6 text-red-400 shrink-0 mt-0.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,g.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M12 9v2m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`p`,{className:`font-semibold text-red-800 text-sm`,children:`الحجز غير متاح حالياً`}),(0,g.jsx)(`p`,{className:`text-red-700 text-sm mt-1`,children:`لا توجد مواعيد متاحة لحمام السباحة في الوقت الحالي. يُرجى التواصل مع الإدارة أو المحاولة لاحقاً.`}),(0,g.jsx)(a,{href:route(`services`),className:`inline-block mt-3 text-sm font-medium text-red-700 underline hover:text-red-900`,children:`← العودة للخدمات`})]})]}):((0,h.useMemo)(()=>{let e={girls:[],boys:[],families:[]};return _.forEach(t=>{e[t.visitor_type]&&e[t.visitor_type].push(t)}),e},[_]),(0,g.jsxs)(`form`,{onSubmit:ae,className:`space-y-6`,children:[(0,g.jsx)(`div`,{className:`rounded-xl border border-blue-100 bg-gradient-to-br from-blue-50 to-sky-50 p-5 space-y-4`,children:(t>0||r>0)&&(0,g.jsxs)(`div`,{className:`flex flex-wrap gap-x-6 gap-y-2`,children:[t>0&&(0,g.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-blue-800`,children:[(0,g.jsx)(`svg`,{className:`h-4 w-4 text-blue-500 shrink-0`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,g.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})}),`السعر: `,(0,g.jsxs)(`strong`,{children:[Number(t).toLocaleString(`ar-EG`),` جنيه / شخص / ساعة`]})]}),r>0&&(0,g.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-blue-800`,children:[(0,g.jsx)(`svg`,{className:`h-4 w-4 text-blue-500 shrink-0`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,g.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0z`})}),`الطاقة الاستيعابية: `,(0,g.jsxs)(`strong`,{children:[r,` شخص`]})]})]})}),(0,g.jsxs)(j,{number:`١`,label:`اختر اليوم والتاريخ`,children:[(0,g.jsx)(`div`,{className:`-mx-2`,children:(0,g.jsx)(K,{schedules:_,available:m,selectedDate:T.date,onDateSelect:te,lockedRanges:u})}),T.date&&(0,g.jsxs)(`p`,{className:`mt-3 text-sm font-semibold text-amber-700 flex items-center gap-1.5`,children:[(0,g.jsx)(f,{className:`w-4 h-4 shrink-0`}),` `,new Date(T.date+`T00:00:00`).toLocaleDateString(`ar-EG`,{weekday:`long`,year:`numeric`,month:`long`,day:`numeric`})]}),H.date&&(0,g.jsx)(`p`,{className:S,children:H.date})]}),T.date&&(0,g.jsxs)(j,{number:`٢`,label:`اختر الفئة`,children:[!1,U.length===0?(0,g.jsx)(`div`,{className:`rounded-lg bg-amber-50 border border-amber-200 px-4 py-3 text-sm text-amber-700`,children:`لا توجد فئات متاحة لهذا اليوم. اختر يوماً آخر.`}):(0,g.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:U.map(e=>{let t=T.visitor_type===e,n=N[e]??`border-gray-300 bg-gray-50 text-gray-700 hover:bg-gray-100`,r=P[e]??`border-gray-500 bg-gray-500 text-white`,i=L(_,e,T.date);return(0,g.jsxs)(`button`,{type:`button`,onClick:()=>ne(e),className:`rounded-xl border-2 px-5 py-3 text-sm font-semibold transition-all ${t?r:n}`,children:[(0,g.jsx)(`span`,{className:`block text-base`,children:M[e]}),i&&(0,g.jsxs)(`span`,{className:`block text-xs font-normal mt-0.5 ${t?`opacity-80`:`opacity-60`}`,children:[D(i.start_time),` – `,D(i.end_time)]})]},e)})}),H.visitor_type&&(0,g.jsx)(`p`,{className:S,children:H.visitor_type})]}),T.date&&T.visitor_type&&W&&(0,g.jsxs)(j,{number:`٣`,label:`اختر الوقت`,children:[r>0&&(0,g.jsxs)(`p`,{className:`mb-3 text-xs text-gray-400`,children:[`الطاقة الاستيعابية: `,r,` شخص`]}),(0,g.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:gap-6`,children:[(0,g.jsxs)(`div`,{className:`sm:flex-1`,children:[(0,g.jsxs)(`p`,{className:x,children:[`اختر وقت البداية `,(0,g.jsx)(`span`,{className:`text-red-500 ml-0.5`,children:`*`})]}),G.length===0?(0,g.jsx)(`div`,{className:`rounded-lg bg-amber-50 border border-amber-200 px-4 py-3 text-sm text-amber-700`,children:`لا توجد فترات زمنية متاحة لهذا الجدول.`}):G.every(e=>J(e.start))?(0,g.jsx)(`div`,{className:`rounded-lg bg-gray-50 border border-gray-200 px-4 py-3 text-sm text-gray-600`,children:`جميع الفترات محجوزة في هذا اليوم.`}):(0,g.jsx)(`div`,{className:`grid gap-2 grid-cols-3`,children:G.filter(e=>!J(e.start)).map(e=>(0,g.jsxs)(`button`,{type:`button`,onClick:()=>re(e.start),className:`rounded-xl border-2 px-2 text-sm font-medium text-center transition-all w-full h-[3.75rem] flex flex-col items-center justify-center overflow-hidden ${T.time_start===e.start?`border-amber-500 bg-amber-500 text-white shadow-md`:`border-gray-200 bg-white text-gray-700 hover:border-amber-400 hover:bg-amber-50`}`,children:[(0,g.jsx)(`span`,{className:`block font-semibold`,children:D(e.start)}),(0,g.jsx)(`span`,{className:`block text-xs mt-0.5 opacity-0`,"aria-hidden":`true`,children:`—`})]},e.start))}),H.time_start&&(0,g.jsx)(`p`,{className:S,children:H.time_start})]}),T.time_start&&(0,g.jsxs)(`div`,{className:`sm:flex-1`,children:[(0,g.jsxs)(`p`,{className:x,children:[`اختر وقت النهاية `,(0,g.jsx)(`span`,{className:`text-red-500 ml-0.5`,children:`*`})]}),Y.length===0?(0,g.jsx)(`div`,{className:`rounded-lg bg-amber-50 border border-amber-200 px-4 py-3 text-sm text-amber-700`,children:`لا توجد خيارات متاحة من هذا الوقت.`}):(0,g.jsx)(`div`,{className:`grid gap-2 grid-cols-3`,children:Y.map(e=>{let t=T.time_end===e.time,n=R(e.time)-R(T.time_start),r=n>=60?n%60==0?`${n/60} ساعة`:`${Math.floor(n/60)} س ${n%60} د`:`${n} د`;return(0,g.jsxs)(`button`,{type:`button`,onClick:()=>ie(e.time),className:`rounded-xl border-2 px-2 text-sm font-medium text-center transition-all w-full h-[3.75rem] flex flex-col items-center justify-center overflow-hidden ${t?`border-amber-500 bg-amber-500 text-white shadow-md`:`border-gray-200 bg-white text-gray-700 hover:border-amber-400 hover:bg-amber-50`}`,children:[(0,g.jsx)(`span`,{className:`block font-semibold`,children:D(e.time)}),(0,g.jsx)(`span`,{className:`block text-xs mt-0.5 whitespace-nowrap ${t?`opacity-80`:`text-gray-400`}`,children:r})]},e.time)})}),H.time_end&&(0,g.jsx)(`p`,{className:S,children:H.time_end})]})]})]}),T.time_end&&(0,g.jsx)(j,{number:`٤`,label:`بيانات الحجز`,children:(0,g.jsxs)(`div`,{className:`space-y-4`,children:[(0,g.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-4`,children:[(0,g.jsx)(C,{label:`الاسم`,error:H.name,required:!0,children:(0,g.jsx)(`input`,{type:`text`,className:v,value:T.name,onChange:e=>E(`name`,e.target.value)})}),(0,g.jsxs)(C,{label:`رقم الموبايل`,error:H.phone,required:!0,children:[(0,g.jsx)(`input`,{type:`text`,inputMode:`numeric`,maxLength:11,dir:`rtl`,placeholder:`01xxxxxxxxx`,className:v,value:T.phone,onChange:e=>E(`phone`,e.target.value.replace(/\D/g,``))}),(0,g.jsx)(`p`,{className:`mt-1 text-xs text-gray-400`,children:`11 رقماً بالضبط`})]}),(0,g.jsxs)(C,{label:`عدد الأشخاص`,error:H.persons_count,required:!0,children:[(0,g.jsx)(`input`,{type:`number`,min:`1`,className:v,value:T.persons_count,onChange:e=>E(`persons_count`,e.target.value)}),X===null?r>0&&(0,g.jsxs)(`p`,{className:`mt-1 text-xs text-gray-400`,children:[`الطاقة الاستيعابية الإجمالية: `,r,` شخص`]}):(0,g.jsxs)(`p`,{className:`mt-1 text-xs text-gray-400`,children:[`الطاقة المتاحة لهذه الفترة: `,X,` شخص`]})]}),(0,g.jsx)(O,{value:T.payment_method,onChange:e=>{E(t=>({...t,payment_method:e.target.value,instapay_sender_phone:``}))},error:H.payment_method,instapayEnabled:c,cashEnabled:l}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`label`,{className:x,children:`سعر الشخص / ساعة`}),(0,g.jsx)(`input`,{type:`text`,readOnly:!0,dir:`rtl`,value:t?`${Number(t).toLocaleString(`ar-EG`)} جنيه`:`—`,className:y})]}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`label`,{className:x,children:`الإجمالي`}),(0,g.jsx)(`input`,{type:`text`,readOnly:!0,dir:`rtl`,value:$>0?`${Number($).toLocaleString(`ar-EG`)} جنيه`:`—`,className:`${y} font-semibold text-gray-800`})]})]}),(0,g.jsx)(k,{show:T.payment_method===`online`&&!!c,whatsapp:d,senderPhone:T.instapay_sender_phone,onChange:e=>E(`instapay_sender_phone`,e),error:H.instapay_sender_phone}),(0,g.jsx)(C,{label:`ملاحظات`,error:H.notes,children:(0,g.jsx)(`textarea`,{className:v,rows:3,value:T.notes,onChange:e=>E(`notes`,e.target.value),placeholder:`أي تفاصيل أو طلبات إضافية…`})})]})}),T.time_end&&T.date&&(0,g.jsxs)(`div`,{className:`rounded-xl bg-blue-50  border border-blue-200 p-4 space-y-2`,children:[(0,g.jsx)(`p`,{className:`text-sm font-semibold  text-blue-800 mb-2`,children:`ملخص الحجز`}),(0,g.jsx)(w,{label:`اليوم`,value:F[I(T.date)]}),(0,g.jsx)(w,{label:`التاريخ`,value:T.date}),(0,g.jsx)(w,{label:`الفئة`,value:M[T.visitor_type]??T.visitor_type}),(0,g.jsx)(w,{label:`الفترة`,value:`${D(T.time_start)} – ${D(T.time_end)}`}),(0,g.jsx)(w,{label:`المدة`,value:Z>=60?Z%60==0?`${Z/60} ساعة`:`${Math.floor(Z/60)} س ${Z%60} د`:`${Z} دقيقة`}),(0,g.jsx)(`p`,{className:`text-xs text-amber-600 pt-1`,children:`السعر النهائي يُحدده الإداري عند تأكيد الحجز.`})]}),T.time_end&&(0,g.jsx)(Q,{processing:V})]}))}function J({checkIn:e,checkOut:t,onRangeChange:n}){let r=new Date,i=r.toISOString().split(`T`)[0],[a,o]=(0,h.useState)(r.getFullYear()),[s,c]=(0,h.useState)(r.getMonth()),[l,u]=(0,h.useState)(null),d=new Date(a,s+1,0).getDate(),f=new Date(a,s,1).getDay(),p=a===r.getFullYear()&&s===r.getMonth(),m=(e,t,n)=>`${e}-${String(t+1).padStart(2,`0`)}-${String(n).padStart(2,`0`)}`,_=()=>{p||(s===0?(o(e=>e-1),c(11)):c(e=>e-1))},v=()=>{s===11?(o(e=>e+1),c(0)):c(e=>e+1)},y=!e||e&&t?`in`:`out`,b=y===`out`&&l&&l>e?l:t,x=t=>e&&b&&b>e&&t>e&&t<b;function S(t){y===`in`||t<=e?n(t,``):n(e,t)}function C(e){if(!e)return null;let t=new Date(e+`T00:00:00`);return{day:t.toLocaleDateString(`ar-EG`,{day:`numeric`,month:`long`}),weekday:t.toLocaleDateString(`ar-EG`,{weekday:`long`})}}let w=C(e),T=C(t);return(0,g.jsxs)(`div`,{className:`space-y-3`,children:[(0,g.jsxs)(`div`,{className:`grid items-stretch gap-2`,style:{gridTemplateColumns:`1fr auto 1fr`},children:[(0,g.jsxs)(`div`,{onClick:()=>n(``,``),className:`rounded-xl border-2 p-3 cursor-pointer transition-all ${y===`in`?`border-amber-500 bg-white shadow-sm`:w?`border-amber-600 bg-amber-600 text-white`:`border-gray-200 bg-gray-50`}`,children:[(0,g.jsxs)(`p`,{className:`text-[10px] font-medium mb-1 flex items-center gap-1 ${y===`in`?`text-amber-500`:w?`text-amber-200`:`text-gray-400`}`,children:[(0,g.jsx)(`svg`,{className:`w-3 h-3`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,g.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z`})}),`تاريخ الدخول`]}),w?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`p`,{className:`text-base font-bold leading-tight ${y===`in`?`text-gray-900`:`text-white`}`,children:w.day}),(0,g.jsx)(`p`,{className:`text-xs mt-0.5 ${y===`in`?`text-gray-500`:`text-amber-200`}`,children:w.weekday})]}):(0,g.jsx)(`p`,{className:`text-sm text-gray-400`,children:`اختر التاريخ`})]}),(0,g.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-1 px-1`,children:[(0,g.jsx)(`div`,{className:`w-10 h-10 rounded-full border-2 border-amber-300 bg-white flex items-center justify-center shadow-sm`,children:(0,g.jsx)(`span`,{className:`text-sm font-bold text-amber-700 leading-none`,children:e&&t?Math.round((new Date(t+`T00:00:00`)-new Date(e+`T00:00:00`))/864e5):`—`})}),(0,g.jsx)(`span`,{className:`text-[10px] text-gray-400 font-medium`,children:`ليلة`})]}),(0,g.jsxs)(`div`,{onClick:()=>e&&n(e,``),className:`rounded-xl border-2 p-3 transition-all ${y===`out`?`border-amber-500 bg-white shadow-sm cursor-pointer`:T?`border-amber-600 bg-amber-600 text-white cursor-pointer`:`border-gray-200 bg-gray-50 cursor-default`}`,children:[(0,g.jsxs)(`p`,{className:`text-[10px] font-medium mb-1 flex items-center gap-1 ${y===`out`?`text-amber-500`:T?`text-amber-200`:`text-gray-400`}`,children:[(0,g.jsx)(`svg`,{className:`w-3 h-3`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,g.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z`})}),`تاريخ الخروج`]}),T?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`p`,{className:`text-base font-bold leading-tight ${y===`out`?`text-gray-900`:`text-white`}`,children:T.day}),(0,g.jsx)(`p`,{className:`text-xs mt-0.5 ${y===`out`?`text-gray-500`:`text-amber-200`}`,children:T.weekday})]}):(0,g.jsx)(`p`,{className:`text-sm text-gray-400`,children:e?`اختر التاريخ`:`—`})]})]}),(0,g.jsxs)(`div`,{className:`rounded-xl border border-gray-200 overflow-hidden select-none`,children:[(0,g.jsxs)(`div`,{className:`flex items-center justify-between bg-gray-50 border-b border-gray-200 px-4 py-3`,children:[(0,g.jsx)(`button`,{type:`button`,onClick:_,disabled:p,className:`w-8 h-8 flex items-center justify-center rounded-lg text-lg transition-colors ${p?`text-gray-300 cursor-default`:`text-gray-600 hover:bg-gray-200`}`,children:`‹`}),(0,g.jsxs)(`span`,{className:`font-semibold text-gray-800 text-sm`,children:[V[s],` `,a]}),(0,g.jsx)(`button`,{type:`button`,onClick:v,className:`w-8 h-8 flex items-center justify-center rounded-lg text-lg text-gray-600 hover:bg-gray-200 transition-colors`,children:`›`})]}),(0,g.jsx)(`div`,{className:`grid grid-cols-7 bg-gray-50 border-b border-gray-100`,children:H.map(e=>(0,g.jsx)(`div`,{className:`py-1.5 text-center text-xs font-medium text-gray-500`,children:e},e))}),(0,g.jsxs)(`div`,{className:`grid grid-cols-7`,children:[Array.from({length:f}).map((e,t)=>(0,g.jsx)(`div`,{className:`h-14 border-b border-r border-gray-100 last:border-r-0 bg-gray-50/50`},`e${t}`)),Array.from({length:d},(e,t)=>t+1).map(n=>{let r=m(a,s,n),o=r<i,c=r===i,l=r===e,d=r===t,p=x(r),h=(f+n-1)%7,_=!o,v=l||d||p?`bg-amber-50`:o?`bg-gray-50/50`:`hover:bg-amber-50/60`,b=l||d?`bg-amber-500 text-white font-bold`:p?`text-amber-700 font-semibold`:c?`ring-2 ring-amber-400 text-amber-700 font-semibold`:o?`text-gray-300`:`text-gray-800`;return(0,g.jsxs)(`button`,{type:`button`,disabled:!_,onClick:()=>_&&S(r),onMouseEnter:()=>y===`out`&&u(r),onMouseLeave:()=>u(null),className:`h-14 flex flex-col items-center justify-center border-b border-r border-gray-100 transition-colors ${h===6?`border-r-0`:``} ${v} ${_?`cursor-pointer`:`cursor-default`}`,children:[(0,g.jsx)(`span`,{className:`text-sm w-7 h-7 flex items-center justify-center rounded-full font-medium ${b}`,children:n}),l&&!d&&(0,g.jsx)(`span`,{className:`text-[9px] leading-none text-amber-500 mt-0.5`,children:`دخول`}),d&&(0,g.jsx)(`span`,{className:`text-[9px] leading-none text-amber-500 mt-0.5`,children:`خروج`})]},n)})]})]})]})}function Y({chaletPricePerNight:t=0,meals:r=[],instapayEnabled:i,cashEnabled:a=!0,instapayWhatsapp:o=``}){let{auth:s}=e().props,{data:c,setData:l,post:u,processing:d,errors:f}=n({date_start:``,date_end:``,adults_count:`1`,children_count:`0`,name:s.user?.name??``,phone:s.user?.phone??``,payment_method:`cash`,instapay_sender_phone:``,notes:``,meal_selections:[]}),[p,m]=(0,h.useState)(!1),_=T(c.date_start,c.date_end),x=_*t,S=(0,h.useMemo)(()=>(c.meal_selections??[]).flatMap(e=>{let t=r.find(t=>String(t.id)===String(e.meal_id)),n=parseInt(e.persons)||0;return!t||!n?[]:[{meal:t,persons:n,subtotal:t.price_per_person*n}]}),[r,c.meal_selections]).reduce((e,t)=>e+t.subtotal,0),w=x+S,D=(0,h.useMemo)(()=>[{label:`فطار`,opts:r.filter(e=>e.meal_type===`breakfast`)},{label:`غدا`,opts:r.filter(e=>e.meal_type===`lunch`)},{label:`عشاء`,opts:r.filter(e=>e.meal_type===`dinner`)}],[r]);function A(){let e=!p;m(e),e||l(e=>({...e,meal_selections:[]}))}function j(){l(e=>({...e,meal_selections:[...e.meal_selections??[],{meal_id:``,persons:``}]}))}function M(e){l(t=>({...t,meal_selections:(t.meal_selections??[]).filter((t,n)=>n!==e)}))}function N(e,t,n){l(r=>({...r,meal_selections:(r.meal_selections??[]).map((r,i)=>i===e?{...r,[t]:n}:r)}))}function P(e){e.preventDefault(),u(route(`book.store`,{facility:`chalet`}))}return(0,g.jsxs)(`form`,{onSubmit:P,className:`space-y-5`,children:[(0,g.jsx)(J,{checkIn:c.date_start,checkOut:c.date_end,onRangeChange:(e,t)=>l(n=>({...n,date_start:e,date_end:t}))}),(f.date_start||f.date_end)&&(0,g.jsx)(`p`,{className:`text-xs text-red-600`,children:f.date_start||f.date_end}),(0,g.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,g.jsx)(C,{label:`عدد البالغين`,error:f.adults_count,required:!0,children:(0,g.jsx)(`input`,{type:`number`,min:`1`,className:v,value:c.adults_count,onChange:e=>l(`adults_count`,e.target.value)})}),(0,g.jsx)(C,{label:`عدد الأطفال`,error:f.children_count,children:(0,g.jsx)(`input`,{type:`number`,min:`0`,className:v,value:c.children_count,onChange:e=>l(`children_count`,e.target.value)})}),(0,g.jsx)(C,{label:`الاسم`,error:f.name,required:!0,children:(0,g.jsx)(`input`,{type:`text`,className:v,value:c.name,onChange:e=>l(`name`,e.target.value)})}),(0,g.jsxs)(C,{label:`رقم الموبايل`,error:f.phone,required:!0,children:[(0,g.jsx)(`input`,{type:`text`,inputMode:`numeric`,maxLength:11,dir:`rtl`,placeholder:`01xxxxxxxxx`,className:v,value:c.phone,onChange:e=>l(`phone`,e.target.value.replace(/\D/g,``))}),(0,g.jsx)(`p`,{className:`mt-1 text-xs text-gray-400`,children:`11 رقماً بالضبط`})]})]}),r.length>0&&(0,g.jsxs)(`div`,{className:`rounded-xl border border-gray-200 overflow-hidden`,children:[(0,g.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 bg-amber-50 border-b border-amber-100`,children:[(0,g.jsxs)(`span`,{className:`text-sm font-medium text-amber-900 flex items-center gap-2`,children:[`🍽️ إضافات الوجبات `,(0,g.jsx)(`span`,{className:`font-normal text-amber-600 text-xs`,children:`(اختياري)`})]}),(0,g.jsx)(`button`,{type:`button`,dir:`ltr`,onClick:A,className:`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors focus:outline-none ${p?`bg-amber-500`:`bg-gray-300`}`,children:(0,g.jsx)(`span`,{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow transition-transform ${p?`translate-x-6`:`translate-x-1`}`})})]}),p&&(0,g.jsxs)(`div`,{className:`p-4 space-y-3`,children:[(c.meal_selections??[]).length===0&&(0,g.jsx)(`p`,{className:`text-sm text-gray-400 text-center py-2`,children:`اضغط «إضافة وجبة» لإضافة وجبات للحجز`}),(c.meal_selections??[]).map((e,t)=>{let n=r.find(t=>String(t.id)===String(e.meal_id)),i=n&&e.persons?n.price_per_person*parseInt(e.persons):0;return(0,g.jsxs)(`div`,{className:`flex items-end gap-3 p-3 rounded-lg bg-gray-50 border border-gray-200`,children:[(0,g.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,g.jsx)(C,{label:`الوجبة`,error:f[`meal_selections.${t}.meal_id`],children:(0,g.jsxs)(`select`,{className:b,value:e.meal_id,onChange:e=>N(t,`meal_id`,e.target.value),children:[(0,g.jsx)(`option`,{value:``,children:`— اختر الوجبة —`}),D.map(e=>e.opts.length>0&&(0,g.jsx)(`optgroup`,{label:e.label,children:e.opts.map(e=>(0,g.jsxs)(`option`,{value:e.id,children:[e.name,` (`,E(e.price_per_person),` جنيه/شخص)`]},e.id))},e.label))]})})}),(0,g.jsx)(`div`,{className:`w-24 shrink-0`,children:(0,g.jsx)(C,{label:`أشخاص`,error:f[`meal_selections.${t}.persons`],children:(0,g.jsx)(`input`,{type:`number`,min:`1`,className:v,value:e.persons,onChange:e=>N(t,`persons`,e.target.value)})})}),i>0&&(0,g.jsxs)(`p`,{className:`text-sm font-medium text-gray-700 pb-2 shrink-0`,children:[E(i),` جنيه`]}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>M(t),className:`pb-2 shrink-0 text-red-400 hover:text-red-600 transition-colors`,children:(0,g.jsx)(`svg`,{className:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,g.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M6 18L18 6M6 6l12 12`})})})]},t)}),(0,g.jsxs)(`button`,{type:`button`,onClick:j,className:`flex items-center gap-2 text-sm text-amber-700 hover:text-amber-900 font-medium transition-colors`,children:[(0,g.jsx)(`svg`,{className:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,g.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M12 4v16m8-8H4`})}),`إضافة وجبة`]})]})]}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-4`,children:[(0,g.jsx)(C,{label:`سعر الليلة`,children:(0,g.jsx)(`input`,{className:y,readOnly:!0,dir:`rtl`,value:t>0?`${E(t)} جنيه`:`—`})}),(0,g.jsx)(C,{label:`عدد الليالي`,children:(0,g.jsx)(`input`,{className:y,readOnly:!0,dir:`rtl`,value:_||`—`})}),(0,g.jsx)(C,{label:`تكلفة الشاليه`,children:(0,g.jsx)(`input`,{className:y,readOnly:!0,dir:`rtl`,value:x>0?`${E(x)} جنيه`:`—`})}),(0,g.jsx)(C,{label:`إجمالي الوجبات`,children:(0,g.jsx)(`input`,{className:y,readOnly:!0,dir:`rtl`,value:S>0?`${E(S)} جنيه`:`—`})})]}),(0,g.jsxs)(`div`,{className:`rounded-lg bg-amber-50 border border-amber-200 px-4 py-3 flex items-center justify-between`,children:[(0,g.jsx)(`span`,{className:`text-sm font-semibold text-amber-800`,children:`الإجمالي الكلي`}),(0,g.jsx)(`span`,{className:`text-lg font-bold text-amber-900`,children:w>0?`${E(w)} جنيه`:`—`})]}),(0,g.jsx)(O,{value:c.payment_method,onChange:e=>{l(t=>({...t,payment_method:e.target.value,instapay_sender_phone:``}))},error:f.payment_method,instapayEnabled:i,cashEnabled:a}),(0,g.jsx)(k,{show:c.payment_method===`online`&&!!i,whatsapp:o,senderPhone:c.instapay_sender_phone,onChange:e=>l(`instapay_sender_phone`,e),error:f.instapay_sender_phone}),(0,g.jsx)(C,{label:`ملاحظات`,error:f.notes,children:(0,g.jsx)(`textarea`,{className:v,rows:3,value:c.notes,onChange:e=>l(`notes`,e.target.value),placeholder:`أي طلبات خاصة…`})}),(0,g.jsx)(Q,{processing:d})]})}function X({schedules:e,selectedDate:t,onDateSelect:n,lockedRanges:r=[]}){let i=new Date,a=i.toISOString().split(`T`)[0];function o(e){return r.some(t=>e>=t.date_from&&e<=t.date_to)}let[s,c]=(0,h.useState)(i.getFullYear()),[l,u]=(0,h.useState)(i.getMonth()),d=new Date(s,l+1,0).getDate(),f=new Date(s,l,1).getDay(),p=s===i.getFullYear()&&l===i.getMonth();function m(e,t,n){return`${e}-${String(t+1).padStart(2,`0`)}-${String(n).padStart(2,`0`)}`}function _(){p||(l===0?(c(e=>e-1),u(11)):u(e=>e-1))}function v(){l===11?(c(e=>e+1),u(0)):u(e=>e+1)}function y(t){let n=new Date(t+`T00:00:00`).getDay();return e.some(e=>e.day_of_week===n||e.day_of_week===7)}return(0,g.jsxs)(`div`,{className:`rounded-xl border border-gray-200 overflow-hidden select-none`,children:[(0,g.jsxs)(`div`,{className:`flex items-center justify-between bg-gray-50 border-b border-gray-200 px-4 py-3`,children:[(0,g.jsx)(`button`,{type:`button`,onClick:_,disabled:p,className:`w-8 h-8 flex items-center justify-center rounded-lg text-lg transition-colors ${p?`text-gray-300 cursor-default`:`text-gray-600 hover:bg-gray-200`}`,children:`‹`}),(0,g.jsxs)(`span`,{className:`font-semibold text-gray-800 text-sm`,children:[V[l],` `,s]}),(0,g.jsx)(`button`,{type:`button`,onClick:v,className:`w-8 h-8 flex items-center justify-center rounded-lg text-lg text-gray-600 hover:bg-gray-200 transition-colors`,children:`›`})]}),(0,g.jsx)(`div`,{className:`grid grid-cols-7 bg-gray-50 border-b border-gray-100`,children:H.map(e=>(0,g.jsx)(`div`,{className:`py-1.5 text-center text-xs font-medium text-gray-500`,children:e},e))}),(0,g.jsxs)(`div`,{className:`grid grid-cols-7`,children:[Array.from({length:f}).map((e,t)=>(0,g.jsx)(`div`,{className:`h-14 border-b border-r border-gray-100 last:border-r-0 bg-gray-50/50`},`e${t}`)),Array.from({length:d},(e,t)=>t+1).map(e=>{let r=m(s,l,e),i=r<a,c=r===a,u=r===t,d=o(r),p=!i&&!d&&y(r),h=(f+e-1)%7;return(0,g.jsxs)(`button`,{type:`button`,disabled:!p,onClick:()=>p&&n(r),className:`h-14 flex flex-col items-center justify-center border-b border-r border-gray-100 transition-colors ${h===6?`border-r-0`:``} ${u?`bg-amber-50`:d?`bg-red-50/60`:i?`bg-gray-50/50`:p?`hover:bg-amber-50/60`:`bg-gray-50/50`} ${p?`cursor-pointer`:`cursor-default`}`,children:[(0,g.jsx)(`span`,{className:`text-sm w-7 h-7 flex items-center justify-center rounded-full font-medium ${u?`bg-amber-500 text-white font-bold`:c?`ring-2 ring-amber-400 text-amber-700 font-semibold`:i?`text-gray-300`:d?`text-red-300 line-through`:p?`text-gray-800`:`text-gray-300`}`,children:e}),p&&(0,g.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-green-500 mt-0.5`}),d&&(0,g.jsx)(`span`,{className:`text-[9px] leading-none text-red-400 mt-0.5`,children:`مغلق`})]},e)})]})]})}function Z({courts:t,sportsSchedules:r,sportsBookings:i,instapayEnabled:a,cashEnabled:o=!0,selectedId:s,onCourtChange:c,lockedRanges:l=[],instapayWhatsapp:u=``}){let{auth:d}=e().props,p=r??[],m=i??[],{data:_,setData:T,post:A,processing:M,errors:N}=n({facility_id:s?String(s):``,date_start:``,time_start:``,time_end:``,name:d.user?.name??``,phone:d.user?.phone??``,payment_method:`cash`,instapay_sender_phone:``,notes:``}),P=(0,h.useMemo)(()=>t.find(e=>e.id==_.facility_id),[t,_.facility_id]),F=(0,h.useMemo)(()=>p.filter(e=>String(e.court_id)===String(_.facility_id)),[p,_.facility_id]),I=(0,h.useMemo)(()=>{if(!_.date_start||!F.length)return null;let e=new Date(_.date_start+`T00:00:00`).getDay();return F.find(t=>t.day_of_week===e)??F.find(e=>e.day_of_week===7)??null},[F,_.date_start]),L=(0,h.useMemo)(()=>B(I?.start_time,I?.end_time,60),[I]);function V(e){let t=R(e),n=t+60;return m.some(e=>String(e.court_id)!==String(_.facility_id)||e.date!==_.date_start||e.status!==`confirmed`?!1:R(e.time_start)<=t&&R(e.time_end)>=n)}function H(e){let t=R(e),n=t+60;return m.some(e=>String(e.court_id)!==String(_.facility_id)||e.date!==_.date_start||e.status!==`pending`?!1:R(e.time_start)<=t&&R(e.time_end)>=n)}let U=(0,h.useMemo)(()=>{if(!_.time_start||!I)return[];let e=R(_.time_start),t=R(I.end_time.slice(0,5)),n=[],r=1;for(;e+r*60<=t;){let t=e+(r-1)*60;if(m.some(e=>String(e.court_id)!==String(_.facility_id)||e.date!==_.date_start||e.status!==`confirmed`?!1:R(e.time_start)<=t&&R(e.time_end)>=t+60))break;n.push({time:z(e+r*60),n:r}),r++}return n},[_.time_start,I,m,_.facility_id,_.date_start]),W=_.time_end?R(_.time_end)-R(_.time_start):0,G=W/60*(P?.price_per_hour??0);function K(e){T(t=>({...t,facility_id:e,date_start:``,time_start:``,time_end:``})),c?.(e)}function q(e){T(t=>({...t,date_start:e,time_start:``,time_end:``}))}function J(e){T(t=>({...t,time_start:e,time_end:``}))}function Y(e){e.preventDefault(),A(route(`book.store`,{facility:`sports_court`}))}return t.length===0?(0,g.jsxs)(`div`,{className:`rounded-xl bg-amber-50 border border-amber-200 p-6 text-center space-y-2`,children:[(0,g.jsx)(`p`,{className:`text-amber-800 font-semibold`,children:`لا توجد ملاعب متاحة للحجز حالياً`}),(0,g.jsx)(`p`,{className:`text-sm text-amber-600`,children:`يرجى التواصل مع الإدارة للاستفسار عن التوافر.`})]}):(0,g.jsxs)(`form`,{onSubmit:Y,className:`space-y-6`,children:[(0,g.jsx)(j,{number:`١`,label:`اختر الملعب`,children:(0,g.jsxs)(`div`,{className:`space-y-3`,children:[(0,g.jsx)(C,{error:N.facility_id,children:(0,g.jsxs)(`select`,{className:b,value:_.facility_id,onChange:e=>K(e.target.value),children:[(0,g.jsx)(`option`,{value:``,children:`— اختر الملعب —`}),t.map(e=>(0,g.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.sport_type,`) — `,E(e.price_per_hour),` ج/ساعة`]},e.id))]})}),P&&(0,g.jsxs)(`div`,{className:`rounded-xl bg-green-50 border border-green-100 p-4 space-y-2 text-sm`,children:[(0,g.jsx)(`p`,{className:`font-semibold text-green-800`,children:P.name}),(0,g.jsxs)(`div`,{className:`flex gap-4 text-green-700`,children:[(0,g.jsxs)(`span`,{children:[`الرياضة: `,(0,g.jsx)(`strong`,{children:P.sport_type})]}),(0,g.jsxs)(`span`,{children:[`السعر: `,(0,g.jsxs)(`strong`,{children:[E(P.price_per_hour),` ج/ساعة`]})]})]}),P.notes&&(0,g.jsx)(`p`,{className:`text-xs text-green-600 border-t border-green-100 pt-2`,children:P.notes})]}),P&&F.length===0&&(0,g.jsx)(`div`,{className:`rounded-lg bg-amber-50 border border-amber-200 px-4 py-3 text-sm text-amber-700`,children:`لا توجد مواعيد محددة لهذا الملعب. يُرجى التواصل مع الإدارة.`})]})}),P&&F.length>0&&(0,g.jsxs)(j,{number:`٢`,label:`اختر اليوم والتاريخ`,children:[(0,g.jsx)(`div`,{className:`-mx-2`,children:(0,g.jsx)(X,{schedules:F,selectedDate:_.date_start,onDateSelect:q,lockedRanges:l})}),_.date_start&&(0,g.jsxs)(`p`,{className:`mt-3 text-sm font-semibold text-amber-700 flex items-center gap-1.5`,children:[(0,g.jsx)(f,{className:`w-4 h-4 shrink-0`}),` `,new Date(_.date_start+`T00:00:00`).toLocaleDateString(`ar-EG`,{weekday:`long`,year:`numeric`,month:`long`,day:`numeric`})]}),N.date_start&&(0,g.jsx)(`p`,{className:S,children:N.date_start})]}),_.date_start&&I&&(0,g.jsx)(j,{number:`٣`,label:`اختر الوقت`,children:(0,g.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:gap-6`,children:[(0,g.jsxs)(`div`,{className:`sm:flex-1`,children:[(0,g.jsxs)(`p`,{className:x,children:[`اختر وقت البداية `,(0,g.jsx)(`span`,{className:`text-red-500 ml-0.5`,children:`*`})]}),L.length===0?(0,g.jsx)(`div`,{className:`rounded-lg bg-amber-50 border border-amber-200 px-4 py-3 text-sm text-amber-700`,children:`لا توجد فترات زمنية متاحة لهذا اليوم.`}):L.every(e=>V(e.start))?(0,g.jsxs)(`div`,{className:`rounded-lg bg-gray-50 border border-gray-200 p-4 space-y-2`,children:[(0,g.jsx)(`p`,{className:`text-sm font-medium text-gray-700`,children:`جميع الفترات محجوزة في هذا اليوم.`}),(0,g.jsx)(`p`,{className:`text-xs text-gray-500`,children:`إذا كنت تريد الانضمام لقائمة الانتظار أو حجز تاريخ آخر، يُرجى اختيار يوم آخر أو التواصل مع الإدارة.`})]}):(0,g.jsxs)(g.Fragment,{children:[L.some(e=>H(e.start))&&(0,g.jsx)(`div`,{className:`mb-2 rounded-lg bg-amber-50 border border-amber-200 px-3 py-2 text-xs text-amber-700`,children:`الفترات المميزة بالأصفر قيد المراجعة — يمكنك حجزها وسيُضاف طلبك لقائمة الانتظار.`}),I?.is_24h?(0,g.jsx)(`div`,{className:`space-y-4`,children:[{label:`الصباح المبكر`,from:0,to:6},{label:`الصباح`,from:6,to:12},{label:`بعد الظهر`,from:12,to:18},{label:`المساء والليل`,from:18,to:24}].map(e=>{let t=L.filter(t=>{let n=parseInt(t.start.split(`:`)[0],10);return n>=e.from&&n<e.to&&!V(t.start)});return t.length===0?null:(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`p`,{className:`text-xs font-semibold text-gray-500 mb-1.5`,children:e.label}),(0,g.jsx)(`div`,{className:`grid gap-2 grid-cols-3`,children:t.map(e=>{let t=H(e.start),n=_.time_start===e.start;return(0,g.jsxs)(`button`,{type:`button`,onClick:()=>J(e.start),className:`rounded-xl border-2 px-2 text-sm font-medium text-center transition-all w-full h-[3.75rem] flex flex-col items-center justify-center overflow-hidden ${t?n?`border-amber-500 bg-amber-500 text-white shadow-md`:`border-amber-300 bg-amber-50 text-amber-700 hover:border-amber-500 hover:bg-amber-100`:n?`border-amber-500 bg-amber-500 text-white shadow-md`:`border-gray-200 bg-white text-gray-700 hover:border-amber-400 hover:bg-amber-50`}`,children:[(0,g.jsx)(`span`,{className:`block font-semibold`,children:D(e.start)}),t?(0,g.jsx)(`span`,{className:`block text-xs mt-0.5 text-amber-600`,children:`مؤقت`}):(0,g.jsx)(`span`,{className:`block text-xs mt-0.5 opacity-0`,"aria-hidden":`true`,children:`—`})]},e.start)})})]},e.label)})}):(0,g.jsx)(`div`,{className:`grid gap-2 grid-cols-3`,children:L.filter(e=>!V(e.start)).map(e=>{let t=H(e.start),n=_.time_start===e.start;return(0,g.jsxs)(`button`,{type:`button`,onClick:()=>J(e.start),className:`rounded-xl border-2 px-2 text-sm font-medium text-center transition-all w-full h-[3.75rem] flex flex-col items-center justify-center overflow-hidden ${t?n?`border-amber-500 bg-amber-500 text-white shadow-md`:`border-amber-300 bg-amber-50 text-amber-700 hover:border-amber-500 hover:bg-amber-100`:n?`border-amber-500 bg-amber-500 text-white shadow-md`:`border-gray-200 bg-white text-gray-700 hover:border-amber-400 hover:bg-amber-50`}`,children:[(0,g.jsx)(`span`,{className:`block font-semibold`,children:D(e.start)}),t?(0,g.jsx)(`span`,{className:`block text-xs mt-0.5 text-amber-600`,children:`مؤقت`}):(0,g.jsx)(`span`,{className:`block text-xs mt-0.5 opacity-0`,"aria-hidden":`true`,children:`—`})]},e.start)})})]}),N.time_start&&(0,g.jsx)(`p`,{className:S,children:N.time_start})]}),_.time_start&&(0,g.jsxs)(`div`,{className:`sm:flex-1`,children:[(0,g.jsxs)(`p`,{className:x,children:[`اختر وقت النهاية `,(0,g.jsx)(`span`,{className:`text-red-500 ml-0.5`,children:`*`})]}),U.length===0?(0,g.jsx)(`div`,{className:`rounded-lg bg-amber-50 border border-amber-200 px-4 py-3 text-sm text-amber-700`,children:`لا توجد خيارات متاحة من هذا الوقت.`}):(0,g.jsx)(`div`,{className:`grid gap-2 grid-cols-3`,children:U.map(e=>{let t=_.time_end===e.time,n=R(e.time)-R(_.time_start),r=n>=60?n%60==0?`${n/60} ساعة`:`${Math.floor(n/60)} س ${n%60} د`:`${n} د`;return(0,g.jsxs)(`button`,{type:`button`,onClick:()=>T(`time_end`,e.time),className:`rounded-xl border-2 px-2 text-sm font-medium text-center transition-all w-full h-[3.75rem] flex flex-col items-center justify-center overflow-hidden ${t?`border-amber-500 bg-amber-500 text-white shadow-md`:`border-gray-200 bg-white text-gray-700 hover:border-amber-400 hover:bg-amber-50`}`,children:[(0,g.jsx)(`span`,{className:`block font-semibold`,children:D(e.time)}),(0,g.jsx)(`span`,{className:`block text-xs mt-0.5 whitespace-nowrap ${t?`opacity-80`:`text-gray-400`}`,children:r})]},e.time)})}),N.time_end&&(0,g.jsx)(`p`,{className:S,children:N.time_end})]})]})}),_.time_end&&(0,g.jsx)(j,{number:`٤`,label:`بيانات الحجز`,children:(0,g.jsxs)(`div`,{className:`space-y-4`,children:[(0,g.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-4`,children:[(0,g.jsx)(C,{label:`الاسم`,error:N.name,required:!0,children:(0,g.jsx)(`input`,{type:`text`,className:v,value:_.name,onChange:e=>T(`name`,e.target.value)})}),(0,g.jsxs)(C,{label:`رقم الموبايل`,error:N.phone,required:!0,children:[(0,g.jsx)(`input`,{type:`text`,inputMode:`numeric`,maxLength:11,dir:`rtl`,placeholder:`01xxxxxxxxx`,className:v,value:_.phone,onChange:e=>T(`phone`,e.target.value.replace(/\D/g,``))}),(0,g.jsx)(`p`,{className:`mt-1 text-xs text-gray-400`,children:`11 رقماً بالضبط`})]}),(0,g.jsx)(O,{value:_.payment_method,onChange:e=>{T(t=>({...t,payment_method:e.target.value,instapay_sender_phone:``}))},error:N.payment_method,instapayEnabled:a}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`label`,{className:x,children:`سعر الساعة`}),(0,g.jsx)(`input`,{type:`text`,readOnly:!0,dir:`rtl`,value:P?.price_per_hour?`${Number(P.price_per_hour).toLocaleString(`ar-EG`)} جنيه`:`—`,className:y})]}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`label`,{className:x,children:`الإجمالي`}),(0,g.jsx)(`input`,{type:`text`,readOnly:!0,dir:`rtl`,value:G>0?`${Number(G).toLocaleString(`ar-EG`)} جنيه`:`—`,className:`${y} font-semibold text-gray-800`})]})]}),(0,g.jsx)(k,{show:_.payment_method===`online`&&!!a,whatsapp:u,senderPhone:_.instapay_sender_phone,onChange:e=>T(`instapay_sender_phone`,e),error:N.instapay_sender_phone}),(0,g.jsx)(C,{label:`ملاحظات`,error:N.notes,children:(0,g.jsx)(`textarea`,{className:v,rows:3,value:_.notes,onChange:e=>T(`notes`,e.target.value),placeholder:`أي طلبات خاصة…`})})]})}),_.time_end&&_.date_start&&P&&(0,g.jsxs)(`div`,{className:`rounded-xl bg-green-50 border border-green-200 p-4 space-y-2`,children:[(0,g.jsx)(`p`,{className:`text-sm font-semibold text-green-800 mb-2`,children:`ملخص الحجز`}),(0,g.jsx)(w,{label:`الملعب`,value:P.name}),(0,g.jsx)(w,{label:`التاريخ`,value:_.date_start}),(0,g.jsx)(w,{label:`الفترة`,value:`${D(_.time_start)} – ${D(_.time_end)}`}),(0,g.jsx)(w,{label:`المدة`,value:W>=60?W%60==0?`${W/60} ساعة`:`${Math.floor(W/60)} س ${W%60} د`:`${W} دقيقة`}),(0,g.jsx)(`p`,{className:`text-xs text-amber-600 pt-1`,children:`السعر النهائي يُحدده الإداري عند تأكيد الحجز.`})]}),_.time_end&&(0,g.jsx)(Q,{processing:M})]})}function ee({ticketPrice:t=0,instapayEnabled:r,cashEnabled:i=!0,instapayWhatsapp:a=``,lockedRanges:o=[]}){let{auth:c}=e().props,{data:l,setData:u,post:d,processing:f,errors:p}=n({date:``,persons_count:`1`,name:c.user?.name??``,phone:c.user?.phone??``,payment_method:`cash`,instapay_sender_phone:``,notes:``}),m=new Date().toISOString().split(`T`)[0];function h(e){return o.some(t=>e>=t.date_from&&e<=t.date_to)}let _=t>0&&l.persons_count?Number(l.persons_count)*t:0;function b(e){e.preventDefault(),d(route(`book.store`,{facility:`entry`}))}return(0,g.jsxs)(`form`,{onSubmit:b,className:`space-y-5`,children:[(0,g.jsxs)(`div`,{className:`rounded-xl border border-amber-100 bg-amber-50 p-4 space-y-1 text-sm`,children:[(0,g.jsxs)(`p`,{className:`font-semibold text-amber-800 flex items-center gap-2`,children:[(0,g.jsx)(s,{className:`w-4 h-4`}),` تذكرة دخول النادي`]}),(0,g.jsx)(`p`,{className:`text-amber-700`,children:`تصدر التذكرة فوراً بعد إرسال الطلب. يمكن عرضها رقمياً عند البوابة.`}),t>0&&(0,g.jsxs)(`p`,{className:`text-amber-700`,children:[`سعر التذكرة: `,(0,g.jsxs)(`strong`,{children:[E(t),` جنيه / شخص`]})]})]}),(0,g.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,g.jsxs)(C,{label:`تاريخ الزيارة`,error:p.date,required:!0,children:[(0,g.jsx)(`input`,{type:`date`,className:`${v} ${l.date&&h(l.date)?`border-red-400`:``}`,value:l.date,min:m,onChange:e=>u(`date`,e.target.value)}),l.date&&h(l.date)&&(0,g.jsx)(`p`,{className:S,children:`هذا التاريخ غير متاح بسبب إغلاق مؤقت.`})]}),(0,g.jsx)(C,{label:`عدد الأشخاص`,error:p.persons_count,required:!0,children:(0,g.jsx)(`input`,{type:`number`,min:`1`,max:`500`,className:v,value:l.persons_count,onChange:e=>u(`persons_count`,e.target.value)})}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`label`,{className:x,children:`سعر التذكرة / شخص`}),(0,g.jsx)(`input`,{type:`text`,readOnly:!0,dir:`rtl`,value:t?`${Number(t).toLocaleString(`ar-EG`)} جنيه`:`—`,className:y})]}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`label`,{className:x,children:`الإجمالي`}),(0,g.jsx)(`input`,{type:`text`,readOnly:!0,dir:`rtl`,value:_>0?`${Number(_).toLocaleString(`ar-EG`)} جنيه`:`—`,className:`${y} font-semibold text-gray-800`})]}),(0,g.jsx)(C,{label:`الاسم`,error:p.name,required:!0,children:(0,g.jsx)(`input`,{type:`text`,className:v,value:l.name,onChange:e=>u(`name`,e.target.value)})}),(0,g.jsxs)(C,{label:`رقم الموبايل`,error:p.phone,required:!0,children:[(0,g.jsx)(`input`,{type:`text`,inputMode:`numeric`,maxLength:11,dir:`rtl`,placeholder:`01xxxxxxxxx`,className:v,value:l.phone,onChange:e=>u(`phone`,e.target.value.replace(/\D/g,``))}),(0,g.jsx)(`p`,{className:`mt-1 text-xs text-gray-400`,children:`11 رقماً بالضبط`})]}),(0,g.jsx)(O,{value:l.payment_method,onChange:e=>{u(t=>({...t,payment_method:e.target.value,instapay_sender_phone:``}))},error:p.payment_method,instapayEnabled:r,cashEnabled:i})]}),(0,g.jsx)(k,{show:l.payment_method===`online`&&!!r,whatsapp:a,senderPhone:l.instapay_sender_phone,onChange:e=>u(`instapay_sender_phone`,e),error:p.instapay_sender_phone}),(0,g.jsx)(C,{label:`ملاحظات`,error:p.notes,children:(0,g.jsx)(`textarea`,{className:v,rows:2,value:l.notes,onChange:e=>u(`notes`,e.target.value),placeholder:`أي تفاصيل أو طلبات إضافية…`})}),(0,g.jsx)(Q,{processing:f,label:`إصدار التذكرة`})]})}function Q({processing:e,disabled:t,label:n=`إرسال طلب الحجز`}){return(0,g.jsxs)(`div`,{className:`flex items-center justify-between pt-2 border-t border-gray-100`,children:[(0,g.jsx)(a,{href:route(`services`),className:`text-sm text-gray-500 hover:text-amber-700 transition-colors`,children:`← العودة للخدمات`}),(0,g.jsx)(`button`,{type:`submit`,disabled:e||t,className:`inline-flex items-center gap-2 rounded-lg bg-amber-700 px-6 py-2.5 text-sm font-semibold text-white hover:bg-amber-800 disabled:opacity-60 transition-colors`,children:e?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`svg`,{className:`h-4 w-4 animate-spin`,fill:`none`,viewBox:`0 0 24 24`,children:[(0,g.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,g.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8v8H4z`})]}),`جارٍ الإرسال…`]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`svg`,{className:`h-4 w-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,g.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z`})}),n]})})]})}function $({facility:e,facilityName:t,pricePerPerson:n,poolMaxCapacity:i,availableVisitorTypes:a,poolSchedules:o,poolBookings:s,poolPhotos:c,chalets:l,chaletPricePerNight:u=0,meals:d,halls:f,buildings:p,courts:v,sportsSchedules:y,sportsBookings:b,sportsPhotos:x,selectedId:S,instapayEnabled:C,cashEnabled:w=!0,instapayWhatsapp:T=``,ticketPrice:E=0,lockedRanges:D}){let O=_[e]??null,[k,j]=(0,h.useState)(S?String(S):``),M=(0,h.useMemo)(()=>{if(k&&v?.length){let e=v.find(e=>String(e.id)===k);if(e?.photos?.length)return e.photos}return x??[]},[k,v,x]),N=(0,h.useMemo)(()=>{if(k&&v?.length){let e=v.find(e=>String(e.id)===k);if(e)return e.name}return`حجز الملاعب الرياضية`},[k,v]);return(0,g.jsxs)(m,{children:[(0,g.jsx)(r,{title:`حجز — ${t}`}),e===`pool`&&(0,g.jsx)(A,{photos:c??[],title:`حجز حمام السباحة`,subtitle:`اختر التاريخ والفئة والوقت المناسب لك`,pricePerPerson:n??0,capacity:i??0}),e===`sports_court`&&M.length>0&&(0,g.jsx)(A,{photos:M,title:N,subtitle:`اختر التاريخ والوقت المناسب لك`}),e!==`pool`&&e!==`sports_court`&&e!==`entry`&&(0,g.jsxs)(`div`,{className:`max-w-3xl mx-auto px-4 sm:px-6 pt-8 pb-2`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-3 mb-1`,children:[O?(0,g.jsx)(O,{className:`w-8 h-8 text-gray-700`}):(0,g.jsx)(`span`,{className:`text-3xl`,children:`📋`}),(0,g.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900`,children:t})]}),(0,g.jsx)(`p`,{className:`text-sm text-gray-500 mr-12`,children:`أملأ النموذج أدناه وسيتم مراجعة طلبك من قِبَل الإداري خلال 24 ساعة.`})]}),(0,g.jsx)(`div`,{id:`booking-form-start`,className:`max-w-7xl mx-auto px-4 sm:px-6 py-8`,children:(0,g.jsxs)(`div`,{className:`bg-white rounded-3xl border border-gray-100 shadow-md p-6 sm:p-8`,children:[e===`pool`&&(0,g.jsx)(q,{pricePerPerson:n,poolMaxCapacity:i,availableVisitorTypes:a,poolSchedules:o,poolBookings:s,instapayEnabled:C,cashEnabled:w,lockedRanges:D??[],instapayWhatsapp:T}),e===`chalet`&&(0,g.jsx)(Y,{chaletPricePerNight:u,meals:d??[],instapayEnabled:C,cashEnabled:w,instapayWhatsapp:T}),e===`sports_court`&&(0,g.jsx)(Z,{courts:v??[],sportsSchedules:y??[],sportsBookings:b??[],instapayEnabled:C,cashEnabled:w,selectedId:S,onCourtChange:j,lockedRanges:D??[],instapayWhatsapp:T}),e===`entry`&&(0,g.jsx)(ee,{ticketPrice:E,instapayEnabled:C,cashEnabled:w,instapayWhatsapp:T,lockedRanges:D??[]})]})})]})}export{$ as default};