// Initialize local storage if not exists if (!localStorage.getItem('restaurantData')) { const initialData = { orders: [], reservations: [], menuItems: [ { id: 1, name: "Margherita Pizza", price: 12.99, category: "Main Course" }, { id: 2, name: "Caesar Salad", price: 8.99, category: "Appetizer" }, { id: 3, name: "Tiramisu", price: 6.99, category: "Dessert" } ], staff: [ { id: 1, name: "John Doe", role: "Chef", shift: "Morning" }, { id: 2, name: "Jane Smith", role: "Waiter", shift: "Evening" } ], stats: { dailyRevenue: 0, monthlyRevenue: 0, activeOrders: 0, todaysReservations: 0 } }; localStorage.setItem('restaurantData', JSON.stringify(initialData)); } // Utility functions function updateLocalStorage(data) { localStorage.setItem('restaurantData', JSON.stringify(data)); } function getRestaurantData() { return JSON.parse(localStorage.getItem('restaurantData')); } // Event bus for component communication const eventBus = new EventTarget(); // Export functions to be used in components window.restaurantApp = { getData: getRestaurantData, updateData: updateLocalStorage, eventBus: eventBus };