@timardex/cluemart-shared 2.2.41 → 2.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-VHNCSCQU.mjs → chunk-DV3K3JDE.mjs} +2 -2
- package/dist/{chunk-PJY7OAQ2.mjs → chunk-HKTBJOB7.mjs} +27 -11
- package/dist/chunk-HKTBJOB7.mjs.map +1 -0
- package/dist/{chunk-QIF4ZGMY.mjs → chunk-KMS64DE2.mjs} +2 -2
- package/dist/{chunk-2GUAD63W.mjs → chunk-PBW5K54C.mjs} +2 -2
- package/dist/{chunk-MKHXXZWF.mjs → chunk-UWMZ6VLV.mjs} +45 -2
- package/dist/chunk-UWMZ6VLV.mjs.map +1 -0
- package/dist/formFields/index.cjs +10 -0
- package/dist/formFields/index.cjs.map +1 -1
- package/dist/formFields/index.mjs +3 -3
- package/dist/graphql/index.cjs +46 -1
- package/dist/graphql/index.cjs.map +1 -1
- package/dist/graphql/index.d.mts +25 -1
- package/dist/graphql/index.d.ts +25 -1
- package/dist/graphql/index.mjs +5 -1
- package/dist/hooks/index.cjs +25 -0
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.mjs +5 -5
- package/dist/index.cjs +73 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +33 -1
- package/dist/index.d.ts +33 -1
- package/dist/index.mjs +70 -11
- package/dist/index.mjs.map +1 -1
- package/dist/sharing/index.cjs +6 -0
- package/dist/sharing/index.cjs.map +1 -1
- package/dist/sharing/index.mjs +2 -2
- package/dist/utils/index.cjs +27 -10
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.mts +9 -1
- package/dist/utils/index.d.ts +9 -1
- package/dist/utils/index.mjs +4 -2
- package/package.json +1 -1
- package/dist/chunk-MKHXXZWF.mjs.map +0 -1
- package/dist/chunk-PJY7OAQ2.mjs.map +0 -1
- /package/dist/{chunk-VHNCSCQU.mjs.map → chunk-DV3K3JDE.mjs.map} +0 -0
- /package/dist/{chunk-QIF4ZGMY.mjs.map → chunk-KMS64DE2.mjs.map} +0 -0
- /package/dist/{chunk-2GUAD63W.mjs.map → chunk-PBW5K54C.mjs.map} +0 -0
package/dist/sharing/index.cjs
CHANGED
|
@@ -178,6 +178,12 @@ var formatDate = (dateStr, display = "datetime", timeStr) => {
|
|
|
178
178
|
return formattedDate;
|
|
179
179
|
}
|
|
180
180
|
};
|
|
181
|
+
var SLOT_FORMATS = [
|
|
182
|
+
`${dateFormat} ${timeFormat}`,
|
|
183
|
+
`${dateFormat} H:mm`,
|
|
184
|
+
`${dateFormat} ${timeFormat}:ss`,
|
|
185
|
+
`${dateFormat} H:mm:ss`
|
|
186
|
+
];
|
|
181
187
|
var futureTimePeriods = FUTURE_EVENT_DATE_STATUSES.filter(
|
|
182
188
|
(status) => status !== "Starting_Soon" /* STARTING_SOON */
|
|
183
189
|
).map((status) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/sharing/index.ts","../../src/utils/date.ts","../../src/utils/dateFormats.ts","../../src/utils/eventDateStatus.ts","../../src/sharing/relationShareTypes.ts","../../src/sharing/constants.ts","../../src/sharing/formatCategoryLabel.ts","../../src/sharing/joinShareDescriptionSections.ts","../../src/sharing/buildRelationShareDescription.ts","../../src/sharing/buildPublicShareDescription.ts","../../src/sharing/buildShareUrl.ts","../../src/sharing/normalizeShareDescription.ts","../../src/sharing/normalizeShareRouteId.ts","../../src/sharing/shareSlugResource.ts","../../src/sharing/toShareSocialImageCacheVersion.ts"],"sourcesContent":["export * from \"./buildPublicShareDescription\";\nexport * from \"./buildRelationShareDescription\";\nexport * from \"./shareRelationTypes\";\nexport * from \"./buildShareUrl\";\nexport * from \"./constants\";\nexport * from \"./formatCategoryLabel\";\nexport * from \"./joinShareDescriptionSections\";\nexport * from \"./normalizeShareDescription\";\nexport * from \"./normalizeShareRouteId\";\nexport * from \"./relationShareTypes\";\nexport * from \"./shareSlugResource\";\nexport * from \"./toShareSocialImageCacheVersion\";\n","import dayjs from \"dayjs\";\nimport customParseFormat from \"dayjs/plugin/customParseFormat.js\";\nimport isSameOrAfter from \"dayjs/plugin/isSameOrAfter.js\";\nimport timezone from \"dayjs/plugin/timezone.js\";\nimport utc from \"dayjs/plugin/utc.js\";\n\nimport { EnumEventDateStatus } from \"src/enums\";\n\nimport { dateFormat, timeFormat } from \"./dateFormats\";\nimport {\n FUTURE_EVENT_DATE_STATUSES,\n EVENT_DATE_STATUS_LABELS,\n} from \"./eventDateStatus\";\n\nexport { dateFormat, timeFormat };\n\n// Enable custom format parsing\ndayjs.extend(customParseFormat);\ndayjs.extend(utc);\ndayjs.extend(timezone);\ndayjs.extend(isSameOrAfter);\n\nconst NZ_TZ = \"Pacific/Auckland\";\n\nexport function toNZTime(date?: Date | string) {\n return date ? dayjs(date).tz(NZ_TZ) : dayjs().tz(NZ_TZ);\n}\n\n/** Start of the calendar day in Pacific/Auckland (daily games, streaks, etc.). */\nexport function nzStartOfDay(\n input?: Date | string | number | null,\n): dayjs.Dayjs {\n if (input == null) {\n return dayjs().tz(NZ_TZ).startOf(\"day\");\n }\n return dayjs.tz(input, NZ_TZ).startOf(\"day\");\n}\n\ntype DateFormat = \"date\" | \"time\" | \"datetime\";\n\n/**\n * Format a date string to a more readable format.\n * @param dateStr - the date string\n * @param timeStr - optional time string\n * @param display - 'date' | 'time' | 'datetime'\n * @returns formatted string based on display option\n */\nexport const formatDate = (\n dateStr: string,\n display: DateFormat = \"datetime\",\n timeStr?: string,\n) => {\n // Combine date and time into a single string if time is provided\n const dateTimeStr = timeStr ? `${dateStr} ${timeStr}` : dateStr;\n\n // Parse with formats\n const dateTime = timeStr\n ? dayjs(dateTimeStr, `${dateFormat} ${timeFormat}`)\n : dayjs(dateStr, dateFormat);\n\n // Format parts\n const formattedDate = dateTime.format(\"dddd, D MMMM, YYYY\");\n const formattedTime = dateTime.format(\"h:mm a\");\n\n // Return based on display option\n switch (display) {\n case \"date\":\n return formattedDate;\n case \"time\":\n return formattedTime;\n case \"datetime\":\n return `${formattedDate} at ${formattedTime}`;\n default:\n return formattedDate;\n }\n};\n\nexport const getCurrentAndFutureDates = <\n T extends { startDate?: string; startTime?: string },\n>(\n dates: T[],\n): T[] => {\n const now = dayjs(); // current date and time\n\n return dates.filter((dateObj) => {\n if (!dateObj.startDate || !dateObj.startTime) {\n return false;\n }\n\n const dateTime = dayjs(\n `${dateObj.startDate} ${dateObj.startTime}`,\n `${dateFormat} ${timeFormat}`,\n );\n return dateTime.isSameOrAfter(now);\n });\n};\n\nexport const isFutureDatesBeforeThreshold = (\n date: {\n startDate?: string;\n startTime?: string;\n },\n minHoursFromNow: number,\n): boolean => {\n if (!date.startDate || !date.startTime) {\n return false;\n }\n\n const threshold = minHoursFromNow\n ? dayjs().add(minHoursFromNow, \"hour\")\n : dayjs().startOf(\"day\");\n\n const dateTime = dayjs(\n `${date.startDate} ${date.startTime}`,\n `${dateFormat} ${timeFormat}`,\n );\n\n return dateTime.isSameOrAfter(threshold);\n};\n\nexport const formatTimestamp = (timestamp: string) => {\n const formattedDate = toNZTime(timestamp).format(dateFormat);\n\n return formatDate(formattedDate, \"date\");\n};\n\nexport const isIsoDateString = (value: unknown): value is string => {\n return typeof value === \"string\" && !Number.isNaN(Date.parse(value));\n};\n\n/**\n * Sort an array of date strings by their proximity to the current date.\n * @param dates - The array of date strings to sort.\n * @returns - The sorted array of date strings.\n */\nexport function sortDatesChronologically<\n T extends { startDate?: string; startTime?: string },\n>(dates: T[]): T[] {\n if (!dates?.length) {\n return [];\n }\n\n return [...dates].sort((a, b) => {\n const dateTimeFormat = `${dateFormat} ${timeFormat}`;\n const dateA =\n a.startDate && a.startTime\n ? dayjs(`${a.startDate} ${a.startTime}`, dateTimeFormat)\n : null;\n const dateB =\n b.startDate && b.startTime\n ? dayjs(`${b.startDate} ${b.startTime}`, dateTimeFormat)\n : null;\n\n if (dateA && dateB) {\n return dateA.valueOf() - dateB.valueOf();\n }\n\n if (dateA) {\n return -1;\n }\n\n if (dateB) {\n return 1;\n }\n\n return 0;\n });\n}\n\n/**\n * Start dates of the given date/time slots, chronological and de-duplicated.\n * Slots that share a `startDate` (e.g. two stall slots on the same day) collapse\n * into a single entry.\n */\nexport function getUniqueStartDates(\n dates: Array<{ startDate?: string; startTime?: string }> | null | undefined,\n): string[] {\n const seenStartDates = new Set<string>();\n const uniqueStartDates: string[] = [];\n\n for (const { startDate } of sortDatesChronologically(dates ?? [])) {\n if (!startDate || seenStartDates.has(startDate)) {\n continue;\n }\n\n seenStartDates.add(startDate);\n uniqueStartDates.push(startDate);\n }\n\n return uniqueStartDates;\n}\n\n/**\n * UI filter options for user-activity event periods. Derived from the canonical\n * {@link FUTURE_EVENT_DATE_STATUSES} list, minus `STARTING_SOON` (a presentational\n * choice: \"starting soon\" is surfaced separately rather than as a filter).\n */\nexport const futureTimePeriods = FUTURE_EVENT_DATE_STATUSES.filter(\n (status) => status !== EnumEventDateStatus.STARTING_SOON,\n).map((status) => ({\n label: EVENT_DATE_STATUS_LABELS[status],\n value: status,\n}));\n","export const dateFormat = \"DD-MM-YYYY\";\nexport const timeFormat = \"HH:mm\";\n","import dayjs from \"dayjs\";\nimport customParseFormat from \"dayjs/plugin/customParseFormat.js\";\nimport isoWeek from \"dayjs/plugin/isoWeek.js\";\n\nimport { EnumEventDateStatus } from \"../enums\";\nimport type { DateTimeType } from \"../types/global\";\n\nimport { dateFormat, timeFormat } from \"./dateFormats\";\n\n// Enable dayjs plugins used by event date parsing/status logic\ndayjs.extend(customParseFormat);\ndayjs.extend(isoWeek);\n\n/**\n * Display label per date status. Single source of truth instead of deriving\n * the label with `replaceAll(\"_\", \" \")` / text-transform tricks, so each\n * status maps to an explicit, correctly-cased string (e.g. \"This Week\",\n * \"Starting Soon\", \"Rescheduled\"). Lives here (not in `calendar`) so both\n * `calendar/eventCalendar` and `utils/date` can consume it without a circular\n * import.\n */\nexport const EVENT_DATE_STATUS_LABELS: Record<EnumEventDateStatus, string> = {\n [EnumEventDateStatus.STARTING_SOON]: \"Starting Soon\",\n [EnumEventDateStatus.STARTED]: \"Started\",\n [EnumEventDateStatus.TODAY]: \"Today\",\n [EnumEventDateStatus.TOMORROW]: \"Tomorrow\",\n [EnumEventDateStatus.THIS_WEEK]: \"This Week\",\n [EnumEventDateStatus.NEXT_WEEK]: \"Next Week\",\n [EnumEventDateStatus.UPCOMING]: \"Upcoming\",\n [EnumEventDateStatus.ENDED]: \"Ended\",\n [EnumEventDateStatus.RE_SCHEDULED]: \"Rescheduled\",\n [EnumEventDateStatus.CANCELED]: \"Canceled\",\n [EnumEventDateStatus.INVALID]: \"Invalid\",\n};\n\nexport const EVENT_DATE_STATUS_PERIOD_MAP: Partial<\n Record<EnumEventDateStatus, EnumEventDateStatus[]>\n> = {\n [EnumEventDateStatus.TODAY]: [\n EnumEventDateStatus.STARTED,\n EnumEventDateStatus.STARTING_SOON,\n EnumEventDateStatus.TODAY,\n ],\n [EnumEventDateStatus.THIS_WEEK]: [\n EnumEventDateStatus.STARTED,\n EnumEventDateStatus.STARTING_SOON,\n EnumEventDateStatus.THIS_WEEK,\n EnumEventDateStatus.TODAY,\n EnumEventDateStatus.TOMORROW,\n ],\n};\n\nexport function getAllowedEventDateStatuses(\n period: EnumEventDateStatus,\n): EnumEventDateStatus[] {\n return EVENT_DATE_STATUS_PERIOD_MAP[period] ?? [period];\n}\n\nexport function eventMatchesDateStatusPeriod(\n dateTime: Pick<DateTimeType, \"dateStatus\">[] | null | undefined,\n period: EnumEventDateStatus,\n): boolean {\n const allowedStatuses = getAllowedEventDateStatuses(period);\n\n return (\n dateTime?.some((dt) => allowedStatuses.includes(dt.dateStatus)) ?? false\n );\n}\n\nexport function filterEventsByDateStatusPeriod<\n T extends { dateTime?: Pick<DateTimeType, \"dateStatus\">[] | null },\n>(events: T[], period: EnumEventDateStatus): T[] {\n return events.filter((event) =>\n eventMatchesDateStatusPeriod(event.dateTime, period),\n );\n}\n\n/**\n * Canonical list of date statuses whose start date/time is still in the future\n * (i.e. the slot has not started yet). `STARTED`, `ENDED`, `INVALID`,\n * `CANCELED` and `RE_SCHEDULED` are intentionally excluded.\n *\n * This is the single source of truth for \"is this slot still in the future\".\n * `futureTimePeriods` (in `utils/date.ts`) derives from this list for UI\n * filters, additionally excluding `STARTING_SOON`.\n */\nexport const FUTURE_EVENT_DATE_STATUSES: readonly EnumEventDateStatus[] = [\n EnumEventDateStatus.STARTING_SOON,\n EnumEventDateStatus.TODAY,\n EnumEventDateStatus.TOMORROW,\n EnumEventDateStatus.THIS_WEEK,\n EnumEventDateStatus.NEXT_WEEK,\n EnumEventDateStatus.UPCOMING,\n];\n\nexport function isFutureEventDateStatus(\n dateStatus: EnumEventDateStatus | null | undefined,\n): boolean {\n return Boolean(dateStatus && FUTURE_EVENT_DATE_STATUSES.includes(dateStatus));\n}\n\nexport function filterDatesByFutureStatus<\n T extends { dateStatus?: EnumEventDateStatus | null },\n>(dates: T[]): T[] {\n return dates.filter((date) => isFutureEventDateStatus(date.dateStatus));\n}\n\n/**\n * Statuses set by an explicit user action rather than derived from the\n * schedule clock. The status recomputation below must leave them untouched,\n * otherwise a canceled/rescheduled date would silently flip back to a\n * time-derived status on the next run.\n */\nexport const MANUAL_DATE_STATUSES: ReadonlySet<EnumEventDateStatus> = new Set([\n EnumEventDateStatus.CANCELED,\n EnumEventDateStatus.RE_SCHEDULED,\n]);\n\n/**\n * Builds the event schedule that relation dates should be matched against.\n *\n * Manual statuses (`MANUAL_DATE_STATUSES`: CANCELED and RE_SCHEDULED) stay on\n * the live `Event.dateTime` for visibility, but a relation date pointing at\n * them is treated as removed. Archived (ended) slots are appended separately\n * so relation dates for archived history still match instead of being wrongly\n * marked unavailable.\n *\n * Shared by the server's `processUnavailableRelations` sync and the cron\n * orphan-date cleanup so both use the same archive-aware schedule.\n */\nexport function buildRelationEligibleEventSchedule<\n T extends { dateStatus?: EnumEventDateStatus | null },\n>(liveDateTime: T[], archivedDateTime: T[] = []): T[] {\n const eligible = liveDateTime.filter(\n (slot) => !slot.dateStatus || !MANUAL_DATE_STATUSES.has(slot.dateStatus),\n );\n return [...eligible, ...archivedDateTime];\n}\n\n/**\n * Determines the dateStatus for a future event date\n * @param startDateTime The start date-time of the event\n * @param now The current date-time\n * @returns The appropriate EnumEventDateStatus\n */\nexport function getFutureEventStatus(\n startDateTime: dayjs.Dayjs,\n now: dayjs.Dayjs,\n): EnumEventDateStatus {\n const hoursUntilStart = startDateTime.diff(now, \"hour\", true);\n if (hoursUntilStart > 0 && hoursUntilStart <= 4) {\n return EnumEventDateStatus.STARTING_SOON;\n }\n\n if (startDateTime.isSame(now, \"day\")) {\n return EnumEventDateStatus.TODAY;\n }\n\n if (startDateTime.isSame(now.add(1, \"day\"), \"day\")) {\n return EnumEventDateStatus.TOMORROW;\n }\n\n if (startDateTime.isSame(now, \"isoWeek\")) {\n return EnumEventDateStatus.THIS_WEEK;\n }\n\n if (startDateTime.isSame(now.add(1, \"week\"), \"isoWeek\")) {\n return EnumEventDateStatus.NEXT_WEEK;\n }\n\n return EnumEventDateStatus.UPCOMING;\n}\n\n/**\n * Updates the dateStatus field for a single DateTimeType object based on the current date/time.\n * Manual statuses (CANCELED, RE_SCHEDULED) are preserved and returned as-is.\n * @param dateTime The date-time object to update\n * @returns A new object with an updated dateStatus value, or the original\n * object when the stored status is a manual override\n */\nexport function updateSingleDateTimeStatus<T extends DateTimeType>(\n dateTime: T,\n now: dayjs.Dayjs = dayjs(),\n): T {\n if (MANUAL_DATE_STATUSES.has(dateTime.dateStatus)) {\n return dateTime;\n }\n\n // Parse start and end date-time\n const dateTimeFormat = `${dateFormat} ${timeFormat}`;\n const startDateTime = dayjs(\n `${dateTime.startDate} ${dateTime.startTime}`,\n dateTimeFormat,\n true,\n );\n const endDateTime = dayjs(\n `${dateTime.endDate} ${dateTime.endTime}`,\n dateTimeFormat,\n true,\n );\n\n // Skip if dates are invalid\n if (!startDateTime.isValid() || !endDateTime.isValid()) {\n return {\n ...dateTime,\n dateStatus: EnumEventDateStatus.INVALID,\n };\n }\n\n if (endDateTime.isBefore(startDateTime)) {\n return {\n ...dateTime,\n dateStatus: EnumEventDateStatus.INVALID,\n };\n }\n\n let dateStatus: EnumEventDateStatus;\n\n if (endDateTime.isAfter(now)) {\n if (startDateTime.isAfter(now)) {\n // Event has not started yet\n dateStatus = getFutureEventStatus(startDateTime, now);\n } else {\n // Event is in progress\n dateStatus = EnumEventDateStatus.STARTED;\n }\n } else {\n // Event has ended\n dateStatus = EnumEventDateStatus.ENDED;\n }\n\n return {\n ...dateTime,\n dateStatus,\n };\n}\n","/** Path segments for relation share URLs — must match mobile `RelationTitle` values. */\nexport const RELATION_SHARE_INVITATION = \"invitation\" as const;\nexport const RELATION_SHARE_APPLICATION = \"application\" as const;\n\n/**\n * Bump when relation overlay SVG/layout changes so og:image URLs and API ETags\n * invalidate after deploy. Facebook caches preview JPEGs by exact URL — changing\n * this value forces crawlers to fetch a fresh image after server deploy.\n */\nexport const RELATION_OVERLAY_LAYOUT_VERSION = 43;\n\nexport const RELATION_SHARE_RESOURCE_TYPES = [\n RELATION_SHARE_INVITATION,\n RELATION_SHARE_APPLICATION,\n] as const;\n\nexport type RelationShareResourceType =\n (typeof RELATION_SHARE_RESOURCE_TYPES)[number];\n\nexport function isRelationShareResourceType(\n resourceType: string,\n): resourceType is RelationShareResourceType {\n return (RELATION_SHARE_RESOURCE_TYPES as readonly string[]).includes(\n resourceType,\n );\n}\n","import {\n RELATION_SHARE_APPLICATION,\n RELATION_SHARE_INVITATION,\n type RelationShareResourceType,\n} from \"./relationShareTypes\";\n\nexport {\n RELATION_SHARE_APPLICATION,\n RELATION_SHARE_INVITATION,\n RELATION_OVERLAY_LAYOUT_VERSION,\n RELATION_SHARE_RESOURCE_TYPES,\n isRelationShareResourceType,\n type RelationShareResourceType,\n} from \"./relationShareTypes\";\n\n/** Open Graph recommended preview size (must match admin `SHARE_OG_IMAGE_*`). */\nexport const SOCIAL_IMAGE_WIDTH = 1200;\n\n/** Open Graph recommended preview size (must match admin `SHARE_OG_IMAGE_*`). */\nexport const SOCIAL_IMAGE_HEIGHT = 630;\n\n/** Keep in sync with `CLUEMART_MAIN_DOMAIN_URL` in utils (avoid utils↔sharing import cycle). */\nexport const SHARE_SITE_URL = \"https://cluemart.co.nz\";\n\n/** Calendar marker for invitation market-dates share copy (U+1F4C5 📅). */\nexport const SHARE_CALENDAR_ICON = \"\\u{1F4C5}\";\n\nexport const SHARE_MARKET_DATES_SECTION_HEADING = `${SHARE_CALENDAR_ICON} Market dates:`;\n\n/** Check mark for invitation requirements share copy (U+2705 ✅). */\nexport const SHARE_CHECKMARK_ICON = \"\\u{2705}\";\n\nexport const SHARE_REQUIREMENTS_SECTION_HEADING = `${SHARE_CHECKMARK_ICON} Requirements:`;\n\n/** Information marker for tags share copy (U+2139 ℹ️). */\nexport const SHARE_INFO_ICON = \"\\u{2139}\\u{FE0F}\";\n\nexport const SHARE_TAGS_SECTION_HEADING = `${SHARE_INFO_ICON} Tags:`;\n\n/** Standalone line when `rainOrShine` is true (invitation share + OG section parsing). */\nexport const SHARE_RAIN_OR_SHINE_LINE = \"Rain or Shine\";\n\n/** Standalone line when `foodTruck` is true (application share + OG section parsing). */\nexport const SHARE_FOOD_TRUCK_LINE = \"Food Truck\";\n\n/** Prefix for application compliance line (share text + OG section parsing). */\nexport const SHARE_COMPLIANCE_PREFIX = `${SHARE_CHECKMARK_ICON} Compliance:`;\n\n/** Label tag for application categories share copy (U+1F3F7 🏷️). */\nexport const SHARE_CATEGORY_ICON = \"\\u{1F3F7}\\u{FE0F}\";\n\nexport const SHARE_CATEGORIES_SECTION_HEADING = `${SHARE_CATEGORY_ICON} Categories:`;\n\n/** Straight ruler for application stall-size share copy (U+1F4CF 📏). */\nexport const SHARE_RULER_ICON = \"\\u{1F4CF}\";\n\n/** Prefix for application stall-size line (share text + OG section parsing). */\nexport const SHARE_STALL_SIZE_PREFIX = `${SHARE_RULER_ICON} Stall size:`;\n\n/** Dollar marker for price-range share copy (U+0024 $ — text, not emoji, so it stays black). */\nexport const SHARE_DOLLAR_ICON = \"$\";\n\n/** Prefix for application price-range line (share text + OG section parsing). */\nexport const SHARE_PRICE_RANGE_PREFIX = `${SHARE_DOLLAR_ICON} Price range:`;\n\n/** Alarm clock for invitation application-deadline share copy (U+23F0 ⏰). */\nexport const SHARE_CLOCK_ICON = \"\\u{23F0}\";\n\n/** Prefix for the invitation application-deadline sentence (share text + OG section parsing). */\nexport const SHARE_APPLICATION_DEADLINE_PREFIX = `${SHARE_CLOCK_ICON} Application deadline:`;\n\n/** First line of `og:description` (and legacy share-message text). */\nexport const SHARE_MORE_INFO_LINE = \"Shared from ClueMart\";\n\nexport const DEFAULT_SHARE_OG_IMAGE = `${SHARE_SITE_URL}/assets/logo.webp`;\n\nexport const RESOURCE_SHARE_TYPES = [\n \"market\",\n \"stallholder\",\n \"partner\",\n \"affiliate\",\n \"school\",\n] as const;\n\nexport type ResourceShareType = (typeof RESOURCE_SHARE_TYPES)[number];\n\nexport const POST_SHARE_RESOURCE_TYPES = [\n \"market_faces\",\n \"clue_bites\",\n \"play_and_win\",\n] as const;\n\nexport type PostShareResourceType = (typeof POST_SHARE_RESOURCE_TYPES)[number];\n\nexport type ShareResourceType =\n ResourceShareType | PostShareResourceType | RelationShareResourceType;\n\nexport const SHARE_RESOURCE_LABEL: Record<ShareResourceType, string> = {\n [RELATION_SHARE_APPLICATION]: \"Application\",\n [RELATION_SHARE_INVITATION]: \"Invitation\",\n affiliate: \"Affiliate\",\n clue_bites: \"Clue Bites\",\n market_faces: \"Market Faces\",\n market: \"Market\",\n partner: \"Partner\",\n play_and_win: \"Play & Win\",\n school: \"School\",\n stallholder: \"Stallholder\",\n};\n\nexport function isPostShareResourceType(\n resourceType: ShareResourceType,\n): resourceType is PostShareResourceType {\n return (POST_SHARE_RESOURCE_TYPES as readonly string[]).includes(\n resourceType,\n );\n}\n","import type { Category } from \"../types/global\";\n\nexport function formatCategoryLabel(category: Category): string {\n const subcategoryNames = category.subcategories\n .map((subcategory) => subcategory.name)\n .filter(Boolean);\n\n if (subcategoryNames.length === 0) {\n return category.name;\n }\n\n return `${category.name} (${subcategoryNames.join(\", \")})`;\n}\n","import { SHARE_MORE_INFO_LINE } from \"./constants\";\n\n/** Blank line between share sections — title, address, dates, URL, etc. */\nexport const SHARE_DESCRIPTION_SECTION_BREAK = \"\\n\\n\";\n\n/**\n * Line break for `og:description` meta content. Use instead of `\\n` — Next.js\n * HTML serialisation collapses literal newlines to spaces; Facebook reads ` `.\n */\nexport const OG_DESCRIPTION_LINE_BREAK = \" \";\n\n/** Joins OG description sections for Facebook link cards (and Twitter). */\nexport function joinShareOgDescriptionSections(\n sections: ReadonlyArray<string | false | null | undefined>,\n): string {\n return sections\n .map((section) => (typeof section === \"string\" ? section.trim() : \"\"))\n .filter((section): section is string => section.length > 0)\n .map((section) => section.replace(/\\n/g, OG_DESCRIPTION_LINE_BREAK))\n .join(OG_DESCRIPTION_LINE_BREAK);\n}\n\nexport function joinShareDescriptionSections(\n sections: ReadonlyArray<string | false | null | undefined>,\n): string {\n return sections\n .filter((section): section is string => Boolean(section))\n .join(SHARE_DESCRIPTION_SECTION_BREAK);\n}\n\n/** Prepends the standard share branding line when assembling display text. */\nexport function appendShareMoreInfoLine(description: string): string {\n const trimmed = description.trim();\n if (trimmed.startsWith(SHARE_MORE_INFO_LINE)) {\n return trimmed;\n }\n if (trimmed.length === 0) {\n return SHARE_MORE_INFO_LINE;\n }\n return joinShareDescriptionSections([SHARE_MORE_INFO_LINE, trimmed]);\n}\n","import type { StallType } from \"../types/event\";\nimport { formatDate } from \"../utils/date\";\n\nimport {\n SHARE_APPLICATION_DEADLINE_PREFIX,\n SHARE_CATEGORIES_SECTION_HEADING,\n SHARE_FOOD_TRUCK_LINE,\n SHARE_MARKET_DATES_SECTION_HEADING,\n SHARE_RAIN_OR_SHINE_LINE,\n SHARE_REQUIREMENTS_SECTION_HEADING,\n SHARE_COMPLIANCE_PREFIX,\n SHARE_PRICE_RANGE_PREFIX,\n SHARE_STALL_SIZE_PREFIX,\n SHARE_TAGS_SECTION_HEADING,\n} from \"./constants\";\nimport { formatCategoryLabel } from \"./formatCategoryLabel\";\nimport { joinShareDescriptionSections } from \"./joinShareDescriptionSections\";\nimport type {\n ShareEventForInvitation,\n ShareEventInfoForInvitation,\n ShareVendorForApplication,\n ShareVendorInfoForApplication,\n} from \"./shareRelationTypes\";\n\nexport type {\n ShareEventForInvitation,\n ShareEventInfoForInvitation,\n ShareVendorForApplication,\n ShareVendorInfoForApplication,\n} from \"./shareRelationTypes\";\n\n/** Formats event `startDate` (`DD-MM-YYYY`) for share copy — same as share preview UI. */\nexport function formatShareMarketDate(dateStr: string): string {\n return formatDate(dateStr, \"date\");\n}\n\nexport function formatStallCapacityLabel(stallCapacity: number): string {\n return stallCapacity > 0 ? ` (${stallCapacity} spaces available)` : \" - Full\";\n}\n\nexport function formatShareStallLine(stall: StallType): string {\n return ` - ${stall.label} — $${stall.price}${formatStallCapacityLabel(stall.stallCapacity)}`;\n}\n\n/** Nested market dates + per-date stall lines for invitation share copy. */\nexport function formatShareInvitationMarketDatesSection(\n dateTime: ShareEventInfoForInvitation[\"dateTime\"],\n): string {\n const dateBlocks = dateTime.map((date) => {\n const formattedDate = date.startDate\n ? formatShareMarketDate(date.startDate)\n : \"Unknown date\";\n const stallLines = date.stallTypes.map(formatShareStallLine);\n return [`- ${formattedDate}`, ...stallLines].join(\"\\n\");\n });\n\n return `${SHARE_MARKET_DATES_SECTION_HEADING}\\n${dateBlocks.join(\"\\n\")}`;\n}\n\nexport function formatShareRainOrShineLine(\n rainOrShine: boolean,\n): string | null {\n return rainOrShine ? SHARE_RAIN_OR_SHINE_LINE : null;\n}\n\nexport function formatShareIsFoodTrueLine(foodTruck: boolean): string | null {\n return foodTruck ? SHARE_FOOD_TRUCK_LINE : null;\n}\n\n/** Bulleted requirements list for invitation share copy. */\nexport function formatShareInvitationRequirementsSection(\n requirements: ShareEventInfoForInvitation[\"requirements\"] | null,\n): string | null {\n const bullets = (requirements ?? [])\n .filter((item) => item.value)\n .map((item) => item.label.trim())\n .filter((label) => label.length > 0)\n .map((label) => `- ${label}`);\n if (bullets.length === 0) {\n return null;\n }\n return `${SHARE_REQUIREMENTS_SECTION_HEADING}\\n${bullets.join(\"\\n\")}`;\n}\n\nexport function formatShareTagsSection(tags: string[]): string | null {\n const bullets = tags\n .map((tag) => tag.trim())\n .filter((tag) => tag.length > 0)\n .map((tag) => `- ${tag}`);\n if (bullets.length === 0) {\n return null;\n }\n return `${SHARE_TAGS_SECTION_HEADING}\\n${bullets.join(\"\\n\")}`;\n}\n\n/** Bulleted categories list for application share copy. */\nexport function formatShareApplicationCategoriesSection(\n categories: ShareVendorForApplication[\"categories\"],\n): string | null {\n const bullets = categories\n .map((category) => formatCategoryLabel(category).trim())\n .filter((label) => label.length > 0)\n .map((label) => `- ${label}`);\n if (bullets.length === 0) {\n return null;\n }\n return `${SHARE_CATEGORIES_SECTION_HEADING}\\n${bullets.join(\"\\n\")}`;\n}\n\n/** Stall dimensions line for application share copy. */\nexport function formatShareApplicationStallSizeLine(size: {\n width: string;\n depth: string;\n}): string {\n return `${SHARE_STALL_SIZE_PREFIX} ${size.width}m × ${size.depth}m`;\n}\n\n/** Bulleted compliance list for application share copy. */\nexport function formatShareApplicationComplianceSection(\n compliance: ShareVendorInfoForApplication[\"compliance\"],\n): string | null {\n const bullets = [\n compliance?.liabilityInsurance && \"Liability insurance\",\n compliance?.foodBeverageLicense && \"Food & beverage licence\",\n ]\n .filter((label): label is string => Boolean(label))\n .map((label) => `- ${label}`);\n if (bullets.length === 0) {\n return null;\n }\n return `${SHARE_COMPLIANCE_PREFIX}\\n${bullets.join(\"\\n\")}`;\n}\n\n/** Price range line for application share copy. */\nexport function formatShareApplicationPriceRangeLine(priceRange: {\n min: string;\n max: string;\n}): string {\n return `${SHARE_PRICE_RANGE_PREFIX} $${priceRange.min} – $${priceRange.max}`;\n}\n\n/** Application-deadline sentence for invitation share copy. */\nexport function formatShareInvitationApplicationDeadlineLine(\n applicationDeadlineHours: number,\n): string {\n return `${SHARE_APPLICATION_DEADLINE_PREFIX} vendors must apply at least ${applicationDeadlineHours} hours before each market date.`;\n}\n\nexport function buildInvitationShareDescription(\n event: ShareEventForInvitation,\n eventInfo: ShareEventInfoForInvitation | null | undefined,\n): string {\n const stallTypes =\n eventInfo?.dateTime?.flatMap((date) => date.stallTypes) ?? [];\n\n if (!eventInfo || stallTypes.length === 0) {\n return event.description?.trim() || \"\";\n }\n\n const sections = [\n event.location.fullAddress,\n formatShareRainOrShineLine(event.rainOrShine),\n formatShareTagsSection(event.tags),\n formatShareInvitationMarketDatesSection(eventInfo.dateTime),\n formatShareInvitationApplicationDeadlineLine(\n eventInfo.applicationDeadlineHours,\n ),\n formatShareInvitationRequirementsSection(eventInfo.requirements),\n ];\n\n return joinShareDescriptionSections(sections);\n}\n\nexport function buildApplicationShareDescription(\n vendor: ShareVendorForApplication,\n vendorInfo: ShareVendorInfoForApplication | null | undefined,\n): string {\n if (!vendorInfo) {\n return vendor.description?.trim() || \"\";\n }\n\n const profileDescription = vendor.description?.trim();\n\n const sections = [\n formatShareIsFoodTrueLine(vendor.foodTruck),\n formatShareApplicationCategoriesSection(vendor.categories),\n formatShareApplicationStallSizeLine(vendorInfo.stallInfo.size),\n formatShareApplicationComplianceSection(vendorInfo.compliance),\n formatShareApplicationPriceRangeLine(vendorInfo.product.priceRange),\n profileDescription,\n ];\n\n return joinShareDescriptionSections(sections);\n}\n","import {\n formatShareIsFoodTrueLine,\n formatShareRainOrShineLine,\n formatShareTagsSection,\n} from \"./buildRelationShareDescription\";\nimport { joinShareDescriptionSections } from \"./joinShareDescriptionSections\";\n\n/** Minimal event fields for public (market) share copy — matches in-app preview. */\nexport type ShareEventForPublic = {\n description?: string | null;\n rainOrShine: boolean;\n tags: string[];\n};\n\n/** Minimal vendor fields for public (stallholder) share copy — matches in-app preview. */\nexport type ShareVendorForPublic = {\n description?: string | null;\n foodTruck: boolean;\n};\n\nexport function buildPublicEventShareDescription(\n event: ShareEventForPublic,\n): string {\n return joinShareDescriptionSections([\n formatShareRainOrShineLine(event.rainOrShine),\n formatShareTagsSection(event.tags),\n event.description?.trim(),\n ]);\n}\n\nexport function buildPublicVendorShareDescription(\n vendor: ShareVendorForPublic,\n): string {\n return joinShareDescriptionSections([\n formatShareIsFoodTrueLine(vendor.foodTruck),\n vendor.description?.trim(),\n ]);\n}\n","import {\n POST_SHARE_RESOURCE_TYPES,\n RESOURCE_SHARE_TYPES,\n SHARE_SITE_URL,\n} from \"./constants\";\nimport {\n RELATION_SHARE_APPLICATION,\n RELATION_SHARE_INVITATION,\n} from \"./relationShareTypes\";\n\n/** Path segments for public resource share URLs (markets, posts, etc.). */\nexport const PUBLIC_SHARE_PATH_TYPES = [\n ...RESOURCE_SHARE_TYPES,\n ...POST_SHARE_RESOURCE_TYPES,\n] as const;\n\nexport type PublicSharePathType = (typeof PUBLIC_SHARE_PATH_TYPES)[number];\n\nexport type RelationSharePathType =\n | typeof RELATION_SHARE_INVITATION\n | typeof RELATION_SHARE_APPLICATION;\n\nexport type ShareType = PublicSharePathType | RelationSharePathType;\n\n/** Alternation for deep-link regexes — keep in sync with {@link ShareType}. */\nexport const SHARE_TYPE_PATH_REGEX = [\n ...PUBLIC_SHARE_PATH_TYPES,\n RELATION_SHARE_APPLICATION,\n RELATION_SHARE_INVITATION,\n].join(\"|\");\n\nexport function buildShareUrl(\n type: ShareType,\n slug: string,\n utmMedium: string = \"app\",\n): string {\n return `${SHARE_SITE_URL}/${type}/${encodeURIComponent(slug)}?utm_source=share&utm_medium=${utmMedium}&utm_campaign=${type}`;\n}\n","import { joinShareOgDescriptionSections } from \"./joinShareDescriptionSections\";\n\nexport {\n joinShareOgDescriptionSections,\n OG_DESCRIPTION_LINE_BREAK,\n SHARE_DESCRIPTION_SECTION_BREAK,\n} from \"./joinShareDescriptionSections\";\n\n/** Trims share text and collapses spaces per line; preserves `\\n\\n` section breaks. */\nconst LEADING_WHITESPACE = /^[ \\t]*/;\n\nexport function normalizeShareText(value: string | null | undefined): string {\n if (value == null) {\n return \"\";\n }\n return value\n .trim()\n .split(\"\\n\")\n .map((line) => {\n const leading = LEADING_WHITESPACE.exec(line)?.[0] ?? \"\";\n const rest = line\n .slice(leading.length)\n .trim()\n .replace(/[ \\t]{2,}/g, \" \");\n return leading + rest;\n })\n .join(\"\\n\")\n .replace(/\\n{3,}/g, \"\\n\\n\");\n}\n\nexport function splitShareDescriptionSections(value: string): string[] {\n const trimmed = normalizeShareText(value);\n if (!trimmed) {\n return [];\n }\n\n if (/\\n\\n/.test(trimmed)) {\n return trimmed\n .split(/\\n\\n+/)\n .map((section) => normalizeShareText(section))\n .filter((section) => section.length > 0);\n }\n\n if (/\\n/.test(trimmed)) {\n return trimmed\n .split(/\\n+/)\n .map((section) => normalizeShareText(section))\n .filter((section) => section.length > 0);\n }\n\n return [trimmed];\n}\n\n/**\n * Formats share descriptions for Open Graph / Twitter meta tags.\n * Sections are joined with {@link OG_DESCRIPTION_LINE_BREAK} (` `).\n */\nexport function normalizeShareOgDescription(value: string): string {\n return joinShareOgDescriptionSections(splitShareDescriptionSections(value));\n}\n\n/**\n * Open Graph / Twitter description from pre-built section strings.\n * Prefer {@link joinShareOgDescriptionSections} when sections are already known.\n */\nexport function buildShareOgDescriptionFromSections(\n sections: ReadonlyArray<string | false | null | undefined>,\n): string {\n return joinShareOgDescriptionSections(sections);\n}\n\n/** Open Graph / Twitter description — body sections only (`og:title` is separate). */\nexport function buildShareOgDescription(\n _title: string,\n description: string,\n): string {\n return joinShareOgDescriptionSections(\n splitShareDescriptionSections(description),\n );\n}\n\n/**\n * Strips emoji and symbols that do not render reliably in overlay SVG fonts.\n * Keeps letters, numbers, whitespace, and common sentence punctuation.\n */\nexport function stripOverlaySubtitleSpecialChars(text: string): string {\n const regex = /[^\\p{L}\\p{M}\\p{N}\\s.,!?'\"&\\-():;/]/gu;\n const result = text\n .replace(/\\p{Extended_Pictographic}/gu, \"\")\n .replace(regex, \"\");\n return result.trim();\n}\n","import type { ShareResourceType } from \"./constants\";\n\nexport function normalizeShareRouteId(id: string): string {\n try {\n return decodeURIComponent(id);\n } catch {\n return id;\n }\n}\n\n/** Relative path for a public share landing page (`/market/demo-market`). */\nexport function buildSharePagePath(\n resourceType: ShareResourceType,\n slug: string,\n): string {\n return `/${resourceType}/${encodeURIComponent(normalizeShareRouteId(slug))}`;\n}\n","export type ShareSlugResource = {\n _id: string;\n};\n\nexport function shareSlugResourceId(\n resource: ShareSlugResource | null | undefined,\n): string | null {\n return resource?._id ?? null;\n}\n","/**\n * Normalizes resource `updatedAt` to an epoch-ms string for Facebook/CDN cache busting\n * on social-image URLs (`?v=`). The API ignores this query param.\n */\nexport function toShareSocialImageCacheVersion(\n updatedAt: Date | string | number | null | undefined,\n): string | null {\n if (updatedAt == null || updatedAt === \"\") {\n return null;\n }\n\n let ms: number;\n if (typeof updatedAt === \"number\") {\n ms = updatedAt;\n } else if (updatedAt instanceof Date) {\n ms = updatedAt.getTime();\n } else {\n ms = Date.parse(String(updatedAt));\n }\n\n if (!Number.isFinite(ms)) {\n return null;\n }\n\n return String(Math.trunc(ms));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAAkB;AACl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;AACF,WAAO,mBAAmB,EAAE;AAAA,EAC9B,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAGO,SAAS,mBACd,cACA,MACQ;AACR,SAAO,IAAI,YAAY,IAAI,mBAAmB,sBAAsB,IAAI,CAAC,CAAC;AAC5E;;;ACZO,SAAS,oBACd,UACe;AACf,SAAO,UAAU,OAAO;AAC1B;;;ACJO,SAAS,+BACd,WACe;AACf,MAAI,aAAa,QAAQ,cAAc,IAAI;AACzC,WAAO;AAAA,EACT;AAEA,MAAI;AACJ,MAAI,OAAO,cAAc,UAAU;AACjC,SAAK;AAAA,EACP,WAAW,qBAAqB,MAAM;AACpC,SAAK,UAAU,QAAQ;AAAA,EACzB,OAAO;AACL,SAAK,KAAK,MAAM,OAAO,SAAS,CAAC;AAAA,EACnC;AAEA,MAAI,CAAC,OAAO,SAAS,EAAE,GAAG;AACxB,WAAO;AAAA,EACT;AAEA,SAAO,OAAO,KAAK,MAAM,EAAE,CAAC;AAC9B;","names":["import_dayjs","import_customParseFormat","dayjs","customParseFormat","isoWeek","dayjs","customParseFormat","utc","timezone","isSameOrAfter","dayjs"]}
|
|
1
|
+
{"version":3,"sources":["../../src/sharing/index.ts","../../src/utils/date.ts","../../src/utils/dateFormats.ts","../../src/utils/eventDateStatus.ts","../../src/sharing/relationShareTypes.ts","../../src/sharing/constants.ts","../../src/sharing/formatCategoryLabel.ts","../../src/sharing/joinShareDescriptionSections.ts","../../src/sharing/buildRelationShareDescription.ts","../../src/sharing/buildPublicShareDescription.ts","../../src/sharing/buildShareUrl.ts","../../src/sharing/normalizeShareDescription.ts","../../src/sharing/normalizeShareRouteId.ts","../../src/sharing/shareSlugResource.ts","../../src/sharing/toShareSocialImageCacheVersion.ts"],"sourcesContent":["export * from \"./buildPublicShareDescription\";\nexport * from \"./buildRelationShareDescription\";\nexport * from \"./shareRelationTypes\";\nexport * from \"./buildShareUrl\";\nexport * from \"./constants\";\nexport * from \"./formatCategoryLabel\";\nexport * from \"./joinShareDescriptionSections\";\nexport * from \"./normalizeShareDescription\";\nexport * from \"./normalizeShareRouteId\";\nexport * from \"./relationShareTypes\";\nexport * from \"./shareSlugResource\";\nexport * from \"./toShareSocialImageCacheVersion\";\n","import dayjs from \"dayjs\";\nimport customParseFormat from \"dayjs/plugin/customParseFormat.js\";\nimport isSameOrAfter from \"dayjs/plugin/isSameOrAfter.js\";\nimport timezone from \"dayjs/plugin/timezone.js\";\nimport utc from \"dayjs/plugin/utc.js\";\n\nimport { EnumEventDateStatus } from \"src/enums\";\n\nimport { dateFormat, timeFormat } from \"./dateFormats\";\nimport {\n FUTURE_EVENT_DATE_STATUSES,\n EVENT_DATE_STATUS_LABELS,\n} from \"./eventDateStatus\";\n\nexport { dateFormat, timeFormat };\n\n// Enable custom format parsing\ndayjs.extend(customParseFormat);\ndayjs.extend(utc);\ndayjs.extend(timezone);\ndayjs.extend(isSameOrAfter);\n\nconst NZ_TZ = \"Pacific/Auckland\";\n\nexport function toNZTime(date?: Date | string) {\n return date ? dayjs(date).tz(NZ_TZ) : dayjs().tz(NZ_TZ);\n}\n\n/** Start of the calendar day in Pacific/Auckland (daily games, streaks, etc.). */\nexport function nzStartOfDay(\n input?: Date | string | number | null,\n): dayjs.Dayjs {\n if (input == null) {\n return dayjs().tz(NZ_TZ).startOf(\"day\");\n }\n return dayjs.tz(input, NZ_TZ).startOf(\"day\");\n}\n\ntype DateFormat = \"date\" | \"time\" | \"datetime\";\n\n/**\n * Format a date string to a more readable format.\n * @param dateStr - the date string\n * @param timeStr - optional time string\n * @param display - 'date' | 'time' | 'datetime'\n * @returns formatted string based on display option\n */\nexport const formatDate = (\n dateStr: string,\n display: DateFormat = \"datetime\",\n timeStr?: string,\n) => {\n // Combine date and time into a single string if time is provided\n const dateTimeStr = timeStr ? `${dateStr} ${timeStr}` : dateStr;\n\n // Parse with formats\n const dateTime = timeStr\n ? dayjs(dateTimeStr, `${dateFormat} ${timeFormat}`)\n : dayjs(dateStr, dateFormat);\n\n // Format parts\n const formattedDate = dateTime.format(\"dddd, D MMMM, YYYY\");\n const formattedTime = dateTime.format(\"h:mm a\");\n\n // Return based on display option\n switch (display) {\n case \"date\":\n return formattedDate;\n case \"time\":\n return formattedTime;\n case \"datetime\":\n return `${formattedDate} at ${formattedTime}`;\n default:\n return formattedDate;\n }\n};\n\n/**\n * Formats accepted for a stored slot. The canonical writer is\n * `dayjs(...).format(`${dateFormat} ${timeFormat}`)`; the variants cover legacy\n * rows with an unpadded hour or trailing seconds. Each is parsed **strictly**, so\n * impossible values (`31-02`, `25:00`) are rejected instead of rolling over into\n * a real instant.\n */\nconst SLOT_FORMATS = [\n `${dateFormat} ${timeFormat}`,\n `${dateFormat} H:mm`,\n `${dateFormat} ${timeFormat}:ss`,\n `${dateFormat} H:mm:ss`,\n];\n\nconst parseSlot = (date: {\n startDate?: string;\n startTime?: string;\n}): dayjs.Dayjs | null => {\n if (!date.startDate || !date.startTime) {\n return null;\n }\n\n const value = `${date.startDate} ${date.startTime}`;\n\n for (const format of SLOT_FORMATS) {\n const parsed = dayjs(value, format, true);\n\n if (parsed.isValid()) {\n return parsed;\n }\n }\n\n return null;\n};\n\n/**\n * Shared \"starts now or later\" rule for `dd-mm-yyyy` + `HH:mm` slots. `now` is\n * passed in so a caller filtering a list compares every slot against the same\n * instant. A slot with a missing or unparseable date/time is never future.\n */\nconst isFutureDateTime = (\n date: { startDate?: string; startTime?: string },\n now: dayjs.Dayjs,\n): boolean => {\n const slot = parseSlot(date);\n\n return slot ? slot.isSameOrAfter(now) : false;\n};\n\nexport const getCurrentAndFutureDates = <\n T extends { startDate?: string; startTime?: string },\n>(\n dates: T[],\n): T[] => {\n const now = dayjs(); // current date and time\n\n return dates.filter((dateObj) => isFutureDateTime(dateObj, now));\n};\n\n/**\n * True when the slot starts now or later. Status-agnostic: used to hide past\n * relation dates from reads while the records stay in the database.\n */\nexport const isFutureStartDate = (date: {\n startDate?: string;\n startTime?: string;\n}): boolean => isFutureDateTime(date, dayjs());\n\nexport const isFutureDatesBeforeThreshold = (\n date: {\n startDate?: string;\n startTime?: string;\n },\n minHoursFromNow: number,\n): boolean => {\n if (!date.startDate || !date.startTime) {\n return false;\n }\n\n const threshold = minHoursFromNow\n ? dayjs().add(minHoursFromNow, \"hour\")\n : dayjs().startOf(\"day\");\n\n const dateTime = dayjs(\n `${date.startDate} ${date.startTime}`,\n `${dateFormat} ${timeFormat}`,\n );\n\n return dateTime.isSameOrAfter(threshold);\n};\n\nexport const formatTimestamp = (timestamp: string) => {\n const formattedDate = toNZTime(timestamp).format(dateFormat);\n\n return formatDate(formattedDate, \"date\");\n};\n\nexport const isIsoDateString = (value: unknown): value is string => {\n return typeof value === \"string\" && !Number.isNaN(Date.parse(value));\n};\n\n/**\n * Sort an array of date strings by their proximity to the current date.\n * @param dates - The array of date strings to sort.\n * @returns - The sorted array of date strings.\n */\nexport function sortDatesChronologically<\n T extends { startDate?: string; startTime?: string },\n>(dates: T[]): T[] {\n if (!dates?.length) {\n return [];\n }\n\n return [...dates].sort((a, b) => {\n const dateTimeFormat = `${dateFormat} ${timeFormat}`;\n const dateA =\n a.startDate && a.startTime\n ? dayjs(`${a.startDate} ${a.startTime}`, dateTimeFormat)\n : null;\n const dateB =\n b.startDate && b.startTime\n ? dayjs(`${b.startDate} ${b.startTime}`, dateTimeFormat)\n : null;\n\n if (dateA && dateB) {\n return dateA.valueOf() - dateB.valueOf();\n }\n\n if (dateA) {\n return -1;\n }\n\n if (dateB) {\n return 1;\n }\n\n return 0;\n });\n}\n\n/**\n * Start dates of the given date/time slots, chronological and de-duplicated.\n * Slots that share a `startDate` (e.g. two stall slots on the same day) collapse\n * into a single entry.\n */\nexport function getUniqueStartDates(\n dates: Array<{ startDate?: string; startTime?: string }> | null | undefined,\n): string[] {\n const seenStartDates = new Set<string>();\n const uniqueStartDates: string[] = [];\n\n for (const { startDate } of sortDatesChronologically(dates ?? [])) {\n if (!startDate || seenStartDates.has(startDate)) {\n continue;\n }\n\n seenStartDates.add(startDate);\n uniqueStartDates.push(startDate);\n }\n\n return uniqueStartDates;\n}\n\n/**\n * UI filter options for user-activity event periods. Derived from the canonical\n * {@link FUTURE_EVENT_DATE_STATUSES} list, minus `STARTING_SOON` (a presentational\n * choice: \"starting soon\" is surfaced separately rather than as a filter).\n */\nexport const futureTimePeriods = FUTURE_EVENT_DATE_STATUSES.filter(\n (status) => status !== EnumEventDateStatus.STARTING_SOON,\n).map((status) => ({\n label: EVENT_DATE_STATUS_LABELS[status],\n value: status,\n}));\n","export const dateFormat = \"DD-MM-YYYY\";\nexport const timeFormat = \"HH:mm\";\n","import dayjs from \"dayjs\";\nimport customParseFormat from \"dayjs/plugin/customParseFormat.js\";\nimport isoWeek from \"dayjs/plugin/isoWeek.js\";\n\nimport { EnumEventDateStatus } from \"../enums\";\nimport type { DateTimeType } from \"../types/global\";\n\nimport { dateFormat, timeFormat } from \"./dateFormats\";\n\n// Enable dayjs plugins used by event date parsing/status logic\ndayjs.extend(customParseFormat);\ndayjs.extend(isoWeek);\n\n/**\n * Display label per date status. Single source of truth instead of deriving\n * the label with `replaceAll(\"_\", \" \")` / text-transform tricks, so each\n * status maps to an explicit, correctly-cased string (e.g. \"This Week\",\n * \"Starting Soon\", \"Rescheduled\"). Lives here (not in `calendar`) so both\n * `calendar/eventCalendar` and `utils/date` can consume it without a circular\n * import.\n */\nexport const EVENT_DATE_STATUS_LABELS: Record<EnumEventDateStatus, string> = {\n [EnumEventDateStatus.STARTING_SOON]: \"Starting Soon\",\n [EnumEventDateStatus.STARTED]: \"Started\",\n [EnumEventDateStatus.TODAY]: \"Today\",\n [EnumEventDateStatus.TOMORROW]: \"Tomorrow\",\n [EnumEventDateStatus.THIS_WEEK]: \"This Week\",\n [EnumEventDateStatus.NEXT_WEEK]: \"Next Week\",\n [EnumEventDateStatus.UPCOMING]: \"Upcoming\",\n [EnumEventDateStatus.ENDED]: \"Ended\",\n [EnumEventDateStatus.RE_SCHEDULED]: \"Rescheduled\",\n [EnumEventDateStatus.CANCELED]: \"Canceled\",\n [EnumEventDateStatus.INVALID]: \"Invalid\",\n};\n\nexport const EVENT_DATE_STATUS_PERIOD_MAP: Partial<\n Record<EnumEventDateStatus, EnumEventDateStatus[]>\n> = {\n [EnumEventDateStatus.TODAY]: [\n EnumEventDateStatus.STARTED,\n EnumEventDateStatus.STARTING_SOON,\n EnumEventDateStatus.TODAY,\n ],\n [EnumEventDateStatus.THIS_WEEK]: [\n EnumEventDateStatus.STARTED,\n EnumEventDateStatus.STARTING_SOON,\n EnumEventDateStatus.THIS_WEEK,\n EnumEventDateStatus.TODAY,\n EnumEventDateStatus.TOMORROW,\n ],\n};\n\nexport function getAllowedEventDateStatuses(\n period: EnumEventDateStatus,\n): EnumEventDateStatus[] {\n return EVENT_DATE_STATUS_PERIOD_MAP[period] ?? [period];\n}\n\nexport function eventMatchesDateStatusPeriod(\n dateTime: Pick<DateTimeType, \"dateStatus\">[] | null | undefined,\n period: EnumEventDateStatus,\n): boolean {\n const allowedStatuses = getAllowedEventDateStatuses(period);\n\n return (\n dateTime?.some((dt) => allowedStatuses.includes(dt.dateStatus)) ?? false\n );\n}\n\nexport function filterEventsByDateStatusPeriod<\n T extends { dateTime?: Pick<DateTimeType, \"dateStatus\">[] | null },\n>(events: T[], period: EnumEventDateStatus): T[] {\n return events.filter((event) =>\n eventMatchesDateStatusPeriod(event.dateTime, period),\n );\n}\n\n/**\n * Canonical list of date statuses whose start date/time is still in the future\n * (i.e. the slot has not started yet). `STARTED`, `ENDED`, `INVALID`,\n * `CANCELED` and `RE_SCHEDULED` are intentionally excluded.\n *\n * This is the single source of truth for \"is this slot still in the future\".\n * `futureTimePeriods` (in `utils/date.ts`) derives from this list for UI\n * filters, additionally excluding `STARTING_SOON`.\n */\nexport const FUTURE_EVENT_DATE_STATUSES: readonly EnumEventDateStatus[] = [\n EnumEventDateStatus.STARTING_SOON,\n EnumEventDateStatus.TODAY,\n EnumEventDateStatus.TOMORROW,\n EnumEventDateStatus.THIS_WEEK,\n EnumEventDateStatus.NEXT_WEEK,\n EnumEventDateStatus.UPCOMING,\n];\n\nexport function isFutureEventDateStatus(\n dateStatus: EnumEventDateStatus | null | undefined,\n): boolean {\n return Boolean(dateStatus && FUTURE_EVENT_DATE_STATUSES.includes(dateStatus));\n}\n\nexport function filterDatesByFutureStatus<\n T extends { dateStatus?: EnumEventDateStatus | null },\n>(dates: T[]): T[] {\n return dates.filter((date) => isFutureEventDateStatus(date.dateStatus));\n}\n\n/**\n * Statuses set by an explicit user action rather than derived from the\n * schedule clock. The status recomputation below must leave them untouched,\n * otherwise a canceled/rescheduled date would silently flip back to a\n * time-derived status on the next run.\n */\nexport const MANUAL_DATE_STATUSES: ReadonlySet<EnumEventDateStatus> = new Set([\n EnumEventDateStatus.CANCELED,\n EnumEventDateStatus.RE_SCHEDULED,\n]);\n\n/**\n * Builds the event schedule that relation dates should be matched against.\n *\n * Manual statuses (`MANUAL_DATE_STATUSES`: CANCELED and RE_SCHEDULED) stay on\n * the live `Event.dateTime` for visibility, but a relation date pointing at\n * them is treated as removed. Archived (ended) slots are appended separately\n * so relation dates for archived history still match instead of being wrongly\n * marked unavailable.\n *\n * Shared by the server's `processUnavailableRelations` sync and the cron\n * orphan-date cleanup so both use the same archive-aware schedule.\n */\nexport function buildRelationEligibleEventSchedule<\n T extends { dateStatus?: EnumEventDateStatus | null },\n>(liveDateTime: T[], archivedDateTime: T[] = []): T[] {\n const eligible = liveDateTime.filter(\n (slot) => !slot.dateStatus || !MANUAL_DATE_STATUSES.has(slot.dateStatus),\n );\n return [...eligible, ...archivedDateTime];\n}\n\n/**\n * Determines the dateStatus for a future event date\n * @param startDateTime The start date-time of the event\n * @param now The current date-time\n * @returns The appropriate EnumEventDateStatus\n */\nexport function getFutureEventStatus(\n startDateTime: dayjs.Dayjs,\n now: dayjs.Dayjs,\n): EnumEventDateStatus {\n const hoursUntilStart = startDateTime.diff(now, \"hour\", true);\n if (hoursUntilStart > 0 && hoursUntilStart <= 4) {\n return EnumEventDateStatus.STARTING_SOON;\n }\n\n if (startDateTime.isSame(now, \"day\")) {\n return EnumEventDateStatus.TODAY;\n }\n\n if (startDateTime.isSame(now.add(1, \"day\"), \"day\")) {\n return EnumEventDateStatus.TOMORROW;\n }\n\n if (startDateTime.isSame(now, \"isoWeek\")) {\n return EnumEventDateStatus.THIS_WEEK;\n }\n\n if (startDateTime.isSame(now.add(1, \"week\"), \"isoWeek\")) {\n return EnumEventDateStatus.NEXT_WEEK;\n }\n\n return EnumEventDateStatus.UPCOMING;\n}\n\n/**\n * Updates the dateStatus field for a single DateTimeType object based on the current date/time.\n * Manual statuses (CANCELED, RE_SCHEDULED) are preserved and returned as-is.\n * @param dateTime The date-time object to update\n * @returns A new object with an updated dateStatus value, or the original\n * object when the stored status is a manual override\n */\nexport function updateSingleDateTimeStatus<T extends DateTimeType>(\n dateTime: T,\n now: dayjs.Dayjs = dayjs(),\n): T {\n if (MANUAL_DATE_STATUSES.has(dateTime.dateStatus)) {\n return dateTime;\n }\n\n // Parse start and end date-time\n const dateTimeFormat = `${dateFormat} ${timeFormat}`;\n const startDateTime = dayjs(\n `${dateTime.startDate} ${dateTime.startTime}`,\n dateTimeFormat,\n true,\n );\n const endDateTime = dayjs(\n `${dateTime.endDate} ${dateTime.endTime}`,\n dateTimeFormat,\n true,\n );\n\n // Skip if dates are invalid\n if (!startDateTime.isValid() || !endDateTime.isValid()) {\n return {\n ...dateTime,\n dateStatus: EnumEventDateStatus.INVALID,\n };\n }\n\n if (endDateTime.isBefore(startDateTime)) {\n return {\n ...dateTime,\n dateStatus: EnumEventDateStatus.INVALID,\n };\n }\n\n let dateStatus: EnumEventDateStatus;\n\n if (endDateTime.isAfter(now)) {\n if (startDateTime.isAfter(now)) {\n // Event has not started yet\n dateStatus = getFutureEventStatus(startDateTime, now);\n } else {\n // Event is in progress\n dateStatus = EnumEventDateStatus.STARTED;\n }\n } else {\n // Event has ended\n dateStatus = EnumEventDateStatus.ENDED;\n }\n\n return {\n ...dateTime,\n dateStatus,\n };\n}\n","/** Path segments for relation share URLs — must match mobile `RelationTitle` values. */\nexport const RELATION_SHARE_INVITATION = \"invitation\" as const;\nexport const RELATION_SHARE_APPLICATION = \"application\" as const;\n\n/**\n * Bump when relation overlay SVG/layout changes so og:image URLs and API ETags\n * invalidate after deploy. Facebook caches preview JPEGs by exact URL — changing\n * this value forces crawlers to fetch a fresh image after server deploy.\n */\nexport const RELATION_OVERLAY_LAYOUT_VERSION = 43;\n\nexport const RELATION_SHARE_RESOURCE_TYPES = [\n RELATION_SHARE_INVITATION,\n RELATION_SHARE_APPLICATION,\n] as const;\n\nexport type RelationShareResourceType =\n (typeof RELATION_SHARE_RESOURCE_TYPES)[number];\n\nexport function isRelationShareResourceType(\n resourceType: string,\n): resourceType is RelationShareResourceType {\n return (RELATION_SHARE_RESOURCE_TYPES as readonly string[]).includes(\n resourceType,\n );\n}\n","import {\n RELATION_SHARE_APPLICATION,\n RELATION_SHARE_INVITATION,\n type RelationShareResourceType,\n} from \"./relationShareTypes\";\n\nexport {\n RELATION_SHARE_APPLICATION,\n RELATION_SHARE_INVITATION,\n RELATION_OVERLAY_LAYOUT_VERSION,\n RELATION_SHARE_RESOURCE_TYPES,\n isRelationShareResourceType,\n type RelationShareResourceType,\n} from \"./relationShareTypes\";\n\n/** Open Graph recommended preview size (must match admin `SHARE_OG_IMAGE_*`). */\nexport const SOCIAL_IMAGE_WIDTH = 1200;\n\n/** Open Graph recommended preview size (must match admin `SHARE_OG_IMAGE_*`). */\nexport const SOCIAL_IMAGE_HEIGHT = 630;\n\n/** Keep in sync with `CLUEMART_MAIN_DOMAIN_URL` in utils (avoid utils↔sharing import cycle). */\nexport const SHARE_SITE_URL = \"https://cluemart.co.nz\";\n\n/** Calendar marker for invitation market-dates share copy (U+1F4C5 📅). */\nexport const SHARE_CALENDAR_ICON = \"\\u{1F4C5}\";\n\nexport const SHARE_MARKET_DATES_SECTION_HEADING = `${SHARE_CALENDAR_ICON} Market dates:`;\n\n/** Check mark for invitation requirements share copy (U+2705 ✅). */\nexport const SHARE_CHECKMARK_ICON = \"\\u{2705}\";\n\nexport const SHARE_REQUIREMENTS_SECTION_HEADING = `${SHARE_CHECKMARK_ICON} Requirements:`;\n\n/** Information marker for tags share copy (U+2139 ℹ️). */\nexport const SHARE_INFO_ICON = \"\\u{2139}\\u{FE0F}\";\n\nexport const SHARE_TAGS_SECTION_HEADING = `${SHARE_INFO_ICON} Tags:`;\n\n/** Standalone line when `rainOrShine` is true (invitation share + OG section parsing). */\nexport const SHARE_RAIN_OR_SHINE_LINE = \"Rain or Shine\";\n\n/** Standalone line when `foodTruck` is true (application share + OG section parsing). */\nexport const SHARE_FOOD_TRUCK_LINE = \"Food Truck\";\n\n/** Prefix for application compliance line (share text + OG section parsing). */\nexport const SHARE_COMPLIANCE_PREFIX = `${SHARE_CHECKMARK_ICON} Compliance:`;\n\n/** Label tag for application categories share copy (U+1F3F7 🏷️). */\nexport const SHARE_CATEGORY_ICON = \"\\u{1F3F7}\\u{FE0F}\";\n\nexport const SHARE_CATEGORIES_SECTION_HEADING = `${SHARE_CATEGORY_ICON} Categories:`;\n\n/** Straight ruler for application stall-size share copy (U+1F4CF 📏). */\nexport const SHARE_RULER_ICON = \"\\u{1F4CF}\";\n\n/** Prefix for application stall-size line (share text + OG section parsing). */\nexport const SHARE_STALL_SIZE_PREFIX = `${SHARE_RULER_ICON} Stall size:`;\n\n/** Dollar marker for price-range share copy (U+0024 $ — text, not emoji, so it stays black). */\nexport const SHARE_DOLLAR_ICON = \"$\";\n\n/** Prefix for application price-range line (share text + OG section parsing). */\nexport const SHARE_PRICE_RANGE_PREFIX = `${SHARE_DOLLAR_ICON} Price range:`;\n\n/** Alarm clock for invitation application-deadline share copy (U+23F0 ⏰). */\nexport const SHARE_CLOCK_ICON = \"\\u{23F0}\";\n\n/** Prefix for the invitation application-deadline sentence (share text + OG section parsing). */\nexport const SHARE_APPLICATION_DEADLINE_PREFIX = `${SHARE_CLOCK_ICON} Application deadline:`;\n\n/** First line of `og:description` (and legacy share-message text). */\nexport const SHARE_MORE_INFO_LINE = \"Shared from ClueMart\";\n\nexport const DEFAULT_SHARE_OG_IMAGE = `${SHARE_SITE_URL}/assets/logo.webp`;\n\nexport const RESOURCE_SHARE_TYPES = [\n \"market\",\n \"stallholder\",\n \"partner\",\n \"affiliate\",\n \"school\",\n] as const;\n\nexport type ResourceShareType = (typeof RESOURCE_SHARE_TYPES)[number];\n\nexport const POST_SHARE_RESOURCE_TYPES = [\n \"market_faces\",\n \"clue_bites\",\n \"play_and_win\",\n] as const;\n\nexport type PostShareResourceType = (typeof POST_SHARE_RESOURCE_TYPES)[number];\n\nexport type ShareResourceType =\n ResourceShareType | PostShareResourceType | RelationShareResourceType;\n\nexport const SHARE_RESOURCE_LABEL: Record<ShareResourceType, string> = {\n [RELATION_SHARE_APPLICATION]: \"Application\",\n [RELATION_SHARE_INVITATION]: \"Invitation\",\n affiliate: \"Affiliate\",\n clue_bites: \"Clue Bites\",\n market_faces: \"Market Faces\",\n market: \"Market\",\n partner: \"Partner\",\n play_and_win: \"Play & Win\",\n school: \"School\",\n stallholder: \"Stallholder\",\n};\n\nexport function isPostShareResourceType(\n resourceType: ShareResourceType,\n): resourceType is PostShareResourceType {\n return (POST_SHARE_RESOURCE_TYPES as readonly string[]).includes(\n resourceType,\n );\n}\n","import type { Category } from \"../types/global\";\n\nexport function formatCategoryLabel(category: Category): string {\n const subcategoryNames = category.subcategories\n .map((subcategory) => subcategory.name)\n .filter(Boolean);\n\n if (subcategoryNames.length === 0) {\n return category.name;\n }\n\n return `${category.name} (${subcategoryNames.join(\", \")})`;\n}\n","import { SHARE_MORE_INFO_LINE } from \"./constants\";\n\n/** Blank line between share sections — title, address, dates, URL, etc. */\nexport const SHARE_DESCRIPTION_SECTION_BREAK = \"\\n\\n\";\n\n/**\n * Line break for `og:description` meta content. Use instead of `\\n` — Next.js\n * HTML serialisation collapses literal newlines to spaces; Facebook reads ` `.\n */\nexport const OG_DESCRIPTION_LINE_BREAK = \" \";\n\n/** Joins OG description sections for Facebook link cards (and Twitter). */\nexport function joinShareOgDescriptionSections(\n sections: ReadonlyArray<string | false | null | undefined>,\n): string {\n return sections\n .map((section) => (typeof section === \"string\" ? section.trim() : \"\"))\n .filter((section): section is string => section.length > 0)\n .map((section) => section.replace(/\\n/g, OG_DESCRIPTION_LINE_BREAK))\n .join(OG_DESCRIPTION_LINE_BREAK);\n}\n\nexport function joinShareDescriptionSections(\n sections: ReadonlyArray<string | false | null | undefined>,\n): string {\n return sections\n .filter((section): section is string => Boolean(section))\n .join(SHARE_DESCRIPTION_SECTION_BREAK);\n}\n\n/** Prepends the standard share branding line when assembling display text. */\nexport function appendShareMoreInfoLine(description: string): string {\n const trimmed = description.trim();\n if (trimmed.startsWith(SHARE_MORE_INFO_LINE)) {\n return trimmed;\n }\n if (trimmed.length === 0) {\n return SHARE_MORE_INFO_LINE;\n }\n return joinShareDescriptionSections([SHARE_MORE_INFO_LINE, trimmed]);\n}\n","import type { StallType } from \"../types/event\";\nimport { formatDate } from \"../utils/date\";\n\nimport {\n SHARE_APPLICATION_DEADLINE_PREFIX,\n SHARE_CATEGORIES_SECTION_HEADING,\n SHARE_FOOD_TRUCK_LINE,\n SHARE_MARKET_DATES_SECTION_HEADING,\n SHARE_RAIN_OR_SHINE_LINE,\n SHARE_REQUIREMENTS_SECTION_HEADING,\n SHARE_COMPLIANCE_PREFIX,\n SHARE_PRICE_RANGE_PREFIX,\n SHARE_STALL_SIZE_PREFIX,\n SHARE_TAGS_SECTION_HEADING,\n} from \"./constants\";\nimport { formatCategoryLabel } from \"./formatCategoryLabel\";\nimport { joinShareDescriptionSections } from \"./joinShareDescriptionSections\";\nimport type {\n ShareEventForInvitation,\n ShareEventInfoForInvitation,\n ShareVendorForApplication,\n ShareVendorInfoForApplication,\n} from \"./shareRelationTypes\";\n\nexport type {\n ShareEventForInvitation,\n ShareEventInfoForInvitation,\n ShareVendorForApplication,\n ShareVendorInfoForApplication,\n} from \"./shareRelationTypes\";\n\n/** Formats event `startDate` (`DD-MM-YYYY`) for share copy — same as share preview UI. */\nexport function formatShareMarketDate(dateStr: string): string {\n return formatDate(dateStr, \"date\");\n}\n\nexport function formatStallCapacityLabel(stallCapacity: number): string {\n return stallCapacity > 0 ? ` (${stallCapacity} spaces available)` : \" - Full\";\n}\n\nexport function formatShareStallLine(stall: StallType): string {\n return ` - ${stall.label} — $${stall.price}${formatStallCapacityLabel(stall.stallCapacity)}`;\n}\n\n/** Nested market dates + per-date stall lines for invitation share copy. */\nexport function formatShareInvitationMarketDatesSection(\n dateTime: ShareEventInfoForInvitation[\"dateTime\"],\n): string {\n const dateBlocks = dateTime.map((date) => {\n const formattedDate = date.startDate\n ? formatShareMarketDate(date.startDate)\n : \"Unknown date\";\n const stallLines = date.stallTypes.map(formatShareStallLine);\n return [`- ${formattedDate}`, ...stallLines].join(\"\\n\");\n });\n\n return `${SHARE_MARKET_DATES_SECTION_HEADING}\\n${dateBlocks.join(\"\\n\")}`;\n}\n\nexport function formatShareRainOrShineLine(\n rainOrShine: boolean,\n): string | null {\n return rainOrShine ? SHARE_RAIN_OR_SHINE_LINE : null;\n}\n\nexport function formatShareIsFoodTrueLine(foodTruck: boolean): string | null {\n return foodTruck ? SHARE_FOOD_TRUCK_LINE : null;\n}\n\n/** Bulleted requirements list for invitation share copy. */\nexport function formatShareInvitationRequirementsSection(\n requirements: ShareEventInfoForInvitation[\"requirements\"] | null,\n): string | null {\n const bullets = (requirements ?? [])\n .filter((item) => item.value)\n .map((item) => item.label.trim())\n .filter((label) => label.length > 0)\n .map((label) => `- ${label}`);\n if (bullets.length === 0) {\n return null;\n }\n return `${SHARE_REQUIREMENTS_SECTION_HEADING}\\n${bullets.join(\"\\n\")}`;\n}\n\nexport function formatShareTagsSection(tags: string[]): string | null {\n const bullets = tags\n .map((tag) => tag.trim())\n .filter((tag) => tag.length > 0)\n .map((tag) => `- ${tag}`);\n if (bullets.length === 0) {\n return null;\n }\n return `${SHARE_TAGS_SECTION_HEADING}\\n${bullets.join(\"\\n\")}`;\n}\n\n/** Bulleted categories list for application share copy. */\nexport function formatShareApplicationCategoriesSection(\n categories: ShareVendorForApplication[\"categories\"],\n): string | null {\n const bullets = categories\n .map((category) => formatCategoryLabel(category).trim())\n .filter((label) => label.length > 0)\n .map((label) => `- ${label}`);\n if (bullets.length === 0) {\n return null;\n }\n return `${SHARE_CATEGORIES_SECTION_HEADING}\\n${bullets.join(\"\\n\")}`;\n}\n\n/** Stall dimensions line for application share copy. */\nexport function formatShareApplicationStallSizeLine(size: {\n width: string;\n depth: string;\n}): string {\n return `${SHARE_STALL_SIZE_PREFIX} ${size.width}m × ${size.depth}m`;\n}\n\n/** Bulleted compliance list for application share copy. */\nexport function formatShareApplicationComplianceSection(\n compliance: ShareVendorInfoForApplication[\"compliance\"],\n): string | null {\n const bullets = [\n compliance?.liabilityInsurance && \"Liability insurance\",\n compliance?.foodBeverageLicense && \"Food & beverage licence\",\n ]\n .filter((label): label is string => Boolean(label))\n .map((label) => `- ${label}`);\n if (bullets.length === 0) {\n return null;\n }\n return `${SHARE_COMPLIANCE_PREFIX}\\n${bullets.join(\"\\n\")}`;\n}\n\n/** Price range line for application share copy. */\nexport function formatShareApplicationPriceRangeLine(priceRange: {\n min: string;\n max: string;\n}): string {\n return `${SHARE_PRICE_RANGE_PREFIX} $${priceRange.min} – $${priceRange.max}`;\n}\n\n/** Application-deadline sentence for invitation share copy. */\nexport function formatShareInvitationApplicationDeadlineLine(\n applicationDeadlineHours: number,\n): string {\n return `${SHARE_APPLICATION_DEADLINE_PREFIX} vendors must apply at least ${applicationDeadlineHours} hours before each market date.`;\n}\n\nexport function buildInvitationShareDescription(\n event: ShareEventForInvitation,\n eventInfo: ShareEventInfoForInvitation | null | undefined,\n): string {\n const stallTypes =\n eventInfo?.dateTime?.flatMap((date) => date.stallTypes) ?? [];\n\n if (!eventInfo || stallTypes.length === 0) {\n return event.description?.trim() || \"\";\n }\n\n const sections = [\n event.location.fullAddress,\n formatShareRainOrShineLine(event.rainOrShine),\n formatShareTagsSection(event.tags),\n formatShareInvitationMarketDatesSection(eventInfo.dateTime),\n formatShareInvitationApplicationDeadlineLine(\n eventInfo.applicationDeadlineHours,\n ),\n formatShareInvitationRequirementsSection(eventInfo.requirements),\n ];\n\n return joinShareDescriptionSections(sections);\n}\n\nexport function buildApplicationShareDescription(\n vendor: ShareVendorForApplication,\n vendorInfo: ShareVendorInfoForApplication | null | undefined,\n): string {\n if (!vendorInfo) {\n return vendor.description?.trim() || \"\";\n }\n\n const profileDescription = vendor.description?.trim();\n\n const sections = [\n formatShareIsFoodTrueLine(vendor.foodTruck),\n formatShareApplicationCategoriesSection(vendor.categories),\n formatShareApplicationStallSizeLine(vendorInfo.stallInfo.size),\n formatShareApplicationComplianceSection(vendorInfo.compliance),\n formatShareApplicationPriceRangeLine(vendorInfo.product.priceRange),\n profileDescription,\n ];\n\n return joinShareDescriptionSections(sections);\n}\n","import {\n formatShareIsFoodTrueLine,\n formatShareRainOrShineLine,\n formatShareTagsSection,\n} from \"./buildRelationShareDescription\";\nimport { joinShareDescriptionSections } from \"./joinShareDescriptionSections\";\n\n/** Minimal event fields for public (market) share copy — matches in-app preview. */\nexport type ShareEventForPublic = {\n description?: string | null;\n rainOrShine: boolean;\n tags: string[];\n};\n\n/** Minimal vendor fields for public (stallholder) share copy — matches in-app preview. */\nexport type ShareVendorForPublic = {\n description?: string | null;\n foodTruck: boolean;\n};\n\nexport function buildPublicEventShareDescription(\n event: ShareEventForPublic,\n): string {\n return joinShareDescriptionSections([\n formatShareRainOrShineLine(event.rainOrShine),\n formatShareTagsSection(event.tags),\n event.description?.trim(),\n ]);\n}\n\nexport function buildPublicVendorShareDescription(\n vendor: ShareVendorForPublic,\n): string {\n return joinShareDescriptionSections([\n formatShareIsFoodTrueLine(vendor.foodTruck),\n vendor.description?.trim(),\n ]);\n}\n","import {\n POST_SHARE_RESOURCE_TYPES,\n RESOURCE_SHARE_TYPES,\n SHARE_SITE_URL,\n} from \"./constants\";\nimport {\n RELATION_SHARE_APPLICATION,\n RELATION_SHARE_INVITATION,\n} from \"./relationShareTypes\";\n\n/** Path segments for public resource share URLs (markets, posts, etc.). */\nexport const PUBLIC_SHARE_PATH_TYPES = [\n ...RESOURCE_SHARE_TYPES,\n ...POST_SHARE_RESOURCE_TYPES,\n] as const;\n\nexport type PublicSharePathType = (typeof PUBLIC_SHARE_PATH_TYPES)[number];\n\nexport type RelationSharePathType =\n | typeof RELATION_SHARE_INVITATION\n | typeof RELATION_SHARE_APPLICATION;\n\nexport type ShareType = PublicSharePathType | RelationSharePathType;\n\n/** Alternation for deep-link regexes — keep in sync with {@link ShareType}. */\nexport const SHARE_TYPE_PATH_REGEX = [\n ...PUBLIC_SHARE_PATH_TYPES,\n RELATION_SHARE_APPLICATION,\n RELATION_SHARE_INVITATION,\n].join(\"|\");\n\nexport function buildShareUrl(\n type: ShareType,\n slug: string,\n utmMedium: string = \"app\",\n): string {\n return `${SHARE_SITE_URL}/${type}/${encodeURIComponent(slug)}?utm_source=share&utm_medium=${utmMedium}&utm_campaign=${type}`;\n}\n","import { joinShareOgDescriptionSections } from \"./joinShareDescriptionSections\";\n\nexport {\n joinShareOgDescriptionSections,\n OG_DESCRIPTION_LINE_BREAK,\n SHARE_DESCRIPTION_SECTION_BREAK,\n} from \"./joinShareDescriptionSections\";\n\n/** Trims share text and collapses spaces per line; preserves `\\n\\n` section breaks. */\nconst LEADING_WHITESPACE = /^[ \\t]*/;\n\nexport function normalizeShareText(value: string | null | undefined): string {\n if (value == null) {\n return \"\";\n }\n return value\n .trim()\n .split(\"\\n\")\n .map((line) => {\n const leading = LEADING_WHITESPACE.exec(line)?.[0] ?? \"\";\n const rest = line\n .slice(leading.length)\n .trim()\n .replace(/[ \\t]{2,}/g, \" \");\n return leading + rest;\n })\n .join(\"\\n\")\n .replace(/\\n{3,}/g, \"\\n\\n\");\n}\n\nexport function splitShareDescriptionSections(value: string): string[] {\n const trimmed = normalizeShareText(value);\n if (!trimmed) {\n return [];\n }\n\n if (/\\n\\n/.test(trimmed)) {\n return trimmed\n .split(/\\n\\n+/)\n .map((section) => normalizeShareText(section))\n .filter((section) => section.length > 0);\n }\n\n if (/\\n/.test(trimmed)) {\n return trimmed\n .split(/\\n+/)\n .map((section) => normalizeShareText(section))\n .filter((section) => section.length > 0);\n }\n\n return [trimmed];\n}\n\n/**\n * Formats share descriptions for Open Graph / Twitter meta tags.\n * Sections are joined with {@link OG_DESCRIPTION_LINE_BREAK} (` `).\n */\nexport function normalizeShareOgDescription(value: string): string {\n return joinShareOgDescriptionSections(splitShareDescriptionSections(value));\n}\n\n/**\n * Open Graph / Twitter description from pre-built section strings.\n * Prefer {@link joinShareOgDescriptionSections} when sections are already known.\n */\nexport function buildShareOgDescriptionFromSections(\n sections: ReadonlyArray<string | false | null | undefined>,\n): string {\n return joinShareOgDescriptionSections(sections);\n}\n\n/** Open Graph / Twitter description — body sections only (`og:title` is separate). */\nexport function buildShareOgDescription(\n _title: string,\n description: string,\n): string {\n return joinShareOgDescriptionSections(\n splitShareDescriptionSections(description),\n );\n}\n\n/**\n * Strips emoji and symbols that do not render reliably in overlay SVG fonts.\n * Keeps letters, numbers, whitespace, and common sentence punctuation.\n */\nexport function stripOverlaySubtitleSpecialChars(text: string): string {\n const regex = /[^\\p{L}\\p{M}\\p{N}\\s.,!?'\"&\\-():;/]/gu;\n const result = text\n .replace(/\\p{Extended_Pictographic}/gu, \"\")\n .replace(regex, \"\");\n return result.trim();\n}\n","import type { ShareResourceType } from \"./constants\";\n\nexport function normalizeShareRouteId(id: string): string {\n try {\n return decodeURIComponent(id);\n } catch {\n return id;\n }\n}\n\n/** Relative path for a public share landing page (`/market/demo-market`). */\nexport function buildSharePagePath(\n resourceType: ShareResourceType,\n slug: string,\n): string {\n return `/${resourceType}/${encodeURIComponent(normalizeShareRouteId(slug))}`;\n}\n","export type ShareSlugResource = {\n _id: string;\n};\n\nexport function shareSlugResourceId(\n resource: ShareSlugResource | null | undefined,\n): string | null {\n return resource?._id ?? null;\n}\n","/**\n * Normalizes resource `updatedAt` to an epoch-ms string for Facebook/CDN cache busting\n * on social-image URLs (`?v=`). The API ignores this query param.\n */\nexport function toShareSocialImageCacheVersion(\n updatedAt: Date | string | number | null | undefined,\n): string | null {\n if (updatedAt == null || updatedAt === \"\") {\n return null;\n }\n\n let ms: number;\n if (typeof updatedAt === \"number\") {\n ms = updatedAt;\n } else if (updatedAt instanceof Date) {\n ms = updatedAt.getTime();\n } else {\n ms = Date.parse(String(updatedAt));\n }\n\n if (!Number.isFinite(ms)) {\n return null;\n }\n\n return String(Math.trunc(ms));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAAkB;AAClB,IAAAC,4BAA8B;AAC9B,2BAA0B;AAC1B,sBAAqB;AACrB,iBAAgB;;;ACJT,IAAM,aAAa;AACnB,IAAM,aAAa;;;ACD1B,mBAAkB;AAClB,+BAA8B;AAC9B,qBAAoB;AAQpB,aAAAC,QAAM,OAAO,yBAAAC,OAAiB;AAC9B,aAAAD,QAAM,OAAO,eAAAE,OAAO;AAUb,IAAM,2BAAgE;AAAA,EAC3E,oCAAkC,GAAG;AAAA,EACrC,wBAA4B,GAAG;AAAA,EAC/B,oBAA0B,GAAG;AAAA,EAC7B,0BAA6B,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U,OAAO;AAC1B;;;ACJO,SAAS,+BACd,WACe;AACf,MAAI,aAAa,QAAQ,cAAc,IAAI;AACzC,WAAO;AAAA,EACT;AAEA,MAAI;AACJ,MAAI,OAAO,cAAc,UAAU;AACjC,SAAK;AAAA,EACP,WAAW,qBAAqB,MAAM;AACpC,SAAK,UAAU,QAAQ;AAAA,EACzB,OAAO;AACL,SAAK,KAAK,MAAM,OAAO,SAAS,CAAC;AAAA,EACnC;AAEA,MAAI,CAAC,OAAO,SAAS,EAAE,GAAG;AACxB,WAAO;AAAA,EACT;AAEA,SAAO,OAAO,KAAK,MAAM,EAAE,CAAC;AAC9B;","names":["import_dayjs","import_customParseFormat","dayjs","customParseFormat","isoWeek","dayjs","customParseFormat","utc","timezone","isSameOrAfter","dayjs"]}
|
package/dist/sharing/index.mjs
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
normalizeShareRouteId,
|
|
25
25
|
shareSlugResourceId,
|
|
26
26
|
toShareSocialImageCacheVersion
|
|
27
|
-
} from "../chunk-
|
|
27
|
+
} from "../chunk-KMS64DE2.mjs";
|
|
28
28
|
import {
|
|
29
29
|
DEFAULT_SHARE_OG_IMAGE,
|
|
30
30
|
OG_DESCRIPTION_LINE_BREAK,
|
|
@@ -68,7 +68,7 @@ import {
|
|
|
68
68
|
normalizeShareText,
|
|
69
69
|
splitShareDescriptionSections,
|
|
70
70
|
stripOverlaySubtitleSpecialChars
|
|
71
|
-
} from "../chunk-
|
|
71
|
+
} from "../chunk-HKTBJOB7.mjs";
|
|
72
72
|
import "../chunk-XGGFB7HY.mjs";
|
|
73
73
|
export {
|
|
74
74
|
DEFAULT_SHARE_OG_IMAGE,
|
package/dist/utils/index.cjs
CHANGED
|
@@ -118,6 +118,7 @@ __export(utils_exports, {
|
|
|
118
118
|
hasMatchingEventDate: () => hasMatchingEventDate,
|
|
119
119
|
isFutureDatesBeforeThreshold: () => isFutureDatesBeforeThreshold,
|
|
120
120
|
isFutureEventDateStatus: () => isFutureEventDateStatus,
|
|
121
|
+
isFutureStartDate: () => isFutureStartDate,
|
|
121
122
|
isInternalErrorMessage: () => isInternalErrorMessage,
|
|
122
123
|
isIsoDateString: () => isIsoDateString,
|
|
123
124
|
isResourceImageActive: () => isResourceImageActive,
|
|
@@ -471,19 +472,34 @@ var formatDate = (dateStr, display = "datetime", timeStr) => {
|
|
|
471
472
|
return formattedDate;
|
|
472
473
|
}
|
|
473
474
|
};
|
|
475
|
+
var SLOT_FORMATS = [
|
|
476
|
+
`${dateFormat} ${timeFormat}`,
|
|
477
|
+
`${dateFormat} H:mm`,
|
|
478
|
+
`${dateFormat} ${timeFormat}:ss`,
|
|
479
|
+
`${dateFormat} H:mm:ss`
|
|
480
|
+
];
|
|
481
|
+
var parseSlot = (date) => {
|
|
482
|
+
if (!date.startDate || !date.startTime) {
|
|
483
|
+
return null;
|
|
484
|
+
}
|
|
485
|
+
const value = `${date.startDate} ${date.startTime}`;
|
|
486
|
+
for (const format of SLOT_FORMATS) {
|
|
487
|
+
const parsed = (0, import_dayjs2.default)(value, format, true);
|
|
488
|
+
if (parsed.isValid()) {
|
|
489
|
+
return parsed;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
return null;
|
|
493
|
+
};
|
|
494
|
+
var isFutureDateTime = (date, now) => {
|
|
495
|
+
const slot = parseSlot(date);
|
|
496
|
+
return slot ? slot.isSameOrAfter(now) : false;
|
|
497
|
+
};
|
|
474
498
|
var getCurrentAndFutureDates = (dates) => {
|
|
475
499
|
const now = (0, import_dayjs2.default)();
|
|
476
|
-
return dates.filter((dateObj) =>
|
|
477
|
-
if (!dateObj.startDate || !dateObj.startTime) {
|
|
478
|
-
return false;
|
|
479
|
-
}
|
|
480
|
-
const dateTime = (0, import_dayjs2.default)(
|
|
481
|
-
`${dateObj.startDate} ${dateObj.startTime}`,
|
|
482
|
-
`${dateFormat} ${timeFormat}`
|
|
483
|
-
);
|
|
484
|
-
return dateTime.isSameOrAfter(now);
|
|
485
|
-
});
|
|
500
|
+
return dates.filter((dateObj) => isFutureDateTime(dateObj, now));
|
|
486
501
|
};
|
|
502
|
+
var isFutureStartDate = (date) => isFutureDateTime(date, (0, import_dayjs2.default)());
|
|
487
503
|
var isFutureDatesBeforeThreshold = (date, minHoursFromNow) => {
|
|
488
504
|
if (!date.startDate || !date.startTime) {
|
|
489
505
|
return false;
|
|
@@ -2617,6 +2633,7 @@ function getErrorMessage(error, fallback = DEFAULT_USER_FACING_ERROR) {
|
|
|
2617
2633
|
hasMatchingEventDate,
|
|
2618
2634
|
isFutureDatesBeforeThreshold,
|
|
2619
2635
|
isFutureEventDateStatus,
|
|
2636
|
+
isFutureStartDate,
|
|
2620
2637
|
isInternalErrorMessage,
|
|
2621
2638
|
isIsoDateString,
|
|
2622
2639
|
isResourceImageActive,
|