demoman 0.9.4 → 0.9.6

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.
@@ -1,4 +0,0 @@
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 ue,n as de,nt as fe,ot as pe,p as me,pt as he,rt as ge,st as _e,t as ve,tt as ye,vt as be,w as xe,wt as Se,z as Ce}from"./toast-D-n2UDmc.js";import{C as we,T as Te,b as Ee,f as De,h as Oe,l as ke,m as Ae,o as je,p as Me,s as Ne,w as Pe,x as Fe}from"./state-nRiGhQ0_.js";import{A as Ie,C as Le,D as Re,E as ze,O as Be,S as Ve,T as He,_ as Ue,a as We,b as Ge,c as Ke,d as qe,f as Je,g as Ye,h as Xe,k as Ze,l as Qe,m as $e,o as C,p as et,s as tt,u as nt,v as rt,w as it,x as at,y as ot}from"./view-BAVIEhJQ.js";function st(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 ct=64;function lt(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 ut(e,t,n,r){let i=[];for(let a of st(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(ct,Math.round(a.rect.width))),u=Math.max(1,Math.min(ct,Math.round(a.rect.height))),d;try{d=c(lt(e,a.rect,t.viewport,l,u),lt(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 dt(e){return S.neutral.zoomHoldMs+ee(e).zoomOutMs}dt(ie.smoothness);var ft=Math.abs(S.leadInMs)+S.neutral.minPlateauMs+400;function pt(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 ${ft}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 ${mt}x).`;case`textTooWide`:return`${t}: target too wide to zoom without cutting text (would be ${e.scale}x, floor ${mt}x).`}}S.fitMarginPx;var mt=1.2,ht=1e4,gt=`__demomanClickProbe`;`${gt}${JSON.stringify(`__demomanClickSeen`)}`,`${gt}`,`${gt}`,globalThis.process?.platform;var _t={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 ${ht/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 vt(e){return e in _t?_t[e]:e}function yt(e){if(!e)return`(navigation)`;let t=e.fingerprint;return t.accessibleName??t.textContent??t.stableId??t.dataKey??e.id}function bt(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:yt(e.anchors.find(e=>e.id===n.anchorId))}:null}function xt(e,t){return bt(e,t)}function St(e){return e.meta.capture.mode===`authored`}function Ct(e){return e?`run its script again in Runs`:`re-shoot it in Runs`}var wt=`motion reclaimed to free space`;function Tt(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]=Dt(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 Et(e,t=2){return String(Number(e.toFixed(t)))}function Dt(e,t){for(let n=2;n<4;n++)if(Et(e,n)!==Et(t,n))return[Et(e,n),Et(t,n)];return[Et(e,4),Et(t,4)]}function Ot(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=>Tt(e,t))}}function kt(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 At={run:{phase:`idle`},files:[],save:null,error:null};function jt(e){return{run:{phase:`encoding`,done:0,total:0},files:e.map(e=>({fileType:e,jobId:null,ended:null})),save:null,error:null}}function Mt(e){return e.find(e=>e.ended===null)??null}var Nt=(e,t)=>e===null?t:`${e}; ${t}`;function Pt(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 Ft(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 It(e,t,n){let r=e.map((e,r)=>r===t?{...e,ended:n}:e);return{files:r,run:Mt(r)===null?{phase:`idle`}:{phase:`encoding`,done:0,total:0}}}function Lt(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}=Pt(e.files,t.jobId),a=Mt(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:Nt(e.error,t.line)},effect:`none`};case`saving`:return{flow:{...e,files:r,run:{phase:`saving`}},effect:`render`};case`saved`:return{flow:{...e,...It(r,i,`saved`),save:Ft(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?``:`${Qe[n.fileType]}: `;return{flow:{...e,...It(r,i,`failed`),error:t.detail===null?e.error:Nt(e.error,`${a}${t.detail}`)},effect:`render`}}}}function Rt(e){return e?`Run its script again in Runs`:`Re-shoot this video in Runs`}function zt(e){let t=Ct(e);return t.charAt(0).toUpperCase()+t.slice(1)}function Bt(e){return e.rerun.kind===`line`?e.rerun.text:null}function Vt(e,t,n){return t??`${zt(e)} ${n}.`}var w=1,T=e=>({kind:`refusal`,reason:e});function Ht(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 Ut(e){return new Map(e.markers.map(e=>[e.actionId,e.sourceTimeMs]))}function Wt(e,t,n){return Gt(e,_e(t,n))}function Gt(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 Kt(e,t,n){let r=Ut(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=Ht(t,e=>c(e.start,-1/0)),u=Ht(t,e=>-c(e.end,1/0));if(l===void 0||u===void 0)continue;let d=pe(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:pe(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)<w).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=pe(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<w||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 qt(e,t,n,r){if(t===null||n===null)return T(`Nothing has rendered yet, so there is no frame to split at.`);if(r<=0||r>=n.outputDurationMs)return T(`A split at the video's start or end splits nothing.`);let i=Wt(t,n,r);if(i===null)return T(`These frames name no step, so there is nothing to split by.`);let a=Ut(t).get(i.actionId)??0,o=pe(n,a+i.sourceOffsetMs),{pieces:s}=Kt(e,t,n);return o<=w||o>=n.outputDurationMs-w||s.some(e=>Math.abs(e.startMs-o)<w)?T(Math.abs(o-r)<w?`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 Jt=(e,t)=>e===null||t===null?e===t:e.actionId===t.actionId&&e.sourceOffsetMs===t.sourceOffsetMs;function Yt(e,t,n){let r=e.find(e=>Jt(e.start,t));if(r===void 0)return T(`That piece is no longer on the timeline.`);if(e.length===1)return T(`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+w&&e.startMs<n.tailMs-w;if(t(r)&&e.filter(t).length===1)return T(`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 Xt(e,t,n,r,i,a){let o=n.find(e=>Jt(e.start,r));if(o===void 0)return T(`That piece is no longer on the timeline.`);if(e===null||t===null)return T(`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 T(`This piece is as short as a piece can be.`);let r=Wt(e,t,n);return r===null?T(`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 T(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-w:u<=l.srcStartMs+w)return{kind:`restorePiece`,id:l.removedId};let d=Gt(e,u);return d===null?T(`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 Zt=1e3;function Qt(e,t){return`Motion reclaimed to free space. ${Vt(e,t,`to restore`)}`}var $t=new Set([`Motion reclaimed to free space. Replay to restore.`,`Motion reclaimed to free space. Rebuild to restore.`]);function en(e,t,n,r){return e===`motionReclaimed`?$t.has(t)||t===`Motion reclaimed to free space. Re-shoot it in Runs to restore.`?Qt(n,r):t:`${e}: ${t}`}var tn=(e,t)=>e.hasBundle?t.outputMs??t.captureMs:t.captureMs;function nn(e){return e.hasBundle&&e.outputDurationMs!==null?e.outputDurationMs:(e.beats[e.beats.length-1]?.captureMs??0)+Zt}var rn=e=>({actionId:e.actionId,offsetMs:e.sourceOffsetMs});function an(e,t){let n=e.beats.find(e=>e.actionId===t.actionId);return(n?tn(e,n):0)+t.offsetMs}function on(e){let{scene:t,view:n,bundle:r,resolved:i}=e,a=St(t),o=e.rerunLine??null,s=e=>Vt(a,o,e),c=nn(n),l=[],u=new Set(e.hoverReport?.removable??[]),d=new Map(n.beats.map(e=>[e.actionId,tn(n,e)])),f=new Map(n.beats.map(e=>[e.actionId,e.timing])),p=e=>i===null?`estimated`:e?f.get(e.actionId)??`estimated`:`rendered`,m=n.beats.map(e=>({actionId:e.actionId,atMs:d.get(e.actionId)??0,verb:e.verb,label:e.label,timing:e.timing,flag:u.has(e.actionId)?`unchangedHover`:null,canZoom:e.canZoom,cut:e.cut})),h=t.edits.trim,g=i?{headMs:i.range.startMs,headTiming:i.trimUnplaced.includes(`head`)?`estimated`:`rendered`,tailMs:i.range.endMs,tailTiming:i.trimUnplaced.includes(`tail`)?`estimated`:`rendered`,headMarker:h?.head??null,tailMarker:h?.tail??null}:{headMs:h?.head?Math.max(0,an(n,h.head)):0,headTiming:h?.head?`estimated`:`rendered`,tailMs:h?.tail?Math.min(c,an(n,h.tail)):c,tailTiming:h?.tail?`estimated`:`rendered`,headMarker:h?.head??null,tailMarker:h?.tail??null};for(let e of i?.trimUnplaced??[])l.push(`The trim's ${e} is placed from the video's own timestamp: the last render carried no marker for its step. ${s(`to give it measured timing`)}`);for(let e of i?.timeline.unplacedCuts??[])l.push(`A removed piece removed no frames: ${e.reason}.`);let _=new Set((i?.clampedRanges??[]).filter(e=>e.kind===`zoom`).map(e=>e.id));for(let e of i?.clampedRanges??[])l.push(e.note);let v=new Map((i?.cameraSegments??[]).map(e=>[e.id,e])),{smoothness:y}=t.motion??ie,b=dt(y),{zoomInMs:x}=ee(y),te=new Set,ne=t.camera.flatMap(e=>{let t=e.scale??1;if(t<=1)return[];let r=v.get(e.id);r||te.add(e.id);let i=r?r.startMs:Math.max(0,an(n,e.marker)),a=r?r.endMs:Math.min(c,e.end?an(n,e.end):i+b),o=e.point?{kind:`point`,x:e.point.x,y:e.point.y}:{kind:`element`,anchorId:e.anchorId??``};return r?.endUnplaced&&l.push(`The end of zoom "${e.id}" is placed from the video's own timestamp: the last render carried no marker for its step. ${s(`to give it measured timing`)}`),[{id:e.id,actionId:e.marker.actionId,departMs:r?.departMs??i,startMs:i,endMs:a,drawnEndMs:a,endAuthored:e.end!==void 0,scale:t,target:o,aimFallback:e.note??null,timing:r?r.endUnplaced?`estimated`:p(e.marker):`estimated`,clamped:_.has(e.id),marker:e.marker,endMarker:e.end??null}]}),re=ne.map(e=>{if(!te.has(e.id))return e;let t=Math.min(...ne.map(e=>e.startMs).filter(t=>t>e.startMs));return e.endMs>t?{...e,endMs:t}:e}),ae=re.map(e=>te.has(e.id)?{...e,departMs:sn(re,e.startMs,x)}:e),oe=ae.map(e=>({...e,drawnEndMs:cn(ae,e.startMs,e.endMs)})),se=new Set(t.camera.map(e=>e.marker.actionId));for(let e of t.zoomsSkipped??[])se.has(e.actionId)||`afterActionId`in e&&!se.has(e.afterActionId)||l.push(pt(e));let S=new Map((i?.cosmetics??[]).map(e=>[e.id,e])),ce=t.edits.masks.map(e=>{let t=e.start===void 0||e.end===void 0,r=S.get(e.id),a=r?.range??null;for(let t of r?.unplaced??[])l.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. ${s(`to give it measured timing`)}`);let o=t?0:a?a.startMs:e.start?Math.max(0,an(n,rn(e.start))):0,u=t?c:a?a.endMs:e.end?Math.min(c,an(n,rn(e.end))):c;return{id:e.id,startMs:o,endMs:u,rect:e.rect,wholeTake:t,timing:t||i&&a&&p(e.start)===`rendered`&&p(e.end)===`rendered`?`rendered`:`estimated`,startMarker:e.start??null,endMarker:e.end??null}}),le=e=>i?pe(i.timeline,e):e,ue=(r?.degradations??[]).map(e=>({startMs:le(e.startMs),endMs:le(e.endMs)}));for(let e of r?.degradations??[])l.push(en(e.kind,e.note,a,o));let de=i?.timeline.unplacedPaces??0;if(de>0){let e=de===1?`pause`:`pauses`;l.push(`pacingUnplaced: ${de} 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. ${s(`to restore them`)}`)}let fe=i?.timeline.nonMonotonicPaces??0;if(fe>0){let e=fe===1?`pair`:`pairs`;l.push(`pacingBackwards: ${fe} 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 ${fe===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:me,joins:he,unplacedSplits:ge}=r!==null&&i!==null?Kt(t,r,i.timeline):{pieces:[],joins:[],unplacedSplits:[]};for(let e of ge)l.push(`A split is not drawn: the last render carried no marker for its step. ${s(`to place it`)}`);return{clip:{durationMs:c,trim:g,ticks:m,degraded:ue,pieces:me,joins:he},zooms:oe,masks:ce,durationMs:c,timeSource:n.hasBundle?`rendered`:`captured`,authored:a,rerunLine:o,hoverCheck:{failed:e.hoverReport?.failed??!1,unchecked:e.hoverReport?.unchecked??0},notices:l,zoomDefaultMs:b,zoomInMs:x}}function sn(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 cn(e,t,n){return Math.min(n,...e.filter(e=>e.startMs>t).map(e=>e.departMs))}function ln(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 un(e){let{resolved:t,outputTimeMs:r,presentation:i,target:a,viewport:o}=e;return ge(t,r,n(i.frameRect,o),i.frameRect,o,a)}var dn=(e,t,n)=>Math.min(n,Math.max(t,e));function fn(e,t){let n=e.width/2,r=e.height/2;return{x:dn(t.x-n/2,0,e.width-n),y:dn(t.y-r/2,0,e.height-r),width:n,height:r}}function pn(e){let{rect:t,resolved:n,target:r,presentation:i,outputTimeMs:a}=e,o=n.plan.viewport,s=un({resolved:n,outputTimeMs:a,presentation:i,target:r,viewport:o});return p(t,s,i.frameRect,o)}function mn(e){let{rect:t,resolved:n,target:r,presentation:i,outputTimeMs:a}=e,o=n.plan.viewport,c=un({resolved:n,outputTimeMs:a,presentation:i,target:r,viewport:o}),l=s(t,c,i.frameRect,o),u=dn(l.x,0,o.width),d=dn(l.y,0,o.height),f=dn(l.x+l.width,0,o.width),p=dn(l.y+l.height,0,o.height);return{x:u,y:d,width:f-u,height:p-d}}function hn(e){let{zoom:t,resolved:n,viewport:r,presentation:i,target:a}=e,o=un({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 gn=2e3,_n=e=>e!==null&&e.kind===`refusal`,E=e=>({kind:`refusal`,reason:e});function vn(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=_e(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=ye(e.resolved.cursor,n);return r?{point:r}:{reason:`the pointer was not observed here`}}var yn=(e,t)=>e.zooms.find(e=>e.id===t),bn=(e,t)=>e.masks.find(e=>e.id===t);function xn(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=Sn(a,i,n,r);if(e)return{zoom:a,why:e}}}function Sn(e,t,n,r){let i=Math.abs(n-e.startMs);if(i<ft&&(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 Cn({zoom:e,why:t}){switch(t){case`start`:return E(`That would start it within ${ft}ms of the zoom "${e.id}" at ${wn(e.startMs)}; the camera needs ${ft}ms between two zooms to glide from one to the other.`);case`endsAfter`:return E(`That would end it after the zoom "${e.id}" starts at ${wn(e.startMs)}; a zoom can stay in until the next one, not past it.`);case`startsInside`:return E(`That would start it before the zoom "${e.id}" ends at ${wn(e.endMs)}; drag that zoom's end earlier first.`)}}var wn=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 Tn(e){let{leadInMs:t}=S;return{earliestMs:e+t,latestMs:e}}function En(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}=Tn(t);return e.zooms.find(e=>Sn(e,void 0,n,null)!==void 0||Sn(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+ft,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-ft;if(Tn(e).earliestMs<0)break;let t=a(e);if(!t)return i(e,{zoom:s,side:`before`});s=t}return E(`There is no room for a zoom here: it would run into the zoom "${o.id}" at ${wn(o.startMs)}, and there is no slot either side of it. Drag that zoom to make space, or remove one.`)}function Dn(e,t){let{trim:n}=e.clip;if(t>n.tailMs-200)return E(`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+gn,e.durationMs)}}function On(e,t,n,r){let i=ln(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(_e(t.resolved.timeline,n)-a.sourceTimeMs)}}var kn=(e,t)=>e.actionId===t.actionId&&t.sourceOffsetMs<=e.sourceOffsetMs;function An(e,t){return t!==null&&e.actionId===t.actionId&&t.offsetMs<=e.offsetMs}var jn=e=>E(`That would leave the ${e} no length; drag its end further.`),Mn=e=>E(`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 Nn(e,t){let n=e.clip.ticks,r=n.findIndex(e=>e.actionId===t);return r===-1?void 0:n[r+1]}function Pn(e,t,n,r){let{durationMs:i}=e;if(e.clip.ticks.length===0)return E(`This video has no steps to attach an edit to.`);switch(n.kind){case`pieceEdge`:return Xt(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 E(`The cut would leave nothing: the head has to stay at least 200ms before the tail.`);let r=ln(e,n.toMs,n.snapMs);return An(r,t.tailMarker)?Mn(`head`):{kind:`setTrim`,head:r}}if(n.toMs>=i)return{kind:`setTrim`,tail:null};if(n.toMs<t.headMs+200)return E(`The cut would leave nothing: the tail has to stay at least 200ms after the head.`);let r=ln(e,n.toMs,n.snapMs);return t.headMarker&&An(t.headMarker,r)?Mn(`tail`):{kind:`setTrim`,tail:r}}case`addZoom`:{let i=En(e,n.atMs);if(_n(i))return i;let{atMs:a,movedPast:o}=i,s=ln(e,a,o?0:n.snapMs),c=o?`Placed ${o.side} the zoom at ${wn(o.zoom.startMs)}: there was no room at ${wn(n.atMs)}.`:null,l=S.defaultZoomScale,u=vn(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 E(`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=yn(e,n.id);if(!t)return E(`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 E(`A zoom cannot start before the video does.`);if(a>i)return E(`A zoom cannot end after the video does.`);let o=xn(e,t.id,r,t.endAuthored?a:null);if(o)return Cn(o);let s=ln(e,r,n.snapMs),c=t.endAuthored?ln(e,a,n.snapMs):null;return An(s,c)?jn(`zoom`):{kind:`setZoomRange`,id:t.id,start:s,end:c}}case`zoomEdge`:{let t=yn(e,n.id);if(!t)return E(`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 E(`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 E(`Zooming in from there, it would land at ${wn(i)}, after its end at ${wn(t.endMs)}. Drag the end later first.`);let a=xn(e,t.id,i,null);if(a)return Cn(a);let o=ln(e,r,n.snapMs),s={...o,offsetMs:o.offsetMs+e.zoomInMs},c=t.endMarker;return An(s,c)?jn(`zoom`):{kind:`setZoomRange`,id:t.id,start:s,end:c}}if(n.toMs>i)return E(`A zoom cannot end after the video does.`);if(n.toMs<t.startMs+100)return E(`A zoom's end cannot cross its start; it would end before it starts. Drag the start earlier first.`);let r=xn(e,t.id,t.startMs,n.toMs);if(r)return Cn(r);let a=t.marker,o=ln(e,n.toMs,n.snapMs);return An(a,o)?jn(`zoom`):{kind:`setZoomRange`,id:t.id,start:a,end:o}}case`addMask`:{let t=Dn(e,n.atMs);if(_n(t))return t;let{endMs:i}=t,a=vn(r,n.atMs),o=`point`in a?a.point:{x:r.viewport.width/2,y:r.viewport.height/2},s=fn(r.viewport,o),c=On(e,r,n.atMs,n.snapMs),l=On(e,r,i,n.snapMs);if(kn(c,l)){let t=Nn(e,c.actionId);if(!t)return E(`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=bn(e,n.id);if(!t)return E(`There is no mask "${n.id}" to move.`);if(t.wholeTake||t.startMarker===null||t.endMarker===null)return E(`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 E(`A mask cannot start before the video does.`);if(o>i)return E(`A mask cannot end after the video does.`);let s=On(e,r,a,n.snapMs),c=On(e,r,o,n.snapMs);return kn(s,c)?jn(`mask`):{kind:`setMaskRange`,id:t.id,start:s,end:c}}case`maskEdge`:{let t=bn(e,n.id);if(!t)return E(`There is no mask "${n.id}" to resize.`);if(t.wholeTake||t.startMarker===null||t.endMarker===null)return E(`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 E(`A mask cannot start before the video does.`);if(n.toMs>t.endMs-100)return E(`A mask cannot start after it ends; drag its end later first.`);let i=On(e,r,n.toMs,n.snapMs),a=t.endMarker;return kn(i,a)?jn(`mask`):{kind:`setMaskRange`,id:t.id,start:i,end:a}}if(n.toMs>i)return E(`A mask cannot end after the video does.`);if(n.toMs<t.startMs+100)return E(`A mask cannot end before it starts; drag its start earlier first.`);let a=t.startMarker,o=On(e,r,n.toMs,n.snapMs);return kn(a,o)?jn(`mask`):{kind:`setMaskRange`,id:t.id,start:a,end:o}}}}function Fn(e,t,n){let r=e.beats.find(e=>e.actionId===t);return r===void 0?E(`There is no step "${t}" to pace.`):r.isLast?E(`"${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?E(`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}:E(`A pause has to be a number of milliseconds.`)}function In(e){return e.actions.map(e=>e.id).join(` `)}function Ln(e){return{bundle:e.bundle,actionIds:In(e.scene)}}function Rn(e,t){return e!==null&&t.bundle===e.bundle&&In(t.scene)===e.actionIds&&t.hoverReport!==null}var zn={removable:[],checked:0,unchecked:0,failed:!0};function Bn(e){return e.kind!==`unknown`||e.reason!==`notStyleSignalled`}function Vn(e,t){let n=e.filter(Bn).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 Hn={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 Un(e){return Object.entries(e.uncheckedBy??{}).filter(([,e])=>e>0).sort((e,t)=>t[1]-e[1]).map(([e,t])=>{let n=Hn[e];return`${t} ${t===1?n.one:n.many}`}).join(`, `)}function Wn(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=Un(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 Gn(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 Kn(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 Jn(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 Yn(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=Jn(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 Xn(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 Zn(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 D(e){let t=Math.max(0,Math.floor(e/1e3)),n=t%60;return`${Math.floor(t/60)}:${String(n).padStart(2,`0`)}`}function Qn(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 $n(e,t){let{cursor:n,branding:r,motion:i}=t;return n===e.cursor&&r===e.branding&&i===e.motion?e:{...e,cursor:n,branding:r,...i===void 0?{}:{motion:i}}}function er(e,t){return e===null||[...new Set([...Object.keys(t),...Object.keys(e)])].some(n=>t[n]!==e[n])}function tr(e,t){return e===null||e.smoothness!==t.smoothness||e.blur!==t.blur||e.follow!==t.follow}function nr(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!rt(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 rr(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 ir(){let e=new Map;return{isOpen:(t,n)=>e.get(t)??n,set:(t,n)=>{e.set(t,n)}}}var ar={attachFailed:`Couldn't record the screen, so this video has no motion`,debuggerDetached:`The video stopped partway through`,debuggerLost:`The video stopped and couldn't restart`,debuggerRecovered:`A stretch in the middle is missing`,workerRestarted:`The extension restarted mid-recording, so this video has no motion`,noKeyframes:`Nothing could be photographed, so there's no video`,screencastUnavailable:`Motion couldn't be recorded, so this video is stills`,muxFailed:`The motion couldn't be encoded, so this video is stills`,muxUnavailable:`There was nowhere to encode the motion, so this video is stills`,budgetSpent:`The video outran its motion budget, so the rest is stills`,credentialSuspended:`Motion paused while you typed in a password field`,motionIncomplete:`Some motion couldn't be saved, so parts are stills`,motionInterrupted:`Motion was interrupted, so parts are stills`,spansDiscarded:`Some motion couldn't be encoded, so those moments are stills`,storageRefused:`This video's frames couldn't be saved — free up space and record it again`,bundleInvalid:`This video couldn't be put together`},or={canceled_by_user:`you cancelled it on the debugging bar`,target_closed:`the page was replaced`,replaced_with_devtools:`DevTools took the tab`,render_process_gone:`the page crashed`},sr=new Set([`debuggerDetached`,`debuggerLost`,`debuggerRecovered`]),cr=e=>Object.hasOwn(or,e)?or[e]:e;function lr(e){let t=ar[e];if(t!==void 0)return t;let n=e.indexOf(`:`);if(n>0){let t=e.slice(0,n),r=ar[t],i=e.slice(n+1);if(r!==void 0&&i!==``)return`${r} — ${sr.has(t)?cr(i):i}`}return e}function ur(e){if(e.reason==null)return null;let t=e=>`${e>0?Math.max(1,Math.round(e/1e3)):0}s`,n=e.coveredMs>0?` (${t(e.coveredMs)} of ${t(e.takeMs)} recorded)`:``;return`${lr(e.reason)}${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=vt(e.reason),i=n!==void 0&&St(n),a=i?`The script run`:`The re-shoot`,o=i?`performed`:`reconstructed`,s=n?xt(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 ${Ct(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 O(e,t){let n=e.actions.findIndex(e=>e.id===t);if(n===-1)throw Error(`unknown action "${t}"`);return n}function mr(e,t){let n=e.camera.find(e=>e.id===t);if(!n)throw Error(`unknown zoom "${t}"`);return n}var hr=1,gr=e=>Error(`1:1 is not a zoom — remove the zoom instead of authoring ${e}`);function _r(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 gr(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=mr(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=mr(e,t.id);if(t.scale<=1)throw gr(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=mr(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=mr(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<hr||t.rect.height<hr)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:Ye(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 vr(e,t,n){return be.parse(_r(e,t,n))}function yr(e){return{scene:e,past:[],future:[],error:null,dirty:!1,hoverReport:null}}function br(e,t,n){let r;try{r=vr(e.scene,t,n)}catch(t){return{...e,error:t instanceof Error?t.message:String(t)}}return t.kind===`setBranding`&&ot(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 xr(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 Sr(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 Cr(e){return{...e,dirty:!1}}var wr={mayReplay:!0};function Tr(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 Er(e,t){return e.meta===void 0||e.flags===void 0?!1:Tr(e)===Tr(t)}function Dr(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(Tr(e)),JSON.parse(Tr(t)),`scene`)}function Or(e,t){let{renderMode:n,...r}=e.meta;return{...e,meta:t.meta.renderMode===void 0?r:{...r,renderMode:t.meta.renderMode}}}function kr(e,t){return{...Or(e,t),flags:{...e.flags,hoverSensitive:t.flags.hoverSensitive}}}function Ar(e){let t=yr({}),n=null,r=null,i=null,a=null,o=new Set,s=Promise.resolve(),c=e=>{let t=s.then(e,e);return s=t.catch(()=>{}),t},l=()=>({scene:t.scene,bundle:n,madeFrom:n?.madeFrom??null,replaySentence:pr(i,wr,t.scene),replayRecoverable:fr(i),captureSentence:a===null||n!==null&&n.source!==`capture`?null:ur(a),error:t.error,canUndo:t.past.length>0,canRedo:t.future.length>0,hoverReport:t.hoverReport}),u=()=>{let e=l();for(let t of o)t(e)},d=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=Or(i,n),await e.saveScene(i),r=i.meta.name,i};return{load:()=>c(async()=>{let o=await e.loadScene(e.sceneId),s=await e.bundles.active(e.sceneId);n=s.bundle,i=s.replay,a=s.capture;let c=Er(t.scene,o);!c&&(t.past.length>0||t.future.length>0)&&console.info(`[demoman] editor: undo history cleared on re-read — the document changed at ${Dr(t.scene,o)}`),t=c?{...yr(o),past:t.past.map(e=>kr(e,o)),future:t.future.map(e=>kr(e,o))}:yr(o),r=o.meta.name,u()}),snapshot:l,subscribe(e){return o.add(e),()=>o.delete(e)},async dispatch(n){await c(async()=>{let r=t,i=br(t,n,e.newId);if(i.scene===r.scene){t=i,u();return}t=i;try{t={...t,scene:await d(t.scene)}}catch(e){t={...r,error:e instanceof Error?e.message:String(e)},u();return}t=Cr(t),u()})},async undo(){await c(async()=>{let e=xr(t);if(e.scene===t.scene)return;let n=t;t=e;try{t={...t,scene:await d(t.scene)}}catch(e){t={...n,error:e instanceof Error?e.message:String(e)},u();return}t=Cr(t),u()})},async redo(){await c(async()=>{let e=Sr(t);if(e.scene===t.scene)return;let n=t;t=e;try{t={...t,scene:await d(t.scene)}}catch(e){t={...n,error:e instanceof Error?e.message:String(e)},u();return}t=Cr(t),u()})},async settled(){let e;do e=s,await e;while(e!==s)},setHoverReport(e){t={...t,hoverReport:e},u()}}}var jr=1.2;function Mr(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:jr}:null:n===`-`||n===`_`?t.hasTimeline?{kind:`zoomTimeline`,factor:1/jr}: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 Nr={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`}},Pr=(e,t)=>typeof e==`string`?e:t?e.mac:e.other;function Fr(e,t){let n=Nr[e];return n===void 0?e:Pr(n.label,t)}var Ir=new Set([`⌘`,`⇧`,`⌫`,`←`,`→`,`↑`,`↓`]);function Lr(e){return Ir.has(e)}function Rr(e,t){let n=Nr[e];return n===void 0?e:Pr(n.spoken,t)}function zr(e,t){return e.map(e=>Rr(e,t)).join(` plus `)}function Br(e){return/\bMac/i.test(e)}function Vr(e,t){return Pr(e.description,t)}var Hr=[{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 Ur(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 Wr=[`nw`,`n`,`ne`,`e`,`se`,`s`,`sw`,`w`],Gr=3;function Kr(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 qr(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 Jr(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=Ur(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=C(`div`,`overlay`);a.setAttribute(`data-overlay`,`mask`);let c=pn({rect:i.rect,...s});Kr(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)>Gr&&(l=!0),c=qr(r,t,(n.clientX-e.clientX)/o.scale,(n.clientY-e.clientY)/o.scale),Kr(a,c,o)},d=()=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),l&&n.onMaskRect(i.id,mn({rect:c,...s}))};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d)})};l(a,`body`);for(let e of Wr){let t=C(`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=C(`div`,`overlay`);l.setAttribute(`data-overlay`,`zoom`);let u=pn({rect:hn({zoom:c,resolved:i,viewport:i.plan.viewport,presentation:a,target:t.target}),...s});Kr(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)>Gr&&(r=!0),u=qr(t,`body`,(n.clientX-e.clientX)/o.scale,(n.clientY-e.clientY)/o.scale),Kr(l,u,o)},a=()=>{if(window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,a),!r)return;let e=mn({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 Yr(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)||Se(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:yt(_),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?pe(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 Xr=(e,t,n)=>Math.min(n,Math.max(t,e)),Zr=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 $r(e,t,n,r){let i=Math.max(250,r),a=Xr(n,250,i),o=Xr(e-t*a,0,i-a);return{startMs:o,endMs:o+a}}function ei(e,t,n,r){return $r(Qr(e,r),r,(e.endMs-e.startMs)/n,t)}function ti(e,t,n){let r=e.endMs-e.startMs;return $r(e.startMs+n,0,r,t)}var ni=(e,t,n,r)=>$r(Qr(e,r),r,n,t);function ri(e,t){let n=Math.max(250,e);return n*(250/n)**Xr(t,0,1)}function ii(e,t){let n=Math.max(250,e);if(n<=250)return 0;let r=Xr(t,250,n);return Math.log(r/n)/Math.log(250/n)}function ai(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 oi(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=Br(navigator.userAgent);e.setAttribute(`aria-keyshortcuts`,n.map(e=>ai(e,r)).join(`+`))}function si(e){delete e.dataset.tip,delete e.dataset.tipKeys,e.removeAttribute(`aria-keyshortcuts`)}var ci=Symbol.for(`demoman.tooltip`);function li(e=document){let t=e,n=t[ci];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[ci]={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=Br(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=Fr(n,r),a=e.createElement(`kbd`);a.className=`keycap`,a.textContent=i,Lr(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 ui(){let e=C(`div`,`demo-panel`);e.setAttribute(`data-export-panel`,``),e.append(C(`h2`,void 0,`Export`));let t=C(`div`);return t.setAttribute(`data-panel-export`,``),e.append(t),e}function di(){let e=C(`div`,`demo-panel`);e.setAttribute(`data-background-panel`,``),e.append(C(`h2`,void 0,`Background`));let t=C(`div`);return t.setAttribute(`data-panel-branding`,``),e.append(t),e}function fi(){let e=C(`div`,`demo-panel`);e.setAttribute(`data-shortcuts-panel`,``),e.append(C(`h2`,void 0,`Keyboard shortcuts`));let t=C(`div`);return t.setAttribute(`data-panel-shortcuts`,``),e.append(t),e}function pi(){let e=C(`div`,`demo-panel`);e.setAttribute(`data-cursor-panel`,``),e.append(C(`h2`,void 0,`Cursor`));let t=C(`div`);return t.setAttribute(`data-panel-cursor`,``),e.append(t),e}function mi(e,t,n){let r=C(`div`,`beat-panel`);r.setAttribute(`data-step-panel`,e.actionId);let i=C(`h2`);if(i.append(C(`span`,`verb`,e.verb),` `,e.label),e.strategy){let t=C(`span`,`chip`,e.strategy);t.setAttribute(`data-health`,e.strategy),i.append(` `,t)}r.append(i);let a=C(`div`);if(e.verb===`type`){if(e.redacted)a.append(C(`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=C(`div`,`control-row`),n=C(`span`,void 0,e.text??``);n.setAttribute(`data-typed-text`,e.actionId),t.append(C(`span`,`control-label`,`Typed text`),n),a.append(t)}}e.timing===`estimated`&&a.append(C(`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=C(`div`,`control-actions`);if(!e.canZoom)o.append(C(`span`,`muted`,`No zoom — nothing on screen to aim at`));else{let t=C(`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=C(`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=C(`label`,`control-row`),i=C(`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=C(`span`,`control-inline`);if(a.append(i,C(`span`,void 0,`ms`)),e.gap!==null&&a.append(s()),t.append(C(`span`,`control-label`,`Pause after this step`),a),r.append(t),e.gap!==null&&e.gap.durationMs>0&&e.renderedPaceFreezeMs===0){let t=C(`div`);t.setAttribute(`data-gap-floored`,e.actionId),t.append(C(`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=C(`div`);t.setAttribute(`data-gap-inert`,e.actionId),t.append(C(`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=C(`div`);i.setAttribute(`data-legacy-hold`,e.actionId),i.append(C(`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=C(`div`);n.setAttribute(`data-cut-panel`,e.actionId),n.append(C(`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=C(`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=C(`div`,`control-actions`);if(t.hoverReport?.removable.includes(e.actionId)??!1){let t=C(`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 hi(e,t,n){let r=C(`div`,`zoom-panel`);r.setAttribute(`data-zoom-panel`,e.id),r.append(C(`h2`,void 0,`Zoom`));let i=C(`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`),tt(i),i.addEventListener(`input`,()=>tt(i)),i.addEventListener(`change`,()=>n.onZoomScale(e.id,Number(i.value)));let a=C(`div`,`slider-row`);a.append(C(`span`,`control-label slider-label`,`Level`),C(`span`,`slider-value`,`${e.scale.toFixed(2)}x`),i),r.append(a);let o=C(`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?yt(r):n}`}else o.textContent=`Aims at the cursor at ${D(e.startMs)}`;if(r.append(o),e.aimFallback!==null){let t=C(`div`,`muted`,e.aimFallback);t.setAttribute(`data-zoom-fallback`,``),r.append(t)}let s=C(`div`);s.setAttribute(`data-zoom-range`,``),s.textContent=`${D(e.startMs)} to ${D(e.endMs)}${e.endAuthored?``:` (end automatic; drag its cap to set one)`}`,r.append(s),e.clamped&&r.append(C(`div`,`muted`,`The end you set could not be reached; see the note under the timeline.`)),e.timing===`estimated`&&r.append(C(`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=C(`button`,`btn btn-quiet`,`Remove zoom`);c.type=`button`,c.setAttribute(`data-remove-zoom`,e.id),oi(c,`Remove zoom`,[`Delete`]),c.addEventListener(`click`,()=>n.onRemoveZoom(e.id));let l=C(`div`,`control-actions`);return l.append(c),r.append(l),r}function gi(e,t,n){let r=C(`div`,`mask-panel`);r.setAttribute(`data-mask-panel`,e.id),r.append(C(`h2`,void 0,`Mask`));let i=C(`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=C(`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=C(`label`,`control-row`);o.append(C(`span`,`control-label`,`Note`),a),r.append(o);let s=C(`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=`${D(e.startMs)} to ${D(e.endMs)}`,r.append(s),r.append(C(`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=C(`button`,`btn btn-quiet`,`Remove mask`);c.type=`button`,c.setAttribute(`data-remove-mask`,e.id),oi(c,`Remove mask`,[`Delete`]),c.addEventListener(`click`,()=>n.onRemoveMask(e.id));let l=C(`div`,`control-actions`);return l.append(c),r.append(l),r}function _i(e,t,n){let{selection:r,rail:i}=t;if(i===`shortcuts`&&e.querySelector(`:scope > .inspector > [data-shortcuts-panel]`)!==null)return;let a=C(`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=mi(o,t,n):s?l=hi(s,t,n):c?l=gi(c,t,n):(console.error(`[demoman] editor: the rail is on Selection with nothing selected`),l=ui()):l=i===`background`?di():i===`cursor`?pi():i===`shortcuts`?fi():ui();let u=C(`button`,`btn btn-icon inspector-close`);u.type=`button`,u.setAttribute(`data-inspector-close`,``),u.setAttribute(`aria-label`,`Close panel`),oi(u,`Close`,[`Esc`]),u.append(b(`close`)),u.addEventListener(`click`,()=>n.onClose()),a.append(u,l),e.replaceChildren(a)}var vi=[{entry:`background`,label:`Background`,glyph:`image`},{entry:`cursor`,label:`Cursor`,glyph:`mousePointer2`},{entry:`selection`,label:`Selection`,glyph:`mousePointerClick`}],yi=`Select a step or zoom on the timeline`;function bi(e,t,n){let r=vi.map(({entry:e,label:r,glyph:i})=>{let a=C(`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?yi:r,a.append(b(i)),a.addEventListener(`click`,()=>n.onPick(e)),a});e.replaceChildren(...r)}function xi(e,t,n){e.querySelector(`svg[data-icon]`)===null&&e.replaceChildren(b(`download`),C(`span`,void 0,`Export`)),e.setAttribute(`aria-pressed`,String(t.panelOpen&&t.rail===`export`)),e.onclick=()=>n.onPick(`export`)}function Si(e,t,n){e.setAttribute(`aria-pressed`,String(t.panelOpen&&t.rail===`shortcuts`)),e.onclick=()=>n.onPick(`shortcuts`)}function Ci(e,t,n,r=null){let i=r===null?``:` ${Qe[r]}`;switch(e.phase){case`idle`:return Je(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 wi=1e3,Ti=new Map;function Ei(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=Ti.get(t);if(s!==void 0&&o-s.at>wi)Ti.delete(t);else if(s!==void 0){let e=s.on===n?o-s.at:0;s.on!==n&&Ti.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`),Ti.set(t,{on:i.checked,at:performance.now()}),e.onChange(i.checked)}),r}function Di(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 Oi(e,t){let n=t.hoverReport===null?null:Wn(t.hoverReport);if(t.notices.length===0&&n===null){e.replaceChildren();return}let r=C(`div`,void 0);r.setAttribute(`data-take-notes`,``);for(let e of t.notices){let t=C(`div`,`notice`);ue(t,e),t.setAttribute(`data-take-notice`,``),r.append(t)}if(n!==null){let e=C(`div`,`notice`,n);e.setAttribute(`data-hover-report`,``),r.append(e)}e.replaceChildren(r)}function ki(e,t){if(t.hasFrames){e.replaceChildren();return}let n=C(`div`,`banner`),r=C(`span`);r.append(Ai(t.route)),n.append(r),e.replaceChildren(n)}function Ai(e){let t=document.createDocumentFragment();return t.append(`This video has no frames — `,ji(e,Ct(e.authored))),t}function ji(e,t){if(e.rerun.kind===`line`){let t=C(`span`);return ue(t,e.rerun.text),t.setAttribute(`data-rerun-line`,``),t}let n=C(`a`,void 0,t);return n.setAttribute(`href`,e.rerun.href),n.setAttribute(`data-runs-route`,``),n}function Mi(e,t){let n=[];if(t.openError!=null){let e=C(`div`,`notice`);e.setAttribute(`data-open-error`,``),e.append(C(`strong`,void 0,`This video could not be opened`)),e.append(C(`div`,void 0,t.openError)),n.push(e)}if(t.replaySentence!==null){let e=C(`div`,`notice`);e.setAttribute(`data-replay-failure`,``);let r=t.runsRoute?.authored===!0?`script run`:`re-shoot`;if(e.append(C(`strong`,void 0,t.replayRecoverable===!0?`The last ${r} stopped early`:`The last ${r} did not finish`)),e.append(C(`div`,void 0,t.replaySentence)),t.runsRoute!=null){let n=C(`div`);n.setAttribute(`data-replay-runs-route`,``),n.append(ji(t.runsRoute,Rt(t.runsRoute.authored))),e.append(n)}n.push(e)}if(t.captureSentence!=null){let e=C(`div`,`notice`);e.setAttribute(`data-capture-note`,``),e.append(C(`strong`,void 0,`What this video recorded`)),e.append(C(`div`,void 0,t.captureSentence)),n.push(e)}if(t.renderError!=null){let e=C(`div`,`notice`);e.setAttribute(`data-render-error`,``),e.append(C(`strong`,void 0,`The export did not start`)),e.append(C(`div`,void 0,t.renderError)),n.push(e)}if(t.previewError!=null){let e=C(`div`,`notice`);e.setAttribute(`data-preview-error`,``),e.append(C(`strong`,void 0,`The preview stopped`)),e.append(C(`div`,void 0,t.previewError)),n.push(e)}if(t.logoLoadError!=null){let e=C(`div`,`notice`);e.setAttribute(`data-logo-load-error`,``),e.append(C(`strong`,void 0,`The logo could not be loaded`)),e.append(C(`div`,void 0,t.logoLoadError)),n.push(e)}if(t.wallpaperLoadError!=null){let e=C(`div`,`notice`);e.setAttribute(`data-wallpaper-load-error`,``),e.setAttribute(`role`,`alert`),e.append(C(`strong`,void 0,`The background image could not be loaded`)),e.append(C(`div`,void 0,t.wallpaperLoadError)),n.push(e)}if(t.error!==null){let e=C(`div`,`notice`);e.setAttribute(`data-action-error`,``),e.append(C(`strong`,void 0,`That edit did not go through`)),e.append(C(`div`,void 0,t.error)),n.push(e)}if(t.deleteError!=null){let e=C(`div`,`notice`);e.setAttribute(`data-delete-error`,``),e.append(C(`strong`,void 0,`This video was not deleted`)),e.append(C(`div`,void 0,t.deleteError)),n.push(e)}if(t.navigationError!=null){let e=C(`div`,`notice`);e.setAttribute(`data-navigation-error`,``),e.append(C(`strong`,void 0,`The ${t.navigationError.page} did not open`)),e.append(C(`div`,void 0,t.navigationError.reason)),n.push(e)}e.replaceChildren(...n)}function Ni(e,t,n){We(e,t,n)}var Pi={light:`Light`,dark:`Dark`,touch:`Touch`},Fi={light:1/16,dark:1/16,touch:0};function Ii(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-Fi[e])*o,y:n/2-(s.y-i.y)*o}}var Li=.6;function Ri(e,t,n){return Math.min(Math.min(2,Math.max(.5,t))*Li,n/f[e].height)}function zi(t,n){let r=C(`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=Ri(t,n,44);return ne(i,Ii(t,a,44),a,e,t),r}function Bi(e,t,n,r,i,a,o,s){let c=C(`div`,`slider-row`),l=C(`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=C(`span`,`slider-value`,a(n));tt(l),l.addEventListener(`input`,()=>{tt(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(C(`span`,`control-label slider-label`,t),u,l),c}var Vi=e=>`${Math.round(e*100)}%`,Hi=e=>`${e.toFixed(2)}x`;function Ui(e,t,n,r,i,a,o,s,c){return Bi(e,t,n,r,i,a,{preview:e=>s.onCursorPreview({[o]:e}),commit:e=>s.onCursor({[o]:e}),end:()=>s.onCursorPreviewEnd()},c)}function Wi(e,t,n,r,i){return Bi(e,t,n,0,1,Vi,{preview:e=>i.onMotionPreview({[r]:e}),commit:e=>i.onMotion({[r]:e}),end:()=>i.onMotionPreviewEnd()},!1)}function Gi(e,t,n,r,i,a){return Di(t,null,Ei({key:r,checked:n,disabled:a,attrs:{[e]:``},onChange:e=>i.onCursor({[r]:e})}))}function Ki(e,t,n,r,i=!1){let a=C(`div`),o=t.hidden;a.append(Gi(`data-cursor-hidden`,`Hide cursor`,t.hidden,`hidden`,r,!1));let s=Ui(`data-cursor-scale`,`Size`,t.scale,.5,2,Hi,`scale`,r,o);i&&a.append(s);let c=C(`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=C(`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`,Pi[e]),n.title=Pi[e],n.append(zi(e,t.scale)),n.addEventListener(`click`,()=>r.onCursor({style:e})),c.append(n)}i||a.append(C(`div`,`cursor-label`,`Style`),c),i||a.append(s,Ui(`data-cursor-blur`,`Motion blur`,t.motionBlur,0,1,Vi,`motionBlur`,r,o),Ui(`data-cursor-tilt`,`Tilt`,t.tilt??he.tilt,0,1,Vi,`tilt`,r,o),Ui(`data-cursor-bounce`,`Click bounce`,t.clickBounce??he.clickBounce,0,2,Hi,`clickBounce`,r,o),Gi(`data-cursor-idle`,`Hide when not moving`,t.hideWhenIdle,`hideWhenIdle`,r,o)),a.append(C(`div`,`cursor-label camera-label`,`Camera`),Wi(`data-motion-smoothness`,`Smoothness`,n.smoothness,`smoothness`,r),Wi(`data-motion-blur`,`Camera blur`,n.blur,`blur`,r),Di(`Follow cursor`,null,Ei({key:`motion-follow`,checked:n.follow,attrs:{"data-motion-follow":``},onChange:e=>r.onMotion({follow:e})}))),e.replaceChildren(a)}function qi(){let e=C(`progress`,`export-progress`);return e.setAttribute(`data-export-progress`,``),e.setAttribute(`aria-label`,`Export progress`),e}function Ji(e,t,n){return e.phase!==`idle`||t.kind===`noFrames`||n.length===0}function Yi(e,t,n,r,i=[]){let a=e.querySelector(`[data-export-start]`);if(a===null)return!1;a.textContent=Ci(t,n,r,Xi(i)),a.disabled=Ji(t,r,n);let o=Mt(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??qi();return Zi(c,t,i),s===null&&a.closest(`.control-actions`)?.after(c),!0}function Xi(e){return e.length>1?Mt(e)?.fileType??null:null}function Zi(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!==Mt(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 $i(e,t,n){let r=C(`div`),o=t.run.phase!==`idle`;if(t.hasReclaimedMotion){let e=C(`p`,`notice`,`This export will use still frames where motion was reclaimed.`);e.setAttribute(`data-reclaimed-motion-notice`,``),r.append(e)}let s=nt(t.aspect),c=C(`div`,`export-facts`),l=(e,t,n)=>{let r=C(`div`,`export-fact`),i=C(`span`,`export-fact-value`,t);return i.setAttribute(n,``),r.append(C(`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(C(`span`,`visually-hidden`,`Set under the preview`)),l(`Source`,$e(t.recording),`data-size-readout`),r.append(c),s.reason!==null){let e=C(`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=C(`div`,`control-row files-row`),p=C(`div`,`files-head`);if(p.append(C(`span`,`section-label`,`Files`)),t.quality!=null){let e=!t.fileTypes.includes(`mp4`),r=C(`div`,`file-quality`);r.append(C(`span`,`control-aside`,`Quality`));let s=C(`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=C(`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=C(`div`,`file-types`);m.setAttribute(`role`,`group`),m.setAttribute(`aria-label`,`Files`),m.setAttribute(`data-file-types`,``);for(let e of Ke){let r=C(`label`,`file-type`),i=C(`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?C(`span`,`file-facts`,et(e,t.targets[e])):C(`span`,`file-status`,Qi(a,t.run,t.files));a!==void 0&&s.setAttribute(`data-file-status`,e),r.append(i,C(`span`,`file-name`,Qe[e]),s),m.append(r)}f.append(m),r.append(f);let h=C(`button`,`btn btn-primary export-start`,Ci(t.run,t.fileTypes,t.readiness,Xi(t.files)));h.type=`button`,h.setAttribute(`data-export-start`,``),h.setAttribute(`data-readiness`,t.readiness.kind),h.disabled=Ji(t.run,t.readiness,t.fileTypes),h.addEventListener(`click`,n.onExport);let g=C(`div`,`control-actions`);if(g.append(h),t.readiness.kind===`noFrames`){let e=C(`p`,`muted`);e.setAttribute(`data-export-no-frames`,``),e.append(Ai(t.runsRoute)),r.append(g,e)}else if(t.fileTypes.length===0){let e=C(`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=qi();Zi(e,t.run,t.files),r.append(e)}let _=ea(t.repo,n);if(_!==null&&r.append(_),t.save!==null&&r.append(da(t.save,n)),!o)for(let e of t.files.filter(e=>e.ended===`failed`)){let t=C(`div`,`notice notice-error`);t.setAttribute(`data-file-failed`,e.fileType);let i=C(`button`,`btn btn-quiet`,`Retry`);i.type=`button`,i.addEventListener(`click`,()=>n.onRetry(e.fileType)),t.append(C(`span`,void 0,`${Qe[e.fileType]} failed`),` `,i),r.append(t)}if(t.revealError!=null){let e=C(`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`&&ia(r,n.output,t)}e.replaceChildren(r)}function ea(e,t){if(e==null)return null;let n=C(`div`,`control-row`);n.setAttribute(`data-repo-section`,``),n.append(C(`span`,`section-label`,`Repo`));let r=(e,t)=>{let n=C(`button`,`btn btn-quiet`);return n.type=`button`,n.append(b(t),e),n};if(e.inRepo!==null){n.append(C(`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=C(`p`,`notice`,e.note);t.setAttribute(`data-note`,``),n.append(t)}if(e.status!==null){let t=C(`p`,`notice notice-error`,e.status);t.setAttribute(`data-status`,``),n.append(t)}return n}function ta(e,t,n){let r=document.createDocumentFragment(),i=t.showAll?t.outputs:t.outputs.slice(0,5);for(let e of i){let i=C(`div`,`output`);if(i.setAttribute(`data-output`,e.kind===`file`?e.key:e.output.ref),r.append(i),e.kind===`file`){la(i,e,t,n);continue}let a=e.output,o=C(`div`,`beat`),s=a.sceneDigest!==void 0&&a.sceneDigest!==t.currentDigest,c=t.warningsOpen.has(a.ref);o.append(sa(a.name,[s?oa(a.ref):null,ra(a.ref,na(a),c,n)]));let l=C(`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(ca(a.ref,[je(a.byteLength),aa(a.renderedAt)],null)),c&&na(a)>0){let e=C(`div`,`output-warnings`);e.setAttribute(`data-output-warnings-body`,a.ref),ia(e,a,t.reportContext),i.append(e)}}let a=t.outputs.length-i.length;if(a>0){let e=C(`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 na(e){return[e.detailViolations.length>0,e.logoWarning!==void 0,(e.unavailableSpans??[]).length>0,(e.unplacedStills??[]).length>0].filter(Boolean).length}function ra(e,t,n,r){if(t===0)return null;let i=C(`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 ia(e,t,n){if(t.detailViolations.length>0){let{heading:r,lines:i}=Ot(t.detailViolations,n.beatAt),a=C(`div`,`notice`);a.setAttribute(`data-violations`,t.ref),a.append(C(`strong`,void 0,r));for(let e of i)a.append(C(`div`,void 0,e));a.append(C(`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=C(`div`,`notice`);n.setAttribute(`data-logo-warning`,t.ref),n.append(C(`div`,void 0,t.logoWarning)),e.append(n)}let r=t.unavailableSpans??[];if(r.length>0){let i=C(`div`,`notice`);i.setAttribute(`data-unavailable`,t.ref);let a=r.every(e=>e.reason===wt),o=C(`strong`);ue(o,a?`Motion was reclaimed to free space and shown as a still. ${Vt(n.runsRoute.authored,Bt(n.runsRoute),`to restore`)}`:`Some motion could not be decoded and was shown as a still`),i.append(o);for(let e of r)i.append(C(`div`,void 0,`${e.ref}: ${e.reason}`));e.append(i)}let i=t.unplacedStills??[];if(i.length>0){let n=C(`div`,`notice`);n.setAttribute(`data-unplaced-stills`,t.ref);let r=i.every(e=>e.reason.includes(`cut`));n.append(C(`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(C(`div`,void 0,`${e.actionId}: ${e.reason}`));e.append(n)}}function aa(e,t=new Date){let n=new Date(e);return Number.isNaN(n.getTime())?e:De(n,n.getFullYear()!==t.getFullYear())}function oa(e){let t=C(`span`,`chip`,`Outdated`);return t.setAttribute(`data-stale-export`,e),t.title=`Made before your last edit`,t}function sa(e,t){let n=C(`span`,`output-head`),r=C(`span`,`output-name`,e);r.title=e,n.append(r);for(let e of t)e!==null&&n.append(e);return n}function ca(e,t,n){let r=C(`div`,`muted output-meta`,t.join(` · `));return r.setAttribute(`data-output-meta`,e),n!==null&&(r.title=n),r}function la(e,t,n,r){let i=C(`div`,`beat`),a=n.warningsOpen.has(t.key);if(i.append(sa(t.name,[t.sceneDigest===n.currentDigest?null:oa(t.key),ra(t.key,t.caveats.length,a,r)])),t.exists){let e=C(`button`,`btn btn-quiet`,xa());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=C(`span`,`muted`,`moved or deleted`);e.setAttribute(`data-output-gone`,``),i.append(e)}if(e.append(i),e.append(ca(t.key,[je(t.byteLength),aa(t.renderedAt)],t.detail)),a&&t.caveats.length>0){let n=C(`div`,`notice output-warnings`);n.setAttribute(`data-output-warnings-body`,t.key);for(let e of t.caveats)n.append(C(`div`,void 0,ua(e)));e.append(n)}}function ua(e){let t=e.charAt(0).toUpperCase()+e.slice(1);return/[.!?]$/.test(t)?t:`${t}.`}function da(e,t){let n=C(`div`,e.kind===`failed`?`notice notice-error`:`notice`);n.setAttribute(`data-save-outcome`,e.kind);let r=(e,n)=>{let r=C(`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]} · ${je(e.byteLength)}`:`Saved ${e.names.length} files · ${je(e.byteLength)}`;n.append(C(`span`,void 0,r));let i=e.reveal;if(i!==null){let e=C(`button`,`btn btn-quiet`,i.kind===`path`?xa():`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=C(`div`,`muted`,e.summary);t.setAttribute(`data-save-summary`,``),n.append(t)}}else e.kind===`cancelled`?(n.append(C(`span`,void 0,`You cancelled the save.`)),e.total>1?n.append(C(`div`,void 0,`Saved ${e.saved} of ${e.total} files.`)):n.append(` `),n.append(r(e.refs,`Download again`))):(n.append(C(`strong`,void 0,`Exported, but the browser didn't save it.`)),e.total>1&&n.append(C(`div`,void 0,`Saved ${e.saved} of ${e.total} files.`)),n.append(C(`div`,void 0,e.error),r(e.refs,`Download again`)));return n}function fa(e,t){let n=C(`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 pa(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=C(`button`,`btn btn-icon transport-button`),r.type=`button`,r.setAttribute(`data-transport-play`,``),s=C(`button`,`btn btn-icon transport-button`),s.type=`button`,s.setAttribute(`data-transport-skip`,``),s.append(b(`skipBack`)),o=C(`button`,`btn btn-icon transport-button`),o.type=`button`,o.setAttribute(`data-transport-repeat`,``),o.append(b(`repeat`));let t=C(`span`,`transport-pip`);t.setAttribute(`aria-hidden`,`true`),o.append(t),i=C(`span`,`rate`),i.setAttribute(`data-transport-rate`,``),a=C(`div`,`transport-controls`),a.setAttribute(`data-transport-controls`,``),a.append(s,fa(-1,`Rewind`),r,fa(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?oi(e,o,[r===-1?`J`:`L`]):(si(e),e.title=o)}s.onclick=()=>n.onSkipToStart(),s.disabled=!t.enabled;let l=`Jump to start`;s.setAttribute(`aria-label`,l),t.enabled?oi(s,l,[`Mod`,`Left`]):(si(s),s.title=ae(`This video has no frames yet, so there is nothing to play. ${Vt(t.authored,t.rerunLine??null,`first`)}`)),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?oi(r,d,[`Space`]):(si(r),r.title=ae(`This video has no frames yet, so there is nothing to play. ${Vt(t.authored,t.rerunLine??null,`first`)}`));let p=t.playing&&c!==1;i.textContent=p?`${c}x`:``,i.hidden=!p,i.dataset.side=t.rate<0?`back`:`forward`}function ma(e,t,n,r=e){let i=r.querySelector(`[data-transport-time]`),a=e.querySelector(`[data-stage-actions]`);if(i===null||a===null){i=C(`span`,`stage-clock`),i.setAttribute(`data-transport-time`,``),a=C(`div`,`stage-actions`),a.setAttribute(`data-stage-actions`,``);let t=C(`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=C(`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=C(`button`,`btn chip`);n.type=`button`,n.setAttribute(`data-stage-zoom`,``),a.append(n);let o=C(`button`,`btn btn-icon chip chip-icon`);o.type=`button`,o.setAttribute(`data-stage-fullscreen`,``),a.append(o);let s=C(`div`,`stage-error`);s.setAttribute(`data-stage-error`,``),s.setAttribute(`role`,`alert`),s.hidden=!0;let c=C(`span`,`stage-error-text`);c.setAttribute(`data-stage-error-text`,``);let l=C(`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=`${D(t.positionMs)} / ${D(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. ${Vt(t.authored,t.rerunLine??null,`first`)}`),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 ha={undo:[`Mod`,`Z`],redo:[`Shift`,`Mod`,`Z`],"shortcuts-open":[`?`]};function ga(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=ha[t];a===void 0?i.title===``&&(i.title=r):oi(i,r,a),i.querySelector(`svg`)===null&&(i.textContent=``,i.append(b(n)))}}var _a=`#failure > .notice:not([data-capture-note])`;function va(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(_a)===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=C(`span`),a.setAttribute(`data-count`,``),a.setAttribute(`aria-hidden`,`true`),e.append(a)),a.textContent=String(n)}function ya(e,t){let n=[...e.querySelectorAll(_a)].map(e=>e.textContent??``).join(`
2
- `);return n!==``&&n!==t&&typeof e.showPopover==`function`&&!e.matches(`:popover-open`)&&e.showPopover(),n}function ba(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=C(`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=C(`div`,`shortcuts-body`),o=[];for(let e of Hr){let n=o[o.length-1];if(n?.group!==e.group){let t=C(`section`,`shortcuts-section`);t.append(C(`h3`,`shortcuts-group`,e.group)),a.append(t),n={section:t,group:e.group,rows:[]},o.push(n)}let r=C(`div`,`shortcuts-row`);r.setAttribute(`data-shortcut-row`,``),r.append(C(`span`,`shortcuts-what`,Vr(e,t.mac)));let i=C(`span`,`shortcuts-keys`);for(let n of e.combos){let e=C(`span`,`keychord`);e.setAttribute(`data-combo`,``),e.setAttribute(`aria-label`,zr(n,t.mac));for(let r of n){let n=Fr(r,t.mac),i=C(`kbd`,`keycap`,n);i.setAttribute(`aria-hidden`,`true`),Lr(n)&&i.setAttribute(`data-symbol`,``),e.append(i)}i.append(e)}r.append(i),n.section.append(r),n.rows.push(r)}let s=C(`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 xa(){return Br(navigator.userAgent)?`Show in Finder`:`Show in folder`}function Sa(e){return`${Ne(e)}${ke(e)}`}function Ca(e,t,n=!1){let r=C(`div`,`info-row`);r.append(C(`span`,`info-key`,e));let i=C(`span`,n?`info-value mono`:`info-value`,t);return i.title=t,r.append(i),r}function wa(e,t,n,r){let i=Ca(e,t,!0),a=C(`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=C(`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=C(`div`);return s.append(i,o),s}function Ta(e,t,n){let r=C(`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(Ca(`Recorded`,aa(t.recordedAt)),Ca(`Site`,Sa(t.site)),Ca(`Length`,i),Ca(`Source`,`${t.recording.width} × ${t.recording.height}`),Ca(`Export`,`${t.target.width} × ${t.target.height} · ${a}`));let o=C(`div`,`info-group`);if(o.setAttribute(`data-info-ids`,``),o.append(wa(`Video ID`,t.takeId,`video ID`,n.onCopy)),t.rerun.kind===`link`){let e=C(`div`,`info-row`);e.append(C(`span`,`info-key`,`Re-record`));let n=C(`a`,`info-value`,t.rerun.label);n.setAttribute(`href`,t.rerun.href),n.setAttribute(`data-runs-route`,``),e.append(n),o.append(e)}let s=[r,o];if(t.history.outputs.length>0){let e=C(`div`,`info-group info-exports`);if(e.setAttribute(`data-info-exports`,``),e.append(C(`div`,`info-label`,`Exports`)),t.revealError!==null){let n=C(`p`,`notice notice-warn`,t.revealError);n.setAttribute(`data-reveal-error`,``),e.append(n)}let r=C(`div`,`info-history`);ta(r,t.history,n),e.append(r),s.push(e)}e.replaceChildren(...s)}var Ea=.006,A=e=>`${(e*100).toFixed(4)}%`;function Da(e,t,n,r=Ea){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 Oa=(e,t)=>Math.min(1,Math.max(0,k(e,t))),ka=[100,250,500,1e3,2e3,5e3,1e4,15e3,3e4,6e4],Aa=(e,t)=>t>=1e3?D(e):`${D(e)}.${Math.floor(e%1e3/100)}`;function ja(e,t){let n=C(`div`,`ruler`);n.setAttribute(`data-ruler`,``),n.setAttribute(`data-source`,e.timeSource);let r=(t.viewport.endMs-t.viewport.startMs)/10,i=ka.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=C(`span`,`tick`,Aa(e,i));a.style.left=A(r),a.dataset.fraction=String(r),n.append(a)}return Na?.observe(n),n}function Ma(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 Na=typeof ResizeObserver>`u`?null:new ResizeObserver(e=>{for(let t of e){let e=t.target;e.isConnected?Ma(e):Na?.unobserve(e)}});function Pa(e,t){let n=C(`div`,`lane`);return n.append(e,t),n}function Fa(e,t,n){let r=C(`div`,`lane-label lane-head`),i=C(`span`,`lane-title`),a=C(`span`,`lane-glyph`);return a.append(b(t)),i.append(a,C(`span`,`lane-name`,e)),n&&i.append(n),r.append(i),r}function Ia(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=C(`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 La=3;function Ra(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 za=(e,t)=>e!==null&&t!==null&&e.kind===t.kind&&(e.kind===`tick`?e.actionId===t.actionId:e.kind===`piece`?Jt(e.start,t.start):e.id===t.id),Ba=(e,t)=>e.snapping?8*t:0;function Va(e,t){let n=e.getBoundingClientRect().width;return n===0?0:(t.endMs-t.startMs)/n}function Ha(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 Ua(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=Va(t,n.viewport);return{toMs:Ha(t,n.viewport,e),deltaMs:(e-s)*r,snapMs:Ba(n,r)}},u=e=>{Math.abs(e.clientX-s)>La&&(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 Wa=e=>Math.max(0,Math.min(1,e));function Ga(e,t,n,r){let i=Wa(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 Ka(e,t,n,r,i){let a=C(`div`,`edge`);return a.setAttribute(`data-edge`,t),a.setAttribute(`aria-label`,t===`start`?`Drag the piece's start`:`Drag the piece's end`),Ua(a,n,r,({deltaMs:n})=>({kind:`pieceEdge`,start:e.start,side:t,deltaMs:n}),i,{move:({deltaMs:e})=>{let i=e/Va(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 qa(e,t,n,r){let i=C(`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=C(`div`,`join-card-what`),o=C(`b`),s=C(`span`);e.unplaced===void 0?(o.textContent=`${n} removed`,s.textContent=`${Ja(e.srcStartMs)} to ${Ja(e.srcEndMs)}`):(o.textContent=`Removes no frames`,s.textContent=e.unplaced.charAt(0).toUpperCase()+e.unplaced.slice(1)),a.append(o,s);let c=C(`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 Ja(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 Ya(e,t,n){let r=C(`div`,`track`);r.setAttribute(`data-track`,`clip`);let{clip:i}=e;for(let e of i.degraded){let n=Da(t.viewport,e.startMs,e.endMs,0);if(n===null)continue;let i=C(`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=Da(t.viewport,i.trim.headMs,i.trim.tailMs);if(s!==null){let e=C(`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=Da(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=C(`div`,`piece-wrap`);d.style.left=A(o),d.style.width=A(u-o);let f=C(`button`,`piece`);f.type=`button`,f.setAttribute(`data-piece`,String(e.startMs)),f.setAttribute(`aria-label`,`Piece of the clip`),za(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(Ka(e,`start`,r,t,n)),(!m||e.after!==null)&&d.append(Ka(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=C(`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)>La;u=null,r||n.onOpenJoin(s?null:e.removedId)});let d=C(`span`,`seam`);d.setAttribute(`data-seam`,e.removedId),d.style.left=o,r.append(d,l),s&&r.append(qa(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=C(`div`,`handle`);a.setAttribute(`data-trim`,e),a.setAttribute(`data-timing`,c),a.style.left=A(s),Ua(a,r,t,({toMs:t,snapMs:n})=>({kind:`trim`,edge:e,toMs:t,snapMs:n}),n,{move:({toMs:n})=>Ga(r,a,e,k(t.viewport,n)),end:()=>Ga(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=C(`button`,`tick`);o.type=`button`,o.setAttribute(`data-tick`,e.actionId),o.setAttribute(`data-verb`,e.verb);let s=no[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(Xa(i.ticks,e));o.setAttribute(`data-stack-index`,c),o.style.setProperty(`--tick-stack`,c),za(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 Xa(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 Za(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=Da(i.viewport,s,c);if(l===null)return null;let u=C(`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};za(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(C(`span`,`seg-label`,`${t.scale.toFixed(1)}x`))}else p&&u.setAttribute(`data-whole-take`,``),u.append(C(`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=C(`div`,`cap`);c.setAttribute(`data-cap`,s),Ua(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=Wa(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)}Ua(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=C(`div`,`track`);a.setAttribute(`data-track`,e);let o=e===`zoom`?t.zooms:t.masks;for(let i of o){let o=Za(i,e,a,t,n,r);o&&a.append(o)}return i?(a.addEventListener(`click`,i=>{if(i.target!==a)return;let o=Va(a,n.viewport);r.onGesture({kind:e===`zoom`?`addZoom`:`addMask`,atMs:$a(e,t,Ha(a,n.viewport,i.clientX)),snapMs:Ba(n,o)})}),to(a,e,t,n),a):a}function $a(e,t,n){let r=e===`zoom`?(t.zoomDefaultMs-t.zoomInMs)/2:gn/2;return Math.max(0,Math.min(t.durationMs,n-r))}function eo(e,t,n){let r=e===`zoom`?En(t,n):Dn(t,n);return _n(r)?null:e===`mask`?{startMs:r.startMs,endMs:r.endMs}:{startMs:sn(t.zooms,r.startMs,t.zoomInMs),endMs:cn(t.zooms,r.startMs,r.endMs)}}function to(e,t,n,r){let i=null,a=()=>{i?.remove(),i=null};e.addEventListener(`pointermove`,o=>{if(o.target!==e)return a();let s=eo(t,n,$a(t,n,Ha(e,r.viewport,o.clientX))),c=s&&Da(r.viewport,s.startMs,s.endMs);if(c===null)return a();i===null&&(i=C(`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 no={click:`mousePointerClick`,type:`type`,moveTo:`mousePointer2`,scrollTo:`moveVertical`,waitFor:`hourglass`,drag:`handGrab`,press:`type`};function ro(e,t,n,r){let i=C(`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=C(`p`,`muted`);ue(e,t.rerunLine===null?`Timing from the video, not from a render — ${Ct(t.authored)} to see the timing this video will actually have.`:`Timing from the video, not from a render. ${t.rerunLine}`),i.append(e)}let a=ja(t,n);Ra(a,()=>a.getBoundingClientRect(),n,t.durationMs,r);let o=C(`div`,`lanes`);o.append(Pa(C(`b`,`lane-label`),a));let s=C(`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(ei(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(ti(n.viewport,t.durationMs,a/i.width*o))});let c=Fa(`Clip`,`film`),l=Ia(t.hoverCheck);l!==null&&c.querySelector(`.lane-glyph`)?.append(l);let u=Pa(c,Ya(t,n,r));u.setAttribute(`data-lane`,`clip`),o.append(u);let d=Pa(Fa(`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=C(`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?Va(e,n.viewport):0;r.onGesture({kind:`addMask`,atMs:n.positionMs,snapMs:Ba(n,t)})});let a=Pa(Fa(`Mask`,`eyeOff`,e),Qa(`mask`,t,n,r,f));a.setAttribute(`data-lane`,`mask`),o.append(a)}let p=C(`div`,`playhead`);p.setAttribute(`data-playhead`,``),p.style.left=A(Oa(n.viewport,n.positionMs));let m=C(`div`,`grab`);m.setAttribute(`data-playhead-grab`,``),m.setAttribute(`aria-hidden`,`true`),Ra(m,()=>s.getBoundingClientRect(),n,t.durationMs,r),p.append(m),s.append(p),o.append(s),i.append(o);let h=C(`p`,`refusal`);ue(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&&io(v)}function io(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 ao(e){let t=C(`button`,`btn btn-quiet btn-icon tool`);return t.type=`button`,t.append(b(e)),t}function oo(e,t,n){e.setAttribute(`aria-label`,t),e.disabled?(si(e),e.title=t):oi(e,t,n)}var so=new WeakMap;function co(){let e=C(`div`,`bar-controls`);e.setAttribute(`data-timeline-tools`,`view`);let t=ao(`magnet`);t.classList.add(`snap`);let n=ao(`moveHorizontal`);n.classList.add(`fit`),n.setAttribute(`data-fit`,``);let r=ao(`scissors`);r.setAttribute(`data-split-tool`,``);let i=C(`div`,`zoom-control`);i.setAttribute(`data-zoom-control`,``);let a=C(`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=ao(`zoomOut`);o.classList.add(`zoom-step`),o.setAttribute(`data-zoom-step`,`out`);let s=ao(`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 lo(e,t,n,r){let i=so.get(e);(i===void 0||i.view.parentElement!==e)&&(i=co(),so.set(e,i),e.replaceChildren(i.view));let{split:a,snap:o,fit:s,zoom:c,zoomOut:l,zoomIn:u}=i;oo(a,`Split at playhead`,[`Mod`,`B`]),a.onclick=()=>r.onSplit(),oo(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=Zr(t.durationMs),f=n.viewport.startMs===d.startMs&&n.viewport.endMs===d.endMs;s.disabled=f,oo(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=ii(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=ri(t.durationMs,Number(c.value)),i=k(n.viewport,n.positionMs);r.onViewport(ni(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(ei(n.viewport,t.durationMs,e,i))};l.disabled=!h||m<=5e-4,l.onclick=()=>g(1/jr),oo(l,`Zoom out`,[`−`]),u.disabled=!h||m>=.9995,oo(u,`Zoom in`,[`+`]),u.onclick=()=>g(jr)}var j=me();function M(e){console.error(`demoman editor:`,e)}var uo=j.kits,N={state:`ready`,kits:[],defaultId:null,migrationPending:!1},fo=null,po=null;function mo(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`&&ot(t.read.kit,e)),i=r.find(e=>e.id===fo)??r.find(e=>e.id===t.defaultId)??r[0];if(i!==void 0)return fo=i.id,{kit:i,edited:!1};let a=n.find(e=>e.id===fo);return a===void 0?null:{kit:a,edited:!0}}var ho=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},go=null,_o=!1,I=Ar({sceneId:P,loadScene:async e=>{let t=await j.scenes.get(e);if(t===null)throw Error(`no scene "${e}"`);return fs??=t.notes,_o||=(go=t.revision,!0),t.scene},saveScene:async e=>{go=(await j.scenes.put(e,go)).revision},bundles:{active:e=>ho.active(e)},newId:()=>crypto.randomUUID()});function L(e){let t=I.snapshot().scene;return I.dispatch(e).catch(M).then(()=>vo(t))}function vo(e){if(Jo===null)return;let t=I.snapshot();t.scene!==e&&t.error===null&&(Jo=null,$(t))}var R=At,yo=null,z=null,bo=!1;function xo(e){e!==z&&(bo=!1),z=e}var B=null,So=null,Co=[],wo=null,To=null,Eo=null,V=null,Do=null,H=`export`,U=!0,Oo=`export`,ko=ir(),Ao=[`mp4`],jo=()=>Ao[0]??`mp4`;function W(e,n=jo()){let r=I.snapshot().scene,i=Po();return t(n,r.canvas.aspect,e,d({...r,branding:Rs(r)}),i===null?{}:{quality:i})}var Mo=j.exportQuality===void 0?null:m,No=null,Po=()=>Mo===null?null:No??Mo,Fo=!1,Io=null;function Lo(e){return Io?.scene!==e&&(Io={scene:e,digest:Te(e)}),Io.digest}var Ro=`fit`;function zo(e){e!==null&&e.kind!==`piece`?(H!==`selection`&&(Oo=H),H=`selection`,U=!0):H===`selection`&&(H=Oo),V=e}var Bo=null,Vo=null,Ho=0,G=null,Uo=!0,Wo=!1,Go=``,Ko=!1,qo=null,Jo=null,Yo=[];function Xo(){return Yo.flatMap(e=>e.kind===`stored`?[e.output]:[])}var Zo=!1,Qo=new Set,K=qn(l),q=null,J=null,$o=F(`preview`),es=new OffscreenCanvas(K.width,K.height),ts=es.getContext(`2d`);function ns(e){let t=W(e),n=xc(e,F(`stage-frame`).getBoundingClientRect().width),r=n.width!==K.width||n.height!==K.height;K=n,r&&(es=new OffscreenCanvas(K.width,K.height),ts=es.getContext(`2d`)),q=null;let i=F(`stage`);i.style.setProperty(`--frame-ratio`,`${t.width} / ${t.height}`),i.style.setProperty(`--frame-px`,String(qn(t).width))}var rs=150,is=null,as=!1,os=!1;document.addEventListener(`pointerdown`,()=>{as=!0},!0);var ss=()=>{as=!1,Ls?.patch.background!==void 0&&setTimeout(()=>{!as&&Ls?.patch.background!==void 0&&Zs()},0),os&&setTimeout(()=>{os&&!as&&$(I.snapshot())},0)};window.addEventListener(`pointerup`,ss,!0),window.addEventListener(`pointercancel`,ss,!0);var cs=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`),Sl&&(is!==null&&clearTimeout(is),is=setTimeout(()=>{is=null;let e=xc(I.snapshot().bundle,F(`stage-frame`).getBoundingClientRect().width);(e.width!==K.width||e.height!==K.height)&&(as&&(Ls!==null||Fs!==null)?(Zs(),os=!0):$(I.snapshot()))},rs))});cs.observe(F(`stage-frame`)),cs.observe(F(`stage`));var ls=[],us=null,ds=``,fs=null,ps=`The video shows the text that was recorded; re-record to type the new text.`;function ms(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 hs=null,gs=null,_s=0,vs=null,ys=Qn(e=>e.motionSpans.length>0?_(e,ho.load,{onSpanUnavailable:(e,t)=>console.info(`[demoman] preview: span ${e} could not be decoded (${t})`)}):Promise.resolve(v(e,ho.load)));async function bs(e){let{bundle:t,scene:n}=e;if(t===null||Rn(us,e))return;us=Ln({scene:n,bundle:t}),ls=[];let r=fe(n).retiming.motionDiffThreshold,i=()=>{let e=I.snapshot();return e.scene===n&&e.bundle===t},a;try{a=await ys(t),ls=await o(t,a,r)}catch(e){M(e),i()&&I.setHoverReport(zn),$(I.snapshot());return}try{let e=await ut(n,t,a,r);if(i()){let t=le(I.snapshot().scene);I.setHoverReport(Vn(e,t))}}catch(e){M(e),i()&&I.setHoverReport(zn)}$(I.snapshot())}var xs=null,Ss=null,Cs=null,Y=null,ws=``,Ts=null,Es=null,Ds=null,Os=null,ks=null,As=null,js=null,Ms=null,Ns=null,Ps=null,Fs=null,Is=null,Ls=null;function Rs(e){let t=Ue(Ls,e,M);return Ls=t.preview,t.branding}function zs(e){Ls={patch:e,scene:I.snapshot().scene},Zs();let t=I.snapshot();Vs(t,W(t.bundle))}function Bs(e){yo!==null&&(yo=null,$(I.snapshot())),j.files.reveal(e).catch(e=>{let t=rr(e);t.expected?console.info(`demoman editor: ${t.text}`):M(e),yo=t.text,$(I.snapshot())})}function Vs(e,t){let n=Xe({durationMs:yc-Z,fileType:jo(),target:t,hasFrames:Nc(e).kind!==`noFrames`}),r=F(`take-meta`);r.textContent=n,r.setAttribute(`aria-label`,`Video info: ${n}`)}var Hs=null;function Us(e){return Fs===null?e.cursor:{...e.cursor,...Fs}}function Ws(e){let t=e.motion??ie;return Is===null?t:{...t,...Is}}var Gs=null,Ks=null;function qs(e){Fs=e,Zs()}function Js(e){Is=e,Zs()}function Ys(){Is!==null&&(Is=null,Zs())}function Xs(){Fs!==null&&(Fs=null,Zs())}function Zs(){Ks===null&&(Ks=requestAnimationFrame(()=>{Ks=null;let e=I.snapshot();ic(e),J&&(Hs=Us(e.scene),Gs=Ws(e.scene),vs=q,Q.seek(Q.positionMs))}))}function Qs(){Ks!==null&&cancelAnimationFrame(Ks),Ks=null,Fs=null,Is=null}function $s(e){return e===null?null:Ts?.ref===e?Ts.thumb:{kind:`loading`}}function ec(e){return e.kind===`image`&&Ps?.ref!==e.ref?{ref:e.ref,thumb:{kind:`loading`}}:Ps}function tc(e){if(Ns=null,ks===null)return null;let t=as&&Ls?.patch.background!==void 0;try{return Ge(t?Ve(ks,K):ks,e,K)}catch(e){return Ns=`it could not be blurred: ${e instanceof Error?e.message:String(e)}`,null}}async function nc(e){let t=Rs(e.scene).background;if(!Le(t)){if(As===null&&js===null)return;ks=null,As=null,js=null,Ms=null,$(I.snapshot());return}let n=ze(t,K),r=As?.key===n?As:null;if(r!==null&&(r.error!==null||ks!==null&&it(K,r.natural).width<=ks.width)){js=null;return}if(js===n)return;js=n,r===null&&(Ms=null);let i=null,a=null;try{i=await at(t,K,j.wallpapers)}catch(e){a=e instanceof Error?e.message:String(e)}if(js!==n){i!==null&&`close`in i.image.image&&i.image.image.close();return}if(js=null,ks=i?.image??null,As={key:n,natural:i?.natural??null,error:a},Ms=a,t.kind===`image`){let e=Ps,n;if(i===null)n={kind:`failed`,reason:a??``};else if(Ps?.ref===t.ref&&Ps.thumb?.kind===`ready`)n=Ps.thumb;else try{n={kind:`ready`,url:await Re(i.image)}}catch(e){n={kind:`failed`,reason:e instanceof Error?e.message:String(e)}}if(Ps!==e)n.kind===`ready`&&n!==e?.thumb&&URL.revokeObjectURL(n.url);else{let e=Ps?.thumb;e?.kind===`ready`&&e!==n&&URL.revokeObjectURL(e.url),Ps={ref:t.ref,thumb:n}}}$(I.snapshot())}async function rc(e){let t=Rs(e.scene),n=t.logo?.ref??null;if(n!==Ss&&(Ss=n,Cs=null,Y=null,xs=null,ws=``,n!==null)){let e=await j.logos.load(n);if(Ss!==n)return;e.ok?Cs=e.source:Y=e.error}let r=g(t,K),i=`${n}@${r}`;if(Cs!==null&&r>0&&i!==ws){ws=i;try{let e=await Cs.rasterAt(r);if(Ss!==n||ws!==i)return;xs=e,Y=null}catch(e){xs=null,Y=e instanceof Error?e.message:String(e)}}let a=null;if(n!==null){if(Cs!==null){try{a={kind:`ready`,url:await Ze(Cs)}}catch(e){a={kind:`failed`,reason:e instanceof Error?e.message:String(e)}}if(Ss!==n)return}else a=Y===null?{kind:`loading`}:{kind:`failed`,reason:Y}}let o=JSON.stringify(a)!==JSON.stringify(Ts?.thumb??null)||(Ts?.ref??null)!==n;Ts=n===null?null:{ref:n,thumb:a};let s=Cs?Ie(Cs,g(t,W(e.bundle)),qe(jo(),e.scene.canvas.aspect)):null,c=[Os?.ref===n?Os.note:null,s].filter(e=>e!==null),l=o||xs!==Es||Y!==Ds||c.join(`
3
- `)!==Co.join(`
4
- `);Co=c,Es=xs,Ds=Y,l&&$(I.snapshot())}function ic(e){ns(e.bundle);let{scene:t,bundle:n}=e,r=Us(t),i=Rs(t),a=$n(t,{cursor:r,branding:i,motion:Is===null?t.motion:Ws(t)}),o=n?u({plan:fe(a),bundle:n,scene:a,target:K,detailTarget:W(n),hints:ls,logo:xs,wallpaper:tc(i.background)}):null;J=o?.resolved??null,q=o?.presentation??null,$o.width!==K.width&&($o.width=K.width),$o.height!==K.height&&($o.height=K.height)}var ac=[];function oc(e,t){let n=t.width*t.height/1e6;n<=0||(ac.push(e/n),ac.length>60&&ac.splice(0,ac.length-30))}var sc=null,cc=null,lc=2e3,uc=!1,X={requestedFrames:0,drawnFrames:0,elapsedMs:0,sourceLookupMs:0,composeMs:0,blitMs:0},dc=0,fc=null,pc=null,mc=0,hc=0;function gc(){X.requestedFrames=0,X.drawnFrames=0,X.elapsedMs=0,X.sourceLookupMs=0,X.composeMs=0,X.blitMs=0,mc=0,hc=0,dc=performance.now()}function _c(){if(Q.playing===uc)return;if(uc=Q.playing,$(I.snapshot()),uc){fc={width:K.width,height:K.height},gc();return}X.elapsedMs=performance.now()-dc;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(Yn({...X,...e===null?{}:{sourceFrame:e},...fc===null?{}:{bitmap:fc},parkedHeight:K.height,msPerMegapixel:pc,...hc>0?{decodeMs:mc}:{}}))}var vc=Xn({schedule:e=>requestAnimationFrame(e),onDrawFailed:e=>{xo(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:J,presentation:q,target:K,offscreen:es,offscreenCtx:ts};if(!n.resolved||!n.presentation||!t.bundle)return;let r=performance.now(),i=await ys(t.bundle),a=performance.now();uc&&i.warm?.(_e(n.resolved.timeline,e),_e(n.resolved.timeline,e+lc));let o=0;await Ce({resolved:n.resolved,target:n.target,presentation:n.presentation,frames:i,ctx:n.offscreenCtx,outputTimeMs:e,onStage:(e,t)=>{e===`fetch`&&(o=t,uc&&(mc+=t,hc+=1))}});let s=performance.now();if(n.offscreen===es){if(oc(s-a-o,n.target),$o.getContext(`2d`)?.drawImage(es,0,0),Q.playing&&cc!==null&&(cc+=1,cc>=15)){let e=ac.slice(-cc),t=sc;sc=null,sc=xc(I.snapshot().bundle,F(`stage-frame`).getBoundingClientRect().width,e).height,cc=null,sc!==t&&($(I.snapshot()),fc={width:K.width,height:K.height})}Bo&&(V?.kind===`mask`||V?.kind===`zoom`)&&Jr(F(`stage-overlay`),{canvas:$o,selection:V,model:Bo,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})}),uc&&(X.drawnFrames+=1,X.sourceLookupMs+=a-r,X.composeMs+=s-a,X.blitMs+=performance.now()-s)}}}),Z=0,yc=0,bc=!1,Q=Zn({seek:e=>{uc&&(X.requestedFrames+=1),vc.seek(e)},durationMs:()=>bc?yc:0,startMs:()=>Z,looping:()=>Wo,now:()=>performance.now(),schedule:e=>requestAnimationFrame(e),onChange:()=>{_c(),Tc()}});function xc(e,t,n=ac){let r=W(e),i=()=>Kn({target:r,paintedCssWidth:t,devicePixelRatio:window.devicePixelRatio,playing:Q.playing,msPerMegapixel:Gn(n)});return Q.playing?(sc===null&&(sc=i(),pc=Gn(n),cc=0),qn(r,sc)):(sc=null,qn(r,i()))}function Sc(e){e!==I.snapshot().scene.canvas.aspect&&L({kind:`setAspect`,aspect:e}).then(()=>Q.seek(Q.positionMs))}function Cc(e){if(e===Po())return;let t=document.activeElement instanceof HTMLElement&&document.activeElement.hasAttribute(`data-export-quality`);No=e,$(I.snapshot()),t&&document.querySelector(`[data-export-quality="${e}"]`)?.focus()}function wc(e,t){if(Ao.includes(e)===t)return;let n=document.activeElement instanceof HTMLElement&&document.activeElement.hasAttribute(`data-file-type`);Ao=Ke.filter(n=>n===e?t:Ao.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 Tc(){pa(F(`transport`),{authored:St(I.snapshot().scene),rerunLine:Bt(Pc(I.snapshot())),playing:Q.playing,enabled:bc&&yc>Z,rate:Q.rate,looping:Wo},{onToggle:Ec,onSkipToStart:()=>yl({kind:`seekEdge`,edge:`head`},I.snapshot()),onLooping:e=>{Wo=e,Tc()},onShuttle:e=>{z=null,Q.shuttle(e)}});for(let[e,t]of[[F(`stage-tools`),F(`toolbar-clock`)],[F(`stage-bar`),F(`stage-bar`)]])ma(e,{authored:St(I.snapshot().scene),rerunLine:Bt(Pc(I.snapshot())),positionMs:Q.positionMs-Z,durationMs:yc-Z,aspect:I.snapshot().scene.canvas.aspect,enabled:bc&&yc>Z,fullscreen:!!document.fullscreenElement,error:bo?null:z,zoom:Ro},{onAspect:Sc,onFullscreen:Oc,onZoom:Dc,onDismissError:()=>{bo=!0,Tc()}},t);let e=F(`timeline`).querySelector(`[data-playhead]`);e&&G&&(e.style.left=`${(Oa(G,Q.positionMs)*100).toFixed(4)}%`)}function Ec(){z=null,Q.toggle(),$(I.snapshot())}function Dc(){Ro=Ro===`fit`?`actual`:`fit`,document.body.dataset.zoom=Ro,Tc()}function Oc(){z=null;let e=!document.fullscreenElement;(e?F(`stage`).requestFullscreen():document.exitFullscreen()).catch(t=>{xo(`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,Tc();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 kc(){let e=I.snapshot();Ac(qt(e.scene,e.bundle,J?.timeline??null,Q.positionMs))}function Ac(e){if(e!==null){if(_n(e)){Jo=e.reason,$(I.snapshot());return}L(e)}}function jc(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&&(zo(null),$(r))})}function Mc(e){if(M(e),wo=e instanceof Error?e.message:String(e),Sl){$(I.snapshot());return}Mi(F(`failure`),{error:null,replaySentence:null,captureSentence:null,openError:wo})}function Nc(e){return e.bundle===null?{kind:`noFrames`}:{kind:`exact`}}function Pc(e){let t=St(e.scene);return{takeId:P,authored:t,rerun:j.nav.rerun(P,t)}}function Fc(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){os=!1,Qs(),ic(e);let t=Fc(J);t!==hs&&(hs=t,console.info(t));let n=Yr({scene:e.scene,bundle:e.bundle,resolved:J}),r=F(`name`);r.value=e.scene.meta.name,r.placeholder=Pe(e.scene.meta),F(`undo`).disabled=!e.canUndo,F(`redo`).disabled=!e.canRedo,ki(F(`banner`),{hasFrames:e.bundle!==null,route:Pc(e)}),B!==null&&e.scene!==So&&(B=null),Mi(F(`failure`),{error:e.error??B,replaySentence:e.replaySentence,replayRecoverable:e.replayRecoverable,captureSentence:e.captureSentence,renderError:R.error,previewError:z,logoLoadError:Y,wallpaperLoadError:Ms??Ns,openError:wo,deleteError:To,navigationError:Eo,runsRoute:Pc(e)});let i=on({scene:e.scene,view:n,bundle:e.bundle,resolved:J,hoverReport:e.hoverReport,rerunLine:Bt(Pc(e))});Bo=i,Vo=n,Ho=i.durationMs,(G===null||qo!==i.durationMs)&&(G=Zr(i.durationMs),qo=i.durationMs);let a={resolved:J,bundle:e.bundle,viewport:e.scene.meta.capture.viewport},o=e=>Ac(Pn(i,n,e,a)),s=e=>{G=e,$(I.snapshot())},c=e=>{Uo=e,$(I.snapshot())};ro(F(`timeline`),i,{viewport:G,selection:V,get positionMs(){return Q.positionMs},refusal:Jo,hoverReport:e.hoverReport,snapping:Uo,openJoin:Do},{onSelect:e=>{zo(e),$(I.snapshot())},onSeek:e=>Q.seek(e),onSeekStart:()=>Q.pause(),onSplit:kc,onRestorePiece:e=>{Do=null,L({kind:`restorePiece`,id:e})},onOpenJoin:e=>{Do=e,$(I.snapshot())},onGesture:o,onViewport:s,onSnapping:c}),Oi(F(`take-notes`),{notices:[...fs??[],...ms(e)?[ps]:[],...i.notices],hoverReport:e.hoverReport}),lo(F(`timeline-tools`),i,{viewport:G,snapping:Uo,get positionMs(){return Q.positionMs}},{onGesture:o,onSplit:kc,onViewport:s,onSnapping:c});let l=V;l?.kind===`piece`&&!i.clip.pieces.some(e=>Jt(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`)),zo(null)),document.body.dataset.panel=U?`open`:`closed`,bi(F(`rail`),{rail:H,panelOpen:U,hasSelection:u},{onPick:bl}),xi(F(`export-open`),{rail:H,panelOpen:U},{onPick:bl}),Si(F(`shortcuts-open`),{rail:H,panelOpen:U},{onPick:bl});let f=document.activeElement?.matches(`[data-shortcuts-search]`)===!0;_i(F(`inspector`),{selection:V,view:n,model:i,scene:e.scene,hoverReport:e.hoverReport,viewport:e.scene.meta.capture.viewport,rail:H,sections:ko,attachedToCuts:J?.plan.attachedToCuts??[]},{onClose:xl,onGap:(e,t)=>Ac(Fn(n,e,t)),onGapClear:e=>L({kind:`clearGap`,afterActionId:e}),onKeepHover:Ic,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&&(zo({kind:`zoom`,id:e.id}),$(I.snapshot()))})},onZoomScale:(e,t)=>L({kind:`setZoomScale`,id:e,scale:t}),onRemoveZoom:e=>jc({kind:`removeZoom`,id:e}),onMaskNote:(e,t)=>L({kind:`setMaskNote`,id:e,note:t}),onRemoveMask:e=>jc({kind:`removeMask`,id:e})});let p=document.querySelector(`#inspector [data-panel-shortcuts]`);p!==null&&ba(p,{mac:Br(navigator.userAgent),query:Go,focus:U&&(Ko||f)},{onClose:xl,onQuery:e=>{Go=e}}),Ko=!1,Jr(F(`stage-overlay`),{canvas:$o,selection:V,model:i,resolved:J,presentation:q,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`);_&&Ni(_,{branding:e.scene.branding,logoThumb:$s(e.scene.branding.logo?.ref??null),logoPlacement:q?.logoPlacement??null,formatTitle:qe(jo(),e.scene.canvas.aspect),logoNotes:Co,wallpaper:{thumbUrl:Be,custom:ec(e.scene.branding.background),loadError:null},kit:{read:N,standing:mo(e.scene.branding),naming:po,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}.`,So=I.snapshot().scene,$(I.snapshot());return}fo=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 zc(),onStartNew:()=>{po={text:``,error:null},$(I.snapshot())},onNameInput:e=>{po!==null&&(po={text:e,error:null})},onConfirmNew:e=>void Bc(e),onCancelNew:()=>{po=null,$(I.snapshot())}}},{onCommit:e=>L({kind:`setBranding`,patch:e}),onPreview:zs,onLogoFile:e=>Lc(e).catch(M),onWallpaperFile:e=>Rc(e).catch(M)});let v=g(`cursor`);v&&Ki(v,Us(e.scene),Ws(e.scene),{onCursor:e=>{Qs(),L({kind:`setCursor`,patch:e})},onCursorPreview:qs,onCursorPreviewEnd:Xs,onMotion:e=>{Qs(),L({kind:`setMotion`,patch:e})},onMotionPreview:Js,onMotionPreviewEnd:Ys},e.scene.meta.capture.device?.touch===!0);let y=W(e.bundle),ee=g(`export`);ee&&$i(ee,{outputs:Yo,fileTypes:Ao,files:R.files,quality:Po(),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:yo,repo:Yc(),readiness:Nc(e),runsRoute:Pc(e),currentDigest:Lo(e.scene),sections:ko,beatAt:kt(n.beats),hasReclaimedMotion:e.bundle?.degradations.some(e=>e.kind===`motionReclaimed`)??!1},{onExport:()=>Vc().catch(M),onFileType:wc,onRetry:e=>Vc([e]).catch(M),onQuality:Cc,onSaveAgain:e=>Hc(e).catch(M),onReveal:Bs,onAddToRepo:()=>void $c().catch(M),onRemoveFromRepo:()=>void el().catch(M)}),bc=n.hasBundle,Z=i.clip.trim.headMs,yc=i.clip.trim.tailMs,Vs(e,y),Ta(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,rerun:Pc(e).rerun,revealError:yo,history:{outputs:Yo,currentDigest:Lo(e.scene),showAll:Zo,warningsOpen:Qo,reportContext:{beatAt:kt(n.beats),runsRoute:Pc(e)}}},{onCopy:e=>navigator.clipboard.writeText(e),onDownload:e=>Hc([e]).catch(M),onReveal:Bs,onShowAll:()=>{Zo=!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>yc&&Q.seek(yc),Tc();let b=Us(e.scene),x=Ws(e.scene),te=JSON.stringify(e.scene.edits.removed??[]);J&&q&&(e.bundle!==gs||K.height!==_s||er(Hs,b)||tr(Gs,x)||nr(vs,q)||te!==ds)&&(gs=e.bundle,Hs=b,Gs=x,vs=q,_s=K.height,ds=te,Q.seek(Q.positionMs)),rc(e).catch(M),nc(e).catch(M)}function Ic(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 Lc(e){B=null;let t=xe(e),n=e=>{B=e,So=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);Os=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 Rc(e){B=null;let t;try{({ref:t}=await j.wallpapers.put(e))}catch(e){B=e instanceof Error?e.message:String(e),So=I.snapshot().scene,$(I.snapshot());return}await I.dispatch({kind:`setBranding`,patch:{background:He(t,I.snapshot().scene.branding.background)}})}async function zc(){let e=mo(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}".`,So=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 uo.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 uo.read()}catch(e){B=`The brand kit "${t.name}" was not saved: ${e instanceof Error?e.message:String(e)}`,So=I.snapshot().scene}$(I.snapshot())}async function Bc(e){let t=N.state===`ready`?N.kits:[],n=re(e,t,null);if(!n.ok){po={text:e,error:n.reason},$(I.snapshot());return}let r=I.snapshot().scene.branding,i=y();try{let t=await uo.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){po={text:e,error:t},$(I.snapshot());return}po=null,fo=i,N=await uo.read()}catch(e){B=`The brand kit "${n.name}" was not saved: ${e instanceof Error?e.message:String(e)}`,So=I.snapshot().scene}$(I.snapshot())}async function Vc(e=Ao){yo=null;let t=I.snapshot().scene;R=jt(e),$(I.snapshot());let n=0;try{await I.settled();let r=Po();for(let i of e)await j.exports.start(P,{fileType:i,aspect:t.canvas.aspect,revision:go,...r===null||i!==`mp4`||No===null&&!Fo?{}:{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:Mt(r)===null?{phase:`idle`}:R.run,error:R.error===null?t:`${R.error}; ${t}`},$(I.snapshot()),e}}async function Hc(e){let t=Xo(),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 Uc=!1;function Wc(){let e=document.querySelector(`[data-panel-export]`);e!==null&&!Yi(e,R.run,Ao,Nc(I.snapshot()),R.files)&&!Uc&&(Uc=!0,M(Error(`the Export panel has no start button, so progress cannot show`)))}var Gc=null,Kc=null,qc=null,Jc=!1;function Yc(){let e=Gc;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:Jc,status:Kc,note:qc}}var Xc=0;async function Zc(){if(j.folder===void 0)return;let e=++Xc,t=await j.folder.read();if(e!==Xc)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(Gc)&&(Kc=null,qc=null),Gc=i,Sl&&$(I.snapshot())}j.folder?.onChange(()=>void Zc().catch(M)),Zc().catch(M);var Qc=e=>e.replace(/\.$/,``);async function $c(){let e=Gc;if(Jc||e===null||e.addable?.ok===!1)return;Jc=!0,Kc=null,qc=null;let t=null;$(I.snapshot());try{let n=await Me({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(Ee(e))}.`}finally{Jc=!1}await Zc(),Kc=t,$(I.snapshot())}async function el(){let e=Gc?.video.kept;if(Gc===null||e==null||`unknown`in e)return;let{video:t}=Gc;Kc=null,qc=null;let n=null,r=null;if(await se(Ae(t,e.file))){try{let e=await j.videos.repo.remove(t.id);e.notes.length===0?ve(Oe(t.name)):r=[Oe(t.name),...e.notes].join(` `)}catch(e){n=`Couldn't remove: ${Qc(Ee(e))}.`}await Zc(),Kc=n,qc=r,$(I.snapshot())}}function tl(e){let t=Lt(R,e);switch(R=t.flow,t.effect){case`render`:$(I.snapshot());return;case`progress`:Wc();return;case`relist`:j.outputs.list(P).then(e=>{Yo=e,$(I.snapshot())}).catch(M);return;case`none`:return}}j.exports.onEvent(tl),j.nav.onOpen?.(e=>cl(()=>location.assign(e))),F(`name`).addEventListener(`change`,e=>{L({kind:`rename`,name:e.target.value.trim()})});var nl=e=>()=>{let t=I.snapshot().scene;e().catch(M).then(()=>vo(t))};F(`undo`).addEventListener(`click`,nl(()=>I.undo())),F(`redo`).addEventListener(`click`,nl(()=>I.redo()));var rl={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 il(e){To=e,al()}function al(){if(Sl){$(I.snapshot());return}Mi(F(`failure`),{error:null,replaySentence:null,captureSentence:null,deleteError:To,navigationError:Eo})}function ol(e,t,n=``){Eo=null;try{location.assign(t())}catch(t){M(t),Eo={page:e,reason:`${n}${t instanceof Error?t.message:String(t)}`},al()}}function sl(e=``,t=null,n=null){let r=j.nav.library(),i=n===null||n===``?r:`${r}${r.includes(`?`)?`&`:`?`}from=${encodeURIComponent(n)}`;ol(`Flows page`,()=>we(i,t),e)}function cl(e){(async()=>{let t=null,n=I.subscribe(e=>{t=e});try{await I.settled()}finally{n()}t?.error??e()})()}F(`back`).addEventListener(`click`,()=>{cl(()=>sl(``,null,P))});function ll(e){let t=ul(e);t&&(e.preventDefault(),cl(()=>ol(`Runs page`,()=>t.href)))}F(`banner`).addEventListener(`click`,ll),F(`inspector`).addEventListener(`click`,ll),F(`take-info`).addEventListener(`click`,ll),F(`failure`).addEventListener(`click`,ll),F(`take-info`).addEventListener(`toggle`,e=>{F(`take-meta`).setAttribute(`aria-expanded`,String(e.newState===`open`))});function ul(e){let t=(e.target instanceof Element?e.target:null)?.closest(`a[data-runs-route]`);return!t||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey?null:t}var dl=null;document.addEventListener(`mousedown`,e=>{let t=ul(e);dl=t?{link:t,href:t.href}:null},!0),document.addEventListener(`mouseup`,e=>{let t=dl;if(dl=null,!t)return;let n=ul(e);!n||n===t.link||n.href===t.href&&cl(()=>ol(`Runs page`,()=>n.href))},!0),F(`delete`).addEventListener(`click`,()=>{(async()=>{try{if(!await se(de))return}catch(e){M(e),il(`Not deleted: the confirmation could not open — ${e instanceof Error?e.message:String(e)}.`);return}To=null;let e;try{e=await j.scenes.remove(P)}catch(e){M(e),il(`Not deleted: ${e instanceof Error?e.message:String(e)}.`);return}if(!e.ok){il(`Not deleted: ${rl[e.error]??e.detail??e.error}.`);return}if(e.result!==void 0&&!e.result.ok){let t=e.result.steps.find(e=>!e.ok);il(`Partly deleted: ${t?.step??`a step`} could not be removed — ${t?.error??`unknown error`}. Open Flows to retry.`);return}let t=e.note??null;sl(t===null?`This video was deleted. `:`This video was deleted. ${t} `,t===null?Fe:`This video was deleted. ${t}`)})()});var fl=Symbol.for(`demoman.editor.keydown`),pl=globalThis,ml=pl[fl];ml instanceof AbortController&&ml.abort();var hl=new AbortController;pl[fl]=hl;var gl=!1,_l=null;document.addEventListener(`pointerdown`,()=>{gl=!0},{capture:!0,signal:hl.signal}),document.addEventListener(`pointerdown`,()=>{Do!==null&&(Do=null,$(I.snapshot()))},{signal:hl.signal}),document.addEventListener(`keydown`,()=>{gl=!1},{capture:!0,signal:hl.signal}),document.addEventListener(`focusin`,e=>{_l=gl?e.target:null},{signal:hl.signal});var vl=new WeakMap;document.addEventListener(`focusin`,e=>{let t=e.target;(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&vl.set(t,t.value)},{signal:hl.signal}),document.addEventListener(`change`,e=>{let t=e.target;(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&vl.set(t,t.value)},{capture:!0,signal:hl.signal}),document.addEventListener(`keydown`,e=>{if(document.querySelector(`dialog[open]`)!==null)return;if(e.key===`Escape`&&Do!==null){e.preventDefault(),Do=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=vl.get(t);e!==void 0&&t.value!==e&&(t.value=e)}t?.blur()}return}let r=e.key===`Enter`||e.key===` `&&t!==_l;if((n===`BUTTON`||n===`A`)&&r&&t?.hasAttribute(`data-tick`)!==!0)return;let i=I.snapshot(),a=Mr(e,{hasSelection:V!==null,selectionIsBeat:V?.kind===`tick`,canUndo:i.canUndo,canRedo:i.canRedo,panelOpen:U,hasTimeline:G!==null&&Ho>0});a!==null&&(e.preventDefault(),yl(a,i))},{signal:hl.signal});function yl(e,t){switch(e.kind){case`playPause`:Ec();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:yc);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;zo({kind:`tick`,actionId:i}),$(t);return}case`setTrim`:{let n=Bo,r=Vo;if(n===null||r===null||J===null||!bc){let e=Pc(t);Jo=`This video has not been rendered yet, so there is nothing to trim to. ${Vt(e.authored,Bt(e),`first`)}`,$(t);return}Ac(Pn(n,r,{kind:`trim`,edge:e.edge,toMs:Q.positionMs,snapMs:0},{resolved:J,bundle:t.bundle,viewport:t.scene.meta.capture.viewport}));return}case`split`:kc();return;case`undo`:nl(()=>I.undo())();return;case`redo`:nl(()=>I.redo())();return;case`deleteSelection`:if(V===null)return;if(V.kind===`zoom`){jc({kind:`removeZoom`,id:V.id});return}if(V.kind===`mask`){jc({kind:`removeMask`,id:V.id});return}if(V.kind===`piece`){Ac(Yt(Bo?.clip.pieces??[],V.start,Bo?.clip.trim));return}Ac({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=ei(G,Ho,e.factor,n),$(t);return}case`zoomFit`:G=Zr(Ho),$(t);return;case`toggleSnapping`:Uo=!Uo,$(t);return;case`clearSelection`:zo(null),$(t);return;case`toggleHelp`:bl(`shortcuts`);return;case`closePanel`:xl();return}}function bl(e){H===e&&U?U=!1:(H=e,U=!0,e===`shortcuts`&&(Ko=!0)),e!==`selection`&&(Oo=e),$(I.snapshot())}function xl(){U=!1,$(I.snapshot())}ga(),li(),document.body.dataset.zoom=`fit`;{let e=F(`notes`),t=``,n=()=>{va(F(`notes-open`),e),t=ya(e,t)};new MutationObserver(n).observe(e,{childList:!0,subtree:!0,characterData:!0}),n()}var Sl=!1;I.subscribe(e=>{Sl=!0,wo=null,$(e)}),I.subscribe(e=>bs(e).catch(M));async function Cl(){N=await uo.read(),Sl&&$(I.snapshot())}Cl().catch(M),uo.onChange===void 0?console.info(`demoman: no storage change feed here, so the brand kit is read once`):uo.onChange(()=>{Cl().catch(M)});async function wl(){let e=j.exportQuality;if(e===void 0)return;let t=await e.read();Fo=t.unreadable===void 0,t.unreadable!==void 0&&console.info(`demoman editor: the Studio exports at ${a[t.quality]} quality: ${t.unreadable}`),t.quality!==Mo&&(Mo=t.quality,Sl&&$(I.snapshot()))}j.exportQuality!==void 0&&(wl().catch(M),window.addEventListener(`focus`,()=>{wl().catch(M)})),j.outputs.list(P).then(e=>{Yo=e,Sl&&$(I.snapshot())}).catch(M),I.load().catch(Mc);
@@ -1 +0,0 @@
1
- import{a as e,b as t,c as n,d as r,f as i,h as a,i as o,m as s,n as c,o as l,p as u,r as d,s as f,t as p,u as m,x as h,y as g}from"./toast-D-n2UDmc.js";import{S as _,T as v,_ as y,a as b,b as x,c as S,d as C,g as w,h as T,i as E,l as D,m as O,n as k,o as A,p as j,r as ee,t as te,u as M,v as ne,y as re}from"./state-nRiGhQ0_.js";import{n as ie,t as ae}from"./topbar-DW2VlQMA.js";var oe=new Set([`a`,`an`,`the`,`and`,`in`,`on`,`of`,`for`,`by`,`to`,`with`]),se=e=>e.length>3&&e.endsWith(`s`)&&!e.endsWith(`ss`)?e.slice(0,-1):e;function ce(e){return e.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(e=>e&&!oe.has(e)).map(se)}function le(e,t){let n=e.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean),r=t&&n.length>0&&/[\p{L}\p{N}]$/u.test(e)?n.pop():null;return{words:n.flatMap(ce),prefix:r===null?null:se(r)}}function ue(e,t=!1){let{words:n,prefix:r}=le(e,t);return n.length>0||r!==null}function de(e,t,n){let{words:r,prefix:i}=le(e,t),a=[...new Set(n.flatMap(ce))],o=new Set(r.filter(e=>a.includes(e)));return i!==null&&a.some(e=>e.startsWith(i))&&o.add(i),o}var fe=e=>[e.name,...e.pages,...e.steps];function pe(e,t,n=!1){return de(e,n,fe(t)).size}function me(e,t,n=!1){if(de(e,n,[t.name]).size>0)return null;let r=t.steps.find(t=>de(e,n,[t]).size>0);if(r!==void 0)return{step:r};let i=t.pages.find(t=>de(e,n,[t]).size>0);return i===void 0?null:{page:i}}function he(e,t,n=!1){for(let r of t.matchAll(/[\p{L}\p{N}]+/gu))if(de(e,n,[r[0]]).size>0)return r.index;return-1}function ge(){let e=new Map,t=new Map,n=new WeakMap,r=e=>{let t=n.get(e);return t===void 0&&(t=v(e),n.set(e,t)),`${e.meta.id}:${t}`};return{get:t=>e.get(r(t)),measure(n,i){let a=r(n),o=e.get(a);if(o!==void 0)return Promise.resolve(o);let s=t.get(a);return s===void 0&&(s=i().then(n=>(e.set(a,n),t.delete(a),n),e=>{throw t.delete(a),e}),t.set(a,s)),s}}}function _e(e,t){t!==void 0&&(t instanceof Error?(e.textContent=`—`,e.title=t.message):t.kind===`nothing`?(e.textContent=`—`,e.title=t.reason):(e.textContent=r(t.ms),e.removeAttribute(`title`)))}function ve(e,t){let n=e=>({ref:e.ref,sourceTimeMs:e.sourceTimeMs});if(e.length<=t)return e.map(n);let r=t>1?(e.length-1)/(t-1):0,i=new Set(Array.from({length:Math.max(0,t)},(e,t)=>Math.round(t*r)));return e.filter((e,t)=>i.has(t)).map(n)}function ye(e){return e===null?{kind:`noBundle`}:e.keyframes.length===0?{kind:`noKeyframes`}:{kind:`ready`,frames:ve(e.keyframes,8)}}function be(e){switch(e.kind){case`ready`:return null;case`loading`:return`Loading preview…`;case`noBundle`:return`No frames stored — nothing to preview.`;case`noKeyframes`:return`This video has no keyframes.`;case`failed`:return`Preview unavailable — ${e.reason}`}}function xe(e,t){return t<=1?0:(e+1)%t}function Se(e,t){let n=e.querySelector(`[data-preview-canvas]`),r=e.querySelector(`[data-preview-note]`),i=be(t);n!==null&&(n.hidden=i!==null),r!==null&&(r.textContent=i??``)}function Ce(e){let t=[],n=!1;function i(i,a){let o=a.querySelector(`[data-preview-canvas]`);if(o===null){console.error(`demoman library: preview box for ${i} has no canvas to paint into`),Se(a,{kind:`failed`,reason:`this row has no canvas to paint into`});return}let s=[],c=[],l=0,u=null,d=()=>{u!==null&&(clearInterval(u),u=null)};t.push(d);let f=(e,t)=>{d(),console.error(`demoman library: ${e} for ${i} —`,t),Se(a,{kind:`failed`,reason:t instanceof Error?t.message:String(t)})},p=async t=>{let n=c[t];if(n!==void 0)return n;let r=s[t];if(r===void 0)throw Error(`preview frame ${t} is past the end of the video`);let i=await e.image(r.ref),a=document.createElement(`canvas`);return a.width=320,a.height=Math.max(1,Math.round(320*i.height/i.width)),a.getContext(`2d`)?.drawImage(i,0,0,a.width,a.height),i.close(),c[t]=a,a},m=async e=>{let t=await p(e);n||(o.width=t.width,o.height=t.height,o.style.setProperty(`--thumb-ratio`,String(t.width/t.height)),o.getContext(`2d`)?.drawImage(t,0,0))},h=()=>{l=xe(l,s.length),m(l).catch(e=>f(`drawing a keyframe`,e))},g=()=>{u!==null||s.length<=1||(u=setInterval(h,400))},_=()=>{d(),l=0,m(0).catch(e=>f(`drawing the first keyframe`,e))},v=()=>{let e=a.closest(`article`);if(e===null){console.error(`demoman library: preview box for ${i} has no row to hover`);return}e.addEventListener(`mouseenter`,g),e.addEventListener(`mouseleave`,_),e.addEventListener(`focusin`,g),e.addEventListener(`focusout`,_),t.push(()=>{e.removeEventListener(`mouseenter`,g),e.removeEventListener(`mouseleave`,_),e.removeEventListener(`focusin`,g),e.removeEventListener(`focusout`,_)})},y=t=>{let o=a.querySelector(`[data-duration]`);if(o===null){console.error(`demoman library: preview box for ${i} has no duration badge`);return}e.length(i,t).then(e=>{if(!n){if(e.kind===`nothing`){console.info(`demoman library: no length on ${i}'s card — ${e.reason}`);return}o.textContent=r(e.ms),o.title=`Length of the exported video`,o.hidden=!1}}).catch(e=>{console.warn(`demoman library: could not work out ${i}'s length —`,e)})},b=async()=>{let t;try{t=await e.bundle(i)}catch(e){f(`reading the frame bundle`,e);return}if(n)return;let r=ye(t);if(r.kind!==`ready`){Se(a,r);return}s=r.frames;try{await m(0)}catch(e){f(`drawing the first keyframe`,e);return}n||(Se(a,r),v(),t!==null&&y(t))};t.push(e.whenVisible(a,()=>{b()}))}return{mount:i,dispose(){n=!0;for(let e of t)e();t.length=0}}}function N(e){let t=e.group?.video;return t===void 0?null:t.addedTo===null?`key`in t.repo?t.repo.key:null:t.addedTo}var we=e=>e.replace(/^local:/,``).split(`/`).filter(e=>e!==``&&e!==`.git`),Te=e=>e.startsWith(`local:`);function Ee(e,t){let n=we(e),r=n.at(-1)??e;if(Te(e))return{owner:t.some(t=>t!==e&&Te(t)&&we(t).at(-1)===r)?n.at(-2)??null:null,name:r,local:!0};let i=e=>{let t=we(e);return t.length>2?t.slice(1,-1).join(`/`):t[0]??e},a=i(e);return{owner:t.some(e=>!Te(e)&&i(e)===a&&we(e).at(-1)===r&&we(e)[0]!==n[0])?`${n[0]}/${a}`:a,name:r,local:!1}}var De=e=>e.owner===null?e.name:`${e.owner}/${e.name}`;function Oe(e,t,n){let r=new Map,i=0;for(let t of e){let e=N(t);e===null?i+=1:r.set(e,(r.get(e)??0)+1)}typeof n==`object`&&!r.has(n.project)&&r.set(n.project,0);let a=[...r.keys()],o=a.map(e=>({key:e,...Ee(e,a),count:r.get(e)})).sort((e,t)=>Number(e.local)-Number(t.local)||De(e).localeCompare(De(t)));return{all:e.length,projects:o,none:i,unreadable:t}}var ke=(e,t)=>t===`all`?!0:t===`unreadable`?!1:t===`none`?N(e)===null:N(e)===t.project,Ae=e=>e.row.kept!=null,je=(e,t)=>t===`all`||t===`inRepo`===Ae(e);function Me(e,t,n){let r=E(e).filter(e=>ke(e,t)&&je(e,n)),i=new Set(r.flatMap(e=>e.group?[e.group]:[])),a=new Set;for(let e of r)if(e.group===null)a.add(e.row.sceneId);else for(let t of e.group.versions)a.add(t.sceneId);return{...e,rows:e.rows.filter(e=>a.has(e.sceneId)),groups:e.groups?.filter(e=>i.has(e))}}function Ne(e,t){let n=e.filter(e=>ke(e,t)),r=n.filter(Ae).length;return{inRepo:r,notInRepo:n.length-r,all:n.length}}function Pe(e,t){return t===`unreadable`?!1:t!==`none`||e.some(e=>ke(e,t)&&Ae(e))}var Fe=e=>!/\s$/u.test(e),Ie=e=>ue(e,Fe(e));function Le(e){let t=e.group?.video;return t===void 0?{name:e.row.label,pages:[],steps:[]}:{name:t.name||e.row.label,pages:t.pages,steps:t.steps}}var Re=(e,t)=>pe(t,Le(e),Fe(t));function ze(e,t){let n=Fe(t),r=me(t,Le(e),n);if(r===null)return null;let[i,a]=`step`in r?[`step`,r.step]:[`page`,D(r.page)||`/`],o=`${i}: ${a}`,s=he(t,a,n),c=i===`page`?a.lastIndexOf(`/`,s):s;return c>0&&o.length>12?{text:`${i}: …${a.slice(c)}`,full:o}:{text:o,full:o}}function Be(e,t){if(!Ie(t))return e;let n=E(e).filter(e=>Re(e,t)>0),r=new Set(n.flatMap(e=>e.group?[e.group]:[])),i=new Set;for(let e of n)if(e.group===null)i.add(e.row.sceneId);else for(let t of e.group.versions)i.add(t.sceneId);return{...e,rows:e.rows.filter(e=>i.has(e.sceneId)),groups:e.groups?.filter(e=>r.has(e))}}function Ve(e,t,n,r){if(t===`all`||!Ie(r))return[];let i=e.filter(e=>je(e,n)&&Re(e,r)>0);return[...Oe(e,0,`all`).projects.map(e=>({project:e.key})),`none`].flatMap(e=>{if(typeof e==`object`&&typeof t==`object`?e.project===t.project:e===t)return[];let n=i.filter(t=>ke(t,e)).length;return n>0?[{place:e,count:n}]:[]})}var He=()=>({ids:new Set,anchor:null,range:[]});function Ue(e,t,n,r,i){let a=e.anchor!==null&&r.includes(e.anchor)?e.anchor:i??null,o=a===null?-1:r.indexOf(a),s=r.indexOf(t);if(n===`range`&&o>=0&&s>=0){let t=new Set(e.ids);for(let n of e.range)r.includes(n)&&t.delete(n);let n=[];for(let e of r.slice(Math.min(o,s),Math.max(o,s)+1))t.has(e)||(t.add(e),n.push(e));return{ids:t,anchor:a,range:n}}let c=new Set(e.ids);return c.has(t)?c.delete(t):c.add(t),{ids:c,anchor:t,range:[]}}function We(e,t){return{ids:new Set([...e.ids,...t]),anchor:e.anchor,range:[]}}function Ge(e,t){let n=new Set(e.ids),r=t.length>0&&t.every(e=>n.has(e));for(let e of t)r?n.delete(e):n.add(e);return{ids:n,anchor:e.anchor,range:[]}}function Ke(e,t){return{ids:new Set([...e.ids].filter(e=>t.has(e))),anchor:e.anchor!==null&&t.has(e.anchor)?e.anchor:null,range:e.range.filter(e=>t.has(e))}}function qe(e,t,r,i={}){let a=document.createElement(`div`);a.className=`empty`;for(let[e,t]of Object.entries(i))a.setAttribute(e,t);let o=document.createElement(`strong`);o.textContent=t;let s=document.createElement(`p`);s.className=`hint`,s.append(...typeof r==`string`?[r]:r);let c=document.createElement(`div`);return c.append(o,s),a.append(n(e),c),a}var Je=new WeakMap;function Ye(e,t,n){let r=n.toLocaleLowerCase();for(let n=1;n<=e.length;n++){let i=(t+n+e.length)%e.length;if(e[i].toLocaleLowerCase().startsWith(r))return i}return null}var P=`[role=row][data-key]`,Xe=`head`,Ze=`[data-list-head] [data-sort]`,Qe=`button, input, a[href]`,$e=e=>[...e.querySelectorAll(`${P}:not([hidden])`)],et=e=>e.closest(`[role=gridcell], [role=columnheader]`)?.dataset.col??null;function tt(e){return[...e.querySelectorAll(`:scope > [role=gridcell]`)].flatMap(e=>{let t=[...e.querySelectorAll(Qe)];return t.length===0||e.dataset.col===`name`?[e,...t]:t}).filter(e=>e.checkVisibility({visibilityProperty:!0}))}var nt=(e,t)=>t===null?e:tt(e).find(e=>et(e)===t)??e;function rt(e){let t=Number(e.getAttribute(`aria-level`));for(let n=e.previousElementSibling;n!==null;){if(Number(n.getAttribute(`aria-level`))<t)return n;n=n.previousElementSibling}return null}function F(e){e!=null&&(e.focus({preventScroll:!0}),e.scrollIntoView({block:`nearest`}))}function it(e,t){for(let t of e.querySelectorAll(`[tabindex="0"]`))t.tabIndex=-1;t.tabIndex=0;let n=t.closest(P);Je.set(e,{key:n===null?Xe:n.dataset.key,col:t===n?null:et(t)})}function at(e){let t=e===null?void 0:Je.get(e);if(e===null||t===void 0)return null;let n=$e(e).findIndex(e=>e.dataset.key===t.key);return{...t,at:n,inside:e.contains(document.activeElement)}}function ot(e,t){if(t===null)return;let n=$e(e),r=n.find(e=>e.dataset.key===t.key)??n[Math.min(t.at,n.length-1)],i=t.key===`head`?e.querySelector(`[data-list-head] [data-col="${t.col}"] [data-sort]`):r===void 0?null:nt(r,t.col);i!==null&&(t.inside?i.focus({preventScroll:!0}):it(e,i))}function st(e,t){for(let t of e.querySelectorAll(`${Ze}, ${P}, ${P} > [role=gridcell], ${P} :is(${Qe})`))t.tabIndex=-1;let n=$e(e)[0];n!==void 0&&(n.tabIndex=0),e.addEventListener(`focusin`,t=>{let n=t.target,r=n.closest(P),i=n.matches(Ze);r===null&&!i||n.matches(`[data-name]`)||it(e,n)}),e.addEventListener(`keydown`,t=>{let n=t.target;if(!n.matches(Ze)||t.ctrlKey||t.altKey||t.metaKey||t.shiftKey)return;let r=[...e.querySelectorAll(Ze)].filter(e=>e.checkVisibility()),i=r.indexOf(n);switch(t.key){case`ArrowLeft`:F(r[i-1]);break;case`ArrowRight`:F(r[i+1]);break;case`ArrowDown`:F($e(e)[0]);break;case`ArrowUp`:case`Home`:case`End`:break;default:return}t.preventDefault()});let r=``,i=-1/0,a=-1,o=null;e.addEventListener(`keydown`,n=>{let s=n.target,c=s.closest(P);if(c===null||document.activeElement?.matches(`[data-name]`)||n.ctrlKey||n.altKey)return;let{key:l,metaKey:u,shiftKey:d}=n,f=$e(e),p=f.indexOf(c),m=s!==c,h=m?et(s):null,g=n.timeStamp-i<=500&&document.activeElement===o;if(l.length===1&&!u&&(l!==` `||g)){g||(r=``,a=p),r+=l,i=n.timeStamp;let e=Ye(f.map(e=>e.dataset.flow!==void 0||e.dataset.take!==void 0?e.getAttribute(`aria-label`)??``:``),a,r);e!==null&&F(nt(f[e],h)),o=document.activeElement,n.preventDefault();return}let _=m?tt(c):[],v=_.indexOf(s),y=e.closest(`[data-busy]`)!==null,b=c.dataset.flow,x=()=>{h===`actions`&&(b!==void 0||c.dataset.videoRow!==void 0)&&F(c)},S=c.hasAttribute(`aria-expanded`)&&(c.dataset.heading!==void 0||h===`open`);(()=>{if(u&&![`ArrowUp`,`ArrowDown`,`Backspace`,`a`,`A`].includes(l))return!1;switch(l){case`ArrowDown`:case`ArrowUp`:{let n=l===`ArrowDown`?1:-1;if(u){let e=n>0?f[f.length-1]:f[0];return F(e===void 0?null:nt(e,h)),!0}let r=f[p+n];if(r===void 0&&n<0&&!d)return F(e.querySelector(`[data-list-head] [data-col="${h}"] [data-sort]`)??e.querySelector(`[data-sort="name"]`)),!0;if(d){if(m)return!1;if(y)return!0;F(r);let n=r?.dataset.flow;return n!==void 0&&t.select?.(n,`range`,Lt(e),b),!0}return r!==void 0&&F(nt(r,h)),!0}case`ArrowRight`:return m?F(_[v+1]):c.getAttribute(`aria-expanded`)===`false`?It(c,!0):F(tt(c)[0]),!0;case`ArrowLeft`:return m?F(v>0?_[v-1]:c):c.getAttribute(`aria-expanded`)===`true`?It(c,!1):F(rt(c)),!0;case`Home`:return F(m?_[0]:f[0]),!0;case`End`:return F(m?_.at(-1):f.at(-1)),!0;case`PageDown`:case`PageUp`:{let e=Math.max(1,Math.floor(document.documentElement.clientHeight/Math.max(1,c.offsetHeight))),t=Math.min(f.length-1,Math.max(0,p+(l===`PageDown`?e:-e)));return F(nt(f[t],h)),!0}case`Enter`:if(m&&s.matches(Qe))return!1;if(S)It(c,c.getAttribute(`aria-expanded`)===`false`);else if(h===`name`)kt(c);else if(!m){if(e.closest(`[data-selecting]`)!==null)b!==void 0&&!y?t.select?.(b,`toggle`,Lt(e)):c.dataset.videoRow===void 0&&!c.hasAttribute(`data-absent`)&&c.dataset.scene!==void 0&&t.edit(c.dataset.scene);else if(!c.hasAttribute(`data-absent`)){let e=c.dataset.scene;e!==void 0&&t.edit(e)}}return!0;case` `:return m&&s.matches(Qe)?!1:(y||b!==void 0&&(x(),t.select?.(b,`toggle`,Lt(e))),!0);case`a`:case`A`:return y||(x(),t.selectAll?.(Lt(e))),!0;case`Backspace`:return u?(y||(e.closest(`[data-selecting]`)===null?b===void 0?c.dataset.scene!==void 0&&t.remove(c.dataset.scene,`take`):t.remove(b,`video`):t.deleteSelected?.()),!0):!1;case`Escape`:return m?(F(c),n.stopPropagation(),!0):!1;default:return!1}})()&&(n.preventDefault(),i=-1/0)})}var ct=e=>e!==`name`&&e!==`where`;function lt(e,t){return e.column===t?{column:t,descending:!e.descending}:{column:t,descending:ct(t)}}var ut=/^(?:localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/;function dt(e){return ut.test(e)?`localhost`:e}function ft(e,t,n){let r=!t||e.group===null?null:M(e.group.video.repo),{origin:i,path:a}=e.row,o=n===null?``:n===`short`?dt(i):i;return`${r===null?``:`${r} · `}${o}${a||`/`}`}function pt(e,t){let n=new Map;for(let t of e){let e=N(t);e!==null&&n.set(e,(n.get(e)??new Set).add(t.row.origin))}return e=>{let r=N(e);return{text:ft(e,t,r===null||(n.get(r)?.size??0)>1&&!ut.test(e.row.origin)?`short`:null),title:ft(e,t,`whole`)}}}function mt(e){let t=e.group===null?[e.row]:e.group.versions,n=t.flatMap(e=>e.sizeBytes===void 0?[]:[e.sizeBytes]);return n.length===0?{kind:`unknown`}:{kind:`known`,bytes:n.reduce((e,t)=>e+t,0),unmeasured:t.length-n.length}}var ht=e=>e.group===null?e.row.label:e.group.video.name||e.row.label,I=e=>{let t=Date.parse(e.row.createdAt);return Number.isNaN(t)?-1/0:t},gt=e=>e.group?.versions.length??1;function _t(e,t){switch(t){case`name`:return ht(e);case`where`:return[N(e)??``,e.row.path||`/`,e.row.origin];case`videos`:return gt(e);case`recorded`:return Number.isFinite(I(e))?I(e):null;case`size`:{let t=mt(e);return t.kind===`known`?t.bytes:null}}}function vt(e,t){for(let n=0;n<e.length;n++){let r=(e[n]??``).localeCompare(t[n]??``,void 0,{numeric:!0});if(r!==0)return r}return 0}function yt(e,t){let n=t.descending?-1:1;return[...e].sort((e,r)=>{let i=_t(e,t.column),a=_t(r,t.column);if(i===null||a===null){if(i!==a)return i===null?1:-1}else if(i!==a){let e=typeof i==`number`?i-a:vt(typeof i==`string`?[i]:i,typeof a==`string`?[a]:a);if(e!==0)return e*n}return I(r)-I(e)})}function bt(e,t,n){let r=E(e),i=[],a=(e,t,n)=>{let r=t===null?1:2,{group:a}=e,o=a===null?`t:${e.row.sceneId}`:`f:${a.video.id}`;i.push({kind:`flow`,key:o,parent:t,level:r,card:e,flowId:a===null?null:a.video.id,namesDay:n,size:mt(e)});for(let e of a?.versions??[])i.push({kind:`video`,key:`v:${e.sceneId}`,parent:o,level:r===1?2:3,row:e,flowId:a.video.id})};if(`rank`in t){let e=r.map(e=>[t.rank(e),e]);e.sort((e,t)=>t[0]-e[0]||I(t[1])-I(e[1]));for(let[,t]of e)a(t,null,!1);return i}let o=t;if(o.column===`recorded`&&o.descending){let e=yt(r,o),t=new Map(e.map(e=>[e.row.sceneId,e]));for(let r of C(e.map(e=>e.row),n)){let e=`h:${r.key}`;i.push({kind:`heading`,key:e,parent:null,level:1,section:r});for(let n of r.rows)a(t.get(n.sceneId),e,r.namesDay)}}else for(let e of yt(r,o))a(e,null,!1);return i}var xt=(e,t)=>e.expired===!0?{absent:Bt(!0,t.rerunLine?.(e.sceneId,e.authored))??`Expired`}:`here`,St=[[`select`,`Select`,null,!1],[`open`,`Open`,null,!1],[`name`,`Name`,`name`,!0],[`where`,`Where`,`where`,!0],[`videos`,`Videos`,`videos`,!0],[`length`,`Length`,null,!0],[`size`,`Size`,`size`,!0],[`recorded`,`Recorded`,`recorded`,!0],[`actions`,`Actions`,null,!1]];function Ct(e){return new Set([...e.querySelectorAll(`[data-list] [role=row][aria-expanded="false"]`)].map(e=>e.dataset.key))}function wt(e,t,r){let i=R(`div`,{role:`row`,"data-list-head":``});for(let[a,o,s,c]of St){let l=R(`div`,{role:`columnheader`,"data-col":a});c||l.setAttribute(`aria-label`,o),s!==null&&s===r?.column&&l.setAttribute(`aria-sort`,r.descending?`descending`:`ascending`);let u=t.setView;if(s!==null&&u!==void 0){let t=R(`button`,{type:`button`,"data-sort":s},o);l.hasAttribute(`aria-sort`)&&t.append(n(`chevronDown`)),t.addEventListener(`click`,()=>u({...e,sort:r===null?{column:s,descending:ct(s)}:lt(r,s)})),l.append(t)}else c&&(l.textContent=o);i.append(l)}return i}function Tt(e,t,n,r=n){e[t].textContent=n,e[t].title=r}var Et=()=>{let e=n(`chevronRight`);return e.classList.add(`chev`),e};function Dt(e,t,r){let i=`row-menu-${r}`,a=R(`button`,{type:`button`,class:`btn btn-quiet btn-icon row-more`,popovertarget:i,"aria-label":`More for ${t}`,title:`More`});a.append(n(`ellipsis`));let o=R(`div`,{id:i,popover:``,role:`menu`,class:`row-menu`});for(let t of e.querySelectorAll(`button`)){let e=R(`button`,{type:`button`,role:`menuitem`});t.classList.contains(`btn-danger`)&&e.classList.add(`btn-danger`),e.append(...[...t.childNodes].map(e=>e.cloneNode(!0)),t.title.split(` — `)[0]??t.title),e.disabled=t.disabled,t.getAttribute(`aria-disabled`)===`true`&&(e.setAttribute(`aria-disabled`,`true`),e.replaceChildren(...[...t.childNodes].map(e=>e.cloneNode(!0)),t.getAttribute(`aria-label`)??t.title)),e.addEventListener(`click`,()=>{o.hidePopover(),t.click()}),o.append(e)}return[a,o]}var Ot=new WeakMap,kt=e=>Ot.get(e)?.();function At(e){let t=R(`button`,{type:`button`,"data-action":`rename`,class:`btn btn-quiet btn-icon`,"aria-label":`Rename ${e}`,title:`Rename`});return t.append(n(`pencilLine`)),t}var jt=e=>R(`p`,{class:`notice notice-error`},e);function Mt(e,t,n){let r=R(`input`,{type:`checkbox`,class:`select-box`,"data-select-group":JSON.stringify(t),"aria-label":`Select ${e}`});return r.addEventListener(`click`,e=>{e.stopPropagation(),n.selectGroup?.([...t])}),r}function Nt(e,t,n,r,i,o=[],c=()=>null){let l=R(`div`,{role:`row`,"data-key":e.key}),u=Object.fromEntries(St.map(([e])=>[e,R(`div`,{role:`gridcell`,"data-col":e})])),d=[];if(e.kind===`heading`){let{section:n}=e;l.setAttribute(`data-heading`,n.key),l.id=jn(n.key),l.setAttribute(`aria-label`,n.label),u.open.append(Et()),t.selectGroup!==void 0&&o.length>0&&u.select.append(Mt(n.label,o,t)),u.name.append(R(`span`,{"data-name-text":``},n.label),R(`span`,{class:`section-count`,"data-section-count":``},String(n.rows.length)))}else if(e.kind===`flow`){let{card:a}=e,o=a.row,f=a.group,p=f===null?o.name||o.label:f.video.name||o.label;l.setAttribute(`data-scene`,o.sceneId),l.setAttribute(`aria-label`,p),xt(o,t)!==`here`&&l.setAttribute(`data-absent`,``),f===null?l.setAttribute(`data-take`,o.sceneId):(l.setAttribute(`data-flow`,f.video.id),r.set(f.video.id,f),u.open.append(Et()),t.select!==void 0&&u.select.append(R(`input`,{type:`checkbox`,class:`select-box`,"data-select":f.video.id,"aria-label":`Select ${p}`}))),u.name.append(R(`span`,{"data-name-text":``,title:p},p));let m=c(a);m!==null&&u.name.append(_n(m,`name`));let h=dn(o,t,!1);h!==null&&u.name.append(h);let g=i(a);if(Tt(u,`where`,g.text,g.title),m!==null&&u.where.replaceChildren(R(`span`,{"data-where-text":``},g.text),_n(m,`where`)),u.videos.textContent=String(f?.versions.length??1),u.recorded.textContent=e.namesDay?o.time:o.when,u.recorded.title=o.when,e.size.kind===`unknown`)u.size.textContent=`—`;else{let t=e.size.unmeasured;u.size.textContent=`${A(e.size.bytes)}${t>0?`+`:``}`,t>0&&(u.size.title=`${t} ${t===1?`video`:`videos`} could not be measured`)}let _=u.name;Ot.set(l,()=>{let e=_.querySelector(`[data-name-text]`);if(e===null)return;let n=hn(o,t,f);n.addEventListener(`blur`,()=>{e.textContent=n.value||o.label,e.title=e.textContent,n.replaceWith(e)}),n.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===`Escape`)&&(_.focus({preventScroll:!0}),e.stopPropagation())}),e.replaceWith(n),n.focus({preventScroll:!0}),n.select()});let{buttons:v,rerunLine:y}=vn(o,t,f),b=At(p);if(b.addEventListener(`click`,()=>kt(l)),v.insertBefore(b,v.querySelector(`[data-action="edit"], [data-action="delete"]`)),u.actions.append(v,...Dt(v,p,e.key)),y!==null){let e=R(`p`,{"data-rerun-line":``,class:`row-rerun`});s(e,y),d.push(e)}let x=f===null?n.get(L(`take`,o.sceneId)):n.get(L(`video`,f.video.id));x!==void 0&&d.push(jt(x));for(let e of f?.versions??[]){let t=n.get(L(`take`,e.sceneId));if(t===void 0)continue;let r=jt(e.sceneId===o.sceneId?t:`Video ${e.version??`?`}: ${t}`);r.setAttribute(`data-lead-status`,``),d.push(r)}}else{let i=e.row;l.setAttribute(`data-video-row`,i.sceneId),l.setAttribute(`data-scene`,i.sceneId);let o=`Video ${i.version??`?`}`;l.setAttribute(`aria-label`,o),u.name.append(R(`span`,{"data-name-text":``},o));let c=xn(i);c!==null&&u.name.append(c);let f=xt(i,t);if(f!==`here`&&l.setAttribute(`data-absent`,``),f===`here`){let e=Cn(i.exports);e!==null&&u.where.append(e)}else s(u.where,f.absent),u.where.title=a(f.absent);u.recorded.textContent=i.when,u.recorded.title=i.when,u.size.textContent=i.sizeBytes===void 0?`—`:A(i.sizeBytes);let p=Sn(i,r.get(e.flowId),t,f===`here`);u.actions.append(p,...Dt(p,o,e.key));let m=n.get(L(`take`,i.sceneId));m!==void 0&&d.push(jt(m))}if(l.append(...St.map(([e])=>u[e])),d.length>0){let t=R(`div`,{"data-status":``,id:`list-status-${e.key}`});t.append(...d),l.append(t),l.setAttribute(`aria-describedby`,t.id)}return l}function Pt(e,t,n,r,i,a,o,s=!0,c=a.sort,l){let u=bt(t,c,i),d=pt(E(t),s),f=R(`div`,{role:`treegrid`,class:`library-list`,"data-list":``,"aria-multiselectable":`true`,"aria-label":`Flows`,"aria-rowcount":String(u.length+1)});f.append(wt(a,n,`rank`in c?null:c));let p=new Map;for(let e of u)p.set(e.parent,(p.get(e.parent)??0)+1);let m=new Map,h=new Map,g=new Map;for(let e of u)e.kind===`flow`&&e.parent!==null&&e.flowId!==null&&g.set(e.parent,[...g.get(e.parent)??[],e.flowId]);for(let e of u){let t=Nt(e,n,r,h,d,g.get(e.key),l),i=(m.get(e.parent)??0)+1;if(m.set(e.parent,i),t.setAttribute(`aria-level`,String(e.level)),t.setAttribute(`aria-posinset`,String(i)),t.setAttribute(`aria-setsize`,String(p.get(e.parent))),e.kind===`heading`||e.kind===`flow`&&e.flowId!==null){let n=e.kind!==`heading`||e.section.folded,r=o.collapsed.has(e.key)||n&&!(o.drawn?.has(e.key)??!1);t.setAttribute(`aria-expanded`,String(!r))}e.kind===`flow`&&e.flowId!==null&&t.setAttribute(`aria-selected`,`false`),f.append(t)}return Ft(f),Rt(f,n),st(f,n),e.append(f),f}function Ft(e){let t=[];for(let n of e.querySelectorAll(`[role=row][data-key]`)){let e=Number(n.getAttribute(`aria-level`));n.hidden=e>1&&t[e-1]!==!0,t[e]=!n.hidden&&n.getAttribute(`aria-expanded`)!==`false`;let r=n.querySelectorAll(`:scope > [data-status] > [data-lead-status]`);if(r.length>0){for(let e of r)e.hidden=n.getAttribute(`aria-expanded`)===`true`;let e=r[0]?.parentElement;e.hidden=[...e.children].every(e=>e.hidden),e.hidden?n.removeAttribute(`aria-describedby`):n.setAttribute(`aria-describedby`,e.id)}}}function It(e,t){e.setAttribute(`aria-expanded`,String(t));let n=e.closest(`[data-list]`);if(n===null)return;let r=[...n.querySelectorAll(`[data-video-row]`)],i=r.map(e=>e.hidden);Ft(n);for(let[e,t]of r.entries())t.toggleAttribute(`data-opening`,i[e]===!0&&!t.hidden)}var Lt=e=>[...e.querySelectorAll(`[role=row][data-flow]:not([hidden])`)].map(e=>e.dataset.flow);function Rt(e,t){let n=!1;e.addEventListener(`pointerdown`,()=>{let t=document.activeElement;n=t?.matches(`[data-name]`)===!0&&e.contains(t)}),e.addEventListener(`click`,r=>{let i=r.target,a=i.closest(`[role=row][data-key]`),o=n;if(n=!1,a===null||i.closest(`[data-status]`)!==null)return;let s=a.dataset.flow,c=()=>{r.shiftKey&&window.getSelection()?.removeAllRanges(),t.select?.(s,r.shiftKey?`range`:`toggle`,Lt(e))};if(a.hasAttribute(`aria-expanded`)&&(a.dataset.heading!==void 0||i.closest(`[data-col="open"]`)!==null)){It(a,a.getAttribute(`aria-expanded`)===`false`);return}if(i.matches(`[data-select]`)){c();return}if(o||i.closest(`button, input, a`))return;if(s!==void 0&&t.select!==void 0&&(e.closest(`[data-selecting]`)!==null||r.metaKey||r.shiftKey)){c();return}if(a.dataset.videoRow!==void 0&&e.closest(`[data-selecting]`)!==null||(window.getSelection()?.toString()??``)!==``||a.hasAttribute(`data-absent`))return;let l=a.dataset.scene;l!==void 0&&t.edit(l)})}var zt=e=>e.kind===`upkeep`?null:e.kind===`video`?`record`:`folder`,L=(e,t)=>`${e}:${t}`,Bt=(e,t)=>t==null?null:e===!0?`Expired — ${t.charAt(0).toLowerCase()}${t.slice(1)}`:t;function Vt(e){let t=e.querySelector(`.place-tabs`),n=t?.querySelector(`[aria-pressed="true"]`);if(t==null||n==null||t.scrollWidth<=t.clientWidth)return;let r=Number.parseFloat(getComputedStyle(t).paddingLeft)||0,i=t.getBoundingClientRect(),a=n.getBoundingClientRect();a.left<i.left+r?t.scrollLeft-=i.left+r-a.left:a.right>i.right-r&&(t.scrollLeft+=a.right-(i.right-r))}function Ht(e){return[...(e.closest(`[data-library]`)??e.ownerDocument).querySelectorAll(`:is(details[open], [data-results]) [data-select]`)].map(e=>e.dataset.select)}function Ut(e){let t=R(`div`,{class:`selection-bar`,"data-selection-bar":``}),n=R(`button`,{type:`button`,class:`btn btn-quiet`,"data-action":`cancel-selection`},`Cancel`);n.addEventListener(`click`,()=>e.clearSelection?.());let r=R(`button`,{type:`button`,class:`btn btn-danger`,"data-action":`delete-selected`},`Delete`);return r.addEventListener(`click`,()=>e.deleteSelected?.()),t.append(R(`span`,{class:`selection-count`,"data-selection-count":``}),n,r,R(`p`,{class:`selection-said`,"data-selection-said":``,role:`status`})),t}function Wt(e,t,n){let r=`${t} ${t===1?`flow`:`flows`}`,i=n?.busy===!0;e.querySelector(`[data-selection-count]`).textContent=i?`Deleting ${r}…`:`${r} selected`;for(let t of e.querySelectorAll(`button`))t.disabled=i;let a=e.querySelector(`[data-selection-said]`);a.textContent=n?.said??``,a.hidden=n?.said==null}var Gt=new WeakMap;function Kt(e,t){if(t===null){e.replaceChildren();return}let r=R(`button`,{type:`button`,class:`btn btn-quiet`,"data-ci-setup":``});r.append(n(`shieldCheck`),`Set up CI`),r.addEventListener(`click`,t),e.replaceChildren(r)}function qt(e,t,n,r){let i=t.select===void 0?new Set:n?.ids??new Set;e.toggleAttribute(`data-selecting`,i.size>0);let a=r?.busy===!0;e.toggleAttribute(`data-busy`,a);for(let t of e.querySelectorAll(`[data-select]`)){let e=i.has(t.dataset.select);t.checked=e,t.disabled=a,t.closest(`article`)?.toggleAttribute(`data-selected`,e),t.closest(`[role=row]`)?.setAttribute(`aria-selected`,String(e))}for(let t of e.querySelectorAll(`[data-select-group]`)){let e=JSON.parse(t.dataset.selectGroup),n=e.filter(e=>i.has(e)).length;t.checked=n>0&&n===e.length,t.indeterminate=n>0&&n<e.length,t.disabled=a}let o=e.querySelector(`[data-selection-bar]`);if(i.size===0){o?.remove(),Gt.get(e)?.disconnect(),e.style.removeProperty(`--selection-bar`);return}if(o===null){let n=un.get(e)?.notices;if(n===void 0)return;o=Ut(t),n.after(o)}Wt(o,i.size,r);let s=t=>e.style.setProperty(`--selection-bar`,`${t.getBoundingClientRect().height}px`);s(o);let c=Gt.get(e);c===void 0&&(c=new ResizeObserver(e=>{for(let t of e)s(t.target)}),Gt.set(e,c)),c.disconnect(),c.observe(o)}var Jt=1024**3;function R(e,t={},n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))r.setAttribute(e,n);return n!==void 0&&(r.textContent=n),r}function Yt(e,t,r={}){let i=R(`span`,{class:`tag`,...r});return i.append(n(e),t),i}function Xt(){let e=R(`div`,{class:`meter`}),t=R(`div`,{class:`meter-fill`});return e.append(t),{bar:e,set(n){t.style.width=`${(n*100).toFixed(1)}%`,e.toggleAttribute(`data-full`,n>=.9)}}}var Zt=`storage-panel`,Qt=`place-menu`,$t=16,en=300;function z(e,t,n=!1,r=!1){let i=t.getBoundingClientRect(),a=document.documentElement.clientWidth,o=Math.min(en,a-32),s=!r&&i.right-o>=$t?i.right-o:i.left,c=Math.max($t,Math.min(s,a-$t-o)),l=t.closest(`[data-header]`),u=l!==null&&getComputedStyle(l).position===`sticky`;e.style.maxHeight=``;let d=e.offsetHeight,f=i.bottom+6,p=window.innerHeight-$t-f,m=i.top-6-$t,h=n&&e.dataset.side!==void 0?e.dataset.side===`above`:d>p&&(d<=m||m>p);e.dataset.side=h?`above`:`below`;let g=Math.max(0,h?m:p);d>g&&(e.style.maxHeight=`${Math.round(g)}px`);let _=Math.min(d,g),v=h?i.top-6-_:f;e.style.position=u?`fixed`:`absolute`,e.style.width=`${Math.round(o)}px`,e.style.left=`${Math.round(c+(u?0:window.scrollX))}px`,e.style.top=`${Math.round(v+(u?0:window.scrollY))}px`}var tn=e=>(e/Jt).toFixed(2).replace(/\.?0+$/,``),nn=[[`inRepo`,`In repo`],[`notInRepo`,`Not in repo`],[`all`,`All`]],rn={all:`All flows`,none:`No project`,unreadable:`Couldn't read`};function an(e){let t=(e,t)=>R(`span`,{class:`proj-dim ${e}`,[`data-${e}`]:``},t);return[...e.owner===null?[]:[t(`place-owner`,`${e.owner}/`)],R(`span`,{class:`place-name`,"data-place-name":``},e.name),...e.local?[t(`place-local`,` local`)]:[]]}function on(e,t,n){let r=R(`div`,{class:`side-list`}),i=h(t),a=(e,t,a,o=t.join(``))=>{let s=h(e),c=R(`a`,{href:s,class:`side-item`,"data-place":s,"aria-current":String(s===i),title:o}),l=R(`span`,{class:`side-label`});l.append(...t),c.append(l,R(`span`,{class:`side-count`},String(a))),c.addEventListener(`click`,t=>{t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),n.goPlace?.(e))}),r.append(c)};a(`all`,[rn.all],e.all);for(let t of e.projects)a({project:t.key},an(t),t.count,t.key);return(e.none>0||t===`none`)&&a(`none`,[rn.none],e.none),(e.unreadable>0||t===`unreadable`)&&a(`unreadable`,[rn.unreadable],e.unreadable),r}function sn(e){if(e===void 0)return[`Flows`];let t=e.place;if(typeof t==`string`)return[rn[t]];let n=e.rail.projects.find(e=>e.key===t.project);return n===void 0?[R(`span`,{class:`place-name`,"data-place-name":``},t.project)]:an(n)}function cn(e){let t=null,r,i=R(`div`,{class:`library`,"data-library":``}),a=R(`aside`,{class:`library-side`,"data-header":``}),o=R(`h1`,{}),s=R(`span`,{"data-place-title":``},`Flows`),c=R(`span`,{class:`place-switch-name`}),l=R(`button`,{type:`button`,class:`place-switch`,"data-place-switch":``,popovertarget:Qt,"aria-controls":Qt,"aria-haspopup":`menu`,"aria-expanded":`false`});l.hidden=!0,l.append(c,n(`chevronDown`)),o.append(l,s);let u=R(`div`,{id:Qt,class:`place-menu`,popover:``,role:`menu`,"aria-label":`Switch project`,"data-place-menu":``}),d=()=>[...u.querySelectorAll(`[data-place]`)],f=null;u.addEventListener(`beforetoggle`,e=>{e.newState===`open`&&z(u,l,!1,!0)}),u.addEventListener(`toggle`,e=>{let t=e.newState===`open`;l.setAttribute(`aria-expanded`,String(t)),f?.abort(),f=null,t&&(z(u,l,!1,!0),(u.querySelector(`[aria-current="true"]`)??d()[0])?.focus(),f=new AbortController,window.addEventListener(`resize`,()=>{l.getClientRects().length===0?u.hidePopover():z(u,l,!1,!0)},{signal:f.signal}))}),u.addEventListener(`keydown`,e=>{let t=d(),n=t.indexOf(document.activeElement),r=t.length,i=e.key===`ArrowDown`?(n+1)%r:e.key===`ArrowUp`?(n-1+r)%r:e.key===`Home`?0:e.key===`End`?r-1:null;i!==null&&r!==0&&(e.preventDefault(),t[i]?.focus())}),u.addEventListener(`click`,e=>{e.defaultPrevented&&(u.hidePopover(),l.focus())}),u.addEventListener(`focusout`,e=>{let t=e.relatedTarget;t!==null&&!u.contains(t)&&u.matches(`:popover-open`)&&u.hidePopover()});let p=R(`nav`,{class:`side-group`,"aria-label":`Projects`,"data-rail":``}),m=R(`div`,{class:`library-content`}),h=Xt();h.bar.setAttribute(`aria-hidden`,`true`);let g=R(`span`,{"data-meter":``}),_=R(`button`,{type:`button`,class:`btn btn-quiet storage-trigger`,"data-storage-trigger":``,popovertarget:Zt,"aria-controls":Zt});_.append(R(`span`,{class:`storage-label`},`Storage`),h.bar,g,n(`chevronDown`));let v=R(`div`,{class:`storage`}),y=R(`span`,{"data-total-size":``}),b=R(`span`,{class:`library-total`,"data-library-total":``});b.append(R(`span`,{class:`storage-label`},`Storage`),y);let x=R(`div`,{"data-notices":``}),S=R(`div`,{class:`tabs-row`,"data-tabs-row":``}),C=R(`div`,{class:`place-tabs`}),w=new Map;for(let[e,n]of nn){let r=R(`span`,{class:`side-count`}),i=R(`button`,{type:`button`,class:`btn btn-quiet`,"data-tab":e},n);i.append(r),i.addEventListener(`click`,()=>t?.goTab?.(e)),w.set(e,r),C.append(i)}let T=R(`label`,{class:`search-field`}),E=R(`input`,{type:`search`,"data-search":``,"aria-label":`Search flows`,placeholder:`Search`});E.addEventListener(`input`,()=>t?.search?.(E.value)),E.addEventListener(`keydown`,e=>{e.key===`Escape`&&E.value!==``&&(e.preventDefault(),t?.search?.(``))}),T.append(n(`search`),E,R(`kbd`,{},`/`));let D=R(`div`,{class:`layout-toggle`,"data-layout-toggle":``});for(let[e,i,a]of[[`list`,`list`,`List`],[`grid`,`layoutGrid`,`Grid`]]){let o=R(`button`,{type:`button`,class:`btn btn-quiet btn-icon`,"data-layout":e,"aria-label":a,title:a});o.append(n(i)),o.addEventListener(`click`,()=>{r!==void 0&&r.layout!==e&&t?.setView?.({...r,layout:e,sort:{...r.sort}})}),D.append(o)}let O=R(`div`,{id:Zt,class:`storage-panel`,popover:``,"data-storage":``,"aria-label":`Storage`}),k=null;O.addEventListener(`beforetoggle`,e=>{e.newState===`open`&&z(O,_)}),O.addEventListener(`toggle`,e=>{let t=e.newState===`open`;_.toggleAttribute(`data-open`,t),k?.abort(),k=null,t&&(z(O,_),k=new AbortController,window.addEventListener(`resize`,()=>z(O,_),{signal:k.signal}),window.addEventListener(`scroll`,()=>z(O,_,!0),{passive:!0,signal:k.signal}))});let j=Xt();j.bar.setAttribute(`role`,`progressbar`),j.bar.setAttribute(`aria-label`,`Storage used`),j.bar.setAttribute(`aria-valuemin`,`0`),j.bar.setAttribute(`aria-valuemax`,`1`);let ee=R(`p`,{class:`storage-used`,"data-storage-used":``}),M=R(`input`,{type:`number`,min:`0.25`,step:`0.25`,id:`storage-budget`,"data-storage-budget":``}),ne=R(`p`,{class:`notice notice-error hidden`,role:`alert`,"data-budget-note":``});M.addEventListener(`change`,()=>{let e=Number(M.value);if(!Number.isFinite(e)||e<=0){ne.textContent=te,ne.classList.remove(`hidden`);return}ne.classList.add(`hidden`),t?.setBudget?.(Math.round(e*Jt))});let re=R(`div`,{class:`storage-budget-row`});re.append(M,R(`span`,{},`GB`));let ie=R(`div`,{class:`storage-field`});ie.append(R(`label`,{for:`storage-budget`},`Budget`),re,R(`p`,{class:`storage-hint`},`Saves automatically.`),ne);let ae=R(`button`,{type:`button`,"data-action":`reclaim`,class:`btn btn-quiet storage-reclaim`});ae.append(n(`trash`),`Reclaim space`),ae.addEventListener(`click`,()=>t?.reclaim?.());let oe=R(`div`,{class:`storage-foot`});oe.append(ae,R(`p`,{class:`storage-hint`},`Clears cached exports, then hosted videos' motion, oldest first, until the library fits its budget.`)),O.append(R(`h2`,{class:`storage-title`},`Storage`),j.bar,ee,ie,oe),v.append(_,O);let se=R(`div`,{class:`ci-setup`,"data-ci-slot":``}),ce=R(`div`,{class:`title-row`});ce.append(o,se),a.append(ce,p,u),S.append(C,T,D),m.append(S,x),i.append(a,m);let le=document.querySelector(`[data-storage-slot]`);return e&&(le??a).append(v),{box:i,content:m,tabsRow:S,notices:x,update(e,n,i,o){t=n,r=i,D.hidden=r===void 0||n.setView===void 0;for(let e of D.querySelectorAll(`button`))e.setAttribute(`aria-pressed`,String(e.dataset.layout===r?.layout));let f=document.activeElement;f instanceof HTMLElement&&D.contains(f)&&!f.checkVisibility()&&[...D.querySelectorAll(`button`)].find(e=>e.checkVisibility())?.focus(),C.hidden=o?.tabs==null;for(let e of C.querySelectorAll(`[data-tab]`)){let t=e.dataset.tab;e.setAttribute(`aria-pressed`,String(t===o?.tab)),w.get(t).textContent=String(o?.tabs?.[t]??``)}T.hidden=n.search===void 0||o?.place===`unreadable`;let m=o?.search?.query??``;E.value!==m&&(E.value=m),S.hidden=D.hidden&&C.hidden&&T.hidden,s.replaceChildren(...sn(o));let v=o?.place,O=v!==void 0&&typeof v==`object`?n.ciSetup?.(v)??null:null;Kt(se,O),c.replaceChildren(...o===void 0?[]:sn(o)),l.hidden=o===void 0;for(let e of[p,u]){let t=document.activeElement?.closest(`[data-place]`),r=e.contains(t??null)?t?.dataset.place:void 0;e.replaceChildren(...o===void 0?[]:[on(o.rail,o.place,n)]),r!==void 0&&e.querySelector(`[data-place="${CSS.escape(r)}"]`)?.focus()}u.querySelector(`.side-list`)?.setAttribute(`role`,`none`);for(let e of d())e.setAttribute(`role`,`menuitem`),e.tabIndex=-1;if(e.totalBytes===void 0)b.remove();else{let t=e.unmeasured??0,n=`${A(e.totalBytes)}${t>0?`+`:``}`,r=t>0?`${t} ${t===1?`folder`:`folders`} could not be measured`:null;y.textContent=n,b.setAttribute(`aria-label`,`Storage: ${n}${r===null?``:` (${r})`}`),r===null?b.removeAttribute(`title`):b.setAttribute(`title`,r),b.parentNode===null&&(le??a).append(b)}let k=A(e.usedBytes),te=A(e.budgetBytes);h.set(e.fraction),j.set(e.fraction),j.bar.setAttribute(`aria-valuenow`,e.fraction.toFixed(3)),g.textContent=`${k} of ${te}`,_.setAttribute(`aria-label`,`Storage: ${k} of ${te} used`),ee.textContent=`${k} used of a ${te} budget`,document.activeElement!==M&&(M.value=tn(e.budgetBytes)),x.replaceChildren(...ln(e))}}}function ln(e){let t=[];return e.migrating&&t.push(R(`p`,{"data-migrating":``,class:`notice`},`Measuring existing videos…`)),e.migrationFailed&&t.push(R(`p`,{"data-migration-failed":``,class:`notice notice-warn`},`Measuring existing videos failed, so sizes below may be wrong. Open the extension's error log if this keeps happening.`)),e.chromeNearLimit&&t.push(R(`p`,{"data-chrome-limit":``,class:`notice notice-warn`},`Chrome is near its storage limit on this drive.`)),e.unwatched!=null&&t.push(R(`p`,{"data-unwatched":``,class:`notice notice-warn`},`New videos will not show until you reload — ${e.unwatched}.`)),e.notice!==null&&t.push(R(`p`,{"data-notice":``,class:`notice notice-error`},e.notice)),t}var un=new WeakMap;function dn(e,t,r=!0){let i=R(`div`,{class:`row-tags`}),a=t.openReview;if(e.needsLook&&a!==void 0){let t=R(`button`,{type:`button`,class:`tag tag-warn tag-look`,"data-needs-look":``,"aria-label":`Needs a look: ${e.label}`,title:`Needs a look`});t.append(n(`circleAlert`)),t.addEventListener(`click`,()=>a(e.sceneId)),i.append(t)}return e.kept!=null&&i.append(Yt(`bookmark`,`In repo`,{"data-kept":``,title:`unknown`in e.kept?e.kept.unknown:`${e.kept.root}/${e.kept.file}${e.keptUnder===void 0?``:` — its repo could not be read, so it is listed under ${e.keptUnder}`}`})),e.hosted&&r&&i.append(Yt(`cloud`,`Hosted`,{"data-hosted":``,title:`Hosted copy stays online after a local delete`})),e.state===`Motion reclaimed`?i.append(Yt(`restore`,e.state,{"data-state-chip":``,class:`tag tag-warn`,title:e.authored?`Its motion was reclaimed to free space; Restore opens Runs to run its script again, which makes a new video`:`Its motion was reclaimed to free space; Restore re-shoots it in Runs`})):e.state===`Keyframes only`&&i.append(Yt(`image`,e.state,{"data-state-chip":``,title:`No motion was recorded for this video`})),i.childElementCount>0?i:null}function fn(e,t){let n=R(`div`,{"data-preview":``}),r=R(`canvas`,{"data-preview-canvas":``,"aria-hidden":`true`,hidden:``});n.append(r,R(`p`,{"data-preview-note":``},be({kind:`loading`})??``));let i=dn(e,t);return i!==null&&n.append(i),n.append(R(`span`,{"data-duration":``,hidden:``})),n}var pn={Complete:`complete`,"Motion reclaimed":`reclaimed`,"Keyframes only":`keyframesOnly`},mn=e=>`name-${e}`;function hn(e,t,n){let r=n===null?e.name:n.video.name,i=R(`input`,{type:`text`,id:mn(e.sceneId),"data-name":``,"aria-label":n===null?`Video name`:`Flow name`,title:r,placeholder:`Untitled`,spellcheck:`false`,autocomplete:`off`});i.value=r;let a=r;return i.addEventListener(`change`,()=>{let r=i.value.trim();if(r===a||n!==null&&r===``){i.value=a;return}a=r,i.value=r,i.title=r,n===null?t.rename(e.sceneId,r):t.renameVideo(n.video.id,r)}),i.addEventListener(`keydown`,e=>{e.key===`Escape`?(i.value=a,i.blur()):e.key===`Enter`&&i.blur()}),i}function gn(e,t,n,r,i,a,o,c,l=null){let u=i?.video.id??null,d=R(`article`,{class:`card`,"data-row":e.sceneId,"data-state":pn[e.state],...i===null?{}:{"data-video":i.video.id},...e.name===``&&i===null?{"aria-label":e.label}:{"aria-labelledby":mn(e.sceneId)}}),f=!1;d.addEventListener(`pointerdown`,()=>{let e=document.activeElement;f=e?.matches(`[data-name]`)===!0&&d.contains(e)}),d.addEventListener(`click`,n=>{let r=n.target;if(!f&&!r.closest(`button, input, a, [data-versions]`)){if(u!==null&&t.select!==void 0&&(d.closest(`[data-selecting]`)!==null||n.metaKey||n.shiftKey)){t.select?.(u,n.shiftKey?`range`:`toggle`,Ht(d));return}(window.getSelection()?.toString()??``)===``&&e.expired!==!0&&t.edit(e.sceneId)}});let p=fn(e,t);if(u!==null&&t.select!==void 0){let n=R(`input`,{type:`checkbox`,class:`select-box`,"data-select":u,"aria-label":`Select ${i?.video.name||e.label}`});n.addEventListener(`click`,e=>{t.select?.(u,e.shiftKey?`range`:`toggle`,Ht(n))}),p.append(n)}d.append(p);let{buttons:m,rerunLine:h}=vn(e,t,i),g=R(`div`,{class:`row-text`}),_=R(`div`,{class:`row-title`});_.append(hn(e,t,i),m),g.append(_);let v=c({row:e,group:i}),y=R(`div`,{class:`row-line`}),b=R(`p`,{class:`row-meta`,"data-meta":``,title:l?.full??v.title});if(b.append(l===null?v.text:_n(l),` · ${r?e.time:e.when}`),y.append(b),e.sizeBytes===void 0?t.reclaim!==void 0&&y.append(R(`p`,{"data-size":``,class:`row-size`},`${A(e.frameBytes)} frames · ${A(e.outputBytes)} renders`)):y.append(R(`p`,{"data-size":``,class:`row-size`},A(e.sizeBytes))),g.append(y),d.append(g),i!==null&&i.versions.length>1)d.append(bn(i,t,a,o));else if(i!==null){let e=i.versions[0],t=Cn(e?.exports),n=e===void 0?null:xn(e);if(t!==null||n!==null){let e=R(`div`,{class:`card-exports`});n!==null&&e.append(n),t!==null&&e.append(t),d.append(e)}}if(h!==null){let e=R(`p`,{"data-rerun-line":``,class:`row-rerun`});s(e,h),d.append(e)}return n!==void 0&&d.append(R(`p`,{"data-status":``,class:`notice notice-error`},n)),d}var _n=(e,t=``)=>R(`span`,{class:`match-why`,"data-match-why":t,title:e.full},e.text);function vn(e,t,r){let i=R(`div`,{class:`row-actions`});if(e.servesReshoot){let r=R(`button`,{type:`button`,"data-action":`back-to-recording`,class:`btn btn-quiet btn-icon`,"aria-label":`Back to the original footage: ${e.label}`,title:`Back to the original footage — this video plays its re-shot frames; its original footage is kept`});r.append(n(`undo`)),r.addEventListener(`click`,()=>t.backToRecording(e.sceneId)),i.append(r)}let a=e.canRestore||e.expired===!0?Bt(e.expired,t.rerunLine?.(e.sceneId,e.authored)):null;if(e.canRestore&&a===null){let r=R(`button`,{type:`button`,"data-action":`restore`,class:`btn btn-quiet btn-icon`,"aria-label":`Restore motion: ${e.label}`,title:e.authored?`Restore motion — run its script again in Runs; a script-made video cannot be re-shot, so this makes a new video`:`Restore motion — re-shoot it in Runs`});r.append(n(`restore`)),r.addEventListener(`click`,()=>t.restore(e.sceneId)),i.append(r)}let o=R(`button`,{type:`button`,"data-action":`edit`,class:`btn btn-quiet btn-icon`,"aria-label":`Edit ${e.label}`,title:`Edit`});o.append(n(`clapperboard`)),o.addEventListener(`click`,()=>t.edit(e.sceneId)),e.expired!==!0&&i.append(o);let s=yn(e,t,r);s!==null&&i.append(s);let c=R(`button`,{type:`button`,"data-action":`delete`,class:`btn btn-quiet btn-icon btn-danger`,"aria-label":`Delete ${e.label}`,title:`Delete`});return c.append(n(`trash`)),c.addEventListener(`click`,()=>r===null?t.remove(e.sceneId,`take`):t.remove(r.video.id,`video`)),i.append(c),{buttons:i,rerunLine:a}}function yn(e,t,r){let i=t.repo;if(i===void 0||r===null)return null;let a=r.video.id,o=r.video.kept;if(o!=null){if(`unknown`in o)return null;let t=R(`button`,{type:`button`,"data-action":`repo-remove`,class:`btn btn-quiet btn-icon`,"aria-label":`Remove from repo: ${e.label}`,title:`Remove from repo`});return t.append(n(`gitBranchMinus`)),t.addEventListener(`click`,()=>i.remove(a)),t}let s=i.addable(a),c=R(`button`,{type:`button`,"data-action":`repo-add`,class:`btn btn-quiet btn-icon`});return c.append(n(`gitBranchPlus`)),i.adding(a)?(c.setAttribute(`aria-disabled`,`true`),c.setAttribute(`aria-label`,`Adding to repo: ${e.label}`),c.title=`Adding to repo…`):s===void 0||s.ok?(c.setAttribute(`aria-label`,`Add to repo: ${e.label}`),c.title=`Add to repo`,c.addEventListener(`click`,()=>i.add(a))):(c.setAttribute(`aria-disabled`,`true`),c.setAttribute(`aria-label`,`Can't add: ${s.label}`),c.title=s.detail),c}function bn(e,t,r,i){let a=R(`details`,{class:`versions`,"data-versions":e.video.id});a.open=i;let o=R(`summary`,{class:`versions-count`}),c=n(`chevronRight`);c.classList.add(`chev`),o.append(c,`${e.versions.length} videos`),a.append(o);let l=R(`ol`,{class:`versions-list`});for(let n of e.versions){let i=R(`li`,{class:`version`,"data-version-row":n.sceneId,...n.expired===!0?{"data-expired":``}:{}}),a=R(`div`,{class:`version-head`});a.append(R(`span`,{class:`version-number`},`Video ${n.version??`?`}`),R(`span`,{class:`version-when`,title:n.when},n.when));let o=xn(n);o!==null&&a.append(o);let c=n.expired===!0?Bt(!0,t.rerunLine?.(n.sceneId,n.authored)):null;a.append(Sn(n,e,t,n.expired!==!0)),i.append(a);let u=Cn(n.exports);if(u!==null&&i.append(u),c!==null){let e=R(`p`,{"data-rerun-line":``,class:`row-rerun`});s(e,c),i.append(e)}let d=r.get(L(`take`,n.sceneId));d!==void 0&&i.append(R(`p`,{"data-status":``,class:`notice notice-error`},d)),l.append(i)}return a.append(l),a}function xn(e){let t=b(e.filmedCode);if(t===null)return null;let n=e.filmedCode;return R(`span`,{class:`version-commit`,"data-commit":``,title:n.commit},t)}function Sn(e,t,r,i){let a=R(`div`,{class:`row-actions`});if(i){let i=R(`button`,{type:`button`,"data-action":`edit`,class:`btn btn-quiet btn-icon`,"aria-label":`Edit video ${e.version??``} of ${t.video.name}`,title:`Edit`});i.append(n(`clapperboard`)),i.addEventListener(`click`,()=>r.edit(e.sceneId)),a.append(i)}let o=R(`button`,{type:`button`,"data-action":`delete`,class:`btn btn-quiet btn-icon btn-danger`,"aria-label":`Delete video ${e.version??``} of ${t.video.name}`,title:`Delete`});return o.append(n(`trash`)),o.addEventListener(`click`,()=>r.remove(e.sceneId,`take`)),a.append(o),a}function Cn(e){if(e===void 0)return null;if(`unreadable`in e)return R(`p`,{class:`row-rerun`,"data-exports-unreadable":``},`Its exports could not be read: ${e.unreadable}`);if(e.length===0)return null;let t=R(`ul`,{class:`version-exports`});for(let n of e){let e=n.path.slice(n.path.lastIndexOf(`/`)+1)||n.path,r=R(`li`,{"data-export":n.path,title:n.path,...n.exists?{}:{"data-gone":``}});r.append(R(`span`,{class:`export-name`},e),R(`span`,{class:`export-type`},n.exists?n.fileType.toUpperCase():`${n.fileType.toUpperCase()} · gone`)),t.append(r)}return t}var wn=new WeakMap,Tn=e=>new Set([...e.querySelectorAll(`[data-versions]`)].filter(e=>e.open).map(e=>e.getAttribute(`data-versions`)));function En(e){let t=document.activeElement;if(!(t instanceof HTMLInputElement)||!t.matches(`[data-name]`)||!e.contains(t))return null;let n=t.closest(`[data-row]`)?.getAttribute(`data-row`),r=t.closest(`[data-list] [data-key]`)?.dataset.key,i=n?`[data-row="${CSS.escape(n)}"]`:r?`[data-list] [data-key="${CSS.escape(r)}"]`:null;return i===null?null:{row:i,value:t.value,start:t.selectionStart,end:t.selectionEnd}}function Dn(e,t){if(t===null)return!1;let n=e.querySelector(t.row);if(n===null)return!1;n.querySelector(`[data-name]`)===null&&kt(n);let r=n.querySelector(`[data-name]`);return r!==null&&(r.value=t.value,r.focus(),t.start!==null&&t.end!==null&&r.setSelectionRange(t.start,t.end),!0)}var On=e=>`section-${e.replace(/:/g,`-`)}`;function kn(e){let t=new Map;for(let n of e.querySelectorAll(`[data-section]`)){let e=n.getAttribute(`data-section`);e!==null&&t.set(e,n.open)}return t}var An=`unreadable`,jn=e=>`when-${e.replace(/:/g,`-`)}`,Mn=(e,t,n)=>t===null?n.get(L(`take`,e.sceneId)):n.get(L(`video`,t.video.id))??(t.versions.length>1?void 0:n.get(L(`take`,e.sceneId)));function Nn(e,t,r,i,a,o,s){let c=On(e.key),l=R(`details`,{class:`section`,id:jn(e.key),"data-section":e.key,"aria-labelledby":c});l.open=t;let u=R(`summary`,{class:`section-head`}),d=n(`chevronRight`);d.classList.add(`chev`);let f=e.rows.flatMap(e=>a.get(e.sceneId)?.video.id??[]);u.append(d,...f.length>0&&r.selectGroup!==void 0?[Mt(e.label,f,r)]:[],R(`h2`,{id:c},e.label),R(`span`,{class:`section-count`,"data-section-count":``},String(e.rows.length))),l.append(u);let p=R(`div`,{class:`rows`}),m=e.rows.map(t=>{let n=a.get(t.sceneId)??null,c=gn(t,r,Mn(t,n,i),e.namesDay,n,i,n!==null&&o.has(n.video.id),s);return p.append(c),[t.sceneId,c]});return l.append(p),{box:l,articles:m}}function Pn(e,t,n,r=!1){let i=R(`section`,{class:`section`,id:An,"data-unreadable":``,"aria-labelledby":`section-unreadable`}),a=R(`div`,{class:`section-head`});if(a.append(R(`h2`,{id:`section-unreadable`},`Couldn't read`),R(`span`,{class:`section-count`},String(e.length))),i.append(a),r)return i.append(In(e,t,n)),i;let o=R(`div`,{class:`rows`});for(let r of e){let e=R(`article`,{class:`card`,"data-unreadable-row":r.folder}),i=R(`div`,{class:`row-text`}),a=R(`div`,{class:`row-title`});a.append(R(`p`,{class:`row-meta`,"data-unreadable-name":``},r.folder));let s=zt(r),c=Fn(r,t);c!==null&&a.append(c),i.append(a,R(`p`,{class:`row-meta`,"data-reason":``},r.reason)),r.sizeBytes!==void 0&&i.append(R(`p`,{"data-size":``,class:`row-size`},A(r.sizeBytes))),e.append(i);let l=s===null?void 0:n.get(L(s,r.folder));l!==void 0&&e.append(R(`p`,{"data-status":``,class:`notice notice-error`},l)),o.append(e)}return i.append(o),i}function Fn(e,t){let r=zt(e);if(r===null)return null;let i=R(`button`,{type:`button`,"data-action":`delete`,class:`btn btn-quiet btn-icon btn-danger`,"aria-label":`Delete ${e.folder}`,title:`Delete`});return i.append(n(`trash`)),i.addEventListener(`click`,()=>t.remove(e.folder,r)),i}function In(e,t,n){let r=R(`div`,{class:`unreadable-list`});for(let i of e){let e=R(`div`,{class:`unreadable-row`,"data-unreadable-row":i.folder}),a=R(`span`,{"data-col":`actions`}),o=Fn(i,t);o!==null&&a.append(o),e.append(R(`span`,{"data-col":`name`,"data-unreadable-name":``,title:i.folder},i.folder),R(`span`,{"data-col":`where`,"data-reason":``,title:i.reason},i.reason),R(`span`,{"data-col":`size`,"data-size":``},i.sizeBytes===void 0?`—`:A(i.sizeBytes)),a);let s=zt(i),c=s===null?void 0:n.get(L(s,i.folder));if(c!==void 0){let t=R(`div`,{"data-status":``});t.append(R(`p`,{class:`notice notice-error`},c)),e.append(t)}r.append(e)}return r}function Ln(e,t,n,r){let i=R(`p`,{class:`none-here`,"data-none-here":``});i.append(`None here.`);for(let[a,{place:o,count:s}]of e.entries()){let e=R(`a`,{href:`${h(o)}&q=${encodeURIComponent(n)}`,"data-place":h(o)});e.append(`${s} in `,...sn({place:o,rail:t})),e.addEventListener(`click`,e=>{e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),r.goPlace?.(o))}),i.append(a===0?` `:`, `,e)}return e.length>0&&i.append(`.`),i}function Rn(e,t,n,r,i=new Date,a,o,s,c){let l=En(e),u=kn(e),d=Tn(e),f=new Set([...e.querySelectorAll(`[data-list] [data-key]`)].map(e=>e.dataset.key)),p=wn.get(e),m={collapsed:new Set([...[...p?.collapsed??[]].filter(e=>!f.has(e)),...Ct(e)]),drawn:new Set([...p?.drawn??[],...f])};wn.set(e,m);let h=at(e.querySelector(`[data-list]`)),g=un.get(e);g===void 0&&(g=cn(n.reclaim!==void 0&&n.setBudget!==void 0),un.set(e,g)),g.update(t,n,s,c);for(let t of[...e.childNodes])t!==g.box&&t.remove();g.box.parentNode!==e&&e.prepend(g.box),Vt(g.tabsRow);for(let e of[...g.content.childNodes])e!==g.notices&&e!==g.tabsRow&&e.remove();let _=g.content,v=c===void 0||c.place===`unreadable`?t.unreadable??[]:[],y=c===void 0||typeof c.place==`string`,b=c?.search,x=b?.query??``,S=b!==void 0&&c!==void 0&&c.place!==`unreadable`&&Ie(x),w=()=>{v.length>0&&_.append(Pn(v,n,r,s?.layout===`list`))};if(t.rows.length===0){if(qt(e,n,void 0),S){_.append(Ln(b.elsewhere,c.rail,x,n));return}if(v.length>0){w();return}if(c!==void 0&&c.rail.all>0)return;let r=R(`div`,{"data-empty":``,class:`card empty-card`});r.append(qe(`monitorPlay`,`No flows yet`,t.emptyHint??`Click the Demoman icon in your browser's toolbar and press Record. Each video shows up here, grouped by the day you made it.`)),_.append(r);return}let T=E(t),D=pt(T,y),O=T.map(e=>e.row),k=new Map(T.flatMap(e=>e.group===null?[]:[[e.row.sceneId,e.group]])),A=[],j=S?b.sort??{rank:e=>Re(e,x)}:null;if(s?.layout===`list`){let c=Pt(_,t,n,r,i,s,m,y,j??s.sort,S?e=>ze(e,x):void 0);w();for(let e of c.querySelectorAll(`[data-scene]`))n.measure?.(e.dataset.scene,e.querySelector(`[data-col="length"]`));let u=Dn(e,l);qt(e,n,a,o),u||ot(c,h);return}if(j!==null){let e=R(`div`,{class:`rows`,"data-results":``});for(let a of bt(t,j,i)){if(a.kind!==`flow`)continue;let{row:t,group:i}=a.card,o=gn(t,n,Mn(t,i,r),!1,i,r,i!==null&&d.has(i.video.id),D,ze(a.card,x));e.append(o),A.push([t.sceneId,o])}_.append(e)}for(let e of j===null?C(O,i):[]){let t=Nn(e,u.get(e.key)??!e.folded,n,r,k,d,D);_.append(t.box),A.push(...t.articles)}w();for(let[e,t]of A)n.preview(e,t.querySelector(`[data-preview]`));Dn(e,l),qt(e,n,a,o)}function zn(e){let t=document.createElement(`dialog`);t.className=`confirm-dialog repo-sheet`,t.setAttribute(`data-repo-sheet`,``),t.setAttribute(`data-ci-sheet`,``);let n=document.createElement(`form`);n.addEventListener(`submit`,e=>e.preventDefault()),t.append(n);let r=()=>{},i=new Promise(e=>{r=e}),a=!1,o=()=>{a||c.busy||(a=!0,c.stop(),r({prOpened:c.prUrl}))},s=()=>{let t=document.createElement(`h2`);t.className=`confirm-title`,t.textContent=`Set up CI`;let r=document.createElement(`p`);r.className=`repo-sheet-sub`,r.textContent=e.name;let i=[t,r];if(c.step.k===`setUp`){let e=document.createElement(`p`);e.textContent=`CI is set up.`,e.setAttribute(`data-ci-set-up`,``),i.push(e)}let a=re(c),s=y(`Done`,`check`);s.setAttribute(`data-ci-done`,``),s.disabled=c.busy,s.addEventListener(`click`,o);let l=document.createElement(`div`);l.className=`confirm-actions`,l.append(...a.actions,s),i.push(...a.nodes,l),n.replaceChildren(...i),a.focus!==void 0&&queueMicrotask(()=>a.focus?.focus())},c=ne(e.ci,e.root,s);s(),c.read();let l=()=>{a||(a=!0,c.stop(),r({prOpened:c.prUrl}))};try{w(t,{ask:o,closed:l,ended:i})}catch(e){return Promise.reject(e)}return i}var Bn=document.querySelector(`#root`),Vn=document.querySelector(`#notice`),B=u(),Hn=B.scenes;B.nav.onOpen?.(e=>location.assign(e)),ae(B);var V=new Map;function H(e,t){Vn.textContent=e,Vn.className=t===`info`?`notice`:`notice notice-${t}`,Vn.classList.remove(`hidden`)}function Un(e){H(e,`error`)}function Wn(){Vn.textContent=``,Vn.className=`notice notice-error hidden`}function U(e,t){console.error(`demoman library: ${e} —`,t),Un(`Something went wrong (${e}). Try again.`)}function Gn(e,t){try{location.assign(e)}catch(e){U(t,e)}}var Kn=B.bundles,qn=new Map,Jn=typeof IntersectionObserver==`function`?new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;let e=qn.get(t.target);e!==void 0&&(qn.delete(t.target),Jn?.unobserve(t.target),e())}},{rootMargin:`200px`}):null,Yn=!1,Xn=(e,t)=>Jn===null?(Yn||(Yn=!0,console.info(`demoman library: no IntersectionObserver here, so every preview paints at once`)),t(),()=>{}):(qn.set(e,t),Jn.observe(e),()=>{qn.delete(e),Jn.unobserve(e)}),Zn=new Map,Qn={bundle:async e=>(await Kn.active(e)).bundle,length:async(e,t)=>{let n=Zn.get(e);if(n===void 0)throw Error(`no document for ${e} in the last listing`);return m(n,t,Kn.load)},image:async e=>{let t=B.folder;if(t===void 0||$n)return tr(e);try{return await t.thumb(e)}catch(t){if(!(t instanceof i)||t.reason!==`thumbFailed`)throw t;let n=t.status===501;n&&($n=!0),console.info(`demoman library: the Studio made no preview of ${e} (${t.message}); decoding ${n?`every preview`:`it`} here`);try{return await tr(e)}catch(e){throw Error(`${wr(t.message)}; decoding it on this page failed too: ${x(e)}`)}}},whenVisible:Xn},$n=!1,er=new Map;async function tr(e){let t=er.get(e);if(t===void 0){let n=nr(e).then(async e=>{try{return await createImageBitmap(e,{resizeWidth:320})}finally{e.close()}});n.catch(()=>{er.get(e)===n&&er.delete(e)}),er.set(e,n),t=n}let n=await t;return createImageBitmap(n)}async function nr(e){let t=await Kn.load(e);if(t instanceof Uint8Array)throw Error(`${e} loaded as motion bytes, not a keyframe`);if(!(t.image instanceof ImageBitmap))throw Error(`${e} decoded to something other than an ImageBitmap`);return t.image}var rr=null,W=null;function ir(e){let t=new Set([...e.rows.map(e=>L(`take`,e.sceneId)),...(e.groups??[]).map(e=>L(`video`,e.video.id)),...(e.unreadable??[]).flatMap(e=>{let t=zt(e);return t===null?[]:[L(t,e.folder)]})]);for(let e of V.keys())t.has(e)||V.delete(e)}var G=He(),K,q=g,ar=B.libraryView.read().then(e=>{q=e.view,e.unreadable!==void 0&&console.warn(`demoman library: the stored view could not be used, so it is the default: ${e.unreadable}`)},e=>{console.warn(`demoman library: the stored view could not be read, so it is the default: ${e instanceof Error?e.message:String(e)}`)}),J=null,or=t(location.search),sr=new URLSearchParams(location.search).get(`from`),cr=`all`,Y=new URLSearchParams(location.search).get(`q`)??``,lr=null,ur=(e,t)=>Be(Me(e,t,cr),Y);function dr(e){let n=q.project===null?null:t(`?project=${encodeURIComponent(q.project)}`);return n===null||n===`all`?`all`:(n===`unreadable`?(e.unreadable??[]).length:E(e).filter(e=>N(e)===(n===`none`?null:n.project)).length)>0?n:`all`}function fr(e){if(sr!==null){let t=E(e).find(e=>(e.group?.versions??[e.row]).some(e=>e.sceneId===sr));if(t!==void 0){let e=N(t);return e===null?`none`:{project:e}}}return or??dr(e)}function pr(e){let t=new URL(location.href);t.searchParams.delete(`from`),t.searchParams.delete(`project`);let n=t.searchParams.toString();return`${t.pathname}${h(e)}${n===``?``:`&${n}`}${t.hash}`}function mr(){G=He(),K=void 0}function X(e){ir(e),K?.busy!==!0&&(G=Ke(G,new Set((e.groups??[]).map(e=>e.video.id)))),rr?.dispose();for(let e of Br.splice(0))e();rr=Ce(Qn),J===null&&(J=fr(e),history.replaceState(history.state,``,pr(J)));let t=E(e);Rn(Bn,ur(e,J),Vr,V,void 0,G,K,q,{place:J,tab:cr,rail:Oe(t,(e.unreadable??[]).length,J),tabs:Pe(t,J)?Ne(E(Be(e,Y)),J):null,search:{query:Y,sort:lr,elsewhere:Ve(t,J,`all`,Y)}})}function hr(){qt(Bn,Vr,G,K)}var gr=ie({paint:e=>_r({keepNotice:e}),onRefreshFailed:e=>U(`refreshing the library`,e)});function Z(){return gr.render()}async function _r({keepNotice:e=!1}={}){e||Wn();let[,t]=await Promise.all([ar,B.folder.read()]);br(t)}var vr=null,yr=new Map;function br(e){let t=xr(e);vr=t;let n=t.scenes;Zn=new Map(n.map(e=>[e.meta.id,e]));let r=k({videos:t.videos,videoOf:t.videoOf,sizes:t.sizes,unreadable:t.unreadable,unwatched:t.unwatched,emptyHint:B.nav.firstTakeHint(),scenes:n,migrating:!1,migrationFailed:!1,notice:null,needsLook:new Set});W=r,Sr=t.addable??{},X(r)}function xr(e){return yr.size===0?e:{...e,videos:e.videos.map(e=>{let t=yr.get(e.id);return t===void 0?e:e.kept===null?{...e,kept:t,addedTo:t.key}:(yr.delete(e.id),e)})}}var Sr={},Cr=new Set,wr=e=>e.replace(/\.$/,``);async function Tr(e){let t=Sr[e],n=W?.groups?.find(t=>t.video.id===e);if(Cr.has(e)||t?.ok===!1||n===void 0)return;let r=L(`video`,e);V.delete(r),Cr.add(e),jr();let i=null;try{let t=await j({video:{id:e,name:n.video.name},repo:B.videos.repo,ci:B.repoCi,reveal:e=>B.files.reveal({kind:`path`,path:e})});i=t.added,t.failed!==void 0&&V.set(r,`Couldn't add: ${wr(t.failed)}.`)}catch(e){console.error(`demoman library: opening the add sheet —`,e),V.set(r,`Couldn't add: ${wr(x(e))}.`)}finally{Cr.delete(e)}if(i!==null&&Er.delete(i.root),i?.marked===!0&&vr!==null){let{root:t,file:n,deliver:r,key:a}=i;yr.set(e,{root:t,file:n,deliver:r,key:a}),br(vr)}else jr();Z().catch(e=>U(`adding it`,e))}var Er=new Map;function Dr(e){for(let t of vr?.videos??[]){let n=t.kept;if(!(n===null||`unknown`in n)&&(n.key??(`key`in t.repo?t.repo.key:null))===e)return n.root}return null}function Or(e){if(typeof e!=`object`)return null;let t=Dr(e.project);if(t===null)return null;let n=Er.get(t);return n===void 0?(Er.set(t,`reading`),B.repoCi.state(t).then(e=>Er.set(t,e),e=>Er.set(t,{kind:`unreadable`,detail:x(e)})).finally(Ar),null):n===`reading`||n.kind===`setUp`?null:()=>void kr(t,e.project)}async function kr(e,t){try{await zn({root:e,name:t.split(`/`).slice(1).join(`/`)||t,ci:B.repoCi})}catch(e){U(`opening CI setup`,e)}Er.delete(e),Ar()}function Ar(){let e=Bn.querySelector(`[data-ci-slot]`);e!==null&&typeof J==`object`&&J&&Kt(e,Or(J))}function jr(){vr!==null&&br(vr)}async function Mr(e){let t=W?.groups?.find(t=>t.video.id===e),n=t?.video.kept;if(t===void 0||n==null||`unknown`in n)return;let r=L(`video`,e),i;try{i=await o(O(t.video,n.file))}catch(e){V.set(r,`Couldn't remove: the confirmation could not open — ${wr(x(e))}.`),await Z();return}if(i)try{let n=await B.videos.repo.remove(e);V.delete(r),await Z();let i=T(t.video.name);n.notes.length===0?p(i):H([i,...n.notes].join(` `),`info`)}catch(e){V.set(r,`Couldn't remove: ${wr(x(e))}.`),await Z().catch(e=>U(`removing it`,e))}}var Nr={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`},Q=new Map;function Pr(e,t,n){let r=Q.get(e)??Q.get(Fr(e)??``);if(r===void 0){Gn(t,n);return}r.then(e=>{e&&Gn(t,n)})}function Fr(e){return W?.groups?.find(t=>t.versions.some(t=>t.sceneId===e))?.video.id}function Ir(t,n){if(n===`record`)return d;if(n===`video`){let n=W?.groups?.find(e=>e.video.id===t);if(n===void 0)return c;let r=e(n.video.versions),i=S(n.video);return i===null?r:{...r,body:`${r.body} ${i}`}}if(n===`take`){let e=W?.groups?.find(e=>e.versions.some(e=>e.sceneId===t));if(e!==void 0){let n=e.versions.find(e=>e.sceneId===t)?.version;return f(n,e.video.name)}}return c}var Lr={video:`Deleted the flow`,take:`Deleted the video`,folder:`Deleted the folder`,record:`Deleted the flow record`};function Rr(e){return Zn.get(e)?.meta.capture.mode===`authored`}var zr=ge(),Br=[],Vr={setView:e=>{if(Ie(Y)&&e.layout===q.layout){lr={...e.sort},W!==null&&X(W);return}q=e,W!==null&&X(W),B.libraryView.write(e).then(e=>{e.replaced!==void 0&&(console.warn(`demoman library: ${e.replaced}`),H(e.replaced,`warn`))},e=>{let t=e instanceof Error?e.message:String(e);console.warn(`demoman library: the view was not saved: ${t}`),H(`The view was not saved: ${t.replace(/\.$/,``)}.`,`warn`)})},goPlace:e=>{K?.busy!==!0&&(J=e,cr=`all`,mr(),location.search!==new URL(pr(e),location.href).search&&history.pushState(history.state,``,pr(e)),W!==null&&X(W),q={...q,project:typeof e==`string`?e:e.project},B.libraryView.write(q).then(e=>{e.replaced!==void 0&&(console.warn(`demoman library: ${e.replaced}`),H(e.replaced,`warn`))},e=>{console.warn(`demoman library: the project picked was not saved: ${e instanceof Error?e.message:String(e)}`)}))},search:e=>{Y=e,Ie(e)||(lr=null),K?.busy!==!0&&W!==null&&J!==null&&(G=Ke(G,new Set((ur(W,J).groups??[]).map(e=>e.video.id))));let t=new URL(location.href);e===``?t.searchParams.delete(`q`):t.searchParams.set(`q`,e),history.replaceState(history.state,``,t),W!==null&&X(W)},goTab:e=>{K?.busy!==!0&&(cr=e,mr(),W!==null&&X(W))},measure:(e,t)=>{let n=n=>{let r=n instanceof Error?n:Error(String(n));console.warn(`demoman library: length of ${e} could not be measured: ${r.message}`),_e(t,r)},r=Zn.get(e);if(r===void 0){n(Error(`no document for ${e} in the last listing`));return}let i=zr.get(r);if(i!==void 0){_e(t,i);return}let a=Xn(t,()=>{Kn.active(e).then(({bundle:e})=>e===null?{kind:`nothing`,reason:`it has no frames`}:zr.measure(r,()=>m(r,e,Kn.load))).then(e=>_e(t,e),n)});Br.push(a)},preview:(e,t)=>{if(rr===null){console.error(`demoman library: a row asked for a preview before the page had a mounter`);return}rr.mount(e,t)},edit:e=>{Pr(e,B.nav.editor(e),`opening the editor`)},rename:(e,t)=>{let n=(async()=>{try{let n=null;try{let r=await Hn.get(e);if(r===null)n=`the video is no longer stored`;else{let e={...r.scene,meta:{...r.scene.meta,name:t}};await Hn.put(e,r.revision)}}catch(e){n=e instanceof Error?e.message:String(e)}let r=L(`take`,e);return n===null?V.delete(r):V.set(r,`Couldn't rename: ${n}.`),await Z(),n===null}catch(t){return U(`renaming it`,t),V.set(L(`take`,e),`Couldn't rename: ${t instanceof Error?t.message:String(t)}.`),W!==null&&X(W),!1}})();Q.set(e,n),n.finally(()=>{Q.get(e)===n&&Q.delete(e)})},renameVideo:(e,t)=>{let n=(async()=>{let n=L(`video`,e),r=null;try{await B.videos.rename(e,t)}catch(e){r=e instanceof Error?e.message:String(e)}r===null?V.delete(n):V.set(n,`Couldn't rename: ${r.replace(/\.$/,``)}.`);try{await Z()}catch(e){U(`refreshing the library`,e)}return r===null})();Q.set(e,n),n.finally(()=>{Q.get(e)===n&&Q.delete(e)})},restore:e=>{let t=B.nav.rerun(e,Rr(e));if(t.kind===`line`){console.error(`demoman library: Restore was pressed on a platform whose route is a line`);return}Pr(e,new URL(t.href,B.nav.library()).href,`opening Runs to restore motion`)},rerunLine:(e,t)=>{let n=B.nav.rerun(e,t);return n.kind===`line`?n.text:null},backToRecording:e=>{(async()=>{let t=null,n=await Q.get(e),r=L(`take`,e),i=n===!1?V.get(r):void 0;try{let n=await Hn.get(e);if(n===null)throw Error(`the video is no longer stored`);let r={...n.scene,meta:{...n.scene.meta,renderMode:`screen`}};await Hn.put(r,n.revision);let i=(await Kn.active(e)).bundle;i?.source!==`capture`&&(t=i===null?`The original footage could not be put back: no frames could be read for this video.`:`There is no original footage of this video to go back to, so it keeps its re-shot frames. Videos rebuilt before original footage was kept have none.`,console.info(`[demoman] library: back to the original footage — not served (${i===null?`no bundle`:`serving ${i.source}`})`))}catch(e){U(`going back to the original footage`,e),t=`Couldn't go back to the original footage: ${e instanceof Error?e.message:String(e)}.`}let a=[i,t].filter(e=>e!=null).join(` `);a===``?V.delete(r):V.set(r,a);try{await Z()}catch(e){U(`refreshing the library`,e)}})()},select:(e,t,n,r)=>{K?.busy!==!0&&(G=Ue(G,e,t,n,r),K=void 0,hr())},selectAll:e=>{K?.busy!==!0&&(G=We(G,e),K=void 0,hr())},selectGroup:e=>{K?.busy!==!0&&(G=Ge(G,e),K=void 0,hr())},clearSelection:()=>{K?.busy!==!0&&(G=He(),K=void 0,hr())},deleteSelected:()=>{Hr()},repo:{addable:e=>Sr[e],adding:e=>Cr.has(e),add:e=>void Tr(e),remove:e=>void Mr(e)},ciSetup:e=>Or(e),remove:(e,t)=>{if(K?.busy===!0)return;let n=L(t,e);(async()=>{try{let r;try{r=await o(Ir(e,t))}catch(e){console.error(`demoman library: asking before a delete —`,e),V.set(n,`Not deleted: the confirmation could not open — ${e instanceof Error?e.message:String(e)}.`),await Z();return}if(!r)return;let i=W?.groups?.find(t=>t.video.id===e),a=t===`video`&&i!==void 0?S(i.video):null,s=e=>a===null?e:`${e} ${a}`;await Q.get(e);let c=t===`video`||t===`record`?await B.videos.remove(e):await Hn.remove(e),l=null;if(!c.ok){let e=c.detail??Nr[c.error]??c.error;V.set(n,`Not deleted: ${e}.`)}else if(c.partly!==void 0)V.delete(n),l=s(`Partly deleted: ${c.partly}.`);else if(c.result!==void 0&&!c.result.ok){let e=c.result.steps.find(e=>!e.ok),t=`Partly deleted: ${e?.step??`a step`} could not be removed — ${e?.error??`unknown error`}`;c.result.steps.find(e=>e.step===`scene`)?.ok===!0?(V.delete(n),l=t):V.set(n,t)}else V.delete(n);await Z(),l===null?c.ok&&c.note!==void 0?H(s(c.note),`info`):c.ok&&c.partly===void 0&&c.result?.ok!==!1&&p(a===null?Lr[t]:`${Lr[t]}. ${a}`):Un(l)}catch(e){U(`deleting it`,e)}})()}};async function Hr(){let e=new Map((W?.groups??[]).map(e=>[e.video.id,e.video])),t=[...G.ids].filter(t=>e.has(t));if(t.length===0||K?.busy===!0)return;let n=t.reduce((t,n)=>t+(e.get(n)?.versions??0),0),r=new Map(t.flatMap(t=>{let n=e.get(t),r=n===void 0?null:S(n);return r===null?[]:[[t,r]]})),i=l(t.length,n),a;try{a=await o(r.size===0?i:{...i,body:[i.body,...r.values()].join(` `)})}catch(e){console.error(`demoman library: asking before a bulk delete —`,e),K={busy:!1,said:`Not deleted: the confirmation could not open — ${e instanceof Error?e.message:String(e)}.`},hr();return}if(!a)return;let s=t.filter(e=>G.ids.has(e));if(s.length===0)return;K={busy:!0,said:null},hr();let c=[];for(let t of s){let n=e.get(t)?.name??t;try{let e=await B.videos.remove(t),i=[e.ok?e.note:void 0,r.get(t)].filter(e=>e!==void 0),a=i.length===0?{}:{note:i.join(` `)};e.ok&&e.partly!==void 0?c.push({id:t,name:n,stayed:`only part of it went: ${e.partly}`,...a}):e.ok?c.push({id:t,name:n,gone:!0,...a}):e.error===`videoNotFound`?c.push({id:t,name:n,gone:!0}):c.push({id:t,name:n,stayed:e.detail??Nr[e.error]??e.error})}catch(e){c.push({id:t,name:n,stayed:e instanceof Error?e.message:String(e)})}}let u=ee(c),d=new Set(c.flatMap(e=>`stayed`in e?[e.id]:[]));G=Ke(G,d),K=d.size===0?void 0:{busy:!1,said:u.text};try{await Z()}catch(e){U(`refreshing the library`,e)}d.size===0?c.some(e=>`gone`in e&&e.note!==void 0)?H(u.text,u.level):p(u.text):G.ids.size===0&&H(u.text,u.level)}window.addEventListener(`popstate`,()=>{J=t(location.search)??`all`,cr=`all`,Y=new URLSearchParams(location.search).get(`q`)??``,lr=null,K?.busy!==!0&&mr(),W!==null&&X(W)}),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&G.ids.size!==0&&document.querySelector(`dialog[open]`)===null&&(document.activeElement?.matches(`input:not([type=checkbox]), textarea`)||Vr.clearSelection?.())}),document.addEventListener(`keydown`,e=>{if(e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey)return;let t=document.querySelector(`[data-search]`);if(t===null||t.closest(`[hidden]`)!==null||document.querySelector(`dialog[open]`)!==null)return;let n=document.activeElement;n?.matches(`input:not([type=checkbox]), textarea, select`)!==!0&&n?.isContentEditable!==!0&&(e.preventDefault(),t.focus())}),B.folder?.onChange(()=>gr.soon());var $=_();Z().then(()=>{$===`Deleted the video`?p($):$!==null&&H($,`info`)},e=>{$!==null&&console.info(`demoman library: ${$}`),U(`loading your flows`,e)});