From 93341da5a5f047c1132309421ee6824fd7995a46 Mon Sep 17 00:00:00 2001 From: John Coffey Date: Sun, 25 Oct 2026 00:03:31 -0700 Subject: [PATCH] GA4: Consent Mode signals, and ad_conversions for Google ads GA4 is told what the visitor agreed to when it starts: statistics granted, ad personalization denied, ad measurement only with ad_conversions: true. Without the signals Google drops what it learns from visitors in the EEA and the UK. ad_conversions (ga4, consent required) says so in the banner and the privacy notice and adds Google ad hosts to the CSP. The editor offers it and keeps it when saving. --- docs/privacy.md | 15 +++++++++ editor-ui/src/Privacy.tsx | 9 +++++- editor-ui/src/api.ts | 2 +- internal/build/consent.go | 17 +++++++++- internal/build/static/hotdog-consent.js | 7 +++- internal/check/consent_test.go | 32 +++++++++++++++++-- internal/editor/privacy.go | 3 ++ ...r-Bk2XWLOr.js => VisualEditor-ChliXE4b.js} | 2 +- .../{index-D5e-FBh8.js => index-CG9QFeJ3.js} | 6 ++-- internal/editor/ui/dist/index.html | 2 +- internal/site/config.go | 10 ++++++ 11 files changed, 93 insertions(+), 12 deletions(-) rename internal/editor/ui/dist/assets/{VisualEditor-Bk2XWLOr.js => VisualEditor-ChliXE4b.js} (99%) rename internal/editor/ui/dist/assets/{index-D5e-FBh8.js => index-CG9QFeJ3.js} (92%) diff --git a/docs/privacy.md b/docs/privacy.md index 7b9eba2..d880b81 100644 --- a/docs/privacy.md +++ b/docs/privacy.md @@ -32,6 +32,21 @@ strict Content-Security-Policy still holds. check -csp` includes them in the policy it prints, and so do container images built with `csp: true`. +**Google ads:** with GA4, `ad_conversions: true` also measures the site's +Google Ads campaigns, for visitors who accept: whether a visit from one of the +ads went on to sign up or buy. The banner says so, the privacy notice gets a +line for it, and the policy from `check -csp` adds Google's ad hosts. + +```yaml +analytics: { provider: ga4, id: G-XXXXXXX, ad_conversions: true } +``` + +GA4 is always told what the visitor agreed to (Google's Consent Mode), so +what it learns from visitors in the EEA and the UK isn't thrown away: +statistics granted, ad personalization denied, and ad measurement granted +only with `ad_conversions: true`. It needs consent, so it can't be combined +with `gated: false`. + **Counting without asking** needs `gated: false` in `analytics:`. That's a choice written into `site.yaml` where a reviewer sees it. The privacy notice says so, and `check` warns (`analytics-ungated`) on every build. diff --git a/editor-ui/src/Privacy.tsx b/editor-ui/src/Privacy.tsx index 03be90d..7994f87 100644 --- a/editor-ui/src/Privacy.tsx +++ b/editor-ui/src/Privacy.tsx @@ -83,10 +83,17 @@ export function PrivacyView({ id, branch }: { id: string; branch?: string }) { {an?.provider === 'ga4' && field('id', 'Measurement ID', 'G-XXXXXXX')} {an && ( )} + {an?.provider === 'ga4' && gated && ( + + )} {an && gated &&

A banner asks on the first visit, with Decline first and as prominent as Accept. Nothing is counted until someone accepts; declining later removes the counter's cookies.

} {an && !gated &&

Statistics will start on page view, without asking. That's recorded in site.yaml (gated: false), the privacy notice says so, and every check warns about it. In much of the world, counting with cookies needs consent.

} diff --git a/editor-ui/src/api.ts b/editor-ui/src/api.ts index e139619..ca2e6be 100644 --- a/editor-ui/src/api.ts +++ b/editor-ui/src/api.ts @@ -31,7 +31,7 @@ export type LookValue = string | { light?: string; dark?: string } export type LookInfo = { look: LookFile | null; values: Record; branch: string; commit: string; canWrite: boolean; minContrast: number } export type FileInfo = { path: string; size: number; text: boolean } export type Commit = { sha: string; author: string; when: string; subject: string } -export type Analytics = { provider: 'plausible' | 'matomo' | 'ga4'; domain?: string; src?: string; url?: string; siteId?: string; id?: string; gated?: boolean } +export type Analytics = { provider: 'plausible' | 'matomo' | 'ga4'; domain?: string; src?: string; url?: string; siteId?: string; id?: string; gated?: boolean; adConversions?: boolean } export type FormField = { name: string; type?: string; label?: string; help?: string; placeholder?: string; required?: boolean; max?: number; options?: string[] } export type FormDef = { name?: string; title?: string; to?: string; subject?: string; reply_to?: string; submit?: string; success?: string; mailto?: string; turnstile_sitekey?: string; store?: boolean; fields: FormField[] } export type Submissions = { form: string; total: number; fields?: { name: string; label: string }[]; submissions: { time: string; values: Record }[] } diff --git a/internal/build/consent.go b/internal/build/consent.go index f8e78a5..e49cb30 100644 --- a/internal/build/consent.go +++ b/internal/build/consent.go @@ -23,6 +23,11 @@ import ( // // The consent script's tag carries the counter's hosts (data-hosts), so the // checks and the Content-Security-Policy see them in the page. +// +// GA4 gets Google's consent signals (Consent Mode) when it starts: without +// them Google drops what it learns from visitors in the EEA and the UK, +// even ones who said yes. Statistics are granted, ad personalization never +// is, and ad measurement only with ad_conversions: true. var ( //go:embed static/hotdog-consent.js @@ -52,7 +57,11 @@ func analyticsHosts(a *site.AnalyticsConfig) []string { case "matomo": return []string{origin(a.URL)} case "ga4": - return []string{"https://www.googletagmanager.com", "https://www.google-analytics.com", "https://*.google-analytics.com", "https://*.analytics.google.com"} + h := []string{"https://www.googletagmanager.com", "https://www.google-analytics.com", "https://*.google-analytics.com", "https://*.analytics.google.com"} + if a.AdConversions { + h = append(h, "https://www.google.com", "https://www.googleadservices.com", "https://*.doubleclick.net") + } + return h } return nil } @@ -77,6 +86,9 @@ func consentTags(cfg *site.Config, a *Assets) template.HTML { {"data-site", an.SiteID}, {"data-id", an.ID}, {"data-privacy", privacyPage(cfg)}, {"data-hosts", strings.Join(analyticsHosts(an), " ")}, } + if an.AdConversions { + attrs = append(attrs, [2]string{"data-ads", "true"}) + } if !an.IsGated() { attrs = append(attrs, [2]string{"data-gated", "false"}) } @@ -106,6 +118,9 @@ func privacyFacts(cfg *site.Config, siteForms map[string]*forms.Form) []site.Pri who += " (" + strings.TrimPrefix(hosts[0], "https://") + ")" } out = append(out, site.PrivacyFact{What: "Visit statistics", Who: who, Why: "To count visits and see which pages are read.", Basis: basis}) + if an.AdConversions { + out = append(out, site.PrivacyFact{What: "Whether a visit from one of the site's Google ads went on to sign up or buy", Who: "Google Ads, through Google Analytics", Why: "To see which of the site's ads work. Ad personalization is off: nothing is used to show you ads elsewhere.", Basis: basis}) + } } names := make([]string, 0, len(siteForms)) for n := range siteForms { diff --git a/internal/build/static/hotdog-consent.js b/internal/build/static/hotdog-consent.js index 62a01a5..105eacd 100644 --- a/internal/build/static/hotdog-consent.js +++ b/internal/build/static/hotdog-consent.js @@ -4,6 +4,8 @@ // Declining (now or later) removes the counter's cookies. A browser that // sends Global Privacy Control has already said no. Any element with // data-hotdog-consent-open reopens the choice ("Cookie settings"). +// Google Analytics is told what was agreed (Consent Mode): statistics yes, +// ad personalization no, ad measurement only when the site asks about it. (() => { const me = document.currentScript if (!me) return @@ -34,6 +36,8 @@ if (c.provider === 'ga4') { window.dataLayer = window.dataLayer || [] window.gtag = function () { window.dataLayer.push(arguments) } + const ads = c.ads === 'true' ? 'granted' : 'denied' + window.gtag('consent', 'default', { analytics_storage: 'granted', ad_storage: ads, ad_user_data: ads, ad_personalization: 'denied' }) window.gtag('js', new Date()) window.gtag('config', c.id) script('https://www.googletagmanager.com/gtag/js?id=' + encodeURIComponent(c.id), {}) @@ -69,7 +73,8 @@ box.setAttribute('role', 'region') box.setAttribute('aria-label', 'Visit statistics') const p = document.createElement('p') - p.textContent = 'May this site count your visit with ' + (names[c.provider] || 'its statistics') + '? Nothing is counted unless you agree. ' + const what = names[c.provider] || 'its statistics' + p.textContent = 'May this site count your visit with ' + what + (c.ads === 'true' ? ', including whether you came from one of its Google ads' : '') + '? Nothing is counted unless you agree. ' if (c.privacy) { const a = document.createElement('a') a.href = c.privacy diff --git a/internal/check/consent_test.go b/internal/check/consent_test.go index c1d291d..1ee6232 100644 --- a/internal/check/consent_test.go +++ b/internal/check/consent_test.go @@ -90,9 +90,35 @@ func TestConsentAndPrivacy(t *testing.T) { t.Error("no analytics-ungated warning") } + // Measuring Google ads: the banner and the notice say so, and the policy + // lets Google's ad hosts through. + dir = starterSite(t, "analytics: { provider: ga4, id: G-ABC123, ad_conversions: true }\n") + res, err = build.Run(build.Options{SiteDir: dir}) + if err != nil { + t.Fatal(err) + } + home, _ = os.ReadFile(filepath.Join(res.Out, "index.html")) + if !strings.Contains(string(home), `data-ads="true"`) { + t.Error("home missing data-ads") + } + priv, _ = os.ReadFile(filepath.Join(res.Out, "privacy", "index.html")) + if !strings.Contains(string(priv), "Google Ads, through Google Analytics") { + t.Error("privacy page doesn't mention Google Ads") + } + rep, _ = Run(dir, res.Out, res.Site.Config) + if !strings.Contains(rep.CSP, "https://www.googleadservices.com") { + t.Errorf("CSP: %s", rep.CSP) + } + // A bad analytics setting stops the build, saying why. - dir = starterSite(t, "analytics: { provider: ga4, id: UA-1 }\n") - if _, err := build.Run(build.Options{SiteDir: dir}); err == nil || !strings.Contains(err.Error(), "G-ABC123") { - t.Errorf("bad id: %v", err) + for setting, want := range map[string]string{ + "analytics: { provider: ga4, id: UA-1 }\n": "G-ABC123", + "analytics: { provider: ga4, id: G-ABC123, gated: false, ad_conversions: true }\n": "needs consent", + "analytics: { provider: plausible, domain: example.org, ad_conversions: true }\n": "is for ga4", + } { + dir = starterSite(t, setting) + if _, err := build.Run(build.Options{SiteDir: dir}); err == nil || !strings.Contains(err.Error(), want) { + t.Errorf("%s: %v", setting, err) + } } } diff --git a/internal/editor/privacy.go b/internal/editor/privacy.go index 9bd6472..e232d49 100644 --- a/internal/editor/privacy.go +++ b/internal/editor/privacy.go @@ -86,6 +86,9 @@ func (s *Server) privacySave(w http.ResponseWriter, r *http.Request, sess *Sessi if !a.IsGated() { an["gated"] = false // counting without asking: a choice, written down } + if a.AdConversions { + an["ad_conversions"] = true + } } pv := map[string]any{} for _, k := range []string{"controller", "contact", "updated"} { diff --git a/internal/editor/ui/dist/assets/VisualEditor-Bk2XWLOr.js b/internal/editor/ui/dist/assets/VisualEditor-ChliXE4b.js similarity index 99% rename from internal/editor/ui/dist/assets/VisualEditor-Bk2XWLOr.js rename to internal/editor/ui/dist/assets/VisualEditor-ChliXE4b.js index 0fd5777..06e8e9a 100644 --- a/internal/editor/ui/dist/assets/VisualEditor-Bk2XWLOr.js +++ b/internal/editor/ui/dist/assets/VisualEditor-ChliXE4b.js @@ -1,4 +1,4 @@ -import{n as e,r as t,t as n}from"./index-D5e-FBh8.js";var r=e();function i(e){this.content=e}i.prototype={constructor:i,find:function(e){for(var t=0;t>1}},i.from=function(e){if(e instanceof i)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new i(t)};function a(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),o=t.child(r);if(i==o)n+=i.nodeSize;else{if(!i.sameMarkup(o))return n;if(i.isText&&i.text!=o.text){let e=i.text,t=o.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i=56320&&e<57344}function c(e){return e>=55296&&e<56320}var l=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;te&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);at)for(let e=0,a=0;at&&((an)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?d(t+1,i):d(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;ethis.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;te.type.rank-t.type.rank),n}};p.none=[];var m=class extends Error{},h=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=_(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(g(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(l.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};h.empty=new h(l.empty,0,0);function g(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(g(a.content,t-i-1,n-i-1)))}function _(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=_(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function v(e,t,n){if(n.openStart>e.depth)throw new m(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new m(`Inconsistent open depths`);return y(e,t,n,0)}function y(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function te(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(x(e.nodeAfter,r),a++));for(let e=a;ei&&ee(e,t,i+1),o=r.depth>i&&ee(n,r,i+1),s=[];return te(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(b(a,o),x(ne(a,re(e,t,n,r,i+1)),s)):(a&&x(ne(a,ie(e,t,i+1)),s),te(t,n,i,s),o&&x(ne(o,ie(n,r,i+1)),s)),te(r,null,i,s),new l(s)}function ie(e,t,n){let r=[];return te(null,e,n,r),e.depth>n&&x(ne(ee(e,t,n+1),ie(e,t,n+1)),r),te(t,null,n,r),new l(r)}function ae(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(l.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var oe=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new ue(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=le.get(t);if(r)for(let e=0;ee&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),me(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=l.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;ee.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=l.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)}};fe.prototype.text=void 0;var pe=class e extends fe{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):me(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function me(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}function he(e,t,n,r){for(let i in t)if(!(i in e))throw RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let n in e)e[n].validate&&e[n].validate(t[n])}var ge=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new _e(t,n);if(r.next==null)return e.empty;let i=ve(r);r.next&&r.err(`Unexpected trailing text`);let a=Oe(Te(i));return ke(a,r),a}matchType(e){for(let t=0;te.createAndFill()));for(let e=0;e=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n`+e.indexOf(t.next[n].next);return r}).join(` +import{n as e,r as t,t as n}from"./index-CG9QFeJ3.js";var r=e();function i(e){this.content=e}i.prototype={constructor:i,find:function(e){for(var t=0;t>1}},i.from=function(e){if(e instanceof i)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new i(t)};function a(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),o=t.child(r);if(i==o)n+=i.nodeSize;else{if(!i.sameMarkup(o))return n;if(i.isText&&i.text!=o.text){let e=i.text,t=o.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i=56320&&e<57344}function c(e){return e>=55296&&e<56320}var l=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;te&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);at)for(let e=0,a=0;at&&((an)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?d(t+1,i):d(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;ethis.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;te.type.rank-t.type.rank),n}};p.none=[];var m=class extends Error{},h=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=_(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(g(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(l.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};h.empty=new h(l.empty,0,0);function g(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(g(a.content,t-i-1,n-i-1)))}function _(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=_(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function v(e,t,n){if(n.openStart>e.depth)throw new m(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new m(`Inconsistent open depths`);return y(e,t,n,0)}function y(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function te(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(x(e.nodeAfter,r),a++));for(let e=a;ei&&ee(e,t,i+1),o=r.depth>i&&ee(n,r,i+1),s=[];return te(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(b(a,o),x(ne(a,re(e,t,n,r,i+1)),s)):(a&&x(ne(a,ie(e,t,i+1)),s),te(t,n,i,s),o&&x(ne(o,ie(n,r,i+1)),s)),te(r,null,i,s),new l(s)}function ie(e,t,n){let r=[];return te(null,e,n,r),e.depth>n&&x(ne(ee(e,t,n+1),ie(e,t,n+1)),r),te(t,null,n,r),new l(r)}function ae(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(l.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var oe=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new ue(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=le.get(t);if(r)for(let e=0;ee&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),me(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=l.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;ee.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=l.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)}};fe.prototype.text=void 0;var pe=class e extends fe{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):me(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function me(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}function he(e,t,n,r){for(let i in t)if(!(i in e))throw RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let n in e)e[n].validate&&e[n].validate(t[n])}var ge=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new _e(t,n);if(r.next==null)return e.empty;let i=ve(r);r.next&&r.err(`Unexpected trailing text`);let a=Oe(Te(i));return ke(a,r),a}matchType(e){for(let t=0;te.createAndFill()));for(let e=0;e=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n`+e.indexOf(t.next[n].next);return r}).join(` `)}};ge.empty=new ge(!0);var _e=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function ve(e){let t=[];do t.push(ye(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function ye(e){let t=[];do t.push(be(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function be(e){let t=we(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=Se(e,t);else break;return t}function xe(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function Se(e,t){let n=xe(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:xe(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function Ce(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function we(e){if(e.eat(`(`)){let t=ve(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=Ce(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function Te(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new ge(r.indexOf(e.length-1)>-1);for(let e=0;e-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:je(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new fe(this,this.computeAttrs(e),l.from(t),p.setFrom(n))}createChecked(e=null,t,n){return t=l.from(t),this.checkContent(t),new fe(this,this.computeAttrs(e),t,p.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=l.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(l.empty,!0);return i?new fe(this,e,t.append(i),p.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;tr[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function Pe(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var Fe=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?Pe(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},Ie=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=Me(e,r.attrs),this.excluded=null;let i=Ae(this.attrs);this.instance=i?new p(this,i):null}create(e=null){return!e&&this.instance?this.instance:new p(this,je(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t-1}},Le=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=i.from(e.nodes),t.marks=i.from(e.marks||{}),this.nodes=Ne.compile(this.spec.nodes,this),this.marks=Ie.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=ge.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?Re(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:Re(this,n.split(` `))}this.nodeFromJSON=e=>fe.fromJSON(this,e),this.markFromJSON=e=>p.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof Ne))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new pe(n,n.defaultAttrs,e,p.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function Re(e,t){let n=[];for(let r=0;r-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function ze(e){return e.tag!=null}function Be(e){return e.style!=null}var Ve=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(ze(e))this.tags.push(e);else if(Be(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new Xe(this,t,!1);return n.addAll(e,p.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Xe(this,t,!0);return n.addAll(e,p.none,t.from,t.to),h.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;re.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r{n(e=$e(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=$e(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},He={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Ue={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},We={ol:!0,ul:!0},Ge=1,Ke=2,qe=4;function Je(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?Ge:0)|(t===`full`?Ke:0)}var Ye=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=p.none,this.match=i||(a&qe?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(l.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Ge)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=l.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(l.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!He.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Xe=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=Je(null,t.preserveWhitespace,0)|(n?qe:0);i=r?new Ye(r.type,r.attrs,p.none,!0,t.topMatch||r.type.contentMatch,a):n?new Ye(null,null,p.none,!0,null,a):new Ye(e.schema.topNodeType,null,p.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&Ke?`full`:this.localPreserveWS||(r.options&Ge)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,` `);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node){if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e!(a.type?a.type.allowsMarkType(t.type):et(t.type,e))||(s=t.addToSet(s),!1)),this.nodes.push(new Ye(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=Ge);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function Ze(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&We.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function Qe(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function $e(e){let t={};for(let n in e)t[n]=e[n];return t}function et(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n{if(i.length||e.marks.length){let n=0,a=0;for(;n=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&st(rt(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return typeof t==`string`?{dom:e.createTextNode(t)}:st(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=nt(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return nt(e.marks)}};function nt(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function rt(e){return e.document||window.document}var it=new WeakMap;function at(e){let t=it.get(e);return t===void 0&&it.set(e,t=ot(e)),t}function ot(e){let t=null;function n(e){if(e&&typeof e==`object`){if(Array.isArray(e)){if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;iu)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}if(typeof a==`string`)c.appendChild(e.createTextNode(a));else{let{dom:t,contentDOM:i}=st(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var ct=65535,lt=2**16;function ut(e,t){return e+t*lt}function dt(e){return e&ct}function ft(e){return(e-(e&ct))/lt}var pt=1,mt=2,ht=4,gt=8,_t=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo>)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&ht)>0}},vt=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=dt(e);if(!this.inverted)for(let e=0;ee)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:ut(o/3,e-s),f=0;return c&&(f|=e==s?mt:e==u?pt:ht,(t<0?e!=s:e!=u)&&(f|=gt)),new _t(a,f,d)}r+=l-c}return n?e+r:new _t(e+r,0,null)}touches(e,t){let n=0,r=dt(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;te)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;nn&&t!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return C.fromReplace(e,this.from,this.to,i)}invert(){return new Ct(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};S.jsonID(`addMark`,St);var Ct=class e extends S{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new h(xt(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return C.fromReplace(e,this.from,this.to,n)}invert(){return new St(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};S.jsonID(`removeMark`,Ct);var wt=class e extends S{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return C.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return C.fromReplace(e,this.pos,this.pos+1,new h(l.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;rr.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,h.fromJSON(t,n.slice),n.insert,!!n.structure)}};S.jsonID(`replaceAround`,w);function Dt(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function Ot(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;ee.step(t)),a.forEach(t=>e.step(t))}function kt(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof Ie){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;ee.step(new Ct(t.from,t.to,t.style)))}function At(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t=0;t--)e.step(o[t])}function jt(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Mt(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(nn;e--)t||r.index(e)>0?(t=!0,d=l.from(r.node(e).copy(d)),f++):c--;let p=l.empty,m=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=l.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new w(i,a,i,a,new h(r,0,0),n.length,!0))}function zt(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&Ht(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&Vt(e,t,n,a),At(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),u=s.map(n+t.nodeSize,1);return e.step(new w(c,u,c+1,u-1,new h(l.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&Bt(e,t,n,a),!1}})}function Bt(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function Vt(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(` diff --git a/internal/editor/ui/dist/assets/index-D5e-FBh8.js b/internal/editor/ui/dist/assets/index-CG9QFeJ3.js similarity index 92% rename from internal/editor/ui/dist/assets/index-D5e-FBh8.js rename to internal/editor/ui/dist/assets/index-CG9QFeJ3.js index a8b9ea2..dc2dc39 100644 --- a/internal/editor/ui/dist/assets/index-D5e-FBh8.js +++ b/internal/editor/ui/dist/assets/index-CG9QFeJ3.js @@ -1,4 +1,4 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/VisualEditor-Bk2XWLOr.js","assets/VisualEditor-ptHiDCW_.css"])))=>i.map(i=>d[i]); +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/VisualEditor-ChliXE4b.js","assets/VisualEditor-ptHiDCW_.css"])))=>i.map(i=>d[i]); var e=Object.defineProperty,t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),n=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},r=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function A(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var j=/\/+/g;function ee(e,t){return typeof e==`object`&&e&&e.key!=null?A(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function te(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,te(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+ee(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(j,`$&/`)+`/`),te(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(j,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u{t.exports=r()})),a=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-Tt&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),o=t(((e,t)=>{t.exports=a()})),s=t((e=>{var t=i();function n(e){var t=`https://react.dev/errors/`+e;if(1{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=s()})),l=t((e=>{var t=o(),n=i(),r=c();function a(e){var t=`https://react.dev/errors/`+e;if(1_e||(e.current=ge[_e],ge[_e]=null,_e--)}function R(e,t){_e++,ge[_e]=e.current,e.current=t}var be=ve(null),xe=ve(null),Se=ve(null),Ce=ve(null);function we(e,t){switch(R(Se,t),R(xe,e),R(be,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ye(be),R(be,e)}function Te(){ye(be),ye(xe),ye(Se)}function Ee(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,R(Ce,e)),t=be.current;var n=dp(t,e.type);t!==n&&(R(xe,e),R(be,n))}function De(e){xe.current===e&&(ye(be),ye(xe)),Ce.current===e&&(ye(Ce),sh._currentValue=he)}var Oe,ke;function Ae(e){if(Oe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Oe=t&&t[1]||``,ke=-1)`:-1ie(t,{options:e.target.value.split(` `).map(e=>e.trim()).filter(Boolean)})})]}),(0,j.jsxs)(`label`,{children:[`Help`,(0,j.jsx)(`input`,{value:e.help||``,disabled:!F,onChange:e=>ie(t,{help:e.target.value})})]}),(0,j.jsxs)(`div`,{className:`actions-row`,children:[(0,j.jsxs)(`label`,{className:`check`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:!!e.required,disabled:!F,onChange:e=>ie(t,{required:e.target.checked||void 0})}),` Required`]}),(0,j.jsxs)(`label`,{className:`inline`,children:[`Most characters`,(0,j.jsx)(`input`,{type:`number`,min:1,value:e.max||``,disabled:!F,onChange:e=>ie(t,{max:e.target.value?Number(e.target.value):void 0})})]}),F&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,disabled:t===0,onClick:()=>P({fields:qe(s.fields,t,t-1)}),"aria-label":`Move up`,children:`↑`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,disabled:t===s.fields.length-1,onClick:()=>P({fields:qe(s.fields,t,t+1)}),"aria-label":`Move down`,children:`↓`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>P({fields:s.fields.filter((e,n)=>n!==t)}),children:`Remove`})]})]})]},t))}),F&&(0,j.jsxs)(`div`,{className:`actions-row`,children:[(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>P({fields:[...s.fields,{name:`field_${s.fields.length+1}`,label:`New field`}]}),children:`Add a field`}),(0,j.jsx)(`button`,{type:`button`,className:`button primary`,disabled:!re||T,onClick:()=>ae(),children:a?.branch===t?`Save`:`Save as draft`}),l&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,disabled:T,onClick:()=>ae(!0),children:`Delete form`})]})]}),f===`submissions`&&(0,j.jsxs)(`div`,{className:`subs`,children:[!A&&(0,j.jsx)(`p`,{className:`muted`,children:`Reading submissions…`}),A&&A.total===0&&(0,j.jsx)(`p`,{className:`muted`,children:`No submissions kept for this form.`}),A&&A.submissions.length>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`p`,{className:`muted small`,children:[A.total,` kept, newest first. Read from the endpoint's private viewer; the public site can't show them.`]}),(0,j.jsx)(`div`,{className:`table-wrap`,children:(0,j.jsxs)(`table`,{className:`pages`,children:[(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{children:`When`}),(A.fields||[]).map(e=>(0,j.jsx)(`th`,{children:e.label||e.name},e.name))]})}),(0,j.jsx)(`tbody`,{children:A.submissions.map((e,t)=>(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`td`,{className:`small`,children:new Date(e.time).toLocaleString()}),(A.fields||[]).map(t=>(0,j.jsx)(`td`,{className:`small sub-cell`,children:e.values[t.name]},t.name))]},t))})]})}),(0,j.jsxs)(`div`,{className:`actions-row`,children:[(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,disabled:M===0,onClick:()=>te(Math.max(0,M-50)),children:`Newer`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,disabled:M+50>=A.total,onClick:()=>te(M+50),children:`Older`})]})]})]})]}),!n&&r&&r.length>0&&(0,j.jsx)(`p`,{className:`muted`,children:`Choose a form to change it.`})]}),right:(0,j.jsxs)(`section`,{className:`preview-pane`,"aria-label":`Preview`,children:[(0,j.jsx)(`div`,{className:`preview-bar`,children:(0,j.jsx)(We,{device:S,onChange:w})}),v&&(0,j.jsx)(`p`,{className:`notice warn small preview-note`,children:v}),(0,j.jsx)(Ge,{src:g,device:S,title:`Preview of the form`,reloadKey:b})]})})}function Ye({id:e}){let[t,n]=(0,d.useState)(),[r,i]=(0,d.useState)(),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)();(0,d.useEffect)(()=>{C.site(e).then(e=>o(e.canWrite),()=>void 0),C.log(e,void 0,void 0,50).then(e=>n(e.commits),e=>i({kind:`bad`,text:e.message}))},[e]);let l=async t=>{c(t.sha),i({kind:`info`,text:`Undoing "${t.subject}"…`});try{let n=await C.revert(e,t.sha);i({kind:`good`,text:`"${t.subject}" is undone on a new draft, ${n.branch}. Look it over, then submit it for review and publish.`,branch:n.branch})}catch(e){i({kind:`bad`,text:e.message})}finally{c(void 0)}};return(0,j.jsxs)(`section`,{className:`pad history`,children:[(0,j.jsx)(`a`,{className:`back`,href:`/sites/${encodeURIComponent(e)}`,onClick:t=>{t.preventDefault(),D({view:`site`,id:e})},children:`← Site`}),(0,j.jsx)(`h1`,{children:`History`}),(0,j.jsx)(`p`,{className:`muted`,children:`Every change that reached the published site, newest first. Undoing one makes a draft that reverses it; nothing changes until that's published.`}),r&&(0,j.jsxs)(`p`,{className:`notice ${r.kind}`,role:`status`,children:[r.text,r.branch&&(0,j.jsxs)(j.Fragment,{children:[` `,(0,j.jsx)(`a`,{href:`#`,onClick:t=>{t.preventDefault(),D({view:`site`,id:e,branch:r.branch})},children:`Open the draft`})]})]}),!t&&!r&&(0,j.jsx)(`p`,{className:`muted`,children:`Reading the history…`}),(0,j.jsx)(`ol`,{className:`commit-list`,children:t?.map(e=>(0,j.jsxs)(`li`,{children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`strong`,{children:e.subject}),(0,j.jsxs)(`span`,{className:`muted small`,children:[` `,e.author,` · `,new Date(e.when).toLocaleString(),` · `,(0,j.jsx)(`span`,{className:`mono`,children:e.sha.slice(0,8)})]})]}),a&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,disabled:!!s,onClick:()=>l(e),children:s===e.sha?`Undoing…`:`Undo on a draft`})]},e.sha))})]})}function Xe({id:e,url:t,branch:n}){let[r,i]=Ue(),[a,o]=(0,d.useState)(0);return(0,d.useEffect)(()=>{let e=Ze();if(e)return e.onmessage=e=>{e.data?.url===t&&o(e=>e+1)},()=>e.close()},[t]),(0,j.jsxs)(`div`,{className:`present`,children:[(0,j.jsxs)(`div`,{className:`preview-bar`,children:[(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>window.opener?window.close():history.length>1?history.back():D({view:`site`,id:e,branch:n}),children:`← Back to editing`}),(0,j.jsx)(`span`,{className:`spacer`}),(0,j.jsx)(We,{device:r,onChange:i}),(0,j.jsx)(`span`,{className:`spacer`}),(0,j.jsx)(`a`,{className:`ghost small linkbtn`,href:t,target:`_blank`,rel:`noopener noreferrer`,children:`Open ↗`})]}),(0,j.jsx)(Ge,{src:t,device:r,title:`Presentation preview`,reloadKey:a})]})}function Ze(){return typeof BroadcastChannel>`u`?void 0:new BroadcastChannel(`hotdog-live`)}var Qe=60,$e=160;function et({id:e,branch:t,seo:n,siteURL:r,path:i}){let a=r.replace(/\/$/,``)+i,o=n.image,s=o&&o.startsWith(`/media/`),c=[];return n.title?n.title.length>Qe&&c.push(`The title is ${n.title.length} characters; search results show about ${Qe}, so the end may be cut.`):c.push(`No title.`),n.description?n.description.length>$e&&c.push(`The description is ${n.description.length} characters; results show about ${$e}.`):c.push(`No description: search engines will pick some text from the page. Add a summary.`),o?n.imageAlt||c.push(`The preview picture has no description (image_alt).`):c.push(`No picture for link previews: set image in the front matter.`),(0,j.jsxs)(`details`,{className:`seo`,children:[(0,j.jsxs)(`summary`,{children:[(0,j.jsx)(`strong`,{children:`Search and social`}),(0,j.jsxs)(`span`,{className:`muted small`,children:[` `,n.noindex?`hidden from search engines`:c.length?`${c.length} thing${c.length===1?``:`s`} to look at`:`looks good`]})]}),n.noindex&&(0,j.jsx)(`p`,{className:`notice warn small`,children:`This page asks search engines not to list it (noindex).`}),(0,j.jsxs)(`div`,{className:`serp`,"aria-label":`As a search result`,children:[(0,j.jsx)(`span`,{className:`serp-url`,children:a}),(0,j.jsx)(`span`,{className:`serp-title`,children:n.title.length>Qe?n.title.slice(0,59)+`…`:n.title||`(no title)`}),(0,j.jsx)(`span`,{className:`serp-desc`,children:n.description?n.description.length>$e?n.description.slice(0,159)+`…`:n.description:(0,j.jsx)(`em`,{className:`muted`,children:`No description`})})]}),(0,j.jsxs)(`div`,{className:`card-preview`,"aria-label":`As a link preview`,children:[(0,j.jsx)(`div`,{className:`card-img`,children:s?(0,j.jsx)(`img`,{src:C.mediaFile(e,o,t),alt:``}):o?(0,j.jsx)(`span`,{className:`muted small mono`,children:o}):(0,j.jsx)(`span`,{className:`muted small`,children:`No picture`})}),(0,j.jsxs)(`div`,{className:`card-text`,children:[(0,j.jsx)(`span`,{className:`muted small`,children:new URL(a).host}),(0,j.jsx)(`strong`,{children:n.title||`(no title)`}),n.description&&(0,j.jsx)(`span`,{className:`small`,children:n.description})]})]}),(0,j.jsx)(`p`,{className:`muted small`,children:`Mastodon, LinkedIn and Bluesky show the picture above the title like this; a picture 1200×630 suits them all.`}),c.length>0&&(0,j.jsx)(`ul`,{className:`seo-notes`,children:c.map(e=>(0,j.jsx)(`li`,{children:e},e))})]})}function tt(e,t,n){return[e.trim(),t.trim(),n].filter(Boolean).join(` -`)}function nt(e){let t=e.trim().toLowerCase().replace(/^https?:\/\//,``).replace(/\/.*$/,``);return t.includes(`@`)&&(t=t.slice(t.lastIndexOf(`@`)+1)),/^(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}(?::\d{1,5})?$/.test(t)?t:``}function rt(e,t){return`https://${e}/share?text=${encodeURIComponent(t)}`}function it(e){return`https://bsky.app/intent/compose?text=${encodeURIComponent(e)}`}function at(e){return`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(e)}`}function ot(e){if(typeof Intl<`u`&&`Segmenter`in Intl){let t=0;for(let n of new Intl.Segmenter(void 0,{granularity:`grapheme`}).segment(e))t++;return t}return[...e].length}var st=`hotdog-mastodon`;function ct(){try{return localStorage.getItem(st)||``}catch{return``}}function lt({title:e,summary:t,url:n,onClose:r}){let[i,a]=(0,d.useState)(()=>tt(e,t,n)),[o,s]=(0,d.useState)(ct),[c,l]=(0,d.useState)(!1),u=nt(o),f=ot(i),p=e=>window.open(e,`_blank`,`noopener,noreferrer`);return(0,j.jsxs)(`div`,{className:`share-panel form`,role:`group`,"aria-label":`Share this page`,children:[(0,j.jsxs)(`div`,{className:`library-head`,children:[(0,j.jsx)(`strong`,{children:`Share`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:r,children:`Close`})]}),(0,j.jsx)(`p`,{className:`muted small`,children:`Each button opens the network's own share page with this filled in; you post it from your account there. Share once the live site shows the change.`}),(0,j.jsxs)(`label`,{children:[`Post`,(0,j.jsx)(`textarea`,{rows:5,value:i,onChange:e=>a(e.target.value)})]}),(0,j.jsxs)(`p`,{className:`small ${f>300?`bad-text`:`muted`}`,children:[f,` characters`,f>300?`: Bluesky allows 300`:``]}),(0,j.jsxs)(`div`,{className:`share-row`,children:[(0,j.jsxs)(`label`,{className:`share-server`,children:[`Mastodon server`,(0,j.jsx)(`input`,{value:o,placeholder:`mastodon.social`,onChange:e=>s(e.target.value),spellCheck:!1})]}),(0,j.jsx)(`button`,{type:`button`,className:`button`,disabled:!u||!i.trim(),onClick:()=>{try{localStorage.setItem(st,u)}catch{}p(rt(u,i))},children:`Mastodon ↗`})]}),(0,j.jsxs)(`div`,{className:`actions`,children:[(0,j.jsx)(`button`,{type:`button`,className:`button`,disabled:!i.trim()||f>300,onClick:()=>p(it(i)),children:`Bluesky ↗`}),(0,j.jsx)(`button`,{type:`button`,className:`button`,onClick:()=>p(at(n)),title:`LinkedIn takes the link and reads the title and picture from the page; copy the text to add it`,children:`LinkedIn ↗`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost`,onClick:async()=>{try{await navigator.clipboard.writeText(i),l(!0),setTimeout(()=>l(!1),2e3)}catch{}},children:c?`Copied`:`Copy text`})]})]})}var ut=(function(){let e=typeof document<`u`&&document.createElement(`link`).relList;return e&&e.supports&&e.supports(`modulepreload`)?`modulepreload`:`preload`})(),dt=function(e){return`/`+e},ft={},pt=function(e){return e.pathname.endsWith(`.css`)},mt=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},ht=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=dt(t,n);let r=s(t),i=pt(r);return mt(ft,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:ut,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},gt=(0,d.lazy)(()=>ht(()=>import(`./VisualEditor-Bk2XWLOr.js`).then(e=>({default:e.VisualEditor})),__vite__mapDeps([0,1]))),_t=[`title`,`summary`,`date`,`tags`,`image`,`image_alt`,`draft`,`publish_at`];function vt(e){return e==null?``:typeof e==`string`?e:String(e)}function yt(e){let t=vt(e);return/^\d{4}-\d{2}-\d{2}/.test(t)?t.slice(0,10):t}function bt(e){let t=vt(e);if(!t)return``;let n=new Date(t);if(isNaN(n.getTime()))return``;let r=e=>String(e).padStart(2,`0`);return`${n.getFullYear()}-${r(n.getMonth()+1)}-${r(n.getDate())}T${r(n.getHours())}:${r(n.getMinutes())}`}function xt(e){let t=Array.isArray(e.tags)?e.tags.map(vt).join(`, `):vt(e.tags);return{title:vt(e.title),summary:vt(e.summary),date:yt(e.date),tags:t,image:vt(e.image),image_alt:vt(e.image_alt),draft:e.draft===!0,publish_at:bt(e.publish_at)}}function St(e,t,n){let r={};for(let i of _t){if(e[i]===t[i])continue;let a=t[i];i===`draft`?r.draft=a?!0:null:i===`tags`?r.tags=a.trim()?a.split(`,`).map(e=>e.trim()).filter(Boolean):null:i===`publish_at`?r.publish_at=a?new Date(a).toISOString().replace(`.000Z`,`Z`):null:r[i]=a.trim()?a:i in n?null:void 0}for(let e of Object.keys(r))r[e]===void 0&&delete r[e];return r}function Ct({id:e,source:t,branch:n,site:r,onSiteChanged:i}){let[a,o]=(0,d.useState)(),[s,c]=(0,d.useState)(),[l,u]=(0,d.useState)(),[f,p]=(0,d.useState)(``),[g,_]=(0,d.useState)(!1),[v,y]=(0,d.useState)(``),[b,x]=(0,d.useState)(),[S,w]=(0,d.useState)(!1),[T,O]=(0,d.useState)(!1),[k,A]=(0,d.useState)(),[ee,M]=(0,d.useState)(),[N,ne]=(0,d.useState)(0),[ie,ae]=Ue(),[F,oe]=(0,d.useState)(!1),[ce,le]=(0,d.useState)(),[ue,de]=(0,d.useState)(),[fe,pe]=(0,d.useState)(),[me,I]=(0,d.useState)(()=>{try{return localStorage.getItem(`hotdog-body-mode`)===`visual`?`visual`:`markdown`}catch{return`markdown`}}),L=e=>{I(e);try{localStorage.setItem(`hotdog-body-mode`,e)}catch{}},he=(0,d.useRef)(null),[ge,_e]=(0,d.useState)(!1),[ve,ye]=(0,d.useState)(),[R,be]=(0,d.useState)(),xe=(0,d.useRef)(null),Se=(0,d.useRef)(void 0),we=(0,d.useRef)(void 0),Te=n||r?.publishBranch||``;(0,d.useEffect)(()=>{o(void 0),C.page(e,t,n).then(e=>{o(e);let t=Se.current;Se.current=void 0,u(t?t.fields:xt(e.frontMatter)),p(t?t.body:e.body),y(t?t.yaml:e.frontMatterRaw),_(t?t.yamlMode:!1),pe(t?t.secs:re(e.frontMatter.sections))},e=>c(e.message))},[e,t,n]);let De=(0,d.useMemo)(()=>a?xt(a.frontMatter):void 0,[a]),Oe=(0,d.useMemo)(()=>{if(!a||!l||!De)return null;if(g)return v===a.frontMatterRaw&&f===a.body?null:{frontMatter:v,body:f};let e=St(De,l,a.frontMatter);if(fe){let t=P(fe);JSON.stringify(t)!==JSON.stringify(a.frontMatter.sections??null)&&(e.sections=t.length?t:null)}return Object.keys(e).length===0&&f===a.body?null:{set:e,body:f}},[a,l,De,f,v,g,fe]),ke=Oe!==null,Ae=(0,d.useRef)(0),je=(0,d.useRef)(void 0);(0,d.useEffect)(()=>(je.current=Ze(),()=>je.current?.close()),[]);let Me=(0,d.useCallback)(n=>{a&&C.live(e,{source:t,branch:Te,edit:n}).then(e=>{e.error?M(`The preview shows the last version that rendered. ${e.error}`):(M(void 0),e.seo&&e.siteURL&&e.path&&be({seo:e.seo,siteURL:e.siteURL,path:e.path}),e.url===k?ne(e=>e+1):A(e.url),je.current?.postMessage({url:e.url}))},e=>M(e.message))},[e,t,Te,a,k]);(0,d.useEffect)(()=>{if(a)return window.clearTimeout(Ae.current),Ae.current=window.setTimeout(()=>Me(Oe),Oe?600:0),()=>window.clearTimeout(Ae.current)},[Oe,a]),(0,d.useEffect)(()=>{let e=e=>{ke&&e.preventDefault()};return addEventListener(`beforeunload`,e),()=>removeEventListener(`beforeunload`,e)},[ke]);let Ne=r?.pages?.find(e=>e.source===t)?.path,Pe=Ne?Ne.endsWith(`/`)?`public${Ne}index.html`:`public${Ne}`:``,Fe=(r?.build.problems||[]).filter(e=>e.File===Pe||e.File.startsWith(t)),Ie=r?.reviews?.find(e=>e.branch===Te),Le=r?Te!==r.publishBranch:!1,Re=r?.canWrite,ze=r?.siteURL&&Ne?r.siteURL.replace(/\/+$/,``)+Ne:``,Be=!Le&&!!l&&!l.draft&&!!ze,He=async()=>{if(a&&Oe){O(!0),x({kind:`info`,text:`Saving…`});try{let r=await C.save(e,{source:t,branch:Te,baseCommit:a.commit,edit:Oe});if(x({kind:`good`,text:r.created?`Saved. Your change is on a new draft, ${r.branch}; the published site is unchanged.`:`Saved to ${r.branch}.`}),i(),r.created||r.branch!==n)D({view:`page`,id:e,source:t,branch:r.branch});else{let n=await C.page(e,t,r.branch);o(n),u(xt(n.frontMatter)),p(n.body),y(n.frontMatterRaw),pe(re(n.frontMatter.sections))}}catch(e){x({kind:`bad`,text:e instanceof m?e.message:`Not saved: ${e.message}`})}finally{O(!1)}}},Ke=n=>{let r,s=me===`visual`&&he.current,c=/^!\[([^\]]*)\]\(([^)]+)\)$/.exec(n);if(s&&c)r=he.current.insertImage(c[2],c[1]);else{let e=xe.current,t=e?e.selectionStart:f.length,i=f.slice(0,t),a=f.slice(t),o=i===``||i.endsWith(` +`)}function nt(e){let t=e.trim().toLowerCase().replace(/^https?:\/\//,``).replace(/\/.*$/,``);return t.includes(`@`)&&(t=t.slice(t.lastIndexOf(`@`)+1)),/^(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}(?::\d{1,5})?$/.test(t)?t:``}function rt(e,t){return`https://${e}/share?text=${encodeURIComponent(t)}`}function it(e){return`https://bsky.app/intent/compose?text=${encodeURIComponent(e)}`}function at(e){return`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(e)}`}function ot(e){if(typeof Intl<`u`&&`Segmenter`in Intl){let t=0;for(let n of new Intl.Segmenter(void 0,{granularity:`grapheme`}).segment(e))t++;return t}return[...e].length}var st=`hotdog-mastodon`;function ct(){try{return localStorage.getItem(st)||``}catch{return``}}function lt({title:e,summary:t,url:n,onClose:r}){let[i,a]=(0,d.useState)(()=>tt(e,t,n)),[o,s]=(0,d.useState)(ct),[c,l]=(0,d.useState)(!1),u=nt(o),f=ot(i),p=e=>window.open(e,`_blank`,`noopener,noreferrer`);return(0,j.jsxs)(`div`,{className:`share-panel form`,role:`group`,"aria-label":`Share this page`,children:[(0,j.jsxs)(`div`,{className:`library-head`,children:[(0,j.jsx)(`strong`,{children:`Share`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:r,children:`Close`})]}),(0,j.jsx)(`p`,{className:`muted small`,children:`Each button opens the network's own share page with this filled in; you post it from your account there. Share once the live site shows the change.`}),(0,j.jsxs)(`label`,{children:[`Post`,(0,j.jsx)(`textarea`,{rows:5,value:i,onChange:e=>a(e.target.value)})]}),(0,j.jsxs)(`p`,{className:`small ${f>300?`bad-text`:`muted`}`,children:[f,` characters`,f>300?`: Bluesky allows 300`:``]}),(0,j.jsxs)(`div`,{className:`share-row`,children:[(0,j.jsxs)(`label`,{className:`share-server`,children:[`Mastodon server`,(0,j.jsx)(`input`,{value:o,placeholder:`mastodon.social`,onChange:e=>s(e.target.value),spellCheck:!1})]}),(0,j.jsx)(`button`,{type:`button`,className:`button`,disabled:!u||!i.trim(),onClick:()=>{try{localStorage.setItem(st,u)}catch{}p(rt(u,i))},children:`Mastodon ↗`})]}),(0,j.jsxs)(`div`,{className:`actions`,children:[(0,j.jsx)(`button`,{type:`button`,className:`button`,disabled:!i.trim()||f>300,onClick:()=>p(it(i)),children:`Bluesky ↗`}),(0,j.jsx)(`button`,{type:`button`,className:`button`,onClick:()=>p(at(n)),title:`LinkedIn takes the link and reads the title and picture from the page; copy the text to add it`,children:`LinkedIn ↗`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost`,onClick:async()=>{try{await navigator.clipboard.writeText(i),l(!0),setTimeout(()=>l(!1),2e3)}catch{}},children:c?`Copied`:`Copy text`})]})]})}var ut=(function(){let e=typeof document<`u`&&document.createElement(`link`).relList;return e&&e.supports&&e.supports(`modulepreload`)?`modulepreload`:`preload`})(),dt=function(e){return`/`+e},ft={},pt=function(e){return e.pathname.endsWith(`.css`)},mt=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},ht=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=dt(t,n);let r=s(t),i=pt(r);return mt(ft,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:ut,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},gt=(0,d.lazy)(()=>ht(()=>import(`./VisualEditor-ChliXE4b.js`).then(e=>({default:e.VisualEditor})),__vite__mapDeps([0,1]))),_t=[`title`,`summary`,`date`,`tags`,`image`,`image_alt`,`draft`,`publish_at`];function vt(e){return e==null?``:typeof e==`string`?e:String(e)}function yt(e){let t=vt(e);return/^\d{4}-\d{2}-\d{2}/.test(t)?t.slice(0,10):t}function bt(e){let t=vt(e);if(!t)return``;let n=new Date(t);if(isNaN(n.getTime()))return``;let r=e=>String(e).padStart(2,`0`);return`${n.getFullYear()}-${r(n.getMonth()+1)}-${r(n.getDate())}T${r(n.getHours())}:${r(n.getMinutes())}`}function xt(e){let t=Array.isArray(e.tags)?e.tags.map(vt).join(`, `):vt(e.tags);return{title:vt(e.title),summary:vt(e.summary),date:yt(e.date),tags:t,image:vt(e.image),image_alt:vt(e.image_alt),draft:e.draft===!0,publish_at:bt(e.publish_at)}}function St(e,t,n){let r={};for(let i of _t){if(e[i]===t[i])continue;let a=t[i];i===`draft`?r.draft=a?!0:null:i===`tags`?r.tags=a.trim()?a.split(`,`).map(e=>e.trim()).filter(Boolean):null:i===`publish_at`?r.publish_at=a?new Date(a).toISOString().replace(`.000Z`,`Z`):null:r[i]=a.trim()?a:i in n?null:void 0}for(let e of Object.keys(r))r[e]===void 0&&delete r[e];return r}function Ct({id:e,source:t,branch:n,site:r,onSiteChanged:i}){let[a,o]=(0,d.useState)(),[s,c]=(0,d.useState)(),[l,u]=(0,d.useState)(),[f,p]=(0,d.useState)(``),[g,_]=(0,d.useState)(!1),[v,y]=(0,d.useState)(``),[b,x]=(0,d.useState)(),[S,w]=(0,d.useState)(!1),[T,O]=(0,d.useState)(!1),[k,A]=(0,d.useState)(),[ee,M]=(0,d.useState)(),[N,ne]=(0,d.useState)(0),[ie,ae]=Ue(),[F,oe]=(0,d.useState)(!1),[ce,le]=(0,d.useState)(),[ue,de]=(0,d.useState)(),[fe,pe]=(0,d.useState)(),[me,I]=(0,d.useState)(()=>{try{return localStorage.getItem(`hotdog-body-mode`)===`visual`?`visual`:`markdown`}catch{return`markdown`}}),L=e=>{I(e);try{localStorage.setItem(`hotdog-body-mode`,e)}catch{}},he=(0,d.useRef)(null),[ge,_e]=(0,d.useState)(!1),[ve,ye]=(0,d.useState)(),[R,be]=(0,d.useState)(),xe=(0,d.useRef)(null),Se=(0,d.useRef)(void 0),we=(0,d.useRef)(void 0),Te=n||r?.publishBranch||``;(0,d.useEffect)(()=>{o(void 0),C.page(e,t,n).then(e=>{o(e);let t=Se.current;Se.current=void 0,u(t?t.fields:xt(e.frontMatter)),p(t?t.body:e.body),y(t?t.yaml:e.frontMatterRaw),_(t?t.yamlMode:!1),pe(t?t.secs:re(e.frontMatter.sections))},e=>c(e.message))},[e,t,n]);let De=(0,d.useMemo)(()=>a?xt(a.frontMatter):void 0,[a]),Oe=(0,d.useMemo)(()=>{if(!a||!l||!De)return null;if(g)return v===a.frontMatterRaw&&f===a.body?null:{frontMatter:v,body:f};let e=St(De,l,a.frontMatter);if(fe){let t=P(fe);JSON.stringify(t)!==JSON.stringify(a.frontMatter.sections??null)&&(e.sections=t.length?t:null)}return Object.keys(e).length===0&&f===a.body?null:{set:e,body:f}},[a,l,De,f,v,g,fe]),ke=Oe!==null,Ae=(0,d.useRef)(0),je=(0,d.useRef)(void 0);(0,d.useEffect)(()=>(je.current=Ze(),()=>je.current?.close()),[]);let Me=(0,d.useCallback)(n=>{a&&C.live(e,{source:t,branch:Te,edit:n}).then(e=>{e.error?M(`The preview shows the last version that rendered. ${e.error}`):(M(void 0),e.seo&&e.siteURL&&e.path&&be({seo:e.seo,siteURL:e.siteURL,path:e.path}),e.url===k?ne(e=>e+1):A(e.url),je.current?.postMessage({url:e.url}))},e=>M(e.message))},[e,t,Te,a,k]);(0,d.useEffect)(()=>{if(a)return window.clearTimeout(Ae.current),Ae.current=window.setTimeout(()=>Me(Oe),Oe?600:0),()=>window.clearTimeout(Ae.current)},[Oe,a]),(0,d.useEffect)(()=>{let e=e=>{ke&&e.preventDefault()};return addEventListener(`beforeunload`,e),()=>removeEventListener(`beforeunload`,e)},[ke]);let Ne=r?.pages?.find(e=>e.source===t)?.path,Pe=Ne?Ne.endsWith(`/`)?`public${Ne}index.html`:`public${Ne}`:``,Fe=(r?.build.problems||[]).filter(e=>e.File===Pe||e.File.startsWith(t)),Ie=r?.reviews?.find(e=>e.branch===Te),Le=r?Te!==r.publishBranch:!1,Re=r?.canWrite,ze=r?.siteURL&&Ne?r.siteURL.replace(/\/+$/,``)+Ne:``,Be=!Le&&!!l&&!l.draft&&!!ze,He=async()=>{if(a&&Oe){O(!0),x({kind:`info`,text:`Saving…`});try{let r=await C.save(e,{source:t,branch:Te,baseCommit:a.commit,edit:Oe});if(x({kind:`good`,text:r.created?`Saved. Your change is on a new draft, ${r.branch}; the published site is unchanged.`:`Saved to ${r.branch}.`}),i(),r.created||r.branch!==n)D({view:`page`,id:e,source:t,branch:r.branch});else{let n=await C.page(e,t,r.branch);o(n),u(xt(n.frontMatter)),p(n.body),y(n.frontMatterRaw),pe(re(n.frontMatter.sections))}}catch(e){x({kind:`bad`,text:e instanceof m?e.message:`Not saved: ${e.message}`})}finally{O(!1)}}},Ke=n=>{let r,s=me===`visual`&&he.current,c=/^!\[([^\]]*)\]\(([^)]+)\)$/.exec(n);if(s&&c)r=he.current.insertImage(c[2],c[1]);else{let e=xe.current,t=e?e.selectionStart:f.length,i=f.slice(0,t),a=f.slice(t),o=i===``||i.endsWith(` `)?``:i.endsWith(` `)?` @@ -53,4 +53,4 @@ It never runs shell commands: the editor host is not a shell.`;function Ae(e){le `:` `;r=i+o+n+s+a}p(r),de(void 0);let u=we.current;if(we.current=void 0,!u)return;let d=(u.notes||[]).join(` `);x({kind:`good`,text:`Added ${u.url}${u.created?` on a new draft, ${u.branch}`:``}. ${d} Save to keep it in the page.`.trim()}),i(),u.created||u.branch!==Te?(l&&(Se.current={fields:l,body:r,yaml:v,yamlMode:g,secs:fe}),D({view:`page`,id:e,source:t,branch:u.branch})):a&&o({...a,commit:u.commit})},qe=(0,d.useRef)(void 0),Je=async n=>{let r=await C.upload(e,n,{branch:Te,baseCommit:a?.commit||``,source:t});return qe.current=r,r.url};(0,d.useEffect)(()=>{let n=qe.current;if(!n)return;qe.current=void 0;let r=(n.notes||[]).join(` `);x({kind:`good`,text:`Added ${n.url}${n.created?` on a new draft, ${n.branch}`:``}. ${r} Save to keep it in the page.`.trim()}),i(),n.created||n.branch!==Te?(l&&(Se.current={fields:l,body:f,yaml:v,yamlMode:g,secs:fe}),D({view:`page`,id:e,source:t,branch:n.branch})):a&&o({...a,commit:n.commit})},[fe]);let Ye=async()=>{O(!0),x({kind:`info`,text:`Checking the draft and publishing…`}),le(void 0);try{await C.publish(e,{branch:Te}),x({kind:`good`,text:`Published: the change is merged. The live site updates when its publishing pipeline runs.`}),w(!0),r&&D({view:`page`,id:e,source:t,branch:r.publishBranch}),i()}catch(e){e instanceof h&&le(e.problems),x({kind:`bad`,text:e.message})}finally{O(!1)}},Xe=k?new URL(k).origin:``,Qe=e=>{let t=document.querySelector(`.preview-pane iframe`);t?.contentWindow&&Xe&&t.contentWindow.postMessage({type:`hotdog:point`,on:e},Xe)};if((0,d.useEffect)(()=>{let e=e=>{if(!Xe||e.origin!==Xe||!e.data||typeof e.data!=`object`||(e.data.type===`hotdog:ready`&&Qe(ge),e.data.type!==`hotdog:jump`||typeof e.data.text!=`string`))return;let t=e.data.text.slice(0,200);if(me===`visual`&&he.current){he.current.jumpTo(t)||x({kind:`info`,text:`"${t.slice(0,60)}" isn't in the body; it comes from the front matter, a section or the template.`});return}let n=xe.current;if(!n)return;let r=f.toLowerCase(),i=t.toLowerCase().split(` `),a=-1;for(let e of[t.toLowerCase().slice(0,40),i.slice(0,4).join(` `),i.slice(0,2).join(` `)])if(e.length>=3&&(a=r.indexOf(e))>=0)break;if(a<0){x({kind:`info`,text:`"${t.slice(0,60)}" isn't in the body; it comes from the front matter, a section or the template.`});return}n.focus(),n.setSelectionRange(a,a+Math.min(t.length,f.length-a));let o=f.slice(0,a).split(` -`).length;n.scrollTop=Math.max(0,(o-3)*parseFloat(getComputedStyle(n).lineHeight||`20`))};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[Xe,ge,me,f]),(0,d.useEffect)(()=>Qe(ge),[ge,k]),Ee(`mod+s`,()=>ke&&!T&&Re&&He(),!!a),Ce(()=>a?[...Re&&ke?[{id:`page-save`,title:Le?`Save`:`Save as draft`,group:`Page`,keys:`Ctrl+S`,run:He}]:[],...Re?[{id:`page-picture`,title:`Insert picture`,group:`Page`,run:()=>de({})}]:[],{id:`page-mode`,title:me===`visual`?`Edit the body as Markdown`:`Edit the body visually`,group:`Page`,run:()=>L(me===`visual`?`markdown`:`visual`)},...k?[{id:`page-point`,title:ge?`Stop pointing in the preview`:`Point and edit: click text in the preview`,group:`Page`,run:()=>_e(!ge)}]:[],{id:`page-yaml`,title:g?`Edit front matter as fields`:`Edit front matter as YAML`,group:`Page`,run:()=>_(!g)},...Le&&!Ie&&Re&&!ke?[{id:`page-review`,title:`Submit for review`,group:`Page`,run:()=>oe(!0)}]:[],...Le&&Ie&&Re&&!ke?[{id:`page-publish`,title:`Publish`,group:`Page`,run:Ye}]:[],...Be&&!ke?[{id:`page-share`,title:`Share this page`,group:`Page`,run:()=>w(!0)}]:[],...k?[{id:`page-present`,title:`Present in a new tab`,group:`Page`,run:()=>window.open(E({view:`present`,id:e,url:k,branch:n}),`_blank`,`noopener`)}]:[],{id:`page-file`,title:`Edit ${t} as a raw file`,group:`Page`,run:()=>D({view:`files`,id:e,branch:n,path:t})}]:[]),s)return(0,j.jsx)(`div`,{className:`pad notice bad`,role:`alert`,children:s});if(!a||!l)return(0,j.jsx)(`p`,{className:`pad muted`,children:`Loading the page…`});let $e=Object.keys(a.frontMatter).filter(e=>!_t.includes(e)&&!(e===`sections`&&fe)),tt=e=>t=>u({...l,[e]:t.target.type===`checkbox`?!!t.target.checked:t.target.value});return(0,j.jsx)(Ve,{left:(0,j.jsxs)(`section`,{className:`editor-pane`,children:[(0,j.jsxs)(`div`,{className:`pane-head`,children:[(0,j.jsxs)(`a`,{className:`back`,href:`/sites/${encodeURIComponent(e)}${n?`?branch=${encodeURIComponent(n)}`:``}`,onClick:t=>{t.preventDefault(),D({view:`site`,id:e,branch:n})},children:[`← `,r?.name||`Site`]}),(0,j.jsxs)(`span`,{className:`pane-pills`,children:[r&&r.accounts.length>1&&(0,j.jsxs)(`span`,{className:`pill`,title:`Change it in the site view`,children:[`as @`,r.as.split(`/`).pop()]}),(0,j.jsx)(`span`,{className:`pill ${Le?`warn`:``}`,children:Le?`draft: ${Te}`:`${Te} · published`})]})]}),(0,j.jsx)(`h1`,{children:l.title||t}),(0,j.jsxs)(`p`,{className:`muted mono small`,children:[t,Ne?` → ${Ne}`:``,Re&&ve===void 0&&t!==`content/index.md`&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small move-btn`,onClick:()=>ye(Ne||``),children:`Move…`})]}),ve!==void 0&&(0,j.jsx)(Tt,{id:e,source:t,branch:Te,baseCommit:a.commit,current:Ne||``,value:ve,dirty:ke,onChange:ye,onDone:t=>{ye(void 0),x({kind:`good`,text:`Moved to ${t.to}${t.redirected?`; ${t.from} now redirects there`:``}.${t.created?` On a new draft, ${t.branch}.`:``}`}),i(),D({view:`page`,id:e,source:t.source,branch:t.branch})}}),(0,j.jsxs)(`div`,{className:`actions`,children:[(0,j.jsx)(`button`,{type:`button`,className:`button primary`,disabled:!ke||T||!Re,onClick:He,children:Le?`Save`:`Save as draft`}),Le&&!Ie&&(0,j.jsx)(`button`,{type:`button`,className:`button`,disabled:T||ke||!Re,onClick:()=>oe(!F),children:`Submit for review`}),Le&&Ie&&(0,j.jsxs)(`a`,{className:`button`,href:Ie.url,target:`_blank`,rel:`noopener noreferrer`,children:[`Review #`,Ie.number,` ↗`]}),Le&&Ie&&(0,j.jsx)(`button`,{type:`button`,className:`button`,disabled:T||ke||!Re,onClick:Ye,title:`Merges the review, if the draft passes the checks`,children:`Publish`}),Be&&!S&&(0,j.jsx)(`button`,{type:`button`,className:`ghost`,disabled:ke,onClick:()=>w(!0),title:`Post a link to this page on Mastodon, Bluesky or LinkedIn`,children:`Share…`}),!Re&&(0,j.jsx)(`span`,{className:`muted small`,children:`Read only: the platform doesn't let you change this site.`}),ke&&(0,j.jsx)(`span`,{className:`muted small`,children:`Unsaved changes`})]}),b&&(0,j.jsx)(`p`,{className:`notice ${b.kind}`,role:`status`,children:b.text}),ce&&ce.length>0&&(0,j.jsx)(`ul`,{className:`problems`,children:ce.filter(e=>e.Level===`error`).map((e,t)=>(0,j.jsxs)(`li`,{className:`error`,children:[(0,j.jsx)(`span`,{className:`pill`,children:e.Rule}),` `,(0,j.jsx)(`span`,{className:`mono small`,children:e.File}),` `,e.What]},t))}),S&&Be&&(0,j.jsx)(lt,{title:t===`content/index.md`&&r?.siteName||l.title,summary:l.summary,url:ze,onClose:()=>w(!1)}),F&&(0,j.jsx)(wt,{id:e,branch:Te,title:l.title,onDone:e=>{oe(!1),x({kind:`good`,text:e}),i()},onError:e=>x({kind:`bad`,text:e})}),Fe.length>0&&(0,j.jsxs)(`div`,{className:`notice warn`,children:[(0,j.jsx)(`strong`,{children:`Checks on this page`}),(0,j.jsx)(`ul`,{className:`problems`,children:Fe.map((e,t)=>(0,j.jsxs)(`li`,{className:e.Level,children:[(0,j.jsx)(`span`,{className:`pill`,children:e.Rule}),` `,e.What,e.Fix&&(0,j.jsx)(`span`,{className:`fix`,children:e.Fix})]},t))})]}),R&&(0,j.jsx)(et,{id:e,branch:Te,seo:R.seo,siteURL:R.siteURL,path:R.path}),(0,j.jsxs)(`div`,{className:`fm-head`,children:[(0,j.jsx)(`h2`,{className:`side-label`,children:`Front matter`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>_(!g),children:g?`Edit as fields`:`Edit as YAML`})]}),g?(0,j.jsx)(`textarea`,{className:`code`,rows:10,value:v,onChange:e=>y(e.target.value),spellCheck:!1,"aria-label":`Front matter as YAML`}):(0,j.jsxs)(`div`,{className:`form`,children:[(0,j.jsxs)(`label`,{children:[`Title`,(0,j.jsx)(`input`,{value:l.title,onChange:tt(`title`)})]}),(0,j.jsxs)(`label`,{children:[`Summary`,(0,j.jsx)(`textarea`,{rows:2,value:l.summary,onChange:tt(`summary`)})]}),(0,j.jsxs)(`div`,{className:`row2`,children:[(0,j.jsxs)(`label`,{children:[`Date`,(0,j.jsx)(`input`,{type:`date`,value:l.date,onChange:tt(`date`)})]}),(0,j.jsxs)(`label`,{children:[`Publish at`,(0,j.jsx)(`input`,{type:`datetime-local`,value:l.publish_at,onChange:tt(`publish_at`)})]})]}),(0,j.jsxs)(`label`,{children:[`Tags `,(0,j.jsx)(`span`,{className:`muted small`,children:`comma-separated`}),(0,j.jsx)(`input`,{value:l.tags,onChange:tt(`tags`)})]}),(0,j.jsxs)(`div`,{className:`row2`,children:[(0,j.jsxs)(`label`,{children:[`Image`,(0,j.jsx)(`input`,{value:l.image,onChange:tt(`image`),placeholder:`/img/…`})]}),(0,j.jsxs)(`label`,{children:[`Image alt text`,(0,j.jsx)(`input`,{value:l.image_alt,onChange:tt(`image_alt`)})]})]}),(0,j.jsxs)(`label`,{className:`check`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:l.draft,onChange:tt(`draft`)}),` Keep out of the published site (draft)`]}),$e.length>0&&(0,j.jsxs)(`p`,{className:`muted small`,children:[`Other fields (`,$e.join(`, `),`) are kept as they are; edit them as YAML.`]})]}),fe&&!g&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`h2`,{className:`side-label`,children:[`Sections `,(0,j.jsx)(`span`,{className:`muted small`,children:`the page, top to bottom`})]}),(0,j.jsx)(se,{id:e,branch:Te,value:fe,onChange:pe,disabled:!Re,upload:Je})]}),(0,j.jsxs)(`div`,{className:`body-head`,children:[(0,j.jsx)(`h2`,{className:`side-label`,children:`Body`}),(0,j.jsxs)(`div`,{className:`seg small`,role:`group`,"aria-label":`Edit the body as`,children:[(0,j.jsx)(`button`,{type:`button`,"aria-pressed":me===`markdown`,onClick:()=>L(`markdown`),children:`Markdown`}),(0,j.jsx)(`button`,{type:`button`,"aria-pressed":me===`visual`,onClick:()=>L(`visual`),children:`Visual`})]}),Re&&me===`markdown`&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>de({}),children:`Insert picture`})]}),me===`visual`&&(0,j.jsx)(d.Suspense,{fallback:(0,j.jsx)(`p`,{className:`muted small`,children:`Loading the visual editor…`}),children:(0,j.jsx)(gt,{ref:he,value:f,onChange:p,onPicture:e=>de({file:e}),disabled:!Re})}),me===`markdown`&&(0,j.jsx)(`textarea`,{ref:xe,className:`code body-edit`,value:f,onChange:e=>p(e.target.value),onDragOver:e=>Re&&e.dataTransfer.types.includes(`Files`)&&e.preventDefault(),onDrop:e=>{let t=Array.from(e.dataTransfer.files).find(e=>`image/jpeg,image/png,image/gif,image/webp`.split(`,`).includes(e.type));t&&Re&&(e.preventDefault(),de({file:t}))},onPaste:e=>{let t=Array.from(e.clipboardData.files).find(e=>`image/jpeg,image/png,image/gif,image/webp`.split(`,`).includes(e.type));t&&Re&&(e.preventDefault(),de({file:t}))},spellCheck:!0,"aria-label":`Page body, Markdown`}),ue&&(0,j.jsx)(te,{id:e,branch:Te,baseCommit:a.commit,source:t,onDraft:Le,file:ue.file,onUploaded:e=>we.current=e,onInsert:Ke,onClose:()=>de(void 0)})]}),right:(0,j.jsxs)(`section`,{className:`preview-pane`,"aria-label":`Preview`,children:[(0,j.jsxs)(`div`,{className:`preview-bar`,children:[(0,j.jsx)(We,{device:ie,onChange:ae}),(0,j.jsx)(`span`,{className:`spacer`}),k&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,"aria-pressed":ge,onClick:()=>_e(!ge),title:`Click text in the preview to put the cursor there`,children:`Point & edit`}),k&&(0,j.jsx)(`a`,{className:`ghost small linkbtn`,href:E({view:`present`,id:e,url:k,branch:n}),target:`_blank`,rel:`noopener`,children:`Present ↗`}),k&&(0,j.jsx)(`a`,{className:`ghost small linkbtn`,href:k,target:`_blank`,rel:`noopener noreferrer`,children:`Open ↗`})]}),ee&&(0,j.jsx)(`p`,{className:`notice warn small preview-note`,children:ee}),(0,j.jsx)(Ge,{src:k,device:ie,title:`Preview of ${l.title}`,reloadKey:N})]})})}function wt({id:e,branch:t,title:n,onDone:r,onError:i}){let[a,o]=(0,d.useState)(`Update ${n}`),[s,c]=(0,d.useState)(``),[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)(),[m,h]=(0,d.useState)([]);return(0,d.useEffect)(()=>{C.people(e).then(e=>p(e.people),()=>p([]))},[e]),(0,j.jsxs)(`div`,{className:`form review-form`,children:[(0,j.jsxs)(`label`,{children:[`Review title`,(0,j.jsx)(`input`,{value:a,onChange:e=>o(e.target.value)})]}),(0,j.jsxs)(`label`,{children:[`What changed, for the reviewer`,(0,j.jsx)(`textarea`,{rows:3,value:s,onChange:e=>c(e.target.value)})]}),f&&f.length>0&&(0,j.jsxs)(`fieldset`,{className:`field group`,children:[(0,j.jsx)(`legend`,{children:`Ask for a review from`}),(0,j.jsx)(`div`,{className:`reviewer-pick`,children:f.map(e=>(0,j.jsxs)(`label`,{className:`check`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:m.includes(e.login),onChange:t=>h(t.target.checked?[...m,e.login]:m.filter(t=>t!==e.login))}),e.name||e.login,` `,(0,j.jsxs)(`span`,{className:`muted small`,children:[`@`,e.login]})]},e.login))})]}),(0,j.jsx)(`div`,{className:`actions`,children:(0,j.jsx)(`button`,{type:`button`,className:`button primary`,disabled:l||!a.trim(),onClick:async()=>{u(!0);try{let n=await C.review(e,{branch:t,title:a,description:s,reviewers:m}),i=n.reviewers?.length?` ${n.reviewers.map(e=>`@`+e).join(`, `)} ${n.reviewers.length===1?`was`:`were`} asked to review; the platform lets them know.`:``;r(`Submitted for review as #${n.number}.${n.preview?` The review links to this draft's preview.`:``}${i}${n.reviewersError?` `+n.reviewersError:``}`)}catch(e){i(e.message)}finally{u(!1)}},children:`Open the review`})})]})}function Tt({id:e,source:t,branch:n,baseCommit:r,current:i,value:a,dirty:o,onChange:s,onDone:c}){let[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)(),m=`/`+a.trim().replace(/^\/+|\/+$/g,``)+`/`,h=m===`//`?``:`content${m.slice(0,-1)}.md`,g=async()=>{u(!0),p(void 0);try{c(await C.move(e,{branch:n,baseCommit:r,source:t,to:h}))}catch(e){p(e.message)}finally{u(!1)}};return(0,j.jsxs)(`form`,{className:`form move-form`,onSubmit:e=>{e.preventDefault(),h&&!o&&g()},children:[(0,j.jsxs)(`label`,{children:[`New address`,(0,j.jsx)(`input`,{autoFocus:!0,value:a,onChange:e=>s(e.target.value),placeholder:`/about-us/`})]}),h&&(0,j.jsxs)(`p`,{className:`muted small`,children:[`Renames `,(0,j.jsx)(`span`,{className:`mono`,children:t}),` to `,(0,j.jsx)(`span`,{className:`mono`,children:h}),i&&m!==i?(0,j.jsxs)(j.Fragment,{children:[`, and `,(0,j.jsx)(`span`,{className:`mono`,children:i}),` will redirect to `,(0,j.jsx)(`span`,{className:`mono`,children:m})]}):``,`.`]}),o&&(0,j.jsx)(`p`,{className:`notice warn small`,children:`Save your changes first; the move is its own commit.`}),f&&(0,j.jsx)(`p`,{className:`notice bad small`,children:f}),(0,j.jsxs)(`div`,{className:`actions-row`,children:[(0,j.jsx)(`button`,{type:`submit`,className:`button`,disabled:l||!h||o||m===i,children:`Move`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>s(void 0),children:`Cancel`})]})]})}function Et(e){let t=e.replace(`#`,``);if(t.length===3&&(t=t.split(``).map(e=>e+e).join(``)),t.length!==6)return 0;let n=[0,2,4].map(e=>{let n=parseInt(t.slice(e,e+2),16)/255;return n<=.03928?n/12.92:((n+.055)/1.055)**2.4});return .2126*n[0]+.7152*n[1]+.0722*n[2]}function Dt(e,t){let[n,r]=[Et(e),Et(t)].sort((e,t)=>t-e);return Math.round((n+.05)/(r+.05)*100)/100}var Ot=e=>(typeof e==`string`?e:e?.light)||``,kt=e=>(typeof e==`object`&&e?e.dark:``)||``;function At(e,t,n,r){let i=e.tokens.find(e=>e.name===n),a=t[n];return r===`dark`?kt(a)||i.dark||Ot(a)||i.default||`#000000`:Ot(a)||i.default||`#000000`}function jt({id:e,branch:t}){let[n,r]=(0,d.useState)(),[i,a]=(0,d.useState)(),[o,s]=(0,d.useState)({}),[c,l]=(0,d.useState)(),[u,f]=(0,d.useState)(!1),[p,m]=(0,d.useState)(),[h,g]=(0,d.useState)(),[_,v]=(0,d.useState)(0),[y,b]=Ue(),[x,S]=(0,d.useState)(),[w,T]=(0,d.useState)(!1),E=(0,d.useRef)(void 0),O=(0,d.useRef)(void 0),k=async r=>{let i=await C.upload(e,r,{branch:t||n?.branch||``,baseCommit:n?.commit||``,source:`look.md`});return E.current=i,i.url},A=()=>C.look(e,t).then(e=>{r(e);let t=O.current;O.current=void 0,s(t||e.values||{})},e=>a(e.message));(0,d.useEffect)(()=>{A(),C.site(e,t).then(S,()=>void 0)},[e,t]);let ee=t||n?.branch||``,M=x?ee!==x.publishBranch:!1,te=x?.reviews?.find(e=>e.branch===ee),N=n?JSON.stringify(o)!==JSON.stringify(n.values||{}):!1;(0,d.useEffect)(()=>{let t=E.current;t&&(E.current=void 0,l({kind:`good`,text:`Added ${t.url}${t.created?` on a new draft, ${t.branch}`:``}. Save to keep it in the look.`}),t.created||t.branch!==ee?(O.current=o,D({view:`look`,id:e,branch:t.branch})):n&&r({...n,commit:t.commit}))},[o]);let ne=(0,d.useRef)(0);(0,d.useEffect)(()=>{if(n?.look)return window.clearTimeout(ne.current),ne.current=window.setTimeout(()=>{C.lookLive(e,{branch:ee,look:o}).then(e=>{if(e.error)return g(e.error);g(void 0),e.url===p?v(e=>e+1):m(e.url)},e=>g(e.message))},350),()=>window.clearTimeout(ne.current)},[o,n]);let re=(0,d.useMemo)(()=>n?.look?(n.look.contrast||[]).map(([e,t])=>({fg:e,bg:t,light:Dt(At(n.look,o,e,`light`),At(n.look,o,t,`light`)),dark:Dt(At(n.look,o,e,`dark`),At(n.look,o,t,`dark`))})):[],[n,o]),P=re.filter(e=>e.light<(n?.minContrast||4.5)||e.dark<(n?.minContrast||4.5)).length,ie=(e,t)=>s(n=>{let{[e]:r,...i}=n;return t===void 0||t===``?i:{...i,[e]:t}}),ae=async()=>{if(n){f(!0),l({kind:`info`,text:`Saving…`});try{let r=await C.lookSave(e,{branch:ee,baseCommit:n.commit,look:o});l({kind:`good`,text:r.created?`Saved. The new look is on a draft, ${r.branch}; the published site is unchanged.`:`Saved to ${r.branch}.`}),r.created||r.branch!==t?D({view:`look`,id:e,branch:r.branch}):A()}catch(e){l({kind:`bad`,text:`Not saved: ${e.message}`})}finally{f(!1)}}},F=async()=>{f(!0),l({kind:`info`,text:`Checking the draft and publishing…`});try{await C.publish(e,{branch:ee}),l({kind:`good`,text:`Published: the change is merged. The live site updates when its publishing pipeline runs.`}),x&&D({view:`look`,id:e,branch:x.publishBranch})}catch(e){l({kind:`bad`,text:e.message})}finally{f(!1)}};if(Ee(`mod+s`,()=>N&&!u&&n?.canWrite&&ae(),!!n),i)return(0,j.jsx)(`p`,{className:`pad notice bad`,role:`alert`,children:i});if(!n)return(0,j.jsx)(`p`,{className:`pad muted`,children:`Loading the look…`});let oe=(0,j.jsx)(`a`,{className:`back`,href:`/sites/${encodeURIComponent(e)}`,onClick:n=>{n.preventDefault(),D({view:`site`,id:e,branch:t})},children:`← Site`});if(!n.look)return(0,j.jsxs)(`section`,{className:`pad`,children:[oe,(0,j.jsx)(`h1`,{children:`Look`}),(0,j.jsxs)(`p`,{className:`muted`,children:[`This site's theme doesn't say what can be changed: it has no `,(0,j.jsx)(`span`,{className:`mono`,children:`look.yaml`}),`. A developer adds one to offer colors, fonts and a logo here.`]})]});let se=n.canWrite;return(0,j.jsx)(Ve,{left:(0,j.jsxs)(`section`,{className:`editor-pane`,children:[(0,j.jsxs)(`div`,{className:`pane-head`,children:[oe,(0,j.jsx)(`span`,{className:`pill ${M?`warn`:``}`,children:M?`draft: ${ee}`:`${ee} · published`})]}),(0,j.jsx)(`h1`,{children:`Look`}),(0,j.jsx)(`p`,{className:`muted small`,children:`What this site's theme lets change. The preview shows the home page as you pick.`}),(0,j.jsxs)(`div`,{className:`actions-row`,children:[(0,j.jsx)(`button`,{type:`button`,className:`button primary`,disabled:!N||u||!se,onClick:ae,children:M?`Save`:`Save as draft`}),M&&!te&&(0,j.jsx)(`button`,{type:`button`,className:`button`,disabled:u||N||!se,onClick:()=>T(!w),children:`Submit for review`}),M&&te&&(0,j.jsxs)(`a`,{className:`button`,href:te.url,target:`_blank`,rel:`noopener noreferrer`,children:[`Review #`,te.number,` ↗`]}),M&&te&&(0,j.jsx)(`button`,{type:`button`,className:`button`,disabled:u||N||!se,onClick:F,children:`Publish`}),N&&(0,j.jsx)(`span`,{className:`muted small`,children:`Unsaved changes`}),!se&&(0,j.jsx)(`span`,{className:`muted small`,children:`Read only: the platform doesn't let you change this site.`})]}),c&&(0,j.jsx)(`p`,{className:`notice ${c.kind}`,role:`status`,children:c.text}),w&&(0,j.jsx)(wt,{id:e,branch:ee,title:`the look`,onDone:n=>{T(!1),l({kind:`good`,text:n}),C.site(e,t).then(S)},onError:e=>l({kind:`bad`,text:e})}),(0,j.jsxs)(`div`,{className:`notice ${P?`bad`:`good`}`,children:[(0,j.jsx)(`strong`,{children:P?`${P} pair${P===1?``:`s`} too hard to read: this can't be published until fixed.`:`Every pair is readable.`}),(0,j.jsxs)(`table`,{className:`contrast`,children:[(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{children:`Text`}),(0,j.jsx)(`th`,{children:`On`}),(0,j.jsx)(`th`,{children:`Light`}),(0,j.jsx)(`th`,{children:`Dark`})]})}),(0,j.jsx)(`tbody`,{children:re.map(e=>(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`td`,{children:Mt(n.look,e.fg)}),(0,j.jsx)(`td`,{children:Mt(n.look,e.bg)}),[e.light,e.dark].map((e,t)=>(0,j.jsxs)(`td`,{className:e(0,j.jsx)(Nt,{t,value:o[t.name],onChange:e=>ie(t.name,e),id:e,branch:ee,disabled:!se,upload:k},t.name))})]}),right:(0,j.jsxs)(`section`,{className:`preview-pane`,"aria-label":`Preview`,children:[(0,j.jsx)(`div`,{className:`preview-bar`,children:(0,j.jsx)(We,{device:y,onChange:b})}),h&&(0,j.jsx)(`p`,{className:`notice warn small preview-note`,children:h}),(0,j.jsx)(Ge,{src:p,device:y,title:`Preview of the look`,reloadKey:_})]})})}function Mt(e,t){return e.tokens.find(e=>e.name===t)?.label||t}function Nt({t:e,value:t,onChange:n,id:r,branch:i,disabled:a,upload:o}){let s=t!==void 0&&!a&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>n(void 0),children:`Use the theme's`}),c=e.help&&(0,j.jsx)(`span`,{className:`muted small`,children:e.help});switch(e.type){case`color`:{let r=Ot(t),i=kt(t),o=(t,r)=>n(r?{light:t||e.default,dark:r}:t||void 0);return(0,j.jsxs)(`fieldset`,{className:`field group token`,children:[(0,j.jsxs)(`legend`,{children:[e.label||e.name,` `,s]}),c,(0,j.jsxs)(`div`,{className:`color-row`,children:[(0,j.jsxs)(`label`,{className:`color-pick`,children:[(0,j.jsx)(`input`,{type:`color`,value:r||e.default,disabled:a,onChange:e=>o(e.target.value,i),"aria-label":`${e.label}, light`}),(0,j.jsx)(`span`,{className:`mono small`,children:r||`${e.default} (theme)`})]}),(0,j.jsxs)(`label`,{className:`check small`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:!!i,disabled:a,onChange:t=>o(r,t.target.checked?e.dark||r||e.default||`#000000`:``)}),` Different in dark mode`]}),i&&(0,j.jsxs)(`label`,{className:`color-pick`,children:[(0,j.jsx)(`input`,{type:`color`,value:i,disabled:a,onChange:e=>o(r,e.target.value),"aria-label":`${e.label}, dark`}),(0,j.jsxs)(`span`,{className:`mono small`,children:[i,` (dark)`]})]}),!i&&e.dark&&(0,j.jsxs)(`span`,{className:`muted small`,children:[`Dark mode: `,e.dark,` (theme)`]})]})]})}case`font`:case`select`:return(0,j.jsxs)(`label`,{className:`field token`,children:[(0,j.jsxs)(`span`,{className:`field-label`,children:[e.label||e.name,` `,s]}),(0,j.jsxs)(`select`,{value:Ot(t),disabled:a,onChange:e=>n(e.target.value||void 0),children:[(0,j.jsxs)(`option`,{value:``,children:[`The theme's (`,e.default,`)`]}),(e.options||[]).map(t=>(0,j.jsx)(`option`,{value:t.name,style:e.type===`font`?{fontFamily:t.value}:void 0,children:t.name},t.name))]}),c]});case`image`:return(0,j.jsx)(ue,{f:{name:e.name,label:e.label,type:`image`},label:(0,j.jsxs)(`span`,{className:`field-label`,children:[e.label||e.name,` `,s]}),help:c,value:Ot(t),onChange:e=>n(e||void 0),ctx:{id:r,branch:i,lib:{sections:[],data:[],collections:[]},upload:o},disabled:a})}}var Pt=()=>void 0,Ft=()=>Pt();function It(){let[e,t]=(0,d.useState)(!1),[n,r]=(0,d.useState)(``),[i,a]=(0,d.useState)(0),[o,s]=(0,d.useState)([]),c=(0,d.useRef)(null),l=(0,d.useRef)(null),u=()=>{s(we()),r(``),a(0),t(!0)};Pt=u,Ee(`mod+k`,()=>e?t(!1):u()),(0,d.useEffect)(()=>{e?c.current?.showModal():c.current?.open&&c.current.close()},[e]);let f=(0,d.useMemo)(()=>{let e=o.map(e=>({c:e,s:Math.max(Te(n,e.title),Te(n,`${e.group} ${e.title}`)-50)})).filter(e=>e.s>=0);return n.trim()&&e.sort((e,t)=>t.s-e.s),e.slice(0,60).map(e=>e.c)},[o,n]);(0,d.useEffect)(()=>{l.current?.querySelector(`[aria-selected="true"]`)?.scrollIntoView({block:`nearest`})},[i]);let p=e=>{t(!1),setTimeout(e.run,0)};return(0,j.jsx)(`dialog`,{ref:c,className:`palette`,"aria-label":`Command palette`,onClose:()=>t(!1),children:e&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`input`,{autoFocus:!0,className:`palette-input`,placeholder:`Type a command or a page…`,value:n,role:`combobox`,"aria-expanded":`true`,"aria-controls":`palette-list`,"aria-activedescendant":f[i]?`cmd-${i}`:void 0,onChange:e=>{r(e.target.value),a(0)},onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),a(e=>Math.min(e+1,f.length-1))):e.key===`ArrowUp`?(e.preventDefault(),a(e=>Math.max(e-1,0))):e.key===`Enter`&&f[i]&&(e.preventDefault(),p(f[i]))}}),(0,j.jsxs)(`ul`,{id:`palette-list`,role:`listbox`,ref:l,className:`palette-list`,children:[f.length===0&&(0,j.jsx)(`li`,{className:`muted small palette-empty`,children:`Nothing matches.`}),f.map((e,t)=>(0,j.jsxs)(`li`,{id:`cmd-${t}`,role:`option`,"aria-selected":t===i,className:t===i?`on`:``,onMouseMove:()=>a(t),onClick:()=>p(e),children:[(0,j.jsx)(`span`,{className:`muted small palette-group`,children:e.group}),(0,j.jsx)(`span`,{className:`palette-title`,children:e.title}),e.keys&&(0,j.jsx)(`kbd`,{children:e.keys})]},e.id))]}),(0,j.jsx)(`p`,{className:`palette-foot muted small`,children:"↑↓ to move · Enter to run · Esc to close · Ctrl+` opens the console"})]})})}var Lt=[{id:``,label:`None`,about:`No visit statistics.`},{id:`plausible`,label:`Plausible`,about:`Counts visits without cookies; hosted or self-hosted.`},{id:`matomo`,label:`Matomo`,about:`Self-hosted statistics.`},{id:`ga4`,label:`Google Analytics`,about:`Google Analytics 4. Visitors’ data goes to Google.`}];function Rt({id:e,branch:t}){let[n,r]=(0,d.useState)(),[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)({}),[c,l]=(0,d.useState)(),[u,f]=(0,d.useState)(!1),p=()=>C.privacy(e,t).then(e=>{a(e.analytics),s(e.privacy),r({commit:e.commit,branch:e.branch,canWrite:e.canWrite,start:JSON.stringify([e.analytics,e.privacy])})},e=>l({kind:`bad`,text:e.message}));(0,d.useEffect)(()=>{p()},[e,t]);let m=!!n&&JSON.stringify([i,o])!==n.start,h=!i||i.gated!==!1,g=(e,t,r,o)=>(0,j.jsxs)(`label`,{className:`field`,children:[t,(0,j.jsx)(`input`,{value:i?.[e]||``,placeholder:r,disabled:!n?.canWrite,onChange:t=>a({...i,[e]:t.target.value})}),o&&(0,j.jsx)(`span`,{className:`muted small`,children:o})]});return(0,j.jsxs)(`section`,{className:`pad privacy-view`,children:[(0,j.jsx)(`a`,{className:`back`,href:`/sites/${encodeURIComponent(e)}`,onClick:n=>{n.preventDefault(),D({view:`site`,id:e,branch:t})},children:`← Site`}),(0,j.jsx)(`h1`,{children:`Privacy and statistics`}),(0,j.jsx)(`p`,{className:`muted`,children:`What the site counts, and who answers for visitors' data. The privacy notice at /privacy/ is written from these settings every time the site is built.`}),c&&(0,j.jsx)(`p`,{className:`notice ${c.kind}`,role:`status`,children:c.text}),n&&(0,j.jsxs)(`div`,{className:`form wizard`,children:[(0,j.jsxs)(`fieldset`,{className:`field group`,children:[(0,j.jsx)(`legend`,{children:`Visit statistics`}),(0,j.jsx)(`div`,{className:`provider-pick`,role:`radiogroup`,"aria-label":`Statistics`,children:Lt.map(e=>(0,j.jsxs)(`label`,{className:`provider ${(i?.provider||``)===e.id?`on`:``}`,children:[(0,j.jsx)(`input`,{type:`radio`,name:`provider`,checked:(i?.provider||``)===e.id,disabled:!n.canWrite,onChange:()=>a(e.id?{provider:e.id,gated:i?.gated}:null)}),(0,j.jsx)(`strong`,{children:e.label}),(0,j.jsx)(`span`,{className:`muted small`,children:e.about})]},e.id))}),i?.provider===`plausible`&&(0,j.jsxs)(j.Fragment,{children:[g(`domain`,`Site domain in Plausible`,`example.org`),g(`src`,`Script address (if self-hosted)`,`https://plausible.io/js/script.js`,`Leave empty for plausible.io.`)]}),i?.provider===`matomo`&&(0,j.jsxs)(j.Fragment,{children:[g(`url`,`Matomo address`,`https://matomo.example.org/`),g(`siteId`,`Site ID`,`1`)]}),i?.provider===`ga4`&&g(`id`,`Measurement ID`,`G-XXXXXXX`),i&&(0,j.jsxs)(`label`,{className:`check field`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:h,disabled:!n.canWrite,onChange:e=>a({...i,gated:e.target.checked?void 0:!1})}),`Ask visitors first (recommended)`]}),i&&h&&(0,j.jsx)(`p`,{className:`muted small`,children:`A banner asks on the first visit, with Decline first and as prominent as Accept. Nothing is counted until someone accepts; declining later removes the counter's cookies.`}),i&&!h&&(0,j.jsx)(`p`,{className:`notice warn small`,children:`Statistics will start on page view, without asking. That's recorded in site.yaml (gated: false), the privacy notice says so, and every check warns about it. In much of the world, counting with cookies needs consent.`})]}),(0,j.jsxs)(`fieldset`,{className:`field group`,children:[(0,j.jsx)(`legend`,{children:`Who answers for visitors' data`}),(0,j.jsxs)(`label`,{className:`field`,children:[`Person or organization`,(0,j.jsx)(`input`,{value:o.controller||``,disabled:!n.canWrite,placeholder:`Your name, or your company`,onChange:e=>s({...o,controller:e.target.value})})]}),(0,j.jsxs)(`label`,{className:`field`,children:[`Email to write to`,(0,j.jsx)(`input`,{value:o.contact||``,disabled:!n.canWrite,placeholder:`privacy@example.org`,onChange:e=>s({...o,contact:e.target.value})})]}),(0,j.jsxs)(`label`,{className:`field`,children:[`Last changed`,(0,j.jsx)(`input`,{value:o.updated||``,disabled:!n.canWrite,placeholder:`10 October 2026`,onChange:e=>s({...o,updated:e.target.value})})]})]}),n.canWrite&&(0,j.jsx)(`div`,{className:`actions-row`,children:(0,j.jsx)(`button`,{type:`button`,className:`button primary`,disabled:!m||u,onClick:async()=>{if(n){f(!0),l({kind:`info`,text:`Saving…`});try{let r=await C.privacySave(e,{branch:n.branch,baseCommit:n.commit,analytics:i,privacy:o});l({kind:`good`,text:`Saved on ${r.created?`a new draft, ${r.branch}`:r.branch}. Its preview's /privacy/ page shows the new list.`}),r.created||r.branch!==t?D({view:`privacy`,id:e,branch:r.branch}):p()}catch(e){l({kind:`bad`,text:e.message})}finally{f(!1)}}},children:n.branch===t?`Save`:`Save as draft`})})]})]})}function zt({id:e,branch:t}){let[n,r]=(0,d.useState)(),[i,a]=(0,d.useState)(),[o,s]=(0,d.useState)(),[c,l]=(0,d.useState)(!1),u=()=>C.redirects(e,t).then(e=>{a({rows:e.redirects,commit:e.commit,branch:e.branch,canWrite:e.canWrite}),r(e.redirects.map(e=>({...e})))},e=>s({kind:`bad`,text:e.message}));(0,d.useEffect)(()=>{u()},[e,t]);let f=!!i&&JSON.stringify(n)!==JSON.stringify(i.rows),p=(e,t,n)=>r(r=>r.map((r,i)=>i===e?{...r,[t]:n}:r));return(0,j.jsxs)(`section`,{className:`pad redirects`,children:[(0,j.jsx)(`a`,{className:`back`,href:`/sites/${encodeURIComponent(e)}`,onClick:n=>{n.preventDefault(),D({view:`site`,id:e,branch:t})},children:`← Site`}),(0,j.jsx)(`h1`,{children:`Redirects`}),(0,j.jsx)(`p`,{className:`muted`,children:`Old addresses that should keep working. Moving a page adds its redirect by itself; add others here, for a page that's gone or a link printed somewhere.`}),o&&(0,j.jsx)(`p`,{className:`notice ${o.kind}`,role:`status`,children:o.text}),!n&&!o&&(0,j.jsx)(`p`,{className:`muted`,children:`Reading site.yaml…`}),n&&(0,j.jsxs)(`div`,{className:`form`,children:[(0,j.jsxs)(`table`,{className:`pages redirect-table`,children:[(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{children:`Old address`}),(0,j.jsx)(`th`,{children:`Goes to`}),(0,j.jsx)(`th`,{})]})}),(0,j.jsxs)(`tbody`,{children:[n.map((e,t)=>(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`td`,{children:(0,j.jsx)(`input`,{value:e.from,placeholder:`/old-page/`,disabled:!i?.canWrite,onChange:e=>p(t,`from`,e.target.value),"aria-label":`Old address ${t+1}`})}),(0,j.jsx)(`td`,{children:(0,j.jsx)(`input`,{value:e.to,placeholder:`/new-page/ or https://…`,disabled:!i?.canWrite,onChange:e=>p(t,`to`,e.target.value),"aria-label":`Goes to ${t+1}`})}),(0,j.jsx)(`td`,{children:i?.canWrite&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>r(n.filter((e,n)=>n!==t)),children:`Remove`})})]},t)),n.length===0&&(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:3,className:`muted small`,children:`No redirects.`})})]})]}),i?.canWrite&&(0,j.jsxs)(`div`,{className:`actions-row`,children:[(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>r([...n,{from:``,to:``}]),children:`Add a redirect`}),(0,j.jsx)(`button`,{type:`button`,className:`button primary`,disabled:!f||c,onClick:async()=>{if(i&&n){l(!0),s({kind:`info`,text:`Saving…`});try{let r=await C.redirectsSave(e,{branch:i.branch,baseCommit:i.commit,redirects:n.filter(e=>e.from.trim()||e.to.trim())});s({kind:`good`,text:`Saved on ${r.created?`a new draft, ${r.branch}`:r.branch}.`}),r.created||r.branch!==t?D({view:`redirects`,id:e,branch:r.branch}):u()}catch(e){s({kind:`bad`,text:e.message})}finally{l(!1)}}},children:i.branch===t?`Save`:`Save as draft`})]})]})]})}var Bt=[{k:`google`,name:`Google Search Console`,where:`Add a property for the site, choose "HTML tag", and copy the content="…" value (or the whole tag; the code is taken out of it).`},{k:`bing`,name:`Bing Webmaster Tools`,where:`Add the site, choose "HTML Meta Tag", and copy the content value of msvalidate.01.`},{k:`yandex`,name:`Yandex Webmaster`,where:`Add the site, choose "Meta tag", and copy the content value.`}];function Vt(){let e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}function Ht({id:e,branch:t}){let[n,r]=(0,d.useState)(),[i,a]=(0,d.useState)({}),[o,s]=(0,d.useState)(``),[c,l]=(0,d.useState)(),[u,f]=(0,d.useState)(!1),p=()=>C.search(e,t).then(e=>{let t={google:e.verify.google||``,bing:e.verify.bing||``,yandex:e.verify.yandex||``};a(t),s(e.indexnow||``),r({commit:e.commit,branch:e.branch,canWrite:e.canWrite,sitemap:e.sitemap,siteURL:e.siteURL,start:JSON.stringify([t,e.indexnow||``])})},e=>l({kind:`bad`,text:e.message}));(0,d.useEffect)(()=>{p()},[e,t]);let m=!!n&&JSON.stringify([i,o])!==n.start;return(0,j.jsxs)(`section`,{className:`pad search-view`,children:[(0,j.jsx)(`a`,{className:`back`,href:`/sites/${encodeURIComponent(e)}`,onClick:n=>{n.preventDefault(),D({view:`site`,id:e,branch:t})},children:`← Site`}),(0,j.jsx)(`h1`,{children:`Search engines`}),(0,j.jsx)(`p`,{className:`muted`,children:`Show each search console the site is yours, and tell search engines what changed whenever it's published.`}),c&&(0,j.jsx)(`p`,{className:`notice ${c.kind}`,role:`status`,children:c.text}),n&&(0,j.jsxs)(`div`,{className:`form wizard`,children:[(0,j.jsxs)(`fieldset`,{className:`field group`,children:[(0,j.jsx)(`legend`,{children:`Verification`}),Bt.map(e=>(0,j.jsxs)(`label`,{className:`field`,children:[e.name,(0,j.jsx)(`input`,{value:i[e.k]||``,disabled:!n.canWrite,placeholder:`The code from the meta tag`,onChange:t=>a({...i,[e.k]:t.target.value})}),(0,j.jsx)(`span`,{className:`muted small`,children:e.where})]},e.k)),(0,j.jsxs)(`p`,{className:`muted small`,children:[`The codes become meta tags on the home page. The site's sitemap, to give each console: `,(0,j.jsx)(`span`,{className:`mono`,children:n.sitemap})]})]}),(0,j.jsxs)(`fieldset`,{className:`field group`,children:[(0,j.jsx)(`legend`,{children:`IndexNow`}),(0,j.jsxs)(`p`,{className:`muted small`,children:[`IndexNow tells Bing, Yandex and the other search engines that share it which pages changed, each time the site is published. The key proves the message is the site's own; the build publishes it as `,(0,j.jsxs)(`span`,{className:`mono`,children:[`/`,o||`key`,`.txt`]}),`.`]}),(0,j.jsxs)(`div`,{className:`image-row`,children:[(0,j.jsx)(`input`,{value:o,disabled:!n.canWrite,placeholder:`No key: IndexNow is off`,onChange:e=>s(e.target.value),"aria-label":`IndexNow key`}),n.canWrite&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>s(Vt()),children:o?`New key`:`Make a key`})]}),(0,j.jsxs)(`p`,{className:`muted small`,children:[`Then, on the live site's publish target, set `,(0,j.jsx)(`span`,{className:`mono`,children:`indexnow: true`}),` in publish.yaml (or run the pull agent with `,(0,j.jsx)(`span`,{className:`mono`,children:`-indexnow`}),`). Only that target sends; staging never does.`]})]}),n.canWrite&&(0,j.jsx)(`div`,{className:`actions-row`,children:(0,j.jsx)(`button`,{type:`button`,className:`button primary`,disabled:!m||u,onClick:async()=>{if(n){f(!0),l({kind:`info`,text:`Saving…`});try{let r=await C.searchSave(e,{branch:n.branch,baseCommit:n.commit,verify:i,indexnow:o});l({kind:`good`,text:`Saved on ${r.created?`a new draft, ${r.branch}`:r.branch}. Once it's published, press Verify in each console.`}),r.created||r.branch!==t?D({view:`search`,id:e,branch:r.branch}):p()}catch(e){l({kind:`bad`,text:e.message})}finally{f(!1)}}},children:n.branch===t?`Save`:`Save as draft`})})]})]})}var Ut=`hotdog-theme`;function Wt(){try{let e=localStorage.getItem(Ut);if(e===`light`||e===`dark`)return e}catch{}return`system`}function Gt(){let[e,t]=(0,d.useState)(Wt),n=e=>{t(e),e===`system`?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e;try{e===`system`?localStorage.removeItem(Ut):localStorage.setItem(Ut,e)}catch{}},r={system:`Auto`,light:`Light`,dark:`Dark`};return(0,j.jsx)(`div`,{className:`seg theme-pick`,role:`group`,"aria-label":`Color theme`,children:Object.keys(r).map(t=>(0,j.jsx)(`button`,{type:`button`,"aria-pressed":e===t,title:t===`system`?`Follow the device setting`:`${r[t]} theme`,onClick:()=>n(t),children:r[t]},t))})}function z({to:e,children:t,className:n}){return(0,j.jsx)(`a`,{className:n,href:E(e),onClick:t=>{t.metaKey||t.ctrlKey||t.shiftKey||t.button!==0||(t.preventDefault(),D(e))},children:t})}function Kt(e,t){let[n,r]=(0,d.useState)({loading:!0}),i=(0,d.useCallback)(()=>{r(e=>({...e,loading:!0})),e().then(e=>r({data:e,loading:!1}),e=>r({error:e,loading:!1}))},t);return(0,d.useEffect)(i,[i]),{...n,reload:i}}function qt(){let e=O(),t=Kt(C.session,[]);if(t.loading&&!t.data)return(0,j.jsx)(Jt,{children:(0,j.jsx)(`p`,{className:`muted pad`,children:`Loading…`})});if(t.error)return(0,j.jsx)(Jt,{children:(0,j.jsx)(Yt,{error:t.error})});let n=t.data;return n.signedIn?(0,j.jsxs)(Jt,{session:n,onAccountsChanged:t.reload,children:[e.view===`sites`&&(0,j.jsx)(Zt,{}),e.view===`site`&&(0,j.jsx)(Qt,{id:e.id,branch:e.branch}),e.view===`page`&&(0,j.jsx)(en,{id:e.id,source:e.source,branch:e.branch}),e.view===`present`&&(0,j.jsx)(Xe,{id:e.id,url:e.url,branch:e.branch}),e.view===`media`&&(0,j.jsx)(M,{id:e.id,branch:e.branch}),e.view===`look`&&(0,j.jsx)(jt,{id:e.id,branch:e.branch}),e.view===`files`&&(0,j.jsx)(Pe,{id:e.id,branch:e.branch,path:e.path}),e.view===`redirects`&&(0,j.jsx)(zt,{id:e.id,branch:e.branch}),e.view===`privacy`&&(0,j.jsx)(Rt,{id:e.id,branch:e.branch}),e.view===`search`&&(0,j.jsx)(Ht,{id:e.id,branch:e.branch}),e.view===`forms`&&(0,j.jsx)(Je,{id:e.id,branch:e.branch,form:e.form}),e.view===`history`&&(0,j.jsx)(Ye,{id:e.id}),e.view===`quick`&&(0,j.jsx)(pe,{id:e.id,kind:e.kind})]}):(0,j.jsx)(Xt,{session:n})}function Jt({children:e,session:t,onAccountsChanged:n}){return(0,j.jsxs)(`div`,{className:`app`,children:[(0,j.jsxs)(`header`,{className:`top`,children:[(0,j.jsxs)(z,{to:{view:`sites`},className:`brand`,children:[(0,j.jsx)(`img`,{className:`logo only-light`,src:R,alt:`HotDog CMS`}),(0,j.jsx)(`img`,{className:`logo only-dark`,src:ye,alt:`HotDog CMS`}),(0,j.jsx)(`span`,{className:`brand-sub`,children:`Editor`})]}),(0,j.jsxs)(`div`,{className:`who`,children:[t?.signedIn&&(0,j.jsxs)(`button`,{type:`button`,className:`ghost small kbd-hint`,onClick:Ft,title:`Every action, by name`,children:[`Commands `,(0,j.jsx)(`kbd`,{children:`Ctrl K`})]}),(0,j.jsx)(Gt,{}),t?.signedIn&&n&&(0,j.jsx)(xe,{session:t,onChanged:n})]})]}),(0,j.jsx)(`main`,{id:`main`,children:e}),(0,j.jsx)(ve,{}),t?.signedIn&&(0,j.jsx)(nn,{session:t}),t?.signedIn&&(0,j.jsx)(It,{}),t?.signedIn&&(0,j.jsx)(je,{})]})}function Yt({error:e}){return e instanceof p?(0,j.jsxs)(`div`,{className:`pad`,children:[(0,j.jsx)(`p`,{children:e.message}),(0,j.jsx)(`p`,{children:(0,j.jsx)(`button`,{type:`button`,className:`button`,onClick:()=>location.reload(),children:`Sign in again`})})]}):(0,j.jsx)(`div`,{className:`pad notice bad`,role:`alert`,children:e.message})}function Xt({session:e}){let t=location.pathname+location.search;return(0,j.jsxs)(`div`,{className:`app`,children:[(0,j.jsx)(`div`,{className:`signin`,children:(0,j.jsxs)(`div`,{className:`card`,children:[(0,j.jsx)(`img`,{className:`signin-logo only-light`,src:R,alt:`HotDog CMS`}),(0,j.jsx)(`img`,{className:`signin-logo only-dark`,src:ye,alt:`HotDog CMS`}),(0,j.jsx)(`h1`,{children:`Sign in`}),(0,j.jsx)(`p`,{className:`muted`,children:`With the git platform your sites live on. The editor keeps no accounts of its own: what you can open and change is what the platform already lets you, and every change is made as you.`}),(0,j.jsxs)(`div`,{className:`stack`,children:[e.forges.map(e=>(0,j.jsxs)(`a`,{className:`button primary`,href:w(e.host,t),children:[`Sign in with `,be(e.kind),` `,(0,j.jsxs)(`span`,{className:`muted-on`,children:[`· `,e.host]})]},e.host)),e.forges.length===0&&(0,j.jsx)(`p`,{className:`notice bad`,children:`No git platform is configured for this editor.`})]})]})}),(0,j.jsx)(ve,{})]})}function Zt(){let e=Kt(C.sites,[]);return(0,j.jsxs)(`section`,{className:`pad`,children:[(0,j.jsx)(`h1`,{children:`Your sites`}),e.loading&&!e.data&&(0,j.jsx)(`p`,{className:`muted`,children:`Asking the platform which sites you can open…`}),e.error&&(0,j.jsx)(Yt,{error:e.error}),e.data&&e.data.length===0&&(0,j.jsx)(`p`,{className:`muted`,children:`None of the sites this editor knows about are open to your account.`}),(0,j.jsx)(`ul`,{className:`tiles`,children:e.data?.map(e=>(0,j.jsx)(`li`,{children:(0,j.jsxs)(z,{to:{view:`site`,id:e.id},className:`tile`,children:[(0,j.jsx)(`strong`,{children:e.name}),e.discovered&&(0,j.jsx)(`span`,{className:`muted small`,title:`Not listed in editor.yaml: found because it has a site.yaml`,children:`Found in your repositories`}),(0,j.jsx)(`span`,{className:`muted mono`,children:e.repo.replace(/^https?:\/\//,``).replace(/\.git$/,``)}),(0,j.jsx)(`span`,{className:`tile-accounts`,children:e.accounts.map(e=>(0,j.jsxs)(`span`,{className:`pill`,title:`${e.login} on ${e.forge}`,children:[`@`,e.login,` · `,e.canWrite?`can edit`:`read only`]},e.id))})]})},e.id))})]})}function Qt({id:e,branch:t}){let n=Kt(()=>C.site(e,t),[e,t]);Ce(()=>{let r=n.data;return r?[...(r.pages||[]).filter(e=>e.source).map(n=>({id:`page:${n.source}`,title:`${n.title} ${n.path}`,group:`Open page`,run:()=>D({view:`page`,id:e,source:n.source,branch:t})})),...(r.drafts||[]).map(t=>({id:`draft:${t.branch}`,title:t.branch,group:`Switch to draft`,run:()=>D({view:`site`,id:e,branch:t.branch})})),...t?[{id:`draft:back`,title:`Back to ${r.publishBranch}`,group:`Switch to draft`,run:()=>D({view:`site`,id:e})}]:[]]:[]});let[r,i]=(0,d.useState)(``),a=n.data,o=(0,d.useMemo)(()=>(a?.pages||[]).filter(e=>r===``?!0:r===`-`?!e.collection:e.collection===r),[a,r]);if(n.loading&&!a)return(0,j.jsx)(`p`,{className:`pad muted`,children:`Fetching the site with your account…`});if(n.error)return(0,j.jsx)(Yt,{error:n.error});if(!a)return null;let s=(a.pages||[]).filter(e=>!e.collection).length;return(0,j.jsxs)(`div`,{className:`split`,children:[(0,j.jsxs)(`aside`,{className:`side`,"aria-label":`Site`,children:[(0,j.jsxs)(`div`,{className:`side-head`,children:[(0,j.jsx)(z,{to:{view:`sites`},className:`back`,children:`← Sites`}),(0,j.jsx)(`h1`,{children:a.name}),(0,j.jsx)(`p`,{className:`muted mono small`,children:a.branch===a.publishBranch?`${a.branch} · published branch`:`${a.branch} · draft`}),a.role&&(0,j.jsx)(`p`,{className:`muted small role-line`,title:`From the platform's permissions`,children:{reader:`You can read this site.`,writer:`You can save drafts and open reviews; the platform decides who may publish.`,maintainer:`You maintain this site: drafts, reviews and publishing.`}[a.role]}),a.accounts.length>1&&(0,j.jsxs)(`label`,{className:`working-as`,children:[`Working as`,(0,j.jsx)(`select`,{value:a.as,onChange:t=>{b(e,t.target.value),n.reload()},children:a.accounts.map(e=>(0,j.jsxs)(`option`,{value:e.id,children:[`@`,e.login,` · `,e.forge,e.canWrite?``:` (read only)`]},e.id))})]})]}),(0,j.jsxs)(`nav`,{"aria-label":`Pages`,children:[(0,j.jsx)(`h2`,{className:`side-label`,children:`Pages`}),(0,j.jsxs)(`button`,{type:`button`,className:`side-item ${r===``?`on`:``}`,onClick:()=>i(``),children:[`All pages `,(0,j.jsx)(`span`,{children:(a.pages||[]).length})]}),s>0&&(0,j.jsxs)(`button`,{type:`button`,className:`side-item ${r===`-`?`on`:``}`,onClick:()=>i(`-`),children:[`Pages `,(0,j.jsx)(`span`,{children:s})]}),(a.collections||[]).map(e=>(0,j.jsxs)(`button`,{type:`button`,className:`side-item ${r===e.name?`on`:``}`,onClick:()=>i(e.name),children:[e.title,` `,(0,j.jsx)(`span`,{children:e.count})]},e.name))]}),(0,j.jsxs)(`nav`,{"aria-label":`Site files`,children:[(0,j.jsx)(`h2`,{className:`side-label`,children:`Files`}),(0,j.jsx)(z,{to:{view:`media`,id:e,branch:t},className:`side-item`,children:`Pictures`}),(0,j.jsx)(z,{to:{view:`forms`,id:e,branch:t},className:`side-item`,children:`Forms`}),(0,j.jsx)(z,{to:{view:`look`,id:e,branch:t},className:`side-item`,children:`Look`}),(0,j.jsx)(z,{to:{view:`files`,id:e,branch:t},className:`side-item`,children:`Files`}),(0,j.jsx)(z,{to:{view:`redirects`,id:e,branch:t},className:`side-item`,children:`Redirects`}),(0,j.jsx)(z,{to:{view:`history`,id:e},className:`side-item`,children:`History`}),(0,j.jsx)(z,{to:{view:`privacy`,id:e,branch:t},className:`side-item`,children:`Privacy & statistics`}),(0,j.jsx)(z,{to:{view:`search`,id:e,branch:t},className:`side-item`,children:`Search engines`})]}),(0,j.jsxs)(`nav`,{"aria-label":`Drafts`,children:[(0,j.jsx)(`h2`,{className:`side-label`,children:`Drafts`}),a.branch!==a.publishBranch&&(0,j.jsxs)(z,{to:{view:`site`,id:e},className:`side-item`,children:[`← Back to `,a.publishBranch]}),(a.drafts||[]).length===0&&(0,j.jsx)(`p`,{className:`muted small side-note`,children:`No drafts.`}),(a.drafts||[]).map(t=>(0,j.jsx)(z,{to:{view:`site`,id:e,branch:t.branch},className:`side-item ${a.branch===t.branch?`on`:``}`,children:t.branch},t.branch))]}),(0,j.jsxs)(`nav`,{"aria-label":`Reviews`,children:[(0,j.jsx)(`h2`,{className:`side-label`,children:`In review`}),(a.reviews||[]).length===0&&(0,j.jsx)(`p`,{className:`muted small side-note`,children:`Nothing waiting for review.`}),(a.reviews||[]).map(e=>(0,j.jsxs)(`a`,{className:`side-item`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:[`#`,e.number,` `,e.title]},e.number))]}),a.notYet&&(0,j.jsx)(`p`,{className:`muted small side-note`,children:a.notYet})]}),(0,j.jsxs)(`section`,{className:`content`,children:[(0,j.jsx)($t,{build:a.build}),(0,j.jsxs)(`div`,{className:`toolbar`,children:[(0,j.jsx)(`h2`,{children:r===``?`All pages`:r===`-`?`Pages`:(a.collections||[]).find(e=>e.name===r)?.title}),(0,j.jsxs)(`span`,{className:`toolbar-actions`,children:[a.canWrite&&(0,j.jsx)(z,{to:{view:`quick`,id:e},className:`button primary`,children:`Quick post`}),a.canWrite&&(0,j.jsx)(tn,{id:e,collections:a.collections,branch:a.branch===a.publishBranch?void 0:a.branch}),a.preview&&(0,j.jsx)(`button`,{type:`button`,className:`button`,onClick:()=>D({view:`present`,id:e,url:a.preview,branch:t}),children:`Present`}),a.preview&&(0,j.jsx)(`a`,{className:`button`,href:a.preview,target:`_blank`,rel:`noopener noreferrer`,children:`Open preview ↗`})]})]}),(0,j.jsxs)(`table`,{className:`pages`,children:[(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{children:`Title`}),(0,j.jsx)(`th`,{children:`Address`}),(0,j.jsx)(`th`,{children:`Date`})]})}),(0,j.jsx)(`tbody`,{children:o.map(n=>(0,j.jsxs)(`tr`,{children:[(0,j.jsxs)(`td`,{children:[(0,j.jsx)(z,{to:{view:`page`,id:e,source:n.source,branch:t},children:n.title}),n.draft&&(0,j.jsx)(`span`,{className:`pill warn`,children:`draft`}),n.redirect&&(0,j.jsx)(`span`,{className:`pill`,children:`redirects`})]}),(0,j.jsx)(`td`,{className:`mono small`,children:n.path}),(0,j.jsx)(`td`,{className:`small`,children:n.date||``})]},n.source))})]})]})]})}function $t({build:e}){let[t,n]=(0,d.useState)(!1);if(e.failed)return(0,j.jsxs)(`div`,{className:`notice bad`,role:`alert`,children:[(0,j.jsx)(`strong`,{children:`This branch doesn't build.`}),` `,e.failed]});let r=e.problems||[];return(0,j.jsxs)(`div`,{className:`notice ${e.errors?`bad`:e.warnings?`warn`:`good`}`,children:[(0,j.jsxs)(`div`,{className:`notice-row`,children:[(0,j.jsxs)(`span`,{children:[e.errors?(0,j.jsxs)(`strong`,{children:[e.errors,` check error`,e.errors===1?``:`s`,`: this can't be published until they're fixed.`]}):(0,j.jsx)(`strong`,{children:`Passes the checks.`}),e.warnings>0&&(0,j.jsxs)(j.Fragment,{children:[` `,e.warnings,` warning`,e.warnings===1?``:`s`,`.`]}),(0,j.jsxs)(`span`,{className:`muted`,children:[` `,e.pages,` pages built from `,e.commit.slice(0,10),`.`]})]}),r.length>0&&(0,j.jsxs)(`button`,{type:`button`,className:`ghost`,"aria-expanded":t,onClick:()=>n(!t),children:[t?`Hide`:`Show`,` details`]})]}),t&&(0,j.jsx)(`ul`,{className:`problems`,children:r.map((e,t)=>(0,j.jsxs)(`li`,{className:e.Level,children:[(0,j.jsx)(`span`,{className:`pill`,children:e.Rule}),` `,(0,j.jsx)(`span`,{className:`mono small`,children:e.File}),` `,e.What,e.Fix&&(0,j.jsx)(`span`,{className:`fix`,children:e.Fix})]},t))})]})}function en({id:e,source:t,branch:n}){let r=Kt(()=>C.site(e,n),[e,n]);return(0,j.jsx)(Ct,{id:e,source:t,branch:n,site:r.data,onSiteChanged:r.reload})}function tn({id:e,collections:t,branch:n}){let[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(``),[s,c]=(0,d.useState)(t?.[0]?.name||``),[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)();if(!r)return(0,j.jsx)(`button`,{type:`button`,className:`button`,onClick:()=>i(!0),children:`New page`});let m=async()=>{u(!0),p(void 0);try{let t=await C.newPage(e,{collection:s,title:a,branch:n});D({view:`page`,id:e,source:t.source,branch:t.branch})}catch(e){p(e.message),u(!1)}};return(0,j.jsxs)(`div`,{className:`newpage form`,children:[(0,j.jsxs)(`label`,{children:[`In`,(0,j.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),children:[(t||[]).map(e=>(0,j.jsx)(`option`,{value:e.name,children:e.title},e.name)),(0,j.jsx)(`option`,{value:``,children:`Pages (top level)`})]})]}),(0,j.jsxs)(`label`,{children:[`Title`,(0,j.jsx)(`input`,{value:a,autoFocus:!0,onChange:e=>o(e.target.value),onKeyDown:e=>e.key===`Enter`&&a.trim()&&m()})]}),(0,j.jsxs)(`div`,{className:`actions`,children:[(0,j.jsx)(`button`,{type:`button`,className:`button primary`,disabled:l||!a.trim(),onClick:m,children:n?`Add the page`:`Start a draft`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>i(!1),children:`Cancel`})]}),f&&(0,j.jsx)(`p`,{className:`notice bad`,children:f})]})}function nn({session:e}){let t=O(),n=`id`in t?t.id:void 0,r=`branch`in t?t.branch:void 0,i=e=>()=>{try{e===`auto`?localStorage.removeItem(`hotdog-theme`):localStorage.setItem(`hotdog-theme`,e)}catch{}e===`auto`?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e};return Ce(()=>[{id:`go-sites`,title:`All sites`,group:`Go to`,run:()=>D({view:`sites`})},...n?[{id:`go-site`,title:`This site's pages`,group:`Go to`,run:()=>D({view:`site`,id:n,branch:r})},{id:`go-files`,title:`Files`,group:`Go to`,run:()=>D({view:`files`,id:n,branch:r})},{id:`go-pictures`,title:`Pictures`,group:`Go to`,run:()=>D({view:`media`,id:n,branch:r})},{id:`go-look`,title:`Look`,group:`Go to`,run:()=>D({view:`look`,id:n,branch:r})},{id:`go-history`,title:`History (undo a published change)`,group:`Go to`,run:()=>D({view:`history`,id:n})},{id:`quick-banner`,title:`Quick post: banner or alert`,group:`Post`,run:()=>D({view:`quick`,id:n,kind:`banner`})},{id:`quick-post`,title:`Quick post: news post`,group:`Post`,run:()=>D({view:`quick`,id:n,kind:`post`})},{id:`quick-event`,title:`Quick post: event`,group:`Post`,run:()=>D({view:`quick`,id:n,kind:`event`})},{id:`quick-home`,title:`Quick post: front page`,group:`Post`,run:()=>D({view:`quick`,id:n,kind:`home`})},{id:`go-forms`,title:`Forms and submissions`,group:`Go to`,run:()=>D({view:`forms`,id:n,branch:r})},{id:`go-redirects`,title:`Redirects`,group:`Go to`,run:()=>D({view:`redirects`,id:n,branch:r})},{id:`go-search`,title:`Search engines (verification, IndexNow)`,group:`Go to`,run:()=>D({view:`search`,id:n,branch:r})},{id:`go-privacy`,title:`Privacy and statistics (analytics)`,group:`Go to`,run:()=>D({view:`privacy`,id:n,branch:r})}]:[],{id:`console-open`,title:`Open the console`,group:`Editor`,keys:"Ctrl+`",run:Oe},{id:`theme-light`,title:`Light theme`,group:`Editor`,run:i(`light`)},{id:`theme-dark`,title:`Dark theme`,group:`Editor`,run:i(`dark`)},{id:`theme-auto`,title:`Automatic theme`,group:`Editor`,run:i(`auto`)},...e.forges.map(t=>({id:`add-${t.host}`,title:`Add an account: ${be(t.kind)} · ${t.host}`,group:`Accounts`,run:()=>{location.href=w(t.host,location.pathname+location.search,e.accounts.some(e=>e.forge===t.host))}}))]),null}(0,f.createRoot)(document.getElementById(`root`)).render((0,j.jsx)(d.StrictMode,{children:(0,j.jsx)(qt,{})}));export{i as n,n as r,A as t}; \ No newline at end of file +`).length;n.scrollTop=Math.max(0,(o-3)*parseFloat(getComputedStyle(n).lineHeight||`20`))};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[Xe,ge,me,f]),(0,d.useEffect)(()=>Qe(ge),[ge,k]),Ee(`mod+s`,()=>ke&&!T&&Re&&He(),!!a),Ce(()=>a?[...Re&&ke?[{id:`page-save`,title:Le?`Save`:`Save as draft`,group:`Page`,keys:`Ctrl+S`,run:He}]:[],...Re?[{id:`page-picture`,title:`Insert picture`,group:`Page`,run:()=>de({})}]:[],{id:`page-mode`,title:me===`visual`?`Edit the body as Markdown`:`Edit the body visually`,group:`Page`,run:()=>L(me===`visual`?`markdown`:`visual`)},...k?[{id:`page-point`,title:ge?`Stop pointing in the preview`:`Point and edit: click text in the preview`,group:`Page`,run:()=>_e(!ge)}]:[],{id:`page-yaml`,title:g?`Edit front matter as fields`:`Edit front matter as YAML`,group:`Page`,run:()=>_(!g)},...Le&&!Ie&&Re&&!ke?[{id:`page-review`,title:`Submit for review`,group:`Page`,run:()=>oe(!0)}]:[],...Le&&Ie&&Re&&!ke?[{id:`page-publish`,title:`Publish`,group:`Page`,run:Ye}]:[],...Be&&!ke?[{id:`page-share`,title:`Share this page`,group:`Page`,run:()=>w(!0)}]:[],...k?[{id:`page-present`,title:`Present in a new tab`,group:`Page`,run:()=>window.open(E({view:`present`,id:e,url:k,branch:n}),`_blank`,`noopener`)}]:[],{id:`page-file`,title:`Edit ${t} as a raw file`,group:`Page`,run:()=>D({view:`files`,id:e,branch:n,path:t})}]:[]),s)return(0,j.jsx)(`div`,{className:`pad notice bad`,role:`alert`,children:s});if(!a||!l)return(0,j.jsx)(`p`,{className:`pad muted`,children:`Loading the page…`});let $e=Object.keys(a.frontMatter).filter(e=>!_t.includes(e)&&!(e===`sections`&&fe)),tt=e=>t=>u({...l,[e]:t.target.type===`checkbox`?!!t.target.checked:t.target.value});return(0,j.jsx)(Ve,{left:(0,j.jsxs)(`section`,{className:`editor-pane`,children:[(0,j.jsxs)(`div`,{className:`pane-head`,children:[(0,j.jsxs)(`a`,{className:`back`,href:`/sites/${encodeURIComponent(e)}${n?`?branch=${encodeURIComponent(n)}`:``}`,onClick:t=>{t.preventDefault(),D({view:`site`,id:e,branch:n})},children:[`← `,r?.name||`Site`]}),(0,j.jsxs)(`span`,{className:`pane-pills`,children:[r&&r.accounts.length>1&&(0,j.jsxs)(`span`,{className:`pill`,title:`Change it in the site view`,children:[`as @`,r.as.split(`/`).pop()]}),(0,j.jsx)(`span`,{className:`pill ${Le?`warn`:``}`,children:Le?`draft: ${Te}`:`${Te} · published`})]})]}),(0,j.jsx)(`h1`,{children:l.title||t}),(0,j.jsxs)(`p`,{className:`muted mono small`,children:[t,Ne?` → ${Ne}`:``,Re&&ve===void 0&&t!==`content/index.md`&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small move-btn`,onClick:()=>ye(Ne||``),children:`Move…`})]}),ve!==void 0&&(0,j.jsx)(Tt,{id:e,source:t,branch:Te,baseCommit:a.commit,current:Ne||``,value:ve,dirty:ke,onChange:ye,onDone:t=>{ye(void 0),x({kind:`good`,text:`Moved to ${t.to}${t.redirected?`; ${t.from} now redirects there`:``}.${t.created?` On a new draft, ${t.branch}.`:``}`}),i(),D({view:`page`,id:e,source:t.source,branch:t.branch})}}),(0,j.jsxs)(`div`,{className:`actions`,children:[(0,j.jsx)(`button`,{type:`button`,className:`button primary`,disabled:!ke||T||!Re,onClick:He,children:Le?`Save`:`Save as draft`}),Le&&!Ie&&(0,j.jsx)(`button`,{type:`button`,className:`button`,disabled:T||ke||!Re,onClick:()=>oe(!F),children:`Submit for review`}),Le&&Ie&&(0,j.jsxs)(`a`,{className:`button`,href:Ie.url,target:`_blank`,rel:`noopener noreferrer`,children:[`Review #`,Ie.number,` ↗`]}),Le&&Ie&&(0,j.jsx)(`button`,{type:`button`,className:`button`,disabled:T||ke||!Re,onClick:Ye,title:`Merges the review, if the draft passes the checks`,children:`Publish`}),Be&&!S&&(0,j.jsx)(`button`,{type:`button`,className:`ghost`,disabled:ke,onClick:()=>w(!0),title:`Post a link to this page on Mastodon, Bluesky or LinkedIn`,children:`Share…`}),!Re&&(0,j.jsx)(`span`,{className:`muted small`,children:`Read only: the platform doesn't let you change this site.`}),ke&&(0,j.jsx)(`span`,{className:`muted small`,children:`Unsaved changes`})]}),b&&(0,j.jsx)(`p`,{className:`notice ${b.kind}`,role:`status`,children:b.text}),ce&&ce.length>0&&(0,j.jsx)(`ul`,{className:`problems`,children:ce.filter(e=>e.Level===`error`).map((e,t)=>(0,j.jsxs)(`li`,{className:`error`,children:[(0,j.jsx)(`span`,{className:`pill`,children:e.Rule}),` `,(0,j.jsx)(`span`,{className:`mono small`,children:e.File}),` `,e.What]},t))}),S&&Be&&(0,j.jsx)(lt,{title:t===`content/index.md`&&r?.siteName||l.title,summary:l.summary,url:ze,onClose:()=>w(!1)}),F&&(0,j.jsx)(wt,{id:e,branch:Te,title:l.title,onDone:e=>{oe(!1),x({kind:`good`,text:e}),i()},onError:e=>x({kind:`bad`,text:e})}),Fe.length>0&&(0,j.jsxs)(`div`,{className:`notice warn`,children:[(0,j.jsx)(`strong`,{children:`Checks on this page`}),(0,j.jsx)(`ul`,{className:`problems`,children:Fe.map((e,t)=>(0,j.jsxs)(`li`,{className:e.Level,children:[(0,j.jsx)(`span`,{className:`pill`,children:e.Rule}),` `,e.What,e.Fix&&(0,j.jsx)(`span`,{className:`fix`,children:e.Fix})]},t))})]}),R&&(0,j.jsx)(et,{id:e,branch:Te,seo:R.seo,siteURL:R.siteURL,path:R.path}),(0,j.jsxs)(`div`,{className:`fm-head`,children:[(0,j.jsx)(`h2`,{className:`side-label`,children:`Front matter`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>_(!g),children:g?`Edit as fields`:`Edit as YAML`})]}),g?(0,j.jsx)(`textarea`,{className:`code`,rows:10,value:v,onChange:e=>y(e.target.value),spellCheck:!1,"aria-label":`Front matter as YAML`}):(0,j.jsxs)(`div`,{className:`form`,children:[(0,j.jsxs)(`label`,{children:[`Title`,(0,j.jsx)(`input`,{value:l.title,onChange:tt(`title`)})]}),(0,j.jsxs)(`label`,{children:[`Summary`,(0,j.jsx)(`textarea`,{rows:2,value:l.summary,onChange:tt(`summary`)})]}),(0,j.jsxs)(`div`,{className:`row2`,children:[(0,j.jsxs)(`label`,{children:[`Date`,(0,j.jsx)(`input`,{type:`date`,value:l.date,onChange:tt(`date`)})]}),(0,j.jsxs)(`label`,{children:[`Publish at`,(0,j.jsx)(`input`,{type:`datetime-local`,value:l.publish_at,onChange:tt(`publish_at`)})]})]}),(0,j.jsxs)(`label`,{children:[`Tags `,(0,j.jsx)(`span`,{className:`muted small`,children:`comma-separated`}),(0,j.jsx)(`input`,{value:l.tags,onChange:tt(`tags`)})]}),(0,j.jsxs)(`div`,{className:`row2`,children:[(0,j.jsxs)(`label`,{children:[`Image`,(0,j.jsx)(`input`,{value:l.image,onChange:tt(`image`),placeholder:`/img/…`})]}),(0,j.jsxs)(`label`,{children:[`Image alt text`,(0,j.jsx)(`input`,{value:l.image_alt,onChange:tt(`image_alt`)})]})]}),(0,j.jsxs)(`label`,{className:`check`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:l.draft,onChange:tt(`draft`)}),` Keep out of the published site (draft)`]}),$e.length>0&&(0,j.jsxs)(`p`,{className:`muted small`,children:[`Other fields (`,$e.join(`, `),`) are kept as they are; edit them as YAML.`]})]}),fe&&!g&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`h2`,{className:`side-label`,children:[`Sections `,(0,j.jsx)(`span`,{className:`muted small`,children:`the page, top to bottom`})]}),(0,j.jsx)(se,{id:e,branch:Te,value:fe,onChange:pe,disabled:!Re,upload:Je})]}),(0,j.jsxs)(`div`,{className:`body-head`,children:[(0,j.jsx)(`h2`,{className:`side-label`,children:`Body`}),(0,j.jsxs)(`div`,{className:`seg small`,role:`group`,"aria-label":`Edit the body as`,children:[(0,j.jsx)(`button`,{type:`button`,"aria-pressed":me===`markdown`,onClick:()=>L(`markdown`),children:`Markdown`}),(0,j.jsx)(`button`,{type:`button`,"aria-pressed":me===`visual`,onClick:()=>L(`visual`),children:`Visual`})]}),Re&&me===`markdown`&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>de({}),children:`Insert picture`})]}),me===`visual`&&(0,j.jsx)(d.Suspense,{fallback:(0,j.jsx)(`p`,{className:`muted small`,children:`Loading the visual editor…`}),children:(0,j.jsx)(gt,{ref:he,value:f,onChange:p,onPicture:e=>de({file:e}),disabled:!Re})}),me===`markdown`&&(0,j.jsx)(`textarea`,{ref:xe,className:`code body-edit`,value:f,onChange:e=>p(e.target.value),onDragOver:e=>Re&&e.dataTransfer.types.includes(`Files`)&&e.preventDefault(),onDrop:e=>{let t=Array.from(e.dataTransfer.files).find(e=>`image/jpeg,image/png,image/gif,image/webp`.split(`,`).includes(e.type));t&&Re&&(e.preventDefault(),de({file:t}))},onPaste:e=>{let t=Array.from(e.clipboardData.files).find(e=>`image/jpeg,image/png,image/gif,image/webp`.split(`,`).includes(e.type));t&&Re&&(e.preventDefault(),de({file:t}))},spellCheck:!0,"aria-label":`Page body, Markdown`}),ue&&(0,j.jsx)(te,{id:e,branch:Te,baseCommit:a.commit,source:t,onDraft:Le,file:ue.file,onUploaded:e=>we.current=e,onInsert:Ke,onClose:()=>de(void 0)})]}),right:(0,j.jsxs)(`section`,{className:`preview-pane`,"aria-label":`Preview`,children:[(0,j.jsxs)(`div`,{className:`preview-bar`,children:[(0,j.jsx)(We,{device:ie,onChange:ae}),(0,j.jsx)(`span`,{className:`spacer`}),k&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,"aria-pressed":ge,onClick:()=>_e(!ge),title:`Click text in the preview to put the cursor there`,children:`Point & edit`}),k&&(0,j.jsx)(`a`,{className:`ghost small linkbtn`,href:E({view:`present`,id:e,url:k,branch:n}),target:`_blank`,rel:`noopener`,children:`Present ↗`}),k&&(0,j.jsx)(`a`,{className:`ghost small linkbtn`,href:k,target:`_blank`,rel:`noopener noreferrer`,children:`Open ↗`})]}),ee&&(0,j.jsx)(`p`,{className:`notice warn small preview-note`,children:ee}),(0,j.jsx)(Ge,{src:k,device:ie,title:`Preview of ${l.title}`,reloadKey:N})]})})}function wt({id:e,branch:t,title:n,onDone:r,onError:i}){let[a,o]=(0,d.useState)(`Update ${n}`),[s,c]=(0,d.useState)(``),[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)(),[m,h]=(0,d.useState)([]);return(0,d.useEffect)(()=>{C.people(e).then(e=>p(e.people),()=>p([]))},[e]),(0,j.jsxs)(`div`,{className:`form review-form`,children:[(0,j.jsxs)(`label`,{children:[`Review title`,(0,j.jsx)(`input`,{value:a,onChange:e=>o(e.target.value)})]}),(0,j.jsxs)(`label`,{children:[`What changed, for the reviewer`,(0,j.jsx)(`textarea`,{rows:3,value:s,onChange:e=>c(e.target.value)})]}),f&&f.length>0&&(0,j.jsxs)(`fieldset`,{className:`field group`,children:[(0,j.jsx)(`legend`,{children:`Ask for a review from`}),(0,j.jsx)(`div`,{className:`reviewer-pick`,children:f.map(e=>(0,j.jsxs)(`label`,{className:`check`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:m.includes(e.login),onChange:t=>h(t.target.checked?[...m,e.login]:m.filter(t=>t!==e.login))}),e.name||e.login,` `,(0,j.jsxs)(`span`,{className:`muted small`,children:[`@`,e.login]})]},e.login))})]}),(0,j.jsx)(`div`,{className:`actions`,children:(0,j.jsx)(`button`,{type:`button`,className:`button primary`,disabled:l||!a.trim(),onClick:async()=>{u(!0);try{let n=await C.review(e,{branch:t,title:a,description:s,reviewers:m}),i=n.reviewers?.length?` ${n.reviewers.map(e=>`@`+e).join(`, `)} ${n.reviewers.length===1?`was`:`were`} asked to review; the platform lets them know.`:``;r(`Submitted for review as #${n.number}.${n.preview?` The review links to this draft's preview.`:``}${i}${n.reviewersError?` `+n.reviewersError:``}`)}catch(e){i(e.message)}finally{u(!1)}},children:`Open the review`})})]})}function Tt({id:e,source:t,branch:n,baseCommit:r,current:i,value:a,dirty:o,onChange:s,onDone:c}){let[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)(),m=`/`+a.trim().replace(/^\/+|\/+$/g,``)+`/`,h=m===`//`?``:`content${m.slice(0,-1)}.md`,g=async()=>{u(!0),p(void 0);try{c(await C.move(e,{branch:n,baseCommit:r,source:t,to:h}))}catch(e){p(e.message)}finally{u(!1)}};return(0,j.jsxs)(`form`,{className:`form move-form`,onSubmit:e=>{e.preventDefault(),h&&!o&&g()},children:[(0,j.jsxs)(`label`,{children:[`New address`,(0,j.jsx)(`input`,{autoFocus:!0,value:a,onChange:e=>s(e.target.value),placeholder:`/about-us/`})]}),h&&(0,j.jsxs)(`p`,{className:`muted small`,children:[`Renames `,(0,j.jsx)(`span`,{className:`mono`,children:t}),` to `,(0,j.jsx)(`span`,{className:`mono`,children:h}),i&&m!==i?(0,j.jsxs)(j.Fragment,{children:[`, and `,(0,j.jsx)(`span`,{className:`mono`,children:i}),` will redirect to `,(0,j.jsx)(`span`,{className:`mono`,children:m})]}):``,`.`]}),o&&(0,j.jsx)(`p`,{className:`notice warn small`,children:`Save your changes first; the move is its own commit.`}),f&&(0,j.jsx)(`p`,{className:`notice bad small`,children:f}),(0,j.jsxs)(`div`,{className:`actions-row`,children:[(0,j.jsx)(`button`,{type:`submit`,className:`button`,disabled:l||!h||o||m===i,children:`Move`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>s(void 0),children:`Cancel`})]})]})}function Et(e){let t=e.replace(`#`,``);if(t.length===3&&(t=t.split(``).map(e=>e+e).join(``)),t.length!==6)return 0;let n=[0,2,4].map(e=>{let n=parseInt(t.slice(e,e+2),16)/255;return n<=.03928?n/12.92:((n+.055)/1.055)**2.4});return .2126*n[0]+.7152*n[1]+.0722*n[2]}function Dt(e,t){let[n,r]=[Et(e),Et(t)].sort((e,t)=>t-e);return Math.round((n+.05)/(r+.05)*100)/100}var Ot=e=>(typeof e==`string`?e:e?.light)||``,kt=e=>(typeof e==`object`&&e?e.dark:``)||``;function At(e,t,n,r){let i=e.tokens.find(e=>e.name===n),a=t[n];return r===`dark`?kt(a)||i.dark||Ot(a)||i.default||`#000000`:Ot(a)||i.default||`#000000`}function jt({id:e,branch:t}){let[n,r]=(0,d.useState)(),[i,a]=(0,d.useState)(),[o,s]=(0,d.useState)({}),[c,l]=(0,d.useState)(),[u,f]=(0,d.useState)(!1),[p,m]=(0,d.useState)(),[h,g]=(0,d.useState)(),[_,v]=(0,d.useState)(0),[y,b]=Ue(),[x,S]=(0,d.useState)(),[w,T]=(0,d.useState)(!1),E=(0,d.useRef)(void 0),O=(0,d.useRef)(void 0),k=async r=>{let i=await C.upload(e,r,{branch:t||n?.branch||``,baseCommit:n?.commit||``,source:`look.md`});return E.current=i,i.url},A=()=>C.look(e,t).then(e=>{r(e);let t=O.current;O.current=void 0,s(t||e.values||{})},e=>a(e.message));(0,d.useEffect)(()=>{A(),C.site(e,t).then(S,()=>void 0)},[e,t]);let ee=t||n?.branch||``,M=x?ee!==x.publishBranch:!1,te=x?.reviews?.find(e=>e.branch===ee),N=n?JSON.stringify(o)!==JSON.stringify(n.values||{}):!1;(0,d.useEffect)(()=>{let t=E.current;t&&(E.current=void 0,l({kind:`good`,text:`Added ${t.url}${t.created?` on a new draft, ${t.branch}`:``}. Save to keep it in the look.`}),t.created||t.branch!==ee?(O.current=o,D({view:`look`,id:e,branch:t.branch})):n&&r({...n,commit:t.commit}))},[o]);let ne=(0,d.useRef)(0);(0,d.useEffect)(()=>{if(n?.look)return window.clearTimeout(ne.current),ne.current=window.setTimeout(()=>{C.lookLive(e,{branch:ee,look:o}).then(e=>{if(e.error)return g(e.error);g(void 0),e.url===p?v(e=>e+1):m(e.url)},e=>g(e.message))},350),()=>window.clearTimeout(ne.current)},[o,n]);let re=(0,d.useMemo)(()=>n?.look?(n.look.contrast||[]).map(([e,t])=>({fg:e,bg:t,light:Dt(At(n.look,o,e,`light`),At(n.look,o,t,`light`)),dark:Dt(At(n.look,o,e,`dark`),At(n.look,o,t,`dark`))})):[],[n,o]),P=re.filter(e=>e.light<(n?.minContrast||4.5)||e.dark<(n?.minContrast||4.5)).length,ie=(e,t)=>s(n=>{let{[e]:r,...i}=n;return t===void 0||t===``?i:{...i,[e]:t}}),ae=async()=>{if(n){f(!0),l({kind:`info`,text:`Saving…`});try{let r=await C.lookSave(e,{branch:ee,baseCommit:n.commit,look:o});l({kind:`good`,text:r.created?`Saved. The new look is on a draft, ${r.branch}; the published site is unchanged.`:`Saved to ${r.branch}.`}),r.created||r.branch!==t?D({view:`look`,id:e,branch:r.branch}):A()}catch(e){l({kind:`bad`,text:`Not saved: ${e.message}`})}finally{f(!1)}}},F=async()=>{f(!0),l({kind:`info`,text:`Checking the draft and publishing…`});try{await C.publish(e,{branch:ee}),l({kind:`good`,text:`Published: the change is merged. The live site updates when its publishing pipeline runs.`}),x&&D({view:`look`,id:e,branch:x.publishBranch})}catch(e){l({kind:`bad`,text:e.message})}finally{f(!1)}};if(Ee(`mod+s`,()=>N&&!u&&n?.canWrite&&ae(),!!n),i)return(0,j.jsx)(`p`,{className:`pad notice bad`,role:`alert`,children:i});if(!n)return(0,j.jsx)(`p`,{className:`pad muted`,children:`Loading the look…`});let oe=(0,j.jsx)(`a`,{className:`back`,href:`/sites/${encodeURIComponent(e)}`,onClick:n=>{n.preventDefault(),D({view:`site`,id:e,branch:t})},children:`← Site`});if(!n.look)return(0,j.jsxs)(`section`,{className:`pad`,children:[oe,(0,j.jsx)(`h1`,{children:`Look`}),(0,j.jsxs)(`p`,{className:`muted`,children:[`This site's theme doesn't say what can be changed: it has no `,(0,j.jsx)(`span`,{className:`mono`,children:`look.yaml`}),`. A developer adds one to offer colors, fonts and a logo here.`]})]});let se=n.canWrite;return(0,j.jsx)(Ve,{left:(0,j.jsxs)(`section`,{className:`editor-pane`,children:[(0,j.jsxs)(`div`,{className:`pane-head`,children:[oe,(0,j.jsx)(`span`,{className:`pill ${M?`warn`:``}`,children:M?`draft: ${ee}`:`${ee} · published`})]}),(0,j.jsx)(`h1`,{children:`Look`}),(0,j.jsx)(`p`,{className:`muted small`,children:`What this site's theme lets change. The preview shows the home page as you pick.`}),(0,j.jsxs)(`div`,{className:`actions-row`,children:[(0,j.jsx)(`button`,{type:`button`,className:`button primary`,disabled:!N||u||!se,onClick:ae,children:M?`Save`:`Save as draft`}),M&&!te&&(0,j.jsx)(`button`,{type:`button`,className:`button`,disabled:u||N||!se,onClick:()=>T(!w),children:`Submit for review`}),M&&te&&(0,j.jsxs)(`a`,{className:`button`,href:te.url,target:`_blank`,rel:`noopener noreferrer`,children:[`Review #`,te.number,` ↗`]}),M&&te&&(0,j.jsx)(`button`,{type:`button`,className:`button`,disabled:u||N||!se,onClick:F,children:`Publish`}),N&&(0,j.jsx)(`span`,{className:`muted small`,children:`Unsaved changes`}),!se&&(0,j.jsx)(`span`,{className:`muted small`,children:`Read only: the platform doesn't let you change this site.`})]}),c&&(0,j.jsx)(`p`,{className:`notice ${c.kind}`,role:`status`,children:c.text}),w&&(0,j.jsx)(wt,{id:e,branch:ee,title:`the look`,onDone:n=>{T(!1),l({kind:`good`,text:n}),C.site(e,t).then(S)},onError:e=>l({kind:`bad`,text:e})}),(0,j.jsxs)(`div`,{className:`notice ${P?`bad`:`good`}`,children:[(0,j.jsx)(`strong`,{children:P?`${P} pair${P===1?``:`s`} too hard to read: this can't be published until fixed.`:`Every pair is readable.`}),(0,j.jsxs)(`table`,{className:`contrast`,children:[(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{children:`Text`}),(0,j.jsx)(`th`,{children:`On`}),(0,j.jsx)(`th`,{children:`Light`}),(0,j.jsx)(`th`,{children:`Dark`})]})}),(0,j.jsx)(`tbody`,{children:re.map(e=>(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`td`,{children:Mt(n.look,e.fg)}),(0,j.jsx)(`td`,{children:Mt(n.look,e.bg)}),[e.light,e.dark].map((e,t)=>(0,j.jsxs)(`td`,{className:e(0,j.jsx)(Nt,{t,value:o[t.name],onChange:e=>ie(t.name,e),id:e,branch:ee,disabled:!se,upload:k},t.name))})]}),right:(0,j.jsxs)(`section`,{className:`preview-pane`,"aria-label":`Preview`,children:[(0,j.jsx)(`div`,{className:`preview-bar`,children:(0,j.jsx)(We,{device:y,onChange:b})}),h&&(0,j.jsx)(`p`,{className:`notice warn small preview-note`,children:h}),(0,j.jsx)(Ge,{src:p,device:y,title:`Preview of the look`,reloadKey:_})]})})}function Mt(e,t){return e.tokens.find(e=>e.name===t)?.label||t}function Nt({t:e,value:t,onChange:n,id:r,branch:i,disabled:a,upload:o}){let s=t!==void 0&&!a&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>n(void 0),children:`Use the theme's`}),c=e.help&&(0,j.jsx)(`span`,{className:`muted small`,children:e.help});switch(e.type){case`color`:{let r=Ot(t),i=kt(t),o=(t,r)=>n(r?{light:t||e.default,dark:r}:t||void 0);return(0,j.jsxs)(`fieldset`,{className:`field group token`,children:[(0,j.jsxs)(`legend`,{children:[e.label||e.name,` `,s]}),c,(0,j.jsxs)(`div`,{className:`color-row`,children:[(0,j.jsxs)(`label`,{className:`color-pick`,children:[(0,j.jsx)(`input`,{type:`color`,value:r||e.default,disabled:a,onChange:e=>o(e.target.value,i),"aria-label":`${e.label}, light`}),(0,j.jsx)(`span`,{className:`mono small`,children:r||`${e.default} (theme)`})]}),(0,j.jsxs)(`label`,{className:`check small`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:!!i,disabled:a,onChange:t=>o(r,t.target.checked?e.dark||r||e.default||`#000000`:``)}),` Different in dark mode`]}),i&&(0,j.jsxs)(`label`,{className:`color-pick`,children:[(0,j.jsx)(`input`,{type:`color`,value:i,disabled:a,onChange:e=>o(r,e.target.value),"aria-label":`${e.label}, dark`}),(0,j.jsxs)(`span`,{className:`mono small`,children:[i,` (dark)`]})]}),!i&&e.dark&&(0,j.jsxs)(`span`,{className:`muted small`,children:[`Dark mode: `,e.dark,` (theme)`]})]})]})}case`font`:case`select`:return(0,j.jsxs)(`label`,{className:`field token`,children:[(0,j.jsxs)(`span`,{className:`field-label`,children:[e.label||e.name,` `,s]}),(0,j.jsxs)(`select`,{value:Ot(t),disabled:a,onChange:e=>n(e.target.value||void 0),children:[(0,j.jsxs)(`option`,{value:``,children:[`The theme's (`,e.default,`)`]}),(e.options||[]).map(t=>(0,j.jsx)(`option`,{value:t.name,style:e.type===`font`?{fontFamily:t.value}:void 0,children:t.name},t.name))]}),c]});case`image`:return(0,j.jsx)(ue,{f:{name:e.name,label:e.label,type:`image`},label:(0,j.jsxs)(`span`,{className:`field-label`,children:[e.label||e.name,` `,s]}),help:c,value:Ot(t),onChange:e=>n(e||void 0),ctx:{id:r,branch:i,lib:{sections:[],data:[],collections:[]},upload:o},disabled:a})}}var Pt=()=>void 0,Ft=()=>Pt();function It(){let[e,t]=(0,d.useState)(!1),[n,r]=(0,d.useState)(``),[i,a]=(0,d.useState)(0),[o,s]=(0,d.useState)([]),c=(0,d.useRef)(null),l=(0,d.useRef)(null),u=()=>{s(we()),r(``),a(0),t(!0)};Pt=u,Ee(`mod+k`,()=>e?t(!1):u()),(0,d.useEffect)(()=>{e?c.current?.showModal():c.current?.open&&c.current.close()},[e]);let f=(0,d.useMemo)(()=>{let e=o.map(e=>({c:e,s:Math.max(Te(n,e.title),Te(n,`${e.group} ${e.title}`)-50)})).filter(e=>e.s>=0);return n.trim()&&e.sort((e,t)=>t.s-e.s),e.slice(0,60).map(e=>e.c)},[o,n]);(0,d.useEffect)(()=>{l.current?.querySelector(`[aria-selected="true"]`)?.scrollIntoView({block:`nearest`})},[i]);let p=e=>{t(!1),setTimeout(e.run,0)};return(0,j.jsx)(`dialog`,{ref:c,className:`palette`,"aria-label":`Command palette`,onClose:()=>t(!1),children:e&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`input`,{autoFocus:!0,className:`palette-input`,placeholder:`Type a command or a page…`,value:n,role:`combobox`,"aria-expanded":`true`,"aria-controls":`palette-list`,"aria-activedescendant":f[i]?`cmd-${i}`:void 0,onChange:e=>{r(e.target.value),a(0)},onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),a(e=>Math.min(e+1,f.length-1))):e.key===`ArrowUp`?(e.preventDefault(),a(e=>Math.max(e-1,0))):e.key===`Enter`&&f[i]&&(e.preventDefault(),p(f[i]))}}),(0,j.jsxs)(`ul`,{id:`palette-list`,role:`listbox`,ref:l,className:`palette-list`,children:[f.length===0&&(0,j.jsx)(`li`,{className:`muted small palette-empty`,children:`Nothing matches.`}),f.map((e,t)=>(0,j.jsxs)(`li`,{id:`cmd-${t}`,role:`option`,"aria-selected":t===i,className:t===i?`on`:``,onMouseMove:()=>a(t),onClick:()=>p(e),children:[(0,j.jsx)(`span`,{className:`muted small palette-group`,children:e.group}),(0,j.jsx)(`span`,{className:`palette-title`,children:e.title}),e.keys&&(0,j.jsx)(`kbd`,{children:e.keys})]},e.id))]}),(0,j.jsx)(`p`,{className:`palette-foot muted small`,children:"↑↓ to move · Enter to run · Esc to close · Ctrl+` opens the console"})]})})}var Lt=[{id:``,label:`None`,about:`No visit statistics.`},{id:`plausible`,label:`Plausible`,about:`Counts visits without cookies; hosted or self-hosted.`},{id:`matomo`,label:`Matomo`,about:`Self-hosted statistics.`},{id:`ga4`,label:`Google Analytics`,about:`Google Analytics 4. Visitors’ data goes to Google.`}];function Rt({id:e,branch:t}){let[n,r]=(0,d.useState)(),[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)({}),[c,l]=(0,d.useState)(),[u,f]=(0,d.useState)(!1),p=()=>C.privacy(e,t).then(e=>{a(e.analytics),s(e.privacy),r({commit:e.commit,branch:e.branch,canWrite:e.canWrite,start:JSON.stringify([e.analytics,e.privacy])})},e=>l({kind:`bad`,text:e.message}));(0,d.useEffect)(()=>{p()},[e,t]);let m=!!n&&JSON.stringify([i,o])!==n.start,h=!i||i.gated!==!1,g=(e,t,r,o)=>(0,j.jsxs)(`label`,{className:`field`,children:[t,(0,j.jsx)(`input`,{value:i?.[e]||``,placeholder:r,disabled:!n?.canWrite,onChange:t=>a({...i,[e]:t.target.value})}),o&&(0,j.jsx)(`span`,{className:`muted small`,children:o})]});return(0,j.jsxs)(`section`,{className:`pad privacy-view`,children:[(0,j.jsx)(`a`,{className:`back`,href:`/sites/${encodeURIComponent(e)}`,onClick:n=>{n.preventDefault(),D({view:`site`,id:e,branch:t})},children:`← Site`}),(0,j.jsx)(`h1`,{children:`Privacy and statistics`}),(0,j.jsx)(`p`,{className:`muted`,children:`What the site counts, and who answers for visitors' data. The privacy notice at /privacy/ is written from these settings every time the site is built.`}),c&&(0,j.jsx)(`p`,{className:`notice ${c.kind}`,role:`status`,children:c.text}),n&&(0,j.jsxs)(`div`,{className:`form wizard`,children:[(0,j.jsxs)(`fieldset`,{className:`field group`,children:[(0,j.jsx)(`legend`,{children:`Visit statistics`}),(0,j.jsx)(`div`,{className:`provider-pick`,role:`radiogroup`,"aria-label":`Statistics`,children:Lt.map(e=>(0,j.jsxs)(`label`,{className:`provider ${(i?.provider||``)===e.id?`on`:``}`,children:[(0,j.jsx)(`input`,{type:`radio`,name:`provider`,checked:(i?.provider||``)===e.id,disabled:!n.canWrite,onChange:()=>a(e.id?{provider:e.id,gated:i?.gated}:null)}),(0,j.jsx)(`strong`,{children:e.label}),(0,j.jsx)(`span`,{className:`muted small`,children:e.about})]},e.id))}),i?.provider===`plausible`&&(0,j.jsxs)(j.Fragment,{children:[g(`domain`,`Site domain in Plausible`,`example.org`),g(`src`,`Script address (if self-hosted)`,`https://plausible.io/js/script.js`,`Leave empty for plausible.io.`)]}),i?.provider===`matomo`&&(0,j.jsxs)(j.Fragment,{children:[g(`url`,`Matomo address`,`https://matomo.example.org/`),g(`siteId`,`Site ID`,`1`)]}),i?.provider===`ga4`&&g(`id`,`Measurement ID`,`G-XXXXXXX`),i&&(0,j.jsxs)(`label`,{className:`check field`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:h,disabled:!n.canWrite,onChange:e=>a({...i,gated:e.target.checked?void 0:!1,adConversions:e.target.checked?i.adConversions:void 0})}),`Ask visitors first (recommended)`]}),i?.provider===`ga4`&&h&&(0,j.jsxs)(`label`,{className:`check field`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:!!i.adConversions,disabled:!n.canWrite,onChange:e=>a({...i,adConversions:e.target.checked||void 0})}),`Also measure the site's Google ads`,(0,j.jsx)(`span`,{className:`muted small`,children:`For visitors who accept: whether a visit from one of your ads went on to sign up or buy. The banner and the privacy notice say so. Ad personalization stays off.`})]}),i&&h&&(0,j.jsx)(`p`,{className:`muted small`,children:`A banner asks on the first visit, with Decline first and as prominent as Accept. Nothing is counted until someone accepts; declining later removes the counter's cookies.`}),i&&!h&&(0,j.jsx)(`p`,{className:`notice warn small`,children:`Statistics will start on page view, without asking. That's recorded in site.yaml (gated: false), the privacy notice says so, and every check warns about it. In much of the world, counting with cookies needs consent.`})]}),(0,j.jsxs)(`fieldset`,{className:`field group`,children:[(0,j.jsx)(`legend`,{children:`Who answers for visitors' data`}),(0,j.jsxs)(`label`,{className:`field`,children:[`Person or organization`,(0,j.jsx)(`input`,{value:o.controller||``,disabled:!n.canWrite,placeholder:`Your name, or your company`,onChange:e=>s({...o,controller:e.target.value})})]}),(0,j.jsxs)(`label`,{className:`field`,children:[`Email to write to`,(0,j.jsx)(`input`,{value:o.contact||``,disabled:!n.canWrite,placeholder:`privacy@example.org`,onChange:e=>s({...o,contact:e.target.value})})]}),(0,j.jsxs)(`label`,{className:`field`,children:[`Last changed`,(0,j.jsx)(`input`,{value:o.updated||``,disabled:!n.canWrite,placeholder:`10 October 2026`,onChange:e=>s({...o,updated:e.target.value})})]})]}),n.canWrite&&(0,j.jsx)(`div`,{className:`actions-row`,children:(0,j.jsx)(`button`,{type:`button`,className:`button primary`,disabled:!m||u,onClick:async()=>{if(n){f(!0),l({kind:`info`,text:`Saving…`});try{let r=await C.privacySave(e,{branch:n.branch,baseCommit:n.commit,analytics:i,privacy:o});l({kind:`good`,text:`Saved on ${r.created?`a new draft, ${r.branch}`:r.branch}. Its preview's /privacy/ page shows the new list.`}),r.created||r.branch!==t?D({view:`privacy`,id:e,branch:r.branch}):p()}catch(e){l({kind:`bad`,text:e.message})}finally{f(!1)}}},children:n.branch===t?`Save`:`Save as draft`})})]})]})}function zt({id:e,branch:t}){let[n,r]=(0,d.useState)(),[i,a]=(0,d.useState)(),[o,s]=(0,d.useState)(),[c,l]=(0,d.useState)(!1),u=()=>C.redirects(e,t).then(e=>{a({rows:e.redirects,commit:e.commit,branch:e.branch,canWrite:e.canWrite}),r(e.redirects.map(e=>({...e})))},e=>s({kind:`bad`,text:e.message}));(0,d.useEffect)(()=>{u()},[e,t]);let f=!!i&&JSON.stringify(n)!==JSON.stringify(i.rows),p=(e,t,n)=>r(r=>r.map((r,i)=>i===e?{...r,[t]:n}:r));return(0,j.jsxs)(`section`,{className:`pad redirects`,children:[(0,j.jsx)(`a`,{className:`back`,href:`/sites/${encodeURIComponent(e)}`,onClick:n=>{n.preventDefault(),D({view:`site`,id:e,branch:t})},children:`← Site`}),(0,j.jsx)(`h1`,{children:`Redirects`}),(0,j.jsx)(`p`,{className:`muted`,children:`Old addresses that should keep working. Moving a page adds its redirect by itself; add others here, for a page that's gone or a link printed somewhere.`}),o&&(0,j.jsx)(`p`,{className:`notice ${o.kind}`,role:`status`,children:o.text}),!n&&!o&&(0,j.jsx)(`p`,{className:`muted`,children:`Reading site.yaml…`}),n&&(0,j.jsxs)(`div`,{className:`form`,children:[(0,j.jsxs)(`table`,{className:`pages redirect-table`,children:[(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{children:`Old address`}),(0,j.jsx)(`th`,{children:`Goes to`}),(0,j.jsx)(`th`,{})]})}),(0,j.jsxs)(`tbody`,{children:[n.map((e,t)=>(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`td`,{children:(0,j.jsx)(`input`,{value:e.from,placeholder:`/old-page/`,disabled:!i?.canWrite,onChange:e=>p(t,`from`,e.target.value),"aria-label":`Old address ${t+1}`})}),(0,j.jsx)(`td`,{children:(0,j.jsx)(`input`,{value:e.to,placeholder:`/new-page/ or https://…`,disabled:!i?.canWrite,onChange:e=>p(t,`to`,e.target.value),"aria-label":`Goes to ${t+1}`})}),(0,j.jsx)(`td`,{children:i?.canWrite&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>r(n.filter((e,n)=>n!==t)),children:`Remove`})})]},t)),n.length===0&&(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:3,className:`muted small`,children:`No redirects.`})})]})]}),i?.canWrite&&(0,j.jsxs)(`div`,{className:`actions-row`,children:[(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>r([...n,{from:``,to:``}]),children:`Add a redirect`}),(0,j.jsx)(`button`,{type:`button`,className:`button primary`,disabled:!f||c,onClick:async()=>{if(i&&n){l(!0),s({kind:`info`,text:`Saving…`});try{let r=await C.redirectsSave(e,{branch:i.branch,baseCommit:i.commit,redirects:n.filter(e=>e.from.trim()||e.to.trim())});s({kind:`good`,text:`Saved on ${r.created?`a new draft, ${r.branch}`:r.branch}.`}),r.created||r.branch!==t?D({view:`redirects`,id:e,branch:r.branch}):u()}catch(e){s({kind:`bad`,text:e.message})}finally{l(!1)}}},children:i.branch===t?`Save`:`Save as draft`})]})]})]})}var Bt=[{k:`google`,name:`Google Search Console`,where:`Add a property for the site, choose "HTML tag", and copy the content="…" value (or the whole tag; the code is taken out of it).`},{k:`bing`,name:`Bing Webmaster Tools`,where:`Add the site, choose "HTML Meta Tag", and copy the content value of msvalidate.01.`},{k:`yandex`,name:`Yandex Webmaster`,where:`Add the site, choose "Meta tag", and copy the content value.`}];function Vt(){let e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}function Ht({id:e,branch:t}){let[n,r]=(0,d.useState)(),[i,a]=(0,d.useState)({}),[o,s]=(0,d.useState)(``),[c,l]=(0,d.useState)(),[u,f]=(0,d.useState)(!1),p=()=>C.search(e,t).then(e=>{let t={google:e.verify.google||``,bing:e.verify.bing||``,yandex:e.verify.yandex||``};a(t),s(e.indexnow||``),r({commit:e.commit,branch:e.branch,canWrite:e.canWrite,sitemap:e.sitemap,siteURL:e.siteURL,start:JSON.stringify([t,e.indexnow||``])})},e=>l({kind:`bad`,text:e.message}));(0,d.useEffect)(()=>{p()},[e,t]);let m=!!n&&JSON.stringify([i,o])!==n.start;return(0,j.jsxs)(`section`,{className:`pad search-view`,children:[(0,j.jsx)(`a`,{className:`back`,href:`/sites/${encodeURIComponent(e)}`,onClick:n=>{n.preventDefault(),D({view:`site`,id:e,branch:t})},children:`← Site`}),(0,j.jsx)(`h1`,{children:`Search engines`}),(0,j.jsx)(`p`,{className:`muted`,children:`Show each search console the site is yours, and tell search engines what changed whenever it's published.`}),c&&(0,j.jsx)(`p`,{className:`notice ${c.kind}`,role:`status`,children:c.text}),n&&(0,j.jsxs)(`div`,{className:`form wizard`,children:[(0,j.jsxs)(`fieldset`,{className:`field group`,children:[(0,j.jsx)(`legend`,{children:`Verification`}),Bt.map(e=>(0,j.jsxs)(`label`,{className:`field`,children:[e.name,(0,j.jsx)(`input`,{value:i[e.k]||``,disabled:!n.canWrite,placeholder:`The code from the meta tag`,onChange:t=>a({...i,[e.k]:t.target.value})}),(0,j.jsx)(`span`,{className:`muted small`,children:e.where})]},e.k)),(0,j.jsxs)(`p`,{className:`muted small`,children:[`The codes become meta tags on the home page. The site's sitemap, to give each console: `,(0,j.jsx)(`span`,{className:`mono`,children:n.sitemap})]})]}),(0,j.jsxs)(`fieldset`,{className:`field group`,children:[(0,j.jsx)(`legend`,{children:`IndexNow`}),(0,j.jsxs)(`p`,{className:`muted small`,children:[`IndexNow tells Bing, Yandex and the other search engines that share it which pages changed, each time the site is published. The key proves the message is the site's own; the build publishes it as `,(0,j.jsxs)(`span`,{className:`mono`,children:[`/`,o||`key`,`.txt`]}),`.`]}),(0,j.jsxs)(`div`,{className:`image-row`,children:[(0,j.jsx)(`input`,{value:o,disabled:!n.canWrite,placeholder:`No key: IndexNow is off`,onChange:e=>s(e.target.value),"aria-label":`IndexNow key`}),n.canWrite&&(0,j.jsx)(`button`,{type:`button`,className:`ghost small`,onClick:()=>s(Vt()),children:o?`New key`:`Make a key`})]}),(0,j.jsxs)(`p`,{className:`muted small`,children:[`Then, on the live site's publish target, set `,(0,j.jsx)(`span`,{className:`mono`,children:`indexnow: true`}),` in publish.yaml (or run the pull agent with `,(0,j.jsx)(`span`,{className:`mono`,children:`-indexnow`}),`). Only that target sends; staging never does.`]})]}),n.canWrite&&(0,j.jsx)(`div`,{className:`actions-row`,children:(0,j.jsx)(`button`,{type:`button`,className:`button primary`,disabled:!m||u,onClick:async()=>{if(n){f(!0),l({kind:`info`,text:`Saving…`});try{let r=await C.searchSave(e,{branch:n.branch,baseCommit:n.commit,verify:i,indexnow:o});l({kind:`good`,text:`Saved on ${r.created?`a new draft, ${r.branch}`:r.branch}. Once it's published, press Verify in each console.`}),r.created||r.branch!==t?D({view:`search`,id:e,branch:r.branch}):p()}catch(e){l({kind:`bad`,text:e.message})}finally{f(!1)}}},children:n.branch===t?`Save`:`Save as draft`})})]})]})}var Ut=`hotdog-theme`;function Wt(){try{let e=localStorage.getItem(Ut);if(e===`light`||e===`dark`)return e}catch{}return`system`}function Gt(){let[e,t]=(0,d.useState)(Wt),n=e=>{t(e),e===`system`?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e;try{e===`system`?localStorage.removeItem(Ut):localStorage.setItem(Ut,e)}catch{}},r={system:`Auto`,light:`Light`,dark:`Dark`};return(0,j.jsx)(`div`,{className:`seg theme-pick`,role:`group`,"aria-label":`Color theme`,children:Object.keys(r).map(t=>(0,j.jsx)(`button`,{type:`button`,"aria-pressed":e===t,title:t===`system`?`Follow the device setting`:`${r[t]} theme`,onClick:()=>n(t),children:r[t]},t))})}function z({to:e,children:t,className:n}){return(0,j.jsx)(`a`,{className:n,href:E(e),onClick:t=>{t.metaKey||t.ctrlKey||t.shiftKey||t.button!==0||(t.preventDefault(),D(e))},children:t})}function Kt(e,t){let[n,r]=(0,d.useState)({loading:!0}),i=(0,d.useCallback)(()=>{r(e=>({...e,loading:!0})),e().then(e=>r({data:e,loading:!1}),e=>r({error:e,loading:!1}))},t);return(0,d.useEffect)(i,[i]),{...n,reload:i}}function qt(){let e=O(),t=Kt(C.session,[]);if(t.loading&&!t.data)return(0,j.jsx)(Jt,{children:(0,j.jsx)(`p`,{className:`muted pad`,children:`Loading…`})});if(t.error)return(0,j.jsx)(Jt,{children:(0,j.jsx)(Yt,{error:t.error})});let n=t.data;return n.signedIn?(0,j.jsxs)(Jt,{session:n,onAccountsChanged:t.reload,children:[e.view===`sites`&&(0,j.jsx)(Zt,{}),e.view===`site`&&(0,j.jsx)(Qt,{id:e.id,branch:e.branch}),e.view===`page`&&(0,j.jsx)(en,{id:e.id,source:e.source,branch:e.branch}),e.view===`present`&&(0,j.jsx)(Xe,{id:e.id,url:e.url,branch:e.branch}),e.view===`media`&&(0,j.jsx)(M,{id:e.id,branch:e.branch}),e.view===`look`&&(0,j.jsx)(jt,{id:e.id,branch:e.branch}),e.view===`files`&&(0,j.jsx)(Pe,{id:e.id,branch:e.branch,path:e.path}),e.view===`redirects`&&(0,j.jsx)(zt,{id:e.id,branch:e.branch}),e.view===`privacy`&&(0,j.jsx)(Rt,{id:e.id,branch:e.branch}),e.view===`search`&&(0,j.jsx)(Ht,{id:e.id,branch:e.branch}),e.view===`forms`&&(0,j.jsx)(Je,{id:e.id,branch:e.branch,form:e.form}),e.view===`history`&&(0,j.jsx)(Ye,{id:e.id}),e.view===`quick`&&(0,j.jsx)(pe,{id:e.id,kind:e.kind})]}):(0,j.jsx)(Xt,{session:n})}function Jt({children:e,session:t,onAccountsChanged:n}){return(0,j.jsxs)(`div`,{className:`app`,children:[(0,j.jsxs)(`header`,{className:`top`,children:[(0,j.jsxs)(z,{to:{view:`sites`},className:`brand`,children:[(0,j.jsx)(`img`,{className:`logo only-light`,src:R,alt:`HotDog CMS`}),(0,j.jsx)(`img`,{className:`logo only-dark`,src:ye,alt:`HotDog CMS`}),(0,j.jsx)(`span`,{className:`brand-sub`,children:`Editor`})]}),(0,j.jsxs)(`div`,{className:`who`,children:[t?.signedIn&&(0,j.jsxs)(`button`,{type:`button`,className:`ghost small kbd-hint`,onClick:Ft,title:`Every action, by name`,children:[`Commands `,(0,j.jsx)(`kbd`,{children:`Ctrl K`})]}),(0,j.jsx)(Gt,{}),t?.signedIn&&n&&(0,j.jsx)(xe,{session:t,onChanged:n})]})]}),(0,j.jsx)(`main`,{id:`main`,children:e}),(0,j.jsx)(ve,{}),t?.signedIn&&(0,j.jsx)(nn,{session:t}),t?.signedIn&&(0,j.jsx)(It,{}),t?.signedIn&&(0,j.jsx)(je,{})]})}function Yt({error:e}){return e instanceof p?(0,j.jsxs)(`div`,{className:`pad`,children:[(0,j.jsx)(`p`,{children:e.message}),(0,j.jsx)(`p`,{children:(0,j.jsx)(`button`,{type:`button`,className:`button`,onClick:()=>location.reload(),children:`Sign in again`})})]}):(0,j.jsx)(`div`,{className:`pad notice bad`,role:`alert`,children:e.message})}function Xt({session:e}){let t=location.pathname+location.search;return(0,j.jsxs)(`div`,{className:`app`,children:[(0,j.jsx)(`div`,{className:`signin`,children:(0,j.jsxs)(`div`,{className:`card`,children:[(0,j.jsx)(`img`,{className:`signin-logo only-light`,src:R,alt:`HotDog CMS`}),(0,j.jsx)(`img`,{className:`signin-logo only-dark`,src:ye,alt:`HotDog CMS`}),(0,j.jsx)(`h1`,{children:`Sign in`}),(0,j.jsx)(`p`,{className:`muted`,children:`With the git platform your sites live on. The editor keeps no accounts of its own: what you can open and change is what the platform already lets you, and every change is made as you.`}),(0,j.jsxs)(`div`,{className:`stack`,children:[e.forges.map(e=>(0,j.jsxs)(`a`,{className:`button primary`,href:w(e.host,t),children:[`Sign in with `,be(e.kind),` `,(0,j.jsxs)(`span`,{className:`muted-on`,children:[`· `,e.host]})]},e.host)),e.forges.length===0&&(0,j.jsx)(`p`,{className:`notice bad`,children:`No git platform is configured for this editor.`})]})]})}),(0,j.jsx)(ve,{})]})}function Zt(){let e=Kt(C.sites,[]);return(0,j.jsxs)(`section`,{className:`pad`,children:[(0,j.jsx)(`h1`,{children:`Your sites`}),e.loading&&!e.data&&(0,j.jsx)(`p`,{className:`muted`,children:`Asking the platform which sites you can open…`}),e.error&&(0,j.jsx)(Yt,{error:e.error}),e.data&&e.data.length===0&&(0,j.jsx)(`p`,{className:`muted`,children:`None of the sites this editor knows about are open to your account.`}),(0,j.jsx)(`ul`,{className:`tiles`,children:e.data?.map(e=>(0,j.jsx)(`li`,{children:(0,j.jsxs)(z,{to:{view:`site`,id:e.id},className:`tile`,children:[(0,j.jsx)(`strong`,{children:e.name}),e.discovered&&(0,j.jsx)(`span`,{className:`muted small`,title:`Not listed in editor.yaml: found because it has a site.yaml`,children:`Found in your repositories`}),(0,j.jsx)(`span`,{className:`muted mono`,children:e.repo.replace(/^https?:\/\//,``).replace(/\.git$/,``)}),(0,j.jsx)(`span`,{className:`tile-accounts`,children:e.accounts.map(e=>(0,j.jsxs)(`span`,{className:`pill`,title:`${e.login} on ${e.forge}`,children:[`@`,e.login,` · `,e.canWrite?`can edit`:`read only`]},e.id))})]})},e.id))})]})}function Qt({id:e,branch:t}){let n=Kt(()=>C.site(e,t),[e,t]);Ce(()=>{let r=n.data;return r?[...(r.pages||[]).filter(e=>e.source).map(n=>({id:`page:${n.source}`,title:`${n.title} ${n.path}`,group:`Open page`,run:()=>D({view:`page`,id:e,source:n.source,branch:t})})),...(r.drafts||[]).map(t=>({id:`draft:${t.branch}`,title:t.branch,group:`Switch to draft`,run:()=>D({view:`site`,id:e,branch:t.branch})})),...t?[{id:`draft:back`,title:`Back to ${r.publishBranch}`,group:`Switch to draft`,run:()=>D({view:`site`,id:e})}]:[]]:[]});let[r,i]=(0,d.useState)(``),a=n.data,o=(0,d.useMemo)(()=>(a?.pages||[]).filter(e=>r===``?!0:r===`-`?!e.collection:e.collection===r),[a,r]);if(n.loading&&!a)return(0,j.jsx)(`p`,{className:`pad muted`,children:`Fetching the site with your account…`});if(n.error)return(0,j.jsx)(Yt,{error:n.error});if(!a)return null;let s=(a.pages||[]).filter(e=>!e.collection).length;return(0,j.jsxs)(`div`,{className:`split`,children:[(0,j.jsxs)(`aside`,{className:`side`,"aria-label":`Site`,children:[(0,j.jsxs)(`div`,{className:`side-head`,children:[(0,j.jsx)(z,{to:{view:`sites`},className:`back`,children:`← Sites`}),(0,j.jsx)(`h1`,{children:a.name}),(0,j.jsx)(`p`,{className:`muted mono small`,children:a.branch===a.publishBranch?`${a.branch} · published branch`:`${a.branch} · draft`}),a.role&&(0,j.jsx)(`p`,{className:`muted small role-line`,title:`From the platform's permissions`,children:{reader:`You can read this site.`,writer:`You can save drafts and open reviews; the platform decides who may publish.`,maintainer:`You maintain this site: drafts, reviews and publishing.`}[a.role]}),a.accounts.length>1&&(0,j.jsxs)(`label`,{className:`working-as`,children:[`Working as`,(0,j.jsx)(`select`,{value:a.as,onChange:t=>{b(e,t.target.value),n.reload()},children:a.accounts.map(e=>(0,j.jsxs)(`option`,{value:e.id,children:[`@`,e.login,` · `,e.forge,e.canWrite?``:` (read only)`]},e.id))})]})]}),(0,j.jsxs)(`nav`,{"aria-label":`Pages`,children:[(0,j.jsx)(`h2`,{className:`side-label`,children:`Pages`}),(0,j.jsxs)(`button`,{type:`button`,className:`side-item ${r===``?`on`:``}`,onClick:()=>i(``),children:[`All pages `,(0,j.jsx)(`span`,{children:(a.pages||[]).length})]}),s>0&&(0,j.jsxs)(`button`,{type:`button`,className:`side-item ${r===`-`?`on`:``}`,onClick:()=>i(`-`),children:[`Pages `,(0,j.jsx)(`span`,{children:s})]}),(a.collections||[]).map(e=>(0,j.jsxs)(`button`,{type:`button`,className:`side-item ${r===e.name?`on`:``}`,onClick:()=>i(e.name),children:[e.title,` `,(0,j.jsx)(`span`,{children:e.count})]},e.name))]}),(0,j.jsxs)(`nav`,{"aria-label":`Site files`,children:[(0,j.jsx)(`h2`,{className:`side-label`,children:`Files`}),(0,j.jsx)(z,{to:{view:`media`,id:e,branch:t},className:`side-item`,children:`Pictures`}),(0,j.jsx)(z,{to:{view:`forms`,id:e,branch:t},className:`side-item`,children:`Forms`}),(0,j.jsx)(z,{to:{view:`look`,id:e,branch:t},className:`side-item`,children:`Look`}),(0,j.jsx)(z,{to:{view:`files`,id:e,branch:t},className:`side-item`,children:`Files`}),(0,j.jsx)(z,{to:{view:`redirects`,id:e,branch:t},className:`side-item`,children:`Redirects`}),(0,j.jsx)(z,{to:{view:`history`,id:e},className:`side-item`,children:`History`}),(0,j.jsx)(z,{to:{view:`privacy`,id:e,branch:t},className:`side-item`,children:`Privacy & statistics`}),(0,j.jsx)(z,{to:{view:`search`,id:e,branch:t},className:`side-item`,children:`Search engines`})]}),(0,j.jsxs)(`nav`,{"aria-label":`Drafts`,children:[(0,j.jsx)(`h2`,{className:`side-label`,children:`Drafts`}),a.branch!==a.publishBranch&&(0,j.jsxs)(z,{to:{view:`site`,id:e},className:`side-item`,children:[`← Back to `,a.publishBranch]}),(a.drafts||[]).length===0&&(0,j.jsx)(`p`,{className:`muted small side-note`,children:`No drafts.`}),(a.drafts||[]).map(t=>(0,j.jsx)(z,{to:{view:`site`,id:e,branch:t.branch},className:`side-item ${a.branch===t.branch?`on`:``}`,children:t.branch},t.branch))]}),(0,j.jsxs)(`nav`,{"aria-label":`Reviews`,children:[(0,j.jsx)(`h2`,{className:`side-label`,children:`In review`}),(a.reviews||[]).length===0&&(0,j.jsx)(`p`,{className:`muted small side-note`,children:`Nothing waiting for review.`}),(a.reviews||[]).map(e=>(0,j.jsxs)(`a`,{className:`side-item`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:[`#`,e.number,` `,e.title]},e.number))]}),a.notYet&&(0,j.jsx)(`p`,{className:`muted small side-note`,children:a.notYet})]}),(0,j.jsxs)(`section`,{className:`content`,children:[(0,j.jsx)($t,{build:a.build}),(0,j.jsxs)(`div`,{className:`toolbar`,children:[(0,j.jsx)(`h2`,{children:r===``?`All pages`:r===`-`?`Pages`:(a.collections||[]).find(e=>e.name===r)?.title}),(0,j.jsxs)(`span`,{className:`toolbar-actions`,children:[a.canWrite&&(0,j.jsx)(z,{to:{view:`quick`,id:e},className:`button primary`,children:`Quick post`}),a.canWrite&&(0,j.jsx)(tn,{id:e,collections:a.collections,branch:a.branch===a.publishBranch?void 0:a.branch}),a.preview&&(0,j.jsx)(`button`,{type:`button`,className:`button`,onClick:()=>D({view:`present`,id:e,url:a.preview,branch:t}),children:`Present`}),a.preview&&(0,j.jsx)(`a`,{className:`button`,href:a.preview,target:`_blank`,rel:`noopener noreferrer`,children:`Open preview ↗`})]})]}),(0,j.jsxs)(`table`,{className:`pages`,children:[(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{children:`Title`}),(0,j.jsx)(`th`,{children:`Address`}),(0,j.jsx)(`th`,{children:`Date`})]})}),(0,j.jsx)(`tbody`,{children:o.map(n=>(0,j.jsxs)(`tr`,{children:[(0,j.jsxs)(`td`,{children:[(0,j.jsx)(z,{to:{view:`page`,id:e,source:n.source,branch:t},children:n.title}),n.draft&&(0,j.jsx)(`span`,{className:`pill warn`,children:`draft`}),n.redirect&&(0,j.jsx)(`span`,{className:`pill`,children:`redirects`})]}),(0,j.jsx)(`td`,{className:`mono small`,children:n.path}),(0,j.jsx)(`td`,{className:`small`,children:n.date||``})]},n.source))})]})]})]})}function $t({build:e}){let[t,n]=(0,d.useState)(!1);if(e.failed)return(0,j.jsxs)(`div`,{className:`notice bad`,role:`alert`,children:[(0,j.jsx)(`strong`,{children:`This branch doesn't build.`}),` `,e.failed]});let r=e.problems||[];return(0,j.jsxs)(`div`,{className:`notice ${e.errors?`bad`:e.warnings?`warn`:`good`}`,children:[(0,j.jsxs)(`div`,{className:`notice-row`,children:[(0,j.jsxs)(`span`,{children:[e.errors?(0,j.jsxs)(`strong`,{children:[e.errors,` check error`,e.errors===1?``:`s`,`: this can't be published until they're fixed.`]}):(0,j.jsx)(`strong`,{children:`Passes the checks.`}),e.warnings>0&&(0,j.jsxs)(j.Fragment,{children:[` `,e.warnings,` warning`,e.warnings===1?``:`s`,`.`]}),(0,j.jsxs)(`span`,{className:`muted`,children:[` `,e.pages,` pages built from `,e.commit.slice(0,10),`.`]})]}),r.length>0&&(0,j.jsxs)(`button`,{type:`button`,className:`ghost`,"aria-expanded":t,onClick:()=>n(!t),children:[t?`Hide`:`Show`,` details`]})]}),t&&(0,j.jsx)(`ul`,{className:`problems`,children:r.map((e,t)=>(0,j.jsxs)(`li`,{className:e.Level,children:[(0,j.jsx)(`span`,{className:`pill`,children:e.Rule}),` `,(0,j.jsx)(`span`,{className:`mono small`,children:e.File}),` `,e.What,e.Fix&&(0,j.jsx)(`span`,{className:`fix`,children:e.Fix})]},t))})]})}function en({id:e,source:t,branch:n}){let r=Kt(()=>C.site(e,n),[e,n]);return(0,j.jsx)(Ct,{id:e,source:t,branch:n,site:r.data,onSiteChanged:r.reload})}function tn({id:e,collections:t,branch:n}){let[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(``),[s,c]=(0,d.useState)(t?.[0]?.name||``),[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)();if(!r)return(0,j.jsx)(`button`,{type:`button`,className:`button`,onClick:()=>i(!0),children:`New page`});let m=async()=>{u(!0),p(void 0);try{let t=await C.newPage(e,{collection:s,title:a,branch:n});D({view:`page`,id:e,source:t.source,branch:t.branch})}catch(e){p(e.message),u(!1)}};return(0,j.jsxs)(`div`,{className:`newpage form`,children:[(0,j.jsxs)(`label`,{children:[`In`,(0,j.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),children:[(t||[]).map(e=>(0,j.jsx)(`option`,{value:e.name,children:e.title},e.name)),(0,j.jsx)(`option`,{value:``,children:`Pages (top level)`})]})]}),(0,j.jsxs)(`label`,{children:[`Title`,(0,j.jsx)(`input`,{value:a,autoFocus:!0,onChange:e=>o(e.target.value),onKeyDown:e=>e.key===`Enter`&&a.trim()&&m()})]}),(0,j.jsxs)(`div`,{className:`actions`,children:[(0,j.jsx)(`button`,{type:`button`,className:`button primary`,disabled:l||!a.trim(),onClick:m,children:n?`Add the page`:`Start a draft`}),(0,j.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>i(!1),children:`Cancel`})]}),f&&(0,j.jsx)(`p`,{className:`notice bad`,children:f})]})}function nn({session:e}){let t=O(),n=`id`in t?t.id:void 0,r=`branch`in t?t.branch:void 0,i=e=>()=>{try{e===`auto`?localStorage.removeItem(`hotdog-theme`):localStorage.setItem(`hotdog-theme`,e)}catch{}e===`auto`?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e};return Ce(()=>[{id:`go-sites`,title:`All sites`,group:`Go to`,run:()=>D({view:`sites`})},...n?[{id:`go-site`,title:`This site's pages`,group:`Go to`,run:()=>D({view:`site`,id:n,branch:r})},{id:`go-files`,title:`Files`,group:`Go to`,run:()=>D({view:`files`,id:n,branch:r})},{id:`go-pictures`,title:`Pictures`,group:`Go to`,run:()=>D({view:`media`,id:n,branch:r})},{id:`go-look`,title:`Look`,group:`Go to`,run:()=>D({view:`look`,id:n,branch:r})},{id:`go-history`,title:`History (undo a published change)`,group:`Go to`,run:()=>D({view:`history`,id:n})},{id:`quick-banner`,title:`Quick post: banner or alert`,group:`Post`,run:()=>D({view:`quick`,id:n,kind:`banner`})},{id:`quick-post`,title:`Quick post: news post`,group:`Post`,run:()=>D({view:`quick`,id:n,kind:`post`})},{id:`quick-event`,title:`Quick post: event`,group:`Post`,run:()=>D({view:`quick`,id:n,kind:`event`})},{id:`quick-home`,title:`Quick post: front page`,group:`Post`,run:()=>D({view:`quick`,id:n,kind:`home`})},{id:`go-forms`,title:`Forms and submissions`,group:`Go to`,run:()=>D({view:`forms`,id:n,branch:r})},{id:`go-redirects`,title:`Redirects`,group:`Go to`,run:()=>D({view:`redirects`,id:n,branch:r})},{id:`go-search`,title:`Search engines (verification, IndexNow)`,group:`Go to`,run:()=>D({view:`search`,id:n,branch:r})},{id:`go-privacy`,title:`Privacy and statistics (analytics)`,group:`Go to`,run:()=>D({view:`privacy`,id:n,branch:r})}]:[],{id:`console-open`,title:`Open the console`,group:`Editor`,keys:"Ctrl+`",run:Oe},{id:`theme-light`,title:`Light theme`,group:`Editor`,run:i(`light`)},{id:`theme-dark`,title:`Dark theme`,group:`Editor`,run:i(`dark`)},{id:`theme-auto`,title:`Automatic theme`,group:`Editor`,run:i(`auto`)},...e.forges.map(t=>({id:`add-${t.host}`,title:`Add an account: ${be(t.kind)} · ${t.host}`,group:`Accounts`,run:()=>{location.href=w(t.host,location.pathname+location.search,e.accounts.some(e=>e.forge===t.host))}}))]),null}(0,f.createRoot)(document.getElementById(`root`)).render((0,j.jsx)(d.StrictMode,{children:(0,j.jsx)(qt,{})}));export{i as n,n as r,A as t}; \ No newline at end of file diff --git a/internal/editor/ui/dist/index.html b/internal/editor/ui/dist/index.html index 353e148..e73db28 100644 --- a/internal/editor/ui/dist/index.html +++ b/internal/editor/ui/dist/index.html @@ -8,7 +8,7 @@ - + diff --git a/internal/site/config.go b/internal/site/config.go index d68414d..4b0f454 100644 --- a/internal/site/config.go +++ b/internal/site/config.go @@ -379,6 +379,10 @@ type AnalyticsConfig struct { SiteID string `yaml:"site_id" json:"siteId,omitempty"` // matomo ID string `yaml:"id" json:"id,omitempty"` // ga4: G-… Gated *bool `yaml:"gated" json:"gated,omitempty"` // default true + // ga4: also measure the site's Google ads (whether a visit from one went + // on to sign up or buy), for visitors who accept. Ad personalization + // stays off either way. + AdConversions bool `yaml:"ad_conversions" json:"adConversions,omitempty"` } // IsGated reports whether analytics waits for consent. @@ -395,6 +399,12 @@ func (a *AnalyticsConfig) Validate() error { } return nil } + if a.AdConversions && a.Provider != "ga4" { + return fmt.Errorf("ad_conversions is for ga4: Google Ads measures through Google Analytics") + } + if a.AdConversions && !a.IsGated() { + return fmt.Errorf("ad_conversions needs consent: remove gated: false") + } switch a.Provider { case "plausible": if a.Domain == "" { -- 2.54.0