demoman 0.7.3 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{$ as e,B as t,F as n,G as r,H as i,I as a,J as o,K as s,P as c,Q as l,T as u,U as d,V as f,W as p,X as m,Y as h,Z as g,c as _,ct as v,d as y,et as ee,f as b,ft as x,h as te,i as ne,l as re,lt as ie,nt as ae,o as S,ot as oe,p as se,pt as ce,q as le,t as ue,tt as de,u as fe,ut as pe,v as me,y as he}from"./confirm-dialog-DVfQ_GQr.js";import{C as ge,E as _e,S as ve,T as ye,_ as be,a as xe,b as Se,c as Ce,d as we,f as Te,g as Ee,h as De,l as Oe,m as ke,o as C,p as Ae,s as je,u as Me,v as Ne,w as Pe,x as Fe,y as Ie}from"./view-v5HQTLVP.js";import{c as Le,f as Re,h as ze,l as Be,m as Ve}from"./state-tew-ACWl.js";function He(e,t){let{bundle:n,scene:r}=o(t,e),i=new Map(r.anchors.map(e=>[e.id,e])),a=new Map((n.markers??[]).map(e=>[e.actionId,e.sourceTimeMs])),s=new Map;for(let e of r.anchors)e.fingerprint.boundingRect&&s.set(e.id,e.fingerprint.boundingRect);let c=new Map;for(let e of n.anchorRects??[])c.set(e.actionId,e.rect);let l=(e,t)=>c.get(t)??s.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:l(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:c,height:u}=n.viewport;return s.x<0||s.y<0||s.x+s.width>c||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 Ue=64;function We(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}function Ge(e,t){let n=0;for(let r=0;r<e.length;r++)n+=Math.abs((e[r]??0)-(t[r]??0));return n/e.length}async function Ke(e,t,n,r){let i=[];for(let a of He(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 c=Math.max(1,Math.min(Ue,Math.round(a.rect.width))),l=Math.max(1,Math.min(Ue,Math.round(a.rect.height))),u;try{u=Ge(We(e,a.rect,t.viewport,c,l),We(o,a.rect,t.viewport,c,l))}catch{i.push({actionId:a.actionId,kind:`unknown`,reason:`decodeFailed`});continue}i.push({actionId:a.actionId,kind:u>r?`moved`:`still`})}return i}function qe(t){return g.neutral.zoomHoldMs+e(t).zoomOutMs}qe(ie.smoothness);var Je=Math.abs(g.leadInMs)+g.neutral.minPlateauMs+400;function Ye(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`tooClose`:return`${t}: too close to the previous zoom (${n}, minimum ${Je}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 ${Xe}x).`;case`textTooWide`:return`${t}: target too wide to zoom without cutting text (would be ${e.scale}x, floor ${Xe}x).`}}g.fitMarginPx;var Xe=1.2,Ze=`__demomanClickProbe`;`${Ze}${JSON.stringify(`__demomanClickSeen`)}`,`${Ze}`,`${Ze}`;var Qe={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 is no longer on the page — re-record that step, or remap its anchor`,ambiguousAnchor:`several elements matched this step, so replay stopped rather than risk clicking the wrong one — that target needs identifying more precisely`,anchorNotRendered:`an element had not been rendered yet — the page probably just needs scrolling further, and the take itself is likely fine`,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 anchor, so re-recording that 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; re-record that step`,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:`the page never reached a state the take was waiting for`,occlusionTimeout:`the render window stayed covered, so the frames would not have been usable`,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 take, so re-recording 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 $e(e){return e in Qe?Qe[e]:e}function et(e){if(!e)return`(navigation)`;let t=e.fingerprint;return t.accessibleName??t.textContent??t.stableId??t.dataKey??e.id}function tt(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:et(e.anchors.find(e=>e.id===n.anchorId))}:null}function nt(e,t){return tt(e,t)}function rt(e){return e.meta.capture.mode===`authored`}function it(e){return e?`run its script again in Runs`:`re-shoot it in Runs`}function at(e){let{toolchain:t,name:n,...r}=e.meta,{canvas:i,...a}=e;return st(ot({...a,meta:r})).toString(16)}function ot(e){if(typeof e!=`object`||!e)return JSON.stringify(e)??`null`;if(Array.isArray(e))return`[${e.map(ot).join(`,`)}]`;let t=e;return`{${Object.keys(t).filter(e=>t[e]!==void 0).sort().map(e=>`${JSON.stringify(e)}:${ot(t[e])}`).join(`,`)}}`}function st(e){let t=3735928559,n=1103547991;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);t=Math.imul(t^i,2654435761),n=Math.imul(n^i,1597334677)}return t=Math.imul(t^t>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),4294967296*(2097151&n)+(t>>>0)}var ct={run:{phase:`idle`},save:null,error:null},lt=(e,t)=>e===null?t:`${e}; ${t}`;function ut(e,t){let n=e.run.phase===`encoding`||e.run.phase===`queued`;switch(t.kind){case`queued`:return n?{flow:{...e,run:{phase:`queued`,position:t.position}},effect:`render`}:{flow:e,effect:`none`};case`rendering`:return n?{flow:{...e,run:{phase:`encoding`,done:t.done,total:t.total}},effect:`progress`}:{flow:e,effect:`none`};case`fileFailed`:return{flow:{...e,error:lt(e.error,t.line)},effect:`none`};case`saving`:return{flow:{...e,run:{phase:`saving`}},effect:`render`};case`saved`:return{flow:{...e,run:{phase:`idle`},save:t.save.kind===`saved`&&t.summary!==null?{...t.save,summary:t.summary}:t.save},effect:`render`};case`failed`:return{flow:{...e,run:{phase:`idle`},error:t.detail===null?e.error:lt(e.error,t.detail)},effect:`render`};case`outputsChanged`:return{flow:e,effect:`relist`}}}var dt=`motion reclaimed to free space`;function ft(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]=mt(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 pt(e,t=2){return String(Number(e.toFixed(t)))}function mt(e,t){for(let n=2;n<4;n++)if(pt(e,n)!==pt(t,n))return[pt(e,n),pt(t,n)];return[pt(e,4),pt(t,4)]}function ht(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 recording 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=>ft(e,t))}}function gt(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}}function _t(e){return e?`Run its script again in Runs`:`Re-shoot this take in Runs`}function vt(e){let t=it(e);return t.charAt(0).toUpperCase()+t.slice(1)}function yt(e){return e.rerun.kind===`line`?e.rerun.text:null}function bt(e,t,n){return t??`${vt(e)} ${n}.`}var w=1,T=e=>({kind:`refusal`,reason:e});function xt(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 St(e){return new Map(e.markers.map(e=>[e.actionId,e.sourceTimeMs]))}function Ct(e,t,n){return wt(e,de(t,n))}function wt(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 Tt(e,t,n){let r=St(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=xt(t,e=>c(e.start,-1/0)),u=xt(t,e=>-c(e.end,1/0));if(l===void 0||u===void 0)continue;let d=ee(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:ee(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=ee(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 Et(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 take's start or end splits nothing.`);let i=Ct(t,n,r);if(i===null)return T(`These frames name no step, so there is nothing to split by.`);let a=St(t).get(i.actionId)??0,o=ee(n,a+i.sourceOffsetMs),{pieces:s}=Tt(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 Dt=(e,t)=>e===null||t===null?e===t:e.actionId===t.actionId&&e.sourceOffsetMs===t.sourceOffsetMs;function Ot(e,t,n){let r=e.find(e=>Dt(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 kt(e,t,n,r,i,a){let o=n.find(e=>Dt(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=Ct(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=wt(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 At=1e3;function jt(e,t){return`Motion reclaimed to free space. ${bt(e,t,`to restore`)}`}var Mt=new Set([`Motion reclaimed to free space. Replay to restore.`,`Motion reclaimed to free space. Rebuild to restore.`]);function Nt(e,t,n,r){return e===`motionReclaimed`?Mt.has(t)||t===`Motion reclaimed to free space. Re-shoot it in Runs to restore.`?jt(n,r):t:`${e}: ${t}`}var Pt=(e,t)=>e.hasBundle?t.outputMs??t.captureMs:t.captureMs;function Ft(e){return e.hasBundle&&e.outputDurationMs!==null?e.outputDurationMs:(e.beats[e.beats.length-1]?.captureMs??0)+At}var It=e=>({actionId:e.actionId,offsetMs:e.sourceOffsetMs});function Lt(e,t){let n=e.beats.find(e=>e.actionId===t.actionId);return(n?Pt(e,n):0)+t.offsetMs}function Rt(t){let{scene:n,view:r,bundle:i,resolved:a}=t,o=rt(n),s=t.rerunLine??null,c=e=>bt(o,s,e),l=Ft(r),u=[],d=new Set(t.hoverReport?.removable??[]),f=new Map(r.beats.map(e=>[e.actionId,Pt(r,e)])),p=new Map(r.beats.map(e=>[e.actionId,e.timing])),m=e=>a===null?`estimated`:e?p.get(e.actionId)??`estimated`:`rendered`,h=r.beats.map(e=>({actionId:e.actionId,atMs:f.get(e.actionId)??0,verb:e.verb,label:e.label,timing:e.timing,flag:d.has(e.actionId)?`unchangedHover`:null,canZoom:e.canZoom,cut:e.cut})),g=n.edits.trim,_=a?{headMs:a.range.startMs,headTiming:a.trimUnplaced.includes(`head`)?`estimated`:`rendered`,tailMs:a.range.endMs,tailTiming:a.trimUnplaced.includes(`tail`)?`estimated`:`rendered`,headMarker:g?.head??null,tailMarker:g?.tail??null}:{headMs:g?.head?Math.max(0,Lt(r,g.head)):0,headTiming:g?.head?`estimated`:`rendered`,tailMs:g?.tail?Math.min(l,Lt(r,g.tail)):l,tailTiming:g?.tail?`estimated`:`rendered`,headMarker:g?.head??null,tailMarker:g?.tail??null};for(let e of a?.trimUnplaced??[])u.push(`The trim's ${e} is placed from the take's own timestamp: the last render carried no marker for its step. ${c(`to give it measured timing`)}`);for(let e of a?.timeline.unplacedCuts??[])u.push(`A removed piece removed no frames: ${e.reason}.`);let v=new Set((a?.clampedRanges??[]).filter(e=>e.kind===`zoom`).map(e=>e.id));for(let e of a?.clampedRanges??[])u.push(e.note);let y=new Map((a?.cameraSegments??[]).map(e=>[e.id,e])),{smoothness:b}=n.motion??ie,x=qe(b),{zoomInMs:te}=e(b),ne=new Set,re=n.camera.flatMap(e=>{let t=e.scale??1;if(t<=1)return[];let n=y.get(e.id);n||ne.add(e.id);let i=n?n.startMs:Math.max(0,Lt(r,e.marker)),a=n?n.endMs:Math.min(l,e.end?Lt(r,e.end):i+x),o=e.point?{kind:`point`,x:e.point.x,y:e.point.y}:{kind:`element`,anchorId:e.anchorId??``};return n?.endUnplaced&&u.push(`The end of zoom "${e.id}" is placed from the take's own timestamp: the last render carried no marker for its step. ${c(`to give it measured timing`)}`),[{id:e.id,actionId:e.marker.actionId,departMs:n?.departMs??i,startMs:i,endMs:a,drawnEndMs:a,endAuthored:e.end!==void 0,scale:t,target:o,aimFallback:e.note??null,timing:n?n.endUnplaced?`estimated`:m(e.marker):`estimated`,clamped:v.has(e.id),marker:e.marker,endMarker:e.end??null}]}),ae=re.map(e=>{if(!ne.has(e.id))return e;let t=Math.min(...re.map(e=>e.startMs).filter(t=>t>e.startMs));return e.endMs>t?{...e,endMs:t}:e}),S=ae.map(e=>ne.has(e.id)?{...e,departMs:zt(ae,e.startMs,te)}:e),oe=S.map(e=>({...e,drawnEndMs:Bt(S,e.startMs,e.endMs)})),se=new Set(n.camera.map(e=>e.marker.actionId));for(let e of n.zoomsSkipped??[])se.has(e.actionId)||`afterActionId`in e&&!se.has(e.afterActionId)||u.push(Ye(e));let ce=new Map((a?.cosmetics??[]).map(e=>[e.id,e])),le=n.edits.masks.map(e=>{let t=e.start===void 0||e.end===void 0,n=ce.get(e.id),i=n?.range??null;for(let t of n?.unplaced??[])u.push(`The ${t} of mask "${e.id}" is placed from the take'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. ${c(`to give it measured timing`)}`);let o=t?0:i?i.startMs:e.start?Math.max(0,Lt(r,It(e.start))):0,s=t?l:i?i.endMs:e.end?Math.min(l,Lt(r,It(e.end))):l;return{id:e.id,startMs:o,endMs:s,rect:e.rect,wholeTake:t,timing:t||a&&i&&m(e.start)===`rendered`&&m(e.end)===`rendered`?`rendered`:`estimated`,startMarker:e.start??null,endMarker:e.end??null}}),ue=e=>a?ee(a.timeline,e):e,de=(i?.degradations??[]).map(e=>({startMs:ue(e.startMs),endMs:ue(e.endMs)}));for(let e of i?.degradations??[])u.push(Nt(e.kind,e.note,o,s));let fe=a?.timeline.unplacedPaces??0;if(fe>0){let e=fe===1?`pause`:`pauses`;u.push(`pacingUnplaced: ${fe} recorded ${e} could not be placed. The last render carried no marker for the steps they sit between, so this video is shorter than the take by however long those ${e} were. ${c(`to restore them`)}`)}let pe=a?.timeline.nonMonotonicPaces??0;if(pe>0){let e=pe===1?`pair`:`pairs`;u.push(`pacingBackwards: ${pe} step ${e} in this take carry timestamps that run backwards, so the take's order is not its time order. A re-shoot counts the pause across ${pe===1?`it`:`them`} twice and comes out longer than the take. Re-record to straighten the order; the frames you already have are unaffected.`)}let{pieces:me,joins:he,unplacedSplits:ge}=i!==null&&a!==null?Tt(n,i,a.timeline):{pieces:[],joins:[],unplacedSplits:[]};for(let e of ge)u.push(`A split is not drawn: the last render carried no marker for its step. ${c(`to place it`)}`);return{clip:{durationMs:l,trim:_,ticks:h,degraded:de,pieces:me,joins:he},zooms:oe,masks:le,durationMs:l,timeSource:r.hasBundle?`rendered`:`captured`,authored:o,rerunLine:s,hoverCheck:{failed:t.hoverReport?.failed??!1,unchecked:t.hoverReport?.unchecked??0},notices:u,zoomDefaultMs:x,zoomInMs:te}}function zt(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 Bt(e,t,n){return Math.min(n,...e.filter(e=>e.startMs>t).map(e=>e.departMs))}function Vt(e,t,n){let r=e.clip.ticks,i=r[0];if(!i)throw Error(`a take 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 Ht(e){let{resolved:t,outputTimeMs:n,presentation:r,target:i,viewport:o}=e;return l(m(t,n),a(r.frameRect,o),r.frameRect,o,i)}var Ut=(e,t,n)=>Math.min(n,Math.max(t,e));function Wt(e,t){let n=e.width/2,r=e.height/2;return{x:Ut(t.x-n/2,0,e.width-n),y:Ut(t.y-r/2,0,e.height-r),width:n,height:r}}function Gt(e){let{rect:t,resolved:n,target:r,presentation:i,outputTimeMs:a}=e,o=n.plan.viewport,s=Ht({resolved:n,outputTimeMs:a,presentation:i,target:r,viewport:o});return c(t,s,i.frameRect,o)}function Kt(e){let{rect:t,resolved:n,target:r,presentation:i,outputTimeMs:a}=e,o=n.plan.viewport,s=Ht({resolved:n,outputTimeMs:a,presentation:i,target:r,viewport:o}),c=f(t,s,i.frameRect,o),l=Ut(c.x,0,o.width),u=Ut(c.y,0,o.height),d=Ut(c.x+c.width,0,o.width),p=Ut(c.y+c.height,0,o.height);return{x:l,y:u,width:d-l,height:p-u}}function qt(e){let{zoom:t,resolved:n,viewport:r,presentation:i,target:a}=e,o=Ht({resolved:n,outputTimeMs:(t.startMs+t.endMs)/2,presentation:i,target:a,viewport:r});return f({x:0,y:0,width:a.width,height:a.height},o,i.frameRect,r)}var Jt=2e3,Yt=e=>e!==null&&e.kind===`refusal`,E=e=>({kind:`refusal`,reason:e});function Xt(e,t){if(e.resolved===null||e.bundle===null)return{reason:`nothing has rendered yet`};if(e.bundle.cursorSamples.length===0)return{reason:`this take has no recorded pointer`};let n=de(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=le(e.resolved.cursor,n);return r?{point:r}:{reason:`the pointer was not observed here`}}var Zt=(e,t)=>e.zooms.find(e=>e.id===t),Qt=(e,t)=>e.masks.find(e=>e.id===t);function $t(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=en(a,i,n,r);if(e)return{zoom:a,why:e}}}function en(e,t,n,r){let i=Math.abs(n-e.startMs);if(i<Je&&(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 tn({zoom:e,why:t}){switch(t){case`start`:return E(`That would start it within ${Je}ms of the zoom "${e.id}" at ${nn(e.startMs)}; the camera needs ${Je}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 ${nn(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 ${nn(e.endMs)}; drag that zoom's end earlier first.`)}}var nn=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 rn(e){let{leadInMs:t}=g;return{earliestMs:e+t,latestMs:e}}function an(e,t){let{leadInMs:n}=g,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}=rn(t);return e.zooms.find(e=>en(e,void 0,n,null)!==void 0||en(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+Je,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-Je;if(rn(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 ${nn(o.startMs)}, and there is no slot either side of it. Drag that zoom to make space, or remove one.`)}function on(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+Jt,e.durationMs)}}function sn(e,t,n,r){let i=Vt(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(de(t.resolved.timeline,n)-a.sourceTimeMs)}}var cn=(e,t)=>e.actionId===t.actionId&&t.sourceOffsetMs<=e.sourceOffsetMs;function ln(e,t){return t!==null&&e.actionId===t.actionId&&t.offsetMs<=e.offsetMs}var un=e=>E(`That would leave the ${e} no length; drag its end further.`),dn=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 fn(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 take has no steps to attach an edit to.`);switch(n.kind){case`pieceEdge`:return kt(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=Vt(e,n.toMs,n.snapMs);return ln(r,t.tailMarker)?dn(`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=Vt(e,n.toMs,n.snapMs);return t.headMarker&&ln(t.headMarker,r)?dn(`tail`):{kind:`setTrim`,tail:r}}case`addZoom`:{let i=an(e,n.atMs);if(Yt(i))return i;let{atMs:a,movedPast:o}=i,s=Vt(e,a,o?0:n.snapMs),c=o?`Placed ${o.side} the zoom at ${nn(o.zoom.startMs)}: there was no room at ${nn(n.atMs)}.`:null,l=g.defaultZoomScale,u=Xt(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 take 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=Zt(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 take does.`);if(a>i)return E(`A zoom cannot end after the take does.`);let o=$t(e,t.id,r,t.endAuthored?a:null);if(o)return tn(o);let s=Vt(e,r,n.snapMs),c=t.endAuthored?Vt(e,a,n.snapMs):null;return ln(s,c)?un(`zoom`):{kind:`setZoomRange`,id:t.id,start:s,end:c}}case`zoomEdge`:{let t=Zt(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 ${nn(i)}, after its end at ${nn(t.endMs)}. Drag the end later first.`);let a=$t(e,t.id,i,null);if(a)return tn(a);let o=Vt(e,r,n.snapMs),s={...o,offsetMs:o.offsetMs+e.zoomInMs},c=t.endMarker;return ln(s,c)?un(`zoom`):{kind:`setZoomRange`,id:t.id,start:s,end:c}}if(n.toMs>i)return E(`A zoom cannot end after the take 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=$t(e,t.id,t.startMs,n.toMs);if(r)return tn(r);let a=t.marker,o=Vt(e,n.toMs,n.snapMs);return ln(a,o)?un(`zoom`):{kind:`setZoomRange`,id:t.id,start:a,end:o}}case`addMask`:{let t=on(e,n.atMs);if(Yt(t))return t;let{endMs:i}=t,a=Xt(r,n.atMs),o=`point`in a?a.point:{x:r.viewport.width/2,y:r.viewport.height/2},s=Wt(r.viewport,o),c=sn(e,r,n.atMs,n.snapMs),l=sn(e,r,i,n.snapMs);if(cn(c,l)){let t=fn(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=Qt(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 take, 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 take does.`);if(o>i)return E(`A mask cannot end after the take does.`);let s=sn(e,r,a,n.snapMs),c=sn(e,r,o,n.snapMs);return cn(s,c)?un(`mask`):{kind:`setMaskRange`,id:t.id,start:s,end:c}}case`maskEdge`:{let t=Qt(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 take, 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 take does.`);if(n.toMs>t.endMs-100)return E(`A mask cannot start after it ends; drag its end later first.`);let i=sn(e,r,n.toMs,n.snapMs),a=t.endMarker;return cn(i,a)?un(`mask`):{kind:`setMaskRange`,id:t.id,start:i,end:a}}if(n.toMs>i)return E(`A mask cannot end after the take 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=sn(e,r,n.toMs,n.snapMs);return cn(a,o)?un(`mask`):{kind:`setMaskRange`,id:t.id,start:a,end:o}}}}function mn(e,t,n){let r=e.beats.find(e=>e.actionId===t);return r===void 0?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 hn(e){return e.actions.map(e=>e.id).join(` `)}function gn(e){return{bundle:e.bundle,actionIds:hn(e.scene)}}function _n(e,t){return e!==null&&t.bundle===e.bundle&&hn(t.scene)===e.actionIds&&t.hoverReport!==null}var vn={removable:[],checked:0,unchecked:0,failed:!0};function yn(e){return e.kind!==`unknown`||e.reason!==`notStyleSignalled`}function bn(e,t){let n=e.filter(yn).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 xn={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 Sn(e){return Object.entries(e.uncheckedBy??{}).filter(([,e])=>e>0).sort((e,t)=>t[1]-e[1]).map(([e,t])=>{let n=xn[e];return`${t} ${t===1?n.one:n.many}`}).join(`, `)}function Cn(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=Sn(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 wn(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 Tn(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 En(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 Dn(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 On(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=Dn(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 kn(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 An(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 jn(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 Mn(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 Nn(e,t){return e===null||[...new Set([...Object.keys(t),...Object.keys(e)])].some(n=>t[n]!==e[n])}function Pn(e,t){return e===null||e.smoothness!==t.smoothness||e.blur!==t.blur||e.follow!==t.follow}function Fn(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!(r.kind===i.kind&&(r.kind===`solid`?r.color===i.color:r.from===i.from&&r.to===i.to&&r.angle===i.angle))||e.cornerRadius!==t.cornerRadius||!n(e.frameRect,t.frameRect)||e.logo?.image!==t.logo?.image||e.logo?.opacity!==t.logo?.opacity||!n(e.logo?.rect,t.logo?.rect)}function In(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 Ln(){let e=new Map;return{isOpen:(t,n)=>e.get(t)??n,set:(t,n)=>{e.set(t,n)}}}var Rn={attachFailed:`Couldn't record the screen, so this take has no video`,debuggerDetached:`Recording stopped partway through`,debuggerLost:`Recording stopped and couldn't restart`,debuggerRecovered:`A stretch in the middle is missing`,workerRestarted:`The extension restarted mid-take, so this take has no video`,noKeyframes:`Nothing could be photographed, so there's no video`,screencastUnavailable:`Motion couldn't be recorded, so this take is stills`,muxFailed:`The motion couldn't be encoded, so this take is stills`,muxUnavailable:`There was nowhere to encode the motion, so this take is stills`,budgetSpent:`The take 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:`Recording was interrupted, so parts are stills`,spansDiscarded:`Some motion couldn't be encoded, so those moments are stills`,storageRefused:`This take's frames couldn't be saved — free up space and record it again`,bundleInvalid:`This take's video couldn't be put together`},zn={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`},Bn=new Set([`debuggerDetached`,`debuggerLost`,`debuggerRecovered`]),Vn=e=>Object.hasOwn(zn,e)?zn[e]:e;function Hn(e){let t=Rn[e];if(t!==void 0)return t;let n=e.indexOf(`:`);if(n>0){let t=e.slice(0,n),r=Rn[t],i=e.slice(n+1);if(r!==void 0&&i!==``)return`${r} — ${Bn.has(t)?Vn(i):i}`}return e}function Un(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`${Hn(e.reason)}${n}`}var Wn={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 Gn(e){return e===null||e.reason===null?!1:Wn[e.reason]===!0}function Kn(e,t,n){if(e===null||e.reason===null||!t.mayReplay||e.reason===`mutating`)return null;let r=$e(e.reason),i=n!==void 0&&rt(n),a=i?`The script run`:`The re-shoot`,o=i?`performed`:`reconstructed`,s=n?nt(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 ${it(i)} to try again.`:`${a} ${o} all ${e.total} steps, but: ${r}.`;let l=Gn(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 qn(e,t){let n=e.camera.find(e=>e.id===t);if(!n)throw Error(`unknown zoom "${t}"`);return n}var Jn=1,Yn=e=>Error(`1:1 is not a zoom — remove the zoom instead of authoring ${e}`);function Xn(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 Yn(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?g.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,...t.note===void 0?{}:{note:t.note}};return{...e,camera:[...e.camera,a]}}case`setZoomRange`:{let n=qn(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{...e,camera:e.camera.map(e=>e.id===n.id?a:e)}}case`setZoomScale`:{let n=qn(e,t.id);if(t.scale<=1)throw Yn(t.scale);return{...e,camera:e.camera.map(e=>e.id===n.id?{...e,scale:t.scale}:e)}}case`setZoomTarget`:{let n=qn(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}}:e)}}case`removeZoom`:return qn(e,t.id),{...e,camera:e.camera.filter(e=>e.id!==t.id)};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<Jn||t.rect.height<Jn)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:De(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 take 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 take 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 Zn(e,t,n){return pe.parse(Xn(e,t,n))}function Qn(e){return{scene:e,past:[],future:[],error:null,dirty:!1,hoverReport:null}}function $n(e,t,n){let r;try{r=Zn(e.scene,t,n)}catch(t){return{...e,error:t instanceof Error?t.message:String(t)}}return t.kind===`setBranding`&&be(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 er(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 tr(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 nr(e){return{...e,dirty:!1}}var rr={mayReplay:!0};function ir(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 ar(e,t){return e.meta===void 0||e.flags===void 0?!1:ir(e)===ir(t)}function or(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(ir(e)),JSON.parse(ir(t)),`scene`)}function sr(e,t){let{renderMode:n,...r}=e.meta;return{...e,meta:t.meta.renderMode===void 0?r:{...r,renderMode:t.meta.renderMode}}}function cr(e,t){return{...sr(e,t),flags:{...e.flags,hoverSensitive:t.flags.hoverSensitive}}}function lr(e){let t=Qn({}),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:Kn(i,rr,t.scene),replayRecoverable:Gn(i),captureSentence:a===null||n!==null&&n.source!==`capture`?null:Un(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=sr(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=ar(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 ${or(t.scene,o)}`),t=c?{...Qn(o),past:t.past.map(e=>cr(e,o)),future:t.future.map(e=>cr(e,o))}:Qn(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=$n(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=nr(t),u()})},async undo(){await c(async()=>{let e=er(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=nr(t),u()})},async redo(){await c(async()=>{let e=tr(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=nr(t),u()})},async settled(){let e;do e=s,await e;while(e!==s)},setHoverReport(e){t={...t,hoverReport:e},u()}}}var ur=1.2;function dr(e,t){let n=e.key,r=n.toLowerCase();if(e.metaKey||e.ctrlKey)return r===`z`?e.shiftKey?t.canRedo?{kind:`redo`}:null:t.canUndo?{kind:`undo`}:null:r===`y`&&e.ctrlKey&&!e.metaKey?t.canRedo?{kind:`redo`}:null:r===`b`&&!e.shiftKey?{kind:`split`}:!e.shiftKey&&(n===`ArrowLeft`||n===`ArrowRight`)?{kind:`seekEdge`,edge:n===`ArrowLeft`?`head`:`tail`}:null;if(n===` `)return{kind:`playPause`};if(r===`j`)return{kind:`shuttle`,direction:-1};if(r===`k`)return{kind:`stop`};if(r===`l`)return{kind:`shuttle`,direction:1};if(n===`ArrowRight`||n===`ArrowLeft`){let t=e.shiftKey?500:100;return{kind:`nudge`,deltaMs:n===`ArrowRight`?t:-t}}return n===`ArrowDown`?{kind:`stepBeat`,delta:1}:n===`ArrowUp`?{kind:`stepBeat`,delta:-1}:n===`Home`?{kind:`seekEdge`,edge:`head`}:n===`End`?{kind:`seekEdge`,edge:`tail`}:r===`i`?{kind:`setTrim`,edge:`head`}:r===`o`?{kind:`setTrim`,edge:`tail`}:n===`Delete`||n===`Backspace`?t.hasSelection?{kind:`deleteSelection`}:null:n===`+`||n===`=`?t.hasTimeline?{kind:`zoomTimeline`,factor:ur}:null:n===`-`||n===`_`?t.hasTimeline?{kind:`zoomTimeline`,factor:1/ur}: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 fr={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 mr(e,t){let n=fr[e];return n===void 0?e:pr(n.label,t)}var hr=new Set([`⌘`,`⇧`,`⌫`,`←`,`→`,`↑`,`↓`]);function gr(e){return hr.has(e)}function _r(e,t){let n=fr[e];return n===void 0?e:pr(n.spoken,t)}function vr(e,t){return e.map(e=>_r(e,t)).join(` plus `)}function yr(e){return/\bMac/i.test(e)}function br(e,t){return pr(e.description,t)}var xr=[{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, zoom or mask`,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 take`,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 Sr(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 Cr=[`nw`,`n`,`ne`,`e`,`se`,`s`,`sw`,`w`],wr=3;function Tr(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 Er(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 Dr(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=Sr(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=Gt({rect:i.rect,...s});Tr(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)>wr&&(l=!0),c=Er(r,t,(n.clientX-e.clientX)/o.scale,(n.clientY-e.clientY)/o.scale),Tr(a,c,o)},d=()=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),l&&n.onMaskRect(i.id,Kt({rect:c,...s}))};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d)})};l(a,`body`);for(let e of Cr){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=Gt({rect:qt({zoom:c,resolved:i,viewport:i.plan.viewport,presentation:a,target:t.target}),...s});Tr(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)>wr&&(r=!0),u=Er(t,`body`,(n.clientX-e.clientX)/o.scale,(n.clientY-e.clientY)/o.scale),Tr(l,u,o)},a=()=>{if(window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,a),!r)return;let e=Kt({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 Or(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??g.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??[]):ae(t),l=new Map((r?.markers??[]).map(e=>[e.actionId,e.sourceTimeMs])),u=(e,t)=>{if(n===null||r===null||!ce(r)||x(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||ce(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,h)=>{let g=e.anchorId?i.get(e.anchorId):void 0,_=a.get(e.id),v=o.get(e.id),y=s.get(e.id),b=t.actions[h+1],x=l.get(e.id);return{actionId:e.id,index:h,verb:e.kind,anchorId:e.anchorId,label:et(g),text:e.kind===`type`?e.text:null,redacted:e.kind===`type`&&e.redacted,host:e.kind===`type`&&e.host===!0,strategy:g?.resolution.strategy??null,outputMs:n?ee(n.timeline,x??e.timestamp):null,timing:x===void 0?`estimated`:`rendered`,captureMs:e.timestamp,camera:_??null,canZoom:e.anchorId!==null,gap:v?{durationMs:v.durationMs}:null,canPace:b!==void 0&&u(e,b),renderedPauseMs:f(e,b),renderedPaceFreezeMs:p(e,b),renderedFreezeBeforeMs:r!==null&&!ce(r)&&x!==void 0&&n!==null&&x<n.timeline.sourceDurationMs?d(x):0,legacyHold:y?{offsetMs:y.marker.offsetMs,durationMs:y.durationMs}:null,cut:c.has(e.id),isLast:h===m}}),outputDurationMs:n?.timeline.outputDurationMs??null,hasBundle:n!==null}}var kr=(e,t,n)=>Math.min(n,Math.max(t,e)),Ar=e=>({startMs:0,endMs:Math.max(250,e)}),k=(e,t)=>(t-e.startMs)/(e.endMs-e.startMs),jr=(e,t)=>e.startMs+t*(e.endMs-e.startMs);function Mr(e,t,n,r){let i=Math.max(250,r),a=kr(n,250,i),o=kr(e-t*a,0,i-a);return{startMs:o,endMs:o+a}}function Nr(e,t,n,r){return Mr(jr(e,r),r,(e.endMs-e.startMs)/n,t)}function Pr(e,t,n){let r=e.endMs-e.startMs;return Mr(e.startMs+n,0,r,t)}var Fr=(e,t,n,r)=>Mr(jr(e,r),r,n,t);function Ir(e,t){let n=Math.max(250,e);return n*(250/n)**kr(t,0,1)}function Lr(e,t){let n=Math.max(250,e);if(n<=250)return 0;let r=kr(t,250,n);return Math.log(r/n)/Math.log(250/n)}function Rr(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 zr(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=yr(navigator.userAgent);e.setAttribute(`aria-keyshortcuts`,n.map(e=>Rr(e,r)).join(`+`))}function Br(e){delete e.dataset.tip,delete e.dataset.tipKeys,e.removeAttribute(`aria-keyshortcuts`)}var Vr=Symbol.for(`demoman.tooltip`);function Hr(e=document){let t=e,n=t[Vr];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[Vr]={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=yr(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=mr(n,r),a=e.createElement(`kbd`);a.className=`keycap`,a.textContent=i,gr(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 Ur(){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 Wr(){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 Gr(){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 Kr(){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 qr(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 take'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 your recording from its Recordings card, 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 Jr(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(g.maxScale),i.step=`0.05`,i.value=String(e.scale),i.setAttribute(`data-zoom-scale`,e.id),i.setAttribute(`aria-label`,`Zoom level`),je(i),i.addEventListener(`input`,()=>je(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?et(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),zr(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 Yr(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 take (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),zr(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 Xr(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=qr(o,t,n):s?l=Jr(s,t,n):c?l=Yr(c,t,n):(console.error(`[demoman] editor: the rail is on Selection with nothing selected`),l=Ur()):l=i===`background`?Wr():i===`cursor`?Kr():i===`shortcuts`?Gr():Ur();let u=C(`button`,`btn btn-icon inspector-close`);u.type=`button`,u.setAttribute(`data-inspector-close`,``),u.setAttribute(`aria-label`,`Close panel`),zr(u,`Close`,[`Esc`]),u.append(S(`close`)),u.addEventListener(`click`,()=>n.onClose()),a.append(u,l),e.replaceChildren(a)}var Zr=[{entry:`background`,label:`Background`,glyph:`image`},{entry:`cursor`,label:`Cursor`,glyph:`mousePointer2`},{entry:`selection`,label:`Selection`,glyph:`mousePointerClick`}],Qr=`Select a step, zoom or mask on the timeline`;function $r(e,t,n){let r=Zr.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?Qr:r,a.append(S(i)),a.addEventListener(`click`,()=>n.onPick(e)),a});e.replaceChildren(...r)}function ei(e,t,n){e.querySelector(`svg[data-icon]`)===null&&e.replaceChildren(S(`download`),C(`span`,void 0,`Export`)),e.setAttribute(`aria-pressed`,String(t.panelOpen&&t.rail===`export`)),e.onclick=()=>n.onPick(`export`)}function ti(e,t,n){e.setAttribute(`aria-pressed`,String(t.panelOpen&&t.rail===`shortcuts`)),e.onclick=()=>n.onPick(`shortcuts`)}function ni(e,t,n){switch(e.phase){case`idle`:return Ce[t];case`queued`:return e.position===0?`Queued…`:`Queued (${e.position} ahead)`;case`encoding`:return e.total>0?`Exporting · ${Math.floor(e.done*100/e.total)}%`:`Exporting…`;case`saving`:return`Saving…`}}function ri(e){let t=e/1048576;return t>=1?`${Math.round(t*10)/10} MB`:`${Math.max(1,Math.round(e/1024))} KB`}var ii=1e3,ai=new Map;function oi(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=ai.get(t);if(s!==void 0&&o-s.at>ii)ai.delete(t);else if(s!==void 0){let e=s.on===n?o-s.at:0;s.on!==n&&ai.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`),ai.set(t,{on:i.checked,at:performance.now()}),e.onChange(i.checked)}),r}function si(e,t,n){let r=document.createElement(`label`);r.className=`switch-row`;let i=document.createElement(`span`);i.className=`switch-text`;let a=document.createElement(`strong`);if(a.textContent=e,i.append(a),t!==null){let e=document.createElement(`span`);e.className=`hint`,e.textContent=t,i.append(e)}return r.append(i,n),r}function ci(e,t){let n=t.hoverReport===null?null:Cn(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`);fe(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 li(e,t){if(t.hasFrames){e.replaceChildren();return}let n=C(`div`,`banner`),r=C(`span`);r.append(ui(t.route)),n.append(r),e.replaceChildren(n)}function ui(e){let t=document.createDocumentFragment();return t.append(`This take has no frames — `,di(e,it(e.authored))),t}function di(e,t){if(e.rerun.kind===`line`){let t=C(`span`);return fe(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 fi(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 take 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(di(t.runsRoute,_t(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 take 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.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 demo 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 pi(e,t,n){xe(e,t,n)}var mi={light:`Light`,dark:`Dark`,touch:`Touch`},hi={light:1/16,dark:1/16,touch:0};function gi(e,t,n){let{height:r,hotspot:a,ink:o}=i[e],s=r*t,c={x:(o.min.x+o.max.x)/2,y:(o.min.y+o.max.y)/2};return{x:n/2-(c.x-a.x-hi[e])*s,y:n/2-(c.y-a.y)*s}}var _i=.6;function vi(e,t,n){return Math.min(Math.min(2,Math.max(.5,t))*_i,n/i[e].height)}function yi(e,t){let n=C(`canvas`);n.width=44,n.height=44;let r=n.getContext(`2d`);if(!r)return console.error(`the cursor panel could not paint its "${e}" preview: no 2D context`),n;let i=vi(e,t,44);return p(r,gi(e,i,44),i,d,e),n}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));je(l),l.addEventListener(`input`,()=>{je(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 xi=e=>`${Math.round(e*100)}%`,Si=e=>`${e.toFixed(2)}x`;function Ci(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,xi,{preview:e=>i.onMotionPreview({[r]:e}),commit:e=>i.onMotion({[r]:e}),end:()=>i.onMotionPreviewEnd()},!1)}function Ti(e,t,n,r,i,a){return si(t,null,oi({key:r,checked:n,disabled:a,attrs:{[e]:``},onChange:e=>i.onCursor({[r]:e})}))}function Ei(e,t,n,r,i=!1){let a=C(`div`),o=t.hidden;a.append(Ti(`data-cursor-hidden`,`Hide cursor`,t.hidden,`hidden`,r,!1));let s=Ci(`data-cursor-scale`,`Size`,t.scale,.5,2,Si,`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`,mi[e]),n.title=mi[e],n.append(yi(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,Ci(`data-cursor-blur`,`Motion blur`,t.motionBlur,0,1,xi,`motionBlur`,r,o),Ci(`data-cursor-tilt`,`Tilt`,t.tilt??oe.tilt,0,1,xi,`tilt`,r,o),Ci(`data-cursor-bounce`,`Click bounce`,t.clickBounce??oe.clickBounce,0,2,Si,`clickBounce`,r,o),Ti(`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),si(`Follow cursor`,null,oi({key:`motion-follow`,checked:n.follow,attrs:{"data-motion-follow":``},onChange:e=>r.onMotion({follow:e})}))),e.replaceChildren(a)}function Di(){let e=C(`progress`,`export-progress`);return e.setAttribute(`data-export-progress`,``),e.setAttribute(`aria-label`,`Export progress`),e}function Oi(e,t){return e.phase!==`idle`||t.kind===`noFrames`}function ki(e,t,n,r){let i=e.querySelector(`[data-export-start]`);if(i===null)return!1;i.textContent=ni(t,n,r),i.disabled=Oi(t,r);let a=e.querySelector(`[data-export-progress]`);if(t.phase!==`encoding`||t.total===0)return a?.remove(),!0;let o=a??Di();return o.max=t.total,o.value=t.done,a===null&&i.closest(`.control-actions`)?.after(o),!0}function Ai(e,t,n){let r=C(`div`),i=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 a=C(`p`,`export-summary`,Te(t.fileType,t.durationMs));a.setAttribute(`data-export-summary`,``);let o=C(`p`,`muted`,Me(t.aspect));o.setAttribute(`data-aspect-note`,``),r.append(a,o);let s=C(`p`,`muted`,Ae(t.recording,t.target));s.setAttribute(`data-size-readout`,``),r.append(s);let c=C(`div`,`control-row`);c.append(C(`span`,`control-label`,`File type`));let l=C(`div`,`segmented`);l.setAttribute(`role`,`radiogroup`),l.setAttribute(`aria-label`,`File type`),l.setAttribute(`data-file-types`,``);for(let e of[`mp4`,`gif`,`stills`]){let r=C(`button`,`segment`,Oe[e]);r.type=`button`,r.setAttribute(`role`,`radio`),r.setAttribute(`data-file-type`,e),r.setAttribute(`aria-checked`,String(e===t.fileType)),r.disabled=i,r.addEventListener(`click`,()=>n.onFileType(e)),l.append(r)}if(c.append(l),r.append(c),t.quality!=null&&t.fileType===`mp4`){let e=C(`div`,`control-row`);e.append(C(`span`,`control-label`,`Quality`));let a=C(`div`,`segmented`);a.setAttribute(`role`,`radiogroup`),a.setAttribute(`aria-label`,`Quality`),a.setAttribute(`data-export-qualities`,``);for(let e of ge){let r=C(`button`,`segment`,ve[e]);r.type=`button`,r.setAttribute(`role`,`radio`),r.setAttribute(`data-export-quality`,e),r.setAttribute(`aria-checked`,String(e===t.quality)),r.disabled=i,r.addEventListener(`click`,()=>n.onQuality(e)),a.append(r)}e.append(a),r.append(e)}let u=C(`button`,`btn btn-primary export-start`,ni(t.run,t.fileType,t.readiness));u.type=`button`,u.setAttribute(`data-export-start`,``),u.setAttribute(`data-readiness`,t.readiness.kind),u.disabled=Oi(t.run,t.readiness),u.addEventListener(`click`,n.onExport);let d=C(`div`,`control-actions`);if(d.append(u),t.readiness.kind===`noFrames`){let e=C(`p`,`muted`);e.setAttribute(`data-export-no-frames`,``),e.append(ui(t.runsRoute)),r.append(d,e)}else r.append(d);if(t.run.phase===`encoding`&&t.run.total>0){let e=Di();e.max=t.run.total,e.value=t.run.done,r.append(e)}if(t.save!==null&&r.append(Vi(t.save,n)),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`&&Pi(r,n.output,t)}e.replaceChildren(r)}function ji(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`){zi(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(Li(a.name,[s?Ii(a.ref):null,Ni(a.ref,Mi(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(Ri(a.ref,[ri(a.byteLength),Fi(a.renderedAt)],null)),c&&Mi(a)>0){let e=C(`div`,`output-warnings`);e.setAttribute(`data-output-warnings-body`,a.ref),Pi(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 Mi(e){return[e.detailViolations.length>0,e.logoWarning!==void 0,(e.unavailableSpans??[]).length>0,(e.unplacedStills??[]).length>0].filter(Boolean).length}function Ni(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 Pi(e,t,n){if(t.detailViolations.length>0){let{heading:r,lines:i}=ht(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 recording 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===dt),o=C(`strong`);fe(o,a?`Motion was reclaimed to free space and shown as a still. ${bt(n.runsRoute.authored,yt(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 Fi(e,t=new Date){let n=new Date(e);return Number.isNaN(n.getTime())?e:Re(n,n.getFullYear()!==t.getFullYear())}function Ii(e){let t=C(`span`,`chip`,`Outdated`);return t.setAttribute(`data-stale-export`,e),t.title=`Made before your last edit`,t}function Li(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 Ri(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 zi(e,t,n,r){let i=C(`div`,`beat`),a=n.warningsOpen.has(t.key);if(i.append(Li(t.name,[t.sceneDigest===n.currentDigest?null:Ii(t.key),Ni(t.key,t.caveats.length,a,r)])),t.exists){let e=C(`button`,`btn btn-quiet`,`Show in Finder`);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(Ri(t.key,[ri(t.byteLength),Fi(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,Bi(e)));e.append(n)}}function Bi(e){let t=e.charAt(0).toUpperCase()+e.slice(1);return/[.!?]$/.test(t)?t:`${t}.`}function Vi(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]} · ${ri(e.byteLength)}`:`Saved ${e.names.length} files · ${ri(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`?`Show in Finder`:`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 Hi(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(S(e===-1?`rewind`:`fastForward`)),n}function Ui(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(S(`skipBack`)),o=C(`button`,`btn btn-icon transport-button`),o.type=`button`,o.setAttribute(`data-transport-repeat`,``),o.append(S(`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,Hi(-1,`Rewind`),r,Hi(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?zr(e,o,[r===-1?`J`:`L`]):(Br(e),e.title=o)}s.onclick=()=>n.onSkipToStart(),s.disabled=!t.enabled;let l=`Jump to start`;s.setAttribute(`aria-label`,l),t.enabled?zr(s,l,[`Mod`,`Left`]):(Br(s),s.title=y(`This demo has no frames yet, so there is nothing to play. ${bt(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(S(f)),r.toggleAttribute(`data-playing`,t.playing),r.toggleAttribute(`data-active`,t.playing&&t.rate===1),r.disabled=!t.enabled,t.enabled?zr(r,d,[`Space`]):(Br(r),r.title=y(`This demo has no frames yet, so there is nothing to play. ${bt(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 Wi(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 video takes the recording'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(S(`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`:y(`This demo has no frames yet, so there is nothing to zoom into. ${bt(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(S(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 Gi={undo:[`Mod`,`Z`],redo:[`Shift`,`Mod`,`Z`],"shortcuts-open":[`?`]};function Ki(e=document){for(let[t,n,r]of[[`back`,`chevronLeft`,`Back to your demos`],[`undo`,`undo`,`Undo`],[`redo`,`redo`,`Redo`],[`delete`,`trash`,`Delete this demo`],[`shortcuts-open`,`circleQuestionMark`,`Keyboard shortcuts`]]){let i=e.querySelector(`#${t}`);if(i===null)continue;i.setAttribute(`aria-label`,r);let a=Gi[t];a===void 0?i.title===``&&(i.title=r):zr(i,r,a),i.querySelector(`svg`)===null&&(i.textContent=``,i.append(S(n)))}}var qi=`#failure > .notice:not([data-capture-note])`;function Ji(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(qi)===null?`warn`:`error`;e.setAttribute(`data-level`,r);let i=`${n} ${n===1?`note`:`notes`} on this take${r===`error`?`, with an error`:``}`;e.setAttribute(`aria-label`,i),e.title=i,e.querySelector(`svg`)===null&&e.append(S(`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 Yi(e,t){let n=[...e.querySelectorAll(qi)].map(e=>e.textContent??``).join(`
1
+ import{$ as e,B as t,F as n,G as r,H as i,I as a,J as o,K as s,P as c,Q as l,T as u,U as d,V as f,W as p,X as m,Y as h,Z as g,c as _,ct as v,d as y,et as ee,f as b,ft as x,h as te,i as ne,l as re,lt as ie,nt as ae,o as S,ot as oe,p as se,pt as ce,q as le,t as ue,tt as de,u as fe,ut as pe,v as me,y as he}from"./confirm-dialog-Bcrw3f1a.js";import{C as ge,E as _e,S as ve,T as ye,_ as be,a as xe,b as Se,c as Ce,d as we,f as Te,g as Ee,h as De,l as Oe,m as ke,o as C,p as Ae,s as je,u as Me,v as Ne,w as Pe,x as Fe,y as Ie}from"./view-SxAupNyx.js";import{c as Le,f as Re,h as ze,l as Be,m as Ve}from"./state-tew-ACWl.js";function He(e,t){let{bundle:n,scene:r}=o(t,e),i=new Map(r.anchors.map(e=>[e.id,e])),a=new Map((n.markers??[]).map(e=>[e.actionId,e.sourceTimeMs])),s=new Map;for(let e of r.anchors)e.fingerprint.boundingRect&&s.set(e.id,e.fingerprint.boundingRect);let c=new Map;for(let e of n.anchorRects??[])c.set(e.actionId,e.rect);let l=(e,t)=>c.get(t)??s.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:l(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:c,height:u}=n.viewport;return s.x<0||s.y<0||s.x+s.width>c||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 Ue=64;function We(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}function Ge(e,t){let n=0;for(let r=0;r<e.length;r++)n+=Math.abs((e[r]??0)-(t[r]??0));return n/e.length}async function Ke(e,t,n,r){let i=[];for(let a of He(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 c=Math.max(1,Math.min(Ue,Math.round(a.rect.width))),l=Math.max(1,Math.min(Ue,Math.round(a.rect.height))),u;try{u=Ge(We(e,a.rect,t.viewport,c,l),We(o,a.rect,t.viewport,c,l))}catch{i.push({actionId:a.actionId,kind:`unknown`,reason:`decodeFailed`});continue}i.push({actionId:a.actionId,kind:u>r?`moved`:`still`})}return i}function qe(t){return g.neutral.zoomHoldMs+e(t).zoomOutMs}qe(ie.smoothness);var Je=Math.abs(g.leadInMs)+g.neutral.minPlateauMs+400;function Ye(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`tooClose`:return`${t}: too close to the previous zoom (${n}, minimum ${Je}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 ${Xe}x).`;case`textTooWide`:return`${t}: target too wide to zoom without cutting text (would be ${e.scale}x, floor ${Xe}x).`}}g.fitMarginPx;var Xe=1.2,Ze=`__demomanClickProbe`;`${Ze}${JSON.stringify(`__demomanClickSeen`)}`,`${Ze}`,`${Ze}`;var Qe={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 is no longer on the page — re-record that step, or remap its anchor`,ambiguousAnchor:`several elements matched this step, so replay stopped rather than risk clicking the wrong one — that target needs identifying more precisely`,anchorNotRendered:`an element had not been rendered yet — the page probably just needs scrolling further, and the take itself is likely fine`,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 anchor, so re-recording that 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; re-record that step`,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:`the page never reached a state the take was waiting for`,occlusionTimeout:`the render window stayed covered, so the frames would not have been usable`,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 take, so re-recording 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 $e(e){return e in Qe?Qe[e]:e}function et(e){if(!e)return`(navigation)`;let t=e.fingerprint;return t.accessibleName??t.textContent??t.stableId??t.dataKey??e.id}function tt(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:et(e.anchors.find(e=>e.id===n.anchorId))}:null}function nt(e,t){return tt(e,t)}function rt(e){return e.meta.capture.mode===`authored`}function it(e){return e?`run its script again in Runs`:`re-shoot it in Runs`}function at(e){let{toolchain:t,name:n,...r}=e.meta,{canvas:i,...a}=e;return st(ot({...a,meta:r})).toString(16)}function ot(e){if(typeof e!=`object`||!e)return JSON.stringify(e)??`null`;if(Array.isArray(e))return`[${e.map(ot).join(`,`)}]`;let t=e;return`{${Object.keys(t).filter(e=>t[e]!==void 0).sort().map(e=>`${JSON.stringify(e)}:${ot(t[e])}`).join(`,`)}}`}function st(e){let t=3735928559,n=1103547991;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);t=Math.imul(t^i,2654435761),n=Math.imul(n^i,1597334677)}return t=Math.imul(t^t>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),4294967296*(2097151&n)+(t>>>0)}var ct={run:{phase:`idle`},save:null,error:null},lt=(e,t)=>e===null?t:`${e}; ${t}`;function ut(e,t){let n=e.run.phase===`encoding`||e.run.phase===`queued`;switch(t.kind){case`queued`:return n?{flow:{...e,run:{phase:`queued`,position:t.position}},effect:`render`}:{flow:e,effect:`none`};case`rendering`:return n?{flow:{...e,run:{phase:`encoding`,done:t.done,total:t.total}},effect:`progress`}:{flow:e,effect:`none`};case`fileFailed`:return{flow:{...e,error:lt(e.error,t.line)},effect:`none`};case`saving`:return{flow:{...e,run:{phase:`saving`}},effect:`render`};case`saved`:return{flow:{...e,run:{phase:`idle`},save:t.save.kind===`saved`&&t.summary!==null?{...t.save,summary:t.summary}:t.save},effect:`render`};case`failed`:return{flow:{...e,run:{phase:`idle`},error:t.detail===null?e.error:lt(e.error,t.detail)},effect:`render`};case`outputsChanged`:return{flow:e,effect:`relist`}}}var dt=`motion reclaimed to free space`;function ft(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]=mt(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 pt(e,t=2){return String(Number(e.toFixed(t)))}function mt(e,t){for(let n=2;n<4;n++)if(pt(e,n)!==pt(t,n))return[pt(e,n),pt(t,n)];return[pt(e,4),pt(t,4)]}function ht(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 recording 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=>ft(e,t))}}function gt(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}}function _t(e){return e?`Run its script again in Runs`:`Re-shoot this take in Runs`}function vt(e){let t=it(e);return t.charAt(0).toUpperCase()+t.slice(1)}function yt(e){return e.rerun.kind===`line`?e.rerun.text:null}function bt(e,t,n){return t??`${vt(e)} ${n}.`}var w=1,T=e=>({kind:`refusal`,reason:e});function xt(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 St(e){return new Map(e.markers.map(e=>[e.actionId,e.sourceTimeMs]))}function Ct(e,t,n){return wt(e,de(t,n))}function wt(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 Tt(e,t,n){let r=St(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=xt(t,e=>c(e.start,-1/0)),u=xt(t,e=>-c(e.end,1/0));if(l===void 0||u===void 0)continue;let d=ee(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:ee(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=ee(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 Et(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 take's start or end splits nothing.`);let i=Ct(t,n,r);if(i===null)return T(`These frames name no step, so there is nothing to split by.`);let a=St(t).get(i.actionId)??0,o=ee(n,a+i.sourceOffsetMs),{pieces:s}=Tt(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 Dt=(e,t)=>e===null||t===null?e===t:e.actionId===t.actionId&&e.sourceOffsetMs===t.sourceOffsetMs;function Ot(e,t,n){let r=e.find(e=>Dt(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 kt(e,t,n,r,i,a){let o=n.find(e=>Dt(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=Ct(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=wt(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 At=1e3;function jt(e,t){return`Motion reclaimed to free space. ${bt(e,t,`to restore`)}`}var Mt=new Set([`Motion reclaimed to free space. Replay to restore.`,`Motion reclaimed to free space. Rebuild to restore.`]);function Nt(e,t,n,r){return e===`motionReclaimed`?Mt.has(t)||t===`Motion reclaimed to free space. Re-shoot it in Runs to restore.`?jt(n,r):t:`${e}: ${t}`}var Pt=(e,t)=>e.hasBundle?t.outputMs??t.captureMs:t.captureMs;function Ft(e){return e.hasBundle&&e.outputDurationMs!==null?e.outputDurationMs:(e.beats[e.beats.length-1]?.captureMs??0)+At}var It=e=>({actionId:e.actionId,offsetMs:e.sourceOffsetMs});function Lt(e,t){let n=e.beats.find(e=>e.actionId===t.actionId);return(n?Pt(e,n):0)+t.offsetMs}function Rt(t){let{scene:n,view:r,bundle:i,resolved:a}=t,o=rt(n),s=t.rerunLine??null,c=e=>bt(o,s,e),l=Ft(r),u=[],d=new Set(t.hoverReport?.removable??[]),f=new Map(r.beats.map(e=>[e.actionId,Pt(r,e)])),p=new Map(r.beats.map(e=>[e.actionId,e.timing])),m=e=>a===null?`estimated`:e?p.get(e.actionId)??`estimated`:`rendered`,h=r.beats.map(e=>({actionId:e.actionId,atMs:f.get(e.actionId)??0,verb:e.verb,label:e.label,timing:e.timing,flag:d.has(e.actionId)?`unchangedHover`:null,canZoom:e.canZoom,cut:e.cut})),g=n.edits.trim,_=a?{headMs:a.range.startMs,headTiming:a.trimUnplaced.includes(`head`)?`estimated`:`rendered`,tailMs:a.range.endMs,tailTiming:a.trimUnplaced.includes(`tail`)?`estimated`:`rendered`,headMarker:g?.head??null,tailMarker:g?.tail??null}:{headMs:g?.head?Math.max(0,Lt(r,g.head)):0,headTiming:g?.head?`estimated`:`rendered`,tailMs:g?.tail?Math.min(l,Lt(r,g.tail)):l,tailTiming:g?.tail?`estimated`:`rendered`,headMarker:g?.head??null,tailMarker:g?.tail??null};for(let e of a?.trimUnplaced??[])u.push(`The trim's ${e} is placed from the take's own timestamp: the last render carried no marker for its step. ${c(`to give it measured timing`)}`);for(let e of a?.timeline.unplacedCuts??[])u.push(`A removed piece removed no frames: ${e.reason}.`);let v=new Set((a?.clampedRanges??[]).filter(e=>e.kind===`zoom`).map(e=>e.id));for(let e of a?.clampedRanges??[])u.push(e.note);let y=new Map((a?.cameraSegments??[]).map(e=>[e.id,e])),{smoothness:b}=n.motion??ie,x=qe(b),{zoomInMs:te}=e(b),ne=new Set,re=n.camera.flatMap(e=>{let t=e.scale??1;if(t<=1)return[];let n=y.get(e.id);n||ne.add(e.id);let i=n?n.startMs:Math.max(0,Lt(r,e.marker)),a=n?n.endMs:Math.min(l,e.end?Lt(r,e.end):i+x),o=e.point?{kind:`point`,x:e.point.x,y:e.point.y}:{kind:`element`,anchorId:e.anchorId??``};return n?.endUnplaced&&u.push(`The end of zoom "${e.id}" is placed from the take's own timestamp: the last render carried no marker for its step. ${c(`to give it measured timing`)}`),[{id:e.id,actionId:e.marker.actionId,departMs:n?.departMs??i,startMs:i,endMs:a,drawnEndMs:a,endAuthored:e.end!==void 0,scale:t,target:o,aimFallback:e.note??null,timing:n?n.endUnplaced?`estimated`:m(e.marker):`estimated`,clamped:v.has(e.id),marker:e.marker,endMarker:e.end??null}]}),ae=re.map(e=>{if(!ne.has(e.id))return e;let t=Math.min(...re.map(e=>e.startMs).filter(t=>t>e.startMs));return e.endMs>t?{...e,endMs:t}:e}),S=ae.map(e=>ne.has(e.id)?{...e,departMs:zt(ae,e.startMs,te)}:e),oe=S.map(e=>({...e,drawnEndMs:Bt(S,e.startMs,e.endMs)})),se=new Set(n.camera.map(e=>e.marker.actionId));for(let e of n.zoomsSkipped??[])se.has(e.actionId)||`afterActionId`in e&&!se.has(e.afterActionId)||u.push(Ye(e));let ce=new Map((a?.cosmetics??[]).map(e=>[e.id,e])),le=n.edits.masks.map(e=>{let t=e.start===void 0||e.end===void 0,n=ce.get(e.id),i=n?.range??null;for(let t of n?.unplaced??[])u.push(`The ${t} of mask "${e.id}" is placed from the take'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. ${c(`to give it measured timing`)}`);let o=t?0:i?i.startMs:e.start?Math.max(0,Lt(r,It(e.start))):0,s=t?l:i?i.endMs:e.end?Math.min(l,Lt(r,It(e.end))):l;return{id:e.id,startMs:o,endMs:s,rect:e.rect,wholeTake:t,timing:t||a&&i&&m(e.start)===`rendered`&&m(e.end)===`rendered`?`rendered`:`estimated`,startMarker:e.start??null,endMarker:e.end??null}}),ue=e=>a?ee(a.timeline,e):e,de=(i?.degradations??[]).map(e=>({startMs:ue(e.startMs),endMs:ue(e.endMs)}));for(let e of i?.degradations??[])u.push(Nt(e.kind,e.note,o,s));let fe=a?.timeline.unplacedPaces??0;if(fe>0){let e=fe===1?`pause`:`pauses`;u.push(`pacingUnplaced: ${fe} recorded ${e} could not be placed. The last render carried no marker for the steps they sit between, so this video is shorter than the take by however long those ${e} were. ${c(`to restore them`)}`)}let pe=a?.timeline.nonMonotonicPaces??0;if(pe>0){let e=pe===1?`pair`:`pairs`;u.push(`pacingBackwards: ${pe} step ${e} in this take carry timestamps that run backwards, so the take's order is not its time order. A re-shoot counts the pause across ${pe===1?`it`:`them`} twice and comes out longer than the take. Re-record to straighten the order; the frames you already have are unaffected.`)}let{pieces:me,joins:he,unplacedSplits:ge}=i!==null&&a!==null?Tt(n,i,a.timeline):{pieces:[],joins:[],unplacedSplits:[]};for(let e of ge)u.push(`A split is not drawn: the last render carried no marker for its step. ${c(`to place it`)}`);return{clip:{durationMs:l,trim:_,ticks:h,degraded:de,pieces:me,joins:he},zooms:oe,masks:le,durationMs:l,timeSource:r.hasBundle?`rendered`:`captured`,authored:o,rerunLine:s,hoverCheck:{failed:t.hoverReport?.failed??!1,unchecked:t.hoverReport?.unchecked??0},notices:u,zoomDefaultMs:x,zoomInMs:te}}function zt(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 Bt(e,t,n){return Math.min(n,...e.filter(e=>e.startMs>t).map(e=>e.departMs))}function Vt(e,t,n){let r=e.clip.ticks,i=r[0];if(!i)throw Error(`a take 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 Ht(e){let{resolved:t,outputTimeMs:n,presentation:r,target:i,viewport:o}=e;return l(m(t,n),a(r.frameRect,o),r.frameRect,o,i)}var Ut=(e,t,n)=>Math.min(n,Math.max(t,e));function Wt(e,t){let n=e.width/2,r=e.height/2;return{x:Ut(t.x-n/2,0,e.width-n),y:Ut(t.y-r/2,0,e.height-r),width:n,height:r}}function Gt(e){let{rect:t,resolved:n,target:r,presentation:i,outputTimeMs:a}=e,o=n.plan.viewport,s=Ht({resolved:n,outputTimeMs:a,presentation:i,target:r,viewport:o});return c(t,s,i.frameRect,o)}function Kt(e){let{rect:t,resolved:n,target:r,presentation:i,outputTimeMs:a}=e,o=n.plan.viewport,s=Ht({resolved:n,outputTimeMs:a,presentation:i,target:r,viewport:o}),c=f(t,s,i.frameRect,o),l=Ut(c.x,0,o.width),u=Ut(c.y,0,o.height),d=Ut(c.x+c.width,0,o.width),p=Ut(c.y+c.height,0,o.height);return{x:l,y:u,width:d-l,height:p-u}}function qt(e){let{zoom:t,resolved:n,viewport:r,presentation:i,target:a}=e,o=Ht({resolved:n,outputTimeMs:(t.startMs+t.endMs)/2,presentation:i,target:a,viewport:r});return f({x:0,y:0,width:a.width,height:a.height},o,i.frameRect,r)}var Jt=2e3,Yt=e=>e!==null&&e.kind===`refusal`,E=e=>({kind:`refusal`,reason:e});function Xt(e,t){if(e.resolved===null||e.bundle===null)return{reason:`nothing has rendered yet`};if(e.bundle.cursorSamples.length===0)return{reason:`this take has no recorded pointer`};let n=de(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=le(e.resolved.cursor,n);return r?{point:r}:{reason:`the pointer was not observed here`}}var Zt=(e,t)=>e.zooms.find(e=>e.id===t),Qt=(e,t)=>e.masks.find(e=>e.id===t);function $t(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=en(a,i,n,r);if(e)return{zoom:a,why:e}}}function en(e,t,n,r){let i=Math.abs(n-e.startMs);if(i<Je&&(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 tn({zoom:e,why:t}){switch(t){case`start`:return E(`That would start it within ${Je}ms of the zoom "${e.id}" at ${nn(e.startMs)}; the camera needs ${Je}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 ${nn(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 ${nn(e.endMs)}; drag that zoom's end earlier first.`)}}var nn=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 rn(e){let{leadInMs:t}=g;return{earliestMs:e+t,latestMs:e}}function an(e,t){let{leadInMs:n}=g,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}=rn(t);return e.zooms.find(e=>en(e,void 0,n,null)!==void 0||en(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+Je,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-Je;if(rn(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 ${nn(o.startMs)}, and there is no slot either side of it. Drag that zoom to make space, or remove one.`)}function on(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+Jt,e.durationMs)}}function sn(e,t,n,r){let i=Vt(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(de(t.resolved.timeline,n)-a.sourceTimeMs)}}var cn=(e,t)=>e.actionId===t.actionId&&t.sourceOffsetMs<=e.sourceOffsetMs;function ln(e,t){return t!==null&&e.actionId===t.actionId&&t.offsetMs<=e.offsetMs}var un=e=>E(`That would leave the ${e} no length; drag its end further.`),dn=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 fn(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 take has no steps to attach an edit to.`);switch(n.kind){case`pieceEdge`:return kt(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=Vt(e,n.toMs,n.snapMs);return ln(r,t.tailMarker)?dn(`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=Vt(e,n.toMs,n.snapMs);return t.headMarker&&ln(t.headMarker,r)?dn(`tail`):{kind:`setTrim`,tail:r}}case`addZoom`:{let i=an(e,n.atMs);if(Yt(i))return i;let{atMs:a,movedPast:o}=i,s=Vt(e,a,o?0:n.snapMs),c=o?`Placed ${o.side} the zoom at ${nn(o.zoom.startMs)}: there was no room at ${nn(n.atMs)}.`:null,l=g.defaultZoomScale,u=Xt(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 take 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=Zt(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 take does.`);if(a>i)return E(`A zoom cannot end after the take does.`);let o=$t(e,t.id,r,t.endAuthored?a:null);if(o)return tn(o);let s=Vt(e,r,n.snapMs),c=t.endAuthored?Vt(e,a,n.snapMs):null;return ln(s,c)?un(`zoom`):{kind:`setZoomRange`,id:t.id,start:s,end:c}}case`zoomEdge`:{let t=Zt(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 ${nn(i)}, after its end at ${nn(t.endMs)}. Drag the end later first.`);let a=$t(e,t.id,i,null);if(a)return tn(a);let o=Vt(e,r,n.snapMs),s={...o,offsetMs:o.offsetMs+e.zoomInMs},c=t.endMarker;return ln(s,c)?un(`zoom`):{kind:`setZoomRange`,id:t.id,start:s,end:c}}if(n.toMs>i)return E(`A zoom cannot end after the take 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=$t(e,t.id,t.startMs,n.toMs);if(r)return tn(r);let a=t.marker,o=Vt(e,n.toMs,n.snapMs);return ln(a,o)?un(`zoom`):{kind:`setZoomRange`,id:t.id,start:a,end:o}}case`addMask`:{let t=on(e,n.atMs);if(Yt(t))return t;let{endMs:i}=t,a=Xt(r,n.atMs),o=`point`in a?a.point:{x:r.viewport.width/2,y:r.viewport.height/2},s=Wt(r.viewport,o),c=sn(e,r,n.atMs,n.snapMs),l=sn(e,r,i,n.snapMs);if(cn(c,l)){let t=fn(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=Qt(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 take, 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 take does.`);if(o>i)return E(`A mask cannot end after the take does.`);let s=sn(e,r,a,n.snapMs),c=sn(e,r,o,n.snapMs);return cn(s,c)?un(`mask`):{kind:`setMaskRange`,id:t.id,start:s,end:c}}case`maskEdge`:{let t=Qt(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 take, 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 take does.`);if(n.toMs>t.endMs-100)return E(`A mask cannot start after it ends; drag its end later first.`);let i=sn(e,r,n.toMs,n.snapMs),a=t.endMarker;return cn(i,a)?un(`mask`):{kind:`setMaskRange`,id:t.id,start:i,end:a}}if(n.toMs>i)return E(`A mask cannot end after the take 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=sn(e,r,n.toMs,n.snapMs);return cn(a,o)?un(`mask`):{kind:`setMaskRange`,id:t.id,start:a,end:o}}}}function mn(e,t,n){let r=e.beats.find(e=>e.actionId===t);return r===void 0?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 hn(e){return e.actions.map(e=>e.id).join(` `)}function gn(e){return{bundle:e.bundle,actionIds:hn(e.scene)}}function _n(e,t){return e!==null&&t.bundle===e.bundle&&hn(t.scene)===e.actionIds&&t.hoverReport!==null}var vn={removable:[],checked:0,unchecked:0,failed:!0};function yn(e){return e.kind!==`unknown`||e.reason!==`notStyleSignalled`}function bn(e,t){let n=e.filter(yn).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 xn={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 Sn(e){return Object.entries(e.uncheckedBy??{}).filter(([,e])=>e>0).sort((e,t)=>t[1]-e[1]).map(([e,t])=>{let n=xn[e];return`${t} ${t===1?n.one:n.many}`}).join(`, `)}function Cn(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=Sn(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 wn(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 Tn(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 En(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 Dn(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 On(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=Dn(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 kn(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 An(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 jn(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 Mn(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 Nn(e,t){return e===null||[...new Set([...Object.keys(t),...Object.keys(e)])].some(n=>t[n]!==e[n])}function Pn(e,t){return e===null||e.smoothness!==t.smoothness||e.blur!==t.blur||e.follow!==t.follow}function Fn(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!(r.kind===i.kind&&(r.kind===`solid`?r.color===i.color:r.from===i.from&&r.to===i.to&&r.angle===i.angle))||e.cornerRadius!==t.cornerRadius||!n(e.frameRect,t.frameRect)||e.logo?.image!==t.logo?.image||e.logo?.opacity!==t.logo?.opacity||!n(e.logo?.rect,t.logo?.rect)}function In(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 Ln(){let e=new Map;return{isOpen:(t,n)=>e.get(t)??n,set:(t,n)=>{e.set(t,n)}}}var Rn={attachFailed:`Couldn't record the screen, so this take has no video`,debuggerDetached:`Recording stopped partway through`,debuggerLost:`Recording stopped and couldn't restart`,debuggerRecovered:`A stretch in the middle is missing`,workerRestarted:`The extension restarted mid-take, so this take has no video`,noKeyframes:`Nothing could be photographed, so there's no video`,screencastUnavailable:`Motion couldn't be recorded, so this take is stills`,muxFailed:`The motion couldn't be encoded, so this take is stills`,muxUnavailable:`There was nowhere to encode the motion, so this take is stills`,budgetSpent:`The take 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:`Recording was interrupted, so parts are stills`,spansDiscarded:`Some motion couldn't be encoded, so those moments are stills`,storageRefused:`This take's frames couldn't be saved — free up space and record it again`,bundleInvalid:`This take's video couldn't be put together`},zn={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`},Bn=new Set([`debuggerDetached`,`debuggerLost`,`debuggerRecovered`]),Vn=e=>Object.hasOwn(zn,e)?zn[e]:e;function Hn(e){let t=Rn[e];if(t!==void 0)return t;let n=e.indexOf(`:`);if(n>0){let t=e.slice(0,n),r=Rn[t],i=e.slice(n+1);if(r!==void 0&&i!==``)return`${r} — ${Bn.has(t)?Vn(i):i}`}return e}function Un(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`${Hn(e.reason)}${n}`}var Wn={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 Gn(e){return e===null||e.reason===null?!1:Wn[e.reason]===!0}function Kn(e,t,n){if(e===null||e.reason===null||!t.mayReplay||e.reason===`mutating`)return null;let r=$e(e.reason),i=n!==void 0&&rt(n),a=i?`The script run`:`The re-shoot`,o=i?`performed`:`reconstructed`,s=n?nt(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 ${it(i)} to try again.`:`${a} ${o} all ${e.total} steps, but: ${r}.`;let l=Gn(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 qn(e,t){let n=e.camera.find(e=>e.id===t);if(!n)throw Error(`unknown zoom "${t}"`);return n}var Jn=1,Yn=e=>Error(`1:1 is not a zoom — remove the zoom instead of authoring ${e}`);function Xn(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 Yn(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?g.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,...t.note===void 0?{}:{note:t.note}};return{...e,camera:[...e.camera,a]}}case`setZoomRange`:{let n=qn(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{...e,camera:e.camera.map(e=>e.id===n.id?a:e)}}case`setZoomScale`:{let n=qn(e,t.id);if(t.scale<=1)throw Yn(t.scale);return{...e,camera:e.camera.map(e=>e.id===n.id?{...e,scale:t.scale}:e)}}case`setZoomTarget`:{let n=qn(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}}:e)}}case`removeZoom`:return qn(e,t.id),{...e,camera:e.camera.filter(e=>e.id!==t.id)};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<Jn||t.rect.height<Jn)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:De(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 take 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 take 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 Zn(e,t,n){return pe.parse(Xn(e,t,n))}function Qn(e){return{scene:e,past:[],future:[],error:null,dirty:!1,hoverReport:null}}function $n(e,t,n){let r;try{r=Zn(e.scene,t,n)}catch(t){return{...e,error:t instanceof Error?t.message:String(t)}}return t.kind===`setBranding`&&be(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 er(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 tr(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 nr(e){return{...e,dirty:!1}}var rr={mayReplay:!0};function ir(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 ar(e,t){return e.meta===void 0||e.flags===void 0?!1:ir(e)===ir(t)}function or(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(ir(e)),JSON.parse(ir(t)),`scene`)}function sr(e,t){let{renderMode:n,...r}=e.meta;return{...e,meta:t.meta.renderMode===void 0?r:{...r,renderMode:t.meta.renderMode}}}function cr(e,t){return{...sr(e,t),flags:{...e.flags,hoverSensitive:t.flags.hoverSensitive}}}function lr(e){let t=Qn({}),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:Kn(i,rr,t.scene),replayRecoverable:Gn(i),captureSentence:a===null||n!==null&&n.source!==`capture`?null:Un(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=sr(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=ar(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 ${or(t.scene,o)}`),t=c?{...Qn(o),past:t.past.map(e=>cr(e,o)),future:t.future.map(e=>cr(e,o))}:Qn(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=$n(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=nr(t),u()})},async undo(){await c(async()=>{let e=er(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=nr(t),u()})},async redo(){await c(async()=>{let e=tr(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=nr(t),u()})},async settled(){let e;do e=s,await e;while(e!==s)},setHoverReport(e){t={...t,hoverReport:e},u()}}}var ur=1.2;function dr(e,t){let n=e.key,r=n.toLowerCase();if(e.metaKey||e.ctrlKey)return r===`z`?e.shiftKey?t.canRedo?{kind:`redo`}:null:t.canUndo?{kind:`undo`}:null:r===`y`&&e.ctrlKey&&!e.metaKey?t.canRedo?{kind:`redo`}:null:r===`b`&&!e.shiftKey?{kind:`split`}:!e.shiftKey&&(n===`ArrowLeft`||n===`ArrowRight`)?{kind:`seekEdge`,edge:n===`ArrowLeft`?`head`:`tail`}:null;if(n===` `)return{kind:`playPause`};if(r===`j`)return{kind:`shuttle`,direction:-1};if(r===`k`)return{kind:`stop`};if(r===`l`)return{kind:`shuttle`,direction:1};if(n===`ArrowRight`||n===`ArrowLeft`){let t=e.shiftKey?500:100;return{kind:`nudge`,deltaMs:n===`ArrowRight`?t:-t}}return n===`ArrowDown`?{kind:`stepBeat`,delta:1}:n===`ArrowUp`?{kind:`stepBeat`,delta:-1}:n===`Home`?{kind:`seekEdge`,edge:`head`}:n===`End`?{kind:`seekEdge`,edge:`tail`}:r===`i`?{kind:`setTrim`,edge:`head`}:r===`o`?{kind:`setTrim`,edge:`tail`}:n===`Delete`||n===`Backspace`?t.hasSelection?{kind:`deleteSelection`}:null:n===`+`||n===`=`?t.hasTimeline?{kind:`zoomTimeline`,factor:ur}:null:n===`-`||n===`_`?t.hasTimeline?{kind:`zoomTimeline`,factor:1/ur}: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 fr={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 mr(e,t){let n=fr[e];return n===void 0?e:pr(n.label,t)}var hr=new Set([`⌘`,`⇧`,`⌫`,`←`,`→`,`↑`,`↓`]);function gr(e){return hr.has(e)}function _r(e,t){let n=fr[e];return n===void 0?e:pr(n.spoken,t)}function vr(e,t){return e.map(e=>_r(e,t)).join(` plus `)}function yr(e){return/\bMac/i.test(e)}function br(e,t){return pr(e.description,t)}var xr=[{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, zoom or mask`,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 take`,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 Sr(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 Cr=[`nw`,`n`,`ne`,`e`,`se`,`s`,`sw`,`w`],wr=3;function Tr(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 Er(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 Dr(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=Sr(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=Gt({rect:i.rect,...s});Tr(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)>wr&&(l=!0),c=Er(r,t,(n.clientX-e.clientX)/o.scale,(n.clientY-e.clientY)/o.scale),Tr(a,c,o)},d=()=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),l&&n.onMaskRect(i.id,Kt({rect:c,...s}))};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d)})};l(a,`body`);for(let e of Cr){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=Gt({rect:qt({zoom:c,resolved:i,viewport:i.plan.viewport,presentation:a,target:t.target}),...s});Tr(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)>wr&&(r=!0),u=Er(t,`body`,(n.clientX-e.clientX)/o.scale,(n.clientY-e.clientY)/o.scale),Tr(l,u,o)},a=()=>{if(window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,a),!r)return;let e=Kt({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 Or(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??g.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??[]):ae(t),l=new Map((r?.markers??[]).map(e=>[e.actionId,e.sourceTimeMs])),u=(e,t)=>{if(n===null||r===null||!ce(r)||x(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||ce(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,h)=>{let g=e.anchorId?i.get(e.anchorId):void 0,_=a.get(e.id),v=o.get(e.id),y=s.get(e.id),b=t.actions[h+1],x=l.get(e.id);return{actionId:e.id,index:h,verb:e.kind,anchorId:e.anchorId,label:et(g),text:e.kind===`type`?e.text:null,redacted:e.kind===`type`&&e.redacted,host:e.kind===`type`&&e.host===!0,strategy:g?.resolution.strategy??null,outputMs:n?ee(n.timeline,x??e.timestamp):null,timing:x===void 0?`estimated`:`rendered`,captureMs:e.timestamp,camera:_??null,canZoom:e.anchorId!==null,gap:v?{durationMs:v.durationMs}:null,canPace:b!==void 0&&u(e,b),renderedPauseMs:f(e,b),renderedPaceFreezeMs:p(e,b),renderedFreezeBeforeMs:r!==null&&!ce(r)&&x!==void 0&&n!==null&&x<n.timeline.sourceDurationMs?d(x):0,legacyHold:y?{offsetMs:y.marker.offsetMs,durationMs:y.durationMs}:null,cut:c.has(e.id),isLast:h===m}}),outputDurationMs:n?.timeline.outputDurationMs??null,hasBundle:n!==null}}var kr=(e,t,n)=>Math.min(n,Math.max(t,e)),Ar=e=>({startMs:0,endMs:Math.max(250,e)}),k=(e,t)=>(t-e.startMs)/(e.endMs-e.startMs),jr=(e,t)=>e.startMs+t*(e.endMs-e.startMs);function Mr(e,t,n,r){let i=Math.max(250,r),a=kr(n,250,i),o=kr(e-t*a,0,i-a);return{startMs:o,endMs:o+a}}function Nr(e,t,n,r){return Mr(jr(e,r),r,(e.endMs-e.startMs)/n,t)}function Pr(e,t,n){let r=e.endMs-e.startMs;return Mr(e.startMs+n,0,r,t)}var Fr=(e,t,n,r)=>Mr(jr(e,r),r,n,t);function Ir(e,t){let n=Math.max(250,e);return n*(250/n)**kr(t,0,1)}function Lr(e,t){let n=Math.max(250,e);if(n<=250)return 0;let r=kr(t,250,n);return Math.log(r/n)/Math.log(250/n)}function Rr(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 zr(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=yr(navigator.userAgent);e.setAttribute(`aria-keyshortcuts`,n.map(e=>Rr(e,r)).join(`+`))}function Br(e){delete e.dataset.tip,delete e.dataset.tipKeys,e.removeAttribute(`aria-keyshortcuts`)}var Vr=Symbol.for(`demoman.tooltip`);function Hr(e=document){let t=e,n=t[Vr];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[Vr]={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=yr(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=mr(n,r),a=e.createElement(`kbd`);a.className=`keycap`,a.textContent=i,gr(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 Ur(){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 Wr(){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 Gr(){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 Kr(){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 qr(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 take'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 your recording from its Recordings card, 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 Jr(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(g.maxScale),i.step=`0.05`,i.value=String(e.scale),i.setAttribute(`data-zoom-scale`,e.id),i.setAttribute(`aria-label`,`Zoom level`),je(i),i.addEventListener(`input`,()=>je(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?et(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),zr(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 Yr(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 take (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),zr(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 Xr(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=qr(o,t,n):s?l=Jr(s,t,n):c?l=Yr(c,t,n):(console.error(`[demoman] editor: the rail is on Selection with nothing selected`),l=Ur()):l=i===`background`?Wr():i===`cursor`?Kr():i===`shortcuts`?Gr():Ur();let u=C(`button`,`btn btn-icon inspector-close`);u.type=`button`,u.setAttribute(`data-inspector-close`,``),u.setAttribute(`aria-label`,`Close panel`),zr(u,`Close`,[`Esc`]),u.append(S(`close`)),u.addEventListener(`click`,()=>n.onClose()),a.append(u,l),e.replaceChildren(a)}var Zr=[{entry:`background`,label:`Background`,glyph:`image`},{entry:`cursor`,label:`Cursor`,glyph:`mousePointer2`},{entry:`selection`,label:`Selection`,glyph:`mousePointerClick`}],Qr=`Select a step, zoom or mask on the timeline`;function $r(e,t,n){let r=Zr.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?Qr:r,a.append(S(i)),a.addEventListener(`click`,()=>n.onPick(e)),a});e.replaceChildren(...r)}function ei(e,t,n){e.querySelector(`svg[data-icon]`)===null&&e.replaceChildren(S(`download`),C(`span`,void 0,`Export`)),e.setAttribute(`aria-pressed`,String(t.panelOpen&&t.rail===`export`)),e.onclick=()=>n.onPick(`export`)}function ti(e,t,n){e.setAttribute(`aria-pressed`,String(t.panelOpen&&t.rail===`shortcuts`)),e.onclick=()=>n.onPick(`shortcuts`)}function ni(e,t,n){switch(e.phase){case`idle`:return Ce[t];case`queued`:return e.position===0?`Queued…`:`Queued (${e.position} ahead)`;case`encoding`:return e.total>0?`Exporting · ${Math.floor(e.done*100/e.total)}%`:`Exporting…`;case`saving`:return`Saving…`}}function ri(e){let t=e/1048576;return t>=1?`${Math.round(t*10)/10} MB`:`${Math.max(1,Math.round(e/1024))} KB`}var ii=1e3,ai=new Map;function oi(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=ai.get(t);if(s!==void 0&&o-s.at>ii)ai.delete(t);else if(s!==void 0){let e=s.on===n?o-s.at:0;s.on!==n&&ai.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`),ai.set(t,{on:i.checked,at:performance.now()}),e.onChange(i.checked)}),r}function si(e,t,n){let r=document.createElement(`label`);r.className=`switch-row`;let i=document.createElement(`span`);i.className=`switch-text`;let a=document.createElement(`strong`);if(a.textContent=e,i.append(a),t!==null){let e=document.createElement(`span`);e.className=`hint`,e.textContent=t,i.append(e)}return r.append(i,n),r}function ci(e,t){let n=t.hoverReport===null?null:Cn(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`);fe(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 li(e,t){if(t.hasFrames){e.replaceChildren();return}let n=C(`div`,`banner`),r=C(`span`);r.append(ui(t.route)),n.append(r),e.replaceChildren(n)}function ui(e){let t=document.createDocumentFragment();return t.append(`This take has no frames — `,di(e,it(e.authored))),t}function di(e,t){if(e.rerun.kind===`line`){let t=C(`span`);return fe(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 fi(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 take 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(di(t.runsRoute,_t(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 take 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.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 demo 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 pi(e,t,n){xe(e,t,n)}var mi={light:`Light`,dark:`Dark`,touch:`Touch`},hi={light:1/16,dark:1/16,touch:0};function gi(e,t,n){let{height:r,hotspot:a,ink:o}=i[e],s=r*t,c={x:(o.min.x+o.max.x)/2,y:(o.min.y+o.max.y)/2};return{x:n/2-(c.x-a.x-hi[e])*s,y:n/2-(c.y-a.y)*s}}var _i=.6;function vi(e,t,n){return Math.min(Math.min(2,Math.max(.5,t))*_i,n/i[e].height)}function yi(e,t){let n=C(`canvas`);n.width=44,n.height=44;let r=n.getContext(`2d`);if(!r)return console.error(`the cursor panel could not paint its "${e}" preview: no 2D context`),n;let i=vi(e,t,44);return p(r,gi(e,i,44),i,d,e),n}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));je(l),l.addEventListener(`input`,()=>{je(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 xi=e=>`${Math.round(e*100)}%`,Si=e=>`${e.toFixed(2)}x`;function Ci(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,xi,{preview:e=>i.onMotionPreview({[r]:e}),commit:e=>i.onMotion({[r]:e}),end:()=>i.onMotionPreviewEnd()},!1)}function Ti(e,t,n,r,i,a){return si(t,null,oi({key:r,checked:n,disabled:a,attrs:{[e]:``},onChange:e=>i.onCursor({[r]:e})}))}function Ei(e,t,n,r,i=!1){let a=C(`div`),o=t.hidden;a.append(Ti(`data-cursor-hidden`,`Hide cursor`,t.hidden,`hidden`,r,!1));let s=Ci(`data-cursor-scale`,`Size`,t.scale,.5,2,Si,`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`,mi[e]),n.title=mi[e],n.append(yi(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,Ci(`data-cursor-blur`,`Motion blur`,t.motionBlur,0,1,xi,`motionBlur`,r,o),Ci(`data-cursor-tilt`,`Tilt`,t.tilt??oe.tilt,0,1,xi,`tilt`,r,o),Ci(`data-cursor-bounce`,`Click bounce`,t.clickBounce??oe.clickBounce,0,2,Si,`clickBounce`,r,o),Ti(`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),si(`Follow cursor`,null,oi({key:`motion-follow`,checked:n.follow,attrs:{"data-motion-follow":``},onChange:e=>r.onMotion({follow:e})}))),e.replaceChildren(a)}function Di(){let e=C(`progress`,`export-progress`);return e.setAttribute(`data-export-progress`,``),e.setAttribute(`aria-label`,`Export progress`),e}function Oi(e,t){return e.phase!==`idle`||t.kind===`noFrames`}function ki(e,t,n,r){let i=e.querySelector(`[data-export-start]`);if(i===null)return!1;i.textContent=ni(t,n,r),i.disabled=Oi(t,r);let a=e.querySelector(`[data-export-progress]`);if(t.phase!==`encoding`||t.total===0)return a?.remove(),!0;let o=a??Di();return o.max=t.total,o.value=t.done,a===null&&i.closest(`.control-actions`)?.after(o),!0}function Ai(e,t,n){let r=C(`div`),i=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 a=C(`p`,`export-summary`,Te(t.fileType,t.durationMs));a.setAttribute(`data-export-summary`,``);let o=C(`p`,`muted`,Me(t.aspect));o.setAttribute(`data-aspect-note`,``),r.append(a,o);let s=C(`p`,`muted`,Ae(t.recording,t.target));s.setAttribute(`data-size-readout`,``),r.append(s);let c=C(`div`,`control-row`);c.append(C(`span`,`control-label`,`File type`));let l=C(`div`,`segmented`);l.setAttribute(`role`,`radiogroup`),l.setAttribute(`aria-label`,`File type`),l.setAttribute(`data-file-types`,``);for(let e of[`mp4`,`gif`,`stills`]){let r=C(`button`,`segment`,Oe[e]);r.type=`button`,r.setAttribute(`role`,`radio`),r.setAttribute(`data-file-type`,e),r.setAttribute(`aria-checked`,String(e===t.fileType)),r.disabled=i,r.addEventListener(`click`,()=>n.onFileType(e)),l.append(r)}if(c.append(l),r.append(c),t.quality!=null&&t.fileType===`mp4`){let e=C(`div`,`control-row`);e.append(C(`span`,`control-label`,`Quality`));let a=C(`div`,`segmented`);a.setAttribute(`role`,`radiogroup`),a.setAttribute(`aria-label`,`Quality`),a.setAttribute(`data-export-qualities`,``);for(let e of ge){let r=C(`button`,`segment`,ve[e]);r.type=`button`,r.setAttribute(`role`,`radio`),r.setAttribute(`data-export-quality`,e),r.setAttribute(`aria-checked`,String(e===t.quality)),r.disabled=i,r.addEventListener(`click`,()=>n.onQuality(e)),a.append(r)}e.append(a),r.append(e)}let u=C(`button`,`btn btn-primary export-start`,ni(t.run,t.fileType,t.readiness));u.type=`button`,u.setAttribute(`data-export-start`,``),u.setAttribute(`data-readiness`,t.readiness.kind),u.disabled=Oi(t.run,t.readiness),u.addEventListener(`click`,n.onExport);let d=C(`div`,`control-actions`);if(d.append(u),t.readiness.kind===`noFrames`){let e=C(`p`,`muted`);e.setAttribute(`data-export-no-frames`,``),e.append(ui(t.runsRoute)),r.append(d,e)}else r.append(d);if(t.run.phase===`encoding`&&t.run.total>0){let e=Di();e.max=t.run.total,e.value=t.run.done,r.append(e)}if(t.save!==null&&r.append(Vi(t.save,n)),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`&&Pi(r,n.output,t)}e.replaceChildren(r)}function ji(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`){zi(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(Li(a.name,[s?Ii(a.ref):null,Ni(a.ref,Mi(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(Ri(a.ref,[ri(a.byteLength),Fi(a.renderedAt)],null)),c&&Mi(a)>0){let e=C(`div`,`output-warnings`);e.setAttribute(`data-output-warnings-body`,a.ref),Pi(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 Mi(e){return[e.detailViolations.length>0,e.logoWarning!==void 0,(e.unavailableSpans??[]).length>0,(e.unplacedStills??[]).length>0].filter(Boolean).length}function Ni(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 Pi(e,t,n){if(t.detailViolations.length>0){let{heading:r,lines:i}=ht(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 recording 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===dt),o=C(`strong`);fe(o,a?`Motion was reclaimed to free space and shown as a still. ${bt(n.runsRoute.authored,yt(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 Fi(e,t=new Date){let n=new Date(e);return Number.isNaN(n.getTime())?e:Re(n,n.getFullYear()!==t.getFullYear())}function Ii(e){let t=C(`span`,`chip`,`Outdated`);return t.setAttribute(`data-stale-export`,e),t.title=`Made before your last edit`,t}function Li(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 Ri(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 zi(e,t,n,r){let i=C(`div`,`beat`),a=n.warningsOpen.has(t.key);if(i.append(Li(t.name,[t.sceneDigest===n.currentDigest?null:Ii(t.key),Ni(t.key,t.caveats.length,a,r)])),t.exists){let e=C(`button`,`btn btn-quiet`,`Show in Finder`);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(Ri(t.key,[ri(t.byteLength),Fi(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,Bi(e)));e.append(n)}}function Bi(e){let t=e.charAt(0).toUpperCase()+e.slice(1);return/[.!?]$/.test(t)?t:`${t}.`}function Vi(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]} · ${ri(e.byteLength)}`:`Saved ${e.names.length} files · ${ri(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`?`Show in Finder`:`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 Hi(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(S(e===-1?`rewind`:`fastForward`)),n}function Ui(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(S(`skipBack`)),o=C(`button`,`btn btn-icon transport-button`),o.type=`button`,o.setAttribute(`data-transport-repeat`,``),o.append(S(`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,Hi(-1,`Rewind`),r,Hi(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?zr(e,o,[r===-1?`J`:`L`]):(Br(e),e.title=o)}s.onclick=()=>n.onSkipToStart(),s.disabled=!t.enabled;let l=`Jump to start`;s.setAttribute(`aria-label`,l),t.enabled?zr(s,l,[`Mod`,`Left`]):(Br(s),s.title=y(`This demo has no frames yet, so there is nothing to play. ${bt(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(S(f)),r.toggleAttribute(`data-playing`,t.playing),r.toggleAttribute(`data-active`,t.playing&&t.rate===1),r.disabled=!t.enabled,t.enabled?zr(r,d,[`Space`]):(Br(r),r.title=y(`This demo has no frames yet, so there is nothing to play. ${bt(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 Wi(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 video takes the recording'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(S(`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`:y(`This demo has no frames yet, so there is nothing to zoom into. ${bt(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(S(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 Gi={undo:[`Mod`,`Z`],redo:[`Shift`,`Mod`,`Z`],"shortcuts-open":[`?`]};function Ki(e=document){for(let[t,n,r]of[[`back`,`chevronLeft`,`Back to your demos`],[`undo`,`undo`,`Undo`],[`redo`,`redo`,`Redo`],[`delete`,`trash`,`Delete this demo`],[`shortcuts-open`,`circleQuestionMark`,`Keyboard shortcuts`]]){let i=e.querySelector(`#${t}`);if(i===null)continue;i.setAttribute(`aria-label`,r);let a=Gi[t];a===void 0?i.title===``&&(i.title=r):zr(i,r,a),i.querySelector(`svg`)===null&&(i.textContent=``,i.append(S(n)))}}var qi=`#failure > .notice:not([data-capture-note])`;function Ji(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(qi)===null?`warn`:`error`;e.setAttribute(`data-level`,r);let i=`${n} ${n===1?`note`:`notes`} on this take${r===`error`?`, with an error`:``}`;e.setAttribute(`aria-label`,i),e.title=i,e.querySelector(`svg`)===null&&e.append(S(`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 Yi(e,t){let n=[...e.querySelectorAll(qi)].map(e=>e.textContent??``).join(`
2
2
  `);return n!==``&&n!==t&&typeof e.showPopover==`function`&&!e.matches(`:popover-open`)&&e.showPopover(),n}function Xi(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 xr){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`,br(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`,vr(n,t.mac));for(let r of n){let n=mr(r,t.mac),i=C(`kbd`,`keycap`,n);i.setAttribute(`aria-hidden`,`true`),gr(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 Zi(e){return`${Le(e)}${Be(e)}`}function Qi(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 $i(e,t,n,r){let i=Qi(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(S(`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(S(`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 ea(e,t,n){let r=C(`div`,`info-group`);r.setAttribute(`data-info-facts`,``);let i=`${_(t.durationMs)} · ${t.steps} ${t.steps===1?`step`:`steps`}`,a=t.aspect===`auto`?`Auto`:t.aspect;r.append(Qi(`Recorded`,Fi(t.recordedAt)),Qi(`Site`,Zi(t.site)),Qi(`Length`,i),Qi(`Recording`,`${t.recording.width} × ${t.recording.height}`),Qi(`Video`,`${t.target.width} × ${t.target.height} · ${a}`));let o=C(`div`,`info-group`);if(o.setAttribute(`data-info-ids`,``),o.append($i(`Take ID`,t.takeId,`take 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`);ji(r,t.history,n),e.append(r),s.push(e)}e.replaceChildren(...s)}var ta=.006,A=e=>`${(e*100).toFixed(4)}%`;function na(e,t,n,r=ta){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 ra=(e,t)=>Math.min(1,Math.max(0,k(e,t))),ia=[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 oa(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=ia.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 ca?.observe(n),n}function sa(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 ca=typeof ResizeObserver>`u`?null:new ResizeObserver(e=>{for(let t of e){let e=t.target;e.isConnected?sa(e):ca?.unobserve(e)}});function la(e,t){let n=C(`div`,`lane`);return n.append(e,t),n}function ua(e,t,n){let r=C(`div`,`lane-label lane-head`),i=C(`span`,`lane-title`),a=C(`span`,`lane-glyph`);return a.append(S(t)),i.append(a,C(`span`,`lane-name`,e)),n&&i.append(n),r.append(i),r}function da(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 fa=3;function pa(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 ma=(e,t)=>e!==null&&t!==null&&e.kind===t.kind&&(e.kind===`tick`?e.actionId===t.actionId:e.kind===`piece`?Dt(e.start,t.start):e.id===t.id),ha=(e,t)=>e.snapping?8*t:0;function ga(e,t){let n=e.getBoundingClientRect().width;return n===0?0:(t.endMs-t.startMs)/n}function _a(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 va(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=ga(t,n.viewport);return{toMs:_a(t,n.viewport,e),deltaMs:(e-s)*r,snapMs:ha(n,r)}},u=e=>{Math.abs(e.clientX-s)>fa&&(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 ya=e=>Math.max(0,Math.min(1,e));function ba(e,t,n,r){let i=ya(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 xa(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`),va(a,n,r,({deltaMs:n})=>({kind:`pieceEdge`,start:e.start,side:t,deltaMs:n}),i,{move:({deltaMs:e})=>{let i=e/ga(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 Sa(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=`${Ca(e.srcStartMs)} to ${Ca(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 Ca(e){let t=Math.max(0,Math.round(e/100)),n=t%600/10;return`${Math.floor(t/600)}:${n.toFixed(1).padStart(4,`0`)}`}function wa(e,t,n){let r=C(`div`,`track`);r.setAttribute(`data-track`,`clip`);let{clip:i}=e;for(let e of i.degraded){let n=na(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=na(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=na(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`),ma(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(xa(e,`start`,r,t,n)),(!m||e.after!==null)&&d.append(xa(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)>fa;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(Sa(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),va(a,r,t,({toMs:t,snapMs:n})=>({kind:`trim`,edge:e,toMs:t,snapMs:n}),n,{move:({toMs:n})=>ba(r,a,e,k(t.viewport,n)),end:()=>ba(r,a,e,s)}),r.append(a)}for(let e of i.ticks){let a=k(t.viewport,e.atMs);if(a<0||a>1)continue;let o=C(`button`,`tick`);o.type=`button`,o.setAttribute(`data-tick`,e.actionId),o.setAttribute(`data-verb`,e.verb);let s=ja[e.verb];s!==void 0&&o.append(S(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(Ta(i.ticks,e));o.setAttribute(`data-stack-index`,c),o.style.setProperty(`--tick-stack`,c),ma(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 Ta(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 Ea(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=na(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};ma(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 take`:`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),va(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=ya(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)}va(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 Da(e,t,n,r){let i=C(`div`,`track`);i.setAttribute(`data-track`,e);let a=e===`zoom`?t.zooms:t.masks;for(let o of a){let a=Ea(o,e,i,t,n,r);a&&i.append(a)}return i.addEventListener(`click`,a=>{if(a.target!==i)return;let o=ga(i,n.viewport);r.onGesture({kind:e===`zoom`?`addZoom`:`addMask`,atMs:Oa(e,t,_a(i,n.viewport,a.clientX)),snapMs:ha(n,o)})}),Aa(i,e,t,n),i}function Oa(e,t,n){let r=e===`zoom`?(t.zoomDefaultMs-t.zoomInMs)/2:Jt/2;return Math.max(0,Math.min(t.durationMs,n-r))}function ka(e,t,n){let r=e===`zoom`?an(t,n):on(t,n);return Yt(r)?null:e===`mask`?{startMs:r.startMs,endMs:r.endMs}:{startMs:zt(t.zooms,r.startMs,t.zoomInMs),endMs:Bt(t.zooms,r.startMs,r.endMs)}}function Aa(e,t,n,r){let i=null,a=()=>{i?.remove(),i=null};e.addEventListener(`pointermove`,o=>{if(o.target!==e)return a();let s=ka(t,n,Oa(t,n,_a(e,r.viewport,o.clientX))),c=s&&na(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 ja={click:`mousePointerClick`,type:`type`,moveTo:`mousePointer2`,scrollTo:`moveVertical`,waitFor:`hourglass`,drag:`handGrab`};function Ma(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`);fe(e,t.rerunLine===null?`Timing from the take, not from a render — ${it(t.authored)} to see the timing this demo will actually have.`:`Timing from the take, not from a render. ${t.rerunLine}`),i.append(e)}let a=oa(t,n);pa(a,()=>a.getBoundingClientRect(),n,t.durationMs,r);let o=C(`div`,`lanes`);o.append(la(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(Nr(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(Pr(n.viewport,t.durationMs,a/i.width*o))});let c=ua(`Clip`,`film`),l=da(t.hoverCheck);l!==null&&c.querySelector(`.lane-glyph`)?.append(l);let u=la(c,wa(t,n,r));u.setAttribute(`data-lane`,`clip`),o.append(u);let d=la(ua(`Zoom`,`zoomIn`),Da(`zoom`,t,n,r));d.setAttribute(`data-lane`,`zoom`),o.append(d);let f=C(`button`,`btn btn-quiet btn-icon lane-add`);f.type=`button`,f.setAttribute(`data-add-mask`,``),f.setAttribute(`aria-label`,`Add a mask at the playhead`),f.title=`Add a mask at the playhead`,f.append(S(`plus`)),f.onclick=()=>{let e=i.querySelector(`[data-track="clip"]`),t=e?ga(e,n.viewport):0;r.onGesture({kind:`addMask`,atMs:n.positionMs,snapMs:ha(n,t)})};let p=la(ua(`Mask`,`eyeOff`,f),Da(`mask`,t,n,r));p.setAttribute(`data-lane`,`mask`),o.append(p);let m=C(`div`,`playhead`);m.setAttribute(`data-playhead`,``),m.style.left=A(ra(n.viewport,n.positionMs));let h=C(`div`,`grab`);h.setAttribute(`data-playhead-grab`,``),h.setAttribute(`aria-hidden`,`true`),pa(h,()=>s.getBoundingClientRect(),n,t.durationMs,r),m.append(h),s.append(m),o.append(s),i.append(o);let g=C(`p`,`refusal`);fe(g,n.refusal??``),g.setAttribute(`data-refusal`,``),g.hidden=n.refusal===null,i.append(g);let _=e.ownerDocument.activeElement,v=_ instanceof HTMLElement&&e.contains(_)&&_.matches(`[data-lane="mask"] [data-add-mask]`);e.replaceChildren(i),v&&f.focus();let y=i.querySelector(`[data-join-card]`);y!==null&&Na(y)}function Na(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 Pa(e){let t=C(`button`,`btn btn-quiet btn-icon tool`);return t.type=`button`,t.append(S(e)),t}function Fa(e,t,n){e.setAttribute(`aria-label`,t),e.disabled?(Br(e),e.title=t):zr(e,t,n)}var Ia=new WeakMap;function La(){let e=C(`div`,`bar-controls`);e.setAttribute(`data-timeline-tools`,`view`);let t=Pa(`magnet`);t.classList.add(`snap`);let n=Pa(`moveHorizontal`);n.classList.add(`fit`),n.setAttribute(`data-fit`,``);let r=Pa(`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=Pa(`zoomOut`);o.classList.add(`zoom-step`),o.setAttribute(`data-zoom-step`,`out`);let s=Pa(`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 Ra(e,t,n,r){let i=Ia.get(e);(i===void 0||i.view.parentElement!==e)&&(i=La(),Ia.set(e,i),e.replaceChildren(i.view));let{split:a,snap:o,fit:s,zoom:c,zoomOut:l,zoomIn:u}=i;Fa(a,`Split at playhead`,[`Mod`,`B`]),a.onclick=()=>r.onSplit(),Fa(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=Ar(t.durationMs),f=n.viewport.startMs===d.startMs&&n.viewport.endMs===d.endMs;s.disabled=f,Fa(s,f?`The whole take is already in view`:`Fit the whole take`,[`Shift`,`Z`]),s.onclick=()=>r.onViewport(d);let p=n.viewport.endMs-n.viewport.startMs,m=Lr(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 take is too short to zoom into.`,c.oninput=()=>{let e=Ir(t.durationMs,Number(c.value)),i=k(n.viewport,n.positionMs);r.onViewport(Fr(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(Nr(n.viewport,t.durationMs,e,i))};l.disabled=!h||m<=5e-4,l.onclick=()=>g(1/ur),Fa(l,`Zoom out`,[`−`]),u.disabled=!h||m>=.9995,Fa(u,`Zoom in`,[`+`]),u.onclick=()=>g(ur)}var j=re();function M(e){console.error(`demoman editor:`,e)}var za=j.kits,N={state:`ready`,kits:[],defaultId:null,migrationPending:!1},Ba=null,Va=null;function Ha(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`&&be(t.read.kit,e)),i=r.find(e=>e.id===Ba)??r.find(e=>e.id===t.defaultId)??r[0];if(i!==void 0)return Ba=i.id,{kit:i,edited:!1};let a=n.find(e=>e.id===Ba);return a===void 0?null:{kit:a,edited:!0}}var Ua=j.bundles,Wa=new URL(location.href).searchParams.get(`scene`)??``,P=e=>{let t=document.getElementById(e);if(!t)throw Error(`editor is missing #${e}`);return t},Ga=null,Ka=!1,F=lr({sceneId:Wa,loadScene:async e=>{let t=await j.scenes.get(e);if(t===null)throw Error(`no scene "${e}"`);return Vo??=t.notes,Ka||=(Ga=t.revision,!0),t.scene},saveScene:async e=>{Ga=(await j.scenes.put(e,Ga)).revision},bundles:{active:e=>Ua.active(e)},newId:()=>crypto.randomUUID()});function I(e){let t=F.snapshot().scene;return F.dispatch(e).catch(M).then(()=>qa(t))}function qa(e){if(Co===null)return;let t=F.snapshot();t.scene!==e&&t.error===null&&(Co=null,$(t))}var L=ct,Ja=null,R=null,Ya=!1;function Xa(e){e!==R&&(Ya=!1),R=e}var z=null,Za=null,Qa=[],$a=null,eo=null,to=null,B=null,no=null,V=`export`,H=!0,ro=`export`,io=Ln(),U=`mp4`;function ao(e){let t=F.snapshot().scene,n=co();return _e(U,t.canvas.aspect,e,Pe({...t,branding:ss(t)}),n===null?{}:{quality:n})}var oo=j.exportQuality===void 0?null:Fe,so=null,co=()=>oo===null?null:so??oo,lo=!1,uo=null;function fo(e){return uo?.scene!==e&&(uo={scene:e,digest:at(e)}),uo.digest}var po=`fit`;function mo(e){e!==null&&e.kind!==`piece`?(V!==`selection`&&(ro=V),V=`selection`,H=!0):V===`selection`&&(V=ro),B=e}var ho=null,go=null,_o=0,W=null,vo=!0,yo=!1,bo=``,xo=!1,So=null,Co=null,wo=[];function To(){return wo.flatMap(e=>e.kind===`stored`?[e.output]:[])}var Eo=!1,Do=new Set,G=En(u),K=null,q=null,Oo=P(`preview`),ko=new OffscreenCanvas(G.width,G.height),Ao=ko.getContext(`2d`);function jo(e){let t=ao(e),n=Vs(e,P(`stage-frame`).getBoundingClientRect().width),r=n.width!==G.width||n.height!==G.height;G=n,r&&(ko=new OffscreenCanvas(G.width,G.height),Ao=ko.getContext(`2d`)),K=null;let i=P(`stage`);i.style.setProperty(`--frame-ratio`,`${t.width} / ${t.height}`),i.style.setProperty(`--frame-px`,String(En(t).width))}var Mo=150,No=null,Po=!1,Fo=!1;document.addEventListener(`pointerdown`,()=>{Po=!0},!0);var Io=()=>{Po=!1,Fo&&setTimeout(()=>{Fo&&!Po&&$(F.snapshot())},0)};window.addEventListener(`pointerup`,Io,!0),window.addEventListener(`pointercancel`,Io,!0);var Lo=new ResizeObserver(()=>{let e=P(`stage`),t=P(`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`),Ac&&(No!==null&&clearTimeout(No),No=setTimeout(()=>{No=null;let e=Vs(F.snapshot().bundle,P(`stage-frame`).getBoundingClientRect().width);(e.width!==G.width||e.height!==G.height)&&(Po&&(os!==null||is!==null)?(bs(),Fo=!0):$(F.snapshot()))},Mo))});Lo.observe(P(`stage-frame`)),Lo.observe(P(`stage`));var Ro=[],zo=null,Bo=``,Vo=null,Ho=`The video shows the text that was recorded; re-record to type the new text.`;function Uo(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 Wo=null,Go=null,Ko=0,qo=null,Jo=jn(e=>e.motionSpans.length>0?r(e,Ua.load,{onSpanUnavailable:(e,t)=>console.info(`[demoman] preview: span ${e} could not be decoded (${t})`)}):Promise.resolve(s(e,Ua.load)));async function Yo(e){let{bundle:t,scene:n}=e;if(t===null||_n(zo,e))return;zo=gn({scene:n,bundle:t}),Ro=[];let r=h(n).retiming.motionDiffThreshold,i=()=>{let e=F.snapshot();return e.scene===n&&e.bundle===t},a;try{a=await Jo(t),Ro=await me(t,a,r)}catch(e){M(e),i()&&F.setHoverReport(vn),$(F.snapshot());return}try{let e=await Ke(n,t,a,r);if(i()){let t=ae(F.snapshot().scene);F.setHoverReport(bn(e,t))}}catch(e){M(e),i()&&F.setHoverReport(vn)}$(F.snapshot())}var Xo=null,Zo=null,Qo=null,J=null,$o=``,es=null,ts=null,ns=null,rs=null,is=null,as=null,os=null;function ss(e){let t=Ee(os,e,M);return os=t.preview,t.branding}function cs(e){os={patch:e,scene:F.snapshot().scene},bs();let t=F.snapshot();us(t,ao(t.bundle))}function ls(e){Ja!==null&&(Ja=null,$(F.snapshot())),j.files.reveal(e).catch(e=>{let t=In(e);t.expected?console.info(`demoman editor: ${t.text}`):M(e),Ja=t.text,$(F.snapshot())})}function us(e,t){let n=ke({durationMs:zs-X,fileType:U,target:t,hasFrames:$s(e).kind!==`noFrames`}),r=P(`take-meta`);r.textContent=n,r.setAttribute(`aria-label`,`Take info: ${n}`)}var ds=null;function fs(e){return is===null?e.cursor:{...e.cursor,...is}}function ps(e){let t=e.motion??ie;return as===null?t:{...t,...as}}var ms=null,hs=null;function gs(e){is=e,bs()}function _s(e){as=e,bs()}function vs(){as!==null&&(as=null,bs())}function ys(){is!==null&&(is=null,bs())}function bs(){hs===null&&(hs=requestAnimationFrame(()=>{hs=null;let e=F.snapshot();ws(e),q&&(ds=fs(e.scene),ms=ps(e.scene),qo=K,Z.seek(Z.positionMs))}))}function xs(){hs!==null&&cancelAnimationFrame(hs),hs=null,is=null,as=null}function Ss(e){return e===null?null:es?.ref===e?es.thumb:{kind:`loading`}}async function Cs(e){let n=ss(e.scene),r=n.logo?.ref??null;if(r!==Zo&&(Zo=r,Qo=null,J=null,Xo=null,$o=``,r!==null)){let e=await j.logos.load(r);if(Zo!==r)return;e.ok?Qo=e.source:J=e.error}let i=t(n,G),a=`${r}@${i}`;if(Qo!==null&&i>0&&a!==$o){$o=a;try{let e=await Qo.rasterAt(i);if(Zo!==r||$o!==a)return;Xo=e,J=null}catch(e){Xo=null,J=e instanceof Error?e.message:String(e)}}let o=null;if(r!==null){if(Qo!==null){try{o={kind:`ready`,url:await Ne(Qo)}}catch(e){o={kind:`failed`,reason:e instanceof Error?e.message:String(e)}}if(Zo!==r)return}else o=J===null?{kind:`loading`}:{kind:`failed`,reason:J}}let s=JSON.stringify(o)!==JSON.stringify(es?.thumb??null)||(es?.ref??null)!==r;es=r===null?null:{ref:r,thumb:o};let c=Qo?Ie(Qo,t(n,ao(e.bundle)),we(U,e.scene.canvas.aspect)):null,l=[rs?.ref===r?rs.note:null,c].filter(e=>e!==null),u=s||Xo!==ts||J!==ns||l.join(`
3
3
  `)!==Qa.join(`
4
4
  `);Qa=l,ts=Xo,ns=J,u&&$(F.snapshot())}function ws(e){jo(e.bundle);let{scene:t,bundle:n}=e,r=Mn(t,{cursor:fs(t),branding:ss(t),motion:as===null?t.motion:ps(t)}),i=n?he({plan:h(r),bundle:n,scene:r,target:G,detailTarget:ao(n),hints:Ro,logo:Xo}):null;q=i?.resolved??null,K=i?.presentation??null,Oo.width!==G.width&&(Oo.width=G.width),Oo.height!==G.height&&(Oo.height=G.height)}var Ts=[];function Es(e,t){let n=t.width*t.height/1e6;n<=0||(Ts.push(e/n),Ts.length>60&&Ts.splice(0,Ts.length-30))}var Ds=null,Os=null,ks=2e3,As=!1,Y={requestedFrames:0,drawnFrames:0,elapsedMs:0,sourceLookupMs:0,composeMs:0,blitMs:0},js=0,Ms=null,Ns=null,Ps=0,Fs=0;function Is(){Y.requestedFrames=0,Y.drawnFrames=0,Y.elapsedMs=0,Y.sourceLookupMs=0,Y.composeMs=0,Y.blitMs=0,Ps=0,Fs=0,js=performance.now()}function Ls(){if(Z.playing===As)return;if(As=Z.playing,$(F.snapshot()),As){Ms={width:G.width,height:G.height},Is();return}Y.elapsedMs=performance.now()-js;let e=(F.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(On({...Y,...e===null?{}:{sourceFrame:e},...Ms===null?{}:{bitmap:Ms},parkedHeight:G.height,msPerMegapixel:Ns,...Fs>0?{decodeMs:Ps}:{}}))}var Rs=kn({schedule:e=>requestAnimationFrame(e),onDrawFailed:e=>{Xa(e instanceof Error?e.message:String(e)),Z.pause(),$(F.snapshot())},onDrawRecovered:()=>{R!==null&&(R=null,$(F.snapshot()))},draw:async e=>{let t=F.snapshot(),r={resolved:q,presentation:K,target:G,offscreen:ko,offscreenCtx:Ao};if(!r.resolved||!r.presentation||!t.bundle)return;let i=performance.now(),a=await Jo(t.bundle),o=performance.now();As&&a.warm?.(de(r.resolved.timeline,e),de(r.resolved.timeline,e+ks));let s=0;await n({resolved:r.resolved,target:r.target,presentation:r.presentation,frames:a,ctx:r.offscreenCtx,outputTimeMs:e,onStage:(e,t)=>{e===`fetch`&&(s=t,As&&(Ps+=t,Fs+=1))}});let c=performance.now();if(r.offscreen===ko){if(Es(c-o-s,r.target),Oo.getContext(`2d`)?.drawImage(ko,0,0),Z.playing&&Os!==null&&(Os+=1,Os>=15)){let e=Ts.slice(-Os),t=Ds;Ds=null,Ds=Vs(F.snapshot().bundle,P(`stage-frame`).getBoundingClientRect().width,e).height,Os=null,Ds!==t&&($(F.snapshot()),Ms={width:G.width,height:G.height})}ho&&(B?.kind===`mask`||B?.kind===`zoom`)&&Dr(P(`stage-overlay`),{canvas:Oo,selection:B,model:ho,resolved:r.resolved,presentation:r.presentation,target:r.target,outputTimeMs:e},{onMaskRect:(e,t)=>I({kind:`moveMask`,id:e,rect:t}),onZoomPoint:(e,t)=>I({kind:`setZoomTarget`,id:e,point:t})}),As&&(Y.drawnFrames+=1,Y.sourceLookupMs+=o-i,Y.composeMs+=c-o,Y.blitMs+=performance.now()-c)}}}),X=0,zs=0,Bs=!1,Z=An({seek:e=>{As&&(Y.requestedFrames+=1),Rs.seek(e)},durationMs:()=>Bs?zs:0,startMs:()=>X,looping:()=>yo,now:()=>performance.now(),schedule:e=>requestAnimationFrame(e),onChange:()=>{Ls(),Gs()}});function Vs(e,t,n=Ts){let r=ao(e),i=()=>Tn({target:r,paintedCssWidth:t,devicePixelRatio:window.devicePixelRatio,playing:Z.playing,msPerMegapixel:wn(n)});return Z.playing?(Ds===null&&(Ds=i(),Ns=wn(n),Os=0),En(r,Ds)):(Ds=null,En(r,i()))}function Hs(e){e!==F.snapshot().scene.canvas.aspect&&I({kind:`setAspect`,aspect:e}).then(()=>Z.seek(Z.positionMs))}function Us(e){if(e===co())return;let t=document.activeElement instanceof HTMLElement&&document.activeElement.hasAttribute(`data-export-quality`);so=e,$(F.snapshot()),t&&document.querySelector(`[data-export-quality="${e}"]`)?.focus()}function Ws(e){if(e===U)return;let t=document.activeElement instanceof HTMLElement&&document.activeElement.hasAttribute(`data-file-type`);U=e,$(F.snapshot()),t&&document.querySelector(`[data-file-type="${e}"]`)?.focus(),Z.seek(Z.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`&&(B?.kind===`mask`||B?.kind===`zoom`)&&Z.seek(Z.positionMs)});function Gs(){Ui(P(`transport`),{authored:rt(F.snapshot().scene),rerunLine:yt(Q(F.snapshot())),playing:Z.playing,enabled:Bs&&zs>X,rate:Z.rate,looping:yo},{onToggle:Ks,onSkipToStart:()=>Dc({kind:`seekEdge`,edge:`head`},F.snapshot()),onLooping:e=>{yo=e,Gs()},onShuttle:e=>{R=null,Z.shuttle(e)}});for(let[e,t]of[[P(`stage-tools`),P(`toolbar-clock`)],[P(`stage-bar`),P(`stage-bar`)]])Wi(e,{authored:rt(F.snapshot().scene),rerunLine:yt(Q(F.snapshot())),positionMs:Z.positionMs-X,durationMs:zs-X,aspect:F.snapshot().scene.canvas.aspect,enabled:Bs&&zs>X,fullscreen:!!document.fullscreenElement,error:Ya?null:R,zoom:po},{onAspect:Hs,onFullscreen:Js,onZoom:qs,onDismissError:()=>{Ya=!0,Gs()}},t);let e=P(`timeline`).querySelector(`[data-playhead]`);e&&W&&(e.style.left=`${(ra(W,Z.positionMs)*100).toFixed(4)}%`)}function Ks(){R=null,Z.toggle(),$(F.snapshot())}function qs(){po=po===`fit`?`actual`:`fit`,document.body.dataset.zoom=po,Gs()}function Js(){R=null;let e=!document.fullscreenElement;(e?P(`stage`).requestFullscreen():document.exitFullscreen()).catch(t=>{Xa(`The preview could not ${e?`go full screen`:`exit full screen`}: ${t instanceof Error?t.message:String(t)}`),$(F.snapshot())})}document.addEventListener(`fullscreenchange`,()=>{let e=document.activeElement;R=null,Gs();let t=!!document.fullscreenElement;P(`stage`).toggleAttribute(`data-fullscreen`,t);let n=P(t?`stage-tools`:`stage-bar`),r=P(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 Ys(){let e=F.snapshot();Xs(Et(e.scene,e.bundle,q?.timeline??null,Z.positionMs))}function Xs(e){if(e!==null){if(Yt(e)){Co=e.reason,$(F.snapshot());return}I(e)}}function Zs(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);I(e).then(()=>{let r=F.snapshot();n(r.scene)||B?.kind===t&&B.id===e.id&&(mo(null),$(r))})}function Qs(e){if(M(e),$a=e instanceof Error?e.message:String(e),Ac){$(F.snapshot());return}fi(P(`failure`),{error:null,replaySentence:null,captureSentence:null,openError:$a})}function $s(e){return e.bundle===null?{kind:`noFrames`}:{kind:`exact`}}function Q(e){let t=rt(e.scene);return{takeId:Wa,authored:t,rerun:j.nav.rerun(Wa,t)}}function ec(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){Fo=!1,xs(),ws(e);let t=ec(q);t!==Wo&&(Wo=t,console.info(t));let n=Or({scene:e.scene,bundle:e.bundle,resolved:q}),r=P(`name`);r.value=e.scene.meta.name,r.placeholder=ze(e.scene.meta),P(`undo`).disabled=!e.canUndo,P(`redo`).disabled=!e.canRedo,li(P(`banner`),{hasFrames:e.bundle!==null,route:Q(e)}),z!==null&&e.scene!==Za&&(z=null),fi(P(`failure`),{error:e.error??z,replaySentence:e.replaySentence,replayRecoverable:e.replayRecoverable,captureSentence:e.captureSentence,renderError:L.error,previewError:R,logoLoadError:J,openError:$a,deleteError:eo,navigationError:to,runsRoute:Q(e)});let i=Rt({scene:e.scene,view:n,bundle:e.bundle,resolved:q,hoverReport:e.hoverReport,rerunLine:yt(Q(e))});ho=i,go=n,_o=i.durationMs,(W===null||So!==i.durationMs)&&(W=Ar(i.durationMs),So=i.durationMs);let a={resolved:q,bundle:e.bundle,viewport:e.scene.meta.capture.viewport},o=e=>Xs(pn(i,n,e,a)),s=e=>{W=e,$(F.snapshot())},c=e=>{vo=e,$(F.snapshot())};Ma(P(`timeline`),i,{viewport:W,selection:B,get positionMs(){return Z.positionMs},refusal:Co,hoverReport:e.hoverReport,snapping:vo,openJoin:no},{onSelect:e=>{mo(e),$(F.snapshot())},onSeek:e=>Z.seek(e),onSeekStart:()=>Z.pause(),onSplit:Ys,onRestorePiece:e=>{no=null,I({kind:`restorePiece`,id:e})},onOpenJoin:e=>{no=e,$(F.snapshot())},onGesture:o,onViewport:s,onSnapping:c}),ci(P(`take-notes`),{notices:[...Vo??[],...Uo(e)?[Ho]:[],...i.notices],hoverReport:e.hoverReport}),Ra(P(`timeline-tools`),i,{viewport:W,snapping:vo,get positionMs(){return Z.positionMs}},{onGesture:o,onSplit:Ys,onViewport:s,onSnapping:c});let l=B;l?.kind===`piece`&&!i.clip.pieces.some(e=>Dt(e.start,l.start))&&(B=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);V===`selection`&&!u&&(B===null&&M(Error(`the rail was on Selection with nothing selected`)),mo(null)),document.body.dataset.panel=H?`open`:`closed`,$r(P(`rail`),{rail:V,panelOpen:H,hasSelection:u},{onPick:Oc}),ei(P(`export-open`),{rail:V,panelOpen:H},{onPick:Oc}),ti(P(`shortcuts-open`),{rail:V,panelOpen:H},{onPick:Oc});let d=document.activeElement?.matches(`[data-shortcuts-search]`)===!0;Xr(P(`inspector`),{selection:B,view:n,model:i,scene:e.scene,hoverReport:e.hoverReport,viewport:e.scene.meta.capture.viewport,rail:V,sections:io,attachedToCuts:q?.plan.attachedToCuts??[]},{onClose:kc,onGap:(e,t)=>Xs(mn(n,e,t)),onGapClear:e=>I({kind:`clearGap`,afterActionId:e}),onKeepHover:tc,onZoomOnStep:e=>{let t=n.beats.find(t=>t.actionId===e);if(!t?.anchorId)return;let r=new Set(F.snapshot().scene.camera.map(e=>e.id));I({kind:`addZoom`,marker:{actionId:e,offsetMs:0},target:{kind:`element`,anchorId:t.anchorId},scale:g.defaultZoomScale}).then(()=>{let e=F.snapshot().scene.camera.find(e=>!r.has(e.id));e&&(mo({kind:`zoom`,id:e.id}),$(F.snapshot()))})},onZoomScale:(e,t)=>I({kind:`setZoomScale`,id:e,scale:t}),onRemoveZoom:e=>Zs({kind:`removeZoom`,id:e}),onMaskNote:(e,t)=>I({kind:`setMaskNote`,id:e,note:t}),onRemoveMask:e=>Zs({kind:`removeMask`,id:e})});let f=document.querySelector(`#inspector [data-panel-shortcuts]`);f!==null&&Xi(f,{mac:yr(navigator.userAgent),query:bo,focus:H&&(xo||d)},{onClose:kc,onQuery:e=>{bo=e}}),xo=!1,Dr(P(`stage-overlay`),{canvas:Oo,selection:B,model:i,resolved:q,presentation:K,target:G,outputTimeMs:Z.positionMs},{onMaskRect:(e,t)=>I({kind:`moveMask`,id:e,rect:t}),onZoomPoint:(e,t)=>I({kind:`setZoomTarget`,id:e,point:t})});let p=P(`inspector`);p.querySelector(`.inspector`)===null&&M(Error(`the inspector has not rendered anything`));let m={export:`export`,branding:`background`,cursor:`cursor`},h=e=>{let t=p.querySelector(`[data-panel-${e}]`);return t===null&&V===m[e]&&H&&M(Error(`the inspector's ${e} panel is missing`)),t},_=h(`branding`);_&&pi(_,{branding:e.scene.branding,logoThumb:Ss(e.scene.branding.logo?.ref??null),logoPlacement:K?.logoPlacement??null,formatTitle:we(U,e.scene.canvas.aspect),logoNotes:Qa,kit:{read:N,standing:Ha(e.scene.branding),naming:Va,onApply:e=>{let t=N.state===`ready`?N.kits.find(t=>t.id===e):void 0;if(t?.read.state!==`ready`){z=t===void 0?`That brand kit was not applied: it was deleted in another tab.`:`That brand kit was not applied: ${t.read.reason}.`,Za=F.snapshot().scene,$(F.snapshot());return}Ba=e;let{background:n,logo:r,padding:i}=t.read.kit;I({kind:`setBranding`,patch:{background:n,logo:r,padding:i}}),$(F.snapshot())},onUpdate:()=>void rc(),onStartNew:()=>{Va={text:``,error:null},$(F.snapshot())},onNameInput:e=>{Va!==null&&(Va={text:e,error:null})},onConfirmNew:e=>void ic(e),onCancelNew:()=>{Va=null,$(F.snapshot())}}},{onCommit:e=>I({kind:`setBranding`,patch:e}),onPreview:cs,onLogoFile:e=>nc(e).catch(M)});let v=h(`cursor`);v&&Ei(v,fs(e.scene),ps(e.scene),{onCursor:e=>{xs(),I({kind:`setCursor`,patch:e})},onCursorPreview:gs,onCursorPreviewEnd:ys,onMotion:e=>{xs(),I({kind:`setMotion`,patch:e})},onMotionPreview:_s,onMotionPreviewEnd:vs},e.scene.meta.capture.device?.touch===!0);let y=ao(e.bundle),ee=h(`export`);ee&&Ai(ee,{outputs:wo,fileType:U,quality:co(),aspect:e.scene.canvas.aspect,target:y,recording:ye(e.bundle,Pe(e.scene)),durationMs:i.clip.trim.tailMs-i.clip.trim.headMs,run:L.run,save:L.save,revealError:Ja,readiness:$s(e),runsRoute:Q(e),currentDigest:fo(e.scene),sections:io,beatAt:gt(n.beats),hasReclaimedMotion:e.bundle?.degradations.some(e=>e.kind===`motionReclaimed`)??!1},{onExport:()=>ac().catch(M),onFileType:Ws,onQuality:Us,onSaveAgain:e=>oc(e).catch(M),onReveal:ls}),Bs=n.hasBundle,X=i.clip.trim.headMs,zs=i.clip.trim.tailMs,us(e,y),ea(P(`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:ye(e.bundle,Pe(e.scene)),target:y,aspect:e.scene.canvas.aspect,takeId:Wa,rerun:Q(e).rerun,revealError:Ja,history:{outputs:wo,currentDigest:fo(e.scene),showAll:Eo,warningsOpen:Do,reportContext:{beatAt:gt(n.beats),runsRoute:Q(e)}}},{onCopy:e=>navigator.clipboard.writeText(e),onDownload:e=>oc([e]).catch(M),onReveal:ls,onShowAll:()=>{Eo=!0,$(F.snapshot())},onWarnings:e=>{Do.delete(e)||Do.add(e),$(F.snapshot()),document.querySelector(`#take-info [data-output-warnings="${CSS.escape(e)}"]`)?.focus()}}),Z.positionMs<X&&Z.seek(X),Z.positionMs>zs&&Z.seek(zs),Gs();let b=fs(e.scene),x=ps(e.scene),te=JSON.stringify(e.scene.edits.removed??[]);q&&K&&(e.bundle!==Go||G.height!==Ko||Nn(ds,b)||Pn(ms,x)||Fn(qo,K)||te!==Bo)&&(Go=e.bundle,ds=b,ms=x,qo=K,Ko=G.height,Bo=te,Z.seek(Z.positionMs)),Cs(e).catch(M)}function tc(e){let t=F.snapshot().hoverReport;if(t===null){M(Error(`kept hover "${e}" with no hover report`));return}F.setHoverReport({...t,removable:t.removable.filter(t=>t!==e)})}async function nc(e){z=null;let t=Se(e),n=e=>{z=e,Za=F.snapshot().scene,$(F.snapshot())};if(!t.ok)return n(t.reason);let r=new Uint8Array(await e.arrayBuffer());try{await te(r,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:i}=await j.logos.put(e);rs=t.note===null?null:{ref:i,note:t.note};let a=F.snapshot().scene.branding.logo,o=a?{corner:a.corner,size:a.size,opacity:a.opacity}:v;await F.dispatch({kind:`setBranding`,patch:{logo:{ref:i,...o}}})}async function rc(){let e=Ha(F.snapshot().scene.branding);if(e===null||!e.edited){z=e===null?`No brand kit was updated: this demo is no longer on a kit.`:`No brand kit was updated: this demo already matches "${e.kit.name}".`,Za=F.snapshot().scene,$(F.snapshot());return}let t=e.kit,n=`This demo's background, logo and padding will replace the brand kit "${t.name}".`;try{if(!await ne({glyph:`refresh`,title:`Replace "${t.name}"`,body:n,confirmLabel:`Replace`,danger:!1,focus:`confirm`}))return;let e=F.snapshot().scene.branding,r=await za.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 za.read()}catch(e){z=`The brand kit "${t.name}" was not saved: ${e instanceof Error?e.message:String(e)}`,Za=F.snapshot().scene}$(F.snapshot())}async function ic(e){let t=N.state===`ready`?N.kits:[],n=b(e,t,null);if(!n.ok){Va={text:e,error:n.reason},$(F.snapshot());return}let r=F.snapshot().scene.branding,i=se();try{let t=await za.update(e=>{let t=b(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){Va={text:e,error:t},$(F.snapshot());return}Va=null,Ba=i,N=await za.read()}catch(e){z=`The brand kit "${n.name}" was not saved: ${e instanceof Error?e.message:String(e)}`,Za=F.snapshot().scene}$(F.snapshot())}async function ac(){Ja=null;let e=F.snapshot().scene;L={run:{phase:`encoding`,done:0,total:0},save:null,error:null},$(F.snapshot());try{await F.settled();let t=co();await j.exports.start(Wa,{fileType:U,aspect:e.canvas.aspect,revision:Ga,...t===null||U!==`mp4`||so===null&&!lo?{}:{quality:t}})}catch(e){throw L={...L,run:{phase:`idle`},error:e instanceof Error?e.message:String(e)},$(F.snapshot()),e}}async function oc(e){let t=To(),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`);L={...L,save:await i.save(n)},$(F.snapshot())}var sc=!1;function cc(){let e=document.querySelector(`[data-panel-export]`);e!==null&&!ki(e,L.run,U,$s(F.snapshot()))&&!sc&&(sc=!0,M(Error(`the Export panel has no start button, so progress cannot show`)))}function lc(e){let t=ut(L,e);switch(L=t.flow,t.effect){case`render`:$(F.snapshot());return;case`progress`:cc();return;case`relist`:j.outputs.list(Wa).then(e=>{wo=e,$(F.snapshot())}).catch(M);return;case`none`:return}}j.exports.onEvent(lc),j.nav.onOpen?.(e=>gc(()=>location.assign(e))),P(`name`).addEventListener(`change`,e=>{I({kind:`rename`,name:e.target.value.trim()})});var uc=e=>()=>{let t=F.snapshot().scene;e().catch(M).then(()=>qa(t))};P(`undo`).addEventListener(`click`,uc(()=>F.undo())),P(`redo`).addEventListener(`click`,uc(()=>F.redo()));var dc={recording:`a take is recording`,rendering:`a render is running`,sharing:`a share is in progress`,replaying:`a take is being run in Runs`};function fc(e){eo=e,pc()}function pc(){if(Ac){$(F.snapshot());return}fi(P(`failure`),{error:null,replaySentence:null,captureSentence:null,deleteError:eo,navigationError:to})}function mc(e,t,n=``){to=null;try{location.assign(t())}catch(t){M(t),to={page:e,reason:`${n}${t instanceof Error?t.message:String(t)}`},pc()}}function hc(e=``,t=null){mc(`Recordings page`,()=>Ve(j.nav.library(),t),e)}function gc(e){(async()=>{let t=null,n=F.subscribe(e=>{t=e});try{await F.settled()}finally{n()}t?.error??e()})()}P(`back`).addEventListener(`click`,()=>{gc(()=>hc())});function _c(e){let t=vc(e);t&&(e.preventDefault(),gc(()=>mc(`Runs page`,()=>t.href)))}P(`banner`).addEventListener(`click`,_c),P(`inspector`).addEventListener(`click`,_c),P(`take-info`).addEventListener(`click`,_c),P(`failure`).addEventListener(`click`,_c),P(`take-info`).addEventListener(`toggle`,e=>{P(`take-meta`).setAttribute(`aria-expanded`,String(e.newState===`open`))});function vc(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 yc=null;document.addEventListener(`mousedown`,e=>{let t=vc(e);yc=t?{link:t,href:t.href}:null},!0),document.addEventListener(`mouseup`,e=>{let t=yc;if(yc=null,!t)return;let n=vc(e);!n||n===t.link||n.href===t.href&&gc(()=>mc(`Runs page`,()=>n.href))},!0),P(`delete`).addEventListener(`click`,()=>{(async()=>{try{if(!await ne(ue))return}catch(e){M(e),fc(`Not deleted: the confirmation could not open — ${e instanceof Error?e.message:String(e)}.`);return}eo=null;let e;try{e=await j.scenes.remove(Wa)}catch(e){M(e),fc(`Not deleted: ${e instanceof Error?e.message:String(e)}.`);return}if(!e.ok){fc(`Not deleted: ${dc[e.error]??e.detail??e.error}.`);return}if(e.result!==void 0&&!e.result.ok){let t=e.result.steps.find(e=>!e.ok);fc(`Partly deleted: ${t?.step??`a step`} could not be removed — ${t?.error??`unknown error`}. Open Your demos to retry.`);return}let t=e.note??null;hc(t===null?`This demo was deleted. `:`This demo was deleted. ${t} `,t===null?null:`This demo was deleted. ${t}`)})()});var bc=Symbol.for(`demoman.editor.keydown`),xc=globalThis,Sc=xc[bc];Sc instanceof AbortController&&Sc.abort();var Cc=new AbortController;xc[bc]=Cc;var wc=!1,Tc=null;document.addEventListener(`pointerdown`,()=>{wc=!0},{capture:!0,signal:Cc.signal}),document.addEventListener(`pointerdown`,()=>{no!==null&&(no=null,$(F.snapshot()))},{signal:Cc.signal}),document.addEventListener(`keydown`,()=>{wc=!1},{capture:!0,signal:Cc.signal}),document.addEventListener(`focusin`,e=>{Tc=wc?e.target:null},{signal:Cc.signal});var Ec=new WeakMap;document.addEventListener(`focusin`,e=>{let t=e.target;(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&Ec.set(t,t.value)},{signal:Cc.signal}),document.addEventListener(`change`,e=>{let t=e.target;(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&Ec.set(t,t.value)},{capture:!0,signal:Cc.signal}),document.addEventListener(`keydown`,e=>{if(document.querySelector(`dialog[open]`)!==null)return;if(e.key===`Escape`&&no!==null){e.preventDefault(),no=null,$(F.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=Ec.get(t);e!==void 0&&t.value!==e&&(t.value=e)}t?.blur()}return}let r=e.key===`Enter`||e.key===` `&&t!==Tc;if((n===`BUTTON`||n===`A`)&&r&&t?.hasAttribute(`data-tick`)!==!0)return;let i=F.snapshot(),a=dr(e,{hasSelection:B!==null,selectionIsBeat:B?.kind===`tick`,canUndo:i.canUndo,canRedo:i.canRedo,panelOpen:H,hasTimeline:W!==null&&_o>0});a!==null&&(e.preventDefault(),Dc(a,i))},{signal:Cc.signal});function Dc(e,t){switch(e.kind){case`playPause`:Ks();return;case`shuttle`:R=null,Z.shuttle(e.direction);return;case`stop`:Z.stop();return;case`nudge`:Z.seek(Z.positionMs+e.deltaMs);return;case`seekEdge`:Z.seek(e.edge===`head`?X:zs);return;case`stepBeat`:{let n=t.scene.actions.map(e=>e.id),r=B?.kind===`tick`?n.indexOf(B.actionId):-1,i=n[r===-1?e.delta>0?0:n.length-1:r+e.delta];if(i===void 0)return;mo({kind:`tick`,actionId:i}),$(t);return}case`setTrim`:{let n=ho,r=go;if(n===null||r===null||q===null||!Bs){let e=Q(t);Co=`This take has not been rendered yet, so there is nothing to trim to. ${bt(e.authored,yt(e),`first`)}`,$(t);return}Xs(pn(n,r,{kind:`trim`,edge:e.edge,toMs:Z.positionMs,snapMs:0},{resolved:q,bundle:t.bundle,viewport:t.scene.meta.capture.viewport}));return}case`split`:Ys();return;case`undo`:uc(()=>F.undo())();return;case`redo`:uc(()=>F.redo())();return;case`deleteSelection`:if(B===null)return;if(B.kind===`zoom`){Zs({kind:`removeZoom`,id:B.id});return}if(B.kind===`mask`){Zs({kind:`removeMask`,id:B.id});return}if(B.kind===`piece`){Xs(Ot(ho?.clip.pieces??[],B.start,ho?.clip.trim));return}Xs({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(W===null)return;let n=Math.min(1,Math.max(0,k(W,Z.positionMs)));W=Nr(W,_o,e.factor,n),$(t);return}case`zoomFit`:W=Ar(_o),$(t);return;case`toggleSnapping`:vo=!vo,$(t);return;case`clearSelection`:mo(null),$(t);return;case`toggleHelp`:Oc(`shortcuts`);return;case`closePanel`:kc();return}}function Oc(e){V===e&&H?H=!1:(V=e,H=!0,e===`shortcuts`&&(xo=!0)),e!==`selection`&&(ro=e),$(F.snapshot())}function kc(){H=!1,$(F.snapshot())}Ki(),Hr(),document.body.dataset.zoom=`fit`;{let e=P(`notes`),t=``,n=()=>{Ji(P(`notes-open`),e),t=Yi(e,t)};new MutationObserver(n).observe(e,{childList:!0,subtree:!0,characterData:!0}),n()}var Ac=!1;F.subscribe(e=>{Ac=!0,$a=null,$(e)}),F.subscribe(e=>Yo(e).catch(M));async function jc(){N=await za.read(),Ac&&$(F.snapshot())}jc().catch(M),za.onChange===void 0?console.info(`demoman: no storage change feed here, so the brand kit is read once`):za.onChange(()=>{jc().catch(M)});async function Mc(){let e=j.exportQuality;if(e===void 0)return;let t=await e.read();lo=t.unreadable===void 0,t.unreadable!==void 0&&console.info(`demoman editor: the Studio exports at ${ve[t.quality]} quality: ${t.unreadable}`),t.quality!==oo&&(oo=t.quality,Ac&&$(F.snapshot()))}j.exportQuality!==void 0&&(Mc().catch(M),window.addEventListener(`focus`,()=>{Mc().catch(M)})),j.outputs.list(Wa).then(e=>{wo=e,Ac&&$(F.snapshot())}).catch(M),F.load().catch(Qs);