galley-cms 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/galley.mjs +1205 -1091
- package/dist/starters/astro-editorial/src/galley/catalog-data.js +1 -1
- package/dist/starters/astro-editorial/src/galley/catalog.js +1 -1
- package/dist/starters/astro-editorial/src/galley/client/attribution.js +1 -1
- package/dist/starters/astro-editorial/src/galley/client/forms.js +2 -2
- package/dist/starters/astro-editorial/src/galley/client/providers/frame-post.js +1 -1
- package/dist/starters/astro-editorial/src/galley/client/providers/galley.js +1 -1
- package/dist/starters/astro-editorial/src/galley/client/providers/hubspot.js +1 -1
- package/dist/starters/astro-editorial/src/galley/client/providers/mailto.js +1 -1
- package/dist/starters/astro-editorial/src/galley/client/providers/marketo.js +1 -1
- package/dist/starters/astro-editorial/src/galley/client/providers/pardot.js +1 -1
- package/dist/starters/astro-editorial/src/galley/client/providers/salesforce.js +1 -1
- package/dist/starters/astro-editorial/src/galley/client/providers/webhook.js +1 -1
- package/dist/starters/astro-editorial/src/galley/client/registry.js +1 -1
- package/dist/starters/astro-editorial/src/galley/client/types.d.ts +1 -1
- package/dist/starters/astro-editorial/src/galley/components/ConsentBanner.astro +1 -1
- package/dist/starters/astro-editorial/src/galley/components/Form.astro +1 -1
- package/dist/starters/astro-editorial/src/galley/components/Scripts.astro +1 -1
- package/dist/starters/astro-editorial/src/galley/components/index.js +1 -1
- package/dist/starters/astro-editorial/src/galley/forms/forms.css +1 -1
- package/dist/starters/astro-editorial/src/galley/forms/free-email-domains.js +1 -1
- package/dist/starters/astro-editorial/src/galley/forms/logic.js +1 -1
- package/dist/starters/astro-editorial/src/galley/forms/messages.js +1 -1
- package/dist/starters/astro-editorial/src/galley/forms/render.js +1 -1
- package/dist/starters/astro-editorial/src/galley/integration.js +1 -1
- package/dist/starters/astro-editorial/src/galley/kit.d.ts +1 -1
- package/dist/starters/astro-editorial/src/galley/mailto/config.js +1 -1
- package/dist/starters/astro-editorial/src/galley/mailto/runtime.gen.js +1 -1
- package/dist/starters/astro-editorial/src/galley/runtime/site-config.js +1 -1
- package/dist/starters/astro-editorial/src/galley/schema.js +1 -1
- package/dist/starters/astro-editorial/src/galley/scripts/banner.js +1 -1
- package/dist/starters/astro-editorial/src/galley/scripts/plan.js +1 -1
- package/dist/starters/astro-editorial/src/galley/scripts/runtime.gen.js +1 -1
- package/dist/starters/astro-editorial/src/galley/scripts/snippets.js +1 -1
- package/dist/starters/astro-editorial/src/galley/shared/glob.js +1 -1
- package/dist/starters/astro-editorial/src/galley/shared/markdown.js +1 -1
- package/dist/starters/astro-editorial/src/galley/visibility/config.js +1 -1
- package/dist/starters/astro-editorial/src/galley/visibility/content.js +1 -1
- package/dist/starters/astro-editorial/src/galley/visibility/crawlers.js +1 -1
- package/dist/starters/astro-editorial/src/galley/visibility/html.js +1 -1
- package/dist/starters/astro-editorial/src/galley/visibility/integration.js +1 -1
- package/dist/starters/astro-editorial/src/galley/visibility/markdown.js +1 -1
- package/dist/starters/astro-editorial/src/galley/visibility/page.js +1 -1
- package/dist/starters/astro-editorial/src/galley/visibility/site.js +1 -1
- package/dist/starters/astro-editorial/src/galley/visibility/structured.js +1 -1
- package/dist/starters/astro-saas/src/galley/catalog-data.js +1 -1
- package/dist/starters/astro-saas/src/galley/catalog.js +1 -1
- package/dist/starters/astro-saas/src/galley/client/attribution.js +1 -1
- package/dist/starters/astro-saas/src/galley/client/forms.js +2 -2
- package/dist/starters/astro-saas/src/galley/client/providers/frame-post.js +1 -1
- package/dist/starters/astro-saas/src/galley/client/providers/galley.js +1 -1
- package/dist/starters/astro-saas/src/galley/client/providers/hubspot.js +1 -1
- package/dist/starters/astro-saas/src/galley/client/providers/mailto.js +1 -1
- package/dist/starters/astro-saas/src/galley/client/providers/marketo.js +1 -1
- package/dist/starters/astro-saas/src/galley/client/providers/pardot.js +1 -1
- package/dist/starters/astro-saas/src/galley/client/providers/salesforce.js +1 -1
- package/dist/starters/astro-saas/src/galley/client/providers/webhook.js +1 -1
- package/dist/starters/astro-saas/src/galley/client/registry.js +1 -1
- package/dist/starters/astro-saas/src/galley/client/types.d.ts +1 -1
- package/dist/starters/astro-saas/src/galley/components/ConsentBanner.astro +1 -1
- package/dist/starters/astro-saas/src/galley/components/Form.astro +1 -1
- package/dist/starters/astro-saas/src/galley/components/Scripts.astro +1 -1
- package/dist/starters/astro-saas/src/galley/components/index.js +1 -1
- package/dist/starters/astro-saas/src/galley/forms/forms.css +1 -1
- package/dist/starters/astro-saas/src/galley/forms/free-email-domains.js +1 -1
- package/dist/starters/astro-saas/src/galley/forms/logic.js +1 -1
- package/dist/starters/astro-saas/src/galley/forms/messages.js +1 -1
- package/dist/starters/astro-saas/src/galley/forms/render.js +1 -1
- package/dist/starters/astro-saas/src/galley/integration.js +1 -1
- package/dist/starters/astro-saas/src/galley/kit.d.ts +1 -1
- package/dist/starters/astro-saas/src/galley/mailto/config.js +1 -1
- package/dist/starters/astro-saas/src/galley/mailto/runtime.gen.js +1 -1
- package/dist/starters/astro-saas/src/galley/runtime/site-config.js +1 -1
- package/dist/starters/astro-saas/src/galley/schema.js +1 -1
- package/dist/starters/astro-saas/src/galley/scripts/banner.js +1 -1
- package/dist/starters/astro-saas/src/galley/scripts/plan.js +1 -1
- package/dist/starters/astro-saas/src/galley/scripts/runtime.gen.js +1 -1
- package/dist/starters/astro-saas/src/galley/scripts/snippets.js +1 -1
- package/dist/starters/astro-saas/src/galley/shared/glob.js +1 -1
- package/dist/starters/astro-saas/src/galley/shared/markdown.js +1 -1
- package/dist/starters/astro-saas/src/galley/visibility/config.js +1 -1
- package/dist/starters/astro-saas/src/galley/visibility/content.js +1 -1
- package/dist/starters/astro-saas/src/galley/visibility/crawlers.js +1 -1
- package/dist/starters/astro-saas/src/galley/visibility/html.js +1 -1
- package/dist/starters/astro-saas/src/galley/visibility/integration.js +1 -1
- package/dist/starters/astro-saas/src/galley/visibility/markdown.js +1 -1
- package/dist/starters/astro-saas/src/galley/visibility/page.js +1 -1
- package/dist/starters/astro-saas/src/galley/visibility/site.js +1 -1
- package/dist/starters/astro-saas/src/galley/visibility/structured.js +1 -1
- package/dist/starters/astro-starter/src/galley/catalog-data.js +1 -1
- package/dist/starters/astro-starter/src/galley/catalog.js +1 -1
- package/dist/starters/astro-starter/src/galley/client/attribution.js +1 -1
- package/dist/starters/astro-starter/src/galley/client/forms.js +2 -2
- package/dist/starters/astro-starter/src/galley/client/providers/frame-post.js +1 -1
- package/dist/starters/astro-starter/src/galley/client/providers/galley.js +1 -1
- package/dist/starters/astro-starter/src/galley/client/providers/hubspot.js +1 -1
- package/dist/starters/astro-starter/src/galley/client/providers/mailto.js +1 -1
- package/dist/starters/astro-starter/src/galley/client/providers/marketo.js +1 -1
- package/dist/starters/astro-starter/src/galley/client/providers/pardot.js +1 -1
- package/dist/starters/astro-starter/src/galley/client/providers/salesforce.js +1 -1
- package/dist/starters/astro-starter/src/galley/client/providers/webhook.js +1 -1
- package/dist/starters/astro-starter/src/galley/client/registry.js +1 -1
- package/dist/starters/astro-starter/src/galley/client/types.d.ts +1 -1
- package/dist/starters/astro-starter/src/galley/components/ConsentBanner.astro +1 -1
- package/dist/starters/astro-starter/src/galley/components/Form.astro +1 -1
- package/dist/starters/astro-starter/src/galley/components/Scripts.astro +1 -1
- package/dist/starters/astro-starter/src/galley/components/index.js +1 -1
- package/dist/starters/astro-starter/src/galley/forms/forms.css +1 -1
- package/dist/starters/astro-starter/src/galley/forms/free-email-domains.js +1 -1
- package/dist/starters/astro-starter/src/galley/forms/logic.js +1 -1
- package/dist/starters/astro-starter/src/galley/forms/messages.js +1 -1
- package/dist/starters/astro-starter/src/galley/forms/render.js +1 -1
- package/dist/starters/astro-starter/src/galley/integration.js +1 -1
- package/dist/starters/astro-starter/src/galley/kit.d.ts +1 -1
- package/dist/starters/astro-starter/src/galley/mailto/config.js +1 -1
- package/dist/starters/astro-starter/src/galley/mailto/runtime.gen.js +1 -1
- package/dist/starters/astro-starter/src/galley/runtime/site-config.js +1 -1
- package/dist/starters/astro-starter/src/galley/schema.js +1 -1
- package/dist/starters/astro-starter/src/galley/scripts/banner.js +1 -1
- package/dist/starters/astro-starter/src/galley/scripts/plan.js +1 -1
- package/dist/starters/astro-starter/src/galley/scripts/runtime.gen.js +1 -1
- package/dist/starters/astro-starter/src/galley/scripts/snippets.js +1 -1
- package/dist/starters/astro-starter/src/galley/shared/glob.js +1 -1
- package/dist/starters/astro-starter/src/galley/shared/markdown.js +1 -1
- package/dist/starters/astro-starter/src/galley/visibility/config.js +1 -1
- package/dist/starters/astro-starter/src/galley/visibility/content.js +1 -1
- package/dist/starters/astro-starter/src/galley/visibility/crawlers.js +1 -1
- package/dist/starters/astro-starter/src/galley/visibility/html.js +1 -1
- package/dist/starters/astro-starter/src/galley/visibility/integration.js +1 -1
- package/dist/starters/astro-starter/src/galley/visibility/markdown.js +1 -1
- package/dist/starters/astro-starter/src/galley/visibility/page.js +1 -1
- package/dist/starters/astro-starter/src/galley/visibility/site.js +1 -1
- package/dist/starters/astro-starter/src/galley/visibility/structured.js +1 -1
- package/dist/starters/astro-storefront/src/galley/catalog-data.js +1 -1
- package/dist/starters/astro-storefront/src/galley/catalog.js +1 -1
- package/dist/starters/astro-storefront/src/galley/client/attribution.js +1 -1
- package/dist/starters/astro-storefront/src/galley/client/forms.js +2 -2
- package/dist/starters/astro-storefront/src/galley/client/providers/frame-post.js +1 -1
- package/dist/starters/astro-storefront/src/galley/client/providers/galley.js +1 -1
- package/dist/starters/astro-storefront/src/galley/client/providers/hubspot.js +1 -1
- package/dist/starters/astro-storefront/src/galley/client/providers/mailto.js +1 -1
- package/dist/starters/astro-storefront/src/galley/client/providers/marketo.js +1 -1
- package/dist/starters/astro-storefront/src/galley/client/providers/pardot.js +1 -1
- package/dist/starters/astro-storefront/src/galley/client/providers/salesforce.js +1 -1
- package/dist/starters/astro-storefront/src/galley/client/providers/webhook.js +1 -1
- package/dist/starters/astro-storefront/src/galley/client/registry.js +1 -1
- package/dist/starters/astro-storefront/src/galley/client/types.d.ts +1 -1
- package/dist/starters/astro-storefront/src/galley/components/ConsentBanner.astro +1 -1
- package/dist/starters/astro-storefront/src/galley/components/Form.astro +1 -1
- package/dist/starters/astro-storefront/src/galley/components/Scripts.astro +1 -1
- package/dist/starters/astro-storefront/src/galley/components/index.js +1 -1
- package/dist/starters/astro-storefront/src/galley/forms/forms.css +1 -1
- package/dist/starters/astro-storefront/src/galley/forms/free-email-domains.js +1 -1
- package/dist/starters/astro-storefront/src/galley/forms/logic.js +1 -1
- package/dist/starters/astro-storefront/src/galley/forms/messages.js +1 -1
- package/dist/starters/astro-storefront/src/galley/forms/render.js +1 -1
- package/dist/starters/astro-storefront/src/galley/integration.js +1 -1
- package/dist/starters/astro-storefront/src/galley/kit.d.ts +1 -1
- package/dist/starters/astro-storefront/src/galley/mailto/config.js +1 -1
- package/dist/starters/astro-storefront/src/galley/mailto/runtime.gen.js +1 -1
- package/dist/starters/astro-storefront/src/galley/runtime/site-config.js +1 -1
- package/dist/starters/astro-storefront/src/galley/schema.js +1 -1
- package/dist/starters/astro-storefront/src/galley/scripts/banner.js +1 -1
- package/dist/starters/astro-storefront/src/galley/scripts/plan.js +1 -1
- package/dist/starters/astro-storefront/src/galley/scripts/runtime.gen.js +1 -1
- package/dist/starters/astro-storefront/src/galley/scripts/snippets.js +1 -1
- package/dist/starters/astro-storefront/src/galley/shared/glob.js +1 -1
- package/dist/starters/astro-storefront/src/galley/shared/markdown.js +1 -1
- package/dist/starters/astro-storefront/src/galley/visibility/config.js +1 -1
- package/dist/starters/astro-storefront/src/galley/visibility/content.js +1 -1
- package/dist/starters/astro-storefront/src/galley/visibility/crawlers.js +1 -1
- package/dist/starters/astro-storefront/src/galley/visibility/html.js +1 -1
- package/dist/starters/astro-storefront/src/galley/visibility/integration.js +1 -1
- package/dist/starters/astro-storefront/src/galley/visibility/markdown.js +1 -1
- package/dist/starters/astro-storefront/src/galley/visibility/page.js +1 -1
- package/dist/starters/astro-storefront/src/galley/visibility/site.js +1 -1
- package/dist/starters/astro-storefront/src/galley/visibility/structured.js +1 -1
- package/dist/web/assets/{AppSettingsScreen-C-YJx3gF.js → AppSettingsScreen-Dc1Bnkjc.js} +1 -1
- package/dist/web/assets/{BodyEditor-8Hp9g0iX.js → BodyEditor-sFGFYiy3.js} +1 -1
- package/dist/web/assets/BrandScreen-sRlTBAK2.js +1 -0
- package/dist/web/assets/{CollectionScreen-Ci_RBTIP.js → CollectionScreen-B1Dk62it.js} +1 -1
- package/dist/web/assets/{EditorScreen-CG30ospj.js → EditorScreen-CzwKUTDg.js} +3 -3
- package/dist/web/assets/{FormsScreen-C5Z4-vVZ.js → FormsScreen-DIAnSDOR.js} +1 -1
- package/dist/web/assets/{HistoryScreen-Cz0FyF3N.js → HistoryScreen-rlc0r8Mc.js} +1 -1
- package/dist/web/assets/ImportScreen-C7Ktj3md.js +1 -0
- package/dist/web/assets/{InboxScreen-GB8e8oLq.js → InboxScreen-CfKusmcx.js} +1 -1
- package/dist/web/assets/{MediaLibraryPane-D5J9z7rw.js → MediaLibraryPane-DTjjTvfl.js} +1 -1
- package/dist/web/assets/{MediaScreen-CoOq4MwF.js → MediaScreen-DBLgSoRu.js} +1 -1
- package/dist/web/assets/{NewSiteScreen-B_2094y0.js → NewSiteScreen-B-KeJDBG.js} +1 -1
- package/dist/web/assets/{Online-CS3LLMG4.js → Online-CFMXFfKL.js} +1 -1
- package/dist/web/assets/{PluginsScreen-Cdkv2qWN.js → PluginsScreen-BpMt6QXM.js} +1 -1
- package/dist/web/assets/{PreviewPane-HeTLVD45.js → PreviewPane-BhtgFkYG.js} +1 -1
- package/dist/web/assets/{ProofScreen-BGAsVuYb.js → ProofScreen-DJPRt15E.js} +1 -1
- package/dist/web/assets/{ProviderSettings-BtM56M7d.js → ProviderSettings-CbQQdCdU.js} +1 -1
- package/dist/web/assets/{PublishDialog-Ctv1sxHs.js → PublishDialog-DhytG_-7.js} +1 -1
- package/dist/web/assets/{ReachNote-BJrBYKWR.js → ReachNote-D-RSOg6l.js} +1 -1
- package/dist/web/assets/RedirectsScreen-CSdhCO4l.js +3 -0
- package/dist/web/assets/RedirectsScreen-DayIuauB.css +1 -0
- package/dist/web/assets/{ScriptsScreen-BsYOIXkI.js → ScriptsScreen-mAuVetAc.js} +1 -1
- package/dist/web/assets/{SiteHomeScreen-C7LLVNdQ.js → SiteHomeScreen-BNmf8jor.js} +1 -1
- package/dist/web/assets/{SiteSettingsScreen-DhX8CluW.js → SiteSettingsScreen-CUJkP4Zt.js} +1 -1
- package/dist/web/assets/{SourceView-CkX8bKwR.js → SourceView-Dx9Hkcz6.js} +1 -1
- package/dist/web/assets/VisibilityScreen-0dqY5q9C.js +2 -0
- package/dist/web/assets/brand-ChGvDfhV.css +1 -0
- package/dist/web/assets/{codemirror-ClWBLK2a.js → codemirror-BDN0rzm7.js} +1 -1
- package/dist/web/assets/{index-CtsAxi5d.js → index-A7aTfJ-x.js} +2 -2
- package/dist/web/assets/{listPlan-BPJMzA6e.js → listPlan-Bds9RfG_.js} +1 -1
- package/dist/web/assets/{outside-Bv1jj3yu.js → outside-1xNdvt-F.js} +1 -1
- package/dist/web/assets/{paths-B6ATG9Kg.js → paths-C9eC1yfK.js} +1 -1
- package/dist/web/assets/{prefs-D04M07D3.js → prefs-BRO4YD9h.js} +1 -1
- package/dist/web/assets/{scaffold-DrnWBKU9.js → scaffold-CA0oGKYi.js} +1 -1
- package/dist/web/assets/{usePlugins-6k3yRVYT.js → usePlugins-D8UH3hzc.js} +1 -1
- package/dist/web/assets/{useVisibility-kpZhLMTT.js → useVisibility-DFye68F4.js} +3 -3
- package/dist/web/assets/words-CoSgsy_e.js +1 -0
- package/dist/web/index.html +1 -1
- package/package.json +4 -4
- package/dist/web/assets/BrandScreen-BuYHSbp6.js +0 -1
- package/dist/web/assets/ImportScreen-eVAPjnE2.js +0 -1
- package/dist/web/assets/RedirectsScreen-DeR_yuj5.js +0 -3
- package/dist/web/assets/RedirectsScreen-QTaAXMh-.css +0 -1
- package/dist/web/assets/VisibilityScreen-ChOKniqk.js +0 -2
- package/dist/web/assets/brand-BYux4UiC.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,A as t,At as n,B as r,C as i,F as a,Ft as o,G as s,H as c,I as l,Nt as u,O as d,P as f,S as p,St as m,W as h,_ as g,a as ee,bt as _,c as v,ft as y,g as b,h as x,ht as S,j as C,k as te,m as w,mt as T,n as E,pt as D,tt as O,ut as k,v as A,vt as j,z as M}from"./ui-C6O2tW4c.js";import{a as N,f as P,i as F,o as ne,p as I,t as re,u as L}from"./MediaLibraryPane-D5J9z7rw.js";import{a as R,n as z,s as B}from"./chrome-Brnq5kGb.js";import{t as V}from"./changes-DLBkrfUR.js";import{B as H}from"./index-CtsAxi5d.js";import{i as ie,n as U,o as ae,r as oe,t as W}from"./cost-BhkzE86J.js";import{o as G}from"./events-CTTFdOf-.js";import{n as se,t as ce}from"./prefs-D04M07D3.js";import{r as le}from"./useBrand-DSAfWS_y.js";import{r as K,t as q}from"./jobs-BHawhnH2.js";var J=o(u(),1),Y=_(),X={clean:`Published`,added:`New — not published yet`,modified:`Changed — not published yet`,deleted:`Deleted`};function ue({siteId:e,item:t,onDelete:n}){let[r,i]=(0,J.useState)(!1);if(!t)return(0,Y.jsx)(`aside`,{className:`app-media-details`,"aria-label":`Details`,children:(0,Y.jsx)(`p`,{className:`app-media-details__empty`,children:`Choose a file to see its details.`})});let a=async()=>{await navigator.clipboard.writeText(t.url),i(!0),setTimeout(()=>i(!1),1600)},o=I(t)===`image`;return(0,Y.jsxs)(`aside`,{className:`app-media-details`,"aria-label":`Details of ${t.name}`,children:[(0,Y.jsx)(`div`,{className:`app-media-details__preview`,children:o?(0,Y.jsx)(`img`,{src:s(e,t.path),alt:``}):I(t)===`video`?(0,Y.jsx)(`video`,{src:s(e,t.path),controls:!0,preload:`metadata`,playsInline:!0,"aria-label":t.name}):(0,Y.jsx)(j,{name:`page`,size:28})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`app-media-details__name`,children:t.name}),t.status===`clean`?null:(0,Y.jsx)(v,{tone:t.status===`added`?`insert`:t.status===`deleted`?`delete`:`change`,children:t.status===`added`?`New`:t.status===`deleted`?`Deleted`:`Edited`})]}),(0,Y.jsxs)(`div`,{className:`app-media-details__url`,children:[(0,Y.jsx)(d,{size:`sm`,mono:!0,readOnly:!0,value:t.url,"aria-label":`Address on the site`,onFocus:e=>e.target.select()}),(0,Y.jsx)(T,{icon:r?`check`:`copy`,label:r?`Copied`:`Copy address`,onClick:()=>void a()})]}),(0,Y.jsxs)(`dl`,{className:`app-media-details__facts`,children:[t.width&&t.height?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`dt`,{children:`Size`}),(0,Y.jsxs)(`dd`,{children:[t.width,` × `,t.height,` px`]})]}):null,(0,Y.jsx)(`dt`,{children:`File`}),(0,Y.jsxs)(`dd`,{children:[O(t.size),` · `,t.type.replace(/^image\//,``).replace(`+xml`,``).toUpperCase()]}),(0,Y.jsx)(`dt`,{children:`Folder`}),(0,Y.jsx)(`dd`,{className:`g-mono`,children:P(t.path)}),(0,Y.jsx)(`dt`,{children:`Status`}),(0,Y.jsx)(`dd`,{children:X[t.status]}),(0,Y.jsx)(`dt`,{children:`Changed`}),(0,Y.jsx)(`dd`,{children:y(t.modifiedAt)})]}),(0,Y.jsxs)(`div`,{className:`app-media-details__actions`,children:[(0,Y.jsxs)(`a`,{className:`g-btn g-btn--secondary g-btn--sm`,href:s(e,t.path),target:`_blank`,rel:`noreferrer noopener`,children:[(0,Y.jsx)(j,{name:`external`}),`Open full size`]}),(0,Y.jsx)(D,{size:`sm`,variant:`danger-quiet`,icon:`trash`,onClick:()=>n(t),children:`Delete`})]})]})}var Z=i()(w((e,t)=>({tracked:[],track:n=>e({tracked:[n,...t().tracked.filter(e=>e.jobId!==n.jobId)]}),forget:n=>e({tracked:t().tracked.filter(e=>e.jobId!==n)})}),{name:`galley.video-jobs`,merge:(e,t)=>{let n=(e?.tracked??[]).filter(e=>Date.now()-e.startedAt<108e5);return{...t,tracked:n}}})),Q=e=>[`videos`,`job`,e];function $(e){let t=B(Q(e),()=>M(`GET /api/videos/jobs/:jobId`,{params:{jobId:e}}));return G(`job`,t=>{t.job.id===e&&t.job.state!==`running`&&R(Q(e))}),t}function de(e){return r(`GET /api/videos/candidates/:candidateId`,{candidateId:e})}function fe(e){return M(`DELETE /api/videos/candidates/:candidateId`,{params:{candidateId:e}}).catch(()=>void 0)}var pe=[`16:9`,`9:16`,`1:1`,`4:3`,`3:4`,`21:9`],me=new Set([`image/png`,`image/jpeg`,`image/webp`]);function he({siteId:e,value:t,onChange:n}){let[r,i]=(0,J.useState)(!1),a=B(H.media(e),()=>M(`GET /api/sites/:siteId/media`,{params:{siteId:e}})),o=(a.data?.items??[]).filter(e=>me.has(e.type));return(0,Y.jsxs)(C,{label:`Start from a picture`,group:!0,hint:`Optional. The video begins on this picture — PNG, JPEG or WebP from media.`,children:[(0,Y.jsxs)(`div`,{className:`vid-frame`,children:[t?(0,Y.jsxs)(`span`,{className:`vid-frame__chosen`,children:[(0,Y.jsx)(`img`,{src:s(e,t.path),alt:``}),(0,Y.jsx)(`span`,{className:`vid-frame__name`,children:t.name}),(0,Y.jsx)(T,{icon:`close`,label:`Don’t start from ${t.name}`,onClick:()=>n(null)})]}):null,(0,Y.jsx)(D,{size:`sm`,variant:`secondary`,icon:`image`,"aria-expanded":r,onClick:()=>i(!r),children:r?`Close the pictures`:t?`Choose another…`:`Choose a picture…`})]}),r?a.loading?(0,Y.jsx)(b,{height:120}):o.length===0?(0,Y.jsx)(`p`,{className:`g-hint`,children:`There are no PNG, JPEG or WebP pictures in media yet. Upload one first.`}):(0,Y.jsx)(`div`,{className:`vid-frame__grid`,children:(0,Y.jsx)(F,{siteId:e,items:o,selected:t?.path??null,label:`Pictures to start from`,onSelect:e=>n(e),onActivate:e=>{n(e),i(!1)}})}):null]})}function ge({siteId:n,onStarted:r,onCancel:i}){let a=B(H.videoProviders(),()=>M(`GET /api/videos/providers`)),o=se(),s=p(e=>e.meta?.mode===`hosted`),u=(0,J.useMemo)(()=>a.data?.providers??[],[a.data]),d=le(n),[f,_]=(0,J.useState)(``),[v,y]=(0,J.useState)(``),[x,w]=(0,J.useState)(``),[T,E]=(0,J.useState)(``),[O,k]=(0,J.useState)(``),[A,j]=(0,J.useState)(``),[N,P]=(0,J.useState)(!0),[F,I]=(0,J.useState)(null),[re,L]=(0,J.useState)(!1),[R,z]=(0,J.useState)(null);(0,J.useEffect)(()=>{if(v||u.length===0||!o.ready)return;let e=ce(u,o.provider);e&&(y(e.id),w(o.provider===e.id&&o.model&&e.models.some(e=>e.id===o.model)?o.model:e.defaultModel))},[u,v,o.provider,o.model,o.ready]);let V=u.find(e=>e.id===v),W=V?.models.find(e=>e.id===x)??V?.models.find(e=>e.id===V.defaultModel)??V?.models[0],G=U(W?.durations),K=U(W?.resolutions),q=U(W?.aspects).filter(e=>pe.includes(e));if((0,J.useEffect)(()=>{E(ie(W)?.toString()??``),k(W?.resolutions?.[0]??``),j(W?.aspects?.find(e=>pe.includes(e))??``),P(!!W?.audio),W?.supportsFirstFrame||I(null)},[W]),a.loading)return(0,Y.jsxs)(`div`,{className:`vid-generate`,"aria-busy":`true`,children:[(0,Y.jsx)(b,{height:76}),(0,Y.jsx)(b,{width:260,height:28})]});if(a.status===`error`&&!a.data)return h(a.error)&&a.error.status===404?(0,Y.jsxs)(`p`,{className:`g-margin-note`,children:[(0,Y.jsx)(e,{kind:`stet`}),(0,Y.jsx)(`span`,{children:`This server doesn’t make videos. A newer version of the app does, with a video plugin turned on.`})]}):(0,Y.jsx)(l,{compact:!0,title:`Couldn’t load the video services`,error:a.error,onRetry:()=>void a.refetch()});if(u.length===0)return(0,Y.jsx)(`div`,{className:`vid-generate`,children:(0,Y.jsxs)(`div`,{className:`vid-setup`,children:[(0,Y.jsx)(`p`,{className:`vid-setup__title`,children:`No video service is set up yet.`}),(0,Y.jsx)(`p`,{className:`vid-setup__body`,children:`Videos are made by a plugin. OpenRouter comes with the app: turn it on in Plugins and add its API key, then come back here.`}),(0,Y.jsx)(m,{className:S(`primary`,`sm`),to:`/plugins`,children:`Open plugins`})]})});let X=T?Number(T):void 0,ue=!!(V?.configured&&W&&f.trim().length>=3),Q=async()=>{if(V&&W){L(!0),z(null);try{let e=await M(`POST /api/sites/:siteId/videos/generate`,{params:{siteId:n},body:{prompt:f.trim(),provider:V.id,model:W.id,...X?{durationSeconds:X}:{},...O&&K.length?{resolution:O}:{},...A&&q.length?{aspect:A}:{},...W.audio?{audio:N}:{},...F&&W.supportsFirstFrame?{firstFramePath:F.path}:{},...d?{brandDirection:d}:{}}});Z.getState().track({jobId:e.id,siteId:n,prompt:f.trim(),startedAt:e.startedAt}),r(e)}catch(e){z(e)}finally{L(!1)}}},$=h(R)&&R.shape.code===`unconfigured`;return(0,Y.jsxs)(`div`,{className:`vid-generate`,children:[V&&!V.configured?(0,Y.jsxs)(`div`,{className:`vid-setup`,role:`status`,children:[(0,Y.jsxs)(`p`,{className:`vid-setup__title`,children:[V.label,` needs its API key before it can make videos.`]}),(0,Y.jsxs)(`p`,{className:`vid-setup__body`,children:[`Add the key on the Plugins screen. It’s kept on this `,s?`server`:`computer`,` with the app’s other keys, and never shown again.`]}),(0,Y.jsx)(m,{className:S(`primary`,`sm`),to:`/plugins`,children:`Add the key`})]}):null,(0,Y.jsx)(C,{label:`Describe the video`,hint:`What happens, where, and how the camera moves. A sentence or two is plenty.`,children:(0,Y.jsx)(t,{value:f,rows:3,maxRows:8,placeholder:`Slow push-in on a loaf being sliced on a floured board, morning light from the left…`,onChange:e=>_(e.target.value)})}),(0,Y.jsx)(ne,{direction:d}),(0,Y.jsxs)(`div`,{className:`app-form-row`,children:[u.length>1?(0,Y.jsx)(C,{label:`Service`,children:(0,Y.jsx)(te,{value:v,onChange:e=>{y(e),w(u.find(t=>t.id===e)?.defaultModel??``)},options:u.map(e=>({value:e.id,label:e.configured?e.label:`${e.label} — needs its key`}))})}):null,V?(0,Y.jsx)(C,{label:`Model`,hint:W?ae(W):void 0,children:(0,Y.jsx)(te,{value:W?.id??``,onChange:w,options:V.models.map(e=>({value:e.id,label:e.price?`${e.label} — ${e.price}`:e.label}))})}):null]}),G.length>0||K.length>0||q.length>0?(0,Y.jsxs)(`div`,{className:`vid-generate__row`,children:[G.length>0?(0,Y.jsx)(C,{label:`Length`,group:!0,children:(0,Y.jsx)(g,{label:`Length in seconds`,options:G.map(e=>({value:String(e),label:`${e} s`,title:`${e} seconds`})),value:T,onChange:E})}):null,K.length>1?(0,Y.jsx)(C,{label:`Resolution`,group:!0,children:(0,Y.jsx)(g,{label:`Resolution`,options:K.map(e=>({value:e,label:e})),value:O,onChange:k})}):null,q.length>1?(0,Y.jsx)(C,{label:`Shape`,group:!0,children:(0,Y.jsx)(g,{label:`Shape`,options:q.map(e=>({value:e,label:e})),value:A,onChange:e=>j(e)})}):null]}):null,W?.audio?(0,Y.jsx)(ee,{checked:N,onChange:P,label:`With sound`,description:`The model adds sound to match the picture.`}):null,W?.supportsFirstFrame?(0,Y.jsx)(he,{siteId:n,value:F,onChange:I}):null,(0,Y.jsxs)(`div`,{className:`vid-cost`,"aria-live":`polite`,children:[(0,Y.jsx)(e,{kind:`reg`}),(0,Y.jsx)(`span`,{children:oe(W,X,V?.label??`the service`)})]}),(0,Y.jsxs)(`p`,{className:`g-hint vid-generate__limits`,children:[`It takes a few minutes, and you can leave this screen while it’s made. Media keeps MP4 videos up to 25 MB; a finished video waits `,2,` hours for you to save it.`]}),R?(0,Y.jsx)(l,{compact:!0,title:$?`The video service needs attention`:`Couldn’t start the video`,message:`${c(R).message} Nothing was charged.`,detail:c(R).detail,actions:$?(0,Y.jsx)(m,{className:S(`secondary`,`sm`),to:`/plugins`,children:`Open plugins`}):void 0}):null,(0,Y.jsxs)(`div`,{className:`vid-generate__go`,children:[i?(0,Y.jsx)(D,{variant:`quiet`,onClick:i,children:`Not now`}):null,(0,Y.jsx)(D,{variant:`primary`,busy:re,busyLabel:`Starting`,disabled:!ue,onClick:()=>void Q(),children:`Make the video`})]})]})}function _e({siteId:t,candidate:n,onSaved:r,onGone:i}){let[a,o]=(0,J.useState)(()=>L(n.prompt).split(`-`).slice(0,6).join(`-`)),[s,l]=(0,J.useState)(!1),[u,f]=(0,J.useState)(null),[p,m]=(0,J.useState)(!0),h=n.size>W,g=async()=>{l(!0),f(null);try{let e=await M(`POST /api/sites/:siteId/videos/save`,{params:{siteId:t},body:{candidateId:n.id,...a.trim()?{filename:a.trim()}:{}}});R(H.media(t)),r(e)}catch(e){f(c(e).message)}finally{l(!1)}};return(0,Y.jsxs)(`div`,{className:`vid-candidate`,children:[(0,Y.jsx)(`div`,{className:`vid-candidate__player`,children:p?(0,Y.jsx)(`video`,{src:de(n.id),controls:!0,preload:`metadata`,playsInline:!0,onError:()=>m(!1),"aria-label":`The video made from “${n.prompt}”`}):(0,Y.jsx)(`p`,{className:`vid-candidate__unplayable`,children:`This preview can’t be played in the browser. Save it to see it in media, or discard it.`})}),(0,Y.jsxs)(`div`,{className:`vid-candidate__side`,children:[(0,Y.jsxs)(`p`,{className:`vid-candidate__facts`,children:[(0,Y.jsx)(`span`,{children:O(n.size)}),n.cost===void 0?null:(0,Y.jsxs)(`span`,{children:[`Cost `,k(n.cost)]})]}),h?(0,Y.jsxs)(`p`,{className:`g-margin-note vid-candidate__warn`,children:[(0,Y.jsx)(e,{kind:`bang`}),(0,Y.jsx)(`span`,{children:`It’s larger than 25 MB, the most media keeps, so it can’t be saved. Make a shorter or lower-resolution one.`})]}):(0,Y.jsx)(C,{label:`Name it`,hint:`Lowercase words with hyphens; .mp4 is added for you.`,error:u??void 0,children:(0,Y.jsx)(d,{value:a,mono:!0,onChange:e=>o(e.target.value),placeholder:`loaf-being-sliced`})}),(0,Y.jsxs)(`div`,{className:`vid-candidate__actions`,children:[(0,Y.jsx)(D,{variant:`quiet`,onClick:()=>{fe(n.id),i()},children:`Discard`}),(0,Y.jsx)(D,{variant:`primary`,busy:s,busyLabel:`Saving`,disabled:h,onClick:()=>void g(),children:`Save to media`})]})]})]})}function ve({video:t,onSaved:n}){let r=$(t.jobId),i=q(t.jobId),a=Z(e=>e.forget),[o,s]=(0,J.useState)([]);K(t.jobId);let l=i??r.data?.job??null,u=(r.data?.candidates??[]).filter(e=>!o.includes(e.id));if(r.status===`error`&&!r.data){let n=h(r.error)&&r.error.status===404;return(0,Y.jsxs)(`li`,{className:`vid-job vid-job--error`,children:[(0,Y.jsxs)(`div`,{className:`vid-job__head`,children:[(0,Y.jsx)(e,{kind:`bang`}),(0,Y.jsxs)(`span`,{className:`vid-job__prompt`,children:[`“`,t.prompt,`”`]}),(0,Y.jsx)(T,{icon:`close`,label:`Dismiss`,onClick:()=>a(t.jobId)})]}),(0,Y.jsx)(`p`,{className:`vid-job__detail`,children:n?`This video isn’t known any more — the app was restarted or it expired. Nothing more will be charged for it.`:c(r.error).message})]})}if(!l)return(0,Y.jsx)(`li`,{className:`vid-job`,children:(0,Y.jsxs)(`div`,{className:`vid-job__head`,children:[(0,Y.jsx)(x,{label:`Reading`}),(0,Y.jsxs)(`span`,{className:`vid-job__prompt`,children:[`“`,t.prompt,`”`]})]})});let d=l.progress===void 0?null:Math.round(l.progress*100),f=l.state===`done`,p=f&&r.data&&!r.fetching&&u.length===0;return(0,Y.jsxs)(`li`,{className:`vid-job vid-job--${l.state}`,children:[(0,Y.jsxs)(`div`,{className:`vid-job__head`,children:[l.state===`running`?(0,Y.jsx)(x,{label:`Making the video`}):(0,Y.jsx)(e,{kind:f?`reg`:`bang`}),(0,Y.jsxs)(`span`,{className:`vid-job__prompt`,children:[`“`,t.prompt,`”`]}),l.state===`running`?null:(0,Y.jsx)(T,{icon:`close`,label:f&&u.length?`Discard and dismiss`:`Dismiss`,onClick:()=>{for(let e of u)fe(e.id);a(t.jobId)}})]}),(0,Y.jsxs)(`p`,{className:`vid-job__detail`,role:`status`,children:[l.detail??(l.state===`running`?`Working…`:f?`The video is ready.`:`Stopped.`),l.state===`error`?` Nothing was added to media.`:``]}),l.state===`running`?(0,Y.jsx)(`div`,{className:`app-progress`,role:`progressbar`,"aria-label":`Making “${t.prompt}”`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":d??void 0,children:(0,Y.jsx)(`span`,{className:d===null?`app-progress__bar app-progress__bar--indeterminate`:`app-progress__bar`,style:d===null?void 0:{inlineSize:`${d}%`}})}):null,f&&u.length>0?(0,Y.jsxs)(Y.Fragment,{children:[u.map(e=>(0,Y.jsx)(_e,{siteId:t.siteId,candidate:e,onGone:()=>{let n=u.filter(t=>t.id!==e.id);s(t=>[...t,e.id]),n.length===0&&a(t.jobId)},onSaved:r=>{let i=u.filter(t=>t.id!==e.id);s(t=>[...t,e.id]),i.length===0&&a(t.jobId),n(r)}},e.id)),(0,Y.jsxs)(`p`,{className:`g-hint`,children:[`Kept for `,2,` hours from when it was made, unless you save it.`]})]}):null,p?(0,Y.jsx)(`p`,{className:`g-hint`,children:`Nothing left to save from this one.`}):null]})}function ye({siteId:e,onSaved:t}){let n=Z(e=>e.tracked).filter(t=>t.siteId===e);return n.length===0?null:(0,Y.jsxs)(`section`,{className:`vid-jobs`,"aria-label":`Videos`,children:[(0,Y.jsx)(`h2`,{className:`g-eyebrow vid-jobs__title`,children:n.length===1?`Video`:`Videos`}),(0,Y.jsx)(`ul`,{className:`vid-jobs__list`,children:n.map(e=>(0,Y.jsx)(ve,{video:e,onSaved:t},e.jobId))})]})}var be=[{value:`all`,label:`All`},{value:`image`,label:`Images`},{value:`video`,label:`Videos`},{value:`document`,label:`Documents`}];function xe(){let{siteId:e=``}=n();z({crumbs:[{label:`Media`}]});let t=B(H.media(e),()=>M(`GET /api/sites/:siteId/media`,{params:{siteId:e}})),[r,i]=(0,J.useState)(`all`),[o,s]=(0,J.useState)(null),[l,u]=(0,J.useState)(!1),[d,p]=(0,J.useState)(!1),[m,h]=(0,J.useState)(null),ee=t.data?.items.find(e=>e.path===o)??null,_=async t=>{await M(`DELETE /api/sites/:siteId/media`,{params:{siteId:e},query:{path:t.path}}),R(H.media(e)),s(e=>e===t.path?null:e),t.status===`added`?E({tone:`neutral`,title:`${t.name} deleted`}):E({tone:`neutral`,title:`${t.name} deleted`,body:t.status===`modified`?`It leaves the site when you publish. Until then, Undo brings back the published version.`:`It leaves the site when you publish. Until then, Undo brings it back.`,action:{label:`Undo`,onClick:()=>void V.getState().discard([t.path]).then(()=>{R(H.media(e)),s(t.path),E({tone:`neutral`,title:`${t.name} is back`})}).catch(e=>E({tone:`danger`,title:`Couldn’t bring it back`,body:c(e).message}))}})};return(0,Y.jsxs)(`div`,{className:`app-screen app-media`,children:[(0,Y.jsx)(A,{title:`Media`,description:`Images and files the site uses. Drop files anywhere here, or paste an image.`,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(D,{variant:`secondary`,icon:`play`,onClick:()=>p(!0),children:`Generate a video`}),(0,Y.jsx)(D,{variant:`primary`,icon:`plus`,onClick:()=>u(!0),children:`Generate an image`})]})}),(0,Y.jsx)(ye,{siteId:e,onSaved:e=>{s(e.path),E({tone:`success`,title:`Video saved`,body:`“${e.name}” is in media, ready to use.`})}}),(0,Y.jsxs)(`div`,{className:`app-media__layout`,children:[(0,Y.jsx)(re,{siteId:e,kind:r,selected:o,onSelect:e=>s(e?.path??null),onGenerate:()=>u(!0),toolbar:(0,Y.jsx)(g,{label:`Show`,options:be,value:r,onChange:i})}),(0,Y.jsx)(ue,{siteId:e,item:ee,onDelete:e=>{e.status===`clean`?_(e).catch(e=>E({tone:`danger`,title:`Couldn’t delete the file`,body:c(e).message,detail:c(e).detail})):h(e)}})]}),(0,Y.jsx)(a,{open:l,onClose:()=>u(!1),title:`Generate an image`,size:`xl`,children:l?(0,Y.jsx)(N,{siteId:e,onSaved:e=>{u(!1),s(e.path),E({tone:`success`,title:`Image saved`,body:`“${e.name}” is in media, ready to use.`})}}):null}),(0,Y.jsx)(a,{open:d,onClose:()=>p(!1),title:`Generate a video`,size:`lg`,children:d?(0,Y.jsx)(ge,{siteId:e,onCancel:()=>p(!1),onStarted:()=>{p(!1),E({tone:`neutral`,title:`Making the video`,body:`It takes a few minutes. It waits at the top of Media when it’s ready — you can leave this screen.`})}}):null}),(0,Y.jsx)(f,{open:m!==null,onClose:()=>h(null),title:`Delete “${m?.name??``}”?`,body:m?.status===`added`?`It hasn’t been published, so once it’s deleted it can’t be brought back. Pages that use it will show a missing image.`:`Its unpublished changes are lost; Undo brings back only the published version. Pages that use it will show a missing image once this is published.`,confirmLabel:`Delete file`,busyLabel:`Deleting`,cancelLabel:`Keep it`,errorTitle:`Couldn’t delete the file`,onConfirm:()=>m?_(m):void 0})]})}export{xe as MediaScreen};
|
|
1
|
+
import{$ as e,A as t,At as n,B as r,C as i,F as a,Ft as o,G as s,H as c,I as l,Nt as u,O as d,P as f,S as p,St as m,W as h,_ as g,a as ee,bt as _,c as v,ft as y,g as b,h as x,ht as S,j as C,k as te,m as w,mt as T,n as E,pt as D,tt as O,ut as k,v as A,vt as j,z as M}from"./ui-C6O2tW4c.js";import{a as N,f as P,i as F,o as ne,p as I,t as re,u as L}from"./MediaLibraryPane-DTjjTvfl.js";import{a as R,n as z,s as B}from"./chrome-Brnq5kGb.js";import{t as V}from"./changes-DLBkrfUR.js";import{B as H}from"./index-A7aTfJ-x.js";import{i as ie,n as U,o as ae,r as oe,t as W}from"./cost-BhkzE86J.js";import{o as G}from"./events-CTTFdOf-.js";import{n as se,t as ce}from"./prefs-BRO4YD9h.js";import{r as le}from"./useBrand-DSAfWS_y.js";import{r as K,t as q}from"./jobs-BHawhnH2.js";var J=o(u(),1),Y=_(),X={clean:`Published`,added:`New — not published yet`,modified:`Changed — not published yet`,deleted:`Deleted`};function ue({siteId:e,item:t,onDelete:n}){let[r,i]=(0,J.useState)(!1);if(!t)return(0,Y.jsx)(`aside`,{className:`app-media-details`,"aria-label":`Details`,children:(0,Y.jsx)(`p`,{className:`app-media-details__empty`,children:`Choose a file to see its details.`})});let a=async()=>{await navigator.clipboard.writeText(t.url),i(!0),setTimeout(()=>i(!1),1600)},o=I(t)===`image`;return(0,Y.jsxs)(`aside`,{className:`app-media-details`,"aria-label":`Details of ${t.name}`,children:[(0,Y.jsx)(`div`,{className:`app-media-details__preview`,children:o?(0,Y.jsx)(`img`,{src:s(e,t.path),alt:``}):I(t)===`video`?(0,Y.jsx)(`video`,{src:s(e,t.path),controls:!0,preload:`metadata`,playsInline:!0,"aria-label":t.name}):(0,Y.jsx)(j,{name:`page`,size:28})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`app-media-details__name`,children:t.name}),t.status===`clean`?null:(0,Y.jsx)(v,{tone:t.status===`added`?`insert`:t.status===`deleted`?`delete`:`change`,children:t.status===`added`?`New`:t.status===`deleted`?`Deleted`:`Edited`})]}),(0,Y.jsxs)(`div`,{className:`app-media-details__url`,children:[(0,Y.jsx)(d,{size:`sm`,mono:!0,readOnly:!0,value:t.url,"aria-label":`Address on the site`,onFocus:e=>e.target.select()}),(0,Y.jsx)(T,{icon:r?`check`:`copy`,label:r?`Copied`:`Copy address`,onClick:()=>void a()})]}),(0,Y.jsxs)(`dl`,{className:`app-media-details__facts`,children:[t.width&&t.height?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`dt`,{children:`Size`}),(0,Y.jsxs)(`dd`,{children:[t.width,` × `,t.height,` px`]})]}):null,(0,Y.jsx)(`dt`,{children:`File`}),(0,Y.jsxs)(`dd`,{children:[O(t.size),` · `,t.type.replace(/^image\//,``).replace(`+xml`,``).toUpperCase()]}),(0,Y.jsx)(`dt`,{children:`Folder`}),(0,Y.jsx)(`dd`,{className:`g-mono`,children:P(t.path)}),(0,Y.jsx)(`dt`,{children:`Status`}),(0,Y.jsx)(`dd`,{children:X[t.status]}),(0,Y.jsx)(`dt`,{children:`Changed`}),(0,Y.jsx)(`dd`,{children:y(t.modifiedAt)})]}),(0,Y.jsxs)(`div`,{className:`app-media-details__actions`,children:[(0,Y.jsxs)(`a`,{className:`g-btn g-btn--secondary g-btn--sm`,href:s(e,t.path),target:`_blank`,rel:`noreferrer noopener`,children:[(0,Y.jsx)(j,{name:`external`}),`Open full size`]}),(0,Y.jsx)(D,{size:`sm`,variant:`danger-quiet`,icon:`trash`,onClick:()=>n(t),children:`Delete`})]})]})}var Z=i()(w((e,t)=>({tracked:[],track:n=>e({tracked:[n,...t().tracked.filter(e=>e.jobId!==n.jobId)]}),forget:n=>e({tracked:t().tracked.filter(e=>e.jobId!==n)})}),{name:`galley.video-jobs`,merge:(e,t)=>{let n=(e?.tracked??[]).filter(e=>Date.now()-e.startedAt<108e5);return{...t,tracked:n}}})),Q=e=>[`videos`,`job`,e];function $(e){let t=B(Q(e),()=>M(`GET /api/videos/jobs/:jobId`,{params:{jobId:e}}));return G(`job`,t=>{t.job.id===e&&t.job.state!==`running`&&R(Q(e))}),t}function de(e){return r(`GET /api/videos/candidates/:candidateId`,{candidateId:e})}function fe(e){return M(`DELETE /api/videos/candidates/:candidateId`,{params:{candidateId:e}}).catch(()=>void 0)}var pe=[`16:9`,`9:16`,`1:1`,`4:3`,`3:4`,`21:9`],me=new Set([`image/png`,`image/jpeg`,`image/webp`]);function he({siteId:e,value:t,onChange:n}){let[r,i]=(0,J.useState)(!1),a=B(H.media(e),()=>M(`GET /api/sites/:siteId/media`,{params:{siteId:e}})),o=(a.data?.items??[]).filter(e=>me.has(e.type));return(0,Y.jsxs)(C,{label:`Start from a picture`,group:!0,hint:`Optional. The video begins on this picture — PNG, JPEG or WebP from media.`,children:[(0,Y.jsxs)(`div`,{className:`vid-frame`,children:[t?(0,Y.jsxs)(`span`,{className:`vid-frame__chosen`,children:[(0,Y.jsx)(`img`,{src:s(e,t.path),alt:``}),(0,Y.jsx)(`span`,{className:`vid-frame__name`,children:t.name}),(0,Y.jsx)(T,{icon:`close`,label:`Don’t start from ${t.name}`,onClick:()=>n(null)})]}):null,(0,Y.jsx)(D,{size:`sm`,variant:`secondary`,icon:`image`,"aria-expanded":r,onClick:()=>i(!r),children:r?`Close the pictures`:t?`Choose another…`:`Choose a picture…`})]}),r?a.loading?(0,Y.jsx)(b,{height:120}):o.length===0?(0,Y.jsx)(`p`,{className:`g-hint`,children:`There are no PNG, JPEG or WebP pictures in media yet. Upload one first.`}):(0,Y.jsx)(`div`,{className:`vid-frame__grid`,children:(0,Y.jsx)(F,{siteId:e,items:o,selected:t?.path??null,label:`Pictures to start from`,onSelect:e=>n(e),onActivate:e=>{n(e),i(!1)}})}):null]})}function ge({siteId:n,onStarted:r,onCancel:i}){let a=B(H.videoProviders(),()=>M(`GET /api/videos/providers`)),o=se(),s=p(e=>e.meta?.mode===`hosted`),u=(0,J.useMemo)(()=>a.data?.providers??[],[a.data]),d=le(n),[f,_]=(0,J.useState)(``),[v,y]=(0,J.useState)(``),[x,w]=(0,J.useState)(``),[T,E]=(0,J.useState)(``),[O,k]=(0,J.useState)(``),[A,j]=(0,J.useState)(``),[N,P]=(0,J.useState)(!0),[F,I]=(0,J.useState)(null),[re,L]=(0,J.useState)(!1),[R,z]=(0,J.useState)(null);(0,J.useEffect)(()=>{if(v||u.length===0||!o.ready)return;let e=ce(u,o.provider);e&&(y(e.id),w(o.provider===e.id&&o.model&&e.models.some(e=>e.id===o.model)?o.model:e.defaultModel))},[u,v,o.provider,o.model,o.ready]);let V=u.find(e=>e.id===v),W=V?.models.find(e=>e.id===x)??V?.models.find(e=>e.id===V.defaultModel)??V?.models[0],G=U(W?.durations),K=U(W?.resolutions),q=U(W?.aspects).filter(e=>pe.includes(e));if((0,J.useEffect)(()=>{E(ie(W)?.toString()??``),k(W?.resolutions?.[0]??``),j(W?.aspects?.find(e=>pe.includes(e))??``),P(!!W?.audio),W?.supportsFirstFrame||I(null)},[W]),a.loading)return(0,Y.jsxs)(`div`,{className:`vid-generate`,"aria-busy":`true`,children:[(0,Y.jsx)(b,{height:76}),(0,Y.jsx)(b,{width:260,height:28})]});if(a.status===`error`&&!a.data)return h(a.error)&&a.error.status===404?(0,Y.jsxs)(`p`,{className:`g-margin-note`,children:[(0,Y.jsx)(e,{kind:`stet`}),(0,Y.jsx)(`span`,{children:`This server doesn’t make videos. A newer version of the app does, with a video plugin turned on.`})]}):(0,Y.jsx)(l,{compact:!0,title:`Couldn’t load the video services`,error:a.error,onRetry:()=>void a.refetch()});if(u.length===0)return(0,Y.jsx)(`div`,{className:`vid-generate`,children:(0,Y.jsxs)(`div`,{className:`vid-setup`,children:[(0,Y.jsx)(`p`,{className:`vid-setup__title`,children:`No video service is set up yet.`}),(0,Y.jsx)(`p`,{className:`vid-setup__body`,children:`Videos are made by a plugin. OpenRouter comes with the app: turn it on in Plugins and add its API key, then come back here.`}),(0,Y.jsx)(m,{className:S(`primary`,`sm`),to:`/plugins`,children:`Open plugins`})]})});let X=T?Number(T):void 0,ue=!!(V?.configured&&W&&f.trim().length>=3),Q=async()=>{if(V&&W){L(!0),z(null);try{let e=await M(`POST /api/sites/:siteId/videos/generate`,{params:{siteId:n},body:{prompt:f.trim(),provider:V.id,model:W.id,...X?{durationSeconds:X}:{},...O&&K.length?{resolution:O}:{},...A&&q.length?{aspect:A}:{},...W.audio?{audio:N}:{},...F&&W.supportsFirstFrame?{firstFramePath:F.path}:{},...d?{brandDirection:d}:{}}});Z.getState().track({jobId:e.id,siteId:n,prompt:f.trim(),startedAt:e.startedAt}),r(e)}catch(e){z(e)}finally{L(!1)}}},$=h(R)&&R.shape.code===`unconfigured`;return(0,Y.jsxs)(`div`,{className:`vid-generate`,children:[V&&!V.configured?(0,Y.jsxs)(`div`,{className:`vid-setup`,role:`status`,children:[(0,Y.jsxs)(`p`,{className:`vid-setup__title`,children:[V.label,` needs its API key before it can make videos.`]}),(0,Y.jsxs)(`p`,{className:`vid-setup__body`,children:[`Add the key on the Plugins screen. It’s kept on this `,s?`server`:`computer`,` with the app’s other keys, and never shown again.`]}),(0,Y.jsx)(m,{className:S(`primary`,`sm`),to:`/plugins`,children:`Add the key`})]}):null,(0,Y.jsx)(C,{label:`Describe the video`,hint:`What happens, where, and how the camera moves. A sentence or two is plenty.`,children:(0,Y.jsx)(t,{value:f,rows:3,maxRows:8,placeholder:`Slow push-in on a loaf being sliced on a floured board, morning light from the left…`,onChange:e=>_(e.target.value)})}),(0,Y.jsx)(ne,{direction:d}),(0,Y.jsxs)(`div`,{className:`app-form-row`,children:[u.length>1?(0,Y.jsx)(C,{label:`Service`,children:(0,Y.jsx)(te,{value:v,onChange:e=>{y(e),w(u.find(t=>t.id===e)?.defaultModel??``)},options:u.map(e=>({value:e.id,label:e.configured?e.label:`${e.label} — needs its key`}))})}):null,V?(0,Y.jsx)(C,{label:`Model`,hint:W?ae(W):void 0,children:(0,Y.jsx)(te,{value:W?.id??``,onChange:w,options:V.models.map(e=>({value:e.id,label:e.price?`${e.label} — ${e.price}`:e.label}))})}):null]}),G.length>0||K.length>0||q.length>0?(0,Y.jsxs)(`div`,{className:`vid-generate__row`,children:[G.length>0?(0,Y.jsx)(C,{label:`Length`,group:!0,children:(0,Y.jsx)(g,{label:`Length in seconds`,options:G.map(e=>({value:String(e),label:`${e} s`,title:`${e} seconds`})),value:T,onChange:E})}):null,K.length>1?(0,Y.jsx)(C,{label:`Resolution`,group:!0,children:(0,Y.jsx)(g,{label:`Resolution`,options:K.map(e=>({value:e,label:e})),value:O,onChange:k})}):null,q.length>1?(0,Y.jsx)(C,{label:`Shape`,group:!0,children:(0,Y.jsx)(g,{label:`Shape`,options:q.map(e=>({value:e,label:e})),value:A,onChange:e=>j(e)})}):null]}):null,W?.audio?(0,Y.jsx)(ee,{checked:N,onChange:P,label:`With sound`,description:`The model adds sound to match the picture.`}):null,W?.supportsFirstFrame?(0,Y.jsx)(he,{siteId:n,value:F,onChange:I}):null,(0,Y.jsxs)(`div`,{className:`vid-cost`,"aria-live":`polite`,children:[(0,Y.jsx)(e,{kind:`reg`}),(0,Y.jsx)(`span`,{children:oe(W,X,V?.label??`the service`)})]}),(0,Y.jsxs)(`p`,{className:`g-hint vid-generate__limits`,children:[`It takes a few minutes, and you can leave this screen while it’s made. Media keeps MP4 videos up to 25 MB; a finished video waits `,2,` hours for you to save it.`]}),R?(0,Y.jsx)(l,{compact:!0,title:$?`The video service needs attention`:`Couldn’t start the video`,message:`${c(R).message} Nothing was charged.`,detail:c(R).detail,actions:$?(0,Y.jsx)(m,{className:S(`secondary`,`sm`),to:`/plugins`,children:`Open plugins`}):void 0}):null,(0,Y.jsxs)(`div`,{className:`vid-generate__go`,children:[i?(0,Y.jsx)(D,{variant:`quiet`,onClick:i,children:`Not now`}):null,(0,Y.jsx)(D,{variant:`primary`,busy:re,busyLabel:`Starting`,disabled:!ue,onClick:()=>void Q(),children:`Make the video`})]})]})}function _e({siteId:t,candidate:n,onSaved:r,onGone:i}){let[a,o]=(0,J.useState)(()=>L(n.prompt).split(`-`).slice(0,6).join(`-`)),[s,l]=(0,J.useState)(!1),[u,f]=(0,J.useState)(null),[p,m]=(0,J.useState)(!0),h=n.size>W,g=async()=>{l(!0),f(null);try{let e=await M(`POST /api/sites/:siteId/videos/save`,{params:{siteId:t},body:{candidateId:n.id,...a.trim()?{filename:a.trim()}:{}}});R(H.media(t)),r(e)}catch(e){f(c(e).message)}finally{l(!1)}};return(0,Y.jsxs)(`div`,{className:`vid-candidate`,children:[(0,Y.jsx)(`div`,{className:`vid-candidate__player`,children:p?(0,Y.jsx)(`video`,{src:de(n.id),controls:!0,preload:`metadata`,playsInline:!0,onError:()=>m(!1),"aria-label":`The video made from “${n.prompt}”`}):(0,Y.jsx)(`p`,{className:`vid-candidate__unplayable`,children:`This preview can’t be played in the browser. Save it to see it in media, or discard it.`})}),(0,Y.jsxs)(`div`,{className:`vid-candidate__side`,children:[(0,Y.jsxs)(`p`,{className:`vid-candidate__facts`,children:[(0,Y.jsx)(`span`,{children:O(n.size)}),n.cost===void 0?null:(0,Y.jsxs)(`span`,{children:[`Cost `,k(n.cost)]})]}),h?(0,Y.jsxs)(`p`,{className:`g-margin-note vid-candidate__warn`,children:[(0,Y.jsx)(e,{kind:`bang`}),(0,Y.jsx)(`span`,{children:`It’s larger than 25 MB, the most media keeps, so it can’t be saved. Make a shorter or lower-resolution one.`})]}):(0,Y.jsx)(C,{label:`Name it`,hint:`Lowercase words with hyphens; .mp4 is added for you.`,error:u??void 0,children:(0,Y.jsx)(d,{value:a,mono:!0,onChange:e=>o(e.target.value),placeholder:`loaf-being-sliced`})}),(0,Y.jsxs)(`div`,{className:`vid-candidate__actions`,children:[(0,Y.jsx)(D,{variant:`quiet`,onClick:()=>{fe(n.id),i()},children:`Discard`}),(0,Y.jsx)(D,{variant:`primary`,busy:s,busyLabel:`Saving`,disabled:h,onClick:()=>void g(),children:`Save to media`})]})]})]})}function ve({video:t,onSaved:n}){let r=$(t.jobId),i=q(t.jobId),a=Z(e=>e.forget),[o,s]=(0,J.useState)([]);K(t.jobId);let l=i??r.data?.job??null,u=(r.data?.candidates??[]).filter(e=>!o.includes(e.id));if(r.status===`error`&&!r.data){let n=h(r.error)&&r.error.status===404;return(0,Y.jsxs)(`li`,{className:`vid-job vid-job--error`,children:[(0,Y.jsxs)(`div`,{className:`vid-job__head`,children:[(0,Y.jsx)(e,{kind:`bang`}),(0,Y.jsxs)(`span`,{className:`vid-job__prompt`,children:[`“`,t.prompt,`”`]}),(0,Y.jsx)(T,{icon:`close`,label:`Dismiss`,onClick:()=>a(t.jobId)})]}),(0,Y.jsx)(`p`,{className:`vid-job__detail`,children:n?`This video isn’t known any more — the app was restarted or it expired. Nothing more will be charged for it.`:c(r.error).message})]})}if(!l)return(0,Y.jsx)(`li`,{className:`vid-job`,children:(0,Y.jsxs)(`div`,{className:`vid-job__head`,children:[(0,Y.jsx)(x,{label:`Reading`}),(0,Y.jsxs)(`span`,{className:`vid-job__prompt`,children:[`“`,t.prompt,`”`]})]})});let d=l.progress===void 0?null:Math.round(l.progress*100),f=l.state===`done`,p=f&&r.data&&!r.fetching&&u.length===0;return(0,Y.jsxs)(`li`,{className:`vid-job vid-job--${l.state}`,children:[(0,Y.jsxs)(`div`,{className:`vid-job__head`,children:[l.state===`running`?(0,Y.jsx)(x,{label:`Making the video`}):(0,Y.jsx)(e,{kind:f?`reg`:`bang`}),(0,Y.jsxs)(`span`,{className:`vid-job__prompt`,children:[`“`,t.prompt,`”`]}),l.state===`running`?null:(0,Y.jsx)(T,{icon:`close`,label:f&&u.length?`Discard and dismiss`:`Dismiss`,onClick:()=>{for(let e of u)fe(e.id);a(t.jobId)}})]}),(0,Y.jsxs)(`p`,{className:`vid-job__detail`,role:`status`,children:[l.detail??(l.state===`running`?`Working…`:f?`The video is ready.`:`Stopped.`),l.state===`error`?` Nothing was added to media.`:``]}),l.state===`running`?(0,Y.jsx)(`div`,{className:`app-progress`,role:`progressbar`,"aria-label":`Making “${t.prompt}”`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":d??void 0,children:(0,Y.jsx)(`span`,{className:d===null?`app-progress__bar app-progress__bar--indeterminate`:`app-progress__bar`,style:d===null?void 0:{inlineSize:`${d}%`}})}):null,f&&u.length>0?(0,Y.jsxs)(Y.Fragment,{children:[u.map(e=>(0,Y.jsx)(_e,{siteId:t.siteId,candidate:e,onGone:()=>{let n=u.filter(t=>t.id!==e.id);s(t=>[...t,e.id]),n.length===0&&a(t.jobId)},onSaved:r=>{let i=u.filter(t=>t.id!==e.id);s(t=>[...t,e.id]),i.length===0&&a(t.jobId),n(r)}},e.id)),(0,Y.jsxs)(`p`,{className:`g-hint`,children:[`Kept for `,2,` hours from when it was made, unless you save it.`]})]}):null,p?(0,Y.jsx)(`p`,{className:`g-hint`,children:`Nothing left to save from this one.`}):null]})}function ye({siteId:e,onSaved:t}){let n=Z(e=>e.tracked).filter(t=>t.siteId===e);return n.length===0?null:(0,Y.jsxs)(`section`,{className:`vid-jobs`,"aria-label":`Videos`,children:[(0,Y.jsx)(`h2`,{className:`g-eyebrow vid-jobs__title`,children:n.length===1?`Video`:`Videos`}),(0,Y.jsx)(`ul`,{className:`vid-jobs__list`,children:n.map(e=>(0,Y.jsx)(ve,{video:e,onSaved:t},e.jobId))})]})}var be=[{value:`all`,label:`All`},{value:`image`,label:`Images`},{value:`video`,label:`Videos`},{value:`document`,label:`Documents`}];function xe(){let{siteId:e=``}=n();z({crumbs:[{label:`Media`}]});let t=B(H.media(e),()=>M(`GET /api/sites/:siteId/media`,{params:{siteId:e}})),[r,i]=(0,J.useState)(`all`),[o,s]=(0,J.useState)(null),[l,u]=(0,J.useState)(!1),[d,p]=(0,J.useState)(!1),[m,h]=(0,J.useState)(null),ee=t.data?.items.find(e=>e.path===o)??null,_=async t=>{await M(`DELETE /api/sites/:siteId/media`,{params:{siteId:e},query:{path:t.path}}),R(H.media(e)),s(e=>e===t.path?null:e),t.status===`added`?E({tone:`neutral`,title:`${t.name} deleted`}):E({tone:`neutral`,title:`${t.name} deleted`,body:t.status===`modified`?`It leaves the site when you publish. Until then, Undo brings back the published version.`:`It leaves the site when you publish. Until then, Undo brings it back.`,action:{label:`Undo`,onClick:()=>void V.getState().discard([t.path]).then(()=>{R(H.media(e)),s(t.path),E({tone:`neutral`,title:`${t.name} is back`})}).catch(e=>E({tone:`danger`,title:`Couldn’t bring it back`,body:c(e).message}))}})};return(0,Y.jsxs)(`div`,{className:`app-screen app-media`,children:[(0,Y.jsx)(A,{title:`Media`,description:`Images and files the site uses. Drop files anywhere here, or paste an image.`,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(D,{variant:`secondary`,icon:`play`,onClick:()=>p(!0),children:`Generate a video`}),(0,Y.jsx)(D,{variant:`primary`,icon:`plus`,onClick:()=>u(!0),children:`Generate an image`})]})}),(0,Y.jsx)(ye,{siteId:e,onSaved:e=>{s(e.path),E({tone:`success`,title:`Video saved`,body:`“${e.name}” is in media, ready to use.`})}}),(0,Y.jsxs)(`div`,{className:`app-media__layout`,children:[(0,Y.jsx)(re,{siteId:e,kind:r,selected:o,onSelect:e=>s(e?.path??null),onGenerate:()=>u(!0),toolbar:(0,Y.jsx)(g,{label:`Show`,options:be,value:r,onChange:i})}),(0,Y.jsx)(ue,{siteId:e,item:ee,onDelete:e=>{e.status===`clean`?_(e).catch(e=>E({tone:`danger`,title:`Couldn’t delete the file`,body:c(e).message,detail:c(e).detail})):h(e)}})]}),(0,Y.jsx)(a,{open:l,onClose:()=>u(!1),title:`Generate an image`,size:`xl`,children:l?(0,Y.jsx)(N,{siteId:e,onSaved:e=>{u(!1),s(e.path),E({tone:`success`,title:`Image saved`,body:`“${e.name}” is in media, ready to use.`})}}):null}),(0,Y.jsx)(a,{open:d,onClose:()=>p(!1),title:`Generate a video`,size:`lg`,children:d?(0,Y.jsx)(ge,{siteId:e,onCancel:()=>p(!1),onStarted:()=>{p(!1),E({tone:`neutral`,title:`Making the video`,body:`It takes a few minutes. It waits at the top of Media when it’s ready — you can leave this screen.`})}}):null}),(0,Y.jsx)(f,{open:m!==null,onClose:()=>h(null),title:`Delete “${m?.name??``}”?`,body:m?.status===`added`?`It hasn’t been published, so once it’s deleted it can’t be brought back. Pages that use it will show a missing image.`:`Its unpublished changes are lost; Undo brings back only the published version. Pages that use it will show a missing image once this is published.`,confirmLabel:`Delete file`,busyLabel:`Deleting`,cancelLabel:`Keep it`,errorTitle:`Couldn’t delete the file`,onConfirm:()=>m?_(m):void 0})]})}export{xe as MediaScreen};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,A as t,Ft as n,H as r,I as i,Nt as a,O as o,St as s,bt as c,ct as l,g as u,gt as d,h as f,ht as p,j as m,kt as h,mt as g,n as _,pt as v,z as y}from"./ui-C6O2tW4c.js";import{n as b,s as x}from"./chrome-Brnq5kGb.js";import{t as S}from"./store-C95UZPFo.js";import{n as C,r as w,t as T}from"./jobs-BHawhnH2.js";import{B as E}from"./index-CtsAxi5d.js";var D=n(a(),1),O=[`name`,`starter`,`about`,`style`,`create`],k=[`Home`,`About`,`Services`,`Contact`],A=[`Warm and plain`,`Confident and direct`,`Calm and expert`,`Friendly and playful`],j=`#2F5D50`;function M(e=``){return{name:``,starter:e,description:``,audience:``,tone:``,pages:[...k],brandColor:j,notes:``}}var N=/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i,P=e=>N.test(e.trim());function F(e,t){let n=t.trim().replace(/\s+/g,` `);return!n||e.length>=12||e.some(e=>e.toLowerCase()===n.toLowerCase())?e:[...e,n.charAt(0).toUpperCase()+n.slice(1)]}function I(e,t){switch(e){case`name`:return/[\p{L}\p{N}]/u.test(t.name)?t.name.trim().length>100?`That name is too long. Keep it under 100 characters.`:null:`Give the site a name with at least one letter or number.`;case`starter`:return t.starter?null:`Choose a starter to begin from.`;case`about`:return t.description.trim().length<12?`Say what the organisation is and does in a sentence or two.`:null;case`style`:return t.pages.length===0?`Add at least one page.`:t.brandColor.trim()&&!P(t.brandColor)?`The brand colour should be a hex value like #2F5D50.`:null;case`create`:return O.slice(0,-1).map(e=>I(e,t)).find(e=>e!==null)??null}}function L(e){let t={description:e.description.trim()};return e.audience.trim()&&(t.audience=e.audience.trim()),e.tone.trim()&&(t.tone=e.tone.trim()),e.pages.length&&(t.pages=e.pages),P(e.brandColor)&&(t.brandColor=e.brandColor.trim()),e.notes.trim()&&(t.notes=e.notes.trim()),t}function R(e){return e.pages?.length?`Build the site from my brief: ${l(e.pages)}.`:`Build the site from my brief.`}var z=c();function B({heading:e,title:t,lede:n}){return(0,z.jsxs)(`header`,{className:`wizard-head`,children:[(0,z.jsx)(`h1`,{ref:e,tabIndex:-1,className:`wizard-title`,children:t}),(0,z.jsx)(`p`,{className:`wizard-lede`,children:n})]})}function V({draft:e,update:t,heading:n}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{heading:n,title:`What’s the site called?`,lede:`Usually the organisation’s name. You can change it later.`}),(0,z.jsx)(m,{label:`Site name`,children:(0,z.jsx)(o,{value:e.name,onChange:e=>t({name:e.target.value}),placeholder:`e.g. Harbour Dental`,autoComplete:`organization`,maxLength:100,"data-autofocus":!0})})]})}function H({draft:e,update:t,heading:n,starters:r}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{heading:n,title:`Start from…`,lede:`A starter is a complete site with sample pages. The assistant rewrites it for you.`}),r.loading?(0,z.jsx)(`div`,{"aria-busy":`true`,className:`wizard-starters`,children:(0,z.jsx)(u,{height:96})}):r.data?(0,z.jsxs)(`fieldset`,{className:`app-fieldset wizard-starters`,children:[(0,z.jsx)(`legend`,{className:`g-sr`,children:`Starter`}),r.data.map(n=>(0,z.jsxs)(`label`,{className:d(`app-model wizard-starter`,e.starter===n.id&&`app-model--checked`),children:[(0,z.jsx)(`input`,{type:`radio`,name:`starter`,className:`app-model__radio`,checked:e.starter===n.id,onChange:()=>t({starter:n.id})}),(0,z.jsxs)(`span`,{className:`app-model__text`,children:[(0,z.jsx)(`span`,{className:`app-model__name`,children:n.name}),(0,z.jsx)(`span`,{className:`app-model__blurb`,children:n.description})]}),n.previewUrl?(0,z.jsx)(`img`,{className:`wizard-starter__image`,src:n.previewUrl,alt:``}):(0,z.jsx)(`span`,{className:`g-tag`,children:n.framework})]},n.id))]}):(0,z.jsx)(i,{compact:!0,title:`Couldn’t list the starters`,error:r.error,onRetry:()=>void r.refetch()}),(0,z.jsxs)(`label`,{className:d(`app-model wizard-starter wizard-from-wp`,e.fromWordPress&&`app-model--checked`),children:[(0,z.jsx)(`input`,{type:`checkbox`,className:`wizard-from-wp__check`,checked:!!e.fromWordPress,onChange:e=>t({fromWordPress:e.target.checked})}),(0,z.jsxs)(`span`,{className:`app-model__text`,children:[(0,z.jsx)(`span`,{className:`app-model__name`,children:`Start from my WordPress site`}),(0,z.jsx)(`span`,{className:`app-model__blurb`,children:`The starter gives the design; your WordPress posts, pages and images are brought into it next, as changes you check before anything goes live.`})]})]})]})}function U({draft:e,update:n,heading:r}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{heading:r,title:`What does ${e.name.trim()||`the organisation`} do?`,lede:`A few plain sentences are enough. The assistant writes every page from them.`}),(0,z.jsx)(m,{label:`What it is and does`,hint:`Who you are, what you offer, where`,children:(0,z.jsx)(t,{value:e.description,onChange:e=>n({description:e.target.value}),rows:4,maxRows:10,placeholder:`e.g. A family dental practice in the town centre, open six days a week, with early and late appointments.`,"data-autofocus":!0})}),(0,z.jsx)(m,{label:`Who it’s for`,hint:`Optional`,children:(0,z.jsx)(o,{value:e.audience,onChange:e=>n({audience:e.target.value}),placeholder:`e.g. Families nearby looking for a new dentist`})})]})}function W({draft:n,update:r,heading:i}){let[a,s]=(0,D.useState)(``),c=()=>{r({pages:F(n.pages,a)}),s(``)},l=P(n.brandColor)?n.brandColor:j;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{heading:i,title:`How should it sound and look?`,lede:`Pick what fits; everything here can be changed later.`}),(0,z.jsx)(m,{label:`Tone of voice`,group:!0,children:(0,z.jsx)(`div`,{className:`g-quick-replies wizard-tones`,children:A.map(t=>(0,z.jsxs)(`button`,{type:`button`,className:`g-chip`,"aria-pressed":n.tone===t,onClick:()=>r({tone:n.tone===t?``:t}),children:[n.tone===t?(0,z.jsx)(e,{kind:`caret`,tone:`insert`}):null,t]},t))})}),(0,z.jsx)(m,{label:`Pages`,group:!0,hint:`Up to 12. Remove any you don’t need.`,children:(0,z.jsxs)(`div`,{className:`wizard-pages`,children:[(0,z.jsx)(`ul`,{className:`wizard-pages__list`,"aria-label":`Pages`,children:n.pages.map(e=>(0,z.jsxs)(`li`,{className:`wizard-page`,children:[(0,z.jsx)(`span`,{children:e}),(0,z.jsx)(g,{icon:`close`,label:`Remove ${e}`,size:`sm`,tooltip:!1,onClick:()=>r({pages:n.pages.filter(t=>t!==e)})})]},e))}),(0,z.jsxs)(`span`,{className:`wizard-pages__add`,children:[(0,z.jsx)(o,{size:`sm`,value:a,"aria-label":`Add a page`,placeholder:`Add a page`,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),c())}}),(0,z.jsx)(g,{icon:`plus`,label:`Add page`,onClick:c,disabled:!a.trim()})]})]})}),(0,z.jsx)(m,{label:`Brand colour`,hint:`A hex value, like #2F5D50`,children:(0,z.jsxs)(`span`,{className:`wizard-color`,children:[(0,z.jsx)(`input`,{type:`color`,className:`wizard-color__swatch`,value:l,"aria-label":`Pick the brand colour`,onChange:e=>r({brandColor:e.target.value.toUpperCase()})}),(0,z.jsx)(o,{mono:!0,value:n.brandColor,onChange:e=>r({brandColor:e.target.value}),maxLength:7})]})}),(0,z.jsx)(m,{label:`Anything else`,hint:`Optional: opening hours, things to avoid, a site you like`,children:(0,z.jsx)(t,{value:n.notes,onChange:e=>r({notes:e.target.value}),rows:2,maxRows:6})})]})}function G({draft:t,heading:n,keyReady:r}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{heading:n,title:`Ready to create ${t.name.trim()}.`,lede:r===!1?`One thing first: the assistant isn’t connected yet.`:`The starter is copied, then the assistant builds the site from your brief while the preview fills in.`}),(0,z.jsxs)(`dl`,{className:`wizard-summary`,children:[(0,z.jsx)(`dt`,{children:`About`}),(0,z.jsx)(`dd`,{children:t.description.trim()}),t.audience.trim()?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{children:`For`}),(0,z.jsx)(`dd`,{children:t.audience.trim()})]}):null,t.tone?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{children:`Tone`}),(0,z.jsx)(`dd`,{children:t.tone})]}):null,(0,z.jsx)(`dt`,{children:`Pages`}),(0,z.jsx)(`dd`,{children:l(t.pages)}),P(t.brandColor)?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{children:`Colour`}),(0,z.jsxs)(`dd`,{className:`wizard-summary__color`,children:[(0,z.jsx)(`span`,{className:`wizard-summary__swatch`,style:{background:t.brandColor},"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`g-mono`,children:t.brandColor})]})]}):null]}),r===!1?(0,z.jsxs)(`div`,{className:`wizard-nokey`,role:`note`,children:[(0,z.jsx)(e,{kind:`reg`}),(0,z.jsx)(`p`,{children:`Without it, the site is created exactly as the starter is, and you edit it by hand — in the form, or by clicking text on the page. Add an API key in Settings first and the assistant will build it from this brief. The brief is kept while you’re away.`})]}):null]})}var K=`galley.newSite`,q={name:`Name`,starter:`Starter`,about:`About`,style:`Look and pages`,create:`Create`};function J(){try{let e=sessionStorage.getItem(K);return e?{...M(),...JSON.parse(e)}:M()}catch{return M()}}function Y({jobId:t,draft:n,withBrief:a,onBack:o}){let s=h(),c=T(t);w(t);let l=(0,D.useRef)(!1);if((0,D.useEffect)(()=>{if(!c||c.state!==`done`||!c.siteId||l.current)return;l.current=!0;let e=c.siteId;C.getState().dismiss(c.id),sessionStorage.removeItem(K),c.detail&&c.detail!==`The site is ready.`&&_({tone:`warning`,title:`Created, with one problem`,body:c.detail});let t=()=>s(`/sites/${e}/edit`);if(n.fromWordPress){s(`/sites/${e}/import?from=new`);return}if(!a){S.getState().setThread(e,null),t();return}let i=L(n);(async()=>{try{let t=await y(`POST /api/sites/:siteId/threads`,{params:{siteId:e},body:{mode:`build`,title:`Build ${n.name.trim()}`}});S.getState().setThread(e,t.id),S.getState().confirmBuild(e),await y(`POST /api/sites/:siteId/threads/:threadId/messages`,{params:{siteId:e,threadId:t.id},body:{text:R(i),mode:`build`,brief:i}})}catch(e){_({tone:`warning`,title:`The site is ready, but the assistant didn’t start`,body:`${r(e).message} You can ask it from the editor.`})}t()})()},[c,n,a,s]),c?.state===`error`)return(0,z.jsx)(`div`,{className:`wizard-progress`,children:(0,z.jsx)(i,{title:`Couldn’t create the site`,message:c.detail??`The starter couldn’t be copied.`,onRetry:o,retryLabel:`Back to the brief`})});let u=c?.progress??0,d=[{label:`Copying the starter`,done:u>=.3},{label:`Installing what the site needs`,done:c?.state===`done`,active:u>=.3},{label:n.fromWordPress?`Opening the WordPress import`:a?`Opening the editor and starting the assistant`:`Opening the editor`,done:!1,active:c?.state===`done`}];return(0,z.jsxs)(`div`,{className:`wizard-progress`,"aria-busy":`true`,children:[(0,z.jsx)(`p`,{className:`g-eyebrow`,children:`New site`}),(0,z.jsx)(`h1`,{className:`wizard-title`,children:`Setting up ${n.name.trim()}…`}),(0,z.jsx)(`p`,{className:`wizard-lede`,children:`The first install can take a few minutes. You can leave this screen; the site appears in Sites when it’s ready.`}),(0,z.jsx)(`ol`,{className:`wizard-phases`,children:d.map((t,n)=>{let r=!t.done&&(n===0||!!t.active);return(0,z.jsxs)(`li`,{className:t.done?`wizard-phase wizard-phase--done`:r?`wizard-phase wizard-phase--running`:`wizard-phase`,children:[t.done?(0,z.jsx)(e,{kind:`caret`,tone:`insert`,label:`Done`}):r?(0,z.jsx)(f,{label:`Working`}):(0,z.jsx)(`span`,{className:`wizard-phase__dot`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{children:t.label})]},t.label)})}),(0,z.jsx)(`div`,{className:`app-progress`,role:`progressbar`,"aria-label":`Setting up the site`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(u*100),children:(0,z.jsx)(`span`,{className:`app-progress__bar`,style:{inlineSize:`${Math.max(4,Math.round(u*100))}%`}})}),c?.detail?(0,z.jsx)(`p`,{className:`wizard-detail g-mono`,children:c.detail}):null]})}function X(){b({crumbs:[{label:`Sites`,to:`/`},{label:`New site`}]});let t=x(E.starters(),()=>y(`GET /api/starters`)),n=x(E.settings(),()=>y(`GET /api/settings`)),i=n.data?n.data.secrets.some(e=>e.name===`anthropic`&&e.configured):null,[a,o]=(0,D.useState)(J),[c,l]=(0,D.useState)(`name`),[u,d]=(0,D.useState)(null),[f,m]=(0,D.useState)(null),[h,g]=(0,D.useState)(null),_=(0,D.useRef)(null);(0,D.useEffect)(()=>{try{sessionStorage.setItem(K,JSON.stringify(a))}catch{}},[a]),(0,D.useEffect)(()=>{let e=t.data?.[0];e&&!t.data?.some(e=>e.id===a.starter)&&o(t=>({...t,starter:e.id}))},[t.data,a.starter]),(0,D.useEffect)(()=>_.current?.focus(),[c]);let S=e=>{d(null),o(t=>({...t,...e}))},w=O.indexOf(c),T=()=>{let e=I(c,a);if(e){d(e);return}let t=c===`starter`&&a.fromWordPress?`create`:O[w+1];t&&l(t)},k=()=>{d(null);let e=c===`create`&&a.fromWordPress?`starter`:O[w-1];e&&l(e)},A=async e=>{let t=e?I(`create`,a):I(`name`,a)??I(`starter`,a);if(t)d(t);else{m(e?`brief`:`plain`);try{let t=await y(`POST /api/sites/create`,{body:{name:a.name.trim(),starter:a.starter,...e?{brief:L(a)}:{}}});C.getState().upsert(t),g({id:t.id,withBrief:e})}catch(e){d(r(e).message)}finally{m(null)}}};return h?(0,z.jsx)(Y,{jobId:h.id,draft:a,withBrief:h.withBrief,onBack:()=>g(null)}):(0,z.jsx)(`div`,{className:`app-screen wizard`,children:(0,z.jsxs)(`div`,{className:`wizard-sheet`,children:[(0,z.jsx)(`ol`,{className:`wizard-steps`,"aria-label":`Steps`,children:O.map((e,t)=>(0,z.jsxs)(`li`,{className:t===w?`wizard-step wizard-step--current`:t<w?`wizard-step wizard-step--done`:`wizard-step`,"aria-current":t===w?`step`:void 0,children:[(0,z.jsx)(`span`,{className:`wizard-step__number`,children:t+1}),(0,z.jsx)(`span`,{className:`wizard-step__label`,children:q[e]})]},e))}),(0,z.jsxs)(`form`,{className:`wizard-form`,onSubmit:e=>{e.preventDefault(),c===`create`?A(i!==!1&&!a.fromWordPress):T()},children:[c===`name`?(0,z.jsx)(V,{draft:a,update:S,heading:_}):null,c===`starter`?(0,z.jsx)(H,{draft:a,update:S,heading:_,starters:t}):null,c===`about`?(0,z.jsx)(U,{draft:a,update:S,heading:_}):null,c===`style`?(0,z.jsx)(W,{draft:a,update:S,heading:_}):null,c===`create`&&!a.fromWordPress?(0,z.jsx)(G,{draft:a,heading:_,keyReady:i}):null,c===`create`&&a.fromWordPress?(0,z.jsxs)(`header`,{className:`wizard-head`,children:[(0,z.jsx)(`h1`,{ref:_,tabIndex:-1,className:`wizard-title`,children:`Create ${a.name.trim()}, then bring your WordPress site in`}),(0,z.jsx)(`p`,{className:`wizard-lede`,children:`The starter is copied first. Then you point at your WordPress site — its address or an export file — see what will come across, and bring it over.`})]}):null,u?(0,z.jsxs)(`p`,{className:`g-error-text wizard-problem`,role:`alert`,children:[(0,z.jsx)(e,{kind:`bang`}),(0,z.jsx)(`span`,{children:u})]}):null,(0,z.jsxs)(`div`,{className:`wizard-actions`,children:[w>0?(0,z.jsx)(v,{type:`button`,variant:`quiet`,onClick:k,children:`Back`}):(0,z.jsx)(s,{className:p(`quiet`,`md`),to:`/`,children:`Not now`}),(0,z.jsx)(`span`,{className:`g-toolbar__spacer`}),c===`create`?a.fromWordPress?(0,z.jsx)(v,{type:`submit`,variant:`primary`,busy:f===`plain`,busyLabel:`Creating…`,children:`Create and continue`}):i===!1?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(v,{type:`button`,variant:`secondary`,busy:f===`plain`,busyLabel:`Creating…`,onClick:()=>void A(!1),children:`Create the starter as it is`}),(0,z.jsx)(s,{className:p(`primary`,`md`),to:`/settings`,children:`Add a key first`})]}):(0,z.jsx)(v,{type:`submit`,variant:`primary`,busy:f===`brief`,busyLabel:`Creating…`,disabled:i===null,children:`Create site`}):(0,z.jsx)(v,{type:`submit`,variant:`primary`,children:`Continue`})]})]})]})})}export{X as NewSiteScreen};
|
|
1
|
+
import{$ as e,A as t,Ft as n,H as r,I as i,Nt as a,O as o,St as s,bt as c,ct as l,g as u,gt as d,h as f,ht as p,j as m,kt as h,mt as g,n as _,pt as v,z as y}from"./ui-C6O2tW4c.js";import{n as b,s as x}from"./chrome-Brnq5kGb.js";import{t as S}from"./store-C95UZPFo.js";import{n as C,r as w,t as T}from"./jobs-BHawhnH2.js";import{B as E}from"./index-A7aTfJ-x.js";var D=n(a(),1),O=[`name`,`starter`,`about`,`style`,`create`],k=[`Home`,`About`,`Services`,`Contact`],A=[`Warm and plain`,`Confident and direct`,`Calm and expert`,`Friendly and playful`],j=`#2F5D50`;function M(e=``){return{name:``,starter:e,description:``,audience:``,tone:``,pages:[...k],brandColor:j,notes:``}}var N=/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i,P=e=>N.test(e.trim());function F(e,t){let n=t.trim().replace(/\s+/g,` `);return!n||e.length>=12||e.some(e=>e.toLowerCase()===n.toLowerCase())?e:[...e,n.charAt(0).toUpperCase()+n.slice(1)]}function I(e,t){switch(e){case`name`:return/[\p{L}\p{N}]/u.test(t.name)?t.name.trim().length>100?`That name is too long. Keep it under 100 characters.`:null:`Give the site a name with at least one letter or number.`;case`starter`:return t.starter?null:`Choose a starter to begin from.`;case`about`:return t.description.trim().length<12?`Say what the organisation is and does in a sentence or two.`:null;case`style`:return t.pages.length===0?`Add at least one page.`:t.brandColor.trim()&&!P(t.brandColor)?`The brand colour should be a hex value like #2F5D50.`:null;case`create`:return O.slice(0,-1).map(e=>I(e,t)).find(e=>e!==null)??null}}function L(e){let t={description:e.description.trim()};return e.audience.trim()&&(t.audience=e.audience.trim()),e.tone.trim()&&(t.tone=e.tone.trim()),e.pages.length&&(t.pages=e.pages),P(e.brandColor)&&(t.brandColor=e.brandColor.trim()),e.notes.trim()&&(t.notes=e.notes.trim()),t}function R(e){return e.pages?.length?`Build the site from my brief: ${l(e.pages)}.`:`Build the site from my brief.`}var z=c();function B({heading:e,title:t,lede:n}){return(0,z.jsxs)(`header`,{className:`wizard-head`,children:[(0,z.jsx)(`h1`,{ref:e,tabIndex:-1,className:`wizard-title`,children:t}),(0,z.jsx)(`p`,{className:`wizard-lede`,children:n})]})}function V({draft:e,update:t,heading:n}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{heading:n,title:`What’s the site called?`,lede:`Usually the organisation’s name. You can change it later.`}),(0,z.jsx)(m,{label:`Site name`,children:(0,z.jsx)(o,{value:e.name,onChange:e=>t({name:e.target.value}),placeholder:`e.g. Harbour Dental`,autoComplete:`organization`,maxLength:100,"data-autofocus":!0})})]})}function H({draft:e,update:t,heading:n,starters:r}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{heading:n,title:`Start from…`,lede:`A starter is a complete site with sample pages. The assistant rewrites it for you.`}),r.loading?(0,z.jsx)(`div`,{"aria-busy":`true`,className:`wizard-starters`,children:(0,z.jsx)(u,{height:96})}):r.data?(0,z.jsxs)(`fieldset`,{className:`app-fieldset wizard-starters`,children:[(0,z.jsx)(`legend`,{className:`g-sr`,children:`Starter`}),r.data.map(n=>(0,z.jsxs)(`label`,{className:d(`app-model wizard-starter`,e.starter===n.id&&`app-model--checked`),children:[(0,z.jsx)(`input`,{type:`radio`,name:`starter`,className:`app-model__radio`,checked:e.starter===n.id,onChange:()=>t({starter:n.id})}),(0,z.jsxs)(`span`,{className:`app-model__text`,children:[(0,z.jsx)(`span`,{className:`app-model__name`,children:n.name}),(0,z.jsx)(`span`,{className:`app-model__blurb`,children:n.description})]}),n.previewUrl?(0,z.jsx)(`img`,{className:`wizard-starter__image`,src:n.previewUrl,alt:``}):(0,z.jsx)(`span`,{className:`g-tag`,children:n.framework})]},n.id))]}):(0,z.jsx)(i,{compact:!0,title:`Couldn’t list the starters`,error:r.error,onRetry:()=>void r.refetch()}),(0,z.jsxs)(`label`,{className:d(`app-model wizard-starter wizard-from-wp`,e.fromWordPress&&`app-model--checked`),children:[(0,z.jsx)(`input`,{type:`checkbox`,className:`wizard-from-wp__check`,checked:!!e.fromWordPress,onChange:e=>t({fromWordPress:e.target.checked})}),(0,z.jsxs)(`span`,{className:`app-model__text`,children:[(0,z.jsx)(`span`,{className:`app-model__name`,children:`Start from my WordPress site`}),(0,z.jsx)(`span`,{className:`app-model__blurb`,children:`The starter gives the design; your WordPress posts, pages and images are brought into it next, as changes you check before anything goes live.`})]})]})]})}function U({draft:e,update:n,heading:r}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{heading:r,title:`What does ${e.name.trim()||`the organisation`} do?`,lede:`A few plain sentences are enough. The assistant writes every page from them.`}),(0,z.jsx)(m,{label:`What it is and does`,hint:`Who you are, what you offer, where`,children:(0,z.jsx)(t,{value:e.description,onChange:e=>n({description:e.target.value}),rows:4,maxRows:10,placeholder:`e.g. A family dental practice in the town centre, open six days a week, with early and late appointments.`,"data-autofocus":!0})}),(0,z.jsx)(m,{label:`Who it’s for`,hint:`Optional`,children:(0,z.jsx)(o,{value:e.audience,onChange:e=>n({audience:e.target.value}),placeholder:`e.g. Families nearby looking for a new dentist`})})]})}function W({draft:n,update:r,heading:i}){let[a,s]=(0,D.useState)(``),c=()=>{r({pages:F(n.pages,a)}),s(``)},l=P(n.brandColor)?n.brandColor:j;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{heading:i,title:`How should it sound and look?`,lede:`Pick what fits; everything here can be changed later.`}),(0,z.jsx)(m,{label:`Tone of voice`,group:!0,children:(0,z.jsx)(`div`,{className:`g-quick-replies wizard-tones`,children:A.map(t=>(0,z.jsxs)(`button`,{type:`button`,className:`g-chip`,"aria-pressed":n.tone===t,onClick:()=>r({tone:n.tone===t?``:t}),children:[n.tone===t?(0,z.jsx)(e,{kind:`caret`,tone:`insert`}):null,t]},t))})}),(0,z.jsx)(m,{label:`Pages`,group:!0,hint:`Up to 12. Remove any you don’t need.`,children:(0,z.jsxs)(`div`,{className:`wizard-pages`,children:[(0,z.jsx)(`ul`,{className:`wizard-pages__list`,"aria-label":`Pages`,children:n.pages.map(e=>(0,z.jsxs)(`li`,{className:`wizard-page`,children:[(0,z.jsx)(`span`,{children:e}),(0,z.jsx)(g,{icon:`close`,label:`Remove ${e}`,size:`sm`,tooltip:!1,onClick:()=>r({pages:n.pages.filter(t=>t!==e)})})]},e))}),(0,z.jsxs)(`span`,{className:`wizard-pages__add`,children:[(0,z.jsx)(o,{size:`sm`,value:a,"aria-label":`Add a page`,placeholder:`Add a page`,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),c())}}),(0,z.jsx)(g,{icon:`plus`,label:`Add page`,onClick:c,disabled:!a.trim()})]})]})}),(0,z.jsx)(m,{label:`Brand colour`,hint:`A hex value, like #2F5D50`,children:(0,z.jsxs)(`span`,{className:`wizard-color`,children:[(0,z.jsx)(`input`,{type:`color`,className:`wizard-color__swatch`,value:l,"aria-label":`Pick the brand colour`,onChange:e=>r({brandColor:e.target.value.toUpperCase()})}),(0,z.jsx)(o,{mono:!0,value:n.brandColor,onChange:e=>r({brandColor:e.target.value}),maxLength:7})]})}),(0,z.jsx)(m,{label:`Anything else`,hint:`Optional: opening hours, things to avoid, a site you like`,children:(0,z.jsx)(t,{value:n.notes,onChange:e=>r({notes:e.target.value}),rows:2,maxRows:6})})]})}function G({draft:t,heading:n,keyReady:r}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{heading:n,title:`Ready to create ${t.name.trim()}.`,lede:r===!1?`One thing first: the assistant isn’t connected yet.`:`The starter is copied, then the assistant builds the site from your brief while the preview fills in.`}),(0,z.jsxs)(`dl`,{className:`wizard-summary`,children:[(0,z.jsx)(`dt`,{children:`About`}),(0,z.jsx)(`dd`,{children:t.description.trim()}),t.audience.trim()?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{children:`For`}),(0,z.jsx)(`dd`,{children:t.audience.trim()})]}):null,t.tone?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{children:`Tone`}),(0,z.jsx)(`dd`,{children:t.tone})]}):null,(0,z.jsx)(`dt`,{children:`Pages`}),(0,z.jsx)(`dd`,{children:l(t.pages)}),P(t.brandColor)?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{children:`Colour`}),(0,z.jsxs)(`dd`,{className:`wizard-summary__color`,children:[(0,z.jsx)(`span`,{className:`wizard-summary__swatch`,style:{background:t.brandColor},"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`g-mono`,children:t.brandColor})]})]}):null]}),r===!1?(0,z.jsxs)(`div`,{className:`wizard-nokey`,role:`note`,children:[(0,z.jsx)(e,{kind:`reg`}),(0,z.jsx)(`p`,{children:`Without it, the site is created exactly as the starter is, and you edit it by hand — in the form, or by clicking text on the page. Add an API key in Settings first and the assistant will build it from this brief. The brief is kept while you’re away.`})]}):null]})}var K=`galley.newSite`,q={name:`Name`,starter:`Starter`,about:`About`,style:`Look and pages`,create:`Create`};function J(){try{let e=sessionStorage.getItem(K);return e?{...M(),...JSON.parse(e)}:M()}catch{return M()}}function Y({jobId:t,draft:n,withBrief:a,onBack:o}){let s=h(),c=T(t);w(t);let l=(0,D.useRef)(!1);if((0,D.useEffect)(()=>{if(!c||c.state!==`done`||!c.siteId||l.current)return;l.current=!0;let e=c.siteId;C.getState().dismiss(c.id),sessionStorage.removeItem(K),c.detail&&c.detail!==`The site is ready.`&&_({tone:`warning`,title:`Created, with one problem`,body:c.detail});let t=()=>s(`/sites/${e}/edit`);if(n.fromWordPress){s(`/sites/${e}/import?from=new`);return}if(!a){S.getState().setThread(e,null),t();return}let i=L(n);(async()=>{try{let t=await y(`POST /api/sites/:siteId/threads`,{params:{siteId:e},body:{mode:`build`,title:`Build ${n.name.trim()}`}});S.getState().setThread(e,t.id),S.getState().confirmBuild(e),await y(`POST /api/sites/:siteId/threads/:threadId/messages`,{params:{siteId:e,threadId:t.id},body:{text:R(i),mode:`build`,brief:i}})}catch(e){_({tone:`warning`,title:`The site is ready, but the assistant didn’t start`,body:`${r(e).message} You can ask it from the editor.`})}t()})()},[c,n,a,s]),c?.state===`error`)return(0,z.jsx)(`div`,{className:`wizard-progress`,children:(0,z.jsx)(i,{title:`Couldn’t create the site`,message:c.detail??`The starter couldn’t be copied.`,onRetry:o,retryLabel:`Back to the brief`})});let u=c?.progress??0,d=[{label:`Copying the starter`,done:u>=.3},{label:`Installing what the site needs`,done:c?.state===`done`,active:u>=.3},{label:n.fromWordPress?`Opening the WordPress import`:a?`Opening the editor and starting the assistant`:`Opening the editor`,done:!1,active:c?.state===`done`}];return(0,z.jsxs)(`div`,{className:`wizard-progress`,"aria-busy":`true`,children:[(0,z.jsx)(`p`,{className:`g-eyebrow`,children:`New site`}),(0,z.jsx)(`h1`,{className:`wizard-title`,children:`Setting up ${n.name.trim()}…`}),(0,z.jsx)(`p`,{className:`wizard-lede`,children:`The first install can take a few minutes. You can leave this screen; the site appears in Sites when it’s ready.`}),(0,z.jsx)(`ol`,{className:`wizard-phases`,children:d.map((t,n)=>{let r=!t.done&&(n===0||!!t.active);return(0,z.jsxs)(`li`,{className:t.done?`wizard-phase wizard-phase--done`:r?`wizard-phase wizard-phase--running`:`wizard-phase`,children:[t.done?(0,z.jsx)(e,{kind:`caret`,tone:`insert`,label:`Done`}):r?(0,z.jsx)(f,{label:`Working`}):(0,z.jsx)(`span`,{className:`wizard-phase__dot`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{children:t.label})]},t.label)})}),(0,z.jsx)(`div`,{className:`app-progress`,role:`progressbar`,"aria-label":`Setting up the site`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(u*100),children:(0,z.jsx)(`span`,{className:`app-progress__bar`,style:{inlineSize:`${Math.max(4,Math.round(u*100))}%`}})}),c?.detail?(0,z.jsx)(`p`,{className:`wizard-detail g-mono`,children:c.detail}):null]})}function X(){b({crumbs:[{label:`Sites`,to:`/`},{label:`New site`}]});let t=x(E.starters(),()=>y(`GET /api/starters`)),n=x(E.settings(),()=>y(`GET /api/settings`)),i=n.data?n.data.secrets.some(e=>e.name===`anthropic`&&e.configured):null,[a,o]=(0,D.useState)(J),[c,l]=(0,D.useState)(`name`),[u,d]=(0,D.useState)(null),[f,m]=(0,D.useState)(null),[h,g]=(0,D.useState)(null),_=(0,D.useRef)(null);(0,D.useEffect)(()=>{try{sessionStorage.setItem(K,JSON.stringify(a))}catch{}},[a]),(0,D.useEffect)(()=>{let e=t.data?.[0];e&&!t.data?.some(e=>e.id===a.starter)&&o(t=>({...t,starter:e.id}))},[t.data,a.starter]),(0,D.useEffect)(()=>_.current?.focus(),[c]);let S=e=>{d(null),o(t=>({...t,...e}))},w=O.indexOf(c),T=()=>{let e=I(c,a);if(e){d(e);return}let t=c===`starter`&&a.fromWordPress?`create`:O[w+1];t&&l(t)},k=()=>{d(null);let e=c===`create`&&a.fromWordPress?`starter`:O[w-1];e&&l(e)},A=async e=>{let t=e?I(`create`,a):I(`name`,a)??I(`starter`,a);if(t)d(t);else{m(e?`brief`:`plain`);try{let t=await y(`POST /api/sites/create`,{body:{name:a.name.trim(),starter:a.starter,...e?{brief:L(a)}:{}}});C.getState().upsert(t),g({id:t.id,withBrief:e})}catch(e){d(r(e).message)}finally{m(null)}}};return h?(0,z.jsx)(Y,{jobId:h.id,draft:a,withBrief:h.withBrief,onBack:()=>g(null)}):(0,z.jsx)(`div`,{className:`app-screen wizard`,children:(0,z.jsxs)(`div`,{className:`wizard-sheet`,children:[(0,z.jsx)(`ol`,{className:`wizard-steps`,"aria-label":`Steps`,children:O.map((e,t)=>(0,z.jsxs)(`li`,{className:t===w?`wizard-step wizard-step--current`:t<w?`wizard-step wizard-step--done`:`wizard-step`,"aria-current":t===w?`step`:void 0,children:[(0,z.jsx)(`span`,{className:`wizard-step__number`,children:t+1}),(0,z.jsx)(`span`,{className:`wizard-step__label`,children:q[e]})]},e))}),(0,z.jsxs)(`form`,{className:`wizard-form`,onSubmit:e=>{e.preventDefault(),c===`create`?A(i!==!1&&!a.fromWordPress):T()},children:[c===`name`?(0,z.jsx)(V,{draft:a,update:S,heading:_}):null,c===`starter`?(0,z.jsx)(H,{draft:a,update:S,heading:_,starters:t}):null,c===`about`?(0,z.jsx)(U,{draft:a,update:S,heading:_}):null,c===`style`?(0,z.jsx)(W,{draft:a,update:S,heading:_}):null,c===`create`&&!a.fromWordPress?(0,z.jsx)(G,{draft:a,heading:_,keyReady:i}):null,c===`create`&&a.fromWordPress?(0,z.jsxs)(`header`,{className:`wizard-head`,children:[(0,z.jsx)(`h1`,{ref:_,tabIndex:-1,className:`wizard-title`,children:`Create ${a.name.trim()}, then bring your WordPress site in`}),(0,z.jsx)(`p`,{className:`wizard-lede`,children:`The starter is copied first. Then you point at your WordPress site — its address or an export file — see what will come across, and bring it over.`})]}):null,u?(0,z.jsxs)(`p`,{className:`g-error-text wizard-problem`,role:`alert`,children:[(0,z.jsx)(e,{kind:`bang`}),(0,z.jsx)(`span`,{children:u})]}):null,(0,z.jsxs)(`div`,{className:`wizard-actions`,children:[w>0?(0,z.jsx)(v,{type:`button`,variant:`quiet`,onClick:k,children:`Back`}):(0,z.jsx)(s,{className:p(`quiet`,`md`),to:`/`,children:`Not now`}),(0,z.jsx)(`span`,{className:`g-toolbar__spacer`}),c===`create`?a.fromWordPress?(0,z.jsx)(v,{type:`submit`,variant:`primary`,busy:f===`plain`,busyLabel:`Creating…`,children:`Create and continue`}):i===!1?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(v,{type:`button`,variant:`secondary`,busy:f===`plain`,busyLabel:`Creating…`,onClick:()=>void A(!1),children:`Create the starter as it is`}),(0,z.jsx)(s,{className:p(`primary`,`md`),to:`/settings`,children:`Add a key first`})]}):(0,z.jsx)(v,{type:`submit`,variant:`primary`,busy:f===`brief`,busyLabel:`Creating…`,disabled:i===null,children:`Create site`}):(0,z.jsx)(v,{type:`submit`,variant:`primary`,children:`Continue`})]})]})]})})}export{X as NewSiteScreen};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{At as e,Ft as t,H as n,I as r,N as i,Nt as a,St as o,a as s,bt as c,c as l,et as u,ft as d,g as f,ht as p,it as m,mt as h,n as g,pt as _,tt as v,v as y,vt as b,z as x}from"./ui-C6O2tW4c.js";import{n as S,s as C}from"./chrome-Brnq5kGb.js";import{B as w,a as T,c as E,d as D,f as O,g as k,h as A,i as j,l as M,n as N,o as P,p as F,r as I,s as L,u as R}from"./index-
|
|
1
|
+
import{At as e,Ft as t,H as n,I as r,N as i,Nt as a,St as o,a as s,bt as c,c as l,et as u,ft as d,g as f,ht as p,it as m,mt as h,n as g,pt as _,tt as v,v as y,vt as b,z as x}from"./ui-C6O2tW4c.js";import{n as S,s as C}from"./chrome-Brnq5kGb.js";import{B as w,a as T,c as E,d as D,f as O,g as k,h as A,i as j,l as M,n as N,o as P,p as F,r as I,s as L,u as R}from"./index-A7aTfJ-x.js";var z=t(a(),1),B=c(),V=`Putting the published version live`;function H({siteId:e,variant:t=`home`,listLink:i=!0}){let a=L(e),c=E(),l=a.data,u=A(l,a.job),m=l?.config,[v,y]=(0,z.useState)(null);return a.loading?(0,B.jsx)(f,{height:120}):l?(0,B.jsx)(`div`,{className:`app-card app-card--pad deploy-card`,children:m?(0,B.jsxs)(B.Fragment,{children:[l.production?(0,B.jsxs)(`a`,{className:`deploy-card__address`,href:l.production.url,target:`_blank`,rel:`noopener noreferrer`,children:[F(l.production.url),(0,B.jsx)(b,{name:`external`})]}):null,(0,B.jsx)(`p`,{className:`deploy-card__line deploy-card__line--${u.tone}`,children:u.tone===`success`&&l.production?`Live · updated ${d(l.production.createdAt)}`:u.text}),a.job?.state===`running`?(0,B.jsx)(D,{job:a.job,intent:a.job.label.startsWith(`Making`)?`preview`:`production`}):null,(0,B.jsxs)(`p`,{className:`g-hint`,children:[`On `,k(c.data,m.target),` · project `,(0,B.jsx)(`span`,{className:`g-mono`,children:m.project})]}),(0,B.jsxs)(`div`,{className:`deploy-card__actions`,children:[l.behind!==0||!l.production?(0,B.jsx)(_,{variant:`primary`,size:`sm`,disabled:a.job?.state===`running`,onClick:()=>void N(e),children:`Put live`}):null,l.production?(0,B.jsx)(h,{icon:`copy`,label:`Copy the address`,onClick:()=>O(l.production.url)}):null,t===`home`?(0,B.jsx)(I,{siteId:e}):null,i?(0,B.jsx)(o,{className:p(`quiet`,`sm`),to:`/sites/${e}/online`,children:`Deployments`}):null]}),t===`settings`?(0,B.jsx)(j,{siteId:e}):null,t===`settings`?(0,B.jsxs)(`div`,{className:`deploy-card__settings`,children:[(0,B.jsx)(s,{checked:v??!!m.autoDeploy,onChange:t=>{y(t),P(e,t).catch(e=>g({tone:`danger`,title:`Couldn’t change that`,body:n(e).message})).finally(()=>y(null))},label:`Put changes live every time I publish`,description:`Off: published versions wait until you choose Put live.`}),(0,B.jsx)(_,{variant:`quiet`,size:`sm`,onClick:()=>M.getState().openSetup(),children:`Change host or project…`})]}):null]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:`deploy-card__text`,children:`Put the site at a real address with Cloudflare or Vercel. After that, publishing can put changes live by itself, and you can share a preview link before you publish.`}),(0,B.jsx)(`div`,{className:`deploy-card__actions`,children:(0,B.jsx)(_,{variant:`primary`,size:`sm`,icon:`globe`,onClick:()=>M.getState().openSetup(),children:`Put this site online`})})]})}):(0,B.jsx)(r,{compact:!0,title:`Couldn’t check whether the site is online`,error:a.error,onRetry:()=>void a.refetch()})}function U(){let{siteId:t=``}=e(),n=L(t),r=n.data;return r?r.config?n.job?.state===`running`?(0,B.jsx)(l,{tone:`info`,children:`Putting it live…`}):r.production&&r.behind===0?(0,B.jsx)(l,{tone:`success`,children:`Live`}):(0,B.jsx)(_,{size:`sm`,variant:`secondary`,icon:`globe`,onClick:()=>void N(t),children:`Put live`}):(0,B.jsx)(_,{size:`sm`,variant:`quiet`,icon:`globe`,onClick:()=>M.getState().openSetup(),children:`Put this site online`}):null}function W({siteId:e}){let t=L(e),n=R(e),r=(0,z.useRef)(Date.now()),i=n&&(n.startedAt>=r.current||n.label===V&&n.startedAt>=r.current-3e4)?n:null,a=t.data?.config,[o,s]=(0,z.useState)(!1);return t.data?a?i?.state===`running`?(0,B.jsxs)(`div`,{className:`deploy-note deploy-note--stack`,"aria-live":`polite`,children:[(0,B.jsx)(`p`,{className:`deploy-note__title`,children:`Putting it live…`}),(0,B.jsx)(D,{job:i,intent:`production`})]}):i?.state===`done`&&i.url?(0,B.jsxs)(`p`,{className:`deploy-note`,role:`status`,children:[(0,B.jsx)(b,{name:`check`}),(0,B.jsxs)(`span`,{children:[`Live at`,` `,(0,B.jsx)(`a`,{className:`g-link`,href:i.url,target:`_blank`,rel:`noopener noreferrer`,children:F(i.url)}),`.`]})]}):i?.state===`error`?(0,B.jsx)(`p`,{className:`deploy-note deploy-note--danger`,role:`alert`,children:(0,B.jsxs)(`span`,{children:[`Published, but not live yet: `,i.detail]})}):a.autoDeploy?null:(0,B.jsxs)(`p`,{className:`deploy-note`,children:[(0,B.jsx)(`span`,{children:`Published here. The live site changes when you put it live.`}),(0,B.jsx)(`button`,{type:`button`,className:`app-link-button`,disabled:o,onClick:()=>{s(!0),r.current=Date.now()-1e3,N(e).finally(()=>s(!1))},children:o?`Starting…`:`Put live`})]}):(0,B.jsxs)(`p`,{className:`deploy-note`,children:[(0,B.jsx)(`span`,{children:`Want it at a real address?`}),(0,B.jsx)(`button`,{type:`button`,className:`app-link-button`,onClick:()=>M.getState().openSetup(),children:`Put this site online`})]}):null}function G({item:e,versions:t}){let n=e.commit?t.get(e.commit):void 0;return(0,B.jsxs)(`li`,{className:`deploy-row`,children:[(0,B.jsx)(l,{tone:e.kind===`production`?`success`:`info`,mark:null,children:e.kind===`production`?`Live`:`Preview`}),(0,B.jsxs)(`div`,{className:`deploy-row__main`,children:[(0,B.jsx)(`a`,{className:`deploy-row__address`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:F(e.url)}),(0,B.jsxs)(`p`,{className:`deploy-row__meta`,children:[e.label??(e.kind===`production`?n?`“${n}”`:`A published version`:`Unpublished changes`),(0,B.jsx)(`span`,{"aria-hidden":`true`,children:` · `}),(0,B.jsx)(`time`,{dateTime:e.createdAt,title:u(e.createdAt),children:d(e.createdAt)}),e.who?` · ${e.who}`:``,(0,B.jsx)(`span`,{"aria-hidden":`true`,children:` · `}),m(e.files,`file`),`, `,v(e.bytes)]})]}),(0,B.jsxs)(`div`,{className:`deploy-row__actions`,children:[(0,B.jsxs)(`a`,{className:p(`quiet`,`sm`),href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:[(0,B.jsx)(b,{name:`external`}),`Open`]}),(0,B.jsx)(h,{icon:`copy`,label:`Copy the address`,onClick:()=>O(e.url)})]})]})}function K(){let{siteId:t=``}=e();S({crumbs:[{label:`Online`}]});let n=C(T.deployments(t),()=>x(`GET /api/sites/:siteId/deployments`,{params:{siteId:t},query:{limit:50}})),a=C(w.history(t,50),()=>x(`GET /api/sites/:siteId/history`,{params:{siteId:t},query:{limit:50}})),o=new Map((a.data?.items??[]).map(e=>[e.commit,e.message])),s=n.data?.items??[];return(0,B.jsx)(`div`,{className:`app-screen`,children:(0,B.jsxs)(`div`,{className:`app-screen__inner`,children:[(0,B.jsx)(y,{title:`Online`,description:`Where the site lives on the internet. What’s live is what you’ve published; a preview link shows unpublished changes too.`}),(0,B.jsx)(H,{siteId:t,variant:`settings`,listLink:!1}),(0,B.jsx)(`h2`,{className:`app-section__title deploy-list__title`,children:`Deployments`}),n.loading?(0,B.jsx)(f,{lines:4}):n.status===`error`&&!n.data?(0,B.jsx)(r,{compact:!0,title:`Couldn’t load the deployments`,error:n.error,onRetry:()=>void n.refetch()}):s.length===0?(0,B.jsx)(i,{compact:!0,title:`Nothing put online yet.`,body:`Each time the site goes live or a preview link is made, it’s listed here.`,mark:`reg`}):(0,B.jsx)(`ul`,{className:`app-card deploy-list`,children:s.map(e=>(0,B.jsx)(G,{item:e,versions:o},`${e.kind}-${e.id}`))})]})})}export{H as OnlineCard,K as OnlineScreen,W as PublishDeployNote,U as PutLiveButton};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{$ as e,At as t,Ft as n,H as r,I as i,N as a,Nt as o,O as s,S as c,St as l,a as u,bt as d,c as f,ct as p,g as m,gt as h,ht as g,it as _,j as v,k as y,l as b,n as x,pt as S,v as C,z as ee}from"./ui-C6O2tW4c.js";import{n as w}from"./chrome-Brnq5kGb.js";import{t as te}from"./site-DJUEXLHW.js";import{t as T}from"./sites-CGDZymBT.js";import{i as E,n as D,r as O,t as k}from"./usePlugins-6k3yRVYT.js";var A=n(o(),1),ne={builtin:`Comes with the app`,user:`Added on this computer`,site:`Named by this site`};function j(e,t){return e===`user`&&t?`Added on this server`:ne[e]}function M(e,t=3){return e.length<=t?p([...e]):`${e.slice(0,t).join(`, `)} and ${e.length-t} more`}var N={beforePublish:`checks each publish first`,afterPublish:`runs after each publish`,afterDeploy:`runs after each time the site is put online`,onSubmission:`runs on each form submission`};function P(e,t){let n=[],r=t?`/sites/${t}`:null,i=(e,t,r,i,a,o=!0)=>{if(t.length===0)return;let s=_(t.length,r,i);n.push({kind:e,text:o?`${s}: ${M(t)}`:s,...a||{}})};i(`imageProviders`,e.imageProviders,`image generator`,`image generators`,{to:`/settings#images`,where:`App settings › Images`}),i(`videoProviders`,e.videoProviders,`video generator`,`video generators`,{to:`/settings#videos`,where:`App settings › Videos`}),i(`formProviders`,e.formProviders,`form destination`,`form destinations`,r?{to:`${r}/forms`,where:`Forms`}:null),i(`scriptIntegrations`,e.scriptIntegrations,`script`,`scripts`,r?{to:`${r}/scripts`,where:`Scripts › Add a script`}:null),i(`importers`,e.importers,`importer`,`importers`),i(`deployTargets`,e.deployTargets,`host to put sites online`,`hosts to put sites online`,r?{to:`${r}/online`,where:`Online`}:null),i(`adapters`,e.adapters,`kind of site it can read`,`kinds of site it can read`),i(`tools`,e.tools.map(e=>e.title),`assistant tool`,`assistant tools`,r?{to:`${r}/edit`,where:`the assistant`}:null,!1),i(`dataSources`,e.dataSources??[],`data source for fields`,`data sources for fields`);let a=e.hooks.map(e=>N[e]??`runs on “${e}”`);return a.length&&n.push({kind:`hooks`,text:`${a.length===1?`A step that`:`Steps that`} ${p(a)}`}),n}function F(e){return Object.values(e).some(e=>(e?.length??0)>0)}function I(e,t){let n=e.trim();for(let e of[t.name,t.location].filter(e=>!!e))n.startsWith(`${e}: `)&&(n=n.slice(e.length+2));n=n.replace(/\s*\([^()]*(?:\([^()]*\)[^()]*)*\)/g,``),n=n.replace(/\s+([,.;])/g,`$1`).replace(/\s{2,}/g,` `).trim();let r=n?n.charAt(0).toUpperCase()+n.slice(1):e;return{plain:r,detail:r.toLowerCase()===e.trim().toLowerCase()?null:e}}var L={adapter:`kind of site`,imageProvider:`image generator`,videoProvider:`video generator`,formProvider:`form destination`,scriptIntegration:`script`,importer:`importer`,deployTarget:`host`,tool:`assistant tool`,dataSource:`data source for fields`};function R(e,t){let n=t(e.used);return`${p(e.ignored.map(t))} and ${n} both add the ${L[e.kind]} “${e.id}”. The one from ${n} is used.`}function z(e,t){return{lost:t.filter(t=>t.ignored.includes(e)),won:t.filter(t=>t.used===e)}}function B(e){if(!e.configured)return e.required?`Not set — needed`:`Not set`;let t=e.hint?` · ends in ${e.hint}`:``;return e.source===`env`?`Set by this computer’s environment${t}`:`Set${t}`}function V(e,t){let n=t.trim();if(!n)return e.required?`${e.label} is needed.`:null;if(!e.pattern)return null;let r;try{r=new RegExp(e.pattern)}catch{return null}let i=/^[aeiou]/i.test(e.label)?`an`:`a`;return r.test(n)?null:`That doesn’t look like ${i} ${e.label}${e.placeholder?` — it looks like ${e.placeholder}`:``}`.replace(/…?$/,e=>e?`…`:`.`)}function H(e){return e.settings.filter(e=>e.required&&!e.configured)}function U(e){let t=e=>e.problems.length?0:e.source===`builtin`?1:e.source===`user`?2:3;return[...e].sort((e,n)=>t(e)-t(n)||e.displayName.localeCompare(n.displayName))}function W(e,t=`<name>`){return`${e} plugin add ${/^[@\w./:<>-]+$/.test(t)?t:`'${t.replace(/'/g,`'\\''`)}'`}`}var G=d();function K(){let e=c(e=>e.meta?.mode===`hosted`),[t,n]=(0,A.useState)(``),[r,i]=(0,A.useState)(!1),a=W(E.slug,t.trim()||`<name>`);return(0,G.jsxs)(`section`,{className:`plg-add`,"aria-labelledby":`plg-add-title`,children:[(0,G.jsxs)(`div`,{className:`plg-add__text`,children:[(0,G.jsx)(`h2`,{className:`plg-add__title`,id:`plg-add-title`,children:`Add a plugin`}),(0,G.jsxs)(`p`,{className:`plg-add__lede`,children:[`Plugins are added with a command `,e?`on the server`:`in a terminal on this computer`,`, not from here: adding one downloads a package and lets it run with the app’s access, so it’s a step taken on purpose.`]})]}),(0,G.jsxs)(`div`,{className:`plg-add__form`,children:[(0,G.jsx)(v,{label:`Package name or folder`,hint:`From npm, a folder, or a .tgz file. Leave it empty to copy the command as it is.`,children:(0,G.jsx)(s,{mono:!0,spellCheck:!1,value:t,placeholder:`galley-plugin-example`,onChange:e=>{n(e.target.value),i(!1)}})}),(0,G.jsxs)(`div`,{className:`plg-command`,children:[(0,G.jsxs)(`code`,{className:`plg-command__text`,"aria-label":`Command`,children:[(0,G.jsx)(`span`,{className:`plg-command__prompt`,"aria-hidden":`true`,children:`$`}),` `,a]}),(0,G.jsx)(S,{size:`sm`,variant:`secondary`,icon:`copy`,onClick:()=>{navigator.clipboard?.writeText(a).then(()=>i(!0))},children:r?`Copied`:`Copy`})]}),(0,G.jsx)(`p`,{className:`g-hint plg-add__after`,children:e?`Then restart the server: a plugin added with the command shows up here only after a restart.`:`Then restart the app: a plugin added with the command shows up here only after a restart. This window stays signed in.`}),(0,G.jsx)(`span`,{className:`g-sr`,role:`status`,children:r?`Command copied`:``})]})]})}function q(){let e=c(e=>e.meta?.mode===`hosted`);return(0,G.jsxs)(`aside`,{className:`plg-trust`,"aria-label":`About plugins`,children:[(0,G.jsxs)(`p`,{children:[(0,G.jsx)(`strong`,{children:`A plugin is code that runs inside this app`}),` with the same access the app has `,e?`on this server`:`on this computer`,` — its files and its keys. Add only plugins you trust, as you would any program.`]}),(0,G.jsxs)(`p`,{children:[`Plugins a site names in its settings file load only for that site, and can’t change the image or video generator, which is chosen for the whole app.`,` `,e?`On this shared server they stay off unless whoever runs it allows them, because anyone who can open a site here would otherwise run that site’s code on the server.`:`On a shared server, behind a password, they stay off unless whoever runs it allows them.`]})]})}async function J(e,t,n){let r=await ee(`PUT /api/plugins/settings`,{body:{name:e.name,values:t,...n?{siteId:n}:{}}});return k(r),r}function Y(){return c(e=>e.meta?.mode===`hosted`)?`this server’s environment`:`this computer’s environment`}function X({setting:t}){let n=Y();return(0,G.jsxs)(`div`,{className:`plg-setting`,children:[(0,G.jsxs)(`div`,{className:`plg-setting__row`,children:[(0,G.jsxs)(`div`,{className:`plg-setting__text`,children:[(0,G.jsx)(`span`,{className:`g-label`,children:t.label}),(0,G.jsxs)(`span`,{className:`plg-setting__status`,children:[(0,G.jsx)(e,{kind:`reg`,className:`app-secret__ok`}),(0,G.jsxs)(`span`,{children:[`Set by `,n,t.secret&&t.hint?(0,G.jsxs)(G.Fragment,{children:[` `,`· ends in `,(0,G.jsx)(`span`,{className:`g-mono`,children:t.hint})]}):null,!t.secret&&t.value?(0,G.jsxs)(G.Fragment,{children:[` `,`· `,(0,G.jsx)(`span`,{className:`g-mono`,children:t.value})]}):null]})]})]}),(0,G.jsx)(f,{mark:null,children:`Read-only`})]}),(0,G.jsx)(`p`,{className:`g-hint`,children:`It can’t be changed here. Change it where the app is started, then restart the app.`})]})}function Z({plugin:t,setting:n,siteId:i}){let[a,o]=(0,A.useState)(!1),[c,l]=(0,A.useState)(``),[u,d]=(0,A.useState)(null),[f,p]=(0,A.useState)(null),m=(0,A.useId)(),h=async e=>{e.preventDefault();let a=V({...n,required:!0},c);if(a)p(c.trim()?a:`Paste it first.`);else{d(`save`),p(null);try{await J(t,{[n.key]:c.trim()},i),l(``),o(!1),x({tone:`success`,title:`${n.label} saved`,body:`It’s kept with the app’s own keys and never shown again — only its last four characters.`})}catch(e){p(r(e).message)}finally{d(null)}}},g=async()=>{d(`remove`);try{await J(t,{[n.key]:null},i),x({tone:`neutral`,title:`${n.label} removed`})}catch(e){x({tone:`danger`,title:`Couldn’t remove the ${n.label}`,body:r(e).message})}finally{d(null)}};return(0,G.jsxs)(`div`,{className:`plg-setting`,children:[(0,G.jsxs)(`div`,{className:`plg-setting__row`,children:[(0,G.jsxs)(`div`,{className:`plg-setting__text`,children:[(0,G.jsxs)(`span`,{className:`g-label`,id:`${m}-label`,children:[n.label,n.required?null:(0,G.jsx)(`span`,{className:`g-faint`,children:` · optional`})]}),(0,G.jsxs)(`span`,{className:n.configured?`plg-setting__status`:`plg-setting__status g-faint`,children:[n.configured?(0,G.jsx)(e,{kind:`reg`,className:`app-secret__ok`}):null,(0,G.jsx)(`span`,{children:n.configured?(0,G.jsxs)(G.Fragment,{children:[`Set`,n.hint?` · ends in `:``,n.hint?(0,G.jsx)(`span`,{className:`g-mono`,children:n.hint}):null]}):B(n)})]})]}),a?null:(0,G.jsxs)(`div`,{className:`app-secret__actions`,children:[n.configured?(0,G.jsx)(S,{size:`sm`,variant:`danger-quiet`,busy:u===`remove`,busyLabel:`Removing`,onClick:()=>void g(),"aria-label":`Remove the ${n.label}`,children:`Remove`}):null,(0,G.jsx)(S,{size:`sm`,variant:`secondary`,icon:`key`,onClick:()=>o(!0),"aria-label":`${n.configured?`Replace`:`Add`} the ${n.label}`,children:n.configured?`Replace…`:`Add…`})]})]}),n.help&&!a?(0,G.jsx)(`p`,{className:`g-hint`,children:n.help}):null,a?(0,G.jsxs)(`form`,{className:`app-secret__form`,onSubmit:h,children:[(0,G.jsx)(v,{label:`New ${n.label}`,hideLabel:!0,error:f??void 0,hint:n.help,children:(0,G.jsx)(s,{type:`password`,mono:!0,autoComplete:`off`,spellCheck:!1,placeholder:n.placeholder??`Paste it here`,value:c,onChange:e=>l(e.target.value),autoFocus:!0})}),(0,G.jsxs)(`div`,{className:`app-secret__actions`,children:[(0,G.jsx)(S,{size:`sm`,variant:`quiet`,onClick:()=>{o(!1),l(``),p(null)},children:`Cancel`}),(0,G.jsx)(S,{size:`sm`,variant:`primary`,type:`submit`,busy:u===`save`,busyLabel:`Saving`,children:`Save`})]})]}):null]})}function re({plugin:e,setting:t,siteId:n}){let[i,a]=(0,A.useState)(t.value??``),[o,c]=(0,A.useState)(!1),[l,u]=(0,A.useState)(null);(0,A.useEffect)(()=>a(t.value??``),[t.value]);let d=i.trim()!==(t.value??``);return(0,G.jsxs)(`form`,{className:`plg-setting plg-setting--text`,onSubmit:async a=>{a.preventDefault();let o=V(t,i);if(o)u(o);else{c(!0),u(null);try{await J(e,{[t.key]:i.trim()?i.trim():null},n),x({tone:`success`,title:`${t.label} saved`})}catch(e){u(r(e).message)}finally{c(!1)}}},children:[(0,G.jsx)(v,{label:t.label,aside:t.required?(0,G.jsx)(`span`,{className:`plg-required`,children:`Required`}):(0,G.jsx)(`span`,{className:`g-faint`,children:`Optional`}),error:l??void 0,hint:t.help,children:(0,G.jsx)(s,{mono:!0,spellCheck:!1,placeholder:t.placeholder,value:i,onChange:e=>a(e.target.value)})}),(0,G.jsx)(S,{size:`sm`,variant:`secondary`,type:`submit`,disabled:!d,busy:o,busyLabel:`Saving`,children:`Save`})]})}var ie=e=>/^(on|yes|true|1)$/i.test((e.value??e.default??`off`).trim());function ae({plugin:t,setting:n,siteId:i}){let[a,o]=(0,A.useState)(!1),[s,c]=(0,A.useState)(null),l=ie(n),d=!!n.switchesOn?.length,f=n.consequence,p=async(e,a=!0)=>{o(!0),c(null);try{await J(t,{[n.key]:e?`on`:`off`},i),x({tone:`neutral`,title:e?`Switched on`:`Switched off`,body:n.label,...a?{action:{label:`Undo`,onClick:()=>void p(!e,!1)}}:{}})}catch(e){c(r(e).message)}finally{o(!1)}};return d?(0,G.jsxs)(`div`,{className:l?`plg-setting plg-decision plg-decision--on`:`plg-setting plg-decision`,children:[(0,G.jsxs)(`label`,{className:`plg-decision__row`,children:[(0,G.jsxs)(`span`,{className:`plg-decision__text`,children:[(0,G.jsx)(`span`,{className:`plg-decision__label`,children:n.label}),f?(0,G.jsxs)(`span`,{className:`plg-decision__consequence`,children:[(0,G.jsx)(e,{kind:`bang`}),(0,G.jsx)(`span`,{children:f})]}):null]}),(0,G.jsx)(`span`,{className:`plg-decision__state`,"aria-hidden":`true`,children:l?`On`:`Off`}),(0,G.jsx)(u,{checked:l,disabled:a,onChange:e=>void p(e),"aria-label":n.label})]}),n.help?(0,G.jsx)(`p`,{className:`g-hint`,children:n.help}):null,s?(0,G.jsxs)(`p`,{className:`g-error-text`,role:`alert`,children:[(0,G.jsx)(e,{kind:`bang`}),s]}):null]}):(0,G.jsxs)(`div`,{className:`plg-setting`,children:[(0,G.jsx)(u,{checked:l,disabled:a,onChange:e=>void p(e),label:n.label,description:f??n.help}),f&&n.help?(0,G.jsx)(`p`,{className:`g-hint`,children:n.help}):null,s?(0,G.jsxs)(`p`,{className:`g-error-text`,role:`alert`,children:[(0,G.jsx)(e,{kind:`bang`}),s]}):null]})}function oe({plugin:e,setting:t,siteId:n}){let[i,a]=(0,A.useState)(!1),[o,s]=(0,A.useState)(null),c=t.value??t.default??``,l=async i=>{if(i!==c){a(!0),s(null);try{await J(e,{[t.key]:i||null},n),x({tone:`success`,title:`${t.label} saved`})}catch(e){s(r(e).message)}finally{a(!1)}}};return(0,G.jsx)(`div`,{className:`plg-setting`,children:(0,G.jsx)(v,{label:t.label,error:o??void 0,hint:t.help,children:(0,G.jsx)(y,{value:c,disabled:i,options:(t.options??[]).map(e=>({value:e.value,label:e.label})),placeholder:t.default?void 0:`Choose…`,onChange:e=>void l(e)})})})}function se({plugin:e,siteId:t}){return e.settings.length===0?null:(0,G.jsx)(`div`,{className:`plg-settings`,role:`group`,"aria-label":`${e.displayName} settings`,children:e.settings.map(n=>n.source===`env`?(0,G.jsx)(X,{setting:n},n.key):n.secret?(0,G.jsx)(Z,{plugin:e,setting:n,siteId:t},n.key):n.type===`toggle`?(0,G.jsx)(ae,{plugin:e,setting:n,siteId:t},n.key):n.type===`select`?(0,G.jsx)(oe,{plugin:e,setting:n,siteId:t},n.key):(0,G.jsx)(re,{plugin:e,setting:n,siteId:t},n.key))})}function Q({plugin:e}){return e.problems.length>0&&!e.active?(0,G.jsx)(f,{tone:`danger`,children:`Not working`}):e.enabled&&H(e).length>0?(0,G.jsx)(f,{tone:`warning`,children:`Needs a setting`}):null}function ce({plugin:t,technical:n}){let[r,i]=(0,A.useState)(!1);if(t.problems.length===0)return null;let a=t.problems.map(e=>I(e,t)),o=[...a.map(e=>e.detail).filter(Boolean),...n].join(`
|
|
1
|
+
import{$ as e,At as t,Ft as n,H as r,I as i,N as a,Nt as o,O as s,S as c,St as l,a as u,bt as d,c as f,ct as p,g as m,gt as h,ht as g,it as _,j as v,k as y,l as b,n as x,pt as S,v as C,z as ee}from"./ui-C6O2tW4c.js";import{n as w}from"./chrome-Brnq5kGb.js";import{t as te}from"./site-DJUEXLHW.js";import{t as T}from"./sites-CGDZymBT.js";import{i as E,n as D,r as O,t as k}from"./usePlugins-D8UH3hzc.js";var A=n(o(),1),ne={builtin:`Comes with the app`,user:`Added on this computer`,site:`Named by this site`};function j(e,t){return e===`user`&&t?`Added on this server`:ne[e]}function M(e,t=3){return e.length<=t?p([...e]):`${e.slice(0,t).join(`, `)} and ${e.length-t} more`}var N={beforePublish:`checks each publish first`,afterPublish:`runs after each publish`,afterDeploy:`runs after each time the site is put online`,onSubmission:`runs on each form submission`};function P(e,t){let n=[],r=t?`/sites/${t}`:null,i=(e,t,r,i,a,o=!0)=>{if(t.length===0)return;let s=_(t.length,r,i);n.push({kind:e,text:o?`${s}: ${M(t)}`:s,...a||{}})};i(`imageProviders`,e.imageProviders,`image generator`,`image generators`,{to:`/settings#images`,where:`App settings › Images`}),i(`videoProviders`,e.videoProviders,`video generator`,`video generators`,{to:`/settings#videos`,where:`App settings › Videos`}),i(`formProviders`,e.formProviders,`form destination`,`form destinations`,r?{to:`${r}/forms`,where:`Forms`}:null),i(`scriptIntegrations`,e.scriptIntegrations,`script`,`scripts`,r?{to:`${r}/scripts`,where:`Scripts › Add a script`}:null),i(`importers`,e.importers,`importer`,`importers`),i(`deployTargets`,e.deployTargets,`host to put sites online`,`hosts to put sites online`,r?{to:`${r}/online`,where:`Online`}:null),i(`adapters`,e.adapters,`kind of site it can read`,`kinds of site it can read`),i(`tools`,e.tools.map(e=>e.title),`assistant tool`,`assistant tools`,r?{to:`${r}/edit`,where:`the assistant`}:null,!1),i(`dataSources`,e.dataSources??[],`data source for fields`,`data sources for fields`);let a=e.hooks.map(e=>N[e]??`runs on “${e}”`);return a.length&&n.push({kind:`hooks`,text:`${a.length===1?`A step that`:`Steps that`} ${p(a)}`}),n}function F(e){return Object.values(e).some(e=>(e?.length??0)>0)}function I(e,t){let n=e.trim();for(let e of[t.name,t.location].filter(e=>!!e))n.startsWith(`${e}: `)&&(n=n.slice(e.length+2));n=n.replace(/\s*\([^()]*(?:\([^()]*\)[^()]*)*\)/g,``),n=n.replace(/\s+([,.;])/g,`$1`).replace(/\s{2,}/g,` `).trim();let r=n?n.charAt(0).toUpperCase()+n.slice(1):e;return{plain:r,detail:r.toLowerCase()===e.trim().toLowerCase()?null:e}}var L={adapter:`kind of site`,imageProvider:`image generator`,videoProvider:`video generator`,formProvider:`form destination`,scriptIntegration:`script`,importer:`importer`,deployTarget:`host`,tool:`assistant tool`,dataSource:`data source for fields`};function R(e,t){let n=t(e.used);return`${p(e.ignored.map(t))} and ${n} both add the ${L[e.kind]} “${e.id}”. The one from ${n} is used.`}function z(e,t){return{lost:t.filter(t=>t.ignored.includes(e)),won:t.filter(t=>t.used===e)}}function B(e){if(!e.configured)return e.required?`Not set — needed`:`Not set`;let t=e.hint?` · ends in ${e.hint}`:``;return e.source===`env`?`Set by this computer’s environment${t}`:`Set${t}`}function V(e,t){let n=t.trim();if(!n)return e.required?`${e.label} is needed.`:null;if(!e.pattern)return null;let r;try{r=new RegExp(e.pattern)}catch{return null}let i=/^[aeiou]/i.test(e.label)?`an`:`a`;return r.test(n)?null:`That doesn’t look like ${i} ${e.label}${e.placeholder?` — it looks like ${e.placeholder}`:``}`.replace(/…?$/,e=>e?`…`:`.`)}function H(e){return e.settings.filter(e=>e.required&&!e.configured)}function U(e){let t=e=>e.problems.length?0:e.source===`builtin`?1:e.source===`user`?2:3;return[...e].sort((e,n)=>t(e)-t(n)||e.displayName.localeCompare(n.displayName))}function W(e,t=`<name>`){return`${e} plugin add ${/^[@\w./:<>-]+$/.test(t)?t:`'${t.replace(/'/g,`'\\''`)}'`}`}var G=d();function K(){let e=c(e=>e.meta?.mode===`hosted`),[t,n]=(0,A.useState)(``),[r,i]=(0,A.useState)(!1),a=W(E.slug,t.trim()||`<name>`);return(0,G.jsxs)(`section`,{className:`plg-add`,"aria-labelledby":`plg-add-title`,children:[(0,G.jsxs)(`div`,{className:`plg-add__text`,children:[(0,G.jsx)(`h2`,{className:`plg-add__title`,id:`plg-add-title`,children:`Add a plugin`}),(0,G.jsxs)(`p`,{className:`plg-add__lede`,children:[`Plugins are added with a command `,e?`on the server`:`in a terminal on this computer`,`, not from here: adding one downloads a package and lets it run with the app’s access, so it’s a step taken on purpose.`]})]}),(0,G.jsxs)(`div`,{className:`plg-add__form`,children:[(0,G.jsx)(v,{label:`Package name or folder`,hint:`From npm, a folder, or a .tgz file. Leave it empty to copy the command as it is.`,children:(0,G.jsx)(s,{mono:!0,spellCheck:!1,value:t,placeholder:`galley-plugin-example`,onChange:e=>{n(e.target.value),i(!1)}})}),(0,G.jsxs)(`div`,{className:`plg-command`,children:[(0,G.jsxs)(`code`,{className:`plg-command__text`,"aria-label":`Command`,children:[(0,G.jsx)(`span`,{className:`plg-command__prompt`,"aria-hidden":`true`,children:`$`}),` `,a]}),(0,G.jsx)(S,{size:`sm`,variant:`secondary`,icon:`copy`,onClick:()=>{navigator.clipboard?.writeText(a).then(()=>i(!0))},children:r?`Copied`:`Copy`})]}),(0,G.jsx)(`p`,{className:`g-hint plg-add__after`,children:e?`Then restart the server: a plugin added with the command shows up here only after a restart.`:`Then restart the app: a plugin added with the command shows up here only after a restart. This window stays signed in.`}),(0,G.jsx)(`span`,{className:`g-sr`,role:`status`,children:r?`Command copied`:``})]})]})}function q(){let e=c(e=>e.meta?.mode===`hosted`);return(0,G.jsxs)(`aside`,{className:`plg-trust`,"aria-label":`About plugins`,children:[(0,G.jsxs)(`p`,{children:[(0,G.jsx)(`strong`,{children:`A plugin is code that runs inside this app`}),` with the same access the app has `,e?`on this server`:`on this computer`,` — its files and its keys. Add only plugins you trust, as you would any program.`]}),(0,G.jsxs)(`p`,{children:[`Plugins a site names in its settings file load only for that site, and can’t change the image or video generator, which is chosen for the whole app.`,` `,e?`On this shared server they stay off unless whoever runs it allows them, because anyone who can open a site here would otherwise run that site’s code on the server.`:`On a shared server, behind a password, they stay off unless whoever runs it allows them.`]})]})}async function J(e,t,n){let r=await ee(`PUT /api/plugins/settings`,{body:{name:e.name,values:t,...n?{siteId:n}:{}}});return k(r),r}function Y(){return c(e=>e.meta?.mode===`hosted`)?`this server’s environment`:`this computer’s environment`}function X({setting:t}){let n=Y();return(0,G.jsxs)(`div`,{className:`plg-setting`,children:[(0,G.jsxs)(`div`,{className:`plg-setting__row`,children:[(0,G.jsxs)(`div`,{className:`plg-setting__text`,children:[(0,G.jsx)(`span`,{className:`g-label`,children:t.label}),(0,G.jsxs)(`span`,{className:`plg-setting__status`,children:[(0,G.jsx)(e,{kind:`reg`,className:`app-secret__ok`}),(0,G.jsxs)(`span`,{children:[`Set by `,n,t.secret&&t.hint?(0,G.jsxs)(G.Fragment,{children:[` `,`· ends in `,(0,G.jsx)(`span`,{className:`g-mono`,children:t.hint})]}):null,!t.secret&&t.value?(0,G.jsxs)(G.Fragment,{children:[` `,`· `,(0,G.jsx)(`span`,{className:`g-mono`,children:t.value})]}):null]})]})]}),(0,G.jsx)(f,{mark:null,children:`Read-only`})]}),(0,G.jsx)(`p`,{className:`g-hint`,children:`It can’t be changed here. Change it where the app is started, then restart the app.`})]})}function Z({plugin:t,setting:n,siteId:i}){let[a,o]=(0,A.useState)(!1),[c,l]=(0,A.useState)(``),[u,d]=(0,A.useState)(null),[f,p]=(0,A.useState)(null),m=(0,A.useId)(),h=async e=>{e.preventDefault();let a=V({...n,required:!0},c);if(a)p(c.trim()?a:`Paste it first.`);else{d(`save`),p(null);try{await J(t,{[n.key]:c.trim()},i),l(``),o(!1),x({tone:`success`,title:`${n.label} saved`,body:`It’s kept with the app’s own keys and never shown again — only its last four characters.`})}catch(e){p(r(e).message)}finally{d(null)}}},g=async()=>{d(`remove`);try{await J(t,{[n.key]:null},i),x({tone:`neutral`,title:`${n.label} removed`})}catch(e){x({tone:`danger`,title:`Couldn’t remove the ${n.label}`,body:r(e).message})}finally{d(null)}};return(0,G.jsxs)(`div`,{className:`plg-setting`,children:[(0,G.jsxs)(`div`,{className:`plg-setting__row`,children:[(0,G.jsxs)(`div`,{className:`plg-setting__text`,children:[(0,G.jsxs)(`span`,{className:`g-label`,id:`${m}-label`,children:[n.label,n.required?null:(0,G.jsx)(`span`,{className:`g-faint`,children:` · optional`})]}),(0,G.jsxs)(`span`,{className:n.configured?`plg-setting__status`:`plg-setting__status g-faint`,children:[n.configured?(0,G.jsx)(e,{kind:`reg`,className:`app-secret__ok`}):null,(0,G.jsx)(`span`,{children:n.configured?(0,G.jsxs)(G.Fragment,{children:[`Set`,n.hint?` · ends in `:``,n.hint?(0,G.jsx)(`span`,{className:`g-mono`,children:n.hint}):null]}):B(n)})]})]}),a?null:(0,G.jsxs)(`div`,{className:`app-secret__actions`,children:[n.configured?(0,G.jsx)(S,{size:`sm`,variant:`danger-quiet`,busy:u===`remove`,busyLabel:`Removing`,onClick:()=>void g(),"aria-label":`Remove the ${n.label}`,children:`Remove`}):null,(0,G.jsx)(S,{size:`sm`,variant:`secondary`,icon:`key`,onClick:()=>o(!0),"aria-label":`${n.configured?`Replace`:`Add`} the ${n.label}`,children:n.configured?`Replace…`:`Add…`})]})]}),n.help&&!a?(0,G.jsx)(`p`,{className:`g-hint`,children:n.help}):null,a?(0,G.jsxs)(`form`,{className:`app-secret__form`,onSubmit:h,children:[(0,G.jsx)(v,{label:`New ${n.label}`,hideLabel:!0,error:f??void 0,hint:n.help,children:(0,G.jsx)(s,{type:`password`,mono:!0,autoComplete:`off`,spellCheck:!1,placeholder:n.placeholder??`Paste it here`,value:c,onChange:e=>l(e.target.value),autoFocus:!0})}),(0,G.jsxs)(`div`,{className:`app-secret__actions`,children:[(0,G.jsx)(S,{size:`sm`,variant:`quiet`,onClick:()=>{o(!1),l(``),p(null)},children:`Cancel`}),(0,G.jsx)(S,{size:`sm`,variant:`primary`,type:`submit`,busy:u===`save`,busyLabel:`Saving`,children:`Save`})]})]}):null]})}function re({plugin:e,setting:t,siteId:n}){let[i,a]=(0,A.useState)(t.value??``),[o,c]=(0,A.useState)(!1),[l,u]=(0,A.useState)(null);(0,A.useEffect)(()=>a(t.value??``),[t.value]);let d=i.trim()!==(t.value??``);return(0,G.jsxs)(`form`,{className:`plg-setting plg-setting--text`,onSubmit:async a=>{a.preventDefault();let o=V(t,i);if(o)u(o);else{c(!0),u(null);try{await J(e,{[t.key]:i.trim()?i.trim():null},n),x({tone:`success`,title:`${t.label} saved`})}catch(e){u(r(e).message)}finally{c(!1)}}},children:[(0,G.jsx)(v,{label:t.label,aside:t.required?(0,G.jsx)(`span`,{className:`plg-required`,children:`Required`}):(0,G.jsx)(`span`,{className:`g-faint`,children:`Optional`}),error:l??void 0,hint:t.help,children:(0,G.jsx)(s,{mono:!0,spellCheck:!1,placeholder:t.placeholder,value:i,onChange:e=>a(e.target.value)})}),(0,G.jsx)(S,{size:`sm`,variant:`secondary`,type:`submit`,disabled:!d,busy:o,busyLabel:`Saving`,children:`Save`})]})}var ie=e=>/^(on|yes|true|1)$/i.test((e.value??e.default??`off`).trim());function ae({plugin:t,setting:n,siteId:i}){let[a,o]=(0,A.useState)(!1),[s,c]=(0,A.useState)(null),l=ie(n),d=!!n.switchesOn?.length,f=n.consequence,p=async(e,a=!0)=>{o(!0),c(null);try{await J(t,{[n.key]:e?`on`:`off`},i),x({tone:`neutral`,title:e?`Switched on`:`Switched off`,body:n.label,...a?{action:{label:`Undo`,onClick:()=>void p(!e,!1)}}:{}})}catch(e){c(r(e).message)}finally{o(!1)}};return d?(0,G.jsxs)(`div`,{className:l?`plg-setting plg-decision plg-decision--on`:`plg-setting plg-decision`,children:[(0,G.jsxs)(`label`,{className:`plg-decision__row`,children:[(0,G.jsxs)(`span`,{className:`plg-decision__text`,children:[(0,G.jsx)(`span`,{className:`plg-decision__label`,children:n.label}),f?(0,G.jsxs)(`span`,{className:`plg-decision__consequence`,children:[(0,G.jsx)(e,{kind:`bang`}),(0,G.jsx)(`span`,{children:f})]}):null]}),(0,G.jsx)(`span`,{className:`plg-decision__state`,"aria-hidden":`true`,children:l?`On`:`Off`}),(0,G.jsx)(u,{checked:l,disabled:a,onChange:e=>void p(e),"aria-label":n.label})]}),n.help?(0,G.jsx)(`p`,{className:`g-hint`,children:n.help}):null,s?(0,G.jsxs)(`p`,{className:`g-error-text`,role:`alert`,children:[(0,G.jsx)(e,{kind:`bang`}),s]}):null]}):(0,G.jsxs)(`div`,{className:`plg-setting`,children:[(0,G.jsx)(u,{checked:l,disabled:a,onChange:e=>void p(e),label:n.label,description:f??n.help}),f&&n.help?(0,G.jsx)(`p`,{className:`g-hint`,children:n.help}):null,s?(0,G.jsxs)(`p`,{className:`g-error-text`,role:`alert`,children:[(0,G.jsx)(e,{kind:`bang`}),s]}):null]})}function oe({plugin:e,setting:t,siteId:n}){let[i,a]=(0,A.useState)(!1),[o,s]=(0,A.useState)(null),c=t.value??t.default??``,l=async i=>{if(i!==c){a(!0),s(null);try{await J(e,{[t.key]:i||null},n),x({tone:`success`,title:`${t.label} saved`})}catch(e){s(r(e).message)}finally{a(!1)}}};return(0,G.jsx)(`div`,{className:`plg-setting`,children:(0,G.jsx)(v,{label:t.label,error:o??void 0,hint:t.help,children:(0,G.jsx)(y,{value:c,disabled:i,options:(t.options??[]).map(e=>({value:e.value,label:e.label})),placeholder:t.default?void 0:`Choose…`,onChange:e=>void l(e)})})})}function se({plugin:e,siteId:t}){return e.settings.length===0?null:(0,G.jsx)(`div`,{className:`plg-settings`,role:`group`,"aria-label":`${e.displayName} settings`,children:e.settings.map(n=>n.source===`env`?(0,G.jsx)(X,{setting:n},n.key):n.secret?(0,G.jsx)(Z,{plugin:e,setting:n,siteId:t},n.key):n.type===`toggle`?(0,G.jsx)(ae,{plugin:e,setting:n,siteId:t},n.key):n.type===`select`?(0,G.jsx)(oe,{plugin:e,setting:n,siteId:t},n.key):(0,G.jsx)(re,{plugin:e,setting:n,siteId:t},n.key))})}function Q({plugin:e}){return e.problems.length>0&&!e.active?(0,G.jsx)(f,{tone:`danger`,children:`Not working`}):e.enabled&&H(e).length>0?(0,G.jsx)(f,{tone:`warning`,children:`Needs a setting`}):null}function ce({plugin:t,technical:n}){let[r,i]=(0,A.useState)(!1);if(t.problems.length===0)return null;let a=t.problems.map(e=>I(e,t)),o=[...a.map(e=>e.detail).filter(Boolean),...n].join(`
|
|
2
2
|
`);return(0,G.jsxs)(`div`,{className:`plg-problem`,role:`status`,children:[(0,G.jsx)(e,{kind:`bang`,className:`plg-problem__mark`}),(0,G.jsxs)(`div`,{className:`plg-problem__main`,children:[a.map((e,t)=>(0,G.jsx)(`p`,{className:`plg-problem__text`,children:e.plain},t)),o?(0,G.jsxs)(`details`,{className:`app-details`,children:[(0,G.jsx)(`summary`,{children:`Technical details`}),(0,G.jsx)(`pre`,{className:`app-error__detail`,children:o}),(0,G.jsx)(S,{size:`sm`,variant:`quiet`,icon:`copy`,onClick:()=>void navigator.clipboard?.writeText(o).then(()=>i(!0)),children:r?`Copied`:`Copy details`})]}):null]})]})}function le({plugin:t,conflicts:n,nameOf:i,linkSiteId:a,siteId:o}){let s=c(e=>e.meta?.mode===`hosted`),[d,f]=(0,A.useState)(!1),p=P(t.contributes,a),{lost:m,won:g}=z(t.name,n),_=H(t),v=[`Package: ${t.name}`,t.location?`From: ${t.location}`:null,...t.warnings.map(e=>`Note: ${e}`),...t.log.length?[`Recent log:`,...t.log.map(e=>` ${e}`)]:[]].filter(e=>e!==null),y=t.problems.length===0&&(t.log.length>0||t.warnings.length>0),b=`plugin-${t.name.replace(/[^a-z0-9]+/gi,`-`)}`,S=async e=>{f(!0);try{let n=await D(t,e,o);x({tone:`neutral`,title:e?`${n.displayName} is on`:`${n.displayName} is off`,body:e?n.active?`What it adds is in use now.`:`It’s on, but not working yet — see the note on it.`:`What it adds is gone from the app until you turn it on again.`})}catch(n){x({tone:`danger`,title:`Couldn’t turn ${t.displayName} ${e?`on`:`off`}`,body:r(n).message,detail:r(n).detail})}finally{f(!1)}};return(0,G.jsxs)(`article`,{className:h(`plg-card`,!t.active&&`plg-card--inactive`,t.problems.length>0&&`plg-card--problem`),"aria-labelledby":b,children:[(0,G.jsxs)(`header`,{className:`plg-card__head`,children:[(0,G.jsxs)(`div`,{className:`plg-card__titles`,children:[(0,G.jsx)(`h3`,{className:`plg-card__name`,id:b,children:t.displayName}),(0,G.jsxs)(`p`,{className:`plg-card__meta`,children:[(0,G.jsx)(`span`,{children:j(t.source,s)}),t.version?(0,G.jsx)(`span`,{className:`g-mono`,children:t.version}):null,t.displayName===t.name?null:(0,G.jsx)(`span`,{className:`g-mono plg-card__package`,children:t.name})]})]}),(0,G.jsx)(Q,{plugin:t}),t.canDisable?(0,G.jsx)(`span`,{className:`plg-card__switch`,children:(0,G.jsx)(u,{checked:t.enabled,disabled:d,onChange:e=>void S(e),"aria-label":`Use ${t.displayName}`})}):(0,G.jsx)(`span`,{className:`plg-card__always g-faint`,title:`The app’s own parts can’t be turned off`,children:`Always on`})]}),t.description?(0,G.jsx)(`p`,{className:`plg-card__description`,children:t.description}):null,(0,G.jsx)(ce,{plugin:t,technical:v}),m.length>0||g.length>0?(0,G.jsxs)(`ul`,{className:`plg-notes`,children:[m.map(t=>(0,G.jsxs)(`li`,{children:[(0,G.jsx)(e,{kind:`transpose`,tone:`change`}),` `,R(t,i)]},`${t.kind}-${t.id}`)),g.map(t=>(0,G.jsxs)(`li`,{children:[(0,G.jsx)(e,{kind:`reg`}),` `,R(t,i)]},`${t.kind}-${t.id}`))]}):null,t.active&&_.length>0?(0,G.jsxs)(`p`,{className:`plg-card__needs`,children:[`It does nothing until its `,_.map(e=>e.label).join(` and `),` `,_.length===1?`is`:`are`,` set, below.`]}):null,p.length>0?(0,G.jsxs)(`div`,{className:`plg-adds`,children:[(0,G.jsx)(`p`,{className:`g-eyebrow`,children:t.active?`Adds`:`Would add`}),(0,G.jsx)(`ul`,{className:`plg-adds__list`,children:p.map(e=>(0,G.jsx)(`li`,{className:`plg-adds__item`,children:e.to&&t.active?(0,G.jsxs)(l,{className:`plg-adds__link`,to:e.to,title:e.where?`Shows up in ${e.where}`:void 0,children:[e.text,(0,G.jsxs)(`span`,{className:`g-sr`,children:[`, shows up in `,e.where]})]}):(0,G.jsx)(`span`,{children:e.text})},e.kind))})]}):F(t.contributes)?null:t.problems.length===0?(0,G.jsx)(`p`,{className:`g-hint plg-card__nothing`,children:`It doesn’t add anything yet.`}):null,(0,G.jsx)(se,{plugin:t,siteId:o}),y?(0,G.jsxs)(`details`,{className:`app-details plg-card__tech`,children:[(0,G.jsx)(`summary`,{children:`Technical details`}),(0,G.jsx)(`pre`,{className:`app-error__detail`,children:v.join(`
|
|
3
3
|
`)})]}):null]})}var ue=[`site`,`user`,`builtin`];function de(){return(0,G.jsx)(`div`,{className:`plg-list`,"aria-busy":`true`,"aria-label":`Loading plugins`,children:[0,1,2].map(e=>(0,G.jsxs)(`div`,{className:`plg-card`,children:[(0,G.jsx)(m,{width:180-e*30,height:18}),(0,G.jsx)(m,{lines:2})]},e))})}function fe({list:e,siteId:t,linkSiteId:n}){let r=c(e=>e.meta?.mode===`hosted`),i=(0,A.useMemo)(()=>new Map(e.plugins.map(e=>[e.name,e.displayName])),[e.plugins]),a=e=>i.get(e)??e,o=ue.map(t=>({source:t,plugins:U(e.plugins.filter(e=>e.source===t))}));return(0,G.jsx)(`div`,{className:`plg-groups`,children:o.map(({source:i,plugins:o})=>{if(i===`site`&&!t)return null;let s=j(i,r);return(0,G.jsxs)(`section`,{className:`plg-group`,"aria-label":s,children:[(0,G.jsxs)(`h2`,{className:`plg-group__title`,children:[s,o.length?(0,G.jsx)(b,{value:o.length,quiet:!0,label:_(o.length,`plugin`)}):null]}),o.length===0?(0,G.jsx)(`p`,{className:`plg-group__empty`,children:i===`site`?`This site doesn’t name any plugins. A developer can add some to the site’s settings file; they load for this site only.`:r?`Nothing has been added on this server yet. Plugins added with the command below show up here.`:`Nothing has been added on this computer yet. Plugins added with the command below show up here.`}):(0,G.jsx)(`div`,{className:`plg-list`,children:o.map(r=>(0,G.jsx)(le,{plugin:r,conflicts:e.conflicts,nameOf:a,linkSiteId:n,siteId:t},`${r.source}-${r.name}`))})]},i)})})}function pe({list:e}){let t=e.plugins.filter(e=>e.problems.length>0);return t.length===0?null:(0,G.jsxs)(`p`,{className:`plg-attention`,role:`status`,children:[_(t.length,`plugin`),` `,t.length===1?`isn’t`:`aren’t`,` working: `,t.map(e=>e.displayName).join(`, `),`. `,t.length===1?`Its note says`:`Their notes say`,` why.`]})}function $({siteId:e,linkSiteId:t}){let n=O(e);return n.loading?(0,G.jsx)(de,{}):n.status===`error`&&!n.data?(0,G.jsx)(i,{title:`Couldn’t load the plugins`,error:n.error,onRetry:()=>void n.refetch()}):n.data?n.data.plugins.length===0?(0,G.jsx)(a,{title:`No plugins here.`,body:`This server doesn’t offer plugins, so nothing beyond the app’s own parts is in use.`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(pe,{list:n.data}),(0,G.jsx)(fe,{list:n.data,siteId:e,linkSiteId:t})]}):null}function me(){w({crumbs:[{label:`Plugins`}]});let e=T(e=>e.sites)?.find(e=>!e.missing)??null;return(0,G.jsx)(`div`,{className:`app-screen`,children:(0,G.jsxs)(`div`,{className:`app-screen__inner plg-screen`,children:[(0,G.jsx)(C,{title:`Plugins`,description:`What plugins add to this app — image and video generators, form destinations, scripts, importers and tools for the assistant. They apply to every site you open here.`}),(0,G.jsx)(q,{}),(0,G.jsx)($,{linkSiteId:e?.id??null}),(0,G.jsx)(K,{})]})})}function he(){let{siteId:e=``}=t(),n=te(e=>e.detail?.name);return w({crumbs:[{label:`Settings`,to:`/sites/${e}/settings`},{label:`Plugins`}]}),(0,G.jsx)(`div`,{className:`app-screen`,children:(0,G.jsxs)(`div`,{className:`app-screen__inner plg-screen`,children:[(0,G.jsx)(C,{title:`Plugins for this site`,description:`Everything active while ${n??`this site`} is open: what’s added to the app, and the plugins the site itself names.`,actions:(0,G.jsx)(l,{className:g(`secondary`),to:`/plugins`,children:`All plugins`})}),(0,G.jsx)(q,{}),(0,G.jsx)($,{siteId:e,linkSiteId:e})]})})}export{me as PluginsScreen,he as SitePluginsScreen};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{$ as e,A as t,D as n,Ft as r,G as i,H as a,I as o,N as s,Nt as c,O as l,S as u,St as d,_ as f,a as p,b as m,bt as h,gt as g,h as _,ht as v,it as y,k as b,mt as x,n as S,p as C,pt as w,r as T,vt as E,z as D}from"./ui-C6O2tW4c.js";import{a as O,c as ee,f as k,i as te,n as ne,o as A,r as j,s as M,t as re}from"./listPlan-BPJMzA6e.js";import{a as N,f as P,n as F}from"./paths-B6ATG9Kg.js";import{t as I}from"./scaffold-DrnWBKU9.js";import{n as ie,r as L,t as R}from"./site-DJUEXLHW.js";import{a as z,n as B,o as V,r as H,s as ae,t as U}from"./clickToEdit-CV1WT3k1.js";import{t as W}from"./PreviewControls-Du87hOEG.js";var G=r(c(),1),K=h(),q=new WeakMap,J=new WeakMap,oe=new WeakMap;function se(e,t,n){let r=q.get(e);r||q.set(e,r=new Map);let i=N(t),a=r.get(i);return a||r.set(i,a=new Set),a.add(n),()=>a?.delete(n)}function ce(e,t,n){for(let r of q.get(e)?.get(N(t))??[])r(n)}function le(e){let t=J.get(e);if(!t)return!1;J.delete(e);let n=oe.get(e);return n!==void 0&&T.getState().dismiss(n),t(),!0}function Y({store:e,path:t},n,r,i){if(!n)return null;let a=N(t),o=e.actions.idle()?{raw:e.getState().raw,hash:e.getState().hash}:null;ce(e,t,n.change),e.actions.apply(...n.ops);let s=null,c=async()=>{o&&s!==null&&await e.actions.restore(o.raw,s)||(ce(e,t,n.undoChange),e.actions.apply(...n.undo))};return J.set(e,c),{plan:n,done:e.actions.flush().then(()=>{let t=e.getState(),n=t.refusals[a];if(n||t.saveError||t.conflict)return J.get(e)===c&&J.delete(e),n&&S({tone:`danger`,title:`Couldn’t change ${i}`,body:n}),!1;if(s=t.hash,r){let t=oe.get(e);t!==void 0&&T.getState().dismiss(t);let n=S({tone:`neutral`,title:r.title,body:r.body,action:{label:`Undo`,onClick:()=>{J.get(e)===c&&J.delete(e),c()}},duration:1e4});oe.set(e,n)}return!0})}}function X(e){let{store:t,path:n,noun:r,label:i}=e,a=()=>{let e=F(t.getState().data,n);return Array.isArray(e)?e:[]},o=e=>{let t=a();return`“${i(t[e],e)}”`};return{move(t,r){let o=a(),s=i(o[t],t);return Y(e,te(n,o.length,t,r),{title:`${s} moved`,body:`It’s now ${r+1} of ${o.length}. Undo puts it back where it was.`},`“${s}”`)},step(t,r){return Y(e,A(n,a().length,t,r),null,o(t))},duplicate(t){let r=a(),o=i(r[t],t);return Y(e,ne(n,r,t),{title:`${o} duplicated`,body:`The copy is right below the original. Undo takes it away.`},`“${o}”`)},remove(t){let o=a(),s=i(o[t],t);return Y(e,O(n,o,t),{title:`${s} removed`,body:`The ${r} is gone from this page. Undo puts it back where it was.`},`“${s}”`)},insert(t,i){return Y(e,j(n,a().length,t,i),null,`the new ${r}`)}}}var ue=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function de(e){return e.filter(e=>e.type===`blocks`&&!e.hidden)}var Z=(e,t)=>`${e}.${t}`;function fe(e){if(!e)return null;let t=e.lastIndexOf(`.`),n=Number(e.slice(t+1));return t<=0||!Number.isInteger(n)||n<0?null:{field:e.slice(0,t),index:n}}var pe=new Set([`select`,`boolean`,`number`,`color`,`date`,`datetime`,`json`]),me=new Set([`image`,`url`,`select`,`color`,`date`,`datetime`,`reference`,`boolean`,`number`,`json`]),he=/^(href|url|link|src|slug|id|icon|anchor|target|rel|class|style|type|variant|tone|align|layout|theme|size|width|height)$/i,ge=/(^|_|-)(image|img|src|logo|photo|picture|avatar|thumbnail|background|poster)s?$/i,_e=16,ve=8;function ye(e){let t=[];for(let n of e.split(/\r?\n\s*\r?\n/)){let e=n.split(/\r?\n/).filter(e=>e.trim()),r=e.length>0&&e.every(e=>/^\s*([-*+]|\d+[.)])\s+/.test(e))?e.map(e=>e.replace(/^\s*([-*+]|\d+[.)])\s+/,``)):[e.join(` `)];for(let e of r){let n=e.replace(/^\s{0,3}(#{1,6}|>)\s*/,``).replace(/!\[[^\]]*\]\([^)]*\)/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/<[^>]+>/g,``).replace(/(\*\*|__|\*|_|~~|`)/g,``).replace(/\\([\\`*_{}[\]()#+\-.!])/g,`$1`).replace(/\s+/g,` `).trim();n&&t.push(n)}}return t}var be=e=>/^(\/|\.\.?\/|https?:|mailto:|tel:|#)/i.test(e)&&!/\s/.test(e),xe=e=>be(e)&&/\.(png|jpe?g|gif|webp|avif|svg)(\?|#|$)/i.test(e),Se=e=>e.length>=3&&/[\p{L}\p{N}]/u.test(e);function Ce(e,t,n){let r=[],i=[],a=(e,t,o)=>{if(e!=null){if(typeof e==`string`){if(t?.type===`image`||!t&&ge.test(o)||xe(e)){be(e)&&i.push(e);return}if(t?me.has(t.type):he.test(o)||be(e))return;for(let t of ye(e))Se(t)&&r.push(t)}else if(Array.isArray(e))for(let n of e)a(n,t?.of??(t?.type===`tags`?{...t,type:`string`}:void 0),o);else if(typeof e==`object`)for(let[r,i]of Object.entries(e))(r!==n||t!==void 0||o!==``)&&a(i,t?.fields?.find(e=>e.key===r),r)}};if(ue(e))for(let[r,i]of Object.entries(e))r!==n&&a(i,t?.fields.find(e=>e.key===r),r);return{texts:[...new Set(r)],images:[...new Set(i)]}}function we(e,t){let n=de(e).map(e=>{let n=t[e.key],r=Array.isArray(n)?n:[],i=e.discriminator??`type`;return{field:e,sections:r.map((t,n)=>{let r=ee(t,e);return{index:n,type:ue(t)&&typeof t[i]==`string`?t[i]:``,label:M(t,e),...Ce(t,r,i)}})}}),r=new Map,i=e=>r.set(e,(r.get(e)??0)+1);for(let e of n)for(let t of e.sections){for(let e of t.texts)i(`t${e}`);for(let e of t.images)i(`i${e}`)}let a=e=>t=>r.get(`${e}${t}`)===1;return n.map(({field:e,sections:t})=>({field:e.key,sections:t.map(e=>({index:e.index,type:e.type,label:e.label,texts:e.texts.filter(a(`t`)).sort((e,t)=>t.length-e.length).slice(0,_e),images:e.images.filter(a(`i`)).slice(0,ve)}))}))}function Te(e){return(e?.fields??[]).filter(e=>{if(e.hidden)return!1;if(e.type===`boolean`)return!0;let t=e.options?.length??0;return e.type===`select`&&t>=2&&t<=6})}function Ee(e){let t=e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/[-_]+/g,` `).trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function De(e,t){return(ue(e)?e[t.key]:void 0)??t.default}function Oe(e,t=3){let n=e.fields.filter(e=>!e.hidden&&!pe.has(e.type)&&!/^(id|anchor|slug)$/i.test(e.key)).map(e=>e.label);if(n.length===0)return`No fields`;let r=n.slice(0,t).join(` · `);return n.length>t?`${r} · ${n.length-t} more`:r}var ke=e=>{let t=(e.trim().split(/\s+/)[0]??``).toLowerCase();return t.length>3?t.replace(/s$/,``):t};function Ae(e){if(e.length<8)return[{label:null,blocks:[...e]}];let t=new Map;for(let n of e){let e=ke(n.label);t.set(e,[...t.get(e)??[],n])}let n=[...t.values()].filter(e=>e.length>=2);if(n.length<2)return[{label:null,blocks:[...e]}];let r=new Set(n.flat()),i=n.map(e=>({label:e[0].label.trim().split(/\s+/)[0],blocks:e})),a=e.filter(e=>!r.has(e));return a.length>0&&i.push({label:`More sections`,blocks:a}),i}function je(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?[...e]:e.filter(e=>{let t=`${e.label} ${e.type} ${e.description??``}`.toLowerCase();return n.every(e=>t.includes(e))})}function Me(e,t){return e.length===0?`on this page`:t>=e.length?`at the end of the page`:t<=0?`at the top of the page`:`after “${e[t-1]}”`}function Ne({siteId:e,block:t,titled:n=!0}){let[r,a]=(0,G.useState)(!1);return t.thumbnail&&!r?(0,K.jsx)(`span`,{className:`builder-thumb`,children:(0,K.jsx)(`img`,{src:i(e,t.thumbnail),alt:``,loading:`lazy`,decoding:`async`,draggable:!1,onError:()=>a(!0)})}):(0,K.jsxs)(`span`,{className:`builder-thumb builder-thumb--plain g-crop`,"aria-hidden":`true`,children:[n?(0,K.jsx)(`span`,{className:`builder-thumb__title`,children:t.label}):null,(0,K.jsxs)(`span`,{className:`builder-thumb__rules`,children:[(0,K.jsx)(`span`,{}),(0,K.jsx)(`span`,{}),(0,K.jsx)(`span`,{})]})]})}function Pe({siteId:e,blocks:t,layout:n,onPick:r,onPress:i,current:a,autoFocus:o,focusToken:s,disabled:c}){let u=(0,G.useId)();(0,G.useEffect)(()=>{s&&document.getElementById(`${u}-search`)?.focus()},[s,u]);let[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(0),h=(0,G.useMemo)(()=>je(t,d),[t,d]),_=(0,G.useMemo)(()=>d.trim()?[{label:null,blocks:h}]:Ae(h),[h,d]),v=_.flatMap(e=>e.blocks),y=e=>`${u}-option-${e}`,b=e=>{e&&!c&&r(e)},x=e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=(p+(e.key===`ArrowDown`?1:-1)+v.length)%Math.max(1,v.length);m(t),document.getElementById(y(t))?.scrollIntoView({block:`nearest`})}else e.key===`Enter`&&(e.preventDefault(),b(v[p]))},S=-1;return(0,K.jsxs)(`div`,{className:g(`builder-palette`,`builder-palette--${n}`),children:[(0,K.jsxs)(`div`,{className:`app-palette-search builder-palette__search`,children:[(0,K.jsx)(E,{name:`search`}),(0,K.jsx)(l,{id:`${u}-search`,"data-autofocus":o||void 0,size:`sm`,value:d,placeholder:`Find a section type…`,"aria-label":`Find a section type`,role:`combobox`,"aria-expanded":`true`,"aria-controls":`${u}-list`,"aria-activedescendant":v[p]?y(p):void 0,onChange:e=>{f(e.target.value),m(0)},onKeyDown:x,className:`builder-palette__input`})]}),(0,K.jsxs)(`div`,{className:`builder-palette__list`,id:`${u}-list`,role:`listbox`,"aria-label":`Section types`,children:[_.map(t=>(0,K.jsxs)(`div`,{role:`group`,"aria-label":t.label??void 0,className:`builder-palette__group`,children:[t.label?(0,K.jsx)(`p`,{className:`g-eyebrow builder-palette__heading`,"aria-hidden":`true`,children:t.label}):null,t.blocks.map(t=>{S+=1;let r=S;return(0,K.jsxs)(`div`,{id:y(r),role:`option`,"aria-selected":r===p,"aria-disabled":c||void 0,"aria-current":a===t.type?`true`:void 0,"data-block-type":t.type,className:g(`builder-card`,r===p&&`builder-card--active`,a===t.type&&`builder-card--current`),onMouseEnter:()=>m(r),onClick:()=>b(t),onPointerDown:e=>{!i||c||e.pointerType===`mouse`&&e.button!==0||i(e.nativeEvent,t)},children:[(0,K.jsx)(Ne,{siteId:e,block:t,titled:n===`grid`}),(0,K.jsxs)(`span`,{className:`builder-card__text`,children:[(0,K.jsx)(`span`,{className:`builder-card__label`,children:t.label}),(0,K.jsx)(`span`,{className:`builder-card__description`,children:t.description??Oe(t)})]})]},t.type)})]},t.label??`all`)),v.length===0?(0,K.jsxs)(`p`,{className:`builder-palette__empty`,children:[`No section types match “`,d,`”.`]}):null]})]})}function Fe(e,t){let[n,r]=(0,G.useState)(()=>{try{let n=window.localStorage.getItem(e);if(n===null)return t;let r=JSON.parse(n);return typeof r==typeof t?r:t}catch{return t}});return[n,(0,G.useCallback)(t=>{r(t);try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}},[e])]}function Ie(e,t){return{saving:(0,G.useSyncExternalStore)(e.subscribe,()=>e.getState().saveState[t]===`saving`),refusal:(0,G.useSyncExternalStore)(e.subscribe,()=>e.getState().refusals[t])}}function Le({store:t,field:n,path:r,item:i}){let{saving:a,refusal:o}=Ie(t,N(r)),s=De(i,n),c=e=>t.actions.edit(r,e,{required:n.required,immediate:!0}),l;if(n.type===`boolean`)l=(0,K.jsx)(p,{checked:s===!0,onChange:c,label:n.label});else{let e=(n.options??[]).map(e=>({value:e,label:Ee(e)}));l=typeof s==`string`&&n.options?.includes(s)?(0,K.jsx)(f,{label:n.label,options:e,value:s,onChange:c,className:`builder-option__choices`}):(0,K.jsx)(b,{value:``,placeholder:`Choose…`,options:e,onChange:c,"aria-label":n.label})}return(0,K.jsxs)(`div`,{className:`builder-option`,"data-option":n.key,children:[n.type===`boolean`?null:(0,K.jsxs)(`span`,{className:`builder-option__label`,children:[(0,K.jsx)(`span`,{className:`g-label`,children:n.label}),(0,K.jsx)(`span`,{className:`g-field__key`,children:n.key})]}),(0,K.jsxs)(`div`,{className:`builder-option__row`,children:[l,a?(0,K.jsx)(_,{label:`Saving`}):null]}),o?(0,K.jsxs)(`p`,{className:`g-error-text`,role:`alert`,children:[(0,K.jsx)(e,{kind:`bang`}),(0,K.jsxs)(`span`,{children:[`Couldn’t change it. `,o]})]}):null]})}function Re({store:e,fieldKey:t,index:n,item:r,block:i,focusToken:a,disabled:o}){let s=Te(i),c=(0,G.useRef)(null);return(0,G.useEffect)(()=>{a&&(c.current?.scrollIntoView({block:`nearest`}),c.current?.querySelector(`[tabindex="0"], input, select, button`)?.focus())},[a]),s.length===0?(0,K.jsx)(`p`,{className:`builder-panel__hint`,ref:c,tabIndex:-1,children:`This section has no options to switch. Its words and pictures are in Edit content.`}):(0,K.jsx)(`div`,{className:`builder-options`,ref:c,"aria-disabled":o||void 0,children:s.map(i=>(0,K.jsx)(Le,{store:e,field:i,path:[t,n,i.key],item:r},i.key))})}var ze=760;function Be(){let e=(0,G.useCallback)(e=>{let t=document.querySelector(`.preview`);if(!t||typeof ResizeObserver>`u`)return()=>void 0;let n=new ResizeObserver(e);return n.observe(t),()=>n.disconnect()},[]);return(0,G.useSyncExternalStore)(e,()=>(document.querySelector(`.preview`)?.getBoundingClientRect().width??1e3)<ze)}function Ve({reason:t,docsUrl:n,onShowForm:r}){return(0,K.jsxs)(`div`,{className:`builder-note`,role:`note`,children:[(0,K.jsxs)(`p`,{className:`builder-note__title`,children:[(0,K.jsx)(e,{kind:`bang`}),(0,K.jsx)(`span`,{children:`Sections can’t be arranged on this page.`})]}),(0,K.jsx)(`p`,{children:`This site hasn’t marked its sections for arranging on the page, and they can’t be told apart for certain here. The form’s section list still works: add, move and remove them there.`}),(0,K.jsxs)(`div`,{className:`builder-note__actions`,children:[r?(0,K.jsx)(w,{size:`sm`,variant:`secondary`,onClick:r,children:`Show the form`}):null,(0,K.jsxs)(`a`,{className:`g-link builder-note__link`,href:`${n.replace(/\/+$/,``)}/visual-builder/`,target:`_blank`,rel:`noopener noreferrer`,children:[`How a site marks its sections `,(0,K.jsx)(E,{name:`external`,size:12})]})]}),t?(0,K.jsxs)(`details`,{className:`app-details builder-note__detail`,children:[(0,K.jsx)(`summary`,{children:`Technical details`}),(0,K.jsx)(`p`,{className:`g-mono`,children:t})]}):null]})}function He({siteId:e,arrange:t,onShowForm:n}){let r=Be(),[i,a]=Fe(`galley.arrange.collapsed`,!1),[o,s]=(0,G.useState)(!1),c=r?!o:i,l=(0,G.useCallback)(e=>r?s(!e):a(e),[r,a]),d=u(e=>e.meta?.brand.docsUrl)??`https://galley.fictiontribe.com/docs`,{status:f,selected:p,placing:m,target:h,editable:g,fields:v}=t,[b,S]=(0,G.useState)(0);(0,G.useEffect)(()=>{h&&(l(!1),S(Date.now()))},[h,l]),(0,G.useEffect)(()=>{t.optionsToken&&l(!1)},[t.optionsToken,l]);let C=p?.field??v[0]??null,T=C?t.labelsOf(C.key):[],E=C?.blocks??[],D=f.status===`mapped`,O=p?ee(p.item,p.field):void 0;return c?(0,K.jsxs)(`aside`,{className:`builder-panel builder-panel--rail`,"aria-label":`Arrange`,children:[(0,K.jsx)(x,{icon:`panel-left`,label:`Show the Arrange panel`,tooltipSide:`right`,onClick:()=>l(!1)}),(0,K.jsx)(x,{icon:`plus`,label:`Add a section`,tooltipSide:`right`,disabled:!D||!g,onClick:()=>{l(!1),S(Date.now())}})]}):(0,K.jsxs)(`aside`,{className:`builder-panel`,"aria-label":`Arrange`,onKeyDown:e=>{e.key===`Escape`&&(m?(e.stopPropagation(),t.stopPlacing()):h&&(e.stopPropagation(),t.setTarget(null)))},children:[(0,K.jsxs)(`div`,{className:`builder-panel__head`,children:[(0,K.jsx)(`span`,{className:`g-eyebrow`,children:`Arrange`}),(0,K.jsx)(`span`,{className:`g-hint builder-panel__count`,children:C?y(T.length,`section`):``}),(0,K.jsx)(`span`,{className:`g-toolbar__spacer`}),(0,K.jsx)(x,{icon:`panel-left`,label:`Hide the Arrange panel`,tooltipSide:`bottom`,onClick:()=>l(!0)})]}),(0,K.jsxs)(`div`,{className:`builder-panel__body`,children:[f.status===`loading`||f.status===`waiting`&&!D?(0,K.jsxs)(`p`,{className:`builder-panel__status`,"aria-busy":`true`,children:[(0,K.jsx)(_,{label:`Working`}),(0,K.jsx)(`span`,{children:`Finding the sections on the page…`})]}):f.status===`declined`?(0,K.jsx)(Ve,{reason:f.reason,docsUrl:d,onShowForm:n}):g?p?null:(0,K.jsx)(`p`,{className:`builder-panel__hint`,children:`Click a section on the page to select it. Drag it by its handle to move it, or use + between sections to add one.`}):(0,K.jsx)(`p`,{className:`builder-panel__hint`,children:`This page can’t be changed here, so its sections stay where they are.`}),D&&p&&t.store?(0,K.jsxs)(`section`,{className:`builder-panel__selected`,"aria-label":`${O?.label??`Section`}, selected`,children:[(0,K.jsxs)(`p`,{className:`g-eyebrow`,children:[`Selected · `,p.index+1,` of `,T.length]}),(0,K.jsxs)(`div`,{className:`builder-panel__title-row`,children:[(0,K.jsx)(`p`,{className:`builder-panel__title`,children:O?.label??T[p.index]??`Section`}),(0,K.jsx)(w,{size:`sm`,variant:`secondary`,onClick:()=>t.editSection(p.field.key,p.index),children:`Edit content`})]}),g?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`g-eyebrow builder-panel__sub`,children:`Options`}),(0,K.jsx)(Re,{store:t.store,fieldKey:p.field.key,index:p.index,item:p.item,block:O,focusToken:t.optionsToken})]}):null]}):null,D&&g&&C?(0,K.jsxs)(`section`,{className:`builder-panel__add`,"aria-label":`Add a section`,children:[(0,K.jsx)(`p`,{className:`g-eyebrow builder-panel__sub`,children:`Add a section`}),m?(0,K.jsxs)(`div`,{className:`builder-placing`,role:`status`,children:[(0,K.jsxs)(`p`,{children:[`Choose where `,(0,K.jsx)(`strong`,{children:m.block.label}),` goes: press a + line on the page, or:`]}),(0,K.jsxs)(`div`,{className:`builder-placing__actions`,children:[(0,K.jsx)(w,{size:`sm`,variant:`primary`,onClick:()=>{t.insertAt(m.block,m.field,T.length),t.stopPlacing()},children:`Add at the end`}),p?(0,K.jsxs)(w,{size:`sm`,variant:`secondary`,onClick:()=>{t.insertAt(m.block,m.field,p.index+1),t.stopPlacing()},children:[`Add after “`,T[p.index],`”`]}):null,(0,K.jsx)(w,{size:`sm`,variant:`quiet`,onClick:t.stopPlacing,children:`Not now`})]})]}):h?(0,K.jsxs)(`div`,{className:`builder-placing`,role:`status`,children:[(0,K.jsxs)(`p`,{children:[`Pick a section to add `,(0,K.jsx)(`strong`,{children:Me(T,h.index)}),`.`]}),(0,K.jsx)(`div`,{className:`builder-placing__actions`,children:(0,K.jsx)(w,{size:`sm`,variant:`quiet`,onClick:()=>t.setTarget(null),children:`Not now`})})]}):(0,K.jsx)(`p`,{className:`builder-panel__hint`,children:`Drag one onto the page, or pick one and then choose its place.`}),(0,K.jsx)(Pe,{siteId:e,blocks:E,layout:`rows`,onPick:t.choose,onPress:t.beginDrag,current:m?.block.type??null,focusToken:b})]}):null]}),(0,K.jsx)(`div`,{className:`g-sr`,role:`status`,children:t.note})]})}var Ue=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Q=e=>typeof e==`number`&&Number.isInteger(e)&&e>=0,We=e=>typeof e==`string`&&e.startsWith(`/`)&&!e.startsWith(`//`);function Ge(e){return Ue(e)&&[`x`,`y`,`width`,`height`].every(t=>typeof e[t]==`number`&&Number.isFinite(e[t]))}function Ke(e){if(!Ue(e)||e.galley!==1)return null;switch(e.type){case`ready`:case`navigate`:return We(e.path)&&typeof e.title==`string`?{galley:1,type:e.type,path:e.path,title:e.title}:null;case`select`:return typeof e.text==`string`&&typeof e.tag==`string`&&Q(e.occurrence)&&Q(e.total)&&Ge(e.rect)?{galley:1,type:`select`,text:e.text,tag:e.tag,occurrence:e.occurrence,total:e.total,rect:e.rect}:null;case`select-image`:return typeof e.src==`string`&&typeof e.alt==`string`&&Ge(e.rect)?{galley:1,type:`select-image`,src:e.src,alt:e.alt,rect:e.rect}:null;case`edit`:return typeof e.text==`string`&&typeof e.newText==`string`&&Q(e.occurrence)&&Q(e.total)?{galley:1,type:`edit`,text:e.text,newText:e.newText,occurrence:e.occurrence,total:e.total}:null;case`edit-cancelled`:return typeof e.text==`string`&&Q(e.occurrence)?{galley:1,type:`edit-cancelled`,text:e.text,occurrence:e.occurrence}:null;case`scroll`:return typeof e.y==`number`&&Number.isFinite(e.y)?{galley:1,type:`scroll`,y:e.y}:null;case`arrange-status`:return e.status!==`mapped`&&e.status!==`waiting`&&e.status!==`declined`||e.how!==null&&e.how!==`markers`&&e.how!==`evidence`||e.reason!==null&&typeof e.reason!=`string`||!Q(e.revision)?null:{galley:1,type:`arrange-status`,status:e.status,how:e.how,reason:e.reason,revision:e.revision};case`arrange-select`:return e.key===null||qe(e.key)?{galley:1,type:`arrange-select`,key:e.key}:null;case`arrange-action`:{if(typeof e.field!=`string`||!Q(e.index))return null;let{field:t,index:n}=e;switch(e.action){case`move`:return Q(e.to)?{galley:1,type:`arrange-action`,action:`move`,field:t,index:n,to:e.to}:null;case`step`:return e.delta===1||e.delta===-1?{galley:1,type:`arrange-action`,action:`step`,field:t,index:n,delta:e.delta}:null;case`duplicate`:case`remove`:case`edit`:case`options`:case`add`:case`undo`:return{galley:1,type:`arrange-action`,action:e.action,field:t,index:n};default:return null}}case`placing-at`:return e.field===null&&e.index===null?{galley:1,type:`placing-at`,field:null,index:null}:typeof e.field==`string`&&Q(e.index)?{galley:1,type:`placing-at`,field:e.field,index:e.index}:null;case`place`:return typeof e.field==`string`&&Q(e.index)?{galley:1,type:`place`,field:e.field,index:e.index}:null;default:return null}}var qe=e=>typeof e==`string`&&/^[^\s]+\.\d+$/.test(e)&&e.length<=200;function $(e){return{galley:1,...e}}function Je(e,t){return`${e.replace(/\/+$/,``)}${t.startsWith(`/`)?t:`/${t}`}`}function Ye(e,t){let n=e.trim();if(!n)return null;if(/^[a-z][a-z0-9+.-]*:/i.test(n))try{let e=new URL(n);return t.some(t=>t&&new URL(t).origin===e.origin)?`${e.pathname}${e.search}${e.hash}`:null}catch{return null}return n.startsWith(`//`)?null:n.startsWith(`/`)?n:`/${n}`}function Xe(e){return e.split(/[?#]/)[0]||`/`}function Ze(e){return{entries:[e],index:0,pendingIndex:null}}function Qe(e,t){if(e.pendingIndex!==null&&e.entries[e.pendingIndex]===t)return{...e,index:e.pendingIndex,pendingIndex:null};if(e.entries[e.index]===t)return{...e,pendingIndex:null};let n=[...e.entries.slice(0,e.index+1),t].slice(-50);return{entries:n,index:n.length-1,pendingIndex:null}}function $e(e,t){let n=e.index+t,r=e.entries[n];return r===void 0?null:{history:{...e,pendingIndex:n},path:r}}var et=(e,t)=>e.entries[e.index+t]!==void 0,tt=/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;function nt(e){let t=e.trim();if(tt.test(t))return t.toUpperCase();let n=/^rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i.exec(t);return n?`#${[n[1],n[2],n[3]].map(e=>Math.min(255,Number(e)).toString(16).padStart(2,`0`)).join(``)}`.toUpperCase():null}function rt(e,t,n){return t<e.left||t>=e.right||n<e.top||n>=e.bottom?null:{x:t-e.left,y:n-e.top}}function it(e,t,n){return e===`touch`?Math.abs(t)>10&&Math.abs(t)>Math.abs(n)*1.2:Math.hypot(t,n)>5}var at=`app-placing`;function ot(e,t){let n=e.target instanceof Node?e.target.ownerDocument??document:document,r={x:e.clientX,y:e.clientY},i=!1,a=null,o=null,s=(e,t)=>{o&&(o.style.transform=`translate(${Math.round(e+12)}px, ${Math.round(t+10)}px)`)},c=()=>{i=!0,n.documentElement.classList.add(at),o=n.createElement(`div`),o.className=`builder-ghost`,o.setAttribute(`aria-hidden`,`true`),o.textContent=t.label,n.body.append(o),t.onStart()},l=n=>{if(n.pointerId!==e.pointerId)return;if(!i){if(!it(n.pointerType,n.clientX-r.x,n.clientY-r.y))return;c()}n.preventDefault(),s(n.clientX,n.clientY);let l=t.frame(),u=l?rt(l.getBoundingClientRect(),n.clientX,n.clientY):null;o?.classList.toggle(`builder-ghost--over`,u!==null),(u||a)&&t.onPoint(u),a=u},u=e=>{n.removeEventListener(`pointermove`,l,!0),n.removeEventListener(`pointerup`,d,!0),n.removeEventListener(`pointercancel`,f,!0),n.removeEventListener(`keydown`,p,!0),i&&(n.documentElement.classList.remove(at),o?.remove(),o=null,t.onEnd(e&&a!==null))},d=t=>{t.pointerId===e.pointerId&&u(!0)},f=t=>{t.pointerId===e.pointerId&&u(!1)},p=e=>{e.key===`Escape`&&i&&(e.preventDefault(),e.stopPropagation(),a=null,u(!1))};return n.addEventListener(`pointermove`,l,!0),n.addEventListener(`pointerup`,d,!0),n.addEventListener(`pointercancel`,f,!0),n.addEventListener(`keydown`,p,!0),()=>{a=null,u(!1)}}var st=6e3,ct=[],lt={};function ut(e,t,n){let r=(0,G.useCallback)(t=>e?e.subscribe(t):()=>void 0,[e]);return(0,G.useSyncExternalStore)(r,()=>e?t(e.getState()):n)}function dt({source:e,on:t,post:n,frame:r}){let i=e?.entry??null,a=e?.store??null,o=(0,G.useMemo)(()=>de(i?.fields??ct),[i?.fields]),s=o.length>0&&a!==null,c=t&&s,l=i!==null&&i.status!==`deleted`,u=ut(a,e=>e.stored,lt),d=ut(a,e=>e.data,lt),f=ut(a,e=>e.busy,!1),p=(0,G.useMemo)(()=>we(o,u),[o,u]),m=(0,G.useRef)({signature:``,value:0}),h=JSON.stringify(p);h!==m.current.signature&&(m.current={signature:h,value:m.current.value+1});let g=m.current.value,[_,v]=(0,G.useState)(null),y=(0,G.useRef)(!1),b=(0,G.useCallback)((e,t=!1)=>{y.current=t,v(e)},[]),[x,S]=(0,G.useState)({status:`loading`,how:null,reason:null}),[C,w]=(0,G.useState)(0),[T,E]=(0,G.useState)(null),[D,O]=(0,G.useState)(null),[ee,k]=(0,G.useState)(null),[te,ne]=(0,G.useState)(0),[A,j]=(0,G.useState)(``),N=(0,G.useRef)(D);N.current=D;let P=(0,G.useRef)(null),F=(0,G.useRef)(null);(0,G.useEffect)(()=>{b(null),E(null),O(null),S({status:`loading`,how:null,reason:null})},[i?.path,b]);let ie=(0,G.useRef)(g);(0,G.useEffect)(()=>{ie.current!==g&&(ie.current=g,x.status===`mapped`&&w(Date.now()+st))},[g,x.status]),(0,G.useEffect)(()=>{if(C<=Date.now())return;let e=setTimeout(()=>w(0),C-Date.now()+10);return()=>clearTimeout(e)},[C]);let L=f||C>Date.now(),R=fe(_),z=R?o.find(e=>e.key===R.field)??null:null,B=z?d[z.key]:void 0,V=R&&Array.isArray(B)?B[R.index]:void 0;(0,G.useEffect)(()=>{_&&V===void 0&&!f&&b(null)},[_,V,f,b]),(0,G.useEffect)(()=>{if(!a)return;let e=o.map(e=>se(a,[e.key],t=>{v(n=>{let r=fe(n);if(!r||r.field!==e.key)return n;let i=re(r.index,t);return i===null?null:Z(e.key,i)})}));return()=>e.forEach(e=>e())},[a,o]);let H=(0,G.useCallback)(()=>{n($({type:`arrange`,on:c,lists:c?p:[],editable:l,selected:c?_:null,settling:L,revision:g,reveal:y.current})),y.current=!1},[n,c,p,l,_,L,g]),ae=(0,G.useRef)(!1);(0,G.useEffect)(()=>{(c||ae.current)&&(ae.current=c,H())},[H,c]);let U=(0,G.useMemo)(()=>{let e=new Map;if(a)for(let t of o)e.set(t.key,{field:t,actions:X({store:a,path:[t.key],noun:`section`,label:e=>M(e,t)})});return e},[a,o]),W=(0,G.useCallback)(e=>{let t=U.get(e),n=d[e];return t&&Array.isArray(n)?n.map(e=>M(e,t.field)):[]},[U,d]),K=(0,G.useCallback)((e,t,n)=>{let r=U.get(t);if(!r||!l)return;let i=Me(W(t),n);r.actions.insert(n,I(e,r.field.discriminator??`type`))&&(b(Z(t,n),!0),j(`${e.label} added ${i}. It’s waiting in Proof.`))},[U,l,W,b]),q=(0,G.useCallback)(()=>{N.current&&n($({type:`placing`,field:null,label:null})),O(null),k(null)},[n]),J=(0,G.useCallback)(t=>{switch(t.type){case`arrange-status`:if(t.revision!==m.current.value)return;S({status:t.status,how:t.how,reason:t.reason}),t.status===`mapped`&&w(0);return;case`arrange-select`:b(t.key);return;case`arrange-action`:{let n=U.get(t.field);if(!n)return;let{actions:r}=n,i=d[t.field],o=Array.isArray(i)?i.length:0;switch(t.action){case`move`:l&&r.move(t.index,t.to)&&b(Z(t.field,t.to),!0);return;case`step`:{let e=fe(_),n=e&&e.field===t.field?e.index:t.index;l&&r.step(n,t.delta)&&b(Z(t.field,n+t.delta),!0);return}case`duplicate`:l&&r.duplicate(t.index)&&b(Z(t.field,t.index+1),!0);return;case`remove`:if(!l||!r.remove(t.index))return;b(o>1?Z(t.field,Math.min(t.index,o-2)):null,!0);return;case`undo`:a&&le(a);return;case`edit`:e?.onEditSection(t.field,t.index);return;case`options`:b(Z(t.field,t.index)),ne(Date.now());return;case`add`:E({field:t.field,index:t.index});return}return}case`placing-at`:k(t.index);return;case`place`:{let e=N.current??P.current;P.current=null,e&&K(e.block,t.field,t.index),q();return}}},[U,d,l,_,b,e,a,K,q]),oe=(0,G.useCallback)(e=>{let t=o[0];if(!t||!l)return;if(T){K(e,T.field,T.index),E(null);return}let r=N.current;if(r&&r.block.type===e.type){K(e,r.field,W(r.field).length),q();return}let i=fe(_)?.field??t.key;O({block:e,field:i}),n($({type:`placing`,field:i,label:e.label}))},[o,l,T,_,K,W,q,n]),ce=(0,G.useCallback)((e,t)=>{let i=fe(_)?.field??o[0]?.key;i&&l&&x.status===`mapped`&&(F.current?.(),F.current=ot(e,{frame:()=>r.current,label:t.label,onStart:()=>{E(null),O({block:t,field:i}),N.current={block:t,field:i},n($({type:`placing`,field:i,label:t.label}))},onPoint:e=>n($({type:`placing-pointer`,point:e})),onEnd:e=>{F.current=null,e?(P.current={block:t,field:i},n($({type:`placing-drop`}))):n($({type:`placing-pointer`,point:null})),n($({type:`placing`,field:null,label:null})),O(null),N.current=null,k(null),setTimeout(()=>{P.current=null},1500)}}))},[_,o,l,x.status,r,n]);return(0,G.useEffect)(()=>()=>F.current?.(),[]),(0,G.useEffect)(()=>{c||(O(null),E(null))},[c]),{available:s,active:c,editable:l,fields:o,data:d,store:a,status:x,settling:L,selected:R&&z&&V!==void 0?{...R,field:z,item:V}:null,select:b,target:T,setTarget:E,placing:D,placingAt:ee,choose:oe,beginDrag:ce,stopPlacing:q,insertAt:K,labelsOf:W,optionsToken:te,note:A,handle:J,resend:()=>{S(e=>e.status===`mapped`?e:{status:`loading`,how:null,reason:null}),c&&H()},editSection:(t,n)=>e?.onEditSection(t,n)}}function ft(e,t){let n=e?.getBoundingClientRect();if(!n||!t)return{display:`none`};let r=Math.min(Math.max(n.left+t.x,n.left),n.right-8),i=Math.min(Math.max(n.top+t.y,n.top),n.bottom-8);return{left:r,top:i,width:Math.max(1,Math.min(t.width,n.right-r)),height:Math.max(1,Math.min(t.height,n.bottom-i))}}function pt({match:n,label:r,error:i,onSave:a,onClose:o}){let[s,c]=(0,G.useState)(n.value),[l,u]=(0,G.useState)(!1),d=async()=>{u(!0),await a(s),u(!1)};return(0,K.jsxs)(`form`,{className:`preview-assist`,onSubmit:e=>{e.preventDefault(),d()},children:[(0,K.jsx)(`p`,{className:`g-eyebrow`,children:r}),(0,K.jsx)(t,{"aria-label":r,value:s,maxRows:10,"data-autofocus":!0,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),d())}}),(0,K.jsxs)(`p`,{className:`preview-assist__note`,children:[(0,K.jsx)(e,{kind:`pilcrow`}),(0,K.jsx)(`span`,{children:`This text carries formatting the page doesn’t show, like emphasis or a link, so you’re editing it as it’s stored. Keep the marks where you want them.`})]}),i?(0,K.jsxs)(`p`,{className:`g-error-text`,role:`alert`,children:[(0,K.jsx)(e,{kind:`bang`}),(0,K.jsx)(`span`,{children:i})]}):null,(0,K.jsxs)(`div`,{className:`preview-assist__actions`,children:[(0,K.jsx)(w,{type:`button`,variant:`quiet`,size:`sm`,onClick:o,children:`Leave as is`}),(0,K.jsx)(w,{type:`submit`,variant:`primary`,size:`sm`,busy:l,busyLabel:`Saving…`,disabled:s===n.value,children:`Save`})]})]})}function mt({siteId:e,assist:t,frame:n,onClose:r,onSaveStored:i,onChoose:a,onChooseSpot:o,onPickImage:s,onAsk:c,onShowForm:l}){let u=R(e=>e.detail?.model.collections),d=`rect`in t?t.rect:null,f=(0,G.useRef)(null),p=(e,t=!1)=>ae(e,u?.find(t=>t.id===e.collection)?.label,{places:t}),h=(()=>{switch(t.kind){case`stored`:return(0,K.jsx)(pt,{match:t.match,label:p(t.match),error:t.error,onSave:i,onClose:r},`${t.match.path}:${JSON.stringify(t.match.location)}`);case`choose`:return(0,K.jsxs)(`div`,{className:`preview-assist`,children:[(0,K.jsx)(`p`,{className:`preview-assist__title`,children:`Which one did you mean?`}),(0,K.jsx)(`p`,{className:`preview-assist__text`,children:t.reason}),(0,K.jsx)(`ul`,{className:`preview-assist__choices`,children:t.matches.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,className:`preview-assist__choice`,onClick:()=>a(e),children:[(0,K.jsx)(`span`,{children:p(e,!0)}),!e.editable||e.location.kind===`source`?(0,K.jsx)(`span`,{className:`g-faint`,children:` · part of the design`}):null]})},`${e.path}:${JSON.stringify(e.location)}`))})]});case`design`:return(0,K.jsxs)(`div`,{className:`preview-assist`,children:[(0,K.jsx)(`p`,{className:`preview-assist__title`,children:`This text is part of the site’s design.`}),(0,K.jsxs)(`p`,{className:`preview-assist__text`,children:[t.reason,` The assistant can change it for you.`]}),(0,K.jsxs)(`div`,{className:`preview-assist__actions`,children:[(0,K.jsx)(w,{variant:`quiet`,size:`sm`,onClick:r,children:`Close`}),c?(0,K.jsx)(w,{variant:`primary`,size:`sm`,icon:`chat`,"data-autofocus":!0,onClick:()=>{c(t.text),r()},children:`Ask the assistant to change it`}):null]})]});case`image-unknown`:return(0,K.jsxs)(`div`,{className:`preview-assist`,children:[(0,K.jsx)(`p`,{className:`preview-assist__title`,children:`This image can’t be swapped by clicking.`}),(0,K.jsx)(`p`,{className:`preview-assist__text`,children:`It isn’t one of this page’s own image fields. If it belongs to a section, change it in the form, in that section’s image field. Otherwise it’s part of the design, and the assistant can change it.`}),(0,K.jsxs)(`div`,{className:`preview-assist__actions`,children:[(0,K.jsx)(w,{variant:`quiet`,size:`sm`,onClick:r,children:`Close`}),l?(0,K.jsx)(w,{variant:`secondary`,size:`sm`,icon:`page`,"data-autofocus":!0,onClick:()=>{l(),r()},children:`Show the form`}):null,c?(0,K.jsx)(w,{variant:l?`quiet`:`primary`,size:`sm`,icon:`chat`,onClick:()=>{c(t.text,`image`),r()},children:`Ask the assistant`}):null]})]});case`image`:return t.chosen?null:(0,K.jsxs)(`div`,{className:`preview-assist`,children:[(0,K.jsx)(`p`,{className:`preview-assist__title`,children:`This image is used in more than one place.`}),(0,K.jsx)(`ul`,{className:`preview-assist__choices`,children:t.spots.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsx)(`button`,{type:`button`,className:`preview-assist__choice`,onClick:()=>o(e),children:e.label})},JSON.stringify(e.path)))})]});default:return null}})();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{ref:f,className:`preview-anchor`,style:ft(n.current,d),"aria-hidden":`true`}),(0,K.jsx)(m,{open:h!==null,onClose:r,anchor:f,placement:`bottom-start`,role:`dialog`,"aria-label":`Edit on the page`,className:`preview-assist-surface`,children:h}),t.kind===`image`?(0,K.jsx)(P,{siteId:e,open:t.chosen!==null,onClose:r,onPick:e=>void s(e)}):null]})}function ht(){let e=document.documentElement,t=nt(getComputedStyle(e).getPropertyValue(`--accent`));if(!t)return null;let n=e.dataset.theme;return{accent:t,theme:n===`dark`||n!==`light`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}}function gt(){let e=u(e=>e.meta?.brand.accent),t=C(e=>e.theme),[n,r]=(0,G.useState)(ht);return(0,G.useEffect)(()=>{let e=requestAnimationFrame(()=>r(ht())),t=window.matchMedia(`(prefers-color-scheme: dark)`),n=()=>r(ht());return t.addEventListener(`change`,n),()=>{cancelAnimationFrame(e),t.removeEventListener(`change`,n)}},[e,t]),n}function _t({log:e,open:t}){return e.length===0?null:(0,K.jsxs)(`details`,{className:`app-details preview-log`,open:t,children:[(0,K.jsx)(`summary`,{children:`What it’s doing`}),(0,K.jsx)(`pre`,{className:`app-error__detail preview-log__lines`,"aria-live":`off`,children:e.slice(-14).join(`
|
|
1
|
+
import{$ as e,A as t,D as n,Ft as r,G as i,H as a,I as o,N as s,Nt as c,O as l,S as u,St as d,_ as f,a as p,b as m,bt as h,gt as g,h as _,ht as v,it as y,k as b,mt as x,n as S,p as C,pt as w,r as T,vt as E,z as D}from"./ui-C6O2tW4c.js";import{a as O,c as ee,f as k,i as te,n as ne,o as A,r as j,s as M,t as re}from"./listPlan-Bds9RfG_.js";import{a as N,f as P,n as F}from"./paths-C9eC1yfK.js";import{t as I}from"./scaffold-CA0oGKYi.js";import{n as ie,r as L,t as R}from"./site-DJUEXLHW.js";import{a as z,n as B,o as V,r as H,s as ae,t as U}from"./clickToEdit-CV1WT3k1.js";import{t as W}from"./PreviewControls-Du87hOEG.js";var G=r(c(),1),K=h(),q=new WeakMap,J=new WeakMap,oe=new WeakMap;function se(e,t,n){let r=q.get(e);r||q.set(e,r=new Map);let i=N(t),a=r.get(i);return a||r.set(i,a=new Set),a.add(n),()=>a?.delete(n)}function ce(e,t,n){for(let r of q.get(e)?.get(N(t))??[])r(n)}function le(e){let t=J.get(e);if(!t)return!1;J.delete(e);let n=oe.get(e);return n!==void 0&&T.getState().dismiss(n),t(),!0}function Y({store:e,path:t},n,r,i){if(!n)return null;let a=N(t),o=e.actions.idle()?{raw:e.getState().raw,hash:e.getState().hash}:null;ce(e,t,n.change),e.actions.apply(...n.ops);let s=null,c=async()=>{o&&s!==null&&await e.actions.restore(o.raw,s)||(ce(e,t,n.undoChange),e.actions.apply(...n.undo))};return J.set(e,c),{plan:n,done:e.actions.flush().then(()=>{let t=e.getState(),n=t.refusals[a];if(n||t.saveError||t.conflict)return J.get(e)===c&&J.delete(e),n&&S({tone:`danger`,title:`Couldn’t change ${i}`,body:n}),!1;if(s=t.hash,r){let t=oe.get(e);t!==void 0&&T.getState().dismiss(t);let n=S({tone:`neutral`,title:r.title,body:r.body,action:{label:`Undo`,onClick:()=>{J.get(e)===c&&J.delete(e),c()}},duration:1e4});oe.set(e,n)}return!0})}}function X(e){let{store:t,path:n,noun:r,label:i}=e,a=()=>{let e=F(t.getState().data,n);return Array.isArray(e)?e:[]},o=e=>{let t=a();return`“${i(t[e],e)}”`};return{move(t,r){let o=a(),s=i(o[t],t);return Y(e,te(n,o.length,t,r),{title:`${s} moved`,body:`It’s now ${r+1} of ${o.length}. Undo puts it back where it was.`},`“${s}”`)},step(t,r){return Y(e,A(n,a().length,t,r),null,o(t))},duplicate(t){let r=a(),o=i(r[t],t);return Y(e,ne(n,r,t),{title:`${o} duplicated`,body:`The copy is right below the original. Undo takes it away.`},`“${o}”`)},remove(t){let o=a(),s=i(o[t],t);return Y(e,O(n,o,t),{title:`${s} removed`,body:`The ${r} is gone from this page. Undo puts it back where it was.`},`“${s}”`)},insert(t,i){return Y(e,j(n,a().length,t,i),null,`the new ${r}`)}}}var ue=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function de(e){return e.filter(e=>e.type===`blocks`&&!e.hidden)}var Z=(e,t)=>`${e}.${t}`;function fe(e){if(!e)return null;let t=e.lastIndexOf(`.`),n=Number(e.slice(t+1));return t<=0||!Number.isInteger(n)||n<0?null:{field:e.slice(0,t),index:n}}var pe=new Set([`select`,`boolean`,`number`,`color`,`date`,`datetime`,`json`]),me=new Set([`image`,`url`,`select`,`color`,`date`,`datetime`,`reference`,`boolean`,`number`,`json`]),he=/^(href|url|link|src|slug|id|icon|anchor|target|rel|class|style|type|variant|tone|align|layout|theme|size|width|height)$/i,ge=/(^|_|-)(image|img|src|logo|photo|picture|avatar|thumbnail|background|poster)s?$/i,_e=16,ve=8;function ye(e){let t=[];for(let n of e.split(/\r?\n\s*\r?\n/)){let e=n.split(/\r?\n/).filter(e=>e.trim()),r=e.length>0&&e.every(e=>/^\s*([-*+]|\d+[.)])\s+/.test(e))?e.map(e=>e.replace(/^\s*([-*+]|\d+[.)])\s+/,``)):[e.join(` `)];for(let e of r){let n=e.replace(/^\s{0,3}(#{1,6}|>)\s*/,``).replace(/!\[[^\]]*\]\([^)]*\)/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/<[^>]+>/g,``).replace(/(\*\*|__|\*|_|~~|`)/g,``).replace(/\\([\\`*_{}[\]()#+\-.!])/g,`$1`).replace(/\s+/g,` `).trim();n&&t.push(n)}}return t}var be=e=>/^(\/|\.\.?\/|https?:|mailto:|tel:|#)/i.test(e)&&!/\s/.test(e),xe=e=>be(e)&&/\.(png|jpe?g|gif|webp|avif|svg)(\?|#|$)/i.test(e),Se=e=>e.length>=3&&/[\p{L}\p{N}]/u.test(e);function Ce(e,t,n){let r=[],i=[],a=(e,t,o)=>{if(e!=null){if(typeof e==`string`){if(t?.type===`image`||!t&&ge.test(o)||xe(e)){be(e)&&i.push(e);return}if(t?me.has(t.type):he.test(o)||be(e))return;for(let t of ye(e))Se(t)&&r.push(t)}else if(Array.isArray(e))for(let n of e)a(n,t?.of??(t?.type===`tags`?{...t,type:`string`}:void 0),o);else if(typeof e==`object`)for(let[r,i]of Object.entries(e))(r!==n||t!==void 0||o!==``)&&a(i,t?.fields?.find(e=>e.key===r),r)}};if(ue(e))for(let[r,i]of Object.entries(e))r!==n&&a(i,t?.fields.find(e=>e.key===r),r);return{texts:[...new Set(r)],images:[...new Set(i)]}}function we(e,t){let n=de(e).map(e=>{let n=t[e.key],r=Array.isArray(n)?n:[],i=e.discriminator??`type`;return{field:e,sections:r.map((t,n)=>{let r=ee(t,e);return{index:n,type:ue(t)&&typeof t[i]==`string`?t[i]:``,label:M(t,e),...Ce(t,r,i)}})}}),r=new Map,i=e=>r.set(e,(r.get(e)??0)+1);for(let e of n)for(let t of e.sections){for(let e of t.texts)i(`t${e}`);for(let e of t.images)i(`i${e}`)}let a=e=>t=>r.get(`${e}${t}`)===1;return n.map(({field:e,sections:t})=>({field:e.key,sections:t.map(e=>({index:e.index,type:e.type,label:e.label,texts:e.texts.filter(a(`t`)).sort((e,t)=>t.length-e.length).slice(0,_e),images:e.images.filter(a(`i`)).slice(0,ve)}))}))}function Te(e){return(e?.fields??[]).filter(e=>{if(e.hidden)return!1;if(e.type===`boolean`)return!0;let t=e.options?.length??0;return e.type===`select`&&t>=2&&t<=6})}function Ee(e){let t=e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/[-_]+/g,` `).trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function De(e,t){return(ue(e)?e[t.key]:void 0)??t.default}function Oe(e,t=3){let n=e.fields.filter(e=>!e.hidden&&!pe.has(e.type)&&!/^(id|anchor|slug)$/i.test(e.key)).map(e=>e.label);if(n.length===0)return`No fields`;let r=n.slice(0,t).join(` · `);return n.length>t?`${r} · ${n.length-t} more`:r}var ke=e=>{let t=(e.trim().split(/\s+/)[0]??``).toLowerCase();return t.length>3?t.replace(/s$/,``):t};function Ae(e){if(e.length<8)return[{label:null,blocks:[...e]}];let t=new Map;for(let n of e){let e=ke(n.label);t.set(e,[...t.get(e)??[],n])}let n=[...t.values()].filter(e=>e.length>=2);if(n.length<2)return[{label:null,blocks:[...e]}];let r=new Set(n.flat()),i=n.map(e=>({label:e[0].label.trim().split(/\s+/)[0],blocks:e})),a=e.filter(e=>!r.has(e));return a.length>0&&i.push({label:`More sections`,blocks:a}),i}function je(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?[...e]:e.filter(e=>{let t=`${e.label} ${e.type} ${e.description??``}`.toLowerCase();return n.every(e=>t.includes(e))})}function Me(e,t){return e.length===0?`on this page`:t>=e.length?`at the end of the page`:t<=0?`at the top of the page`:`after “${e[t-1]}”`}function Ne({siteId:e,block:t,titled:n=!0}){let[r,a]=(0,G.useState)(!1);return t.thumbnail&&!r?(0,K.jsx)(`span`,{className:`builder-thumb`,children:(0,K.jsx)(`img`,{src:i(e,t.thumbnail),alt:``,loading:`lazy`,decoding:`async`,draggable:!1,onError:()=>a(!0)})}):(0,K.jsxs)(`span`,{className:`builder-thumb builder-thumb--plain g-crop`,"aria-hidden":`true`,children:[n?(0,K.jsx)(`span`,{className:`builder-thumb__title`,children:t.label}):null,(0,K.jsxs)(`span`,{className:`builder-thumb__rules`,children:[(0,K.jsx)(`span`,{}),(0,K.jsx)(`span`,{}),(0,K.jsx)(`span`,{})]})]})}function Pe({siteId:e,blocks:t,layout:n,onPick:r,onPress:i,current:a,autoFocus:o,focusToken:s,disabled:c}){let u=(0,G.useId)();(0,G.useEffect)(()=>{s&&document.getElementById(`${u}-search`)?.focus()},[s,u]);let[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(0),h=(0,G.useMemo)(()=>je(t,d),[t,d]),_=(0,G.useMemo)(()=>d.trim()?[{label:null,blocks:h}]:Ae(h),[h,d]),v=_.flatMap(e=>e.blocks),y=e=>`${u}-option-${e}`,b=e=>{e&&!c&&r(e)},x=e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=(p+(e.key===`ArrowDown`?1:-1)+v.length)%Math.max(1,v.length);m(t),document.getElementById(y(t))?.scrollIntoView({block:`nearest`})}else e.key===`Enter`&&(e.preventDefault(),b(v[p]))},S=-1;return(0,K.jsxs)(`div`,{className:g(`builder-palette`,`builder-palette--${n}`),children:[(0,K.jsxs)(`div`,{className:`app-palette-search builder-palette__search`,children:[(0,K.jsx)(E,{name:`search`}),(0,K.jsx)(l,{id:`${u}-search`,"data-autofocus":o||void 0,size:`sm`,value:d,placeholder:`Find a section type…`,"aria-label":`Find a section type`,role:`combobox`,"aria-expanded":`true`,"aria-controls":`${u}-list`,"aria-activedescendant":v[p]?y(p):void 0,onChange:e=>{f(e.target.value),m(0)},onKeyDown:x,className:`builder-palette__input`})]}),(0,K.jsxs)(`div`,{className:`builder-palette__list`,id:`${u}-list`,role:`listbox`,"aria-label":`Section types`,children:[_.map(t=>(0,K.jsxs)(`div`,{role:`group`,"aria-label":t.label??void 0,className:`builder-palette__group`,children:[t.label?(0,K.jsx)(`p`,{className:`g-eyebrow builder-palette__heading`,"aria-hidden":`true`,children:t.label}):null,t.blocks.map(t=>{S+=1;let r=S;return(0,K.jsxs)(`div`,{id:y(r),role:`option`,"aria-selected":r===p,"aria-disabled":c||void 0,"aria-current":a===t.type?`true`:void 0,"data-block-type":t.type,className:g(`builder-card`,r===p&&`builder-card--active`,a===t.type&&`builder-card--current`),onMouseEnter:()=>m(r),onClick:()=>b(t),onPointerDown:e=>{!i||c||e.pointerType===`mouse`&&e.button!==0||i(e.nativeEvent,t)},children:[(0,K.jsx)(Ne,{siteId:e,block:t,titled:n===`grid`}),(0,K.jsxs)(`span`,{className:`builder-card__text`,children:[(0,K.jsx)(`span`,{className:`builder-card__label`,children:t.label}),(0,K.jsx)(`span`,{className:`builder-card__description`,children:t.description??Oe(t)})]})]},t.type)})]},t.label??`all`)),v.length===0?(0,K.jsxs)(`p`,{className:`builder-palette__empty`,children:[`No section types match “`,d,`”.`]}):null]})]})}function Fe(e,t){let[n,r]=(0,G.useState)(()=>{try{let n=window.localStorage.getItem(e);if(n===null)return t;let r=JSON.parse(n);return typeof r==typeof t?r:t}catch{return t}});return[n,(0,G.useCallback)(t=>{r(t);try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}},[e])]}function Ie(e,t){return{saving:(0,G.useSyncExternalStore)(e.subscribe,()=>e.getState().saveState[t]===`saving`),refusal:(0,G.useSyncExternalStore)(e.subscribe,()=>e.getState().refusals[t])}}function Le({store:t,field:n,path:r,item:i}){let{saving:a,refusal:o}=Ie(t,N(r)),s=De(i,n),c=e=>t.actions.edit(r,e,{required:n.required,immediate:!0}),l;if(n.type===`boolean`)l=(0,K.jsx)(p,{checked:s===!0,onChange:c,label:n.label});else{let e=(n.options??[]).map(e=>({value:e,label:Ee(e)}));l=typeof s==`string`&&n.options?.includes(s)?(0,K.jsx)(f,{label:n.label,options:e,value:s,onChange:c,className:`builder-option__choices`}):(0,K.jsx)(b,{value:``,placeholder:`Choose…`,options:e,onChange:c,"aria-label":n.label})}return(0,K.jsxs)(`div`,{className:`builder-option`,"data-option":n.key,children:[n.type===`boolean`?null:(0,K.jsxs)(`span`,{className:`builder-option__label`,children:[(0,K.jsx)(`span`,{className:`g-label`,children:n.label}),(0,K.jsx)(`span`,{className:`g-field__key`,children:n.key})]}),(0,K.jsxs)(`div`,{className:`builder-option__row`,children:[l,a?(0,K.jsx)(_,{label:`Saving`}):null]}),o?(0,K.jsxs)(`p`,{className:`g-error-text`,role:`alert`,children:[(0,K.jsx)(e,{kind:`bang`}),(0,K.jsxs)(`span`,{children:[`Couldn’t change it. `,o]})]}):null]})}function Re({store:e,fieldKey:t,index:n,item:r,block:i,focusToken:a,disabled:o}){let s=Te(i),c=(0,G.useRef)(null);return(0,G.useEffect)(()=>{a&&(c.current?.scrollIntoView({block:`nearest`}),c.current?.querySelector(`[tabindex="0"], input, select, button`)?.focus())},[a]),s.length===0?(0,K.jsx)(`p`,{className:`builder-panel__hint`,ref:c,tabIndex:-1,children:`This section has no options to switch. Its words and pictures are in Edit content.`}):(0,K.jsx)(`div`,{className:`builder-options`,ref:c,"aria-disabled":o||void 0,children:s.map(i=>(0,K.jsx)(Le,{store:e,field:i,path:[t,n,i.key],item:r},i.key))})}var ze=760;function Be(){let e=(0,G.useCallback)(e=>{let t=document.querySelector(`.preview`);if(!t||typeof ResizeObserver>`u`)return()=>void 0;let n=new ResizeObserver(e);return n.observe(t),()=>n.disconnect()},[]);return(0,G.useSyncExternalStore)(e,()=>(document.querySelector(`.preview`)?.getBoundingClientRect().width??1e3)<ze)}function Ve({reason:t,docsUrl:n,onShowForm:r}){return(0,K.jsxs)(`div`,{className:`builder-note`,role:`note`,children:[(0,K.jsxs)(`p`,{className:`builder-note__title`,children:[(0,K.jsx)(e,{kind:`bang`}),(0,K.jsx)(`span`,{children:`Sections can’t be arranged on this page.`})]}),(0,K.jsx)(`p`,{children:`This site hasn’t marked its sections for arranging on the page, and they can’t be told apart for certain here. The form’s section list still works: add, move and remove them there.`}),(0,K.jsxs)(`div`,{className:`builder-note__actions`,children:[r?(0,K.jsx)(w,{size:`sm`,variant:`secondary`,onClick:r,children:`Show the form`}):null,(0,K.jsxs)(`a`,{className:`g-link builder-note__link`,href:`${n.replace(/\/+$/,``)}/visual-builder/`,target:`_blank`,rel:`noopener noreferrer`,children:[`How a site marks its sections `,(0,K.jsx)(E,{name:`external`,size:12})]})]}),t?(0,K.jsxs)(`details`,{className:`app-details builder-note__detail`,children:[(0,K.jsx)(`summary`,{children:`Technical details`}),(0,K.jsx)(`p`,{className:`g-mono`,children:t})]}):null]})}function He({siteId:e,arrange:t,onShowForm:n}){let r=Be(),[i,a]=Fe(`galley.arrange.collapsed`,!1),[o,s]=(0,G.useState)(!1),c=r?!o:i,l=(0,G.useCallback)(e=>r?s(!e):a(e),[r,a]),d=u(e=>e.meta?.brand.docsUrl)??`https://galley.fictiontribe.com/docs`,{status:f,selected:p,placing:m,target:h,editable:g,fields:v}=t,[b,S]=(0,G.useState)(0);(0,G.useEffect)(()=>{h&&(l(!1),S(Date.now()))},[h,l]),(0,G.useEffect)(()=>{t.optionsToken&&l(!1)},[t.optionsToken,l]);let C=p?.field??v[0]??null,T=C?t.labelsOf(C.key):[],E=C?.blocks??[],D=f.status===`mapped`,O=p?ee(p.item,p.field):void 0;return c?(0,K.jsxs)(`aside`,{className:`builder-panel builder-panel--rail`,"aria-label":`Arrange`,children:[(0,K.jsx)(x,{icon:`panel-left`,label:`Show the Arrange panel`,tooltipSide:`right`,onClick:()=>l(!1)}),(0,K.jsx)(x,{icon:`plus`,label:`Add a section`,tooltipSide:`right`,disabled:!D||!g,onClick:()=>{l(!1),S(Date.now())}})]}):(0,K.jsxs)(`aside`,{className:`builder-panel`,"aria-label":`Arrange`,onKeyDown:e=>{e.key===`Escape`&&(m?(e.stopPropagation(),t.stopPlacing()):h&&(e.stopPropagation(),t.setTarget(null)))},children:[(0,K.jsxs)(`div`,{className:`builder-panel__head`,children:[(0,K.jsx)(`span`,{className:`g-eyebrow`,children:`Arrange`}),(0,K.jsx)(`span`,{className:`g-hint builder-panel__count`,children:C?y(T.length,`section`):``}),(0,K.jsx)(`span`,{className:`g-toolbar__spacer`}),(0,K.jsx)(x,{icon:`panel-left`,label:`Hide the Arrange panel`,tooltipSide:`bottom`,onClick:()=>l(!0)})]}),(0,K.jsxs)(`div`,{className:`builder-panel__body`,children:[f.status===`loading`||f.status===`waiting`&&!D?(0,K.jsxs)(`p`,{className:`builder-panel__status`,"aria-busy":`true`,children:[(0,K.jsx)(_,{label:`Working`}),(0,K.jsx)(`span`,{children:`Finding the sections on the page…`})]}):f.status===`declined`?(0,K.jsx)(Ve,{reason:f.reason,docsUrl:d,onShowForm:n}):g?p?null:(0,K.jsx)(`p`,{className:`builder-panel__hint`,children:`Click a section on the page to select it. Drag it by its handle to move it, or use + between sections to add one.`}):(0,K.jsx)(`p`,{className:`builder-panel__hint`,children:`This page can’t be changed here, so its sections stay where they are.`}),D&&p&&t.store?(0,K.jsxs)(`section`,{className:`builder-panel__selected`,"aria-label":`${O?.label??`Section`}, selected`,children:[(0,K.jsxs)(`p`,{className:`g-eyebrow`,children:[`Selected · `,p.index+1,` of `,T.length]}),(0,K.jsxs)(`div`,{className:`builder-panel__title-row`,children:[(0,K.jsx)(`p`,{className:`builder-panel__title`,children:O?.label??T[p.index]??`Section`}),(0,K.jsx)(w,{size:`sm`,variant:`secondary`,onClick:()=>t.editSection(p.field.key,p.index),children:`Edit content`})]}),g?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`g-eyebrow builder-panel__sub`,children:`Options`}),(0,K.jsx)(Re,{store:t.store,fieldKey:p.field.key,index:p.index,item:p.item,block:O,focusToken:t.optionsToken})]}):null]}):null,D&&g&&C?(0,K.jsxs)(`section`,{className:`builder-panel__add`,"aria-label":`Add a section`,children:[(0,K.jsx)(`p`,{className:`g-eyebrow builder-panel__sub`,children:`Add a section`}),m?(0,K.jsxs)(`div`,{className:`builder-placing`,role:`status`,children:[(0,K.jsxs)(`p`,{children:[`Choose where `,(0,K.jsx)(`strong`,{children:m.block.label}),` goes: press a + line on the page, or:`]}),(0,K.jsxs)(`div`,{className:`builder-placing__actions`,children:[(0,K.jsx)(w,{size:`sm`,variant:`primary`,onClick:()=>{t.insertAt(m.block,m.field,T.length),t.stopPlacing()},children:`Add at the end`}),p?(0,K.jsxs)(w,{size:`sm`,variant:`secondary`,onClick:()=>{t.insertAt(m.block,m.field,p.index+1),t.stopPlacing()},children:[`Add after “`,T[p.index],`”`]}):null,(0,K.jsx)(w,{size:`sm`,variant:`quiet`,onClick:t.stopPlacing,children:`Not now`})]})]}):h?(0,K.jsxs)(`div`,{className:`builder-placing`,role:`status`,children:[(0,K.jsxs)(`p`,{children:[`Pick a section to add `,(0,K.jsx)(`strong`,{children:Me(T,h.index)}),`.`]}),(0,K.jsx)(`div`,{className:`builder-placing__actions`,children:(0,K.jsx)(w,{size:`sm`,variant:`quiet`,onClick:()=>t.setTarget(null),children:`Not now`})})]}):(0,K.jsx)(`p`,{className:`builder-panel__hint`,children:`Drag one onto the page, or pick one and then choose its place.`}),(0,K.jsx)(Pe,{siteId:e,blocks:E,layout:`rows`,onPick:t.choose,onPress:t.beginDrag,current:m?.block.type??null,focusToken:b})]}):null]}),(0,K.jsx)(`div`,{className:`g-sr`,role:`status`,children:t.note})]})}var Ue=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Q=e=>typeof e==`number`&&Number.isInteger(e)&&e>=0,We=e=>typeof e==`string`&&e.startsWith(`/`)&&!e.startsWith(`//`);function Ge(e){return Ue(e)&&[`x`,`y`,`width`,`height`].every(t=>typeof e[t]==`number`&&Number.isFinite(e[t]))}function Ke(e){if(!Ue(e)||e.galley!==1)return null;switch(e.type){case`ready`:case`navigate`:return We(e.path)&&typeof e.title==`string`?{galley:1,type:e.type,path:e.path,title:e.title}:null;case`select`:return typeof e.text==`string`&&typeof e.tag==`string`&&Q(e.occurrence)&&Q(e.total)&&Ge(e.rect)?{galley:1,type:`select`,text:e.text,tag:e.tag,occurrence:e.occurrence,total:e.total,rect:e.rect}:null;case`select-image`:return typeof e.src==`string`&&typeof e.alt==`string`&&Ge(e.rect)?{galley:1,type:`select-image`,src:e.src,alt:e.alt,rect:e.rect}:null;case`edit`:return typeof e.text==`string`&&typeof e.newText==`string`&&Q(e.occurrence)&&Q(e.total)?{galley:1,type:`edit`,text:e.text,newText:e.newText,occurrence:e.occurrence,total:e.total}:null;case`edit-cancelled`:return typeof e.text==`string`&&Q(e.occurrence)?{galley:1,type:`edit-cancelled`,text:e.text,occurrence:e.occurrence}:null;case`scroll`:return typeof e.y==`number`&&Number.isFinite(e.y)?{galley:1,type:`scroll`,y:e.y}:null;case`arrange-status`:return e.status!==`mapped`&&e.status!==`waiting`&&e.status!==`declined`||e.how!==null&&e.how!==`markers`&&e.how!==`evidence`||e.reason!==null&&typeof e.reason!=`string`||!Q(e.revision)?null:{galley:1,type:`arrange-status`,status:e.status,how:e.how,reason:e.reason,revision:e.revision};case`arrange-select`:return e.key===null||qe(e.key)?{galley:1,type:`arrange-select`,key:e.key}:null;case`arrange-action`:{if(typeof e.field!=`string`||!Q(e.index))return null;let{field:t,index:n}=e;switch(e.action){case`move`:return Q(e.to)?{galley:1,type:`arrange-action`,action:`move`,field:t,index:n,to:e.to}:null;case`step`:return e.delta===1||e.delta===-1?{galley:1,type:`arrange-action`,action:`step`,field:t,index:n,delta:e.delta}:null;case`duplicate`:case`remove`:case`edit`:case`options`:case`add`:case`undo`:return{galley:1,type:`arrange-action`,action:e.action,field:t,index:n};default:return null}}case`placing-at`:return e.field===null&&e.index===null?{galley:1,type:`placing-at`,field:null,index:null}:typeof e.field==`string`&&Q(e.index)?{galley:1,type:`placing-at`,field:e.field,index:e.index}:null;case`place`:return typeof e.field==`string`&&Q(e.index)?{galley:1,type:`place`,field:e.field,index:e.index}:null;default:return null}}var qe=e=>typeof e==`string`&&/^[^\s]+\.\d+$/.test(e)&&e.length<=200;function $(e){return{galley:1,...e}}function Je(e,t){return`${e.replace(/\/+$/,``)}${t.startsWith(`/`)?t:`/${t}`}`}function Ye(e,t){let n=e.trim();if(!n)return null;if(/^[a-z][a-z0-9+.-]*:/i.test(n))try{let e=new URL(n);return t.some(t=>t&&new URL(t).origin===e.origin)?`${e.pathname}${e.search}${e.hash}`:null}catch{return null}return n.startsWith(`//`)?null:n.startsWith(`/`)?n:`/${n}`}function Xe(e){return e.split(/[?#]/)[0]||`/`}function Ze(e){return{entries:[e],index:0,pendingIndex:null}}function Qe(e,t){if(e.pendingIndex!==null&&e.entries[e.pendingIndex]===t)return{...e,index:e.pendingIndex,pendingIndex:null};if(e.entries[e.index]===t)return{...e,pendingIndex:null};let n=[...e.entries.slice(0,e.index+1),t].slice(-50);return{entries:n,index:n.length-1,pendingIndex:null}}function $e(e,t){let n=e.index+t,r=e.entries[n];return r===void 0?null:{history:{...e,pendingIndex:n},path:r}}var et=(e,t)=>e.entries[e.index+t]!==void 0,tt=/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;function nt(e){let t=e.trim();if(tt.test(t))return t.toUpperCase();let n=/^rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i.exec(t);return n?`#${[n[1],n[2],n[3]].map(e=>Math.min(255,Number(e)).toString(16).padStart(2,`0`)).join(``)}`.toUpperCase():null}function rt(e,t,n){return t<e.left||t>=e.right||n<e.top||n>=e.bottom?null:{x:t-e.left,y:n-e.top}}function it(e,t,n){return e===`touch`?Math.abs(t)>10&&Math.abs(t)>Math.abs(n)*1.2:Math.hypot(t,n)>5}var at=`app-placing`;function ot(e,t){let n=e.target instanceof Node?e.target.ownerDocument??document:document,r={x:e.clientX,y:e.clientY},i=!1,a=null,o=null,s=(e,t)=>{o&&(o.style.transform=`translate(${Math.round(e+12)}px, ${Math.round(t+10)}px)`)},c=()=>{i=!0,n.documentElement.classList.add(at),o=n.createElement(`div`),o.className=`builder-ghost`,o.setAttribute(`aria-hidden`,`true`),o.textContent=t.label,n.body.append(o),t.onStart()},l=n=>{if(n.pointerId!==e.pointerId)return;if(!i){if(!it(n.pointerType,n.clientX-r.x,n.clientY-r.y))return;c()}n.preventDefault(),s(n.clientX,n.clientY);let l=t.frame(),u=l?rt(l.getBoundingClientRect(),n.clientX,n.clientY):null;o?.classList.toggle(`builder-ghost--over`,u!==null),(u||a)&&t.onPoint(u),a=u},u=e=>{n.removeEventListener(`pointermove`,l,!0),n.removeEventListener(`pointerup`,d,!0),n.removeEventListener(`pointercancel`,f,!0),n.removeEventListener(`keydown`,p,!0),i&&(n.documentElement.classList.remove(at),o?.remove(),o=null,t.onEnd(e&&a!==null))},d=t=>{t.pointerId===e.pointerId&&u(!0)},f=t=>{t.pointerId===e.pointerId&&u(!1)},p=e=>{e.key===`Escape`&&i&&(e.preventDefault(),e.stopPropagation(),a=null,u(!1))};return n.addEventListener(`pointermove`,l,!0),n.addEventListener(`pointerup`,d,!0),n.addEventListener(`pointercancel`,f,!0),n.addEventListener(`keydown`,p,!0),()=>{a=null,u(!1)}}var st=6e3,ct=[],lt={};function ut(e,t,n){let r=(0,G.useCallback)(t=>e?e.subscribe(t):()=>void 0,[e]);return(0,G.useSyncExternalStore)(r,()=>e?t(e.getState()):n)}function dt({source:e,on:t,post:n,frame:r}){let i=e?.entry??null,a=e?.store??null,o=(0,G.useMemo)(()=>de(i?.fields??ct),[i?.fields]),s=o.length>0&&a!==null,c=t&&s,l=i!==null&&i.status!==`deleted`,u=ut(a,e=>e.stored,lt),d=ut(a,e=>e.data,lt),f=ut(a,e=>e.busy,!1),p=(0,G.useMemo)(()=>we(o,u),[o,u]),m=(0,G.useRef)({signature:``,value:0}),h=JSON.stringify(p);h!==m.current.signature&&(m.current={signature:h,value:m.current.value+1});let g=m.current.value,[_,v]=(0,G.useState)(null),y=(0,G.useRef)(!1),b=(0,G.useCallback)((e,t=!1)=>{y.current=t,v(e)},[]),[x,S]=(0,G.useState)({status:`loading`,how:null,reason:null}),[C,w]=(0,G.useState)(0),[T,E]=(0,G.useState)(null),[D,O]=(0,G.useState)(null),[ee,k]=(0,G.useState)(null),[te,ne]=(0,G.useState)(0),[A,j]=(0,G.useState)(``),N=(0,G.useRef)(D);N.current=D;let P=(0,G.useRef)(null),F=(0,G.useRef)(null);(0,G.useEffect)(()=>{b(null),E(null),O(null),S({status:`loading`,how:null,reason:null})},[i?.path,b]);let ie=(0,G.useRef)(g);(0,G.useEffect)(()=>{ie.current!==g&&(ie.current=g,x.status===`mapped`&&w(Date.now()+st))},[g,x.status]),(0,G.useEffect)(()=>{if(C<=Date.now())return;let e=setTimeout(()=>w(0),C-Date.now()+10);return()=>clearTimeout(e)},[C]);let L=f||C>Date.now(),R=fe(_),z=R?o.find(e=>e.key===R.field)??null:null,B=z?d[z.key]:void 0,V=R&&Array.isArray(B)?B[R.index]:void 0;(0,G.useEffect)(()=>{_&&V===void 0&&!f&&b(null)},[_,V,f,b]),(0,G.useEffect)(()=>{if(!a)return;let e=o.map(e=>se(a,[e.key],t=>{v(n=>{let r=fe(n);if(!r||r.field!==e.key)return n;let i=re(r.index,t);return i===null?null:Z(e.key,i)})}));return()=>e.forEach(e=>e())},[a,o]);let H=(0,G.useCallback)(()=>{n($({type:`arrange`,on:c,lists:c?p:[],editable:l,selected:c?_:null,settling:L,revision:g,reveal:y.current})),y.current=!1},[n,c,p,l,_,L,g]),ae=(0,G.useRef)(!1);(0,G.useEffect)(()=>{(c||ae.current)&&(ae.current=c,H())},[H,c]);let U=(0,G.useMemo)(()=>{let e=new Map;if(a)for(let t of o)e.set(t.key,{field:t,actions:X({store:a,path:[t.key],noun:`section`,label:e=>M(e,t)})});return e},[a,o]),W=(0,G.useCallback)(e=>{let t=U.get(e),n=d[e];return t&&Array.isArray(n)?n.map(e=>M(e,t.field)):[]},[U,d]),K=(0,G.useCallback)((e,t,n)=>{let r=U.get(t);if(!r||!l)return;let i=Me(W(t),n);r.actions.insert(n,I(e,r.field.discriminator??`type`))&&(b(Z(t,n),!0),j(`${e.label} added ${i}. It’s waiting in Proof.`))},[U,l,W,b]),q=(0,G.useCallback)(()=>{N.current&&n($({type:`placing`,field:null,label:null})),O(null),k(null)},[n]),J=(0,G.useCallback)(t=>{switch(t.type){case`arrange-status`:if(t.revision!==m.current.value)return;S({status:t.status,how:t.how,reason:t.reason}),t.status===`mapped`&&w(0);return;case`arrange-select`:b(t.key);return;case`arrange-action`:{let n=U.get(t.field);if(!n)return;let{actions:r}=n,i=d[t.field],o=Array.isArray(i)?i.length:0;switch(t.action){case`move`:l&&r.move(t.index,t.to)&&b(Z(t.field,t.to),!0);return;case`step`:{let e=fe(_),n=e&&e.field===t.field?e.index:t.index;l&&r.step(n,t.delta)&&b(Z(t.field,n+t.delta),!0);return}case`duplicate`:l&&r.duplicate(t.index)&&b(Z(t.field,t.index+1),!0);return;case`remove`:if(!l||!r.remove(t.index))return;b(o>1?Z(t.field,Math.min(t.index,o-2)):null,!0);return;case`undo`:a&&le(a);return;case`edit`:e?.onEditSection(t.field,t.index);return;case`options`:b(Z(t.field,t.index)),ne(Date.now());return;case`add`:E({field:t.field,index:t.index});return}return}case`placing-at`:k(t.index);return;case`place`:{let e=N.current??P.current;P.current=null,e&&K(e.block,t.field,t.index),q();return}}},[U,d,l,_,b,e,a,K,q]),oe=(0,G.useCallback)(e=>{let t=o[0];if(!t||!l)return;if(T){K(e,T.field,T.index),E(null);return}let r=N.current;if(r&&r.block.type===e.type){K(e,r.field,W(r.field).length),q();return}let i=fe(_)?.field??t.key;O({block:e,field:i}),n($({type:`placing`,field:i,label:e.label}))},[o,l,T,_,K,W,q,n]),ce=(0,G.useCallback)((e,t)=>{let i=fe(_)?.field??o[0]?.key;i&&l&&x.status===`mapped`&&(F.current?.(),F.current=ot(e,{frame:()=>r.current,label:t.label,onStart:()=>{E(null),O({block:t,field:i}),N.current={block:t,field:i},n($({type:`placing`,field:i,label:t.label}))},onPoint:e=>n($({type:`placing-pointer`,point:e})),onEnd:e=>{F.current=null,e?(P.current={block:t,field:i},n($({type:`placing-drop`}))):n($({type:`placing-pointer`,point:null})),n($({type:`placing`,field:null,label:null})),O(null),N.current=null,k(null),setTimeout(()=>{P.current=null},1500)}}))},[_,o,l,x.status,r,n]);return(0,G.useEffect)(()=>()=>F.current?.(),[]),(0,G.useEffect)(()=>{c||(O(null),E(null))},[c]),{available:s,active:c,editable:l,fields:o,data:d,store:a,status:x,settling:L,selected:R&&z&&V!==void 0?{...R,field:z,item:V}:null,select:b,target:T,setTarget:E,placing:D,placingAt:ee,choose:oe,beginDrag:ce,stopPlacing:q,insertAt:K,labelsOf:W,optionsToken:te,note:A,handle:J,resend:()=>{S(e=>e.status===`mapped`?e:{status:`loading`,how:null,reason:null}),c&&H()},editSection:(t,n)=>e?.onEditSection(t,n)}}function ft(e,t){let n=e?.getBoundingClientRect();if(!n||!t)return{display:`none`};let r=Math.min(Math.max(n.left+t.x,n.left),n.right-8),i=Math.min(Math.max(n.top+t.y,n.top),n.bottom-8);return{left:r,top:i,width:Math.max(1,Math.min(t.width,n.right-r)),height:Math.max(1,Math.min(t.height,n.bottom-i))}}function pt({match:n,label:r,error:i,onSave:a,onClose:o}){let[s,c]=(0,G.useState)(n.value),[l,u]=(0,G.useState)(!1),d=async()=>{u(!0),await a(s),u(!1)};return(0,K.jsxs)(`form`,{className:`preview-assist`,onSubmit:e=>{e.preventDefault(),d()},children:[(0,K.jsx)(`p`,{className:`g-eyebrow`,children:r}),(0,K.jsx)(t,{"aria-label":r,value:s,maxRows:10,"data-autofocus":!0,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),d())}}),(0,K.jsxs)(`p`,{className:`preview-assist__note`,children:[(0,K.jsx)(e,{kind:`pilcrow`}),(0,K.jsx)(`span`,{children:`This text carries formatting the page doesn’t show, like emphasis or a link, so you’re editing it as it’s stored. Keep the marks where you want them.`})]}),i?(0,K.jsxs)(`p`,{className:`g-error-text`,role:`alert`,children:[(0,K.jsx)(e,{kind:`bang`}),(0,K.jsx)(`span`,{children:i})]}):null,(0,K.jsxs)(`div`,{className:`preview-assist__actions`,children:[(0,K.jsx)(w,{type:`button`,variant:`quiet`,size:`sm`,onClick:o,children:`Leave as is`}),(0,K.jsx)(w,{type:`submit`,variant:`primary`,size:`sm`,busy:l,busyLabel:`Saving…`,disabled:s===n.value,children:`Save`})]})]})}function mt({siteId:e,assist:t,frame:n,onClose:r,onSaveStored:i,onChoose:a,onChooseSpot:o,onPickImage:s,onAsk:c,onShowForm:l}){let u=R(e=>e.detail?.model.collections),d=`rect`in t?t.rect:null,f=(0,G.useRef)(null),p=(e,t=!1)=>ae(e,u?.find(t=>t.id===e.collection)?.label,{places:t}),h=(()=>{switch(t.kind){case`stored`:return(0,K.jsx)(pt,{match:t.match,label:p(t.match),error:t.error,onSave:i,onClose:r},`${t.match.path}:${JSON.stringify(t.match.location)}`);case`choose`:return(0,K.jsxs)(`div`,{className:`preview-assist`,children:[(0,K.jsx)(`p`,{className:`preview-assist__title`,children:`Which one did you mean?`}),(0,K.jsx)(`p`,{className:`preview-assist__text`,children:t.reason}),(0,K.jsx)(`ul`,{className:`preview-assist__choices`,children:t.matches.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,className:`preview-assist__choice`,onClick:()=>a(e),children:[(0,K.jsx)(`span`,{children:p(e,!0)}),!e.editable||e.location.kind===`source`?(0,K.jsx)(`span`,{className:`g-faint`,children:` · part of the design`}):null]})},`${e.path}:${JSON.stringify(e.location)}`))})]});case`design`:return(0,K.jsxs)(`div`,{className:`preview-assist`,children:[(0,K.jsx)(`p`,{className:`preview-assist__title`,children:`This text is part of the site’s design.`}),(0,K.jsxs)(`p`,{className:`preview-assist__text`,children:[t.reason,` The assistant can change it for you.`]}),(0,K.jsxs)(`div`,{className:`preview-assist__actions`,children:[(0,K.jsx)(w,{variant:`quiet`,size:`sm`,onClick:r,children:`Close`}),c?(0,K.jsx)(w,{variant:`primary`,size:`sm`,icon:`chat`,"data-autofocus":!0,onClick:()=>{c(t.text),r()},children:`Ask the assistant to change it`}):null]})]});case`image-unknown`:return(0,K.jsxs)(`div`,{className:`preview-assist`,children:[(0,K.jsx)(`p`,{className:`preview-assist__title`,children:`This image can’t be swapped by clicking.`}),(0,K.jsx)(`p`,{className:`preview-assist__text`,children:`It isn’t one of this page’s own image fields. If it belongs to a section, change it in the form, in that section’s image field. Otherwise it’s part of the design, and the assistant can change it.`}),(0,K.jsxs)(`div`,{className:`preview-assist__actions`,children:[(0,K.jsx)(w,{variant:`quiet`,size:`sm`,onClick:r,children:`Close`}),l?(0,K.jsx)(w,{variant:`secondary`,size:`sm`,icon:`page`,"data-autofocus":!0,onClick:()=>{l(),r()},children:`Show the form`}):null,c?(0,K.jsx)(w,{variant:l?`quiet`:`primary`,size:`sm`,icon:`chat`,onClick:()=>{c(t.text,`image`),r()},children:`Ask the assistant`}):null]})]});case`image`:return t.chosen?null:(0,K.jsxs)(`div`,{className:`preview-assist`,children:[(0,K.jsx)(`p`,{className:`preview-assist__title`,children:`This image is used in more than one place.`}),(0,K.jsx)(`ul`,{className:`preview-assist__choices`,children:t.spots.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsx)(`button`,{type:`button`,className:`preview-assist__choice`,onClick:()=>o(e),children:e.label})},JSON.stringify(e.path)))})]});default:return null}})();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{ref:f,className:`preview-anchor`,style:ft(n.current,d),"aria-hidden":`true`}),(0,K.jsx)(m,{open:h!==null,onClose:r,anchor:f,placement:`bottom-start`,role:`dialog`,"aria-label":`Edit on the page`,className:`preview-assist-surface`,children:h}),t.kind===`image`?(0,K.jsx)(P,{siteId:e,open:t.chosen!==null,onClose:r,onPick:e=>void s(e)}):null]})}function ht(){let e=document.documentElement,t=nt(getComputedStyle(e).getPropertyValue(`--accent`));if(!t)return null;let n=e.dataset.theme;return{accent:t,theme:n===`dark`||n!==`light`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}}function gt(){let e=u(e=>e.meta?.brand.accent),t=C(e=>e.theme),[n,r]=(0,G.useState)(ht);return(0,G.useEffect)(()=>{let e=requestAnimationFrame(()=>r(ht())),t=window.matchMedia(`(prefers-color-scheme: dark)`),n=()=>r(ht());return t.addEventListener(`change`,n),()=>{cancelAnimationFrame(e),t.removeEventListener(`change`,n)}},[e,t]),n}function _t({log:e,open:t}){return e.length===0?null:(0,K.jsxs)(`details`,{className:`app-details preview-log`,open:t,children:[(0,K.jsx)(`summary`,{children:`What it’s doing`}),(0,K.jsx)(`pre`,{className:`app-error__detail preview-log__lines`,"aria-live":`off`,children:e.slice(-14).join(`
|
|
2
2
|
`)})]})}function vt({siteId:e,status:t}){let n=ie(e=>e.run),r=t?.state??`idle`;if(r===`error`)return(0,K.jsx)(`div`,{className:`app-preview-state`,children:(0,K.jsx)(o,{compact:!0,title:`The preview stopped`,message:t?.detail??`The site’s own build reported a problem.`,detail:t?.log.slice(-40).join(`
|
|
3
3
|
`)||void 0,retryLabel:`Restart preview`,onRetry:()=>void n(e,`restart`).catch(e=>S({tone:`danger`,title:`Couldn’t restart the preview`,body:a(e).message,detail:a(e).detail})),actions:(0,K.jsx)(d,{className:v(`quiet`,`sm`),to:`/sites/${e}/settings`,children:`Open site settings`})})});if(r===`installing`||r===`starting`||r===`idle`){let e=r===`installing`;return(0,K.jsx)(`div`,{className:`app-preview-state`,"aria-busy":`true`,children:(0,K.jsx)(s,{compact:!0,mark:`reg`,title:e?`Preparing the preview…`:`Starting the preview…`,body:t?.detail??(e?`Installing what the site needs. The first time can take a few minutes.`:`The site’s own preview is starting. This can take a moment the first time.`),actions:(0,K.jsx)(_,{label:e?`Preparing the preview`:`Starting the preview`}),children:(0,K.jsx)(_t,{log:t?.log??[]})})})}return(0,K.jsx)(`div`,{className:`app-preview-state`,children:(0,K.jsx)(s,{compact:!0,mark:`reg`,title:`The preview is off.`,body:`Start it to see your pages as visitors will, with your changes.`,actions:(0,K.jsx)(W,{siteId:e,size:`md`})})})}function yt({siteId:e}){return(0,K.jsx)(`div`,{className:`app-preview-state`,children:(0,K.jsx)(s,{compact:!0,mark:`transpose`,title:`No live site to compare with.`,body:`Add the site’s staging or production address in its settings to see what visitors see now beside your changes.`,actions:(0,K.jsx)(d,{className:v(`secondary`,`sm`),to:`/sites/${e}/settings`,children:`Open site settings`})})})}function bt(e,t){return`galley-preview${t?``:`-proof`}${e===`live`?`-live`:``}`}function xt({frameRef:e,src:t,title:n,width:r,caption:i,onLoad:a,name:o}){let[s]=(0,G.useState)(t);return(0,K.jsxs)(`div`,{className:`preview-side`,children:[i?(0,K.jsx)(`p`,{className:`g-eyebrow preview-side__caption`,children:i}):null,(0,K.jsx)(`div`,{className:`g-preview preview-table`,children:(0,K.jsx)(`div`,{className:g(`g-preview__frame g-crop preview-sheet`,r!==null&&`preview-sheet--fixed`),style:r===null?void 0:{inlineSize:r},children:(0,K.jsx)(`iframe`,{ref:e,name:o,className:`preview-sheet__iframe`,src:s,title:n,onLoad:a})})})]})}var St=.05,Ct=e=>Math.min(.8,Math.max(.2,e));function wt({ratio:e,onRatio:t,stage:n}){let r=(0,G.useRef)(!1),i=e=>{e.preventDefault(),r.current=!0,e.currentTarget.setPointerCapture(e.pointerId),document.documentElement.classList.add(`app-resizing`)},a=e=>{if(!r.current)return;let i=n.current?.getBoundingClientRect();i&&i.width>0&&t(Ct((e.clientX-i.left)/i.width))},o=e=>{r.current&&(r.current=!1,e.currentTarget.releasePointerCapture(e.pointerId),document.documentElement.classList.remove(`app-resizing`))};return(0,K.jsx)(`div`,{className:`preview-divider`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Live site and proposed page`,"aria-valuemin":20,"aria-valuemax":80,"aria-valuenow":Math.round(e*100),"aria-valuetext":`Live site ${Math.round(e*100)}%`,tabIndex:0,onPointerDown:i,onPointerMove:a,onPointerUp:o,onPointerCancel:o,onKeyDown:n=>{let r=n.key===`ArrowLeft`?e-St:n.key===`ArrowRight`?e+St:n.key===`Home`?.2:n.key===`End`?.8:n.key===`Enter`?.5:null;r!==null&&(n.preventDefault(),t(Ct(r)))},children:(0,K.jsx)(`span`,{className:`preview-divider__grip`,"aria-hidden":`true`})})}var Tt={desktop:null,tablet:768,phone:390},Et=[{value:`desktop`,label:`Desktop`,title:`Full width`},{value:`tablet`,label:`Tablet`,title:`768 pixels wide`},{value:`phone`,label:`Phone`,title:`390 pixels wide`}];function Dt({path:e,onGo:t,canBack:r,canForward:i,onBack:a,onForward:o,onReload:s,width:c,onWidth:l,tool:u,openUrl:d}){let[p,m]=(0,G.useState)(e),[h,g]=(0,G.useState)(!1),[_,y]=(0,G.useState)(null);return(0,G.useEffect)(()=>{h||m(e)},[e,h]),(0,K.jsxs)(`div`,{className:`preview-toolbar`,role:`toolbar`,"aria-label":`Preview`,children:[(0,K.jsx)(x,{icon:`chevron-left`,label:`Back`,disabled:!r,onClick:a}),(0,K.jsx)(x,{icon:`chevron-right`,label:`Forward`,disabled:!i,onClick:o}),(0,K.jsx)(x,{icon:`refresh`,label:`Reload the page`,onClick:s}),(0,K.jsxs)(`form`,{className:`preview-address`,onSubmit:e=>{e.preventDefault();let n=t(p);y(n),n||(g(!1),document.activeElement?.blur())},children:[(0,K.jsx)(`label`,{className:`g-sr`,htmlFor:`preview-address`,children:`Page address`}),(0,K.jsx)(`input`,{id:`preview-address`,className:`g-input g-input--sm g-input--mono preview-address__input`,value:p,spellCheck:!1,autoComplete:`off`,"aria-invalid":_?!0:void 0,"aria-describedby":_?`preview-address-error`:void 0,onFocus:e=>{g(!0),e.currentTarget.select()},onBlur:()=>{g(!1),y(null)},onKeyDown:t=>{t.key===`Escape`&&(m(e),y(null),t.currentTarget.blur())},onChange:e=>m(e.target.value)}),_?(0,K.jsx)(`span`,{id:`preview-address-error`,className:`preview-address__error`,role:`alert`,children:_}):null]}),(0,K.jsx)(f,{label:`Page width`,options:Et,value:c,onChange:l,className:`preview-widths`}),u?(0,K.jsx)(f,{label:`On the page`,className:`preview-tools`,value:u.value,onChange:u.onChange,options:[{value:`edit`,label:`Click to edit`,title:`Click text or an image on the page to change it. On a link, Enter edits it and ${n(`mod`)===`⌘`?`⌘Enter`:`Ctrl+Enter`} follows it.`},...u.arrange?[{value:`arrange`,label:`Arrange`,title:`Move, add and remove the page’s sections, and switch their options, right on the page.`}]:[],{value:`browse`,label:`Browse`,title:`Click links and buttons as a visitor would.`}]}):null,d?(0,K.jsx)(`a`,{className:v(`quiet`,`sm`,`g-btn--icon`),href:d,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`Open this page in a new tab`,title:`Open this page in a new tab`,children:(0,K.jsx)(E,{name:`external`})}):null]})}var Ot={kind:`idle`};function kt({siteId:e,currentPath:t,send:n,onSelection:r}){let[i,o]=(0,G.useState)(Ot),[s,c]=(0,G.useState)(null),l=(0,G.useRef)(0),u=(0,G.useRef)(null),d=(0,G.useCallback)(e=>{u.current&&clearTimeout(u.current),c(e),e&&e.tone!==`working`&&(u.current=setTimeout(()=>c(null),e.tone===`done`?4e3:9e3))},[]);(0,G.useEffect)(()=>()=>void(u.current&&clearTimeout(u.current)),[]);let f=(0,G.useCallback)(async(t,n)=>{d({tone:`working`,text:`Saving…`});try{let r=await D(`PATCH /api/sites/:siteId/entry`,{params:{siteId:e},query:{path:t},body:{ops:n}}),i=r.refused[0];return i?(d({tone:`problem`,text:`Couldn’t change it. ${i.reason}`}),i.reason):(k(e,r.entry),d(r.applied>0?{tone:`done`,text:`Saved. It’s waiting in Proof.`}:{tone:`done`,text:`Nothing changed.`}),null)}catch(e){let{message:t}=a(e);return d({tone:`problem`,text:`Couldn’t change it. ${t}`}),t}},[e,d]),p=(0,G.useCallback)((e,t)=>{switch(e.kind){case`in-place`:n($({type:`begin-edit`,text:t.text,occurrence:t.occurrence})),o({kind:`editing`,text:t.text,match:e.match});return;case`stored`:o({kind:`stored`,rect:t.rect,match:e.match});return;case`choose`:o({kind:`choose`,rect:t.rect,text:t.text,occurrence:t.occurrence,matches:e.matches,reason:e.reason});return;case`design`:o({kind:`design`,rect:t.rect,text:t.text,reason:e.reason})}},[n]),m=(0,G.useCallback)(async i=>{let s=++l.current;r?.({text:i.text}),o({kind:`resolving`,rect:i.rect});try{let n=await D(`POST /api/sites/:siteId/resolve`,{params:{siteId:e},body:{urlPath:Xe(t()),text:i.text,occurrence:i.occurrence,total:i.total}});if(s!==l.current)return;let a=U(n);(a.kind===`in-place`||a.kind===`stored`)&&r?.({text:i.text,sourcePath:a.match.path}),p(a,i)}catch(e){if(s!==l.current)return;o(Ot),n($({type:`cancel-edit`})),d({tone:`problem`,text:`Couldn’t find where this text lives. ${a(e).message}`})}},[e,t,p,r,n,d]),h=(0,G.useCallback)(async n=>{let i=++l.current;r?.(n.alt?{text:n.alt}:null),o({kind:`resolving`,rect:n.rect});let s={kind:`image-unknown`,rect:n.rect,text:n.alt};try{let{entry:r}=await D(`GET /api/sites/:siteId/route`,{params:{siteId:e},query:{url:Xe(t())}});if(!r){i===l.current&&o(s);return}let a=await D(`GET /api/sites/:siteId/entry`,{params:{siteId:e},query:{path:r.path}});if(i!==l.current)return;let c=V(a.data,n.src).map(e=>({path:e,label:z(a.fields,a.data,e)}));c.length===0?o(s):o({kind:`image`,rect:n.rect,entryPath:a.path,spots:c,chosen:c.length===1?c[0]??null:null})}catch(e){if(i!==l.current)return;o(Ot),d({tone:`problem`,text:`Couldn’t find where this image lives. ${a(e).message}`})}},[e,t,r,d]),g=(0,G.useCallback)(async e=>{if(i.kind!==`editing`||i.text!==e.text)return;let{match:t}=i;if(o(Ot),e.newText===e.text)return;let r=H(t,e.newText);r&&await f(r.path,r.ops)&&n($({type:`restore-text`,text:e.text,newText:e.newText,occurrence:e.occurrence}))},[i,f,n]),_=(0,G.useCallback)(e=>{i.kind===`editing`&&i.text===e.text&&o(Ot)},[i]),v=(0,G.useCallback)(()=>{l.current++,o(Ot),n($({type:`cancel-edit`}))},[n]);return{assist:i,notice:s,onSelect:m,onSelectImage:h,onEdit:g,onEditCancelled:_,close:v,saveStored:(0,G.useCallback)(async e=>{if(i.kind!==`stored`)return;let t=H(i.match,e);if(!t)return;if(e===i.match.value){v();return}let n=await f(t.path,t.ops);n?o({...i,error:n}):v()},[i,f,v]),choose:(0,G.useCallback)(e=>{i.kind===`choose`&&(r?.({text:i.text,sourcePath:e.path}),p(B(e),{text:i.text,occurrence:i.occurrence,rect:i.rect}))},[i,p,r]),chooseSpot:(0,G.useCallback)(e=>o(t=>t.kind===`image`?{...t,chosen:e}:t),[]),pickImage:(0,G.useCallback)(async e=>{if(i.kind!==`image`||!i.chosen)return;let{entryPath:t,chosen:n}=i;v(),await f(t,[{op:`set`,path:n.path,value:e}])},[i,v,f]),dismissNotice:()=>d(null)}}function At(){try{return window.localStorage.getItem(`galley.preview.clickToEdit`)===`false`?`browse`:`edit`}catch{return`edit`}}var jt=[`proposed`,`live`],Mt=e=>e===`proposed`?`live`:`proposed`,Nt=e=>{try{return e?new URL(e).origin:null}catch{return null}};function Pt({siteId:t,status:n,urlPath:r,onNavigate:i,mode:a,editable:o=!0,onSelection:s,onAsk:c,highlight:l,onShowForm:u,builder:d}){let f={proposed:Nt(n.url),live:Nt(n.baselineUrl)},p={proposed:(0,G.useRef)(null),live:(0,G.useRef)(null)},m=(0,G.useRef)(null),h=a===`live`?`live`:`proposed`,g=(0,G.useRef)({proposed:null,live:null}),v=(0,G.useRef)({proposed:r,live:r}),y=(0,G.useRef)({proposed:!1,live:!1}),b=(0,G.useRef)({proposed:!1,live:!1}),x=(0,G.useRef)(r),[S,C]=(0,G.useState)(r),[w,T]=(0,G.useState)(()=>Ze(r)),[E,D]=Fe(`galley.preview.width`,`desktop`),[O,ee]=Fe(`galley.preview.split`,.5),[k,te]=Fe(`galley.preview.tool`,At()),ne=k===`arrange`||k===`browse`?k:`edit`,A=(0,G.useCallback)((e,t)=>{let n=p[e].current?.contentWindow,r=f[e];n&&r&&(b.current[e]||y.current[e])&&n.postMessage(t,r)},[]),j=(0,G.useCallback)((e,t)=>{let n=p[e].current,r=f[e];if(!n||!r)return;v.current[e]=t;let i=Je(r,t);try{n.contentWindow?.location.replace(i)}catch{n.src=i}},[]),M=gt(),re=(0,G.useRef)(M);re.current=M;let N=(0,G.useCallback)(e=>{let t=re.current;t&&A(e,$({type:`appearance`,accent:t.accent,theme:t.theme}))},[A]);(0,G.useEffect)(()=>{for(let e of jt)y.current[e]&&N(e)},[M?.accent,M?.theme,N]);let P=dt({source:o?d:void 0,on:o&&ne===`arrange`&&a!==`live`,post:e=>A(`proposed`,e),frame:p.proposed}),F=ne===`arrange`&&!P.available?`edit`:ne,I=o&&F===`edit`&&a!==`live`,ie=P.active,L=(0,G.useRef)(I);L.current=I;let R=(0,G.useRef)(P);R.current=P;let z=kt({siteId:t,currentPath:()=>g.current.proposed??S,send:e=>A(`proposed`,e),onSelection:s}),B=(0,G.useRef)(z);B.current=z;let V=(e,t)=>{if(g.current[e]=t,v.current[e]=t,e===h&&(C(t),T(e=>Qe(e,t)),t!==x.current&&(x.current=t,i(t))),a===`split`){let n=Mt(e);g.current[n]!==t&&v.current[n]!==t&&j(n,t)}},H=(e,t)=>{switch(t.type){case`ready`:y.current[e]=!0,A(e,$({type:`mode`,edit:e===`proposed`&&I})),N(e),V(e,t.path),e===`proposed`&&l&&setTimeout(()=>A(`proposed`,$({type:`highlight`,text:l})),400),e===`proposed`&&R.current.resend();return;case`navigate`:V(e,t.path);return;case`scroll`:a===`split`&&A(Mt(e),$({type:`scroll`,y:t.y}));return;case`select`:e===`proposed`&&I&&B.current.onSelect(t);return;case`select-image`:e===`proposed`&&I&&B.current.onSelectImage(t);return;case`edit`:e===`proposed`&&B.current.onEdit(t);return;case`edit-cancelled`:e===`proposed`&&B.current.onEditCancelled(t);return;case`arrange-status`:case`arrange-select`:case`arrange-action`:case`placing-at`:case`place`:e===`proposed`&&R.current.handle(t)}},ae=(0,G.useRef)(H);ae.current=H,(0,G.useEffect)(()=>{let e=e=>{let t=jt.find(t=>p[t].current?.contentWindow===e.source&&f[t]===e.origin);if(!t)return;let n=Ke(e.data);n&&ae.current(t,n)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[]),(0,G.useEffect)(()=>{x.current=r;for(let e of a===`split`?jt:[h]){let t=g.current[e]??v.current[e];(t===null||Xe(t)!==Xe(r))&&j(e,r)}},[r,a,h,j]),(0,G.useEffect)(()=>{y.current.proposed&&A(`proposed`,$({type:`mode`,edit:I})),I||B.current.close()},[I,A]);let U=e=>{b.current[e]=!0,A(e,$({type:`mode`,edit:e===`proposed`&&L.current}))},W=e=>{for(let t of a===`split`?jt:[h])j(t,e)},q=e=>{let t=$e(w,e);t&&(T(t.history),W(t.path))},J=()=>{for(let e of a===`split`?jt:[h])y.current[e]?A(e,$({type:`reload`})):j(e,g.current[e]??S)},oe=n.baselineSource===`production`?`Live site · production`:`Live site · staging`,se=Tt[E],ce=g.current[h]??S,{assist:le,notice:Y}=z,X=le.kind===`resolving`?{tone:`working`,text:`Finding where this text lives…`}:Y;return(0,K.jsxs)(`div`,{className:`preview`,children:[(0,K.jsx)(Dt,{path:S,onGo:e=>{let t=Ye(e,[n.url,n.baselineUrl]);return t?(W(t),null):`Only pages of this site open here. Type a path such as /about/.`},canBack:et(w,-1),canForward:et(w,1),onBack:()=>q(-1),onForward:()=>q(1),onReload:J,width:E,onWidth:D,tool:o&&a!==`live`?{value:F,onChange:te,arrange:P.available}:void 0,openUrl:f[h]?Je(f[h],S):null}),(0,K.jsxs)(`div`,{className:`preview-body`,children:[ie?(0,K.jsx)(He,{siteId:t,arrange:P,onShowForm:u}):null,(0,K.jsxs)(`div`,{ref:m,className:`preview-stage preview-stage--${a}`,style:a===`split`?{gridTemplateColumns:`${O}fr auto ${1-O}fr`}:void 0,children:[a===`proposed`?null:f.live?(0,K.jsx)(xt,{frameRef:p.live,name:bt(`live`,o),src:Je(f.live,ce),title:`Live site`,width:se,caption:a===`split`?oe:void 0,onLoad:()=>U(`live`)},`live`):(0,K.jsx)(`div`,{className:`preview-side`,children:(0,K.jsx)(yt,{siteId:t})},`live`),a===`split`?(0,K.jsx)(wt,{ratio:O,onRatio:ee,stage:m},`divider`):null,a!==`live`&&f.proposed?(0,K.jsx)(xt,{frameRef:p.proposed,name:bt(`proposed`,o),src:Je(f.proposed,ce),title:`Proposed page`,width:se,caption:a===`split`?`Proposed · your changes`:void 0,onLoad:()=>U(`proposed`)},`proposed`):null]})]}),X?(0,K.jsxs)(`div`,{className:`preview-notice preview-notice--${X.tone}`,role:`status`,children:[X.tone===`working`?(0,K.jsx)(_,{label:`Working`}):(0,K.jsx)(e,{kind:X.tone===`done`?`caret`:`bang`,tone:X.tone===`done`?`insert`:void 0}),(0,K.jsx)(`span`,{children:X.text})]}):(0,K.jsx)(`div`,{className:`g-sr`,role:`status`}),o?(0,K.jsx)(mt,{siteId:t,assist:le,frame:p.proposed,onClose:z.close,onSaveStored:z.saveStored,onChoose:z.choose,onChooseSpot:z.chooseSpot,onPickImage:z.pickImage,onAsk:c,onShowForm:u}):null]})}function Ft(e){let{siteId:t}=e,n=L(t),r=ie(e=>e.run),i=(0,G.useRef)(!1);return(0,G.useEffect)(()=>{!i.current&&n&&n.state===`idle`&&(i.current=!0,r(t,`start`).catch(e=>S({tone:`danger`,title:`Couldn’t start the preview`,body:a(e).message,detail:a(e).detail})))},[t,n,r]),!n||n.state!==`ready`||!n.url?(0,K.jsx)(vt,{siteId:t,status:n}):(0,K.jsx)(Pt,{...e,status:n},`${n.url} ${n.baselineUrl??``}`)}export{se as i,Pe as n,X as r,Ft as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{$ as e,At as t,Ft as n,G as r,H as i,I as a,N as o,Nt as s,P as c,Q as l,St as u,W as d,at as f,bt as p,c as m,ft as h,g,gt as _,ht as v,it as y,jt as b,lt as x,n as S,o as C,ot as w,pt as T,s as ee,st as te,tt as ne,z as E}from"./ui-C6O2tW4c.js";import{n as re,s as ie,t as ae}from"./chrome-Brnq5kGb.js";import{t as D}from"./changes-DLBkrfUR.js";import{t as oe}from"./site-DJUEXLHW.js";import{r as se}from"./index-CtsAxi5d.js";import{o as ce}from"./events-CTTFdOf-.js";/* empty css */import{t as le}from"./PreviewPane-HeTLVD45.js";import{a as ue,c as O,d as de,h as fe,i as pe,l as me,n as he,o as ge,r as _e,s as ve,t as ye,u as be}from"./changes-BtRtvJ12.js";import{a as xe,i as k,n as Se,r as A,t as Ce}from"./proof-zOrlMTSg.js";import{f as j,h as we}from"./listPlan-BPJMzA6e.js";var M=n(s(),1),N=p();function Te({siteId:e}){let[t,n]=(0,M.useState)([]),[r,i]=(0,M.useState)(0);return ce(`changes.updated`,t=>{t.siteId===e&&i(e=>e+1)}),(0,M.useEffect)(()=>{let t=!0,r=window.setTimeout(()=>{E(`POST /api/sites/:siteId/brand/check`,{params:{siteId:e},body:{}}).then(e=>t&&n(e.items)).catch(()=>t&&n([]))},400);return()=>{t=!1,window.clearTimeout(r)}},[e,r]),t.length?(0,N.jsxs)(`aside`,{className:`brand-check`,"aria-label":`Against the brand`,children:[(0,N.jsx)(`span`,{className:`g-eyebrow`,children:`Against the brand`}),(0,N.jsx)(`ul`,{children:t.slice(0,12).map((e,t)=>(0,N.jsxs)(`li`,{children:[e.kind===`colour`&&e.value?(0,N.jsx)(`i`,{className:`brand-drift__chip`,style:{background:e.value},"aria-hidden":`true`}):null,(0,N.jsx)(`span`,{children:e.text}),(0,N.jsxs)(`code`,{children:[e.path.split(`/`).pop(),e.line?`:${e.line}`:``]})]},`${e.path}-${e.line??0}-${t}`))})]}):null}var P=``;function F(e){return I(e).some(e=>e.hidden)}function I(e){let t=Array.from(e,()=>({hidden:!1,style:{}}));if(t.length!==e.length){t.length=0;for(let n=0;n<e.length;n++)t.push({hidden:!1,style:{}})}let n=e.split(``),r=(e,r)=>{for(let i=e;i<r;i++){let e=t[i];e&&(e.hidden=!0),n[i]=P}},i=(e,r,i,a=!1)=>{for(let o=e;o<r;o++){let e=t[o];e&&(e.style={...e.style,...i}),a&&(n[o]=P)}};for(let t=0;t<e.length-1;t++)e[t]===`\\`&&/[\\`*_[\]()#+\-.!]/.test(e[t+1]??``)&&(r(t,t+1),n[t+1]=P,t++);for(let e of L(/`([^`\n]+)`/g,n.join(``))){let t=e.index,n=t+e[0].length;r(t,t+1),r(n-1,n),i(t+1,n-1,{code:!0},!0)}for(let e of L(/!?\[([^\]\n]+)\]\(([^)\s]+)((?:\s+"[^"\n]*")?)\)/g,n.join(``))){let t=e.index,n=t+e[0].indexOf(`[`)+1,a=n+(e[1]?.length??0),o=a+2,s=o+(e[2]?.length??0),c=t+e[0].length;r(t,n),i(n,a,{link:!0}),r(a,o),i(o,s,{address:!0},!0),r(s,c)}for(let{pattern:e,patch:t,width:a}of[{pattern:/(\*\*)(?=[^\s*])([^\n]*?[^\s*])\*\*/g,patch:{strong:!0},width:2},{pattern:/(?<![\p{L}\p{N}_])(__)(?=[^\s_])([^\n]*?[^\s_])__(?![\p{L}\p{N}_])/gu,patch:{strong:!0},width:2},{pattern:/(\*)(?=[^\s*])([^\n*]*?[^\s*])\*/g,patch:{em:!0},width:1},{pattern:/(?<![\p{L}\p{N}_])(_)(?=[^\s_])([^\n_]*?[^\s_])_(?![\p{L}\p{N}_])/gu,patch:{em:!0},width:1}])for(let o of L(e,n.join(``))){let e=o.index,n=e+o[0].length;r(e,e+a),r(n-a,n),i(e+a,n-a,t)}return t}function L(e,t){let n=[];e.lastIndex=0;for(let r=e.exec(t);r;r=e.exec(t))n.push(r),r[0].length===0&&e.lastIndex++;return n}var Ee=e=>`${e.strong?`b`:``}${e.em?`i`:``}${e.code?`c`:``}${e.link?`l`:``}${e.address?`a`:``}`;function De(e){let t=e.map(e=>e.kind===`same`||e.kind===`del`?e.text:e.kind===`gap`?e.text??``:``).join(``),n=e.map(e=>e.kind===`same`||e.kind===`ins`?e.text:e.kind===`gap`?e.text??``:``).join(``),r=I(t),i=I(n),a=0,o=0,s=[],c=(e,t,n,r)=>{let i=s[s.length-1];i&&i.kind===e&&Ee(i.style)===Ee(n)&&!!i.stored===r?i.text+=t:s.push(r?{kind:e,text:t,style:n,stored:r}:{kind:e,text:t,style:n})};for(let t of e){if(t.kind===`gap`){let e=t.text?.length??0;a+=e,o+=e,s.push({kind:`gap`,words:t.words});continue}if(t.kind===`same`){for(let e=0;e<t.text.length;e++){let n=i[o+e],s=r[a+e];n?.hidden&&s?.hidden||c(`same`,t.text[e]??``,n?.hidden?{}:n?.style??{},!1)}o+=t.text.length,a+=t.text.length;continue}let e=t.kind===`ins`?i:r,n=t.kind===`ins`?o:a,l=!1;for(let r=0;r<t.text.length;r++)!e[n+r]?.hidden&&/\S/.test(t.text[r]??``)&&(l=!0);let u=!l&&/\S/.test(t.text);for(let r=0;r<t.text.length;r++){let i=e[n+r];u?c(t.kind,t.text[r]??``,{},!0):i?.hidden||c(t.kind,t.text[r]??``,i?.style??{},!1)}t.kind===`ins`?o+=t.text.length:a+=t.text.length}return s}function Oe(e){let t=/^(\s*)([\s\S]*?)(\s*)$/.exec(e);return t?[t[1]??``,t[2]??``,t[3]??``]:[``,e,``]}function ke(e,t,n,r){let[i,a,o]=Oe(e.text);if(!a)return e.kind===`ins`?e.text:null;let s=r?`g-ink-in`:void 0,c=e.kind===`ins`?(0,N.jsxs)(`ins`,{className:_(`g-ins`,n&&`g-ins--plain`,s),children:[(0,N.jsx)(`span`,{className:`g-sr`,children:`Added: `}),a]}):(0,N.jsxs)(`del`,{className:_(`g-del`,n&&`g-del--plain`,s),children:[(0,N.jsx)(`span`,{className:`g-sr`,children:`Removed: `}),a]});return(0,N.jsxs)(`span`,{children:[i,c,o]},t)}function Ae(e,t,n){if(n)return(0,N.jsx)(`span`,{className:`g-mono ui-md-stored`,children:e});let r=e;return t.code&&(r=(0,N.jsx)(`code`,{className:`ui-md-code`,children:r})),t.address&&(r=(0,N.jsx)(`span`,{className:`ui-md-address`,children:r})),t.link&&(r=(0,N.jsx)(`span`,{className:`ui-md-link`,children:r})),t.em&&(r=(0,N.jsx)(`em`,{children:r})),t.strong&&(r=(0,N.jsx)(`strong`,{children:r})),r}function je(e,t,n,r){let[i,a,o]=Oe(e.text);if(!a)return e.kind===`ins`?(0,N.jsx)(`span`,{children:e.text},t):null;let s=r?`g-ink-in`:void 0,c=Ae(a,e.style,e.stored),l=e.kind===`ins`?(0,N.jsxs)(`ins`,{className:_(`g-ins`,n&&`g-ins--plain`,s),children:[(0,N.jsx)(`span`,{className:`g-sr`,children:`Added: `}),c]}):(0,N.jsxs)(`del`,{className:_(`g-del`,n&&`g-del--plain`,s),children:[(0,N.jsx)(`span`,{className:`g-sr`,children:`Removed: `}),c]});return(0,N.jsxs)(`span`,{children:[i,l,o]},t)}function Me({words:e}){return(0,N.jsxs)(`span`,{className:`ui-proof__gap`,title:`${e} unchanged words`,children:[(0,N.jsx)(`span`,{"aria-hidden":`true`,children:` … `}),(0,N.jsx)(`span`,{className:`g-sr`,children:`(${e} unchanged words)`})]})}function R({parts:e,plain:t=!1,inkIn:n=!1,markdown:r=!1,className:i}){return r?(0,N.jsx)(`span`,{className:_(`ui-proof`,`ui-proof--rendered`,i),children:De(e).map((e,r)=>e.kind===`gap`?(0,N.jsx)(Me,{words:e.words},r):e.kind===`same`?(0,N.jsx)(`span`,{children:Ae(e.text,e.style,e.stored)},r):je(e,r,t,n))}):(0,N.jsx)(`span`,{className:_(`ui-proof`,i),children:e.map((e,r)=>e.kind===`same`?(0,N.jsx)(`span`,{children:e.text},r):e.kind===`gap`?(0,N.jsx)(Me,{words:e.words},r):ke(e,r,t,n))})}var z=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r)setTimeout(function(){r(e)},0);else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h)d[r]=void 0;else{if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}};new class extends z{};function Ne(e,t){let n=0;for(;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function Pe(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function Fe(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function B(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function V(e,t){return Fe(e,t,``)}function H(e,t){return B(e,t,``)}function Ie(e,t){return t.slice(0,Le(e,t))}function Le(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function Re(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function U(e,t){if(t)return G(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function W(e,t){if(t)return G(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function G(e,t){if(!t)return[W(e),U(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=Re(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var K=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,ze=RegExp(`[${K}]+|\\s+|[^${K}]`,`ug`),Be=new class extends z{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=Re(e,r)}else n=e.match(ze)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&He(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&He(n,i,r,null,t.intlSegmenter),e}};function Ve(e,t,n){return n?.ignoreWhitespace!=null&&!n.ignoreWhitespace?We(e,t,n):Be.diff(e,t,n)}function He(e,t,n,r,i){if(t&&n){let[a,o]=G(t.value,i),[s,c]=G(n.value,i);if(e){let r=Ne(a,s);e.value=B(e.value,s,r),t.value=V(t.value,r),n.value=V(n.value,r)}if(r){let e=Pe(o,c);r.value=Fe(r.value,c,e),t.value=H(t.value,e),n.value=H(n.value,e)}}else if(n){if(e){let e=W(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=W(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=W(r.value,i),[a,o]=G(t.value,i),s=Ne(n,a);t.value=V(t.value,s);let c=Pe(V(n,s),o);t.value=H(t.value,c),r.value=Fe(r.value,n,c),e.value=B(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=W(r.value,i),n=Ie(U(t.value,i),e);t.value=H(t.value,n)}else if(e){let n=Ie(U(e.value,i),W(t.value,i));t.value=V(t.value,n)}}var Ue=new class extends z{tokenize(e){let t=RegExp(`(\\r?\\n)|[${K}]+|[^\\S\\n\\r]+|[^${K}]`,`ug`);return e.match(t)||[]}};function We(e,t,n){return Ue.diff(e,t,n)}new class extends z{constructor(){super(...arguments),this.tokenize=Ge}equals(e,t,n){return n.ignoreWhitespace?(n.newlineIsToken&&e.includes(`
|
|
1
|
+
import{$ as e,At as t,Ft as n,G as r,H as i,I as a,N as o,Nt as s,P as c,Q as l,St as u,W as d,at as f,bt as p,c as m,ft as h,g,gt as _,ht as v,it as y,jt as b,lt as x,n as S,o as C,ot as w,pt as T,s as ee,st as te,tt as ne,z as E}from"./ui-C6O2tW4c.js";import{n as re,s as ie,t as ae}from"./chrome-Brnq5kGb.js";import{t as D}from"./changes-DLBkrfUR.js";import{t as oe}from"./site-DJUEXLHW.js";import{r as se}from"./index-A7aTfJ-x.js";import{o as ce}from"./events-CTTFdOf-.js";/* empty css */import{t as le}from"./PreviewPane-BhtgFkYG.js";import{a as ue,c as O,d as de,h as fe,i as pe,l as me,n as he,o as ge,r as _e,s as ve,t as ye,u as be}from"./changes-BtRtvJ12.js";import{a as xe,i as k,n as Se,r as A,t as Ce}from"./proof-zOrlMTSg.js";import{f as j,h as we}from"./listPlan-Bds9RfG_.js";var M=n(s(),1),N=p();function Te({siteId:e}){let[t,n]=(0,M.useState)([]),[r,i]=(0,M.useState)(0);return ce(`changes.updated`,t=>{t.siteId===e&&i(e=>e+1)}),(0,M.useEffect)(()=>{let t=!0,r=window.setTimeout(()=>{E(`POST /api/sites/:siteId/brand/check`,{params:{siteId:e},body:{}}).then(e=>t&&n(e.items)).catch(()=>t&&n([]))},400);return()=>{t=!1,window.clearTimeout(r)}},[e,r]),t.length?(0,N.jsxs)(`aside`,{className:`brand-check`,"aria-label":`Against the brand`,children:[(0,N.jsx)(`span`,{className:`g-eyebrow`,children:`Against the brand`}),(0,N.jsx)(`ul`,{children:t.slice(0,12).map((e,t)=>(0,N.jsxs)(`li`,{children:[e.kind===`colour`&&e.value?(0,N.jsx)(`i`,{className:`brand-drift__chip`,style:{background:e.value},"aria-hidden":`true`}):null,(0,N.jsx)(`span`,{children:e.text}),(0,N.jsxs)(`code`,{children:[e.path.split(`/`).pop(),e.line?`:${e.line}`:``]})]},`${e.path}-${e.line??0}-${t}`))})]}):null}var P=``;function F(e){return I(e).some(e=>e.hidden)}function I(e){let t=Array.from(e,()=>({hidden:!1,style:{}}));if(t.length!==e.length){t.length=0;for(let n=0;n<e.length;n++)t.push({hidden:!1,style:{}})}let n=e.split(``),r=(e,r)=>{for(let i=e;i<r;i++){let e=t[i];e&&(e.hidden=!0),n[i]=P}},i=(e,r,i,a=!1)=>{for(let o=e;o<r;o++){let e=t[o];e&&(e.style={...e.style,...i}),a&&(n[o]=P)}};for(let t=0;t<e.length-1;t++)e[t]===`\\`&&/[\\`*_[\]()#+\-.!]/.test(e[t+1]??``)&&(r(t,t+1),n[t+1]=P,t++);for(let e of L(/`([^`\n]+)`/g,n.join(``))){let t=e.index,n=t+e[0].length;r(t,t+1),r(n-1,n),i(t+1,n-1,{code:!0},!0)}for(let e of L(/!?\[([^\]\n]+)\]\(([^)\s]+)((?:\s+"[^"\n]*")?)\)/g,n.join(``))){let t=e.index,n=t+e[0].indexOf(`[`)+1,a=n+(e[1]?.length??0),o=a+2,s=o+(e[2]?.length??0),c=t+e[0].length;r(t,n),i(n,a,{link:!0}),r(a,o),i(o,s,{address:!0},!0),r(s,c)}for(let{pattern:e,patch:t,width:a}of[{pattern:/(\*\*)(?=[^\s*])([^\n]*?[^\s*])\*\*/g,patch:{strong:!0},width:2},{pattern:/(?<![\p{L}\p{N}_])(__)(?=[^\s_])([^\n]*?[^\s_])__(?![\p{L}\p{N}_])/gu,patch:{strong:!0},width:2},{pattern:/(\*)(?=[^\s*])([^\n*]*?[^\s*])\*/g,patch:{em:!0},width:1},{pattern:/(?<![\p{L}\p{N}_])(_)(?=[^\s_])([^\n_]*?[^\s_])_(?![\p{L}\p{N}_])/gu,patch:{em:!0},width:1}])for(let o of L(e,n.join(``))){let e=o.index,n=e+o[0].length;r(e,e+a),r(n-a,n),i(e+a,n-a,t)}return t}function L(e,t){let n=[];e.lastIndex=0;for(let r=e.exec(t);r;r=e.exec(t))n.push(r),r[0].length===0&&e.lastIndex++;return n}var Ee=e=>`${e.strong?`b`:``}${e.em?`i`:``}${e.code?`c`:``}${e.link?`l`:``}${e.address?`a`:``}`;function De(e){let t=e.map(e=>e.kind===`same`||e.kind===`del`?e.text:e.kind===`gap`?e.text??``:``).join(``),n=e.map(e=>e.kind===`same`||e.kind===`ins`?e.text:e.kind===`gap`?e.text??``:``).join(``),r=I(t),i=I(n),a=0,o=0,s=[],c=(e,t,n,r)=>{let i=s[s.length-1];i&&i.kind===e&&Ee(i.style)===Ee(n)&&!!i.stored===r?i.text+=t:s.push(r?{kind:e,text:t,style:n,stored:r}:{kind:e,text:t,style:n})};for(let t of e){if(t.kind===`gap`){let e=t.text?.length??0;a+=e,o+=e,s.push({kind:`gap`,words:t.words});continue}if(t.kind===`same`){for(let e=0;e<t.text.length;e++){let n=i[o+e],s=r[a+e];n?.hidden&&s?.hidden||c(`same`,t.text[e]??``,n?.hidden?{}:n?.style??{},!1)}o+=t.text.length,a+=t.text.length;continue}let e=t.kind===`ins`?i:r,n=t.kind===`ins`?o:a,l=!1;for(let r=0;r<t.text.length;r++)!e[n+r]?.hidden&&/\S/.test(t.text[r]??``)&&(l=!0);let u=!l&&/\S/.test(t.text);for(let r=0;r<t.text.length;r++){let i=e[n+r];u?c(t.kind,t.text[r]??``,{},!0):i?.hidden||c(t.kind,t.text[r]??``,i?.style??{},!1)}t.kind===`ins`?o+=t.text.length:a+=t.text.length}return s}function Oe(e){let t=/^(\s*)([\s\S]*?)(\s*)$/.exec(e);return t?[t[1]??``,t[2]??``,t[3]??``]:[``,e,``]}function ke(e,t,n,r){let[i,a,o]=Oe(e.text);if(!a)return e.kind===`ins`?e.text:null;let s=r?`g-ink-in`:void 0,c=e.kind===`ins`?(0,N.jsxs)(`ins`,{className:_(`g-ins`,n&&`g-ins--plain`,s),children:[(0,N.jsx)(`span`,{className:`g-sr`,children:`Added: `}),a]}):(0,N.jsxs)(`del`,{className:_(`g-del`,n&&`g-del--plain`,s),children:[(0,N.jsx)(`span`,{className:`g-sr`,children:`Removed: `}),a]});return(0,N.jsxs)(`span`,{children:[i,c,o]},t)}function Ae(e,t,n){if(n)return(0,N.jsx)(`span`,{className:`g-mono ui-md-stored`,children:e});let r=e;return t.code&&(r=(0,N.jsx)(`code`,{className:`ui-md-code`,children:r})),t.address&&(r=(0,N.jsx)(`span`,{className:`ui-md-address`,children:r})),t.link&&(r=(0,N.jsx)(`span`,{className:`ui-md-link`,children:r})),t.em&&(r=(0,N.jsx)(`em`,{children:r})),t.strong&&(r=(0,N.jsx)(`strong`,{children:r})),r}function je(e,t,n,r){let[i,a,o]=Oe(e.text);if(!a)return e.kind===`ins`?(0,N.jsx)(`span`,{children:e.text},t):null;let s=r?`g-ink-in`:void 0,c=Ae(a,e.style,e.stored),l=e.kind===`ins`?(0,N.jsxs)(`ins`,{className:_(`g-ins`,n&&`g-ins--plain`,s),children:[(0,N.jsx)(`span`,{className:`g-sr`,children:`Added: `}),c]}):(0,N.jsxs)(`del`,{className:_(`g-del`,n&&`g-del--plain`,s),children:[(0,N.jsx)(`span`,{className:`g-sr`,children:`Removed: `}),c]});return(0,N.jsxs)(`span`,{children:[i,l,o]},t)}function Me({words:e}){return(0,N.jsxs)(`span`,{className:`ui-proof__gap`,title:`${e} unchanged words`,children:[(0,N.jsx)(`span`,{"aria-hidden":`true`,children:` … `}),(0,N.jsx)(`span`,{className:`g-sr`,children:`(${e} unchanged words)`})]})}function R({parts:e,plain:t=!1,inkIn:n=!1,markdown:r=!1,className:i}){return r?(0,N.jsx)(`span`,{className:_(`ui-proof`,`ui-proof--rendered`,i),children:De(e).map((e,r)=>e.kind===`gap`?(0,N.jsx)(Me,{words:e.words},r):e.kind===`same`?(0,N.jsx)(`span`,{children:Ae(e.text,e.style,e.stored)},r):je(e,r,t,n))}):(0,N.jsx)(`span`,{className:_(`ui-proof`,i),children:e.map((e,r)=>e.kind===`same`?(0,N.jsx)(`span`,{children:e.text},r):e.kind===`gap`?(0,N.jsx)(Me,{words:e.words},r):ke(e,r,t,n))})}var z=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r)setTimeout(function(){r(e)},0);else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h)d[r]=void 0;else{if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}};new class extends z{};function Ne(e,t){let n=0;for(;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function Pe(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function Fe(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function B(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function V(e,t){return Fe(e,t,``)}function H(e,t){return B(e,t,``)}function Ie(e,t){return t.slice(0,Le(e,t))}function Le(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function Re(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function U(e,t){if(t)return G(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function W(e,t){if(t)return G(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function G(e,t){if(!t)return[W(e),U(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=Re(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var K=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,ze=RegExp(`[${K}]+|\\s+|[^${K}]`,`ug`),Be=new class extends z{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=Re(e,r)}else n=e.match(ze)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&He(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&He(n,i,r,null,t.intlSegmenter),e}};function Ve(e,t,n){return n?.ignoreWhitespace!=null&&!n.ignoreWhitespace?We(e,t,n):Be.diff(e,t,n)}function He(e,t,n,r,i){if(t&&n){let[a,o]=G(t.value,i),[s,c]=G(n.value,i);if(e){let r=Ne(a,s);e.value=B(e.value,s,r),t.value=V(t.value,r),n.value=V(n.value,r)}if(r){let e=Pe(o,c);r.value=Fe(r.value,c,e),t.value=H(t.value,e),n.value=H(n.value,e)}}else if(n){if(e){let e=W(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=W(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=W(r.value,i),[a,o]=G(t.value,i),s=Ne(n,a);t.value=V(t.value,s);let c=Pe(V(n,s),o);t.value=H(t.value,c),r.value=Fe(r.value,n,c),e.value=B(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=W(r.value,i),n=Ie(U(t.value,i),e);t.value=H(t.value,n)}else if(e){let n=Ie(U(e.value,i),W(t.value,i));t.value=V(t.value,n)}}var Ue=new class extends z{tokenize(e){let t=RegExp(`(\\r?\\n)|[${K}]+|[^\\S\\n\\r]+|[^${K}]`,`ug`);return e.match(t)||[]}};function We(e,t,n){return Ue.diff(e,t,n)}new class extends z{constructor(){super(...arguments),this.tokenize=Ge}equals(e,t,n){return n.ignoreWhitespace?(n.newlineIsToken&&e.includes(`
|
|
2
2
|
`)||(e=e.trim()),n.newlineIsToken&&t.includes(`
|
|
3
3
|
`)||(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
|
|
4
4
|
`)&&(e=e.slice(0,-1)),t.endsWith(`
|