domma-cms 1.6.60 → 1.7.1

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.
Files changed (168) hide show
  1. package/CHANGELOG.md +4349 -0
  2. package/README.md +1 -1
  3. package/admin/dist/domma/domma-tools.css +3 -3
  4. package/admin/dist/domma/domma-tools.min.js +3 -3
  5. package/admin/js/lib/effect-defs.js +1 -1
  6. package/admin/js/lib/effects-builder.js +2 -2
  7. package/admin/js/lib/mail-compose.js +1 -0
  8. package/admin/js/lib/page-editor-reference.js +5 -5
  9. package/admin/js/lib/shortcode-tags.js +1 -1
  10. package/admin/js/templates/call-new.html +1 -1
  11. package/admin/js/templates/docs/usage-shortcodes.html +39 -0
  12. package/admin/js/views/call-new.js +1 -1
  13. package/admin/js/views/contacts.js +15 -15
  14. package/admin/js/views/form-submissions.js +2 -2
  15. package/docs/DommaFeatures.md +3005 -0
  16. package/docs/MultiTenant.md +176 -0
  17. package/docs/api-reference.md +1667 -0
  18. package/docs/cache.md +96 -0
  19. package/docs/configuration.md +1811 -0
  20. package/docs/editions-and-licences.md +190 -0
  21. package/docs/getting-started.md +201 -0
  22. package/docs/guides/form-triggers.md +260 -0
  23. package/docs/guides/mongodb-storage-adapter.md +282 -0
  24. package/docs/guides/multi-page-forms.md +121 -0
  25. package/docs/images/scribe-composer.png +0 -0
  26. package/docs/markdown-shortcodes.md +1738 -0
  27. package/docs/pentest-report-2026-04-03.md +181 -0
  28. package/docs/plans/2026-02-28-admin-topbar-login-forms.md +349 -0
  29. package/docs/plans/2026-02-28-domma-ui-polish.md +286 -0
  30. package/docs/plans/2026-02-28-reset-seed-fresh-commands.md +520 -0
  31. package/docs/plans/2026-03-02-cookie-consent-design.md +86 -0
  32. package/docs/plans/2026-03-02-cookie-consent-plugin.md +453 -0
  33. package/docs/plans/2026-03-02-tooltip-sweep-and-back-to-top-plugin-design.md +126 -0
  34. package/docs/plans/2026-03-02-tooltip-sweep-back-to-top.md +427 -0
  35. package/docs/plans/2026-03-05-cookie-consent-btt-core.md +115 -0
  36. package/docs/plans/2026-03-05-custom-css-migrate-to-core-design.md +35 -0
  37. package/docs/plans/2026-03-05-custom-css-migrate-to-core.md +352 -0
  38. package/docs/plans/2026-03-05-scribe-script-shortcode.md +373 -0
  39. package/docs/plans/2026-03-05-user-types-design.md +139 -0
  40. package/docs/plans/2026-03-05-user-types-implementation.md +1035 -0
  41. package/docs/plans/2026-03-09-page-editor-view-cta-inserts-design.md +78 -0
  42. package/docs/plans/2026-03-09-page-editor-view-cta-inserts.md +388 -0
  43. package/docs/plans/2026-03-09-pro-documentation-design.md +80 -0
  44. package/docs/plans/2026-03-09-pro-documentation.md +1017 -0
  45. package/docs/plans/2026-06-10-core-project-design.md +240 -0
  46. package/docs/plugin-development.md +827 -0
  47. package/docs/recruitment-recipe.md +501 -0
  48. package/docs/scaffolding.md +312 -0
  49. package/docs/screenshots/calculator-floating.png +0 -0
  50. package/docs/screenshots/calculator-standard.png +0 -0
  51. package/docs/screenshots/email-settings.png +0 -0
  52. package/docs/screenshots/messages-count.png +0 -0
  53. package/docs/structure/user-types.md +107 -0
  54. package/docs/superpowers/plans/2026-05-25-admin-sidebar-via-menus.md +1112 -0
  55. package/docs/superpowers/plans/2026-06-08-navbar-mobile-drawer-and-menu-enrichment.md +1161 -0
  56. package/docs/superpowers/plans/2026-06-25-domma-docs-project.md +695 -0
  57. package/docs/superpowers/plans/2026-06-26-surveys-HANDOFF.md +68 -0
  58. package/docs/superpowers/plans/2026-06-26-surveys-pro-plugin.md +1902 -0
  59. package/docs/superpowers/plans/2026-08-19-collection-context-sort-export.md +1577 -0
  60. package/docs/superpowers/plans/2026-10-09-content-api.md +1192 -0
  61. package/docs/superpowers/specs/2026-03-12-form-followup-actions-design.md +152 -0
  62. package/docs/superpowers/specs/2026-03-12-page-editor-form-insert-and-per-page-theme-design.md +115 -0
  63. package/docs/superpowers/specs/2026-03-17-nav-hidden-items-design.md +85 -0
  64. package/docs/superpowers/specs/2026-03-19-accordion-insert-design.md +175 -0
  65. package/docs/superpowers/specs/2026-03-25-static-block-shortcode-design.md +153 -0
  66. package/docs/superpowers/specs/2026-03-25-text-shortcode-design.md +168 -0
  67. package/docs/superpowers/specs/2026-04-05-card-builder-design.md +315 -0
  68. package/docs/superpowers/specs/2026-04-06-insert-builders-design.md +278 -0
  69. package/docs/superpowers/specs/2026-04-06-layouts-design.md +226 -0
  70. package/docs/superpowers/specs/2026-04-07-blog-plugin-design.md +300 -0
  71. package/docs/superpowers/specs/2026-04-07-calendar-plugin-design.md +538 -0
  72. package/docs/superpowers/specs/2026-04-17-components-area-design.md +368 -0
  73. package/docs/superpowers/specs/2026-05-02-effects-slideover-overhaul-design.md +193 -0
  74. package/docs/superpowers/specs/2026-05-06-dashboard-rebuild-design.md +257 -0
  75. package/docs/superpowers/specs/2026-05-24-menus-design.md +466 -0
  76. package/docs/superpowers/specs/2026-05-25-admin-sidebar-via-menus-design.md +358 -0
  77. package/docs/superpowers/specs/2026-05-25-projects-design.md +380 -0
  78. package/docs/superpowers/specs/2026-06-08-navbar-mobile-drawer-and-menu-enrichment-design.md +292 -0
  79. package/docs/superpowers/specs/2026-06-08-sidebar-tools-plugins-folders-design.md +59 -0
  80. package/docs/superpowers/specs/2026-06-25-domma-docs-project-design.md +192 -0
  81. package/docs/superpowers/specs/2026-06-26-domma-charts-upstream-proposal.md +44 -0
  82. package/docs/superpowers/specs/2026-06-26-manager-scheduler-upstream-proposal.md +46 -0
  83. package/docs/superpowers/specs/2026-06-26-surveys-pro-plugin-design.md +206 -0
  84. package/docs/superpowers/specs/2026-07-02-shortcode-context-menu-design.md +96 -0
  85. package/docs/superpowers/specs/2026-08-19-collection-context-sort-export-design.md +330 -0
  86. package/docs/superpowers/specs/2026-09-22-dcms-marketplace-design.md +1150 -0
  87. package/docs/superpowers/specs/2026-10-09-content-api-design.md +325 -0
  88. package/docs/superpowers/specs/plans/2026-03-12-form-followup-actions.md +624 -0
  89. package/docs/superpowers/specs/plans/2026-03-12-page-editor-form-insert-and-per-page-theme.md +125 -0
  90. package/docs/superpowers/specs/plans/2026-03-17-nav-hidden-items.md +578 -0
  91. package/docs/superpowers/specs/plans/2026-03-19-accordion-insert.md +635 -0
  92. package/docs/superpowers/specs/plans/2026-03-25-text-shortcode.md +545 -0
  93. package/docs/superpowers/specs/plans/2026-04-05-card-builder.md +1970 -0
  94. package/docs/superpowers/specs/plans/2026-04-06-insert-builders.md +1049 -0
  95. package/docs/superpowers/specs/plans/2026-04-06-layouts.md +1015 -0
  96. package/docs/superpowers/specs/plans/2026-04-07-calendar-plugin.md +1526 -0
  97. package/docs/superpowers/specs/plans/2026-04-08-plugin-monetisation-split.md +242 -0
  98. package/docs/superpowers/specs/plans/2026-04-17-components-area.md +2038 -0
  99. package/docs/superpowers/specs/plans/2026-05-02-effects-slideover-overhaul.md +2335 -0
  100. package/docs/superpowers/specs/plans/2026-05-06-dashboard-rebuild.md +1999 -0
  101. package/docs/superpowers/specs/plans/2026-05-17-cache-system.md +1436 -0
  102. package/docs/superpowers/specs/plans/2026-05-24-menus.md +3096 -0
  103. package/docs/superpowers/specs/plans/2026-05-25-projects.md +2869 -0
  104. package/docs/superpowers/specs/plans/2026-09-22-marketplace-step2-consolidation.md +505 -0
  105. package/docs/superpowers/specs/plans/2026-09-22-marketplace-step3-catalogue-and-key.md +154 -0
  106. package/docs/superpowers/specs/plans/2026-09-22-tools-promotion.md +260 -0
  107. package/docs/theming.md +320 -0
  108. package/package.json +2 -2
  109. package/plugins/_lib/admin/mail/compose-window.js +3 -1
  110. package/plugins/_lib/admin/mail/identity.js +18 -3
  111. package/plugins/_lib/admin/mail/reader-view.js +32 -3
  112. package/plugins/blog/CLAUDE.md +4 -0
  113. package/plugins/blog/admin/lib/email.js +191 -0
  114. package/plugins/blog/admin/views/comments.js +3 -1
  115. package/plugins/blog/plugin.json +2 -2
  116. package/plugins/blog/plugin.public.js +1 -1
  117. package/plugins/blog/tests/email.test.js +69 -0
  118. package/plugins/booking/CLAUDE.md +4 -0
  119. package/plugins/booking/admin/lib/email.js +191 -0
  120. package/plugins/booking/admin/views/panels.js +7 -3
  121. package/plugins/booking/plugin.json +1 -1
  122. package/plugins/booking/tests/email.test.js +69 -0
  123. package/plugins/free-tier.lock.json +27 -19
  124. package/plugins/shopping-cart/CLAUDE.md +4 -0
  125. package/plugins/shopping-cart/admin/lib/email.js +191 -0
  126. package/plugins/shopping-cart/admin/views/orders.js +11 -3
  127. package/plugins/shopping-cart/plugin.json +2 -2
  128. package/plugins/shopping-cart/tests/email.test.js +69 -0
  129. package/plugins/support/CLAUDE.md +4 -0
  130. package/plugins/support/admin/lib/email.js +191 -0
  131. package/plugins/support/admin/views/desk.js +4 -1
  132. package/plugins/support/admin/views/inbox.js +6 -2
  133. package/plugins/support/plugin.json +2 -2
  134. package/plugins/support/tests/email.test.js +69 -0
  135. package/public/js/celebrations/core/canvas.js +1 -1
  136. package/public/js/celebrations/index.js +1 -1
  137. package/public/js/celebrations/licenses/ABeeZee-Regular-OFL.txt +93 -0
  138. package/public/js/celebrations/licenses/Allura-Regular-OFL.txt +93 -0
  139. package/public/js/celebrations/message-attrs.mjs +1 -0
  140. package/public/js/celebrations/themes/anniversary.js +1 -0
  141. package/public/js/celebrations/themes/autumn.js +1 -0
  142. package/public/js/celebrations/themes/birthday.js +1 -0
  143. package/public/js/celebrations/themes/butterfly-flight.js +1 -0
  144. package/public/js/celebrations/themes/calendar.js +1 -0
  145. package/public/js/celebrations/themes/chinese-new-year-dates.js +1 -0
  146. package/public/js/celebrations/themes/chinese-new-year.js +1 -0
  147. package/public/js/celebrations/themes/christmas.js +1 -1
  148. package/public/js/celebrations/themes/easter.js +1 -0
  149. package/public/js/celebrations/themes/garden-drawing.js +1 -0
  150. package/public/js/celebrations/themes/garden.js +1 -0
  151. package/public/js/celebrations/themes/graduation.js +1 -0
  152. package/public/js/celebrations/themes/greeting.js +1 -0
  153. package/public/js/celebrations/themes/make-it-rain.js +1 -0
  154. package/public/js/celebrations/themes/money-rain.js +1 -0
  155. package/public/js/celebrations/themes/new-year.js +1 -0
  156. package/public/js/celebrations/themes/occasion-drawing.js +1 -0
  157. package/public/js/celebrations/themes/occasions.js +1 -0
  158. package/public/js/celebrations/themes/rain-control.js +1 -0
  159. package/public/js/celebrations/themes/sparkler-font-data.js +1 -0
  160. package/public/js/celebrations/themes/sparkler-font.js +1 -0
  161. package/public/js/celebrations/themes/sparkler-writing.js +1 -0
  162. package/public/js/celebrations/themes/summer-garden.js +1 -0
  163. package/public/js/celebrations/themes/winter.js +1 -0
  164. package/public/js/celebrations/trait-data.mjs +1 -1
  165. package/public/js/effects.js +1 -1
  166. package/scripts/build.js +4 -0
  167. package/server/services/markdown.js +5 -2
  168. package/server/templates/page.html +1 -1
