domma-cms 1.21.0 → 1.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.22.0] - 2026-10-30
4
+
5
+ - Admin: promote Footer and Appearance to innate tools under Content, each with its own Save, drafts and unsaved-change protection. Footer retains layout, Showcase options, blocks and social links.
6
+ - Appearance: move Favicon, Navigation (previously Page Navigation), Breadcrumbs, Reduced Motion and Search out of Site Settings. Add icons to all five tabs. Search now presents its four sections together in a responsive grid.
7
+ - Site Settings: rename Email to SMTP. Each settings tool saves only the values it owns, preserving existing configuration and edits made in other tools. Existing Search and appearance-tab bookmarks open the new location.
8
+ - Fonts: searchable visual pickers show font names and samples in their own typefaces in Theme, editor preferences and text/Scribe controls. Previews load on demand, licensed fonts use site-owned files, and existing values and save behaviour are retained.
9
+
3
10
  ## [1.21.0] - 2026-10-29
4
11
 
5
12
  - Menus: five more bar shapes that change the bar itself. **Tabs** (folder tabs on a line; the current page's tab joins the page), **Tiles** (each link a coloured icon square over its label, Rainbow unless Bar icons says otherwise), **Bubbles** (no shared tray; each link floats in its own pill), **Brutalist** (thick borders, hard offset shadows, bold type) and **Gradient band** (the bar is a band in the theme's colours, white words, the current page in a white pill). Behaviour > Bar shape, `look.bar`, or `[navbar bar=…]`.
