domma-cms 1.57.1 → 1.59.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.
@@ -1,4 +1,4 @@
1
- import{apiRequest as V,api as we}from"../api.js";import{CHARACTERS as Ve}from"../../../public/js/characters.mjs";import{addBannerAction as ye}from"../lib/plugin-chrome.js";import{helpPopovers as ke}from"../lib/help-popover.js";import{onceClosed as Ge,openMenuAt as Se,sidebarCount as Ce,viewLifetime as Je}from"../lib/tool-kit.js";import{rowPlaceKeeper as Qe}from"../lib/menu-drag.js";import{FILTERS as Ze,LAUNCHER_POSITION_LABEL as Te,arrangeLaunchers as ea,blankLauncher as aa,checkLauncherForm as ta,countLaunchers as la,duplicateLauncher as na,formFromLauncher as sa,launcherFromForm as oa,launcherRow as ia,moveItem as da,previewSpot as ra}from"../lib/launchers-arrange.js";import{LAUNCHER_LIMITS as o,LAUNCHER_TOKENS as G,launcherChatAccentCss as ca,launcherColourCss as $e,launcherHref as J}from"../../../public/js/launcher-settings.mjs";const Me=/^#\/launchers\/?(\?.*)?$/,Ee="#/launchers",Q="launchers.filter",U="launchers.draft",ha=`
1
+ import{apiRequest as V,api as ye}from"../api.js";import{CHARACTERS as Ge}from"../../../public/js/characters.mjs";import{addBannerAction as ke}from"../lib/plugin-chrome.js";import{helpPopovers as Se}from"../lib/help-popover.js";import{onceClosed as Je,openMenuAt as Ce,sidebarCount as Te,viewLifetime as Qe}from"../lib/tool-kit.js";import{rowPlaceKeeper as Ze}from"../lib/menu-drag.js";import{FILTERS as ea,LAUNCHER_POSITION_LABEL as $e,arrangeLaunchers as aa,blankLauncher as ta,checkLauncherForm as la,countLaunchers as na,duplicateLauncher as sa,formFromLauncher as ia,launcherFromForm as oa,launcherRow as da,moveItem as ra,previewSpot as ca}from"../lib/launchers-arrange.js";import{LAUNCHER_LIMITS as i,LAUNCHER_TOKENS as G,launcherChatAccentCss as ha,launcherColourCss as Me,launcherHref as J}from"../../../public/js/launcher-settings.mjs";const Ee=/^#\/launchers\/?(\?.*)?$/,Ae="#/launchers",Q="launchers.filter",D="launchers.draft",pa=`
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,19 +9,19 @@ import{apiRequest as V,api as we}from"../api.js";import{CHARACTERS as Ve}from"..
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>`,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"]],place:[["site","The site"],["admin","The admin"],["both","The site and the admin"]],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(s=>[s,s.charAt(0).toUpperCase()+s.slice(1)]),["custom","Custom hex\u2026"]],foreground:[["","Theme (reads on the background)"],...G.map(s=>[s,s.charAt(0).toUpperCase()+s.slice(1)]),["custom","Custom hex\u2026"]]},pa=["TL","TC","TR","ML","","MR","BL","BC","BR"],h=s=>s.map(([p,A])=>`<option value="${p}">${A}</option>`).join(""),Ae=s=>pa.map(p=>p?`<button type="button" data-pos="${p}" data-bind-class="${s}.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(""),ua=`
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"]],place:[["site","The site"],["admin","The admin"],["both","The site and the admin"]],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(s=>[s,s.charAt(0).toUpperCase()+s.slice(1)]),["custom","Custom hex\u2026"]],foreground:[["","Theme (reads on the background)"],...G.map(s=>[s,s.charAt(0).toUpperCase()+s.slice(1)]),["custom","Custom hex\u2026"]]},ua=["TL","TC","TR","ML","","MR","BL","BC","BR"],h=s=>s.map(([p,A])=>`<option value="${p}">${A}</option>`).join(""),Oe=s=>ua.map(p=>p?`<button type="button" data-pos="${p}" data-bind-class="${s}.value === '${p}' && 'is-on'" title="${$e[p]}" aria-label="${$e[p]}">${p}</button>`:'<button type="button" class="lnx-corner-mid" tabindex="-1" aria-hidden="true"></button>').join(""),ma=`
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="${o.nameMax}" data-model="name.value">
19
+ <input id="lnx-f-name" class="form-input" maxlength="${i.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="${o.labelMax}" data-model="label.value">
24
+ <input id="lnx-f-label" class="form-input" maxlength="${i.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">
@@ -30,12 +30,12 @@ import{apiRequest as V,api as we}from"../api.js";import{CHARACTERS as Ve}from"..
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="${o.tooltipMax}" placeholder="e.g. Questions? Ask us here" data-model="tooltip.value">
33
+ <input id="lnx-f-tip" class="form-input" maxlength="${i.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="${o.iconMax}" data-model="icon.value">
38
+ <input id="lnx-f-icon" class="form-input" maxlength="${i.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>
@@ -105,7 +105,7 @@ import{apiRequest as V,api as we}from"../api.js";import{CHARACTERS as Ve}from"..
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="${o.titleMax}" data-model="title.value">
108
+ <input id="lnx-f-title" class="form-input" maxlength="${i.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>
@@ -114,7 +114,7 @@ import{apiRequest as V,api as we}from"../api.js";import{CHARACTERS as Ve}from"..
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 === '%' ? ${o.widthPct[0]} : ${o.widthPx[0]}" data-bind-max="widthUnit.value === '%' ? ${o.widthPct[1]} : ${o.widthPx[1]}">
117
+ data-bind-min="widthUnit.value === '%' ? ${i.widthPct[0]} : ${i.widthPx[0]}" data-bind-max="widthUnit.value === '%' ? ${i.widthPct[1]} : ${i.widthPx[1]}">
118
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'">
@@ -124,7 +124,7 @@ import{apiRequest as V,api as we}from"../api.js";import{CHARACTERS as Ve}from"..
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' ? ${o.heightPx[0]} : ${o.heightVh[0]}" data-bind-max="heightUnit.value === 'px' ? ${o.heightPx[1]} : ${o.heightVh[1]}">
127
+ data-bind-min="heightUnit.value === 'px' ? ${i.heightPx[0]} : ${i.heightVh[0]}" data-bind-max="heightUnit.value === 'px' ? ${i.heightPx[1]} : ${i.heightVh[1]}">
128
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'">
@@ -139,18 +139,18 @@ import{apiRequest as V,api as we}from"../api.js";import{CHARACTERS as Ve}from"..
139
139
  <div class="lnx-grid2" data-bind-hidden="actionType.value !== 'chat'">
140
140
  <div class="lnx-field" style="grid-column: 1 / -1">
141
141
  <label class="form-label" for="lnx-f-character">Character</label>
142
- <select id="lnx-f-character" class="form-input" data-model="character.value"><option value="">No character</option>${Object.values(Ve).map(s=>`<option value="${s.id}">${s.name}</option>`).join("")}</select>
142
+ <select id="lnx-f-character" class="form-input" data-model="character.value"><option value="">No character</option>${Object.values(Ge).map(s=>`<option value="${s.id}">${s.name}</option>`).join("")}</select>
143
143
  <small>Use the character's name, portrait and animated poses. Site Settings controls visibility and motion. Your custom name and picture are kept when no character is selected.</small>
144
144
  <div data-bind-hidden="!character.value">
145
145
  <label class="form-label" for="lnx-f-charname">Display name <span data-help-title="Display name" data-help="Leave empty to use the character's own name. An optional name changes the chat name, while keeping the selected artwork."></span></label>
146
- <input id="lnx-f-charname" class="form-input" maxlength="${o.botNameMax}" placeholder="Character's own name" data-model="characterName.value">
146
+ <input id="lnx-f-charname" class="form-input" maxlength="${i.botNameMax}" placeholder="Character's own name" data-model="characterName.value">
147
147
  </div>
148
148
  <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>
149
- <textarea id="lnx-f-greeting" class="form-input" rows="2" maxlength="${o.greetingMax}" data-model="greeting.value"></textarea>
149
+ <textarea id="lnx-f-greeting" class="form-input" rows="2" maxlength="${i.greetingMax}" data-model="greeting.value"></textarea>
150
150
  </div>
