@marktiderman/genesis-sites 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.
Files changed (64) hide show
  1. package/README.md +128 -11
  2. package/SKILL.md +5 -0
  3. package/dist/analytics.d.ts +184 -0
  4. package/dist/analytics.js +3 -0
  5. package/dist/analytics.js.map +1 -0
  6. package/dist/assets/islands.399b13ea6f.js +1 -0
  7. package/dist/assets/sites-forms.b64c156079.css +10 -0
  8. package/dist/assets/sites-forms.css +1 -1
  9. package/dist/assets/sites.2fac65f96a.css +2 -0
  10. package/dist/assets/sites.css +1 -1
  11. package/dist/assets.generated-ZBFSP23U.js +3 -0
  12. package/dist/{assets.generated-YGLB7VKL.js.map → assets.generated-ZBFSP23U.js.map} +1 -1
  13. package/dist/{chunk-MXV2HOJO.js → chunk-5G2H6EZ2.js} +6 -6
  14. package/dist/chunk-5G2H6EZ2.js.map +1 -0
  15. package/dist/chunk-5RYCQEEE.js +256 -0
  16. package/dist/chunk-5RYCQEEE.js.map +1 -0
  17. package/dist/{chunk-FMQTSXJN.js → chunk-ATRS5GSD.js} +60 -19
  18. package/dist/chunk-ATRS5GSD.js.map +1 -0
  19. package/dist/{chunk-MU2Z2C4F.js → chunk-CXBBUKGB.js} +14 -4
  20. package/dist/chunk-CXBBUKGB.js.map +1 -0
  21. package/dist/{chunk-6CXTOPYI.js → chunk-QGU6FDH5.js} +74 -8
  22. package/dist/chunk-QGU6FDH5.js.map +1 -0
  23. package/dist/{chunk-I767PDBR.js → chunk-SBONYMUC.js} +38 -15
  24. package/dist/chunk-SBONYMUC.js.map +1 -0
  25. package/dist/{chunk-YAMQ2JKO.js → chunk-UOKNFG5O.js} +127 -14
  26. package/dist/chunk-UOKNFG5O.js.map +1 -0
  27. package/dist/{chunk-QE7KS2JS.js → chunk-UUC5USJH.js} +8 -45
  28. package/dist/chunk-UUC5USJH.js.map +1 -0
  29. package/dist/editor.d.ts +63 -14
  30. package/dist/editor.js +682 -254
  31. package/dist/editor.js.map +1 -1
  32. package/dist/handler-OR554RTS.js +11 -0
  33. package/dist/{handler-J5BCH2VW.js.map → handler-OR554RTS.js.map} +1 -1
  34. package/dist/import.d.ts +3 -3
  35. package/dist/import.js +1 -1
  36. package/dist/index.d.ts +23 -9
  37. package/dist/index.js +4 -4
  38. package/dist/{redirects-BNSD9MKa.d.ts → redirects-LcCNIJHQ.d.ts} +2 -2
  39. package/dist/{registry-BPn-tDlL.d.ts → registry-Cw7NF_le.d.ts} +17 -1
  40. package/dist/sections.d.ts +1 -1
  41. package/dist/sections.js +3 -3
  42. package/dist/{store-B_GMH42V.d.ts → store-BNYD5NAQ.d.ts} +30 -4
  43. package/dist/supabase.d.ts +4 -4
  44. package/dist/supabase.js +4 -4
  45. package/dist/{templates-CFSSG1iU.d.ts → templates-DPv0OYLl.d.ts} +2 -2
  46. package/dist/templates.d.ts +3 -3
  47. package/dist/templates.js +7 -3
  48. package/dist/templates.js.map +1 -1
  49. package/dist/{theme-Dw42GDI_.d.ts → theme-HJzN2tOm.d.ts} +2 -2
  50. package/dist/web.d.ts +49 -13
  51. package/dist/web.js +7 -6
  52. package/package.json +6 -2
  53. package/dist/assets/islands.83aaf5e0df.js +0 -1
  54. package/dist/assets/sites-forms.bac9a6aafd.css +0 -10
  55. package/dist/assets/sites.323090ba26.css +0 -2
  56. package/dist/assets.generated-YGLB7VKL.js +0 -3
  57. package/dist/chunk-6CXTOPYI.js.map +0 -1
  58. package/dist/chunk-FMQTSXJN.js.map +0 -1
  59. package/dist/chunk-I767PDBR.js.map +0 -1
  60. package/dist/chunk-MU2Z2C4F.js.map +0 -1
  61. package/dist/chunk-MXV2HOJO.js.map +0 -1
  62. package/dist/chunk-QE7KS2JS.js.map +0 -1
  63. package/dist/chunk-YAMQ2JKO.js.map +0 -1
  64. package/dist/handler-J5BCH2VW.js +0 -10
package/dist/editor.js CHANGED
@@ -1,10 +1,10 @@
1
- import { starterSite, exampleBrands, landingDirectory, landingPath, landingSlugProblems, landingDirectoryProblems, landingMoves, redirectDestinations, isLandingPage, landingPage, removeRedirect, landingPages, redirectFromProblems, redirectToProblems, upsertRedirect, landingSlugOf } from './chunk-QE7KS2JS.js';
2
- import './chunk-I767PDBR.js';
1
+ import { starterSite, exampleBrands, redirectDestinations, landingPage, removeRedirect, redirectFromProblems, redirectToProblems, upsertRedirect } from './chunk-UUC5USJH.js';
2
+ import './chunk-SBONYMUC.js';
3
3
  import './chunk-VZUDRPFG.js';
4
- import { stableHash, isConflict, prepareRelease, PublishBlockedError, SiteConflictError, siteTheme, brandDisplayName, themeCss, migrateNode, migratePage, migrateSite } from './chunk-YAMQ2JKO.js';
5
- import { getSection, sectionJsonSchema, listSections, SECTION_CATEGORIES, NOT_FOUND_PATH, PageDoc, SiteDoc, notFoundPageDoc, newSectionId, isNotFoundPage, SeoDefaults } from './chunk-6CXTOPYI.js';
6
- import { isSafeImageSrc, DEFAULT_RESERVED_PATHS, pagePathProblems, isSafeHref } from './chunk-MU2Z2C4F.js';
7
- import * as React10 from 'react';
4
+ import { stableHash, isConflict, prepareRelease, PublishBlockedError, applyCheckLevels, landingDirectory, landingPath, landingSlugProblems, landingDirectoryProblems, landingMoves, SiteConflictError, siteTheme, brandDisplayName, themeCss, isLandingPage, migrateNode, landingPages, migratePage, migrateSite, landingSlugOf, pageWindowProblems } from './chunk-UOKNFG5O.js';
5
+ import { getSection, sectionJsonSchema, listSections, SECTION_CATEGORIES, NOT_FOUND_PATH, PageDoc, SiteDoc, notFoundPageDoc, newSectionId, isNotFoundPage, SeoDefaults, sampleImage } from './chunk-QGU6FDH5.js';
6
+ import { isSafeImageSrc, DEFAULT_RESERVED_PATHS, pagePathProblems, isSafeHref } from './chunk-CXBBUKGB.js';
7
+ import * as React11 from 'react';
8
8
  import { createContext, useContext } from 'react';
9
9
  import { createUsePuck, Puck } from '@puckeditor/core';
10
10
  export { createUsePuck, usePuck } from '@puckeditor/core';
@@ -22,10 +22,10 @@ import { Label } from '@marktiderman/genesis-ui/label';
22
22
  import { Switch } from '@marktiderman/genesis-ui/switch';
23
23
  import { Textarea } from '@marktiderman/genesis-ui/textarea';
24
24
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
25
+ import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from '@marktiderman/genesis-ui/select';
25
26
  import { RichTextEditor } from '@marktiderman/genesis-ui/rich-text-editor';
26
27
  import { Badge } from '@marktiderman/genesis-ui/badge';
27
28
  import { RadioGroup, RadioGroupItem } from '@marktiderman/genesis-ui/radio-group';
28
- import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from '@marktiderman/genesis-ui/select';
29
29
  import { Separator } from '@marktiderman/genesis-ui/separator';
30
30
  import { Checkbox } from '@marktiderman/genesis-ui/checkbox';
31
31
  import { Combobox } from '@marktiderman/genesis-ui/combobox';
@@ -49,18 +49,18 @@ function uploadProblem(file, maxBytes = 10 * 1024 * 1024) {
49
49
  }
50
50
  function AssetPicker({ open, siteId, store, assets, current, altElsewhere = false, onDone }) {
51
51
  const canUpload = Boolean(assets?.upload || store.putAsset);
52
- const [tab, setTab] = React10.useState(canUpload ? "upload" : "link");
53
- const [file, setFile] = React10.useState(null);
54
- const [url, setUrl] = React10.useState(current?.src ?? "");
55
- const [chosen, setChosen] = React10.useState(null);
56
- const [alt, setAlt] = React10.useState(current?.alt ?? "");
57
- const [decorative, setDecorative] = React10.useState(current?.decorative === true);
58
- const [library, setLibrary] = React10.useState(null);
59
- const [uploaded, setUploaded] = React10.useState([]);
60
- const [busy, setBusy] = React10.useState(false);
61
- const [error, setError] = React10.useState(null);
62
- const id = React10.useId();
63
- React10.useEffect(() => {
52
+ const [tab, setTab] = React11.useState(canUpload ? "upload" : "link");
53
+ const [file, setFile] = React11.useState(null);
54
+ const [url, setUrl] = React11.useState(current?.src ?? "");
55
+ const [chosen, setChosen] = React11.useState(null);
56
+ const [alt, setAlt] = React11.useState(current?.alt ?? "");
57
+ const [decorative, setDecorative] = React11.useState(current?.decorative === true);
58
+ const [library, setLibrary] = React11.useState(null);
59
+ const [uploaded, setUploaded] = React11.useState([]);
60
+ const [busy, setBusy] = React11.useState(false);
61
+ const [error, setError] = React11.useState(null);
62
+ const id = React11.useId();
63
+ React11.useEffect(() => {
64
64
  if (!open) return;
65
65
  setFile(null);
66
66
  setChosen(null);
@@ -112,39 +112,73 @@ function AssetPicker({ open, siteId, store, assets, current, altElsewhere = fals
112
112
  return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: (o) => o ? null : onDone(null), children: /* @__PURE__ */ jsxs(DialogContent, { className: "sm:max-w-lg", children: [
113
113
  /* @__PURE__ */ jsxs(DialogHeader, { children: [
114
114
  /* @__PURE__ */ jsx(DialogTitle, { children: "Choose an image" }),
115
- /* @__PURE__ */ jsx(DialogDescription, { children: "Upload one, pick one the site has, or link one. Every image needs alt text unless it's decorative." })
115
+ /* @__PURE__ */ jsx(DialogDescription, { children: altElsewhere ? "Upload one, pick one the site has, or link one. You describe it in its Alt text field after." : "Upload one, pick one the site has, or link one, and describe it for people who can't see it." })
116
116
  ] }),
117
- /* @__PURE__ */ jsxs(Tabs, { defaultValue: "upload", value: tab, onValueChange: setTab, children: [
118
- /* @__PURE__ */ jsxs(TabsList, { className: "grid w-full grid-cols-3", children: [
119
- /* @__PURE__ */ jsx(TabsTrigger, { value: "upload", disabled: !canUpload, children: "Upload" }),
120
- /* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: "Library" }),
121
- /* @__PURE__ */ jsx(TabsTrigger, { value: "link", children: "Link" })
122
- ] }),
123
- /* @__PURE__ */ jsxs(TabsContent, { value: "upload", className: "flex flex-col gap-2 pt-2", children: [
124
- /* @__PURE__ */ jsx(Label, { htmlFor: `${id}-file`, children: "Image file" }),
125
- /* @__PURE__ */ jsx(Input, { id: `${id}-file`, type: "file", accept: IMAGE_TYPES.join(","), onChange: (e) => setFile(e.currentTarget.files?.[0] ?? null) }),
126
- !canUpload ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "This site's store doesn't take uploads; link an image instead." }) : null
127
- ] }),
128
- /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "pt-2", children: all.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: library === null && assets?.list ? "Loading\u2026" : "No images yet. Upload one first." }) : /* @__PURE__ */ jsx("div", { role: "group", "aria-label": "Site images", className: "grid max-h-64 grid-cols-3 gap-2 overflow-y-auto", children: all.map((a) => /* @__PURE__ */ jsx(
129
- "button",
130
- {
131
- type: "button",
132
- "aria-pressed": chosen?.id === a.id,
133
- "aria-label": a.alt?.trim() || a.path.split("/").pop() || "Image",
134
- onClick: () => {
135
- setChosen(a);
136
- if (a.alt && !alt) setAlt(a.alt);
137
- },
138
- className: cn("overflow-hidden rounded-md border-2 focus-visible:outline-2 focus-visible:outline-ring", chosen?.id === a.id ? "border-primary" : "border-transparent"),
139
- children: isSafeImageSrc(a.url) ? /* @__PURE__ */ jsx("img", { src: a.url, alt: a.alt ?? "", className: "h-20 w-full object-cover" }) : /* @__PURE__ */ jsx("span", { className: "p-2 text-xs", children: a.path })
117
+ /* @__PURE__ */ jsxs(
118
+ Tabs,
119
+ {
120
+ defaultValue: "upload",
121
+ value: tab,
122
+ onValueChange: (t) => {
123
+ setError(null);
124
+ setTab(t);
140
125
  },
141
- a.id
142
- )) }) }),
143
- /* @__PURE__ */ jsxs(TabsContent, { value: "link", className: "flex flex-col gap-2 pt-2", children: [
144
- /* @__PURE__ */ jsx(Label, { htmlFor: `${id}-url`, children: "Image address" }),
145
- /* @__PURE__ */ jsx(Input, { id: `${id}-url`, value: url, placeholder: "https://\u2026 or /images/photo.jpg", onChange: (e) => setUrl(e.currentTarget.value) })
146
- ] })
147
- ] }),
126
+ children: [
127
+ /* @__PURE__ */ jsxs(TabsList, { className: "grid w-full grid-cols-3", children: [
128
+ /* @__PURE__ */ jsx(TabsTrigger, { value: "upload", disabled: !canUpload, children: "Upload" }),
129
+ /* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: "Library" }),
130
+ /* @__PURE__ */ jsx(TabsTrigger, { value: "link", children: "Link" })
131
+ ] }),
132
+ /* @__PURE__ */ jsxs(TabsContent, { value: "upload", className: "flex flex-col gap-2 pt-2", children: [
133
+ /* @__PURE__ */ jsx(Label, { htmlFor: `${id}-file`, children: "Image file" }),
134
+ /* @__PURE__ */ jsx(
135
+ Input,
136
+ {
137
+ id: `${id}-file`,
138
+ type: "file",
139
+ accept: IMAGE_TYPES.join(","),
140
+ onChange: (e) => {
141
+ setError(null);
142
+ setFile(e.currentTarget.files?.[0] ?? null);
143
+ }
144
+ }
145
+ ),
146
+ !canUpload ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "This site's store doesn't take uploads; link an image instead." }) : null
147
+ ] }),
148
+ /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "pt-2", children: all.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: library === null && assets?.list ? "Loading\u2026" : "No images yet. Upload one first." }) : /* @__PURE__ */ jsx("div", { role: "group", "aria-label": "Site images", className: "grid max-h-64 grid-cols-3 gap-2 overflow-y-auto", children: all.map((a) => /* @__PURE__ */ jsx(
149
+ "button",
150
+ {
151
+ type: "button",
152
+ "aria-pressed": chosen?.id === a.id,
153
+ "aria-label": a.alt?.trim() || a.path.split("/").pop() || "Image",
154
+ onClick: () => {
155
+ setError(null);
156
+ setChosen(a);
157
+ if (a.alt && !alt) setAlt(a.alt);
158
+ },
159
+ className: cn("overflow-hidden rounded-md border-2 focus-visible:outline-2 focus-visible:outline-ring", chosen?.id === a.id ? "border-primary" : "border-transparent"),
160
+ children: isSafeImageSrc(a.url) ? /* @__PURE__ */ jsx("img", { src: a.url, alt: a.alt ?? "", className: "h-20 w-full object-cover" }) : /* @__PURE__ */ jsx("span", { className: "flex h-20 items-center justify-center break-all p-2 text-xs text-muted-foreground", children: a.path.split("/").pop() })
161
+ },
162
+ a.id
163
+ )) }) }),
164
+ /* @__PURE__ */ jsxs(TabsContent, { value: "link", className: "flex flex-col gap-2 pt-2", children: [
165
+ /* @__PURE__ */ jsx(Label, { htmlFor: `${id}-url`, children: "Image address" }),
166
+ /* @__PURE__ */ jsx(
167
+ Input,
168
+ {
169
+ id: `${id}-url`,
170
+ value: url,
171
+ placeholder: "https://\u2026 or /images/photo.jpg",
172
+ onChange: (e) => {
173
+ setError(null);
174
+ setUrl(e.currentTarget.value);
175
+ }
176
+ }
177
+ )
178
+ ] })
179
+ ]
180
+ }
181
+ ),
148
182
  altElsewhere ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Describe the image in the item's Alt text field, after you choose it." }) : /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
