@migma/mcp 1.11.11 → 1.11.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -95,12 +95,21 @@ dedicated origin ChatGPT requires of a published app (`openai/widgetDomain`).
95
95
 
96
96
  The same hosts show an email card (`ui://migma/email`) on `migma_generate_email`,
97
97
  `migma_get_generation_status`, `migma_edit_email` and `migma_get_email`: the steps
98
- while Migma designs or changes an email, then each email as its picture at real width,
99
- a series as tabs, full screen where the host has it, "Edit in Migma", and two asks
100
- sent to the chat ("Make it shorter", "Try another version").
101
- A status check shows one line that keeps itself current and turns into a Ready row that
102
- opens in place (ChatGPT draws only the last card of a reply). The card only reads
103
- `migma_get_generation_status`, `migma_get_email_edit_status` and `migma_get_email`.
98
+ while Migma designs or changes an email, then each email's first screen (the whole email
99
+ opens full screen, or in place where the host has no full screen), a series as tabs,
100
+ "Edit in Migma", and the path from ready to sent: Test, Audience, Send, one button for the
101
+ next step. Each step runs from the card on the user's click: a test to the account's own inbox
102
+ (`migma_send_test_email` with no `to`), the audience from the brand's segments and lists (when
103
+ the tool input or result names the brand), and a send that only prepares an approval
104
+ (`migma_send_email`, with the account's one sending address or the one the user picks), which the
105
+ user approves on migma.ai while the card reads `migma_get_send_approval`. A workspace connected
106
+ through managed sign-in may send only campaigns, so on that refusal (`WORKSPACE_KEY_SINGLE_SEND_REFUSED`,
107
+ passed through in the send tools' error as `{error, code}`) the card saves the same send as a
108
+ campaign draft (`migma_create_campaign`) and asks for its approval (`migma_send_campaign`). Full screen adds "Make it
109
+ shorter" (`migma_edit_email`, shown in place) and "Try another version" (a chat message). A host
110
+ that refuses a call gets the step as a chat message, and what the card did reaches the model
111
+ through `ui/update-model-context`. A status check shows one line that keeps itself current and
112
+ turns into a Ready row that opens in place (ChatGPT draws only the last card of a reply).
104
113
  The same `mcpApps` option turns it on or off. When the client draws the card, email
105
114
  results stop asking the assistant to paste previews or check progress in a loop: the
106
115
  card already shows them. That holds when the client advertises the
@@ -10,7 +10,13 @@ import { createMigmaMcpServer, createOpenAIMcpServer } from "../../index.js";
10
10
  import { EMAIL_CARD_HTML, EMAIL_CARD_URI } from "../email-card.js";
11
11
  import { IMAGE_ORIGINS } from "../mcp-apps.js";
12
12
  const EMAIL_TOOLS = ["migma_generate_email", "migma_get_generation_status", "migma_edit_email", "migma_get_email"];
13
- const CARD_READS = ["migma_get_email", "migma_get_email_edit_status", "migma_get_generation_status"];
13
+ // The card reads progress, emails, audiences, senders and approvals...
14
+ const CARD_READS = ["migma_get_email", "migma_get_email_edit_status", "migma_get_generation_status", "migma_get_send_approval", "migma_list_domains", "migma_list_segments", "migma_list_tags"];
15
+ // ...and writes only on a click: a test to the user's own inbox, a send that waits for the user's
16
+ // approval on migma.ai, and "Make it shorter".
17
+ // A managed workspace connection may only send campaigns, so the card's send falls back to a campaign
18
+ // draft and its approval (migma_create_campaign, migma_send_campaign) on that refusal.
19
+ const CARD_WRITES = ["migma_create_campaign", "migma_edit_email", "migma_send_campaign", "migma_send_email", "migma_send_test_email"];
14
20
  async function listed(createServer, options = {}) {
15
21
  const server = createServer({ client: {}, config: { apiKey: "sk_test" }, ...options });
16
22
  const client = new Client({ name: "card-test", version: "1" });
@@ -39,18 +45,33 @@ test("the four email tools open the email card; polls the card makes itself do n
39
45
  const content = read.contents[0];
40
46
  assert.equal(content.mimeType, "text/html;profile=mcp-app");
41
47
  assert.deepEqual(content._meta.ui.csp.resourceDomains, IMAGE_ORIGINS);
48
+ // OpenAI holds tools whose card CSP is missing or too broad: exact hosts only, and no network calls.
49
+ assert.deepEqual(IMAGE_ORIGINS, ["https://cdn.migma.ai"]);
50
+ assert.deepEqual(content._meta.ui.csp.connectDomains, []);
42
51
  assert.equal(content._meta.ui.prefersBorder, true);
43
52
  });
44
- test("the card only reads, and talks to nothing but the host", async () => {
53
+ test("the card reads, writes only on a click, and talks to nothing but the host", async () => {
45
54
  const { tools } = await listed(createMigmaMcpServer);
46
55
  const named = new Set([...EMAIL_CARD_HTML.matchAll(/"(migma_[a-z_]+)"/g)].map((m) => m[1]));
47
- assert.deepEqual([...named].sort(), CARD_READS);
48
- for (const name of named)
56
+ assert.deepEqual([...named].sort(), [...CARD_READS, ...CARD_WRITES].sort());
57
+ for (const name of CARD_READS)
49
58
  assert.equal(tools.find((t) => t.name === name)?.annotations?.readOnlyHint, true, `${name} is read-only`);
59
+ for (const name of CARD_WRITES)
60
+ assert.ok(tools.some((t) => t.name === name), `${name} exists`);
61
+ assert.match(tools.find((t) => t.name === "migma_send_email").description, /user approves it on migma\.ai/, "a send from the card only prepares an approval");
62
+ assert.match(tools.find((t) => t.name === "migma_create_campaign").description, /Sends nothing/, "the managed fallback saves a draft");
63
+ assert.match(EMAIL_CARD_HTML, /WORKSPACE_KEY_SINGLE_SEND_REFUSED/, "the fallback keys on the refusal's code, not its words");
50
64
  const requests = new Set([...EMAIL_CARD_HTML.matchAll(/request\("([a-z/-]+)"/g)].map((m) => m[1]));
51
- assert.deepEqual([...requests].sort(), ["tools/call", "ui/initialize", "ui/message", "ui/open-link", "ui/request-display-mode"]);
65
+ assert.deepEqual([...requests].sort(), ["tools/call", "ui/initialize", "ui/message", "ui/open-link", "ui/request-display-mode", "ui/update-model-context"]);
52
66
  assert.doesNotMatch(EMAIL_CARD_HTML, /fetch\(|XMLHttpRequest|sendBeacon|WebSocket|EventSource|import\(|<link /, "no network outside the host");
53
67
  });
68
+ test("the card shows no credits or prices, and plans only as a link", () => {
69
+ const visible = EMAIL_CARD_HTML.replace(/^\s*\/\/[^\n]*|\/\*[\s\S]*?\*\//gm, "");
70
+ assert.doesNotMatch(visible, /credit|\$\d/i);
71
+ // The one plans mention is the plans page, linked only beside a refusal that names the plan.
72
+ const plans = visible.match(/"[^"\n]*(?:upgrade|pricing|price)[^"\n]*"/gi) ?? [];
73
+ assert.deepEqual(plans, ['"https://migma.ai/pricing"']);
74
+ });
54
75
  test("the card script is valid JavaScript", () => {
55
76
  const script = EMAIL_CARD_HTML.match(/<script type="module">([\s\S]*)<\/script>/)?.[1];
56
77
  assert.ok(script);
@@ -1 +1 @@
1
- {"version":3,"file":"email-card.test.js","sourceRoot":"","sources":["../../../src/tools/__tests__/email-card.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,MAAM,WAAW,GAAG,CAAC,sBAAsB,EAAE,6BAA6B,EAAE,kBAAkB,EAAE,iBAAiB,CAAC,CAAC;AACnH,MAAM,UAAU,GAAG,CAAC,iBAAiB,EAAE,6BAA6B,EAAE,6BAA6B,CAAC,CAAC;AAErG,KAAK,UAAU,MAAM,CAAC,YAAyC,EAAE,UAAsD,EAAE;IACvH,MAAM,MAAM,GAAG,YAAY,CAAC,EAAE,MAAM,EAAE,EAAsB,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC3G,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;IAC/D,MAAM,C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B,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IACnH,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -61,6 +61,14 @@ test("campaign send and schedule go through approvals; server refusals pass thro
61
61
  assert.match(refused.content[0].text, /single recipient/);
62
62
  }, 400);
63
63
  });
64
+ test("a refusal's code passes through, so the email card can act on it", async () => {
65
+ const refusal = { success: false, error: "Single sends are not available through your workspace's managed connection. Create a campaign, or send from Migma.", code: "WORKSPACE_KEY_SINGLE_SEND_REFUSED" };
66
+ await withFetch(refusal, async () => {
67
+ const refused = await call(tools().migma_send_email, { recipientType: "segment", recipientId: "s1", from: "a@b.co", fromName: "B", subject: "S", emailId: "e1" });
68
+ assert.equal(refused.isError, true);
69
+ assert.deepEqual(JSON.parse(refused.content[0].text), { error: refusal.error, code: refusal.code });
70
+ }, 403);
71
+ });
64
72
  test("migma_get_send_approval reports the outcome; it needs a send scope", async () => {
65
73
  await withFetch({ success: true, data: { ...view, status: "sent", result: { status: "sent", sentCount: 1 }, decidedAt: "2031-01-01T10:00:00Z" } }, async (calls) => {
66
74
  const result = await call(tools().migma_get_send_approval, { approvalId: "a1" });
@@ -1 +1 @@
1
- {"version":3,"file":"send-approval.test.js","sourceRoot":"","sources":["../../../src/tools/__tests__/send-approval.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKlD,SAAS,KAAK,CAAC,WAAsB;IACnC,MAAM,MAAM,GAAG,oBAAoB,CAAC;QA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,CAAC,GAAG,CAAC,CAAC;IAC1H,MAAM,CAAC,KAAK,CAAC,IAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,qBAAqB,CAAC,EAAE,kBAAkB,CAAC,CAAC;AACrF,CAAC,CAAC,CAAC"}
@@ -1,10 +1,12 @@
1
1
  import type { Config } from "../config.js";
2
+ /** `code` is the API's machine-readable refusal (e.g. WORKSPACE_KEY_SINGLE_SEND_REFUSED), when it sends one. */
2
3
  export type ApiResult = {
3
4
  ok: true;
4
5
  data: unknown;
5
6
  } | {
6
7
  ok: false;
7
8
  error: string;
9
+ code?: string;
8
10
  };
9
11
  /** Public API call for routes the SDK does not cover; JSON unless a FormData body is passed. */
10
12
  export declare function apiRequest(config: Config, method: "GET" | "POST", path: string, body?: FormData | Record<string, unknown>, extraHeaders?: Record<string, string>): Promise<ApiResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"api-request.d.ts","sourceRoot":"","sources":["../../src/tools/api-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAI3C,MAAM,MAAM,SAAS,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAMnF,gGAAgG;AAChG,wBAAsB,UAAU,CAC9B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,KAAK,GAAG,MAAM,EACtB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,OAAO,CAAC,SAAS,CAAC,CA4BpB"}
1
+ {"version":3,"file":"api-request.d.ts","sourceRoot":"","sources":["../../src/tools/api-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAI3C,gHAAgH;AAChH,MAAM,MAAM,SAAS,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAMlG,gGAAgG;AAChG,wBAAsB,UAAU,CAC9B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,KAAK,GAAG,MAAM,EACtB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,OAAO,CAAC,SAAS,CAAC,CA6BpB"}
@@ -24,7 +24,8 @@ export async function apiRequest(config, method, path, body, extraHeaders) {
24
24
  });
25
25
  const json = (await response.json().catch(() => null));
26
26
  if (!response.ok || !json?.success) {
27
- return { ok: false, error: json?.error || `Request failed with status ${response.status}` };
27
+ const code = typeof json?.code === "string" ? json.code : undefined;
28
+ return { ok: false, error: json?.error || `Request failed with status ${response.status}`, ...(code ? { code } : {}) };
28
29
  }
29
30
  return { ok: true, data: json.data };
30
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"api-request.js","sourceRoot":"","sources":["../../src/tools/api-request.ts"],"names":[],"mappings":"AAEA,MAAM,gBAAgB,GAAG,yBAAyB,CAAC;AAInD,SAAS,cAAc,CAAC,MAAc;IACpC,OAAO,CAAC,MAAM,CAAC,OAAO,IAAI,gBAAgB,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACjE,CAAC;AAED,gGAAgG;AAChG,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,MAAc,EACd,MAAsB,EACtB,IAAY,EACZ,IAAyC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YACpE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,8BAA8B,QAAQ,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;QACzH,CAAC;QACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;IACvC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC;IACpF,CAAC;AACH,CAAC"}
@@ -1,14 +1,18 @@
1
1
  import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  /**
3
3
  * MCP Apps card for the email tools (generate, generation status, edit, get): progress while
4
- * Migma designs or changes an email, then each email as its picture at real width, a series
5
- * as tabs, "Edit in Migma" through ui/open-link, a few asks sent to the chat through
6
- * ui/message, and full screen where the host has it. It only reads: migma_get_generation_status,
7
- * migma_get_email_edit_status and migma_get_email. Hosts without MCP Apps read the text result.
4
+ * Migma designs or changes an email, then each email's first screen, a series as tabs, and the
5
+ * path from ready to sent (Test, Audience, Send). Each step runs on a click through tools/call: a
6
+ * test to the account's own inbox (migma_send_test_email), the audience from the brand's segments
7
+ * and lists, and a send that only prepares an approval (migma_send_email), which the user approves
8
+ * on migma.ai while the card reads it (migma_get_send_approval). "Make it shorter" changes the email
9
+ * in place (migma_edit_email). A host that refuses a call gets the step as a chat message
10
+ * (ui/message); what the card did reaches the model through ui/update-model-context. "Edit in
11
+ * Migma" goes through ui/open-link. Hosts without MCP Apps read the text result.
8
12
  */
9
13
  export declare const EMAIL_CARD_URI = "ui://migma/email";
10
14
  /** Tool `_meta` that links an email tool to the card, when the server shows it. */
11
15
  export declare function emailCardMeta(card: boolean): Record<string, unknown> | undefined;
12
16
  export declare function registerEmailCard(server: McpServer, card: boolean): void;
13
- export declare const EMAIL_CARD_HTML = "<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"color-scheme\" content=\"light dark\">\n<title>Email</title>\n<style>\n :root {\n color-scheme: light dark;\n --surface: var(--color-background-primary, light-dark(#ffffff, #30302e));\n --muted: var(--color-background-secondary, light-dark(#f5f4ed, #262624));\n --muted-2: var(--color-background-tertiary, light-dark(#ebe9df, #3a3a37));\n --text: var(--color-text-primary, light-dark(#141413, #faf9f5));\n --text-2: var(--color-text-secondary, light-dark(#3d3d3a, #c2c0b6));\n --text-3: var(--color-text-tertiary, light-dark(#73726c, #9c9a92));\n --line: var(--color-border-tertiary, light-dark(rgb(31 30 29 / 15%), rgb(222 220 209 / 15%)));\n --line-2: var(--color-border-secondary, light-dark(rgb(31 30 29 / 30%), rgb(222 220 209 / 30%)));\n --inverse: var(--color-background-inverse, light-dark(#141413, #faf9f5));\n --on-inverse: var(--color-text-inverse, light-dark(#ffffff, #141413));\n --info: var(--color-border-info, light-dark(#4682d5, #6c9be0));\n --success: var(--color-border-success, light-dark(#437426, #7fb05b));\n --danger: var(--color-border-danger, light-dark(#a73d39, #d1615c));\n --danger-text: var(--color-text-danger, light-dark(#7f2c28, #ee8884));\n --warning-text: var(--color-text-warning, light-dark(#5a4815, #d1a041));\n --radius: var(--border-radius-lg, 10px);\n --radius-md: var(--border-radius-md, 8px);\n }\n * { box-sizing: border-box; }\n html, body { margin: 0; background: transparent; }\n body {\n font-family: var(--font-sans, system-ui, -apple-system, sans-serif);\n font-size: var(--font-text-sm-size, 14px);\n line-height: var(--font-text-sm-line-height, 1.4);\n color: var(--text);\n -webkit-font-smoothing: antialiased;\n }\n p, h1, ul { margin: 0; }\n button { font: inherit; cursor: pointer; }\n button:focus-visible, .stage:focus-visible { outline: 2px solid var(--color-ring-primary, var(--info)); outline-offset: 2px; }\n button[disabled] { cursor: default; opacity: .5; }\n main {\n container-type: inline-size;\n padding: calc(16px + var(--inset-top, 0px)) calc(16px + var(--inset-right, 0px)) calc(16px + var(--inset-bottom, 0px)) calc(16px + var(--inset-left, 0px));\n }\n .i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }\n .i.big { width: 24px; height: 24px; }\n\n .head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }\n .title { min-width: 0; }\n h1 { font-size: var(--font-heading-md-size, 16px); line-height: var(--font-heading-md-line-height, 1.4); font-weight: var(--font-weight-semibold, 600); overflow-wrap: anywhere; }\n .pre { color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n .icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text-2); }\n .icon-btn:hover { background: var(--muted); }\n\n .stage { position: relative; margin-top: 12px; height: var(--stage-h, 520px); border-radius: var(--radius); background: var(--muted); overflow: auto; overscroll-behavior: contain; display: flex; justify-content: center; align-items: flex-start; padding: 16px; scrollbar-width: thin; }\n .stage.short { height: 240px; overflow: hidden; }\n .shot { width: min(600px, 100%); flex: none; border-radius: 4px; overflow: hidden; box-shadow: 0 0 0 0.5px var(--line); background: var(--surface); }\n .shot img { display: block; width: 100%; height: auto; }\n .shot.dim { opacity: .45; }\n .skel { width: min(600px, 100%); height: 100%; min-height: 200px; flex: none; border-radius: 4px; background: var(--surface); box-shadow: 0 0 0 0.5px var(--line); padding: 28px; display: flex; flex-direction: column; gap: 14px; overflow: hidden; }\n .sk { background: var(--muted-2); border-radius: 6px; flex: none; }\n .stage-note { position: absolute; inset: 0; margin: auto; height: fit-content; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px; color: var(--text-2); text-align: center; max-width: 340px; }\n .pill { display: inline-flex; gap: 8px; align-items: center; padding: 6px 12px; border-radius: 999px; background: var(--surface); box-shadow: 0 0 0 0.5px var(--line); color: var(--text-2); }\n\n .tabs { display: flex; gap: 4px; margin-top: 12px; overflow-x: auto; scrollbar-width: none; }\n .tab { display: inline-flex; gap: 8px; align-items: center; height: 36px; max-width: 220px; flex: none; padding: 0 12px 0 8px; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text-2); font-size: 13px; }\n .tab .n { display: grid; place-items: center; width: 20px; height: 20px; flex: none; border-radius: 50%; background: var(--muted); font-size: 12px; font-weight: 600; }\n .tab .t { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }\n .tab .d { color: var(--text-3); flex: none; }\n .tab[aria-selected=\"true\"] { background: var(--muted); color: var(--text); }\n .tab[aria-selected=\"true\"] .n { background: var(--inverse); color: var(--on-inverse); }\n\n .foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }\n .asks { display: flex; gap: 6px; flex-wrap: wrap; }\n .chip { display: inline-flex; gap: 6px; align-items: center; min-height: 32px; padding: 0 12px; border: 0.5px solid var(--line-2); border-radius: 999px; background: transparent; color: var(--text); font-size: 13px; font-weight: var(--font-weight-medium, 500); }\n .chip:hover { background: var(--muted); }\n .primary, .ghost { display: inline-flex; gap: 6px; align-items: center; justify-content: center; min-height: 36px; padding: 0 14px; border-radius: var(--radius-md); white-space: nowrap; font-weight: var(--font-weight-semibold, 600); }\n .primary { border: 0; background: var(--inverse); color: var(--on-inverse); margin-left: auto; }\n .ghost { border: 0.5px solid var(--line-2); background: transparent; color: var(--text); font-weight: var(--font-weight-medium, 500); margin-left: auto; }\n .ghost:hover { background: var(--muted); }\n @container (max-width: 420px) { .foot .primary, .foot .ghost { width: 100%; } }\n\n .status { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; color: var(--text-2); font-weight: var(--font-weight-medium, 500); }\n .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--text-3); }\n .dot.info { background: var(--info); } .dot.ok { background: var(--success); } .dot.bad { background: var(--danger); }\n .time { margin-left: auto; color: var(--text-3); font-variant-numeric: tabular-nums; font-weight: 400; }\n .steps { list-style: none; padding: 0; margin-top: 12px; display: grid; gap: 6px; }\n .steps li { display: flex; gap: 8px; align-items: center; color: var(--text-3); min-width: 0; }\n .steps li span:nth-child(2) { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }\n .steps li.now { color: var(--text); }\n .mark { display: grid; place-items: center; width: 16px; height: 16px; flex: none; }\n .ring { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--line-2); }\n .now .ring { border-color: var(--info); background: var(--info); }\n .note { margin-top: 12px; color: var(--text-2); overflow-wrap: anywhere; }\n .note.bad { color: var(--danger-text); }\n .note.warn { margin-top: 4px; color: var(--warning-text); }\n .note.small { color: var(--text-3); font-size: 13px; }\n\n .slots { display: flex; gap: 12px; margin-top: 12px; overflow-x: auto; }\n .slot { flex: 1 0 72px; min-width: 0; max-width: 200px; display: flex; flex-direction: column; gap: 8px; }\n .slot .frame { aspect-ratio: 3 / 4; border-radius: var(--radius-md); background: var(--muted); display: grid; place-items: center; color: var(--text-3); }\n .slot.done .frame { color: var(--success); }\n .slot .lab { display: flex; flex-wrap: wrap; column-gap: 6px; color: var(--text-2); font-size: 13px; }\n .slot .lab span:last-child { color: var(--text-3); margin-left: auto; }\n\n .line { display: flex; gap: 8px; align-items: center; min-height: 28px; color: var(--text-2); min-width: 0; }\n .line .t { color: var(--text); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }\n .line .s { color: var(--text-3); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }\n .line .thumb { width: 40px; height: 40px; flex: none; border-radius: 6px; overflow: hidden; box-shadow: 0 0 0 0.5px var(--line); background: var(--muted); }\n .line .thumb img { display: block; width: 100%; }\n .line .ghost, .line .primary { min-height: 30px; padding: 0 10px; font-size: 13px; margin-left: 0; }\n .line .ghost:first-of-type { margin-left: auto; }\n @container (max-width: 420px) { .line { flex-wrap: wrap; } .line .ghost:first-of-type { margin-left: 48px; } }\n\n :root:has(.fs), :root:has(.fs) body { height: 100%; }\n main:has(.fs) { height: 100%; padding: 0; }\n .fs { height: 100%; display: flex; flex-direction: column; }\n .fs > .head { padding: calc(14px + var(--inset-top, 0px)) calc(20px + var(--inset-right, 0px)) 14px calc(20px + var(--inset-left, 0px)); border-bottom: 0.5px solid var(--line); }\n .fs-body { flex: 1; display: flex; min-height: 0; }\n .rail { width: 200px; flex: none; padding: 16px; display: flex; flex-direction: column; gap: 12px; border-right: 0.5px solid var(--line); overflow-y: auto; }\n .rail-item { display: flex; flex-direction: column; gap: 6px; padding: 6px; border-radius: var(--radius); border: 0; background: transparent; text-align: left; color: var(--text-2); font-size: 13px; }\n .rail-item .thumb { height: 140px; border-radius: 6px; overflow: hidden; box-shadow: 0 0 0 0.5px var(--line); background: var(--muted); display: grid; place-items: center; color: var(--text-3); }\n .rail-item .thumb img { display: block; width: 100%; align-self: start; }\n .rail-item[aria-current=\"true\"] { background: var(--muted); color: var(--text); }\n .fs .stage { flex: 1; height: auto; margin: 0; border-radius: 0; padding: 24px; }\n .fs .foot { margin: 0; padding: 12px calc(20px + var(--inset-right, 0px)) calc(12px + var(--inset-bottom, 0px)) calc(20px + var(--inset-left, 0px)); border-top: 0.5px solid var(--line); }\n .fs .note { margin: 0; padding: 0 20px 12px; }\n .step-btn { position: absolute; top: 50%; margin-top: -18px; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; border: 0.5px solid var(--line); background: var(--surface); color: var(--text); }\n .step-btn.prev { left: 16px; } .step-btn.next { right: 16px; }\n .fs-wrap { flex: 1; position: relative; display: flex; min-width: 0; }\n .fs .tabs { display: none; margin: 0; padding: 8px calc(20px + var(--inset-right, 0px)) 8px calc(20px + var(--inset-left, 0px)); border-bottom: 0.5px solid var(--line); }\n /* Narrow full screen (Claude's side panel): tabs replace the rail and the arrows over the email. */\n @container (max-width: 720px) { .rail, .step-btn { display: none; } .fs .tabs { display: flex; } }\n\n @media (prefers-reduced-motion: no-preference) {\n .sk, .now .ring { animation: pulse 1.4s ease-in-out infinite; }\n @keyframes pulse { 50% { opacity: .55; } }\n }\n</style>\n</head>\n<body>\n<main id=\"card\" aria-busy=\"true\">\n <div class=\"sk\" style=\"height:16px;width:40%\"></div>\n <div class=\"sk\" style=\"height:12px;width:70%;margin-top:8px\"></div>\n <div class=\"stage short\"></div>\n</main>\n<script type=\"module\">\n const ICON = {\n expand: '<path d=\"M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7\"/>',\n collapse: '<path d=\"M4 14h6v6M20 10h-6V4M14 10l7-7M3 21l7-7\"/>',\n out: '<path d=\"M7 17L17 7M8 7h9v9\"/>',\n check: '<path d=\"M5 12l5 5L20 7\"/>',\n prev: '<path d=\"M15 18l-6-6 6-6\"/>',\n next: '<path d=\"M9 18l6-6-6-6\"/>',\n image: '<rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\"/><circle cx=\"9\" cy=\"9\" r=\"2\"/><path d=\"M21 15l-5-5L5 21\"/>',\n alert: '<circle cx=\"12\" cy=\"12\" r=\"9\"/><path d=\"M12 8v4M12 16h.01\"/>',\n };\n const EDIT_STEPS = [[\"Checking the email\", [\"queued\", \"checking\"]], [\"Changing it\", [\"editing\"]], [\"Saving\", [\"saved\"]]];\n const PICTURE_TRIES = 4;\n const $ = (id) => document.getElementById(id);\n const el = (tag, text, attrs = {}) => Object.assign(document.createElement(tag), { textContent: text ?? \"\" }, attrs);\n function icon(name, big) {\n const svg = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n svg.setAttribute(\"class\", big ? \"i big\" : \"i\");\n svg.setAttribute(\"viewBox\", \"0 0 24 24\");\n svg.setAttribute(\"aria-hidden\", \"true\");\n svg.innerHTML = ICON[name];\n return svg;\n }\n function button(className, label, onclick, attrs = {}) {\n const b = el(\"button\", label, { type: \"button\", className, ...attrs });\n b.addEventListener(\"click\", onclick);\n return b;\n }\n const https = (url) => (typeof url === \"string\" && url.startsWith(\"https://\") ? url : \"\");\n\n let host = {}, caps = {}, input = {}, s = null, sel = 0, nextId = 1, timer = 0, ticker = 0, delay = 3000, tries = 0, busy = false;\n const pending = new Map();\n\n function send(msg) { window.parent.postMessage({ jsonrpc: \"2.0\", ...msg }, \"*\"); }\n function request(method, params, ms) {\n const id = nextId++;\n send({ id, method, params });\n return new Promise((resolve, reject) => {\n pending.set(id, { resolve, reject });\n // A host that never answers must not stall the card's reads.\n if (ms) setTimeout(() => pending.delete(id) && reject(new Error(\"timeout\")), ms);\n });\n }\n\n window.addEventListener(\"message\", (event) => {\n if (event.source !== window.parent) return;\n const msg = event.data;\n if (!msg || msg.jsonrpc !== \"2.0\") return;\n if (msg.id !== undefined && !msg.method) {\n const waiter = pending.get(msg.id);\n pending.delete(msg.id);\n if (waiter) msg.error ? waiter.reject(msg.error) : waiter.resolve(msg.result);\n return;\n }\n if (msg.id !== undefined) {\n // Host requests (ping, teardown) need an answer; this card holds no state to save.\n send({ id: msg.id, result: {} });\n return;\n }\n if (msg.method === \"ui/notifications/tool-input\") input = msg.params?.arguments ?? {};\n if (msg.method === \"ui/notifications/tool-result\") onResult(msg.params);\n if (msg.method === \"ui/notifications/host-context-changed\") { applyHost(msg.params); if (s) render(); }\n });\n\n function applyHost(ctx = {}) {\n host = { ...host, ...ctx };\n const root = document.documentElement;\n if (ctx.theme) { root.dataset.theme = ctx.theme; root.style.colorScheme = ctx.theme; }\n for (const [key, value] of Object.entries(ctx.styles?.variables ?? {})) if (value) root.style.setProperty(key, value);\n if (ctx.styles?.css?.fonts && !$(\"host-fonts\")) document.head.append(el(\"style\", ctx.styles.css.fonts, { id: \"host-fonts\" }));\n const inset = ctx.safeAreaInsets;\n if (inset) for (const side of [\"top\", \"right\", \"bottom\", \"left\"]) root.style.setProperty(\"--inset-\" + side, (inset[side] || 0) + \"px\");\n root.dataset.mode = host.displayMode || \"inline\";\n // Inline, the email scrolls inside the card; keep the card within the height the host allows.\n const max = host.containerDimensions?.maxHeight;\n root.style.setProperty(\"--stage-h\", (max ? Math.max(240, Math.min(520, max - 200)) : innerWidth < 480 ? 420 : 520) + \"px\");\n }\n\n // Each tool puts its JSON in one text item among others (a lead sentence, guidance, the Previews list).\n const texts = (result) => (result?.content ?? []).filter((c) => c.type === \"text\").map((c) => c.text);\n function json(result) {\n for (const text of texts(result)) {\n try { const value = JSON.parse(text); if (value && typeof value === \"object\" && !Array.isArray(value)) return value; } catch {}\n }\n return null;\n }\n function toEmail(e = {}, link = \"\") {\n return {\n emailId: e.emailId || e.id || \"\",\n subject: e.subject || \"\",\n preheader: e.preheader || e.previewText || \"\",\n picture: https(e.screenshotFullUrl) || https(e.screenshotUrl) || https(e.thumbnailUrl),\n appUrl: https(e.appUrl) || link,\n failed: e.status === \"failed\",\n day: typeof e.sendOffsetDays === \"number\" ? e.sendOffsetDays : null,\n };\n }\n\n function onResult(result) {\n clearTimeout(timer);\n sel = 0; tries = 0;\n const data = json(result);\n if (result?.isError || !data || (data.error && !data.conversationId && !data.editId)) {\n const mode = input.emailId && input.prompt ? \"edit\" : input.prompt ? \"create\" : \"email\";\n // Refused before anything started (no credits, a locked email): trying again would only repeat it.\n s = { mode, phase: \"failed\", refused: true, emailId: input.emailId, count: input.count, error: (typeof data?.error === \"string\" && data.error) || (!data && texts(result)[0]) || \"Migma could not do this.\" };\n render();\n if (mode === \"edit\") readBefore();\n return;\n }\n if (data.editId) {\n s = { mode: \"edit\", phase: \"working\", emailId: data.emailId, editId: data.editId, appUrl: https(data.appUrl), createdAt: data.createdAt, stage: data.stage };\n delay = data.pollAfterMs || 2000;\n render();\n readBefore();\n poll();\n } else if (data.emailId && \"subject\" in data) {\n s = { mode: \"email\", phase: \"ready\", emails: [toEmail(data)] };\n render();\n if (missingPicture()) retryPicture();\n } else if (data.conversationId) {\n // A status check draws one line that turns into a Ready row, which opens in place. It keeps\n // itself current: ChatGPT shows only the last card of a reply, so the generate call's card may\n // never be seen.\n s = { mode: \"create\", phase: \"working\", compact: !!data.createdAt && !input.prompt, conversationId: data.conversationId, appUrl: https(data.appUrl), count: data.count || input.count };\n applyStatus(data);\n // Slower than the full card: several status lines can poll at once, and hosted MCP allows 100 calls a minute.\n delay = s.compact ? 6000 : 3000;\n render();\n poll();\n }\n }\n\n function applyStatus(d) {\n if (d.createdAt) s.createdAt = d.createdAt;\n if (d.status === \"failed\") { s.phase = \"failed\"; s.error = d.error || \"Migma could not create this email.\"; return; }\n if (d.status === \"completed\") {\n const r = d.result || {};\n const rows = Array.isArray(r.emails) && r.emails.length ? r.emails : [r];\n s.emails = rows.map((e) => toEmail(e, s.appUrl));\n s.phase = \"ready\";\n return;\n }\n const p = d.progress || {};\n const events = Array.isArray(p.events) ? p.events.filter((e) => e?.label) : [];\n const done = [...new Set(events.filter((e) => e.status === \"complete\").map((e) => e.label))];\n const live = p.now?.label && (p.now.status === \"start\" || p.now.status === \"progress\") ? p.now.label : \"\";\n s.now = live || events.filter((e) => e.status === \"processing\").pop()?.label || s.now || \"\";\n s.steps = done.filter((label) => label !== s.now).slice(-3);\n if (Array.isArray(p.slots) && p.slots.length) s.slots = p.slots;\n }\n\n function applyEdit(d) {\n if (d.createdAt) s.createdAt = d.createdAt;\n s.stage = d.stage || s.stage;\n if (d.status === \"completed\") {\n s.mode = \"email\"; s.phase = \"ready\";\n s.emails = [unchanged(toEmail(d.result || { emailId: s.emailId, subject: s.before?.subject }, s.before?.appUrl || s.appUrl), s.before?.picture)];\n } else if (d.status === \"failed\") {\n s.phase = \"failed\"; s.error = d.error || \"Migma could not change this email.\"; s.mayHaveSaved = !!d.changesMayHaveBeenSaved;\n }\n }\n\n // Right after a change the email can still carry its old picture until Migma captures the new\n // one: wait for a different picture, and show the old one only once the retries run out.\n function unchanged(e, old) {\n if (e.picture && e.picture === old) { e.stale = e.picture; e.picture = \"\"; }\n return e;\n }\n\n // Tried even when the host does not list serverTools or openLinks: a refusal falls back.\n async function read(name, args) {\n try {\n const result = await request(\"tools/call\", { name, arguments: args }, 30000);\n return result?.isError ? null : json(result);\n } catch { return null; }\n }\n\n async function readBefore() {\n if (!s?.emailId) return;\n const d = await read(\"migma_get_email\", { emailId: s.emailId });\n if (d?.emailId && s.mode !== \"email\") { s.before = toEmail(d); render(); }\n }\n\n async function poll() {\n clearTimeout(timer);\n if (!s || s.phase !== \"working\" || busy || document.visibilityState !== \"visible\") return;\n busy = true;\n if (s.mode === \"create\") {\n const d = await read(\"migma_get_generation_status\", { conversationId: s.conversationId });\n if (d?.conversationId) applyStatus(d);\n } else {\n const d = await read(\"migma_get_email_edit_status\", { emailId: s.emailId, editId: s.editId });\n if (d?.status) applyEdit(d);\n }\n busy = false;\n render();\n if (s.phase === \"working\") {\n // ponytail: backoff to one read every 15 s; a push from Migma would replace polling if hosts add it.\n timer = setTimeout(poll, delay);\n delay = Math.min(delay * 1.4, 15000);\n } else if (missingPicture()) retryPicture();\n }\n\n const missingPicture = () => s?.phase === \"ready\" && s.emails.some((e) => !e.failed && !e.picture);\n // The picture is captured after the email is saved. Each read returns every picture of the\n // run, so try a few times, further apart, then say it is ready in Migma.\n function retryPicture() {\n clearTimeout(timer);\n if (tries >= PICTURE_TRIES) {\n for (const e of s.emails) if (!e.picture && e.stale) e.picture = e.stale;\n s.noPicture = true;\n return render();\n }\n timer = setTimeout(async () => {\n tries++;\n if (s.mode === \"create\") {\n const d = await read(\"migma_get_generation_status\", { conversationId: s.conversationId });\n if (d?.status === \"completed\") applyStatus(d);\n } else {\n const d = await read(\"migma_get_email\", { emailId: s.emails[0].emailId });\n if (d?.emailId) s.emails = [unchanged(toEmail(d, s.emails[0].appUrl), s.emails[0].stale)];\n }\n render();\n if (missingPicture()) retryPicture();\n }, 4000 * 2 ** tries);\n }\n\n function refreshSoon() { if (s?.phase === \"working\") { delay = 3000; poll(); } }\n document.addEventListener(\"visibilitychange\", () => document.visibilityState === \"visible\" && refreshSoon());\n window.addEventListener(\"focus\", refreshSoon);\n\n function elapsed() {\n const start = Date.parse(s.createdAt);\n if (!start) return \"\";\n const secs = Math.max(0, Math.round((Date.now() - start) / 1000));\n return Math.floor(secs / 60) + \":\" + String(secs % 60).padStart(2, \"0\");\n }\n function tick() {\n clearInterval(ticker);\n if (s.phase !== \"working\" || !s.createdAt) return;\n ticker = setInterval(() => document.querySelectorAll(\".time\").forEach((t) => { t.textContent = elapsed(); }), 1000);\n }\n\n // ---- actions ----\n async function openLink(url) {\n if (!url) return;\n try { const r = await request(\"ui/open-link\", { url }); if (!r?.isError) return; } catch {}\n s.note = \"Could not open the link. Copy it: \" + url;\n render();\n }\n async function ask(text) {\n try {\n const r = await request(\"ui/message\", { role: \"user\", content: [{ type: \"text\", text }] });\n if (r?.isError) throw new Error();\n } catch {\n s.note = \"Could not send that to the chat. Type it there instead.\";\n render();\n }\n }\n async function displayMode(mode) {\n try { const r = await request(\"ui/request-display-mode\", { mode }); applyHost({ displayMode: r?.mode || host.displayMode }); } catch {}\n render();\n }\n const canFullScreen = () => (host.availableDisplayModes || []).includes(\"fullscreen\");\n const fullScreen = () => host.displayMode === \"fullscreen\" && s.phase === \"ready\" && !s.compact;\n function select(i) {\n sel = Math.max(0, Math.min(s.emails.length - 1, i));\n render();\n document.querySelector('[aria-selected=\"true\"], [aria-current=\"true\"]')?.focus();\n }\n document.addEventListener(\"keydown\", (event) => {\n if (!s || !fullScreen() || s.emails.length < 2 || event.target.closest?.('[role=\"tab\"]')) return;\n if (event.key === \"ArrowLeft\") select(sel - 1);\n if (event.key === \"ArrowRight\") select(sel + 1);\n });\n\n // ---- pieces ----\n const series = () => s.emails.length > 1;\n const quoted = (e) => (e.subject ? \"\u201C\" + e.subject + \"\u201D\" : \"this email\");\n const named = (e, i) => (series() ? \"email \" + (i + 1) + \" of the series, \" + quoted(e) + \",\" : quoted(e));\n const chip = (label, text) => button(\"chip\", label, () => ask(text));\n function asks(list) {\n const box = el(\"div\", \"\", { className: \"asks\" });\n if (caps.message) box.append(...list.map(([label, text]) => chip(label, text)));\n return box;\n }\n function linkButton(url, primary) {\n if (!url) return el(\"span\", \"\");\n const b = button(primary ? \"primary\" : \"ghost\", primary ? \"Edit in Migma\" : \"Open in Migma\", () => openLink(url));\n b.append(icon(\"out\"));\n return b;\n }\n function foot(list, url, primary) {\n const f = el(\"div\", \"\", { className: \"foot\" });\n f.append(asks(list), linkButton(url, primary));\n return f;\n }\n function head(title, pre, tools = []) {\n const h = el(\"div\", \"\", { className: \"head\" });\n const t = el(\"div\", \"\", { className: \"title\" });\n t.append(el(\"h1\", title));\n if (pre) t.append(el(\"p\", pre, { className: \"pre\", title: pre }));\n h.append(t);\n if (tools.length) { const box = el(\"div\", \"\", { className: \"tools\" }); box.append(...tools); h.append(box); }\n return h;\n }\n function statusLine(label, tone) {\n const p = el(\"p\", \"\", { className: \"status\" });\n p.append(el(\"span\", \"\", { className: \"dot \" + tone }), el(\"span\", label));\n return p;\n }\n function steps(items) {\n const ul = el(\"ul\", \"\", { className: \"steps\" });\n ul.setAttribute(\"aria-live\", \"polite\");\n for (const [label, state] of items) {\n const li = el(\"li\", \"\", { className: state });\n const mark = el(\"span\", \"\", { className: \"mark\" });\n mark.append(state === \"done\" ? icon(\"check\") : el(\"span\", \"\", { className: \"ring\" }));\n li.append(mark, el(\"span\", label));\n if (state === \"now\") li.append(el(\"span\", elapsed(), { className: \"time\" }));\n ul.append(li);\n }\n return ul;\n }\n function skeleton() {\n const box = el(\"div\", \"\", { className: \"skel\" });\n for (const [h, w, m] of [[14, 30, 0], [56, 85, 16], [56, 60, 0], [200, 100, 8]]) {\n box.append(el(\"div\", \"\", { className: \"sk\", style: \"height:\" + h + \"px;width:\" + w + \"%;margin-top:\" + m + \"px\" }));\n }\n return box;\n }\n function picture(e, dim) {\n const shot = el(\"div\", \"\", { className: dim ? \"shot dim\" : \"shot\" });\n const img = el(\"img\", \"\", { alt: (e.subject || \"Email\") + (dim ? \", before the change\" : \"\") });\n img.addEventListener(\"error\", () => { e.picture = \"\"; render(); if (missingPicture()) retryPicture(); }, { once: true });\n img.src = e.picture;\n shot.append(img);\n return shot;\n }\n function stageNote(iconName, text) {\n const note = el(\"div\", \"\", { className: \"stage-note\" });\n note.append(icon(iconName, true), el(\"p\", text));\n return note;\n }\n function stage(e, opts = {}) {\n const box = el(\"div\", \"\", { className: opts.short ? \"stage short\" : \"stage\" });\n if (e?.failed) {\n const ready = s.emails.filter((x) => !x.failed).length;\n box.append(stageNote(\"alert\", \"Migma could not create this email.\" + (ready ? \" The other \" + (ready === 1 ? \"one is\" : ready + \" are\") + \" ready.\" : \"\")));\n } else if (e?.picture) {\n box.append(picture(e, opts.dim));\n box.tabIndex = 0;\n box.setAttribute(\"aria-label\", (e.subject || \"Email\") + \", scroll to read\");\n } else if (opts.short || !s.noPicture || !e) {\n box.append(skeleton());\n if (e && !opts.short) {\n const note = el(\"p\", \"\", { className: \"stage-note\", role: \"status\" });\n const pill = el(\"span\", \"\", { className: \"pill\" });\n pill.append(el(\"span\", \"\", { className: \"dot info\" }), el(\"span\", \"Preparing the picture\"));\n note.append(pill);\n box.append(note);\n }\n } else {\n box.append(stageNote(\"image\", \"No picture of this email yet. It is ready in Migma.\"));\n }\n return box;\n }\n function tabs() {\n const list = el(\"div\", \"\", { className: \"tabs\", role: \"tablist\" });\n list.setAttribute(\"aria-label\", \"Emails in this series\");\n s.emails.forEach((e, i) => {\n const tab = button(\"tab\", \"\", () => select(i), { role: \"tab\" });\n tab.setAttribute(\"aria-selected\", String(i === sel));\n tab.tabIndex = i === sel ? 0 : -1;\n tab.append(el(\"span\", String(i + 1), { className: \"n\" }), el(\"span\", e.failed ? \"Not created\" : e.subject || \"Email \" + (i + 1), { className: \"t\" }));\n if (e.failed) tab.append(el(\"span\", \"\", { className: \"dot bad\" }));\n else if (e.day !== null) tab.append(el(\"span\", \"Day \" + e.day, { className: \"d\" }));\n tab.addEventListener(\"keydown\", (event) => {\n if (event.key === \"ArrowLeft\") select(i - 1);\n if (event.key === \"ArrowRight\") select(i + 1);\n });\n list.append(tab);\n });\n return list;\n }\n function readyAsks(e, i) {\n if (e.failed) return [[\"Try this email again\", \"Try creating email \" + (i + 1) + \" of the series again.\"]];\n return [\n [\"Make it shorter\", \"Make \" + named(e, i) + \" shorter.\"],\n [\"Try another version\", \"Make another version of \" + named(e, i).replace(/,$/, \"\") + \".\"],\n ];\n }\n\n // ---- views ----\n function compactView() {\n const line = el(\"div\", \"\", { className: \"line\", role: \"status\" });\n const many = (s.count || s.slots?.length || s.emails?.length || 1) > 1;\n if (s.phase === \"working\") {\n line.append(el(\"span\", \"\", { className: \"dot info\" }), el(\"span\", many ? \"Designing \" + (s.count || s.slots.length) + \" emails\" : \"Designing your email\", { className: \"t\" }));\n if (s.now) line.append(el(\"span\", s.now, { className: \"s\" }));\n line.append(el(\"span\", elapsed(), { className: \"time\" }));\n } else if (s.phase === \"failed\") {\n line.append(el(\"span\", \"\", { className: \"dot bad\" }), el(\"span\", \"Not created\", { className: \"t\" }), el(\"span\", s.error, { className: \"s\" }));\n } else {\n const first = s.emails.find((e) => e.picture);\n const thumb = el(\"span\", \"\", { className: \"thumb\" });\n if (first) thumb.append(el(\"img\", \"\", { src: first.picture, alt: \"\" }));\n line.append(thumb, el(\"span\", many ? s.emails.length + \" emails\" : s.emails[0].subject || \"Your email\", { className: \"t\" }), el(\"span\", \"Ready\", { className: \"s\" }));\n const show = button(\"ghost\", \"Show\", () => { s.compact = false; render(); if (missingPicture()) retryPicture(); });\n show.setAttribute(\"aria-expanded\", \"false\");\n line.append(show, linkButton(s.emails[0].appUrl || s.appUrl, true));\n }\n return [line];\n }\n\n function workingView() {\n if (s.mode === \"edit\") {\n const at = Math.max(0, EDIT_STEPS.findIndex(([, stages]) => stages.includes(s.stage)));\n return [\n head(s.before?.subject || \"Changing your email\", input.prompt),\n steps(EDIT_STEPS.map(([label], i) => [label, i < at ? \"done\" : i === at ? \"now\" : \"todo\"])),\n s.before?.picture ? stage(s.before, { dim: true }) : stage(null, { short: true }),\n foot([], s.before?.appUrl || s.appUrl, false),\n ];\n }\n const count = s.count || s.slots?.length || 1;\n const parts = [\n head(count > 1 ? \"Designing \" + count + \" emails\" : \"Designing your email\", input.prompt),\n steps([...(s.steps || []).map((label) => [label, \"done\"]), [s.now || \"Starting\", \"now\"]]),\n ];\n if (count > 1) {\n const slots = el(\"div\", \"\", { className: \"slots\" });\n for (let i = 0; i < count; i++) {\n const done = s.slots?.[i] && !s.slots[i].pending;\n const slot = el(\"div\", \"\", { className: done ? \"slot done\" : \"slot\" });\n const frame = el(\"div\", \"\", { className: \"frame\" });\n frame.append(done ? icon(\"check\", true) : el(\"span\", \"\", { className: \"dot info\" }));\n const lab = el(\"div\", \"\", { className: \"lab\" });\n lab.append(el(\"span\", \"Email \" + (i + 1)), el(\"span\", done ? \"Done\" : \"Designing\"));\n slot.append(frame, lab);\n slots.append(slot);\n }\n parts.push(slots);\n } else {\n parts.push(stage(null, { short: true }));\n }\n parts.push(foot([], s.appUrl, false));\n return parts;\n }\n\n function failedView() {\n if (s.mode === \"edit\") {\n const e = s.before;\n const parts = [statusLine(\"Not changed\", \"bad\"), head(e?.subject || \"Your email\", input.prompt), el(\"p\", s.error, { className: \"note bad\" })];\n if (s.mayHaveSaved) parts.push(el(\"p\", \"Some changes may have been saved. Check the email in Migma before you try again.\", { className: \"note warn\" }));\n if (e?.picture) parts.push(stage(e));\n parts.push(foot(input.prompt && !s.refused ? [[\"Try again\", \"Try that change to \" + (e ? quoted(e) : \"the email\") + \" again.\"]] : [], e?.appUrl || s.appUrl, true));\n return parts;\n }\n if (s.mode === \"email\") return [statusLine(\"Could not show this email\", \"bad\"), el(\"p\", s.error, { className: \"note bad\" })];\n const many = (s.count || 1) > 1;\n return [\n statusLine(\"Not created\", \"bad\"),\n head(many ? \"Your emails\" : \"Your email\", input.prompt),\n el(\"p\", s.error, { className: \"note bad\" }),\n foot(input.prompt && !s.refused ? [[\"Try again\", many ? \"Try creating those emails again.\" : \"Try creating that email again.\"]] : [], s.appUrl, false),\n ];\n }\n\n function readyView() {\n const e = s.emails[sel];\n const full = canFullScreen() ? [button(\"icon-btn\", \"\", () => displayMode(\"fullscreen\"), { ariaLabel: \"Full screen\" })] : [];\n full[0]?.append(icon(\"expand\"));\n const title = e.failed ? \"Email \" + (sel + 1) + \" was not created\" : e.subject || \"Your email\";\n const parts = [head(title, e.failed ? \"\" : e.preheader, full)];\n if (series()) parts.push(tabs());\n parts.push(stage(e), foot(readyAsks(e, sel), e.appUrl || s.appUrl, true));\n return parts;\n }\n\n function fullScreenView() {\n const e = s.emails[sel];\n const back = button(\"icon-btn\", \"\", () => displayMode(\"inline\"), { ariaLabel: \"Back to the chat\" });\n back.append(icon(\"collapse\"));\n const box = el(\"section\", \"\", { className: \"fs\" });\n const body = el(\"div\", \"\", { className: \"fs-body\" });\n if (series()) {\n const rail = el(\"nav\", \"\", { className: \"rail\" });\n rail.setAttribute(\"aria-label\", \"Emails in this series\");\n s.emails.forEach((x, i) => {\n const item = button(\"rail-item\", \"\", () => select(i));\n if (i === sel) item.setAttribute(\"aria-current\", \"true\");\n const thumb = el(\"div\", \"\", { className: \"thumb\" });\n thumb.append(x.picture ? el(\"img\", \"\", { src: x.picture, alt: \"\" }) : icon(x.failed ? \"alert\" : \"image\", true));\n item.append(thumb, el(\"span\", (i + 1) + (x.failed ? \" \u00B7 Not created\" : x.day !== null ? \" \u00B7 Day \" + x.day : \"\")));\n rail.append(item);\n });\n body.append(rail);\n }\n const wrap = el(\"div\", \"\", { className: \"fs-wrap\" });\n wrap.append(stage(e));\n if (series()) {\n const prev = button(\"step-btn prev\", \"\", () => select(sel - 1), { ariaLabel: \"Previous email\", disabled: sel === 0 });\n const next = button(\"step-btn next\", \"\", () => select(sel + 1), { ariaLabel: \"Next email\", disabled: sel === s.emails.length - 1 });\n prev.append(icon(\"prev\")); next.append(icon(\"next\"));\n wrap.append(prev, next);\n }\n body.append(wrap);\n box.append(head(e.failed ? \"Email \" + (sel + 1) + \" was not created\" : e.subject || \"Your email\", e.failed ? \"\" : e.preheader, [back]));\n if (series()) box.append(tabs());\n box.append(body, foot(readyAsks(e, sel), e.appUrl || s.appUrl, true));\n if (s.note) box.append(el(\"p\", s.note, { className: \"note small\" }));\n return [box];\n }\n\n function render() {\n const main = $(\"card\");\n main.setAttribute(\"aria-busy\", String(s.phase === \"working\" && !s.compact));\n let parts;\n if (s.compact) parts = compactView();\n else if (fullScreen()) parts = fullScreenView();\n else parts = s.phase === \"working\" ? workingView() : s.phase === \"failed\" ? failedView() : readyView();\n if (s.note && !fullScreen()) parts.push(el(\"p\", s.note, { className: \"note small\" }));\n main.replaceChildren(...parts);\n // ChatGPT's own \"Open in\" button in full screen opens this card's page unless told otherwise.\n const link = s.emails?.[sel]?.appUrl || s.before?.appUrl || s.appUrl;\n if (link) window.openai?.setOpenInAppUrl?.({ href: link });\n tick();\n }\n\n new ResizeObserver(() => send({ method: \"ui/notifications/size-changed\", params: { height: Math.ceil(document.documentElement.getBoundingClientRect().height) } }))\n .observe(document.documentElement);\n\n const init = await request(\"ui/initialize\", {\n appInfo: { name: \"Migma email\", version: \"1.0.0\" },\n appCapabilities: { availableDisplayModes: [\"inline\", \"fullscreen\"] },\n protocolVersion: \"2026-01-26\",\n });\n caps = init?.hostCapabilities ?? {};\n applyHost(init?.hostContext);\n send({ method: \"ui/notifications/initialized\", params: {} });\n</script>\n</body>\n</html>\n";
17
+ export declare const EMAIL_CARD_HTML = "<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"color-scheme\" content=\"light dark\">\n<title>Email</title>\n<style>\n :root {\n color-scheme: light dark;\n --surface: var(--color-background-primary, light-dark(#ffffff, #30302e));\n --muted: var(--color-background-secondary, light-dark(#f5f4ed, #262624));\n --muted-2: var(--color-background-tertiary, light-dark(#ebe9df, #3a3a37));\n --text: var(--color-text-primary, light-dark(#141413, #faf9f5));\n --text-2: var(--color-text-secondary, light-dark(#3d3d3a, #c2c0b6));\n --text-3: var(--color-text-tertiary, light-dark(#73726c, #9c9a92));\n --line: var(--color-border-tertiary, light-dark(rgb(31 30 29 / 15%), rgb(222 220 209 / 15%)));\n --line-2: var(--color-border-secondary, light-dark(rgb(31 30 29 / 30%), rgb(222 220 209 / 30%)));\n --inverse: var(--color-background-inverse, light-dark(#141413, #faf9f5));\n --on-inverse: var(--color-text-inverse, light-dark(#ffffff, #141413));\n --info: var(--color-border-info, light-dark(#4682d5, #6c9be0));\n --success: var(--color-border-success, light-dark(#437426, #7fb05b));\n --danger: var(--color-border-danger, light-dark(#a73d39, #d1615c));\n --danger-text: var(--color-text-danger, light-dark(#7f2c28, #ee8884));\n --warning-text: var(--color-text-warning, light-dark(#5a4815, #d1a041));\n --radius: var(--border-radius-lg, 10px);\n --radius-md: var(--border-radius-md, 8px);\n }\n * { box-sizing: border-box; }\n html, body { margin: 0; background: transparent; }\n body {\n font-family: var(--font-sans, system-ui, -apple-system, sans-serif);\n font-size: var(--font-text-sm-size, 14px);\n line-height: var(--font-text-sm-line-height, 1.4);\n color: var(--text);\n -webkit-font-smoothing: antialiased;\n }\n p, h1, ul { margin: 0; }\n button { font: inherit; cursor: pointer; }\n button:focus-visible, .stage:focus-visible { outline: 2px solid var(--color-ring-primary, var(--info)); outline-offset: 2px; }\n button[disabled] { cursor: default; opacity: .5; }\n main {\n container-type: inline-size;\n padding: calc(16px + var(--inset-top, 0px)) calc(16px + var(--inset-right, 0px)) calc(16px + var(--inset-bottom, 0px)) calc(16px + var(--inset-left, 0px));\n }\n .i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }\n .i.big { width: 24px; height: 24px; }\n\n .head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }\n .title { min-width: 0; }\n h1 { font-size: var(--font-heading-md-size, 16px); line-height: var(--font-heading-md-line-height, 1.4); font-weight: var(--font-weight-semibold, 600); overflow-wrap: anywhere; }\n .pre { color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n .icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text-2); }\n .icon-btn:hover { background: var(--muted); }\n\n .stage { position: relative; margin-top: 12px; height: var(--stage-h, 520px); border-radius: var(--radius); background: var(--muted); overflow: auto; overscroll-behavior: contain; display: flex; justify-content: center; align-items: flex-start; padding: 16px; scrollbar-width: thin; }\n .stage.short { height: 240px; overflow: hidden; }\n .shot { width: min(600px, 100%); flex: none; border-radius: 4px; overflow: hidden; box-shadow: 0 0 0 0.5px var(--line); background: var(--surface); }\n .shot img { display: block; width: 100%; height: auto; }\n .shot.dim { opacity: .45; }\n .skel { width: min(600px, 100%); height: 100%; min-height: 200px; flex: none; border-radius: 4px; background: var(--surface); box-shadow: 0 0 0 0.5px var(--line); padding: 28px; display: flex; flex-direction: column; gap: 14px; overflow: hidden; }\n .sk { background: var(--muted-2); border-radius: 6px; flex: none; }\n .stage-note { position: absolute; inset: 0; margin: auto; height: fit-content; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px; color: var(--text-2); text-align: center; max-width: 340px; }\n .pill { display: inline-flex; gap: 8px; align-items: center; padding: 6px 12px; border-radius: 999px; background: var(--surface); box-shadow: 0 0 0 0.5px var(--line); color: var(--text-2); }\n\n .tabs { display: flex; gap: 4px; margin-top: 12px; overflow-x: auto; scrollbar-width: none; }\n .tab { display: inline-flex; gap: 8px; align-items: center; height: 36px; max-width: 220px; flex: none; padding: 0 12px 0 8px; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text-2); font-size: 13px; }\n .tab .n { display: grid; place-items: center; width: 20px; height: 20px; flex: none; border-radius: 50%; background: var(--muted); font-size: 12px; font-weight: 600; }\n .tab .t { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }\n .tab .d { color: var(--text-3); flex: none; }\n .tab[aria-selected=\"true\"] { background: var(--muted); color: var(--text); }\n .tab[aria-selected=\"true\"] .n { background: var(--inverse); color: var(--on-inverse); }\n\n .foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }\n .asks { display: flex; gap: 6px; flex-wrap: wrap; }\n .chip { display: inline-flex; gap: 6px; align-items: center; min-height: 32px; padding: 0 12px; border: 0.5px solid var(--line-2); border-radius: 999px; background: transparent; color: var(--text); font-size: 13px; font-weight: var(--font-weight-medium, 500); }\n .chip:hover { background: var(--muted); }\n .primary, .ghost { display: inline-flex; gap: 6px; align-items: center; justify-content: center; min-height: 36px; padding: 0 14px; border-radius: var(--radius-md); white-space: nowrap; font-weight: var(--font-weight-semibold, 600); }\n .primary { border: 0; background: var(--inverse); color: var(--on-inverse); margin-left: auto; }\n .ghost { border: 0.5px solid var(--line-2); background: transparent; color: var(--text); font-weight: var(--font-weight-medium, 500); margin-left: auto; }\n .ghost:hover { background: var(--muted); }\n @container (max-width: 420px) { .foot .primary, .foot .ghost { width: 100%; } }\n\n .status { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; color: var(--text-2); font-weight: var(--font-weight-medium, 500); }\n .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--text-3); }\n .dot.info { background: var(--info); } .dot.ok { background: var(--success); } .dot.bad { background: var(--danger); }\n .time { margin-left: auto; color: var(--text-3); font-variant-numeric: tabular-nums; font-weight: 400; }\n .steps { list-style: none; padding: 0; margin-top: 12px; display: grid; gap: 6px; }\n .steps li { display: flex; gap: 8px; align-items: center; color: var(--text-3); min-width: 0; }\n .steps li span:nth-child(2) { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }\n .steps li.now { color: var(--text); }\n .mark { display: grid; place-items: center; width: 16px; height: 16px; flex: none; }\n .ring { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--line-2); }\n .now .ring { border-color: var(--info); background: var(--info); }\n .note { margin-top: 12px; color: var(--text-2); overflow-wrap: anywhere; }\n .note.bad { color: var(--danger-text); }\n .note.warn { margin-top: 4px; color: var(--warning-text); }\n .note.small { color: var(--text-3); font-size: 13px; }\n\n .slots { display: flex; gap: 12px; margin-top: 12px; overflow-x: auto; }\n .slot { flex: 1 0 72px; min-width: 0; max-width: 200px; display: flex; flex-direction: column; gap: 8px; }\n .slot .frame { aspect-ratio: 3 / 4; border-radius: var(--radius-md); background: var(--muted); display: grid; place-items: center; color: var(--text-3); }\n .slot.done .frame { color: var(--success); }\n .slot .lab { display: flex; flex-wrap: wrap; column-gap: 6px; color: var(--text-2); font-size: 13px; }\n .slot .lab span:last-child { color: var(--text-3); margin-left: auto; }\n\n .line { display: flex; gap: 8px; align-items: center; min-height: 28px; color: var(--text-2); min-width: 0; }\n .line .t { color: var(--text); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }\n .line .s { color: var(--text-3); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }\n .line .thumb { width: 40px; height: 40px; flex: none; border-radius: 6px; overflow: hidden; box-shadow: 0 0 0 0.5px var(--line); background: var(--muted); }\n .line .thumb img { display: block; width: 100%; }\n .line .ghost, .line .primary { min-height: 30px; padding: 0 10px; font-size: 13px; margin-left: 0; }\n .line .ghost:first-of-type { margin-left: auto; }\n @container (max-width: 420px) { .line { flex-wrap: wrap; } .line .ghost:first-of-type { margin-left: 48px; } }\n\n :root:has(.fs), :root:has(.fs) body { height: 100%; }\n main:has(.fs) { height: 100%; padding: 0; }\n .fs { height: 100%; display: flex; flex-direction: column; }\n .fs > .head { padding: calc(14px + var(--inset-top, 0px)) calc(20px + var(--inset-right, 0px)) 14px calc(20px + var(--inset-left, 0px)); border-bottom: 0.5px solid var(--line); }\n .fs-body { flex: 1; display: flex; min-height: 0; }\n .rail { width: 200px; flex: none; padding: 16px; display: flex; flex-direction: column; gap: 12px; border-right: 0.5px solid var(--line); overflow-y: auto; }\n .rail-item { display: flex; flex-direction: column; gap: 6px; padding: 6px; border-radius: var(--radius); border: 0; background: transparent; text-align: left; color: var(--text-2); font-size: 13px; }\n .rail-item .thumb { height: 140px; border-radius: 6px; overflow: hidden; box-shadow: 0 0 0 0.5px var(--line); background: var(--muted); display: grid; place-items: center; color: var(--text-3); }\n .rail-item .thumb img { display: block; width: 100%; align-self: start; }\n .rail-item[aria-current=\"true\"] { background: var(--muted); color: var(--text); }\n .fs .stage { flex: 1; height: auto; margin: 0; border-radius: 0; padding: 24px; }\n .fs .foot { margin: 0; padding: 12px calc(20px + var(--inset-right, 0px)) calc(12px + var(--inset-bottom, 0px)) calc(20px + var(--inset-left, 0px)); border-top: 0.5px solid var(--line); }\n .fs .note { margin: 0; padding: 0 20px 12px; }\n .step-btn { position: absolute; top: 50%; margin-top: -18px; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; border: 0.5px solid var(--line); background: var(--surface); color: var(--text); }\n .step-btn.prev { left: 16px; } .step-btn.next { right: 16px; }\n .fs-wrap { flex: 1; position: relative; display: flex; min-width: 0; }\n .fs .tabs { display: none; margin: 0; padding: 8px calc(20px + var(--inset-right, 0px)) 8px calc(20px + var(--inset-left, 0px)); border-bottom: 0.5px solid var(--line); }\n /* Narrow full screen (Claude's side panel): tabs replace the rail and the arrows over the email. */\n @container (max-width: 720px) { .rail, .step-btn { display: none; } .fs .tabs { display: flex; } }\n\n /* Ready: one line of status and fact, the email's first screen, the path from ready to sent. */\n :root { --pink: light-dark(#e31c5b, #f0587f); }\n .ready { display: flex; gap: 8px; align-items: center; min-height: 32px; margin: -6px 0 2px; color: var(--text-2); font-size: 13px; font-weight: var(--font-weight-medium, 500); }\n .ready .fact { display: inline-flex; gap: 4px; align-items: center; padding-left: 10px; margin-left: 2px; border-left: 0.5px solid var(--line-2); color: var(--text-3); font-weight: 400; }\n .ready .fact .i { width: 14px; height: 14px; color: var(--success); }\n .ready .brand { margin-left: auto; display: inline-flex; gap: 6px; align-items: center; color: var(--text-3); font-weight: 400; }\n .ready .brand i { width: 12px; height: 12px; border-radius: 3px; background: var(--pink); }\n .ready .icon-btn { margin-right: -8px; }\n @container (max-width: 420px) { .ready .fact { display: none; } }\n .stage.first { height: var(--first-h, 320px); overflow: hidden; }\n .stage.open { height: auto; overflow: visible; }\n .whole { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); min-height: 32px; padding: 0 14px; border: 0.5px solid var(--line-2); border-radius: 999px; background: var(--surface); color: var(--text); font-size: 13px; font-weight: var(--font-weight-medium, 500); white-space: nowrap; box-shadow: 0 2px 8px rgb(0 0 0 / 8%); }\n .whole:hover { background: var(--muted); }\n .path { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 12px; list-style: none; padding: 0; }\n .path.faded { opacity: .55; }\n .step { display: flex; flex-direction: column; gap: 4px; min-height: 72px; padding: 10px 12px; border-radius: var(--radius); background: var(--muted); min-width: 0; }\n .step .k { display: flex; gap: 6px; align-items: center; font-size: 13px; font-weight: var(--font-weight-semibold, 600); color: var(--text); }\n .step .k .i { width: 14px; height: 14px; }\n .step .v { font-size: 12.5px; color: var(--text-3); overflow-wrap: anywhere; }\n .step .s { margin-left: auto; display: grid; place-items: center; width: 18px; height: 18px; flex: none; border-radius: 50%; }\n .step .s.todo { width: 14px; height: 14px; border: 1.5px solid var(--line-2); }\n .step .s.asked { width: 14px; height: 14px; border: 2px solid var(--info); }\n .step .s.done { background: var(--success); color: #fff; }\n .step .s.done .i { width: 12px; height: 12px; stroke-width: 2.5; }\n .step .s.run { width: 14px; height: 14px; border: 2px solid var(--line-2); border-top-color: var(--pink); }\n .step .s.warn { width: 10px; height: 10px; background: var(--warning-text); }\n .step.warn .v { color: var(--warning-text); }\n .step.next { background: var(--surface); box-shadow: 0 0 0 1.5px var(--pink); }\n .step.done .v, .step.asked .v { color: var(--text-2); }\n @container (max-width: 420px) { .path { grid-template-columns: minmax(0, 1fr); } .step { min-height: 0; } }\n .pick { margin-top: 12px; padding: 12px; border-radius: var(--radius); background: var(--muted); display: flex; flex-direction: column; gap: 10px; }\n .pick-h { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 8px; font-size: 13px; font-weight: var(--font-weight-semibold, 600); }\n .pick-h span { color: var(--text-3); font-weight: 400; }\n .opts { display: flex; gap: 6px; flex-wrap: wrap; }\n .opt { display: inline-flex; gap: 8px; align-items: center; min-height: 36px; padding: 0 12px; border: 0.5px solid var(--line-2); border-radius: 999px; background: var(--surface); color: var(--text); font-size: 13px; font-weight: var(--font-weight-medium, 500); }\n .opt small { color: var(--text-3); font-size: 12px; font-weight: 400; font-variant-numeric: tabular-nums; }\n .opt[aria-pressed=\"true\"] { box-shadow: 0 0 0 1.5px var(--text); border-color: transparent; }\n .ghost.left { margin-left: 0; }\n .facts { margin: 12px 0 0; display: grid; grid-template-columns: 72px 1fr; gap: 6px 12px; padding: 12px; border-radius: var(--radius); background: var(--muted); font-size: 13px; }\n .facts dt { color: var(--text-3); }\n .facts dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }\n .panel .facts { margin: 0; }\n .note a.plans { color: inherit; text-decoration: underline; text-underline-offset: 3px; }\n\n /* Full screen: the whole email, the path in a panel beside it. */\n .desk { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 340px; grid-template-rows: minmax(0, 1fr); min-width: 0; min-height: 0; }\n .desk .fs-wrap { min-height: 0; }\n .panel { border-left: 0.5px solid var(--line); padding: 20px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }\n .panel h2 { margin: 0; font-size: 14px; font-weight: var(--font-weight-semibold, 600); }\n .panel .path { grid-template-columns: minmax(0, 1fr); margin-top: 0; }\n .panel .step { min-height: 0; }\n .panel .pick { margin-top: 0; }\n .panel .asks { margin-top: auto; padding-top: 12px; }\n @container (max-width: 720px) {\n .desk { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }\n .panel { border-left: 0; border-top: 0.5px solid var(--line); padding: 12px 20px; overflow: visible; }\n .panel h2 { display: none; }\n .panel .path { grid-template-columns: repeat(3, minmax(0, 1fr)); }\n .panel .asks { padding-top: 0; }\n }\n\n @media (prefers-reduced-motion: no-preference) {\n .sk, .now .ring { animation: pulse 1.4s ease-in-out infinite; }\n .step .s.run { animation: spin 0.9s linear infinite; }\n @keyframes spin { to { transform: rotate(360deg); } }\n @keyframes pulse { 50% { opacity: .55; } }\n }\n</style>\n</head>\n<body>\n<main id=\"card\" aria-busy=\"true\">\n <div class=\"sk\" style=\"height:16px;width:40%\"></div>\n <div class=\"sk\" style=\"height:12px;width:70%;margin-top:8px\"></div>\n <div class=\"stage short\"></div>\n</main>\n<script type=\"module\">\n const ICON = {\n expand: '<path d=\"M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7\"/>',\n collapse: '<path d=\"M4 14h6v6M20 10h-6V4M14 10l7-7M3 21l7-7\"/>',\n out: '<path d=\"M7 17L17 7M8 7h9v9\"/>',\n check: '<path d=\"M5 12l5 5L20 7\"/>',\n prev: '<path d=\"M15 18l-6-6 6-6\"/>',\n next: '<path d=\"M9 18l6-6-6-6\"/>',\n image: '<rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\"/><circle cx=\"9\" cy=\"9\" r=\"2\"/><path d=\"M21 15l-5-5L5 21\"/>',\n alert: '<circle cx=\"12\" cy=\"12\" r=\"9\"/><path d=\"M12 8v4M12 16h.01\"/>',\n mail: '<path d=\"M4 6h16v12H4zM4 7l8 6 8-6\"/>',\n people: '<circle cx=\"9\" cy=\"8\" r=\"3.5\"/><path d=\"M2.5 20a6.5 6.5 0 0113 0M16 4.5a3.5 3.5 0 010 7M18 14a6 6 0 013.5 6\"/>',\n send: '<path d=\"M21 3L10 14M21 3l-7 18-4-7-7-4z\"/>',\n };\n const CONTACTS_URL = \"https://migma.ai/contacts/imports\";\n const EDIT_STEPS = [[\"Checking the email\", [\"queued\", \"checking\"]], [\"Changing it\", [\"editing\"]], [\"Saving\", [\"saved\"]]];\n const PICTURE_TRIES = 4;\n const $ = (id) => document.getElementById(id);\n const el = (tag, text, attrs = {}) => Object.assign(document.createElement(tag), { textContent: text ?? \"\" }, attrs);\n function icon(name, big) {\n const svg = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n svg.setAttribute(\"class\", big ? \"i big\" : \"i\");\n svg.setAttribute(\"viewBox\", \"0 0 24 24\");\n svg.setAttribute(\"aria-hidden\", \"true\");\n svg.innerHTML = ICON[name];\n return svg;\n }\n function button(className, label, onclick, attrs = {}) {\n const b = el(\"button\", label, { type: \"button\", className, ...attrs });\n b.addEventListener(\"click\", onclick);\n return b;\n }\n const https = (url) => (typeof url === \"string\" && url.startsWith(\"https://\") ? url : \"\");\n\n let host = {}, caps = {}, input = {}, s = null, sel = 0, nextId = 1, timer = 0, ticker = 0, delay = 3000, tries = 0, busy = false;\n // The path from ready to sent: each email's steps (a series sends each email on its own), the\n // audience being picked, and whether the inline email is open to its full length.\n let brand = \"\", flow = {}, pick = null, whole = false, history = [];\n const pending = new Map();\n\n function send(msg) { window.parent.postMessage({ jsonrpc: \"2.0\", ...msg }, \"*\"); }\n function request(method, params, ms) {\n const id = nextId++;\n send({ id, method, params });\n return new Promise((resolve, reject) => {\n pending.set(id, { resolve, reject });\n // A host that never answers must not stall the card's reads.\n if (ms) setTimeout(() => pending.delete(id) && reject(new Error(\"timeout\")), ms);\n });\n }\n\n window.addEventListener(\"message\", (event) => {\n if (event.source !== window.parent) return;\n const msg = event.data;\n if (!msg || msg.jsonrpc !== \"2.0\") return;\n if (msg.id !== undefined && !msg.method) {\n const waiter = pending.get(msg.id);\n pending.delete(msg.id);\n if (waiter) msg.error ? waiter.reject(msg.error) : waiter.resolve(msg.result);\n return;\n }\n if (msg.id !== undefined) {\n // Host requests (ping, teardown) need an answer; this card holds no state to save.\n send({ id: msg.id, result: {} });\n return;\n }\n if (msg.method === \"ui/notifications/tool-input\") input = msg.params?.arguments ?? {};\n if (msg.method === \"ui/notifications/tool-result\") onResult(msg.params);\n if (msg.method === \"ui/notifications/host-context-changed\") { applyHost(msg.params); if (s) render(); }\n });\n\n function applyHost(ctx = {}) {\n host = { ...host, ...ctx };\n const root = document.documentElement;\n if (ctx.theme) { root.dataset.theme = ctx.theme; root.style.colorScheme = ctx.theme; }\n for (const [key, value] of Object.entries(ctx.styles?.variables ?? {})) if (value) root.style.setProperty(key, value);\n if (ctx.styles?.css?.fonts && !$(\"host-fonts\")) document.head.append(el(\"style\", ctx.styles.css.fonts, { id: \"host-fonts\" }));\n const inset = ctx.safeAreaInsets;\n if (inset) for (const side of [\"top\", \"right\", \"bottom\", \"left\"]) root.style.setProperty(\"--inset-\" + side, (inset[side] || 0) + \"px\");\n root.dataset.mode = host.displayMode || \"inline\";\n // Inline, the email shows its first screen (no scrolling inside the card); keep the card within\n // the height the host allows. While designing or changing, the stage keeps --stage-h.\n const max = host.containerDimensions?.maxHeight;\n root.style.setProperty(\"--stage-h\", (max ? Math.max(240, Math.min(520, max - 200)) : innerWidth < 480 ? 420 : 520) + \"px\");\n root.style.setProperty(\"--first-h\", (max ? Math.max(200, Math.min(340, max - 280)) : 320) + \"px\");\n }\n\n // Each tool puts its JSON in one text item among others (a lead sentence, guidance, the Previews list).\n const texts = (result) => (result?.content ?? []).filter((c) => c.type === \"text\").map((c) => c.text);\n function json(result) {\n for (const text of texts(result)) {\n try { const value = JSON.parse(text); if (value && typeof value === \"object\" && !Array.isArray(value)) return value; } catch {}\n }\n return null;\n }\n // Lists come back as an array, or as an object holding one.\n function rows(result) {\n for (const text of texts(result)) {\n try {\n const value = JSON.parse(text);\n if (Array.isArray(value)) return value;\n for (const key of [\"data\", \"segments\", \"tags\", \"items\"]) if (Array.isArray(value?.[key])) return value[key];\n } catch {}\n }\n return null;\n }\n function toEmail(e = {}, link = \"\") {\n return {\n emailId: e.emailId || e.id || \"\",\n subject: e.subject || \"\",\n preheader: e.preheader || e.previewText || \"\",\n picture: https(e.screenshotFullUrl) || https(e.screenshotUrl) || https(e.thumbnailUrl),\n appUrl: https(e.appUrl) || link,\n failed: e.status === \"failed\",\n day: typeof e.sendOffsetDays === \"number\" ? e.sendOffsetDays : null,\n };\n }\n\n function onResult(result) {\n clearTimeout(timer);\n sel = 0; tries = 0;\n const data = json(result);\n // The brand, for reading its audiences: the tool input names it on hosted servers.\n brand = (typeof input.projectId === \"string\" && input.projectId) || (typeof data?.projectId === \"string\" && data.projectId) || \"\";\n flow = {}; pick = null; whole = false; history = [];\n if (result?.isError || !data || (data.error && !data.conversationId && !data.editId)) {\n const mode = input.emailId && input.prompt ? \"edit\" : input.prompt ? \"create\" : \"email\";\n // Refused before anything started (no credits, a locked email): trying again would only repeat it.\n s = { mode, phase: \"failed\", refused: true, emailId: input.emailId, count: input.count, error: (typeof data?.error === \"string\" && data.error) || (!data && texts(result)[0]) || \"Migma could not do this.\" };\n render();\n if (mode === \"edit\") readBefore();\n return;\n }\n if (data.editId) {\n s = { mode: \"edit\", phase: \"working\", emailId: data.emailId, editId: data.editId, appUrl: https(data.appUrl), createdAt: data.createdAt, stage: data.stage };\n delay = data.pollAfterMs || 2000;\n render();\n readBefore();\n poll();\n } else if (data.emailId && \"subject\" in data) {\n s = { mode: \"email\", phase: \"ready\", emails: [toEmail(data)] };\n render();\n if (missingPicture()) retryPicture();\n } else if (data.conversationId) {\n // A status check draws one line that turns into a Ready row, which opens in place. It keeps\n // itself current: ChatGPT shows only the last card of a reply, so the generate call's card may\n // never be seen.\n s = { mode: \"create\", phase: \"working\", compact: !!data.createdAt && !input.prompt, conversationId: data.conversationId, appUrl: https(data.appUrl), count: data.count || input.count };\n applyStatus(data);\n // Slower than the full card: several status lines can poll at once, and hosted MCP allows 100 calls a minute.\n delay = s.compact ? 6000 : 3000;\n render();\n poll();\n }\n }\n\n function applyStatus(d) {\n if (d.createdAt) s.createdAt = d.createdAt;\n if (d.status === \"failed\") { s.phase = \"failed\"; s.error = d.error || \"Migma could not create this email.\"; return; }\n if (d.status === \"completed\") {\n const r = d.result || {};\n const rows = Array.isArray(r.emails) && r.emails.length ? r.emails : [r];\n s.emails = rows.map((e) => toEmail(e, s.appUrl));\n s.phase = \"ready\";\n return;\n }\n const p = d.progress || {};\n const events = Array.isArray(p.events) ? p.events.filter((e) => e?.label) : [];\n const done = [...new Set(events.filter((e) => e.status === \"complete\").map((e) => e.label))];\n const live = p.now?.label && (p.now.status === \"start\" || p.now.status === \"progress\") ? p.now.label : \"\";\n s.now = live || events.filter((e) => e.status === \"processing\").pop()?.label || s.now || \"\";\n s.steps = done.filter((label) => label !== s.now).slice(-3);\n if (Array.isArray(p.slots) && p.slots.length) s.slots = p.slots;\n }\n\n function applyEdit(d) {\n if (d.createdAt) s.createdAt = d.createdAt;\n s.stage = d.stage || s.stage;\n if (d.status === \"completed\") {\n s.mode = \"email\"; s.phase = \"ready\";\n s.emails = [unchanged(toEmail(d.result || { emailId: s.emailId, subject: s.before?.subject }, s.before?.appUrl || s.appUrl), s.before?.picture)];\n } else if (d.status === \"failed\") {\n s.phase = \"failed\"; s.error = d.error || \"Migma could not change this email.\"; s.mayHaveSaved = !!d.changesMayHaveBeenSaved;\n }\n }\n\n // Right after a change the email can still carry its old picture until Migma captures the new\n // one: wait for a different picture, and show the old one only once the retries run out.\n function unchanged(e, old) {\n if (e.picture && e.picture === old) { e.stale = e.picture; e.picture = \"\"; }\n return e;\n }\n\n // Tried even when the host does not list serverTools or openLinks: a refusal falls back.\n async function read(name, args) {\n try {\n const result = await request(\"tools/call\", { name, arguments: args }, 30000);\n return result?.isError ? null : json(result);\n } catch { return null; }\n }\n\n async function readBefore() {\n if (!s?.emailId) return;\n const d = await read(\"migma_get_email\", { emailId: s.emailId });\n if (d?.emailId && s.mode !== \"email\") { s.before = toEmail(d); render(); }\n }\n\n async function poll() {\n clearTimeout(timer);\n if (!s || s.phase !== \"working\" || busy || document.visibilityState !== \"visible\") return;\n busy = true;\n if (s.mode === \"create\") {\n const d = await read(\"migma_get_generation_status\", { conversationId: s.conversationId });\n if (d?.conversationId) applyStatus(d);\n } else {\n const d = await read(\"migma_get_email_edit_status\", { emailId: s.emailId, editId: s.editId });\n if (d?.status) applyEdit(d);\n }\n busy = false;\n render();\n if (s.phase === \"working\") {\n // ponytail: backoff to one read every 15 s; a push from Migma would replace polling if hosts add it.\n timer = setTimeout(poll, delay);\n delay = Math.min(delay * 1.4, 15000);\n } else if (missingPicture()) retryPicture();\n }\n\n const missingPicture = () => s?.phase === \"ready\" && s.emails.some((e) => !e.failed && !e.picture);\n // The picture is captured after the email is saved. Each read returns every picture of the\n // run, so try a few times, further apart, then say it is ready in Migma.\n function retryPicture() {\n clearTimeout(timer);\n if (tries >= PICTURE_TRIES) {\n for (const e of s.emails) if (!e.picture && e.stale) e.picture = e.stale;\n s.noPicture = true;\n return render();\n }\n timer = setTimeout(async () => {\n tries++;\n if (s.mode === \"create\") {\n const d = await read(\"migma_get_generation_status\", { conversationId: s.conversationId });\n if (d?.status === \"completed\") applyStatus(d);\n } else {\n const d = await read(\"migma_get_email\", { emailId: s.emails[0].emailId });\n if (d?.emailId) s.emails = [unchanged(toEmail(d, s.emails[0].appUrl), s.emails[0].stale)];\n }\n render();\n if (missingPicture()) retryPicture();\n }, 4000 * 2 ** tries);\n }\n\n function refreshSoon() { if (s?.phase === \"working\") { delay = 3000; poll(); } }\n document.addEventListener(\"visibilitychange\", () => document.visibilityState === \"visible\" && refreshSoon());\n window.addEventListener(\"focus\", refreshSoon);\n\n function elapsed() {\n const start = Date.parse(s.createdAt);\n if (!start) return \"\";\n const secs = Math.max(0, Math.round((Date.now() - start) / 1000));\n return Math.floor(secs / 60) + \":\" + String(secs % 60).padStart(2, \"0\");\n }\n function tick() {\n clearInterval(ticker);\n if (s.phase !== \"working\" || !s.createdAt) return;\n ticker = setInterval(() => document.querySelectorAll(\".time\").forEach((t) => { t.textContent = elapsed(); }), 1000);\n }\n\n // ---- actions ----\n async function openLink(url) {\n if (!url) return;\n try { const r = await request(\"ui/open-link\", { url }); if (!r?.isError) return; } catch {}\n s.note = \"Could not open the link. Copy it: \" + url;\n render();\n }\n async function ask(text) {\n try {\n const r = await request(\"ui/message\", { role: \"user\", content: [{ type: \"text\", text }] });\n if (r?.isError) throw new Error();\n return true;\n } catch {\n s.note = \"Could not send that to the chat. Type it there instead.\";\n render();\n return false;\n }\n }\n async function displayMode(mode) {\n try { const r = await request(\"ui/request-display-mode\", { mode }); applyHost({ displayMode: r?.mode || host.displayMode }); } catch {}\n render();\n }\n const canFullScreen = () => (host.availableDisplayModes || []).includes(\"fullscreen\");\n const fullScreen = () => host.displayMode === \"fullscreen\" && s.phase === \"ready\" && !s.compact;\n function select(i) {\n sel = Math.max(0, Math.min(s.emails.length - 1, i));\n render();\n document.querySelector('[aria-selected=\"true\"], [aria-current=\"true\"]')?.focus();\n }\n document.addEventListener(\"keydown\", (event) => {\n if (!s || !fullScreen() || s.emails.length < 2 || event.target.closest?.('[role=\"tab\"]')) return;\n if (event.key === \"ArrowLeft\") select(sel - 1);\n if (event.key === \"ArrowRight\") select(sel + 1);\n });\n\n // ---- pieces ----\n const series = () => s.emails.length > 1;\n const quoted = (e) => (e.subject ? \"\u201C\" + e.subject + \"\u201D\" : \"this email\");\n const named = (e, i) => (series() ? \"email \" + (i + 1) + \" of the series, \" + quoted(e) + \",\" : quoted(e));\n // An ask is run by the card (a function) or sent to the chat (text, where the host takes messages).\n const chip = (label, act) => button(\"chip\", label, () => (typeof act === \"function\" ? act() : ask(act)));\n function asks(list) {\n const box = el(\"div\", \"\", { className: \"asks\" });\n box.append(...list.filter(([, act]) => typeof act === \"function\" || caps.message).map(([label, act]) => chip(label, act)));\n return box;\n }\n function linkButton(url, primary) {\n if (!url) return el(\"span\", \"\");\n const b = button(primary ? \"primary\" : \"ghost\", primary ? \"Edit in Migma\" : \"Open in Migma\", () => openLink(url));\n b.append(icon(\"out\"));\n return b;\n }\n function foot(list, url, primary) {\n const f = el(\"div\", \"\", { className: \"foot\" });\n f.append(asks(list), linkButton(url, primary));\n return f;\n }\n function head(title, pre, tools = []) {\n const h = el(\"div\", \"\", { className: \"head\" });\n const t = el(\"div\", \"\", { className: \"title\" });\n t.append(el(\"h1\", title));\n if (pre) t.append(el(\"p\", pre, { className: \"pre\", title: pre }));\n h.append(t);\n if (tools.length) { const box = el(\"div\", \"\", { className: \"tools\" }); box.append(...tools); h.append(box); }\n return h;\n }\n function statusLine(label, tone) {\n const p = el(\"p\", \"\", { className: \"status\" });\n p.append(el(\"span\", \"\", { className: \"dot \" + tone }), el(\"span\", label));\n return p;\n }\n function steps(items) {\n const ul = el(\"ul\", \"\", { className: \"steps\" });\n ul.setAttribute(\"aria-live\", \"polite\");\n for (const [label, state] of items) {\n const li = el(\"li\", \"\", { className: state });\n const mark = el(\"span\", \"\", { className: \"mark\" });\n mark.append(state === \"done\" ? icon(\"check\") : el(\"span\", \"\", { className: \"ring\" }));\n li.append(mark, el(\"span\", label));\n if (state === \"now\") li.append(el(\"span\", elapsed(), { className: \"time\" }));\n ul.append(li);\n }\n return ul;\n }\n function skeleton() {\n const box = el(\"div\", \"\", { className: \"skel\" });\n for (const [h, w, m] of [[14, 30, 0], [56, 85, 16], [56, 60, 0], [200, 100, 8]]) {\n box.append(el(\"div\", \"\", { className: \"sk\", style: \"height:\" + h + \"px;width:\" + w + \"%;margin-top:\" + m + \"px\" }));\n }\n return box;\n }\n function picture(e, dim) {\n const shot = el(\"div\", \"\", { className: dim ? \"shot dim\" : \"shot\" });\n const img = el(\"img\", \"\", { alt: (e.subject || \"Email\") + (dim ? \", before the change\" : \"\") });\n img.addEventListener(\"error\", () => { e.picture = \"\"; render(); if (missingPicture()) retryPicture(); }, { once: true });\n img.src = e.picture;\n shot.append(img);\n return shot;\n }\n function stageNote(iconName, text) {\n const note = el(\"div\", \"\", { className: \"stage-note\" });\n note.append(icon(iconName, true), el(\"p\", text));\n return note;\n }\n function stage(e, opts = {}) {\n const box = el(\"div\", \"\", { className: opts.short ? \"stage short\" : opts.first ? (whole ? \"stage open\" : \"stage first\") : \"stage\" });\n if (e?.failed) {\n const ready = s.emails.filter((x) => !x.failed).length;\n box.append(stageNote(\"alert\", \"Migma could not create this email.\" + (ready ? \" The other \" + (ready === 1 ? \"one is\" : ready + \" are\") + \" ready.\" : \"\")));\n } else if (e?.picture && opts.first) {\n // Inline, the first screen: no scrolling inside an inline card (host guidance). The whole email\n // opens full screen, or in place where the host has no full screen.\n box.append(picture(e, opts.dim));\n if (!whole) box.append(button(\"whole\", \"See the whole email\", () => (canFullScreen() ? displayMode(\"fullscreen\") : ((whole = true), render()))));\n } else if (e?.picture) {\n box.append(picture(e, opts.dim));\n box.tabIndex = 0;\n box.setAttribute(\"aria-label\", (e.subject || \"Email\") + \", scroll to read\");\n } else if (opts.short || !s.noPicture || !e) {\n box.append(skeleton());\n if (e && !opts.short) {\n const note = el(\"p\", \"\", { className: \"stage-note\", role: \"status\" });\n const pill = el(\"span\", \"\", { className: \"pill\" });\n pill.append(el(\"span\", \"\", { className: \"dot info\" }), el(\"span\", \"Preparing the picture\"));\n note.append(pill);\n box.append(note);\n }\n } else {\n box.append(stageNote(\"image\", \"No picture of this email yet. It is ready in Migma.\"));\n }\n return box;\n }\n function tabs() {\n const list = el(\"div\", \"\", { className: \"tabs\", role: \"tablist\" });\n list.setAttribute(\"aria-label\", \"Emails in this series\");\n s.emails.forEach((e, i) => {\n const tab = button(\"tab\", \"\", () => select(i), { role: \"tab\" });\n tab.setAttribute(\"aria-selected\", String(i === sel));\n tab.tabIndex = i === sel ? 0 : -1;\n tab.append(el(\"span\", String(i + 1), { className: \"n\" }), el(\"span\", e.failed ? \"Not created\" : e.subject || \"Email \" + (i + 1), { className: \"t\" }));\n if (e.failed) tab.append(el(\"span\", \"\", { className: \"dot bad\" }));\n else if (e.day !== null) tab.append(el(\"span\", \"Day \" + e.day, { className: \"d\" }));\n tab.addEventListener(\"keydown\", (event) => {\n if (event.key === \"ArrowLeft\") select(i - 1);\n if (event.key === \"ArrowRight\") select(i + 1);\n });\n list.append(tab);\n });\n return list;\n }\n function readyAsks(e, i) {\n if (e.failed) return [[\"Try this email again\", \"Try creating email \" + (i + 1) + \" of the series again.\"]];\n return [\n [\"Make it shorter\", () => shorten(e, i)],\n [\"Try another version\", \"Make another version of \" + named(e, i).replace(/,$/, \"\") + \".\"],\n ];\n }\n\n // ---- the path from ready to sent ----\n // The card runs each step itself on a click (tools/call): a test to the account's own inbox, the\n // audience from the brand's segments and lists, and a send that only prepares an approval, which\n // the user approves on migma.ai. A host that refuses the call gets the step as a chat message.\n // What the card did is told to the model (ui/update-model-context), so the chat keeps track.\n const SETUP_URL = \"https://migma.ai/sending-domains\";\n const PLANS_URL = \"https://migma.ai/pricing\";\n const keyOf = (e) => e.emailId || \"email-\" + sel;\n const blank = () => ({ test: \"\", sentTo: \"\", audience: null, send: \"\", approval: null, change: \"\", note: \"\", plans: false });\n const flowOf = (e) => (flow[keyOf(e)] ||= blank());\n const people = (n) => n.toLocaleString(\"en-US\") + (n === 1 ? \" person\" : \" people\");\n const short = (text) => (text.length > 24 ? text.slice(0, 23) + \"\u2026\" : text);\n const subjectOf = (e, i) => named(e, i).replace(/,$/, \"\");\n const target = (e) => (e.emailId ? { emailId: e.emailId } : { conversationId: s.conversationId });\n const stamp = () => Date.now().toString(36);\n // A refusal that names the plan gets the plans page; nothing else in the card mentions plans.\n const planRefusal = (text) => /\\bplan\\b|upgrade|pricing/i.test(text || \"\");\n const waitMs = (ms) => new Promise((done) => setTimeout(done, ms));\n\n // The tool's answer, the error it returned, or null when the host refused the call itself.\n async function run(name, args) {\n try {\n const result = await request(\"tools/call\", { name, arguments: args }, 60000);\n if (result?.isError) {\n const refusal = json(result);\n return { error: refusal?.error || texts(result)[0] || \"Migma could not do this.\", code: typeof refusal?.code === \"string\" ? refusal.code : \"\" };\n }\n return { data: json(result) ?? {}, list: rows(result) };\n } catch { return null; }\n }\n function remember(text) {\n history.push(text);\n const context = \"In the Migma email card, the user \" + history.join(\"; \") + \".\";\n request(\"ui/update-model-context\", { content: [{ type: \"text\", text: context }] }, 10000).catch(() => {});\n }\n function failed(f, error) {\n f.note = error;\n f.plans = planRefusal(error);\n }\n\n async function testIt(e, i) {\n const f = flowOf(e);\n f.test = \"running\"; f.note = \"\"; render();\n const r = await run(\"migma_send_test_email\", target(e));\n if (!r) f.test = (await ask(\"Send me a test of \" + subjectOf(e, i) + \".\")) ? \"asked\" : \"\";\n else if (r.error) { f.test = \"warn\"; failed(f, r.error); }\n else {\n f.test = \"done\";\n f.sentTo = String(r.data.sentTo || \"\");\n remember(\"sent a test of \" + subjectOf(e, i) + (f.sentTo ? \" to \" + f.sentTo : \" to their own inbox\"));\n }\n render();\n }\n\n async function chooseAudience(e, i) {\n if (!brand) return askSend(e, i);\n const key = keyOf(e);\n flowOf(e).note = \"\";\n pick = { key, kind: \"audience\", loading: true, options: [], chosen: 0 };\n render();\n const [segments, lists] = await Promise.all([\n run(\"migma_list_segments\", { projectId: brand }),\n run(\"migma_list_tags\", { projectId: brand }),\n ]);\n if (pick?.key !== key) return;\n // Without either list the chat picks the audience with the user.\n if (!segments?.list && !lists?.list) { pick = null; return askSend(e, i); }\n const count = (r) => (typeof r.count === \"number\" ? r.count : typeof r.subscriberCount === \"number\" ? r.subscriberCount : null);\n const option = (type) => (r) => ({ type, id: String(r?.id ?? r?._id ?? \"\"), name: String(r?.name ?? \"\"), count: count(r ?? {}) });\n pick.options = [...(segments?.list ?? []).map(option(\"segment\")), ...(lists?.list ?? []).map(option(\"list\"))]\n .filter((o) => o.id && o.name)\n .sort((a, b) => (b.count ?? -1) - (a.count ?? -1))\n .slice(0, 6);\n pick.loading = false;\n render();\n }\n function useAudience(e) {\n const f = flowOf(e);\n f.audience = pick.options[pick.chosen];\n f.send = \"\"; f.note = \"\"; f.plans = false;\n pick = null;\n render();\n }\n\n // Sending domains belong to the account, not a brand: one sender is used as it is; several are\n // offered as choices; none sends the user to set one up.\n let senders = null;\n async function loadSenders() {\n if (senders) return senders;\n const r = await run(\"migma_list_domains\", {});\n if (!r || r.error) return null;\n senders = (r.list ?? [])\n .filter((d) => d?.isVerified === true || d?.status === \"verified\")\n .flatMap((d) => (Array.isArray(d.senders) ? d.senders : []).map((x) => ({ email: String(x?.email ?? \"\"), name: String(x?.fromName ?? \"\"), first: x?.isDefault === true })))\n .filter((x) => x.email && x.name)\n .sort((a, b) => Number(b.first) - Number(a.first))\n .slice(0, 6);\n return senders;\n }\n async function sendIt(e, i, sender) {\n const f = flowOf(e);\n const a = f.audience;\n if (!a || a.chat) return askSend(e, i);\n f.note = \"\"; f.plans = false;\n if (!sender) {\n f.send = \"running\"; render();\n const list = await loadSenders();\n if (!list) { f.send = \"\"; return askSend(e, i); }\n if (!list.length) { f.send = \"nosender\"; return render(); }\n if (list.length > 1) {\n f.send = \"\";\n pick = { key: keyOf(e), kind: \"sender\", loading: false, options: list, chosen: 0 };\n return render();\n }\n sender = list[0];\n }\n pick = null;\n f.send = \"running\"; render();\n const key = \"card-\" + keyOf(e) + \"-\" + a.id + \"-\" + stamp();\n let r = await run(\"migma_send_email\", {\n recipientType: a.type === \"list\" ? \"tag\" : \"segment\",\n recipientId: a.id,\n from: sender.email,\n fromName: sender.name,\n subject: e.subject,\n ...target(e),\n idempotency_key: key,\n });\n if (r?.code === MANAGED_SINGLE_SEND_REFUSED) r = await viaCampaign(e, a, sender, key);\n if (!r) { f.send = \"\"; return askSend(e, i); }\n if (r.error) { f.send = \"warn\"; failed(f, r.error); return render(); }\n const approval = r.data.approval ?? {};\n const summary = r.data.summary ?? {};\n f.approval = {\n id: String(approval.id ?? \"\"),\n url: https(approval.approvalUrl),\n count: typeof summary.recipients === \"number\" ? summary.recipients : a.count,\n from: (summary.fromName || sender.name) + \" <\" + (summary.from || sender.email) + \">\",\n subject: summary.subject || e.subject,\n warning: Array.isArray(summary.warnings) ? String(summary.warnings[0] ?? \"\") : \"\",\n };\n f.send = \"waiting\";\n remember(\"prepared a send of \" + subjectOf(e, i) + \" to \" + a.name + \"; it waits for their approval on migma.ai (\" + f.approval.url + \")\");\n render();\n watchApproval(e, i, f);\n }\n // A workspace connected through managed sign-in may send only campaigns (their approval re-checks\n // the member's role), so the same send goes as a campaign draft and its approval, which the user\n // approves on migma.ai the same way. Null (the host refused, or no brand to save it in) asks the chat.\n const MANAGED_SINGLE_SEND_REFUSED = \"WORKSPACE_KEY_SINGLE_SEND_REFUSED\";\n async function viaCampaign(e, a, sender, key) {\n if (!brand) return null;\n const draft = await run(\"migma_create_campaign\", {\n projectId: brand,\n name: e.subject || \"Email from Migma\",\n ...target(e),\n subject: e.subject,\n from: sender.email,\n fromName: sender.name,\n recipientType: a.type === \"list\" ? \"tag\" : \"audience\",\n recipientId: a.id,\n idempotency_key: key + \"-draft\",\n });\n if (!draft || draft.error) return draft;\n if (!draft.data.id) return { error: \"Migma could not save the campaign.\" };\n return run(\"migma_send_campaign\", { campaignId: String(draft.data.id), idempotency_key: key + \"-send\" });\n }\n // The approval happens on migma.ai; the card reads it until it is decided.\n async function watchApproval(e, i, f) {\n let wait = 5000;\n while (f.send === \"waiting\" && f.approval?.id) {\n await waitMs(wait);\n wait = Math.min(wait * 1.3, 20000);\n if (document.visibilityState !== \"visible\") continue;\n const r = await run(\"migma_get_send_approval\", { approvalId: f.approval.id });\n const status = r?.data?.status;\n if (status === \"sent\" || status === \"scheduled\") {\n f.send = \"sent\";\n remember(\"approved the send of \" + subjectOf(e, i) + \" on migma.ai; Migma sent it\");\n } else if (status === \"declined\" || status === \"expired\" || status === \"failed\") {\n f.send = \"warn\";\n failed(f, status === \"declined\" ? \"The send was declined on migma.ai.\" : status === \"expired\" ? \"The approval expired before anyone approved it.\" : r.data.error || \"The send did not go out.\");\n } else continue;\n return render();\n }\n }\n async function askSend(e, i) {\n const f = flowOf(e);\n const a = f.audience;\n const to = a && !a.chat ? \" to the \" + a.name + (a.type === \"list\" ? \" list\" : \" segment\") : \" to my audience\";\n if (!(await ask(\"Send \" + subjectOf(e, i) + to + \".\"))) return;\n f.send = \"asked\";\n if (!f.audience) f.audience = { chat: true };\n render();\n }\n\n // \"Make it shorter\" changes the email in place; the steps start again for the changed email.\n async function shorten(e, i) {\n if (!e.emailId) return ask(\"Make \" + named(e, i) + \" shorter.\");\n const f = flowOf(e);\n f.change = \"running\"; f.note = \"\"; pick = null; render();\n const r = await run(\"migma_edit_email\", { emailId: e.emailId, prompt: \"Make it shorter.\", idempotency_key: \"card-shorter-\" + e.emailId + \"-\" + stamp() });\n if (!r) { f.change = \"\"; render(); return ask(\"Make \" + named(e, i) + \" shorter.\"); }\n if (r.error || !r.data.editId) { f.change = \"\"; failed(f, r.error || \"Migma could not change this email.\"); return render(); }\n let wait = r.data.pollAfterMs || 2000;\n for (;;) {\n await waitMs(wait);\n wait = Math.min(wait * 1.4, 15000);\n const d = await run(\"migma_get_email_edit_status\", { emailId: e.emailId, editId: r.data.editId });\n if (d?.data?.status === \"failed\") { f.change = \"\"; failed(f, d.data.error || \"Migma could not change this email.\"); return render(); }\n if (d?.data?.status === \"completed\") break;\n }\n const at = s.emails.indexOf(e);\n const now = await run(\"migma_get_email\", { emailId: e.emailId });\n if (at >= 0 && now?.data?.emailId) s.emails[at] = unchanged(toEmail(now.data, e.appUrl), e.picture);\n flow[keyOf(e)] = blank();\n remember(\"made \" + subjectOf(e, i) + \" shorter\");\n tries = 0;\n render();\n if (missingPicture()) retryPicture();\n }\n\n function pathView(e, opts = {}) {\n const f = e ? flowOf(e) : blank();\n const a = f.audience;\n const picking = e && pick?.key === keyOf(e) && pick.kind === \"audience\";\n const test = {\n \"\": [\"\", \"To your own inbox\"], running: [\"run\", \"Sending\"], done: [\"done\", f.sentTo ? \"Sent to \" + f.sentTo : \"In your inbox\"],\n warn: [\"warn\", \"Not sent\"], asked: [\"asked\", \"Asked in the chat\"],\n }[f.test];\n const audience = a\n ? (a.chat ? [\"asked\", \"In the chat\"] : [\"done\", a.name + (a.count !== null ? \", \" + people(a.count) : \"\")])\n : [\"\", picking && !pick.loading && !pick.options.length ? \"No contacts yet\" : picking ? \"Pick who gets it\" : \"Your list, or bring one\"];\n const send = {\n \"\": [\"\", \"You approve on migma.ai\"], running: [\"run\", \"Preparing\"], waiting: [\"asked\", \"Waiting for your approval\"],\n sent: [\"done\", typeof f.approval?.count === \"number\" ? \"Sent to \" + people(f.approval.count) : \"Sent\"],\n warn: [\"warn\", \"Not sent\"], nosender: [\"warn\", \"Needs a sending address\"], asked: [\"asked\", \"Asked in the chat\"],\n }[f.send];\n const next = opts.faded || f.change ? \"\" : !test[0] || f.test === \"running\" ? \"test\" : !a ? \"audience\" : f.send !== \"sent\" && f.send !== \"asked\" ? \"send\" : \"\";\n const list = el(\"ol\", \"\", { className: opts.faded ? \"path faded\" : \"path\" });\n list.setAttribute(\"aria-label\", \"From ready to sent\");\n for (const [key, label, iconName, [state, value]] of [[\"test\", \"Test\", \"mail\", test], [\"audience\", \"Audience\", \"people\", audience], [\"send\", \"Send\", \"send\", send]]) {\n const li = el(\"li\", \"\", { className: \"step\" + (key === next ? \" next\" : \"\") + (state ? \" \" + state : \"\") });\n if (key === next) li.setAttribute(\"aria-current\", \"step\");\n const mark = el(\"span\", \"\", { className: \"s \" + (state || \"todo\") });\n if (state === \"done\") mark.append(icon(\"check\"));\n const k = el(\"span\", \"\", { className: \"k\" });\n k.append(icon(iconName), el(\"span\", label), mark);\n li.append(k, el(\"span\", value, { className: \"v\" }));\n list.append(li);\n }\n return list;\n }\n // What the last step left: the approval as it will go out, or why a step stopped.\n function stepNote(e) {\n const f = flowOf(e);\n const parts = [];\n if (f.approval && (f.send === \"waiting\" || f.send === \"sent\")) {\n const facts = el(\"dl\", \"\", { className: \"facts\" });\n const a = f.audience;\n for (const [k, v] of [[\"To\", a.name + (typeof f.approval.count === \"number\" ? \", \" + people(f.approval.count) : \"\")], [\"From\", f.approval.from], [\"Subject\", f.approval.subject]]) {\n facts.append(el(\"dt\", k), el(\"dd\", v));\n }\n parts.push(facts);\n if (f.approval.warning) parts.push(el(\"p\", f.approval.warning, { className: \"note warn\" }));\n }\n if (f.send === \"nosender\") parts.push(el(\"p\", \"Emails go out from your own address. Set it up once in Migma.\", { className: \"note small\" }));\n if (f.note) {\n const p = el(\"p\", f.note, { className: \"note warn\" });\n if (f.plans) {\n const plans = el(\"a\", \"See plans\", { href: PLANS_URL, className: \"plans\" });\n plans.addEventListener(\"click\", (event) => { event.preventDefault(); openLink(PLANS_URL); });\n p.append(\" \", plans);\n }\n parts.push(p);\n }\n if (f.change === \"running\") parts.push(el(\"p\", \"Making it shorter\", { className: \"note small\", role: \"status\" }));\n return parts;\n }\n function pickView(e) {\n if (!pick || pick.key !== keyOf(e)) return null;\n const box = el(\"div\", \"\", { className: \"pick\", role: \"group\" });\n box.setAttribute(\"aria-label\", pick.kind === \"sender\" ? \"Sender\" : \"Audience\");\n if (pick.loading) {\n box.append(el(\"p\", \"Who gets it\", { className: \"pick-h\" }), el(\"div\", \"\", { className: \"sk\", style: \"height:36px;width:60%\" }));\n return box;\n }\n if (!pick.options.length) {\n box.append(\n el(\"p\", \"No contacts yet\", { className: \"pick-h\" }),\n el(\"p\", \"Bring your list from Klaviyo, Shopify, Mailchimp or a CSV once, and every send can use it.\", { className: \"note small\", style: \"margin:0\" }),\n );\n return box;\n }\n const h = el(\"p\", pick.kind === \"sender\" ? \"Who it is from\" : \"Who gets it\", { className: \"pick-h\" });\n h.append(el(\"span\", pick.kind === \"sender\" ? \"Your sending addresses in Migma\" : \"From your contacts in Migma\"));\n const opts = el(\"div\", \"\", { className: \"opts\" });\n pick.options.forEach((o, n) => {\n const b = button(\"opt\", o.name, () => { pick.chosen = n; render(); });\n b.setAttribute(\"aria-pressed\", String(n === pick.chosen));\n if (pick.kind === \"sender\") b.append(el(\"small\", o.email));\n else if (o.count !== null) b.append(el(\"small\", o.count.toLocaleString(\"en-US\")));\n opts.append(b);\n });\n box.append(h, opts);\n return box;\n }\n function linkPrimary(label, url) {\n const b = button(\"primary\", label, () => openLink(url));\n b.append(icon(\"out\"));\n return b;\n }\n function nextButton(e, i) {\n const f = flowOf(e);\n if (f.change) return null;\n const p = pick?.key === keyOf(e) ? pick : null;\n if (p?.kind === \"sender\") return button(\"primary\", \"Send from \" + short(p.options[p.chosen].name), () => sendIt(e, i, p.options[p.chosen]));\n if (!f.test || f.test === \"running\") return button(\"primary\", \"Send me a test\", () => testIt(e, i), { disabled: f.test === \"running\" });\n if (!f.audience) {\n if (!p) return button(\"primary\", \"Choose audience\", () => chooseAudience(e, i));\n if (p.loading) return button(\"primary\", \"Choose audience\", () => {}, { disabled: true });\n if (!p.options.length) return linkPrimary(\"Add contacts in Migma\", CONTACTS_URL);\n return button(\"primary\", \"Use \" + short(p.options[p.chosen].name), () => useAudience(e));\n }\n if (f.send === \"nosender\") return linkPrimary(\"Set up sending in Migma\", SETUP_URL);\n if (f.send === \"waiting\") return linkPrimary(\"Approve on migma.ai\", f.approval.url);\n if (f.send === \"sent\") return f.approval.url ? linkPrimary(\"See results\", f.approval.url) : null;\n if (f.send === \"warn\" && f.plans) return button(\"primary\", \"Choose another list\", () => { f.audience = null; f.send = \"\"; chooseAudience(e, i); });\n if (f.send === \"warn\") return button(\"primary\", \"Try the send again\", () => sendIt(e, i));\n if (f.send === \"\" || f.send === \"running\") return button(\"primary\", \"Send\", () => sendIt(e, i), { disabled: f.send === \"running\" });\n return null;\n }\n function pathFoot(e, i) {\n const f = el(\"div\", \"\", { className: \"foot\" });\n const url = e.appUrl || s.appUrl;\n if (url) {\n const edit = button(\"ghost left\", \"Edit in Migma\", () => openLink(url));\n edit.append(icon(\"out\"));\n f.append(edit);\n }\n const next = nextButton(e, i);\n if (next) f.append(next);\n return f;\n }\n function readyLine(tools) {\n const line = el(\"div\", \"\", { className: \"ready\" });\n const fact = el(\"span\", \"\", { className: \"fact\" });\n fact.append(icon(\"check\"), el(\"span\", \"Works in every inbox\"));\n const mark = el(\"span\", \"\", { className: \"brand\" });\n mark.append(el(\"i\", \"\"), el(\"span\", \"Migma\"));\n line.append(el(\"span\", \"\", { className: \"dot ok\" }), el(\"span\", series() ? \"Email designs ready\" : \"Email design ready\"), fact, mark, ...tools);\n return line;\n }\n // A host that can neither run tools nor take messages shows the email and its link.\n const hasPath = (e) => !e.failed && !!(caps.message || caps.serverTools);\n\n // ---- views ----\n function compactView() {\n const line = el(\"div\", \"\", { className: \"line\", role: \"status\" });\n const many = (s.count || s.slots?.length || s.emails?.length || 1) > 1;\n if (s.phase === \"working\") {\n line.append(el(\"span\", \"\", { className: \"dot info\" }), el(\"span\", many ? \"Designing \" + (s.count || s.slots.length) + \" emails\" : \"Designing your email\", { className: \"t\" }));\n if (s.now) line.append(el(\"span\", s.now, { className: \"s\" }));\n line.append(el(\"span\", elapsed(), { className: \"time\" }));\n } else if (s.phase === \"failed\") {\n line.append(el(\"span\", \"\", { className: \"dot bad\" }), el(\"span\", \"Not created\", { className: \"t\" }), el(\"span\", s.error, { className: \"s\" }));\n } else {\n const first = s.emails.find((e) => e.picture);\n const thumb = el(\"span\", \"\", { className: \"thumb\" });\n if (first) thumb.append(el(\"img\", \"\", { src: first.picture, alt: \"\" }));\n line.append(thumb, el(\"span\", many ? s.emails.length + \" emails\" : s.emails[0].subject || \"Your email\", { className: \"t\" }), el(\"span\", \"Ready\", { className: \"s\" }));\n const show = button(\"ghost\", \"Show\", () => { s.compact = false; render(); if (missingPicture()) retryPicture(); });\n show.setAttribute(\"aria-expanded\", \"false\");\n line.append(show, linkButton(s.emails[0].appUrl || s.appUrl, true));\n }\n return [line];\n }\n\n function workingView() {\n if (s.mode === \"edit\") {\n const at = Math.max(0, EDIT_STEPS.findIndex(([, stages]) => stages.includes(s.stage)));\n return [\n head(s.before?.subject || \"Changing your email\", input.prompt),\n steps(EDIT_STEPS.map(([label], i) => [label, i < at ? \"done\" : i === at ? \"now\" : \"todo\"])),\n s.before?.picture ? stage(s.before, { dim: true }) : stage(null, { short: true }),\n foot([], s.before?.appUrl || s.appUrl, false),\n ];\n }\n const count = s.count || s.slots?.length || 1;\n const parts = [\n head(count > 1 ? \"Designing \" + count + \" emails\" : \"Designing your email\", input.prompt),\n steps([...(s.steps || []).map((label) => [label, \"done\"]), [s.now || \"Starting\", \"now\"]]),\n ];\n if (count > 1) {\n const slots = el(\"div\", \"\", { className: \"slots\" });\n for (let i = 0; i < count; i++) {\n const done = s.slots?.[i] && !s.slots[i].pending;\n const slot = el(\"div\", \"\", { className: done ? \"slot done\" : \"slot\" });\n const frame = el(\"div\", \"\", { className: \"frame\" });\n frame.append(done ? icon(\"check\", true) : el(\"span\", \"\", { className: \"dot info\" }));\n const lab = el(\"div\", \"\", { className: \"lab\" });\n lab.append(el(\"span\", \"Email \" + (i + 1)), el(\"span\", done ? \"Done\" : \"Designing\"));\n slot.append(frame, lab);\n slots.append(slot);\n }\n parts.push(slots);\n } else {\n parts.push(stage(null, { short: true }));\n }\n // What comes next, faded, while people wait.\n if (caps.message) parts.push(el(\"p\", \"Next, without leaving the chat\", { className: \"note small\" }), pathView(null, { faded: true }));\n parts.push(foot([], s.appUrl, false));\n return parts;\n }\n\n function failedView() {\n if (s.mode === \"edit\") {\n const e = s.before;\n const parts = [statusLine(\"Not changed\", \"bad\"), head(e?.subject || \"Your email\", input.prompt), el(\"p\", s.error, { className: \"note bad\" })];\n if (s.mayHaveSaved) parts.push(el(\"p\", \"Some changes may have been saved. Check the email in Migma before you try again.\", { className: \"note warn\" }));\n if (e?.picture) parts.push(stage(e));\n parts.push(foot(input.prompt && !s.refused ? [[\"Try again\", \"Try that change to \" + (e ? quoted(e) : \"the email\") + \" again.\"]] : [], e?.appUrl || s.appUrl, true));\n return parts;\n }\n if (s.mode === \"email\") return [statusLine(\"Could not show this email\", \"bad\"), el(\"p\", s.error, { className: \"note bad\" })];\n const many = (s.count || 1) > 1;\n return [\n statusLine(\"Not created\", \"bad\"),\n head(many ? \"Your emails\" : \"Your email\", input.prompt),\n el(\"p\", s.error, { className: \"note bad\" }),\n foot(input.prompt && !s.refused ? [[\"Try again\", many ? \"Try creating those emails again.\" : \"Try creating that email again.\"]] : [], s.appUrl, false),\n ];\n }\n\n function readyView() {\n const e = s.emails[sel];\n const full = canFullScreen() ? [button(\"icon-btn\", \"\", () => displayMode(\"fullscreen\"), { ariaLabel: \"Full screen\" })] : [];\n full[0]?.append(icon(\"expand\"));\n const title = e.failed ? \"Email \" + (sel + 1) + \" was not created\" : e.subject || \"Your email\";\n const parts = e.failed ? [head(title, \"\", full)] : [readyLine(full), head(title, e.preheader)];\n if (series()) parts.push(tabs());\n parts.push(stage(e, { first: true, dim: !e.failed && flowOf(e).change === \"running\" }));\n if (!hasPath(e)) {\n parts.push(foot(e.failed ? readyAsks(e, sel) : [], e.appUrl || s.appUrl, true));\n return parts;\n }\n parts.push(pathView(e), ...stepNote(e));\n const picking = pickView(e);\n if (picking) parts.push(picking);\n parts.push(pathFoot(e, sel));\n return parts;\n }\n\n function fullScreenView() {\n const e = s.emails[sel];\n const back = button(\"icon-btn\", \"\", () => displayMode(\"inline\"), { ariaLabel: \"Back to the chat\" });\n back.append(icon(\"collapse\"));\n const box = el(\"section\", \"\", { className: \"fs\" });\n const body = el(\"div\", \"\", { className: \"fs-body\" });\n if (series()) {\n const rail = el(\"nav\", \"\", { className: \"rail\" });\n rail.setAttribute(\"aria-label\", \"Emails in this series\");\n s.emails.forEach((x, i) => {\n const item = button(\"rail-item\", \"\", () => select(i));\n if (i === sel) item.setAttribute(\"aria-current\", \"true\");\n const thumb = el(\"div\", \"\", { className: \"thumb\" });\n thumb.append(x.picture ? el(\"img\", \"\", { src: x.picture, alt: \"\" }) : icon(x.failed ? \"alert\" : \"image\", true));\n item.append(thumb, el(\"span\", (i + 1) + (x.failed ? \" \u00B7 Not created\" : x.day !== null ? \" \u00B7 Day \" + x.day : \"\")));\n rail.append(item);\n });\n body.append(rail);\n }\n const wrap = el(\"div\", \"\", { className: \"fs-wrap\" });\n wrap.append(stage(e));\n if (series()) {\n const prev = button(\"step-btn prev\", \"\", () => select(sel - 1), { ariaLabel: \"Previous email\", disabled: sel === 0 });\n const next = button(\"step-btn next\", \"\", () => select(sel + 1), { ariaLabel: \"Next email\", disabled: sel === s.emails.length - 1 });\n prev.append(icon(\"prev\")); next.append(icon(\"next\"));\n wrap.append(prev, next);\n }\n const desk = el(\"div\", \"\", { className: \"desk\" });\n desk.append(wrap);\n if (hasPath(e)) {\n // The path beside the whole email; changes to the email live here, where there is room.\n const panel = el(\"aside\", \"\", { className: \"panel\" });\n panel.setAttribute(\"aria-label\", \"From ready to sent\");\n panel.append(el(\"h2\", \"From ready to sent\"), pathView(e), ...stepNote(e));\n const picking = pickView(e);\n if (picking) panel.append(picking);\n panel.append(asks(readyAsks(e, sel)));\n desk.append(panel);\n }\n body.append(desk);\n box.append(head(e.failed ? \"Email \" + (sel + 1) + \" was not created\" : e.subject || \"Your email\", e.failed ? \"\" : e.preheader, [back]));\n if (series()) box.append(tabs());\n box.append(body, hasPath(e) ? pathFoot(e, sel) : foot(readyAsks(e, sel), e.appUrl || s.appUrl, true));\n if (s.note) box.append(el(\"p\", s.note, { className: \"note small\" }));\n return [box];\n }\n\n function render() {\n const main = $(\"card\");\n main.setAttribute(\"aria-busy\", String(s.phase === \"working\" && !s.compact));\n let parts;\n if (s.compact) parts = compactView();\n else if (fullScreen()) parts = fullScreenView();\n else parts = s.phase === \"working\" ? workingView() : s.phase === \"failed\" ? failedView() : readyView();\n if (s.note && !fullScreen()) parts.push(el(\"p\", s.note, { className: \"note small\" }));\n main.replaceChildren(...parts);\n // ChatGPT's own \"Open in\" button in full screen opens this card's page unless told otherwise.\n const link = s.emails?.[sel]?.appUrl || s.before?.appUrl || s.appUrl;\n if (link) window.openai?.setOpenInAppUrl?.({ href: link });\n tick();\n }\n\n new ResizeObserver(() => send({ method: \"ui/notifications/size-changed\", params: { height: Math.ceil(document.documentElement.getBoundingClientRect().height) } }))\n .observe(document.documentElement);\n\n const init = await request(\"ui/initialize\", {\n appInfo: { name: \"Migma email\", version: \"1.0.0\" },\n appCapabilities: { availableDisplayModes: [\"inline\", \"fullscreen\"] },\n protocolVersion: \"2026-01-26\",\n });\n caps = init?.hostCapabilities ?? {};\n applyHost(init?.hostContext);\n send({ method: \"ui/notifications/initialized\", params: {} });\n</script>\n</body>\n</html>\n";
14
18
  //# sourceMappingURL=email-card.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"email-card.d.ts","sourceRoot":"","sources":["../../src/tools/email-card.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE;;;;;;GAMG;AAEH,eAAO,MAAM,cAAc,qBAAqB,CAAC;AAEjD,mFAAmF;AACnF,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAEhF;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,QAQjE;AAED,eAAO,MAAM,eAAe,+wsCAorB3B,CAAC"}
1
+ {"version":3,"file":"email-card.d.ts","sourceRoot":"","sources":["../../src/tools/email-card.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,cAAc,qBAAqB,CAAC;AAEjD,mFAAmF;AACnF,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAEhF;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,QAQjE;AAED,eAAO,MAAM,eAAe,qpjEA4oC3B,CAAC"}