@kriya-ai/harness 0.0.0-stage → 0.2.1
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 +379 -2
- package/SAFETY.md +162 -0
- package/THIRD_PARTY_NOTICES.md +7911 -0
- package/bin/kriya.js +577 -0
- package/bundle/cordis.patch.yml +397 -0
- package/contract/SOURCE.md +15 -0
- package/contract/contract.json +1355 -0
- package/package.json +57 -4
- package/plugins/anchor/index.js +56 -0
- package/plugins/anchor/package.json +13 -0
- package/plugins/approvals/index.js +183 -0
- package/plugins/approvals/package.json +13 -0
- package/plugins/brand/DESIGN.md +112 -0
- package/plugins/brand/client.js +826 -0
- package/plugins/brand/index.js +15 -0
- package/plugins/brand/package.json +25 -0
- package/plugins/brand/src/client.js +823 -0
- package/plugins/browser/index.js +218 -0
- package/plugins/browser/package.json +13 -0
- package/plugins/budget/index.js +108 -0
- package/plugins/budget/package.json +13 -0
- package/plugins/changes/client.js +245 -0
- package/plugins/changes/index.js +75 -0
- package/plugins/changes/package.json +22 -0
- package/plugins/edit/client.js +113 -0
- package/plugins/edit/index.js +58 -0
- package/plugins/edit/package.json +23 -0
- package/plugins/fs-freshness/index.js +28 -0
- package/plugins/fs-freshness/package.json +13 -0
- package/plugins/graph/client.js +178 -0
- package/plugins/graph/index.js +4 -0
- package/plugins/graph/package.json +22 -0
- package/plugins/kriya-handoff/index.js +194 -0
- package/plugins/kriya-handoff/package.json +13 -0
- package/plugins/kriya-tools/index.js +189 -0
- package/plugins/kriya-tools/package.json +13 -0
- package/plugins/loop/index.js +743 -0
- package/plugins/loop/package.json +13 -0
- package/plugins/mirror/index.js +235 -0
- package/plugins/mirror/package.json +13 -0
- package/plugins/overview/client.js +276 -0
- package/plugins/overview/index.js +95 -0
- package/plugins/overview/package.json +22 -0
- package/plugins/preview/client.js +337 -0
- package/plugins/preview/index.js +4 -0
- package/plugins/preview/package.json +22 -0
- package/plugins/progress/client.js +290 -0
- package/plugins/progress/index.js +100 -0
- package/plugins/progress/package.json +22 -0
- package/plugins/projects/client.js +249 -0
- package/plugins/projects/index.js +30 -0
- package/plugins/projects/package.json +24 -0
- package/plugins/rea/index.js +256 -0
- package/plugins/rea/package.json +10 -0
- package/plugins/rea/skill/LICENSE +21 -0
- package/plugins/rea/skill/SKILL.md +360 -0
- package/plugins/rea/skill/references/android-applications.md +36 -0
- package/plugins/rea/skill/references/connection-and-recovery.md +127 -0
- package/plugins/rea/skill/references/evidence-workflows.md +71 -0
- package/plugins/rea/skill/references/javascript-applications.md +218 -0
- package/plugins/rea/skill/references/native-and-artifacts.md +297 -0
- package/plugins/rea/skill/references/runtime-observation.md +78 -0
- package/plugins/remote/index.js +297 -0
- package/plugins/remote/package.json +10 -0
- package/plugins/router/index.js +84 -0
- package/plugins/router/package.json +13 -0
- package/plugins/sessions/client.js +68 -0
- package/plugins/sessions/index.js +79 -0
- package/plugins/sessions/package.json +20 -0
- package/plugins/skills/client.js +504 -0
- package/plugins/skills/index.js +166 -0
- package/plugins/skills/package.json +23 -0
- package/src/api.js +97 -0
- package/src/browser.js +286 -0
- package/src/changes.js +191 -0
- package/src/checkpoints.js +313 -0
- package/src/daemon.js +503 -0
- package/src/doctor.js +137 -0
- package/src/edit/core/anchors.js +102 -0
- package/src/edit/core/audio.js +158 -0
- package/src/edit/core/faces.js +99 -0
- package/src/edit/core/ffmpeg.js +258 -0
- package/src/edit/core/handoff.js +220 -0
- package/src/edit/core/history.js +90 -0
- package/src/edit/core/layout.js +92 -0
- package/src/edit/core/mix.js +115 -0
- package/src/edit/core/ops.js +602 -0
- package/src/edit/core/plan.js +266 -0
- package/src/edit/core/project.d.ts +134 -0
- package/src/edit/core/project.js +307 -0
- package/src/edit/core/reframe.js +125 -0
- package/src/edit/core/solver.js +416 -0
- package/src/edit/core/time.js +110 -0
- package/src/edit/core/tonemap.js +57 -0
- package/src/edit/director/ask.js +120 -0
- package/src/edit/director/gateway.js +16 -0
- package/src/edit/director/revise.js +186 -0
- package/src/edit/engine/capabilities.js +33 -0
- package/src/edit/engine/captions.js +154 -0
- package/src/edit/engine/color.js +269 -0
- package/src/edit/engine/confine.js +67 -0
- package/src/edit/engine/dna.js +148 -0
- package/src/edit/engine/index.js +473 -0
- package/src/edit/engine/loudness.js +43 -0
- package/src/edit/engine/media.js +57 -0
- package/src/edit/engine/motion.js +281 -0
- package/src/edit/engine/packs.js +87 -0
- package/src/edit/engine/probe.js +101 -0
- package/src/edit/engine/receipt.js +123 -0
- package/src/edit/engine/tool.js +101 -0
- package/src/edit/gates/copy.js +113 -0
- package/src/edit/gates/index.js +430 -0
- package/src/edit/gates/picture.js +130 -0
- package/src/edit/gates/sound.js +58 -0
- package/src/edit/gates/speech.js +127 -0
- package/src/edit/gates/text.js +196 -0
- package/src/edit/gates/text.swift +22 -0
- package/src/edit/graph/index.js +139 -0
- package/src/edit/graph/journal.js +69 -0
- package/src/edit/graph/scheduler.js +79 -0
- package/src/edit/host/client.js +58 -0
- package/src/edit/host/deliver.js +119 -0
- package/src/edit/host/jobs.js +84 -0
- package/src/edit/host/main.js +135 -0
- package/src/edit/host/paths.js +11 -0
- package/src/edit/host/projects.js +415 -0
- package/src/edit/host/server.js +391 -0
- package/src/edit/host/taste.js +135 -0
- package/src/edit/host/tavi.js +417 -0
- package/src/edit/host/watch.js +141 -0
- package/src/edit/index/db.js +109 -0
- package/src/edit/index/index.js +236 -0
- package/src/edit/index/layers/faces.js +78 -0
- package/src/edit/index/layers/faces.swift +18 -0
- package/src/edit/index/layers/meta.js +35 -0
- package/src/edit/index/layers/music.js +146 -0
- package/src/edit/index/layers/quality.js +120 -0
- package/src/edit/index/layers/retakes.js +132 -0
- package/src/edit/index/layers/screen.js +99 -0
- package/src/edit/index/layers/shots.js +29 -0
- package/src/edit/index/layers/sound.js +42 -0
- package/src/edit/index/layers/words.js +64 -0
- package/src/edit/index/story.js +248 -0
- package/src/edit/index/views.js +71 -0
- package/src/edit/loop/governor.js +112 -0
- package/src/edit/loop/loop.js +69 -0
- package/src/edit/loop/make.js +115 -0
- package/src/edit/loop/repair.js +97 -0
- package/src/edit/loop/replay.js +32 -0
- package/src/edit/recipes/multicam.js +461 -0
- package/src/edit/recipes/reel.js +202 -0
- package/src/edit/recipes/short-from-long.js +237 -0
- package/src/edit/recipes/tutorial.js +137 -0
- package/src/edit/recipes/youtube.js +155 -0
- package/src/edit/runtime/cli.js +126 -0
- package/src/edit/runtime/doctor.js +122 -0
- package/src/edit/runtime/fetch.js +15 -0
- package/src/edit/runtime/licences.js +88 -0
- package/src/edit/runtime/manifest.js +73 -0
- package/src/edit/runtime/setup.js +252 -0
- package/src/failure.js +69 -0
- package/src/gateway-proxy.js +213 -0
- package/src/intent.js +130 -0
- package/src/launch.js +315 -0
- package/src/live.js +81 -0
- package/src/local-skills.js +284 -0
- package/src/login.js +82 -0
- package/src/loop.js +428 -0
- package/src/modes.js +128 -0
- package/src/overview.js +71 -0
- package/src/paths.js +30 -0
- package/src/profiles.js +92 -0
- package/src/projects.js +104 -0
- package/src/recon.js +244 -0
- package/src/rules.js +139 -0
- package/src/runner.bundle.js +21172 -0
- package/src/sentinel.js +248 -0
- package/src/skill-switches.js +130 -0
- package/src/store.js +58 -0
- package/src/strict.js +124 -0
- package/src/verify.js +659 -0
- package/src/world.js +268 -0
- package/studio/dist/index.html +14 -0
- package/studio/dist/studio.css +163 -0
- package/studio/dist/studio.js +1 -0
package/src/world.js
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { mkdir, readdir, realpath, rm, stat } from "node:fs/promises"
|
|
2
|
+
import { homedir } from "node:os"
|
|
3
|
+
import { join } from "node:path"
|
|
4
|
+
|
|
5
|
+
import { call, KriyaError } from "./api.js"
|
|
6
|
+
import { createRunner } from "./runner.bundle.js"
|
|
7
|
+
import { CLIENT_VERSION } from "./paths.js"
|
|
8
|
+
|
|
9
|
+
// `kriya serve [folder]` (H10, HD-12): this machine as the execution world
|
|
10
|
+
// of the person's cloud tasks. One outbound WebSocket to kriya-relay; the
|
|
11
|
+
// worker's runner requests arrive as frames (kriya-relay/1) and go to track
|
|
12
|
+
// C's own runner (src/runner.bundle.js, the same protocol as a cloud
|
|
13
|
+
// sandbox, CD-26), one per workspace, each in its own fresh folder
|
|
14
|
+
// <folder>/<workspace id>-<generation>, so the agent never works in files
|
|
15
|
+
// the person put there. Lifecycle requests (/world/*) come from the worker;
|
|
16
|
+
// runner requests carry the workspace's own token, which the runner checks.
|
|
17
|
+
|
|
18
|
+
const REF = /^device-([0-9a-f-]{36})-([0-9a-f-]{36})-(\d{1,9})$/
|
|
19
|
+
const DIR = /^([0-9a-f-]{36})-(\d{1,9})$/
|
|
20
|
+
// The relay accepts frames up to 512 KiB; body chunks stay well under it
|
|
21
|
+
const CHUNK = 256 * 1024
|
|
22
|
+
|
|
23
|
+
const text = (value) => Buffer.from(JSON.stringify(value)).toString("base64")
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The frame handler, apart from the socket (tests drive it directly).
|
|
27
|
+
* @param {{ folder: string, deviceId: string, runnerFactory?: typeof createRunner }} options
|
|
28
|
+
*/
|
|
29
|
+
export function createWorld({ folder, deviceId, runnerFactory = createRunner }) {
|
|
30
|
+
/** @type {Map<string, { url: string, close: () => Promise<void> }>} */
|
|
31
|
+
const runners = new Map()
|
|
32
|
+
const pending = new Map()
|
|
33
|
+
const aborts = new Map()
|
|
34
|
+
|
|
35
|
+
const dirOf = (ref) => {
|
|
36
|
+
const match = REF.exec(String(ref ?? ""))
|
|
37
|
+
return match && match[1] === deviceId ? join(folder, `${match[2]}-${match[3]}`) : null
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function world(route, body) {
|
|
41
|
+
if (route === "/world/list") {
|
|
42
|
+
const names = await readdir(folder).catch(() => [])
|
|
43
|
+
const refs = names
|
|
44
|
+
.map((name) => DIR.exec(name))
|
|
45
|
+
.filter(Boolean)
|
|
46
|
+
.map(([, workspaceId, generation]) => {
|
|
47
|
+
const ref = `device-${deviceId}-${workspaceId}-${generation}`
|
|
48
|
+
return { ref, running: runners.has(ref) }
|
|
49
|
+
})
|
|
50
|
+
return [200, { refs }]
|
|
51
|
+
}
|
|
52
|
+
const dir = dirOf(body.ref)
|
|
53
|
+
if (!dir) return [400, { error: "not a workspace of this machine" }]
|
|
54
|
+
const ref = body.ref
|
|
55
|
+
if (route === "/world/open") {
|
|
56
|
+
const exists = await stat(dir).then(
|
|
57
|
+
(found) => found.isDirectory(),
|
|
58
|
+
() => false
|
|
59
|
+
)
|
|
60
|
+
if (body.fresh) {
|
|
61
|
+
// A fresh generation never reuses a folder: the runner imports into an empty one
|
|
62
|
+
if (exists) return [409, { error: "that workspace folder already exists" }]
|
|
63
|
+
await mkdir(dir, { recursive: true })
|
|
64
|
+
} else if (!exists) {
|
|
65
|
+
return [404, { error: "this machine no longer has that workspace" }]
|
|
66
|
+
}
|
|
67
|
+
await runners.get(ref)?.close()
|
|
68
|
+
runners.delete(ref)
|
|
69
|
+
runners.set(
|
|
70
|
+
ref,
|
|
71
|
+
await runnerFactory({
|
|
72
|
+
root: dir,
|
|
73
|
+
token: String(body.token ?? ""),
|
|
74
|
+
generation: Number(body.generation),
|
|
75
|
+
limits: body.limits ?? {},
|
|
76
|
+
// The person's own account runs the commands (no sandbox here)
|
|
77
|
+
home: homedir(),
|
|
78
|
+
path: process.env.PATH ?? "/usr/bin:/bin",
|
|
79
|
+
})
|
|
80
|
+
)
|
|
81
|
+
return [200, { opened: true }]
|
|
82
|
+
}
|
|
83
|
+
if (route === "/world/pause" || route === "/world/destroy") {
|
|
84
|
+
await runners.get(ref)?.close()
|
|
85
|
+
runners.delete(ref)
|
|
86
|
+
// Only the workspace's own folder, never anything else in the served one
|
|
87
|
+
if (route === "/world/destroy") await rm(dir, { recursive: true, force: true })
|
|
88
|
+
return [200, { ok: true }]
|
|
89
|
+
}
|
|
90
|
+
return [404, { error: "not found" }]
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async function handle(id, send) {
|
|
94
|
+
const request = pending.get(id)
|
|
95
|
+
pending.delete(id)
|
|
96
|
+
const body = Buffer.concat(request.chunks)
|
|
97
|
+
try {
|
|
98
|
+
if (request.path.startsWith("/world/")) {
|
|
99
|
+
let parsed = {}
|
|
100
|
+
try {
|
|
101
|
+
parsed = body.length ? JSON.parse(String(body)) : {}
|
|
102
|
+
} catch {
|
|
103
|
+
parsed = null
|
|
104
|
+
}
|
|
105
|
+
const [status, answer] = parsed ? await world(request.path, parsed) : [400, { error: "not JSON" }]
|
|
106
|
+
send({ t: "res", id, status, headers: { "content-type": "application/json" } })
|
|
107
|
+
send({ t: "body", id, data: text(answer) })
|
|
108
|
+
return send({ t: "end", id })
|
|
109
|
+
}
|
|
110
|
+
const runner = runners.get(request.headers["x-kriya-world-ref"] ?? "")
|
|
111
|
+
if (!runner) {
|
|
112
|
+
send({ t: "res", id, status: 503, headers: { "content-type": "application/json" } })
|
|
113
|
+
send({ t: "body", id, data: text({ error: "that workspace isn't open on this machine" }) })
|
|
114
|
+
return send({ t: "end", id })
|
|
115
|
+
}
|
|
116
|
+
const abort = new AbortController()
|
|
117
|
+
aborts.set(id, abort)
|
|
118
|
+
const headers = { ...request.headers }
|
|
119
|
+
delete headers["x-kriya-world-ref"]
|
|
120
|
+
const response = await fetch(runner.url + request.path, {
|
|
121
|
+
method: request.method,
|
|
122
|
+
headers,
|
|
123
|
+
body: request.method === "GET" || request.method === "HEAD" ? undefined : body,
|
|
124
|
+
signal: abort.signal,
|
|
125
|
+
})
|
|
126
|
+
send({ t: "res", id, status: response.status, headers: Object.fromEntries(response.headers) })
|
|
127
|
+
for await (const chunk of response.body ?? []) {
|
|
128
|
+
for (let at = 0; at < chunk.length; at += CHUNK) {
|
|
129
|
+
send({ t: "body", id, data: Buffer.from(chunk.subarray(at, at + CHUNK)).toString("base64") })
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
send({ t: "end", id })
|
|
133
|
+
} catch (error) {
|
|
134
|
+
// The message only: request bodies and file contents stay on this machine
|
|
135
|
+
send({ t: "error", id, message: String(error?.message ?? error).slice(0, 200) })
|
|
136
|
+
} finally {
|
|
137
|
+
aborts.delete(id)
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return {
|
|
142
|
+
runners,
|
|
143
|
+
/** @param {any} frame @param {(frame: unknown) => void} send */
|
|
144
|
+
onFrame(frame, send) {
|
|
145
|
+
if (typeof frame?.id !== "number") return
|
|
146
|
+
if (frame.t === "req") {
|
|
147
|
+
pending.set(frame.id, {
|
|
148
|
+
method: String(frame.method),
|
|
149
|
+
path: String(frame.path),
|
|
150
|
+
headers: frame.headers ?? {},
|
|
151
|
+
chunks: [],
|
|
152
|
+
})
|
|
153
|
+
} else if (frame.t === "body") {
|
|
154
|
+
pending.get(frame.id)?.chunks.push(Buffer.from(String(frame.data), "base64"))
|
|
155
|
+
} else if (frame.t === "end") {
|
|
156
|
+
if (pending.has(frame.id)) return handle(frame.id, send)
|
|
157
|
+
} else if (frame.t === "abort") {
|
|
158
|
+
pending.delete(frame.id)
|
|
159
|
+
aborts.get(frame.id)?.abort()
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
// Runners stop; every folder stays (the worker destroys what it no longer needs)
|
|
163
|
+
async close() {
|
|
164
|
+
for (const abort of aborts.values()) abort.abort()
|
|
165
|
+
for (const runner of runners.values()) await runner.close()
|
|
166
|
+
runners.clear()
|
|
167
|
+
},
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export class ServeError extends Error {}
|
|
172
|
+
|
|
173
|
+
/** The served folder: an existing directory, as its real path */
|
|
174
|
+
export async function servedFolder(given) {
|
|
175
|
+
let folder
|
|
176
|
+
try {
|
|
177
|
+
folder = await realpath(given)
|
|
178
|
+
} catch {
|
|
179
|
+
throw new ServeError(`${given} doesn't exist; create the folder first.`)
|
|
180
|
+
}
|
|
181
|
+
if (!(await stat(folder)).isDirectory()) throw new ServeError(`${given} isn't a folder.`)
|
|
182
|
+
return folder
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Serves `folder` until stopped: connects, reconnects with back-off, stops for
|
|
187
|
+
* good when Kriya signs this device out or another `kriya serve` replaces it.
|
|
188
|
+
* @param {{ device: { url: string, token: string }, folder: string, say?: (line: string) => void,
|
|
189
|
+
* signal?: AbortSignal, WebSocketImpl?: typeof WebSocket, runnerFactory?: typeof createRunner,
|
|
190
|
+
* backoffMs?: number }} options
|
|
191
|
+
*/
|
|
192
|
+
export async function serve({ device, folder, say = () => {}, signal, WebSocketImpl = WebSocket, runnerFactory, backoffMs = 1000 }) {
|
|
193
|
+
if (process.platform === "win32") throw new ServeError("kriya serve needs macOS or Linux (the runner uses bash).")
|
|
194
|
+
const where = async () => {
|
|
195
|
+
try {
|
|
196
|
+
return await call(device.url, "GET", "/world", { token: device.token })
|
|
197
|
+
} catch (error) {
|
|
198
|
+
if (error instanceof KriyaError && error.status === 404)
|
|
199
|
+
throw new ServeError("Your Kriya doesn't have the device world turned on.")
|
|
200
|
+
if (error instanceof KriyaError && error.status === 401)
|
|
201
|
+
throw new ServeError("This device is signed out; run kriya login.")
|
|
202
|
+
throw error
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
const { deviceId, relayUrl } = await where()
|
|
206
|
+
const world = createWorld({ folder, deviceId, runnerFactory })
|
|
207
|
+
const url = `${relayUrl.replace(/^http/, "ws").replace(/\/+$/, "")}/v1/device/${deviceId}`
|
|
208
|
+
let delay = backoffMs
|
|
209
|
+
try {
|
|
210
|
+
while (!signal?.aborted) {
|
|
211
|
+
const outcome = await new Promise((done) => {
|
|
212
|
+
const socket = new WebSocketImpl(url, {
|
|
213
|
+
headers: { Authorization: `Bearer ${device.token}`, "X-Kriya-Harness": CLIENT_VERSION },
|
|
214
|
+
})
|
|
215
|
+
const send = (frame) => {
|
|
216
|
+
if (socket.readyState === 1) socket.send(JSON.stringify(frame))
|
|
217
|
+
}
|
|
218
|
+
const stop = () => socket.close()
|
|
219
|
+
signal?.addEventListener("abort", stop, { once: true })
|
|
220
|
+
let opened = false
|
|
221
|
+
socket.addEventListener("open", () => {
|
|
222
|
+
opened = true
|
|
223
|
+
delay = backoffMs
|
|
224
|
+
say(`Serving ${folder} to your Kriya agents. Stop with Ctrl-C.`)
|
|
225
|
+
})
|
|
226
|
+
socket.addEventListener("message", (event) => {
|
|
227
|
+
let frame
|
|
228
|
+
try {
|
|
229
|
+
frame = JSON.parse(String(event.data))
|
|
230
|
+
} catch {
|
|
231
|
+
return
|
|
232
|
+
}
|
|
233
|
+
void world.onFrame(frame, send)
|
|
234
|
+
})
|
|
235
|
+
socket.addEventListener("close", (event) => {
|
|
236
|
+
signal?.removeEventListener("abort", stop)
|
|
237
|
+
done({ opened, code: event.code })
|
|
238
|
+
})
|
|
239
|
+
})
|
|
240
|
+
if (signal?.aborted) break
|
|
241
|
+
if (outcome.code === 4000) throw new ServeError("Another kriya serve took over for this device.")
|
|
242
|
+
if (outcome.code === 4001) throw new ServeError("This device was signed out; run kriya login.")
|
|
243
|
+
// Refused at the door: find out why (signed out, switched off) before
|
|
244
|
+
// retrying. Kriya being unreachable is no answer: try again later
|
|
245
|
+
if (!outcome.opened) {
|
|
246
|
+
try {
|
|
247
|
+
await where()
|
|
248
|
+
} catch (error) {
|
|
249
|
+
if (error instanceof ServeError) throw error
|
|
250
|
+
}
|
|
251
|
+
} else say("Lost the connection to Kriya; reconnecting…")
|
|
252
|
+
await new Promise((resume) => {
|
|
253
|
+
const wake = () => {
|
|
254
|
+
clearTimeout(timer)
|
|
255
|
+
resume()
|
|
256
|
+
}
|
|
257
|
+
const timer = setTimeout(() => {
|
|
258
|
+
signal?.removeEventListener("abort", wake)
|
|
259
|
+
resume()
|
|
260
|
+
}, delay)
|
|
261
|
+
signal?.addEventListener("abort", wake, { once: true })
|
|
262
|
+
})
|
|
263
|
+
delay = Math.min(delay * 2, 30_000)
|
|
264
|
+
}
|
|
265
|
+
} finally {
|
|
266
|
+
await world.close()
|
|
267
|
+
}
|
|
268
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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>Kriya Editing Studio</title>
|
|
7
|
+
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3' y='5' width='18' height='14' rx='3' fill='%231F6362'/%3E%3Cpath d='M12 9l-1.5 6' stroke='%23FBF8F3' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E" />
|
|
8
|
+
<link rel="stylesheet" href="/studio.css" />
|
|
9
|
+
<script type="module" src="/studio.js"></script>
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<div id="app"><p class="note">Opening the Studio…</p></div>
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/* The Studio's look (UX_SPEC §11): the harness's palette (plugins/brand/DESIGN.md),
|
|
2
|
+
copied here because the Studio is its own app; tests/edit-ui.test.js checks they
|
|
3
|
+
still match. The monitor's surround is neutral grey and the timeline is flat. */
|
|
4
|
+
|
|
5
|
+
:root {
|
|
6
|
+
--paper: #f3eee6;
|
|
7
|
+
--sheet: #fbf8f3;
|
|
8
|
+
--loom: #eae3d7;
|
|
9
|
+
--ink: #13292b;
|
|
10
|
+
--teal: #1f6362;
|
|
11
|
+
--saffron: #b4622f;
|
|
12
|
+
--error: #c2413a;
|
|
13
|
+
--ink-2: rgb(19 41 43 / 0.68);
|
|
14
|
+
--edge: rgb(19 41 43 / 0.14);
|
|
15
|
+
--hover: rgb(19 41 43 / 0.06);
|
|
16
|
+
--on-teal: #fbf8f3;
|
|
17
|
+
--surround: #3a3a3a;
|
|
18
|
+
--lane: rgb(19 41 43 / 0.06);
|
|
19
|
+
--clip-picture: #8fb9b5;
|
|
20
|
+
--clip-broll: #c9a37c;
|
|
21
|
+
--clip-audio: #9fb7c9;
|
|
22
|
+
--clip-caption: #c6b98d;
|
|
23
|
+
--wave: rgb(19 41 43 / 0.55);
|
|
24
|
+
--shot: #13292b;
|
|
25
|
+
--playhead: #b4622f;
|
|
26
|
+
--focus: #1f6362;
|
|
27
|
+
--scope: #1f6362;
|
|
28
|
+
--ghost: #b4622f;
|
|
29
|
+
color-scheme: light dark;
|
|
30
|
+
}
|
|
31
|
+
@media (prefers-color-scheme: dark) {
|
|
32
|
+
:root {
|
|
33
|
+
--paper: #0a1213;
|
|
34
|
+
--sheet: #122021;
|
|
35
|
+
--loom: #071011;
|
|
36
|
+
--ink: #f2eadf;
|
|
37
|
+
--teal: #6cc0b8;
|
|
38
|
+
--saffron: #e7a46d;
|
|
39
|
+
--error: #f07a6e;
|
|
40
|
+
--ink-2: rgb(242 234 223 / 0.7);
|
|
41
|
+
--edge: rgb(242 234 223 / 0.14);
|
|
42
|
+
--hover: rgb(242 234 223 / 0.07);
|
|
43
|
+
--on-teal: #0a1213;
|
|
44
|
+
--lane: rgb(242 234 223 / 0.06);
|
|
45
|
+
--clip-picture: #2f6b67;
|
|
46
|
+
--clip-broll: #7a5a3a;
|
|
47
|
+
--clip-audio: #3d5a6e;
|
|
48
|
+
--clip-caption: #6b6040;
|
|
49
|
+
--wave: rgb(242 234 223 / 0.6);
|
|
50
|
+
--shot: #f2eadf;
|
|
51
|
+
--playhead: #e7a46d;
|
|
52
|
+
--focus: #6cc0b8;
|
|
53
|
+
--scope: #6cc0b8;
|
|
54
|
+
--ghost: #e7a46d;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
* { box-sizing: border-box; }
|
|
59
|
+
html, body { margin: 0; height: 100%; }
|
|
60
|
+
body { accent-color: var(--teal); background: var(--paper); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
|
|
61
|
+
h1 { font-size: 28px; font-weight: 450; letter-spacing: -0.015em; margin: 8px 0 20px; }
|
|
62
|
+
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); margin: 0 0 10px; }
|
|
63
|
+
a { color: var(--teal); }
|
|
64
|
+
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
65
|
+
.note { color: var(--ink-2); margin: 6px 0; }
|
|
66
|
+
.label-mono { font-family: ui-monospace, "JetBrains Mono", monospace; font-size: 13px; }
|
|
67
|
+
.error { color: var(--error); }
|
|
68
|
+
|
|
69
|
+
.btn { min-height: 44px; min-width: 44px; padding: 0 14px; border-radius: 10px; border: 0; background: var(--sheet); color: var(--ink); box-shadow: inset 0 0 0 1px var(--edge); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
|
|
70
|
+
.btn:hover { background: var(--hover); }
|
|
71
|
+
.btn.primary { background: var(--teal); color: var(--on-teal); box-shadow: none; }
|
|
72
|
+
.btn.ghost { background: transparent; box-shadow: none; }
|
|
73
|
+
.btn[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--teal); }
|
|
74
|
+
.field { min-height: 44px; padding: 0 12px; border-radius: 10px; border: 0; background: var(--sheet); color: inherit; font: inherit; box-shadow: inset 0 0 0 1px var(--edge); width: 100%; }
|
|
75
|
+
.field.small { width: auto; }
|
|
76
|
+
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
|
|
77
|
+
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
|
|
78
|
+
.inline { display: inline-flex; gap: 6px; align-items: center; min-height: 44px; }
|
|
79
|
+
.inline input[type="checkbox"] { width: 22px; height: 22px; }
|
|
80
|
+
.zoom { width: 110px; min-height: 44px; }
|
|
81
|
+
.chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--hover); color: var(--ink-2); }
|
|
82
|
+
|
|
83
|
+
.bar { display: flex; align-items: center; gap: 12px; padding: 8px 16px; border-bottom: 1px solid var(--edge); background: var(--loom); flex-wrap: wrap; }
|
|
84
|
+
.bar .title { font-weight: 600; }
|
|
85
|
+
.bar .brand { font-weight: 700; color: var(--teal); }
|
|
86
|
+
.bar .project-name { color: var(--ink-2); }
|
|
87
|
+
.modes { margin-left: auto; display: flex; gap: 4px; }
|
|
88
|
+
|
|
89
|
+
.panel { background: var(--sheet); border-radius: 14px; padding: 14px; box-shadow: inset 0 0 0 1px var(--edge); min-width: 0; }
|
|
90
|
+
.center, .home { max-width: 760px; margin: 0 auto; padding: 32px 16px; }
|
|
91
|
+
.home .panel { margin-bottom: 16px; }
|
|
92
|
+
.taste-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0; }
|
|
93
|
+
.taste-row p { flex: 1 1 200px; margin: 0; }
|
|
94
|
+
.new { display: grid; gap: 8px; }
|
|
95
|
+
.projects { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
|
|
96
|
+
|
|
97
|
+
.workspace { display: flex; flex-direction: column; min-height: 100%; }
|
|
98
|
+
.grid { flex: 1; display: grid; gap: 12px; padding: 12px; min-height: 0; grid-template-columns: minmax(0, 1fr) 320px; grid-template-areas: "monitor kriya" "transcript transcript" "strip strip"; align-content: start; }
|
|
99
|
+
.area-bin { grid-area: bin; }
|
|
100
|
+
.area-monitor { grid-area: monitor; background: var(--surround); color: #eee; }
|
|
101
|
+
.area-kriya { grid-area: kriya; }
|
|
102
|
+
.area-transcript { grid-area: transcript; }
|
|
103
|
+
.area-strip { grid-area: strip; }
|
|
104
|
+
.area-timeline { grid-area: timeline; }
|
|
105
|
+
.area-finish { grid-area: finish; }
|
|
106
|
+
.workspace[data-mode="direct"] :is(.area-bin, .area-timeline, .area-finish) { display: none; }
|
|
107
|
+
.workspace[data-mode="edit"] .grid { grid-template-columns: 280px minmax(0, 1fr) 320px; grid-template-areas: "bin monitor transcript" "timeline timeline timeline"; }
|
|
108
|
+
.workspace[data-mode="edit"] :is(.area-kriya, .area-strip, .area-finish) { display: none; }
|
|
109
|
+
.workspace[data-mode="finish"] .grid { grid-template-columns: minmax(0, 1fr) 360px; grid-template-areas: "monitor finish"; }
|
|
110
|
+
.workspace[data-mode="finish"] :is(.area-bin, .area-kriya, .area-transcript, .area-strip, .area-timeline) { display: none; }
|
|
111
|
+
|
|
112
|
+
.monitor-frame { display: flex; justify-content: center; align-items: center; min-height: 200px; }
|
|
113
|
+
.monitor { max-width: 100%; max-height: 62vh; background: #000; display: block; }
|
|
114
|
+
.transport { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
|
|
115
|
+
.area-monitor .chip { background: rgb(255 255 255 / 0.12); color: #ddd; }
|
|
116
|
+
.area-monitor .field { background: #2a2a2a; color: #eee; }
|
|
117
|
+
|
|
118
|
+
.prompt { display: flex; gap: 8px; }
|
|
119
|
+
.chip.selection { background: color-mix(in srgb, var(--teal) 16%, transparent); color: var(--ink); }
|
|
120
|
+
.proposal { margin-top: 12px; display: grid; gap: 8px; }
|
|
121
|
+
.proposal ul, .did { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
|
|
122
|
+
.proposal li { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
|
|
123
|
+
.proposal .lead { color: var(--saffron); font-weight: 600; font-size: 13px; }
|
|
124
|
+
.did li::before { content: "✓ "; color: var(--teal); }
|
|
125
|
+
.transcript { max-height: 40vh; overflow: auto; }
|
|
126
|
+
.sentence { margin: 0 0 10px; line-height: 2.1; }
|
|
127
|
+
.sentence .tag { font-size: 11px; color: var(--saffron); margin-right: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
|
|
128
|
+
.word { font: inherit; color: inherit; background: none; border: 0; padding: 4px 2px; min-height: 32px; border-radius: 6px; cursor: pointer; }
|
|
129
|
+
.word:hover { background: var(--hover); }
|
|
130
|
+
.word.struck, .sentence.lost .word { text-decoration: line-through; color: var(--ink-2); }
|
|
131
|
+
.word.unsure { text-decoration: underline dotted var(--saffron); }
|
|
132
|
+
.word.now { background: color-mix(in srgb, var(--saffron) 25%, transparent); }
|
|
133
|
+
.word[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--teal); }
|
|
134
|
+
|
|
135
|
+
.timeline { display: grid; grid-template-columns: 80px minmax(0, 1fr); grid-template-rows: auto auto; gap: 0 8px; }
|
|
136
|
+
.lane-labels { display: grid; grid-auto-rows: 50px; font-size: 12px; color: var(--ink-2); align-items: center; }
|
|
137
|
+
.lanes-wrap { min-width: 0; }
|
|
138
|
+
.lanes { width: 100%; display: block; touch-action: none; cursor: col-resize; }
|
|
139
|
+
.clip-list { grid-column: 1 / -1; list-style: none; padding: 0; margin: 8px 0 0; display: flex; gap: 6px; flex-wrap: wrap; }
|
|
140
|
+
.clip-list button { min-height: 44px; font: inherit; font-size: 13px; padding: 0 10px; border-radius: 8px; border: 0; background: var(--lane); color: inherit; cursor: pointer; }
|
|
141
|
+
.clip-list button[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--teal); }
|
|
142
|
+
.strip .clip-list { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
|
|
143
|
+
.strip .clip-list:focus-within { position: static; width: auto; height: auto; clip: auto; }
|
|
144
|
+
|
|
145
|
+
.bin { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 8px; }
|
|
146
|
+
.asset { display: grid; gap: 4px; }
|
|
147
|
+
.finish { display: grid; gap: 12px; }
|
|
148
|
+
.scope-row { display: flex; gap: 10px; flex-wrap: wrap; }
|
|
149
|
+
.scope-row figure { margin: 0; }
|
|
150
|
+
.scope { background: #111; border-radius: 6px; width: 160px; height: 100px; }
|
|
151
|
+
.jobs { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 4px; font-size: 13px; }
|
|
152
|
+
.jobs .file { color: var(--ink-2); }
|
|
153
|
+
|
|
154
|
+
/* Review mode under 760 px (UX_SPEC §12): preview, Kriya, export. No timeline, no bin */
|
|
155
|
+
@media (max-width: 760px) {
|
|
156
|
+
.grid, .workspace[data-mode] .grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "monitor" "kriya" "transcript" "finish"; padding: 8px; }
|
|
157
|
+
.workspace[data-mode] :is(.area-bin, .area-timeline, .area-strip) { display: none; }
|
|
158
|
+
.workspace[data-mode="edit"] .area-kriya { display: block; }
|
|
159
|
+
.modes { margin-left: 0; width: 100%; }
|
|
160
|
+
.modes .btn { flex: 1; }
|
|
161
|
+
.monitor { max-height: 50vh; }
|
|
162
|
+
}
|
|
163
|
+
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(e,o={},...d){let i=document.createElement(e);for(let[l,n]of Object.entries(o??{}))n==null||n===!1||(l.startsWith("on")?i.addEventListener(l.slice(2),n):l==="class"?i.className=n:l==="dataset"?Object.assign(i.dataset,n):n===!0?i.setAttribute(l,""):i.setAttribute(l,String(n)));for(let l of d.flat())l!=null&&l!==!1&&i.append(l instanceof Node?l:String(l));return i}var U=e=>(e.replaceChildren(),e);async function F(e,o,d){let i=await fetch(o,{method:e,headers:d===void 0?{}:{"content-type":"application/json"},body:d===void 0?void 0:JSON.stringify(d),credentials:"same-origin"}),l=await i.json().catch(()=>({}));if(!i.ok){let n=new Error(l.message??`The Edit Host answered ${i.status}.`);throw n.status=i.status,n.value=l,n}return l}var Bt=(e,o,d)=>.2126*e+.7152*o+.0722*d;function Gt(e,o=128){let d=new Uint32Array(256),i=Array.from({length:o},()=>new Uint32Array(64)),{data:l,width:n,height:m}=e,h=Math.max(1,Math.floor(n*m/6e4));for(let c=0,u=0;u<n*m;u+=h,c=u*4){let y=Math.min(255,Math.round(Bt(l[c],l[c+1],l[c+2])));d[y]++,i[Math.min(o-1,Math.floor(u%n/n*o))][y>>2]++}return{histogram:d,waveform:i}}function $t({root:e,pixels:o,project:d}){let i=t("canvas",{class:"scope",width:256,height:100,role:"img","aria-label":"Luma histogram"}),l=t("canvas",{class:"scope",width:256,height:100,role:"img","aria-label":"Luma waveform"}),n=t("ul",{class:"jobs","aria-live":"polite"}),m=t("p",{class:"note",role:"status"}),h=async a=>{m.textContent="";try{await F("POST","/jobs",{project:d().id,quality:a}),C()}catch(b){m.textContent=b.message}},c=t("p",{class:"note",role:"status"}),u=t("ul",{class:"jobs","aria-label":"Handoff files"}),y=async()=>{c.textContent="",U(u);try{let a=await F("POST",`/projects/${d().id}/export/handoff`),b=a.chapters.length,x=b?`, ${b} chapter${b===1?"":"s"}`:"";c.textContent=`Written to ${a.folder}, with ${a.media} media file${a.media===1?"":"s"} linked${x}.`;for(let P of a.files)u.append(t("li",{},t("span",{class:"file"},P)));for(let P of a.omitted)u.append(t("li",{},t("span",{class:"label-mono"},P.format),` ${P.reason}`))}catch(a){c.textContent=a.message}};e.append(t("section",{class:"panel scopes","aria-label":"Scopes"},t("h2",{},"Scopes"),t("div",{class:"scope-row"},t("figure",{},i,t("figcaption",{},"Histogram")),t("figure",{},l,t("figcaption",{},"Waveform"))),t("p",{class:"note"},"Measured on the preview: 8-bit, from the proxy.")),t("section",{class:"panel export","aria-label":"Export"},t("h2",{},"Export"),t("div",{class:"row"},t("button",{type:"button",class:"btn",onclick:()=>h("draft")},"Render a draft"),t("button",{type:"button",class:"btn primary",onclick:()=>h("master")},"Render the master")),t("p",{class:"note"},"Files go to the exports folder beside the project. Sources are never written."),m,n),t("section",{class:"panel handoff","aria-label":"Handoff"},t("h2",{},"Handoff"),t("p",{class:"note"},"For Premiere, Resolve or Final Cut: the cut as OTIO, FCPXML, EDL and SRT, with chapters, and the media linked beside them."),t("div",{class:"row"},t("button",{type:"button",class:"btn",onclick:y},"Export for another editor")),c,u));function w(a,b){let x=a.getContext("2d");x.clearRect(0,0,a.width,a.height),x.fillStyle=getComputedStyle(e).getPropertyValue("--scope").trim()||"#6cc0b8",b(x)}function W(){let a=o();if(!a)return;let{histogram:b,waveform:x}=Gt(a),P=Math.max(1,...b);w(i,T=>b.forEach((E,_)=>T.fillRect(_,100-E/P*100,1,E/P*100))),w(l,T=>x.forEach((E,_)=>E.forEach((K,A)=>{K&&(T.globalAlpha=Math.min(1,.15+K/200),T.fillRect(_*2,100-A/64*100-2,2,2))})))}async function C(){let{jobs:a}=await F("GET","/jobs");U(n);for(let b of a.filter(x=>x.project===d().id&&x.kind==="render").reverse().slice(0,8)){let x=b.output?b.output.split(/[\\/]/).at(-1):null;n.append(t("li",{},t("span",{class:"label-mono"},b.status),` ${b.progress}%`,x?t("span",{class:"file"},` ${x}`):null,b.error?t("span",{class:"error"},` ${b.error}`):null))}}return{scopes:W,refresh:C}}var Ct=e=>typeof e=="number"?{n:e,d:1}:e??{n:1,d:1},jt=e=>[...e?.picture??[]].sort((o,d)=>o.at-d.at),ft=e=>[{clip:null,asset:e.id,in:0,out:e.facts.duration,at:0,end:e.facts.duration,speed:{n:1,d:1}}],tt=(e,o)=>e.find(d=>o>=d.at&&o<d.end)??(e.length&&o>=e.at(-1).end?e.at(-1):null);function Q(e,o){if(e.hold)return e.in;let{n:d,d:i}=Ct(e.speed);return Math.min(e.out,e.in+Math.round((o-e.at)*d/i))}function it(e,o,d){for(let i of e){if(i.asset!==o||i.hold||d<i.in||d>=i.out)continue;let{n:l,d:n}=Ct(i.speed);return i.at+Math.round((d-i.in)*n/l)}return null}var ct=e=>e.length?Math.max(...e.map(o=>o.end)):0;function Pt(e,o){let d=[];for(let i of o){let l=it(e,i.asset,i.start);l!==null&&l>0&&d.push({id:i.id,at:l})}return d}var Y=e=>7056e5*e.d/e.n,Tt=(e,o)=>Math.floor(e/Y(o)+1e-9),lt=(e,o)=>Math.round(Tt(e,o)*Y(o));function et(e,o){let d=Math.max(0,e)/7056e5,i=Math.floor(d/60),l=Math.floor(d%60),n=Tt(Math.max(0,e)-Math.floor(d)*7056e5,o);return`${String(i).padStart(2,"0")}:${String(l).padStart(2,"0")}.${String(n).padStart(2,"0")}`}function Et(e,{shift:o=!1,mod:d=!1}={}){if(d)return e==="z"||e==="Z"?{type:o?"redo":"undo"}:null;switch(e){case" ":return{type:"toggle"};case"k":case"K":return{type:"rate",rate:0};case"l":case"L":return{type:"faster"};case"j":case"J":return{type:"reverse"};case"ArrowRight":return{type:"step",frames:o?null:1,seconds:o?1:null};case"ArrowLeft":return{type:"step",frames:o?null:-1,seconds:o?-1:null};case"Home":return{type:"seek",t:0};case"1":return{type:"mode",mode:"direct"};case"2":return{type:"mode",mode:"edit"};case"3":return{type:"mode",mode:"finish"};case"/":return{type:"prompt"};case"s":case"S":return{type:"split"};case"Backspace":case"Delete":return{type:"delete"};default:return null}}function At(e,o,{fps:d,duration:i}){let l=Math.max(0,i-Y(d)),n=m=>Math.min(Math.max(0,Math.round(m)),l);switch(o.type){case"toggle":return{...e,rate:e.rate===0?1:0};case"rate":return{...e,rate:o.rate};case"faster":return{...e,rate:e.rate<=0?1:2};case"reverse":return{...e,rate:e.rate>=0?-1:-2};case"step":{let m=o.frames!==null?o.frames*Y(d):o.seconds*7056e5;return{rate:0,t:n(lt(e.t,d)+m)}}case"seek":return{...e,t:n(o.t)};case"tick":{let m=n(o.t);return{t:m,rate:m===0&&e.rate<0||m===l&&e.rate>0?0:e.rate}}default:return e}}var Ht=1280;function Ot({canvas:e,urlOf:o,assetOf:d,onTime:i,onRate:l}){let n=e.getContext("2d",{willReadFrequently:!0}),m=new Map,h=[],c={n:30,d:1},u=0,y=0,w=0,W={width:1920,height:1080},C=1,a=!1,b=0,x=null;function P(r){let f=h[r],v=`${f.asset}:${r%2}`;if(!m.has(v)){let S=document.createElement("video");Object.assign(S,{muted:!0,preload:"auto",playsInline:!0,crossOrigin:"anonymous",src:o(f.asset)}),m.set(v,S)}return m.get(v)}function T(r,f){let v=d(r.asset)?.facts?.fps??c;return(f+Y(v)/2)/7056e5}function E(){let r=Math.min(1,Ht/Math.max(W.width,W.height)),f=Math.round(W.width*r),v=Math.round(W.height*r);(e.width!==f||e.height!==v)&&Object.assign(e,{width:f,height:v})}function _(r,f,v){E();let{width:S,height:N}=e;if(n.fillStyle="#000",n.fillRect(0,0,S,N),r?.videoWidth){let $=Math.max(S/r.videoWidth,N/r.videoHeight)*C,L=r.videoWidth*$,Z=r.videoHeight*$;n.drawImage(r,(S-L)/2,(N-Z)/2,L,Z),x={asset:f.asset,source:v}}if(a){n.strokeStyle="rgb(255 255 255 / 0.55)",n.setLineDash([6,6]),n.lineWidth=1;for(let $ of[.05,.1])n.strokeRect(S*$,N*$,S*(1-2*$),N*(1-2*$));n.setLineDash([])}}let K=()=>{E(),n.fillStyle="#000",n.fillRect(0,0,e.width,e.height),x=null},A=0,g=Promise.resolve();function M(r){let f=h.indexOf(tt(h,r));if(f<0)return Promise.resolve(K());let v=h[f],S=Q(v,r),N=P(f),$=T(v,S),L=++A,Z=new Promise(z=>{let J=()=>{A===L&&_(N,v,S),z()};if(N.readyState>=2&&Math.abs(N.currentTime-$)<1e-4)return J();N.addEventListener("seeked",J,{once:!0}),N.currentTime=$});if(g=Z,h[f+1]){let z=P(f+1);z!==N&&(z.currentTime=T(h[f+1],h[f+1].in))}return Z}function D(){for(let r of m.values())r.pause(),r.muted=!0}function B(r,f=!0){y=Math.min(Math.max(0,r),Math.max(0,u-Y(c))),f&&i(y)}function O(r){let f=h.indexOf(tt(h,y));if(f<0)return R(0);let v=(S,N)=>{let $=h[S],L=P(S);L.currentTime=T($,Q($,N)),L.playbackRate=w,L.muted=!1;let{n:Z,d:z}=typeof $.speed=="object"?$.speed:{n:1,d:1},J=(bt,ut)=>{if(r!==b)return;let st=$.at+Math.round((Math.round(ut.mediaTime*7056e5)-$.in)*z/Z);if(st>=$.end-Y(c)/2||L.ended)return L.pause(),L.muted=!0,h[S+1]?(f=S+1,B(h[f].at),v(f,h[f].at)):R(0);_(L,$,Q($,st)),B(st),L.requestVideoFrameCallback(J)};L.requestVideoFrameCallback(J),L.play().catch(()=>r===b&&R(0))};v(f,y)}function q(r){let f=performance.now(),v=async S=>{if(r===b){if(B(y-(S-f)/1e3*7056e5*Math.abs(w)),f=S,await M(y),y===0)return R(0);requestAnimationFrame(v)}};requestAnimationFrame(v)}function R(r){if(r===w&&r!==0)return;w=r;let f=++b;D(),l(w),w>0?O(f):w<0?q(f):(B(lt(y,c)),M(y))}return{load(r,{fps:f,duration:v,shape:S}){return h=r,c=f,u=v,S&&(W=S),++b,D(),w=0,l(0),B(Math.min(y,Math.max(0,u-Y(c)))),M(y)},seek(r){return w!==0&&R(0),B(lt(r,c)),M(y)},setRate:R,get time(){return y},get rate(){return w},get shown(){return x},get settled(){return g},setShape(r){return W=r,M(y)},setZoom(r){return C=r,M(y)},setGuides(r){return a=r,M(y)},pixels:()=>e.width?n.getImageData(0,0,e.width,e.height):null}}var Rt=[{key:"picture",label:"Picture",colour:"--clip-picture"},{key:"overlays",label:"B-roll",colour:"--clip-broll"},{key:"audio",label:"Audio",colour:"--clip-audio"},{key:"captions",label:"Captions",colour:"--clip-caption"}],X=44,Lt=6;function mt({root:e,compact:o=!1,onSeek:d,onSelect:i=()=>{}}){let l=o?Rt.slice(0,1):Rt,n=t("canvas",{class:"lanes","aria-hidden":"true"}),m=o?null:t("div",{class:"lane-labels","aria-hidden":"true"},l.map(g=>t("div",{class:"lane-label"},g.label))),h=t("ul",{class:"clip-list","aria-label":o?"Story":"Clips on the timeline"});e.append(...[m,t("div",{class:"lanes-wrap"},n),h].filter(Boolean));let c=n.getContext("2d"),u={picture:[],overlays:[],audio:[],captions:[]},y=0,w={n:30,d:1},W=0,C=[],a=[],b=new Map,x=null,P=null,T=g=>getComputedStyle(e).getPropertyValue(g).trim()||"#888";function E(){let g=Math.max(1,n.clientWidth),M=l.length*(X+Lt),D=window.devicePixelRatio||1;(n.width!==Math.round(g*D)||n.height!==Math.round(M*D))&&(n.width=Math.round(g*D),n.height=Math.round(M*D),n.style.height=`${M}px`),c.setTransform(D,0,0,D,0,0),c.clearRect(0,0,g,M);let B=O=>y?O/y*g:0;l.forEach((O,q)=>{let R=q*(X+Lt);c.fillStyle=T("--lane"),c.fillRect(0,R,g,X);for(let r of u[O.key]??[]){let f=B(r.at),v=Math.max(2,B(r.end)-f);c.fillStyle=T(O.colour),c.fillRect(f,R+2,v-1,X-4),r.clip&&r.clip===x&&(c.strokeStyle=T("--focus"),c.lineWidth=2,c.strokeRect(f+1,R+3,v-3,X-6));let S=O.key==="audio"||o&&O.key==="picture"?b.get(r.asset):null;if(S&&r.in!==void 0){c.fillStyle=T("--wave");let N=r.out-r.in;for(let $=0;$<v;$++){let L=(r.in+N*$/v)/7056e5,z=(S.peaks[Math.floor(L*S.perSecond)]??0)*(X-8);c.fillRect(f+$,R+X/2-z/2,1,Math.max(1,z))}}}if(O.key==="picture"&&P){c.strokeStyle=T("--ghost"),c.setLineDash([5,4]),c.lineWidth=2;let r=Math.max(y,P.duration)||1;for(let f of P.picture)c.strokeRect(f.at/r*g+1,R+6,Math.max(2,(f.end-f.at)/r*g-2),X-12);c.setLineDash([])}if(O.key==="picture"){c.fillStyle=T("--shot");for(let r of C)c.fillRect(B(r.at)-.5,R,1,8)}}),c.fillStyle=T("--playhead");for(let O of a)c.fillRect(B(O.at)-1,0,3,8);c.fillStyle=T("--playhead"),c.fillRect(B(W)-1,0,2,M)}let _=!1,K=g=>{let M=n.getBoundingClientRect();d(Math.round(Math.min(1,Math.max(0,(g.clientX-M.left)/M.width))*y))};n.addEventListener("pointerdown",g=>{_=!0,n.setPointerCapture(g.pointerId),K(g)}),n.addEventListener("pointermove",g=>_&&K(g)),n.addEventListener("pointerup",()=>_=!1),new ResizeObserver(E).observe(n);function A(g){x=g;for(let M of h.querySelectorAll("button"))M.setAttribute("aria-pressed",String(M.dataset.clip===g));i(g),E()}return{load(g,{duration:M,fps:D,marks:B=[],pins:O=[]}){a=O,u=g,y=M,w=D,C=B,x&&!u.picture.some(q=>q.clip===x)&&(x=null),U(h);for(let q of u.picture.filter((R,r,f)=>f.findIndex(v=>v.clip===R.clip)===r)){let R=t("button",{type:"button","aria-pressed":String(q.clip===x),dataset:{clip:q.clip},onclick:()=>(A(q.clip),d(q.at))},`Clip ${q.clip}, ${et(q.at,w)} to ${et(q.end,w)}`);h.append(t("li",{},R))}E()},setPeaks(g,M){b.set(g,M),E()},setGhost(g){P=g,E()},setTime(g){W=g,E()},select:A,get selected(){return x},draw:E}}var It=new Set(["filler","stutter","restart"]);function Ft({root:e,onSeek:o,onCut:d}){let i=[],l=new Map,n=null,m=[],h=null,c=()=>{for(let u of e.querySelectorAll(".word[aria-pressed='true']"))u.setAttribute("aria-pressed","false");for(let u of m)e.querySelector(`[data-word="${CSS.escape(u)}"]`)?.setAttribute("aria-pressed","true")};return e.addEventListener("click",u=>{let y=u.target.closest(".word");if(!y)return;let w=l.get(y.dataset.word);if(u.shiftKey&&n){let[W,C]=[i.indexOf(n),i.indexOf(w)].sort((a,b)=>a-b);m=i.slice(W,C+1).filter(a=>a.asset===w.asset).map(a=>a.id)}else n=w,m=[w.id],o(w);c()}),e.addEventListener("keydown",u=>{(u.key==="Backspace"||u.key==="Delete")&&m.length&&(u.preventDefault(),u.stopPropagation(),d(l.get(m[0]),l.get(m.at(-1))))}),{load({words:u=[],sentences:y=[],takes:w=[]}){i=u,l=new Map(u.map(a=>[a.id,a])),m=m.filter(a=>l.has(a));let W=new Map(w.map(a=>[a.sentence,a]));if(U(e),!u.length){e.append(t("p",{class:"note"},"No transcript yet. Index a clip in the bin to read its words."));return}let C=y.length?y:[...new Set(u.map(a=>a.asset))].map(a=>{let b=u.filter(x=>x.asset===a);return{id:null,asset:a,firstWord:b[0].id,lastWord:b.at(-1).id,score:1}});for(let a of C){let b=W.get(a.id),x=b&&b.rank>1||a.score===0,P=Number(a.firstWord.split(":w")[1]),T=Number(a.lastWord.split(":w")[1]),E=t("p",{class:`sentence${x?" lost":""}`,dataset:a.id?{sentence:a.id}:{}});b&&E.append(t("span",{class:"tag"},b.rank===1?"best take":`take ${b.rank}`));for(let _=P;_<=T;_++){let K=l.get(`${a.asset}:w${_}`);if(!K)continue;let A=x||K.flags.some(D=>It.has(D)),g=A?`${K.text} (${x?"retake":K.flags.filter(D=>It.has(D)).join(", ")})`:null,M=t("button",{type:"button",class:`word${A?" struck":""}${K.flags.includes("low_confidence")?" unsure":""}`,"aria-pressed":"false","aria-label":g,dataset:{word:K.id}});M.textContent=K.text,E.append(M," ")}e.append(E)}c()},playing(u){u!==h&&(e.querySelector(".word.now")?.classList.remove("now"),h=u,u&&e.querySelector(`[data-word="${CSS.escape(u)}"]`)?.classList.add("now"))},words:()=>i,selection:()=>m.length?[m[0],m.at(-1)]:null,clear(){m=[],n=null,c()}}}var yt=document.getElementById("app"),Wt=["direct","edit","finish"],gt=(e,o)=>{try{if(o===void 0)return localStorage.getItem(e);localStorage.setItem(e,o)}catch{return null}},Ut=()=>{try{return sessionStorage.getItem("kriya-edit-back")}catch{return null}};function Kt(...e){let o=Ut();return t("header",{class:"bar"},o?t("a",{class:"btn ghost",href:o},"\u2190 Kriya Harness"):t("span",{class:"brand"},"Kriya"),t("span",{class:"title"},"Editing Studio"),...e)}function dt(e){U(yt).append(t("main",{class:"center"},t("h1",{},"Open the Studio from Kriya"),t("p",{},e??"Click Editing Studio in Kriya Harness, or run kriya edit and open its link.")))}async function zt(){let e;try{({projects:e}=await F("GET","/projects"))}catch(h){return h.status===401?dt():dt(h.message)}let o=t("input",{id:"new-name",class:"field",required:!0,placeholder:"Pricing reel",autocomplete:"off"}),d=t("input",{id:"new-folder",class:"field",required:!0,placeholder:"/Users/you/Movies/pricing"}),i=t("p",{class:"note",role:"status"}),l=t("form",{class:"panel new",onsubmit:async h=>{h.preventDefault();try{let{id:c}=await F("POST","/projects",{name:o.value.trim(),folder:d.value.trim()});location.hash=`#/p/${c}`}catch(c){i.textContent=c.message}}},t("h2",{},"New project"),t("label",{for:"new-name"},"Name"),o,t("label",{for:"new-folder"},"Folder for the project file (its footage stays where it is)"),d,t("button",{class:"btn primary",type:"submit"},"Create"),i),n=t("section",{class:"panel taste","aria-label":"Your taste"}),m=async h=>{let{proposed:c,confirmed:u}=h??await F("GET","/taste"),y=(w,W)=>async()=>m(await F("POST",`/taste/${encodeURIComponent(w)}/${W}`));U(n).append(t("h2",{},"Your taste"),...c.length||u.length?[]:[t("p",{class:"note"},"Nothing yet. When you make the same choice across projects, Kriya asks here before using it.")],...c.map(w=>t("div",{class:"taste-row"},t("p",{},w.sentence),t("button",{type:"button",class:"btn primary",onclick:y(w.key,"confirm")},"Use it"),t("button",{type:"button",class:"btn",onclick:y(w.key,"dismiss")},"No"))),...u.map(w=>t("div",{class:"taste-row"},t("p",{},w.shown),t("button",{type:"button",class:"btn","aria-label":`Remove the rule ${w.shown}`,onclick:y(w.key,"remove")},"Remove"))))};m().catch(()=>{}),U(yt).append(Kt(),t("main",{class:"home"},t("h1",{},"What are we making?"),t("section",{class:"panel"},t("h2",{},"Projects"),e.length?t("ul",{class:"projects"},e.map(h=>t("li",{},t("a",{class:"btn",href:`#/p/${h.id}`},h.name)))):t("p",{class:"note"},"No projects yet.")),l,n))}async function Zt(e){let o;try{o=await F("GET",`/projects/${e}`)}catch(s){return s.status===401?dt():dt(s.message)}let d=o.project,i=o.assets,l={assets:[],words:[],sentences:[],takes:[],shots:[]},n=[],m={picture:[],overlays:[],audio:[],captions:[]},h=null,c=Wt.includes(gt("kriya-edit-mode"))?gt("kriya-edit-mode"):"direct",u=()=>d.canvas.fps,y=t("span",{class:"time label-mono","aria-live":"off"},"00:00.00"),w=t("span",{class:"chip"},"Preview"),W=t("canvas",{class:"monitor",role:"img","aria-label":"Program monitor"}),C=t("p",{class:"note",role:"status","aria-live":"polite"}),a=Ot({canvas:W,urlOf:s=>`/media/${i.find(p=>p.id===s).media}`,assetOf:s=>i.find(p=>p.id===s),onTime:s=>{y.textContent=`${et(s,u())} / ${et(x(),u())}`,A.setTime(s),g.setTime(s);let p=tt(b(),s),k=p?Q(p,s):null,j=k===null?null:l.words.find(I=>I.asset===p.asset&&k>=I.start&&k<I.end);K.playing(j?.id??null)},onRate:s=>{ot.textContent=s===0?"Play":"Pause",ot.setAttribute("aria-label",s===0?"Play (Space)":`Pause (Space), playing at ${s}\xD7`)}}),b=()=>h?ft(i.find(s=>s.id===h)):n,x=()=>ct(b()),P=t("div",{class:"transcript",tabindex:"-1"}),T=t("div",{class:"strip"}),E=t("div",{class:"timeline"}),_=t("div",{class:"finish"}),K=Ft({root:P,onSeek:s=>{let p=it(n,s.asset,s.start);p!==null?(D(),a.seek(p)):B(s.asset,s.start)},onCut:(s,p)=>q([{op:"remove_range",asset:s.asset,from:{word:s.id,edge:"start"},to:{word:p.id,edge:"end"}}])}),A=mt({root:E,onSeek:s=>(D(),a.seek(s))}),g=mt({root:T,compact:!0,onSeek:s=>(D(),a.seek(s))}),M=$t({root:_,pixels:()=>a.pixels(),project:()=>d});function D(){h&&(h=null,w.textContent="Preview",a.load(n,{fps:u(),duration:ct(n),shape:d.canvas}))}function B(s,p){h=s;let k=i.find(j=>j.id===s).facts;w.textContent="Source",a.load(ft(i.find(j=>j.id===s)),{fps:k.fps??u(),duration:k.duration,shape:{width:k.width??1920,height:k.height??1080}}).then(()=>a.seek(p))}async function O(){let[s,p,k]=await Promise.all([F("GET",`/projects/${e}`),F("GET",`/projects/${e}/plan`),F("GET",`/projects/${e}/index`)]);d=s.project,i=s.assets,l=k,m=p.timeline,n=jt(p.timeline);let j=ct(n),I=Pt(n,l.shots),nt=new Map((l.words??[]).map(G=>[G.id,G])),_t=(d.sequences.find(G=>G.id===d.active)?.markers??[]).flatMap(G=>{let V=G.name.startsWith("Note: ")&&G.at?.word?nt.get(G.at.word):null,H=V?it(n,V.asset,V.start):null;return H==null?[]:[{at:H,name:G.name}]});A.load(m,{duration:j,fps:u(),marks:I,pins:_t}),g.load({picture:m.picture},{duration:j,fps:u(),marks:I}),K.load(l),f(),h||await a.load(n,{fps:u(),duration:j,shape:d.canvas});for(let G of new Set([...m.audio,...m.picture].map(V=>V.asset))){let V=i.find(H=>H.id===G)?.media;V&&i.find(H=>H.id===G).facts.hasAudio&&fetch(`/tiles/${V}?kind=peaks`).then(H=>H.ok?H.json():null).then(H=>H&&(A.setPeaks(G,H.levels[0]),g.setPeaks(G,H.levels[0]))).catch(()=>{})}}async function q(s){try{let p=await F("PATCH",`/projects/${e}`,{ops:s});C.textContent=p.diagnostics?.length?p.diagnostics[0].message:""}catch(p){C.textContent=p.value?.diagnostics?.[0]?.message??p.message}await O()}let R=t("ul",{class:"bin","aria-label":"Footage"}),r=t("input",{id:"add-path",class:"field",placeholder:"/path/to/take.mov",autocomplete:"off"});function f(){U(R);for(let s of i){let p=l.assets.find(I=>I.asset===s.id),k=p?.layers.find(I=>I.layer==="L2"),j=p?k?.status==="ok"?"Indexed":k?.notice??"Indexed, no words":"Not indexed";R.append(t("li",{class:"asset"},t("button",{type:"button",class:"btn",onclick:()=>B(s.id,0)},`${s.path.split(/[\\/]/).at(-1)} \xB7 ${s.kind}`),t("span",{class:"note"},j),t("button",{type:"button",class:"btn",onclick:async()=>(await F("POST",`/projects/${e}/index`,{asset:s.id}),C.textContent="Reading your footage. You can start working now.")},"Index"),t("button",{type:"button",class:"btn",onclick:()=>q([{op:"keep_range",asset:s.id,from:0,to:s.facts.duration}])},"Add to cut")))}}let v=t("section",{class:"panel bin-panel","aria-label":"Bin"},t("h2",{},"Bin"),R,t("form",{class:"row",onsubmit:async s=>{s.preventDefault();try{await F("POST",`/projects/${e}/assets`,{path:r.value.trim()}),r.value="",await O()}catch(p){C.textContent=p.message}}},t("label",{for:"add-path",class:"sr-only"},"Add a file by its path"),r,t("button",{class:"btn",type:"submit"},"Add"))),S=t("input",{id:"prompt",class:"field",placeholder:"Ask for a change",autocomplete:"off"}),N=t("span",{class:"chip selection",hidden:!0}),$=t("div",{class:"proposal","aria-live":"polite"}),L=t("ul",{class:"did","aria-label":"What I did"}),Z=()=>{let s=K.selection();return s?{selection:{words:s},label:`Selected: ${l.words.find(p=>p.id===s[0])?.text??""}${s[0]===s[1]?"":" \u2026"}`}:A.selected?{selection:{clip:A.selected},label:`Selected: clip ${A.selected}`}:{selection:{at:a.time},label:null}},z=()=>{let{label:s}=Z();N.hidden=!s,N.textContent=s??""};P.addEventListener("click",()=>setTimeout(z));function J(s){if(U($),A.setGhost(s?s.timeline:null),g.setGhost(s?s.timeline:null),!s)return;let p=async(k,j)=>{try{let I=await F("POST",`/projects/${e}/proposals/${s.id}`,{accept:k,...j?{only:j}:{}});if(C.textContent=I.dropped.length?`Not applied, because you changed that part: ${I.dropped.map(nt=>nt.change).join("; ")}.`:k?"Done. Undo with Cmd+Z.":"Left as it was.",k)for(let nt of j?j.map(Mt=>s.changes[Mt]):s.changes)L.prepend(t("li",{},nt))}catch(I){C.textContent=I.message}J(null),await O()};$.append(t("p",{class:"lead"},"Proposed, not applied yet"),t("ul",{},s.changes.map((k,j)=>t("li",{},t("span",{},k),s.changes.length>1?t("button",{type:"button",class:"btn",onclick:()=>p(!0,[j])},"Only this"):null))),t("div",{class:"row"},t("button",{type:"button",class:"btn primary",onclick:()=>p(!0)},s.changes.length>1?"Accept all":"Accept"),t("button",{type:"button",class:"btn",onclick:()=>p(!1)},"Reject")))}let bt=t("form",{class:"prompt",onsubmit:async s=>{s.preventDefault();let p=S.value.trim();if(p){C.textContent="Thinking about that\u2026";try{let{proposal:k,reason:j}=await F("POST",`/projects/${e}/ask`,{text:p,selection:Z().selection});C.textContent=k?"":j??"Kriya couldn't turn that into an edit.",k&&(S.value=""),J(k)}catch(k){C.textContent=k.status===0||k.status>=500?"I can't reach Kriya, so I can't make changes by asking. You can still edit by hand.":k.message}}}},t("label",{for:"prompt",class:"sr-only"},"Ask for a change"),S,t("button",{class:"btn primary",type:"submit"},"Ask")),ut={delivered:"Checked",delivered_with_notes:"Checked, with notes",blocked:"Needs you",not_checked:"Not checked"},st=t("button",{type:"button",class:"btn",onclick:async()=>{try{at=(await F("POST",`/projects/${e}/make`,{})).id,C.textContent="Reading your footage. You can start working now."}catch(s){C.textContent=s.message}}},"Make a reel"),at=null;async function Dt(){if(!at)return;let s=(await F("GET","/jobs")).jobs.find(k=>k.id===at);if(!s||!["done","failed","canceled"].includes(s.status))return;if(at=null,s.status!=="done")return C.textContent=s.error??"The reel stopped.";let p=JSON.parse(s.output);C.textContent=`${ut[p.verdict]??p.verdict}. ${p.notes.join(" ")}`;for(let k of[...p.changes].reverse())L.prepend(t("li",{},k))}let ot=t("button",{type:"button",class:"btn primary",onclick:()=>pt({type:"toggle"})},"Play"),qt={project:()=>d.canvas,"16:9":()=>({width:1920,height:1080}),"9:16":()=>({width:1080,height:1920})},wt=t("select",{class:"field small","aria-label":"Preview shape",onchange:()=>a.setShape(qt[wt.value]())},["project","16:9","9:16"].map(s=>t("option",{value:s},s==="project"?"Project shape":s))),kt=t("input",{type:"range",min:"1",max:"3",step:"0.05",value:"1",class:"zoom","aria-label":"Zoom",oninput:()=>a.setZoom(Number(kt.value))}),xt=t("input",{type:"checkbox",id:"guides",onchange:()=>a.setGuides(xt.checked)});function pt(s){if(!s)return;if(s.type==="mode")return rt(s.mode);if(s.type==="prompt")return S.focus();if(s.type==="undo")return F("PATCH",`/projects/${e}`,{undo:!0}).then(O);if(s.type==="redo")return C.textContent="Redo isn't here yet.";if(s.type==="split"){let I=tt(n,a.time);return I&&q([{op:"split",clip:I.clip,at:Q(I,a.time)}])}if(s.type==="delete")return A.selected&&q([{op:"ripple_delete",clip:A.selected}]);let p={fps:h?i.find(I=>I.id===h).facts.fps??u():u(),duration:x()},k={t:a.time,rate:a.rate},j=At(k,s,p);j.rate!==k.rate&&a.setRate(j.rate),(j.t!==k.t||s.type==="seek")&&a.seek(j.t)}function rt(s){c=s,gt("kriya-edit-mode",c),St.dataset.mode=c;for(let p of vt.querySelectorAll("button"))p.setAttribute("aria-pressed",String(p.dataset.mode===c));A.draw(),g.draw(),c==="finish"&&M.refresh().catch(()=>{})}let vt=t("div",{class:"modes",role:"group","aria-label":"Mode"},Wt.map((s,p)=>t("button",{type:"button",class:"btn",dataset:{mode:s},"aria-pressed":"false","aria-keyshortcuts":String(p+1),onclick:()=>rt(s)},s[0].toUpperCase()+s.slice(1)))),St=t("div",{class:"workspace"},Kt(t("span",{class:"project-name"},d.name),vt),t("div",{class:"grid"},t("div",{class:"area-bin"},v),t("section",{class:"area-monitor panel","aria-label":"Monitor"},t("div",{class:"monitor-frame"},W),t("div",{class:"transport"},ot,y,w,wt,t("label",{class:"inline"},xt," Safe zones"),t("label",{class:"inline"},"Zoom ",kt))),t("aside",{class:"area-kriya panel","aria-label":"Kriya"},t("h2",{},"Kriya"),st,N,bt,C,$,t("h2",{},"What I did"),L),t("section",{class:"area-transcript panel","aria-label":"Transcript"},t("h2",{},"Transcript"),P),t("div",{class:"area-strip"},T),t("section",{class:"area-timeline panel","aria-label":"Timeline"},E),t("div",{class:"area-finish"},_)));U(yt).append(St),rt(c),window.onkeydown=s=>{let p=s.target.closest?.("input, select, textarea");if(p&&s.key!=="Escape")return;if(s.key==="Escape")return p?document.activeElement?.blur():(K.clear(),A.select(null),z());let k=Et(s.key,{shift:s.shiftKey,mod:s.metaKey||s.ctrlKey});k&&(k.type==="toggle"&&s.target.closest?.("button")&&s.target!==ot||(s.preventDefault(),pt(k)))},setInterval(()=>c==="finish"&&M.scopes(),250),new EventSource("/events").addEventListener("job",()=>{c==="finish"&&M.refresh().catch(()=>{}),Dt().catch(()=>{}),O().catch(()=>{})}),await O(),window.__studio={monitor:a,act:pt,reload:O,setMode:rt,get pieces(){return n}}}function Nt(){let e=/^#\/p\/([0-9a-f]{16})$/.exec(location.hash);e?Zt(e[1]):zt()}window.addEventListener("hashchange",Nt);Nt();
|