domma-cms 1.49.2 → 1.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/admin/js/lib/chats-arrange.js +2 -2
  3. package/admin/js/lib/launchers-arrange.js +5 -2
  4. package/admin/js/lib/site-settings-arrange.js +3 -3
  5. package/admin/js/templates/chats.html +26 -2
  6. package/admin/js/templates/docs/usage-chat.html +51 -5
  7. package/admin/js/templates/docs/usage-launchers.html +2 -0
  8. package/admin/js/templates/launchers.html +4 -0
  9. package/admin/js/templates/settings.html +34 -0
  10. package/admin/js/views/chats.js +5 -5
  11. package/admin/js/views/launchers.js +107 -33
  12. package/docs/DommaFeatures.md +4 -0
  13. package/docs/screenshots/builder-character-site-settings.png +0 -0
  14. package/docs/screenshots/launcher-della-settings.png +0 -0
  15. package/docs/screenshots/site-settings-characters.png +0 -0
  16. package/package.json +2 -1
  17. package/public/css/characters.css +1 -0
  18. package/public/css/launcher-chat.css +1 -1
  19. package/public/css/launchers.css +1 -1
  20. package/public/images/characters/daisy-poses.png +0 -0
  21. package/public/images/characters/della-poses.png +0 -0
  22. package/public/images/characters/dot-poses.png +0 -0
  23. package/public/js/builder-character.mjs +2 -0
  24. package/public/js/character-view.mjs +1 -0
  25. package/public/js/characters.mjs +1 -0
  26. package/public/js/launcher-chat.mjs +20 -10
  27. package/public/js/launcher-settings.mjs +6 -2
  28. package/public/js/launchers.mjs +3 -3
  29. package/scripts/build.js +1 -0
  30. package/server/routes/api/chat.js +4 -2
  31. package/server/routes/api/chats.js +37 -0
  32. package/server/routes/api/settings.js +36 -2
  33. package/server/services/assistant.js +67 -0
  34. package/server/services/chat/ai.js +109 -0
  35. package/server/services/chat/conversation.js +37 -2
  36. package/server/services/chat/launcher-bridge.js +3 -1
  37. package/server/services/chat/saved.js +117 -0
  38. package/server/services/chat/settings.js +31 -4
  39. package/server/services/chat/store.js +1 -1
  40. package/server/services/collectionAccess.js +2 -1
  41. package/server/services/launchers.js +7 -2
  42. package/server/services/presetCollections.js +24 -2
  43. package/server/services/siteGitignore.js +1 -1
@@ -1,4 +1,4 @@
1
- import{apiRequest as V,api as ye}from"../api.js";import{addBannerAction as we}from"../lib/plugin-chrome.js";import{helpPopovers as ke}from"../lib/help-popover.js";import{onceClosed as Ve,openMenuAt as Se,sidebarCount as Ee,viewLifetime as Je}from"../lib/tool-kit.js";import{rowPlaceKeeper as Ge}from"../lib/menu-drag.js";import{FILTERS as Qe,LAUNCHER_POSITION_LABEL as Ce,arrangeLaunchers as Ze,blankLauncher as ea,checkLauncherForm as aa,countLaunchers as ta,duplicateLauncher as la,formFromLauncher as na,launcherFromForm as sa,launcherRow as oa,moveItem as ia,previewSpot as da}from"../lib/launchers-arrange.js";import{LAUNCHER_LIMITS as u,LAUNCHER_TOKENS as J,launcherColourCss as Me,launcherHref as G}from"../../../public/js/launcher-settings.mjs";const $e=/^#\/launchers\/?(\?.*)?$/,Te="#/launchers",Q="launchers.filter",R="launchers.draft",ra=`
1
+ import{apiRequest as V,api as ye}from"../api.js";import{addBannerAction as we}from"../lib/plugin-chrome.js";import{helpPopovers as ke}from"../lib/help-popover.js";import{onceClosed as Ve,openMenuAt as Se,sidebarCount as Ce,viewLifetime as Ge}from"../lib/tool-kit.js";import{rowPlaceKeeper as Je}from"../lib/menu-drag.js";import{FILTERS as Qe,LAUNCHER_POSITION_LABEL as Te,arrangeLaunchers as Ze,blankLauncher as ea,checkLauncherForm as aa,countLaunchers as ta,duplicateLauncher as la,formFromLauncher as na,launcherFromForm as sa,launcherRow as ia,moveItem as oa,previewSpot as da}from"../lib/launchers-arrange.js";import{LAUNCHER_LIMITS as s,LAUNCHER_TOKENS as G,launcherChatAccentCss as ra,launcherColourCss as $e,launcherHref as J}from"../../../public/js/launcher-settings.mjs";const Me=/^#\/launchers\/?(\?.*)?$/,Ee="#/launchers",Q="launchers.filter",D="launchers.draft",ca=`
2
2
  <div class="lnx-row" data-id="{{id}}" tabindex="0" data-bind-class="rowCls">
3
3
  <span class="lnx-grip" title="Drag to reorder" aria-hidden="true"><span data-icon="menu" data-icon-size="14"></span></span>
4
4
  <span class="lnx-disc" data-bind-class="pill && 'is-pill'" data-bind-style="discStyle" aria-hidden="true"><span data-icon="{{icon}}"></span><span data-bind-hidden="!pill">{{label}}</span></span>
@@ -9,49 +9,49 @@ import{apiRequest as V,api as ye}from"../api.js";import{addBannerAction as we}fr
9
9
  </span>
10
10
  <label class="lnx-switch" title="On or off"><input type="checkbox" class="form-switch lnx-toggle" data-bind-checked="on" aria-label="{{name}} on or off"></label>
11
11
  <button type="button" class="lnx-kebab" aria-label="Actions for {{name}}" title="Actions">\u22EE</button>
12
- </div>`,h={triggerStyle:[["icon","Disc - icon only"],["icon-text","Pill - icon and label"]],tooltipMode:[["label","The label"],["custom","Words of its own"],["off","None"]],actionType:[["modal","A page, form or block, in a modal"],["slideover","A page, form or block, in a slideover"],["chat","A chat"]],kind:[["page","Page"],["form","Form"],["block","Block"]],modalSize:[["xs","Extra small (320px)"],["sm","Small (400px)"],["md","Medium (600px)"],["lg","Large (800px)"],["xl","Extra large (1140px)"],["xxl","Huge (1400px)"],["full","Nearly full width (90%)"],["screen","Full screen"],["custom","Custom\u2026"]],modalHeight:[["auto","Fit the page"],["sm","Short (40% of the window)"],["md","Medium (60%)"],["lg","Tall (80%)"],["full","Nearly full height (90%)"],["custom","Custom\u2026"]],widthUnit:[["px","px"],["%","% of window"]],heightUnit:[["vh","% of window"],["px","px"]],side:[["right","Right"],["left","Left"]],width:[["sm","Narrow (360px)"],["md","Medium (480px)"],["lg","Wide (640px)"],["xl","Extra wide (860px)"]],devices:[["all","Phones and desktops"],["desktop","Desktops only"],["phone","Phones only"]],pagesMode:[["all","Every page"],["only","Only these pages"],["except","Every page except these"]],audience:[["everyone","Everyone"],["signed-in","Signed-in people only"],["signed-out","Signed-out visitors only"]],askDetails:[["offline","When nobody is there to answer"],["always","Before the chat starts"],["never","Never"]],background:[["","Theme (primary)"],...J.map(s=>[s,s.charAt(0).toUpperCase()+s.slice(1)]),["custom","Custom hex\u2026"]],foreground:[["","Theme (reads on the background)"],...J.map(s=>[s,s.charAt(0).toUpperCase()+s.slice(1)]),["custom","Custom hex\u2026"]]},ca=["TL","TC","TR","ML","","MR","BL","BC","BR"],f=s=>s.map(([d,T])=>`<option value="${d}">${T}</option>`).join(""),Oe=s=>ca.map(d=>d?`<button type="button" data-pos="${d}" data-bind-class="${s}.value === '${d}' && 'is-on'" title="${Ce[d]}" aria-label="${Ce[d]}">${d}</button>`:'<button type="button" class="lnx-corner-mid" tabindex="-1" aria-hidden="true"></button>').join(""),pa=`
12
+ </div>`,c={triggerStyle:[["icon","Disc - icon only"],["icon-text","Pill - icon and label"]],tooltipMode:[["label","The label"],["custom","Words of its own"],["off","None"]],actionType:[["modal","A page, form or block, in a modal"],["slideover","A page, form or block, in a slideover"],["chat","A chat"]],kind:[["page","Page"],["form","Form"],["block","Block"]],modalSize:[["xs","Extra small (320px)"],["sm","Small (400px)"],["md","Medium (600px)"],["lg","Large (800px)"],["xl","Extra large (1140px)"],["xxl","Huge (1400px)"],["full","Nearly full width (90%)"],["screen","Full screen"],["custom","Custom\u2026"]],modalHeight:[["auto","Fit the page"],["sm","Short (40% of the window)"],["md","Medium (60%)"],["lg","Tall (80%)"],["full","Nearly full height (90%)"],["custom","Custom\u2026"]],widthUnit:[["px","px"],["%","% of window"]],heightUnit:[["vh","% of window"],["px","px"]],side:[["right","Right"],["left","Left"]],width:[["sm","Narrow (360px)"],["md","Medium (480px)"],["lg","Wide (640px)"],["xl","Extra wide (860px)"]],devices:[["all","Phones and desktops"],["desktop","Desktops only"],["phone","Phones only"]],pagesMode:[["all","Every page"],["only","Only these pages"],["except","Every page except these"]],audience:[["everyone","Everyone"],["signed-in","Signed-in people only"],["signed-out","Signed-out visitors only"]],askDetails:[["offline","When nobody is there to answer"],["always","Before the chat starts"],["never","Never"]],times:[["time","The time (09:42)"],["datetime","The date and time (10 Nov, 09:42)"],["none","Nothing"]],personButton:[["below","A button under the conversation"],["header","An icon in the chat heading"]],chatSize:[["sm","Small (340 x 500)"],["md","Medium (400 x 600)"],["lg","Large (480 x 720)"],["custom","Custom\u2026"]],background:[["","Theme (primary)"],...G.map(i=>[i,i.charAt(0).toUpperCase()+i.slice(1)]),["custom","Custom hex\u2026"]],foreground:[["","Theme (reads on the background)"],...G.map(i=>[i,i.charAt(0).toUpperCase()+i.slice(1)]),["custom","Custom hex\u2026"]]},ha=["TL","TC","TR","ML","","MR","BL","BC","BR"],h=i=>i.map(([p,A])=>`<option value="${p}">${A}</option>`).join(""),Ae=i=>ha.map(p=>p?`<button type="button" data-pos="${p}" data-bind-class="${i}.value === '${p}' && 'is-on'" title="${Te[p]}" aria-label="${Te[p]}">${p}</button>`:'<button type="button" class="lnx-corner-mid" tabindex="-1" aria-hidden="true"></button>').join(""),pa=`
13
13
  <div class="lnx-form">
14
14
  <div class="lnx-section">
15
15
  <h6><span data-icon="message-circle" data-icon-size="14"></span> The disc</h6>
16
16
  <div class="lnx-grid2">
17
17
  <div class="lnx-field">
18
18
  <label class="form-label" for="lnx-f-name">Name <span data-help="Only you see this - it names the launcher in this list."></span></label>
19
- <input id="lnx-f-name" class="form-input" maxlength="${u.nameMax}" data-model="name.value">
19
+ <input id="lnx-f-name" class="form-input" maxlength="${s.nameMax}" data-model="name.value">
20
20
  <small class="lnx-err" data-bind-hidden="!err.value.name" data-bind-text="err.value.name"></small>
21
21
  </div>
22
22
  <div class="lnx-field">
23
23
  <label class="form-label" for="lnx-f-label">Label <span data-help="What the disc says: read out to screen readers, and written on the pill when the style is Pill."></span></label>
24
- <input id="lnx-f-label" class="form-input" maxlength="${u.labelMax}" data-model="label.value">
24
+ <input id="lnx-f-label" class="form-input" maxlength="${s.labelMax}" data-model="label.value">
25
25
  <small class="lnx-err" data-bind-hidden="!err.value.label" data-bind-text="err.value.label"></small>
26
26
  </div>
27
27
  <div class="lnx-field">
28
28
  <label class="form-label" for="lnx-f-tipmode">Tooltip <span data-help="Shown when a visitor hovers over the disc or tabs to it. The label gives a pill no tooltip - it already shows its label."></span></label>
29
- <select id="lnx-f-tipmode" class="form-input" data-model="tooltipMode.value">${f(h.tooltipMode)}</select>
29
+ <select id="lnx-f-tipmode" class="form-input" data-model="tooltipMode.value">${h(c.tooltipMode)}</select>
30
30
  </div>
31
31
  <div class="lnx-field" data-bind-hidden="tooltipMode.value !== 'custom'">
32
32
  <label class="form-label" for="lnx-f-tip">Tooltip words</label>
33
- <input id="lnx-f-tip" class="form-input" maxlength="${u.tooltipMax}" placeholder="e.g. Questions? Ask us here" data-model="tooltip.value">
33
+ <input id="lnx-f-tip" class="form-input" maxlength="${s.tooltipMax}" placeholder="e.g. Questions? Ask us here" data-model="tooltip.value">
34
34
  </div>
35
35
  <div class="lnx-field">
36
36
  <label class="form-label" for="lnx-f-icon">Icon <span data-help="A Domma icon name - press the grid button to browse them."></span></label>
37
37
  <div class="lnx-inline">
38
- <input id="lnx-f-icon" class="form-input" maxlength="${u.iconMax}" data-model="icon.value">
38
+ <input id="lnx-f-icon" class="form-input" maxlength="${s.iconMax}" data-model="icon.value">
39
39
  <button type="button" class="lnx-icon-btn lnx-pick-icon" title="Browse icons"><span data-icon="grid" data-icon-size="14"></span></button>
40
40
  </div>
41
41
  </div>
42
42
  <div class="lnx-field">
43
43
  <label class="form-label" for="lnx-f-style">Style <span data-help="A round disc with just the icon, or a pill with the icon and the label."></span></label>
44
- <select id="lnx-f-style" class="form-input" data-model="triggerStyle.value">${f(h.triggerStyle)}</select>
44
+ <select id="lnx-f-style" class="form-input" data-model="triggerStyle.value">${h(c.triggerStyle)}</select>
45
45
  </div>
46
46
  <div class="lnx-field">
47
47
  <label class="form-label" for="lnx-f-bg">Background <span data-help="One of the theme's colours - so it follows light, dark and custom themes - or your own hex colour."></span></label>
48
- <select id="lnx-f-bg" class="form-input" data-model="bgChoice.value">${f(h.background)}</select>
48
+ <select id="lnx-f-bg" class="form-input" data-model="bgChoice.value">${h(c.background)}</select>
49
49
  <input class="form-input" placeholder="#3366ff" data-model="bgHex.value" data-bind-hidden="bgChoice.value !== 'custom'" aria-label="Background hex colour">
