wicked-studio 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,271 @@
1
+ {
2
+ "id": "wicked-video",
3
+ "title": "Video",
4
+ "version": "0.9.0",
5
+ "protocol": [
6
+ 1,
7
+ 2
8
+ ],
9
+ "kinds": [
10
+ "demo-video",
11
+ "walkthrough"
12
+ ],
13
+ "entry": "index.html",
14
+ "sizes": [
15
+ "inline",
16
+ "pane",
17
+ "full"
18
+ ],
19
+ "permissions": [
20
+ {
21
+ "id": "artifact.read",
22
+ "why": "to show the cut and read its chapters"
23
+ },
24
+ {
25
+ "id": "artifact.write",
26
+ "why": "to reorder, rename or trim a chapter, each as one new cut with Undo"
27
+ },
28
+ {
29
+ "id": "media.read",
30
+ "why": "to play the video and its chapters"
31
+ },
32
+ {
33
+ "id": "selection.chip",
34
+ "why": "to make the chapter you select the subject of your next message"
35
+ },
36
+ {
37
+ "id": "artifact.theme",
38
+ "why": "to change the captions and the title and end cards"
39
+ },
40
+ {
41
+ "id": "artifact.export",
42
+ "why": "to export the video"
43
+ },
44
+ {
45
+ "id": "ui.fullscreen",
46
+ "why": "to show the video full screen"
47
+ }
48
+ ],
49
+ "surfaces": {
50
+ "card": {
51
+ "interactive": true,
52
+ "aspect": "16:9",
53
+ "actions": [
54
+ {
55
+ "id": "prev",
56
+ "label": "Previous chapter",
57
+ "verb": "plugin"
58
+ },
59
+ {
60
+ "id": "next",
61
+ "label": "Next chapter",
62
+ "verb": "plugin",
63
+ "primary": true
64
+ },
65
+ {
66
+ "id": "ask",
67
+ "label": "Ask about this",
68
+ "verb": "host:ask"
69
+ },
70
+ {
71
+ "id": "export",
72
+ "label": "Export",
73
+ "verb": "host:export"
74
+ }
75
+ ]
76
+ },
77
+ "options": {
78
+ "tabs": [
79
+ {
80
+ "id": "chapters",
81
+ "label": "Chapters",
82
+ "render": "plugin"
83
+ },
84
+ {
85
+ "id": "captions",
86
+ "label": "Captions",
87
+ "render": "controls",
88
+ "controls": [
89
+ {
90
+ "id": "on",
91
+ "label": "Captions",
92
+ "type": "toggle"
93
+ },
94
+ {
95
+ "id": "burn",
96
+ "label": "Burn into video",
97
+ "type": "toggle"
98
+ },
99
+ {
100
+ "id": "position",
101
+ "label": "Position",
102
+ "type": "segmented",
103
+ "options": [
104
+ {
105
+ "id": "bottom",
106
+ "label": "Bottom"
107
+ },
108
+ {
109
+ "id": "top",
110
+ "label": "Top"
111
+ }
112
+ ]
113
+ },
114
+ {
115
+ "id": "size",
116
+ "label": "Text size",
117
+ "type": "range",
118
+ "min": 18,
119
+ "max": 72,
120
+ "step": 2
121
+ },
122
+ {
123
+ "id": "lines",
124
+ "label": "Max lines",
125
+ "type": "range",
126
+ "min": 1,
127
+ "max": 3,
128
+ "step": 1
129
+ },
130
+ {
131
+ "id": "wrap",
132
+ "label": "Line length",
133
+ "type": "range",
134
+ "min": 20,
135
+ "max": 80,
136
+ "step": 1
137
+ },
138
+ {
139
+ "id": "look",
140
+ "label": "Look",
141
+ "type": "segmented",
142
+ "options": [
143
+ {
144
+ "id": "bar",
145
+ "label": "Bar"
146
+ },
147
+ {
148
+ "id": "outline",
149
+ "label": "Outline"
150
+ },
151
+ {
152
+ "id": "plain",
153
+ "label": "Plain"
154
+ }
155
+ ]
156
+ }
157
+ ]
158
+ },
159
+ {
160
+ "id": "theme",
161
+ "label": "Theme",
162
+ "render": "controls",
163
+ "controls": [
164
+ {
165
+ "id": "palette",
166
+ "label": "Colours",
167
+ "type": "select",
168
+ "options": [
169
+ {
170
+ "id": "studio",
171
+ "label": "Studio skin · default"
172
+ },
173
+ {
174
+ "id": "corporate",
175
+ "label": "Corporate Light"
176
+ },
177
+ {
178
+ "id": "midnight",
179
+ "label": "Midnight Purple"
180
+ },
181
+ {
182
+ "id": "warm",
183
+ "label": "Warm Dark"
184
+ },
185
+ {
186
+ "id": "custom",
187
+ "label": "Custom"
188
+ }
189
+ ]
190
+ },
191
+ {
192
+ "id": "title",
193
+ "label": "Title card",
194
+ "type": "toggle"
195
+ },
196
+ {
197
+ "id": "titletext",
198
+ "label": "Title",
199
+ "type": "text",
200
+ "maxChars": 80
201
+ },
202
+ {
203
+ "id": "end",
204
+ "label": "End card",
205
+ "type": "toggle"
206
+ },
207
+ {
208
+ "id": "endtext",
209
+ "label": "End card text",
210
+ "type": "text",
211
+ "maxChars": 80
212
+ },
213
+ {
214
+ "id": "background",
215
+ "label": "Background",
216
+ "type": "color"
217
+ },
218
+ {
219
+ "id": "foreground",
220
+ "label": "Text colour",
221
+ "type": "color"
222
+ },
223
+ {
224
+ "id": "accent",
225
+ "label": "Accent",
226
+ "type": "color"
227
+ },
228
+ {
229
+ "id": "font",
230
+ "label": "Font",
231
+ "type": "select",
232
+ "options": [
233
+ {
234
+ "id": "inter",
235
+ "label": "Inter"
236
+ },
237
+ {
238
+ "id": "roboto",
239
+ "label": "Roboto"
240
+ },
241
+ {
242
+ "id": "source-sans",
243
+ "label": "Source Sans 3"
244
+ },
245
+ {
246
+ "id": "plex",
247
+ "label": "IBM Plex Sans"
248
+ },
249
+ {
250
+ "id": "system",
251
+ "label": "System"
252
+ },
253
+ {
254
+ "id": "archivo",
255
+ "label": "Archivo"
256
+ }
257
+ ]
258
+ }
259
+ ]
260
+ }
261
+ ]
262
+ },
263
+ "full": {
264
+ "modes": [
265
+ "simple",
266
+ "advanced"
267
+ ],
268
+ "default": "simple"
269
+ }
270
+ }
271
+ }
@@ -0,0 +1,28 @@
1
+ <!doctype html>
2
+ <html lang="en"><head><meta charset="utf-8">
3
+ <meta name="wicked-editor" content="wicked-video">
4
+ <meta name="wicked-editor-version" content="0.9.0">
5
+ <title>Video</title>
6
+ <style>
7
+ :root{--surface-base:#fff;--surface-card:#f6f7f9;--surface-raised:#fff;--ink-high:#0d1117;--ink-body:#2b333d;--ink-muted:#5b6673;--border:#d5dae1;--accent:#224a5e;--font-sans:system-ui,sans-serif}
8
+ *{box-sizing:border-box}html,body{height:100%;margin:0}body{font:13px var(--font-sans);background:var(--surface-base);color:var(--ink-high)}[hidden]{display:none!important}
9
+ button,input,select,textarea{font:inherit;color:inherit}button{border:1px solid var(--border);border-radius:6px;background:var(--surface-raised);padding:7px 10px;cursor:pointer}button:disabled{opacity:.5;cursor:default}button:focus-visible,input:focus-visible,select:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
10
+ .video-editor{display:grid;grid-template-columns:240px minmax(0,1fr);height:100%;outline:none}.chapters{padding:16px 12px;overflow:auto;background:var(--surface-card);border-right:1px solid var(--border)}h2{font-size:14px;margin:0 0 12px}ol{list-style:none;padding:0;margin:0;display:grid;gap:8px}.chapter{width:100%;text-align:left;display:flex;gap:8px;align-items:center}.chapter[aria-current=true],.chip[aria-current=true],.segment[aria-current=true]{border-color:var(--accent);background:color-mix(in srgb,var(--accent) 12%,var(--surface-card))}.number{color:var(--ink-muted);font-variant-numeric:tabular-nums}.duration{margin-left:auto;font-size:11px;color:var(--ink-muted)}
11
+ .work{min-width:0;min-height:0;padding:16px;display:flex;flex-direction:column;gap:12px;overflow:auto}.player{container-type:inline-size;position:relative;aspect-ratio:16/9;background:var(--video-background,var(--surface-raised));flex:none;max-height:calc(100vh - 150px);width:100%;overflow:hidden;border-radius:8px}.player video{width:100%;height:100%;object-fit:contain;display:block}.poster{position:absolute;inset:0;width:100%;height:100%;object-fit:contain}.unavailable{position:absolute;inset:auto 0 0 0;z-index:1;display:grid;place-items:center;color:var(--video-foreground,var(--ink-high));padding:24px;text-align:center}.caption{position:absolute;left:10%;right:10%;text-align:center;white-space:pre-line;color:var(--video-foreground,var(--ink-high));font-family:var(--video-font,system-ui),system-ui,sans-serif;font-size:max(9px,calc(var(--caption-px,36) / 1080 * 56.25cqw));line-height:1.3;pointer-events:none;overflow:hidden}.caption[data-position=bottom]{bottom:8%}.caption[data-position=top]{top:8%}.caption[data-look=bar]{background:var(--video-background,var(--surface-raised));padding:8px 12px;border-radius:4px}.caption[data-look=outline]{text-shadow:1px 1px 2px #000,-1px -1px 2px #000}
12
+ .transport{display:flex;align-items:center;gap:12px}.chips{display:flex;gap:6px;overflow-x:auto;flex:none}.chip{border-radius:999px;white-space:nowrap;padding:5px 9px}.timeline{display:flex;gap:4px;min-height:52px;flex:none}.segment-box{position:relative;min-width:32px}.segment{width:100%;height:52px;text-align:left;overflow:hidden;white-space:nowrap;background:var(--surface-card);border-top:3px solid var(--video-accent,var(--accent))}.trim-handle{position:absolute;top:2px;bottom:2px;width:10px;cursor:ew-resize;padding:0;background:var(--accent);touch-action:none;border:0}.trim-handle[data-edge=in]{left:0}.trim-handle[data-edge=out]{right:0}.editor-fields{display:grid;gap:10px;margin-top:16px}.buttons{display:flex;gap:6px;flex-wrap:wrap}label{display:grid;gap:5px;color:var(--ink-muted)}input,select,textarea{width:100%;padding:7px;border:1px solid var(--border);border-radius:5px;background:var(--surface-raised);color:var(--ink-high)}.trim-fields{display:grid;grid-template-columns:1fr 1fr;gap:8px}.hint,.status{font-size:12px;color:var(--ink-muted);line-height:1.5;margin:8px 0}.inspectors{padding:16px;border-left:1px solid var(--border);overflow:auto;background:var(--surface-card)}.inspectors textarea{resize:vertical;min-height:100px}.summary{line-height:1.6;white-space:pre-line}.video-editor[data-mode=advanced][data-surface=full]{grid-template-columns:240px minmax(0,1fr) 280px}
13
+ .video-editor[data-surface=card]{grid-template-columns:1fr}.video-editor[data-surface=card] .work{padding:0;gap:6px}.video-editor[data-surface=card] .player{border-radius:0;max-height:calc(100vh - 70px);flex:1;min-height:0}.video-editor[data-surface=card] .transport{padding:0 8px}.video-editor[data-surface=options]{grid-template-columns:1fr}.video-editor[data-surface=options] .chapters{border:0}
14
+ .timeline{position:relative}.timeline[data-proof=true]{padding-bottom:24px}.check-track{position:absolute;bottom:0;left:10px;right:10px;height:20px}.check-mark{position:absolute;transform:translateX(-50%);padding:0 3px;height:20px;min-width:12px;border:0;border-radius:2px;border-left:2px solid currentColor;background:var(--surface-raised);color:var(--ink-muted)}.check-mark[data-state=FAIL],.chapter-verdict[data-verdict=FAIL],#check-list [data-state=FAIL]{color:var(--status-fail)}.check-mark[data-state=PASS],.chapter-verdict[data-verdict=PASS]{color:var(--status-ok)}#proof{margin-bottom:20px}#check-list{font-size:12px;line-height:1.5;overflow-wrap:anywhere}textarea:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
15
+ @media(max-width:850px){.video-editor[data-mode=advanced][data-surface=full]{grid-template-columns:200px minmax(0,1fr)}.inspectors{grid-column:2;border-left:0}.video-editor[data-surface=full]{grid-template-columns:200px minmax(0,1fr)}}
16
+ </style></head><body><script>var wickedEditor=(function(Z){"use strict";var Ut=Object.defineProperty;var Dt=(Z,G,re)=>G in Z?Ut(Z,G,{enumerable:!0,configurable:!0,writable:!0,value:re}):Z[G]=re;var ut=(Z,G,re)=>Dt(Z,typeof G!="symbol"?G+"":G,re);const G={"Alt+J":{verb:"navigate",what:"next card or row"},"Alt+K":{verb:"navigate",what:"previous card or row"},"Alt+/":{verb:"navigate",what:"the keyboard shortcuts overlay"},"Alt+P":{verb:"navigate",what:"peek at the top item that needs you"},"Alt+G":{verb:"navigate",what:"jump to the top item that needs you"},"Alt+B":{verb:"navigate",what:"back to where you were"},"Alt+T":{verb:"navigate",what:"the run’s evidence timeline"},"Alt+U":{verb:"navigate",what:"the run’s unit list"},"Alt+A":{verb:"approve",what:"approve the open gate"},"Alt+R":{verb:"decide",what:"reject the open gate"},"Alt+X":{verb:"decide",what:"select a gate for batch resolution"},"Alt+N":{verb:"compose",what:"compose a steer note"}},re=new Set(["Escape","Mod+K","Tab","Shift+Tab"]);function pt(t){if(re.has(t))return!0;const n=G[ft(t)];return n!==void 0&&n.verb==="navigate"}function ft(t){const n=/^alt\+(.)$/i.exec(t);return n===null?t:`Alt+${n[1].toUpperCase()}`}const K="wicked.editor",q=1,He=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),ht=["card","options","full"];function Xe(t){return t==="inline"?"card":t==="pane"?"options":"full"}function mt(t){const n=He(t)?t:{},l=n.size==="inline"||n.size==="full"?n.size:"pane",c=n.protocol===2?2:1,a=c===2&&typeof n.tab=="string"?n.tab:null,v=c===2&&ht.includes(n.surface)?n.surface:Xe(l),b=v==="options"&&a===null?"full":v,y=c===2&&(n.mode==="simple"||n.mode==="advanced")?n.mode:null;return{protocol:c,surface:b,tab:a,mode:y,size:l}}function bt(t,n,l){return{editor:t,version:n,protocol:[1,2],surfaces:l}}function vt(t,n){const l=document.querySelector('meta[name="wicked-editor-version"]')?.getAttribute("content")??"0.0.0";parent.postMessage({p:K,v:q,type:"plugin.ready",payload:bt(t,l,n)},"*")}function yt(t,n,l){const c=t.metaKey||t.ctrlKey;let a=null;if(t.key==="Escape")a="Escape";else if(c&&!t.altKey&&t.key.toLowerCase()==="k")a="Mod+K";else if(t.altKey&&!c&&/^Key[A-Z]$/.test(t.code)&&pt(`Alt+${t.code.slice(3)}`))a=`Alt+${t.code.slice(3)}`;else if(t.key==="Tab"){const v=Array.from(n.querySelectorAll("button, input, select, textarea, [tabindex]")).filter(y=>y.tabIndex>=0&&!y.matches(":disabled")&&y.closest("[hidden]")===null),b=v.indexOf(t.target);(t.shiftKey?b<=0:b===-1||b===v.length-1)&&(a=t.shiftKey?"Shift+Tab":"Tab")}return a===null?!1:(t.preventDefault(),t.stopPropagation(),l(a),!0)}class gt{constructor(n,l){ut(this,"revs",new Map);this.port=n,this.h=l}reply(n,l){this.port.postMessage({p:K,v:q,re:n,ok:!0,payload:l})}refuse(n,l,c){this.port.postMessage({p:K,v:q,re:n,ok:!1,error:{code:l,message:c}})}bump(n){const l=(this.revs.get(n)??0)+1;return this.revs.set(n,l),l}values(n,l){this.port.postMessage({p:K,v:q,type:"options.values",payload:{tab:n,rev:this.bump(n),values:l}})}height(n){this.port.postMessage({p:K,v:q,type:"ui.height",payload:{px:Math.round(n)}})}dispatch(n){const l=He(n.payload)?n.payload:{},c=typeof n.id=="string"?n.id:null;switch(n.type){case"host.surface":{const a=l.surface;return(a==="card"||a==="options"||a==="full")&&this.h.surface?.(a,l.mode==="simple"||l.mode==="advanced"?l.mode:null),!0}case"host.mode":{if(c===null)return!0;const a=l.mode;return a!=="simple"&&a!=="advanced"?(this.refuse(c,"bad_request","mode is simple or advanced"),!0):(this.reply(c,{mode:this.h.mode?.(a)??a}),!0)}case"host.action":{if(c===null)return!0;const a=l.id;return typeof a!="string"||this.h.action===void 0?(this.reply(c,{handled:!1}),!0):(Promise.resolve(this.h.action(a)).then(v=>this.reply(c,{handled:v.handled===!0,...typeof v.status=="string"?{status:v.status.slice(0,120)}:{}}),()=>this.reply(c,{handled:!1})),!0)}case"host.tab":return typeof l.tab=="string"&&this.h.tab?.(l.tab),!0;case"host.selection":return Array.isArray(l.anchors)&&this.h.selection?.(l.anchors),!0;case"options.changed":{if(c===null)return!0;const a=l.tab,v=l.id;return typeof a!="string"||typeof v!="string"||this.h.optionsChanged===void 0?(this.refuse(c,"unsupported","no controls here"),!0):(Promise.resolve(this.h.optionsChanged(a,v,l.value)).then(b=>this.reply(c,{applied:b.applied,rev:this.bump(a),values:b.values,...b.reason!==void 0?{reason:b.reason.slice(0,120)}:{}}),b=>this.refuse(c,"unavailable",b instanceof Error?b.message.slice(0,120):"failed")),!0)}default:return!1}}}const Ze={card:{interactive:!0,aspect:"16:9",actions:[{id:"prev",label:"Previous chapter",verb:"plugin"},{id:"next",label:"Next chapter",verb:"plugin",primary:!0},{id:"ask",label:"Ask about this",verb:"host:ask"},{id:"export",label:"Export",verb:"host:export"}]},options:{tabs:[{id:"chapters",label:"Chapters",render:"plugin"},{id:"captions",label:"Captions",render:"controls",controls:[{id:"on",label:"Captions",type:"toggle"},{id:"burn",label:"Burn into video",type:"toggle"},{id:"position",label:"Position",type:"segmented",options:[{id:"bottom",label:"Bottom"},{id:"top",label:"Top"}]},{id:"size",label:"Text size",type:"range",min:18,max:72,step:2},{id:"lines",label:"Max lines",type:"range",min:1,max:3,step:1},{id:"wrap",label:"Line length",type:"range",min:20,max:80,step:1},{id:"look",label:"Look",type:"segmented",options:[{id:"bar",label:"Bar"},{id:"outline",label:"Outline"},{id:"plain",label:"Plain"}]}]},{id:"theme",label:"Theme",render:"controls",controls:[{id:"palette",label:"Colours",type:"select",options:[{id:"studio",label:"Studio skin · default"},{id:"corporate",label:"Corporate Light"},{id:"midnight",label:"Midnight Purple"},{id:"warm",label:"Warm Dark"},{id:"custom",label:"Custom"}]},{id:"title",label:"Title card",type:"toggle"},{id:"titletext",label:"Title",type:"text",maxChars:80},{id:"end",label:"End card",type:"toggle"},{id:"endtext",label:"End card text",type:"text",maxChars:80},{id:"background",label:"Background",type:"color"},{id:"foreground",label:"Text colour",type:"color"},{id:"accent",label:"Accent",type:"color"},{id:"font",label:"Font",type:"select",options:[{id:"inter",label:"Inter"},{id:"roboto",label:"Roboto"},{id:"source-sans",label:"Source Sans 3"},{id:"plex",label:"IBM Plex Sans"},{id:"system",label:"System"},{id:"archivo",label:"Archivo"}]}]}]},full:{modes:["simple","advanced"],default:"simple"}},Ge={corporate:{background:"#FFFFFF",foreground:"#1E293B",accent:"#0891B2"},midnight:{background:"#0A0A0F",foreground:"#FFFFFF",accent:"#A100FF"},warm:{background:"#1A1A2E",foreground:"#F8F8F2",accent:"#FFD93D"}},kt=(t,n)=>["background","foreground","accent"].every(l=>t[l].toLowerCase()===n[l].toLowerCase());function be(t){if(t.palette===void 0||t.palette==="skin")return"studio";for(const[n,l]of Object.entries(Ge))if(kt(t,l))return n;return"custom"}function Re(t,n,l){const c=be(t)==="studio"?l??n??t:t;return{background:c.background,foreground:c.foreground,accent:c.accent}}const Pe={inter:"Inter",roboto:"Roboto","source-sans":"Source Sans 3",plex:"IBM Plex Sans",system:"system-ui",archivo:"Archivo"};function le(t,n,l=null,c){const a=t.captions,v=t.theme;if(n==="captions")return{on:a.on,burn:a.burnIn,position:a.position,size:a.size,lines:a.maxLines,wrap:a.wrapChars,look:a.style};if(n==="theme"){const b=Re(v,l,c),y=be(v)==="studio"?c?.font??v.font:v.font;return{palette:be(v),title:v.titleCard.on,titletext:v.titleCard.title,end:v.endCard.on,endtext:v.endCard.title,background:b.background,foreground:b.foreground,accent:b.accent,font:Object.keys(Pe).find(k=>Pe[k]===y)??"system"}}return{}}function St(t,n,l,c){const a=JSON.parse(JSON.stringify(t));if(n==="captions"){const v={on:"on",burn:"burnIn",position:"position",size:"size",lines:"maxLines",wrap:"wrapChars",look:"style"};Object.assign(a.captions,{[v[l]]:c})}else if(n==="theme")switch(l){case"title":a.theme.titleCard.on=c;break;case"titletext":a.theme.titleCard.title=c;break;case"end":a.theme.endCard.on=c;break;case"endtext":a.theme.endCard.title=c;break;case"font":a.theme.font=Pe[c],a.theme.palette="custom";break;case"palette":a.theme.palette=c==="studio"?"skin":"custom",(c==="corporate"||c==="midnight"||c==="warm")&&Object.assign(a.theme,Ge[c]);break;default:Object.assign(a.theme,{[l]:c,palette:"custom"})}return a}const R={actions:4,tabs:5,controls:12,options:8,labelChars:24,maxChars:200},Te=/^[a-z][a-z0-9-]{0,31}$/u,xt=/^[A-Za-z0-9 ·'-]{1,24}$/u,At=["approve","accept","deliver","merge","send","launch","delete","remove","stop","deny","allow","grant","install"],$t={а:"a",е:"e",о:"o",р:"p",с:"c",у:"y",х:"x",і:"i",ј:"j",ѕ:"s","ԁ":"d","ӏ":"l",α:"a",ε:"e",ο:"o",ρ:"p",ν:"v",τ:"t",κ:"k",ι:"i",μ:"m",0:"o",1:"l",3:"e",4:"a",5:"s",7:"t"};function Ct(t){const n=t.normalize("NFKD").replace(/\p{M}+/gu,"").toLowerCase();let l="";for(const c of n)l+=$t[c]??c;return l.split(/[^a-z]+/u).filter(c=>c!=="")}function wt(t){return Ct(t).some(n=>At.some(l=>n.startsWith(l)))}const ee=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),Le=t=>typeof t=="number"&&Number.isFinite(t),m=t=>({ok:!1,reason:t}),Et=/(?:[A-Za-z][0-9]|[0-9][A-Za-z])/u;function Fe(t,n){return typeof t!="string"||!xt.test(t)?`${n}: a label is 1 to ${R.labelChars} plain characters`:Et.test(t)?`${n}: a word in a label is letters or digits, not both`:wt(t)?`${n}: "${t}" uses a word only the host's own controls may use`:null}function Me(t,n){const l=new Set;for(const c of t){if(l.has(c.id))return`${n}: the id "${c.id}" is used twice`;l.add(c.id)}return null}const te=(t,n,l)=>{for(const c of Object.keys(t))if(!n.includes(c))return`${l}: unknown field "${c}"`;return null};function Tt(t,n){if(!ee(t))return m(`${n}: not an object`);const l=te(t,["id","label","type","options","min","max","step","maxChars"],n);if(l!==null)return m(l);if(typeof t.id!="string"||!Te.test(t.id))return m(`${n}: a bad id`);const c=Fe(t.label,n);if(c!==null)return m(c);const a=t.type;if(a!=="toggle"&&a!=="segmented"&&a!=="select"&&a!=="color"&&a!=="text"&&a!=="range")return m(`${n}: an unknown control type`);const v={id:t.id,label:t.label,type:a};if(a==="segmented"||a==="select"){const b=t.options;if(!Array.isArray(b)||b.length<2||b.length>R.options)return m(`${n}: ${a} needs 2 to ${R.options} options`);const y=[];for(const[V,g]of b.entries()){if(!ee(g)||typeof g.id!="string"||!Te.test(g.id))return m(`${n}.options[${V}]: a bad id`);const A=Fe(g.label,`${n}.options[${V}]`);if(A!==null)return m(A);const C=te(g,["id","label"],`${n}.options[${V}]`);if(C!==null)return m(C);y.push({id:g.id,label:g.label})}const k=Me(y,`${n}.options`);if(k!==null)return m(k);v.options=y}else if(t.options!==void 0)return m(`${n}: only select and segmented take options`);if(a==="range"){const{min:b,max:y,step:k}=t;if(!Le(b)||!Le(y)||!Le(k))return m(`${n}: range needs finite min, max and step`);if(!(b<y)||!(k>0)||k>y-b)return m(`${n}: range needs min < max and 0 < step ≤ max - min`);if(Math.abs(b)>1e9||Math.abs(y)>1e9||k<1e-6||(y-b)/k>1e6)return m(`${n}: range bounds are within ±1e9, step ≥ 1e-6, at most 1e6 steps`);if(k<Math.max(Math.abs(b),Math.abs(y))*1e-12)return m(`${n}: range step is too fine for its bounds`);v.min=b,v.max=y,v.step=k}else if(t.min!==void 0||t.max!==void 0||t.step!==void 0)return m(`${n}: only range takes min, max and step`);if(a==="text"){const b=t.maxChars===void 0?R.maxChars:t.maxChars;if(!Number.isInteger(b)||b<1||b>R.maxChars)return m(`${n}: maxChars is 1 to ${R.maxChars}`);v.maxChars=b}else if(t.maxChars!==void 0)return m(`${n}: only text takes maxChars`);return{ok:!0,value:v}}function Lt(t){if(!ee(t))return m("surfaces: not an object");const n=te(t,["card","options","full"],"surfaces");if(n!==null)return m(n);const l=t.card;if(!ee(l))return m("surfaces.card is required");const c=te(l,["interactive","aspect","actions"],"surfaces.card");if(c!==null)return m(c);const a=l.interactive===void 0?!1:l.interactive;if(typeof a!="boolean")return m("surfaces.card.interactive: a boolean");const v=l.aspect===void 0?"16:9":l.aspect;if(v!=="16:9"&&v!=="4:3"&&v!=="auto")return m("surfaces.card.aspect: 16:9, 4:3 or auto");const b=l.actions===void 0?[]:l.actions;if(!Array.isArray(b)||b.length>R.actions)return m(`surfaces.card.actions: at most ${R.actions}`);const y=[];for(const[A,C]of b.entries()){const T=`surfaces.card.actions[${A}]`;if(!ee(C))return m(`${T}: not an object`);const M=te(C,["id","label","primary","verb"],T);if(M!==null)return m(M);if(typeof C.id!="string"||!Te.test(C.id))return m(`${T}: a bad id`);const i=Fe(C.label,T);if(i!==null)return m(i);const $=C.verb;if($!=="plugin"&&$!=="host:export"&&$!=="host:ask")return m(`${T}: verb is plugin, host:export or host:ask`);const I=C.primary===void 0?!1:C.primary;if(typeof I!="boolean")return m(`${T}: primary is a boolean`);y.push({id:C.id,label:C.label,primary:I,verb:$})}const k=Me(y,"surfaces.card.actions");if(k!==null)return m(k);let V=null;if(t.options!==void 0){const A=t.options;if(!ee(A))return m("surfaces.options: not an object");const C=te(A,["tabs"],"surfaces.options");if(C!==null)return m(C);const T=A.tabs;if(!Array.isArray(T)||T.length<1||T.length>R.tabs)return m(`surfaces.options.tabs: 1 to ${R.tabs}`);const M=[];for(const[$,I]of T.entries()){const O=`surfaces.options.tabs[${$}]`;if(!ee(I))return m(`${O}: not an object`);const _=te(I,["id","label","render","controls"],O);if(_!==null)return m(_);if(typeof I.id!="string"||!Te.test(I.id))return m(`${O}: a bad id`);const W=Fe(I.label,O);if(W!==null)return m(W);const j=I.render;if(j!=="plugin"&&j!=="controls")return m(`${O}: render is plugin or controls`);const ie={id:I.id,label:I.label,render:j};if(j==="controls"){const ae=I.controls;if(!Array.isArray(ae)||ae.length<1||ae.length>R.controls)return m(`${O}.controls: 1 to ${R.controls}`);const D=[];for(const[ve,N]of ae.entries()){const H=Tt(N,`${O}.controls[${ve}]`);if(!H.ok)return H;D.push(H.value)}const ne=Me(D,`${O}.controls`);if(ne!==null)return m(ne);ie.controls=D}else if(I.controls!==void 0)return m(`${O}: a plugin-rendered tab has no controls`);M.push(ie)}const i=Me(M,"surfaces.options.tabs");if(i!==null)return m(i);V={tabs:M}}let g=null;if(t.full!==void 0){const A=t.full;if(!ee(A))return m("surfaces.full: not an object");const C=te(A,["modes","default"],"surfaces.full");if(C!==null)return m(C);let T=null;if(A.modes!==void 0){const i=A.modes;if(!Array.isArray(i)||i.length!==2||i[0]!=="simple"||i[1]!=="advanced")return m('surfaces.full.modes: exactly ["simple","advanced"]');T=["simple","advanced"]}const M=A.default===void 0?"simple":A.default;if(M!=="simple"&&M!=="advanced")return m("surfaces.full.default: simple or advanced");if(T===null&&A.default!==void 0)return m("surfaces.full.default needs modes");g={modes:T,default:M}}return{ok:!0,value:{card:{interactive:a,aspect:v,actions:y},options:V,full:g}}}const Je=String.raw`(?:\d{1,3}(?:\.\d+)?%?|\.\d+%?)`,Ft=new RegExp(String.raw`^(?:#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})|(?:rgba?|hsla?)\(\s*${Je}(?:\s*,\s*${Je}){2,3}\s*\))$`,"iu");function Mt(t,n){switch(t.type){case"toggle":return typeof n=="boolean";case"segmented":case"select":return typeof n=="string"&&(t.options??[]).some(l=>l.id===n);case"color":return typeof n=="string"&&n.length<=64&&Ft.test(n);case"text":return typeof n=="string"&&n.length<=(t.maxChars??R.maxChars)&&!/[\r\n]/u.test(n);case"range":{if(!Le(n)||t.min===void 0||t.max===void 0||t.step===void 0||n<t.min||n>t.max)return!1;const l=Math.round((n-t.min)/t.step);return Math.abs(n-(t.min+l*t.step))<=t.step*.001}}}const je=Lt(Ze);if(!je.ok)throw new Error(je.reason);const Ot=je.value;function Ye(){document.body.insertAdjacentHTML("afterbegin",`<main id="video-editor" class="video-editor" data-testid="video-editor" tabindex="0">
17
+ <aside id="chapters" class="chapters"><h2>Chapters</h2><ol id="chapter-list"></ol><div id="editor-fields" class="editor-fields"></div><p id="hint" class="hint"></p></aside>
18
+ <section id="work" class="work"><div class="player"><video id="player" data-testid="video-player" playsinline preload="metadata" aria-label="Video"></video><div id="unavailable" class="unavailable">The video isn't available here</div><img id="poster" data-testid="video-poster" class="poster" alt="" hidden><div id="caption" class="caption"></div></div>
19
+ <div class="transport"><button id="play" data-testid="video-play" type="button">Play</button><span id="count"></span></div><div id="chips" class="chips" aria-label="Chapter chips"></div><div id="timeline" class="timeline" aria-label="Chapter timeline"></div><p id="status" class="status" role="status"></p></section>
20
+ <aside id="inspectors" class="inspectors"><section id="proof"><h2>Checks</h2><p id="proof-summary" class="summary"></p><ol id="check-list" aria-label="Checks"></ol></section><h2>Text</h2><textarea id="say" aria-label="Chapter caption text" readonly></textarea><h2>Theme</h2><p id="theme-summary" class="summary"></p></aside></main>`);const t=e=>document.getElementById(e),n=t("video-editor"),l=t("chapter-list"),c=t("editor-fields"),a=t("player"),v=t("chips"),b=t("timeline"),y=t("caption");let k=null,V=null,g="card",A="simple",C="chapters",T=1,M=[],i=null,$=null,I=0,O=!1,_=!1,W=null,j=null,ie="",ae=0,D=null,ne=0,ve=0,N=!1,H=null,ye=!1;const ce=new Map,Oe=(e,o)=>k?.postMessage({p:K,v:q,type:e,payload:o}),ge=(e,o)=>new Promise(r=>{if(k===null||_){r({ok:!1,error:{code:"unavailable",message:"No host here."}});return}const d=`wv-${++I}`,u=setTimeout(()=>{ce.delete(d),r({ok:!1,error:{code:"timeout",message:"The host has not answered; check Versions."}})},1e4);ce.set(d,{resolve:r,timer:u}),k.postMessage({p:K,v:q,type:e,id:d,payload:o})}),ke=()=>i?.chapters.find(e=>e.id===$),ze=e=>i?.chapters.find(o=>o.startSec>=0&&e>=o.startSec&&(o.durationSec<0||e<o.startSec+o.durationSec)),Qe=e=>e!==void 0&&e.startSec>=0&&i!==null&&i.style.captions.on&&(N||!(i.style.captions.burnIn&&i.ffmpeg?.burnIn)),z=()=>M.includes("artifact.write")&&!O&&!_,de=()=>g==="options"||A==="advanced",Ne=e=>{t("status").textContent=e,Oe("ui.status",{line:e.replace(/[\r\n]/g," ").slice(0,120)})},Ue=()=>{if(T===2&&i!==null)for(const e of["captions","theme"])V?.values(e,le(i.style,e,J,i.resolvedTheme))};let J=null;const De=e=>{if(typeof e!="string"||e===""||e.length>200||/url\(/i.test(e))return null;const o=document.createElement("span");o.style.color=e,document.body.append(o);const r=getComputedStyle(o).color;return o.remove(),/^rgba?\(\s*\d/.test(r)?r.replace(/\s+/g," "):null},et=e=>{if(typeof e!="object"||e===null)return;const o=e,r=De(o["--surface-raised"]??o["--surface-base"]),d=De(o["--ink-high"]),u=De(o["--accent"]);r!==null&&d!==null&&u!==null&&(J={background:r,foreground:d,accent:u});for(const[s,f]of Object.entries(e))typeof f=="string"&&/^--[a-z0-9-]+$/.test(s)&&f.length<=200&&!/url\(/i.test(f)&&document.documentElement.style.setProperty(s,f)},Be=()=>{D!==null&&URL.revokeObjectURL(D),D=null,a.removeAttribute("src")};let B=null;async function Nt(e){const o=await ge("artifact.media",{ref:"poster"});if(_||e!==ne)return;const r=o.payload?.blob,d=o.payload?.type,u=t("poster");if(B!==null&&(URL.revokeObjectURL(B),B=null),!o.ok||!(r instanceof Blob)||typeof d!="string"||!d.startsWith("image/")||typeof URL.createObjectURL!="function"){u.hidden=!0;return}B=URL.createObjectURL(r),u.src=B,u.alt=i?.proof?.verdict==="FAIL"?"The moment the walkthrough failed":"The recording's still",u.hidden=!1,t("unavailable").textContent=i?.proof?.verdict==="FAIL"?"No video: this is the moment it failed":"The video isn't available here"}async function oe(e="video",o){const r=++ne;if(ye=!0,!M.includes("media.read")){ye=!1,Be(),t("unavailable").hidden=!1;return}const d=await ge("artifact.media",{ref:e});if(_||r!==ne)return;Be();const u=d.payload?.blob,s=d.payload?.type;if(!d.ok||!(u instanceof Blob)||typeof s!="string"||!s.startsWith("video/")||typeof URL.createObjectURL!="function"){ye=!1,t("unavailable").hidden=!1,Nt(r);return}t("poster").hidden=!0,B!==null&&(URL.revokeObjectURL(B),B=null,t("poster").removeAttribute("src")),D=URL.createObjectURL(u),a.src=D,t("unavailable").hidden=!0,qe(),a.onloadedmetadata=()=>{if(!(_||r!==ne)){if(ye=!1,!N&&i!==null&&Number.isFinite(a.duration)){for(const[f,h]of i.chapters.entries())if(h.startSec>=0&&h.durationSec<0){const S=i.chapters.slice(f+1).find(x=>x.startSec>=0)?.startSec??a.duration;h.durationSec=Math.max(0,S-h.startSec),h.outSec=h.inSec+h.durationSec}w()}if(a.currentTime=H??o??(N?ke()?.inSec??0:Math.max(0,ke()?.startSec??0)),H!==null){H=null;const f=ze(a.currentTime);f!==void 0&&($=f.id),w()}}}}const Y=(e,o,r)=>{const d=document.createElement("button");return d.type="button",d.textContent=e,d.onclick=o,r!==void 0&&(d.dataset.testid=r),d};function ue(e,o=!0){i?.chapters.some(r=>r.id===e&&r.startSec>=0)&&(H=null,$=e,N&&(N=!1,oe()),a.currentTime=ke()?.startSec??0,w(),o&&M.includes("selection.chip")&&Oe("selection.set",{anchors:[{kind:"chapter",id:e}]}))}function It(e){if(!Number.isFinite(e)||e<0||(H=e,i===null))return;const o=ze(e);o!==void 0&&($=o.id),N?(N=!1,oe()):!ye&&D!==null&&a.readyState>=1&&(a.currentTime=e,H=null),w()}function Ke(e,o){const r=i?.chapters??[],d=r.findIndex(f=>f.id===e),u=d+o;if(u<0||u>=r.length)return;const s=r.filter(f=>f.id!==e);se({op:"chapter-move",chapter:e,after:u===0?null:s[u-1].id})}async function pe(){const e=++ve,o=await ge("artifact.read",{});if(_||e!==ve)return!1;const r=o.payload?.content;if(!o.ok||r?.type!=="demo-cut"||!Array.isArray(r.chapters))return Ne(o.error?.message??"No cut is available here."),!1;if(i!==null&&r.version<i.version)return!1;const d=i?.version;return i=r,d!==i.version&&(N=!1),i.chapters.some(u=>u.id===$&&u.startSec>=0)||($=i.chapters.find(u=>u.startSec>=0)?.id??null),w(),Ue(),g!=="options"&&d!==i.version&&oe(),!0}async function se(e,o=i?.version){if(!(!z()||i===null||o===void 0)){O=!0,w();try{const r=await ge("version.write",{base:o,ops:[e],summary:`chapter ${i.chapters.findIndex(d=>d.id===e.chapter)+1}`});r.ok?(await pe(),e.op==="chapter-take"&&g!=="options"&&(N=!0,oe({chapter:e.chapter}))):(Ne(r.error?.message??"The chapter could not be saved."),r.error?.code==="head_moved"&&await pe())}finally{O=!1,w()}}}function tt(e){if(!z()||i===null||j!==null)return;j=e.id,ie=e.title,ae=i.version,w();const o=c.querySelector('[data-testid="video-rename-input"]');o?.focus(),o?.select()}function Rt(){const e=i?.chapters.find(r=>r.id===j);if(e===void 0)return j=null,null;const o=document.createElement("input");return o.value=ie,o.maxLength=80,o.setAttribute("aria-label","Chapter title"),o.dataset.testid="video-rename-input",o.oninput=()=>{ie=o.value},o.onkeydown=r=>{r.key==="Escape"?(r.preventDefault(),r.stopPropagation(),j=null,w()):r.key==="Enter"&&(r.preventDefault(),r.stopPropagation(),j=null,o.value.trim()&&!/[\r\n]/.test(o.value)&&o.value!==e.title?se({op:"chapter-rename",chapter:e.id,title:o.value},ae):w())},o}function qe(){if(i===null)return;const e=i.style,o=ke();y.hidden=!Qe(o),y.dataset.position=e.captions.position,y.dataset.look=e.captions.style;const r=[];let d="";for(const f of(o?.say??"").split(/\s+/))d&&(d+" "+f).length>e.captions.wrapChars?(r.push(d),d=f):d+=(d?" ":"")+f;d&&r.push(d),y.textContent=r.slice(0,e.captions.maxLines).join(`
21
+ `),y.style.fontSize=`max(9px, ${e.captions.size/19.2}cqw)`,y.style.maxHeight=`${e.captions.maxLines*1.3+.8}em`;const u=Re(e.theme,J,i.resolvedTheme),s={background:u.background,foreground:u.foreground,accent:u.accent,font:be(e.theme)==="studio"?i.resolvedTheme?.font??e.theme.font:e.theme.font};for(const[f,h]of Object.entries(s))n.style.setProperty(`--video-${f}`,h)}function nt(e,o){const r=Y("",()=>{},`video-trim-${o}`);r.className="trim-handle",r.dataset.edge=o,r.setAttribute("role","slider"),r.setAttribute("aria-label",`${o==="in"?"In":"Out"} trim`);const d=i?.takes[e.id]?.find(s=>s.file===e.take)?.durationSec??e.outSec;r.setAttribute("aria-valuemin","0"),r.setAttribute("aria-valuemax",String(d)),r.setAttribute("aria-valuenow",String(o==="in"?e.inSec:e.outSec));const u=e.durationSec<=0||e.outSec-e.inSec<=0;return r.disabled=!z()||u,r.onpointerdown=s=>{if(!z()||i===null||u)return;s.preventDefault(),s.stopPropagation();const f=i.version,h=s.clientX,S=r.parentElement.getBoundingClientRect().width||1;let x=e.inSec,X=e.outSec;const fe=Q=>{const Ce=(Q-h)/S*e.durationSec;o==="in"?x=Math.max(0,Math.min(e.outSec-.5,e.inSec+Ce)):X=Math.max(e.inSec+.5,Math.min(d,e.outSec+Ce)),r.setAttribute("aria-valuenow",(o==="in"?x:X).toFixed(2));const we=c.querySelector(`[data-testid="video-${o}"]`);we&&(we.value=(o==="in"?x:X).toFixed(2))},Se=Q=>fe(Q.clientX),xe=Q=>{fe(Q.clientX),Ae(),(x!==e.inSec||X!==e.outSec)&&se({op:"chapter-trim",chapter:e.id,inSec:x,outSec:X},f)},Ae=()=>{window.removeEventListener("pointermove",Se),window.removeEventListener("pointerup",xe),window.removeEventListener("pointercancel",$e)},$e=()=>{Ae(),w()};window.addEventListener("pointermove",Se),window.addEventListener("pointerup",xe),window.addEventListener("pointercancel",$e,{once:!0})},r.onkeydown=s=>{if(!z()||u||!["ArrowLeft","ArrowRight"].includes(s.key))return;s.preventDefault(),s.stopPropagation();const f=s.key==="ArrowLeft"?-.1:.1,h=o==="in"?Math.max(0,Math.min(e.outSec-.5,e.inSec+f)):e.inSec,S=o==="out"?Math.max(e.inSec+.5,Math.min(d,e.outSec+f)):e.outSec;(h!==e.inSec||S!==e.outSec)&&se({op:"chapter-trim",chapter:e.id,inSec:h,outSec:S})},r}function Pt(){const e=i?.proof,o=t("check-list");if(o.replaceChildren(),t("proof").hidden=e===void 0,e===void 0||i===null)return;t("proof-summary").textContent=`${e.verdict??"Pending"}${e.failedAtSec===null?"":` · Failed at ${e.failedAtSec.toFixed(1)}s`}`;const r=!N&&Number.isFinite(a.duration)&&a.duration>0?a.duration:Math.max(1,...i.chapters.filter(s=>s.startSec>=0).map(s=>s.startSec+Math.max(0,s.durationSec)),...e.checks.map(s=>s.atSec??0),e.failedAtSec??0),d=document.createElement("div");d.className="check-track",d.setAttribute("aria-label","Check timeline");const u=(s,f,h,S)=>{if(s<0||!Number.isFinite(s)||r<=0)return;const x=Y(f==="FAIL"?"✗":f==="PASS"?"✓":"·",()=>{N&&(N=!1,oe("video",s)),a.currentTime=s,a.dispatchEvent(new Event("timeupdate"))},S);x.className="check-mark",x.dataset.state=f,x.dataset.sec=String(s),x.style.left=`${Math.min(100,s/r*100)}%`,x.title=`${s.toFixed(1)}s · ${h}`,x.setAttribute("aria-label",x.title),d.append(x)};for(const s of e.checks){const f=i.chapters.find(x=>x.id===s.chapter)?.title??s.chapter,h=`${s.state} · ${f} · ${s.text}`,S=document.createElement("li");S.dataset.testid="video-check",S.dataset.state=s.state,S.textContent=`${h}${s.atSec===null?"":` · ${s.atSec.toFixed(1)}s`}`,o.append(S),s.atSec!==null&&u(s.atSec,s.state,h,"video-check-mark")}e.failedAtSec!==null&&!e.checks.some(s=>s.state==="FAIL"&&s.atSec===e.failedAtSec)&&u(e.failedAtSec,"FAIL","Failed","video-failure-mark"),b.dataset.proof=String(d.childElementCount>0),b.append(d)}function w(){const e=document.activeElement,o=c.querySelector('[data-testid="video-rename-input"]');o!==null&&(ie=o.value);const r=e===o,d=o?.selectionStart,u=o?.selectionEnd,s=e?.dataset.chapter,f=e?.dataset.testid;if(n.dataset.surface=g,n.dataset.mode=A,n.dataset.head=String(i?.version??0),n.dataset.current=$??"",t("chapters").hidden=g==="card"||g==="options"&&C!=="chapters",t("work").hidden=g==="options",t("inspectors").hidden=g!=="full"||A!=="advanced",b.hidden=g!=="full",v.hidden=g!=="card",l.replaceChildren(),v.replaceChildren(),b.replaceChildren(),c.replaceChildren(),b.dataset.proof="false",i===null)return;if(j!==null){const p=Rt();p!==null&&(c.prepend(p),r&&(p.focus(),p.setSelectionRange(d??null,u??null)))}i.chapters.forEach((p,E)=>{const P=document.createElement("li"),F=Y("",()=>ue(p.id),"video-chapter");F.className="chapter",F.dataset.chapter=p.id,F.disabled=p.startSec<0,F.disabled&&(F.title="Not in this recording");const L=document.createElement("span");L.className="number",L.textContent=String(E+1);const Ie=document.createElement("span");Ie.textContent=p.title;const _e=document.createElement("span");if(_e.className="duration",_e.textContent=p.durationSec<0?"—":`${p.durationSec.toFixed(1)}s`,F.append(L,Ie,_e),F.setAttribute("aria-current",String(p.id===$)),F.setAttribute("aria-label",`Chapter ${E+1}: ${p.title}`),p.verdict==="PASS"||p.verdict==="FAIL"){const U=document.createElement("span");U.className="chapter-verdict",U.dataset.verdict=p.verdict,U.textContent=p.verdict==="PASS"?"✓":"✗",U.setAttribute("aria-label",p.verdict),F.append(U)}F.ondblclick=()=>{de()&&tt(p)},P.draggable=de()&&z(),P.ondragstart=U=>{W=p.id,U.dataTransfer?.setData("text/plain",p.id)},P.ondragover=U=>{de()&&z()&&U.preventDefault()},P.ondrop=U=>{if(U.preventDefault(),W===null||W===p.id||!de())return;const lt=i.chapters.filter(We=>We.id!==W),ct=lt.findIndex(We=>We.id===p.id),dt=P.getBoundingClientRect(),zt=U.clientY>=dt.top+dt.height/2?p.id:ct===0?null:lt[ct-1].id;se({op:"chapter-move",chapter:W,after:zt}),W=null},P.ondragend=()=>{W=null},P.append(F),l.append(P);const he=Y(`${E+1} · ${p.title}`,()=>ue(p.id),"video-chip");he.className="chip",he.setAttribute("aria-current",String(p.id===$)),v.append(he),he.disabled=p.startSec<0,he.disabled&&(he.title="Not in this recording");const Ee=document.createElement("div");Ee.className="segment-box",Ee.style.flex=String(p.durationSec<0?1:p.durationSec);const me=Y(`${E+1} · ${p.title}`,()=>ue(p.id),"video-segment");me.className="segment",me.setAttribute("aria-current",String(p.id===$)),Ee.append(me),me.disabled=p.startSec<0,me.disabled&&(me.title="Not in this recording"),A==="advanced"&&p.id===$&&Ee.append(nt(p,"in"),nt(p,"out")),b.append(Ee)}),Pt();const h=ke();t("hint").textContent=h===void 0?"":"Re-record this chapter: the host's button",t("count").textContent=h===void 0?"No chapters":`${i.chapters.findIndex(p=>p.id===h.id)+1} of ${i.chapters.length}`,t("say").value=h?.say??"";const S=i.style.theme,x=Re(S,J,i.resolvedTheme),X=be(S);if(t("theme-summary").textContent=`${X==="studio"?"Studio skin (default)":X==="custom"?"Custom colours":"Preset: "+X}
22
+ ${X==="studio"?i.resolvedTheme?.font??S.font:S.font}
23
+ Background ${x.background}
24
+ Text ${x.foreground}
25
+ Accent ${x.accent}
26
+ Title card: ${S.titleCard.on?S.titleCard.title:"Off"}
27
+ End card: ${S.endCard.on?S.endCard.title:"Off"}`,qe(),s!==void 0&&Array.from(l.querySelectorAll("[data-chapter]")).find(p=>p.dataset.chapter===s)?.focus(),!de()||g==="card"||h===void 0)return;const fe=document.createElement("div");fe.className="buttons";const Se=Y("Rename",()=>tt(h),"video-rename"),xe=Y("Move up",()=>Ke(h.id,-1),"video-move-up"),Ae=Y("Move down",()=>Ke(h.id,1),"video-move-down");Se.disabled=!z(),xe.disabled=!z()||i.chapters[0]?.id===h.id,Ae.disabled=!z()||i.chapters.at(-1)?.id===h.id,fe.append(Se,xe,Ae),c.append(fe);const $e=i.version,Q=document.createElement("div");Q.className="trim-fields";const Ce=(p,E,P)=>{const F=document.createElement("label");F.textContent=p;const L=document.createElement("input");return L.type="number",L.step="0.1",L.min="0",L.value=String(E),L.dataset.testid=P,L.setAttribute("aria-label",p),L.disabled=!z(),L.max=String(i.takes[h.id]?.find(Ie=>Ie.file===h.take)?.durationSec??h.outSec),F.append(L),Q.append(F),L},we=Ce("In (seconds)",h.inSec,"video-in"),Ve=Ce("Out (seconds)",h.outSec,"video-out"),st=()=>{const p=we.valueAsNumber,E=Ve.valueAsNumber;if(!(p===h.inSec&&E===h.outSec)){if(!Number.isFinite(p)||!Number.isFinite(E)||p<0||E-p<.5||E>Number(Ve.max)){Ne("Keep at least 0.5 seconds within this take.");return}se({op:"chapter-trim",chapter:h.id,inSec:p,outSec:E},$e)}};we.onchange=st,Ve.onchange=st,c.append(Q);const rt=i.takes[h.id]??[];if(rt.length>1){const p=document.createElement("label");p.textContent="Take";const E=document.createElement("select");E.setAttribute("aria-label","Take"),E.dataset.testid="video-take",E.disabled=!z(),rt.forEach((P,F)=>{const L=document.createElement("option");L.value=P.file,L.textContent=`Take ${F+1} · ${P.durationSec.toFixed(1)}s`,E.append(L)}),E.value=h.take,E.onchange=()=>{E.value!==h.take&&se({op:"chapter-take",chapter:h.id,take:E.value},$e)},p.append(E),c.append(p),g!=="options"&&c.append(Y("Preview take",()=>{N=!0,oe({chapter:h.id})},"video-preview-take"))}if(f!==void 0&&!f.includes("rename-input")){const p=n.querySelector(`[data-testid="${f}"]`);p&&!p.disabled&&!p.closest("[hidden]")&&p.focus()}}async function jt(e,o,r){const d=Ot.options?.tabs.find(u=>u.id===e)?.controls?.find(u=>u.id===o);if(i===null||d===void 0||!Mt(d,r)||!M.includes("artifact.theme")||typeof r=="string"&&/[\r\n]/.test(r))return{applied:!1,values:i===null?{}:le(i.style,e,J,i.resolvedTheme),reason:"That style change is not available."};if(O)return{applied:!1,values:le(i.style,e,J,i.resolvedTheme),reason:"A cut is being saved."};O=!0,w();try{for(let u=0;u<2;u++){const s=St(i.style,e,o,r),f=await ge("theme.set",{base:i.version,tokens:{kind:"video-style",style:s}});if(f.ok){const h=await pe();return{applied:h,values:le(i.style,e,J,i.resolvedTheme),...h?{}:{reason:"The saved style could not be read."}}}if(!(f.error?.code==="head_moved"&&u===0&&await pe()))return Ue(),{applied:!1,values:le(i.style,e,J,i.resolvedTheme),reason:f.error?.message??"Style was not changed."}}return{applied:!1,values:le(i.style,e,J,i.resolvedTheme)}}finally{O=!1,w()}}const ot=()=>{t("play").textContent=a.paused?"Play":"Pause"};a.onplay=ot,a.onpause=ot,t("play").onclick=()=>{D!==null&&(a.paused?a.play().catch(()=>Ne("The video isn't available here")):a.pause())},a.onerror=()=>{t("unavailable").hidden=!1},a.ontimeupdate=()=>{if(i===null||N)return;const e=ze(a.currentTime);e!==void 0&&e.id!==$&&($=e.id,w()),y.hidden=!Qe(e)},n.onkeydown=e=>{const o=e.target,r=e.metaKey||e.ctrlKey;if(!yt(e,n,d=>Oe("ui.key",{key:d}))&&!o.closest("input,textarea,select")&&e.key!=="Tab"){if(e.altKey&&!r&&["ArrowUp","ArrowDown"].includes(e.key)&&de()&&$!==null){e.preventDefault(),Ke($,e.key==="ArrowUp"?-1:1);return}if(!(r||e.altKey)){if(["ArrowLeft","ArrowRight","Home","End"].includes(e.key)&&i!==null){e.preventDefault();const d=i.chapters.filter(h=>h.startSec>=0),u=d.findIndex(h=>h.id===$),s=e.key==="Home"?0:e.key==="End"?d.length-1:Math.max(0,Math.min(d.length-1,u+(e.key==="ArrowRight"?1:-1))),f=d[s];f&&ue(f.id);return}o.closest("button")&&[" ","Enter"].includes(e.key)||e.key.length===1&&(e.preventDefault(),Oe("ui.typed",{grapheme:e.key}))}}};function it(){_=!0,++ne,++ve,Be(),B!==null&&(URL.revokeObjectURL(B),B=null);for(const{timer:e,resolve:o}of ce.values())clearTimeout(e),o({ok:!1,error:{code:"unavailable",message:"Editor closed."}});ce.clear(),k?.close(),window.removeEventListener("message",at)}function at(e){const o=e.data;if(k!==null||o?.p!==K||o.v!==q||o.type!=="host.hello"||!e.ports[0])return;const r=mt(o.payload),d=o.payload;g=r.surface,A=r.mode??"simple",C=r.tab??"chapters",T=r.protocol,M=Array.isArray(d.grants)?d.grants.filter(u=>typeof u=="string"):[],et(d.theme),k=e.ports[0],V=new gt(k,{surface(u,s){const f=g;g=u,s!==null&&(A=s),w(),f==="options"&&u!=="options"&&oe()},mode(u){return A=u,w(),A},action(u){const s=i?.chapters.filter(x=>x.startSec>=0)??[];if(!["next","prev"].includes(u)||i===null||s.length===0)return{handled:!1};const f=s.findIndex(x=>x.id===$),h=Math.max(0,Math.min(s.length-1,f+(u==="next"?1:-1))),S=s[h];return ue(S.id),{handled:!0,status:`Chapter ${i.chapters.indexOf(S)+1} of ${i.chapters.length} · ${S.title}`}},tab(u){C=u,w()},selection(u){const s=u.find(f=>typeof f=="object"&&f!==null&&["chapter","time"].includes(f.kind));s?.kind==="time"&&typeof s.atSec=="number"?It(s.atSec):typeof s?.id=="string"&&ue(s.id,!1)},optionsChanged:jt}),k.onmessage=u=>{const s=u.data;if(s?.p!==K||s.v!==q)return;if(typeof s.re=="string"){const h=ce.get(s.re);if(h===void 0)return;clearTimeout(h.timer),ce.delete(s.re),h.resolve({ok:s.ok===!0,...s.payload!==void 0?{payload:s.payload}:{},...s.error===void 0?{}:{error:s.error}});return}if(T===2&&V?.dispatch(s))return;const f=s.payload??{};switch(s.type){case"host.ping":s.id&&k?.postMessage({p:K,v:q,re:s.id,ok:!0,payload:{}});break;case"host.size":if(f.size==="inline"||f.size==="pane"||f.size==="full"){const h=g;g=T===1&&f.size==="pane"?"full":Xe(f.size),w(),h==="options"&&g!=="options"&&oe()}break;case"host.theme":et(f.theme),Ue(),qe(),w();break;case"artifact.changed":(typeof f.head!="number"||i===null||f.head>i.version)&&pe();break;case"host.teardown":it();break;case"selection.cleared":$=null,w();break}},k.start(),w(),pe()}window.addEventListener("message",at),window.addEventListener("pagehide",it,{once:!0}),w(),vt("wicked-video",Ze)}return Ye(),Z.start=Ye,Object.defineProperty(Z,Symbol.toStringTag,{value:"Module"}),Z})({});
28
+ </script></body></html>
package/dist/index.html CHANGED
@@ -4,8 +4,8 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>wicked-studio</title>
7
- <script type="module" crossorigin src="/assets/index-R8uK_NlG.js"></script>
8
- <link rel="stylesheet" crossorigin href="/assets/index-BSPM1fFW.css">
7
+ <script type="module" crossorigin src="/assets/index-1Ucvzihb.js"></script>
8
+ <link rel="stylesheet" crossorigin href="/assets/index-B0u_f6HD.css">
9
9
  </head>
10
10
  <body>
11
11
  <div id="root"></div>