@cliptude/cli 0.1.30 → 0.1.33

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.
@@ -0,0 +1,32 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Job</title>
7
+ <style>
8
+ /*@BASE_CSS@*/
9
+ </style>
10
+ </head>
11
+ <body>
12
+ <main class="app" id="content" aria-live="polite"></main>
13
+ <div id="toast" role="status" aria-live="polite"></div>
14
+ <script>
15
+ /*@BRIDGE_JS@*/
16
+ /*@VIEWS_JS@*/
17
+ (function () {
18
+ "use strict";
19
+ // get_job, get_product_video_status and get_narration. The agent polls these often, so the card draws once,
20
+ // straight from the data, with no loading animation: a script to approve, a progress card, or (when the video
21
+ // is ready) the progress card with the publish kit under it.
22
+ var content = document.getElementById("content");
23
+ var ctx = { mode: "job", input: function () { return Cliptude.state.toolInput; } };
24
+ Cliptude.connect({
25
+ name: "cliptude-job",
26
+ onResult: function (data) { Views.mount(content, data || {}, ctx); },
27
+ onCancelled: function () { UI.status(content, "Cancelled."); }
28
+ }).catch(function () { UI.status(content, "This view could not connect to the chat.", "error"); });
29
+ })();
30
+ </script>
31
+ </body>
32
+ </html>
@@ -6,19 +6,6 @@
6
6
  <title>Publish kit</title>
7
7
  <style>
8
8
  /*@BASE_CSS@*/
9
- section { display: flex; flex-direction: column; gap: 8px; }
10
- h2 { font-size: var(--font-text-md-size); margin: 0; font-weight: 600; }
11
- .sec-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
12
- .big { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--border-radius-md); background: var(--color-background-tertiary); display: block; }
13
- .thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
14
- .thumbs .card .thumb { aspect-ratio: 16 / 9; }
15
- pre.copy {
16
- margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--font-sans); font-size: var(--font-text-sm-size);
17
- background: var(--color-background-secondary); border: 1px solid var(--color-border-secondary); border-radius: var(--border-radius-md);
18
- padding: 10px 12px; max-height: 260px; overflow: auto; user-select: text;
19
- }
20
- .title-row .name { font-weight: 500; }
21
- .tag { user-select: text; }
22
9
  </style>
23
10
  </head>
24
11
  <body>