50
50
  <small class="lnx-err" data-bind-hidden="!err.value.background" data-bind-text="err.value.background"></small>
51
51
  </div>
52
52
  <div class="lnx-field">
53
53
  <label class="form-label" for="lnx-f-fg">Icon and text colour <span data-help="Theme picks the colour that reads on the theme's primary colour."></span></label>
54
- <select id="lnx-f-fg" class="form-input" data-model="fgChoice.value">${f(h.foreground)}</select>
54
+ <select id="lnx-f-fg" class="form-input" data-model="fgChoice.value">${h(c.foreground)}</select>
55
55
  <input class="form-input" placeholder="#ffffff" data-model="fgHex.value" data-bind-hidden="fgChoice.value !== 'custom'" aria-label="Icon and text hex colour">
56
56
  <small class="lnx-err" data-bind-hidden="!err.value.text" data-bind-text="err.value.text"></small>
57
57
  </div>
@@ -77,12 +77,12 @@ import{apiRequest as V,api as ye}from"../api.js";import{addBannerAction as we}fr
77
77
  <h6><span data-icon="external-link" data-icon-size="14"></span> What it opens</h6>
78
78
  <div class="lnx-field">
79
79
  <label class="form-label" for="lnx-f-type">Opens <span data-help-title="Opens" data-help="Modal: a page (on its own, no navbar or footer), a form or a block in a box over the page. Slideover: the same in a panel from the side. Chat: a chat panel by the disc (full screen on phones) - the bot answers from your Knowledge first, then your team."></span></label>
80
- <select id="lnx-f-type" class="form-input" data-model="actionType.value">${f(h.actionType)}</select>
80
+ <select id="lnx-f-type" class="form-input" data-model="actionType.value">${h(c.actionType)}</select>
81
81
  </div>
82
82
  <div class="lnx-grid2" data-bind-hidden="actionType.value === 'chat'">
83
83
  <div class="lnx-field">
84
84
  <label class="form-label" for="lnx-f-kind">Show <span data-help="A page shows its body only. A form or block is drawn as it would be on a page."></span></label>
85
- <select id="lnx-f-kind" class="form-input" data-model="kind.value">${f(h.kind)}</select>
85
+ <select id="lnx-f-kind" class="form-input" data-model="kind.value">${h(c.kind)}</select>
86
86
  </div>
87
87
  <div class="lnx-field" data-bind-hidden="kind.value !== 'page'">
88
88
  <label class="form-label" for="lnx-f-page">Page <span data-help="The page's address. Its own visibility still applies: a members-only page opens for members only, and a draft never opens."></span></label>
@@ -105,54 +105,128 @@ import{apiRequest as V,api as ye}from"../api.js";import{addBannerAction as we}fr
105
105
  <div class="lnx-grid2">
106
106
  <div class="lnx-field">
107
107
  <label class="form-label" for="lnx-f-title">Title <span data-help="The heading of the modal, slideover or chat. Empty uses the label."></span></label>
108
- <input id="lnx-f-title" class="form-input" maxlength="${u.titleMax}" data-model="title.value">
108
+ <input id="lnx-f-title" class="form-input" maxlength="${s.titleMax}" data-model="title.value">
109
109
  </div>
110
110
  <div class="lnx-field" data-bind-hidden="actionType.value !== 'modal'">
111
111
  <label class="form-label" for="lnx-f-size">Modal width <span data-help="Never wider than the window: a phone always gets nearly its full width. Full screen fills the whole window, height too."></span></label>
112
- <select id="lnx-f-size" class="form-input" data-model="modalSize.value">${f(h.modalSize)}</select>
112
+ <select id="lnx-f-size" class="form-input" data-model="modalSize.value">${h(c.modalSize)}</select>
113
113
  </div>
114
114
  <div class="lnx-field" data-bind-hidden="actionType.value !== 'modal' || modalSize.value !== 'custom'">
115
115
  <label class="form-label" for="lnx-f-cw">Custom width</label>
116
116
  <div class="lnx-unit"><input id="lnx-f-cw" type="number" class="form-input" data-model="customWidth.value"
117
- data-bind-min="widthUnit.value === '%' ? ${u.widthPct[0]} : ${u.widthPx[0]}" data-bind-max="widthUnit.value === '%' ? ${u.widthPct[1]} : ${u.widthPx[1]}">
118
- <select class="form-input" data-model="widthUnit.value" aria-label="Width unit">${f(h.widthUnit)}</select></div>
117
+ data-bind-min="widthUnit.value === '%' ? ${s.widthPct[0]} : ${s.widthPx[0]}" data-bind-max="widthUnit.value === '%' ? ${s.widthPct[1]} : ${s.widthPx[1]}">
118
+ <select class="form-input" data-model="widthUnit.value" aria-label="Width unit">${h(c.widthUnit)}</select></div>
119
119
  </div>
120
120
  <div class="lnx-field" data-bind-hidden="actionType.value !== 'modal' || modalSize.value === 'screen'">
121
121
  <label class="form-label" for="lnx-f-height">Modal height <span data-help="Fit the page grows and shrinks with the page, up to most of the window. A fixed height keeps the modal that tall; a longer page scrolls inside it."></span></label>
122
- <select id="lnx-f-height" class="form-input" data-model="modalHeight.value">${f(h.modalHeight)}</select>
122
+ <select id="lnx-f-height" class="form-input" data-model="modalHeight.value">${h(c.modalHeight)}</select>
123
123
  </div>
124
124
  <div class="lnx-field" data-bind-hidden="actionType.value !== 'modal' || modalSize.value === 'screen' || modalHeight.value !== 'custom'">
125
125
  <label class="form-label" for="lnx-f-ch">Custom height</label>
126
126
  <div class="lnx-unit"><input id="lnx-f-ch" type="number" class="form-input" data-model="customHeight.value"
127
- data-bind-min="heightUnit.value === 'px' ? ${u.heightPx[0]} : ${u.heightVh[0]}" data-bind-max="heightUnit.value === 'px' ? ${u.heightPx[1]} : ${u.heightVh[1]}">
128
- <select class="form-input" data-model="heightUnit.value" aria-label="Height unit">${f(h.heightUnit)}</select></div>
127
+ data-bind-min="heightUnit.value === 'px' ? ${s.heightPx[0]} : ${s.heightVh[0]}" data-bind-max="heightUnit.value === 'px' ? ${s.heightPx[1]} : ${s.heightVh[1]}">
128
+ <select class="form-input" data-model="heightUnit.value" aria-label="Height unit">${h(c.heightUnit)}</select></div>
129
129
  </div>
130
130
  <div class="lnx-field" data-bind-hidden="actionType.value !== 'slideover'">
131
131
  <label class="form-label" for="lnx-f-side">Slides in from <span data-help="On a phone a slideover fills the screen whatever its width."></span></label>
132
- <select id="lnx-f-side" class="form-input" data-model="side.value">${f(h.side)}</select>
132
+ <select id="lnx-f-side" class="form-input" data-model="side.value">${h(c.side)}</select>
133
133
  </div>
134
134
  <div class="lnx-field" data-bind-hidden="actionType.value !== 'slideover'">
135
135
  <label class="form-label" for="lnx-f-width">Width</label>
136
- <select id="lnx-f-width" class="form-input" data-model="width.value">${f(h.width)}</select>
136
+ <select id="lnx-f-width" class="form-input" data-model="width.value">${h(c.width)}</select>
137
137
  </div>
138
138
  </div>
139
139
  <div class="lnx-grid2" data-bind-hidden="actionType.value !== 'chat'">
140
140
  <div class="lnx-field" style="grid-column: 1 / -1">
141
- <label class="form-label" for="lnx-f-greeting">Greeting <span data-help="The first message a visitor sees when the chat opens."></span></label>
142
- <textarea id="lnx-f-greeting" class="form-input" rows="2" maxlength="${u.greetingMax}" data-model="greeting.value"></textarea>
141
+ <label class="lnx-check"><input id="lnx-f-della" type="checkbox" class="form-switch" data-model="useDella.value"> Use Della</label>
142
+ <small>Use Della's name, portrait and animated character. Site Settings controls visibility and motion. Your custom name and picture are kept when this is switched off.</small>
143
+ <label class="form-label" for="lnx-f-greeting">Greeting <span data-help-title="Greeting" data-help="The first message a visitor sees when the chat opens. Words in braces are filled in from the visitor's own clock: {greeting} (Good morning / afternoon / evening), {timeofday} (morning / afternoon / evening), {day} (Monday...), {date} (10 November), {time} (09:42), {botname} and {site}. For example: {greeting}! I'm {botname} - how can I help this {timeofday}?"></span></label>
144
+ <textarea id="lnx-f-greeting" class="form-input" rows="2" maxlength="${s.greetingMax}" data-model="greeting.value"></textarea>
143
145
  </div>
144
146
  <div class="lnx-field">
145
147
  <label class="form-label" for="lnx-f-botname">Bot's name <span data-help="Shown on the bot's answers."></span></label>
146
- <input id="lnx-f-botname" class="form-input" maxlength="${u.botNameMax}" data-model="botName.value">
148
+ <input id="lnx-f-botname" data-bind-disabled="useDella.value" class="form-input" maxlength="${s.botNameMax}" data-model="botName.value">
149
+ </div>
150
+ <div class="lnx-field">
151
+ <label class="form-label" for="lnx-f-accent">Chat colour <span data-help="This chat's own colour: its heading, the visitor's messages and the send button. Theme uses the site's primary colour, so each chat can carry its own branding."></span></label>
152
+ <select id="lnx-f-accent" class="form-input" data-model="accentChoice.value">${h(c.background)}</select>
153
+ <input class="form-input" placeholder="#0f766e" data-model="accentHex.value" data-bind-hidden="accentChoice.value !== 'custom'" aria-label="Chat hex colour">
154
+ <small class="lnx-err" data-bind-hidden="!err.value.accent" data-bind-text="err.value.accent"></small>
155
+ </div>
156
+ <div class="lnx-field">
157
+ <label class="form-label" for="lnx-f-accent-text">Text on that colour <span data-help="Theme picks black or white, whichever reads better on the chat colour."></span></label>
158
+ <select id="lnx-f-accent-text" class="form-input" data-model="accentTextChoice.value">${h(c.foreground)}</select>
159
+ <input class="form-input" placeholder="#ffffff" data-model="accentTextHex.value" data-bind-hidden="accentTextChoice.value !== 'custom'" aria-label="Chat text hex colour">
160
+ <small class="lnx-err" data-bind-hidden="!err.value.accentText" data-bind-text="err.value.accentText"></small>
161
+ </div>
162
+ <div class="lnx-field">
163
+ <label class="form-label" for="lnx-f-chatsize">Chat window size <span data-help="How big the chat window opens on a computer, in pixels. It never grows past the visitor's window, and on a phone the chat always fills the screen."></span></label>
164
+ <select id="lnx-f-chatsize" class="form-input" data-model="chatSize.value">${h(c.chatSize)}</select>
165
+ <div class="lnx-grid2" data-bind-hidden="chatSize.value !== 'custom'">
166
+ <input type="number" class="form-input" aria-label="Chat window width in pixels" min="${s.chatWidth[0]}" max="${s.chatWidth[1]}" data-model="chatWidth.value">
167
+ <input type="number" class="form-input" aria-label="Chat window height in pixels" min="${s.chatHeight[0]}" max="${s.chatHeight[1]}" data-model="chatHeight.value">
168
+ </div>
169
+ <small class="lnx-err" data-bind-hidden="!err.value.chatWidth && !err.value.chatHeight" data-bind-text="err.value.chatWidth || err.value.chatHeight"></small>
170
+ </div>
171
+ <div class="lnx-field" data-bind-hidden="!staff.value && askDetails.value === 'never'">
172
+ <label class="form-label" for="lnx-f-person">Talk to a person <span data-help="Where the Talk to a person (or Leave a message) button goes: under the conversation, or as an icon in the chat's heading, with its name as a tooltip - more room for the conversation."></span></label>
173
+ <select id="lnx-f-person" class="form-input" data-model="personButton.value">${h(c.personButton)}</select>
174
+ </div>
175
+ <div class="lnx-field">
176
+ <label class="form-label" for="lnx-f-times">Show on each message <span data-help="When each message was sent, beside its name, in the visitor's own time. Date and time says Today for today's."></span></label>
177
+ <select id="lnx-f-times" class="form-input" data-model="times.value">${h(c.times)}</select>
178
+ </div>
179
+ <label class="lnx-check" style="grid-column: 1 / -1"><input type="checkbox" class="form-switch" data-model="keepOwn.value"> Keep this chat's conversations for a different time
180
+ <span data-help-title="How long chats are kept" data-help="Every conversation is saved, and ended ones are deleted after the time in Chats > settings (the site's default, 90 days to begin with). Switch this on to keep this launcher's for longer or shorter (1 to 730 days). Chats that only ever talked to the bot and left no details still go within a week. Save one for good with Save for a closer look."></span></label>
181
+ <div class="lnx-field" data-bind-hidden="!keepOwn.value">
182
+ <label class="form-label" for="lnx-f-keep">Keep ended chats for (days)</label>
183
+ <input id="lnx-f-keep" type="number" class="form-input" min="1" max="730" data-model="keepDays.value">
184
+ <small class="lnx-err" data-bind-hidden="!err.value.keepDays" data-bind-text="err.value.keepDays"></small>
185
+ </div>
186
+ <label class="lnx-check"><input type="checkbox" class="form-switch" data-model="chatResizable.value"> Visitors can resize the chat
187
+ <span data-help="A grip in the corner away from the disc lets visitors drag the window bigger or smaller (between ${s.chatWidth[0]} x ${s.chatHeight[0]} and ${s.chatWidth[1]} x ${s.chatHeight[1]}). Their size is remembered in their browser; a double-click on the grip puts yours back."></span></label>
188
+ <div class="lnx-field" style="grid-column: 1 / -1">
189
+ <label class="form-label" for="lnx-f-starters">Questions to start with <span data-help="Up to ${s.startersMax}, one per line: buttons under the greeting that ask the question for the visitor. They go once the chat starts."></span></label>
190
+ <textarea id="lnx-f-starters" class="form-input" rows="3" data-model="starters.value" placeholder="How much does it cost?&#10;Can you move my WordPress site?"></textarea>
191
+ <small class="lnx-err" data-bind-hidden="!err.value.starters" data-bind-text="err.value.starters"></small>
192
+ </div>
193
+ <div class="lnx-field" style="grid-column: 1 / -1">
194
+ <span class="form-label">Bot's picture <span data-help="A picture from Media shown beside the bot's messages and in the chat's heading - a face or a logo, square works best. None: the first letter of the bot's name."></span></span>
195
+ <div class="lnx-avatar-row">
196
+ <span class="lnx-avatar-preview" data-bind-style="avatarPreview.value"><img data-bind-src="avatar.value" data-bind-hidden="!avatar.value" alt=""><span data-bind-hidden="avatar.value" data-bind-text="botInitial.value"></span></span>
197
+ <button type="button" class="btn btn-sm btn-outline lnx-pick-avatar">Choose from Media</button>
198
+ <button type="button" class="btn btn-sm btn-ghost lnx-clear-avatar" data-bind-hidden="!avatar.value">Remove</button>
199
+ </div>
200
+ <small class="lnx-err" data-bind-hidden="!err.value.avatar" data-bind-text="err.value.avatar"></small>
147
201
  </div>
