@lystech/sections 0.8.0 → 0.9.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.
@@ -0,0 +1,1509 @@
1
+ import { jsx as e, jsxs as n, Fragment as H } from "react/jsx-runtime";
2
+ import { memo as _e, useState as N, useRef as J, useLayoutEffect as Re, useEffect as ae, useMemo as Z, useDeferredValue as ze, useCallback as Ie } from "react";
3
+ import { E as oe, m as Be, e as qe } from "./index-C_uFDnBO.js";
4
+ function ke(o) {
5
+ return o.normalize("NFD").replace(new RegExp("\\p{M}", "gu"), "").toLowerCase();
6
+ }
7
+ const we = _e(function({ src: i, taille: g = 48 }) {
8
+ return i ? /* @__PURE__ */ e("img", { className: "b-vignette", src: i, alt: "", loading: "lazy", decoding: "async", width: g, height: g, style: { width: g, height: g } }) : /* @__PURE__ */ e("span", { className: "b-vignette b-vignette--vide", "aria-hidden": "true", style: { width: g, height: g }, children: "◇" });
9
+ });
10
+ function Ne(o) {
11
+ return (o.photos.find((i) => i.principale) ?? o.photos[0])?.src;
12
+ }
13
+ function Me(o) {
14
+ return o.stock.mode === "unique" ? "Pièce unique" : o.stock.mode === "illimite" ? "Sans limite" : `${o.stock.restant ?? 0} en stock`;
15
+ }
16
+ function Fe(o) {
17
+ return o.visible ? o.vendu ? ["vendu", "Épuisé"] : ["vente", "En vente"] : ["masque", "Masqué"];
18
+ }
19
+ const ne = (o, i, g) => o === 1 ? `1 ${i}` : `${o} ${g}`;
20
+ function Te({
21
+ api: o,
22
+ collections: i,
23
+ brouillons: g,
24
+ surOuvrir: w,
25
+ surCree: I
26
+ }) {
27
+ const [S, D] = N(""), [E, q] = N(!1), [k, L] = N(null), z = J(Math.random().toString(36).slice(2)), v = async () => {
28
+ const u = S.trim();
29
+ if (!(!u || E)) {
30
+ q(!0), L(null);
31
+ try {
32
+ const U = await o.creerBrouillon("collection", { nom: u, description: "", produits: [] }, z.current);
33
+ z.current = Math.random().toString(36).slice(2), D(""), I(U);
34
+ } catch (U) {
35
+ L(U instanceof oe ? U.message : "La création a échoué.");
36
+ } finally {
37
+ q(!1);
38
+ }
39
+ }
40
+ }, b = (u, U) => /* @__PURE__ */ n("button", { type: "button", className: "b-rangee", onClick: () => w(u.UID), "aria-label": `Ouvrir la collection ${u.nom || "sans nom"}`, children: [
41
+ /* @__PURE__ */ e("span", { className: "b-vignette b-vignette--vide", "aria-hidden": "true", children: "▦" }),
42
+ /* @__PURE__ */ n("span", { className: "b-rangee__texte", children: [
43
+ /* @__PURE__ */ e("span", { className: "b-rangee__nom", children: u.nom || "Sans nom" }),
44
+ /* @__PURE__ */ n("span", { className: "b-rangee__meta", children: [
45
+ ne(u.nbProduits, "bijou", "bijoux"),
46
+ " · ",
47
+ U ? "invisible jusqu'à « Publier »" : u.accesLibelle
48
+ ] })
49
+ ] }),
50
+ /* @__PURE__ */ e("span", { className: "b-etiquette " + (U ? "b-etiquette--brouillon" : u.ouverte ? "b-etiquette--vente" : "b-etiquette--masque"), children: U ? "Brouillon" : u.ouverte ? "Ouverte" : "Fermée" })
51
+ ] }, u.UID);
52
+ return /* @__PURE__ */ n(H, { children: [
53
+ /* @__PURE__ */ n("div", { className: "b-champ", children: [
54
+ /* @__PURE__ */ e("label", { htmlFor: "b-nouvelle-coll", children: "Nouvelle collection" }),
55
+ /* @__PURE__ */ n("form", { className: "b-ligne-ajout", onSubmit: (u) => {
56
+ u.preventDefault(), v();
57
+ }, children: [
58
+ /* @__PURE__ */ e("input", { id: "b-nouvelle-coll", type: "text", value: S, maxLength: 120, placeholder: "Ex. Collection d'hiver", onChange: (u) => D(u.target.value) }),
59
+ /* @__PURE__ */ e("button", { type: "submit", className: "bouton bouton--principal", disabled: E || !S.trim(), children: "Créer" })
60
+ ] }),
61
+ k && /* @__PURE__ */ e("p", { className: "b-erreur", role: "alert", children: k }),
62
+ /* @__PURE__ */ e("p", { className: "b-aide", children: "Elle naît en brouillon, invisible : vous la garnissez, puis vous la publiez." })
63
+ ] }),
64
+ g.length > 0 && /* @__PURE__ */ e("h3", { className: "b-intertitre", children: "En brouillon" }),
65
+ g.map((u) => b(u, !0)),
66
+ i.length > 0 && /* @__PURE__ */ e("h3", { className: "b-intertitre", children: "En ligne" }),
67
+ i.length === 0 && g.length === 0 && /* @__PURE__ */ e("p", { className: "b-vide", children: "Aucune collection pour l'instant." }),
68
+ i.map((u) => b(u, !1))
69
+ ] });
70
+ }
71
+ function Pe({
72
+ items: o,
73
+ hauteur: i,
74
+ conteneur: g,
75
+ cle: w,
76
+ rendu: I,
77
+ surplus: S = 6,
78
+ etiquette: D
79
+ }) {
80
+ const E = J(null), [q, k] = N({ debut: 0, fin: Math.min(o.length, 24) });
81
+ Re(() => {
82
+ const v = g.current, b = E.current;
83
+ if (!v || !b) return;
84
+ let u = 0;
85
+ const U = () => {
86
+ u = 0;
87
+ const l = b.getBoundingClientRect().top - v.getBoundingClientRect().top + v.scrollTop, R = v.scrollTop - l, f = Math.max(0, Math.floor(R / i) - S), F = Math.min(o.length, Math.ceil((R + v.clientHeight) / i) + S);
88
+ k((C) => C.debut === f && C.fin === F ? C : { debut: f, fin: F });
89
+ }, x = () => {
90
+ u || (u = requestAnimationFrame(U));
91
+ };
92
+ U(), v.addEventListener("scroll", x, { passive: !0 });
93
+ const m = new ResizeObserver(x);
94
+ return m.observe(v), () => {
95
+ v.removeEventListener("scroll", x), m.disconnect(), u && cancelAnimationFrame(u);
96
+ };
97
+ }, [g, i, o.length, S]);
98
+ const L = Math.min(q.fin, o.length), z = o.slice(q.debut, L);
99
+ return /* @__PURE__ */ e("div", { ref: E, role: "list", "aria-label": D, style: { position: "relative", height: o.length * i }, children: z.map((v, b) => /* @__PURE__ */ e("div", { role: "listitem", style: { position: "absolute", left: 0, right: 0, top: (q.debut + b) * i, height: i }, children: I(v, q.debut + b) }, w(v))) });
100
+ }
101
+ const Le = [
102
+ { acces: "fermee", titre: "Fermée", aide: "Plus de commandes. Rien n'est écrit aux clients." },
103
+ { acces: "tous", titre: "Visible dans la boutique", aide: "Tout le monde la voit et peut commander." },
104
+ { acces: "lien", titre: "À qui a le lien", aide: "Absente de la vitrine ; vous partagez son adresse." },
105
+ { acces: "invites", titre: "Sur invitation", aide: "Seules les personnes invitées, connectées, peuvent commander." }
106
+ ], Ve = 58;
107
+ function He({
108
+ api: o,
109
+ collection: i,
110
+ produits: g,
111
+ brouillonsProduits: w,
112
+ signaler: I,
113
+ surRetour: S,
114
+ majCollection: D,
115
+ majProduits: E,
116
+ majBrouillons: q,
117
+ surAjouterExistants: k,
118
+ surCreer: L,
119
+ surOuvrirProduit: z,
120
+ annonce: v = null
121
+ }) {
122
+ const b = "brouillon" in i && i.brouillon, [u, U] = N(i.nom), [x, m] = N(i.description), [l, R] = N(i.acces), [f, F] = N(!1), [C, T] = N(null), [Q, K] = N(!1), $ = J(null), ee = J(null);
123
+ ae(() => {
124
+ U(i.nom), m(i.description), R(i.acces), K(!1), T(v ? { ton: "ok", texte: v } : null), ee.current?.focus();
125
+ }, [i.UID, v]);
126
+ const X = u.trim() !== i.nom || x !== i.description || !b && l !== i.acces, P = Z(() => {
127
+ const p = b ? (g ?? []).filter((h) => i.produits.includes(h.UID)) : (g ?? []).filter((h) => h.collections.includes(i.UID));
128
+ return [
129
+ ...w.filter((h) => h.collections.includes(i.UID)).map((h) => ({ UID: h.UID, nom: h.nom || "Sans nom", src: Ne(h), brouillon: !0, masque: !1 })),
130
+ ...p.map((h) => ({ UID: h.UID, nom: h.nom || "Sans nom", src: Ne(h), brouillon: !1, masque: !h.visible }))
131
+ ];
132
+ }, [g, w, i, b]), O = async (p, B) => {
133
+ F(!0), T(null);
134
+ try {
135
+ return await p(), T({ ton: "ok", texte: B }), !0;
136
+ } catch (h) {
137
+ return T({ ton: "erreur", texte: h instanceof oe ? h.message : "Le changement a échoué." }), !1;
138
+ } finally {
139
+ F(!1);
140
+ }
141
+ }, G = () => O(async () => {
142
+ if (!u.trim()) throw new oe("Donnez un nom à la collection.", 400);
143
+ if (b) {
144
+ D(await o.modifierBrouillon(i.UID, { nom: u.trim(), description: x }));
145
+ return;
146
+ }
147
+ const p = await o.modifierCollection(i.UID, {
148
+ ...u.trim() !== i.nom ? { nom: u.trim() } : {},
149
+ ...x !== i.description ? { description: x } : {},
150
+ ...l !== i.acces ? { acces: l } : {}
151
+ });
152
+ p && D(p), I({ quoi: "collection", UID: i.UID, action: l !== i.acces ? l === "fermee" ? "masque" : "visible" : "modifie" });
153
+ }, b ? "Brouillon enregistré. Toujours invisible." : "Enregistré — en ligne maintenant."), ie = (p) => O(async () => {
154
+ if (p.brouillon) {
155
+ const h = w.find((y) => y.UID === p.UID);
156
+ await o.modifierBrouillon(p.UID, { collections: (h?.collections ?? []).filter((y) => y !== i.UID) }), q();
157
+ return;
158
+ }
159
+ if (b) {
160
+ D(await o.modifierBrouillon(i.UID, { produits: i.produits.filter((h) => h !== p.UID) }));
161
+ return;
162
+ }
163
+ const B = await o.garnirCollection(i.UID, [], [p.UID]);
164
+ B && D(B), E(), I({ quoi: "collection", UID: i.UID, action: "retire" });
165
+ }, `« ${p.nom} » retiré de « ${i.nom} ».`), c = () => O(async () => {
166
+ await o.supprimerBrouillon(i.UID), q(), S();
167
+ }, "Brouillon supprimé."), j = () => {
168
+ X && !window.confirm("Quitter sans enregistrer ? Vos changements seront perdus.") || S();
169
+ }, _ = i.acces === "invites" || i.acces === "lien";
170
+ return /* @__PURE__ */ n(H, { children: [
171
+ /* @__PURE__ */ n("div", { className: "b-tete", children: [
172
+ /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--icone bouton--discret", onClick: j, "aria-label": "Retour", children: "←" }),
173
+ /* @__PURE__ */ e("h2", { ref: ee, tabIndex: -1, children: i.nom || "Nouvelle collection" }),
174
+ /* @__PURE__ */ e("span", { className: "b-etiquette " + (b ? "b-etiquette--brouillon" : i.ouverte ? "b-etiquette--vente" : "b-etiquette--masque"), children: b ? "Brouillon" : i.ouverte ? "Ouverte" : "Fermée" })
175
+ ] }),
176
+ /* @__PURE__ */ n("div", { className: "panneau__corps", ref: $, children: [
177
+ C && /* @__PURE__ */ e("p", { className: "message message--" + C.ton, role: C.ton === "erreur" ? "alert" : "status", children: C.texte }),
178
+ b && /* @__PURE__ */ n("p", { className: "b-avis b-avis--brouillon", role: "note", children: [
179
+ "Brouillon : cette collection reste ",
180
+ /* @__PURE__ */ e("b", { children: "invisible" }),
181
+ " jusqu'à « Publier ». Vous choisirez alors comment l'ouvrir."
182
+ ] }),
183
+ /* @__PURE__ */ n("form", { onSubmit: (p) => {
184
+ p.preventDefault(), X && G();
185
+ }, children: [
186
+ /* @__PURE__ */ n("div", { className: "b-champ", children: [
187
+ /* @__PURE__ */ e("label", { htmlFor: "coll-nom", children: "Nom de la collection" }),
188
+ /* @__PURE__ */ e("input", { id: "coll-nom", type: "text", value: u, maxLength: 120, onChange: (p) => U(p.target.value), placeholder: "Ex. Collection d'hiver" })
189
+ ] }),
190
+ /* @__PURE__ */ n("div", { className: "b-champ", children: [
191
+ /* @__PURE__ */ n("label", { htmlFor: "coll-desc", children: [
192
+ "Description ",
193
+ /* @__PURE__ */ e("small", { children: "(facultatif — affichée au-dessus des bijoux)" })
194
+ ] }),
195
+ /* @__PURE__ */ e("textarea", { id: "coll-desc", value: x, onChange: (p) => m(p.target.value), placeholder: "Ce qui rend cette collection unique…" })
196
+ ] }),
197
+ !b && /* @__PURE__ */ n("fieldset", { className: "b-niveaux", children: [
198
+ /* @__PURE__ */ e("legend", { children: "Qui peut commander ?" }),
199
+ Le.map((p) => /* @__PURE__ */ n("label", { className: "b-niveau" + (l === p.acces ? " b-niveau--choisi" : ""), children: [
200
+ /* @__PURE__ */ e("input", { type: "radio", name: "coll-acces", value: p.acces, checked: l === p.acces, onChange: () => R(p.acces) }),
201
+ /* @__PURE__ */ n("span", { children: [
202
+ /* @__PURE__ */ e("b", { children: p.titre }),
203
+ /* @__PURE__ */ e("small", { children: p.aide })
204
+ ] })
205
+ ] }, p.acces)),
206
+ l === "tous" && _ && /* @__PURE__ */ e("p", { className: "b-aide b-aide--attention", role: "note", children: "Attention : elle deviendra publique. Tout le monde la verra dans la boutique." })
207
+ ] }),
208
+ /* @__PURE__ */ e("button", { type: "submit", hidden: !0, "aria-hidden": "true", tabIndex: -1 })
209
+ ] }),
210
+ /* @__PURE__ */ n("section", { className: "b-section", "aria-labelledby": "coll-bijoux", style: { marginTop: 16 }, children: [
211
+ /* @__PURE__ */ n("h3", { id: "coll-bijoux", children: [
212
+ ne(P.length, "bijou", "bijoux"),
213
+ " dans cette collection"
214
+ ] }),
215
+ /* @__PURE__ */ n("div", { className: "b-deux", style: { marginBottom: 10 }, children: [
216
+ /* @__PURE__ */ e("button", { type: "button", className: "b-ajout", style: { margin: 0 }, onClick: k, disabled: f, children: "+ Bijoux existants" }),
217
+ /* @__PURE__ */ e("button", { type: "button", className: "b-ajout", style: { margin: 0 }, onClick: L, disabled: f, children: "+ Nouveau bijou" })
218
+ ] }),
219
+ P.length === 0 && /* @__PURE__ */ e("p", { className: "b-aide", children: "Aucun bijou pour l'instant." }),
220
+ /* @__PURE__ */ e(
221
+ Pe,
222
+ {
223
+ items: P,
224
+ hauteur: Ve,
225
+ conteneur: $,
226
+ cle: (p) => p.UID,
227
+ etiquette: "Bijoux de " + i.nom,
228
+ rendu: (p) => /* @__PURE__ */ n("div", { className: "b-mini", children: [
229
+ /* @__PURE__ */ n("button", { type: "button", className: "b-mini__ouvrir", onClick: () => z(p.UID), "aria-label": "Ouvrir la fiche de " + p.nom, children: [
230
+ /* @__PURE__ */ e(we, { src: p.src, taille: 40 }),
231
+ /* @__PURE__ */ e("span", { children: p.nom }),
232
+ p.brouillon && /* @__PURE__ */ e("span", { className: "b-etiquette b-etiquette--brouillon", children: "Brouillon" }),
233
+ p.masque && /* @__PURE__ */ e("span", { className: "b-etiquette b-etiquette--masque", children: "Masqué" })
234
+ ] }),
235
+ /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--discret", disabled: f, "aria-label": `Retirer ${p.nom} de ${i.nom}`, onClick: () => {
236
+ ie(p);
237
+ }, children: "Retirer" })
238
+ ] })
239
+ }
240
+ )
241
+ ] }),
242
+ b && /* @__PURE__ */ e("section", { className: "b-danger", "aria-label": "Supprimer ce brouillon", children: Q ? /* @__PURE__ */ n("div", { className: "b-confirmer", role: "alertdialog", "aria-label": "Confirmer la suppression", children: [
243
+ /* @__PURE__ */ n("p", { children: [
244
+ /* @__PURE__ */ n("b", { children: [
245
+ "Supprimer le brouillon « ",
246
+ i.nom,
247
+ " » ?"
248
+ ] }),
249
+ /* @__PURE__ */ e("br", {}),
250
+ "Les bijoux existants n'en sont pas touchés ; les bijoux en brouillon restent, sans cette collection."
251
+ ] }),
252
+ /* @__PURE__ */ n("div", { className: "rang", children: [
253
+ /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--danger-plein", onClick: () => {
254
+ c();
255
+ }, disabled: f, children: "Oui, supprimer le brouillon" }),
256
+ /* @__PURE__ */ e("button", { type: "button", className: "bouton", onClick: () => K(!1), autoFocus: !0, children: "Non, le garder" })
257
+ ] })
258
+ ] }) : /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--danger", onClick: () => K(!0), children: "Supprimer ce brouillon…" }) })
259
+ ] }),
260
+ /* @__PURE__ */ n("div", { className: "panneau__pied", children: [
261
+ /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--discret", onClick: j, disabled: f, children: X ? "Annuler" : "Retour" }),
262
+ /* @__PURE__ */ e("span", { className: "espace" }),
263
+ /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--principal", onClick: () => {
264
+ G();
265
+ }, disabled: f || !X, children: f ? "Un instant…" : b ? "Enregistrer le brouillon" : "Enregistrer" })
266
+ ] })
267
+ ] });
268
+ }
269
+ const Je = 2400;
270
+ async function $e(o) {
271
+ const i = o.name || "photo.jpg";
272
+ if (typeof createImageBitmap != "function" || o.size < 9e5) return { donnees: o, nom: i };
273
+ try {
274
+ const g = await createImageBitmap(o, { imageOrientation: "from-image" }), w = Math.min(1, Je / Math.max(g.width, g.height)), I = Math.round(g.width * w), S = Math.round(g.height * w), D = document.createElement("canvas");
275
+ D.width = I, D.height = S;
276
+ const E = D.getContext("2d");
277
+ if (!E) return { donnees: o, nom: i };
278
+ E.drawImage(g, 0, 0, I, S), g.close?.();
279
+ const q = await new Promise((k) => D.toBlob(k, "image/jpeg", 0.9));
280
+ return !q || q.size >= o.size ? { donnees: o, nom: i } : { donnees: q, nom: i.replace(/\.[^.]+$/, "") + ".jpg" };
281
+ } catch {
282
+ return { donnees: o, nom: i };
283
+ }
284
+ }
285
+ function Qe(o) {
286
+ const i = Array.from(o ?? []), g = i.filter((w) => w.type.startsWith("image/") || /\.(heic|heif)$/i.test(w.name));
287
+ return { images: g, ecartes: i.length - g.length };
288
+ }
289
+ function Se(o) {
290
+ return o == null ? "" : Number.isInteger(o) ? String(o) : o.toFixed(2).replace(".", ",");
291
+ }
292
+ function ue(o, i) {
293
+ const g = !!o && "brouillon" in o;
294
+ return {
295
+ nom: o?.nom ?? "",
296
+ prix: o && (o.prix || !g) ? Se(o.prix) : "",
297
+ prixAvant: o?.prixAvant ? Se(o.prixAvant) : "",
298
+ mode: o?.stock.mode ?? i?.mode ?? "unique",
299
+ quantite: o?.stock.mode === "quantite" ? String(o.stock.restant ?? 0) : "1",
300
+ visible: o?.visible ?? !0,
301
+ collections: o?.collections ?? i?.collections ?? [],
302
+ description: o?.description ?? ""
303
+ };
304
+ }
305
+ const Ee = () => Math.random().toString(36).slice(2) + Date.now().toString(36);
306
+ function Xe({
307
+ api: o,
308
+ produit: i,
309
+ collections: g,
310
+ collectionDefaut: w = null,
311
+ surEnregistre: I,
312
+ surSupprime: S,
313
+ surRetour: D,
314
+ surFermer: E,
315
+ envoyerEnArrierePlan: q,
316
+ photosEnCours: k = 0,
317
+ compteBrouillons: L = 0,
318
+ signaler: z,
319
+ annonce: v
320
+ }) {
321
+ const b = i === null, u = b || !!i && "brouillon" in i, U = { collections: w ? [w] : [] }, [x, m] = N(() => ue(i, U)), [l, R] = N(x), [f, F] = N(i), [C, T] = N([]), [Q, K] = N(0), [$, ee] = N({}), [X, P] = N(null), [O, G] = N(!1), [ie, c] = N(!1), [j, _] = N(!1), [p, B] = N(Ee), h = J(null), y = J(null), te = J(null);
322
+ ae(() => {
323
+ m(ue(i, U)), R(ue(i, U)), F(i), T([]), ee({}), P(v ? { ton: "ok", texte: v } : null), _(!1), (b ? y.current : h.current)?.focus();
324
+ }, [i?.UID]);
325
+ const se = J(C);
326
+ se.current = C, ae(() => () => se.current.forEach((t) => URL.revokeObjectURL(t.apercu)), []);
327
+ const V = JSON.stringify(l) !== JSON.stringify(x), Y = (t, d) => {
328
+ R((s) => ({ ...s, [t]: d })), P((s) => s?.ton === "erreur" ? null : s), ee((s) => {
329
+ const M = { ...s };
330
+ return delete M[t], M;
331
+ });
332
+ }, pe = u ? { ajouter: o.photoBrouillon, principale: o.principaleBrouillon, retirer: o.retirerPhotoBrouillon } : { ajouter: o.ajouterPhoto, principale: o.principale, retirer: o.retirerPhoto }, ge = async (t) => {
333
+ const { images: d, ecartes: s } = Qe(t);
334
+ if (s && P({ ton: "erreur", texte: s === 1 ? "Un fichier n'était pas une photo : il a été écarté." : `${s} fichiers n'étaient pas des photos : ils ont été écartés.` }), !!d.length) {
335
+ if (b || !f) {
336
+ T((M) => [...M, ...d.map((W) => ({ cle: Math.random().toString(36).slice(2), fichier: W, apercu: URL.createObjectURL(W) }))]);
337
+ return;
338
+ }
339
+ await je(f.UID, d);
340
+ }
341
+ }, je = async (t, d) => {
342
+ let s = null, M = 0;
343
+ for (const [W, le] of d.entries()) {
344
+ K(d.length - W), P({ ton: "info", texte: d.length > 1 ? `Envoi de la photo ${W + 1} sur ${d.length}…` : "Envoi de la photo…" });
345
+ try {
346
+ const { donnees: ye, nom: Oe } = await $e(le);
347
+ s = await pe.ajouter(t, ye, Oe), F(s);
348
+ } catch (ye) {
349
+ M++, P({ ton: "erreur", texte: ye instanceof oe ? ye.message : "Une photo n'a pas pu être envoyée." });
350
+ }
351
+ }
352
+ if (K(0), s) {
353
+ u || z({ quoi: "photo", UID: t, action: "ajoute" }), I(s);
354
+ const W = u ? "enregistrée, toujours en brouillon" : "en ligne maintenant";
355
+ M || P({ ton: "ok", texte: d.length > 1 ? `Photos ajoutées — ${W.replace("enregistrée", "enregistrées")}.` : `Photo ajoutée — ${W}.` });
356
+ }
357
+ return s;
358
+ }, xe = async (t, d) => {
359
+ G(!0);
360
+ try {
361
+ const s = await t();
362
+ F(s), I(s), u || z({ quoi: "photo", UID: s.UID, action: "modifie" }), P({ ton: "ok", texte: d });
363
+ } catch (s) {
364
+ P({ ton: "erreur", texte: s instanceof oe ? s.message : "Le changement de photo a échoué." });
365
+ } finally {
366
+ G(!1);
367
+ }
368
+ }, Ce = (t) => {
369
+ t.preventDefault(), c(!1), ge(t.dataTransfer.files);
370
+ }, ce = () => {
371
+ const t = {}, d = (s) => b || l[s] !== x[s] || JSON.stringify(l[s]) !== JSON.stringify(x[s]);
372
+ return d("nom") && (t.nom = l.nom), d("prix") && (t.prix = l.prix), d("prixAvant") && (t.prixAvant = l.prixAvant.trim() === "" ? null : l.prixAvant), (d("mode") || d("quantite")) && (t.stock = { mode: l.mode, quantite: l.mode === "quantite" ? l.quantite : null }), d("visible") && (t.visible = l.visible), d("collections") && (t.collections = l.collections), d("description") && (t.description = l.description), t;
373
+ }, fe = () => ({
374
+ nom: l.nom.trim(),
375
+ prix: l.prix.trim(),
376
+ prixAvant: l.prixAvant.trim() || null,
377
+ description: l.description,
378
+ stock: { mode: l.mode, quantite: l.mode === "quantite" ? l.quantite : null },
379
+ collections: l.collections
380
+ }), de = async (t = "rester") => {
381
+ if (!O) {
382
+ G(!0), P(null);
383
+ try {
384
+ if (b) {
385
+ if (!l.nom.trim() && !l.prix.trim() && !C.length) {
386
+ ee({ nom: "Un nom, un prix ou une photo : de quoi reconnaître ce bijou." });
387
+ return;
388
+ }
389
+ const s = await o.creerBrouillon("produit", fe(), p);
390
+ I(s), C.length && q?.(s.UID, C.map((le) => le.fichier));
391
+ const M = s.nom || "Ce bijou";
392
+ if (t === "fermer") {
393
+ E?.();
394
+ return;
395
+ }
396
+ const W = ue(null, { collections: l.collections, mode: l.mode });
397
+ T([]), m(W), R(W), ee({}), B(Ee()), P({ ton: "ok", texte: `« ${M} » est rangé en brouillon. Au suivant !` }), te.current?.scrollTo({ top: 0 }), requestAnimationFrame(() => y.current?.focus());
398
+ return;
399
+ }
400
+ if (!f) return;
401
+ if (u) {
402
+ const s = await o.modifierBrouillon(f.UID, fe());
403
+ F(s), m(ue(s)), R(ue(s)), I(s), P({ ton: "ok", texte: s.problemes.length ? `Brouillon enregistré. Avant de publier : ${s.problemes.join(" ")}` : "Brouillon enregistré — prêt à publier." });
404
+ return;
405
+ }
406
+ const d = await o.modifier(f.UID, ce());
407
+ F(d), m(ue(d)), R(ue(d)), P({ ton: "ok", texte: "Enregistré — en ligne maintenant." }), I(d), z({ quoi: "produit", UID: d.UID, action: l.visible !== x.visible ? l.visible ? "visible" : "masque" : "modifie" });
408
+ } catch (d) {
409
+ d instanceof oe ? (ee(d.erreurs), P({ ton: "erreur", texte: d.message })) : P({ ton: "erreur", texte: "L'enregistrement a échoué. Vos changements sont toujours à l'écran." });
410
+ } finally {
411
+ G(!1);
412
+ }
413
+ }
414
+ }, be = async () => {
415
+ if (f) {
416
+ G(!0);
417
+ try {
418
+ u ? await o.supprimerBrouillon(f.UID) : (await o.supprimer(f.UID), z({ quoi: "produit", UID: f.UID, action: "supprime" })), S(f.UID);
419
+ } catch (t) {
420
+ _(!1), P({ ton: "erreur", texte: t instanceof oe ? t.message : "La suppression a échoué." });
421
+ } finally {
422
+ G(!1);
423
+ }
424
+ }
425
+ }, ve = () => {
426
+ (V || C.length) && !window.confirm("Quitter sans enregistrer ? Vos changements seront perdus.") || D();
427
+ }, he = f?.photos ?? [], re = (t) => $[t] ? /* @__PURE__ */ e("p", { className: "b-erreur", role: "alert", children: $[t] }) : null, A = (t) => "fiche-" + t, Ue = l.collections.length === 0 && g.length > 0, r = f && "problemes" in f ? f.problemes : [], a = b ? "Nouveau bijou" : l.nom || "Sans nom";
428
+ return /* @__PURE__ */ n(H, { children: [
429
+ /* @__PURE__ */ n("div", { className: "b-tete", children: [
430
+ /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--icone bouton--discret", onClick: ve, "aria-label": "Retour", children: "←" }),
431
+ /* @__PURE__ */ e("h2", { ref: h, tabIndex: -1, children: a }),
432
+ u && /* @__PURE__ */ e("span", { className: "b-etiquette b-etiquette--brouillon", title: "Invisible jusqu'à « Publier »", children: b && L > 0 ? `${L} en brouillon` : "Brouillon" })
433
+ ] }),
434
+ /* @__PURE__ */ n(
435
+ "form",
436
+ {
437
+ className: "panneau__corps",
438
+ ref: te,
439
+ onSubmit: (t) => {
440
+ t.preventDefault(), de(b ? "suivant" : "rester");
441
+ },
442
+ children: [
443
+ X && /* @__PURE__ */ e("p", { className: "message message--" + X.ton, role: X.ton === "erreur" ? "alert" : "status", children: X.texte }),
444
+ b && /* @__PURE__ */ n("p", { className: "b-avis b-avis--brouillon", role: "note", children: [
445
+ "Chaque bijou est rangé ",
446
+ /* @__PURE__ */ e("b", { children: "en brouillon" }),
447
+ " : invisible pour vos visiteurs jusqu'à « Publier ». Photo, nom, prix, et « Enregistrer et suivant ».",
448
+ k > 0 && /* @__PURE__ */ n(H, { children: [
449
+ /* @__PURE__ */ e("br", {}),
450
+ "Envoi des photos en arrière-plan : ",
451
+ k,
452
+ " restante",
453
+ k > 1 ? "s" : "",
454
+ "."
455
+ ] })
456
+ ] }),
457
+ !b && u && /* @__PURE__ */ e("p", { className: "b-avis " + (r.length ? "" : "b-avis--brouillon"), role: "note", children: r.length ? /* @__PURE__ */ n(H, { children: [
458
+ "Brouillon — avant de publier : ",
459
+ r.join(" ")
460
+ ] }) : /* @__PURE__ */ e(H, { children: "Brouillon complet : il partira au prochain « Publier »." }) }),
461
+ f?.vendu && /* @__PURE__ */ n("p", { className: "b-bandeau", children: [
462
+ f.stock.mode === "unique" ? "Pièce vendue." : "Plus rien en stock.",
463
+ " La boutique l'affiche « épuisé »."
464
+ ] }),
465
+ /* @__PURE__ */ n("section", { className: "b-section", "aria-labelledby": A("photos"), children: [
466
+ /* @__PURE__ */ e("h3", { id: A("photos"), children: "Photos" }),
467
+ /* @__PURE__ */ n(
468
+ "div",
469
+ {
470
+ className: "b-photos",
471
+ onDragOver: (t) => {
472
+ t.preventDefault(), c(!0);
473
+ },
474
+ onDragLeave: () => c(!1),
475
+ onDrop: Ce,
476
+ children: [
477
+ he.map((t) => /* @__PURE__ */ n("div", { className: "b-photo" + (t.principale ? " b-photo--principale" : ""), children: [
478
+ /* @__PURE__ */ e("img", { src: t.src, alt: t.principale ? "Photo principale" : "Photo du bijou", loading: "lazy", decoding: "async" }),
479
+ t.principale && /* @__PURE__ */ e("span", { className: "b-photo__badge", children: "Principale" }),
480
+ /* @__PURE__ */ n("span", { className: "b-photo__actions", children: [
481
+ !t.principale && /* @__PURE__ */ e(
482
+ "button",
483
+ {
484
+ type: "button",
485
+ disabled: O,
486
+ title: "Choisir comme photo principale",
487
+ "aria-label": "Choisir comme photo principale",
488
+ onClick: () => f && xe(() => pe.principale(f.UID, t.UID), u ? "Photo principale choisie." : "Photo principale changée — en ligne maintenant."),
489
+ children: "★"
490
+ }
491
+ ),
492
+ /* @__PURE__ */ e(
493
+ "button",
494
+ {
495
+ type: "button",
496
+ disabled: O,
497
+ title: "Retirer cette photo",
498
+ "aria-label": "Retirer cette photo",
499
+ onClick: () => f && xe(() => pe.retirer(f.UID, t.UID), "Photo retirée. Elle reste dans votre librairie d'images."),
500
+ children: "✕"
501
+ }
502
+ )
503
+ ] })
504
+ ] }, t.UID)),
505
+ C.map((t, d) => /* @__PURE__ */ n("div", { className: "b-photo" + (d === 0 && !he.length ? " b-photo--principale" : "") + (Q ? " b-photo--envoi" : ""), children: [
506
+ /* @__PURE__ */ e("img", { src: t.apercu, alt: "Photo à envoyer" }),
507
+ d === 0 && !he.length && /* @__PURE__ */ e("span", { className: "b-photo__badge", children: "Principale" }),
508
+ /* @__PURE__ */ e("span", { className: "b-photo__actions", children: /* @__PURE__ */ e("button", { type: "button", "aria-label": "Ne pas ajouter cette photo", onClick: () => {
509
+ URL.revokeObjectURL(t.apercu), T((s) => s.filter((M) => M.cle !== t.cle));
510
+ }, children: "✕" }) })
511
+ ] }, t.cle)),
512
+ /* @__PURE__ */ n("div", { className: "b-depot" + (ie ? " b-depot--survol" : ""), children: [
513
+ Q ? `Envoi en cours… (${Q} restante${Q > 1 ? "s" : ""})` : /* @__PURE__ */ e("span", { className: "b-glisser", children: "Glissez vos photos ici, ou :" }),
514
+ /* @__PURE__ */ n("div", { className: "b-depot__boutons", children: [
515
+ /* @__PURE__ */ n("label", { className: "bouton bouton--principal b-camera", children: [
516
+ "📷 Prendre une photo",
517
+ /* @__PURE__ */ e("input", { type: "file", accept: "image/*", capture: "environment", onChange: (t) => {
518
+ ge(t.target.files), t.target.value = "";
519
+ } })
520
+ ] }),
521
+ /* @__PURE__ */ n("label", { className: "bouton", children: [
522
+ "Choisir des photos",
523
+ /* @__PURE__ */ e("input", { ref: y, type: "file", accept: "image/*", multiple: !0, onChange: (t) => {
524
+ ge(t.target.files), t.target.value = "";
525
+ } })
526
+ ] })
527
+ ] })
528
+ ] })
529
+ ]
530
+ }
531
+ ),
532
+ /* @__PURE__ */ e("p", { className: "b-aide", children: b ? "La première photo devient la principale (celle de la carte en boutique)." : u ? "Les photos d'un brouillon sont gardées sur le serveur, hors de la boutique." : "La photo principale est celle des cartes de la boutique. Chaque photo est en ligne dès l'ajout." })
533
+ ] }),
534
+ /* @__PURE__ */ n("section", { className: "b-section", "aria-labelledby": A("essentiel"), children: [
535
+ /* @__PURE__ */ e("h3", { id: A("essentiel"), children: "L'essentiel" }),
536
+ /* @__PURE__ */ n("div", { className: "b-champ" + ($.nom ? " b-champ--erreur" : ""), children: [
537
+ /* @__PURE__ */ e("label", { htmlFor: A("nom"), children: "Nom du bijou" }),
538
+ /* @__PURE__ */ e(
539
+ "input",
540
+ {
541
+ id: A("nom"),
542
+ type: "text",
543
+ value: l.nom,
544
+ maxLength: 150,
545
+ placeholder: "Ex. Collier Aurore",
546
+ enterKeyHint: "next",
547
+ onChange: (t) => Y("nom", t.target.value),
548
+ "aria-invalid": !!$.nom
549
+ }
550
+ ),
551
+ re("nom")
552
+ ] }),
553
+ /* @__PURE__ */ n("div", { className: "b-deux", children: [
554
+ /* @__PURE__ */ n("div", { className: "b-champ" + ($.prix ? " b-champ--erreur" : ""), children: [
555
+ /* @__PURE__ */ e("label", { htmlFor: A("prix"), children: "Prix" }),
556
+ /* @__PURE__ */ n("div", { className: "b-prix", children: [
557
+ /* @__PURE__ */ e(
558
+ "input",
559
+ {
560
+ id: A("prix"),
561
+ type: "text",
562
+ inputMode: "decimal",
563
+ value: l.prix,
564
+ placeholder: "0,00",
565
+ onChange: (t) => Y("prix", t.target.value),
566
+ "aria-invalid": !!$.prix
567
+ }
568
+ ),
569
+ /* @__PURE__ */ e("span", { "aria-hidden": "true", children: "$" })
570
+ ] }),
571
+ re("prix")
572
+ ] }),
573
+ /* @__PURE__ */ n("div", { className: "b-champ" + ($.prixAvant ? " b-champ--erreur" : ""), children: [
574
+ /* @__PURE__ */ n("label", { htmlFor: A("avant"), children: [
575
+ "Prix avant rabais ",
576
+ /* @__PURE__ */ e("small", { children: "(facultatif)" })
577
+ ] }),
578
+ /* @__PURE__ */ n("div", { className: "b-prix", children: [
579
+ /* @__PURE__ */ e(
580
+ "input",
581
+ {
582
+ id: A("avant"),
583
+ type: "text",
584
+ inputMode: "decimal",
585
+ value: l.prixAvant,
586
+ placeholder: "—",
587
+ onChange: (t) => Y("prixAvant", t.target.value),
588
+ "aria-invalid": !!$.prixAvant
589
+ }
590
+ ),
591
+ /* @__PURE__ */ e("span", { "aria-hidden": "true", children: "$" })
592
+ ] }),
593
+ re("prixAvant")
594
+ ] })
595
+ ] })
596
+ ] }),
597
+ /* @__PURE__ */ n("section", { className: "b-section", "aria-labelledby": A("stock"), children: [
598
+ /* @__PURE__ */ e("h3", { id: A("stock"), children: "Combien en avez-vous ?" }),
599
+ /* @__PURE__ */ e("div", { className: "b-seg", role: "group", "aria-labelledby": A("stock"), children: [["unique", "Pièce unique"], ["quantite", "Quantité"], ["illimite", "Sans limite"]].map(([t, d]) => /* @__PURE__ */ e("button", { type: "button", "aria-pressed": l.mode === t, onClick: () => Y("mode", t), children: d }, t)) }),
600
+ l.mode === "quantite" && /* @__PURE__ */ n("div", { className: "b-champ" + ($.stock ? " b-champ--erreur" : ""), style: { marginTop: 10 }, children: [
601
+ /* @__PURE__ */ e("label", { htmlFor: A("qte"), children: "Quantité disponible" }),
602
+ /* @__PURE__ */ e("input", { id: A("qte"), type: "text", inputMode: "numeric", value: l.quantite, onChange: (t) => Y("quantite", t.target.value) })
603
+ ] }),
604
+ re("stock"),
605
+ /* @__PURE__ */ n("p", { className: "b-aide", children: [
606
+ l.mode === "unique" && "Un seul exemplaire. Une fois vendu, il s'affiche « épuisé », tout seul.",
607
+ l.mode === "quantite" && `Ce qui vous reste.${f?.vendus ? ` Déjà vendus : ${f.vendus}.` : ""}`,
608
+ l.mode === "illimite" && "Fait sur commande : ne s'épuise jamais."
609
+ ] })
610
+ ] }),
611
+ !u && /* @__PURE__ */ n("section", { className: "b-section", "aria-labelledby": A("vitrine"), children: [
612
+ /* @__PURE__ */ e("h3", { id: A("vitrine"), children: "Dans la boutique" }),
613
+ /* @__PURE__ */ n("button", { type: "button", className: "b-inter", role: "switch", "aria-checked": l.visible, onClick: () => Y("visible", !l.visible), children: [
614
+ /* @__PURE__ */ e("span", { className: "b-rail", "aria-hidden": "true" }),
615
+ /* @__PURE__ */ n("span", { children: [
616
+ /* @__PURE__ */ e("b", { children: l.visible ? "Visible" : "Masqué" }),
617
+ /* @__PURE__ */ e("small", { children: l.visible ? "Vos visiteurs le voient et peuvent l'acheter." : "Invisible aux visiteurs. Vous le retrouvez ici quand vous voulez." })
618
+ ] })
619
+ ] })
620
+ ] }),
621
+ /* @__PURE__ */ n("section", { className: "b-section", "aria-labelledby": A("coll"), children: [
622
+ /* @__PURE__ */ e("h3", { id: A("coll"), children: "Collections" }),
623
+ g.length === 0 ? /* @__PURE__ */ e("p", { className: "b-aide", children: "Aucune collection pour l'instant — l'onglet « Collections » permet d'en créer une." }) : /* @__PURE__ */ e("div", { className: "b-puces", role: "group", "aria-labelledby": A("coll"), children: g.map((t) => {
624
+ const d = l.collections.includes(t.UID), s = "brouillon" in t;
625
+ return s && !u ? null : /* @__PURE__ */ n(
626
+ "button",
627
+ {
628
+ type: "button",
629
+ className: "b-puce",
630
+ "aria-pressed": d,
631
+ onClick: () => Y("collections", d ? l.collections.filter((M) => M !== t.UID) : [...l.collections, t.UID]),
632
+ children: [
633
+ d ? "✓ " : "+ ",
634
+ t.nom || "Sans nom",
635
+ s ? /* @__PURE__ */ e("small", { children: "brouillon" }) : !t.ouverte && /* @__PURE__ */ e("small", { children: "fermée" })
636
+ ]
637
+ },
638
+ t.UID
639
+ );
640
+ }) }),
641
+ Ue && /* @__PURE__ */ e("p", { className: "b-aide", style: { color: "#f1d9a6" }, children: "Sans collection, ce bijou n'apparaît dans aucune vitrine de la boutique." }),
642
+ re("collections")
643
+ ] }),
644
+ /* @__PURE__ */ e("section", { className: "b-section", children: /* @__PURE__ */ n("div", { className: "b-champ" + ($.description ? " b-champ--erreur" : ""), children: [
645
+ /* @__PURE__ */ e("label", { htmlFor: A("desc"), children: "Description" }),
646
+ /* @__PURE__ */ e(
647
+ "textarea",
648
+ {
649
+ id: A("desc"),
650
+ value: l.description,
651
+ placeholder: "Matières, dimensions, l'histoire de la pièce…",
652
+ onChange: (t) => Y("description", t.target.value)
653
+ }
654
+ ),
655
+ re("description")
656
+ ] }) }),
657
+ f && u && /* @__PURE__ */ e("section", { className: "b-danger", "aria-label": "Supprimer ce brouillon", children: j ? /* @__PURE__ */ n("div", { className: "b-confirmer", role: "alertdialog", "aria-label": "Confirmer la suppression", children: [
658
+ /* @__PURE__ */ n("p", { children: [
659
+ /* @__PURE__ */ n("b", { children: [
660
+ "Supprimer le brouillon « ",
661
+ f.nom || "sans nom",
662
+ " » ?"
663
+ ] }),
664
+ /* @__PURE__ */ e("br", {}),
665
+ "Il n'a jamais été en ligne. Ses photos restent dans votre librairie."
666
+ ] }),
667
+ /* @__PURE__ */ n("div", { className: "rang", children: [
668
+ /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--danger-plein", onClick: be, disabled: O, children: "Oui, supprimer le brouillon" }),
669
+ /* @__PURE__ */ e("button", { type: "button", className: "bouton", onClick: () => _(!1), autoFocus: !0, children: "Non, le garder" })
670
+ ] })
671
+ ] }) : /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--danger", onClick: () => _(!0), children: "Supprimer ce brouillon…" }) }),
672
+ f && !u && /* @__PURE__ */ e("section", { className: "b-danger", "aria-label": "Retirer ce bijou", children: x.visible ? /* @__PURE__ */ e("p", { children: "Pour retirer ce bijou de la boutique, passez-le à « Masqué » ci-dessus. Vous pourrez le remettre en vente à tout moment." }) : j ? /* @__PURE__ */ n("div", { className: "b-confirmer", role: "alertdialog", "aria-label": "Confirmer la suppression", children: [
673
+ /* @__PURE__ */ n("p", { children: [
674
+ /* @__PURE__ */ n("b", { children: [
675
+ "Supprimer « ",
676
+ f.nom,
677
+ " » pour toujours ?"
678
+ ] }),
679
+ /* @__PURE__ */ e("br", {}),
680
+ "Ses photos restent dans votre librairie. S'il a déjà été vendu, il restera masqué : ses factures en ont besoin."
681
+ ] }),
682
+ /* @__PURE__ */ n("div", { className: "rang", children: [
683
+ /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--danger-plein", onClick: be, disabled: O, children: "Oui, supprimer pour toujours" }),
684
+ /* @__PURE__ */ e("button", { type: "button", className: "bouton", onClick: () => _(!1), autoFocus: !0, children: "Non, le garder" })
685
+ ] })
686
+ ] }) : /* @__PURE__ */ n(H, { children: [
687
+ /* @__PURE__ */ e("p", { children: "Ce bijou est masqué. Vous pouvez le remettre en vente, ou le supprimer." }),
688
+ /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--danger", onClick: () => _(!0), children: "Supprimer pour toujours…" })
689
+ ] }) }),
690
+ /* @__PURE__ */ e("button", { type: "submit", hidden: !0, "aria-hidden": "true", tabIndex: -1 })
691
+ ]
692
+ }
693
+ ),
694
+ /* @__PURE__ */ n("div", { className: "panneau__pied", children: [
695
+ !b && /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--discret", onClick: ve, disabled: O, children: V || C.length ? "Annuler" : "Retour" }),
696
+ /* @__PURE__ */ e("span", { className: "espace" }),
697
+ b ? /* @__PURE__ */ n(H, { children: [
698
+ /* @__PURE__ */ e("button", { type: "button", className: "bouton", onClick: () => {
699
+ de("fermer");
700
+ }, disabled: O || !V && !C.length, children: "Enregistrer et fermer" }),
701
+ /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--principal", onClick: () => {
702
+ de("suivant");
703
+ }, disabled: O || !V && !C.length, children: O ? "Un instant…" : "Enregistrer et suivant →" })
704
+ ] }) : /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--principal", onClick: () => {
705
+ de();
706
+ }, disabled: O || Q > 0 || !V, children: O ? "Un instant…" : u ? "Enregistrer le brouillon" : "Enregistrer" })
707
+ ] })
708
+ ] });
709
+ }
710
+ function Ge({
711
+ api: o,
712
+ brouillons: i,
713
+ noms: g,
714
+ textes: w,
715
+ publierTextes: I,
716
+ surPublie: S,
717
+ surOuvrir: D,
718
+ surRetour: E
719
+ }) {
720
+ const [q, k] = N({}), [L, z] = N(i), v = Z(() => {
721
+ const c = (j, _) => [
722
+ ...j,
723
+ ..._.filter((p) => q[p.UID]?.ok && !j.some((B) => B.UID === p.UID))
724
+ ];
725
+ return { collections: c(i.collections, L.collections), produits: c(i.produits, L.produits) };
726
+ }, [i, L, q]), b = Z(() => [...v.collections.map((c) => c.UID), ...v.produits.map((c) => c.UID)], [v]), u = Z(
727
+ () => new Set([...v.collections, ...v.produits].filter((c) => c.problemes.length === 0).map((c) => c.UID)),
728
+ [v]
729
+ ), [U, x] = N(() => new Set(u)), m = J(new Set(u));
730
+ ae(() => {
731
+ const c = [...u].filter((j) => !m.current.has(j));
732
+ c.length && (c.forEach((j) => m.current.add(j)), x((j) => /* @__PURE__ */ new Set([...j, ...c])));
733
+ }, [u]);
734
+ const [l, R] = N(w > 0), [f, F] = N({}), [C, T] = N(!1), [Q, K] = N(null), $ = J(!1), ee = (c) => x((j) => {
735
+ const _ = new Set(j);
736
+ return _.has(c) ? _.delete(c) : _.add(c), _;
737
+ }), X = Z(() => {
738
+ const c = /* @__PURE__ */ new Map();
739
+ for (const j of v.produits) {
740
+ const _ = v.collections.find((p) => j.collections.includes(p.UID) && !U.has(p.UID));
741
+ _ && U.has(j.UID) && c.set(j.UID, _.nom || "sans nom");
742
+ }
743
+ return c;
744
+ }, [v, U]), P = [...U].filter((c) => b.includes(c)).length + (l && w > 0 ? 1 : 0), O = async () => {
745
+ if ($.current) return;
746
+ $.current = !0, T(!0), K({ ton: "info", texte: "Publication en cours…" });
747
+ let c = 0, j = 0;
748
+ try {
749
+ const _ = b.filter((p) => U.has(p));
750
+ if (_.length) {
751
+ z(v);
752
+ const p = Object.fromEntries(Object.entries(f).filter(([h]) => _.includes(h))), { resultats: B } = await o.publier(_, p);
753
+ k((h) => ({ ...h, ...Object.fromEntries(B.map((y) => [y.UID, y])) })), c += B.filter((h) => !h.ok).length, j += B.filter((h) => h.ok).length, S(B), x((h) => new Set([...h].filter((y) => !B.some((te) => te.UID === y && te.ok))));
754
+ }
755
+ l && w > 0 && (await I() ? (j++, R(!1)) : c++), K(
756
+ c === 0 ? { ton: "ok", texte: `${ne(j, "élément publié", "éléments publiés")}. Vos visiteurs le voient maintenant.` } : { ton: "erreur", texte: `${ne(j, "élément publié", "éléments publiés")}, ${ne(c, "non publié", "non publiés")} — la raison est sur chaque ligne.` }
757
+ );
758
+ } catch (_) {
759
+ K({ ton: "erreur", texte: _ instanceof oe ? _.message : "La publication n'a pas pu partir. Rien n'a été perdu ; réessayez." });
760
+ } finally {
761
+ $.current = !1, T(!1);
762
+ }
763
+ }, G = (c, j, _, p, B, h) => {
764
+ const y = q[c], te = h.length > 0, se = X.get(c);
765
+ return /* @__PURE__ */ n("div", { className: "b-pub" + (y?.ok ? " b-pub--ok" : y && !y.ok ? " b-pub--echec" : ""), children: [
766
+ /* @__PURE__ */ n("label", { className: "b-pub__ligne", children: [
767
+ /* @__PURE__ */ e("input", { type: "checkbox", checked: U.has(c), disabled: te || C || !!y?.ok, onChange: () => ee(c), "aria-describedby": "pub-" + c }),
768
+ j === "produit" ? /* @__PURE__ */ e(we, { src: p, taille: 40 }) : /* @__PURE__ */ e("span", { className: "b-vignette b-vignette--vide", "aria-hidden": "true", style: { width: 40, height: 40 }, children: "▦" }),
769
+ /* @__PURE__ */ n("span", { className: "b-rangee__texte", children: [
770
+ /* @__PURE__ */ e("span", { className: "b-rangee__nom", children: _ || "Sans nom" }),
771
+ /* @__PURE__ */ e("span", { className: "b-rangee__meta", children: B })
772
+ ] })
773
+ ] }),
774
+ /* @__PURE__ */ n("div", { id: "pub-" + c, className: "b-pub__etat", children: [
775
+ y?.ok && /* @__PURE__ */ n("span", { className: "b-pub__ok", children: [
776
+ "✓ ",
777
+ y.deja ? "Déjà publié" : "Publié"
778
+ ] }),
779
+ y && !y.ok && /* @__PURE__ */ n("span", { className: "b-pub__erreur", role: "alert", children: [
780
+ y.message,
781
+ y.problemes?.length ? " " + y.problemes.join(" ") : ""
782
+ ] }),
783
+ !y && te && /* @__PURE__ */ n("span", { className: "b-pub__erreur", children: [
784
+ "À compléter : ",
785
+ h.join(" "),
786
+ " ",
787
+ /* @__PURE__ */ e("button", { type: "button", className: "b-lien", onClick: () => D(c, j), children: "Compléter" })
788
+ ] }),
789
+ !y && !te && se && /* @__PURE__ */ n("span", { className: "b-pub__erreur", children: [
790
+ "Sa collection « ",
791
+ se,
792
+ " » est décochée : cochez-la aussi."
793
+ ] })
794
+ ] }),
795
+ j === "collection" && !y?.ok && !te && /* @__PURE__ */ n("label", { className: "b-pub__ouvrir", children: [
796
+ /* @__PURE__ */ e("span", { children: "À la publication :" }),
797
+ /* @__PURE__ */ e("select", { value: f[c] ?? "fermee", disabled: C, onChange: (V) => F((Y) => ({ ...Y, [c]: V.target.value })), children: Le.map((V) => /* @__PURE__ */ e("option", { value: V.acces, children: V.acces === "fermee" ? "La laisser fermée" : "L'ouvrir — " + V.titre.toLowerCase() }, V.acces)) })
798
+ ] })
799
+ ] }, c);
800
+ }, ie = b.length === 0 && w === 0;
801
+ return /* @__PURE__ */ n(H, { children: [
802
+ /* @__PURE__ */ n("div", { className: "b-tete", children: [
803
+ /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--icone bouton--discret", onClick: E, "aria-label": "Retour", children: "←" }),
804
+ /* @__PURE__ */ e("h2", { tabIndex: -1, children: "Publier" })
805
+ ] }),
806
+ /* @__PURE__ */ n("div", { className: "panneau__corps", children: [
807
+ Q && /* @__PURE__ */ e("p", { className: "message message--" + Q.ton, role: Q.ton === "erreur" ? "alert" : "status", children: Q.texte }),
808
+ ie && /* @__PURE__ */ e("p", { className: "b-vide", children: "Rien n'attend : tout est en ligne." }),
809
+ !ie && /* @__PURE__ */ e("p", { className: "b-aide", style: { margin: "0 0 12px" }, children: "Décochez ce qui n'est pas prêt : il restera en brouillon, invisible, et vous le retrouverez ici." }),
810
+ v.collections.length > 0 && /* @__PURE__ */ e("h3", { className: "b-intertitre", children: "Collections" }),
811
+ v.collections.map((c) => G(c.UID, "collection", c.nom, void 0, ne(c.nbProduits, "bijou", "bijoux"), c.problemes)),
812
+ v.produits.length > 0 && /* @__PURE__ */ e("h3", { className: "b-intertitre", children: "Bijoux" }),
813
+ v.produits.map((c) => {
814
+ const j = Ne(c), _ = c.collections.map((B) => g.get(B) ?? null).filter(Boolean), p = c.prix ? new Intl.NumberFormat("fr-CA", { style: "currency", currency: "CAD" }).format(c.prix) : "sans prix";
815
+ return G(c.UID, "produit", c.nom, j, `${p} · ${ne(c.photos.length, "photo", "photos")}${_.length ? " · " + _.join(", ") : ""}`, c.problemes);
816
+ }),
817
+ w > 0 && /* @__PURE__ */ n(H, { children: [
818
+ /* @__PURE__ */ e("h3", { className: "b-intertitre", children: "Textes du site" }),
819
+ /* @__PURE__ */ e("div", { className: "b-pub", children: /* @__PURE__ */ n("label", { className: "b-pub__ligne", children: [
820
+ /* @__PURE__ */ e("input", { type: "checkbox", checked: l, disabled: C, onChange: () => R((c) => !c) }),
821
+ /* @__PURE__ */ e("span", { className: "b-vignette b-vignette--vide", "aria-hidden": "true", style: { width: 40, height: 40 }, children: "Aa" }),
822
+ /* @__PURE__ */ n("span", { className: "b-rangee__texte", children: [
823
+ /* @__PURE__ */ e("span", { className: "b-rangee__nom", children: ne(w, "texte modifié", "textes modifiés") }),
824
+ /* @__PURE__ */ e("span", { className: "b-rangee__meta", children: "Titres, paragraphes, prix affichés…" })
825
+ ] })
826
+ ] }) })
827
+ ] })
828
+ ] }),
829
+ /* @__PURE__ */ n("div", { className: "panneau__pied", children: [
830
+ /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--discret", onClick: E, disabled: C, children: "Fermer" }),
831
+ /* @__PURE__ */ e("span", { className: "espace" }),
832
+ /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--principal", onClick: () => {
833
+ O();
834
+ }, disabled: C || P === 0 || X.size > 0, children: C ? "Publication…" : P === 0 ? "Rien de coché" : `Publier (${P})` })
835
+ ] })
836
+ ] });
837
+ }
838
+ const Ke = 64;
839
+ function We({
840
+ produits: o,
841
+ deja: i,
842
+ nomCollection: g,
843
+ occupe: w,
844
+ surValider: I,
845
+ surAnnuler: S
846
+ }) {
847
+ const D = J(null), [E, q] = N(""), [k, L] = N(() => /* @__PURE__ */ new Set()), z = J(null), v = ze(ke(E.trim()));
848
+ ae(() => z.current?.focus(), []);
849
+ const b = Z(() => (o ?? []).map((x) => [x, ke(x.nom)]), [o]), u = Z(() => {
850
+ const x = b.filter(([, m]) => !v || m.includes(v)).map(([m]) => m);
851
+ return [...x.filter((m) => !i.has(m.UID)), ...x.filter((m) => i.has(m.UID))];
852
+ }, [b, v, i]), U = (x) => L((m) => {
853
+ const l = new Set(m);
854
+ return l.has(x) ? l.delete(x) : l.add(x), l;
855
+ });
856
+ return /* @__PURE__ */ n(H, { children: [
857
+ /* @__PURE__ */ n("div", { className: "panneau__corps", ref: D, children: [
858
+ /* @__PURE__ */ e(
859
+ "input",
860
+ {
861
+ ref: z,
862
+ className: "b-recherche",
863
+ type: "search",
864
+ value: E,
865
+ onChange: (x) => q(x.target.value),
866
+ placeholder: "Chercher un bijou…",
867
+ "aria-label": "Chercher un bijou à ajouter"
868
+ }
869
+ ),
870
+ /* @__PURE__ */ e("p", { className: "b-aide", "aria-live": "polite", style: { margin: "8px 0 10px" }, children: o === null ? "Chargement de vos bijoux…" : `${ne(u.length, "bijou", "bijoux")}${v ? " trouvés" : ""} · ${i.size} déjà dans « ${g} »` }),
871
+ o !== null && u.length === 0 && /* @__PURE__ */ e("p", { className: "b-vide", children: "Aucun bijou ne correspond." }),
872
+ /* @__PURE__ */ e(
873
+ Pe,
874
+ {
875
+ items: u,
876
+ hauteur: Ke,
877
+ conteneur: D,
878
+ cle: (x) => x.UID,
879
+ etiquette: "Bijoux à ajouter",
880
+ rendu: (x) => {
881
+ const m = i.has(x.UID), l = m || k.has(x.UID);
882
+ return /* @__PURE__ */ n("label", { className: "b-choisir" + (m ? " b-choisir--deja" : "") + (l ? " b-choisir--coche" : ""), children: [
883
+ /* @__PURE__ */ e("input", { type: "checkbox", checked: l, disabled: m, onChange: () => U(x.UID) }),
884
+ /* @__PURE__ */ e(we, { src: Ne(x), taille: 44 }),
885
+ /* @__PURE__ */ n("span", { className: "b-rangee__texte", children: [
886
+ /* @__PURE__ */ e("span", { className: "b-rangee__nom", children: x.nom || "Sans nom" }),
887
+ /* @__PURE__ */ e("span", { className: "b-rangee__meta", children: m ? "Déjà dans la collection" : `${Be(x.prix)}${x.visible ? "" : " · masqué"}` })
888
+ ] })
889
+ ] });
890
+ }
891
+ }
892
+ )
893
+ ] }),
894
+ /* @__PURE__ */ n("div", { className: "panneau__pied", children: [
895
+ /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--discret", onClick: S, disabled: w, children: "Annuler" }),
896
+ /* @__PURE__ */ e("span", { className: "espace" }),
897
+ /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--principal", disabled: w || k.size === 0, onClick: () => I([...k]), children: w ? "Un instant…" : k.size === 0 ? "Cochez des bijoux" : `Ajouter ${ne(k.size, "bijou", "bijoux")}` })
898
+ ] })
899
+ ] });
900
+ }
901
+ const Ye = `
902
+ .panneau--boutique { width: min(440px, 100vw); }
903
+ .panneau--boutique .bouton { min-height: 40px; }
904
+ @media (max-width: 520px) {
905
+ .panneau--boutique {
906
+ top: auto; left: 0; right: 0; width: auto; height: 88vh; height: 88dvh;
907
+ border-radius: 18px 18px 0 0;
908
+ }
909
+ .panneau--boutique .bouton { min-height: 44px; }
910
+ .panneau--boutique .bouton--icone { min-width: 44px; }
911
+ }
912
+ .poignee { display: none; width: 44px; height: 5px; border-radius: 3px; background: #4a505d; margin: 8px auto 0; flex: none; }
913
+ @media (max-width: 520px) { .poignee { display: block; } }
914
+
915
+ .b-tete { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--bord); }
916
+ .b-tete h2 { flex: 1; margin: 0; font-size: 16px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
917
+ .b-tete .bouton--icone { min-width: 40px; min-height: 40px; font-size: 16px; }
918
+
919
+ .b-onglets { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--bord); }
920
+ .b-onglets button {
921
+ border: 0; background: transparent; color: var(--texte-doux); font: inherit; font-weight: 600;
922
+ min-height: 44px; padding: 0 12px; cursor: pointer; border-bottom: 2px solid transparent;
923
+ }
924
+ .b-onglets button[aria-selected="true"] { color: var(--texte); border-bottom-color: var(--accent); }
925
+ .b-onglets button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
926
+ .b-onglets small { opacity: .65; margin-left: 4px; font-weight: 500; }
927
+
928
+ .b-avis {
929
+ margin: 0 0 12px; padding: 9px 11px; border-radius: 10px; font-size: 12.5px; line-height: 1.45;
930
+ background: rgba(227, 181, 91, 0.1); border: 1px solid rgba(227, 181, 91, 0.35); color: #f1d9a6;
931
+ }
932
+ .b-ajout {
933
+ width: 100%; min-height: 48px; margin-bottom: 12px; border-radius: 12px; cursor: pointer;
934
+ border: 2px dashed var(--accent); background: transparent; color: #9fe3d1; font: inherit; font-weight: 650;
935
+ }
936
+ .b-ajout:hover, .b-ajout:focus-visible { background: rgba(59, 165, 141, 0.1); outline: none; }
937
+
938
+ .b-recherche { min-height: 44px; border-radius: 10px !important; font-size: 14px !important; }
939
+ .b-filtres { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 12px; scrollbar-width: none; }
940
+ .b-puce {
941
+ flex: none; display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 12px;
942
+ border-radius: 999px; border: 1px solid var(--bord); background: transparent; color: var(--texte-doux);
943
+ font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
944
+ }
945
+ .b-puce small { opacity: .7; font-weight: 500; }
946
+ .b-puce[aria-pressed="true"] { background: rgba(59, 165, 141, 0.16); border-color: var(--accent); color: #9fe3d1; }
947
+ .b-puce:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
948
+ @media (max-width: 520px) { .b-puce { min-height: 44px; } }
949
+
950
+ .b-rangee {
951
+ display: flex; align-items: center; gap: 12px; width: 100%; height: 64px; margin-bottom: 6px; padding: 8px;
952
+ border-radius: 12px; border: 1px solid var(--bord); background: var(--fond-clair); color: var(--texte);
953
+ font: inherit; text-align: left; cursor: pointer;
954
+ }
955
+ .b-rangee:hover, .b-rangee:focus-visible { border-color: var(--accent); outline: none; }
956
+ .b-vignette { width: 48px; height: 48px; flex: none; border-radius: 9px; object-fit: cover; background: #2a2e37; display: block; }
957
+ .b-vignette--vide { display: grid; place-items: center; color: var(--texte-doux); font-size: 18px; }
958
+ .b-rangee__texte { flex: 1; min-width: 0; }
959
+ .b-rangee__nom { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
960
+ .b-rangee__meta { display: block; font-size: 12px; color: var(--texte-doux); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
961
+ .b-etiquette { flex: none; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
962
+ .b-etiquette--vente { background: rgba(59, 165, 141, 0.18); color: #8fd9c6; }
963
+ .b-etiquette--masque { background: rgba(163, 169, 182, 0.16); color: var(--texte-doux); }
964
+ .b-etiquette--vendu { background: rgba(217, 119, 106, 0.18); color: #f0b3a9; }
965
+ .b-vide { color: var(--texte-doux); font-size: 13px; padding: 18px 4px; text-align: center; }
966
+
967
+ /* ---------------------------------------------------------- FICHE ------ */
968
+ .b-section { margin-bottom: 18px; }
969
+ .b-section > h3 { margin: 0 0 8px; font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--texte-doux); }
970
+ .b-champ { margin-bottom: 12px; }
971
+ .b-champ label, .b-champ .b-etiq { display: block; margin-bottom: 5px; font-size: 12.5px; font-weight: 600; }
972
+ .b-champ label small { font-weight: 400; color: var(--texte-doux); }
973
+ .panneau--boutique input[type="text"], .panneau--boutique input[type="search"], .panneau--boutique textarea {
974
+ min-height: 44px; padding: 10px 12px; border-radius: 10px; font-size: 14px;
975
+ }
976
+ .b-champ--erreur input, .b-champ--erreur textarea { border-color: var(--danger) !important; }
977
+ .b-erreur { margin: 4px 0 0; font-size: 12px; color: #f0b3a9; }
978
+ .b-aide { margin: 4px 0 0; font-size: 11.5px; color: var(--texte-doux); }
979
+ .b-deux { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
980
+ .b-prix { position: relative; }
981
+ .b-prix span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--texte-doux); pointer-events: none; }
982
+ .b-prix input { padding-right: 28px !important; }
983
+
984
+ .b-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
985
+ .b-seg button {
986
+ min-height: 44px; border-radius: 10px; border: 1px solid var(--bord); background: var(--fond-clair);
987
+ color: var(--texte-doux); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
988
+ }
989
+ .b-seg button[aria-pressed="true"] { border-color: var(--accent); color: #9fe3d1; background: rgba(59, 165, 141, 0.14); }
990
+ .b-seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
991
+
992
+ .b-inter {
993
+ display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 10px 12px;
994
+ border-radius: 12px; background: var(--fond-clair); border: 1px solid var(--bord); color: var(--texte);
995
+ font: inherit; text-align: left; cursor: pointer;
996
+ }
997
+ .b-inter:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
998
+ .b-inter small { display: block; color: var(--texte-doux); font-size: 11.5px; font-weight: 400; }
999
+ .b-rail { position: relative; width: 46px; height: 28px; flex: none; border-radius: 999px; background: #4a505d; transition: background .15s; }
1000
+ .b-rail::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .15s; }
1001
+ [aria-checked="true"] > .b-rail { background: var(--accent); }
1002
+ [aria-checked="true"] > .b-rail::after { left: 21px; }
1003
+
1004
+ .b-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
1005
+ .b-photo { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 2px solid transparent; background: #2a2e37; }
1006
+ .b-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
1007
+ .b-photo--principale { border-color: var(--accent); }
1008
+ .b-photo__badge { position: absolute; left: 6px; bottom: 6px; background: var(--accent); color: #06120e; font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 999px; }
1009
+ .b-photo__actions { position: absolute; top: 4px; right: 4px; display: flex; gap: 4px; }
1010
+ .b-photo__actions button {
1011
+ width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
1012
+ background: rgba(22, 24, 29, 0.85); color: #fff; font: inherit; font-size: 14px;
1013
+ }
1014
+ .b-photo__actions button:hover, .b-photo__actions button:focus-visible { background: var(--accent); color: #06120e; outline: none; }
1015
+ .b-photo--envoi::after { content: "Envoi…"; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(22,24,29,.6); color: #fff; font-size: 12px; }
1016
+ .b-depot {
1017
+ grid-column: 1 / -1; padding: 14px; border-radius: 12px; border: 2px dashed #4a505d;
1018
+ text-align: center; color: var(--texte-doux); font-size: 12.5px; transition: background .12s, border-color .12s;
1019
+ }
1020
+ .b-depot--survol { border-color: var(--accent); background: rgba(59, 165, 141, 0.1); color: #9fe3d1; }
1021
+ .b-depot__boutons { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
1022
+ .b-depot__boutons label { cursor: pointer; }
1023
+ .b-depot__boutons input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
1024
+ .b-depot__boutons label:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
1025
+ .b-camera { display: none !important; }
1026
+ @media (pointer: coarse) { .b-camera { display: inline-flex !important; } .b-glisser { display: none; } }
1027
+
1028
+ .b-puces { display: flex; flex-wrap: wrap; gap: 6px; }
1029
+ .b-danger { border-top: 1px solid var(--bord); padding-top: 14px; }
1030
+ .b-danger p { margin: 0 0 8px; font-size: 12.5px; color: var(--texte-doux); }
1031
+ .bouton--danger { background: transparent; color: var(--danger); border-color: rgba(217, 119, 106, 0.5); }
1032
+ .bouton--danger:hover { background: rgba(217, 119, 106, 0.14); }
1033
+ .bouton--danger-plein { background: #b3261e; border-color: #b3261e; color: #fff; }
1034
+ .bouton--danger-plein:hover { background: #c9372e; }
1035
+ .b-confirmer { padding: 12px; border-radius: 12px; border: 1px solid rgba(217, 119, 106, 0.5); background: rgba(217, 119, 106, 0.08); }
1036
+ .b-confirmer p { margin: 0 0 10px; color: var(--texte); }
1037
+ .b-confirmer .rang { display: flex; gap: 8px; flex-wrap: wrap; }
1038
+ .b-bandeau { margin: 0 0 12px; padding: 9px 11px; border-radius: 10px; font-size: 12.5px; background: rgba(217, 119, 106, 0.12); border: 1px solid rgba(217, 119, 106, 0.4); color: #f0b3a9; }
1039
+
1040
+ /* ------------------------------------------------------ COLLECTIONS ---- */
1041
+ .b-coll { border: 1px solid var(--bord); border-radius: 12px; background: var(--fond-clair); margin-bottom: 8px; }
1042
+ .b-coll__ligne { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; min-height: 64px; }
1043
+ .b-coll__texte { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--texte); font: inherit; text-align: left; cursor: pointer; padding: 6px 0; min-height: 44px; }
1044
+ .b-coll__texte:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
1045
+ .b-coll__nom { display: block; font-weight: 600; }
1046
+ .b-coll__meta { display: block; font-size: 12px; color: var(--texte-doux); }
1047
+ .b-coll .b-inter { width: auto; min-height: 44px; padding: 0 6px; border: 0; background: transparent; }
1048
+ .b-coll__corps { border-top: 1px solid var(--bord); padding: 10px 12px 12px; }
1049
+ .b-choix { display: grid; gap: 6px; margin-top: 8px; }
1050
+ .b-mini { display: flex; align-items: center; gap: 10px; padding: 6px 0; min-height: 52px; }
1051
+ .b-mini img, .b-mini .b-vignette { width: 40px; height: 40px; }
1052
+ .b-mini span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1053
+ .b-coche { display: flex; align-items: center; gap: 10px; min-height: 48px; cursor: pointer; }
1054
+ .b-coche input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
1055
+ .b-ligne-ajout { display: flex; gap: 8px; margin-top: 8px; }
1056
+ .b-ligne-ajout input { flex: 1; }
1057
+
1058
+ /* ------------------------------------------------------- BROUILLONS ---- */
1059
+ .b-etiquette--brouillon { background: rgba(227, 181, 91, 0.18); color: #f1d9a6; }
1060
+ .b-avis--brouillon { background: rgba(59, 165, 141, 0.1); border-color: rgba(59, 165, 141, 0.4); color: #bfeadf; }
1061
+ .b-intertitre { margin: 14px 0 8px; font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--texte-doux); }
1062
+ .b-lien { border: 0; background: none; padding: 0 2px; color: #9fe3d1; font: inherit; font-weight: 650; text-decoration: underline; cursor: pointer; min-height: 32px; }
1063
+ .b-lien:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
1064
+ .b-alerte { margin: 8px 12px 0; }
1065
+ .b-aide--attention { color: #f1d9a6; }
1066
+ .b-tete .bouton--principal { min-height: 40px; }
1067
+ .panneau--boutique .panneau__pied { flex-wrap: wrap; }
1068
+ @media (max-width: 520px) {
1069
+ .panneau--boutique .panneau__pied { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
1070
+ .panneau--boutique .panneau__pied .bouton { flex: 1 1 auto; }
1071
+ .panneau--boutique .panneau__pied .espace { display: none; }
1072
+ }
1073
+
1074
+ /* ------------------------------------------------- CHOIX DU « + » ------ */
1075
+ .b-choix-grand { display: grid; gap: 10px; }
1076
+ .b-gros-choix {
1077
+ display: flex; align-items: flex-start; gap: 14px; width: 100%; min-height: 88px; padding: 14px;
1078
+ border-radius: 14px; border: 1px solid var(--bord); background: var(--fond-clair); color: var(--texte);
1079
+ font: inherit; text-align: left; cursor: pointer;
1080
+ }
1081
+ .b-gros-choix:hover, .b-gros-choix:focus-visible { border-color: var(--accent); outline: none; background: #262a32; }
1082
+ .b-gros-choix b { display: block; font-size: 15px; margin-bottom: 3px; }
1083
+ .b-gros-choix small { display: block; color: var(--texte-doux); font-size: 12.5px; line-height: 1.45; }
1084
+ .b-gros-choix__icone { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: rgba(59, 165, 141, 0.16); color: #9fe3d1; font-size: 22px; }
1085
+
1086
+ /* --------------------------------------------------------- SÉLECTEUR --- */
1087
+ .b-choisir {
1088
+ display: flex; align-items: center; gap: 12px; height: 58px; padding: 0 8px; border-radius: 12px;
1089
+ border: 1px solid transparent; cursor: pointer;
1090
+ }
1091
+ .b-choisir:hover { background: var(--fond-clair); }
1092
+ .b-choisir:focus-within { border-color: var(--accent); }
1093
+ .b-choisir input { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }
1094
+ .b-choisir--coche { background: rgba(59, 165, 141, 0.1); }
1095
+ .b-choisir--deja { opacity: .6; cursor: default; }
1096
+
1097
+ /* ------------------------------------------------- FICHE COLLECTION ---- */
1098
+ .b-niveaux { border: 0; margin: 0 0 6px; padding: 0; display: grid; gap: 6px; }
1099
+ .b-niveaux legend { margin-bottom: 6px; font-size: 12.5px; font-weight: 600; padding: 0; }
1100
+ .b-niveau {
1101
+ display: flex; align-items: flex-start; gap: 10px; min-height: 52px; padding: 10px 12px; border-radius: 12px;
1102
+ border: 1px solid var(--bord); background: var(--fond-clair); cursor: pointer;
1103
+ }
1104
+ .b-niveau input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
1105
+ .b-niveau b { display: block; font-size: 13.5px; }
1106
+ .b-niveau small { display: block; color: var(--texte-doux); font-size: 12px; }
1107
+ .b-niveau--choisi { border-color: var(--accent); background: rgba(59, 165, 141, 0.1); }
1108
+ .b-niveau:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
1109
+ .b-mini { height: 58px; padding: 0; }
1110
+ .b-mini__ouvrir {
1111
+ flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 4px;
1112
+ border: 0; border-radius: 8px; background: transparent; color: var(--texte); font: inherit; text-align: left; cursor: pointer;
1113
+ }
1114
+ .b-mini__ouvrir:hover, .b-mini__ouvrir:focus-visible { background: var(--fond-clair); outline: none; }
1115
+ .b-mini__ouvrir > span:not(.b-etiquette):not(.b-vignette) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1116
+
1117
+ /* ------------------------------------------------------------ PUBLIER --- */
1118
+ .b-pub { border: 1px solid var(--bord); border-radius: 12px; background: var(--fond-clair); margin-bottom: 8px; padding: 6px 10px 8px; }
1119
+ .b-pub__ligne { display: flex; align-items: center; gap: 10px; min-height: 52px; cursor: pointer; }
1120
+ .b-pub__ligne input { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }
1121
+ .b-pub__etat { font-size: 12px; padding-left: 32px; }
1122
+ .b-pub__etat:empty { display: none; }
1123
+ .b-pub__ok { color: #8fd9c6; font-weight: 650; }
1124
+ .b-pub__erreur { color: #f0b3a9; }
1125
+ .b-pub--ok { border-color: rgba(59, 165, 141, 0.6); }
1126
+ .b-pub--echec { border-color: rgba(217, 119, 106, 0.6); }
1127
+ .b-pub__ouvrir { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 0 0 32px; font-size: 12.5px; color: var(--texte-doux); }
1128
+ .b-pub__ouvrir select { min-height: 40px; border-radius: 10px; border: 1px solid var(--bord); background: var(--fond); color: var(--texte); font: inherit; padding: 0 8px; max-width: 100%; }
1129
+
1130
+ @media (prefers-reduced-motion: reduce) { .b-rail, .b-rail::after, .b-depot { transition: none; } }
1131
+ `, me = (o) => "brouillon" in o, De = [
1132
+ ["tous", "Tous", () => !0],
1133
+ ["brouillons", "Brouillons", (o) => me(o)],
1134
+ ["vente", "En vente", (o) => !me(o) && o.visible && !o.vendu],
1135
+ ["masques", "Masqués", (o) => !me(o) && !o.visible],
1136
+ ["vendus", "Épuisés", (o) => !me(o) && o.vendu],
1137
+ ["sans", "Sans collection", (o) => o.collections.length === 0]
1138
+ ], Ze = 70;
1139
+ function Ae(o) {
1140
+ switch (o.vue) {
1141
+ case "fiche":
1142
+ return { k: "fiche", UID: o.UID };
1143
+ case "nouveau":
1144
+ return { k: "nouveau", collection: o.collection };
1145
+ case "ajout":
1146
+ return o.collection ? { k: "choix", collection: o.collection } : { k: "nouveau", collection: null };
1147
+ case "collection":
1148
+ return { k: "collection", UID: o.UID };
1149
+ case "publier":
1150
+ return { k: "publier" };
1151
+ default:
1152
+ return { k: "liste" };
1153
+ }
1154
+ }
1155
+ function et({
1156
+ api: o,
1157
+ demande: i,
1158
+ surFermer: g,
1159
+ signaler: w,
1160
+ textes: I = 0,
1161
+ publierTextes: S,
1162
+ surCompteBrouillons: D
1163
+ }) {
1164
+ const [E, q] = N(i.vue === "liste" && i.onglet ? i.onglet : "bijoux"), [k, L] = N(null), [z, v] = N([]), [b, u] = N({ produits: [], collections: [] }), [U, x] = N(null), [m, l] = N(() => Ae(i)), [R, f] = N([]), [F, C] = N(null), [T, Q] = N(""), [K, $] = N("tous"), [ee, X] = N(!1), [P, O] = N(0), [G, ie] = N(null), c = J(null), j = J(null), _ = Ie(async () => {
1165
+ try {
1166
+ const [r, a, t] = await Promise.all([o.produits(), o.collections(), o.brouillons().catch(() => ({ produits: [], collections: [] }))]);
1167
+ L(r), v(a), u(t), x(null);
1168
+ } catch (r) {
1169
+ x(r instanceof oe ? r.message : "Impossible de lire la boutique.");
1170
+ }
1171
+ }, [o]);
1172
+ ae(() => {
1173
+ _();
1174
+ }, [_]);
1175
+ const p = b.produits.length + b.collections.length;
1176
+ ae(() => {
1177
+ D?.(p);
1178
+ }, [p, D]);
1179
+ const B = J(!0);
1180
+ ae(() => {
1181
+ if (B.current) {
1182
+ B.current = !1;
1183
+ return;
1184
+ }
1185
+ C(null), f([]), i.vue === "liste" && i.onglet && q(i.onglet), l(Ae(i));
1186
+ }, [i.n]);
1187
+ const h = (r) => {
1188
+ C(null), f((a) => [...a, m]), l(r);
1189
+ }, y = Ie(() => {
1190
+ C(null), l(R[R.length - 1] ?? { k: "liste" }), f(R.slice(0, -1));
1191
+ }, [R]);
1192
+ ae(() => {
1193
+ const r = (t) => {
1194
+ if (t.key !== "Escape") return;
1195
+ const d = t.composedPath()[0];
1196
+ d instanceof HTMLInputElement || d instanceof HTMLTextAreaElement || d instanceof HTMLSelectElement || (m.k !== "liste" ? y() : g());
1197
+ }, a = c.current;
1198
+ return a?.addEventListener("keydown", r), () => a?.removeEventListener("keydown", r);
1199
+ }, [m.k, g, y]);
1200
+ const te = (r) => L((a) => a ? a.some((t) => t.UID === r.UID) ? a.map((t) => t.UID === r.UID ? r : t) : [r, ...a] : [r]), se = (r) => u((a) => ({ ...a, produits: a.produits.some((t) => t.UID === r.UID) ? a.produits.map((t) => t.UID === r.UID ? r : t) : [r, ...a.produits] })), V = (r) => u((a) => ({ ...a, collections: a.collections.some((t) => t.UID === r.UID) ? a.collections.map((t) => t.UID === r.UID ? r : t) : [r, ...a.collections] })), Y = (r) => {
1201
+ "brouillon" in r ? V(r) : v((a) => a.some((t) => t.UID === r.UID) ? a.map((t) => t.UID === r.UID ? r : t) : [...a, r]);
1202
+ }, pe = () => o.collections().then(v).catch(() => {
1203
+ }), ge = () => o.brouillons().then(u).catch(() => {
1204
+ }), je = () => o.produits().then(L).catch(() => {
1205
+ }), xe = J(Promise.resolve()), Ce = Ie(
1206
+ (r, a) => {
1207
+ O((t) => t + a.length);
1208
+ for (const t of a)
1209
+ xe.current = xe.current.then(async () => {
1210
+ try {
1211
+ const { donnees: d, nom: s } = await $e(t);
1212
+ se(await o.photoBrouillon(r, d, s));
1213
+ } catch (d) {
1214
+ ie(`Une photo n'a pas pu partir (${d instanceof oe ? d.message : "réseau"}). Le brouillon est gardé : ajoutez-la depuis sa fiche.`);
1215
+ } finally {
1216
+ O((d) => d - 1);
1217
+ }
1218
+ });
1219
+ },
1220
+ [o]
1221
+ ), ce = Z(() => [...b.produits, ...k ?? []], [b.produits, k]), fe = Z(() => ce.map((r) => [r, ke(r.nom)]), [ce]), de = Z(() => Object.fromEntries(De.map(([r, , a]) => [r, ce.filter(a).length])), [ce]), be = ze(ke(T.trim())), ve = ze(K), he = Z(() => {
1222
+ const r = De.find(([a]) => a === ve)?.[2] ?? (() => !0);
1223
+ return fe.filter(([a, t]) => r(a) && (!be || t.includes(be))).map(([a]) => a);
1224
+ }, [fe, be, ve]), re = Z(() => {
1225
+ const r = /* @__PURE__ */ new Map();
1226
+ for (const a of z) r.set(a.UID, a.nom);
1227
+ for (const a of b.collections) r.set(a.UID, a.nom);
1228
+ return r;
1229
+ }, [z, b.collections]), A = Z(() => [...b.collections, ...z], [b.collections, z]), Ue = (() => {
1230
+ switch (m.k) {
1231
+ case "fiche":
1232
+ case "nouveau": {
1233
+ const r = m.k === "fiche" ? m.UID : null, a = r ? (qe(r) ? b.produits.find((t) => t.UID === r) : k?.find((t) => t.UID === r)) ?? null : null;
1234
+ return r && !a ? /* @__PURE__ */ n("div", { className: "panneau__corps", children: [
1235
+ /* @__PURE__ */ e("p", { className: "b-vide", children: U ?? (k ? "Ce bijou est introuvable (déjà publié ou supprimé ?)." : "Chargement…") }),
1236
+ /* @__PURE__ */ e("button", { type: "button", className: "bouton", onClick: () => l({ k: "liste" }), children: "Voir tous les bijoux" })
1237
+ ] }) : /* @__PURE__ */ e(
1238
+ Xe,
1239
+ {
1240
+ api: o,
1241
+ produit: a,
1242
+ collections: A,
1243
+ collectionDefaut: m.k === "nouveau" ? m.collection : null,
1244
+ annonce: F,
1245
+ signaler: w,
1246
+ photosEnCours: P,
1247
+ compteBrouillons: b.produits.length,
1248
+ envoyerEnArrierePlan: Ce,
1249
+ surRetour: y,
1250
+ surFermer: g,
1251
+ surEnregistre: (t) => {
1252
+ if (me(t)) se(t);
1253
+ else {
1254
+ const d = k?.find((s) => s.UID === t.UID);
1255
+ te(t), JSON.stringify(d?.collections) !== JSON.stringify(t.collections) && pe();
1256
+ }
1257
+ },
1258
+ surSupprime: (t) => {
1259
+ qe(t) ? u((d) => ({ ...d, produits: d.produits.filter((s) => s.UID !== t) })) : (L((d) => d?.filter((s) => s.UID !== t) ?? null), pe()), y();
1260
+ }
1261
+ },
1262
+ r ?? "nouveau"
1263
+ );
1264
+ }
1265
+ case "choix":
1266
+ return /* @__PURE__ */ n(H, { children: [
1267
+ /* @__PURE__ */ n("div", { className: "b-tete", children: [
1268
+ /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--icone bouton--discret", onClick: y, "aria-label": "Retour", children: "←" }),
1269
+ /* @__PURE__ */ n("h2", { tabIndex: -1, children: [
1270
+ "Ajouter à « ",
1271
+ m.collection.nom,
1272
+ " »"
1273
+ ] })
1274
+ ] }),
1275
+ /* @__PURE__ */ e("div", { className: "panneau__corps", children: /* @__PURE__ */ n("div", { className: "b-choix-grand", children: [
1276
+ /* @__PURE__ */ n("button", { type: "button", className: "b-gros-choix", autoFocus: !0, onClick: () => h({ k: "selecteur", collection: m.collection.UID }), children: [
1277
+ /* @__PURE__ */ e("span", { className: "b-gros-choix__icone", "aria-hidden": "true", children: "▤" }),
1278
+ /* @__PURE__ */ n("span", { children: [
1279
+ /* @__PURE__ */ e("b", { children: "Ajouter un bijou existant" }),
1280
+ /* @__PURE__ */ n("small", { children: [
1281
+ "Choisir parmi vos ",
1282
+ k ? ne(k.length, "bijou", "bijoux") : "bijoux",
1283
+ " ; ils rejoignent « ",
1284
+ m.collection.nom,
1285
+ " »."
1286
+ ] })
1287
+ ] })
1288
+ ] }),
1289
+ /* @__PURE__ */ n("button", { type: "button", className: "b-gros-choix", onClick: () => h({ k: "nouveau", collection: m.collection.UID }), children: [
1290
+ /* @__PURE__ */ e("span", { className: "b-gros-choix__icone", "aria-hidden": "true", children: "+" }),
1291
+ /* @__PURE__ */ n("span", { children: [
1292
+ /* @__PURE__ */ e("b", { children: "Créer un nouveau bijou" }),
1293
+ /* @__PURE__ */ n("small", { children: [
1294
+ "Rangé en brouillon dans « ",
1295
+ m.collection.nom,
1296
+ " » ; vous en créez plusieurs d'affilée, et vous publiez quand vous voulez."
1297
+ ] })
1298
+ ] })
1299
+ ] })
1300
+ ] }) })
1301
+ ] });
1302
+ case "selecteur": {
1303
+ const r = m.collection, a = b.collections.find((s) => s.UID === r), t = a ?? z.find((s) => s.UID === r), d = new Set(a ? a.produits : (k ?? []).filter((s) => s.collections.includes(r)).map((s) => s.UID));
1304
+ return /* @__PURE__ */ n(H, { children: [
1305
+ /* @__PURE__ */ n("div", { className: "b-tete", children: [
1306
+ /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--icone bouton--discret", onClick: y, "aria-label": "Retour", children: "←" }),
1307
+ /* @__PURE__ */ n("h2", { tabIndex: -1, children: [
1308
+ "Bijoux existants → « ",
1309
+ t?.nom ?? "collection",
1310
+ " »"
1311
+ ] })
1312
+ ] }),
1313
+ /* @__PURE__ */ e(
1314
+ tt,
1315
+ {
1316
+ produits: k,
1317
+ deja: d,
1318
+ nomCollection: t?.nom ?? "",
1319
+ occupe: ee,
1320
+ surAnnuler: y,
1321
+ surValider: async (s) => {
1322
+ X(!0);
1323
+ try {
1324
+ if (a) V(await o.modifierBrouillon(r, { produits: [...a.produits, ...s] }));
1325
+ else {
1326
+ const M = await o.garnirCollection(r, s, []);
1327
+ M && Y(M), L((W) => W?.map((le) => s.includes(le.UID) && !le.collections.includes(r) ? { ...le, collections: [...le.collections, r] } : le) ?? W), w({ quoi: "collection", UID: r, action: "ajoute" });
1328
+ }
1329
+ f([]), C(`${ne(s.length, "bijou ajouté", "bijoux ajoutés")} à « ${t?.nom} »${a ? " (brouillon)" : " — en ligne maintenant"}.`), l({ k: "collection", UID: r });
1330
+ } catch (M) {
1331
+ ie(M instanceof oe ? M.message : "L'ajout a échoué. Rien n'a changé.");
1332
+ } finally {
1333
+ X(!1);
1334
+ }
1335
+ }
1336
+ }
1337
+ )
1338
+ ] });
1339
+ }
1340
+ case "collection": {
1341
+ const r = (qe(m.UID) ? b.collections.find((a) => a.UID === m.UID) : z.find((a) => a.UID === m.UID)) ?? null;
1342
+ return r ? /* @__PURE__ */ e(
1343
+ He,
1344
+ {
1345
+ api: o,
1346
+ collection: r,
1347
+ annonce: F,
1348
+ produits: k,
1349
+ brouillonsProduits: b.produits,
1350
+ signaler: w,
1351
+ surRetour: y,
1352
+ majCollection: Y,
1353
+ majProduits: () => {
1354
+ je();
1355
+ },
1356
+ majBrouillons: () => {
1357
+ ge();
1358
+ },
1359
+ surAjouterExistants: () => h({ k: "selecteur", collection: r.UID }),
1360
+ surCreer: () => h({ k: "nouveau", collection: r.UID }),
1361
+ surOuvrirProduit: (a) => h({ k: "fiche", UID: a })
1362
+ }
1363
+ ) : /* @__PURE__ */ n("div", { className: "panneau__corps", children: [
1364
+ /* @__PURE__ */ e("p", { className: "b-vide", children: k ? "Cette collection est introuvable (déjà publiée ou supprimée ?)." : "Chargement…" }),
1365
+ /* @__PURE__ */ e("button", { type: "button", className: "bouton", onClick: () => {
1366
+ q("collections"), l({ k: "liste" });
1367
+ }, children: "Voir les collections" })
1368
+ ] });
1369
+ }
1370
+ case "publier":
1371
+ return /* @__PURE__ */ e(
1372
+ Ge,
1373
+ {
1374
+ api: o,
1375
+ brouillons: b,
1376
+ noms: re,
1377
+ textes: I,
1378
+ publierTextes: S ?? (async () => !0),
1379
+ surRetour: y,
1380
+ surOuvrir: (r, a) => h(a === "produit" ? { k: "fiche", UID: r } : { k: "collection", UID: r }),
1381
+ surPublie: (r) => {
1382
+ const a = r.filter((t) => t.ok);
1383
+ if (a.length) {
1384
+ for (const t of a) w({ quoi: t.type === "collection" ? "collection" : "produit", UID: t.publieUID ?? null, action: "cree" });
1385
+ _();
1386
+ }
1387
+ }
1388
+ }
1389
+ );
1390
+ default:
1391
+ return null;
1392
+ }
1393
+ })();
1394
+ return /* @__PURE__ */ n("div", { ref: c, className: "panneau panneau--boutique", role: "dialog", "aria-modal": "false", "aria-label": "Boutique", children: [
1395
+ /* @__PURE__ */ e("style", { children: Ye }),
1396
+ /* @__PURE__ */ e("div", { className: "poignee", "aria-hidden": "true" }),
1397
+ G && /* @__PURE__ */ n("p", { className: "message message--erreur b-alerte", role: "alert", children: [
1398
+ G,
1399
+ " ",
1400
+ /* @__PURE__ */ e("button", { type: "button", className: "b-lien", onClick: () => ie(null), children: "OK" })
1401
+ ] }),
1402
+ m.k !== "liste" ? Ue : /* @__PURE__ */ n(H, { children: [
1403
+ /* @__PURE__ */ n("div", { className: "b-tete", children: [
1404
+ /* @__PURE__ */ e("h2", { children: "Boutique" }),
1405
+ p + I > 0 && /* @__PURE__ */ n("button", { type: "button", className: "bouton bouton--principal", onClick: () => h({ k: "publier" }), "aria-label": `Publier : ${p + I} en attente`, children: [
1406
+ "Publier ",
1407
+ /* @__PURE__ */ e("span", { className: "barre__pastille", children: p + I })
1408
+ ] }),
1409
+ /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--icone bouton--discret", onClick: g, "aria-label": "Fermer la boutique", children: "✕" })
1410
+ ] }),
1411
+ /* @__PURE__ */ n("div", { className: "b-onglets", role: "tablist", "aria-label": "Objets de la boutique", children: [
1412
+ /* @__PURE__ */ n("button", { type: "button", role: "tab", "aria-selected": E === "bijoux", onClick: () => q("bijoux"), children: [
1413
+ "Bijoux",
1414
+ /* @__PURE__ */ e("small", { children: k?.length ?? "" })
1415
+ ] }),
1416
+ /* @__PURE__ */ n("button", { type: "button", role: "tab", "aria-selected": E === "collections", onClick: () => q("collections"), children: [
1417
+ "Collections",
1418
+ /* @__PURE__ */ e("small", { children: z.length + b.collections.length || "" })
1419
+ ] })
1420
+ ] }),
1421
+ /* @__PURE__ */ n("div", { className: "panneau__corps", role: "tabpanel", ref: j, children: [
1422
+ U && /* @__PURE__ */ n("p", { className: "message message--erreur", role: "alert", children: [
1423
+ U,
1424
+ " ",
1425
+ /* @__PURE__ */ e("button", { type: "button", className: "bouton bouton--discret", onClick: () => {
1426
+ _();
1427
+ }, children: "Réessayer" })
1428
+ ] }),
1429
+ E === "bijoux" ? /* @__PURE__ */ n(H, { children: [
1430
+ /* @__PURE__ */ n("p", { className: "b-avis", role: "note", children: [
1431
+ "⚡ Corriger un bijou en ligne est ",
1432
+ /* @__PURE__ */ e("b", { children: "en ligne tout de suite" }),
1433
+ ". Un ",
1434
+ /* @__PURE__ */ e("b", { children: "nouveau" }),
1435
+ " bijou est rangé en brouillon, invisible, jusqu'à « Publier »."
1436
+ ] }),
1437
+ /* @__PURE__ */ e("button", { type: "button", className: "b-ajout", onClick: () => {
1438
+ C(null), h({ k: "nouveau", collection: null });
1439
+ }, children: "+ Ajouter des bijoux" }),
1440
+ /* @__PURE__ */ e(
1441
+ "input",
1442
+ {
1443
+ className: "b-recherche",
1444
+ type: "search",
1445
+ value: T,
1446
+ onChange: (r) => Q(r.target.value),
1447
+ placeholder: "Chercher un bijou…",
1448
+ "aria-label": "Chercher un bijou par son nom"
1449
+ }
1450
+ ),
1451
+ /* @__PURE__ */ e("div", { className: "b-filtres", role: "group", "aria-label": "Filtrer les bijoux", children: De.map(
1452
+ ([r, a]) => r === "brouillons" && !de[r] ? null : /* @__PURE__ */ n("button", { type: "button", className: "b-puce", "aria-pressed": K === r, onClick: () => $(r), children: [
1453
+ a,
1454
+ /* @__PURE__ */ e("small", { children: de[r] })
1455
+ ] }, r)
1456
+ ) }),
1457
+ k === null && !U && /* @__PURE__ */ e("p", { className: "b-vide", children: "Chargement de vos bijoux…" }),
1458
+ k !== null && he.length === 0 && /* @__PURE__ */ n("p", { className: "b-vide", children: [
1459
+ ce.length === 0 ? "Aucun bijou pour l'instant. Ajoutez le premier !" : "Aucun bijou ne correspond.",
1460
+ (T || K !== "tous") && ce.length > 0 && /* @__PURE__ */ n(H, { children: [
1461
+ " ",
1462
+ /* @__PURE__ */ e("button", { type: "button", className: "b-puce", onClick: () => {
1463
+ Q(""), $("tous");
1464
+ }, children: "Tout montrer" })
1465
+ ] })
1466
+ ] }),
1467
+ /* @__PURE__ */ e(
1468
+ Pe,
1469
+ {
1470
+ items: he,
1471
+ hauteur: Ze,
1472
+ conteneur: j,
1473
+ cle: (r) => r.UID,
1474
+ etiquette: "Vos bijoux",
1475
+ rendu: (r) => /* @__PURE__ */ e(nt, { p: r, noms: re, ouvrir: (a) => {
1476
+ C(null), h({ k: "fiche", UID: a });
1477
+ } })
1478
+ }
1479
+ )
1480
+ ] }) : /* @__PURE__ */ e(
1481
+ Te,
1482
+ {
1483
+ api: o,
1484
+ collections: z,
1485
+ brouillons: b.collections,
1486
+ surOuvrir: (r) => h({ k: "collection", UID: r }),
1487
+ surCree: (r) => {
1488
+ V(r), h({ k: "collection", UID: r.UID });
1489
+ }
1490
+ }
1491
+ )
1492
+ ] })
1493
+ ] })
1494
+ ] });
1495
+ }
1496
+ const tt = _e(We), nt = _e(function({ p: i, noms: g, ouvrir: w }) {
1497
+ const I = me(i), S = I ? ["brouillon", "Brouillon"] : Fe(i), D = i.collections.map((E) => g.get(E)).filter(Boolean).join(", ");
1498
+ return /* @__PURE__ */ n("button", { type: "button", className: "b-rangee", onClick: () => w(i.UID), children: [
1499
+ /* @__PURE__ */ e(we, { src: Ne(i) }),
1500
+ /* @__PURE__ */ n("span", { className: "b-rangee__texte", children: [
1501
+ /* @__PURE__ */ e("span", { className: "b-rangee__nom", children: i.nom || "Sans nom" }),
1502
+ /* @__PURE__ */ e("span", { className: "b-rangee__meta", children: I && i.problemes.length ? `À compléter : ${i.problemes.join(" ").toLowerCase()}` : `${i.prix ? Be(i.prix) : "sans prix"} · ${Me(i)} · ${D || "aucune collection"}` })
1503
+ ] }),
1504
+ /* @__PURE__ */ e("span", { className: "b-etiquette b-etiquette--" + S[0], children: S[1] })
1505
+ ] });
1506
+ }), lt = _e(et);
1507
+ export {
1508
+ lt as default
1509
+ };