149
183
  /* @__PURE__ */ jsx(Label, { htmlFor: `${id}-alt`, children: "Alt text" }),
150
184
  /* @__PURE__ */ jsx(Textarea, { id: `${id}-alt`, rows: 2, maxLength: 300, value: alt, disabled: decorative, "aria-invalid": altInvalid || void 0, "aria-describedby": `${id}-alt-hint`, onChange: (e) => setAlt(e.currentTarget.value), placeholder: "Two people stretching on mats by a window" }),
@@ -373,6 +407,12 @@ function currentProps(node) {
373
407
  }
374
408
  return { props, v: def.version };
375
409
  }
410
+ function componentNameOf(node) {
411
+ const def = getSection(node.type);
412
+ if (!def || !node.variant) return node.type;
413
+ const index = def.presets.findIndex((p) => p.variant === node.variant);
414
+ return index > 0 ? presetComponentName(node.type, index) : node.type;
415
+ }
376
416
  function nodeToItem(node, slotKeys = noSlots) {
377
417
  const current = currentProps(node);
378
418
  const props = { ...current.props };
@@ -380,16 +420,21 @@ function nodeToItem(node, slotKeys = noSlots) {
380
420
  const nested = props[key];
381
421
  if (Array.isArray(nested)) props[key] = nested.map((n) => nodeToItem(n, slotKeys));
382
422
  }
423
+ const unset = {};
424
+ for (const preset of getSection(node.type)?.presets ?? []) {
425
+ for (const key of Object.keys(preset.props ?? {})) if (!(key in props)) unset[key] = void 0;
426
+ }
383
427
  return {
384
- type: node.type,
428
+ type: componentNameOf(node),
385
429
  props: {
430
+ ...unset,
386
431
  ...props,
387
432
  id: node.id,
388
433
  _v: current.v,
389
- ...node.variant ? { _variant: node.variant } : {},
434
+ _variant: node.variant,
390
435
  _hidden: node.hidden === true,
391
436
  _hideOn: node.hideOn?.length ? hideOnValue(node.hideOn) : "none",
392
- ...node.placeholder ? { _placeholder: true } : {}
437
+ _placeholder: node.placeholder ? structuredClone(current.props) : void 0
393
438
  }
394
439
  };
395
440
  }
@@ -438,8 +483,7 @@ function itemToNode(item, options2 = {}) {
438
483
  props[key] = Array.isArray(nested) ? nested.map((n) => itemToNode(n, options2)) : [];
439
484
  }
440
485
  const hideOn = _hideOn === "both" ? ["mobile", "desktop"] : _hideOn === "mobile" || _hideOn === "desktop" ? [_hideOn] : void 0;
441
- const original = options2.placeholders?.get(String(id));
442
- const placeholder = _placeholder === true && original !== void 0 && original === placeholderHash(props);
486
+ const placeholder = isSample(_placeholder, props, options2.placeholders?.get(String(id)));
443
487
  return {
444
488
  id: safeSectionId(String(id)),
445
489
  type,
@@ -452,6 +496,14 @@ function itemToNode(item, options2 = {}) {
452
496
  };
453
497
  }
454
498
  var placeholderHash = (props) => stableHash(stripArrayIds(pruneEmpty(props)) ?? {});
499
+ function isSample(marker, props, snapshot) {
500
+ if (marker && typeof marker === "object" && !Array.isArray(marker)) return placeholderHash(marker) === placeholderHash(props);
501
+ return marker === true && snapshot !== void 0 && snapshot === placeholderHash(props);
502
+ }
503
+ function isUneditedSample(item, options2 = {}) {
504
+ if (!item?.props._placeholder) return false;
505
+ return itemToNode(item, options2).placeholder === true;
506
+ }
455
507
  function placeholderSnapshot(nodes, into = /* @__PURE__ */ new Map()) {
456
508
  for (const n of nodes) if (n.placeholder) into.set(n.id, placeholderHash(n.props));
457
509
  return into;
@@ -514,6 +566,8 @@ function useEditorServices() {
514
566
  }
515
567
  function Thumb({ src, alt }) {
516
568
  if (!src) return /* @__PURE__ */ jsx("div", { className: "flex h-24 w-full items-center justify-center rounded-md border border-dashed border-border text-sm text-muted-foreground", children: "No image" });
569
+ const sample = sampleImage(src);
570
+ if (sample) return /* @__PURE__ */ jsx("img", { src: sample.src, alt, className: "h-24 w-full rounded-md border border-border object-cover" });
517
571
  if (!isSafeImageSrc(src)) return /* @__PURE__ */ jsx("div", { className: "rounded-md border border-destructive p-2 text-sm text-destructive", children: "This address can't be used for an image: use a site path or an https link." });
518
572
  return /* @__PURE__ */ jsx("img", { src, alt, className: "h-24 w-full rounded-md border border-border object-cover" });
519
573
  }
@@ -586,9 +640,9 @@ function RichTextField({ field, id, value, onChange, readOnly }) {
586
640
  }
587
641
  function LinesField({ field, id, value, onChange, readOnly }) {
588
642
  const max = field.metadata?.maxItems;
589
- const [text, setText] = React10.useState(() => (value ?? []).join("\n"));
590
- const lastSent = React10.useRef(value);
591
- React10.useEffect(() => {
643
+ const [text, setText] = React11.useState(() => (value ?? []).join("\n"));
644
+ const lastSent = React11.useRef(value);
645
+ React11.useEffect(() => {
592
646
  if (JSON.stringify(value ?? []) !== JSON.stringify(lastSent.current ?? [])) setText((value ?? []).join("\n"));
593
647
  }, [value]);
594
648
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
@@ -623,6 +677,44 @@ function UnsupportedField({ field }) {
623
677
  /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "This can't be edited here yet; it's kept as it is." })
624
678
  ] });
625
679
  }
680
+ function FormField({ field, id, value, onChange, readOnly }) {
681
+ const services = useEditorServices();
682
+ const [list, setList] = React11.useState(null);
683
+ const [failed, setFailed] = React11.useState(false);
684
+ React11.useEffect(() => {
685
+ if (!services.listForms) return;
686
+ let live = true;
687
+ services.listForms().then((forms) => live && setList(forms)).catch(() => live && setFailed(true));
688
+ return () => {
689
+ live = false;
690
+ };
691
+ }, [services]);
692
+ const label = /* @__PURE__ */ jsx(Label, { htmlFor: id, id: `${id}-label`, children: field.label });
693
+ if (!services.listForms || failed) {
694
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
695
+ label,
696
+ /* @__PURE__ */ jsx(Input, { id, value: value ?? "", placeholder: "contact", readOnly, onChange: (e) => onChange(e.currentTarget.value.trim().toLowerCase()) }),
697
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: failed ? "Your forms couldn't load: type the form's short name." : "The form's short name, as your forms list shows it." })
698
+ ] });
699
+ }
700
+ if (!list) return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
701
+ label,
702
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Loading your forms\u2026" })
703
+ ] });
704
+ const known = !value || list.some((f) => f.slug === value);
705
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
706
+ label,
707
+ list.length ? /* @__PURE__ */ jsxs(Select, { value: known ? value ?? "" : "", onValueChange: (v) => onChange(v), disabled: readOnly, children: [
708
+ /* @__PURE__ */ jsx(SelectTrigger, { id, "aria-labelledby": `${id}-label`, children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Choose a form" }) }),
709
+ /* @__PURE__ */ jsx(SelectContent, { children: list.map((f) => /* @__PURE__ */ jsx(SelectItem, { value: f.slug, children: f.title }, f.slug)) })
710
+ ] }) : /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "You have no forms yet. Make one, then choose it here." }),
711
+ known ? null : /* @__PURE__ */ jsxs("p", { role: "alert", className: "text-xs text-destructive", children: [
712
+ "There's no form \u201C",
713
+ value,
714
+ "\u201D. Choose one of yours."
715
+ ] })
716
+ ] });
717
+ }
626
718
 
627
719
  // src/editor/fields.ts
628
720
  var GENERIC_TITLES = /* @__PURE__ */ new Set(["Link", "Image", "Rich text"]);
@@ -675,6 +767,7 @@ function fieldFor(key, schema, required, ctx) {
675
767
  return { type: "slot", label, ...schema["x-genesis-allow"] ?? ctx.slotAllow ? { allow: schema["x-genesis-allow"] ?? ctx.slotAllow } : {} };
676
768
  }
677
769
  if (kind === "rich-text") return { type: "custom", label, render: RichTextField };
770
+ if (kind === "form") return { type: "custom", label, render: FormField };
678
771
  if (isImageSchema(schema)) return { type: "custom", label, render: ImageField, metadata: { required } };
679
772
  const union = schema.anyOf ?? schema.oneOf;