151
151
  <div class="lnx-field">
152
152
  <label class="form-label" for="lnx-f-botname">Bot's name <span data-help="Shown on the bot's answers."></span></label>
153
- <input id="lnx-f-botname" data-bind-disabled="!!character.value" class="form-input" maxlength="${o.botNameMax}" data-model="botName.value">
153
+ <input id="lnx-f-botname" data-bind-disabled="!!character.value" class="form-input" maxlength="${i.botNameMax}" data-model="botName.value">
154
154
  </div>
155
155
  <div class="lnx-field">
156
156
  <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>
@@ -168,8 +168,8 @@ import{apiRequest as V,api as we}from"../api.js";import{CHARACTERS as Ve}from"..
168
168
  <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>
169
169
  <select id="lnx-f-chatsize" class="form-input" data-model="chatSize.value">${h(c.chatSize)}</select>
170
170
  <div class="lnx-grid2" data-bind-hidden="chatSize.value !== 'custom'">
171
- <input type="number" class="form-input" aria-label="Chat window width in pixels" min="${o.chatWidth[0]}" max="${o.chatWidth[1]}" data-model="chatWidth.value">
172
- <input type="number" class="form-input" aria-label="Chat window height in pixels" min="${o.chatHeight[0]}" max="${o.chatHeight[1]}" data-model="chatHeight.value">
171
+ <input type="number" class="form-input" aria-label="Chat window width in pixels" min="${i.chatWidth[0]}" max="${i.chatWidth[1]}" data-model="chatWidth.value">
172
+ <input type="number" class="form-input" aria-label="Chat window height in pixels" min="${i.chatHeight[0]}" max="${i.chatHeight[1]}" data-model="chatHeight.value">
173
173
  </div>
174
174
  <small class="lnx-err" data-bind-hidden="!err.value.chatWidth && !err.value.chatHeight" data-bind-text="err.value.chatWidth || err.value.chatHeight"></small>
175
175
  </div>
@@ -189,9 +189,9 @@ import{apiRequest as V,api as we}from"../api.js";import{CHARACTERS as Ve}from"..
189
189
  <small class="lnx-err" data-bind-hidden="!err.value.keepDays" data-bind-text="err.value.keepDays"></small>
190
190
  </div>
191
191
  <label class="lnx-check"><input type="checkbox" class="form-switch" data-model="chatResizable.value"> Visitors can resize the chat
192
- <span data-help="A grip in the corner away from the disc lets visitors drag the window bigger or smaller (between ${o.chatWidth[0]} x ${o.chatHeight[0]} and ${o.chatWidth[1]} x ${o.chatHeight[1]}). Their size is remembered in their browser; a double-click on the grip puts yours back."></span></label>
192
+ <span data-help="A grip in the corner away from the disc lets visitors drag the window bigger or smaller (between ${i.chatWidth[0]} x ${i.chatHeight[0]} and ${i.chatWidth[1]} x ${i.chatHeight[1]}). Their size is remembered in their browser; a double-click on the grip puts yours back."></span></label>
193
193
  <div class="lnx-field" style="grid-column: 1 / -1">
194
- <label class="form-label" for="lnx-f-starters">Questions to start with <span data-help="Up to ${o.startersMax}, one per line: buttons under the greeting that ask the question for the visitor. They go once the chat starts."></span></label>
194
+ <label class="form-label" for="lnx-f-starters">Questions to start with <span data-help="Up to ${i.startersMax}, one per line: buttons under the greeting that ask the question for the visitor. They go once the chat starts."></span></label>
195
195
  <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>
196
196
  <small class="lnx-err" data-bind-hidden="!err.value.starters" data-bind-text="err.value.starters"></small>
197
197
  </div>
@@ -215,13 +215,14 @@ import{apiRequest as V,api as we}from"../api.js";import{CHARACTERS as Ve}from"..
215
215
  <label class="lnx-check" data-bind-hidden="!bot.value"><input type="checkbox" class="form-switch" data-model="useKnowledge.value"> Answer from the Knowledge
216
216
  <span data-help-title="Answer from the Knowledge" data-help="On: the bot answers from your Knowledge entries (Chats > Knowledge) first, and the AI sees them too. Off: this chat ignores the Knowledge and only the AI answers, from the boxes below - for a chat about something else, such as help in the admin."></span></label>
217
217
  <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
218
- <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>
218
+ <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 AI Assist, in the Pro plan on hosted sites; without it the bot answers from the Knowledge alone."></span></label>
219
+ <small class="lnx-warn" style="grid-column: 1 / -1" data-bind-hidden="!bot.value || !ai.value || aiAssist.value">AI answers need AI Assist, in the Pro plan. Until this site has it, this chat answers from the Knowledge only.</small>
219
220
  <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
220
221
  <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>
221
222
  <div class="lnx-field" style="grid-column: 1 / -1" data-bind-hidden="!bot.value || !ai.value">
222
223
  <label class="form-label" for="lnx-f-aicontext">What the AI should know for this launcher
223
224
  <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>
224
- <textarea id="lnx-f-aicontext" class="form-input" rows="3" maxlength="${o.aiContextMax}" data-model="aiContext.value"
225
+ <textarea id="lnx-f-aicontext" class="form-input" rows="3" maxlength="${i.aiContextMax}" data-model="aiContext.value"
225
226
  placeholder="On the shop pages: we post to the UK only, orders before 2pm go the same day."></textarea>
226
227
  </div>
227
228
  <div class="lnx-field" data-bind-hidden="!bot.value || !ai.value">
@@ -231,7 +232,7 @@ import{apiRequest as V,api as we}from"../api.js";import{CHARACTERS as Ve}from"..
231
232
  <div class="lnx-field" style="grid-column: 1 / -1" data-bind-hidden="!bot.value || !ai.value">
232
233
  <label class="form-label" for="lnx-f-airules">Rules for this launcher
233
234
  <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>
234
- <textarea id="lnx-f-airules" class="form-input" rows="2" maxlength="${o.aiRulesMax}" data-model="aiRules.value"
235
+ <textarea id="lnx-f-airules" class="form-input" rows="2" maxlength="${i.aiRulesMax}" data-model="aiRules.value"
235
236
  placeholder="Only talk about orders and delivery. Never promise a delivery date."></textarea>
236
237
  </div>
237
238
  </div>
@@ -242,7 +243,7 @@ import{apiRequest as V,api as we}from"../api.js";import{CHARACTERS as Ve}from"..
242
243
  <div class="lnx-place">
243
244
  <div class="lnx-field">
244
245
  <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>
245
- <div class="lnx-corners lnx-corners-main" role="group" aria-label="Spot">${Ae("position")}</div>
246
+ <div class="lnx-corners lnx-corners-main" role="group" aria-label="Spot">${Oe("position")}</div>
246
247
  </div>
247
248
  <div class="lnx-previews">
248
249
  <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>
@@ -255,7 +256,7 @@ import{apiRequest as V,api as we}from"../api.js";import{CHARACTERS as Ve}from"..
255
256
  <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>
256
257
  <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>
257
258
  <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>
258
- <div class="lnx-range"><input type="range" min="${o.sizeMin}" max="${o.sizeMax}" data-model="size.value" aria-label="Size"><output data-bind-text="size.value"></output></div></div>
259
+ <div class="lnx-range"><input type="range" min="${i.sizeMin}" max="${i.sizeMax}" data-model="size.value" aria-label="Size"><output data-bind-text="size.value"></output></div></div>
259
260
  <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>
260
261
  <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>
261
262
  <div class="lnx-field">
@@ -268,7 +269,7 @@ import{apiRequest as V,api as we}from"../api.js";import{CHARACTERS as Ve}from"..
268
269
  <div class="lnx-place" data-bind-hidden="!phoneOverride.value || devices.value === 'desktop'">
269
270
  <div class="lnx-field">
270
271
  <span class="form-label">Spot on phones</span>