@@ -0,0 +1 @@
1
+ .stx{display:flex;flex-direction:column;gap:.75rem}.stx [hidden]{display:none!important}.stx-alert{margin:0;display:flex;gap:.5rem;align-items:center;flex-wrap:wrap;padding:.6rem .8rem;border-radius:var(--dm-radius-md);color:var(--dm-text)}.stx-alert.is-dirty{background:color-mix(in srgb,var(--dm-primary) 12%,transparent)}.stx-alert.is-warn{background:color-mix(in srgb,var(--dm-warning) 16%,transparent)}.stx-alert.is-bad{background:color-mix(in srgb,var(--dm-danger) 14%,transparent)}.stx-spacer{flex:1}.stx-alert.is-dirty>span:nth-child(2){flex:1 1 18rem;min-width:0}.stx-tabs .tab-item{display:inline-flex;align-items:center;gap:.35rem}.stx-dot{display:inline-block;width:.45rem;height:.45rem;border-radius:50%;background:var(--dm-primary)}.stx-dot.is-bad{background:var(--dm-danger)}.stx-card{border:1px solid var(--dm-border);border-radius:var(--dm-radius-md);padding:.75rem .9rem;display:flex;flex-direction:column;gap:.65rem;margin-top:.75rem}.stx-card-title{display:flex;align-items:center;gap:.4rem;font-weight:600;flex-wrap:wrap}.stx-card-title .btn{display:inline-flex;align-items:center;gap:.3rem;font-weight:500}.stx-card-columns{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:1rem;align-items:start}.stx-card-columns>.stx-card{min-width:0}.stx-scroll-icon{display:inline-flex;padding:.35rem;border-radius:50%;background:var(--dm-surface-raised)}@media(max-width:900px){.stx-card-columns{grid-template-columns:minmax(0,1fr)}}.stx-grid{display:grid;grid-template-columns:1fr 1fr;gap:.75rem 1rem}.stx-wide{grid-column:1 / -1}.stx-pair{display:grid;grid-template-columns:1fr 1fr;gap:.75rem}.stx .form-label{display:flex;align-items:center;gap:.3rem}.stx-setting{display:flex;align-items:center;justify-content:space-between;gap:.75rem}.stx-setting .form-label{margin:0}.stx-hint{display:block;color:var(--dm-text-muted);font-size:var(--dm-text-xs);margin-top:.25rem}.stx-muted{color:var(--dm-text-muted);font-weight:400}.stx-note{margin:0;color:var(--dm-text-muted);font-size:var(--dm-text-sm)}.stx-note.is-bad{color:var(--dm-danger)}.stx-moved{flex-direction:row;align-items:center;gap:.75rem;background:var(--dm-surface-raised)}.stx-moved-text{flex:1;display:flex;flex-direction:column}.stx-moved-text small{color:var(--dm-text-muted)}.stx-problems{display:flex;flex-direction:column;gap:.35rem}.stx-problem{display:flex;align-items:center;gap:.6rem;font-size:var(--dm-text-sm)}.stx-problem button{margin-left:auto}.stx-inline{display:flex;gap:.5rem;align-items:center;flex-wrap:wrap}.stx-inline .btn{display:inline-flex;align-items:center;gap:.3rem}.stx-test-to{max-width:18rem}.stx-result{font-size:var(--dm-text-sm)}.stx-result.is-ok{color:var(--dm-success)}.stx-result.is-bad{color:var(--dm-danger)}.stx-corners{display:grid;grid-template-columns:1fr 1fr;border:1px solid var(--dm-border);border-radius:var(--dm-radius-md);overflow:hidden;width:fit-content}.stx-corners button{border:0;background:none;color:var(--dm-text);padding:.45rem .8rem;cursor:pointer;font:inherit;font-size:var(--dm-text-sm)}.stx-corners button:nth-child(odd){border-right:1px solid var(--dm-border)}.stx-corners button:nth-child(-n+2){border-bottom:1px solid var(--dm-border)}.stx-corners button:hover{background:var(--dm-table-hover-bg, color-mix(in srgb, var(--dm-text) 6%, transparent))}.stx-corners button.is-on{background:var(--dm-primary);color:var(--dm-primary-text)}.stx-segments{display:inline-flex;flex-wrap:wrap;border:1px solid var(--dm-border);border-radius:var(--dm-radius-md);overflow:hidden}.stx-segments button{border:0;background:none;color:var(--dm-text);padding:.45rem .8rem;cursor:pointer;font:inherit;font-size:var(--dm-text-sm)}.stx-segments button+button{border-left:1px solid var(--dm-border)}.stx-segments button:hover{background:var(--dm-table-hover-bg, color-mix(in srgb, var(--dm-text) 6%, transparent))}.stx-segments button.is-on{background:var(--dm-primary);color:var(--dm-primary-text)}.stx-readout{color:var(--dm-text-muted);font-weight:400;font-variant-numeric:tabular-nums}.stx-pair input[type=range]{width:100%}.stx-inline-link{background:none;border:0;padding:0;font:inherit;color:var(--dm-primary);text-decoration:underline;cursor:pointer}.stx-chips{display:flex;gap:.35rem;flex-wrap:wrap}.stx-chip{display:inline-flex;align-items:center;font-size:var(--dm-text-xs);font-weight:600;padding:.1rem .5rem;border-radius:999px;white-space:nowrap;background:color-mix(in srgb,var(--dm-text) 10%,transparent);color:var(--dm-text-muted)}.stx-chip.is-ok{background:color-mix(in srgb,var(--dm-success) 16%,transparent);color:var(--dm-success)}.stx-chip.is-warn{background:color-mix(in srgb,var(--dm-warning) 18%,transparent);color:var(--dm-warning)}.stx-chip.is-bad{background:color-mix(in srgb,var(--dm-danger) 16%,transparent);color:var(--dm-danger)}.stx-count{opacity:.65;font-size:var(--dm-text-xs);font-weight:500}.stx-search{max-width:14rem;font-weight:400}.stx-list{display:flex;flex-direction:column}.stx-row{display:flex;align-items:center;gap:.75rem;padding:.45rem .3rem;border-bottom:1px solid var(--dm-border);cursor:pointer}.stx-row:last-child{border-bottom:0}.stx-row:hover,.stx-row:focus-visible{background:var(--dm-table-hover-bg, color-mix(in srgb, var(--dm-text) 6%, transparent));outline:none}.stx-main{flex:1;min-width:0;display:flex;flex-direction:column}.stx-main strong,.stx-main small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.stx-main strong{font-family:var(--dm-font-mono, monospace);font-size:var(--dm-text-sm);font-weight:600}.stx-main small{color:var(--dm-text-muted);font-size:var(--dm-text-xs)}.stx-kebab{border:0;background:none;cursor:pointer;font-size:var(--dm-text-lg);color:var(--dm-text-muted);border-radius:var(--dm-radius-sm);padding:0 .3rem}.stx-kebab:hover{color:var(--dm-primary)}@media(max-width:720px){.stx-grid,.stx-pair{grid-template-columns:1fr}}
package/admin/js/app.js CHANGED
@@ -1,4 +1,4 @@
1
- import{wireNotificationMenu as Q}from"./lib/topbar-notifications.js";import{installSmoothCarets as X}from"./lib/smooth-caret.js";import{viewLoaders as Z}from"./views/index.js";import{createLazyViews as tt}from"./lib/lazy-views.js";import{withPluginChrome as _}from"./lib/plugin-chrome.js";import{api as r,getUser as L,isAuthenticated as m,logout as et,sendToLogin as it}from"./api.js";import{claimDrafts as at}from"./lib/draft-owner.js";import{isAuthScreen as C,loginHashFor as ot}from"./lib/login-arrange.js";import{installHttpInterceptor as st}from"./http-interceptor.js";import{installResizableSlideovers as nt}from"./lib/slideover-resizable.js";import{installActivityThrobber as rt}from"./lib/activity-throbber.js";import{installUpdateNotice as lt,renderCmsVersion as ct}from"./lib/update-notice.js";import{renderFrameworkVersions as W,wireAccountMenu as mt}from"./lib/topbar-account.js";import{refreshTopbarProject as B}from"./lib/topbar-project.js";import{isPathAllowed as pt,redirectFor as dt}from"./lib/admin-scope.js";import{deliverDesktop as ut,desktopActive as ht,notificationSettings as wt}from"./lib/desktop-notify.js";import{avatarUrl as gt,installAccountAvatar as ft}from"./lib/avatar.js";import{installCalculator as vt}from"./lib/calculator.js";import{takeOverviewPass as bt,withDashboardStrip as H}from"./lib/dashboards-strip.js";import{installHotkeys as St}from"./lib/hotkeys-ui.js";import{applyAdminBrand as q}from"./lib/admin-brand.js";import{installRouterCatchUp as Ct}from"./lib/router-catch-up.js";import{installSidebarDrawer as Mt}from"./lib/sidebar-drawer.js";$(()=>{X(document),st(),vt(),lt(),rt(),nt(),Mt(),(async()=>{const{applyAdminTheme:t,refreshAdminTheme:a}=await import("./lib/admin-theme.js");m()?await a(r,{init:!0}):t({dommaTheme:"charcoal-dark"},{init:!0})})();let p=null,h=null,c="/",w=!1,g=null;function D(t){if(P[t])return E.toast(`${P[t]} is switched off on this site.`,{type:"info"}),"/";if(t.split("?")[0]==="/my-dashboard")return"/dashboards";const a=y[t]||dt(p,t);return a||((t.split("?")[0]||"/")==="/"&&c&&c!=="/"&&!bt()?y[c]||c:null)}const y={},P={};R.use(async(t,a,e)=>{if(C(t.path))return e();if(!m()){it();return}const i=D(t.path);if(i){R.navigate(i);return}e()});async function f(){try{const t=await r.get("/auth/permissions");p=t.adminScope||null,h=t.adminBrand||null,q(h),c=t.adminHome||"/",W(t.versions);const a=t.permissions||[];return w=pt(p,"/settings")&&a.some(e=>e==="settings"||e.startsWith("settings.")),g=a.some(e=>e==="notifications"||e.startsWith("notifications.")),a}catch{return p=null,c="/",h||q(null),w=!1,g=null,[]}}document.addEventListener("dm:admin-home-changed",()=>{f()});let N=null,A=!1;document.addEventListener("dm:sidebar-rebuild",()=>{if(B(r),N){A=!0;return}N=(async()=>{do{A=!1;try{await j(await f())}catch{}}while(A)})().finally(()=>{N=null})});async function j(t){const{renderAdminSidebar:a}=await import("./lib/sidebar-renderer.js");await a({mount:"#admin-sidebar",permissions:t,adminScope:p,brand:h})}M.subscribe("router:afterChange",({to:t})=>{C(t.path)&&(u&&(clearInterval(u),u=null),p=null,c="/",w=!1,g=null)});const z=[{path:"/",view:"dashboard",title:"Dashboard - Domma CMS"},{path:"/dashboards",view:"dashboards",title:"Dashboards - Domma CMS"},{path:"/my-dashboard",view:"dashboards",title:"Dashboards - Domma CMS"},{path:"/pages",view:"pages",title:"Pages - Domma CMS"},{path:"/pages/new",view:"pageEditor",title:"New Page - Domma CMS"},{path:"/pages/edit/*",view:"pageEditor",title:"Edit Page - Domma CMS"},{path:"/media",view:"media",title:"Media - Domma CMS"},{path:"/menus",view:"menus",title:"Menus - Domma CMS"},{path:"/context-menus",view:"contextMenus",title:"Context Menus - Domma CMS"},{path:"/context-menus/new",view:"contextMenuEditor",title:"New Context Menu - Domma CMS"},{path:"/context-menus/edit/:slug",view:"contextMenuEditor",title:"Edit Context Menu - Domma CMS"},{path:"/menus/new",view:"menuEditor",title:"New Menu - Domma CMS"},{path:"/menus/edit/:slug",view:"menuEditor",title:"Edit Menu - Domma CMS"},{path:"/menu-locations",view:"menuLocations",title:"Menu Locations - Domma CMS"},{path:"/navigation",view:"menusRedirect",title:"Menus - Domma CMS"},{path:"/layouts",view:"layouts",title:"Layouts - Domma CMS"},{path:"/settings",view:"settings",title:"Settings - Domma CMS"},{path:"/theme",view:"theme",title:"Theme - Domma CMS"},{path:"/users",view:"users",title:"Users - Domma CMS"},{path:"/users/new",view:"userEditor",title:"New User - Domma CMS"},{path:"/users/edit/:id",view:"userEditor",title:"Edit User - Domma CMS"},{path:"/plugins",view:"plugins",title:"Plugins - Domma CMS"},{path:"/plugins/code/:name",view:"pluginCode",title:"Plugin Code - Domma CMS"},{path:"/documentation",view:"documentation",title:"Usage - Domma CMS"},{path:"/tutorials",view:"tutorials",title:"Tutorials - Domma CMS"},{path:"/tutorials/crud",view:"tutorialCrud",title:"Building a CRUD App - Domma CMS"},{path:"/tutorials/editor",view:"tutorialEditor",title:"The Editor - Domma CMS"},{path:"/tutorials/plugin",view:"tutorialPlugin",title:"Writing a Tool - Domma CMS"},{path:"/tutorials/forms",view:"tutorialForms",title:"Form Follow-Up - Domma CMS"},{path:"/docs/components",view:"componentsReference",title:"Components Reference - Domma CMS"},{path:"/docs/components-howto",view:"componentsHowto",title:"Components How-To - Domma CMS"},{path:"/docs/components-walkthrough",view:"componentsWalkthrough",title:"Components Walkthrough - Domma CMS"},{path:"/docs/components-rules",view:"componentsRules",title:"Components Rules - Domma CMS"},{path:"/docs/usage/pages",view:"usagePages",title:"Pages - Usage - Domma CMS"},{path:"/docs/usage/media",view:"usageMedia",title:"Media - Usage - Domma CMS"},{path:"/docs/usage/navigation",view:"usageNavigation",title:"Navigation - Usage - Domma CMS"},{path:"/docs/usage/dconfig",view:"usageDconfig",title:"DConfig - Usage - Domma CMS"},{path:"/docs/usage/shortcodes",view:"usageShortcodes",title:"Shortcodes - Usage - Domma CMS"},{path:"/docs/usage/site-settings",view:"usageSiteSettings",title:"Site Settings - Usage - Domma CMS"},{path:"/docs/usage/plugins",view:"usagePlugins",title:"Plugins - Usage - Domma CMS"},{path:"/docs/usage/users-roles",view:"usageUsersRoles",title:"Users & Roles - Usage - Domma CMS"},{path:"/docs/usage/views",view:"usageViews",title:"Views - Usage - Domma CMS"},{path:"/docs/usage/actions",view:"usageActions",title:"Actions - Usage - Domma CMS"},{path:"/docs/usage/cta-shortcode",view:"usageCtaShortcode",title:"CTA Shortcode - Usage - Domma CMS"},{path:"/docs/usage/editions",view:"usageEditions",title:"Editions & Licences - Usage - Domma CMS"},{path:"/docs/usage/collections",view:"usageCollections",title:"Collections & Forms - Usage - Domma CMS"},{path:"/docs/usage/blocks",view:"usageBlocks",title:"Blocks - Usage - Domma CMS"},{path:"/docs/usage/tools",view:"usageTools",title:"Built-in Tools - Usage - Domma CMS"},{path:"/docs/usage/dashboard",view:"usageDashboard",title:"Dashboard - Usage - Domma CMS"},{path:"/docs/usage/search-engines",view:"usageSearchEngines",title:"Search Engines & AI - Usage - Domma CMS"},{path:"/docs/plugins",view:"pluginGuides",title:"Plugin Guides - Domma CMS"},{path:"/docs/plugins/*",view:"pluginGuide",title:"Plugin Guide - Domma CMS"},{path:"/docs/api/authentication",view:"apiRefAuthentication",title:"Authentication - API - Domma CMS"},{path:"/docs/api/pages",view:"apiRefPages",title:"Pages - API - Domma CMS"},{path:"/docs/api/settings",view:"apiRefSettings",title:"Settings - API - Domma CMS"},{path:"/docs/api/layouts",view:"apiRefLayouts",title:"Layouts - API - Domma CMS"},{path:"/docs/api/navigation",view:"apiRefNavigation",title:"Navigation - API - Domma CMS"},{path:"/docs/api/media",view:"apiRefMedia",title:"Media - API - Domma CMS"},{path:"/docs/api/users",view:"apiRefUsers",title:"Users - API - Domma CMS"},{path:"/docs/api/plugins",view:"apiRefPlugins",title:"Plugins - API - Domma CMS"},{path:"/docs/api/collections",view:"apiRefCollections",title:"Collections - API - Domma CMS"},{path:"/docs/api/views",view:"apiRefViews",title:"Views API - Domma CMS"},{path:"/docs/api/actions",view:"apiRefActions",title:"Actions API - Domma CMS"},{path:"/docs/api/forms",view:"apiRefForms",title:"Forms API - Domma CMS"},{path:"/docs/api/scaffold",view:"apiRefScaffold",title:"Scaffold API - Domma CMS"},{path:"/docs/api/external",view:"apiRefExternal",title:"External API & Tokens - Domma CMS"},{path:"/docs/api/content",view:"apiRefContent",title:"Content API - Domma CMS"},{path:"/docs/api/builder",view:"apiRefBuilder",title:"API Builder - Domma CMS"},{path:"/api-reference",view:"apiReference",title:"API Reference - Domma CMS"},{path:"/collections",view:"collections",title:"Collections - Domma CMS"},{path:"/collections/new",view:"collectionEditor",title:"New Collection - Domma CMS"},{path:"/collections/edit/:slug",view:"collectionEditor",title:"Edit Collection - Domma CMS"},{path:"/collections/:slug/entries",view:"collectionEntries",title:"Entries - Domma CMS"},{path:"/forms",view:"forms",title:"Forms - Domma CMS"},{path:"/forms/new",view:"formEditor",title:"New Form - Domma CMS"},{path:"/forms/edit/:slug",view:"formEditor",title:"Edit Form - Domma CMS"},{path:"/forms/:slug/submissions",view:"formSubmissions",title:"Submissions - Domma CMS"},{path:"/views",view:"viewsList",title:"Views - Domma CMS"},{path:"/views/new",view:"viewEditor",title:"New View - Domma CMS"},{path:"/views/edit/:slug",view:"viewEditor",title:"Edit View - Domma CMS"},{path:"/views/:slug/preview",view:"viewPreview",title:"View Preview - Domma CMS"},{path:"/actions",view:"actionsList",title:"Actions - Domma CMS"},{path:"/actions/new",view:"actionEditor",title:"New Action - Domma CMS"},{path:"/actions/edit/:slug",view:"actionEditor",title:"Edit Action - Domma CMS"},{path:"/pro/docs",view:"proDocs",title:"Pro Documentation - Domma CMS"},{path:"/blocks",view:"blocks",title:"Blocks - Domma CMS"},{path:"/blocks/new",view:"pageEditor",title:"New Block - Domma CMS"},{path:"/blocks/edit/:name",view:"pageEditor",title:"Edit Block - Domma CMS"},{path:"/components",view:"components",title:"Components - Domma CMS"},{path:"/components/new",view:"pageEditor",title:"New Component - Domma CMS"},{path:"/components/edit/:name",view:"pageEditor",title:"Edit Component - Domma CMS"},{path:"/my-profile",view:"myProfile",title:"My Profile - Domma CMS"},{path:"/roles",view:"roles",title:"Roles & Permissions - Domma CMS"},{path:"/roles/edit/:id",view:"roleEditor",title:"Edit Role - Domma CMS"},{path:"/effects",view:"effects",title:"Effects - Domma CMS"},{path:"/search",view:"search",title:"Search - Domma CMS"},{path:"/content-api",view:"contentApi",title:"Content API - Domma CMS"},{path:"/notes",view:"notes",title:"Notes - Domma CMS"},{path:"/todo",view:"todo",title:"Todo - Domma CMS"},{path:"/calculator",view:"calculator",title:"Calculator - Domma CMS"},{path:"/analytics",view:"analytics",title:"Analytics - Domma CMS"},{path:"/seo",view:"seo",title:"SEO - Domma CMS"},{path:"/seo/:tab",view:"seo",title:"SEO - Domma CMS"},{path:"/wordpress-import",view:"wordpressImport",title:"Import from WordPress - Domma CMS"},{path:"/contacts",view:"contacts",title:"Contacts - Domma CMS"},{path:"/calls/new",view:"callNew",title:"Call now - Domma CMS"},{path:"/system/notifications",view:"notifications",title:"Notifications - Domma CMS"},{path:"/api-tokens",view:"apiTokens",title:"API Tokens - Domma CMS"},{path:"/api-endpoints",view:"apiEndpoints",title:"API Builder - Domma CMS"},{path:"/api-endpoints/new",view:"apiEndpointEditor",title:"New API Endpoint - Domma CMS"},{path:"/api-endpoints/edit/:id",view:"apiEndpointEditor",title:"Edit API Endpoint - Domma CMS"},{path:"/projects",view:"projects",title:"Projects - Domma CMS"},{path:"/projects/new",view:"projects",title:"New Project - Domma CMS"},{path:"/projects/edit/:slug",view:"projects",title:"Edit Project - Domma CMS"},{path:"/projects/:slug/settings",view:"projectSettings",title:"Project settings - Domma CMS"},{path:"/projects/:slug/pages",view:"pages",title:"Project pages - Domma CMS"},{path:"/projects/:slug/collections",view:"collections",title:"Project collections - Domma CMS"},{path:"/projects/:slug/forms",view:"forms",title:"Project forms - Domma CMS"},{path:"/projects/:slug/actions",view:"actionsList",title:"Project actions - Domma CMS"},{path:"/projects/:slug/menus",view:"menus",title:"Project menus - Domma CMS"},{path:"/projects/:slug/blocks",view:"blocks",title:"Project blocks - Domma CMS"},{path:"/projects/:slug/components",view:"components",title:"Project components - Domma CMS"},{path:"/projects/:slug/views",view:"viewsList",title:"Project views - Domma CMS"},{path:"/projects/:slug/roles",view:"roles",title:"Project roles - Domma CMS"},{path:"/projects/:slug/users",view:"users",title:"Project users - Domma CMS"},{path:"/projects/:slug/apis",view:"apiEndpoints",title:"Project APIs - Domma CMS"},{path:"/projects/:slug",view:"projectDetail",title:"Project - Domma CMS"},{path:"/login",view:"login",title:"Sign in - Domma CMS",onEnter:()=>{$("#admin-sidebar").hide(),$("#admin-topbar").hide()}},{path:"/reset-password",view:"login",title:"Reset Password - Domma CMS",onEnter:()=>{$("#admin-sidebar").hide(),$("#admin-topbar").hide()}}];M.subscribe("router:afterChange",async({to:t,from:a})=>{if(!C(t.path)){if($("#admin-sidebar").show(),$("#admin-topbar").show(),C(a?.path)){$("#topbar-user-name").remove(),import("./lib/admin-theme.js").then(o=>o.refreshAdminTheme(r)),await T();const e=await f(),i=D(t.path);if(i&&R.navigate(i),j(e),wt.read().signInToasts)try{const o=await r.system.notifications.list().catch(()=>[]),n=(Array.isArray(o)?o:[]).filter(s=>s.unread&&["warning","critical"].includes(s.data?.severity)).slice(0,3);for(const s of n){const l=d(s.data?.title||""),x=d((s.data?.body||"").slice(0,120));E.toast(`${l} - ${x}`,{type:s.data?.severity==="critical"?"error":"warning",duration:0})}}catch{}}V()}}),M.subscribe("router:afterChange",()=>{setTimeout(()=>{$(".btn-primary, .btn-danger").length&&Domma.effects.reveal(".btn-primary, .btn-danger",{animation:"fade",stagger:40,duration:300})},50)});const G=["#field-project","#menu-project","#collection-project","#endpoint-project","#action-project","#view-project","#block-project","#component-project","#role-project",'[name="project"]','[name="ownedByProject"]'];function J(t){return/^\/(pages|menus|context-menus|collections|forms|actions|views|blocks|components|users|roles|api-endpoints)\/(new|edit\/)/.test(t)}M.subscribe("router:afterChange",({to:t})=>{const a=t?String(t.path).split("?")[0]:"";if(!t||!J(a))return;const i=new URLSearchParams(location.hash.split("?")[1]||"").get("project");if(!i||!/\/new$/.test(a))return;let o=0;const n=60,s=1500,l=()=>{o+=n;for(const x of G){const b=document.querySelector(x);if(!b)continue;if(Array.from(b.options||[]).find(Y=>Y.value===i)){b.value=i,b.dispatchEvent(new Event("change",{bubbles:!0}));return}}o<s&&setTimeout(l,n)};setTimeout(l,n)});const F="cms_card_states",k=S.get(F)||{};M.subscribe("router:afterChange",()=>{setTimeout(()=>{$("#view-container .card-collapsible").each(function(){const t=$(this).find(".card-header h2, .card-header h3").first().text().trim();t&&k[t]==="collapsed"&&$(this).addClass("card-collapsed")})},200)}),$("#view-container").on("click",".card-collapsible .card-header",function(t){if($(t.target).closest("button, a").length)return;const a=$(this).closest(".card");a.toggleClass("card-collapsed");const e=$(this).find("h2, h3").first().text().trim();e&&(k[e]=a.hasClass("card-collapsed")?"collapsed":"open",S.set(F,k))}),St(),document.addEventListener("keydown",t=>{if(!(t.ctrlKey||t.metaKey)||t.key!=="s"||window.location.hash.startsWith("#/login")||window.location.hash.startsWith("#/reset-password"))return;const a=document.querySelector("#view-container .view-header button.btn-primary");a&&(t.preventDefault(),a.click())});const v=tt(),O=v.views,K={notes:{displayName:"Notes",icon:"edit-3"},todo:{displayName:"Todo",icon:"check-square"},calculator:{displayName:"Calculator",icon:"calculator"},analytics:{displayName:"Analytics",icon:"chart-bar"},seo:{displayName:"SEO",icon:"search"},wordpressImport:{displayName:"Import from WordPress",icon:"download"},contacts:{displayName:"Contacts",icon:"users"},projects:{displayName:"Projects",icon:"folder"},pages:{displayName:"Pages",icon:"file-text"},media:{displayName:"Media",icon:"image"},menus:{displayName:"Site menus",icon:"menu"},contextMenus:{displayName:"Context Menus",icon:"menu"},theme:{displayName:"Theme",icon:"droplet"},collections:{displayName:"Collections",icon:"database"},forms:{displayName:"Forms",icon:"layout"},viewsList:{displayName:"Views",icon:"eye"},actionsList:{displayName:"Actions",icon:"zap"},apiEndpoints:{displayName:"API Builder",icon:"code"},blocks:{displayName:"Blocks",icon:"box"},components:{displayName:"Components",icon:"component"},notifications:{displayName:"Notifications",icon:"bell"},roles:{displayName:"Roles",icon:"shield"},users:{displayName:"Users",icon:"users"},settings:{displayName:"Site Settings",icon:"settings"},effects:{displayName:"Effects",icon:"sparkles"},layouts:{displayName:"Layouts",icon:"layout"},plugins:{displayName:"Marketplace",icon:"store"},myProfile:{displayName:"My Profile",icon:"user"},apiTokens:{displayName:"API Tokens",icon:"key"},search:{displayName:"Search",icon:"search"},contentApi:{displayName:"Content API",icon:"file-text"},dashboard:{displayName:"Dashboard",icon:"home"},dashboards:{displayName:"Dashboards",icon:"home"},pageEditor:{displayName:"Pages",section:"Edit",icon:"file-text"},menuEditor:{displayName:"Site menus",section:"Edit",icon:"menu"},menuLocations:{displayName:"Site menus",section:"Locations",icon:"map-pin"},contextMenuEditor:{displayName:"Context Menus",section:"Edit",icon:"menu"},collectionEditor:{displayName:"Collections",section:"Edit",icon:"database"},collectionEntries:{displayName:"Collections",section:"Entries",icon:"database"},formEditor:{displayName:"Forms",section:"Edit",icon:"layout"},formSubmissions:{displayName:"Forms",section:"Submissions",icon:"inbox"},viewEditor:{displayName:"Views",section:"Edit",icon:"eye"},viewPreview:{displayName:"Views",section:"Preview",icon:"eye"},actionEditor:{displayName:"Actions",section:"Edit",icon:"zap"},apiEndpointEditor:{displayName:"API Builder",section:"Edit",icon:"code"},roleEditor:{displayName:"Roles",section:"Edit",icon:"shield"},userEditor:{displayName:"Users",section:"Edit",icon:"users"},projectDetail:{displayName:"Projects",section:"Overview",icon:"folder"},projectSettings:{displayName:"Projects",section:"Settings",icon:"folder"},pluginCode:{displayName:"Marketplace",section:"Code",icon:"code"}};for(const[t,a]of Object.entries(Z))v.register(t,async()=>{let e=await a();const i=K[t];return i&&(e=_(e,{plugin:t,licence:"Built in",...i})),t==="dashboard"?H(e):e});R.use(async(t,a,e)=>{try{await v.load(t.view)}catch(i){console.error("[admin] Screen failed to load",i),O[t.view]={template:'<p role="alert">This screen could not load. Reload the page to try again.</p>'}}e()});const I=[...z];async function T(){if(m())try{const t=await r.plugins.adminConfig(),a=new Set(I.map(e=>e.path));for(const e of t.routes||[])a.has(e.path)||I.push(e);for(const[e,i]of Object.entries(t.views||{})){const o=(t.meta||{})[e];v.register(e,async()=>{const s=(await import(`/plugins/${i.entry}`))[i.exportName];if(!s)throw new Error(`Missing plugin screen: ${e}`);const l=_(s,o);return e==="dashboard"?H(l):l},JSON.stringify([i,o]))}for(const[e,{route:i}]of Object.entries(t.takeovers||{}))i&&(y[`/${e}`]=i);for(const[e,{enabled:i,displayName:o}]of Object.entries(t.tools||{}))i===!1&&(P[`/${e}`]=o);for(const{id:e,href:i}of t.css||[])if(!document.getElementById(e)){const o=document.createElement("link");o.id=e,o.rel="stylesheet",o.href=i,document.head.appendChild(o)}}catch{}}function V(){const t=L();if(!t)return;if($("#topbar-user-name").length){B(r);return}const e={"super-admin":"Super Admin",admin:"Admin",user:"User"}[t.role]||t.role,i=gt(t);$("#topbar-user").get(0).innerHTML=`
1
+ import{wireNotificationMenu as Q}from"./lib/topbar-notifications.js";import{installSmoothCarets as X}from"./lib/smooth-caret.js";import{viewLoaders as Z}from"./views/index.js";import{createLazyViews as tt}from"./lib/lazy-views.js";import{withPluginChrome as _}from"./lib/plugin-chrome.js";import{api as r,getUser as L,isAuthenticated as m,logout as et,sendToLogin as at}from"./api.js";import{claimDrafts as it}from"./lib/draft-owner.js";import{isAuthScreen as C,loginHashFor as ot}from"./lib/login-arrange.js";import{installHttpInterceptor as st}from"./http-interceptor.js";import{installResizableSlideovers as nt}from"./lib/slideover-resizable.js";import{installActivityThrobber as rt}from"./lib/activity-throbber.js";import{installUpdateNotice as lt,renderCmsVersion as ct}from"./lib/update-notice.js";import{renderFrameworkVersions as W,wireAccountMenu as mt}from"./lib/topbar-account.js";import{refreshTopbarProject as B}from"./lib/topbar-project.js";import{isPathAllowed as pt,redirectFor as dt}from"./lib/admin-scope.js";import{deliverDesktop as ut,desktopActive as ht,notificationSettings as wt}from"./lib/desktop-notify.js";import{avatarUrl as gt,installAccountAvatar as ft}from"./lib/avatar.js";import{installCalculator as vt}from"./lib/calculator.js";import{takeOverviewPass as bt,withDashboardStrip as H}from"./lib/dashboards-strip.js";import{installHotkeys as St}from"./lib/hotkeys-ui.js";import{applyAdminBrand as q}from"./lib/admin-brand.js";import{installRouterCatchUp as Ct}from"./lib/router-catch-up.js";import{installSidebarDrawer as Mt}from"./lib/sidebar-drawer.js";$(()=>{X(document),st(),vt(),lt(),rt(),nt(),Mt(),(async()=>{const{applyAdminTheme:t,refreshAdminTheme:i}=await import("./lib/admin-theme.js");m()?await i(r,{init:!0}):t({dommaTheme:"charcoal-dark"},{init:!0})})();let p=null,h=null,c="/",w=!1,g=null;function D(t){if(P[t])return E.toast(`${P[t]} is switched off on this site.`,{type:"info"}),"/";const[i,e]=t.split("?"),a=new URLSearchParams(e||"").get("tab");if(i==="/settings"&&["favicon","pageNavigation","breadcrumbs","motion","search"].includes(a))return`/appearance?tab=${a}`;if(t.split("?")[0]==="/my-dashboard")return"/dashboards";const o=y[t]||dt(p,t);return o||((t.split("?")[0]||"/")==="/"&&c&&c!=="/"&&!bt()?y[c]||c:null)}const y={},P={};R.use(async(t,i,e)=>{if(C(t.path))return e();if(!m()){at();return}const a=D(t.path);if(a){R.navigate(a);return}e()});async function f(){try{const t=await r.get("/auth/permissions");p=t.adminScope||null,h=t.adminBrand||null,q(h),c=t.adminHome||"/",W(t.versions);const i=t.permissions||[];return w=pt(p,"/settings")&&i.some(e=>e==="settings"||e.startsWith("settings.")),g=i.some(e=>e==="notifications"||e.startsWith("notifications.")),i}catch{return p=null,c="/",h||q(null),w=!1,g=null,[]}}document.addEventListener("dm:admin-home-changed",()=>{f()});let N=null,A=!1;document.addEventListener("dm:sidebar-rebuild",()=>{if(B(r),N){A=!0;return}N=(async()=>{do{A=!1;try{await j(await f())}catch{}}while(A)})().finally(()=>{N=null})});async function j(t){const{renderAdminSidebar:i}=await import("./lib/sidebar-renderer.js");await i({mount:"#admin-sidebar",permissions:t,adminScope:p,brand:h})}M.subscribe("router:afterChange",({to:t})=>{C(t.path)&&(u&&(clearInterval(u),u=null),p=null,c="/",w=!1,g=null)});const z=[{path:"/",view:"dashboard",title:"Dashboard - Domma CMS"},{path:"/dashboards",view:"dashboards",title:"Dashboards - Domma CMS"},{path:"/my-dashboard",view:"dashboards",title:"Dashboards - Domma CMS"},{path:"/pages",view:"pages",title:"Pages - Domma CMS"},{path:"/pages/new",view:"pageEditor",title:"New Page - Domma CMS"},{path:"/pages/edit/*",view:"pageEditor",title:"Edit Page - Domma CMS"},{path:"/media",view:"media",title:"Media - Domma CMS"},{path:"/menus",view:"menus",title:"Menus - Domma CMS"},{path:"/context-menus",view:"contextMenus",title:"Context Menus - Domma CMS"},{path:"/context-menus/new",view:"contextMenuEditor",title:"New Context Menu - Domma CMS"},{path:"/context-menus/edit/:slug",view:"contextMenuEditor",title:"Edit Context Menu - Domma CMS"},{path:"/menus/new",view:"menuEditor",title:"New Menu - Domma CMS"},{path:"/menus/edit/:slug",view:"menuEditor",title:"Edit Menu - Domma CMS"},{path:"/menu-locations",view:"menuLocations",title:"Menu Locations - Domma CMS"},{path:"/navigation",view:"menusRedirect",title:"Menus - Domma CMS"},{path:"/layouts",view:"layouts",title:"Layouts - Domma CMS"},{path:"/appearance",view:"appearance",title:"Appearance - Domma CMS"},{path:"/footer",view:"footer",title:"Footer - Domma CMS"},{path:"/settings",view:"settings",title:"Settings - Domma CMS"},{path:"/theme",view:"theme",title:"Theme - Domma CMS"},{path:"/users",view:"users",title:"Users - Domma CMS"},{path:"/users/new",view:"userEditor",title:"New User - Domma CMS"},{path:"/users/edit/:id",view:"userEditor",title:"Edit User - Domma CMS"},{path:"/plugins",view:"plugins",title:"Plugins - Domma CMS"},{path:"/plugins/code/:name",view:"pluginCode",title:"Plugin Code - Domma CMS"},{path:"/documentation",view:"documentation",title:"Usage - Domma CMS"},{path:"/tutorials",view:"tutorials",title:"Tutorials - Domma CMS"},{path:"/tutorials/crud",view:"tutorialCrud",title:"Building a CRUD App - Domma CMS"},{path:"/tutorials/editor",view:"tutorialEditor",title:"The Editor - Domma CMS"},{path:"/tutorials/plugin",view:"tutorialPlugin",title:"Writing a Tool - Domma CMS"},{path:"/tutorials/forms",view:"tutorialForms",title:"Form Follow-Up - Domma CMS"},{path:"/docs/components",view:"componentsReference",title:"Components Reference - Domma CMS"},{path:"/docs/components-howto",view:"componentsHowto",title:"Components How-To - Domma CMS"},{path:"/docs/components-walkthrough",view:"componentsWalkthrough",title:"Components Walkthrough - Domma CMS"},{path:"/docs/components-rules",view:"componentsRules",title:"Components Rules - Domma CMS"},{path:"/docs/usage/pages",view:"usagePages",title:"Pages - Usage - Domma CMS"},{path:"/docs/usage/media",view:"usageMedia",title:"Media - Usage - Domma CMS"},{path:"/docs/usage/navigation",view:"usageNavigation",title:"Navigation - Usage - Domma CMS"},{path:"/docs/usage/dconfig",view:"usageDconfig",title:"DConfig - Usage - Domma CMS"},{path:"/docs/usage/shortcodes",view:"usageShortcodes",title:"Shortcodes - Usage - Domma CMS"},{path:"/docs/usage/site-settings",view:"usageSiteSettings",title:"Site Settings - Usage - Domma CMS"},{path:"/docs/usage/plugins",view:"usagePlugins",title:"Plugins - Usage - Domma CMS"},{path:"/docs/usage/users-roles",view:"usageUsersRoles",title:"Users & Roles - Usage - Domma CMS"},{path:"/docs/usage/views",view:"usageViews",title:"Views - Usage - Domma CMS"},{path:"/docs/usage/actions",view:"usageActions",title:"Actions - Usage - Domma CMS"},{path:"/docs/usage/cta-shortcode",view:"usageCtaShortcode",title:"CTA Shortcode - Usage - Domma CMS"},{path:"/docs/usage/editions",view:"usageEditions",title:"Editions & Licences - Usage - Domma CMS"},{path:"/docs/usage/collections",view:"usageCollections",title:"Collections & Forms - Usage - Domma CMS"},{path:"/docs/usage/blocks",view:"usageBlocks",title:"Blocks - Usage - Domma CMS"},{path:"/docs/usage/tools",view:"usageTools",title:"Built-in Tools - Usage - Domma CMS"},{path:"/docs/usage/dashboard",view:"usageDashboard",title:"Dashboard - Usage - Domma CMS"},{path:"/docs/usage/search-engines",view:"usageSearchEngines",title:"Search Engines & AI - Usage - Domma CMS"},{path:"/docs/plugins",view:"pluginGuides",title:"Plugin Guides - Domma CMS"},{path:"/docs/plugins/*",view:"pluginGuide",title:"Plugin Guide - Domma CMS"},{path:"/docs/api/authentication",view:"apiRefAuthentication",title:"Authentication - API - Domma CMS"},{path:"/docs/api/pages",view:"apiRefPages",title:"Pages - API - Domma CMS"},{path:"/docs/api/settings",view:"apiRefSettings",title:"Settings - API - Domma CMS"},{path:"/docs/api/layouts",view:"apiRefLayouts",title:"Layouts - API - Domma CMS"},{path:"/docs/api/navigation",view:"apiRefNavigation",title:"Navigation - API - Domma CMS"},{path:"/docs/api/media",view:"apiRefMedia",title:"Media - API - Domma CMS"},{path:"/docs/api/users",view:"apiRefUsers",title:"Users - API - Domma CMS"},{path:"/docs/api/plugins",view:"apiRefPlugins",title:"Plugins - API - Domma CMS"},{path:"/docs/api/collections",view:"apiRefCollections",title:"Collections - API - Domma CMS"},{path:"/docs/api/views",view:"apiRefViews",title:"Views API - Domma CMS"},{path:"/docs/api/actions",view:"apiRefActions",title:"Actions API - Domma CMS"},{path:"/docs/api/forms",view:"apiRefForms",title:"Forms API - Domma CMS"},{path:"/docs/api/scaffold",view:"apiRefScaffold",title:"Scaffold API - Domma CMS"},{path:"/docs/api/external",view:"apiRefExternal",title:"External API & Tokens - Domma CMS"},{path:"/docs/api/content",view:"apiRefContent",title:"Content API - Domma CMS"},{path:"/docs/api/builder",view:"apiRefBuilder",title:"API Builder - Domma CMS"},{path:"/api-reference",view:"apiReference",title:"API Reference - Domma CMS"},{path:"/collections",view:"collections",title:"Collections - Domma CMS"},{path:"/collections/new",view:"collectionEditor",title:"New Collection - Domma CMS"},{path:"/collections/edit/:slug",view:"collectionEditor",title:"Edit Collection - Domma CMS"},{path:"/collections/:slug/entries",view:"collectionEntries",title:"Entries - Domma CMS"},{path:"/forms",view:"forms",title:"Forms - Domma CMS"},{path:"/forms/new",view:"formEditor",title:"New Form - Domma CMS"},{path:"/forms/edit/:slug",view:"formEditor",title:"Edit Form - Domma CMS"},{path:"/forms/:slug/submissions",view:"formSubmissions",title:"Submissions - Domma CMS"},{path:"/views",view:"viewsList",title:"Views - Domma CMS"},{path:"/views/new",view:"viewEditor",title:"New View - Domma CMS"},{path:"/views/edit/:slug",view:"viewEditor",title:"Edit View - Domma CMS"},{path:"/views/:slug/preview",view:"viewPreview",title:"View Preview - Domma CMS"},{path:"/actions",view:"actionsList",title:"Actions - Domma CMS"},{path:"/actions/new",view:"actionEditor",title:"New Action - Domma CMS"},{path:"/actions/edit/:slug",view:"actionEditor",title:"Edit Action - Domma CMS"},{path:"/pro/docs",view:"proDocs",title:"Pro Documentation - Domma CMS"},{path:"/blocks",view:"blocks",title:"Blocks - Domma CMS"},{path:"/blocks/new",view:"pageEditor",title:"New Block - Domma CMS"},{path:"/blocks/edit/:name",view:"pageEditor",title:"Edit Block - Domma CMS"},{path:"/components",view:"components",title:"Components - Domma CMS"},{path:"/components/new",view:"pageEditor",title:"New Component - Domma CMS"},{path:"/components/edit/:name",view:"pageEditor",title:"Edit Component - Domma CMS"},{path:"/my-profile",view:"myProfile",title:"My Profile - Domma CMS"},{path:"/roles",view:"roles",title:"Roles & Permissions - Domma CMS"},{path:"/roles/edit/:id",view:"roleEditor",title:"Edit Role - Domma CMS"},{path:"/effects",view:"effects",title:"Effects - Domma CMS"},{path:"/search",view:"search",title:"Search - Domma CMS"},{path:"/content-api",view:"contentApi",title:"Content API - Domma CMS"},{path:"/notes",view:"notes",title:"Notes - Domma CMS"},{path:"/todo",view:"todo",title:"Todo - Domma CMS"},{path:"/calculator",view:"calculator",title:"Calculator - Domma CMS"},{path:"/analytics",view:"analytics",title:"Analytics - Domma CMS"},{path:"/seo",view:"seo",title:"SEO - Domma CMS"},{path:"/seo/:tab",view:"seo",title:"SEO - Domma CMS"},{path:"/wordpress-import",view:"wordpressImport",title:"Import from WordPress - Domma CMS"},{path:"/contacts",view:"contacts",title:"Contacts - Domma CMS"},{path:"/calls/new",view:"callNew",title:"Call now - Domma CMS"},{path:"/system/notifications",view:"notifications",title:"Notifications - Domma CMS"},{path:"/api-tokens",view:"apiTokens",title:"API Tokens - Domma CMS"},{path:"/api-endpoints",view:"apiEndpoints",title:"API Builder - Domma CMS"},{path:"/api-endpoints/new",view:"apiEndpointEditor",title:"New API Endpoint - Domma CMS"},{path:"/api-endpoints/edit/:id",view:"apiEndpointEditor",title:"Edit API Endpoint - Domma CMS"},{path:"/projects",view:"projects",title:"Projects - Domma CMS"},{path:"/projects/new",view:"projects",title:"New Project - Domma CMS"},{path:"/projects/edit/:slug",view:"projects",title:"Edit Project - Domma CMS"},{path:"/projects/:slug/settings",view:"projectSettings",title:"Project settings - Domma CMS"},{path:"/projects/:slug/pages",view:"pages",title:"Project pages - Domma CMS"},{path:"/projects/:slug/collections",view:"collections",title:"Project collections - Domma CMS"},{path:"/projects/:slug/forms",view:"forms",title:"Project forms - Domma CMS"},{path:"/projects/:slug/actions",view:"actionsList",title:"Project actions - Domma CMS"},{path:"/projects/:slug/menus",view:"menus",title:"Project menus - Domma CMS"},{path:"/projects/:slug/blocks",view:"blocks",title:"Project blocks - Domma CMS"},{path:"/projects/:slug/components",view:"components",title:"Project components - Domma CMS"},{path:"/projects/:slug/views",view:"viewsList",title:"Project views - Domma CMS"},{path:"/projects/:slug/roles",view:"roles",title:"Project roles - Domma CMS"},{path:"/projects/:slug/users",view:"users",title:"Project users - Domma CMS"},{path:"/projects/:slug/apis",view:"apiEndpoints",title:"Project APIs - Domma CMS"},{path:"/projects/:slug",view:"projectDetail",title:"Project - Domma CMS"},{path:"/login",view:"login",title:"Sign in - Domma CMS",onEnter:()=>{$("#admin-sidebar").hide(),$("#admin-topbar").hide()}},{path:"/reset-password",view:"login",title:"Reset Password - Domma CMS",onEnter:()=>{$("#admin-sidebar").hide(),$("#admin-topbar").hide()}}];M.subscribe("router:afterChange",async({to:t,from:i})=>{if(!C(t.path)){if($("#admin-sidebar").show(),$("#admin-topbar").show(),C(i?.path)){$("#topbar-user-name").remove(),import("./lib/admin-theme.js").then(o=>o.refreshAdminTheme(r)),await T();const e=await f(),a=D(t.path);if(a&&R.navigate(a),j(e),wt.read().signInToasts)try{const o=await r.system.notifications.list().catch(()=>[]),n=(Array.isArray(o)?o:[]).filter(s=>s.unread&&["warning","critical"].includes(s.data?.severity)).slice(0,3);for(const s of n){const l=d(s.data?.title||""),x=d((s.data?.body||"").slice(0,120));E.toast(`${l} - ${x}`,{type:s.data?.severity==="critical"?"error":"warning",duration:0})}}catch{}}V()}}),M.subscribe("router:afterChange",()=>{setTimeout(()=>{$(".btn-primary, .btn-danger").length&&Domma.effects.reveal(".btn-primary, .btn-danger",{animation:"fade",stagger:40,duration:300})},50)});const G=["#field-project","#menu-project","#collection-project","#endpoint-project","#action-project","#view-project","#block-project","#component-project","#role-project",'[name="project"]','[name="ownedByProject"]'];function J(t){return/^\/(pages|menus|context-menus|collections|forms|actions|views|blocks|components|users|roles|api-endpoints)\/(new|edit\/)/.test(t)}M.subscribe("router:afterChange",({to:t})=>{const i=t?String(t.path).split("?")[0]:"";if(!t||!J(i))return;const a=new URLSearchParams(location.hash.split("?")[1]||"").get("project");if(!a||!/\/new$/.test(i))return;let o=0;const n=60,s=1500,l=()=>{o+=n;for(const x of G){const b=document.querySelector(x);if(!b)continue;if(Array.from(b.options||[]).find(Y=>Y.value===a)){b.value=a,b.dispatchEvent(new Event("change",{bubbles:!0}));return}}o<s&&setTimeout(l,n)};setTimeout(l,n)});const F="cms_card_states",k=S.get(F)||{};M.subscribe("router:afterChange",()=>{setTimeout(()=>{$("#view-container .card-collapsible").each(function(){const t=$(this).find(".card-header h2, .card-header h3").first().text().trim();t&&k[t]==="collapsed"&&$(this).addClass("card-collapsed")})},200)}),$("#view-container").on("click",".card-collapsible .card-header",function(t){if($(t.target).closest("button, a").length)return;const i=$(this).closest(".card");i.toggleClass("card-collapsed");const e=$(this).find("h2, h3").first().text().trim();e&&(k[e]=i.hasClass("card-collapsed")?"collapsed":"open",S.set(F,k))}),St(),document.addEventListener("keydown",t=>{if(!(t.ctrlKey||t.metaKey)||t.key!=="s"||window.location.hash.startsWith("#/login")||window.location.hash.startsWith("#/reset-password"))return;const i=document.querySelector("#view-container .view-header button.btn-primary");i&&(t.preventDefault(),i.click())});const v=tt(),O=v.views,K={notes:{displayName:"Notes",icon:"edit-3"},todo:{displayName:"Todo",icon:"check-square"},calculator:{displayName:"Calculator",icon:"calculator"},analytics:{displayName:"Analytics",icon:"chart-bar"},seo:{displayName:"SEO",icon:"search"},wordpressImport:{displayName:"Import from WordPress",icon:"download"},contacts:{displayName:"Contacts",icon:"users"},projects:{displayName:"Projects",icon:"folder"},pages:{displayName:"Pages",icon:"file-text"},media:{displayName:"Media",icon:"image"},menus:{displayName:"Site menus",icon:"menu"},contextMenus:{displayName:"Context Menus",icon:"menu"},theme:{displayName:"Theme",icon:"droplet"},collections:{displayName:"Collections",icon:"database"},forms:{displayName:"Forms",icon:"layout"},viewsList:{displayName:"Views",icon:"eye"},actionsList:{displayName:"Actions",icon:"zap"},apiEndpoints:{displayName:"API Builder",icon:"code"},blocks:{displayName:"Blocks",icon:"box"},components:{displayName:"Components",icon:"component"},notifications:{displayName:"Notifications",icon:"bell"},roles:{displayName:"Roles",icon:"shield"},users:{displayName:"Users",icon:"users"},appearance:{displayName:"Appearance",icon:"layout"},footer:{displayName:"Footer",icon:"panel-bottom"},settings:{displayName:"Site Settings",icon:"settings"},effects:{displayName:"Effects",icon:"sparkles"},layouts:{displayName:"Layouts",icon:"layout"},plugins:{displayName:"Marketplace",icon:"store"},myProfile:{displayName:"My Profile",icon:"user"},apiTokens:{displayName:"API Tokens",icon:"key"},search:{displayName:"Search",icon:"search"},contentApi:{displayName:"Content API",icon:"file-text"},dashboard:{displayName:"Dashboard",icon:"home"},dashboards:{displayName:"Dashboards",icon:"home"},pageEditor:{displayName:"Pages",section:"Edit",icon:"file-text"},menuEditor:{displayName:"Site menus",section:"Edit",icon:"menu"},menuLocations:{displayName:"Site menus",section:"Locations",icon:"map-pin"},contextMenuEditor:{displayName:"Context Menus",section:"Edit",icon:"menu"},collectionEditor:{displayName:"Collections",section:"Edit",icon:"database"},collectionEntries:{displayName:"Collections",section:"Entries",icon:"database"},formEditor:{displayName:"Forms",section:"Edit",icon:"layout"},formSubmissions:{displayName:"Forms",section:"Submissions",icon:"inbox"},viewEditor:{displayName:"Views",section:"Edit",icon:"eye"},viewPreview:{displayName:"Views",section:"Preview",icon:"eye"},actionEditor:{displayName:"Actions",section:"Edit",icon:"zap"},apiEndpointEditor:{displayName:"API Builder",section:"Edit",icon:"code"},roleEditor:{displayName:"Roles",section:"Edit",icon:"shield"},userEditor:{displayName:"Users",section:"Edit",icon:"users"},projectDetail:{displayName:"Projects",section:"Overview",icon:"folder"},projectSettings:{displayName:"Projects",section:"Settings",icon:"folder"},pluginCode:{displayName:"Marketplace",section:"Code",icon:"code"}};for(const[t,i]of Object.entries(Z))v.register(t,async()=>{let e=await i();const a=K[t];return a&&(e=_(e,{plugin:t,licence:"Built in",...a})),t==="dashboard"?H(e):e});R.use(async(t,i,e)=>{try{await v.load(t.view)}catch(a){console.error("[admin] Screen failed to load",a),O[t.view]={template:'<p role="alert">This screen could not load. Reload the page to try again.</p>'}}e()});const I=[...z];async function T(){if(m())try{const t=await r.plugins.adminConfig(),i=new Set(I.map(e=>e.path));for(const e of t.routes||[])i.has(e.path)||I.push(e);for(const[e,a]of Object.entries(t.views||{})){const o=(t.meta||{})[e];v.register(e,async()=>{const s=(await import(`/plugins/${a.entry}`))[a.exportName];if(!s)throw new Error(`Missing plugin screen: ${e}`);const l=_(s,o);return e==="dashboard"?H(l):l},JSON.stringify([a,o]))}for(const[e,{route:a}]of Object.entries(t.takeovers||{}))a&&(y[`/${e}`]=a);for(const[e,{enabled:a,displayName:o}]of Object.entries(t.tools||{}))a===!1&&(P[`/${e}`]=o);for(const{id:e,href:a}of t.css||[])if(!document.getElementById(e)){const o=document.createElement("link");o.id=e,o.rel="stylesheet",o.href=a,document.head.appendChild(o)}}catch{}}function V(){const t=L();if(!t)return;if($("#topbar-user-name").length){B(r);return}const e={"super-admin":"Super Admin",admin:"Admin",user:"User"}[t.role]||t.role,a=gt(t);$("#topbar-user").get(0).innerHTML=`
2
2
  <a id="topbar-project" class="topbar-action-link topbar-project" hidden>
3
3
  <span data-icon="folder"></span>
4
4
  <span id="topbar-project-name" class="topbar-project-name"></span>
@@ -32,7 +32,7 @@ import{wireNotificationMenu as Q}from"./lib/topbar-notifications.js";import{inst
32
32
  </button>
33
33
  <div id="topbar-account-menu" class="topbar-account-menu" hidden>
34
34
  <div class="topbar-account-identity">
35
- ${i?`<img id="topbar-avatar" class="topbar-avatar" src="${d(i)}" alt="">`:""}
35
+ ${a?`<img id="topbar-avatar" class="topbar-avatar" src="${d(a)}" alt="">`:""}
36
36
  <span id="topbar-user-name" class="topbar-user-name">${d(t.name)}</span>
37
37
  <span class="topbar-role-badge topbar-role-badge--${d(t.role)}">${d(e)}</span>
38
38
  </div>
@@ -50,4 +50,4 @@ import{wireNotificationMenu as Q}from"./lib/topbar-notifications.js";import{inst
50
50
  </a>
51
51
  </div>
52
52
  </div>
53
- `;const o=$("#topbar-bell").get(0);o&&(o.hidden=!0);const n=$("#topbar-settings").get(0);n&&(n.hidden=!w),$("#topbar-logout-btn").on("click",s=>{s.preventDefault(),et()}),Domma.icons.scan("#admin-topbar"),E.tooltip("#topbar-actions [data-tooltip]",{placement:"bottom"}),mt(t),Q({refreshBadge:U}),ft(t),W(),ct(),B(r),U(),u||(u=setInterval(U,6e4))}function d(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}let u=null;async function U(){if(!(!m()||g===!1))try{const{count:t}=await r.system.notifications.unreadCount();$("#topbar-bell").removeAttr("hidden");const a=$("#topbar-bell-badge");t>0?a.text(t>99?"99+":String(t)).removeAttr("hidden"):a.attr("hidden","").text(""),t>0&&ht()&&ut(await r.system.notifications.list().catch(()=>[]))}catch{}}(async()=>{if(!m()&&!window.location.hash.startsWith("#/reset-password"))window.location.hash.startsWith("#/login")||(window.location.hash=ot(window.location.hash));else{at(L()?.id);const i=L(),[o]=await Promise.all([i?f():Promise.resolve([]),T()]);if(i){const n=(window.location.hash||"#/").slice(1)||"/",s=D(n);s&&(window.location.hash=`#${s}`),j(o).catch(l=>console.error("[admin] Sidebar failed to load",l)),V()}}const t=R._extractParams.bind(R);R._extractParams=function(i,o){const n=o.indexOf("?");if(n!==-1&&(o=o.slice(0,n)),i.endsWith("/*")){const s=i.slice(0,-2);return o.startsWith(s+"/")?{}:null}return t(i,o)};const a=R._renderNotFound.bind(R);let e="";R._renderNotFound=async function(i){return m()&&e!==i&&(e=i,await T(),R._matchRoute(i).route)?(e="",R._handleRouteChange()):(e="",m()&&$("#admin-sidebar").get(0)?.style.display==="none"?(E.toast("That link goes nowhere - here is your home page.",{type:"warning"}),R.navigate("/")):a(i))},Ct(R),R.init({container:"#view-container",routes:I,views:O,default:"/",transitions:{enter:"fadeIn",leave:"fadeOut",duration:150}})})()});
53
+ `;const o=$("#topbar-bell").get(0);o&&(o.hidden=!0);const n=$("#topbar-settings").get(0);n&&(n.hidden=!w),$("#topbar-logout-btn").on("click",s=>{s.preventDefault(),et()}),Domma.icons.scan("#admin-topbar"),E.tooltip("#topbar-actions [data-tooltip]",{placement:"bottom"}),mt(t),Q({refreshBadge:U}),ft(t),W(),ct(),B(r),U(),u||(u=setInterval(U,6e4))}function d(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}let u=null;async function U(){if(!(!m()||g===!1))try{const{count:t}=await r.system.notifications.unreadCount();$("#topbar-bell").removeAttr("hidden");const i=$("#topbar-bell-badge");t>0?i.text(t>99?"99+":String(t)).removeAttr("hidden"):i.attr("hidden","").text(""),t>0&&ht()&&ut(await r.system.notifications.list().catch(()=>[]))}catch{}}(async()=>{if(!m()&&!window.location.hash.startsWith("#/reset-password"))window.location.hash.startsWith("#/login")||(window.location.hash=ot(window.location.hash));else{it(L()?.id);const a=L(),[o]=await Promise.all([a?f():Promise.resolve([]),T()]);if(a){const n=(window.location.hash||"#/").slice(1)||"/",s=D(n);s&&(window.location.hash=`#${s}`),j(o).catch(l=>console.error("[admin] Sidebar failed to load",l)),V()}}const t=R._extractParams.bind(R);R._extractParams=function(a,o){const n=o.indexOf("?");if(n!==-1&&(o=o.slice(0,n)),a.endsWith("/*")){const s=a.slice(0,-2);return o.startsWith(s+"/")?{}:null}return t(a,o)};const i=R._renderNotFound.bind(R);let e="";R._renderNotFound=async function(a){return m()&&e!==a&&(e=a,await T(),R._matchRoute(a).route)?(e="",R._handleRouteChange()):(e="",m()&&$("#admin-sidebar").get(0)?.style.display==="none"?(E.toast("That link goes nowhere - here is your home page.",{type:"warning"}),R.navigate("/")):i(a))},Ct(R),R.init({container:"#view-container",routes:I,views:O,default:"/",transitions:{enter:"fadeIn",leave:"fadeOut",duration:150}})})()});
@@ -1 +1 @@
1
- export const CONTEXT_ACTION_HELP={navigate:"Open the destination entered in URL in the current browser tab. Use a site path for an internal page or an allowed full address for an external destination. This action does not depend on the element that was right-clicked. The item label and icon are set separately.",reload:"Reload the current page, like the browser Reload button. This refreshes the whole page rather than just a collection display. Any unsaved input may be lost according to the page own leave-page behaviour. No argument is needed.",back:"Go to the previous entry in the visitor browser history. This follows their browsing history, rather than a fixed parent page. The item is greyed out when there is no earlier history entry. Use Go to a URL instead when the destination must always be the same.",forward:"Move forward in the visitor browser history after they have navigated back. It is normally greyed out on an ordinary page load, because the browser does not expose a reliable forward-history position. No destination is configured here; it follows the visitor history.",print:"Open the browser print dialog for the current page. The visitor chooses the printer or a PDF destination where supported. Page print styles determine the printed layout. This does not automatically print, export collection data or save a document on the server.","copy-link":"Copy the current page URL to the clipboard, including its query string and fragment. This copies the address of the view, rather than the URL of a link under the pointer. The browser must allow clipboard access; a message reports whether copying succeeded.","site-search":"Open the built-in site search interface, whether its trigger is in the navbar or floating on the page. This searches the site rather than the nearest collection display. The item is greyed out when site search is unavailable. Configure its behaviour under Site Settings > Search.",copy:"Copy the currently selected text from the page or the editable field that was right-clicked. The item is greyed out when nothing is selected. It copies plain text rather than the entire entry or page. Clipboard access must be allowed by the browser.",cut:"Copy the selected text from the editable field that was right-clicked, then remove that selection from the field. The item is greyed out without a selection or outside an editable field. Read-only and disabled fields do not qualify. The text is removed only after clipboard copying succeeds.",paste:"Insert clipboard text at the selection or caret in the editable field that was right-clicked. This is unavailable outside editable fields. Browsers may refuse clipboard reads or ask for permission; if paste is blocked, the visitor is prompted to use Ctrl+V. It does not upload files or paste rich formatting.","select-all":"Select the contents of the editable field that was right-clicked. Outside a field, select the nearest collection region or page body. This selects text for a later operation; it does not automatically copy it, select collection records for a bulk action or change stored data.",filter:"Request filtering in the collection display that was right-clicked. The optional Field identifies a field to focus on; leave it empty for the display normal filter flow. This is greyed out outside a collection display. It affects the view, rather than changing or deleting entries.",search:"Open search for the collection display that was right-clicked. It narrows that display rather than searching the entire website. The item is greyed out outside a compatible collection display. No extra argument is needed. Use Open site search for a site-wide search interface.",sort:"Request sorting in the collection display that was right-clicked. The optional Field supplies the field name, such as price; leave it empty to use the display sorting flow. The item is greyed out outside a collection display. This changes presentation order, not the saved values in the entries.",export:"Request an export from the collection display that was right-clicked. Format supplies the requested export type, such as csv, subject to what that display supports. Leave it empty for its normal export choice. This is greyed out outside a collection display and does not export the entire website.","mark-as-spam":"Mark the collection entry under the right-click as spam. This requires an actual entry inside a collection display and permission to update collections. Flag field optionally supplies the marker field; leave it empty for the normal spam field. This writes to the entry. A red Destructive style alone does not add confirmation or permissions.","open-modal":"Render an existing content block and open it in a modal over the current page. Enter its saved Block name, such as contact-card. The block can provide content or a form without navigating away. It must be available to the visitor; this option does not create a new block.","run-action":"Run the saved CMS Action named by Action slug against the entry that was right-clicked. The click must be within an element carrying an entry ID. The visitor must be signed in and allowed by the Action Who can run it rule. The Action determines the changes made; choosing this menu item does not bypass its permissions."};
1
+ export const CONTEXT_ACTION_HELP={navigate:"Open the destination entered in URL in the current browser tab. Use a site path for an internal page or an allowed full address for an external destination. This action does not depend on the element that was right-clicked. The item label and icon are set separately.",reload:"Reload the current page, like the browser Reload button. This refreshes the whole page rather than just a collection display. Any unsaved input may be lost according to the page own leave-page behaviour. No argument is needed.",back:"Go to the previous entry in the visitor browser history. This follows their browsing history, rather than a fixed parent page. The item is greyed out when there is no earlier history entry. Use Go to a URL instead when the destination must always be the same.",forward:"Move forward in the visitor browser history after they have navigated back. It is normally greyed out on an ordinary page load, because the browser does not expose a reliable forward-history position. No destination is configured here; it follows the visitor history.",print:"Open the browser print dialog for the current page. The visitor chooses the printer or a PDF destination where supported. Page print styles determine the printed layout. This does not automatically print, export collection data or save a document on the server.","copy-link":"Copy the current page URL to the clipboard, including its query string and fragment. This copies the address of the view, rather than the URL of a link under the pointer. The browser must allow clipboard access; a message reports whether copying succeeded.","site-search":"Open the built-in site search interface, whether its trigger is in the navbar or floating on the page. This searches the site rather than the nearest collection display. The item is greyed out when site search is unavailable. Configure its behaviour under Appearance > Search.",copy:"Copy the currently selected text from the page or the editable field that was right-clicked. The item is greyed out when nothing is selected. It copies plain text rather than the entire entry or page. Clipboard access must be allowed by the browser.",cut:"Copy the selected text from the editable field that was right-clicked, then remove that selection from the field. The item is greyed out without a selection or outside an editable field. Read-only and disabled fields do not qualify. The text is removed only after clipboard copying succeeds.",paste:"Insert clipboard text at the selection or caret in the editable field that was right-clicked. This is unavailable outside editable fields. Browsers may refuse clipboard reads or ask for permission; if paste is blocked, the visitor is prompted to use Ctrl+V. It does not upload files or paste rich formatting.","select-all":"Select the contents of the editable field that was right-clicked. Outside a field, select the nearest collection region or page body. This selects text for a later operation; it does not automatically copy it, select collection records for a bulk action or change stored data.",filter:"Request filtering in the collection display that was right-clicked. The optional Field identifies a field to focus on; leave it empty for the display normal filter flow. This is greyed out outside a collection display. It affects the view, rather than changing or deleting entries.",search:"Open search for the collection display that was right-clicked. It narrows that display rather than searching the entire website. The item is greyed out outside a compatible collection display. No extra argument is needed. Use Open site search for a site-wide search interface.",sort:"Request sorting in the collection display that was right-clicked. The optional Field supplies the field name, such as price; leave it empty to use the display sorting flow. The item is greyed out outside a collection display. This changes presentation order, not the saved values in the entries.",export:"Request an export from the collection display that was right-clicked. Format supplies the requested export type, such as csv, subject to what that display supports. Leave it empty for its normal export choice. This is greyed out outside a collection display and does not export the entire website.","mark-as-spam":"Mark the collection entry under the right-click as spam. This requires an actual entry inside a collection display and permission to update collections. Flag field optionally supplies the marker field; leave it empty for the normal spam field. This writes to the entry. A red Destructive style alone does not add confirmation or permissions.","open-modal":"Render an existing content block and open it in a modal over the current page. Enter its saved Block name, such as contact-card. The block can provide content or a form without navigating away. It must be available to the visitor; this option does not create a new block.","run-action":"Run the saved CMS Action named by Action slug against the entry that was right-clicked. The click must be within an element carrying an entry ID. The visitor must be signed in and allowed by the Action Who can run it rule. The Action determines the changes made; choosing this menu item does not bypass its permissions."};
@@ -1,3 +1,3 @@
1
- import{findEnclosingShortcode as j}from"./shortcode-tags.js";import{encodeMessageAttribute as x,decodeMessageAttribute as O}from"../../../public/js/celebrations/message-attrs.mjs";import{EFFECTS as k,effectsByCategory as N,effectsInjectableInto as B,getEffect as u,getEffectAttrs as g}from"./effect-defs.js";import{scribeLoop as q}from"./scribe-model.js";import{buildScribeStyle as P}from"../../../public/js/scribe-style.mjs?v=20261029-all-cms-fonts";import{insertAtCursor as M,replaceRange as T}from"./markdown-toolbar.js";let h=null,b=null;function F(e,t,o=14){e.textContent="";const n=document.createElement("span");return n.setAttribute("data-icon",t),n.setAttribute("data-icon-size",String(o)),n.style.cssText="display:inline-flex;align-items:center;vertical-align:middle;",e.appendChild(n),I.scan(e),e}function D(e,t,o,n=14){return F(e,t,n),e.appendChild(document.createTextNode(" "+o)),e}export const EffectsBuilder={open(e){if(h)return;const t={textarea:e,activeEffect:S.get("effects-builder-last")||"reveal",scope:"standalone",host:null,editing:null,fieldValues:{}};if(t.host=G(e),t.host&&B(t.host.name).map(r=>r.name).includes(t.activeEffect)&&!(t.activeEffect in t.host.attrs)&&(t.scope="inject"),t.editing=W(e),t.editing){t.activeEffect=t.editing.name,t.scope="standalone";const c=u(t.editing.name);for(const r of g(c,t.fieldValues))if(r.name in t.editing.attrs){const l=t.editing.attrs[r.name];r.type==="number"?t.fieldValues[r.name]=Number(l):r.type==="checkbox"?t.fieldValues[r.name]=l==="true":t.fieldValues[r.name]=l}}const o=E.slideover({title:"Effects",size:"lg",position:"right",onClose:()=>{b?.destroy(),b=null,h=null}}),n=H(t,o);o.element.appendChild(n),o.open(),I.scan(n),h={state:t,slideover:o}},close(){h&&(h.slideover.close(),h=null)}};function H(e,t){const o=document.createElement("div");o.style.cssText="display:grid;grid-template-columns:170px 1fr;height:100%;min-height:520px;";const n=document.createElement("div");n.className="effects-rail",n.style.cssText="background:var(--dm-background-alt,#15152a);border-right:1px solid var(--dm-border,#2a2a40);padding:.5rem .35rem;font-size:.8rem;overflow-y:auto;";const c=document.createElement("div");c.className="effects-pane",c.style.cssText="padding:1rem;display:flex;flex-direction:column;gap:.75rem;overflow-y:auto;";function r(){Q(c,e,t)}return $(n,e,r),r(),o.appendChild(n),o.appendChild(c),o}function $(e,t,o){e.replaceChildren();for(const n of N()){const c=document.createElement("div");c.style.cssText="color:var(--dm-text-muted,#888);text-transform:uppercase;font-size:.65rem;letter-spacing:.05em;margin:.4rem .35rem .25rem;",c.textContent=n.category,e.appendChild(c);for(const r of n.effects){const l=document.createElement("button");l.type="button",l.dataset.effect=r.name,l.style.cssText="display:block;width:100%;text-align:left;padding:.3rem .5rem;border:none;background:transparent;color:var(--dm-text,#ddd);border-radius:3px;font-size:.8rem;cursor:pointer;margin-bottom:.1rem;",l.textContent=r.label,r.name===t.activeEffect&&(l.style.background="var(--dm-primary,#4338ca)",l.style.color="var(--dm-primary-text,#fff)"),l.addEventListener("click",()=>{t.activeEffect=r.name,S.set("effects-builder-last",r.name),t.fieldValues={},$(e,t,o),o()}),e.appendChild(l)}}}function K(e,t){if(e.type==="select"){const n=document.createElement("select");n.style.cssText="width:100%;padding:.35rem .5rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:3px;color:var(--dm-text,#eee);font-size:.85rem;";for(const[c,r]of e.options){const l=document.createElement("option");l.value=c,l.textContent=r,n.appendChild(l)}return n.value=t??e.default??"",n}if(e.type==="checkbox"){const n=document.createElement("input");return n.type="checkbox",n.checked=t??e.default??!1,n}const o=document.createElement("input");return o.type=e.type==="number"?"number":e.type==="colour"?"color":"text",o.value=t??e.default??"",e.placeholder&&(o.placeholder=e.placeholder),e.type==="number"&&(e.min!=null&&(o.min=e.min),e.max!=null&&(o.max=e.max),e.step!=null&&(o.step=e.step)),o.style.cssText="width:100%;padding:.35rem .5rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:3px;color:var(--dm-text,#eee);font-size:.85rem;",o}function w(e,t){return t.type==="checkbox"?e.checked:t.type==="number"?e.value===""?"":Number(e.value):e.value}function y(e,t,o){const n=u(t.activeEffect);if(e.replaceChildren(),n.attrs.length===0){const r=document.createElement("div");r.style.cssText="color:var(--dm-text-muted,#888);font-size:.8rem;font-style:italic;",r.textContent="This effect takes no parameters.",e.appendChild(r);return}const c=document.createElement("div");c.style.cssText="display:grid;grid-template-columns:1fr 1fr;gap:.6rem .7rem;";for(const r of g(n,t.fieldValues)){const l=document.createElement("div"),d=document.createElement("label");d.style.cssText="display:block;color:var(--dm-text-muted,#888);font-size:.7rem;text-transform:uppercase;letter-spacing:.05em;margin-bottom:.2rem;",d.textContent=r.label,l.appendChild(d);const i=K(r,t.fieldValues[r.name]);if(i.addEventListener("input",()=>{t.fieldValues[r.name]=w(i,r),o(),r.name==="theme"&&y(e,t,o)}),i.addEventListener("change",()=>{t.fieldValues[r.name]=w(i,r),o(),r.name==="theme"&&y(e,t,o)}),l.appendChild(i),r.hint){const s=document.createElement("div");s.style.cssText="color:var(--dm-text-muted,#666);font-size:.7rem;margin-top:.15rem;",s.textContent=r.hint,l.appendChild(s)}c.appendChild(l)}e.appendChild(c)}function _(e){const t={},o=/(\w[\w-]*)(?:\s*=\s*"([^"]*)"|\s*=\s*'([^']*)'|\s*=\s*(\S+))?/g;for(const n of e.matchAll(o)){const c=n[1],r=n[2]??n[3]??n[4]??"";t[c]=c==="message"?O(r):r}return t}const U=k.filter(e=>!e.selfClosing).map(e=>e.name);function W(e){const t=j(e,k.filter(c=>c.selfClosing));if(t?.selfClosing)return{name:t.name,blockStart:t.openTagStart,blockEnd:t.openTagEnd,openTagEnd:t.openTagEnd,attrs:t.attrs};const o=e.value,n=e.selectionStart;for(const c of U){const r=new RegExp(`\\[${c}([^\\]]*)\\]`,"g"),l=new RegExp(`\\[/${c}\\]`,"g"),d=[];for(const a of o.matchAll(r)){if(a.index>=n)break;d.push({type:"open",start:a.index,end:a.index+a[0].length,attrStr:a[1]})}for(const a of o.matchAll(l)){if(a.index>=n)break;d.push({type:"close",start:a.index,end:a.index+a[0].length})}d.sort((a,m)=>a.start-m.start);let i=0,s=null;for(const a of d)a.type==="open"?(i++,s=a):(i--,i<0&&(i=0,s=null));if(i>0&&s){const a=new RegExp(`\\[/${c}\\]`,"g"),m=o.slice(n),f=m.match(a);if(f){const p=n+m.indexOf(f[0]);return{name:c,blockStart:s.start,blockEnd:p+f[0].length,openTagEnd:s.end,attrs:_(s.attrStr)}}}}return null}const X=["card","box","hero","banner","col","button"];function G(e){const t=e.value,o=e.selectionStart;for(const n of X){const c=new RegExp(`\\[${n}([^\\]]*)\\]`,"g"),r=new RegExp(`\\[/${n}\\]`,"g"),l=[];for(const s of t.matchAll(c)){if(s.index>=o)break;l.push({type:"open",start:s.index,end:s.index+s[0].length,attrStr:s[1]})}for(const s of t.matchAll(r)){if(s.index>=o)break;l.push({type:"close",start:s.index,end:s.index+s[0].length})}l.sort((s,a)=>s.start-a.start);let d=0,i=null;for(const s of l)s.type==="open"?(d++,i=s):(d--,d<0&&(d=0,i=null));if(d>0&&i){const s=new RegExp(`\\[/${n}\\]`,"g"),a=t.slice(o),m=a.match(s);if(m){const f=o+a.indexOf(m[0]);return{name:n,openTagStart:i.start,openTagEnd:i.end,closeTagStart:f,closeTagEnd:f+m[0].length,attrs:_(i.attrStr)}}}}return null}function z(e,t){const o=[];for(const n of g(t,e.fieldValues)){const c=e.fieldValues[n.name];c===void 0||c===""||c===null||c===n.default&&!n.always||(n.type==="checkbox"?o.push(`${n.name}="${c?"true":"false"}"`):o.push(`${n.name}="${n.name==="message"?x(c):String(c).replace(/"/g,"&quot;")}"`))}return o.join(" ")}function A(e){const t=u(e.activeEffect),o=z(e,t),n=o?" ":"";if(e.scope==="inject"&&e.host){const c=e.host.attrs,r=t.name,l=[];for(const d of Object.keys(c)){if(d===r||d.startsWith(r+"-"))continue;const i=c[d];l.push(i===""?d:`${d}="${attr.name==="message"?x(i):String(i).replace(/"/g,"&quot;")}"`)}l.push(r);for(const d of g(t,e.fieldValues)){const i=e.fieldValues[d.name];if(i===void 0||i===""||i===null||i===d.default)continue;const s=d.type==="checkbox"?i?"true":"false":d.name==="message"?x(i):String(i).replace(/"/g,"&quot;");l.push(`${r}-${d.name}="${s}"`)}return`[${e.host.name} ${l.join(" ")}]\u2026[/${e.host.name}]`}return t.selfClosing?`[${t.name}${n}${o} /]`:`[${t.name}${n}${o}]
1
+ import{enhanceFontSelect as j}from"./font-picker.js";import{findEnclosingShortcode as O}from"./shortcode-tags.js";import{encodeMessageAttribute as x,decodeMessageAttribute as N}from"../../../public/js/celebrations/message-attrs.mjs";import{EFFECTS as k,effectsByCategory as B,effectsInjectableInto as q,getEffect as u,getEffectAttrs as g}from"./effect-defs.js";import{scribeLoop as P}from"./scribe-model.js";import{buildScribeStyle as F}from"../../../public/js/scribe-style.mjs?v=20261029-all-cms-fonts";import{insertAtCursor as M,replaceRange as T}from"./markdown-toolbar.js";let h=null,b=null;function D(e,t,r=14){e.textContent="";const o=document.createElement("span");return o.setAttribute("data-icon",t),o.setAttribute("data-icon-size",String(r)),o.style.cssText="display:inline-flex;align-items:center;vertical-align:middle;",e.appendChild(o),I.scan(e),e}function H(e,t,r,o=14){return D(e,t,o),e.appendChild(document.createTextNode(" "+r)),e}export const EffectsBuilder={open(e){if(h)return;const t={textarea:e,activeEffect:S.get("effects-builder-last")||"reveal",scope:"standalone",host:null,editing:null,fieldValues:{}};if(t.host=J(e),t.host&&q(t.host.name).map(n=>n.name).includes(t.activeEffect)&&!(t.activeEffect in t.host.attrs)&&(t.scope="inject"),t.editing=X(e),t.editing){t.activeEffect=t.editing.name,t.scope="standalone";const c=u(t.editing.name);for(const n of g(c,t.fieldValues))if(n.name in t.editing.attrs){const l=t.editing.attrs[n.name];n.type==="number"?t.fieldValues[n.name]=Number(l):n.type==="checkbox"?t.fieldValues[n.name]=l==="true":t.fieldValues[n.name]=l}}const r=E.slideover({title:"Effects",size:"lg",position:"right",onClose:()=>{b?.destroy(),b=null,h=null}}),o=K(t,r);r.element.appendChild(o),r.open(),I.scan(o),h={state:t,slideover:r}},close(){h&&(h.slideover.close(),h=null)}};function K(e,t){const r=document.createElement("div");r.style.cssText="display:grid;grid-template-columns:170px 1fr;height:100%;min-height:520px;";const o=document.createElement("div");o.className="effects-rail",o.style.cssText="background:var(--dm-background-alt,#15152a);border-right:1px solid var(--dm-border,#2a2a40);padding:.5rem .35rem;font-size:.8rem;overflow-y:auto;";const c=document.createElement("div");c.className="effects-pane",c.style.cssText="padding:1rem;display:flex;flex-direction:column;gap:.75rem;overflow-y:auto;";function n(){Y(c,e,t)}return $(o,e,n),n(),r.appendChild(o),r.appendChild(c),r}function $(e,t,r){e.replaceChildren();for(const o of B()){const c=document.createElement("div");c.style.cssText="color:var(--dm-text-muted,#888);text-transform:uppercase;font-size:.65rem;letter-spacing:.05em;margin:.4rem .35rem .25rem;",c.textContent=o.category,e.appendChild(c);for(const n of o.effects){const l=document.createElement("button");l.type="button",l.dataset.effect=n.name,l.style.cssText="display:block;width:100%;text-align:left;padding:.3rem .5rem;border:none;background:transparent;color:var(--dm-text,#ddd);border-radius:3px;font-size:.8rem;cursor:pointer;margin-bottom:.1rem;",l.textContent=n.label,n.name===t.activeEffect&&(l.style.background="var(--dm-primary,#4338ca)",l.style.color="var(--dm-primary-text,#fff)"),l.addEventListener("click",()=>{t.activeEffect=n.name,S.set("effects-builder-last",n.name),t.fieldValues={},$(e,t,r),r()}),e.appendChild(l)}}}function U(e,t){if(e.type==="select"){const o=document.createElement("select");o.style.cssText="width:100%;padding:.35rem .5rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:3px;color:var(--dm-text,#eee);font-size:.85rem;";for(const[c,n]of e.options){const l=document.createElement("option");l.value=c,l.textContent=n,o.appendChild(l)}return o.value=t??e.default??"",o}if(e.type==="checkbox"){const o=document.createElement("input");return o.type="checkbox",o.checked=t??e.default??!1,o}const r=document.createElement("input");return r.type=e.type==="number"?"number":e.type==="colour"?"color":"text",r.value=t??e.default??"",e.placeholder&&(r.placeholder=e.placeholder),e.type==="number"&&(e.min!=null&&(r.min=e.min),e.max!=null&&(r.max=e.max),e.step!=null&&(r.step=e.step)),r.style.cssText="width:100%;padding:.35rem .5rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:3px;color:var(--dm-text,#eee);font-size:.85rem;",r}function w(e,t){return t.type==="checkbox"?e.checked:t.type==="number"?e.value===""?"":Number(e.value):e.value}function y(e,t,r){const o=u(t.activeEffect);if(e.replaceChildren(),o.attrs.length===0){const n=document.createElement("div");n.style.cssText="color:var(--dm-text-muted,#888);font-size:.8rem;font-style:italic;",n.textContent="This effect takes no parameters.",e.appendChild(n);return}const c=document.createElement("div");c.style.cssText="display:grid;grid-template-columns:1fr 1fr;gap:.6rem .7rem;";for(const n of g(o,t.fieldValues)){const l=document.createElement("div"),d=document.createElement("label");d.style.cssText="display:block;color:var(--dm-text-muted,#888);font-size:.7rem;text-transform:uppercase;letter-spacing:.05em;margin-bottom:.2rem;",d.textContent=n.label,l.appendChild(d);const i=U(n,t.fieldValues[n.name]);if(i.addEventListener("input",()=>{t.fieldValues[n.name]=w(i,n),r(),n.name==="theme"&&y(e,t,r)}),i.addEventListener("change",()=>{t.fieldValues[n.name]=w(i,n),r(),n.name==="theme"&&y(e,t,r)}),l.appendChild(i),n.type==="select"&&n.name==="font"&&j(i,{label:n.label}),n.hint){const s=document.createElement("div");s.style.cssText="color:var(--dm-text-muted,#666);font-size:.7rem;margin-top:.15rem;",s.textContent=n.hint,l.appendChild(s)}c.appendChild(l)}e.appendChild(c)}function _(e){const t={},r=/(\w[\w-]*)(?:\s*=\s*"([^"]*)"|\s*=\s*'([^']*)'|\s*=\s*(\S+))?/g;for(const o of e.matchAll(r)){const c=o[1],n=o[2]??o[3]??o[4]??"";t[c]=c==="message"?N(n):n}return t}const W=k.filter(e=>!e.selfClosing).map(e=>e.name);function X(e){const t=O(e,k.filter(c=>c.selfClosing));if(t?.selfClosing)return{name:t.name,blockStart:t.openTagStart,blockEnd:t.openTagEnd,openTagEnd:t.openTagEnd,attrs:t.attrs};const r=e.value,o=e.selectionStart;for(const c of W){const n=new RegExp(`\\[${c}([^\\]]*)\\]`,"g"),l=new RegExp(`\\[/${c}\\]`,"g"),d=[];for(const a of r.matchAll(n)){if(a.index>=o)break;d.push({type:"open",start:a.index,end:a.index+a[0].length,attrStr:a[1]})}for(const a of r.matchAll(l)){if(a.index>=o)break;d.push({type:"close",start:a.index,end:a.index+a[0].length})}d.sort((a,m)=>a.start-m.start);let i=0,s=null;for(const a of d)a.type==="open"?(i++,s=a):(i--,i<0&&(i=0,s=null));if(i>0&&s){const a=new RegExp(`\\[/${c}\\]`,"g"),m=r.slice(o),f=m.match(a);if(f){const p=o+m.indexOf(f[0]);return{name:c,blockStart:s.start,blockEnd:p+f[0].length,openTagEnd:s.end,attrs:_(s.attrStr)}}}}return null}const G=["card","box","hero","banner","col","button"];function J(e){const t=e.value,r=e.selectionStart;for(const o of G){const c=new RegExp(`\\[${o}([^\\]]*)\\]`,"g"),n=new RegExp(`\\[/${o}\\]`,"g"),l=[];for(const s of t.matchAll(c)){if(s.index>=r)break;l.push({type:"open",start:s.index,end:s.index+s[0].length,attrStr:s[1]})}for(const s of t.matchAll(n)){if(s.index>=r)break;l.push({type:"close",start:s.index,end:s.index+s[0].length})}l.sort((s,a)=>s.start-a.start);let d=0,i=null;for(const s of l)s.type==="open"?(d++,i=s):(d--,d<0&&(d=0,i=null));if(d>0&&i){const s=new RegExp(`\\[/${o}\\]`,"g"),a=t.slice(r),m=a.match(s);if(m){const f=r+a.indexOf(m[0]);return{name:o,openTagStart:i.start,openTagEnd:i.end,closeTagStart:f,closeTagEnd:f+m[0].length,attrs:_(i.attrStr)}}}}return null}function z(e,t){const r=[];for(const o of g(t,e.fieldValues)){const c=e.fieldValues[o.name];c===void 0||c===""||c===null||c===o.default&&!o.always||(o.type==="checkbox"?r.push(`${o.name}="${c?"true":"false"}"`):r.push(`${o.name}="${o.name==="message"?x(c):String(c).replace(/"/g,"&quot;")}"`))}return r.join(" ")}function A(e){const t=u(e.activeEffect),r=z(e,t),o=r?" ":"";if(e.scope==="inject"&&e.host){const c=e.host.attrs,n=t.name,l=[];for(const d of Object.keys(c)){if(d===n||d.startsWith(n+"-"))continue;const i=c[d];l.push(i===""?d:`${d}="${attr.name==="message"?x(i):String(i).replace(/"/g,"&quot;")}"`)}l.push(n);for(const d of g(t,e.fieldValues)){const i=e.fieldValues[d.name];if(i===void 0||i===""||i===null||i===d.default)continue;const s=d.type==="checkbox"?i?"true":"false":d.name==="message"?x(i):String(i).replace(/"/g,"&quot;");l.push(`${n}-${d.name}="${s}"`)}return`[${e.host.name} ${l.join(" ")}]\u2026[/${e.host.name}]`}return t.selfClosing?`[${t.name}${o}${r} /]`:`[${t.name}${o}${r}]
2
2
  Content
3
- [/${t.name}]`}function V(e,t){e.replaceChildren();const o=document.createElement("div");o.style.cssText="color:var(--dm-text-muted,#888);font-size:.7rem;text-transform:uppercase;letter-spacing:.05em;margin-bottom:.25rem;",o.textContent="Shortcode (live)",e.appendChild(o);const n=document.createElement("pre");n.style.cssText="background:var(--dm-code-bg,#000);border:1px solid var(--dm-border,#333);padding:.5rem .65rem;border-radius:3px;font-family:var(--dm-font-mono,monospace);font-size:.75rem;color:var(--dm-code-text,#7c6af7);line-height:1.5;white-space:pre-wrap;word-break:break-all;margin:0;",n.textContent=A(t),e.appendChild(n)}function J(e,t,o){if(e.replaceChildren(),t.editing)return;const n=u(t.activeEffect),c=t.host&&n.hosts.includes(t.host.name),r=document.createElement("div");r.style.cssText="background:var(--dm-background-alt,#15152a);border:1px solid var(--dm-border,#2a2a40);border-radius:4px;padding:.5rem .6rem;";const l=document.createElement("div");if(l.style.cssText="color:var(--dm-text-muted,#888);text-transform:uppercase;font-size:.65rem;letter-spacing:.05em;margin-bottom:.3rem;",l.textContent="Apply as",r.appendChild(l),!c){const s=document.createElement("div");s.style.cssText="color:var(--dm-text-muted,#888);font-size:.75rem;font-style:italic;",t.host?s.textContent=`Inserted as a standalone block (${n.label} cannot be injected into [${t.host.name}]).`:s.textContent="Inserted as a standalone block.",r.appendChild(s),e.appendChild(r),t.scope="standalone";return}const d=document.createElement("div");d.style.cssText="display:flex;gap:.3rem;";function i(s,a){const m=document.createElement("button");return m.type="button",m.style.cssText="flex:1;padding:.35rem;border:1px solid var(--dm-border,#333);border-radius:3px;font-size:.75rem;font-weight:600;cursor:pointer;",t.scope===s?(m.style.background="var(--dm-primary,#4338ca)",m.style.color="var(--dm-primary-text,#fff)",m.style.borderColor="var(--dm-primary,#4338ca)"):(m.style.background="transparent",m.style.color="var(--dm-text-muted,#bbb)"),m.textContent=a,m.addEventListener("click",()=>{t.scope=s,o()}),m}d.appendChild(i("standalone","Standalone block")),d.appendChild(i("inject",`Inject into [${t.host.name}]`)),r.appendChild(d),e.appendChild(r)}let C=0;function R(e){return e.replace(/-([a-z])/g,(t,o)=>o.toUpperCase())}function L(e,t){e.replaceChildren();const o=u(t.activeEffect),n=document.createElement("div");n.style.cssText="display:flex;justify-content:space-between;align-items:center;margin-bottom:.25rem;";const c=document.createElement("div");if(c.style.cssText="color:var(--dm-text-muted,#888);text-transform:uppercase;font-size:.65rem;letter-spacing:.05em;",c.textContent="Live preview",n.appendChild(c),!o.previewable){const i=document.createElement("div");i.style.cssText="background:var(--dm-background-alt,#15152a);border:1px solid var(--dm-border,#2a2a40);border-radius:4px;padding:.6rem;color:var(--dm-text-muted,#888);font-size:.8rem;font-style:italic;text-align:center;",i.textContent="Runs full-page on the published site - no inline preview.",e.appendChild(i);return}const r=document.createElement("button");r.type="button",r.style.cssText="background:transparent;border:1px solid var(--dm-border,#333);color:var(--dm-text-muted,#888);font-size:.65rem;padding:.15rem .4rem;border-radius:2px;cursor:pointer;",D(r,"refresh-cw","Replay",12),n.appendChild(r),e.appendChild(n);const l=document.createElement("div");l.style.cssText="background:var(--dm-background-alt,#1a1a2e);border:1px solid var(--dm-border,#2a2a40);border-radius:4px;padding:1rem;text-align:center;min-height:80px;position:relative;overflow:hidden;",e.appendChild(l);function d(i=!1){b?.destroy(),b=null,C++;const s=C;l.replaceChildren();const a=document.createElement("div");a.style.cssText="background:linear-gradient(135deg,#6366f1,#a855f7);color:#fff;padding:.6rem;border-radius:4px;font-size:.8rem;font-weight:600;",a.textContent="Sample content",l.appendChild(a);const m=window.Domma&&window.Domma.effects;if(!m)return;const f={};for(const p of g(o,t.fieldValues)){const v=t.fieldValues[p.name];v===void 0||v===""||v===null||(f[R(p.name)]=v)}o.name==="scribe"&&(a.style.cssText+=";"+P(t.fieldValues),f.loop=q(f.loop??!1),f.actions=[{render:a.textContent,effect:f.effect||"none"}],a.textContent="");try{const p=m[R(o.name)];if(typeof p=="function"){if(s!==C)return;b=p(a,f),i&&b?.resume()}}catch(p){console.warn("Effects preview failed:",p)}}r.addEventListener("click",()=>d(!0)),d()}function Q(e,t,o){const n=u(t.activeEffect);e.replaceChildren();const c=document.createElement("h3");c.style.cssText="margin:0;font-size:1rem;color:var(--dm-text,#eee);",c.textContent=n.label,e.appendChild(c);const r=document.createElement("p");r.style.cssText="margin:0;color:var(--dm-text-muted,#999);font-size:.8rem;line-height:1.4;",r.textContent=n.description,e.appendChild(r);const l=document.createElement("div");e.appendChild(l);const d=document.createElement("div");e.appendChild(d);const i=document.createElement("div");e.appendChild(i);const s=document.createElement("div");e.appendChild(s);function a(){J(l,t,a),y(d,t,()=>{V(i,t),L(s,t)}),V(i,t),L(s,t)}a();const m=document.createElement("div");m.style.cssText="display:flex;gap:.5rem;margin-top:auto;padding-top:.75rem;border-top:1px solid var(--dm-border,#2a2a40);";const f=document.createElement("button");f.type="button",f.className="btn btn-ghost",f.textContent="Cancel",f.addEventListener("click",()=>o.close()),m.appendChild(f);const p=document.createElement("button");p.type="button",p.className="btn btn-primary",p.style.flex="2",p.textContent=t.editing?"Update":"Insert effect",p.addEventListener("click",()=>Y(t,o)),m.appendChild(p),e.appendChild(m)}function Y(e,t){const o=e.textarea,n=A(e);if(e.editing){const c=u(e.editing.name),r=o.value,l=`[/${c.name}]`.length,d=e.editing.openTagEnd,i=e.editing.blockEnd-l,s=r.substring(d,i),a=z(e,c),m=a?" ":"",f=c.selfClosing?`[${c.name}${m}${a} /]`:`[${c.name}${m}${a}]${s}[/${c.name}]`;T(o,e.editing.blockStart,e.editing.blockEnd,f);const p=c.selfClosing?e.editing.blockStart+f.length:e.editing.blockStart+f.indexOf("]")+1;o.setSelectionRange(p,p),t.close();return}if(e.scope==="inject"&&e.host){const c=u(e.activeEffect),r=e.host.attrs,l=c.name,d=[];for(const s of Object.keys(r)){if(s===l||s.startsWith(l+"-"))continue;const a=r[s];d.push(a===""?s:`${s}="${attr.name==="message"?x(a):String(a).replace(/"/g,"&quot;")}"`)}d.push(l);for(const s of g(c,e.fieldValues)){const a=e.fieldValues[s.name];if(a===void 0||a===""||a===null||a===s.default)continue;const m=s.type==="checkbox"?a?"true":"false":s.name==="message"?x(a):String(a).replace(/"/g,"&quot;");d.push(`${l}-${s.name}="${m}"`)}const i=`[${e.host.name} ${d.join(" ")}]`;T(o,e.host.openTagStart,e.host.openTagEnd,i),t.close();return}M(o,n),t.close()}
3
+ [/${t.name}]`}function V(e,t){e.replaceChildren();const r=document.createElement("div");r.style.cssText="color:var(--dm-text-muted,#888);font-size:.7rem;text-transform:uppercase;letter-spacing:.05em;margin-bottom:.25rem;",r.textContent="Shortcode (live)",e.appendChild(r);const o=document.createElement("pre");o.style.cssText="background:var(--dm-code-bg,#000);border:1px solid var(--dm-border,#333);padding:.5rem .65rem;border-radius:3px;font-family:var(--dm-font-mono,monospace);font-size:.75rem;color:var(--dm-code-text,#7c6af7);line-height:1.5;white-space:pre-wrap;word-break:break-all;margin:0;",o.textContent=A(t),e.appendChild(o)}function Q(e,t,r){if(e.replaceChildren(),t.editing)return;const o=u(t.activeEffect),c=t.host&&o.hosts.includes(t.host.name),n=document.createElement("div");n.style.cssText="background:var(--dm-background-alt,#15152a);border:1px solid var(--dm-border,#2a2a40);border-radius:4px;padding:.5rem .6rem;";const l=document.createElement("div");if(l.style.cssText="color:var(--dm-text-muted,#888);text-transform:uppercase;font-size:.65rem;letter-spacing:.05em;margin-bottom:.3rem;",l.textContent="Apply as",n.appendChild(l),!c){const s=document.createElement("div");s.style.cssText="color:var(--dm-text-muted,#888);font-size:.75rem;font-style:italic;",t.host?s.textContent=`Inserted as a standalone block (${o.label} cannot be injected into [${t.host.name}]).`:s.textContent="Inserted as a standalone block.",n.appendChild(s),e.appendChild(n),t.scope="standalone";return}const d=document.createElement("div");d.style.cssText="display:flex;gap:.3rem;";function i(s,a){const m=document.createElement("button");return m.type="button",m.style.cssText="flex:1;padding:.35rem;border:1px solid var(--dm-border,#333);border-radius:3px;font-size:.75rem;font-weight:600;cursor:pointer;",t.scope===s?(m.style.background="var(--dm-primary,#4338ca)",m.style.color="var(--dm-primary-text,#fff)",m.style.borderColor="var(--dm-primary,#4338ca)"):(m.style.background="transparent",m.style.color="var(--dm-text-muted,#bbb)"),m.textContent=a,m.addEventListener("click",()=>{t.scope=s,r()}),m}d.appendChild(i("standalone","Standalone block")),d.appendChild(i("inject",`Inject into [${t.host.name}]`)),n.appendChild(d),e.appendChild(n)}let C=0;function R(e){return e.replace(/-([a-z])/g,(t,r)=>r.toUpperCase())}function L(e,t){e.replaceChildren();const r=u(t.activeEffect),o=document.createElement("div");o.style.cssText="display:flex;justify-content:space-between;align-items:center;margin-bottom:.25rem;";const c=document.createElement("div");if(c.style.cssText="color:var(--dm-text-muted,#888);text-transform:uppercase;font-size:.65rem;letter-spacing:.05em;",c.textContent="Live preview",o.appendChild(c),!r.previewable){const i=document.createElement("div");i.style.cssText="background:var(--dm-background-alt,#15152a);border:1px solid var(--dm-border,#2a2a40);border-radius:4px;padding:.6rem;color:var(--dm-text-muted,#888);font-size:.8rem;font-style:italic;text-align:center;",i.textContent="Runs full-page on the published site - no inline preview.",e.appendChild(i);return}const n=document.createElement("button");n.type="button",n.style.cssText="background:transparent;border:1px solid var(--dm-border,#333);color:var(--dm-text-muted,#888);font-size:.65rem;padding:.15rem .4rem;border-radius:2px;cursor:pointer;",H(n,"refresh-cw","Replay",12),o.appendChild(n),e.appendChild(o);const l=document.createElement("div");l.style.cssText="background:var(--dm-background-alt,#1a1a2e);border:1px solid var(--dm-border,#2a2a40);border-radius:4px;padding:1rem;text-align:center;min-height:80px;position:relative;overflow:hidden;",e.appendChild(l);function d(i=!1){b?.destroy(),b=null,C++;const s=C;l.replaceChildren();const a=document.createElement("div");a.style.cssText="background:linear-gradient(135deg,#6366f1,#a855f7);color:#fff;padding:.6rem;border-radius:4px;font-size:.8rem;font-weight:600;",a.textContent="Sample content",l.appendChild(a);const m=window.Domma&&window.Domma.effects;if(!m)return;const f={};for(const p of g(r,t.fieldValues)){const v=t.fieldValues[p.name];v===void 0||v===""||v===null||(f[R(p.name)]=v)}r.name==="scribe"&&(a.style.cssText+=";"+F(t.fieldValues),f.loop=P(f.loop??!1),f.actions=[{render:a.textContent,effect:f.effect||"none"}],a.textContent="");try{const p=m[R(r.name)];if(typeof p=="function"){if(s!==C)return;b=p(a,f),i&&b?.resume()}}catch(p){console.warn("Effects preview failed:",p)}}n.addEventListener("click",()=>d(!0)),d()}function Y(e,t,r){const o=u(t.activeEffect);e.replaceChildren();const c=document.createElement("h3");c.style.cssText="margin:0;font-size:1rem;color:var(--dm-text,#eee);",c.textContent=o.label,e.appendChild(c);const n=document.createElement("p");n.style.cssText="margin:0;color:var(--dm-text-muted,#999);font-size:.8rem;line-height:1.4;",n.textContent=o.description,e.appendChild(n);const l=document.createElement("div");e.appendChild(l);const d=document.createElement("div");e.appendChild(d);const i=document.createElement("div");e.appendChild(i);const s=document.createElement("div");e.appendChild(s);function a(){Q(l,t,a),y(d,t,()=>{V(i,t),L(s,t)}),V(i,t),L(s,t)}a();const m=document.createElement("div");m.style.cssText="display:flex;gap:.5rem;margin-top:auto;padding-top:.75rem;border-top:1px solid var(--dm-border,#2a2a40);";const f=document.createElement("button");f.type="button",f.className="btn btn-ghost",f.textContent="Cancel",f.addEventListener("click",()=>r.close()),m.appendChild(f);const p=document.createElement("button");p.type="button",p.className="btn btn-primary",p.style.flex="2",p.textContent=t.editing?"Update":"Insert effect",p.addEventListener("click",()=>Z(t,r)),m.appendChild(p),e.appendChild(m)}function Z(e,t){const r=e.textarea,o=A(e);if(e.editing){const c=u(e.editing.name),n=r.value,l=`[/${c.name}]`.length,d=e.editing.openTagEnd,i=e.editing.blockEnd-l,s=n.substring(d,i),a=z(e,c),m=a?" ":"",f=c.selfClosing?`[${c.name}${m}${a} /]`:`[${c.name}${m}${a}]${s}[/${c.name}]`;T(r,e.editing.blockStart,e.editing.blockEnd,f);const p=c.selfClosing?e.editing.blockStart+f.length:e.editing.blockStart+f.indexOf("]")+1;r.setSelectionRange(p,p),t.close();return}if(e.scope==="inject"&&e.host){const c=u(e.activeEffect),n=e.host.attrs,l=c.name,d=[];for(const s of Object.keys(n)){if(s===l||s.startsWith(l+"-"))continue;const a=n[s];d.push(a===""?s:`${s}="${attr.name==="message"?x(a):String(a).replace(/"/g,"&quot;")}"`)}d.push(l);for(const s of g(c,e.fieldValues)){const a=e.fieldValues[s.name];if(a===void 0||a===""||a===null||a===s.default)continue;const m=s.type==="checkbox"?a?"true":"false":s.name==="message"?x(a):String(a).replace(/"/g,"&quot;");d.push(`${l}-${s.name}="${m}"`)}const i=`[${e.host.name} ${d.join(" ")}]`;T(r,e.host.openTagStart,e.host.openTagEnd,i),t.close();return}M(r,o),t.close()}
@@ -1 +1 @@
1
- import{apiRequest as s}from"../api.js";import{pickMedia as u}from"./media-picker.js";export function faviconGenerator(i,c,t){const a=M.observable(c.peek()||""),o=M.observable(!1),n=M.observable(""),r=M.observable("");return{data:{faviconSource:a,faviconGenerating:o,faviconError:n,faviconGenerated:r},methods:{chooseFaviconSource:async()=>{const e=await u({title:"Choose a favicon source image",current:a.peek()});e&&t()&&(a.value=e,n.value="")},generateFavicon:async()=>{if(!(o.peek()||!a.peek())){o.value=!0,n.value="";try{const e=await s("/settings/favicon",{method:"POST",body:JSON.stringify({source:a.peek()})});if(!t())return;r.value=e.url,i.value=e.url,E.toast("Favicon generated. Save Site Settings to apply it.",{type:"success"})}catch(e){t()&&(n.value=e.message||"Could not generate the favicon.")}finally{t()&&(o.value=!1)}}}}}}
1
+ import{apiRequest as s}from"../api.js";import{pickMedia as u}from"./media-picker.js";export function faviconGenerator(c,i,o){const a=M.observable(i.peek()||""),t=M.observable(!1),r=M.observable(""),n=M.observable("");return{data:{faviconSource:a,faviconGenerating:t,faviconError:r,faviconGenerated:n},methods:{chooseFaviconSource:async()=>{const e=await u({title:"Choose a favicon source image",current:a.peek()});e&&o()&&(a.value=e,r.value="")},generateFavicon:async()=>{if(!(t.peek()||!a.peek())){t.value=!0,r.value="";try{const e=await s("/settings/favicon",{method:"POST",body:JSON.stringify({source:a.peek()})});if(!o())return;n.value=e.url,c.value=e.url,E.toast("Favicon generated. Save Appearance to apply it.",{type:"success"})}catch(e){o()&&(r.value=e.message||"Could not generate the favicon.")}finally{o()&&(t.value=!1)}}}}}}
@@ -0,0 +1,22 @@
1
+ import{fontFamilyValue as j,fontStylesheetHref as q,isLicensedFont as J}from"../../../public/js/font-families.mjs?v=20261029-cms-fonts";import{FONT_MAP as K,CMS_WEB_FONTS as Q}from"../../../public/js/text-style.mjs?v=20261029-all-cms-fonts";const _="The quick brown fox - Aa Bb 0123456789",X=new Set(Q),I=new WeakMap,G=new WeakMap;let Z=0;function ee(t){if(t.getElementById("dm-font-picker-css"))return;const s=t.createElement("style");s.id="dm-font-picker-css",s.textContent=`
2
+ .dm-font-picker { position:relative; width:100%; min-width:0; }
3
+ .dm-font-picker .dm-font-native { position:absolute!important; width:1px!important; height:1px!important; padding:0!important; margin:0!important; border:0!important; clip-path:inset(50%); overflow:hidden; }
4
+ .dm-font-trigger { display:flex; align-items:center; gap:.6rem; width:100%; min-height:38px; padding:.45rem .65rem; border:1px solid var(--dm-border); border-radius:var(--dm-radius-md,6px); background:var(--dm-input-bg,var(--dm-surface)); color:var(--dm-text); font:inherit; text-align:left; cursor:pointer; }
5
+ .dm-font-trigger:after { content:''; width:.4rem; height:.4rem; margin-left:auto; flex-shrink:0; border-right:1.5px solid currentColor; border-bottom:1.5px solid currentColor; transform:rotate(45deg) translateY(-2px); opacity:.65; }
6
+ .dm-font-trigger-label { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
7
+ .dm-font-trigger:focus-visible,.dm-font-search:focus-visible { outline:2px solid var(--dm-primary); outline-offset:2px; }
8
+ .dm-font-trigger:disabled { cursor:default; opacity:.55; }
9
+ .dm-font-panel { position:fixed; z-index:10001; box-sizing:border-box; padding:.5rem; border:1px solid var(--dm-border); border-radius:12px; background:var(--dm-surface); color:var(--dm-text); box-shadow:0 12px 36px rgba(0,0,0,.18); }
10
+ .dm-font-panel[hidden] { display:none!important; }
11
+ .dm-font-search { display:block; box-sizing:border-box; width:100%; margin:0 0 .4rem; padding:.5rem .65rem; border:1px solid var(--dm-border); border-radius:7px; background:var(--dm-input-bg,var(--dm-surface)); color:var(--dm-text); font:inherit; font-size:.85rem; }
12
+ .dm-font-options { overflow:auto; overscroll-behavior:contain; max-height:300px; }
13
+ .dm-font-group { padding:.65rem .55rem .3rem; color:var(--dm-text-muted); font-size:.7rem; font-weight:600; }
14
+ .dm-font-option { display:flex; flex-direction:column; gap:.25rem; padding:.6rem; border-radius:8px; cursor:pointer; }
15
+ .dm-font-option.is-active { background:color-mix(in srgb,var(--dm-primary) 10%,var(--dm-surface)); outline:1px solid color-mix(in srgb,var(--dm-primary) 25%,transparent); outline-offset:-1px; }
16
+ .dm-font-option[aria-selected=true] .dm-font-name:after { content:'\u2713'; margin-left:.5rem; color:var(--dm-primary); font:600 .8rem var(--dm-font-sans,sans-serif); }
17
+ .dm-font-option[aria-disabled=true] { opacity:.55; cursor:default; }
18
+ .dm-font-name { font-size:1.05rem; font-weight:400; line-height:1.35; }
19
+ .dm-font-sample { font-size:.84rem; font-weight:400; line-height:1.4; overflow-wrap:anywhere; }
20
+ .dm-font-status,.dm-font-empty { color:var(--dm-text-muted); font:400 .73rem/1.4 var(--dm-font-sans,sans-serif); }
21
+ .dm-font-empty { margin:0; padding:.7rem .6rem; }
22
+ `,t.head.appendChild(s)}export function fontChoice(t,s=[]){const c=s.find(n=>n.id===t);if(c)return{family:c.google||(c.licensed?c.label.replace(/ \(licensed\)$/,""):""),stack:c.stack,web:!!c.google,licensed:!!c.licensed};const v={system:"system-ui",mono:"monospace",serif:"serif","":"inherit"};return{family:t,stack:K[t]||j(v[t]??t),web:X.has(t),licensed:J(t)}}async function Y(t,s,c){if(!s.web&&!s.licensed)return!0;if(s.licensed&&!c&&!t.getElementById("dm-licensed-fonts"))return!1;const v=s.web?q(s.family).replace(/:ital,wght@[^&]+/,":wght@400"):q(s.family,{stylesheet:c});let n=G.get(t);n||(n=new Map,G.set(t,n));const h=`${s.family}|${v}`;if(n.has(h))return n.get(h);const y=(async()=>(v&&![...t.querySelectorAll("link[rel=stylesheet]")].some(o=>o.href===new URL(v,t.baseURI).href&&o.sheet)&&await new Promise(o=>{const p=t.createElement("link");p.rel="stylesheet",p.href=v,p.dataset.fontPreview=s.family;const a=()=>{clearTimeout(d),p.removeEventListener("load",a),p.removeEventListener("error",a),o()},d=setTimeout(a,8e3);p.addEventListener("load",a),p.addEventListener("error",a),t.head.appendChild(p)}),t.fonts?.load?(await t.fonts.load(`400 16px "${s.family}"`,_).catch(()=>[])).length>0:!1))();return n.set(h,y),await y||n.delete(h),y}export function enhanceFontSelect(t,{label:s="Font",fonts:c=[],stylesheet:v=()=>""}={}){if(I.has(t))return I.get(t);const n=t.ownerDocument;ee(n);const h=`dm-font-picker-${++Z}`,y={tabindex:t.getAttribute("tabindex"),hidden:t.getAttribute("aria-hidden")},u=n.createElement("div");u.className="dm-font-picker",t.style.flex&&(u.style.flex=t.style.flex);const o=n.createElement("button");o.type="button",o.className="dm-font-trigger",o.setAttribute("aria-label",s),o.setAttribute("aria-haspopup","dialog"),o.setAttribute("aria-expanded","false"),o.setAttribute("aria-controls",h);const p=n.createElement("span");p.className="dm-font-trigger-label",o.appendChild(p);const a=n.createElement("div");a.id=h,a.className="dm-font-panel",a.hidden=!0,a.setAttribute("data-focus-trap-allow",""),a.setAttribute("role","dialog"),a.setAttribute("aria-label",`Choose ${s.toLowerCase()}`);const d=n.createElement("input");d.type="search",d.className="dm-font-search",d.placeholder="Search fonts",d.setAttribute("aria-label","Search fonts"),d.setAttribute("role","combobox"),d.setAttribute("aria-autocomplete","list"),d.setAttribute("aria-expanded","true"),d.setAttribute("aria-controls",`${h}-list`);const b=n.createElement("div");b.id=`${h}-list`,b.className="dm-font-options",b.setAttribute("role","listbox"),b.setAttribute("aria-label",s),a.append(d,b),t.before(u),u.append(t,o,a),t.classList.add("dm-font-native"),t.tabIndex=-1,t.setAttribute("aria-hidden","true");let E=!1,l=[],A=-1,C,S;const D=()=>L(),O=()=>o.focus(),V=e=>{!u.contains(e.target)&&!a.contains(e.target)&&w(!1)},M=()=>{const e=o.getBoundingClientRect(),r=6,i=8,f=Math.min(Math.max(e.width,280),n.documentElement.clientWidth-i*2),m=n.defaultView.innerHeight-e.bottom-i-r,g=e.top-i-r,x=m>=Math.min(360,g),k=Math.max(90,Math.min(370,x?m:g));a.style.width=`${f}px`,a.style.left=`${Math.max(i,Math.min(e.left,n.documentElement.clientWidth-f-i))}px`,b.style.maxHeight=`${Math.max(40,k-62)}px`,a.style.top=x?`${e.bottom+r}px`:`${Math.max(i,e.top-r-a.offsetHeight)}px`},P=e=>{if(l.forEach(r=>r.el.classList.remove("is-active")),A=e,!l[e]){d.removeAttribute("aria-activedescendant");return}l[e].el.classList.add("is-active"),d.setAttribute("aria-activedescendant",l[e].el.id),l[e].el.scrollIntoView({block:"nearest"})},T=e=>{if(e.option.disabled||t.matches(":disabled"))return;const r=t.value!==e.option.value;t.value=e.option.value,r&&(t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))),L(),w()},F=e=>{if(e.loaded)return;e.loaded=!0;const r=fontChoice(e.option.value,c);Y(n,r,v()).then(i=>{i?e.status.textContent="":(e.status.textContent=r.licensed?"Font files not installed":"Preview unavailable",e.name.style.fontFamily="",e.sample.hidden=!0)})},z=()=>{C?.disconnect(),l=[],b.replaceChildren();const e=d.value.trim().toLocaleLowerCase();let r;for(const i of t.options){if(i.hidden||!i.textContent.toLocaleLowerCase().includes(e))continue;const f=i.parentElement.tagName==="OPTGROUP"?i.parentElement.label:"";if(f&&f!==r){const $=n.createElement("div");$.className="dm-font-group",$.textContent=f,$.setAttribute("role","presentation"),b.appendChild($)}r=f;const m=n.createElement("div");m.id=`${h}-option-${l.length}`,m.className="dm-font-option",m.setAttribute("role","option"),m.setAttribute("aria-selected",String(i.value===t.value)),m.setAttribute("aria-disabled",String(i.disabled||i.parentElement.disabled===!0));const g=n.createElement("span");g.className="dm-font-name",g.textContent=i.textContent;const x=n.createElement("span");x.className="dm-font-sample",x.textContent=_,x.setAttribute("aria-hidden","true");const k=n.createElement("span");k.className="dm-font-status";const N=fontChoice(i.value,c);g.style.fontFamily=N.stack,x.style.fontFamily=N.stack,(N.web||N.licensed)&&(k.textContent="Loading preview..."),m.append(g,x,k),b.appendChild(m);const R={el:m,option:i,name:g,sample:x,status:k};l.push(R),m.addEventListener("click",()=>{m.getAttribute("aria-disabled")!=="true"&&T(R)})}if(!l.length){const i=n.createElement("p");i.className="dm-font-empty",i.textContent="No matching fonts",b.appendChild(i)}A=-1,d.removeAttribute("aria-activedescendant"),n.defaultView.IntersectionObserver?(C=new n.defaultView.IntersectionObserver(i=>{for(const f of i)if(f.isIntersecting){const m=l.find(g=>g.el===f.target);m&&F(m),C.unobserve(f.target)}},{root:b,rootMargin:"60px"}),l.forEach(i=>C.observe(i.el))):l.slice(0,6).forEach(F),M(),e&&P(l.findIndex(i=>i.el.getAttribute("aria-disabled")!=="true"))};function w(e=!0){E&&(E=!1,a.hidden=!0,C?.disconnect(),S?.disconnect(),u.appendChild(a),o.setAttribute("aria-expanded","false"),n.removeEventListener("pointerdown",V,!0),n.defaultView.removeEventListener("resize",M),n.removeEventListener("scroll",H,!0),e&&o.isConnected&&o.focus())}function H(e){a.contains(e.target)||M()}function L(){p.textContent=t.selectedOptions[0]?.textContent||"Choose font",o.setAttribute("aria-label",`${s}: ${p.textContent}`),o.disabled=t.matches(":disabled");const e=fontChoice(t.value,c);p.style.fontFamily=e.stack,l.forEach(r=>r.el.setAttribute("aria-selected",String(r.option.value===t.value))),(e.web||e.licensed)&&Y(n,e,v())}function B(){if(t.matches(":disabled"))return;if(E){w();return}let e=10001;for(let r=u;r;r=r.parentElement)e=Math.max(e,(parseInt(n.defaultView.getComputedStyle(r).zIndex,10)||0)+2);a.style.zIndex=String(e),E=!0,n.body.appendChild(a),a.hidden=!1,o.setAttribute("aria-expanded","true"),d.value="",z(),n.addEventListener("pointerdown",V,!0),n.defaultView.addEventListener("resize",M),n.addEventListener("scroll",H,!0),S=new n.defaultView.MutationObserver(()=>{u.isConnected||w(!1)}),S.observe(n.body,{subtree:!0,childList:!0}),d.focus()}o.addEventListener("click",B),o.addEventListener("keydown",e=>{["ArrowDown","ArrowUp"].includes(e.key)&&(e.preventDefault(),E||B())}),a.addEventListener("keydown",e=>{if(e.key==="Escape")e.preventDefault(),e.stopPropagation(),w();else if(e.key==="Tab")w();else if(e.key==="Enter")e.preventDefault(),l[A]&&T(l[A]);else if(["ArrowDown","ArrowUp","Home","End"].includes(e.key)){e.preventDefault();const r=l.map((f,m)=>f.el.getAttribute("aria-disabled")!=="true"?m:-1).filter(f=>f>=0);if(!r.length)return;const i=e.key==="Home"?r[0]:e.key==="End"?r.at(-1):A<0?e.key==="ArrowDown"?r[0]:r.at(-1):r[(r.indexOf(A)+(e.key==="ArrowDown"?1:-1)+r.length)%r.length];P(i),F(l[i])}}),d.addEventListener("input",z),t.addEventListener("change",D),t.addEventListener("focus",O);const U=new n.defaultView.MutationObserver(()=>{L(),E&&z()});U.observe(t,{subtree:!0,childList:!0,attributes:!0,characterData:!0});const W={refresh:L,close:w,destroy(){w(!1),U.disconnect(),t.removeEventListener("change",D),t.removeEventListener("focus",O),t.classList.remove("dm-font-native");for(const[e,r]of[["tabindex",y.tabindex],["aria-hidden",y.hidden]])r==null?t.removeAttribute(e):t.setAttribute(e,r);u.before(t),u.remove(),I.delete(t)}};return I.set(t,W),L(),W}
@@ -1 +1 @@
1
- import{insertAtCursor as re}from"./markdown-toolbar.js";import{buildScribeStyle as ae,loadScribeFont as se}from"../../../public/js/scribe-style.mjs?v=20261029-all-cms-fonts";import{SCRIBE_FIELDS as ce,scribeDefaults as ie,scribeLoop as le,stateToScribeActions as de,buildScribeShortcode as pe}from"./scribe-model.js";const me=20,Q={render:{label:"Render",icon:"edit-3",color:"var(--dm-info,#3b82f6)"},wait:{label:"Wait",icon:"clock",color:"var(--dm-warning,#f59e0b)"},undo:{label:"Undo",icon:"corner-up-left",color:"var(--dm-secondary,#a855f7)"},redraw:{label:"Redraw",icon:"refresh-cw",color:"var(--dm-success,#22c55e)"}},T="padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;box-sizing:border-box;width:100%;",ue="display:block;font-size:.7rem;font-weight:600;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;margin-bottom:.25rem;",he="display:flex;align-items:center;gap:.5rem;cursor:pointer;font-size:.85em;";export function openScribeComposer(s){const r=fe(),n=[];let t=null,p=null;function i(){clearTimeout(t),p?.destroy(),p=null}const h=E.slideover({title:"Scribe Composer",size:"lg",position:"right",onClose:i});ke();const b=document.createElement("div");b.className="scribe-composer",b.style.cssText="display:flex;flex-direction:column;height:100%;";const y=document.createElement("div");y.style.cssText="padding:1rem 1.25rem;border-bottom:1px solid var(--dm-border,#333);background:var(--dm-background-alt,#0f0f17);";const k=document.createElement("div");k.style.cssText="min-height:3.5rem;padding:.85rem 1rem;background:var(--dm-surface,#1a1a1a);border:1px dashed var(--dm-border,#333);border-radius:6px;font-size:1.25rem;line-height:1.5;overflow-wrap:normal;word-break:normal;",y.appendChild(k);const B=document.createElement("div");B.style.cssText="display:flex;gap:.5rem;margin-top:.75rem;align-items:center;";const K=V("rotate-cw","Replay"),Y=V("code","Show code"),N=document.createElement("span");N.style.cssText="font-size:.8em;color:var(--dm-text-muted,#aaa);flex:1;text-align:right;margin-right:.5rem;",B.appendChild(K),B.appendChild(N),B.appendChild(Y),y.appendChild(B);const M=document.createElement("pre");M.style.cssText="display:none;margin:.75rem 0 0;padding:.6rem .75rem;background:var(--dm-surface,#0a0a0a);border:1px solid var(--dm-border,#333);border-radius:4px;font-family:monospace;font-size:.78em;white-space:pre-wrap;word-break:break-all;color:var(--dm-text-muted,#bbb);max-height:200px;overflow:auto;",y.appendChild(M),Y.addEventListener("click",()=>{const e=M.style.display!=="none";M.style.display=e?"none":"block"}),K.addEventListener("click",()=>{J(),p?.resume(),p&&(N.textContent="Playing preview")}),b.appendChild(y);const R=document.createElement("div");R.style.cssText="display:flex;flex:1;min-height:0;overflow:hidden;";const q=xe(r,()=>{C(),x()});R.appendChild(q.el);const z=document.createElement("main");z.style.cssText="flex:1;overflow-y:auto;padding:1rem 1.25rem;display:flex;flex-direction:column;";const D=document.createElement("h4");D.textContent="Actions",D.style.cssText="margin:0 0 .75rem;font-size:.75rem;font-weight:700;text-transform:uppercase;letter-spacing:.08em;color:var(--dm-text-muted,#aaa);",z.appendChild(D);const A=document.createElement("div");A.style.cssText="display:flex;flex-direction:column;gap:.6rem;",z.appendChild(A);const P=document.createElement("div");P.style.cssText="display:flex;gap:.4rem;margin-top:.9rem;flex-wrap:wrap;",Object.entries(Q).forEach(([e,a])=>{const c=document.createElement("button");c.type="button",c.style.cssText=`padding:.4rem .8rem;background:transparent;border:1px dashed color-mix(in srgb, ${a.color} 40%, transparent);border-radius:4px;color:${a.color};cursor:pointer;font-size:.85em;display:inline-flex;align-items:center;gap:.35rem;`;const l=document.createElement("span");l.setAttribute("data-icon",a.icon),c.appendChild(l),c.appendChild(document.createTextNode(` + ${a.label}`)),c.addEventListener("click",()=>{C(),r.actions.push(be(e)),$(),x()}),P.appendChild(c)}),z.appendChild(P),R.appendChild(z),b.appendChild(R);const L=document.createElement("div");L.style.cssText="display:flex;padding:.75rem 1rem;border-top:1px solid var(--dm-border,#333);background:var(--dm-background-alt,#0f0f17);gap:.5rem;align-items:center;";const S=document.createElement("button");S.type="button",S.className="btn btn-ghost btn-sm",S.textContent="Undo (Ctrl+Z)",S.addEventListener("click",()=>H()),L.appendChild(S);const U=document.createElement("span");U.style.cssText="font-size:.75em;color:var(--dm-text-muted,#aaa);",L.appendChild(U);const G=document.createElement("div");G.style.flex="1",L.appendChild(G);const W=document.createElement("button");W.type="button",W.className="btn btn-ghost",W.textContent="Cancel",W.addEventListener("click",()=>h.close()),L.appendChild(W);const j=document.createElement("button");j.type="button",j.className="btn btn-primary",j.textContent="Insert Scribe",j.addEventListener("click",()=>{re(s,Z()),h.close()}),L.appendChild(j),b.appendChild(L),h.setContent(b),b.addEventListener("keydown",e=>{const a=(e.key||"").toLowerCase();(e.ctrlKey||e.metaKey)&&a==="z"&&!e.shiftKey&&n.length>0&&(e.preventDefault(),e.stopPropagation(),H())}),$(),x(),O(),requestAnimationFrame(()=>{Domma.icons.scan()}),h.open();function C(){n.push(JSON.stringify(r)),n.length>me&&n.shift(),O()}function H(){if(n.length===0){E.toast("Nothing to undo",{type:"info",duration:700});return}const e=JSON.parse(n.pop());Object.assign(r.globals,e.globals),r.actions.length=0,e.actions.forEach(a=>r.actions.push(a)),q.sync(),$(),x(),O(),E.toast("Undone",{type:"info",duration:500})}function O(){U.textContent=n.length===0?"":`${n.length} step${n.length===1?"":"s"} stored`,S.disabled=n.length===0,S.style.opacity=n.length===0?".4":"1"}function x(e=150){clearTimeout(t),t=setTimeout(J,e)}function J(){i(),ee(k),k.style.color="",k.style.fontStyle="",M.textContent=Z();const e=r.actions.filter(o=>o.type==="render"||o.type==="redraw"?(o.text||"").length>0:!0);if(e.length===0){k.textContent="(add an action to preview)",k.style.color="var(--dm-text-muted,#666)",k.style.fontStyle="italic",N.textContent="";return}const a=document.createElement("span");a.className="dm-fx-scribe",k.appendChild(a);const c=r.globals;se(c.font),a.style.cssText=ae(c);const{effect:l,controls:g,...w}=c;w.actions=de(e,l);try{p=Domma.effects.scribe(a,w),N.textContent=c.autoStart?`${e.length} action${e.length===1?"":"s"}`:"Press Replay to start"}catch{N.textContent="Preview error"}}function $(){if(ee(A),r.actions.length===0){const e=document.createElement("p");e.textContent="No actions yet - add one from the buttons below.",e.style.cssText="font-size:.85em;color:var(--dm-text-muted,#888);font-style:italic;margin:.5rem 0;",A.appendChild(e);return}r.actions.forEach((e,a)=>{A.appendChild(ne(e,a))}),requestAnimationFrame(()=>Domma.icons.scan())}function ne(e,a){const c=Q[e.type],l=document.createElement("div");l.style.cssText=`border:1px solid var(--dm-border,#333);border-left:3px solid ${c.color};border-radius:4px;padding:.6rem .75rem;background:var(--dm-surface,#15151a);`;const g=document.createElement("div");g.style.cssText="display:flex;align-items:center;gap:.5rem;margin-bottom:.5rem;";const w=document.createElement("span");w.style.cssText=`display:inline-flex;align-items:center;gap:.3rem;font-size:.72rem;font-weight:700;color:${c.color};text-transform:uppercase;letter-spacing:.06em;`;const o=document.createElement("span");o.setAttribute("data-icon",c.icon),w.appendChild(o),w.appendChild(document.createTextNode(c.label)),g.appendChild(w);const u=document.createElement("span");u.textContent=`#${a+1}`,u.style.cssText="font-size:.7rem;color:var(--dm-text-muted,#888);",g.appendChild(u);const m=document.createElement("div");m.style.flex="1",g.appendChild(m);const d=F("chevron-up","Move up");a===0&&(d.disabled=!0,d.style.opacity=".3"),d.addEventListener("click",()=>X(a,-1)),g.appendChild(d);const f=F("chevron-down","Move down");a===r.actions.length-1&&(f.disabled=!0,f.style.opacity=".3"),f.addEventListener("click",()=>X(a,1)),g.appendChild(f);const v=F("x","Remove");return v.addEventListener("click",()=>{C(),r.actions.splice(a,1),$(),x()}),g.appendChild(v),l.appendChild(g),l.appendChild(oe(e)),l}function X(e,a){const c=e+a;if(c<0||c>=r.actions.length)return;C();const[l]=r.actions.splice(e,1);r.actions.splice(c,0,l),$(),x()}function oe(e){const a=document.createElement("div");if(a.style.cssText="display:flex;flex-direction:column;gap:.5rem;",e.type==="render"||e.type==="redraw"){const o=document.createElement("textarea");o.value=e.text||"",o.placeholder=e.type==="redraw"?"New text - clears everything first, then types this":"Text to type out",o.rows=2,o.style.cssText=T+"resize:vertical;font-family:inherit;min-height:2.2rem;";let u=o.value;o.addEventListener("input",()=>{e.text=o.value,x()}),o.addEventListener("blur",()=>{o.value!==u&&(C(),u=o.value)}),a.appendChild(o);const m=document.createElement("div");m.style.cssText="display:flex;align-items:center;gap:.5rem;font-size:.8em;";const d=document.createElement("label");d.textContent="Effect:",d.style.color="var(--dm-text-muted,#aaa)";const f=document.createElement("select");return f.style.cssText=T+"width:auto;padding:.25rem .4rem;",["inherit","none","fade","bounce","glow"].forEach(v=>{const _=document.createElement("option");_.value=v,_.textContent=v==="inherit"?"Default effect":v.charAt(0).toUpperCase()+v.slice(1),f.appendChild(_)}),f.value=e.effect||"none",f.addEventListener("change",()=>{C(),e.effect=f.value,x()}),m.appendChild(d),m.appendChild(f),a.appendChild(m),a}if(e.type==="wait"){const o=document.createElement("div");o.style.cssText="display:flex;gap:.4rem;align-items:center;";const u=document.createElement("input");u.type="number",u.min="0",u.step="any",u.value=String(e.duration??1e3),u.style.cssText=T+"flex:1;",u.addEventListener("input",()=>{const d=Number(u.value);!Number.isNaN(d)&&d>=0&&(e.duration=d,x())}),u.addEventListener("blur",()=>C()),o.appendChild(u);const m=document.createElement("select");return m.style.cssText=T+"width:auto;",[["ms","ms"],["s","seconds"]].forEach(([d,f])=>{const v=document.createElement("option");v.value=d,v.textContent=f,m.appendChild(v)}),m.value=e.unit||"ms",m.addEventListener("change",()=>{C(),e.unit=m.value,x()}),o.appendChild(m),a.appendChild(o),a}const c=document.createElement("div");c.style.cssText="display:flex;gap:.75rem;align-items:center;flex-wrap:wrap;font-size:.85em;";const l=document.createElement("input");l.type="number",l.min="1",l.value=String(e.count||5),l.style.cssText=T+"width:5rem;",l.addEventListener("input",()=>{const o=parseInt(l.value,10);!Number.isNaN(o)&&o>0&&(e.count=o,x())}),l.addEventListener("blur",()=>C());const g=`undo-mode-${Math.random().toString(36).slice(2)}`;return[["last","Last render"],["all","All text"],["count","Exactly N units"]].forEach(([o,u])=>{const m=document.createElement("label");m.style.cssText="display:inline-flex;align-items:center;gap:.3rem;cursor:pointer;";const d=document.createElement("input");d.type="radio",d.name=g,d.value=o,d.checked=(e.mode||"last")===o,d.addEventListener("change",()=>{d.checked&&(C(),e.mode=o,l.style.display=o==="count"?"":"none",x())}),m.appendChild(d),m.appendChild(document.createTextNode(u)),c.appendChild(m),o==="count"&&(c.appendChild(l),l.style.display=(e.mode||"last")==="count"?"":"none")}),a.appendChild(c),a}function Z(){return pe(r.globals,r.actions)}}function fe(){return{globals:ie(),actions:[{type:"render",text:"We build things that matter.",effect:"inherit"},{type:"wait",duration:1500,unit:"ms"},{type:"redraw",text:"We create solutions that last.",effect:"inherit"},{type:"wait",duration:1500,unit:"ms"}]}}function be(s){switch(s){case"render":return{type:"render",text:"",effect:"inherit"};case"wait":return{type:"wait",duration:1e3,unit:"ms"};case"undo":return{type:"undo",mode:"last",count:5};case"redraw":return{type:"redraw",text:"",effect:"inherit"}}return{type:"render",text:"",effect:"inherit"}}function xe(s,r){const n=document.createElement("aside");n.style.cssText="width:240px;flex-shrink:0;padding:1rem 1.25rem;border-right:1px solid var(--dm-border,#333);overflow-y:auto;display:flex;flex-direction:column;gap:.75rem;background:var(--dm-background-alt,#0c0c12);";const t=document.createElement("h4");t.textContent="Global settings",t.style.cssText="margin:0 0 .25rem;font-size:.75rem;font-weight:700;text-transform:uppercase;letter-spacing:.08em;color:var(--dm-text-muted,#aaa);",n.appendChild(t);const p=ce.map(i=>{const h=y=>{r(),s.globals[i.key]=i.key==="loop"?le(y):y};let b;if(i.type==="checkbox"){const y=Ee(s.globals[i.key],h,i.label);n.appendChild(y.wrap),b=y.input}else b=i.type==="select"?Ce(i.options,s.globals[i.key],h):i.type==="number"?ge(s.globals[i.key],h,i.min):ve(s.globals[i.key],"",h),n.appendChild(ye(i.label,b));return{field:i,input:b}});return{el:n,sync(){p.forEach(({field:i,input:h})=>{i.type==="checkbox"?h.checked=s.globals[i.key]:h.value=String(s.globals[i.key])})}}}function ye(s,r){const n=document.createElement("div"),t=document.createElement("label");return t.style.cssText=ue,t.textContent=s,n.appendChild(t),n.appendChild(r),n}function ge(s,r,n=1){const t=document.createElement("input");return t.type="number",t.min=String(n),t.value=String(s),t.style.cssText=T,t.addEventListener("input",()=>{const p=Number(t.value);!Number.isNaN(p)&&p>=n&&r(p)}),t}function ve(s,r,n){const t=document.createElement("input");return t.type="text",t.value=s,t.placeholder=r,t.style.cssText=T,t.addEventListener("input",()=>n(t.value)),t}function Ce(s,r,n){const t=document.createElement("select");return t.style.cssText=T,s.forEach(([p,i])=>{const h=document.createElement("option");h.value=p,h.textContent=i,t.appendChild(h)}),t.value=r,t.addEventListener("change",()=>n(t.value)),t}function Ee(s,r,n){const t=document.createElement("label");t.style.cssText=he;const p=document.createElement("input");return p.type="checkbox",p.checked=s,p.addEventListener("change",()=>r(p.checked)),t.appendChild(p),t.appendChild(document.createTextNode(n)),{wrap:t,input:p}}function V(s,r){const n=document.createElement("button");n.type="button",n.className="btn btn-ghost btn-sm",n.style.cssText="display:inline-flex;align-items:center;gap:.35rem;";const t=document.createElement("span");return t.setAttribute("data-icon",s),n.appendChild(t),n.appendChild(document.createTextNode(r)),n}function F(s,r){const n=document.createElement("button");n.type="button",n.title=r,n.style.cssText="padding:.25rem .4rem;background:transparent;border:1px solid var(--dm-border,#333);border-radius:3px;color:var(--dm-text-muted,#aaa);cursor:pointer;display:inline-flex;align-items:center;";const t=document.createElement("span");return t.setAttribute("data-icon",s),n.appendChild(t),n}function ee(s){for(;s.firstChild;)s.removeChild(s.firstChild)}function Se(s){return String(s).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}let te=!1;function ke(){te||(te=!0,I.register("edit-3",{viewBox:"0 0 24 24",paths:["M12 20h9","M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("clock",{viewBox:"0 0 24 24",paths:["M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10z","M12 6v6l4 2"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("corner-up-left",{viewBox:"0 0 24 24",paths:["M9 14 4 9l5-5","M20 20v-7a4 4 0 0 0-4-4H4"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("refresh-cw",{viewBox:"0 0 24 24",paths:["M23 4v6h-6","M1 20v-6h6","M3.51 9a9 9 0 0 1 14.85-3.36L23 10","M20.49 15a9 9 0 0 1-14.85 3.36L1 14"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("rotate-cw",{viewBox:"0 0 24 24",paths:["M23 4v6h-6","M20.49 15a9 9 0 1 1-2.12-9.36L23 10"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("code",{viewBox:"0 0 24 24",paths:["M16 18l6-6-6-6","M8 6l-6 6 6 6"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("chevron-up",{viewBox:"0 0 24 24",path:"M18 15l-6-6-6 6",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("chevron-down",{viewBox:"0 0 24 24",path:"M6 9l6 6 6-6",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("x",{viewBox:"0 0 24 24",paths:["M18 6L6 18","M6 6l12 12"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}))}
1
+ import{enhanceFontSelect as re}from"./font-picker.js";import{insertAtCursor as ae}from"./markdown-toolbar.js";import{buildScribeStyle as se,loadScribeFont as ce}from"../../../public/js/scribe-style.mjs?v=20261029-all-cms-fonts";import{SCRIBE_FIELDS as ie,scribeDefaults as le,scribeLoop as de,stateToScribeActions as pe,buildScribeShortcode as me}from"./scribe-model.js";const ue=20,Q={render:{label:"Render",icon:"edit-3",color:"var(--dm-info,#3b82f6)"},wait:{label:"Wait",icon:"clock",color:"var(--dm-warning,#f59e0b)"},undo:{label:"Undo",icon:"corner-up-left",color:"var(--dm-secondary,#a855f7)"},redraw:{label:"Redraw",icon:"refresh-cw",color:"var(--dm-success,#22c55e)"}},w="padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;box-sizing:border-box;width:100%;",he="display:block;font-size:.7rem;font-weight:600;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;margin-bottom:.25rem;",fe="display:flex;align-items:center;gap:.5rem;cursor:pointer;font-size:.85em;";export function openScribeComposer(s){const r=be(),n=[];let t=null,p=null;function c(){clearTimeout(t),p?.destroy(),p=null}const h=E.slideover({title:"Scribe Composer",size:"lg",position:"right",onClose:c});we();const f=document.createElement("div");f.className="scribe-composer",f.style.cssText="display:flex;flex-direction:column;height:100%;";const T=document.createElement("div");T.style.cssText="padding:1rem 1.25rem;border-bottom:1px solid var(--dm-border,#333);background:var(--dm-background-alt,#0f0f17);";const b=document.createElement("div");b.style.cssText="min-height:3.5rem;padding:.85rem 1rem;background:var(--dm-surface,#1a1a1a);border:1px dashed var(--dm-border,#333);border-radius:6px;font-size:1.25rem;line-height:1.5;overflow-wrap:normal;word-break:normal;",T.appendChild(b);const B=document.createElement("div");B.style.cssText="display:flex;gap:.5rem;margin-top:.75rem;align-items:center;";const K=V("rotate-cw","Replay"),Y=V("code","Show code"),N=document.createElement("span");N.style.cssText="font-size:.8em;color:var(--dm-text-muted,#aaa);flex:1;text-align:right;margin-right:.5rem;",B.appendChild(K),B.appendChild(N),B.appendChild(Y),T.appendChild(B);const M=document.createElement("pre");M.style.cssText="display:none;margin:.75rem 0 0;padding:.6rem .75rem;background:var(--dm-surface,#0a0a0a);border:1px solid var(--dm-border,#333);border-radius:4px;font-family:monospace;font-size:.78em;white-space:pre-wrap;word-break:break-all;color:var(--dm-text-muted,#bbb);max-height:200px;overflow:auto;",T.appendChild(M),Y.addEventListener("click",()=>{const e=M.style.display!=="none";M.style.display=e?"none":"block"}),K.addEventListener("click",()=>{J(),p?.resume(),p&&(N.textContent="Playing preview")}),f.appendChild(T);const R=document.createElement("div");R.style.cssText="display:flex;flex:1;min-height:0;overflow:hidden;";const q=ye(r,()=>{C(),y()});R.appendChild(q.el);const z=document.createElement("main");z.style.cssText="flex:1;overflow-y:auto;padding:1rem 1.25rem;display:flex;flex-direction:column;";const D=document.createElement("h4");D.textContent="Actions",D.style.cssText="margin:0 0 .75rem;font-size:.75rem;font-weight:700;text-transform:uppercase;letter-spacing:.08em;color:var(--dm-text-muted,#aaa);",z.appendChild(D);const A=document.createElement("div");A.style.cssText="display:flex;flex-direction:column;gap:.6rem;",z.appendChild(A);const P=document.createElement("div");P.style.cssText="display:flex;gap:.4rem;margin-top:.9rem;flex-wrap:wrap;",Object.entries(Q).forEach(([e,a])=>{const i=document.createElement("button");i.type="button",i.style.cssText=`padding:.4rem .8rem;background:transparent;border:1px dashed color-mix(in srgb, ${a.color} 40%, transparent);border-radius:4px;color:${a.color};cursor:pointer;font-size:.85em;display:inline-flex;align-items:center;gap:.35rem;`;const l=document.createElement("span");l.setAttribute("data-icon",a.icon),i.appendChild(l),i.appendChild(document.createTextNode(` + ${a.label}`)),i.addEventListener("click",()=>{C(),r.actions.push(xe(e)),$(),y()}),P.appendChild(i)}),z.appendChild(P),R.appendChild(z),f.appendChild(R);const L=document.createElement("div");L.style.cssText="display:flex;padding:.75rem 1rem;border-top:1px solid var(--dm-border,#333);background:var(--dm-background-alt,#0f0f17);gap:.5rem;align-items:center;";const S=document.createElement("button");S.type="button",S.className="btn btn-ghost btn-sm",S.textContent="Undo (Ctrl+Z)",S.addEventListener("click",()=>H()),L.appendChild(S);const U=document.createElement("span");U.style.cssText="font-size:.75em;color:var(--dm-text-muted,#aaa);",L.appendChild(U);const G=document.createElement("div");G.style.flex="1",L.appendChild(G);const W=document.createElement("button");W.type="button",W.className="btn btn-ghost",W.textContent="Cancel",W.addEventListener("click",()=>h.close()),L.appendChild(W);const j=document.createElement("button");j.type="button",j.className="btn btn-primary",j.textContent="Insert Scribe",j.addEventListener("click",()=>{ae(s,Z()),h.close()}),L.appendChild(j),f.appendChild(L),h.setContent(f),f.addEventListener("keydown",e=>{const a=(e.key||"").toLowerCase();(e.ctrlKey||e.metaKey)&&a==="z"&&!e.shiftKey&&n.length>0&&(e.preventDefault(),e.stopPropagation(),H())}),$(),y(),O(),requestAnimationFrame(()=>{Domma.icons.scan()}),h.open();function C(){n.push(JSON.stringify(r)),n.length>ue&&n.shift(),O()}function H(){if(n.length===0){E.toast("Nothing to undo",{type:"info",duration:700});return}const e=JSON.parse(n.pop());Object.assign(r.globals,e.globals),r.actions.length=0,e.actions.forEach(a=>r.actions.push(a)),q.sync(),$(),y(),O(),E.toast("Undone",{type:"info",duration:500})}function O(){U.textContent=n.length===0?"":`${n.length} step${n.length===1?"":"s"} stored`,S.disabled=n.length===0,S.style.opacity=n.length===0?".4":"1"}function y(e=150){clearTimeout(t),t=setTimeout(J,e)}function J(){c(),ee(b),b.style.color="",b.style.fontStyle="",M.textContent=Z();const e=r.actions.filter(o=>o.type==="render"||o.type==="redraw"?(o.text||"").length>0:!0);if(e.length===0){b.textContent="(add an action to preview)",b.style.color="var(--dm-text-muted,#666)",b.style.fontStyle="italic",N.textContent="";return}const a=document.createElement("span");a.className="dm-fx-scribe",b.appendChild(a);const i=r.globals;ce(i.font),a.style.cssText=se(i);const{effect:l,controls:g,...k}=i;k.actions=pe(e,l);try{p=Domma.effects.scribe(a,k),N.textContent=i.autoStart?`${e.length} action${e.length===1?"":"s"}`:"Press Replay to start"}catch{N.textContent="Preview error"}}function $(){if(ee(A),r.actions.length===0){const e=document.createElement("p");e.textContent="No actions yet - add one from the buttons below.",e.style.cssText="font-size:.85em;color:var(--dm-text-muted,#888);font-style:italic;margin:.5rem 0;",A.appendChild(e);return}r.actions.forEach((e,a)=>{A.appendChild(ne(e,a))}),requestAnimationFrame(()=>Domma.icons.scan())}function ne(e,a){const i=Q[e.type],l=document.createElement("div");l.style.cssText=`border:1px solid var(--dm-border,#333);border-left:3px solid ${i.color};border-radius:4px;padding:.6rem .75rem;background:var(--dm-surface,#15151a);`;const g=document.createElement("div");g.style.cssText="display:flex;align-items:center;gap:.5rem;margin-bottom:.5rem;";const k=document.createElement("span");k.style.cssText=`display:inline-flex;align-items:center;gap:.3rem;font-size:.72rem;font-weight:700;color:${i.color};text-transform:uppercase;letter-spacing:.06em;`;const o=document.createElement("span");o.setAttribute("data-icon",i.icon),k.appendChild(o),k.appendChild(document.createTextNode(i.label)),g.appendChild(k);const u=document.createElement("span");u.textContent=`#${a+1}`,u.style.cssText="font-size:.7rem;color:var(--dm-text-muted,#888);",g.appendChild(u);const m=document.createElement("div");m.style.flex="1",g.appendChild(m);const d=F("chevron-up","Move up");a===0&&(d.disabled=!0,d.style.opacity=".3"),d.addEventListener("click",()=>X(a,-1)),g.appendChild(d);const x=F("chevron-down","Move down");a===r.actions.length-1&&(x.disabled=!0,x.style.opacity=".3"),x.addEventListener("click",()=>X(a,1)),g.appendChild(x);const v=F("x","Remove");return v.addEventListener("click",()=>{C(),r.actions.splice(a,1),$(),y()}),g.appendChild(v),l.appendChild(g),l.appendChild(oe(e)),l}function X(e,a){const i=e+a;if(i<0||i>=r.actions.length)return;C();const[l]=r.actions.splice(e,1);r.actions.splice(i,0,l),$(),y()}function oe(e){const a=document.createElement("div");if(a.style.cssText="display:flex;flex-direction:column;gap:.5rem;",e.type==="render"||e.type==="redraw"){const o=document.createElement("textarea");o.value=e.text||"",o.placeholder=e.type==="redraw"?"New text - clears everything first, then types this":"Text to type out",o.rows=2,o.style.cssText=w+"resize:vertical;font-family:inherit;min-height:2.2rem;";let u=o.value;o.addEventListener("input",()=>{e.text=o.value,y()}),o.addEventListener("blur",()=>{o.value!==u&&(C(),u=o.value)}),a.appendChild(o);const m=document.createElement("div");m.style.cssText="display:flex;align-items:center;gap:.5rem;font-size:.8em;";const d=document.createElement("label");d.textContent="Effect:",d.style.color="var(--dm-text-muted,#aaa)";const x=document.createElement("select");return x.style.cssText=w+"width:auto;padding:.25rem .4rem;",["inherit","none","fade","bounce","glow"].forEach(v=>{const _=document.createElement("option");_.value=v,_.textContent=v==="inherit"?"Default effect":v.charAt(0).toUpperCase()+v.slice(1),x.appendChild(_)}),x.value=e.effect||"none",x.addEventListener("change",()=>{C(),e.effect=x.value,y()}),m.appendChild(d),m.appendChild(x),a.appendChild(m),a}if(e.type==="wait"){const o=document.createElement("div");o.style.cssText="display:flex;gap:.4rem;align-items:center;";const u=document.createElement("input");u.type="number",u.min="0",u.step="any",u.value=String(e.duration??1e3),u.style.cssText=w+"flex:1;",u.addEventListener("input",()=>{const d=Number(u.value);!Number.isNaN(d)&&d>=0&&(e.duration=d,y())}),u.addEventListener("blur",()=>C()),o.appendChild(u);const m=document.createElement("select");return m.style.cssText=w+"width:auto;",[["ms","ms"],["s","seconds"]].forEach(([d,x])=>{const v=document.createElement("option");v.value=d,v.textContent=x,m.appendChild(v)}),m.value=e.unit||"ms",m.addEventListener("change",()=>{C(),e.unit=m.value,y()}),o.appendChild(m),a.appendChild(o),a}const i=document.createElement("div");i.style.cssText="display:flex;gap:.75rem;align-items:center;flex-wrap:wrap;font-size:.85em;";const l=document.createElement("input");l.type="number",l.min="1",l.value=String(e.count||5),l.style.cssText=w+"width:5rem;",l.addEventListener("input",()=>{const o=parseInt(l.value,10);!Number.isNaN(o)&&o>0&&(e.count=o,y())}),l.addEventListener("blur",()=>C());const g=`undo-mode-${Math.random().toString(36).slice(2)}`;return[["last","Last render"],["all","All text"],["count","Exactly N units"]].forEach(([o,u])=>{const m=document.createElement("label");m.style.cssText="display:inline-flex;align-items:center;gap:.3rem;cursor:pointer;";const d=document.createElement("input");d.type="radio",d.name=g,d.value=o,d.checked=(e.mode||"last")===o,d.addEventListener("change",()=>{d.checked&&(C(),e.mode=o,l.style.display=o==="count"?"":"none",y())}),m.appendChild(d),m.appendChild(document.createTextNode(u)),i.appendChild(m),o==="count"&&(i.appendChild(l),l.style.display=(e.mode||"last")==="count"?"":"none")}),a.appendChild(i),a}function Z(){return me(r.globals,r.actions)}}function be(){return{globals:le(),actions:[{type:"render",text:"We build things that matter.",effect:"inherit"},{type:"wait",duration:1500,unit:"ms"},{type:"redraw",text:"We create solutions that last.",effect:"inherit"},{type:"wait",duration:1500,unit:"ms"}]}}function xe(s){switch(s){case"render":return{type:"render",text:"",effect:"inherit"};case"wait":return{type:"wait",duration:1e3,unit:"ms"};case"undo":return{type:"undo",mode:"last",count:5};case"redraw":return{type:"redraw",text:"",effect:"inherit"}}return{type:"render",text:"",effect:"inherit"}}function ye(s,r){const n=document.createElement("aside");n.style.cssText="width:240px;flex-shrink:0;padding:1rem 1.25rem;border-right:1px solid var(--dm-border,#333);overflow-y:auto;display:flex;flex-direction:column;gap:.75rem;background:var(--dm-background-alt,#0c0c12);";const t=document.createElement("h4");t.textContent="Global settings",t.style.cssText="margin:0 0 .25rem;font-size:.75rem;font-weight:700;text-transform:uppercase;letter-spacing:.08em;color:var(--dm-text-muted,#aaa);",n.appendChild(t);const p=ie.map(c=>{const h=b=>{r(),s.globals[c.key]=c.key==="loop"?de(b):b};let f;if(c.type==="checkbox"){const b=ke(s.globals[c.key],h,c.label);n.appendChild(b.wrap),f=b.input}else f=c.type==="select"?Ee(c.options,s.globals[c.key],h):c.type==="number"?ve(s.globals[c.key],h,c.min):Ce(s.globals[c.key],"",h),n.appendChild(ge(c.label,f));const T=c.key==="font"?re(f,{label:c.label}):null;return{field:c,input:f,picker:T}});return{el:n,sync(){p.forEach(({field:c,input:h,picker:f})=>{c.type==="checkbox"?h.checked=s.globals[c.key]:h.value=String(s.globals[c.key]),f?.refresh()})}}}function ge(s,r){const n=document.createElement("div"),t=document.createElement("label");return t.style.cssText=he,t.textContent=s,n.appendChild(t),n.appendChild(r),n}function ve(s,r,n=1){const t=document.createElement("input");return t.type="number",t.min=String(n),t.value=String(s),t.style.cssText=w,t.addEventListener("input",()=>{const p=Number(t.value);!Number.isNaN(p)&&p>=n&&r(p)}),t}function Ce(s,r,n){const t=document.createElement("input");return t.type="text",t.value=s,t.placeholder=r,t.style.cssText=w,t.addEventListener("input",()=>n(t.value)),t}function Ee(s,r,n){const t=document.createElement("select");return t.style.cssText=w,s.forEach(([p,c])=>{const h=document.createElement("option");h.value=p,h.textContent=c,t.appendChild(h)}),t.value=r,t.addEventListener("change",()=>n(t.value)),t}function ke(s,r,n){const t=document.createElement("label");t.style.cssText=fe;const p=document.createElement("input");return p.type="checkbox",p.checked=s,p.addEventListener("change",()=>r(p.checked)),t.appendChild(p),t.appendChild(document.createTextNode(n)),{wrap:t,input:p}}function V(s,r){const n=document.createElement("button");n.type="button",n.className="btn btn-ghost btn-sm",n.style.cssText="display:inline-flex;align-items:center;gap:.35rem;";const t=document.createElement("span");return t.setAttribute("data-icon",s),n.appendChild(t),n.appendChild(document.createTextNode(r)),n}function F(s,r){const n=document.createElement("button");n.type="button",n.title=r,n.style.cssText="padding:.25rem .4rem;background:transparent;border:1px solid var(--dm-border,#333);border-radius:3px;color:var(--dm-text-muted,#aaa);cursor:pointer;display:inline-flex;align-items:center;";const t=document.createElement("span");return t.setAttribute("data-icon",s),n.appendChild(t),n}function ee(s){for(;s.firstChild;)s.removeChild(s.firstChild)}function Be(s){return String(s).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}let te=!1;function we(){te||(te=!0,I.register("edit-3",{viewBox:"0 0 24 24",paths:["M12 20h9","M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("clock",{viewBox:"0 0 24 24",paths:["M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10z","M12 6v6l4 2"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("corner-up-left",{viewBox:"0 0 24 24",paths:["M9 14 4 9l5-5","M20 20v-7a4 4 0 0 0-4-4H4"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("refresh-cw",{viewBox:"0 0 24 24",paths:["M23 4v6h-6","M1 20v-6h6","M3.51 9a9 9 0 0 1 14.85-3.36L23 10","M20.49 15a9 9 0 0 1-14.85 3.36L1 14"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("rotate-cw",{viewBox:"0 0 24 24",paths:["M23 4v6h-6","M20.49 15a9 9 0 1 1-2.12-9.36L23 10"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("code",{viewBox:"0 0 24 24",paths:["M16 18l6-6-6-6","M8 6l-6 6 6 6"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("chevron-up",{viewBox:"0 0 24 24",path:"M18 15l-6-6-6 6",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("chevron-down",{viewBox:"0 0 24 24",path:"M6 9l6 6 6-6",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("x",{viewBox:"0 0 24 24",paths:["M18 6L6 18","M6 6l12 12"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}))}
@@ -1,8 +1,8 @@
1
- import{replaceRange as ce}from"./markdown-toolbar.js";import{boolState as de,boolValue as pe,parseAttrs as te,serialiseTag as ne,setAttrs as me}from"./shortcode-tags.js";import{SHORTCODES as ue}from"./shortcode-registry.js";import{clearLookupCache as fe,lookupOptions as he}from"./shortcode-lookups.js";import{PREVIEW_RENDERERS as ge}from"./shortcode-preview.js";import{dommaHelp as be,whenCatalogue as xe}from"./domma-catalogue.js";import{SHORTCODE_EXPIRY_FIELDS as ye}from"../../../public/js/shortcode-expiry.mjs";import{makeCheckbox as ve,makeColourInput as Ee,makeField as v,makeIconInput as oe,makeImageInput as le,makeLivePreview as Ce,makeSelect as W,makeTextInput as Y}from"./shortcode-modal.js";const we=new Map(ue.map(e=>[e.name,e])),se=new Set(ye.map(e=>e.name)),re=6;export function templateAttrs(e){const n=String(e.template||"").match(new RegExp(`^\\[${e.name}([\\s\\S]*?)\\s*/?\\]`));return n?te(n[1]):{}}export function templateBody(e){if(e.selfClosing)return"";const n=String(e.template||"").match(new RegExp(`^\\[${e.name}[^\\]]*\\]([\\s\\S]*)\\[/${e.name}\\]$`));return n?n[1].replace(/^\n/,"").replace(/\n$/,""):""}export function templateChildren(e){if(!e.children)return[];const n=e.children.name,a=new RegExp(`\\[${n}([^\\]]*)\\]([\\s\\S]*?)\\[/${n}\\]`,"g"),c=[];for(const l of templateBody(e).matchAll(a))c.push({attrs:te(l[1]),body:l[2].replace(/^\n/,"").replace(/\n$/,"")});return c}const ke=new Set(["lookup","url"]);export function seedAttrs(e,n){const a=new Map((e.attrs||[]).map(l=>[l.name,l.type])),c={};for(const[l,p]of Object.entries(n))ke.has(a.get(l))||(c[l]=p);return c}export function buildSnippet(e,n,a=""){const c=ne(e.name,n,e.selfClosing);if(e.selfClosing)return c;const l=`[/${e.name}]`;return e.inline?`${c}${a}${l}`:`${c}
1
+ import{enhanceFontSelect as te}from"./font-picker.js";import{replaceRange as de}from"./markdown-toolbar.js";import{boolState as pe,boolValue as me,parseAttrs as ne,serialiseTag as oe,setAttrs as ue}from"./shortcode-tags.js";import{SHORTCODES as fe}from"./shortcode-registry.js";import{clearLookupCache as he,lookupOptions as be}from"./shortcode-lookups.js";import{PREVIEW_RENDERERS as ge}from"./shortcode-preview.js";import{dommaHelp as xe,whenCatalogue as ye}from"./domma-catalogue.js";import{SHORTCODE_EXPIRY_FIELDS as ve}from"../../../public/js/shortcode-expiry.mjs";import{makeCheckbox as Ee,makeColourInput as Ce,makeField as v,makeIconInput as le,makeImageInput as se,makeLivePreview as we,makeSelect as M,makeTextInput as Y}from"./shortcode-modal.js";const ke=new Map(fe.map(e=>[e.name,e])),re=new Set(ve.map(e=>e.name)),ie=6;export function templateAttrs(e){const n=String(e.template||"").match(new RegExp(`^\\[${e.name}([\\s\\S]*?)\\s*/?\\]`));return n?ne(n[1]):{}}export function templateBody(e){if(e.selfClosing)return"";const n=String(e.template||"").match(new RegExp(`^\\[${e.name}[^\\]]*\\]([\\s\\S]*)\\[/${e.name}\\]$`));return n?n[1].replace(/^\n/,"").replace(/\n$/,""):""}export function templateChildren(e){if(!e.children)return[];const n=e.children.name,a=new RegExp(`\\[${n}([^\\]]*)\\]([\\s\\S]*?)\\[/${n}\\]`,"g"),d=[];for(const l of templateBody(e).matchAll(a))d.push({attrs:ne(l[1]),body:l[2].replace(/^\n/,"").replace(/\n$/,"")});return d}const Se=new Set(["lookup","url"]);export function seedAttrs(e,n){const a=new Map((e.attrs||[]).map(l=>[l.name,l.type])),d={};for(const[l,p]of Object.entries(n))Se.has(a.get(l))||(d[l]=p);return d}export function buildSnippet(e,n,a=""){const d=oe(e.name,n,e.selfClosing);if(e.selfClosing)return d;const l=`[/${e.name}]`;return e.inline?`${d}${a}${l}`:`${d}
2
2
  ${a}
3
3
  ${l}`}export function buildChildrenBody(e,n){return n.map(a=>buildSnippet(e,a.attrs,a.body)).join(`
4
- `)}export function emitSnippet(e,n,a,c){const l=(e.formats||[]).find(p=>p.value===c);if(l&&typeof l.emit=="function"){const p=l.emit(n,a);if(p!=null)return p}return buildSnippet(e,n,a)}const Le="display:block;font-size:.7rem;font-weight:600;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;margin-bottom:.25rem;";function ie(e,n,a,c){const l=n===!0||n==null?"":String(n);if(e.type==="checkbox"){const s=ve(e.label),d=s.querySelector("input");return d.checked=de(n,e.default),d.addEventListener("change",a),{el:s,bare:!0,get:()=>pe(e,d.checked)}}if(e.type==="select"){const s=e.options.some(([w])=>w==="")?e.options:[["","- none -"],...e.options],d=W(s);return d.value=l,d.addEventListener("change",a),{el:v(e.label,d),get:()=>d.value||null}}if(e.type==="icon"){const{el:s,input:d}=oe("icon name (optional)",l);return d.addEventListener("input",a),{el:v(e.label,s),get:()=>d.value.trim()||null}}if(e.type==="image"){const{el:s,input:d}=le("/media/photo.jpg",l);return d.addEventListener("input",a),{el:v(e.label,s),get:()=>d.value.trim()||null}}if(e.type==="colour"){const{el:s,input:d}=Ee("#0f172a or a theme colour",l);return d.addEventListener("input",a),{el:v(e.label,s),get:()=>d.value.trim()||null}}if(e.type==="lookup"){const s=W([["","Loading\u2026"]]);s.disabled=!0,s.addEventListener("change",a);let d;const w=()=>{const h=c(),P=e.source==="collection-fields"?String(h.slug??""):e.source;P!==d&&(d=P,s.disabled=!0,he(e.source,h).then(f=>{const y=s.value||l,g=f.some(([T])=>T===y),k=[["","- none -"],...f];y&&!g&&k.push([y,`${y} (missing)`]),s.replaceChildren();for(const[T,b]of k){const $=document.createElement("option");$.value=T,$.textContent=b,s.appendChild($)}s.value=y,s.disabled=!1,a()}))};return w(),{el:v(e.label,s),get:()=>s.value||null,refresh:e.source==="collection-fields"?w:null}}const p=Y(e.placeholder||(e.type==="url"?"/about or https://example.com":""),l);return e.type==="number"&&(p.type="number"),p.addEventListener("input",a),{el:v(e.label,p),get:()=>p.value.trim()||null}}function Se(e,n){xe(a=>{const c=be(a,n);if(!c)return;const l=document.createElement("small");l.className="sc-domma-help",l.style.cssText="display:block;margin-top:.2rem;font-size:.75em;color:var(--dm-text-muted,#999);",l.textContent=c,e.appendChild(l)})}export function openShortcodeForm(e,n,a={}){const{span:c=null,defaults:l=null}=a,p=!!c;fe();const s=e.selectionStart,d=e.selectionEnd,w=e.value.slice(s,d),h=n.children?we.get(n.children.name):null,P={...seedAttrs(n,templateAttrs(n)),...l||{}},f=document.createElement("div");f.style.cssText="padding:.25rem 0 .5rem;display:flex;flex-direction:column;gap:.75rem;";const y=[],g=[];let k=()=>{};const T=()=>{const t={};for(const{attr:o,w:m}of y){const r=m.get();r!=null&&r!==""&&(t[o.name]=r)}return t},b=()=>k(),$=()=>T();let _=null;!p&&n.formats?.length&&(_=W(n.formats.map(t=>[t.value,t.label])),_.addEventListener("change",b),f.appendChild(v("Format",_)));const R=n.attrs||[],D=R.length>re+2?re:R.length,q=(t,o)=>{const m=p?c.attrs[t.name]:P[t.name],r=ie(t,m,b,$);y.push({attr:t,w:r,initial:r.get()});const x=t.domma&&r.bare?document.createElement("div"):r.el;x!==r.el&&x.appendChild(r.el),o.appendChild(x),t.domma&&Se(x,t)};for(const t of R.slice(0,D))q(t,f);if(D<R.length){const t=document.createElement("details");t.style.cssText="border-top:1px solid var(--dm-border,#333);padding-top:.6rem;";const o=document.createElement("summary");o.textContent=`More options (${R.length-D})`,o.style.cssText="cursor:pointer;font-size:.75rem;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;",t.appendChild(o);const m=document.createElement("div");m.style.cssText="display:flex;flex-direction:column;gap:.75rem;padding-top:.75rem;",t.appendChild(m);for(const r of R.slice(D))q(r,m);f.appendChild(t)}let L=null,S=null;const F=document.createElement("div");if(!p&&h){const t=document.createElement("div");t.style.cssText=Le,t.textContent=`${h.label}s`,f.appendChild(t),F.style.cssText="display:flex;flex-direction:column;gap:.4rem;",f.appendChild(F),S=document.createElement("button"),S.type="button",S.textContent=`+ Add ${h.label.toLowerCase()}`,S.style.cssText="padding:.35rem .75rem;background:transparent;border:1px dashed var(--dm-border,#555);border-radius:4px;color:var(--dm-text-muted,#aaa);cursor:pointer;font-size:.85em;align-self:flex-start;",S.addEventListener("click",()=>{V({attrs:{},body:templateBody(h)||"Content"}),k()}),f.appendChild(S);const o=templateChildren(n),m=o.length?o:[{attrs:{},body:"Content"}];for(const r of m)V({attrs:seedAttrs(h,r.attrs),body:r.body});w&&(g[0].bodyInput.value=w)}else!p&&!n.selfClosing&&(L=document.createElement("textarea"),L.rows=n.inline?2:4,L.value=w||templateBody(n),L.style.cssText="width:100%;padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;font-family:inherit;box-sizing:border-box;resize:vertical;",L.addEventListener("input",b),f.appendChild(v("Content",L)));function V(t){if(g.length>=(n.children.max??20))return;const o=document.createElement("div");o.style.cssText="display:flex;flex-direction:column;gap:.25rem;";const m=document.createElement("div");m.style.cssText="display:flex;gap:.35rem;align-items:center;",o.appendChild(m);const r=[],x=(h.attrs||[]).filter(i=>!se.has(i.name)),H=(h.attrs||[]).filter(i=>se.has(i.name));for(const i of x)if(i.type==="icon"){const{el:u,input:C}=oe(i.label.toLowerCase(),t.attrs[i.name]||"");u.style.flex=".7",C.addEventListener("input",b),r.push({attr:i,get:()=>C.value.trim()||null}),m.appendChild(u)}else if(i.type==="image"){const{el:u,input:C}=le(i.label,t.attrs[i.name]||"");u.style.flex="1",C.addEventListener("input",b),r.push({attr:i,get:()=>C.value.trim()||null}),m.appendChild(u)}else if(i.type==="select"){const u=W(i.options);u.value=t.attrs[i.name]||i.options[0][0],u.style.flex=".7",u.addEventListener("change",b),r.push({attr:i,get:()=>u.value||null}),m.appendChild(u)}else{const u=Y(i.label,t.attrs[i.name]||"");u.style.flex="1",u.addEventListener("input",b),r.push({attr:i,get:()=>u.value.trim()||null}),m.appendChild(u)}const M=Y("Content",t.body||"");M.style.flex="1.2",M.addEventListener("input",b),m.appendChild(M);const A=document.createElement("button");if(A.type="button",A.textContent="\xD7",A.style.cssText="padding:.3rem .5rem;background:transparent;border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text-muted,#aaa);cursor:pointer;font-size:.85em;flex-shrink:0;",H.length){const i=document.createElement("details");i.style.cssText="margin-left:.15rem;";const u=document.createElement("summary");u.textContent="Expiry",u.style.cssText="cursor:pointer;font-size:.7rem;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;",i.appendChild(u);const C=document.createElement("div");C.style.cssText="display:flex;flex-direction:column;gap:.6rem;padding:.5rem 0 .25rem .75rem;",i.appendChild(C);for(const z of H){const ee=ie(z,t.attrs[z.name],b,$);r.push({attr:z,get:ee.get}),C.appendChild(ee.el)}H.some(z=>t.attrs[z.name]!=null)&&(i.open=!0),o.appendChild(i)}const Z={row:o,fields:r,bodyInput:M,remove:A};A.addEventListener("click",()=>{g.length<=(n.children.min??1)||(g.splice(g.indexOf(Z),1),o.remove(),k())}),m.appendChild(A),g.push(Z),F.appendChild(o),window.I?.scan?.(o)}const X=ge[n.preview];let I=null;if(X){const t=document.createElement("div");t.style.cssText="background:var(--dm-background-alt,#111);border:1px solid var(--dm-border,#333);border-radius:4px;padding:.75rem;min-height:2.5rem;display:flex;align-items:center;overflow-x:auto;",I=document.createElement("span"),t.appendChild(I),f.appendChild(v("Preview",t))}const K=Ce();f.appendChild(v(p?"Tag preview":"Shortcode preview",K.el));const N=document.createElement("div");N.style.cssText="display:flex;justify-content:flex-end;gap:.75rem;padding-top:.75rem;border-top:1px solid var(--dm-border,#333);";const B=document.createElement("button");B.type="button",B.className="btn btn-ghost",B.textContent="Cancel";const O=document.createElement("button");O.type="button",O.className="btn btn-primary",O.textContent=p?"Apply":`Insert ${n.label}`,N.appendChild(B),N.appendChild(O),f.appendChild(N);const G=()=>h&&g.length?buildChildrenBody(h,g.map(t=>({attrs:Object.fromEntries(t.fields.map(o=>[o.attr.name,o.get()]).filter(([,o])=>o!=null)),body:t.bodyInput.value}))):L?L.value:templateBody(n),J=()=>emitSnippet(n,T(),G(),_?.value),ae=t=>{if(n.inline||n.selfClosing||!t.startsWith("["))return t;const o=e.value.slice(0,s),m=e.value.slice(d),r=o===""||o.endsWith(`
4
+ `)}export function emitSnippet(e,n,a,d){const l=(e.formats||[]).find(p=>p.value===d);if(l&&typeof l.emit=="function"){const p=l.emit(n,a);if(p!=null)return p}return buildSnippet(e,n,a)}const Le="display:block;font-size:.7rem;font-weight:600;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;margin-bottom:.25rem;";function ae(e,n,a,d){const l=n===!0||n==null?"":String(n);if(e.type==="checkbox"){const r=Ee(e.label),c=r.querySelector("input");return c.checked=pe(n,e.default),c.addEventListener("change",a),{el:r,bare:!0,get:()=>me(e,c.checked)}}if(e.type==="select"){const r=e.options.some(([h])=>h==="")?e.options:[["","- none -"],...e.options],c=M(r);c.value=l,c.addEventListener("change",a);const w=v(e.label,c);return e.name==="font"&&te(c,{label:e.label}),{el:w,get:()=>c.value||null}}if(e.type==="icon"){const{el:r,input:c}=le("icon name (optional)",l);return c.addEventListener("input",a),{el:v(e.label,r),get:()=>c.value.trim()||null}}if(e.type==="image"){const{el:r,input:c}=se("/media/photo.jpg",l);return c.addEventListener("input",a),{el:v(e.label,r),get:()=>c.value.trim()||null}}if(e.type==="colour"){const{el:r,input:c}=Ce("#0f172a or a theme colour",l);return c.addEventListener("input",a),{el:v(e.label,r),get:()=>c.value.trim()||null}}if(e.type==="lookup"){const r=M([["","Loading\u2026"]]);r.disabled=!0,r.addEventListener("change",a);let c;const w=()=>{const h=d(),P=e.source==="collection-fields"?String(h.slug??""):e.source;P!==c&&(c=P,r.disabled=!0,be(e.source,h).then(f=>{const y=r.value||l,b=f.some(([T])=>T===y),k=[["","- none -"],...f];y&&!b&&k.push([y,`${y} (missing)`]),r.replaceChildren();for(const[T,g]of k){const $=document.createElement("option");$.value=T,$.textContent=g,r.appendChild($)}r.value=y,r.disabled=!1,a()}))};return w(),{el:v(e.label,r),get:()=>r.value||null,refresh:e.source==="collection-fields"?w:null}}const p=Y(e.placeholder||(e.type==="url"?"/about or https://example.com":""),l);return e.type==="number"&&(p.type="number"),p.addEventListener("input",a),{el:v(e.label,p),get:()=>p.value.trim()||null}}function Te(e,n){ye(a=>{const d=xe(a,n);if(!d)return;const l=document.createElement("small");l.className="sc-domma-help",l.style.cssText="display:block;margin-top:.2rem;font-size:.75em;color:var(--dm-text-muted,#999);",l.textContent=d,e.appendChild(l)})}export function openShortcodeForm(e,n,a={}){const{span:d=null,defaults:l=null}=a,p=!!d;he();const r=e.selectionStart,c=e.selectionEnd,w=e.value.slice(r,c),h=n.children?ke.get(n.children.name):null,P={...seedAttrs(n,templateAttrs(n)),...l||{}},f=document.createElement("div");f.style.cssText="padding:.25rem 0 .5rem;display:flex;flex-direction:column;gap:.75rem;";const y=[],b=[];let k=()=>{};const T=()=>{const t={};for(const{attr:o,w:m}of y){const i=m.get();i!=null&&i!==""&&(t[o.name]=i)}return t},g=()=>k(),$=()=>T();let _=null;!p&&n.formats?.length&&(_=M(n.formats.map(t=>[t.value,t.label])),_.addEventListener("change",g),f.appendChild(v("Format",_)));const R=n.attrs||[],D=R.length>ie+2?ie:R.length,q=(t,o)=>{const m=p?d.attrs[t.name]:P[t.name],i=ae(t,m,g,$);y.push({attr:t,w:i,initial:i.get()});const x=t.domma&&i.bare?document.createElement("div"):i.el;x!==i.el&&x.appendChild(i.el),o.appendChild(x),t.domma&&Te(x,t)};for(const t of R.slice(0,D))q(t,f);if(D<R.length){const t=document.createElement("details");t.style.cssText="border-top:1px solid var(--dm-border,#333);padding-top:.6rem;";const o=document.createElement("summary");o.textContent=`More options (${R.length-D})`,o.style.cssText="cursor:pointer;font-size:.75rem;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;",t.appendChild(o);const m=document.createElement("div");m.style.cssText="display:flex;flex-direction:column;gap:.75rem;padding-top:.75rem;",t.appendChild(m);for(const i of R.slice(D))q(i,m);f.appendChild(t)}let S=null,L=null;const W=document.createElement("div");if(!p&&h){const t=document.createElement("div");t.style.cssText=Le,t.textContent=`${h.label}s`,f.appendChild(t),W.style.cssText="display:flex;flex-direction:column;gap:.4rem;",f.appendChild(W),L=document.createElement("button"),L.type="button",L.textContent=`+ Add ${h.label.toLowerCase()}`,L.style.cssText="padding:.35rem .75rem;background:transparent;border:1px dashed var(--dm-border,#555);border-radius:4px;color:var(--dm-text-muted,#aaa);cursor:pointer;font-size:.85em;align-self:flex-start;",L.addEventListener("click",()=>{V({attrs:{},body:templateBody(h)||"Content"}),k()}),f.appendChild(L);const o=templateChildren(n),m=o.length?o:[{attrs:{},body:"Content"}];for(const i of m)V({attrs:seedAttrs(h,i.attrs),body:i.body});w&&(b[0].bodyInput.value=w)}else!p&&!n.selfClosing&&(S=document.createElement("textarea"),S.rows=n.inline?2:4,S.value=w||templateBody(n),S.style.cssText="width:100%;padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;font-family:inherit;box-sizing:border-box;resize:vertical;",S.addEventListener("input",g),f.appendChild(v("Content",S)));function V(t){if(b.length>=(n.children.max??20))return;const o=document.createElement("div");o.style.cssText="display:flex;flex-direction:column;gap:.25rem;";const m=document.createElement("div");m.style.cssText="display:flex;gap:.35rem;align-items:center;",o.appendChild(m);const i=[],x=(h.attrs||[]).filter(s=>!re.has(s.name)),H=(h.attrs||[]).filter(s=>re.has(s.name));for(const s of x)if(s.type==="icon"){const{el:u,input:C}=le(s.label.toLowerCase(),t.attrs[s.name]||"");u.style.flex=".7",C.addEventListener("input",g),i.push({attr:s,get:()=>C.value.trim()||null}),m.appendChild(u)}else if(s.type==="image"){const{el:u,input:C}=se(s.label,t.attrs[s.name]||"");u.style.flex="1",C.addEventListener("input",g),i.push({attr:s,get:()=>C.value.trim()||null}),m.appendChild(u)}else if(s.type==="select"){const u=M(s.options);u.value=t.attrs[s.name]||s.options[0][0],u.style.flex=".7",u.addEventListener("change",g),i.push({attr:s,get:()=>u.value||null}),m.appendChild(u),s.name==="font"&&te(u,{label:s.label})}else{const u=Y(s.label,t.attrs[s.name]||"");u.style.flex="1",u.addEventListener("input",g),i.push({attr:s,get:()=>u.value.trim()||null}),m.appendChild(u)}const F=Y("Content",t.body||"");F.style.flex="1.2",F.addEventListener("input",g),m.appendChild(F);const A=document.createElement("button");if(A.type="button",A.textContent="\xD7",A.style.cssText="padding:.3rem .5rem;background:transparent;border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text-muted,#aaa);cursor:pointer;font-size:.85em;flex-shrink:0;",H.length){const s=document.createElement("details");s.style.cssText="margin-left:.15rem;";const u=document.createElement("summary");u.textContent="Expiry",u.style.cssText="cursor:pointer;font-size:.7rem;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;",s.appendChild(u);const C=document.createElement("div");C.style.cssText="display:flex;flex-direction:column;gap:.6rem;padding:.5rem 0 .25rem .75rem;",s.appendChild(C);for(const z of H){const ee=ae(z,t.attrs[z.name],g,$);i.push({attr:z,get:ee.get}),C.appendChild(ee.el)}H.some(z=>t.attrs[z.name]!=null)&&(s.open=!0),o.appendChild(s)}const Z={row:o,fields:i,bodyInput:F,remove:A};A.addEventListener("click",()=>{b.length<=(n.children.min??1)||(b.splice(b.indexOf(Z),1),o.remove(),k())}),m.appendChild(A),b.push(Z),W.appendChild(o),window.I?.scan?.(o)}const X=ge[n.preview];let I=null;if(X){const t=document.createElement("div");t.style.cssText="background:var(--dm-background-alt,#111);border:1px solid var(--dm-border,#333);border-radius:4px;padding:.75rem;min-height:2.5rem;display:flex;align-items:center;overflow-x:auto;",I=document.createElement("span"),t.appendChild(I),f.appendChild(v("Preview",t))}const K=we();f.appendChild(v(p?"Tag preview":"Shortcode preview",K.el));const N=document.createElement("div");N.style.cssText="display:flex;justify-content:flex-end;gap:.75rem;padding-top:.75rem;border-top:1px solid var(--dm-border,#333);";const B=document.createElement("button");B.type="button",B.className="btn btn-ghost",B.textContent="Cancel";const O=document.createElement("button");O.type="button",O.className="btn btn-primary",O.textContent=p?"Apply":`Insert ${n.label}`,N.appendChild(B),N.appendChild(O),f.appendChild(N);const G=()=>h&&b.length?buildChildrenBody(h,b.map(t=>({attrs:Object.fromEntries(t.fields.map(o=>[o.attr.name,o.get()]).filter(([,o])=>o!=null)),body:t.bodyInput.value}))):S?S.value:templateBody(n),J=()=>emitSnippet(n,T(),G(),_?.value),ce=t=>{if(n.inline||n.selfClosing||!t.startsWith("["))return t;const o=e.value.slice(0,r),m=e.value.slice(c),i=o===""||o.endsWith(`
5
5
  `)?"":`
6
6
  `,x=m===""||m.startsWith(`
7
7
  `)?"":`
8
- `;return`${r}${t}${x}`};k=()=>{S&&(S.disabled=g.length>=(n.children.max??20));for(const{w:t}of y)t.refresh?.();if(I){const t=X(p?{...c.attrs,...Q()}:T(),p?"":G());I.style.cssText=t.css,I.textContent=t.text}K.update(p?ne(c.name,{...c.attrs,...U()},c.selfClosing,{keepEmpty:!!n.block}):J())};function Q(){const t={};for(const{attr:o,w:m,initial:r}of y){const x=m.get();x!==r&&(t[o.name]=x)}return t}function U(){const t=Q();if(n.block)for(const o of Object.keys(t))t[o]==null&&(t[o]="");return t}const j=E.slideover({title:p?`Edit ${n.label}`:`Insert ${n.label}`,size:h?"lg":"md",position:"right",content:f});return j.open(),window.I?.scan?.(f),k(),B.addEventListener("click",()=>j.close()),O.addEventListener("click",()=>{if(j.close(),p)me(e,c,U(),{keepEmpty:!!n.block});else{const t=ae(J());ce(e,s,d,t),e.setSelectionRange(s+t.length,s+t.length)}e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}),requestAnimationFrame(()=>{f.querySelector("input:not([type=checkbox]):not([type=color]), select, textarea")?.focus()}),j}
8
+ `;return`${i}${t}${x}`};k=()=>{L&&(L.disabled=b.length>=(n.children.max??20));for(const{w:t}of y)t.refresh?.();if(I){const t=X(p?{...d.attrs,...Q()}:T(),p?"":G());I.style.cssText=t.css,I.textContent=t.text}K.update(p?oe(d.name,{...d.attrs,...U()},d.selfClosing,{keepEmpty:!!n.block}):J())};function Q(){const t={};for(const{attr:o,w:m,initial:i}of y){const x=m.get();x!==i&&(t[o.name]=x)}return t}function U(){const t=Q();if(n.block)for(const o of Object.keys(t))t[o]==null&&(t[o]="");return t}const j=E.slideover({title:p?`Edit ${n.label}`:`Insert ${n.label}`,size:h?"lg":"md",position:"right",content:f});return j.open(),window.I?.scan?.(f),k(),B.addEventListener("click",()=>j.close()),O.addEventListener("click",()=>{if(j.close(),p)ue(e,d,U(),{keepEmpty:!!n.block});else{const t=ce(J());de(e,r,c,t),e.setSelectionRange(r+t.length,r+t.length)}e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}),requestAnimationFrame(()=>{f.querySelector("input:not([type=checkbox]):not([type=color]), select, textarea")?.focus()}),j}
@@ -1 +1 @@
1
- export function siteSearchSection(a){const r=a.querySelector("[data-site-search-tab]"),n=a.querySelector("[data-site-search-panel]"),h=a.querySelector("[data-site-search-dirty]");let s=null,d=!1,i=!1;const f=[];function u(e){for(const t of e.querySelectorAll("button, a")){if(t.dataset.siteTooltip||t.classList.contains("dm-help-btn")||!t.querySelector("svg, [data-icon]"))continue;const o=t.getAttribute("aria-label")||t.title||t.textContent.trim();if(!o)continue;t.dataset.siteTooltip="1",t.dataset.tooltip=o,t.setAttribute("aria-label",o);const c=E.tooltip(t,{content:o,placement:"bottom"});f.push(()=>{for(const l of Array.isArray(c)?c:[c])l?.destroy?.()})}}async function p(){if(!(d||s||i)){d=!0,n.textContent="Loading Search settings...";try{const[e,t]=await Promise.all([fetch("/admin/js/templates/search.html",{cache:"no-cache"}),import("../views/search.js")]);if(!e.ok)throw new Error("Could not load Search settings.");const o=await e.text();if(i||!a.isConnected)return;const c=document.createElement("template");c.innerHTML=o,n.replaceChildren(c.content.cloneNode(!0)),await t.mountSearchSettings($(n),{onDirty:l=>{i||(h.hidden=!l)},onReady:l=>{i?l.dispose():(s=l,u(n))}}),i||u(n)}catch(e){i||(n.textContent=e.message||"Could not load Search settings. Reopen Site Settings to try again.",n.setAttribute("role","alert"))}finally{d=!1}}}return r.addEventListener("click",p),u(a.closest(".dm-plugin-shell")||a),r.classList.contains("active")&&p(),{dirty:()=>s?.dirty()||!1,save:()=>s?.save(),discard:()=>s?.discard(),dispose(){i=!0,r.removeEventListener("click",p),s?.dispose(),f.splice(0).forEach(e=>e())}}}
1
+ export function siteSearchSection(o,{onDirty:h=()=>{}}={}){const r=o.querySelector("[data-site-search-tab]"),n=o.querySelector("[data-site-search-panel]"),m=o.querySelector("[data-site-search-dirty]");let s=null,d=!1,a=!1;const f=[];function u(e){for(const t of e.querySelectorAll("button, a")){if(t.dataset.siteTooltip||t.classList.contains("dm-help-btn")||!t.querySelector("svg, [data-icon]"))continue;const c=t.getAttribute("aria-label")||t.title||t.textContent.trim();if(!c)continue;t.dataset.siteTooltip="1",t.dataset.tooltip=c,t.setAttribute("aria-label",c);const l=E.tooltip(t,{content:c,placement:"bottom"});f.push(()=>{for(const i of Array.isArray(l)?l:[l])i?.destroy?.()})}}async function p(){if(!(d||s||a)){d=!0,n.textContent="Loading Search settings...";try{const[e,t]=await Promise.all([fetch("/admin/js/templates/search.html",{cache:"no-cache"}),import("../views/search.js")]);if(!e.ok)throw new Error("Could not load Search settings.");const c=await e.text();if(a||!o.isConnected)return;const l=document.createElement("template");l.innerHTML=c,n.replaceChildren(l.content.cloneNode(!0)),await t.mountSearchSettings($(n),{onDirty:i=>{a||(m.hidden=!i,h(i))},onReady:i=>{a?i.dispose():(s=i,u(n))}}),a||u(n)}catch(e){a||(n.textContent=e.message||"Could not load Search settings. Reopen Appearance to try again.",n.setAttribute("role","alert"))}finally{d=!1}}}return r.addEventListener("click",p),u(o.closest(".dm-plugin-shell")||o),r.classList.contains("active")&&p(),{dirty:()=>s?.dirty()||!1,save:()=>s?.save(),discard:()=>s?.discard(),dispose(){a=!0,r.removeEventListener("click",p),s?.dispose(),f.splice(0).forEach(e=>e())}}}