680
773
  if (union) {
@@ -756,7 +849,7 @@ function objectFields(schema, ctx) {
756
849
  function imageItemFields(schema, ctx) {
757
850
  const out = {
758
851
  src: { type: "custom", label: "Image", render: ImageSrcField },
759
- alt: { type: "textarea", label: "Alt text (what the image shows)" },
852
+ alt: { type: "textarea", label: "Alt text (what the image shows)", placeholder: "Describe what the photo shows" },
760
853
  decorative: {
761
854
  type: "radio",
762
855
  label: "Decorative (no alt text needed)",
@@ -820,7 +913,7 @@ var CATEGORY_TITLES = {
820
913
  footer: "Footer"
821
914
  };
822
915
  var META = /* @__PURE__ */ new Set(["puck", "editMode", "id"]);
823
- var SectionBoundary = class extends React10.Component {
916
+ var SectionBoundary = class extends React11.Component {
824
917
  state = { error: null };
825
918
  static getDerivedStateFromError(error) {
826
919
  return { error };
@@ -842,19 +935,65 @@ function Problem({ title, lines: lines2 }) {
842
935
  function Tag({ children }) {
843
936
  return /* @__PURE__ */ jsx("span", { style: { position: "absolute", top: "0.5rem", right: "0.5rem", zIndex: 5, padding: "0.125rem 0.5rem", borderRadius: "999px", background: "hsl(var(--foreground))", color: "hsl(var(--background))", fontFamily: "system-ui, sans-serif", fontSize: "0.75rem", fontWeight: 600 }, children });
844
937
  }
938
+ function issuePlace(path) {
939
+ return path.map((p) => typeof p === "number" ? String(p + 1) : humanize(String(p))).join(" \u203A ");
940
+ }
941
+ function friendlyIssue(issue) {
942
+ const place = issuePlace(issue.path) || "This section";
943
+ const missing = issue.code === "invalid_type" && ("input" in issue ? issue.input === void 0 : /received undefined$/.test(issue.message));
944
+ const blank2 = issue.code === "too_small" && issue.origin === "string" && ("input" in issue ? issue.input === "" : Number(issue.minimum) === 1);
945
+ if (missing || blank2) return `${place}: fill this in.`;
946
+ if (issue.code === "too_small" && issue.origin === "string") return `${place}: too short (at least ${issue.minimum} characters).`;
947
+ if (issue.code === "too_small" && issue.origin === "array") return `${place}: add at least ${issue.minimum}.`;
948
+ if (issue.code === "too_big" && issue.origin === "string") return `${place}: too long (at most ${issue.maximum} characters).`;
949
+ if (issue.code === "too_big" && issue.origin === "array") return `${place}: at most ${issue.maximum}.`;
950
+ return `${place}: ${issue.message.replace(/^Invalid input: /, "")}`;
951
+ }
952
+ function withoutUnfinishedItems(def, node) {
953
+ if (node.v !== def.version) return null;
954
+ const parsed = def.schema.safeParse(node.props);
955
+ if (parsed.success) return null;
956
+ const drop = /* @__PURE__ */ new Map();
957
+ for (const issue of parsed.error.issues) {
958
+ const [key, index] = issue.path;
959
+ if (typeof key !== "string" || typeof index !== "number" || issue.path.length < 3 || !Array.isArray(node.props[key])) return null;
960
+ drop.set(key, (drop.get(key) ?? /* @__PURE__ */ new Set()).add(index));
961
+ }
962
+ const props = { ...node.props };
963
+ const unfinished = [];
964
+ for (const [key, indexes] of drop) {
965
+ props[key] = node.props[key].filter((_, i) => !indexes.has(i));
966
+ for (const i of [...indexes].sort((a, b) => a - b)) unfinished.push(`${humanize(key)} \u203A ${i + 1}`);
967
+ }
968
+ const repaired = { ...node, props };
969
+ return migrateNode(repaired).node ? { node: repaired, unfinished } : null;
970
+ }
971
+ function sectionProblems(def, node, fallback) {
972
+ if (node.v !== def.version) return fallback;
973
+ const parsed = def.schema.safeParse(node.props);
974
+ return parsed.success ? fallback : parsed.error.issues.map(friendlyIssue);
975
+ }
845
976
  function CanvasSection({ def, componentName, input, slotKeys }) {
846
977
  const meta = input.puck?.metadata ?? {};
847
978
  const id = String(input.id);
848
979
  const props = { id };
849
980
  for (const [k, v] of Object.entries(input)) if (!META.has(k) && !slotKeys.includes(k)) props[k] = v;
850
981
  const node = itemToNode({ type: componentName, props }, { ...meta.placeholders ? { placeholders: new Map(Object.entries(meta.placeholders)) } : {} });
851
- const migrated = migrateNode(node);
982
+ let migrated = migrateNode(node);
983
+ let unfinished = [];
984
+ if (!migrated.node) {
985
+ const partial = withoutUnfinishedItems(def, node);
986
+ if (partial) {
987
+ migrated = migrateNode(partial.node);
988
+ unfinished = partial.unfinished;
989
+ }
990
+ }
852
991
  const slots = slotKeys.map((key) => {
853
992
  const Slot = input[key];
854
993
  return typeof Slot === "function" ? /* @__PURE__ */ jsx("div", { "aria-label": `${def.label}: ${key}`, style: { padding: "0.5rem" }, children: /* @__PURE__ */ jsx(Slot, { minEmptyHeight: 64 }) }, key) : null;
855
994
  });
856
995
  if (!migrated.node) {
857
- return /* @__PURE__ */ jsx(Problem, { title: `Fix the ${def.label} section to show it`, lines: migrated.issues.map((i) => i.message.replace(/^Section \S+ \([^)]*\): /, "")) });
996
+ return /* @__PURE__ */ jsx(Problem, { title: `Fix the ${def.label} section to show it`, lines: sectionProblems(def, node, migrated.issues.map((i) => i.message.replace(/^Section \S+ \([^)]*\): /, ""))) });
858
997
  }
859
998
  const ctx = {
860
999
  headingLevel: meta.h1Id === id ? 1 : 2,
@@ -865,7 +1004,7 @@ function CanvasSection({ def, componentName, input, slotKeys }) {
865
1004
  mode: "preview",
866
1005
  idPrefix: `gs-${id}`
867
1006
  };
868
- const tags = [node.hidden ? "Hidden: not published" : null, node.hideOn?.includes("mobile") ? "Hidden on phones" : null, node.hideOn?.includes("desktop") ? "Phones only" : null, node.placeholder ? "Sample content: replace it" : null].filter(Boolean);
1007
+ const tags = [node.hidden ? "Hidden: not published" : null, node.hideOn?.includes("mobile") ? "Hidden on phones" : null, node.hideOn?.includes("desktop") ? "Phones only" : null, node.placeholder ? "Sample content: replace it" : null, unfinished.length ? `Not shown until filled in: ${unfinished.join(", ")}` : null].filter(Boolean);
869
1008
  return /* @__PURE__ */ jsxs("div", { style: { position: "relative", ...node.hidden ? { opacity: 0.45 } : {} }, "data-gs-section": def.type, children: [
870
1009
  tags.length ? /* @__PURE__ */ jsx(Tag, { children: tags.join(" \xB7 ") }) : null,
871
1010
  /* @__PURE__ */ jsx(SectionBoundary, { label: def.label, children: def.render({ props: migrated.node.props, variant: migrated.node.variant, node: migrated.node, ctx }) }),
@@ -894,7 +1033,17 @@ function createEditorConfig(options2 = {}) {
894
1033
  components[name] = {
895
1034
  label: i === 0 ? def.label : `${def.label}: ${preset.name}`,
896
1035
  fields,
897
- defaultProps: { ...structuredClone(preset.props), _v: def.version, _variant: preset.variant, _hidden: false, _hideOn: "none" },
1036
+ // What an added section starts with. A `sample` preset's section starts as a placeholder, carrying the props it
1037
+ // started with (data.ts): the publish check holds it until it's edited. Puck also draws existing items over these
1038
+ // defaults, so `nodeToItem` sets every key an item lacks to undefined.
1039
+ defaultProps: {
1040
+ ...structuredClone(preset.props),
1041
+ _v: def.version,
1042
+ _variant: preset.variant,
1043
+ _hidden: false,
1044
+ _hideOn: "none",
1045
+ _placeholder: preset.sample ? structuredClone(preset.props) : void 0
1046
+ },
898
1047
  // Read each time Puck asks (the Add picker), so a section at its limit can't be dragged in.
899
1048
  permissions: {
900
1049
  get insert() {
@@ -938,7 +1087,16 @@ function createEditorConfig(options2 = {}) {
938
1087
  return { config, components: info, slotKeys: (type) => slots.get(sectionTypeOf(type)) ?? [] };
939
1088
  }
940
1089
  var usePuck = createUsePuck();
941
- var EditorLockContext = React10.createContext(false);
1090
+ function sampleHint(value, sample) {
1091
+ return sample && typeof value === "string" && value !== "" ? value : void 0;
1092
+ }
1093
+ function useSampleHint(value) {
1094
+ const selected = usePuck((s) => s.selectedItem);
1095
+ const sample = React11.useMemo(() => isUneditedSample(selected), [selected]);
1096
+ return sampleHint(value, sample);
1097
+ }
1098
+ var usePuck2 = createUsePuck();
1099
+ var EditorLockContext = React11.createContext(false);
942
1100
  var fieldId = (p) => p.id ?? `gs-field-${p.name.replace(/[^a-zA-Z0-9_-]/g, "-")}`;
943
1101
  function FieldShell({ id, label, children }) {
944
1102
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5 py-1", children: [
@@ -948,11 +1106,13 @@ function FieldShell({ id, label, children }) {
948
1106
  }
949
1107
  function TextInput(p) {
950
1108
  const id = fieldId(p);
951
- return /* @__PURE__ */ jsx(FieldShell, { id, label: p.field.label, children: /* @__PURE__ */ jsx(Input, { id, name: p.name, value: typeof p.value === "string" ? p.value : "", placeholder: p.field.placeholder, disabled: p.readOnly, onChange: (e) => p.onChange(e.currentTarget.value) }) });
1109
+ const hint = useSampleHint(p.value);
1110
+ return /* @__PURE__ */ jsx(FieldShell, { id, label: p.field.label, children: /* @__PURE__ */ jsx(Input, { id, name: p.name, value: hint !== void 0 ? "" : typeof p.value === "string" ? p.value : "", placeholder: hint ?? p.field.placeholder, disabled: p.readOnly, onChange: (e) => p.onChange(e.currentTarget.value) }) });
952
1111
  }
953
1112
  function TextareaInput(p) {
954
1113
  const id = fieldId(p);
955
- return /* @__PURE__ */ jsx(FieldShell, { id, label: p.field.label, children: /* @__PURE__ */ jsx(Textarea, { id, name: p.name, rows: 3, value: typeof p.value === "string" ? p.value : "", placeholder: p.field.placeholder, disabled: p.readOnly, onChange: (e) => p.onChange(e.currentTarget.value) }) });
1114
+ const hint = useSampleHint(p.value);
1115
+ return /* @__PURE__ */ jsx(FieldShell, { id, label: p.field.label, children: /* @__PURE__ */ jsx(Textarea, { id, name: p.name, rows: 3, value: hint !== void 0 ? "" : typeof p.value === "string" ? p.value : "", placeholder: hint ?? p.field.placeholder, disabled: p.readOnly, onChange: (e) => p.onChange(e.currentTarget.value) }) });
956
1116
  }
957
1117
  function NumberInput(p) {
958
1118
  const id = fieldId(p);
@@ -1001,13 +1161,13 @@ function RadioInput(p) {
1001
1161
  ] });
1002
1162
  }
1003
1163
  function ComponentItem({ name, info, announce }) {
1004
- const data = usePuck((s) => s.appState.data);
1164
+ const data = usePuck2((s) => s.appState.data);
1005
1165
  const meta = info.get(name);
1006
1166
  const type = sectionTypeOf(name);
1007
- const used = React10.useMemo(() => countTypes(data).get(type) ?? 0, [data, type]);
1167
+ const used = React11.useMemo(() => countTypes(data).get(type) ?? 0, [data, type]);
1008
1168
  const full = meta?.limit !== void 0 && used >= meta.limit;
1009
- const dispatch = usePuck((s) => s.dispatch);
1010
- const locked = React10.useContext(EditorLockContext);
1169
+ const dispatch = usePuck2((s) => s.dispatch);
1170
+ const locked = React11.useContext(EditorLockContext);
1011
1171
  const label = meta?.label ?? name;
1012
1172
  const add = () => {
1013
1173
  if (locked) return;
@@ -1020,13 +1180,24 @@ function ComponentItem({ name, info, announce }) {
1020
1180
  scrollCanvasTo(id, ref.current?.ownerDocument);
1021
1181
  announce?.(`${label} added at the end of the ${zone === "root:header" ? "header" : zone === "root:footer" ? "footer" : "page"}. Its fields are open; Up and Down move it.`);
1022
1182
  };
1023
- const ref = React10.useRef(null);
1024
- React10.useEffect(() => {
1183
+ const ref = React11.useRef(null);
1184
+ React11.useEffect(() => {
1025
1185
  const copy = ref.current?.closest('[class*="draggableBg"]');
1026
1186
  if (copy) {
1027
1187
  copy.setAttribute("aria-hidden", "true");
1028
1188
  copy.inert = true;
1029
1189
  }
1190
+ const item = ref.current?.closest("[data-puck-drawer-item]");
1191
+ if (!item || item === copy?.querySelector("[data-puck-drawer-item]")) return;
1192
+ const plain = () => {
1193
+ for (const name2 of ["role", "tabindex", "aria-roledescription", "aria-describedby", "aria-pressed", "aria-disabled"]) {
1194
+ if (item.hasAttribute(name2)) item.removeAttribute(name2);
1195
+ }
1196
+ };
1197
+ plain();
1198
+ const observer = new MutationObserver(plain);
1199
+ observer.observe(item, { attributes: true, attributeFilter: ["role", "tabindex", "aria-roledescription", "aria-describedby", "aria-pressed", "aria-disabled"] });
1200
+ return () => observer.disconnect();
1030
1201
  }, []);
1031
1202
  return /* @__PURE__ */ jsxs(
1032
1203
  "div",
@@ -1034,7 +1205,7 @@ function ComponentItem({ name, info, announce }) {
1034
1205
  ref,
1035
1206
  className: cn(
1036
1207
  "flex w-full items-center justify-between gap-2 rounded-md border border-border bg-background px-3 py-2 text-left text-sm text-foreground",
1037
- full ? "cursor-not-allowed opacity-60" : "cursor-grab hover:border-primary"
1208
+ full ? "cursor-not-allowed bg-muted" : "cursor-grab hover:border-primary"
1038
1209
  ),
1039
1210
  title: full ? `A page has at most ${meta?.limit} of these` : `Drag onto the page, or press Add: ${label}`,
1040
1211
  children: [
@@ -1042,19 +1213,19 @@ function ComponentItem({ name, info, announce }) {
1042
1213
  /* @__PURE__ */ jsx("span", { className: "font-medium", children: label }),
1043
1214
  meta && meta.label !== meta.sectionLabel ? /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: meta.sectionLabel }) : null
1044
1215
  ] }),
1045
- full ? /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "shrink-0", children: "Limit reached" }) : /* @__PURE__ */ jsx(Button, { type: "button", size: "sm", variant: "outline", className: "h-7 shrink-0 px-2", "aria-label": `Add ${label}`, disabled: locked, onPointerDown: (e) => e.stopPropagation(), onClick: add, children: "Add" })
1216
+ full ? /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "shrink-0", children: "Limit reached" }) : /* @__PURE__ */ jsx(Button, { type: "button", size: "sm", variant: "outline", className: "h-7 min-w-11 shrink-0 px-2", "aria-label": `Add ${label}`, disabled: locked, onPointerDown: (e) => e.stopPropagation(), onClick: add, children: "Add" })
1046
1217
  ]
1047
1218
  }
1048
1219
  );
1049
1220
  }
1050
1221
  function SectionActions({ info, announce }) {
1051
- const selected = usePuck((s) => s.selectedItem);
1052
- const getSelectorForId = usePuck((s) => s.getSelectorForId);
1053
- const getItemBySelector = usePuck((s) => s.getItemBySelector);
1054
- const dispatch = usePuck((s) => s.dispatch);
1055
- const locked = React10.useContext(EditorLockContext);
1056
- const upRef = React10.useRef(null);
1057
- const downRef = React10.useRef(null);
1222
+ const selected = usePuck2((s) => s.selectedItem);
1223
+ const getSelectorForId = usePuck2((s) => s.getSelectorForId);
1224
+ const getItemBySelector = usePuck2((s) => s.getItemBySelector);
1225
+ const dispatch = usePuck2((s) => s.dispatch);
1226
+ const locked = React11.useContext(EditorLockContext);
1227
+ const upRef = React11.useRef(null);
1228
+ const downRef = React11.useRef(null);
1058
1229
  if (!selected) return null;
1059
1230
  const id = String(selected.props.id);
1060
1231
  const selector = getSelectorForId(id);
@@ -1100,6 +1271,42 @@ function SectionActions({ info, announce }) {
1100
1271
  ] })
1101
1272
  ] });
1102
1273
  }
1274
+ var OUTLINE_AREAS = {
1275
+ header: { label: "Header", order: 0 },
1276
+ "default-zone": { label: "Page", order: 1 },
1277
+ footer: { label: "Footer", order: 2 }
1278
+ };
1279
+ function OutlineAreas({ children }) {
1280
+ const ref = React11.useRef(null);
1281
+ React11.useEffect(() => {
1282
+ const root = ref.current;
1283
+ if (!root) return;
1284
+ const apply = () => {
1285
+ for (const title of root.querySelectorAll('[class*="LayerTree-zoneTitle"]')) {
1286
+ const list = title.parentElement;
1287
+ if (!list) continue;
1288
+ const text = [...title.childNodes].find((n) => n.nodeType === Node.TEXT_NODE && n.textContent?.trim());
1289
+ const key = title.dataset.gsArea ?? text?.textContent?.trim() ?? "";
1290
+ const area = OUTLINE_AREAS[key];
1291
+ if (!area) continue;
1292
+ title.dataset.gsArea = key;
1293
+ if (text && text.textContent !== area.label) text.textContent = area.label;
1294
+ list.style.display = "flex";
1295
+ list.style.flexDirection = "column";
1296
+ let el = title;
1297
+ while (el && (el === title || !el.matches('[class*="LayerTree-zoneTitle"]'))) {
1298
+ el.style.order = String(area.order);
1299
+ el = el.nextElementSibling;
1300
+ }
1301
+ }
1302
+ };
1303
+ apply();
1304
+ const observer = new MutationObserver(apply);
1305
+ observer.observe(root, { childList: true, subtree: true, characterData: true });
1306
+ return () => observer.disconnect();
1307
+ }, []);
1308
+ return /* @__PURE__ */ jsx("div", { ref, className: "contents", children });
1309
+ }
1103
1310
  function genesisOverrides(info, extra = {}, options2 = {}) {
1104
1311
  return {
1105
1312
  fields: ({ children }) => /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -1121,6 +1328,7 @@ function genesisOverrides(info, extra = {}, options2 = {}) {
1121
1328
  ] });
1122
1329
  },
1123
1330
  drawerItem: ({ name }) => /* @__PURE__ */ jsx(ComponentItem, { name, info, announce: options2.announce }),
1331
+ outline: ({ children }) => /* @__PURE__ */ jsx(OutlineAreas, { children }),
1124
1332
  ...extra
1125
1333
  };
1126
1334
  }
@@ -1140,21 +1348,57 @@ async function checkSite(store, siteId, options2 = {}) {
1140
1348
  issues = prepareRelease(draft.site, pages, {
1141
1349
  reserved: options2.reserved ?? DEFAULT_RESERVED_PATHS,
1142
1350
  ...options2.brand ? { brand: options2.brand } : {},
1143
- ...store.assetOrigin ? { assetOrigins: [store.assetOrigin] } : {}
1351
+ ...store.assetOrigin ? { assetOrigins: [store.assetOrigin] } : {},
1352
+ ...options2.checks ? { checks: options2.checks } : {}
1144
1353
  }).issues;
1145
1354
  } catch (err) {
1146
1355
  if (!(err instanceof PublishBlockedError)) {
1147
1356
  issues = [{ severity: "error", code: "invalid-draft", message: `The drafts can't be checked: ${err.message}` }];
1148
1357
  } else issues = err.issues;
1149
1358
  }
1359
+ if ((options2.forms || options2.listForms) && options2.checks?.missingForms !== "off") {
1360
+ issues = [...issues, ...applyCheckLevels(await formIssues(options2, siteId, draft.site, pages), options2.checks)];
1361
+ }
1150
1362
  const sorted = [...issues].sort((a, b) => a.severity === b.severity ? 0 : a.severity === "error" ? -1 : 1);
1151
1363
  return { issues: sorted, publishable: !sorted.some((i) => i.severity === "error") };
1152
1364
  }
1365
+ async function formIssues({ forms, listForms }, siteId, site, pages) {
1366
+ const found = [];
1367
+ const collect = (nodes, at, page) => {
1368
+ for (const node of nodes) if (!node.hidden && node.type === "form-embed") found.push({ node, at, ...page ? { page } : {} });
1369
+ };
1370
+ collect(site.header, "the site header");
1371
+ collect(site.footer, "the site footer");
1372
+ for (const p of pages) collect(p.doc.content, p.path, p);
1373
+ if (!found.length) return [];
1374
+ const listed = listForms ? await listForms().then((l) => new Set(l.map((f) => f.slug)), () => null) : null;
1375
+ const results = await Promise.all(
1376
+ found.map(async ({ node, at, page }) => {
1377
+ const slug = typeof node.props.form === "string" ? node.props.form : "";
1378
+ const known = !slug ? false : listed ? listed.has(slug) : forms ? Boolean(await Promise.resolve(forms(slug, { siteId, pagePath: page?.path ?? "/", mode: "live" })).catch(() => null)) : true;
1379
+ if (known) return null;
1380
+ const issue = {
1381
+ severity: "error",
1382
+ code: "form-missing",
1383
+ sectionId: node.id,
1384
+ ...page ? { pageId: page.id, path: page.path } : {},
1385
+ message: slug ? `${at}: the form section shows \u201C${slug}\u201D, and there's no form by that name. Pick one of your forms in it.` : `${at}: the form section has no form. Pick one of your forms in it.`
1386
+ };
1387
+ return issue;
1388
+ })
1389
+ );
1390
+ return results.filter((i) => i !== null);
1391
+ }
1153
1392
  async function publishSite(store, siteId, options2) {
1154
1393
  const check = await checkSite(store, siteId, options2);
1155
1394
  if (!check.publishable) return { blocked: check.issues };
1156
1395
  try {
1157
- const release = await store.publish(siteId, { brand: options2.brand, ...options2.note?.trim() ? { note: options2.note.trim() } : {}, ...options2.reserved ? { reserved: options2.reserved } : {} });
1396
+ const release = await store.publish(siteId, {
1397
+ brand: options2.brand,
1398
+ ...options2.note?.trim() ? { note: options2.note.trim() } : {},
1399
+ ...options2.reserved ? { reserved: options2.reserved } : {},
1400
+ ...options2.checks ? { checks: options2.checks } : {}
1401
+ });
1158
1402
  return { release };
1159
1403
  } catch (err) {
1160
1404
  if (err instanceof PublishBlockedError) return { blocked: err.issues };
@@ -1202,6 +1446,20 @@ function pageTemplates() {
1202
1446
  doc: ({ title }) => notFoundPageDoc({ title })
1203
1447
  }
1204
1448
  ];
1449
+ templates.push({
1450
+ id: "blog",
1451
+ label: "Blog",
1452
+ description: "The page your posts live on: their list here, and each post at its own address below it. A site has one.",
1453
+ kind: "post",
1454
+ doc: ({ title }) => ({
1455
+ schemaVersion: 1,
1456
+ root: { props: { title } },
1457
+ content: [
1458
+ { id: "post", type: "post-body", v: 1, variant: "article", props: {} },
1459
+ { id: "posts", type: "blog-list", v: 1, variant: "grid", props: { heading: "Latest posts", perPage: 9 } }
1460
+ ]
1461
+ })
1462
+ });
1205
1463
  const starter = starterSite({ brand: exampleBrands.riverside, message: { headline: "Your headline" } });
1206
1464
  for (const page of starter.pages.slice(1)) {
1207
1465
  const name = page.doc.root.props.title;
@@ -1312,13 +1570,13 @@ function SlugField({ id, directory, slug, problems, onChange, autoFocus }) {
1312
1570
  ] });
1313
1571
  }