271
- <div class="lnx-corners lnx-corners-phone" role="group" aria-label="Spot on phones">${Ae("phonePosition")}</div>
272
+ <div class="lnx-corners lnx-corners-phone" role="group" aria-label="Spot on phones">${Oe("phonePosition")}</div>
272
273
  </div>
273
274
  <div class="lnx-grid2" style="flex:1">
274
275
  <div class="lnx-field"><label class="form-label">From the side</label>
@@ -276,7 +277,7 @@ import{apiRequest as V,api as we}from"../api.js";import{CHARACTERS as Ve}from"..
276
277
  <div class="lnx-field"><label class="form-label">From the top or bottom</label>
277
278
  <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>
278
279
  <div class="lnx-field"><label class="form-label">Size</label>
279
- <div class="lnx-range"><input type="range" min="${o.sizeMin}" max="${o.sizeMax}" data-model="phoneSize.value" aria-label="Size on phones"><output data-bind-text="phoneSize.value"></output></div></div>
280
+ <div class="lnx-range"><input type="range" min="${i.sizeMin}" max="${i.sizeMax}" data-model="phoneSize.value" aria-label="Size on phones"><output data-bind-text="phoneSize.value"></output></div></div>
280
281
  </div>
281
282
  </div>
282
283
  </div>
@@ -312,4 +313,4 @@ import{apiRequest as V,api as we}from"../api.js";import{CHARACTERS as Ve}from"..
312
313
  <button type="button" class="btn btn-sm btn-primary" data-on-click="save" data-bind-disabled="cannot.value">
313
314
  <span data-icon="check" data-icon-size="13"></span> <span data-bind-text="saveText"></span></button>
314
315
  </div>
