1const Me="cubic-bezier(0.16, 1, 0.3, 1)",Oe="cubic-bezier(0.65, 0, 0.35, 1)",Z="cubic-bezier(0.55, 0, 0.75, 0.3)",r={expand:560,fadeOut:240,fadeIn:540,stagger:60,shift:440,glide:1100,read:1700},p={settle:1600,look:2e3,read:2200,beat:1e3},he=window.matchMedia("(prefers-reduced-motion: reduce)"),C=()=>he.matches,$e=o=>o<.5?4*o*o*o:1-Math.pow(-2*o+2,3)/2;class F extends Error{}function Be(o,A){const l=(e,t=o)=>t.querySelector(e),d=(e,t=o)=>[...t.querySelectorAll(e)],u=l(".scene-body"),j=l("#sample-references .ka-workspace-body"),ye=l("#sample-outline .ka-workspace-body"),ge=l(".ka-workspace-panes"),M=d('input[name="sample-scene"]'),ve=d('input[name="sample-scene-view"]'),H=d('input[name="sample-workspace-region"]'),z={outline:l(".ka-workspace-outline"),main:l(".ka-workspace-main"),inspector:l(".ka-workspace-inspector")},ee=["outline","main","inspector"],N=new Set;function v(e,t,n){const a=e.animate(t,{duration:C()?0:n.duration,delay:C()?0:n.delay??0,easing:n.easing??Me,fill:n.fill??"none"});N.add(a);const s=()=>N.delete(a);return a.finished.then(s,s),a}const E=e=>Promise.all(e.map(t=>t.finished.catch(()=>{})));function U(){const e=[...N];for(const t of e)try{t.updatePlaybackRate(6)}catch{}return E(e)}let W=0,P=null;function te(){cancelAnimationFrame(W),P?.(),P=null}function O(e,t,n=r.glide){te();const a=e.scrollTop,s=Math.max(0,Math.min(t,e.scrollHeight-e.clientHeight));return C()||Math.abs(s-a)<1?(e.scrollTop=s,Promise.resolve()):new Promise(i=>{P=i;const c=performance.now(),L=q=>{const I=Math.min(1,(q-c)/n);e.scrollTop=a+(s-a)*$e(I),I<1?W=requestAnimationFrame(L):(P=null,i())};W=requestAnimationFrame(L)})}const ne=(e,t)=>e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop,be=e=>e.closest(".ka-workspace-body"),_=new WeakMap;async function $(e,t,{reveal:n=!0}={}){const a=_.get(e);if(a&&await a,e.open===t)return;if(!e.getClientRects().length){e.open=t;return}const s=(async()=>{const i=[...e.children].filter(h=>h.tagName!=="SUMMARY"),c=l(".ka-beat-preview",e.querySelector(":scope > summary"));t&&c&&await E([v(c,[{opacity:1},{opacity:0}],{duration:160,easing:Z,fill:"forwards"})]);const L=e.getBoundingClientRect().height;let q;t?(e.open=!0,q=e.getBoundingClientRect().height):(e.open=!1,q=e.getBoundingClientRect().height,e.open=!0,e.classList.add("is-closing")),e.style.overflow="clip";const I=[v(e,[{height:`${L}px`},{height:`${q}px`}],{duration:r.expand,easing:Oe})];if(t){for(const h of i)I.push(v(h,[{opacity:0,transform:"translateY(-12px)"},{opacity:1,transform:"none"}],{duration:r.expand,fill:"backwards"}));c?.getAnimations().forEach(h=>h.cancel()),n&&ke(e,q)}else for(const h of i)I.push(v(h,[{opacity:1},{opacity:0}],{duration:r.expand*.55,easing:Z,fill:"forwards"}));if(await E(I.slice(0,1)),!t){e.open=!1,e.classList.remove("is-closing");for(const h of i)h.getAnimations().forEach(Ae=>Ae.cancel());c&&v(c,[{opacity:0,transform:"translateY(-8px)"},{opacity:1,transform:"none"}],{duration:r.fadeIn})}e.style.overflow=""})();_.set(e,s);try{await s}finally{_.delete(e)}}function ke(e,t){const n=be(e);if(!n)return;const a=ne(e,n),s=n.clientHeight,i=16,c=n.scrollTop;if(a-i>=c&&a+t<=c+s)return;const L=t+i*2>s?a-i:a+t+i-s;O(n,L,r.expand+200)}const S=()=>M.find(e=>e.checked).value,Y=e=>[d(`.scene-body [data-scene="${e}"] > .ka-scene-column > *`),d(`#sample-references [data-scene="${e}"] .reference-list > *`),d(`.ka-statusbar [data-scene="${e}"] > *`)],Ee=e=>Y(e).flat(),ae=()=>H.find(e=>e.checked)?.value??"main",se=()=>getComputedStyle(ge).display!=="none",ie=({x:e=0,y:t=0})=>`translate(${e}px, ${t}px)`;function B(e,t={y:20}){return e.map((n,a)=>v(n,[{opacity:0,transform:ie(t)},{opacity:1,transform:"none"}],{duration:r.fadeIn,delay:a*r.stagger,fill:"backwards"}))}function oe(e,t={y:-10}){return e.map(n=>v(n,[{opacity:1,transform:"none"},{opacity:0,transform:ie(t)}],{duration:r.fadeOut,easing:Z,fill:"forwards"}))}async function ce(e,t,n,a={}){const s=oe(t,a.to);await E(s),e.checked=!0,s.forEach(i=>i.cancel()),await E(n().flatMap(i=>B(i,a.from)))}async function G(e){const t=M.find(s=>s.value===e);if(!t||t.checked)return;const n=t.closest("details");n&&!n.open&&await $(n,!0);const a=S();await ce(t,Ee(a),()=>(u.scrollTop=0,j.scrollTop=0,Y(e)))}async function V(e){const t=ve.find(i=>i.value===e);if(!t||t.checked)return;const n=l(`.scene-body [data-scene="${S()}"]`),[a,s]=e==="page"?[".scene-beats",".scene-page"]:[".scene-page",".scene-beats"];await O(u,0,r.shift),await ce(t,[l(a,n)],()=>[[l(s,n)]],{from:{y:28},to:{y:-14}})}async function w(e){if(!se())return;const t=H.find(c=>c.value===e);if(!t||t.checked)return;const n=z[ae()],a=z[e],s=Math.sign(ee.indexOf(e)-ee.indexOf(ae()))||1;n.style.display="flex",n.style.pointerEvents="none",t.checked=!0;const i=oe([n],{x:s*-24});await E([...i,...B([a],{x:s*36}
1)]),i.forEach(c=>c.cancel()),n.style.display="",n.style.pointerEvents=""}let X=!1;async function Se(e){e.name==="sample-scene"?(await G(e.value),X=!0,e.dispatchEvent(new Event("change",{bubbles:!0})),X=!1,await w("main")):e.name==="sample-scene-view"?await V(e.value):e.name==="sample-workspace-region"&&await w(e.value)}o.addEventListener("click",e=>{const t=e.target,n=t.closest("summary");if(n&&o.contains(n)){const s=n.parentElement;e.preventDefault(),requestAnimationFrame(async()=>{await U(),$(s,!s.open)});return}const a=t instanceof HTMLInputElement&&t.type==="radio"?t:t.closest("label")?.querySelector('input[type="radio"]');a&&o.contains(a)&&!a.checked&&(e.preventDefault(),requestAnimationFrame(async()=>{await U(),Se(a)}))}),o.addEventListener("change",e=>{if(X)return;const t=e.target;t.name==="sample-scene"?(u.scrollTop=0,Y(t.value).forEach(n=>B(n)),se()&&(H.find(n=>n.value==="main").checked=!0)):t.name==="sample-scene-view"?B([l(`.scene-body [data-scene="${S()}"] ${t.value==="page"?".scene-page":".scene-beats"}`)],{y:28}):t.name==="sample-workspace-region"&&B([z[t.value]],{x:24})});const f=(e,t)=>new Promise((n,a)=>{if(t.aborted)return a(new F);const s=setTimeout(n,e);t.addEventListener("abort",()=>{clearTimeout(s),a(new F)},{once:!0})}),m=e=>{if(e.aborted)throw new F},xe=M.map(e=>e.value),D=e=>d(`.scene-body [data-scene="${e}"] .ka-beat`),re=e=>D(e).filter(t=>t.querySelector(".ka-beat-preview, .ka-manuscript")),le=e=>d(`#sample-references [data-scene="${e}"] .ka-reference`),b=S(),Te=[b,...xe.filter(e=>e!==b&&re(e).length)].slice(0,3);async function x(e,t){await Promise.all(e.filter(n=>n!==t&&n.open).map(n=>$(n,!1)))}async function Le(e,t){m(t),await w("main"),await x(D(S()),e),m(t),await $(e,!0)}async function ue(e,t,n){const a=le(e),s=a[Math.min(t,a.length-1)];s&&(m(n),await w("inspector"),await x(a,s),m(n),await $(s,!0))}async function qe(e,t){const a=e.querySelector("blockquote")??e.querySelector(".ka-manuscript-prose p:last-child");a&&(m(t),await O(u,ne(a,u)-u.clientHeight*.25,r.read))}const y=[e=>f(p.settle,e)];Te.forEach((e,t)=>{t>0&&y.push(async a=>{m(a),await w("outline");const s=M.find(i=>i.value===e).closest("details");await G(e),await x(d(".ka-tree > .ka-tree-list > li > details"),s),await f(p.beat,a),await w("main"),await f(p.look,a)}),re(e).slice(0,t===0?2:1).forEach((a,s)=>{y.push(async i=>{await Le(a,i),await f(p.look,i)}),t===0&&s===0&&y.push(async i=>{await qe(a,i),await f(p.read,i)})}),t===0&&y.push(async a=>{m(a),await w("main"),await V("page"),await f(p.beat,a),await O(u,u.scrollTop+u.clientHeight*.6,r.read),await f(p.read,a),await V("beats"),await f(p.beat,a)}),y.push(async a=>{await ue(e,1,a),await f(p.look,a)})}),y.push(async e=>{m(e),await w("main"),await x(D(S())),await O(u,0,r.shift),m(e),await x(D(b)),le(b).forEach((n,a)=>{n.open=a===0}),await w("outline"),await G(b),await x(d(".ka-tree > .ka-tree-list > li > details"),M.find(n=>n.value===b).closest("details")),await f(p.beat,e),await ue(b,0,e),await w("main"),await f(p.look,e)});let J=0,g=null,T=!1,K=!1,fe=!1;const pe=()=>!T&&fe&&!document.hidden&&(K||!C());async function Ie(){const e=new AbortController;g=e,o.dataset.tour="playing";try{for(;!e.signal.aborted;)await y[J](e.signal),J=(J+1)%y.length}catch(t){if(!(t instanceof F))throw t}finally{g===e&&(g=null),g||(o.dataset.tour=T?"stopped":"paused"),Q()}}function R(){pe()&&!g?Ie():!pe()&&g&&g.abort(),Q()}function k(){T||(T=!0,te(),U(),g?.abort(),R())}const de=()=>!T&&(K||!C()),we={pause:'<rect x="14" y="4" width="4" height="16" rx="1"/><rect x="6" y="4" width="4" height="16" rx="1"/>',play:'<path d="M6 3.5v17a1 1 0 0 0 1.5.86l14-8.5a1 1 0 0 0 0-1.72l-14-8.5A1 1 0 0 0 6 3.5z"/>'};function Q(){if(!A)return;const e=de();A.hidden=!1;const t=A.querySelector("svg");t&&(t.innerHTML=e?we.pause:we.play);const n=A.querySelector("[data-tour-label]");n&&(n.textContent=e?"Pause tour":"Play tour")}A?.addEventListener("click",()=>{de()?k():(T=!1,K=!0,R())}),o.addEventListener("pointerdown",e=>{e.pointerType==="mouse"&&k()},{capture:!0}),o.addEventListener("click",k,{capture:!0}),o.addEventListener("keydown",k,{capture:!0});for(const e of[u,j,ye])e.addEventListener("wheel",k,{passive:!0}),e.addEventListener("touchmove",k,{passive:!0});o.addEventListener("focusin",e=>{e.target.matches(":focus-visible")&&k()}),new IntersectionObserver(([e])=>{fe=e.isIntersecting,R()},{threshold:.5}).observe(o),document.addEventListener("visibilitychange",R),he.addEventListener("change",R),Q()}const me=document.getElementById("workspace");me&&Be(me,document.querySelector(".demo-tour-toggle"));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.