1"use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[5095],{6089:(e,s,a)=>{a.d(s,{F:()=>g});var t=a(65043),i=a(13390),r=a(65598),n=a(5949),l=a(91140),o=a(82054),c=a(37719),d=a(85692),m=a(87978),p=a(50516),h=a(56328),u=a(70579);const x="https://balkandestination.com",g=({isOpen:e,onClose:s,tourId:a,tourType:g="offline",onPricesUpdated:j})=>{var _,v,b,y,f;const[N,w]=(0,t.useState)(!1),[C,k]=(0,t.useState)(!1),[A,S]=(0,t.useState)(null),[J,P]=(0,t.useState)(null),[$,T]=(0,t.useState)(!1),[R,F]=(0,t.useState)([]),D=e=>new Intl.NumberFormat("en-EU",{style:"currency",currency:"EUR"}).format(e||0),I=()=>{S(null),P(null),T(!1),s()};return(0,u.jsx)(r.lG,{open:e,onOpenChange:I,children:(0,u.jsxs)(r.Cf,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[(0,u.jsx)(r.c7,{children:(0,u.jsxs)(r.L3,{className:"flex items-center gap-2",children:[(0,u.jsx)(p.A,{className:"h-5 w-5 text-blue-600"}),"Automated Price Update"]})}),(0,u.jsxs)("div",{className:"py-4 space-y-4",children:[(0,u.jsx)("div",{className:"p-4 bg-blue-50 rounded-lg border border-blue-200",children:(0,u.jsx)("p",{className:"text-sm text-blue-800",children:"This tool will automatically update tour prices based on the latest approved supplier prices. It will recalculate all pricing tiers while maintaining your profit margins and risk percentages."})}),!A&&!J&&(0,u.jsxs)("div",{className:"text-center py-8",children:[(0,u.jsx)(p.A,{className:"h-12 w-12 mx-auto mb-4 text-gray-400 "+(C?"animate-spin":"")}),(0,u.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Analyze Price Changes"}),(0,u.jsx)("p",{className:"text-muted-foreground mb-4",children:"Click below to check for supplier price updates"}),(0,u.jsxs)("div",{className:"flex justify-center gap-2",children:[(0,u.jsx)(i.$,{onClick:async()=>{k(!0),S(null),P(null);try{const e=localStorage.getItem("token"),s=await fetch(`${x}/api/admin/price-updates/analyze/${g}/${a}`,{method:"POST",headers:{Authorization:`Bearer ${e}`}});if(s.ok){const e=await s.json();S(e.analysis)}else{const e=await s.json();h.oR.error(e.detail||"Failed to analyze prices")}}catch(e){console.error("Error analyzing prices:",e),h.oR.error("Failed to analyze prices")}finally{k(!1)}},disabled:C,children:C?"Analyzing...":"Analyze Prices"}),(0,u.jsxs)(i.$,{variant:"outline",onClick:async()=>{try{const e=localStorage.getItem("token"),s=await fetch(`${x}/api/admin/price-updates/history/${g}/${a}?limit=10`,{headers:{Authorization:`Bearer ${e}`}});if(s.ok){const e=await s.json();F(e.history),T(!0)}}catch(e){console.error("Error loading history:",e)}},children:[(0,u.jsx)(m.A,{className:"h-4 w-4 mr-2"}),"View History"]})]})]}),A&&!J&&(0,u.jsxs)("div",{className:"space-y-4",children:[(0,u.jsxs)("div",{className:"grid grid-cols-4 gap-3",children:[(0,u.jsx)(l.Zp,{children:(0,u.jsxs)(l.Wu,{className:"p-3 text-center",children:[(0,u.jsx)("div",{className:"text-2xl font-bold",children:A.total_components}),(0,u.jsx)("div",{className:"text-xs text-muted-foreground",children:"Total Components"})]})}),(0,u.jsx)(l.Zp,{children:(0,u.jsxs)(l.Wu,{className:"p-3 text-center",children:[(0,u.jsx)("div",{className:"text-2xl font-bold text-green-600",children:(null===(_=A.price_changes)||void 0===_?void 0:_.length)||0}),(0,u.jsx)("div",{className:"text-xs text-muted-foreground",children:"Price Changes"})]})}),(0,u.jsx)(l.Zp,{children:(0,u.jsxs)(l.Wu,{className:"p-3 text-center",children:[(0,u.jsx)("div",{className:"text-2xl font-bold text-amber-600",children:(null===(v=A.missing_suppliers)||void 0===v?void 0:v.length)||0}),(0,u.jsx)("div",{className:"text-xs text-muted-foreground",children:"Missing Suppliers"})]})}),(0,u.jsx)(l.Zp,{children:(0,u.jsxs)(l.Wu,{className:"p-3 text-center",children:[(0,u.jsx)("div",{className:"text-2xl font-bold text-gray-500",children:(null===(b=A.unchanged)||void 0===b?void 0:b.length)||0}),(0,u.jsx)("div",{className:"text-xs text-muted-foreground",children:"Unchanged"})]})})]}),A.price_changes&&A.price_changes.length>0&&(0,u.jsxs)("div",{children:[(0,u.jsxs)("h4",{className:"font-semibold mb-2 flex items-center gap-2",children:[(0,u.jsx)(o.A,{className:"h-4 w-4 text-green-600"}),"Price Changes to Apply (",A.price_changes.length,")"]}),(0,u.jsx)("div",{className:"space-y-2 max-h-48 overflow-y-auto",children:A.price_changes.map((e,s)=>{var a,t;return(0,u.jsx)("div",{className:"p-3 bg-green-50 rounded-lg border border-green-200",children:(0,u.jsxs)("div",{className:"flex justify-between items-start",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)(n.E,{variant:"outline",className:"mb-1",children:e.type}),(0,u.jsx)("div",{className:"font-medium",children:e.name}),(0,u.jsxs)("div",{className:"text-xs text-muted-foreground",children:["Supplier: ",(null===(a=e.supplier_info)||void 0===a?void 0:a.supplier_name)||"Unknown"]})]}),(0,u.jsx)("div",{className:"text-right",children:null===(t=e.changes)||void 0===t?void 0:t.map((e,s)=>(0,u.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,u.jsx)("span",{className:"text-red-600 line-through",children:D(e.old_price)}),(0,u.jsx)(d.A,{className:"h-3 w-3"}),(0,u.jsx)("span",{className:"text-green-600 font-semibold",children:D(e.new_price)})]},s))})]})},s)})})]}),A.missing_suppliers&&A.missing_suppliers.length>0&&(0,u.jsxs)("div",{children:[(0,u.jsxs)("h4",{className:"font-semibold mb-2 flex items-center gap-2 text-amber-700",children:[(0,u.jsx)(c.A,{className:"h-4 w-4"}),"Missing Supplier Links (",A.missing_suppliers.length,")"]}),(0,u.jsxs)("div",{className:"p-3 bg-amber-50 rounded-lg border border-amber-200",children:[(0,u.jsx)("p",{className:"text-sm text-amber-800 mb-2",children:"The following components don't have linked suppliers. Their prices must be updated manually:"}),(0,u.jsx)("ul",{className:"text-sm space-y-1",children:A.missing_suppliers.map((e,s)=>(0,u.jsxs)("li",{className:"flex items-center gap-2",children:[(0,u.jsx)("span",{className:"text-amber-600",children:"\u2022"}),(0,u.jsx)(n.E,{variant:"outline",className:"text-xs",children:e.type}),(0,u.jsx)("span",{children:e.name})]},s))})]})]}),(!A.price_changes||0===A.price_changes.length)&&(!A.missing_suppliers||0===A.missing_suppliers.length)&&(0,u.jsxs)("div",{className:"text-center py-6 text-green-700",children:[(0,u.jsx)(o.A,{className:"h-12 w-12 mx-auto mb-2"}),(0,u.jsx)("h4",{className:"font-semibold",children:"All Prices Up to Date!"}),(0,u.jsx)("p",{className:"text-sm text-muted-foreground",children:"No supplier price changes were found."})]})]}),J&&(0,u.jsxs)("div",{className:"space-y-4",children:[(0,u.jsxs)("div",{className:"text-center py-4",children:[(0,u.jsx)(o.A,{className:"h-12 w-12 mx-auto mb-2 text-green-600"}),(0,u.jsx)("h4",{className:"font-semibold text-lg",children:"Prices Updated Successfully!"}),(0,u.jsxs)("p",{className:"text-muted-foreground",children:[(null===(y=J.changes_applied)||void 0===y?void 0:y.length)||0," price(s) were updated"]})]}),J.changes_applied&&J.changes_applied.length>0&&(0,u.jsxs)("div",{className:"p-4 bg-green-50 rounded-lg",children:[(0,u.jsx)("h5",{className:"font-medium mb-2",children:"Changes Applied:"}),(0,u.jsx)("div",{className:"space-y-1 text-sm max-h-40 overflow-y-auto",children:J.changes_applied.map((e,s)=>(0,u.jsxs)("div",{className:"flex justify-between",children:[(0,u.jsxs)("span",{children:[e.component_name,"
1(",e.field,")"]}),(0,u.jsxs)("span",{children:[D(e.old_price)," \u2192 ",D(e.new_price)]})]},s))})]}),J.warnings&&J.warnings.length>0&&(0,u.jsxs)("div",{className:"p-4 bg-amber-50 rounded-lg",children:[(0,u.jsx)("h5",{className:"font-medium mb-2 text-amber-700",children:"Warnings:"}),(0,u.jsx)("ul",{className:"text-sm space-y-1",children:J.warnings.map((e,s)=>(0,u.jsx)("li",{className:"text-amber-700",children:e},s))})]}),J.new_pricing_tiers&&J.new_pricing_tiers.length>0&&(0,u.jsxs)("div",{className:"p-4 bg-blue-50 rounded-lg",children:[(0,u.jsx)("h5",{className:"font-medium mb-2",children:"Updated Pricing Tiers:"}),(0,u.jsx)("div",{className:"grid grid-cols-4 gap-2 text-sm",children:J.new_pricing_tiers.map((e,s)=>(0,u.jsxs)("div",{className:"text-center p-2 bg-white rounded",children:[(0,u.jsxs)("div",{className:"font-bold",children:[e.number_of_pax," PAX"]}),(0,u.jsxs)("div",{children:[D(e.price_per_person_double),"/person"]})]},s))})]})]}),$&&(0,u.jsxs)("div",{className:"space-y-4",children:[(0,u.jsxs)("div",{className:"flex justify-between items-center",children:[(0,u.jsx)("h4",{className:"font-semibold",children:"Price Update History"}),(0,u.jsx)(i.$,{variant:"ghost",size:"sm",onClick:()=>T(!1),children:"Back"})]}),0===R.length?(0,u.jsx)("p",{className:"text-center text-muted-foreground py-4",children:"No price update history found."}):(0,u.jsx)("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:R.map((e,s)=>{var a,t;return(0,u.jsx)(l.Zp,{children:(0,u.jsx)(l.Wu,{className:"p-3",children:(0,u.jsxs)("div",{className:"flex justify-between items-start",children:[(0,u.jsxs)("div",{children:[(0,u.jsxs)("div",{className:"font-medium",children:[(null===(a=e.summary)||void 0===a?void 0:a.total_changes)||0," changes applied"]}),(0,u.jsxs)("div",{className:"text-xs text-muted-foreground",children:["By ",e.performed_by_name," on"," ",new Date(e.timestamp).toLocaleString("en-GB")]})]}),(0,u.jsxs)(n.E,{variant:"outline",children:[(null===(t=e.summary)||void 0===t?void 0:t.components_updated)||0," components"]})]})})},s)})})]})]}),(0,u.jsxs)(r.Es,{children:[A&&!J&&(null===(f=A.price_changes)||void 0===f?void 0:f.length)>0&&(0,u.jsx)(i.$,{onClick:async()=>{w(!0);try{const e=localStorage.getItem("token"),s=await fetch(`${x}/api/admin/price-updates/update/${g}/${a}`,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify({apply_all:!0})});if(s.ok){const e=await s.json();P(e),e.changes_applied&&e.changes_applied.length>0?(h.oR.success(`Updated ${e.changes_applied.length} prices successfully!`),j&&j(e)):h.oR.info("No price changes were needed.")}else{const e=await s.json();h.oR.error(e.detail||"Failed to update prices")}}catch(e){console.error("Error updating prices:",e),h.oR.error("Failed to update prices")}finally{w(!1)}},disabled:N,className:"bg-green-600 hover:bg-green-700",children:N?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(p.A,{className:"h-4 w-4 mr-2 animate-spin"}),"Updating..."]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(o.A,{className:"h-4 w-4 mr-2"}),"Apply ",A.price_changes.length," Updates"]})}),(0,u.jsx)(i.$,{variant:"outline",onClick:I,children:J?"Close":"Cancel"})]})]})})}},13416:(e,s,a)=>{a.d(s,{T:()=>n});var t=a(65043),i=a(99766),r=a(70579);const n=t.forwardRef(({className:e,...s},a)=>(0,r.jsx)("textarea",{className:(0,i.cn)("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:a,...s}));n.displayName="Textarea"},55095:(e,s,a)=>{a.r(s),a.d(s,{default:()=>I});var t=a(65043),i=a(18163),r=a(13390),n=a(91140),l=a(92264),o=a(20556),c=a(13416),d=a(84370),m=a(5949),p=a(65469),h=a(7727),u=a(22633),x=a(99996),g=a(9855),j=a(71360),_=a(87260),v=a(28006),b=a(37719),y=a(50516),f=a(78384),N=a(88693),w=a(56328),C=a(63478),k=a(7118),A=a(73062),S=a(70579);const J=({tier:e,tierIndex:s,durationDays:a,onUpdate:i})=>{const c=(0,t.useMemo)(()=>({accommodation_cost_per_night_shared:0,accommodation_cost_per_night_private:0,total_nights:a-1||1,arrival_transfer_cost:0,departure_transfer_cost:0,luggage_transport_per_day:0,gps_maps_cost:0,booking_service_fee:0,coordination_fee:0,emergency_supp
1ort_cost:0,additional_services:[],profit_margin_percentage:25,risk_cost_percentage:2,pax_tiers:[2,4,6,8]}),[a]),d=e.costs||c,p=(s,a)=>{const t={...d,[s]:a};i({...e,costs:t})},h=(e,s,a)=>{const t=[...d.additional_services||[]];t[e]={...t[e],[s]:a},p("additional_services",t)},u=(0,t.useMemo)(()=>{const e=d.total_nights||a-1||1,s=d.profit_margin_percentage||25,t=d.risk_cost_percentage||2;return d.pax_tiers.map(a=>{const i=((d.arrival_transfer_cost||0)+(d.departure_transfer_cost||0)+(d.luggage_transport_per_day||0)*e+(d.gps_maps_cost||0)+(d.booking_service_fee||0)+(d.coordination_fee||0)+(d.emergency_support_cost||0))/a,r=(d.accommodation_cost_per_night_shared||0)*e,n=(d.accommodation_cost_per_night_private||0)*e;let l=0,o=0;(d.additional_services||[]).forEach(e=>{e.is_fixed?o+=e.cost_per_person||0:l+=e.cost_per_person||0});const c=i+r+l+o/a,m=(c+c*(t/100))*(1+s/100),p=i+n+l+o/a,h=(p+p*(t/100))*(1+s/100),u=Math.max(0,h-m);return{pax:a,price_per_person_shared:Math.round(100*m)/100,price_per_person_private:Math.round(100*h)/100,single_supplement:Math.round(100*u)/100,cost_breakdown:{fixed_costs_pp:Math.round(100*i)/100,accommodation_shared_pp:Math.round(100*r)/100,accommodation_private_pp:Math.round(100*n)/100,additional_services_pp:Math.round(100*(l+o/a))/100,subtotal_shared:Math.round(100*c)/100,subtotal_private:Math.round(100*p)/100,profit_margin:s,risk_cost:t}}})},[d,a]),x=(0,t.useCallback)(s=>{if(s.length>0){const a=s[0];i({...e,price_per_person:a.price_per_person_shared,single_supplement:a.single_supplement,pax_pricing:s,costs:d})}},[e,d,i]);return(0,t.useEffect)(()=>{if(u.length>0){const s=u[0];e.price_per_person===s.price_per_person_shared&&e.single_supplement===s.single_supplement||x(u)}},[u,e.price_per_person,e.single_supplement,x]),(0,S.jsxs)("div",{className:"space-y-4 mt-4 border-t pt-4",children:[(0,S.jsxs)("div",{className:"flex items-center gap-2 text-lg font-semibold text-gray-800",children:[(0,S.jsx)(_.A,{className:"h-5 w-5 text-indigo-600"}),"Cost Calculator"]}),(0,S.jsx)("div",{className:"bg-white p-4 rounded-lg border",children:(0,S.jsxs)("div",{className:"grid grid-cols-3 gap-4",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Number of Nights"}),(0,S.jsx)(l.p,{type:"number",value:d.total_nights,onChange:e=>p("total_nights",parseInt(e.target.value)||1),min:"1"}),(0,S.jsxs)("p",{className:"text-xs text-gray-500 mt-1",children:["Usually ",a-1," for ",a,"-day tour"]})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Profit Margin (%)"}),(0,S.jsx)(l.p,{type:"number",value:d.profit_margin_percentage,onChange:e=>p("profit_margin_percentage",parseFloat(e.target.value)||0),min:"0",max:"100"})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Risk Cost (%)"}),(0,S.jsx)(l.p,{type:"number",value:d.risk_cost_percentage,onChange:e=>p("risk_cost_percentage",parseFloat(e.target.value)||0),min:"0",max:"20"})]})]})}),(0,S.jsxs)("div",{className:"bg-blue-50 p-4 rounded-lg border border-blue-200",children:[(0,S.jsx)(o.J,{className:"text-blue-800 font-semibold flex items-center gap-2",children:"\ud83c\udfe8 Accommodation Costs (per person per night)"}),(0,S.jsxs)("div",{className:"grid grid-cols-2 gap-4 mt-3",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-sm",children:"Shared Room (\u20ac/night)"}),(0,S.jsx)(l.p,{type:"number",value:d.accommodation_cost_per_night_shared,onChange:e=>p("accommodation_cost_per_night_shared",parseFloat(e.target.value)||0),min:"0",step:"0.01"}),(0,S.jsx)("p",{className:"text-xs text-gray-500",children:"Cost when sharing room (2-4 pax)"})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-sm",children:"Private Room (\u20ac/night)"}),(0,S.jsx)(l.p,{type:"number",value:d.accommodation_cost_per_night_private,onChange:e=>p("accommodation_cost_per_night_private",parseFloat(e.target.value)||0),min:"0",step:"0.01"}),(0,S.jsx)("p",{className:"text-xs text-gray-500",children:"Cost for single/private room"})]})]})]}),(0,S.jsxs)("div",{className:"bg-green-50 p-4 rounded-lg border border-green-200",children:[(0,S.jsx)(o.J,{className:"text-green-800 font-semibold flex items-center gap-2",children:"\ud83d\ude90 Transfer Costs (FIXED - shared among group)"}),(0,S.jsxs)("div",{className:"grid grid-cols-3 gap-4 mt-3",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-sm",children:"Arrival Transfer (\u20ac)"}),(0,S.jsx)(l.p,{type:"number",value:d.arrival_transfer_cost,onChange:e=>p("arrival_transfer_cost",parseFloat(e.target.value)||0),min:"0",step:"0.01"})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-sm",children:"Departure Transfer (\u20ac)"}),(0,S.jsx)(l.p,{type:"number",value:d.departure_transfer_cost,onChange:e=>p("departure_transfer_cost",parseFloat(e.target.value)||0),min:"0",step:"0.01"})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-sm",children:"Luggage Transport/day (\u20ac)"}),(0,S.jsx)(l.p,{type:"number",value:d.luggage_transport_per_day,onChange:e=>p("luggage_transport_per_day",parseFloat(e.target.value)||0),min:"0",step:"0.01"})]})]})]}),(0,S.jsxs)("div",{className:"bg-purple-50 p-4 rounded-lg border border-purple-200",children:[(0,S.jsx)(o.J,{className:"text-purple-800 font-semibold flex items-center gap-2",children:"\u2699\ufe0f Operational Costs (FIXED - shared among group)"}),(0,S.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mt-3",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-sm",children:"GPS/Maps (\u20ac)"}),(0,S.jsx)(l.p,{type:"number",value:d.gps_maps_cost,onChange:e=>p("gps_maps_cost",parseFloat(e.target.value)||0),min:"0",step:"0.01"})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-sm",children:"Booking Service (\u20ac)"}),(0,S.jsx)(l.p,{type:"number",value:d.booking_service_fee,onChange:e=>p("booking_service_fee",parseFloat(e.target.value)||0),min:"0",step:"0.01"})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-sm",children:"Coordination (\u20ac)"}),(0,S.jsx)(l.p,{type:"number",value:d.coordination_fee,onChange:e=>p("coordination_fee",parseFloat(e.target.value)||0),min:"0",step:"0.01"})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-sm",children:"Emergency Support (\u20ac)"}
1),(0,S.jsx)(l.p,{type:"number",value:d.emergency_support_cost,onChange:e=>p("emergency_support_cost",parseFloat(e.target.value)||0),min:"0",step:"0.01"})]})]})]}),(0,S.jsxs)("div",{className:"bg-orange-50 p-4 rounded-lg border border-orange-200",children:[(0,S.jsxs)("div",{className:"flex justify-between items-center mb-3",children:[(0,S.jsx)(o.J,{className:"text-orange-800 font-semibold flex items-center gap-2",children:"\u2795 Additional Services"}),(0,S.jsxs)(r.$,{type:"button",variant:"outline",size:"sm",onClick:()=>{const e=d.additional_services||[];p("additional_services",[...e,{name:"",cost_per_person:0,is_fixed:!1}])},children:[(0,S.jsx)(j.A,{className:"h-4 w-4 mr-1"}),"Add Service"]})]}),(d.additional_services||[]).map((e,s)=>(0,S.jsxs)("div",{className:"flex gap-3 items-center mb-2 bg-white p-2 rounded",children:[(0,S.jsx)(l.p,{value:e.name,onChange:e=>h(s,"name",e.target.value),placeholder:"Service name",className:"flex-1"}),(0,S.jsx)(l.p,{type:"number",value:e.cost_per_person,onChange:e=>h(s,"cost_per_person",parseFloat(e.target.value)||0),placeholder:"Cost \u20ac",className:"w-24",min:"0",step:"0.01"}),(0,S.jsxs)("label",{className:"flex items-center gap-1 text-sm whitespace-nowrap",children:[(0,S.jsx)("input",{type:"checkbox",checked:e.is_fixed,onChange:e=>h(s,"is_fixed",e.target.checked)}),"Fixed"]}),(0,S.jsx)(r.$,{type:"button",variant:"ghost",size:"sm",onClick:()=>(e=>{const s=(d.additional_services||[]).filter((s,a)=>a!==e);p("additional_services",s)})(s),className:"text-red-600",children:(0,S.jsx)(g.A,{className:"h-4 w-4"})})]},s)),(0,S.jsx)("p",{className:"text-xs text-gray-600 mt-2",children:'"Fixed" costs are shared among group. Non-fixed costs are per person.'})]}),(0,S.jsxs)("div",{className:"bg-gray-50 p-4 rounded-lg border",children:[(0,S.jsxs)("div",{className:"flex justify-between items-center mb-3",children:[(0,S.jsxs)(o.J,{className:"font-semibold flex items-center gap-2",children:[(0,S.jsx)(k.A,{className:"h-4 w-4"}),"Group Size Tiers"]}),(0,S.jsxs)(r.$,{type:"button",variant:"outline",size:"sm",onClick:()=>{const e=Math.max(...d.pax_tiers)+2;p("pax_tiers",[...d.pax_tiers,e].sort((e,s)=>e-s))},children:[(0,S.jsx)(j.A,{className:"h-4 w-4 mr-1"}),"Add Size"]})]}),(0,S.jsx)("div",{className:"flex flex-wrap gap-2",children:d.pax_tiers.map((e,s)=>(0,S.jsxs)("div",{className:"flex items-center gap-1 bg-white rounded border px-2 py-1",children:[(0,S.jsx)(l.p,{type:"number",value:e,onChange:e=>((e,s)=>{const a=[...d.pax_tiers];a[e]=parseInt(s)||2,p("pax_tiers",a.sort((e,s)=>e-s))})(s,e.target.value),className:"w-16 h-8 text-center",min:"1"}),(0,S.jsx)("span",{className:"text-sm text-gray-500",children:"pax"}),d.pax_tiers.length>1&&(0,S.jsx)(r.$,{type:"button",variant:"ghost",size:"sm",onClick:()=>(e=>{if(d.pax_tiers.length<=1)return;const s=d.pax_tiers.filter((s,a)=>a!==e);p("pax_tiers",s)})(s),className:"h-6 w-6 p-0 text-red-500",children:"\xd7"})]},s))})]}),(0,S.jsxs)(n.Zp,{className:"border-2 border-indigo-300 bg-gradient-to-r from-indigo-50 to-purple-50",children:[(0,S.jsx)(n.aR,{className:"pb-2",children:(0,S.jsxs)(n.ZB,{className:"text-lg flex items-center gap-2",children:[(0,S.jsx)(A.A,{className:"h-5 w-5 text-indigo-600"}),"Calculated Prices by Group Size"]})}),(0,S.jsx)(n.Wu,{children:(0,S.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:u.map((e,s)=>(0,S.jsxs)("div",{className:"bg-white p-3 rounded-lg border shadow-sm",children:[(0,S.jsx)("div",{className:"text-center mb-2",children:(0,S.jsxs)(m.E,{variant:"secondary",className:"text-lg font-bold",children:[e.pax," PAX"]})}),(0,S.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,S.jsxs)("div",{className:"flex justify-between",children:[(0,S.jsx)("span",{className:"text-gray-600",children:"Shared:"}),(0,S.jsxs)("span",{className:"font-bold text-green-600",children:["\u20ac",e.price_per_person_shared]})]}),(0,S.jsxs)("div",{className:"flex justify-between",children:[(0,S.jsx)("span",{className:"text-gray-600",children:"Private:"}),(0,S.jsxs)("span",{className:"font-bold text-blue-600",children:["\u20ac",e.price_per_person_private]})]}),(0,S.jsxs)("div",{className:"flex justify-between border-t pt-1 mt-1",children:[(0,S.jsx)("span",{className:"text-gray-600",children:"Supplement:"}),(0,S.jsxs)("span",{className:"font-semibold text-orange-600",children:["+\u20ac",e.single_supplement]}
1)]})]}),(0,S.jsxs)("details",{className:"mt-2",children:[(0,S.jsx)("summary",{className:"text-xs text-indigo-600 cursor-pointer",children:"Cost breakdown"}),(0,S.jsxs)("div",{className:"text-xs mt-1 space-y-0.5 text-gray-600",children:[(0,S.jsxs)("div",{children:["Fixed: \u20ac",e.cost_breakdown.fixed_costs_pp]}),(0,S.jsxs)("div",{children:["Acc (shared): \u20ac",e.cost_breakdown.accommodation_shared_pp]}),(0,S.jsxs)("div",{children:["Services: \u20ac",e.cost_breakdown.additional_services_pp]})]})]})]},s))})})]})]})};var P=a(28646),$=a(82054);const T=({departures:e=[],onUpdate:s})=>{const[a,i]=(0,t.useState)({start_date:"",end_date:"",tier_type:"standard",min_participants:2,max_participants:12,current_bookings:0,price_per_person:0,single_supplement:0,status:"open",notes:"",guide_name:"",guide_language:"English",meeting_point:"",meeting_time:""}),p=(a,t,i)=>{const r=[...e];r[a]={...r[a],[t]:i},s(r)},h=e=>{switch(e){case"open":return"bg-green-100 text-green-800 border-green-200";case"almost_full":return"bg-yellow-100 text-yellow-800 border-yellow-200";case"full":return"bg-red-100 text-red-800 border-red-200";case"cancelled":return"bg-gray-100 text-gray-800 border-gray-200";case"completed":return"bg-blue-100 text-blue-800 border-blue-200";default:return"bg-gray-100 text-gray-800"}},u=e=>{switch(e){case"basic":return"bg-blue-100 text-blue-700";case"standard":return"bg-yellow-100 text-yellow-700";case"premium":return"bg-purple-100 text-purple-700";default:return"bg-gray-100 text-gray-700"}};return(0,S.jsxs)(n.Zp,{className:"border-2 border-emerald-200",children:[(0,S.jsxs)(n.aR,{className:"bg-emerald-50",children:[(0,S.jsxs)(n.ZB,{className:"flex items-center gap-2 text-emerald-900",children:[(0,S.jsx)(P.A,{className:"h-5 w-5"}),"Group Departures (Scheduled Dates)"]}),(0,S.jsx)("p",{className:"text-sm text-gray-600 mt-1",children:"Set specific departure dates with guaranteed departures for group bookings"})]}),(0,S.jsxs)(n.Wu,{className:"space-y-6 pt-6",children:[e.length>0&&(0,S.jsxs)("div",{className:"space-y-4",children:[(0,S.jsxs)(o.J,{className:"font-semibold",children:["Scheduled Departures (",e.length,")"]}),e.map((a,t)=>{var i,x;return(0,S.jsx)(n.Zp,{className:`border-2 ${h(a.status)}`,children:(0,S.jsxs)(n.Wu,{className:"p-4",children:[(0,S.jsxs)("div",{className:"flex justify-between items-start mb-3",children:[(0,S.jsxs)("div",{className:"flex items-center gap-2",children:[(0,S.jsx)(m.E,{className:u(a.tier_type),children:null===(i=a.tier_type)||void 0===i?void 0:i.toUpperCase()}),(0,S.jsxs)(m.E,{variant:"outline",className:h(a.status),children:["open"===a.status&&(0,S.jsx)($.A,{className:"h-3 w-3 mr-1"}),null===(x=a.status)||void 0===x?void 0:x.replace("_"," ").toUpperCase()]})]}),(0,S.jsx)(r.$,{type:"button",variant:"ghost",size:"sm",onClick:()=>(a=>{window.confirm("Are you sure you want to remove this departure?")&&s(e.filter((e,s)=>s!==a))})(t),className:"text-red-600 hover:text-red-700",children:(0,S.jsx)(g.A,{className:"h-4 w-4"})})]}),(0,S.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-3",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-xs",children:"Start Date"}),(0,S.jsx)(l.p,{type:"date",value:a.start_date,onChange:e=>p(t,"start_date",e.target.value)})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-xs",children:"End Date"}),(0,S.jsx)(l.p,{type:"date",value:a.end_date,onChange:e=>p(t,"end_date",e.target.value)})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-xs",children:"Price/Person (\u20ac)"}),(0,S.jsx)(l.p,{type:"number",value:a.price_per_person,onChange:e=>p(t,"price_per_person",parseFloat(e.target.value)||0),min:"0"})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-xs",children:"Single Supplement (\u20ac)"}),(0,S.jsx)(l.p,{type:"number",value:a.single_supplement,onChange:e=>p(t,"single_supplement",parseFloat(e.target.value)||0),min:"0"})]})]}),(0,S.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-3",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-xs",children:"Min Participants"}),(0,S.jsx)(l.p,{type:"number",value:a.min_participants,onChange:e=>p(t,"min_participants",parseInt(e.target.value)||2),min:"1"})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-xs",children:"Max Participants"}),(0,S.jsx)(l.p,{type:"number",value:a.max_participants,onChange:e=>p(t,"max_participants",parseInt(e.target.value)||12),min:"1"})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-xs",children:"Current Bookings"}),(0,S.jsx)(l.p,{type:"number",value:a.current_bookings,onChange:e=>p(t,"current_bookings",parseInt(e.target.value)||0),min:"0"})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-xs",children:"Status"}),(0,S.jsxs)(d.l6,{value:a.status,onValueChange:e=>p(t,"status",e),children:[(0,S.jsx)(d.bq,{children:(0,S.jsx)(d.yv,{})}),(0,S.jsxs)(d.gC,{children:[(0,S.jsx)(d.eb,{value:"open",children:"Open for Booking"}),(0,S.jsx)(d.eb,{value:"almost_full",children:"Almost Full"}),(0,S.jsx)(d.eb,{value:"full",children:"Full"}),(0,S.jsx)(d.eb,{value:"cancelled",children:"Cancelled"}),(0,S.jsx)(d.eb,{value:"completed",children:"Completed"})]})]})]})]}),(0,S.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-3",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-xs",children:"Guide Name"}),(0,S.jsx)(l.p,{value:a.guide_name||"",onChange:e=>p(t,"guide_name",e.target.value),placeholder:"Guide name"})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-xs",children:"Guide Language"}),(0,S.jsx)(l.p,{value:a.guide_language||"English",onChange:e=>p(t,"guide_language",e.target.value),placeholder:"English, German, etc."})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-xs",children:"Meeting Point"}),(0,S.jsx)(l.p,{value:a.meeting_point||"",onChange:e=>p(t,"meeting_point",e.target.value),placeholder:"Hotel lobby, airport, etc."})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-xs",children:"Meeting Time"}),(0,S.jsx)(l.p,{type:"time",value:a.meeting_time||"",onChange:e=>p(t,"meeting_time",e.target.value)})]})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-xs",children:"Notes (internal)"}),(0,S.jsx)(c.T,{value:a.notes||"",onChange:e=>p(t,"notes",e.target.value),placeholder:"Internal notes about this departure...",rows:2})]}),(0,S.jsxs)("div",{className:"mt-3 flex items-center gap-2",children:[(0,S.jsx)(k.A,{className:"h-4 w-4 text-gray-500"}),(0,S.jsx)("div",{className:"flex-1 bg-gray-200 rounded-full h-2 overflow-hidden",children:(0,S.jsx)("div",{className:"h-full "+(a.current_bookings>=a.max_participants?"bg-red-500":a.current_bookings>=.8*a.max_participants?"bg-yellow-500":"bg-green-500"),style:{width:`${Math.min(a.current_bookings/a.max_participants*100,100)}%`}})}),(0,S.jsxs)("span",{className:"text-sm text-gray-600",children:[a.current_bookings,"/",a.max_participants," booked"]})]})]})},a.id||t)})]}),(0,S.jsxs)(n.Zp,{className:"border-dashed border-2 border-emerald-300 bg-emerald-50/50",children:[(0,S.jsx)(n.aR,{className:"pb-3",children:(0,S.jsxs)(n.ZB,{className:"text-base flex items-center gap-2",children:[(0,S.jsx)(j.A,{className:"h-4 w-4"}),"Add New Departure"]})}),(0,S.jsxs)(n.Wu,{className:"space-y-4",children:[(0,S.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Start Date *"}),(0,S.jsx)(l.p,{type:"date",value:a.start_date,onChange:e=>i(s=>({...s,start_date:e.target.value}))})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"End Date"}),(0,S.jsx)(l.p,{type:"date",value:a.end_date,onChange:e=>i(s=>({...s,end_date:e.target.value}))})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Tier Type"}),(0,S.jsxs)(d.l6,{value:a.tier_type,onValueChange:e=>i(s=>({...s,tier_type:e})),children:[(0,S.jsx)(d.bq,{children:(0,S.jsx)(d.yv,{})}),(0,S.jsxs)(d.gC,{children:[(0,S.jsx)(d.eb,{value:"basic",children:"Basic"}),(0,S.jsx)(d.eb,{value:"standard",children:"Standard"}),(0,S.jsx)(d.eb,{value:"premium",children:"Premium"})]})]})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Price/Person (\u20ac)"}),(0,S.jsx)(l.p,{type:"number",value:a.price_per_person,onChange:e=>i(s=>({...s,price_per_person:parseFloat(e.target.value)||0})),min:"0"})]})]}),(0,S.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Single Supplement (\u20ac)"}),(0,S.jsx)(l.p,{type:"number",value:a.single_supplement,onChange:e=>i(s=>({...s,single_supplement:parseFloat(e.target.value)||0})),min:"0"})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Min Participants"}),(0,S.jsx)(l.p,{type:"number",value:a.min_participants,onChange:e=>i(s=>({...s,min_participants:parseInt(e.target.value)||2})),min:"1"})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Max Participants"}),(0,S.jsx)(l.p,{type:"number",value:a.max_participants,onChange:e=>i(s=>({...s,max_participants:parseInt(e.target.value)||12})),min:"1"})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Meeting Point"}),(0,S.jsx)(l.p,{value:a.meeting_point,onChange:e=>i(s=>({...s,meeting_point:e.target.value})),placeholder:"e.g., Pristina Airport"})]})]}),(0,S.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Guide Name"}),(0,S.jsx)(l.p,{value:a.guide_name,onChange:e=>i(s=>({...s,guide_name:e.target.value})),placeholder:"Assigned guide"})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Meeting Time"}),(0,S.jsx)(l.p,{type:"time",value:a.meeting_time,onChange:e=>i(s=>({...s,meeting_time:e.target.value}))})]})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Notes"}),(0,S.jsx)(c.T,{value:a.notes,onChange:e=>i(s=>({...s,notes:e.target.value})),placeholder:"Any special notes for this departure...",rows:2})]}),(0,S.jsxs)(r.$,{type:"button",onClick:()=>{a.start_date?(s([...e,{...a,id:`dep_${Date.now()}`,created_at:(new Date).toISOString()}]),i({start_date:"",end_date:"",tier_type:"standard",min_participants:2,max_participants:12,current_bookings:0,price_per_person:0,single_supplement:0,status:"open",notes:"",guide_name:"",guide_language:"English",meeting_point:"",meeting_time:""})):alert("Please select a start date")},className:"w-full bg-emerald-600 hover:bg-emerald-700",children:[(0,S.jsx)(j.A,{className:"h-4 w-4 mr-2"}),"Add Departure Date"]})]})]}),0===e.length&&(0,S.jsxs)("div",{className:"text-center py-6 text-gray-500",children:[(0,S.jsx)(P.A,{className:"h-12 w-12 mx-auto mb-3 text-gray-300"}),(0,S.jsx)("p",{children:"No scheduled departures yet"}),(0,S.jsx)("p",{className:"text-sm",children:"Add departure dates for group bookings"})]})]})]})};var R=a(6089),F=a(15236);const D="https://balkandestination.com";function I(){var e,s;const a=(0,i.Zp)(),{tourId:k}=(0,i.g)(),A=!!k,[P,$]=(0,t.useState)(A),[I,E]=(0,t.useState)(!1),[M,z]=(0,t.useState)(!1),[B,W]=(0,t.useState)(!1),[U,Z]=(0,t.useState)(!1),[O,G]=(0,t.useState)(null),[L,q]=(0,t.useState)({title:"",description:"",price_per_person:0,duration_days:3,total_distance_km:0,difficulty:"moderate",language:"English",is_multi_day:!0,tour_type:"self_guided_hiking",countries:[],cross_border_info:"",best_season:"",equipment_needed:[],daily_itinerary:[],pricing_tiers:[{tier_name:"Basic",tier_type:"basic",price_per_person:50,single_supplement:0,group_discount_threshold:6,group_discount_percentage:0,booking_advance_days:0,deposit_percentage:100,includes_accommodation:!1,includes_transfer:!1,whats_included:["Detailed GPS route and waypoints","Digital maps for each day","Route planning assistance","Emergency contact information"],whats_not_included:["Accommodation","Meals and drinks","Transportation/transfers","Travel insurance","Personal expenses"]},{tier_name:"Standard",tier_type:"standard",price_per_person:350,single_supplement:80,group_discount_threshold:6,group_discount_percentage:10,booking_advance_days:30,deposit_percentage:30,includes_accommodation:!0,includes_transfer:!0,accommodation_type:"Shared accommodation in traditional guesthouses/lodges (2-5 persons per room)",transfer_details:"One private group transfer: Airport \u2192 Starting point",whats_included:["Everything in Basic","Shared accommodation (all nights)","One arrival transfer (Airport \u2192 Starting point)","Accommodation booking & confirmation","Local host coordination"],whats_not_included:["Meals and drinks","Travel insurance","Personal expenses","Additional transfers","Private room upgrade"]},{tier_name:"Premium",tier_type:"premium",price_per_person:490,single_supplement:100,group_discount_threshold:6,group_discount_percentage:15,booking_advance_days:30,deposit_percentage:30,includes_accommodation:!0,includes_transfer:!0,accommodation_type:"Upgraded lodges and guesthouses with better amenities",transfer_details:"One private group transfer: Airport \u2192 Starting point",whats_included:["Everything in Standard","Upgraded accommodation","Priority booking & support","Luggage transport between stops (optional)","24/7 emergency supp
1ort","Detailed cultural & local information"],whats_not_included:["Meals and drinks","Travel insurance","Personal expenses","Additional transfers beyond included"]}],whats_included:["Detailed GPS route and waypoints","Digital maps for each day","Accommodation coordinates and contacts","Cross-border information and requirements"],whats_not_included:["Accommodation costs (pay locally)","Meals and drinks","Travel insurance","Transportation to/from trailheads","Border crossing fees or visas","Everything else that is not mentioned in the 'Includes' section"],highlights:[],suitable_for:"",not_suitable_for:"",weather_considerations:"",altitude_warnings:"",dangerous_sections:"",local_customs:"",park_regulations:"",language_tips:"",emergency_contacts:[],baggage_transfer_available:!1,baggage_transfer_info:"",public_transport_info:"",parking_info:"",published:!1,published_online:!1,status:"draft",cover_image_url:"",group_departures:[],enable_cost_calculation:!1,seasonal_booking_enabled:!1,season_start_month:5,season_start_day:20,season_end_month:10,season_end_day:10,seasonal_message:"",cancellation_policy:""}),[V,H]=(0,t.useState)(""),[K,X]=(0,t.useState)(""),[Y,Q]=(0,t.useState)(""),[ee,se]=(0,t.useState)({country:"",service:"",number:""});(0,t.useEffect)(()=>{A&&ae()},[k]);const ae=async()=>{try{const e=localStorage.getItem("token"),s=await fetch(`${D}/api/admin/hiking-tours/${k}`,{headers:{Authorization:`Bearer ${e}`}});if(s.ok){const e=await s.json();q(s=>({...s,...e,countries:e.countries||[],equipment_needed:e.equipment_needed||[],daily_itinerary:(e.daily_itinerary||[]).map(e=>({...e,waypoints:e.waypoints||[],accommodation_options:e.accommodation_options||[]})),images:e.images||[],pricing_tiers:(e.pricing_tiers||s.pricing_tiers||[]).map(e=>({...e,whats_included:e.whats_included||[],whats_not_included:e.whats_not_included||[],costs:e.costs||null,pax_pricing:e.pax_pricing||[]})),whats_included:e.whats_included||s.whats_included,whats_not_included:e.whats_not_included||s.whats_not_included,group_departures:e.group_departures||[],enable_cost_calculation:e.enable_cost_calculation||!1}))}else w.oR.error("Failed to fetch tour"),a("/admin/multi-day-hiking-tours")}catch(e){console.error("Error fetching tour:",e),w.oR.error("Error loading tour")}finally{$(!1)}},te=async(e=!1)=>{if(L.title&&L.description)if(0!==L.daily_itinerary.length){E(!0);try{const s=localStorage.getItem("token"),t=A?`${D}/api/admin/hiking-tours/${k}`:`${D}/api/admin/hiking-tours`,i=await fetch(t,{method:A?"PUT":"POST",headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json"},body:JSON.stringify({...L,published:e,is_multi_day:!0,tour_type:"multi_day_hiking"})});if(i.ok)w.oR.success(`Tour ${e?"published":"saved"} successfully`),a("/admin/multi-day-hiking-tours");else{const e=await i.json();w.oR.error(e.detail||"Failed to save tour")}}catch(s){console.error("Error saving tour:",s),w.oR.error("Error saving tour")}finally{E(!1)}}else w.oR.error("Please add at least one day to the itinerary");else w.oR.error("Please fill in all required fields")},ie=(e,s,a)=>{q(t=>({...t,daily_itinerary:(t.daily_itinerary||[]).map((t,i)=>i===e?{...t,[s]:a}:t)}))},re=(e,s,a)=>{q(t=>({...t,daily_itinerary:(t.daily_itinerary||[]).map((t,i)=>i===e?{...t,accommodation:{...t.accommodation||{},[s]:a}}:t)}))},ne=()=>{V.trim()&&!(L.countries||[]).includes(V.trim())&&(q(e=>({...e,countries:[...e.countries||[],V.trim()]})),H(""))},le=()=>{K.trim()&&!L.equipment_needed.includes(K.trim())&&(q(e=>({...e,equipment_needed:[...e.equipment_needed,K.trim()]})),X(""))},oe=()=>{Y.trim()&&(q(e=>({...e,highlights:[...e.highlights||[],Y.trim()]})),Q(""))},ce=(e,s,a,t)=>{q(i=>({...i,daily_itinerary:(i.daily_itinerary||[]).map((i,r)=>r===e?{...i,waypoints:(i.waypoints||[]).map((e,i)=>i===s?{...e,[a]:t}:e)}:i)}))},de=(e,s,a,t)=>{q(i=>({...i,daily_itinerary:(i.daily_itinerary||[]).map((i,r)=>r===e?{...i,accommodation_options:(i.accommodation_options||[]).map((e,i)=>i===s?{...e,[a]:t}:e)}:i)}))};return P?(0,S.jsx)(C.U,{children:(0,S.jsx)("div",{className:"container mx-auto px-4 py-8",children:(0,S.jsx)("p",{children:"Loading..."})})}):(0,S.jsxs)(C.U,{children:[(0,S.jsxs)("div",{className:"container mx-auto px-4 py-8 max-w-5xl",children:[(0,S.jsxs)(r.$,{variant:"ghost",onClick:()=>a("/admin/multi-day-hiking-tours"),className:"mb-4",children:[(0,S.jsx)(p.A,{className:"h-4 w-4 mr-2"}),"Back to Tours"]}),(0,S.jsx)("div",{className:"flex justify-between items-center mb-6",children:(0,S.jsxs)("h1",{className:"text-3xl font-bold flex items-center gap-2",children:[(0,S.jsx)(h.A,{className:"h-8 w-8 text-emerald-600"}),A?"Edit":"Create"," Multi-Day Hiking Tour"]})}),(0,S.jsxs)("div",{className:"space-y-6",children:[(0,S.jsxs)(n.Zp,{children:[(0,S.jsx)(n.aR,{children:(0,S.jsx)(n.ZB,{children:"Basic Information"})}),(0,S.jsxs)(n.Wu,{className:"space-y-4",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{htmlFor:"title",children:"Tour Title *"}),(0,S.jsx)(l.p,{id:"title",value:L.title,onChange:e=>q(s=>({...s,title:e.target.value})),placeholder:"e.g., Peaks of the Balkans - 7 Day Hiking Tour"})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{htmlFor:"description",children:"Description *"}),(0,S.jsx)(c.T,{id:"description",value:L.description,onChange:e=>q(s=>({...s,description:e.target.value})),placeholder:"Detailed tour overview (2-3 paragraphs, SEO-optimized)",rows:6})]}),(0,S.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{htmlFor:"duration_days",children:"Duration (Days) *"}),(0,S.jsx)(l.p,{id:"duration_days",type:"number",value:L.duration_days,onChange:e=>q(s=>({...s,duration_days:parseInt(e.target.value)})),min:"1"})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{htmlFor:"total_distance_km",children:"Total Distance (km)"}),(0,S.jsx)(l.p,{id:"total_distance_km",type:"number",value:L.total_distance_km,onCh
1ange:e=>q(s=>({...s,total_distance_km:parseFloat(e.target.value)})),min:"0",step:"0.1"})]})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{htmlFor:"difficulty",children:"Difficulty Level"}),(0,S.jsxs)(d.l6,{value:L.difficulty,onValueChange:e=>q(s=>({...s,difficulty:e})),children:[(0,S.jsx)(d.bq,{children:(0,S.jsx)(d.yv,{})}),(0,S.jsxs)(d.gC,{children:[(0,S.jsx)(d.eb,{value:"easy",children:"Easy"}),(0,S.jsx)(d.eb,{value:"moderate",children:"Moderate"}),(0,S.jsx)(d.eb,{value:"challenging",children:"Challenging"}),(0,S.jsx)(d.eb,{value:"difficult",children:"Difficult"}),(0,S.jsx)(d.eb,{value:"expert",children:"Expert"})]})]})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{htmlFor:"best_season",children:"Best Season"}),(0,S.jsx)(l.p,{id:"best_season",value:L.best_season,onChange:e=>q(s=>({...s,best_season:e.target.value})),placeholder:"e.g., June to September"})]}),(0,S.jsxs)("div",{className:"border rounded-lg p-4 bg-amber-50 border-amber-200",children:[(0,S.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,S.jsx)("input",{type:"checkbox",id:"seasonal_booking_enabled",checked:L.seasonal_booking_enabled||!1,onChange:e=>q(s=>({...s,seasonal_booking_enabled:e.target.checked})),className:"h-4 w-4"}),(0,S.jsx)(o.J,{htmlFor:"seasonal_booking_enabled",className:"font-semibold text-amber-800",children:"\ud83d\uddd3\ufe0f Enable Seasonal Booking Window (for FIT bookings)"})]}),(0,S.jsx)("p",{className:"text-sm text-amber-700 mb-3",children:"Set the dates when this tour can be carried out. Customers can make reservations anytime, but tour dates must fall within this window."}),L.seasonal_booking_enabled&&(0,S.jsxs)("div",{className:"space-y-4",children:[(0,S.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-sm font-medium",children:"Season Start Date"}),(0,S.jsxs)("div",{className:"flex gap-2 mt-1",children:[(0,S.jsxs)(d.l6,{value:String(L.season_start_month||5),onValueChange:e=>q(s=>({...s,season_start_month:parseInt(e)})),children:[(0,S.jsx)(d.bq,{className:"w-32",children:(0,S.jsx)(d.yv,{placeholder:"Month"})}),(0,S.jsxs)(d.gC,{children:[(0,S.jsx)(d.eb,{value:"1",children:"January"}),(0,S.jsx)(d.eb,{value:"2",children:"February"}),(0,S.jsx)(d.eb,{value:"3",children:"March"}),(0,S.jsx)(d.eb,{value:"4",children:"April"}),(0,S.jsx)(d.eb,{value:"5",children:"May"}),(0,S.jsx)(d.eb,{value:"6",children:"June"}),(0,S.jsx)(d.eb,{value:"7",children:"July"}),(0,S.jsx)(d.eb,{value:"8",children:"August"}),(0,S.jsx)(d.eb,{value:"9",children:"September"}),(0,S.jsx)(d.eb,{value:"10",children:"October"}),(0,S.jsx)(d.eb,{value:"11",children:"November"}),(0,S.jsx)(d.eb,{value:"12",children:"December"})]})]}),(0,S.jsx)(l.p,{type:"number",min:"1",max:"31",value:L.season_start_day||1,onChange:e=>q(s=>({...s,season_start_day:parseInt(e.target.value)||1})),className:"w-20",placeholder:"Day"})]})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-sm font-medium",children:"Season End Date"}),(0,S.jsxs)("div",{className:"flex gap-2 mt-1",children:[(0,S.jsxs)(d.l6,{value:String(L.season_end_month||10),onValueChange:e=>q(s=>({...s,season_end_month:parseInt(e)})),children:[(0,S.jsx)(d.bq,{className:"w-32",children:(0,S.jsx)(d.yv,{placeholder:"Month"})}),(0,S.jsxs)(d.gC,{children:[(0,S.jsx)(d.eb,{value:"1",children:"January"}),(0,S.jsx)(d.eb,{value:"2",children:"February"}),(0,S.jsx)(d.eb,{value:"3",children:"March"}),(0,S.jsx)(d.eb,{value:"4",children:"April"}),(0,S.jsx)(d.eb,{value:"5",children:"May"}),(0,S.jsx)(d.eb,{value:"6",children:"June"}),(0,S.jsx)(d.eb,{value:"7",children:"July"}),(0,S.jsx)(d.eb,{value:"8",children:"August"}),(0,S.jsx)(d.eb,{value:"9",children:"September"}),(0,S.jsx)(d.eb,{value:"10",children:"October"}),(0,S.jsx)(d.eb,{value:"11",children:"November"}),(0,S.jsx)(d.eb,{value:"12",children:"December"})]})]}),(0,S.jsx)(l.p,{type:"number",min:"1",max:"31",value:L.season_end_day||31,onChange:e=>q(s=>({...s,season_end_day:parseInt(e.target.value)||31})),className:"w-20",placeholder:"Day"})]})]})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{htmlFor:"seasonal_message",children:"Custom Message for Customers"}),(0,S.jsx)(c.T,{id:"seasonal_message",value:L.seasonal_message||"",onChange:e=>q(s=>({...s,seasonal_message:e.target.value})),placeholder:"e.g., Due to weather conditions, this hiking tour can only be carried out between May 20th and October 10th. Outside these dates, trails may be dangerous or inaccessible.",rows:2,className:"mt-1"})]}),(0,S.jsx)("div",{className:"bg-white p-3 rounded border border-amber-300",children:(0,S.jsxs)("p",{className:"text-sm font-medium text-amber-800",children:["\ud83d\udcc5 Tour available: ",["January","February","March","April","May","June","July","August","September","October","November","December"][L.season_start_month-1]," ",L.season_start_day," - ",["January","February","March","April","May","June","July","August","September","October","November","December"][L.season_end_month-1]," ",L.season_end_day]})})]})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{htmlFor:"tour_images",children:"Tour Images (Multiple allowed)"}),(0,S.jsx)("p",{className:"text-sm text-gray-600 mb-2",children:"Upload multiple images for slideshow display. Use arrows to reorder - first image is the cover."}),L.images&&L.images.length>0&&(0,S.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:(L.images||[]).map((e,s)=>(0,S.jsxs)("div",{className:"relative group",children:[(0,S.jsx)("img",{src:e,alt:`Tour image ${s+1}`,className:"w-full h-32 object-cover rounded-lg border-2 "+(0===s?"border-blue-500":"border-gray-200")}),(0,S.jsxs)("div",{className:"absolute top-2 left-2 flex gap-1 opacity-0 group-hover:opacity-100 transition",children:[(0,S.jsx)(r.$,{type:"button",variant:"secondary",size:"icon",className:"h-7 w-7 bg-white/90",disabled:0===s,onClick:()=>{const e=[...L.images];[e[s-1],e[s]]=[e[s],e[s-1]],q(s=>({...s,images:e,cover_image_url:e[0]}))},children:(0,S.jsx)(u.A,{className:"h-4 w-4"})}),(0,S.jsx)(r.$,{type:"button",variant:"secondary",size:"icon",className:"h-7 w-7 bg-white/90",disabled:s===L.images.length-1,onClick:()=>{const e=[...L.images];[e[s],e[s+1]]=[e[s+1],e[s]],q(s=>({...s,images:e,cover_image_url:e[0]}))},children:(0,S.jsx)(x.A,{className:"h-4 w-4"})})]}),(0,S.jsx)(r.$,{type:"button",variant:"destructive",size:"sm",className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition",onClick:()=>{return e=s,q(s=>({...s,images:s.images.filter((s,a)=>a!==e)})),void w.oR.success("Image removed");var e},children:(0,S.jsx)(g.A,{className:"h-4 w-4"})}),0===s&&(0,S.jsx)(m.E,{className:"absolute bottom-2 left-2 bg-blue-600",children:"Cover"}),(0,S.jsx)(m.E,{variant:"secondary",className:"absolute bottom-2 right-2",children:s+1})]},s))}),(0,S.jsxs)("div",{children:[(0,S.jsx)(l.p,{id:"tour_images",type:"file",accept:"image/*",multiple:!0,onChange:async e=>{const s=e.target.files;if(!s||0===s.length)return;z(!0);const a=localStorage.getItem("token"),t=[];try{for(let e=0;e<s.length;e++){const i=s[e];if(!i.type.startsWith("image/")){w.oR.error(`${i.name} is not an image file`);continue}if(i.size>5242880){w.oR.error(`${i.name} is too large (max 5MB)`);continue}const r=new FormData;r.append("file",i);const n=await fetch(`${D}/api/upload/cloudinary/tours`,{method:"POST",headers:{Authorization:`Bearer ${a}`},body:r});if(n.ok){const e=await n.json();t.push(e.url)}else w.oR.error(`Failed to upload ${i.name}`)}t.length>0&&(q(e=>({...e,images:[...e.images||[],...t],cover_image_url:e.cover_image_url||t[0]})),w.oR.success(`${t.length} image(s) uploaded successfully`))}catch(i){console.error("Error uploading images:",i),w.oR.error("Failed to upload images")}finally{z(!1),e.target.value=""}},disabled:M,className:"mb-2"}),(0,S.jsx)("p",{className:"text-xs text-gray-500",children:M?"Uploading...":"Select multiple images (max 5MB each). First image will be cover."})]})]})]})]}),(0,S.jsxs)(n.Zp,{className:"border-2 border-indigo-200",children:[(0,S.jsxs)(n.aR,{className:"bg-indigo-50",children:[(0,S.jsx)(n.ZB,{className:"flex items-center gap-2 text-indigo-900",children:"\ud83d\udcb0 Pricing Tiers (Basic / Standard / Premium)"}),(0,S.jsx)("p",{className:"text-sm text-gray-600 mt-2",children:"Configure three pricing tiers with different service levels. Basic = GPS only, Standard = +Accommodation+Transfer, Premium = Enhanced services"})]}),(0,S.jsx)(n.Wu,{className:"space-y-6 pt-6",children:(L.pricing_tiers||[]).map((e,s)=>(0,S.jsxs)(n.Zp,{className:"border-2 "+("basic"===e.tier_type?"border-blue-200 bg-blue-50":"standard"===e.tier_type?"border-yellow-200 bg-yellow-50":"border-red-200 bg-red-50"),children:[(0,S.jsx)(n.aR,{children:(0,S.jsxs)(n.ZB,{className:"text-lg",children:["basic"===e.tier_type?"\ud83d\udfe6":"standard"===e.tier_type?"\ud83d\udfe8":"\ud83d\udfe5"," ",e.tier_name," Tier"]})}),(0,S.jsxs)(n.Wu,{className:"space-y-4",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Tier Display Name"}),(0,S.jsx)(l.p,{value:e.tier_name,onChange:e=>{const a=[...L.pricing_tiers];a[s].tier_name=e.target.value,q(e=>({...e,pricing_tiers:a}))},placeholder:"e.g., Basic, Standard, Premium"})]}),(0,S.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Price per Person (\u20ac)"}),(0,S.jsx)(l.p,{type:"number",value:e.price_per_person,onChange:e=>{const a=[...L.pricing_tiers];a[s].price_per_person=parseFloat(e.target.value)||0,q(e=>({...e,pricing_tiers:a}))},min:"0",step:"0.01"})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Single Supplement (\u20ac)"}),(0,S.jsx)(l.p,{type:"number",value:e.single_supplement,onChange:e=>{const a=[...L.pricing_tiers];a[s].single_supplement=parseFloat(e.target.value)||0,q(e=>({...e,pricing_tiers:a}))},min:"0",step:"0.01"})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Group Discount (%)"}),(0,S.jsx)(l.p,{type:"number",value:e.group_discount_percentage,onChange:e=>{const a=[...L.pricing_tiers];a[s].group_discount_percentage=parseFloat(e.target.value)||0,q(e=>({...e,pricing_tiers:a}))},min:"0",max:"50"}),(0,S.jsxs)("p",{className:"text-xs text-gray-500 mt-1",children:["For ",e.group_discount_threshold,"+ people"]})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Full Payment Deadline (days before arrival)"}),(0,S.jsx)(l.p,{type:"number",value:e.booking_advance_days,onChange:e=>{const a=[...L.pricing_tiers];a[s].booking_advance_days=parseInt(e.target.value)||0,q(e=>({...e,pricing_tiers:a}))},min:"0"}),(0,S.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:0===e.booking_advance_days?"Full payment required at booking":`Within ${e.booking_advance_days} days: Full payment required. Before ${e.booking_advance_days} days: ${e.deposit_percentage}% deposit now, ${100-e.deposit_percentage}% due ${e.booking_advance_days} days before arrival`})]})]}),(0,S.jsxs)("div",{className:"bg-white p-3 rounded border",children:[(0,S.jsx)(o.J,{children:"Payment Terms"}),(0,S.jsxs)("div",{className:"grid grid-cols-2 gap-4 mt-2",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-sm",children:"Deposit %"}),(0,S.jsx)(l.p,{type:"number",value:e.deposit_percentage,onChange:e=>{const a=[...L.pricing_tiers];a[s].deposit_percentage=parseInt(e.target.value)||0,q(e=>({...e,pricing_tiers:a}))},min:"0",max:"100"})]}),(0,S.jsx)("div",{className:"flex items-end",children:(0,S.jsxs)("p",{className:"text-sm text-gray-600",children:[e.deposit_percentage,"% at booking, ",100-e.deposit_percentage,"% before arrival"]})})]})]}),(0,S.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,S.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,S.jsx)("input",{type:"checkbox",id:`accommodation-${s}`,checked:e.includes_accommodation,onChange:e=>{const a=[...L.pricing_tiers];a[s].includes_accommodation=e.target.checked,q(e=>({...e,pricing_tiers:a}))},className:"w-4 h-4"}),(0,S.jsx)(o.J,{htmlFor:`accommodation-${s}`,children:"Includes Accommodation"})]}),(0,S.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,S.jsx)("input",{type:"checkbox",id:`transfer-${s}`,checked:e.includes_transfer,onChange:e=>{const a=[...L.pricing_tiers];a[s].includes_transfer=e.target.checked,q(e=>({...e,pricing_tiers:a}))},className:"w-4 h-4"}),(0,S.jsx)(o.J,{htmlFor:`transfer-${s}`,children:"Includes Transfer"})]})]}),e.includes_accommodation&&(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Accommodation Type Description"}),(0,S.jsx)(c.T,{value:e.accommodation_type||"",onChange:e=>{const a=[...L.pricing_tiers];a[s].accommodation_type=e.target.value,q(e=>({...e,pricing_tiers:a}))},placeholder:"e.g., Shared rooms in traditional guesthouses (2-5 persons)",rows:2})]}),e.includes_transfer&&(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Transfer Details"}),(0,S.jsx)(c.T,{value:e.transfer_details||"",onChange:e=>{const a=[...L.pricing_tiers];a[s].transfer_details=e.target.value,q(e=>({...e,pricing_tiers:a}))},placeholder:"e.g., One private group transfer: Airport \u2192 Starting point",rows:2})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"What's Included (for this tier)"}),(0,S.jsx)("p",{className:"text-xs text-gray-500 mb-2",children:"Use arrows to reorder - first items appear at top"}),(0,S.jsxs)("div",{className:"space-y-2 mt-2",children:[(e.whats_included||[]).map((a,t)=>(0,S.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,S.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,S.jsx)(r.$,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",disabled:0===t,onClick:()=>{const e=[...L.pricing_tiers],a=[...e[s].whats_included];[a[t-1],a[t]]=[a[t],a[t-1]],e[s].whats_included=a,q(s=>({...s,pricing_tiers:e}))},children:(0,S.jsx)(u.A,{className:"h-3 w-3"})}),(0,S.jsx)(r.$,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",disabled:t===(e.whats_included||[]).length-1,onClick:()=>{const e=[...L.pricing_tiers],a=[...e[s].whats_included];[a[t],a[t+1]]=[a[t+1],a[t]],e[s].whats_included=a,q(s=>({...s,pricing_tiers:e}))},children:(0,S.jsx)(x.A,{className:"h-3 w-3"})})]}),(0,S.jsx)(l.p,{value:a,onChange:e=>{const a=[...L.pricing_tiers];a[s].whats_included[t]=e.target.value,q(e=>({...e,pricing_tiers:a}))},placeholder:"Included item",className:"flex-1"}),(0,S.jsx)(r.$,{type:"button",variant:"destructive",size:"icon",onClick:()=>{const e=[...L.pricing_tiers];e[s].whats_included.splice(t,1),q(s=>({...s,pricing_tiers:e}))},children:(0,S.jsx)(g.A,{className:"h-4 w-4"})})]},t)),(0,S.jsxs)(r.$,{type:"button",variant:"outline",size:"sm",onClick:()=>{const e=[...L.pricing_tiers];e[s].whats_included.push(""),q(s=>({...s,pricing_tiers:e}))},children:[(0,S.jsx)(j.A,{className:"h-4 w-4 mr-2"}),"Add Included Item"]})]})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"What's NOT Included (for this tier)"}),(0,S.jsx)("p",{className:"text-xs text-gray-500 mb-2",children:"Use arrows to reorder - first items appear at top"}),(0,S.jsxs)("div",{className:"space-y-2 mt-2",children:[(e.whats_not_included||[]).map((a,t)=>(0,S.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,S.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,S.jsx)(r.$,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",disabled:0===t,onClick:()=>{const e=[...L.pricing_tiers],a=[...e[s].whats_not_included];[a[t-1],a[t]]=[a[t],a[t-1]],e[s].whats_not_included=a,q(s=>({...s,pricing_tiers:e}))},children:(0,S.jsx)(u.A,{className:"h-3 w-3"})}),(0,S.jsx)(r.$,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",disabled:t===(e.whats_not_included||[]).length-1,onClick:()=>{const e=[...L.pricing_tiers],a=[...e[s].whats_not_included];[a[t],a[t+1]]=[a[t+1],a[t]],e[s].whats_not_included=a,q(s=>({...s,pricing_tiers:e}))},children:(0,S.jsx)(x.A,{className:"h-3 w-3"})})]}),(0,S.jsx)(l.p,{value:a,onChange:e=>{const a=[...L.pricing_tiers];a[s].whats_not_included[t]=e.target.value,q(e=>({...e,pricing_tiers:a}))},placeholder:"Not included item",className:"flex-1"}),(0,S.jsx)(r.$,{type:"button",variant:"destructive",size:"icon",onClick:()=>{const e=[...L.pricing_tiers];e[s].whats_not_included.splice(t,1),q(s=>({...s,pricing_tiers:e}))},children:(0,S.jsx)(g.A,{className:"h-4 w-4"})})]},t)),(0,S.jsxs)(r.$,{type:"button",variant:"outline",size:"sm",onClick:()=>{const e=[...L.pricing_tiers];e[s].whats_not_included.push(""),q(s=>({...s,pricing_
1tiers:e}))},children:[(0,S.jsx)(j.A,{className:"h-4 w-4 mr-2"}),"Add Not Included Item"]})]})]}),("standard"===e.tier_type||"premium"===e.tier_type)&&(0,S.jsxs)("div",{className:"border-t pt-4 mt-4",children:[(0,S.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,S.jsxs)("div",{className:"flex items-center gap-2",children:[(0,S.jsx)(_.A,{className:"h-5 w-5 text-indigo-600"}),(0,S.jsx)(o.J,{className:"font-semibold",children:"Enable Cost Calculator"})]}),(0,S.jsx)("input",{type:"checkbox",checked:e.enable_cost_calculation||!1,onChange:e=>{const a=[...L.pricing_tiers];a[s].enable_cost_calculation=e.target.checked,q(e=>({...e,pricing_tiers:a}))},className:"w-5 h-5"})]}),e.enable_cost_calculation&&(0,S.jsx)(J,{tier:e,tierIndex:s,durationDays:L.duration_days,onUpdate:e=>{const a=[...L.pricing_tiers];a[s]=e,q(e=>({...e,pricing_tiers:a}))}})]})]})]},s))})]}),(0,S.jsx)(T,{departures:L.group_departures||[],onUpdate:e=>q(s=>({...s,group_departures:e}))}),(0,S.jsxs)(n.Zp,{children:[(0,S.jsx)(n.aR,{children:(0,S.jsx)(n.ZB,{children:"Countries Covered"})}),(0,S.jsxs)(n.Wu,{className:"space-y-4",children:[(0,S.jsxs)("div",{className:"flex gap-2",children:[(0,S.jsx)(l.p,{value:V,onChange:e=>H(e.target.value),placeholder:"Add country (e.g., Kosovo, Montenegro)",onKeyPress:e=>"Enter"===e.key&&(e.preventDefault(),ne())}),(0,S.jsx)(r.$,{onClick:ne,type:"button",children:(0,S.jsx)(j.A,{className:"h-4 w-4"})})]}),(0,S.jsx)("div",{className:"flex flex-wrap gap-2",children:(L.countries||[]).map((e,s)=>(0,S.jsxs)(m.E,{variant:"secondary",className:"flex items-center gap-1",children:[(0,S.jsx)(v.A,{className:"h-3 w-3"}),e,(0,S.jsx)("button",{onClick:()=>(e=>{q(s=>({...s,countries:(s.countries||[]).filter(s=>s!==e)}))})(e),className:"ml-1 hover:text-red-600",children:"\xd7"})]},s))})]})]}),(0,S.jsxs)(n.Zp,{children:[(0,S.jsx)(n.aR,{children:(0,S.jsx)(n.ZB,{children:"Cross-Border Information"})}),(0,S.jsx)(n.Wu,{children:(0,S.jsx)(c.T,{value:L.cross_border_info,onChange:e=>q(s=>({...s,cross_border_info:e.target.value})),placeholder:"Important information about border crossings, visa requirements, permits, customs rules",rows:4})})]}),(0,S.jsxs)(n.Zp,{children:[(0,S.jsx)(n.aR,{children:(0,S.jsxs)("div",{className:"flex justify-between items-center",children:[(0,S.jsxs)(n.ZB,{children:["Daily Itinerary (",L.daily_itinerary.length," days)"]}),(0,S.jsxs)(r.$,{onClick:()=>{q(e=>({...e,daily_itinerary:[...e.daily_itinerary,{day_number:e.daily_itinerary.length+1,title:`Day ${e.daily_itinerary.length+1}`,description:"",start_location:"",end_location:"",distance_km:0,elevation_gain_m:0,elevation_loss_m:0,duration_hours:0,difficulty:"moderate",terrain_type:"mixed",waypoints:[],accommodation:{name:"",location:"",latitude:0,longitude:0,type:"Guest House",description:"",phone:"",email:"",website:"",booking_instructions:""},accommodation_options:[]}]}))},size:"sm",children:[(0,S.jsx)(j.A,{className:"h-4 w-4 mr-2"}),"Add Day"]})]})}),(0,S.jsx)(n.Wu,{className:"space-y-6",children:(L.daily_itinerary||[]).map((e,s)=>{var a,t,i,m,p,h,u,x;return(0,S.jsxs)(n.Zp,{className:"border-2",children:[(0,S.jsx)(n.aR,{className:"pb-3",children:(0,S.jsxs)("div",{className:"flex justify-between items-center",children:[(0,S.jsxs)(n.ZB,{className:"text-lg",children:["Day ",e.day_number]}),(0,S.jsx)(r.$,{variant:"ghost",size:"sm",onClick:()=>(e=>{q(s=>({...s,daily_itinerary:(s.daily_itinerary||[]).filter((s,a)=>a!==e).map((e,s)=>({...e,day_number:s+1}))}))})(s),className:"text-red-600 hover:text-red-700",children:(0,S.jsx)(g.A,{className:"h-4 w-4"})})]})}),(0,S.jsxs)(n.Wu,{className:"space-y-3",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Day Title"}),(0,S.jsx)(l.p,{value:e.title,onChange:e=>ie(s,"title",e.target.value),placeholder:"e.g., Day 1: Peja to Rugova Valley"})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Description"}),(0,S.jsx)(c.T,{value:e.description,onChange:e=>ie(s,"description",e.target.value),placeholder:"Detailed description of the day's hike",rows:3})]}),(0,S.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Start Location"}),(0,S.jsx)(l.p,{value:e.start_location,onChange:e=>ie(s,"start_location",e.target.value)})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"End Location"}),(0,S.jsx)(l.p,{value:e.end_location,onChange:e=>ie(s,"end_location",e.target.value)})]})]}),(0,S.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Distance (km)"}
1),(0,S.jsx)(l.p,{type:"number",value:e.distance_km,onChange:e=>ie(s,"distance_km",parseFloat(e.target.value)),step:"0.1"})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Elevation Gain (m)"}),(0,S.jsx)(l.p,{type:"number",value:e.elevation_gain_m,onChange:e=>ie(s,"elevation_gain_m",parseInt(e.target.value))})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Elevation Loss (m)"}),(0,S.jsx)(l.p,{type:"number",value:e.elevation_loss_m,onChange:e=>ie(s,"elevation_loss_m",parseInt(e.target.value))})]})]}),(0,S.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Duration (hours)"}),(0,S.jsx)(l.p,{type:"number",value:e.duration_hours,onChange:e=>ie(s,"duration_hours",parseFloat(e.target.value)),step:"0.5"})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Difficulty"}),(0,S.jsxs)(d.l6,{value:e.difficulty,onValueChange:e=>ie(s,"difficulty",e),children:[(0,S.jsx)(d.bq,{children:(0,S.jsx)(d.yv,{})}),(0,S.jsxs)(d.gC,{children:[(0,S.jsx)(d.eb,{value:"easy",children:"Easy"}),(0,S.jsx)(d.eb,{value:"moderate",children:"Moderate"}),(0,S.jsx)(d.eb,{value:"challenging",children:"Challenging"}),(0,S.jsx)(d.eb,{value:"difficult",children:"Difficult"})]})]})]})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{children:"Terrain Type"}),(0,S.jsxs)(d.l6,{value:e.terrain_type||"mixed",onValueChange:e=>ie(s,"terrain_type",e),children:[(0,S.jsx)(d.bq,{children:(0,S.jsx)(d.yv,{})}),(0,S.jsxs)(d.gC,{children:[(0,S.jsx)(d.eb,{value:"trail",children:"Trail"}),(0,S.jsx)(d.eb,{value:"rocky",children:"Rocky"}),(0,S.jsx)(d.eb,{value:"forest",children:"Forest"}),(0,S.jsx)(d.eb,{value:"alpine",children:"Alpine"}),(0,S.jsx)(d.eb,{value:"glacier",children:"Glacier"}),(0,S.jsx)(d.eb,{value:"mixed",children:"Mixed"})]})]})]}),(0,S.jsxs)("div",{className:"border-t pt-3 mt-3",children:[(0,S.jsxs)("div",{className:"flex justify-between items-center mb-2",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-sm font-semibold",children:"Trail Waypoints / GPS Points"}),(0,S.jsxs)("p",{className:"text-xs text-gray-500 mt-1",children:["Add GPS waypoints along the trail route. Hikers will follow these points from start to end.",(0,S.jsx)("br",{}),(0,S.jsx)("strong",{children:"Important:"})," Add waypoints in ORDER from start to finish. Include mountain passes, junctions, and key landmarks."]})]}),(0,S.jsxs)(r.$,{type:"button",size:"sm",variant:"outline",onClick:()=>{return e=s,void q(s=>({...s,daily_itinerary:(s.daily_itinerary||[]).map((s,a)=>a===e?{...s,waypoints:[...s.waypoints||[],{name:"",latitude:0,longitude:0,elevation_m:0,description:""}]}:s)}));var e},className:"ml-4",children:[(0,S.jsx)(j.A,{className:"h-4 w-4 mr-1"}),"Add Waypoint"]})]}),(!e.waypoints||0===e.waypoints.length)&&(0,S.jsxs)("div",{className:"bg-amber-50 border border-amber-200 p-3 rounded-lg text-sm text-amber-800",children:[(0,S.jsx)("strong",{children:"\u26a0\ufe0f No waypoints added yet!"}),(0,S.jsx)("br",{}),"For hiking safety, please add GPS waypoints along the trail:",(0,S.jsxs)("ul",{className:"list-disc ml-5 mt-1",children:[(0,S.jsx)("li",{children:"Start point (trailhead)"}),(0,S.jsx)("li",{children:"Key junctions and turns"}),(0,S.jsx)("li",{children:"Mountain passes"}),(0,S.jsx)("li",{children:"Water sources"}),(0,S.jsx)("li",{children:"End point (destination)"})]})]}),(e.waypoints||[]).map((a,t)=>{var i;return(0,S.jsxs)("div",{className:"p-3 bg-gray-50 rounded-lg mb-2 space-y-2 border border-gray-200",children:[(0,S.jsxs)("div",{className:"flex justify-between items-center",children:[(0,S.jsxs)("span",{className:"text-sm font-semibold text-blue-700",children:["\ud83d\udccd Waypoint ",t+1," ",0===t?"(Start)":t===((null===(i=e.waypoints)||void 0===i?void 0:i.length)||0)-1?"(End)":""]}),(0,S.jsx)(r.$,{type:"button",variant:"ghost",size:"sm",onClick:()=>{return e=s,a=t,void q(s=>({...s,daily_itinerary:(s.daily_itinerary||[]).map((s,t)=>t===e?{...s,waypoints:(s.waypoints||[]).filter((e,s)=>s!==a)}:s)}));var e,a},className:"text-red-600 hover:bg-red-50",children:(0,S.jsx)(g.A,{className:"h-4 w-4"})})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-xs text-gray-600",children:"Waypoint Name *"}),(0,S.jsx)(l.p,{value:a.name,onChange:e=>ce(s,t,"name",e.target.value),placeholder:"e.g., Valbona Pass (1,795m), River Crossing, Mountain Hut",className:"mt-1"})]}),(0,S.jsxs)("div",{className:"grid grid-cols-3 gap-2",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-xs text-gray-600",children:"Latitude * (e.g., 42.4500)"}),(0,S.jsx)(l.p,{type:"number",value:a.latitude||"",onChange:e=>ce(s,t,"latitude",parseFloat(e.target.value)||0),placeholder:"42.4500",step:"0.000001",className:"mt-1"})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-xs text-gray-600",children:"Longitude * (e.g., 19.8833)"}),(0,S.jsx)(l.p,{type:"number",value:a.longitude||"",onChange:e=>ce(s,t,"longitude",parseFloat(e.target.value)||0),placeholder:"19.8833",step:"0.000001",className:"mt-1"})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-xs text-gray-600",children:"Elevation (meters)"}),(0,S.jsx)(l.p,{type:"number",value:a.elevation_m||"",onChange:e=>ce(s,t,"elevation_m",parseInt(e.target.value)||0),placeholder:"1795",className:"mt-1"})]})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{className:"text-xs text-gray-600",children:"Waypoint Description / Instru
1ctions"}),(0,S.jsx)(c.T,{value:a.description,onChange:e=>ce(s,t,"description",e.target.value),placeholder:"e.g., Turn left at the wooden signpost, follow red-white trail markers for 500m",rows:2,className:"mt-1"})]})]},t)})]}),(0,S.jsxs)("div",{className:"border-t pt-3 mt-3",children:[(0,S.jsx)(o.J,{className:"text-sm font-semibold mb-2 block",children:"Accommodation"}),(0,S.jsxs)("div",{className:"space-y-2",children:[(0,S.jsx)(l.p,{value:(null===(a=e.accommodation)||void 0===a?void 0:a.name)||"",onChange:e=>re(s,"name",e.target.value),placeholder:"Accommodation name (e.g., Mountain Guest House)"}),(0,S.jsx)(l.p,{value:(null===(t=e.accommodation)||void 0===t?void 0:t.location)||"",onChange:e=>re(s,"location",e.target.value),placeholder:"Location (e.g., Rugova Village)"}),(0,S.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,S.jsx)(l.p,{type:"number",value:(null===(i=e.accommodation)||void 0===i?void 0:i.latitude)||0,onChange:e=>re(s,"latitude",parseFloat(e.target.value)),placeholder:"Latitude",step:"0.000001"}),(0,S.jsx)(l.p,{type:"number",value:(null===(m=e.accommodation)||void 0===m?void 0:m.longitude)||0,onChange:e=>re(s,"longitude",parseFloat(e.target.value)),placeholder:"Longitude",step:"0.000001"})]}),(0,S.jsxs)("div",{className:"border-t pt-2 mt-2",children:[(0,S.jsx)(o.J,{className:"text-xs text-gray-600 mb-1 block",children:"Contact Information"}),(0,S.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,S.jsx)(l.p,{value:(null===(p=e.accommodation)||void 0===p?void 0:p.phone)||"",onChange:e=>re(s,"phone",e.target.value),placeholder:"Phone (e.g., +383 49 123 456)"}),(0,S.jsx)(l.p,{value:(null===(h=e.accommodation)||void 0===h?void 0:h.email)||"",onChange:e=>re(s,"email",e.target.value),placeholder:"Email",type:"email"})]}),(0,S.jsx)(l.p,{value:(null===(u=e.accommodation)||void 0===u?void 0:u.website)||"",onChange:e=>re(s,"website",e.target.value),placeholder:"Website URL",className:"mt-2"}),(0,S.jsx)(c.T,{value:(null===(x=e.accommodation)||void 0===x?void 0:x.booking_instructions)||"",onChange:e=>re(s,"booking_instructions",e.target.value),placeholder:"Booking instructions (e.g., Call 24h in advance, mention tour booking code)",rows:2,className:"mt-2"})]})]})]}),(0,S.jsxs)("div",{className:"border-t pt-3 mt-3",children:[(0,S.jsxs)("div",{className:"flex justify-between items-center mb-2",children:[(0,S.jsx)(o.J,{className:"text-sm font-semibold",children:"Alternative Accommodations"}),(0,S.jsxs)(r.$,{type:"button",size:"sm",variant:"outline",onClick:()=>{return e=s,void q(s=>({...s,daily_itinerary:(s.daily_itinerary||[]).map((s,a)=>a===e?{...s,accommodation_options:[...s.accommodation_options||[],{name:"",location:"",phone:"",email:"",website:"",price_range:""}]}:s)}));var e},children:[(0,S.jsx)(j.A,{className:"h-4 w-4 mr-1"}),"Add Option"]})]}),(e.accommodation_options||[]).map((e,a)=>(0,S.jsxs)("div",{className:"p-3 bg-blue-50 rounded mb-2 space-y-2",children:[(0,S.jsxs)("div",{className:"flex justify-between items-start",children:[(0,S.jsxs)("span",{className:"text-sm font-medium",children:["Option ",a+1]}),(0,S.jsx)(r.$,{type:"button",variant:"ghost",size:"sm",onClick:()=>{return e=s,t=a,void q(s=>({...s,daily_itinerary:(s.daily_itinerary||[]).map((s,a)=>a===e?{...s,accommodation_options:(s.accommodation_options||[]).filter((e,s)=>s!==t)}:s)}));var e,t},className:"text-red-600",children:(0,S.jsx)(g.A,{className:"h-4 w-4"})})]}),(0,S.jsx)(l.p,{value:e.name,onChange:e=>de(s,a,"name",e.target.value),placeholder:"Name"}),(0,S.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,S.jsx)(l.p,{value:e.location,onChange:e=>de(s,a,"location",e.target.value),placeholder:"Location"}),(0,S.jsx)(l.p,{value:e.phone,onChange:e=>de(s,a,"phone",e.target.value),placeholder:"Phone"})]}),(0,S.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,S.jsx)(l.p,{value:e.email,onChange:e=>de(s,a,"email",e.target.value),placeholder:"Email"}),(0,S.jsx)(l.p,{value:e.website,onChange:e=>de(s,a,"website",e.target.value),placeholder:"Website"})]}),(0,S.jsx)(l.p,{value:e.price_range,onChange:e=>de(s,a,"price_range",e.target.value),placeholder:"Price range (e.g., \u20ac30-50/night)"})]},a))]})]})]},s)})})]}),(0,S.jsxs)(n.Zp,{children:[(0,S.jsx)(n.aR,{children:(0,S.jsx)(n.ZB,{children:"Equipment Needed"})}),(0,S.jsxs)(n.Wu,{className:"space-y-4",children:[(0,S.jsxs)("div",{className:"flex gap-2",children:[(0,S.jsx)(l.p,{value:K,onChange:e=>X(e.target.value),placeholder:"Add equipment (e.g., Hiking boots, Sleeping bag)",onKeyPress:e=>"Enter"===e.key&&(e.preventDefault(),le())}),(0,S.jsx)(r.$,{onClick:le,type:"button",children:(0,S.jsx)(j.A,{className:"h-4 w-4"})})]}),(0,S.jsx)("ul",{className:"space-y-2",children:(L.equipment_needed||[]).map((e,s)=>(0,S.jsxs)("li",{className:"flex items-center justify-between bg-muted p-2 rounded",children:[(0,S.jsx)("span",{children:e}),(0,S.jsx)(r.$,{variant:"ghost",size:"sm",onClick:()=>(e=>{q(s=>({...s,equipment_needed:s.equipment_needed.filter(s=>s!==e)}))})(e),className:"text-red-600",children:(0,S.jsx)(g.A,{className:"h-4 w-4"})})]},s))})]})]}),(0,S.jsxs)(n.Zp,{children:[(0,S.jsx)(n.aR,{children:(0,S.jsx)(n.ZB,{children:"Tour Highlights"})}),(0,S.jsxs)(n.Wu,{className:"space-y-4",children:[(0,S.jsxs)("div",{className:"flex gap-2",children:[(0,S.jsx)(l.p,{value:Y,onChange:e=>Q(e.target.value),placeholder:"Add highlight (e.g., Stunning mountain views)",onKeyPress:e=>"Enter"===e.key&&(e.preventDefault(),oe())}),(0,S.jsx)(r.$,{onClick:oe,type:"button",children:(0,S.jsx)(j.A,{className:"h-4 w-4"})})]}),(0,S.jsx)("ul",{className:"space-y-2",children:(L.highlights||[]).map((e,s)=>(0,S.jsxs)("li",{className:"flex items-center justify-between bg-yellow-50 p-2 rounded",children:[(0,S.jsxs)("span",{children:["\u2022 ",e]}),(0,S.jsx)(r.$,{variant:"ghost",size:"sm",onClick:()=>(e=>{q(s=>({...s,highlights:s.highlights.filter((s,a)=>a!==e)}))})(s),className:"text-red-600",children:(0,S.jsx)(g.A,{className:"h-4 w-4"})})]},s))})]})]}),(0,S.jsxs)(n.Zp,{children:[(0,S.jsx)(n.aR,{children:(0,S.jsx)(n.ZB,{children:"Suitability"})}),(0,S.jsxs)(n.Wu,{className:"space-y-4",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{htmlFor:"suitable_for",children:"Suitable For"}),(0,S.jsx)(c.T,{id:"suitable_for",value:L.suitable_for,onChange:e=>q(s=>({...s,suitable_for:e.target.value})),placeholder:"e.g., Experienced hikers, adventure seekers, nature lovers",rows:3})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{htmlFor:"not_suitable_for",children:"Not Suitable For"}),(0,S.jsx)(c.T,{id:"not_suitable_for",value:L.not_suitable_for,onChange:e=>q(s=>({...s,not_suitable_for:e.target.value})),placeholder:"e.g., Beginners, people with mobility issues, families with young children",rows:3})]})]})]}),(0,S.jsxs)(n.Zp,{children:[(0,S.jsx)(n.aR,{children:(0,S.jsx)(n.ZB,{children:"Safety & Warnings"})}),(0,S.jsxs)(n.Wu,{className:"space-y-4",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{htmlFor:"weather_considerations",children:"Weather Considerations"}),(0,S.jsx)(c.T,{id:"weather_considerations",value:L.weather_considerations,onChange:e=>q(s=>({...s,weather_considerations:e.target.value})),placeholder:"Weather patterns, best/worst months, rainfall, temperature ranges",rows:3})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{htmlFor:"altitude_warnings",children:"Altitude Warnings"}),(0,S.jsx)(c.T,{id:"altitude_warnings",value:L.altitude_warnings,onChange:e=>q(s=>({...s,altitude_warnings:e.target.value})),placeholder:"Maximum altitude, altitude sickness risks, acclimatization tips",rows:3})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{htmlFor:"dangerous_sections",children:"Dangerous Sections"}),(0,S.jsx)(c.T,{id:"dangerous_sections",value:L.dangerous_sections,onChange:e=>q(s=>({...s,dangerous_sections:e.target.value})),placeholder:"Steep drops, river crossings, exposed areas, wildlife warnings",rows:3})]})]})]}),(0,S.jsxs)(n.Zp,{children:[(0,S.jsx)(n.aR,{children:(0,S.jsx)(n.ZB,{children:"Emergency Contacts (Country-Specific)"})}),(0,S.jsxs)(n.Wu,{className:"space-y-4",children:[(0,S.jsxs)("div",{className:"grid grid-cols-3 gap-2",children:[(0,S.jsx)(l.p,{value:ee.country,onChange:e=>se(s=>({...s,country:e.target.value})),placeholder:"Country"}),(0,S.jsx)(l.p,{value:ee.service,onChange:e=>se(s=>({...s,service:e.target.value})),placeholder:"Service (e.g., Police, Mountain Rescue)"}),(0,S.jsxs)("div",{className:"flex gap-2",children:[(0,S.jsx)(l.p,{value:ee.number,onChange:e=>se(s=>({...s,number:e.target.value})),placeholder:"Number"}),(0,S.jsx)(r.$,{onClick:()=>{ee.country&&ee.service&&ee.number&&(q(e=>({...e,emergency_contacts:[...e.emergency_contacts||[],{...ee}]})),se({country:"",service:"",number:""}))},type:"button",children:(0,S.jsx)(j.A,{className:"h-4 w-4"})})]})]}),(0,S.jsx)("ul",{className:"space-y-2",children:(L.emergency_contacts||[]).map((e,s)=>(0,S.jsxs)("li",{className:"flex items-center justify-between bg-red-50 p-3 rounded border border-red-200",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)("span",{className:"font-semibold",children:e.country})," - ",e.service,": ",(0,S.jsx)("strong",{children:e.number})]}),(0,S.jsx)(r.$,{variant:"ghost",size:"sm",onClick:()=>(e=>{q(s=>({...s,emergency_contacts:s.emergency_contacts.filter((s,a)=>a!==e)}))})(s),className:"text-red-600",children:(0,S.jsx)(g.A,{className:"h-4 w-4"})})]},s))})]})]}),(0,S.jsxs)(n.Zp,{children:[(0,S.jsx)(n.aR,{children:(0,S.jsx)(n.ZB,{children:"Logistics & Transport"})}),(0,S.jsxs)(n.Wu,{className:"space-y-4",children:[(0,S.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,S.jsx)("input",{type:"checkbox",id:"baggage_transfer_available",checked:L.baggage_transfer_available,onChange:e=>q(s=>({...s,baggage_transfer_available:e.target.checked})),className:"h-4 w-4"}),(0,S.jsx)(o.J,{htmlFor:"baggage_transfer_available",className:"cursor-pointer",children:"Baggage Transfer Available"})]}),L.baggage_transfer_available&&(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{htmlFor:"baggage_transfer_info",children:"Baggage Transfer Details"}),(0,S.jsx)(c.T,{id:"baggage_transfer_info",value:L.baggage_transfer_info,onChange:e=>q(s=>({...s,baggage_transfer_info:e.target.value})),placeholder:"Price, booking process, weight limits, contact info",rows:3})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{htmlFor:"public_transport_info",children:"Public Transport Acce
1ss"}),(0,S.jsx)(c.T,{id:"public_transport_info",value:L.public_transport_info,onChange:e=>q(s=>({...s,public_transport_info:e.target.value})),placeholder:"How to reach start point, buses, trains, schedules, costs",rows:3})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{htmlFor:"parking_info",children:"Parking Information"}),(0,S.jsx)(c.T,{id:"parking_info",value:L.parking_info,onChange:e=>q(s=>({...s,parking_info:e.target.value})),placeholder:"Parking locations, costs, security, multi-day parking options",rows:3})]})]})]}),(0,S.jsxs)(n.Zp,{children:[(0,S.jsx)(n.aR,{children:(0,S.jsx)(n.ZB,{children:"Cultural & Local Information"})}),(0,S.jsxs)(n.Wu,{className:"space-y-4",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{htmlFor:"local_customs",children:"Local Customs"}),(0,S.jsx)(c.T,{id:"local_customs",value:L.local_customs,onChange:e=>q(s=>({...s,local_customs:e.target.value})),placeholder:"Cultural norms, dress code, greetings, tipping, behavior in villages",rows:3})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{htmlFor:"park_regulations",children:"Park Regulations"}),(0,S.jsx)(c.T,{id:"park_regulations",value:L.park_regulations,onChange:e=>q(s=>({...s,park_regulations:e.target.value})),placeholder:"Permits required, camping rules, fire restrictions, waste disposal",rows:3})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(o.J,{htmlFor:"language_tips",children:"Language Tips"}),(0,S.jsx)(c.T,{id:"language_tips",value:L.language_tips,onChange:e=>q(s=>({...s,language_tips:e.target.value})),placeholder:"Useful phrases, language spoken in each country, English proficiency",rows:3})]})]})]}),(0,S.jsx)(n.Zp,{children:(0,S.jsxs)(n.Wu,{className:"p-6",children:[(0,S.jsxs)("h3",{className:"text-lg font-bold mb-1 flex items-center gap-2",children:[(0,S.jsx)(b.A,{className:"h-5 w-5 text-amber-500"}),"Cancellation Policy & Terms"]}),(0,S.jsx)("p",{className:"text-xs text-gray-500 mb-4",children:"This text will be displayed to customers on the public tour page and booking page, below all pricing tiers. Use this for cancellation rules, payment terms, deposit conditions, etc."}),(0,S.jsx)("textarea",{value:L.cancellation_policy,onChange:e=>q(s=>({...s,cancellation_policy:e.target.value})),placeholder:"Enter cancellation policy and terms. Example: Free cancellation up to 30 days before departure.\n50% charge for cancellations 15-29 days before.\nNo refund for cancellations less than 14 days before departure.\nDeposit is non-refundable.\n...",className:"w-full min-h-[200px] p-3 border rounded-lg text-sm resize-y focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:border-emerald-500","data-testid":"cancellation-policy-textarea"})]})}),(0,S.jsxs)("div",{className:"flex gap-3 justify-end",children:[(0,S.jsx)(r.$,{variant:"outline",onClick:()=>a("/admin/multi-day-hiking-tours"),disabled:I,children:"Cancel"}),A&&(0,S.jsxs)(r.$,{variant:"outline",onClick:()=>W(!0),disabled:I,className:"border-blue-300 text-blue-700 hover:bg-blue-50",children:[(0,S.jsx)(y.A,{className:"h-4 w-4 mr-2"}),"Update Prices"]}),A&&(0,S.jsxs)(r.$,{variant:"outline",onClick:async()=>{if(k){Z(!0),G(null);try{const e=localStorage.getItem("token"),s=await fetch(`${D}/api/admin/tours/${k}/verify-integrity`,{headers:{Authorization:`Bearer ${e}`}});if(s.ok){const e=await s.json();G(e),"PASS"===e.overall_status?w.oR.success("\u2705 Tour verification passed! All safety checks completed."):"PASS_WITH_WARNINGS"===e.overall_status?w.oR.warning(`\u26a0\ufe0f Tour passed with ${e.warnings} warning(s). Review the report.`):w.oR.error(`\u274c Tour verification failed. ${e.issues_found} issue(s) found.`)}else{const e=await s.json();w.oR.error(e.detail||"Verification failed")}}catch(e){console.error("Verification error:",e),w.oR.error("Error verifying tour")}finally{Z(!1)}}else w.oR.error("Please save the tour first before verifying")},disabled:U||I,className:"border-emerald-300 text-emerald-700 hover:bg-emerald-50","data-testid":"verify-integrity-btn",children:[(0,S.jsx)(f.A,{className:"h-4 w-4 mr-2"}),U?"Verifying...":"Verify Safety"]}),A&&(0,S.jsxs)(r.$,{variant:"outline",onClick:async()=>
1{if(k){Z(!0),w.oR.info("Verifying GPS coordinates online... This may take a moment.");try{const e=localStorage.getItem("token"),s=await fetch(`${D}/api/admin/tours/${k}/verify-gps-online`,{method:"POST",headers:{Authorization:`Bearer ${e}`}});if(s.ok){const e=await s.json();G(e),"PASS"===e.overall_status?w.oR.success(`\u2705 GPS Verified! ${e.coordinates_verified} coordinates confirmed.`):"WARNING"===e.overall_status?w.oR.warning(`\u26a0\ufe0f ${e.coordinates_failed} coordinates may be incorrect.`):w.oR.info("GPS verification completed. Check report for details.")}else{const e=await s.json();w.oR.error(e.detail||"GPS verification failed")}}catch(e){console.error("GPS verification error:",e),w.oR.error("Error verifying GPS")}finally{Z(!1)}}else w.oR.error("Please save the tour first")},disabled:U||I,className:"border-purple-300 text-purple-700 hover:bg-purple-50","data-testid":"verify-gps-btn",children:[(0,S.jsx)(v.A,{className:"h-4 w-4 mr-2"}),"Verify GPS Online"]}),A&&(0,S.jsxs)(r.$,{variant:"outline",onClick:async()=>{if(k){Z(!0),w.oR.info("Looking up missing coordinates...");try{const e=localStorage.getItem("token"),s=await fetch(`${D}/api/admin/tours/${k}/auto-fix-coordinates`,{method:"POST",headers:{Authorization:`Bearer ${e}`}});if(s.ok){const e=await s.json();e.fixes_applied>0?(w.oR.success(`\u2705 Fixed ${e.fixes_applied} coordinates! Refreshing...`),ae()):w.oR.info("No coordinates needed fixing."),e.fixes_failed>0&&w.oR.warning(`Could not find ${e.fixes_failed} locations.`)}else{const e=await s.json();w.oR.error(e.detail||"Auto-fix failed")}}catch(e){console.error("Auto-fix error:",e),w.oR.error("Error fixing coordinates")}finally{Z(!1)}}else w.oR.error("Please save the tour first")},disabled:U||I,className:"border-orange-300 text-orange-700 hover:bg-orange-50","data-testid":"auto-fix-coords-btn",children:[(0,S.jsx)(y.A,{className:"h-4 w-4 mr-2"}),"Auto-Fix Missing"]}),A&&(0,S.jsxs)(r.$,{variant:"outline",onClick:async()=>{if(k){if(window.confirm("This will update ALL waypoint coordinates from OpenStreetMap. This may take a minute. Continue?")){Z(!0),w.oR.info("\ud83c\udf0d Looking up coordinates from OpenStreetMap... Please wait.");try{const e=localStorage.getItem("token"),s=await fetch(`${D}/api/admin/tours/${k}/update-gps-from-osm`,{method:"POST",headers:{Authorization:`Bearer ${e}`}});if(s.ok){const e=await s.json();e.coordinates_updated>0?(w.oR.success(`\u2705 Updated ${e.coordinates_updated} coordinates from OpenStreetMap!`),G({overall_status:"PASS",summary:`Updated ${e.coordinates_updated} coordinates`,checks:e.updates.map(e=>({check:e.name,status:"UPDATED",details:`OSM: ${e.osm_name}`})),recommendations:e.failures}),ae()):w.oR.warning("Could not find any locations in OpenStreetMap."),e.coordinates_failed>0&&w.oR.warning(`${e.coordinates_failed} locations not found in OSM.`)}else{const e=await s.json();w.oR.error(e.detail||"Update failed")}}catch(e){console.error("Update GPS error:",e),w.oR.error("Error updating coordinates")}finally{Z(!1)}}}else w.oR.error("Please save the tour first")},disabled:U||I,className:"border-cyan-300 text-cyan-700 hover:bg-cyan-50","data-testid":"update-gps-osm-btn",children:[(0,S.jsx)(v.A,{className:"h-4 w-4 mr-2"}),"\ud83c\udf0d Fix GPS from OSM"]}),(0,S.jsxs)(r.$,{variant:"outline",onClick:()=>te(!1),disabled:I,children:[(0,S.jsx)(N.A,{className:"h-4 w-4 mr-2"}),A?"Update as Draft":"Save as Draft"]}),(0,S.jsxs)(r.$,{onClick:()=>te(!0),disabled:I,className:"bg-emerald-600 hover:bg-emerald-700",children:[(0,S.jsx)(N.A,{className:"h-4 w-4 mr-2"}),A?"Update & Publish":"Save & Publish"]})]}),O&&(0,S.jsxs)(n.Zp,{className:"mt-4 "+("PASS"===O.overall_status?"border-emerald-400 bg-emerald-50":"PASS_WITH_WARNINGS"===O.overall_status?"border-yellow-400 bg-yellow-50":"border-red-400 bg-red-50"),"data-testid":"verification-report",children:[(0,S.jsx)(n.aR,{className:"pb-2",children:(0,S.jsxs)(n.ZB,{className:"flex items-center gap-2 text-lg",children:["PASS"===O.overall_status?(0,S.jsx)(f.A,{className:"h-5 w-5 text-emerald-600"}):"PASS_WITH_WARNINGS"===O.overall_status?(0,S.jsx)(b.A,{className:"h-5 w-5 text-yellow-600"}):(0,S.jsx)(b.A,{className:"h-5 w-5 text-red-600"}),O.summary]})}),(0,S.jsxs)(n.Wu,{children:[(0,S.jsx)("div",{className:"space-y-2",children:null===(e=O.checks)||void 0===e?void 0:e.map((e,s)=>(0,S.jsxs)("div",{className:"flex items-start gap-2 text-sm",children:[(0,S.jsx)("span",{className:"font-medium min-w-[80px] "+("PASS"===e.status?"text-emerald-700":"WARNING"===e.status?"text-yellow-700":"text-red-700"),children:e.status}),(0,S.jsxs)("span",{className:"font-medium",children:[e.check,":"]}),(0,S.jsx)("span",{className:"text-gray-600",children:Array.isArray(e.details)?e.details.join(", "):e.details})]},s))}),(null===(s=O.recommendations)||void 0===s?void 0:s.length)>0&&(0,S.jsxs)("div",{className:"mt-4 pt-4 border-t",children:[(0,S.jsx)("p",{className:"font-medium text-sm mb-2",children:"Recommendations:"}),(0,S.jsx)("ul",{className:"list-disc list-inside text-sm text-gray-700 space-y-1",children:O.recommendations.map((e,s)=>(0,S.jsx)("li",{children:e},s))})]}),(0,S.jsx)(r.$,{variant:"ghost",size:"sm",className:"mt-3",onClick:()=>G(null),children:"Dismiss"})]})]}),A&&(0,S.jsx)(R.F,{isOpen:B,onClose:()=>W(!1),tourId:k,tourType:"multi-day-hiking",onPricesUpdated:e=>{ae(),W(!1)}})]})]}),(0,S.jsx)(F.S,{tourId:k,tourType:"hiking",tourName:L.title||"New Tour",onTourUpdate:()=>window.location.reload(),pageContext:k?"edit":"create"})]})}},65598:(e,s,a)=>{a.d(s,{Cf:()=>u,Es:()=>g,L3:()=>j,c7:()=>x,lG:()=>c,rr:()=>_,zM:()=>d});var t=a(65043),i=a(57427),r=a(40614),n=a(99766),l=a(70579);const o=t.createContext(!0),c=({modal:e=!0,...s})=>{const[a,r]=t.useState(!1);t.useEffect(()=>{const e=()=>{const e=document.getElementById("ai-assistant-portal"),s=e&&e.children.length>0;r(s||window.__aiAssistantClicked)};e();const s=document.getElementById("ai-assistant-portal");if(s){const a=new MutationObserver(e);return a.observe(s,{childList:!0,subtree:!0}),()=>a.disconnect()}},[]);const n=!a&&e;return(0,l.jsx)(o.Provider,{value:n,children:(0,l.jsx)(i.bL,{modal:n,...s})})},d=i.l9,m=i.ZL,p=(i.bm,t.forwardRef(({className:e,...s},a)=>(0,l.jsx)(i.hJ,{ref:a,className:(0,n.cn)("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...s})));p.displayName=i.hJ.displayName;const h=e=>{var s,a,t,i;if("undefined"!==typeof window&&(window.__aiAssistantClicked||window.__aiInputClicked||window.__aiInputFocused))return!0;const r=null===e||void 0===e?void 0:e.target;return!!r&&!!(null!==(s=r.closest)&&void 0!==s&&s.call(r,"[data-ai-assistant]")||null!==(a=r.closest)&&void 0!==a&&a.call(r,".ai-assistant-panel")||null!==(t=r.hasAttribute)&&void 0!==t&&t.call(r,"data-ai-assistant")||null!==(i=r.closest)&&void 0!==i&&i.call(r,"#ai-assistant-portal"))},u=t.forwardRef(({className:e,children:s,...a},t)=>(0,l.jsxs)(m,{children:[(0,l.jsx)(p,{}),(0,l.jsxs)(i.UC,{ref:t,className:(0,n.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rou
1nded-lg",e),onPointerDownOutside:e=>{var s;if(h(e))return e.preventDefault(),void e.stopPropagation();null===(s=a.onPointerDownOutside)||void 0===s||s.call(a,e)},onInteractOutside:e=>{var s;if(h(e))return e.preventDefault(),void e.stopPropagation();null===(s=a.onInteractOutside)||void 0===s||s.call(a,e)},onFocusOutside:e=>{var s;if(h(e)||"undefined"!==typeof window&&window.__aiAssistantClicked)return e.preventDefault(),void e.stopPropagation();null===(s=a.onFocusOutside)||void 0===s||s.call(a,e)},onEscapeKeyDown:e=>{"undefined"!==typeof window&&window.__aiAssistantClicked&&e.preventDefault()},...a,children:[s,(0,l.jsxs)(i.bm,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[(0,l.jsx)(r.A,{className:"h-4 w-4"}),(0,l.jsx)("span",{className:"sr-only",children:"Close"})]})]})]}));u.displayName=i.UC.displayName;const x=({className:e,...s})=>(0,l.jsx)("div",{className:(0,n.cn)("flex flex-col space-y-1.5 text-center sm:text-left",e),...s});x.displayName="DialogHeader";const g=({className:e,...s})=>(0,l.jsx)("div",{className:(0,n.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...s});g.displayName="DialogFooter";const j=t.forwardRef(({className:e,...s},a)=>(0,l.jsx)(i.hE,{ref:a,className:(0,n.cn)("text-lg font-semibold leading-none tracking-tight",e),...s}));j.displayName=i.hE.displayName;const _=t.forwardRef(({className:e,...s},a)=>(0,l.jsx)(i.VY,{ref:a,className:(0,n.cn)("text-sm text-muted-foreground",e),...s}));_.displayName=i.VY.displayName},84370:(e,s,a)=>{a.d(s,{bq:()=>p,eb:()=>g,gC:()=>x,l6:()=>d,yv:()=>m});var t=a(65043),i=a(12520),r=a(36210),n=a(92382),l=a(15711),o=a(99766),c=a(70579);const d=i.bL,m=(i.YJ,i.WT),p=t.forwardRef(({className:e,children:s,...a},t)=>(0,c.jsxs)(i.l9,{ref:t,className:(0,o.cn)("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...a,children:[s,(0,c.jsx)(i.In,{asChild:!0,children:(0,c.jsx)(n.A,{className:"h-4 w-4 opacity-50"})})]}));p.displayName=i.l9.displayName;const h=t.forwardRef(({className:e,...s},a)=>(0,c.jsx)(i.PP,{ref:a,className:(0,o.cn)("flex cursor-default items-center justify-center py-1",e),...s,children:(0,c.jsx)(l.A,{className:"h-4 w-4"})}));h.displayName=i.PP.displayName;const u=t.forwardRef(({className:e,...s},a)=>(0,c.jsx)(i.wn,{ref:a,className:(0,o.cn)("flex cursor-default items-center justify-center py-1",e),...s,children:(0,c.jsx)(n.A,{className:"h-4 w-4"})}));u.displayName=i.wn.displayName;const x=t.forwardRef(({className:e,children:s,position:a="popper",...t},r)=>(0,c.jsx)(i.ZL,{children:(0,c.jsxs)(i.UC,{ref:r,className:(0,o.cn)("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]","popper"===a&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:a,...t,children:[(0,c.jsx)(h,{}),(0,c.jsx)(i.LM,{className:(0,o.cn)("p-1","popper"===a&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),(0,c.jsx)(u,{})]})}));x.displayName=i.UC.displayName;t.forwardRef(({className:e,...s},a)=>(0,c.jsx)(i.JU,{ref:a,className:(0,o.cn)("px-2 py-1.5 text-sm font-semibold",e),...s})).displayName=i.JU.displayName;const g=t.forwardRef(({className:e,children:s,...a},t)=>(0,c.jsxs)(i.q7,{ref:t,className:(0,o.cn)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...a,children:[(0,c.jsx)("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,c.jsx)(i.VF,{children:(0,c.jsx)(r.A,{className:"h-4 w-4"})})}),(0,c.jsx)(i.p4,{children:s})]}));g.displayName=i.q7.displayName;t.forwardRef(({className:e,...s},a)=>(0,c.jsx)(i.wv,{ref:a,className:(0,o.cn)("-mx-1 my-1 h-px bg-muted",e),...s})).displayName=i.wv.displayName}}]); 2//# sourceMappingURL=5095.c72f18d4.chunk.js.map
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.