@paroicms/contact-form-plugin 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paroicms/contact-form-plugin",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Contact form plugin for ParoiCMS",
5
5
  "keywords": [
6
6
  "paroicms",
@@ -19,7 +19,9 @@
19
19
  "dev:public": "(cd public-front && vite)",
20
20
  "build": "npm run build:backend && npm run build:public",
21
21
  "build:backend": "(cd backend && tsc)",
22
- "build:public": "(cd public-front && tsc && vite build)",
22
+ "build:public": "(cd public-front && tsc && vite build && npm run minify:public)",
23
+ "minify:public": "terser public-front/dist/public-front-plugin.mjs --output public-front/dist/public-front-plugin.mjs",
24
+ "build:public:watch": "(cd public-front && tsc && vite build --watch)",
23
25
  "clear": "rimraf backend/dist/* public-front/dist/*"
24
26
  },
25
27
  "dependencies": {
@@ -31,16 +33,17 @@
31
33
  },
32
34
  "devDependencies": {
33
35
  "@paroicms/public-anywhere-lib": "0.8.0",
34
- "@paroicms/public-server-lib": "0.14.0",
36
+ "@paroicms/public-server-lib": "0.14.1",
35
37
  "@solid-primitives/i18n": "~2.1.1",
36
38
  "@types/node": "~20.14.8",
37
39
  "rimraf": "~6.0.1",
38
40
  "sass": "~1.77.8",
39
41
  "solid-devtools": "~0.30.1",
40
- "solid-js": "~1.8.20",
42
+ "solid-js": "1.8.20",
41
43
  "typescript": "~5.5.4",
42
44
  "vite": "~5.4.0",
43
- "vite-plugin-solid": "~2.10.2"
45
+ "vite-plugin-solid": "~2.10.2",
46
+ "terser": "~5.34.1"
44
47
  },
45
48
  "main": "backend/dist/plugin.js",