@@ -0,0 +1,191 @@
1
+ /**
2
+ * Email someone from this Tool: Email Pro's compose window when the user can
3
+ * send from it, otherwise the device's mail program through `mailto:`.
4
+ *
5
+ * Core makes the choice (`/admin/js/lib/mail-compose.js`, CMS 1.6.61+). It is
6
+ * imported at RUN time, never statically, so this Tool still loads on an older
7
+ * core - where every action keeps the plain `mailto:` it always had.
8
+ *
9
+ * `emailTo()` is for menu actions; `routeMailLinks()` is for a visible
10
+ * `<a href="mailto:…">` - the link stays a link (copy, hover, middle-click all
11
+ * still work) and a plain click goes the same way as the menu action.
12
+ *
13
+ * @module support/admin/lib/email
14
+ */
15
+
16
+ const CORE = '/admin/js/lib/mail-compose.js';
17
+ let core = null;
18
+
19
+ /** The core module, or null on a core without it. Asked once. */
20
+ const loadCore = () => (core ??= import(CORE).catch(() => null));
21
+
22
+ /** Longest subject or body carried (as core's). */
23
+ const MAX_TEXT = 2000;
24
+ /** Longest mailto: handed to the device - mail programs cut or refuse longer ones. */
25
+ const MAX_MAILTO = 1800;
26
+
27
+ /**
28
+ * Something that can only be an email address: one @, no spaces or line
29
+ * breaks, nothing that would start another recipient or a query.
30
+ *
31
+ * @param {*} value
32
+ * @returns {boolean}
33
+ */
34
+ export function looksLikeAddress(value) {
35
+ return typeof value === 'string' && /^[^\s@<>,;"?&]+@[^\s@<>,;"?&]+$/.test(value);
36
+ }
37
+
38
+ /** Valid addresses only, once each (ignoring case), from a string, `{address}`/`{email}`, or a list. */
39
+ function addressesOf(list) {
40
+ const seen = new Set();
41
+ return (Array.isArray(list) ? list : list == null ? [] : [list])
42
+ .map(x => String(typeof x === 'string' ? x : (x?.address ?? x?.email ?? '')).trim())
43
+ .filter(a => looksLikeAddress(a) && !seen.has(a.toLowerCase()) && seen.add(a.toLowerCase()));
44
+ }
45
+
46
+ /** Trim and cap; a subject loses its line breaks (they would be a header). */
47
+ function cleanText(value, {oneLine = false} = {}) {
48
+ let text = String(value ?? '');
49
+ if (oneLine) text = text.replace(/[\r\n]+/g, ' ');
50
+ return text.slice(0, MAX_TEXT).trim();
51
+ }
52
+
53
+ /**
54
+ * The request as a `mailto:` link (the fallback on an older core).
55
+ *
56
+ * @param {{to?: *, cc?: *, bcc?: *, subject?: string, body?: string}} request
57
+ * @returns {string}
58
+ */
59
+ export function mailtoHref({to, cc, bcc, subject, body} = {}) {
60
+ const enc = (list) => addressesOf(list).map(a => encodeURIComponent(a).replace(/%40/g, '@')).join(',');
61
+ const s = cleanText(subject, {oneLine: true});
62
+ const b = cleanText(body);
63
+ const query = [];
64
+ if (enc(cc)) query.push(`cc=${enc(cc)}`);
65
+ if (enc(bcc)) query.push(`bcc=${enc(bcc)}`);
66
+ if (s) query.push(`subject=${encodeURIComponent(s)}`);
67
+ if (b) query.push(`body=${encodeURIComponent(b)}`);
68
+ return `mailto:${enc(to)}${query.length ? `?${query.join('&')}` : ''}`;
69
+ }
70
+
71
+ /** Copy text: the clipboard, else the old copy command, else a box to copy it from by hand. */
72
+ async function copyText(text) {
73
+ try {
74
+ await navigator.clipboard.writeText(text);
75
+ return true;
76
+ } catch { /* next */ }
77
+ const box = document.createElement('textarea');
78
+ box.className = 'form-input';
79
+ box.readOnly = true;
80
+ box.rows = 6;
81
+ box.value = text;
82
+ try {
83
+ box.style.position = 'fixed';
84
+ box.style.opacity = '0';
85
+ document.body.appendChild(box);
86
+ box.select();
87
+ if (document.execCommand('copy')) return true;
88
+ } catch { /* next */ } finally {
89
+ box.remove();
90
+ box.style.position = '';
91
+ box.style.opacity = '';
92
+ }
93
+ const modal = E.modal({title: 'Copy the addresses', size: 'medium', buttons: [{id: 'close', text: 'Close', variant: 'secondary'}]});
94
+ modal.element.appendChild(box); // light DOM: setContent would strip the textarea
95
+ modal.open();
96
+ box.select();
97
+ return false;
98
+ }
99
+
100
+ /**
101
+ * Hand the request to the device's mail program - unless the link would be
102
+ * too long for it, when the addresses are copied instead and the toast says
103
+ * what did not go.
104
+ */
105
+ async function openMailto(request) {
106
+ const href = mailtoHref(request);
107
+ if (href.length <= MAX_MAILTO) {
108
+ location.href = href;
109
+ return 'mailto';
110
+ }
111
+ const all = addressesOf([...addressesOf(request.to), ...addressesOf(request.cc), ...addressesOf(request.bcc)]);
112
+ const copied = all.length ? await copyText(all.join(', ')) : false;
113
+ const lost = [cleanText(request.subject) && 'the subject', cleanText(request.body) && 'the message'].filter(Boolean);
114
+ E.toast(`Too long for your mail program to open. ${all.length
115
+ ? `${copied ? 'The' : 'Copy the'} ${all.length} address${all.length === 1 ? '' : 'es'}${copied ? ' are copied' : ''} - paste them into Bcc of a new email.` : ''}${lost.length ? ` Not carried over: ${lost.join(' and ')}.` : ''}`,
116
+ {type: 'warning', duration: 9000});
117
+ return 'copied';
118
+ }
119
+
120
+ const decode = (s) => { try { return decodeURIComponent(s); } catch { return s; } };
121
+
122
+ /**
123
+ * A `mailto:` link read back into a request (what a visible link carries).
124
+ * When the address part holds anything that is not an address, the query
125
+ * is ignored: an address stored as `me@x.com?body=…` must not prefill a message.
126
+ *
127
+ * @param {string} href
128
+ * @returns {null|{to: string[], cc: string[], bcc: string[], subject: string, body: string}}
129
+ */
130
+ export function parseMailto(href) {
131
+ const m = String(href ?? '').match(/^mailto:([^?]*)(?:\?(.*))?$/i);
132
+ if (!m) return null;
133
+ const split = (s) => decode(s || '').split(/[,;]/).map(x => x.trim()).filter(Boolean);
134
+ const named = split(m[1]);
135
+ const out = {to: addressesOf(named), cc: [], bcc: [], subject: '', body: ''};
136
+ if (named.some(a => !looksLikeAddress(a))) return out;
137
+ for (const pair of (m[2] || '').split('&')) {
138
+ const i = pair.indexOf('=');
139
+ if (i < 1) continue;
140
+ const key = pair.slice(0, i).toLowerCase();
141
+ const value = pair.slice(i + 1);
142
+ if (key === 'to') out.to = addressesOf([...out.to, ...split(value)]);
143
+ else if (key === 'cc' || key === 'bcc') out[key] = addressesOf([...out[key], ...split(value)]);
144
+ else if (key === 'subject') out.subject = cleanText(decode(value), {oneLine: true});
145
+ else if (key === 'body') out.body = cleanText(decode(value));
146
+ }
147
+ return out;
148
+ }
149
+
150
+ /**
151
+ * Email someone. Recipients are `{name, address}`, `{name, email}` or bare
152
+ * addresses; several people belong in `bcc`, so nobody sees the others.
153
+ * With nobody to address (a link to pass on) compose still opens, To empty.
154
+ *
155
+ * @param {{to?: *, cc?: *, bcc?: *, subject?: string, body?: string}} request
156
+ * @returns {Promise<'compose'|'mailto'|'copied'|'none'>}
157
+ */
158
+ export async function emailTo(request = {}) {
159
+ const mail = await loadCore();
160
+ if (!mail) return openMailto(request);
161
+ const r = mail.composeRequest(request);
162
+ if (r.to.length || r.cc.length || r.bcc.length) return mail.openEmail(r);
163
+ if (await mail.emailReady()) {
164
+ location.hash = mail.composeHash(r);
165
+ return 'compose';
166
+ }
167
+ location.href = mail.mailtoHref(r);
168
+ return 'mailto';
169
+ }
170
+
171
+ /**
172
+ * Send plain clicks on the `mailto:` links inside `root` through `emailTo()`.
173
+ * A modified click (new tab/window) or one already handled is left alone.
174
+ *
175
+ * @param {Element} root
176
+ * @returns {() => void} removes the listener
177
+ */
178
+ export function routeMailLinks(root) {
179
+ if (!root) return () => {};
180
+ const onClick = (e) => {
181
+ if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
182
+ const a = e.target?.closest?.('a[href^="mailto:" i]');
183
+ if (!a || !root.contains(a)) return;
184
+ const request = parseMailto(a.getAttribute('href'));
185
+ if (!request) return;
186
+ e.preventDefault();
187
+ emailTo(request);
188
+ };
189
+ root.addEventListener('click', onClick);
190
+ return () => root.removeEventListener('click', onClick);
191
+ }
@@ -18,6 +18,7 @@ import {
18
18
  refreshBadge, rowKeys, stamp, store, telHref, threadFiles, threadRows, when
19
19
  } from '../lib/kit.js';