315
- </div>`,Z=s=>String(s??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function ma(s){const p=document.createElement("template");return p.innerHTML=s.trim(),p.content.firstElementChild}const T=s=>s?G.includes(s)?s:"custom":"",x=Je(Me),ee={list:()=>V("/launchers/items",{method:"GET"}),save:s=>V("/launchers/items",{method:"PUT",body:JSON.stringify({launchers:s})}),patch:(s,p)=>V(`/launchers/items/${encodeURIComponent(s)}`,{method:"PATCH",body:JSON.stringify(p)})};export const launchersView={templateUrl:"/admin/js/templates/launchers.html",async onMount(s){x.reset();const p=s.get(0).querySelector(".lnx")||s.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=Ze.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=ea(u.value,{filter:$.value,query:W.value}).map(ia)}));const Oe=M.computed(()=>la(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([we.forms.list().catch(()=>[]),we.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 Ie(a){const t=u.peek(),l=t.findIndex(i=>i.id===a.id),m=na(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 Pe(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:()=>Ie(t)},{type:"divider"},{label:"Delete\u2026",icon:"trash",danger:!0,action:()=>Pe(t)}]:[]}let y=null;const j=new Set;function De(a,t,l){const m=a.close.bind(a);let i=!1,b=!1;return a.close=async r=>{if(!i&&r!==!0&&t()){if(b)return;b=!0;const N=await E.confirm(l);if(b=!1,!N)return}return i=!0,m()},()=>{i=!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(y){E.toast("Finish the launcher you have open first.",{type:"info"});return}const m=!l,i=sa(l||aa(u.peek()));t&&!Object.hasOwn(t,"character")&&typeof t.useDella=="boolean"&&(t={...t,character:t.useDella?"della":""});const b={...i,refPage:i.kind==="page"?i.ref:"",refForm:i.kind==="form"?i.ref:"",refBlock:i.kind==="block"?i.ref:"",bgChoice:T(i.background),bgHex:T(i.background)==="custom"?i.background:"",fgChoice:T(i.text),fgHex:T(i.text)==="custom"?i.text:"",accentChoice:T(i.accent),accentHex:T(i.accent)==="custom"?i.accent:"",accentTextChoice:T(i.accentText),accentTextHex:T(i.accentText)==="custom"?i.accentText:"",...t||{}};delete b.useDella,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]))),Y=M.computed(()=>ta(H())),R=M.observable(!1),he=(e,d)=>{const n=ra({...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(()=>Y.value.errors),warn:M.computed(()=>Y.value.warnings),cannot:M.computed(()=>R.value||Object.keys(Y.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=ca(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=ma(ua),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(D=>D.value===n)?[...d,{value:n,text:`${n} (missing)`}]:d;for(const D of C){const X=document.createElement("option");X.value=D.value,X.textContent=D.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=oa(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 je=ke(v),Ye=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};y=ge,j.add(k),Ge(k,()=>{Ye.dispose(),je(),We?.(),Ke?.(),qe?.(),Xe?.(),v.removeEventListener("click",xe),j.delete(k),y===ge&&(y=null)}),be=De(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=ha;const Ue=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(()=>Ue.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)},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&&z(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=Qe(),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:i})=>{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=da(u.peek(),m,i);u.value=b,P(b)}});x.add(()=>t.destroy())}ye(s,{id:"launchers-new",icon:"plus",title:"New launcher",onClick:()=>z()}),ye(s,{id:"launchers-chats",icon:"message-square",title:"Chats - the conversations from chat launchers",onClick:()=>{location.hash="#/launchers/chats"}});const ie=a=>{y?.dirty()&&(a.preventDefault(),a.returnValue="")};if(window.addEventListener("beforeunload",ie),x.add(()=>window.removeEventListener("beforeunload",ie)),x.add(()=>{if(y?.dirty())try{S.set(U,{id:y.id,values:y.values(),at:new Date().toISOString()})}catch{}[...j].forEach(a=>{try{a.close(!0)}catch{}})}),I.scan(p),await Le(),!A())return;let w=null;try{w=S.get(U)}catch{}if(w?.values){try{S.remove?S.remove(U):S.set(U,null)}catch{}const a=w.id&&O(w.id)?`your changes to "${Z(O(w.id).name)}"`:"the new launcher you started";await E.confirm(`You left ${a} unsaved. Pick up where you left off?`)&&A()&&z(w.id&&O(w.id)?w.id:null,w.values)}}};
316
+ </div>`,Z=s=>String(s??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function fa(s){const p=document.createElement("template");return p.innerHTML=s.trim(),p.content.firstElementChild}const T=s=>s?G.includes(s)?s:"custom":"",x=Qe(Ee),ee={list:()=>V("/launchers/items",{method:"GET"}),save:s=>V("/launchers/items",{method:"PUT",body:JSON.stringify({launchers:s})}),patch:(s,p)=>V(`/launchers/items/${encodeURIComponent(s)}`,{method:"PATCH",body:JSON.stringify(p)})};export const launchersView={templateUrl:"/admin/js/templates/launchers.html",async onMount(s){x.reset();const p=s.get(0).querySelector(".lnx")||s.get(0),A=()=>p.isConnected&&Ee.test(location.hash),u=M.observable([]),ae=M.observable(!0),F=M.observable(""),B=M.observable(!0);let te="all";try{te=ea.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=aa(u.value,{filter:$.value,query:W.value}).map(da)}));const ze=M.computed(()=>na(u.value)),Ne=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 ne=!0,L=null;const Ie=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:[],ne=a?.aiAssist===!0,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),Te(Ae),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),Te(Ae),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=sa(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 He(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 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 Ue(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:()=>Re(t)},{type:"divider"},{label:"Duplicate",icon:"copy",action:()=>Pe(t)},{type:"divider"},{label:"Delete\u2026",icon:"trash",danger:!0,action:()=>He(t)}]:[]}let y=null;const j=new Set;function De(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(y){E.toast("Finish the launcher you have open first.",{type:"info"});return}const m=!l,o=ia(l||ta(u.peek()));t&&!Object.hasOwn(t,"character")&&typeof t.useDella=="boolean"&&(t={...t,character:t.useDella?"della":""});const 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.useDella,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()])),re=e=>JSON.stringify(Object.fromEntries(Object.entries(e).map(([d,n])=>[d,typeof n=="boolean"?n:String(n??"")]))),We=re(b),ce=()=>re(N())!==We||!!t,he=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=()=>he(Object.fromEntries(Object.keys(r).map(e=>[e,r[e].value]))),Y=M.computed(()=>la(H())),R=M.observable(!1),pe=(e,d)=>{const n=ca({...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":Me(e.background)||"var(--dm-primary)","--lnx-fg":Me(e.text)||"var(--dm-primary-text)"}},ue={...r,saving:R,aiAssist:M.observable(ne),err:M.computed(()=>Y.value.errors),warn:M.computed(()=>Y.value.warnings),cannot:M.computed(()=>R.value||Object.keys(Y.value.errors).length>0),maxRadius:M.computed(()=>Math.floor(Number(r.size.value)/2)),previewStyle:M.computed(()=>pe(H(),!1)),phonePreviewStyle:M.computed(()=>pe(H(),!0)),botInitial:M.computed(()=>(String(r.botName.value||"").trim()[0]||"?").toUpperCase()),avatarPreview:M.computed(()=>{const e=ha(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)},Ke=M.effect(()=>{const e=Math.floor(Number(r.size.value)/2);Number(r.radius.peek())>e&&(r.radius.value=e)}),me=(e,d,n)=>{let f=e.peek();return M.effect(()=>{const C=e.value;C!==f&&(f=C,d.value=n(C))})},qe=me(r.widthUnit,r.customWidth,e=>e==="%"?90:900),je=me(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=fa(ma),fe=await Ie().catch(()=>({forms:[],blocks:[]})),be=(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)}};be(v.querySelector(".lnx-form-select"),fe.forms,b.refForm),be(v.querySelector(".lnx-block-select"),fe.blocks,b.refBlock);let ve=()=>{};async function xe(){if(!ue.cannot.peek()){R.value=!0;try{const e=oa(he(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;ve(),k.close()}finally{R.value=!1}}}k.element.appendChild(v);const Ye=Se(v),_e=M.applyBindings(ue,v,{methods:{save:xe,cancel:()=>k.close()}}),Xe=e=>{(e.ctrlKey||e.metaKey)&&e.key==="Enter"&&(e.preventDefault(),xe())};v.addEventListener("keydown",Xe);const ge=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",ge);const Ve=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)})}),we={id:l?.id??null,dirty:ce,values:N};y=we,j.add(k),Je(k,()=>{_e.dispose(),Ye(),Ke?.(),qe?.(),je?.(),Ve?.(),v.removeEventListener("click",ge),j.delete(k),y===we&&(y=null)}),ve=De(k,ce,"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=pa;const Fe=M.applyBindings({launchers:u,loading:ae,loadError:F,toolOn:B,filter:$,query:W,rows:K,counts:ze,emptyText:Ne,dragNote:le},p,{methods:{showAll:()=>{$.value="all"},showOn:()=>{$.value="on"},showOff:()=>{$.value="off"}}});x.add(()=>Fe.dispose()),x.add(Se(p,{position:"bottom"})),x.add(M.effect(()=>{K.value,requestAnimationFrame(()=>{p.isConnected&&I.scan(g)})}));const Be=E.contextMenu(g,{cursor:"glyph",match:".lnx-row",inherit:!1,density:"compact",items:a=>Ue(a.dataset.id)});x.add(()=>Be?.destroy?.());const se=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){Ce(l);return}z(t.dataset.id)},ie=a=>{const t=a.target.closest(".lnx-toggle"),l=t?.closest(".lnx-row"),m=l&&O(l.dataset.id);m&&q(m,t.checked)},oe=a=>{const t=a.target.closest(".lnx-row");t&&(a.key==="F10"&&a.shiftKey?(a.preventDefault(),Ce(t)):a.key==="Enter"&&a.target===t&&z(t.dataset.id))};if(g.addEventListener("click",se),g.addEventListener("change",ie),g.addEventListener("keydown",oe),x.add(()=>{g.removeEventListener("click",se),g.removeEventListener("change",ie),g.removeEventListener("keydown",oe)}),typeof E.sortable=="function"){const a=Ze(),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=ra(u.peek(),m,o);u.value=b,P(b)}});x.add(()=>t.destroy())}ke(s,{id:"launchers-new",icon:"plus",title:"New launcher",onClick:()=>z()}),ke(s,{id:"launchers-chats",icon:"message-square",title:"Chats - the conversations from chat launchers",onClick:()=>{location.hash="#/launchers/chats"}});const de=a=>{y?.dirty()&&(a.preventDefault(),a.returnValue="")};if(window.addEventListener("beforeunload",de),x.add(()=>window.removeEventListener("beforeunload",de)),x.add(()=>{if(y?.dirty())try{S.set(D,{id:y.id,values:y.values(),at:new Date().toISOString()})}catch{}[...j].forEach(a=>{try{a.close(!0)}catch{}})}),I.scan(p),await Le(),!A())return;let w=null;try{w=S.get(D)}catch{}if(w?.values){try{S.remove?S.remove(D):S.set(D,null)}catch{}const a=w.id&&O(w.id)?`your changes to "${Z(O(w.id).name)}"`:"the new launcher you started";await E.confirm(`You left ${a} unsaved. Pick up where you left off?`)&&A()&&z(w.id&&O(w.id)?w.id:null,w.values)}}};
@@ -1,4 +1,4 @@
1
- import{api as k,apiRequest as f}from"../api.js";import{addBannerAction as B}from"../lib/plugin-chrome.js";import{SHAPES as $e,whileLoading as Pe}from"../lib/loading.js";import{helpPopovers as oe}from"../lib/help-popover.js";import{onceClosed as Ie,openMenuAt as ie,sidebarCount as Oe,viewLifetime as qe}from"../lib/tool-kit.js";import{DEFAULT_SETTINGS as re,FILTERS as A,arrangeNotifications as Ue,filterCounts as _e,normaliseSettings as Be,notificationRow as ce,sourceRow as Fe}from"../lib/notifications-arrange.js";import{desktopPermission as le,notificationSettings as de,primeSeen as We,requestDesktopPermission as He,showTestNotification as je}from"../lib/desktop-notify.js";const ue=/^#\/system\/notifications\/?(\?.*)?$/,Ge="#/system/notifications",F="notifications.filter",Ke=`
1
+ import{api as k,apiRequest as f}from"../api.js";import{addBannerAction as B}from"../lib/plugin-chrome.js";import{SHAPES as $e,whileLoading as Ie}from"../lib/loading.js";import{helpPopovers as oe}from"../lib/help-popover.js";import{onceClosed as Pe,openMenuAt as ie,sidebarCount as Oe,viewLifetime as qe}from"../lib/tool-kit.js";import{DEFAULT_SETTINGS as re,FILTERS as L,arrangeNotifications as Ue,filterCounts as _e,normaliseSettings as Be,notificationRow as le,sourceRow as We}from"../lib/notifications-arrange.js";import{desktopPermission as ce,notificationSettings as de,primeSeen as Fe,requestDesktopPermission as He,showTestNotification as je}from"../lib/desktop-notify.js";const pe=/^#\/system\/notifications\/?(\?.*)?$/,Ge="#/system/notifications",W="notifications.filter",Ke=`
2
2
  <div class="ntx-row" data-id="{{id}}" tabindex="0" data-bind-class="rowCls" data-bind-aria-expanded="open ? 'true' : 'false'">
3
3
  <span class="ntx-dot" aria-hidden="true"></span>
4
4
  <span class="ntx-main">
@@ -29,9 +29,9 @@ import{api as k,apiRequest as f}from"../api.js";import{addBannerAction as B}from
29
29
  <button type="button" class="btn btn-sm btn-ghost ntx-src-run" data-bind-hidden="!every">Run now</button>
30
30
  </div>
31
31
  <small class="ntx-src-err" data-bind-hidden="!lastError">{{lastError}}</small>
32
- </div>`,R={granted:"Allowed in this browser.",default:"Your browser will ask for permission when you turn this on.",denied:"Blocked in this browser. Allow notifications for this site in the browser's site settings (the icon by the address), then turn this on.",unsupported:"This browser cannot show desktop notifications here - they need a current browser and an https address."};function Je(r){const c=document.createElement("template");return c.innerHTML=r.trim(),c.content.firstElementChild}const d=qe(ue);async function b(){Oe(Ge);try{const{count:r}=await k.system.notifications.unreadCount(),c=$("#topbar-bell-badge");r>0?c.text(r>99?"99+":String(r)).removeAttr("hidden"):c.attr("hidden","").text("")}catch{}}export const notificationsView={templateUrl:"/admin/js/templates/notifications.html",async onMount(r){d.reset();const c=r.get(0).querySelector(".ntx")||r.get(0),y=()=>ue.test(location.hash)&&c.isConnected,i=M.observable([]),T=M.observable(!0),N=M.observable("");let W="all";try{W=A.includes(S.get(F))?S.get(F):"all"}catch{}const C=()=>new URLSearchParams(location.hash.split("?")[1]||"").get("type"),m=M.observable(A.includes(C())?C():W),H=()=>{y()&&A.includes(C())&&(m.value=C())},j=e=>{y()&&A.includes(e.detail?.type)&&(m.value=e.detail.type)};document.addEventListener("dm:notifications-filter",j),d.add(()=>document.removeEventListener("dm:notifications-filter",j)),window.addEventListener("hashchange",H),d.add(()=>window.removeEventListener("hashchange",H));const G=()=>{y()&&x({markRead:!1})};document.addEventListener("dm:notifications-changed",G),d.add(()=>document.removeEventListener("dm:notifications-changed",G));const K=M.observable(""),L=M.observable("");d.add(M.effect(()=>{const e=m.value;try{S.set(F,e)}catch{}}));const Y=M.computed(()=>_e(i.value));d.add(M.effect(()=>{const e=Y.value;!T.value&&m.peek()==="new"&&!e.new&&(m.value="all")}));const z=M.observable([]);d.add(M.effect(()=>{const e=Date.now(),t=L.value;z.value=Ue(i.value,{filter:m.value,query:K.value}).map(n=>ce(n,{now:e,expanded:t}))}));const pe=M.computed(()=>i.value.length?"No notifications match.":"No notifications - you're all caught up."),u=M.observable(de.read());d.add(M.effect(()=>de.write(u.value)));const D=(e,t)=>{u.value=Be({...u.peek(),[e]:t})},J=e=>i.peek().find(t=>String(t.id)===String(e)),me=(e,t)=>{i.value=i.peek().map(n=>String(n.id)===String(e)?t(n):n)},V=e=>{i.value=i.peek().filter(t=>String(t.id)!==String(e))};async function x({markRead:e=!0}={}){try{const t=i.peek().length?null:c.querySelector(".dm-loading-slot"),n=await Pe(t,k.system.notifications.list(),$e.iconRows);if(!y())return;const p=Array.isArray(n)?n:[];if(i.value=p.map(l=>({...l,isNew:!!l.unread})),N.value="",e&&p.some(l=>l.unread)){if(await f("/system/notifications/read-all",{method:"POST"}).catch(()=>{}),!y())return;i.value=i.peek().map(l=>({...l,unread:!1})),b()}}catch(t){N.value=`Could not load notifications: ${t.message||t}`}finally{T.value=!1}}async function X(e,t){try{t?await k.system.notifications.markRead(e.id):await f(`/system/notifications/${encodeURIComponent(e.id)}/unread`,{method:"POST"}),me(e.id,n=>({...n,unread:!t})),b()}catch(n){E.toast(`Not changed: ${n.message||n}`,{type:"error"})}}async function Q(e){try{await k.system.notifications.dismiss(e.id),V(e.id),b()}catch(t){E.toast(`Could not dismiss it: ${t.message||t}`,{type:"error"})}}async function he(e){if(await E.confirm(`Delete "${Ye(e.data?.title||"this notification")}" for everyone? Dismissing hides it for you only.`))try{await k.system.notifications.remove(e.id),V(e.id),E.toast("Notification deleted.",{type:"success"}),b()}catch(t){E.toast(/403|forbidden|permission/i.test(String(t.message||t))?"Deleting needs the Notifications delete permission - Dismiss hides it for you.":`Could not delete it: ${t.message||t}`,{type:"error"})}}async function fe(){const e=i.peek().length;if(!e){E.toast("Nothing to dismiss.",{type:"info"});return}if(await E.confirm(`Dismiss all ${e} notification${e===1?"":"s"}? They are hidden for you only.`))try{await f("/system/notifications/dismiss-all",{method:"POST"}),i.value=[],b()}catch(t){E.toast(`Could not dismiss them: ${t.message||t}`,{type:"error"})}}async function be(e){const t=e.data||{},n=[t.title,t.body,t.link].filter(Boolean).join(`
32
+ </div>`,R={granted:"Allowed in this browser.",default:"Your browser will ask for permission when you turn this on.",denied:"Blocked in this browser. Allow notifications for this site in the browser's site settings (the icon by the address), then turn this on.",unsupported:"This browser cannot show desktop notifications here - they need a current browser and an https address."};function Je(r){const l=document.createElement("template");return l.innerHTML=r.trim(),l.content.firstElementChild}const d=qe(pe);async function b(){Oe(Ge);try{const{count:r}=await k.system.notifications.unreadCount(),l=$("#topbar-bell-badge");r>0?l.text(r>99?"99+":String(r)).removeAttr("hidden"):l.attr("hidden","").text("")}catch{}}export const notificationsView={templateUrl:"/admin/js/templates/notifications.html",async onMount(r){d.reset();const l=r.get(0).querySelector(".ntx")||r.get(0),y=()=>pe.test(location.hash)&&l.isConnected,i=M.observable([]),T=M.observable(!0),N=M.observable("");let F="all";try{F=L.includes(S.get(W))?S.get(W):"all"}catch{}const C=()=>new URLSearchParams(location.hash.split("?")[1]||"").get("type"),h=M.observable(L.includes(C())?C():F),H=()=>{y()&&L.includes(C())&&(h.value=C())},j=e=>{y()&&L.includes(e.detail?.type)&&(h.value=e.detail.type)};document.addEventListener("dm:notifications-filter",j),d.add(()=>document.removeEventListener("dm:notifications-filter",j)),window.addEventListener("hashchange",H),d.add(()=>window.removeEventListener("hashchange",H));const G=()=>{y()&&x({markRead:!1})};document.addEventListener("dm:notifications-changed",G),d.add(()=>document.removeEventListener("dm:notifications-changed",G));const K=M.observable(""),A=M.observable("");d.add(M.effect(()=>{const e=h.value;try{S.set(W,e)}catch{}}));const Y=M.computed(()=>_e(i.value));d.add(M.effect(()=>{const e=Y.value;!T.value&&h.peek()==="new"&&!e.new&&(h.value="all")}));const z=M.observable([]);d.add(M.effect(()=>{const e=Date.now(),t=A.value;z.value=Ue(i.value,{filter:h.value,query:K.value}).map(n=>le(n,{now:e,expanded:t}))}));const ue=M.computed(()=>i.value.length?"No notifications match.":"No notifications - you're all caught up."),p=M.observable(de.read());d.add(M.effect(()=>de.write(p.value)));const D=(e,t)=>{p.value=Be({...p.peek(),[e]:t})},J=e=>i.peek().find(t=>String(t.id)===String(e)),he=(e,t)=>{i.value=i.peek().map(n=>String(n.id)===String(e)?t(n):n)},V=e=>{i.value=i.peek().filter(t=>String(t.id)!==String(e))};async function x({markRead:e=!0}={}){try{const t=i.peek().length?null:l.querySelector(".dm-loading-slot"),n=await Ie(t,k.system.notifications.list(),$e.iconRows);if(!y())return;const u=Array.isArray(n)?n:[];if(i.value=u.map(c=>({...c,isNew:!!c.unread})),N.value="",e&&u.some(c=>c.unread)){if(await f("/system/notifications/read-all",{method:"POST"}).catch(()=>{}),!y())return;i.value=i.peek().map(c=>({...c,unread:!1})),b()}}catch(t){N.value=`Could not load notifications: ${t.message||t}`}finally{T.value=!1}}async function X(e,t){try{t?await k.system.notifications.markRead(e.id):await f(`/system/notifications/${encodeURIComponent(e.id)}/unread`,{method:"POST"}),he(e.id,n=>({...n,unread:!t})),b()}catch(n){E.toast(`Not changed: ${n.message||n}`,{type:"error"})}}async function Q(e){try{await k.system.notifications.dismiss(e.id),V(e.id),b()}catch(t){E.toast(`Could not dismiss it: ${t.message||t}`,{type:"error"})}}async function me(e){if(await E.confirm(`Delete "${Ye(e.data?.title||"this notification")}" for everyone? Dismissing hides it for you only.`))try{await k.system.notifications.remove(e.id),V(e.id),E.toast("Notification deleted.",{type:"success"}),b()}catch(t){E.toast(/403|forbidden|permission/i.test(String(t.message||t))?"Deleting needs the Notifications delete permission - Dismiss hides it for you.":`Could not delete it: ${t.message||t}`,{type:"error"})}}async function fe(){const e=i.peek().length;if(!e){E.toast("Nothing to dismiss.",{type:"info"});return}if(await E.confirm(`Dismiss all ${e} notification${e===1?"":"s"}? They are hidden for you only.`))try{await f("/system/notifications/dismiss-all",{method:"POST"}),i.value=[],b()}catch(t){E.toast(`Could not dismiss them: ${t.message||t}`,{type:"error"})}}async function be(e){const t=e.data||{},n=[t.title,t.body,t.link].filter(Boolean).join(`
33
33
 
34
- `);try{await navigator.clipboard.writeText(n),E.toast("Copied.",{type:"success"})}catch{E.toast("Copying is blocked here - select the text instead.",{type:"warning"})}}const P=e=>{L.value=L.peek()===String(e)?"":String(e)};function ye(e){const t=J(e);if(!t)return[];const n=ce(t);return[{header:n.title},{label:n.open||L.peek()===n.id?"Close":"Read it",icon:"eye",action:()=>P(e)},...n.link?[n.linkTarget==="_self"?{label:"Go there",icon:"arrow-right",action:()=>{location.hash=n.link}}:{label:"Open link",icon:"external-link",action:()=>window.open(n.link,"_blank","noopener")}]:[],{label:"Copy text",icon:"copy",action:()=>be(t)},t.unread?{label:"Mark as read",icon:"check",action:()=>X(t,!0)}:{label:"Mark as unread",icon:"mail",action:()=>X(t,!1)},{type:"divider"},{label:"Dismiss",icon:"x",action:()=>Q(t)},{label:"Delete for everyone\u2026",icon:"trash",danger:!0,action:()=>he(t)}]}const v=c.querySelector(".ntx-list");v.innerHTML=Ke;const g=e=>()=>{m.value=e},ve=M.applyBindings({items:i,loading:T,loadError:N,filter:m,query:K,rows:z,counts:Y,emptyText:pe},c,{methods:{showAll:g("all"),showNew:g("new"),showCritical:g("critical"),showWarning:g("warning"),showInfo:g("info"),showSuccess:g("success")}});d.add(()=>ve.dispose()),d.add(oe(c,{position:"bottom"}));const ge=E.contextMenu(v,{cursor:"glyph",match:".ntx-row",inherit:!1,density:"compact",items:e=>ye(e.dataset.id)});d.add(()=>ge?.destroy?.());const Z=e=>{const t=e.target.closest(".ntx-row");if(!t)return;const n=e.target.closest(".ntx-kebab");if(n){ie(n);return}e.target.closest("a")||P(t.dataset.id)},ee=e=>{const t=e.target.closest(".ntx-row");if(t){if(e.key==="F10"&&e.shiftKey)e.preventDefault(),ie(t);else if(e.key==="Enter"&&e.target===t)P(t.dataset.id);else if(e.key==="Delete"&&e.target===t){const n=J(t.dataset.id);n&&Q(n)}}};v.addEventListener("click",Z),v.addEventListener("keydown",ee),d.add(()=>{v.removeEventListener("click",Z),v.removeEventListener("keydown",ee)});async function we(){try{const{added:e}=await f("/system/notifications/samples",{method:"POST"});await x({markRead:!1}),b(),E.toast(`${e} sample notifications added.${u.peek().desktop?" They pop up on the desktop within a minute.":""}`,{type:"success"})}catch(e){E.toast(/403|forbidden|permission/i.test(String(e.message||e))?"Adding samples needs the Notifications delete permission.":`Could not add samples: ${e.message||e}`,{type:"error"})}}function ke(){const e=E.slideover({title:"Notifications settings",size:"md",position:"right"}),t=Je(`
34
+ `);try{await navigator.clipboard.writeText(n),E.toast("Copied.",{type:"success"})}catch{E.toast("Copying is blocked here - select the text instead.",{type:"warning"})}}const P=e=>{A.value=A.peek()===String(e)?"":String(e)};function ye(e){const t=J(e);if(!t)return[];const n=le(t);return[{header:n.title},{label:n.open||A.peek()===n.id?"Close":"Read it",icon:"eye",action:()=>P(e)},...n.link?[n.linkTarget==="_self"?{label:"Go there",icon:"arrow-right",action:()=>{location.hash=n.link}}:{label:"Open link",icon:"external-link",action:()=>window.open(n.link,"_blank","noopener")}]:[],{label:"Copy text",icon:"copy",action:()=>be(t)},t.unread?{label:"Mark as read",icon:"check",action:()=>X(t,!0)}:{label:"Mark as unread",icon:"mail",action:()=>X(t,!1)},{type:"divider"},{label:"Dismiss",icon:"x",action:()=>Q(t)},{label:"Delete for everyone\u2026",icon:"trash",danger:!0,action:()=>me(t)}]}const v=l.querySelector(".ntx-list");v.innerHTML=Ke;const g=e=>()=>{h.value=e},ve=M.applyBindings({items:i,loading:T,loadError:N,filter:h,query:K,rows:z,counts:Y,emptyText:ue},l,{methods:{showAll:g("all"),showNew:g("new"),showCritical:g("critical"),showWarning:g("warning"),showInfo:g("info"),showSuccess:g("success")}});d.add(()=>ve.dispose()),d.add(oe(l,{position:"bottom"}));const ge=E.contextMenu(v,{cursor:"glyph",match:".ntx-row",inherit:!1,density:"compact",items:e=>ye(e.dataset.id)});d.add(()=>ge?.destroy?.());const Z=e=>{const t=e.target.closest(".ntx-row");if(!t)return;const n=e.target.closest(".ntx-kebab");if(n){ie(n);return}e.target.closest("a")||P(t.dataset.id)},ee=e=>{const t=e.target.closest(".ntx-row");if(t){if(e.key==="F10"&&e.shiftKey)e.preventDefault(),ie(t);else if(e.key==="Enter"&&e.target===t)P(t.dataset.id);else if(e.key==="Delete"&&e.target===t){const n=J(t.dataset.id);n&&Q(n)}}};v.addEventListener("click",Z),v.addEventListener("keydown",ee),d.add(()=>{v.removeEventListener("click",Z),v.removeEventListener("keydown",ee)});async function we(){try{const{added:e}=await f("/system/notifications/samples",{method:"POST"});await x({markRead:!1}),b(),E.toast(`${e} sample notifications added.${p.peek().desktop?" They pop up on the desktop within a minute.":""}`,{type:"success"})}catch(e){E.toast(/403|forbidden|permission/i.test(String(e.message||e))?"Adding samples needs the Notifications delete permission.":`Could not add samples: ${e.message||e}`,{type:"error"})}}function ke(){const e=E.slideover({title:"Notifications settings",size:"md",position:"right"}),t=Je(`
35
35
  <div class="ntx-panel">
36
36
  <div class="ntx-setting-row">
37
37
  <label class="form-label" for="ntx-set-desktop" style="margin:0">Desktop notifications
@@ -59,6 +59,12 @@ import{api as k,apiRequest as f}from"../api.js";import{addBannerAction as B}from
59
59
  </label>
60
60
  <input id="ntx-set-toasts" type="checkbox" class="form-switch" data-model="signInToasts.value">
61
61
  </div>
62
+ <div class="ntx-setting-row">
63
+ <label class="form-label" for="ntx-set-chat-toasts" style="margin:0">Chat pop-ups
64
+ <span data-help="While the admin is open, a message pops up when a visitor starts a chat, asks for a person or leaves a message, or when the AI turns a question down - with a button to open Chats. Checked every 30 seconds. Asking for a person stays until you close it."></span>
65
+ </label>
66
+ <input id="ntx-set-chat-toasts" type="checkbox" class="form-switch" data-model="chatToasts.value">
67
+ </div>
62
68
  <small class="ntx-panel-meta">Saved in this browser as you change them.</small>
63
69
  <div class="ntx-setting-row">
64
70
  <label class="form-label" style="margin:0">Sample notifications
@@ -78,4 +84,4 @@ import{api as k,apiRequest as f}from"../api.js";import{addBannerAction as B}from
78
84
  <span class="spacer"></span>
79
85
  <button type="button" class="btn btn-sm btn-primary" data-on-click="done">Done</button>
80
86
  </div>
81
- </div>`),n=t.querySelector("#ntx-set-desktop"),p=t.querySelector(".ntx-src-list");p.innerHTML=ze;const l=M.observable([]),O=M.observable([]),q=M.observable(!1),xe=M.effect(()=>{O.value=l.value.map(s=>Fe(s))}),Se=M.effect(()=>{const s=O.value;setTimeout(()=>s.forEach(a=>{const o=p.querySelector(`.ntx-src[data-id="${CSS.escape(a.id)}"] .ntx-src-aud`);o&&(o.value=a.audience)}),0)}),U=s=>{l.value=l.peek().map(a=>a.id===s.id?s:a)},te=s=>`/system/notifications/sources/${encodeURIComponent(s)}`;f("/system/notifications/sources",{method:"GET"}).then(s=>{l.value=s.sources||[],q.value=!0}).catch(()=>{q.value=!1});async function se(s,a){const o=l.peek().find(w=>w.id===s);try{const{setting:w}=await f(te(s),{method:"PUT",body:JSON.stringify(a)});U({...o,...w})}catch(w){U({...o}),E.toast(`Not saved: ${w.message||w}`,{type:"error"})}}async function Ee(s,a){a.disabled=!0;try{const o=await f(`${te(s)}/run`,{method:"POST"});o.source&&U(o.source),E.toast(o.ok?"Done - anything it found is in the list.":`It failed: ${o.error}`,{type:o.ok?"success":"error"}),await x({markRead:!1}),b()}catch(o){E.toast(`Could not run it: ${o.message||o}`,{type:"error"})}finally{a.disabled=!1}}const ne=s=>{const a=s.target.closest(".ntx-src");a&&(s.target.matches(".ntx-src-on")?se(a.dataset.id,{enabled:s.target.checked}):s.target.matches(".ntx-src-aud")&&se(a.dataset.id,{audience:s.target.value}))},ae=s=>{const a=s.target.closest(".ntx-src-run");a&&Ee(a.closest(".ntx-src").dataset.id,a)};p.addEventListener("change",ne),p.addEventListener("click",ae);const h=M.observable(le()),Te=M.computed(()=>u.value.desktop&&h.value!=="granted"?`On, but not showing: ${R[h.value]}`:R[h.value]),Me=M.computed(()=>h.value==="denied"||h.value==="unsupported"?"is-bad":""),Ce=M.computed(()=>u.value.desktop&&h.value==="granted"),_=()=>{n.checked=u.peek().desktop};function Le(){const s=le();if(s==="unsupported"||s==="denied"){h.value=s,E.toast(R[s],{type:"warning"}),_();return}(s==="granted"?Promise.resolve("granted"):He()).then(async o=>{h.value=o,o==="granted"?(We(await k.system.notifications.list().catch(()=>[])),D("desktop",!0),E.toast("Desktop notifications are on for this browser.",{type:"success"})):E.toast(o==="denied"?R.denied:"Not turned on - the browser was not given permission.",{type:"warning"}),_()})}const Ae=s=>M.computed({read:()=>u.value[s],write:a=>D(s,a)}),Re={...Object.fromEntries(Object.keys(re).map(s=>[s,Ae(s)])),desktop:M.computed({read:()=>u.value.desktop,write:s=>s?Le():D("desktop",!1)}),permText:Te,permTone:Me,canTest:Ce,sourceRows:O,sourcesShown:q};e.element.appendChild(t);const Ne=oe(t),De=M.applyBindings(Re,t,{methods:{done:()=>e.close(),reset:()=>{u.value={...re},_()},samples:()=>{we()},test:()=>{je()||E.toast("The browser would not show it - check its notification settings.",{type:"warning"})}}});Ie(e,()=>{De.dispose(),Ne(),xe(),Se(),p.removeEventListener("change",ne),p.removeEventListener("click",ae)}),e.open()}B(r,{id:"notifications-settings",icon:"settings",title:"Notifications settings",onClick:ke}),B(r,{id:"notifications-dismiss-all",icon:"check-circle",title:"Dismiss all",onClick:()=>fe()}),B(r,{id:"notifications-refresh",icon:"refresh-cw",title:"Refresh",onClick:()=>{T.value=!0,x()}}),I.scan(c),await x(),y()&&I.scan(c)}};
87
+ </div>`),n=t.querySelector("#ntx-set-desktop"),u=t.querySelector(".ntx-src-list");u.innerHTML=ze;const c=M.observable([]),O=M.observable([]),q=M.observable(!1),xe=M.effect(()=>{O.value=c.value.map(s=>We(s))}),Se=M.effect(()=>{const s=O.value;setTimeout(()=>s.forEach(a=>{const o=u.querySelector(`.ntx-src[data-id="${CSS.escape(a.id)}"] .ntx-src-aud`);o&&(o.value=a.audience)}),0)}),U=s=>{c.value=c.peek().map(a=>a.id===s.id?s:a)},te=s=>`/system/notifications/sources/${encodeURIComponent(s)}`;f("/system/notifications/sources",{method:"GET"}).then(s=>{c.value=s.sources||[],q.value=!0}).catch(()=>{q.value=!1});async function se(s,a){const o=c.peek().find(w=>w.id===s);try{const{setting:w}=await f(te(s),{method:"PUT",body:JSON.stringify(a)});U({...o,...w})}catch(w){U({...o}),E.toast(`Not saved: ${w.message||w}`,{type:"error"})}}async function Ee(s,a){a.disabled=!0;try{const o=await f(`${te(s)}/run`,{method:"POST"});o.source&&U(o.source),E.toast(o.ok?"Done - anything it found is in the list.":`It failed: ${o.error}`,{type:o.ok?"success":"error"}),await x({markRead:!1}),b()}catch(o){E.toast(`Could not run it: ${o.message||o}`,{type:"error"})}finally{a.disabled=!1}}const ne=s=>{const a=s.target.closest(".ntx-src");a&&(s.target.matches(".ntx-src-on")?se(a.dataset.id,{enabled:s.target.checked}):s.target.matches(".ntx-src-aud")&&se(a.dataset.id,{audience:s.target.value}))},ae=s=>{const a=s.target.closest(".ntx-src-run");a&&Ee(a.closest(".ntx-src").dataset.id,a)};u.addEventListener("change",ne),u.addEventListener("click",ae);const m=M.observable(ce()),Te=M.computed(()=>p.value.desktop&&m.value!=="granted"?`On, but not showing: ${R[m.value]}`:R[m.value]),Ce=M.computed(()=>m.value==="denied"||m.value==="unsupported"?"is-bad":""),Me=M.computed(()=>p.value.desktop&&m.value==="granted"),_=()=>{n.checked=p.peek().desktop};function Ae(){const s=ce();if(s==="unsupported"||s==="denied"){m.value=s,E.toast(R[s],{type:"warning"}),_();return}(s==="granted"?Promise.resolve("granted"):He()).then(async o=>{m.value=o,o==="granted"?(Fe(await k.system.notifications.list().catch(()=>[])),D("desktop",!0),E.toast("Desktop notifications are on for this browser.",{type:"success"})):E.toast(o==="denied"?R.denied:"Not turned on - the browser was not given permission.",{type:"warning"}),_()})}const Le=s=>M.computed({read:()=>p.value[s],write:a=>D(s,a)}),Re={...Object.fromEntries(Object.keys(re).map(s=>[s,Le(s)])),desktop:M.computed({read:()=>p.value.desktop,write:s=>s?Ae():D("desktop",!1)}),permText:Te,permTone:Ce,canTest:Me,sourceRows:O,sourcesShown:q};e.element.appendChild(t);const Ne=oe(t),De=M.applyBindings(Re,t,{methods:{done:()=>e.close(),reset:()=>{p.value={...re},_()},samples:()=>{we()},test:()=>{je()||E.toast("The browser would not show it - check its notification settings.",{type:"warning"})}}});Pe(e,()=>{De.dispose(),Ne(),xe(),Se(),u.removeEventListener("change",ne),u.removeEventListener("click",ae)}),e.open()}B(r,{id:"notifications-settings",icon:"settings",title:"Notifications settings",onClick:ke}),B(r,{id:"notifications-dismiss-all",icon:"check-circle",title:"Dismiss all",onClick:()=>fe()}),B(r,{id:"notifications-refresh",icon:"refresh-cw",title:"Refresh",onClick:()=>{T.value=!0,x()}}),I.scan(l),await x(),y()&&I.scan(l)}};
@@ -1237,9 +1237,10 @@ The four Tools below were plugins until 0.67.0 and are now part of the CMS. They
1237
1237
  - The bot (`server/services/chat/matcher.js`, pure): normalises text (accents, contractions, punctuation), drops stop words, stems lightly (bookings/booked/booking -> book), folds synonym groups onto one word (cost/fee/charge -> price, open/hours/close, delivery/shipping/postage, ...), forgives a one-edit typo in words of five letters or more, and weights words by rarity across the Knowledge. A phrasing's score blends how much of the question it covers with how much of the phrasing the question covers, plus a bonus when one contains the other and a nudge per keyword. `answer` (one clear winner over a margin), `suggest` (top three "Did you mean", plus None of these), or `none` (logged as unanswered; after two misses in a row it offers a person). Handover phrases ("talk to a person", "real human", "customer service"), greetings and thanks are recognised first. Confidence Strict / Balanced / Relaxed in the settings cog.
