@gui-chat-plugin/sequence 0.6.2 → 0.6.3

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.
@@ -236,7 +236,7 @@ ${e ? `<h1>${p(e)}</h1>` : ""}
236
236
  }
237
237
  //#endregion
238
238
  //#region src/core/definitions.ts
239
- var S = "presentSlide", pe = "defineStoryboard", C = "presentPanel", me = 4, he = 12, ge = 3, w = /^[0-9a-f]{12}$/, T = (e) => typeof e == "object" && !!e && !Array.isArray(e), E = (e) => typeof e == "string" ? e.trim() : "", D = (e, t) => e.toLowerCase() === t.toLowerCase(), O = (e) => typeof e == "number" && Number.isInteger(e), _e = "presentSlide needs slide and totalSlides (whole numbers, slide from 1 to totalSlides), and one of imagePrompt, html, markdown or chart", ve = `presentSlide's slide is too long: keep its html, markdown or chart under ${r} characters`, ye = `presentSlide's chart must be a Chart.js configuration: an object with type (${b.join(", ")}), data ({ labels, datasets }) and optionally options`;
239
+ var S = "presentSlide", pe = "defineStoryboard", me = "presentPanel", he = 4, ge = 12, _e = 3, ve = /^[0-9a-f]{12}$/, C = (e) => typeof e == "object" && !!e && !Array.isArray(e), w = (e) => typeof e == "string" ? e.trim() : "", T = (e, t) => e.toLowerCase() === t.toLowerCase(), E = (e) => typeof e == "number" && Number.isInteger(e), ye = "presentSlide needs slide and totalSlides (whole numbers, slide from 1 to totalSlides), and one of imagePrompt, html, markdown or chart", D = `presentSlide's slide is too long: keep its html, markdown or chart under ${r} characters`, O = `presentSlide's chart must be a Chart.js configuration: an object with type (${b.join(", ")}), data ({ labels, datasets }) and optionally options`;
240
240
  function be(e) {
241
241
  let t = e;
242
242
  if (typeof t == "string") try {
@@ -244,44 +244,44 @@ function be(e) {
244
244
  } catch {
245
245
  return null;
246
246
  }
247
- if (!T(t) || !T(t.data)) return null;
247
+ if (!C(t) || !C(t.data)) return null;
248
248
  let n = t.type;
249
- return !b.some((e) => e === n) || t.options !== void 0 && !T(t.options) ? null : t;
249
+ return !b.some((e) => e === n) || t.options !== void 0 && !C(t.options) ? null : t;
250
250
  }
251
- function xe(e) {
252
- let { slide: t, totalSlides: n, title: r, imagePrompt: i } = e, a = E(e.html), o = a ? "" : E(e.markdown), s = !a && !o && e.chart !== void 0 && e.chart !== null;
253
- if (!O(t) || !O(n) || t < 1 || n < t || !a && !o && !s && !E(i)) return _e;
251
+ function k(e) {
252
+ let { slide: t, totalSlides: n, title: r, imagePrompt: i } = e, a = w(e.html), o = a ? "" : w(e.markdown), s = !a && !o && e.chart !== void 0 && e.chart !== null;
253
+ if (!E(t) || !E(n) || t < 1 || n < t || !a && !o && !s && !w(i)) return ye;
254
254
  let c = s ? be(e.chart) : null;
255
- if (s && !c) return ye;
256
- if (Math.max(a.length, o.length, c ? JSON.stringify(c).length : 0) > 6e4) return ve;
255
+ if (s && !c) return O;
256
+ if (Math.max(a.length, o.length, c ? JSON.stringify(c).length : 0) > 6e4) return D;
257
257
  let l = !a && !o && !c, u = !!a && y(a);
258
258
  return {
259
259
  slide: t,
260
260
  totalSlides: n,
261
261
  title: typeof r == "string" ? r : "",
262
- imagePrompt: l ? String(i) : u || o ? E(i) : "",
262
+ imagePrompt: l ? String(i) : u || o ? w(i) : "",
263
263
  ...a && { html: a },
264
264
  ...o && { markdown: o },
265
265
  ...c && { chart: c },
266
266
  mode: e.mode === "steps" ? "steps" : "presentation"
267
267
  };
268
268
  }
269
- var Se = "teach its subject as a presenter speaking to the audience, and cover everything on it: every section, point and number, in order, each in a sentence or more. The slide is replaced by the next one as soon as you stop talking, so a point you leave out is never explained. Begin with the content itself, never with the slide or your plan: no \"This slide is about…\", \"The first slide shows…\", \"Let's unpack this one\", \"Next, I'll…\". A line about the slide is not an explanation.", k = ({ slide: e, totalSlides: t, title: n, mode: r }) => {
269
+ var xe = "teach its subject as a presenter speaking to the audience, and cover everything on it: every section, point and number, in order, each in a sentence or more. The slide is replaced by the next one as soon as you stop talking, so a point you leave out is never explained. Begin with the content itself, never with the slide or your plan: no \"This slide is about…\", \"The first slide shows…\", \"Let's unpack this one\", \"Next, I'll…\". A line about the slide is not an explanation.", A = ({ slide: e, totalSlides: t, title: n, mode: r }) => {
270
270
  let i = n ? ` ("${n}")` : "";
271
271
  if (r === "steps") {
272
272
  let n = `Step ${e} of ${t}${i}`;
273
273
  return e < t ? `${n} is now on the screen. Say what to do in this step, directly ("Crack two eggs into a bowl…", not "This step is about eggs"), then stop and wait while the user does it. When they say they're ready (next, done, go on), call presentSlide for step ${e + 1} with mode "steps". If they ask to go back or to see a step again, call presentSlide for that step.` : `${n}, the last one, is now on the screen. Say what to do, directly, then wrap up the guide once the user is done.`;
274
274
  }
275
275
  let a = `Slide ${e} of ${t}${i}`;
276
- return e < t ? `${a} is now on the screen. Explain it: ${Se} This reply is only the explanation: don't call presentSlide in it. When you have finished, you will be asked for slide ${e + 1}. If the user has asked you to stop, or asked something else, since the slideshow began, answer them instead of going on.` : `${a}, the last one, is now on the screen. Explain it: ${Se} Then wrap up the slideshow.`;
277
- }, Ce = [
276
+ return e < t ? `${a} is now on the screen. Explain it: ${xe} This reply is only the explanation: don't call presentSlide in it. When you have finished, you will be asked for slide ${e + 1}. If the user has asked you to stop, or asked something else, since the slideshow began, answer them instead of going on.` : `${a}, the last one, is now on the screen. Explain it: ${xe} Then wrap up the slideshow.`;
277
+ }, Se = [
278
278
  `For an HTML slide: the slide's content, the inside of <body> only (no <html>, <head> or <body> tags), for a ${t}x720 px canvas, which it should fill (start with a <div class="w-full h-full ...">). Style it with Tailwind CSS v4 classes, which are loaded for you: a clear layout, a large title (text-6xl or so), few words in large type, a color scheme, and inline SVG or emoji for icons and diagrams. There is no network: no <img> from URLs, no links to follow. For one generated picture on the slide (a photo, a scene, an object beside the text), give imagePrompt too and put <img src="${g}" alt="..." class="..."> where it goes, sized by its classes (for example class="w-1/2 h-full object-cover rounded-2xl").`,
279
279
  "Animate it so it builds up as you explain it, with MulmoCast's data-animation attributes (the same ones make it move in a movie of the slideshow): data-animation=\"animate\" with data-opacity=\"0,1\", data-translate-x, data-translate-y (px), data-scale, data-rotate (deg), data-width or data-height (\"0,80,%\"), each \"from,to\"; data-animation=\"counter\" with data-from, data-to, data-decimals, data-prefix, data-suffix; data-animation=\"typewriter\" (its text, or data-text). Give every one data-start and data-end in seconds, and optionally data-easing (linear, easeIn, easeOut, easeInOut); stagger the parts with later data-start values so they appear one after another over a few seconds (for example 0, 0.6, 1.2). Set the first frame inline too (style=\"opacity:0\" on an element that fades in).",
280
280
  "CSS animations, transitions and scripts don't play: animate only with data-animation. A <style> for layout is allowed (and Google Fonts by @import)."
281
- ].join(" "), we = `For a Markdown slide: the slide in Markdown (GitHub's: headings, lists, bold, tables, code), with math in TeX between $...$ inline or $$...$$ for a displayed equation (on lines of its own). Start with a # heading, and keep it to what fits on one slide: a heading and a few lines, a list or an equation or two. Write a dollar sign that isn't math as \\$. For one generated picture on the slide, give imagePrompt too and put ![what it shows](${g}) on a line of its own: the slide is then two columns, the text on the left and the picture on the right. Without imagePrompt, the alt text is what is drawn.`, Te = `For a chart slide, instead of imagePrompt (for numbers: real figures you have, never a picture of a chart): a Chart.js configuration as JSON text, {"type": ..., "data": ...}: { type, data: { labels, datasets: [{ label, data, backgroundColor }] }, options }. type is one of ${b.join(", ")}. It is drawn under the slide's title, so leave out options.plugins.title; give the datasets colors, and the axes titles (options.scales.x.title) when their units aren't obvious. JSON values only: no functions.`, Ee = "When the user asks for a slideshow (or to explain something with slides), plan four to six slides (more when the subject or your instructions need them), then show them one at a time with presentSlide: slide 1 first, and each next slide only after you have explained the one on the screen. Explain the subject, not the slides: say what the slide teaches, not that a slide is about it, and explain everything on a slide before showing the next; put on a slide only what you will explain. Go on to the last slide without asking whether to continue. A slide is a generated picture (imagePrompt), a chart (chart), a text slide in Markdown (markdown) or a designed slide in HTML (html): use a picture for a scene, an object or a place; a chart for numbers to compare, a trend or proportions; Markdown for equations and formulas (TeX math), definitions, short lists and small tables; and HTML for designed layouts, comparisons, timelines and diagrams. A picture model draws words, numbers and math badly, so they go on the other kinds; a slideshow can mix them. When a picture helps the text (the thing being explained, beside its key points), make an HTML or Markdown slide with one generated picture on it: imagePrompt for the picture, and {{image}} where it goes. Numbers go on a chart slide: when you have figures (from a search, a document or the user: revenue, market share, growth, prices, counts over time), show them in a chart with those exact values, labelled with their units and the year or period, and say where they come from. Figures over time, shares of a whole or values side by side are a chart, not a list or table on a Markdown or HTML slide. Never make a chart, graph or table a picture (imagePrompt): a picture of a chart has made-up bars and no real numbers. A slideshow about a business, a market or a comparison of companies has its figures on chart slides, not only in text. Never invent figures; with none to show, leave the chart out. A slide holds only its subject, never notes about your work (what you searched for, that a search succeeded). When the user asks for HTML slides (slides in HTML, an HTML presentation), this is the tool: make them HTML slides with presentSlide, one call per slide, not one HTML page. When the user wants to be shown how to do something they will do along with you (cooking, folding, fixing, an exercise), make it a step-by-step guide instead: mode \"steps\", one slide per step, and after each step wait for the user to say they are ready. Use generateImage for a single picture, not for slides.", A = {
281
+ ].join(" "), Ce = `For a Markdown slide: the slide in Markdown (GitHub's: headings, lists, bold, tables, code), with math in TeX between $...$ inline or $$...$$ for a displayed equation (on lines of its own). Start with a # heading, and keep it to what fits on one slide: a heading and a few lines, a list or an equation or two. Write a dollar sign that isn't math as \\$, and & % # inside \\text{} as \\& \\% \\#. For one generated picture on the slide, give imagePrompt too and put ![what it shows](${g}) on a line of its own: the slide is then two columns, the text on the left and the picture on the right. Without imagePrompt, the alt text is what is drawn.`, we = `For a chart slide, instead of imagePrompt (for numbers: real figures you have, never a picture of a chart): a Chart.js configuration as JSON text, {"type": ..., "data": ...}: { type, data: { labels, datasets: [{ label, data, backgroundColor }] }, options }. type is one of ${b.join(", ")}. It is drawn under the slide's title, so leave out options.plugins.title; give the datasets colors, and the axes titles (options.scales.x.title) when their units aren't obvious. JSON values only: no functions.`, Te = "When the user asks for a slideshow (or to explain something with slides), plan four to six slides (more when the subject or your instructions need them), then show them one at a time with presentSlide: slide 1 first, and each next slide only after you have explained the one on the screen. Explain the subject, not the slides: say what the slide teaches, not that a slide is about it, and explain everything on a slide before showing the next; put on a slide only what you will explain. Go on to the last slide without asking whether to continue. A slide is a generated picture (imagePrompt), a chart (chart), a text slide in Markdown (markdown) or a designed slide in HTML (html): use a picture for a scene, an object or a place; a chart for numbers to compare, a trend or proportions; Markdown for equations and formulas (TeX math), definitions, short lists and small tables; and HTML for designed layouts, comparisons, timelines and diagrams. A picture model draws words, numbers and math badly, so they go on the other kinds; a slideshow can mix them. When a picture helps the text (the thing being explained, beside its key points), make an HTML or Markdown slide with one generated picture on it: imagePrompt for the picture, and {{image}} where it goes. Numbers go on a chart slide: when you have figures (from a search, a document or the user: revenue, market share, growth, prices, counts over time), show them in a chart with those exact values, labelled with their units and the year or period, and say where they come from. Figures over time, shares of a whole or values side by side are a chart, not a list or table on a Markdown or HTML slide. Never make a chart, graph or table a picture (imagePrompt): a picture of a chart has made-up bars and no real numbers. A slideshow about a business, a market or a comparison of companies has its figures on chart slides, not only in text. Never invent figures; with none to show, leave the chart out. A slide holds only its subject, never notes about your work (what you searched for, that a search succeeded). When the user asks for HTML slides (slides in HTML, an HTML presentation), this is the tool: make them HTML slides with presentSlide, one call per slide, not one HTML page. When the user wants to be shown how to do something they will do along with you (cooking, folding, fixing, an exercise), make it a step-by-step guide instead: mode \"steps\", one slide per step, and after each step wait for the user to say they are ready. Use generateImage for a single picture, not for slides.", j = {
282
282
  type: "function",
283
283
  name: S,
284
- prompt: Ee,
284
+ prompt: Te,
285
285
  description: "Show one slide of a slideshow, full screen: a picture generated from imagePrompt, a chart (chart), a slide written in Markdown with TeX math (markdown), or a slide written in HTML (html). Give one of the four; an HTML or Markdown slide can also hold one generated picture (imagePrompt, placed at {{image}}). Call it once per slide, in order, starting with slide 1. With mode \"steps\" it is a step-by-step guide: one slide per step, and the next step waits for the user.",
286
286
  parameters: {
287
287
  type: "object",
@@ -304,15 +304,15 @@ var Se = "teach its subject as a presenter speaking to the audience, and cover e
304
304
  },
305
305
  html: {
306
306
  type: "string",
307
- description: Ce
307
+ description: Se
308
308
  },
309
309
  markdown: {
310
310
  type: "string",
311
- description: we
311
+ description: Ce
312
312
  },
313
313
  chart: {
314
314
  type: "string",
315
- description: Te
315
+ description: we
316
316
  },
317
317
  mode: {
318
318
  type: "string",
@@ -327,49 +327,49 @@ var Se = "teach its subject as a presenter speaking to the audience, and cover e
327
327
  ]
328
328
  }
329
329
  };
330
- function j(e) {
330
+ function M(e) {
331
331
  let { totalPanels: t } = e;
332
- if (!O(t) || t < 1 || t > 12) return "totalPanels must be a whole number from 1 to 12";
332
+ if (!E(t) || t < 1 || t > 12) return "totalPanels must be a whole number from 1 to 12";
333
333
  let n = [];
334
334
  for (let t of Array.isArray(e.characters) ? e.characters : []) {
335
- let e = T(t) ? E(t.name) : "", r = T(t) ? E(t.description) : "";
335
+ let e = C(t) ? w(t.name) : "", r = C(t) ? w(t.description) : "";
336
336
  if (!e || !r) return "every character needs a name and a description";
337
- if (n.some((t) => D(t.name, e))) return `two characters are named ${e}`;
337
+ if (n.some((t) => T(t.name, e))) return `two characters are named ${e}`;
338
338
  n.push({
339
339
  name: e,
340
340
  description: r
341
341
  });
342
342
  }
343
343
  return n.length < 1 || n.length > 4 ? "a storyboard has 1 to 4 characters" : {
344
- title: E(e.title),
345
- style: E(e.style),
344
+ title: w(e.title),
345
+ style: w(e.style),
346
346
  totalPanels: t,
347
347
  characters: n,
348
348
  interactive: e.interactive === !0
349
349
  };
350
350
  }
351
- var M = ({ title: e }) => `The cast of "${e}" is now on the screen. Introduce the characters briefly. This reply is only the introduction: don't call presentPanel in it. When you have finished, you will be asked for panel 1. If the user has asked you to stop, or asked something else, answer them instead of going on.`, N = "presentPanel needs a storyboardId, a panel number (from 1) and an imagePrompt";
352
- function P(e) {
353
- let { panel: t } = e, n = E(e.storyboardId), r = E(e.imagePrompt);
354
- if (!n || !r || !O(t) || t < 1) return null;
355
- let i = (e) => (Array.isArray(e) ? e : []).map(E).filter(Boolean);
351
+ var N = ({ title: e }) => `The cast of "${e}" is now on the screen. Introduce the characters briefly. This reply is only the introduction: don't call presentPanel in it. When you have finished, you will be asked for panel 1. If the user has asked you to stop, or asked something else, answer them instead of going on.`, P = "presentPanel needs a storyboardId, a panel number (from 1) and an imagePrompt";
352
+ function F(e) {
353
+ let { panel: t } = e, n = w(e.storyboardId), r = w(e.imagePrompt);
354
+ if (!n || !r || !E(t) || t < 1) return null;
355
+ let i = (e) => (Array.isArray(e) ? e : []).map(w).filter(Boolean);
356
356
  return {
357
357
  storyboardId: n,
358
358
  panel: t,
359
359
  characters: i(e.characters),
360
360
  imagePrompt: r,
361
- caption: E(e.caption),
361
+ caption: w(e.caption),
362
362
  choices: i(e.choices).slice(0, 3)
363
363
  };
364
364
  }
365
- function F(e, t, n) {
365
+ function I(e, t, n) {
366
366
  let { id: r, totalPanels: i } = e;
367
367
  return n.length ? `Panel ${t} of ${i} is now on the screen, with the user's choices: ${n.map((e, t) => `${t + 1}. ${e}`).join(" ")} Tell this part of the story, then read the choices out and ask the user which one they pick, and wait for their answer. Then call presentPanel for panel ${t + 1} with storyboardId "${r}", going on the way they chose.` : t < i ? `Panel ${t} of ${i} is now on the screen. Tell this part of the story, aloud, as a storyteller. This reply is only the telling: don't call presentPanel in it. When you have finished, you will be asked for panel ${t + 1}. If the user has asked you to stop, or asked something else, since the story began, answer them instead of going on.` : `Panel ${t} of ${i}, the last one, is now on the screen. Tell this part of the story, then bring it to an end.`;
368
368
  }
369
- var I = "When the user asks for a story, a picture book, a comic or a storyboard, tell it in pictures: first call defineStoryboard with the art style and the characters who appear more than once (it draws a reference sheet for each, so they look the same in every panel), then show the panels one at a time with presentPanel, naming the characters in each, and tell each part of the story when its panel appears. Go on to the last panel without asking whether to continue, unless the story is interactive. When the user wants to decide what happens (an adventure, a story for a child who wants to choose), set interactive, and give two or three choices on two or three of the panels: the story waits there for the user's pick and goes on their way; it still ends at the last panel whichever way it goes. Use presentSlide to explain a topic, not to tell a story.", L = {
369
+ var L = "When the user asks for a story, a picture book, a comic or a storyboard, tell it in pictures: first call defineStoryboard with the art style and the characters who appear more than once (it draws a reference sheet for each, so they look the same in every panel), then show the panels one at a time with presentPanel, naming the characters in each, and tell each part of the story when its panel appears. Go on to the last panel without asking whether to continue, unless the story is interactive. When the user wants to decide what happens (an adventure, a story for a child who wants to choose), set interactive, and give two or three choices on two or three of the panels: the story waits there for the user's pick and goes on their way; it still ends at the last panel whichever way it goes. Use presentSlide to explain a topic, not to tell a story.", R = {
370
370
  type: "function",
371
371
  name: pe,
372
- prompt: I,
372
+ prompt: L,
373
373
  description: "Start a story told in pictures: set its art style and draw a reference sheet for each recurring character, shown as the cast. Then call presentPanel for each panel, in order.",
374
374
  parameters: {
375
375
  type: "object",
@@ -416,9 +416,9 @@ var I = "When the user asks for a story, a picture book, a comic or a storyboard
416
416
  "characters"
417
417
  ]
418
418
  }
419
- }, R = {
419
+ }, z = {
420
420
  type: "function",
421
- name: C,
421
+ name: me,
422
422
  description: "Show one panel of a storyboard made with defineStoryboard: a picture of the scene with its characters drawn as in their reference sheets, and a caption. Call it once per panel, in order, starting with panel 1.",
423
423
  parameters: {
424
424
  type: "object",
@@ -457,60 +457,60 @@ var I = "When the user asks for a story, a picture book, a comic or a storyboard
457
457
  "imagePrompt"
458
458
  ]
459
459
  }
460
- }, z = (e) => typeof e == "object" && !!e && !Array.isArray(e), De = (e) => z(e) && typeof e.message == "string";
461
- function B(e) {
462
- let t = z(e?.data) ? e.data : {};
460
+ }, B = (e) => typeof e == "object" && !!e && !Array.isArray(e), Ee = (e) => B(e) && typeof e.message == "string";
461
+ function V(e) {
462
+ let t = B(e?.data) ? e.data : {};
463
463
  return {
464
464
  ...typeof t.imageData == "string" && { imageData: t.imageData },
465
465
  ...typeof t.imagePath == "string" && { imagePath: t.imagePath }
466
466
  };
467
467
  }
468
- function V(e) {
469
- let t = z(e?.data) ? e.data : {};
468
+ function H(e) {
469
+ let t = B(e?.data) ? e.data : {};
470
470
  return typeof t.html == "string" ? t.html : "";
471
471
  }
472
- function H(e) {
473
- let t = z(e?.data) ? e.data : {};
474
- return z(t.chart) ? JSON.stringify(t.chart) : "";
472
+ function U(e) {
473
+ let t = B(e?.data) ? e.data : {};
474
+ return B(t.chart) ? JSON.stringify(t.chart) : "";
475
475
  }
476
- var Oe = (e) => !!B(e).imageData || !!V(e) || !!H(e);
477
- function ke(e, t) {
478
- let n = B(e), r = B(t);
476
+ var De = (e) => !!V(e).imageData || !!H(e) || !!U(e);
477
+ function Oe(e, t) {
478
+ let n = V(e), r = V(t);
479
479
  if (n.imagePath && r.imagePath) return n.imagePath === r.imagePath;
480
480
  if (n.imageData) return n.imageData === r.imageData;
481
- let i = V(e);
482
- if (i) return i === V(t);
483
- let a = H(e);
484
- return !!a && a === H(t);
481
+ let i = H(e);
482
+ if (i) return i === H(t);
483
+ let a = U(e);
484
+ return !!a && a === U(t);
485
485
  }
486
- var U = (e, t) => e.userSpokeAt === void 0 || e.userSpokeAt > t, W = () => crypto.randomUUID().replace(/-/g, "").slice(0, 12), Ae = "artifacts/";
487
- async function G(e, t) {
486
+ var W = (e, t) => e.userSpokeAt === void 0 || e.userSpokeAt > t, G = () => crypto.randomUUID().replace(/-/g, "").slice(0, 12), ke = "artifacts/";
487
+ async function K(e, t) {
488
488
  let n = e.files?.artifacts;
489
489
  if (!e.app?.editImages || !n) return [];
490
490
  let r = [];
491
- for (let e of t) if (e.startsWith(Ae)) try {
491
+ for (let e of t) if (e.startsWith(ke)) try {
492
492
  await n.exists(e.slice(10)) && r.push(e);
493
493
  } catch {}
494
494
  return r;
495
495
  }
496
- async function K(e, t, n = []) {
496
+ async function q(e, t, n = []) {
497
497
  let r = e.app, i = r?.editImages, a = r?.generateImage;
498
498
  try {
499
499
  let e;
500
500
  if (n.length && i) e = await i(t, [...n]);
501
501
  else if (a) e = await a(t);
502
502
  else return { message: "image generation isn't available" };
503
- return De(e) ? e : { message: "image generation returned an unrecognized result" };
503
+ return Ee(e) ? e : { message: "image generation returned an unrecognized result" };
504
504
  } catch (e) {
505
505
  return { message: `image generation failed: ${e instanceof Error ? e.message : String(e)}` };
506
506
  }
507
507
  }
508
- var je = 50;
509
- function q(e) {
508
+ var Ae = 50;
509
+ function J(e) {
510
510
  let t = /* @__PURE__ */ new Map();
511
511
  return (n) => {
512
512
  let r = n.conversationId ?? "", i = t.get(r);
513
- if (i === void 0 ? i = e() : t.delete(r), t.set(r, i), t.size > je) {
513
+ if (i === void 0 ? i = e() : t.delete(r), t.set(r, i), t.size > Ae) {
514
514
  let e = t.keys().next().value;
515
515
  e !== void 0 && t.delete(e);
516
516
  }
@@ -519,45 +519,45 @@ function q(e) {
519
519
  }
520
520
  //#endregion
521
521
  //#region src/core/markdownSlide.ts
522
- var J = "slide-md", Me = "slide-md-split", Y = "slide-md-text", Ne = "slide-md-picture", Pe = .8, Fe = `
523
- .${J} { box-sizing: border-box; flex-shrink: 0; width: ${t}px; height: 720px; padding: 56px 80px; overflow: hidden; display: flex; flex-direction: column; justify-content: center; gap: 0.5em; background: #ffffff; color: #0f172a; font-family: ui-sans-serif, system-ui, sans-serif; line-height: 1.35; }
524
- .${J} > * { margin: 0; }
525
- .${J} h1 { font-size: 1.9em; font-weight: 800; color: #1e3a8a; line-height: 1.15; }
526
- .${J} h2 { font-size: 1.5em; font-weight: 700; color: #1e40af; line-height: 1.2; }
527
- .${J} h3 { font-size: 1.2em; font-weight: 700; color: #334155; }
528
- .${J} ul, .${J} ol { padding-left: 1.3em; display: flex; flex-direction: column; gap: 0.3em; }
529
- .${J} ul { list-style: disc; }
530
- .${J} ol { list-style: decimal; }
531
- .${J} li > ul, .${J} li > ol { margin-top: 0.3em; font-size: 0.9em; }
532
- .${J} li::marker { color: #2563eb; }
533
- .${J} strong { font-weight: 700; color: #1e3a8a; }
534
- .${J} em { font-style: italic; }
535
- .${J} a { color: #2563eb; text-decoration: underline; }
536
- .${J} code { font-family: ui-monospace, monospace; font-size: 0.85em; background: #f1f5f9; border-radius: 0.2em; padding: 0.05em 0.3em; }
537
- .${J} pre { background: #0f172a; color: #e2e8f0; border-radius: 0.4em; padding: 0.6em 0.8em; font-size: 0.75em; overflow: hidden; }
538
- .${J} pre code { background: none; padding: 0; color: inherit; }
539
- .${J} blockquote { border-left: 0.2em solid #93c5fd; padding-left: 0.8em; color: #475569; font-style: italic; }
540
- .${J} table { border-collapse: collapse; font-size: 0.85em; align-self: flex-start; }
541
- .${J} th, .${J} td { border: 1px solid #cbd5e1; padding: 0.25em 0.7em; text-align: left; }
542
- .${J} th { background: #eff6ff; font-weight: 700; }
543
- .${J} hr { border: 0; border-top: 2px solid #e2e8f0; }
544
- .${J} img { max-width: 100%; max-height: 60%; }
545
- .${J}.${Me} { flex-direction: row; align-items: center; gap: 48px; }
546
- .${J} .${Y} { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 0.5em; }
547
- .${J} .${Y} > * { margin: 0; }
548
- .${J} .${Ne} { flex: 0 0 44%; width: 44%; height: 100%; max-width: none; max-height: 100%; object-fit: cover; border-radius: 0.6em; box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18); }
549
- .${J} .math-display { display: block; text-align: center; font-size: 1.15em; }
550
- .${J} math { font-family: "Latin Modern Math", "STIX Two Math", "Cambria Math", math; }
551
- .${J} mtd { padding: 0.1em 0.4em; }
552
- .${J} mtd:first-child { padding-left: 0; }
553
- .${J} mtd:last-child { padding-right: 0; }
554
- .${J} .math-error { color: #b91c1c; font-family: ui-monospace, monospace; }`;
555
- function Ie(e) {
522
+ var Y = "slide-md", je = "slide-md-split", X = "slide-md-text", Me = "slide-md-picture", Ne = .8, Pe = `
523
+ .${Y} { box-sizing: border-box; flex-shrink: 0; width: ${t}px; height: 720px; padding: 56px 80px; overflow: hidden; display: flex; flex-direction: column; justify-content: center; gap: 0.5em; background: #ffffff; color: #0f172a; font-family: ui-sans-serif, system-ui, sans-serif; line-height: 1.35; }
524
+ .${Y} > * { margin: 0; }
525
+ .${Y} h1 { font-size: 1.9em; font-weight: 800; color: #1e3a8a; line-height: 1.15; }
526
+ .${Y} h2 { font-size: 1.5em; font-weight: 700; color: #1e40af; line-height: 1.2; }
527
+ .${Y} h3 { font-size: 1.2em; font-weight: 700; color: #334155; }
528
+ .${Y} ul, .${Y} ol { padding-left: 1.3em; display: flex; flex-direction: column; gap: 0.3em; }
529
+ .${Y} ul { list-style: disc; }
530
+ .${Y} ol { list-style: decimal; }
531
+ .${Y} li > ul, .${Y} li > ol { margin-top: 0.3em; font-size: 0.9em; }
532
+ .${Y} li::marker { color: #2563eb; }
533
+ .${Y} strong { font-weight: 700; color: #1e3a8a; }
534
+ .${Y} em { font-style: italic; }
535
+ .${Y} a { color: #2563eb; text-decoration: underline; }
536
+ .${Y} code { font-family: ui-monospace, monospace; font-size: 0.85em; background: #f1f5f9; border-radius: 0.2em; padding: 0.05em 0.3em; }
537
+ .${Y} pre { background: #0f172a; color: #e2e8f0; border-radius: 0.4em; padding: 0.6em 0.8em; font-size: 0.75em; overflow: hidden; }
538
+ .${Y} pre code { background: none; padding: 0; color: inherit; }
539
+ .${Y} blockquote { border-left: 0.2em solid #93c5fd; padding-left: 0.8em; color: #475569; font-style: italic; }
540
+ .${Y} table { border-collapse: collapse; font-size: 0.85em; align-self: flex-start; }
541
+ .${Y} th, .${Y} td { border: 1px solid #cbd5e1; padding: 0.25em 0.7em; text-align: left; }
542
+ .${Y} th { background: #eff6ff; font-weight: 700; }
543
+ .${Y} hr { border: 0; border-top: 2px solid #e2e8f0; }
544
+ .${Y} img { max-width: 100%; max-height: 60%; }
545
+ .${Y}.${je} { flex-direction: row; align-items: center; gap: 48px; }
546
+ .${Y} .${X} { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 0.5em; }
547
+ .${Y} .${X} > * { margin: 0; }
548
+ .${Y} .${Me} { flex: 0 0 44%; width: 44%; height: 100%; max-width: none; max-height: 100%; object-fit: cover; border-radius: 0.6em; box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18); }
549
+ .${Y} .math-display { display: block; text-align: center; font-size: 1.15em; }
550
+ .${Y} math { font-family: "Latin Modern Math", "STIX Two Math", "Cambria Math", math; }
551
+ .${Y} mtd { padding: 0.1em 0.4em; }
552
+ .${Y} mtd:first-child { padding-left: 0; }
553
+ .${Y} mtd:last-child { padding-right: 0; }
554
+ .${Y} .math-error { color: #b91c1c; font-family: ui-monospace, monospace; }`;
555
+ function Fe(e) {
556
556
  let t = e.split("\n").filter((e) => e.trim()).length, n = e.length;
557
557
  return t <= 5 && n <= 250 ? 40 : t <= 8 && n <= 450 ? 34 : t <= 12 && n <= 700 ? 28 : 24;
558
558
  }
559
- var Le = /^[ \t]*(?:\$\$([\s\S]+?)\$\$|\\\[([\s\S]+?)\\\])[ \t]*(?:\n|$)/, Re = /^(?:\$\$(.+?)\$\$|\$(?!\s)((?:\\.|[^\\$\n])+?)(?<!\s)\$(?!\d)|\\\((.+?)\\\))/;
560
- function ze(e) {
559
+ var Ie = /^[ \t]*(?:\$\$([\s\S]+?)\$\$|\\\[([\s\S]+?)\\\])[ \t]*(?:\n|$)/, Le = /^(?:\$\$(.+?)\$\$|\$(?!\s)((?:\\.|[^\\$\n])+?)(?<!\s)\$(?!\d)|\\\((.+?)\\\))/;
560
+ function Re(e) {
561
561
  return [{
562
562
  name: "blockMath",
563
563
  level: "block",
@@ -566,7 +566,7 @@ function ze(e) {
566
566
  return t ? t.index + (t[1] ?? "").length : void 0;
567
567
  },
568
568
  tokenizer(e) {
569
- let t = Le.exec(e);
569
+ let t = Ie.exec(e);
570
570
  if (t) return {
571
571
  type: "blockMath",
572
572
  raw: t[0],
@@ -579,7 +579,7 @@ function ze(e) {
579
579
  level: "inline",
580
580
  start: (e) => e.match(/(?<!\\)\$|\\\(/)?.index,
581
581
  tokenizer(e) {
582
- let t = Re.exec(e);
582
+ let t = Le.exec(e);
583
583
  if (t) return {
584
584
  type: "inlineMath",
585
585
  raw: t[0],
@@ -590,11 +590,21 @@ function ze(e) {
590
590
  renderer: (t) => e(String(t.text), t.display === !0)
591
591
  }];
592
592
  }
593
- var Be = /(<\/mi>|<\/mn>|<\/mrow>|<mo[^>]*>[)\]]<\/mo>)?(<mi(?: mathvariant="normal")?>[A-Za-z]{2,}<\/mi>)<mo>\u2061<\/mo>/g, Ve = "<mspace width=\"0.1667em\"></mspace>", He = (e) => e.replace(Be, (e, t, n) => `${t ? t + Ve : ""}${n}<mo lspace="0" rspace="0.1667em">\u2061</mo>`);
594
- async function Ue(e) {
593
+ var ze = /(<\/mi>|<\/mn>|<\/mrow>|<mo[^>]*>[)\]]<\/mo>)?(<mi(?: mathvariant="normal")?>[A-Za-z]{2,}<\/mi>)<mo>\u2061<\/mo>/g, Be = "<mspace width=\"0.1667em\"></mspace>", Ve = (e) => e.replace(ze, (e, t, n) => `${t ? t + Be : ""}${n}<mo lspace="0" rspace="0.1667em">\u2061</mo>`), He = /\\(?:text(?:bf|it|rm|sf|tt|normal)?|mbox)\s*\{/g, Ue = (e) => {
594
+ let t = "", n = 0;
595
+ for (let r of e.matchAll(He)) {
596
+ let i = r.index + r[0].length;
597
+ if (i <= n) continue;
598
+ let a = 1, o = i;
599
+ for (; o < e.length && a > 0; o++) e[o] === "\\" ? o++ : e[o] === "{" ? a++ : e[o] === "}" && a--;
600
+ t += e.slice(n, i) + e.slice(i, o).replace(/(?<!\\)((?:\\\\)*)([&%#])/g, "$1\\$2"), n = o;
601
+ }
602
+ return t + e.slice(n);
603
+ };
604
+ async function We(e) {
595
605
  let [{ Marked: t }, { default: n }] = await Promise.all([import("marked"), import("katex")]), r = (e, t) => {
596
606
  try {
597
- return He(n.renderToString(e, {
607
+ return Ve(n.renderToString(Ue(e), {
598
608
  output: "mathml",
599
609
  displayMode: t,
600
610
  throwOnError: !0
@@ -606,7 +616,7 @@ async function Ue(e) {
606
616
  gfm: !0,
607
617
  breaks: !1
608
618
  });
609
- i.use({ extensions: ze(r) });
619
+ i.use({ extensions: Re(r) });
610
620
  let a = i.lexer(e), o = a.findIndex((e) => {
611
621
  if (e.type !== "paragraph" || e.tokens?.length !== 1) return !1;
612
622
  let t = e.tokens[0];
@@ -614,34 +624,34 @@ async function Ue(e) {
614
624
  });
615
625
  if (o >= 0) {
616
626
  let [t] = a.splice(o, 1), n = t?.type === "paragraph" ? t.tokens?.[0] : void 0, r = n?.type === "image" ? n.text : "", s = i.parser(a), c = e.replace(t?.raw ?? "", "");
617
- return `<style>${Fe}</style>
618
- <div class="${J} ${Me}" data-fit style="font-size: ${Math.round(Ie(c) * Pe)}px">
619
- <div class="${Y}">
627
+ return `<style>${Pe}</style>
628
+ <div class="${Y} ${je}" data-fit style="font-size: ${Math.round(Fe(c) * Ne)}px">
629
+ <div class="${X}">
620
630
  ${s}</div>
621
- <img class="${Ne}" src="${g}" alt="${p(r)}">
631
+ <img class="${Me}" src="${g}" alt="${p(r)}">
622
632
  </div>`;
623
633
  }
624
634
  let s = await i.parse(e);
625
- return `<style>${Fe}</style>
626
- <div class="${J}" data-fit style="font-size: ${Ie(e)}px">
635
+ return `<style>${Pe}</style>
636
+ <div class="${Y}" data-fit style="font-size: ${Fe(e)}px">
627
637
  ${s}</div>`;
628
638
  }
629
639
  //#endregion
630
640
  //#region src/core/records.ts
631
- var We = "slideshows", X = "storyboards", Ge = {}, Ke = /* @__PURE__ */ new WeakMap(), qe = /* @__PURE__ */ new WeakMap();
632
- function Je(e) {
633
- let t = Ke.get(e);
634
- return t || Ke.set(e, t = /* @__PURE__ */ new Map()), t;
641
+ var Ge = "slideshows", Z = "storyboards", Ke = {}, qe = /* @__PURE__ */ new WeakMap(), Je = /* @__PURE__ */ new WeakMap();
642
+ function Ye(e) {
643
+ let t = qe.get(e);
644
+ return t || qe.set(e, t = /* @__PURE__ */ new Map()), t;
635
645
  }
636
- function Ye(t, n) {
637
- let r = qe.get(t);
638
- r || qe.set(t, r = /* @__PURE__ */ new Map());
646
+ function Xe(t, n) {
647
+ let r = Je.get(t);
648
+ r || Je.set(t, r = /* @__PURE__ */ new Map());
639
649
  let i = r.get(n);
640
650
  return i || r.set(n, i = e()), i;
641
651
  }
642
- var Xe = (e, t) => `${e}/${t}.json`;
643
- async function Ze(e, t) {
644
- let n = Je(e ?? Ge), r = n.get(t);
652
+ var Ze = (e, t) => `${e}/${t}.json`;
653
+ async function Qe(e, t) {
654
+ let n = Ye(e ?? Ke), r = n.get(t);
645
655
  if (r) return r;
646
656
  if (!e) return null;
647
657
  try {
@@ -651,14 +661,14 @@ async function Ze(e, t) {
651
661
  return null;
652
662
  }
653
663
  }
654
- async function Qe(e, t, n) {
655
- return w.test(n) ? Ze(e, Xe(t, n)) : null;
664
+ async function $e(e, t, n) {
665
+ return ve.test(n) ? Qe(e, Ze(t, n)) : null;
656
666
  }
657
- async function Z(e, t, n, r) {
658
- let i = Xe(t, n), a = e ?? Ge;
659
- return Ye(a, i)(async () => {
660
- let t = r(await Ze(e, i));
661
- if (Je(a).set(i, t), !e) return !1;
667
+ async function Q(e, t, n, r) {
668
+ let i = Ze(t, n), a = e ?? Ke;
669
+ return Xe(a, i)(async () => {
670
+ let t = r(await Qe(e, i));
671
+ if (Ye(a).set(i, t), !e) return !1;
662
672
  try {
663
673
  return await e.write(i, JSON.stringify(t, null, 2)), !0;
664
674
  } catch (e) {
@@ -666,12 +676,12 @@ async function Z(e, t, n, r) {
666
676
  }
667
677
  });
668
678
  }
669
- var Q = (e) => `the ${e} could not be saved, so it lasts only until the app or server restarts`, $e = 6e4;
670
- function et() {
679
+ var $ = (e) => `the ${e} could not be saved, so it lasts only until the app or server restarts`, et = 6e4;
680
+ function tt() {
671
681
  let e = /* @__PURE__ */ new Map();
672
682
  return { claim: (t) => {
673
683
  let n = Date.now();
674
- for (let [t, r] of e) n - r.at > $e && e.delete(t);
684
+ for (let [t, r] of e) n - r.at > et && e.delete(t);
675
685
  let r = e.get(t);
676
686
  if (r) return { earlier: r.shown };
677
687
  let i = () => void 0, a = new Promise((e) => i = e);
@@ -685,7 +695,7 @@ function et() {
685
695
  }
686
696
  //#endregion
687
697
  //#region src/core/presentSlide.ts
688
- function tt({ slide: e, totalSlides: t, mode: n }) {
698
+ function nt({ slide: e, totalSlides: t, mode: n }) {
689
699
  return n === "steps" ? {
690
700
  step: e,
691
701
  total: t,
@@ -703,7 +713,7 @@ function tt({ slide: e, totalSlides: t, mode: n }) {
703
713
  nextCall: `call presentSlide for slide ${e + 1} of ${t}`
704
714
  };
705
715
  }
706
- var nt = (e, { slide: t, totalSlides: n, title: r, imagePrompt: i, html: a, markdown: o, chart: s }) => JSON.stringify([
716
+ var rt = (e, { slide: t, totalSlides: n, title: r, imagePrompt: i, html: a, markdown: o, chart: s }) => JSON.stringify([
707
717
  e,
708
718
  t,
709
719
  n,
@@ -712,19 +722,19 @@ var nt = (e, { slide: t, totalSlides: n, title: r, imagePrompt: i, html: a, mark
712
722
  a,
713
723
  o,
714
724
  s
715
- ]), rt = q(() => ({
725
+ ]), it = J(() => ({
716
726
  latest: {
717
727
  presentation: null,
718
728
  steps: null
719
729
  },
720
730
  lastShown: null,
721
- repeats: et()
731
+ repeats: tt()
722
732
  }));
723
- function it(e, t) {
733
+ function at(e, t) {
724
734
  let n = e.latest[t.mode], r = n?.totalSlides === t.totalSlides && (t.slide !== 1 || n.firstTitle === t.title);
725
735
  if (n && r) return n;
726
736
  let i = {
727
- id: W(),
737
+ id: G(),
728
738
  mode: t.mode,
729
739
  totalSlides: t.totalSlides,
730
740
  firstTitle: t.slide === 1 ? t.title : "",
@@ -734,46 +744,46 @@ function it(e, t) {
734
744
  };
735
745
  return e.latest[t.mode] = i, i;
736
746
  }
737
- function at(e, t, n, r) {
747
+ function ot(e, t, n, r) {
738
748
  t.current = n.slide, t.shownAt = Date.now(), e.lastShown = t;
739
749
  let i = n.mode === "steps" ? "step" : "slide", { uuid: a, ...o } = r;
740
750
  return {
741
751
  ...o,
742
752
  message: `${i} ${n.slide} of ${n.totalSlides} is on the screen again, as it was`,
743
- instructions: k(n),
753
+ instructions: A(n),
744
754
  instructionsRequired: !0,
745
- sequence: tt(n)
755
+ sequence: nt(n)
746
756
  };
747
757
  }
748
- function ot(e, t) {
758
+ function st(e, t) {
749
759
  if (e.mode !== "steps") return e.title ? `A presentation slide titled "${e.title}". ${e.imagePrompt}` : e.imagePrompt;
750
760
  let n = e.title ? `, "${e.title}"` : "";
751
761
  return [
752
762
  `An instructional illustration of step ${e.slide} of ${e.totalSlides}${n}. ${e.imagePrompt}`,
753
- t ? st : "",
763
+ t ? ct : "",
754
764
  "Show the action clearly, with little or no text."
755
765
  ].filter(Boolean).join(" ");
756
766
  }
757
- var st = "The reference image is the previous step: keep the same objects, hands, tools and setting, and show what this step changes.";
758
- async function ct(e, t, n) {
767
+ var ct = "The reference image is the previous step: keep the same objects, hands, tools and setting, and show what this step changes.";
768
+ async function lt(e, t, n) {
759
769
  if (n.mode !== "steps") return [];
760
- let r = B(t.slides.get(n.slide - 1)).imagePath;
761
- return r ? await G(e, [r]) : [];
770
+ let r = V(t.slides.get(n.slide - 1)).imagePath;
771
+ return r ? await K(e, [r]) : [];
762
772
  }
763
- var lt = (e, t) => [
773
+ var ut = (e, t) => [
764
774
  e.mode === "steps" ? `An instructional illustration for step ${e.slide} of ${e.totalSlides}${e.title ? `, "${e.title}"` : ""}. ${e.imagePrompt}` : `A picture for a presentation slide${e.title ? ` titled "${e.title}"` : ""}. ${e.imagePrompt}`,
765
- t ? st : "",
775
+ t ? ct : "",
766
776
  e.markdown ? "Keep the subject in the middle: the picture is cropped to a tall frame." : "",
767
777
  "No text, letters or numbers in the picture."
768
778
  ].filter(Boolean).join(" ");
769
- async function ut(e, t, n) {
779
+ async function dt(e, t, n) {
770
780
  if (n.chart) return {
771
781
  chart: n.chart,
772
782
  prompt: ""
773
783
  };
774
784
  if (n.html || n.markdown) {
775
785
  let r = n.html ? { html: n.html } : {
776
- html: await Ue(n.markdown ?? ""),
786
+ html: await We(n.markdown ?? ""),
777
787
  markdown: n.markdown ?? ""
778
788
  };
779
789
  if (!y(r.html)) return {
@@ -783,7 +793,7 @@ async function ut(e, t, n) {
783
793
  let i = n.imagePrompt || ie(r.html) || n.title, a = {
784
794
  ...n,
785
795
  imagePrompt: i
786
- }, o = await ct(e, t, a), s = lt(a, o.length > 0), c = await K(e, s, o), { imageData: l, imagePath: u } = B(c);
796
+ }, o = await lt(e, t, a), s = ut(a, o.length > 0), c = await q(e, s, o), { imageData: l, imagePath: u } = V(c);
787
797
  return l ? {
788
798
  ...r,
789
799
  imageData: l,
@@ -797,7 +807,7 @@ async function ut(e, t, n) {
797
807
  pictureFailed: c.message
798
808
  };
799
809
  }
800
- let r = await ct(e, t, n), i = ot(n, r.length > 0), a = await K(e, i, r), { imageData: o, imagePath: s } = B(a);
810
+ let r = await lt(e, t, n), i = st(n, r.length > 0), a = await q(e, i, r), { imageData: o, imagePath: s } = V(a);
801
811
  return o ? {
802
812
  imageData: o,
803
813
  ...s && { imagePath: s },
@@ -807,10 +817,10 @@ async function ut(e, t, n) {
807
817
  sequence: null
808
818
  } };
809
819
  }
810
- async function dt(e, t, n) {
811
- let r = await ut(e, t, n);
820
+ async function ft(e, t, n) {
821
+ let r = await dt(e, t, n);
812
822
  if ("failed" in r) return r.failed;
813
- let { imageData: i, imagePath: a, html: o, markdown: s, chart: c, prompt: l, pictureFailed: u } = r, d = t.id, f = await Z(e.files?.artifacts, We, d, (e) => {
823
+ let { imageData: i, imagePath: a, html: o, markdown: s, chart: c, prompt: l, pictureFailed: u } = r, d = t.id, f = await Q(e.files?.artifacts, Ge, d, (e) => {
814
824
  let t = e ?? {
815
825
  id: d,
816
826
  title: "",
@@ -846,21 +856,21 @@ async function dt(e, t, n) {
846
856
  `${m} ${n.slide} of ${n.totalSlides} of slideshow "${d}" is on the screen`,
847
857
  a ? `saved to ${a}` : "",
848
858
  u ? `its picture couldn't be drawn (${u}), so the slide is shown without it` : "",
849
- f ? "" : Q("slideshow")
859
+ f ? "" : $("slideshow")
850
860
  ].filter(Boolean).join("; "),
851
- instructions: k(n),
861
+ instructions: A(n),
852
862
  instructionsRequired: !0,
853
- sequence: tt(n)
863
+ sequence: nt(n)
854
864
  };
855
865
  }
856
- async function $(e, t) {
857
- let n = xe(t);
866
+ async function pt(e, t) {
867
+ let n = k(t);
858
868
  if (typeof n == "string") return {
859
869
  message: n,
860
870
  sequence: null
861
871
  };
862
- let r = rt(e), i = it(r, n), a = n.mode === "steps";
863
- if (a && n.slide > i.current && i.current > 0 && !U(e, i.shownAt)) {
872
+ let r = it(e), i = at(r, n), a = n.mode === "steps";
873
+ if (a && n.slide > i.current && i.current > 0 && !W(e, i.shownAt)) {
864
874
  console.info(`[sequence] holding step ${n.slide} for the user`);
865
875
  let e = i.shownAt === Infinity ? "is still being drawn" : "is still on the screen";
866
876
  return {
@@ -869,15 +879,15 @@ async function $(e, t) {
869
879
  };
870
880
  }
871
881
  let o = a ? i.slides.get(n.slide) : void 0;
872
- if (o) return ke(e.currentResult, o) ? {
882
+ if (o) return Oe(e.currentResult, o) ? {
873
883
  message: `step ${n.slide} of ${n.totalSlides} is already on the screen`,
874
884
  cancelled: !0
875
- } : at(r, i, n, o);
876
- let s = r.repeats.claim(nt(i.id, n));
885
+ } : ot(r, i, n, o);
886
+ let s = r.repeats.claim(rt(i.id, n));
877
887
  if ("earlier" in s) {
878
- if (!await s.earlier) return $(e, t);
888
+ if (!await s.earlier) return pt(e, t);
879
889
  let a = i.slides.get(n.slide);
880
- return a && r.lastShown !== i ? at(r, i, n, a) : {
890
+ return a && r.lastShown !== i ? ot(r, i, n, a) : {
881
891
  message: `slide ${n.slide} of ${n.totalSlides} is already on the screen`,
882
892
  cancelled: !0
883
893
  };
@@ -889,22 +899,22 @@ async function $(e, t) {
889
899
  i.current = n.slide, i.shownAt = Infinity;
890
900
  let u = !1;
891
901
  try {
892
- let t = await dt(e, i, n);
893
- return u = Oe(t), u && (i.slides.set(n.slide, t), i.current = n.slide, i.shownAt = Date.now(), r.lastShown = i), t;
902
+ let t = await ft(e, i, n);
903
+ return u = De(t), u && (i.slides.set(n.slide, t), i.current = n.slide, i.shownAt = Date.now(), r.lastShown = i), t;
894
904
  } finally {
895
905
  c(u), !u && i.current === n.slide && (i.current = l.current, i.shownAt = l.shownAt);
896
906
  }
897
907
  }
898
908
  //#endregion
899
909
  //#region src/core/storyboard.ts
900
- var ft = ({ id: e, title: t, totalPanels: n }) => ({
910
+ var mt = ({ id: e, title: t, totalPanels: n }) => ({
901
911
  step: 0,
902
912
  total: n,
903
913
  kind: "story",
904
914
  label: `The cast of "${t}"`,
905
915
  onShown: "introduce the characters",
906
916
  nextCall: `call presentPanel for panel 1 of ${n} with storyboardId "${e}"`
907
- }), pt = ({ id: e, totalPanels: t }, n, r) => ({
917
+ }), ht = ({ id: e, totalPanels: t }, n, r) => ({
908
918
  step: n,
909
919
  total: t,
910
920
  kind: "story",
@@ -912,21 +922,21 @@ var ft = ({ id: e, title: t, totalPanels: n }) => ({
912
922
  onShown: "tell that part of the story",
913
923
  nextCall: `call presentPanel for panel ${n + 1} of ${t} with storyboardId "${e}"`,
914
924
  ...r.length > 0 && { waitsForUser: !0 }
915
- }), mt = (e, t) => e ? `${e}. ${t}` : t, ht = (e, { name: t, description: n }) => mt(e, `Character reference sheet of ${t}: ${n}. Full body, front, side and back views, on a plain white background. No text or labels.`);
916
- async function gt(e, t) {
917
- let n = j(t);
925
+ }), gt = (e, t) => e ? `${e}. ${t}` : t, _t = (e, { name: t, description: n }) => gt(e, `Character reference sheet of ${t}: ${n}. Full body, front, side and back views, on a plain white background. No text or labels.`);
926
+ async function vt(e, t) {
927
+ let n = M(t);
918
928
  if (typeof n == "string") return {
919
929
  message: n,
920
930
  sequence: null
921
931
  };
922
- let r = await Promise.all(n.characters.map((t) => K(e, ht(n.style, t)))), i = r.map(B), a = r.find((e, t) => !i[t]?.imageData);
932
+ let r = await Promise.all(n.characters.map((t) => q(e, _t(n.style, t)))), i = r.map(V), a = r.find((e, t) => !i[t]?.imageData);
923
933
  if (i.every(({ imageData: e }) => !e) && a) return {
924
934
  ...a,
925
935
  message: `the character sheets couldn't be made: ${a.message}`,
926
936
  sequence: null
927
937
  };
928
938
  let o = {
929
- id: W(),
939
+ id: G(),
930
940
  ...n,
931
941
  characters: n.characters.map((e, t) => {
932
942
  let n = i[t]?.imagePath;
@@ -936,7 +946,7 @@ async function gt(e, t) {
936
946
  };
937
947
  }),
938
948
  panels: {}
939
- }, s = await Z(e.files?.artifacts, X, o.id, () => o), c = o.characters.filter((e) => e.imagePath).map((e) => `${e.name}: ${e.imagePath}`), l = n.characters.map(({ name: e }, t) => i[t]?.imageData ? null : `${e} (${r[t]?.message ?? ""})`).filter((e) => !!e), u = i.find((e) => e.imageData)?.imageData;
949
+ }, s = await Q(e.files?.artifacts, Z, o.id, () => o), c = o.characters.filter((e) => e.imagePath).map((e) => `${e.name}: ${e.imagePath}`), l = n.characters.map(({ name: e }, t) => i[t]?.imageData ? null : `${e} (${r[t]?.message ?? ""})`).filter((e) => !!e), u = i.find((e) => e.imageData)?.imageData;
940
950
  return {
941
951
  data: {
942
952
  storyboardId: o.id,
@@ -957,39 +967,39 @@ async function gt(e, t) {
957
967
  `storyboard "${o.id}" is ready with ${o.totalPanels} panels; the cast is on the screen`,
958
968
  c.length ? `character sheets saved to ${c.join(", ")}` : "",
959
969
  l.length ? `no sheet for ${l.join("; ")}: they will be drawn from their description` : "",
960
- s ? "" : Q("storyboard")
970
+ s ? "" : $("storyboard")
961
971
  ].filter(Boolean).join("; "),
962
- instructions: M(o),
972
+ instructions: N(o),
963
973
  instructionsRequired: !0,
964
- sequence: ft(o)
974
+ sequence: mt(o)
965
975
  };
966
976
  }
967
- function _t(e, t, n) {
968
- let r = [mt(e.style, `Panel ${t.panel} of ${e.totalPanels} of the illustrated story "${e.title}". ${t.imagePrompt}`)], i = 0, a = n.map(({ character: e, hasSheet: t }) => t ? `${e.name} is the character in reference image ${++i}` : `${e.name}: ${e.description}`);
977
+ function yt(e, t, n) {
978
+ let r = [gt(e.style, `Panel ${t.panel} of ${e.totalPanels} of the illustrated story "${e.title}". ${t.imagePrompt}`)], i = 0, a = n.map(({ character: e, hasSheet: t }) => t ? `${e.name} is the character in reference image ${++i}` : `${e.name}: ${e.description}`);
969
979
  return a.length && r.push(`${a.join(". ")}.`), i && r.push("Draw each character exactly as in their reference image: the same face, hair, clothes and colors. Use the reference images only for how the characters look, not for their pose or the background."), r.push("No captions, speech bubbles or other text in the picture."), r.join(" ");
970
980
  }
971
- async function vt(e, t, n) {
981
+ async function bt(e, t, n) {
972
982
  let r = [], i = [];
973
983
  for (let a of n.characters) {
974
- let n = t.characters.find((e) => D(e.name, a));
984
+ let n = t.characters.find((e) => T(e.name, a));
975
985
  if (!n) r.push(a);
976
986
  else if (!i.some((e) => e.character === n)) {
977
- let [t] = n.imagePath ? await G(e, [n.imagePath]) : [];
987
+ let [t] = n.imagePath ? await K(e, [n.imagePath]) : [];
978
988
  i.push({
979
989
  character: n,
980
990
  sheet: t ?? null
981
991
  });
982
992
  }
983
993
  }
984
- let a = i.map(({ sheet: e }) => e).filter((e) => !!e), o = _t(t, n, i.map(({ character: e, sheet: t }) => ({
994
+ let a = i.map(({ sheet: e }) => e).filter((e) => !!e), o = yt(t, n, i.map(({ character: e, sheet: t }) => ({
985
995
  character: e,
986
996
  hasSheet: !!t
987
- }))), s = await K(e, o, a), { imageData: c, imagePath: l } = B(s);
997
+ }))), s = await q(e, o, a), { imageData: c, imagePath: l } = V(s);
988
998
  if (!c) return {
989
999
  ...s,
990
1000
  sequence: null
991
1001
  };
992
- let u = n.panel < t.totalPanels && n.choices.length >= 2 ? n.choices : [], d = await Z(e.files?.artifacts, X, t.id, (e) => {
1002
+ let u = n.panel < t.totalPanels && n.choices.length >= 2 ? n.choices : [], d = await Q(e.files?.artifacts, Z, t.id, (e) => {
993
1003
  let r = e ?? t;
994
1004
  return u.length && (r.interactive = !0), r.panels[String(n.panel)] = {
995
1005
  caption: n.caption,
@@ -1015,25 +1025,25 @@ async function vt(e, t, n) {
1015
1025
  `panel ${n.panel} of ${t.totalPanels} is on the screen`,
1016
1026
  l ? `saved to ${l}` : "",
1017
1027
  r.length ? `not in the cast, so drawn from the prompt alone: ${r.join(", ")}` : "",
1018
- d ? "" : Q("storyboard")
1028
+ d ? "" : $("storyboard")
1019
1029
  ].filter(Boolean).join("; "),
1020
- instructions: F(t, n.panel, u),
1030
+ instructions: I(t, n.panel, u),
1021
1031
  instructionsRequired: !0,
1022
- sequence: pt(t, n.panel, u)
1032
+ sequence: ht(t, n.panel, u)
1023
1033
  };
1024
1034
  }
1025
- var yt = q(() => ({
1026
- repeats: et(),
1035
+ var xt = J(() => ({
1036
+ repeats: tt(),
1027
1037
  awaitingChoice: /* @__PURE__ */ new Map()
1028
1038
  }));
1029
- async function bt(e, t) {
1030
- let n = P(t);
1039
+ async function St(e, t) {
1040
+ let n = F(t);
1031
1041
  if (!n) return {
1032
- message: N,
1042
+ message: P,
1033
1043
  sequence: null
1034
1044
  };
1035
- let { storyboardId: r, panel: i } = n, { repeats: a, awaitingChoice: o } = yt(e), s = o.get(r);
1036
- if (s && i > s.panel && !U(e, s.shownAt)) return console.info(`[sequence] holding panel ${i} for the user`), {
1045
+ let { storyboardId: r, panel: i } = n, { repeats: a, awaitingChoice: o } = xt(e), s = o.get(r);
1046
+ if (s && i > s.panel && !W(e, s.shownAt)) return console.info(`[sequence] holding panel ${i} for the user`), {
1037
1047
  message: s.shownAt === Infinity ? `panel ${i} was not shown: panel ${s.panel} is still being drawn. Wait for it before going on.` : `panel ${i} was not shown: the user hasn't picked a choice yet, and panel ${s.panel} is still on the screen. Wait for their answer.`,
1038
1048
  cancelled: !0
1039
1049
  };
@@ -1041,7 +1051,7 @@ async function bt(e, t) {
1041
1051
  if ("earlier" in c) return await c.earlier ? {
1042
1052
  message: `panel ${i} is already on the screen`,
1043
1053
  cancelled: !0
1044
- } : bt(e, t);
1054
+ } : St(e, t);
1045
1055
  let { settle: l } = c, u = {
1046
1056
  panel: i,
1047
1057
  shownAt: Infinity
@@ -1049,7 +1059,7 @@ async function bt(e, t) {
1049
1059
  o.set(r, u);
1050
1060
  let f = () => o.get(r) === u, p = !1;
1051
1061
  try {
1052
- let t = await Qe(e.files?.artifacts, X, r);
1062
+ let t = await $e(e.files?.artifacts, Z, r);
1053
1063
  if (!t) return {
1054
1064
  message: `there is no storyboard "${r}"; call defineStoryboard first`,
1055
1065
  sequence: null
@@ -1058,8 +1068,8 @@ async function bt(e, t) {
1058
1068
  message: `storyboard "${t.id}" has ${t.totalPanels} panels`,
1059
1069
  sequence: null
1060
1070
  };
1061
- let a = await vt(e, t, n);
1062
- p = !!B(a).imageData;
1071
+ let a = await bt(e, t, n);
1072
+ p = !!V(a).imageData;
1063
1073
  let s = a.data;
1064
1074
  return p && f() && (s?.choices?.length ? o.set(r, {
1065
1075
  panel: i,
@@ -1071,21 +1081,21 @@ async function bt(e, t) {
1071
1081
  }
1072
1082
  //#endregion
1073
1083
  //#region src/core/index.ts
1074
- var xt = {
1075
- toolDefinition: A,
1084
+ var Ct = {
1085
+ toolDefinition: j,
1076
1086
  generatingMessage: "Making the slide...",
1077
1087
  isEnabled: () => !0,
1078
- execute: (e, t) => $(e, t)
1079
- }, St = {
1080
- toolDefinition: L,
1088
+ execute: (e, t) => pt(e, t)
1089
+ }, wt = {
1090
+ toolDefinition: R,
1081
1091
  generatingMessage: "Drawing the characters...",
1082
1092
  isEnabled: () => !0,
1083
- execute: (e, t) => gt(e, t)
1084
- }, Ct = {
1085
- toolDefinition: R,
1093
+ execute: (e, t) => vt(e, t)
1094
+ }, Tt = {
1095
+ toolDefinition: z,
1086
1096
  generatingMessage: "Drawing the panel...",
1087
1097
  isEnabled: () => !0,
1088
- execute: (e, t) => bt(e, t)
1098
+ execute: (e, t) => St(e, t)
1089
1099
  };
1090
1100
  //#endregion
1091
- export { k as A, t as B, I as C, xe as D, P as E, s as F, oe as H, h as I, l as L, fe as M, r as N, j as O, o as P, n as R, ve as S, F as T, ae as U, y as V, A as _, X as a, _e as b, pe as c, ge as d, he as f, S as g, R as h, We as i, b as j, D as k, L as l, C as m, Ct as n, Qe as o, N as p, xt as r, Ue as s, St as t, me as u, Ee as v, M as w, ye as x, w as y, g as z };
1101
+ export { A, t as B, L as C, k as D, F as E, s as F, oe as H, h as I, l as L, fe as M, r as N, M as O, o as P, n as R, D as S, I as T, ae as U, y as V, j as _, Z as a, ye as b, pe as c, _e as d, ge as f, S as g, z as h, Ge as i, b as j, T as k, R as l, me as m, Tt as n, $e as o, P as p, Ct as r, We as s, wt as t, he as u, Te as v, N as w, O as x, ve as y, g as z };