20
20
  import {DRAFT_KEYS, afterSend, draftQuestion, draftText, draftValues, newDraftQuestion, ticketPrint} from '../lib/drafts.js';
21
+ import {looksLikeAddress, routeMailLinks} from '../lib/email.js';
21
22
 
22
23
  const ROW = `
23
24
  <div class="sp-row" data-id="{{key}}" tabindex="0" role="button" aria-haspopup="menu">
@@ -154,9 +155,11 @@ export async function mount(root, ctx) {
154
155
  const tel = view.querySelector('[data-ref="tel"]');
155
156
  scope(M.effect(() => {
156
157
  const c = contact.value || {};
157
- if (c.email) mailLink.setAttribute('href', `mailto:${c.email}`);
158
+ if (looksLikeAddress(c.email)) mailLink.setAttribute('href', `mailto:${encodeURIComponent(c.email)}`);
158
159
  if (c.phone) tel.setAttribute('href', telHref(c.phone));
159
160
  }));
161
+ // Domma's address stays a link; a click goes to Email Pro's compose when this user can send from it.
162
+ scope(routeMailLinks(view));
160
163
 
161
164
  // The first load shows a skeleton in the slot; a reload keeps the list on screen.
162
165
  let loaded = false;
@@ -13,6 +13,7 @@ import {
13
13
  threadFiles, threadRows, when
14
14
  } from '../lib/kit.js';
15
15
  import {DRAFT_KEYS, afterSend, draftQuestion, draftText, draftValues, ticketPrint} from '../lib/drafts.js';
16
+ import {looksLikeAddress, routeMailLinks} from '../lib/email.js';
16
17
 
17
18
  const ROW = `
18
19
  <div class="sp-row" data-id="{{key}}" tabindex="0" role="button" aria-haspopup="menu">