148
202
  <div class="lnx-field">
149
203
  <label class="form-label" for="lnx-f-ask">Ask for name and email <span data-help="When the chat asks a visitor for their name and email so your team can reply later."></span></label>
150
- <select id="lnx-f-ask" class="form-input" data-model="askDetails.value">${f(h.askDetails)}</select>
204
+ <select id="lnx-f-ask" class="form-input" data-model="askDetails.value">${h(c.askDetails)}</select>
151
205
  </div>
152
206
  <label class="lnx-check"><input type="checkbox" class="form-switch" data-model="bot.value"> Bot answers first
153
207
  <span data-help="The bot answers from your Knowledge entries. It offers choices when it is not sure, and hands over to your team when it has no answer."></span></label>
154
208
  <label class="lnx-check"><input type="checkbox" class="form-switch" data-model="staff.value"> Your team can answer
155
209
  <span data-help="Conversations reach the Chats inbox so your team can reply live. Off: the bot only, and a visitor can still leave their details."></span></label>
210
+ <label class="lnx-check" data-bind-hidden="!bot.value"><input type="checkbox" class="form-switch" data-model="ai.value"> AI answers what the Knowledge does not
211
+ <span data-help-title="AI answers" data-help="When no Knowledge entry fits, the bot asks Claude, which answers only from your Knowledge, Site Settings > AI assistant and the box below, and says it does not know rather than guess. Comes with the Pro plan on hosted sites; elsewhere the bot answers from the Knowledge alone."></span></label>
212
+ <label class="lnx-check" style="grid-column: 1 / -1" data-bind-hidden="!bot.value || !ai.value"><input type="checkbox" class="form-switch" data-model="aiUseSite.value"> Use the site's About the business
213
+ <span data-help-title="Site-wide settings" data-help="On: the AI starts from Site Settings > General > AI assistant > About the business and adds what you write below. Off: only what you write below - for a chat about something else entirely, such as one event or one product. The site's Rules apply either way: a launcher can add rules, never lift one."></span></label>
214
+ <div class="lnx-field" style="grid-column: 1 / -1" data-bind-hidden="!bot.value || !ai.value">
215
+ <label class="form-label" for="lnx-f-aicontext">What the AI should know for this launcher
216
+ <span data-help="Added to Site Settings > AI assistant > About the business (or used on its own when the site's settings are off), for chats from this launcher only - say, the products on the pages it shows on. Sent to Claude with each question, so leave out anything private."></span></label>
217
+ <textarea id="lnx-f-aicontext" class="form-input" rows="3" maxlength="${s.aiContextMax}" data-model="aiContext.value"
218
+ placeholder="On the shop pages: we post to the UK only, orders before 2pm go the same day."></textarea>
219
+ </div>
220
+ <div class="lnx-field" data-bind-hidden="!bot.value || !ai.value">
221
+ <label class="form-label" for="lnx-f-aimax">AI answers per chat <span data-help="The most AI answers one conversation may have (0 to 100). Past it the bot answers from the Knowledge alone and offers a person - a guard against someone using the chat as a free AI."></span></label>
222
+ <input id="lnx-f-aimax" type="number" class="form-input" min="0" max="100" data-model="aiMaxPerChat.value">
223
+ </div>
224
+ <div class="lnx-field" style="grid-column: 1 / -1" data-bind-hidden="!bot.value || !ai.value">
225
+ <label class="form-label" for="lnx-f-airules">Rules for this launcher
226
+ <span data-help="One per line: what answers from this launcher must never do or say. They add to the rules in Site Settings > AI assistant; they cannot lift one."></span></label>
227
+ <textarea id="lnx-f-airules" class="form-input" rows="2" maxlength="${s.aiRulesMax}" data-model="aiRules.value"
228
+ placeholder="Only talk about orders and delivery. Never promise a delivery date."></textarea>
229
+ </div>
156
230
  </div>
157
231
  </div>
158
232
 
@@ -161,7 +235,7 @@ import{apiRequest as V,api as ye}from"../api.js";import{addBannerAction as we}fr
161
235
  <div class="lnx-place">
162
236
  <div class="lnx-field">
163
237
  <span class="form-label">Spot <span data-help="Pick a corner, the middle of an edge, or the top or bottom centre. It steps clear of other discs there - Search, Back to top, Reduce motion and your other launchers."></span></span>
164
- <div class="lnx-corners lnx-corners-main" role="group" aria-label="Spot">${Oe("position")}</div>
238
+ <div class="lnx-corners lnx-corners-main" role="group" aria-label="Spot">${Ae("position")}</div>
165
239
  </div>
166
240
  <div class="lnx-previews">
167
241
  <div><div class="lnx-preview"><span class="lnx-preview-bar"></span><span class="lnx-preview-disc" data-bind-style="previewStyle.value"><span data-icon="message-circle" class="lnx-preview-icon"></span><span data-bind-hidden="triggerStyle.value !== 'icon-text'" data-bind-text="label.value"></span></span></div><small>Desktop</small></div>
@@ -174,12 +248,12 @@ import{apiRequest as V,api as ye}from"../api.js";import{addBannerAction as we}fr
174
248
  <div class="lnx-field"><label class="form-label">From the top or bottom <span data-help="How far in from the top or bottom edge, in pixels. For a middle spot it nudges the disc down."></span></label>
175
249
  <div class="lnx-range"><input type="range" min="0" max="300" data-model="offsetY.value" aria-label="From the top or bottom"><output data-bind-text="offsetY.value"></output></div></div>
176
250
  <div class="lnx-field"><label class="form-label">Size <span data-help="The disc's width and height. 44px or more is easy to tap."></span></label>
177
- <div class="lnx-range"><input type="range" min="${u.sizeMin}" max="${u.sizeMax}" data-model="size.value" aria-label="Size"><output data-bind-text="size.value"></output></div></div>
251
+ <div class="lnx-range"><input type="range" min="${s.sizeMin}" max="${s.sizeMax}" data-model="size.value" aria-label="Size"><output data-bind-text="size.value"></output></div></div>
178
252
  <div class="lnx-field" data-bind-hidden="triggerStyle.value === 'icon-text'"><label class="form-label">Roundness <span data-help="0 is a square; half the size is a circle."></span></label>
179
253
  <div class="lnx-range"><input type="range" min="0" data-bind-max="maxRadius.value" data-model="radius.value" aria-label="Roundness"><output data-bind-text="radius.value"></output></div></div>
180
254
  <div class="lnx-field">
181
255
  <label class="form-label" for="lnx-f-devices">Shows on <span data-help="Phones are screens up to 640px wide."></span></label>
182
- <select id="lnx-f-devices" class="form-input" data-model="devices.value">${f(h.devices)}</select>
256
+ <select id="lnx-f-devices" class="form-input" data-model="devices.value">${h(c.devices)}</select>
183
257
  </div>
184
258
  <label class="lnx-check" data-bind-hidden="devices.value === 'desktop'"><input type="checkbox" class="form-switch" data-model="phoneOverride.value"> Its own spot on phones
185
259
  <span data-help="A different spot, distance and size on phones - for instance, out of the way of a phone's bottom bar."></span></label>
@@ -187,7 +261,7 @@ import{apiRequest as V,api as ye}from"../api.js";import{addBannerAction as we}fr
187
261
  <div class="lnx-place" data-bind-hidden="!phoneOverride.value || devices.value === 'desktop'">
188
262
  <div class="lnx-field">
189
263
  <span class="form-label">Spot on phones</span>
190
- <div class="lnx-corners lnx-corners-phone" role="group" aria-label="Spot on phones">${Oe("phonePosition")}</div>
264
+ <div class="lnx-corners lnx-corners-phone" role="group" aria-label="Spot on phones">${Ae("phonePosition")}</div>
191
265
  </div>
192
266
  <div class="lnx-grid2" style="flex:1">
193
267
  <div class="lnx-field"><label class="form-label">From the side</label>
@@ -195,7 +269,7 @@ import{apiRequest as V,api as ye}from"../api.js";import{addBannerAction as we}fr
195
269
  <div class="lnx-field"><label class="form-label">From the top or bottom</label>
196
270
  <div class="lnx-range"><input type="range" min="0" max="200" data-model="phoneOffsetY.value" aria-label="From the top or bottom on phones"><output data-bind-text="phoneOffsetY.value"></output></div></div>
197
271
  <div class="lnx-field"><label class="form-label">Size</label>
198
- <div class="lnx-range"><input type="range" min="${u.sizeMin}" max="${u.sizeMax}" data-model="phoneSize.value" aria-label="Size on phones"><output data-bind-text="phoneSize.value"></output></div></div>
272
+ <div class="lnx-range"><input type="range" min="${s.sizeMin}" max="${s.sizeMax}" data-model="phoneSize.value" aria-label="Size on phones"><output data-bind-text="phoneSize.value"></output></div></div>
199
273
  </div>
200
274
  </div>
201
275
  </div>
@@ -205,11 +279,11 @@ import{apiRequest as V,api as ye}from"../api.js";import{addBannerAction as we}fr
205
279
  <div class="lnx-grid2">
206
280
  <div class="lnx-field">
207
281
  <label class="form-label" for="lnx-f-pages">Pages <span data-help="Every page, only the pages listed, or every page but those."></span></label>
208
- <select id="lnx-f-pages" class="form-input" data-model="pagesMode.value">${f(h.pagesMode)}</select>
282
+ <select id="lnx-f-pages" class="form-input" data-model="pagesMode.value">${h(c.pagesMode)}</select>
209
283
  </div>
210
284
  <div class="lnx-field">
211
285
  <label class="form-label" for="lnx-f-aud">Who sees it <span data-help="Signed-in: only people signed in to this site. Signed-out: only visitors who are not."></span></label>
212
- <select id="lnx-f-aud" class="form-input" data-model="audience.value">${f(h.audience)}</select>
286
+ <select id="lnx-f-aud" class="form-input" data-model="audience.value">${h(c.audience)}</select>
213
287
  </div>
214
288
  </div>
215
289
  <div class="lnx-field" data-bind-hidden="pagesMode.value === 'all'">
@@ -227,4 +301,4 @@ import{apiRequest as V,api as ye}from"../api.js";import{addBannerAction as we}fr
227
301
  <button type="button" class="btn btn-sm btn-primary" data-on-click="save" data-bind-disabled="cannot.value">
228
302
  <span data-icon="check" data-icon-size="13"></span> <span data-bind-text="saveText"></span></button>
229
303
  </div>
