demoman 0.9.5 → 0.9.7

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/dist/recipe.md CHANGED
@@ -141,14 +141,14 @@ The file, with one account:
141
141
 
142
142
  `snapshot(url)` opens `url` in Demoman's browser and lists the page's
143
143
  targets, leaving the page open. Each entry is
144
- `{ target, kind, text, value, rect, shown, inFirstViewport }`. Every `target` resolves in a run to that element.
144
+ `{ target, kind, text, value, rect, shown, inFirstViewport }`. Every `target` resolves in a run.
145
145
 
146
146
  - **Copy a `target` into a step verbatim. Never compose one**, and never
147
147
  translate a name from another tool's accessibility tree: Demoman's roles
148
148
  are not Chrome's.
149
149
  - `landedElsewhere: true` - the app redirected, often to its sign-in page;
150
150
  `landedUrl` says where. If it is a sign-in page,
151
- see `session` below and spend no run. If it is not a sign-in page (a
151
+ see `session` below. If it is not a sign-in page (a
152
152
  trailing slash, `https`, a locale prefix), use `landedUrl` as the
153
153
  script's `target`; this snapshot stands.
154
154
  `landedElsewhere: null`: the address could not be read; not an
@@ -169,9 +169,8 @@ targets, leaving the page open. Each entry is
169
169
  `waitFor … until: "visible"` target after the step that opens it.
170
170
  `shown: false`: transparent, hidden or a sliver now; `waitFor` waits.
171
171
  - `size` is `{ width, height, from, error }`: the size the page was laid out
172
- at, as a run records. `from` is `screen` (this machine's screen),
173
- or `device`. `from: "window"` with an `error`: Demoman could not read the
174
- screen and listed the browser's smaller layout; tell the user the `error`.
172
+ at. `snapshot` measures it and `inFirstViewport` at this screen, a run its own: `from` is `screen`, `flow` (the flow's recorded size) or `device`. `from: "window"` with an `error`: Demoman could not read the
173
+ screen and listed the browser's smaller layout; tell the user any `error`.
175
174
  - `positional: true`: the target is a `treePath` (shared or no name); snapshot
176
175
  again after the page changes. `value`: a field's text, never a password's.
177
176
  `unresolvable`: no target reaches it. `notExamined` above 0: pass `contains`
@@ -273,18 +272,17 @@ A flow in the repo (.demoman/flows) is rewritten by each run: commit that file w
273
272
  - In any outcome, a step whose `textHidden` is set typed into a credential
274
273
  field (`"credentialField"`, or `"credentialUnchecked"` if the page could
275
274
  not say): its text is kept nowhere. Re-filming or deriving that video
276
- asks for a demo value. `landing.startedElsewhere` names where the start URL went; `landing.unchecked`: the page could not be checked for a
277
- sign-in page. `notStored` with `what: "session"` means the saved
275
+ asks for a demo value. `landing.startedElsewhere`: where the start URL went; `landing.unchecked`: no sign-in check. `notStored` with `what: "session"` means the saved
278
276
  session could not be refreshed: name it to the user.
279
277
  - `threw` - a fault in the run; report its `error`.
280
278
  - Then read `frames.degradations` and `frames.storageRefused`, about the
281
279
  video (`surfaceMismatch`: wrong-size frames; `dragPictureMissing`: a
282
280
  drag's item jumps) or refresh screens (`step*`, `requestNotWaited`), not
283
281
  the script. `notDragged`: a drag did nothing; `verdict.diverged` lists
284
- it. Name them to the user; spend no run. `clickUnconfirmed` is about a step: a click
282
+ it. Name them to the user; spend no run. `clickUnconfirmed`: a click
285
283
  could not be confirmed to have reached its target, and
286
- `frames.unconfirmedClicks` names each such step and says why; check in
287
- the video that the step did what it should before saying so.
284
+ `frames.unconfirmedClicks` names each such step and says why; check the video
285
+ before saying so.
288
286
  - A re-film's report carries `rerecord`: `from` (the old video), `notes`
289
287
  (as `report.skeleton` above, `stepDropped` with `why` `actionGone` or
290
288
  `neverPerformed`; `migrated`, `trimClampedToStep`, `zoomNotWritten`: a `sentence`) and `notCarried` (each `removed`, `split`,
@@ -293,20 +291,20 @@ A flow in the repo (.demoman/flows) is rewritten by each run: commit that file w
293
291
  from clicks). Name each
294
292
  to the user; a mask not carried may show what the old video hid.
295
293
  3. **Read the video.** The report carries `video` and `recording`. Read
296
- `video.summary` first (a count per label: `inside`, `atEdge`, `cutOff`,
294
+ `video.summary` first (counts: `inside`, `atEdge`, `cutOff`,
297
295
  `outOfFrame`, `strayArrival`, `detour`, `longStill`), then
298
296
  `video.steps[i].framing.label`, and `video.journeys[j].arrival` /
299
297
  `video.journeys[j].detour` for the cursor.
300
298
  - **Which script step a video step is:** `video.steps` lists the video's
301
- actions, and a `pause` makes no action. Find the report's `steps[k]`
302
- whose `actionId` equals `video.steps[i].actionId`; `steps[k].index` is
303
- its 0-based position in your script.
299
+ actions, and a `pause` makes no action. Match `steps[k].actionId` to
300
+ `video.steps[i].actionId`; `steps[k].index` is its 0-based position.
304
301
  - `video` may be `{ "unavailable": … }` (`refused`, `noVideo`, `noFrames`,
305
- `checkFailed` with `error`): not a clean bill; say so, do not retry. Likewise
302
+ `checkFailed` with `error`): not a clean bill; say so, no retry. Likewise
306
303
  `video.steps[i].unknown` and `video.noCursor: true`.
304
+ - `video.pacing: "planned"`: `plannedMs` is its length before any trim, `recordedMs` how long it ran. `video.unplacedBeats`: pauses played as recorded, named in `frames.unplacedBeats[].step`.
307
305
  - `recording` is `{ "unavailable": … }` or
308
306
  `{ recordingVideoId, steps[], notInRecording[] }`, comparing the run with
309
- the video a derived script came from. `unavailable` is again an answer.
307
+ the video a derived script came from.
310
308
 
311
309
  | Finding | Whose | The move |
312
310
  | --- | --- | --- |
@@ -452,8 +450,7 @@ Studio exports go to `~/Downloads`.
452
450
  - A `click` or `drag` takes `zoom`: `false` for none, or `{ "scale": 1.5 }` (over 1, at most 2.5).
453
451
  - `scrollTo` takes `landing: { "top": <px> }`, optional: the viewport y of
454
452
  the element's top edge once scrolled; absent is centred.
455
- - `viewport` absent means the size the user chose: the screen's, which
456
- `snapshot` measured `inFirstViewport` against. Leave `viewport` out unless the user asked.
453
+ - `viewport` absent means the flow's recorded size, or this screen's on a first run. Leave `viewport` out unless the user asked.
457
454
  - `device` is `"phone"` or `"tablet"`: the page is recorded as a phone (393x852)
458
455
  or a tablet (820x1180). Name a device or a
459
456
  `viewport`, not both. A device has no hover: a `hover` under one is
@@ -0,0 +1,4 @@
1
+ import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,I as c,J as l,L as u,O as d,Q as f,R as p,T as m,Tt as h,W as g,X as _,Z as v,_ as y,at as ee,c as b,ct as x,d as te,et as ne,g as re,gt as ie,h as ae,ht as oe,i as se,it as S,k as ce,lt as le,m as C,n as ue,nt as de,ot as fe,p as pe,pt as me,rt as he,st as ge,t as _e,tt as ve,vt as ye,w as be,wt as xe,z as Se}from"./toast-DqduzzQ9.js";import{C as Ce,T as we,b as Te,f as Ee,h as De,l as Oe,m as ke,o as Ae,p as je,s as Me,w as Ne,x as Pe}from"./state-BS-KyCjA.js";import{A as Fe,C as Ie,D as Le,E as Re,O as ze,S as Be,T as Ve,_ as He,a as Ue,b as We,c as Ge,d as Ke,f as qe,g as Je,h as Ye,k as Xe,l as Ze,m as Qe,o as w,p as $e,s as et,u as tt,v as nt,w as rt,x as it,y as at}from"./view-DCUIuEZt.js";function ot(e,t){let{bundle:n,scene:r}=x(t,e),i=new Map(r.anchors.map(e=>[e.id,e])),a=new Map((n.markers??[]).map(e=>[e.actionId,e.sourceTimeMs])),o=new Map;for(let e of r.anchors)e.fingerprint.boundingRect&&o.set(e.id,e.fingerprint.boundingRect);let s=new Map;for(let e of n.anchorRects??[])s.set(e.actionId,e.rect);let c=(e,t)=>s.get(t)??o.get(e)??null;return r.actions.flatMap(e=>{if(e.kind!==`moveTo`)return[];let t=e.id;if(e.signal!==`style`)return[{kind:`unknown`,actionId:t,reason:`notStyleSignalled`}];let r=a.get(t);if(r===void 0)return[{kind:`unknown`,actionId:t,reason:`noMarker`}];let o=e.anchorId===null?void 0:i.get(e.anchorId),s=e.anchorId===null?null:c(e.anchorId,t);if(s===null)return[{kind:`unknown`,actionId:t,reason:`noRect`}];if(o?.fingerprint.treePath?.startsWith(`#frame(`)===!0)return[{kind:`unknown`,actionId:t,reason:`crossFrameRect`}];if(s.width<=0||s.height<=0)return[{kind:`unknown`,actionId:t,reason:`degenerateRect`}];let{width:l,height:u}=n.viewport;return s.x<0||s.y<0||s.x+s.width>l||s.y+s.height>u?[{kind:`unknown`,actionId:t,reason:`offFrame`}]:s.width<8||s.height<8?[{kind:`unknown`,actionId:t,reason:`cropTooSmall`}]:[{kind:`probe`,actionId:t,rect:{x:s.x,y:s.y,width:s.width,height:s.height},preMs:r-400,postMs:r+100}]})}var st=64;function ct(e,t,n,r,i){let a=e.width/n.width,o=e.height/n.height,s=new OffscreenCanvas(r,i).getContext(`2d`);s.drawImage(e.image,t.x*a,t.y*o,t.width*a,t.height*o,0,0,r,i);let{data:c}=s.getImageData(0,0,r,i),l=new Float32Array(r*i);for(let e=0;e<l.length;e++){let t=c[e*4]??0,n=c[e*4+1]??0,r=c[e*4+2]??0;l[e]=(.2126*t+.7152*n+.0722*r)/255}return l}async function lt(e,t,n,r){let i=[];for(let a of ot(e,t)){if(a.kind===`unknown`){i.push({actionId:a.actionId,kind:`unknown`,reason:a.reason});continue}let e,o;try{e=await n.at(a.preMs),o=await n.at(a.postMs)}catch{i.push({actionId:a.actionId,kind:`unknown`,reason:`decodeFailed`});continue}if(e.sourceTimeMs===o.sourceTimeMs){i.push({actionId:a.actionId,kind:`unknown`,reason:`sameFrame`});continue}if(Math.max(Math.abs(e.sourceTimeMs-a.preMs),Math.abs(o.sourceTimeMs-a.postMs))>250){i.push({actionId:a.actionId,kind:`unknown`,reason:`outOfTolerance`});continue}let s=e=>{let n=e.width/t.viewport.width,r=e.height/t.viewport.height;return a.rect.width*n<8||a.rect.height*r<8};if(s(e)||s(o)){i.push({actionId:a.actionId,kind:`unknown`,reason:`nativeCropTooSmall`});continue}let l=Math.max(1,Math.min(st,Math.round(a.rect.width))),u=Math.max(1,Math.min(st,Math.round(a.rect.height))),d;try{d=c(ct(e,a.rect,t.viewport,l,u),ct(o,a.rect,t.viewport,l,u))}catch{i.push({actionId:a.actionId,kind:`unknown`,reason:`decodeFailed`});continue}i.push({actionId:a.actionId,kind:d>r?`moved`:`still`})}return i}function ut(e){return S.neutral.zoomHoldMs+ee(e).zoomOutMs}ut(ie.smoothness);var dt=Math.abs(S.leadInMs)+S.neutral.minPlateauMs+400;function ft(e){let t=`No zoom on click ${e.actionId}`,n=`gapMs`in e?`${Math.abs(e.gapMs)}ms ${e.gapMs<0?`before`:`after`} ${e.afterActionId}`:``;switch(e.reason){case`off`:return`${t}: turned off.`;case`tooClose`:return`${t}: too close to the previous zoom (${n}, minimum ${dt}ms).`;case`sameTarget`:return`${t}: same target as the previous zoom, already zoomed in (${n}).`;case`targetTooWide`:return`${t}: target too wide to zoom (fits at ${e.scale}x, floor ${pt}x).`;case`textTooWide`:return`${t}: target too wide to zoom without cutting text (would be ${e.scale}x, floor ${pt}x).`}}S.fitMarginPx;var pt=1.2,mt=1e4,ht=`__demomanClickProbe`;`${ht}${JSON.stringify(`__demomanClickSeen`)}`,`${ht}`,`${ht}`,globalThis.process?.platform;var gt=`__demomanCaretHold`,_t=`*{caret-color:transparent!important}`;`${gt}${gt}${_t}${_t}`,`${gt}`;var vt={mutating:`this flow writes data and rebuilding is switched off for it, so what you have is what this take itself recorded — turn on rebuilds for write flows, then rebuild it`,cancelledByAuthor:`you cancelled before it started, so this scene still has what the take itself recorded — re-shoot it in Runs to run it now`,unresolvedAnchor:`an element this demo depends on was not on the page — check the step's target names something the page really shows, or what the step before it does`,ambiguousAnchor:`several elements matched this step, so replay stopped rather than risk clicking the wrong one — name the target more precisely (a stableId, or a role with a fuller name, from a snapshot of the page)`,anchorNotRendered:`an element was in the page's data but not rendered — the page probably needs scrolling further first, so add a scrollTo step before this one`,pageSilent:`the page did not answer when replay asked it to find an element — the app may be down, offline, or showing a browser error page; check it loads, then run again`,pageFaulted:`the page itself threw an error when replay asked it to find an element, so nothing about the element was measured — the app is up; look at that page's own console for the fault, then run again`,anchorUnreachable:`replay found the element this step needs and then could not reach it to measure — nothing is wrong with the target, so changing the step will not help; run it again, and say so if it repeats`,anchorFrameMismatch:`replay found the element this step needs and the frame holding it is not the one recorded — the page's frames have changed since the take, so running it again will fail the same way; change the step to target an element outside that frame`,redactedWithoutReplacement:`a typed value was withheld — a credential field, a secret-shaped value, or an editor whose text went unknown — and has no demo-safe replacement yet; select that step on the timeline and fill in Replace on-screen text, then run it again`,pageWentElsewhere:`the app moved to a different page partway through this script, and nothing in the script asked it to — either a step navigated, or the session expired and it went to a sign-in page; check the app is still signed in, and add a waitForLoad after any step that navigates, then run it again`,signedOut:`the app sent this browser to its sign-in page, so nothing was recorded — sign in again with demoman signin, then run it again`,unperformableStep:`this script asks for something the run cannot perform — a click with a button other than the left one — so it stopped rather than do something else and report success; change that step to a left click`,clickNotDelivered:`the browser put a click somewhere other than where it was sent, so the page never saw that click and the step did not happen — nothing is wrong with the steps; run it again, and say so if it repeats`,dragEndOutOfView:`a drag's start or end was off the page once its start was in view, and a drag cannot scroll while it moves, so it was not begun; drag to a target on the same screen, or scroll first`,dragNoDistance:`a drag's two ends landed on the same point once measured, which is a click, not a drag, so it was not begun; give the drag's end another target, spot or offset`,waitTimeout:`what the step waited for (an element to show or hide, or the page to load) did not happen within ${mt/1e3} s — check the target, or what the step before it does`,occlusionTimeout:`the render window stayed covered, so the frames would not have been usable — leave the window uncovered while it runs, then run it again`,windowClosed:`the replay window was closed before the run finished — nothing is wrong with the take, run it again`,debuggerUnavailable:`the debugger could not be attached to the replay tab — close DevTools on it and run again`,deviceFailed:`the browser refused to emulate the device, so nothing was recorded — the note says which command and why`,portFailure:`something underneath the run gave way — not a fault in the script, so changing it will not fix it; run it once more, and if it stops the same way, report it`,noActions:`this take has no step that acts on the page, so there is nothing to record`};function yt(e){return e in vt?vt[e]:e}function bt(e){if(!e)return`(navigation)`;let t=e.fingerprint;return t.accessibleName??t.textContent??t.stableId??t.dataKey??e.id}function xt(e,t){if(t===null||t.reason===null||t.outcome===`complete`)return null;let n=e.actions[t.completed];return n?{number:t.completed+1,total:e.actions.length,kind:n.kind,label:bt(e.anchors.find(e=>e.id===n.anchorId))}:null}function St(e,t){return xt(e,t)}function Ct(e){return e.meta.capture.mode===`authored`}function wt(e){return e?`run its script again in Runs`:`re-shoot it in Runs`}var Tt=`motion reclaimed to free space`;function Et(e,t){let n=t(e.outputTimeMs),r=n===null?`at ${(e.outputTimeMs/1e3).toFixed(1)}s`:`on the ${n} beat`,i=Math.round(e.neededWidth),a=e.sourceWidth<e.neededWidth,o=(e.neededWidth/e.sourceWidth).toFixed(2);if(e.grantedScale>=e.requestedScale)return`The picture ${r} is upscaled ${o}x — the source frames were only ${e.sourceWidth}px wide there against the ${i}px it is drawn at.`;let[s,c]=Ot(e.requestedScale,e.grantedScale),l=`The camera zoom ${r} was reduced from ${s}x to ${c}x — the source frames were only ${e.sourceWidth}px wide there and could not back it.`;return a?`${l} Even at ${c}x it is upscaled ${o}x against the ${i}px it is drawn at.`:l}function Dt(e,t=2){return String(Number(e.toFixed(t)))}function Ot(e,t){for(let n=2;n<4;n++)if(Dt(e,n)!==Dt(t,n))return[Dt(e,n),Dt(t,n)];return[Dt(e,4),Dt(t,4)]}function kt(e,t){let n=e.some(e=>e.grantedScale<e.requestedScale),r=e.some(e=>e.sourceWidth<e.neededWidth),i=n&&r?`This export asked for more detail than the video holds`:n?`Camera zoom was reduced on this export`:`This export is drawn from fewer pixels than it has`,a=new Map;for(let n of e){let e=t(n.outputTimeMs),r=n.grantedScale<n.requestedScale?`cut`:`short`,i=`${e??Math.floor(n.outputTimeMs/1e3)}|${r}`,o=a.get(i),s=n.sourceWidth/n.neededWidth;(!o||s<o.sourceWidth/o.neededWidth)&&a.set(i,n)}return{heading:i,lines:[...a.values()].map(e=>Et(e,t))}}function At(e){let t=e.flatMap(e=>e.outputMs===null?[]:[{outputMs:e.outputMs,label:e.label}]).sort((e,t)=>e.outputMs-t.outputMs);return e=>{let n=null;for(let r of t)if(r.outputMs<=e)n=r.label;else break;return n}}var jt={run:{phase:`idle`},files:[],save:null,error:null};function Mt(e){return{run:{phase:`encoding`,done:0,total:0},files:e.map(e=>({fileType:e,jobId:null,ended:null})),save:null,error:null}}function Nt(e){return e.find(e=>e.ended===null)??null}var Pt=(e,t)=>e===null?t:`${e}; ${t}`;function Ft(e,t){let n=e.findIndex(e=>e.jobId===t);if(n!==-1)return{files:e,index:n};let r=e.findIndex(e=>e.jobId===null&&e.ended===null);return r===-1?{files:e,index:-1}:{files:e.map((e,n)=>n===r?{...e,jobId:t}:e),index:r}}function It(e,t){if(e?.kind!==`saved`||t.kind!==`saved`)return t;let n=[e.summary,t.summary].filter(e=>e!==null);return{kind:`saved`,names:[...e.names,...t.names],byteLength:e.byteLength+t.byteLength,reveal:e.reveal??t.reveal,summary:n.length===0?null:n.join(` `),outputRefs:[...e.outputRefs,...t.outputRefs]}}function Lt(e,t,n){let r=e.map((e,r)=>r===t?{...e,ended:n}:e);return{files:r,run:Nt(r)===null?{phase:`idle`}:{phase:`encoding`,done:0,total:0}}}function Rt(e,t){let n=e.run.phase===`encoding`||e.run.phase===`queued`;if(t.kind===`outputsChanged`)return{flow:e,effect:`relist`};let{files:r,index:i}=Ft(e.files,t.jobId),a=Nt(r),o=i===-1||r[i]===a;switch(t.kind){case`queued`:return n&&o?{flow:{...e,files:r,run:{phase:`queued`,position:t.position}},effect:`render`}:{flow:{...e,files:r},effect:`none`};case`rendering`:return n&&o?{flow:{...e,files:r,run:{phase:`encoding`,done:t.done,total:t.total}},effect:`progress`}:{flow:{...e,files:r},effect:`none`};case`fileFailed`:return{flow:{...e,files:r,error:Pt(e.error,t.line)},effect:`none`};case`saving`:return{flow:{...e,files:r,run:{phase:`saving`}},effect:`render`};case`saved`:return{flow:{...e,...Lt(r,i,`saved`),save:It(e.save,t.save.kind===`saved`&&t.summary!==null?{...t.save,summary:t.summary}:t.save)},effect:`render`};case`failed`:{let n=r.length>1?r[i]:void 0,a=n===void 0?``:`${Ze[n.fileType]}: `;return{flow:{...e,...Lt(r,i,`failed`),error:t.detail===null?e.error:Pt(e.error,`${a}${t.detail}`)},effect:`render`}}}}var T=1,E=e=>({kind:`refusal`,reason:e});function zt(e,t){let n,r=1/0;for(let i of e){let e=t(i);(n===void 0||e<r)&&(n=i,r=e)}return n}function Bt(e){return new Map(e.markers.map(e=>[e.actionId,e.sourceTimeMs]))}function Vt(e,t,n){return Ht(e,ge(t,n))}function Ht(e,t){let n=[...e.markers].sort((e,t)=>e.sourceTimeMs-t.sourceTimeMs),r=n[0];if(r===void 0)return null;let i=r;for(let e of n)e.sourceTimeMs<=t&&(i=e);return{actionId:i.actionId,sourceOffsetMs:Math.round(t-i.sourceTimeMs)}}function Ut(e,t,n){let r=Bt(t),i=new Map((e.edits.removed??[]).map(e=>[e.id,e])),a=[{atMs:0,left:null,right:null,rank:0},{atMs:n.outputDurationMs,left:null,right:null,rank:2}],o=[],s=e=>{let t=(e,t)=>{if(e===null)return t;let i=r.get(e.actionId);if(i===void 0)return t;let a=i+e.sourceOffsetMs;return Math.max(0,Math.min(n.sourceDurationMs,a))};return{removedId:e.id,srcStartMs:t(e.start,0),srcEndMs:t(e.end,n.sourceDurationMs)}},c=[];for(let e of n.cuts){let t=e.ids.flatMap(e=>{let t=i.get(e);return t===void 0?[]:[t]}),c=(e,t)=>e===null?t:(r.get(e.actionId)??t)+e.sourceOffsetMs,l=zt(t,e=>c(e.start,-1/0)),u=zt(t,e=>-c(e.end,1/0));if(l===void 0||u===void 0)continue;let d=fe(n,e.srcStartMs);a.push({atMs:d,left:l.start,right:u.end,rank:1,leftBeside:s(l),rightBeside:s(u)}),e.ids.forEach((t,n)=>{let r=i.get(t),a=r===void 0?null:s(r);o.push({removedId:t,atMs:d,index:n,srcStartMs:a?.srcStartMs??e.srcStartMs,srcEndMs:a?.srcEndMs??e.srcEndMs})})}for(let e of n.unplacedCuts)for(let t of e.ids){let a=i.get(t),s=[a?.start,a?.end].find(e=>e!=null&&r.has(e.actionId)),c=s===void 0?0:fe(n,Math.max(0,Math.min(n.sourceDurationMs,(r.get(s.actionId)??0)+s.sourceOffsetMs)));o.push({removedId:t,atMs:c,index:o.filter(e=>Math.abs(e.atMs-c)<T).length,srcStartMs:0,srcEndMs:0,unplaced:e.reason})}for(let t of e.edits.splits??[]){let e=r.get(t.at.actionId);if(e===void 0){c.push(t.id);continue}let i=e+t.at.sourceOffsetMs;if(n.cuts.some(e=>i>=e.srcStartMs&&i<=e.srcEndMs))continue;let o=fe(n,i);a.push({atMs:o,left:t.at,right:t.at,rank:1})}a.sort((e,t)=>e.atMs-t.atMs||e.rank-t.rank);let l=[];for(let e=0;e+1<a.length;e++){let t=a[e],n=a[e+1];n.atMs-t.atMs<T||l.push({startMs:t.atMs,endMs:n.atMs,start:t.right,end:n.left,before:t.rightBeside??null,after:n.leftBeside??null})}return{pieces:l,joins:o,unplacedSplits:c}}function Wt(e,t,n,r){if(t===null||n===null)return E(`Nothing has rendered yet, so there is no frame to split at.`);if(r<=0||r>=n.outputDurationMs)return E(`A split at the video's start or end splits nothing.`);let i=Vt(t,n,r);if(i===null)return E(`These frames name no step, so there is nothing to split by.`);let a=Bt(t).get(i.actionId)??0,o=fe(n,a+i.sourceOffsetMs),{pieces:s}=Ut(e,t,n);return o<=T||o>=n.outputDurationMs-T||s.some(e=>Math.abs(e.startMs-o)<T)?E(Math.abs(o-r)<T?`The clip is already split here.`:`A pause is one frame, so a split anywhere in it lands at its edge — and the clip is already split there.`):{kind:`split`,at:i}}var Gt=(e,t)=>e===null||t===null?e===t:e.actionId===t.actionId&&e.sourceOffsetMs===t.sourceOffsetMs;function Kt(e,t,n){let r=e.find(e=>Gt(e.start,t));if(r===void 0)return E(`That piece is no longer on the timeline.`);if(e.length===1)return E(`This is the only piece left, so removing it would leave nothing to export.`);if(n!==void 0){let t=e=>e.endMs>n.headMs+T&&e.startMs<n.tailMs-T;if(t(r)&&e.filter(t).length===1)return E(`This is the only piece inside the trim, so removing it would leave nothing to export.`)}return{kind:`removePiece`,start:r.start,end:r.end}}function qt(e,t,n,r,i,a){let o=n.find(e=>Gt(e.start,r));if(o===void 0)return E(`That piece is no longer on the timeline.`);if(e===null||t===null)return E(`Nothing has rendered yet, so there is no frame to move the edge to.`);let s=Math.round(a);if(s===0)return null;let c=i===`end`?s<0:s>0,l=i===`end`?o.after:o.before;if(c){let n=i===`end`?Math.max(o.startMs+200,o.endMs+s):Math.min(o.endMs-200,o.startMs+s);if(i===`end`?n>=o.endMs:n<=o.startMs)return E(`This piece is as short as a piece can be.`);let r=Vt(e,t,n);return r===null?E(`These frames name no step, so there is nothing to move the edge by.`):l===null?i===`end`?{kind:`removePiece`,start:r,end:o.end}:{kind:`removePiece`,start:o.start,end:r}:i===`end`?{kind:`setRemovedEdge`,id:l.removedId,start:r}:{kind:`setRemovedEdge`,id:l.removedId,end:r}}if(l===null)return E(i===`end`?`Nothing was removed after this piece, so its end can only move in.`:`Nothing was removed before this piece, so its start can only move in.`);let u=i===`end`?l.srcStartMs+s:l.srcEndMs+s;if(i===`end`?u>=l.srcEndMs-T:u<=l.srcStartMs+T)return{kind:`restorePiece`,id:l.removedId};let d=Ht(e,u);return d===null?E(`These frames name no step, so there is nothing to move the edge by.`):i===`end`?{kind:`setRemovedEdge`,id:l.removedId,start:d}:{kind:`setRemovedEdge`,id:l.removedId,end:d}}var Jt=1e3;function Yt(e){return`Motion reclaimed to free space. ${e}`}var Xt=new Set([`Motion reclaimed to free space. Replay to restore.`,`Motion reclaimed to free space. Rebuild to restore.`]);function Zt(e,t,n){return e===`motionReclaimed`?Xt.has(t)||t===`Motion reclaimed to free space. Re-shoot it in Runs to restore.`?Yt(n):t:`${e}: ${t}`}var Qt=(e,t)=>e.hasBundle?t.outputMs??t.captureMs:t.captureMs;function $t(e){return e.hasBundle&&e.outputDurationMs!==null?e.outputDurationMs:(e.beats[e.beats.length-1]?.captureMs??0)+Jt}var en=e=>({actionId:e.actionId,offsetMs:e.sourceOffsetMs});function tn(e,t){let n=e.beats.find(e=>e.actionId===t.actionId);return(n?Qt(e,n):0)+t.offsetMs}function nn(e){let{scene:t,view:n,bundle:r,resolved:i}=e,{rerunLine:a}=e,o=$t(n),s=[],c=new Set(e.hoverReport?.removable??[]),l=new Map(n.beats.map(e=>[e.actionId,Qt(n,e)])),u=new Map(n.beats.map(e=>[e.actionId,e.timing])),d=e=>i===null?`estimated`:e?u.get(e.actionId)??`estimated`:`rendered`,f=n.beats.map(e=>({actionId:e.actionId,atMs:l.get(e.actionId)??0,verb:e.verb,label:e.label,timing:e.timing,flag:c.has(e.actionId)?`unchangedHover`:null,canZoom:e.canZoom,cut:e.cut})),p=t.edits.trim,m=i?{headMs:i.range.startMs,headTiming:i.trimUnplaced.includes(`head`)?`estimated`:`rendered`,tailMs:i.range.endMs,tailTiming:i.trimUnplaced.includes(`tail`)?`estimated`:`rendered`,headMarker:p?.head??null,tailMarker:p?.tail??null}:{headMs:p?.head?Math.max(0,tn(n,p.head)):0,headTiming:p?.head?`estimated`:`rendered`,tailMs:p?.tail?Math.min(o,tn(n,p.tail)):o,tailTiming:p?.tail?`estimated`:`rendered`,headMarker:p?.head??null,tailMarker:p?.tail??null};for(let e of i?.trimUnplaced??[])s.push(`The trim's ${e} is placed from the video's own timestamp: the last render carried no marker for its step. ${a}`);for(let e of i?.timeline.unplacedCuts??[])s.push(`A removed piece removed no frames: ${e.reason}.`);let h=new Set((i?.clampedRanges??[]).filter(e=>e.kind===`zoom`).map(e=>e.id));for(let e of i?.clampedRanges??[])s.push(e.note);let g=new Map((i?.cameraSegments??[]).map(e=>[e.id,e])),{smoothness:_}=t.motion??ie,v=ut(_),{zoomInMs:y}=ee(_),b=new Set,x=t.camera.flatMap(e=>{let t=e.scale??1;if(t<=1)return[];let r=g.get(e.id);r||b.add(e.id);let i=r?r.startMs:Math.max(0,tn(n,e.marker)),c=r?r.endMs:Math.min(o,e.end?tn(n,e.end):i+v),l=e.point?{kind:`point`,x:e.point.x,y:e.point.y}:{kind:`element`,anchorId:e.anchorId??``};return r?.endUnplaced&&s.push(`The end of zoom "${e.id}" is placed from the video's own timestamp: the last render carried no marker for its step. ${a}`),[{id:e.id,actionId:e.marker.actionId,departMs:r?.departMs??i,startMs:i,endMs:c,drawnEndMs:c,endAuthored:e.end!==void 0,scale:t,target:l,aimFallback:e.note??null,timing:r?r.endUnplaced?`estimated`:d(e.marker):`estimated`,clamped:h.has(e.id),marker:e.marker,endMarker:e.end??null}]}),te=x.map(e=>{if(!b.has(e.id))return e;let t=Math.min(...x.map(e=>e.startMs).filter(t=>t>e.startMs));return e.endMs>t?{...e,endMs:t}:e}),ne=te.map(e=>b.has(e.id)?{...e,departMs:rn(te,e.startMs,y)}:e),re=ne.map(e=>({...e,drawnEndMs:an(ne,e.startMs,e.endMs)})),ae=new Set(t.camera.map(e=>e.marker.actionId));for(let e of t.zoomsSkipped??[])ae.has(e.actionId)||`afterActionId`in e&&!ae.has(e.afterActionId)||s.push(ft(e));let oe=new Map((i?.cosmetics??[]).map(e=>[e.id,e])),se=t.edits.masks.map(e=>{let t=e.start===void 0||e.end===void 0,r=oe.get(e.id),c=r?.range??null;for(let t of r?.unplaced??[])s.push(`The ${t} of mask "${e.id}" is placed from the video's own timestamp: the last render carried no marker for its step, so the mask covers more of the video than it was drawn to. ${a}`);let l=t?0:c?c.startMs:e.start?Math.max(0,tn(n,en(e.start))):0,u=t?o:c?c.endMs:e.end?Math.min(o,tn(n,en(e.end))):o;return{id:e.id,startMs:l,endMs:u,rect:e.rect,wholeTake:t,timing:t||i&&c&&d(e.start)===`rendered`&&d(e.end)===`rendered`?`rendered`:`estimated`,startMarker:e.start??null,endMarker:e.end??null}}),S=e=>i?fe(i.timeline,e):e,ce=(r?.degradations??[]).map(e=>({startMs:S(e.startMs),endMs:S(e.endMs)}));for(let e of r?.degradations??[])s.push(Zt(e.kind,e.note,a));let le=i?.timeline.unplacedPaces??0;if(le>0){let e=le===1?`pause`:`pauses`;s.push(t.pacing===void 0?`pacingUnplaced: ${le} recorded ${e} could not be placed. The last render carried no marker for the steps they sit between, so this export is shorter than the video by however long those ${e} were. ${a}`:`pacingUnplaced: ${le} planned ${e} could not be placed. The last render carried no marker for the steps they sit before, so ${le===1?`that stretch plays`:`those stretches play`} as recorded, not at the planned length. ${a}`)}let C=i?.timeline.nonMonotonicPaces??0;if(C>0){let e=C===1?`pair`:`pairs`;s.push(`pacingBackwards: ${C} step ${e} in this video carry timestamps that run backwards, so the video's order is not its time order. A re-record counts the pause across ${C===1?`it`:`them`} twice and comes out longer than the video. Record it again to straighten the order; the frames you already have are unaffected.`)}let{pieces:ue,joins:de,unplacedSplits:pe}=r!==null&&i!==null?Ut(t,r,i.timeline):{pieces:[],joins:[],unplacedSplits:[]};for(let e of pe)s.push(`A split is not drawn: the last render carried no marker for its step. ${a}`);return{clip:{durationMs:o,trim:m,ticks:f,degraded:ce,pieces:ue,joins:de},zooms:re,masks:se,durationMs:o,timeSource:n.hasBundle?`rendered`:`captured`,rerunLine:a,hoverCheck:{failed:e.hoverReport?.failed??!1,unchecked:e.hoverReport?.unchecked??0},notices:s,zoomDefaultMs:v,zoomInMs:y}}function rn(e,t,n){let r=0;for(let n of e)n.startMs>=t||(r=Math.max(r,n.endMs<t?n.endMs:n.startMs));return Math.max(r,t-n)}function an(e,t,n){return Math.min(n,...e.filter(e=>e.startMs>t).map(e=>e.departMs))}function on(e,t,n){let r=e.clip.ticks,i=r[0];if(!i)throw Error(`a video with no steps has nothing to attach an edit to`);let a=i;for(let e of r){let n=Math.abs(e.atMs-t),r=Math.abs(a.atMs-t);(n<r||n===r&&e.atMs<a.atMs)&&(a=e)}let o=Math.round(t-a.atMs);return{actionId:a.actionId,offsetMs:Math.abs(o)<=n?0:o}}function sn(e){let{resolved:t,outputTimeMs:r,presentation:i,target:a,viewport:o}=e;return he(t,r,n(i.frameRect,o),i.frameRect,o,a)}var cn=(e,t,n)=>Math.min(n,Math.max(t,e));function ln(e,t){let n=e.width/2,r=e.height/2;return{x:cn(t.x-n/2,0,e.width-n),y:cn(t.y-r/2,0,e.height-r),width:n,height:r}}function un(e){let{rect:t,resolved:n,target:r,presentation:i,outputTimeMs:a}=e,o=n.plan.viewport,s=sn({resolved:n,outputTimeMs:a,presentation:i,target:r,viewport:o});return p(t,s,i.frameRect,o)}function dn(e){let{rect:t,resolved:n,target:r,presentation:i,outputTimeMs:a}=e,o=n.plan.viewport,c=sn({resolved:n,outputTimeMs:a,presentation:i,target:r,viewport:o}),l=s(t,c,i.frameRect,o),u=cn(l.x,0,o.width),d=cn(l.y,0,o.height),f=cn(l.x+l.width,0,o.width),p=cn(l.y+l.height,0,o.height);return{x:u,y:d,width:f-u,height:p-d}}function fn(e){let{zoom:t,resolved:n,viewport:r,presentation:i,target:a}=e,o=sn({resolved:n,outputTimeMs:(t.startMs+t.endMs)/2,presentation:i,target:a,viewport:r});return s({x:0,y:0,width:a.width,height:a.height},o,i.frameRect,r)}var pn=2e3,mn=e=>e!==null&&e.kind===`refusal`,D=e=>({kind:`refusal`,reason:e});function hn(e,t){if(e.resolved===null||e.bundle===null)return{reason:`nothing has rendered yet`};if(e.bundle.cursorSamples.length===0)return{reason:`this video has no recorded pointer`};let n=ge(e.resolved.timeline,t);if(e.bundle.cursorGaps.some(e=>n>=e.startMs&&n<e.endMs))return{reason:`the pointer was off the page here`};let r=ve(e.resolved.cursor,n);return r?{point:r}:{reason:`the pointer was not observed here`}}var gn=(e,t)=>e.zooms.find(e=>e.id===t),_n=(e,t)=>e.masks.find(e=>e.id===t);function vn(e,t,n,r){let i=e.zooms.find(e=>e.id===t);for(let a of e.zooms){if(a.id===t)continue;let e=yn(a,i,n,r);if(e)return{zoom:a,why:e}}}function yn(e,t,n,r){let i=Math.abs(n-e.startMs);if(i<dt&&(t===void 0||i<Math.abs(t.startMs-e.startMs)||n<e.startMs!=t.startMs<e.startMs))return`start`;if(r!==null&&e.startMs>n&&r>e.startMs&&(t===void 0||!t.endAuthored||r>t.endMs))return`endsAfter`;if(e.endAuthored&&e.startMs<n&&e.endMs>n&&(t===void 0||n<t.startMs))return`startsInside`}function bn({zoom:e,why:t}){switch(t){case`start`:return D(`That would start it within ${dt}ms of the zoom "${e.id}" at ${xn(e.startMs)}; the camera needs ${dt}ms between two zooms to glide from one to the other.`);case`endsAfter`:return D(`That would end it after the zoom "${e.id}" starts at ${xn(e.startMs)}; a zoom can stay in until the next one, not past it.`);case`startsInside`:return D(`That would start it before the zoom "${e.id}" ends at ${xn(e.endMs)}; drag that zoom's end earlier first.`)}}var xn=e=>{let t=Math.max(0,Math.floor(e/100)),n=Math.floor(t/10);return`${Math.floor(n/60)}:${String(n%60).padStart(2,`0`)}.${t%10}`};function Sn(e){let{leadInMs:t}=S;return{earliestMs:e+t,latestMs:e}}function Cn(e,t){let{leadInMs:n}=S,r=e.zoomDefaultMs-n,i=(t,n)=>{let r=Math.min(...e.zooms.map(e=>e.startMs).filter(e=>e>t));return{kind:`placed`,atMs:t,startMs:t,endMs:Math.min(t+e.zoomDefaultMs,r),movedPast:n}},a=t=>{let{earliestMs:n,latestMs:r}=Sn(t);return e.zooms.find(e=>yn(e,void 0,n,null)!==void 0||yn(e,void 0,r,null)!==void 0)},o=a(t);if(!o)return i(t,null);let s=o;for(let t=0;t<=e.zooms.length&&s;t++){let t=Math.max(s.startMs+dt,s.endAuthored?s.endMs:-1/0)-n;if(t+r+n>e.durationMs)break;let o=a(t);if(!o)return i(t,{zoom:s,side:`after`});s=o}s=o;for(let t=0;t<=e.zooms.length&&s;t++){let e=s.startMs-dt;if(Sn(e).earliestMs<0)break;let t=a(e);if(!t)return i(e,{zoom:s,side:`before`});s=t}return D(`There is no room for a zoom here: it would run into the zoom "${o.id}" at ${xn(o.startMs)}, and there is no slot either side of it. Drag that zoom to make space, or remove one.`)}function wn(e,t){let{trim:n}=e.clip;if(t>n.tailMs-200)return D(`Move the playhead earlier: a mask needs some of the video after it to cover.`);let r=e.clip.ticks.find(e=>e.atMs>t+1)?.atMs??1/0;return{kind:`span`,startMs:t,endMs:Math.min(r,t+pn,e.durationMs)}}function Tn(e,t,n,r){let i=on(e,n,r),a=t.bundle?.markers.find(e=>e.actionId===i.actionId);return i.offsetMs===0||t.resolved===null||a===void 0?{actionId:i.actionId,sourceOffsetMs:i.offsetMs}:{actionId:i.actionId,sourceOffsetMs:Math.round(ge(t.resolved.timeline,n)-a.sourceTimeMs)}}var En=(e,t)=>e.actionId===t.actionId&&t.sourceOffsetMs<=e.sourceOffsetMs;function Dn(e,t){return t!==null&&e.actionId===t.actionId&&t.offsetMs<=e.offsetMs}var On=e=>D(`That would leave the ${e} no length; drag its end further.`),kn=e=>D(`The cut would leave nothing: that puts the ${e} on the same step as the ${e===`head`?`tail`:`head`}. Drag it further away, or move the other end first.`);function An(e,t){let n=e.clip.ticks,r=n.findIndex(e=>e.actionId===t);return r===-1?void 0:n[r+1]}function jn(e,t,n,r){let{durationMs:i}=e;if(e.clip.ticks.length===0)return D(`This video has no steps to attach an edit to.`);switch(n.kind){case`pieceEdge`:return qt(r.bundle,r.resolved?.timeline??null,e.clip.pieces,n.start,n.side,n.deltaMs);case`trim`:{let{trim:t}=e.clip;if(n.edge===`head`){if(n.toMs<=0)return{kind:`setTrim`,head:null};if(n.toMs>t.tailMs-200)return D(`The cut would leave nothing: the head has to stay at least 200ms before the tail.`);let r=on(e,n.toMs,n.snapMs);return Dn(r,t.tailMarker)?kn(`head`):{kind:`setTrim`,head:r}}if(n.toMs>=i)return{kind:`setTrim`,tail:null};if(n.toMs<t.headMs+200)return D(`The cut would leave nothing: the tail has to stay at least 200ms after the head.`);let r=on(e,n.toMs,n.snapMs);return t.headMarker&&Dn(t.headMarker,r)?kn(`tail`):{kind:`setTrim`,tail:r}}case`addZoom`:{let i=Cn(e,n.atMs);if(mn(i))return i;let{atMs:a,movedPast:o}=i,s=on(e,a,o?0:n.snapMs),c=o?`Placed ${o.side} the zoom at ${xn(o.zoom.startMs)}: there was no room at ${xn(n.atMs)}.`:null,l=S.defaultZoomScale,u=hn(r,a);if(`point`in u)return{kind:`addZoom`,marker:s,target:{kind:`point`,x:u.point.x,y:u.point.y},scale:l,...c===null?{}:{note:c}};let d=[...e.clip.ticks].filter(e=>e.canZoom).sort((e,t)=>Math.abs(e.atMs-a)-Math.abs(t.atMs-a))[0],f=d?t.beats.find(e=>e.actionId===d.actionId)?.anchorId:null;if(!d||!f)return D(`There is nothing to aim at here: ${u.reason}, and no step on this video has an element on screen.`);let p={kind:`element`,anchorId:f},m=`Aimed at "${d.label}" instead of the cursor: ${u.reason}.`;return{kind:`addZoom`,marker:s,target:p,scale:l,note:c?`${c} ${m}`:m}}case`moveZoom`:{let t=gn(e,n.id);if(!t)return D(`There is no zoom "${n.id}" to move.`);if(n.deltaMs===0)return null;let r=t.startMs+n.deltaMs,a=t.endMs+n.deltaMs;if(r<0)return D(`A zoom cannot start before the video does.`);if(a>i)return D(`A zoom cannot end after the video does.`);let o=vn(e,t.id,r,t.endAuthored?a:null);if(o)return bn(o);let s=on(e,r,n.snapMs),c=t.endAuthored?on(e,a,n.snapMs):null;return Dn(s,c)?On(`zoom`):{kind:`setZoomRange`,id:t.id,start:s,end:c}}case`zoomEdge`:{let t=gn(e,n.id);if(!t)return D(`There is no zoom "${n.id}" to resize.`);if(n.edge===`start`){let r=Math.max(0,n.toMs);if(r>t.drawnEndMs-100)return D(`A zoom's start cannot cross its end; it would start after the zoom already ends. Drag the end later first.`);let i=r+e.zoomInMs;if(t.endAuthored&&i>t.endMs-100)return D(`Zooming in from there, it would land at ${xn(i)}, after its end at ${xn(t.endMs)}. Drag the end later first.`);let a=vn(e,t.id,i,null);if(a)return bn(a);let o=on(e,r,n.snapMs),s={...o,offsetMs:o.offsetMs+e.zoomInMs},c=t.endMarker;return Dn(s,c)?On(`zoom`):{kind:`setZoomRange`,id:t.id,start:s,end:c}}if(n.toMs>i)return D(`A zoom cannot end after the video does.`);if(n.toMs<t.startMs+100)return D(`A zoom's end cannot cross its start; it would end before it starts. Drag the start earlier first.`);let r=vn(e,t.id,t.startMs,n.toMs);if(r)return bn(r);let a=t.marker,o=on(e,n.toMs,n.snapMs);return Dn(a,o)?On(`zoom`):{kind:`setZoomRange`,id:t.id,start:a,end:o}}case`addMask`:{let t=wn(e,n.atMs);if(mn(t))return t;let{endMs:i}=t,a=hn(r,n.atMs),o=`point`in a?a.point:{x:r.viewport.width/2,y:r.viewport.height/2},s=ln(r.viewport,o),c=Tn(e,r,n.atMs,n.snapMs),l=Tn(e,r,i,n.snapMs);if(En(c,l)){let t=An(e,c.actionId);if(!t)return D(`That would leave the mask no length; move the playhead earlier.`);l={actionId:t.actionId,sourceOffsetMs:0}}return`point`in a?{kind:`addMask`,rect:s,start:c,end:l}:{kind:`addMask`,rect:s,start:c,end:l,note:`Placed at the centre of the frame: ${a.reason}. Drag it into place on the preview.`}}case`moveMask`:{let t=_n(e,n.id);if(!t)return D(`There is no mask "${n.id}" to move.`);if(t.wholeTake||t.startMarker===null||t.endMarker===null)return D(`This mask covers the whole video, so it has no ends to move. Add a new mask to cover a stretch.`);if(n.deltaMs===0)return null;let a=t.startMs+n.deltaMs,o=t.endMs+n.deltaMs;if(a<0)return D(`A mask cannot start before the video does.`);if(o>i)return D(`A mask cannot end after the video does.`);let s=Tn(e,r,a,n.snapMs),c=Tn(e,r,o,n.snapMs);return En(s,c)?On(`mask`):{kind:`setMaskRange`,id:t.id,start:s,end:c}}case`maskEdge`:{let t=_n(e,n.id);if(!t)return D(`There is no mask "${n.id}" to resize.`);if(t.wholeTake||t.startMarker===null||t.endMarker===null)return D(`This mask covers the whole video, so it has no ends to move. Add a new mask to cover a stretch.`);if(n.edge===`start`){if(n.toMs<0)return D(`A mask cannot start before the video does.`);if(n.toMs>t.endMs-100)return D(`A mask cannot start after it ends; drag its end later first.`);let i=Tn(e,r,n.toMs,n.snapMs),a=t.endMarker;return En(i,a)?On(`mask`):{kind:`setMaskRange`,id:t.id,start:i,end:a}}if(n.toMs>i)return D(`A mask cannot end after the video does.`);if(n.toMs<t.startMs+100)return D(`A mask cannot end before it starts; drag its start earlier first.`);let a=t.startMarker,o=Tn(e,r,n.toMs,n.snapMs);return En(a,o)?On(`mask`):{kind:`setMaskRange`,id:t.id,start:a,end:o}}}}function Mn(e,t,n){let r=e.beats.find(e=>e.actionId===t);return r===void 0?D(`There is no step "${t}" to pace.`):r.isLast?D(`"${t}" is the last step, and a pause is the time between two steps. Trim or add a step after it instead.`):Number.isFinite(n)?n<0?D(`A pause cannot be shorter than nothing. Type 0 to cut the dead air here, or use the recorded pause.`):{kind:`setGap`,afterActionId:t,durationMs:n}:D(`A pause has to be a number of milliseconds.`)}function Nn(e){return e.actions.map(e=>e.id).join(` `)}function Pn(e){return{bundle:e.bundle,actionIds:Nn(e.scene)}}function Fn(e,t){return e!==null&&t.bundle===e.bundle&&Nn(t.scene)===e.actionIds&&t.hoverReport!==null}var In={removable:[],checked:0,unchecked:0,failed:!0};function Ln(e){return e.kind!==`unknown`||e.reason!==`notStyleSignalled`}function Rn(e,t){let n=e.filter(Ln).filter(e=>!t.has(e.actionId)),r={};for(let e of n)e.kind===`unknown`&&(r[e.reason]=(r[e.reason]??0)+1);return{removable:n.flatMap(e=>e.kind===`still`?[e.actionId]:[]),checked:n.filter(e=>e.kind!==`unknown`).length,unchecked:n.filter(e=>e.kind===`unknown`).length,uncheckedBy:r,failed:!1}}var zn={notStyleSignalled:{one:`was not a style hover`,many:`were not style hovers`},noMarker:{one:`had no place on the timeline`,many:`had no place on the timeline`},noRect:{one:`had no recorded position`,many:`had no recorded position`},crossFrameRect:{one:`was inside an embedded frame`,many:`were inside an embedded frame`},degenerateRect:{one:`had a zero-size target`,many:`had a zero-size target`},offFrame:{one:`was partly off screen`,many:`were partly off screen`},cropTooSmall:{one:`was too small to compare`,many:`were too small to compare`},nativeCropTooSmall:{one:`was too small in the recorded frames to compare`,many:`were too small in the recorded frames to compare`},sameFrame:{one:`had only one frame around it`,many:`had only one frame around them`},outOfTolerance:{one:`had no frame close enough to the hover`,many:`had no frame close enough to the hover`},decodeFailed:{one:`had a frame that would not decode`,many:`had frames that would not decode`}};function Bn(e){return Object.entries(e.uncheckedBy??{}).filter(([,e])=>e>0).sort((e,t)=>t[1]-e[1]).map(([e,t])=>{let n=zn[e];return`${t} ${t===1?n.one:n.many}`}).join(`, `)}function Vn(e){if(e.failed)return`The hover check could not run, so nothing here has been checked.`;let t=e.removable.length>0?`${e.removable.length} hover ${e.removable.length===1?`move`:`moves`} changed nothing on screen.`:null,n=Bn(e),r=e.checked+e.unchecked,i=e.unchecked>0?`${e.unchecked} of ${r} ${r===1?`hover`:`hovers`} could not be checked${n===``?``:`: ${n}`}.`:null;return t===null&&i===null?null:[t,i].filter(e=>e!==null).join(` `)}function O(e,t){let n=e.actions.findIndex(e=>e.id===t);if(n===-1)throw Error(`unknown action "${t}"`);return n}function Hn(e,t){let n=e.camera.find(e=>e.id===t);if(!n)throw Error(`unknown zoom "${t}"`);return n}var Un=1,Wn=e=>Error(`1:1 is not a zoom — remove the zoom instead of authoring ${e}`);function Gn(e,t,n){switch(t.kind){case`rename`:return{...e,meta:{...e.meta,name:t.name}};case`setTrim`:{let n={...e.edits.trim??{}};for(let r of[`head`,`tail`]){let i=t[r];i!==void 0&&(i===null?delete n[r]:(O(e,i.actionId),n[r]=i))}let r={...e.edits};return n.head===void 0&&n.tail===void 0?delete r.trim:r.trim=n,{...e,edits:r}}case`addZoom`:{if(O(e,t.marker.actionId),t.scale<=1)throw Wn(t.scale);let r=t.target;if(r.kind===`element`&&!e.anchors.some(e=>e.id===r.anchorId))throw Error(`unknown anchor "${r.anchorId}"`);let i=r.kind===`element`&&t.marker.offsetMs===0?S.leadInMs:t.marker.offsetMs,a={id:n(),kind:`zoom`,...r.kind===`element`?{anchorId:r.anchorId}:{point:{x:r.x,y:r.y}},marker:{actionId:t.marker.actionId,offsetMs:i},scale:t.scale,source:`author`,...t.note===void 0?{}:{note:t.note}},{zoomsSkipped:o,...s}=e,c=(o??[]).filter(e=>e.actionId!==t.marker.actionId||e.reason!==`off`);return{...s,camera:[...e.camera,a],...c.length>0?{zoomsSkipped:c}:{}}}case`setZoomRange`:{let n=Hn(e,t.id);O(e,t.start.actionId),t.end&&O(e,t.end.actionId);let{end:r,...i}=n,a=t.end===null?{...i,marker:t.start}:{...i,marker:t.start,end:t.end};return n.source===`click`&&(a.source=`author`),{...e,camera:e.camera.map(e=>e.id===n.id?a:e)}}case`setZoomScale`:{let n=Hn(e,t.id);if(t.scale<=1)throw Wn(t.scale);return{...e,camera:e.camera.map(e=>e.id===n.id?{...e,scale:t.scale,...e.source===`author`?{}:{scaleSetBy:`author`}}:e)}}case`setZoomTarget`:{let n=Hn(e,t.id),{anchorId:r,note:i,...a}=n;return{...e,camera:e.camera.map(e=>e.id===n.id?{...a,point:{x:t.point.x,y:t.point.y},...n.source===`click`?{source:`author`}:{}}:e)}}case`removeZoom`:{let n=Hn(e,t.id),r=e.camera.filter(e=>e.id!==t.id),i=e.actions.find(e=>e.id===n.marker.actionId);return i?.kind!==`click`&&i?.kind!==`drag`||r.some(e=>e.marker.actionId===n.marker.actionId)?{...e,camera:r}:{...e,camera:r,zoomsSkipped:[...(e.zoomsSkipped??[]).filter(e=>e.actionId!==n.marker.actionId),{actionId:n.marker.actionId,reason:`off`}]}}case`addMask`:return O(e,t.start.actionId),O(e,t.end.actionId),{...e,edits:{...e.edits,masks:[...e.edits.masks,{id:n(),rect:t.rect,start:t.start,end:t.end,...t.note===void 0?{}:{note:t.note}}]}};case`setMaskRange`:if(O(e,t.start.actionId),O(e,t.end.actionId),!e.edits.masks.some(e=>e.id===t.id))throw Error(`unknown mask "${t.id}"`);return{...e,edits:{...e.edits,masks:e.edits.masks.map(e=>e.id===t.id?{...e,start:t.start,end:t.end}:e)}};case`moveMask`:if(!e.edits.masks.some(e=>e.id===t.id))throw Error(`unknown mask "${t.id}"`);if(t.rect.width<Un||t.rect.height<Un)throw Error(`That drag left the mask off the frame — nothing would be covered. Drag it back over the picture.`);return{...e,edits:{...e.edits,masks:e.edits.masks.map(e=>e.id===t.id?{...e,rect:t.rect}:e)}};case`setMaskNote`:return{...e,edits:{...e.edits,masks:e.edits.masks.map(e=>{if(e.id!==t.id)return e;let{note:n,...r}=e;return t.note===``?r:{...r,note:t.note}})}};case`removeMask`:return{...e,edits:{...e.edits,masks:e.edits.masks.filter(e=>e.id!==t.id)}};case`setBranding`:return{...e,branding:Je(e.branding,t.patch)};case`setCursor`:return{...e,cursor:{...e.cursor,...t.patch}};case`setMotion`:return{...e,motion:{...e.motion??ie,...t.patch}};case`setAspect`:return{...e,canvas:{...e.canvas,aspect:t.aspect}};case`split`:return O(e,t.at.actionId),{...e,edits:{...e.edits,splits:[...e.edits.splits??[],{id:n(),at:t.at}]}};case`removePiece`:if(t.start===null&&t.end===null)throw Error(`Removing the whole video would leave nothing to export.`);return t.start&&O(e,t.start.actionId),t.end&&O(e,t.end.actionId),{...e,edits:{...e.edits,removed:[...e.edits.removed??[],{id:n(),start:t.start,end:t.end}]}};case`restorePiece`:{let n=e.edits.removed??[];if(!n.some(e=>e.id===t.id))throw Error(`there is no removed piece "${t.id}" to restore`);return{...e,edits:{...e.edits,removed:n.filter(e=>e.id!==t.id)}}}case`setRemovedEdge`:{let n=e.edits.removed??[],r=n.find(e=>e.id===t.id);if(r===void 0)throw Error(`there is no removed piece "${t.id}" to move`);t.start&&O(e,t.start.actionId),t.end&&O(e,t.end.actionId);let i={...r,...t.start===void 0?{}:{start:t.start},...t.end===void 0?{}:{end:t.end}};if(i.start===null&&i.end===null)throw Error(`Removing the whole video would leave nothing to export.`);return{...e,edits:{...e.edits,removed:n.map(e=>e.id===t.id?i:e)}}}case`setGap`:{if(O(e,t.afterActionId)===e.actions.length-1)throw Error(`there is no step after "${t.afterActionId}" — a gap is the time between two steps, so the last step cannot carry one`);let r=e.edits.gaps??[],i=r.find(e=>e.afterActionId===t.afterActionId),a={id:i?.id??n(),afterActionId:t.afterActionId,durationMs:t.durationMs};return{...e,edits:{...e.edits,gaps:i?r.map(e=>e.id===i.id?a:e):[...r,a]}}}case`clearGap`:return{...e,edits:{...e.edits,gaps:(e.edits.gaps??[]).filter(e=>e.afterActionId!==t.afterActionId)}}}}function Kn(e,t,n){let r=Gn(e,t,n);return ye.parse(Jn.has(t.kind)||qn(e,r)?Yn(r):r)}function qn(e,t){return(e.motion??ie).smoothness!==(t.motion??ie).smoothness}var Jn=new Set([`addZoom`,`setZoomRange`,`removeZoom`]);function Yn(e){return{...e,camera:e.camera.map(({arrives:e,...t})=>t)}}function Xn(e){if(e.length<4)return null;let t=e.slice(-30).sort((e,t)=>e-t);return t[Math.min(t.length-1,Math.max(0,Math.ceil(.8*t.length)-1))]??null}function Zn(e){let{target:t,paintedCssWidth:n,devicePixelRatio:r,playing:i}=e,a=Math.min(t.height,720);if(!Number.isFinite(n)||n<=0)return a;let o=n*r,s=Math.round(o*t.height/t.width),c=Math.max(a,Math.min(t.height,s));if(!i)return c;let l=e.msPerMegapixel;if(l==null||!Number.isFinite(l)||l<0)return a;let u=t.width/t.height,d=Math.sqrt((e.budgetMs??11)/l*1e6/u);if(d>=c)return c;let f=Math.floor(d/90)*90;return Math.min(c,Math.max(a,f))}function Qn(e,t=720){let n=t/e.height;return{...e,format:`png`,fps:0,bitrate:0,width:Math.round(e.width*n),height:t,cornerRadius:Math.max(4,Math.round(e.cornerRadius*n))}}function $n(e){let{bitmap:t,parkedHeight:n}=e;if(!t)return``;let r=e.msPerMegapixel==null?`cost not measured yet`:`${e.msPerMegapixel.toFixed(1)}ms/megapixel`,i=n!=null&&t.height>=n,a=n==null?``:i?` (full resolution)`:`, parked ${n}`;return` | played ${t.width}x${t.height}${a}, ${r}`}function er(e){let{requestedFrames:t,drawnFrames:n,elapsedMs:r,sourceLookupMs:i,composeMs:a,blitMs:o}=e;if(n<=0)return`[demoman] preview: no frames drawn in ${Math.round(r)}ms, ${t} asked for`;let s=r/1e3,c=e=>s>0?`${(e/s).toFixed(1)}`:`n/a`,l=e=>(e/n).toFixed(1),u=(100*n/Math.max(1,t)).toFixed(0),d=e.sourceFrame?`, stills ${e.sourceFrame.width}x${e.sourceFrame.height}`:``,f=$n(e),p=e.decodeMs===void 0?``:` (decode ${l(e.decodeMs)}ms)`,m=i/n>=.05?`, source ${l(i)}ms`:``;return`[demoman] preview: ${c(n)} fps drawn, ${c(t)} asked (${u}% kept) — per drawn frame: compose ${l(a)}ms${p}, blit ${l(o)}ms${m}${d}${f}`}function tr(e){let{draw:t,schedule:n,onDrawFailed:r,onDrawRecovered:i}=e,a=null,o=!1,s=!1,c=Promise.resolve(),l=()=>{if(s||o||a===null)return;let e=a;a=null,o=!0,c=t(e).then(()=>{i?.()}).catch(e=>{r?.(e)}).then(()=>{o=!1,a!==null&&n(l)})};return{seek(e){s||(a=e,n(l))},async idle(){for(;o||a!==null;)await c},dispose(){s=!0,a=null}}}function nr(e){let{seek:t,durationMs:n,now:r,schedule:i,onChange:a}=e,o=e.startMs??(()=>0),s=e.looping??(()=>!1),c=0,l=!1,u=!1,d=0,f=0,p=1,m=()=>a?.(),h=e=>{c=e,t(e)},g=e=>{c=e,y(),h(e),m(),i(v)},_=e=>s()&&e>o(),v=()=>{if(u||!l)return;let e=n(),t=d+(r()-f)*p;if(t>=e){if(_(e)){g(o());return}l=!1,p=1,h(e),m();return}if(p<0&&t<=o()){if(_(e)){g(e);return}l=!1,p=1,h(o()),m();return}h(t),m(),i(v)},y=()=>{d=c,f=r()};return{play(){if(u||l)return;let e=n();e<=0||((c>=e||c<o())&&(c=o()),p=1,y(),l=!0,h(c),m(),i(v))},pause(){u||!l||(l=!1,p=1,m())},shuttle(e){if(u)return;let t=n();t<=0||(p=l&&Math.sign(p)===e?e*Math.min(4,Math.abs(p)*2):e,e>0&&c>=t&&(c=o()),e<0&&c<=o()&&(c=t),y(),l=!0,h(c),m(),i(v))},stop(){u||(p=1,l&&(l=!1,m()))},toggle(){l?this.pause():this.play()},seek(e){if(u)return;let t=Math.min(Math.max(e,o()),n());c=t,y(),h(t),m()},get playing(){return l},get rate(){return p},get positionMs(){return c},dispose(){u=!0,l=!1}}}function rr(e){let t=Math.max(0,Math.floor(e/1e3)),n=t%60;return`${Math.floor(t/60)}:${String(n).padStart(2,`0`)}`}function ir(e){let t=null,n=null;return r=>((t===null||r!==n)&&(n=r,t=e(r).catch(e=>{throw t=null,n=null,e})),t)}function ar(e,t){let{cursor:n,branding:r,motion:i}=t;if(n===e.cursor&&r===e.branding&&i===e.motion)return e;let a={...e,cursor:n,branding:r,...i===void 0?{}:{motion:i}};return qn(e,a)?Yn(a):a}function or(e,t){return e===null||[...new Set([...Object.keys(t),...Object.keys(e)])].some(n=>t[n]!==e[n])}function sr(e,t){return e===null||e.smoothness!==t.smoothness||e.blur!==t.blur||e.follow!==t.follow}function cr(e,t){if(e===null)return!0;let n=(e,t)=>e===t||e!==void 0&&t!==void 0&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,r=e.background,i=t.background;return!nt(r,i)||e.cornerRadius!==t.cornerRadius||!n(e.frameRect,t.frameRect)||e.logo?.image!==t.logo?.image||e.wallpaper?.image!==t.wallpaper?.image||e.logo?.opacity!==t.logo?.opacity||!n(e.logo?.rect,t.logo?.rect)}function lr(e){let t=e instanceof Error?e.message:String(e),n=/[.!?]$/.test(t)?t:`${t}.`,r=typeof e==`object`&&e?e:{};return{text:`Not shown: ${n}`,expected:r.reason===`revealRefused`&&r.status===404}}function ur(){let e=new Map;return{isOpen:(t,n)=>e.get(t)??n,set:(t,n)=>{e.set(t,n)}}}var dr={anchorNotRendered:!0,anchorUnreachable:!0,cancelledByAuthor:!0,pageSilent:!0,pageFaulted:!0,clickNotDelivered:!0,mutating:!1,dragEndOutOfView:!1,dragNoDistance:!1,redactedWithoutReplacement:!1,unresolvedAnchor:!1,ambiguousAnchor:!1,anchorFrameMismatch:!1,pageWentElsewhere:!1,signedOut:!1,unperformableStep:!1,waitTimeout:!1,occlusionTimeout:!1,debuggerUnavailable:!1,windowClosed:!1,portFailure:!1,deviceFailed:!1,noActions:!1};function fr(e){return e===null||e.reason===null?!1:dr[e.reason]===!0}function pr(e,t,n){if(e===null||e.reason===null||!t.mayReplay||e.reason===`mutating`)return null;let r=yt(e.reason),i=n!==void 0&&Ct(n),a=i?`The script run`:`The re-shoot`,o=i?`performed`:`reconstructed`,s=n?St(n,e):null,c=s?` Stopped at step ${s.number}, ${s.kind} ${s.label}.`:``;if(e.reason===`noActions`)return`${a} never started: ${r}.`;if(e.outcome===`complete`)return e.reason===`portFailure`?`${a} ${o} all ${e.total} steps but could not save the frames: ${r}. Nothing from it reached the store, so this page still shows the frames from before it ran — free some space and ${wt(i)} to try again.`:`${a} ${o} all ${e.total} steps, but: ${r}.`;let l=fr(e)?`and stopped early`:`then stopped`;return`${a} ${o} ${e.completed} of ${e.total} steps ${l}: ${r}.${c}`}function mr(e){return{scene:e,past:[],future:[],error:null,dirty:!1,hoverReport:null}}function hr(e,t,n){let r;try{r=Kn(e.scene,t,n)}catch(t){return{...e,error:t instanceof Error?t.message:String(t)}}return t.kind===`setBranding`&&at(e.scene.branding,r.branding)?{...e,error:null}:{scene:r,past:[...e.past,e.scene].slice(-50),future:[],error:null,dirty:!0,hoverReport:t.kind===`removePiece`||t.kind===`restorePiece`||t.kind===`setRemovedEdge`?null:e.hoverReport}}function gr(e){let t=e.past[e.past.length-1];return t?{...e,scene:t,past:e.past.slice(0,-1),future:[e.scene,...e.future],error:null,dirty:!0,hoverReport:null}:e}function _r(e){let[t,...n]=e.future;return t?{...e,scene:t,past:[...e.past,e.scene].slice(-50),future:n,error:null,dirty:!0,hoverReport:null}:e}function vr(e){return{...e,dirty:!1}}var yr={mayReplay:!0};function br(e){let{renderMode:t,...n}=e.meta,r={...e,meta:n,flags:{...e.flags,hoverSensitive:!1}};return JSON.stringify(r,(e,t)=>typeof t==`object`&&t&&!Array.isArray(t)?Object.fromEntries(Object.entries(t).sort(([e],[t])=>e<t?-1:+(e>t))):t)}function xr(e,t){return e.meta===void 0||e.flags===void 0?!1:br(e)===br(t)}function Sr(e,t){let n=(e,t,r)=>{if(JSON.stringify(e)===JSON.stringify(t))return null;if(e!==null&&t!==null&&typeof e==`object`&&typeof t==`object`){let i=new Set([...Object.keys(e),...Object.keys(t)]);for(let a of[...i].sort()){let i=n(e[a],t[a],`${r}.${a}`);if(i!==null)return i}}let i=e=>JSON.stringify(e)?.slice(0,80)??`undefined`;return`${r}: ${i(e)} -> ${i(t)}`};return n(JSON.parse(br(e)),JSON.parse(br(t)),`scene`)}function Cr(e,t){let{renderMode:n,...r}=e.meta;return{...e,meta:t.meta.renderMode===void 0?r:{...r,renderMode:t.meta.renderMode}}}function wr(e,t){return{...Cr(e,t),flags:{...e.flags,hoverSensitive:t.flags.hoverSensitive}}}function Tr(e){let t=mr({}),n=null,r=null,i=null,a=new Set,o=Promise.resolve(),s=e=>{let t=o.then(e,e);return o=t.catch(()=>{}),t},c=()=>({scene:t.scene,bundle:n,madeFrom:n?.madeFrom??null,replaySentence:pr(i,yr,t.scene),replayRecoverable:fr(i),error:t.error,canUndo:t.past.length>0,canRedo:t.future.length>0,hoverReport:t.hoverReport}),l=()=>{let e=c();for(let t of a)t(e)},u=async t=>{let n=await e.loadScene(e.sceneId),i=n.flags.hoverSensitive&&!t.flags.hoverSensitive?{...t,flags:{...t.flags,hoverSensitive:!0}}:t;return r!==null&&t.meta.name===r&&n.meta.name!==r&&(i={...i,meta:{...i.meta,name:n.meta.name}}),i=Cr(i,n),await e.saveScene(i),r=i.meta.name,i};return{load:()=>s(async()=>{let a=await e.loadScene(e.sceneId),o=await e.bundles.active(e.sceneId);n=o.bundle,i=o.replay;let s=xr(t.scene,a);!s&&(t.past.length>0||t.future.length>0)&&console.info(`[demoman] editor: undo history cleared on re-read — the document changed at ${Sr(t.scene,a)}`),t=s?{...mr(a),past:t.past.map(e=>wr(e,a)),future:t.future.map(e=>wr(e,a))}:mr(a),r=a.meta.name,l()}),snapshot:c,subscribe(e){return a.add(e),()=>a.delete(e)},async dispatch(n){await s(async()=>{let r=t,i=hr(t,n,e.newId);if(i.scene===r.scene){t=i,l();return}t=i;try{t={...t,scene:await u(t.scene)}}catch(e){t={...r,error:e instanceof Error?e.message:String(e)},l();return}t=vr(t),l()})},async undo(){await s(async()=>{let e=gr(t);if(e.scene===t.scene)return;let n=t;t=e;try{t={...t,scene:await u(t.scene)}}catch(e){t={...n,error:e instanceof Error?e.message:String(e)},l();return}t=vr(t),l()})},async redo(){await s(async()=>{let e=_r(t);if(e.scene===t.scene)return;let n=t;t=e;try{t={...t,scene:await u(t.scene)}}catch(e){t={...n,error:e instanceof Error?e.message:String(e)},l();return}t=vr(t),l()})},async settled(){let e;do e=o,await e;while(e!==o)},setHoverReport(e){t={...t,hoverReport:e},l()}}}var Er=1.2;function Dr(e,t){let n=e.key,r=n.toLowerCase();if(e.metaKey||e.ctrlKey)return r===`z`?e.shiftKey?t.canRedo?{kind:`redo`}:null:t.canUndo?{kind:`undo`}:null:r===`y`&&e.ctrlKey&&!e.metaKey?t.canRedo?{kind:`redo`}:null:r===`b`&&!e.shiftKey?{kind:`split`}:!e.shiftKey&&(n===`ArrowLeft`||n===`ArrowRight`)?{kind:`seekEdge`,edge:n===`ArrowLeft`?`head`:`tail`}:null;if(n===` `)return{kind:`playPause`};if(r===`j`)return{kind:`shuttle`,direction:-1};if(r===`k`)return{kind:`stop`};if(r===`l`)return{kind:`shuttle`,direction:1};if(n===`ArrowRight`||n===`ArrowLeft`){let t=e.shiftKey?500:100;return{kind:`nudge`,deltaMs:n===`ArrowRight`?t:-t}}return n===`ArrowDown`?{kind:`stepBeat`,delta:1}:n===`ArrowUp`?{kind:`stepBeat`,delta:-1}:n===`Home`?{kind:`seekEdge`,edge:`head`}:n===`End`?{kind:`seekEdge`,edge:`tail`}:r===`i`?{kind:`setTrim`,edge:`head`}:r===`o`?{kind:`setTrim`,edge:`tail`}:n===`Delete`||n===`Backspace`?t.hasSelection?{kind:`deleteSelection`}:null:n===`+`||n===`=`?t.hasTimeline?{kind:`zoomTimeline`,factor:Er}:null:n===`-`||n===`_`?t.hasTimeline?{kind:`zoomTimeline`,factor:1/Er}:null:r===`z`&&e.shiftKey?t.hasTimeline?{kind:`zoomFit`}:null:r===`s`?{kind:`toggleSnapping`}:n===`Escape`?t.hasSelection?{kind:`clearSelection`}:t.panelOpen?{kind:`closePanel`}:null:n===`?`?{kind:`toggleHelp`}:null}var Or={Mod:{label:{mac:`⌘`,other:`Ctrl`},spoken:{mac:`Command`,other:`Control`}},Shift:{label:{mac:`⇧`,other:`Shift`},spoken:`Shift`},Space:{label:`Space`,spoken:`Space`},Esc:{label:`Esc`,spoken:`Escape`},Delete:{label:{mac:`⌫`,other:`Delete`},spoken:`Delete`},Home:{label:`Home`,spoken:`Home`},End:{label:`End`,spoken:`End`},Left:{label:`←`,spoken:`Left arrow`},Right:{label:`→`,spoken:`Right arrow`},Up:{label:`↑`,spoken:`Up arrow`},Down:{label:`↓`,spoken:`Down arrow`}},kr=(e,t)=>typeof e==`string`?e:t?e.mac:e.other;function Ar(e,t){let n=Or[e];return n===void 0?e:kr(n.label,t)}var jr=new Set([`⌘`,`⇧`,`⌫`,`←`,`→`,`↑`,`↓`]);function Mr(e){return jr.has(e)}function Nr(e,t){let n=Or[e];return n===void 0?e:kr(n.spoken,t)}function Pr(e,t){return e.map(e=>Nr(e,t)).join(` plus `)}function Fr(e){return/\bMac/i.test(e)}function Ir(e,t){return kr(e.description,t)}var Lr=[{group:`Playback`,combos:[[`Space`]],description:`Play / pause`,action:`playPause`},{group:`Playback`,combos:[[`J`],[`L`]],description:`Shuttle back / forward`,action:`shuttle`},{group:`Playback`,combos:[[`K`]],description:`Stop`,action:`stop`},{group:`Playback`,combos:[[`Left`],[`Right`]],description:`Nudge playhead`,action:`nudge`},{group:`Playback`,combos:[[`Shift`,`Left`],[`Shift`,`Right`]],description:`Nudge half a second`,action:`nudge`},{group:`Playback`,combos:[[`Mod`,`Left`],[`Mod`,`Right`]],description:`Jump to start / end`,action:`seekEdge`},{group:`Steps`,combos:[[`Up`],[`Down`]],description:`Previous / next step`,action:`stepBeat`},{group:`Steps`,combos:[[`Esc`]],description:`Clear selection`,action:`clearSelection`},{group:`Trim`,combos:[[`I`],[`O`]],description:`Trim start / end to playhead`,action:`setTrim`},{group:`Editing`,combos:[[`Mod`,`B`]],description:`Split at playhead`,action:`split`},{group:`Editing`,combos:[[`Delete`]],description:`Delete the selected piece or zoom`,action:`deleteSelection`},{group:`Editing`,combos:[[`Mod`,`Z`]],description:`Undo`,action:`undo`},{group:`Editing`,combos:[[`Shift`,`Mod`,`Z`]],description:{mac:`Redo`,other:`Redo — or Ctrl+Y`},action:`redo`},{group:`Timeline`,combos:[[`+`],[`−`]],description:`Zoom in / out`,action:`zoomTimeline`},{group:`Timeline`,combos:[[`Shift`,`Z`]],description:`Fit the whole video`,action:`zoomFit`},{group:`Timeline`,combos:[[`S`]],description:`Snapping on / off`,action:`toggleSnapping`},{group:`Panels`,combos:[[`?`]],description:`Show shortcuts`,action:`toggleHelp`},{group:`Panels`,combos:[[`Esc`]],description:`Close the panel`,action:`closePanel`}];function Rr(e){let t=e.getBoundingClientRect(),n=Math.min(t.width/e.width,t.height/e.height);return{left:(t.width-e.width*n)/2,top:(t.height-e.height*n)/2,scale:n}}var zr=[`nw`,`n`,`ne`,`e`,`se`,`s`,`sw`,`w`],Br=3;function Vr(e,t,n){e.style.left=`${n.left+t.x*n.scale}px`,e.style.top=`${n.top+t.y*n.scale}px`,e.style.width=`${t.width*n.scale}px`,e.style.height=`${t.height*n.scale}px`}function Hr(e,t,n,r){let{x:i,y:a,width:o,height:s}=e;return t===`body`?{x:i+n,y:a+r,width:o,height:s}:(t.includes(`w`)&&(i+=n,o-=n),t.includes(`e`)&&(o+=n),t.includes(`n`)&&(a+=r,s-=r),t.includes(`s`)&&(s+=r),o<0&&(i+=o,o=-o),s<0&&(a+=s,s=-s),{x:i,y:a,width:o,height:s})}function Ur(e,t,n){e.replaceChildren();let{selection:r,resolved:i,presentation:a}=t;if(r===null||r.kind===`tick`||i===null||a===null)return;let o=Rr(t.canvas),s={resolved:i,target:t.target,presentation:a,outputTimeMs:t.outputTimeMs};if(r.kind===`mask`){let i=t.model.masks.find(e=>e.id===r.id);if(!i)return;let a=w(`div`,`overlay`);a.setAttribute(`data-overlay`,`mask`);let c=un({rect:i.rect,...s});Vr(a,c,o);let l=(e,t)=>{e.addEventListener(`pointerdown`,e=>{e.preventDefault(),e.stopPropagation();let r=c,l=!1,u=n=>{Math.hypot(n.clientX-e.clientX,n.clientY-e.clientY)>Br&&(l=!0),c=Hr(r,t,(n.clientX-e.clientX)/o.scale,(n.clientY-e.clientY)/o.scale),Vr(a,c,o)},d=()=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),l&&n.onMaskRect(i.id,dn({rect:c,...s}))};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d)})};l(a,`body`);for(let e of zr){let t=w(`div`,`grip`);t.setAttribute(`data-handle`,e),l(t,e),a.append(t)}e.append(a);return}if(r.kind!==`zoom`)return;let c=t.model.zooms.find(e=>e.id===r.id);if(!c)return;let l=w(`div`,`overlay`);l.setAttribute(`data-overlay`,`zoom`);let u=un({rect:fn({zoom:c,resolved:i,viewport:i.plan.viewport,presentation:a,target:t.target}),...s});Vr(l,u,o),l.addEventListener(`pointerdown`,e=>{e.preventDefault();let t=u,r=!1,i=n=>{Math.hypot(n.clientX-e.clientX,n.clientY-e.clientY)>Br&&(r=!0),u=Hr(t,`body`,(n.clientX-e.clientX)/o.scale,(n.clientY-e.clientY)/o.scale),Vr(l,u,o)},a=()=>{if(window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,a),!r)return;let e=dn({rect:u,...s});n.onZoomPoint(c.id,{x:e.x+e.width/2,y:e.y+e.height/2})};window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,a)}),e.append(l)}function Wr(e){let{scene:t,resolved:n,bundle:r=null}=e,i=new Map(t.anchors.map(e=>[e.id,e])),a=new Map(n?n.plan.cameraIntents.map(e=>[e.actionId,{id:e.id,scale:e.scale,offsetMs:e.offsetMs}]):t.camera.map(e=>[e.marker.actionId,{id:e.id,scale:e.scale??S.defaultZoomScale,offsetMs:e.marker.offsetMs}])),o=new Map((t.edits.gaps??[]).map(e=>[e.afterActionId,e])),s=new Map((t.edits.holds??[]).map(e=>[e.marker.actionId,e])),c=n?new Set(n.plan.removedSteps??[]):le(t),l=new Map((r?.markers??[]).map(e=>[e.actionId,e.sourceTimeMs])),u=(e,t)=>{if(n===null||r===null||!h(r)||xe(r,e.id))return!0;let i=l.get(e.id),a=l.get(t.id);return i===void 0||a===void 0||n.timeline.segments.some(e=>e.kind===`idle`&&e.srcEndMs>e.srcStartMs&&i<=e.srcStartMs&&e.srcEndMs<=a)},d=e=>{if(n===null)return 0;let t=0;for(let r of n.timeline.segments)r.kind===`pace`&&(Math.abs(r.srcStartMs-e)>1e-6||(t+=r.outEndMs-r.outStartMs));return t},f=(e,t)=>{if(t===void 0)return 0;if(n===null||r===null)return null;let i=l.get(e.id),a=l.get(t.id);if(i===void 0||a===void 0)return null;let o=d(a);for(let e of n.timeline.segments)e.kind===`idle`&&i<=e.srcStartMs&&e.srcEndMs<=a&&(o+=e.outEndMs-e.outStartMs);return o},p=(e,t)=>{if(t===void 0||n===null||r===null||h(r))return null;let i=l.get(t.id);return l.get(e.id)===void 0||i===void 0?null:d(i)},m=t.actions.length-1;return{beats:t.actions.map((e,g)=>{let _=e.anchorId?i.get(e.anchorId):void 0,v=a.get(e.id),y=o.get(e.id),ee=s.get(e.id),b=t.actions[g+1],x=l.get(e.id);return{actionId:e.id,index:g,verb:e.kind,anchorId:e.anchorId,label:bt(_),text:e.kind===`type`?e.text:null,redacted:e.kind===`type`&&e.redacted,host:e.kind===`type`&&e.host===!0,strategy:_?.resolution.strategy??null,outputMs:n?fe(n.timeline,x??e.timestamp):null,timing:x===void 0?`estimated`:`rendered`,captureMs:e.timestamp,camera:v??null,canZoom:e.anchorId!==null,gap:y?{durationMs:y.durationMs}:null,canPace:b!==void 0&&u(e,b),renderedPauseMs:f(e,b),renderedPaceFreezeMs:p(e,b),renderedFreezeBeforeMs:r!==null&&!h(r)&&x!==void 0&&n!==null&&x<n.timeline.sourceDurationMs?d(x):0,legacyHold:ee?{offsetMs:ee.marker.offsetMs,durationMs:ee.durationMs}:null,cut:c.has(e.id),isLast:g===m}}),outputDurationMs:n?.timeline.outputDurationMs??null,hasBundle:n!==null}}var Gr=(e,t,n)=>Math.min(n,Math.max(t,e)),Kr=e=>({startMs:0,endMs:Math.max(250,e)}),k=(e,t)=>(t-e.startMs)/(e.endMs-e.startMs),qr=(e,t)=>e.startMs+t*(e.endMs-e.startMs);function Jr(e,t,n,r){let i=Math.max(250,r),a=Gr(n,250,i),o=Gr(e-t*a,0,i-a);return{startMs:o,endMs:o+a}}function Yr(e,t,n,r){return Jr(qr(e,r),r,(e.endMs-e.startMs)/n,t)}function Xr(e,t,n){let r=e.endMs-e.startMs;return Jr(e.startMs+n,0,r,t)}var Zr=(e,t,n,r)=>Jr(qr(e,r),r,n,t);function Qr(e,t){let n=Math.max(250,e);return n*(250/n)**Gr(t,0,1)}function $r(e,t){let n=Math.max(250,e);if(n<=250)return 0;let r=Gr(t,250,n);return Math.log(r/n)/Math.log(250/n)}function ei(e,t){switch(e){case`Mod`:return t?`Meta`:`Control`;case`Esc`:return`Escape`;case`Left`:return`ArrowLeft`;case`Right`:return`ArrowRight`;case`Up`:return`ArrowUp`;case`Down`:return`ArrowDown`;case`−`:return`-`;default:return e}}function ti(e,t,n=[]){if(e.dataset.tip=t,e.removeAttribute(`title`),n.length===0){delete e.dataset.tipKeys,e.removeAttribute(`aria-keyshortcuts`);return}e.dataset.tipKeys=n.join(` `);let r=Fr(navigator.userAgent);e.setAttribute(`aria-keyshortcuts`,n.map(e=>ei(e,r)).join(`+`))}function ni(e){delete e.dataset.tip,delete e.dataset.tipKeys,e.removeAttribute(`aria-keyshortcuts`)}var ri=Symbol.for(`demoman.tooltip`);function ii(e=document){let t=e,n=t[ri];n?.abort.abort(),n?.tip.remove();let r=new AbortController,{signal:i}=r,a=e.createElement(`div`);a.className=`tooltip`,a.setAttribute(`role`,`tooltip`),a.setAttribute(`data-tooltip`,``),a.hidden=!0,e.body.append(a),t[ri]={abort:r,tip:a};let o=e.defaultView??window,s=null,c=null,l=null,u=0,d=e=>e instanceof Element?e.closest(`[data-tip]`):null,f=()=>{s!==null&&clearTimeout(s),s=null,c=null},p=t=>{f();let n=t.dataset.tip??``;if(n===``||!t.isConnected)return;let r=Fr(o.navigator.userAgent),i=(t.dataset.tipKeys??``).split(` `).filter(e=>e!==``);if(a.replaceChildren(e.createTextNode(n)),i.length>0){let t=e.createElement(`span`);t.className=`tooltip-keys`;for(let n of i){let i=Ar(n,r),a=e.createElement(`kbd`);a.className=`keycap`,a.textContent=i,Mr(i)&&a.setAttribute(`data-symbol`,``),t.append(a)}a.append(t)}a.hidden=!1,l=t;let s=t.getBoundingClientRect(),c=a.getBoundingClientRect(),u=Math.min(Math.max(8,s.left+s.width/2-c.width/2),o.innerWidth-c.width-8),d=s.bottom+6,p=d+c.height>o.innerHeight-8?s.top-6-c.height:d;a.style.left=`${Math.round(u)}px`,a.style.top=`${Math.round(p)}px`},m=e=>{f(),!a.hidden&&e&&(u=Date.now()+500),e||(u=0),a.hidden=!0,l=null};return e.addEventListener(`pointerover`,e=>{if(e.pointerType===`touch`)return;let t=d(e.target);if(t===null){(l!==null||c!==null)&&m(!0);return}t!==l&&t!==c&&(f(),l!==null||Date.now()<u?p(t):(c=t,s=setTimeout(()=>p(t),600)))},{signal:i}),e.addEventListener(`pointerout`,e=>{let t=d(e.target);if(t===null)return;let n=e.relatedTarget;n instanceof Node&&t.contains(n)||m(!0)},{signal:i}),e.addEventListener(`pointerdown`,()=>m(!1),{capture:!0,signal:i}),e.addEventListener(`keydown`,e=>{e.key!==`Tab`&&m(!1)},{capture:!0,signal:i}),e.addEventListener(`scroll`,()=>m(!1),{capture:!0,passive:!0,signal:i}),e.addEventListener(`focusin`,e=>{let t=d(e.target);t?.matches(`:focus-visible`)&&p(t)},{signal:i}),e.addEventListener(`focusout`,e=>{l!==null&&d(e.target)===l&&m(!1)},{signal:i}),a}function ai(){let e=w(`div`,`demo-panel`);e.setAttribute(`data-export-panel`,``),e.append(w(`h2`,void 0,`Export`));let t=w(`div`);return t.setAttribute(`data-panel-export`,``),e.append(t),e}function oi(){let e=w(`div`,`demo-panel`);e.setAttribute(`data-background-panel`,``),e.append(w(`h2`,void 0,`Background`));let t=w(`div`);return t.setAttribute(`data-panel-branding`,``),e.append(t),e}function si(){let e=w(`div`,`demo-panel`);e.setAttribute(`data-shortcuts-panel`,``),e.append(w(`h2`,void 0,`Keyboard shortcuts`));let t=w(`div`);return t.setAttribute(`data-panel-shortcuts`,``),e.append(t),e}function ci(){let e=w(`div`,`demo-panel`);e.setAttribute(`data-cursor-panel`,``),e.append(w(`h2`,void 0,`Cursor`));let t=w(`div`);return t.setAttribute(`data-panel-cursor`,``),e.append(t),e}function li(e,t,n){let r=w(`div`,`beat-panel`);r.setAttribute(`data-step-panel`,e.actionId);let i=w(`h2`);if(i.append(w(`span`,`verb`,e.verb),` `,e.label),e.strategy){let t=w(`span`,`chip`,e.strategy);t.setAttribute(`data-health`,e.strategy),i.append(` `,t)}r.append(i);let a=w(`div`);if(e.verb===`type`){if(e.redacted)a.append(w(`div`,`redacted`,e.host?`This was typed into an editor, and an edit the sensor does not follow landed mid-field, so the text is unknown.`:`This value was never recorded — a credential field, or text that looked like a secret.`));else{let t=w(`div`,`control-row`),n=w(`span`,void 0,e.text??``);n.setAttribute(`data-typed-text`,e.actionId),t.append(w(`span`,`control-label`,`Typed text`),n),a.append(t)}}e.timing===`estimated`&&a.append(w(`div`,`muted`,`Not in the video: the frames have no marker for this step, so the timeline places it from the video's own timestamp.`)),a.hasChildNodes()&&r.append(a);let o=w(`div`,`control-actions`);if(!e.canZoom)o.append(w(`span`,`muted`,`No zoom — nothing on screen to aim at`));else{let t=w(`button`,`btn btn-quiet`,`Zoom on this step`);t.type=`button`,t.setAttribute(`data-zoom-on-step`,e.actionId),t.addEventListener(`click`,()=>n.onZoomOnStep(e.actionId)),o.append(t)}r.append(o);let s=()=>{let t=w(`button`,`btn btn-quiet`,`Use recorded`);return t.type=`button`,t.setAttribute(`data-gap-clear`,e.actionId),t.setAttribute(`aria-label`,`Restore the recorded pause after ${e.label}`),t.addEventListener(`click`,()=>n.onGapClear(e.actionId)),t},c=e.isLast?`This is the last step, and a pause is the time between two steps.`:e.canPace?null:`This step runs straight into the next one, with no dead air between them to stretch.`;if(c===null){let t=w(`label`,`control-row`),i=w(`input`);i.type=`number`,i.min=`0`,i.step=`100`,i.value=e.gap===null?``:String(e.gap.durationMs),i.placeholder=`recorded`,i.setAttribute(`data-gap`,e.actionId),i.setAttribute(`aria-label`,`Pause after ${e.label}, in milliseconds. Empty plays back the recorded pause.`),i.addEventListener(`change`,()=>{let t=i.value.trim();t===``?n.onGapClear(e.actionId):n.onGap(e.actionId,Number(t))});let a=w(`span`,`control-inline`);if(a.append(i,w(`span`,void 0,`ms`)),e.gap!==null&&a.append(s()),t.append(w(`span`,`control-label`,`Pause after this step`),a),r.append(t),e.gap!==null&&e.gap.durationMs>0&&e.renderedPaceFreezeMs===0){let t=w(`div`);t.setAttribute(`data-gap-floored`,e.actionId),t.append(w(`span`,void 0,`A ${e.gap.durationMs}ms pause is set here, but the re-shot frames already leave at least that long between these two steps, so it adds nothing to this video. Pacing only ever adds time — it never speeds your app up. Raise it, or go back to the original footage from its card on the Flows page, where this number is the pause.`)),r.append(t)}}else if(e.gap!==null){let t=w(`div`);t.setAttribute(`data-gap-inert`,e.actionId),t.append(w(`span`,void 0,`A ${e.gap.durationMs}ms pause is set here but is not playing. ${c}`),s()),r.append(t)}if(e.legacyHold!==null){let t=e.legacyHold.offsetMs===0?`after this step`:`${e.legacyHold.offsetMs}ms into this step`,n=e.timing===`rendered`?`still plays ${t}`:`is set ${t}, but nothing has rendered that step, so it is not in the video you have`,i=w(`div`);i.setAttribute(`data-legacy-hold`,e.actionId),i.append(w(`span`,void 0,`A ${e.legacyHold.durationMs}ms pause from an earlier edit ${n}. There is no control for it: deleting this step removes it, and nothing else in the editor does.`)),r.append(i)}if(e.cut){let n=w(`div`);n.setAttribute(`data-cut-panel`,e.actionId),n.append(w(`p`,`honesty`,`This step is in a removed piece, so it is not in the video.`));let i=t.attachedToCuts.filter(t=>t.actionId===e.actionId);if(i.length>0){let t=[...i].map(e=>e.kind).sort(),r=i.length===1,a=w(`p`,`muted`,`${i.length} edit${r?``:`s`} on this step (${t.join(`, `)}) ${r?`is`:`are`} kept and not drawn. Restoring the piece brings ${r?`it`:`them`} back.`);a.setAttribute(`data-cut-attached`,e.actionId),n.append(a)}r.append(n)}let l=w(`div`,`control-actions`);if(t.hoverReport?.removable.includes(e.actionId)??!1){let t=w(`button`,`btn btn-quiet`,`Keep this hover`);t.type=`button`,t.setAttribute(`data-keep-hover`,e.actionId),t.addEventListener(`click`,()=>n.onKeepHover(e.actionId)),l.append(t)}return l.hasChildNodes()&&r.append(l),r}function ui(e,t,n){let r=w(`div`,`zoom-panel`);r.setAttribute(`data-zoom-panel`,e.id),r.append(w(`h2`,void 0,`Zoom`));let i=w(`input`);i.type=`range`,i.min=`1.1`,i.max=String(S.maxScale),i.step=`0.05`,i.value=String(e.scale),i.setAttribute(`data-zoom-scale`,e.id),i.setAttribute(`aria-label`,`Zoom level`),et(i),i.addEventListener(`input`,()=>et(i)),i.addEventListener(`change`,()=>n.onZoomScale(e.id,Number(i.value)));let a=w(`div`,`slider-row`);a.append(w(`span`,`control-label slider-label`,`Level`),w(`span`,`slider-value`,`${e.scale.toFixed(2)}x`),i),r.append(a);let o=w(`div`);if(o.setAttribute(`data-zoom-aim`,``),e.target.kind===`element`){let{anchorId:n}=e.target,r=t.scene.anchors.find(e=>e.id===n);o.textContent=`Aims at ${r?bt(r):n}`}else o.textContent=`Aims at the cursor at ${rr(e.startMs)}`;if(r.append(o),e.aimFallback!==null){let t=w(`div`,`muted`,e.aimFallback);t.setAttribute(`data-zoom-fallback`,``),r.append(t)}let s=w(`div`);s.setAttribute(`data-zoom-range`,``),s.textContent=`${rr(e.startMs)} to ${rr(e.endMs)}${e.endAuthored?``:` (end automatic; drag its cap to set one)`}`,r.append(s),e.clamped&&r.append(w(`div`,`muted`,`The end you set could not be reached; see the note under the timeline.`)),e.timing===`estimated`&&r.append(w(`div`,`muted`,`Estimated position: the last render carried no marker for this zoom's step, or no on-screen rect for its target.`));let c=w(`button`,`btn btn-quiet`,`Remove zoom`);c.type=`button`,c.setAttribute(`data-remove-zoom`,e.id),ti(c,`Remove zoom`,[`Delete`]),c.addEventListener(`click`,()=>n.onRemoveZoom(e.id));let l=w(`div`,`control-actions`);return l.append(c),r.append(l),r}function di(e,t,n){let r=w(`div`,`mask-panel`);r.setAttribute(`data-mask-panel`,e.id),r.append(w(`h2`,void 0,`Mask`));let i=w(`div`);i.setAttribute(`data-mask-rect`,``),i.textContent=`${Math.round(e.rect.width)}x${Math.round(e.rect.height)} at ${Math.round(e.rect.x)}, ${Math.round(e.rect.y)}`,r.append(i);let a=w(`input`);a.type=`text`,a.placeholder=`What this hides`,a.value=t.scene.edits.masks.find(t=>t.id===e.id)?.note??``,a.setAttribute(`data-mask-note`,e.id),a.setAttribute(`aria-label`,`Mask note`),a.addEventListener(`change`,()=>n.onMaskNote(e.id,a.value));let o=w(`label`,`control-row`);o.append(w(`span`,`control-label`,`Note`),a),r.append(o);let s=w(`div`);s.setAttribute(`data-mask-range`,``),e.wholeTake?(s.setAttribute(`data-mask-whole-take`,``),s.textContent=`Covers the whole video (made before masks had a range).`):s.textContent=`${rr(e.startMs)} to ${rr(e.endMs)}`,r.append(s),r.append(w(`p`,`honesty`,`Masks are opaque fills stored in the page's own coordinates and re-applied on every render — non-destructive as layers, absolute as pixels.`));let c=w(`button`,`btn btn-quiet`,`Remove mask`);c.type=`button`,c.setAttribute(`data-remove-mask`,e.id),ti(c,`Remove mask`,[`Delete`]),c.addEventListener(`click`,()=>n.onRemoveMask(e.id));let l=w(`div`,`control-actions`);return l.append(c),r.append(l),r}function fi(e,t,n){let{selection:r,rail:i}=t;if(i===`shortcuts`&&e.querySelector(`:scope > .inspector > [data-shortcuts-panel]`)!==null)return;let a=w(`div`,`inspector`),o=r?.kind===`tick`?t.view.beats.find(e=>e.actionId===r.actionId):void 0,s=r?.kind===`zoom`?t.model.zooms.find(e=>e.id===r.id):void 0,c=r?.kind===`mask`?t.model.masks.find(e=>e.id===r.id):void 0,l;i===`selection`?o?l=li(o,t,n):s?l=ui(s,t,n):c?l=di(c,t,n):(console.error(`[demoman] editor: the rail is on Selection with nothing selected`),l=ai()):l=i===`background`?oi():i===`cursor`?ci():i===`shortcuts`?si():ai();let u=w(`button`,`btn btn-icon inspector-close`);u.type=`button`,u.setAttribute(`data-inspector-close`,``),u.setAttribute(`aria-label`,`Close panel`),ti(u,`Close`,[`Esc`]),u.append(b(`close`)),u.addEventListener(`click`,()=>n.onClose()),a.append(u,l),e.replaceChildren(a)}var pi=[{entry:`background`,label:`Background`,glyph:`image`},{entry:`cursor`,label:`Cursor`,glyph:`mousePointer2`},{entry:`selection`,label:`Selection`,glyph:`mousePointerClick`}],mi=`Select a step or zoom on the timeline`;function hi(e,t,n){let r=pi.map(({entry:e,label:r,glyph:i})=>{let a=w(`button`,`btn btn-icon`);a.type=`button`,a.setAttribute(`data-rail`,e),a.setAttribute(`aria-label`,r),a.setAttribute(`aria-pressed`,String(t.panelOpen&&t.rail===e));let o=e===`selection`&&!t.hasSelection;return a.disabled=o,a.title=o?mi:r,a.append(b(i)),a.addEventListener(`click`,()=>n.onPick(e)),a});e.replaceChildren(...r)}function gi(e,t,n){e.querySelector(`svg[data-icon]`)===null&&e.replaceChildren(b(`download`),w(`span`,void 0,`Export`)),e.setAttribute(`aria-pressed`,String(t.panelOpen&&t.rail===`export`)),e.onclick=()=>n.onPick(`export`)}function _i(e,t,n){e.setAttribute(`aria-pressed`,String(t.panelOpen&&t.rail===`shortcuts`)),e.onclick=()=>n.onPick(`shortcuts`)}function vi(e,t,n,r=null){let i=r===null?``:` ${Ze[r]}`;switch(e.phase){case`idle`:return qe(t);case`queued`:return e.position===0?`Queued…`:`Queued (${e.position} ahead)`;case`encoding`:return e.total>0?`Exporting${i} · ${Math.floor(e.done*100/e.total)}%`:`Exporting${i}…`;case`saving`:return`Saving${i}…`}}var yi=1e3,bi=new Map;function xi(e){let{key:t,checked:n}=e,r=document.createElement(`span`);r.className=`switch`;let i=document.createElement(`input`);i.type=`checkbox`,i.checked=n,i.disabled=e.disabled??!1,i.setAttribute(`role`,`switch`),i.setAttribute(`aria-checked`,n?`true`:`false`);for(let[t,n]of Object.entries(e.attrs??{}))i.setAttribute(t,n);let a=document.createElement(`span`);a.className=`switch-track`,a.setAttribute(`aria-hidden`,`true`),r.append(i,a);let o=performance.now(),s=bi.get(t);if(s!==void 0&&o-s.at>yi)bi.delete(t);else if(s!==void 0){let e=s.on===n?o-s.at:0;s.on!==n&&bi.set(t,{on:n,at:o}),r.setAttribute(`data-flip`,``),r.style.setProperty(`--switch-elapsed`,`${-e}ms`)}return a.addEventListener(`animationend`,()=>r.removeAttribute(`data-flip`)),i.addEventListener(`click`,()=>{r.removeAttribute(`data-flip`),bi.set(t,{on:i.checked,at:performance.now()}),e.onChange(i.checked)}),r}function Si(e,t,n){let r=document.createElement(`label`);r.className=`switch-row`;let i=document.createElement(`span`);i.className=`switch-text`;let a=document.createElement(`strong`);if(a.textContent=e,i.append(a),t!==null){let e=document.createElement(`span`);e.className=`hint`,e.textContent=t,i.append(e)}return r.append(i,n),r}function Ci(e,t){let n=t.hoverReport===null?null:Vn(t.hoverReport);if(t.notices.length===0&&n===null){e.replaceChildren();return}let r=w(`div`,void 0);r.setAttribute(`data-take-notes`,``);for(let e of t.notices){let t=w(`div`,`notice`);C(t,e),t.setAttribute(`data-take-notice`,``),r.append(t)}if(n!==null){let e=w(`div`,`notice`,n);e.setAttribute(`data-hover-report`,``),r.append(e)}e.replaceChildren(r)}function wi(e,t){if(t.hasFrames){e.replaceChildren();return}let n=w(`div`,`banner`),r=w(`span`);r.append(Ti(t.route)),n.append(r),e.replaceChildren(n)}function Ti(e){let t=document.createDocumentFragment();return t.append(`This video has no frames — `,Ei(e)),t}function Ei(e){let t=w(`span`);return C(t,e.rerun),t.setAttribute(`data-rerun-line`,``),t}function Di(e,t){let n=[];if(t.openError!=null){let e=w(`div`,`notice`);e.setAttribute(`data-open-error`,``),e.append(w(`strong`,void 0,`This video could not be opened`)),e.append(w(`div`,void 0,t.openError)),n.push(e)}if(t.replaySentence!==null){let e=w(`div`,`notice`);e.setAttribute(`data-replay-failure`,``);let r=t.runsRoute?.authored===!0?`script run`:`re-shoot`;if(e.append(w(`strong`,void 0,t.replayRecoverable===!0?`The last ${r} stopped early`:`The last ${r} did not finish`)),e.append(w(`div`,void 0,t.replaySentence)),t.runsRoute!=null){let n=w(`div`);n.setAttribute(`data-replay-runs-route`,``),n.append(Ei(t.runsRoute)),e.append(n)}n.push(e)}if(t.renderError!=null){let e=w(`div`,`notice`);e.setAttribute(`data-render-error`,``),e.append(w(`strong`,void 0,`The export did not start`)),e.append(w(`div`,void 0,t.renderError)),n.push(e)}if(t.previewError!=null){let e=w(`div`,`notice`);e.setAttribute(`data-preview-error`,``),e.append(w(`strong`,void 0,`The preview stopped`)),e.append(w(`div`,void 0,t.previewError)),n.push(e)}if(t.logoLoadError!=null){let e=w(`div`,`notice`);e.setAttribute(`data-logo-load-error`,``),e.append(w(`strong`,void 0,`The logo could not be loaded`)),e.append(w(`div`,void 0,t.logoLoadError)),n.push(e)}if(t.wallpaperLoadError!=null){let e=w(`div`,`notice`);e.setAttribute(`data-wallpaper-load-error`,``),e.setAttribute(`role`,`alert`),e.append(w(`strong`,void 0,`The background image could not be loaded`)),e.append(w(`div`,void 0,t.wallpaperLoadError)),n.push(e)}if(t.error!==null){let e=w(`div`,`notice`);e.setAttribute(`data-action-error`,``),e.append(w(`strong`,void 0,`That edit did not go through`)),e.append(w(`div`,void 0,t.error)),n.push(e)}if(t.deleteError!=null){let e=w(`div`,`notice`);e.setAttribute(`data-delete-error`,``),e.append(w(`strong`,void 0,`This video was not deleted`)),e.append(w(`div`,void 0,t.deleteError)),n.push(e)}if(t.navigationError!=null){let e=w(`div`,`notice`);e.setAttribute(`data-navigation-error`,``),e.append(w(`strong`,void 0,`The ${t.navigationError.page} did not open`)),e.append(w(`div`,void 0,t.navigationError.reason)),n.push(e)}e.replaceChildren(...n)}function Oi(e,t,n){Ue(e,t,n)}var ki={light:`Light`,dark:`Dark`,touch:`Touch`},Ai={light:1/16,dark:1/16,touch:0};function ji(e,t,n){let{height:r,hotspot:i,ink:a}=f[e],o=r*t,s={x:(a.min.x+a.max.x)/2,y:(a.min.y+a.max.y)/2};return{x:n/2-(s.x-i.x-Ai[e])*o,y:n/2-(s.y-i.y)*o}}var Mi=.6;function Ni(e,t,n){return Math.min(Math.min(2,Math.max(.5,t))*Mi,n/f[e].height)}function Pi(t,n){let r=w(`canvas`);r.width=44,r.height=44;let i=r.getContext(`2d`);if(!i)return console.error(`the cursor panel could not paint its "${t}" preview: no 2D context`),r;let a=Ni(t,n,44);return ne(i,ji(t,a,44),a,e,t),r}function Fi(e,t,n,r,i,a,o,s){let c=w(`div`,`slider-row`),l=w(`input`);l.type=`range`,l.min=String(r),l.max=String(i),l.step=`0.05`,l.value=String(n),l.disabled=s,l.setAttribute(e,``),l.setAttribute(`aria-label`,t);let u=w(`span`,`slider-value`,a(n));et(l),l.addEventListener(`input`,()=>{et(l),u.textContent=a(Number(l.value)),o.preview(Number(l.value))}),l.addEventListener(`change`,()=>o.commit(Number(l.value)));let d=()=>{Number(l.value)===n&&o.end()};return l.addEventListener(`pointerup`,d),l.addEventListener(`pointercancel`,d),c.append(w(`span`,`control-label slider-label`,t),u,l),c}var Ii=e=>`${Math.round(e*100)}%`,Li=e=>`${e.toFixed(2)}x`;function Ri(e,t,n,r,i,a,o,s,c){return Fi(e,t,n,r,i,a,{preview:e=>s.onCursorPreview({[o]:e}),commit:e=>s.onCursor({[o]:e}),end:()=>s.onCursorPreviewEnd()},c)}function zi(e,t,n,r,i){return Fi(e,t,n,0,1,Ii,{preview:e=>i.onMotionPreview({[r]:e}),commit:e=>i.onMotion({[r]:e}),end:()=>i.onMotionPreviewEnd()},!1)}function Bi(e,t,n,r,i,a){return Si(t,null,xi({key:r,checked:n,disabled:a,attrs:{[e]:``},onChange:e=>i.onCursor({[r]:e})}))}function Vi(e,t,n,r,i=!1){let a=w(`div`),o=t.hidden;a.append(Bi(`data-cursor-hidden`,`Hide cursor`,t.hidden,`hidden`,r,!1));let s=Ri(`data-cursor-scale`,`Size`,t.scale,.5,2,Li,`scale`,r,o);i&&a.append(s);let c=w(`div`,`cursor-styles`);c.setAttribute(`role`,`radiogroup`),c.setAttribute(`aria-label`,`Cursor style`),o&&c.setAttribute(`aria-disabled`,`true`);for(let e of[`light`,`dark`,`touch`]){let n=w(`button`,`cursor-style`);n.type=`button`,n.disabled=o,n.setAttribute(`role`,`radio`),n.setAttribute(`data-cursor-style`,e),n.setAttribute(`aria-checked`,String(t.style===e)),n.setAttribute(`aria-label`,ki[e]),n.title=ki[e],n.append(Pi(e,t.scale)),n.addEventListener(`click`,()=>r.onCursor({style:e})),c.append(n)}i||a.append(w(`div`,`cursor-label`,`Style`),c),i||a.append(s,Ri(`data-cursor-blur`,`Motion blur`,t.motionBlur,0,1,Ii,`motionBlur`,r,o),Ri(`data-cursor-tilt`,`Tilt`,t.tilt??me.tilt,0,1,Ii,`tilt`,r,o),Ri(`data-cursor-bounce`,`Click bounce`,t.clickBounce??me.clickBounce,0,2,Li,`clickBounce`,r,o),Bi(`data-cursor-idle`,`Hide when not moving`,t.hideWhenIdle,`hideWhenIdle`,r,o)),a.append(w(`div`,`cursor-label camera-label`,`Camera`),zi(`data-motion-smoothness`,`Smoothness`,n.smoothness,`smoothness`,r),zi(`data-motion-blur`,`Camera blur`,n.blur,`blur`,r),Si(`Follow cursor`,null,xi({key:`motion-follow`,checked:n.follow,attrs:{"data-motion-follow":``},onChange:e=>r.onMotion({follow:e})}))),e.replaceChildren(a)}function Hi(){let e=w(`progress`,`export-progress`);return e.setAttribute(`data-export-progress`,``),e.setAttribute(`aria-label`,`Export progress`),e}function Ui(e,t,n){return e.phase!==`idle`||t.kind===`noFrames`||n.length===0}function Wi(e,t,n,r,i=[]){let a=e.querySelector(`[data-export-start]`);if(a===null)return!1;a.textContent=vi(t,n,r,Gi(i)),a.disabled=Ui(t,r,n);let o=Nt(i);if(o!==null&&i.length>1){let n=e.querySelector(`[data-file-status="${o.fileType}"]`);n!==null&&(n.textContent=qi(o,t,i))}let s=e.querySelector(`[data-export-progress]`);if(t.phase!==`encoding`||t.total===0)return s?.remove(),!0;let c=s??Hi();return Ki(c,t,i),s===null&&a.closest(`.control-actions`)?.after(c),!0}function Gi(e){return e.length>1?Nt(e)?.fileType??null:null}function Ki(e,t,n){let r=Math.max(1,n.length),i=Math.max(0,n.findIndex(e=>e.ended===null));e.max=t.total*r,e.value=t.total*i+t.done}function qi(e,t,n){if(e.ended===`saved`)return`Saved`;if(e.ended===`failed`)return`Failed`;if(e!==Nt(n))return`Waiting`;switch(t.phase){case`idle`:return`Waiting`;case`queued`:return`Queued`;case`encoding`:return t.total>0?`${Math.floor(t.done*100/t.total)}%`:`Exporting`;case`saving`:return`Saving`}}function Ji(e,t,n){let r=w(`div`),o=t.run.phase!==`idle`;if(t.hasReclaimedMotion){let e=w(`p`,`notice`,`This export will use still frames where motion was reclaimed.`);e.setAttribute(`data-reclaimed-motion-notice`,``),r.append(e)}let s=tt(t.aspect),c=w(`div`,`export-facts`),l=(e,t,n)=>{let r=w(`div`,`export-fact`),i=w(`span`,`export-fact-value`,t);return i.setAttribute(n,``),r.append(w(`span`,`export-fact-label`,e),i),c.append(r),r};l(`Length`,te(t.durationMs),`data-export-summary`);let u=l(`Aspect`,s.value,`data-aspect-note`);if(u.title=`Set under the preview`,u.append(w(`span`,`visually-hidden`,`Set under the preview`)),l(`Source`,Qe(t.recording),`data-size-readout`),r.append(c),s.reason!==null){let e=w(`p`,`muted export-fact-reason`,s.reason);e.setAttribute(`data-aspect-reason`,``),r.append(e)}let d=o&&t.files.length>1?t.files:[],f=w(`div`,`control-row files-row`),p=w(`div`,`files-head`);if(p.append(w(`span`,`section-label`,`Files`)),t.quality!=null){let e=!t.fileTypes.includes(`mp4`),r=w(`div`,`file-quality`);r.append(w(`span`,`control-aside`,`Quality`));let s=w(`div`,`segmented`);s.setAttribute(`role`,`radiogroup`);let c=`Quality applies to the MP4: tick MP4 to choose`;s.setAttribute(`aria-label`,e?c:`Quality`),s.setAttribute(`data-export-qualities`,``),e&&(r.title=c);for(let r of i){let i=w(`button`,`segment`,a[r]);i.type=`button`,i.setAttribute(`role`,`radio`),i.setAttribute(`data-export-quality`,r),i.setAttribute(`aria-checked`,String(r===t.quality)),i.disabled=o||e,i.addEventListener(`click`,()=>n.onQuality(r)),s.append(i)}r.append(s),p.append(r)}f.append(p);let m=w(`div`,`file-types`);m.setAttribute(`role`,`group`),m.setAttribute(`aria-label`,`Files`),m.setAttribute(`data-file-types`,``);for(let e of Ge){let r=w(`label`,`file-type`),i=w(`input`);i.type=`checkbox`,i.checked=t.fileTypes.includes(e),i.setAttribute(`data-file-type`,e),i.disabled=o,i.addEventListener(`click`,()=>n.onFileType(e,i.checked));let a=d.find(t=>t.fileType===e),s=a===void 0?w(`span`,`file-facts`,$e(e,t.targets[e])):w(`span`,`file-status`,qi(a,t.run,t.files));a!==void 0&&s.setAttribute(`data-file-status`,e),r.append(i,w(`span`,`file-name`,Ze[e]),s),m.append(r)}f.append(m),r.append(f);let h=w(`button`,`btn btn-primary export-start`,vi(t.run,t.fileTypes,t.readiness,Gi(t.files)));h.type=`button`,h.setAttribute(`data-export-start`,``),h.setAttribute(`data-readiness`,t.readiness.kind),h.disabled=Ui(t.run,t.readiness,t.fileTypes),h.addEventListener(`click`,n.onExport);let g=w(`div`,`control-actions`);if(g.append(h),t.readiness.kind===`noFrames`){let e=w(`p`,`muted`);e.setAttribute(`data-export-no-frames`,``),e.append(Ti(t.runsRoute)),r.append(g,e)}else if(t.fileTypes.length===0){let e=w(`p`,`muted`,`Tick at least one file.`);e.setAttribute(`data-export-none-ticked`,``),r.append(g,e)}else r.append(g);if(t.run.phase===`encoding`&&t.run.total>0){let e=Hi();Ki(e,t.run,t.files),r.append(e)}let _=Yi(t.repo,n);if(_!==null&&r.append(_),t.save!==null&&r.append(oa(t.save,n)),!o)for(let e of t.files.filter(e=>e.ended===`failed`)){let t=w(`div`,`notice notice-error`);t.setAttribute(`data-file-failed`,e.fileType);let i=w(`button`,`btn btn-quiet`,`Retry`);i.type=`button`,i.addEventListener(`click`,()=>n.onRetry(e.fileType)),t.append(w(`span`,void 0,`${Ze[e.fileType]} failed`),` `,i),r.append(t)}if(t.revealError!=null){let e=w(`p`,`notice notice-warn`,t.revealError);e.setAttribute(`data-reveal-error`,``),r.append(e)}if(t.save?.kind===`saved`)for(let e of t.save.outputRefs){let n=t.outputs.find(t=>t.kind===`stored`&&t.output.ref===e);n?.kind===`stored`&&$i(r,n.output,t)}e.replaceChildren(r)}function Yi(e,t){if(e==null)return null;let n=w(`div`,`control-row`);n.setAttribute(`data-repo-section`,``),n.append(w(`span`,`section-label`,`Repo`));let r=(e,t)=>{let n=w(`button`,`btn btn-quiet`);return n.type=`button`,n.append(b(t),e),n};if(e.inRepo!==null){n.append(w(`span`,`control-aside`,`In repo`));let e=r(`Remove from repo`,`gitBranchMinus`);e.setAttribute(`data-action`,`repo-remove`),e.addEventListener(`click`,()=>t.onRemoveFromRepo?.()),n.append(e)}else{let i=r(`Add to repo`,`gitBranchPlus`);i.setAttribute(`data-action`,`repo-add`),e.adding?(i.setAttribute(`aria-disabled`,`true`),i.title=`Adding to repo…`):e.addable===void 0||e.addable.ok?i.addEventListener(`click`,()=>t.onAddToRepo?.()):(i.setAttribute(`aria-disabled`,`true`),i.replaceChildren(b(`gitBranchPlus`),`Can't add: ${e.addable.label}`),i.title=e.addable.detail),n.append(i)}if(e.note!=null){let t=w(`p`,`notice`,e.note);t.setAttribute(`data-note`,``),n.append(t)}if(e.status!==null){let t=w(`p`,`notice notice-error`,e.status);t.setAttribute(`data-status`,``),n.append(t)}return n}function Xi(e,t,n){let r=document.createDocumentFragment(),i=t.showAll?t.outputs:t.outputs.slice(0,5);for(let e of i){let i=w(`div`,`output`);if(i.setAttribute(`data-output`,e.kind===`file`?e.key:e.output.ref),r.append(i),e.kind===`file`){ia(i,e,t,n);continue}let a=e.output,o=w(`div`,`beat`),s=a.sceneDigest!==void 0&&a.sceneDigest!==t.currentDigest,c=t.warningsOpen.has(a.ref);o.append(na(a.name,[s?ta(a.ref):null,Qi(a.ref,Zi(a),c,n)]));let l=w(`button`,`btn btn-quiet`,`Download`);if(l.type=`button`,l.setAttribute(`data-download`,a.ref),l.addEventListener(`click`,()=>n.onDownload(a.ref)),o.append(l),i.append(o),i.append(ra(a.ref,[Ae(a.byteLength),ea(a.renderedAt)],null)),c&&Zi(a)>0){let e=w(`div`,`output-warnings`);e.setAttribute(`data-output-warnings-body`,a.ref),$i(e,a,t.reportContext),i.append(e)}}let a=t.outputs.length-i.length;if(a>0){let e=w(`button`,`btn btn-quiet`,`Show all ${t.outputs.length}`);e.type=`button`,e.setAttribute(`data-history-all`,``),e.title=`${a} more`,e.addEventListener(`click`,n.onShowAll),r.append(e)}e.replaceChildren(r)}function Zi(e){return[e.detailViolations.length>0,e.logoWarning!==void 0,(e.unavailableSpans??[]).length>0,(e.unplacedStills??[]).length>0].filter(Boolean).length}function Qi(e,t,n,r){if(t===0)return null;let i=w(`button`,`chip chip-warn`,t===1?`1 warning`:`${t} warnings`);return i.type=`button`,i.setAttribute(`data-output-warnings`,e),i.setAttribute(`aria-expanded`,String(n)),i.addEventListener(`click`,()=>r.onWarnings(e)),i}function $i(e,t,n){if(t.detailViolations.length>0){let{heading:r,lines:i}=kt(t.detailViolations,n.beatAt),a=w(`div`,`notice`);a.setAttribute(`data-violations`,t.ref),a.append(w(`strong`,void 0,r));for(let e of i)a.append(w(`div`,void 0,e));a.append(w(`div`,`honesty`,`A wider browser window is what gives the camera more to work with: both the stills and the motion scale with it. A smaller export size is the other way to close the gap.`)),e.append(a)}if(t.logoWarning!==void 0){let n=w(`div`,`notice`);n.setAttribute(`data-logo-warning`,t.ref),n.append(w(`div`,void 0,t.logoWarning)),e.append(n)}let r=t.unavailableSpans??[];if(r.length>0){let i=w(`div`,`notice`);i.setAttribute(`data-unavailable`,t.ref);let a=r.every(e=>e.reason===Tt),o=w(`strong`);C(o,a?`Motion was reclaimed to free space and shown as a still. ${n.runsRoute.rerun}`:`Some motion could not be decoded and was shown as a still`),i.append(o);for(let e of r)i.append(w(`div`,void 0,`${e.ref}: ${e.reason}`));e.append(i)}let i=t.unplacedStills??[];if(i.length>0){let n=w(`div`,`notice`);n.setAttribute(`data-unplaced-stills`,t.ref);let r=i.every(e=>e.reason.includes(`cut`));n.append(w(`strong`,void 0,r?`No still for ${i.length===1?`a step you cut`:`the steps you cut`}`:`Some steps got no still`));for(let e of i)n.append(w(`div`,void 0,`${e.actionId}: ${e.reason}`));e.append(n)}}function ea(e,t=new Date){let n=new Date(e);return Number.isNaN(n.getTime())?e:Ee(n,n.getFullYear()!==t.getFullYear())}function ta(e){let t=w(`span`,`chip`,`Outdated`);return t.setAttribute(`data-stale-export`,e),t.title=`Made before your last edit`,t}function na(e,t){let n=w(`span`,`output-head`),r=w(`span`,`output-name`,e);r.title=e,n.append(r);for(let e of t)e!==null&&n.append(e);return n}function ra(e,t,n){let r=w(`div`,`muted output-meta`,t.join(` · `));return r.setAttribute(`data-output-meta`,e),n!==null&&(r.title=n),r}function ia(e,t,n,r){let i=w(`div`,`beat`),a=n.warningsOpen.has(t.key);if(i.append(na(t.name,[t.sceneDigest===n.currentDigest?null:ta(t.key),Qi(t.key,t.caveats.length,a,r)])),t.exists){let e=w(`button`,`btn btn-quiet`,ga());e.type=`button`,e.setAttribute(`data-reveal`,t.key),e.addEventListener(`click`,()=>r.onReveal({kind:`path`,path:t.path})),i.append(e)}else{let e=w(`span`,`muted`,`moved or deleted`);e.setAttribute(`data-output-gone`,``),i.append(e)}if(e.append(i),e.append(ra(t.key,[Ae(t.byteLength),ea(t.renderedAt)],t.detail)),a&&t.caveats.length>0){let n=w(`div`,`notice output-warnings`);n.setAttribute(`data-output-warnings-body`,t.key);for(let e of t.caveats)n.append(w(`div`,void 0,aa(e)));e.append(n)}}function aa(e){let t=e.charAt(0).toUpperCase()+e.slice(1);return/[.!?]$/.test(t)?t:`${t}.`}function oa(e,t){let n=w(`div`,e.kind===`failed`?`notice notice-error`:`notice`);n.setAttribute(`data-save-outcome`,e.kind);let r=(e,n)=>{let r=w(`button`,`btn btn-quiet`,n);return r.type=`button`,r.setAttribute(`data-save-again`,``),r.addEventListener(`click`,()=>t.onSaveAgain(e)),r};if(e.kind===`saved`){let r=e.names.length===1?`Saved ${e.names[0]} · ${Ae(e.byteLength)}`:`Saved ${e.names.length} files · ${Ae(e.byteLength)}`;n.append(w(`span`,void 0,r));let i=e.reveal;if(i!==null){let e=w(`button`,`btn btn-quiet`,i.kind===`path`?ga():`Show in folder`);e.type=`button`,e.setAttribute(`data-show-in-folder`,``),e.addEventListener(`click`,()=>t.onReveal(i)),n.append(` `,e)}if(e.summary!==null){let t=w(`div`,`muted`,e.summary);t.setAttribute(`data-save-summary`,``),n.append(t)}}else e.kind===`cancelled`?(n.append(w(`span`,void 0,`You cancelled the save.`)),e.total>1?n.append(w(`div`,void 0,`Saved ${e.saved} of ${e.total} files.`)):n.append(` `),n.append(r(e.refs,`Download again`))):(n.append(w(`strong`,void 0,`Exported, but the browser didn't save it.`)),e.total>1&&n.append(w(`div`,void 0,`Saved ${e.saved} of ${e.total} files.`)),n.append(w(`div`,void 0,e.error),r(e.refs,`Download again`)));return n}function sa(e,t){let n=w(`button`,`btn btn-icon transport-button`);return n.type=`button`,n.setAttribute(`data-transport-shuttle`,String(e)),n.setAttribute(`aria-label`,t),n.append(b(e===-1?`rewind`:`fastForward`)),n}function ca(e,t,n){let r=e.querySelector(`[data-transport-play]`),i=e.querySelector(`[data-transport-rate]`),a=e.querySelector(`[data-transport-controls]`),o=e.querySelector(`[data-transport-repeat]`),s=e.querySelector(`[data-transport-skip]`);if(r===null||i===null||a===null||o===null||s===null){r=w(`button`,`btn btn-icon transport-button`),r.type=`button`,r.setAttribute(`data-transport-play`,``),s=w(`button`,`btn btn-icon transport-button`),s.type=`button`,s.setAttribute(`data-transport-skip`,``),s.append(b(`skipBack`)),o=w(`button`,`btn btn-icon transport-button`),o.type=`button`,o.setAttribute(`data-transport-repeat`,``),o.append(b(`repeat`));let t=w(`span`,`transport-pip`);t.setAttribute(`aria-hidden`,`true`),o.append(t),i=w(`span`,`rate`),i.setAttribute(`data-transport-rate`,``),a=w(`div`,`transport-controls`),a.setAttribute(`data-transport-controls`,``),a.append(s,sa(-1,`Rewind`),r,sa(1,`Fast forward`),o,i),e.querySelector(`[data-transport-controls]`)?.remove();let n=e.querySelector(`:scope > .transport-end`);n===null?e.append(a):n.before(a)}let c=Math.abs(t.rate);for(let e of a.querySelectorAll(`[data-transport-shuttle]`)){let r=e.dataset.transportShuttle===`-1`?-1:1;e.onclick=()=>n.onShuttle(r),e.disabled=!t.enabled;let i=r===-1?t.playing&&t.rate<0:t.playing&&t.rate>1;e.toggleAttribute(`data-active`,i);let a=r===-1?`Rewind`:`Fast forward`,o=i?`${a}, playing ${r===-1?`backwards`:`forwards`} at ${c}x`:a;e.setAttribute(`aria-label`,o),t.enabled?ti(e,o,[r===-1?`J`:`L`]):(ni(e),e.title=o)}s.onclick=()=>n.onSkipToStart(),s.disabled=!t.enabled;let l=`Jump to start`;s.setAttribute(`aria-label`,l),t.enabled?ti(s,l,[`Mod`,`Left`]):(ni(s),s.title=ae(`This video has no frames yet, so there is nothing to play. ${t.rerunLine}`)),o.onclick=()=>n.onLooping(!t.looping),o.toggleAttribute(`data-active`,t.looping),o.setAttribute(`aria-pressed`,t.looping?`true`:`false`);let u=t.looping?`Repeat on — playback loops back to the start`:`Repeat off — playback stops at the end`;o.setAttribute(`aria-label`,u),o.title=u,r.onclick=()=>n.onToggle();let d=t.playing?`Pause`:`Play`;r.setAttribute(`aria-label`,d);let f=t.playing?`pause`:`play`;r.firstElementChild?.getAttribute(`data-icon`)!==f&&r.replaceChildren(b(f)),r.toggleAttribute(`data-playing`,t.playing),r.toggleAttribute(`data-active`,t.playing&&t.rate===1),r.disabled=!t.enabled,t.enabled?ti(r,d,[`Space`]):(ni(r),r.title=ae(`This video has no frames yet, so there is nothing to play. ${t.rerunLine}`));let p=t.playing&&c!==1;i.textContent=p?`${c}x`:``,i.hidden=!p,i.dataset.side=t.rate<0?`back`:`forward`}function la(e,t,n,r=e){let i=r.querySelector(`[data-transport-time]`),a=e.querySelector(`[data-stage-actions]`);if(i===null||a===null){i=w(`span`,`stage-clock`),i.setAttribute(`data-transport-time`,``),a=w(`div`,`stage-actions`),a.setAttribute(`data-stage-actions`,``);let t=w(`div`,`segmented`);t.setAttribute(`role`,`radiogroup`),t.setAttribute(`aria-label`,`Aspect ratio`),t.setAttribute(`data-aspect-toggle`,``);for(let e of[`auto`,`16:9`,`9:16`]){let n=w(`button`,`segment`,e===`auto`?`Auto`:e);n.type=`button`,n.setAttribute(`role`,`radio`),n.setAttribute(`data-aspect`,e),n.title=e===`auto`?`Auto: the export takes the source's shape`:e===`9:16`?`Vertical: the camera follows each step, cropped for a phone`:`Landscape`,t.append(n)}a.append(t);let n=w(`button`,`btn chip`);n.type=`button`,n.setAttribute(`data-stage-zoom`,``),a.append(n);let o=w(`button`,`btn btn-icon chip chip-icon`);o.type=`button`,o.setAttribute(`data-stage-fullscreen`,``),a.append(o);let s=w(`div`,`stage-error`);s.setAttribute(`data-stage-error`,``),s.setAttribute(`role`,`alert`),s.hidden=!0;let c=w(`span`,`stage-error-text`);c.setAttribute(`data-stage-error-text`,``);let l=w(`button`,`btn btn-icon stage-error-dismiss`);l.type=`button`,l.setAttribute(`data-stage-error-dismiss`,``),l.setAttribute(`aria-label`,`Dismiss`),l.title=`Dismiss`,l.append(b(`close`)),s.append(c,l),r===e?e.replaceChildren(i,a,s):(r.replaceChildren(i),e.replaceChildren(a,s))}i.textContent=`${rr(t.positionMs)} / ${rr(t.durationMs)}`;for(let r of e.querySelectorAll(`[data-aspect]`)){let e=r.dataset.aspect;r.setAttribute(`aria-checked`,String(e===t.aspect)),r.onclick=()=>n.onAspect(e)}let o=e.querySelector(`[data-stage-zoom]`);o!==null&&(o.textContent=t.zoom===`fit`?`Fit`:`100%`,o.setAttribute(`aria-label`,`Zoom: ${o.textContent}`),o.disabled=!t.enabled,o.title=t.enabled?`Switch between fitting the window and actual pixels`:ae(`This video has no frames yet, so there is nothing to zoom into. ${t.rerunLine}`),o.onclick=()=>n.onZoom());let s=e.querySelector(`[data-stage-fullscreen]`);if(s!==null){let e=t.fullscreen?`Exit full screen`:`Full screen`;s.setAttribute(`aria-label`,e),s.title=e;let r=t.fullscreen?`minimize`:`maximize`;s.firstElementChild?.getAttribute(`data-icon`)!==r&&s.replaceChildren(b(r)),s.onclick=()=>n.onFullscreen()}let c=e.querySelector(`[data-stage-error]`);if(c!==null){c.hidden=t.error===null;let e=c.querySelector(`[data-stage-error-text]`);e!==null&&(e.textContent=t.error??``);let r=c.querySelector(`[data-stage-error-dismiss]`);r!==null&&(r.onclick=()=>n.onDismissError())}}var ua={undo:[`Mod`,`Z`],redo:[`Shift`,`Mod`,`Z`],"shortcuts-open":[`?`]};function da(e=document){for(let[t,n,r]of[[`back`,`chevronLeft`,`Back to your flows`],[`undo`,`undo`,`Undo`],[`redo`,`redo`,`Redo`],[`delete`,`trash`,`Delete this video`],[`shortcuts-open`,`circleQuestionMark`,`Keyboard shortcuts`]]){let i=e.querySelector(`#${t}`);if(i===null)continue;i.setAttribute(`aria-label`,r);let a=ua[t];a===void 0?i.title===``&&(i.title=r):ti(i,r,a),i.querySelector(`svg`)===null&&(i.textContent=``,i.append(b(n)))}}var fa=`#failure > .notice`;function pa(e,t){let n=[...t.querySelectorAll(`.notice, .banner`)].length;if(e.classList.toggle(`hidden`,n===0),n===0){e.removeAttribute(`data-level`),typeof t.hidePopover==`function`&&t.matches(`:popover-open`)&&t.hidePopover();return}let r=t.querySelector(fa)===null?`warn`:`error`;e.setAttribute(`data-level`,r);let i=`${n} ${n===1?`note`:`notes`} on this video${r===`error`?`, with an error`:``}`;e.setAttribute(`aria-label`,i),e.title=i,e.querySelector(`svg`)===null&&e.append(b(`circleAlert`));let a=e.querySelector(`[data-count]`);a===null&&(a=w(`span`),a.setAttribute(`data-count`,``),a.setAttribute(`aria-hidden`,`true`),e.append(a)),a.textContent=String(n)}function ma(e,t){let n=[...e.querySelectorAll(fa)].map(e=>e.textContent??``).join(`
2
+ `);return n!==``&&n!==t&&typeof e.showPopover==`function`&&!e.matches(`:popover-open`)&&e.showPopover(),n}function ha(e,t,n){let r=e.querySelector(`[data-shortcuts-search]`);if(r!==null&&r.value===t.query&&e.dataset.shortcutsMac===String(t.mac)){t.focus&&document.activeElement!==r&&r.focus();return}e.setAttribute(`data-shortcuts`,``),e.dataset.shortcutsMac=String(t.mac);let i=w(`input`,`shortcuts-search`);i.type=`search`,i.placeholder=`Search shortcuts`,i.setAttribute(`aria-label`,`Search shortcuts`),i.setAttribute(`data-shortcuts-search`,``),i.autocomplete=`off`,i.spellcheck=!1,i.value=t.query;let a=w(`div`,`shortcuts-body`),o=[];for(let e of Lr){let n=o[o.length-1];if(n?.group!==e.group){let t=w(`section`,`shortcuts-section`);t.append(w(`h3`,`shortcuts-group`,e.group)),a.append(t),n={section:t,group:e.group,rows:[]},o.push(n)}let r=w(`div`,`shortcuts-row`);r.setAttribute(`data-shortcut-row`,``),r.append(w(`span`,`shortcuts-what`,Ir(e,t.mac)));let i=w(`span`,`shortcuts-keys`);for(let n of e.combos){let e=w(`span`,`keychord`);e.setAttribute(`data-combo`,``),e.setAttribute(`aria-label`,Pr(n,t.mac));for(let r of n){let n=Ar(r,t.mac),i=w(`kbd`,`keycap`,n);i.setAttribute(`aria-hidden`,`true`),Mr(n)&&i.setAttribute(`data-symbol`,``),e.append(i)}i.append(e)}r.append(i),n.section.append(r),n.rows.push(r)}let s=w(`p`,`shortcuts-empty`,`No shortcuts match`);s.setAttribute(`data-shortcuts-empty`,``),a.append(s);let c=()=>{let e=i.value.trim().toLowerCase(),t=0;for(let{section:n,group:r,rows:i}of o){let a=r.toLowerCase().includes(e),o=0;for(let t of i){let n=t.querySelector(`.shortcuts-what`)?.textContent?.toLowerCase()??``;t.hidden=!(a||n.includes(e)),t.hidden||(o+=1)}n.hidden=o===0,t+=o}s.hidden=t>0};c(),i.addEventListener(`input`,()=>{n.onQuery(i.value),c()}),i.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.preventDefault(),i.value===``?n.onClose():(i.value=``,n.onQuery(``),c()))}),e.replaceChildren(i,a),t.focus&&i.focus()}function ga(){return Fr(navigator.userAgent)?`Show in Finder`:`Show in folder`}function _a(e){return`${Me(e)}${Oe(e)}`}function va(e,t,n=!1){let r=w(`div`,`info-row`);r.append(w(`span`,`info-key`,e));let i=w(`span`,n?`info-value mono`:`info-value`,t);return i.title=t,r.append(i),r}function ya(e,t,n,r){let i=va(e,t,!0),a=w(`button`,`btn btn-quiet btn-icon info-copy`);a.type=`button`,a.setAttribute(`aria-label`,`Copy ${n}`),a.title=`Copy ${n}`,a.setAttribute(`data-copy`,n),a.append(b(`copy`));let o=w(`div`,`info-error`);o.setAttribute(`data-copy-error`,n),o.hidden=!0,a.addEventListener(`click`,()=>{r(t).then(()=>{o.hidden=!0,a.replaceChildren(b(`check`)),a.setAttribute(`aria-label`,`Copied`),a.title=`Copied`},e=>{o.textContent=`Couldn't copy: ${e instanceof Error?e.message:String(e)}`,o.hidden=!1})}),i.append(a);let s=w(`div`);return s.append(i,o),s}function ba(e,t,n){let r=w(`div`,`info-group`);r.setAttribute(`data-info-facts`,``);let i=`${te(t.durationMs)} · ${t.steps} ${t.steps===1?`step`:`steps`}`,a=t.aspect===`auto`?`Auto`:t.aspect;r.append(va(`Recorded`,ea(t.recordedAt)),va(`Site`,_a(t.site)),va(`Length`,i),va(`Source`,`${t.recording.width} × ${t.recording.height}`),va(`Export`,`${t.target.width} × ${t.target.height} · ${a}`));let o=w(`div`,`info-group`);o.setAttribute(`data-info-ids`,``),o.append(ya(`Video ID`,t.takeId,`video ID`,n.onCopy));let s=[r,o];if(t.history.outputs.length>0){let e=w(`div`,`info-group info-exports`);if(e.setAttribute(`data-info-exports`,``),e.append(w(`div`,`info-label`,`Exports`)),t.revealError!==null){let n=w(`p`,`notice notice-warn`,t.revealError);n.setAttribute(`data-reveal-error`,``),e.append(n)}let r=w(`div`,`info-history`);Xi(r,t.history,n),e.append(r),s.push(e)}e.replaceChildren(...s)}var xa=.006,A=e=>`${(e*100).toFixed(4)}%`;function Sa(e,t,n,r=xa){if(n<e.startMs||t>e.endMs)return null;let i=Math.max(0,k(e,t)),a=Math.min(1,k(e,n)),o=Math.max(r,a-i);return{left:Math.min(i,1-o),width:o,toScale:a-i>=r}}var Ca=(e,t)=>Math.min(1,Math.max(0,k(e,t))),wa=[100,250,500,1e3,2e3,5e3,1e4,15e3,3e4,6e4],Ta=(e,t)=>t>=1e3?rr(e):`${rr(e)}.${Math.floor(e%1e3/100)}`;function Ea(e,t){let n=w(`div`,`ruler`);n.setAttribute(`data-ruler`,``),n.setAttribute(`data-source`,e.timeSource);let r=(t.viewport.endMs-t.viewport.startMs)/10,i=wa.find(e=>e>=r)??Math.ceil(r/6e4)*6e4;for(let e=Math.ceil(t.viewport.startMs/i)*i;e<=t.viewport.endMs;e+=i){let r=k(t.viewport,e),a=w(`span`,`tick`,Ta(e,i));a.style.left=A(r),a.dataset.fraction=String(r),n.append(a)}return Oa?.observe(n),n}function Da(e){let t=e.clientWidth;if(t===0)return;let n=[...e.querySelectorAll(`.tick`)].map(e=>({tick:e,w:e.offsetWidth})),r=-1/0;for(let{tick:e,w:i}of n){let n=Number(e.dataset.fraction)*t,a=n+i>t,o=a?n-i:n,s=o<r;e.toggleAttribute(`data-crowded`,s),a?e.setAttribute(`data-edge`,`end`):e.removeAttribute(`data-edge`),s||(r=o+i)}}var Oa=typeof ResizeObserver>`u`?null:new ResizeObserver(e=>{for(let t of e){let e=t.target;e.isConnected?Da(e):Oa?.unobserve(e)}});function ka(e,t){let n=w(`div`,`lane`);return n.append(e,t),n}function Aa(e,t,n){let r=w(`div`,`lane-label lane-head`),i=w(`span`,`lane-title`),a=w(`span`,`lane-glyph`);return a.append(b(t)),i.append(a,w(`span`,`lane-name`,e)),n&&i.append(n),r.append(i),r}function ja(e){let t;if(e.failed)t=`The hover check could not run, so nothing here has been checked.`;else if(e.unchecked>0)t=`${e.unchecked} ${e.unchecked===1?`hover`:`hovers`} could not be checked.`;else return null;let n=w(`span`,`lane-flag`);return n.setAttribute(`role`,`img`),n.setAttribute(`aria-label`,t),n.title=t,n.setAttribute(`data-hover-check`,e.failed?`failed`:`unchecked`),n}var Ma=3;function Na(e,t,n,r,i){e.addEventListener(`pointerdown`,e=>{e.preventDefault(),e.stopPropagation();let a=e=>{let i=t();if(i.width===0)return n.viewport.startMs;let a=(e-i.left)/i.width,o=n.viewport.startMs+a*(n.viewport.endMs-n.viewport.startMs);return Math.min(Math.max(o,0),r)};i.onSeekStart(),i.onSeek(a(e.clientX));let o=e=>i.onSeek(a(e.clientX)),s=e=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),i.onSeek(a(e.clientX))};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)})}var Pa=(e,t)=>e!==null&&t!==null&&e.kind===t.kind&&(e.kind===`tick`?e.actionId===t.actionId:e.kind===`piece`?Gt(e.start,t.start):e.id===t.id),Fa=(e,t)=>e.snapping?8*t:0;function Ia(e,t){let n=e.getBoundingClientRect().width;return n===0?0:(t.endMs-t.startMs)/n}function La(e,t,n){let r=e.getBoundingClientRect(),i=r.width===0?0:(n-r.left)/r.width;return t.startMs+i*(t.endMs-t.startMs)}function Ra(e,t,n,r,i,a){e.addEventListener(`pointerdown`,o=>{o.preventDefault(),o.stopPropagation(),e.setAttribute(`data-dragging`,``);let s=o.clientX,c=!1,l=e=>{let r=Ia(t,n.viewport);return{toMs:La(t,n.viewport,e),deltaMs:(e-s)*r,snapMs:Fa(n,r)}},u=e=>{Math.abs(e.clientX-s)>Ma&&(c=!0),c&&a?.move(l(e.clientX))},d=t=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),e.removeAttribute(`data-dragging`),c&&(a?.end(),i.onGesture(r(l(t.clientX))))};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d)})}var za=e=>Math.max(0,Math.min(1,e));function Ba(e,t,n,r){let i=za(r);t.style.left=A(i);let a=e.querySelector(`[data-clip-block]`);if(a===null)return;let o=Number(a.dataset[n===`head`?`blockTail`:`blockHead`]);if(!Number.isFinite(o))return;let s=n===`head`?i:o,c=n===`head`?o:i,l=Math.min(s,c);a.style.left=A(l),a.style.width=A(Math.max(s,c)-l)}function Va(e,t,n,r,i){let a=w(`div`,`edge`);return a.setAttribute(`data-edge`,t),a.setAttribute(`aria-label`,t===`start`?`Drag the piece's start`:`Drag the piece's end`),Ra(a,n,r,({deltaMs:n})=>({kind:`pieceEdge`,start:e.start,side:t,deltaMs:n}),i,{move:({deltaMs:e})=>{let i=e/Ia(n,r.viewport);a.style.transform=`translateX(${i}px)`;let o=t===`end`?e:-e;a.setAttribute(`data-readout`,`${o<0?`−`:`+`}${(Math.abs(o)/1e3).toFixed(1)}s`)},end:()=>{a.style.transform=``,a.removeAttribute(`data-readout`)}}),a}function Ha(e,t,n,r){let i=w(`div`,`join-card`);i.setAttribute(`data-join-card`,e.removedId),i.setAttribute(`role`,`dialog`),i.setAttribute(`aria-label`,`Removed frames`),i.setAttribute(`data-align`,t>.85?`end`:t<.15?`start`:`center`),i.addEventListener(`pointerdown`,e=>e.stopPropagation()),i.addEventListener(`click`,e=>e.stopPropagation());let a=w(`div`,`join-card-what`),o=w(`b`),s=w(`span`);e.unplaced===void 0?(o.textContent=`${n} removed`,s.textContent=`${Ua(e.srcStartMs)} to ${Ua(e.srcEndMs)}`):(o.textContent=`Removes no frames`,s.textContent=e.unplaced.charAt(0).toUpperCase()+e.unplaced.slice(1)),a.append(o,s);let c=w(`button`,`join-card-restore`);return c.type=`button`,c.setAttribute(`data-restore`,e.removedId),c.textContent=e.unplaced===void 0?`Restore`:`Discard`,c.addEventListener(`click`,()=>r.onRestorePiece(e.removedId)),i.append(a,c),i}function Ua(e){let t=Math.max(0,Math.round(e/100)),n=t%600/10;return`${Math.floor(t/600)}:${n.toFixed(1).padStart(4,`0`)}`}function Wa(e,t,n){let r=w(`div`,`track`);r.setAttribute(`data-track`,`clip`);let{clip:i}=e;for(let e of i.degraded){let n=Sa(t.viewport,e.startMs,e.endMs,0);if(n===null)continue;let i=w(`div`,`degraded`);i.setAttribute(`data-degraded`,``),i.style.left=A(n.left),i.style.width=A(n.width),r.append(i)}let a=k(t.viewport,i.trim.headMs),o=k(t.viewport,i.trim.tailMs),s=Sa(t.viewport,i.trim.headMs,i.trim.tailMs);if(s!==null){let e=w(`div`,`seg`);e.setAttribute(`data-clip-block`,``),e.setAttribute(`data-kind`,`clip`),e.setAttribute(`data-to-scale`,String(s.toScale)),e.style.left=A(s.left),e.style.width=A(s.width),e.dataset.blockHead=String(s.left),e.dataset.blockTail=String(s.left+s.width),r.append(e)}let c=r.querySelector(`[data-clip-block]`),l=i.pieces;c!==null&&s!==null&&s.width>0&&(l.length>1&&c.setAttribute(`data-pieces`,``),l.forEach((e,i)=>{let a=Sa(t.viewport,e.startMs,e.endMs,0);if(a===null)return;let o=Math.max(0,(a.left-s.left)/s.width),u=Math.min(1,(a.left+a.width-s.left)/s.width);if(u<=o)return;let d=w(`div`,`piece-wrap`);d.style.left=A(o),d.style.width=A(u-o);let f=w(`button`,`piece`);f.type=`button`,f.setAttribute(`data-piece`,String(e.startMs)),f.setAttribute(`aria-label`,`Piece of the clip`),Pa(t.selection,{kind:`piece`,start:e.start})&&(d.setAttribute(`data-selected`,``),f.setAttribute(`data-selected`,``)),f.addEventListener(`click`,t=>{t.stopPropagation(),n.onSelect({kind:`piece`,start:e.start})}),d.append(f);let p=i===0,m=i===l.length-1;(!p||e.before!==null)&&d.append(Va(e,`start`,r,t,n)),(!m||e.after!==null)&&d.append(Va(e,`end`,r,t,n)),c.append(d)}));for(let e of i.joins){let i=k(t.viewport,e.atMs);if(i<0||i>1)continue;let a=(i>=1?-1:+(i<=0))+(i>=1?-1:1)*e.index*14,o=`calc(${A(i)} + ${a}px)`,s=t.openJoin===e.removedId,c=`${((e.srcEndMs-e.srcStartMs)/1e3).toFixed(1)}s`,l=w(`button`,`join`);l.type=`button`,l.setAttribute(`data-join`,e.removedId),l.setAttribute(`aria-label`,e.unplaced===void 0?`Removed, ${c}`:`Removed nothing`),l.setAttribute(`aria-expanded`,String(s)),l.style.left=o;let u=null;l.addEventListener(`pointerdown`,e=>{e.stopPropagation(),u={x:e.clientX,y:e.clientY}}),l.addEventListener(`click`,t=>{t.stopPropagation();let r=u!==null&&t.detail>0&&Math.hypot(t.clientX-u.x,t.clientY-u.y)>Ma;u=null,r||n.onOpenJoin(s?null:e.removedId)});let d=w(`span`,`seam`);d.setAttribute(`data-seam`,e.removedId),d.style.left=o,r.append(d,l),s&&r.append(Ha(e,i,c,n))}let u=l[0],d=l.at(-1);for(let[e,s,c]of[[`head`,a,i.trim.headTiming],[`tail`,o,i.trim.tailTiming]]){if(s<0||s>1||(e===`head`?i.trim.headMarker===null&&(u?.before??null)!==null:i.trim.tailMarker===null&&(d?.after??null)!==null))continue;let a=w(`div`,`handle`);a.setAttribute(`data-trim`,e),a.setAttribute(`data-timing`,c),a.style.left=A(s),Ra(a,r,t,({toMs:t,snapMs:n})=>({kind:`trim`,edge:e,toMs:t,snapMs:n}),n,{move:({toMs:n})=>Ba(r,a,e,k(t.viewport,n)),end:()=>Ba(r,a,e,s)}),r.append(a)}for(let e of i.ticks){let a=k(t.viewport,e.atMs);if(a<0||a>1)continue;let o=w(`button`,`tick`);o.type=`button`,o.setAttribute(`data-tick`,e.actionId),o.setAttribute(`data-verb`,e.verb);let s=Za[e.verb];s!==void 0&&o.append(b(s)),o.setAttribute(`data-timing`,e.timing),o.setAttribute(`aria-label`,`${e.verb} ${e.label}`),o.title=`${e.verb} ${e.label}`,e.timing===`estimated`&&(o.setAttribute(`data-not-in-video`,``),o.title=o.title?`${o.title} — not in the video`:`Not in the video`),e.flag&&o.setAttribute(`data-flag`,e.flag),e.cut&&o.setAttribute(`data-cut`,``);let c=String(Ga(i.ticks,e));o.setAttribute(`data-stack-index`,c),o.style.setProperty(`--tick-stack`,c),Pa(t.selection,{kind:`tick`,actionId:e.actionId})&&o.setAttribute(`data-selected`,``),o.style.left=A(a),o.addEventListener(`click`,t=>{t.stopPropagation(),n.onSelect({kind:`tick`,actionId:e.actionId})}),r.append(o)}return r}function Ga(e,t){let n=e.indexOf(t),r=0;for(let i=0;i<n;i++)e[i]?.atMs===t.atMs&&(r+=1);return r}function Ka(e,t,n,r,i,a){let o=t===`zoom`?e:null,s=o?o.departMs:e.startMs,c=o?o.drawnEndMs:e.endMs,l=Sa(i.viewport,s,c);if(l===null)return null;let u=w(`div`,`seg`);u.setAttribute(`data-segment`,e.id),u.setAttribute(`data-kind`,t),u.setAttribute(`data-timing`,e.timing),u.setAttribute(`data-to-scale`,String(l.toScale)),u.style.left=A(l.left),u.style.width=A(l.width);let{trim:d}=r.clip;(c<=d.headMs||s>=d.tailMs)&&u.setAttribute(`data-outside-trim`,``);let f={kind:t,id:e.id};Pa(i.selection,f)&&u.setAttribute(`data-selected`,``);let p=t===`mask`&&e.wholeTake;if(t===`zoom`){let t=e;u.setAttribute(`data-authored-end`,String(t.endAuthored)),u.setAttribute(`data-clamped`,String(t.clamped)),u.append(w(`span`,`seg-label`,`${t.scale.toFixed(1)}x`))}else p&&u.setAttribute(`data-whole-take`,``),u.append(w(`span`,`seg-label`,p?`mask · whole video`:`mask`));if(u.addEventListener(`click`,e=>{e.stopPropagation(),a.onSelect(f)}),!p){let r=(e,t)=>{u.style.left=A(e),u.style.width=A(t)},o=()=>r(l.left,l.width),s=i.viewport.endMs-i.viewport.startMs;for(let s of[`start`,`end`]){let c=w(`div`,`cap`);c.setAttribute(`data-cap`,s),Ra(c,n,i,({toMs:n,snapMs:r})=>t===`zoom`?{kind:`zoomEdge`,id:e.id,edge:s,toMs:n,snapMs:r}:{kind:`maskEdge`,id:e.id,edge:s,toMs:n,snapMs:r},a,{move:({toMs:e})=>{let t=za(k(i.viewport,e)),n=l.left+l.width;if(s===`start`){let e=Math.min(t,n);r(e,n-e)}else r(l.left,Math.max(t,l.left)-l.left)},end:o}),u.append(c)}Ra(u,n,i,({deltaMs:n,snapMs:r})=>t===`zoom`?{kind:`moveZoom`,id:e.id,deltaMs:n,snapMs:r}:{kind:`moveMask`,id:e.id,deltaMs:n,snapMs:r},a,{move:({deltaMs:e})=>{let t=s===0?0:e/s;r(Math.max(0,Math.min(1-l.width,l.left+t)),l.width)},end:o})}return u}function qa(e,t,n,r,i=!0){let a=w(`div`,`track`);a.setAttribute(`data-track`,e);let o=e===`zoom`?t.zooms:t.masks;for(let i of o){let o=Ka(i,e,a,t,n,r);o&&a.append(o)}return i?(a.addEventListener(`click`,i=>{if(i.target!==a)return;let o=Ia(a,n.viewport);r.onGesture({kind:e===`zoom`?`addZoom`:`addMask`,atMs:Ja(e,t,La(a,n.viewport,i.clientX)),snapMs:Fa(n,o)})}),Xa(a,e,t,n),a):a}function Ja(e,t,n){let r=e===`zoom`?(t.zoomDefaultMs-t.zoomInMs)/2:pn/2;return Math.max(0,Math.min(t.durationMs,n-r))}function Ya(e,t,n){let r=e===`zoom`?Cn(t,n):wn(t,n);return mn(r)?null:e===`mask`?{startMs:r.startMs,endMs:r.endMs}:{startMs:rn(t.zooms,r.startMs,t.zoomInMs),endMs:an(t.zooms,r.startMs,r.endMs)}}function Xa(e,t,n,r){let i=null,a=()=>{i?.remove(),i=null};e.addEventListener(`pointermove`,o=>{if(o.target!==e)return a();let s=Ya(t,n,Ja(t,n,La(e,r.viewport,o.clientX))),c=s&&Sa(r.viewport,s.startMs,s.endMs);if(c===null)return a();i===null&&(i=w(`div`,`seg`),i.setAttribute(`data-ghost`,t),i.setAttribute(`aria-hidden`,`true`),e.append(i)),i.style.left=A(c.left),i.style.width=A(c.width)}),e.addEventListener(`pointerleave`,a)}var Za={click:`mousePointerClick`,type:`type`,moveTo:`mousePointer2`,scrollTo:`moveVertical`,waitFor:`hourglass`,drag:`handGrab`,press:`type`};function Qa(e,t,n,r){let i=w(`div`,`timeline`);if(i.addEventListener(`click`,e=>{e.target?.closest(`[data-ruler], [data-trim], [data-playhead], [data-track="zoom"], [data-track="mask"], button`)||r.onSelect(null)}),t.timeSource===`captured`){let e=w(`p`,`muted`);C(e,`Timing from the video, not from a render. ${t.rerunLine}`),i.append(e)}let a=Ea(t,n);Na(a,()=>a.getBoundingClientRect(),n,t.durationMs,r);let o=w(`div`,`lanes`);o.append(ka(w(`b`,`lane-label`),a));let s=w(`div`,`axis`);s.setAttribute(`data-axis`,``),i.addEventListener(`wheel`,e=>{let i=s.getBoundingClientRect();if(i.width===0)return;if(e.ctrlKey||e.metaKey){e.preventDefault();let a=(e.clientX-i.left)/i.width;r.onViewport(Yr(n.viewport,t.durationMs,e.deltaY<0?1.2:1/1.2,a));return}let a=e.shiftKey?e.deltaY:e.deltaX;if(a===0)return;e.preventDefault();let o=n.viewport.endMs-n.viewport.startMs;r.onViewport(Xr(n.viewport,t.durationMs,a/i.width*o))});let c=Aa(`Clip`,`film`),l=ja(t.hoverCheck);l!==null&&c.querySelector(`.lane-glyph`)?.append(l);let u=ka(c,Wa(t,n,r));u.setAttribute(`data-lane`,`clip`),o.append(u);let d=ka(Aa(`Zoom`,`zoomIn`),qa(`zoom`,t,n,r));d.setAttribute(`data-lane`,`zoom`),o.append(d);let f=n.maskLane===!0;if(f||t.masks.length>0){let e;f&&(e=w(`button`,`btn btn-quiet btn-icon lane-add`),e.type=`button`,e.setAttribute(`data-add-mask`,``),e.setAttribute(`aria-label`,`Add a mask at the playhead`),e.title=`Add a mask at the playhead`,e.append(b(`plus`)),e.onclick=()=>{let e=i.querySelector(`[data-track="clip"]`),t=e?Ia(e,n.viewport):0;r.onGesture({kind:`addMask`,atMs:n.positionMs,snapMs:Fa(n,t)})});let a=ka(Aa(`Mask`,`eyeOff`,e),qa(`mask`,t,n,r,f));a.setAttribute(`data-lane`,`mask`),o.append(a)}let p=w(`div`,`playhead`);p.setAttribute(`data-playhead`,``),p.style.left=A(Ca(n.viewport,n.positionMs));let m=w(`div`,`grab`);m.setAttribute(`data-playhead-grab`,``),m.setAttribute(`aria-hidden`,`true`),Na(m,()=>s.getBoundingClientRect(),n,t.durationMs,r),p.append(m),s.append(p),o.append(s),i.append(o);let h=w(`p`,`refusal`);C(h,n.refusal??``),h.setAttribute(`data-refusal`,``),h.hidden=n.refusal===null,i.append(h);let g=e.ownerDocument.activeElement,_=g instanceof HTMLElement&&e.contains(g)&&g.matches(`[data-lane="mask"] [data-add-mask]`);e.replaceChildren(i),_&&i.querySelector(`[data-lane="mask"] [data-add-mask]`)?.focus();let v=i.querySelector(`[data-join-card]`);v!==null&&$a(v)}function $a(e){let t=e.getAttribute(`data-join-card`),n=e.parentElement?.querySelector(`[data-join="${t}"]`);if(n==null||typeof e.showPopover!=`function`)return;e.setAttribute(`popover`,`manual`),e.showPopover();let r=n.getBoundingClientRect(),i=e.getBoundingClientRect(),a=r.left+r.width/2,o=Math.max(8,Math.min(innerWidth-i.width-8,a-i.width/2));e.style.left=`${o}px`,e.style.top=`${Math.max(8,r.top-i.height-8)}px`,e.style.setProperty(`--arrow`,`${a-o}px`)}function eo(e){let t=w(`button`,`btn btn-quiet btn-icon tool`);return t.type=`button`,t.append(b(e)),t}function to(e,t,n){e.setAttribute(`aria-label`,t),e.disabled?(ni(e),e.title=t):ti(e,t,n)}var no=new WeakMap;function ro(){let e=w(`div`,`bar-controls`);e.setAttribute(`data-timeline-tools`,`view`);let t=eo(`magnet`);t.classList.add(`snap`);let n=eo(`moveHorizontal`);n.classList.add(`fit`),n.setAttribute(`data-fit`,``);let r=eo(`scissors`);r.setAttribute(`data-split-tool`,``);let i=w(`div`,`zoom-control`);i.setAttribute(`data-zoom-control`,``);let a=w(`input`);a.setAttribute(`aria-label`,`Timeline zoom`),a.type=`range`,a.min=`0`,a.max=`1`,a.step=`0.001`,a.setAttribute(`data-zoom-slider`,``);let o=eo(`zoomOut`);o.classList.add(`zoom-step`),o.setAttribute(`data-zoom-step`,`out`);let s=eo(`zoomIn`);return s.classList.add(`zoom-step`),s.setAttribute(`data-zoom-step`,`in`),i.append(o,a,s),e.append(r,t,n,i),{view:e,split:r,snap:t,fit:n,zoom:a,zoomOut:o,zoomIn:s}}function io(e,t,n,r){let i=no.get(e);(i===void 0||i.view.parentElement!==e)&&(i=ro(),no.set(e,i),e.replaceChildren(i.view));let{split:a,snap:o,fit:s,zoom:c,zoomOut:l,zoomIn:u}=i;to(a,`Split at playhead`,[`Mod`,`B`]),a.onclick=()=>r.onSplit(),to(o,n.snapping?`Snapping on — drags land on the nearest step`:`Snapping off — drags land where you drop them`,[`S`]),o.setAttribute(`data-snap`,n.snapping?`on`:`off`),o.setAttribute(`aria-pressed`,n.snapping?`true`:`false`),o.onclick=()=>r.onSnapping(!n.snapping);let d=Kr(t.durationMs),f=n.viewport.startMs===d.startMs&&n.viewport.endMs===d.endMs;s.disabled=f,to(s,f?`The whole video is already in view`:`Fit the whole video`,[`Shift`,`Z`]),s.onclick=()=>r.onViewport(d);let p=n.viewport.endMs-n.viewport.startMs,m=$r(t.durationMs,p);c.value=String(m),c.style.setProperty(`--fill`,`${(m*100).toFixed(2)}%`);let h=t.durationMs>250;c.disabled=!h,c.title=h?`Zoom the timeline (⌘-scroll, ⇧Z to fit)`:`This video is too short to zoom into.`,c.oninput=()=>{let e=Qr(t.durationMs,Number(c.value)),i=k(n.viewport,n.positionMs);r.onViewport(Zr(n.viewport,t.durationMs,e,i>=0&&i<=1?i:.5))};let g=e=>{let i=Math.min(1,Math.max(0,k(n.viewport,n.positionMs)));r.onViewport(Yr(n.viewport,t.durationMs,e,i))};l.disabled=!h||m<=5e-4,l.onclick=()=>g(1/Er),to(l,`Zoom out`,[`−`]),u.disabled=!h||m>=.9995,to(u,`Zoom in`,[`+`]),u.onclick=()=>g(Er)}var j=pe();function M(e){console.error(`demoman editor:`,e)}var ao=j.kits,N={state:`ready`,kits:[],defaultId:null},oo=null,so=null;function co(e){let t=N;if(t.state!==`ready`)return null;let n=t.kits.filter(e=>e.read.state===`ready`),r=n.filter(t=>t.read.state===`ready`&&at(t.read.kit,e)),i=r.find(e=>e.id===oo)??r.find(e=>e.id===t.defaultId)??r[0];if(i!==void 0)return oo=i.id,{kit:i,edited:!1};let a=n.find(e=>e.id===oo);return a===void 0?null:{kit:a,edited:!0}}var lo=j.bundles,P=new URL(location.href).searchParams.get(`scene`)??``,F=e=>{let t=document.getElementById(e);if(!t)throw Error(`editor is missing #${e}`);return t},uo=null,fo=!1,I=Tr({sceneId:P,loadScene:async e=>{let t=await j.scenes.get(e);if(t===null)throw Error(`no scene "${e}"`);return cs??=t.notes,fo||=(uo=t.revision,!0),t.scene},saveScene:async e=>{uo=(await j.scenes.put(e,uo)).revision},bundles:{active:e=>lo.active(e)},newId:()=>crypto.randomUUID()});function L(e){let t=I.snapshot().scene;return I.dispatch(e).catch(M).then(()=>po(t))}function po(e){if(Uo===null)return;let t=I.snapshot();t.scene!==e&&t.error===null&&(Uo=null,$(t))}var R=jt,mo=null,z=null,ho=!1;function go(e){e!==z&&(ho=!1),z=e}var B=null,_o=null,vo=[],yo=null,bo=null,xo=null,V=null,So=null,H=`export`,U=!0,Co=`export`,wo=ur(),To=[`mp4`],Eo=()=>To[0]??`mp4`;function W(e,n=Eo()){let r=I.snapshot().scene,i=ko();return t(n,r.canvas.aspect,e,d({...r,branding:Ns(r)}),i===null?{}:{quality:i})}var Do=j.exportQuality===void 0?null:m,Oo=null,ko=()=>Do===null?null:Oo??Do,Ao=!1,jo=null;function Mo(e){return jo?.scene!==e&&(jo={scene:e,digest:we(e)}),jo.digest}var No=`fit`;function Po(e){e!==null&&e.kind!==`piece`?(H!==`selection`&&(Co=H),H=`selection`,U=!0):H===`selection`&&(H=Co),V=e}var Fo=null,Io=null,Lo=0,G=null,Ro=!0,zo=!1,Bo=``,Vo=!1,Ho=null,Uo=null,Wo=[];function Go(){return Wo.flatMap(e=>e.kind===`stored`?[e.output]:[])}var Ko=!1,qo=new Set,K=Qn(l),Jo=null,q=null,Yo=F(`preview`),Xo=new OffscreenCanvas(K.width,K.height),Zo=Xo.getContext(`2d`);function Qo(e){let t=W(e),n=gc(e,F(`stage-frame`).getBoundingClientRect().width),r=n.width!==K.width||n.height!==K.height;K=n,r&&(Xo=new OffscreenCanvas(K.width,K.height),Zo=Xo.getContext(`2d`)),Jo=null;let i=F(`stage`);i.style.setProperty(`--frame-ratio`,`${t.width} / ${t.height}`),i.style.setProperty(`--frame-px`,String(Qn(t).width))}var $o=150,es=null,ts=!1,ns=!1;document.addEventListener(`pointerdown`,()=>{ts=!0},!0);var rs=()=>{ts=!1,Ms?.patch.background!==void 0&&setTimeout(()=>{!ts&&Ms?.patch.background!==void 0&&Ks()},0),ns&&setTimeout(()=>{ns&&!ts&&$(I.snapshot())},0)};window.addEventListener(`pointerup`,rs,!0),window.addEventListener(`pointercancel`,rs,!0);var is=new ResizeObserver(()=>{let e=F(`stage`),t=F(`stage-frame`).getBoundingClientRect(),n=e.getBoundingClientRect();e.style.setProperty(`--bar-w`,`${t.width}px`),e.style.setProperty(`--bar-lift`,`${Math.max(0,n.bottom-t.bottom)}px`),ml&&(es!==null&&clearTimeout(es),es=setTimeout(()=>{es=null;let e=gc(I.snapshot().bundle,F(`stage-frame`).getBoundingClientRect().width);(e.width!==K.width||e.height!==K.height)&&(ts&&(Ms!==null||As!==null)?(Ks(),ns=!0):$(I.snapshot()))},$o))});is.observe(F(`stage-frame`)),is.observe(F(`stage`));var as=[],os=null,ss=``,cs=null,ls=`The video shows the text that was recorded; re-record to type the new text.`;function us(e){let t=new Map((e.madeFrom??[]).map(e=>[e.actionId,e]));return e.scene.actions.some(e=>{let n=t.get(e.id);return e.kind===`type`&&n?.kind===`type`&&n.text!==e.text})}var ds=null,fs=null,ps=0,ms=null,hs=ir(e=>e.motionSpans.length>0?_(e,lo.load,{onSpanUnavailable:(e,t)=>console.info(`[demoman] preview: span ${e} could not be decoded (${t})`)}):Promise.resolve(v(e,lo.load)));async function gs(e){let{bundle:t,scene:n}=e;if(t===null||Fn(os,e))return;os=Pn({scene:n,bundle:t}),as=[];let r=de(n).retiming.motionDiffThreshold,i=()=>{let e=I.snapshot();return e.scene===n&&e.bundle===t},a;try{a=await hs(t),as=await o(t,a,r)}catch(e){M(e),i()&&I.setHoverReport(In),$(I.snapshot());return}try{let e=await lt(n,t,a,r);if(i()){let t=le(I.snapshot().scene);I.setHoverReport(Rn(e,t))}}catch(e){M(e),i()&&I.setHoverReport(In)}$(I.snapshot())}var _s=null,vs=null,ys=null,J=null,bs=``,xs=null,Ss=null,Cs=null,ws=null,Ts=null,Es=null,Ds=null,Os=null,ks=null,Y=null,As=null,js=null,Ms=null;function Ns(e){let t=He(Ms,e,M);return Ms=t.preview,t.branding}function Ps(e){Ms={patch:e,scene:I.snapshot().scene},Ks();let t=I.snapshot();Is(t,W(t.bundle))}function Fs(e){mo!==null&&(mo=null,$(I.snapshot())),j.files.reveal(e).catch(e=>{let t=lr(e);t.expected?console.info(`demoman editor: ${t.text}`):M(e),mo=t.text,$(I.snapshot())})}function Is(e,t){let n=Ye({durationMs:mc-Z,fileType:Eo(),target:t,hasFrames:Oc(e).kind!==`noFrames`}),r=F(`take-meta`);r.textContent=n,r.setAttribute(`aria-label`,`Video info: ${n}`)}var Ls=null;function Rs(e){return As===null?e.cursor:{...e.cursor,...As}}function zs(e){let t=e.motion??ie;return js===null?t:{...t,...js}}var Bs=null,Vs=null;function Hs(e){As=e,Ks()}function Us(e){js=e,Ks()}function Ws(){js!==null&&(js=null,Ks())}function Gs(){As!==null&&(As=null,Ks())}function Ks(){Vs===null&&(Vs=requestAnimationFrame(()=>{Vs=null;let e=I.snapshot();$s(e),q&&(Ls=Rs(e.scene),Bs=zs(e.scene),ms=Jo,Q.seek(Q.positionMs))}))}function qs(){Vs!==null&&cancelAnimationFrame(Vs),Vs=null,As=null,js=null}function Js(e){return e===null?null:xs?.ref===e?xs.thumb:{kind:`loading`}}function Ys(e){return e.kind===`image`&&Y?.ref!==e.ref?{ref:e.ref,thumb:{kind:`loading`}}:Y}function Xs(e){if(ks=null,Ts===null)return null;let t=ts&&Ms?.patch.background!==void 0;try{return We(t?Be(Ts,K):Ts,e,K)}catch(e){return ks=`it could not be blurred: ${e instanceof Error?e.message:String(e)}`,null}}async function Zs(e){let t=Ns(e.scene).background;if(!Ie(t)){if(Es===null&&Ds===null)return;Ts=null,Es=null,Ds=null,Os=null,$(I.snapshot());return}let n=Re(t,K),r=Es?.key===n?Es:null;if(r!==null&&(r.error!==null||Ts!==null&&rt(K,r.natural).width<=Ts.width)){Ds=null;return}if(Ds===n)return;Ds=n,r===null&&(Os=null);let i=null,a=null;try{i=await it(t,K,j.wallpapers)}catch(e){a=e instanceof Error?e.message:String(e)}if(Ds!==n){i!==null&&`close`in i.image.image&&i.image.image.close();return}if(Ds=null,Ts=i?.image??null,Es={key:n,natural:i?.natural??null,error:a},Os=a,t.kind===`image`){let e=Y,n;if(i===null)n={kind:`failed`,reason:a??``};else if(Y?.ref===t.ref&&Y.thumb?.kind===`ready`)n=Y.thumb;else try{n={kind:`ready`,url:await Le(i.image)}}catch(e){n={kind:`failed`,reason:e instanceof Error?e.message:String(e)}}if(Y!==e)n.kind===`ready`&&n!==e?.thumb&&URL.revokeObjectURL(n.url);else{let e=Y?.thumb;e?.kind===`ready`&&e!==n&&URL.revokeObjectURL(e.url),Y={ref:t.ref,thumb:n}}}$(I.snapshot())}async function Qs(e){let t=Ns(e.scene),n=t.logo?.ref??null;if(n!==vs&&(vs=n,ys=null,J=null,_s=null,bs=``,n!==null)){let e=await j.logos.load(n);if(vs!==n)return;e.ok?ys=e.source:J=e.error}let r=g(t,K),i=`${n}@${r}`;if(ys!==null&&r>0&&i!==bs){bs=i;try{let e=await ys.rasterAt(r);if(vs!==n||bs!==i)return;_s=e,J=null}catch(e){_s=null,J=e instanceof Error?e.message:String(e)}}let a=null;if(n!==null){if(ys!==null){try{a={kind:`ready`,url:await Xe(ys)}}catch(e){a={kind:`failed`,reason:e instanceof Error?e.message:String(e)}}if(vs!==n)return}else a=J===null?{kind:`loading`}:{kind:`failed`,reason:J}}let o=JSON.stringify(a)!==JSON.stringify(xs?.thumb??null)||(xs?.ref??null)!==n;xs=n===null?null:{ref:n,thumb:a};let s=ys?Fe(ys,g(t,W(e.bundle)),Ke(Eo(),e.scene.canvas.aspect)):null,c=[ws?.ref===n?ws.note:null,s].filter(e=>e!==null),l=o||_s!==Ss||J!==Cs||c.join(`
3
+ `)!==vo.join(`
4
+ `);vo=c,Ss=_s,Cs=J,l&&$(I.snapshot())}function $s(e){Qo(e.bundle);let{scene:t,bundle:n}=e,r=Rs(t),i=Ns(t),a=ar(t,{cursor:r,branding:i,motion:js===null?t.motion:zs(t)}),o=n?u({plan:de(a),bundle:n,scene:a,target:K,detailTarget:W(n),hints:as,logo:_s,wallpaper:Xs(i.background)}):null;q=o?.resolved??null,Jo=o?.presentation??null,Yo.width!==K.width&&(Yo.width=K.width),Yo.height!==K.height&&(Yo.height=K.height)}var ec=[];function tc(e,t){let n=t.width*t.height/1e6;n<=0||(ec.push(e/n),ec.length>60&&ec.splice(0,ec.length-30))}var nc=null,rc=null,ic=2e3,ac=!1,X={requestedFrames:0,drawnFrames:0,elapsedMs:0,sourceLookupMs:0,composeMs:0,blitMs:0},oc=0,sc=null,cc=null,lc=0,uc=0;function dc(){X.requestedFrames=0,X.drawnFrames=0,X.elapsedMs=0,X.sourceLookupMs=0,X.composeMs=0,X.blitMs=0,lc=0,uc=0,oc=performance.now()}function fc(){if(Q.playing===ac)return;if(ac=Q.playing,$(I.snapshot()),ac){sc={width:K.width,height:K.height},dc();return}X.elapsedMs=performance.now()-oc;let e=(I.snapshot().bundle?.keyframes??[]).reduce((e,t)=>e===null||t.width*t.height>e.width*e.height?{width:t.width,height:t.height}:e,null);console.info(er({...X,...e===null?{}:{sourceFrame:e},...sc===null?{}:{bitmap:sc},parkedHeight:K.height,msPerMegapixel:cc,...uc>0?{decodeMs:lc}:{}}))}var pc=tr({schedule:e=>requestAnimationFrame(e),onDrawFailed:e=>{go(e instanceof Error?e.message:String(e)),Q.pause(),$(I.snapshot())},onDrawRecovered:()=>{z!==null&&(z=null,$(I.snapshot()))},draw:async e=>{let t=I.snapshot(),n={resolved:q,presentation:Jo,target:K,offscreen:Xo,offscreenCtx:Zo};if(!n.resolved||!n.presentation||!t.bundle)return;let r=performance.now(),i=await hs(t.bundle),a=performance.now();ac&&i.warm?.(ge(n.resolved.timeline,e),ge(n.resolved.timeline,e+ic));let o=0;await Se({resolved:n.resolved,target:n.target,presentation:n.presentation,frames:i,ctx:n.offscreenCtx,outputTimeMs:e,onStage:(e,t)=>{e===`fetch`&&(o=t,ac&&(lc+=t,uc+=1))}});let s=performance.now();if(n.offscreen===Xo){if(tc(s-a-o,n.target),Yo.getContext(`2d`)?.drawImage(Xo,0,0),Q.playing&&rc!==null&&(rc+=1,rc>=15)){let e=ec.slice(-rc),t=nc;nc=null,nc=gc(I.snapshot().bundle,F(`stage-frame`).getBoundingClientRect().width,e).height,rc=null,nc!==t&&($(I.snapshot()),sc={width:K.width,height:K.height})}Fo&&(V?.kind===`mask`||V?.kind===`zoom`)&&Ur(F(`stage-overlay`),{canvas:Yo,selection:V,model:Fo,resolved:n.resolved,presentation:n.presentation,target:n.target,outputTimeMs:e},{onMaskRect:(e,t)=>L({kind:`moveMask`,id:e,rect:t}),onZoomPoint:(e,t)=>L({kind:`setZoomTarget`,id:e,point:t})}),ac&&(X.drawnFrames+=1,X.sourceLookupMs+=a-r,X.composeMs+=s-a,X.blitMs+=performance.now()-s)}}}),Z=0,mc=0,hc=!1,Q=nr({seek:e=>{ac&&(X.requestedFrames+=1),pc.seek(e)},durationMs:()=>hc?mc:0,startMs:()=>Z,looping:()=>zo,now:()=>performance.now(),schedule:e=>requestAnimationFrame(e),onChange:()=>{fc(),bc()}});function gc(e,t,n=ec){let r=W(e),i=()=>Zn({target:r,paintedCssWidth:t,devicePixelRatio:window.devicePixelRatio,playing:Q.playing,msPerMegapixel:Xn(n)});return Q.playing?(nc===null&&(nc=i(),cc=Xn(n),rc=0),Qn(r,nc)):(nc=null,Qn(r,i()))}function _c(e){e!==I.snapshot().scene.canvas.aspect&&L({kind:`setAspect`,aspect:e}).then(()=>Q.seek(Q.positionMs))}function vc(e){if(e===ko())return;let t=document.activeElement instanceof HTMLElement&&document.activeElement.hasAttribute(`data-export-quality`);Oo=e,$(I.snapshot()),t&&document.querySelector(`[data-export-quality="${e}"]`)?.focus()}function yc(e,t){if(To.includes(e)===t)return;let n=document.activeElement instanceof HTMLElement&&document.activeElement.hasAttribute(`data-file-type`);To=Ge.filter(n=>n===e?t:To.includes(n)),$(I.snapshot()),n&&document.querySelector(`[data-file-type="${e}"]`)?.focus(),Q.seek(Q.positionMs)}console.info(`demoman editor: panel transition "${getComputedStyle(document.body).transitionProperty}"`),document.body.addEventListener(`transitionend`,e=>{e.target===document.body&&e.propertyName===`grid-template-columns`&&(V?.kind===`mask`||V?.kind===`zoom`)&&Q.seek(Q.positionMs)});function bc(){ca(F(`transport`),{rerunLine:kc(I.snapshot()).rerun,playing:Q.playing,enabled:hc&&mc>Z,rate:Q.rate,looping:zo},{onToggle:xc,onSkipToStart:()=>dl({kind:`seekEdge`,edge:`head`},I.snapshot()),onLooping:e=>{zo=e,bc()},onShuttle:e=>{z=null,Q.shuttle(e)}});for(let[e,t]of[[F(`stage-tools`),F(`toolbar-clock`)],[F(`stage-bar`),F(`stage-bar`)]])la(e,{rerunLine:kc(I.snapshot()).rerun,positionMs:Q.positionMs-Z,durationMs:mc-Z,aspect:I.snapshot().scene.canvas.aspect,enabled:hc&&mc>Z,fullscreen:!!document.fullscreenElement,error:ho?null:z,zoom:No},{onAspect:_c,onFullscreen:Cc,onZoom:Sc,onDismissError:()=>{ho=!0,bc()}},t);let e=F(`timeline`).querySelector(`[data-playhead]`);e&&G&&(e.style.left=`${(Ca(G,Q.positionMs)*100).toFixed(4)}%`)}function xc(){z=null,Q.toggle(),$(I.snapshot())}function Sc(){No=No===`fit`?`actual`:`fit`,document.body.dataset.zoom=No,bc()}function Cc(){z=null;let e=!document.fullscreenElement;(e?F(`stage`).requestFullscreen():document.exitFullscreen()).catch(t=>{go(`The preview could not ${e?`go full screen`:`exit full screen`}: ${t instanceof Error?t.message:String(t)}`),$(I.snapshot())})}document.addEventListener(`fullscreenchange`,()=>{let e=document.activeElement;z=null,bc();let t=!!document.fullscreenElement;F(`stage`).toggleAttribute(`data-fullscreen`,t);let n=F(t?`stage-tools`:`stage-bar`),r=F(t?`stage-bar`:`stage-tools`);if(e!==null&&e===n.querySelector(`[data-stage-fullscreen]`)){let e=r.querySelector(`[data-stage-fullscreen]`);e?e.focus():console.warn(`demoman editor: no full-screen button in #${r.id} to take the focus; it stays on a control that is no longer shown`)}});function wc(){let e=I.snapshot();Tc(Wt(e.scene,e.bundle,q?.timeline??null,Q.positionMs))}function Tc(e){if(e!==null){if(mn(e)){Uo=e.reason,$(I.snapshot());return}L(e)}}function Ec(e){let t=e.kind===`removeZoom`?`zoom`:`mask`,n=t=>e.kind===`removeZoom`?t.camera.some(t=>t.id===e.id):t.edits.masks.some(t=>t.id===e.id);L(e).then(()=>{let r=I.snapshot();n(r.scene)||V?.kind===t&&V.id===e.id&&(Po(null),$(r))})}function Dc(e){if(M(e),yo=e instanceof Error?e.message:String(e),ml){$(I.snapshot());return}Di(F(`failure`),{error:null,replaySentence:null,openError:yo})}function Oc(e){return e.bundle===null?{kind:`noFrames`}:{kind:`exact`}}function kc(e){let t=Ct(e.scene);return{takeId:P,authored:t,rerun:j.nav.rerun(P,t)}}function Ac(e){let t=`[demoman] editor: removed pieces — `,n=e?.timeline.cuts??[],r=e?.timeline.unplacedCuts??[];return n.length+r.length===0?`${t}none`:`${t}${[...n.map(e=>`${e.ids.join(`+`)} removed ${Math.round(e.srcStartMs)}-${Math.round(e.srcEndMs)}ms${e.trailing?` (trailing)`:``}`),...r.map(e=>`${e.ids.join(`+`)} removed nothing: ${e.reason}`)].join(`; `)}`}function $(e){ns=!1,qs(),$s(e);let t=Ac(q);t!==ds&&(ds=t,console.info(t));let n=Wr({scene:e.scene,bundle:e.bundle,resolved:q}),r=F(`name`);r.value=e.scene.meta.name,r.placeholder=Ne(e.scene.meta),F(`undo`).disabled=!e.canUndo,F(`redo`).disabled=!e.canRedo,wi(F(`banner`),{hasFrames:e.bundle!==null,route:kc(e)}),B!==null&&e.scene!==_o&&(B=null),Di(F(`failure`),{error:e.error??B,replaySentence:e.replaySentence,replayRecoverable:e.replayRecoverable,renderError:R.error,previewError:z,logoLoadError:J,wallpaperLoadError:Os??ks,openError:yo,deleteError:bo,navigationError:xo,runsRoute:kc(e)});let i=nn({scene:e.scene,view:n,bundle:e.bundle,resolved:q,hoverReport:e.hoverReport,rerunLine:kc(e).rerun});Fo=i,Io=n,Lo=i.durationMs,(G===null||Ho!==i.durationMs)&&(G=Kr(i.durationMs),Ho=i.durationMs);let a={resolved:q,bundle:e.bundle,viewport:e.scene.meta.capture.viewport},o=e=>Tc(jn(i,n,e,a)),s=e=>{G=e,$(I.snapshot())},c=e=>{Ro=e,$(I.snapshot())};Qa(F(`timeline`),i,{viewport:G,selection:V,get positionMs(){return Q.positionMs},refusal:Uo,hoverReport:e.hoverReport,snapping:Ro,openJoin:So},{onSelect:e=>{Po(e),$(I.snapshot())},onSeek:e=>Q.seek(e),onSeekStart:()=>Q.pause(),onSplit:wc,onRestorePiece:e=>{So=null,L({kind:`restorePiece`,id:e})},onOpenJoin:e=>{So=e,$(I.snapshot())},onGesture:o,onViewport:s,onSnapping:c}),Ci(F(`take-notes`),{notices:[...cs??[],...us(e)?[ls]:[],...i.notices],hoverReport:e.hoverReport}),io(F(`timeline-tools`),i,{viewport:G,snapping:Ro,get positionMs(){return Q.positionMs}},{onGesture:o,onSplit:wc,onViewport:s,onSnapping:c});let l=V;l?.kind===`piece`&&!i.clip.pieces.some(e=>Gt(e.start,l.start))&&(V=null);let u=l?.kind===`tick`&&n.beats.some(e=>e.actionId===l.actionId)||l?.kind===`zoom`&&i.zooms.some(e=>e.id===l.id)||l?.kind===`mask`&&i.masks.some(e=>e.id===l.id);H===`selection`&&!u&&(V===null&&M(Error(`the rail was on Selection with nothing selected`)),Po(null)),document.body.dataset.panel=U?`open`:`closed`,hi(F(`rail`),{rail:H,panelOpen:U,hasSelection:u},{onPick:fl}),gi(F(`export-open`),{rail:H,panelOpen:U},{onPick:fl}),_i(F(`shortcuts-open`),{rail:H,panelOpen:U},{onPick:fl});let f=document.activeElement?.matches(`[data-shortcuts-search]`)===!0;fi(F(`inspector`),{selection:V,view:n,model:i,scene:e.scene,hoverReport:e.hoverReport,viewport:e.scene.meta.capture.viewport,rail:H,sections:wo,attachedToCuts:q?.plan.attachedToCuts??[]},{onClose:pl,onGap:(e,t)=>Tc(Mn(n,e,t)),onGapClear:e=>L({kind:`clearGap`,afterActionId:e}),onKeepHover:jc,onZoomOnStep:e=>{let t=n.beats.find(t=>t.actionId===e);if(!t?.anchorId)return;let r=new Set(I.snapshot().scene.camera.map(e=>e.id));L({kind:`addZoom`,marker:{actionId:e,offsetMs:0},target:{kind:`element`,anchorId:t.anchorId},scale:S.defaultZoomScale}).then(()=>{let e=I.snapshot().scene.camera.find(e=>!r.has(e.id));e&&(Po({kind:`zoom`,id:e.id}),$(I.snapshot()))})},onZoomScale:(e,t)=>L({kind:`setZoomScale`,id:e,scale:t}),onRemoveZoom:e=>Ec({kind:`removeZoom`,id:e}),onMaskNote:(e,t)=>L({kind:`setMaskNote`,id:e,note:t}),onRemoveMask:e=>Ec({kind:`removeMask`,id:e})});let p=document.querySelector(`#inspector [data-panel-shortcuts]`);p!==null&&ha(p,{mac:Fr(navigator.userAgent),query:Bo,focus:U&&(Vo||f)},{onClose:pl,onQuery:e=>{Bo=e}}),Vo=!1,Ur(F(`stage-overlay`),{canvas:Yo,selection:V,model:i,resolved:q,presentation:Jo,target:K,outputTimeMs:Q.positionMs},{onMaskRect:(e,t)=>L({kind:`moveMask`,id:e,rect:t}),onZoomPoint:(e,t)=>L({kind:`setZoomTarget`,id:e,point:t})});let m=F(`inspector`);m.querySelector(`.inspector`)===null&&M(Error(`the inspector has not rendered anything`));let h={export:`export`,branding:`background`,cursor:`cursor`},g=e=>{let t=m.querySelector(`[data-panel-${e}]`);return t===null&&H===h[e]&&U&&M(Error(`the inspector's ${e} panel is missing`)),t},_=g(`branding`);_&&Oi(_,{branding:e.scene.branding,logoThumb:Js(e.scene.branding.logo?.ref??null),logoPlacement:Jo?.logoPlacement??null,formatTitle:Ke(Eo(),e.scene.canvas.aspect),logoNotes:vo,wallpaper:{thumbUrl:ze,custom:Ys(e.scene.branding.background),loadError:null},kit:{read:N,standing:co(e.scene.branding),naming:so,onApply:e=>{let t=N.state===`ready`?N.kits.find(t=>t.id===e):void 0;if(t?.read.state!==`ready`){B=t===void 0?`That brand kit was not applied: it was deleted in another tab.`:`That brand kit was not applied: ${t.read.reason}.`,_o=I.snapshot().scene,$(I.snapshot());return}oo=e;let{background:n,logo:r,padding:i}=t.read.kit;L({kind:`setBranding`,patch:{background:n,logo:r,padding:i}}),$(I.snapshot())},onUpdate:()=>void Pc(),onStartNew:()=>{so={text:``,error:null},$(I.snapshot())},onNameInput:e=>{so!==null&&(so={text:e,error:null})},onConfirmNew:e=>void Fc(e),onCancelNew:()=>{so=null,$(I.snapshot())}}},{onCommit:e=>L({kind:`setBranding`,patch:e}),onPreview:Ps,onLogoFile:e=>Mc(e).catch(M),onWallpaperFile:e=>Nc(e).catch(M)});let v=g(`cursor`);v&&Vi(v,Rs(e.scene),zs(e.scene),{onCursor:e=>{qs(),L({kind:`setCursor`,patch:e})},onCursorPreview:Hs,onCursorPreviewEnd:Gs,onMotion:e=>{qs(),L({kind:`setMotion`,patch:e})},onMotionPreview:Us,onMotionPreviewEnd:Ws},e.scene.meta.capture.device?.touch===!0);let y=W(e.bundle),ee=g(`export`);ee&&Ji(ee,{outputs:Wo,fileTypes:To,files:R.files,quality:ko(),aspect:e.scene.canvas.aspect,targets:{mp4:W(e.bundle,`mp4`),gif:W(e.bundle,`gif`),stills:W(e.bundle,`stills`)},recording:ce(e.bundle,d(e.scene)),durationMs:i.clip.trim.tailMs-i.clip.trim.headMs,run:R.run,save:R.save,revealError:mo,repo:Wc(),readiness:Oc(e),runsRoute:kc(e),currentDigest:Mo(e.scene),sections:wo,beatAt:At(n.beats),hasReclaimedMotion:e.bundle?.degradations.some(e=>e.kind===`motionReclaimed`)??!1},{onExport:()=>Ic().catch(M),onFileType:yc,onRetry:e=>Ic([e]).catch(M),onQuality:vc,onSaveAgain:e=>Lc(e).catch(M),onReveal:Fs,onAddToRepo:()=>void Jc().catch(M),onRemoveFromRepo:()=>void Yc().catch(M)}),hc=n.hasBundle,Z=i.clip.trim.headMs,mc=i.clip.trim.tailMs,Is(e,y),ba(F(`take-info`),{recordedAt:e.scene.meta.createdAt,site:e.scene.meta.capture.originUrl,durationMs:i.clip.trim.tailMs-i.clip.trim.headMs,steps:n.beats.length,recording:ce(e.bundle,d(e.scene)),target:y,aspect:e.scene.canvas.aspect,takeId:P,revealError:mo,history:{outputs:Wo,currentDigest:Mo(e.scene),showAll:Ko,warningsOpen:qo,reportContext:{beatAt:At(n.beats),runsRoute:kc(e)}}},{onCopy:e=>navigator.clipboard.writeText(e),onDownload:e=>Lc([e]).catch(M),onReveal:Fs,onShowAll:()=>{Ko=!0,$(I.snapshot())},onWarnings:e=>{qo.delete(e)||qo.add(e),$(I.snapshot()),document.querySelector(`#take-info [data-output-warnings="${CSS.escape(e)}"]`)?.focus()}}),Q.positionMs<Z&&Q.seek(Z),Q.positionMs>mc&&Q.seek(mc),bc();let b=Rs(e.scene),x=zs(e.scene),te=JSON.stringify(e.scene.edits.removed??[]);q&&Jo&&(e.bundle!==fs||K.height!==ps||or(Ls,b)||sr(Bs,x)||cr(ms,Jo)||te!==ss)&&(fs=e.bundle,Ls=b,Bs=x,ms=Jo,ps=K.height,ss=te,Q.seek(Q.positionMs)),Qs(e).catch(M),Zs(e).catch(M)}function jc(e){let t=I.snapshot().hoverReport;if(t===null){M(Error(`kept hover "${e}" with no hover report`));return}I.setHoverReport({...t,removable:t.removable.filter(t=>t!==e)})}async function Mc(e){B=null;let t=be(e),n=e=>{B=e,_o=I.snapshot().scene,$(I.snapshot())};if(!t.ok)return n(t.reason);let i=new Uint8Array(await e.arrayBuffer());try{await r(i,e.type)}catch(t){return n(`The logo "${e.name}" could not be read as an image: ${t instanceof Error?t.message:String(t)}`)}let{ref:a}=await j.logos.put(e);ws=t.note===null?null:{ref:a,note:t.note};let o=I.snapshot().scene.branding.logo,s=o?{corner:o.corner,size:o.size,opacity:o.opacity}:oe;await I.dispatch({kind:`setBranding`,patch:{logo:{ref:a,...s}}})}async function Nc(e){B=null;let t;try{({ref:t}=await j.wallpapers.put(e))}catch(e){B=e instanceof Error?e.message:String(e),_o=I.snapshot().scene,$(I.snapshot());return}await I.dispatch({kind:`setBranding`,patch:{background:Ve(t,I.snapshot().scene.branding.background)}})}async function Pc(){let e=co(I.snapshot().scene.branding);if(e===null||!e.edited){B=e===null?`No brand kit was updated: this video is no longer on a kit.`:`No brand kit was updated: this video already matches "${e.kit.name}".`,_o=I.snapshot().scene,$(I.snapshot());return}let t=e.kit,n=`This video's background, logo and padding will replace the brand kit "${t.name}".`;try{if(!await se({glyph:`refresh`,title:`Replace "${t.name}"`,body:n,confirmLabel:`Replace`,danger:!1,focus:`confirm`}))return;let e=I.snapshot().scene.branding,r=await ao.update(n=>n.kits.some(e=>e.id===t.id)?{...n,kits:n.kits.map(n=>n.id===t.id?{...n,branding:e}:n)}:`it was deleted in another tab`);if(r!==null)throw Error(r);N=await ao.read()}catch(e){B=`The brand kit "${t.name}" was not saved: ${e instanceof Error?e.message:String(e)}`,_o=I.snapshot().scene}$(I.snapshot())}async function Fc(e){let t=N.state===`ready`?N.kits:[],n=re(e,t,null);if(!n.ok){so={text:e,error:n.reason},$(I.snapshot());return}let r=I.snapshot().scene.branding,i=y();try{let t=await ao.update(e=>{let t=re(n.name,e.kits,null);return t.ok?{kits:[...e.kits,{id:i,name:t.name,branding:r}],defaultId:e.defaultId??i}:t.reason});if(t!==null){so={text:e,error:t},$(I.snapshot());return}so=null,oo=i,N=await ao.read()}catch(e){B=`The brand kit "${n.name}" was not saved: ${e instanceof Error?e.message:String(e)}`,_o=I.snapshot().scene}$(I.snapshot())}async function Ic(e=To){mo=null;let t=I.snapshot().scene;R=Mt(e),$(I.snapshot());let n=0;try{await I.settled();let r=ko();for(let i of e)await j.exports.start(P,{fileType:i,aspect:t.canvas.aspect,revision:uo,...r===null||i!==`mp4`||Oo===null&&!Ao?{}:{quality:r}}),n+=1}catch(e){let t=e instanceof Error?e.message:String(e),r=R.files.map((e,t)=>t>=n&&e.ended===null?{...e,ended:`failed`}:e);throw R={...R,files:r,run:Nt(r)===null?{phase:`idle`}:R.run,error:R.error===null?t:`${R.error}; ${t}`},$(I.snapshot()),e}}async function Lc(e){let t=Go(),n=e.map(e=>t.find(t=>t.ref===e)),r=e.filter((e,t)=>n[t]===void 0);if(r.length>0)throw Error(`no output row for ${r.map(e=>`"${e}"`).join(`, `)}`);if(n.length===0)return;let i=j.downloads;if(i===void 0)throw Error(`this page cannot save an export again`);R={...R,save:await i.save(n)},$(I.snapshot())}var Rc=!1;function zc(){let e=document.querySelector(`[data-panel-export]`);e!==null&&!Wi(e,R.run,To,Oc(I.snapshot()),R.files)&&!Rc&&(Rc=!0,M(Error(`the Export panel has no start button, so progress cannot show`)))}var Bc=null,Vc=null,Hc=null,Uc=!1;function Wc(){let e=Bc;if(e===null)return null;let t=e.video.kept;return t!=null&&`unknown`in t?null:{inRepo:t==null?null:{file:t.file},addable:e.addable,adding:Uc,status:Vc,note:Hc}}var Gc=0;async function Kc(){if(j.folder===void 0)return;let e=++Gc,t=await j.folder.read();if(e!==Gc)return;let n=t.videoOf[P]?.videoId,r=t.videos.find(e=>e.id===n),i=n===void 0||r===void 0?null:{video:r,addable:t.addable?.[n]};JSON.stringify(i)!==JSON.stringify(Bc)&&(Vc=null,Hc=null),Bc=i,ml&&$(I.snapshot())}j.folder?.onChange(()=>void Kc().catch(M)),Kc().catch(M);var qc=e=>e.replace(/\.$/,``);async function Jc(){let e=Bc;if(Uc||e===null||e.addable?.ok===!1)return;Uc=!0,Vc=null,Hc=null;let t=null;$(I.snapshot());try{let n=await je({video:{id:e.video.id,name:e.video.name},repo:j.videos.repo,ci:j.repoCi,reveal:e=>j.files.reveal({kind:`path`,path:e})});n.failed!==void 0&&(t=`Couldn't add: ${qc(n.failed)}.`)}catch(e){console.error(`demoman editor: opening the add sheet —`,e),t=`Couldn't add: ${qc(Te(e))}.`}finally{Uc=!1}await Kc(),Vc=t,$(I.snapshot())}async function Yc(){let e=Bc?.video.kept;if(Bc===null||e==null||`unknown`in e)return;let{video:t}=Bc;Vc=null,Hc=null;let n=null,r=null;if(await se(ke(t,e.file))){try{let e=await j.videos.repo.remove(t.id);e.notes.length===0?_e(De(t.name)):r=[De(t.name),...e.notes].join(` `)}catch(e){n=`Couldn't remove: ${qc(Te(e))}.`}await Kc(),Vc=n,Hc=r,$(I.snapshot())}}function Xc(e){let t=Rt(R,e);switch(R=t.flow,t.effect){case`render`:$(I.snapshot());return;case`progress`:zc();return;case`relist`:j.outputs.list(P).then(e=>{Wo=e,$(I.snapshot())}).catch(M);return;case`none`:return}}j.exports.onEvent(Xc),j.nav.onOpen?.(e=>rl(()=>location.assign(e))),F(`name`).addEventListener(`change`,e=>{L({kind:`rename`,name:e.target.value.trim()})});var Zc=e=>()=>{let t=I.snapshot().scene;e().catch(M).then(()=>po(t))};F(`undo`).addEventListener(`click`,Zc(()=>I.undo())),F(`redo`).addEventListener(`click`,Zc(()=>I.redo()));var Qc={recording:`a video is being recorded`,rendering:`a render is running`,sharing:`a share is in progress`,replaying:`a video is being run in Runs`};function $c(e){bo=e,el()}function el(){if(ml){$(I.snapshot());return}Di(F(`failure`),{error:null,replaySentence:null,deleteError:bo,navigationError:xo})}function tl(e,t,n=``){xo=null;try{location.assign(t())}catch(t){M(t),xo={page:e,reason:`${n}${t instanceof Error?t.message:String(t)}`},el()}}function nl(e=``,t=null,n=null){let r=j.nav.library(),i=n===null||n===``?r:`${r}${r.includes(`?`)?`&`:`?`}from=${encodeURIComponent(n)}`;tl(`Flows page`,()=>Ce(i,t),e)}function rl(e){(async()=>{let t=null,n=I.subscribe(e=>{t=e});try{await I.settled()}finally{n()}t?.error??e()})()}F(`back`).addEventListener(`click`,()=>{rl(()=>nl(``,null,P))}),F(`take-info`).addEventListener(`toggle`,e=>{F(`take-meta`).setAttribute(`aria-expanded`,String(e.newState===`open`))}),F(`delete`).addEventListener(`click`,()=>{(async()=>{try{if(!await se(ue))return}catch(e){M(e),$c(`Not deleted: the confirmation could not open — ${e instanceof Error?e.message:String(e)}.`);return}bo=null;let e;try{e=await j.scenes.remove(P)}catch(e){M(e),$c(`Not deleted: ${e instanceof Error?e.message:String(e)}.`);return}if(!e.ok){$c(`Not deleted: ${Qc[e.error]??e.detail??e.error}.`);return}if(e.result!==void 0&&!e.result.ok){let t=e.result.steps.find(e=>!e.ok);$c(`Partly deleted: ${t?.step??`a step`} could not be removed — ${t?.error??`unknown error`}. Open Flows to retry.`);return}let t=e.note??null;nl(t===null?`This video was deleted. `:`This video was deleted. ${t} `,t===null?Pe:`This video was deleted. ${t}`)})()});var il=Symbol.for(`demoman.editor.keydown`),al=globalThis,ol=al[il];ol instanceof AbortController&&ol.abort();var sl=new AbortController;al[il]=sl;var cl=!1,ll=null;document.addEventListener(`pointerdown`,()=>{cl=!0},{capture:!0,signal:sl.signal}),document.addEventListener(`pointerdown`,()=>{So!==null&&(So=null,$(I.snapshot()))},{signal:sl.signal}),document.addEventListener(`keydown`,()=>{cl=!1},{capture:!0,signal:sl.signal}),document.addEventListener(`focusin`,e=>{ll=cl?e.target:null},{signal:sl.signal});var ul=new WeakMap;document.addEventListener(`focusin`,e=>{let t=e.target;(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&ul.set(t,t.value)},{signal:sl.signal}),document.addEventListener(`change`,e=>{let t=e.target;(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&ul.set(t,t.value)},{capture:!0,signal:sl.signal}),document.addEventListener(`keydown`,e=>{if(document.querySelector(`dialog[open]`)!==null)return;if(e.key===`Escape`&&So!==null){e.preventDefault(),So=null,$(I.snapshot());return}if(e.key===`Escape`&&document.querySelector(`:popover-open`)!==null)return;let t=e.target,n=t?.tagName;if(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t?.isContentEditable===!0){if(e.key===`Escape`&&t?.matches(`[data-shortcuts-search]`)!==!0){if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){let e=ul.get(t);e!==void 0&&t.value!==e&&(t.value=e)}t?.blur()}return}let r=e.key===`Enter`||e.key===` `&&t!==ll;if((n===`BUTTON`||n===`A`)&&r&&t?.hasAttribute(`data-tick`)!==!0)return;let i=I.snapshot(),a=Dr(e,{hasSelection:V!==null,selectionIsBeat:V?.kind===`tick`,canUndo:i.canUndo,canRedo:i.canRedo,panelOpen:U,hasTimeline:G!==null&&Lo>0});a!==null&&(e.preventDefault(),dl(a,i))},{signal:sl.signal});function dl(e,t){switch(e.kind){case`playPause`:xc();return;case`shuttle`:z=null,Q.shuttle(e.direction);return;case`stop`:Q.stop();return;case`nudge`:Q.seek(Q.positionMs+e.deltaMs);return;case`seekEdge`:Q.seek(e.edge===`head`?Z:mc);return;case`stepBeat`:{let n=t.scene.actions.map(e=>e.id),r=V?.kind===`tick`?n.indexOf(V.actionId):-1,i=n[r===-1?e.delta>0?0:n.length-1:r+e.delta];if(i===void 0)return;Po({kind:`tick`,actionId:i}),$(t);return}case`setTrim`:{let n=Fo,r=Io;if(n===null||r===null||q===null||!hc){Uo=`This video has not been rendered yet, so there is nothing to trim to. ${kc(t).rerun}`,$(t);return}Tc(jn(n,r,{kind:`trim`,edge:e.edge,toMs:Q.positionMs,snapMs:0},{resolved:q,bundle:t.bundle,viewport:t.scene.meta.capture.viewport}));return}case`split`:wc();return;case`undo`:Zc(()=>I.undo())();return;case`redo`:Zc(()=>I.redo())();return;case`deleteSelection`:if(V===null)return;if(V.kind===`zoom`){Ec({kind:`removeZoom`,id:V.id});return}if(V.kind===`mask`){Ec({kind:`removeMask`,id:V.id});return}if(V.kind===`piece`){Tc(Kt(Fo?.clip.pieces??[],V.start,Fo?.clip.trim));return}Tc({kind:`refusal`,reason:`A step can't be deleted. To take it out of the video, split the clip around it and remove that piece.`});return;case`zoomTimeline`:{if(G===null)return;let n=Math.min(1,Math.max(0,k(G,Q.positionMs)));G=Yr(G,Lo,e.factor,n),$(t);return}case`zoomFit`:G=Kr(Lo),$(t);return;case`toggleSnapping`:Ro=!Ro,$(t);return;case`clearSelection`:Po(null),$(t);return;case`toggleHelp`:fl(`shortcuts`);return;case`closePanel`:pl();return}}function fl(e){H===e&&U?U=!1:(H=e,U=!0,e===`shortcuts`&&(Vo=!0)),e!==`selection`&&(Co=e),$(I.snapshot())}function pl(){U=!1,$(I.snapshot())}da(),ii(),document.body.dataset.zoom=`fit`;{let e=F(`notes`),t=``,n=()=>{pa(F(`notes-open`),e),t=ma(e,t)};new MutationObserver(n).observe(e,{childList:!0,subtree:!0,characterData:!0}),n()}var ml=!1;I.subscribe(e=>{ml=!0,yo=null,$(e)}),I.subscribe(e=>gs(e).catch(M));async function hl(){N=await ao.read(),ml&&$(I.snapshot())}hl().catch(M),ao.onChange===void 0?console.info(`demoman: no storage change feed here, so the brand kit is read once`):ao.onChange(()=>{hl().catch(M)});async function gl(){let e=j.exportQuality;if(e===void 0)return;let t=await e.read();Ao=t.unreadable===void 0,t.unreadable!==void 0&&console.info(`demoman editor: the Studio exports at ${a[t.quality]} quality: ${t.unreadable}`),t.quality!==Do&&(Do=t.quality,ml&&$(I.snapshot()))}j.exportQuality!==void 0&&(gl().catch(M),window.addEventListener(`focus`,()=>{gl().catch(M)})),j.outputs.list(P).then(e=>{Wo=e,ml&&$(I.snapshot())}).catch(M),I.load().catch(Dc);
@@ -2161,8 +2161,6 @@
2161
2161
  transition: transform 120ms ease;
2162
2162
  }