1314
1572
  function NewLandingDialog({ open, onOpenChange, pages, directory, reserved, onCreate }) {
1315
- const [title, setTitle] = React10.useState("");
1316
- const [slug, setSlug] = React10.useState("");
1317
- const [slugEdited, setSlugEdited] = React10.useState(false);
1318
- const [error, setError] = React10.useState(null);
1319
- const [busy, setBusy] = React10.useState(false);
1320
- const id = React10.useId();
1321
- React10.useEffect(() => {
1573
+ const [title, setTitle] = React11.useState("");
1574
+ const [slug, setSlug] = React11.useState("");
1575
+ const [slugEdited, setSlugEdited] = React11.useState(false);
1576
+ const [error, setError] = React11.useState(null);
1577
+ const [busy, setBusy] = React11.useState(false);
1578
+ const id = React11.useId();
1579
+ React11.useEffect(() => {
1322
1580
  if (open) {
1323
1581
  setTitle("");
1324
1582
  setSlug("");
@@ -1391,12 +1649,12 @@ function NewLandingDialog({ open, onOpenChange, pages, directory, reserved, onCr
1391
1649
  ) }) });
1392
1650
  }
1393
1651
  function MoveLandingDialog({ page, pages, directory, reserved, onClose, onMove }) {
1394
- const [slug, setSlug] = React10.useState("");
1395
- const [error, setError] = React10.useState(null);
1396
- const [busy, setBusy] = React10.useState(false);
1397
- const id = React10.useId();
1652
+ const [slug, setSlug] = React11.useState("");
1653
+ const [error, setError] = React11.useState(null);
1654
+ const [busy, setBusy] = React11.useState(false);
1655
+ const id = React11.useId();
1398
1656
  const initial = page ? landingSlugOf(directory, page.path) ?? page.path.split("/").pop() ?? "" : "";
1399
- React10.useEffect(() => {
1657
+ React11.useEffect(() => {
1400
1658
  setSlug(initial);
1401
1659
  setError(null);
1402
1660
  }, [initial]);
@@ -1449,12 +1707,12 @@ function MoveLandingDialog({ page, pages, directory, reserved, onClose, onMove }
1449
1707
  ) }) });
1450
1708
  }
1451
1709
  function DirectoryDialog({ open, onOpenChange, pages, directory, reserved, onSave }) {
1452
- const [value, setValue] = React10.useState(directory);
1453
- const [movePages, setMovePages] = React10.useState(true);
1454
- const [error, setError] = React10.useState(null);
1455
- const [busy, setBusy] = React10.useState(false);
1456
- const id = React10.useId();
1457
- React10.useEffect(() => {
1710
+ const [value, setValue] = React11.useState(directory);
1711
+ const [movePages, setMovePages] = React11.useState(true);
1712
+ const [error, setError] = React11.useState(null);
1713
+ const [busy, setBusy] = React11.useState(false);
1714
+ const id = React11.useId();
1715
+ React11.useEffect(() => {
1458
1716
  if (open) {
1459
1717
  setValue(directory);
1460
1718
  setMovePages(true);
@@ -1518,12 +1776,12 @@ function DirectoryDialog({ open, onOpenChange, pages, directory, reserved, onSav
1518
1776
  ) }) });
1519
1777
  }
1520
1778
  function LandingPanel(props) {
1521
- const [adding, setAdding] = React10.useState(false);
1522
- const [moving, setMoving] = React10.useState(null);
1523
- const [deleting, setDeleting] = React10.useState(null);
1524
- const [editingDir, setEditingDir] = React10.useState(false);
1779
+ const [adding, setAdding] = React11.useState(false);
1780
+ const [moving, setMoving] = React11.useState(null);
1781
+ const [deleting, setDeleting] = React11.useState(null);
1782
+ const [editingDir, setEditingDir] = React11.useState(false);
1525
1783
  const list = landingPages(props.pages);
1526
- const headingId = React10.useId();
1784
+ const headingId = React11.useId();
1527
1785
  return /* @__PURE__ */ jsxs("section", { "aria-labelledby": headingId, className: "flex flex-col gap-2", "data-gs-landing": "", children: [
1528
1786
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
1529
1787
  /* @__PURE__ */ jsx("h2", { id: headingId, className: "text-sm font-semibold", children: "Landing pages" }),
@@ -1589,16 +1847,17 @@ function LandingPanel(props) {
1589
1847
  ] });
1590
1848
  }
1591
1849
  function AddPageDialog({ open, onOpenChange, pages, reserved, onCreate }) {
1592
- const templates = React10.useMemo(() => pageTemplates().filter((t) => t.kind !== "landing" && t.id !== "not-found"), []);
1593
- const [title, setTitle] = React10.useState("");
1594
- const [path, setPath] = React10.useState("");
1595
- const [pathEdited, setPathEdited] = React10.useState(false);
1596
- const [templateId, setTemplateId] = React10.useState("blank");
1597
- const [addToMenu, setAddToMenu] = React10.useState(true);
1598
- const [error, setError] = React10.useState(null);
1599
- const [busy, setBusy] = React10.useState(false);
1600
- const id = React10.useId();
1601
- React10.useEffect(() => {
1850
+ const hasBlog = pages.some((p) => p.kind === "post");
1851
+ const templates = React11.useMemo(() => pageTemplates().filter((t) => t.kind !== "landing" && t.id !== "not-found" && !(t.kind === "post" && hasBlog)), [hasBlog]);
1852
+ const [title, setTitle] = React11.useState("");
1853
+ const [path, setPath] = React11.useState("");
1854
+ const [pathEdited, setPathEdited] = React11.useState(false);
1855
+ const [templateId, setTemplateId] = React11.useState("blank");
1856
+ const [addToMenu, setAddToMenu] = React11.useState(true);
1857
+ const [error, setError] = React11.useState(null);
1858
+ const [busy, setBusy] = React11.useState(false);
1859
+ const id = React11.useId();
1860
+ React11.useEffect(() => {
1602
1861
  if (open) {
1603
1862
  setTitle("");
1604
1863
  setPath("");
@@ -1685,11 +1944,11 @@ function AddPageDialog({ open, onOpenChange, pages, reserved, onCreate }) {
1685
1944
  ] }) }) });
1686
1945
  }
1687
1946
  function RenameDialog({ page, pages, reserved, onClose, onRename }) {
1688
- const [path, setPath] = React10.useState("");
1689
- const [error, setError] = React10.useState(null);
1690
- const [busy, setBusy] = React10.useState(false);
1691
- const id = React10.useId();
1692
- React10.useEffect(() => {
1947
+ const [path, setPath] = React11.useState("");
1948
+ const [error, setError] = React11.useState(null);
1949
+ const [busy, setBusy] = React11.useState(false);
1950
+ const id = React11.useId();
1951
+ React11.useEffect(() => {
1693
1952
  setPath(page?.path ?? "");
1694
1953
  setError(null);
1695
1954
  }, [page]);
@@ -1749,8 +2008,8 @@ function menuItemProblems(item) {
1749
2008
  }
1750
2009
  function MenuEditor({ nav, pages, busy, onChange }) {
1751
2010
  const items = nav;
1752
- const id = React10.useId();
1753
- const list = React10.useRef(null);
2011
+ const id = React11.useId();
2012
+ const list = React11.useRef(null);
1754
2013
  const commit = (next) => onChange(next);
1755
2014
  const move = (i, by) => {
1756
2015
  const next = [...items];
@@ -1789,27 +2048,27 @@ function MenuEditor({ nav, pages, busy, onChange }) {
1789
2048
  ] }, i);
1790
2049
  }) }),
1791
2050
  /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
1792
- unlinked.slice(0, 4).map((p) => /* @__PURE__ */ jsxs(Button, { type: "button", size: "sm", variant: "outline", disabled: busy || items.length >= 12, onClick: () => commit([...items, { label: p.title.slice(0, 40), href: p.path }]), children: [
1793
- /* @__PURE__ */ jsx(Plus, { className: "mr-1 h-3 w-3" }),
2051
+ unlinked.slice(0, 4).map((p) => /* @__PURE__ */ jsxs(Button, { type: "button", size: "sm", variant: "outline", "aria-label": `Add ${p.title} to the menu`, disabled: busy || items.length >= 12, onClick: () => commit([...items, { label: p.title.slice(0, 40), href: p.path }]), children: [
2052
+ /* @__PURE__ */ jsx(Plus, { className: "mr-1 h-3 w-3", "aria-hidden": true }),
1794
2053
  " ",
1795
2054
  p.title
1796
2055
  ] }, p.id)),
1797
- /* @__PURE__ */ jsxs(Button, { type: "button", size: "sm", variant: "outline", disabled: busy || items.length >= 12, onClick: () => commit([...items, { label: "", href: "" }]), children: [
1798
- /* @__PURE__ */ jsx(Plus, { className: "mr-1 h-3 w-3" }),
2056
+ /* @__PURE__ */ jsxs(Button, { type: "button", size: "sm", variant: "outline", disabled: busy || items.length >= 12, "aria-label": "Add a link to the menu", onClick: () => commit([...items, { label: "", href: "" }]), children: [
2057
+ /* @__PURE__ */ jsx(Plus, { className: "mr-1 h-3 w-3", "aria-hidden": true }),
1799
2058
  " Link"
1800
2059
  ] })
1801
2060
  ] })
1802
2061
  ] });
1803
2062
  }
1804
2063
  function PagesPanel(props) {
1805
- const [adding, setAdding] = React10.useState(false);
1806
- const [renaming, setRenaming] = React10.useState(null);
1807
- const [deleting, setDeleting] = React10.useState(null);
2064
+ const [adding, setAdding] = React11.useState(false);
2065
+ const [renaming, setRenaming] = React11.useState(null);
2066
+ const [deleting, setDeleting] = React11.useState(null);
1808
2067
  const ordinary = props.pages.filter((p) => !isLandingPage(p) && !isNotFoundPage(p));
1809
2068
  const notFoundPage = props.pages.find(isNotFoundPage) ?? null;
1810
- const notFoundTemplate = React10.useMemo(() => pageTemplates().find((t) => t.id === "not-found"), []);
1811
- const [makingNotFound, setMakingNotFound] = React10.useState(false);
1812
- const [notFoundError, setNotFoundError] = React10.useState(null);
2069
+ const notFoundTemplate = React11.useMemo(() => pageTemplates().find((t) => t.id === "not-found"), []);
2070
+ const [makingNotFound, setMakingNotFound] = React11.useState(false);
2071
+ const [notFoundError, setNotFoundError] = React11.useState(null);
1813
2072
  const makeNotFound = async () => {
1814
2073
  setNotFoundError(null);
1815
2074
  setMakingNotFound(true);
@@ -1903,6 +2162,12 @@ function PagesPanel(props) {
1903
2162
  /* @__PURE__ */ jsx(Button, { type: "button", size: "sm", variant: "outline", onClick: props.onEditFooter, children: "Edit the footer" })
1904
2163
  ] })
1905
2164
  ] }),
