demoman 0.7.1 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ import{$ as e,B as t,G as n,H as r,J as i,K as a,L as o,M as s,N as c,Q as l,R as u,S as d,U as f,V as p,W as m,X as h,Y as g,Z as _,a as v,at as y,c as b,f as x,g as S,h as ee,j as te,l as ne,lt as re,n as ie,o as ae,ot as oe,q as se,r as C,rt as ce,s as le,st as ue,t as de,u as fe,ut as pe,z as me}from"./confirm-dialog-CN_GqXY_.js";import{C as he,E as ge,S as _e,T as ve,_ as ye,a as be,b as xe,c as Se,d as Ce,f as we,g as Te,h as Ee,l as De,m as Oe,o as w,p as ke,s as Ae,u as je,v as Me,w as Ne,x as Pe,y as Fe}from"./view-DsZQo9AJ.js";import{c as Ie,f as Le,p as Re,s as ze,u as Be}from"./state-COWbBf84.js";function Ve(e,t){let{bundle:r,scene:i}=n(t,e),a=new Map(i.anchors.map(e=>[e.id,e])),o=new Map((r.markers??[]).map(e=>[e.actionId,e.sourceTimeMs])),s=new Map;for(let e of i.anchors)e.fingerprint.boundingRect&&s.set(e.id,e.fingerprint.boundingRect);let c=new Map;for(let e of r.anchorRects??[])c.set(e.actionId,e.rect);let l=(e,t)=>c.get(t)??s.get(e)??null;return i.actions.flatMap(e=>{if(e.kind!==`moveTo`)return[];let t=e.id;if(e.signal!==`style`)return[{kind:`unknown`,actionId:t,reason:`notStyleSignalled`}];let n=o.get(t);if(n===void 0)return[{kind:`unknown`,actionId:t,reason:`noMarker`}];let i=e.anchorId===null?void 0:a.get(e.anchorId),s=e.anchorId===null?null:l(e.anchorId,t);if(s===null)return[{kind:`unknown`,actionId:t,reason:`noRect`}];if(i?.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}=r.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:n-400,postMs:n+100}]})}var He=64;function Ue(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 We(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 Ge(e,t,n,r){let i=[];for(let a of Ve(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(He,Math.round(a.rect.width))),l=Math.max(1,Math.min(He,Math.round(a.rect.height))),u;try{u=We(Ue(e,a.rect,t.viewport,c,l),Ue(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 Ke(e){return i.neutral.zoomHoldMs+h(e).zoomOutMs}Ke(oe.smoothness);var qe=Math.abs(i.leadInMs)+i.neutral.minPlateauMs+400;function Je(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 ${qe}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 ${Ye}x).`;case`textTooWide`:return`${t}: target too wide to zoom without cutting text (would be ${e.scale}x, floor ${Ye}x).`}}i.fitMarginPx;var Ye=1.2,Xe=`__demomanClickProbe`;`${Xe}${JSON.stringify(`__demomanClickSeen`)}`,`${Xe}`,`${Xe}`;var Ze={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 Qe(e){return e in Ze?Ze[e]:e}function $e(e){if(!e)return`(navigation)`;let t=e.fingerprint;return t.accessibleName??t.textContent??t.stableId??t.dataKey??e.id}function et(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:$e(e.anchors.find(e=>e.id===n.anchorId))}:null}function tt(e,t){return et(e,t)}function nt(e){return e.meta.capture.mode===`authored`}function rt(e){return e?`run its script again in Runs`:`re-shoot it in Runs`}function it(e){let{toolchain:t,name:n,...r}=e.meta,{canvas:i,...a}=e;return ot(at({...a,meta:r})).toString(16)}function at(e){if(typeof e!=`object`||!e)return JSON.stringify(e)??`null`;if(Array.isArray(e))return`[${e.map(at).join(`,`)}]`;let t=e;return`{${Object.keys(t).filter(e=>t[e]!==void 0).sort().map(e=>`${JSON.stringify(e)}:${at(t[e])}`).join(`,`)}}`}function ot(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 st={run:{phase:`idle`},save:null,error:null},ct=(e,t)=>e===null?t:`${e}; ${t}`;function lt(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:ct(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:ct(e.error,t.detail)},effect:`render`};case`outputsChanged`:return{flow:e,effect:`relist`}}}var ut=`motion reclaimed to free space`;function dt(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]=pt(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 ft(e,t=2){return String(Number(e.toFixed(t)))}function pt(e,t){for(let n=2;n<4;n++)if(ft(e,n)!==ft(t,n))return[ft(e,n),ft(t,n)];return[ft(e,4),ft(t,4)]}function mt(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=>dt(e,t))}}function ht(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 gt(e){return e?`Run its script again in Runs`:`Re-shoot this take in Runs`}function _t(e){let t=rt(e);return t.charAt(0).toUpperCase()+t.slice(1)}function vt(e){return e.rerun.kind===`line`?e.rerun.text:null}function yt(e,t,n){return t??`${_t(e)} ${n}.`}var T=1,E=e=>({kind:`refusal`,reason:e});function bt(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 xt(e){return new Map(e.markers.map(e=>[e.actionId,e.sourceTimeMs]))}function St(e,t,n){return Ct(e,l(t,n))}function Ct(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 wt(e,t,n){let r=xt(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=bt(t,e=>c(e.start,-1/0)),u=bt(t,e=>-c(e.end,1/0));if(l===void 0||u===void 0)continue;let d=_(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:_(n,Math.max(0,Math.min(n.sourceDurationMs,(r.get(s.actionId)??0)+s.sourceOffsetMs)));o.push({removedId:t,atMs:c,index:o.filter(e=>Math.abs(e.atMs-c)<T).length,srcStartMs:0,srcEndMs:0,unplaced:e.reason})}for(let t of e.edits.splits??[]){let e=r.get(t.at.actionId);if(e===void 0){c.push(t.id);continue}let i=e+t.at.sourceOffsetMs;if(n.cuts.some(e=>i>=e.srcStartMs&&i<=e.srcEndMs))continue;let o=_(n,i);a.push({atMs:o,left:t.at,right:t.at,rank:1})}a.sort((e,t)=>e.atMs-t.atMs||e.rank-t.rank);let l=[];for(let e=0;e+1<a.length;e++){let t=a[e],n=a[e+1];n.atMs-t.atMs<T||l.push({startMs:t.atMs,endMs:n.atMs,start:t.right,end:n.left,before:t.rightBeside??null,after:n.leftBeside??null})}return{pieces:l,joins:o,unplacedSplits:c}}function Tt(e,t,n,r){if(t===null||n===null)return E(`Nothing has rendered yet, so there is no frame to split at.`);if(r<=0||r>=n.outputDurationMs)return E(`A split at the take's start or end splits nothing.`);let i=St(t,n,r);if(i===null)return E(`These frames name no step, so there is nothing to split by.`);let a=xt(t).get(i.actionId)??0,o=_(n,a+i.sourceOffsetMs),{pieces:s}=wt(e,t,n);return o<=T||o>=n.outputDurationMs-T||s.some(e=>Math.abs(e.startMs-o)<T)?E(Math.abs(o-r)<T?`The clip is already split here.`:`A pause is one frame, so a split anywhere in it lands at its edge — and the clip is already split there.`):{kind:`split`,at:i}}var Et=(e,t)=>e===null||t===null?e===t:e.actionId===t.actionId&&e.sourceOffsetMs===t.sourceOffsetMs;function Dt(e,t,n){let r=e.find(e=>Et(e.start,t));if(r===void 0)return E(`That piece is no longer on the timeline.`);if(e.length===1)return E(`This is the only piece left, so removing it would leave nothing to export.`);if(n!==void 0){let t=e=>e.endMs>n.headMs+T&&e.startMs<n.tailMs-T;if(t(r)&&e.filter(t).length===1)return E(`This is the only piece inside the trim, so removing it would leave nothing to export.`)}return{kind:`removePiece`,start:r.start,end:r.end}}function Ot(e,t,n,r,i,a){let o=n.find(e=>Et(e.start,r));if(o===void 0)return E(`That piece is no longer on the timeline.`);if(e===null||t===null)return E(`Nothing has rendered yet, so there is no frame to move the edge to.`);let s=Math.round(a);if(s===0)return null;let c=i===`end`?s<0:s>0,l=i===`end`?o.after:o.before;if(c){let n=i===`end`?Math.max(o.startMs+200,o.endMs+s):Math.min(o.endMs-200,o.startMs+s);if(i===`end`?n>=o.endMs:n<=o.startMs)return E(`This piece is as short as a piece can be.`);let r=St(e,t,n);return r===null?E(`These frames name no step, so there is nothing to move the edge by.`):l===null?i===`end`?{kind:`removePiece`,start:r,end:o.end}:{kind:`removePiece`,start:o.start,end:r}:i===`end`?{kind:`setRemovedEdge`,id:l.removedId,start:r}:{kind:`setRemovedEdge`,id:l.removedId,end:r}}if(l===null)return E(i===`end`?`Nothing was removed after this piece, so its end can only move in.`:`Nothing was removed before this piece, so its start can only move in.`);let u=i===`end`?l.srcStartMs+s:l.srcEndMs+s;if(i===`end`?u>=l.srcEndMs-T:u<=l.srcStartMs+T)return{kind:`restorePiece`,id:l.removedId};let d=Ct(e,u);return d===null?E(`These frames name no step, so there is nothing to move the edge by.`):i===`end`?{kind:`setRemovedEdge`,id:l.removedId,start:d}:{kind:`setRemovedEdge`,id:l.removedId,end:d}}var kt=1e3;function At(e,t){return`Motion reclaimed to free space. ${yt(e,t,`to restore`)}`}var jt=new Set([`Motion reclaimed to free space. Replay to restore.`,`Motion reclaimed to free space. Rebuild to restore.`]);function Mt(e,t,n,r){return e===`motionReclaimed`?jt.has(t)||t===`Motion reclaimed to free space. Re-shoot it in Runs to restore.`?At(n,r):t:`${e}: ${t}`}var Nt=(e,t)=>e.hasBundle?t.outputMs??t.captureMs:t.captureMs;function Pt(e){return e.hasBundle&&e.outputDurationMs!==null?e.outputDurationMs:(e.beats[e.beats.length-1]?.captureMs??0)+kt}function Ft(e,t){let n=e.beats.find(e=>e.actionId===t.actionId);return(n?Nt(e,n):0)+t.offsetMs}function It(e){let{scene:t,view:n,bundle:r,resolved:i}=e,a=nt(t),o=e.rerunLine??null,s=e=>yt(a,o,e),c=Pt(n),l=[],u=new Set(e.hoverReport?.removable??[]),d=new Map(n.beats.map(e=>[e.actionId,Nt(n,e)])),f=new Map(n.beats.map(e=>[e.actionId,e.timing])),p=e=>i===null?`estimated`:e?f.get(e.actionId)??`estimated`:`rendered`,m=n.beats.map(e=>({actionId:e.actionId,atMs:d.get(e.actionId)??0,verb:e.verb,label:e.label,timing:e.timing,flag:u.has(e.actionId)?`unchangedHover`:null,canZoom:e.canZoom,cut:e.cut})),g=t.edits.trim,v=i?{headMs:i.range.startMs,headTiming:i.trimUnplaced.includes(`head`)?`estimated`:`rendered`,tailMs:i.range.endMs,tailTiming:i.trimUnplaced.includes(`tail`)?`estimated`:`rendered`,headMarker:g?.head??null,tailMarker:g?.tail??null}:{headMs:g?.head?Math.max(0,Ft(n,g.head)):0,headTiming:g?.head?`estimated`:`rendered`,tailMs:g?.tail?Math.min(c,Ft(n,g.tail)):c,tailTiming:g?.tail?`estimated`:`rendered`,headMarker:g?.head??null,tailMarker:g?.tail??null};for(let e of i?.trimUnplaced??[])l.push(`The trim's ${e} is placed from the take's own timestamp: the last render carried no marker for its step. ${s(`to give it measured timing`)}`);for(let e of i?.timeline.unplacedCuts??[])l.push(`A removed piece removed no frames: ${e.reason}.`);let y=new Set((i?.clampedRanges??[]).filter(e=>e.kind===`zoom`).map(e=>e.id));for(let e of i?.clampedRanges??[])l.push(e.note);let b=new Map((i?.cameraSegments??[]).map(e=>[e.id,e])),{smoothness:x}=t.motion??oe,S=Ke(x),{zoomInMs:ee}=h(x),te=new Set,ne=t.camera.flatMap(e=>{let t=e.scale??1;if(t<=1)return[];let r=b.get(e.id);r||te.add(e.id);let i=r?r.startMs:Math.max(0,Ft(n,e.marker)),a=r?r.endMs:Math.min(c,e.end?Ft(n,e.end):i+S),o=e.point?{kind:`point`,x:e.point.x,y:e.point.y}:{kind:`element`,anchorId:e.anchorId??``};return r?.endUnplaced&&l.push(`The end of zoom "${e.id}" is placed from the take's own timestamp: the last render carried no marker for its step. ${s(`to give it measured timing`)}`),[{id:e.id,actionId:e.marker.actionId,departMs:r?.departMs??i,startMs:i,endMs:a,drawnEndMs:a,endAuthored:e.end!==void 0,scale:t,target:o,aimFallback:e.note??null,timing:r?r.endUnplaced?`estimated`:p(e.marker):`estimated`,clamped:y.has(e.id),marker:e.marker,endMarker:e.end??null}]}),re=ne.map(e=>{if(!te.has(e.id))return e;let t=Math.min(...ne.map(e=>e.startMs).filter(t=>t>e.startMs));return e.endMs>t?{...e,endMs:t}:e}),ie=re.map(e=>te.has(e.id)?{...e,departMs:Lt(re,e.startMs,ee)}:e),ae=ie.map(e=>({...e,drawnEndMs:Rt(ie,e.startMs,e.endMs)})),se=new Set(t.camera.map(e=>e.marker.actionId));for(let e of t.zoomsSkipped??[])se.has(e.actionId)||`afterActionId`in e&&!se.has(e.afterActionId)||l.push(Je(e));let C=new Map((i?.cosmetics??[]).map(e=>[e.id,e])),ce=t.edits.masks.map(e=>{let t=e.start===void 0||e.end===void 0,r=C.get(e.id),a=r?.range??null;for(let t of r?.unplaced??[])l.push(`The ${t} of mask "${e.id}" is placed from the 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. ${s(`to give it measured timing`)}`);let o=t?0:a?a.startMs:e.start?Math.max(0,Ft(n,e.start)):0,u=t?c:a?a.endMs:e.end?Math.min(c,Ft(n,e.end)):c;return{id:e.id,startMs:o,endMs:u,rect:e.rect,wholeTake:t,timing:t||i&&a&&p(e.start)===`rendered`&&p(e.end)===`rendered`?`rendered`:`estimated`,startMarker:e.start??null,endMarker:e.end??null}}),le=e=>i?_(i.timeline,e):e,ue=(r?.degradations??[]).map(e=>({startMs:le(e.startMs),endMs:le(e.endMs)}));for(let e of r?.degradations??[])l.push(Mt(e.kind,e.note,a,o));let de=i?.timeline.unplacedPaces??0;if(de>0){let e=de===1?`pause`:`pauses`;l.push(`pacingUnplaced: ${de} recorded ${e} could not be placed. The last render carried no marker for the steps they sit between, so this video is shorter than the take by however long those ${e} were. ${s(`to restore them`)}`)}let fe=i?.timeline.nonMonotonicPaces??0;if(fe>0){let e=fe===1?`pair`:`pairs`;l.push(`pacingBackwards: ${fe} step ${e} in this take carry timestamps that run backwards, so the take's order is not its time order. A re-shoot counts the pause across ${fe===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:pe,joins:me,unplacedSplits:he}=r!==null&&i!==null?wt(t,r,i.timeline):{pieces:[],joins:[],unplacedSplits:[]};for(let e of he)l.push(`A split is not drawn: the last render carried no marker for its step. ${s(`to place it`)}`);return{clip:{durationMs:c,trim:v,ticks:m,degraded:ue,pieces:pe,joins:me},zooms:ae,masks:ce,durationMs:c,timeSource:n.hasBundle?`rendered`:`captured`,authored:a,rerunLine:o,hoverCheck:{failed:e.hoverReport?.failed??!1,unchecked:e.hoverReport?.unchecked??0},notices:l,zoomDefaultMs:S,zoomInMs:ee}}function Lt(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 Rt(e,t,n){return Math.min(n,...e.filter(e=>e.startMs>t).map(e=>e.departMs))}function D(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 zt(e){let{resolved:t,outputTimeMs:n,presentation:r,target:i,viewport:a}=e;return g(se(t,n),c(r.frameRect,a),r.frameRect,a,i)}var Bt=(e,t,n)=>Math.min(n,Math.max(t,e));function Vt(e,t){let n=e.width/2,r=e.height/2;return{x:Bt(t.x-n/2,0,e.width-n),y:Bt(t.y-r/2,0,e.height-r),width:n,height:r}}function Ht(e){let{rect:t,resolved:n,target:r,presentation:i,outputTimeMs:a}=e,o=n.plan.viewport,s=zt({resolved:n,outputTimeMs:a,presentation:i,target:r,viewport:o});return te(t,s,i.frameRect,o)}function Ut(e){let{rect:t,resolved:n,target:r,presentation:i,outputTimeMs:a}=e,o=n.plan.viewport,s=zt({resolved:n,outputTimeMs:a,presentation:i,target:r,viewport:o}),c=u(t,s,i.frameRect,o),l=Bt(c.x,0,o.width),d=Bt(c.y,0,o.height),f=Bt(c.x+c.width,0,o.width),p=Bt(c.y+c.height,0,o.height);return{x:l,y:d,width:f-l,height:p-d}}function Wt(e){let{zoom:t,resolved:n,viewport:r,presentation:i,target:a}=e,o=zt({resolved:n,outputTimeMs:(t.startMs+t.endMs)/2,presentation:i,target:a,viewport:r});return u({x:0,y:0,width:a.width,height:a.height},o,i.frameRect,r)}var Gt=2e3,Kt=e=>e!==null&&e.kind===`refusal`,O=e=>({kind:`refusal`,reason:e});function qt(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=l(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=m(e.resolved.cursor,n);return r?{point:r}:{reason:`the pointer was not observed here`}}var Jt=(e,t)=>e.zooms.find(e=>e.id===t),Yt=(e,t)=>e.masks.find(e=>e.id===t);function Xt(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=Zt(a,i,n,r);if(e)return{zoom:a,why:e}}}function Zt(e,t,n,r){let i=Math.abs(n-e.startMs);if(i<qe&&(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 Qt({zoom:e,why:t}){switch(t){case`start`:return O(`That would start it within ${qe}ms of the zoom "${e.id}" at ${$t(e.startMs)}; the camera needs ${qe}ms between two zooms to glide from one to the other.`);case`endsAfter`:return O(`That would end it after the zoom "${e.id}" starts at ${$t(e.startMs)}; a zoom can stay in until the next one, not past it.`);case`startsInside`:return O(`That would start it before the zoom "${e.id}" ends at ${$t(e.endMs)}; drag that zoom's end earlier first.`)}}var $t=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 en(e){let{leadInMs:t}=i;return{earliestMs:e+t,latestMs:e}}function tn(e,t){let{leadInMs:n}=i,r=e.zoomDefaultMs-n,a=(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}},o=t=>{let{earliestMs:n,latestMs:r}=en(t);return e.zooms.find(e=>Zt(e,void 0,n,null)!==void 0||Zt(e,void 0,r,null)!==void 0)},s=o(t);if(!s)return a(t,null);let c=s;for(let t=0;t<=e.zooms.length&&c;t++){let t=Math.max(c.startMs+qe,c.endAuthored?c.endMs:-1/0)-n;if(t+r+n>e.durationMs)break;let i=o(t);if(!i)return a(t,{zoom:c,side:`after`});c=i}c=s;for(let t=0;t<=e.zooms.length&&c;t++){let e=c.startMs-qe;if(en(e).earliestMs<0)break;let t=o(e);if(!t)return a(e,{zoom:c,side:`before`});c=t}return O(`There is no room for a zoom here: it would run into the zoom "${s.id}" at ${$t(s.startMs)}, and there is no slot either side of it. Drag that zoom to make space, or remove one.`)}function nn(e,t){let{trim:n}=e.clip;if(t>n.tailMs-200)return O(`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+Gt,e.durationMs)}}function k(e,t){return t!==null&&e.actionId===t.actionId&&t.offsetMs<=e.offsetMs}var rn=e=>O(`That would leave the ${e} no length; drag its end further.`),an=e=>O(`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 on(e,t){let n=e.clip.ticks,r=n.findIndex(e=>e.actionId===t);return r===-1?void 0:n[r+1]}function sn(e,t,n,r){let{durationMs:a}=e;if(e.clip.ticks.length===0)return O(`This take has no steps to attach an edit to.`);switch(n.kind){case`pieceEdge`:return Ot(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 O(`The cut would leave nothing: the head has to stay at least 200ms before the tail.`);let r=D(e,n.toMs,n.snapMs);return k(r,t.tailMarker)?an(`head`):{kind:`setTrim`,head:r}}if(n.toMs>=a)return{kind:`setTrim`,tail:null};if(n.toMs<t.headMs+200)return O(`The cut would leave nothing: the tail has to stay at least 200ms after the head.`);let r=D(e,n.toMs,n.snapMs);return t.headMarker&&k(t.headMarker,r)?an(`tail`):{kind:`setTrim`,tail:r}}case`addZoom`:{let a=tn(e,n.atMs);if(Kt(a))return a;let{atMs:o,movedPast:s}=a,c=D(e,o,s?0:n.snapMs),l=s?`Placed ${s.side} the zoom at ${$t(s.zoom.startMs)}: there was no room at ${$t(n.atMs)}.`:null,u=i.defaultZoomScale,d=qt(r,o);if(`point`in d)return{kind:`addZoom`,marker:c,target:{kind:`point`,x:d.point.x,y:d.point.y},scale:u,...l===null?{}:{note:l}};let f=[...e.clip.ticks].filter(e=>e.canZoom).sort((e,t)=>Math.abs(e.atMs-o)-Math.abs(t.atMs-o))[0],p=f?t.beats.find(e=>e.actionId===f.actionId)?.anchorId:null;if(!f||!p)return O(`There is nothing to aim at here: ${d.reason}, and no step on this take has an element on screen.`);let m={kind:`element`,anchorId:p},h=`Aimed at "${f.label}" instead of the cursor: ${d.reason}.`;return{kind:`addZoom`,marker:c,target:m,scale:u,note:l?`${l} ${h}`:h}}case`moveZoom`:{let t=Jt(e,n.id);if(!t)return O(`There is no zoom "${n.id}" to move.`);if(n.deltaMs===0)return null;let r=t.startMs+n.deltaMs,i=t.endMs+n.deltaMs;if(r<0)return O(`A zoom cannot start before the take does.`);if(i>a)return O(`A zoom cannot end after the take does.`);let o=Xt(e,t.id,r,t.endAuthored?i:null);if(o)return Qt(o);let s=D(e,r,n.snapMs),c=t.endAuthored?D(e,i,n.snapMs):null;return k(s,c)?rn(`zoom`):{kind:`setZoomRange`,id:t.id,start:s,end:c}}case`zoomEdge`:{let t=Jt(e,n.id);if(!t)return O(`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 O(`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 O(`Zooming in from there, it would land at ${$t(i)}, after its end at ${$t(t.endMs)}. Drag the end later first.`);let a=Xt(e,t.id,i,null);if(a)return Qt(a);let o=D(e,r,n.snapMs),s={...o,offsetMs:o.offsetMs+e.zoomInMs},c=t.endMarker;return k(s,c)?rn(`zoom`):{kind:`setZoomRange`,id:t.id,start:s,end:c}}if(n.toMs>a)return O(`A zoom cannot end after the take does.`);if(n.toMs<t.startMs+100)return O(`A zoom's end cannot cross its start; it would end before it starts. Drag the start earlier first.`);let r=Xt(e,t.id,t.startMs,n.toMs);if(r)return Qt(r);let i=t.marker,o=D(e,n.toMs,n.snapMs);return k(i,o)?rn(`zoom`):{kind:`setZoomRange`,id:t.id,start:i,end:o}}case`addMask`:{let t=nn(e,n.atMs);if(Kt(t))return t;let{endMs:i}=t,a=qt(r,n.atMs),o=`point`in a?a.point:{x:r.viewport.width/2,y:r.viewport.height/2},s=Vt(r.viewport,o),c=D(e,n.atMs,n.snapMs),l=D(e,i,n.snapMs);if(k(c,l)){let t=on(e,c.actionId);if(!t)return O(`That would leave the mask no length; move the playhead earlier.`);l={actionId:t.actionId,offsetMs: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=Yt(e,n.id);if(!t)return O(`There is no mask "${n.id}" to move.`);if(t.wholeTake||t.startMarker===null||t.endMarker===null)return O(`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 r=t.startMs+n.deltaMs,i=t.endMs+n.deltaMs;if(r<0)return O(`A mask cannot start before the take does.`);if(i>a)return O(`A mask cannot end after the take does.`);let o=D(e,r,n.snapMs),s=D(e,i,n.snapMs);return k(o,s)?rn(`mask`):{kind:`setMaskRange`,id:t.id,start:o,end:s}}case`maskEdge`:{let t=Yt(e,n.id);if(!t)return O(`There is no mask "${n.id}" to resize.`);if(t.wholeTake||t.startMarker===null||t.endMarker===null)return O(`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 O(`A mask cannot start before the take does.`);if(n.toMs>t.endMs-100)return O(`A mask cannot start after it ends; drag its end later first.`);let r=D(e,n.toMs,n.snapMs),i=t.endMarker;return k(r,i)?rn(`mask`):{kind:`setMaskRange`,id:t.id,start:r,end:i}}if(n.toMs>a)return O(`A mask cannot end after the take does.`);if(n.toMs<t.startMs+100)return O(`A mask cannot end before it starts; drag its start earlier first.`);let r=t.startMarker,i=D(e,n.toMs,n.snapMs);return k(r,i)?rn(`mask`):{kind:`setMaskRange`,id:t.id,start:r,end:i}}}}function cn(e,t,n){let r=e.beats.find(e=>e.actionId===t);return r===void 0?O(`There is no step "${t}" to pace.`):r.isLast?O(`"${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?O(`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}:O(`A pause has to be a number of milliseconds.`)}function ln(e){return e.actions.map(e=>e.id).join(` `)}function un(e){return{bundle:e.bundle,actionIds:ln(e.scene)}}function dn(e,t){return e!==null&&t.bundle===e.bundle&&ln(t.scene)===e.actionIds&&t.hoverReport!==null}var fn={removable:[],checked:0,unchecked:0,failed:!0};function pn(e){return e.kind!==`unknown`||e.reason!==`notStyleSignalled`}function mn(e,t){let n=e.filter(pn).filter(e=>!t.has(e.actionId)),r={};for(let e of n)e.kind===`unknown`&&(r[e.reason]=(r[e.reason]??0)+1);return{removable:n.flatMap(e=>e.kind===`still`?[e.actionId]:[]),checked:n.filter(e=>e.kind!==`unknown`).length,unchecked:n.filter(e=>e.kind===`unknown`).length,uncheckedBy:r,failed:!1}}var hn={notStyleSignalled:{one:`was not a style hover`,many:`were not style hovers`},noMarker:{one:`had no place on the timeline`,many:`had no place on the timeline`},noRect:{one:`had no recorded position`,many:`had no recorded position`},crossFrameRect:{one:`was inside an embedded frame`,many:`were inside an embedded frame`},degenerateRect:{one:`had a zero-size target`,many:`had a zero-size target`},offFrame:{one:`was partly off screen`,many:`were partly off screen`},cropTooSmall:{one:`was too small to compare`,many:`were too small to compare`},nativeCropTooSmall:{one:`was too small in the recorded frames to compare`,many:`were too small in the recorded frames to compare`},sameFrame:{one:`had only one frame around it`,many:`had only one frame around them`},outOfTolerance:{one:`had no frame close enough to the hover`,many:`had no frame close enough to the hover`},decodeFailed:{one:`had a frame that would not decode`,many:`had frames that would not decode`}};function gn(e){return Object.entries(e.uncheckedBy??{}).filter(([,e])=>e>0).sort((e,t)=>t[1]-e[1]).map(([e,t])=>{let n=hn[e];return`${t} ${t===1?n.one:n.many}`}).join(`, `)}function _n(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=gn(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 vn(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 yn(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 bn(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 xn(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 Sn(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=xn(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 Cn(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 wn(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 A(e){let t=Math.max(0,Math.floor(e/1e3)),n=t%60;return`${Math.floor(t/60)}:${String(n).padStart(2,`0`)}`}function Tn(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 En(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 Dn(e,t){return e===null||[...new Set([...Object.keys(t),...Object.keys(e)])].some(n=>t[n]!==e[n])}function On(e,t){return e===null||e.smoothness!==t.smoothness||e.blur!==t.blur||e.follow!==t.follow}function kn(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 An(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 jn(){let e=new Map;return{isOpen:(t,n)=>e.get(t)??n,set:(t,n)=>{e.set(t,n)}}}var Mn={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`},Nn={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`},Pn=new Set([`debuggerDetached`,`debuggerLost`,`debuggerRecovered`]),Fn=e=>Object.hasOwn(Nn,e)?Nn[e]:e;function In(e){let t=Mn[e];if(t!==void 0)return t;let n=e.indexOf(`:`);if(n>0){let t=e.slice(0,n),r=Mn[t],i=e.slice(n+1);if(r!==void 0&&i!==``)return`${r} — ${Pn.has(t)?Fn(i):i}`}return e}function Ln(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`${In(e.reason)}${n}`}var Rn={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 zn(e){return e===null||e.reason===null?!1:Rn[e.reason]===!0}function Bn(e,t,n){if(e===null||e.reason===null||!t.mayReplay||e.reason===`mutating`)return null;let r=Qe(e.reason),i=n!==void 0&&nt(n),a=i?`The script run`:`The re-shoot`,o=i?`performed`:`reconstructed`,s=n?tt(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 ${rt(i)} to try again.`:`${a} ${o} all ${e.total} steps, but: ${r}.`;let l=zn(e)?`and stopped early`:`then stopped`;return`${a} ${o} ${e.completed} of ${e.total} steps ${l}: ${r}.${c}`}function j(e,t){let n=e.actions.findIndex(e=>e.id===t);if(n===-1)throw Error(`unknown action "${t}"`);return n}function Vn(e,t){let n=e.camera.find(e=>e.id===t);if(!n)throw Error(`unknown zoom "${t}"`);return n}var Hn=1,Un=e=>Error(`1:1 is not a zoom — remove the zoom instead of authoring ${e}`);function Wn(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]:(j(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(j(e,t.marker.actionId),t.scale<=1)throw Un(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 a=r.kind===`element`&&t.marker.offsetMs===0?i.leadInMs:t.marker.offsetMs,o={id:n(),kind:`zoom`,...r.kind===`element`?{anchorId:r.anchorId}:{point:{x:r.x,y:r.y}},marker:{actionId:t.marker.actionId,offsetMs:a},scale:t.scale,...t.note===void 0?{}:{note:t.note}};return{...e,camera:[...e.camera,o]}}case`setZoomRange`:{let n=Vn(e,t.id);j(e,t.start.actionId),t.end&&j(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=Vn(e,t.id);if(t.scale<=1)throw Un(t.scale);return{...e,camera:e.camera.map(e=>e.id===n.id?{...e,scale:t.scale}:e)}}case`setZoomTarget`:{let n=Vn(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 Vn(e,t.id),{...e,camera:e.camera.filter(e=>e.id!==t.id)};case`addMask`:return j(e,t.start.actionId),j(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(j(e,t.start.actionId),j(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<Hn||t.rect.height<Hn)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:Ee(e.branding,t.patch)};case`setCursor`:return{...e,cursor:{...e.cursor,...t.patch}};case`setMotion`:return{...e,motion:{...e.motion??oe,...t.patch}};case`setAspect`:return{...e,canvas:{...e.canvas,aspect:t.aspect}};case`split`:return j(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&&j(e,t.start.actionId),t.end&&j(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&&j(e,t.start.actionId),t.end&&j(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(j(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 Gn(e,t,n){return ue.parse(Wn(e,t,n))}function Kn(e){return{scene:e,past:[],future:[],error:null,dirty:!1,hoverReport:null}}function qn(e,t,n){let r;try{r=Gn(e.scene,t,n)}catch(t){return{...e,error:t instanceof Error?t.message:String(t)}}return t.kind===`setBranding`&&ye(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 Jn(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 Yn(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 Xn(e){return{...e,dirty:!1}}var Zn={mayReplay:!0};function Qn(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 $n(e,t){return e.meta===void 0||e.flags===void 0?!1:Qn(e)===Qn(t)}function er(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(Qn(e)),JSON.parse(Qn(t)),`scene`)}function tr(e,t){let{renderMode:n,...r}=e.meta;return{...e,meta:t.meta.renderMode===void 0?r:{...r,renderMode:t.meta.renderMode}}}function nr(e,t){return{...tr(e,t),flags:{...e.flags,hoverSensitive:t.flags.hoverSensitive}}}function rr(e){let t=Kn({}),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:Bn(i,Zn,t.scene),replayRecoverable:zn(i),captureSentence:a===null||n!==null&&n.source!==`capture`?null:Ln(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=tr(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=$n(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 ${er(t.scene,o)}`),t=c?{...Kn(o),past:t.past.map(e=>nr(e,o)),future:t.future.map(e=>nr(e,o))}:Kn(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=qn(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=Xn(t),u()})},async undo(){await c(async()=>{let e=Jn(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=Xn(t),u()})},async redo(){await c(async()=>{let e=Yn(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=Xn(t),u()})},async settled(){let e;do e=s,await e;while(e!==s)},setHoverReport(e){t={...t,hoverReport:e},u()}}}var ir=1.2;function ar(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:ir}:null:n===`-`||n===`_`?t.hasTimeline?{kind:`zoomTimeline`,factor:1/ir}:null:r===`z`&&e.shiftKey?t.hasTimeline?{kind:`zoomFit`}:null:r===`s`?{kind:`toggleSnapping`}:n===`Escape`?t.hasSelection?{kind:`clearSelection`}:t.panelOpen?{kind:`closePanel`}:null:n===`?`?{kind:`toggleHelp`}:null}var or={Mod:{label:{mac:`⌘`,other:`Ctrl`},spoken:{mac:`Command`,other:`Control`}},Shift:{label:{mac:`⇧`,other:`Shift`},spoken:`Shift`},Space:{label:`Space`,spoken:`Space`},Esc:{label:`Esc`,spoken:`Escape`},Delete:{label:{mac:`⌫`,other:`Delete`},spoken:`Delete`},Home:{label:`Home`,spoken:`Home`},End:{label:`End`,spoken:`End`},Left:{label:`←`,spoken:`Left arrow`},Right:{label:`→`,spoken:`Right arrow`},Up:{label:`↑`,spoken:`Up arrow`},Down:{label:`↓`,spoken:`Down arrow`}},sr=(e,t)=>typeof e==`string`?e:t?e.mac:e.other;function cr(e,t){let n=or[e];return n===void 0?e:sr(n.label,t)}var lr=new Set([`⌘`,`⇧`,`⌫`,`←`,`→`,`↑`,`↓`]);function ur(e){return lr.has(e)}function dr(e,t){let n=or[e];return n===void 0?e:sr(n.spoken,t)}function fr(e,t){return e.map(e=>dr(e,t)).join(` plus `)}function pr(e){return/\bMac/i.test(e)}function mr(e,t){return sr(e.description,t)}var hr=[{group:`Playback`,combos:[[`Space`]],description:`Play / pause`,action:`playPause`},{group:`Playback`,combos:[[`J`],[`L`]],description:`Shuttle back / forward`,action:`shuttle`},{group:`Playback`,combos:[[`K`]],description:`Stop`,action:`stop`},{group:`Playback`,combos:[[`Left`],[`Right`]],description:`Nudge playhead`,action:`nudge`},{group:`Playback`,combos:[[`Shift`,`Left`],[`Shift`,`Right`]],description:`Nudge half a second`,action:`nudge`},{group:`Playback`,combos:[[`Mod`,`Left`],[`Mod`,`Right`]],description:`Jump to start / end`,action:`seekEdge`},{group:`Steps`,combos:[[`Up`],[`Down`]],description:`Previous / next step`,action:`stepBeat`},{group:`Steps`,combos:[[`Esc`]],description:`Clear selection`,action:`clearSelection`},{group:`Trim`,combos:[[`I`],[`O`]],description:`Trim start / end to playhead`,action:`setTrim`},{group:`Editing`,combos:[[`Mod`,`B`]],description:`Split at playhead`,action:`split`},{group:`Editing`,combos:[[`Delete`]],description:`Delete the selected piece, 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 gr(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 _r=[`nw`,`n`,`ne`,`e`,`se`,`s`,`sw`,`w`],vr=3;function yr(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 br(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 xr(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=gr(t.canvas),s={resolved:i,target:t.target,presentation:a,outputTimeMs:t.outputTimeMs};if(r.kind===`mask`){let i=t.model.masks.find(e=>e.id===r.id);if(!i)return;let a=w(`div`,`overlay`);a.setAttribute(`data-overlay`,`mask`);let c=Ht({rect:i.rect,...s});yr(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)>vr&&(l=!0),c=br(r,t,(n.clientX-e.clientX)/o.scale,(n.clientY-e.clientY)/o.scale),yr(a,c,o)},d=()=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),l&&n.onMaskRect(i.id,Ut({rect:c,...s}))};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d)})};l(a,`body`);for(let e of _r){let t=w(`div`,`grip`);t.setAttribute(`data-handle`,e),l(t,e),a.append(t)}e.append(a);return}if(r.kind!==`zoom`)return;let c=t.model.zooms.find(e=>e.id===r.id);if(!c)return;let l=w(`div`,`overlay`);l.setAttribute(`data-overlay`,`zoom`);let u=Ht({rect:Wt({zoom:c,resolved:i,viewport:i.plan.viewport,presentation:a,target:t.target}),...s});yr(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)>vr&&(r=!0),u=br(t,`body`,(n.clientX-e.clientX)/o.scale,(n.clientY-e.clientY)/o.scale),yr(l,u,o)},a=()=>{if(window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,a),!r)return;let e=Ut({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 Sr(t){let{scene:n,resolved:r,bundle:a=null}=t,o=new Map(n.anchors.map(e=>[e.id,e])),s=new Map(r?r.plan.cameraIntents.map(e=>[e.actionId,{id:e.id,scale:e.scale,offsetMs:e.offsetMs}]):n.camera.map(e=>[e.marker.actionId,{id:e.id,scale:e.scale??i.defaultZoomScale,offsetMs:e.marker.offsetMs}])),c=new Map((n.edits.gaps??[]).map(e=>[e.afterActionId,e])),l=new Map((n.edits.holds??[]).map(e=>[e.marker.actionId,e])),u=r?new Set(r.plan.removedSteps??[]):e(n),d=new Map((a?.markers??[]).map(e=>[e.actionId,e.sourceTimeMs])),f=(e,t)=>{if(r===null||a===null||!pe(a)||re(a,e.id))return!0;let n=d.get(e.id),i=d.get(t.id);return n===void 0||i===void 0||r.timeline.segments.some(e=>e.kind===`idle`&&e.srcEndMs>e.srcStartMs&&n<=e.srcStartMs&&e.srcEndMs<=i)},p=e=>{if(r===null)return 0;let t=0;for(let n of r.timeline.segments)n.kind===`pace`&&(Math.abs(n.srcStartMs-e)>1e-6||(t+=n.outEndMs-n.outStartMs));return t},m=(e,t)=>{if(t===void 0)return 0;if(r===null||a===null)return null;let n=d.get(e.id),i=d.get(t.id);if(n===void 0||i===void 0)return null;let o=p(i);for(let e of r.timeline.segments)e.kind===`idle`&&n<=e.srcStartMs&&e.srcEndMs<=i&&(o+=e.outEndMs-e.outStartMs);return o},h=(e,t)=>{if(t===void 0||r===null||a===null||pe(a))return null;let n=d.get(t.id);return d.get(e.id)===void 0||n===void 0?null:p(n)},g=n.actions.length-1;return{beats:n.actions.map((e,t)=>{let i=e.anchorId?o.get(e.anchorId):void 0,v=s.get(e.id),y=c.get(e.id),b=l.get(e.id),x=n.actions[t+1],S=d.get(e.id);return{actionId:e.id,index:t,verb:e.kind,anchorId:e.anchorId,label:$e(i),text:e.kind===`type`?e.text:null,redacted:e.kind===`type`&&e.redacted,host:e.kind===`type`&&e.host===!0,strategy:i?.resolution.strategy??null,outputMs:r?_(r.timeline,S??e.timestamp):null,timing:S===void 0?`estimated`:`rendered`,captureMs:e.timestamp,camera:v??null,canZoom:e.anchorId!==null,gap:y?{durationMs:y.durationMs}:null,canPace:x!==void 0&&f(e,x),renderedPauseMs:m(e,x),renderedPaceFreezeMs:h(e,x),renderedFreezeBeforeMs:a!==null&&!pe(a)&&S!==void 0&&r!==null&&S<r.timeline.sourceDurationMs?p(S):0,legacyHold:b?{offsetMs:b.marker.offsetMs,durationMs:b.durationMs}:null,cut:u.has(e.id),isLast:t===g}}),outputDurationMs:r?.timeline.outputDurationMs??null,hasBundle:r!==null}}var Cr=(e,t,n)=>Math.min(n,Math.max(t,e)),wr=e=>({startMs:0,endMs:Math.max(250,e)}),M=(e,t)=>(t-e.startMs)/(e.endMs-e.startMs),Tr=(e,t)=>e.startMs+t*(e.endMs-e.startMs);function Er(e,t,n,r){let i=Math.max(250,r),a=Cr(n,250,i),o=Cr(e-t*a,0,i-a);return{startMs:o,endMs:o+a}}function Dr(e,t,n,r){return Er(Tr(e,r),r,(e.endMs-e.startMs)/n,t)}function Or(e,t,n){let r=e.endMs-e.startMs;return Er(e.startMs+n,0,r,t)}var kr=(e,t,n,r)=>Er(Tr(e,r),r,n,t);function Ar(e,t){let n=Math.max(250,e);return n*(250/n)**Cr(t,0,1)}function jr(e,t){let n=Math.max(250,e);if(n<=250)return 0;let r=Cr(t,250,n);return Math.log(r/n)/Math.log(250/n)}function Mr(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 Nr(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=pr(navigator.userAgent);e.setAttribute(`aria-keyshortcuts`,n.map(e=>Mr(e,r)).join(`+`))}function Pr(e){delete e.dataset.tip,delete e.dataset.tipKeys,e.removeAttribute(`aria-keyshortcuts`)}var Fr=Symbol.for(`demoman.tooltip`);function Ir(e=document){let t=e,n=t[Fr];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[Fr]={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=pr(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=cr(n,r),a=e.createElement(`kbd`);a.className=`keycap`,a.textContent=i,ur(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 Lr(){let e=w(`div`,`demo-panel`);e.setAttribute(`data-export-panel`,``),e.append(w(`h2`,void 0,`Export`));let t=w(`div`);return t.setAttribute(`data-panel-export`,``),e.append(t),e}function Rr(){let e=w(`div`,`demo-panel`);e.setAttribute(`data-background-panel`,``),e.append(w(`h2`,void 0,`Background`));let t=w(`div`);return t.setAttribute(`data-panel-branding`,``),e.append(t),e}function zr(){let e=w(`div`,`demo-panel`);e.setAttribute(`data-shortcuts-panel`,``),e.append(w(`h2`,void 0,`Keyboard shortcuts`));let t=w(`div`);return t.setAttribute(`data-panel-shortcuts`,``),e.append(t),e}function Br(){let e=w(`div`,`demo-panel`);e.setAttribute(`data-cursor-panel`,``),e.append(w(`h2`,void 0,`Cursor`));let t=w(`div`);return t.setAttribute(`data-panel-cursor`,``),e.append(t),e}function Vr(e,t,n){let r=w(`div`,`beat-panel`);r.setAttribute(`data-step-panel`,e.actionId);let i=w(`h2`);if(i.append(w(`span`,`verb`,e.verb),` `,e.label),e.strategy){let t=w(`span`,`chip`,e.strategy);t.setAttribute(`data-health`,e.strategy),i.append(` `,t)}r.append(i);let a=w(`div`);if(e.verb===`type`){if(e.redacted)a.append(w(`div`,`redacted`,e.host?`This was typed into an editor, and an edit the sensor does not follow landed mid-field, so the text is unknown.`:`This value was never recorded — a credential field, or text that looked like a secret.`));else{let t=w(`div`,`control-row`),n=w(`span`,void 0,e.text??``);n.setAttribute(`data-typed-text`,e.actionId),t.append(w(`span`,`control-label`,`Typed text`),n),a.append(t)}}e.timing===`estimated`&&a.append(w(`div`,`muted`,`Not in the video: the frames have no marker for this step, so the timeline places it from the take's own timestamp.`)),a.hasChildNodes()&&r.append(a);let o=w(`div`,`control-actions`);if(!e.canZoom)o.append(w(`span`,`muted`,`No zoom — nothing on screen to aim at`));else{let t=w(`button`,`btn btn-quiet`,`Zoom on this step`);t.type=`button`,t.setAttribute(`data-zoom-on-step`,e.actionId),t.addEventListener(`click`,()=>n.onZoomOnStep(e.actionId)),o.append(t)}r.append(o);let s=()=>{let t=w(`button`,`btn btn-quiet`,`Use recorded`);return t.type=`button`,t.setAttribute(`data-gap-clear`,e.actionId),t.setAttribute(`aria-label`,`Restore the recorded pause after ${e.label}`),t.addEventListener(`click`,()=>n.onGapClear(e.actionId)),t},c=e.isLast?`This is the last step, and a pause is the time between two steps.`:e.canPace?null:`This step runs straight into the next one, with no dead air between them to stretch.`;if(c===null){let t=w(`label`,`control-row`),i=w(`input`);i.type=`number`,i.min=`0`,i.step=`100`,i.value=e.gap===null?``:String(e.gap.durationMs),i.placeholder=`recorded`,i.setAttribute(`data-gap`,e.actionId),i.setAttribute(`aria-label`,`Pause after ${e.label}, in milliseconds. Empty plays back the recorded pause.`),i.addEventListener(`change`,()=>{let t=i.value.trim();t===``?n.onGapClear(e.actionId):n.onGap(e.actionId,Number(t))});let a=w(`span`,`control-inline`);if(a.append(i,w(`span`,void 0,`ms`)),e.gap!==null&&a.append(s()),t.append(w(`span`,`control-label`,`Pause after this step`),a),r.append(t),e.gap!==null&&e.gap.durationMs>0&&e.renderedPaceFreezeMs===0){let t=w(`div`);t.setAttribute(`data-gap-floored`,e.actionId),t.append(w(`span`,void 0,`A ${e.gap.durationMs}ms pause is set here, but the re-shot frames already leave at least that long between these two steps, so it adds nothing to this video. Pacing only ever adds time — it never speeds your app up. Raise it, or go back to your recording from its Recordings card, where this number is the pause.`)),r.append(t)}}else if(e.gap!==null){let t=w(`div`);t.setAttribute(`data-gap-inert`,e.actionId),t.append(w(`span`,void 0,`A ${e.gap.durationMs}ms pause is set here but is not playing. ${c}`),s()),r.append(t)}if(e.legacyHold!==null){let t=e.legacyHold.offsetMs===0?`after this step`:`${e.legacyHold.offsetMs}ms into this step`,n=e.timing===`rendered`?`still plays ${t}`:`is set ${t}, but nothing has rendered that step, so it is not in the video you have`,i=w(`div`);i.setAttribute(`data-legacy-hold`,e.actionId),i.append(w(`span`,void 0,`A ${e.legacyHold.durationMs}ms pause from an earlier edit ${n}. There is no control for it: deleting this step removes it, and nothing else in the editor does.`)),r.append(i)}if(e.cut){let n=w(`div`);n.setAttribute(`data-cut-panel`,e.actionId),n.append(w(`p`,`honesty`,`This step is in a removed piece, so it is not in the video.`));let i=t.attachedToCuts.filter(t=>t.actionId===e.actionId);if(i.length>0){let t=[...i].map(e=>e.kind).sort(),r=i.length===1,a=w(`p`,`muted`,`${i.length} edit${r?``:`s`} on this step (${t.join(`, `)}) ${r?`is`:`are`} kept and not drawn. Restoring the piece brings ${r?`it`:`them`} back.`);a.setAttribute(`data-cut-attached`,e.actionId),n.append(a)}r.append(n)}let l=w(`div`,`control-actions`);if(t.hoverReport?.removable.includes(e.actionId)??!1){let t=w(`button`,`btn btn-quiet`,`Keep this hover`);t.type=`button`,t.setAttribute(`data-keep-hover`,e.actionId),t.addEventListener(`click`,()=>n.onKeepHover(e.actionId)),l.append(t)}return l.hasChildNodes()&&r.append(l),r}function Hr(e,t,n){let r=w(`div`,`zoom-panel`);r.setAttribute(`data-zoom-panel`,e.id),r.append(w(`h2`,void 0,`Zoom`));let a=w(`input`);a.type=`range`,a.min=`1.1`,a.max=String(i.maxScale),a.step=`0.05`,a.value=String(e.scale),a.setAttribute(`data-zoom-scale`,e.id),a.setAttribute(`aria-label`,`Zoom level`),Ae(a),a.addEventListener(`input`,()=>Ae(a)),a.addEventListener(`change`,()=>n.onZoomScale(e.id,Number(a.value)));let o=w(`div`,`slider-row`);o.append(w(`span`,`control-label slider-label`,`Level`),w(`span`,`slider-value`,`${e.scale.toFixed(2)}x`),a),r.append(o);let s=w(`div`);if(s.setAttribute(`data-zoom-aim`,``),e.target.kind===`element`){let{anchorId:n}=e.target,r=t.scene.anchors.find(e=>e.id===n);s.textContent=`Aims at ${r?$e(r):n}`}else s.textContent=`Aims at the cursor at ${A(e.startMs)}`;if(r.append(s),e.aimFallback!==null){let t=w(`div`,`muted`,e.aimFallback);t.setAttribute(`data-zoom-fallback`,``),r.append(t)}let c=w(`div`);c.setAttribute(`data-zoom-range`,``),c.textContent=`${A(e.startMs)} to ${A(e.endMs)}${e.endAuthored?``:` (end automatic; drag its cap to set one)`}`,r.append(c),e.clamped&&r.append(w(`div`,`muted`,`The end you set could not be reached; see the note under the timeline.`)),e.timing===`estimated`&&r.append(w(`div`,`muted`,`Estimated position: the last render carried no marker for this zoom's step, or no on-screen rect for its target.`));let l=w(`button`,`btn btn-quiet`,`Remove zoom`);l.type=`button`,l.setAttribute(`data-remove-zoom`,e.id),Nr(l,`Remove zoom`,[`Delete`]),l.addEventListener(`click`,()=>n.onRemoveZoom(e.id));let u=w(`div`,`control-actions`);return u.append(l),r.append(u),r}function Ur(e,t,n){let r=w(`div`,`mask-panel`);r.setAttribute(`data-mask-panel`,e.id),r.append(w(`h2`,void 0,`Mask`));let i=w(`div`);i.setAttribute(`data-mask-rect`,``),i.textContent=`${Math.round(e.rect.width)}x${Math.round(e.rect.height)} at ${Math.round(e.rect.x)}, ${Math.round(e.rect.y)}`,r.append(i);let a=w(`input`);a.type=`text`,a.placeholder=`What this hides`,a.value=t.scene.edits.masks.find(t=>t.id===e.id)?.note??``,a.setAttribute(`data-mask-note`,e.id),a.setAttribute(`aria-label`,`Mask note`),a.addEventListener(`change`,()=>n.onMaskNote(e.id,a.value));let o=w(`label`,`control-row`);o.append(w(`span`,`control-label`,`Note`),a),r.append(o);let s=w(`div`);s.setAttribute(`data-mask-range`,``),e.wholeTake?(s.setAttribute(`data-mask-whole-take`,``),s.textContent=`Covers the whole take (made before masks had a range).`):s.textContent=`${A(e.startMs)} to ${A(e.endMs)}`,r.append(s),r.append(w(`p`,`honesty`,`Masks are opaque fills stored in the page's own coordinates and re-applied on every render — non-destructive as layers, absolute as pixels.`));let c=w(`button`,`btn btn-quiet`,`Remove mask`);c.type=`button`,c.setAttribute(`data-remove-mask`,e.id),Nr(c,`Remove mask`,[`Delete`]),c.addEventListener(`click`,()=>n.onRemoveMask(e.id));let l=w(`div`,`control-actions`);return l.append(c),r.append(l),r}function Wr(e,t,n){let{selection:r,rail:i}=t;if(i===`shortcuts`&&e.querySelector(`:scope > .inspector > [data-shortcuts-panel]`)!==null)return;let a=w(`div`,`inspector`),o=r?.kind===`tick`?t.view.beats.find(e=>e.actionId===r.actionId):void 0,s=r?.kind===`zoom`?t.model.zooms.find(e=>e.id===r.id):void 0,c=r?.kind===`mask`?t.model.masks.find(e=>e.id===r.id):void 0,l;i===`selection`?o?l=Vr(o,t,n):s?l=Hr(s,t,n):c?l=Ur(c,t,n):(console.error(`[demoman] editor: the rail is on Selection with nothing selected`),l=Lr()):l=i===`background`?Rr():i===`cursor`?Br():i===`shortcuts`?zr():Lr();let u=w(`button`,`btn btn-icon inspector-close`);u.type=`button`,u.setAttribute(`data-inspector-close`,``),u.setAttribute(`aria-label`,`Close panel`),Nr(u,`Close`,[`Esc`]),u.append(C(`close`)),u.addEventListener(`click`,()=>n.onClose()),a.append(u,l),e.replaceChildren(a)}var Gr=[{entry:`background`,label:`Background`,glyph:`image`},{entry:`cursor`,label:`Cursor`,glyph:`mousePointer2`},{entry:`selection`,label:`Selection`,glyph:`mousePointerClick`}],Kr=`Select a step, zoom or mask on the timeline`;function qr(e,t,n){let r=Gr.map(({entry:e,label:r,glyph:i})=>{let a=w(`button`,`btn btn-icon`);a.type=`button`,a.setAttribute(`data-rail`,e),a.setAttribute(`aria-label`,r),a.setAttribute(`aria-pressed`,String(t.panelOpen&&t.rail===e));let o=e===`selection`&&!t.hasSelection;return a.disabled=o,a.title=o?Kr:r,a.append(C(i)),a.addEventListener(`click`,()=>n.onPick(e)),a});e.replaceChildren(...r)}function Jr(e,t,n){e.querySelector(`svg[data-icon]`)===null&&e.replaceChildren(C(`download`),w(`span`,void 0,`Export`)),e.setAttribute(`aria-pressed`,String(t.panelOpen&&t.rail===`export`)),e.onclick=()=>n.onPick(`export`)}function Yr(e,t,n){e.setAttribute(`aria-pressed`,String(t.panelOpen&&t.rail===`shortcuts`)),e.onclick=()=>n.onPick(`shortcuts`)}function Xr(e,t,n){switch(e.phase){case`idle`:return Se[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 Zr(e){let t=e/1048576;return t>=1?`${Math.round(t*10)/10} MB`:`${Math.max(1,Math.round(e/1024))} KB`}var Qr=1e3,$r=new Map;function ei(e){let{key:t,checked:n}=e,r=document.createElement(`span`);r.className=`switch`;let i=document.createElement(`input`);i.type=`checkbox`,i.checked=n,i.disabled=e.disabled??!1,i.setAttribute(`role`,`switch`),i.setAttribute(`aria-checked`,n?`true`:`false`);for(let[t,n]of Object.entries(e.attrs??{}))i.setAttribute(t,n);let a=document.createElement(`span`);a.className=`switch-track`,a.setAttribute(`aria-hidden`,`true`),r.append(i,a);let o=performance.now(),s=$r.get(t);if(s!==void 0&&o-s.at>Qr)$r.delete(t);else if(s!==void 0){let e=s.on===n?o-s.at:0;s.on!==n&&$r.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`),$r.set(t,{on:i.checked,at:performance.now()}),e.onChange(i.checked)}),r}function ti(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 ni(e,t){let n=t.hoverReport===null?null:_n(t.hoverReport);if(t.notices.length===0&&n===null){e.replaceChildren();return}let r=w(`div`,void 0);r.setAttribute(`data-take-notes`,``);for(let e of t.notices){let t=w(`div`,`notice`);le(t,e),t.setAttribute(`data-take-notice`,``),r.append(t)}if(n!==null){let e=w(`div`,`notice`,n);e.setAttribute(`data-hover-report`,``),r.append(e)}e.replaceChildren(r)}function ri(e,t){if(t.hasFrames){e.replaceChildren();return}let n=w(`div`,`banner`),r=w(`span`);r.append(ii(t.route)),n.append(r),e.replaceChildren(n)}function ii(e){let t=document.createDocumentFragment();return t.append(`This take has no frames — `,ai(e,rt(e.authored))),t}function ai(e,t){if(e.rerun.kind===`line`){let t=w(`span`);return le(t,e.rerun.text),t.setAttribute(`data-rerun-line`,``),t}let n=w(`a`,void 0,t);return n.setAttribute(`href`,e.rerun.href),n.setAttribute(`data-runs-route`,``),n}function oi(e,t){let n=[];if(t.openError!=null){let e=w(`div`,`notice`);e.setAttribute(`data-open-error`,``),e.append(w(`strong`,void 0,`This take could not be opened`)),e.append(w(`div`,void 0,t.openError)),n.push(e)}if(t.replaySentence!==null){let e=w(`div`,`notice`);e.setAttribute(`data-replay-failure`,``);let r=t.runsRoute?.authored===!0?`script run`:`re-shoot`;if(e.append(w(`strong`,void 0,t.replayRecoverable===!0?`The last ${r} stopped early`:`The last ${r} did not finish`)),e.append(w(`div`,void 0,t.replaySentence)),t.runsRoute!=null){let n=w(`div`);n.setAttribute(`data-replay-runs-route`,``),n.append(ai(t.runsRoute,gt(t.runsRoute.authored))),e.append(n)}n.push(e)}if(t.captureSentence!=null){let e=w(`div`,`notice`);e.setAttribute(`data-capture-note`,``),e.append(w(`strong`,void 0,`What this take recorded`)),e.append(w(`div`,void 0,t.captureSentence)),n.push(e)}if(t.renderError!=null){let e=w(`div`,`notice`);e.setAttribute(`data-render-error`,``),e.append(w(`strong`,void 0,`The export did not start`)),e.append(w(`div`,void 0,t.renderError)),n.push(e)}if(t.previewError!=null){let e=w(`div`,`notice`);e.setAttribute(`data-preview-error`,``),e.append(w(`strong`,void 0,`The preview stopped`)),e.append(w(`div`,void 0,t.previewError)),n.push(e)}if(t.logoLoadError!=null){let e=w(`div`,`notice`);e.setAttribute(`data-logo-load-error`,``),e.append(w(`strong`,void 0,`The logo could not be loaded`)),e.append(w(`div`,void 0,t.logoLoadError)),n.push(e)}if(t.error!==null){let e=w(`div`,`notice`);e.setAttribute(`data-action-error`,``),e.append(w(`strong`,void 0,`That edit did not go through`)),e.append(w(`div`,void 0,t.error)),n.push(e)}if(t.deleteError!=null){let e=w(`div`,`notice`);e.setAttribute(`data-delete-error`,``),e.append(w(`strong`,void 0,`This demo was not deleted`)),e.append(w(`div`,void 0,t.deleteError)),n.push(e)}if(t.navigationError!=null){let e=w(`div`,`notice`);e.setAttribute(`data-navigation-error`,``),e.append(w(`strong`,void 0,`The ${t.navigationError.page} did not open`)),e.append(w(`div`,void 0,t.navigationError.reason)),n.push(e)}e.replaceChildren(...n)}function si(e,t,n){be(e,t,n)}var ci={light:`Light`,dark:`Dark`,touch:`Touch`},li={light:1/16,dark:1/16,touch:0};function ui(e,t,n){let{height:r,hotspot:i,ink:a}=me[e],o=r*t,s={x:(a.min.x+a.max.x)/2,y:(a.min.y+a.max.y)/2};return{x:n/2-(s.x-i.x-li[e])*o,y:n/2-(s.y-i.y)*o}}var di=.6;function fi(e,t,n){return Math.min(Math.min(2,Math.max(.5,t))*di,n/me[e].height)}function pi(e,n){let r=w(`canvas`);r.width=44,r.height=44;let i=r.getContext(`2d`);if(!i)return console.error(`the cursor panel could not paint its "${e}" preview: no 2D context`),r;let a=fi(e,n,44);return p(i,ui(e,a,44),a,t,e),r}function mi(e,t,n,r,i,a,o,s){let c=w(`div`,`slider-row`),l=w(`input`);l.type=`range`,l.min=String(r),l.max=String(i),l.step=`0.05`,l.value=String(n),l.disabled=s,l.setAttribute(e,``),l.setAttribute(`aria-label`,t);let u=w(`span`,`slider-value`,a(n));Ae(l),l.addEventListener(`input`,()=>{Ae(l),u.textContent=a(Number(l.value)),o.preview(Number(l.value))}),l.addEventListener(`change`,()=>o.commit(Number(l.value)));let d=()=>{Number(l.value)===n&&o.end()};return l.addEventListener(`pointerup`,d),l.addEventListener(`pointercancel`,d),c.append(w(`span`,`control-label slider-label`,t),u,l),c}var hi=e=>`${Math.round(e*100)}%`,gi=e=>`${e.toFixed(2)}x`;function _i(e,t,n,r,i,a,o,s,c){return mi(e,t,n,r,i,a,{preview:e=>s.onCursorPreview({[o]:e}),commit:e=>s.onCursor({[o]:e}),end:()=>s.onCursorPreviewEnd()},c)}function vi(e,t,n,r,i){return mi(e,t,n,0,1,hi,{preview:e=>i.onMotionPreview({[r]:e}),commit:e=>i.onMotion({[r]:e}),end:()=>i.onMotionPreviewEnd()},!1)}function yi(e,t,n,r,i,a){return ti(t,null,ei({key:r,checked:n,disabled:a,attrs:{[e]:``},onChange:e=>i.onCursor({[r]:e})}))}function bi(e,t,n,r,i=!1){let a=w(`div`),o=t.hidden;a.append(yi(`data-cursor-hidden`,`Hide cursor`,t.hidden,`hidden`,r,!1));let s=_i(`data-cursor-scale`,`Size`,t.scale,.5,2,gi,`scale`,r,o);i&&a.append(s);let c=w(`div`,`cursor-styles`);c.setAttribute(`role`,`radiogroup`),c.setAttribute(`aria-label`,`Cursor style`),o&&c.setAttribute(`aria-disabled`,`true`);for(let e of[`light`,`dark`,`touch`]){let n=w(`button`,`cursor-style`);n.type=`button`,n.disabled=o,n.setAttribute(`role`,`radio`),n.setAttribute(`data-cursor-style`,e),n.setAttribute(`aria-checked`,String(t.style===e)),n.setAttribute(`aria-label`,ci[e]),n.title=ci[e],n.append(pi(e,t.scale)),n.addEventListener(`click`,()=>r.onCursor({style:e})),c.append(n)}i||a.append(w(`div`,`cursor-label`,`Style`),c),i||a.append(s,_i(`data-cursor-blur`,`Motion blur`,t.motionBlur,0,1,hi,`motionBlur`,r,o),_i(`data-cursor-tilt`,`Tilt`,t.tilt??ce.tilt,0,1,hi,`tilt`,r,o),_i(`data-cursor-bounce`,`Click bounce`,t.clickBounce??ce.clickBounce,0,2,gi,`clickBounce`,r,o),yi(`data-cursor-idle`,`Hide when not moving`,t.hideWhenIdle,`hideWhenIdle`,r,o)),a.append(w(`div`,`cursor-label camera-label`,`Camera`),vi(`data-motion-smoothness`,`Smoothness`,n.smoothness,`smoothness`,r),vi(`data-motion-blur`,`Camera blur`,n.blur,`blur`,r),ti(`Follow cursor`,null,ei({key:`motion-follow`,checked:n.follow,attrs:{"data-motion-follow":``},onChange:e=>r.onMotion({follow:e})}))),e.replaceChildren(a)}function xi(){let e=w(`progress`,`export-progress`);return e.setAttribute(`data-export-progress`,``),e.setAttribute(`aria-label`,`Export progress`),e}function Si(e,t){return e.phase!==`idle`||t.kind===`noFrames`}function Ci(e,t,n,r){let i=e.querySelector(`[data-export-start]`);if(i===null)return!1;i.textContent=Xr(t,n,r),i.disabled=Si(t,r);let a=e.querySelector(`[data-export-progress]`);if(t.phase!==`encoding`||t.total===0)return a?.remove(),!0;let o=a??xi();return o.max=t.total,o.value=t.done,a===null&&i.closest(`.control-actions`)?.after(o),!0}function wi(e,t,n){let r=w(`div`),i=t.run.phase!==`idle`;if(t.hasReclaimedMotion){let e=w(`p`,`notice`,`This export will use still frames where motion was reclaimed.`);e.setAttribute(`data-reclaimed-motion-notice`,``),r.append(e)}let a=w(`p`,`export-summary`,we(t.fileType,t.durationMs));a.setAttribute(`data-export-summary`,``);let o=w(`p`,`muted`,je(t.aspect));o.setAttribute(`data-aspect-note`,``),r.append(a,o);let s=w(`p`,`muted`,ke(t.recording,t.target));s.setAttribute(`data-size-readout`,``),r.append(s);let c=w(`div`,`control-row`);c.append(w(`span`,`control-label`,`File type`));let l=w(`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=w(`button`,`segment`,De[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=w(`div`,`control-row`);e.append(w(`span`,`control-label`,`Quality`));let a=w(`div`,`segmented`);a.setAttribute(`role`,`radiogroup`),a.setAttribute(`aria-label`,`Quality`),a.setAttribute(`data-export-qualities`,``);for(let e of he){let r=w(`button`,`segment`,_e[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=w(`button`,`btn btn-primary export-start`,Xr(t.run,t.fileType,t.readiness));u.type=`button`,u.setAttribute(`data-export-start`,``),u.setAttribute(`data-readiness`,t.readiness.kind),u.disabled=Si(t.run,t.readiness),u.addEventListener(`click`,n.onExport);let d=w(`div`,`control-actions`);if(d.append(u),t.readiness.kind===`noFrames`){let e=w(`p`,`muted`);e.setAttribute(`data-export-no-frames`,``),e.append(ii(t.runsRoute)),r.append(d,e)}else r.append(d);if(t.run.phase===`encoding`&&t.run.total>0){let e=xi();e.max=t.run.total,e.value=t.run.done,r.append(e)}if(t.save!==null&&r.append(Fi(t.save,n)),t.revealError!=null){let e=w(`p`,`notice notice-warn`,t.revealError);e.setAttribute(`data-reveal-error`,``),r.append(e)}if(t.save?.kind===`saved`)for(let e of t.save.outputRefs){let n=t.outputs.find(t=>t.kind===`stored`&&t.output.ref===e);n?.kind===`stored`&&Oi(r,n.output,t)}e.replaceChildren(r)}function Ti(e,t,n){let r=document.createDocumentFragment(),i=t.showAll?t.outputs:t.outputs.slice(0,5);for(let e of i){let i=w(`div`,`output`);if(i.setAttribute(`data-output`,e.kind===`file`?e.key:e.output.ref),r.append(i),e.kind===`file`){Ni(i,e,t,n);continue}let a=e.output,o=w(`div`,`beat`),s=a.sceneDigest!==void 0&&a.sceneDigest!==t.currentDigest,c=t.warningsOpen.has(a.ref);o.append(ji(a.name,[s?Ai(a.ref):null,Di(a.ref,Ei(a),c,n)]));let l=w(`button`,`btn btn-quiet`,`Download`);if(l.type=`button`,l.setAttribute(`data-download`,a.ref),l.addEventListener(`click`,()=>n.onDownload(a.ref)),o.append(l),i.append(o),i.append(Mi(a.ref,[Zr(a.byteLength),ki(a.renderedAt)],null)),c&&Ei(a)>0){let e=w(`div`,`output-warnings`);e.setAttribute(`data-output-warnings-body`,a.ref),Oi(e,a,t.reportContext),i.append(e)}}let a=t.outputs.length-i.length;if(a>0){let e=w(`button`,`btn btn-quiet`,`Show all ${t.outputs.length}`);e.type=`button`,e.setAttribute(`data-history-all`,``),e.title=`${a} more`,e.addEventListener(`click`,n.onShowAll),r.append(e)}e.replaceChildren(r)}function Ei(e){return[e.detailViolations.length>0,e.logoWarning!==void 0,(e.unavailableSpans??[]).length>0,(e.unplacedStills??[]).length>0].filter(Boolean).length}function Di(e,t,n,r){if(t===0)return null;let i=w(`button`,`chip chip-warn`,t===1?`1 warning`:`${t} warnings`);return i.type=`button`,i.setAttribute(`data-output-warnings`,e),i.setAttribute(`aria-expanded`,String(n)),i.addEventListener(`click`,()=>r.onWarnings(e)),i}function Oi(e,t,n){if(t.detailViolations.length>0){let{heading:r,lines:i}=mt(t.detailViolations,n.beatAt),a=w(`div`,`notice`);a.setAttribute(`data-violations`,t.ref),a.append(w(`strong`,void 0,r));for(let e of i)a.append(w(`div`,void 0,e));a.append(w(`div`,`honesty`,`A wider 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=w(`div`,`notice`);n.setAttribute(`data-logo-warning`,t.ref),n.append(w(`div`,void 0,t.logoWarning)),e.append(n)}let r=t.unavailableSpans??[];if(r.length>0){let i=w(`div`,`notice`);i.setAttribute(`data-unavailable`,t.ref);let a=r.every(e=>e.reason===ut),o=w(`strong`);le(o,a?`Motion was reclaimed to free space and shown as a still. ${yt(n.runsRoute.authored,vt(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(w(`div`,void 0,`${e.ref}: ${e.reason}`));e.append(i)}let i=t.unplacedStills??[];if(i.length>0){let n=w(`div`,`notice`);n.setAttribute(`data-unplaced-stills`,t.ref);let r=i.every(e=>e.reason.includes(`cut`));n.append(w(`strong`,void 0,r?`No still for ${i.length===1?`a step you cut`:`the steps you cut`}`:`Some steps got no still`));for(let e of i)n.append(w(`div`,void 0,`${e.actionId}: ${e.reason}`));e.append(n)}}function ki(e,t=new Date){let n=new Date(e);return Number.isNaN(n.getTime())?e:Be(n,n.getFullYear()!==t.getFullYear())}function Ai(e){let t=w(`span`,`chip`,`Outdated`);return t.setAttribute(`data-stale-export`,e),t.title=`Made before your last edit`,t}function ji(e,t){let n=w(`span`,`output-head`),r=w(`span`,`output-name`,e);r.title=e,n.append(r);for(let e of t)e!==null&&n.append(e);return n}function Mi(e,t,n){let r=w(`div`,`muted output-meta`,t.join(` · `));return r.setAttribute(`data-output-meta`,e),n!==null&&(r.title=n),r}function Ni(e,t,n,r){let i=w(`div`,`beat`),a=n.warningsOpen.has(t.key);if(i.append(ji(t.name,[t.sceneDigest===n.currentDigest?null:Ai(t.key),Di(t.key,t.caveats.length,a,r)])),t.exists){let e=w(`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=w(`span`,`muted`,`moved or deleted`);e.setAttribute(`data-output-gone`,``),i.append(e)}if(e.append(i),e.append(Mi(t.key,[Zr(t.byteLength),ki(t.renderedAt)],t.detail)),a&&t.caveats.length>0){let n=w(`div`,`notice output-warnings`);n.setAttribute(`data-output-warnings-body`,t.key);for(let e of t.caveats)n.append(w(`div`,void 0,Pi(e)));e.append(n)}}function Pi(e){let t=e.charAt(0).toUpperCase()+e.slice(1);return/[.!?]$/.test(t)?t:`${t}.`}function Fi(e,t){let n=w(`div`,e.kind===`failed`?`notice notice-error`:`notice`);n.setAttribute(`data-save-outcome`,e.kind);let r=(e,n)=>{let r=w(`button`,`btn btn-quiet`,n);return r.type=`button`,r.setAttribute(`data-save-again`,``),r.addEventListener(`click`,()=>t.onSaveAgain(e)),r};if(e.kind===`saved`){let r=e.names.length===1?`Saved ${e.names[0]} · ${Zr(e.byteLength)}`:`Saved ${e.names.length} files · ${Zr(e.byteLength)}`;n.append(w(`span`,void 0,r));let i=e.reveal;if(i!==null){let e=w(`button`,`btn btn-quiet`,i.kind===`path`?`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=w(`div`,`muted`,e.summary);t.setAttribute(`data-save-summary`,``),n.append(t)}}else e.kind===`cancelled`?(n.append(w(`span`,void 0,`You cancelled the save.`)),e.total>1?n.append(w(`div`,void 0,`Saved ${e.saved} of ${e.total} files.`)):n.append(` `),n.append(r(e.refs,`Download again`))):(n.append(w(`strong`,void 0,`Exported, but the browser didn't save it.`)),e.total>1&&n.append(w(`div`,void 0,`Saved ${e.saved} of ${e.total} files.`)),n.append(w(`div`,void 0,e.error),r(e.refs,`Download again`)));return n}function Ii(e,t){let n=w(`button`,`btn btn-icon transport-button`);return n.type=`button`,n.setAttribute(`data-transport-shuttle`,String(e)),n.setAttribute(`aria-label`,t),n.append(C(e===-1?`rewind`:`fastForward`)),n}function Li(e,t,n){let r=e.querySelector(`[data-transport-play]`),i=e.querySelector(`[data-transport-rate]`),a=e.querySelector(`[data-transport-controls]`),o=e.querySelector(`[data-transport-repeat]`),s=e.querySelector(`[data-transport-skip]`);if(r===null||i===null||a===null||o===null||s===null){r=w(`button`,`btn btn-icon transport-button`),r.type=`button`,r.setAttribute(`data-transport-play`,``),s=w(`button`,`btn btn-icon transport-button`),s.type=`button`,s.setAttribute(`data-transport-skip`,``),s.append(C(`skipBack`)),o=w(`button`,`btn btn-icon transport-button`),o.type=`button`,o.setAttribute(`data-transport-repeat`,``),o.append(C(`repeat`));let t=w(`span`,`transport-pip`);t.setAttribute(`aria-hidden`,`true`),o.append(t),i=w(`span`,`rate`),i.setAttribute(`data-transport-rate`,``),a=w(`div`,`transport-controls`),a.setAttribute(`data-transport-controls`,``),a.append(s,Ii(-1,`Rewind`),r,Ii(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?Nr(e,o,[r===-1?`J`:`L`]):(Pr(e),e.title=o)}s.onclick=()=>n.onSkipToStart(),s.disabled=!t.enabled;let l=`Jump to start`;s.setAttribute(`aria-label`,l),t.enabled?Nr(s,l,[`Mod`,`Left`]):(Pr(s),s.title=b(`This demo has no frames yet, so there is nothing to play. ${yt(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(C(f)),r.toggleAttribute(`data-playing`,t.playing),r.toggleAttribute(`data-active`,t.playing&&t.rate===1),r.disabled=!t.enabled,t.enabled?Nr(r,d,[`Space`]):(Pr(r),r.title=b(`This demo has no frames yet, so there is nothing to play. ${yt(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 Ri(e,t,n,r=e){let i=r.querySelector(`[data-transport-time]`),a=e.querySelector(`[data-stage-actions]`);if(i===null||a===null){i=w(`span`,`stage-clock`),i.setAttribute(`data-transport-time`,``),a=w(`div`,`stage-actions`),a.setAttribute(`data-stage-actions`,``);let t=w(`div`,`segmented`);t.setAttribute(`role`,`radiogroup`),t.setAttribute(`aria-label`,`Aspect ratio`),t.setAttribute(`data-aspect-toggle`,``);for(let e of[`auto`,`16:9`,`9:16`]){let n=w(`button`,`segment`,e===`auto`?`Auto`:e);n.type=`button`,n.setAttribute(`role`,`radio`),n.setAttribute(`data-aspect`,e),n.title=e===`auto`?`Auto: the 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=w(`button`,`btn chip`);n.type=`button`,n.setAttribute(`data-stage-zoom`,``),a.append(n);let o=w(`button`,`btn btn-icon chip chip-icon`);o.type=`button`,o.setAttribute(`data-stage-fullscreen`,``),a.append(o);let s=w(`div`,`stage-error`);s.setAttribute(`data-stage-error`,``),s.setAttribute(`role`,`alert`),s.hidden=!0;let c=w(`span`,`stage-error-text`);c.setAttribute(`data-stage-error-text`,``);let l=w(`button`,`btn btn-icon stage-error-dismiss`);l.type=`button`,l.setAttribute(`data-stage-error-dismiss`,``),l.setAttribute(`aria-label`,`Dismiss`),l.title=`Dismiss`,l.append(C(`close`)),s.append(c,l),r===e?e.replaceChildren(i,a,s):(r.replaceChildren(i),e.replaceChildren(a,s))}i.textContent=`${A(t.positionMs)} / ${A(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`:b(`This demo has no frames yet, so there is nothing to zoom into. ${yt(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(C(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 zi={undo:[`Mod`,`Z`],redo:[`Shift`,`Mod`,`Z`],"shortcuts-open":[`?`]};function Bi(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=zi[t];a===void 0?i.title===``&&(i.title=r):Nr(i,r,a),i.querySelector(`svg`)===null&&(i.textContent=``,i.append(C(n)))}}var Vi=`#failure > .notice:not([data-capture-note])`;function Hi(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(Vi)===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(C(`circleAlert`));let a=e.querySelector(`[data-count]`);a===null&&(a=w(`span`),a.setAttribute(`data-count`,``),a.setAttribute(`aria-hidden`,`true`),e.append(a)),a.textContent=String(n)}function Ui(e,t){let n=[...e.querySelectorAll(Vi)].map(e=>e.textContent??``).join(`
2
+ `);return n!==``&&n!==t&&typeof e.showPopover==`function`&&!e.matches(`:popover-open`)&&e.showPopover(),n}function Wi(e,t,n){let r=e.querySelector(`[data-shortcuts-search]`);if(r!==null&&r.value===t.query&&e.dataset.shortcutsMac===String(t.mac)){t.focus&&document.activeElement!==r&&r.focus();return}e.setAttribute(`data-shortcuts`,``),e.dataset.shortcutsMac=String(t.mac);let i=w(`input`,`shortcuts-search`);i.type=`search`,i.placeholder=`Search shortcuts`,i.setAttribute(`aria-label`,`Search shortcuts`),i.setAttribute(`data-shortcuts-search`,``),i.autocomplete=`off`,i.spellcheck=!1,i.value=t.query;let a=w(`div`,`shortcuts-body`),o=[];for(let e of hr){let n=o[o.length-1];if(n?.group!==e.group){let t=w(`section`,`shortcuts-section`);t.append(w(`h3`,`shortcuts-group`,e.group)),a.append(t),n={section:t,group:e.group,rows:[]},o.push(n)}let r=w(`div`,`shortcuts-row`);r.setAttribute(`data-shortcut-row`,``),r.append(w(`span`,`shortcuts-what`,mr(e,t.mac)));let i=w(`span`,`shortcuts-keys`);for(let n of e.combos){let e=w(`span`,`keychord`);e.setAttribute(`data-combo`,``),e.setAttribute(`aria-label`,fr(n,t.mac));for(let r of n){let n=cr(r,t.mac),i=w(`kbd`,`keycap`,n);i.setAttribute(`aria-hidden`,`true`),ur(n)&&i.setAttribute(`data-symbol`,``),e.append(i)}i.append(e)}r.append(i),n.section.append(r),n.rows.push(r)}let s=w(`p`,`shortcuts-empty`,`No shortcuts match`);s.setAttribute(`data-shortcuts-empty`,``),a.append(s);let c=()=>{let e=i.value.trim().toLowerCase(),t=0;for(let{section:n,group:r,rows:i}of o){let a=r.toLowerCase().includes(e),o=0;for(let t of i){let n=t.querySelector(`.shortcuts-what`)?.textContent?.toLowerCase()??``;t.hidden=!(a||n.includes(e)),t.hidden||(o+=1)}n.hidden=o===0,t+=o}s.hidden=t>0};c(),i.addEventListener(`input`,()=>{n.onQuery(i.value),c()}),i.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.preventDefault(),i.value===``?n.onClose():(i.value=``,n.onQuery(``),c()))}),e.replaceChildren(i,a),t.focus&&i.focus()}function Gi(e){return`${ze(e)}${Ie(e)}`}function Ki(e,t,n=!1){let r=w(`div`,`info-row`);r.append(w(`span`,`info-key`,e));let i=w(`span`,n?`info-value mono`:`info-value`,t);return i.title=t,r.append(i),r}function qi(e,t,n,r){let i=Ki(e,t,!0),a=w(`button`,`btn btn-quiet btn-icon info-copy`);a.type=`button`,a.setAttribute(`aria-label`,`Copy ${n}`),a.title=`Copy ${n}`,a.setAttribute(`data-copy`,n),a.append(C(`copy`));let o=w(`div`,`info-error`);o.setAttribute(`data-copy-error`,n),o.hidden=!0,a.addEventListener(`click`,()=>{r(t).then(()=>{o.hidden=!0,a.replaceChildren(C(`check`)),a.setAttribute(`aria-label`,`Copied`),a.title=`Copied`},e=>{o.textContent=`Couldn't copy: ${e instanceof Error?e.message:String(e)}`,o.hidden=!1})}),i.append(a);let s=w(`div`);return s.append(i,o),s}function Ji(e,t,n){let r=w(`div`,`info-group`);r.setAttribute(`data-info-facts`,``);let i=`${v(t.durationMs)} · ${t.steps} ${t.steps===1?`step`:`steps`}`,a=t.aspect===`auto`?`Auto`:t.aspect;r.append(Ki(`Recorded`,ki(t.recordedAt)),Ki(`Site`,Gi(t.site)),Ki(`Length`,i),Ki(`Recording`,`${t.recording.width} × ${t.recording.height}`),Ki(`Video`,`${t.target.width} × ${t.target.height} · ${a}`));let o=w(`div`,`info-group`);if(o.setAttribute(`data-info-ids`,``),o.append(qi(`Take ID`,t.takeId,`take ID`,n.onCopy)),t.rerun.kind===`link`){let e=w(`div`,`info-row`);e.append(w(`span`,`info-key`,`Re-record`));let n=w(`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=w(`div`,`info-group info-exports`);if(e.setAttribute(`data-info-exports`,``),e.append(w(`div`,`info-label`,`Exports`)),t.revealError!==null){let n=w(`p`,`notice notice-warn`,t.revealError);n.setAttribute(`data-reveal-error`,``),e.append(n)}let r=w(`div`,`info-history`);Ti(r,t.history,n),e.append(r),s.push(e)}e.replaceChildren(...s)}var Yi=.006,N=e=>`${(e*100).toFixed(4)}%`;function Xi(e,t,n,r=Yi){if(n<e.startMs||t>e.endMs)return null;let i=Math.max(0,M(e,t)),a=Math.min(1,M(e,n)),o=Math.max(r,a-i);return{left:Math.min(i,1-o),width:o,toScale:a-i>=r}}var Zi=(e,t)=>Math.min(1,Math.max(0,M(e,t))),Qi=[100,250,500,1e3,2e3,5e3,1e4,15e3,3e4,6e4],$i=(e,t)=>t>=1e3?A(e):`${A(e)}.${Math.floor(e%1e3/100)}`;function ea(e,t){let n=w(`div`,`ruler`);n.setAttribute(`data-ruler`,``),n.setAttribute(`data-source`,e.timeSource);let r=(t.viewport.endMs-t.viewport.startMs)/10,i=Qi.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=M(t.viewport,e),a=w(`span`,`tick`,$i(e,i));a.style.left=N(r),a.dataset.fraction=String(r),n.append(a)}return na?.observe(n),n}function ta(e){let t=e.clientWidth;if(t===0)return;let n=[...e.querySelectorAll(`.tick`)].map(e=>({tick:e,w:e.offsetWidth})),r=-1/0;for(let{tick:e,w:i}of n){let n=Number(e.dataset.fraction)*t,a=n+i>t,o=a?n-i:n,s=o<r;e.toggleAttribute(`data-crowded`,s),a?e.setAttribute(`data-edge`,`end`):e.removeAttribute(`data-edge`),s||(r=o+i)}}var na=typeof ResizeObserver>`u`?null:new ResizeObserver(e=>{for(let t of e){let e=t.target;e.isConnected?ta(e):na?.unobserve(e)}});function ra(e,t){let n=w(`div`,`lane`);return n.append(e,t),n}function ia(e,t,n){let r=w(`div`,`lane-label lane-head`),i=w(`span`,`lane-title`),a=w(`span`,`lane-glyph`);return a.append(C(t)),i.append(a,w(`span`,`lane-name`,e)),n&&i.append(n),r.append(i),r}function aa(e){let t;if(e.failed)t=`The hover check could not run, so nothing here has been checked.`;else if(e.unchecked>0)t=`${e.unchecked} ${e.unchecked===1?`hover`:`hovers`} could not be checked.`;else return null;let n=w(`span`,`lane-flag`);return n.setAttribute(`role`,`img`),n.setAttribute(`aria-label`,t),n.title=t,n.setAttribute(`data-hover-check`,e.failed?`failed`:`unchecked`),n}var oa=3;function sa(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 ca=(e,t)=>e!==null&&t!==null&&e.kind===t.kind&&(e.kind===`tick`?e.actionId===t.actionId:e.kind===`piece`?Et(e.start,t.start):e.id===t.id),la=(e,t)=>e.snapping?8*t:0;function ua(e,t){let n=e.getBoundingClientRect().width;return n===0?0:(t.endMs-t.startMs)/n}function da(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 fa(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=ua(t,n.viewport);return{toMs:da(t,n.viewport,e),deltaMs:(e-s)*r,snapMs:la(n,r)}},u=e=>{Math.abs(e.clientX-s)>oa&&(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 pa=e=>Math.max(0,Math.min(1,e));function ma(e,t,n,r){let i=pa(r);t.style.left=N(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=N(l),a.style.width=N(Math.max(s,c)-l)}function ha(e,t,n,r,i){let a=w(`div`,`edge`);return a.setAttribute(`data-edge`,t),a.setAttribute(`aria-label`,t===`start`?`Drag the piece's start`:`Drag the piece's end`),fa(a,n,r,({deltaMs:n})=>({kind:`pieceEdge`,start:e.start,side:t,deltaMs:n}),i,{move:({deltaMs:e})=>{let i=e/ua(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 ga(e,t,n,r){let i=w(`div`,`join-card`);i.setAttribute(`data-join-card`,e.removedId),i.setAttribute(`role`,`dialog`),i.setAttribute(`aria-label`,`Removed frames`),i.setAttribute(`data-align`,t>.85?`end`:t<.15?`start`:`center`),i.addEventListener(`pointerdown`,e=>e.stopPropagation()),i.addEventListener(`click`,e=>e.stopPropagation());let a=w(`div`,`join-card-what`),o=w(`b`),s=w(`span`);e.unplaced===void 0?(o.textContent=`${n} removed`,s.textContent=`${_a(e.srcStartMs)} to ${_a(e.srcEndMs)}`):(o.textContent=`Removes no frames`,s.textContent=e.unplaced.charAt(0).toUpperCase()+e.unplaced.slice(1)),a.append(o,s);let c=w(`button`,`join-card-restore`);return c.type=`button`,c.setAttribute(`data-restore`,e.removedId),c.textContent=e.unplaced===void 0?`Restore`:`Discard`,c.addEventListener(`click`,()=>r.onRestorePiece(e.removedId)),i.append(a,c),i}function _a(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 va(e,t,n){let r=w(`div`,`track`);r.setAttribute(`data-track`,`clip`);let{clip:i}=e;for(let e of i.degraded){let n=Xi(t.viewport,e.startMs,e.endMs,0);if(n===null)continue;let i=w(`div`,`degraded`);i.setAttribute(`data-degraded`,``),i.style.left=N(n.left),i.style.width=N(n.width),r.append(i)}let a=M(t.viewport,i.trim.headMs),o=M(t.viewport,i.trim.tailMs),s=Xi(t.viewport,i.trim.headMs,i.trim.tailMs);if(s!==null){let e=w(`div`,`seg`);e.setAttribute(`data-clip-block`,``),e.setAttribute(`data-kind`,`clip`),e.setAttribute(`data-to-scale`,String(s.toScale)),e.style.left=N(s.left),e.style.width=N(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=Xi(t.viewport,e.startMs,e.endMs,0);if(a===null)return;let o=Math.max(0,(a.left-s.left)/s.width),u=Math.min(1,(a.left+a.width-s.left)/s.width);if(u<=o)return;let d=w(`div`,`piece-wrap`);d.style.left=N(o),d.style.width=N(u-o);let f=w(`button`,`piece`);f.type=`button`,f.setAttribute(`data-piece`,String(e.startMs)),f.setAttribute(`aria-label`,`Piece of the clip`),ca(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(ha(e,`start`,r,t,n)),(!m||e.after!==null)&&d.append(ha(e,`end`,r,t,n)),c.append(d)}));for(let e of i.joins){let i=M(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(${N(i)} + ${a}px)`,s=t.openJoin===e.removedId,c=`${((e.srcEndMs-e.srcStartMs)/1e3).toFixed(1)}s`,l=w(`button`,`join`);l.type=`button`,l.setAttribute(`data-join`,e.removedId),l.setAttribute(`aria-label`,e.unplaced===void 0?`Removed, ${c}`:`Removed nothing`),l.setAttribute(`aria-expanded`,String(s)),l.style.left=o;let u=null;l.addEventListener(`pointerdown`,e=>{e.stopPropagation(),u={x:e.clientX,y:e.clientY}}),l.addEventListener(`click`,t=>{t.stopPropagation();let r=u!==null&&t.detail>0&&Math.hypot(t.clientX-u.x,t.clientY-u.y)>oa;u=null,r||n.onOpenJoin(s?null:e.removedId)});let d=w(`span`,`seam`);d.setAttribute(`data-seam`,e.removedId),d.style.left=o,r.append(d,l),s&&r.append(ga(e,i,c,n))}let u=l[0],d=l.at(-1);for(let[e,s,c]of[[`head`,a,i.trim.headTiming],[`tail`,o,i.trim.tailTiming]]){if(s<0||s>1||(e===`head`?i.trim.headMarker===null&&(u?.before??null)!==null:i.trim.tailMarker===null&&(d?.after??null)!==null))continue;let a=w(`div`,`handle`);a.setAttribute(`data-trim`,e),a.setAttribute(`data-timing`,c),a.style.left=N(s),fa(a,r,t,({toMs:t,snapMs:n})=>({kind:`trim`,edge:e,toMs:t,snapMs:n}),n,{move:({toMs:n})=>ma(r,a,e,M(t.viewport,n)),end:()=>ma(r,a,e,s)}),r.append(a)}for(let e of i.ticks){let a=M(t.viewport,e.atMs);if(a<0||a>1)continue;let o=w(`button`,`tick`);o.type=`button`,o.setAttribute(`data-tick`,e.actionId),o.setAttribute(`data-verb`,e.verb);let s=Ta[e.verb];s!==void 0&&o.append(C(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(ya(i.ticks,e));o.setAttribute(`data-stack-index`,c),o.style.setProperty(`--tick-stack`,c),ca(t.selection,{kind:`tick`,actionId:e.actionId})&&o.setAttribute(`data-selected`,``),o.style.left=N(a),o.addEventListener(`click`,t=>{t.stopPropagation(),n.onSelect({kind:`tick`,actionId:e.actionId})}),r.append(o)}return r}function ya(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 ba(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=Xi(i.viewport,s,c);if(l===null)return null;let u=w(`div`,`seg`);u.setAttribute(`data-segment`,e.id),u.setAttribute(`data-kind`,t),u.setAttribute(`data-timing`,e.timing),u.setAttribute(`data-to-scale`,String(l.toScale)),u.style.left=N(l.left),u.style.width=N(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};ca(i.selection,f)&&u.setAttribute(`data-selected`,``);let p=t===`mask`&&e.wholeTake;if(t===`zoom`){let t=e;u.setAttribute(`data-authored-end`,String(t.endAuthored)),u.setAttribute(`data-clamped`,String(t.clamped)),u.append(w(`span`,`seg-label`,`${t.scale.toFixed(1)}x`))}else p&&u.setAttribute(`data-whole-take`,``),u.append(w(`span`,`seg-label`,p?`mask · whole take`:`mask`));if(u.addEventListener(`click`,e=>{e.stopPropagation(),a.onSelect(f)}),!p){let r=(e,t)=>{u.style.left=N(e),u.style.width=N(t)},o=()=>r(l.left,l.width),s=i.viewport.endMs-i.viewport.startMs;for(let s of[`start`,`end`]){let c=w(`div`,`cap`);c.setAttribute(`data-cap`,s),fa(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=pa(M(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)}fa(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 xa(e,t,n,r){let i=w(`div`,`track`);i.setAttribute(`data-track`,e);let a=e===`zoom`?t.zooms:t.masks;for(let o of a){let a=ba(o,e,i,t,n,r);a&&i.append(a)}return i.addEventListener(`click`,a=>{if(a.target!==i)return;let o=ua(i,n.viewport);r.onGesture({kind:e===`zoom`?`addZoom`:`addMask`,atMs:Sa(e,t,da(i,n.viewport,a.clientX)),snapMs:la(n,o)})}),wa(i,e,t,n),i}function Sa(e,t,n){let r=e===`zoom`?(t.zoomDefaultMs-t.zoomInMs)/2:Gt/2;return Math.max(0,Math.min(t.durationMs,n-r))}function Ca(e,t,n){let r=e===`zoom`?tn(t,n):nn(t,n);return Kt(r)?null:e===`mask`?{startMs:r.startMs,endMs:r.endMs}:{startMs:Lt(t.zooms,r.startMs,t.zoomInMs),endMs:Rt(t.zooms,r.startMs,r.endMs)}}function wa(e,t,n,r){let i=null,a=()=>{i?.remove(),i=null};e.addEventListener(`pointermove`,o=>{if(o.target!==e)return a();let s=Ca(t,n,Sa(t,n,da(e,r.viewport,o.clientX))),c=s&&Xi(r.viewport,s.startMs,s.endMs);if(c===null)return a();i===null&&(i=w(`div`,`seg`),i.setAttribute(`data-ghost`,t),i.setAttribute(`aria-hidden`,`true`),e.append(i)),i.style.left=N(c.left),i.style.width=N(c.width)}),e.addEventListener(`pointerleave`,a)}var Ta={click:`mousePointerClick`,type:`type`,moveTo:`mousePointer2`,scrollTo:`moveVertical`,waitFor:`hourglass`,drag:`handGrab`};function Ea(e,t,n,r){let i=w(`div`,`timeline`);if(i.addEventListener(`click`,e=>{e.target?.closest(`[data-ruler], [data-trim], [data-playhead], [data-track="zoom"], [data-track="mask"], button`)||r.onSelect(null)}),t.timeSource===`captured`){let e=w(`p`,`muted`);le(e,t.rerunLine===null?`Timing from the take, not from a render — ${rt(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=ea(t,n);sa(a,()=>a.getBoundingClientRect(),n,t.durationMs,r);let o=w(`div`,`lanes`);o.append(ra(w(`b`,`lane-label`),a));let s=w(`div`,`axis`);s.setAttribute(`data-axis`,``),i.addEventListener(`wheel`,e=>{let i=s.getBoundingClientRect();if(i.width===0)return;if(e.ctrlKey||e.metaKey){e.preventDefault();let a=(e.clientX-i.left)/i.width;r.onViewport(Dr(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(Or(n.viewport,t.durationMs,a/i.width*o))});let c=ia(`Clip`,`film`),l=aa(t.hoverCheck);l!==null&&c.querySelector(`.lane-glyph`)?.append(l);let u=ra(c,va(t,n,r));u.setAttribute(`data-lane`,`clip`),o.append(u);let d=ra(ia(`Zoom`,`zoomIn`),xa(`zoom`,t,n,r));d.setAttribute(`data-lane`,`zoom`),o.append(d);let f=w(`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(C(`plus`)),f.onclick=()=>{let e=i.querySelector(`[data-track="clip"]`),t=e?ua(e,n.viewport):0;r.onGesture({kind:`addMask`,atMs:n.positionMs,snapMs:la(n,t)})};let p=ra(ia(`Mask`,`eyeOff`,f),xa(`mask`,t,n,r));p.setAttribute(`data-lane`,`mask`),o.append(p);let m=w(`div`,`playhead`);m.setAttribute(`data-playhead`,``),m.style.left=N(Zi(n.viewport,n.positionMs));let h=w(`div`,`grab`);h.setAttribute(`data-playhead-grab`,``),h.setAttribute(`aria-hidden`,`true`),sa(h,()=>s.getBoundingClientRect(),n,t.durationMs,r),m.append(h),s.append(m),o.append(s),i.append(o);let g=w(`p`,`refusal`);le(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&&Da(y)}function Da(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 Oa(e){let t=w(`button`,`btn btn-quiet btn-icon tool`);return t.type=`button`,t.append(C(e)),t}function ka(e,t,n){e.setAttribute(`aria-label`,t),e.disabled?(Pr(e),e.title=t):Nr(e,t,n)}var Aa=new WeakMap;function ja(){let e=w(`div`,`bar-controls`);e.setAttribute(`data-timeline-tools`,`view`);let t=Oa(`magnet`);t.classList.add(`snap`);let n=Oa(`moveHorizontal`);n.classList.add(`fit`),n.setAttribute(`data-fit`,``);let r=Oa(`scissors`);r.setAttribute(`data-split-tool`,``);let i=w(`div`,`zoom-control`);i.setAttribute(`data-zoom-control`,``);let a=w(`input`);a.setAttribute(`aria-label`,`Timeline zoom`),a.type=`range`,a.min=`0`,a.max=`1`,a.step=`0.001`,a.setAttribute(`data-zoom-slider`,``);let o=Oa(`zoomOut`);o.classList.add(`zoom-step`),o.setAttribute(`data-zoom-step`,`out`);let s=Oa(`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 Ma(e,t,n,r){let i=Aa.get(e);(i===void 0||i.view.parentElement!==e)&&(i=ja(),Aa.set(e,i),e.replaceChildren(i.view));let{split:a,snap:o,fit:s,zoom:c,zoomOut:l,zoomIn:u}=i;ka(a,`Split at playhead`,[`Mod`,`B`]),a.onclick=()=>r.onSplit(),ka(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=wr(t.durationMs),f=n.viewport.startMs===d.startMs&&n.viewport.endMs===d.endMs;s.disabled=f,ka(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=jr(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=Ar(t.durationMs,Number(c.value)),i=M(n.viewport,n.positionMs);r.onViewport(kr(n.viewport,t.durationMs,e,i>=0&&i<=1?i:.5))};let g=e=>{let i=Math.min(1,Math.max(0,M(n.viewport,n.positionMs)));r.onViewport(Dr(n.viewport,t.durationMs,e,i))};l.disabled=!h||m<=5e-4,l.onclick=()=>g(1/ir),ka(l,`Zoom out`,[`−`]),u.disabled=!h||m>=.9995,ka(u,`Zoom in`,[`+`]),u.onclick=()=>g(ir)}var P=ae();function F(e){console.error(`demoman editor:`,e)}var Na=P.kits,I={state:`ready`,kits:[],defaultId:null,migrationPending:!1},Pa=null,Fa=null;function Ia(e){let t=I;if(t.state!==`ready`)return null;let n=t.kits.filter(e=>e.read.state===`ready`),r=n.filter(t=>t.read.state===`ready`&&ye(t.read.kit,e)),i=r.find(e=>e.id===Pa)??r.find(e=>e.id===t.defaultId)??r[0];if(i!==void 0)return Pa=i.id,{kit:i,edited:!1};let a=n.find(e=>e.id===Pa);return a===void 0?null:{kit:a,edited:!0}}var La=P.bundles,Ra=new URL(location.href).searchParams.get(`scene`)??``,L=e=>{let t=document.getElementById(e);if(!t)throw Error(`editor is missing #${e}`);return t},za=null,Ba=!1,R=rr({sceneId:Ra,loadScene:async e=>{let t=await P.scenes.get(e);if(t===null)throw Error(`no scene "${e}"`);return Io??=t.notes,Ba||=(za=t.revision,!0),t.scene},saveScene:async e=>{za=(await P.scenes.put(e,za)).revision},bundles:{active:e=>La.active(e)},newId:()=>crypto.randomUUID()});function z(e){let t=R.snapshot().scene;return R.dispatch(e).catch(F).then(()=>Va(t))}function Va(e){if(_o===null)return;let t=R.snapshot();t.scene!==e&&t.error===null&&(_o=null,$(t))}var B=st,Ha=null,V=null,Ua=!1;function Wa(e){e!==V&&(Ua=!1),V=e}var H=null,Ga=null,Ka=[],qa=null,Ja=null,Ya=null,U=null,Xa=null,W=`export`,G=!0,Za=`export`,Qa=jn(),K=`mp4`;function $a(e){let t=R.snapshot().scene,n=no();return ge(K,t.canvas.aspect,e,Ne({...t,branding:rs(t)}),n===null?{}:{quality:n})}var eo=P.exportQuality===void 0?null:Pe,to=null,no=()=>eo===null?null:to??eo,ro=!1,io=null;function ao(e){return io?.scene!==e&&(io={scene:e,digest:it(e)}),io.digest}var oo=`fit`;function so(e){e!==null&&e.kind!==`piece`?(W!==`selection`&&(Za=W),W=`selection`,G=!0):W===`selection`&&(W=Za),U=e}var co=null,lo=null,uo=0,q=null,fo=!0,po=!1,mo=``,ho=!1,go=null,_o=null,vo=[];function yo(){return vo.flatMap(e=>e.kind===`stored`?[e.output]:[])}var bo=!1,xo=new Set,J=bn(d),So=null,Y=null,Co=L(`preview`),wo=new OffscreenCanvas(J.width,J.height),To=wo.getContext(`2d`);function Eo(e){let t=$a(e),n=Fs(e,L(`stage-frame`).getBoundingClientRect().width),r=n.width!==J.width||n.height!==J.height;J=n,r&&(wo=new OffscreenCanvas(J.width,J.height),To=wo.getContext(`2d`)),So=null;let i=L(`stage`);i.style.setProperty(`--frame-ratio`,`${t.width} / ${t.height}`),i.style.setProperty(`--frame-px`,String(bn(t).width))}var Do=150,Oo=null,ko=!1,Ao=!1;document.addEventListener(`pointerdown`,()=>{ko=!0},!0);var jo=()=>{ko=!1,Ao&&setTimeout(()=>{Ao&&!ko&&$(R.snapshot())},0)};window.addEventListener(`pointerup`,jo,!0),window.addEventListener(`pointercancel`,jo,!0);var Mo=new ResizeObserver(()=>{let e=L(`stage`),t=L(`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`),Tc&&(Oo!==null&&clearTimeout(Oo),Oo=setTimeout(()=>{Oo=null;let e=Fs(R.snapshot().bundle,L(`stage-frame`).getBoundingClientRect().width);(e.width!==J.width||e.height!==J.height)&&(ko&&(ns!==null||es!==null)?(gs(),Ao=!0):$(R.snapshot()))},Do))});Mo.observe(L(`stage-frame`)),Mo.observe(L(`stage`));var No=[],Po=null,Fo=``,Io=null,Lo=`The video shows the text that was recorded; re-record to type the new text.`;function Ro(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 zo=null,Bo=null,Vo=0,Ho=null,Uo=Tn(e=>e.motionSpans.length>0?r(e,La.load,{onSpanUnavailable:(e,t)=>console.info(`[demoman] preview: span ${e} could not be decoded (${t})`)}):Promise.resolve(f(e,La.load)));async function Wo(t){let{bundle:n,scene:r}=t;if(n===null||dn(Po,t))return;Po=un({scene:r,bundle:n}),No=[];let i=a(r).retiming.motionDiffThreshold,o=()=>{let e=R.snapshot();return e.scene===r&&e.bundle===n},s;try{s=await Uo(n),No=await ee(n,s,i)}catch(e){F(e),o()&&R.setHoverReport(fn),$(R.snapshot());return}try{let t=await Ge(r,n,s,i);if(o()){let n=e(R.snapshot().scene);R.setHoverReport(mn(t,n))}}catch(e){F(e),o()&&R.setHoverReport(fn)}$(R.snapshot())}var Go=null,Ko=null,qo=null,Jo=null,Yo=``,Xo=null,Zo=null,Qo=null,$o=null,es=null,ts=null,ns=null;function rs(e){let t=Te(ns,e,F);return ns=t.preview,t.branding}function is(e){ns={patch:e,scene:R.snapshot().scene},gs();let t=R.snapshot();os(t,$a(t.bundle))}function as(e){Ha!==null&&(Ha=null,$(R.snapshot())),P.files.reveal(e).catch(e=>{let t=An(e);t.expected?console.info(`demoman editor: ${t.text}`):F(e),Ha=t.text,$(R.snapshot())})}function os(e,t){let n=Oe({durationMs:Ns-Z,fileType:K,target:t,hasFrames:qs(e).kind!==`noFrames`}),r=L(`take-meta`);r.textContent=n,r.setAttribute(`aria-label`,`Take info: ${n}`)}var ss=null;function cs(e){return es===null?e.cursor:{...e.cursor,...es}}function ls(e){let t=e.motion??oe;return ts===null?t:{...t,...ts}}var us=null,ds=null;function fs(e){es=e,gs()}function ps(e){ts=e,gs()}function ms(){ts!==null&&(ts=null,gs())}function hs(){es!==null&&(es=null,gs())}function gs(){ds===null&&(ds=requestAnimationFrame(()=>{ds=null;let e=R.snapshot();bs(e),Y&&(ss=cs(e.scene),us=ls(e.scene),Ho=So,Q.seek(Q.positionMs))}))}function _s(){ds!==null&&cancelAnimationFrame(ds),ds=null,es=null,ts=null}function vs(e){return e===null?null:Xo?.ref===e?Xo.thumb:{kind:`loading`}}async function ys(e){let t=rs(e.scene),n=t.logo?.ref??null;if(n!==Ko&&(Ko=n,qo=null,Jo=null,Go=null,Yo=``,n!==null)){let e=await P.logos.load(n);if(Ko!==n)return;e.ok?qo=e.source:Jo=e.error}let r=o(t,J),i=`${n}@${r}`;if(qo!==null&&r>0&&i!==Yo){Yo=i;try{let e=await qo.rasterAt(r);if(Ko!==n||Yo!==i)return;Go=e,Jo=null}catch(e){Go=null,Jo=e instanceof Error?e.message:String(e)}}let a=null;if(n!==null){if(qo!==null){try{a={kind:`ready`,url:await Me(qo)}}catch(e){a={kind:`failed`,reason:e instanceof Error?e.message:String(e)}}if(Ko!==n)return}else a=Jo===null?{kind:`loading`}:{kind:`failed`,reason:Jo}}let s=JSON.stringify(a)!==JSON.stringify(Xo?.thumb??null)||(Xo?.ref??null)!==n;Xo=n===null?null:{ref:n,thumb:a};let c=qo?Fe(qo,o(t,$a(e.bundle)),Ce(K,e.scene.canvas.aspect)):null,l=[$o?.ref===n?$o.note:null,c].filter(e=>e!==null),u=s||Go!==Zo||Jo!==Qo||l.join(`
3
+ `)!==Ka.join(`
4
+ `);Ka=l,Zo=Go,Qo=Jo,u&&$(R.snapshot())}function bs(e){Eo(e.bundle);let{scene:t,bundle:n}=e,r=En(t,{cursor:cs(t),branding:rs(t),motion:ts===null?t.motion:ls(t)}),i=n?S({plan:a(r),bundle:n,scene:r,target:J,detailTarget:$a(n),hints:No,logo:Go}):null;Y=i?.resolved??null,So=i?.presentation??null,Co.width!==J.width&&(Co.width=J.width),Co.height!==J.height&&(Co.height=J.height)}var xs=[];function Ss(e,t){let n=t.width*t.height/1e6;n<=0||(xs.push(e/n),xs.length>60&&xs.splice(0,xs.length-30))}var Cs=null,ws=null,Ts=!1,X={requestedFrames:0,drawnFrames:0,elapsedMs:0,sourceLookupMs:0,composeMs:0,blitMs:0},Es=0,Ds=null,Os=0,ks=0;function As(){X.requestedFrames=0,X.drawnFrames=0,X.elapsedMs=0,X.sourceLookupMs=0,X.composeMs=0,X.blitMs=0,Os=0,ks=0,Es=performance.now()}function js(){if(Q.playing===Ts)return;if(Ts=Q.playing,$(R.snapshot()),Ts){Ds={width:J.width,height:J.height},As();return}X.elapsedMs=performance.now()-Es;let e=(R.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(Sn({...X,...e===null?{}:{sourceFrame:e},...Ds===null?{}:{bitmap:Ds},parkedHeight:J.height,msPerMegapixel:vn(xs),...ks>0?{decodeMs:Os}:{}}))}var Ms=Cn({schedule:e=>requestAnimationFrame(e),onDrawFailed:e=>{Wa(e instanceof Error?e.message:String(e)),Q.pause(),$(R.snapshot())},onDrawRecovered:()=>{V!==null&&(V=null,$(R.snapshot()))},draw:async e=>{let t=R.snapshot(),n={resolved:Y,presentation:So,target:J,offscreen:wo,offscreenCtx:To};if(!n.resolved||!n.presentation||!t.bundle)return;let r=performance.now(),i=await Uo(t.bundle),a=performance.now();await s({resolved:n.resolved,target:n.target,presentation:n.presentation,frames:i,ctx:n.offscreenCtx,outputTimeMs:e,onStage:Ts?(e,t)=>{e===`fetch`&&(Os+=t,ks+=1)}:void 0});let o=performance.now();if(n.offscreen===wo){if(Ss(o-a,n.target),Co.getContext(`2d`)?.drawImage(wo,0,0),Q.playing&&ws!==null&&(ws+=1,ws>=4)){let e=xs.slice(-ws),t=Cs;Cs=null,Cs=Fs(R.snapshot().bundle,L(`stage-frame`).getBoundingClientRect().width,e).height,ws=null,Cs!==t&&($(R.snapshot()),Ds={width:J.width,height:J.height})}co&&(U?.kind===`mask`||U?.kind===`zoom`)&&xr(L(`stage-overlay`),{canvas:Co,selection:U,model:co,resolved:n.resolved,presentation:n.presentation,target:n.target,outputTimeMs:e},{onMaskRect:(e,t)=>z({kind:`moveMask`,id:e,rect:t}),onZoomPoint:(e,t)=>z({kind:`setZoomTarget`,id:e,point:t})}),Ts&&(X.drawnFrames+=1,X.sourceLookupMs+=a-r,X.composeMs+=o-a,X.blitMs+=performance.now()-o)}}}),Z=0,Ns=0,Ps=!1,Q=wn({seek:e=>{Ts&&(X.requestedFrames+=1),Ms.seek(e)},durationMs:()=>Ps?Ns:0,startMs:()=>Z,looping:()=>po,now:()=>performance.now(),schedule:e=>requestAnimationFrame(e),onChange:()=>{js(),zs()}});function Fs(e,t,n=xs){let r=$a(e),i=()=>yn({target:r,paintedCssWidth:t,devicePixelRatio:window.devicePixelRatio,playing:Q.playing,msPerMegapixel:vn(n)});return Q.playing?(Cs===null&&(Cs=i(),ws=0),bn(r,Cs)):(Cs=null,bn(r,i()))}function Is(e){e!==R.snapshot().scene.canvas.aspect&&z({kind:`setAspect`,aspect:e}).then(()=>Q.seek(Q.positionMs))}function Ls(e){if(e===no())return;let t=document.activeElement instanceof HTMLElement&&document.activeElement.hasAttribute(`data-export-quality`);to=e,$(R.snapshot()),t&&document.querySelector(`[data-export-quality="${e}"]`)?.focus()}function Rs(e){if(e===K)return;let t=document.activeElement instanceof HTMLElement&&document.activeElement.hasAttribute(`data-file-type`);K=e,$(R.snapshot()),t&&document.querySelector(`[data-file-type="${e}"]`)?.focus(),Q.seek(Q.positionMs)}console.info(`demoman editor: panel transition "${getComputedStyle(document.body).transitionProperty}"`),document.body.addEventListener(`transitionend`,e=>{e.target===document.body&&e.propertyName===`grid-template-columns`&&(U?.kind===`mask`||U?.kind===`zoom`)&&Q.seek(Q.positionMs)});function zs(){Li(L(`transport`),{authored:nt(R.snapshot().scene),rerunLine:vt(Js(R.snapshot())),playing:Q.playing,enabled:Ps&&Ns>Z,rate:Q.rate,looping:po},{onToggle:Bs,onSkipToStart:()=>Sc({kind:`seekEdge`,edge:`head`},R.snapshot()),onLooping:e=>{po=e,zs()},onShuttle:e=>{V=null,Q.shuttle(e)}});for(let[e,t]of[[L(`stage-tools`),L(`toolbar-clock`)],[L(`stage-bar`),L(`stage-bar`)]])Ri(e,{authored:nt(R.snapshot().scene),rerunLine:vt(Js(R.snapshot())),positionMs:Q.positionMs-Z,durationMs:Ns-Z,aspect:R.snapshot().scene.canvas.aspect,enabled:Ps&&Ns>Z,fullscreen:!!document.fullscreenElement,error:Ua?null:V,zoom:oo},{onAspect:Is,onFullscreen:Hs,onZoom:Vs,onDismissError:()=>{Ua=!0,zs()}},t);let e=L(`timeline`).querySelector(`[data-playhead]`);e&&q&&(e.style.left=`${(Zi(q,Q.positionMs)*100).toFixed(4)}%`)}function Bs(){V=null,Q.toggle(),$(R.snapshot())}function Vs(){oo=oo===`fit`?`actual`:`fit`,document.body.dataset.zoom=oo,zs()}function Hs(){V=null;let e=!document.fullscreenElement;(e?L(`stage`).requestFullscreen():document.exitFullscreen()).catch(t=>{Wa(`The preview could not ${e?`go full screen`:`exit full screen`}: ${t instanceof Error?t.message:String(t)}`),$(R.snapshot())})}document.addEventListener(`fullscreenchange`,()=>{let e=document.activeElement;V=null,zs();let t=!!document.fullscreenElement;L(`stage`).toggleAttribute(`data-fullscreen`,t);let n=L(t?`stage-tools`:`stage-bar`),r=L(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 Us(){let e=R.snapshot();Ws(Tt(e.scene,e.bundle,Y?.timeline??null,Q.positionMs))}function Ws(e){if(e!==null){if(Kt(e)){_o=e.reason,$(R.snapshot());return}z(e)}}function Gs(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);z(e).then(()=>{let r=R.snapshot();n(r.scene)||U?.kind===t&&U.id===e.id&&(so(null),$(r))})}function Ks(e){if(F(e),qa=e instanceof Error?e.message:String(e),Tc){$(R.snapshot());return}oi(L(`failure`),{error:null,replaySentence:null,captureSentence:null,openError:qa})}function qs(e){return e.bundle===null?{kind:`noFrames`}:{kind:`exact`}}function Js(e){let t=nt(e.scene);return{takeId:Ra,authored:t,rerun:P.nav.rerun(Ra,t)}}function Ys(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){Ao=!1,_s(),bs(e);let t=Ys(Y);t!==zo&&(zo=t,console.info(t));let n=Sr({scene:e.scene,bundle:e.bundle,resolved:Y}),r=L(`name`);r.value=e.scene.meta.name,r.placeholder=Re(e.scene.meta),L(`undo`).disabled=!e.canUndo,L(`redo`).disabled=!e.canRedo,ri(L(`banner`),{hasFrames:e.bundle!==null,route:Js(e)}),H!==null&&e.scene!==Ga&&(H=null),oi(L(`failure`),{error:e.error??H,replaySentence:e.replaySentence,replayRecoverable:e.replayRecoverable,captureSentence:e.captureSentence,renderError:B.error,previewError:V,logoLoadError:Jo,openError:qa,deleteError:Ja,navigationError:Ya,runsRoute:Js(e)});let a=It({scene:e.scene,view:n,bundle:e.bundle,resolved:Y,hoverReport:e.hoverReport,rerunLine:vt(Js(e))});co=a,lo=n,uo=a.durationMs,(q===null||go!==a.durationMs)&&(q=wr(a.durationMs),go=a.durationMs);let o={resolved:Y,bundle:e.bundle,viewport:e.scene.meta.capture.viewport},s=e=>Ws(sn(a,n,e,o)),c=e=>{q=e,$(R.snapshot())},l=e=>{fo=e,$(R.snapshot())};Ea(L(`timeline`),a,{viewport:q,selection:U,get positionMs(){return Q.positionMs},refusal:_o,hoverReport:e.hoverReport,snapping:fo,openJoin:Xa},{onSelect:e=>{so(e),$(R.snapshot())},onSeek:e=>Q.seek(e),onSeekStart:()=>Q.pause(),onSplit:Us,onRestorePiece:e=>{Xa=null,z({kind:`restorePiece`,id:e})},onOpenJoin:e=>{Xa=e,$(R.snapshot())},onGesture:s,onViewport:c,onSnapping:l}),ni(L(`take-notes`),{notices:[...Io??[],...Ro(e)?[Lo]:[],...a.notices],hoverReport:e.hoverReport}),Ma(L(`timeline-tools`),a,{viewport:q,snapping:fo,get positionMs(){return Q.positionMs}},{onGesture:s,onSplit:Us,onViewport:c,onSnapping:l});let u=U;u?.kind===`piece`&&!a.clip.pieces.some(e=>Et(e.start,u.start))&&(U=null);let d=u?.kind===`tick`&&n.beats.some(e=>e.actionId===u.actionId)||u?.kind===`zoom`&&a.zooms.some(e=>e.id===u.id)||u?.kind===`mask`&&a.masks.some(e=>e.id===u.id);W===`selection`&&!d&&(U===null&&F(Error(`the rail was on Selection with nothing selected`)),so(null)),document.body.dataset.panel=G?`open`:`closed`,qr(L(`rail`),{rail:W,panelOpen:G,hasSelection:d},{onPick:Cc}),Jr(L(`export-open`),{rail:W,panelOpen:G},{onPick:Cc}),Yr(L(`shortcuts-open`),{rail:W,panelOpen:G},{onPick:Cc});let f=document.activeElement?.matches(`[data-shortcuts-search]`)===!0;Wr(L(`inspector`),{selection:U,view:n,model:a,scene:e.scene,hoverReport:e.hoverReport,viewport:e.scene.meta.capture.viewport,rail:W,sections:Qa,attachedToCuts:Y?.plan.attachedToCuts??[]},{onClose:wc,onGap:(e,t)=>Ws(cn(n,e,t)),onGapClear:e=>z({kind:`clearGap`,afterActionId:e}),onKeepHover:Xs,onZoomOnStep:e=>{let t=n.beats.find(t=>t.actionId===e);if(!t?.anchorId)return;let r=new Set(R.snapshot().scene.camera.map(e=>e.id));z({kind:`addZoom`,marker:{actionId:e,offsetMs:0},target:{kind:`element`,anchorId:t.anchorId},scale:i.defaultZoomScale}).then(()=>{let e=R.snapshot().scene.camera.find(e=>!r.has(e.id));e&&(so({kind:`zoom`,id:e.id}),$(R.snapshot()))})},onZoomScale:(e,t)=>z({kind:`setZoomScale`,id:e,scale:t}),onRemoveZoom:e=>Gs({kind:`removeZoom`,id:e}),onMaskNote:(e,t)=>z({kind:`setMaskNote`,id:e,note:t}),onRemoveMask:e=>Gs({kind:`removeMask`,id:e})});let p=document.querySelector(`#inspector [data-panel-shortcuts]`);p!==null&&Wi(p,{mac:pr(navigator.userAgent),query:mo,focus:G&&(ho||f)},{onClose:wc,onQuery:e=>{mo=e}}),ho=!1,xr(L(`stage-overlay`),{canvas:Co,selection:U,model:a,resolved:Y,presentation:So,target:J,outputTimeMs:Q.positionMs},{onMaskRect:(e,t)=>z({kind:`moveMask`,id:e,rect:t}),onZoomPoint:(e,t)=>z({kind:`setZoomTarget`,id:e,point:t})});let m=L(`inspector`);m.querySelector(`.inspector`)===null&&F(Error(`the inspector has not rendered anything`));let h={export:`export`,branding:`background`,cursor:`cursor`},g=e=>{let t=m.querySelector(`[data-panel-${e}]`);return t===null&&W===h[e]&&G&&F(Error(`the inspector's ${e} panel is missing`)),t},_=g(`branding`);_&&si(_,{branding:e.scene.branding,logoThumb:vs(e.scene.branding.logo?.ref??null),logoPlacement:So?.logoPlacement??null,formatTitle:Ce(K,e.scene.canvas.aspect),logoNotes:Ka,kit:{read:I,standing:Ia(e.scene.branding),naming:Fa,onApply:e=>{let t=I.state===`ready`?I.kits.find(t=>t.id===e):void 0;if(t?.read.state!==`ready`){H=t===void 0?`That brand kit was not applied: it was deleted in another tab.`:`That brand kit was not applied: ${t.read.reason}.`,Ga=R.snapshot().scene,$(R.snapshot());return}Pa=e;let{background:n,logo:r,padding:i}=t.read.kit;z({kind:`setBranding`,patch:{background:n,logo:r,padding:i}}),$(R.snapshot())},onUpdate:()=>void Qs(),onStartNew:()=>{Fa={text:``,error:null},$(R.snapshot())},onNameInput:e=>{Fa!==null&&(Fa={text:e,error:null})},onConfirmNew:e=>void $s(e),onCancelNew:()=>{Fa=null,$(R.snapshot())}}},{onCommit:e=>z({kind:`setBranding`,patch:e}),onPreview:is,onLogoFile:e=>Zs(e).catch(F)});let v=g(`cursor`);v&&bi(v,cs(e.scene),ls(e.scene),{onCursor:e=>{_s(),z({kind:`setCursor`,patch:e})},onCursorPreview:fs,onCursorPreviewEnd:hs,onMotion:e=>{_s(),z({kind:`setMotion`,patch:e})},onMotionPreview:ps,onMotionPreviewEnd:ms},e.scene.meta.capture.device?.touch===!0);let y=$a(e.bundle),b=g(`export`);b&&wi(b,{outputs:vo,fileType:K,quality:no(),aspect:e.scene.canvas.aspect,target:y,recording:ve(e.bundle,Ne(e.scene)),durationMs:a.clip.trim.tailMs-a.clip.trim.headMs,run:B.run,save:B.save,revealError:Ha,readiness:qs(e),runsRoute:Js(e),currentDigest:ao(e.scene),sections:Qa,beatAt:ht(n.beats),hasReclaimedMotion:e.bundle?.degradations.some(e=>e.kind===`motionReclaimed`)??!1},{onExport:()=>ec().catch(F),onFileType:Rs,onQuality:Ls,onSaveAgain:e=>tc(e).catch(F),onReveal:as}),Ps=n.hasBundle,Z=a.clip.trim.headMs,Ns=a.clip.trim.tailMs,os(e,y),Ji(L(`take-info`),{recordedAt:e.scene.meta.createdAt,site:e.scene.meta.capture.originUrl,durationMs:a.clip.trim.tailMs-a.clip.trim.headMs,steps:n.beats.length,recording:ve(e.bundle,Ne(e.scene)),target:y,aspect:e.scene.canvas.aspect,takeId:Ra,rerun:Js(e).rerun,revealError:Ha,history:{outputs:vo,currentDigest:ao(e.scene),showAll:bo,warningsOpen:xo,reportContext:{beatAt:ht(n.beats),runsRoute:Js(e)}}},{onCopy:e=>navigator.clipboard.writeText(e),onDownload:e=>tc([e]).catch(F),onReveal:as,onShowAll:()=>{bo=!0,$(R.snapshot())},onWarnings:e=>{xo.delete(e)||xo.add(e),$(R.snapshot()),document.querySelector(`#take-info [data-output-warnings="${CSS.escape(e)}"]`)?.focus()}}),Q.positionMs<Z&&Q.seek(Z),Q.positionMs>Ns&&Q.seek(Ns),zs();let x=cs(e.scene),S=ls(e.scene),ee=JSON.stringify(e.scene.edits.removed??[]);Y&&So&&(e.bundle!==Bo||J.height!==Vo||Dn(ss,x)||On(us,S)||kn(Ho,So)||ee!==Fo)&&(Bo=e.bundle,ss=x,us=S,Ho=So,Vo=J.height,Fo=ee,Q.seek(Q.positionMs)),ys(e).catch(F)}function Xs(e){let t=R.snapshot().hoverReport;if(t===null){F(Error(`kept hover "${e}" with no hover report`));return}R.setHoverReport({...t,removable:t.removable.filter(t=>t!==e)})}async function Zs(e){H=null;let t=xe(e),n=e=>{H=e,Ga=R.snapshot().scene,$(R.snapshot())};if(!t.ok)return n(t.reason);let r=new Uint8Array(await e.arrayBuffer());try{await x(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 P.logos.put(e);$o=t.note===null?null:{ref:i,note:t.note};let a=R.snapshot().scene.branding.logo,o=a?{corner:a.corner,size:a.size,opacity:a.opacity}:y;await R.dispatch({kind:`setBranding`,patch:{logo:{ref:i,...o}}})}async function Qs(){let e=Ia(R.snapshot().scene.branding);if(e===null||!e.edited){H=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}".`,Ga=R.snapshot().scene,$(R.snapshot());return}let t=e.kit,n=`This demo's background, logo and padding will replace the brand kit "${t.name}".`;try{if(!await ie({glyph:`refresh`,title:`Replace "${t.name}"`,body:n,confirmLabel:`Replace`,danger:!1,focus:`confirm`}))return;let e=R.snapshot().scene.branding,r=await Na.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);I=await Na.read()}catch(e){H=`The brand kit "${t.name}" was not saved: ${e instanceof Error?e.message:String(e)}`,Ga=R.snapshot().scene}$(R.snapshot())}async function $s(e){let t=I.state===`ready`?I.kits:[],n=ne(e,t,null);if(!n.ok){Fa={text:e,error:n.reason},$(R.snapshot());return}let r=R.snapshot().scene.branding,i=fe();try{let t=await Na.update(e=>{let t=ne(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){Fa={text:e,error:t},$(R.snapshot());return}Fa=null,Pa=i,I=await Na.read()}catch(e){H=`The brand kit "${n.name}" was not saved: ${e instanceof Error?e.message:String(e)}`,Ga=R.snapshot().scene}$(R.snapshot())}async function ec(){Ha=null;let e=R.snapshot().scene;B={run:{phase:`encoding`,done:0,total:0},save:null,error:null},$(R.snapshot());try{await R.settled();let t=no();await P.exports.start(Ra,{fileType:K,aspect:e.canvas.aspect,revision:za,...t===null||K!==`mp4`||to===null&&!ro?{}:{quality:t}})}catch(e){throw B={...B,run:{phase:`idle`},error:e instanceof Error?e.message:String(e)},$(R.snapshot()),e}}async function tc(e){let t=yo(),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=P.downloads;if(i===void 0)throw Error(`this page cannot save an export again`);B={...B,save:await i.save(n)},$(R.snapshot())}var nc=!1;function rc(){let e=document.querySelector(`[data-panel-export]`);e!==null&&!Ci(e,B.run,K,qs(R.snapshot()))&&!nc&&(nc=!0,F(Error(`the Export panel has no start button, so progress cannot show`)))}function ic(e){let t=lt(B,e);switch(B=t.flow,t.effect){case`render`:$(R.snapshot());return;case`progress`:rc();return;case`relist`:P.outputs.list(Ra).then(e=>{vo=e,$(R.snapshot())}).catch(F);return;case`none`:return}}P.exports.onEvent(ic),P.nav.onOpen?.(e=>dc(()=>location.assign(e))),L(`name`).addEventListener(`change`,e=>{z({kind:`rename`,name:e.target.value.trim()})});var ac=e=>()=>{let t=R.snapshot().scene;e().catch(F).then(()=>Va(t))};L(`undo`).addEventListener(`click`,ac(()=>R.undo())),L(`redo`).addEventListener(`click`,ac(()=>R.redo()));var oc={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 sc(e){Ja=e,cc()}function cc(){if(Tc){$(R.snapshot());return}oi(L(`failure`),{error:null,replaySentence:null,captureSentence:null,deleteError:Ja,navigationError:Ya})}function lc(e,t,n=``){Ya=null;try{location.assign(t())}catch(t){F(t),Ya={page:e,reason:`${n}${t instanceof Error?t.message:String(t)}`},cc()}}function uc(e=``,t=null){lc(`Recordings page`,()=>Le(P.nav.library(),t),e)}function dc(e){(async()=>{let t=null,n=R.subscribe(e=>{t=e});try{await R.settled()}finally{n()}t?.error??e()})()}L(`back`).addEventListener(`click`,()=>{dc(()=>uc())});function fc(e){let t=pc(e);t&&(e.preventDefault(),dc(()=>lc(`Runs page`,()=>t.href)))}L(`banner`).addEventListener(`click`,fc),L(`inspector`).addEventListener(`click`,fc),L(`take-info`).addEventListener(`click`,fc),L(`failure`).addEventListener(`click`,fc),L(`take-info`).addEventListener(`toggle`,e=>{L(`take-meta`).setAttribute(`aria-expanded`,String(e.newState===`open`))});function pc(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 mc=null;document.addEventListener(`mousedown`,e=>{let t=pc(e);mc=t?{link:t,href:t.href}:null},!0),document.addEventListener(`mouseup`,e=>{let t=mc;if(mc=null,!t)return;let n=pc(e);!n||n===t.link||n.href===t.href&&dc(()=>lc(`Runs page`,()=>n.href))},!0),L(`delete`).addEventListener(`click`,()=>{(async()=>{try{if(!await ie(de))return}catch(e){F(e),sc(`Not deleted: the confirmation could not open — ${e instanceof Error?e.message:String(e)}.`);return}Ja=null;let e;try{e=await P.scenes.remove(Ra)}catch(e){F(e),sc(`Not deleted: ${e instanceof Error?e.message:String(e)}.`);return}if(!e.ok){sc(`Not deleted: ${oc[e.error]??e.detail??e.error}.`);return}if(e.result!==void 0&&!e.result.ok){let t=e.result.steps.find(e=>!e.ok);sc(`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;uc(t===null?`This demo was deleted. `:`This demo was deleted. ${t} `,t===null?null:`This demo was deleted. ${t}`)})()});var hc=Symbol.for(`demoman.editor.keydown`),gc=globalThis,_c=gc[hc];_c instanceof AbortController&&_c.abort();var vc=new AbortController;gc[hc]=vc;var yc=!1,bc=null;document.addEventListener(`pointerdown`,()=>{yc=!0},{capture:!0,signal:vc.signal}),document.addEventListener(`pointerdown`,()=>{Xa!==null&&(Xa=null,$(R.snapshot()))},{signal:vc.signal}),document.addEventListener(`keydown`,()=>{yc=!1},{capture:!0,signal:vc.signal}),document.addEventListener(`focusin`,e=>{bc=yc?e.target:null},{signal:vc.signal});var xc=new WeakMap;document.addEventListener(`focusin`,e=>{let t=e.target;(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&xc.set(t,t.value)},{signal:vc.signal}),document.addEventListener(`change`,e=>{let t=e.target;(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&xc.set(t,t.value)},{capture:!0,signal:vc.signal}),document.addEventListener(`keydown`,e=>{if(document.querySelector(`dialog[open]`)!==null)return;if(e.key===`Escape`&&Xa!==null){e.preventDefault(),Xa=null,$(R.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=xc.get(t);e!==void 0&&t.value!==e&&(t.value=e)}t?.blur()}return}let r=e.key===`Enter`||e.key===` `&&t!==bc;if((n===`BUTTON`||n===`A`)&&r&&t?.hasAttribute(`data-tick`)!==!0)return;let i=R.snapshot(),a=ar(e,{hasSelection:U!==null,selectionIsBeat:U?.kind===`tick`,canUndo:i.canUndo,canRedo:i.canRedo,panelOpen:G,hasTimeline:q!==null&&uo>0});a!==null&&(e.preventDefault(),Sc(a,i))},{signal:vc.signal});function Sc(e,t){switch(e.kind){case`playPause`:Bs();return;case`shuttle`:V=null,Q.shuttle(e.direction);return;case`stop`:Q.stop();return;case`nudge`:Q.seek(Q.positionMs+e.deltaMs);return;case`seekEdge`:Q.seek(e.edge===`head`?Z:Ns);return;case`stepBeat`:{let n=t.scene.actions.map(e=>e.id),r=U?.kind===`tick`?n.indexOf(U.actionId):-1,i=n[r===-1?e.delta>0?0:n.length-1:r+e.delta];if(i===void 0)return;so({kind:`tick`,actionId:i}),$(t);return}case`setTrim`:{let n=co,r=lo;if(n===null||r===null||Y===null||!Ps){let e=Js(t);_o=`This take has not been rendered yet, so there is nothing to trim to. ${yt(e.authored,vt(e),`first`)}`,$(t);return}Ws(sn(n,r,{kind:`trim`,edge:e.edge,toMs:Q.positionMs,snapMs:0},{resolved:Y,bundle:t.bundle,viewport:t.scene.meta.capture.viewport}));return}case`split`:Us();return;case`undo`:ac(()=>R.undo())();return;case`redo`:ac(()=>R.redo())();return;case`deleteSelection`:if(U===null)return;if(U.kind===`zoom`){Gs({kind:`removeZoom`,id:U.id});return}if(U.kind===`mask`){Gs({kind:`removeMask`,id:U.id});return}if(U.kind===`piece`){Ws(Dt(co?.clip.pieces??[],U.start,co?.clip.trim));return}Ws({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(q===null)return;let n=Math.min(1,Math.max(0,M(q,Q.positionMs)));q=Dr(q,uo,e.factor,n),$(t);return}case`zoomFit`:q=wr(uo),$(t);return;case`toggleSnapping`:fo=!fo,$(t);return;case`clearSelection`:so(null),$(t);return;case`toggleHelp`:Cc(`shortcuts`);return;case`closePanel`:wc();return}}function Cc(e){W===e&&G?G=!1:(W=e,G=!0,e===`shortcuts`&&(ho=!0)),e!==`selection`&&(Za=e),$(R.snapshot())}function wc(){G=!1,$(R.snapshot())}Bi(),Ir(),document.body.dataset.zoom=`fit`;{let e=L(`notes`),t=``,n=()=>{Hi(L(`notes-open`),e),t=Ui(e,t)};new MutationObserver(n).observe(e,{childList:!0,subtree:!0,characterData:!0}),n()}var Tc=!1;R.subscribe(e=>{Tc=!0,qa=null,$(e)}),R.subscribe(e=>Wo(e).catch(F));async function Ec(){I=await Na.read(),Tc&&$(R.snapshot())}Ec().catch(F),Na.onChange===void 0?console.info(`demoman: no storage change feed here, so the brand kit is read once`):Na.onChange(()=>{Ec().catch(F)});async function Dc(){let e=P.exportQuality;if(e===void 0)return;let t=await e.read();ro=t.unreadable===void 0,t.unreadable!==void 0&&console.info(`demoman editor: the Studio exports at ${_e[t.quality]} quality: ${t.unreadable}`),t.quality!==eo&&(eo=t.quality,Tc&&$(R.snapshot()))}P.exportQuality!==void 0&&(Dc().catch(F),window.addEventListener(`focus`,()=>{Dc().catch(F)})),P.outputs.list(Ra).then(e=>{vo=e,Tc&&$(R.snapshot())}).catch(F),R.load().catch(Ks);
@@ -1 +1 @@
1
- import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./confirm-dialog-DkCVzKzd.js";import{a as s,d as c,i as l,l as u,n as d,o as f,r as p,t as m}from"./state-COWbBf84.js";import{n as h,r as g,t as _}from"./topbar-sSUyITjl.js";function v(e,t){let n=e=>({ref:e.ref,sourceTimeMs:e.sourceTimeMs});if(e.length<=t)return e.map(n);let r=t>1?(e.length-1)/(t-1):0,i=new Set(Array.from({length:Math.max(0,t)},(e,t)=>Math.round(t*r)));return e.filter((e,t)=>i.has(t)).map(n)}function y(e){return e===null?{kind:`noBundle`}:e.keyframes.length===0?{kind:`noKeyframes`}:{kind:`ready`,frames:v(e.keyframes,8)}}function b(e){switch(e.kind){case`ready`:return null;case`loading`:return`Loading preview…`;case`noBundle`:return`No frames stored — nothing to preview.`;case`noKeyframes`:return`This demo has no keyframes.`;case`failed`:return`Preview unavailable — ${e.reason}`}}function x(e,t){return t<=1?0:(e+1)%t}function S(e,t){let n=e.querySelector(`[data-preview-canvas]`),r=e.querySelector(`[data-preview-note]`),i=b(t);n!==null&&(n.hidden=i!==null),r!==null&&(r.textContent=i??``)}function C(t){let n=[],r=!1;function i(i,a){let o=a.querySelector(`[data-preview-canvas]`);if(o===null){console.error(`demoman library: preview box for ${i} has no canvas to paint into`),S(a,{kind:`failed`,reason:`this row has no canvas to paint into`});return}let s=[],c=[],l=0,u=null,d=()=>{u!==null&&(clearInterval(u),u=null)};n.push(d);let f=(e,t)=>{d(),console.error(`demoman library: ${e} for ${i} —`,t),S(a,{kind:`failed`,reason:t instanceof Error?t.message:String(t)})},p=async e=>{let n=c[e];if(n!==void 0)return n;let r=s[e];if(r===void 0)throw Error(`preview frame ${e} is past the end of the take`);let i=await t.image(r.ref),a=document.createElement(`canvas`);return a.width=320,a.height=Math.max(1,Math.round(320*i.height/i.width)),a.getContext(`2d`)?.drawImage(i,0,0,a.width,a.height),i.close(),c[e]=a,a},m=async e=>{let t=await p(e);r||(o.width=t.width,o.height=t.height,o.style.setProperty(`--thumb-ratio`,String(t.width/t.height)),o.getContext(`2d`)?.drawImage(t,0,0))},h=()=>{l=x(l,s.length),m(l).catch(e=>f(`drawing a keyframe`,e))},g=()=>{u!==null||s.length<=1||(u=setInterval(h,400))},_=()=>{d(),l=0,m(0).catch(e=>f(`drawing the first keyframe`,e))},v=()=>{let e=a.closest(`article`);if(e===null){console.error(`demoman library: preview box for ${i} has no row to hover`);return}e.addEventListener(`mouseenter`,g),e.addEventListener(`mouseleave`,_),e.addEventListener(`focusin`,g),e.addEventListener(`focusout`,_),n.push(()=>{e.removeEventListener(`mouseenter`,g),e.removeEventListener(`mouseleave`,_),e.removeEventListener(`focusin`,g),e.removeEventListener(`focusout`,_)})},b=n=>{let o=a.querySelector(`[data-duration]`);if(o===null){console.error(`demoman library: preview box for ${i} has no duration badge`);return}t.length(i,n).then(t=>{if(!r){if(t.kind===`nothing`){console.info(`demoman library: no length on ${i}'s card — ${t.reason}`);return}o.textContent=e(t.ms),o.title=`Length of the exported video`,o.hidden=!1}}).catch(e=>{console.warn(`demoman library: could not work out ${i}'s length —`,e)})},C=async()=>{let e;try{e=await t.bundle(i)}catch(e){f(`reading the frame bundle`,e);return}if(r)return;let n=y(e);if(n.kind!==`ready`){S(a,n);return}s=n.frames;try{await m(0)}catch(e){f(`drawing the first keyframe`,e);return}r||(S(a,n),v(),e!==null&&b(e))};n.push(t.whenVisible(a,()=>{C()}))}return{mount:i,dispose(){r=!0;for(let e of n)e();n.length=0}}}function w(e,t,n,r={}){let a=document.createElement(`div`);a.className=`empty`;for(let[e,t]of Object.entries(r))a.setAttribute(e,t);let o=document.createElement(`strong`);o.textContent=t;let s=document.createElement(`p`);s.className=`hint`,s.append(...typeof n==`string`?[n]:n);let c=document.createElement(`div`);return c.append(o,s),a.append(i(e),c),a}var T=(e,t)=>`${e}:${t}`,ee=1024**3;function E(e,t={},n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))r.setAttribute(e,n);return n!==void 0&&(r.textContent=n),r}function D(e,t,n={}){let r=E(`span`,{class:`tag`,...n});return r.append(i(e),t),r}function O(){let e=E(`div`,{class:`meter`}),t=E(`div`,{class:`meter-fill`});return e.append(t),{bar:e,set(n){t.style.width=`${(n*100).toFixed(1)}%`,e.toggleAttribute(`data-full`,n>=.9)}}}var k=`storage-panel`,A=16,te=300;function j(e,t,n=!1){let r=t.getBoundingClientRect(),i=document.documentElement.clientWidth,a=Math.min(te,i-32),o=r.right-a>=A?r.right-a:r.left,s=Math.max(A,Math.min(o,i-A-a)),c=t.closest(`[data-header]`),l=c!==null&&getComputedStyle(c).position===`sticky`;e.style.maxHeight=``;let u=e.offsetHeight,d=r.bottom+6,f=window.innerHeight-A-d,p=r.top-6-A,m=n&&e.dataset.side!==void 0?e.dataset.side===`above`:u>f&&(u<=p||p>f);e.dataset.side=m?`above`:`below`;let h=Math.max(0,m?p:f);u>h&&(e.style.maxHeight=`${Math.round(h)}px`);let g=Math.min(u,h),_=m?r.top-6-g:d;e.style.position=l?`fixed`:`absolute`,e.style.width=`${Math.round(a)}px`,e.style.left=`${Math.round(s+(l?0:window.scrollX))}px`,e.style.top=`${Math.round(_+(l?0:window.scrollY))}px`}var ne=e=>(e/ee).toFixed(2).replace(/\.?0+$/,``);function re(e){let t=null,n=E(`div`,{class:`library`,"data-library":``}),r=E(`aside`,{class:`library-side`,"data-header":``}),a=E(`nav`,{class:`side-group`,"aria-label":`Sections`,"data-jumps":``}),o=E(`div`,{class:`library-content`}),s=O();s.bar.setAttribute(`aria-hidden`,`true`);let c=E(`span`,{"data-meter":``}),l=E(`button`,{type:`button`,class:`btn btn-quiet storage-trigger`,"data-storage-trigger":``,popovertarget:k,"aria-controls":k});l.append(E(`span`,{class:`storage-label`},`Storage`),s.bar,c,i(`chevronDown`));let u=E(`div`,{class:`storage`}),d=E(`span`,{"data-total-size":``}),p=E(`span`,{class:`library-total`,"data-library-total":``});p.append(E(`span`,{class:`storage-label`},`Storage`),d);let h=E(`div`,{"data-notices":``}),g=E(`div`,{id:k,class:`storage-panel`,popover:``,"data-storage":``,"aria-label":`Storage`}),_=null;g.addEventListener(`beforetoggle`,e=>{e.newState===`open`&&j(g,l)}),g.addEventListener(`toggle`,e=>{let t=e.newState===`open`;l.toggleAttribute(`data-open`,t),_?.abort(),_=null,t&&(j(g,l),_=new AbortController,window.addEventListener(`resize`,()=>j(g,l),{signal:_.signal}),window.addEventListener(`scroll`,()=>j(g,l,!0),{passive:!0,signal:_.signal}))});let v=O();v.bar.setAttribute(`role`,`progressbar`),v.bar.setAttribute(`aria-label`,`Storage used`),v.bar.setAttribute(`aria-valuemin`,`0`),v.bar.setAttribute(`aria-valuemax`,`1`);let y=E(`p`,{class:`storage-used`,"data-storage-used":``}),b=E(`input`,{type:`number`,min:`0.25`,step:`0.25`,id:`storage-budget`,"data-storage-budget":``}),x=E(`p`,{class:`notice notice-error hidden`,role:`alert`,"data-budget-note":``});b.addEventListener(`change`,()=>{let e=Number(b.value);if(!Number.isFinite(e)||e<=0){x.textContent=m,x.classList.remove(`hidden`);return}x.classList.add(`hidden`),t?.setBudget?.(Math.round(e*ee))});let S=E(`div`,{class:`storage-budget-row`});S.append(b,E(`span`,{},`GB`));let C=E(`div`,{class:`storage-field`});C.append(E(`label`,{for:`storage-budget`},`Budget`),S,E(`p`,{class:`storage-hint`},`Saves automatically.`),x);let w=E(`button`,{type:`button`,"data-action":`reclaim`,class:`btn btn-quiet storage-reclaim`});w.append(i(`trash`),`Reclaim space`),w.addEventListener(`click`,()=>t?.reclaim?.());let T=E(`div`,{class:`storage-foot`});T.append(w,E(`p`,{class:`storage-hint`},`Clears cached exports, then hosted takes' motion, oldest first, until the library fits its budget.`)),g.append(E(`h2`,{class:`storage-title`},`Storage`),v.bar,y,C,T),u.append(l,g),r.append(E(`h1`,{},`Recordings`),a),o.append(h),n.append(r,o);let D=document.querySelector(`[data-storage-slot]`);return e&&(D??r).append(u),{box:n,jumps:a,content:o,notices:h,update(e,n){if(t=n,e.totalBytes===void 0)p.remove();else{let t=e.unmeasured??0,n=`${f(e.totalBytes)}${t>0?`+`:``}`,i=t>0?`${t} ${t===1?`folder`:`folders`} could not be measured`:null;d.textContent=n,p.setAttribute(`aria-label`,`Storage: ${n}${i===null?``:` (${i})`}`),i===null?p.removeAttribute(`title`):p.setAttribute(`title`,i),p.parentNode===null&&(D??r).append(p)}let i=f(e.usedBytes),a=f(e.budgetBytes);s.set(e.fraction),v.set(e.fraction),v.bar.setAttribute(`aria-valuenow`,e.fraction.toFixed(3)),c.textContent=`${i} of ${a}`,l.setAttribute(`aria-label`,`Storage: ${i} of ${a} used`),y.textContent=`${i} used of a ${a} budget`,document.activeElement!==b&&(b.value=ne(e.budgetBytes)),h.replaceChildren(...ie(e))}}}function ie(e){let t=[];return e.migrating&&t.push(E(`p`,{"data-migrating":``,class:`notice`},`Measuring existing demos…`)),e.migrationFailed&&t.push(E(`p`,{"data-migration-failed":``,class:`notice notice-warn`},`Measuring existing demos failed, so sizes below may be wrong. Open the extension's error log if this keeps happening.`)),e.chromeNearLimit&&t.push(E(`p`,{"data-chrome-limit":``,class:`notice notice-warn`},`Chrome is near its storage limit on this drive.`)),e.unwatched!=null&&t.push(E(`p`,{"data-unwatched":``,class:`notice notice-warn`},`New takes will not show until you reload — ${e.unwatched}.`)),e.notice!==null&&t.push(E(`p`,{"data-notice":``,class:`notice notice-error`},e.notice)),t}var ae=new WeakMap;function oe(e,t,n){let r=l(e),i=r.states.filter(e=>e.value!==`Complete`);if(r.hosts.length<=1&&i.length===0)return null;let a=E(`div`,{class:`filters`,role:`group`,"aria-label":`Filter`,"data-filters":``}),o=(e,t,r,i,a)=>{let o=E(`button`,{type:`button`,class:`pill`,"aria-pressed":r?`true`:`false`,...a});return o.append(e),t!==null&&o.append(E(`span`,{class:`pill-count`},String(t))),o.addEventListener(`click`,()=>n.filter(i)),o},s=t.host===null&&t.state===null;if(a.append(o(`All`,e.length,s,d,{"data-filter-all":``})),r.hosts.length>1)for(let e of r.hosts){let n=t.host===e.value;a.append(o(e.value,e.count,n,{...t,host:n?null:e.value},{"data-filter-host":e.value}))}i.length>0&&r.hosts.length>1&&a.append(E(`span`,{class:`filters-sep`,"aria-hidden":`true`}));for(let e of i){let n=t.state===e.value;a.append(o(e.value,e.count,n,{...t,state:n?null:e.value},{"data-filter-state":e.value}))}return a}function se(e,t){let n=E(`div`,{class:`row-tags`}),r=t.openReview;if(e.needsLook&&r!==void 0){let t=E(`button`,{type:`button`,class:`tag tag-warn tag-look`,"data-needs-look":``,"aria-label":`Needs a look: ${e.label}`,title:`Needs a look`});t.append(i(`circleAlert`)),t.addEventListener(`click`,()=>r(e.sceneId)),n.append(t)}return e.hosted&&n.append(D(`cloud`,`Hosted`,{"data-hosted":``,title:`Hosted copy stays online after a local delete`})),e.state===`Motion reclaimed`?n.append(D(`restore`,e.state,{"data-state-chip":``,class:`tag tag-warn`,title:e.authored?`Its motion was reclaimed to free space; Restore opens Runs to run its script again, which makes a new take`:`Its motion was reclaimed to free space; Restore re-shoots it in Runs`})):e.state===`Keyframes only`&&n.append(D(`image`,e.state,{"data-state-chip":``,title:`No motion was recorded for this take`})),n.childElementCount>0?n:null}function ce(e,t){let n=E(`div`,{"data-preview":``}),r=E(`canvas`,{"data-preview-canvas":``,"aria-hidden":`true`,hidden:``});n.append(r,E(`p`,{"data-preview-note":``},b({kind:`loading`})??``));let i=se(e,t);return i!==null&&n.append(i),n.append(E(`span`,{"data-duration":``,hidden:``})),n}var le={Complete:`complete`,"Motion reclaimed":`reclaimed`,"Keyframes only":`keyframesOnly`},M=e=>`name-${e}`;function ue(e,t){let n=E(`input`,{type:`text`,id:M(e.sceneId),"data-name":``,"aria-label":`Demo name`,title:e.name,placeholder:`Untitled`,spellcheck:`false`,autocomplete:`off`});n.value=e.name;let r=e.name;return n.addEventListener(`change`,()=>{let i=n.value.trim();if(i===r){n.value=r;return}r=i,n.value=i,n.title=i,t.rename(e.sceneId,i)}),n.addEventListener(`keydown`,e=>{e.key===`Escape`?(n.value=r,n.blur()):e.key===`Enter`&&n.blur()}),n}function de(e,t,n,r){let o=E(`article`,{class:`card`,"data-row":e.sceneId,"data-state":le[e.state],...e.name===``?{"aria-label":e.label}:{"aria-labelledby":M(e.sceneId)}}),s=!1;o.addEventListener(`pointerdown`,()=>{let e=document.activeElement;s=e?.matches(`[data-name]`)===!0&&o.contains(e)}),o.addEventListener(`click`,n=>{let r=n.target;s||r.closest(`button, input, a`)||(window.getSelection()?.toString()??``)===``&&t.edit(e.sceneId)}),o.append(ce(e,t));let c=E(`div`,{class:`row-actions`});if(e.servesReshoot){let n=E(`button`,{type:`button`,"data-action":`back-to-recording`,class:`btn btn-quiet btn-icon`,"aria-label":`Back to your recording: ${e.label}`,title:`Back to your recording — this take plays its re-shot frames; its recording is kept`});n.append(i(`undo`)),n.addEventListener(`click`,()=>t.backToRecording(e.sceneId)),c.append(n)}let l=e.canRestore?t.rerunLine?.(e.sceneId,e.authored)??null:null;if(e.canRestore&&l===null){let n=E(`button`,{type:`button`,"data-action":`restore`,class:`btn btn-quiet btn-icon`,"aria-label":`Restore motion: ${e.label}`,title:e.authored?`Restore motion — run its script again in Runs; a script-made take cannot be re-shot, so this makes a new take`:`Restore motion — re-shoot it in Runs`});n.append(i(`restore`)),n.addEventListener(`click`,()=>t.restore(e.sceneId)),c.append(n)}let u=E(`button`,{type:`button`,"data-action":`edit`,class:`btn btn-quiet btn-icon`,"aria-label":`Edit ${e.label}`,title:`Edit`});u.append(i(`clapperboard`)),u.addEventListener(`click`,()=>t.edit(e.sceneId)),c.append(u);let d=E(`button`,{type:`button`,"data-action":`delete`,class:`btn btn-quiet btn-icon btn-danger`,"aria-label":`Delete ${e.label}`,title:`Delete`});d.append(i(`trash`)),d.addEventListener(`click`,()=>t.remove(e.sceneId,`take`)),c.append(d);let p=E(`div`,{class:`row-text`}),m=E(`div`,{class:`row-title`});m.append(ue(e,t),c),p.append(m);let h=`${e.origin}${e.path}`,g=E(`div`,{class:`row-line`});if(g.append(E(`p`,{class:`row-meta`,title:h},`${h} · ${r?e.time:e.when}`)),e.sizeBytes===void 0?t.reclaim!==void 0&&g.append(E(`p`,{"data-size":``,class:`row-size`},`${f(e.frameBytes)} frames · ${f(e.outputBytes)} renders`)):g.append(E(`p`,{"data-size":``,class:`row-size`},f(e.sizeBytes))),p.append(g),o.append(p),l!==null){let e=E(`p`,{"data-rerun-line":``,class:`row-rerun`});a(e,l),o.append(e)}return n!==void 0&&o.append(E(`p`,{"data-status":``,class:`notice notice-error`},n)),o}function fe(e){let t=document.activeElement;if(!(t instanceof HTMLInputElement)||!t.matches(`[data-name]`)||!e.contains(t))return null;let n=t.closest(`[data-row]`)?.getAttribute(`data-row`);return n?{sceneId:n,value:t.value,start:t.selectionStart,end:t.selectionEnd}:null}function pe(e,t){if(t===null)return;let n=e.querySelector(`[data-row="${CSS.escape(t.sceneId)}"] [data-name]`);n!==null&&(n.value=t.value,n.focus(),t.start!==null&&t.end!==null&&n.setSelectionRange(t.start,t.end))}var me=e=>`section-${e.replace(/:/g,`-`)}`;function he(e){let t=new Map;for(let n of e.querySelectorAll(`[data-section]`)){let e=n.getAttribute(`data-section`);e!==null&&t.set(e,n.open)}return t.size>0?(N.set(e,t),t):N.get(e)??t}var N=new WeakMap,P=`unreadable`,ge=e=>`when-${e.replace(/:/g,`-`)}`;function _e(e,t){let n=E(`div`,{class:`side-list`});for(let t of e){let e=ge(t.key),r=E(`a`,{href:`#${e}`,class:`side-item`,"data-nav":e,title:t.label});r.append(E(`span`,{class:`side-label`},t.label),E(`span`,{class:`side-count`},String(t.rows.length))),r.addEventListener(`click`,()=>{let t=document.getElementById(e);t instanceof HTMLDetailsElement&&(t.open=!0)}),n.append(r)}if(t>0){let e=E(`a`,{href:`#${P}`,class:`side-item`,"data-nav":P,title:`Couldn't read`});e.append(E(`span`,{class:`side-label`},`Couldn't read`),E(`span`,{class:`side-count`},String(t))),n.append(e)}return n}function ve(e,t,n,r){let a=me(e.key),o=E(`details`,{class:`section`,id:ge(e.key),"data-section":e.key,"aria-labelledby":a});o.open=t;let s=E(`summary`,{class:`section-head`}),c=i(`chevronRight`);c.classList.add(`chev`),s.append(c,E(`h2`,{id:a},e.label),E(`span`,{class:`section-count`,"data-section-count":``},String(e.rows.length))),o.append(s);let l=E(`div`,{class:`rows`}),u=e.rows.map(t=>{let i=de(t,n,r.get(T(`take`,t.sceneId)),e.namesDay);return l.append(i),[t.sceneId,i]});return o.append(l),{box:o,articles:u}}function ye(e,t,n){let r=E(`section`,{class:`section`,id:P,"data-unreadable":``,"aria-labelledby":`section-unreadable`}),a=E(`div`,{class:`section-head`});a.append(E(`h2`,{id:`section-unreadable`},`Couldn't read`),E(`span`,{class:`section-count`},String(e.length))),r.append(a);let o=E(`div`,{class:`rows`});for(let r of e){let e=E(`article`,{class:`card`,"data-unreadable-row":r.folder}),a=E(`div`,{class:`row-text`}),s=E(`div`,{class:`row-title`}),c=E(`button`,{type:`button`,"data-action":`delete`,class:`btn btn-quiet btn-icon btn-danger`,"aria-label":`Delete ${r.folder}`,title:`Delete`});c.append(i(`trash`)),c.addEventListener(`click`,()=>t.remove(r.folder,`folder`)),s.append(E(`p`,{class:`row-meta`,"data-unreadable-name":``},r.folder),c),a.append(s,E(`p`,{class:`row-meta`,"data-reason":``},r.reason)),r.sizeBytes!==void 0&&a.append(E(`p`,{"data-size":``,class:`row-size`},f(r.sizeBytes))),e.append(a);let l=n.get(T(`folder`,r.folder));l!==void 0&&e.append(E(`p`,{"data-status":``,class:`notice notice-error`},l)),o.append(e)}return r.append(o),r}function be(e,t,n,r,i=d,a=new Date){let o=fe(e),c=he(e),l=ae.get(e);l===void 0&&(l=re(n.reclaim!==void 0&&n.setBudget!==void 0),ae.set(e,l)),l.update(t,n);for(let t of[...e.childNodes])t!==l.box&&t.remove();l.box.parentNode!==e&&e.prepend(l.box);for(let e of[...l.content.childNodes])e!==l.notices&&e.remove();l.jumps.replaceChildren();let f=l.content,p=t.unreadable??[],m=()=>{p.length>0&&f.append(ye(p,n,r))};if(t.rows.length===0){if(p.length>0){m();return}let e=E(`div`,{"data-empty":``,class:`card empty-card`});e.append(w(`monitorPlay`,`No recordings yet`,t.emptyHint??`Click the Demoman icon in your browser's toolbar and press Record. Each take shows up here, grouped by the day you made it.`)),f.append(e);return}let h=oe(t.rows,i,n);h!==null&&f.append(h);let g=s(t.rows,i);if(g.length===0){let e=E(`button`,{type:`button`,class:`btn btn-link`,"data-filter-all":``},`Show all recordings`);e.addEventListener(`click`,()=>n.filter(d));let t=E(`div`,{"data-empty-filtered":``,class:`card empty-card`});t.append(w(`funnel`,`No recordings match this filter`,[e])),f.append(t),m();return}let _=[],v=u(g,a);l.jumps.append(_e(v,p.length));for(let e of v){let t=ve(e,c.get(e.key)??!e.folded,n,r);f.append(t.box),_.push(...t.articles)}m();for(let[e,t]of _)n.preview(e,t.querySelector(`[data-preview]`));pe(e,o)}var xe=document.querySelector(`#root`),F=document.querySelector(`#notice`),Se=g(xe),I=r(),L=I.scenes;I.nav.onOpen?.(e=>location.assign(e)),_(I);var R=new Map;function z(e,t){F.textContent=e,F.className=t===`info`?`notice`:`notice notice-${t}`,F.classList.remove(`hidden`)}function B(e){z(e,`error`)}function Ce(){F.textContent=``,F.className=`notice notice-error hidden`}function V(e,t){console.error(`demoman library: ${e} —`,t),B(`Something went wrong (${e}). Try again.`)}function we(e,t){try{location.assign(e)}catch(e){V(t,e)}}var H=I.bundles,U=new Map,W=typeof IntersectionObserver==`function`?new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;let e=U.get(t.target);e!==void 0&&(U.delete(t.target),W?.unobserve(t.target),e())}},{rootMargin:`200px`}):null,G=!1,Te=(e,t)=>W===null?(G||(G=!0,console.info(`demoman library: no IntersectionObserver here, so every preview paints at once`)),t(),()=>{}):(U.set(e,t),W.observe(e),()=>{U.delete(e),W.unobserve(e)}),K=new Map,Ee={bundle:async e=>(await H.active(e)).bundle,length:async(e,n)=>{let r=K.get(e);if(r===void 0)throw Error(`no document for ${e} in the last listing`);return t(r,n,H.load)},image:async e=>{if(I.folder!==void 0)return I.folder.thumb(e);let t=await H.load(e);if(t instanceof Uint8Array)throw Error(`${e} loaded as motion bytes, not a keyframe`);if(!(t.image instanceof ImageBitmap))throw Error(`${e} decoded to something other than an ImageBitmap`);return t.image},whenVisible:Te},q=null,J=null,Y=d;function De(e){let t=new Set([...e.rows.map(e=>T(`take`,e.sceneId)),...(e.unreadable??[]).map(e=>T(`folder`,e.folder))]);for(let e of R.keys())t.has(e)||R.delete(e)}function X(e){De(e),q?.dispose(),q=C(Ee),be(xe,e,Ne,R,Y),Se.mark()}var Oe=h({paint:e=>ke({keepNotice:e}),onRefreshFailed:e=>V(`refreshing the library`,e)});function Z(){return Oe.render()}async function ke({keepNotice:e=!1}={}){e||Ce();let t=await I.folder.read(),n=t.scenes;K=new Map(n.map(e=>[e.meta.id,e]));let r=p({sizes:t.sizes,unreadable:t.unreadable,unwatched:t.unwatched,emptyHint:I.nav.firstTakeHint(),scenes:n,migrating:!1,migrationFailed:!1,notice:null,needsLook:new Set});J=r,X(r)}var Ae={recording:`a take is recording`,rendering:`a render is running`,sharing:`a share is in progress`,replaying:`a take is being run in Runs`},Q=new Map;function je(e,t,n){let r=Q.get(e);if(r===void 0){we(t,n);return}r.then(e=>{e&&we(t,n)})}function Me(e){return K.get(e)?.meta.capture.mode===`authored`}var Ne={filter:e=>{if(Y=e,J===null){console.error(`demoman library: a filter was picked before the page had rendered`);return}X(J)},preview:(e,t)=>{if(q===null){console.error(`demoman library: a row asked for a preview before the page had a mounter`);return}q.mount(e,t)},edit:e=>{je(e,I.nav.editor(e),`opening the editor`)},rename:(e,t)=>{let n=(async()=>{try{let n=null;try{let r=await L.get(e);if(r===null)n=`the take is no longer stored`;else{let e={...r.scene,meta:{...r.scene.meta,name:t}};await L.put(e,r.revision)}}catch(e){n=e instanceof Error?e.message:String(e)}let r=T(`take`,e);return n===null?R.delete(r):R.set(r,`Couldn't rename: ${n}.`),await Z(),n===null}catch(t){return V(`renaming this demo`,t),R.set(T(`take`,e),`Couldn't rename: ${t instanceof Error?t.message:String(t)}.`),J!==null&&X(J),!1}})();Q.set(e,n),n.finally(()=>{Q.get(e)===n&&Q.delete(e)})},restore:e=>{let t=I.nav.rerun(e,Me(e));if(t.kind===`line`){console.error(`demoman library: Restore was pressed on a platform whose route is a line`);return}je(e,new URL(t.href,I.nav.library()).href,`opening Runs to restore motion`)},rerunLine:(e,t)=>{let n=I.nav.rerun(e,t);return n.kind===`line`?n.text:null},backToRecording:e=>{(async()=>{let t=null,n=await Q.get(e),r=T(`take`,e),i=n===!1?R.get(r):void 0;try{let n=await L.get(e);if(n===null)throw Error(`the take is no longer stored`);let r={...n.scene,meta:{...n.scene.meta,renderMode:`screen`}};await L.put(r,n.revision);let i=(await H.active(e)).bundle;i?.source!==`capture`&&(t=i===null?`Your recording could not be put back: no frames could be read for this take.`:`There is no recording of this take to go back to, so it keeps its re-shot frames. Takes rebuilt before recordings were kept have none.`,console.info(`[demoman] library: back to your recording — not served (${i===null?`no bundle`:`serving ${i.source}`})`))}catch(e){V(`going back to the recording`,e),t=`Couldn't go back to the recording: ${e instanceof Error?e.message:String(e)}.`}let a=[i,t].filter(e=>e!=null).join(` `);a===``?R.delete(r):R.set(r,a);try{await Z()}catch(e){V(`refreshing the library`,e)}})()},remove:(e,t)=>{let r=T(t,e);(async()=>{try{let t;try{t=await n(o)}catch(e){console.error(`demoman library: asking before a delete —`,e),R.set(r,`Not deleted: the confirmation could not open — ${e instanceof Error?e.message:String(e)}.`),await Z();return}if(!t)return;await Q.get(e);let i=await L.remove(e),a=null;if(!i.ok){let e=i.detail??Ae[i.error]??i.error;R.set(r,`Not deleted: ${e}.`)}else if(i.result!==void 0&&!i.result.ok){let e=i.result.steps.find(e=>!e.ok),t=`Partly deleted: ${e?.step??`a step`} could not be removed — ${e?.error??`unknown error`}`;i.result.steps.find(e=>e.step===`scene`)?.ok===!0?(R.delete(r),a=t):R.set(r,t)}else R.delete(r);await Z(),a===null?i.ok&&i.note!==void 0&&z(i.note,`info`):B(a)}catch(e){V(`deleting this demo`,e)}})()}};I.folder?.onChange(()=>Oe.soon());var $=c();Z().then(()=>{$!==null&&z($,`info`)},e=>{$!==null&&console.info(`demoman library: ${$}`),V(`loading your demos`,e)});
1
+ import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./confirm-dialog-CN_GqXY_.js";import{a as s,d as c,i as l,l as u,n as d,o as f,r as p,t as m}from"./state-COWbBf84.js";import{n as h,r as g,t as _}from"./topbar-sSUyITjl.js";function v(e,t){let n=e=>({ref:e.ref,sourceTimeMs:e.sourceTimeMs});if(e.length<=t)return e.map(n);let r=t>1?(e.length-1)/(t-1):0,i=new Set(Array.from({length:Math.max(0,t)},(e,t)=>Math.round(t*r)));return e.filter((e,t)=>i.has(t)).map(n)}function y(e){return e===null?{kind:`noBundle`}:e.keyframes.length===0?{kind:`noKeyframes`}:{kind:`ready`,frames:v(e.keyframes,8)}}function b(e){switch(e.kind){case`ready`:return null;case`loading`:return`Loading preview…`;case`noBundle`:return`No frames stored — nothing to preview.`;case`noKeyframes`:return`This demo has no keyframes.`;case`failed`:return`Preview unavailable — ${e.reason}`}}function x(e,t){return t<=1?0:(e+1)%t}function S(e,t){let n=e.querySelector(`[data-preview-canvas]`),r=e.querySelector(`[data-preview-note]`),i=b(t);n!==null&&(n.hidden=i!==null),r!==null&&(r.textContent=i??``)}function C(t){let n=[],r=!1;function i(i,a){let o=a.querySelector(`[data-preview-canvas]`);if(o===null){console.error(`demoman library: preview box for ${i} has no canvas to paint into`),S(a,{kind:`failed`,reason:`this row has no canvas to paint into`});return}let s=[],c=[],l=0,u=null,d=()=>{u!==null&&(clearInterval(u),u=null)};n.push(d);let f=(e,t)=>{d(),console.error(`demoman library: ${e} for ${i} —`,t),S(a,{kind:`failed`,reason:t instanceof Error?t.message:String(t)})},p=async e=>{let n=c[e];if(n!==void 0)return n;let r=s[e];if(r===void 0)throw Error(`preview frame ${e} is past the end of the take`);let i=await t.image(r.ref),a=document.createElement(`canvas`);return a.width=320,a.height=Math.max(1,Math.round(320*i.height/i.width)),a.getContext(`2d`)?.drawImage(i,0,0,a.width,a.height),i.close(),c[e]=a,a},m=async e=>{let t=await p(e);r||(o.width=t.width,o.height=t.height,o.style.setProperty(`--thumb-ratio`,String(t.width/t.height)),o.getContext(`2d`)?.drawImage(t,0,0))},h=()=>{l=x(l,s.length),m(l).catch(e=>f(`drawing a keyframe`,e))},g=()=>{u!==null||s.length<=1||(u=setInterval(h,400))},_=()=>{d(),l=0,m(0).catch(e=>f(`drawing the first keyframe`,e))},v=()=>{let e=a.closest(`article`);if(e===null){console.error(`demoman library: preview box for ${i} has no row to hover`);return}e.addEventListener(`mouseenter`,g),e.addEventListener(`mouseleave`,_),e.addEventListener(`focusin`,g),e.addEventListener(`focusout`,_),n.push(()=>{e.removeEventListener(`mouseenter`,g),e.removeEventListener(`mouseleave`,_),e.removeEventListener(`focusin`,g),e.removeEventListener(`focusout`,_)})},b=n=>{let o=a.querySelector(`[data-duration]`);if(o===null){console.error(`demoman library: preview box for ${i} has no duration badge`);return}t.length(i,n).then(t=>{if(!r){if(t.kind===`nothing`){console.info(`demoman library: no length on ${i}'s card — ${t.reason}`);return}o.textContent=e(t.ms),o.title=`Length of the exported video`,o.hidden=!1}}).catch(e=>{console.warn(`demoman library: could not work out ${i}'s length —`,e)})},C=async()=>{let e;try{e=await t.bundle(i)}catch(e){f(`reading the frame bundle`,e);return}if(r)return;let n=y(e);if(n.kind!==`ready`){S(a,n);return}s=n.frames;try{await m(0)}catch(e){f(`drawing the first keyframe`,e);return}r||(S(a,n),v(),e!==null&&b(e))};n.push(t.whenVisible(a,()=>{C()}))}return{mount:i,dispose(){r=!0;for(let e of n)e();n.length=0}}}function w(e,t,n,r={}){let a=document.createElement(`div`);a.className=`empty`;for(let[e,t]of Object.entries(r))a.setAttribute(e,t);let o=document.createElement(`strong`);o.textContent=t;let s=document.createElement(`p`);s.className=`hint`,s.append(...typeof n==`string`?[n]:n);let c=document.createElement(`div`);return c.append(o,s),a.append(i(e),c),a}var T=(e,t)=>`${e}:${t}`,ee=1024**3;function E(e,t={},n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))r.setAttribute(e,n);return n!==void 0&&(r.textContent=n),r}function D(e,t,n={}){let r=E(`span`,{class:`tag`,...n});return r.append(i(e),t),r}function O(){let e=E(`div`,{class:`meter`}),t=E(`div`,{class:`meter-fill`});return e.append(t),{bar:e,set(n){t.style.width=`${(n*100).toFixed(1)}%`,e.toggleAttribute(`data-full`,n>=.9)}}}var k=`storage-panel`,A=16,te=300;function j(e,t,n=!1){let r=t.getBoundingClientRect(),i=document.documentElement.clientWidth,a=Math.min(te,i-32),o=r.right-a>=A?r.right-a:r.left,s=Math.max(A,Math.min(o,i-A-a)),c=t.closest(`[data-header]`),l=c!==null&&getComputedStyle(c).position===`sticky`;e.style.maxHeight=``;let u=e.offsetHeight,d=r.bottom+6,f=window.innerHeight-A-d,p=r.top-6-A,m=n&&e.dataset.side!==void 0?e.dataset.side===`above`:u>f&&(u<=p||p>f);e.dataset.side=m?`above`:`below`;let h=Math.max(0,m?p:f);u>h&&(e.style.maxHeight=`${Math.round(h)}px`);let g=Math.min(u,h),_=m?r.top-6-g:d;e.style.position=l?`fixed`:`absolute`,e.style.width=`${Math.round(a)}px`,e.style.left=`${Math.round(s+(l?0:window.scrollX))}px`,e.style.top=`${Math.round(_+(l?0:window.scrollY))}px`}var ne=e=>(e/ee).toFixed(2).replace(/\.?0+$/,``);function re(e){let t=null,n=E(`div`,{class:`library`,"data-library":``}),r=E(`aside`,{class:`library-side`,"data-header":``}),a=E(`nav`,{class:`side-group`,"aria-label":`Sections`,"data-jumps":``}),o=E(`div`,{class:`library-content`}),s=O();s.bar.setAttribute(`aria-hidden`,`true`);let c=E(`span`,{"data-meter":``}),l=E(`button`,{type:`button`,class:`btn btn-quiet storage-trigger`,"data-storage-trigger":``,popovertarget:k,"aria-controls":k});l.append(E(`span`,{class:`storage-label`},`Storage`),s.bar,c,i(`chevronDown`));let u=E(`div`,{class:`storage`}),d=E(`span`,{"data-total-size":``}),p=E(`span`,{class:`library-total`,"data-library-total":``});p.append(E(`span`,{class:`storage-label`},`Storage`),d);let h=E(`div`,{"data-notices":``}),g=E(`div`,{id:k,class:`storage-panel`,popover:``,"data-storage":``,"aria-label":`Storage`}),_=null;g.addEventListener(`beforetoggle`,e=>{e.newState===`open`&&j(g,l)}),g.addEventListener(`toggle`,e=>{let t=e.newState===`open`;l.toggleAttribute(`data-open`,t),_?.abort(),_=null,t&&(j(g,l),_=new AbortController,window.addEventListener(`resize`,()=>j(g,l),{signal:_.signal}),window.addEventListener(`scroll`,()=>j(g,l,!0),{passive:!0,signal:_.signal}))});let v=O();v.bar.setAttribute(`role`,`progressbar`),v.bar.setAttribute(`aria-label`,`Storage used`),v.bar.setAttribute(`aria-valuemin`,`0`),v.bar.setAttribute(`aria-valuemax`,`1`);let y=E(`p`,{class:`storage-used`,"data-storage-used":``}),b=E(`input`,{type:`number`,min:`0.25`,step:`0.25`,id:`storage-budget`,"data-storage-budget":``}),x=E(`p`,{class:`notice notice-error hidden`,role:`alert`,"data-budget-note":``});b.addEventListener(`change`,()=>{let e=Number(b.value);if(!Number.isFinite(e)||e<=0){x.textContent=m,x.classList.remove(`hidden`);return}x.classList.add(`hidden`),t?.setBudget?.(Math.round(e*ee))});let S=E(`div`,{class:`storage-budget-row`});S.append(b,E(`span`,{},`GB`));let C=E(`div`,{class:`storage-field`});C.append(E(`label`,{for:`storage-budget`},`Budget`),S,E(`p`,{class:`storage-hint`},`Saves automatically.`),x);let w=E(`button`,{type:`button`,"data-action":`reclaim`,class:`btn btn-quiet storage-reclaim`});w.append(i(`trash`),`Reclaim space`),w.addEventListener(`click`,()=>t?.reclaim?.());let T=E(`div`,{class:`storage-foot`});T.append(w,E(`p`,{class:`storage-hint`},`Clears cached exports, then hosted takes' motion, oldest first, until the library fits its budget.`)),g.append(E(`h2`,{class:`storage-title`},`Storage`),v.bar,y,C,T),u.append(l,g),r.append(E(`h1`,{},`Recordings`),a),o.append(h),n.append(r,o);let D=document.querySelector(`[data-storage-slot]`);return e&&(D??r).append(u),{box:n,jumps:a,content:o,notices:h,update(e,n){if(t=n,e.totalBytes===void 0)p.remove();else{let t=e.unmeasured??0,n=`${f(e.totalBytes)}${t>0?`+`:``}`,i=t>0?`${t} ${t===1?`folder`:`folders`} could not be measured`:null;d.textContent=n,p.setAttribute(`aria-label`,`Storage: ${n}${i===null?``:` (${i})`}`),i===null?p.removeAttribute(`title`):p.setAttribute(`title`,i),p.parentNode===null&&(D??r).append(p)}let i=f(e.usedBytes),a=f(e.budgetBytes);s.set(e.fraction),v.set(e.fraction),v.bar.setAttribute(`aria-valuenow`,e.fraction.toFixed(3)),c.textContent=`${i} of ${a}`,l.setAttribute(`aria-label`,`Storage: ${i} of ${a} used`),y.textContent=`${i} used of a ${a} budget`,document.activeElement!==b&&(b.value=ne(e.budgetBytes)),h.replaceChildren(...ie(e))}}}function ie(e){let t=[];return e.migrating&&t.push(E(`p`,{"data-migrating":``,class:`notice`},`Measuring existing demos…`)),e.migrationFailed&&t.push(E(`p`,{"data-migration-failed":``,class:`notice notice-warn`},`Measuring existing demos failed, so sizes below may be wrong. Open the extension's error log if this keeps happening.`)),e.chromeNearLimit&&t.push(E(`p`,{"data-chrome-limit":``,class:`notice notice-warn`},`Chrome is near its storage limit on this drive.`)),e.unwatched!=null&&t.push(E(`p`,{"data-unwatched":``,class:`notice notice-warn`},`New takes will not show until you reload — ${e.unwatched}.`)),e.notice!==null&&t.push(E(`p`,{"data-notice":``,class:`notice notice-error`},e.notice)),t}var ae=new WeakMap;function oe(e,t,n){let r=l(e),i=r.states.filter(e=>e.value!==`Complete`);if(r.hosts.length<=1&&i.length===0)return null;let a=E(`div`,{class:`filters`,role:`group`,"aria-label":`Filter`,"data-filters":``}),o=(e,t,r,i,a)=>{let o=E(`button`,{type:`button`,class:`pill`,"aria-pressed":r?`true`:`false`,...a});return o.append(e),t!==null&&o.append(E(`span`,{class:`pill-count`},String(t))),o.addEventListener(`click`,()=>n.filter(i)),o},s=t.host===null&&t.state===null;if(a.append(o(`All`,e.length,s,d,{"data-filter-all":``})),r.hosts.length>1)for(let e of r.hosts){let n=t.host===e.value;a.append(o(e.value,e.count,n,{...t,host:n?null:e.value},{"data-filter-host":e.value}))}i.length>0&&r.hosts.length>1&&a.append(E(`span`,{class:`filters-sep`,"aria-hidden":`true`}));for(let e of i){let n=t.state===e.value;a.append(o(e.value,e.count,n,{...t,state:n?null:e.value},{"data-filter-state":e.value}))}return a}function se(e,t){let n=E(`div`,{class:`row-tags`}),r=t.openReview;if(e.needsLook&&r!==void 0){let t=E(`button`,{type:`button`,class:`tag tag-warn tag-look`,"data-needs-look":``,"aria-label":`Needs a look: ${e.label}`,title:`Needs a look`});t.append(i(`circleAlert`)),t.addEventListener(`click`,()=>r(e.sceneId)),n.append(t)}return e.hosted&&n.append(D(`cloud`,`Hosted`,{"data-hosted":``,title:`Hosted copy stays online after a local delete`})),e.state===`Motion reclaimed`?n.append(D(`restore`,e.state,{"data-state-chip":``,class:`tag tag-warn`,title:e.authored?`Its motion was reclaimed to free space; Restore opens Runs to run its script again, which makes a new take`:`Its motion was reclaimed to free space; Restore re-shoots it in Runs`})):e.state===`Keyframes only`&&n.append(D(`image`,e.state,{"data-state-chip":``,title:`No motion was recorded for this take`})),n.childElementCount>0?n:null}function ce(e,t){let n=E(`div`,{"data-preview":``}),r=E(`canvas`,{"data-preview-canvas":``,"aria-hidden":`true`,hidden:``});n.append(r,E(`p`,{"data-preview-note":``},b({kind:`loading`})??``));let i=se(e,t);return i!==null&&n.append(i),n.append(E(`span`,{"data-duration":``,hidden:``})),n}var le={Complete:`complete`,"Motion reclaimed":`reclaimed`,"Keyframes only":`keyframesOnly`},M=e=>`name-${e}`;function ue(e,t){let n=E(`input`,{type:`text`,id:M(e.sceneId),"data-name":``,"aria-label":`Demo name`,title:e.name,placeholder:`Untitled`,spellcheck:`false`,autocomplete:`off`});n.value=e.name;let r=e.name;return n.addEventListener(`change`,()=>{let i=n.value.trim();if(i===r){n.value=r;return}r=i,n.value=i,n.title=i,t.rename(e.sceneId,i)}),n.addEventListener(`keydown`,e=>{e.key===`Escape`?(n.value=r,n.blur()):e.key===`Enter`&&n.blur()}),n}function de(e,t,n,r){let o=E(`article`,{class:`card`,"data-row":e.sceneId,"data-state":le[e.state],...e.name===``?{"aria-label":e.label}:{"aria-labelledby":M(e.sceneId)}}),s=!1;o.addEventListener(`pointerdown`,()=>{let e=document.activeElement;s=e?.matches(`[data-name]`)===!0&&o.contains(e)}),o.addEventListener(`click`,n=>{let r=n.target;s||r.closest(`button, input, a`)||(window.getSelection()?.toString()??``)===``&&t.edit(e.sceneId)}),o.append(ce(e,t));let c=E(`div`,{class:`row-actions`});if(e.servesReshoot){let n=E(`button`,{type:`button`,"data-action":`back-to-recording`,class:`btn btn-quiet btn-icon`,"aria-label":`Back to your recording: ${e.label}`,title:`Back to your recording — this take plays its re-shot frames; its recording is kept`});n.append(i(`undo`)),n.addEventListener(`click`,()=>t.backToRecording(e.sceneId)),c.append(n)}let l=e.canRestore?t.rerunLine?.(e.sceneId,e.authored)??null:null;if(e.canRestore&&l===null){let n=E(`button`,{type:`button`,"data-action":`restore`,class:`btn btn-quiet btn-icon`,"aria-label":`Restore motion: ${e.label}`,title:e.authored?`Restore motion — run its script again in Runs; a script-made take cannot be re-shot, so this makes a new take`:`Restore motion — re-shoot it in Runs`});n.append(i(`restore`)),n.addEventListener(`click`,()=>t.restore(e.sceneId)),c.append(n)}let u=E(`button`,{type:`button`,"data-action":`edit`,class:`btn btn-quiet btn-icon`,"aria-label":`Edit ${e.label}`,title:`Edit`});u.append(i(`clapperboard`)),u.addEventListener(`click`,()=>t.edit(e.sceneId)),c.append(u);let d=E(`button`,{type:`button`,"data-action":`delete`,class:`btn btn-quiet btn-icon btn-danger`,"aria-label":`Delete ${e.label}`,title:`Delete`});d.append(i(`trash`)),d.addEventListener(`click`,()=>t.remove(e.sceneId,`take`)),c.append(d);let p=E(`div`,{class:`row-text`}),m=E(`div`,{class:`row-title`});m.append(ue(e,t),c),p.append(m);let h=`${e.origin}${e.path}`,g=E(`div`,{class:`row-line`});if(g.append(E(`p`,{class:`row-meta`,title:h},`${h} · ${r?e.time:e.when}`)),e.sizeBytes===void 0?t.reclaim!==void 0&&g.append(E(`p`,{"data-size":``,class:`row-size`},`${f(e.frameBytes)} frames · ${f(e.outputBytes)} renders`)):g.append(E(`p`,{"data-size":``,class:`row-size`},f(e.sizeBytes))),p.append(g),o.append(p),l!==null){let e=E(`p`,{"data-rerun-line":``,class:`row-rerun`});a(e,l),o.append(e)}return n!==void 0&&o.append(E(`p`,{"data-status":``,class:`notice notice-error`},n)),o}function fe(e){let t=document.activeElement;if(!(t instanceof HTMLInputElement)||!t.matches(`[data-name]`)||!e.contains(t))return null;let n=t.closest(`[data-row]`)?.getAttribute(`data-row`);return n?{sceneId:n,value:t.value,start:t.selectionStart,end:t.selectionEnd}:null}function pe(e,t){if(t===null)return;let n=e.querySelector(`[data-row="${CSS.escape(t.sceneId)}"] [data-name]`);n!==null&&(n.value=t.value,n.focus(),t.start!==null&&t.end!==null&&n.setSelectionRange(t.start,t.end))}var me=e=>`section-${e.replace(/:/g,`-`)}`;function he(e){let t=new Map;for(let n of e.querySelectorAll(`[data-section]`)){let e=n.getAttribute(`data-section`);e!==null&&t.set(e,n.open)}return t.size>0?(N.set(e,t),t):N.get(e)??t}var N=new WeakMap,P=`unreadable`,ge=e=>`when-${e.replace(/:/g,`-`)}`;function _e(e,t){let n=E(`div`,{class:`side-list`});for(let t of e){let e=ge(t.key),r=E(`a`,{href:`#${e}`,class:`side-item`,"data-nav":e,title:t.label});r.append(E(`span`,{class:`side-label`},t.label),E(`span`,{class:`side-count`},String(t.rows.length))),r.addEventListener(`click`,()=>{let t=document.getElementById(e);t instanceof HTMLDetailsElement&&(t.open=!0)}),n.append(r)}if(t>0){let e=E(`a`,{href:`#${P}`,class:`side-item`,"data-nav":P,title:`Couldn't read`});e.append(E(`span`,{class:`side-label`},`Couldn't read`),E(`span`,{class:`side-count`},String(t))),n.append(e)}return n}function ve(e,t,n,r){let a=me(e.key),o=E(`details`,{class:`section`,id:ge(e.key),"data-section":e.key,"aria-labelledby":a});o.open=t;let s=E(`summary`,{class:`section-head`}),c=i(`chevronRight`);c.classList.add(`chev`),s.append(c,E(`h2`,{id:a},e.label),E(`span`,{class:`section-count`,"data-section-count":``},String(e.rows.length))),o.append(s);let l=E(`div`,{class:`rows`}),u=e.rows.map(t=>{let i=de(t,n,r.get(T(`take`,t.sceneId)),e.namesDay);return l.append(i),[t.sceneId,i]});return o.append(l),{box:o,articles:u}}function ye(e,t,n){let r=E(`section`,{class:`section`,id:P,"data-unreadable":``,"aria-labelledby":`section-unreadable`}),a=E(`div`,{class:`section-head`});a.append(E(`h2`,{id:`section-unreadable`},`Couldn't read`),E(`span`,{class:`section-count`},String(e.length))),r.append(a);let o=E(`div`,{class:`rows`});for(let r of e){let e=E(`article`,{class:`card`,"data-unreadable-row":r.folder}),a=E(`div`,{class:`row-text`}),s=E(`div`,{class:`row-title`}),c=E(`button`,{type:`button`,"data-action":`delete`,class:`btn btn-quiet btn-icon btn-danger`,"aria-label":`Delete ${r.folder}`,title:`Delete`});c.append(i(`trash`)),c.addEventListener(`click`,()=>t.remove(r.folder,`folder`)),s.append(E(`p`,{class:`row-meta`,"data-unreadable-name":``},r.folder),c),a.append(s,E(`p`,{class:`row-meta`,"data-reason":``},r.reason)),r.sizeBytes!==void 0&&a.append(E(`p`,{"data-size":``,class:`row-size`},f(r.sizeBytes))),e.append(a);let l=n.get(T(`folder`,r.folder));l!==void 0&&e.append(E(`p`,{"data-status":``,class:`notice notice-error`},l)),o.append(e)}return r.append(o),r}function be(e,t,n,r,i=d,a=new Date){let o=fe(e),c=he(e),l=ae.get(e);l===void 0&&(l=re(n.reclaim!==void 0&&n.setBudget!==void 0),ae.set(e,l)),l.update(t,n);for(let t of[...e.childNodes])t!==l.box&&t.remove();l.box.parentNode!==e&&e.prepend(l.box);for(let e of[...l.content.childNodes])e!==l.notices&&e.remove();l.jumps.replaceChildren();let f=l.content,p=t.unreadable??[],m=()=>{p.length>0&&f.append(ye(p,n,r))};if(t.rows.length===0){if(p.length>0){m();return}let e=E(`div`,{"data-empty":``,class:`card empty-card`});e.append(w(`monitorPlay`,`No recordings yet`,t.emptyHint??`Click the Demoman icon in your browser's toolbar and press Record. Each take shows up here, grouped by the day you made it.`)),f.append(e);return}let h=oe(t.rows,i,n);h!==null&&f.append(h);let g=s(t.rows,i);if(g.length===0){let e=E(`button`,{type:`button`,class:`btn btn-link`,"data-filter-all":``},`Show all recordings`);e.addEventListener(`click`,()=>n.filter(d));let t=E(`div`,{"data-empty-filtered":``,class:`card empty-card`});t.append(w(`funnel`,`No recordings match this filter`,[e])),f.append(t),m();return}let _=[],v=u(g,a);l.jumps.append(_e(v,p.length));for(let e of v){let t=ve(e,c.get(e.key)??!e.folded,n,r);f.append(t.box),_.push(...t.articles)}m();for(let[e,t]of _)n.preview(e,t.querySelector(`[data-preview]`));pe(e,o)}var xe=document.querySelector(`#root`),F=document.querySelector(`#notice`),Se=g(xe),I=r(),L=I.scenes;I.nav.onOpen?.(e=>location.assign(e)),_(I);var R=new Map;function z(e,t){F.textContent=e,F.className=t===`info`?`notice`:`notice notice-${t}`,F.classList.remove(`hidden`)}function B(e){z(e,`error`)}function Ce(){F.textContent=``,F.className=`notice notice-error hidden`}function V(e,t){console.error(`demoman library: ${e} —`,t),B(`Something went wrong (${e}). Try again.`)}function we(e,t){try{location.assign(e)}catch(e){V(t,e)}}var H=I.bundles,U=new Map,W=typeof IntersectionObserver==`function`?new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;let e=U.get(t.target);e!==void 0&&(U.delete(t.target),W?.unobserve(t.target),e())}},{rootMargin:`200px`}):null,G=!1,Te=(e,t)=>W===null?(G||(G=!0,console.info(`demoman library: no IntersectionObserver here, so every preview paints at once`)),t(),()=>{}):(U.set(e,t),W.observe(e),()=>{U.delete(e),W.unobserve(e)}),K=new Map,Ee={bundle:async e=>(await H.active(e)).bundle,length:async(e,n)=>{let r=K.get(e);if(r===void 0)throw Error(`no document for ${e} in the last listing`);return t(r,n,H.load)},image:async e=>{if(I.folder!==void 0)return I.folder.thumb(e);let t=await H.load(e);if(t instanceof Uint8Array)throw Error(`${e} loaded as motion bytes, not a keyframe`);if(!(t.image instanceof ImageBitmap))throw Error(`${e} decoded to something other than an ImageBitmap`);return t.image},whenVisible:Te},q=null,J=null,Y=d;function De(e){let t=new Set([...e.rows.map(e=>T(`take`,e.sceneId)),...(e.unreadable??[]).map(e=>T(`folder`,e.folder))]);for(let e of R.keys())t.has(e)||R.delete(e)}function X(e){De(e),q?.dispose(),q=C(Ee),be(xe,e,Ne,R,Y),Se.mark()}var Oe=h({paint:e=>ke({keepNotice:e}),onRefreshFailed:e=>V(`refreshing the library`,e)});function Z(){return Oe.render()}async function ke({keepNotice:e=!1}={}){e||Ce();let t=await I.folder.read(),n=t.scenes;K=new Map(n.map(e=>[e.meta.id,e]));let r=p({sizes:t.sizes,unreadable:t.unreadable,unwatched:t.unwatched,emptyHint:I.nav.firstTakeHint(),scenes:n,migrating:!1,migrationFailed:!1,notice:null,needsLook:new Set});J=r,X(r)}var Ae={recording:`a take is recording`,rendering:`a render is running`,sharing:`a share is in progress`,replaying:`a take is being run in Runs`},Q=new Map;function je(e,t,n){let r=Q.get(e);if(r===void 0){we(t,n);return}r.then(e=>{e&&we(t,n)})}function Me(e){return K.get(e)?.meta.capture.mode===`authored`}var Ne={filter:e=>{if(Y=e,J===null){console.error(`demoman library: a filter was picked before the page had rendered`);return}X(J)},preview:(e,t)=>{if(q===null){console.error(`demoman library: a row asked for a preview before the page had a mounter`);return}q.mount(e,t)},edit:e=>{je(e,I.nav.editor(e),`opening the editor`)},rename:(e,t)=>{let n=(async()=>{try{let n=null;try{let r=await L.get(e);if(r===null)n=`the take is no longer stored`;else{let e={...r.scene,meta:{...r.scene.meta,name:t}};await L.put(e,r.revision)}}catch(e){n=e instanceof Error?e.message:String(e)}let r=T(`take`,e);return n===null?R.delete(r):R.set(r,`Couldn't rename: ${n}.`),await Z(),n===null}catch(t){return V(`renaming this demo`,t),R.set(T(`take`,e),`Couldn't rename: ${t instanceof Error?t.message:String(t)}.`),J!==null&&X(J),!1}})();Q.set(e,n),n.finally(()=>{Q.get(e)===n&&Q.delete(e)})},restore:e=>{let t=I.nav.rerun(e,Me(e));if(t.kind===`line`){console.error(`demoman library: Restore was pressed on a platform whose route is a line`);return}je(e,new URL(t.href,I.nav.library()).href,`opening Runs to restore motion`)},rerunLine:(e,t)=>{let n=I.nav.rerun(e,t);return n.kind===`line`?n.text:null},backToRecording:e=>{(async()=>{let t=null,n=await Q.get(e),r=T(`take`,e),i=n===!1?R.get(r):void 0;try{let n=await L.get(e);if(n===null)throw Error(`the take is no longer stored`);let r={...n.scene,meta:{...n.scene.meta,renderMode:`screen`}};await L.put(r,n.revision);let i=(await H.active(e)).bundle;i?.source!==`capture`&&(t=i===null?`Your recording could not be put back: no frames could be read for this take.`:`There is no recording of this take to go back to, so it keeps its re-shot frames. Takes rebuilt before recordings were kept have none.`,console.info(`[demoman] library: back to your recording — not served (${i===null?`no bundle`:`serving ${i.source}`})`))}catch(e){V(`going back to the recording`,e),t=`Couldn't go back to the recording: ${e instanceof Error?e.message:String(e)}.`}let a=[i,t].filter(e=>e!=null).join(` `);a===``?R.delete(r):R.set(r,a);try{await Z()}catch(e){V(`refreshing the library`,e)}})()},remove:(e,t)=>{let r=T(t,e);(async()=>{try{let t;try{t=await n(o)}catch(e){console.error(`demoman library: asking before a delete —`,e),R.set(r,`Not deleted: the confirmation could not open — ${e instanceof Error?e.message:String(e)}.`),await Z();return}if(!t)return;await Q.get(e);let i=await L.remove(e),a=null;if(!i.ok){let e=i.detail??Ae[i.error]??i.error;R.set(r,`Not deleted: ${e}.`)}else if(i.result!==void 0&&!i.result.ok){let e=i.result.steps.find(e=>!e.ok),t=`Partly deleted: ${e?.step??`a step`} could not be removed — ${e?.error??`unknown error`}`;i.result.steps.find(e=>e.step===`scene`)?.ok===!0?(R.delete(r),a=t):R.set(r,t)}else R.delete(r);await Z(),a===null?i.ok&&i.note!==void 0&&z(i.note,`info`):B(a)}catch(e){V(`deleting this demo`,e)}})()}};I.folder?.onChange(()=>Oe.soon());var $=c();Z().then(()=>{$!==null&&z($,`info`)},e=>{$!==null&&console.info(`demoman library: ${$}`),V(`loading your demos`,e)});
@@ -0,0 +1 @@
1
+ import{L as e,at as t,d as n,et as r,f as i,l as a,m as o,n as s,o as c,p as ee,r as l,tt as u,u as d}from"./confirm-dialog-CN_GqXY_.js";import{b as te,h as f,i as p,n as m,r as h,t as g,v as ne}from"./view-DsZQo9AJ.js";import{n as _,r as re,t as ie}from"./topbar-sSUyITjl.js";function ae(e,t,n,r){let i=document.createElement(`div`);i.className=`notice-body`;let a=document.createElement(`p`);if(a.className=`notice-title`,a.textContent=typeof t==`string`?t:t.title,i.append(a),typeof t!=`string`){let e=document.createElement(`details`);e.className=`notice-details`;let n=document.createElement(`summary`);n.append(`Details`,l(`chevronDown`));let r=document.createElement(`div`);r.className=`notice-reason`,r.dataset.noticeReason=``,r.textContent=t.detail,e.append(n,r),i.append(e)}let o=document.createElement(`button`);o.type=`button`,o.className=`notice-dismiss`,o.dataset.noticeDismiss=``,o.setAttribute(`aria-label`,`Dismiss`),o.title=`Dismiss`,o.append(l(`close`)),o.addEventListener(`click`,r),e.className=n===`info`?`notice notice-line`:`notice notice-line notice-${n}`,e.replaceChildren(...n===`info`?[]:[l(`circleAlert`)],i,o)}function v(e,t){let n=e.querySelector(`:scope > .notice-dismiss`);if(n===null||e.classList.contains(`hidden`))return!1;let r=e.querySelector(`:scope > .notice-actions`);return r===null&&(r=document.createElement(`div`),r.className=`notice-actions`,n.before(r)),r.append(t),!0}var y=document.querySelector(`#root`),b=re(y),x=document.querySelector(`#notice`),S=c(),C=S.kits,w={state:`ready`,kits:[],defaultId:null,migrationPending:!1},T=null,E=null,D=null,O=null,k=null,oe=()=>w.state===`ready`?w.kits.find(e=>e.id===T)??null:null,A=()=>{let e=oe();return e?.read.state===`ready`?e.read.kit:r};function j(){w.state===`ready`&&(w.kits.some(e=>e.id===T)||(T=o(w)?.id??w.kits[0]?.id??null))}var M=0;async function N(e){let t=null,n=await C.update(async n=>{let r=await e(n);if(typeof r==`string`)return r;let i=r.kits[0];return i===void 0||r.kits.some(e=>e.id===r.defaultId)?r:(t=i.name,{...r,defaultId:i.id})});return n===null?(M+=1,w=await C.read(),j(),t===null?null:{warn:`Your default kit was missing, so "${t}" is the default now.`}):n}async function P(e){let t=null,n=await e(e=>(t=e,e));return typeof n!=`string`&&t!==null&&(T=t,j()),n}var F=null;function I(e,t){return N(async n=>{if(n.kits.length===0){let e=await t(r);if(typeof e==`string`)return e;let n=d();return T=n,F=n,{kits:[{id:n,name:`Brand kit`,branding:e}],defaultId:n}}let i=e??F,a=n.kits.find(e=>e.id===i);if(a===void 0)return i===null?`this page's kit list was out of date, so nothing was changed — it now shows your kits as they are`:`the kit was deleted in another tab`;let o=ee(a.branding),s=await t(o.state===`ready`?o.kit:r);return typeof s==`string`?s:{...n,kits:n.kits.map(e=>e.id===i?{...e,branding:s}:e)}})}async function se(t){let n=t.logo?.ref??null;if(n===null){E=null,D=null,O=null;return}if(E?.ref!==n){let e=await S.logos.load(n);E=e.ok?{ref:n,source:e.source,error:null}:{ref:n,source:null,error:e.error}}if(D=null,E.source!==null)try{D=await E.source.rasterAt(e(t,m))}catch(e){E={ref:n,source:null,error:z(e)}}if(E.source===null)O={kind:`failed`,reason:E.error??`the page did not try to load it`};else try{O={kind:`ready`,url:await ne(E.source)}}catch(e){O={kind:`failed`,reason:z(e)}}}function L(e,t=`all`){let n=document.querySelector(`[data-preview-kit]`);if(n===null)return;let r=getComputedStyle(document.documentElement),i=r.getPropertyValue(`--card`).trim()||`#ffffff`,a=Number.parseFloat(r.getPropertyValue(`--radius`))||0;p(n,e,D,i,a)||console.info(`demoman settings: the brand kit preview has no 2D context`);for(let n of document.querySelectorAll(`[data-kit-thumb]`)){let r=n.getAttribute(`data-kit-thumb`);if(t===`selected`&&r!==T)continue;let o=w.state===`ready`?w.kits.find(e=>e.id===r):void 0;if(o?.read.state!==`ready`)continue;let s=r===T?e:o.read.kit;p(n,s,null,i,a)||console.info(`demoman settings: a kit tile has no 2D context`)}}S.nav.onOpen?.(e=>X(e,()=>location.assign(e),new URL(e,location.href).searchParams.has(`scene`)?`Open the take`:`Open Recordings`)),ie(S);var R=new Map,z=e=>e instanceof Error?e.message:String(e);function B(e,t){ae(x,e,t,H)}function V(e){B(e,`error`)}function H(){x.replaceChildren(),x.className=`notice notice-error hidden`}function U(e,t){console.error(`demoman settings: ${e} —`,t),V({title:`Couldn't ${e}`,detail:z(t)})}function W(e,t){let n=R.get(e);R.set(e,n===void 0?t:`${n}. ${t}`)}async function G(e,t,n){try{return await n()}catch(n){for(let r of typeof e==`string`?[e]:e)W(r,`Couldn't read ${t}: ${z(n)}`);return null}}var K=_({paint:e=>ce({keepNotice:e}),onRefreshFailed:e=>U(`refresh Settings`,e),hold:de});function q(){return K.render()}async function ce({keepNotice:e=!1}={}){e||H(),R.clear();let t=M,[n,r,i]=await Promise.all([C.read(),G(`pullRequests`,`the Pull requests setting`,()=>S.pullRequests.read()),G(`export`,`the Export quality setting`,()=>S.exportQuality.read())]);i?.unreadable!==void 0&&W(`export`,`Couldn't read the Export quality setting: ${i.unreadable}`),r?.unreadable!==void 0&&W(`pullRequests`,`Couldn't read the Pull requests setting: ${r.unreadable}`),M===t&&(w=n),j();let a=A();await se(a);let o={exportQuality:i===null||i.unreadable!==void 0?null:i.quality,pullRequests:r===null||r.unreadable!==void 0?null:r.value??`ask`,kitsUnwatched:C.unwatched(),brandKits:w,selectedKitId:T,brandKitLogo:a.logo===null?null:E?.source==null?{ok:!1,error:E?.error??`the page did not try to load it`}:{ok:!0},brandKitLogoThumb:a.logo===null?null:O,brandKitPlacement:h(a,D),brandKitNotes:[E?.error?`The logo could not be loaded: ${E.error}`:null,k!==null&&k.ref===a.logo?.ref?k.note:null].filter(e=>e!==null)};g(y,o,le,R),b.mark(),L(a)}var J=new Set;function Y(e,t){let n=(async()=>{let n;try{n=await t()}catch(t){return U(e,t),`failed`}try{await q()}catch(t){return U(`show the result of: ${e}`,t),`failed`}return n===null?`done`:typeof n==`string`?(V(`Couldn't ${e}: ${n}.`),`failed`):(`warn`in n?B(n.warn,`warn`):B(n.info,`info`),`done`)})();J.add(n),n.then(()=>J.delete(n))}function X(e,t,n){J.size>0&&console.info(`demoman settings: asked to open ${e}; waiting for ${J.size} change${J.size===1?``:`s`} here to save first`),(async()=>{let r=!1;for(;;){let e=K.pending();if((await Promise.all([...J])).includes(`failed`)&&(r=!0),await e.then(()=>void 0,()=>void 0),J.size===0&&K.pending()===e)break}if(r){console.info(`demoman settings: stayed on Settings rather than opening ${e}, because a change here did not save`);let r=document.createElement(`button`);r.type=`button`,r.className=`btn btn-quiet`,r.dataset.openAsked=``,r.textContent=n,r.addEventListener(`click`,()=>{try{t()}catch(t){U(`open ${e}`,t)}}),v(x,r)||(V(`A change here didn't save, so this window stayed on Settings.`),v(x,r));return}try{t()}catch(t){U(`open ${e}`,t)}})()}var le={setPullRequests:e=>Y(`save the Pull requests setting`,async()=>{let t=await S.pullRequests.write(e);return t.replaced===void 0?null:{warn:t.replaced}}),setExportQuality:e=>Y(`save the Export quality setting`,async()=>{let t=await S.exportQuality.write(e);return t.replaced===void 0?null:{warn:t.replaced}}),setBrandKit:e=>{let t=T;Y(`save the brand kit`,()=>I(t,async t=>{let n=u.safeParse(f(t,e));return n.success?n.data:n.error.issues.map(e=>e.message).join(`; `)}))},previewBrandKit:e=>{try{L(f(A(),e),`selected`)}catch(e){console.info(`demoman settings: a brand kit preview did not apply`,e)}},uploadKitLogo:e=>{let n=T;Y(`add the logo`,async()=>{let r=te(e);if(!r.ok)return r.reason;let a=new Uint8Array(await e.arrayBuffer());try{await i(a,e.type)}catch(t){return`the logo "${e.name}" could not be read as an image: ${z(t)}`}let{ref:o}=await S.logos.put(e);return k=r.note===null?null:{ref:o,note:r.note},I(n,async e=>{let n=e.logo,r=n?{corner:n.corner,size:n.size,opacity:n.opacity}:t;return f(e,{logo:{ref:o,...r}})})})},selectKit:e=>{T=e,q().catch(e=>U(`select the kit`,e))},newKit:()=>Y(`add a kit`,()=>P(e=>N(async t=>{let i=e(d());return{kits:[...t.kits,{id:i,name:n(`Untitled kit`,t.kits),branding:r}],defaultId:t.defaultId??i}}))),duplicateKit:e=>Y(`duplicate the kit`,()=>P(t=>N(async r=>{let i=r.kits.find(t=>t.id===e);if(i===void 0)return`the kit was deleted in another tab`;let a={id:t(d()),name:n(`${i.name} copy`,r.kits),branding:structuredClone(i.branding)};return{...r,kits:[...r.kits,a]}}))),renameKit:(e,t)=>Y(`rename the kit`,()=>N(async n=>{let r=a(t,n.kits,e);return r.ok?{...n,kits:n.kits.map(t=>t.id===e?{...t,name:r.name}:t)}:r.reason})),setDefaultKit:e=>Y(`make the kit the default`,()=>N(async t=>t.kits.some(t=>t.id===e)?{...t,defaultId:e}:`the kit was deleted in another tab`)),deleteKit:e=>Y(`delete the kit`,async()=>{if(w.state!==`ready`)return`the kits could not be read`;let t=w.kits.find(t=>t.id===e);if(t===void 0)return`the kit was deleted in another tab`;if(w.kits.length===1)return`the last kit cannot be deleted`;let n=w.kits.find(t=>t.id!==e),r=w.defaultId===e&&n!==void 0?` "${n.name}" becomes the default kit.`:``;return await s({glyph:`trash`,title:`Delete "${t.name}"`,body:`"${t.name}" will be deleted.${r} Takes already made keep their look.`,confirmLabel:`Delete`,danger:!0,focus:`cancel`})?N(async t=>{let n=t.kits.filter(t=>t.id!==e);return n.length===0?`the last kit cannot be deleted`:{kits:n,defaultId:t.defaultId===e?n[0]?.id??null:t.defaultId}}):null}),resetKits:()=>Y(`start a fresh kit list`,async()=>{if(!await s({glyph:`trash`,title:`Start a fresh kit list`,body:`Your brand kits could not be read. Starting fresh replaces them with an empty list; takes already made keep their look.`,confirmLabel:`Start fresh`,danger:!0,focus:`cancel`}))return null;let{backup:e}=await C.reset();return M+=1,w=await C.read(),e===null?null:{info:`Started a fresh kit list. The old list is kept at ${e}.`}})},Z=()=>K.soon(),Q=!1,ue=new Set([`button`,`checkbox`,`file`,`radio`,`range`,`reset`,`submit`]);function de(){if(Q)return!0;let e=document.activeElement;return e===null||!y.contains(e)?!1:e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&!ue.has(e.type)}var $=()=>K.resume();y.addEventListener(`pointerdown`,()=>{Q=!0});for(let e of[`pointerup`,`pointercancel`])window.addEventListener(e,()=>{Q=!1,$()});y.addEventListener(`focusout`,()=>setTimeout($,0)),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&Z()}),C.onChange(Z),q().catch(e=>U(`load Settings`,e));
@@ -0,0 +1 @@
1
+ import{A as e,C as t,D as n,E as r,F as i,I as a,O as o,P as s,S as c,T as l,_ as u,a as d,b as f,ct as p,et as m,it as ee,k as h,m as g,nt as _,r as v,tt as y,v as b,w as x,x as S,y as C}from"./confirm-dialog-CN_GqXY_.js";var w=[`share`,`high`,`full`],T={share:`Sharing`,high:`High`,full:`Full`},E=`high`;function te(e){return{padding:e.branding.padding,viewport:e.meta.capture.viewport}}function D(e,t){return e?.viewport??t.viewport}function ne(t,n,r,i){switch(t){case`mp4`:{let t=n?e(n,r):c;return i!==void 0&&i.width<t.width?i:t}case`gif`:return u;case`stills`:return l}}function re(e){return e.width>=t.width?t:{...t,width:e.width,height:e.height,cornerRadius:e.cornerRadius,bitrate:Math.round(t.bitrate*e.width*e.height/(t.width*t.height))}}function ie(e){return e.width>=C.width?C:{...e,bitrate:Math.min(e.bitrate,C.bitrate)}}function ae(e,t,i,a,o={}){let s=e===`mp4`?o.quality??`full`:`full`;if(t!==`9:16`){let n=ne(e,i,t,o.maxTier),r=h(t,s===`share`?re(n):s===`high`?ie(n):n,D(i,a),a.padding);return s===`high`&&r.bitrate>1e7?{...r,bitrate:f}:r}switch(e){case`mp4`:return s===`share`?x:s===`high`?S:n;case`gif`:return b;case`stills`:return r}}var oe=new Set([`image/svg+xml`,`image/png`,`image/webp`,`image/jpeg`]);function O(e){return e.type===``?{ok:!1,reason:`The logo "${e.name}" has no file type — use SVG, PNG, WebP or JPEG`}:oe.has(e.type)?e.size>2097152?{ok:!1,reason:`The logo "${e.name}" is ${(e.size/1024/1024).toFixed(1)} MB — logos are limited to 2 MB`}:{ok:!0,note:e.type===`image/jpeg`?`JPEG has no transparency — the logo shows as a box on the background`:null}:{ok:!1,reason:`The logo "${e.name}" is a ${e.type} file — use SVG, PNG, WebP or JPEG`}}var k=[`off`,`ask`,`attach`],se={off:`Off`,ask:`Ask`,attach:`Attach`};function ce(e,t,n){return e.naturalHeight===null||e.naturalHeight>=t?null:`Upscaled in a ${n} export — an SVG or a larger PNG stays sharp`}var A=new WeakMap;function le(e){let t=A.get(e);return t===void 0&&(t=(async()=>{let t=await e.rasterAt(160),n=Math.max(1,Math.round(160*e.aspect)),r=document.createElement(`canvas`);r.width=n,r.height=160;let i=r.getContext(`2d`);if(i===null)throw Error(`the thumbnail has no 2D context to draw in`);return i.drawImage(t.image,0,0,n,160),r.toDataURL(`image/png`)})(),A.set(e,t),t.catch(()=>{A.get(e)===t&&A.delete(e)})),t}function j(e,t){let n=e.logo;if(t.logo===null)n=null;else if(t.logo!==void 0){if(`ref`in t.logo)n=t.logo;else if(n===null)throw Error(`there is no logo to adjust — upload one first`);else n={...n,...t.logo}}let r=t.background??e.background;if(t.gradient!==void 0){if(r.kind!==`gradient`)throw Error(`the background is not a gradient any more`);let{swap:e,...n}=t.gradient;e&&(r={...r,from:r.to,to:r.from}),r={...r,...n}}return{...e,background:r,logo:n,padding:t.padding??e.padding}}function ue(e,t){if(e.padding!==t.padding)return!1;let n=e.background,r=t.background;return(n.kind===`solid`?r.kind===`solid`&&n.color===r.color:r.kind===`gradient`&&n.from===r.from&&n.to===r.to&&n.angle===r.angle)?e.logo===null||t.logo===null?e.logo===t.logo:e.logo.ref===t.logo.ref&&e.logo.corner===t.logo.corner&&e.logo.size===t.logo.size&&e.logo.opacity===t.logo.opacity:!1}function de(e,t,n=()=>void 0){if(e===null||e.scene!==t)return{branding:t.branding,preview:null};try{return{branding:j(t.branding,e.patch),preview:e}}catch(e){return n(e instanceof Error?e:Error(String(e))),{branding:t.branding,preview:null}}}var M={mp4:`MP4`,gif:`GIF`,stills:`PNG stills`},fe={mp4:`Export MP4`,gif:`Export GIF`,stills:`Export PNG stills`};function pe(e,t){let n=e===`stills`?`one per step`:d(t);return[M[e],n].join(` · `)}function N(e,t){let n=t===`9:16`;switch(e){case`mp4`:return n?`Vertical video`:t===`auto`?`Video`:`Landscape video`;case`gif`:return n?`Vertical GIF`:`GIF`;case`stills`:return n?`Vertical PNG stills`:`PNG stills`}}function me(e){switch(e){case`auto`:return`Auto, set under the preview — the video takes the recording's shape`;case`9:16`:return`9:16, set under the preview — the camera follows each step`;case`16:9`:return`16:9, set under the preview`}}function he(e,t){return`Recording ${e.width} × ${e.height} · Video ${t.width} × ${t.height}`}function ge(e){if(!e.hasFrames)return`No frames to export`;if(e.durationMs<=0)return`Nothing left to export`;let t=`${e.target.width} × ${e.target.height}`;return e.fileType===`stills`?`${M.stills} · ${t}`:`${d(e.durationMs)} · ${t}`}var P=(e,t,n)=>{let r=document.createElement(e);return t&&(r.className=t),n!==void 0&&(r.textContent=n),r},F=e=>{let t=Number(e.min===``?0:e.min),n=Number(e.max===``?100:e.max)-t,r=n>0?(Number(e.value)-t)/n:0,i=Math.min(1,Math.max(0,r));e.style.setProperty(`--fill`,`${(i*100).toFixed(2)}%`)},I={"top-left":`Top left`,"top-right":`Top right`,"bottom-left":`Bottom left`,"bottom-right":`Bottom right`};function _e(e){let t=P(`span`,`logo-thumb`),n=e??{kind:`failed`,reason:`this page did not load the logo`};if(t.setAttribute(`data-logo-thumb`,n.kind),n.kind===`ready`){let e=P(`img`,`logo-thumb-img`);e.src=n.url,e.alt=`Logo`,t.append(e)}else n.kind===`loading`?(t.setAttribute(`aria-busy`,`true`),t.title=`Loading the logo`):(t.append(v(`circleAlert`)),t.title=`The logo could not be shown: ${n.reason}`,t.setAttribute(`aria-label`,t.title),t.setAttribute(`role`,`img`));return t}function ve(e,t){return e===null||!e.capped?null:e.effectiveSize===0?`No room for the logo in ${t} — the recording fills the frame`:`Shown at ${Math.round(e.effectiveSize*100)}% in ${t} to stay clear of your recording`}var L=null,R=new WeakMap,ye=e=>{let t=R.get(e);return t===void 0&&(t=new Map,R.set(e,t)),t};function z(e,t,n,r,i,a=null){let o=P(`div`,`control-row colour-field`);o.setAttribute(`data-colour-field`,``);let s=P(`input`);s.type=`color`,s.value=t,s.setAttribute(`aria-label`,`${e} swatch`);let c=P(`input`,`colour-text`);c.type=`text`,c.value=t,c.spellcheck=!1,c.setAttribute(`aria-label`,e),c.setAttribute(`data-colour-text`,``);let l=P(`p`,`colour-error`);l.setAttribute(`data-colour-error`,``),l.setAttribute(`role`,`alert`);let u=P(`p`,`muted`);u.setAttribute(`data-colour-note`,``),L!==null&&L.hex===t&&(u.textContent=L.note);let d=i.get(e);d!==void 0&&d.base!==t?i.delete(e):d!==void 0&&(c.value=d.text,l.textContent=d.error,d.error!==``&&(u.textContent=``,c.setAttribute(`aria-invalid`,`true`))),c.addEventListener(`input`,()=>{let n=i.get(e);i.set(e,{base:t,text:c.value,error:n?.error??``})}),s.addEventListener(`input`,()=>{i.delete(e),c.value=s.value,r.onPreview(n(s.value))}),s.addEventListener(`change`,()=>r.onCommit(n(s.value))),c.addEventListener(`change`,()=>{let a=p(c.value);if(!a.ok){l.textContent=a.reason,u.textContent=``,c.setAttribute(`aria-invalid`,`true`),i.set(e,{base:t,text:c.value,error:a.reason});return}i.delete(e),l.textContent=``,u.textContent=a.note??``,L=a.note===null?null:{hex:a.hex,note:a.note},c.removeAttribute(`aria-invalid`),c.value=a.hex,s.value=a.hex,r.onCommit(n(a.hex))});let f=P(`div`,`colour-row`);return f.append(s,c),o.append(P(`span`,`control-label`,e)),a!==null&&(a.classList.add(`control-aside`),o.append(a)),o.append(f,l,u),o}function B(e,t,n,r,i,a,o){let s=P(`div`,`slider-row`),c=P(`input`);c.type=`range`,c.min=String(r.min),c.max=String(r.max),c.step=String(r.step),c.value=String(n),c.setAttribute(e,``),c.setAttribute(`aria-label`,t);let l=P(`span`,`slider-value`,i(n));return F(c),c.addEventListener(`input`,()=>{F(c),l.textContent=i(Number(c.value)),o.onPreview(a(Number(c.value)))}),c.addEventListener(`change`,()=>o.onCommit(a(Number(c.value)))),s.append(P(`span`,`control-label slider-label`,t),l,c),s}function V(e,t,n){let{branding:r}=t,i=r.background,a=P(`div`,`branding-controls`),o=ye(e),s=(e,n)=>{let r=P(`section`,`branding-group`);return r.setAttribute(`data-group`,e),t.groupTitles&&r.append(P(`h3`,`branding-group-title`,n)),r},c=s(`background`,`Background`),l=s(`logo`,`Logo`),u=s(`frame`,`Frame`);t.kit!==void 0&&a.append(be(e,t.kit));let d=P(`div`,`segmented`);d.setAttribute(`role`,`radiogroup`),d.setAttribute(`aria-label`,`Background style`);for(let e of[`solid`,`gradient`]){let t=P(`button`,`segment`,e===`solid`?`Solid`:`Gradient`);t.type=`button`,t.setAttribute(`role`,`radio`),t.setAttribute(`data-bg-kind`,e),t.setAttribute(`aria-checked`,String(i.kind===e)),t.addEventListener(`click`,()=>{if(i.kind===e)return;let t=e===`gradient`&&i.kind===`solid`?{kind:`gradient`,from:i.color,to:`#ffffff`,angle:135}:{kind:`solid`,color:i.kind===`gradient`?i.from:i.color};n.onCommit({background:t})}),d.append(t)}let f=P(`div`,`control-row`);f.append(P(`span`,`control-label`,`Style`),d),c.append(f);let p=null;if(i.kind===`solid`)c.append(z(`Colour`,i.color,e=>({background:{kind:`solid`,color:e}}),n,o));else{let e=e=>({gradient:e}),r=P(`button`,`btn btn-link`,`⇅ Swap`);r.type=`button`,r.setAttribute(`data-swap`,``),r.setAttribute(`aria-label`,`Swap From and To`),r.title=`Swap From and To`,r.addEventListener(`click`,()=>n.onCommit(e({swap:!0}))),c.append(z(`From`,i.from,t=>e({from:t}),n,o,r),z(`To`,i.to,t=>e({to:t}),n,o)),p=B(`data-angle`,`Angle`,i.angle,{min:0,max:359,step:1},e=>`${Math.round(e)}°`,t=>e({angle:Math.round(t)}),n),t.groupTitles||c.append(p)}u.append(B(`data-padding`,`Padding`,r.padding,{min:0,max:.2,step:.01},e=>`${Math.round(e*100)}%`,e=>({padding:Math.round(e*100)/100}),n)),p!==null&&t.groupTitles&&u.append(p);let m=P(`div`,`logo-controls`),h=P(`input`);h.type=`file`,h.accept=`image/svg+xml,image/png,image/webp,image/jpeg`,h.setAttribute(`aria-label`,r.logo?`Replace logo`:`Upload logo`),h.addEventListener(`change`,()=>{let e=h.files?.[0];e&&n.onLogoFile(e)});let g=P(`label`,`btn btn-quiet`,r.logo?`Replace`:`Upload logo`);g.prepend(v(`upload`)),g.append(h);let _=P(`div`,`control-row`);if(t.groupTitles||_.append(P(`span`,`control-label`,`Logo`)),m.append(_),r.logo===null){let e=P(`div`,`control-actions`);e.append(g),_.append(e)}else{let e=r.logo,i=P(`button`,`btn btn-quiet`,`Remove`);i.type=`button`,i.setAttribute(`data-logo-remove`,``),i.prepend(v(`trash`)),i.addEventListener(`click`,()=>n.onCommit({logo:null}));let a=P(`div`,`logo-stack`);a.append(g,i);let o=P(`div`,`logo-row`);o.append(_e(t.logoThumb),a),_.append(o);let s=P(`div`,`corner-frame`);s.setAttribute(`role`,`radiogroup`),s.setAttribute(`aria-label`,`Logo corner`),s.append(P(`div`,`corner-frame-rec`));for(let t of ee){let r=P(`button`,`corner`);r.type=`button`,r.setAttribute(`role`,`radio`),r.setAttribute(`data-logo-corner`,t),r.setAttribute(`aria-checked`,String(e.corner===t)),r.setAttribute(`aria-label`,I[t]),r.title=I[t],r.addEventListener(`click`,()=>n.onCommit({logo:{corner:t}})),s.append(r)}let c=P(`div`,`control-row`);c.append(P(`span`,`control-label`,`Corner`),s),m.append(c,B(`data-logo-size`,`Size`,e.size,{min:.02,max:.2,step:.01},e=>`${Math.round(e*100)}%`,e=>({logo:{size:e}}),n),B(`data-logo-opacity`,`Opacity`,e.opacity,{min:.2,max:1,step:.05},e=>`${Math.round(e*100)}%`,e=>({logo:{opacity:e}}),n));let l=[ve(t.logoPlacement,t.formatTitle),...t.logoNotes].filter(e=>e!==null);if(l.length>0){let e=P(`div`,`muted`);e.setAttribute(`data-logo-notes`,``);for(let t of l)e.append(P(`p`,void 0,t));m.append(e)}}l.append(m),a.append(c,u,l);let y=document.activeElement,b=y instanceof HTMLInputElement&&y.hasAttribute(`data-colour-text`)&&e.contains(y)?{label:y.getAttribute(`aria-label`),start:y.selectionStart,end:y.selectionEnd}:null,x=e.querySelector(`[data-kit-new-name]`),S=x!==null&&document.activeElement===x?{start:x.selectionStart,end:x.selectionEnd}:null;e.replaceChildren(a);let C=a.querySelector(`[data-kit-new-name]`);if(C!==null&&x===null?C.focus():C!==null&&S!==null&&(C.focus(),S.start!==null&&S.end!==null&&C.setSelectionRange(S.start,S.end)),b!==null){let e=Array.from(a.querySelectorAll(`[data-colour-text]`)).find(e=>e.getAttribute(`aria-label`)===b.label);e!==void 0&&(e.focus(),b.start!==null&&b.end!==null&&e.setSelectionRange(b.start,b.end))}}var H=new WeakMap,U=new WeakSet;function W(e){let t=P(`span`,`kit-swatch`);if(e?.read.state===`ready`){let n=e.read.kit.background;t.style.background=n.kind===`solid`?n.color:`linear-gradient(${n.angle}deg, ${n.from}, ${n.to})`}else e!==null&&t.append(v(`circleAlert`));return t}function be(e,t){let{read:n,standing:r,naming:i}=t,a=P(`div`,`control-row kit-actions`);if(a.setAttribute(`data-kit-row`,``),a.append(P(`span`,`control-label`,`Brand kit`)),n.state===`invalid`){let e=P(`p`,`colour-error`,`Your brand kits could not be read: ${n.reason}`);return e.setAttribute(`data-kit-error`,``),a.append(e),a}if(i!==null){let e=P(`div`,`kit-naming`),n=P(`input`,`kit-new-name`);n.type=`text`,n.maxLength=40,n.value=i.text,n.placeholder=`Kit name`,n.setAttribute(`aria-label`,`New kit name`),n.setAttribute(`data-kit-new-name`,``),n.addEventListener(`input`,()=>t.onNameInput(n.value)),n.addEventListener(`keydown`,e=>{e.key===`Enter`?t.onConfirmNew(n.value):e.key===`Escape`&&t.onCancelNew()});let r=P(`button`,`btn btn-primary`,`Save`);r.type=`button`,r.setAttribute(`data-kit-new-save`,``),r.addEventListener(`click`,()=>t.onConfirmNew(n.value));let o=P(`button`,`btn btn-quiet`,`Cancel`);if(o.type=`button`,o.setAttribute(`data-kit-new-cancel`,``),o.addEventListener(`click`,()=>t.onCancelNew()),e.append(n,r,o),a.append(e),i.error!==null){let e=P(`p`,`colour-error`,i.error);e.setAttribute(`data-kit-new-error`,``),a.append(e)}return a}let o=P(`div`,`kit-picker-wrap`),s=P(`button`,`kit-picker`);s.type=`button`,s.setAttribute(`data-kit-picker`,``),s.setAttribute(`aria-haspopup`,`menu`);let c=r===null?n.kits.length===0?`No brand kit`:`Custom look`:r.kit.name;if(s.append(W(r?.kit??null),P(`span`,r===null?`kit-picker-name kit-picker-none`:`kit-picker-name`,c)),r?.edited){let e=P(`span`,`kit-edited`,`Edited`);e.setAttribute(`data-kit-edited`,``),s.append(e)}s.append(v(`chevronDown`));let l=P(`div`,`kit-menu`);l.setAttribute(`role`,`menu`),l.setAttribute(`data-kit-menu`,``);let u=t=>{H.set(e,t),l.hidden=!t,s.setAttribute(`aria-expanded`,String(t))},d=(e,t,n)=>{let r=P(`button`,`kit-menu-item ${e}`.trim());return r.type=`button`,n!==null&&r.append(n),r.append(P(`span`,`kit-menu-label`,t)),r};for(let e of n.kits){let i=d(``,e.name,W(e));i.setAttribute(`role`,`menuitemradio`),i.setAttribute(`data-kit-option`,e.id);let a=e.id===r?.kit.id;i.setAttribute(`aria-checked`,String(a));let o=P(`span`,`kit-menu-meta`);if(e.id===n.defaultId){let e=v(`star`);e.setAttribute(`aria-label`,`Default`),o.append(e)}a&&o.append(v(`check`)),i.append(o),e.read.state===`invalid`&&(i.disabled=!0,i.title=e.read.reason),i.addEventListener(`click`,()=>{u(!1),t.onApply(e.id)}),l.append(i)}if(n.kits.length>0&&l.append(P(`div`,`kit-menu-sep`)),r!==null){let e=d(``,`Update "${r.kit.name}"`,v(`refresh`));e.setAttribute(`role`,`menuitem`),e.setAttribute(`data-kit-update`,``),r.edited||(e.disabled=!0),e.addEventListener(`click`,()=>{u(!1),t.onUpdate()}),l.append(e)}let f=d(``,`Save as new kit…`,v(`plus`));return f.setAttribute(`role`,`menuitem`),f.setAttribute(`data-kit-new`,``),f.addEventListener(`click`,()=>{u(!1),t.onStartNew()}),l.append(f),s.addEventListener(`click`,()=>u(l.hidden)),l.addEventListener(`keydown`,e=>{e.key===`Escape`&&(u(!1),s.focus())}),u(H.get(e)===!0),U.has(e)||(U.add(e),document.addEventListener(`pointerdown`,t=>{if(H.get(e)!==!0||e.querySelector(`[data-kit-row]`)?.contains(t.target))return;H.set(e,!1);let n=e.querySelector(`[data-kit-menu]`);n!==null&&(n.hidden=!0),e.querySelector(`[data-kit-picker]`)?.setAttribute(`aria-expanded`,`false`)})),o.append(s,l),a.append(o),a}var xe={...c,width:480,height:270,cornerRadius:c.cornerRadius*480/c.width},G={width:1280,height:800};function K(e){return o(xe,G,e)}var q=y.shape.padding.maxValue;if(q===null)throw Error(`BrandingSchema's padding has no ceiling to size the preview by`);var J=K(q);function Se(e,t){return s(e,K(e.padding),G,t).logoPlacement}function Ce(e,t,n,r,o=0){let c=e.getContext(`2d`);if(c===null)return!1;let l=J;e.width!==l.width&&(e.width=l.width),e.height!==l.height&&(e.height=l.height);let u=K(t.padding);c.clearRect(0,0,l.width,l.height),c.save(),c.beginPath(),c.roundRect(0,0,u.width,u.height,o),c.clip();let d=c,f=s(t,u,G,n);i(d,u,f);let p=f.frameRect;return c.save(),c.fillStyle=r,c.beginPath(),c.roundRect(p.x,p.y,p.width,p.height,f.cornerRadius),c.fill(),c.restore(),a(d,u,f),c.restore(),!0}function Y(e,t={},n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))r.setAttribute(e,n);return n!==void 0&&(r.textContent=n),r}var X=[{section:`brandKit`,id:`brand-kit`,label:`Brand kit`,glyph:`palette`},{section:`export`,id:`export`,label:`Export`,glyph:`download`},{section:`pullRequests`,id:`pull-requests`,label:`Pull requests`,glyph:`upload`}];function Z(e,t){let n=Y(`section`,{"data-section":e,id:X.find(t=>t.section===e)?.id??e}),r=Y(`div`,{class:`section-head`});r.append(Y(`h2`,{},t));let i=Y(`div`,{class:`card section-body`});return n.append(r,i),{box:n,body:i}}function we(){let e=Y(`nav`,{class:`section-nav`,"aria-label":`Settings sections`}),t=Y(`ul`);for(let e of X){let n=Y(`a`,{href:`#${e.id}`,"data-nav":e.id});n.append(v(e.glyph),Y(`span`,{},e.label));let r=Y(`li`);r.append(n),t.append(r)}return e.append(t),e}function Q(e,t){return Y(`button`,{type:`button`,class:`btn btn-quiet`,...t},e)}function $(e){return Y(`p`,{class:`notice notice-error`,"data-notice":``},e)}function Te(e,t,n,r){let i=Y(`div`,{class:`content`});{let e=Z(`brandKit`,`Brand kit`),a=r.get(`brandKit`);a!==void 0&&e.body.append($(a)),t.kitsUnwatched!==null&&e.body.append(Y(`p`,{class:`notice notice-warn`,"data-notice":``,"data-unwatched":``},`Kits changed outside this window will not show until you reload — ${t.kitsUnwatched}.`)),Ee(e.body,t,n),i.append(e.box)}{let e=Z(`export`,`Export`),a=r.get(`export`);a!==void 0&&e.body.append($(a));let o=t.exportQuality,s=Y(`div`,{class:`switch-row export-quality`}),c=Y(`div`,{class:`segmented`,role:`radiogroup`,"aria-label":`Export quality`});for(let e of w){let t=Y(`button`,{type:`button`,class:`segment`,role:`radio`,"data-export-quality":e,"aria-checked":String(e===o)},T[e]);t.addEventListener(`click`,()=>{e!==o&&n.setExportQuality(e)}),c.append(t)}s.append(c),e.body.append(s),i.append(e.box)}{let e=Z(`pullRequests`,`Pull requests`),a=r.get(`pullRequests`);a!==void 0&&e.body.append($(a));let o=t.pullRequests,s=Y(`div`,{class:`switch-row pull-requests`}),c=Y(`div`,{class:`segmented`,role:`radiogroup`,"aria-label":`Pull requests`});for(let e of k){let t=Y(`button`,{type:`button`,class:`segment`,role:`radio`,"data-pull-requests":e,"aria-checked":String(e===o)},se[e]);t.addEventListener(`click`,()=>{e!==o&&n.setPullRequests(e)}),c.append(t)}s.append(c),e.body.append(s),i.append(e.box)}let a=Y(`div`,{class:`settings-side`});a.append(Y(`h1`,{},`Settings`),we());let o=Y(`div`,{class:`settings`});o.append(a,i),e.replaceChildren(o)}function Ee(e,t,n){let r=t.brandKits;if(r.state===`invalid`){if(e.append($(`Your brand kits could not be read: ${r.reason}`)),r.storageRefused){e.append(Y(`p`,{class:`hint`},`Nothing was changed. Reload this page to try again.`));return}let t=Q(`Start a fresh kit list`,{"data-kit-reset-list":``});t.addEventListener(`click`,()=>n.resetKits()),e.append(t);return}let i=r.kits.find(e=>e.id===t.selectedKitId)??null;e.append(De(r,i,n)),i!==null&&e.append(Oe(i,r,n)),i?.read.state===`invalid`&&e.append($(`"${i.name}" could not be read: ${i.read.reason}`));let a=i?.read.state===`ready`?i.read.kit:m,o=Y(`div`,{class:`kit-hero`});o.append(Y(`canvas`,{"data-preview-kit":``,width:String(J.width),height:String(J.height),class:`kit-preview`}));let s=Y(`div`,{class:`kit-controls`});V(s,{branding:a,logoThumb:t.brandKitLogoThumb,logoPlacement:t.brandKitPlacement,formatTitle:N(`mp4`,_.aspect),logoNotes:t.brandKitNotes,groupTitles:!0},{onCommit:e=>n.setBrandKit(e),onPreview:e=>n.previewBrandKit(e),onLogoFile:e=>n.uploadKitLogo(e)}),e.append(o,s)}function De(e,t,n){let r=Y(`div`,{class:`kit-strip`,role:`list`}),i=g(e);for(let a of e.kits){let e=Y(`div`,{class:`kit-tile`,role:`listitem`,"data-kit-tile":a.id}),o=Y(`button`,{type:`button`,class:`kit-pick`,"data-kit-select":a.id,"aria-pressed":String(a.id===t?.id)});if(a.read.state===`ready`)o.append(Y(`canvas`,{class:`kit-thumb`,"data-kit-thumb":a.id,width:String(J.width),height:String(J.height)}));else{let e=Y(`span`,{class:`kit-thumb kit-thumb-broken`});e.append(v(`circleAlert`)),o.append(e),o.title=a.read.reason}o.append(Y(`span`,{class:`kit-tile-name`},a.name)),o.addEventListener(`click`,()=>n.selectKit(a.id));let s=a.id===i?.id,c=Y(`button`,{type:`button`,class:`kit-star`,"data-kit-star":a.id,"aria-pressed":String(s),"aria-label":s?`"${a.name}" is the default kit`:`Make "${a.name}" the default kit`});c.append(v(`star`)),c.addEventListener(`click`,()=>{s||n.setDefaultKit(a.id)}),e.append(o,c),r.append(e)}let a=Y(`button`,{type:`button`,class:`kit-tile kit-new`,"data-kit-new":``});return a.append(v(`plus`),Y(`span`,{},`New kit`)),a.addEventListener(`click`,()=>n.newKit()),r.append(a),r}function Oe(e,t,n){let r=Y(`div`,{class:`kit-head`}),i=Y(`input`,{type:`text`,class:`kit-name`,"data-kit-name":``,maxlength:`40`,"aria-label":`Kit name`});i.value=e.name,i.addEventListener(`change`,()=>n.renameKit(e.id,i.value)),i.addEventListener(`keydown`,t=>{t.key===`Escape`&&(i.value=e.name,i.blur())});let a=Q(`Duplicate`,{"data-kit-duplicate":``});a.prepend(v(`copy`)),a.addEventListener(`click`,()=>n.duplicateKit(e.id));let o=Q(`Delete`,{"data-kit-delete":``});return o.prepend(v(`trash`)),t.kits.length===1&&(o.disabled=!0,o.title=`The last kit cannot be deleted`),o.addEventListener(`click`,()=>n.deleteKit(e.id)),r.append(i,a,o),r}export{w as C,ae as E,T as S,D as T,ue as _,V as a,O as b,fe as c,N as d,pe as f,de as g,j as h,Ce as i,M as l,ge as m,J as n,P as o,he as p,Se as r,F as s,Te as t,me as u,le as v,te as w,E as x,ce as y};
@@ -7,9 +7,9 @@
7
7
  shared with the popup, the Recordings page and Settings. Only the
8
8
  editor's own rules are inline below. -->
9
9
  <link rel="stylesheet" href="/assets/editor-inline-7e387eed.css">
10
- <script type="module" crossorigin src="/assets/editor-APtBBZEt.js"></script>
11
- <link rel="modulepreload" crossorigin href="/assets/confirm-dialog-DkCVzKzd.js">
12
- <link rel="modulepreload" crossorigin href="/assets/controls-BoAnJbcP.js">
10
+ <script type="module" crossorigin src="/assets/editor-Cy1V14-4.js"></script>
11
+ <link rel="modulepreload" crossorigin href="/assets/confirm-dialog-CN_GqXY_.js">
12
+ <link rel="modulepreload" crossorigin href="/assets/view-DsZQo9AJ.js">
13
13
  <link rel="modulepreload" crossorigin href="/assets/state-COWbBf84.js">
14
14
  <link rel="stylesheet" crossorigin href="/assets/confirm-dialog-Dd_hs1Bv.css">
15
15
  </head>
Binary file
@@ -1,7 +1,4 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="99.69 64.44 411.11 411.11" width="411" height="411">
2
- <title>Demoman head</title>
3
- <circle cx="305.25" cy="270.00" r="205.56" fill="#CDEB45"/>
4
- <g transform="translate(-358.71,26.61) scale(2.2)">
5
- <path fill="#000000" d="M 287.20,151.99 L 345.34,125.16 A 16.00,16.00 0 0 0 345.34,96.10 L 287.20,69.27 A 16.00,16.00 0 0 0 264.50,83.80 L 264.50,137.46 A 16.00,16.00 0 0 0 287.20,151.99 Z"/>
6
- </g>
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="157.0 119.3 299.2 299.2" width="32" height="32">
2
+ <title>Demoman</title>
3
+ <g fill="currentColor"><g transform="translate(5.54,56.31) scale(0.96895)"><path d="M 287.20,151.99 L 345.34,125.16 A 16,16 0 0 0 345.34,96.10 L 287.20,69.27 A 16,16 0 0 0 264.50,83.80 L 264.50,137.46 A 16,16 0 0 0 287.20,151.99 Z"/></g><rect x="264" y="224" width="83" height="83" rx="16.5"/><rect x="264" y="326" width="33" height="92.5" rx="16.5"/><rect x="314" y="326" width="33" height="92.5" rx="16.5"/></g>
7
4
  </svg>