2163
2163
  .inspector details[data-section][open] > summary::before { transform: rotate(45deg); }
2164
- .inspector a[data-runs-route] { color: var(--ink-muted); font-weight: 600; text-decoration: none; }
2165
- .inspector a[data-runs-route]:hover { color: var(--ink); text-decoration: underline; }
2166
2164
  /* An exported output and a shareable one are both a label beside a
2167
2165
  button. Without a rule they were two inline boxes touching, with the
2168
2166
  file size running straight into "Download". */
@@ -2536,8 +2534,6 @@
2536
2534
  #take-info .beat .nowrap { white-space: nowrap; }
2537
2535
  #take-info .notice { margin: 0; background: var(--control); font-size: 12.5px; }
2538
2536
  #take-info [data-history-all] { align-self: stretch; justify-content: center; margin: 4px 10px 8px 14px; }
2539
- #take-info a[data-runs-route] { color: var(--ink-muted); font-weight: 600; text-decoration: none; }
2540
- #take-info a[data-runs-route]:hover { color: var(--ink); text-decoration: underline; }
2541
2537
  /* A history row: the name and its chip, the way to the file, then one
2542
2538
  quiet line of its size and time. */
2543
2539
  #take-info .output-head { display: flex; align-items: center; gap: 6px; min-width: 0; }