2165
+ /* @__PURE__ */ jsx(Separator, {}),
2166
+ /* @__PURE__ */ jsxs("section", { "aria-labelledby": "gs-look-heading", className: "flex flex-col gap-2", children: [
2167
+ /* @__PURE__ */ jsx("h2", { id: "gs-look-heading", className: "text-sm font-semibold", children: "Look" }),
2168
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Fonts, colours and the logo come from the brand, so the site matches everything else it makes. A change goes live with the next publish." }),
2169
+ props.brandSettingsHref ? /* @__PURE__ */ jsx(Button, { asChild: true, size: "sm", variant: "outline", children: /* @__PURE__ */ jsx("a", { href: props.brandSettingsHref, children: "Change the brand's look" }) }) : null
2170
+ ] }),
1906
2171
  /* @__PURE__ */ jsx(AddPageDialog, { open: adding, onOpenChange: setAdding, pages: props.pages, reserved: props.reserved, onCreate: props.onCreate }),
1907
2172
  /* @__PURE__ */ jsx(RenameDialog, { page: renaming, pages: props.pages, reserved: props.reserved, onClose: () => setRenaming(null), onRename: props.onRename }),
1908
2173
  /* @__PURE__ */ jsx(AlertDialog, { open: deleting !== null, onOpenChange: (o) => o ? null : setDeleting(null), children: /* @__PURE__ */ jsxs(AlertDialogContent, { children: [
@@ -1941,16 +2206,16 @@ function RedirectDialog({
1941
2206
  onClose,
1942
2207
  props
1943
2208
  }) {
1944
- const [from, setFrom] = React10.useState("");
1945
- const [choice, setChoice] = React10.useState(void 0);
1946
- const [other, setOther] = React10.useState("");
1947
- const [status, setStatus] = React10.useState("301");
1948
- const [prefix, setPrefix] = React10.useState(false);
1949
- const [keepRest, setKeepRest] = React10.useState(false);
1950
- const [touched, setTouched] = React10.useState(false);
1951
- const [error, setError] = React10.useState(null);
1952
- const id = React10.useId();
1953
- React10.useEffect(() => {
2209
+ const [from, setFrom] = React11.useState("");
2210
+ const [choice, setChoice] = React11.useState(void 0);
2211
+ const [other, setOther] = React11.useState("");
2212
+ const [status, setStatus] = React11.useState("301");
2213
+ const [prefix, setPrefix] = React11.useState(false);
2214
+ const [keepRest, setKeepRest] = React11.useState(false);
2215
+ const [touched, setTouched] = React11.useState(false);
2216
+ const [error, setError] = React11.useState(null);
2217
+ const id = React11.useId();
2218
+ React11.useEffect(() => {
1954
2219
  if (!open) return;
1955
2220
  setFrom(editing?.from ?? "");
1956
2221
  const known = editing && props.destinations.some((d) => d.path === editing.to);
@@ -2078,11 +2343,11 @@ function RedirectDialog({
2078
2343
  ) }) });
2079
2344
  }
2080
2345
  function RedirectsPanel(props) {
2081
- const [editing, setEditing] = React10.useState(null);
2082
- const [adding, setAdding] = React10.useState(false);
2083
- const [removing, setRemoving] = React10.useState(null);
2084
- const [error, setError] = React10.useState(null);
2085
- const headingId = React10.useId();
2346
+ const [editing, setEditing] = React11.useState(null);
2347
+ const [adding, setAdding] = React11.useState(false);
2348
+ const [removing, setRemoving] = React11.useState(null);
2349
+ const [error, setError] = React11.useState(null);
2350
+ const headingId = React11.useId();
2086
2351
  return /* @__PURE__ */ jsxs("section", { "aria-labelledby": headingId, className: "flex flex-col gap-2", "data-gs-redirects": "", children: [
2087
2352
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
2088
2353
  /* @__PURE__ */ jsx("h2", { id: headingId, className: "text-sm font-semibold", children: "Redirects" }),
@@ -2256,10 +2521,10 @@ function Field({ id, label, hint, children }) {
2256
2521
  ] });
2257
2522
  }
2258
2523
  function SearchDialog({ open, onClose, props }) {
2259
- const [form, setForm] = React10.useState(() => searchForm(props.seo));
2260
- const [error, setError] = React10.useState(null);
2261
- const id = React10.useId();
2262
- React10.useEffect(() => {
2524
+ const [form, setForm] = React11.useState(() => searchForm(props.seo));
2525
+ const [error, setError] = React11.useState(null);
2526
+ const id = React11.useId();
2527
+ React11.useEffect(() => {
2263
2528
  if (!open) return;
2264
2529
  setForm(searchForm(props.seo));
2265
2530
  setError(null);
@@ -2363,8 +2628,8 @@ function SearchDialog({ open, onClose, props }) {
2363
2628
  ) }) });
2364
2629
  }
2365
2630
  function SearchPanel(props) {
2366
- const [open, setOpen] = React10.useState(false);
2367
- const headingId = React10.useId();
2631
+ const [open, setOpen] = React11.useState(false);
2632
+ const headingId = React11.useId();
2368
2633
  const b = props.seo.localBusiness;
2369
2634
  const summary = [
2370
2635
  props.seo.noindex ? "Hidden from search" : props.seo.description ? "Description set" : "No description",
@@ -2383,17 +2648,20 @@ function SearchPanel(props) {
2383
2648
 
2384
2649
  // src/editor/preview.ts
2385
2650
  async function loadSiteCss() {
2386
- const { ASSETS } = await import('./assets.generated-YGLB7VKL.js');
2651
+ const { ASSETS } = await import('./assets.generated-ZBFSP23U.js');
2387
2652
  return ASSETS.css.body;
2388
2653
  }
2389
2654
  var styleText = (css) => css.replace(/<\/style/gi, "<\\/style");
2390
2655
  async function renderPreview(input) {
2391
- const [{ renderSitePageToString }, { ASSETS }] = await Promise.all([import('./handler-J5BCH2VW.js'), import('./assets.generated-YGLB7VKL.js')]);
2656
+ const [{ renderSitePageToString }, { ASSETS }] = await Promise.all([import('./handler-OR554RTS.js'), import('./assets.generated-ZBFSP23U.js')]);
2392
2657
  const result = await renderSitePageToString(new Request(`https://preview.invalid${input.path}`), {
2393
2658
  store: input.store,
2394
2659
  brand: { getBrand: () => input.brand },
2395
2660
  siteId: input.siteId,
2396
2661
  mode: input.mode,
2662
+ // The editor is the viewer: its store is the one it edits with, signed in as it, so the
2663
+ // database still decides which drafts come back. (The handler's own rule is for anonymous requests.)
2664
+ viewer: "editor",
2397
2665
  unknownPath: "not-found",
2398
2666
  csp: false,
2399
2667
  ...input.forms ? { forms: input.forms } : {}
@@ -2405,13 +2673,13 @@ async function renderPreview(input) {
2405
2673
  const html = result.html.replace(/<link rel="stylesheet" href="[^"]*\/_gs\/([^"]+)"\/>/g, (_m, name) => name === ASSETS.css.name ? css : name === ASSETS.formsCss.name ? formsCss : "").replace(/<script type="module" src="[^"]*\/_gs\/[^"]*"><\/script>/g, "");
2406
2674
  return { status: result.status, html };
2407
2675
  }
2408
- var usePuck2 = createUsePuck();
2676
+ var usePuck3 = createUsePuck();
2409
2677
  function SeoFields({ siteName, pagePath, pageTitle, readOnly }) {
2410
- const seo = usePuck2((s) => s.appState.data.root.props?.seo);
2411
- const root = usePuck2((s) => s.appState.data.root);
2412
- const dispatch = usePuck2((s) => s.dispatch);
2678
+ const seo = usePuck3((s) => s.appState.data.root.props?.seo);
2679
+ const root = usePuck3((s) => s.appState.data.root);
2680
+ const dispatch = usePuck3((s) => s.dispatch);
2413
2681
  const services = useEditorServices();
2414
- const id = React10.useId();
2682
+ const id = React11.useId();
2415
2683
  const set = (patch) => {
2416
2684
  const next = { ...seo ?? {}, ...patch };
2417
2685
  for (const k of Object.keys(next)) if (next[k] === void 0 || next[k] === "" || next[k] === false) delete next[k];
@@ -2475,11 +2743,53 @@ function SeoFields({ siteName, pagePath, pageTitle, readOnly }) {
2475
2743
  ] })
2476
2744
  ] });
2477
2745
  }
2746
+ function toLocalInput(iso) {
2747
+ if (typeof iso !== "string") return "";
2748
+ const t = new Date(iso);
2749
+ if (Number.isNaN(t.getTime())) return "";
2750
+ const local = new Date(t.getTime() - t.getTimezoneOffset() * 6e4);
2751
+ return local.toISOString().slice(0, 16);
2752
+ }
2753
+ function ShowDates({ pagePath, readOnly }) {
2754
+ const root = usePuck3((s) => s.appState.data.root);
2755
+ const dispatch = usePuck3((s) => s.dispatch);
2756
+ const id = React11.useId();
2757
+ const props = root.props ?? {};
2758
+ const set = (key, value) => {
2759
+ const next = { ...props };
2760
+ const t = value ? new Date(value) : null;
2761
+ if (t && !Number.isNaN(t.getTime())) next[key] = t.toISOString();
2762
+ else delete next[key];
2763
+ dispatch({ type: "replaceRoot", root: { ...root, props: next } });
2764
+ };
2765
+ const problems = pageWindowProblems({ root: { props } }, pagePath);
2766
+ const zone = Intl.DateTimeFormat().resolvedOptions().timeZone;
2767
+ return /* @__PURE__ */ jsxs("section", { "aria-labelledby": `${id}-h`, className: "flex flex-col gap-3", "data-gs-show-dates": "", children: [
2768
+ /* @__PURE__ */ jsxs("h3", { id: `${id}-h`, className: "text-sm font-semibold", children: [
2769
+ "Show dates for ",
2770
+ pagePath
2771
+ ] }),
2772
+ /* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground", children: [
2773
+ "Before the start and from the end, visitors get the page-not-found page and the page leaves the sitemap. It switches on time, with no publish. Times are in ",
2774
+ zone,
2775
+ "."
2776
+ ] }),
2777
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
2778
+ /* @__PURE__ */ jsx(Label, { htmlFor: `${id}-from`, children: "Show from" }),
2779
+ /* @__PURE__ */ jsx(Input, { id: `${id}-from`, type: "datetime-local", value: toLocalInput(props.showFrom), disabled: readOnly, onChange: (e) => set("showFrom", e.currentTarget.value) })
2780
+ ] }),
2781
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
2782
+ /* @__PURE__ */ jsx(Label, { htmlFor: `${id}-until`, children: "Show until" }),
2783
+ /* @__PURE__ */ jsx(Input, { id: `${id}-until`, type: "datetime-local", value: toLocalInput(props.showUntil), disabled: readOnly, "aria-describedby": `${id}-until-hint`, onChange: (e) => set("showUntil", e.currentTarget.value) }),
2784
+ /* @__PURE__ */ jsx("p", { id: `${id}-until-hint`, className: problems.length ? "text-xs text-destructive" : "text-xs text-muted-foreground", children: problems.length ? problems.join(" ") : "Leave either empty: no start, or no end." })
2785
+ ] })
2786
+ ] });
2787
+ }
2478
2788
  function IssueList({ issues, currentPageId, onOpenPage, onShown }) {
2479
- const getSelectorForId = usePuck2((s) => s.getSelectorForId);
2480
- const dispatch = usePuck2((s) => s.dispatch);
2789
+ const getSelectorForId = usePuck3((s) => s.getSelectorForId);
2790
+ const dispatch = usePuck3((s) => s.dispatch);
2481
2791
  const show = (issue) => {
2482
- if (issue.pageId && issue.pageId !== currentPageId) return onOpenPage(issue.pageId);
2792
+ if (issue.pageId && issue.pageId !== currentPageId) return onOpenPage(issue.pageId, issue.sectionId);
2483
2793
  if (!issue.sectionId) return;
2484
2794
  const selector = getSelectorForId(issue.sectionId);
2485
2795
  if (!selector) return;
@@ -2493,12 +2803,13 @@ function IssueList({ issues, currentPageId, onOpenPage, onShown }) {
2493
2803
  ] }, i)) });
2494
2804
  }