@@ -234,6 +235,7 @@ export async function mount(root, ctx) {
234
235
  let guard = null;
235
236
  let savedNotes = saved.notes;
236
237
  let stopScroll = () => {};
238
+ let stopMail = () => {};
237
239
  let menu = null;
238
240
 
239
241
  const run = async (fn) => {
@@ -249,7 +251,7 @@ export async function mount(root, ctx) {
249
251
  size: 'lg',
250
252
  model: {thread, status, statusLabel, tone, urgent, archived, draft, hasDraft, after, notes, busy},
251
253
  cleanup: () => {
252
- stopScroll(); stopFiles(); shown.dispose(); menu?.destroy?.();
254
+ stopScroll(); stopMail(); stopFiles(); shown.dispose(); menu?.destroy?.();
253
255
  [cur, thread, status, statusLabel, tone, urgent, archived, hasDraft].forEach(c => c.dispose?.());
254
256
  panels.release('detail');
255
257
  },
@@ -258,7 +260,7 @@ export async function mount(root, ctx) {
258
260
  <div><dt>Status</dt><dd><span class="sp-chip" data-bind-class="tone.value" data-bind-text="statusLabel.value"></span>
259
261
  <span class="sp-chip is-muted" data-bind-hidden="!archived.value">Archived</span></dd></div>
260
262
  <div><dt>Site</dt><dd>${siteUrl ? `<a href="${esc(siteUrl)}" target="_blank" rel="noopener">${esc(t.siteName)}</a>` : esc(t.siteName)}</dd></div>
261
- <div><dt>From</dt><dd>${esc(t.userName)}${t.userEmail ? ` · <a href="mailto:${esc(t.userEmail)}">${esc(t.userEmail)}</a>` : ''}</dd></div>
263
+ <div><dt>From</dt><dd>${esc(t.userName)}${t.userEmail ? ` · ${looksLikeAddress(t.userEmail) ? `<a href="mailto:${esc(encodeURIComponent(t.userEmail))}">${esc(t.userEmail)}</a>` : esc(t.userEmail)}` : ''}</dd></div>
262
264
  <div><dt>About</dt><dd>${esc(labelOf(t.category))}</dd></div>
263
265
  <div><dt>Opened</dt><dd>${esc(stamp(t.createdAt))}</dd></div>
264
266
  ${t.where ? `<div><dt>Where</dt><dd>${esc(t.where)}</dd></div>` : ''}
@@ -329,6 +331,8 @@ export async function mount(root, ctx) {
329
331
  was: offer.state === 'keep' ? offer.draft.was : ticketPrint(t, {notes: true})
330
332
  });
331
333
  panels.set('detail', {key: tid, close: (how) => guard.close(how)});
334
+ // The customer's address stays a link; a click goes to Email Pro's compose when it can.
335
+ stopMail = routeMailLinks(panel.panel);
332
336
  // Keep the newest message in view as the thread grows.
333
337
  const box = panel.panel.querySelector('.sp-thread-host');
334
338
  stopScroll = M.effect(() => { thread.value; Promise.resolve().then(() => { M.flush?.(); box.scrollTop = box.scrollHeight; }); });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "support",
3
3
  "displayName": "Support",
4
- "version": "1.2.0",
4
+ "version": "1.2.1",
5
5
  "tier": "free",
6
6
  "description": "Get help from Domma straight from your admin: our email, phone and hours always to hand, and a conversation with the Domma team for anything you need - urgent requests first. Right-click a request to archive, resolve or remove it.",
7
7
  "author": "Domma CMS",
@@ -61,7 +61,7 @@
61
61
  ],
62
62
  "views": {
63
63
  "plugin-support": {
64
- "entry": "support/admin/views/support.js?v=1.2.0",
64
+ "entry": "support/admin/views/support.js?v=1.2.1",
65
65
  "exportName": "supportView"
66
66
  }
67
67
  }
@@ -0,0 +1,69 @@
1
+ /**
2
+ * admin/lib/email.js - the mailto: fallback and link reading (node has no
3
+ * /admin/js/lib/mail-compose.js, so emailTo() here is the older-core path).
4
+ */
5
+ import {test} from 'node:test';
6
+ import assert from 'node:assert/strict';
7
+ import {emailTo, looksLikeAddress, mailtoHref, parseMailto} from '../admin/lib/email.js';
8
+
9
+ test('mailtoHref: one person in To, subject and body encoded, @ readable', () => {
10
+ assert.equal(mailtoHref({to: [{name: 'Ann', address: 'ann+x@example.test'}], subject: 'Hi & bye', body: 'Line 1\nLine 2'}),
11
+ 'mailto:ann%2Bx@example.test?subject=Hi%20%26%20bye&body=Line%201%0ALine%202');
12
+ });
13
+
14
+ test('mailtoHref: several people in Bcc, strings and contacts alike', () => {
15
+ assert.equal(mailtoHref({bcc: ['a@x.test', {email: 'b@x.test'}], subject: 'S'}), 'mailto:?bcc=a@x.test,b@x.test&subject=S');
16
+ });
17
+
18
+ test('parseMailto reads back what mailtoHref writes, and plain links', () => {
19
+ const r = parseMailto(mailtoHref({to: 'a@x.test', cc: ['c@x.test'], bcc: ['b@x.test', 'd@x.test'], subject: 'Hi + there', body: 'Join: https://x.test/?a=1&b=2'}));
20
+ assert.deepEqual(r, {to: ['a@x.test'], cc: ['c@x.test'], bcc: ['b@x.test', 'd@x.test'], subject: 'Hi + there', body: 'Join: https://x.test/?a=1&b=2'});
21
+ assert.deepEqual(parseMailto('mailto:ann@example.test'), {to: ['ann@example.test'], cc: [], bcc: [], subject: '', body: ''});
22
+ assert.equal(parseMailto('https://example.test'), null);
23
+ });
24
+
25
+ test('emailTo on a core without mail-compose.js keeps the old mailto:', async () => {
26
+ const saved = globalThis.location;
27
+ globalThis.location = {href: '', hash: ''};
28
+ try {
29
+ assert.equal(await emailTo({to: [{name: 'Ann', address: 'ann@example.test'}], subject: 'Hello'}), 'mailto');
30
+ assert.equal(globalThis.location.href, 'mailto:ann@example.test?subject=Hello');
31
+ assert.equal(globalThis.location.hash, '');
32
+ } finally {
33
+ globalThis.location = saved;
34
+ }
35
+ });
36
+
37
+ test('fallback hardening: bad addresses dropped, repeats once, subject one line, text capped', () => {
38
+ for (const bad of ['a b@x.test', 'a@x.test\r\nBcc: c@x.test', '<a@x.test>', 'a@x.test,b@x.test', 'a@x.test?body=hi', 'nobody']) assert.equal(looksLikeAddress(bad), false, bad);
39
+ const href = mailtoHref({to: ['A@x.test', 'a@x.test', 'a b@x.test', 'me@x.test?body=evil'], subject: 'Hi\r\nBcc: c@x.test', body: 'x'.repeat(3000)});
40
+ assert.ok(href.startsWith('mailto:A@x.test?subject=Hi%20Bcc%3A%20c%40x.test&body='), href);
41
+ assert.equal(decodeURIComponent(href.split('body=')[1]).length, 2000);
42
+ });
43
+
44
+ test('parseMailto ignores the query when the address part is not an address', () => {
45
+ // An address stored as "me@x.com?body=..." and encoded into a link.
46
+ assert.deepEqual(parseMailto(`mailto:${encodeURIComponent('me@x.test?body=Pay now')}`), {to: [], cc: [], bcc: [], subject: '', body: ''});
47
+ assert.deepEqual(parseMailto('mailto:me@x.test%0D%0Abcc:z@x.test?subject=Hi&bcc=y@x.test'), {to: [], cc: [], bcc: [], subject: '', body: ''});
48
+ assert.deepEqual(parseMailto('mailto:?subject=Join&body=link').subject, 'Join');
49
+ });
50
+
51
+ test('emailTo on an old core: a mailto over 1800 characters is not opened - the addresses are copied', async () => {
52
+ const saved = {location: globalThis.location, E: globalThis.E, nav: Object.getOwnPropertyDescriptor(globalThis, 'navigator')};
53
+ let copied = '';
54
+ const toasts = [];
55
+ globalThis.location = {href: '', hash: ''};
56
+ globalThis.E = {toast: (m) => toasts.push(m)};
57
+ Object.defineProperty(globalThis, 'navigator', {value: {clipboard: {writeText: async (t) => { copied = t; }}}, configurable: true});
58
+ try {
59
+ const bcc = Array.from({length: 120}, (_, i) => `person${i}@example.test`);
60
+ assert.equal(await emailTo({bcc, subject: 'News'}), 'copied');
61
+ assert.equal(globalThis.location.href, '');
62
+ assert.equal(copied, bcc.join(', '));
63
+ assert.match(toasts[0], /120 addresses are copied.*Not carried over: the subject/);
64
+ } finally {
65
+ globalThis.location = saved.location;
66
+ globalThis.E = saved.E;
67
+ if (saved.nav) Object.defineProperty(globalThis, 'navigator', saved.nav); else delete globalThis.navigator;
68
+ }
69
+ });
@@ -6,4 +6,4 @@ export class CanvasManager{constructor(e={}){this.canvasId=e.canvasId||"celebrat
6
6
  height: 100vh;
7
7
  pointer-events: none;
8
8
  z-index: ${this.zIndex};
9
- `,this.ctx=this.canvas.getContext("2d",{alpha:!0}),this.resize(),document.body.appendChild(this.canvas),window.addEventListener("resize",this._handleResize))}resize(){this.canvas&&(this.canvas.width=window.innerWidth,this.canvas.height=window.innerHeight)}clear(){this.ctx&&this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height)}getDimensions(){return{width:this.canvas?.width||0,height:this.canvas?.height||0}}isMobile(){return window.innerWidth<768}destroy(){window.removeEventListener("resize",this._handleResize),this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.canvas=null,this.ctx=null}_handleResize(){this.resizeTimeout&&clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{this.resize(),this.resizeCallback&&this.resizeCallback()},250)}}
9
+ `,this.ctx=this.canvas.getContext("2d",{alpha:!0}),this.resize(),document.body.appendChild(this.canvas),window.addEventListener("resize",this._handleResize))}resize(){this.canvas&&(this.canvas.width=window.innerWidth,this.canvas.height=window.innerHeight)}clear(){this.ctx&&this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height)}getDimensions(){return{width:this.canvas?.width||0,height:this.canvas?.height||0}}isMobile(){return window.innerWidth<768}destroy(){this.resizeTimeout&&clearTimeout(this.resizeTimeout),this.resizeTimeout=null,window.removeEventListener("resize",this._handleResize),this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.canvas=null,this.ctx=null}_handleResize(){this.resizeTimeout&&clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{this.resize(),this.resizeCallback&&this.resizeCallback()},250)}}
@@ -1 +1 @@
1
- var w=Object.defineProperty;var b=(u,e,i)=>e in u?w(u,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):u[e]=i;var v=(u,e,i)=>b(u,typeof e!="symbol"?e+"":e,i);export{mountCharacter,getCharacters,CHARACTER_SIZES}from"./characters.js";import{resolveCelebrationTraits as M}from"./trait-data.mjs";import{CanvasManager as P}from"./core/canvas.js";import{PhysicsEngine as C,updateMovingParticle as z,updateParticlePhysics as j}from"./core/physics.js";import{createParticle as F}from"./core/particles.js";const c=class c{static isDateInRange(e,i,s,o){const l=new Date,n=l.getMonth()+1,d=l.getDate();return s<e?n===e&&d>=i||n>e||n<e&&n<=s||n===s&&d<=o:(n>e||n===e&&d>=i)&&(n<s||n===s&&d<=o)}static getCurrentTheme(){for(const[e,i]of Object.entries(c.themes)){const[[s,o],[l,n]]=i.dates;if(c.isDateInRange(s,o,l,n))return e}return null}static isCelebrationSeason(){return c.getCurrentTheme()!==null}static getThemes(){return c.themes}constructor(e={}){this.options={theme:e.theme||"auto",intensity:e.intensity||"medium",enabled:e.enabled!==void 0?e.enabled:!0,zIndex:e.zIndex||999,overrides:e.overrides||{}},this.canvasManager=null,this.physicsEngine=null,this.themeModule=null,this.currentTheme=null,this.particles=[],this.specialParticles=[],this.animationFrame=null,this.lastTime=0,this.running=!1,this.initialized=!1}async init(){if(this.initialized){console.warn("[Celebrations] Already initialized");return}console.log("[Celebrations] Initializing...");let e=this.options.theme;if(e==="auto"&&(e=c.getCurrentTheme(),!e)){console.log("[Celebrations] No active celebration detected");return}if(!c.themes[e]){console.error(`[Celebrations] Unknown theme: ${e}`);return}this.currentTheme=e,console.log(`[Celebrations] Loading theme: ${e}`);try{const s=await import(c.themes[e].module);this.themeModule=s.default,console.log(`[Celebrations] Theme loaded: ${this.themeModule.displayName}`)}catch(i){console.error(`[Celebrations] Failed to load theme module: ${i.message}`);return}this.canvasManager=new P({canvasId:"celebrations-canvas",zIndex:this.options.zIndex}),this.canvasManager.create(),this.physicsEngine=new C({gustInterval:[5e3,15e3],gustStrength:[-2,2]}),window.addEventListener("resize",()=>{this.canvasManager.resize(),this.resetParticles()}),this.resetParticles(),this.initialized=!0,console.log("[Celebrations] Initialized successfully"),this.options.enabled&&this.start()}isParticleEnabled(e){return!this.disabledTypes?.has(e.type)}resetParticles(){const e=Object.assign({},this.themeModule.intensityConfig[this.options.intensity]),i=a=>String(a).toLowerCase().replace(/[^a-z0-9]/g,""),s=[...Object.keys(e),...this.themeModule.decorationKeys||[]],o=a=>s.find(r=>i(r)===i(a))||a,l=a=>["true","1","yes","on"].includes(String(a).toLowerCase()),n=this.themeModule.optInDecorations||{},d=Object.entries(this.options.overrides).some(([a,r])=>["snowonly","fallingonly"].includes(i(a))&&l(r));for(const a of Object.values(n))e[a.chance]=0;for(const[a,r]of Object.entries(this.options.overrides)){if((i(a)==="snowonly"||i(a)==="fallingonly")&&l(r)){for(const m of this.themeModule.decorationKeys||[])e[m]=0;continue}const p=Object.keys(n).find(m=>i(m)===i(a));if(p&&!d&&l(r)){const m=n[p];e[m.chance]=m.value}r==="off"&&(e[o(a)]=0)}const t=M(this.themeModule.name,this.options.overrides);Object.assign(e,t.config),this.disabledTypes=t.disabledTypes,this.disabledGlobals=t.disabledGlobals,this.config=e;const f=this.canvasManager.canvas.width,h=this.canvasManager.canvas.height;this.particles=[],this.specialParticles=[];const g=e.initialParticleRatio!==void 0?e.initialParticleRatio:1,y=Math.floor(e.count*g);if(this.themeModule.createFallingParticle)for(let a=0;a<y;a++){const r=this.themeModule.createFallingParticle(f,h,e);r.y=Math.random()*h,this.isParticleEnabled(r)&&this.particles.push(r)}else for(let a=0;a<y;a++){const r=F(e,f,h);r.y=Math.random()*h,this.isParticleEnabled(r)&&this.particles.push(r)}if(this.themeModule.createInitialDecorations){const a=this.themeModule.createInitialDecorations(f,h,e);this.specialParticles.push(...a.filter(r=>this.isParticleEnabled(r))),console.log(`[Celebrations] Created ${a.length} decorations`)}console.log(`[Celebrations] Created ${y}/${e.count} particles (${this.options.intensity}, ${Math.round(g*100)}% initial)`)}start(){if(!this.initialized){console.warn("[Celebrations] Cannot start - not initialized");return}if(this.running){console.warn("[Celebrations] Already running");return}console.log("[Celebrations] Starting animation"),this.running=!0,this.lastTime=performance.now(),this.animate()}pause(){this.running&&(console.log("[Celebrations] Pausing animation"),this.running=!1,this.animationFrame&&(cancelAnimationFrame(this.animationFrame),this.animationFrame=null))}resume(){this.running||this.start()}destroy(){console.log("[Celebrations] Destroying effect"),this.pause(),this.canvasManager&&this.canvasManager.canvas&&this.canvasManager.canvas.remove(),this.particles=[],this.specialParticles=[],this.canvasManager=null,this.physicsEngine=null,this.themeModule=null,this.initialized=!1}setIntensity(e){if(!["light","medium","heavy"].includes(e)){console.error(`[Celebrations] Invalid intensity: ${e}`);return}console.log(`[Celebrations] Changing intensity to: ${e}`),this.options.intensity=e,this.resetParticles()}async setTheme(e){console.log(`[Celebrations] Changing theme to: ${e}`);const i=this.running;this.pause(),await new Promise(s=>setTimeout(s,20)),this.initialized=!1,this.canvasManager&&this.canvasManager.clear(),this.particles=[],this.specialParticles=[],this.canvasManager&&this.canvasManager.clear(),this.options.theme=e,await this.init(),i&&this.start()}animate(){if(!this.running)return;const e=performance.now(),i=e-this.lastTime;this.lastTime=e,this.canvasManager.clear();const s=this.canvasManager.ctx,o=this.canvasManager.canvas.width,l=this.canvasManager.canvas.height,n=this.config;this.physicsEngine.updateWind(e);const d=this.physicsEngine.getWindForce();if(this.particles.length<n.count&&Math.random()<.05&&this.themeModule.createFallingParticle){const t=this.themeModule.createFallingParticle(o,l,n);(t.y===void 0||t.y<0)&&(t.y=-20),this.isParticleEnabled(t)&&this.particles.push(t)}if(this.particles.forEach((t,f)=>{if(j(t,i,d),t.y>l+50&&(t.y=-20,t.x=Math.random()*o),t.x<-50&&(t.x=o+50),t.x>o+50&&(t.x=-50),this.themeModule.drawSnowflake&&t.type==="snowflake")this.themeModule.drawSnowflake(s,t);else if(this.themeModule["draw"+this.capitalizeFirst(t.type)]){const h="draw"+this.capitalizeFirst(t.type);this.themeModule[h](s,t,e)}else s.save(),s.globalAlpha=t.opacity,s.fillStyle=this.themeModule.colors?.primary||"#ffffff",s.beginPath(),s.arc(t.x,t.y,t.size,0,Math.PI*2),s.fill(),s.restore()}),this.themeModule.updateSpecialParticles&&this.themeModule.updateSpecialParticles(this.specialParticles,i,o,l),this.specialParticles=this.specialParticles.filter(t=>{if(!t.active||!this.isParticleEnabled(t))return!1;if(!t.static){z(t,i,e);const g=t.type==="train"?600:200;if(t.x<-g||t.x>o+g)return t.active=!1,!1}if(!isFinite(t.x)||!isFinite(t.y)||t.size&&!isFinite(t.size))return console.warn("[Celebrations] Invalid particle values, removing:",t.type),t.active=!1,!1;const h="draw"+this.capitalizeFirst(t.type);return this.themeModule[h]&&this.themeModule[h](s,t,e),!0}),this.themeModule.spawnSpecialParticle){const t=this.themeModule.spawnSpecialParticle(this.specialParticles,o,l,n);t&&this.isParticleEnabled(t)&&this.specialParticles.push(t)}this.themeModule.drawGlobalEffects&&!this.disabledGlobals?.has("lightning")&&this.themeModule.drawGlobalEffects(s,e,o,l),this.animationFrame=requestAnimationFrame(()=>this.animate())}capitalizeFirst(e){if(!e)return"";const i=e.replace(/-([a-z])/g,(s,o)=>o.toUpperCase());return i.charAt(0).toUpperCase()+i.slice(1)}};v(c,"themes",{christmas:{module:"./themes/christmas.js?v=20261003-characters",dates:[[12,1],[1,1]],displayName:"Christmas",emoji:"\u{1F384}"},halloween:{module:"./themes/halloween.js?v=20261003-characters",dates:[[10,26],[10,31]],displayName:"Halloween",emoji:"\u{1F383}"},valentines:{module:"./themes/valentines.js?v=20261003-characters",dates:[[2,9],[2,14]],displayName:"Valentine's Day",emoji:"\u{1F495}"},"guy-fawkes":{module:"./themes/guy-fawkes.js?v=20261003-characters",dates:[[11,1],[11,5]],displayName:"Guy Fawkes Night",emoji:"\u{1F386}"},"st-patricks":{module:"./themes/st-patricks.js?v=20261003-characters",dates:[[3,12],[3,17]],displayName:"St Patrick's Day",emoji:"\u2618\uFE0F"},"st-andrews":{module:"./themes/st-andrews.js?v=20261003-characters",dates:[[11,25],[11,30]],displayName:"St Andrew's Day",emoji:"\u{1F3F4}\u{E0067}\u{E0062}\u{E0073}\u{E0063}\u{E0074}\u{E007F}"},"st-davids":{module:"./themes/st-davids.js?v=20261003-characters",dates:[[2,24],[3,1]],displayName:"St David's Day",emoji:"\u{1F3F4}\u{E0067}\u{E0062}\u{E0077}\u{E006C}\u{E0073}\u{E007F}"},"st-georges":{module:"./themes/st-georges.js?v=20261003-characters",dates:[[4,18],[4,23]],displayName:"St George's Day",emoji:"\u{1F3F4}\u{E0067}\u{E0062}\u{E0065}\u{E006E}\u{E0067}\u{E007F}"}});export let CelebrationsEffect=c;export default CelebrationsEffect;
1
+ var M=Object.defineProperty;var b=(d,e,s)=>e in d?M(d,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):d[e]=s;var v=(d,e,s)=>b(d,typeof e!="symbol"?e+"":e,s);export{mountCharacter,getCharacters,CHARACTER_SIZES}from"./characters.js";import{launchMakeItRain as w}from"./themes/rain-control.js";import{isEasterSeason as P,isChineseNewYearSeason as j}from"./themes/calendar.js";import{resolveCelebrationTraits as C}from"./trait-data.mjs";import{CanvasManager as k}from"./core/canvas.js";import{PhysicsEngine as N,updateMovingParticle as S,updateParticlePhysics as I}from"./core/physics.js";import{createParticle as z}from"./core/particles.js";const h=class h{static isDateInRange(e,s,i,n,l=new Date){const o=l.getMonth()+1,c=l.getDate();return i<e?o===e&&c>=s||o>e||o<i||o===i&&c<=n:(o>e||o===e&&c>=s)&&(o<i||o===i&&c<=n)}static getCurrentTheme(e=new Date){for(const[s,i]of Object.entries(h.themes)){if(i.isInSeason){if(i.isInSeason(e))return s;continue}if(!i.dates)continue;const[[n,l],[o,c]]=i.dates;if(h.isDateInRange(n,l,o,c,e))return s}return null}static isCelebrationSeason(){return h.getCurrentTheme()!==null}static getThemes(){return h.themes}constructor(e={}){this.options={theme:e.theme||(e.message?"greeting":"auto"),intensity:e.intensity||"medium",enabled:e.enabled!==void 0?e.enabled:!0,zIndex:e.zIndex||999,overrides:{...e.overrides||{},...typeof e.message=="string"?{message:e.message}:{}}},this.canvasManager=null,this.physicsEngine=null,this.themeModule=null,this.currentTheme=null,this.particles=[],this.specialParticles=[],this.animationFrame=null,this.lastTime=0,this.running=!1,this.initialized=!1}async init(){if(this.initialized){console.warn("[Celebrations] Already initialized");return}console.log("[Celebrations] Initializing...");let e=this.options.theme;if(e==="auto"&&this.options.overrides.message&&(e="greeting"),e==="auto"&&(e=h.getCurrentTheme(),!e)){console.log("[Celebrations] No active celebration detected");return}if(!h.themes[e]){console.error(`[Celebrations] Unknown theme: ${e}`);return}this.currentTheme=e,console.log(`[Celebrations] Loading theme: ${e}`);try{const i=await import(h.themes[e].module);this.themeModule=i.default;const n=this.options.overrides.message||this.themeModule.defaultMessage;if(n){const{prepareSparklerFont:l}=await import("./themes/sparkler-font.js");await l(n)}console.log(`[Celebrations] Theme loaded: ${this.themeModule.displayName}`)}catch(s){console.error(`[Celebrations] Failed to load theme module: ${s.message}`);return}this.canvasManager=new k({canvasId:"celebrations-canvas",zIndex:this.options.zIndex,onResize:()=>{this.initialized&&this.resetParticles()}}),this.canvasManager.create(),this.physicsEngine=new N({gustInterval:[5e3,15e3],gustStrength:[-2,2]}),this.resetParticles(),this.initialized=!0,console.log("[Celebrations] Initialized successfully"),this.options.enabled&&this.start()}isParticleEnabled(e){return!this.disabledTypes?.has(e.type)}resetParticles(){const e=Object.assign({},this.themeModule.intensityConfig[this.options.intensity]);e.sparkler={message:this.options.overrides.message,style:this.options.overrides["sparkler-style"],colour:this.options.overrides["sparkler-colour"]||this.options.overrides["sparkler-color"],greeting:this.options.overrides["sparkler-greeting"],year:this.options.overrides["sparkler-year"]};const s=a=>String(a).toLowerCase().replace(/[^a-z0-9]/g,""),i=[...Object.keys(e),...this.themeModule.decorationKeys||[]],n=a=>i.find(r=>s(r)===s(a))||a,l=a=>["true","1","yes","on"].includes(String(a).toLowerCase()),o=this.themeModule.optInDecorations||{},c=Object.entries(this.options.overrides).some(([a,r])=>["snowonly","fallingonly"].includes(s(a))&&l(r));for(const a of Object.values(o))e[a.chance]=0;for(const[a,r]of Object.entries(this.options.overrides)){if((s(a)==="snowonly"||s(a)==="fallingonly")&&l(r)){for(const u of this.themeModule.decorationKeys||[])e[u]=0;continue}const p=Object.keys(o).find(u=>s(u)===s(a));if(p&&!c&&l(r)){const u=o[p];e[u.chance]=u.value}r==="off"&&(e[n(a)]=0)}const t=C(this.themeModule.name,this.options.overrides);Object.assign(e,t.config),this.disabledTypes=t.disabledTypes,this.disabledGlobals=t.disabledGlobals,this.config=e;const g=this.canvasManager.canvas.width,m=this.canvasManager.canvas.height;this.particles=[],this.specialParticles=[];const f=e.initialParticleRatio!==void 0?e.initialParticleRatio:1,y=Math.floor(e.count*f);if(this.themeModule.createFallingParticle)for(let a=0;a<y;a++){const r=this.themeModule.createFallingParticle(g,m,e);r.y=Math.random()*m,this.isParticleEnabled(r)&&this.particles.push(r)}else for(let a=0;a<y;a++){const r=z(e,g,m);r.y=Math.random()*m,this.isParticleEnabled(r)&&this.particles.push(r)}if(this.themeModule.createInitialDecorations){const a=this.themeModule.createInitialDecorations(g,m,e);this.specialParticles.push(...a.filter(r=>this.isParticleEnabled(r))),console.log(`[Celebrations] Created ${a.length} decorations`)}console.log(`[Celebrations] Created ${y}/${e.count} particles (${this.options.intensity}, ${Math.round(f*100)}% initial)`)}start(){if(!this.initialized){console.warn("[Celebrations] Cannot start - not initialized");return}if(this.running){console.warn("[Celebrations] Already running");return}console.log("[Celebrations] Starting animation"),this.running=!0,this.lastTime=performance.now(),this.animate()}pause(){this.running&&(console.log("[Celebrations] Pausing animation"),this.running=!1,this.animationFrame&&(cancelAnimationFrame(this.animationFrame),this.animationFrame=null))}resume(){this.running||this.start()}destroy(){console.log("[Celebrations] Destroying effect"),this.pause(),this.canvasManager&&this.canvasManager.destroy(),this.particles=[],this.specialParticles=[],this.canvasManager=null,this.physicsEngine=null,this.themeModule=null,this.initialized=!1}setIntensity(e){if(!["light","medium","heavy"].includes(e)){console.error(`[Celebrations] Invalid intensity: ${e}`);return}console.log(`[Celebrations] Changing intensity to: ${e}`),this.options.intensity=e,this.resetParticles()}async setTheme(e){console.log(`[Celebrations] Changing theme to: ${e}`);const s=this.running;this.pause(),await new Promise(i=>setTimeout(i,20)),this.initialized=!1,this.canvasManager&&this.canvasManager.clear(),this.particles=[],this.specialParticles=[],this.canvasManager&&this.canvasManager.clear(),this.options.theme=e,await this.init(),s&&this.start()}animate(){if(!this.running)return;const e=performance.now(),s=e-this.lastTime;this.lastTime=e,this.canvasManager.clear();const i=this.canvasManager.ctx,n=this.canvasManager.canvas.width,l=this.canvasManager.canvas.height,o=this.config;this.physicsEngine.updateWind(e);const c=this.physicsEngine.getWindForce();if(this.particles.length<o.count&&Math.random()<.05&&this.themeModule.createFallingParticle){const t=this.themeModule.createFallingParticle(n,l,o);(t.y===void 0||t.y<0)&&(t.y=-20),this.isParticleEnabled(t)&&this.particles.push(t)}if(this.particles.forEach((t,g)=>{if(I(t,s,c),t.y>l+50&&(t.y=-20,t.x=Math.random()*n),t.x<-50&&(t.x=n+50),t.x>n+50&&(t.x=-50),this.themeModule.drawSnowflake&&t.type==="snowflake")this.themeModule.drawSnowflake(i,t);else if(this.themeModule["draw"+this.capitalizeFirst(t.type)]){const m="draw"+this.capitalizeFirst(t.type);this.themeModule[m](i,t,e)}else i.save(),i.globalAlpha=t.opacity,i.fillStyle=this.themeModule.colors?.primary||"#ffffff",i.beginPath(),i.arc(t.x,t.y,t.size,0,Math.PI*2),i.fill(),i.restore()}),this.themeModule.updateSpecialParticles&&this.themeModule.updateSpecialParticles(this.specialParticles,s,n,l),this.specialParticles=this.specialParticles.filter(t=>{if(!t.active||!this.isParticleEnabled(t))return!1;if(!t.static){S(t,s,e);const f=t.type==="train"?600:200;if(t.x<-f||t.x>n+f)return t.active=!1,!1}if(!isFinite(t.x)||!isFinite(t.y)||t.size&&!isFinite(t.size))return console.warn("[Celebrations] Invalid particle values, removing:",t.type),t.active=!1,!1;const m="draw"+this.capitalizeFirst(t.type);return this.themeModule[m]&&this.themeModule[m](i,t,e),!0}),this.themeModule.spawnSpecialParticle){const t=this.themeModule.spawnSpecialParticle(this.specialParticles,n,l,o);t&&this.isParticleEnabled(t)&&this.specialParticles.push(t)}this.themeModule.drawGlobalEffects&&!this.disabledGlobals?.has("lightning")&&this.themeModule.drawGlobalEffects(i,e,n,l),this.animationFrame=requestAnimationFrame(()=>this.animate())}capitalizeFirst(e){if(!e)return"";const s=e.replace(/-([a-z])/g,(i,n)=>n.toUpperCase());return s.charAt(0).toUpperCase()+s.slice(1)}};v(h,"themes",{"chinese-new-year":{module:"./themes/chinese-new-year.js?v=20261015-occasions",dates:null,isInSeason:j,displayName:"Chinese New Year",emoji:"\u{1F409}"},"new-year":{module:"./themes/new-year.js?v=20261015-occasions",dates:[[12,31],[1,2]],displayName:"New Year",emoji:"\u{1F389}"},easter:{module:"./themes/easter.js?v=20261015-occasions",dates:null,isInSeason:P,displayName:"Easter",emoji:"\u{1F423}"},"summer-garden":{module:"./themes/summer-garden.js?v=20261015-occasions",dates:[[6,1],[8,31]],displayName:"Summer Garden",emoji:"\u{1F33C}"},christmas:{module:"./themes/christmas.js?v=20261015-occasions",dates:[[12,1],[12,30]],displayName:"Christmas",emoji:"\u{1F384}"},halloween:{module:"./themes/halloween.js?v=20261003-characters",dates:[[10,26],[10,31]],displayName:"Halloween",emoji:"\u{1F383}"},valentines:{module:"./themes/valentines.js?v=20261003-characters",dates:[[2,9],[2,14]],displayName:"Valentine's Day",emoji:"\u{1F495}"},"guy-fawkes":{module:"./themes/guy-fawkes.js?v=20261003-characters",dates:[[11,1],[11,5]],displayName:"Guy Fawkes Night",emoji:"\u{1F386}"},"st-patricks":{module:"./themes/st-patricks.js?v=20261003-characters",dates:[[3,12],[3,17]],displayName:"St Patrick's Day",emoji:"\u2618\uFE0F"},"st-andrews":{module:"./themes/st-andrews.js?v=20261003-characters",dates:[[11,25],[11,30]],displayName:"St Andrew's Day",emoji:"\u{1F3F4}\u{E0067}\u{E0062}\u{E0073}\u{E0063}\u{E0074}\u{E007F}"},"st-davids":{module:"./themes/st-davids.js?v=20261003-characters",dates:[[2,24],[3,1]],displayName:"St David's Day",emoji:"\u{1F3F4}\u{E0067}\u{E0062}\u{E0077}\u{E006C}\u{E0073}\u{E007F}"},"st-georges":{module:"./themes/st-georges.js?v=20261003-characters",dates:[[4,18],[4,23]],displayName:"St George's Day",emoji:"\u{1F3F4}\u{E0067}\u{E0062}\u{E0065}\u{E006E}\u{E0067}\u{E007F}"}}),(()=>{h.themes.winter={module:"./themes/winter.js?v=20261015-occasions",dates:[[12,1],[2,28]],displayName:"Winter",emoji:"\u2744\uFE0F"},h.themes["make-it-rain"]={module:"./themes/make-it-rain.js?v=20261015-occasions",dates:null,displayName:"Make it rain",emoji:"\u{1F327}\uFE0F"},h.themes["money-rain"]={module:"./themes/money-rain.js?v=20261015-occasions",dates:null,displayName:"Money Rain",emoji:"\u{1F4B8}"};for(const[e,s,i]of[["graduation","Graduation","\u{1F393}"],["birthday","Birthday","\u{1F382}"],["anniversary","Anniversary","\u{1F48D}"],["greeting","Sparkler greeting","\u2728"]])h.themes[e]={module:`./themes/${e}.js?v=20261015-occasions`,dates:null,displayName:s,emoji:i};h.themes.autumn={module:"./themes/autumn.js?v=20261015-occasions",dates:[[9,1],[11,30]],displayName:"Autumn",emoji:"\u{1F342}"}})();export let CelebrationsEffect=h;export default CelebrationsEffect;export function makeItRain(d={}){return w(CelebrationsEffect,d)}export function moneyRain(d={}){return w(CelebrationsEffect,d,"money-rain")}
@@ -0,0 +1,93 @@
1
+ Copyright 2011 The ABeeZee Project Authors (https://github.com/googlefonts/abeezee), with Reserved Font Name 'ABeeZee'
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ https://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,93 @@
1
+ Copyright 2010 The Allura Project Authors (https://github.com/googlefonts/allura)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ http://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1 @@
1
+ export function encodeMessageAttribute(t){const e={"&":"&amp;",'"':"&quot;","[":"&#91;","]":"&#93;","<":"&lt;",">":"&gt;"};return String(t).replace(/[&"\[\]<>]/g,n=>e[n])}export function decodeMessageAttribute(t){const e={amp:"&",quot:'"',apos:"'",lt:"<",gt:">","#91":"[","#93":"]"};return String(t).replace(/&(amp|quot|apos|lt|gt|#91|#93);/g,(n,o)=>e[o])}
@@ -0,0 +1 @@
1
+ import{createOccasionTheme as e}from"./occasions.js";export default e("anniversary");
@@ -0,0 +1 @@
1
+ const m=["#d98b39","#b9553b","#d8b74b","#a86438","#d77c4a"],t=(e,o,a,r,n={})=>({type:e,x:o,y:a,size:r,vx:0,vy:0,opacity:.95,static:!0,active:!0,phase:Math.random()*Math.PI*2,...n});function i(e,o){return![o.x,o.y,o.size].every(Number.isFinite)||o.size<=0?!1:(e.save(),e.translate(o.x,o.y),e.scale(o.size,o.size),e.globalAlpha*=o.opacity,e.lineCap="round",e.lineJoin="round",!0)}function l(e,o,a,r,n,s){e.beginPath(),e.ellipse(o,a,r,n,0,0,Math.PI*2),e.fillStyle=s,e.fill()}const u={name:"autumn",displayName:"Autumn",emoji:"\u{1F342}",colors:{primary:"#d98b39"},intensityConfig:{light:{count:20,speedRange:[.4,.8],sizeRange:[7,12],trees:2,acorns:3,mushrooms:2},medium:{count:40,speedRange:[.6,1.2],sizeRange:[9,16],trees:3,acorns:5,mushrooms:3},heavy:{count:70,speedRange:[.8,1.6],sizeRange:[12,20],trees:5,acorns:8,mushrooms:5}},particles:["maple-leaf","oak-leaf"],decorations:["autumn-tree","acorn","mushroom"],traits:{mapleLeaf:{label:"Maple leaves",types:["maple-leaf"],kind:"particle"},oakLeaf:{label:"Oak leaves",types:["oak-leaf"],kind:"particle"},tree:{label:"Autumn trees",types:["autumn-tree"],count:"trees"},acorn:{label:"Acorns",types:["acorn"],count:"acorns"},mushroom:{label:"Mushrooms",types:["mushroom"],count:"mushrooms"}},createFallingParticle(e,o,a){return t(Math.random()<.5?"maple-leaf":"oak-leaf",Math.random()*e,-30,a.sizeRange[0]+Math.random()*(a.sizeRange[1]-a.sizeRange[0]),{static:!1,speed:a.speedRange[0]+Math.random()*(a.speedRange[1]-a.speedRange[0]),windOffset:Math.random()*Math.PI*2,windSpeed:.018,rotation:Math.random()*Math.PI*2,rotationSpeed:(Math.random()-.5)*.022,color:m[Math.floor(Math.random()*m.length)]})},createInitialDecorations(e,o,a){const r=[],n=Math.min(1,e/600);for(let s=0;s<a.trees;s++)r.push(t("autumn-tree",(s+.5)*e/a.trees,o-3,(36+Math.random()*12)*n));for(let s=0;s<a.acorns;s++)r.push(t("acorn",(s+.8)*e/(a.acorns+1),o-4,12*n,{rotation:(Math.random()-.5)*.8}));for(let s=0;s<a.mushrooms;s++)r.push(t("mushroom",(s+.3)*e/a.mushrooms,o-2,(13+Math.random()*5)*n));return r},drawMapleLeaf(e,o,a){if(!i(e,o))return;e.rotate(o.rotation),e.scale(.35+Math.abs(Math.sin(a/800+o.phase))*.65,1);const r=[[0,-1],[.2,-.42],[.55,-.68],[.5,-.17],[1,-.22],[.72,.2],[.9,.36],[.15,.65],[0,.95],[-.15,.65],[-.9,.36],[-.72,.2],[-1,-.22],[-.5,-.17],[-.55,-.68],[-.2,-.42]];e.beginPath(),e.moveTo(...r[0]);for(const n of r.slice(1))e.lineTo(...n);e.closePath(),e.fillStyle=o.color,e.fill(),e.strokeStyle="#795334",e.lineWidth=.035,e.beginPath(),e.moveTo(0,1.2),e.lineTo(0,-.8);for(const n of[-1,1])e.moveTo(0,.5),e.lineTo(n*.77,.22),e.moveTo(0,.05),e.lineTo(n*.45,-.46);e.stroke(),e.restore()},drawOakLeaf(e,o,a){if(i(e,o)){e.rotate(o.rotation),e.scale(.4+Math.abs(Math.sin(a/950+o.phase))*.6,1),e.beginPath(),e.moveTo(0,-1.1);for(const r of[1,-1]){const n=r===1?[-.9,-.45,0,.45]:[.45,0,-.45,-.9];for(const s of n)e.quadraticCurveTo(r*.95,s+(r===1?.1:-.1),r*.27,s+(r===1?.35:-.35))}e.closePath(),e.fillStyle=o.color,e.fill(),e.beginPath(),e.moveTo(0,1.25),e.lineTo(0,-.95),e.strokeStyle="#856037",e.lineWidth=.035,e.stroke(),e.restore()}},drawAutumnTree(e,o){if(i(e,o)){e.strokeStyle="#74543b",e.lineWidth=.16,e.beginPath(),e.moveTo(0,0),e.lineTo(0,-1.75);for(const a of[-1,1])e.moveTo(0,-.65),e.lineTo(a*.65,-1.55),e.moveTo(0,-1.2),e.lineTo(a*.4,-2.1);e.stroke();for(const[a,r,n,s]of[[0,-2.1,.75,"#bf793b"],[-.63,-1.6,.65,"#d69442"],[.59,-1.67,.7,"#aa6035"],[0,-1.5,.65,"#d2a044"],[-.1,-2.45,.4,"#dfb457"]])l(e,a,r,n,n*.9,s);e.restore()}},drawAcorn(e,o){if(i(e,o)){e.rotate(o.rotation||0),l(e,0,-.55,.46,.65,"#bb8d54"),l(e,-.13,-.59,.25,.5,"#d4aa70"),l(e,0,-1.02,.56,.28,"#7d6446"),e.beginPath(),e.moveTo(0,-1.2),e.quadraticCurveTo(-.1,-1.5,.12,-1.5),e.strokeStyle="#70543b",e.lineWidth=.11,e.stroke();for(let a=-2;a<=2;a++)e.beginPath(),e.moveTo(a*.16-.08,-1.12),e.lineTo(a*.16+.08,-.95),e.strokeStyle="#a18a60",e.lineWidth=.025,e.stroke();e.restore()}},drawMushroom(e,o){if(i(e,o)){e.fillStyle="#e9d9b9",e.fillRect(-.16,-.95,.32,.95),l(e,0,-.88,.72,.2,"#e2cbaa"),e.beginPath(),e.moveTo(-.75,-.95),e.bezierCurveTo(-.65,-2.1,.65,-2.1,.75,-.95),e.quadraticCurveTo(0,-.78,-.75,-.95),e.fillStyle="#a66a4c",e.fill();for(const[a,r]of[[-.3,-1.3],[.2,-1.53],[.4,-1.18]])l(e,a,r,.1,.055,"#d7b48a");e.restore()}}};export default u;
@@ -0,0 +1 @@
1
+ import{createOccasionTheme as e}from"./occasions.js";export default e("birthday");
@@ -0,0 +1 @@
1
+ export const MEADOW_COLOURS=["#84cc16","#a3e635","#bbf7d0","#bae6fd","#fef08a","#ddd6fe"];const h=()=>MEADOW_COLOURS[Math.floor(Math.random()*MEADOW_COLOURS.length)];export function createGardenButterfly(a,d,e=1){const n=-Math.PI/2+(Math.random()-.5)*1.2;return{type:"garden-butterfly",static:!0,active:!0,x:Math.random()*a,y:d*(.6+Math.random()*.3),vx:0,vy:0,size:(20+Math.random()*12)*e,opacity:.95,heading:n,targetHeading:n,flightSpeed:.6+Math.random()*.8,wanderTimer:Math.random()*60,flapPhase:Math.random()*Math.PI*2,flapSpeed:.18+Math.random()*.12,colourUpper:h(),colourLower:h()}}export function updateGardenButterfly(a,d,e,n){const t=Math.min(100,Math.max(0,d))/16.666666666666668;a.wanderTimer-=t,a.wanderTimer<=0&&(a.targetHeading=-Math.PI/2+(Math.random()-.5)*1.4,a.wanderTimer=30+Math.random()*60);let r=a.targetHeading-a.heading;for(;r>Math.PI;)r-=Math.PI*2;for(;r<-Math.PI;)r+=Math.PI*2;a.heading+=r*(1-.95**t),a.x+=(Math.cos(a.heading)*a.flightSpeed+Math.sin(a.flapPhase)*.3)*t,a.y+=(Math.sin(a.heading)*a.flightSpeed-.4)*t,a.flapPhase+=a.flapSpeed*t,a.x>e+35&&(a.x=-35),a.x<-35&&(a.x=e+35),a.y<-a.size&&(a.y=n+a.size,a.x=Math.random()*e)}
@@ -0,0 +1 @@
1
+ import{CHINESE_NEW_YEAR_DATES as m}from"./chinese-new-year-dates.js";export function easterSunday(t){const e=t%19,n=Math.floor(t/100),o=t%100,a=Math.floor(n/4),c=n%4,r=Math.floor((n+8)/25),l=Math.floor((n-r+1)/3),s=(19*e+n-a-l+15)%30,h=Math.floor(o/4),D=o%4,f=(32+2*c+2*h-s-D)%7,u=Math.floor((e+11*s+22*f)/451),g=Math.floor((s+f-7*u+114)/31),M=(s+f-7*u+114)%31+1;return new Date(t,g-1,M,12)}export function isEasterSeason(t=new Date){const e=easterSunday(t.getFullYear()),n=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()),o=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()),a=(n-o)/864e5;return a>=-5&&a<=1}const i=new Map;export function chineseNewYear(t){const e=m[t];if(e)return new Date(t,e[0]-1,e[1],12);if(!i.has(t)){let o=null;try{const a=new Intl.DateTimeFormat("en-u-ca-chinese",{month:"numeric",day:"numeric",timeZone:"UTC"});if(a.resolvedOptions().calendar==="chinese")for(let c=21;c<=51;c++){const r=new Date(Date.UTC(t,0,c,12)),l=a.formatToParts(r);if(l.find(s=>s.type==="month")?.value==="1"&&l.find(s=>s.type==="day")?.value==="1"){o=[r.getUTCMonth(),r.getUTCDate()];break}}}catch{}i.set(t,o)}const n=i.get(t);return n?new Date(t,n[0],n[1],12):null}export function isChineseNewYearSeason(t=new Date){const e=chineseNewYear(t.getFullYear());if(!e)return!1;const n=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()),o=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate());return n>=o&&n<=o+6*864e5}
@@ -0,0 +1 @@
1
+ export const CHINESE_NEW_YEAR_DATES={2020:[1,25],2021:[2,12],2022:[2,1],2023:[1,22],2024:[2,10],2025:[1,29],2026:[2,17],2027:[2,6],2028:[1,26],2029:[2,13],2030:[2,3],2031:[1,23],2032:[2,11],2033:[1,31],2034:[2,19],2035:[2,8],2036:[1,28],2037:[2,15],2038:[2,4],2039:[1,24],2040:[2,12],2041:[2,1],2042:[1,22],2043:[2,10],2044:[1,30],2045:[2,17],2046:[2,6],2047:[1,26],2048:[2,14],2049:[2,2],2050:[1,23]};