1238
1238
  - Storage: four presets - `chat-knowledge`, `chat-sessions`, `chat-messages`, `chat-unanswered` (`CHAT_PRESET_SLUGS`) - declared MongoDB and resolved like the user-data presets (`MONGO_ELIGIBLE_PRESET_SLUGS`, adapterRegistry `resolveUserDataPreset`): MongoDB where the site has a working connection and the files hold none of their rows, files otherwise; the storage block survives the reseed. Through the generic collections API, views, forms and endpoints they need `chats.manage` (collectionAccess `CORE_TOOL_COLLECTIONS`). Four example Knowledge entries (marked `sample`, removable in one click) are added once per site (`config/chat.json` `examplesSeeded`).
1239
1239
  - Visitor API `/api/chat/*` (`config`, `state` poll, `send`, `pick`, `person`, `details`, `end`): 404 unless `launcher` names an enabled chat launcher (`services/chat/launcher-bridge.js` asks `services/launchers.js` `chatLaunchers()`; the launcher's chat settings are always read server-side). The chat is the visitor's by a random 256-bit token in the `X-Chat-Token` header (only its SHA-256 is stored; kept in the browser as `chat:<launcherId>`); resumable for a day, two weeks after leaving a message. Plain text, 1000 characters, 300 messages a chat; per-route rate limits; per address 6 new chats and 120 messages an hour, and `maxNewChatsPerHour` (300) new chats for the whole site; a honeypot, a missing `_t` or a first message within 1.5s is dropped quietly; details only where the launcher asks and the chat was offered the form (else 403); a bot answer is stored as its Knowledge id plus a 200-character snapshot; messages are numbered within the chat and choices offered by position, so no internal id reaches the browser. Answers render through a strict sanitiser (paragraphs, lists, emphasis, code, http(s)/mailto/tel/site-path links).
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.
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); a visitor's first message notifies admins too (`core:chat-started`, one per chat), and so does a question the AI turned down (`core:chat-declined`, one per chat, said again in place: the Manager's launcher-chat answer carries `declined: true` when Claude's reply starts `DECLINED:`, which it strips); open admins get these as toasts with an Open Chats button (lib/chat-toast.js: the bell's poll, now every 30s, fetches the list when the unread count rises; per-browser "Chat pop-ups" setting, on by default; "wants a person" stays until closed); 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
+ - AI Assist (unreleased): the paid `ai-assist` Tool (Pro plan) calls `hooks.enableAiAssist()` (`services/aiAssist.js`, paid + closedSource only, off when the Tool is disabled). Without it `aiAvailable()` is false (chat config says `ai: false`, nothing is asked) and the admin assistant is unavailable (`requestAdminAnswer` 403). `GET /api/launchers/items` says `aiAssist`, and the launcher editor notes under AI answers when it is off. The Manager checks the `ai-assist` licence (no longer the Site Builder's).
1243
1244
  - 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. A character's chat is called by the character's name, or by `chat.characterName` when set (admin: **Call her** under Use Della) - `characterChat()` in `public/js/characters.mjs` - so Della can be "Dash" on one launcher with her own artwork. Packs in `CHARACTERS`: dot, daisy, della, dash (Job Board) and remy (health care, Regimen; unreleased), each a 3x2 atlas in `public/images/characters/<id>-poses.png`. `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
1245
  - 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
1246
  - 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.
@@ -17,7 +17,7 @@ values are not attached. Conversations stay in browser memory, are cleared on si
17
17
  or a user change, and can be cleared in the panel. They are not saved as visitor chats.
18
18
  The site's shared AI context and rules are combined with the admin-specific settings.
19
19
 
20
- The Manager needs the admin-assistant AI mode update. It uses the existing hosted AI
20
+ The site needs AI Assist (a Tool in the Pro plan) switched on; without it the assistant is unavailable. The Manager needs the admin-assistant AI mode update. It uses the existing hosted AI
21
21
  entitlement and monthly allowance. A site with no configured AI service shows an
22
22
  unavailable message. Older Managers are detected and asked to update; their visitor
23
23
  answer mode is not silently used for admin assistance.
@@ -377,6 +377,7 @@ roles and notifications are stamped with it). The sections below cover the main
377
377
  | `getCalendarSources()` | Read the registered calendar sources (used by the Calendar plugin) |
378
378
  | `registerRelatedItems(kind, provider)` | Show items beside a core contact or note, with menu actions (0.79.0). Kind `message` (0.103.0): actions on an email's menu in the mail reader, `{email}`/`{name}`/`{subject}` in the url; any action can carry `permission: {resource, action}` |
379
379
  | `enableInstantCalls()` | A paid Tool with calls switches on the CMS's instant calls ("Call Sam now…" on contacts and emails, `#/calls/new`, `/api/calls`, `/_call/<id>`). Bound to the plugin's name; refused unless the manifest is `tier: "paid"` AND `closedSource: true` (so it loads only under a licence). Disabling the plugin takes its hold off at once. Returns true when on. Call it with `?.()` - older cores lack it |
380
+ | `enableAiAssist()` | AI Assist switches on AI chat answers (chat launchers, admin launchers, the admin assistant; `services/aiAssist.js`). The same contract as `enableInstantCalls()`: refused unless `tier: "paid"` AND `closedSource: true`; disabling the plugin switches it off at once. Without it `aiAvailable()` is false and the admin assistant answers 403. The Manager still checks the site's `ai-assist` licence on each answer. Call it with `?.()` |
380
381
  | `registerContactAccess(fn)` | A plugin that shares contacts says which contacts that are not the viewer's own they may read: `fn(entries, {id, roles})` resolves to the readable entry ids. Core code taking a contact id (instant calls) uses it through `readableContactIds()` |
381
382
  | `registerSitemapSource({id, label, list})` / `sitemapChanged()` | Add public URLs to `/sitemap.xml` (and `/llms.txt`, where an item's optional `description` follows its link, 1.8.36); call `sitemapChanged()` when they change (otherwise they show within ten minutes) (0.89.0) |
382
383
  | `notify({...})` / `resolveNotification(key)` | Raise or clear an admin notification (source ids are `<plugin>:<id>`) (0.80.0) |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "domma-cms",
3
- "version": "1.57.1",
3
+ "version": "1.59.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",