2495
2805
  function PublishPanel(props) {
2496
- const [note, setNote] = React10.useState("");
2497
- const [rollingBack, setRollingBack] = React10.useState(null);
2498
- const id = React10.useId();
2806
+ const [note, setNote] = React11.useState("");
2807
+ const [rollingBack, setRollingBack] = React11.useState(null);
2808
+ const id = React11.useId();
2499
2809
  const errors = props.issues?.filter((i) => i.severity === "error") ?? [];
2500
2810
  const warnings = props.issues?.filter((i) => i.severity === "warning") ?? [];
2501
2811
  const live = props.releases.find((r) => r.id === props.liveReleaseId);
2812
+ const lookChanged = Boolean(live?.brandHash && props.brandHash && live.brandHash !== props.brandHash);
2502
2813
  const canPublish = props.issues !== null && errors.length === 0 && !props.blockedReason && !props.checking;
2503
2814
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 p-3", children: [
2504
2815
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
@@ -2508,6 +2819,11 @@ function PublishPanel(props) {
2508
2819
  live.number
2509
2820
  ] }) : /* @__PURE__ */ jsx(Badge, { variant: "muted", children: "Not published" })
2510
2821
  ] }),
2822
+ lookChanged ? /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", "data-gs-look-changed": "", children: [
2823
+ "The brand or the site's look changed since release ",
2824
+ live.number,
2825
+ ". Publish to put the new look live."
2826
+ ] }) : null,
2511
2827
  /* @__PURE__ */ jsxs("section", { "aria-labelledby": `${id}-checks`, "aria-busy": props.checking, className: "flex flex-col gap-2", children: [
2512
2828
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
2513
2829
  /* @__PURE__ */ jsx("h3", { id: `${id}-checks`, className: "text-sm font-semibold", children: "Checks" }),
@@ -2556,6 +2872,7 @@ function PublishPanel(props) {
2556
2872
  ),
2557
2873
  /* @__PURE__ */ jsx(Separator, {}),
2558
2874
  /* @__PURE__ */ jsx(SeoFields, { siteName: props.siteName, pagePath: props.pagePath, pageTitle: props.pageTitle, readOnly: props.readOnly === true || props.publishing }),
2875
+ props.pagePath !== "/" && props.pagePath !== NOT_FOUND_PATH && props.pageKind !== "post" ? /* @__PURE__ */ jsx(ShowDates, { pagePath: props.pagePath, readOnly: props.readOnly === true || props.publishing }) : null,
2559
2876
  /* @__PURE__ */ jsx(Separator, {}),
2560
2877
  /* @__PURE__ */ jsxs("section", { "aria-labelledby": `${id}-history`, className: "flex flex-col gap-2", children: [
2561
2878
  /* @__PURE__ */ jsx("h3", { id: `${id}-history`, className: "text-sm font-semibold", children: "Release history" }),
@@ -2605,12 +2922,73 @@ function PublishPanel(props) {
2605
2922
  ] }) })
2606
2923
  ] });
2607
2924
  }
2608
- var usePuck3 = createUsePuck();
2925
+ var usePuck4 = createUsePuck();
2609
2926
  var VIEWPORTS = {
2610
- desktop: { width: "100%", label: "Desktop" },
2927
+ desktop: { width: 1280, label: "Desktop" },
2611
2928
  tablet: { width: 768, label: "Tablet" },
2612
2929
  phone: { width: 390, label: "Phone" }
2613
2930
  };
2931
+ function SizedCanvas({ viewport, children }) {
2932
+ const outer = React11.useRef(null);
2933
+ const [box, setBox] = React11.useState(null);
2934
+ React11.useLayoutEffect(() => {
2935
+ const el = outer.current;
2936
+ if (!el) return;
2937
+ const measure = () => setBox({ width: el.clientWidth, height: el.clientHeight });
2938
+ measure();
2939
+ if (typeof ResizeObserver === "undefined") return;
2940
+ const ro = new ResizeObserver(measure);
2941
+ ro.observe(el);
2942
+ return () => ro.disconnect();
2943
+ }, []);
2944
+ const width = VIEWPORTS[viewport].width;
2945
+ const gutter = 16;
2946
+ const scale = box && box.width > 0 ? Math.min(1, (box.width - gutter * 2) / width) : 1;
2947
+ React11.useEffect(() => {
2948
+ const doc = outer.current?.querySelector("iframe")?.contentDocument;
2949
+ doc?.documentElement?.style.setProperty("--gs-canvas-unzoom", String(1 / scale));
2950
+ });
2951
+ return /* @__PURE__ */ jsx("div", { ref: outer, className: "absolute inset-0 overflow-hidden", "data-gs-viewport": viewport, "data-gs-canvas-scale": scale.toFixed(3), children: /* @__PURE__ */ jsx(
2952
+ "div",
2953
+ {
2954
+ style: {
2955
+ width,
2956
+ height: box ? Math.max(0, box.height - gutter) / scale : "100%",
2957
+ transform: scale === 1 ? void 0 : `scale(${scale})`,
2958
+ transformOrigin: "top left",
2959
+ marginLeft: box ? Math.max(gutter, (box.width - width * scale) / 2) : void 0,
2960
+ marginTop: gutter / 2
2961
+ },
2962
+ className: "bg-background shadow-sm",
2963
+ children
2964
+ }
2965
+ ) });
2966
+ }
2967
+ var token = (name) => `hsl(var(--${name}))`;
2968
+ var PUCK_THEME = {
2969
+ "--puck-color-surface": token("background"),
2970
+ "--puck-color-surface-muted": token("muted"),
2971
+ "--puck-color-surface-subtle": token("muted"),
2972
+ "--puck-color-surface-inverse": token("foreground"),
2973
+ "--puck-color-border": token("border"),
2974
+ "--puck-color-border-hover": token("muted-foreground"),
2975
+ "--puck-color-border-muted": token("border"),
2976
+ "--puck-color-border-inverse": token("muted-foreground"),
2977
+ "--puck-color-text": token("foreground"),
2978
+ "--puck-color-text-secondary": token("muted-foreground"),
2979
+ "--puck-color-text-muted": token("muted-foreground"),
2980
+ "--puck-color-text-subtle": token("muted-foreground"),
2981
+ "--puck-color-text-inverse": token("background"),
2982
+ "--puck-color-interactive": token("primary"),
2983
+ "--puck-color-interactive-hover": token("primary"),
2984
+ "--puck-color-interactive-active": token("primary"),
2985
+ "--puck-color-interactive-subtle": token("accent"),
2986
+ "--puck-color-interactive-soft": token("accent"),
2987
+ "--puck-color-interactive-soft-hover": token("accent"),
2988
+ "--puck-color-interactive-neutral-hover": token("accent"),
2989
+ "--puck-color-focus-ring": token("ring"),
2990
+ "--puck-color-selection-border": token("ring")
2991
+ };
2614
2992
  var LOCKED = { drag: false, duplicate: false, delete: false, edit: false, insert: false };
2615
2993
  var UNLOCKED = { drag: true, duplicate: true, delete: true, edit: true, insert: true };
