galley-cms 0.1.0 → 0.1.1
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/README.md +3 -3
- package/dist/galley.mjs +887 -425
- package/dist/starters/astro-editorial/README.md +3 -11
- 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/README.md +5 -7
- 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/README.md +5 -13
- 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/README.md +3 -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-D9ZHXus9.js → AppSettingsScreen-C-YJx3gF.js} +1 -1
- package/dist/web/assets/{BodyEditor-DAJ8MM41.js → BodyEditor-8Hp9g0iX.js} +1 -1
- package/dist/web/assets/{CollectionScreen-DVXLw7MF.js → CollectionScreen-Ci_RBTIP.js} +1 -1
- package/dist/web/assets/{EditorScreen-8vhIBZu1.js → EditorScreen-CG30ospj.js} +3 -3
- package/dist/web/assets/{FormsScreen-BbngAAzO.js → FormsScreen-C5Z4-vVZ.js} +2 -2
- package/dist/web/assets/{HistoryScreen-CubZj8QG.js → HistoryScreen-Cz0FyF3N.js} +3 -3
- package/dist/web/assets/InboxScreen-GB8e8oLq.js +2 -0
- package/dist/web/assets/{MediaLibraryPane-jMuqbnLa.js → MediaLibraryPane-D5J9z7rw.js} +1 -1
- package/dist/web/assets/{MediaScreen-mg2CATkP.js → MediaScreen-CoOq4MwF.js} +1 -1
- package/dist/web/assets/{NewSiteScreen-D9zWX6oE.js → NewSiteScreen-B_2094y0.js} +1 -1
- package/dist/web/assets/Online-CS3LLMG4.js +1 -0
- package/dist/web/assets/{PluginsScreen-1qEv-u35.js → PluginsScreen-Cdkv2qWN.js} +1 -1
- package/dist/web/assets/{PreviewPane-a06mELw4.js → PreviewPane-HeTLVD45.js} +1 -1
- package/dist/web/assets/{ProofScreen-CZfFbHFS.js → ProofScreen-BGAsVuYb.js} +1 -1
- package/dist/web/assets/{ProviderSettings-BOiCGeSI.js → ProviderSettings-BtM56M7d.js} +1 -1
- package/dist/web/assets/{PublishDialog-CSKU1lfx.js → PublishDialog-Ctv1sxHs.js} +2 -2
- package/dist/web/assets/{ReachNote-CZYr1oL0.js → ReachNote-BJrBYKWR.js} +1 -1
- package/dist/web/assets/{ScriptsScreen-BXY-kqbq.js → ScriptsScreen-BsYOIXkI.js} +2 -2
- package/dist/web/assets/{SiteHomeScreen-DOrqAteL.js → SiteHomeScreen-C7LLVNdQ.js} +1 -1
- package/dist/web/assets/{SiteSettingsScreen-B8xQnhjd.js → SiteSettingsScreen-DhX8CluW.js} +1 -1
- package/dist/web/assets/{SourceView-B5SoYjUF.js → SourceView-CkX8bKwR.js} +1 -1
- package/dist/web/assets/{VisibilityScreen-B4iOATC4.js → VisibilityScreen-ChOKniqk.js} +1 -1
- package/dist/web/assets/{codemirror-g0T4-Tsm.js → codemirror-ClWBLK2a.js} +1 -1
- package/dist/web/assets/index-CtsAxi5d.js +10 -0
- package/dist/web/assets/{index-Pd8oyXqS.css → index-xTbHx1DQ.css} +1 -1
- package/dist/web/assets/{listPlan-BXud7Oxv.js → listPlan-BPJMzA6e.js} +1 -1
- package/dist/web/assets/{outside-DaBM5h5B.js → outside-Bv1jj3yu.js} +1 -1
- package/dist/web/assets/{paths-C8ESZJVU.js → paths-B6ATG9Kg.js} +1 -1
- package/dist/web/assets/{prefs-BcNyBxxO.js → prefs-D04M07D3.js} +1 -1
- package/dist/web/assets/{scaffold-BHkqc62J.js → scaffold-DrnWBKU9.js} +1 -1
- package/dist/web/assets/{usePlugins-acEOSN5a.js → usePlugins-6k3yRVYT.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +5 -5
- package/dist/web/assets/InboxScreen-Azqy6w4_.js +0 -2
- package/dist/web/assets/Online-bYUu0ETZ.js +0 -1
- package/dist/web/assets/index-Djh-DSIT.js +0 -10
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderMarkdown-R9_GwOSq.js","assets/marked.esm-CYtFtVHW.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{$ as e,E as t,Ft as n,G as r,H as i,I as a,N as o,Nt as s,P as c,St as l,T as u,W as d,_ as f,_t as p,bt as m,ft as h,g,gt as _,ht as v,it as y,kt as b,mt as x,n as ee,pt as S,tt as C,vt as w,w as te,y as T,z as E}from"./ui-C6O2tW4c.js";import{o as D,r as ne}from"./events-CTTFdOf-.js";import{a as O,i as re,o as k,s as ie}from"./chrome-Brnq5kGb.js";import{t as A}from"./changes-DLBkrfUR.js";import{t as ae}from"./site-DJUEXLHW.js";import{t as j,z as M}from"./index-Djh-DSIT.js";import{a as N,c as P,n as F,o as I,r as oe,s as L,t as se,u as R}from"./paths-C8ESZJVU.js";import{b as ce,c as le,g as z,m as B,p as V,s as ue}from"./listPlan-BXud7Oxv.js";import{t as H}from"./store-C95UZPFo.js";var U=m(),de={grip:(0,U.jsx)(U.Fragment,{children:[4.5,8,11.5].map(e=>(0,U.jsxs)(`g`,{children:[(0,U.jsx)(`circle`,{cx:`6`,cy:e,r:`1`,fill:`currentColor`,stroke:`none`}),(0,U.jsx)(`circle`,{cx:`10`,cy:e,r:`1`,fill:`currentColor`,stroke:`none`})]},e))}),"arrow-up":(0,U.jsx)(`path`,{d:`M8 13V3M4 7l4-4 4 4`}),"arrow-down":(0,U.jsx)(`path`,{d:`M8 3v10M4 9l4 4 4-4`}),bold:(0,U.jsx)(`path`,{d:`M4.5 2.8h4.2a2.6 2.6 0 0 1 0 5.2H4.5zM4.5 8h4.9a2.6 2.6 0 0 1 0 5.2H4.5z`,strokeWidth:`1.8`}),italic:(0,U.jsx)(`path`,{d:`M7 2.8h5M4 13.2h5M9.8 2.8 6.2 13.2`}),heading:(0,U.jsx)(`path`,{d:`M3.5 3v10M10.5 3v10M3.5 8h7M12.5 13V9.5l-1 .6`}),quote:(0,U.jsx)(`path`,{d:`M3 4v8M6 5h7M6 8h7M6 11h4.5`}),"list-bullet":(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`circle`,{cx:`3.5`,cy:`4.5`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,U.jsx)(`circle`,{cx:`3.5`,cy:`8`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,U.jsx)(`circle`,{cx:`3.5`,cy:`11.5`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,U.jsx)(`path`,{d:`M6.5 4.5h7M6.5 8h7M6.5 11.5h7`})]}),"list-number":(0,U.jsx)(`path`,{d:`M6.5 4.5h7M6.5 8h7M6.5 11.5h7M2.6 3.4l.9-.6V6M2.4 9.2c.2-.5 1.7-.6 1.7.3 0 .6-1.6 1.4-1.6 1.9h1.7`}),code:(0,U.jsx)(`path`,{d:`M5.5 4.5 2 8l3.5 3.5M10.5 4.5 14 8l-3.5 3.5`}),link:(0,U.jsx)(`path`,{d:`M7 9a2.5 2.5 0 0 0 3.5 0l2.2-2.2a2.5 2.5 0 0 0-3.5-3.5L8.5 4M9 7a2.5 2.5 0 0 0-3.5 0L3.3 9.2a2.5 2.5 0 0 0 3.5 3.5l.7-.7`}),image:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M2.5 3.5h11v9h-11zM2.5 10.5l3-3 3 3 2-2 3 3`}),(0,U.jsx)(`circle`,{cx:`10.5`,cy:`6`,r:`1`})]})};function W({name:e,size:t}){return(0,U.jsx)(`svg`,{className:`g-icon`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,width:t,height:t,children:de[e]})}function G({icon:e,label:t,shortcut:n,className:r,type:i=`button`,...a}){return(0,U.jsx)(p,{content:n?`${t} · ${n}`:t,decorative:!0,children:(0,U.jsx)(`button`,{type:i,className:v(`quiet`,`sm`,_(`g-btn--icon app-tool`,r)),"aria-label":t,...a,children:(0,U.jsx)(W,{name:e})})})}var K=n(s(),1),q=e=>Symbol.iterator in e,J=e=>`entries`in e,Y=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},fe=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function pe(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:q(e)&&q(t)?J(e)&&J(t)?Y(e,t):fe(e,t):Y({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function me(e){let t=K.useRef(void 0);return n=>{let r=e(n);return pe(t.current,r)?t.current:t.current=r}}var he=(0,K.createContext)(null);function X(){let e=(0,K.useContext)(he);if(!e)throw Error(`Field components must be inside <EntryForm>`);return e}function Z(e){return te(X().store,e)}function ge(e){return Z(t=>F(t.data,e))}function _e(e){let t=N(e);return Z(e=>e.saveState[t])}function ve(e){let t=N(e);return Z(e=>e.refusals[t])}function ye(e){return Z(me(t=>t.issues.filter(t=>t.field&&I(t.field,e))))}function be(e){return t=>{let n=t.changes?.files.find(t=>t.path===e);return n?.status===`added`?void 0:n?.fieldChanges}}function xe(e){let{entryPath:t}=X(),n=be(t);return A(t=>B(n(t),e))}function Se(e){let{entryPath:t}=X(),n=be(t);return A(t=>V(n(t),e)?.kind??null)}function Ce(e,t){return V(be(e)(A.getState()),t)}function we(){let{entryPath:e}=X();return A(t=>{let n=t.changes?.files.find(t=>t.path===e);return n?.status===`modified`&&!!n.bodyChanged})}function Te(e,t,n,r){let i=z(t,n);for(let e of r)i=e.value===void 0?R(i,e.path):L(i,e.path,e.value);return P(e,i)}function Ee(e){let t=new Map;for(let n of e)n.op===`set`?t.set(N(n.path),{path:n.path,value:n.value}):n.op===`unset`&&t.set(N(n.path),{path:n.path,value:void 0});return[...t.values()]}function De(e,t){return e.flatMap(e=>e.value===void 0?oe(t,e.path)?[{op:`unset`,path:e.path}]:[]:oe(t,e.path)&&se(F(t,e.path),e.value)?[]:[{op:`set`,path:e.path,value:e.value}])}var Oe=`\0body`,ke=500,Ae=2400;function je(e){return`path`in e?N(e.path):Oe}function Q(e){return e.filter(e=>`path`in e)}function Me(e){let t;for(let n of e)n.op===`body`&&(t=n.value);return t}function Ne(e){return d(e)&&(e.status===409||e.shape.code===`conflict`)}function Pe(e,t){let n=u(()=>({path:e.path,hash:e.hash,stored:e.data,storedBody:e.body,raw:e.raw,data:e.data,body:e.body,issues:e.issues,saveState:{},refusals:{},saveError:null,conflict:null,outside:null,reveal:null,busy:!1})),r=new Map,i=null,a=[],o=null,s=[],c=e.modifiedAt,l=null,d=new Map,f=()=>[...o?.ops??[],...a.flatMap(e=>e.ops)];function p(){let e=n.getState(),t=f(),s=Te(e.data,e.stored,Q(t),[...r.values()].map(e=>e.draft)),c=i?.value??Me(t)??e.storedBody;n.setState({data:s,body:c,busy:o!==null||a.length>0})}function m(e,t){let r={...n.getState().saveState};for(let i of e){let e=d.get(i);e&&clearTimeout(e),d.delete(i),t===null?delete r[i]:r[i]=t,t===`saved`&&d.set(i,setTimeout(()=>{d.delete(i);let e={...n.getState().saveState};e[i]===`saved`&&delete e[i],n.setState({saveState:e})},Ae))}n.setState({saveState:r})}function h(e=!1){if(!e&&(o||a.length>0||r.size>0||i))return;let t=s;s=[];for(let e of t)e()}function g(e,t){if(e.length===0)return;a.push({ops:e,keys:t}),m(t,`saving`);let r={...n.getState().refusals};for(let e of t)delete r[e];n.setState({refusals:r})}function _(e){let t=r.get(e);t&&(t.timer&&clearTimeout(t.timer),r.delete(e),g(v(t),[e]))}function v(e){let t=z(n.getState().stored,Q(f()));return ce({path:e.draft.path,next:e.draft.value,stored:t,required:e.required})}function y(){if(!i)return;i.timer&&clearTimeout(i.timer);let e=i.value;i=null,e!==(Me(f())??n.getState().storedBody)&&g([{op:`body`,value:e}],[Oe])}function b(){for(let e of[...r.keys()])_(e);y()}async function x(){if(o||a.length===0||n.getState().saveError){if(!o&&a.length===0&&l){let e=l;l=null,e.entry.modifiedAt>c&&C(e.entry,e.origin)}h(!!n.getState().saveError);return}let e={ops:a.flatMap(e=>e.ops),keys:[...new Set(a.flatMap(e=>e.keys))]};a=[],o=e,n.setState({busy:!0});try{let r=await t.send(e.ops,n.getState().hash);o=null,ee(r,e)}catch(t){o=null,Ne(t)?await S(e):(a=[e,...a],n.setState({saveError:t})),p()}x()}function ee(e,r){let i=new Map;for(let t of e.refused){let e=r.ops[t.index];e&&i.set(je(e),t.reason)}let a={...n.getState().refusals};for(let[e,t]of i)a[e]=t;c=e.entry.modifiedAt,n.setState({hash:e.entry.hash,stored:P(n.getState().stored,e.entry.data),storedBody:e.entry.body,raw:e.entry.raw,issues:e.entry.issues,refusals:a,saveError:null}),m(r.keys.filter(e=>!i.has(e)),`saved`),m([...i.keys()],null),t.onEntry(e.entry),p()}async function S(e){let o=[...e.ops,...a.flatMap(e=>e.ops)],s=z(n.getState().stored,Q(o));for(let e of r.values())o.push(...ce({path:e.draft.path,next:e.draft.value,stored:s,required:e.required}));let l=i?.value??Me(o)??null;for(let e of r.values())e.timer&&clearTimeout(e.timer);r.clear(),i?.timer&&clearTimeout(i.timer),i=null,a=[],m(Object.keys(n.getState().saveState),null);let u=null;try{u=await t.reload()}catch{u=null}let d=Q(o),f=[],p=n.getState().stored;for(let e of d)(e.op===`insert`||e.op===`move`||e.op===`remove`)&&f.push({op:e,data:p}),p=z(p,[e]);n.setState({conflict:{edits:Ee(d),structure:f,body:l},...u?{hash:u.hash,stored:u.data,storedBody:u.body,raw:u.raw,issues:u.issues,refusals:{}}:{}}),u&&(c=u.modifiedAt,t.onEntry(u))}function C(e,t){let r=n.getState();c=e.modifiedAt,n.setState({hash:e.hash,stored:P(r.stored,e.data),storedBody:e.body,raw:e.raw,issues:e.issues,...t?{outside:{origin:t,at:Date.now()}}:{}}),p()}let w={edit(e,t,{required:i,immediate:a}){let o=N(e),s=r.get(o);s?.timer&&clearTimeout(s.timer);let c={draft:{path:e,value:t},required:i,timer:null};r.set(o,c),n.getState().refusals[o]&&w.clearRefusal(e),a?(_(o),p(),x()):(c.timer=setTimeout(()=>{_(o),p(),x()},ke),p())},commit(e){let t=N(e);r.has(t)&&(_(t),p(),x())},editBody(e){i?.timer&&clearTimeout(i.timer),i={value:e,timer:setTimeout(()=>{y(),p(),x()},ke)},p()},commitBody(){i&&(y(),p(),x())},apply(...e){b(),g(e,[...new Set(e.map(je))]),p(),x()},flush(){b(),p();let e=new Promise(e=>s.push(e));return x(),e},receive(e,t=null){let r=n.getState();e.path===r.path&&e.hash!==r.hash&&(o||a.length>0?l={entry:e,origin:t}:C(e,t))},async saveRaw(e){await w.flush();let r=await t.send([{op:`raw`,value:e}],n.getState().hash);return(r.applied>0||r.refused.length===0)&&(c=r.entry.modifiedAt,n.setState({hash:r.entry.hash,stored:P(n.getState().stored,r.entry.data),storedBody:r.entry.body,raw:r.entry.raw,issues:r.entry.issues}),t.onEntry(r.entry),p()),r},idle(){return!o&&a.length===0&&r.size===0&&!i},async restore(e,t){if(!w.idle()||n.getState().hash!==t)return!1;let r=await w.saveRaw(e);return r.applied>0&&r.refused.length===0},reapply(){let e=n.getState().conflict;if(!e)return;n.setState({conflict:null});let t=De(e.edits,z(n.getState().stored,Q(f())));g(t,[...new Set(t.map(je))]),e.body!==null&&e.body!==n.getState().storedBody&&g([{op:`body`,value:e.body}],[Oe]),p(),x()},dismissConflict(){n.setState({conflict:null})},retry(){n.setState({saveError:null}),x()},revealField(e){n.setState({reveal:{path:e,at:Date.now()}})},clearRefusal(e){let t={...n.getState().refusals};delete t[N(e)],n.setState({refusals:t})},dispose(){for(let e of d.values())clearTimeout(e);d.clear(),b(),x()}};return Object.assign(n,{actions:w})}function Fe(e){return ie(M.threads(e),async()=>{let{threads:t}=await E(`GET /api/sites/:siteId/threads`,{params:{siteId:e}});return[...t].sort((e,t)=>t.updatedAt-e.updatedAt)})}var Ie=8;function Le({siteId:e,thread:t,onDone:n}){let[r,a]=(0,K.useState)(t.title),[o,s]=(0,K.useState)(!1),c=(0,K.useRef)(null),l=(0,K.useRef)(!1);(0,K.useEffect)(()=>{c.current?.focus(),c.current?.select()},[]);let u=async a=>{if(a?.preventDefault(),l.current)return;let o=r.trim().replace(/\s+/g,` `);if(!o||o===t.title)l.current=!0,n();else{l.current=!0,s(!0);try{let n=await E(`PATCH /api/sites/:siteId/threads/:threadId`,{params:{siteId:e,threadId:t.id},body:{title:o}}),r=re(M.threads(e)).data;r&&k(M.threads(e),r.map(e=>e.id===n.id?{...e,...n}:e)),O(M.threads(e))}catch(e){ee({tone:`danger`,title:`Couldn’t rename the chat`,body:i(e).message})}finally{s(!1),n()}}};return(0,U.jsx)(`form`,{className:`chat-head__rename`,onSubmit:e=>void u(e),children:(0,U.jsx)(`input`,{ref:c,className:`g-input g-input--sm chat-head__rename-input`,"aria-label":`Chat name`,value:r,maxLength:120,disabled:o,onChange:e=>a(e.target.value),onBlur:()=>void u(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),l.current=!0,n())}})})}function Re({siteId:e}){let t=Fe(e),n=H(t=>t.threadBySite[e]??null),r=H(e=>e.setThread),[i,a]=(0,K.useState)(null),[o,s]=(0,K.useState)(!1),l=(0,K.useRef)(null),u=t.data??[],d=u.find(e=>e.id===n)??null,f=[{id:`new`,label:`New chat`,icon:`plus`,onSelect:()=>r(e,null)},...u.length>0?[{kind:`heading`,id:`recent`,label:`Recent chats`}]:[],...u.slice(0,Ie).map(t=>({id:t.id,label:t.title,hint:h(t.updatedAt),current:t.id===n,onSelect:()=>r(e,t.id)})),...d?[{kind:`separator`,id:`sep`},{id:`rename`,label:`Rename this chat…`,onSelect:()=>s(!0)},{id:`delete`,label:`Delete this chat…`,icon:`trash`,tone:`danger`,onSelect:()=>a(d)}]:[]];return(0,U.jsxs)(U.Fragment,{children:[o&&d?(0,U.jsx)(Le,{siteId:e,thread:d,onDone:()=>{s(!1),requestAnimationFrame(()=>l.current?.focus())}}):(0,U.jsx)(`span`,{className:`chat-head__title`,title:d?.title,children:d?.title??`Assistant`}),o?null:(0,U.jsx)(`span`,{className:`g-toolbar__spacer`}),(0,U.jsx)(x,{icon:`plus`,label:`New chat`,disabled:n===null,onClick:()=>r(e,null),tooltipSide:`bottom`}),(0,U.jsx)(T,{label:`Chats`,placement:`bottom-end`,items:f,trigger:e=>(0,U.jsx)(`button`,{type:`button`,className:`g-btn g-btn--quiet g-btn--sm g-btn--icon`,"aria-label":`Chats`,...e,ref:t=>{l.current=t,e.ref.current=t},children:(0,U.jsx)(w,{name:`history`})})}),(0,U.jsx)(c,{open:i!==null,onClose:()=>a(null),title:`Delete “${i?.title??`this chat`}”?`,body:`The conversation goes away. Changes it made stay where they are — in Proof, or published.`,confirmLabel:`Delete chat`,busyLabel:`Deleting…`,errorTitle:`Couldn’t delete the chat`,onConfirm:async()=>{i&&(await E(`DELETE /api/sites/:siteId/threads/:threadId`,{params:{siteId:e,threadId:i.id}}),n===i.id&&r(e,null),O(M.threads(e)))}})]})}var ze=10485760,Be=[`image/png`,`image/jpeg`,`image/webp`,`image/gif`,`image/avif`,`image/svg+xml`],Ve=`Images only — up to 6 at a time, ${C(ze)} each`;function He(e,t){let n=[],r=[];for(let i of e){let e=i.name||`That file`;Be.includes(i.type)?i.size>10485760?r.push(`“${e}” is ${C(i.size)}, larger than ${C(ze)}. Make it smaller and attach it again.`):t+n.length>=6?r.push(`Only 6 images fit in one message, so “${e}” wasn’t added.`):n.push(i):r.push(`“${e}” isn’t an image. Attach PNG, JPG, WebP, GIF, AVIF or SVG files.`)}return{accepted:n,problems:r}}var Ue=220;function We({value:n,onChange:r,onSend:i,onStop:a,busy:o,disabled:s,locked:c,placeholder:l,history:u,attachments:d,onAttach:f,onRemoveAttachment:p,top:m,foot:h,textareaRef:g}){let _=(0,K.useRef)(null),[v,y]=(0,K.useState)(null);(0,K.useLayoutEffect)(()=>{let e=g.current;e&&(e.style.blockSize=`auto`,e.style.blockSize=`${Math.min(Ue,e.scrollHeight)}px`,e.style.overflowY=e.scrollHeight>Ue?`auto`:`hidden`)},[n,g]);let b=!s&&!o&&(n.trim().length>0||d.length>0);return(0,U.jsxs)(`div`,{className:`g-composer chat-composer`,children:[m?(0,U.jsx)(`div`,{className:`chat-composer__top`,children:m}):null,d.length>0?(0,U.jsx)(`ul`,{className:`chat-composer__files`,"aria-label":`Attached images`,children:d.map(e=>(0,U.jsxs)(`li`,{className:`chat-file`,children:[(0,U.jsx)(`img`,{src:e.dataUrl,alt:``,className:`chat-file__thumb`}),(0,U.jsx)(`span`,{className:`chat-file__name`,title:e.name,children:e.name}),(0,U.jsx)(x,{icon:`close`,label:`Remove ${e.name}`,size:`sm`,onClick:()=>p(e.id)})]},e.id))}):null,(0,U.jsx)(`label`,{className:`g-sr`,htmlFor:`chat-composer`,children:`Ask for a change`}),(0,U.jsx)(`textarea`,{id:`chat-composer`,ref:g,rows:2,value:n,placeholder:l,disabled:c&&n===``,onChange:e=>{y(null),r(e.target.value)},onPaste:e=>{let t=[...e.clipboardData.files];t.length>0&&(e.preventDefault(),f(t))},onKeyDown:e=>{if(e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing)e.preventDefault(),b&&i();else if(e.key===`ArrowUp`&&u.length>0&&(n===``||v!==null)&&e.currentTarget.selectionStart===0){e.preventDefault();let t=v===null?u.length-1:Math.max(0,v-1);y(t),r(u[t]??``)}else if(e.key===`ArrowDown`&&v!==null){e.preventDefault();let t=v+1;t>=u.length?(y(null),r(``)):(y(t),r(u[t]??``))}}}),o?(0,U.jsxs)(`button`,{className:`g-btn g-btn--secondary g-btn--sm chat-stop`,type:`button`,onClick:a,children:[(0,U.jsx)(`span`,{className:`chat-stop__square`,"aria-hidden":`true`}),`Stop`]}):(0,U.jsx)(`button`,{className:`g-btn g-btn--primary g-btn--icon g-btn--sm`,type:`button`,"aria-label":`Send`,disabled:!b,onClick:i,children:(0,U.jsx)(e,{kind:`send`})}),(0,U.jsxs)(`div`,{className:`g-composer__foot chat-composer__foot`,children:[(0,U.jsx)(x,{icon:`image`,label:`Attach images (${Ve.charAt(0).toLowerCase()}${Ve.slice(1)})`,onClick:()=>_.current?.click(),disabled:c}),(0,U.jsx)(`input`,{ref:_,type:`file`,accept:Be.join(`,`),multiple:!0,hidden:!0,onChange:e=>{f([...e.target.files??[]]),e.target.value=``}}),h,(0,U.jsxs)(`span`,{className:`chat-composer__keys`,children:[(0,U.jsx)(t,{keys:[`enter`]}),` to send · `,(0,U.jsx)(t,{keys:[`shift`,`enter`]}),` new line`]})]})]})}var Ge=null,Ke=Promise.all([j(()=>import(`./purify.es-BQJV6A36.js`),[]),j(()=>import(`./renderMarkdown-R9_GwOSq.js`),__vite__mapDeps([0,1]))]).then(([e,t])=>(Ge=n=>e.default.sanitize(t.renderMarkdown(n),{ADD_ATTR:[`target`,`rel`],FORBID_TAGS:[`style`,`img`,`form`,`input`,`button`]}),Ge));function qe({text:e}){let[t,n]=(0,K.useState)(()=>Ge);(0,K.useEffect)(()=>{t||Ke.then(e=>n(()=>e))},[t]);let r=(0,K.useMemo)(()=>t?t(e):null,[t,e]);return r===null?(0,U.jsx)(`p`,{className:`chat-user-text`,children:e}):(0,U.jsx)(`div`,{className:`chat-md`,dangerouslySetInnerHTML:{__html:r}})}function Je(e,t,n){let r=[...e.messages];return r[t]=n,{...e,messages:r}}function Ye(e,t){let n=e??[],r=n.findIndex(e=>e.id===t.id);if(r===-1)return[...n,t];let i=[...n];return i[r]=t,i}function Xe(e,t){let n=e.messages.findIndex(e=>e.id===t.id),r=t.pending?!0:e.busy;if(n===-1)return{...e,busy:r,messages:[...e.messages,t],messageCount:e.messages.length+1,updatedAt:Math.max(e.updatedAt,t.at)};let i=e.messages[n];return{...Je(e,n,t.pending&&i.pending?{...t,text:t.text.length>=i.text.length?t.text:i.text,tools:t.tools?.length?t.tools:i.tools}:t),busy:r}}function Ze(e,t){if(t.threadId!==e.id)return e;switch(t.type){case`chat.message`:return Xe(e,t.message);case`chat.delta`:{let n=e.messages.findIndex(e=>e.id===t.messageId),r=e.messages[n];return!r||!r.pending?e:Je(e,n,{...r,text:r.text+t.text})}case`chat.tool`:{let n=e.messages.findIndex(e=>e.id===t.messageId),r=e.messages[n];return r?Je(e,n,{...r,tools:Ye(r.tools,t.tool)}):e}case`chat.done`:{let n=e.messages.map(e=>e.turnId===t.turnId&&e.pending?{...e,pending:!1}:e);return{...e,busy:!1,messages:n}}case`chat.error`:{let n=e.messages.findIndex(e=>e.turnId===t.turnId&&e.role===`assistant`),r=e.messages[n];if(!r){let n={id:`error-${t.turnId}`,role:`assistant`,text:``,at:Date.now(),turnId:t.turnId,error:t.message};return{...e,busy:!1,messages:[...e.messages,n]}}return{...Je(e,n,{...r,pending:!1,error:r.error??t.message}),busy:!1}}}}function Qe(e,t){if(!e||e.id!==t.id)return t;let n=new Map(e.messages.map(e=>[e.id,e])),r=new Set(t.messages.map(e=>e.id)),i=t.messages.reduce((e,t)=>Math.max(e,t.at),0),a=t.messages.map(e=>{let t=n.get(e.id);return t&&e.pending&&t.pending&&t.text.length>e.text.length?{...e,text:t.text,tools:t.tools??e.tools}:e}),o=e.messages.filter(e=>!r.has(e.id)&&e.at>=i);return{...t,messages:[...a,...o]}}function $e(e){let t=e?.messages[e.messages.length-1];return!t||t.role!==`assistant`||t.pending||t.undone?[]:t.options??[]}function et(e){if(e.status===`running`)return`running`;if(e.status===`error`)return`failed`;let t=e.name.toLowerCase();return/^(delete|remove)_/.test(t)?`remove`:/^(read|search|list|get|find|validate|run|ask)_|^validate$/.test(t)?`read`:`edit`}function tt(e){return(e?.messages??[]).filter(e=>e.role===`user`&&e.text.trim()).map(e=>e.text)}function nt({tool:t}){let n=et(t),r={running:`g-activity--running`,read:`g-activity--done`,edit:`g-activity--edit`,remove:`g-activity--remove`,failed:`g-activity--failed`}[n];return(0,U.jsxs)(`div`,{className:`g-activity ${r}`,title:t.detail??t.label,children:[n===`running`?(0,U.jsxs)(`span`,{className:`g-dots`,"aria-hidden":`true`,children:[(0,U.jsx)(`i`,{}),(0,U.jsx)(`i`,{}),(0,U.jsx)(`i`,{})]}):(0,U.jsx)(e,{kind:n===`read`?`stet`:n===`edit`?`caret`:n===`remove`?`dele`:`bang`}),(0,U.jsxs)(`span`,{className:`g-activity__text`,children:[t.label,n===`failed`&&t.detail?` — ${t.detail}`:null]})]})}function rt({siteId:e,attachments:t}){return(0,U.jsx)(`div`,{className:`chat-thumbs`,children:t.map((t,n)=>t.path?(0,U.jsx)(`img`,{className:`chat-thumb`,src:r(e,t.path),alt:t.name,loading:`lazy`},n):(0,U.jsx)(`span`,{className:`g-tag`,children:t.name},n))})}function it({siteId:t,threadId:n,message:r}){let a=b(),[o,s]=(0,K.useState)(!1),[c,l]=(0,K.useState)(null),u=r.changedPaths??[];if(u.length===0||r.pending)return null;if(r.undone)return(0,U.jsxs)(`p`,{className:`chat-turn__note`,children:[(0,U.jsx)(e,{kind:`stet`}),(0,U.jsx)(`span`,{children:`Undone. Everything this reply changed is back to how it was.`})]});let d=async()=>{s(!0),l(null);try{await E(`POST /api/sites/:siteId/threads/:threadId/undo`,{params:{siteId:t,threadId:n},body:{turnId:r.turnId}})}catch(e){l(i(e).message)}finally{s(!1)}};return(0,U.jsxs)(`div`,{className:`chat-turn`,children:[(0,U.jsxs)(`div`,{className:`chat-turn__actions`,children:[(0,U.jsx)(S,{size:`sm`,variant:`secondary`,icon:`proof`,onClick:()=>a(`/sites/${t}/proof?path=${encodeURIComponent(u[0]??``)}`),children:`Review in Proof`}),(0,U.jsx)(S,{size:`sm`,variant:`quiet`,icon:`undo`,busy:o,busyLabel:`Undoing`,onClick:()=>void d(),children:u.length===1?`Undo this change`:`Undo these ${y(u.length,`change`)}`})]}),c?(0,U.jsxs)(`p`,{className:`g-error-text`,role:`alert`,children:[(0,U.jsx)(e,{kind:`bang`}),(0,U.jsx)(`span`,{children:c})]}):null]})}function at({siteId:t,threadId:n,message:r,options:i,onReply:a,disabled:o}){if(r.role===`user`)return(0,U.jsxs)(`div`,{className:`g-msg g-msg--user`,children:[r.attachments?.length?(0,U.jsx)(rt,{siteId:t,attachments:r.attachments}):null,(0,U.jsx)(`p`,{className:`chat-user-text`,children:r.text})]});let s=r.pending&&!r.text&&!(r.tools??[]).length;return(0,U.jsxs)(`div`,{className:`g-msg g-msg--assistant`,children:[(0,U.jsx)(`span`,{className:`g-msg__by`,"aria-hidden":`true`}),(0,U.jsxs)(`div`,{className:`g-msg__body`,children:[(0,U.jsx)(`span`,{className:`g-sr`,children:`The assistant:`}),(r.tools??[]).map(e=>(0,U.jsx)(nt,{tool:e},e.id)),s?(0,U.jsxs)(`div`,{className:`g-activity g-activity--running`,children:[(0,U.jsxs)(`span`,{className:`g-dots`,"aria-hidden":`true`,children:[(0,U.jsx)(`i`,{}),(0,U.jsx)(`i`,{}),(0,U.jsx)(`i`,{})]}),(0,U.jsx)(`span`,{className:`g-activity__text`,children:`Reading the page`})]}):null,r.text?(0,U.jsx)(qe,{text:r.text}):null,r.error&&r.error!==r.text?(0,U.jsxs)(`p`,{className:`g-error-text chat-error`,children:[(0,U.jsx)(e,{kind:`bang`}),(0,U.jsx)(`span`,{children:r.error})]}):null,i.length>0?(0,U.jsx)(`div`,{className:`g-quick-replies`,role:`group`,"aria-label":`Answers`,children:i.map(e=>(0,U.jsx)(`button`,{type:`button`,className:`g-chip`,disabled:o,title:e.detail,onClick:()=>a(e.label),children:e.label},e.label))}):null,(0,U.jsx)(it,{siteId:t,threadId:n,message:r})]})]})}function ot(e,t){switch(t.type){case`reset`:return{thread:null,status:`idle`,error:void 0};case`loading`:return{...e,status:e.thread?e.status:`loading`};case`loaded`:return{thread:Qe(e.thread,t.thread),status:`ready`,error:void 0};case`failed`:return{...e,status:e.thread?`ready`:`error`,error:t.error};case`event`:return e.thread?{...e,thread:Ze(e.thread,t.event)}:e}}function st(e,t,n){let[r,i]=(0,K.useReducer)(ot,{thread:null,status:`idle`,error:void 0}),a=(0,K.useCallback)(async t=>{i({type:`loading`});try{i({type:`loaded`,thread:await E(`GET /api/sites/:siteId/threads/:threadId`,{params:{siteId:e,threadId:t}})})}catch(e){d(e)&&e.shape.code===`not-found`&&n(),i({type:`failed`,error:e})}},[e,n]);(0,K.useEffect)(()=>{t?(r.thread?.id!==t&&i({type:`reset`}),a(t)):i({type:`reset`})},[t,a]),(0,K.useEffect)(()=>t?ne(()=>void a(t)):void 0,[t,a]);let o=t=>{t.siteId===e&&(i({type:`event`,event:t}),t.type===`chat.done`&&O(M.threads(e)))};D(`chat.message`,o),D(`chat.delta`,o),D(`chat.tool`,o),D(`chat.done`,o),D(`chat.error`,o);let s=(0,K.useCallback)(e=>i({type:`loaded`,thread:e}),[]),c=(0,K.useCallback)(()=>t?a(t):Promise.resolve(),[t,a]);return{...r,adopt:s,retry:c}}var ct=[{value:`content`,label:`Content`,title:`Changes pages, posts and images`},{value:`build`,label:`Build`,title:`Can also change the site’s design and code`}],lt={content:`Changes pages, posts and images.`,build:`Can also change the site’s design and code, and check the build.`},ut=[`Make this page’s heading shorter`,`Fix any typos on this page`,`Suggest a clearer introduction`],dt=0,ft=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t({id:`a${++dt}`,name:e.name||`image`,mime:e.type,dataUrl:String(r.result)}),r.onerror=()=>n(r.error??Error(`The file couldn’t be read.`)),r.readAsDataURL(e)});function pt(){return(0,U.jsxs)(`div`,{className:`chat-nokey`,children:[(0,U.jsx)(e,{kind:`reg`,className:`chat-nokey__mark`}),(0,U.jsx)(`h3`,{className:`chat-nokey__title`,children:`Connect the assistant.`}),(0,U.jsx)(`p`,{className:`chat-nokey__body`,children:`Paste an API key in Settings. It’s stored on this computer only. Until then you can still edit in the form and on the page.`}),(0,U.jsx)(l,{className:v(`primary`,`sm`),to:`/settings`,children:`Open settings`})]})}function mt({siteId:t,context:n,initialMessage:r}){let s=H(e=>e.threadBySite[t]),l=H(e=>e.setThread),u=H(e=>!!e.buildConfirmed[t]),d=H(e=>e.confirmBuild),p=H(e=>e.draft?.siteId===t?e.draft:null),m=ae(e=>e.detail?.model.ai.allowBuild??!1),h=Fe(t),_=ie(M.settings(),()=>E(`GET /api/settings`)),v=_.data?_.data.secrets.some(e=>e.name===`anthropic`&&e.configured):null;(0,K.useEffect)(()=>{s===void 0&&h.data&&l(t,h.data[0]?.id??null)},[s,h.data,t,l]);let y=s??null,{thread:b,status:ee,error:S,adopt:C,retry:w}=st(t,y,(0,K.useCallback)(()=>l(t,null),[t,l])),[te,T]=(0,K.useState)(``),[D,ne]=(0,K.useState)([]),[re,k]=(0,K.useState)([]),[A,j]=(0,K.useState)(!1),[N,P]=(0,K.useState)(null),[F,I]=(0,K.useState)(`content`),[oe,L]=(0,K.useState)(!1),[se,R]=(0,K.useState)(!1),[ce,le]=(0,K.useState)({page:!1,selection:null}),z=(0,K.useRef)(null),B=(0,K.useRef)(null),V=(0,K.useRef)(!0),[ue,de]=(0,K.useState)(``);(0,K.useEffect)(()=>{b&&I(b.mode===`build`&&m?`build`:`content`)},[b?.id]);let W=!!b?.busy,G={entryPath:n?.entryPath,urlPath:ce.page?void 0:n?.urlPath,selection:n?.selection&&ce.selection!==n.selection.text?n.selection:void 0},q=(0,K.useCallback)(async(e,n={})=>{let r=e.trim();if((r||D.length!==0)&&v!==!1){j(!0),P(null);try{let e=n.fresh?null:y;if(!e){let n=await E(`POST /api/sites/:siteId/threads`,{params:{siteId:t},body:{mode:F}});C(n),l(t,n.id),O(M.threads(t)),e=n.id}let i={text:r||`Here are some images.`,mode:F,context:G,...D.length?{attachments:D.map(({name:e,mime:t,dataUrl:n})=>({name:e,mime:t,dataUrl:n}))}:{}};await E(`POST /api/sites/:siteId/threads/:threadId/messages`,{params:{siteId:t,threadId:e},body:i}),V.current=!0,n.fromComposer&&T(``),ne([]),k([])}catch(e){let t=i(e);t.code===`unconfigured`&&_.refetch(),P(t.message),n.fromComposer||T(r)}finally{j(!1)}}},[D,v,y,t,F,G,C,l,_]),J=(0,K.useRef)(!1);(0,K.useEffect)(()=>{!J.current&&r&&v!==null&&(J.current=!0,v?q(r,{fresh:!0}):T(r))},[r,v,q]),(0,K.useEffect)(()=>{p&&(T(p.text),p.mode===`build`&&m&&(u?I(`build`):L(!0)),H.getState().clearDraft(),requestAnimationFrame(()=>{let e=z.current;e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))}))},[p]),(0,K.useLayoutEffect)(()=>{V.current&&B.current&&(B.current.scrollTop=B.current.scrollHeight)},[b?.messages]);let Y=b?.messages[b.messages.length-1],fe=(0,K.useRef)(!1);(0,K.useEffect)(()=>{fe.current&&!W&&de(Y?.error?`The assistant stopped.`:`The assistant replied.`),fe.current=W},[W,Y?.error]);let pe=async e=>{let{accepted:t,problems:n}=He(e,D.length);k(n);try{let e=await Promise.all(t.map(ft));ne(t=>[...t,...e])}catch(e){k(t=>[...t,`An image couldn’t be read. ${i(e).message}`])}},me=e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),R(!1),pe([...e.dataTransfer.files]))},he=$e(b),X=()=>void(y?E(`POST /api/sites/:siteId/threads/:threadId/cancel`,{params:{siteId:t,threadId:y}}).catch(()=>void 0):void 0),Z;Z=v===!1&&!b?(0,U.jsx)(pt,{}):y&&ee===`loading`&&!b?(0,U.jsxs)(`div`,{className:`g-chat`,"aria-busy":`true`,children:[(0,U.jsx)(g,{width:`70%`,height:40}),(0,U.jsx)(g,{lines:3})]}):ee===`error`&&!b?(0,U.jsx)(a,{compact:!0,title:`Couldn’t open this chat`,error:S,onRetry:()=>void w()}):!b||b.messages.length===0?(0,U.jsx)(o,{compact:!0,mark:`caret`,title:`Ask for a change.`,body:`Say it in plain words. The assistant reads the page, makes the change, and leaves it in Proof for you to check.`,children:v?(0,U.jsx)(`div`,{className:`g-quick-replies chat-starters`,children:ut.map(e=>(0,U.jsx)(`button`,{type:`button`,className:`g-chip`,onClick:()=>T(e),children:e},e))}):null}):(0,U.jsxs)(`div`,{className:`g-chat`,role:`log`,"aria-label":`Conversation`,"aria-busy":W,children:[v===!1?(0,U.jsx)(pt,{}):null,b.messages.map(e=>(0,U.jsx)(at,{siteId:t,threadId:b.id,message:e,options:e===Y?he:[],onReply:e=>void q(e),disabled:W||A},e.id))]});let ge=(0,U.jsxs)(U.Fragment,{children:[G.urlPath?(0,U.jsxs)(`span`,{className:`chat-chip`,title:`The assistant will be told which page you’re looking at`,children:[(0,U.jsx)(e,{kind:`reg`}),(0,U.jsxs)(`span`,{className:`chat-chip__text`,children:[`Looking at `,G.urlPath]}),(0,U.jsx)(x,{icon:`close`,label:`Don’t mention this page`,size:`sm`,tooltip:!1,onClick:()=>le(e=>({...e,page:!0}))})]}):null,G.selection?(0,U.jsxs)(`span`,{className:`chat-chip`,title:`The text you picked on the page`,children:[(0,U.jsx)(e,{kind:`caret`}),(0,U.jsxs)(`span`,{className:`chat-chip__text`,children:[`“`,G.selection.text,`”`]}),(0,U.jsx)(x,{icon:`close`,label:`Don’t mention the selected text`,size:`sm`,tooltip:!1,onClick:()=>le(e=>({...e,selection:G.selection?.text??null}))})]}):null]});return(0,U.jsxs)(`div`,{className:se?`chat chat--dropping`:`chat`,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),R(!0))},onDragLeave:e=>{e.currentTarget===e.target&&R(!1)},onDrop:me,children:[(0,U.jsx)(`div`,{ref:B,className:`g-pane__body chat-body`,onScroll:e=>{let t=e.currentTarget;V.current=t.scrollHeight-t.scrollTop-t.clientHeight<80},children:Z}),(0,U.jsx)(`p`,{className:`g-sr`,role:`status`,"aria-live":`polite`,children:ue}),(0,U.jsxs)(`div`,{className:`g-pane__foot chat-foot`,children:[m?(0,U.jsxs)(`div`,{className:`chat-mode`,children:[(0,U.jsx)(f,{label:`What the assistant may change`,options:ct,value:F,onChange:e=>{e===`build`&&!u?L(!0):I(e)}}),(0,U.jsx)(`span`,{className:`chat-mode__line`,children:lt[F]})]}):null,N?(0,U.jsxs)(`p`,{className:`g-error-text chat-send-error`,role:`alert`,children:[(0,U.jsx)(e,{kind:`bang`}),(0,U.jsx)(`span`,{children:N})]}):null,re.map(t=>(0,U.jsxs)(`p`,{className:`g-error-text`,role:`alert`,children:[(0,U.jsx)(e,{kind:`bang`}),(0,U.jsx)(`span`,{children:t})]},t)),(0,U.jsx)(We,{textareaRef:z,value:te,onChange:T,onSend:()=>void q(te,{fromComposer:!0}),onStop:X,busy:W,disabled:A||v===!1,locked:v===!1,placeholder:v===!1?`Connect the assistant to ask for changes`:W?`Working… you can type the next request`:`Ask for a change…`,history:tt(b),attachments:D,onAttach:e=>void pe(e),onRemoveAttachment:e=>ne(t=>t.filter(t=>t.id!==e)),top:G.urlPath||G.selection?ge:void 0})]}),(0,U.jsx)(c,{open:oe,onClose:()=>L(!1),tone:`primary`,title:`Let the assistant change the site’s code?`,body:`In build mode the assistant can also change the site’s design — its layouts, components and styles — and run the site’s build to check its work. Every change still waits in Proof until you publish.`,confirmLabel:`Use build mode`,cancelLabel:`Keep content mode`,onConfirm:()=>{d(t),I(`build`)}})]})}function ht(e,t,n){let r=t+ +!!n,i=r>e?r-1:r;return i===e?null:i}function gt(e,t){return e>t.top+t.height/2}function _t(e,t,n,r=56,i=18){let a=n-t,o=Math.min(r,a/3);return o<=0?0:e<t+o?-Math.ceil(i*Math.min(1,(t+o-e)/o)):e>n-o?Math.ceil(i*Math.min(1,(e-(n-o))/o)):0}function vt(e){let t=null,n=0,r=e=>{t=e.clientY},i=()=>{let r=e();if(r&&t!==null){let e=r.getBoundingClientRect(),n=_t(t,e.top,e.bottom);n!==0&&(r.scrollTop+=n)}n=requestAnimationFrame(i)};return document.addEventListener(`dragover`,r),n=requestAnimationFrame(i),()=>{cancelAnimationFrame(n),document.removeEventListener(`dragover`,r)}}function yt(e){let t=e.replace(/[-_]+/g,` `).replace(/([a-z])([A-Z])/g,`$1 $2`).trim();return t.charAt(0).toUpperCase()+t.slice(1)}function $(e,t,n){let r=[],i=e,a;for(let e=0;e<n.length;e++){let o=n[e];if(typeof o==`number`){let s=F(t,n.slice(0,e+1));a?.type===`blocks`?(r.push(ue(s,a)),i=le(s,a)?.fields):(r.push(`${a?.of?.label??`Item`} ${o+1}`),i=a?.of?.fields),a=void 0}else a=i?.find(e=>e.key===o),r.push(a?.label??yt(String(o))),i=a?.fields}return r.join(` › `)}function bt(e){return e===void 0?`cleared`:typeof e==`string`?e.length>80?`“${e.slice(0,78)}…”`:`“${e}”`:typeof e==`boolean`?e?`on`:`off`:typeof e==`number`?String(e):Array.isArray(e)?e.every(e=>typeof e==`string`)?e.join(`, `):`${e.length} items`:`a group of fields`}var xt=e=>e.split(` › `).pop()??e;function St(e,t){let{op:n,data:r}=t,i=$(e,r,n.path);return n.op===`insert`?`Added “${xt($(e,z(r,[n]),[...n.path,n.index]))}” to ${i}`:n.op===`move`?`Moved “${xt($(e,r,[...n.path,n.from]))}” in ${i} (to position ${n.to+1})`:`Removed “${xt($(e,r,[...n.path,n.index]))}” from ${i}`}function Ct({fields:t,noun:n=`page`}){let{store:r}=X(),i=Z(e=>e.conflict),a=r.getState().data;if(!i)return null;let o=i.edits.length+(i.body===null?0:1);return(0,U.jsxs)(`div`,{className:`app-notice app-notice--warning`,role:`alert`,children:[(0,U.jsx)(e,{kind:`bang`,className:`app-notice__mark`}),(0,U.jsxs)(`div`,{className:`app-notice__main`,children:[(0,U.jsxs)(`p`,{className:`app-notice__title`,children:[`This `,n,` changed while you were editing`]}),(0,U.jsxs)(`p`,{className:`app-notice__body`,children:[`A newer version was saved, so `,o+i.structure.length===1?`your last edit wasn’t`:`your last ${y(o+i.structure.length,`edit`)} weren’t`,` saved. The form now shows the newer version.`]}),o>0?(0,U.jsxs)(`ul`,{className:`app-notice__list`,children:[i.edits.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`b`,{children:$(t,a,e.path)}),` `,(0,U.jsx)(`span`,{className:`g-muted`,children:bt(e.value)})]},e.path.join(`.`))),i.body===null?null:(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`b`,{children:`Main text`}),` `,(0,U.jsx)(`span`,{className:`g-muted`,children:`your changes`})]})]}):null,i.structure.length>0?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`app-notice__body`,children:`These can’t be put back, because the sections and items have changed since. Make them again if you still want them:`}),(0,U.jsx)(`ul`,{className:`app-notice__list`,children:i.structure.map((e,n)=>(0,U.jsx)(`li`,{children:St(t,e)},n))})]}):null,(0,U.jsxs)(`div`,{className:`app-notice__actions`,children:[o>0?(0,U.jsx)(S,{size:`sm`,variant:`primary`,onClick:()=>r.actions.reapply(),children:`Put my edits back`}):null,(0,U.jsx)(S,{size:`sm`,variant:`quiet`,onClick:()=>r.actions.dismissConflict(),children:o>0?`Keep the newer version`:`Dismiss`})]})]})]})}function wt(){let{store:e}=X(),t=Z(e=>e.saveError);return t?(0,U.jsx)(a,{compact:!0,title:`Couldn’t save your last edit`,error:t,message:`Your edit is still in the form. Check that the app’s server is running, then try again.`,onRetry:()=>e.actions.retry(),className:`app-notice-error`}):null}var Tt={agent:`The assistant changed this page. The form shows its edits.`,external:`This page changed outside the app. The form shows the latest version.`},Et=9e3;function Dt(){let t=Z(e=>e.outside),[n,r]=(0,K.useState)(!1);return(0,K.useEffect)(()=>{if(!t)return;r(!0);let e=setTimeout(()=>r(!1),Et);return()=>clearTimeout(e)},[t]),!t||!n?null:(0,U.jsxs)(`p`,{className:`g-margin-note app-outside`,role:`status`,children:[(0,U.jsx)(e,{kind:`transpose`}),(0,U.jsx)(`span`,{children:t.origin===`agent`?Tt.agent:Tt.external})]})}function Ot({own:e,origin:t}){return e?null:t===`agent`||t===`external`?t:null}export{_e as C,W as E,ve as S,G as T,xe as _,$ as a,ge as b,gt as c,Oe as d,Pe as f,Se as g,we as h,wt as i,mt as l,Ce as m,Ct as n,vt as o,he as p,Dt as r,ht as s,Ot as t,Re as u,X as v,me as w,ye as x,Z as y};
|
|
2
|
+
import{$ as e,E as t,Ft as n,G as r,H as i,I as a,N as o,Nt as s,P as c,St as l,T as u,W as d,_ as f,_t as p,bt as m,ft as h,g,gt as _,ht as v,it as y,kt as b,mt as x,n as ee,pt as S,tt as C,vt as w,w as te,y as T,z as E}from"./ui-C6O2tW4c.js";import{o as D,r as ne}from"./events-CTTFdOf-.js";import{a as O,i as re,o as k,s as ie}from"./chrome-Brnq5kGb.js";import{t as A}from"./changes-DLBkrfUR.js";import{t as ae}from"./site-DJUEXLHW.js";import{B as j,t as M}from"./index-CtsAxi5d.js";import{a as N,c as P,n as F,o as I,r as oe,s as L,t as se,u as R}from"./paths-B6ATG9Kg.js";import{b as ce,c as le,g as z,m as B,p as V,s as ue}from"./listPlan-BPJMzA6e.js";import{t as H}from"./store-C95UZPFo.js";var U=m(),de={grip:(0,U.jsx)(U.Fragment,{children:[4.5,8,11.5].map(e=>(0,U.jsxs)(`g`,{children:[(0,U.jsx)(`circle`,{cx:`6`,cy:e,r:`1`,fill:`currentColor`,stroke:`none`}),(0,U.jsx)(`circle`,{cx:`10`,cy:e,r:`1`,fill:`currentColor`,stroke:`none`})]},e))}),"arrow-up":(0,U.jsx)(`path`,{d:`M8 13V3M4 7l4-4 4 4`}),"arrow-down":(0,U.jsx)(`path`,{d:`M8 3v10M4 9l4 4 4-4`}),bold:(0,U.jsx)(`path`,{d:`M4.5 2.8h4.2a2.6 2.6 0 0 1 0 5.2H4.5zM4.5 8h4.9a2.6 2.6 0 0 1 0 5.2H4.5z`,strokeWidth:`1.8`}),italic:(0,U.jsx)(`path`,{d:`M7 2.8h5M4 13.2h5M9.8 2.8 6.2 13.2`}),heading:(0,U.jsx)(`path`,{d:`M3.5 3v10M10.5 3v10M3.5 8h7M12.5 13V9.5l-1 .6`}),quote:(0,U.jsx)(`path`,{d:`M3 4v8M6 5h7M6 8h7M6 11h4.5`}),"list-bullet":(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`circle`,{cx:`3.5`,cy:`4.5`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,U.jsx)(`circle`,{cx:`3.5`,cy:`8`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,U.jsx)(`circle`,{cx:`3.5`,cy:`11.5`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,U.jsx)(`path`,{d:`M6.5 4.5h7M6.5 8h7M6.5 11.5h7`})]}),"list-number":(0,U.jsx)(`path`,{d:`M6.5 4.5h7M6.5 8h7M6.5 11.5h7M2.6 3.4l.9-.6V6M2.4 9.2c.2-.5 1.7-.6 1.7.3 0 .6-1.6 1.4-1.6 1.9h1.7`}),code:(0,U.jsx)(`path`,{d:`M5.5 4.5 2 8l3.5 3.5M10.5 4.5 14 8l-3.5 3.5`}),link:(0,U.jsx)(`path`,{d:`M7 9a2.5 2.5 0 0 0 3.5 0l2.2-2.2a2.5 2.5 0 0 0-3.5-3.5L8.5 4M9 7a2.5 2.5 0 0 0-3.5 0L3.3 9.2a2.5 2.5 0 0 0 3.5 3.5l.7-.7`}),image:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M2.5 3.5h11v9h-11zM2.5 10.5l3-3 3 3 2-2 3 3`}),(0,U.jsx)(`circle`,{cx:`10.5`,cy:`6`,r:`1`})]})};function W({name:e,size:t}){return(0,U.jsx)(`svg`,{className:`g-icon`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,width:t,height:t,children:de[e]})}function G({icon:e,label:t,shortcut:n,className:r,type:i=`button`,...a}){return(0,U.jsx)(p,{content:n?`${t} · ${n}`:t,decorative:!0,children:(0,U.jsx)(`button`,{type:i,className:v(`quiet`,`sm`,_(`g-btn--icon app-tool`,r)),"aria-label":t,...a,children:(0,U.jsx)(W,{name:e})})})}var K=n(s(),1),q=e=>Symbol.iterator in e,J=e=>`entries`in e,Y=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},fe=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function pe(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:q(e)&&q(t)?J(e)&&J(t)?Y(e,t):fe(e,t):Y({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function me(e){let t=K.useRef(void 0);return n=>{let r=e(n);return pe(t.current,r)?t.current:t.current=r}}var he=(0,K.createContext)(null);function X(){let e=(0,K.useContext)(he);if(!e)throw Error(`Field components must be inside <EntryForm>`);return e}function Z(e){return te(X().store,e)}function ge(e){return Z(t=>F(t.data,e))}function _e(e){let t=N(e);return Z(e=>e.saveState[t])}function ve(e){let t=N(e);return Z(e=>e.refusals[t])}function ye(e){return Z(me(t=>t.issues.filter(t=>t.field&&I(t.field,e))))}function be(e){return t=>{let n=t.changes?.files.find(t=>t.path===e);return n?.status===`added`?void 0:n?.fieldChanges}}function xe(e){let{entryPath:t}=X(),n=be(t);return A(t=>B(n(t),e))}function Se(e){let{entryPath:t}=X(),n=be(t);return A(t=>V(n(t),e)?.kind??null)}function Ce(e,t){return V(be(e)(A.getState()),t)}function we(){let{entryPath:e}=X();return A(t=>{let n=t.changes?.files.find(t=>t.path===e);return n?.status===`modified`&&!!n.bodyChanged})}function Te(e,t,n,r){let i=z(t,n);for(let e of r)i=e.value===void 0?R(i,e.path):L(i,e.path,e.value);return P(e,i)}function Ee(e){let t=new Map;for(let n of e)n.op===`set`?t.set(N(n.path),{path:n.path,value:n.value}):n.op===`unset`&&t.set(N(n.path),{path:n.path,value:void 0});return[...t.values()]}function De(e,t){return e.flatMap(e=>e.value===void 0?oe(t,e.path)?[{op:`unset`,path:e.path}]:[]:oe(t,e.path)&&se(F(t,e.path),e.value)?[]:[{op:`set`,path:e.path,value:e.value}])}var Oe=`\0body`,ke=500,Ae=2400;function je(e){return`path`in e?N(e.path):Oe}function Q(e){return e.filter(e=>`path`in e)}function Me(e){let t;for(let n of e)n.op===`body`&&(t=n.value);return t}function Ne(e){return d(e)&&(e.status===409||e.shape.code===`conflict`)}function Pe(e,t){let n=u(()=>({path:e.path,hash:e.hash,stored:e.data,storedBody:e.body,raw:e.raw,data:e.data,body:e.body,issues:e.issues,saveState:{},refusals:{},saveError:null,conflict:null,outside:null,reveal:null,busy:!1})),r=new Map,i=null,a=[],o=null,s=[],c=e.modifiedAt,l=null,d=new Map,f=()=>[...o?.ops??[],...a.flatMap(e=>e.ops)];function p(){let e=n.getState(),t=f(),s=Te(e.data,e.stored,Q(t),[...r.values()].map(e=>e.draft)),c=i?.value??Me(t)??e.storedBody;n.setState({data:s,body:c,busy:o!==null||a.length>0})}function m(e,t){let r={...n.getState().saveState};for(let i of e){let e=d.get(i);e&&clearTimeout(e),d.delete(i),t===null?delete r[i]:r[i]=t,t===`saved`&&d.set(i,setTimeout(()=>{d.delete(i);let e={...n.getState().saveState};e[i]===`saved`&&delete e[i],n.setState({saveState:e})},Ae))}n.setState({saveState:r})}function h(e=!1){if(!e&&(o||a.length>0||r.size>0||i))return;let t=s;s=[];for(let e of t)e()}function g(e,t){if(e.length===0)return;a.push({ops:e,keys:t}),m(t,`saving`);let r={...n.getState().refusals};for(let e of t)delete r[e];n.setState({refusals:r})}function _(e){let t=r.get(e);t&&(t.timer&&clearTimeout(t.timer),r.delete(e),g(v(t),[e]))}function v(e){let t=z(n.getState().stored,Q(f()));return ce({path:e.draft.path,next:e.draft.value,stored:t,required:e.required})}function y(){if(!i)return;i.timer&&clearTimeout(i.timer);let e=i.value;i=null,e!==(Me(f())??n.getState().storedBody)&&g([{op:`body`,value:e}],[Oe])}function b(){for(let e of[...r.keys()])_(e);y()}async function x(){if(o||a.length===0||n.getState().saveError){if(!o&&a.length===0&&l){let e=l;l=null,e.entry.modifiedAt>c&&C(e.entry,e.origin)}h(!!n.getState().saveError);return}let e={ops:a.flatMap(e=>e.ops),keys:[...new Set(a.flatMap(e=>e.keys))]};a=[],o=e,n.setState({busy:!0});try{let r=await t.send(e.ops,n.getState().hash);o=null,ee(r,e)}catch(t){o=null,Ne(t)?await S(e):(a=[e,...a],n.setState({saveError:t})),p()}x()}function ee(e,r){let i=new Map;for(let t of e.refused){let e=r.ops[t.index];e&&i.set(je(e),t.reason)}let a={...n.getState().refusals};for(let[e,t]of i)a[e]=t;c=e.entry.modifiedAt,n.setState({hash:e.entry.hash,stored:P(n.getState().stored,e.entry.data),storedBody:e.entry.body,raw:e.entry.raw,issues:e.entry.issues,refusals:a,saveError:null}),m(r.keys.filter(e=>!i.has(e)),`saved`),m([...i.keys()],null),t.onEntry(e.entry),p()}async function S(e){let o=[...e.ops,...a.flatMap(e=>e.ops)],s=z(n.getState().stored,Q(o));for(let e of r.values())o.push(...ce({path:e.draft.path,next:e.draft.value,stored:s,required:e.required}));let l=i?.value??Me(o)??null;for(let e of r.values())e.timer&&clearTimeout(e.timer);r.clear(),i?.timer&&clearTimeout(i.timer),i=null,a=[],m(Object.keys(n.getState().saveState),null);let u=null;try{u=await t.reload()}catch{u=null}let d=Q(o),f=[],p=n.getState().stored;for(let e of d)(e.op===`insert`||e.op===`move`||e.op===`remove`)&&f.push({op:e,data:p}),p=z(p,[e]);n.setState({conflict:{edits:Ee(d),structure:f,body:l},...u?{hash:u.hash,stored:u.data,storedBody:u.body,raw:u.raw,issues:u.issues,refusals:{}}:{}}),u&&(c=u.modifiedAt,t.onEntry(u))}function C(e,t){let r=n.getState();c=e.modifiedAt,n.setState({hash:e.hash,stored:P(r.stored,e.data),storedBody:e.body,raw:e.raw,issues:e.issues,...t?{outside:{origin:t,at:Date.now()}}:{}}),p()}let w={edit(e,t,{required:i,immediate:a}){let o=N(e),s=r.get(o);s?.timer&&clearTimeout(s.timer);let c={draft:{path:e,value:t},required:i,timer:null};r.set(o,c),n.getState().refusals[o]&&w.clearRefusal(e),a?(_(o),p(),x()):(c.timer=setTimeout(()=>{_(o),p(),x()},ke),p())},commit(e){let t=N(e);r.has(t)&&(_(t),p(),x())},editBody(e){i?.timer&&clearTimeout(i.timer),i={value:e,timer:setTimeout(()=>{y(),p(),x()},ke)},p()},commitBody(){i&&(y(),p(),x())},apply(...e){b(),g(e,[...new Set(e.map(je))]),p(),x()},flush(){b(),p();let e=new Promise(e=>s.push(e));return x(),e},receive(e,t=null){let r=n.getState();e.path===r.path&&e.hash!==r.hash&&(o||a.length>0?l={entry:e,origin:t}:C(e,t))},async saveRaw(e){await w.flush();let r=await t.send([{op:`raw`,value:e}],n.getState().hash);return(r.applied>0||r.refused.length===0)&&(c=r.entry.modifiedAt,n.setState({hash:r.entry.hash,stored:P(n.getState().stored,r.entry.data),storedBody:r.entry.body,raw:r.entry.raw,issues:r.entry.issues}),t.onEntry(r.entry),p()),r},idle(){return!o&&a.length===0&&r.size===0&&!i},async restore(e,t){if(!w.idle()||n.getState().hash!==t)return!1;let r=await w.saveRaw(e);return r.applied>0&&r.refused.length===0},reapply(){let e=n.getState().conflict;if(!e)return;n.setState({conflict:null});let t=De(e.edits,z(n.getState().stored,Q(f())));g(t,[...new Set(t.map(je))]),e.body!==null&&e.body!==n.getState().storedBody&&g([{op:`body`,value:e.body}],[Oe]),p(),x()},dismissConflict(){n.setState({conflict:null})},retry(){n.setState({saveError:null}),x()},revealField(e){n.setState({reveal:{path:e,at:Date.now()}})},clearRefusal(e){let t={...n.getState().refusals};delete t[N(e)],n.setState({refusals:t})},dispose(){for(let e of d.values())clearTimeout(e);d.clear(),b(),x()}};return Object.assign(n,{actions:w})}function Fe(e){return ie(j.threads(e),async()=>{let{threads:t}=await E(`GET /api/sites/:siteId/threads`,{params:{siteId:e}});return[...t].sort((e,t)=>t.updatedAt-e.updatedAt)})}var Ie=8;function Le({siteId:e,thread:t,onDone:n}){let[r,a]=(0,K.useState)(t.title),[o,s]=(0,K.useState)(!1),c=(0,K.useRef)(null),l=(0,K.useRef)(!1);(0,K.useEffect)(()=>{c.current?.focus(),c.current?.select()},[]);let u=async a=>{if(a?.preventDefault(),l.current)return;let o=r.trim().replace(/\s+/g,` `);if(!o||o===t.title)l.current=!0,n();else{l.current=!0,s(!0);try{let n=await E(`PATCH /api/sites/:siteId/threads/:threadId`,{params:{siteId:e,threadId:t.id},body:{title:o}}),r=re(j.threads(e)).data;r&&k(j.threads(e),r.map(e=>e.id===n.id?{...e,...n}:e)),O(j.threads(e))}catch(e){ee({tone:`danger`,title:`Couldn’t rename the chat`,body:i(e).message})}finally{s(!1),n()}}};return(0,U.jsx)(`form`,{className:`chat-head__rename`,onSubmit:e=>void u(e),children:(0,U.jsx)(`input`,{ref:c,className:`g-input g-input--sm chat-head__rename-input`,"aria-label":`Chat name`,value:r,maxLength:120,disabled:o,onChange:e=>a(e.target.value),onBlur:()=>void u(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),l.current=!0,n())}})})}function Re({siteId:e}){let t=Fe(e),n=H(t=>t.threadBySite[e]??null),r=H(e=>e.setThread),[i,a]=(0,K.useState)(null),[o,s]=(0,K.useState)(!1),l=(0,K.useRef)(null),u=t.data??[],d=u.find(e=>e.id===n)??null,f=[{id:`new`,label:`New chat`,icon:`plus`,onSelect:()=>r(e,null)},...u.length>0?[{kind:`heading`,id:`recent`,label:`Recent chats`}]:[],...u.slice(0,Ie).map(t=>({id:t.id,label:t.title,hint:h(t.updatedAt),current:t.id===n,onSelect:()=>r(e,t.id)})),...d?[{kind:`separator`,id:`sep`},{id:`rename`,label:`Rename this chat…`,onSelect:()=>s(!0)},{id:`delete`,label:`Delete this chat…`,icon:`trash`,tone:`danger`,onSelect:()=>a(d)}]:[]];return(0,U.jsxs)(U.Fragment,{children:[o&&d?(0,U.jsx)(Le,{siteId:e,thread:d,onDone:()=>{s(!1),requestAnimationFrame(()=>l.current?.focus())}}):(0,U.jsx)(`span`,{className:`chat-head__title`,title:d?.title,children:d?.title??`Assistant`}),o?null:(0,U.jsx)(`span`,{className:`g-toolbar__spacer`}),(0,U.jsx)(x,{icon:`plus`,label:`New chat`,disabled:n===null,onClick:()=>r(e,null),tooltipSide:`bottom`}),(0,U.jsx)(T,{label:`Chats`,placement:`bottom-end`,items:f,trigger:e=>(0,U.jsx)(`button`,{type:`button`,className:`g-btn g-btn--quiet g-btn--sm g-btn--icon`,"aria-label":`Chats`,...e,ref:t=>{l.current=t,e.ref.current=t},children:(0,U.jsx)(w,{name:`history`})})}),(0,U.jsx)(c,{open:i!==null,onClose:()=>a(null),title:`Delete “${i?.title??`this chat`}”?`,body:`The conversation goes away. Changes it made stay where they are — in Proof, or published.`,confirmLabel:`Delete chat`,busyLabel:`Deleting…`,errorTitle:`Couldn’t delete the chat`,onConfirm:async()=>{i&&(await E(`DELETE /api/sites/:siteId/threads/:threadId`,{params:{siteId:e,threadId:i.id}}),n===i.id&&r(e,null),O(j.threads(e)))}})]})}var ze=10485760,Be=[`image/png`,`image/jpeg`,`image/webp`,`image/gif`,`image/avif`,`image/svg+xml`],Ve=`Images only — up to 6 at a time, ${C(ze)} each`;function He(e,t){let n=[],r=[];for(let i of e){let e=i.name||`That file`;Be.includes(i.type)?i.size>10485760?r.push(`“${e}” is ${C(i.size)}, larger than ${C(ze)}. Make it smaller and attach it again.`):t+n.length>=6?r.push(`Only 6 images fit in one message, so “${e}” wasn’t added.`):n.push(i):r.push(`“${e}” isn’t an image. Attach PNG, JPG, WebP, GIF, AVIF or SVG files.`)}return{accepted:n,problems:r}}var Ue=220;function We({value:n,onChange:r,onSend:i,onStop:a,busy:o,disabled:s,locked:c,placeholder:l,history:u,attachments:d,onAttach:f,onRemoveAttachment:p,top:m,foot:h,textareaRef:g}){let _=(0,K.useRef)(null),[v,y]=(0,K.useState)(null);(0,K.useLayoutEffect)(()=>{let e=g.current;e&&(e.style.blockSize=`auto`,e.style.blockSize=`${Math.min(Ue,e.scrollHeight)}px`,e.style.overflowY=e.scrollHeight>Ue?`auto`:`hidden`)},[n,g]);let b=!s&&!o&&(n.trim().length>0||d.length>0);return(0,U.jsxs)(`div`,{className:`g-composer chat-composer`,children:[m?(0,U.jsx)(`div`,{className:`chat-composer__top`,children:m}):null,d.length>0?(0,U.jsx)(`ul`,{className:`chat-composer__files`,"aria-label":`Attached images`,children:d.map(e=>(0,U.jsxs)(`li`,{className:`chat-file`,children:[(0,U.jsx)(`img`,{src:e.dataUrl,alt:``,className:`chat-file__thumb`}),(0,U.jsx)(`span`,{className:`chat-file__name`,title:e.name,children:e.name}),(0,U.jsx)(x,{icon:`close`,label:`Remove ${e.name}`,size:`sm`,onClick:()=>p(e.id)})]},e.id))}):null,(0,U.jsx)(`label`,{className:`g-sr`,htmlFor:`chat-composer`,children:`Ask for a change`}),(0,U.jsx)(`textarea`,{id:`chat-composer`,ref:g,rows:2,value:n,placeholder:l,disabled:c&&n===``,onChange:e=>{y(null),r(e.target.value)},onPaste:e=>{let t=[...e.clipboardData.files];t.length>0&&(e.preventDefault(),f(t))},onKeyDown:e=>{if(e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing)e.preventDefault(),b&&i();else if(e.key===`ArrowUp`&&u.length>0&&(n===``||v!==null)&&e.currentTarget.selectionStart===0){e.preventDefault();let t=v===null?u.length-1:Math.max(0,v-1);y(t),r(u[t]??``)}else if(e.key===`ArrowDown`&&v!==null){e.preventDefault();let t=v+1;t>=u.length?(y(null),r(``)):(y(t),r(u[t]??``))}}}),o?(0,U.jsxs)(`button`,{className:`g-btn g-btn--secondary g-btn--sm chat-stop`,type:`button`,onClick:a,children:[(0,U.jsx)(`span`,{className:`chat-stop__square`,"aria-hidden":`true`}),`Stop`]}):(0,U.jsx)(`button`,{className:`g-btn g-btn--primary g-btn--icon g-btn--sm`,type:`button`,"aria-label":`Send`,disabled:!b,onClick:i,children:(0,U.jsx)(e,{kind:`send`})}),(0,U.jsxs)(`div`,{className:`g-composer__foot chat-composer__foot`,children:[(0,U.jsx)(x,{icon:`image`,label:`Attach images (${Ve.charAt(0).toLowerCase()}${Ve.slice(1)})`,onClick:()=>_.current?.click(),disabled:c}),(0,U.jsx)(`input`,{ref:_,type:`file`,accept:Be.join(`,`),multiple:!0,hidden:!0,onChange:e=>{f([...e.target.files??[]]),e.target.value=``}}),h,(0,U.jsxs)(`span`,{className:`chat-composer__keys`,children:[(0,U.jsx)(t,{keys:[`enter`]}),` to send · `,(0,U.jsx)(t,{keys:[`shift`,`enter`]}),` new line`]})]})]})}var Ge=null,Ke=Promise.all([M(()=>import(`./purify.es-BQJV6A36.js`),[]),M(()=>import(`./renderMarkdown-R9_GwOSq.js`),__vite__mapDeps([0,1]))]).then(([e,t])=>(Ge=n=>e.default.sanitize(t.renderMarkdown(n),{ADD_ATTR:[`target`,`rel`],FORBID_TAGS:[`style`,`img`,`form`,`input`,`button`]}),Ge));function qe({text:e}){let[t,n]=(0,K.useState)(()=>Ge);(0,K.useEffect)(()=>{t||Ke.then(e=>n(()=>e))},[t]);let r=(0,K.useMemo)(()=>t?t(e):null,[t,e]);return r===null?(0,U.jsx)(`p`,{className:`chat-user-text`,children:e}):(0,U.jsx)(`div`,{className:`chat-md`,dangerouslySetInnerHTML:{__html:r}})}function Je(e,t,n){let r=[...e.messages];return r[t]=n,{...e,messages:r}}function Ye(e,t){let n=e??[],r=n.findIndex(e=>e.id===t.id);if(r===-1)return[...n,t];let i=[...n];return i[r]=t,i}function Xe(e,t){let n=e.messages.findIndex(e=>e.id===t.id),r=t.pending?!0:e.busy;if(n===-1)return{...e,busy:r,messages:[...e.messages,t],messageCount:e.messages.length+1,updatedAt:Math.max(e.updatedAt,t.at)};let i=e.messages[n];return{...Je(e,n,t.pending&&i.pending?{...t,text:t.text.length>=i.text.length?t.text:i.text,tools:t.tools?.length?t.tools:i.tools}:t),busy:r}}function Ze(e,t){if(t.threadId!==e.id)return e;switch(t.type){case`chat.message`:return Xe(e,t.message);case`chat.delta`:{let n=e.messages.findIndex(e=>e.id===t.messageId),r=e.messages[n];return!r||!r.pending?e:Je(e,n,{...r,text:r.text+t.text})}case`chat.tool`:{let n=e.messages.findIndex(e=>e.id===t.messageId),r=e.messages[n];return r?Je(e,n,{...r,tools:Ye(r.tools,t.tool)}):e}case`chat.done`:{let n=e.messages.map(e=>e.turnId===t.turnId&&e.pending?{...e,pending:!1}:e);return{...e,busy:!1,messages:n}}case`chat.error`:{let n=e.messages.findIndex(e=>e.turnId===t.turnId&&e.role===`assistant`),r=e.messages[n];if(!r){let n={id:`error-${t.turnId}`,role:`assistant`,text:``,at:Date.now(),turnId:t.turnId,error:t.message};return{...e,busy:!1,messages:[...e.messages,n]}}return{...Je(e,n,{...r,pending:!1,error:r.error??t.message}),busy:!1}}}}function Qe(e,t){if(!e||e.id!==t.id)return t;let n=new Map(e.messages.map(e=>[e.id,e])),r=new Set(t.messages.map(e=>e.id)),i=t.messages.reduce((e,t)=>Math.max(e,t.at),0),a=t.messages.map(e=>{let t=n.get(e.id);return t&&e.pending&&t.pending&&t.text.length>e.text.length?{...e,text:t.text,tools:t.tools??e.tools}:e}),o=e.messages.filter(e=>!r.has(e.id)&&e.at>=i);return{...t,messages:[...a,...o]}}function $e(e){let t=e?.messages[e.messages.length-1];return!t||t.role!==`assistant`||t.pending||t.undone?[]:t.options??[]}function et(e){if(e.status===`running`)return`running`;if(e.status===`error`)return`failed`;let t=e.name.toLowerCase();return/^(delete|remove)_/.test(t)?`remove`:/^(read|search|list|get|find|validate|run|ask)_|^validate$/.test(t)?`read`:`edit`}function tt(e){return(e?.messages??[]).filter(e=>e.role===`user`&&e.text.trim()).map(e=>e.text)}function nt({tool:t}){let n=et(t),r={running:`g-activity--running`,read:`g-activity--done`,edit:`g-activity--edit`,remove:`g-activity--remove`,failed:`g-activity--failed`}[n];return(0,U.jsxs)(`div`,{className:`g-activity ${r}`,title:t.detail??t.label,children:[n===`running`?(0,U.jsxs)(`span`,{className:`g-dots`,"aria-hidden":`true`,children:[(0,U.jsx)(`i`,{}),(0,U.jsx)(`i`,{}),(0,U.jsx)(`i`,{})]}):(0,U.jsx)(e,{kind:n===`read`?`stet`:n===`edit`?`caret`:n===`remove`?`dele`:`bang`}),(0,U.jsxs)(`span`,{className:`g-activity__text`,children:[t.label,n===`failed`&&t.detail?` — ${t.detail}`:null]})]})}function rt({siteId:e,attachments:t}){return(0,U.jsx)(`div`,{className:`chat-thumbs`,children:t.map((t,n)=>t.path?(0,U.jsx)(`img`,{className:`chat-thumb`,src:r(e,t.path),alt:t.name,loading:`lazy`},n):(0,U.jsx)(`span`,{className:`g-tag`,children:t.name},n))})}function it({siteId:t,threadId:n,message:r}){let a=b(),[o,s]=(0,K.useState)(!1),[c,l]=(0,K.useState)(null),u=r.changedPaths??[];if(u.length===0||r.pending)return null;if(r.undone)return(0,U.jsxs)(`p`,{className:`chat-turn__note`,children:[(0,U.jsx)(e,{kind:`stet`}),(0,U.jsx)(`span`,{children:`Undone. Everything this reply changed is back to how it was.`})]});let d=async()=>{s(!0),l(null);try{await E(`POST /api/sites/:siteId/threads/:threadId/undo`,{params:{siteId:t,threadId:n},body:{turnId:r.turnId}})}catch(e){l(i(e).message)}finally{s(!1)}};return(0,U.jsxs)(`div`,{className:`chat-turn`,children:[(0,U.jsxs)(`div`,{className:`chat-turn__actions`,children:[(0,U.jsx)(S,{size:`sm`,variant:`secondary`,icon:`proof`,onClick:()=>a(`/sites/${t}/proof?path=${encodeURIComponent(u[0]??``)}`),children:`Review in Proof`}),(0,U.jsx)(S,{size:`sm`,variant:`quiet`,icon:`undo`,busy:o,busyLabel:`Undoing`,onClick:()=>void d(),children:u.length===1?`Undo this change`:`Undo these ${y(u.length,`change`)}`})]}),c?(0,U.jsxs)(`p`,{className:`g-error-text`,role:`alert`,children:[(0,U.jsx)(e,{kind:`bang`}),(0,U.jsx)(`span`,{children:c})]}):null]})}function at({siteId:t,threadId:n,message:r,options:i,onReply:a,disabled:o}){if(r.role===`user`)return(0,U.jsxs)(`div`,{className:`g-msg g-msg--user`,children:[r.attachments?.length?(0,U.jsx)(rt,{siteId:t,attachments:r.attachments}):null,(0,U.jsx)(`p`,{className:`chat-user-text`,children:r.text})]});let s=r.pending&&!r.text&&!(r.tools??[]).length;return(0,U.jsxs)(`div`,{className:`g-msg g-msg--assistant`,children:[(0,U.jsx)(`span`,{className:`g-msg__by`,"aria-hidden":`true`}),(0,U.jsxs)(`div`,{className:`g-msg__body`,children:[(0,U.jsx)(`span`,{className:`g-sr`,children:`The assistant:`}),(r.tools??[]).map(e=>(0,U.jsx)(nt,{tool:e},e.id)),s?(0,U.jsxs)(`div`,{className:`g-activity g-activity--running`,children:[(0,U.jsxs)(`span`,{className:`g-dots`,"aria-hidden":`true`,children:[(0,U.jsx)(`i`,{}),(0,U.jsx)(`i`,{}),(0,U.jsx)(`i`,{})]}),(0,U.jsx)(`span`,{className:`g-activity__text`,children:`Reading the page`})]}):null,r.text?(0,U.jsx)(qe,{text:r.text}):null,r.error&&r.error!==r.text?(0,U.jsxs)(`p`,{className:`g-error-text chat-error`,children:[(0,U.jsx)(e,{kind:`bang`}),(0,U.jsx)(`span`,{children:r.error})]}):null,i.length>0?(0,U.jsx)(`div`,{className:`g-quick-replies`,role:`group`,"aria-label":`Answers`,children:i.map(e=>(0,U.jsx)(`button`,{type:`button`,className:`g-chip`,disabled:o,title:e.detail,onClick:()=>a(e.label),children:e.label},e.label))}):null,(0,U.jsx)(it,{siteId:t,threadId:n,message:r})]})]})}function ot(e,t){switch(t.type){case`reset`:return{thread:null,status:`idle`,error:void 0};case`loading`:return{...e,status:e.thread?e.status:`loading`};case`loaded`:return{thread:Qe(e.thread,t.thread),status:`ready`,error:void 0};case`failed`:return{...e,status:e.thread?`ready`:`error`,error:t.error};case`event`:return e.thread?{...e,thread:Ze(e.thread,t.event)}:e}}function st(e,t,n){let[r,i]=(0,K.useReducer)(ot,{thread:null,status:`idle`,error:void 0}),a=(0,K.useCallback)(async t=>{i({type:`loading`});try{i({type:`loaded`,thread:await E(`GET /api/sites/:siteId/threads/:threadId`,{params:{siteId:e,threadId:t}})})}catch(e){d(e)&&e.shape.code===`not-found`&&n(),i({type:`failed`,error:e})}},[e,n]);(0,K.useEffect)(()=>{t?(r.thread?.id!==t&&i({type:`reset`}),a(t)):i({type:`reset`})},[t,a]),(0,K.useEffect)(()=>t?ne(()=>void a(t)):void 0,[t,a]);let o=t=>{t.siteId===e&&(i({type:`event`,event:t}),t.type===`chat.done`&&O(j.threads(e)))};D(`chat.message`,o),D(`chat.delta`,o),D(`chat.tool`,o),D(`chat.done`,o),D(`chat.error`,o);let s=(0,K.useCallback)(e=>i({type:`loaded`,thread:e}),[]),c=(0,K.useCallback)(()=>t?a(t):Promise.resolve(),[t,a]);return{...r,adopt:s,retry:c}}var ct=[{value:`content`,label:`Content`,title:`Changes pages, posts and images`},{value:`build`,label:`Build`,title:`Can also change the site’s design and code`}],lt={content:`Changes pages, posts and images.`,build:`Can also change the site’s design and code, and check the build.`},ut=[`Make this page’s heading shorter`,`Fix any typos on this page`,`Suggest a clearer introduction`],dt=0,ft=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t({id:`a${++dt}`,name:e.name||`image`,mime:e.type,dataUrl:String(r.result)}),r.onerror=()=>n(r.error??Error(`The file couldn’t be read.`)),r.readAsDataURL(e)});function pt(){return(0,U.jsxs)(`div`,{className:`chat-nokey`,children:[(0,U.jsx)(e,{kind:`reg`,className:`chat-nokey__mark`}),(0,U.jsx)(`h3`,{className:`chat-nokey__title`,children:`Connect the assistant.`}),(0,U.jsx)(`p`,{className:`chat-nokey__body`,children:`Paste an API key in Settings. It’s stored on this computer only. Until then you can still edit in the form and on the page.`}),(0,U.jsx)(l,{className:v(`primary`,`sm`),to:`/settings`,children:`Open settings`})]})}function mt({siteId:t,context:n,initialMessage:r}){let s=H(e=>e.threadBySite[t]),l=H(e=>e.setThread),u=H(e=>!!e.buildConfirmed[t]),d=H(e=>e.confirmBuild),p=H(e=>e.draft?.siteId===t?e.draft:null),m=ae(e=>e.detail?.model.ai.allowBuild??!1),h=Fe(t),_=ie(j.settings(),()=>E(`GET /api/settings`)),v=_.data?_.data.secrets.some(e=>e.name===`anthropic`&&e.configured):null;(0,K.useEffect)(()=>{s===void 0&&h.data&&l(t,h.data[0]?.id??null)},[s,h.data,t,l]);let y=s??null,{thread:b,status:ee,error:S,adopt:C,retry:w}=st(t,y,(0,K.useCallback)(()=>l(t,null),[t,l])),[te,T]=(0,K.useState)(``),[D,ne]=(0,K.useState)([]),[re,k]=(0,K.useState)([]),[A,M]=(0,K.useState)(!1),[N,P]=(0,K.useState)(null),[F,I]=(0,K.useState)(`content`),[oe,L]=(0,K.useState)(!1),[se,R]=(0,K.useState)(!1),[ce,le]=(0,K.useState)({page:!1,selection:null}),z=(0,K.useRef)(null),B=(0,K.useRef)(null),V=(0,K.useRef)(!0),[ue,de]=(0,K.useState)(``);(0,K.useEffect)(()=>{b&&I(b.mode===`build`&&m?`build`:`content`)},[b?.id]);let W=!!b?.busy,G={entryPath:n?.entryPath,urlPath:ce.page?void 0:n?.urlPath,selection:n?.selection&&ce.selection!==n.selection.text?n.selection:void 0},q=(0,K.useCallback)(async(e,n={})=>{let r=e.trim();if((r||D.length!==0)&&v!==!1){M(!0),P(null);try{let e=n.fresh?null:y;if(!e){let n=await E(`POST /api/sites/:siteId/threads`,{params:{siteId:t},body:{mode:F}});C(n),l(t,n.id),O(j.threads(t)),e=n.id}let i={text:r||`Here are some images.`,mode:F,context:G,...D.length?{attachments:D.map(({name:e,mime:t,dataUrl:n})=>({name:e,mime:t,dataUrl:n}))}:{}};await E(`POST /api/sites/:siteId/threads/:threadId/messages`,{params:{siteId:t,threadId:e},body:i}),V.current=!0,n.fromComposer&&T(``),ne([]),k([])}catch(e){let t=i(e);t.code===`unconfigured`&&_.refetch(),P(t.message),n.fromComposer||T(r)}finally{M(!1)}}},[D,v,y,t,F,G,C,l,_]),J=(0,K.useRef)(!1);(0,K.useEffect)(()=>{!J.current&&r&&v!==null&&(J.current=!0,v?q(r,{fresh:!0}):T(r))},[r,v,q]),(0,K.useEffect)(()=>{p&&(T(p.text),p.mode===`build`&&m&&(u?I(`build`):L(!0)),H.getState().clearDraft(),requestAnimationFrame(()=>{let e=z.current;e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))}))},[p]),(0,K.useLayoutEffect)(()=>{V.current&&B.current&&(B.current.scrollTop=B.current.scrollHeight)},[b?.messages]);let Y=b?.messages[b.messages.length-1],fe=(0,K.useRef)(!1);(0,K.useEffect)(()=>{fe.current&&!W&&de(Y?.error?`The assistant stopped.`:`The assistant replied.`),fe.current=W},[W,Y?.error]);let pe=async e=>{let{accepted:t,problems:n}=He(e,D.length);k(n);try{let e=await Promise.all(t.map(ft));ne(t=>[...t,...e])}catch(e){k(t=>[...t,`An image couldn’t be read. ${i(e).message}`])}},me=e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),R(!1),pe([...e.dataTransfer.files]))},he=$e(b),X=()=>void(y?E(`POST /api/sites/:siteId/threads/:threadId/cancel`,{params:{siteId:t,threadId:y}}).catch(()=>void 0):void 0),Z;Z=v===!1&&!b?(0,U.jsx)(pt,{}):y&&ee===`loading`&&!b?(0,U.jsxs)(`div`,{className:`g-chat`,"aria-busy":`true`,children:[(0,U.jsx)(g,{width:`70%`,height:40}),(0,U.jsx)(g,{lines:3})]}):ee===`error`&&!b?(0,U.jsx)(a,{compact:!0,title:`Couldn’t open this chat`,error:S,onRetry:()=>void w()}):!b||b.messages.length===0?(0,U.jsx)(o,{compact:!0,mark:`caret`,title:`Ask for a change.`,body:`Say it in plain words. The assistant reads the page, makes the change, and leaves it in Proof for you to check.`,children:v?(0,U.jsx)(`div`,{className:`g-quick-replies chat-starters`,children:ut.map(e=>(0,U.jsx)(`button`,{type:`button`,className:`g-chip`,onClick:()=>T(e),children:e},e))}):null}):(0,U.jsxs)(`div`,{className:`g-chat`,role:`log`,"aria-label":`Conversation`,"aria-busy":W,children:[v===!1?(0,U.jsx)(pt,{}):null,b.messages.map(e=>(0,U.jsx)(at,{siteId:t,threadId:b.id,message:e,options:e===Y?he:[],onReply:e=>void q(e),disabled:W||A},e.id))]});let ge=(0,U.jsxs)(U.Fragment,{children:[G.urlPath?(0,U.jsxs)(`span`,{className:`chat-chip`,title:`The assistant will be told which page you’re looking at`,children:[(0,U.jsx)(e,{kind:`reg`}),(0,U.jsxs)(`span`,{className:`chat-chip__text`,children:[`Looking at `,G.urlPath]}),(0,U.jsx)(x,{icon:`close`,label:`Don’t mention this page`,size:`sm`,tooltip:!1,onClick:()=>le(e=>({...e,page:!0}))})]}):null,G.selection?(0,U.jsxs)(`span`,{className:`chat-chip`,title:`The text you picked on the page`,children:[(0,U.jsx)(e,{kind:`caret`}),(0,U.jsxs)(`span`,{className:`chat-chip__text`,children:[`“`,G.selection.text,`”`]}),(0,U.jsx)(x,{icon:`close`,label:`Don’t mention the selected text`,size:`sm`,tooltip:!1,onClick:()=>le(e=>({...e,selection:G.selection?.text??null}))})]}):null]});return(0,U.jsxs)(`div`,{className:se?`chat chat--dropping`:`chat`,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),R(!0))},onDragLeave:e=>{e.currentTarget===e.target&&R(!1)},onDrop:me,children:[(0,U.jsx)(`div`,{ref:B,className:`g-pane__body chat-body`,onScroll:e=>{let t=e.currentTarget;V.current=t.scrollHeight-t.scrollTop-t.clientHeight<80},children:Z}),(0,U.jsx)(`p`,{className:`g-sr`,role:`status`,"aria-live":`polite`,children:ue}),(0,U.jsxs)(`div`,{className:`g-pane__foot chat-foot`,children:[m?(0,U.jsxs)(`div`,{className:`chat-mode`,children:[(0,U.jsx)(f,{label:`What the assistant may change`,options:ct,value:F,onChange:e=>{e===`build`&&!u?L(!0):I(e)}}),(0,U.jsx)(`span`,{className:`chat-mode__line`,children:lt[F]})]}):null,N?(0,U.jsxs)(`p`,{className:`g-error-text chat-send-error`,role:`alert`,children:[(0,U.jsx)(e,{kind:`bang`}),(0,U.jsx)(`span`,{children:N})]}):null,re.map(t=>(0,U.jsxs)(`p`,{className:`g-error-text`,role:`alert`,children:[(0,U.jsx)(e,{kind:`bang`}),(0,U.jsx)(`span`,{children:t})]},t)),(0,U.jsx)(We,{textareaRef:z,value:te,onChange:T,onSend:()=>void q(te,{fromComposer:!0}),onStop:X,busy:W,disabled:A||v===!1,locked:v===!1,placeholder:v===!1?`Connect the assistant to ask for changes`:W?`Working… you can type the next request`:`Ask for a change…`,history:tt(b),attachments:D,onAttach:e=>void pe(e),onRemoveAttachment:e=>ne(t=>t.filter(t=>t.id!==e)),top:G.urlPath||G.selection?ge:void 0})]}),(0,U.jsx)(c,{open:oe,onClose:()=>L(!1),tone:`primary`,title:`Let the assistant change the site’s code?`,body:`In build mode the assistant can also change the site’s design — its layouts, components and styles — and run the site’s build to check its work. Every change still waits in Proof until you publish.`,confirmLabel:`Use build mode`,cancelLabel:`Keep content mode`,onConfirm:()=>{d(t),I(`build`)}})]})}function ht(e,t,n){let r=t+ +!!n,i=r>e?r-1:r;return i===e?null:i}function gt(e,t){return e>t.top+t.height/2}function _t(e,t,n,r=56,i=18){let a=n-t,o=Math.min(r,a/3);return o<=0?0:e<t+o?-Math.ceil(i*Math.min(1,(t+o-e)/o)):e>n-o?Math.ceil(i*Math.min(1,(e-(n-o))/o)):0}function vt(e){let t=null,n=0,r=e=>{t=e.clientY},i=()=>{let r=e();if(r&&t!==null){let e=r.getBoundingClientRect(),n=_t(t,e.top,e.bottom);n!==0&&(r.scrollTop+=n)}n=requestAnimationFrame(i)};return document.addEventListener(`dragover`,r),n=requestAnimationFrame(i),()=>{cancelAnimationFrame(n),document.removeEventListener(`dragover`,r)}}function yt(e){let t=e.replace(/[-_]+/g,` `).replace(/([a-z])([A-Z])/g,`$1 $2`).trim();return t.charAt(0).toUpperCase()+t.slice(1)}function $(e,t,n){let r=[],i=e,a;for(let e=0;e<n.length;e++){let o=n[e];if(typeof o==`number`){let s=F(t,n.slice(0,e+1));a?.type===`blocks`?(r.push(ue(s,a)),i=le(s,a)?.fields):(r.push(`${a?.of?.label??`Item`} ${o+1}`),i=a?.of?.fields),a=void 0}else a=i?.find(e=>e.key===o),r.push(a?.label??yt(String(o))),i=a?.fields}return r.join(` › `)}function bt(e){return e===void 0?`cleared`:typeof e==`string`?e.length>80?`“${e.slice(0,78)}…”`:`“${e}”`:typeof e==`boolean`?e?`on`:`off`:typeof e==`number`?String(e):Array.isArray(e)?e.every(e=>typeof e==`string`)?e.join(`, `):`${e.length} items`:`a group of fields`}var xt=e=>e.split(` › `).pop()??e;function St(e,t){let{op:n,data:r}=t,i=$(e,r,n.path);return n.op===`insert`?`Added “${xt($(e,z(r,[n]),[...n.path,n.index]))}” to ${i}`:n.op===`move`?`Moved “${xt($(e,r,[...n.path,n.from]))}” in ${i} (to position ${n.to+1})`:`Removed “${xt($(e,r,[...n.path,n.index]))}” from ${i}`}function Ct({fields:t,noun:n=`page`}){let{store:r}=X(),i=Z(e=>e.conflict),a=r.getState().data;if(!i)return null;let o=i.edits.length+(i.body===null?0:1);return(0,U.jsxs)(`div`,{className:`app-notice app-notice--warning`,role:`alert`,children:[(0,U.jsx)(e,{kind:`bang`,className:`app-notice__mark`}),(0,U.jsxs)(`div`,{className:`app-notice__main`,children:[(0,U.jsxs)(`p`,{className:`app-notice__title`,children:[`This `,n,` changed while you were editing`]}),(0,U.jsxs)(`p`,{className:`app-notice__body`,children:[`A newer version was saved, so `,o+i.structure.length===1?`your last edit wasn’t`:`your last ${y(o+i.structure.length,`edit`)} weren’t`,` saved. The form now shows the newer version.`]}),o>0?(0,U.jsxs)(`ul`,{className:`app-notice__list`,children:[i.edits.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`b`,{children:$(t,a,e.path)}),` `,(0,U.jsx)(`span`,{className:`g-muted`,children:bt(e.value)})]},e.path.join(`.`))),i.body===null?null:(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`b`,{children:`Main text`}),` `,(0,U.jsx)(`span`,{className:`g-muted`,children:`your changes`})]})]}):null,i.structure.length>0?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`app-notice__body`,children:`These can’t be put back, because the sections and items have changed since. Make them again if you still want them:`}),(0,U.jsx)(`ul`,{className:`app-notice__list`,children:i.structure.map((e,n)=>(0,U.jsx)(`li`,{children:St(t,e)},n))})]}):null,(0,U.jsxs)(`div`,{className:`app-notice__actions`,children:[o>0?(0,U.jsx)(S,{size:`sm`,variant:`primary`,onClick:()=>r.actions.reapply(),children:`Put my edits back`}):null,(0,U.jsx)(S,{size:`sm`,variant:`quiet`,onClick:()=>r.actions.dismissConflict(),children:o>0?`Keep the newer version`:`Dismiss`})]})]})]})}function wt(){let{store:e}=X(),t=Z(e=>e.saveError);return t?(0,U.jsx)(a,{compact:!0,title:`Couldn’t save your last edit`,error:t,message:`Your edit is still in the form. Check that the app’s server is running, then try again.`,onRetry:()=>e.actions.retry(),className:`app-notice-error`}):null}var Tt={agent:`The assistant changed this page. The form shows its edits.`,external:`This page changed outside the app. The form shows the latest version.`},Et=9e3;function Dt(){let t=Z(e=>e.outside),[n,r]=(0,K.useState)(!1);return(0,K.useEffect)(()=>{if(!t)return;r(!0);let e=setTimeout(()=>r(!1),Et);return()=>clearTimeout(e)},[t]),!t||!n?null:(0,U.jsxs)(`p`,{className:`g-margin-note app-outside`,role:`status`,children:[(0,U.jsx)(e,{kind:`transpose`}),(0,U.jsx)(`span`,{children:t.origin===`agent`?Tt.agent:Tt.external})]})}function Ot({own:e,origin:t}){return e?null:t===`agent`||t===`external`?t:null}export{_e as C,W as E,ve as S,G as T,xe as _,$ as a,ge as b,gt as c,Oe as d,Pe as f,Se as g,we as h,wt as i,mt as l,Ce as m,Ct as n,vt as o,he as p,Dt as r,ht as s,Ot as t,Re as u,X as v,me as w,ye as x,Z as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as e,Ft as t,Nt as n,bt as r,o as i,pt as a,s as o}from"./ui-C6O2tW4c.js";import{a as s,t as c}from"./MediaLibraryPane-
|
|
1
|
+
import{F as e,Ft as t,Nt as n,bt as r,o as i,pt as a,s as o}from"./ui-C6O2tW4c.js";import{a as s,t as c}from"./MediaLibraryPane-D5J9z7rw.js";var l=t(n(),1),u=r(),d=[{id:`library`,label:`From media`},{id:`generate`,label:`Generate`}];function f({siteId:t,open:n,onClose:r,onPick:f}){let[p,m]=(0,l.useState)(`library`),[h,g]=(0,l.useState)(null);(0,l.useEffect)(()=>{n&&g(null)},[n]);let _=e=>{e&&(f(e.url),r())};return(0,u.jsxs)(e,{open:n,onClose:r,title:`Choose an image`,size:`xl`,className:`app-picker`,footer:(0,u.jsxs)(u.Fragment,{children:[h&&p===`library`?(0,u.jsx)(`span`,{className:`app-dialog__hint g-mono`,title:h.path,children:h.url}):null,(0,u.jsx)(a,{variant:`secondary`,onClick:r,children:`Keep editing`}),p===`library`?(0,u.jsx)(a,{variant:`primary`,disabled:!h,onClick:()=>_(h),children:`Use image`}):null]}),children:[(0,u.jsx)(o,{label:`Where the image comes from`,idBase:`picker`,items:d,value:p,onChange:m}),(0,u.jsx)(i,{idBase:`picker`,id:`library`,value:p,children:(0,u.jsx)(c,{siteId:t,kind:`image`,selected:h?.path??null,onSelect:g,onActivate:_,onGenerate:()=>m(`generate`),className:`app-picker__library`})}),(0,u.jsx)(i,{idBase:`picker`,id:`generate`,value:p,children:p===`generate`?(0,u.jsx)(s,{siteId:t,onSaved:e=>_(e)}):null})]})}function p(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function m(e){return e.map(String).join(`.`)}function h(e,t){let n=e;for(let e of t)if(Array.isArray(n)&&typeof e==`number`)n=n[e];else if(p(n)&&Object.hasOwn(n,String(e)))n=n[String(e)];else return;return n}function g(e,t){if(t.length===0)return e!==void 0;let n=h(e,t.slice(0,-1)),r=t[t.length-1];return Array.isArray(n)?typeof r==`number`&&r>=0&&r<n.length:p(n)&&Object.hasOwn(n,String(r))}function _(e,t,n){if(t.length===0)return n;let[r,...i]=t;if(Array.isArray(e)&&typeof r==`number`){let t=e[r],a=_(t,i,n);if(a===t&&r<e.length)return e;let o=e.slice();return o[r]=a,o}let a=p(e)?e:{},o=String(r),s=Object.hasOwn(a,o)?a[o]:void 0,c=_(s,i,n);return c===s&&Object.hasOwn(a,o)?a:{...a,[o]:c}}function v(e,t){if(t.length===0)return e;let n=t.slice(0,-1),r=h(e,n),i=t[t.length-1];if(!p(r)||!Object.hasOwn(r,String(i)))return e;let a={...r};return delete a[String(i)],_(e,n,a)}function y(e,t,n){let r=h(e,t);return _(e,t,n(Array.isArray(r)?r:[]))}function b(e,t){return t.length>e.length?!1:t.every((t,n)=>String(e[n])===String(t))}function x(e,t){return e.length===t.length&&b(e,t)}function S(e,t){if(e===t)return!0;if(typeof e!=typeof t||e===null||t===null||e===void 0||t===void 0)return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.every((e,n)=>S(e,t[n]));if(p(e)){if(!p(t))return!1;let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.hasOwn(t,n)&&S(e[n],t[n]))}return!1}function C(e,t){if(e===t||e===void 0)return t;if(Array.isArray(t)){if(!Array.isArray(e))return t;let n=e.length===t.length,r=t.map((t,r)=>{let i=C(e[r],t);return i!==e[r]&&(n=!1),i});return n?e:r}if(p(t)){if(!p(e))return t;let n=Object.keys(t),r=n.length===Object.keys(e).length,i={};for(let a of n){let n=Object.hasOwn(e,a)?e[a]:void 0,o=C(n,t[a]);o!==n&&(r=!1),i[a]=o}return r&&n.some((t,n)=>Object.keys(e)[n]!==t)&&(r=!1),r?e:i}return S(e,t)?e:t}export{m as a,C as c,y as d,f,p as i,b as l,h as n,x as o,g as r,_ as s,S as t,v as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Ft as e,Nt as t,n,z as r}from"./ui-C6O2tW4c.js";import{o as i,s as a}from"./chrome-Brnq5kGb.js";import{
|
|
1
|
+
import{Ft as e,Nt as t,n,z as r}from"./ui-C6O2tW4c.js";import{o as i,s as a}from"./chrome-Brnq5kGb.js";import{B as o}from"./index-CtsAxi5d.js";var s=e(t(),1),c=`galley.video-prefs`;function l(){try{let e=globalThis.localStorage?.getItem(c),t=e?JSON.parse(e):null;return t?.state?.provider?{provider:t.state.provider,model:t.state.model??null}:null}catch{return null}}async function u(e,t){let n=await r(`PATCH /api/settings`,{body:{videos:{provider:e,model:t}}});return i(o.settings(),n),n}function d(){let e=a(o.settings(),()=>r(`GET /api/settings`)),t=e.data?.videos,i=(0,s.useCallback)((e,t=null)=>{u(e,t).catch(e=>n({tone:`danger`,title:`Couldn’t save the video service`,body:e instanceof Error?e.message:void 0}))},[]);return(0,s.useEffect)(()=>{if(!e.data||!t||t.provider)return;let n=l();globalThis.localStorage?.removeItem(c),n&&u(n.provider,n.model).catch(()=>void 0)},[e.data,t]),{provider:t?.provider??null,model:t?.model??null,ready:e.data!==void 0||e.status===`error`,choose:i}}function f(e,t){return e.find(e=>e.id===t)??e.find(e=>e.configured)??e[0]}export{d as n,f as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./paths-
|
|
1
|
+
import{i as e}from"./paths-B6ATG9Kg.js";var t=new Set([`string`,`text`,`markdown`,`url`,`image`,`reference`,`date`,`datetime`]);function n(e){if(e.default!==void 0)return e.default;switch(e.type){case`number`:return 0;case`boolean`:return!1;case`tags`:return[];case`list`:return[];case`blocks`:return[];case`object`:return r(e.fields??[]);case`select`:return e.options?.[0]??``;case`json`:return null;default:return``}}function r(e){let t={};for(let r of e)r.required&&!r.hidden&&(t[r.key]=n(r));return t}function i(e){return e?e.type===`object`?r(e.fields??[]):e.type===`string`||e.type===`text`||e.type===`markdown`||e.type===`url`||e.type===`image`?``:n(e):``}function a(n,r){let i=r?.required??!1,a=r?.type;if(typeof n==`string`)return a===`select`||a===`color`?n:a===void 0||t.has(a)?i?``:void 0:n;if(typeof n==`number`||typeof n==`boolean`||n===null)return n;if(Array.isArray(n)){if(a===`tags`)return i?[]:void 0;let t=n[0];return t===void 0?i?[]:void 0:e(t)?[o(t,r?.of?.fields??[])]:i?[``]:void 0}return o(n,r?.fields??[])}function o(e,t,r=[]){let i={};for(let[n,o]of Object.entries(e)){if(r.includes(n)){i[n]=o;continue}let e=a(o,t.find(e=>e.key===n));e!==void 0&&(i[n]=e)}for(let e of t)e.required&&!e.hidden&&!Object.hasOwn(i,e.key)&&(i[e.key]=n(e));return i}function s(e,t){let n=o(e.example??{},e.fields,[t]);return{[t]:e.type,...Object.fromEntries(Object.entries(n).filter(([e])=>e!==t))}}export{n,i as r,s as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as e}from"./ui-C6O2tW4c.js";import{i as t,o as n,s as r}from"./chrome-Brnq5kGb.js";import{
|
|
1
|
+
import{z as e}from"./ui-C6O2tW4c.js";import{i as t,o as n,s as r}from"./chrome-Brnq5kGb.js";import{B as i}from"./index-CtsAxi5d.js";var a={name:`Galley`,tagline:`Prompt it. Proof it. Publish it.`,descriptor:`The AI CMS for static sites`,maker:`Fiction Tribe`,slug:`galley`,configFile:`galley.config.json`,commitTrailer:`Galley-Publish`,homeDir:`.galley`},o=`https://galley.fictiontribe.com`;`${o}${a.configFile}`,a.name,`${a.maker}`,`${o}`;var s=new Map;function c(t){let n=i.plugins(t);return s.set(JSON.stringify(n),n),r(n,()=>t?e(`GET /api/sites/:siteId/plugins`,{params:{siteId:t}}):e(`GET /api/plugins`),{...t?{deps:[i.site(t)]}:{}})}function l(e){for(let r of s.values()){let i=t(r).data;i&&i.plugins.some(t=>t.name===e.name)&&n(r,{...i,plugins:i.plugins.map(t=>t.name===e.name?{...e,...t.siteId&&!e.siteId?{siteId:t.siteId}:{}}:t)})}}async function u(t,n,r){let i=await e(`POST /api/plugins/enabled`,{body:{name:t.name,enabled:n,...r?{siteId:r}:{}}});return l(i),i}export{a as i,u as n,c as r,l as t};
|
package/dist/web/index.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<meta name="color-scheme" content="light dark" />
|
|
7
7
|
<title></title>
|
|
8
8
|
<script src="/theme.js"></script>
|
|
9
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
+
<script type="module" crossorigin src="/assets/index-CtsAxi5d.js"></script>
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/ui-C6O2tW4c.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/jobs-BHawhnH2.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/events-CTTFdOf-.js">
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<link rel="modulepreload" crossorigin href="/assets/changes-DLBkrfUR.js">
|
|
16
16
|
<link rel="modulepreload" crossorigin href="/assets/site-DJUEXLHW.js">
|
|
17
17
|
<link rel="modulepreload" crossorigin href="/assets/sites-CGDZymBT.js">
|
|
18
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
18
|
+
<link rel="stylesheet" crossorigin href="/assets/index-xTbHx1DQ.css">
|
|
19
19
|
</head>
|
|
20
20
|
<body class="g-root">
|
|
21
21
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "galley-cms",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Galley, the open-source AI CMS for
|
|
5
|
+
"description": "Galley, the open-source AI CMS for static sites: change a page, check it in Proof, publish it to your own git repository. Run `npx galley-cms` in a site's folder.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"cms",
|
|
8
8
|
"ai-cms",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"esbuild": "^0.28.0",
|
|
42
|
-
"@galley/
|
|
43
|
-
"@galley/
|
|
44
|
-
"@galley/
|
|
42
|
+
"@galley/server": "0.1.1",
|
|
43
|
+
"@galley/core": "0.1.1",
|
|
44
|
+
"@galley/mcp": "0.1.1"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "node build.mjs",
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{A as e,At as t,B as n,F as r,Ft as i,H as a,I as o,N as s,Nt as c,O as l,St as u,_ as d,bt as f,c as p,et as m,ft as h,g,gt as _,ht as v,it as y,j as b,jt as x,n as S,pt as C,v as w,vt as T,z as E}from"./ui-C6O2tW4c.js";import{a as D,n as O,o as k,s as A}from"./chrome-Brnq5kGb.js";import{C as ee,E as j,S as M,T as N,b as P,w as F,x as I,y as L}from"./index-Djh-DSIT.js";import{n as R}from"./ReachNote-CZYr1oL0.js";var z=i(c(),1),B=f();function V(e){return e.split(/[\n,]+/).map(e=>e.trim()).filter(Boolean)}function H({title:e,children:t,aside:n}){return(0,B.jsxs)(`section`,{className:`app-capture__section`,children:[(0,B.jsxs)(`header`,{className:`app-capture__head`,children:[(0,B.jsx)(`h3`,{className:`app-capture__title`,children:e}),n]}),t]})}function te({siteId:t,open:n,onClose:i,settings:o,forms:s}){let[c,u]=(0,z.useState)(``),[d,f]=(0,z.useState)({}),[m,h]=(0,z.useState)(``),[g,_]=(0,z.useState)(``),[v,y]=(0,z.useState)(``),[x,w]=(0,z.useState)(``),[T,D]=(0,z.useState)(``),[O,A]=(0,z.useState)(null),[ee,j]=(0,z.useState)(!1),[M,N]=(0,z.useState)(null);(0,z.useEffect)(()=>{n&&(u(o.origins.extra.join(`
|
|
2
|
-
`)),f(Object.fromEntries(s.map(e=>[e.id,(o.notify[e.id]??[]).join(`, `)]))),h(String(o.rateLimits.perIpPerMinute)),_(String(o.rateLimits.perFormPerMinute)),y(``),A(null),N(null))},[n]);let P=async(e,n)=>{j(!0),N(null);try{let r=await E(`PATCH /api/sites/:siteId/capture`,{params:{siteId:t},body:e});return k(L.capture(t),r),n&&S({tone:`success`,title:n}),!0}catch(e){return N(a(e).message),!1}finally{j(!1)}},F=async()=>{let e=Object.fromEntries(Object.entries(d).map(([e,t])=>[e,V(t)]));await P({extraOrigins:V(c),notify:e,rateLimits:{perIpPerMinute:Number(m),perFormPerMinute:Number(g)}},`Capture settings saved`)&&i()},I=async e=>{try{let n=await E(`POST /api/sites/:siteId/capture/key`,{params:{siteId:t},body:{action:e}});k(L.capture(t),n.settings),A(n.key)}catch(e){N(a(e).message)}};return(0,B.jsx)(r,{open:n,onClose:i,size:`lg`,title:`Capture settings`,description:`How this site’s forms reach the inbox. Kept by this app, not published with the site.`,footer:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(C,{variant:`secondary`,onClick:i,children:`Keep as it was`}),(0,B.jsx)(C,{variant:`primary`,busy:ee,busyLabel:`Saving…`,onClick:()=>void F(),children:`Save settings`})]}),children:(0,B.jsxs)(`div`,{className:`app-capture`,children:[M?(0,B.jsx)(`p`,{className:`g-error-text`,role:`alert`,children:M}):null,(0,B.jsx)(H,{title:`Capture address`,children:(0,B.jsx)(R,{settings:o})}),(0,B.jsxs)(H,{title:`Who can send`,children:[(0,B.jsxs)(`p`,{className:`app-capture__text`,children:[o.origins.site.length?(0,B.jsxs)(B.Fragment,{children:[`The site’s own addresses: `,(0,B.jsx)(`span`,{className:`g-mono`,children:o.origins.site.join(`, `)}),`.`]}):`The site has no live or staging address in its settings yet, so only the addresses below can send.`,o.origins.loopback?` Previews on this computer can send too.`:``]}),(0,B.jsx)(b,{label:`Other addresses allowed to send`,hint:`One per line, like https://landing.example.com`,children:(0,B.jsx)(e,{value:c,onChange:e=>u(e.target.value),rows:2,mono:!0})})]}),(0,B.jsxs)(H,{title:`E-mail alerts`,aside:o.mail.configured?(0,B.jsx)(p,{tone:`success`,children:`Mail is set up`}):(0,B.jsx)(p,{tone:`warning`,children:`No mail settings`}),children:[o.mail.configured?(0,B.jsxs)(`p`,{className:`app-capture__text`,children:[`Alerts are sent from `,o.mail.from,`.`]}):(0,B.jsxs)(`p`,{className:`app-capture__text app-capture__text--warning`,children:[`No e-mail can be sent yet: this server has no mail settings. Whoever runs it sets `,(0,B.jsx)(`span`,{className:`g-mono`,children:`GALLEY_SMTP_URL`}),` and `,(0,B.jsx)(`span`,{className:`g-mono`,children:`GALLEY_MAIL_FROM`}),`. Addresses saved here are kept until then.`,o.mail.problem?` ${o.mail.problem}`:``]}),s.length===0?(0,B.jsx)(`p`,{className:`app-capture__text`,children:`Add a form to choose who hears about it.`}):null,s.map(e=>(0,B.jsx)(b,{label:e.name,hint:`E-mail addresses, separated by commas`,children:(0,B.jsx)(l,{value:d[e.id]??``,onChange:t=>f({...d,[e.id]:t.target.value}),placeholder:`team@example.com`})},e.id))]}),(0,B.jsxs)(H,{title:`Spam protection`,children:[(0,B.jsx)(`p`,{className:`app-capture__text`,children:`A hidden field and a minimum time catch most bots. What they catch goes to Spam, not away.`}),(0,B.jsxs)(`div`,{className:`app-capture__pair`,children:[(0,B.jsx)(b,{label:`Per visitor, each minute`,children:(0,B.jsx)(l,{type:`number`,min:1,max:1e4,value:m,onChange:e=>h(e.target.value)})}),(0,B.jsx)(b,{label:`Per form, each minute`,children:(0,B.jsx)(l,{type:`number`,min:1,max:1e4,value:g,onChange:e=>_(e.target.value)})})]}),(0,B.jsx)(b,{label:`Cloudflare Turnstile secret key`,hint:o.turnstile.configured?`Set, ending in ${o.turnstile.hint}. Forms with a Turnstile site key are checked with it.`:`Only for forms that show the Turnstile check. Its site key goes in the form; the secret goes here.`,aside:o.turnstile.configured?(0,B.jsx)(C,{size:`sm`,variant:`quiet`,onClick:()=>void P({turnstileSecret:null},`Turnstile secret removed`),children:`Remove`}):null,children:(0,B.jsxs)(`div`,{className:`app-capture__inline`,children:[(0,B.jsx)(l,{type:`password`,autoComplete:`off`,value:v,onChange:e=>y(e.target.value),placeholder:o.turnstile.configured?`Paste a new one to replace it`:`0x4AAAA…`}),(0,B.jsx)(C,{size:`sm`,variant:`secondary`,disabled:!v.trim(),onClick:()=>void P({turnstileSecret:v.trim()},`Turnstile secret saved`).then(e=>e&&y(``)),children:`Save secret`})]})})]}),(0,B.jsxs)(H,{title:`Sending from another server`,aside:o.captureKey.enabled?(0,B.jsx)(p,{tone:`success`,children:`Key on`}):(0,B.jsx)(p,{children:`Off`}),children:[(0,B.jsxs)(`p`,{className:`app-capture__text`,children:[`Browsers always say which site they’re on, and only this site’s addresses are let in. A program on a server says nothing, so it needs a key, sent as the `,(0,B.jsx)(`span`,{className:`g-mono`,children:`X-Capture-Key`}),` header.`]}),O?(0,B.jsxs)(`div`,{className:`app-capture__key`,role:`status`,children:[(0,B.jsx)(`p`,{children:`Copy this key now. It isn’t shown again.`}),(0,B.jsx)(`code`,{className:`g-mono`,children:O}),(0,B.jsx)(C,{size:`sm`,variant:`secondary`,icon:`copy`,onClick:()=>void navigator.clipboard?.writeText(O),children:`Copy`})]}):o.captureKey.enabled?(0,B.jsxs)(`p`,{className:`app-capture__text`,children:[`A key ending in `,o.captureKey.hint,` is in use.`]}):null,(0,B.jsxs)(`div`,{className:`app-capture__inline`,children:[(0,B.jsx)(C,{size:`sm`,variant:`secondary`,icon:`key`,onClick:()=>void I(`rotate`),children:o.captureKey.enabled?`Make a new key`:`Turn on with a key`}),o.captureKey.enabled?(0,B.jsx)(C,{size:`sm`,variant:`quiet`,onClick:()=>void I(`remove`),children:`Turn off`}):null]})]}),(0,B.jsxs)(H,{title:`Forwarding secrets`,children:[(0,B.jsxs)(`p`,{className:`app-capture__text`,children:[`Values a server-side destination uses without them being in the site’s files: write `,(0,B.jsx)(`span`,{className:`g-mono`,children:`{{secret:name}}`}),` in its address or a header.`]}),o.forwardSecrets.length?(0,B.jsx)(`ul`,{className:`app-capture__secrets`,children:o.forwardSecrets.map(e=>(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`span`,{className:`g-mono`,children:e}),(0,B.jsx)(p,{tone:`success`,children:`Set`}),(0,B.jsx)(C,{size:`sm`,variant:`quiet`,onClick:()=>void P({forwardSecrets:{[e]:null}},`Secret removed`),children:`Remove`})]},e))}):null,(0,B.jsxs)(`div`,{className:`app-capture__inline`,children:[(0,B.jsx)(l,{size:`sm`,mono:!0,value:x,onChange:e=>w(e.target.value.toLowerCase()),placeholder:`name`,"aria-label":`Secret name`}),(0,B.jsx)(l,{size:`sm`,type:`password`,autoComplete:`off`,value:T,onChange:e=>D(e.target.value),placeholder:`value`,"aria-label":`Secret value`}),(0,B.jsx)(C,{size:`sm`,variant:`secondary`,disabled:!x.trim()||!T,onClick:()=>void P({forwardSecrets:{[x.trim()]:T}},`Secret saved`).then(e=>{e&&(w(``),D(``))}),children:`Add secret`})]})]})]})})}var ne=50,U={honeypot:`Filled in the hidden field bots fill in`,"too-fast":`Sent faster than a person could`,turnstile:`Didn’t pass the Turnstile check`,marked:`Marked as spam`};function W(e){return e===`email`?`E-mail alert`:e===`webhook`?`Webhook`:e.charAt(0).toUpperCase()+e.slice(1)}function re({forms:e,current:t,onPick:n}){return(0,B.jsxs)(`nav`,{className:`app-inbox__forms`,"aria-label":`Forms`,children:[(0,B.jsx)(`p`,{className:`g-eyebrow app-inbox__eyebrow`,children:`Forms`}),(0,B.jsx)(`ul`,{children:e.map(e=>(0,B.jsx)(`li`,{children:(0,B.jsxs)(`button`,{type:`button`,className:`app-inbox__form`,"aria-current":e.id===t?`true`:void 0,onClick:()=>n(e.id),children:[(0,B.jsx)(`span`,{className:`app-inbox__form-name`,children:e.name}),(0,B.jsxs)(`span`,{className:`app-inbox__form-meta`,children:[e.unread>0?(0,B.jsx)(p,{tone:`accent`,mark:null,children:`${e.unread} new`}):null,(0,B.jsx)(`span`,{className:`g-faint`,"aria-label":y(e.total,`submission`),children:e.total.toLocaleString()})]}),e.capturing?null:(0,B.jsx)(`span`,{className:`app-inbox__form-note`,children:e.problem??`Sends elsewhere, not here`})]})},e.id))})]})}function ie({siteId:e,settings:t}){return(0,B.jsxs)(`div`,{className:`app-screen__inner`,children:[(0,B.jsx)(s,{title:`No forms yet.`,body:`Forms on the site send what visitors write here, with an e-mail alert if you like. Build one to start.`,actions:(0,B.jsx)(u,{to:`/sites/${e}/forms`,className:v(`primary`,`md`),children:`Build a form`}),mark:`pilcrow`}),t?(0,B.jsx)(`div`,{className:`app-inbox__reach`,children:(0,B.jsx)(R,{settings:t})}):null]})}function ae({siteId:e,form:t,settings:n}){let r=(0,z.useRef)(Date.now()),[i,a]=(0,z.useState)(!1),[o,c]=(0,z.useState)(null);if(!t.capturing)return(0,B.jsx)(s,{compact:!0,title:`This form sends elsewhere.`,body:t.problem??`Its submissions go to another service, so they don’t arrive here. Add the inbox as one of its destinations to keep a copy here too.`,actions:(0,B.jsx)(u,{to:`/sites/${e}/forms`,className:v(`secondary`,`md`),children:`Open the form builder`})});let l=async()=>{if(!n||!t.definition)return;a(!0);let i=await P(n,t.id,t.definition,r.current);a(!1),i.ok?S({tone:`success`,title:`Test submission received`,body:`It’s at the top of the list, marked Test.`}):c(i),D(L.all(e))};return(0,B.jsxs)(`div`,{className:`app-inbox__first`,children:[(0,B.jsx)(s,{compact:!0,title:`Nothing here yet.`,body:`When someone sends “${t.name}”, it arrives here first.`}),n?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(R,{settings:n}),(0,B.jsxs)(`div`,{className:`app-inbox__test`,children:[(0,B.jsx)(C,{variant:`secondary`,icon:`play`,busy:i,busyLabel:`Sending…`,onClick:()=>void l(),disabled:!t.definition,children:`Send a test submission`}),(0,B.jsxs)(`span`,{className:`g-faint`,children:[`It goes through the same checks as a visitor’s`,n.turnstile.configured&&t.definition?.spam?.turnstileSiteKey?` and lands in Spam, because a test can’t pass the Turnstile check`:``,`.`]})]}),o?(0,B.jsxs)(`div`,{className:_(`app-inbox__outcome`,o.ok?`app-inbox__outcome--ok`:`app-inbox__outcome--bad`),role:`status`,children:[(0,B.jsx)(`p`,{children:o.message}),o.errors?(0,B.jsx)(`ul`,{children:Object.entries(o.errors).map(([e,t])=>(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`span`,{className:`g-mono`,children:e}),` — `,t]},e))}):null]}):null]}):null]})}function oe({item:e,form:t,selected:n,checked:r,fresh:i,onOpen:a,onCheck:o}){let s=j(t.definition,e),[c,...l]=s.length?s:[`(no answers)`];return(0,B.jsxs)(`li`,{className:_(`app-inbox__row`,!e.read&&!e.spam&&`app-inbox__row--unread`,i&&`app-inbox__row--new`),"aria-current":n?`true`:void 0,children:[(0,B.jsx)(`input`,{type:`checkbox`,className:`app-inbox__check`,checked:r,onChange:e=>o(e.target.checked),"aria-label":`Select ${c}`}),(0,B.jsxs)(`button`,{type:`button`,className:`app-inbox__open`,onClick:a,children:[(0,B.jsxs)(`span`,{className:`app-inbox__line`,children:[(0,B.jsx)(`span`,{className:`app-inbox__who`,children:c}),(0,B.jsx)(`time`,{className:`app-inbox__time`,dateTime:e.at,title:m(e.at),children:h(e.at)})]}),(0,B.jsxs)(`span`,{className:`app-inbox__rest`,children:[l.join(` · `)||`\xA0`,e.test?(0,B.jsx)(p,{mark:null,children:`Test`}):null,e.delivery?.some(e=>!e.ok)?(0,B.jsx)(p,{tone:`warning`,children:`Not sent on`}):null]})]}),!e.read&&!e.spam?(0,B.jsx)(`span`,{className:`g-sr`,children:`Unread`}):null]})}function se({siteId:e,form:t,submission:n,onChanged:r,onDelete:i}){let o=N(t.definition,n),s=F(t.definition,n),[c,l]=(0,z.useState)(null),u=j(t.definition,n,1)[0]??`Submission`,d=async(i,o)=>{try{await E(`PATCH /api/sites/:siteId/inbox/:formId`,{params:{siteId:e,formId:t.id},body:{ids:[n.id],...i}}),S({tone:`success`,title:o}),r()}catch(e){let t=a(e);S({tone:`danger`,title:`Couldn’t change that`,body:t.message,detail:t.detail})}},f=async i=>{l(String(i));try{let a=(await E(`POST /api/sites/:siteId/inbox/:formId/:submissionId/retry`,{params:{siteId:e,formId:t.id,submissionId:n.id},body:{destination:i}})).delivery?.find(e=>i===`email`?e.provider===`email`:e.destination===i);S(a?.ok?{tone:`success`,title:`Sent`}:{tone:`warning`,title:`Still not sent`,body:a?.detail}),r()}catch(e){let t=a(e);S({tone:`danger`,title:`Couldn’t send it again`,body:t.message,detail:t.detail})}finally{l(null)}};return(0,B.jsxs)(`article`,{className:`app-inbox__detail`,"aria-label":`Submission from ${u}`,children:[(0,B.jsxs)(`header`,{className:`app-inbox__detail-head`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h2`,{className:`app-inbox__detail-title`,children:u}),(0,B.jsxs)(`p`,{className:`app-inbox__detail-meta`,children:[(0,B.jsx)(`time`,{dateTime:n.at,children:m(n.at)}),n.test?(0,B.jsx)(p,{mark:null,children:`Test`}):null,n.spam?(0,B.jsx)(p,{tone:`danger`,children:`Spam`}):null]})]}),(0,B.jsxs)(`div`,{className:`app-inbox__detail-actions`,children:[(0,B.jsx)(C,{size:`sm`,variant:`quiet`,onClick:()=>void d({read:!n.read},n.read?`Marked unread`:`Marked read`),children:n.read?`Mark unread`:`Mark read`}),(0,B.jsx)(C,{size:`sm`,variant:`quiet`,onClick:()=>void d({spam:!n.spam},n.spam?`Moved to the inbox`:`Moved to Spam`),children:n.spam?`Not spam`:`Spam`}),(0,B.jsx)(C,{size:`sm`,variant:`danger-quiet`,icon:`trash`,onClick:()=>i([n]),children:`Delete`})]})]}),n.spam&&n.spamReason?(0,B.jsxs)(`p`,{className:`app-inbox__spam-note`,children:[U[n.spamReason]??`Caught by the spam checks`,`. Real ones can be moved back with “Not spam”.`]}):null,(0,B.jsxs)(`dl`,{className:`app-inbox__answers`,children:[o.map(e=>(0,B.jsxs)(`div`,{className:`app-inbox__answer`,children:[(0,B.jsx)(`dt`,{children:e.label}),(0,B.jsx)(`dd`,{className:e.type===`textarea`?`app-inbox__long`:void 0,children:e.type===`email`?(0,B.jsx)(`a`,{href:`mailto:${e.value}`,children:e.value}):e.value})]},e.id)),o.length===0?(0,B.jsx)(`p`,{className:`g-faint`,children:`No answers were sent.`}):null]}),n.page?.url||n.page?.referrer?(0,B.jsxs)(`section`,{className:`app-inbox__section`,children:[(0,B.jsx)(`h3`,{className:`g-eyebrow`,children:`Sent from`}),n.page.url?(0,B.jsxs)(`p`,{children:[(0,B.jsx)(`a`,{href:n.page.url,target:`_blank`,rel:`noreferrer noopener`,children:n.page.title||n.page.url}),n.page.title?(0,B.jsx)(`span`,{className:`g-faint g-mono app-inbox__url`,children:n.page.url}):null]}):null,n.page.referrer?(0,B.jsxs)(`p`,{className:`g-faint`,children:[`Came from `,n.page.referrer]}):null]}):null,s.length?(0,B.jsxs)(`section`,{className:`app-inbox__section`,children:[(0,B.jsx)(`h3`,{className:`g-eyebrow`,children:`How they arrived`}),(0,B.jsx)(`dl`,{className:`app-inbox__utm`,children:s.map(e=>(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{children:e.label}),(0,B.jsx)(`dd`,{children:e.value})]},e.label))})]}):null,n.delivery?.length?(0,B.jsxs)(`section`,{className:`app-inbox__section`,children:[(0,B.jsx)(`h3`,{className:`g-eyebrow`,children:`Sent on`}),(0,B.jsx)(`ul`,{className:`app-inbox__delivery`,children:n.delivery.map(e=>{let t=e.provider===`email`?`email`:String(e.destination??``);return(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`span`,{className:`app-inbox__delivery-name`,children:W(e.provider)}),e.ok?(0,B.jsx)(p,{tone:`success`,children:`Sent`}):(0,B.jsx)(p,{tone:`danger`,children:`Not sent`}),(0,B.jsxs)(`span`,{className:`g-faint app-inbox__delivery-detail`,children:[e.detail,e.attempts&&e.attempts>1?` ${y(e.attempts,`try`,`tries`)}.`:``]}),(0,B.jsx)(C,{size:`sm`,variant:`quiet`,icon:`refresh`,busy:c===t,busyLabel:`Sending…`,onClick:()=>void f(e.provider===`email`?`email`:e.destination??0),children:e.ok?`Send again`:`Retry`})]},`${e.provider}-${e.destination??`x`}`)})})]}):null]})}function G(){let{siteId:e=``}=t(),[r,i]=x();O({crumbs:[{label:`Inbox`}]});let c=ee(e),u=I(e),f=M(e),[p,m]=(0,z.useState)(`inbox`),[h,_]=(0,z.useState)(``),[b,k]=(0,z.useState)(``),[j,N]=(0,z.useState)(1),[P,F]=(0,z.useState)(new Set),[V,H]=(0,z.useState)(!1),U=c.data?.forms??[],W=r.get(`form`)??U[0]?.id??null,G=U.find(e=>e.id===W)??null,K=r.get(`id`);(0,z.useEffect)(()=>{let e=window.setTimeout(()=>k(h.trim()),200);return()=>window.clearTimeout(e)},[h]),(0,z.useEffect)(()=>{F(new Set),N(1)},[W,p,b]);let q=A(L.list(e,W??``,p,b,j),()=>E(`GET /api/sites/:siteId/inbox/:formId`,{params:{siteId:e,formId:W??``},query:{filter:p,...b?{q:b}:{},limit:ne*j}}),{enabled:!!W}),J=q.data?.items??[],ce=(0,z.useMemo)(()=>J.find(e=>e.id===K)??null,[J,K]),Y=!!(W&&K&&!ce&&q.data),le=A(Y?[`site`,e,`inbox`,`one`,W??``,K??``]:[`inbox-one-idle`],()=>Y?E(`GET /api/sites/:siteId/inbox/:formId/:submissionId`,{params:{siteId:e,formId:W??``,submissionId:K??``}}):Promise.resolve(null),{enabled:Y}),X=ce??le.data??null;(0,z.useEffect)(()=>{X&&!X.read&&!X.spam&&W&&E(`PATCH /api/sites/:siteId/inbox/:formId`,{params:{siteId:e,formId:W},body:{ids:[X.id],read:!0}}).then(()=>D(L.all(e))).catch(()=>void 0)},[X?.id,X?.read,X?.spam,W,e]);let Z=e=>{let t=new URLSearchParams(r);e.form!==void 0&&(t.set(`form`,e.form),t.delete(`id`)),e.id===null?t.delete(`id`):e.id&&t.set(`id`,e.id),i(t,{replace:!0})},Q=()=>D(L.all(e)),ue=async t=>{if(W&&t.length){K&&t.some(e=>e.id===K)&&Z({id:null});try{let{deleted:n}=await E(`POST /api/sites/:siteId/inbox/:formId/delete`,{params:{siteId:e,formId:W},body:{ids:t.map(e=>e.id)}});F(new Set),Q(),S({tone:`neutral`,title:`Deleted ${y(n.length,`submission`)}`,body:`They’re gone from this app’s files.`,action:{label:`Undo`,onClick:()=>void E(`POST /api/sites/:siteId/inbox/:formId/restore`,{params:{siteId:e,formId:W},body:{submissions:n}}).then(()=>{Q(),S({tone:`success`,title:`Restored ${y(n.length,`submission`)}`})}).catch(e=>S({tone:`danger`,title:`Couldn’t restore them`,body:a(e).message}))}})}catch(e){let t=a(e);S({tone:`danger`,title:`Couldn’t delete`,body:`${t.message} Nothing was removed.`,detail:t.detail})}}},de=async(t,n)=>{if(W&&P.size)try{await E(`PATCH /api/sites/:siteId/inbox/:formId`,{params:{siteId:e,formId:W},body:{ids:[...P],...t}}),F(new Set),Q(),S({tone:`success`,title:n})}catch(e){S({tone:`danger`,title:`Couldn’t change them`,body:a(e).message})}},fe=W?n(`GET /api/sites/:siteId/inbox/:formId/export`,{siteId:e,formId:W},{filter:p}):null,pe=(0,B.jsx)(w,{title:`Inbox`,description:`What visitors send through the site’s forms. Kept by this app, not published with the site.`,actions:(0,B.jsxs)(B.Fragment,{children:[fe&&G&&G.total+G.spam>0?(0,B.jsxs)(`a`,{href:fe,download:!0,className:v(`secondary`,`md`),children:[(0,B.jsx)(T,{name:`download`}),`Export`]}):null,(0,B.jsx)(C,{variant:`secondary`,icon:`settings`,disabled:!u.data,onClick:()=>H(!0),children:`Capture settings…`})]})});if(c.loading)return(0,B.jsx)(`div`,{className:`app-screen`,children:(0,B.jsxs)(`div`,{className:`app-screen__inner app-screen__inner--wide`,"aria-busy":`true`,children:[(0,B.jsx)(g,{width:160,height:28}),(0,B.jsx)(g,{lines:6,style:{marginBlockStart:24}})]})});if(c.status===`error`&&!c.data)return(0,B.jsx)(`div`,{className:`app-screen`,children:(0,B.jsx)(o,{title:`Couldn’t open the inbox`,error:c.error,onRetry:()=>void c.refetch()})});if(!U.length)return(0,B.jsxs)(`div`,{className:`app-screen`,children:[(0,B.jsx)(`div`,{className:`app-screen__inner app-screen__inner--wide`,children:pe}),(0,B.jsx)(ie,{siteId:e,settings:u.data})]});let me=J.length>0&&J.every(e=>P.has(e.id)),$=G&&G.total===0&&G.spam===0&&!b,he;return he=G?$?(0,B.jsx)(ae,{siteId:e,form:G,settings:u.data}):q.loading?(0,B.jsx)(g,{lines:8}):q.status===`error`&&!q.data?(0,B.jsx)(o,{compact:!0,title:`Couldn’t load the submissions`,error:q.error,onRetry:()=>void q.refetch()}):J.length?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`app-inbox__bulk`,children:[(0,B.jsx)(`input`,{type:`checkbox`,className:`app-inbox__check`,checked:me,onChange:e=>F(e.target.checked?new Set(J.map(e=>e.id)):new Set),"aria-label":`Select all shown`}),P.size?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`app-inbox__bulk-count`,children:y(P.size,`selected`,`selected`)}),(0,B.jsx)(C,{size:`sm`,variant:`quiet`,onClick:()=>void de({read:!0},`Marked read`),children:`Mark read`}),(0,B.jsx)(C,{size:`sm`,variant:`quiet`,onClick:()=>void de(p===`spam`?{spam:!1}:{spam:!0},p===`spam`?`Moved to the inbox`:`Moved to Spam`),children:p===`spam`?`Not spam`:`Spam`}),(0,B.jsx)(C,{size:`sm`,variant:`danger-quiet`,icon:`trash`,onClick:()=>void ue(J.filter(e=>P.has(e.id))),children:`Delete ${P.size}`})]}):(0,B.jsx)(`span`,{className:`g-faint`,children:y(q.data?.total??0,p===`spam`?`spam submission`:`submission`)})]}),(0,B.jsx)(`ul`,{className:`app-inbox__rows`,children:J.map(e=>(0,B.jsx)(oe,{item:e,form:G,selected:e.id===X?.id,checked:P.has(e.id),fresh:f.has(e.id),onOpen:()=>Z({id:e.id}),onCheck:t=>F(n=>t?new Set([...n,e.id]):new Set([...n].filter(t=>t!==e.id)))},e.id))}),(q.data?.total??0)>J.length?(0,B.jsx)(C,{variant:`quiet`,block:!0,onClick:()=>N(j+1),children:`Show more`}):null]}):b?(0,B.jsx)(s,{compact:!0,title:`Nothing mentions “${b}”.`,body:`Try a shorter word, or look in Spam.`}):p===`spam`?(0,B.jsx)(s,{compact:!0,title:`No spam.`,body:`Submissions the spam checks catch land here, so you can rescue a real one.`}):p===`unread`?(0,B.jsx)(s,{compact:!0,title:`All read.`,body:`New submissions show up here until you open them.`}):(0,B.jsx)(s,{compact:!0,title:`Nothing in the inbox.`,body:`Everything for this form is in Spam.`}):null,(0,B.jsxs)(`div`,{className:`app-screen app-inbox-screen`,children:[(0,B.jsxs)(`div`,{className:`app-screen__inner app-screen__inner--wide app-inbox-wrap`,children:[pe,u.data&&!u.data.captureReachable&&!$?(0,B.jsx)(`div`,{className:`app-inbox__reach`,children:(0,B.jsx)(R,{settings:u.data,compact:!0})}):null,(0,B.jsxs)(`div`,{className:`app-inbox`,children:[(0,B.jsx)(re,{forms:U,current:W,onPick:e=>Z({form:e})}),(0,B.jsxs)(`section`,{className:`app-inbox__list`,"aria-label":G?`Submissions to ${G.name}`:`Submissions`,children:[$?null:(0,B.jsxs)(`div`,{className:`app-inbox__tools`,children:[(0,B.jsx)(l,{size:`sm`,type:`search`,value:h,onChange:e=>_(e.target.value),placeholder:`Search answers…`,"aria-label":`Search answers`}),(0,B.jsx)(d,{label:`Show`,value:p,onChange:e=>m(e),options:[{value:`inbox`,label:`All`},{value:`unread`,label:G?.unread?`Unread ${G.unread}`:`Unread`},{value:`spam`,label:G?.spam?`Spam ${G.spam}`:`Spam`}]})]}),he]}),(0,B.jsx)(`section`,{className:`app-inbox__pane`,"aria-label":`Submission`,children:G&&X?(0,B.jsx)(se,{siteId:e,form:G,submission:X,onChanged:Q,onDelete:e=>void ue(e)}):(0,B.jsx)(`div`,{className:`app-inbox__placeholder`,children:(0,B.jsx)(`p`,{className:`g-faint`,children:$?`A submission opens here.`:`Choose a submission to read it in full.`})})})]})]}),u.data?(0,B.jsx)(te,{siteId:e,open:V,onClose:()=>H(!1),settings:u.data,forms:U}):null]})}export{G as InboxScreen};
|
|
@@ -1 +0,0 @@
|
|
|
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{a as w,c as T,d as E,f as D,h as O,i as k,l as A,m as j,n as M,o as N,r as P,s as F,u as I,z as L}from"./index-Djh-DSIT.js";var R=t(a(),1),z=c(),B=`Putting the published version live`;function V({siteId:e,variant:t=`home`,listLink:i=!0}){let a=N(e),c=F(),l=a.data,u=j(l,a.job),m=l?.config,[v,y]=(0,R.useState)(null);return a.loading?(0,z.jsx)(f,{height:120}):l?(0,z.jsx)(`div`,{className:`app-card app-card--pad deploy-card`,children:m?(0,z.jsxs)(z.Fragment,{children:[l.production?(0,z.jsxs)(`a`,{className:`deploy-card__address`,href:l.production.url,target:`_blank`,rel:`noopener noreferrer`,children:[D(l.production.url),(0,z.jsx)(b,{name:`external`})]}):null,(0,z.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,z.jsx)(I,{job:a.job,intent:a.job.label.startsWith(`Making`)?`preview`:`production`}):null,(0,z.jsxs)(`p`,{className:`g-hint`,children:[`On `,O(c.data,m.target),` · project `,(0,z.jsx)(`span`,{className:`g-mono`,children:m.project})]}),(0,z.jsxs)(`div`,{className:`deploy-card__actions`,children:[l.behind!==0||!l.production?(0,z.jsx)(_,{variant:`primary`,size:`sm`,disabled:a.job?.state===`running`,onClick:()=>void M(e),children:`Put live`}):null,l.production?(0,z.jsx)(h,{icon:`copy`,label:`Copy the address`,onClick:()=>E(l.production.url)}):null,t===`home`?(0,z.jsx)(P,{siteId:e}):null,i?(0,z.jsx)(o,{className:p(`quiet`,`sm`),to:`/sites/${e}/online`,children:`Deployments`}):null]}),t===`settings`?(0,z.jsxs)(`div`,{className:`deploy-card__settings`,children:[(0,z.jsx)(s,{checked:v??!!m.autoDeploy,onChange:t=>{y(t),w(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,z.jsx)(_,{variant:`quiet`,size:`sm`,onClick:()=>T.getState().openSetup(),children:`Change host or project…`})]}):null]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.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,z.jsx)(`div`,{className:`deploy-card__actions`,children:(0,z.jsx)(_,{variant:`primary`,size:`sm`,icon:`globe`,onClick:()=>T.getState().openSetup(),children:`Put this site online`})})]})}):(0,z.jsx)(r,{compact:!0,title:`Couldn’t check whether the site is online`,error:a.error,onRetry:()=>void a.refetch()})}function H(){let{siteId:t=``}=e(),n=N(t),r=n.data;return r?r.config?n.job?.state===`running`?(0,z.jsx)(l,{tone:`info`,children:`Putting it live…`}):r.production&&r.behind===0?(0,z.jsx)(l,{tone:`success`,children:`Live`}):(0,z.jsx)(_,{size:`sm`,variant:`secondary`,icon:`globe`,onClick:()=>void M(t),children:`Put live`}):(0,z.jsx)(_,{size:`sm`,variant:`quiet`,icon:`globe`,onClick:()=>T.getState().openSetup(),children:`Put this site online`}):null}function U({siteId:e}){let t=N(e),n=A(e),r=(0,R.useRef)(Date.now()),i=n&&(n.startedAt>=r.current||n.label===B&&n.startedAt>=r.current-3e4)?n:null,a=t.data?.config,[o,s]=(0,R.useState)(!1);return t.data?a?i?.state===`running`?(0,z.jsxs)(`div`,{className:`deploy-note deploy-note--stack`,"aria-live":`polite`,children:[(0,z.jsx)(`p`,{className:`deploy-note__title`,children:`Putting it live…`}),(0,z.jsx)(I,{job:i,intent:`production`})]}):i?.state===`done`&&i.url?(0,z.jsxs)(`p`,{className:`deploy-note`,role:`status`,children:[(0,z.jsx)(b,{name:`check`}),(0,z.jsxs)(`span`,{children:[`Live at`,` `,(0,z.jsx)(`a`,{className:`g-link`,href:i.url,target:`_blank`,rel:`noopener noreferrer`,children:D(i.url)}),`.`]})]}):i?.state===`error`?(0,z.jsx)(`p`,{className:`deploy-note deploy-note--danger`,role:`alert`,children:(0,z.jsxs)(`span`,{children:[`Published, but not live yet: `,i.detail]})}):a.autoDeploy?null:(0,z.jsxs)(`p`,{className:`deploy-note`,children:[(0,z.jsx)(`span`,{children:`Published here. The live site changes when you put it live.`}),(0,z.jsx)(`button`,{type:`button`,className:`app-link-button`,disabled:o,onClick:()=>{s(!0),r.current=Date.now()-1e3,M(e).finally(()=>s(!1))},children:o?`Starting…`:`Put live`})]}):(0,z.jsxs)(`p`,{className:`deploy-note`,children:[(0,z.jsx)(`span`,{children:`Want it at a real address?`}),(0,z.jsx)(`button`,{type:`button`,className:`app-link-button`,onClick:()=>T.getState().openSetup(),children:`Put this site online`})]}):null}function W({item:e,versions:t}){let n=e.commit?t.get(e.commit):void 0;return(0,z.jsxs)(`li`,{className:`deploy-row`,children:[(0,z.jsx)(l,{tone:e.kind===`production`?`success`:`info`,mark:null,children:e.kind===`production`?`Live`:`Preview`}),(0,z.jsxs)(`div`,{className:`deploy-row__main`,children:[(0,z.jsx)(`a`,{className:`deploy-row__address`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:D(e.url)}),(0,z.jsxs)(`p`,{className:`deploy-row__meta`,children:[e.label??(e.kind===`production`?n?`“${n}”`:`A published version`:`Unpublished changes`),(0,z.jsx)(`span`,{"aria-hidden":`true`,children:` · `}),(0,z.jsx)(`time`,{dateTime:e.createdAt,title:u(e.createdAt),children:d(e.createdAt)}),e.who?` · ${e.who}`:``,(0,z.jsx)(`span`,{"aria-hidden":`true`,children:` · `}),m(e.files,`file`),`, `,v(e.bytes)]})]}),(0,z.jsxs)(`div`,{className:`deploy-row__actions`,children:[(0,z.jsxs)(`a`,{className:p(`quiet`,`sm`),href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:[(0,z.jsx)(b,{name:`external`}),`Open`]}),(0,z.jsx)(h,{icon:`copy`,label:`Copy the address`,onClick:()=>E(e.url)})]})]})}function G(){let{siteId:t=``}=e();S({crumbs:[{label:`Online`}]});let n=C(k.deployments(t),()=>x(`GET /api/sites/:siteId/deployments`,{params:{siteId:t},query:{limit:50}})),a=C(L.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,z.jsx)(`div`,{className:`app-screen`,children:(0,z.jsxs)(`div`,{className:`app-screen__inner`,children:[(0,z.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,z.jsx)(V,{siteId:t,variant:`settings`,listLink:!1}),(0,z.jsx)(`h2`,{className:`app-section__title deploy-list__title`,children:`Deployments`}),n.loading?(0,z.jsx)(f,{lines:4}):n.status===`error`&&!n.data?(0,z.jsx)(r,{compact:!0,title:`Couldn’t load the deployments`,error:n.error,onRetry:()=>void n.refetch()}):s.length===0?(0,z.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,z.jsx)(`ul`,{className:`app-card deploy-list`,children:s.map(e=>(0,z.jsx)(W,{item:e,versions:o},`${e.kind}-${e.id}`))})]})})}export{V as OnlineCard,G as OnlineScreen,U as PublishDeployNote,H as PutLiveButton};
|