1(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([typeof document === "object" ? document.currentScript : undefined, 282922, ((__turbopack_context__) => { 3"use strict"; 4 5const CATEGORY_BY_TYPE = { 6 meeting: "meeting", 7 call: "meeting", 8 "video-call": "meeting", 9 event: "event", 10 webinar: "event", 11 task: "task", 12 todo: "task", 13 deadline: "task" 14}; 15function categoryOf(interactionType) { 16 return CATEGORY_BY_TYPE[interactionType] ?? "other"; 17} 18function countByCategory(items) { 19 let meetings = 0; 20 let events = 0; 21 for (const item of items){ 22 if (item.category === "meeting") meetings += 1; 23 else if (item.category === "event") events += 1; 24 } 25 return { 26 all: items.length, 27 meetings, 28 events 29 }; 30} 31; 32__turbopack_context__.s([ 33 "categoryOf", 34 0, 35 categoryOf, 36 "countByCategory", 37 0, 38 countByCategory 39]); 40}), 41490186, ((__turbopack_context__) => { 42"use strict"; 43 44const EDITOR_DRAFT_CONFLICT_ID = "__draft__"; 45function sharesActor(first, second) { 46 if (first.ownerUserId && second.ownerUserId && first.ownerUserId === second.ownerUserId) return true; 47 if (first.participants.length === 0 || second.participants.length === 0) return false; 48 const firstParticipantIds = new Set(first.participants.map((participant)=>participant.userId)); 49 return second.participants.some((participant)=>firstParticipantIds.has(participant.userId)); 50} 51function isActor(item, userId) { 52 if (item.ownerUserId === userId) return true; 53 return item.participants.some((participant)=>participant.userId === userId); 54} 55function appendConflict(conflicts, itemId, otherId) { 56 const existing = conflicts.get(itemId); 57 if (existing) existing.push(otherId); 58 else conflicts.set(itemId, [ 59 otherId 60 ]); 61} 62function findConflicts(items, options = {}) { 63 const conflicts = /* @__PURE__ */ new Map(); 64 const restrictToCurrentUser = options.scope === "mine" && Boolean(options.currentUserId); 65 const currentUserId = options.currentUserId ?? ""; 66 const candidates = items.filter((item)=>item.status !== "canceled").sort((first, second)=>first.start.getTime() - second.start.getTime()); 67 for(let index = 0; index < candidates.length; index += 1){ 68 const current = candidates[index]; 69 const currentEnd = current.end.getTime(); 70 for(let lookahead = index + 1; lookahead < candidates.length; lookahead += 1){ 71 const other = candidates[lookahead]; 72 if (other.start.getTime() >= currentEnd) break; 73 if (current.start.getTime() >= other.end.getTime()) continue; 74 if (!sharesActor(current, other)) continue; 75 if (restrictToCurrentUser && !(isActor(current, currentUserId) && isActor(other, currentUserId))) continue; 76 appendConflict(conflicts, current.id, other.id); 77 appendConflict(conflicts, other.id, current.id); 78 } 79 } 80 return conflicts; 81} 82function findEditorConflictItems(draft, others, excludeId, options = {}) { 83 const draftStatus = draft.status ?? "planned"; 84 const draftItem = { 85 id: EDITOR_DRAFT_CONFLICT_ID, 86 title: "", 87 interactionType: "meeting", 88 category: "other", 89 status: draftStatus, 90 start: draft.start, 91 end: draft.end, 92 allDay: false, 93 location: null, 94 platform: null, 95 locationKind: null, 96 participants: draft.participants, 97 ownerUserId: draft.ownerUserId, 98 entityId: null, 99 dealId: null, 100 color: null, 101 isRecurringOccurrence: false, 102 updatedAt: null, 103 raw: { 104 id: EDITOR_DRAFT_CONFLICT_ID, 105 interactionType: "meeting", 106 status: draftStatus 107 } 108 }; 109 const candidates = others.filter((item)=>item.id !== EDITOR_DRAFT_CONFLICT_ID && item.raw.id !== excludeId); 110 const conflictIds = findConflicts([ 111 draftItem, 112 ...candidates 113 ], options).get(EDITOR_DRAFT_CONFLICT_ID) ?? []; 114 const byId = new Map(candidates.map((item)=>[ 115 item.id, 116 item 117 ])); 118 return conflictIds.map((id)=>byId.get(id)).filter((item)=>Boolean(item)); 119} 120; 121__turbopack_context__.s([ 122 "findConflicts", 123 0, 124 findConflicts, 125 "findEditorConflictItems", 126 0, 127 findEditorConflictItems 128]); 129}), 130467550, ((__turbopack_context__) => { 131"use strict"; 132 133var __TURBOPACK__imported__module__595727__ = __turbopack_context__.i(595727); 134var __TURBOPACK__imported__module__688594__ = __turbopack_context__.i(688594); 135var __TURBOPACK__imported__module__433331__ = __turbopack_context__.i(433331); 136var __TURBOPACK__imported__module__145963__ = __turbopack_context__.i(145963); 137var __TURBOPACK__imported__module__39978__ = __turbopack_context__.i(39978); 138var __TURBOPACK__imported__module__707935__ = __turbopack_context__.i(707935); 139var __TURBOPACK__imported__module__585890__ = __turbopack_context__.i(585890); 140var __TURBOPACK__imported__module__608199__ = __turbopack_context__.i(608199); 141var __TURBOPACK__imported__module__614522__ = __turbopack_context__.i(614522); 142; 143; 144; 145; 146; 147; 148; 149; 150; 151const MONDAY_WEEK = { 152 weekStartsOn: 1 153}; 154function getVisibleRange(view, anchor, agendaHorizonDays) { 155 switch(view){ 156 case "day": 157 return { 158 from: (0, __TURBOPACK__imported__module__585890__["startOfDay"])(anchor), 159 to: (0, __TURBOPACK__imported__module__145963__["endOfDay"])(anchor) 160 }; 161 case "week": 162 return { 163 from: (0, __TURBOPACK__imported__module__614522__["startOfWeek"])(anchor, MONDAY_WEEK), 164 to: (0, __TURBOPACK__imported__module__707935__["endOfWeek"])(anchor, MONDAY_WEEK) 165 }; 166 case "month": 167 return { 168 from: (0, __TURBOPACK__imported__module__614522__["startOfWeek"])((0, __TURBOPACK__imported__module__608199__["startOfMonth"])(anchor), MONDAY_WEEK), 169 to: (0, __TURBOPACK__imported__module__707935__["endOfWeek"])((0, __TURBOPACK__imported__module__39978__["endOfMonth"])(anchor), MONDAY_WEEK) 170 }; 171 case "agenda": 172 return { 173 from: (0, __TURBOPACK__imported__module__585890__["startOfDay"])(anchor), 174 to: (0, __TURBOPACK__imported__module__145963__["endOfDay"])((0, __TURBOPACK__imported__module__595727__["addDays"])(anchor, agendaHorizonDays)) 175 }; 176 } 177} 178function getFetchWindow(range) { 179 return { 180 from: (0, __TURBOPACK__imported__module__595727__["addDays"])(range.from, -1), 181 to: range.to 182 }; 183} 184function shiftAnchor(view, anchor, direction) { 185 switch(view){ 186 case "day": 187 return (0, __TURBOPACK__imported__module__595727__["addDays"])(anchor, direction); 188 case "week": 189 return (0, __TURBOPACK__imported__module__433331__["addWeeks"])(anchor, direction); 190 case "month": 191 return (0, __TURBOPACK__imported__module__688594__["addMonths"])(anchor, direction); 192 case "agenda": 193 return (0, __TURBOPACK__imported__module__595727__["addDays"])(anchor, direction * 7); 194 } 195} 196; 197__turbopack_context__.s([ 198 "getFetchWindow", 199 0, 200 getFetchWindow, 201 "getVisibleRange", 202 0, 203 getVisibleRange 204]); 205}), 206938359, ((__turbopack_context__) => { 207"use strict"; 208 209const MS_PER_DAY = 24 * 60 * 60 * 1e3; 210function pluralCategory(locale, count) { 211 try { 212 return new Intl.PluralRules(locale).select(count); 213 } catch { 214 return count === 1 ? "one" : "other"; 215 } 216} 217function eventDisplayTitle(title, fallback) { 218 return title && title.trim().length > 0 ? title : fallback; 219} 220function composeAccessibleName(parts, separator = ", ") { 221 return parts.map((part)=>typeof part === "string" ? part.trim() : "").filter((part)=>part.length > 0).join(separator); 222} 223function parseDateInput(value) { 224 const parsed = /* @__PURE__ */ new Date(`${value}T00:00:00`); 225 return parsed.getTime(); 226} 227function multiDayEventSpan(startDate, endDate) { 228 const start = parseDateInput(startDate); 229 const end = parseDateInput(endDate); 230 if (Number.isNaN(start) || Number.isNaN(end)) return 0; 231 const dayDiff = Math.round((end - start) / MS_PER_DAY); 232 if (dayDiff < 1) return 0; 233 return dayDiff + 1; 234} 235; 236__turbopack_context__.s([ 237 "composeAccessibleName", 238 0, 239 composeAccessibleName, 240 "eventDisplayTitle", 241 0, 242 eventDisplayTitle, 243 "multiDayEventSpan", 244 0, 245 multiDayEventSpan, 246 "pluralCategory", 247 0, 248 pluralCategory 249]); 250}), 251221709, ((__turbopack_context__) => { 252"use strict"; 253 254var __TURBOPACK__imported__module__843476__ = __turbopack_context__.i(843476); 255var __TURBOPACK__imported__module__406911__ = __turbopack_context__.i(406911); 256var __TURBOPACK__imported__module__110035__ = __turbopack_context__.i(110035); 257"use client"; 258; 259; 260; 261function SegmentGroup({ options, value, onChange, size = "sm", ariaLabel }) { 262 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsx"])("div", { 263 role: "group", 264 "aria-label": ariaLabel, 265 className: "flex w-full items-stretch overflow-hidden rounded-md border border-border bg-background", 266 children: options.map((option, index)=>{ 267 const isActive = option.value === value; 268 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsxs"])(__TURBOPACK__imported__module__110035__["Button"], { 269 type: "button", 270 variant: "ghost", 271 "aria-pressed": isActive, 272 onClick: ()=>onChange(option.value), 273 title: option.label, 274 "data-state": isActive ? "active" : "inactive", 275 className: (0, __TURBOPACK__imported__module__406911__["cn"])("h-auto min-w-0 flex-1 justify-center gap-1 rounded-none border-0 px-1.5 text-sm font-medium leading-5 shadow-none", size === "md" ? "py-2" : "py-1.5", index > 0 && "border-l border-border", isActive ? "bg-accent-indigo font-semibold text-accent-indigo-foreground hover:bg-accent-indigo hover:text-accent-indigo-foreground dark:hover:bg-accent-indigo" : "bg-background text-muted-foreground hover:bg-muted hover:text-foreground"), 276 children: [
277 option.icon ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsx"])("span", { 278 "aria-hidden": true, 279 className: (0, __TURBOPACK__imported__module__406911__["cn"])("shrink-0", isActive ? "opacity-100" : "opacity-70"), 280 children: option.icon 281 }) : null, 282 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsx"])("span", { 283 className: "truncate", 284 children: option.label 285 }) 286 ] 287 }, option.value); 288 }) 289 }); 290} 291; 292__turbopack_context__.s([ 293 "SegmentGroup", 294 0, 295 SegmentGroup 296]); 297}), 298137858, ((__turbopack_context__) => { 299"use strict"; 300 301var __TURBOPACK__imported__module__595727__ = __turbopack_context__.i(595727); 302; 303const MAX_OCCURRENCES_PER_WINDOW = 100; 304const WEEKDAY_TOKENS = [ 305 "SU", 306 "MO", 307 "TU", 308 "WE", 309 "TH", 310 "FR", 311 "SA" 312]; 313const UNTIL_PATTERN = /^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z$/; 314function parseUntil(value) { 315 const match = UNTIL_PATTERN.exec(value); 316 if (!match) return null; 317 const [, year, month, day, hours, minutes, seconds] = match; 318 const parsed = new Date(Date.UTC(Number(year), Number(month) - 1, Number(day), Number(hours), Number(minutes), Number(seconds))); 319 return Number.isNaN(parsed.getTime()) ? null : parsed; 320} 321function parseRecurrenceRule(rule) { 322 const parts = rule.split(";").map((part)=>part.trim()).filter((part)=>part.length > 0); 323 if (parts.length === 0) return null; 324 let freq = null; 325 let byDay = null; 326 let count = null; 327 let until = null; 328 for (const part of parts){ 329 const separatorIndex = part.indexOf("="); 330 if (separatorIndex <= 0) return null; 331 const key = part.slice(0, separatorIndex).toUpperCase(); 332 const value = part.slice(separatorIndex + 1); 333 if (key === "FREQ") { 334 if (value !== "DAILY" && value !== "WEEKLY") return null; 335 freq = value; 336 } else if (key === "BYDAY") { 337 const tokens = value.split(",").map((token)=>token.trim().toUpperCase()).filter((token)=>token.length > 0); 338 if (tokens.length === 0) return null; 339 const weekdays = []; 340 for (const token of tokens){ 341 const weekday = WEEKDAY_TOKENS.indexOf(token); 342 if (weekday === -1) return null; 343 weekdays.push(weekday); 344 } 345 byDay = weekdays; 346 } else if (key === "COUNT") { 347 const parsedCount = Number(value); 348 if (!Number.isInteger(parsedCount) || parsedCount < 1) return null; 349 count = parsedCount; 350 } else if (key === "UNTIL") { 351 const parsedUntil = parseUntil(value); 352 if (!parsedUntil) return null; 353 until = parsedUntil; 354 } else { 355 return null; 356 } 357 } 358 if (!freq) return null; 359 return { 360 freq, 361 byDay, 362 count, 363 until 364 }; 365} 366function parseRecurrenceEndTime(rawRecurrenceEnd) { 367 if (typeof rawRecurrenceEnd !== "string" || rawRecurrenceEnd.length === 0) return null; 368 const parsed = new Date(rawRecurrenceEnd); 369 if (Number.isNaN(parsed.getTime())) return null; 370 const endOfDayLocal = new Date(parsed.getUTCFullYear(), parsed.getUTCMonth(), parsed.getUTCDate(), 23, 59, 59, 999); 371 return endOfDayLocal.getTime(); 372} 373function occursOn(date, rule, seriesStartWeekday) { 374 if (rule.freq === "DAILY") return true; 375 const allowedWeekdays = rule.byDay ?? [ 376 seriesStartWeekday 377 ]; 378 return allowedWeekdays.includes(date.getDay()); 379} 380function expandOccurrences(item, range) { 381 const rawRule = item.raw.recurrenceRule; 382 if (typeof rawRule !== "string" || rawRule.trim().length === 0) return [ 383 item 384 ]; 385 const rule = parseRecurrenceRule(rawRule); 386 if (!rule) return [ 387 item 388 ]; 389 const durationMs = item.end.getTime() - item.start.getTime(); 390 const recurrenceEndTime = parseRecurrenceEndTime(item.raw.recurrenceEnd); 391 const untilTime = rule.until ? rule.until.getTime() : null; 392 const seriesStartWeekday = item.start.getDay(); 393 const occurrences = []; 394 let occurrenceIndex = 0;
395 let cursor = new Date(item.start); 396 while(cursor.getTime() <= range.to.getTime()){ 397 if (untilTime !== null && cursor.getTime() > untilTime) break; 398 if (recurrenceEndTime !== null && cursor.getTime() > recurrenceEndTime) break; 399 if (occursOn(cursor, rule, seriesStartWeekday)) { 400 if (rule.count !== null && occurrenceIndex >= rule.count) break; 401 const occurrenceStart = new Date(cursor); 402 const occurrenceEnd = new Date(occurrenceStart.getTime() + durationMs); 403 if (occurrenceStart.getTime() <= range.to.getTime() && occurrenceEnd.getTime() > range.from.getTime()) { 404 occurrences.push({ 405 ...item, 406 id: `${item.id}:${occurrenceIndex}`, 407 start: occurrenceStart, 408 end: occurrenceEnd, 409 isRecurringOccurrence: true 410 }); 411 if (occurrences.length >= MAX_OCCURRENCES_PER_WINDOW) break; 412 } 413 occurrenceIndex += 1; 414 } 415 cursor = (0, __TURBOPACK__imported__module__595727__["addDays"])(cursor, 1); 416 } 417 return occurrences; 418} 419; 420__turbopack_context__.s([ 421 "expandOccurrences", 422 0, 423 expandOccurrences, 424 "parseRecurrenceRule", 425 0, 426 parseRecurrenceRule 427]); 428}), 429250630, ((__turbopack_context__) => { 430"use strict"; 431 432var __TURBOPACK__imported__module__234662__ = __turbopack_context__.i(234662); 433var __TURBOPACK__imported__module__281092__ = __turbopack_context__.i(281092); 434; 435; 436function addMinutes(date, amount, options) { 437 const _date = (0, __TURBOPACK__imported__module__281092__["toDate"])(date, options?.in); 438 _date.setTime(_date.getTime() + amount * __TURBOPACK__imported__module__234662__["millisecondsInMinute"]); 439 return _date; 440} 441const __TURBOPACK__default__export__ = addMinutes; 442__turbopack_context__.s([ 443 "addMinutes", 444 0, 445 addMinutes 446]); 447}), 448924008, ((__turbopack_context__) => { 449"use strict"; 450 451var __TURBOPACK__imported__module__250630__ = __turbopack_context__.i(250630); 452var __TURBOPACK__imported__module__145963__ = __turbopack_context__.i(145963); 453var __TURBOPACK__imported__module__585890__ = __turbopack_context__.i(585890); 454var __TURBOPACK__imported__module__82922__ = __turbopack_context__.i(82922); 455; 456; 457; 458; 459const DEFAULT_DURATION_MINUTES = 30; 460function narrowStatus(status) { 461 if (status === "done") return "done"; 462 if (status === "canceled") return "canceled"; 463 return "planned"; 464} 465function detectPlatform(location) { 466 if (!location) return null; 467 const normalized = location.toLowerCase(); 468 if (normalized.includes("zoom.us") || normalized.includes("zoom")) return "zoom"; 469 if (normalized.includes("meet.google") || normalized.includes("on meet")) return "meet"; 470 if (normalized.includes("slack")) return "slack"; 471 if (normalized.includes("teams")) return "teams"; 472 return null; 473} 474function detectLocationKind(location, platform) { 475 if (!location) return null; 476 const normalized = location.trim().toLowerCase(); 477 if (normalized.startsWith("http") || normalized.startsWith("www")) return "url"; 478 if (platform) return "platform"; 479 return "venue"; 480} 481function mapParticipants(payload) { 482 const participants = payload.participants; 483 if (!Array.isArray(participants)) return []; 484 const seen = /* @__PURE__ */ new Set(); 485 const mapped = []; 486 for (const participant of participants){ 487 if (seen.has(participant.userId)) continue; 488 seen.add(participant.userId); 489 const entry = { 490 userId: participant.userId 491 }; 492 if (typeof participant.name === "string") entry.name = participant.name; 493 if (typeof participant.email === "string") entry.email = participant.email; 494 mapped.push(entry); 495 } 496 return mapped; 497} 498function mapInteractionToCalendarItem(payload, typeColorByType) { 499 const effectiveStartRaw = payload.occurredAt ?? payload.scheduledAt ?? null; 500 if (!effectiveStartRaw) return null; 501 const parsedStart = new Date(effectiveStartRaw); 502 if (Number.isNaN(parsedStart.getTime())) return null; 503 const allDay = payload.allDay === true; 504 const durationMinutes = payload.durationMinutes ?? DEFAULT_DURATION_MINUTES; 505 const start = allDay ? (0, __TURBOPACK__imported__module__585890__["startOfDay"])(parsedStart) : parsedStart; 506 const end = allDay ? (0, __TURBOPACK__imported__module__145963__["endOfDay"])(parsedStart) : (0, __TURBOPACK__imported__module__250630__["addMinutes"])(parsedStart, durationMinutes); 507 const location = payload.location ?? null; 508 const platform = detectPlatform(location); 509 return { 510 id: payload.id, 511 title: payload.title ?? "", 512 interactionType: payload.interactionType, 513 category: (0, __TURBOPACK__imported__module__82922__["categoryOf"])(payload.interactionType), 514 status: narrowStatus(payload.status), 515 start, 516 end, 517 allDay, 518 location, 519 platform, 520 locationKind: detectLocationKind(location, platform), 521 participants: mapParticipants(payload), 522 ownerUserId: payload.ownerUserId ?? null, 523 entityId: payload.entityId ?? null, 524 dealId: payload.dealId ?? null, 525 color: payload.appearanceColor ?? typeColorByType[payload.interactionType] ?? null, 526 isRecurringOccurrence: false, 527 updatedAt: payload.updatedAt ?? null, 528 raw: payload 529 }; 530} 531; 532__turbopack_context__.s([ 533 "mapInteractionToCalendarItem", 534 0, 535 mapInteractionToCalendarItem 536]); 537}), 538451523, ((__turbopack_context__) => { 539"use strict"; 540 541// MERGED MODULE: [project]/node_modules/@open-mercato/core/dist/modules/customers/components/calendar/u
541seCalendarItems.js [app-client] (ecmascript) 542; 543var __TURBOPACK__imported__module__271645__ = __turbopack_context__.i(271645); 544var __TURBOPACK__imported__module__490746__ = __turbopack_context__.i(490746); 545var __TURBOPACK__imported__module__137858__ = __turbopack_context__.i(137858); 546var __TURBOPACK__imported__module__467550__ = __turbopack_context__.i(467550); 547var __TURBOPACK__imported__module__924008__ = __turbopack_context__.i(924008); 548// MERGED MODULE: [project]/node_modules/@open-mercato/core/dist/modules/customers/components/calendar/types.js [app-client] (ecmascript) 549; 550var __TURBOPACK__imported__module__681307__ = __turbopack_context__.i(681307); 551; 552const calendarParticipantSchema = __TURBOPACK__imported__module__681307__["z"].object({ 553 userId: __TURBOPACK__imported__module__681307__["z"].string(), 554 name: __TURBOPACK__imported__module__681307__["z"].string().optional(), 555 email: __TURBOPACK__imported__module__681307__["z"].string().optional() 556}).passthrough(); 557const calendarInteractionPayloadSchema = __TURBOPACK__imported__module__681307__["z"].object({ 558 id: __TURBOPACK__imported__module__681307__["z"].string(), 559 interactionType: __TURBOPACK__imported__module__681307__["z"].string(), 560 title: __TURBOPACK__imported__module__681307__["z"].string().nullable().optional(), 561 status: __TURBOPACK__imported__module__681307__["z"].string(), 562 scheduledAt: __TURBOPACK__imported__module__681307__["z"].string().nullable().optional(), 563 occurredAt: __TURBOPACK__imported__module__681307__["z"].string().nullable().optional(), 564 durationMinutes: __TURBOPACK__imported__module__681307__["z"].number().nullable().optional(), 565 allDay: __TURBOPACK__imported__module__681307__["z"].boolean().nullable().optional(), 566 location: __TURBOPACK__imported__module__681307__["z"].string().nullable().optional(), 567 participants: __TURBOPACK__imported__module__681307__["z"].array(calendarParticipantSchema).nullable().optional(), 568 recurrenceRule: __TURBOPACK__imported__module__681307__["z"].string().nullable().optional(), 569 recurrenceEnd: __TURBOPACK__imported__module__681307__["z"].string().nullable().optional(), 570 appearanceIcon: __TURBOPACK__imported__module__681307__["z"].string().nullable().optional(), 571 appearanceColor: __TURBOPACK__imported__module__681307__["z"].string().nullable().optional(), 572 ownerUserId: __TURBOPACK__imported__module__681307__["z"].string().nullable().optional(), 573 entityId: __TURBOPACK__imported__module__681307__["z"].string().nullable().optional(), 574 dealId: __TURBOPACK__imported__module__681307__["z"].string().nullable().optional(), 575 updatedAt: __TURBOPACK__imported__module__681307__["z"].string().nullable().optional() 576}).passthrough(); 577; 578"use client"; 579; 580; 581; 582; 583; 584; 585const PAGE_LIMIT = 100; 586const MAX_WINDOW_ITEMS = 500; 587async function fetchInteractionWindow(window, signal) { 588 const collected = []; 589 let cursor; 590 let truncated = false; 591 do { 592 const params = new URLSearchParams({ 593 from: window.from.toISOString(), 594 to: window.to.toISOString(), 595 limit: String(PAGE_LIMIT) 596 }); 597 if (cursor) params.set("cursor", cursor); 598 const call = await (0, __TURBOPACK__imported__module__490746__["apiCall"])(`/api/customers/interactions?${params.toString()}`, { 599 signal 600 }); 601 if (!call.ok) throw new Error(`[internal] calendar interactions fetch failed (${call.status})`); 602 const pageItems = Array.isArray(call.result?.items) ? call.result.items : []; 603 for (const rawItem of pageItems){ 604 const parsed = calendarInteractionPayloadSchema.safeParse(rawItem); 605 if (parsed.success) collected.push(parsed.data); 606 } 607 cursor = typeof call.result?.nextCursor === "string" ? call.result.nextCursor : void 0; 608 if (cursor && collected.length >= MAX_WINDOW_ITEMS) { 609 truncated = true; 610 cursor = void 0; 611 } 612 }while (cursor) 613 return { 614 payloads: collected.slice(0, MAX_WINDOW_ITEMS), 615 truncated 616 }; 617} 618function useCalendarItems(range) { 619 const [payloads, setPayloads] = __TURBOPACK__imported__module__271645__["useState"]([]); 620 const [isLoading, setIsLoading] = __TURBOPACK__imported__module__271645__["useState"](true); 621 const [error, setError] = __TURBOPACK__imported__module__271645__["useState"](null); 622 const [truncated, setTruncated] = __TURBOPACK__imported__module__271645__["useState"](false); 623 const [typeLabels, setTypeLabels] = __TURBOPACK__imported__module__271645__["useState"]({}); 624 const [typeColors, setTypeColors] = __TURBOPACK__imported__module__271645__["useState"]({}); 625 const [typeIcons, setTypeIcons] = __TURBOPACK__imported__module__271645__["useState"]({}); 626 const [reloadToken, setReloadToken] = __TURBOPACK__imported__module__271645__["useState"](0); 627 const fromTime = range.from.getTime(); 628 const toTime = range.to.getTime(); 629 __TURBOPACK__imported__module__271645__["useEffect"](()=>{ 630 const controller = new AbortController(); 631 let cancelled = false;
632 async function loadActivityTypes() { 633 const call = await (0, __TURBOPACK__imported__module__490746__["apiCall"])("/api/customers/dictionaries/activity-types", { 634 signal: controller.signal 635 }); 636 if (cancelled || !call.ok) return; 637 const entries = Array.isArray(call.result?.items) ? call.result.items : []; 638 const labels = {}; 639 const colors = {}; 640 const icons = {}; 641 for (const entry of entries){ 642 if (typeof entry?.value !== "string" || entry.value.length === 0) continue; 643 labels[entry.value] = typeof entry.label === "string" && entry.label.length > 0 ? entry.label : entry.value; 644 colors[entry.value] = typeof entry.color === "string" && entry.color.length > 0 ? entry.color : null; 645 icons[entry.value] = typeof entry.icon === "string" && entry.icon.length > 0 ? entry.icon : null; 646 } 647 setTypeLabels(labels); 648 setTypeColors(colors); 649 setTypeIcons(icons); 650 } 651 loadActivityTypes().catch(()=>{ 652 if (cancelled || controller.signal.aborted) return; 653 setTypeLabels({}); 654 setTypeColors({}); 655 setTypeIcons({}); 656 }); 657 return ()=>{ 658 cancelled = true; 659 controller.abort(); 660 }; 661 }, []); 662 __TURBOPACK__imported__module__271645__["useEffect"](()=>{ 663 const controller = new AbortController(); 664 let cancelled = false; 665 async function loadInteractions() { 666 setIsLoading(true); 667 setError(null); 668 try { 669 const fetchWindow = (0, __TURBOPACK__imported__module__467550__["getFetchWindow"])({ 670 from: new Date(fromTime), 671 to: new Date(toTime) 672 }); 673 const { payloads: collected, truncated: windowTruncated } = await fetchInteractionWindow(fetchWindow, controller.signal); 674 if (cancelled) return; 675 setPayloads(collected); 676 setTruncated(windowTruncated); 677 } catch (err) { 678 if (cancelled || controller.signal.aborted) return; 679 setPayloads([]); 680 setTruncated(false); 681 setError(err instanceof Error ? err.message : "[internal] calendar interactions fetch failed"); 682 } finally{ 683 if (!cancelled) setIsLoading(false); 684 } 685 } 686 void loadInteractions(); 687 return ()=>{ 688 cancelled = true; 689 controller.abort(); 690 }; 691 }, [ 692 fromTime, 693 toTime, 694 reloadToken 695 ]); 696 const items = __TURBOPACK__imported__module__271645__["useMemo"](()=>{ 697 const expansionWindow = (0, __TURBOPACK__imported__module__467550__["getFetchWindow"])({ 698 from: new Date(fromTime), 699 to: new Date(toTime) 700 }); 701 const mapped = []; 702 for (const payload of payloads){ 703 const item = (0, __TURBOPACK__imported__module__924008__["mapInteractionToCalendarItem"])(payload, typeColors); 704 if (!item) continue; 705 mapped.push(...(0, __TURBOPACK__imported__module__137858__["expandOccurrences"])(item, expansionWindow)); 706 } 707 return mapped; 708 }, [ 709 payloads, 710 typeColors, 711 fromTime, 712 toTime 713 ]); 714 const refetch = __TURBOPACK__imported__module__271645__["useCallback"](()=>{ 715 setReloadToken((token)=>token + 1); 716 }, []); 717 return { 718 items, 719 isLoading, 720 error, 721 truncated, 722 typeLabels, 723 typeColors, 724 typeIcons, 725 refetch 726 }; 727} 728; 729__turbopack_context__.s([ 730 "MAX_WINDOW_ITEMS", 731 0, 732 MAX_WINDOW_ITEMS, 733 "fetchInteractionWindow", 734 0, 735 fetchInteractionWindow, 736 "useCalendarItems", 737 0, 738 useCalendarItems 739], 451523); 740}), 741603662, ((__turbopack_context__) => { 742"use strict"; 743 744/** 745 * @license lucide-react v0.556.0 - ISC 746 * 747 * This source code is licensed under the ISC license. 748 * See the LICENSE file in the root directory of this source tree. 749 */ var __TURBOPACK__imported__module__475254__ = __turbopack_context__.i(475254); 750; 751const __iconNode = [ 752 [ 753 "rect", 754 { 755 width: "18", 756 height: "18", 757 x: "3", 758 y: "4", 759 rx: "2", 760 key: "1hopcy" 761 } 762 ], 763 [ 764 "path", 765 { 766 d: "M16 2v4", 767 key: "4m81vk" 768 } 769 ], 770 [ 771 "path", 772 { 773 d: "M3 10h18", 774 key: "8toen8" 775 } 776 ], 777 [ 778 "path", 779 { 780 d: "M8 2v4", 781 key: "1cmpym" 782 } 783 ], 784 [ 785 "path", 786 { 787 d: "M17 14h-6", 788 key: "bkmgh3" 789 } 790 ], 791 [ 792 "path", 793 { 794 d: "M13 18H7", 795 key: "bb0bb7" 796 } 797 ], 798 [ 799 "path", 800 { 801 d: "M7 14h.01", 802 key: "1qa3f1" 803 } 804 ], 805 [ 806 "path", 807 { 808 d: "M17 18h.01", 809 key: "1bdyru" 810 } 811 ] 812]; 813const CalendarRange = (0, __TURBOPACK__imported__module__475254__["default"])("calendar-range", __iconNode); 814; 815__turbopack_context__.s([ 816 "default", 817 0, 818 CalendarRange 819]); 820}), 821123197, ((__turbopack_context__) => { 822"use strict"; 823 824// MERGED MODULE: [project]/node_modules/@open-mercato/core/dist/modules/customers/components/calendar/CalendarScreen.js [app-client] (ecmascript) 825; 826var __TURBOPACK__imported__module__843476__ = __turbopack_context__.i(843476); 827var __TURBOPACK__imported__module__271645__ = __turbopack_context__.i(271645);
828var __TURBOPACK__imported__module__770703__ = __turbopack_context__.i(770703); 829var __TURBOPACK__imported__module__595727__ = __turbopack_context__.i(595727); 830// MERGED MODULE: [project]/node_modules/date-fns/isSameDay.js [app-client] (ecmascript) 831; 832var __TURBOPACK__imported__module__845110__ = __turbopack_context__.i(845110); 833var __TURBOPACK__imported__module__585890__ = __turbopack_context__.i(585890); 834; 835; 836function isSameDay(laterDate, earlierDate, options) { 837 const [dateLeft_, dateRight_] = (0, __TURBOPACK__imported__module__845110__["normalizeDates"])(options?.in, laterDate, earlierDate); 838 return +(0, __TURBOPACK__imported__module__585890__["startOfDay"])(dateLeft_) === +(0, __TURBOPACK__imported__module__585890__["startOfDay"])(dateRight_); 839} 840const __TURBOPACK__default__export__ = isSameDay; 841var __TURBOPACK__imported__module__928441__ = __turbopack_context__.i(928441); 842var __TURBOPACK__imported__module__490746__ = __turbopack_context__.i(490746); 843var __TURBOPACK__imported__module__752019__ = __turbopack_context__.i(752019); 844var __TURBOPACK__imported__module__977896__ = __turbopack_context__.i(977896); 845var __TURBOPACK__imported__module__484973__ = __turbopack_context__.i(484973); 846var __TURBOPACK__imported__module__714073__ = __turbopack_context__.i(714073); 847var __TURBOPACK__imported__module__475503__ = __turbopack_context__.i(475503); 848var __TURBOPACK__imported__module__445299__ = __turbopack_context__.i(445299); 849var __TURBOPACK__imported__module__360341__ = __turbopack_context__.i(360341); 850var __TURBOPACK__imported__module__110035__ = __turbopack_context__.i(110035); 851var __TURBOPACK__imported__module__82922__ = __turbopack_context__.i(82922); 852var __TURBOPACK__imported__module__490186__ = __turbopack_context__.i(490186); 853var __TURBOPACK__imported__module__467550__ = __turbopack_context__.i(467550); 854// MERGED MODULE: [project]/node_modules/@open-mercato/core/dist/modules/customers/components/calendar/AgendaList.js [app-client] (ecmascript) 855; 856var __TURBOPACK__imported__module__843476__1 = __TURBOPACK__imported__module__843476__; 857var __TURBOPACK__imported__module__271645__1 = __TURBOPACK__imported__module__271645__; 858var __TURBOPACK__imported__module__595727__1 = __TURBOPACK__imported__module__595727__; 859var __TURBOPACK__imported__module__401851__ = __turbopack_context__.i(401851); 860// MERGED MODULE: [project]/node_modules/date-fns/isToday.js [app-client] (ecmascript) 861; 862var __TURBOPACK__imported__module__677241__ = __turbopack_context__.i(677241); 863var __TURBOPACK__imported__module__24708__ = __turbopack_context__.i(24708); 864; 865; 866; 867function isToday(date, options) { 868 return isSameDay((0, __TURBOPACK__imported__module__677241__["constructFrom"])(options?.in || date, date), (0, __TURBOPACK__imported__module__24708__["constructNow"])(options?.in || date)); 869} 870const __TURBOPACK__default__export__1 = isToday; 871// MERGED MODULE: [project]/node_modules/date-fns/isTomorrow.js [app-client] (ecmascript) 872; 873var __TURBOPACK__imported__module__595727__2 = __TURBOPACK__imported__module__595727__; 874var __TURBOPACK__imported__module__24708__1 = __TURBOPACK__imported__module__24708__; 875; 876; 877; 878function isTomorrow(date, options) { 879 return isSameDay(date, (0, __TURBOPACK__imported__module__595727__2["addDays"])((0, __TURBOPACK__imported__module__24708__1["constructNow"])(options?.in || date), 1), options); 880} 881const __TURBOPACK__default__export__2 = isTomorrow; 882var __TURBOPACK__imported__module__585890__1 = __TURBOPACK__imported__module__585890__; 883var __TURBOPACK__imported__module__928441__1 = __TURBOPACK__imported__module__928441__; 884var __TURBOPACK__imported__module__406911__ = __turbopack_context__.i(406911); 885var __TURBOPACK__imported__module__791576__ = __turbopack_context__.i(791576); 886var __TURBOPACK__imported__module__110035__1 = __TURBOPACK__imported__module__110035__; 887var __TURBOPACK__imported__module__938359__ = __turbopack_context__.i(938359); 888"use client"; 889; 890; 891; 892; 893; 894; 895; 896; 897; 898; 899; 900; 901const MAX_AVATARS_PER_ROW = 2; 902const CATEGORY_BADGE_CLASS = { 903 meeting: "bg-status-info-bg text-status-info-text", 904 event: "bg-status-warning-bg text-status-warning-text", 905 task: "bg-primary text-primary-foreground", 906 other: "bg-status-neutral-bg text-status-neutral-text" 907}; 908const CATEGORY_LABEL = { 909 meeting: { 910 key: "customers.calendar.category.meeting", 911 fallback: "Meeting" 912 }, 913 event: { 914 key: "customers.calendar.category.event", 915 fallback: "Event" 916 }, 917 task: { 918 key: "customers.calendar.category.task", 919 fallback: "Task" 920 }, 921 other: { 922 key: "customers.calendar.category.other", 923 fallback: "Other" 924 } 925}; 926function dayKeyOf(date) { 927 return (0, __TURBOPACK__imported__module__401851__["format"])(date, "yyyy-MM-dd"); 928} 929function formatUrlHost(location) { 930 try { 931 const url = new URL(location.startsWith("http") ? location : `https://${location}`); 932 return url.hostname; 933 } catch { 934 return location; 935 } 936}
937function formatTime(date) { 938 return date.toLocaleTimeString(void 0, { 939 hour: "numeric", 940 minute: "2-digit" 941 }); 942} 943function groupLabelOf(date) { 944 return date.toLocaleDateString(void 0, { 945 weekday: "long", 946 month: "short", 947 day: "numeric" 948 }); 949} 950function deriveTypeLabel(interactionType) { 951 const normalized = interactionType.replace(/[-_]+/g, " ").trim(); 952 if (!normalized) return interactionType; 953 return normalized.charAt(0).toUpperCase() + normalized.slice(1); 954} 955function participantLabel(participant) { 956 return participant.name ?? participant.email ?? participant.userId; 957} 958function buildDayGroups(anchor, horizonDays, items) { 959 const sorted = [ 960 ...items 961 ].sort((first, second)=>first.start.getTime() - second.start.getTime()); 962 const byDay = /* @__PURE__ */ new Map(); 963 for (const item of sorted){ 964 const key = dayKeyOf(item.start); 965 const bucket = byDay.get(key); 966 if (bucket) bucket.push(item); 967 else byDay.set(key, [ 968 item 969 ]); 970 } 971 const firstDay = (0, __TURBOPACK__imported__module__585890__1["startOfDay"])(anchor); 972 const groups = []; 973 for(let offset = 0; offset <= horizonDays; offset += 1){ 974 const day = (0, __TURBOPACK__imported__module__595727__1["addDays"])(firstDay, offset); 975 const dayItems = byDay.get(dayKeyOf(day)); 976 if (dayItems && dayItems.length > 0) groups.push({ 977 date: day, 978 items: dayItems 979 }); 980 } 981 return groups; 982} 983function AgendaDayHeader({ date, count }) { 984 const t = (0, __TURBOPACK__imported__module__928441__1["useT"])(); 985 const locale = (0, __TURBOPACK__imported__module__928441__1["useLocale"])(); 986 const todayMarker = isToday(date); 987 const tomorrowMarker = !todayMarker && isTomorrow(date); 988 const countKey = `customers.calendar.agenda.eventsCount.${(0, __TURBOPACK__imported__module__938359__["pluralCategory"])(locale, count)}`; 989 const resolvedCount = t(countKey, { 990 count 991 }); 992 const countLabel = resolvedCount === countKey ? t("customers.calendar.agenda.eventsCount.other", "{count} events", { 993 count 994 }) : resolvedCount; 995 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsxs"])("div", { 996 className: "flex w-full items-center gap-2 bg-muted/50 px-3 py-2.5 sm:px-5", 997 children: [
998 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])("span", { 999 className: "text-sm font-semibold text-foreground", 1000 children: groupLabelOf(date) 1001 }), 1002 todayMarker || tomorrowMarker ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])("span", { 1003 className: (0, __TURBOPACK__imported__module__406911__["cn"])("text-xs font-medium", todayMarker ? "text-foreground" : "text-muted-foreground"), 1004 children: `\xB7 ${todayMarker ? t("customers.calendar.agenda.today", "Today") : t("customers.calendar.agenda.tomorrow", "Tomorrow")}` 1005 }) : null, 1006 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])("span", { 1007 "aria-hidden": "true", 1008 className: "w-2.5 shrink-0" 1009 }), 1010 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])("span", { 1011 className: "text-xs font-medium text-muted-foreground", 1012 children: countLabel 1013 }) 1014 ] 1015 }); 1016} 1017function AgendaRow({ item, typeLabels, onItemClick }) { 1018 const t = (0, __TURBOPACK__imported__module__928441__1["useT"])(); 1019 const canceled = item.status === "canceled"; 1020 const done = item.status === "done"; 1021 const title = (0, __TURBOPACK__imported__module__938359__["eventDisplayTitle"])(item.title, t("customers.calendar.grid.untitled", "Untitled")); 1022 const typeLabel = typeLabels?.[item.interactionType] ?? deriveTypeLabel(item.interactionType); 1023 const platformLabels = { 1024 zoom: t("customers.calendar.platformFull.zoom", "Zoom"), 1025 meet: t("customers.calendar.platformFull.meet", "Google Meet"), 1026 slack: t("customers.calendar.platformFull.slack", "Slack"), 1027 teams: t("customers.calendar.platformFull.teams", "Microsoft Teams") 1028 }; 1029 const locationLabel = item.platform ? platformLabels[item.platform] : item.locationKind === "url" && item.location ? formatUrlHost(item.location) : item.location; 1030 const startLabel = item.allDay ? t("customers.calendar.grid.allDay", "All day") : formatTime(item.start); 1031 const endLabel = item.allDay ? null : formatTime(item.end); 1032 const ariaTime = item.allDay ? startLabel : `${startLabel} \u2013 ${endLabel}`; 1033 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsxs"])(__TURBOPACK__imported__module__110035__1["Button"], { 1034 type: "button", 1035 variant: "ghost", 1036 "aria-label": `${title} \xB7 ${ariaTime}`, 1037 onClick: ()=>onItemClick(item), 1038 className: (0, __TURBOPACK__imported__module__406911__["cn"])("h-auto w-full justify-start whitespace-normal rounded-none bg-background px-3 py-3 text-left transition-colors hover:bg-muted/30 sm:gap-3.5 sm:px-5", canceled && "opacity-60"), 1039 children: [
1040 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsxs"])("div", { 1041 className: "flex w-16 shrink-0 flex-col gap-0.5 sm:w-[86px]", 1042 children: [ 1043 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])("span", { 1044 className: (0, __TURBOPACK__imported__module__406911__["cn"])("truncate text-sm font-semibold leading-4", done || canceled ? "text-muted-foreground" : "text-foreground"), 1045 children: startLabel 1046 }), 1047 endLabel ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])("span", { 1048 className: "truncate text-xs text-muted-foreground", 1049 children: endLabel 1050 }) : null 1051 ] 1052 }), 1053 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])("span", { 1054 "aria-hidden": "true", 1055 className: (0, __TURBOPACK__imported__module__406911__["cn"])("h-9 w-1 shrink-0 rounded-full", !item.color && "bg-muted-foreground/40"), 1056 style: item.color ? { 1057 backgroundColor: item.color 1058 } : void 0 1059 }),
1060 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsxs"])("div", { 1061 className: "flex min-w-0 flex-1 flex-col gap-0.5", 1062 children: [ 1063 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])("span", { 1064 className: (0, __TURBOPACK__imported__module__406911__["cn"])("truncate text-sm font-semibold", done || canceled ? "text-muted-foreground" : "text-foreground", canceled && "line-through"), 1065 children: title 1066 }), 1067 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])("span", { 1068 className: "truncate text-xs text-muted-foreground", 1069 children: locationLabel ? `${typeLabel} \xB7 ${locationLabel}` : typeLabel 1070 }) 1071 ] 1072 }), 1073 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsxs"])("div", { 1074 className: "flex shrink-0 items-center gap-2", 1075 children: [ 1076 item.participants.length > 0 ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsxs"])("span", { 1077 className: "hidden items-center gap-0.5 sm:flex", 1078 children: [ 1079 item.participants.slice(0, MAX_AVATARS_PER_ROW).map((participant)=>/* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])(__TURBOPACK__imported__module__791576__["Avatar"], { 1080 size: "xs", 1081 label: participantLabel(participant) 1082 }, participant.userId)), 1083 item.participants.length > MAX_AVATARS_PER_ROW ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsxs"])("span", { 1084 className: "ps-0.5 text-xs font-medium text-muted-foreground", 1085 children: [ 1086 "+", 1087 item.participants.length - MAX_AVATARS_PER_ROW 1088 ] 1089 }) : null 1090 ] 1091 }) : null,
1092 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])("span", { 1093 className: (0, __TURBOPACK__imported__module__406911__["cn"])("inline-flex shrink-0 items-center rounded-full px-2 py-0.5 text-overline font-medium uppercase tracking-wide", CATEGORY_BADGE_CLASS[item.category]), 1094 children: t(CATEGORY_LABEL[item.category].key, CATEGORY_LABEL[item.category].fallback) 1095 }) 1096 ] 1097 }) 1098 ] 1099 }); 1100} 1101function AgendaList({ anchor, horizonDays, items, typeLabels, onItemClick }) { 1102 const t = (0, __TURBOPACK__imported__module__928441__1["useT"])(); 1103 const groups = __TURBOPACK__imported__module__271645__1["useMemo"](()=>buildDayGroups(anchor, horizonDays, items), [ 1104 anchor, 1105 horizonDays, 1106 items 1107 ]); 1108 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])("div", { 1109 className: "flex w-full flex-col divide-y divide-border overflow-hidden border border-border bg-background", 1110 children: groups.map((group)=>/* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsxs"])(__TURBOPACK__imported__module__271645__1["Fragment"], { 1111 children: [
1112 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])(AgendaDayHeader, { 1113 date: group.date, 1114 count: group.items.length 1115 }), 1116 group.items.map((item)=>/* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])(AgendaRow, { 1117 item, 1118 typeLabels, 1119 onItemClick 1120 }, item.id)) 1121 ] 1122 }, dayKeyOf(group.date))) 1123 }); 1124} 1125; 1126// MERGED MODULE: [project]/node_modules/@open-mercato/core/dist/modules/customers/components/calendar/CalendarFooter.js [app-client] (ecmascript) 1127; 1128var __TURBOPACK__imported__module__843476__2 = __TURBOPACK__imported__module__843476__; 1129var __TURBOPACK__imported__module__110035__2 = __TURBOPACK__imported__module__110035__; 1130var __TURBOPACK__imported__module__443530__ = __turbopack_context__.i(443530); 1131var __TURBOPACK__imported__module__928441__2 = __TURBOPACK__imported__module__928441__; 1132"use client"; 1133; 1134; 1135; 1136; 1137const CALENDAR_SHORTCUTS = [ 1138 { 1139 key: "T", 1140 labelKey: "customers.calendar.shortcuts.today", 1141 fallback: "Today" 1142 }, 1143 { 1144 key: "D", 1145 labelKey: "customers.calendar.shortcuts.dayView", 1146 fallback: "Day view" 1147 }, 1148 { 1149 key: "W", 1150 labelKey: "customers.calendar.shortcuts.week", 1151 fallback: "Week" 1152 }, 1153 { 1154 key: "M", 1155 labelKey: "customers.calendar.shortcuts.month", 1156 fallback: "Month" 1157 }, 1158 { 1159 key: "A", 1160 labelKey: "customers.calendar.shortcuts.agenda", 1161 fallback: "Agenda" 1162 }, 1163 { 1164 key: "N", 1165 labelKey: "customers.calendar.shortcuts.newEvent", 1166 fallback: "New event" 1167 }, 1168 { 1169 key: "/", 1170 labelKey: "customers.calendar.shortcuts.search", 1171 fallback: "Search" 1172 }, 1173 { 1174 key: "?", 1175 labelKey: "customers.calendar.shortcuts.help", 1176 fallback: "Shortcuts" 1177 } 1178]; 1179function CalendarFooter({ timezoneLabel, onOpenShortcuts }) { 1180 const t = (0, __TURBOPACK__imported__module__928441__2["useT"])(); 1181 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__2["jsxs"])("footer", { 1182 className: "flex flex-wrap items-center gap-x-4 gap-y-1.5 border-t bg-muted/40 px-4 py-2", 1183 children: [ 1184 CALENDAR_SHORTCUTS.map((shortcut)=>
1184{ 1185 const legend = /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__2["jsxs"])(__TURBOPACK__imported__module__843476__2["Fragment"], { 1186 children: [ 1187 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__2["jsx"])(__TURBOPACK__imported__module__443530__["Kbd"], { 1188 children: shortcut.key 1189 }), 1190 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__2["jsx"])("span", { 1191 className: "text-xs text-muted-foreground", 1192 children: t(shortcut.labelKey, shortcut.fallback) 1193 }) 1194 ] 1195 }); 1196 if (shortcut.key === "?" && onOpenShortcuts) { 1197 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__2["jsx"])(__TURBOPACK__imported__module__110035__2["Button"], { 1198 type: "button", 1199 variant: "ghost", 1200 size: "sm", 1201 className: "h-auto gap-1.5 p-0 font-normal hover:bg-transparent", 1202 "aria-label": t("customers.calendar.shortcuts.title", "
1202Keyboard shortcuts"), 1203 onClick: onOpenShortcuts, 1204 children: legend 1205 }, shortcut.key); 1206 } 1207 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__2["jsx"])("span", { 1208 className: "inline-flex items-center gap-1.5", 1209 children: legend 1210 }, shortcut.key); 1211 }), 1212 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__2["jsx"])("span", { 1213 className: "ml-auto text-xs text-muted-foreground", 1214 children: timezoneLabel 1215 }) 1216 ] 1217 }); 1218} 1219; 1220// MERGED MODULE: [project]/node_modules/@open-mercato/core/dist/modules/customers/components/calendar/CalendarHeader.js [app-client] (ecmascript) 1221; 1222var __TURBOPACK__imported__module__843476__3 = __TURBOPACK__imported__module__843476__; 1223var __TURBOPACK__imported__module__271645__2 = __TURBOPACK__imported__module__271645__; 1224var __TURBOPACK__imported__module__107233__ = __turbopack_context__.i(107233); 1225var __TURBOPACK__imported__module__110035__3 = __TURBOPACK__imported__module__110035__; 1226var __TURBOPACK__imported__module__928441__3 = __TURBOPACK__imported__module__928441__; 1227"use client"; 1228; 1229; 1230; 1231; 1232; 1233function CalendarHeader({ view, anchor, onNewEvent }) { 1234 const t = (0, __TURBOPACK__imported__module__928441__3["useT"])(); 1235 const locale = (0, __TURBOPACK__imported__module__928441__3["useLocale"])(); 1236 const title = __TURBOPACK__imported__module__271645__2["useMemo"](()=>{ 1237 if (view === "agenda") return t("customers.calendar.header.titleAgenda", "Upcoming"); 1238 if (view === "month") { 1239 return new Intl.DateTimeFormat(locale, { 1240 month: "long", 1241 year: "numeric" 1242 }).format(anchor); 1243 } 1244 return new Intl.DateTimeFormat(locale, { 1245 month: "short", 1246 day: "2-digit", 1247 year: "numeric" 1248 }).format(anchor); 1249 }, [ 1250 view, 1251 anchor, 1252 locale, 1253 t 1254 ]); 1255 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__3["jsxs"])("header", { 1256 className: "flex items-center gap-3 border-b py-4", 1257 children: [
1258 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__3["jsx"])("h1", { 1259 className: "min-w-0 truncate text-xl font-semibold text-foreground", 1260 children: title 1261 }), 1262 onNewEvent ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__3["jsx"])("div", { 1263 className: "ml-auto flex shrink-0 items-center", 1264 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__3["jsxs"])(__TURBOPACK__imported__module__110035__3["Button"], { 1265 type: "button", 1266 onClick: onNewEvent, 1267 "aria-label": t("customers.calendar.actions.newEvent", "New event"), 1268 children: [ 1269 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__3["jsx"])(__TURBOPACK__imported__module__107233__["Plus"], { 1270 "aria-hidden": "true" 1271 }), 1272 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__3["jsx"])("span", { 1273 className: "hidden sm:inline", 1274 children: t("customers.calendar.actions.newEvent", "New event") 1275 }) 1276 ] 1277 }) 1278 }) : null 1279 ] 1280 }); 1281} 1282; 1283// MERGED MODULE: [project]/node_modules/@open-mercato/core/dist/modules/customers/components/calendar/CalendarTabs.js [app-client] (ecmascript) 1284; 1285var __TURBOPACK__imported__module__843476__4 = __TURBOPACK__imported__module__843476__; 1286var __TURBOPACK__imported__module__503116__ = __turbopack_context__.i(503116); 1287var __TURBOPACK__imported__module__373264__ = __turbopack_context__.i(373264); 1288var __TURBOPACK__imported__module__370956__ = __turbopack_context__.i(370956); 1289var __TURBOPACK__imported__module__635414__ = __turbopack_context__.i(635414); 1290var __TURBOPACK__imported__module__223922__ = __turbopack_context__.i(223922); 1291var __TURBOPACK__imported__module__928441__4 = __TURBOPACK__imported__module__928441__; 1292"use client"; 1293; 1294; 1295; 1296; 1297; 1298function TabCount({ value }) { 1299 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__4["jsxs"])("span", { 1300 className: "text-xs font-medium text-muted-foreground", 1301 children: [ 1302 "(", 1303 value, 1304 ")" 1305 ] 1306 }); 1307} 1308function CalendarTabs({ tab, counts, view, onTabChange, onViewChange }) { 1309 const t = (0, __TURBOPACK__imported__module__928441__4["useT"])(); 1310 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__4["jsx"])(__TURBOPACK__imported__module__223922__["Tabs"], { 1311 value: tab, 1312 onValueChange: (value)=>onTabChange(value), 1313 variant: "underline", 1314 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__4["jsxs"])("div", { 1315 className: "flex flex-wrap items-stretch justify-between gap-x-3 gap-y-2", 1316 children: [
1317 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__4["jsx"])("div", { 1318 className: "min-w-0 max-w-full overflow-x-auto scrollbar-hide [mask-image:linear-gradient(to_right,black_calc(100%-1.5rem),transparent)] sm:[mask-image:none]", 1319 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__4["jsxs"])(__TURBOPACK__imported__module__223922__["TabsList"], { 1320 className: "shrink-0", 1321 children: [ 1322 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__4["jsx"])(__TURBOPACK__imported__module__223922__["TabsTrigger"], { 1323 value: "all", 1324 leading: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__4["jsx"])(__TURBOPACK__imported__module__373264__["LayoutGrid"], { 1325 className: "size-4" 1326 }), 1327 children: t("customers.calendar.tabs.all", "All Scheduled") 1328 }),
1329 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__4["jsxs"])(__TURBOPACK__imported__module__223922__["TabsTrigger"], { 1330 value: "meetings", 1331 leading: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__4["jsx"])(__TURBOPACK__imported__module__370956__["List"], { 1332 className: "size-4" 1333 }), 1334 children: [ 1335 t("customers.calendar.tabs.meetings", "Meetings"), 1336 " ", 1337 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__4["jsx"])(TabCount, { 1338 value: counts.meetings 1339 }) 1340 ] 1341 }), 1342 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__4["jsxs"])(__TURBOPACK__imported__module__223922__["TabsTrigger"], { 1343 value: "events", 1344 leading: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__4["jsx"])(__TURBOPACK__imported__module__503116__["Clock"], { 1345 className: "size-4" 1346 }), 1347 children: [ 1348 t("customers.calendar.tabs.events", "Events"), 1349 " ",
1350 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__4["jsx"])(TabCount, { 1351 value: counts.events 1352 }) 1353 ] 1354 }) 1355 ] 1356 }) 1357 }), 1358 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__4["jsx"])("div", { 1359 className: "flex min-w-0 flex-1 items-center justify-end border-b border-input", 1360 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__4["jsxs"])(__TURBOPACK__imported__module__635414__["SegmentedControl"], { 1361 value: view, 1362 onValueChange: (value)=>onViewChange(value), 1363 "aria-label": t("customers.calendar.views.label", "Calendar view"), 1364 children: [ 1365 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__4["jsx"])(__TURBOPACK__imported__module__635414__["SegmentedControlItem"], { 1366 value: "day", 1367 children: t("customers.calendar.views.day", "Day") 1368 }),
1369 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__4["jsx"])(__TURBOPACK__imported__module__635414__["SegmentedControlItem"], { 1370 value: "week", 1371 children: t("customers.calendar.views.week", "Week") 1372 }), 1373 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__4["jsx"])(__TURBOPACK__imported__module__635414__["SegmentedControlItem"], { 1374 value: "month", 1375 children: t("customers.calendar.views.month", "Month") 1376 }), 1377 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__4["jsx"])(__TURBOPACK__imported__module__635414__["SegmentedControlItem"], { 1378 value: "agenda", 1379 children: t("customers.calendar.views.agenda", "Agenda") 1380 }) 1381 ] 1382 }) 1383 }) 1384 ] 1385 }) 1386 }); 1387} 1388; 1389// MERGED MODULE: [project]/node_modules/@open-mercato/core/dist/modules/customers/components/calendar/CalendarToolbar.js [app-client] (ecmascript) 1390; 1391var __TURBOPACK__imported__module__843476__5 = __TURBOPACK__imported__module__843476__; 1392var __TURBOPACK__imported__module__271645__3 = __TURBOPACK__imported__module__271645__; 1393// MERGED MODULE: [project]/node_modules/lucide-react/dist/esm/icons/calendar-range.js [app-client] (ecmascript) <export default as CalendarRange> 1394; 1395var __TURBOPACK__imported__module__603662__ = __turbopack_context__.i(603662); 1396var __TURBOPACK__imported__module__603662__ = __TURBOPACK__imported__module__603662__; 1397var __TURBOPACK__imported__module__711641__ = __turbopack_context__.i(711641); 1398var __TURBOPACK__imported__module__239616__ = __turbopack_context__.i(239616); 1399var __TURBOPACK__imported__module__873893__ = __turbopack_context__.i(873893); 1400var __TURBOPACK__imported__module__110035__4 = __TURBOPACK__imported__module__110035__; 1401var __TURBOPACK__imported__module__422580__ = __turbopack_context__.i(422580); 1402var __TURBOPACK__imported__module__898894__ = __turbopack_context__.i(898894); 1403var __TURBOPACK__imported__module__741870__ = __turbopack_context__.i(741870); 1404var __TURBOPACK__imported__module__443530__1 = __TURBOPACK__imported__module__443530__; 1405var __TURBOPACK__imported__module__388528__ = __turbopack_context__.i(388528); 1406var __TURBOPACK__imported__module__9762__ = __turbopack_context__.i(9762); 1407var __TURBOPACK__imported__module__262524__ = __turbopack_context__.i(262524); 1408var __TURBOPACK__imported__module__928441__5 = __TURBOPACK__imported__module__928441__; 1409// MERGED MODULE: [project]/node_modules/@open-mercato/core/dist/modules/customers/lib/calendar/format.js [app-client] (ecmascript) 1410; 1411const DATE_OPTIONS = { 1412 day: "numeric", 1413 month: "short", 1414 year: "numeric" 1415}; 1416const TIME_OPTIONS = { 1417 hour: "numeric", 1418 minute: "2-digit" 1419}; 1420function formatDateLabel(locale, date) { 1421 return new Intl.DateTimeFormat(locale, DATE_OPTIONS).format(date); 1422} 1423function formatDateRangeLabel(locale, from, to) { 1424 const formatter = new Intl.DateTimeFormat(locale, DATE_OPTIONS); 1425 try { 1426 return formatter.formatRange(from, to); 1427 } catch { 1428 return `${formatter.format(from)} \u2013 ${formatter.format(to)}`; 1429 } 1430} 1431function formatTimeRangeLabel(locale, start, end) { 1432 const formatter = new Intl.DateTimeFormat(locale, TIME_OPTIONS); 1433 try { 1434 return formatter.formatRange(start, end); 1435 } catch { 1436 return `${formatter.format(start)} \u2013 ${formatter.format(end)}`; 1437 } 1438} 1439; 1440"use client"; 1441; 1442; 1443; 1444; 1445; 1446; 1447; 1448; 1449; 1450; 1451; 1452; 1453; 1454; 1455const RANGE_PRESETS = [ 1456 "thisWeek", 1457 "next7", 1458 "thisMonth", 1459 "next30" 1460]; 1461const STATUS_OPTIONS = [ 1462 "planned", 1463 "done", 1464 "canceled" 1465]; 1466const ALL_OPTION = "all"; 1467const EMPTY_FILTERS = { 1468 types: [], 1469 status: null, 1470 ownerUserId: null 1471}; 1472function CalendarToolbar(props) { 1473 const { anchor, range, preset, search, filters, typeOptions, ownerOptions, onToday, onPresetChange, onAnchorChange, onSearchChange, onFiltersChange, onOpenSettings } = props; 1474 const t = (0, __TURBOPACK__imported__module__928441__5["useT"])(); 1475 const locale = (0, __TURBOPACK__imported__module__928441__5["useLocale"])(); 1476 const [rangeOpen, setRangeOpen] = __TURBOPACK__imported__module__271645__3["useState"](false); 1477 const [filtersOpen, setFiltersOpen] = __TURBOPACK__imported__module__271645__3["useState"](false); 1478 const [pendingFilters, setPendingFilters] = __TURBOPACK__imported__module__271645__3["useState"](filters); 1479 const presetLabels = { 1480 thisWeek: t("customers.calendar.toolbar.presets.thisWeek", "This week"), 1481 next7: t("customers.calendar.toolbar.presets.next7", "Next 7 days"), 1482 thisMonth: t("customers.calendar.toolbar.presets.thisMonth", "This month"), 1483 next30: t("customers.calendar.toolbar.presets.next30", "Next 30 days") 1484 }; 1485 const activeFilterCount = filters.types.length + (filters.status ? 1 : 0) + (filters.ownerUserId ? 1 : 0); 1486 const handleFiltersOpenChange = (open)=>{ 1487 if (open) setPendingFilters(filters); 1488 setFiltersOpen(open); 1489 }; 1490 const applyFilters = ()=>{ 1491 onFiltersChange(pendingFilters); 1492 setFiltersOpen(false); 1493 }; 1494 const clearFilters = ()=>{ 1495 setPendingFilters(EMPTY_FILTERS); 1496 onFiltersChange(EMPTY_FILTERS); 1497 setFiltersOpen(false); 1498 }; 1499 const togglePendingType = (value, checked)=>{ 1500 setPendingFilters((current)=>({ 1501 ...current, 1502 types: checked ? [ 1503 ...current.types, 1504 value 1505 ] : current.types.filter((entry)=>entry !== value) 1506 })); 1507 }; 1508 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsxs"])("div", { 1509 className: "flex flex-wrap items-center gap-2 sm:gap-3", 1510 children: [
1511 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsxs"])("div", { 1512 className: "flex min-w-0 flex-wrap items-center gap-2 sm:gap-3", 1513 children: [ 1514 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__110035__4["Button"], { 1515 type: "button", 1516 variant: "outline", 1517 onClick: onToday, 1518 children: t("customers.calendar.toolbar.today", "Today") 1519 }), 1520 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsxs"])("div", { 1521 className: "flex min-w-0 items-center", 1522 children: [ 1523 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsxs"])(__TURBOPACK__imported__module__262524__["Select"], { 1524 value: preset ?? "", 1525 onValueChange: (value)=>onPresetChange(value), 1526 children: [
1527 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__262524__["SelectTrigger"], { 1528 className: "hidden w-auto min-w-32 rounded-r-none sm:flex", 1529 "aria-label": t("customers.calendar.toolbar.presetLabel", "Date range preset"), 1530 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__262524__["SelectValue"], { 1531 placeholder: t("customers.calendar.toolbar.presetPlaceholder", "Custom range") 1532 }) 1533 }), 1534 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__262524__["SelectContent"], { 1535 children: RANGE_PRESETS.map((value)=>/* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__262524__["SelectItem"], { 1536 value, 1537 children: presetLabels[value] 1538 }, value)) 1539 }) 1540 ] 1541 }),
1542 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsxs"])(__TURBOPACK__imported__module__388528__["Popover"], { 1543 open: rangeOpen, 1544 onOpenChange: setRangeOpen, 1545 children: [ 1546 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__388528__["PopoverTrigger"], { 1547 asChild: true, 1548 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsxs"])(__TURBOPACK__imported__module__110035__4["Button"], { 1549 type: "button", 1550 variant: "outline", 1551 className: "min-w-0 text-muted-foreground sm:-ml-px sm:rounded-l-none", 1552 children: [ 1553 /* @__P
1553URE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__603662__["default"], { 1554 "aria-hidden": "true" 1555 }), 1556 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])("span", { 1557 className: "truncate", 1558 children: formatDateRangeLabel(locale, range.from, range.to) 1559 }) 1560 ] 1561 }) 1562 }), 1563 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__388528__["PopoverContent"], { 1564 align: "start", 1565 className: "w-auto min-w-0 p-2", 1566 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__422580__["Calendar"], { 1567 mode: "single", 1568 selected: anchor, 1569 defaultMonth: anchor, 1570 onSelect: (date)=>{ 1571 if (!date) return; 1572 onAnchorChange(date); 1573 setRangeOpen(false); 1574 } 1575 }) 1576 }) 1577 ] 1578 }) 1579 ] 1580 }) 1581 ] 1582 }),
1583 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsxs"])("div", { 1584 className: "flex w-full min-w-0 items-center gap-2 sm:ml-auto sm:w-auto sm:flex-none sm:gap-3", 1585 children: [ 1586 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsxs"])("div", { 1587 className: "relative min-w-0 flex-1 sm:w-72 sm:flex-none", 1588 children: [ 1589 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__9762__["SearchInput"], { 1590 value: search, 1591 onChange: onSearchChange, 1592 placeholder: t("customers.calendar.toolbar.searchPlaceholder", "Search\u2026"), 1593 "aria-label": t("customers.calendar.toolbar.searchPlaceholder", "Search\u2026"), 1594 "data-calendar-search": "" 1595 }), 1596 search.length === 0 ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__443530__1["Kbd"], { 1597 className: "pointer-events-none absolute right-2 top-1/2 hidden -translate-y-1/2 sm:inline-flex", 1598 children: "/" 1599 }) : null 1600 ] 1601 }),
1602 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsxs"])(__TURBOPACK__imported__module__388528__["Popover"], { 1603 open: filtersOpen, 1604 onOpenChange: handleFiltersOpenChange, 1605 children: [ 1606 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__388528__["PopoverTrigger"], { 1607 asChild: true, 1608 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsxs"])(__TURBOPACK__imported__module__110035__4["Button"], { 1609 type: "button", 1610 variant: "outline", 1611 "aria-label": t("customers.calendar.toolbar.filters.label", "Filter"), 1612 children: [ 1613 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__711641__["ListFilter"], { 1614 "aria-hidden": "true" 1615 }),
1616 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])("span", { 1617 className: "hidden sm:inline", 1618 children: t("customers.calendar.toolbar.filters.label", "Filter") 1619 }), 1620 activeFilterCount > 0 ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__873893__["Badge"], { 1621 variant: "secondary", 1622 size: "sm", 1623 children: activeFilterCount 1624 }) : null 1625 ] 1626 }) 1627 }), 1628 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__388528__["PopoverContent"], { 1629 align: "end", 1630 className: "w-72 p-3", 1631 onKeyDown: (event)=>{ 1632 if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) { 1633 event.preventDefault(); 1634 applyFilters(); 1635 } 1636 }, 1637 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsxs"])("div", { 1638 className: "flex flex-col gap-4", 1639 children: [ 1640 typeOptions.length > 0 ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsxs"])("fieldset", { 1641 className: "flex flex-col gap-2", 1642 children: [
1643 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])("legend", { 1644 className: "pb-1 text-overline font-semibold uppercase tracking-widest text-muted-foreground", 1645 children: t("customers.calendar.toolbar.filters.types", "Type") 1646 }), 1647 typeOptions.map((option)=>/* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__898894__["CheckboxField"], { 1648 label: option.label, 1649 size: "sm", 1650 checked: pendingFilters.types.includes(option.value), 1651 onCheckedChange: (checked)=>togglePendingType(option.value, checked === true) 1652 }, option.value)) 1653 ] 1654 }) : null,
1655 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsxs"])("div", { 1656 className: "flex flex-col gap-1.5", 1657 children: [ 1658 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])("span", { 1659 className: "text-overline font-semibold uppercase tracking-widest text-muted-foreground", 1660 children: t("customers.calendar.toolbar.filters.status", "Status") 1661 }), 1662 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsxs"])(__TURBOPACK__imported__module__262524__["Select"], { 1663 value: pendingFilters.status ?? ALL_OPTION, 1664 onValueChange: (value)=>setPendingFilters((current)=>({ 1665 ...current, 1666 status: value === ALL_OPTION ? null : value 1667 })), 1668 children: [
1669 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__262524__["SelectTrigger"], { 1670 size: "sm", 1671 "aria-label": t("customers.calendar.toolbar.filters.status", "Status"), 1672 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__262524__["SelectValue"], {}) 1673 }), 1674 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsxs"])(__TURBOPACK__imported__module__262524__["SelectContent"], { 1675 children: [ 1676 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__262524__["SelectItem"], { 1677 value: ALL_OPTION, 1678 children: t("customers.calendar.toolbar.filters.allStatuses", "All statuses") 1679 }), 1680 STATUS_OPTIONS.map((status)=>/* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__262524__["SelectItem"], { 1681 value: status, 1682 children: t(`customers.calendar.toolbar.filters.statuses.${status}`, status) 1683 }, status)) 1684 ] 1685 }) 1686 ] 1687 }) 1688 ] 1689 }), 1690 ownerOptions.length > 0 ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsxs"])("div", { 1691 className: "flex flex-col gap-1.5", 1692 children: [
1693 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])("span", { 1694 className: "text-overline font-semibold uppercase tracking-widest text-muted-foreground", 1695 children: t("customers.calendar.toolbar.filters.owner", "Owner") 1696 }), 1697 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsxs"])(__TURBOPACK__imported__module__262524__["Select"], { 1698 value: pendingFilters.ownerUserId ?? ALL_OPTION, 1699 onValueChange: (value)=>setPendingFilters((current)=>({ 1700 ...current, 1701 ownerUserId: value === ALL_OPTION ? null : value 1702 })), 1703 children: [
1704 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__262524__["SelectTrigger"], { 1705 size: "sm", 1706 "aria-label": t("customers.calendar.toolbar.filters.owner", "Owner"), 1707 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__262524__["SelectValue"], {}) 1708 }), 1709 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsxs"])(__TURBOPACK__imported__module__262524__["SelectContent"], { 1710 children: [ 1711 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__262524__["SelectItem"], { 1712 value: ALL_OPTION, 1713 children: t("customers.calendar.toolbar.filters.allOwners", "All owners") 1714 }), 1715 ownerOptions.map((option)=>/* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__262524__["SelectItem"], { 1716 value: option.value, 1717 children: option.label 1718 }, option.value)) 1719 ] 1720 }) 1721 ] 1722 }) 1723 ] 1724 }) : null,
1725 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsxs"])("div", { 1726 className: "flex items-center justify-end gap-2 border-t pt-3", 1727 children: [ 1728 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__110035__4["Button"], { 1729 type: "button", 1730 variant: "ghost", 1731 size: "sm", 1732 onClick: clearFilters, 1733 children: t("customers.calendar.toolbar.filters.clear", "Clear") 1734 }), 1735 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__110035__4["Button"], { 1736 type: "button", 1737 size: "sm", 1738 onClick: applyFilters, 1739 children: t("customers.calendar.toolbar.filters.apply", "Apply") 1740 }) 1741 ] 1742 }) 1743 ] 1744 }) 1745 }) 1746 ] 1747 }),
1748 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__741870__["IconButton"], { 1749 type: "button", 1750 variant: "outline", 1751 "aria-label": t("customers.calendar.toolbar.settings", "Calendar settings"), 1752 onClick: onOpenSettings, 1753 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__5["jsx"])(__TURBOPACK__imported__module__239616__["Settings"], { 1754 "aria-hidden": true 1755 }) 1756 }) 1757 ] 1758 }) 1759 ] 1760 }); 1761} 1762; 1763// MERGED MODULE: [project]/node_modules/@open-mercato/core/dist/modules/customers/components/calendar/MonthGrid.js [app-client] (ecmascript) 1764; 1765var __TURBOPACK__imported__module__843476__6 = __TURBOPACK__imported__module__843476__; 1766var __TURBOPACK__imported__module__271645__4 = __TURBOPACK__imported__module__271645__; 1767var __TURBOPACK__imported__module__595727__3 = __TURBOPACK__imported__module__595727__; 1768var __TURBOPACK__imported__module__401851__1 = __TURBOPACK__imported__module__401851__; 1769// MERGED MODULE: [project]/node_modules/date-fns/isSameMonth.js [app-client] (ecmascript) 1770; 1771var __TURBOPACK__imported__module__845110__1 = __TURBOPACK__imported__module__845110__; 1772; 1773function isSameMonth(laterDate, earlierDate, options) { 1774 const [laterDate_, earlierDate_] = (0, __TURBOPACK__imported__module__845110__1["normalizeDates"])(options?.in, laterDate, earlierDate); 1775 return laterDate_.getFullYear() === earlierDate_.getFullYear() && laterDate_.getMonth() === earlierDate_.getMonth(); 1776} 1777const __TURBOPACK__default__export__3 = isSameMonth; 1778var __TURBOPACK__imported__module__928441__6 = __TURBOPACK__imported__module__928441__; 1779var __TURBOPACK__imported__module__406911__1 = __TURBOPACK__imported__module__406911__; 1780var __TURBOPACK__imported__module__110035__5 = __TURBOPACK__imported__module__110035__; 1781var __TURBOPACK__imported__module__467550__1 = __TURBOPACK__imported__module__467550__; 1782var __TURBOPACK__imported__module__938359__1 = __TURBOPACK__imported__module__938359__; 1783"use client"; 1784; 1785; 1786; 1787; 1788; 1789; 1790; 1791; 1792; 1793; 1794; 1795const MAX_PILLS_PER_DAY = 2; 1796const SOFT_TINT_ALPHA = "1A"; 1797function dayKeyOf1(date) { 1798 return (0, __TURBOPACK__imported__module__401851__1["format"])(date, "yyyy-MM-dd"); 1799} 1800function formatTime1(date) { 1801 return date.toLocaleTimeString(void 0, { 1802 hour: "numeric", 1803 minute: "2-digit" 1804 }); 1805} 1806function fullDateLabel(date) { 1807 return date.toLocaleDateString(void 0, { 1808 weekday: "long", 1809 year: "numeric", 1810 month: "long", 1811 day: "numeric" 1812 }); 1813} 1814function isWeekend(date) { 1815 const weekday = date.getDay(); 1816 return weekday === 0 || weekday === 6; 1817} 1818function buildWeeks(anchor) { 1819 const range = (0, __TURBOPACK__imported__module__467550__1["getVisibleRange"])("month", anchor, 0); 1820 const weeks = []; 1821 let cursor = range.from; 1822 while(cursor.getTime() <= range.to.getTime()){ 1823 const week = []; 1824 for(let dayIndex = 0; dayIndex < 7; dayIndex += 1){ 1825 week.push(cursor); 1826 cursor = (0, __TURBOPACK__imported__module__595727__3["addDays"])(cursor, 1); 1827 } 1828 weeks.push(week); 1829 } 1830 return weeks; 1831} 1832function groupItemsByDay(items) { 1833 const sorted = [ 1834 ...items 1835 ].sort((first, second)=>first.start.getTime() - second.start.getTime()); 1836 const byDay = /* @__PURE__ */ new Map(); 1837 for (const item of sorted){ 1838 const key = dayKeyOf1(item.start); 1839 const bucket = byDay.get(key); 1840 if (bucket) bucket.push(item); 1841 else byDay.set(key, [ 1842 item 1843 ]); 1844 } 1845 return byDay; 1846} 1847function MonthPill({ item, onItemClick }) { 1848 const t = (0, __TURBOPACK__imported__module__928441__6["useT"])(); 1849 const canceled = item.status === "canceled"; 1850 const title = (0, __TURBOPACK__imported__module__938359__1["eventDisplayTitle"])(item.title, t("customers.calendar.grid.untitled", "Untitled")); 1851 const timeLabel = item.allDay ? "" : ` \xB7 ${formatTime1(item.start)} \u2013 ${formatTime1(item.end)}`; 1852 const tintStyle = item.color ? { 1853 backgroundColor: `${item.color}${SOFT_TINT_ALPHA}`, 1854 color: item.color 1855 } : void 0; 1856 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__
18566["jsxs"])(__TURBOPACK__imported__module__110035__5["Button"], { 1857 type: "button", 1858 variant: "ghost", 1859 "aria-label": `${title}${timeLabel}`, 1860 onClick: (event)=>{ 1861 event.stopPropagation(); 1862 onItemClick(item); 1863 }, 1864 className: (0, __TURBOPACK__imported__module__406911__1["cn"])("h-4 w-full min-w-0 justify-center gap-0 rounded-full p-0 pr-2", !item.color && "bg-muted text-muted-foreground", canceled && "opacity-60"), 1865 style: tintStyle, 1866 children: [ 1867 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__6["jsx"])("span", { 1868 "aria-hidden": "true", 1869 className: "flex size-4 shrink-0 items-center justify-center", 1870 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__6["jsx"])("span", { 1871 className: (0, __TURBOPACK__imported__module__406911__1["cn"])("size-1.5 rounded-full", !item.color && "bg-muted-foreground"), 1872 style: item.color ? { 1873 backgroundColor: item.color 1874 } : void 0 1875 }) 1876 }),
1877 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__6["jsx"])("span", { 1878 className: (0, __TURBOPACK__imported__module__406911__1["cn"])("min-w-0 truncate text-overline font-medium uppercase tracking-wide", canceled && "line-through"), 1879 children: title 1880 }) 1881 ] 1882 }); 1883} 1884function MonthDayCell({ day, anchor, items, onItemClick, onDayOpen }) { 1885 const t = (0, __TURBOPACK__imported__module__928441__6["useT"])(); 1886 const inMonth = isSameMonth(day, anchor); 1887 const today = isToday(day); 1888 const visibleItems = items.slice(0, MAX_PILLS_PER_DAY); 1889 const hiddenCount = items.length - visibleItems.length; 1890 const dayLabel = fullDateLabel(day); 1891 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__6["jsxs"])("div", { 1892 className: (0, __TURBOPACK__imported__module__406911__1["cn"])("relative flex h-full min-w-0 flex-1 flex-col items-start gap-1 overflow-hidden border-r border-border p-2 text-left last:border-r-0", isWeekend(day) ? "bg-muted/40" : "bg-background"), 1893 children: [
1894 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__6["jsx"])(__TURBOPACK__imported__module__110035__5["Button"], { 1895 type: "button", 1896 variant: "ghost", 1897 "aria-label": dayLabel, 1898 onClick: ()=>onDayOpen(day), 1899 className: "absolute inset-0 z-0 h-full w-full rounded-none p-0 hover:bg-muted/50", 1900 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__6["jsx"])("span", { 1901 className: "sr-only", 1902 children: dayLabel 1903 }) 1904 }), 1905 today ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__6["jsx"])("span", { 1906 className: "pointer-events-none relative z-10 flex items-center justify-center rounded-full bg-primary px-1.5 py-0.5 text-xs font-semibold text-primary-foreground", 1907 children: day.getDate() 1908 }) : /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__6["jsx"])("span", { 1909 className: (0, __TURBOPACK__imported__module__406911__1["cn"])("pointer-events-none relative z-10 text-xs font-medium", inMonth ? "text-foreground" : "text-muted-foreground"), 1910 children: day.getDate() 1911 }),
1912 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__6["jsxs"])("span", { 1913 className: "relative z-20 hidden w-full flex-col gap-1 sm:flex", 1914 children: [ 1915 visibleItems.map((item)=>/* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__6["jsx"])(MonthPill, { 1916 item, 1917 onItemClick 1918 }, item.id)), 1919 hiddenCount > 0 ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__6["jsx"])(__TURBOPACK__imported__module__110035__5["Button"], { 1920 type: "button", 1921 variant: "ghost", 1922 size: "sm", 1923 className: "h-auto self-start p-0 text-overline font-medium text-muted-foreground hover:bg-transparent hover:underline", 1924 onClick: (event)=>{ 1925 event.stopPropagation(); 1926 onDayOpen(day); 1927 }, 1928 children: t("customers.calendar.grid.more", "+{count} more", { 1929 count: hiddenCount 1930 }) 1931 }) : null 1932 ] 1933 }), 1934 items.length > 0 ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__
19346["jsxs"])("span", { 1935 "aria-hidden": "true", 1936 className: "pointer-events-none relative z-10 flex w-full flex-wrap items-center gap-0.5 sm:hidden", 1937 children: [ 1938 items.slice(0, 4).map((item)=>/* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__6["jsx"])("span", { 1939 className: (0, __TURBOPACK__imported__module__406911__1["cn"])("size-1.5 rounded-full", !item.color && "bg-muted-foreground"), 1940 style: item.color ? { 1941 backgroundColor: item.color 1942 } : void 0 1943 }, item.id)), 1944 items.length > 4 ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__6["jsxs"])("span", { 1945 className: "text-overline font-medium leading-none text-muted-foreground", 1946 children: [ 1947 "+", 1948 items.length - 4 1949 ] 1950 }) : null 1951 ] 1952 }) : null 1953 ] 1954 }); 1955} 1956function MonthGrid({ anchor, items, onItemClick, onDayOpen }) { 1957 const t = (0, __TURBOPACK__imported__module__928441__6["useT"])(); 1958 const weeks = __TURBOPACK__imported__module__271645__4["useMemo"](()=>buildWeeks(anchor), [ 1959 anchor 1960 ]); 1961 const itemsByDay = __TURBOPACK__imported__module__271645__4["useMemo"](()=>groupItemsByDay(items), [ 1962 items 1963 ]); 1964 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__
19646["jsxs"])("div", { 1965 className: "relative flex h-full w-full flex-col overflow-hidden border border-border bg-background", 1966 children: [ 1967 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__6["jsx"])("div", { 1968 className: "flex h-9 w-full shrink-0 border-b border-border", 1969 children: weeks[0]?.map((day)=>{ 1970 const label = day.toLocaleDateString(void 0, { 1971 weekday: "short" 1972 }).toUpperCase(); 1973 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__6["jsx"])("div", { 1974 className: "flex min-w-0 flex-1 items-center justify-center border-r border-border last:border-r-0 sm:justify-start sm:pl-2.5", 1975 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__6["jsxs"])("span", { 1976 className: "truncate text-overline font-medium uppercase tracking-widest text-muted-foreground", 1977 children: [
1978 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__6["jsx"])("span", { 1979 className: "sm:hidden", 1980 children: label.charAt(0) 1981 }), 1982 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__6["jsx"])("span", { 1983 className: "hidden sm:inline", 1984 children: label 1985 }) 1986 ] 1987 }) 1988 }, dayKeyOf1(day)); 1989 }) 1990 }), 1991 weeks.map((week)=>/* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__6["jsx"])("div", { 1992 className: "flex w-full flex-1 border-b border-border last:border-b-0 min-h-14 sm:min-h-[86px]", 1993 children: week.map((day)=>/* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__6["jsx"])(MonthDayCell, { 1994 day, 1995 anchor, 1996 items: itemsByDay.get(dayKeyOf1(day)) ?? [], 1997 onItemClick, 1998 onDayOpen 1999 }, dayKeyOf1(day))) 2000 }, dayKeyOf1(week[0]))) 2001 ] 2002 }); 2003} 2004; 2005// MERGED MODULE: [project]/node_modules/@open-mercato/core/dist/modules/customers/components/calendar/ShortcutsDialog.js [app-client] (ecmascript) 2006; 2007var __TURBOPACK__imported__module__843476__7 = __TURBOPACK__imported__module__843476__; 2008var __TURBOPACK__imported__module__644149__ = __turbopack_context__.i(644149); 2009var __TURBOPACK__imported__module__443530__2 = __TURBOPACK__imported__module__443530__; 2010var __TURBOPACK__imported__module__928441__7 = __TURBOPACK__imported__module__928441__; 2011"use client"; 2012; 2013; 2014; 2015; 2016; 2017function ShortcutsDialog({ open, onOpenChange }) { 2018 const t = (0, __TURBOPACK__imported__module__928441__7["useT"])(); 2019 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__7["jsx"])(__TURBOPACK__imported__module__644149__["Dialog"], { 2020 open, 2021 onOpenChange, 2022 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__7["jsxs"])(__TURBOPACK__imported__module__644149__["DialogContent"], { 2023 size: "sm", 2024 onKeyDown: (event)=>{ 2025 if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) { 2026 event.preventDefault(); 2027 onOpenChange(false); 2028 } 2029 }, 2030 children: [
2031 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__7["jsxs"])(__TURBOPACK__imported__module__644149__["DialogHeader"], { 2032 children: [ 2033 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__7["jsx"])(__TURBOPACK__imported__module__644149__["DialogTitle"], { 2034 children: t("customers.calendar.shortcuts.title", "Keyboard shortcuts") 2035 }), 2036 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__7["jsx"])(__TURBOPACK__imported__module__644149__["DialogDescription"], { 2037 children: t("customers.calendar.shortcuts.description", "Navigate the calendar faster with these keys.") 2038 }) 2039 ] 2040 }), 2041 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__7["jsx"])("ul", { 2042 className: "flex flex-col gap-2", 2043 children: CALENDAR_SHORTCUTS.map((shortcut)=>/* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__7["jsxs"])("li", { 2044 className: "flex items-center justify-between gap-3", 2045 children: [
2046 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__7["jsx"])("span", { 2047 className: "text-sm text-muted-foreground", 2048 children: t(shortcut.labelKey, shortcut.fallback) 2049 }), 2050 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__7["jsx"])(__TURBOPACK__imported__module__443530__2["Kbd"], { 2051 children: shortcut.key 2052 }) 2053 ] 2054 }, shortcut.key)) 2055 }) 2056 ] 2057 }) 2058 }); 2059} 2060; 2061// MERGED MODULE: [project]/node_modules/@open-mercato/core/dist/modules/customers/components/calendar/TimeGrid.js [app-client] (ecmascript) 2062; 2063var __TURBOPACK__imported__module__843476__8 = __TURBOPACK__imported__module__843476__; 2064var __TURBOPACK__imported__module__271645__5 = __TURBOPACK__imported__module__271645__; 2065var __TURBOPACK__imported__module__373375__ = __turbopack_context__.i(373375); 2066var __TURBOPACK__imported__module__463059__ = __turbopack_context__.i(463059); 2067var __TURBOPACK__imported__module__595727__4 = __TURBOPACK__imported__module__595727__; 2068var __TURBOPACK__imported__module__585890__2 = __TURBOPACK__imported__module__585890__; 2069var __TURBOPACK__imported__module__406911__2 = __TURBOPACK__imported__module__406911__; 2070var __TURBOPACK__imported__module__928441__8 = __TURBOPACK__imported__module__928441__; 2071var __TURBOPACK__imported__module__110035__6 = __TURBOPACK__imported__module__110035__; 2072var __TURBOPACK__imported__module__741870__1 = __TURBOPACK__imported__module__741870__; 2073// MERGED MODULE: [project]/node_modules/@open-mercato/core/dist/modules/customers/lib/calendar/layout.js [app-client] (ecmascript) 2074; 2075function packOverlaps(dayItems) { 2076 const sorted = [ 2077 ...dayItems 2078 ].sort((first, second)=>{ 2079 const startDelta = first.start.getTime() - second.start.getTime(); 2080 if (startDelta !== 0) return startDelta; 2081 return second.end.getTime() - first.end.getTime(); 2082 }); 2083 const result = []; 2084 let cluster = []; 2085 let columnEnds = []; 2086 let clusterEnd = Number.NEGATIVE_INFINITY; 2087 const flushCluster = ()=>{ 2088 const columns = columnEnds.length; 2089 for (const entry of cluster){ 2090 result.push({ 2091 item: entry.item, 2092 column: entry.column, 2093 columns 2094 }); 2095 } 2096 cluster = []; 2097 columnEnds = []; 2098 clusterEnd = Number.NEGATIVE_INFINITY; 2099 }; 2100 for (const item of sorted){ 2101 const startTime = item.start.getTime(); 2102 if (cluster.length > 0 && startTime >= clusterEnd) flushCluster(); 2103 let column = columnEnds.findIndex((columnEnd)=>columnEnd <= startTime); 2104 if (column === -1) { 2105 column = columnEnds.length; 2106 columnEnds.push(item.end.getTime()); 2107 } else { 2108 columnEnds[column] = item.end.getTime(); 2109 } 2110 cluster.push({ 2111 item, 2112 column 2113 }); 2114 clusterEnd = Math.max(clusterEnd, item.end.getTime()); 2115 } 2116 flushCluster(); 2117 return result; 2118} 2119; 2120var __TURBOPACK__imported__module__467550__2 = __TURBOPACK__imported__module__467550__; 2121// MERGED MODULE: [project]/node_modules/@open-mercato/core/dist/modules/customers/lib/calendar/grid.js [app-client] (ecmascript) 2122; 2123; 2124const DRAG_SNAP_MINUTES = 15; 2125const MIN_DRAG_DURATION_MINUTES = 30; 2126const MINUTES_PER_DAY = 24 * 60; 2127function isWeekendDay(date) { 2128 const weekday = date.getDay(); 2129 return weekday === 0 || weekday === 6; 2130} 2131function applyWeekendVisibility(days, showWeekends, keepWeekendDate) { 2132 if (showWeekends) return days; 2133 const workingDays = days.filter((day)=>!isWeekendDay(day) || keepWeekendDate != null && isSameDay(day, keepWeekendDate)); 2134 return workingDays.length > 0 ? workingDays : days; 2135} 2136function clampMinutes(value) { 2137 if (value < 0) return 0; 2138 if (value > MINUTES_PER_DAY) return MINUTES_PER_DAY; 2139 return value; 2140}
2141function offsetYToMinutes(offsetY, hourHeightPx, snapMinutes = DRAG_SNAP_MINUTES) { 2142 if (hourHeightPx <= 0) return 0; 2143 const rawMinutes = offsetY / hourHeightPx * 60; 2144 const snapped = Math.round(rawMinutes / snapMinutes) * snapMinutes; 2145 return clampMinutes(snapped); 2146} 2147function buildDragRange(dayStart, startMinutes, endMinutes) { 2148 let lower = clampMinutes(Math.min(startMinutes, endMinutes)); 2149 let upper = clampMinutes(Math.max(startMinutes, endMinutes)); 2150 if (upper - lower < MIN_DRAG_DURATION_MINUTES) upper = lower + MIN_DRAG_DURATION_MINUTES; 2151 if (upper > MINUTES_PER_DAY) { 2152 upper = MINUTES_PER_DAY; 2153 lower = Math.max(0, upper - MIN_DRAG_DURATION_MINUTES); 2154 } 2155 const start = new Date(dayStart); 2156 start.setHours(0, 0, 0, 0); 2157 start.setMinutes(lower); 2158 const end = new Date(dayStart); 2159 end.setHours(0, 0, 0, 0); 2160 end.setMinutes(upper); 2161 return { 2162 start, 2163 end 2164 }; 2165} 2166; 2167// MERGED MODULE: [project]/node_modules/@open-mercato/core/dist/modules/customers/components/calendar/EventBlock.js [app-client] (ecmascript) 2168; 2169var __TURBOPACK__imported__module__843476__9 = __TURBOPACK__imported__module__843476__; 2170var __TURBOPACK__imported__module__271645__6 = __TURBOPACK__imported__module__271645__; 2171var __TURBOPACK__imported__module__248256__ = __turbopack_context__.i(248256); 2172var __TURBOPACK__imported__module__346897__ = __turbopack_context__.i(346897); 2173var __TURBOPACK__imported__module__406911__3 = __TURBOPACK__imported__module__406911__; 2174var __TURBOPACK__imported__module__928441__9 = __TURBOPACK__imported__module__928441__; 2175var __TURBOPACK__imported__module__791576__1 = __TURBOPACK__imported__module__791576__; 2176var __TURBOPACK__imported__module__110035__7 = __TURBOPACK__imported__module__110035__; 2177"use client"; 2178; 2179; 2180; 2181; 2182; 2183; 2184; 2185; 2186const SHOW_TIME_MIN_HEIGHT_PX = 44; 2187const SHOW_META_MIN_HEIGHT_PX = 96; 2188const WRAP_TITLE_MIN_HEIGHT_PX = 128; 2189const MAX_VISIBLE_AVATARS = 3; 2190const PLATFORM_LABELS = { 2191 zoom: { 2192 key: "customers.calendar.platform.zoom", 2193 fallback: "Zoom" 2194 }, 2195 meet: { 2196 key: "customers.calendar.platform.meet", 2197 fallback: "Meet" 2198 }, 2199 slack: { 2200 key: "customers.calendar.platform.slack", 2201 fallback: "Slack" 2202 }, 2203 teams: { 2204 key: "customers.calendar.platform.teams", 2205 fallback: "Teams" 2206 } 2207}; 2208function softTintStyle(color) { 2209 if (/^#[0-9a-fA-F]{6}$/.test(color)) return { 2210 backgroundColor: `${color}1A` 2211 }; 2212 return { 2213 backgroundColor: `color-mix(in srgb, ${color} 10%, transparent)` 2214 }; 2215} 2216function resolveEventTone(item, nowMs) { 2217 if (item.status === "canceled") { 2218 return { 2219 surfaceClassName: "bg-muted/60", 2220 titleClassName: "text-muted-foreground line-through", 2221 subClassName: "text-muted-foreground/70" 2222 }; 2223 } 2224 if (item.status === "done" || item.end.getTime() < nowMs) { 2225 return { 2226 surfaceClassName: "bg-muted", 2227 titleClassName: "text-muted-foreground", 2228 subClassName: "text-muted-foreground" 2229 }; 2230 } 2231 if (item.color) { 2232 return { 2233 surfaceClassName: "", 2234 titleClassName: "text-foreground", 2235 subClassName: "text-muted-foreground", 2236 style: softTintStyle(item.color) 2237 }; 2238 } 2239 return { 2240 surfaceClassName: "bg-muted/60", 2241 titleClassName: "text-foreground", 2242 subClassName: "text-muted-foreground" 2243 }; 2244} 2245function formatTimeRange(locale, start, end) { 2246 return formatTimeRangeLabel(locale, start, end); 2247} 2248function participantLabel1(participant) { 2249 return participant.name ?? participant.email ?? "?"; 2250} 2251function LocationMeta({ item, subClassName, accentColor }) { 2252 const t = (0, __TURBOPACK__imported__module__928441__9["useT"])(); 2253 if (!item.location || !item.locationKind) return null; 2254 const iconStyle = accentColor ? { 2255 color: accentColor 2256 } : void 0; 2257 if (item.locationKind === "platform" && item.platform) { 2258 const platform = PLATFORM_LABELS[item.platform]; 2259 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__9["jsx"])("span", { 2260 className: (0, __TURBOPACK__imported__module__406911__3["cn"])("truncate text-xs", subClassName), 2261 children: t("customers.calendar.grid.onPlatform", "on {platform}", { 2262 platform: t(platform.key, platform.fallback) 2263 }) 2264 }); 2265 } 2266 if (item.locationKind === "url") { 2267 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__9["jsxs"])(__TURBOPACK__imported__module__843476__9["Fragment"], { 2268 children: [
2269 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__9["jsx"])(__TURBOPACK__imported__module__248256__["Globe"], { 2270 className: (0, __TURBOPACK__imported__module__406911__3["cn"])("size-4 shrink-0", !accentColor && subClassName), 2271 style: iconStyle, 2272 "aria-hidden": true 2273 }), 2274 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__9["jsx"])("span", { 2275 className: "truncate text-xs text-foreground", 2276 children: item.location 2277 }) 2278 ] 2279 }); 2280 } 2281 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__9["jsxs"])(__TURBOPACK__imported__module__843476__9["Fragment"], { 2282 children: [ 2283 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__9["jsx"])(__TURBOPACK__imported__module__346897__["MapPin"], { 2284 className: (0, __TURBOPACK__imported__module__406911__3["cn"])("size-4 shrink-0", !accentColor && subClassName), 2285 style: iconStyle, 2286 "aria-hidden": true 2287 }),
2288 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__9["jsx"])("span", { 2289 className: "truncate text-xs text-foreground", 2290 children: t("customers.calendar.grid.venue", "Venue: {name}", { 2291 name: item.location 2292 }) 2293 }) 2294 ] 2295 }); 2296} 2297const EventBlock = /*#__PURE__*/ __TURBOPACK__imported__module__271645__6["forwardRef"](function EventBlock2({ item, top, height, insetInlineStart, width, conflicted, highlighted, selected, nowMs, className, ...buttonProps }, ref) { 2298 const t = (0, __TURBOPACK__imported__module__928441__9["useT"])(); 2299 const locale = (0, __TURBOPACK__imported__module__928441__9["useLocale"])(); 2300 const tone = resolveEventTone(item, nowMs); 2301 const title = item.title || t("customers.calendar.grid.untitled", "Untitled"); 2302 const timeRange = formatTimeRange(locale, item.start, item.end); 2303 const showTime = height >= SHOW_TIME_MIN_HEIGHT_PX; 2304 const wrapTitle = height >= WRAP_TITLE_MIN_HEIGHT_PX; 2305 const hasMetaContent = item.participants.length > 0 || item.location !== null && item.locationKind !== null; 2306 const showMeta = height >= SHOW_META_MIN_HEIGHT_PX && hasMetaContent; 2307 const visibleParticipants = item.participants.slice(0, MAX_VISIBLE_AVATARS); 2308 const overflowCount = item.participants.length - visibleParticipants.length; 2309 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__9["jsxs"])(__TURBOPACK__imported__module__110035__7["Button"], { 2310 ref, 2311 type: "button", 2312 variant: "ghost", 2313 "aria-label": `${title}, ${timeRange}`, 2314 className: (0, __TURBOPACK__imported__module__406911__3["cn"])("pointer-events-auto absolute h-auto flex-col items-start justify-start gap-1 whitespace-normal overflow-hidden rounded-md px-1.5 text-start outline-none hover:bg-muted/70 sm:px-3", height >= SHOW_TIME_MIN_HEIGHT_PX ? "py-1 sm:py-2" : "py-0.5 sm:py-1", tone.surfaceClassName, conflicted && "ring-1 ring-status-warning-icon", selected && "shadow-md ring-2 ring-foreground", highlighted && "motion-safe:animate-pulse", conflicted || highlighted || selected ? "z-30" : "z-10", "focus-visible:z-30 focus-visible:ring-2 focus-visible:ring-ring", className), 2315 style: { 2316 top, 2317 height, 2318 insetInlineStart, 2319 width, 2320 ...tone.style 2321 }, 2322 ...buttonProps, 2323 children: [
2324 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__9["jsx"])("span", { 2325 className: (0, __TURBOPACK__imported__module__406911__3["cn"])("w-full text-xs font-medium leading-4", wrapTitle ? "line-clamp-2" : "truncate", tone.titleClassName), 2326 children: title 2327 }), 2328 showTime ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__9["jsx"])("span", { 2329 className: (0, __TURBOPACK__imported__module__406911__3["cn"])("w-full truncate text-overline uppercase tracking-wide", tone.subClassName), 2330 children: timeRange 2331 }) : null, 2332 showMeta ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__9["jsxs"])("span", { 2333 className: "mt-auto flex w-full min-w-0 items-center gap-1.5", 2334 children: [ 2335 visibleParticipants.length > 0 ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__9["jsxs"])(__TURBOPACK__imported__module__843476__9["Fragment"], { 2336 children: [
2337 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__9["jsx"])(__TURBOPACK__imported__module__791576__1["AvatarStack"], { 2338 size: "xs", 2339 max: MAX_VISIBLE_AVATARS, 2340 className: "shrink-0 gap-px [&>*:not(:first-child)]:-ml-1", 2341 children: visibleParticipants.map((participant)=>/* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__9["jsx"])(__TURBOPACK__imported__module__791576__1["Avatar"], { 2342 size: "xs", 2343 label: participantLabel1(participant) 2344 }, participant.userId)) 2345 }), 2346 overflowCount > 0 ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__9["jsxs"])("span", { 2347 className: (0, __TURBOPACK__imported__module__406911__3["cn"])("shrink-0 text-xs", tone.subClassName), 2348 children: [ 2349 "+", 2350 overflowCount 2351 ] 2352 }) : null 2353 ] 2354 }) : null,
2355 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__9["jsx"])("span", { 2356 className: "ms-auto flex min-w-0 items-center gap-1.5", 2357 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__9["jsx"])(LocationMeta, { 2358 item, 2359 subClassName: tone.subClassName, 2360 accentColor: item.color 2361 }) 2362 }) 2363 ] 2364 }) : null 2365 ] 2366 }); 2367}); 2368EventBlock.displayName = "EventBlock"; 2369; 2370// MERGED MODULE: [project]/node_modules/@open-mercato/core/dist/modules/customers/components/calendar/EventPeekPopover.js [app-client] (ecmascript) 2371; 2372var __TURBOPACK__imported__module__843476__10 = __TURBOPACK__imported__module__843476__; 2373var __TURBOPACK__imported__module__271645__7 = __TURBOPACK__imported__module__271645__; 2374var __TURBOPACK__imported__module__283086__ = __turbopack_context__.i(283086); 2375var __TURBOPACK__imported__module__928441__10 = __TURBOPACK__imported__module__928441__; 2376var __TURBOPACK__imported__module__110035__8 = __TURBOPACK__imported__module__110035__; 2377var __TURBOPACK__imported__module__388528__1 = __TURBOPACK__imported__module__388528__; 2378var __TURBOPACK__imported__module__220339__ = __turbopack_context__.i(220339); 2379"use client"; 2380; 2381; 2382; 2383; 2384; 2385; 2386; 2387; 2388const PLATFORM_FULL_LABELS = { 2389 zoom: { 2390 key: "customers.calendar.platformFull.zoom", 2391 fallback: "Zoom" 2392 }, 2393 meet: { 2394 key: "customers.calendar.platformFull.meet", 2395 fallback: "Google Meet" 2396 }, 2397 slack: { 2398 key: "customers.calendar.platformFull.slack", 2399 fallback: "Slack" 2400 }, 2401 teams: { 2402 key: "customers.calendar.platformFull.teams", 2403 fallback: "Microsoft Teams" 2404 } 2405}; 2406function EventPeekPopover({ item, open, joinUrl, aiSummaries, canManage = true, onOpenChange, onJoin, onEdit, children }) { 2407 const t = (0, __TURBOPACK__imported__module__928441__10["useT"])(); 2408 const locale = (0, __TURBOPACK__imported__module__928441__10["useLocale"])(); 2409 const title = item.title || t("customers.calendar.grid.untitled", "Untitled"); 2410 const dateLabel = __TURBOPACK__imported__module__271645__7["useMemo"](()=>new Intl.DateTimeFormat(locale, { 2411 weekday: "short", 2412 month: "short", 2413 day: "numeric" 2414 }).format(item.start), [ 2415 locale, 2416 item.start 2417 ]); 2418 const timeRange = item.allDay ? t("customers.calendar.grid.allDay", "All day") : formatTimeRange(locale, item.start, item.end); 2419 const attendeeCount = item.participants.length; 2420 const attendeesLabel = attendeeCount === 1 ? t("customers.calendar.peek.attendee", "1 attendee") : t("customers.calendar.peek.attendees", "{count} attendees", { 2421 count: attendeeCount 2422 }); 2423 const platformLabel = item.locationKind === "platform" && item.platform ? t(PLATFORM_FULL_LABELS[item.platform].key, PLATFORM_FULL_LABELS[item.platform].fallback) : null; 2424 const metaParts = [ 2425 platformLabel, 2426 attendeeCount > 0 ? attendeesLabel : null 2427 ].filter((part)=>Boolean(part)); 2428 const showSummary = aiSummaries && metaParts.length > 0; 2429 const showJoin = aiSummaries && Boolean(joinUrl); 2430 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__10["jsxs"])(__TURBOPACK__imported__module__388528__1["Popover"], { 2431 open, 2432 onOpenChange, 2433 children: [
2434 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__10["jsx"])(__TURBOPACK__imported__module__388528__1["PopoverTrigger"], { 2435 asChild: true, 2436 children 2437 }), 2438 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__10["jsx"])(__TURBOPACK__imported__module__388528__1["PopoverContent"], { 2439 align: "start", 2440 side: "right", 2441 sideOffset: 8, 2442 className: "w-56 p-3", 2443 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__10["jsxs"])("div", { 2444 className: "flex flex-col gap-2", 2445 children: [ 2446 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__10["jsx"])("p", { 2447 className: "text-sm font-semibold leading-5 text-foreground", 2448 children: title 2449 }), 2450 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__10["jsx"])("p", { 2451 className: "text-xs leading-4 text-muted-foreground", 2452 children: `${dateLabel} \xB7 ${timeRange}` 2453 }), 2454 showSummary ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__10["jsxs"])("p", { 2455 className: "flex items-center gap-1 text-xs leading-4 text-muted-foreground", 2456 children: [
2457 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__10["jsx"])(__TURBOPACK__imported__module__283086__["Sparkles"], { 2458 "aria-hidden": true, 2459 className: "size-3.5 shrink-0" 2460 }), 2461 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__10["jsx"])("span", { 2462 className: "truncate", 2463 children: metaParts.join(" \xB7 ") 2464 }) 2465 ] 2466 }) : null, 2467 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__10["jsxs"])("div", { 2468 className: "flex items-center gap-2 pt-1", 2469 children: [ 2470 showJoin ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__10["jsx"])(__TURBOPACK__imported__module__110035__8["Button"], { 2471 type: "button", 2472 size: "sm", 2473 onClick: ()=>onJoin(item), 2474 children: t("customers.calendar.peek.join", "Join") 2475 }) : null,
2476 canManage ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__10["jsx"])(__TURBOPACK__imported__module__110035__8["Button"], { 2477 type: "button", 2478 size: "sm", 2479 variant: "secondary", 2480 onClick: ()=>{ 2481 onOpenChange(false); 2482 onEdit(item); 2483 }, 2484 children: t("customers.calendar.peek.edit", "Edit") 2485 }) : /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__10["jsx"])(__TURBOPACK__imported__module__220339__["SimpleTooltip"], { 2486 content: t("customers.calendar.peek.editForbidden", "You don't have permission to edit events"), 2487 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__10["jsx"])("span", { 2488 className: "inline-flex", 2489 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__10["jsx"])(__TURBOPACK__imported__module__110035__8["Button"], { 2490 type: "button", 2491 size: "sm", 2492 variant: "secondary", 2493 disabled: true, 2494 className: "pointer-events-none", 2495 children: t("customers.calendar.peek.edit", "Edit") 2496 }) 2497 }) 2498 }) 2499 ] 2500 }) 2501 ] 2502 }) 2503 }) 2504 ] 2505 }); 2506} 2507; 2508"use client"; 2509; 2510; 2511; 2512; 2513; 2514; 2515; 2516; 2517; 2518; 2519; 2520; 2521; 2522; 2523; 2524const HOUR_HEIGHT_PX = 120; 2525const HOURS_PER_DAY = 24; 2526const GRID_BODY_MAX_HEIGHT_PX = 654; 2527const INITIAL_SCROLL_HOUR = 8; 2528const BLOCK_VERTICAL_GAP_PX = 1; 2529const MIN_BLOCK_HEIGHT_PX = 32; 2530const PACKED_COLUMN_GAP_PX = 2; 2531const NON_WORKING_HATCH_BACKGROUND = "repeating-linear-gradient(45deg, transparent 0px, transparent 8px, var(--border) 8px, var(--border) 9px)"; 2532function buildDayColumn(dayStart, items) { 2533 const dayEnd = (0, __TURBOPACK__imported__module__595727__4["addDays"])(dayStart, 1); 2534 const dayStartMs = dayStart.getTime(); 2535 const dayEndMs = dayEnd.getTime(); 2536 const allDayItems = []; 2537 const segments = []; 2538 for (const item of items){ 2539 const startMs = item.start.getTime(); 2540 const endMs = item.end.getTime(); 2541 if (startMs >= dayEndMs || endMs <= dayStartMs) continue; 2542 if (item.allDay) { 2543 allDayItems.push(item); 2544 continue; 2545 } 2546 segments.push({ 2547 original: item, 2548 start: startMs < dayStartMs ? dayStart : item.start, 2549 end: endMs > dayEndMs ? dayEnd : item.end 2550 }); 2551 } 2552 allDayItems.sort((first, second)=>first.start.getTime() - second.start.getTime()); 2553 const clones = segments.map((segment)=>({ 2554 ...segment.original, 2555 start: segment.start, 2556 end: segment.end 2557 })); 2558 const originalByClone = /* @__PURE__ */ new Map(); 2559 clones.forEach((clone, index)=>originalByClone.set(clone, segments[index].original)); 2560 const blocks = packOverlaps(clones).map(({ item: clone, column, columns })=>{ 2561 const startMinutes = (clone.start.getTime() - dayStartMs) / 6e4; 2562 const durationMinutes = (clone.end.getTime() - clone.start.getTime()) / 6e4; 2563 const rawTop = startMinutes / 60 * HOUR_HEIGHT_PX; 2564 const rawHeight = durationMinutes / 60 * HOUR_HEIGHT_PX; 2565 const widthPct = 100 / columns; 2566 return { 2567 item: originalByClone.get(clone) ?? clone, 2568 top: rawTop + BLOCK_VERTICAL_GAP_PX, 2569 height: Math.max(MIN_BLOCK_HEIGHT_PX, rawHeight - BLOCK_VERTICAL_GAP_PX * 2), 2570 insetInlineStart: `calc(${column * widthPct}% + ${column * PACKED_COLUMN_GAP_PX}px)`, 2571 width: `calc(${widthPct}% - ${(columns - 1) * PACKED_COLUMN_GAP_PX / columns}px)` 2572 }; 2573 }); 2574 return { 2575 dayStart, 2576 allDayItems, 2577 blocks 2578 }; 2579} 2580function ConflictBadge({ count }) { 2581 const t = (0, __TURBOPACK__imported__module__928441__8["useT"])(); 2582 const label = count === 1 ? t("customers.calendar.grid.conflictCount", "1 conflict") : t("customers.calendar.grid.conflictsCount", "{count} conflicts", { 2583 count 2584 }); 2585 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsxs"])("span", { 2586 className: "pointer-events-none absolute left-2 top-1 z-40 inline-flex items-center gap-1 rounded-full bg-status-error-bg px-2 py-0.5 text-overline font-medium uppercase tracking-wide text-status-error-text", 2587 children: [
2588 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])("span", { 2589 "aria-hidden": true, 2590 className: "size-1.5 rounded-full bg-status-error-icon" 2591 }), 2592 label 2593 ] 2594 }); 2595} 2596const AllDayChip = /*#__PURE__*/ __TURBOPACK__imported__module__271645__5["forwardRef"](function AllDayChip2({ item, conflicted, highlighted, selected, nowMs, className, ...buttonProps }, ref) { 2597 const t = (0, __TURBOPACK__imported__module__928441__8["useT"])(); 2598 const tone = resolveEventTone(item, nowMs); 2599 const title = item.title || t("customers.calendar.grid.untitled", "Untitled"); 2600 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])(__TURBOPACK__imported__module__110035__6["Button"], { 2601 ref, 2602 type: "button", 2603 variant: "ghost", 2604 "aria-label": `${title}, ${t("customers.calendar.grid.allDay", "All day")}`, 2605 className: (0, __TURBOPACK__imported__module__406911__2["cn"])("h-auto w-full min-w-0 justify-start rounded-sm px-2 py-0.5 text-start hover:bg-muted/70", tone.surfaceClassName, conflicted && "ring-1 ring-status-warning-icon", selected && "shadow-md ring-2 ring-foreground", highlighted && "motion-safe:animate-pulse", "focus-visible:ring-2 focus-visible:ring-ring", className), 2606 style: tone.style, 2607 ...buttonProps, 2608 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])("span", { 2609 className: (0, __TURBOPACK__imported__module__406911__2["cn"])("truncate text-xs font-medium", tone.titleClassName), 2610 children: title 2611 }) 2612 }); 2613}); 2614AllDayChip.displayName = "AllDayChip"; 2615function TimeGrid({ days, anchor, items, conflictIds, showWeekends, showConflicts, aiSummaries, canManage = true, highlightItemId, onItemClick, onJoin, onNavigate, onCreateRange }) { 2616 const t = (0, __TURBOPACK__imported__module__928441__8["useT"])(); 2617 const locale = (0, __TURBOPACK__imported__module__928441__8["useLocale"])(); 2618 const scrollRef = __TURBOPACK__imported__module__271645__5["useRef"](null); 2619 const nowMs = Date.now(); 2620 const today = (0, __TURBOPACK__imported__module__585890__2["startOfDay"])(/* @__PURE__ */ new Date()); 2621 const todayMs = today.getTime(); 2622 const anchorMs = anchor.getTime(); 2623 const [selectedId, setSelectedId] = __TURBOPACK__imported__module__271645__5["useState"](null); 2624 const [drag, setDrag] = __TURBOPACK__imported__module__271645__5["useState"](null); 2625 const dayStarts = __TURBOPACK__imported__module__271645__5["useMemo"](()=>{ 2626 const rangeStart = (0, __TURBOPACK__imported__module__467550__2["getVisibleRange"])(days === 7 ? "week" : "day", new Date(anchorMs), 0).from; 2627 const all = Array.from({ 2628 length: days 2629 }, (_, index)=>(0, __TURBOPACK__imported__module__595727__4["addDays"])(rangeStart, index)); 2630 return days === 7 ? applyWeekendVisibility(all, showWeekends, new Date(todayMs)) : all; 2631 }, [ 2632 days, 2633 anchorMs, 2634 showWeekends, 2635 todayMs 2636 ]); 2637 const dayColumns = __TURBOPACK__imported__module__271645__5["useMemo"](()=>dayStarts.map((dayStart)=>buildDayColumn(dayStart, items)), [ 2638 dayStarts, 2639 items 2640 ]); 2641 const resolveJoinUrl = __TURBOPACK__imported__module__271645__5["useCallback"]((location)=>{ 2642 const trimmed = location?.trim() ?? ""; 2643 if (!trimmed) return null; 2644 if (/^https?:\/\//i.test(trimmed)) return trimmed; 2645 if (/^www\./i.test(trimmed)) return `https://${trimmed}`; 2646 return null; 2647 }, []); 2648 const hasAllDayLane = dayColumns.some((column)=>column.allDayItems.length > 0); 2649 const formatters = __TURBOPACK__imported__module__271645__5["useMemo"](()=>({ 2650 dayNumber: new Intl.DateTimeFormat(locale, { 2651 day: "2-digit" 2652 }), 2653 weekdayShort: new Intl.DateTimeFormat(locale, { 2654 weekday: "short" 2655 }), 2656 weekdayLong: new Intl.DateTimeFormat(locale, { 2657 weekday: "long" 2658 }) 2659 }), [ 2660 locale 2661 ]); 2662 const hourLabels = __TURBOPACK__imported__module__271645__5["useMemo"](()=>{ 2663 const formatter = new Intl.DateTimeFormat(locale, { 2664 hour: "numeric" 2665 }); 2666 return Array.from({ 2667 length: HOURS_PER_DAY 2668 }, (_, hour)=>formatter.format(new Date(2024, 0, 1, hour))); 2669 }, [ 2670 locale 2671 ]); 2672 __TURBOPACK__imported__module__271645__5["useEffect"](()=>{ 2673 const node = scrollRef.current; 2674 if (!node) return; 2675 node.scrollTop = INITIAL_SCROLL_HOUR * HOUR_HEIGHT_PX; 2676 }, []); 2677 __TURBOPACK__imported__module__271645__5["useEffect"](()=>{ 2678 if (!highlightItemId) return; 2679 const node = scrollRef.current; 2680 if (!node) return; 2681 const target = items.find((item)=>item.id === highlightItemId && !item.allDay); 2682 if (!target) return; 2683 const minutes = (target.start.getTime() - (0, __TURBOPACK__imported__module__585890__2["startOfDay"])(target.start).getTime()) / 6e4; 2684 const top = minutes / 60 * HOUR_HEIGHT_PX; 2685 const reduceMotion = ("TURBOPACK compile-time value", "object") !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches; 2686 node.scrollTo({ 2687 top: Math.max(0, top - HOUR_HEIGHT_PX), 2688 behavior: reduceMotion ? "auto" : "smooth" 2689 }); 2690 }, [ 2691 highlightItemId, 2692 items 2693 ]); 2694 const nonWorkingLabel = t("customers.calendar.grid.nonWorking", "Non-working day"); 2695 const previousLabel = days === 7 ? t("customers.calendar.previousWeek", "Previous week") : t("customers.calendar.grid.previousDay", "Previous day"); 2696 const nextLabel = days === 7 ? t("customers.calendar.nextWeek", "Next week") : t("customers.calendar.grid.nextDay", "Next day"); 2697 const headerLabelFor = (dayStart)=>{ 2698 const dayNumber = formatters.dayNumber.format(dayStart); 2699 if (days === 1) return `${formatters.weekdayLong.format(dayStart).toUpperCase()} \xB7 ${dayNumber}`; 2700 return `${dayNumber} ${formatters.weekdayShort.format(dayStart).toUpperCase()}`; 2701 }; 2702 const canCreateRange = Boolean(onCreateRange); 2703 const beginDrag = (event, dayStart)=>{ 2704 if (!canCreateRange || event.button !== 0) return; 2705 const layer = event.currentTarget; 2706 const rect = layer.getBoundingClientRect(); 2707 const minute = offsetYToMinutes(event.clientY - rect.top, HOUR_HEIGHT_PX); 2708 try { 2709 layer.setPointerCapture(event.pointerId); 2710 } catch {} 2711 setSelectedId(null); 2712 setDrag({ 2713 dayMs: dayStart.getTime(), 2714 startMin: minute, 2715 endMin: minute, 2716 moved: false 2717 }); 2718 }; 2719 const moveDrag = (event)=>{ 2720 const rect = event.currentTarget.getBoundingClientRect(); 2721 const minute = offsetYToMinutes(event.clientY - rect.top, HOUR_HEIGHT_PX); 2722 setDrag((previous)=>{ 2723 if (!previous) return previous; 2724 return { 2725 ...previous, 2726 endMin: minute, 2727 moved: previous.moved || Math.abs(minute - previous.startMin) >= DRAG_SNAP_MINUTES 2728 }; 2729 }); 2730 }; 2731 const endDrag = (dayStart)=>{ 2732 setDrag((previous)=>{ 2733 if (previous && previous.moved && onCreateRange) { 2734 const range = buildDragRange(dayStart, previous.startMin, previous.endMin); 2735 onCreateRange(range.start, range.end); 2736 } 2737 return null; 2738 }); 2739 }; 2740 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])("div", { 2741 className: "relative flex flex-col overflow-hidden rounded-lg border border-border bg-card", 2742 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsxs"])("div", { 2743 ref: scrollRef, 2744 className: "overflow-auto overscroll-contain", 2745 style: { 2746 maxHeight: GRID_BODY_MAX_HEIGHT_PX 2747 }, 2748 children: [
2749 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsxs"])("div", { 2750 className: "sticky top-0 z-30 min-w-full bg-card max-md:w-max", 2751 children: [ 2752 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsxs"])("div", { 2753 className: "flex border-b border-border", 2754 children: [ 2755 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsxs"])("div", { 2756 className: "sticky start-0 z-10 flex w-14 shrink-0 bg-card md:w-26", 2757 children: [ 2758 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])("span", { 2759 className: "flex flex-1 items-center justify-center border-e border-border", 2760 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])(__TURBOPACK__imported__module__741870__1["IconButton"], { 2761 type: "button", 2762 variant: "ghost", 2763 size: "xs", 2764 "aria-label": previousLabel, 2765 onClick: ()=>onNavigate(-days), 2766 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])(__TURBOPACK__imported__module__373375__["ChevronLeft"], { 2767 "aria-hidden": true 2768 }) 2769 }) 2770 }),
2771 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])("span", { 2772 className: "flex flex-1 items-center justify-center border-e border-border", 2773 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])(__TURBOPACK__imported__module__741870__1["IconButton"], { 2774 type: "button", 2775 variant: "ghost", 2776 size: "xs", 2777 "aria-label": nextLabel, 2778 onClick: ()=>onNavigate(days), 2779 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])(__TURBOPACK__imported__module__463059__["ChevronRight"], { 2780 "aria-hidden": true 2781 }) 2782 }) 2783 }) 2784 ] 2785 }), 2786 dayColumns.map(({ dayStart })=>{ 2787 const isToday = isSameDay(dayStart, today); 2788 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])("div", { 2789 className: (0, __TURBOPACK__imported__module__406911__2["cn"])("flex min-w-0 flex-1 items-center justify-center border-e border-border bg-muted px-1 py-2 last:border-e-0", days === 7 && "min-w-[120px] max-md:max-w-[120px] md:min-w-0"), 2790 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])("span", { 2791 className: (0, __TURBOPACK__imported__module__406911__2["cn"])("truncate text-xs uppercase tracking-wide", isToday ? "font-semibold text-foreground" : "font-medium text-muted-foreground"), 2792 children: headerLabelFor(dayStart) 2793 }) 2794 }, dayStart.getTime()); 2795 }) 2796 ] 2797 }), 2798 hasAllDayLane ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsxs"])("div", { 2799 className: "flex border-b border-border", 2800 children: [
2801 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])("div", { 2802 className: "sticky start-0 z-10 flex w-14 shrink-0 items-center justify-center border-e border-border bg-card py-1 md:w-26", 2803 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])("span", { 2804 className: "truncate text-overline uppercase tracking-wide text-muted-foreground", 2805 children: t("customers.calendar.grid.allDay", "All day") 2806 }) 2807 }), 2808 dayColumns.map(({ dayStart, allDayItems })=>/* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])("div", { 2809 className: (0, __TURBOPACK__imported__module__406911__2["cn"])("min-w-0 flex-1 space-y-1 border-e border-border p-1 last:border-e-0", days === 7 && "min-w-[120px] max-md:max-w-[120px] md:min-w-0"), 2810 children: allDayItems.map((item)=>/* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])(EventPeekPopover, { 2811 item, 2812 open: selectedId === item.id, 2813 joinUrl: resolveJoinUrl(item.location), 2814 aiSummaries, 2815 canManage, 2816 onOpenChange: (open)=>setSelectedId(open ? item.id : null), 2817 onJoin, 2818 onEdit: onItemClick, 2819 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])(AllDayChip, { 2820 item, 2821 conflicted: showConflicts && conflictIds.has(item.id), 2822 highlighted: highlightItemId === item.id, 2823 selected: selectedId === item.id, 2824 nowMs 2825 }) 2826 }, item.id)) 2827 }, dayStart.getTime())) 2828 ] 2829 }) : null 2830 ] 2831 }),
2832 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsxs"])("div", { 2833 className: "flex min-w-full max-md:w-max", 2834 style: { 2835 height: HOURS_PER_DAY * HOUR_HEIGHT_PX 2836 }, 2837 children: [ 2838 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])("div", { 2839 className: "sticky start-0 z-10 w-14 shrink-0 border-e border-border bg-card md:w-26", 2840 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])("div", { 2841 className: "relative h-full", 2842 children: hourLabels.map((label, hour)=>hour === 0 ? null : /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])("span", { 2843 className: "absolute w-full -translate-y-1/2 px-1 text-center text-xs font-medium text-muted-foreground md:px-3 md:text-sm", 2844 style: { 2845 top: hour * HOUR_HEIGHT_PX 2846 }, 2847 children: label 2848 }, hour)) 2849 }) 2850 }), 2851 dayColumns.map(({ dayStart, blocks })=>{ 2852 const nonWorking = isWeekendDay(dayStart); 2853 const conflictCount = showConflicts ? blocks.filter((block)=>conflictIds.has(block.item.id)).length : 0; 2854 const dragActive = drag && drag.moved && drag.dayMs === dayStart.getTime(); 2855 const dragRange = dragActive ? buildDragRange(dayStart, drag.startMin, drag.endMin) : null; 2856 const dragStartMinutes = dragRange ? (dragRange.start.getTime() - (0, __TURBOPACK__imported__module__585890__2["startOfDay"])(dragRange.start).getTime()) / 6e4 : 0; 2857 const dragDurationMinutes = dragRange ? (dragRange.end.getTime() - dragRange.start.getTime()) / 6e4 : 0; 2858 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsxs"])("div", { 2859 className: (0, __TURBOPACK__imported__module__406911__2["cn"])("relative min-w-0 flex-1 border-e border-border last:border-e-0", days === 7 && "min-w-[120px] max-md:max-w-[120px] md:min-w-0"), 2860 title: nonWorking ? nonWorkingLabel : void 0, 2861 children: [
2862 nonWorking ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])("span", { 2863 className: "sr-only", 2864 children: nonWorkingLabel 2865 }) : null, 2866 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])("div", { 2867 "aria-hidden": true, 2868 className: "absolute inset-0", 2869 children: Array.from({ 2870 length: HOURS_PER_DAY 2871 }, (_, hour)=>/* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])("div", { 2872 className: "relative h-30 border-b border-border", 2873 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])("span", { 2874 className: "absolute inset-x-0 top-1/2 h-px bg-border/50" 2875 }) 2876 }, hour)) 2877 }),
2878 nonWorking ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])("div", { 2879 "aria-hidden": true, 2880 className: "pointer-events-none absolute inset-0", 2881 style: { 2882 backgroundImage: NON_WORKING_HATCH_BACKGROUND 2883 } 2884 }) : null, 2885 canCreateRange ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])("div", { 2886 className: "absolute inset-0 cursor-cell", 2887 onPointerDown: (event)=>beginDrag(event, dayStart), 2888 onPointerMove: moveDrag, 2889 onPointerUp: ()=>endDrag(dayStart), 2890 onPointerCancel: ()=>setDrag(null), 2891 "aria-hidden": true 2892 }) : null,
2893 dragRange ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsxs"])("div", { 2894 "aria-hidden": true, 2895 className: "pointer-events-none absolute z-30 flex flex-col gap-0.5 overflow-hidden rounded-md border-2 border-dashed border-foreground bg-accent-indigo/10 px-2 pt-1.5", 2896 style: { 2897 top: dragStartMinutes / 60 * HOUR_HEIGHT_PX, 2898 height: Math.max(MIN_BLOCK_HEIGHT_PX, dragDurationMinutes / 60 * HOUR_HEIGHT_PX), 2899 insetInlineStart: 8, 2900 insetInlineEnd: 8 2901 }, 2902 children: [ 2903 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])("span", { 2904 className: "text-overline font-semibold text-foreground", 2905 children: t("customers.calendar.actions.newEvent", "New event") 2906 }),
2907 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])("span", { 2908 className: "text-overline text-muted-foreground", 2909 children: formatTimeRange(locale, dragRange.start, dragRange.end) 2910 }) 2911 ] 2912 }) : null, 2913 conflictCount > 0 ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])(ConflictBadge, { 2914 count: conflictCount 2915 }) : null, 2916 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])("div", { 2917 className: "pointer-events-none absolute inset-y-0", 2918 style: { 2919 insetInlineStart: 8, 2920 insetInlineEnd: 8 2921 }, 2922 children: blocks.map((block)=>/* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])(EventPeekPopover, { 2923 item: block.item, 2924 open: selectedId === block.item.id, 2925 joinUrl: resolveJoinUrl(block.item.location), 2926 aiSummaries, 2927 canManage, 2928 onOpenChange: (open)=>setSelectedId(open ? block.item.id : null), 2929 onJoin, 2930 onEdit: onItemClick, 2931 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__8["jsx"])(EventBlock, { 2932 item: block.item, 2933 top: block.top, 2934 height: block.height, 2935 insetInlineStart: block.insetInlineStart, 2936 width: block.width, 2937 conflicted: showConflicts && conflictIds.has(block.item.id), 2938 highlighted: highlightItemId === block.item.id, 2939 selected: selectedId === block.item.id, 2940 nowMs 2941 }) 2942 }, `${block.item.id}-${block.top}`)) 2943 }) 2944 ] 2945 }, dayStart.getTime()); 2946 }) 2947 ] 2948 }) 2949 ] 2950 }) 2951 }); 2952} 2953; 2954// MERGED MODULE: [project]/node_modules/@open-mercato/core/dist/modules/customers/components/calendar/UpcomingCards.js [app-client] (ecmascript) 2955; 2956var __TURBOPACK__imported__module__843476__11 = __TURBOPACK__imported__module__843476__; 2957var __TURBOPACK__imported__module__381515__ = __turbopack_context__.i(381515); 2958var __TURBOPACK__imported__module__878894__ = __turbopack_context__.i(878894); 2959var __TURBOPACK__imported__module__664659__ = __turbopack_context__.i(664659); 2960var __TURBOPACK__imported__module__503116__1 = __TURBOPACK__imported__module__503116__; 2961var __TURBOPACK__imported__module__110035__9 = __TURBOPACK__imported__module__110035__; 2962var __TURBOPACK__imported__module__741870__2 = __TURBOPACK__imported__module__741870__; 2963var __TURBOPACK__imported__module__228072__ = __turbopack_context__.i(228072); 2964var __TURBOPACK__imported__module__388528__2 = __TURBOPACK__imported__module__388528__;
2965var __TURBOPACK__imported__module__928441__11 = __TURBOPACK__imported__module__928441__; 2966"use client"; 2967; 2968; 2969; 2970; 2971; 2972; 2973; 2974; 2975; 2976function formatTimeRange1(locale, item, allDayLabel) { 2977 if (item.allDay) return allDayLabel; 2978 return formatTimeRangeLabel(locale, item.start, item.end); 2979} 2980function canJoin(item) { 2981 return item.locationKind === "url" || item.locationKind === "platform"; 2982} 2983function UpcomingCardStatus({ card, onJoin, onSeeConflict }) { 2984 const t = (0, __TURBOPACK__imported__module__928441__11["useT"])(); 2985 const locale = (0, __TURBOPACK__imported__module__928441__11["useLocale"])(); 2986 const { item, kind, conflictCount } = card; 2987 if (kind === "today") { 2988 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsxs"])("div", { 2989 className: "flex w-full items-center gap-1.5 rounded-lg bg-status-success-bg py-2 pl-2 pr-3", 2990 children: [ 2991 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsx"])(__TURBOPACK__imported__module__503116__1["Clock"], { 2992 className: "size-4 shrink-0 text-status-success-icon", 2993 "aria-hidden": "true" 2994 }),
2995 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsx"])("span", { 2996 className: "min-w-0 flex-1 truncate text-xs font-medium text-foreground", 2997 children: t("customers.calendar.cards.today", "Today") 2998 }), 2999 canJoin(item) ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsx"])(__TURBOPACK__imported__module__228072__["LinkButton"], { 3000 variant: "gray", 3001 size: "sm", 3002 underline: "always", 3003 onClick: ()=>onJoin(item), 3004 className: "shrink-0", 3005 children: t("customers.calendar.cards.join", "Join Meeting") 3006 }) : null 3007 ] 3008 }); 3009 } 3010 if (kind === "conflicted") { 3011 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsxs"])("div", { 3012 className: "flex w-full items-center gap-1.5 rounded-lg bg-status-warning-bg py-2 pl-2 pr-3", 3013 children: [
3014 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsx"])(__TURBOPACK__imported__module__878894__["AlertTriangle"], { 3015 className: "size-4 shrink-0 text-status-warning-icon", 3016 "aria-hidden": "true" 3017 }), 3018 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsx"])("span", { 3019 className: "min-w-0 flex-1 truncate text-xs font-medium text-foreground", 3020 children: t("customers.calendar.cards.conflictedCount", "{count} Conflicted", { 3021 count: conflictCount 3022 }) 3023 }), 3024 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsx"])(__TURBOPACK__imported__module__228072__["LinkButton"], { 3025 variant: "gray", 3026 size: "sm", 3027 underline: "always", 3028 onClick: ()=>onSeeConflict(item), 3029 className: "shrink-0", 3030 children: t("customers.calendar.cards.seeConflict", "See Conflict") 3031 }) 3032 ] 3033 }); 3034 } 3035 if (kind === "cancelled") { 3036 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsxs"])("div", { 3037 className: "flex w-full items-center gap-1.5 rounded-lg bg-status-error-bg py-2 pl-2 pr-3", 3038 children: [
3039 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsx"])(__TURBOPACK__imported__module__503116__1["Clock"], { 3040 className: "size-4 shrink-0 text-status-error-icon", 3041 "aria-hidden": "true" 3042 }), 3043 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsx"])("span", { 3044 className: "min-w-0 flex-1 truncate text-xs font-medium text-foreground", 3045 children: t("customers.calendar.cards.cancelled", "Cancelled") 3046 }), 3047 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsx"])("span", { 3048 className: "shrink-0 text-xs text-muted-foreground", 3049 children: formatDateLabel(locale, item.start) 3050 }) 3051 ] 3052 }); 3053 } 3054 const daysLater = Math.max(0, (0, __TURBOPACK__imported__module__381515__["differenceInCalendarDays"])(item.start, /* @__PURE__ */ new Date())); 3055 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsxs"])("div", { 3056 className: "flex w-full items-center gap-1.5 rounded-lg bg-muted py-2 pl-2 pr-3", 3057 children: [
3058 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsx"])(__TURBOPACK__imported__module__503116__1["Clock"], { 3059 className: "size-4 shrink-0 text-muted-foreground", 3060 "aria-hidden": "true" 3061 }), 3062 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsx"])("span", { 3063 className: "min-w-0 flex-1 truncate text-xs text-muted-foreground", 3064 children: daysLater === 1 ? t("customers.calendar.cards.dayLater", "1 day later") : t("customers.calendar.cards.daysLater", "{days} days later", { 3065 days: daysLater 3066 }) 3067 }), 3068 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsx"])("span", { 3069 className: "shrink-0 text-xs text-muted-foreground", 3070 children: formatDateLabel(locale, item.start) 3071 }) 3072 ] 3073 }); 3074} 3075function UpcomingCardItem({ card, canManage, onJoin, onSeeConflict, onOpen, onEdit, onCancel }) { 3076 const t = (0, __TURBOPACK__imported__module__928441__11["useT"])(); 3077 const locale = (0, __TURBOPACK__imported__module__928441__11["useLocale"])(); 3078 const { item } = card; 3079 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsxs"])("article", { 3080 className: "flex w-[260px] shrink-0 snap-start flex-col gap-3 rounded-xl border bg-card px-2 pb-2 pt-4 shadow-xs sm:w-auto sm:shrink", 3081 children: [
3082 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsxs"])("div", { 3083 className: "flex items-start gap-2 px-2", 3084 children: [ 3085 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsxs"])("div", { 3086 className: "flex min-w-0 flex-1 flex-col gap-1", 3087 children: [ 3088 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsx"])("p", { 3089 className: "truncate text-sm font-medium text-foreground", 3090 children: item.title 3091 }), 3092 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsx"])("p", { 3093 className: "truncate text-xs text-muted-foreground", 3094 children: formatTimeRange1(locale, item, t("customers.calendar.cards.allDay", "All day")) 3095 }) 3096 ] 3097 }),
3098 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsxs"])(__TURBOPACK__imported__module__388528__2["Popover"], { 3099 children: [ 3100 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsx"])(__TURBOPACK__imported__module__388528__2["PopoverTrigger"], { 3101 asChild: true, 3102 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsx"])(__TURBOPACK__imported__module__741870__2["IconButton"], { 3103 variant: "outline", 3104 size: "xs", 3105 fullRadius: true, 3106 "aria-label": t("customers.calendar.cards.menu.label", "Event actions"), 3107 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsx"])(__TURBOPACK__imported__module__664659__["ChevronDown"], { 3108 "aria-hidden": "true" 3109 }) 3110 }) 3111 }),
3112 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsxs"])(__TURBOPACK__imported__module__388528__2["PopoverContent"], { 3113 align: "end", 3114 className: "w-40 min-w-0 p-1", 3115 children: [ 3116 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsx"])(__TURBOPACK__imported__module__388528__2["PopoverClose"], { 3117 asChild: true, 3118 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsx"])(__TURBOPACK__imported__module__110035__9["Button"], { 3119 type: "button", 3120 variant: "ghost", 3121 size: "sm", 3122 className: "w-full justify-start", 3123 onClick: ()=>onOpen(item), 3124 children: t("customers.calendar.cards.menu.open", "Open") 3125 }) 3126 }),
3127 canManage ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsx"])(__TURBOPACK__imported__module__388528__2["PopoverClose"], { 3128 asChild: true, 3129 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsx"])(__TURBOPACK__imported__module__110035__9["Button"], { 3130 type: "button", 3131 variant: "ghost", 3132 size: "sm", 3133 className: "w-full justify-start", 3134 onClick: ()=>onEdit(item), 3135 children: t("customers.calendar.cards.menu.edit", "Edit") 3136 }) 3137 }) : null, 3138 canManage ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsx"])(__TURBOPACK__imported__module__388528__2["PopoverClose"], { 3139 asChild: true, 3140 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsx"])(__TURBOPACK__imported__module__110035__9["Button"], { 3141 type: "button", 3142 variant: "destructive-ghost", 3143 size: "sm", 3144 className: "w-full justify-start", 3145 onClick: ()=>onCancel(item), 3146 children: t("customers.calendar.cards.menu.cancel", "Cancel") 3147 }) 3148 }) : null 3149 ] 3150 }) 3151 ] 3152 }) 3153 ] 3154 }),
3155 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsx"])(UpcomingCardStatus, { 3156 card, 3157 onJoin, 3158 onSeeConflict 3159 }) 3160 ] 3161 }); 3162} 3163function UpcomingCards({ cards, canManage = true, onJoin, onSeeConflict, onOpen, onEdit, onCancel }) { 3164 if (cards.length === 0) return null; 3165 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsx"])("div", { 3166 className: "flex snap-x snap-mandatory gap-3 overflow-x-auto pb-1 sm:grid sm:snap-none sm:grid-cols-2 sm:gap-4 sm:overflow-visible sm:pb-0 xl:grid-cols-4", 3167 children: cards.map((card)=>/* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__11["jsx"])(UpcomingCardItem, { 3168 card, 3169 canManage, 3170 onJoin, 3171 onSeeConflict, 3172 onOpen, 3173 onEdit, 3174 onCancel 3175 }, card.item.id)) 3176 }); 3177} 3178; 3179// MERGED MODULE: [project]/node_modules/@open-mercato/core/dist/modules/customers/components/calendar/CalendarSettingsModal.js [app-client] (ecmascript) 3180; 3181var __TURBOPACK__imported__module__843476__12 = __TURBOPACK__imported__module__843476__; 3182var __TURBOPACK__imported__module__271645__8 = __TURBOPACK__imported__module__271645__; 3183var __TURBOPACK__imported__module__952571__ = __turbopack_context__.i(952571); 3184var __TURBOPACK__imported__module__37727__ = __turbopack_context__.i(37727); 3185var __TURBOPACK__imported__module__959411__ = __turbopack_context__.i(959411); 3186var __TURBOPACK__imported__module__928441__12 = __TURBOPACK__imported__module__928441__; 3187var __TURBOPACK__imported__module__110035__10 = __TURBOPACK__imported__module__110035__; 3188var __TURBOPACK__imported__module__644149__1 = __TURBOPACK__imported__module__644149__; 3189var __TURBOPACK__imported__module__741870__3 = __TURBOPACK__imported__module__741870__; 3190var __TURBOPACK__imported__module__828010__ = __turbopack_context__.i(828010); 3191var __TURBOPACK__imported__module__410777__ = __turbopack_context__.i(410777); 3192var __TURBOPACK__imported__module__220339__1 = __TURBOPACK__imported__module__220339__; 3193var __TURBOPACK__imported__module__908159__ = __turbopack_context__.i(908159); 3194// MERGED MODULE: [project]/node_modules/@open-mercato/core/dist/modules/customers/lib/calendar/preferences.js [app-client] (ecmascript) 3195; 3196const CONFLICT_SCOPES = [ 3197 "mine", 3198 "all" 3199]; 3200const MAX_EVENT_CATEGORIES = 8; 3201const MAX_ACTIVITY_TYPES = 6; 3202const DEFAULT_CALENDAR_PREFERENCES = { 3203 showWeekends: false, 3204 conflictWarnings: true, 3205 conflictScope: "mine", 3206 showCrmActivities: true, 3207 aiSummaries: true, 3208 eventCategories: [], 3209 activityTypes: [] 3210}; 3211const CALENDAR_PREFERENCES_STORAGE_PREFIX = "om.customers.calendar.preferences.v1"; 3212function calendarPreferencesStorageKey(scopeKey) { 3213 return `${CALENDAR_PREFERENCES_STORAGE_PREFIX}:${scopeKey}`; 3214} 3215function normalizeCalendarTagList(value, max) { 3216 if (!Array.isArray(value)) return []; 3217 const seen = /* @__PURE__ */ new Set(); 3218 const result = []; 3219 for (const entry of value){ 3220 if (typeof entry !== "string") continue; 3221 const trimmed = entry.trim(); 3222 if (!trimmed || seen.has(trimmed)) continue; 3223 seen.add(trimmed); 3224 result.push(trimmed); 3225 if (result.length >= max) break; 3226 } 3227 return result; 3228} 3229function readConflictScope(value, fallback) { 3230 return value === "mine" || value === "all" ? value : fallback; 3231} 3232function mergeCalendarPreferences(stored) { 3233 if (!stored || typeof stored !== "object") return { 3234 ...DEFAULT_CALENDAR_PREFERENCES 3235 }; 3236 const record = stored; 3237 const readBoolean = (key, fallback)=>typeof record[key] === "boolean" ? record[key] : fallback; 3238 return { 3239 showWeekends: readBoolean("showWeekends", DEFAULT_CALENDAR_PREFERENCES.showWeekends), 3240 conflictWarnings: readBoolean("conflictWarnings", DEFAULT_CALENDAR_PREFERENCES.conflictWarnings), 3241 conflictScope: readConflictScope(record.conflictScope, DEFAULT_CALENDAR_PREFERENCES.conflictScope), 3242 showCrmActivities: readBoolean("showCrmActivities", DEFAULT_CALENDAR_PREFERENCES.showCrmActivities), 3243 aiSummaries: readBoolean("aiSummaries", DEFAULT_CALENDAR_PREFERENCES.aiSummaries), 3244 eventCategories: normalizeCalendarTagList(record.eventCategories, MAX_EVENT_CATEGORIES), 3245 activityTypes: normalizeCalendarTagList(record.activityTypes, MAX_ACTIVITY_TYPES) 3246 }; 3247} 3248function parseStoredCalendarPreferences(raw) { 3249 if (!raw) return { 3250 ...DEFAULT_CALENDAR_PREFERENCES 3251 }; 3252 try { 3253 return mergeCalendarPreferences(JSON.parse(raw)); 3254 } catch { 3255 return { 3256 ...DEFAULT_CALENDAR_PREFERENCES 3257 }; 3258 } 3259} 3260function calendarPreferencesEqual(first, second) { 3261 return first.showWeekends === second.showWeekends && first.conflictWarnings === second.conflictWarnings && first.conflictScope === second.conflictScope && first.showCrmActivities === second.showCrmActivities && first.aiSummaries === second.aiSummaries && first.eventCategories.length === second.eventCategories.length && first.eventCategories.every((value, index)=>value === second.eventCategories[index]) && first.activityTypes.length === second.activityTypes.length && first.activityTypes.every((value, index)=>value === second.activityTypes[index]); 3262} 3263; 3264var __TURBOPACK__imported__module__221709__ = __turbopack_context__.i(221709); 3265"use client"; 3266; 3267; 3268; 3269; 3270; 3271; 3272; 3273; 3274; 3275; 3276; 3277; 3278; 3279; 3280function buildDraft(preferences, seedActivityTypes) { 3281 return { 3282 ...preferences, 3283 eventCategories: [ 3284 ...preferences.eventCategories 3285 ], 3286 activityTypes: preferences.activityTypes.length > 0 ? [ 3287 ...preferences.activityTypes 3288 ] : seedActivityTypes.slice(0, MAX_ACTIVITY_TYPES) 3289 }; 3290} 3291function CalendarSettingsModal({ open, preferences, seedActivityTypes, onOpenChange, onSave }) { 3292 const t = (0, __TURBOPACK__imported__module__928441__12["useT"])(); 3293 const [draft, setDraft] = __TURBOPACK__imported__module__271645__8["useState"](()=>buildDraft(preferences, seedActivityTypes)); 3294 const openRef = __TURBOPACK__imported__module__271645__8["useRef"](false); 3295 __TURBOPACK__imported__module__271645__8["useEffect"](()=>{ 3296 if (open && !openRef.current) setDraft(buildDraft(preferences, seedActivityTypes)); 3297 openRef.current = open; 3298 }, [ 3299 open, 3300 preferences, 3301 seedActivityTypes 3302 ]); 3303 const handleSave = __TURBOPACK__imported__module__271645__8["useCallback"](()=>{ 3304 onSave(draft); 3305 onOpenChange(false); 3306 }, [ 3307 draft, 3308 onOpenChange, 3309 onSave 3310 ]); 3311 const handleKeyDown = (0, __TURBOPACK__imported__module__908159__["useDialogKeyHandler"])({ 3312 onConfirm: handleSave 3313 }); 3314 const toggle = (key)=>(checked)=>setDraft((current)=>({ 3315 ...current, 3316 [key]: checked 3317 })); 3318 const toggleRows = [ 3319 { 3320 key: "showCrmActivities", 3321 label: t("customers.calendar.settings.showCrmActivities", "Show CRM activities on calendar") 3322 }, 3323 { 3324 key: "aiSummaries", 3325 label: t("customers.calendar.settings.aiSummaries", "AI summaries & quick actions") 3326 }, 3327 { 3328 key: "conflictWarnings", 3329 label: t("customers.calendar.settings.conflictWarnings", "Conflict warnings") 3330 }, 3331 { 3332 key: "showWeekends", 3333 label: t("customers.calendar.settings.showWeekends", "Show weekends") 3334 } 3335 ]; 3336 const title = t("customers.calendar.settings.title", "Customization"); 3337 const removeTagLabel = __TURBOPACK__imported__module__271645__8["useCallback"]((tag)=>t("customers.calendar.settings.removeTag", "Remove {tag}", { 3338 tag 3339 }), [ 3340 t 3341 ]); 3342 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsx"])(__TURBOPACK__imported__module__644149__1["Dialog"], { 3343 open, 3344 onOpenChange, 3345 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsxs"])(__TURBOPACK__imported__module__644149__1["DialogContent"], { 3346 onKeyDown: handleKeyDown, 3347 "aria-describedby": void 0,
3348 dismissible: false, 3349 className: "flex w-full max-w-[400px] flex-col gap-0 overflow-hidden rounded-2xl border-0 bg-card p-0 shadow-xl", 3350 children: [ 3351 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsx"])(__TURBOPACK__imported__module__959411__["VisuallyHidden"], { 3352 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsx"])(__TURBOPACK__imported__module__644149__1["DialogTitle"], { 3353 children: title 3354 }) 3355 }), 3356 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsxs"])("div", { 3357 className: "flex shrink-0 items-start gap-3.5 border-b border-border py-4 pl-5 pr-4", 3358 children: [ 3359 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsxs"])("div", { 3360 className: "flex min-w-0 flex-1 flex-col gap-1", 3361 children: [
3362 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsx"])("p", { 3363 className: "text-sm font-medium leading-5 text-foreground", 3364 children: title 3365 }), 3366 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsx"])("p", { 3367 className: "text-xs leading-4 text-muted-foreground", 3368 children: t("customers.calendar.settings.subtitle", "Customise your calendar module.") 3369 }) 3370 ] 3371 }), 3372 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsx"])(__TURBOPACK__imported__module__741870__3["IconButton"], { 3373 variant: "ghost", 3374 size: "sm", 3375 onClick: ()=>onOpenChange(false), 3376 "aria-label": t("customers.calendar.settings.close", "Close"), 3377 className: "shrink-0 text-muted-foreground", 3378 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsx"])(__TURBOPACK__imported__module__37727__["X"], { 3379 "aria-hidden": true, 3380 className: "size-5" 3381 }) 3382 }) 3383 ] 3384 }),
3385 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsxs"])("div", { 3386 className: "flex flex-col gap-4 p-5", 3387 children: [ 3388 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsx"])(SettingsTagInput, { 3389 label: t("customers.calendar.settings.eventCategories", "Event Categories"), 3390 maxLabel: t("customers.calendar.settings.max", "(max. {count})", { 3391 count: MAX_EVENT_CATEGORIES 3392 }), 3393 hint: t("customers.calendar.settings.eventCategoriesHint", "Your own grouping labels (e.g. Team Meeting, Sales Call). Offered when creating an event."), 3394 placeholder: t("customers.calendar.settings.addCategory", "Add a category\u2026"), 3395 value: draft.eventCategories, 3396 maxTags: MAX_EVENT_CATEGORIES, 3397 removeTagLabel, 3398 onChange: (eventCategories)=>setDraft((current)=>({ 3399 ...current, 3400 eventCategories 3401 })) 3402 }),
3403 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsx"])(SettingsTagInput, { 3404 label: t("customers.calendar.settings.activityTypes", "Activity Types"), 3405 maxLabel: t("customers.calendar.settings.max", "(max. {count})", { 3406 count: MAX_ACTIVITY_TYPES 3407 }), 3408 hint: t("customers.calendar.settings.activityTypesHint", "The activity types your calendar surfaces when creating an event. Seeded from your workspace dictionary."), 3409 placeholder: t("customers.calendar.settings.addType", "Add a type\u2026"), 3410 value: draft.activityTypes, 3411 maxTags: MAX_ACTIVITY_TYPES, 3412 removeTagLabel, 3413 onChange: (activityTypes)=>setDraft((current)=>({ 3414 ...current, 3415 activityTypes 3416 })) 3417 }), 3418 toggleRows.map((row)=>/* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsxs"])(__TURBOPACK__imported__module__271645__8["Fragment"], { 3419 children: [
3420 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsxs"])("div", { 3421 className: "flex items-center gap-2", 3422 children: [ 3423 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsx"])(__TURBOPACK__imported__module__828010__["Switch"], { 3424 checked: draft[row.key], 3425 onCheckedChange: toggle(row.key), 3426 "aria-label": row.label 3427 }), 3428 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsx"])("span", { 3429 className: "text-sm leading-5 text-foreground", 3430 children: row.label 3431 }) 3432 ] 3433 }), 3434 row.key === "conflictWarnings" && draft.conflictWarnings ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsxs"])("div", { 3435 className: "flex flex-col gap-1.5 pl-11", 3436 children: [
3437 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsx"])("span", { 3438 className: "text-xs leading-4 text-muted-foreground", 3439 children: t("customers.calendar.settings.conflictScopeHint", "Choose whose overlaps the calendar flags as conflicts.") 3440 }), 3441 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsx"])(__TURBOPACK__imported__module__221709__["SegmentGroup"], { 3442 ariaLabel: t("customers.calendar.settings.conflictScope", "Conflict scope"), 3443 value: draft.conflictScope, 3444 onChange: (conflictScope)=>setDraft((current)=>({ 3445 ...current, 3446 conflictScope 3447 })), 3448 options: [ 3449 { 3450 value: "mine", 3451 label: t("customers.calendar.settings.conflictScopeMine", "My meetings") 3452 }, 3453 { 3454 value: "all", 3455 label: t("customers.calendar.settings.conflictScopeAll", "All meetings") 3456 } 3457 ] 3458 }) 3459 ] 3460 }) : null 3461 ] 3462 }, row.key)) 3463 ] 3464 }),
3465 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsxs"])("div", { 3466 className: "flex shrink-0 items-center gap-3 border-t border-border px-5 py-4", 3467 children: [ 3468 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsx"])(__TURBOPACK__imported__module__110035__10["Button"], { 3469 type: "button", 3470 variant: "outline", 3471 className: "flex-1", 3472 onClick: ()=>onOpenChange(false), 3473 children: t("customers.calendar.settings.cancel", "Cancel") 3474 }), 3475 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsx"])(__TURBOPACK__imported__module__110035__10["Button"], { 3476 type: "button", 3477 className: "flex-1", 3478 onClick: handleSave, 3479 children: t("customers.calendar.settings.save", "Save Changes") 3480 }) 3481 ] 3482 }) 3483 ] 3484 }) 3485 }); 3486} 3487function SettingsTagInput({ label, maxLabel, hint, placeholder, value, maxTags, removeTagLabel, onChange }) { 3488 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsxs"])("div", { 3489 className: "flex flex-col gap-1", 3490 children: [
3491 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsxs"])("div", { 3492 className: "flex items-center gap-1", 3493 children: [ 3494 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsx"])("span", { 3495 className: "text-sm font-medium leading-5 text-foreground", 3496 children: label 3497 }), 3498 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsx"])("span", { 3499 className: "text-sm leading-5 text-muted-foreground", 3500 children: maxLabel 3501 }), 3502 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsx"])(__TURBOPACK__imported__module__220339__1["SimpleTooltip"], { 3503 content: hint, 3504 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsx"])("span", { 3505 className: "inline-flex text-muted-foreground", 3506 tabIndex: 0, 3507 role: "img", 3508 "aria-label": hint, 3509 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsx"])(__TURBOPACK__imported__module__952571__["Info"], { 3510 "aria-hidden": true, 3511 className: "size-4" 3512 }) 3513 }) 3514 }) 3515 ] 3516 }),
3517 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__12["jsx"])(__TURBOPACK__imported__module__410777__["TagInput"], { 3518 value, 3519 onChange, 3520 placeholder, 3521 maxTags, 3522 "aria-label": label, 3523 removeTagLabel 3524 }) 3525 ] 3526 }); 3527} 3528; 3529// MERGED MODULE: [project]/node_modules/@open-mercato/core/dist/modules/customers/components/calendar/useCalendarPreferences.js [app-client] (ecmascript) 3530; 3531var __TURBOPACK__imported__module__271645__9 = __TURBOPACK__imported__module__271645__; 3532var __TURBOPACK__imported__module__503477__ = __turbopack_context__.i(503477); 3533"use client"; 3534; 3535; 3536; 3537function useCalendarPreferences() { 3538 const userId = (0, __TURBOPACK__imported__module__503477__["useCurrentUserId"])(); 3539 const scopeKey = userId || "anon"; 3540 const [preferences, setPreferencesState] = __TURBOPACK__imported__module__271645__9["useState"](DEFAULT_CALENDAR_PREFERENCES); 3541 const [hydrated, setHydrated] = __TURBOPACK__imported__module__271645__9["useState"](false); 3542 __TURBOPACK__imported__module__271645__9["useEffect"](()=>{ 3543 if ("TURBOPACK compile-time falsy", 0) //TURBOPACK unreachable 3544 ; 3545 let raw = null; 3546 try { 3547 raw = window.localStorage.getItem(calendarPreferencesStorageKey(scopeKey)); 3548 } catch { 3549 raw = null; 3550 } 3551 setPreferencesState(parseStoredCalendarPreferences(raw)); 3552 setHydrated(true); 3553 }, [ 3554 scopeKey 3555 ]); 3556 const setPreferences = __TURBOPACK__imported__module__271645__9["useCallback"]((next)=>{ 3557 setPreferencesState(next); 3558 if ("TURBOPACK compile-time falsy", 0) //TURBOPACK unreachable 3559 ; 3560 try { 3561 window.localStorage.setItem(calendarPreferencesStorageKey(scopeKey), JSON.stringify(next)); 3562 } catch {} 3563 }, [ 3564 scopeKey 3565 ]); 3566 return { 3567 preferences, 3568 setPreferences, 3569 hydrated, 3570 userId: userId || null 3571 }; 3572} 3573; 3574var __TURBOPACK__imported__module__451523__ = __turbopack_context__.i(451523); 3575; 3576"use client"; 3577; 3578; 3579; 3580; 3581; 3582; 3583; 3584; 3585; 3586; 3587; 3588; 3589; 3590; 3591; 3592; 3593; 3594; 3595; 3596; 3597; 3598; 3599; 3600; 3601; 3602; 3603; 3604; 3605const CalendarEventEditor = (0, __TURBOPACK__imported__module__770703__["default"])(()=>__turbopack_context__.A(787624).then((mod)=>mod.CalendarEventEditor), { 3606 loadableGenerated: { 3607 modules: [ 3608 25201 3609 ] 3610 }, 3611 ssr: false 3612}); 3613const SEARCH_DEBOUNCE_MS = 200; 3614const PHONE_BREAKPOINT_PX = 640; 3615const HIGHLIGHT_CLEAR_MS = 3e3; 3616const DEFAULT_AGENDA_HORIZON_DAYS = 7; 3617const UPCOMING_CARDS_COUNT = 4; 3618const EMPTY_FILTERS1 = { 3619 types: [], 3620 status: null, 3621 ownerUserId: null 3622}; 3623const MANAGE_FEATURE = "customers.interactions.manage"; 3624function useCanManageInteractions() { 3625 const [canManage, setCanManage] = __TURBOPACK__imported__module__271645__["useState"](false); 3626 __TURBOPACK__imported__module__271645__["useEffect"](()=>{ 3627 const controller = new AbortController(); 3628 let cancelled = false; 3629 (0, __TURBOPACK__imported__module__490746__["apiCall"])("/api/auth/feature-check", { 3630 method: "POST", 3631 headers: { 3632 "Content-Type": "application/json" 3633 }, 3634 signal: controller.signal, 3635 body: JSON.stringify({ 3636 features: [ 3637 MANAGE_FEATURE 3638 ] 3639 }) 3640 }).then((call)=>{ 3641 if (cancelled || !call.ok) return; 3642 const granted = Array.isArray(call.result?.granted) ? call.result.granted.map((feature)=>String(feature)) : []; 3643 setCanManage(granted.some((grantedFeature)=>(0, __TURBOPACK__imported__module__752019__["matchFeature"])(MANAGE_FEATURE, grantedFeature))); 3644 }).catch(()=>{ 3645 if (!cancelled && !controller.signal.aborted) setCanManage(false); 3646 }); 3647 return ()=>{ 3648 cancelled = true; 3649 controller.abort(); 3650 }; 3651 }, []); 3652 return canManage; 3653} 3654function buildTimezoneLabel() { 3655 const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone; 3656 const offsetMinutes = -/* @__PURE__ */ new Date().getTimezoneOffset(); 3657 const sign = offsetMinutes >= 0 ? "+" : "-"; 3658 const absolute = Math.abs(offsetMinutes); 3659 const hours = Math.floor(absolute / 60); 3660 const minutes = absolute % 60; 3661 const offset = minutes > 0 ? `${sign}${hours}:${String(minutes).padStart(2, "0")}` : `${sign}${hours}`; 3662 return `${timeZone} (GMT${offset})`; 3663} 3664function resolveJoinUrl(location) { 3665 const trimmed = location?.trim() ?? ""; 3666 if (!trimmed) return null; 3667 if (/^https?:\/\//i.test(trimmed)) return trimmed; 3668 if (/^www\./i.test(trimmed)) return `https://${trimmed}`; 3669 return null; 3670} 3671function asEditableItem(item) { 3672 return item.isRecurringOccurrence ? { 3673 ...item, 3674 id: item.raw.id 3675 } : item; 3676} 3677function CalendarScreen({ resourcesEnabled = false, staffEnabled = true } = {}) { 3678 const t = (0, __TURBOPACK__imported__module__928441__["useT"])();
3679 const [view, setView] = __TURBOPACK__imported__module__271645__["useState"]("week"); 3680 const [anchor, setAnchor] = __TURBOPACK__imported__module__271645__["useState"](()=>/* @__PURE__ */ new Date()); 3681 const [agendaHorizonDays, setAgendaHorizonDays] = __TURBOPACK__imported__module__271645__["useState"](DEFAULT_AGENDA_HORIZON_DAYS); 3682 const [preset, setPreset] = __TURBOPACK__imported__module__271645__["useState"]("thisWeek"); 3683 __TURBOPACK__imported__module__271645__["useEffect"](()=>{ 3684 if (window.innerWidth >= PHONE_BREAKPOINT_PX) return; 3685 setView("day"); 3686 setPreset(null); 3687 }, []); 3688 const [tab, setTab] = __TURBOPACK__imported__module__271645__["useState"]("all"); 3689 const [searchText, setSearchText] = __TURBOPACK__imported__module__271645__["useState"](""); 3690 const [debouncedSearch, setDebouncedSearch] = __TURBOPACK__imported__module__271645__["useState"](""); 3691 const [filters, setFilters] = __TURBOPACK__imported__module__271645__["useState"](EMPTY_FILTERS1); 3692 const [editor, setEditor] = __TURBOPACK__imported__module__271645__["useState"]({ 3693 open: false, 3694 mode: "create", 3695 item: null 3696 }); 3697 const [editorMounted, setEditorMounted] = __TURBOPACK__imported__module__271645__["useState"](false); 3698 const [createRange, setCreateRange] = __TURBOPACK__imported__module__271645__["useState"](null); 3699 const [shortcutsOpen, setShortcutsOpen] = __TURBOPACK__imported__module__271645__["useState"](false); 3700 const [settingsOpen, setSettingsOpen] = __TURBOPACK__imported__module__271645__["useState"](false); 3701 const [highlightItemId, setHighlightItemId] = __TURBOPACK__imported__module__271645__["useState"](null); 3702 const [hasLoadedOnce, setHasLoadedOnce] = __TURBOPACK__imported__module__271645__["useState"](false); 3703 const { preferences, setPreferences, hydrated: preferencesHydrated, userId: currentUserId } = useCalendarPreferences(); 3704 const range = __TURBOPACK__imported__module__271645__["useMemo"](()=>(0, __TURBOPACK__imported__module__467550__["getVisibleRange"])(view, anchor, agendaHorizonDays), [ 3705 view, 3706 anchor, 3707 agendaHorizonDays 3708 ]); 3709 const { items, isLoading, error, truncated, typeLabels, typeColors, typeIcons, refetch } = (0, __TURBOPACK__imported__module__451523__["useCalendarItems"])(range); 3710 __TURBOPACK__imported__module__271645__["useEffect"](()=>{ 3711 if (!isLoading) setHasLoadedOnce(true); 3712 }, [ 3713 isLoading 3714 ]); 3715 __TURBOPACK__imported__module__271645__["useEffect"](()=>{ 3716 const timer = window.setTimeout(()=>setDebouncedSearch(searchText), SEARCH_DEBOUNCE_MS); 3717 return ()=>window.clearTimeout(timer); 3718 }, [ 3719 searchText 3720 ]); 3721 __TURBOPACK__imported__module__271645__["useEffect"](()=>{ 3722 if (!highlightItemId) return; 3723 const timer = window.setTimeout(()=>setHighlightItemId(null), HIGHLIGHT_CLEAR_MS); 3724 return ()=>window.clearTimeout(timer); 3725 }, [ 3726 highlightItemId 3727 ]); 3728 const visibleItems = __TURBOPACK__imported__module__271645__["useMemo"](()=>items.filter((item)=>item.end > range.from && item.start < range.to), [ 3729 items, 3730 range 3731 ]); 3732 const searchedItems = __TURBOPACK__imported__module__271645__["useMemo"](()=>{ 3733 const query = debouncedSearch.trim().toLowerCase(); 3734 if (!query) return visibleItems; 3735 return visibleItems.filter((item)=>{ 3736 if (item.title.toLowerCase().includes(query)) return true; 3737 if (item.location && item.location.toLowerCase().includes(query)) return true; 3738 const rawBody = item.raw.body; 3739 if (typeof rawBody === "string" && rawBody.toLowerCase().includes(query)) return true; 3740 return item.participants.some((participant)=>(participant.name ?? "").toLowerCase().includes(query)); 3741 }); 3742 }, [ 3743 visibleItems, 3744 debouncedSearch 3745 ]); 3746 const baseItems = __TURBOPACK__imported__module__271645__["useMemo"](()=>searchedItems.filter((item)=>{ 3747 if (filters.types.length > 0 && !filters.types.includes(item.interactionType)) return false;
3748 if (filters.status && item.status !== filters.status) return false; 3749 if (filters.ownerUserId && item.ownerUserId !== filters.ownerUserId) return false; 3750 if (!preferences.showCrmActivities && item.category !== "meeting" && item.category !== "event") return false; 3751 return true; 3752 }), [ 3753 searchedItems, 3754 filters, 3755 preferences.showCrmActivities 3756 ]); 3757 const tabCounts = __TURBOPACK__imported__module__271645__["useMemo"](()=>(0, __TURBOPACK__imported__module__82922__["countByCategory"])(baseItems), [ 3758 baseItems 3759 ]); 3760 const viewItems = __TURBOPACK__imported__module__271645__["useMemo"](()=>{ 3761 if (tab === "meetings") return baseItems.filter((item)=>item.category === "meeting"); 3762 if (tab === "events") return baseItems.filter((item)=>item.category === "event"); 3763 return baseItems; 3764 }, [ 3765 baseItems, 3766 tab 3767 ]); 3768 const conflictMap = __TURBOPACK__imported__module__271645__["useMemo"](()=>(0, __TURBOPACK__imported__module__490186__["findConflicts"])(baseItems, { 3769 scope: preferences.conflictScope, 3770 currentUserId 3771 }), [ 3772 baseItems, 3773 preferences.conflictScope, 3774 currentUserId 3775 ]); 3776 const conflictIds = __TURBOPACK__imported__module__271645__["useMemo"](()=>new Set(conflictMap.keys()), [ 3777 conflictMap 3778 ]); 3779 const upcomingCards = __TURBOPACK__imported__module__271645__["useMemo"](()=>{ 3780 const now = /* @__PURE__ */ new Date(); 3781 const nowMs = now.getTime(); 3782 return baseItems.filter((item)=>item.start.getTime() >= nowMs).sort((first, second)=>first.start.getTime() - second.start.getTime()).slice(0, UPCOMING_CARDS_COUNT).map((item)=>{ 3783 const conflictCount = preferences.conflictWarnings ? conflictMap.get(item.id)?.length ?? 0 : 0; 3784 const kind = item.status === "canceled" ? "cancelled" : conflictCount > 0 ? "conflicted" : isSameDay(item.start, now) ? "today" : "future"; 3785 return { 3786 item, 3787 kind, 3788 conflictCount 3789 }; 3790 }); 3791 }, [ 3792 baseItems, 3793 conflictMap, 3794 preferences.conflictWarnings 3795 ]); 3796 const typeOptions = __TURBOPACK__imported__module__271645__["useMemo"](()=>{ 3797 const values = new Set(Object.keys(typeLabels)); 3798 for (const item of items)values.add(item.interactionType); 3799 return [ 3800 ...values 3801 ].sort((a, b)=>a.localeCompare(b)).map((value)=>({ 3802 value, 3803 label: typeLabels[value] ?? value 3804 })); 3805 }, [ 3806 items, 3807 typeLabels 3808 ]); 3809 const ownerOptions = __TURBOPACK__imported__module__271645__["useMemo"](()=>{ 3810 const participantNames = /* @__PURE__ */ new Map(); 3811 for (const item of items){ 3812 for (const participant of item.participants){ 3813 if (participant.name && !participantNames.has(participant.userId)) { 3814 participantNames.set(participant.userId, participant.name); 3815 } 3816 } 3817 } 3818 const owners = /* @__PURE__ */ new Map(); 3819 for (const item of items){ 3820 if (!item.ownerUserId || owners.has(item.ownerUserId)) continue; 3821 owners.set(item.ownerUserId, participantNames.get(item.ownerUserId) ?? item.ownerUserId); 3822 } 3823 return [ 3824 ...owners.entries() 3825 ].map(([value, label])=>({ 3826 value, 3827 label 3828 })).sort((first, second)=>first.label.localeCompare(second.label)); 3829 }, [ 3830 items 3831 ]); 3832 const timezoneLabel = __TURBOPACK__imported__module__271645__["useMemo"](()=>buildTimezoneLabel(), []); 3833 const canManage = useCanManageInteractions(); 3834 const openCreateEditor = __TURBOPACK__imported__module__271645__["useCallback"](()=>{ 3835 if (!canManage) return; 3836 setCreateRange(null); 3837 setEditorMounted(true); 3838 setEditor({ 3839 open: true, 3840 mode: "create", 3841 item: null 3842 }); 3843 }, [ 3844 canManage 3845 ]); 3846 const openEditEditor = __TURBOPACK__imported__module__271645__["useCallback"]((item)=>{ 3847 if (!canManage) return; 3848 setCreateRange(null); 3849 setEditorMounted(true); 3850 setEditor({ 3851 open: true, 3852 mode: "edit", 3853 item: asEditableItem(item) 3854 }); 3855 }, [ 3856 canManage 3857 ]); 3858 const handleCreateRange = __TURBOPACK__imported__module__271645__["useCallback"]((start, end)=>{ 3859 if (!canManage) return; 3860 setCreateRange({ 3861 start, 3862 end 3863 }); 3864 setEditorMounted(true); 3865 setEditor({ 3866 open: true, 3867 mode: "create", 3868 item: null 3869 }); 3870 }, [ 3871 canManage 3872 ]); 3873 const seedActivityTypes = __TURBOPACK__imported__module__271645__["useMemo"](()=>{ 3874 const seen = /* @__PURE__ */ new Set(); 3875 const labels = []; 3876 for (const value of Object.keys(typeLabels)){ 3877 const label = typeLabels[value] ?? value; 3878 if (seen.has(label)) continue; 3879 seen.add(label); 3880 labels.push(label); 3881 } 3882 return labels; 3883 }, [ 3884 typeLabels 3885 ]); 3886 const handleToday = __TURBOPACK__imported__module__271645__["useCallback"](()=>{ 3887 setAnchor(/* @__PURE__ */ new Date()); 3888 setPreset(null); 3889 }, []); 3890 const handlePresetChange = __TURBOPACK__imported__module__271645__["useCallback"]((next)=>{ 3891 setPreset(next); 3892 setAnchor(/* @__PURE__ */ new Date()); 3893 if (next === "thisWeek") {
3894 setView("week"); 3895 } else if (next === "thisMonth") { 3896 setView("month"); 3897 } else { 3898 setView("agenda"); 3899 setAgendaHorizonDays(next === "next30" ? 30 : DEFAULT_AGENDA_HORIZON_DAYS); 3900 } 3901 }, []); 3902 const handleAnchorChange = __TURBOPACK__imported__module__271645__["useCallback"]((date)=>{ 3903 setAnchor(date); 3904 setPreset(null); 3905 }, []); 3906 const handleViewChange = __TURBOPACK__imported__module__271645__["useCallback"]((next)=>{ 3907 setView(next); 3908 setPreset(null); 3909 }, []); 3910 const handleTimeGridNavigate = __TURBOPACK__imported__module__271645__["useCallback"]((deltaDays)=>{ 3911 setAnchor((current)=>(0, __TURBOPACK__imported__module__595727__["addDays"])(current, deltaDays)); 3912 setPreset(null); 3913 }, []); 3914 const handleDayOpen = __TURBOPACK__imported__module__271645__["useCallback"]((date)=>{ 3915 setView("day"); 3916 setAnchor(date); 3917 setPreset(null); 3918 }, []); 3919 const handleSeeConflict = __TURBOPACK__imported__module__271645__["useCallback"]((item)=>{ 3920 setView("week"); 3921 setAnchor(item.start); 3922 setPreset(null); 3923 setHighlightItemId(item.id); 3924 }, []); 3925 const handleJoin = __TURBOPACK__imported__module__271645__["useCallback"]((item)=>{ 3926 const url = resolveJoinUrl(item.location); 3927 if (url) window.open(url, "_blank", "noopener"); 3928 }, []); 3929 const { runMutation, retryLastMutation } = (0, __TURBOPACK__imported__module__714073__["useGuardedMutation"])({ 3930 contextId: "customers-calendar-cancel", 3931 blockedMessage: t("ui.forms.flash.saveBlocked", "Save blocked by validation") 3932 }); 3933 const handleCancelItem = __TURBOPACK__imported__module__271645__["useCallback"](async (item)=>{ 3934 const interactionId = item.raw.id; 3935 try { 3936 await runMutation({ 3937 operation: ()=>(0, __TURBOPACK__imported__module__490746__["withScopedApiRequestHeaders"])((0, __TURBOPACK__imported__module__977896__["buildOptimisticLockHeader"])(item.updatedAt), ()=>(0, __TURBOPACK__imported__module__490746__["apiCallOrThrow"])("/api/customers/interactions", { 3938 method: "PUT", 3939 headers: { 3940 "content-type": "application/json" 3941 }, 3942 body: JSON.stringify({ 3943 id: interactionId, 3944 status: "canceled" 3945 }) 3946 })), 3947 mutationPayload: { 3948 operation: "cancelCalendarEvent", 3949 interactionId, 3950 interactionType: item.interactionType 3951 }, 3952 context: { 3953 formId: "customers-calendar-cancel", 3954 resourceKind: "customers.interaction", 3955 resourceId: interactionId, 3956 retryLastMutation 3957 } 3958 }); 3959 (0, __TURBOPACK__imported__module__484973__["flash"])(t("customers.calendar.cards.cancelSuccess", "Event cancelled"), "success"); 3960 refetch(); 3961 } catch (err) { 3962 if ((0, __TURBOPACK__imported__module__977896__["extractOptimisticLockConflict"])(err)) return; 3963 (0, __TURBOPACK__imported__module__484973__["flash"])(t("customers.calendar.cards.cancelError", "Failed to cancel event"), "error"); 3964 } 3965 }, [ 3966 refetch, 3967 retryLastMutation, 3968 runMutation, 3969 t 3970 ]); 3971 const focusSearch = __TURBOPACK__imported__module__271645__["useCallback"](()=>{ 3972 const node = document.querySelector("[data-calendar-search]"); 3973 if (node instanceof HTMLInputElement) node.focus(); 3974 else if (node instanceof HTMLElement) node.querySelector("input")?.focus(); 3975 }, []); 3976 const editorOpen = editor.open; 3977 __TURBOPACK__imported__module__271645__["useEffect"](()=>{ 3978 const handleKeyDown = (event)=>{ 3979 if (event.defaultPrevented) return; 3980 if (event.metaKey || event.ctrlKey || event.altKey) return; 3981 const target = event.target; 3982 if (target instanceof HTMLElement) { 3983 const tag = target.tagName; 3984 if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT" || target.isContentEditable) return; 3985 } 3986 if (editorOpen) return; 3987 switch(event.key){ 3988 case "t": 3989 case "T": 3990 event.preventDefault(); 3991 setAnchor(/* @__PURE__ */ new Date()); 3992 setPreset(null); 3993 break; 3994 case "d": 3995 case "D": 3996 event.preventDefault();
3997 setView("day"); 3998 setPreset(null); 3999 break; 4000 case "w": 4001 case "W": 4002 event.preventDefault(); 4003 setView("week"); 4004 setPreset(null); 4005 break; 4006 case "m": 4007 case "M": 4008 event.preventDefault(); 4009 setView("month"); 4010 setPreset(null); 4011 break; 4012 case "a": 4013 case "A": 4014 event.preventDefault(); 4015 setView("agenda"); 4016 setPreset(null); 4017 break; 4018 case "n": 4019 case "N": 4020 event.preventDefault(); 4021 openCreateEditor(); 4022 break; 4023 case "/": 4024 event.preventDefault(); 4025 focusSearch(); 4026 break; 4027 case "?": 4028 event.preventDefault(); 4029 setShortcutsOpen((open)=>!open); 4030 break; 4031 case "Escape": 4032 setHighlightItemId(null); 4033 break; 4034 default: 4035 break; 4036 } 4037 }; 4038 window.addEventListener("keydown", handleKeyDown); 4039 return ()=>window.removeEventListener("keydown", handleKeyDown); 4040 }, [ 4041 editorOpen, 4042 focusSearch, 4043 openCreateEditor 4044 ]); 4045 const showInitialLoading = isLoading && !hasLoadedOnce || !preferencesHydrated; 4046 let viewArea; 4047 if (error) { 4048 viewArea = /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsx"])(__TURBOPACK__imported__module__445299__["ErrorMessage"], { 4049 label: t("customers.calendar.errors.loadFailed", "Failed to load calendar events."), 4050 action: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsx"])(__TURBOPACK__imported__module__110035__["Button"], { 4051 type: "button", 4052 variant: "outline", 4053 size: "sm", 4054 onClick: refetch, 4055 children: t("customers.calendar.errors.retry", "Retry") 4056 }) 4057 }); 4058 } else if (showInitialLoading) { 4059 viewArea = /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsx"])(__TURBOPACK__imported__module__360341__["LoadingMessage"], { 4060 label: t("customers.calendar.loading", "Loading calendar\u2026") 4061 }); 4062 } else if (view === "month") { 4063 viewArea = /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsx"])(MonthGrid, { 4064 anchor, 4065 items: viewItems, 4066 onItemClick: openEditEditor, 4067 onDayOpen: handleDayOpen 4068 }); 4069 } else if (view === "agenda") { 4070 viewArea = /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsx"])(AgendaList, { 4071 anchor, 4072 horizonDays: agendaHorizonDays, 4073 items: viewItems, 4074 typeLabels, 4075 onItemClick: openEditEditor 4076 }); 4077 } else { 4078 viewArea = /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsx"])(TimeGrid, { 4079 days: view === "day" ? 1 : 7, 4080 anchor, 4081 items: viewItems, 4082 conflictIds, 4083 showWeekends: preferences.showWeekends, 4084 showConflicts: preferences.conflictWarnings, 4085 aiSummaries: preferences.aiSummaries, 4086 canManage, 4087 highlightItemId, 4088 onItemClick: openEditEditor, 4089 onJoin: handleJoin, 4090 onNavigate: handleTimeGridNavigate, 4091 onCreate: canManage ? openCreateEditor : void 0, 4092 onCreateRange: canManage ? handleCreateRange : void 0 4093 }); 4094 } 4095 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsxs"])("div", { 4096 className: "flex min-h-0 flex-1 flex-col gap-4", 4097 children: [
4098 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsx"])(CalendarHeader, { 4099 view, 4100 anchor, 4101 onNewEvent: canManage ? openCreateEditor : void 0 4102 }), 4103 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsx"])(CalendarToolbar, { 4104 view, 4105 anchor, 4106 range, 4107 preset, 4108 search: searchText, 4109 filters, 4110 typeOptions, 4111 ownerOptions, 4112 onToday: handleToday, 4113 onPresetChange: handlePresetChange, 4114 onAnchorChange: handleAnchorChange, 4115 onSearchChange: setSearchText, 4116 onFiltersChange: setFilters, 4117 onOpenSettings: ()=>setSettingsOpen(true) 4118 }), 4119 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsx"])(UpcomingCards, { 4120 cards: upcomingCards, 4121 canManage, 4122 onJoin: handleJoin, 4123 onSeeConflict: handleSeeConflict, 4124 onOpen: openEditEditor, 4125 onEdit: openEditEditor, 4126 onCancel: handleCancelItem 4127 }),
4128 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsxs"])("div", { 4129 className: "flex min-h-0 flex-1 flex-col gap-3", 4130 children: [ 4131 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsx"])(CalendarTabs, { 4132 tab, 4133 counts: tabCounts, 4134 view, 4135 onTabChange: setTab, 4136 onViewChange: handleViewChange 4137 }), 4138 truncated ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsx"])("p", { 4139 className: "text-xs text-muted-foreground", 4140 role: "status", 4141 children: t("customers.calendar.notice.truncated", "Showing first {count} items for this range.", { 4142 count: __TURBOPACK__imported__module__451523__["MAX_WINDOW_ITEMS"] 4143 }) 4144 }) : null, 4145 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsx"])("div", { 4146 className: "flex min-h-[560px] flex-1 flex-col [&>*]:flex-1", 4147 children: viewArea 4148 }) 4149 ] 4150 }),
4151 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsx"])("div", { 4152 className: "hidden md:block", 4153 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsx"])(CalendarFooter, { 4154 timezoneLabel, 4155 onOpenShortcuts: ()=>setShortcutsOpen(true) 4156 }) 4157 }), 4158 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsx"])(ShortcutsDialog, { 4159 open: shortcutsOpen, 4160 onOpenChange: setShortcutsOpen 4161 }), 4162 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsx"])(CalendarSettingsModal, { 4163 open: settingsOpen, 4164 preferences, 4165 seedActivityTypes, 4166 onOpenChange: setSettingsOpen, 4167 onSave: (next)=>{ 4168 setPreferences(next); 4169 (0, __TURBOPACK__imported__module__484973__["flash"])(t("customers.calendar.settings.saved", "Calendar settings saved"), "success"); 4170 } 4171 }), 4172 editorMounted ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsx"])(CalendarEventEditor, { 4173 open: editor.open, 4174 mode: editor.mode, 4175 item: editor.item, 4176 defaultDate: anchor, 4177 defaultRange: createRange, 4178 typeLabels, 4179 typeIcons, 4180 conflictScope: preferences.conflictScope, 4181 currentUserId, 4182 resourcesEnabled, 4183 staffEnabled, 4184 onOpenChange: (open)=>setEditor((current)=>({ 4185 ...current, 4186 open 4187 })), 4188 onSaved: refetch 4189 }) : null 4190 ] 4191 }); 4192} 4193; 4194__turbopack_context__.s([ 4195 "CalendarScreen", 4196 0, 4197 CalendarScreen 4198], 123197); 4199}), 4200]);
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.