@cloudexp-io/laudro-site-kit 0.0.0-stage → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +55 -2
- package/dist/chunk-YCELGJAT.js +35 -0
- package/dist/client.d.ts +222 -0
- package/dist/client.js +433 -0
- package/dist/index.d.ts +1106 -0
- package/dist/index.js +1017 -0
- package/dist/server.d.ts +90 -0
- package/dist/server.js +225 -0
- package/package.json +57 -3
package/dist/index.js
ADDED
|
@@ -0,0 +1,1017 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_SITE_LANG,
|
|
3
|
+
SITE_LANGS,
|
|
4
|
+
absoluteUrl,
|
|
5
|
+
isSiteLang,
|
|
6
|
+
localePath,
|
|
7
|
+
safePath,
|
|
8
|
+
splitLocale
|
|
9
|
+
} from "./chunk-YCELGJAT.js";
|
|
10
|
+
|
|
11
|
+
// src/i18n.ts
|
|
12
|
+
var et = {
|
|
13
|
+
langName: "Eesti",
|
|
14
|
+
weekdays: ["esmasp\xE4ev", "teisip\xE4ev", "kolmap\xE4ev", "neljap\xE4ev", "reede", "laup\xE4ev", "p\xFChap\xE4ev"],
|
|
15
|
+
weekdaysShort: ["E", "T", "K", "N", "R", "L", "P"],
|
|
16
|
+
today: "t\xE4na",
|
|
17
|
+
tomorrow: "homme",
|
|
18
|
+
openNow: "Avatud",
|
|
19
|
+
closedNow: "Suletud",
|
|
20
|
+
closesAt: (t) => `Avatud kuni ${t}`,
|
|
21
|
+
opensAt: (w) => `Avatakse ${w}`,
|
|
22
|
+
closed: "suletud",
|
|
23
|
+
openingHours: "Lahtiolekuajad",
|
|
24
|
+
kitchen: "K\xF6\xF6k",
|
|
25
|
+
holiday: "riigip\xFCha",
|
|
26
|
+
specialDay: "Erandp\xE4evad",
|
|
27
|
+
lunch: "P\xE4evapakkumine",
|
|
28
|
+
lunchToday: "T\xE4nane p\xE4evapakkumine",
|
|
29
|
+
noLunch: "T\xE4na p\xE4evapakkumist ei ole.",
|
|
30
|
+
nextLunch: (d) => `J\xE4rgmine p\xE4evapakkumine: ${d}`,
|
|
31
|
+
servedBetween: (a, b) => `Pakume ${a}\u2013${b}`,
|
|
32
|
+
setPrice: "Komplekt",
|
|
33
|
+
to: "kuni",
|
|
34
|
+
language: "Keel",
|
|
35
|
+
closedOn: (ds) => `${ds.length > 1 ? `${ds.slice(0, -1).join(", ")} ja ${ds[ds.length - 1]}` : ds[0]} on suletud`,
|
|
36
|
+
visit: "K\xFClasta",
|
|
37
|
+
pages: "Leht",
|
|
38
|
+
menu: "Men\xFC\xFC",
|
|
39
|
+
openMenu: "Ava men\xFC\xFC",
|
|
40
|
+
bookShort: "Broneeri",
|
|
41
|
+
mainNav: "P\xF5himen\xFC\xFC",
|
|
42
|
+
soldOut: "otsas",
|
|
43
|
+
allergens: "Allergeenid",
|
|
44
|
+
mayContain: "v\xF5ib sisaldada",
|
|
45
|
+
ingredients: "Koostisosad",
|
|
46
|
+
tags: {
|
|
47
|
+
vegan: "vegan",
|
|
48
|
+
vegetarian: "taimetoit",
|
|
49
|
+
gluten_free: "gluteenivaba",
|
|
50
|
+
lactose_free: "laktoosivaba",
|
|
51
|
+
spicy: "v\xFCrtsikas",
|
|
52
|
+
new: "uus",
|
|
53
|
+
popular: "populaarne",
|
|
54
|
+
chef_choice: "koka soovitus",
|
|
55
|
+
kids: "lastele"
|
|
56
|
+
},
|
|
57
|
+
allergenNames: {
|
|
58
|
+
gluten: "gluteen",
|
|
59
|
+
crustaceans: "koorikloomad",
|
|
60
|
+
eggs: "munad",
|
|
61
|
+
fish: "kala",
|
|
62
|
+
peanuts: "maap\xE4hklid",
|
|
63
|
+
soybeans: "soja",
|
|
64
|
+
milk: "piim",
|
|
65
|
+
nuts: "p\xE4hklid",
|
|
66
|
+
celery: "seller",
|
|
67
|
+
mustard: "sinep",
|
|
68
|
+
sesame: "seesam",
|
|
69
|
+
sulphites: "sulfitid",
|
|
70
|
+
lupin: "lupiin",
|
|
71
|
+
molluscs: "molluskid"
|
|
72
|
+
},
|
|
73
|
+
booking: {
|
|
74
|
+
title: "Broneeri laud",
|
|
75
|
+
note: "Kinnitus tuleb SMS-iga kohe.",
|
|
76
|
+
fewer: "V\xE4hem inimesi",
|
|
77
|
+
more: "Rohkem inimesi",
|
|
78
|
+
fullHint: "L\xE4bikriipsutatud on t\xE4is",
|
|
79
|
+
today: "T\xE4na",
|
|
80
|
+
tomorrow: "Homme",
|
|
81
|
+
submit: "Broneeri laud"
|
|
82
|
+
},
|
|
83
|
+
events: {
|
|
84
|
+
seatsLeft: (n) => `${n} kohta vaba`,
|
|
85
|
+
soldOut: "V\xE4lja m\xFC\xFCdud"
|
|
86
|
+
},
|
|
87
|
+
form: {
|
|
88
|
+
date: "Kuup\xE4ev",
|
|
89
|
+
time: "Kellaaeg",
|
|
90
|
+
partySize: "Inimesi",
|
|
91
|
+
name: "Nimi",
|
|
92
|
+
phone: "Telefon",
|
|
93
|
+
email: "E-post",
|
|
94
|
+
emailOptional: "E-post (soovi korral)",
|
|
95
|
+
note: "Lisainfo",
|
|
96
|
+
send: "Saada p\xE4ring",
|
|
97
|
+
sending: "Saadan\u2026",
|
|
98
|
+
sent: "Ait\xE4h!",
|
|
99
|
+
bookingSent: "Ait\xE4h! Saime su broneeringusoovi k\xE4tte ja kinnitame selle peagi.",
|
|
100
|
+
eventSent: "Ait\xE4h! Saime su p\xE4ringu k\xE4tte ja v\xF5tame peagi \xFChendust.",
|
|
101
|
+
contactSent: "Ait\xE4h! Saime su s\xF5numi k\xE4tte.",
|
|
102
|
+
required: "Palun t\xE4ida see v\xE4li.",
|
|
103
|
+
tooShort: { phone: "Telefoninumber on liiga l\xFChike" },
|
|
104
|
+
invalid: "Palun kontrolli seda v\xE4lja.",
|
|
105
|
+
invalidEmail: "Palun sisesta korrektne e-posti aadress.",
|
|
106
|
+
rateLimited: "Liiga palju p\xE4ringuid. Proovi m\xF5ne minuti p\xE4rast uuesti.",
|
|
107
|
+
failed: "Saatmine eba\xF5nnestus. Proovi uuesti.",
|
|
108
|
+
failedCall: (p) => `Saatmine eba\xF5nnestus. Proovi uuesti v\xF5i helista ${p}.`,
|
|
109
|
+
eventDate: "\xDCrituse kuup\xE4ev",
|
|
110
|
+
guests: "K\xFClalisi",
|
|
111
|
+
kind: "\xDCrituse liik",
|
|
112
|
+
kinds: { company: "Firma\xFCritus", birthday: "S\xFCnnip\xE4ev", wedding: "Pulm", other: "Muu" },
|
|
113
|
+
budget: "Eelarve (\u20AC)",
|
|
114
|
+
package: "Pakett",
|
|
115
|
+
noPackage: "Ei tea veel",
|
|
116
|
+
perPerson: "/ in",
|
|
117
|
+
company: "Ettev\xF5te",
|
|
118
|
+
message: "S\xF5num",
|
|
119
|
+
sendAnother: "Saada uus p\xE4ring",
|
|
120
|
+
sendAnotherMessage: "Saada uus s\xF5num"
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
var en = {
|
|
124
|
+
langName: "English",
|
|
125
|
+
weekdays: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
|
|
126
|
+
weekdaysShort: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
|
|
127
|
+
today: "today",
|
|
128
|
+
tomorrow: "tomorrow",
|
|
129
|
+
openNow: "Open now",
|
|
130
|
+
closedNow: "Closed",
|
|
131
|
+
closesAt: (t) => `Open until ${t}`,
|
|
132
|
+
opensAt: (w) => `Opens ${w}`,
|
|
133
|
+
closed: "closed",
|
|
134
|
+
openingHours: "Opening hours",
|
|
135
|
+
kitchen: "Kitchen",
|
|
136
|
+
holiday: "public holiday",
|
|
137
|
+
specialDay: "Special days",
|
|
138
|
+
lunch: "Lunch",
|
|
139
|
+
lunchToday: "Today's lunch",
|
|
140
|
+
noLunch: "No lunch offer today.",
|
|
141
|
+
nextLunch: (d) => `Next lunch offer: ${d}`,
|
|
142
|
+
servedBetween: (a, b) => `Served ${a}\u2013${b}`,
|
|
143
|
+
setPrice: "Set menu",
|
|
144
|
+
to: "to",
|
|
145
|
+
language: "Language",
|
|
146
|
+
closedOn: (ds) => `Closed on ${ds.length > 1 ? `${ds.slice(0, -1).join(", ")} and ${ds[ds.length - 1]}` : ds[0]}`,
|
|
147
|
+
visit: "Visit",
|
|
148
|
+
pages: "Pages",
|
|
149
|
+
menu: "Menu",
|
|
150
|
+
openMenu: "Open menu",
|
|
151
|
+
bookShort: "Book",
|
|
152
|
+
mainNav: "Main",
|
|
153
|
+
soldOut: "sold out",
|
|
154
|
+
allergens: "Allergens",
|
|
155
|
+
mayContain: "may contain",
|
|
156
|
+
ingredients: "Ingredients",
|
|
157
|
+
tags: {
|
|
158
|
+
vegan: "vegan",
|
|
159
|
+
vegetarian: "vegetarian",
|
|
160
|
+
gluten_free: "gluten-free",
|
|
161
|
+
lactose_free: "lactose-free",
|
|
162
|
+
spicy: "spicy",
|
|
163
|
+
new: "new",
|
|
164
|
+
popular: "popular",
|
|
165
|
+
chef_choice: "chef's choice",
|
|
166
|
+
kids: "for kids"
|
|
167
|
+
},
|
|
168
|
+
allergenNames: {
|
|
169
|
+
gluten: "gluten",
|
|
170
|
+
crustaceans: "crustaceans",
|
|
171
|
+
eggs: "eggs",
|
|
172
|
+
fish: "fish",
|
|
173
|
+
peanuts: "peanuts",
|
|
174
|
+
soybeans: "soy",
|
|
175
|
+
milk: "milk",
|
|
176
|
+
nuts: "tree nuts",
|
|
177
|
+
celery: "celery",
|
|
178
|
+
mustard: "mustard",
|
|
179
|
+
sesame: "sesame",
|
|
180
|
+
sulphites: "sulphites",
|
|
181
|
+
lupin: "lupin",
|
|
182
|
+
molluscs: "molluscs"
|
|
183
|
+
},
|
|
184
|
+
booking: {
|
|
185
|
+
title: "Book a table",
|
|
186
|
+
note: "You get an SMS confirmation right away.",
|
|
187
|
+
fewer: "Fewer guests",
|
|
188
|
+
more: "More guests",
|
|
189
|
+
fullHint: "Crossed out times are full",
|
|
190
|
+
today: "Today",
|
|
191
|
+
tomorrow: "Tomorrow",
|
|
192
|
+
submit: "Book a table"
|
|
193
|
+
},
|
|
194
|
+
events: {
|
|
195
|
+
seatsLeft: (n) => `${n} ${n === 1 ? "seat" : "seats"} left`,
|
|
196
|
+
soldOut: "Sold out"
|
|
197
|
+
},
|
|
198
|
+
form: {
|
|
199
|
+
date: "Date",
|
|
200
|
+
time: "Time",
|
|
201
|
+
partySize: "Guests",
|
|
202
|
+
name: "Name",
|
|
203
|
+
phone: "Phone",
|
|
204
|
+
email: "Email",
|
|
205
|
+
emailOptional: "Email (optional)",
|
|
206
|
+
note: "Notes",
|
|
207
|
+
send: "Send request",
|
|
208
|
+
sending: "Sending\u2026",
|
|
209
|
+
sent: "Thank you!",
|
|
210
|
+
bookingSent: "Thank you! We got your booking request and will confirm it soon.",
|
|
211
|
+
eventSent: "Thank you! We got your request and will be in touch soon.",
|
|
212
|
+
contactSent: "Thank you! We got your message.",
|
|
213
|
+
required: "Please fill in this field.",
|
|
214
|
+
tooShort: { phone: "Phone number is too short" },
|
|
215
|
+
invalid: "Please check this field.",
|
|
216
|
+
invalidEmail: "Please enter a valid email address.",
|
|
217
|
+
rateLimited: "Too many requests. Please try again in a few minutes.",
|
|
218
|
+
failed: "Sending failed. Please try again.",
|
|
219
|
+
failedCall: (p) => `Sending failed. Please try again or call ${p}.`,
|
|
220
|
+
eventDate: "Event date",
|
|
221
|
+
guests: "Guests",
|
|
222
|
+
kind: "Type of event",
|
|
223
|
+
kinds: { company: "Company event", birthday: "Birthday", wedding: "Wedding", other: "Other" },
|
|
224
|
+
budget: "Budget (\u20AC)",
|
|
225
|
+
package: "Package",
|
|
226
|
+
noPackage: "Not sure yet",
|
|
227
|
+
perPerson: "/ person",
|
|
228
|
+
company: "Company",
|
|
229
|
+
message: "Message",
|
|
230
|
+
sendAnother: "Send another request",
|
|
231
|
+
sendAnotherMessage: "Send another message"
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
var DICTIONARIES = { et, en };
|
|
235
|
+
function dictionary(lang) {
|
|
236
|
+
return DICTIONARIES[lang];
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// src/format.ts
|
|
240
|
+
var LOCALES = { et: "et-EE", en: "en-GB" };
|
|
241
|
+
function formatMoney(money, lang) {
|
|
242
|
+
if (!money) return "";
|
|
243
|
+
const whole = money.cents % 100 === 0;
|
|
244
|
+
return new Intl.NumberFormat(LOCALES[lang], {
|
|
245
|
+
style: "currency",
|
|
246
|
+
currency: money.currency,
|
|
247
|
+
minimumFractionDigits: whole ? 0 : 2,
|
|
248
|
+
maximumFractionDigits: 2
|
|
249
|
+
}).format(money.cents / 100);
|
|
250
|
+
}
|
|
251
|
+
function moneyAmount(money) {
|
|
252
|
+
return (money.cents / 100).toFixed(2);
|
|
253
|
+
}
|
|
254
|
+
function formatTime(value, timeZone) {
|
|
255
|
+
if (/^\d{2}:\d{2}$/.test(value)) return value;
|
|
256
|
+
return new Intl.DateTimeFormat("en-GB", {
|
|
257
|
+
hour: "2-digit",
|
|
258
|
+
minute: "2-digit",
|
|
259
|
+
hour12: false,
|
|
260
|
+
timeZone
|
|
261
|
+
}).format(new Date(value));
|
|
262
|
+
}
|
|
263
|
+
function formatDate(isoDate, lang, withWeekday = false) {
|
|
264
|
+
const [y, m, d] = isoDate.split("-").map(Number);
|
|
265
|
+
const date = new Date(Date.UTC(y ?? 1970, (m ?? 1) - 1, d ?? 1, 12));
|
|
266
|
+
return new Intl.DateTimeFormat(LOCALES[lang], {
|
|
267
|
+
day: "numeric",
|
|
268
|
+
month: "long",
|
|
269
|
+
weekday: withWeekday ? "long" : void 0,
|
|
270
|
+
timeZone: "UTC"
|
|
271
|
+
}).format(date);
|
|
272
|
+
}
|
|
273
|
+
function isoDateIn(timeZone, now = /* @__PURE__ */ new Date()) {
|
|
274
|
+
const parts = new Intl.DateTimeFormat("en-CA", {
|
|
275
|
+
timeZone,
|
|
276
|
+
year: "numeric",
|
|
277
|
+
month: "2-digit",
|
|
278
|
+
day: "2-digit"
|
|
279
|
+
}).formatToParts(now);
|
|
280
|
+
const get = (t) => parts.find((p) => p.type === t)?.value ?? "";
|
|
281
|
+
return `${get("year")}-${get("month")}-${get("day")}`;
|
|
282
|
+
}
|
|
283
|
+
function addDays(isoDate, days) {
|
|
284
|
+
const [y, m, d] = isoDate.split("-").map(Number);
|
|
285
|
+
const date = new Date(Date.UTC(y ?? 1970, (m ?? 1) - 1, (d ?? 1) + days));
|
|
286
|
+
return date.toISOString().slice(0, 10);
|
|
287
|
+
}
|
|
288
|
+
function formatDayMonth(isoDate) {
|
|
289
|
+
const [, m, d] = isoDate.split("-");
|
|
290
|
+
return `${d ?? ""}.${m ?? ""}`;
|
|
291
|
+
}
|
|
292
|
+
function capitalize(text, lang) {
|
|
293
|
+
return text.charAt(0).toLocaleUpperCase(LOCALES[lang]) + text.slice(1);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// src/hours.ts
|
|
297
|
+
function hoursRange(timeZone, now = /* @__PURE__ */ new Date(), days = 7) {
|
|
298
|
+
const today = isoDateIn(timeZone, now);
|
|
299
|
+
const span = Math.min(Math.max(days, 1), 61);
|
|
300
|
+
return { from: addDays(today, -1), to: addDays(today, span - 1), today };
|
|
301
|
+
}
|
|
302
|
+
function openStatus(hours, now = /* @__PURE__ */ new Date(), kind = "open") {
|
|
303
|
+
const t = now.getTime();
|
|
304
|
+
let next = null;
|
|
305
|
+
for (const day of hours.days) {
|
|
306
|
+
const k = day[kind];
|
|
307
|
+
if (!k || k.closed) continue;
|
|
308
|
+
for (const iv of k.intervals) {
|
|
309
|
+
const opens = Date.parse(iv.opens_at);
|
|
310
|
+
const closes = Date.parse(iv.closes_at);
|
|
311
|
+
if (opens <= t && t < closes)
|
|
312
|
+
return { open: true, closes_at: iv.closes_at, next_opens_at: null };
|
|
313
|
+
if (opens > t && (!next || opens < next.at)) next = { at: opens, iso: iv.opens_at };
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return { open: false, closes_at: null, next_opens_at: next?.iso ?? null };
|
|
317
|
+
}
|
|
318
|
+
function describeOpenStatus(status, lang, timeZone, now = /* @__PURE__ */ new Date()) {
|
|
319
|
+
const d = dictionary(lang);
|
|
320
|
+
if (status.open && status.closes_at) return d.closesAt(formatTime(status.closes_at, timeZone));
|
|
321
|
+
if (!status.next_opens_at) return d.closedNow;
|
|
322
|
+
const at = new Date(status.next_opens_at);
|
|
323
|
+
const time = formatTime(status.next_opens_at, timeZone);
|
|
324
|
+
const today = isoDateIn(timeZone, now);
|
|
325
|
+
const day = isoDateIn(timeZone, at);
|
|
326
|
+
const kell = lang === "et" ? "kell" : "at";
|
|
327
|
+
if (day === today) return d.opensAt(`${kell} ${time}`);
|
|
328
|
+
if (day === addDays(today, 1)) return d.opensAt(`${d.tomorrow} ${kell} ${time}`);
|
|
329
|
+
const weekday = d.weekdays[isoWeekday(day) - 1];
|
|
330
|
+
return d.opensAt(`${weekday} ${kell} ${time}`);
|
|
331
|
+
}
|
|
332
|
+
function isoWeekday(isoDate) {
|
|
333
|
+
const [y, m, d] = isoDate.split("-").map(Number);
|
|
334
|
+
const wd = new Date(Date.UTC(y ?? 1970, (m ?? 1) - 1, d ?? 1)).getUTCDay();
|
|
335
|
+
return wd === 0 ? 7 : wd;
|
|
336
|
+
}
|
|
337
|
+
function upcomingDays(hours, today, count = 7) {
|
|
338
|
+
return hours.days.filter((d) => d.date >= today).slice(0, count);
|
|
339
|
+
}
|
|
340
|
+
function weeklyPattern(hours, kind = "open") {
|
|
341
|
+
const seen = /* @__PURE__ */ new Map();
|
|
342
|
+
for (const day of hours.days) {
|
|
343
|
+
const k = day[kind];
|
|
344
|
+
if (!k || k.special || seen.has(day.weekday)) continue;
|
|
345
|
+
seen.set(day.weekday, {
|
|
346
|
+
weekday: day.weekday,
|
|
347
|
+
intervals: k.closed ? [] : k.intervals.map((i) => ({ opens: i.opens, closes: i.closes }))
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
return [...seen.values()].sort((a, b) => a.weekday - b.weekday);
|
|
351
|
+
}
|
|
352
|
+
function specialDays(hours, kind = "open") {
|
|
353
|
+
return hours.days.filter((d) => d[kind]?.special).map((d) => {
|
|
354
|
+
const k = d[kind];
|
|
355
|
+
return {
|
|
356
|
+
date: d.date,
|
|
357
|
+
closed: k.closed,
|
|
358
|
+
intervals: k.intervals.map((i) => ({ opens: i.opens, closes: i.closes })),
|
|
359
|
+
note: k.note,
|
|
360
|
+
holiday: d.holiday
|
|
361
|
+
};
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
function intervalsLabel(intervals, lang) {
|
|
365
|
+
if (intervals.length === 0) return dictionary(lang).closed;
|
|
366
|
+
return intervals.map((i) => `${i.opens}\u2013${i.closes}`).join(", ");
|
|
367
|
+
}
|
|
368
|
+
function groupWeeklyDetailed(pattern, lang) {
|
|
369
|
+
const d = dictionary(lang);
|
|
370
|
+
const out = [];
|
|
371
|
+
for (const slot of pattern) {
|
|
372
|
+
const label = intervalsLabel(slot.intervals, lang);
|
|
373
|
+
const closed = slot.intervals.length === 0;
|
|
374
|
+
const last = out[out.length - 1];
|
|
375
|
+
if (last && last.hours === label && last.to === slot.weekday - 1) last.to = slot.weekday;
|
|
376
|
+
else out.push({ from: slot.weekday, to: slot.weekday, hours: label, closed });
|
|
377
|
+
}
|
|
378
|
+
const name = (n) => d.weekdaysShort[n - 1];
|
|
379
|
+
return out.map((g) => ({
|
|
380
|
+
...g,
|
|
381
|
+
days: g.from === g.to ? name(g.from) : `${name(g.from)}\u2013${name(g.to)}`
|
|
382
|
+
}));
|
|
383
|
+
}
|
|
384
|
+
function groupWeekly(pattern, lang) {
|
|
385
|
+
return groupWeeklyDetailed(pattern, lang).map(({ days, hours }) => ({ days, hours }));
|
|
386
|
+
}
|
|
387
|
+
function specialDaysFrom(hours, kind = "open", today) {
|
|
388
|
+
return specialDays(hours, kind).filter((s) => !today || s.date >= today);
|
|
389
|
+
}
|
|
390
|
+
function splitSpecialDays(specials, table) {
|
|
391
|
+
const closed = table ? specials.filter((x) => x.closed) : [];
|
|
392
|
+
return {
|
|
393
|
+
closedDates: closed.map((x) => x.date),
|
|
394
|
+
closedDays: closed.map((x) => ({ date: x.date, note: x.note?.trim() || null })),
|
|
395
|
+
listed: table ? specials.filter((x) => !x.closed) : specials
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
function closedNoticeText(closedDates, lang) {
|
|
399
|
+
return dictionary(lang).closedOn(
|
|
400
|
+
closedDates.map((x) => {
|
|
401
|
+
if (typeof x === "string") return formatDayMonth(x);
|
|
402
|
+
const note = x.note?.trim();
|
|
403
|
+
return note ? `${formatDayMonth(x.date)} (${note})` : formatDayMonth(x.date);
|
|
404
|
+
})
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
function groupHasDay(group, today) {
|
|
408
|
+
return !!today && isoWeekday(today) >= group.from && isoWeekday(today) <= group.to;
|
|
409
|
+
}
|
|
410
|
+
function weekRowLabels(g, lang, table) {
|
|
411
|
+
const d = dictionary(lang);
|
|
412
|
+
const days = table && g.from === g.to ? capitalize(d.weekdays[g.from - 1], lang) : table ? g.days.replace("\u2013", ` ${d.to} `) : g.days;
|
|
413
|
+
const range = table ? g.hours.replaceAll("\u2013", ` ${d.to} `) : g.hours;
|
|
414
|
+
return { days, hours: table && g.closed ? capitalize(g.hours, lang) : range };
|
|
415
|
+
}
|
|
416
|
+
function noteOf(k, holiday) {
|
|
417
|
+
return k?.note || holiday ? k?.note ?? holiday : null;
|
|
418
|
+
}
|
|
419
|
+
function dayRowView(day, kind, lang, today) {
|
|
420
|
+
const d = dictionary(lang);
|
|
421
|
+
const k = day[kind];
|
|
422
|
+
const isToday = day.date === today;
|
|
423
|
+
return {
|
|
424
|
+
date: day.date,
|
|
425
|
+
isToday,
|
|
426
|
+
dateLabel: isToday ? d.today : formatDate(day.date, lang, true),
|
|
427
|
+
label: !k || k.closed ? d.closed : intervalsLabel(k.intervals, lang),
|
|
428
|
+
special: !!k?.special,
|
|
429
|
+
note: noteOf(k, day.holiday)
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
function specialRowView(s, lang) {
|
|
433
|
+
return {
|
|
434
|
+
date: s.date,
|
|
435
|
+
dateLabel: formatDate(s.date, lang, true),
|
|
436
|
+
label: s.closed ? dictionary(lang).closed : intervalsLabel(s.intervals, lang),
|
|
437
|
+
note: noteOf(s, s.holiday)
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// src/jsonld.ts
|
|
442
|
+
function jsonLdScript(data) {
|
|
443
|
+
return JSON.stringify(data).replace(/</g, "\\u003c");
|
|
444
|
+
}
|
|
445
|
+
var DAY_URLS = [
|
|
446
|
+
"https://schema.org/Monday",
|
|
447
|
+
"https://schema.org/Tuesday",
|
|
448
|
+
"https://schema.org/Wednesday",
|
|
449
|
+
"https://schema.org/Thursday",
|
|
450
|
+
"https://schema.org/Friday",
|
|
451
|
+
"https://schema.org/Saturday",
|
|
452
|
+
"https://schema.org/Sunday"
|
|
453
|
+
];
|
|
454
|
+
var DIETS = {
|
|
455
|
+
vegan: "https://schema.org/VeganDiet",
|
|
456
|
+
vegetarian: "https://schema.org/VegetarianDiet",
|
|
457
|
+
gluten_free: "https://schema.org/GlutenFreeDiet",
|
|
458
|
+
lactose_free: "https://schema.org/LowLactoseDiet"
|
|
459
|
+
};
|
|
460
|
+
function openingHoursSpecification(hours) {
|
|
461
|
+
const out = [];
|
|
462
|
+
for (const slot of weeklyPattern(hours)) {
|
|
463
|
+
for (const iv of slot.intervals) {
|
|
464
|
+
out.push({
|
|
465
|
+
"@type": "OpeningHoursSpecification",
|
|
466
|
+
dayOfWeek: DAY_URLS[slot.weekday - 1],
|
|
467
|
+
opens: iv.opens,
|
|
468
|
+
closes: iv.closes
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
for (const day of specialDays(hours)) {
|
|
473
|
+
const base = {
|
|
474
|
+
"@type": "OpeningHoursSpecification",
|
|
475
|
+
dayOfWeek: DAY_URLS[isoWeekday(day.date) - 1],
|
|
476
|
+
validFrom: day.date,
|
|
477
|
+
validThrough: day.date
|
|
478
|
+
};
|
|
479
|
+
if (day.closed || day.intervals.length === 0)
|
|
480
|
+
out.push({ ...base, opens: "00:00", closes: "00:00" });
|
|
481
|
+
else for (const iv of day.intervals) out.push({ ...base, opens: iv.opens, closes: iv.closes });
|
|
482
|
+
}
|
|
483
|
+
return out;
|
|
484
|
+
}
|
|
485
|
+
function menuItemJsonLd(item) {
|
|
486
|
+
const offers = [];
|
|
487
|
+
if (item.price) {
|
|
488
|
+
offers.push({
|
|
489
|
+
"@type": "Offer",
|
|
490
|
+
price: moneyAmount(item.price),
|
|
491
|
+
priceCurrency: item.price.currency
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
for (const v of item.variants) {
|
|
495
|
+
if (!v.price) continue;
|
|
496
|
+
offers.push({
|
|
497
|
+
"@type": "Offer",
|
|
498
|
+
name: v.name,
|
|
499
|
+
price: moneyAmount(v.price),
|
|
500
|
+
priceCurrency: v.price.currency
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
const diets = item.tags.map((t) => DIETS[t]).filter((d) => !!d);
|
|
504
|
+
return {
|
|
505
|
+
"@type": "MenuItem",
|
|
506
|
+
name: item.name,
|
|
507
|
+
...item.description ? { description: item.description } : {},
|
|
508
|
+
...item.image ? { image: item.image.url } : {},
|
|
509
|
+
...offers.length === 1 ? { offers: offers[0] } : offers.length > 1 ? { offers } : {},
|
|
510
|
+
...diets.length ? { suitableForDiet: diets.length === 1 ? diets[0] : diets } : {}
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
function menuJsonLd(menu, url) {
|
|
514
|
+
return {
|
|
515
|
+
"@type": "Menu",
|
|
516
|
+
name: menu.name,
|
|
517
|
+
...url ? { url } : {},
|
|
518
|
+
...menu.description ? { description: menu.description } : {},
|
|
519
|
+
hasMenuSection: menu.sections.map((s) => ({
|
|
520
|
+
"@type": "MenuSection",
|
|
521
|
+
name: s.name,
|
|
522
|
+
...s.description ? { description: s.description } : {},
|
|
523
|
+
hasMenuItem: s.items.map(menuItemJsonLd)
|
|
524
|
+
}))
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
function restaurantJsonLd(input) {
|
|
528
|
+
const { site, location } = input;
|
|
529
|
+
const sameAs = Object.values(site.social_links).filter((u) => /^https?:\/\//.test(u));
|
|
530
|
+
const image = input.image ?? site.logo?.url;
|
|
531
|
+
const menus = input.menus?.filter((m) => m.sections.length > 0) ?? [];
|
|
532
|
+
const hasMenu = menus.length ? menus.length === 1 ? menuJsonLd(menus[0], input.menuUrl) : menus.map((m) => menuJsonLd(m, input.menuUrl)) : input.menuUrl;
|
|
533
|
+
const phone = location?.phone ?? site.contact.phone;
|
|
534
|
+
const email = location?.email ?? site.contact.email;
|
|
535
|
+
return {
|
|
536
|
+
"@context": "https://schema.org",
|
|
537
|
+
"@type": "Restaurant",
|
|
538
|
+
"@id": `${input.url.replace(/\/$/, "")}/#restaurant`,
|
|
539
|
+
name: site.name,
|
|
540
|
+
url: input.url,
|
|
541
|
+
...image ? { image } : {},
|
|
542
|
+
...site.logo ? { logo: site.logo.url } : {},
|
|
543
|
+
...phone ? { telephone: phone } : {},
|
|
544
|
+
...email ? { email } : {},
|
|
545
|
+
...location?.address ? {
|
|
546
|
+
address: {
|
|
547
|
+
"@type": "PostalAddress",
|
|
548
|
+
streetAddress: location.address,
|
|
549
|
+
...location.city ? { addressLocality: location.city } : {},
|
|
550
|
+
...location.postcode ? { postalCode: location.postcode } : {},
|
|
551
|
+
addressCountry: location.country
|
|
552
|
+
}
|
|
553
|
+
} : site.contact.address ? { address: site.contact.address } : {},
|
|
554
|
+
...location?.geo ? {
|
|
555
|
+
geo: {
|
|
556
|
+
"@type": "GeoCoordinates",
|
|
557
|
+
latitude: location.geo.lat,
|
|
558
|
+
longitude: location.geo.lng
|
|
559
|
+
}
|
|
560
|
+
} : {},
|
|
561
|
+
...location?.google_maps_url ? { hasMap: location.google_maps_url } : {},
|
|
562
|
+
...input.hours ? { openingHoursSpecification: openingHoursSpecification(input.hours) } : {},
|
|
563
|
+
...input.servesCuisine?.length ? { servesCuisine: input.servesCuisine } : {},
|
|
564
|
+
...input.priceRange ? { priceRange: input.priceRange } : {},
|
|
565
|
+
acceptsReservations: site.booking_mode !== null,
|
|
566
|
+
...hasMenu ? { hasMenu } : {},
|
|
567
|
+
...sameAs.length ? { sameAs } : {}
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
// src/seo.ts
|
|
572
|
+
function buildSitemap(opts) {
|
|
573
|
+
const langs = opts.langs ?? SITE_LANGS;
|
|
574
|
+
const out = [];
|
|
575
|
+
for (const r of opts.routes) {
|
|
576
|
+
const languages = {};
|
|
577
|
+
for (const l of langs) languages[l] = absoluteUrl(opts.baseUrl, r.paths[l]);
|
|
578
|
+
languages["x-default"] = absoluteUrl(opts.baseUrl, r.paths.et);
|
|
579
|
+
for (const l of langs) {
|
|
580
|
+
out.push({
|
|
581
|
+
url: absoluteUrl(opts.baseUrl, r.paths[l]),
|
|
582
|
+
...opts.lastModified ? { lastModified: opts.lastModified } : {},
|
|
583
|
+
...r.changeFrequency ? { changeFrequency: r.changeFrequency } : {},
|
|
584
|
+
...r.priority !== void 0 ? { priority: r.priority } : {},
|
|
585
|
+
alternates: { languages }
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
return out;
|
|
590
|
+
}
|
|
591
|
+
function buildRobots(opts) {
|
|
592
|
+
if (opts.noindex) return { rules: { userAgent: "*", disallow: "/" } };
|
|
593
|
+
return {
|
|
594
|
+
rules: { userAgent: "*", allow: "/", disallow: ["/api/"] },
|
|
595
|
+
sitemap: absoluteUrl(opts.baseUrl, "/sitemap.xml")
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
function alternatesFor(baseUrl, paths, lang) {
|
|
599
|
+
return {
|
|
600
|
+
canonical: absoluteUrl(baseUrl, paths[lang]),
|
|
601
|
+
languages: {
|
|
602
|
+
et: absoluteUrl(baseUrl, paths.et),
|
|
603
|
+
en: absoluteUrl(baseUrl, paths.en),
|
|
604
|
+
"x-default": absoluteUrl(baseUrl, paths.et)
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
function buildLlmsTxt(input) {
|
|
609
|
+
const { site, location, lang } = input;
|
|
610
|
+
const et2 = lang === "et";
|
|
611
|
+
const url = (p) => absoluteUrl(input.baseUrl, p);
|
|
612
|
+
const lines = [`# ${site.name}`, ""];
|
|
613
|
+
if (input.summary) lines.push(`> ${input.summary}`, "");
|
|
614
|
+
lines.push(et2 ? "## Asukoht ja kontakt" : "## Location and contact", "");
|
|
615
|
+
const address = location ? [location.address, [location.postcode, location.city].filter(Boolean).join(" ")].filter(Boolean).join(", ") : site.contact.address;
|
|
616
|
+
if (address) lines.push(`- ${et2 ? "Aadress" : "Address"}: ${address}`);
|
|
617
|
+
const phone = location?.phone ?? site.contact.phone;
|
|
618
|
+
if (phone) lines.push(`- ${et2 ? "Telefon" : "Phone"}: ${phone}`);
|
|
619
|
+
const email = location?.email ?? site.contact.email;
|
|
620
|
+
if (email) lines.push(`- ${et2 ? "E-post" : "Email"}: ${email}`);
|
|
621
|
+
if (location?.google_maps_url)
|
|
622
|
+
lines.push(`- ${et2 ? "Kaart" : "Map"}: ${location.google_maps_url}`);
|
|
623
|
+
lines.push(`- ${et2 ? "Koduleht" : "Website"}: ${url("/")}`, "");
|
|
624
|
+
if (input.hours) {
|
|
625
|
+
lines.push(et2 ? "## Lahtiolekuajad" : "## Opening hours", "");
|
|
626
|
+
for (const g of groupWeekly(weeklyPattern(input.hours), lang))
|
|
627
|
+
lines.push(`- ${g.days}: ${g.hours}`);
|
|
628
|
+
for (const s of specialDays(input.hours)) {
|
|
629
|
+
const label = s.closed ? et2 ? "suletud" : "closed" : s.intervals.map((i) => `${i.opens}\u2013${i.closes}`).join(", ");
|
|
630
|
+
const why = s.note ?? s.holiday;
|
|
631
|
+
lines.push(`- ${s.date}: ${label}${why ? ` (${why})` : ""}`);
|
|
632
|
+
}
|
|
633
|
+
lines.push("");
|
|
634
|
+
}
|
|
635
|
+
const offer = input.lunch?.offer;
|
|
636
|
+
if (offer) {
|
|
637
|
+
lines.push(et2 ? `## P\xE4evapakkumine ${offer.date}` : `## Lunch ${offer.date}`, "");
|
|
638
|
+
if (offer.served_from && offer.served_to)
|
|
639
|
+
lines.push(`${offer.served_from}\u2013${offer.served_to}`, "");
|
|
640
|
+
if (offer.set_price)
|
|
641
|
+
lines.push(`- ${et2 ? "Komplekt" : "Set menu"}: ${formatMoney(offer.set_price, lang)}`);
|
|
642
|
+
for (const i of offer.items)
|
|
643
|
+
lines.push(`- ${i.name}${i.price ? `: ${formatMoney(i.price, lang)}` : ""}`);
|
|
644
|
+
lines.push("");
|
|
645
|
+
}
|
|
646
|
+
const max = input.maxItemsPerSection ?? 30;
|
|
647
|
+
lines.push(et2 ? "## Men\xFC\xFC" : "## Menu", "", url(input.links.menu), "");
|
|
648
|
+
for (const menu of input.menus ?? []) {
|
|
649
|
+
lines.push(`### ${menu.name}`, "");
|
|
650
|
+
for (const s of menu.sections) {
|
|
651
|
+
lines.push(`#### ${s.name}`, "");
|
|
652
|
+
for (const i of s.items.slice(0, max)) {
|
|
653
|
+
const price = i.price ? formatMoney(i.price, lang) : i.variants.map((v) => `${v.name} ${formatMoney(v.price, lang)}`.trim()).join(" / ");
|
|
654
|
+
lines.push(`- ${i.name}${price ? `: ${price}` : ""}`);
|
|
655
|
+
}
|
|
656
|
+
lines.push("");
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
lines.push(et2 ? "## Broneerimine" : "## Booking", "");
|
|
660
|
+
const b = input.booking?.locations[0];
|
|
661
|
+
const mode = input.booking?.mode ?? site.booking_mode;
|
|
662
|
+
if ((mode === "provider" || mode === "both") && b?.provider_url) {
|
|
663
|
+
lines.push(`- ${et2 ? "Broneeri veebis" : "Book online"}: ${b.provider_url}`);
|
|
664
|
+
}
|
|
665
|
+
if ((mode === "request" || mode === "both") && input.links.booking) {
|
|
666
|
+
lines.push(`- ${et2 ? "Broneeringusoov" : "Booking request"}: ${url(input.links.booking)}`);
|
|
667
|
+
}
|
|
668
|
+
if (phone) lines.push(`- ${et2 ? "Helista" : "Call"}: ${phone}`);
|
|
669
|
+
if (input.links.events)
|
|
670
|
+
lines.push(`- ${et2 ? "\xDCritused ja grupid" : "Events and groups"}: ${url(input.links.events)}`);
|
|
671
|
+
lines.push("");
|
|
672
|
+
return lines.join("\n");
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// src/allergens.ts
|
|
676
|
+
var ALLERGEN_CODES = {
|
|
677
|
+
gluten: "G",
|
|
678
|
+
crustaceans: "V",
|
|
679
|
+
eggs: "M",
|
|
680
|
+
fish: "K",
|
|
681
|
+
peanuts: "H",
|
|
682
|
+
soybeans: "O",
|
|
683
|
+
milk: "L",
|
|
684
|
+
nuts: "P",
|
|
685
|
+
celery: "T",
|
|
686
|
+
mustard: "N",
|
|
687
|
+
sesame: "E",
|
|
688
|
+
sulphites: "F",
|
|
689
|
+
lupin: "U",
|
|
690
|
+
molluscs: "B"
|
|
691
|
+
};
|
|
692
|
+
function allergenLetter(a, codes) {
|
|
693
|
+
return codes?.[a.code] ?? ALLERGEN_CODES[a.code];
|
|
694
|
+
}
|
|
695
|
+
function allergenName(a, lang) {
|
|
696
|
+
return a.name || dictionary(lang).allergenNames[a.code];
|
|
697
|
+
}
|
|
698
|
+
function uniqueAllergens(allergens) {
|
|
699
|
+
const seen = /* @__PURE__ */ new Map();
|
|
700
|
+
for (const a of allergens) if (!seen.has(a.code)) seen.set(a.code, a);
|
|
701
|
+
return [...seen.values()];
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
// src/menu.ts
|
|
705
|
+
function priceLabel(price, lang) {
|
|
706
|
+
return price ? formatMoney(price, lang) : null;
|
|
707
|
+
}
|
|
708
|
+
function soldOutUntilLabel(until, lang) {
|
|
709
|
+
return until ? ` (${formatDate(until, lang)})` : null;
|
|
710
|
+
}
|
|
711
|
+
function menuHeadings(menuCount, showMenuNames, headingLevel) {
|
|
712
|
+
const showNames = showMenuNames ?? menuCount > 1;
|
|
713
|
+
return { showNames, sectionLevel: showNames ? headingLevel + 1 : headingLevel };
|
|
714
|
+
}
|
|
715
|
+
function menuAllergens(menu) {
|
|
716
|
+
return menu.sections.flatMap((section) => section.items.flatMap((i) => i.allergens));
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
// src/lunch.ts
|
|
720
|
+
function lunchIsToday(date, today) {
|
|
721
|
+
return !!today && date === today;
|
|
722
|
+
}
|
|
723
|
+
function lunchDayLabel(date, lang) {
|
|
724
|
+
const d = dictionary(lang);
|
|
725
|
+
return `${capitalize(d.weekdays[isoWeekday(date) - 1], lang)}, ${formatDayMonth(date)}`;
|
|
726
|
+
}
|
|
727
|
+
function hasLunchOffer(lunch) {
|
|
728
|
+
return !!lunch.offer && lunch.offer.items.length > 0;
|
|
729
|
+
}
|
|
730
|
+
function lunchEmpty(lunch, lang) {
|
|
731
|
+
const d = dictionary(lang);
|
|
732
|
+
return {
|
|
733
|
+
message: d.noLunch,
|
|
734
|
+
next: lunch.next_date ? d.nextLunch(formatDate(lunch.next_date, lang, true)) : null
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
function lunchServed(offer, lang) {
|
|
738
|
+
return offer.served_from && offer.served_to ? dictionary(lang).servedBetween(offer.served_from, offer.served_to) : null;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
// src/events.ts
|
|
742
|
+
function eventDateParts(isoDate, lang) {
|
|
743
|
+
const [y, m, d] = isoDate.split("-").map(Number);
|
|
744
|
+
const date = new Date(Date.UTC(y ?? 1970, (m ?? 1) - 1, d ?? 1, 12));
|
|
745
|
+
const locale = lang === "et" ? "et-EE" : "en-GB";
|
|
746
|
+
return {
|
|
747
|
+
month: new Intl.DateTimeFormat(locale, { month: "short", timeZone: "UTC" }).format(date).replace(/\.$/, ""),
|
|
748
|
+
day: String(d ?? "").padStart(2, "0")
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
function eventAvailability(soldOut, seatsLeft, lang) {
|
|
752
|
+
const d = dictionary(lang);
|
|
753
|
+
return {
|
|
754
|
+
soldOutLabel: soldOut ? d.events.soldOut : null,
|
|
755
|
+
seatsText: !soldOut && seatsLeft !== void 0 ? d.events.seatsLeft(seatsLeft) : null
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
// src/blocks.ts
|
|
760
|
+
function safeHref(value) {
|
|
761
|
+
if (typeof value !== "string") return null;
|
|
762
|
+
const v = value.trim();
|
|
763
|
+
if (v.length === 0 || v.length > 2e3) return null;
|
|
764
|
+
if (v.startsWith("/") && !v.startsWith("//") && !v.includes("\\")) return v;
|
|
765
|
+
if (v.startsWith("#")) return v;
|
|
766
|
+
if (/^(https?:\/\/|mailto:|tel:)/i.test(v)) return v;
|
|
767
|
+
return null;
|
|
768
|
+
}
|
|
769
|
+
function safeImageSrc(value) {
|
|
770
|
+
if (typeof value !== "string") return null;
|
|
771
|
+
return /^https?:\/\//i.test(value.trim()) ? value.trim() : null;
|
|
772
|
+
}
|
|
773
|
+
function blockString(b, key) {
|
|
774
|
+
const v = b[key];
|
|
775
|
+
return typeof v === "string" && v.trim().length > 0 ? v : null;
|
|
776
|
+
}
|
|
777
|
+
function blockHeadingLevel(b) {
|
|
778
|
+
const level = b.level;
|
|
779
|
+
return level === 3 ? 3 : level === 4 ? 4 : 2;
|
|
780
|
+
}
|
|
781
|
+
function blockCta(b) {
|
|
782
|
+
const href = safeHref(blockString(b, "href") ?? blockString(b, "url"));
|
|
783
|
+
const label = blockString(b, "label") ?? blockString(b, "text");
|
|
784
|
+
if (!href || !label) return null;
|
|
785
|
+
return { href, label, external: /^https?:\/\//i.test(href) };
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
// src/contact.ts
|
|
789
|
+
function telHref(phone) {
|
|
790
|
+
return `tel:${phone.replace(/[^+\d]/g, "")}`;
|
|
791
|
+
}
|
|
792
|
+
function mailtoHref(email) {
|
|
793
|
+
return `mailto:${email}`;
|
|
794
|
+
}
|
|
795
|
+
function contactPayload(v) {
|
|
796
|
+
return { name: v.name ?? "", email: v.email ?? "", phone: v.phone, message: v.message ?? "" };
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
// src/booking.ts
|
|
800
|
+
function maxBookingDate(today, maxDaysAhead) {
|
|
801
|
+
return maxDaysAhead ? addDays(today, maxDaysAhead) : void 0;
|
|
802
|
+
}
|
|
803
|
+
function partyLimits(booking) {
|
|
804
|
+
return { min: booking?.min_party ?? 1, max: booking?.max_party ?? 20 };
|
|
805
|
+
}
|
|
806
|
+
function clampParty(n, min, max) {
|
|
807
|
+
return Math.min(Math.max(n, min), max);
|
|
808
|
+
}
|
|
809
|
+
function initialParty(min, max) {
|
|
810
|
+
return Math.min(Math.max(2, min), max);
|
|
811
|
+
}
|
|
812
|
+
function bookingDayCount(days, maxDaysAhead) {
|
|
813
|
+
return Math.min(days, (maxDaysAhead ?? days - 1) + 1);
|
|
814
|
+
}
|
|
815
|
+
function bookingDays(today, count, lang) {
|
|
816
|
+
const d = dictionary(lang);
|
|
817
|
+
return Array.from({ length: count }, (_, i) => {
|
|
818
|
+
const iso = addDays(today, i);
|
|
819
|
+
const top = i === 0 ? d.booking.today : i === 1 ? d.booking.tomorrow : d.weekdaysShort[isoWeekday(iso) - 1].toLocaleUpperCase(lang);
|
|
820
|
+
return { iso, top: capitalize(top, lang), main: formatDayMonth(iso) };
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
function bookingSlots(slots, selected) {
|
|
824
|
+
const list = (slots ?? []).map((s) => ({
|
|
825
|
+
time: s.time,
|
|
826
|
+
disabled: !!s.full,
|
|
827
|
+
pressed: s.time === selected
|
|
828
|
+
}));
|
|
829
|
+
return { slots: list, anyFull: list.some((s) => s.disabled) };
|
|
830
|
+
}
|
|
831
|
+
function bookingPayload(locationId, v) {
|
|
832
|
+
return {
|
|
833
|
+
...locationId ? { location_id: locationId } : {},
|
|
834
|
+
date: v.date ?? "",
|
|
835
|
+
time: v.time ?? "",
|
|
836
|
+
party_size: v.party_size,
|
|
837
|
+
name: v.name ?? "",
|
|
838
|
+
phone: v.phone ?? ""
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
function bookingRequestPayload(locationId, v) {
|
|
842
|
+
return { ...bookingPayload(locationId, v), email: v.email, note: v.note };
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
// src/event-request.ts
|
|
846
|
+
var EVENT_KINDS = ["company", "birthday", "wedding", "other"];
|
|
847
|
+
function budgetToCents(euros) {
|
|
848
|
+
if (euros === void 0) return void 0;
|
|
849
|
+
const n = Number(euros.replace(",", "."));
|
|
850
|
+
return Number.isFinite(n) ? Math.round(n * 100) : Number.NaN;
|
|
851
|
+
}
|
|
852
|
+
function packagePriceLabel(pk, lang) {
|
|
853
|
+
if (!pk.price) return "";
|
|
854
|
+
const unit = pk.price_unit === "per_person" ? ` ${dictionary(lang).form.perPerson}` : "";
|
|
855
|
+
return ` \u2013 ${formatMoney(pk.price, lang)}${unit}`;
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
// src/forms.ts
|
|
859
|
+
var TOKEN_MAX_AGE_MS = 90 * 60 * 1e3;
|
|
860
|
+
var TOKEN_MIN_AGE_MS = 3500;
|
|
861
|
+
function cleanText(v) {
|
|
862
|
+
if (typeof v !== "string") return void 0;
|
|
863
|
+
const s = v.trim();
|
|
864
|
+
return s.length ? s : void 0;
|
|
865
|
+
}
|
|
866
|
+
function cleanInt(v) {
|
|
867
|
+
const s = cleanText(v);
|
|
868
|
+
if (s === void 0) return void 0;
|
|
869
|
+
const n = Number(s);
|
|
870
|
+
return Number.isInteger(n) ? n : Number.NaN;
|
|
871
|
+
}
|
|
872
|
+
function clientFieldErrors(issues, body, form) {
|
|
873
|
+
const errs = {};
|
|
874
|
+
for (const issue of issues) {
|
|
875
|
+
const key = String(issue.path[0] ?? "");
|
|
876
|
+
if (!key || errs[key]) continue;
|
|
877
|
+
const empty = body[key] === void 0 || body[key] === "";
|
|
878
|
+
const short = issue.code === "too_small" && !empty && key in form.tooShort ? form.tooShort[key] : void 0;
|
|
879
|
+
errs[key] = empty ? form.required : short ?? (key === "email" ? form.invalidEmail : form.invalid);
|
|
880
|
+
}
|
|
881
|
+
return errs;
|
|
882
|
+
}
|
|
883
|
+
function failureMessage(form, phone) {
|
|
884
|
+
return phone ? form.failedCall(phone) : form.failed;
|
|
885
|
+
}
|
|
886
|
+
function submitFailure(res, form, phone) {
|
|
887
|
+
if (res.status === 422 && Object.keys(res.fieldErrors).length > 0) {
|
|
888
|
+
const errors = {};
|
|
889
|
+
for (const key of Object.keys(res.fieldErrors)) {
|
|
890
|
+
const field = key.split(".")[0] ?? key;
|
|
891
|
+
errors[field] = field === "email" ? form.invalidEmail : form.invalid;
|
|
892
|
+
}
|
|
893
|
+
return { errors, message: null };
|
|
894
|
+
}
|
|
895
|
+
if (res.status === 429) return { errors: {}, message: form.rateLimited };
|
|
896
|
+
return { errors: {}, message: failureMessage(form, phone) };
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
// src/track.ts
|
|
900
|
+
var MOBILE_QUERY = "(max-width: 767px)";
|
|
901
|
+
function trackBody(input) {
|
|
902
|
+
const path = input.path.slice(0, 300) || "/";
|
|
903
|
+
let ref;
|
|
904
|
+
try {
|
|
905
|
+
const r = input.referrer ? new URL(input.referrer) : null;
|
|
906
|
+
if (r && r.host !== input.host) ref = r.host;
|
|
907
|
+
} catch {
|
|
908
|
+
ref = void 0;
|
|
909
|
+
}
|
|
910
|
+
return {
|
|
911
|
+
name: input.name,
|
|
912
|
+
path,
|
|
913
|
+
lang: input.lang,
|
|
914
|
+
device: input.mobile ? "mobile" : "desktop",
|
|
915
|
+
...ref ? { ref } : {}
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
// src/tabs.ts
|
|
920
|
+
function nextTabIndex(key, current, count) {
|
|
921
|
+
if (count <= 0) return null;
|
|
922
|
+
const wrap = (i) => (i + count) % count;
|
|
923
|
+
if (key === "ArrowRight") return wrap(current + 1);
|
|
924
|
+
if (key === "ArrowLeft") return wrap(current - 1);
|
|
925
|
+
if (key === "Home") return 0;
|
|
926
|
+
if (key === "End") return count - 1;
|
|
927
|
+
return null;
|
|
928
|
+
}
|
|
929
|
+
export {
|
|
930
|
+
ALLERGEN_CODES,
|
|
931
|
+
DEFAULT_SITE_LANG,
|
|
932
|
+
DICTIONARIES,
|
|
933
|
+
EVENT_KINDS,
|
|
934
|
+
MOBILE_QUERY,
|
|
935
|
+
SITE_LANGS,
|
|
936
|
+
TOKEN_MAX_AGE_MS,
|
|
937
|
+
TOKEN_MIN_AGE_MS,
|
|
938
|
+
absoluteUrl,
|
|
939
|
+
addDays,
|
|
940
|
+
allergenLetter,
|
|
941
|
+
allergenName,
|
|
942
|
+
alternatesFor,
|
|
943
|
+
blockCta,
|
|
944
|
+
blockHeadingLevel,
|
|
945
|
+
blockString,
|
|
946
|
+
bookingDayCount,
|
|
947
|
+
bookingDays,
|
|
948
|
+
bookingPayload,
|
|
949
|
+
bookingRequestPayload,
|
|
950
|
+
bookingSlots,
|
|
951
|
+
budgetToCents,
|
|
952
|
+
buildLlmsTxt,
|
|
953
|
+
buildRobots,
|
|
954
|
+
buildSitemap,
|
|
955
|
+
capitalize,
|
|
956
|
+
clampParty,
|
|
957
|
+
cleanInt,
|
|
958
|
+
cleanText,
|
|
959
|
+
clientFieldErrors,
|
|
960
|
+
closedNoticeText,
|
|
961
|
+
contactPayload,
|
|
962
|
+
dayRowView,
|
|
963
|
+
describeOpenStatus,
|
|
964
|
+
dictionary,
|
|
965
|
+
eventAvailability,
|
|
966
|
+
eventDateParts,
|
|
967
|
+
failureMessage,
|
|
968
|
+
formatDate,
|
|
969
|
+
formatDayMonth,
|
|
970
|
+
formatMoney,
|
|
971
|
+
formatTime,
|
|
972
|
+
groupHasDay,
|
|
973
|
+
groupWeekly,
|
|
974
|
+
groupWeeklyDetailed,
|
|
975
|
+
hasLunchOffer,
|
|
976
|
+
hoursRange,
|
|
977
|
+
initialParty,
|
|
978
|
+
intervalsLabel,
|
|
979
|
+
isSiteLang,
|
|
980
|
+
isoDateIn,
|
|
981
|
+
isoWeekday,
|
|
982
|
+
jsonLdScript,
|
|
983
|
+
localePath,
|
|
984
|
+
lunchDayLabel,
|
|
985
|
+
lunchEmpty,
|
|
986
|
+
lunchIsToday,
|
|
987
|
+
lunchServed,
|
|
988
|
+
mailtoHref,
|
|
989
|
+
maxBookingDate,
|
|
990
|
+
menuAllergens,
|
|
991
|
+
menuHeadings,
|
|
992
|
+
menuJsonLd,
|
|
993
|
+
moneyAmount,
|
|
994
|
+
nextTabIndex,
|
|
995
|
+
openStatus,
|
|
996
|
+
openingHoursSpecification,
|
|
997
|
+
packagePriceLabel,
|
|
998
|
+
partyLimits,
|
|
999
|
+
priceLabel,
|
|
1000
|
+
restaurantJsonLd,
|
|
1001
|
+
safeHref,
|
|
1002
|
+
safeImageSrc,
|
|
1003
|
+
safePath,
|
|
1004
|
+
soldOutUntilLabel,
|
|
1005
|
+
specialDays,
|
|
1006
|
+
specialDaysFrom,
|
|
1007
|
+
specialRowView,
|
|
1008
|
+
splitLocale,
|
|
1009
|
+
splitSpecialDays,
|
|
1010
|
+
submitFailure,
|
|
1011
|
+
telHref,
|
|
1012
|
+
trackBody,
|
|
1013
|
+
uniqueAllergens,
|
|
1014
|
+
upcomingDays,
|
|
1015
|
+
weekRowLabels,
|
|
1016
|
+
weeklyPattern
|
|
1017
|
+
};
|