2616
2994
  function saveAndDispose(saver) {
@@ -2633,9 +3011,9 @@ function worst(...states) {
2633
3011
  return "saved";
2634
3012
  }
2635
3013
  function useCanvasFrame(css, href, theme, dark, lang) {
2636
- return React10.useCallback(
3014
+ return React11.useCallback(
2637
3015
  ({ children, document: document2 }) => {
2638
- React10.useEffect(() => {
3016
+ React11.useEffect(() => {
2639
3017
  if (!document2) return;
2640
3018
  const nodes = [];
2641
3019
  if (href) {
@@ -2652,7 +3030,10 @@ function useCanvasFrame(css, href, theme, dark, lang) {
2652
3030
  }
2653
3031
  const vars = document2.createElement("style");
2654
3032
  vars.dataset.gsTheme = "";
2655
- vars.textContent = styleText(theme.replace(/:root/g, "html:root"));
3033
+ vars.textContent = styleText(
3034
+ theme.replace(/:root/g, "html:root") + // The section toolbar stays its own size when the canvas scales the frame down (SizedCanvas).
3035
+ '\n[class*="DraggableComponent-actions"]{transform:scale(var(--gs-canvas-unzoom,1))!important;transform-origin:top right}\n[data-puck-entry]{padding-top:calc(52px * var(--gs-canvas-unzoom,1))}'
3036
+ );
2656
3037
  nodes.push(vars);
2657
3038
  for (const n of nodes) document2.head.appendChild(n);
2658
3039
  const keepLast = new MutationObserver(() => {
@@ -2675,12 +3056,30 @@ function useCanvasFrame(css, href, theme, dark, lang) {
2675
3056
  [css, href, theme, dark, lang]
2676
3057
  );
2677
3058
  }
3059
+ function HistoryKeeper({ pageId, store }) {
3060
+ const histories = usePuck4((s) => s.history.histories);
3061
+ const index = usePuck4((s) => s.history.index);
3062
+ React11.useEffect(() => {
3063
+ store.set(pageId, { histories, index });
3064
+ }, [pageId, store, histories, index]);
3065
+ return null;
3066
+ }
3067
+ function initialHistoryFor(store, pageId, data, options2) {
3068
+ const kept = store.get(pageId);
3069
+ const current = kept?.histories[kept.index]?.state;
3070
+ if (!kept || !current?.data) return void 0;
3071
+ const saved = (d) => stableJson(fromEditorData(d, options2));
3072
+ return saved(current.data) === saved(data) ? kept : void 0;
3073
+ }
3074
+ function stableJson(value) {
3075
+ return JSON.stringify(value, (_k, v) => v && typeof v === "object" && !Array.isArray(v) ? Object.fromEntries(Object.entries(v).sort(([a], [b]) => a.localeCompare(b))) : v);
3076
+ }
2678
3077
  function Toolbar({ siteName, pageTitle, titleId, saveStatus, mode, viewport, onViewport, onPreview }) {
2679
- const history = usePuck3((s) => s.history);
2680
- const dispatch = usePuck3((s) => s.dispatch);
3078
+ const history = usePuck4((s) => s.history);
3079
+ const dispatch = usePuck4((s) => s.dispatch);
2681
3080
  const choose = (v) => {
2682
3081
  onViewport(v);
2683
- dispatch({ type: "setUi", ui: (ui) => ({ viewports: { ...ui.viewports, current: { width: VIEWPORTS[v].width, height: "auto" } } }) });
3082
+ dispatch({ type: "setUi", ui: (ui) => ({ viewports: { ...ui.viewports, current: { width: VIEWPORTS[v].width, height: "auto" } } }), recordHistory: false });
2684
3083
  };
2685
3084
  return /* @__PURE__ */ jsxs("header", { className: "flex flex-wrap items-center justify-between gap-2 border-b border-border bg-background px-3 py-2", children: [
2686
3085
  /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col", children: [
@@ -2703,18 +3102,32 @@ function Toolbar({ siteName, pageTitle, titleId, saveStatus, mode, viewport, onV
2703
3102
  ] });
2704
3103
  }
2705
3104
  function useSelectFooter() {
2706
- const dispatch = usePuck3((s) => s.dispatch);
2707
- const getSelectorForId = usePuck3((s) => s.getSelectorForId);
2708
- const footer = usePuck3((s) => s.appState.data.root.props?.footer);
3105
+ const dispatch = usePuck4((s) => s.dispatch);
3106
+ const getSelectorForId = usePuck4((s) => s.getSelectorForId);
3107
+ const footer = usePuck4((s) => s.appState.data.root.props?.footer);
2709
3108
  return () => {
2710
3109
  const first = footer?.[0];
2711
3110
  const selector = first ? getSelectorForId(first.props.id) : void 0;
2712
3111
  if (selector) dispatch({ type: "setUi", ui: { itemSelector: selector, rightSideBarVisible: true } });
2713
3112
  };
2714
3113
  }
3114
+ function PendingShow({ pending }) {
3115
+ const dispatch = usePuck4((s) => s.dispatch);
3116
+ const getSelectorForId = usePuck4((s) => s.getSelectorForId);
3117
+ React11.useEffect(() => {
3118
+ const id = pending.current;
3119
+ if (!id) return;
3120
+ const selector = getSelectorForId(id);
3121
+ if (!selector) return;
3122
+ pending.current = null;
3123
+ dispatch({ type: "setUi", ui: { itemSelector: selector, rightSideBarVisible: true } });
3124
+ scrollCanvasTo(id);
3125
+ });
3126
+ return null;
3127
+ }
2715
3128
  function SelectionWatcher({ onSelect }) {
2716
- const selected = usePuck3((s) => s.selectedItem?.props.id);
2717
- React10.useEffect(() => {
3129
+ const selected = usePuck4((s) => s.selectedItem?.props.id);
3130
+ React11.useEffect(() => {
2718
3131
  if (selected) onSelect();
2719
3132
  }, [selected]);
2720
3133
  return null;
@@ -2732,46 +3145,48 @@ function PagesTab(props) {
2732
3145
  }
2733
3146
  );
2734
3147
  }
2735
- function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved, landingDirectory: defaultLanding, destinations, previewUrl, autosaveDelay, initialPageId, siteStylesheet, readOnly = false, onDirtyChange, className }) {
2736
- const [loadError, setLoadError] = React10.useState(null);
2737
- const [site, setSite] = React10.useState(null);
2738
- const [pages, setPages] = React10.useState([]);
2739
- const [open, setOpen] = React10.useState(null);
2740
- const [editorKey, setEditorKey] = React10.useState(0);
2741
- const [siteState, setSiteState] = React10.useState(null);
2742
- const [pageState, setPageState] = React10.useState(null);
2743
- const [invalid, setInvalid] = React10.useState(null);
2744
- const [busy, setBusy] = React10.useState(false);
2745
- const [notice, setNotice] = React10.useState(null);
2746
- const [css, setCss] = React10.useState(null);
2747
- const [h1Id, setH1Id] = React10.useState(null);
2748
- const [formMap, setFormMap] = React10.useState(/* @__PURE__ */ new Map());
2749
- const [issues, setIssues] = React10.useState(null);
2750
- const [checking, setChecking] = React10.useState(false);
2751
- const [publishing, setPublishing] = React10.useState(false);
2752
- const [releases, setReleases] = React10.useState([]);
2753
- const [liveId, setLiveId] = React10.useState(null);
2754
- const [liveIds, setLiveIds] = React10.useState(null);
2755
- const [leftTab, setLeftTab] = React10.useState(readOnly ? "outline" : "add");
2756
- const [rightTab, setRightTab] = React10.useState("edit");
2757
- const [viewport, setViewport] = React10.useState("desktop");
2758
- const [picker, setPicker] = React10.useState(null);
2759
- const [preview, setPreview] = React10.useState(null);
2760
- const siteSaver = React10.useRef(null);
2761
- const pageSaver = React10.useRef(null);
2762
- const pageSaverFor = React10.useRef(null);
2763
- const counts = React10.useRef(/* @__PURE__ */ new Map());
2764
- const focusTitle = React10.useRef(false);
2765
- const titleId = React10.useId();
2766
- const [announcement, setAnnouncement] = React10.useState("");
2767
- const [menuDraft, setMenuDraft] = React10.useState(null);
3148
+ function SiteEditor({ siteId, store, brand, forms, listForms, checks, assets, onPublish, brandSettingsHref, reserved, landingDirectory: defaultLanding, destinations, previewUrl, autosaveDelay, initialPageId, siteStylesheet, readOnly = false, onDirtyChange, className }) {
3149
+ const [loadError, setLoadError] = React11.useState(null);
3150
+ const [site, setSite] = React11.useState(null);
3151
+ const [pages, setPages] = React11.useState([]);
3152
+ const [open, setOpen] = React11.useState(null);
3153
+ const [editorKey, setEditorKey] = React11.useState(0);
3154
+ const histories = React11.useRef(/* @__PURE__ */ new Map()).current;
3155
+ const [siteState, setSiteState] = React11.useState(null);
3156
+ const [pageState, setPageState] = React11.useState(null);
3157
+ const [invalid, setInvalid] = React11.useState(null);
3158
+ const [busy, setBusy] = React11.useState(false);
3159
+ const [notice, setNotice] = React11.useState(null);
3160
+ const [css, setCss] = React11.useState(null);
3161
+ const [h1Id, setH1Id] = React11.useState(null);
3162
+ const [formMap, setFormMap] = React11.useState(/* @__PURE__ */ new Map());
3163
+ const [issues, setIssues] = React11.useState(null);
3164
+ const [checking, setChecking] = React11.useState(false);
3165
+ const [publishing, setPublishing] = React11.useState(false);
3166
+ const [releases, setReleases] = React11.useState([]);
3167
+ const [liveId, setLiveId] = React11.useState(null);
3168
+ const [liveIds, setLiveIds] = React11.useState(null);
3169
+ const [leftTab, setLeftTab] = React11.useState(readOnly ? "outline" : "add");
3170
+ const [rightTab, setRightTab] = React11.useState("edit");
3171
+ const [viewport, setViewport] = React11.useState("desktop");
3172
+ const [picker, setPicker] = React11.useState(null);
3173
+ const [preview, setPreview] = React11.useState(null);
3174
+ const pendingShow = React11.useRef(null);
3175
+ const siteSaver = React11.useRef(null);
3176
+ const pageSaver = React11.useRef(null);
3177
+ const pageSaverFor = React11.useRef(null);
3178
+ const counts = React11.useRef(/* @__PURE__ */ new Map());
3179
+ const focusTitle = React11.useRef(false);
3180
+ const titleId = React11.useId();
3181
+ const [announcement, setAnnouncement] = React11.useState("");
3182
+ const [menuDraft, setMenuDraft] = React11.useState(null);
2768
3183
  const locked = readOnly || publishing;
2769
- const lockedRef = React10.useRef(locked);
3184
+ const lockedRef = React11.useRef(locked);
2770
3185
  lockedRef.current = locked;
2771
3186
  const kind = open?.kind ?? "page";
2772
- const editor = React10.useMemo(() => createEditorConfig({ kind, counts: () => counts.current, readOnly: () => lockedRef.current }), [kind]);
2773
- const slotKeys = React10.useMemo(() => createEditorConfig().slotKeys, []);
2774
- const theme = React10.useMemo(() => {
3187
+ const editor = React11.useMemo(() => createEditorConfig({ kind, counts: () => counts.current, readOnly: () => lockedRef.current }), [kind]);
3188
+ const slotKeys = React11.useMemo(() => createEditorConfig().slotKeys, []);
3189
+ const theme = React11.useMemo(() => {
2775
3190
  try {
2776
3191
  return siteTheme(brand, site?.theme ?? {});
2777
3192
  } catch (err) {
@@ -2780,7 +3195,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
2780
3195
  }
2781
3196
  }, [brand, site?.theme]);
2782
3197
  const iframe = useCanvasFrame(css, siteStylesheet, themeCss(theme), theme.colorScheme === "dark", site?.lang ?? "en");
2783
- const loadPage = React10.useCallback(
3198
+ const loadPage = React11.useCallback(
2784
3199
  async (pageId, siteDoc) => {
2785
3200
  const draft = await store.getPageDraft(pageId);
2786
3201
  if (!draft) throw new Error("That page no longer exists, or you can't edit it.");
@@ -2809,13 +3224,13 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
2809
3224
  },
2810
3225
  [store, autosaveDelay, slotKeys, readOnly]
2811
3226
  );
2812
- const refreshPublishing = React10.useCallback(async () => {
3227
+ const refreshPublishing = React11.useCallback(async () => {
2813
3228
  const [list, live] = await Promise.all([store.listReleases(siteId), store.getLive(siteId)]);
2814
3229
  setReleases(list);
2815
3230
  setLiveId(live?.id ?? null);
2816
3231
  setLiveIds(new Set(live?.snapshot.pages.map((p) => p.id) ?? []));
2817
3232
  }, [store, siteId]);
2818
- React10.useEffect(() => {
3233
+ React11.useEffect(() => {
2819
3234
  let cancelled = false;
2820
3235
  (async () => {
2821
3236
  try {
@@ -2846,7 +3261,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
2846
3261
  };
2847
3262
  }, [siteId, store, readOnly]);
2848
3263
  const menuInvalid = menuDraft !== null && !menuDraft.every((i) => menuItemProblems(i).length === 0);
2849
- React10.useEffect(() => {
3264
+ React11.useEffect(() => {
2850
3265
  const guard = (e) => {
2851
3266
  if (siteSaver.current?.dirty || pageSaver.current?.dirty || invalid || menuInvalid) {
2852
3267
  e.preventDefault();
@@ -2857,20 +3272,20 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
2857
3272
  return () => window.removeEventListener("beforeunload", guard);
2858
3273
  }, [invalid, menuInvalid]);
2859
3274
  const dirty = !readOnly && (worst(siteState, pageState) !== "saved" || Boolean(invalid) || menuInvalid);
2860
- const dirtyReported = React10.useRef(false);
2861
- const onDirtyChangeRef = React10.useRef(onDirtyChange);
3275
+ const dirtyReported = React11.useRef(false);
3276
+ const onDirtyChangeRef = React11.useRef(onDirtyChange);
2862
3277
  onDirtyChangeRef.current = onDirtyChange;
2863
- React10.useEffect(() => {
3278
+ React11.useEffect(() => {
2864
3279
  if (dirty === dirtyReported.current) return;
2865
3280
  dirtyReported.current = dirty;
2866
3281
  onDirtyChangeRef.current?.(dirty);
2867
3282
  }, [dirty]);
2868
- const formSlugs = React10.useMemo(() => {
3283
+ const formSlugs = React11.useMemo(() => {
2869
3284
  const slugs = /* @__PURE__ */ new Set();
2870
3285
  for (const item of open?.data.content ?? []) if (item.type.startsWith("form-embed") && typeof item.props.form === "string") slugs.add(item.props.form);
2871
3286
  return [...slugs].sort().join(",");
2872
3287
  }, [open]);
2873
- React10.useEffect(() => {
3288
+ React11.useEffect(() => {
2874
3289
  if (!forms || !formSlugs) return;
2875
3290
  let cancelled = false;
2876
3291
  Promise.all(formSlugs.split(",").map(async (slug) => [slug, await Promise.resolve(forms(slug, { siteId, pagePath: open?.path ?? "/", mode: "preview" })).catch(() => null)])).then((entries) => {
@@ -2880,7 +3295,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
2880
3295
  cancelled = true;
2881
3296
  };
2882
3297
  }, [forms, formSlugs, siteId, open?.path]);
2883
- const onChange = React10.useCallback(
3298
+ const onChange = React11.useCallback(
2884
3299
  (data) => {
2885
3300
  if (!open || !site || readOnly || pageSaverFor.current !== open.id) return;
2886
3301
  const editorData = data;
@@ -2891,8 +3306,8 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
2891
3306
  const current = siteSaver.current?.latest ?? site;
2892
3307
  const nextSite = SiteDoc.safeParse({ ...current, header: result.header, footer: result.footer });
2893
3308
  const problems = [
2894
- ...page.success ? [] : page.error.issues.map((i) => i.path.join(".") === "root.props.title" ? "The page needs a title." : `${i.path.join(".")}: ${i.message}`),
2895
- ...nextSite.success ? [] : nextSite.error.issues.map((i) => `Site ${i.path.join(".")}: ${i.message}`)
3309
+ ...page.success ? [] : page.error.issues.map((i) => i.path.join(".") === "root.props.title" ? "The page needs a title." : friendlyIssue(i)),
3310
+ ...nextSite.success ? [] : nextSite.error.issues.map((i) => `Site ${friendlyIssue(i)}`)
2896
3311
  ];
2897
3312
  setInvalid(problems.length ? problems.join(" ") : null);
2898
3313
  if (page.success) {
@@ -2907,7 +3322,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
2907
3322
  },
2908
3323
  [open, site, slotKeys, readOnly]
2909
3324
  );
2910
- const onNavChange = React10.useCallback(
3325
+ const onNavChange = React11.useCallback(
2911
3326
  (nav) => {
2912
3327
  const current = siteSaver.current?.latest ?? site;
2913
3328
  if (!current || readOnly) return;
@@ -2918,7 +3333,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
2918
3333
  },
2919
3334
  [site, readOnly]
2920
3335
  );
2921
- const onRedirectsChange = React10.useCallback(
3336
+ const onRedirectsChange = React11.useCallback(
2922
3337
  (redirects) => {
2923
3338
  const current = siteSaver.current?.latest ?? site;
2924
3339
  if (!current || readOnly) return "This site can't be changed here.";
@@ -2930,7 +3345,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
2930
3345
  },
2931
3346
  [site, readOnly]
2932
3347
  );
2933
- const onSeoChange = React10.useCallback(
3348
+ const onSeoChange = React11.useCallback(
2934
3349
  (seo) => {
2935
3350
  const current = siteSaver.current?.latest ?? site;
2936
3351
  if (!current || readOnly) return "This site can't be changed here.";
@@ -2942,14 +3357,14 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
2942
3357
  },
2943
3358
  [site, readOnly]
2944
3359
  );
2945
- const onMenuEdit = React10.useCallback(
3360
+ const onMenuEdit = React11.useCallback(
2946
3361
  (items) => {
2947
3362
  setMenuDraft(items);
2948
3363
  if (items.every((i) => menuItemProblems(i).length === 0)) onNavChange(items.map((i) => ({ label: i.label.trim(), href: i.href.trim() })));
2949
3364
  },
2950
3365
  [onNavChange]
2951
3366
  );
2952
- const flushAll = React10.useCallback(async () => {
3367
+ const flushAll = React11.useCallback(async () => {
2953
3368
  if (invalid) {
2954
3369
  setNotice({ tone: "error", text: `Fix this first: ${invalid}` });
2955
3370
  return false;
@@ -2966,7 +3381,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
2966
3381
  return false;
2967
3382
  }
2968
3383
  }, [invalid, menuInvalid]);
2969
- const resync = React10.useCallback(async (options2 = {}) => {
3384
+ const resync = React11.useCallback(async (options2 = {}) => {
2970
3385
  const [draft, list] = await Promise.all([store.getDraft(siteId), store.listPages(siteId)]);
2971
3386
  setPages(list);
2972
3387
  let redraw = false;
@@ -3000,20 +3415,20 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
3000
3415
  }
3001
3416
  return { draft, list };
3002
3417
  }, [store, siteId, open, site, slotKeys]);
3003
- const runCheck = React10.useCallback(async () => {
3418
+ const runCheck = React11.useCallback(async () => {
3004
3419
  if (!await flushAll()) return;
3005
3420
  setChecking(true);
3006
3421
  try {
3007
- const result = await checkSite(store, siteId, { brand, ...reserved ? { reserved } : {} });
3422
+ const result = await checkSite(store, siteId, { brand, ...reserved ? { reserved } : {}, ...forms ? { forms } : {}, ...listForms ? { listForms } : {}, ...checks ? { checks } : {} });
3008
3423
  setIssues(result.issues);
3009
3424
  } catch (err) {
3010
3425
  setIssues([{ severity: "error", code: "check-failed", message: `The checks couldn't run: ${err.message}` }]);
3011
3426
  } finally {
3012
3427
  setChecking(false);
3013
3428
  }
3014
- }, [flushAll, store, siteId, brand, reserved]);
3429
+ }, [flushAll, store, siteId, brand, reserved, forms, listForms, checks]);
3015
3430
  const settled = worst(siteState, pageState) === "saved" && !invalid;
3016
- React10.useEffect(() => {
3431
+ React11.useEffect(() => {
3017
3432
  if (rightTab !== "publish" || !settled) return;
3018
3433
  const t = setTimeout(() => void runCheck(), 600);
3019
3434
  return () => clearTimeout(t);
@@ -3153,7 +3568,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
3153
3568
  for (const s of savers) s?.pause();
3154
3569
  held = true;
3155
3570
  published = await publishedDrafts();
3156
- const result = await publishSite(store, siteId, { brand, note, ...reserved ? { reserved } : {} });
3571
+ const result = await publishSite(store, siteId, { brand, note, ...reserved ? { reserved } : {}, ...forms ? { forms } : {}, ...listForms ? { listForms } : {}, ...checks ? { checks } : {} });
3157
3572
  if ("blocked" in result) {
3158
3573
  setIssues(result.blocked);
3159
3574
  setNotice({ tone: "error", text: "Not published: fix the problems the checks list." });
@@ -3233,13 +3648,13 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
3233
3648
  function focusPageTitle() {
3234
3649
  requestAnimationFrame(() => document.getElementById(titleId)?.focus());
3235
3650
  }
3236
- React10.useEffect(() => setViewport("desktop"), [editorKey]);
3237
- React10.useEffect(() => {
3651
+ React11.useEffect(() => setViewport("desktop"), [editorKey]);
3652
+ React11.useEffect(() => {
3238
3653
  if (!focusTitle.current) return;
3239
3654
  focusTitle.current = false;
3240
3655
  focusPageTitle();
3241
3656
  }, [editorKey]);
3242
- const announce = React10.useCallback((message) => {
3657
+ const announce = React11.useCallback((message) => {
3243
3658
  setAnnouncement("");
3244
3659
  requestAnimationFrame(() => setAnnouncement(message));
3245
3660
  }, []);
@@ -3249,16 +3664,17 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
3249
3664
  const textEntry = target.closest("textarea, [contenteditable=''], [contenteditable='true']") || target instanceof HTMLInputElement && !["button", "checkbox", "radio", "submit", "reset", "file", "range", "color"].includes(target.type);
3250
3665
  if (!textEntry) e.preventDefault();
3251
3666
  };
3252
- const services = React10.useMemo(
3667
+ const services = React11.useMemo(
3253
3668
  () => ({
3254
3669
  siteId,
3255
3670
  store,
3256
3671
  ...assets ? { assets } : {},
3672
+ ...listForms ? { listForms } : {},
3257
3673
  pickImage: (opts) => new Promise((resolve) => setPicker({ ...opts?.current ? { current: opts.current } : {}, ...opts?.altElsewhere ? { altElsewhere: true } : {}, resolve }))
3258
3674
  }),
3259
- [siteId, store, assets]
3675
+ [siteId, store, assets, listForms]
3260
3676
  );
3261
- const metadata = React10.useMemo(
3677
+ const metadata = React11.useMemo(
3262
3678
  () => ({
3263
3679
  site: { name: site?.name ?? "", lang: site?.lang ?? "en", nav: site?.nav ?? [], ...brand && "logo" in brand && brand.logo ? { logo: { src: brand.logo.src, alt: brand.logo.alt?.trim() || brandDisplayName(brand) } } : {} },
3264
3680
  pagePath: open?.path ?? "/",
@@ -3268,7 +3684,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
3268
3684
  }),
3269
3685
  [site?.name, site?.lang, site?.nav, brand, open?.path, open?.placeholders, formMap, h1Id]
3270
3686
  );
3271
- const overrides = React10.useMemo(() => genesisOverrides(editor.components, { iframe }, { announce }), [editor.components, iframe, announce]);
3687
+ const overrides = React11.useMemo(() => genesisOverrides(editor.components, { iframe }, { announce }), [editor.components, iframe, announce]);
3272
3688
  const permissions = locked ? LOCKED : UNLOCKED;
3273
3689
  if (loadError) {
3274
3690
  return /* @__PURE__ */ jsxs(Alert, { variant: "destructive", className, children: [
@@ -3286,12 +3702,16 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
3286
3702
  const pageMeta = pages.find((p) => p.id === open.id);
3287
3703
  const pageTitle = pageMeta?.title ?? open.data.root.props.title;
3288
3704
  const blockedReason = invalid ? `Fix this first: ${invalid}` : conflict ? "Choose a version in the conflict first." : null;
3289
- return /* @__PURE__ */ jsx(EditorServicesContext.Provider, { value: services, children: /* @__PURE__ */ jsx(EditorLockContext.Provider, { value: locked, children: /* @__PURE__ */ jsxs("div", { className: cn("flex h-full min-h-0 flex-col bg-background text-foreground", className), "data-gs-editor": "", children: [
3705
+ return /* @__PURE__ */ jsx(EditorServicesContext.Provider, { value: services, children: /* @__PURE__ */ jsx(EditorLockContext.Provider, { value: locked, children: /* @__PURE__ */ jsxs("div", { className: cn("flex h-full min-h-0 flex-col bg-background text-foreground", className), style: PUCK_THEME, "data-gs-editor": "", children: [
3290
3706
  /* @__PURE__ */ jsx(
3291
3707
  Puck,
3292
3708
  {
3293
3709
  config: editor.config,
3294
3710
  data: open.data,
3711
+ ...(() => {
3712
+ const kept = initialHistoryFor(histories, open.id, open.data, { slotKeys, placeholders: open.placeholders });
3713
+ return kept ? { initialHistory: { histories: kept.histories, index: kept.index, appendData: false } } : {};
3714
+ })(),
3295
3715
  onChange,
3296
3716
  permissions,
3297
3717
  overrides,
@@ -3300,11 +3720,13 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
3300
3720
  viewports: [
3301
3721
  { width: 390, label: "Phone", icon: "Smartphone" },
3302
3722
  { width: 768, label: "Tablet", icon: "Tablet" },
3303
- { width: "100%", label: "Desktop", icon: "Monitor" }
3723
+ { width: 1280, label: "Desktop", icon: "Monitor" }
3304
3724
  ],
3305
3725
  headerTitle: site.name,
3306
3726
  children: /* @__PURE__ */ jsxs("div", { className: "flex h-full min-h-0 flex-col", children: [
3307
3727
  /* @__PURE__ */ jsx(SelectionWatcher, { onSelect: () => setRightTab("edit") }),
3728
+ /* @__PURE__ */ jsx(HistoryKeeper, { pageId: open.id, store: histories }),
3729
+ /* @__PURE__ */ jsx(PendingShow, { pending: pendingShow }),
3308
3730
  /* @__PURE__ */ jsx("p", { role: "status", className: "sr-only", children: announcement }),
3309
3731
  /* @__PURE__ */ jsx(Toolbar, { siteName: site.name, pageTitle: `${pageTitle} (${open.path})`, titleId, saveStatus, mode: readOnly ? "view" : publishing ? "publishing" : "edit", viewport, onViewport: setViewport, onPreview: () => void showPreview("preview") }),
3310
3732
  readOnly ? /* @__PURE__ */ jsx("p", { role: "note", className: "border-b border-border bg-muted px-3 py-2 text-sm", "data-gs-view-only": "", children: "View only: you can look through this site's pages, but not change or publish them." }) : null,
@@ -3319,7 +3741,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
3319
3741
  ] }) : null
3320
3742
  ] }) : null,
3321
3743
  /* @__PURE__ */ jsxs("div", { className: "grid min-h-0 flex-1 grid-cols-1 overflow-y-auto lg:grid-cols-[17rem_minmax(0,1fr)_20rem] lg:overflow-visible", inert: busy || void 0, "aria-busy": busy || void 0, children: [
3322
- /* @__PURE__ */ jsx("aside", { className: "flex flex-col border-b border-border lg:min-h-0 lg:border-b-0 lg:border-r", "aria-label": "Sections and pages", onKeyDown: keepDeleteInPanel, children: /* @__PURE__ */ jsxs(Tabs, { defaultValue: "add", value: leftTab, onValueChange: setLeftTab, className: "flex min-h-0 flex-1 flex-col", children: [
3744
+ /* @__PURE__ */ jsx("aside", { className: "flex max-h-[45vh] flex-col border-b border-border lg:max-h-none lg:min-h-0 lg:border-b-0 lg:border-r", "aria-label": "Sections and pages", onKeyDown: keepDeleteInPanel, children: /* @__PURE__ */ jsxs(Tabs, { defaultValue: "add", value: leftTab, onValueChange: setLeftTab, className: "flex min-h-0 flex-1 flex-col", children: [
3323
3745
  /* @__PURE__ */ jsxs(TabsList, { className: cn("m-2 grid", readOnly ? "grid-cols-2" : "grid-cols-3"), children: [
3324
3746
  readOnly ? null : /* @__PURE__ */ jsx(TabsTrigger, { value: "add", children: "Add" }),
3325
3747
  /* @__PURE__ */ jsx(TabsTrigger, { value: "outline", children: "Outline" }),
@@ -3347,6 +3769,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
3347
3769
  onReorder: reorder,
3348
3770
  onNavChange: onMenuEdit,
3349
3771
  onFooter: () => setRightTab("edit"),
3772
+ brandSettingsHref,
3350
3773
  landing: /* @__PURE__ */ jsx(
3351
3774
  LandingPanel,
3352
3775
  {
@@ -3380,7 +3803,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
3380
3803
  }
3381
3804
  ) })
3382
3805
  ] }) }),
3383
- /* @__PURE__ */ jsx("section", { className: "relative min-h-[28rem] min-w-0 bg-muted", "aria-label": "Page canvas", "data-gs-canvas": "", children: /* @__PURE__ */ jsx(Puck.Preview, {}) }),
3806
+ /* @__PURE__ */ jsx("section", { className: "relative min-h-[28rem] min-w-0 bg-muted", "aria-label": "Page canvas", "data-gs-canvas": "", children: /* @__PURE__ */ jsx(SizedCanvas, { viewport, children: /* @__PURE__ */ jsx(Puck.Preview, {}) }) }),
3384
3807
  /* @__PURE__ */ jsx("aside", { className: "flex flex-col border-t border-border lg:min-h-0 lg:border-l lg:border-t-0", "aria-label": "Section settings and publishing", onKeyDown: keepDeleteInPanel, children: /* @__PURE__ */ jsxs(Tabs, { defaultValue: "edit", value: rightTab, onValueChange: setRightTab, className: "flex min-h-0 flex-1 flex-col", children: [
3385
3808
  /* @__PURE__ */ jsxs(TabsList, { className: "m-2 grid grid-cols-2", children: [
3386
3809
  /* @__PURE__ */ jsx(TabsTrigger, { value: "edit", children: "Edit" }),
@@ -3391,6 +3814,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
3391
3814
  PublishPanel,
3392
3815
  {
3393
3816
  pagePath: open.path,
3817
+ pageKind: open.kind,
3394
3818
  pageTitle,
3395
3819
  siteName: site.name,
3396
3820
  issues,
@@ -3399,6 +3823,7 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
3399
3823
  blockedReason,
3400
3824
  releases,
3401
3825
  liveReleaseId: liveId,
3826
+ brandHash: theme.brandHash,
3402
3827
  previewUrl,
3403
3828
  currentPageId: open.id,
3404
3829
  readOnly,
@@ -3406,7 +3831,10 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
3406
3831
  onPublish: publish,
3407
3832
  onRollback: rollback,
3408
3833
  onPreview: (mode) => void showPreview(mode),
3409
- onOpenPage: (id) => void openPage(id),
3834
+ onOpenPage: (id, sectionId) => {
3835
+ pendingShow.current = sectionId ?? null;
3836
+ void openPage(id);
3837
+ },
3410
3838
  onShowSection: (id) => {
3411
3839
  setRightTab("edit");
3412
3840
  scrollCanvasTo(id);
@@ -3457,6 +3885,6 @@ function SiteEditor({ siteId, store, brand, forms, assets, onPublish, reserved,
3457
3885
  ] }) }) });
3458
3886
  }
3459
3887
 
3460
- export { AssetPicker, AutosaveBlockedError, Autosaver, IMAGE_TYPES, LandingDirectoryError, NODE_KEYS, SiteEditor, checkSite, countTypes, createEditorConfig, createLandingPage, fromEditorData, genesisOverrides, h1SectionId, humanize, itemToNode, moveLandingPage, movePageInList, nodeToItem, pageTemplates, pathProblems, placeholderSnapshot, presetComponentName, pruneEmpty, publishSite, renamePage, renderPreview, safeSectionId, sectionFields, sectionTypeOf, setLandingDirectory, slugify, toEditorData, uploadProblem };
3888
+ export { AssetPicker, AutosaveBlockedError, Autosaver, IMAGE_TYPES, LandingDirectoryError, NODE_KEYS, SiteEditor, checkSite, countTypes, createEditorConfig, createLandingPage, fromEditorData, genesisOverrides, h1SectionId, humanize, isUneditedSample, itemToNode, moveLandingPage, movePageInList, nodeToItem, pageTemplates, pathProblems, placeholderSnapshot, presetComponentName, pruneEmpty, publishSite, renamePage, renderPreview, safeSectionId, sectionFields, sectionTypeOf, setLandingDirectory, slugify, toEditorData, uploadProblem };
3461
3889
  //# sourceMappingURL=editor.js.map
3462
3890
  //# sourceMappingURL=editor.js.map