46
49
  "files": [
@@ -1,560 +1 @@
1
- const Te = (e, t) => e === t, H = {
2
- equals: Te
3
- };
4
- let be = Ce;
5
- const E = 1, B = 2, we = {
6
- owned: null,
7
- cleanups: null,
8
- context: null,
9
- owner: null
10
- };
11
- var u = null;
12
- let z = null, Le = null, a = null, d = null, v = null, k = 0;
13
- function Ne(e, t) {
14
- const s = a, n = u, l = e.length === 0, r = t === void 0 ? n : t, i = l ? we : {
15
- owned: null,
16
- cleanups: null,
17
- context: r ? r.context : null,
18
- owner: r
19
- }, o = l ? e : () => e(() => A(() => V(i)));
20
- u = i, a = null;
21
- try {
22
- return T(o, !0);
23
- } finally {
24
- a = s, u = n;
25
- }
26
- }
27
- function y(e, t) {
28
- t = t ? Object.assign({}, H, t) : H;
29
- const s = {
30
- value: e,
31
- observers: null,
32
- observerSlots: null,
33
- comparator: t.equals || void 0
34
- }, n = (l) => (typeof l == "function" && (l = l(s.value)), ve(s, l));
35
- return [ye.bind(s), n];
36
- }
37
- function S(e, t, s) {
38
- const n = ne(e, t, !1, E);
39
- _(n);
40
- }
41
- function Oe(e, t, s) {
42
- be = qe;
43
- const n = ne(e, t, !1, E);
44
- n.user = !0, v ? v.push(n) : _(n);
45
- }
46
- function ee(e, t, s) {
47
- s = s ? Object.assign({}, H, s) : H;
48
- const n = ne(e, t, !0, 0);
49
- return n.observers = null, n.observerSlots = null, n.comparator = s.equals || void 0, _(n), ye.bind(n);
50
- }
51
- function A(e) {
52
- if (a === null) return e();
53
- const t = a;
54
- a = null;
55
- try {
56
- return e();
57
- } finally {
58
- a = t;
59
- }
60
- }
61
- function Ue(e) {
62
- Oe(() => A(e));
63
- }
64
- function He(e) {
65
- return u === null || (u.cleanups === null ? u.cleanups = [e] : u.cleanups.push(e)), e;
66
- }
67
- function ye() {
68
- if (this.sources && this.state)
69
- if (this.state === E) _(this);
70
- else {
71
- const e = d;
72
- d = null, T(() => q(this), !1), d = e;
73
- }
74
- if (a) {
75
- const e = this.observers ? this.observers.length : 0;
76
- a.sources ? (a.sources.push(this), a.sourceSlots.push(e)) : (a.sources = [this], a.sourceSlots = [e]), this.observers ? (this.observers.push(a), this.observerSlots.push(a.sources.length - 1)) : (this.observers = [a], this.observerSlots = [a.sources.length - 1]);
77
- }
78
- return this.value;
79
- }
80
- function ve(e, t, s) {
81
- let n = e.value;
82
- return (!e.comparator || !e.comparator(n, t)) && (e.value = t, e.observers && e.observers.length && T(() => {
83
- for (let l = 0; l < e.observers.length; l += 1) {
84
- const r = e.observers[l], i = z && z.running;
85
- i && z.disposed.has(r), (i ? !r.tState : !r.state) && (r.pure ? d.push(r) : v.push(r), r.observers && Se(r)), i || (r.state = E);
86
- }
87
- if (d.length > 1e6)
88
- throw d = [], new Error();
89
- }, !1)), t;
90
- }
91
- function _(e) {
92
- if (!e.fn) return;
93
- V(e);
94
- const t = k;
95
- Be(e, e.value, t);
96
- }
97
- function Be(e, t, s) {
98
- let n;
99
- const l = u, r = a;
100
- a = u = e;
101
- try {
102
- n = e.fn(t);
103
- } catch (i) {
104
- return e.pure && (e.state = E, e.owned && e.owned.forEach(V), e.owned = null), e.updatedAt = s + 1, Ee(i);
105
- } finally {
106
- a = r, u = l;
107
- }
108
- (!e.updatedAt || e.updatedAt <= s) && (e.updatedAt != null && "observers" in e ? ve(e, n) : e.value = n, e.updatedAt = s);
109
- }
110
- function ne(e, t, s, n = E, l) {
111
- const r = {
112
- fn: e,
113
- state: n,
114
- updatedAt: null,
115
- owned: null,
116
- sources: null,
117
- sourceSlots: null,
118
- cleanups: null,
119
- value: t,
120
- owner: u,
121
- context: u ? u.context : null,
122
- pure: s
123
- };
124
- return u === null || u !== we && (u.owned ? u.owned.push(r) : u.owned = [r]), r;
125
- }
126
- function I(e) {
127
- if (e.state === 0) return;
128
- if (e.state === B) return q(e);
129
- if (e.suspense && A(e.suspense.inFallback)) return e.suspense.effects.push(e);
130
- const t = [e];
131
- for (; (e = e.owner) && (!e.updatedAt || e.updatedAt < k); )
132
- e.state && t.push(e);
133
- for (let s = t.length - 1; s >= 0; s--)
134
- if (e = t[s], e.state === E)
135
- _(e);
136
- else if (e.state === B) {
137
- const n = d;
138
- d = null, T(() => q(e, t[0]), !1), d = n;
139
- }
140
- }
141
- function T(e, t) {
142
- if (d) return e();
143
- let s = !1;
144
- t || (d = []), v ? s = !0 : v = [], k++;
145
- try {
146
- const n = e();
147
- return Ie(s), n;
148
- } catch (n) {
149
- s || (v = null), d = null, Ee(n);
150
- }
151
- }
152
- function Ie(e) {
153
- if (d && (Ce(d), d = null), e) return;
154
- const t = v;
155
- v = null, t.length && T(() => be(t), !1);
156
- }
157
- function Ce(e) {
158
- for (let t = 0; t < e.length; t++) I(e[t]);
159
- }
160
- function qe(e) {
161
- let t, s = 0;
162
- for (t = 0; t < e.length; t++) {
163
- const n = e[t];
164
- n.user ? e[s++] = n : I(n);
165
- }
166
- for (t = 0; t < s; t++) I(e[t]);
167
- }
168
- function q(e, t) {
169
- e.state = 0;
170
- for (let s = 0; s < e.sources.length; s += 1) {
171
- const n = e.sources[s];
172
- if (n.sources) {
173
- const l = n.state;
174
- l === E ? n !== t && (!n.updatedAt || n.updatedAt < k) && I(n) : l === B && q(n, t);
175
- }
176
- }
177
- }
178
- function Se(e) {
179
- for (let t = 0; t < e.observers.length; t += 1) {
180
- const s = e.observers[t];
181
- s.state || (s.state = B, s.pure ? d.push(s) : v.push(s), s.observers && Se(s));
182
- }
183
- }
184
- function V(e) {
185
- let t;
186
- if (e.sources)
187
- for (; e.sources.length; ) {
188
- const s = e.sources.pop(), n = e.sourceSlots.pop(), l = s.observers;
189
- if (l && l.length) {
190
- const r = l.pop(), i = s.observerSlots.pop();
191
- n < l.length && (r.sourceSlots[i] = n, l[n] = r, s.observerSlots[n] = i);
192
- }
193
- }
194
- if (e.owned) {
195
- for (t = e.owned.length - 1; t >= 0; t--) V(e.owned[t]);
196
- e.owned = null;
197
- }
198
- if (e.cleanups) {
199
- for (t = e.cleanups.length - 1; t >= 0; t--) e.cleanups[t]();
200
- e.cleanups = null;
201
- }
202
- e.state = 0;
203
- }
204
- function De(e) {
205
- return e instanceof Error ? e : new Error(typeof e == "string" ? e : "Unknown error", {
206
- cause: e
207
- });
208
- }
209
- function Ee(e, t = u) {
210
- throw De(e);
211
- }
212
- let ke = !1;
213
- function te(e, t) {
214
- return A(() => e(t || {}));
215
- }
216
- const Ve = (e) => `Stale read from <${e}>.`;
217
- function pe(e) {
218
- const t = e.keyed, s = ee(() => e.when, void 0, {
219
- equals: (n, l) => t ? n === l : !n == !l
220
- });
221
- return ee(() => {
222
- const n = s();
223
- if (n) {
224
- const l = e.children;
225
- return typeof l == "function" && l.length > 0 ? A(() => l(t ? n : () => {
226
- if (!A(s)) throw Ve("Show");
227
- return e.when;
228
- })) : l;
229
- }
230
- return e.fallback;
231
- }, void 0, void 0);
232
- }
233
- function Ge(e, t, s) {
234
- let n = s.length, l = t.length, r = n, i = 0, o = 0, f = t[l - 1].nextSibling, p = null;
235
- for (; i < l || o < r; ) {
236
- if (t[i] === s[o]) {
237
- i++, o++;
238
- continue;
239
- }
240
- for (; t[l - 1] === s[r - 1]; )
241
- l--, r--;
242
- if (l === i) {
243
- const h = r < n ? o ? s[o - 1].nextSibling : s[r - o] : f;
244
- for (; o < r; ) e.insertBefore(s[o++], h);
245
- } else if (r === o)
246
- for (; i < l; )
247
- (!p || !p.has(t[i])) && t[i].remove(), i++;
248
- else if (t[i] === s[r - 1] && s[o] === t[l - 1]) {
249
- const h = t[--l].nextSibling;
250
- e.insertBefore(s[o++], t[i++].nextSibling), e.insertBefore(s[--r], h), t[l] = s[r];
251
- } else {
252
- if (!p) {
253
- p = /* @__PURE__ */ new Map();
254
- let w = o;
255
- for (; w < r; ) p.set(s[w], w++);
256
- }
257
- const h = p.get(t[i]);
258
- if (h != null)
259
- if (o < h && h < r) {
260
- let w = i, j = 1, M;
261
- for (; ++w < l && w < r && !((M = p.get(t[w])) == null || M !== h + j); )
262
- j++;
263
- if (j > h - o) {
264
- const L = t[i];
265
- for (; o < h; ) e.insertBefore(s[o++], L);
266
- } else e.replaceChild(s[o++], t[i++]);
267
- } else i++;
268
- else t[i++].remove();
269
- }
270
- }
271
- }
272
- function Ye(e, t, s, n = {}) {
273
- let l;
274
- return Ne((r) => {
275
- l = r, t === document ? e() : g(t, e(), t.firstChild ? null : void 0, s);
276
- }, n.owner), () => {
277
- l(), t.textContent = "";
278
- };
279
- }
280
- function G(e, t, s) {
281
- let n;
282
- const l = () => {
283
- const i = document.createElement("template");
284
- return i.innerHTML = e, i.content.firstChild;
285
- }, r = () => (n || (n = l())).cloneNode(!0);
286
- return r.cloneNode = r, r;
287
- }
288
- function F(e, t, s) {
289
- s == null ? e.removeAttribute(t) : e.setAttribute(t, s);
290
- }
291
- function g(e, t, s, n) {
292
- if (s !== void 0 && !n && (n = []), typeof t != "function") return D(e, t, n, s);
293
- S((l) => D(e, t(), l, s), n);
294
- }
295
- function D(e, t, s, n, l) {
296
- for (; typeof s == "function"; ) s = s();
297
- if (t === s) return s;
298
- const r = typeof t, i = n !== void 0;
299
- if (e = i && s[0] && s[0].parentNode || e, r === "string" || r === "number") {
300
- if (r === "number" && (t = t.toString(), t === s))
301
- return s;
302
- if (i) {
303
- let o = s[0];
304
- o && o.nodeType === 3 ? o.data !== t && (o.data = t) : o = document.createTextNode(t), s = $(e, s, n, o);
305
- } else
306
- s !== "" && typeof s == "string" ? s = e.firstChild.data = t : s = e.textContent = t;
307
- } else if (t == null || r === "boolean")
308
- s = $(e, s, n);
309
- else {
310
- if (r === "function")
311
- return S(() => {
312
- let o = t();
313
- for (; typeof o == "function"; ) o = o();
314
- s = D(e, o, s, n);
315
- }), () => s;
316
- if (Array.isArray(t)) {
317
- const o = [], f = s && Array.isArray(s);
318
- if (se(o, t, s, l))
319
- return S(() => s = D(e, o, s, n, !0)), () => s;
320
- if (o.length === 0) {
321
- if (s = $(e, s, n), i) return s;
322
- } else f ? s.length === 0 ? me(e, o, n) : Ge(e, s, o) : (s && $(e), me(e, o));
323
- s = o;
324
- } else if (t.nodeType) {
325
- if (Array.isArray(s)) {
326
- if (i) return s = $(e, s, n, t);
327
- $(e, s, null, t);
328
- } else s == null || s === "" || !e.firstChild ? e.appendChild(t) : e.replaceChild(t, e.firstChild);
329
- s = t;
330
- }
331
- }
332
- return s;
333
- }
334
- function se(e, t, s, n) {
335
- let l = !1;
336
- for (let r = 0, i = t.length; r < i; r++) {
337
- let o = t[r], f = s && s[e.length], p;
338
- if (!(o == null || o === !0 || o === !1)) if ((p = typeof o) == "object" && o.nodeType)
339
- e.push(o);
340
- else if (Array.isArray(o))
341
- l = se(e, o, f) || l;
342
- else if (p === "function")
343
- if (n) {
344
- for (; typeof o == "function"; ) o = o();
345
- l = se(e, Array.isArray(o) ? o : [o], Array.isArray(f) ? f : [f]) || l;
346
- } else
347
- e.push(o), l = !0;
348
- else {
349
- const h = String(o);
350
- f && f.nodeType === 3 && f.data === h ? e.push(f) : e.push(document.createTextNode(h));
351
- }
352
- }
353
- return l;
354
- }
355
- function me(e, t, s = null) {
356
- for (let n = 0, l = t.length; n < l; n++) e.insertBefore(t[n], s);
357
- }
358
- function $(e, t, s, n) {
359
- if (s === void 0) return e.textContent = "";
360
- const l = n || document.createTextNode("");
361
- if (t.length) {
362
- let r = !1;
363
- for (let i = t.length - 1; i >= 0; i--) {
364
- const o = t[i];
365
- if (l !== o) {
366
- const f = o.parentNode === e;
367
- !r && !i ? f ? e.replaceChild(l, o) : e.insertBefore(l, s) : f && o.remove();
368
- } else r = !0;
369
- }
370
- } else e.insertBefore(l, s);
371
- return [l];
372
- }
373
- function Je(e) {
374
- return e.varName ? ` for '${e.varName}'` : "";
375
- }
376
- function Qe(e, t = {}) {
377
- if (e == null || e === "" && !t.allowEmpty)
378
- throw new Error(`Missing string value${Je(t)}`);
379
- return typeof e == "string" ? e : e.toString();
380
- }
381
- var xe = (e) => e != null && (e = Object.getPrototypeOf(e), e === Array.prototype || e === Object.prototype);
382
- function Fe(e, t, s) {
383
- for (const [n, l] of Object.entries(t)) {
384
- const r = `${s}.${n}`;
385
- e[r] = l, xe(l) && Fe(e, l, r);
386
- }
387
- }
388
- function We(e) {
389
- const t = { ...e };
390
- for (const [s, n] of Object.entries(e))
391
- xe(n) && Fe(t, n, s);
392
- return t;
393
- }
394
- var Xe = (e, t) => {
395
- if (t)
396
- for (const [s, n] of Object.entries(t))
397
- e = e.replace(new RegExp(`{{\\s*${s}\\s*}}`, "g"), n);
398
- return e;
399
- }, Ze = (e) => e;
400
- function Ke(e, t = Ze) {
401
- return (s, ...n) => {
402
- s[0] === "." && (s = s.slice(1));
403
- const l = e()?.[s];
404
- switch (typeof l) {
405
- case "function":
406
- return l(...n);
407
- case "string":
408
- return t(l, n[0]);
409
- default:
410
- return l;
411
- }
412
- };
413
- }
414
- const ze = "Name", et = "Email", tt = "Subject", st = "Message", nt = "Send", lt = "The e-mail address on which we can reply to you", ot = "Your name", rt = "The subject of your message", it = "Enter your message here...", ct = "Unexpected error, the message could not be sent.", at = "Return Home", ut = "Your message has been sent. If there is a response, it will be sent to the address", ft = {
415
- name: ze,
416
- email: et,
417
- subject: tt,
418
- message: st,
419
- send: nt,
420
- emailPlaceholder: lt,
421
- namePlaceholder: ot,
422
- subjectPlaceholder: rt,
423
- messagePlaceholder: it,
424
- unexpectedErrorMessage: ct,
425
- returnHome: at,
426
- successMessage: ut
427
- }, dt = "Nom", ht = "E-mail", pt = "Sujet", mt = "Message", gt = "Envoyer", bt = "L'adresse e-mail sur laquelle nous pourrons vous répondre", wt = "Votre nom", yt = "Le sujet de votre message", vt = "Saisissez votre message", Ct = "Erreur inattendue, le message n'a pas pu être envoyé.", St = "Retourner à l'accueil", Et = "Votre message a été envoyé. S'il y a une réponse, elle sera envoyée à l'adresse", xt = {
428
- name: dt,
429
- email: ht,
430
- subject: pt,
431
- message: mt,
432
- send: gt,
433
- emailPlaceholder: bt,
434
- namePlaceholder: wt,
435
- subjectPlaceholder: yt,
436
- messagePlaceholder: vt,
437
- unexpectedErrorMessage: Ct,
438
- returnHome: St,
439
- successMessage: Et
440
- }, ge = { en: ft, fr: xt };
441
- function Ft(e) {
442
- const t = ee(() => {
443
- const n = e in ge ? e : "en";
444
- return We(ge[n]);
445
- });
446
- return { t: Ke(t, Xe) };
447
- }
448
- async function $t(e, t, s) {
449
- s(!0);
450
- try {
451
- const n = await At(e);
452
- return t.reset(), n;
453
- } finally {
454
- s(!1);
455
- }
456
- }
457
- async function At(e) {
458
- const t = await fetch("/api/plugin/contact-form", {
459
- headers: {
460
- "Content-Type": "application/json"
461
- },
462
- body: JSON.stringify(e),
463
- method: "POST"
464
- });
465
- if (t.status !== 200) {
466
- const n = await t.text();
467
- throw new Error(`Unexpected error: ${n}`);
468
- }
469
- return await t.json();
470
- }
471
- var jt = /* @__PURE__ */ G("<div class=ContactForm-error>"), Mt = /* @__PURE__ */ G('<div class="ContactForm-done ContactForm-ended"><div class=ContactForm-endedMessage><p></p><p></p></div><div class=ContactForm-endedActions><a class=BigBtn>'), Pt = /* @__PURE__ */ G("<form class=ContactForm><div class=ContactForm-fieldGroup><label class=ContactFormField><span class=ContactFormField-label></span><input class=ContactFormField-input type=email name=email required></label><label class=ContactFormField><span class=ContactFormField-label></span><input class=ContactFormField-input type=text name=name required></label><label class=ContactFormField><span class=ContactFormField-label></span><input class=ContactFormField-input type=text name=subject></label><label class=ContactFormField><span class=ContactFormField-label></span><textarea class=ContactFormField-textarea rows=5 name=message required></textarea></label></div><div class=ContactForm-action><button type=submit class=ContactForm-btn>"), Rt = /* @__PURE__ */ G("<div class=ContactForm-captcha><div class=g-recaptcha data-callback=onRecaptchaSubmitted data-expired-callback=onRecaptchaExpired>");
472
- function _t({
473
- recaptchaKey: e,
474
- language: t,
475
- homeUrl: s
476
- }) {
477
- const [n, l] = y(""), [r, i] = y(""), [o, f] = y(), [p, h] = y(""), [w, j] = y(), [M, L] = y(!e), [le, Y] = y(), [$e, oe] = y(""), [Ae, je] = y(!1), {
478
- t: m
479
- } = Ft(t), Me = async (b) => {
480
- try {
481
- if (b.preventDefault(), !M() || !N) throw new Error("Erreur de recaptcha");
482
- const C = await $t({
483
- language: t,
484
- name: n(),
485
- subject: o(),
486
- message: p(),
487
- email: r(),
488
- gRecaptchaResponse: w()
489
- }, N, je);
490
- C.success ? Y(!0) : (Y(!1), oe(C.message ?? m("unexpectedErrorMessage")));
491
- } catch {
492
- Y(!1), oe(m("unexpectedErrorMessage"));
493
- }
494
- }, N = (() => {
495
- var b = Pt(), C = b.firstChild, re = C.firstChild, ie = re.firstChild, J = ie.nextSibling, ce = re.nextSibling, ae = ce.firstChild, Q = ae.nextSibling, ue = ce.nextSibling, fe = ue.firstChild, W = fe.nextSibling, _e = ue.nextSibling, de = _e.firstChild, X = de.nextSibling, Z = C.nextSibling, K = Z.firstChild;
496
- return b.addEventListener("submit", Me), g(ie, () => m("email")), J.addEventListener("change", (c) => {
497
- i(c.currentTarget.value);
498
- }), g(ae, () => m("name")), Q.addEventListener("change", (c) => l(c.currentTarget.value)), g(fe, () => m("subject")), W.addEventListener("change", (c) => f(c.currentTarget.value)), g(de, () => m("message")), X.addEventListener("change", (c) => h(c.currentTarget.value)), g(b, e && (() => {
499
- var c = Rt(), x = c.firstChild;
500
- return F(x, "data-sitekey", e), c;
501
- })(), Z), g(b, te(pe, {
502
- get when() {
503
- return le() === !1;
504
- },
505
- get children() {
506
- var c = jt();
507
- return g(c, $e), c;
508
- }
509
- }), Z), g(K, () => m("send")), g(b, te(pe, {
510
- get when() {
511
- return le() === !0;
512
- },
513
- get children() {
514
- var c = Mt(), x = c.firstChild, P = x.firstChild, O = P.nextSibling, U = x.nextSibling, R = U.firstChild;
515
- return g(P, () => m("successMessage")), g(O, r), F(R, "href", s), g(R, () => m("returnHome")), c;
516
- }
517
- }), null), S((c) => {
518
- var x = m("emailPlaceholder"), P = m("namePlaceholder"), O = m("subjectPlaceholder"), U = m("messagePlaceholder"), R = !!Ae(), he = !M();
519
- return x !== c.e && F(J, "placeholder", c.e = x), P !== c.t && F(Q, "placeholder", c.t = P), O !== c.a && F(W, "placeholder", c.a = O), U !== c.o && F(X, "placeholder", c.o = U), R !== c.i && K.classList.toggle("inProgress", c.i = R), he !== c.n && (K.disabled = c.n = he), c;
520
- }, {
521
- e: void 0,
522
- t: void 0,
523
- a: void 0,
524
- o: void 0,
525
- i: void 0,
526
- n: void 0
527
- }), S(() => J.value = r()), S(() => Q.value = n()), S(() => W.value = o() ?? ""), S(() => X.value = p()), b;
528
- })();
529
- return Ue(() => {
530
- e && (window.onRecaptchaSubmitted = Pe, window.onRecaptchaExpired = Re);
531
- }), He(() => {
532
- e && (window.onRecaptchaSubmitted = void 0, window.onRecaptchaExpired = void 0);
533
- }), N;
534
- function Pe(b) {
535
- if (!b) return;
536
- L(!0);
537
- const C = N?.elements.namedItem("g-recaptcha-response");
538
- j(C.value);
539
- }
540
- function Re() {
541
- L(!1);
542
- }
543
- }
544
- function Tt(e, {
545
- language: t
546
- }) {
547
- if (!t) throw new Error("Missing language");
548
- const s = e.dataset.recaptchaKey, n = Qe(e.dataset.homeUrl), l = document.createElement("script");
549
- l.setAttribute("src", "https://www.google.com/recaptcha/api.js"), document.head.appendChild(l), Ye(() => te(_t, {
550
- recaptchaKey: s,
551
- language: t,
552
- homeUrl: n
553
- }), e);
554
- }
555
- document.addEventListener("DOMContentLoaded", () => {
556
- const e = document.documentElement.lang, t = document.querySelector("[data-effect='contactForm']");
557
- t && Tt(t, {
558
- language: e
559
- });
560
- });
1
+ import{insert as c,setAttribute as p,createComponent as M,effect as f,template as $,render as re}from"https://esm.sh/solid-js@1.8.20/web";import{createMemo as oe,createSignal as i,Show as V,onMount as ce,onCleanup as le}from"https://esm.sh/solid-js@1.8.20";function ie(e){return e.varName?` for '${e.varName}'`:""}function de(e,s={}){if(e==null||e===""&&!s.allowEmpty)throw new Error(`Missing string value${ie(s)}`);return typeof e=="string"?e:e.toString()}var G=e=>e!=null&&(e=Object.getPrototypeOf(e),e===Array.prototype||e===Object.prototype);function Y(e,s,a){for(const[n,r]of Object.entries(s)){const m=`${a}.${n}`;e[m]=r,G(r)&&Y(e,r,m)}}function ue(e){const s={...e};for(const[a,n]of Object.entries(e))G(n)&&Y(s,n,a);return s}var me=(e,s)=>{if(s)for(const[a,n]of Object.entries(s))e=e.replace(new RegExp(`{{\\s*${a}\\s*}}`,"g"),n);return e},pe=e=>e;function ge(e,s=pe){return(a,...n)=>{a[0]==="."&&(a=a.slice(1));const r=e()?.[a];switch(typeof r){case"function":return r(...n);case"string":return s(r,n[0]);default:return r}}}const he="Name",fe="Email",be="Subject",ve="Message",Fe="Send",$e="The e-mail address on which we can reply to you",Ce="Your name",Ee="The subject of your message",ye="Enter your message here...",we="Unexpected error, the message could not be sent.",xe="Return Home",Se="Your message has been sent. If there is a response, it will be sent to the address",je={name:he,email:fe,subject:be,message:ve,send:Fe,emailPlaceholder:$e,namePlaceholder:Ce,subjectPlaceholder:Ee,messagePlaceholder:ye,unexpectedErrorMessage:we,returnHome:xe,successMessage:Se},Me="Nom",Pe="E-mail",_e="Sujet",Re="Message",Le="Envoyer",Te="L'adresse e-mail sur laquelle nous pourrons vous répondre",He="Votre nom",Oe="Le sujet de votre message",ke="Saisissez votre message",Ae="Erreur inattendue, le message n'a pas pu être envoyé.",Ie="Retourner à l'accueil",Ne="Votre message a été envoyé. S'il y a une réponse, elle sera envoyée à l'adresse",qe={name:Me,email:Pe,subject:_e,message:Re,send:Le,emailPlaceholder:Te,namePlaceholder:He,subjectPlaceholder:Oe,messagePlaceholder:ke,unexpectedErrorMessage:Ae,returnHome:Ie,successMessage:Ne},B={en:je,fr:qe};function Ue(e){const s=oe((()=>{const n=e in B?e:"en";return ue(B[n])}));return{t:ge(s,me)}}async function De(e,s,a){a(!0);try{const n=await Ve(e);return s.reset(),n}finally{a(!1)}}async function Ve(e){const s=await fetch("/api/plugin/contact-form",{headers:{"Content-Type":"application/json"},body:JSON.stringify(e),method:"POST"});if(s.status!==200){const n=await s.text();throw new Error(`Unexpected error: ${n}`)}return await s.json()}var Be=$("<div class=ContactForm-error>"),Ge=$('<div class="ContactForm-done ContactForm-ended"><div class=ContactForm-endedMessage><p></p><p></p></div><div class=ContactForm-endedActions><a class=BigBtn>'),Ye=$("<form class=ContactForm><div class=ContactForm-fieldGroup><label class=ContactFormField><span class=ContactFormField-label></span><input class=ContactFormField-input type=email name=email required></label><label class=ContactFormField><span class=ContactFormField-label></span><input class=ContactFormField-input type=text name=name required></label><label class=ContactFormField><span class=ContactFormField-label></span><input class=ContactFormField-input type=text name=subject></label><label class=ContactFormField><span class=ContactFormField-label></span><textarea class=ContactFormField-textarea rows=5 name=message required></textarea></label></div><div class=ContactForm-action><button type=submit class=ContactForm-btn>"),ze=$("<div class=ContactForm-captcha><div class=g-recaptcha data-callback=onRecaptchaSubmitted data-expired-callback=onRecaptchaExpired>");function Je({recaptchaKey:e,language:s,homeUrl:a}){const[n,r]=i(""),[m,z]=i(""),[P,J]=i(),[_,Q]=i(""),[W,X]=i(),[R,L]=i(!e),[T,C]=i(),[Z,H]=i(""),[K,ee]=i(!1),{t:o}=Ue(s),te=async l=>{try{if(l.preventDefault(),!R()||!b)throw new Error("Erreur de recaptcha");const d=await De({language:s,name:n(),subject:P(),message:_(),email:m(),gRecaptchaResponse:W()},b,ee);d.success?C(!0):(C(!1),H(d.message??o("unexpectedErrorMessage")))}catch{C(!1),H(o("unexpectedErrorMessage"))}},b=(()=>{var l=Ye(),d=l.firstChild,O=d.firstChild,k=O.firstChild,E=k.nextSibling,A=O.nextSibling,I=A.firstChild,y=I.nextSibling,N=A.nextSibling,q=N.firstChild,w=q.nextSibling,ae=N.nextSibling,U=ae.firstChild,x=U.nextSibling,S=d.nextSibling,j=S.firstChild;return l.addEventListener("submit",te),c(k,(()=>o("email"))),E.addEventListener("change",(t=>{z(t.currentTarget.value)})),c(I,(()=>o("name"))),y.addEventListener("change",(t=>r(t.currentTarget.value))),c(q,(()=>o("subject"))),w.addEventListener("change",(t=>J(t.currentTarget.value))),c(U,(()=>o("message"))),x.addEventListener("change",(t=>Q(t.currentTarget.value))),c(l,e&&(()=>{var t=ze(),u=t.firstChild;return p(u,"data-sitekey",e),t})(),S),c(l,M(V,{get when(){return T()===!1},get children(){var t=Be();return c(t,Z),t}}),S),c(j,(()=>o("send"))),c(l,M(V,{get when(){return T()===!0},get children(){var t=Ge(),u=t.firstChild,g=u.firstChild,v=g.nextSibling,F=u.nextSibling,h=F.firstChild;return c(g,(()=>o("successMessage"))),c(v,m),p(h,"href",a),c(h,(()=>o("returnHome"))),t}}),null),f((t=>{var u=o("emailPlaceholder"),g=o("namePlaceholder"),v=o("subjectPlaceholder"),F=o("messagePlaceholder"),h=!!K(),D=!R();return u!==t.e&&p(E,"placeholder",t.e=u),g!==t.t&&p(y,"placeholder",t.t=g),v!==t.a&&p(w,"placeholder",t.a=v),F!==t.o&&p(x,"placeholder",t.o=F),h!==t.i&&j.classList.toggle("inProgress",t.i=h),D!==t.n&&(j.disabled=t.n=D),t}),{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),f((()=>E.value=m())),f((()=>y.value=n())),f((()=>w.value=P()??"")),f((()=>x.value=_())),l})();return ce((()=>{e&&(window.onRecaptchaSubmitted=se,window.onRecaptchaExpired=ne)})),le((()=>{e&&(window.onRecaptchaSubmitted=void 0,window.onRecaptchaExpired=void 0)})),b;function se(l){if(!l)return;L(!0);const d=b?.elements.namedItem("g-recaptcha-response");X(d.value)}function ne(){L(!1)}}function Qe(e,{language:s}){if(!s)throw new Error("Missing language");const a=e.dataset.recaptchaKey,n=de(e.dataset.homeUrl),r=document.createElement("script");r.setAttribute("src","https://www.google.com/recaptcha/api.js"),document.head.appendChild(r),re((()=>M(Je,{recaptchaKey:a,language:s,homeUrl:n})),e)}document.addEventListener("DOMContentLoaded",(()=>{const e=document.documentElement.lang,s=document.querySelector("[data-effect='contactForm']");s&&Qe(s,{language:e})}));