230
- </div>`,Z=s=>String(s??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function ua(s){const d=document.createElement("template");return d.innerHTML=s.trim(),d.content.firstElementChild}const U=s=>s?J.includes(s)?s:"custom":"",x=Je($e),ee={list:()=>V("/launchers/items",{method:"GET"}),save:s=>V("/launchers/items",{method:"PUT",body:JSON.stringify({launchers:s})}),patch:(s,d)=>V(`/launchers/items/${encodeURIComponent(s)}`,{method:"PATCH",body:JSON.stringify(d)})};export const launchersView={templateUrl:"/admin/js/templates/launchers.html",async onMount(s){x.reset();const d=s.get(0).querySelector(".lnx")||s.get(0),T=()=>d.isConnected&&$e.test(location.hash),r=M.observable([]),ae=M.observable(!0),H=M.observable(""),B=M.observable(!0);let te="all";try{te=Qe.includes(S.get(Q))?S.get(Q):"all"}catch{}const $=M.observable(te),D=M.observable("");x.add(M.effect(()=>{const a=$.value;try{S.set(Q,a)}catch{}}));const W=M.observable([]);x.add(M.effect(()=>{W.value=Ze(r.value,{filter:$.value,query:D.value}).map(oa)}));const Le=M.computed(()=>ta(r.value)),ze=M.computed(()=>r.value.length?"No launchers match.":"No launchers yet - New launcher in the banner makes one."),le=M.computed(()=>r.value.length>1&&($.value!=="all"||!!D.value.trim())),O=a=>r.peek().find(t=>t.id===a);let N=null;const Ne=async()=>{if(N)return N;const[a,t]=await Promise.all([ye.forms.list().catch(()=>[]),ye.blocks.list().catch(()=>[])]);return N={forms:(Array.isArray(a)?a:[]).map(l=>({value:l.slug,text:l.title?`${l.title} (${l.slug})`:l.slug})),blocks:(Array.isArray(t)?t:[]).map(l=>({value:l.name,text:l.description?`${l.name} - ${l.description}`:l.name}))},N};async function Pe(){try{const a=await ee.list();if(!T())return;r.value=Array.isArray(a?.launchers)?a.launchers:[],H.value="",B.value=!0}catch(a){const t=String(a?.message||a);/switched off/i.test(t)?B.value=!1:H.value=`Could not load the launchers: ${t}`}finally{ae.value=!1}}async function P(a,t){try{const l=await ee.save(a);return T()&&(r.value=l.launchers),Ee(Te),t&&E.toast(t,{type:"success"}),l.launchers}catch(l){return E.toast(`Not saved: ${l.message||l}`,{type:"error"}),null}}async function q(a,t){try{const l=await ee.patch(a.id,{enabled:t});r.value=r.peek().map(c=>c.id===a.id?l.launcher:c),Ee(Te),E.toast(`"${a.name}" ${t?"switched on":"switched off"}.`,{type:"success",duration:2e3})}catch(l){E.toast(`Not changed: ${l.message||l}`,{type:"error"}),r.value=[...r.peek()]}}async function Ae(a){const t=r.peek(),l=t.findIndex(i=>i.id===a.id),c=la(a,t);await P([...t.slice(0,l+1),c,...t.slice(l+1)],`Duplicated as "${c.name}" - switched off until you are ready.`)}async function Fe(a){await E.confirm(`Delete the launcher "${Z(a.name)}"? It goes from every page. This cannot be undone.`)&&await P(r.peek().filter(t=>t.id!==a.id),"Launcher deleted.")}function Re(a){if(a.action.type==="chat"){E.toast("A chat has nothing to open on its own - see it on any page it shows on.",{type:"info"});return}if(!a.action.ref){E.toast("Choose what it opens first.",{type:"warning"});return}window.open(`/_launcher/${encodeURIComponent(a.id)}`,"_blank","noopener")}function Ie(a){const t=O(a);return t?[{header:t.name},{label:"Edit",icon:"edit",action:()=>L(t.id)},t.enabled?{label:"Switch off",icon:"pause",action:()=>q(t,!1)}:{label:"Switch on",icon:"play",action:()=>q(t,!0)},{label:"Open what it shows",icon:"external-link",action:()=>Re(t)},{type:"divider"},{label:"Duplicate",icon:"copy",action:()=>Ae(t)},{type:"divider"},{label:"Delete\u2026",icon:"trash",danger:!0,action:()=>Fe(t)}]:[]}let w=null;const j=new Set;function Ue(a,t,l){const c=a.close.bind(a);let i=!1,b=!1;return a.close=async p=>{if(!i&&p!==!0&&t()){if(b)return;b=!0;const z=await E.confirm(l);if(b=!1,!z)return}return i=!0,c()},()=>{i=!0}}async function L(a=null,t=null){const l=a?O(a):null;if(a&&!l){E.toast("That launcher is no longer there.",{type:"warning"});return}if(w){E.toast("Finish the launcher you have open first.",{type:"info"});return}const c=!l,i=na(l||ea(r.peek())),b={...i,refPage:i.kind==="page"?i.ref:"",refForm:i.kind==="form"?i.ref:"",refBlock:i.kind==="block"?i.ref:"",bgChoice:U(i.background),bgHex:U(i.background)==="custom"?i.background:"",fgChoice:U(i.text),fgHex:U(i.text)==="custom"?i.text:"",...t||{}};delete b.ref,delete b.background,delete b.text;const p=Object.fromEntries(Object.entries(b).map(([e,o])=>[e,M.observable(o)])),z=()=>Object.fromEntries(Object.keys(p).map(e=>[e,p[e].peek()])),de=e=>JSON.stringify(Object.fromEntries(Object.entries(e).map(([o,n])=>[o,typeof n=="boolean"?n:String(n??"")]))),De=de(b),re=()=>de(z())!==De||!!t,ce=e=>{const o=e.actionType==="chat"?"page":e.kind;return{...e,kind:o,ref:o==="form"?e.refForm:o==="block"?e.refBlock:String(e.refPage||"").trim(),background:e.bgChoice==="custom"?String(e.bgHex||"").trim():e.bgChoice,text:e.fgChoice==="custom"?String(e.fgHex||"").trim():e.fgChoice}},Y=()=>ce(Object.fromEntries(Object.keys(p).map(e=>[e,p[e].value]))),K=M.computed(()=>aa(Y())),A=M.observable(!1),pe=(e,o)=>{const n=da({...e,size:Number(e.size),offsetX:Number(e.offsetX),offsetY:Number(e.offsetY),phoneSize:Number(e.phoneSize),phoneOffsetX:Number(e.phoneOffsetX),phoneOffsetY:Number(e.phoneOffsetY)},o?{vw:120,vh:220,scale:.5,phone:!0}:{vw:320,vh:200,scale:.5}),m=e.triggerStyle==="icon-text"&&!o;return{left:`${n.left}px`,top:`${n.top}px`,height:`${n.size}px`,width:m?"auto":`${n.size}px`,padding:m?"0 6px":"0","border-radius":m?"999px":`${Math.round(Math.min(Number(e.radius),Number(e.size)/2)/Number(e.size)*100)}%`,"--lnx-bg":Me(e.background)||"var(--dm-primary)","--lnx-fg":Me(e.text)||"var(--dm-primary-text)"}},ue={...p,saving:A,err:M.computed(()=>K.value.errors),warn:M.computed(()=>K.value.warnings),cannot:M.computed(()=>A.value||Object.keys(K.value.errors).length>0),maxRadius:M.computed(()=>Math.floor(Number(p.size.value)/2)),previewStyle:M.computed(()=>pe(Y(),!1)),phonePreviewStyle:M.computed(()=>pe(Y(),!0)),saveText:c?"Create launcher":"Save",linkHref:c?"":G(l.id),linkText:c?"Create the launcher first - then it has a link":G(l.id)},We=M.effect(()=>{const e=Math.floor(Number(p.size.value)/2);Number(p.radius.peek())>e&&(p.radius.value=e)}),he=(e,o,n)=>{let m=e.peek();return M.effect(()=>{const C=e.value;C!==m&&(m=C,o.value=n(C))})},qe=he(p.widthUnit,p.customWidth,e=>e==="%"?90:900),je=he(p.heightUnit,p.customHeight,e=>e==="px"?600:70),k=E.slideover({title:c?"New launcher":`Edit ${Z(l.name)}`,size:"lg",position:"right"}),v=ua(pa),fe=await Ne().catch(()=>({forms:[],blocks:[]})),me=(e,o,n)=>{const m=document.createElement("option");m.value="",m.textContent=o.length?"Choose\u2026":"None yet",e.appendChild(m);const C=n&&!o.some(F=>F.value===n)?[...o,{value:n,text:`${n} (missing)`}]:o;for(const F of C){const X=document.createElement("option");X.value=F.value,X.textContent=F.text,e.appendChild(X)}};me(v.querySelector(".lnx-form-select"),fe.forms,b.refForm),me(v.querySelector(".lnx-block-select"),fe.blocks,b.refBlock);let be=()=>{};async function ve(){if(!ue.cannot.peek()){A.value=!0;try{const e=sa(ce(z()),l?.id||""),o=r.peek(),n=c?[...o,e]:o.map(C=>C.id===l.id?e:C);if(!await P(n,c?`Created "${e.name}".`:"Saved."))return;be(),k.close()}finally{A.value=!1}}}k.element.appendChild(v);const Ye=ke(v),_e=M.applyBindings(ue,v,{methods:{save:ve,cancel:()=>k.close()}}),Ke=e=>{(e.ctrlKey||e.metaKey)&&e.key==="Enter"&&(e.preventDefault(),ve())};v.addEventListener("keydown",Ke);const xe=async e=>{const o=e.target.closest(".lnx-corners button[data-pos]");if(o){const n=o.closest(".lnx-corners-phone")?"phonePosition":"position";p[n].value=o.dataset.pos;return}if(e.target.closest(".lnx-pick-icon")){const{openIconPicker:n}=await import("../lib/card-builder.js");n(m=>{p.icon.value=m});return}if(e.target.closest(".lnx-copy-link")&&!c){let n=!1;try{n=await _.copyToClipboard(G(l.id))!==!1}catch{}E.toast(n?"Link copied.":"Could not copy - select the link and copy it.",{type:n?"success":"warning"});return}if(e.target.closest(".lnx-pick-page")){const{openPagePicker:n}=await import("../lib/page-picker.js");n(m=>{p.refPage.value=m})}};v.addEventListener("click",xe);const Xe=M.effect(()=>{const e=p.icon.value;v.querySelectorAll(".lnx-preview-disc").forEach(o=>{const n=document.createElement("span");n.setAttribute("data-icon",e||"message-circle"),n.className="lnx-preview-icon",o.querySelector(".lnx-preview-icon")?.replaceWith(n),I.scan(o)})}),ge={id:l?.id??null,dirty:re,values:z};w=ge,j.add(k),Ve(k,()=>{_e.dispose(),Ye(),We?.(),qe?.(),je?.(),Xe?.(),v.removeEventListener("click",xe),j.delete(k),w===ge&&(w=null)}),be=Ue(k,re,"Discard the changes you have not saved?"),I.scan(v),k.open(),v.querySelector("#lnx-f-name")?.focus()}const g=d.querySelector(".lnx-list");g.innerHTML=ra;const He=M.applyBindings({launchers:r,loading:ae,loadError:H,toolOn:B,filter:$,query:D,rows:W,counts:Le,emptyText:ze,dragNote:le},d,{methods:{showAll:()=>{$.value="all"},showOn:()=>{$.value="on"},showOff:()=>{$.value="off"}}});x.add(()=>He.dispose()),x.add(ke(d,{position:"bottom"})),x.add(M.effect(()=>{W.value,requestAnimationFrame(()=>{d.isConnected&&I.scan(g)})}));const Be=E.contextMenu(g,{cursor:"glyph",match:".lnx-row",inherit:!1,density:"compact",items:a=>Ie(a.dataset.id)});x.add(()=>Be?.destroy?.());const ne=a=>{const t=a.target.closest(".lnx-row");if(!t||a.target.closest(".lnx-switch"))return;const l=a.target.closest(".lnx-kebab");if(l){Se(l);return}L(t.dataset.id)},se=a=>{const t=a.target.closest(".lnx-toggle"),l=t?.closest(".lnx-row"),c=l&&O(l.dataset.id);c&&q(c,t.checked)},oe=a=>{const t=a.target.closest(".lnx-row");t&&(a.key==="F10"&&a.shiftKey?(a.preventDefault(),Se(t)):a.key==="Enter"&&a.target===t&&L(t.dataset.id))};if(g.addEventListener("click",ne),g.addEventListener("change",se),g.addEventListener("keydown",oe),x.add(()=>{g.removeEventListener("click",ne),g.removeEventListener("change",se),g.removeEventListener("keydown",oe)}),typeof E.sortable=="function"){const a=Ge(),t=E.sortable(g,{items:".lnx-row",handle:".lnx-grip",key:null,keyboard:!1,onStart:a.start,onEnd:({item:l})=>a.restore(l),onSort:({item:l,from:c,to:i})=>{if(a.restore(l),le.peek()){E.toast("Clear the search and show All to reorder.",{type:"info"}),r.value=[...r.peek()];return}const b=ia(r.peek(),c,i);r.value=b,P(b)}});x.add(()=>t.destroy())}we(s,{id:"launchers-new",icon:"plus",title:"New launcher",onClick:()=>L()}),we(s,{id:"launchers-chats",icon:"message-square",title:"Chats - the conversations from chat launchers",onClick:()=>{location.hash="#/launchers/chats"}});const ie=a=>{w?.dirty()&&(a.preventDefault(),a.returnValue="")};if(window.addEventListener("beforeunload",ie),x.add(()=>window.removeEventListener("beforeunload",ie)),x.add(()=>{if(w?.dirty())try{S.set(R,{id:w.id,values:w.values(),at:new Date().toISOString()})}catch{}[...j].forEach(a=>{try{a.close(!0)}catch{}})}),I.scan(d),await Pe(),!T())return;let y=null;try{y=S.get(R)}catch{}if(y?.values){try{S.remove?S.remove(R):S.set(R,null)}catch{}const a=y.id&&O(y.id)?`your changes to "${Z(O(y.id).name)}"`:"the new launcher you started";await E.confirm(`You left ${a} unsaved. Pick up where you left off?`)&&T()&&L(y.id&&O(y.id)?y.id:null,y.values)}}};
304
+ </div>`,Z=i=>String(i??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function ua(i){const p=document.createElement("template");return p.innerHTML=i.trim(),p.content.firstElementChild}const T=i=>i?G.includes(i)?i:"custom":"",x=Ge(Me),ee={list:()=>V("/launchers/items",{method:"GET"}),save:i=>V("/launchers/items",{method:"PUT",body:JSON.stringify({launchers:i})}),patch:(i,p)=>V(`/launchers/items/${encodeURIComponent(i)}`,{method:"PATCH",body:JSON.stringify(p)})};export const launchersView={templateUrl:"/admin/js/templates/launchers.html",async onMount(i){x.reset();const p=i.get(0).querySelector(".lnx")||i.get(0),A=()=>p.isConnected&&Me.test(location.hash),u=M.observable([]),ae=M.observable(!0),F=M.observable(""),B=M.observable(!0);let te="all";try{te=Qe.includes(S.get(Q))?S.get(Q):"all"}catch{}const $=M.observable(te),W=M.observable("");x.add(M.effect(()=>{const a=$.value;try{S.set(Q,a)}catch{}}));const K=M.observable([]);x.add(M.effect(()=>{K.value=Ze(u.value,{filter:$.value,query:W.value}).map(ia)}));const Oe=M.computed(()=>ta(u.value)),ze=M.computed(()=>u.value.length?"No launchers match.":"No launchers yet - New launcher in the banner makes one."),le=M.computed(()=>u.value.length>1&&($.value!=="all"||!!W.value.trim())),O=a=>u.peek().find(t=>t.id===a);let L=null;const Ne=async()=>{if(L)return L;const[a,t]=await Promise.all([ye.forms.list().catch(()=>[]),ye.blocks.list().catch(()=>[])]);return L={forms:(Array.isArray(a)?a:[]).map(l=>({value:l.slug,text:l.title?`${l.title} (${l.slug})`:l.slug})),blocks:(Array.isArray(t)?t:[]).map(l=>({value:l.name,text:l.description?`${l.name} - ${l.description}`:l.name}))},L};async function Le(){try{const a=await ee.list();if(!A())return;u.value=Array.isArray(a?.launchers)?a.launchers:[],F.value="",B.value=!0}catch(a){const t=String(a?.message||a);/switched off/i.test(t)?B.value=!1:F.value=`Could not load the launchers: ${t}`}finally{ae.value=!1}}async function P(a,t){try{const l=await ee.save(a);return A()&&(u.value=l.launchers),Ce(Ee),t&&E.toast(t,{type:"success"}),l.launchers}catch(l){return E.toast(`Not saved: ${l.message||l}`,{type:"error"}),null}}async function q(a,t){try{const l=await ee.patch(a.id,{enabled:t});u.value=u.peek().map(m=>m.id===a.id?l.launcher:m),Ce(Ee),E.toast(`"${a.name}" ${t?"switched on":"switched off"}.`,{type:"success",duration:2e3})}catch(l){E.toast(`Not changed: ${l.message||l}`,{type:"error"}),u.value=[...u.peek()]}}async function Pe(a){const t=u.peek(),l=t.findIndex(o=>o.id===a.id),m=la(a,t);await P([...t.slice(0,l+1),m,...t.slice(l+1)],`Duplicated as "${m.name}" - switched off until you are ready.`)}async function Ie(a){await E.confirm(`Delete the launcher "${Z(a.name)}"? It goes from every page. This cannot be undone.`)&&await P(u.peek().filter(t=>t.id!==a.id),"Launcher deleted.")}function He(a){if(a.action.type==="chat"){E.toast("A chat has nothing to open on its own - see it on any page it shows on.",{type:"info"});return}if(!a.action.ref){E.toast("Choose what it opens first.",{type:"warning"});return}window.open(`/_launcher/${encodeURIComponent(a.id)}`,"_blank","noopener")}function Re(a){const t=O(a);return t?[{header:t.name},{label:"Edit",icon:"edit",action:()=>z(t.id)},t.enabled?{label:"Switch off",icon:"pause",action:()=>q(t,!1)}:{label:"Switch on",icon:"play",action:()=>q(t,!0)},{label:"Open what it shows",icon:"external-link",action:()=>He(t)},{type:"divider"},{label:"Duplicate",icon:"copy",action:()=>Pe(t)},{type:"divider"},{label:"Delete\u2026",icon:"trash",danger:!0,action:()=>Ie(t)}]:[]}let w=null;const Y=new Set;function Ue(a,t,l){const m=a.close.bind(a);let o=!1,b=!1;return a.close=async r=>{if(!o&&r!==!0&&t()){if(b)return;b=!0;const N=await E.confirm(l);if(b=!1,!N)return}return o=!0,m()},()=>{o=!0}}async function z(a=null,t=null){const l=a?O(a):null;if(a&&!l){E.toast("That launcher is no longer there.",{type:"warning"});return}if(w){E.toast("Finish the launcher you have open first.",{type:"info"});return}const m=!l,o=na(l||ea(u.peek())),b={...o,refPage:o.kind==="page"?o.ref:"",refForm:o.kind==="form"?o.ref:"",refBlock:o.kind==="block"?o.ref:"",bgChoice:T(o.background),bgHex:T(o.background)==="custom"?o.background:"",fgChoice:T(o.text),fgHex:T(o.text)==="custom"?o.text:"",accentChoice:T(o.accent),accentHex:T(o.accent)==="custom"?o.accent:"",accentTextChoice:T(o.accentText),accentTextHex:T(o.accentText)==="custom"?o.accentText:"",...t||{}};delete b.ref,delete b.background,delete b.text,delete b.accent,delete b.accentText;const r=Object.fromEntries(Object.entries(b).map(([e,d])=>[e,M.observable(d)])),N=()=>Object.fromEntries(Object.keys(r).map(e=>[e,r[e].peek()])),de=e=>JSON.stringify(Object.fromEntries(Object.entries(e).map(([d,n])=>[d,typeof n=="boolean"?n:String(n??"")]))),Be=de(b),re=()=>de(N())!==Be||!!t,ce=e=>{const d=e.actionType==="chat"?"page":e.kind;return{...e,kind:d,ref:d==="form"?e.refForm:d==="block"?e.refBlock:String(e.refPage||"").trim(),background:e.bgChoice==="custom"?String(e.bgHex||"").trim():e.bgChoice,text:e.fgChoice==="custom"?String(e.fgHex||"").trim():e.fgChoice,accent:e.accentChoice==="custom"?String(e.accentHex||"").trim():e.accentChoice,accentText:e.accentTextChoice==="custom"?String(e.accentTextHex||"").trim():e.accentTextChoice}},H=()=>ce(Object.fromEntries(Object.keys(r).map(e=>[e,r[e].value]))),j=M.computed(()=>aa(H())),R=M.observable(!1),he=(e,d)=>{const n=da({...e,size:Number(e.size),offsetX:Number(e.offsetX),offsetY:Number(e.offsetY),phoneSize:Number(e.phoneSize),phoneOffsetX:Number(e.phoneOffsetX),phoneOffsetY:Number(e.phoneOffsetY)},d?{vw:120,vh:220,scale:.5,phone:!0}:{vw:320,vh:200,scale:.5}),f=e.triggerStyle==="icon-text"&&!d;return{left:`${n.left}px`,top:`${n.top}px`,height:`${n.size}px`,width:f?"auto":`${n.size}px`,padding:f?"0 6px":"0","border-radius":f?"999px":`${Math.round(Math.min(Number(e.radius),Number(e.size)/2)/Number(e.size)*100)}%`,"--lnx-bg":$e(e.background)||"var(--dm-primary)","--lnx-fg":$e(e.text)||"var(--dm-primary-text)"}},pe={...r,saving:R,err:M.computed(()=>j.value.errors),warn:M.computed(()=>j.value.warnings),cannot:M.computed(()=>R.value||Object.keys(j.value.errors).length>0),maxRadius:M.computed(()=>Math.floor(Number(r.size.value)/2)),previewStyle:M.computed(()=>he(H(),!1)),phonePreviewStyle:M.computed(()=>he(H(),!0)),botInitial:M.computed(()=>(String(r.botName.value||"").trim()[0]||"?").toUpperCase()),avatarPreview:M.computed(()=>{const e=ra(H());return{background:e.accent||"var(--dm-primary)",color:e.accentText||"var(--dm-primary-text, #fff)"}}),saveText:m?"Create launcher":"Save",linkHref:m?"":J(l.id),linkText:m?"Create the launcher first - then it has a link":J(l.id)},We=M.effect(()=>{const e=Math.floor(Number(r.size.value)/2);Number(r.radius.peek())>e&&(r.radius.value=e)}),ue=(e,d,n)=>{let f=e.peek();return M.effect(()=>{const C=e.value;C!==f&&(f=C,d.value=n(C))})},Ke=ue(r.widthUnit,r.customWidth,e=>e==="%"?90:900),qe=ue(r.heightUnit,r.customHeight,e=>e==="px"?600:70),k=E.slideover({title:m?"New launcher":`Edit ${Z(l.name)}`,size:"lg",position:"right"}),v=ua(pa),me=await Ne().catch(()=>({forms:[],blocks:[]})),fe=(e,d,n)=>{const f=document.createElement("option");f.value="",f.textContent=d.length?"Choose\u2026":"None yet",e.appendChild(f);const C=n&&!d.some(U=>U.value===n)?[...d,{value:n,text:`${n} (missing)`}]:d;for(const U of C){const X=document.createElement("option");X.value=U.value,X.textContent=U.text,e.appendChild(X)}};fe(v.querySelector(".lnx-form-select"),me.forms,b.refForm),fe(v.querySelector(".lnx-block-select"),me.blocks,b.refBlock);let be=()=>{};async function ve(){if(!pe.cannot.peek()){R.value=!0;try{const e=sa(ce(N()),l?.id||""),d=u.peek(),n=m?[...d,e]:d.map(C=>C.id===l.id?e:C);if(!await P(n,m?`Created "${e.name}".`:"Saved."))return;be(),k.close()}finally{R.value=!1}}}k.element.appendChild(v);const Ye=ke(v),je=M.applyBindings(pe,v,{methods:{save:ve,cancel:()=>k.close()}}),_e=e=>{(e.ctrlKey||e.metaKey)&&e.key==="Enter"&&(e.preventDefault(),ve())};v.addEventListener("keydown",_e);const xe=async e=>{const d=e.target.closest(".lnx-corners button[data-pos]");if(d){const n=d.closest(".lnx-corners-phone")?"phonePosition":"position";r[n].value=d.dataset.pos;return}if(e.target.closest(".lnx-pick-icon")){const{openIconPicker:n}=await import("../lib/card-builder.js");n(f=>{r.icon.value=f});return}if(e.target.closest(".lnx-copy-link")&&!m){let n=!1;try{n=await _.copyToClipboard(J(l.id))!==!1}catch{}E.toast(n?"Link copied.":"Could not copy - select the link and copy it.",{type:n?"success":"warning"});return}if(e.target.closest(".lnx-pick-avatar")){const{pickMedia:n}=await import("../lib/media-picker.js"),f=await n({title:"Choose the bot's picture",current:r.avatar.peek()});f&&(r.avatar.value=String(f).replace(/^https?:\/\/[^/]+/i,""));return}if(e.target.closest(".lnx-clear-avatar")){r.avatar.value="";return}if(e.target.closest(".lnx-pick-page")){const{openPagePicker:n}=await import("../lib/page-picker.js");n(f=>{r.refPage.value=f})}};v.addEventListener("click",xe);const Xe=M.effect(()=>{const e=r.icon.value;v.querySelectorAll(".lnx-preview-disc").forEach(d=>{const n=document.createElement("span");n.setAttribute("data-icon",e||"message-circle"),n.className="lnx-preview-icon",d.querySelector(".lnx-preview-icon")?.replaceWith(n),I.scan(d)})}),ge={id:l?.id??null,dirty:re,values:N};w=ge,Y.add(k),Ve(k,()=>{je.dispose(),Ye(),We?.(),Ke?.(),qe?.(),Xe?.(),v.removeEventListener("click",xe),Y.delete(k),w===ge&&(w=null)}),be=Ue(k,re,"Discard the changes you have not saved?"),I.scan(v),k.open(),v.querySelector("#lnx-f-name")?.focus()}const g=p.querySelector(".lnx-list");g.innerHTML=ca;const De=M.applyBindings({launchers:u,loading:ae,loadError:F,toolOn:B,filter:$,query:W,rows:K,counts:Oe,emptyText:ze,dragNote:le},p,{methods:{showAll:()=>{$.value="all"},showOn:()=>{$.value="on"},showOff:()=>{$.value="off"}}});x.add(()=>De.dispose()),x.add(ke(p,{position:"bottom"})),x.add(M.effect(()=>{K.value,requestAnimationFrame(()=>{p.isConnected&&I.scan(g)})}));const Fe=E.contextMenu(g,{cursor:"glyph",match:".lnx-row",inherit:!1,density:"compact",items:a=>Re(a.dataset.id)});x.add(()=>Fe?.destroy?.());const ne=a=>{const t=a.target.closest(".lnx-row");if(!t||a.target.closest(".lnx-switch"))return;const l=a.target.closest(".lnx-kebab");if(l){Se(l);return}z(t.dataset.id)},se=a=>{const t=a.target.closest(".lnx-toggle"),l=t?.closest(".lnx-row"),m=l&&O(l.dataset.id);m&&q(m,t.checked)},ie=a=>{const t=a.target.closest(".lnx-row");t&&(a.key==="F10"&&a.shiftKey?(a.preventDefault(),Se(t)):a.key==="Enter"&&a.target===t&&z(t.dataset.id))};if(g.addEventListener("click",ne),g.addEventListener("change",se),g.addEventListener("keydown",ie),x.add(()=>{g.removeEventListener("click",ne),g.removeEventListener("change",se),g.removeEventListener("keydown",ie)}),typeof E.sortable=="function"){const a=Je(),t=E.sortable(g,{items:".lnx-row",handle:".lnx-grip",key:null,keyboard:!1,onStart:a.start,onEnd:({item:l})=>a.restore(l),onSort:({item:l,from:m,to:o})=>{if(a.restore(l),le.peek()){E.toast("Clear the search and show All to reorder.",{type:"info"}),u.value=[...u.peek()];return}const b=oa(u.peek(),m,o);u.value=b,P(b)}});x.add(()=>t.destroy())}we(i,{id:"launchers-new",icon:"plus",title:"New launcher",onClick:()=>z()}),we(i,{id:"launchers-chats",icon:"message-square",title:"Chats - the conversations from chat launchers",onClick:()=>{location.hash="#/launchers/chats"}});const oe=a=>{w?.dirty()&&(a.preventDefault(),a.returnValue="")};if(window.addEventListener("beforeunload",oe),x.add(()=>window.removeEventListener("beforeunload",oe)),x.add(()=>{if(w?.dirty())try{S.set(D,{id:w.id,values:w.values(),at:new Date().toISOString()})}catch{}[...Y].forEach(a=>{try{a.close(!0)}catch{}})}),I.scan(p),await Le(),!A())return;let y=null;try{y=S.get(D)}catch{}if(y?.values){try{S.remove?S.remove(D):S.set(D,null)}catch{}const a=y.id&&O(y.id)?`your changes to "${Z(O(y.id).name)}"`:"the new launcher you started";await E.confirm(`You left ${a} unsaved. Pick up where you left off?`)&&A()&&z(y.id&&O(y.id)?y.id:null,y.values)}}};
@@ -1240,6 +1240,10 @@ The four Tools below were plugins until 0.67.0 and are now part of the CMS. They
1240
1240
  - Hand-over: with staff available (the Chats screen open and Available on - memory presence, 75s) the chat goes to `waiting` and staff are notified (source `core:chat`, admins); with nobody available the visitor leaves name and email (`message`) unless the launcher says never; `askDetails: always` asks before putting them through. A staff reply makes it `open` and the bot stays quiet. Hourly tidy-up closes quiet chats (bot 2h, waiting/open 24h) and deletes ended ones after `retentionDays` (90) - bot-only chats with no details after 7 days - with their messages and any orphan messages, one write per collection (adapters' `removeMany`). Chats in memory are an LRU of 2000; unknown tokens are remembered for a minute. A Launchers module that is missing refuses every chat.
1241
1241
  - Admin: **Content > Chats** (`#/launchers/chats`, `#/launchers/chats/:id`) - the inbox, waiting first, the live thread (3s poll), replies with per-chat drafts, end/delete/email in a context menu, Available switch, settings cog; sidebar badge `/api/chats/_count` (live while someone waits, red after 5 minutes). **Chats > Knowledge** (`#/launchers/knowledge`) - entries with an editor slideover (question, other ways of asking, keywords, Markdown answer, up to five buttons, on/off), Try the bot with scores, and the Unanswered list (Make an entry, add to the closest entry, dismiss). Visitor panel `public/js/launcher-chat.mjs` `mountChat(container, {launcherId, title, chat})` + `public/css/launcher-chat.css`, domma-reactive.
1242
1242
  - Permission `chats` (`read`, `reply`, `manage`) in the Tools group; Admin is granted it once. All of it is behind the Launchers switch.
1243
+ - Della's AI answers (unreleased; Pro plan, hosted sites): when the matcher says `none`, `services/chat/ai.js` `aiAnswer()` asks the Manager (`MANAGER_URL` + `FLEET_TOKEN`, `POST /api/fleet/launcher-chat`; on dcm the in-process registry `Symbol.for('domma.launcher-chat')`) with the site's name, `assistantBrief()` (site.json `assistant.context`/`rules` from Site Settings > General > AI assistant, plus the launcher's `chat.aiContext`/`aiRules`), the enabled non-sample Knowledge (most used first, 16,000 characters), the last 10 visitor/bot messages and the question. A non-empty answer is stored as a bot message with `ai: true` (`misses` reset); empty or refused falls back to the usual "do not know". The question is still logged as unanswered. A 403 (no licence) backs off 10 minutes, a 429 (month used) 30 minutes, anything else 1 minute. Per launcher `chat.ai` (default on), `chat.aiUseSite` (default on; off = the launcher's own context only - the site's rules always apply), `chat.aiMaxPerChat` (20; `aiCount` on the session); the default bot name is now Della. `aiContext`/`aiRules` never reach the page (`publicLauncher`). `/api/chat/config` says `ai` so the panel can say Della is an AI assistant. Manager side: `plugins/site-manager/services/launcherChatRoutes.js` (fleet token, the `ai-site-builder` licence, 2,000 answers per site per month counting "do not know", 4 at once) and `tools/launcher-chat` (Claude Haiku 5.5, low effort; fixed cached system prompt, then the owner's context and rules as a second system block; the visitor's words only in the user message; `LAUNCHER_CHAT_ANTHROPIC_KEY` read by the job alone).
1244
+ - Saved chats (unreleased): preset `chat-saved` (in `CHAT_PRESET_SLUGS`, `chats.manage` through the generic API, kept out of site repos) - a copy of a chat with `note`, `outcome` (to look at / looking into it / done), visitor, page, dates, who saved it, `transcript` (plain text) and `messages`. `POST /api/chats/:id/save` (reply), `GET /api/chats/saved` and `/saved/:sid` (read), `PUT /saved/:sid` (reply; note, outcome), `DELETE /saved/:sid` (manage); at most 2,000 per site. Chats inbox: a **Saved** tab, the context-menu item **Save for a closer look…**, and an outcome/note bar on an open saved chat (`services/chat/saved.js`, `arrangeSaved()`).
1245
+ - Visitor panel look (unreleased): bot and staff avatars, runs of messages grouped (name on the first, avatar on the last), gradient visitor bubbles, soft chips for links and choices, a rounded composer with the send button inside, messages easing in (still for reduced motion), and in a launcher panel the bot's avatar (with a dot while someone answers) and the status under the title. Panel 400 x 600. Per-chat branding: `chat.accent` / `chat.accentText` (a theme token or hex, `launcherColour`) and `chat.avatar` (a site address only, `launcherAvatar()`), in the page's chat block and `/api/chat/config`; the panel sets `--chat-accent` / `--chat-accent-text` on itself (`launcherChatAccentCss()`: a hex accent with no text colour gets black or white by contrast, a token its `--dm-<token>-text`), and the bot's picture replaces its initial in the heading, the typing row and its messages.
1246
+ - Chat window and extras (unreleased): `chat.size` sm/md/lg/custom + `width`/`height` (`launcherChatBox()`; desktop only, clamped 300-720 x 380-900 and to the window), `chat.resizable` (a grip in the corner opposite the disc; size kept per launcher in the browser, `launcher-chat-size:<id>`, double-click resets), `chat.starters` (up to 4 buttons under the greeting; a tap within 1.7s of opening waits out the anti-bot window), `chat.personButton` below/header (an icon with a tooltip before the close button), greeting placeholders `{greeting}` `{timeofday}` `{day}` `{date}` `{time}` `{botname}` `{site}`, `chat.times` time/datetime/none on each message (`fillGreeting()`, the visitor's clock, text only), and `chat.keepDays` (0 = the site's `retentionDays`; the hourly tidy-up reads each launcher's).
1243
1247
  Where: `server/services/chat/` (matcher, store, conversation, settings, launcher-bridge), `server/routes/api/chat.js`, `server/routes/api/chats.js`, `admin/js/views/chats.js`, `admin/js/views/chat-knowledge.js`, `admin/js/lib/chats-arrange.js`, Documentation > Usage > Chat & Knowledge; tests `tests/services/chat-matcher.test.js`, `tests/routes/chat.test.js`, `tests/services/chat-collection-access.test.js`, `tests/admin/chats-arrange.test.js`.
1244
1248
 
1245
1249
  ## Users, Roles & Security
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "domma-cms",
3
- "version": "1.49.2",
3
+ "version": "1.51.0",
4
4
  "description": "File-based CMS powered by Domma and Fastify. Run npx domma-cms my-site to create a new project.",
5
5
  "type": "module",
6
6
  "main": "server/server.js",
@@ -18,6 +18,7 @@
18
18
  "admin/dist/domma/domma-tools.min.js",
19
19
  "public/js/",
20
20
  "public/css/",
21
+ "public/images/characters/",
21
22
  "config/",
22
23
  "!config/connections.json",
23
24
  "!config/theme.json",
@@ -0,0 +1 @@
1
+ .dm-character{display:inline-block;position:relative;width:112px;height:112px;flex:none;overflow:hidden;vertical-align:middle}.dm-character-sprite{display:block;width:100%;height:100%;background-image:var(--dm-character-art);background-size:300% 200%;background-repeat:no-repeat;transform-origin:50% 95%}.dm-character[data-state=greeting] .dm-character-sprite{background-position:50% 0}.dm-character[data-state=working] .dm-character-sprite{background-position:100% 0}.dm-character[data-state=thinking] .dm-character-sprite{background-position:0 100%}.dm-character[data-state=success] .dm-character-sprite{background-position:50% 100%}.dm-character[data-state=help] .dm-character-sprite{background-position:100% 100%}.dm-character[data-animated=true] .dm-character-sprite{animation:dm-character-breathe 5s ease-in-out infinite}.dm-character[data-animated=true][data-state=greeting] .dm-character-sprite{animation:dm-character-hello 1.4s ease-in-out 2}.dm-character[data-animated=true][data-state=thinking] .dm-character-sprite{animation:dm-character-think 3.5s ease-in-out infinite}.dm-character[data-animated=true][data-state=success] .dm-character-sprite{animation:dm-character-success .85s ease-out both}.dm-character--portrait{width:100%;height:100%;border-radius:inherit;background:#f0e3ef}.dm-character--portrait .dm-character-sprite{position:absolute;width:240%;height:240%;left:-70%;top:0;background-position:0 0!important;animation:none!important}.dm-character-disc>.dm-launcher-icon{display:none}.dm-character-disc>.dm-character{width:var(--launcher-size);height:var(--launcher-size);border-radius:50%}.dm-character-avatar>.dm-chat-avatar-img,.dm-character-avatar>.dm-chat-avatar-letter{display:none}.dm-chat-character{display:flex;align-items:center;gap:8px;padding:0 12px;border-bottom:1px solid var(--dm-border,#e7dfe6);background:var(--dm-surface,#fff)}.dm-chat-character[hidden]{display:none}.dm-chat-character-copy{min-width:0;font-size:12px;line-height:1.5;color:var(--dm-text-muted,#766d73)}.dm-chat-character-copy strong{display:block;font-size:15px;color:var(--dm-text,#382337);margin-bottom:3px}.dm-chat.has-character .dm-chat-msg--bot .dm-chat-avatar{overflow:hidden;position:relative;background:#f0e3ef}.dm-chat.has-character .dm-chat-msg--bot .dm-chat-avatar>img,.dm-chat.has-character .dm-chat-msg--bot .dm-chat-avatar>.dm-chat-avatar-letter{display:none}.dm-chat.has-character .dm-chat-msg--bot .dm-chat-avatar:before{content:"";position:absolute;width:240%;height:240%;left:-70%;top:0;background-image:var(--dm-character-art);background-size:300% 200%;background-repeat:no-repeat}.dm-reduced-motion .dm-character-sprite{animation:none!important}.dm-builder-character{border:1px solid var(--dm-border,#e7dfe6);border-radius:var(--dm-radius,10px);margin-bottom:16px;background:var(--dm-surface,#fff);overflow:hidden}.dm-builder-character-toolbar{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 16px;font-size:13px}.dm-builder-character-toolbar label{display:flex;align-items:center;gap:9px;white-space:nowrap;cursor:pointer;font-weight:600}.dm-builder-character-toolbar small{color:var(--dm-text-muted,#766d73);font-size:11px;line-height:1.5}.dm-builder-character-content{display:flex;align-items:center;gap:18px;padding:0 20px 6px;border-top:1px solid var(--dm-border,#e7dfe6)}.dm-builder-character-content[hidden]{display:none}.dm-builder-character-content .dm-character{width:124px;height:124px}.dm-builder-character-content strong{display:block;font-size:21px;color:var(--dm-text,#382337);margin-bottom:6px}.dm-builder-character-content div>span{display:block;font-size:13px;line-height:1.6;color:var(--dm-text-muted,#766d73)}@media(max-width:640px){.dm-builder-character-toolbar{align-items:flex-start;flex-direction:column;gap:5px}.dm-builder-character-content{gap:6px;padding:0 12px 5px}.dm-builder-character-content .dm-character{width:100px;height:100px}}@keyframes dm-character-breathe{50%{transform:translateY(-1px) scale(1.006)}}@keyframes dm-character-hello{35%{transform:rotate(-1.5deg)}70%{transform:rotate(1deg)}}@keyframes dm-character-think{50%{transform:rotate(-1.2deg)}}@keyframes dm-character-success{35%{transform:translateY(-4px) scale(1.015)}65%{transform:scale(.995)}}@media(prefers-reduced-motion:reduce){.dm-character-sprite{animation:none!important}}@media(max-height:650px){.dm-chat-character .dm-character{width:76px;height:76px}}
@@ -1 +1 @@
1
- .dm-chat{display:flex;flex-direction:column;gap:.5rem;height:100%;min-height:320px;color:var(--dm-text, #111);font-size:.9375rem}.dm-chat [hidden]{display:none!important}.dm-chat-status{margin:0;font-size:.8125rem;color:var(--dm-text-muted, #666)}.dm-chat-log{flex:1 1 auto;min-height:160px;overflow-y:auto;overscroll-behavior:contain;display:flex;flex-direction:column;gap:.75rem;padding:.25rem .125rem .5rem}.dm-chat-log:focus-visible{outline:2px solid var(--dm-primary, #5b8cff);outline-offset:2px}.dm-chat-items{display:flex;flex-direction:column;gap:.75rem}.dm-chat-msg{display:flex;flex-direction:column;align-items:flex-start;gap:.2rem;max-width:88%}.dm-chat-msg--visitor{align-self:flex-end;align-items:flex-end}.dm-chat-msg--system{align-self:center;align-items:center;max-width:95%}.dm-chat-who{font-size:.75rem;color:var(--dm-text-muted, #666);display:flex;gap:.4rem}.dm-chat-who:has(span:empty){display:none}.dm-chat-msg--system .dm-chat-who{display:none}.dm-chat-bubble{padding:.55rem .8rem;border-radius:14px;background:var(--dm-hover-bg, rgba(128, 128, 128, .12));border:1px solid var(--dm-border, rgba(128, 128, 128, .25));overflow-wrap:anywhere;line-height:1.45}.dm-chat-msg--bot .dm-chat-bubble,.dm-chat-msg--staff .dm-chat-bubble{border-bottom-left-radius:4px}.dm-chat-msg--visitor .dm-chat-bubble{background:var(--dm-primary, #5b8cff);border-color:var(--dm-primary, #5b8cff);color:var(--dm-primary-text, #fff);border-bottom-right-radius:4px}.dm-chat-msg--system .dm-chat-bubble{background:transparent;border-style:dashed;font-size:.8125rem;color:var(--dm-text-muted, #666);text-align:center}.dm-chat-text{white-space:pre-wrap}.dm-chat-text:empty,.dm-chat-html:empty,.dm-chat-links:empty,.dm-chat-choices:empty{display:none}.dm-chat-html>:first-child{margin-top:0}.dm-chat-html>:last-child{margin-bottom:0}.dm-chat-html p{margin:0 0 .5em}.dm-chat-html ul,.dm-chat-html ol{margin:0 0 .5em;padding-left:1.25em}.dm-chat-html a{color:var(--dm-link, var(--dm-primary, #5b8cff))}.dm-chat-links,.dm-chat-choices{display:flex;flex-wrap:wrap;gap:.35rem}.dm-chat-link,.dm-chat-choice,.dm-chat-action{display:inline-flex;align-items:center;padding:.3rem .7rem;border-radius:999px;border:1px solid var(--dm-primary, #5b8cff);background:var(--dm-surface, #fff);color:var(--dm-primary, #5b8cff);font:inherit;font-size:.8125rem;text-decoration:none;cursor:pointer;text-align:left}.dm-chat-link:hover,.dm-chat-choice:hover,.dm-chat-action:hover:not(:disabled){background:var(--dm-primary, #5b8cff);color:var(--dm-primary-text, #fff)}.dm-chat-link:focus-visible,.dm-chat-choice:focus-visible,.dm-chat-action:focus-visible{outline:2px solid var(--dm-primary, #5b8cff);outline-offset:2px}.dm-chat-actions{display:flex;flex-wrap:wrap;gap:.4rem}.dm-chat-actions:not(:has(button:not([hidden]))){display:none}.dm-chat-action:disabled{opacity:.55;cursor:default}.dm-chat-action--end{border-color:var(--dm-border, rgba(128, 128, 128, .4));color:var(--dm-text-muted, #666);margin-left:auto}.dm-chat-error{margin:0;padding:.4rem .6rem;border-radius:8px;font-size:.8125rem;background:color-mix(in srgb,var(--dm-danger, #d33) 12%,transparent);color:var(--dm-danger, #c22)}.dm-chat-details{display:flex;flex-direction:column;gap:.45rem;padding:.65rem;border:1px solid var(--dm-border, rgba(128, 128, 128, .25));border-radius:12px;background:var(--dm-surface, #fff)}.dm-chat-details-intro{margin:0;font-size:.8125rem}.dm-chat-field{display:flex;flex-direction:column;gap:.2rem;font-size:.8125rem}.dm-chat-details .btn{align-self:flex-start}.dm-chat-ended{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:.5rem;font-size:.875rem;color:var(--dm-text-muted, #666)}.dm-chat-compose{display:flex;align-items:flex-end;gap:.4rem;padding-top:.25rem;border-top:1px solid var(--dm-border, rgba(128, 128, 128, .25))}.dm-chat-input{flex:1 1 auto;resize:none;min-height:2.5rem;max-height:120px;line-height:1.4;font-family:inherit;font-size:16px}.dm-chat-send{flex:0 0 auto;width:2.5rem;height:2.5rem;padding:0;display:inline-flex;align-items:center;justify-content:center}.dm-chat-send svg{width:16px;height:16px;pointer-events:none}.dm-chat-hp{position:absolute!important;left:-9999px!important;width:1px;height:1px;opacity:0}.dm-chat-typing .dm-chat-bubble{display:inline-flex;gap:4px;padding:.7rem .8rem}.dm-chat-dot{width:6px;height:6px;border-radius:50%;background:var(--dm-text-muted, #888);animation:dm-chat-dot 1.2s infinite ease-in-out}.dm-chat-dot:nth-child(2){animation-delay:.15s}.dm-chat-dot:nth-child(3){animation-delay:.3s}@keyframes dm-chat-dot{0%,80%,to{opacity:.35;transform:translateY(0)}40%{opacity:1;transform:translateY(-3px)}}.dm-chat.is-still .dm-chat-dot,html.dm-reduced-motion .dm-chat-dot{animation:none;opacity:.6}@media(prefers-reduced-motion:reduce){.dm-chat-dot{animation:none;opacity:.6}}@media(max-width:480px){.dm-chat-msg{max-width:94%}}
1
+ .dm-chat{--dm-chat-gap: 14px;display:flex;flex-direction:column;height:100%;min-height:320px;color:var(--dm-text, #111);background:color-mix(in srgb,var(--dm-text, #111) 4%,var(--dm-surface, #fff));font-size:.9375rem}.dm-chat [hidden]{display:none!important}.dm-chat-status{margin:0;padding:10px var(--dm-chat-gap) 0;font-size:.8125rem;color:var(--dm-text-muted, #666)}.dm-chat-log{flex:1 1 auto;min-height:160px;overflow-y:auto;overscroll-behavior:contain;display:flex;flex-direction:column;gap:2px;padding:var(--dm-chat-gap) var(--dm-chat-gap) 8px;scrollbar-width:thin}.dm-chat-log:focus-visible{outline:2px solid var(--chat-accent, var(--dm-primary, #5b8cff));outline-offset:-2px}.dm-chat-items{display:flex;flex-direction:column;gap:2px}.dm-chat-msg{display:grid;grid-template-columns:28px minmax(0,1fr);column-gap:8px;align-items:end;max-width:90%;margin-top:12px}.dm-chat-msg.is-cont{margin-top:2px}.dm-chat-items>.dm-chat-msg:first-child{margin-top:0}.dm-chat-msg>:not(.dm-chat-avatar){grid-column:2}.dm-chat-avatar{grid-column:1;grid-row:1 / span 4;align-self:end;width:28px;height:28px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;font-size:.75rem;font-weight:700;letter-spacing:.02em;background:linear-gradient(135deg,var(--chat-accent, var(--dm-primary, #5b8cff)),color-mix(in srgb,var(--chat-accent, var(--dm-primary, #5b8cff)) 82%,#000));color:var(--chat-accent-text, var(--dm-primary-text, #fff));user-select:none}.dm-chat-msg--staff .dm-chat-avatar{background:var(--dm-surface, #fff);color:var(--dm-text, #111);box-shadow:inset 0 0 0 1px var(--dm-border, rgba(128, 128, 128, .3))}.dm-chat-msg.has-next .dm-chat-avatar{visibility:hidden}.dm-chat-msg.is-cont .dm-chat-who{display:none}.dm-chat-msg--visitor{align-self:flex-end;grid-template-columns:minmax(0,1fr);justify-items:end}.dm-chat-msg--visitor>*{grid-column:1!important}.dm-chat-msg--visitor .dm-chat-avatar{display:none}.dm-chat-msg--system{align-self:center;grid-template-columns:minmax(0,1fr);justify-items:center;max-width:92%;margin:14px 0 6px}.dm-chat-msg--system>*{grid-column:1!important}.dm-chat-msg--system .dm-chat-avatar,.dm-chat-msg--system .dm-chat-who{display:none}.dm-chat-who{display:flex;align-items:baseline;gap:6px;margin:0 4px 4px;font-size:.75rem;font-weight:600;color:var(--dm-text-secondary, var(--dm-text-muted, #555))}.dm-chat-who time{font-weight:400;color:var(--dm-text-muted, #888)}.dm-chat-who time:empty{display:none}.dm-chat-who:has(span:empty){display:none}.dm-chat-msg--visitor .dm-chat-who span{display:none}.dm-chat-bubble{width:fit-content;max-width:100%;padding:9px 13px;border-radius:18px;background:var(--dm-surface-raised, var(--dm-surface, #fff));color:var(--dm-text, #111);box-shadow:0 1px 2px #0000000f,0 0 0 1px color-mix(in srgb,var(--dm-border, #ccc) 55%,transparent);overflow-wrap:anywhere;line-height:1.5}.dm-chat-msg--bot .dm-chat-bubble,.dm-chat-msg--staff .dm-chat-bubble{border-bottom-left-radius:6px}.dm-chat-msg--bot.is-cont .dm-chat-bubble,.dm-chat-msg--staff.is-cont .dm-chat-bubble{border-top-left-radius:6px}.dm-chat-msg--visitor .dm-chat-bubble{background:linear-gradient(135deg,var(--chat-accent, var(--dm-primary, #5b8cff)),color-mix(in srgb,var(--chat-accent, var(--dm-primary, #5b8cff)) 82%,#000));color:var(--chat-accent-text, var(--dm-primary-text, #fff));box-shadow:0 1px 2px #0000001f;border-bottom-right-radius:6px}.dm-chat-msg--visitor.is-cont .dm-chat-bubble{border-top-right-radius:6px}.dm-chat-msg--system .dm-chat-bubble{padding:5px 12px;border-radius:999px;background:color-mix(in srgb,var(--dm-text, #111) 6%,transparent);box-shadow:none;font-size:.78125rem;line-height:1.4;color:var(--dm-text-secondary, var(--dm-text-muted, #555));text-align:center}.dm-chat-text{white-space:pre-wrap}.dm-chat-text:empty,.dm-chat-html:empty,.dm-chat-links:empty,.dm-chat-choices:empty{display:none}.dm-chat-html>:first-child{margin-top:0}.dm-chat-html>:last-child{margin-bottom:0}.dm-chat-html p{margin:0 0 .5em}.dm-chat-html ul,.dm-chat-html ol{margin:0 0 .5em;padding-left:1.25em}.dm-chat-html a{color:var(--dm-link, var(--chat-accent, var(--dm-primary, #5b8cff)))}.dm-chat-links,.dm-chat-choices{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}.dm-chat-link,.dm-chat-choice,.dm-chat-action{display:inline-flex;align-items:center;gap:6px;padding:6px 12px;border-radius:999px;border:1px solid color-mix(in srgb,var(--chat-accent, var(--dm-primary, #5b8cff)) 35%,transparent);background:color-mix(in srgb,var(--chat-accent, var(--dm-primary, #5b8cff)) 8%,var(--dm-surface, #fff));color:var(--chat-accent, var(--dm-primary, #3b6cdf));font:inherit;font-size:.8125rem;font-weight:500;line-height:1.3;text-decoration:none;cursor:pointer;text-align:left;transition:background-color .15s ease,color .15s ease,border-color .15s ease}.dm-chat-link:hover,.dm-chat-choice:hover,.dm-chat-action:hover:not(:disabled){background:var(--chat-accent, var(--dm-primary, #5b8cff));border-color:var(--chat-accent, var(--dm-primary, #5b8cff));color:var(--chat-accent-text, var(--dm-primary-text, #fff))}.dm-chat-link:focus-visible,.dm-chat-choice:focus-visible,.dm-chat-action:focus-visible{outline:2px solid var(--chat-accent, var(--dm-primary, #5b8cff));outline-offset:2px}.dm-chat-choices:not(.dm-chat-starters) .dm-chat-choice:last-child:not(:first-child){border-color:var(--dm-border, rgba(128, 128, 128, .35));background:var(--dm-surface, #fff);color:var(--dm-text-secondary, var(--dm-text-muted, #555))}.dm-chat-actions{display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding:4px var(--dm-chat-gap) 8px}.dm-chat-actions:not(:has(button:not([hidden]))){display:none}.dm-chat-action svg{width:14px;height:14px;flex:0 0 auto}.dm-chat-action:disabled{opacity:.55;cursor:default}.dm-chat-action--end{margin-left:auto;padding:4px 6px;border:0;background:none;color:var(--dm-text-muted, #777);font-weight:400}.dm-chat-action--end:hover:not(:disabled){background:none;color:var(--dm-danger, #c22);text-decoration:underline}.dm-chat-error{margin:0 var(--dm-chat-gap) 8px;padding:8px 12px;border-radius:10px;font-size:.8125rem;background:color-mix(in srgb,var(--dm-danger, #d33) 12%,var(--dm-surface, #fff));color:var(--dm-danger, #c22)}.dm-chat-details{display:flex;flex-direction:column;gap:8px;margin:0 var(--dm-chat-gap) 10px;padding:14px;border-radius:16px;background:var(--dm-surface, #fff);box-shadow:0 1px 2px #0000000f,0 0 0 1px color-mix(in srgb,var(--dm-border, #ccc) 55%,transparent)}.dm-chat-details-intro{margin:0 0 2px;font-size:.875rem;font-weight:600}.dm-chat-field{display:flex;flex-direction:column;gap:4px;font-size:.78125rem;color:var(--dm-text-secondary, var(--dm-text-muted, #555))}.dm-chat-field .form-input{border-radius:10px}.dm-chat-details .btn{align-self:stretch;border-radius:999px;margin-top:4px}.dm-chat-ended{display:flex;flex-direction:column;align-items:center;gap:10px;padding:14px var(--dm-chat-gap) 16px;border-top:1px solid color-mix(in srgb,var(--dm-border, #ccc) 60%,transparent);background:var(--dm-surface, #fff);font-size:.875rem;color:var(--dm-text-muted, #666)}.dm-chat-ended .btn{border-radius:999px}.dm-chat-compose{position:relative;display:flex;align-items:flex-end;gap:6px;margin:0;padding:10px var(--dm-chat-gap) 12px;background:var(--dm-surface, #fff);border-top:1px solid color-mix(in srgb,var(--dm-border, #ccc) 60%,transparent)}.dm-chat-field-wrap{flex:1 1 auto;display:flex;align-items:flex-end;gap:6px;padding:5px 5px 5px 14px;border-radius:22px;background:var(--dm-input-bg, var(--dm-surface, #fff));border:1px solid var(--dm-border, rgba(128, 128, 128, .3));transition:border-color .15s ease,box-shadow .15s ease}.dm-chat-field-wrap:focus-within{border-color:var(--chat-accent, var(--dm-primary, #5b8cff));box-shadow:0 0 0 3px color-mix(in srgb,var(--chat-accent, var(--dm-primary, #5b8cff)) 20%,transparent)}.dm-chat-input.form-input,.dm-chat-input{flex:1 1 auto;resize:none;min-height:32px;max-height:120px;margin:0;padding:6px 0;border:0!important;background:transparent!important;box-shadow:none!important;outline:none;color:var(--dm-input-text, var(--dm-text, #111));line-height:1.4;font-family:inherit;font-size:16px}.dm-chat-send.btn,.dm-chat-send{flex:0 0 auto;width:34px;height:34px;min-height:0;padding:0;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;transition:transform .15s ease,opacity .15s ease}.dm-chat-send:disabled{opacity:.4}.dm-chat-send:not(:disabled):active{transform:scale(.92)}.dm-chat-send svg{width:16px;height:16px;pointer-events:none}.dm-chat-foot{margin:0;padding:0 var(--dm-chat-gap) 10px;background:var(--dm-surface, #fff);font-size:.6875rem;text-align:center;color:var(--dm-text-muted, #888)}.dm-chat-foot:empty{display:none}.dm-chat-hp{position:absolute!important;left:-9999px!important;width:1px;height:1px;opacity:0}.dm-chat-typing{margin-top:12px}.dm-chat-typing .dm-chat-bubble{display:inline-flex;gap:4px;padding:12px 14px}.dm-chat-dot{width:6px;height:6px;border-radius:50%;background:var(--dm-text-muted, #888);animation:dm-chat-dot 1.2s infinite ease-in-out}.dm-chat-dot:nth-child(2){animation-delay:.15s}.dm-chat-dot:nth-child(3){animation-delay:.3s}@keyframes dm-chat-dot{0%,80%,to{opacity:.35;transform:translateY(0)}40%{opacity:1;transform:translateY(-3px)}}.dm-chat-msg.is-new{animation:dm-chat-in .22s ease-out both}@keyframes dm-chat-in{0%{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}.dm-chat.is-still .dm-chat-dot,html.dm-reduced-motion .dm-chat-dot{animation:none;opacity:.6}.dm-chat.is-still .dm-chat-msg.is-new,html.dm-reduced-motion .dm-chat-msg.is-new{animation:none}@media(prefers-reduced-motion:reduce){.dm-chat-dot{animation:none;opacity:.6}.dm-chat-msg.is-new{animation:none}.dm-chat-link,.dm-chat-choice,.dm-chat-action,.dm-chat-field-wrap,.dm-chat-send{transition:none}}@media(max-width:480px){.dm-chat-msg{max-width:94%}}.dm-launcher-chat-avatar{position:relative;flex:0 0 auto;width:38px;height:38px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;font-weight:700;font-size:.95rem;background:color-mix(in srgb,var(--chat-accent-text, var(--dm-primary-text, #fff)) 20%,transparent);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--chat-accent-text, var(--dm-primary-text, #fff)) 30%,transparent);user-select:none}.dm-launcher-chat-avatar.is-online:after{content:"";position:absolute;right:-1px;bottom:-1px;width:11px;height:11px;border-radius:50%;background:var(--dm-success, #22a55b);box-shadow:0 0 0 2px color-mix(in srgb,var(--chat-accent, var(--dm-primary, #5b8cff)) 82%,#000)}.dm-launcher-chat-heading{flex:1;min-width:0;display:flex;flex-direction:column;gap:1px}.dm-launcher-chat-sub{font-size:.75rem;line-height:1.3;opacity:.88;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dm-launcher-chat-sub:empty{display:none}.dm-chat-details .form-input{padding:7px 10px;font-size:16px;line-height:1.3;min-height:0}.dm-chat-details textarea.form-input{min-height:52px;resize:vertical}.dm-chat-avatar{overflow:hidden}.dm-chat-avatar-img{width:100%;height:100%;object-fit:cover;border-radius:50%}.dm-chat-avatar-img[src=""],.dm-chat-avatar-img:not([src]){display:none}.dm-chat-avatar:has(.dm-chat-avatar-img:not([src=""])) .dm-chat-avatar-letter,.dm-launcher-chat-avatar:has(.dm-chat-avatar-img:not([src=""])) .dm-chat-avatar-letter{display:none}.dm-chat-avatar:has(.dm-chat-avatar-img:not([src=""])){background:none}.dm-chat .btn-primary{background:var(--chat-accent, var(--dm-primary));border-color:var(--chat-accent, var(--dm-primary));color:var(--chat-accent-text, var(--dm-primary-text))}.dm-chat .btn-primary:hover:not(:disabled){filter:brightness(.94)}.dm-chat-field-wrap:focus-within{border-color:var(--chat-accent, var(--dm-primary, #5b8cff))}.dm-chat.has-chat .dm-chat-starters{display:none}.dm-launcher-chat-person{flex:0 0 auto;width:32px;height:32px;border:0;border-radius:50%;background:none;color:inherit;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;transition:background-color .15s ease}.dm-launcher-chat-person[hidden]{display:none}.dm-launcher-chat-person:hover:not(:disabled){background:color-mix(in srgb,currentColor 16%,transparent)}.dm-launcher-chat-person:focus-visible{outline:2px solid currentColor;outline-offset:1px}.dm-launcher-chat-person:disabled{opacity:.55;cursor:default}.dm-launcher-chat-person svg{width:18px;height:18px}
@@ -1 +1 @@
1
- .dm-launcher{position:fixed;z-index:1000;width:var(--launcher-size, 52px);height:var(--launcher-size, 52px);border-radius:var(--launcher-radius, 50%);border:1px solid color-mix(in srgb,var(--launcher-bg, var(--dm-primary)) 70%,var(--dm-text));background:var(--launcher-bg, var(--dm-primary));color:var(--launcher-fg, var(--dm-primary-text));box-shadow:0 4px 16px #0000002e;display:flex;align-items:center;justify-content:center;gap:8px;padding:0;cursor:pointer;white-space:nowrap;font:inherit;transition:filter .15s ease}.dm-launcher[hidden]{display:none!important}.dm-launcher:hover,.dm-launcher[aria-expanded=true]{filter:brightness(1.08) saturate(1.05)}.dm-launcher:focus-visible{outline:2px solid var(--launcher-bg, var(--dm-primary));outline-offset:3px}.dm-launcher .dm-launcher-icon,.dm-launcher svg{width:var(--launcher-glyph, 20px);height:var(--launcher-glyph, 20px);flex-shrink:0;pointer-events:none}.dm-launcher--pill{width:auto;height:auto;min-height:44px;padding:0 18px 0 14px}.dm-launcher-label{font-size:.875rem;font-weight:600;pointer-events:none}.dm-launcher-frame{display:block;width:100%;border:0;background:transparent;min-height:160px;max-height:calc(100vh - 12rem)}.dm-launcher-modal::part(dialog){width:min(var(--launcher-modal-w, 800px),90vw);max-width:90vw}.dm-launcher-modal--custom::part(dialog){width:min(var(--launcher-modal-w),100vw);max-width:100vw}.dm-launcher-modal--fixed::part(dialog){height:min(var(--launcher-modal-h),100vh);max-height:100vh}.dm-launcher-modal--fixed::part(body){display:flex;flex-direction:column}.dm-launcher-modal--screen::part(dialog){width:100vw;max-width:none;height:100vh;max-height:none;border:0;border-radius:0}.dm-launcher-frame:not(.is-fill){height:60vh}.dm-launcher-so .dm-slideover-body.dm-launcher-so-body{padding:0;display:flex;flex-direction:column;overflow:hidden}.dm-launcher-frame.is-fill{flex:1;height:100%;max-height:none}.dm-launcher-covering :is(.site-search-floating-trigger,#back-to-top-btn,#go-to-bottom-btn,.dm-theme-switcher:not(.dm-ts-inline),.dm-motion-fab){visibility:hidden!important}.dm-launcher-chat{position:fixed;z-index:1040;display:flex;flex-direction:column;background:var(--dm-surface);color:var(--dm-text);border:1px solid var(--dm-border);border-radius:var(--dm-radius-lg, 12px);box-shadow:0 12px 40px #00000038;overflow:hidden}.dm-launcher-chat.is-full{inset:0;width:auto;height:auto;border-radius:0;border:0}.dm-launcher-chat-head{display:flex;align-items:center;gap:.5rem;padding:.65rem .75rem .65rem 1rem;background:var(--dm-primary);color:var(--dm-primary-text)}.dm-launcher-chat-title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dm-launcher-chat-close{background:none;border:0;color:inherit;cursor:pointer;padding:4px;border-radius:var(--dm-radius-sm, 4px);display:inline-flex}.dm-launcher-chat-close svg{width:18px;height:18px}.dm-launcher-chat-close:focus-visible{outline:2px solid currentColor;outline-offset:1px}.dm-launcher-chat-body{flex:1;min-height:0;display:flex;flex-direction:column;overflow:auto}.dm-launcher-note{margin:0;padding:1rem;color:var(--dm-text-muted);font-size:var(--dm-text-sm, .875rem)}.dm-launcher-note[hidden]{display:none}body.dm-launcher-embed .site-main,body.dm-launcher-embed .site-content{padding-top:0;margin-top:0;min-height:0}body.dm-launcher-embed .site-content>.container{padding-top:1rem;padding-bottom:1rem}@media(prefers-reduced-motion:reduce){.dm-launcher{transition:none}}html.dm-reduced-motion .dm-launcher{transition:none}@media print{.dm-launcher,.dm-launcher-chat{display:none!important}}
1
+ .dm-launcher{position:fixed;z-index:1000;width:var(--launcher-size, 52px);height:var(--launcher-size, 52px);border-radius:var(--launcher-radius, 50%);border:1px solid color-mix(in srgb,var(--launcher-bg, var(--dm-primary)) 70%,var(--dm-text));background:var(--launcher-bg, var(--dm-primary));color:var(--launcher-fg, var(--dm-primary-text));box-shadow:0 4px 16px #0000002e;display:flex;align-items:center;justify-content:center;gap:8px;padding:0;cursor:pointer;white-space:nowrap;font:inherit;transition:filter .15s ease}.dm-launcher[hidden]{display:none!important}.dm-launcher:hover,.dm-launcher[aria-expanded=true]{filter:brightness(1.08) saturate(1.05)}.dm-launcher:focus-visible{outline:2px solid var(--launcher-bg, var(--dm-primary));outline-offset:3px}.dm-launcher .dm-launcher-icon,.dm-launcher svg{width:var(--launcher-glyph, 20px);height:var(--launcher-glyph, 20px);flex-shrink:0;pointer-events:none}.dm-launcher--pill{width:auto;height:auto;min-height:44px;padding:0 18px 0 14px}.dm-launcher-label{font-size:.875rem;font-weight:600;pointer-events:none}.dm-launcher-frame{display:block;width:100%;border:0;background:transparent;min-height:160px;max-height:calc(100vh - 12rem)}.dm-launcher-modal::part(dialog){width:min(var(--launcher-modal-w, 800px),90vw);max-width:90vw}.dm-launcher-modal--custom::part(dialog){width:min(var(--launcher-modal-w),100vw);max-width:100vw}.dm-launcher-modal--fixed::part(dialog){height:min(var(--launcher-modal-h),100vh);max-height:100vh}.dm-launcher-modal--fixed::part(body){display:flex;flex-direction:column}.dm-launcher-modal--screen::part(dialog){width:100vw;max-width:none;height:100vh;max-height:none;border:0;border-radius:0}.dm-launcher-frame:not(.is-fill){height:60vh}.dm-launcher-so .dm-slideover-body.dm-launcher-so-body{padding:0;display:flex;flex-direction:column;overflow:hidden}.dm-launcher-frame.is-fill{flex:1;height:100%;max-height:none}.dm-launcher-covering :is(.site-search-floating-trigger,#back-to-top-btn,#go-to-bottom-btn,.dm-theme-switcher:not(.dm-ts-inline),.dm-motion-fab){visibility:hidden!important}.dm-launcher-chat{position:fixed;z-index:1040;display:flex;flex-direction:column;background:var(--dm-surface);color:var(--dm-text);border:1px solid color-mix(in srgb,var(--dm-border) 70%,transparent);border-radius:20px;box-shadow:0 24px 60px -12px #00000052,0 4px 14px #00000014;overflow:hidden}.dm-launcher-chat.is-full{inset:0;width:auto;height:auto;border-radius:0;border:0}.dm-launcher-chat-head{display:flex;align-items:center;gap:.75rem;padding:14px 12px 14px 16px;background:linear-gradient(135deg,var(--chat-accent, var(--dm-primary)),color-mix(in srgb,var(--chat-accent, var(--dm-primary)) 82%,#000));color:var(--chat-accent-text, var(--dm-primary-text))}.dm-launcher-chat-title{flex:1;min-width:0;font-size:1rem;font-weight:600;line-height:1.25;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dm-launcher-chat-close{flex:0 0 auto;background:none;border:0;color:inherit;cursor:pointer;width:32px;height:32px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;transition:background-color .15s ease}.dm-launcher-chat-close:hover{background:color-mix(in srgb,var(--dm-primary-text) 16%,transparent)}.dm-launcher-chat-close svg{width:18px;height:18px}.dm-launcher-chat-close:focus-visible{outline:2px solid currentColor;outline-offset:1px}.dm-launcher-chat-body{flex:1;min-height:0;display:flex;flex-direction:column;overflow:auto}.dm-launcher-note{margin:0;padding:1rem;color:var(--dm-text-muted);font-size:var(--dm-text-sm, .875rem)}.dm-launcher-note[hidden]{display:none}body.dm-launcher-embed .site-main,body.dm-launcher-embed .site-content{padding-top:0;margin-top:0;min-height:0}body.dm-launcher-embed .site-content>.container{padding-top:1rem;padding-bottom:1rem}@media(prefers-reduced-motion:reduce){.dm-launcher{transition:none}}html.dm-reduced-motion .dm-launcher{transition:none}@media print{.dm-launcher,.dm-launcher-chat{display:none!important}}.dm-launcher-chat-grip{position:absolute;width:14px;height:14px;z-index:2;touch-action:none}.dm-launcher-chat-grip[data-corner=tl]{top:0;left:0;cursor:nwse-resize}.dm-launcher-chat-grip[data-corner=tr]{top:0;right:0;cursor:nesw-resize}.dm-launcher-chat-grip[data-corner=bl]{bottom:0;left:0;cursor:nesw-resize}.dm-launcher-chat-grip[data-corner=br]{bottom:0;right:0;cursor:nwse-resize}.dm-launcher-chat-grip:after{content:"";position:absolute;inset:3px;border:2px solid currentColor;opacity:.45;border-radius:2px;clip-path:polygon(0 0,100% 0,0 100%)}.dm-launcher-chat-grip[data-corner=tr]:after{clip-path:polygon(0 0,100% 0,100% 100%)}.dm-launcher-chat-grip[data-corner=bl]:after{clip-path:polygon(0 0,0 100%,100% 100%)}.dm-launcher-chat-grip[data-corner=br]:after{clip-path:polygon(100% 0,100% 100%,0 100%)}.dm-launcher-chat-grip[data-corner^=t]{color:var(--chat-accent-text, var(--dm-primary-text))}.dm-launcher-chat.is-full .dm-launcher-chat-grip{display:none}.dm-launcher-chat.is-resizing{user-select:none}
@@ -0,0 +1,2 @@
1
+ import{CHARACTERS as p,builderCharacterState as f,normaliseCharacterSettings as w}from"./characters.mjs?v=20261110-builder-characters";import{mountCharacter as R,ensureCharacterCss as T}from"./character-view.mjs?v=20261110-builder-characters";export async function mountBuilderCharacter(d,{id:e,getState:m=()=>({})}={}){const u={destroy(){}};if(!d||!["dot","daisy"].includes(e))return u;const{apiRequest:b}=await import("/admin/js/api.js");let i;try{i=await b("/characters",{method:"GET"})}catch{return u}if(!d.isConnected)return u;const t=M.observable(w(i.settings)),o=M.observable(t.peek()[e]),l=M.observable(!1),c={value:!0};T();const a=document.createElement("section");a.className="dm-builder-character",a.setAttribute("aria-label",`${p[e].name} presentation`),a.innerHTML=`<div class="dm-builder-character-toolbar"><label><input type="checkbox" class="form-switch" data-model="selected.value" data-bind-disabled="disabled.value"><span>Use ${p[e].name}</span></label><small data-bind-text="note.value"></small></div>
2
+ <div class="dm-builder-character-content" data-bind-hidden="!visible.value"><span class="dm-builder-character-stage"></span><div><strong>${p[e].name}</strong><span data-bind-text="words.value"></span></div></div>`,d.prepend(a);const k=()=>i.canUpdate?!t.value.enabled||!t.value.builders?"Character artwork is hidden in Site Settings.":"Saved for this site. Visibility and motion follow Site Settings.":"Only people who can change Site Settings can change this choice.",h=()=>o.value&&t.value.enabled&&t.value.builders,S={selected:o,disabled:M.computed(()=>l.value||!i.canUpdate),visible:M.computed(h),note:M.computed(k),words:M.computed(()=>{const s=m();return s.words?s.words:{greeting:"Ready when you are.",ready:"Here to help with your next step.",working:"Working on your request.",thinking:"Taking a moment to think.",help:"A little input or attention is needed.",success:"Ready for you to review."}[f(s)]})},C=M.applyBindings(S,a);let n=null;const x=M.effect(()=>{const s=m(),r=h(),g=t.value.animated;r&&!n&&(n=R(a.querySelector(".dm-builder-character-stage"),{id:e,animated:g})),!r&&n&&(n.destroy(),n=null),n?.setState(f(s),g)}),v=a.querySelector("input"),y=async()=>{if(l.peek()||!i.canUpdate)return;const s=v.checked;l.value=!0;try{const r=await b(`/characters/${e}`,{method:"PUT",body:JSON.stringify({enabled:s})});if(!c.value)return;t.value=w(r.settings),o.value=t.peek()[e]}catch(r){if(!c.value)return;o.value=t.peek()[e],E.toast(`Not saved: ${r.message||r}`,{type:"error"})}finally{c.value&&(l.value=!1)}};return v.addEventListener("change",y),{destroy(){c.value=!1,v.removeEventListener("change",y),x?.(),n?.destroy(),C?.dispose?.(),a.remove()}}}
@@ -0,0 +1 @@
1
+ import{CHARACTERS as i,characterId as o}from"./characters.mjs?v=20261110-builder-characters";export function ensureCharacterCss(){if(!document.querySelector("link[data-dm-character-css]")){const t=document.createElement("link");t.rel="stylesheet",t.href="/public/css/characters.css?v=20261110-builder-characters",t.dataset.dmCharacterCss="",document.head.appendChild(t)}}export function mountCharacter(t,{id:a,portrait:n=!1,animated:r=!0}={}){if(!t||!o(a))return{setState(){},destroy(){}};ensureCharacterCss();const e=document.createElement("span");e.className=`dm-character${n?" dm-character--portrait":""}`,e.setAttribute("aria-hidden","true"),e.dataset.character=a,e.dataset.state="ready",e.dataset.animated=String(r),e.style.setProperty("--dm-character-art",`url("${i[a].artwork}")`);const s=document.createElement("span");return s.className="dm-character-sprite",e.appendChild(s),t.appendChild(e),{setState(c,d=r){e.dataset.state=["ready","greeting","working","thinking","success","help"].includes(c)?c:"ready",e.dataset.animated=String(d)},destroy(){e.remove()}}}
@@ -0,0 +1 @@
1
+ export const CHARACTERS=Object.freeze({dot:Object.freeze({id:"dot",name:"Dot",artwork:"/public/images/characters/dot-poses.png"}),daisy:Object.freeze({id:"daisy",name:"Daisy",artwork:"/public/images/characters/daisy-poses.png"}),della:Object.freeze({id:"della",name:"Della",artwork:"/public/images/characters/della-poses.png"})});export function characterId(e){return typeof e=="string"&&Object.hasOwn(CHARACTERS,e)?e:""}export function normaliseCharacterSettings(e){const r=e&&typeof e=="object"&&!Array.isArray(e)?e:{};return{enabled:r.enabled!==!1,animated:r.animated!==!1,launchers:r.launchers!==!1,chats:r.chats!==!1,builders:r.builders!==!1,dot:r.dot!==!1,daisy:r.daisy!==!1}}export function builderCharacterState({working:e=!1,busy:r=!1,error:a="",status:t="",hasContent:n=!1}={}){return a||["waiting","failed","stopped"].includes(t)?"help":e||t==="building"?"working":r?"thinking":["ready","released"].includes(t)?"success":n||t==="review"?"ready":"greeting"}export function characterChat(e={},r){const a=characterId(e.character);return{...e,character:a,...a?{botName:CHARACTERS[a].name}:{},characterOptions:normaliseCharacterSettings(r)}}export function chatCharacterState({busy:e=!1,error:r="",ended:a=!1,status:t="none",askDetails:n=!1,replied:i=!1}={}){return r||n?"help":e?"thinking":a||t==="message"?"success":i?"ready":"greeting"}