@@ -32,135 +19,19 @@ pre.copy {
32
19
  <div id="toast" role="status" aria-live="polite"></div>
33
20
  <script>
34
21
  /*@BRIDGE_JS@*/
22
+ /*@VIEWS_JS@*/
35
23
  (function () {
36
24
  "use strict";
37
- var h = UI.h;
38
25
  var content = document.getElementById("content");
39
- var kit = null;
40
- var current = 0;
41
-
42
- function selectText(el) {
43
- try {
44
- var range = document.createRange(); range.selectNodeContents(el);
45
- var sel = window.getSelection(); sel.removeAllRanges(); sel.addRange(range);
46
- } catch (e) {}
47
- }
48
-
49
- /** Clipboard API (clipboardWrite permission), else execCommand, else select the text for the user. */
50
- function copy(text, el) {
51
- function fallback() {
52
- var area = h("textarea", { style: { position: "fixed", opacity: "0", top: "0", left: "0" } });
53
- area.value = text; document.body.appendChild(area); area.select();
54
- var ok = false;
55
- try { ok = document.execCommand("copy"); } catch (e) { ok = false; }
56
- area.remove();
57
- if (ok) { UI.toast("Copied."); return; }
58
- if (el) selectText(el);
59
- UI.toast("Selected. Press ⌘C or Ctrl+C to copy.");
60
- }
61
- if (navigator.clipboard && navigator.clipboard.writeText) {
62
- navigator.clipboard.writeText(text).then(function () { UI.toast("Copied."); }, fallback);
63
- } else fallback();
64
- }
65
-
66
- function open(url) { Cliptude.openLink(url).catch(function () { UI.toast("The link could not be opened here."); }); }
67
-
68
- function thumbsSection(items, status) {
69
- if (!items.length) {
70
- return h("section", {}, [h("h2", {}, ["Thumbnails"]),
71
- h("div", { class: "status" }, [status && status !== "completed" ? "Thumbnails are " + status.replace(/_/g, " ") + "." : "No thumbnails yet."])]);
72
- }
73
- var item = items[current] || items[0];
74
- var big = h("img", { class: "big", src: item.url, alt: (item.label || "Thumbnail") + " preview" });
75
- var grid = h("div", { class: "thumbs", role: "list" });
76
- items.forEach(function (t, i) {
77
- var c = h("button", { type: "button", class: "card", role: "listitem", "aria-pressed": String(i === current),
78
- "aria-label": "Show " + (t.label || "thumbnail " + (i + 1)), onclick: function () { current = i; render(); } },
79
- [UI.img(t.url, "", String(i + 1)), h("span", { class: "body" }, [h("span", { class: "name" }, [t.label || "Thumbnail " + (i + 1)])])]);
80
- grid.appendChild(c);
81
- });
82
- return h("section", {}, [
83
- h("div", { class: "sec-head" }, [h("h2", {}, ["Thumbnails (" + items.length + ")"]),
84
- h("span", { class: "toolbar" }, [
85
- h("button", { type: "button", onclick: function () { open(item.url); } }, ["Open full size"]),
86
- h("button", { type: "button", onclick: function () {
87
- UI.choose("I will use “" + (item.label || "this thumbnail") + "” as the thumbnail: " + item.url, { thumbnail_url: item.url });
88
- } }, ["Use this thumbnail"])
89
- ])]),
90
- big, grid
91
- ]);
92
- }
93
-
94
- function titlesSection(titles) {
95
- if (!titles.length) return null;
96
- var list = h("div", { class: "list", role: "list" });
97
- titles.forEach(function (t) {
98
- list.appendChild(h("div", { class: "row title-row", role: "listitem" }, [
99
- h("div", { class: "main" }, [h("span", { class: "name" }, [t])]),
100
- h("button", { type: "button", "aria-label": "Copy title: " + t, onclick: function () { copy(t); } }, ["Copy"]),
101
- h("button", { type: "button", onclick: function () { UI.choose("Use this title for the video: “" + t + "”", { title: t }); } }, ["Use"])
102
- ]));
103
- });
104
- return h("section", {}, [h("h2", {}, ["Title ideas"]), list]);
105
- }
106
-
107
- function textSection(title, text) {
108
- if (!text) return null;
109
- var pre = h("pre", { class: "copy", tabindex: "0" }, [text]);
110
- return h("section", {}, [
111
- h("div", { class: "sec-head" }, [h("h2", {}, [title]),
112
- h("button", { type: "button", onclick: function () { copy(text, pre); } }, ["Copy " + title.toLowerCase()])]),
113
- pre
114
- ]);
115
- }
116
-
117
- function tagsSection(tags) {
118
- if (!tags.length) return null;
119
- var box = h("div", { class: "chips", role: "list" });
120
- tags.forEach(function (t) { box.appendChild(h("span", { class: "chip tag", role: "listitem" }, [t])); });
121
- return h("section", {}, [
122
- h("div", { class: "sec-head" }, [h("h2", {}, ["Tags (" + tags.length + ")"]),
123
- h("button", { type: "button", onclick: function () { copy(tags.join(", "), box); } }, ["Copy all tags"])]),
124
- box
125
- ]);
126
- }
127
-
128
- function render() {
129
- var meta = kit.publish_metadata || {};
130
- var thumbs = (kit.thumbnails && kit.thumbnails.items) || [];
131
- var tags = meta.tags || [];
132
- var description = String(meta.description || "");
133
- if (tags.length) {
134
- // The generated description ends with its tags line; show it once, as chips.
135
- var line = tags.join(", ").toLowerCase();
136
- description = description.split(/\n\s*\n/).filter(function (p) {
137
- var flat = p.split(",").map(function (x) { return x.trim().replace(/^#/, "").toLowerCase(); }).filter(Boolean);
138
- return !(flat.length >= 5 && flat.every(function (x) { return line.indexOf(x) >= 0; }));
139
- }).join("\n\n");
140
- }
141
- var downloads = meta.downloads || {};
142
- UI.clear(content);
143
- [thumbsSection(thumbs, kit.thumbnails && kit.thumbnails.status),
144
- titlesSection(meta.title_variants || []),
145
- textSection("Description", description.trim()),
146
- textSection("Chapters", meta.chapters || ""),
147
- tagsSection(tags),
148
- downloads.voiceover_url || downloads.project_zip_url ? h("section", {}, [h("h2", {}, ["Downloads"]), h("div", { class: "toolbar" }, [
149
- downloads.voiceover_url ? h("button", { type: "button", onclick: function () { open(downloads.voiceover_url); } }, ["Voiceover"]) : null,
150
- downloads.project_zip_url ? h("button", { type: "button", onclick: function () { open(downloads.project_zip_url); } }, ["Project files"]) : null
151
- ])]) : null
152
- ].forEach(function (s) { if (s) content.appendChild(s); });
153
- if (!content.childNodes.length) UI.status(content, "Nothing to publish yet.");
154
- }
155
-
156
26
  Cliptude.connect({
157
27
  name: "cliptude-publish-kit",
158
28
  onResult: function (data) {
159
29
  var err = UI.errorText(data);
160
30
  if (err) { UI.status(content, err, "error"); return; }
161
- kit = data.project && !data.publish_metadata ? data.project : data;
31
+ // The video stage opens first when there is one: current = kit.video && kit.video.url ? -1 : 0 (views.js).
32
+ var kit = data.project && !data.publish_metadata ? data.project : data;
162
33
  document.getElementById("title").textContent = kit.title ? "Publish kit · " + kit.title : "Publish kit";
163
- render();
34
+ Views.publishKit(content, kit);
164
35
  },
165
36
  onCancelled: function () { UI.status(content, "Cancelled."); }
166
37
  }).catch(function () { UI.status(content, "This view could not connect to the chat.", "error"); });
@@ -0,0 +1,31 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Review and confirm</title>
7
+ <style>
8
+ /*@BASE_CSS@*/
9
+ </style>
10
+ </head>
11
+ <body>
12
+ <main class="app" id="content" aria-live="polite"><div class="status" role="status">Loading the review…</div></main>
13
+ <div id="toast" role="status" aria-live="polite"></div>
14
+ <script>
15
+ /*@BRIDGE_JS@*/
16
+ /*@VIEWS_JS@*/
17
+ (function () {
18
+ "use strict";
19
+ // A 428 review: every setting, warning, acknowledgement and the credits; Confirm resends the same call with
20
+ // its review_token only when the user clicks it. Any other result of these tools shows as a result card.
21
+ var content = document.getElementById("content");
22
+ var ctx = { mode: "review", input: function () { return Cliptude.state.toolInput; } };
23
+ Cliptude.connect({
24
+ name: "cliptude-review",
25
+ onResult: function (data) { Views.mount(content, data || {}, ctx); },
26
+ onCancelled: function () { UI.status(content, "Cancelled."); }
27
+ }).catch(function () { UI.status(content, "This view could not connect to the chat.", "error"); });
28
+ })();
29
+ </script>
30
+ </body>
31
+ </html>
@@ -0,0 +1,152 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Template</title>
7
+ <style>
8
+ /*@BASE_CSS@*/
9
+ .hero { display: grid; grid-template-columns: 150px 1fr; gap: 14px; align-items: start; }
10
+ .hero .thumb { aspect-ratio: 16 / 9; border-radius: var(--border-radius-md); }
11
+ .hero .thumb.portrait { aspect-ratio: 1 / 1; }
12
+ .parts { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
13
+ .part { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--border-radius-md);
14
+ background: var(--color-background-secondary); border: 1px solid var(--color-border-secondary); min-width: 0; }
15
+ .part .main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
16
+ .part .k { font-size: var(--font-text-xs-size); color: var(--color-text-tertiary); text-transform: uppercase; letter-spacing: .04em; }
17
+ .part .v { font-weight: 600; font-size: var(--font-text-sm-size); overflow-wrap: anywhere; }
18
+ .part .pic { width: 64px; flex: none; border-radius: var(--border-radius-sm); }
19
+ .part .pic.r16x9 { aspect-ratio: 16 / 9; }
20
+ @media (max-width: 420px) { .hero { grid-template-columns: 1fr; } }
21
+ </style>
22
+ </head>
23
+ <body>
24
+ <main class="app" id="content" aria-live="polite"><div class="status" role="status">Loading the template…</div></main>
25
+ <div id="toast" role="status" aria-live="polite"></div>
26
+ <script>
27
+ /*@BRIDGE_JS@*/
28
+ (function () {
29
+ "use strict";
30
+ var h = UI.h;
31
+ var PLAY = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M8 5v14l11-7z"/></svg>';
32
+ var PAUSE = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 5h4v14H6zm8 0h4v14h-4z"/></svg>';
33
+ var content = document.getElementById("content");
34
+ var tpl = null;
35
+
36
+ function playButton(key, url, name) {
37
+ if (!url) return null;
38
+ var playing = Media.playing() === key;
39
+ var b = h("button", { type: "button", class: "icon", "aria-pressed": String(playing),
40
+ "aria-label": (playing ? "Pause " : "Play ") + name, onclick: function () { Media.toggleAudio(key, url); } }, []);
41
+ b.innerHTML = playing ? PAUSE : PLAY;
42
+ return b;
43
+ }
44
+
45
+ // The product names of the model tiers (videos.models.Video.GenerationModel): the old high-family values
46
+ // (xhigh, v1_video, medium, low) all run as Cinder now.
47
+ var MODEL_NAMES = { pro: "Caldera", high: "Cinder", xhigh: "Cinder", v1_video: "Cinder", medium: "Cinder", low: "Cinder" };
48
+ function modelName(value) {
49
+ return MODEL_NAMES[String(value).toLowerCase()] || String(value);
50
+ }
51
+
52
+ function part(label, value, extra, pic) {
53
+ return h("div", { class: "part" }, [pic || null, h("span", { class: "main" }, [
54
+ h("span", { class: "k" }, [label]), h("span", { class: "v" }, [value || "—"])
55
+ ]), extra || null]);
56
+ }
57
+
58
+ /** The look from the server (newer Cliptude), else what the summary itself says. */
59
+ function look(t) {
60
+ if (t.look) return t.look;
61
+ return {
62
+ voice: t.voice_name ? { name: t.voice_name, provider: t.voice_provider, preview_url: "" } : null,
63
+ avatar: t.avatar_name ? { name: t.avatar_name, image_url: t.avatar_preview_url || "" } : null,
64
+ switches: [
65
+ { key: "animations", label: "Animations", on: !t.disable_animations },
66
+ { key: "overlays", label: "Text overlays", on: !t.disable_overlays },
67
+ { key: "sound_effects", label: "Sound effects", on: !t.disable_sound_effects },
68
+ { key: "transitions", label: "Transitions", on: !t.disable_transitions }
69
+ ]
70
+ };
71
+ }
72
+
73
+ function render() {
74
+ var t = tpl, l = look(t);
75
+ var presenter = l.avatar || l.character || null;
76
+ var heroPic = presenter && presenter.image_url ? UI.img(presenter.image_url, presenter.name, UI.initials(presenter.name))
77
+ : l.background && l.background.image_url ? UI.img(l.background.image_url, "Background", "")
78
+ : UI.img("", "", UI.initials(t.name));
79
+ if (l.character) heroPic.classList.add("portrait");
80
+ var facts = [t.format_label || t.format, t.duration ? t.duration + " min" : "", t.aspect_ratio || "16:9", t.language || ""]
81
+ .filter(Boolean).map(function (x) { return h("span", { class: "chip" }, [x]); });
82
+
83
+ var parts = [];
84
+ if (l.voice) {
85
+ parts.push(part("Voice", l.voice.name + (l.voice.provider ? " · " + l.voice.provider : ""),
86
+ playButton("voice", l.voice.preview_url, "the voice " + l.voice.name)));
87
+ } else if (t.format !== "talking_head") {
88
+ parts.push(part("Voice", "None set"));
89
+ }
90
+ if (l.avatar) parts.push(part("Presenter", l.avatar.name, null, l.avatar.image_url ? UI.img(l.avatar.image_url, "", "") : null));
91
+ if (t.format === "avatar_video" && !l.avatar) parts.push(part("Presenter", "No avatar chosen"));
92
+ if (l.character) parts.push(part("Character", l.character.name, null, l.character.image_url ? UI.img(l.character.image_url, "", "") : null));
93
+ if (l.music) {
94
+ parts.push(part("Music", l.music.on ? (l.music.label || l.music.file) + (l.music.default ? " (default)" : "") : "No music",
95
+ l.music.on ? playButton("music", l.music.preview_url, "the music") : null));
96
+ }
97
+ if (l.background) {
98
+ var bg = UI.img(l.background.image_url, "", "");
99
+ bg.classList.add("r16x9");
100
+ parts.push(part("Background", l.background.value.indexOf("upload:") === 0 ? "Your upload" : l.background.value, null, bg));
101
+ }
102
+ parts.forEach(function (p) { var pic = p.querySelector(".thumb"); if (pic) pic.classList.add("pic"); });
103
+
104
+ var styleChips = [];
105
+ if (l.style_pack) styleChips.push(h("span", { class: "chip info" }, [
106
+ h("span", { class: "swatches", style: { display: "inline-flex", verticalAlign: "middle", marginRight: "4px" } },
107
+ (l.style_pack.swatches || []).map(function (c) { return h("span", { class: "swatch", style: { background: c, width: "10px", height: "10px" } }); })),
108
+ "Style: " + l.style_pack.label]));
109
+ if (l.visual_theme) styleChips.push(h("span", { class: "chip info" }, ["Theme: " + l.visual_theme.label]));
110
+ if (l.caption_style) styleChips.push(h("span", { class: "chip info" }, ["Captions: " + l.caption_style.label]));
111
+ if (t.generation_model) styleChips.push(h("span", { class: "chip" }, ["Model: " + modelName(t.generation_model)]));
112
+
113
+ var switches = (l.switches || []).map(function (s) {
114
+ return h("span", { class: "chip " + (s.on ? "ok" : "warn off"), "aria-label": s.label + (s.on ? " on" : " off") },
115
+ [(s.on ? "✓ " : "✕ ") + s.label]);
116
+ });
117
+
118
+ UI.clear(content);
119
+ content.appendChild(h("div", { class: "hero" }, [heroPic, h("div", { class: "sec" }, [
120
+ h("h1", { style: { margin: 0, fontSize: "var(--font-heading-sm-size)" } }, [t.name || "Template"]),
121
+ h("span", { class: "chips" }, facts),
122
+ styleChips.length ? h("span", { class: "chips" }, styleChips) : null
123
+ ])]));
124
+ (t.warnings || []).forEach(function (w) { content.appendChild(h("div", { class: "callout warn", role: "note" }, [String(w)])); });
125
+ if (parts.length) content.appendChild(h("div", { class: "parts" }, parts));
126
+ if (switches.length) content.appendChild(h("section", { class: "sec" }, [h("h2", {}, ["Switches"]), h("div", { class: "chips" }, switches)]));
127
+ content.appendChild(h("div", { class: "selection" }, [
128
+ h("button", { type: "button", onclick: function () {
129
+ UI.choose("I want to change something in the template “" + t.name + "” (template_id " + t.id + "). Ask me what to change.",
130
+ { template_id: t.id, change: true });
131
+ } }, ["Change something"]),
132
+ h("button", { type: "button", class: "primary", onclick: function () {
133
+ UI.choose("Make a video with the template “" + t.name + "” (template_id " + t.id + ").", { template_id: t.id });
134
+ } }, ["Make a video with this template"])
135
+ ]));
136
+ }
137
+
138
+ Media.onChange(function () { if (tpl) render(); });
139
+ Cliptude.connect({
140
+ name: "cliptude-template",
141
+ onResult: function (data) {
142
+ var err = UI.errorText(data);
143
+ if (err) { UI.status(content, err, "error"); return; }
144
+ tpl = data.template && !data.id ? data.template : data;
145
+ render();
146
+ },
147
+ onCancelled: function () { UI.status(content, "Cancelled."); }
148
+ }).catch(function () { UI.status(content, "This view could not connect to the chat.", "error"); });
149
+ })();
150
+ </script>
151
+ </body>
152
+ </html>
@@ -0,0 +1,93 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Templates</title>
7
+ <style>
8
+ /*@BASE_CSS@*/
9
+ .card { cursor: default; }
10
+ .card .thumb { aspect-ratio: 16 / 9; }
11
+ .tile { width: 100%; height: 100%; display: flex; align-items: flex-end; padding: 10px; color: #fff; font-weight: 700; font-size: 15px; }
12
+ .card .body .chips { margin-top: 2px; }
13
+ .card .actions { padding: 0 10px 10px; margin-top: auto; }
14
+ .card .actions button { width: 100%; }
15
+ </style>
16
+ </head>
17
+ <body>
18
+ <main class="app" aria-labelledby="title">
19
+ <div class="head">
20
+ <h1 id="title">Your templates</h1>
21
+ <span class="toolbar"><span class="sub" id="count"></span><button type="button" id="all" hidden aria-pressed="false">Show all</button></span>
22
+ </div>
23
+ <div id="content"><div class="status" role="status">Loading templates…</div></div>
24
+ </main>
25
+ <div id="toast" role="status" aria-live="polite"></div>
26
+ <script>
27
+ /*@BRIDGE_JS@*/
28
+ (function () {
29
+ "use strict";
30
+ var h = UI.h;
31
+ // Formats Cliptude makes today; templates of retired formats (whiteboard, sketch, stickman, low_poly_3d,
32
+ // monkey_explained, vox_animation, infographic, mannequin_3d, faceless_explainer, music, ...) hide behind "Show all".
33
+ var LIVE = { faceless_documentary: 1, faceless_top_10: 1, avatar_video: 1, talking_head: 1, vector_explainer: 1 };
34
+ var TILE = { faceless_documentary: "#1e3a5f, #0b1220", faceless_top_10: "#5b2130, #1a0b10", avatar_video: "#2d3b2a, #0e140c",
35
+ talking_head: "#4a3a1e, #171008", vector_explainer: "#3a2a5f, #120b20" };
36
+ var content = document.getElementById("content");
37
+ var all = document.getElementById("all");
38
+ var data = { results: [] };
39
+ var showAll = false;
40
+
41
+ function card(t) {
42
+ var pic;
43
+ if (t.format === "avatar_video" && t.avatar_preview_url) pic = UI.img(t.avatar_preview_url, "", UI.initials(t.avatar_name || t.name));
44
+ else pic = h("span", { class: "thumb" }, [h("span", { class: "tile", style: { background: "linear-gradient(150deg, " + (TILE[t.format] || "#444, #111") + ")" } },
45
+ [t.format_label || t.format || ""])]);
46
+ var chips = [t.duration ? t.duration + " min" : "", t.aspect_ratio || "", LIVE[t.format] ? "" : "Retired format"]
47
+ .filter(Boolean).map(function (x) { return h("span", { class: "chip" + (x === "Retired format" ? " warn" : "") }, [x]); });
48
+ return h("div", { class: "card", role: "listitem" }, [
49
+ pic,
50
+ h("span", { class: "body" }, [
51
+ h("span", { class: "name" }, [t.name || "Untitled"]),
52
+ h("span", { class: "muted" }, [(t.format_label || t.format || "") + (t.voice_name ? " · " + t.voice_name : "") +
53
+ (t.avatar_name ? " · " + t.avatar_name : "")]),
54
+ chips.length ? h("span", { class: "chips" }, chips) : null
55
+ ]),
56
+ h("span", { class: "actions" }, [h("button", { type: "button", class: LIVE[t.format] ? "primary" : "",
57
+ onclick: function () { UI.choose("Use the template “" + t.name + "” (template_id " + t.id + ").", { template_id: t.id }); } },
58
+ ["Use this template"])])
59
+ ]);
60
+ }
61
+
62
+ function render() {
63
+ var rows = data.results || [];
64
+ var live = rows.filter(function (t) { return LIVE[t.format]; });
65
+ var hidden = rows.length - live.length;
66
+ var shown = showAll ? rows : live;
67
+ all.hidden = hidden === 0;
68
+ all.textContent = showAll ? "Live formats only" : "Show all (" + hidden + " more)";
69
+ all.setAttribute("aria-pressed", String(showAll));
70
+ var total = data.count || rows.length;
71
+ document.getElementById("count").textContent = total > rows.length ? rows.length + " of " + total : rows.length + " saved";
72
+ if (!rows.length) { UI.status(content, "No templates yet. Ask Claude to make one: it walks you through the voice, look and music."); return; }
73
+ if (!shown.length) { UI.status(content, "None of your templates uses a format Cliptude makes today. Show all to see them, or ask Claude to make a new one."); return; }
74
+ var grid = h("div", { class: "grid wide", role: "list" });
75
+ shown.forEach(function (t) { grid.appendChild(card(t)); });
76
+ UI.clear(content).appendChild(grid);
77
+ }
78
+
79
+ all.addEventListener("click", function () { showAll = !showAll; render(); });
80
+ Cliptude.connect({
81
+ name: "cliptude-templates",
82
+ onResult: function (d) {
83
+ var err = UI.errorText(d);
84
+ if (err) { UI.status(content, err, "error"); return; }
85
+ data = d || { results: [] };
86
+ render();
87
+ },
88
+ onCancelled: function () { UI.status(content, "Cancelled."); }
89
+ }).catch(function () { UI.status(content, "This view could not connect to the chat.", "error"); });
90
+ })();
91
+ </script>
92
+ </body>
93
+ </html>