decklight 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +16 -8
  2. package/SPEC.md +166 -10
  3. package/cli/agents.mjs +52 -2
  4. package/cli/banner.mjs +125 -0
  5. package/cli/bundle.mjs +14 -4
  6. package/cli/{rec.mjs → cast.mjs} +25 -8
  7. package/cli/comments.mjs +389 -0
  8. package/cli/commit-flow.mjs +157 -0
  9. package/cli/commit-message.mjs +125 -0
  10. package/cli/decklight.mjs +88 -25
  11. package/cli/dev.mjs +159 -13
  12. package/cli/edit.mjs +927 -39
  13. package/cli/git-tree.mjs +87 -0
  14. package/cli/git.mjs +22 -0
  15. package/cli/init.mjs +37 -5
  16. package/cli/port-conflict.mjs +187 -16
  17. package/cli/publish.mjs +15 -40
  18. package/cli/record.mjs +154 -0
  19. package/cli/review-remote.mjs +330 -0
  20. package/cli/review-store.mjs +107 -0
  21. package/cli/review-submit.mjs +292 -0
  22. package/cli/review.mjs +361 -0
  23. package/cli/serve.mjs +36 -1
  24. package/cli/skill-content.mjs +3 -1
  25. package/cli/units.mjs +2 -2
  26. package/cli/util.mjs +59 -0
  27. package/dist/build-info.json +1 -0
  28. package/dist/decklight.css +244 -1
  29. package/dist/decklight.js +102 -79
  30. package/dist/decklight.js.map +4 -4
  31. package/docs/architecture.svg +7 -0
  32. package/package.json +2 -1
  33. package/tools/args.mjs +20 -0
  34. package/tools/deck-html.mjs +50 -0
  35. package/tools/elevenlabs-tts.mjs +1 -1
  36. package/tools/lipsync-server.mjs +64 -2
  37. package/tools/lipsync.mjs +40 -24
  38. package/tools/local-voice.mjs +170 -16
  39. package/tools/publish-voices.mjs +78 -18
  40. package/tools/recording-impact.mjs +110 -0
  41. package/tools/review-anchor.mjs +180 -0
  42. package/tools/test-impact.mjs +259 -0
  43. package/tools/tts-engines.mjs +26 -4
  44. package/tools/tts-setup.mjs +1 -1
  45. package/tools/video.mjs +15 -3
  46. package/tools/voiceover-server.mjs +167 -7
  47. package/tools/voiceover.mjs +30 -1
package/dist/decklight.js CHANGED
@@ -1,10 +1,10 @@
1
- /*! Decklight v0.6.0 — Copyright 2026 Gilles Philippart — SPDX-License-Identifier: Apache-2.0 */
2
- var Decklight=(()=>{var Ga=Object.create;var pr=Object.defineProperty;var ja=Object.getOwnPropertyDescriptor;var Ka=Object.getOwnPropertyNames;var Wa=Object.getPrototypeOf,Va=Object.prototype.hasOwnProperty;var Ks=(r,i)=>()=>(r&&(i=r(r=0)),i);var Za=(r,i)=>()=>(i||r((i={exports:{}}).exports,i),i.exports),Xa=(r,i)=>{for(var l in i)pr(r,l,{get:i[l],enumerable:!0})},Ws=(r,i,l,d)=>{if(i&&typeof i=="object"||typeof i=="function")for(let u of Ka(i))!Va.call(r,u)&&u!==l&&pr(r,u,{get:()=>i[u],enumerable:!(d=ja(i,u))||d.enumerable});return r};var Ya=(r,i,l)=>(l=r!=null?Ga(Wa(r)):{},Ws(i||!r||!r.__esModule?pr(l,"default",{value:r,enumerable:!0}):l,r)),Ja=r=>Ws(pr({},"__esModule",{value:!0}),r);var Ze,le=Ks(()=>{Ze={order:["default","classics"],labels:{default:"Default",classics:"Classics"},packs:{default:["aurora","eclipse","midnight","fjord","cosmos","ink","storm","carbon","synthwave","obsidian","graphite","ember","moss","velvet","porcelain","paper","linen","sepia","glacier","mint","latte","dune","coastal","harvest","meadow","orchid","peony","slate","berry","citrus","ibm-modern","yamabuki"],classics:["reveal-black","reveal-white","reveal-league","reveal-beige","reveal-sky","reveal-night","reveal-serif","reveal-simple","reveal-solarized","reveal-moon","reveal-blood","reveal-dracula","metropolis","seriph"]}}});var Ge,ce=Ks(()=>{Ge=["aurora","berry","carbon","citrus","coastal","cosmos","dune","eclipse","ember","fjord","glacier","graphite","harvest","ibm-modern","ink","latte","linen","meadow","metropolis","midnight","mint","moss","obsidian","orchid","paper","peony","porcelain","reveal-beige","reveal-black","reveal-blood","reveal-dracula","reveal-league","reveal-moon","reveal-night","reveal-serif","reveal-simple","reveal-sky","reveal-solarized","reveal-white","sepia","seriph","slate","storm","synthwave","velvet","yamabuki"]});var Bo=Za((xu,Io)=>{le();ce();function Eo(r){return r instanceof Map?r.clear=r.delete=r.set=function(){throw new Error("map is read-only")}:r instanceof Set&&(r.add=r.clear=r.delete=function(){throw new Error("set is read-only")}),Object.freeze(r),Object.getOwnPropertyNames(r).forEach(i=>{let l=r[i],d=typeof l;(d==="object"||d==="function")&&!Object.isFrozen(l)&&Eo(l)}),r}var br=class{constructor(i){i.data===void 0&&(i.data={}),this.data=i.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function So(r){return r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function Sn(r,...i){let l=Object.create(null);for(let d in r)l[d]=r[d];return i.forEach(function(d){for(let u in d)l[u]=d[u]}),l}var Nl="</span>",bo=r=>!!r.scope,$l=(r,{prefix:i})=>{if(r.startsWith("language:"))return r.replace("language:","language-");if(r.includes(".")){let l=r.split(".");return[`${i}${l.shift()}`,...l.map((d,u)=>`${d}${"_".repeat(u+1)}`)].join(" ")}return`${i}${r}`},Vr=class{constructor(i,l){this.buffer="",this.classPrefix=l.classPrefix,i.walk(this)}addText(i){this.buffer+=So(i)}openNode(i){if(!bo(i))return;let l=$l(i.scope,{prefix:this.classPrefix});this.span(l)}closeNode(i){bo(i)&&(this.buffer+=Nl)}value(){return this.buffer}span(i){this.buffer+=`<span class="${i}">`}},yo=(r={})=>{let i={children:[]};return Object.assign(i,r),i},Zr=class r{constructor(){this.rootNode=yo(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(i){this.top.children.push(i)}openNode(i){let l=yo({scope:i});this.add(l),this.stack.push(l)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(i){return this.constructor._walk(i,this.rootNode)}static _walk(i,l){return typeof l=="string"?i.addText(l):l.children&&(i.openNode(l),l.children.forEach(d=>this._walk(i,d)),i.closeNode(l)),i}static _collapse(i){typeof i!="string"&&i.children&&(i.children.every(l=>typeof l=="string")?i.children=[i.children.join("")]:i.children.forEach(l=>{r._collapse(l)}))}},Xr=class extends Zr{constructor(i){super(),this.options=i}addText(i){i!==""&&this.add(i)}startScope(i){this.openNode(i)}endScope(){this.closeNode()}__addSublanguage(i,l){let d=i.root;l&&(d.scope=`language:${l}`),this.add(d)}toHTML(){return new Vr(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}};function tr(r){return r?typeof r=="string"?r:r.source:null}function Ao(r){return Rn("(?=",r,")")}function Ol(r){return Rn("(?:",r,")*")}function Ml(r){return Rn("(?:",r,")?")}function Rn(...r){return r.map(l=>tr(l)).join("")}function Ll(r){let i=r[r.length-1];return typeof i=="object"&&i.constructor===Object?(r.splice(r.length-1,1),i):{}}function Jr(...r){return"("+(Ll(r).capture?"":"?:")+r.map(d=>tr(d)).join("|")+")"}function _o(r){return new RegExp(r.toString()+"|").exec("").length-1}function Rl(r,i){let l=r&&r.exec(i);return l&&l.index===0}var Il=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function Qr(r,{joinWith:i}){let l=0;return r.map(d=>{l+=1;let u=l,m=tr(d),f="";for(;m.length>0;){let h=Il.exec(m);if(!h){f+=m;break}f+=m.substring(0,h.index),m=m.substring(h.index+h[0].length),h[0][0]==="\\"&&h[1]?f+="\\"+String(Number(h[1])+u):(f+=h[0],h[0]==="("&&l++)}return f}).map(d=>`(${d})`).join(i)}var Bl=/\b\B/,To="[a-zA-Z]\\w*",es="[a-zA-Z_]\\w*",Co="\\b\\d+(\\.\\d+)?",No="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",$o="\\b(0b[01]+)",Pl="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",Dl=(r={})=>{let i=/^#![ ]*\//;return r.binary&&(r.begin=Rn(i,/.*\b/,r.binary,/\b.*/)),Sn({scope:"meta",begin:i,end:/$/,relevance:0,"on:begin":(l,d)=>{l.index!==0&&d.ignoreMatch()}},r)},nr={begin:"\\\\[\\s\\S]",relevance:0},ql={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[nr]},Fl={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[nr]},zl={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},wr=function(r,i,l={}){let d=Sn({scope:"comment",begin:r,end:i,contains:[]},l);d.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});let u=Jr("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return d.contains.push({begin:Rn(/[ ]+/,"(",u,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),d},Ul=wr("//","$"),Hl=wr("/\\*","\\*/"),Gl=wr("#","$"),jl={scope:"number",begin:Co,relevance:0},Kl={scope:"number",begin:No,relevance:0},Wl={scope:"number",begin:$o,relevance:0},Vl={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[nr,{begin:/\[/,end:/\]/,relevance:0,contains:[nr]}]},Zl={scope:"title",begin:To,relevance:0},Xl={scope:"title",begin:es,relevance:0},Yl={begin:"\\.\\s*"+es,relevance:0},Jl=function(r){return Object.assign(r,{"on:begin":(i,l)=>{l.data._beginMatch=i[1]},"on:end":(i,l)=>{l.data._beginMatch!==i[1]&&l.ignoreMatch()}})},gr=Object.freeze({__proto__:null,APOS_STRING_MODE:ql,BACKSLASH_ESCAPE:nr,BINARY_NUMBER_MODE:Wl,BINARY_NUMBER_RE:$o,COMMENT:wr,C_BLOCK_COMMENT_MODE:Hl,C_LINE_COMMENT_MODE:Ul,C_NUMBER_MODE:Kl,C_NUMBER_RE:No,END_SAME_AS_BEGIN:Jl,HASH_COMMENT_MODE:Gl,IDENT_RE:To,MATCH_NOTHING_RE:Bl,METHOD_GUARD:Yl,NUMBER_MODE:jl,NUMBER_RE:Co,PHRASAL_WORDS_MODE:zl,QUOTE_STRING_MODE:Fl,REGEXP_MODE:Vl,RE_STARTERS_RE:Pl,SHEBANG:Dl,TITLE_MODE:Zl,UNDERSCORE_IDENT_RE:es,UNDERSCORE_TITLE_MODE:Xl});function Ql(r,i){r.input[r.index-1]==="."&&i.ignoreMatch()}function ec(r,i){r.className!==void 0&&(r.scope=r.className,delete r.className)}function tc(r,i){i&&r.beginKeywords&&(r.begin="\\b("+r.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",r.__beforeBegin=Ql,r.keywords=r.keywords||r.beginKeywords,delete r.beginKeywords,r.relevance===void 0&&(r.relevance=0))}function nc(r,i){Array.isArray(r.illegal)&&(r.illegal=Jr(...r.illegal))}function rc(r,i){if(r.match){if(r.begin||r.end)throw new Error("begin & end are not supported with match");r.begin=r.match,delete r.match}}function sc(r,i){r.relevance===void 0&&(r.relevance=1)}var oc=(r,i)=>{if(!r.beforeMatch)return;if(r.starts)throw new Error("beforeMatch cannot be used with starts");let l=Object.assign({},r);Object.keys(r).forEach(d=>{delete r[d]}),r.keywords=l.keywords,r.begin=Rn(l.beforeMatch,Ao(l.begin)),r.starts={relevance:0,contains:[Object.assign(l,{endsParent:!0})]},r.relevance=0,delete l.beforeMatch},ic=["of","and","for","in","not","or","if","then","parent","list","value"],ac="keyword";function Oo(r,i,l=ac){let d=Object.create(null);return typeof r=="string"?u(l,r.split(" ")):Array.isArray(r)?u(l,r):Object.keys(r).forEach(function(m){Object.assign(d,Oo(r[m],i,m))}),d;function u(m,f){i&&(f=f.map(h=>h.toLowerCase())),f.forEach(function(h){let b=h.split("|");d[b[0]]=[m,lc(b[0],b[1])]})}}function lc(r,i){return i?Number(i):cc(r)?0:1}function cc(r){return ic.includes(r.toLowerCase())}var wo={},Ln=r=>{console.error(r)},xo=(r,...i)=>{console.log(`WARN: ${r}`,...i)},Un=(r,i)=>{wo[`${r}/${i}`]||(console.log(`Deprecated as of ${r}. ${i}`),wo[`${r}/${i}`]=!0)},yr=new Error;function Mo(r,i,{key:l}){let d=0,u=r[l],m={},f={};for(let h=1;h<=i.length;h++)f[h+d]=u[h],m[h+d]=!0,d+=_o(i[h-1]);r[l]=f,r[l]._emit=m,r[l]._multi=!0}function dc(r){if(Array.isArray(r.begin)){if(r.skip||r.excludeBegin||r.returnBegin)throw Ln("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),yr;if(typeof r.beginScope!="object"||r.beginScope===null)throw Ln("beginScope must be object"),yr;Mo(r,r.begin,{key:"beginScope"}),r.begin=Qr(r.begin,{joinWith:""})}}function uc(r){if(Array.isArray(r.end)){if(r.skip||r.excludeEnd||r.returnEnd)throw Ln("skip, excludeEnd, returnEnd not compatible with endScope: {}"),yr;if(typeof r.endScope!="object"||r.endScope===null)throw Ln("endScope must be object"),yr;Mo(r,r.end,{key:"endScope"}),r.end=Qr(r.end,{joinWith:""})}}function pc(r){r.scope&&typeof r.scope=="object"&&r.scope!==null&&(r.beginScope=r.scope,delete r.scope)}function hc(r){pc(r),typeof r.beginScope=="string"&&(r.beginScope={_wrap:r.beginScope}),typeof r.endScope=="string"&&(r.endScope={_wrap:r.endScope}),dc(r),uc(r)}function mc(r){function i(f,h){return new RegExp(tr(f),"m"+(r.case_insensitive?"i":"")+(r.unicodeRegex?"u":"")+(h?"g":""))}class l{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(h,b){b.position=this.position++,this.matchIndexes[this.matchAt]=b,this.regexes.push([b,h]),this.matchAt+=_o(h)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);let h=this.regexes.map(b=>b[1]);this.matcherRe=i(Qr(h,{joinWith:"|"}),!0),this.lastIndex=0}exec(h){this.matcherRe.lastIndex=this.lastIndex;let b=this.matcherRe.exec(h);if(!b)return null;let k=b.findIndex((P,M)=>M>0&&P!==void 0),A=this.matchIndexes[k];return b.splice(0,k),Object.assign(b,A)}}class d{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(h){if(this.multiRegexes[h])return this.multiRegexes[h];let b=new l;return this.rules.slice(h).forEach(([k,A])=>b.addRule(k,A)),b.compile(),this.multiRegexes[h]=b,b}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(h,b){this.rules.push([h,b]),b.type==="begin"&&this.count++}exec(h){let b=this.getMatcher(this.regexIndex);b.lastIndex=this.lastIndex;let k=b.exec(h);if(this.resumingScanAtSamePosition()&&!(k&&k.index===this.lastIndex)){let A=this.getMatcher(0);A.lastIndex=this.lastIndex+1,k=A.exec(h)}return k&&(this.regexIndex+=k.position+1,this.regexIndex===this.count&&this.considerAll()),k}}function u(f){let h=new d;return f.contains.forEach(b=>h.addRule(b.begin,{rule:b,type:"begin"})),f.terminatorEnd&&h.addRule(f.terminatorEnd,{type:"end"}),f.illegal&&h.addRule(f.illegal,{type:"illegal"}),h}function m(f,h){let b=f;if(f.isCompiled)return b;[ec,rc,hc,oc].forEach(A=>A(f,h)),r.compilerExtensions.forEach(A=>A(f,h)),f.__beforeBegin=null,[tc,nc,sc].forEach(A=>A(f,h)),f.isCompiled=!0;let k=null;return typeof f.keywords=="object"&&f.keywords.$pattern&&(f.keywords=Object.assign({},f.keywords),k=f.keywords.$pattern,delete f.keywords.$pattern),k=k||/\w+/,f.keywords&&(f.keywords=Oo(f.keywords,r.case_insensitive)),b.keywordPatternRe=i(k,!0),h&&(f.begin||(f.begin=/\B|\b/),b.beginRe=i(b.begin),!f.end&&!f.endsWithParent&&(f.end=/\B|\b/),f.end&&(b.endRe=i(b.end)),b.terminatorEnd=tr(b.end)||"",f.endsWithParent&&h.terminatorEnd&&(b.terminatorEnd+=(f.end?"|":"")+h.terminatorEnd)),f.illegal&&(b.illegalRe=i(f.illegal)),f.contains||(f.contains=[]),f.contains=[].concat(...f.contains.map(function(A){return fc(A==="self"?f:A)})),f.contains.forEach(function(A){m(A,b)}),f.starts&&m(f.starts,h),b.matcher=u(b),b}if(r.compilerExtensions||(r.compilerExtensions=[]),r.contains&&r.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return r.classNameAliases=Sn(r.classNameAliases||{}),m(r)}function Lo(r){return r?r.endsWithParent||Lo(r.starts):!1}function fc(r){return r.variants&&!r.cachedVariants&&(r.cachedVariants=r.variants.map(function(i){return Sn(r,{variants:null},i)})),r.cachedVariants?r.cachedVariants:Lo(r)?Sn(r,{starts:r.starts?Sn(r.starts):null}):Object.isFrozen(r)?Sn(r):r}var gc="11.11.1",Yr=class extends Error{constructor(i,l){super(i),this.name="HTMLInjectionError",this.html=l}},Wr=So,vo=Sn,ko=Symbol("nomatch"),bc=7,Ro=function(r){let i=Object.create(null),l=Object.create(null),d=[],u=!0,m="Could not find the language '{}', did you forget to load/include a language module?",f={disableAutodetect:!0,name:"Plain text",contains:[]},h={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:Xr};function b(O){return h.noHighlightRe.test(O)}function k(O){let D=O.className+" ";D+=O.parentNode?O.parentNode.className:"";let V=h.languageDetectRe.exec(D);if(V){let re=xe(V[1]);return re||(xo(m.replace("{}",V[1])),xo("Falling back to no-highlight mode for this block.",O)),re?V[1]:"no-highlight"}return D.split(/\s+/).find(re=>b(re)||xe(re))}function A(O,D,V){let re="",Ae="";typeof D=="object"?(re=O,V=D.ignoreIllegals,Ae=D.language):(Un("10.7.0","highlight(lang, code, ...args) has been deprecated."),Un("10.7.0",`Please use highlight(code, options) instead.
3
- https://github.com/highlightjs/highlight.js/issues/2277`),Ae=O,re=D),V===void 0&&(V=!0);let Ke={code:re,language:Ae};Je("before:highlight",Ke);let Ce=Ke.result?Ke.result:P(Ke.language,Ke.code,V);return Ce.code=Ke.code,Je("after:highlight",Ce),Ce}function P(O,D,V,re){let Ae=Object.create(null);function Ke(me,Ne){return me.keywords[Ne]}function Ce(){if(!Se.keywords){Ee.addText(ze);return}let me=0;Se.keywordPatternRe.lastIndex=0;let Ne=Se.keywordPatternRe.exec(ze),Ie="";for(;Ne;){Ie+=ze.substring(me,Ne.index);let et=Be.case_insensitive?Ne[0].toLowerCase():Ne[0],tt=Ke(Se,et);if(tt){let[bt,He]=tt;if(Ee.addText(Ie),Ie="",Ae[et]=(Ae[et]||0)+1,Ae[et]<=bc&&(oe+=He),bt.startsWith("_"))Ie+=Ne[0];else{let ft=Be.classNameAliases[bt]||bt;N(Ne[0],ft)}}else Ie+=Ne[0];me=Se.keywordPatternRe.lastIndex,Ne=Se.keywordPatternRe.exec(ze)}Ie+=ze.substring(me),Ee.addText(Ie)}function s(){if(ze==="")return;let me=null;if(typeof Se.subLanguage=="string"){if(!i[Se.subLanguage]){Ee.addText(ze);return}me=P(Se.subLanguage,ze,!0,it[Se.subLanguage]),it[Se.subLanguage]=me._top}else me=T(ze,Se.subLanguage.length?Se.subLanguage:null);Se.relevance>0&&(oe+=me.relevance),Ee.__addSublanguage(me._emitter,me.language)}function o(){Se.subLanguage!=null?s():Ce(),ze=""}function N(me,Ne){me!==""&&(Ee.startScope(Ne),Ee.addText(me),Ee.endScope())}function Fe(me,Ne){let Ie=1,et=Ne.length-1;for(;Ie<=et;){if(!me._emit[Ie]){Ie++;continue}let tt=Be.classNameAliases[me[Ie]]||me[Ie],bt=Ne[Ie];tt?N(bt,tt):(ze=bt,Ce(),ze=""),Ie++}}function B(me,Ne){return me.scope&&typeof me.scope=="string"&&Ee.openNode(Be.classNameAliases[me.scope]||me.scope),me.beginScope&&(me.beginScope._wrap?(N(ze,Be.classNameAliases[me.beginScope._wrap]||me.beginScope._wrap),ze=""):me.beginScope._multi&&(Fe(me.beginScope,Ne),ze="")),Se=Object.create(me,{parent:{value:Se}}),Se}function ot(me,Ne,Ie){let et=Rl(me.endRe,Ie);if(et){if(me["on:end"]){let tt=new br(me);me["on:end"](Ne,tt),tt.isMatchIgnored&&(et=!1)}if(et){for(;me.endsParent&&me.parent;)me=me.parent;return me}}if(me.endsWithParent)return ot(me.parent,Ne,Ie)}function mt(me){return Se.matcher.regexIndex===0?(ze+=me[0],1):(Et=!0,0)}function K(me){let Ne=me[0],Ie=me.rule,et=new br(Ie),tt=[Ie.__beforeBegin,Ie["on:begin"]];for(let bt of tt)if(bt&&(bt(me,et),et.isMatchIgnored))return mt(Ne);return Ie.skip?ze+=Ne:(Ie.excludeBegin&&(ze+=Ne),o(),!Ie.returnBegin&&!Ie.excludeBegin&&(ze=Ne)),B(Ie,me),Ie.returnBegin?0:Ne.length}function _e(me){let Ne=me[0],Ie=D.substring(me.index),et=ot(Se,me,Ie);if(!et)return ko;let tt=Se;Se.endScope&&Se.endScope._wrap?(o(),N(Ne,Se.endScope._wrap)):Se.endScope&&Se.endScope._multi?(o(),Fe(Se.endScope,me)):tt.skip?ze+=Ne:(tt.returnEnd||tt.excludeEnd||(ze+=Ne),o(),tt.excludeEnd&&(ze=Ne));do Se.scope&&Ee.closeNode(),!Se.skip&&!Se.subLanguage&&(oe+=Se.relevance),Se=Se.parent;while(Se!==et.parent);return et.starts&&B(et.starts,me),tt.returnEnd?0:Ne.length}function Y(){let me=[];for(let Ne=Se;Ne!==Be;Ne=Ne.parent)Ne.scope&&me.unshift(Ne.scope);me.forEach(Ne=>Ee.openNode(Ne))}let Re={};function y(me,Ne){let Ie=Ne&&Ne[0];if(ze+=me,Ie==null)return o(),0;if(Re.type==="begin"&&Ne.type==="end"&&Re.index===Ne.index&&Ie===""){if(ze+=D.slice(Ne.index,Ne.index+1),!u){let et=new Error(`0 width match regex (${O})`);throw et.languageName=O,et.badRule=Re.rule,et}return 1}if(Re=Ne,Ne.type==="begin")return K(Ne);if(Ne.type==="illegal"&&!V){let et=new Error('Illegal lexeme "'+Ie+'" for mode "'+(Se.scope||"<unnamed>")+'"');throw et.mode=Se,et}else if(Ne.type==="end"){let et=_e(Ne);if(et!==ko)return et}if(Ne.type==="illegal"&&Ie==="")return ze+=`
4
- `,1;if(gt>1e5&&gt>Ne.index*3)throw new Error("potential infinite loop, way more iterations than matches");return ze+=Ie,Ie.length}let Be=xe(O);if(!Be)throw Ln(m.replace("{}",O)),new Error('Unknown language: "'+O+'"');let w=mc(Be),pe="",Se=re||w,it={},Ee=new h.__emitter(h);Y();let ze="",oe=0,Xe=0,gt=0,Et=!1;try{if(Be.__emitTokens)Be.__emitTokens(D,Ee);else{for(Se.matcher.considerAll();;){gt++,Et?Et=!1:Se.matcher.considerAll(),Se.matcher.lastIndex=Xe;let me=Se.matcher.exec(D);if(!me)break;let Ne=D.substring(Xe,me.index),Ie=y(Ne,me);Xe=me.index+Ie}y(D.substring(Xe))}return Ee.finalize(),pe=Ee.toHTML(),{language:O,value:pe,relevance:oe,illegal:!1,_emitter:Ee,_top:Se}}catch(me){if(me.message&&me.message.includes("Illegal"))return{language:O,value:Wr(D),illegal:!0,relevance:0,_illegalBy:{message:me.message,index:Xe,context:D.slice(Xe-100,Xe+100),mode:me.mode,resultSoFar:pe},_emitter:Ee};if(u)return{language:O,value:Wr(D),illegal:!1,relevance:0,errorRaised:me,_emitter:Ee,_top:Se};throw me}}function M(O){let D={value:Wr(O),illegal:!1,relevance:0,_top:f,_emitter:new h.__emitter(h)};return D._emitter.addText(O),D}function T(O,D){D=D||h.languages||Object.keys(i);let V=M(O),re=D.filter(xe).filter(st).map(o=>P(o,O,!1));re.unshift(V);let Ae=re.sort((o,N)=>{if(o.relevance!==N.relevance)return N.relevance-o.relevance;if(o.language&&N.language){if(xe(o.language).supersetOf===N.language)return 1;if(xe(N.language).supersetOf===o.language)return-1}return 0}),[Ke,Ce]=Ae,s=Ke;return s.secondBest=Ce,s}function C(O,D,V){let re=D&&l[D]||V;O.classList.add("hljs"),O.classList.add(`language-${re}`)}function F(O){let D=null,V=k(O);if(b(V))return;if(Je("before:highlightElement",{el:O,language:V}),O.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",O);return}if(O.children.length>0&&(h.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(O)),h.throwUnescapedHTML))throw new Yr("One of your code blocks includes unescaped HTML.",O.innerHTML);D=O;let re=D.textContent,Ae=V?A(re,{language:V,ignoreIllegals:!0}):T(re);O.innerHTML=Ae.value,O.dataset.highlighted="yes",C(O,V,Ae.language),O.result={language:Ae.language,re:Ae.relevance,relevance:Ae.relevance},Ae.secondBest&&(O.secondBest={language:Ae.secondBest.language,relevance:Ae.secondBest.relevance}),Je("after:highlightElement",{el:O,result:Ae,text:re})}function ye(O){h=vo(h,O)}let ge=()=>{de(),Un("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function be(){de(),Un("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let J=!1;function de(){function O(){de()}if(document.readyState==="loading"){J||window.addEventListener("DOMContentLoaded",O,!1),J=!0;return}document.querySelectorAll(h.cssSelector).forEach(F)}function Oe(O,D){let V=null;try{V=D(r)}catch(re){if(Ln("Language definition for '{}' could not be registered.".replace("{}",O)),u)Ln(re);else throw re;V=f}V.name||(V.name=O),i[O]=V,V.rawDefinition=D.bind(null,r),V.aliases&&Le(V.aliases,{languageName:O})}function ke(O){delete i[O];for(let D of Object.keys(l))l[D]===O&&delete l[D]}function De(){return Object.keys(i)}function xe(O){return O=(O||"").toLowerCase(),i[O]||i[l[O]]}function Le(O,{languageName:D}){typeof O=="string"&&(O=[O]),O.forEach(V=>{l[V.toLowerCase()]=D})}function st(O){let D=xe(O);return D&&!D.disableAutodetect}function at(O){O["before:highlightBlock"]&&!O["before:highlightElement"]&&(O["before:highlightElement"]=D=>{O["before:highlightBlock"](Object.assign({block:D.el},D))}),O["after:highlightBlock"]&&!O["after:highlightElement"]&&(O["after:highlightElement"]=D=>{O["after:highlightBlock"](Object.assign({block:D.el},D))})}function _(O){at(O),d.push(O)}function qe(O){let D=d.indexOf(O);D!==-1&&d.splice(D,1)}function Je(O,D){let V=O;d.forEach(function(re){re[V]&&re[V](D)})}function je(O){return Un("10.7.0","highlightBlock will be removed entirely in v12.0"),Un("10.7.0","Please use highlightElement now."),F(O)}Object.assign(r,{highlight:A,highlightAuto:T,highlightAll:de,highlightElement:F,highlightBlock:je,configure:ye,initHighlighting:ge,initHighlightingOnLoad:be,registerLanguage:Oe,unregisterLanguage:ke,listLanguages:De,getLanguage:xe,registerAliases:Le,autoDetection:st,inherit:vo,addPlugin:_,removePlugin:qe}),r.debugMode=function(){u=!1},r.safeMode=function(){u=!0},r.versionString=gc,r.regex={concat:Rn,lookahead:Ao,either:Jr,optional:Ml,anyNumberOfTimes:Ol};for(let O in gr)typeof gr[O]=="object"&&Eo(gr[O]);return Object.assign(r,gr),r},Hn=Ro({});Hn.newInstance=()=>Ro({});Io.exports=Hn;Hn.HighlightJS=Hn;Hn.default=Hn});var Ud={};Xa(Ud,{init:()=>Fd,initTerminals:()=>zd,registerBuildProvider:()=>sr,version:()=>qd});le();ce();le();ce();le();ce();var tl=new Set(["UL","OL","TABLE","TBODY","DL","SVG"]),nl=new Set(["defs","title","desc","style","metadata"]),Xs=new Map;function Ys(r,i){Xs.set(r,i)}function mr(r){return[...r.children].filter(i=>{let l=i.tagName.toLowerCase();return!(nl.has(l)||l==="aside"&&i.classList.contains("notes")||i.hasAttribute("data-build-stay"))})}function rl(r){if(r.hasAttribute("data-build-self"))return!1;let i=r.tagName.toUpperCase();return tl.has(i)?!0:i==="DIV"||i==="G"?mr(r).length>=2:!1}function sl(r){if(r.tagName.toUpperCase()==="TABLE"){let l=r.querySelector(":scope > tbody");return l?mr(l):mr(r).filter(d=>d.tagName==="TR")}return mr(r)}function ol(r){let i=r.map((f,h)=>({...f,i:h}));i.sort((f,h)=>f.key-h.key||f.i-h.i);let l=[],d=null,u=null,m=!1;for(let f of i){if(d&&f.explicit&&m&&f.key===u){d.push(f.i);continue}d=[f.i],u=f.key,m=f.explicit,l.push(d)}return l}function Vs(r,i){r.classList.add("build-step"),r.setAttribute("data-build-style",i),r.setAttribute("data-build-state","pending"),i==="draw"&&il(r)}var Zs="path, line, polyline, polygon, circle, ellipse, rect";function il(r){let i=r.matches?.(Zs)?[r]:[...r.querySelectorAll(Zs)],l=!1;for(let u of i){let m=u.getAttribute("stroke")??getComputedStyle(u).stroke;if(!m||m==="none")continue;let f=0;try{f=u.getTotalLength()}catch{continue}if(!f)continue;l=!0;let h=u.getAttribute("stroke-dasharray")||u.style.strokeDasharray;h&&(u.dataset.drawOrig=h);for(let[b,k]of Gr){let A=u.getAttribute(b);A&&(u.dataset[k]=A)}u.classList.add("draw-stroke"),u.style.setProperty("--draw-len",String(Math.ceil(f)))}r.querySelectorAll("text, tspan").forEach(u=>u.classList.add("draw-fade")),l||r.setAttribute("data-build-style","fade")}var Gr=[["marker-start","drawMarkerStart"],["marker-mid","drawMarkerMid"],["marker-end","drawMarkerEnd"]];function hr(r,i){for(let[l,d]of Gr)d in r.dataset&&(i?r.setAttribute(l,r.dataset[d]):r.removeAttribute(l))}function al(r,i){for(let l of r.querySelectorAll(".draw-stroke")){let d=l.dataset.drawOrig,u=Gr.some(([,m])=>m in l.dataset);if(!(!d&&!u))if(i==="done")d&&(l.style.strokeDasharray=d,l.style.strokeDashoffset="0"),hr(l,!0);else if(i==="pending")l.style.removeProperty("stroke-dasharray"),l.style.removeProperty("stroke-dashoffset"),hr(l,!1);else{l.style.removeProperty("stroke-dasharray"),l.style.removeProperty("stroke-dashoffset"),hr(l,!1);let m=()=>{r.getAttribute("data-build-state")!=="pending"&&(d&&(l.style.strokeDasharray=d,l.style.strokeDashoffset="0"),hr(l,!0))},f=parseFloat(getComputedStyle(l).transitionDuration)||0;f===0?m():(l.addEventListener("transitionend",m,{once:!0}),setTimeout(m,f*1e3+150))}}}function jr(r){let i=[],l=[],d=new Set,u=0,m=(A,P)=>{let M=P!=null&&P!=="",T=M?parseInt(P,10):u;i.push(A),l.push({key:Number.isFinite(T)?T:u,explicit:M}),u++},f=document.createTreeWalker(r,NodeFilter.SHOW_ELEMENT);for(let A=f.nextNode();A;A=f.nextNode()){if(d.has(A))continue;let P=Xs.get(A);if(P){for(let T=0;T<P.count;T++)m({kind:"provider",provider:P,el:A,sub:T},null);A.querySelectorAll("*").forEach(T=>d.add(T));continue}if(!A.hasAttribute("data-build"))continue;let M=A.getAttribute("data-build")||"fade";if(rl(A)){for(let T of sl(A)){d.add(T),T.querySelectorAll("[data-build]").forEach(F=>d.add(F));let C=T.getAttribute("data-build")||M;Vs(T,C),m({kind:"dom",el:T,container:A},T.getAttribute("data-build-order"))}A.setAttribute("data-build-container","")}else Vs(A,M),m({kind:"dom",el:A,container:null},A.getAttribute("data-build-order"))}let h=ol(l),b=[],k=new Map;return i.forEach((A,P)=>{if(A.kind==="provider"){if(!k.has(A.provider)){let M={el:A.el,provider:A.provider,stepIdxs:[]};k.set(A.provider,M),b.push(M)}k.get(A.provider).stepIdxs.push(P)}}),{steps:i,groups:h,providers:b}}function En(r,i){let l=new Set;r.groups.forEach((f,h)=>{for(let b of f)h<i&&l.add(b)});let d=i>0?r.groups[i-1]??[]:[],u=new Set(d),m=new Set;r.steps.forEach((f,h)=>{if(f.kind!=="dom")return;let b=u.has(h)?"current":l.has(h)?"done":"pending";f.el.setAttribute("data-build-state",b),f.el.getAttribute("data-build-style")==="draw"&&al(f.el,b),f.container&&m.add(f.container)});for(let f of m){let h=!!f.querySelector(':scope [data-build-style="highlight"][data-build-state="current"]');f.classList.toggle("has-current-highlight",h)}for(let f of r.providers){let h=f.stepIdxs.filter(b=>l.has(b)||u.has(b)).length;f._last!==h&&(f._last=h,f.provider.apply(h))}}function Js(r){return r.groups.map(i=>{let l=r.steps[i[0]];if(l.kind==="provider"){let u=l.sub;return l.provider.label?l.provider.label(u+1):"step"}return l.el.textContent.trim().replace(/\s+/g," ").slice(0,60)||l.el.tagName.toLowerCase()})}le();ce();var Qs="rect, circle, ellipse, polygon, polyline, path";function ll(r){let i=5381;for(let l of String(r))i=(i*33^l.charCodeAt(0))>>>0;return 1+i%6}function cl(r,i={}){let l=i[r];return typeof l=="number"?`var(--d-fill-${l})`:typeof l=="string"?l:`var(--d-fill-${ll(r)})`}function eo(r,i={}){let l=new Map;r.querySelectorAll("svg [data-concept]").forEach(d=>{let u=d.getAttribute("data-concept");if(!u)return;let m=cl(u,i),f=m.match(/--d-fill-(\d)/);if(f){let b=l.get(f[1]);b&&b!==u?console.warn(`Decklight: concepts "${b}" and "${u}" share fill slot ${f[1]} \u2014 pin one explicitly via init({ concepts: { ${u}: <1-6> } })`):l.set(f[1],u)}let h=d.matches(Qs)?[d]:[...d.children].filter(b=>b.matches(Qs));for(let b of h){let k=b.getAttribute("fill")==="none"||b.style.fill==="none";b.style.setProperty(k?"stroke":"fill",m)}})}var dl=["fill","stroke","filter","clip-path","mask","marker-start","marker-mid","marker-end","style"];function to(r){r.querySelectorAll("svg").forEach((i,l)=>{let d=`svg${l}-`,u=new Map;if(i.querySelectorAll("[id]").forEach(f=>{let h=f.id;u.set(h,d+h),f.id=d+h}),u.size===0)return;let m=f=>f.replace(/url\(['"]?#([^'")]+)['"]?\)/g,(h,b)=>u.has(b)?`url(#${u.get(b)})`:h);i.querySelectorAll("*").forEach(f=>{for(let h of dl){let b=f.getAttribute(h);b&&b.includes("url(#")&&f.setAttribute(h,m(b))}for(let h of["href","xlink:href"]){let b=f.getAttribute(h);b&&b.startsWith("#")&&u.has(b.slice(1))&&f.setAttribute(h,"#"+u.get(b.slice(1)))}})})}le();ce();le();ce();var $t=r=>String(r).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");var no=640,ul=360,ro=["bar","line","area","pie","donut"],Te=r=>{let i=Math.round(r*100)/100;return Object.is(i,-0)?"0":String(i)},Fn=r=>`var(--d-fill-${r%6+1})`;function pl(r,i={}){let l;if(typeof r=="string")try{l=JSON.parse(r)}catch(k){throw new Error(`invalid JSON \u2014 ${k.message}`)}else if(r&&typeof r=="object")l=r;else throw new Error('no data \u2014 expected a <script type="application/json"> child (or the fence body)');let d=String(i.type||l.type||"").toLowerCase();if(!ro.includes(d))throw new Error(`unknown type "${d}" \u2014 use ${ro.join(" | ")}`);if(!Array.isArray(l.labels)||l.labels.length===0)throw new Error('"labels" must be a non-empty array');if(!Array.isArray(l.series)||l.series.length===0)throw new Error('"series" must be a non-empty array');let u=l.labels.map(String),m=l.series.map((k,A)=>{if(!k||!Array.isArray(k.data))throw new Error(`series ${A+1}: "data" must be an array of numbers`);return{name:k.name!=null?String(k.name):`series ${A+1}`,concept:k.concept!=null?String(k.concept):null,data:u.map((P,M)=>{let T=Number(k.data[M]);return Number.isFinite(T)?T:null})}}),f=d==="pie"||d==="donut";if(f&&m.length>1)throw new Error("pie takes exactly one series (labels are the slices)");if(f&&!m[0].data.some(k=>k>0))throw new Error("pie needs at least one positive value");let h=ul,b=i.aspect??l.aspect??null;if(b!=null){let k=String(b).match(/^\s*(\d+(?:\.\d+)?)\s*[:x]\s*(\d+(?:\.\d+)?)\s*$/i);if(!k||+k[1]==0)throw new Error(`bad aspect "${b}" \u2014 use "w:h", e.g. "4:3"`);h=Math.round(no*+k[2]/+k[1])}return{type:f?"pie":d,donut:d==="donut"||l.donut===!0,title:i.title??(l.title!=null?String(l.title):null),labels:u,series:m,legend:l.legend,width:no,height:h,build:l.build}}function hl(r,i,l=5){if(!Number.isFinite(r)||!Number.isFinite(i))throw new Error("niceTicks: non-finite range");if(r>i&&([r,i]=[i,r]),r===i){let P=r===0?1:Math.abs(r)/2;r-=r===0?0:P,i+=P}let d=(i-r)/Math.max(1,l-1),u=10**Math.floor(Math.log10(d)),m=d/u,f=(m<=1?1:m<=2?2:m<=2.5?2.5:m<=5?5:10)*u,h=Math.floor(r/f+1e-9)*f,b=Math.ceil(i/f-1e-9)*f,k=Math.max(1,Math.round((b-h)/f)),A=Array.from({length:k+1},(P,M)=>+(h+M*f).toPrecision(12));return{min:A[0],max:A[k],step:f,ticks:A}}function ml(r,i){let l=0;for(;l<6&&Math.abs(Math.round(i*10**l)-i*10**l)>1e-9;)l++;return r.toFixed(l)}function fl(r,i,l,d){let u=d.max-d.min||1,m=A=>l.y+l.h*(1-(A-d.min)/u),f=m(Math.max(d.min,Math.min(d.max,0))),h=l.w/i,b=h*.72,k=b/r.length;return r.map((A,P)=>Array.from({length:i},(M,T)=>{let C=A.data[T];if(C==null||!Number.isFinite(C))return null;let F=m(C);return{x:l.x+T*h+(h-b)/2+P*k+1,y:Math.min(F,f),w:Math.max(1,k-2),h:Math.abs(f-F),value:C}}))}function gl(r){let i="",l=!1;for(let d of r){if(!d){l=!1;continue}i+=`${l?"L":"M"}${Te(d.x)} ${Te(d.y)}`,l=!0}return i}function bl(r,i){let l=r.filter(Boolean);if(!l.length)return"";let d=`M${Te(l[0].x)} ${Te(i)}`;for(let u of l)d+=`L${Te(u.x)} ${Te(u.y)}`;return d+=`L${Te(l[l.length-1].x)} ${Te(i)}Z`,d}function yl(r,i,l,d,u=0){let m=r.map(k=>Math.max(0,Number(k)||0)),f=m.reduce((k,A)=>k+A,0);if(f<=0)throw new Error("pie needs at least one positive value");let h=(k,A)=>[i+A*Math.cos(k),l+A*Math.sin(k)],b=-Math.PI/2;return m.map(k=>{let A=k/f,P=b,M=b+A*2*Math.PI;b=M;let T=(P+M)/2,C=u>0?(d+u)/2:d*.66,[F,ye]=h(T,C),[ge,be]=h(T,d+14),J={value:k,frac:A,mid:T,labelX:F,labelY:ye,outX:ge,outY:be,anchor:Math.cos(T)<-1e-6?"end":Math.cos(T)>1e-6?"start":"middle"};if(A===0)return{...J,d:""};let de;if(A>=.9999){let[Oe,ke]=h(P,d),[De,xe]=h(P+Math.PI,d);if(de=`M${Te(Oe)} ${Te(ke)}A${Te(d)} ${Te(d)} 0 1 1 ${Te(De)} ${Te(xe)}A${Te(d)} ${Te(d)} 0 1 1 ${Te(Oe)} ${Te(ke)}Z`,u>0){let[Le,st]=h(P,u),[at,_]=h(P+Math.PI,u);de+=`M${Te(Le)} ${Te(st)}A${Te(u)} ${Te(u)} 0 1 0 ${Te(at)} ${Te(_)}A${Te(u)} ${Te(u)} 0 1 0 ${Te(Le)} ${Te(st)}Z`}}else{let Oe=M-P>Math.PI?1:0,[ke,De]=h(P,d),[xe,Le]=h(M,d);if(u>0){let[st,at]=h(M,u),[_,qe]=h(P,u);de=`M${Te(ke)} ${Te(De)}A${Te(d)} ${Te(d)} 0 ${Oe} 1 ${Te(xe)} ${Te(Le)}L${Te(st)} ${Te(at)}A${Te(u)} ${Te(u)} 0 ${Oe} 0 ${Te(_)} ${Te(qe)}Z`}else de=`M${Te(i)} ${Te(l)}L${Te(ke)} ${Te(De)}A${Te(d)} ${Te(d)} 0 ${Oe} 1 ${Te(xe)} ${Te(Le)}Z`}return{...J,d:de}})}var zn='fill="var(--d-text)"';function Kr(r,i){return`<g class="chart-series" data-series="${i+1}" data-name="${$t(r.name)}"`+(r.concept?` data-concept="${$t(r.concept)}"`:"")+">"}function wl(r,i,l){let d=r.series.flatMap(C=>C.data).filter(C=>C!=null),u=Math.min(0,...d),m=Math.max(0,...d),f=hl(u,m===u?u+1:m,5),h=f.ticks.map(C=>ml(C,f.step)),b=14+Math.max(...h.map(C=>C.length))*6.6+8,k={x:b,y:r.title||so(r)?40:18,w:r.width-b-14,h:0};k.h=r.height-k.y-34;let A=f.max-f.min||1,P=C=>k.y+k.h*(1-(C-f.min)/A);f.ticks.forEach((C,F)=>{let ye=P(C);i.push(`<line class="chart-grid" x1="${Te(k.x)}" y1="${Te(ye)}" x2="${Te(k.x+k.w)}" y2="${Te(ye)}" stroke="var(--d-muted)" stroke-opacity="0.35" stroke-width="1"/>`),i.push(`<text class="chart-tick" x="${Te(k.x-8)}" y="${Te(ye+4)}" text-anchor="end" font-size="11" ${zn}>${$t(h[F])}</text>`)}),i.push(`<line class="chart-axis" x1="${Te(k.x)}" y1="${Te(k.y)}" x2="${Te(k.x)}" y2="${Te(k.y+k.h)}" stroke="var(--d-stroke)" stroke-width="1.5"/>`);let M=P(Math.max(f.min,Math.min(f.max,0)));i.push(`<line class="chart-axis" x1="${Te(k.x)}" y1="${Te(M)}" x2="${Te(k.x+k.w)}" y2="${Te(M)}" stroke="var(--d-stroke)" stroke-width="1.5"/>`);let T=k.w/r.labels.length;if(r.labels.forEach((C,F)=>{i.push(`<text class="chart-cat" x="${Te(k.x+(F+.5)*T)}" y="${Te(k.y+k.h+20)}" text-anchor="middle" font-size="12" ${zn}>${$t(C)}</text>`)}),r.type==="bar"){let C=fl(r.series,r.labels.length,k,f);r.series.forEach((F,ye)=>{l.push(Kr(F,ye)),C[ye].forEach(ge=>{ge&&l.push(`<rect class="chart-bar draw-fade" x="${Te(ge.x)}" y="${Te(ge.y)}" width="${Te(ge.w)}" height="${Te(ge.h)}" rx="2" fill="${Fn(ye)}" stroke="var(--d-stroke)" stroke-width="1.5"/>`)}),l.push("</g>")})}else r.series.forEach((C,F)=>{let ye=C.data.map((J,de)=>J==null?null:{x:k.x+(de+.5)*T,y:P(J)}),ge=gl(ye),be='stroke-linejoin="round" stroke-linecap="round"';if(l.push(Kr(C,F)),r.type==="area"&&l.push(`<path class="chart-area draw-fade" d="${bl(ye,M)}" fill="${Fn(F)}" fill-opacity="0.35"/>`),l.push(`<g class="chart-casing"><path d="${ge}" fill="none" stroke="var(--d-stroke)" stroke-width="4.5" ${be}/></g>`),l.push(`<path class="chart-line" d="${ge}" fill="none" stroke="${Fn(F)}" stroke-width="2.5" ${be}/>`),r.type==="line")for(let J of ye)J&&l.push(`<circle class="chart-dot draw-fade" cx="${Te(J.x)}" cy="${Te(J.y)}" r="4" fill="${Fn(F)}" stroke="var(--d-stroke)" stroke-width="1"/>`);l.push("</g>")})}function xl(r,i){let l=r.title?40:16,d=r.width/2,u=l+(r.height-l-12)/2,m=Math.max(24,Math.min((r.height-l-12)/2-26,r.width/2-110)),f=yl(r.series[0].data.map(h=>h??0),d,u,m,r.donut?m*.55:0);i.push(Kr(r.series[0],0)),f.forEach((h,b)=>{h.d&&(i.push(`<path class="chart-slice draw-fade" d="${h.d}" fill="${Fn(b)}" fill-rule="evenodd" stroke="var(--d-stroke)" stroke-width="1.5" stroke-linejoin="round"/>`),i.push(`<text class="chart-cat draw-fade" x="${Te(h.outX)}" y="${Te(h.outY+4)}" text-anchor="${h.anchor}" font-size="12" ${zn}>${$t(r.labels[b])}</text>`),h.frac>=.05&&i.push(`<text class="chart-value draw-fade" x="${Te(h.labelX)}" y="${Te(h.labelY+4)}" text-anchor="middle" font-size="12" font-weight="600" ${zn}>${Math.round(h.frac*100)}%</text>`))}),i.push("</g>")}function so(r){return r.legend===!0?!0:r.legend===!1?!1:r.type!=="pie"&&r.series.length>1}function vl(r){let i=[],l=[];if(r.title&&i.push(`<text class="chart-title" x="14" y="24" font-size="15" font-weight="600" ${zn}>${$t(r.title)}</text>`),so(r)){let u=r.series.map(f=>({name:f.name,w:f.name.length*6.6+24})),m=r.width-14-u.reduce((f,h)=>f+h.w,0);r.series.forEach((f,h)=>{i.push(`<rect class="chart-swatch" x="${Te(m)}" y="14" width="11" height="11" rx="2" fill="${Fn(h)}" stroke="var(--d-stroke)" stroke-width="1"/>`),i.push(`<text class="chart-legend" x="${Te(m+16)}" y="24" font-size="12" ${zn}>${$t(f.name)}</text>`),m+=u[h].w})}r.type==="pie"?xl(r,l):wl(r,i,l);let d=r.title?`${r.title} \u2014 ${r.type} chart`:`${r.type} chart`;return`<svg class="chart-svg" viewBox="0 0 ${r.width} ${r.height}" role="img" aria-label="${$t(d)}" preserveAspectRatio="xMidYMid meet"><g class="chart-chrome" data-build-stay>${i.join("")}</g>`+l.join("")+"</svg>"}function oo(r){r.querySelectorAll("[data-chart]").forEach(i=>{if(i.querySelector(":scope > svg.chart-svg, :scope > .chart-broken"))return;i.classList.add("chart");let l=i.querySelector('script[type="application/json"]');try{let d=pl(l?l.textContent:null,{type:i.getAttribute("data-chart")||void 0,title:i.getAttribute("data-title")||void 0,aspect:i.getAttribute("data-aspect")||void 0}),u=document.createElement("template");u.innerHTML=vl(d);let m=u.content.firstElementChild;i.hasAttribute("data-build")?(m.setAttribute("data-build",i.getAttribute("data-build")),i.removeAttribute("data-build")):d.build!=null&&d.build!==!1&&m.setAttribute("data-build",d.build===!0?"":String(d.build)),i.getAttribute("data-chart")||i.setAttribute("data-chart",d.donut?"donut":d.type),i.insertBefore(m,l)}catch(d){let u=document.createElement("div");u.className="chart-broken",u.textContent=`chart: ${d.message||d}`,i.insertBefore(u,l)}})}le();ce();le();ce();function fr(r,i){let l=String(r??"").trim(),d=parseFloat(l);return!Number.isFinite(d)||d<=0?i:l.endsWith("ms")?d:l.endsWith("s")?d*1e3:d}var er=["opacity","color","backgroundColor","borderRadius","fontSize"],io=(r=er)=>["transform",...r.map(i=>i.replace(/[A-Z]/g,l=>`-${l.toLowerCase()}`))];function ao(r,i,l,d=!1){let u=l?.x||1,m=l?.y||1,f=(r.rect.left-i.rect.left)/u,h=(r.rect.top-i.rect.top)/m,b=d||!i.rect.width?1:r.rect.width/i.rect.width,k=d||!i.rect.height?1:r.rect.height/i.rect.height;return{dx:f,dy:h,sx:b,sy:k}}function lo({dx:r,dy:i,sx:l,sy:d}){return!r&&!i&&l===1&&d===1?"":`translate(${r}px, ${i}px) scale(${l}, ${d})`}var co=(r,i)=>r||i||"fade";function uo(r,i){if(r==="none")return null;let l=`dir-${i}`;return{entering:["entering",`tr-${r}`,l],leaving:["leaving",`tr-${r}`,l,"active-out"]}}var kl=io();function po(r){let i=getComputedStyle(r),l={rect:r.getBoundingClientRect()};for(let d of er)l[d]=i[d];return l}function El(r,i){if(r.ownerSVGElement){let l=r.getScreenCTM?.();if(l&&l.a&&l.d)return{x:l.a,y:l.d}}return{x:i,y:i}}function ho(r,i,l){let d=fr(getComputedStyle(i).getPropertyValue("--auto-animate-duration"),500),u=new Map;r.querySelectorAll("[data-id]").forEach(h=>{u.set(h.getAttribute("data-id"),po(h))});let m=[];i.querySelectorAll("[data-id]").forEach(h=>{let b=u.get(h.getAttribute("data-id"));b&&m.push({el:h,o:b})});for(let{el:h,o:b}of m){let k=po(h),A=El(h,l),P=h.children.length===0&&b.fontSize!==k.fontSize,M=ao(b,k,A,P),T=h.getAttribute("style")??"";h.style.transition="none",h.ownerSVGElement&&(h.style.transformBox="fill-box"),h.style.transformOrigin="0 0",h.style.transform=lo(M);for(let F of er)h.style[F]=b[F];h.offsetWidth,h.style.transition=kl.map(F=>`${F} ${d}ms ease`).join(", "),h.style.transform="";for(let F of er)h.style[F]=k[F];let C=()=>{T?h.setAttribute("style",T):h.removeAttribute("style"),h.removeEventListener("transitionend",C)};h.addEventListener("transitionend",C),setTimeout(C,d+80)}let f=new Set(m.map(h=>h.el));return[...i.children].forEach(h=>{h.matches("aside.notes")||f.has(h)||[...f].some(k=>h.contains(k))||(h.classList.add("aa-fresh"),requestAnimationFrame(()=>requestAnimationFrame(()=>h.classList.add("aa-in"))),setTimeout(()=>h.classList.remove("aa-fresh","aa-in"),d+120))}),d}le();ce();le();ce();var mo=function(){"use strict";class r{constructor(t,n){let a,c=" "+t,p=n&&n.loc;if(p&&p.start<=p.end){let x=p.lexer.input;a=p.start;let q=p.end;a===x.length?c+=" at end of input: ":c+=" at position "+(a+1)+`:
5
- `;let j=x.slice(a,q).replace(/[^]/g,"$&\u0332"),ie,he;ie=a>15?"\u2026"+x.slice(a-15,a):x.slice(0,a),he=q+15<x.length?x.slice(q,q+15)+"\u2026":x.slice(q),c+=ie+j+he}let g=new Error(c);return g.name="ParseError",g.__proto__=r.prototype,g.position=a,g}}r.prototype.__proto__=Error.prototype;let i=function(e,t){return e===void 0?t:e},l=/([A-Z])/g,d=function(e){return e.replace(l,"-$1").toLowerCase()},u={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},m=/[&><"']/g;function f(e){return String(e).replace(m,t=>u[t])}let h=function(e){return e.type==="ordgroup"||e.type==="color"?e.body.length===1?h(e.body[0]):e:e.type==="font"?h(e.body):e},b=function(e){let t=h(e);return t.type==="mathord"||t.type==="textord"||t.type==="atom"},k=function(e){return+e.toFixed(4)},A="aceg\u0131\u0237mnopqrsuvwxyz\u03B1\u03B3\u03B5\u03B7\u03B9\u03BA\u03BC\u03BD\u03BF\u03C0\u03C1\u03C2\u03C3\u03C4\u03C5\u03C7\u03C9\u03D5\u{1D41A}\u{1D41C}\u{1D41E}\u{1D420}\u{1D426}\u{1D427}\u{1D428}\u{1D429}\u{1D42A}\u{1D42B}\u{1D42C}\u{1D42E}\u{1D42F}\u{1D430}\u{1D431}\u{1D432}\u{1D433}";class P{constructor(t){t=t||{},this.displayMode=i(t.displayMode,!1),this.annotate=i(t.annotate,!1),this.leqno=i(t.leqno,!1),this.throwOnError=i(t.throwOnError,!1),this.errorColor=i(t.errorColor,"#b22222"),this.macros=t.macros||{},this.wrap=i(t.wrap,"none"),this.xml=i(t.xml,!1),this.colorIsTextColor=i(t.colorIsTextColor,!1),this.strict=i(t.strict,!1),this.trust=i(t.trust,!1),this.maxSize=t.maxSize===void 0?[1/0,1/0]:Array.isArray(t.maxSize)?t.maxSize:[1/0,1/0],this.maxExpand=Math.max(0,i(t.maxExpand,1e3)),this.wrapDelimiterPairs=!0}isTrusted(t){if(t.url&&!t.protocol){let a=function(c){let p=/^[\x00-\x20]*([^\\/#?]*?)(:|&#0*58|&#x0*3a|&colon)/i.exec(c);return p?p[2]!==":"?null:/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(p[1])?p[1].toLowerCase():null:"_relative"}(t.url);if(a==null)return!1;t.protocol=a}return!!(typeof this.trust=="function"?this.trust(t):this.trust)}}let M={},T={};function C({type:e,names:t,props:n,handler:a,mathmlBuilder:c}){let p={type:e,numArgs:n.numArgs,argTypes:n.argTypes,allowedInArgument:!!n.allowedInArgument,allowedInText:!!n.allowedInText,allowedInMath:n.allowedInMath===void 0||n.allowedInMath,numOptionalArgs:n.numOptionalArgs||0,infix:!!n.infix,primitive:!!n.primitive,handler:a};for(let g=0;g<t.length;++g)M[t[g]]=p;e&&c&&(T[e]=c)}function F({type:e,mathmlBuilder:t}){C({type:e,names:[],props:{numArgs:0},handler(){throw new Error("Should never be called.")},mathmlBuilder:t})}let ye=function(e){return e.type==="ordgroup"&&e.body.length===1?e.body[0]:e},ge=function(e){return e.type==="ordgroup"?e.body:[e]};class be{constructor(t){this.children=t,this.classes=[],this.style={}}hasClass(t){return this.classes.includes(t)}toNode(){let t=document.createDocumentFragment();for(let n=0;n<this.children.length;n++)t.appendChild(this.children[n].toNode());return t}toMarkup(){let t="";for(let n=0;n<this.children.length;n++)t+=this.children[n].toMarkup();return t}toText(){return this.children.map(t=>t.toText()).join("")}}let J=function(e){return e.filter(t=>t).join(" ")},de=function(e,t){this.classes=e||[],this.attributes={},this.style=t||{}},Oe=function(e){let t=document.createElement(e);t.className=J(this.classes);for(let n in this.style)Object.prototype.hasOwnProperty.call(this.style,n)&&(t.style[n]=this.style[n]);for(let n in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,n)&&t.setAttribute(n,this.attributes[n]);for(let n=0;n<this.children.length;n++)t.appendChild(this.children[n].toNode());return t},ke=function(e){let t=`<${e}`;this.classes.length&&(t+=` class="${f(J(this.classes))}"`);let n="";for(let a in this.style)Object.prototype.hasOwnProperty.call(this.style,a)&&(n+=`${d(a)}:${this.style[a]};`);n&&(t+=` style="${n}"`);for(let a in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,a)&&(t+=` ${a}="${f(this.attributes[a])}"`);t+=">";for(let a=0;a<this.children.length;a++)t+=this.children[a].toMarkup();return t+=`</${e}>`,t};class De{constructor(t,n,a){de.call(this,t,a),this.children=n||[]}setAttribute(t,n){this.attributes[t]=n}toNode(){return Oe.call(this,"span")}toMarkup(){return ke.call(this,"span")}}let xe=class{constructor(e){this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return f(this.text)}};class Le{constructor(t,n,a){this.href=t,this.classes=n,this.children=a||[]}toNode(){let t=document.createElement("a");t.setAttribute("href",this.href),this.classes.length>0&&(t.className=J(this.classes));for(let n=0;n<this.children.length;n++)t.appendChild(this.children[n].toNode());return t}toMarkup(){let t=`<a href='${f(this.href)}'`;this.classes.length>0&&(t+=` class="${f(J(this.classes))}"`),t+=">";for(let n=0;n<this.children.length;n++)t+=this.children[n].toMarkup();return t+="</a>",t}}class st{constructor(t,n,a){this.alt=n,this.src=t,this.classes=["mord"],this.style=a}hasClass(t){return this.classes.includes(t)}toNode(){let t=document.createElement("img");t.src=this.src,t.alt=this.alt,t.className="mord";for(let n in this.style)Object.prototype.hasOwnProperty.call(this.style,n)&&(t.style[n]=this.style[n]);return t}toMarkup(){let t=`<img src='${this.src}' alt='${this.alt}'`,n="";for(let a in this.style)Object.prototype.hasOwnProperty.call(this.style,a)&&(n+=`${d(a)}:${this.style[a]};`);return n&&(t+=` style="${f(n)}"`),t+=">",t}}function at(e){return new be(e)}class _{constructor(t,n,a,c){this.type=t,this.attributes={},this.children=n||[],this.classes=a||[],this.style=c||{},this.label=""}setAttribute(t,n){this.attributes[t]=n}getAttribute(t){return this.attributes[t]}setLabel(t){this.label=t}toNode(){let t=document.createElementNS("http://www.w3.org/1998/Math/MathML",this.type);for(let n in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,n)&&t.setAttribute(n,this.attributes[n]);this.classes.length>0&&(t.className=J(this.classes));for(let n in this.style)Object.prototype.hasOwnProperty.call(this.style,n)&&(t.style[n]=this.style[n]);for(let n=0;n<this.children.length;n++)t.appendChild(this.children[n].toNode());return t}toMarkup(){let t="<"+this.type;for(let a in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,a)&&(t+=" "+a+'="',t+=f(this.attributes[a]),t+='"');this.classes.length>0&&(t+=` class="${f(J(this.classes))}"`);let n="";for(let a in this.style)Object.prototype.hasOwnProperty.call(this.style,a)&&(n+=`${d(a)}:${this.style[a]};`);n&&(t+=` style="${n}"`),t+=">";for(let a=0;a<this.children.length;a++)t+=this.children[a].toMarkup();return t+="</"+this.type+">",t}toText(){return this.children.map(t=>t.toText()).join("")}}class qe{constructor(t){this.text=t}toNode(){return document.createTextNode(this.text)}toMarkup(){return f(this.toText())}toText(){return this.text}}let Je=e=>{let t;return e.length===1&&e[0].type==="mrow"?(t=e.pop(),t.type="mstyle"):t=new _("mstyle",e),t},je=e=>{let t=0;if(e.body&&Array.isArray(e.body))for(let n of e.body)t+=je(n);else if(e.body)t+=je(e.body);else if(e.type==="supsub")t+=je(e.base),e.sub&&(t+=.7*je(e.sub)),e.sup&&(t+=.7*je(e.sup));else if(e.type==="mathord"||e.type==="textord")for(let n of e.text.split("")){let a=n.codePointAt(0);t+=96<a&&a<123||944<a&&a<970?.56:47<a&&a<58?.5:.92}else t+=1;return t},O={widehat:"^",widecheck:"\u02C7",widetilde:"~",wideparen:"\u23DC",utilde:"~",overleftarrow:"\u2190",underleftarrow:"\u2190",xleftarrow:"\u2190",overrightarrow:"\u2192",underrightarrow:"\u2192",xrightarrow:"\u2192",underbrace:"\u23DF",overbrace:"\u23DE",overbracket:"\u23B4",underbracket:"\u23B5",overgroup:"\u23E0",overparen:"\u23DC",undergroup:"\u23E1",underparen:"\u23DD",overleftrightarrow:"\u2194",underleftrightarrow:"\u2194",xleftrightarrow:"\u2194",Overrightarrow:"\u21D2",xRightarrow:"\u21D2",overleftharpoon:"\u21BC",xleftharpoonup:"\u21BC",overrightharpoon:"\u21C0",xrightharpoonup:"\u21C0",xLeftarrow:"\u21D0",xLeftrightarrow:"\u21D4",xhookleftarrow:"\u21A9",xhookrightarrow:"\u21AA",xmapsto:"\u21A6",xrightharpoondown:"\u21C1",xleftharpoondown:"\u21BD",xtwoheadleftarrow:"\u219E",xtwoheadrightarrow:"\u21A0",xlongequal:"=",xrightleftarrows:"\u21C4",xtofrom:"\u21C4",xleftrightharpoons:"\u21CB",xrightleftharpoons:"\u21CC",yields:"\u2192",yieldsLeft:"\u2190",mesomerism:"\u2194",longrightharpoonup:"\u21C0",longleftharpoondown:"\u21BD",eqrightharpoonup:"\u21C0",eqleftharpoondown:"\u21BD","\\cdrightarrow":"\u2192","\\cdleftarrow":"\u2190","\\cdlongequal":"=",yieldsLeftRight:"\u21C4",chemequilibrium:"\u21CC"},D=function(e){let t=new qe(O[e.slice(1)]),n=new _("mo",[t]);return n.setAttribute("stretchy","true"),n},V=["\\widetilde","\\widehat","\\widecheck","\\utilde"],re=e=>{let t=D(e.label);if(V.includes(e.label)){let n=je(e.base);1<n&&n<1.6?t.classes.push("tml-crooked-2"):1.6<=n&&n<2.5?t.classes.push("tml-crooked-3"):2.5<=n&&t.classes.push("tml-crooked-4")}return t},Ae={bin:1,close:1,inner:1,open:1,punct:1,rel:1},Ke={"accent-token":1,mathord:1,"op-token":1,spacing:1,textord:1},Ce={math:{},text:{}};function s(e,t,n,a,c){Ce[e][a]={group:t,replace:n},c&&n&&(Ce[e][n]=Ce[e][a])}let o="math",N="text",Fe="accent-token",B="bin",ot="close",mt="inner",K="mathord",_e="op-token",Y="open",Re="punct",y="rel",Be="spacing",w="textord";s(o,y,"\u2261","\\equiv",!0),s(o,y,"\u227A","\\prec",!0),s(o,y,"\u227B","\\succ",!0),s(o,y,"\u223C","\\sim",!0),s(o,y,"\u27C2","\\perp",!0),s(o,y,"\u2AAF","\\preceq",!0),s(o,y,"\u2AB0","\\succeq",!0),s(o,y,"\u2243","\\simeq",!0),s(o,y,"\u224C","\\backcong",!0),s(o,y,"|","\\mid",!0),s(o,y,"\u226A","\\ll",!0),s(o,y,"\u226B","\\gg",!0),s(o,y,"\u224D","\\asymp",!0),s(o,y,"\u2225","\\parallel"),s(o,y,"\u2323","\\smile",!0),s(o,y,"\u2291","\\sqsubseteq",!0),s(o,y,"\u2292","\\sqsupseteq",!0),s(o,y,"\u2250","\\doteq",!0),s(o,y,"\u2322","\\frown",!0),s(o,y,"\u220B","\\ni",!0),s(o,y,"\u220C","\\notni",!0),s(o,y,"\u221D","\\propto",!0),s(o,y,"\u22A2","\\vdash",!0),s(o,y,"\u22A3","\\dashv",!0),s(o,y,"\u220B","\\owns"),s(o,y,"\u2258","\\arceq",!0),s(o,y,"\u2259","\\wedgeq",!0),s(o,y,"\u225A","\\veeeq",!0),s(o,y,"\u225B","\\stareq",!0),s(o,y,"\u225D","\\eqdef",!0),s(o,y,"\u225E","\\measeq",!0),s(o,y,"\u225F","\\questeq",!0),s(o,y,"\u2260","\\ne",!0),s(o,y,"\u2260","\\neq"),s(o,y,"\u2A75","\\eqeq",!0),s(o,y,"\u2A76","\\eqeqeq",!0),s(o,y,"\u2237","\\dblcolon",!0),s(o,y,"\u2254","\\coloneqq",!0),s(o,y,"\u2255","\\eqqcolon",!0),s(o,y,"\u2239","\\eqcolon",!0),s(o,y,"\u2A74","\\Coloneqq",!0),s(o,Re,".","\\ldotp"),s(o,Re,"\xB7","\\cdotp"),s(o,w,"#","\\#"),s(N,w,"#","\\#"),s(o,w,"&","\\&"),s(N,w,"&","\\&"),s(o,w,"\u2135","\\aleph",!0),s(o,w,"\u2200","\\forall",!0),s(o,w,"\u210F","\\hbar",!0),s(o,w,"\u2203","\\exists",!0),s(o,Y,"\u2207","\\nabla",!0),s(o,w,"\u266D","\\flat",!0),s(o,w,"\u2113","\\ell",!0),s(o,w,"\u266E","\\natural",!0),s(o,w,"\u212B","\\Angstrom",!0),s(N,w,"\u212B","\\Angstrom",!0),s(o,w,"\u2663","\\clubsuit",!0),s(o,w,"\u2667","\\varclubsuit",!0),s(o,w,"\u2118","\\wp",!0),s(o,w,"\u266F","\\sharp",!0),s(o,w,"\u2662","\\diamondsuit",!0),s(o,w,"\u2666","\\vardiamondsuit",!0),s(o,w,"\u211C","\\Re",!0),s(o,w,"\u2661","\\heartsuit",!0),s(o,w,"\u2665","\\varheartsuit",!0),s(o,w,"\u2111","\\Im",!0),s(o,w,"\u2660","\\spadesuit",!0),s(o,w,"\u2664","\\varspadesuit",!0),s(o,w,"\u2640","\\female",!0),s(o,w,"\u2642","\\male",!0),s(o,w,"\xA7","\\S",!0),s(N,w,"\xA7","\\S"),s(o,w,"\xB6","\\P",!0),s(N,w,"\xB6","\\P"),s(N,w,"\u263A","\\smiley",!0),s(o,w,"\u263A","\\smiley",!0),s(o,w,"\u2020","\\dag"),s(N,w,"\u2020","\\dag"),s(N,w,"\u2020","\\textdagger"),s(o,w,"\u2021","\\ddag"),s(N,w,"\u2021","\\ddag"),s(N,w,"\u2021","\\textdaggerdbl"),s(o,ot,"\u23B1","\\rmoustache",!0),s(o,Y,"\u23B0","\\lmoustache",!0),s(o,ot,"\u27EF","\\rgroup",!0),s(o,Y,"\u27EE","\\lgroup",!0),s(o,B,"\u2213","\\mp",!0),s(o,B,"\u2296","\\ominus",!0),s(o,B,"\u228E","\\uplus",!0),s(o,B,"\u2293","\\sqcap",!0),s(o,B,"\u2217","\\ast"),s(o,B,"\u2294","\\sqcup",!0),s(o,B,"\u25EF","\\bigcirc",!0),s(o,B,"\u2219","\\bullet",!0),s(o,B,"\u2021","\\ddagger"),s(o,B,"\u2240","\\wr",!0),s(o,B,"\u2A3F","\\amalg"),s(o,B,"&","\\And"),s(o,B,"\u2AFD","\\sslash",!0),s(o,y,"\u27F5","\\longleftarrow",!0),s(o,y,"\u21D0","\\Leftarrow",!0),s(o,y,"\u27F8","\\Longleftarrow",!0),s(o,y,"\u27F6","\\longrightarrow",!0),s(o,y,"\u21D2","\\Rightarrow",!0),s(o,y,"\u27F9","\\Longrightarrow",!0),s(o,y,"\u2194","\\leftrightarrow",!0),s(o,y,"\u27F7","\\longleftrightarrow",!0),s(o,y,"\u21D4","\\Leftrightarrow",!0),s(o,y,"\u27FA","\\Longleftrightarrow",!0),s(o,y,"\u21A4","\\mapsfrom",!0),s(o,y,"\u21A6","\\mapsto",!0),s(o,y,"\u27FC","\\longmapsto",!0),s(o,y,"\u2197","\\nearrow",!0),s(o,y,"\u21A9","\\hookleftarrow",!0),s(o,y,"\u21AA","\\hookrightarrow",!0),s(o,y,"\u2198","\\searrow",!0),s(o,y,"\u21BC","\\leftharpoonup",!0),s(o,y,"\u21C0","\\rightharpoonup",!0),s(o,y,"\u2199","\\swarrow",!0),s(o,y,"\u21BD","\\leftharpoondown",!0),s(o,y,"\u21C1","\\rightharpoondown",!0),s(o,y,"\u2196","\\nwarrow",!0),s(o,y,"\u21CC","\\rightleftharpoons",!0),s(o,K,"\u21AF","\\lightning",!0),s(o,K,"\u220E","\\QED",!0),s(o,K,"\u2030","\\permil",!0),s(N,w,"\u2030","\\permil"),s(o,K,"\u2609","\\astrosun",!0),s(o,K,"\u263C","\\sun",!0),s(o,K,"\u263E","\\leftmoon",!0),s(o,K,"\u263D","\\rightmoon",!0),s(o,K,"\u2295","\\Earth"),s(o,y,"\u226E","\\nless",!0),s(o,y,"\u2A87","\\lneq",!0),s(o,y,"\u2268","\\lneqq",!0),s(o,y,"\u2268\uFE00","\\lvertneqq"),s(o,y,"\u22E6","\\lnsim",!0),s(o,y,"\u2A89","\\lnapprox",!0),s(o,y,"\u2280","\\nprec",!0),s(o,y,"\u22E0","\\npreceq",!0),s(o,y,"\u22E8","\\precnsim",!0),s(o,y,"\u2AB9","\\precnapprox",!0),s(o,y,"\u2241","\\nsim",!0),s(o,y,"\u2224","\\nmid",!0),s(o,y,"\u2224","\\nshortmid"),s(o,y,"\u22AC","\\nvdash",!0),s(o,y,"\u22AD","\\nvDash",!0),s(o,y,"\u22EA","\\ntriangleleft"),s(o,y,"\u22EC","\\ntrianglelefteq",!0),s(o,y,"\u2284","\\nsubset",!0),s(o,y,"\u2285","\\nsupset",!0),s(o,y,"\u228A","\\subsetneq",!0),s(o,y,"\u228A\uFE00","\\varsubsetneq"),s(o,y,"\u2ACB","\\subsetneqq",!0),s(o,y,"\u2ACB\uFE00","\\varsubsetneqq"),s(o,y,"\u226F","\\ngtr",!0),s(o,y,"\u2A88","\\gneq",!0),s(o,y,"\u2269","\\gneqq",!0),s(o,y,"\u2269\uFE00","\\gvertneqq"),s(o,y,"\u22E7","\\gnsim",!0),s(o,y,"\u2A8A","\\gnapprox",!0),s(o,y,"\u2281","\\nsucc",!0),s(o,y,"\u22E1","\\nsucceq",!0),s(o,y,"\u22E9","\\succnsim",!0),s(o,y,"\u2ABA","\\succnapprox",!0),s(o,y,"\u2246","\\ncong",!0),s(o,y,"\u2226","\\nparallel",!0),s(o,y,"\u2226","\\nshortparallel"),s(o,y,"\u22AF","\\nVDash",!0),s(o,y,"\u22EB","\\ntriangleright"),s(o,y,"\u22ED","\\ntrianglerighteq",!0),s(o,y,"\u228B","\\supsetneq",!0),s(o,y,"\u228B","\\varsupsetneq"),s(o,y,"\u2ACC","\\supsetneqq",!0),s(o,y,"\u2ACC\uFE00","\\varsupsetneqq"),s(o,y,"\u22AE","\\nVdash",!0),s(o,y,"\u2AB5","\\precneqq",!0),s(o,y,"\u2AB6","\\succneqq",!0),s(o,B,"\u22B4","\\unlhd"),s(o,B,"\u22B5","\\unrhd"),s(o,y,"\u219A","\\nleftarrow",!0),s(o,y,"\u219B","\\nrightarrow",!0),s(o,y,"\u21CD","\\nLeftarrow",!0),s(o,y,"\u21CF","\\nRightarrow",!0),s(o,y,"\u21AE","\\nleftrightarrow",!0),s(o,y,"\u21CE","\\nLeftrightarrow",!0),s(o,y,"\u25B3","\\vartriangle"),s(o,w,"\u210F","\\hslash"),s(o,w,"\u25BD","\\triangledown"),s(o,w,"\u25CA","\\lozenge"),s(o,w,"\u24C8","\\circledS"),s(o,w,"\xAE","\\circledR",!0),s(N,w,"\xAE","\\circledR"),s(N,w,"\xAE","\\textregistered"),s(o,w,"\u2221","\\measuredangle",!0),s(o,w,"\u2204","\\nexists"),s(o,w,"\u2127","\\mho"),s(o,w,"\u2132","\\Finv",!0),s(o,w,"\u2141","\\Game",!0),s(o,w,"\u2035","\\backprime"),s(o,w,"\u2036","\\backdprime"),s(o,w,"\u2037","\\backtrprime"),s(o,w,"\u25B2","\\blacktriangle"),s(o,w,"\u25BC","\\blacktriangledown"),s(o,w,"\u25A0","\\blacksquare"),s(o,w,"\u29EB","\\blacklozenge"),s(o,w,"\u2605","\\bigstar"),s(o,w,"\u2222","\\sphericalangle",!0),s(o,w,"\u2201","\\complement",!0),s(o,w,"\u2571","\\diagup"),s(o,w,"\u2572","\\diagdown"),s(o,w,"\u25A1","\\square"),s(o,w,"\u25A1","\\Box"),s(o,w,"\u25CA","\\Diamond"),s(o,w,"\xA5","\\yen",!0),s(N,w,"\xA5","\\yen",!0),s(o,w,"\u2713","\\checkmark",!0),s(N,w,"\u2713","\\checkmark"),s(o,w,"\u2717","\\ballotx",!0),s(N,w,"\u2717","\\ballotx"),s(N,w,"\u2022","\\textbullet"),s(o,w,"\u2136","\\beth",!0),s(o,w,"\u2138","\\daleth",!0),s(o,w,"\u2137","\\gimel",!0),s(o,w,"\u03DD","\\digamma",!0),s(o,w,"\u03F0","\\varkappa"),s(o,Y,"\u231C","\\ulcorner",!0),s(o,ot,"\u231D","\\urcorner",!0),s(o,Y,"\u231E","\\llcorner",!0),s(o,ot,"\u231F","\\lrcorner",!0),s(o,y,"\u2266","\\leqq",!0),s(o,y,"\u2A7D","\\leqslant",!0),s(o,y,"\u2A95","\\eqslantless",!0),s(o,y,"\u2272","\\lesssim",!0),s(o,y,"\u2A85","\\lessapprox",!0),s(o,y,"\u224A","\\approxeq",!0),s(o,B,"\u22D6","\\lessdot"),s(o,y,"\u22D8","\\lll",!0),s(o,y,"\u2276","\\lessgtr",!0),s(o,y,"\u22DA","\\lesseqgtr",!0),s(o,y,"\u2A8B","\\lesseqqgtr",!0),s(o,y,"\u2251","\\doteqdot"),s(o,y,"\u2253","\\risingdotseq",!0),s(o,y,"\u2252","\\fallingdotseq",!0),s(o,y,"\u223D","\\backsim",!0),s(o,y,"\u22CD","\\backsimeq",!0),s(o,y,"\u2AC5","\\subseteqq",!0),s(o,y,"\u22D0","\\Subset",!0),s(o,y,"\u228F","\\sqsubset",!0),s(o,y,"\u227C","\\preccurlyeq",!0),s(o,y,"\u22DE","\\curlyeqprec",!0),s(o,y,"\u227E","\\precsim",!0),s(o,y,"\u2AB7","\\precapprox",!0),s(o,y,"\u22B2","\\vartriangleleft"),s(o,y,"\u22B4","\\trianglelefteq"),s(o,y,"\u22A8","\\vDash",!0),s(o,y,"\u22AB","\\VDash",!0),s(o,y,"\u22AA","\\Vvdash",!0),s(o,y,"\u2323","\\smallsmile"),s(o,y,"\u2322","\\smallfrown"),s(o,y,"\u224F","\\bumpeq",!0),s(o,y,"\u224E","\\Bumpeq",!0),s(o,y,"\u2267","\\geqq",!0),s(o,y,"\u2A7E","\\geqslant",!0),s(o,y,"\u2A96","\\eqslantgtr",!0),s(o,y,"\u2273","\\gtrsim",!0),s(o,y,"\u2A86","\\gtrapprox",!0),s(o,B,"\u22D7","\\gtrdot"),s(o,y,"\u22D9","\\ggg",!0),s(o,y,"\u2277","\\gtrless",!0),s(o,y,"\u22DB","\\gtreqless",!0),s(o,y,"\u2A8C","\\gtreqqless",!0),s(o,y,"\u2256","\\eqcirc",!0),s(o,y,"\u2257","\\circeq",!0),s(o,y,"\u225C","\\triangleq",!0),s(o,y,"\u223C","\\thicksim"),s(o,y,"\u2248","\\thickapprox"),s(o,y,"\u2AC6","\\supseteqq",!0),s(o,y,"\u22D1","\\Supset",!0),s(o,y,"\u2290","\\sqsupset",!0),s(o,y,"\u227D","\\succcurlyeq",!0),s(o,y,"\u22DF","\\curlyeqsucc",!0),s(o,y,"\u227F","\\succsim",!0),s(o,y,"\u2AB8","\\succapprox",!0),s(o,y,"\u22B3","\\vartriangleright"),s(o,y,"\u22B5","\\trianglerighteq"),s(o,y,"\u22A9","\\Vdash",!0),s(o,y,"\u2223","\\shortmid"),s(o,y,"\u2225","\\shortparallel"),s(o,y,"\u226C","\\between",!0),s(o,y,"\u22D4","\\pitchfork",!0),s(o,y,"\u221D","\\varpropto"),s(o,y,"\u25C0","\\blacktriangleleft"),s(o,y,"\u2234","\\therefore",!0),s(o,y,"\u220D","\\backepsilon"),s(o,y,"\u25B6","\\blacktriangleright"),s(o,y,"\u2235","\\because",!0),s(o,y,"\u22D8","\\llless"),s(o,y,"\u22D9","\\gggtr"),s(o,B,"\u22B2","\\lhd"),s(o,B,"\u22B3","\\rhd"),s(o,y,"\u2242","\\eqsim",!0),s(o,y,"\u2251","\\Doteq",!0),s(o,y,"\u297D","\\strictif",!0),s(o,y,"\u297C","\\strictfi",!0),s(o,B,"\u2214","\\dotplus",!0),s(o,B,"\u2216","\\smallsetminus"),s(o,B,"\u22D2","\\Cap",!0),s(o,B,"\u22D3","\\Cup",!0),s(o,B,"\u2A5E","\\doublebarwedge",!0),s(o,B,"\u229F","\\boxminus",!0),s(o,B,"\u229E","\\boxplus",!0),s(o,B,"\u29C4","\\boxslash",!0),s(o,B,"\u22C7","\\divideontimes",!0),s(o,B,"\u22C9","\\ltimes",!0),s(o,B,"\u22CA","\\rtimes",!0),s(o,B,"\u22CB","\\leftthreetimes",!0),s(o,B,"\u22CC","\\rightthreetimes",!0),s(o,B,"\u22CF","\\curlywedge",!0),s(o,B,"\u22CE","\\curlyvee",!0),s(o,B,"\u229D","\\circleddash",!0),s(o,B,"\u229B","\\circledast",!0),s(o,B,"\u22BA","\\intercal",!0),s(o,B,"\u22D2","\\doublecap"),s(o,B,"\u22D3","\\doublecup"),s(o,B,"\u22A0","\\boxtimes",!0),s(o,B,"\u22C8","\\bowtie",!0),s(o,B,"\u22C8","\\Join"),s(o,B,"\u27D5","\\leftouterjoin",!0),s(o,B,"\u27D6","\\rightouterjoin",!0),s(o,B,"\u27D7","\\fullouterjoin",!0),s(o,B,"\u2238","\\dotminus",!0),s(o,B,"\u27D1","\\wedgedot",!0),s(o,B,"\u27C7","\\veedot",!0),s(o,B,"\u2A62","\\doublebarvee",!0),s(o,B,"\u2A63","\\veedoublebar",!0),s(o,B,"\u2A5F","\\wedgebar",!0),s(o,B,"\u2A60","\\wedgedoublebar",!0),s(o,B,"\u2A54","\\Vee",!0),s(o,B,"\u2A53","\\Wedge",!0),s(o,B,"\u2A43","\\barcap",!0),s(o,B,"\u2A42","\\barcup",!0),s(o,B,"\u2A48","\\capbarcup",!0),s(o,B,"\u2A40","\\capdot",!0),s(o,B,"\u2A47","\\capovercup",!0),s(o,B,"\u2A46","\\cupovercap",!0),s(o,B,"\u2A4D","\\closedvarcap",!0),s(o,B,"\u2A4C","\\closedvarcup",!0),s(o,B,"\u2A2A","\\minusdot",!0),s(o,B,"\u2A2B","\\minusfdots",!0),s(o,B,"\u2A2C","\\minusrdots",!0),s(o,B,"\u22BB","\\Xor",!0),s(o,B,"\u22BC","\\Nand",!0),s(o,B,"\u22BD","\\Nor",!0),s(o,B,"\u22BD","\\barvee"),s(o,B,"\u2AF4","\\interleave",!0),s(o,B,"\u29E2","\\shuffle",!0),s(o,B,"\u2AF6","\\threedotcolon",!0),s(o,B,"\u2982","\\typecolon",!0),s(o,B,"\u223E","\\invlazys",!0),s(o,B,"\u2A4B","\\twocaps",!0),s(o,B,"\u2A4A","\\twocups",!0),s(o,B,"\u2A4E","\\Sqcap",!0),s(o,B,"\u2A4F","\\Sqcup",!0),s(o,B,"\u2A56","\\veeonvee",!0),s(o,B,"\u2A55","\\wedgeonwedge",!0),s(o,B,"\u29D7","\\blackhourglass",!0),s(o,B,"\u29C6","\\boxast",!0),s(o,B,"\u29C8","\\boxbox",!0),s(o,B,"\u29C7","\\boxcircle",!0),s(o,B,"\u229C","\\circledequal",!0),s(o,B,"\u29B7","\\circledparallel",!0),s(o,B,"\u29B6","\\circledvert",!0),s(o,B,"\u29B5","\\circlehbar",!0),s(o,B,"\u27E1","\\concavediamond",!0),s(o,B,"\u27E2","\\concavediamondtickleft",!0),s(o,B,"\u27E3","\\concavediamondtickright",!0),s(o,B,"\u22C4","\\diamond",!0),s(o,B,"\u29D6","\\hourglass",!0),s(o,B,"\u27E0","\\lozengeminus",!0),s(o,B,"\u233D","\\obar",!0),s(o,B,"\u29B8","\\obslash",!0),s(o,B,"\u2A38","\\odiv",!0),s(o,B,"\u29C1","\\ogreaterthan",!0),s(o,B,"\u29C0","\\olessthan",!0),s(o,B,"\u29B9","\\operp",!0),s(o,B,"\u2A37","\\Otimes",!0),s(o,B,"\u2A36","\\otimeshat",!0),s(o,B,"\u22C6","\\star",!0),s(o,B,"\u25B3","\\triangle",!0),s(o,B,"\u2A3A","\\triangleminus",!0),s(o,B,"\u2A39","\\triangleplus",!0),s(o,B,"\u2A3B","\\triangletimes",!0),s(o,B,"\u27E4","\\whitesquaretickleft",!0),s(o,B,"\u27E5","\\whitesquaretickright",!0),s(o,B,"\u2A33","\\smashtimes",!0),s(o,y,"\u21E2","\\dashrightarrow",!0),s(o,y,"\u21E0","\\dashleftarrow",!0),s(o,y,"\u21C7","\\leftleftarrows",!0),s(o,y,"\u21C6","\\leftrightarrows",!0),s(o,y,"\u21DA","\\Lleftarrow",!0),s(o,y,"\u219E","\\twoheadleftarrow",!0),s(o,y,"\u21A2","\\leftarrowtail",!0),s(o,y,"\u21AB","\\looparrowleft",!0),s(o,y,"\u21CB","\\leftrightharpoons",!0),s(o,y,"\u21B6","\\curvearrowleft",!0),s(o,y,"\u21BA","\\circlearrowleft",!0),s(o,y,"\u21B0","\\Lsh",!0),s(o,y,"\u21C8","\\upuparrows",!0),s(o,y,"\u21BF","\\upharpoonleft",!0),s(o,y,"\u21C3","\\downharpoonleft",!0),s(o,y,"\u22B6","\\origof",!0),s(o,y,"\u22B7","\\imageof",!0),s(o,y,"\u22B8","\\multimap",!0),s(o,y,"\u21AD","\\leftrightsquigarrow",!0),s(o,y,"\u21C9","\\rightrightarrows",!0),s(o,y,"\u21C4","\\rightleftarrows",!0),s(o,y,"\u21A0","\\twoheadrightarrow",!0),s(o,y,"\u21A3","\\rightarrowtail",!0),s(o,y,"\u21AC","\\looparrowright",!0),s(o,y,"\u21B7","\\curvearrowright",!0),s(o,y,"\u21BB","\\circlearrowright",!0),s(o,y,"\u21B1","\\Rsh",!0),s(o,y,"\u21CA","\\downdownarrows",!0),s(o,y,"\u21BE","\\upharpoonright",!0),s(o,y,"\u21C2","\\downharpoonright",!0),s(o,y,"\u21DD","\\rightsquigarrow",!0),s(o,y,"\u21DD","\\leadsto"),s(o,y,"\u21DB","\\Rrightarrow",!0),s(o,y,"\u21BE","\\restriction"),s(o,w,"\u2018","`"),s(o,w,"$","\\$"),s(N,w,"$","\\$"),s(N,w,"$","\\textdollar"),s(o,w,"\xA2","\\cent"),s(N,w,"\xA2","\\cent"),s(o,w,"%","\\%"),s(N,w,"%","\\%"),s(o,w,"_","\\_"),s(N,w,"_","\\_"),s(N,w,"_","\\textunderscore"),s(N,w,"\u2423","\\textvisiblespace",!0),s(o,w,"\u2220","\\angle",!0),s(o,w,"\u221E","\\infty",!0),s(o,w,"\u2032","\\prime"),s(o,w,"\u2033","\\dprime"),s(o,w,"\u2034","\\trprime"),s(o,w,"\u2057","\\qprime"),s(o,w,"\u25B3","\\triangle"),s(N,w,"\u0391","\\Alpha",!0),s(N,w,"\u0392","\\Beta",!0),s(N,w,"\u0393","\\Gamma",!0),s(N,w,"\u0394","\\Delta",!0),s(N,w,"\u0395","\\Epsilon",!0),s(N,w,"\u0396","\\Zeta",!0),s(N,w,"\u0397","\\Eta",!0),s(N,w,"\u0398","\\Theta",!0),s(N,w,"\u0399","\\Iota",!0),s(N,w,"\u039A","\\Kappa",!0),s(N,w,"\u039B","\\Lambda",!0),s(N,w,"\u039C","\\Mu",!0),s(N,w,"\u039D","\\Nu",!0),s(N,w,"\u039E","\\Xi",!0),s(N,w,"\u039F","\\Omicron",!0),s(N,w,"\u03A0","\\Pi",!0),s(N,w,"\u03A1","\\Rho",!0),s(N,w,"\u03A3","\\Sigma",!0),s(N,w,"\u03A4","\\Tau",!0),s(N,w,"\u03A5","\\Upsilon",!0),s(N,w,"\u03A6","\\Phi",!0),s(N,w,"\u03A7","\\Chi",!0),s(N,w,"\u03A8","\\Psi",!0),s(N,w,"\u03A9","\\Omega",!0),s(o,K,"\u0391","\\Alpha",!0),s(o,K,"\u0392","\\Beta",!0),s(o,K,"\u0393","\\Gamma",!0),s(o,K,"\u0394","\\Delta",!0),s(o,K,"\u0395","\\Epsilon",!0),s(o,K,"\u0396","\\Zeta",!0),s(o,K,"\u0397","\\Eta",!0),s(o,K,"\u0398","\\Theta",!0),s(o,K,"\u0399","\\Iota",!0),s(o,K,"\u039A","\\Kappa",!0),s(o,K,"\u039B","\\Lambda",!0),s(o,K,"\u039C","\\Mu",!0),s(o,K,"\u039D","\\Nu",!0),s(o,K,"\u039E","\\Xi",!0),s(o,K,"\u039F","\\Omicron",!0),s(o,K,"\u03A0","\\Pi",!0),s(o,K,"\u03A1","\\Rho",!0),s(o,K,"\u03A3","\\Sigma",!0),s(o,K,"\u03A4","\\Tau",!0),s(o,K,"\u03A5","\\Upsilon",!0),s(o,K,"\u03A6","\\Phi",!0),s(o,K,"\u03A7","\\Chi",!0),s(o,K,"\u03A8","\\Psi",!0),s(o,K,"\u03A9","\\Omega",!0),s(o,Y,"\xAC","\\neg",!0),s(o,Y,"\xAC","\\lnot"),s(o,w,"\u22A4","\\top"),s(o,w,"\u22A5","\\bot"),s(o,w,"\u2205","\\emptyset"),s(o,w,"\u2300","\\varnothing"),s(o,K,"\u03B1","\\alpha",!0),s(o,K,"\u03B2","\\beta",!0),s(o,K,"\u03B3","\\gamma",!0),s(o,K,"\u03B4","\\delta",!0),s(o,K,"\u03F5","\\epsilon",!0),s(o,K,"\u03B6","\\zeta",!0),s(o,K,"\u03B7","\\eta",!0),s(o,K,"\u03B8","\\theta",!0),s(o,K,"\u03B9","\\iota",!0),s(o,K,"\u03BA","\\kappa",!0),s(o,K,"\u03BB","\\lambda",!0),s(o,K,"\u03BC","\\mu",!0),s(o,K,"\u03BD","\\nu",!0),s(o,K,"\u03BE","\\xi",!0),s(o,K,"\u03BF","\\omicron",!0),s(o,K,"\u03C0","\\pi",!0),s(o,K,"\u03C1","\\rho",!0),s(o,K,"\u03C3","\\sigma",!0),s(o,K,"\u03C4","\\tau",!0),s(o,K,"\u03C5","\\upsilon",!0),s(o,K,"\u03D5","\\phi",!0),s(o,K,"\u03C7","\\chi",!0),s(o,K,"\u03C8","\\psi",!0),s(o,K,"\u03C9","\\omega",!0),s(o,K,"\u03B5","\\varepsilon",!0),s(o,K,"\u03D1","\\vartheta",!0),s(o,K,"\u03D6","\\varpi",!0),s(o,K,"\u03F1","\\varrho",!0),s(o,K,"\u03C2","\\varsigma",!0),s(o,K,"\u03C6","\\varphi",!0),s(o,K,"\u03D8","\\Coppa",!0),s(o,K,"\u03D9","\\coppa",!0),s(o,K,"\u03D9","\\varcoppa",!0),s(o,K,"\u03DE","\\Koppa",!0),s(o,K,"\u03DF","\\koppa",!0),s(o,K,"\u03E0","\\Sampi",!0),s(o,K,"\u03E1","\\sampi",!0),s(o,K,"\u03DA","\\Stigma",!0),s(o,K,"\u03DB","\\stigma",!0),s(o,K,"\u2AEB","\\Bot"),s(o,w,"\xF0","\\eth",!0),s(N,w,"\xF0","\xF0"),s(o,w,"\xC5","\\AA"),s(N,w,"\xC5","\\AA",!0),s(o,w,"\xC6","\\AE",!0),s(N,w,"\xC6","\\AE",!0),s(o,w,"\xD0","\\DH",!0),s(N,w,"\xD0","\\DH",!0),s(o,w,"\xDE","\\TH",!0),s(N,w,"\xDE","\\TH",!0),s(o,w,"\xDF","\\ss",!0),s(N,w,"\xDF","\\ss",!0),s(o,w,"\xE5","\\aa"),s(N,w,"\xE5","\\aa",!0),s(o,w,"\xE6","\\ae",!0),s(N,w,"\xE6","\\ae",!0),s(o,w,"\xF0","\\dh"),s(N,w,"\xF0","\\dh",!0),s(o,w,"\xFE","\\th",!0),s(N,w,"\xFE","\\th",!0),s(o,w,"\u0110","\\DJ",!0),s(N,w,"\u0110","\\DJ",!0),s(o,w,"\u0111","\\dj",!0),s(N,w,"\u0111","\\dj",!0),s(o,w,"\u0141","\\L",!0),s(N,w,"\u0141","\\L",!0),s(o,w,"\u0141","\\l",!0),s(N,w,"\u0141","\\l",!0),s(o,w,"\u014A","\\NG",!0),s(N,w,"\u014A","\\NG",!0),s(o,w,"\u014B","\\ng",!0),s(N,w,"\u014B","\\ng",!0),s(o,w,"\u0152","\\OE",!0),s(N,w,"\u0152","\\OE",!0),s(o,w,"\u0153","\\oe",!0),s(N,w,"\u0153","\\oe",!0),s(o,B,"\u2217","\u2217",!0),s(o,B,"+","+"),s(o,B,"\u2217","*"),s(o,B,"\u2044","/",!0),s(o,B,"\u2044","\u2044"),s(o,B,"\u2212","-",!0),s(o,B,"\u22C5","\\cdot",!0),s(o,B,"\u2218","\\circ",!0),s(o,B,"\xF7","\\div",!0),s(o,B,"\xB1","\\pm",!0),s(o,B,"\xD7","\\times",!0),s(o,B,"\u2229","\\cap",!0),s(o,B,"\u222A","\\cup",!0),s(o,B,"\u2216","\\setminus",!0),s(o,B,"\u2227","\\land"),s(o,B,"\u2228","\\lor"),s(o,B,"\u2227","\\wedge",!0),s(o,B,"\u2228","\\vee",!0),s(o,Y,"\u27E6","\\llbracket",!0),s(o,ot,"\u27E7","\\rrbracket",!0),s(o,Y,"\u27E8","\\langle",!0),s(o,Y,"\u27EA","\\lAngle",!0),s(o,Y,"\u2989","\\llangle",!0),s(o,Y,"|","\\lvert"),s(o,Y,"\u2016","\\lVert",!0),s(o,w,"!","\\oc"),s(o,w,"?","\\wn"),s(o,w,"\u2193","\\shpos"),s(o,w,"\u2195","\\shift"),s(o,w,"\u2191","\\shneg"),s(o,ot,"?","?"),s(o,ot,"!","!"),s(o,ot,"\u203C","\u203C"),s(o,ot,"\u27E9","\\rangle",!0),s(o,ot,"\u27EB","\\rAngle",!0),s(o,ot,"\u298A","\\rrangle",!0),s(o,ot,"|","\\rvert"),s(o,ot,"\u2016","\\rVert"),s(o,Y,"\u2983","\\lBrace",!0),s(o,ot,"\u2984","\\rBrace",!0),s(o,y,"=","\\equal",!0),s(o,y,":",":"),s(o,y,"\u2248","\\approx",!0),s(o,y,"\u2245","\\cong",!0),s(o,y,"\u2265","\\ge"),s(o,y,"\u2265","\\geq",!0),s(o,y,"\u2190","\\gets"),s(o,y,">","\\gt",!0),s(o,y,"\u2208","\\in",!0),s(o,y,"\u2209","\\notin",!0),s(o,y,"\uE020","\\@not"),s(o,y,"\u2282","\\subset",!0),s(o,y,"\u2283","\\supset",!0),s(o,y,"\u2286","\\subseteq",!0),s(o,y,"\u2287","\\supseteq",!0),s(o,y,"\u2288","\\nsubseteq",!0),s(o,y,"\u2288","\\nsubseteqq"),s(o,y,"\u2289","\\nsupseteq",!0),s(o,y,"\u2289","\\nsupseteqq"),s(o,y,"\u22A8","\\models"),s(o,y,"\u2190","\\leftarrow",!0),s(o,y,"\u2264","\\le"),s(o,y,"\u2264","\\leq",!0),s(o,y,"<","\\lt",!0),s(o,y,"\u2192","\\rightarrow",!0),s(o,y,"\u2192","\\to"),s(o,y,"\u2271","\\ngeq",!0),s(o,y,"\u2271","\\ngeqq"),s(o,y,"\u2271","\\ngeqslant"),s(o,y,"\u2270","\\nleq",!0),s(o,y,"\u2270","\\nleqq"),s(o,y,"\u2270","\\nleqslant"),s(o,y,"\u2AEB","\\Perp",!0),s(o,Be,"\xA0","\\ "),s(o,Be,"\xA0","\\space"),s(o,Be,"\xA0","\\nobreakspace"),s(N,Be,"\xA0","\\ "),s(N,Be,"\xA0"," "),s(N,Be,"\xA0","\\space"),s(N,Be,"\xA0","\\nobreakspace"),s(o,Be,null,"\\nobreak"),s(o,Be,null,"\\allowbreak"),s(o,Re,",",","),s(N,Re,":",":"),s(o,Re,";",";"),s(o,B,"\u22BC","\\barwedge"),s(o,B,"\u22BB","\\veebar"),s(o,B,"\u2299","\\odot",!0),s(o,B,"\u2295\uFE0E","\\oplus"),s(o,B,"\u2297","\\otimes",!0),s(o,w,"\u2202","\\partial",!0),s(o,B,"\u2298","\\oslash",!0),s(o,B,"\u229A","\\circledcirc",!0),s(o,B,"\u22A1","\\boxdot",!0),s(o,B,"\u25B3","\\bigtriangleup"),s(o,B,"\u25BD","\\bigtriangledown"),s(o,B,"\u2020","\\dagger"),s(o,B,"\u22C4","\\diamond"),s(o,B,"\u25C3","\\triangleleft"),s(o,B,"\u25B9","\\triangleright"),s(o,Y,"{","\\{"),s(N,w,"{","\\{"),s(N,w,"{","\\textbraceleft"),s(o,ot,"}","\\}"),s(N,w,"}","\\}"),s(N,w,"}","\\textbraceright"),s(o,Y,"{","\\lbrace"),s(o,ot,"}","\\rbrace"),s(o,Y,"[","\\lbrack",!0),s(N,w,"[","\\lbrack",!0),s(o,ot,"]","\\rbrack",!0),s(N,w,"]","\\rbrack",!0),s(o,Y,"(","\\lparen",!0),s(o,ot,")","\\rparen",!0),s(o,Y,"\u2987","\\llparenthesis",!0),s(o,ot,"\u2988","\\rrparenthesis",!0),s(N,w,"<","\\textless",!0),s(N,w,">","\\textgreater",!0),s(o,Y,"\u230A","\\lfloor",!0),s(o,ot,"\u230B","\\rfloor",!0),s(o,Y,"\u2308","\\lceil",!0),s(o,ot,"\u2309","\\rceil",!0),s(o,w,"\\","\\backslash"),s(o,w,"|","|"),s(o,w,"|","\\vert"),s(N,w,"|","\\textbar",!0),s(o,w,"\u2016","\\|"),s(o,w,"\u2016","\\Vert"),s(N,w,"\u2016","\\textbardbl"),s(N,w,"~","\\textasciitilde"),s(N,w,"\\","\\textbackslash"),s(N,w,"^","\\textasciicircum"),s(o,y,"\u2191","\\uparrow",!0),s(o,y,"\u21D1","\\Uparrow",!0),s(o,y,"\u2193","\\downarrow",!0),s(o,y,"\u21D3","\\Downarrow",!0),s(o,y,"\u2195","\\updownarrow",!0),s(o,y,"\u21D5","\\Updownarrow",!0),s(o,_e,"\u2210","\\coprod"),s(o,_e,"\u22C1","\\bigvee"),s(o,_e,"\u22C0","\\bigwedge"),s(o,_e,"\u2A04","\\biguplus"),s(o,_e,"\u2A04","\\bigcupplus"),s(o,_e,"\u2A03","\\bigcupdot"),s(o,_e,"\u2A07","\\bigdoublevee"),s(o,_e,"\u2A08","\\bigdoublewedge"),s(o,_e,"\u22C2","\\bigcap"),s(o,_e,"\u22C3","\\bigcup"),s(o,_e,"\u222B","\\int"),s(o,_e,"\u222B","\\intop"),s(o,_e,"\u222C","\\iint"),s(o,_e,"\u222D","\\iiint"),s(o,_e,"\u220F","\\prod"),s(o,_e,"\u2211","\\sum"),s(o,_e,"\u2A02","\\bigotimes"),s(o,_e,"\u2A01","\\bigoplus"),s(o,_e,"\u2A00","\\bigodot"),s(o,_e,"\u2A09","\\bigtimes"),s(o,_e,"\u222E","\\oint"),s(o,_e,"\u222F","\\oiint"),s(o,_e,"\u2230","\\oiiint"),s(o,_e,"\u2231","\\intclockwise"),s(o,_e,"\u2232","\\varointclockwise"),s(o,_e,"\u2A0C","\\iiiint"),s(o,_e,"\u2A0D","\\intbar"),s(o,_e,"\u2A0E","\\intBar"),s(o,_e,"\u2A0F","\\fint"),s(o,_e,"\u2A12","\\rppolint"),s(o,_e,"\u2A13","\\scpolint"),s(o,_e,"\u2A15","\\pointint"),s(o,_e,"\u2A16","\\sqint"),s(o,_e,"\u2A17","\\intlarhk"),s(o,_e,"\u2A18","\\intx"),s(o,_e,"\u2A19","\\intcap"),s(o,_e,"\u2A1A","\\intcup"),s(o,_e,"\u2A05","\\bigsqcap"),s(o,_e,"\u2A06","\\bigsqcup"),s(o,_e,"\u222B","\\smallint"),s(N,mt,"\u2026","\\textellipsis"),s(o,mt,"\u2026","\\mathellipsis"),s(N,mt,"\u2026","\\ldots",!0),s(o,mt,"\u2026","\\ldots",!0),s(o,mt,"\u22F0","\\iddots",!0),s(o,mt,"\u22EF","\\@cdots",!0),s(o,mt,"\u22F1","\\ddots",!0),s(o,w,"\u22EE","\\varvdots"),s(N,w,"\u22EE","\\varvdots"),s(o,Fe,"\xB4","\\acute"),s(o,Fe,"`","\\grave"),s(o,Fe,"\xA8","\\ddot"),s(o,Fe,"\u2026","\\dddot"),s(o,Fe,"\u2026.","\\ddddot"),s(o,Fe,"~","\\tilde"),s(o,Fe,"\u203E","\\bar"),s(o,Fe,"\u02D8","\\breve"),s(o,Fe,"\u02C7","\\check"),s(o,Fe,"^","\\hat"),s(o,Fe,"\u2192","\\vec"),s(o,Fe,"\u02D9","\\dot"),s(o,Fe,"\u02DA","\\mathring"),s(o,K,"\u0131","\\imath",!0),s(o,K,"\u0237","\\jmath",!0),s(o,w,"\u0131","\u0131"),s(o,w,"\u0237","\u0237"),s(N,w,"\u0131","\\i",!0),s(N,w,"\u0237","\\j",!0),s(N,w,"\xF8","\\o",!0),s(o,K,"\xF8","\\o",!0),s(N,w,"\xD8","\\O",!0),s(o,K,"\xD8","\\O",!0),s(N,Fe,"\u02CA","\\'"),s(N,Fe,"\u02CB","\\`"),s(N,Fe,"\u02C6","\\^"),s(N,Fe,"~","\\~"),s(N,Fe,"\u02C9","\\="),s(N,Fe,"\u02D8","\\u"),s(N,Fe,"\u02D9","\\."),s(N,Fe,"\xB8","\\c"),s(N,Fe,"\u02DA","\\r"),s(N,Fe,"\u02C7","\\v"),s(N,Fe,"\xA8",'\\"'),s(N,Fe,"\u02DD","\\H"),s(o,Fe,"\u02CA","\\'"),s(o,Fe,"\u02CB","\\`"),s(o,Fe,"\u02C6","\\^"),s(o,Fe,"~","\\~"),s(o,Fe,"\u02C9","\\="),s(o,Fe,"\u02D8","\\u"),s(o,Fe,"\u02D9","\\."),s(o,Fe,"\xB8","\\c"),s(o,Fe,"\u02DA","\\r"),s(o,Fe,"\u02C7","\\v"),s(o,Fe,"\xA8",'\\"'),s(o,Fe,"\u02DD","\\H");let pe={"--":!0,"---":!0,"``":!0,"''":!0};s(N,w,"\u2013","--",!0),s(N,w,"\u2013","\\textendash"),s(N,w,"\u2014","---",!0),s(N,w,"\u2014","\\textemdash"),s(N,w,"\u2018","`",!0),s(N,w,"\u2018","\\textquoteleft"),s(N,w,"\u2019","'",!0),s(N,w,"\u2019","\\textquoteright"),s(N,w,"\u201C","``",!0),s(N,w,"\u201C","\\textquotedblleft"),s(N,w,"\u201D","''",!0),s(N,w,"\u201D","\\textquotedblright"),s(o,w,"\xB0","\\degree",!0),s(N,w,"\xB0","\\degree"),s(N,w,"\xB0","\\textdegree",!0),s(o,w,"\xA3","\\pounds"),s(o,w,"\xA3","\\mathsterling",!0),s(N,w,"\xA3","\\pounds"),s(N,w,"\xA3","\\textsterling",!0),s(o,w,"\u2720","\\maltese"),s(N,w,"\u2720","\\maltese"),s(o,w,"\u20AC","\\euro",!0),s(N,w,"\u20AC","\\euro",!0),s(N,w,"\u20AC","\\texteuro"),s(o,w,"\xA9","\\copyright",!0),s(N,w,"\xA9","\\textcopyright"),s(o,w,"\u2300","\\diameter",!0),s(N,w,"\u2300","\\diameter"),s(o,w,"\u{1D6E4}","\\varGamma"),s(o,w,"\u{1D6E5}","\\varDelta"),s(o,w,"\u{1D6E9}","\\varTheta"),s(o,w,"\u{1D6EC}","\\varLambda"),s(o,w,"\u{1D6EF}","\\varXi"),s(o,w,"\u{1D6F1}","\\varPi"),s(o,w,"\u{1D6F4}","\\varSigma"),s(o,w,"\u{1D6F6}","\\varUpsilon"),s(o,w,"\u{1D6F7}","\\varPhi"),s(o,w,"\u{1D6F9}","\\varPsi"),s(o,w,"\u{1D6FA}","\\varOmega"),s(N,w,"\u{1D6E4}","\\varGamma"),s(N,w,"\u{1D6E5}","\\varDelta"),s(N,w,"\u{1D6E9}","\\varTheta"),s(N,w,"\u{1D6EC}","\\varLambda"),s(N,w,"\u{1D6EF}","\\varXi"),s(N,w,"\u{1D6F1}","\\varPi"),s(N,w,"\u{1D6F4}","\\varSigma"),s(N,w,"\u{1D6F6}","\\varUpsilon"),s(N,w,"\u{1D6F7}","\\varPhi"),s(N,w,"\u{1D6F9}","\\varPsi"),s(N,w,"\u{1D6FA}","\\varOmega");let Se='0123456789/@."';for(let e=0;e<14;e++){let t=Se.charAt(e);s(o,w,t,t)}let it='0123456789!@*()-=+";:?/.,';for(let e=0;e<25;e++){let t=it.charAt(e);s(N,w,t,t)}let Ee="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";for(let e=0;e<52;e++){let t=Ee.charAt(e);s(o,K,t,t),s(N,w,t,t)}let ze="\xC7\xD0\xDE\xE7\xFE\u2102\u210D\u2115\u2119\u211A\u211D\u2124\u210E\u210F\u210A\u210B\u210C\u2110\u2111\u2112\u2113\u2118\u211B\u211C\u212C\u2130\u2131\u2133\u212D\u2128";for(let e=0;e<30;e++){let t=ze.charAt(e);s(o,K,t,t),s(N,w,t,t)}let oe="";for(let e=0;e<52;e++){oe=String.fromCharCode(55349,56320+e),s(o,K,oe,oe),s(N,w,oe,oe),oe=String.fromCharCode(55349,56372+e),s(o,K,oe,oe),s(N,w,oe,oe),oe=String.fromCharCode(55349,56424+e),s(o,K,oe,oe),s(N,w,oe,oe),oe=String.fromCharCode(55349,56580+e),s(o,K,oe,oe),s(N,w,oe,oe),oe=String.fromCharCode(55349,56736+e),s(o,K,oe,oe),s(N,w,oe,oe),oe=String.fromCharCode(55349,56788+e),s(o,K,oe,oe),s(N,w,oe,oe),oe=String.fromCharCode(55349,56840+e),s(o,K,oe,oe),s(N,w,oe,oe),oe=String.fromCharCode(55349,56944+e),s(o,K,oe,oe),s(N,w,oe,oe),oe=String.fromCharCode(55349,56632+e),s(o,K,oe,oe),s(N,w,oe,oe);let t=Ee.charAt(e);oe=String.fromCharCode(55349,56476+e),s(o,K,t,oe),s(N,w,t,oe)}for(let e=0;e<10;e++)oe=String.fromCharCode(55349,57294+e),s(o,K,oe,oe),s(N,w,oe,oe),oe=String.fromCharCode(55349,57314+e),s(o,K,oe,oe),s(N,w,oe,oe),oe=String.fromCharCode(55349,57324+e),s(o,K,oe,oe),s(N,w,oe,oe),oe=String.fromCharCode(55349,57334+e),s(o,K,oe,oe),s(N,w,oe,oe);let Xe=function(e,t,n){return!Ce[t][e]||!Ce[t][e].replace||e.charCodeAt(0)===55349||Object.prototype.hasOwnProperty.call(pe,e)&&n&&(n.fontFamily&&n.fontFamily.slice(4,6)==="tt"||n.font&&n.font.slice(4,6)==="tt")||(e=Ce[t][e].replace),new qe(e)},gt=(e,t)=>{if(e.children.length===0||e.children[e.children.length-1].type!=="mtext"){let n=new _("mtext",[new qe(t.children[0].text)]);e.children.push(n)}else e.children[e.children.length-1].children[0].text+=t.children[0].text},Et=e=>{if(e.type!=="mrow"&&e.type!=="mstyle"||e.children.length===0)return e;let t=new _("mrow");for(let n=0;n<e.children.length;n++){let a=e.children[n];if(a.type==="mtext"&&Object.keys(a.attributes).length===0)gt(t,a);else if(a.type==="mrow"){let c=!0;for(let p=0;p<a.children.length;p++)if(a.children[p].type!=="mtext"||Object.keys(a.attributes).length!==0){c=!1;break}if(c)for(let p=0;p<a.children.length;p++){let g=a.children[p];gt(t,g)}else t.children.push(a)}else t.children.push(a)}for(let n=0;n<t.children.length;n++)if(t.children[n].type==="mtext"){let a=t.children[n];a.children[0].text.charAt(0)===" "&&(a.children[0].text="\xA0"+a.children[0].text.slice(1));let c=a.children[0].text.length;c>0&&a.children[0].text.charAt(c-1)===" "&&(a.children[0].text=a.children[0].text.slice(0,-1)+"\xA0");for(let[p,g]of Object.entries(e.attributes))a.attributes[p]=g}return t.children.length===1&&t.children[0].type==="mtext"?t.children[0]:t},me=function(e,t=!1){if(!(e.length!==1||e[0]instanceof be))return e[0];if(!t){e[0]instanceof _&&e[0].type==="mo"&&!e[0].attributes.fence&&(e[0].attributes.lspace="0em",e[0].attributes.rspace="0em");let n=e.length-1;e[n]instanceof _&&e[n].type==="mo"&&!e[n].attributes.fence&&(e[n].attributes.lspace="0em",e[n].attributes.rspace="0em")}return new _("mrow",e)};function Ne(e){if(!e)return!1;if(e.type==="mi"&&e.children.length===1){let t=e.children[0];return t instanceof qe&&t.text==="."}if(e.type==="mtext"&&e.children.length===1){let t=e.children[0];return t instanceof qe&&t.text==="\u2008"}if(e.type==="mo"&&e.children.length===1&&e.getAttribute("separator")==="true"&&e.getAttribute("lspace")==="0em"&&e.getAttribute("rspace")==="0em"){let t=e.children[0];return t instanceof qe&&t.text===","}return!1}let Ie=(e,t)=>{let n=e[t],a=e[t+1];return n.type==="atom"&&n.text===","&&n.loc&&a.loc&&n.loc.end===a.loc.start},et=e=>e.type==="atom"&&e.family==="rel"||e.type==="mclass"&&e.mclass==="mrel",tt=function(e,t,n=!1){if(!n&&e.length===1){let g=He(e[0],t);return g instanceof _&&g.type==="mo"&&(g.setAttribute("lspace","0em"),g.setAttribute("rspace","0em")),[g]}let a=[],c=[],p;for(let g=0;g<e.length;g++)c.push(He(e[g],t));for(let g=0;g<c.length;g++){let x=c[g];if(g<e.length-1&&et(e[g])&&et(e[g+1])&&x.setAttribute("rspace","0em"),g>0&&et(e[g])&&et(e[g-1])&&x.setAttribute("lspace","0em"),x.type==="mn"&&p&&p.type==="mn")p.children.push(...x.children);else if(Ne(x)&&p&&p.type==="mn")p.children.push(...x.children);else if(p&&p.type==="mn"&&g<c.length-1&&c[g+1].type==="mn"&&Ie(e,g))p.children.push(...x.children);else{if(x.type==="mn"&&Ne(p))x.children=[...p.children,...x.children],a.pop();else if((x.type==="msup"||x.type==="msub")&&x.children.length>=1&&p&&(p.type==="mn"||Ne(p))){let q=x.children[0];q instanceof _&&q.type==="mn"&&p&&(q.children=[...p.children,...q.children],a.pop())}a.push(x),p=x}}return a},bt=function(e,t,n=!1){return me(tt(e,t,n),n)},He=function(e,t){if(!e)return new _("mrow");if(T[e.type])return T[e.type](e,t);throw new r("Got group of unknown type: '"+e.type+"'")},ft=e=>new _("mtd",[],[],{padding:"0",width:"50%"}),Dt=["mrow","mtd","mtable","mtr"],Kt=e=>{for(let t of e.children)if(t.type&&Dt.includes(t.type)){if(t.classes&&t.classes[0]==="tml-label")return t.label;{let n=Kt(t);if(n)return n}}else if(!t.type){let n=Kt(t);if(n)return n}};function Vt(e,t,n,a){let c=null;e.length===1&&e[0].type==="tag"&&(c=e[0].tag,e=e[0].body);let p=tt(e,n);if(p.length===1&&p[0]instanceof Le)return p[0];let g=a.displayMode||a.annotate?"none":a.wrap,x=p.length===0?null:p[0],q=p.length===1&&c===null&&x instanceof _?p[0]:function(ie,he,ee){let lt=[],We=[],ct=[],At=0,Ve=0;for(;Ve<ie.length;){for(;ie[Ve]instanceof be;)ie.splice(Ve,1,...ie[Ve].children);let rt=ie[Ve];if(rt.attributes&&rt.attributes.linebreak&&rt.attributes.linebreak==="newline"){ct.length>0&&We.push(new _("mrow",ct)),We.push(rt),ct=[];let en=new _("mtd",We);en.style.textAlign="left",lt.push(new _("mtr",[en])),We=[],Ve+=1;continue}if(ct.push(rt),rt.type&&rt.type==="mo"&&rt.children.length===1&&(!rt.attributes.form||rt.attributes.form!=="prefix")&&!Object.prototype.hasOwnProperty.call(rt.attributes,"movablelimits")){let en=rt.children[0].text;if(he==="="&&en==="="){if(At+=1,At>1){ct.pop();let Ut=new _("mrow",ct);We.push(Ut),ct=[rt]}}else if(he==="tex"){let Ut=Ve<ie.length-1?ie[Ve+1]:null,qn=!0;if(!Ut||Ut.type!=="mtext"||!Ut.attributes.linebreak||Ut.attributes.linebreak!=="nobreak")for(let mn=Ve+1;mn<ie.length;mn++){let kn=ie[mn];if(!kn.type||kn.type!=="mspace"||kn.attributes.linebreak&&kn.attributes.linebreak==="newline")break;ct.push(kn),Ve+=1,kn.attributes&&kn.attributes.linebreak&&kn.attributes.linebreak==="nobreak"&&(qn=!1)}if(qn){let mn=new _("mrow",ct);We.push(mn),ct=[]}}}Ve+=1}if(ct.length>0){let rt=new _("mrow",ct);We.push(rt)}if(lt.length>0){let rt=new _("mtd",We);rt.style.textAlign="left";let en=new _("mtr",[rt]);lt.push(en);let Ut=new _("mtable",lt);return ee||(Ut.setAttribute("columnalign","left"),Ut.setAttribute("rowspacing","0em")),Ut}return at(We)}(p,g,a.displayMode);if(c&&(q=((ie,he,ee,lt)=>{he=bt(he[0].body,ee),(he=Et(he)).classes.push("tml-tag");let We=Kt(ie);ie=new _("mtd",[ie]);let ct=[ft(),ie,ft()];ct[lt?0:2].children.push(he);let At=new _("mtr",ct,["tml-tageqn"]);We&&At.setAttribute("id",We);let Ve=new _("mtable",[At]);return Ve.style.width="100%",Ve.setAttribute("displaystyle","true"),Ve})(q,c,n,a.leqno)),a.annotate){let ie=new _("annotation",[new qe(t)]);ie.setAttribute("encoding","application/x-tex"),q=new _("semantics",[q,ie])}let j=new _("math",[q]);return a.xml&&j.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML"),a.displayMode&&(j.setAttribute("display","block"),j.style.display="block math",j.classes=["tml-display"]),j}let Ot=(e,t)=>{let n=e.isStretchy?re(e):new _("mo",[Xe(e.label,e.mode)]);e.isStretchy||n.setAttribute("stretchy","false"),e.label!=="\\vec"&&(n.style.mathDepth="0");let a=e.label==="\\c"?"munder":"mover",c=Zt.has(e.label);if(a==="mover"&&e.mode==="math"&&!e.isStretchy&&e.base.text&&e.base.text.length===1){let p=e.base.text,g=e.label==="\\vec",x=g==="\\vec"?"-vec":"";g&&n.classes.push("tml-vec");let q=g?"-vec":c?"-acc":"";"DHKLUcegorsuvxyz\u03A0\u03A5\u03A8\u03B1\u03B4\u03B7\u03B9\u03BC\u03BD\u03BF\u03C4\u03C5\u03C7\u03F5".indexOf(p)>-1?(n.classes.push(`chr-sml${x}`),n.classes.push(`wbk-sml${q}`)):"BCEGIMNOPQRSTXZlpqtw\u0393\u0398\u039E\u03A3\u03A6\u03A9\u03B2\u03B5\u03B6\u03B8\u03BE\u03C1\u03C2\u03C6\u03C8\u03D1\u03D5\u03F1".indexOf(p)>-1?(n.classes.push(`chr-med${x}`),n.classes.push(`wbk-med${q}`)):"AFJdf\u0394\u039B".indexOf(p)>-1?(n.classes.push(`chr-lrg${x}`),n.classes.push(`wbk-lrg${q}`)):g?n.classes.push("wbk-vec"):c&&n.classes.push("wbk-acc")}else c&&n.classes.push("wbk-acc");return new _(a,[He(e.base,t),n])},Q=new Set(["\\acute","\\check","\\grave","\\ddot","\\dddot","\\ddddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring"]),Zt=new Set(["\\acute","\\bar","\\breve","\\check","\\dot","\\ddot","\\grave","\\hat","\\mathring","\\`","\\'","\\^","\\=","\\u","\\.",'\\"',"\\r","\\H","\\v"]),_t={"\\`":"\u0300","\\'":"\u0301","\\^":"\u0302","\\~":"\u0303","\\=":"\u0304","\\u":"\u0306","\\.":"\u0307",'\\"':"\u0308","\\r":"\u030A","\\H":"\u030B","\\v":"\u030C","\\c":"\u0327"};C({type:"accent",names:["\\acute","\\grave","\\ddot","\\dddot","\\ddddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring","\\overparen","\\widecheck","\\widehat","\\wideparen","\\widetilde","\\overrightarrow","\\overleftarrow","\\Overrightarrow","\\overleftrightarrow","\\overgroup","\\overleftharpoon","\\overrightharpoon"],props:{numArgs:1},handler:(e,t)=>{let n=ye(t[0]),a=!Q.has(e.funcName);return{type:"accent",mode:e.parser.mode,label:e.funcName,isStretchy:a,base:n}},mathmlBuilder:Ot}),C({type:"accent",names:["\\'","\\`","\\^","\\~","\\=","\\c","\\u","\\.",'\\"',"\\r","\\H","\\v"],props:{numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["primitive"]},handler:(e,t)=>{let n=ye(t[0]),a=e.parser.mode;return a==="math"&&e.parser.settings.strict&&console.log(`Temml parse error: Command ${e.funcName} is invalid in math mode.`),a==="text"&&n.text&&n.text.length===1&&e.funcName in _t&&A.indexOf(n.text)>-1?{type:"textord",mode:"text",text:n.text+_t[e.funcName]}:e.funcName==="\\c"&&a==="text"&&n.text&&n.text.length===1?{type:"textord",mode:"text",text:n.text+"\u0327"}:{type:"accent",mode:a,label:e.funcName,isStretchy:!1,base:n}},mathmlBuilder:Ot}),C({type:"accentUnder",names:["\\underleftarrow","\\underrightarrow","\\underleftrightarrow","\\undergroup","\\underparen","\\utilde"],props:{numArgs:1},handler:({parser:e,funcName:t},n)=>{let a=n[0];return{type:"accentUnder",mode:e.mode,label:t,base:a}},mathmlBuilder:(e,t)=>{let n=re(e);return n.style["math-depth"]=0,new _("munder",[He(e.base,t),n])}});let vt={pt:800/803,pc:9600/803,dd:1238/1157*800/803,cc:12.792133216944668,nd:685/642*800/803,nc:1370/107*800/803,sp:1/65536*800/803,mm:25.4/72,cm:2.54/72,in:1/72,px:96/72},Wt=["em","ex","mu","pt","mm","cm","in","px","bp","pc","dd","cc","nd","nc","sp"],Ht=function(e){return typeof e!="string"&&(e=e.unit),Wt.indexOf(e)>-1},R=e=>[1,.7,.5][Math.max(e-1,0)],W=function(e,t){let n=e.number;if(t.maxSize[0]<0&&n>0)return{number:0,unit:"em"};let a=e.unit;switch(a){case"mm":case"cm":case"in":case"px":return n*vt[a]>t.maxSize[1]?{number:t.maxSize[1],unit:"pt"}:{number:n,unit:a};case"em":case"ex":return a==="ex"&&(n*=.431),n=Math.min(n/R(t.level),t.maxSize[0]),{number:k(n),unit:"em"};case"bp":return n>t.maxSize[1]&&(n=t.maxSize[1]),{number:n,unit:"pt"};case"pt":case"pc":case"dd":case"cc":case"nd":case"nc":case"sp":return n=Math.min(n*vt[a],t.maxSize[1]),{number:k(n),unit:"pt"};case"mu":return n=Math.min(n/18,t.maxSize[0]),{number:k(n),unit:"em"};default:throw new r("Invalid unit: '"+a+"'")}},U=e=>{let t=new _("mspace");return t.setAttribute("width",e+"em"),t},se=(e,t=.3,n=0,a=!1)=>{if(e==null&&n===0)return U(t);let c=e?[e]:[];if(t!==0&&c.unshift(U(t)),n>0&&c.push(U(n)),a){let p=new _("mpadded",c);return p.setAttribute("height","0.1px"),p}return new _("mrow",c)},$e=(e,t)=>Number(e)/R(t),S=(e,t,n,a)=>{let c=D(e),p=e.slice(1,3)==="eq",g=e.charAt(1)==="x"?"1.75":e.slice(2,4)==="cd"?"3.0":p?"1.0":"2.0";c.setAttribute("lspace","0"),c.setAttribute("rspace",p?"0.5em":"0");let x=a.withLevel(a.level<2?2:3),q=$e(g,x.level),j=$e(g,3),ie=se(null,q.toFixed(4),0),he=se(null,j.toFixed(4),0),ee=$e(p?0:.3,x.level).toFixed(4),lt,We,ct=t&&t.body&&(t.body.body||t.body.length>0);if(ct){let rt=He(t,x);rt=se(rt,ee,ee,e==="\\\\cdrightarrow"||e==="\\\\cdleftarrow"),lt=new _("mover",[rt,he])}let At=n&&n.body&&(n.body.body||n.body.length>0);if(At){let rt=He(n,x);rt=se(rt,ee,ee),We=new _("munder",[rt,he])}let Ve;return Ve=ct||At?ct&&At?new _("munderover",[c,We,lt]):ct?new _("mover",[c,lt]):new _("munder",[c,We]):new _("mover",[c,ie]),g==="3.0"&&(Ve.style.height="1em"),Ve.setAttribute("accent","false"),Ve};C({type:"xArrow",names:["\\xleftarrow","\\xrightarrow","\\xLeftarrow","\\xRightarrow","\\xleftrightarrow","\\xLeftrightarrow","\\xhookleftarrow","\\xhookrightarrow","\\xmapsto","\\xrightharpoondown","\\xrightharpoonup","\\xleftharpoondown","\\xleftharpoonup","\\xlongequal","\\xtwoheadrightarrow","\\xtwoheadleftarrow","\\xtofrom","\\xleftrightharpoons","\\xrightleftharpoons","\\yields","\\yieldsLeft","\\mesomerism","\\longrightharpoonup","\\longleftharpoondown","\\yieldsLeftRight","\\chemequilibrium","\\\\cdrightarrow","\\\\cdleftarrow","\\\\cdlongequal"],props:{numArgs:1,numOptionalArgs:1},handler:({parser:e,funcName:t},n,a)=>({type:"xArrow",mode:e.mode,name:t,body:n[0],below:a[0]}),mathmlBuilder(e,t){let n=[S(e.name,e.body,e.below,t)];return n.unshift(U(.2778)),n.push(U(.2778)),new _("mrow",n)}});let L={"\\equilibriumRight":["\\longrightharpoonup","\\eqleftharpoondown"],"\\equilibriumLeft":["\\eqrightharpoonup","\\longleftharpoondown"]};C({type:"stackedArrow",names:["\\equilibriumRight","\\equilibriumLeft"],props:{numArgs:1,numOptionalArgs:1},handler({parser:e,funcName:t},n,a){let c=n[0]?{type:"hphantom",mode:e.mode,body:n[0]}:null,p=a[0]?{type:"hphantom",mode:e.mode,body:a[0]}:null;return{type:"stackedArrow",mode:e.mode,name:t,body:n[0],upperArrowBelow:p,lowerArrowBody:c,below:a[0]}},mathmlBuilder(e,t){let n=L[e.name][0],a=L[e.name][1],c=S(n,e.body,e.upperArrowBelow,t),p=S(a,e.lowerArrowBody,e.below,t),g,x=new _("mpadded",[c]);if(x.setAttribute("voffset","0.3em"),x.setAttribute("height","+0.3em"),x.setAttribute("depth","-0.3em"),e.name==="\\equilibriumLeft"){let q=new _("mpadded",[p]);q.setAttribute("width","0.5em"),g=new _("mpadded",[U(.2778),q,x,U(.2778)])}else x.setAttribute("width",e.name==="\\equilibriumRight"?"0.5em":"0"),g=new _("mpadded",[U(.2778),x,p,U(.2778)]);return g.setAttribute("voffset","-0.18em"),g.setAttribute("height","-0.18em"),g.setAttribute("depth","+0.18em"),g}});let $={};function Z({type:e,names:t,props:n,handler:a,mathmlBuilder:c}){let p={type:e,numArgs:n.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:a};for(let g=0;g<t.length;++g)$[t[g]]=p;c&&(T[e]=c)}function te(e,t){if(!e||e.type!==t)throw new Error(`Expected node of type ${t}, but got `+(e?`node of type ${e.type}`:String(e)));return e}function fe(e){let t=Qe(e);if(!t)throw new Error("Expected node of symbol group type, but got "+(e?`node of type ${e.type}`:String(e)));return t}function Qe(e){return e&&(e.type==="atom"||e.type==="delimiter"||Object.prototype.hasOwnProperty.call(Ke,e.type))?e:null}let Pe={">":"\\\\cdrightarrow","<":"\\\\cdleftarrow","=":"\\\\cdlongequal",A:"\\uparrow",V:"\\downarrow","|":"\\Vert",".":"no arrow"},Ye=()=>({type:"styling",body:[],mode:"math",scriptLevel:"display"}),ut=e=>e.type==="textord"&&e.text==="@",dt=(e,t)=>(e.type==="mathord"||e.type==="atom")&&e.text===t;function pt(e,t,n){let a=Pe[e];switch(a){case"\\\\cdrightarrow":case"\\\\cdleftarrow":return n.callFunction(a,[t[0]],[t[1]]);case"\\uparrow":case"\\downarrow":{let c={type:"atom",text:a,mode:"math",family:"rel"},p={type:"ordgroup",mode:"math",body:[n.callFunction("\\\\cdleft",[t[0]],[]),n.callFunction("\\Big",[c],[]),n.callFunction("\\\\cdright",[t[1]],[])],semisimple:!0};return n.callFunction("\\\\cdparent",[p],[])}case"\\\\cdlongequal":return n.callFunction("\\\\cdlongequal",[],[]);case"\\Vert":{let c={type:"textord",text:"\\Vert",mode:"math"};return n.callFunction("\\Big",[c],[])}default:return{type:"textord",text:" ",mode:"math"}}}C({type:"cdlabel",names:["\\\\cdleft","\\\\cdright"],props:{numArgs:1},handler:({parser:e,funcName:t},n)=>({type:"cdlabel",mode:e.mode,side:t.slice(4),label:n[0]}),mathmlBuilder(e,t){if(e.label.body.length===0)return new _("mrow",t);let n=He(e.label,t);e.side==="left"&&n.classes.push("tml-shift-left");let a=new _("mtd",[n]);a.style.padding="0";let c=new _("mtr",[a]),p=new _("mtable",[c]),g=new _("mpadded",[p]);return g.setAttribute("width","0.1px"),g.setAttribute("displaystyle","false"),g.setAttribute("scriptlevel","1"),g}}),C({type:"cdlabelparent",names:["\\\\cdparent"],props:{numArgs:1},handler:({parser:e},t)=>({type:"cdlabelparent",mode:e.mode,fragment:t[0]}),mathmlBuilder:(e,t)=>new _("mrow",[He(e.fragment,t)])});let xt=e=>({type:"ordgroup",mode:"math",body:e,semisimple:!0}),ht=(e,t)=>({type:t,mode:"math",body:xt(e)});class yt{constructor(t,n,a){this.lexer=t,this.start=n,this.end=a}static range(t,n){return n?t&&t.loc&&n.loc&&t.loc.lexer===n.loc.lexer?new yt(t.loc.lexer,t.loc.start,n.loc.end):null:t&&t.loc}}class qt{constructor(t,n){this.text=t,this.loc=n}range(t,n){return new qt(n,yt.range(this,t))}}let Ft=0,Pt=1,an=2,ln=3,tn={};function I(e,t){tn[e]=t}let Tn=tn;I("\\noexpand",function(e){let t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}}),I("\\expandafter",function(e){let t=e.popToken();return e.expandOnce(!0),{tokens:[t],numArgs:0}}),I("\\@firstoftwo",function(e){return{tokens:e.consumeArgs(2)[0],numArgs:0}}),I("\\@secondoftwo",function(e){return{tokens:e.consumeArgs(2)[1],numArgs:0}}),I("\\@ifnextchar",function(e){let t=e.consumeArgs(3);e.consumeSpaces();let n=e.future();return t[0].length===1&&t[0][0].text===n.text?{tokens:t[1],numArgs:0}:{tokens:t[2],numArgs:0}}),I("\\@ifstar","\\@ifnextchar *{\\@firstoftwo{#1}}"),I("\\TextOrMath",function(e){let t=e.consumeArgs(2);return e.mode==="text"?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}});let nn=e=>{let t="";for(let n=e.length-1;n>-1;n--)t+=e[n].text;return t},Xt={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15},hn=e=>{let t=e.future().text;return t==="EOF"?[null,""]:[Xt[t.charAt(0)],t]},Cn=(e,t,n)=>{for(let a=1;a<t.length;a++)e*=n,e+=Xt[t.charAt(a)];return e};function Qt(e){let t=e.consumeArgs(1)[0],n="",a=t[t.length-1].loc.start;for(let c=t.length-1;c>=0;c--){let p=t[c].loc.start;p>a&&(n+=" ",a=p),n+=t[c].text,a+=t[c].text.length}return n}I("\\char",function(e){let t,n=e.popToken(),a="";if(n.text==="'")t=8,n=e.popToken();else if(n.text==='"')t=16,n=e.popToken();else if(n.text==="`")if(n=e.popToken(),n.text[0]==="\\")a=n.text.charCodeAt(1);else{if(n.text==="EOF")throw new r("\\char` missing argument");a=n.text.charCodeAt(0)}else t=10;if(t){let c,p=n.text;if(a=Xt[p.charAt(0)],a==null||a>=t)throw new r(`Invalid base-${t} digit ${n.text}`);for(a=Cn(a,p,t),[c,p]=hn(e);c!=null&&c<t;)a*=t,a+=c,a=Cn(a,p,t),e.popToken(),[c,p]=hn(e)}return`\\@char{${a}}`}),I("\\surd","\\sqrt{\\vphantom{|}}"),I("\u2295","\\oplus"),I("\\long",""),I("\\bgroup","{"),I("\\egroup","}"),I("~","\\nobreakspace"),I("\\lq","`"),I("\\rq","'"),I("\\aa","\\r a"),I("\\Bbbk","\\Bbb{k}"),I("\\mathstrut","\\vphantom{(}"),I("\\underbar","\\underline{\\text{#1}}"),I("\\vdots","{\\varvdots\\rule{0pt}{15pt}}"),I("\u22EE","\\vdots"),I("\\arraystretch","1"),I("\\arraycolsep","6pt"),I("\\substack","\\begin{subarray}{c}#1\\end{subarray}"),I("\\iff","\\DOTSB\\;\\Longleftrightarrow\\;"),I("\\implies","\\DOTSB\\;\\Longrightarrow\\;"),I("\\impliedby","\\DOTSB\\;\\Longleftarrow\\;");let cn={",":"\\dotsc","\\not":"\\dotsb","+":"\\dotsb","=":"\\dotsb","<":"\\dotsb",">":"\\dotsb","-":"\\dotsb","*":"\\dotsb",":":"\\dotsb","\\DOTSB":"\\dotsb","\\coprod":"\\dotsb","\\bigvee":"\\dotsb","\\bigwedge":"\\dotsb","\\biguplus":"\\dotsb","\\bigcap":"\\dotsb","\\bigcup":"\\dotsb","\\prod":"\\dotsb","\\sum":"\\dotsb","\\bigotimes":"\\dotsb","\\bigoplus":"\\dotsb","\\bigodot":"\\dotsb","\\bigsqcap":"\\dotsb","\\bigsqcup":"\\dotsb","\\bigtimes":"\\dotsb","\\And":"\\dotsb","\\longrightarrow":"\\dotsb","\\Longrightarrow":"\\dotsb","\\longleftarrow":"\\dotsb","\\Longleftarrow":"\\dotsb","\\longleftrightarrow":"\\dotsb","\\Longleftrightarrow":"\\dotsb","\\mapsto":"\\dotsb","\\longmapsto":"\\dotsb","\\hookrightarrow":"\\dotsb","\\doteq":"\\dotsb","\\mathbin":"\\dotsb","\\mathrel":"\\dotsb","\\relbar":"\\dotsb","\\Relbar":"\\dotsb","\\xrightarrow":"\\dotsb","\\xleftarrow":"\\dotsb","\\DOTSI":"\\dotsi","\\int":"\\dotsi","\\oint":"\\dotsi","\\iint":"\\dotsi","\\iiint":"\\dotsi","\\iiiint":"\\dotsi","\\DOTSX":"\\dotsx"};I("\\dots",function(e){let t="\\dotso",n=e.expandAfterFuture().text;return n in cn?t=cn[n]:(n.slice(0,4)==="\\not"||n in Ce.math&&["bin","rel"].includes(Ce.math[n].group))&&(t="\\dotsb"),t});let Rt={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};I("\\dotso",function(e){return e.future().text in Rt?"\\ldots\\,":"\\ldots"}),I("\\dotsc",function(e){let t=e.future().text;return t in Rt&&t!==","?"\\ldots\\,":"\\ldots"}),I("\\cdots",function(e){return e.future().text in Rt?"\\@cdots\\,":"\\@cdots"}),I("\\dotsb","\\cdots"),I("\\dotsm","\\cdots"),I("\\dotsi","\\!\\cdots"),I("\\idotsint","\\int\\!\\cdots\\!\\int"),I("\\dotsx","\\ldots\\,"),I("\\DOTSI","\\relax"),I("\\DOTSB","\\relax"),I("\\DOTSX","\\relax"),I("\\tmspace","\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"),I("\\,","{\\tmspace+{3mu}{.1667em}}"),I("\\thinspace","\\,"),I("\\>","\\mskip{4mu}"),I("\\:","{\\tmspace+{4mu}{.2222em}}"),I("\\medspace","\\:"),I("\\;","{\\tmspace+{5mu}{.2777em}}"),I("\\thickspace","\\;"),I("\\!","{\\tmspace-{3mu}{.1667em}}"),I("\\negthinspace","\\!"),I("\\negmedspace","{\\tmspace-{4mu}{.2222em}}"),I("\\negthickspace","{\\tmspace-{5mu}{.277em}}"),I("\\enspace","\\kern.5em "),I("\\enskip","\\hskip.5em\\relax"),I("\\quad","\\hskip1em\\relax"),I("\\qquad","\\hskip2em\\relax"),I("\\AA","\\TextOrMath{\\Angstrom}{\\mathring{A}}\\relax"),I("\\tag","\\@ifstar\\tag@literal\\tag@paren"),I("\\tag@paren","\\tag@literal{({#1})}"),I("\\tag@literal",e=>{if(e.macros.get("\\df@tag"))throw new r("Multiple \\tag");return"\\gdef\\df@tag{\\text{#1}}"}),I("\\notag","\\nonumber"),I("\\nonumber","\\gdef\\@eqnsw{0}"),I("\\bmod","\\mathbin{\\text{mod}}"),I("\\pod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"),I("\\pmod","\\pod{{\\rm mod}\\mkern6mu#1}"),I("\\mod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1"),I("\\newline","\\\\\\relax"),I("\\TeX","\\textrm{T}\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125em\\textrm{X}"),I("\\LaTeX","\\textrm{L}\\kern-.35em\\raisebox{0.2em}{\\scriptstyle A}\\kern-.15em\\TeX"),I("\\Temml","\\textrm{T}\\kern-0.2em\\lower{0.2em}{\\textrm{E}}\\kern-0.08em{\\textrm{M}\\kern-0.08em\\raise{0.2em}\\textrm{M}\\kern-0.08em\\textrm{L}}"),I("\\hspace","\\@ifstar\\@hspacer\\@hspace"),I("\\@hspace","\\hskip #1\\relax"),I("\\@hspacer","\\rule{0pt}{0pt}\\hskip #1\\relax"),I("\\colon",'\\mathpunct{\\char"3a}'),I("\\prescript","\\pres@cript{_{#1}^{#2}}{}{#3}"),I("\\ordinarycolon",'\\char"3a'),I("\\vcentcolon","\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}}"),I("\\coloneq",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"2212}'),I("\\Coloneq",'\\mathrel{\\char"2237\\char"2212}'),I("\\Eqqcolon",'\\mathrel{\\char"3d\\char"2237}'),I("\\Eqcolon",'\\mathrel{\\char"2212\\char"2237}'),I("\\colonapprox",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"2248}'),I("\\Colonapprox",'\\mathrel{\\char"2237\\char"2248}'),I("\\colonsim",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"223c}'),I("\\Colonsim",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"223c}'),I("\\ratio","\\vcentcolon"),I("\\coloncolon","\\dblcolon"),I("\\colonequals","\\coloneqq"),I("\\coloncolonequals","\\Coloneqq"),I("\\equalscolon","\\eqqcolon"),I("\\equalscoloncolon","\\Eqqcolon"),I("\\colonminus","\\coloneq"),I("\\coloncolonminus","\\Coloneq"),I("\\minuscolon","\\eqcolon"),I("\\minuscoloncolon","\\Eqcolon"),I("\\coloncolonapprox","\\Colonapprox"),I("\\coloncolonsim","\\Colonsim"),I("\\notni","\\mathrel{\\char`\u220C}"),I("\\limsup","\\DOTSB\\operatorname*{lim\\,sup}"),I("\\liminf","\\DOTSB\\operatorname*{lim\\,inf}"),I("\\injlim","\\DOTSB\\operatorname*{inj\\,lim}"),I("\\projlim","\\DOTSB\\operatorname*{proj\\,lim}"),I("\\varlimsup","\\DOTSB\\operatorname*{\\overline{\\text{lim}}}"),I("\\varliminf","\\DOTSB\\operatorname*{\\underline{\\text{lim}}}"),I("\\varinjlim","\\DOTSB\\operatorname*{\\underrightarrow{\\text{lim}}}"),I("\\varprojlim","\\DOTSB\\operatorname*{\\underleftarrow{\\text{lim}}}"),I("\\centerdot","{\\medspace\\rule{0.167em}{0.189em}\\medspace}"),I("\\argmin","\\DOTSB\\operatorname*{arg\\,min}"),I("\\argmax","\\DOTSB\\operatorname*{arg\\,max}"),I("\\plim","\\DOTSB\\operatorname*{plim}"),I("\\leftmodels","\\mathop{\\reflectbox{$\\models$}}"),I("\\bra","\\mathinner{\\langle{#1}|}"),I("\\ket","\\mathinner{|{#1}\\rangle}"),I("\\braket","\\mathinner{\\langle{#1}\\rangle}"),I("\\Bra","\\left\\langle#1\\right|"),I("\\Ket","\\left|#1\\right\\rangle");let Nn=(e,t)=>{let n=`}\\,\\middle${t[0]==="|"?"\\vert":"\\Vert"}\\,{`;return e.slice(0,t.index)+n+e.slice(t.index+t[0].length)};I("\\Braket",function(e){let t=Qt(e),n=/\|\||\||\\\|/g,a;for(;(a=n.exec(t))!==null;)t=Nn(t,a);return"\\left\\langle{"+t+"}\\right\\rangle"}),I("\\Set",function(e){let t=Qt(e),n=/\|\||\||\\\|/.exec(t);return n&&(t=Nn(t,n)),"\\left\\{\\:{"+t+"}\\:\\right\\}"}),I("\\set",function(e){return"\\{{"+Qt(e).replace(/\|/,"}\\mid{")+"}\\}"}),I("\\angln","{\\angl n}"),I("\\odv","\\@ifstar\\odv@next\\odv@numerator"),I("\\odv@numerator","\\frac{\\mathrm{d}#1}{\\mathrm{d}#2}"),I("\\odv@next","\\frac{\\mathrm{d}}{\\mathrm{d}#2}#1"),I("\\pdv","\\@ifstar\\pdv@next\\pdv@numerator");let rn=e=>{let t=e[0][0].text,n=nn(e[1]).split(","),a=String(n.length),c=a==="1"?"\\partial":`\\partial^${a}`,p="";return n.map(g=>{p+="\\partial "+g.trim()+"\\,"}),[t,c,p.replace(/\\,$/,"")]};function gn(e){let t=[];e.consumeSpaces();let n=e.fetch().text;for(n==="\\relax"&&(e.consume(),e.consumeSpaces(),n=e.fetch().text);n==="\\hline"||n==="\\hdashline";)e.consume(),t.push(n==="\\hdashline"),e.consumeSpaces(),n=e.fetch().text;return t}I("\\pdv@numerator",function(e){let[t,n,a]=rn(e.consumeArgs(2));return`\\frac{${n} ${t}}{${a}}`}),I("\\pdv@next",function(e){let[t,n,a]=rn(e.consumeArgs(2));return`\\frac{${n}}{${a}} ${t}`}),I("\\upalpha","\\up@greek{\\alpha}"),I("\\upbeta","\\up@greek{\\beta}"),I("\\upgamma","\\up@greek{\\gamma}"),I("\\updelta","\\up@greek{\\delta}"),I("\\upepsilon","\\up@greek{\\epsilon}"),I("\\upzeta","\\up@greek{\\zeta}"),I("\\upeta","\\up@greek{\\eta}"),I("\\uptheta","\\up@greek{\\theta}"),I("\\upiota","\\up@greek{\\iota}"),I("\\upkappa","\\up@greek{\\kappa}"),I("\\uplambda","\\up@greek{\\lambda}"),I("\\upmu","\\up@greek{\\mu}"),I("\\upnu","\\up@greek{\\nu}"),I("\\upxi","\\up@greek{\\xi}"),I("\\upomicron","\\up@greek{\\omicron}"),I("\\uppi","\\up@greek{\\pi}"),I("\\upalpha","\\up@greek{\\alpha}"),I("\\uprho","\\up@greek{\\rho}"),I("\\upsigma","\\up@greek{\\sigma}"),I("\\uptau","\\up@greek{\\tau}"),I("\\upupsilon","\\up@greek{\\upsilon}"),I("\\upphi","\\up@greek{\\phi}"),I("\\upchi","\\up@greek{\\chi}"),I("\\uppsi","\\up@greek{\\psi}"),I("\\upomega","\\up@greek{\\omega}"),I("\\invamp",'\\mathbin{\\char"214b}'),I("\\parr",'\\mathbin{\\char"214b}'),I("\\upand",'\\mathbin{\\char"214b}'),I("\\with",'\\mathbin{\\char"26}'),I("\\multimapinv",'\\mathrel{\\char"27dc}'),I("\\multimapboth",'\\mathrel{\\char"29df}'),I("\\scoh",'{\\mkern5mu\\char"2322\\mkern5mu}'),I("\\sincoh",'{\\mkern5mu\\char"2323\\mkern5mu}'),I("\\coh",`{\\mkern5mu\\rule{}{0.7em}\\mathrlap{\\smash{\\raise2mu{\\char"2322}}}
6
- {\\smash{\\lower4mu{\\char"2323}}}\\mkern5mu}`),I("\\incoh",`{\\mkern5mu\\rule{}{0.7em}\\mathrlap{\\smash{\\raise2mu{\\char"2323}}}
7
- {\\smash{\\lower4mu{\\char"2322}}}\\mkern5mu}`),I("\\standardstate","\\text{\\tiny\\char`\u29B5}");let Yt=e=>{if(!e.parser.settings.displayMode)throw new r(`{${e.envName}} can be used only in display mode.`)},$n=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/,St=e=>{let t=e.get("\\arraystretch");typeof t!="string"&&(t=nn(t.tokens)),t=isNaN(t)?null:Number(t);let n=e.get("\\arraycolsep");typeof n!="string"&&(n=nn(n.tokens));let a=$n.exec(n);return[t,a?{number:+(a[1]+a[2]),unit:a[3]}:null]},Bn=e=>{let t="";for(let n=0;n<e.length;n++)if(e[n].type==="label"){if(t)throw new r("Multiple \\labels in one row");t=e[n].string}return t};function sn(e){if(e.indexOf("ed")===-1)return e.indexOf("*")===-1}function Mt(e,{cols:t,envClasses:n,autoTag:a,singleRow:c,emptySingleRow:p,maxNumCols:g,leqno:x,arraystretch:q,arraycolsep:j},ie){let he=n&&n.includes("bordermatrix")?"}":"\\end";e.gullet.beginGroup(),c||e.gullet.macros.set("\\cr","\\\\\\relax"),e.gullet.beginGroup();let ee=[],lt=[ee],We=[],ct=[],At=[],Ve=a!=null?[]:void 0;function rt(){a&&e.gullet.macros.set("\\@eqnsw","1",!0)}function en(){Ve&&(e.gullet.macros.get("\\df@tag")?(Ve.push(e.subparse([new qt("\\df@tag")])),e.gullet.macros.set("\\df@tag",void 0,!0)):Ve.push(!!a&&e.gullet.macros.get("\\@eqnsw")==="1"))}for(rt(),At.push(gn(e));;){let Ut=e.parseExpression(!1,c?"\\end":"\\\\");e.gullet.endGroup(),e.gullet.beginGroup(),Ut={type:"ordgroup",mode:e.mode,body:Ut,semisimple:!0},ee.push(Ut);let qn=e.fetch().text;if(qn==="&"){if(g&&ee.length===g){if(!n.includes("array"))throw new r(g===2?"The split environment accepts no more than two columns":"The equation environment accepts only one column",e.nextToken);if(e.settings.strict)throw new r("Too few columns specified in the {array} column argument.",e.nextToken)}e.consume()}else{if(qn===he){en(),ee.length===1&&Ut.body.length===0&&(lt.length>1||!p)&&lt.pop(),ct.push(Bn(Ut.body)),At.length<lt.length+1&&At.push([]);break}if(qn!=="\\\\")throw new r("Expected & or \\\\ or \\cr or "+he,e.nextToken);{let mn;e.consume(),e.gullet.future().text!==" "&&(mn=e.parseSizeGroup(!0)),We.push(mn?mn.value:null),en(),ct.push(Bn(Ut.body)),At.push(gn(e)),ee=[],lt.push(ee),rt()}}}return e.gullet.endGroup(),e.gullet.endGroup(),{type:"array",mode:e.mode,body:lt,cols:t,rowGaps:We,hLinesBeforeRow:At,envClasses:n,autoTag:a,scriptLevel:ie,tags:Ve,labels:ct,leqno:x,arraystretch:q,arraycolsep:j}}function Gt(e){return e.slice(0,1)==="d"?"display":"text"}let jt={c:"center ",l:"left ",r:"right "},dn=e=>{let t=new _("mtd",[]);return t.style={padding:"0",width:"50%"},e.envClasses.includes("multline")&&(t.style.width="7.5%"),t},kt=function(e,t){let n=[],a=e.body.length,c=e.hLinesBeforeRow,p=e.tags&&e.tags.some(j=>j);for(let j=0;j<a;j++){let ie=e.body[j],he=[],ee=e.scriptLevel==="text"?Pt:e.scriptLevel==="script"?an:Ft;for(let Ve=0;Ve<ie.length;Ve++){let rt=new _("mtd",[He(ie[Ve],t.withLevel(ee))]);if(e.envClasses.includes("multline")){let en=j===0?"left":j===a-1?"right":"center";en!=="center"&&rt.classes.push("tml-"+en)}he.push(rt)}let lt=e.body[0].length;for(let Ve=0;Ve<lt-ie.length;Ve++)he.push(new _("mtd",[],[],t));if(p){let Ve=e.tags[j],rt;Ve===!0?rt=new _("mtext",[new De(["tml-eqn"])]):Ve===!1?rt=new _("mtext",[],[]):(rt=bt(Ve[0].body,t.withLevel(ee),!0),rt=Et(rt),rt.classes=["tml-tag"]),rt&&(he.unshift(dn(e)),he.push(dn(e)),e.leqno?he[0].children.push(rt):he[he.length-1].children.push(rt))}let We=new _("mtr",he,[]),ct=e.labels.shift();ct&&e.tags&&e.tags[j]&&(We.setAttribute("id",ct),Array.isArray(e.tags[j])&&We.classes.push("tml-tageqn")),j===0&&c[0].length>0&&(c[0].length===2?We.children.forEach(Ve=>{Ve.style.borderTop="0.15em double"}):We.children.forEach(Ve=>{Ve.style.borderTop=c[0][0]?"0.06em dashed":"0.06em solid"})),c[j+1].length>0&&(c[j+1].length===2?We.children.forEach(Ve=>{Ve.style.borderBottom="0.15em double"}):We.children.forEach(Ve=>{Ve.style.borderBottom=c[j+1][0]?"0.06em dashed":"0.06em solid"}));let At=!0;for(let Ve=0;Ve<We.children.length;Ve++){let rt=We.children[Ve].children[0];if(!rt||rt.type!=="mpadded"||rt.attributes.height!=="0px"){At=!1;break}}if(At){We.classes.push("ff-squash");for(let Ve=0;Ve<We.children.length;Ve++)We.children[Ve].style.paddingTop="0",We.children[Ve].style.paddingBottom="0"}n.push(We)}if(e.arraystretch&&e.arraystretch!==1){let j=String(1.4*e.arraystretch-.8)+"ex";for(let ie=0;ie<n.length;ie++)for(let he=0;he<n[ie].children.length;he++)n[ie].children[he].style.paddingTop=j,n[ie].children[he].style.paddingBottom=j}let g,x;if(e.envClasses.length>0&&(g=e.envClasses.includes("abut")||e.envClasses.includes("cases")?"0":e.envClasses.includes("small")?"0.1389":e.envClasses.includes("cd")?"0.25":"0.4",x="em"),e.arraycolsep){let j=W(e.arraycolsep,t);g=j.number.toFixed(4),x=j.unit}if(g){let j=n.length===0?0:n[0].children.length,ie=(he,ee)=>he===0&&ee===0||he===j-1&&ee===1?"0":e.envClasses[0]!=="align"?g:ee===1?"0":p?he%2?"1":"0":he%2?"0":"1";for(let he=0;he<n.length;he++)for(let ee=0;ee<n[he].children.length;ee++)n[he].children[ee].style.paddingLeft=`${ie(ee,0)}${x}`,n[he].children[ee].style.paddingRight=`${ie(ee,1)}${x}`}if(e.envClasses.length===0)for(let j=0;j<n.length;j++)n[j].children[0].style.paddingLeft="0em",n[j].children.length===n[0].children.length&&(n[j].children[n[j].children.length-1].style.paddingRight="0em");if(e.envClasses.length>0){let j=e.envClasses.includes("align")||e.envClasses.includes("alignat");for(let ie=0;ie<n.length;ie++){let he=n[ie];if(j){for(let ee=0;ee<he.children.length;ee++)he.children[ee].classes=["tml-"+(ee%2?"left":"right")];if(p){let ee=e.leqno?0:he.children.length-1;he.children[ee].classes=[]}}if(he.children.length>1&&e.envClasses.includes("cases")&&(he.children[1].style.paddingLeft="1em"),e.envClasses.includes("cases")||e.envClasses.includes("subarray"))for(let ee of he.children)ee.classes.push("tml-left")}}let q=new _("mtable",n);if(e.envClasses.length>0&&(e.envClasses.includes("jot")?q.classes.push("tml-jot"):e.envClasses.includes("small")&&q.classes.push("tml-small")),e.scriptLevel==="display"&&q.setAttribute("displaystyle","true"),(e.autoTag||e.envClasses.includes("multline"))&&(q.style.width="100%"),e.cols&&e.cols.length>0){let j=e.cols,ie=!1,he=0,ee=j.length;for(;j[he].type==="separator";)he+=1;for(;j[ee-1].type==="separator";)ee-=1;if(j[0].type==="separator"){let We=j[1].type==="separator"?"0.15em double":j[0].separator==="|"?"0.06em solid ":"0.06em dashed ";for(let ct of q.children)ct.children[0].style.borderLeft=We}let lt=p?0:-1;for(let We=he;We<ee;We++)if(j[We].type==="align"){let ct=jt[j[We].align];lt+=1;for(let At of q.children)ct.trim()!=="center"&&lt<At.children.length&&(At.children[lt].classes=["tml-"+ct.trim()]);ie=!0}else if(j[We].type==="separator"){if(ie){let ct=j[We+1].type==="separator"?"0.15em double":j[We].separator==="|"?"0.06em solid":"0.06em dashed";for(let At of q.children)lt<At.children.length&&(At.children[lt].style.borderRight=ct)}ie=!1}if(j[j.length-1].type==="separator"){let We=j[j.length-2].type==="separator"?"0.15em double":j[j.length-1].separator==="|"?"0.06em solid":"0.06em dashed";for(let ct of q.children)ct.children[ct.children.length-1].style.borderRight=We,ct.children[ct.children.length-1].style.paddingRight="0.4em"}}return e.envClasses.includes("small")&&(q=new _("mstyle",[q]),q.setAttribute("scriptlevel","1")),q},Tt=function(e,t){e.envName.indexOf("ed")===-1&&Yt(e);let n=e.envName==="split",a=[],c=Mt(e.parser,{cols:a,emptySingleRow:!0,autoTag:n?void 0:sn(e.envName),envClasses:["abut","jot"],maxNumCols:e.envName==="split"?2:void 0,leqno:e.parser.settings.leqno},"display"),p,g=0,x=e.envName.indexOf("at")>-1;if(t[0]&&x){let q="";for(let j=0;j<t[0].body.length;j++)q+=te(t[0].body[j],"textord").text;if(isNaN(q))throw new r("The alignat enviroment requires a numeric first argument.");p=Number(q),g=2*p}c.body.forEach(function(q){if(x){let j=q.length/2;if(p<j)throw new r(`Too many math in a row: expected ${p}, but got ${j}`,q[0])}else g<q.length&&(g=q.length)});for(let q=0;q<g;++q){let j="r";q%2==1&&(j="l"),a[q]={type:"align",align:j}}return e.envName==="split"||(x?c.envClasses.push("alignat"):c.envClasses[0]="align"),c};Z({type:"array",names:["array","darray"],props:{numArgs:1},handler(e,t){let n=(Qe(t[0])?[t[0]]:te(t[0],"ordgroup").body).map(function(g){let x=fe(g).text;if("lcr".indexOf(x)!==-1)return{type:"align",align:x};if(x==="|")return{type:"separator",separator:"|"};if(x===":")return{type:"separator",separator:":"};throw new r("Unknown column alignment: "+x,g)}),[a,c]=St(e.parser.gullet.macros),p={cols:n,envClasses:["array"],maxNumCols:n.length,arraystretch:a,arraycolsep:c};return Mt(e.parser,p,Gt(e.envName))},mathmlBuilder:kt}),Z({type:"array",names:["matrix","pmatrix","bmatrix","Bmatrix","vmatrix","Vmatrix","matrix*","pmatrix*","bmatrix*","Bmatrix*","vmatrix*","Vmatrix*"],props:{numArgs:0},handler(e){let t={matrix:null,pmatrix:["(",")"],bmatrix:["[","]"],Bmatrix:["\\{","\\}"],vmatrix:["|","|"],Vmatrix:["\\Vert","\\Vert"]}[e.envName.replace("*","")],n="c",a={envClasses:[],cols:[]};if(e.envName.charAt(e.envName.length-1)==="*"){let x=e.parser;if(x.consumeSpaces(),x.fetch().text==="["){if(x.consume(),x.consumeSpaces(),n=x.fetch().text,"lcr".indexOf(n)===-1)throw new r("Expected l or c or r",x.nextToken);x.consume(),x.consumeSpaces(),x.expect("]"),x.consume(),a.cols=[]}}let c=Mt(e.parser,a,"text");c.cols=c.body.length>0?new Array(c.body[0].length).fill({type:"align",align:n}):[];let[p,g]=St(e.parser.gullet.macros);return c.arraystretch=p,!g||g===6&&g==="pt"||(c.arraycolsep=g),t?{type:"leftright",mode:e.mode,body:[c],left:t[0],right:t[1],rightColor:void 0}:c},mathmlBuilder:kt}),Z({type:"array",names:["bordermatrix"],props:{numArgs:0},handler(e){let t=Mt(e.parser,{cols:[],envClasses:["bordermatrix"]},"text");return t.cols=t.body.length>0?new Array(t.body[0].length).fill({type:"align",align:"c"}):[],t.envClasses=[],t.arraystretch=1,e.envName==="matrix"?t:((n,a)=>{let c=n.body;c[0].shift();let p=new Array(c.length-1).fill().map(()=>[]);for(let ie=1;ie<c.length;ie++){p[ie-1].push(c[ie].shift());let he=[];for(let ee=0;ee<c[ie].length;ee++)he.push(c[ie][ee]);p[ie-1].push(ht(he,"vphantom"))}let g=new Array(c.length).fill().map(()=>[]);for(let ie=0;ie<c[0].length;ie++)g[0].push(c[0][ie]);for(let ie=1;ie<c.length;ie++)for(let he=0;he<c[0].length;he++)g[ie].push(ht(c[ie][he].body,"hphantom"));for(let ie=0;ie<c[0].length;ie++)c[0][ie]=ht(c[0][ie].body,"hphantom");let x={type:"array",mode:"math",body:p,cols:[{type:"align",align:"c"}],rowGaps:new Array(p.length-1).fill(null),hLinesBeforeRow:new Array(p.length+1).fill().map(()=>[]),envClasses:[],scriptLevel:"text",arraystretch:1,labels:new Array(p.length).fill(""),arraycolsep:{number:.04,unit:"em"}},q={type:"styling",mode:"math",scriptLevel:"text",body:[{type:"array",mode:"math",body:g,cols:new Array(g.length).fill({type:"align",align:"c"}),rowGaps:new Array(g.length-1).fill(null),hLinesBeforeRow:new Array(g.length+1).fill().map(()=>[]),envClasses:[],scriptLevel:"text",arraystretch:1,labels:new Array(g.length).fill(""),arraycolsep:null}]},j={type:"leftright",mode:"math",body:[n],left:a?a[0]:"(",right:a?a[1]:")",rightColor:void 0};return xt([x,{type:"supsub",mode:"math",stack:!0,base:{type:"op",mode:"math",limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!0,symbol:!1,suppressBaseShift:!0,body:[j]},sup:q,sub:null}])})(t,e.delimiters)},mathmlBuilder:kt}),Z({type:"array",names:["smallmatrix"],props:{numArgs:0},handler:e=>Mt(e.parser,{envClasses:["small"]},"script"),mathmlBuilder:kt}),Z({type:"array",names:["subarray"],props:{numArgs:1},handler(e,t){let n=(Qe(t[0])?[t[0]]:te(t[0],"ordgroup").body).map(function(c){let p=fe(c).text;if("lc".indexOf(p)!==-1)return{type:"align",align:p};throw new r("Unknown column alignment: "+p,c)});if(n.length>1)throw new r("{subarray} can contain only one column");let a={cols:n,envClasses:["small"]};if(a=Mt(e.parser,a,"script"),a.body.length>0&&a.body[0].length>1)throw new r("{subarray} can contain only one column");return a},mathmlBuilder:kt}),Z({type:"array",names:["cases","dcases","rcases","drcases"],props:{numArgs:0},handler(e){let t=Mt(e.parser,{cols:[],envClasses:["cases"]},Gt(e.envName));return{type:"leftright",mode:e.mode,body:[t],left:e.envName.indexOf("r")>-1?".":"\\{",right:e.envName.indexOf("r")>-1?"\\}":".",rightColor:void 0}},mathmlBuilder:kt}),Z({type:"array",names:["align","align*","aligned","split"],props:{numArgs:0},handler:Tt,mathmlBuilder:kt}),Z({type:"array",names:["alignat","alignat*","alignedat"],props:{numArgs:1},handler:Tt,mathmlBuilder:kt}),Z({type:"array",names:["gathered","gather","gather*"],props:{numArgs:0},handler(e){e.envName!=="gathered"&&Yt(e);let t={cols:[],envClasses:["abut","jot"],autoTag:sn(e.envName),emptySingleRow:!0,leqno:e.parser.settings.leqno};return Mt(e.parser,t,"display")},mathmlBuilder:kt}),Z({type:"array",names:["equation","equation*"],props:{numArgs:0},handler(e){Yt(e);let t={autoTag:sn(e.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,envClasses:["align"],leqno:e.parser.settings.leqno};return Mt(e.parser,t,"display")},mathmlBuilder:kt}),Z({type:"array",names:["multline","multline*"],props:{numArgs:0},handler(e){Yt(e);let t={autoTag:e.envName==="multline",maxNumCols:1,envClasses:["jot","multline"],leqno:e.parser.settings.leqno};return Mt(e.parser,t,"display")},mathmlBuilder:kt}),Z({type:"array",names:["CD"],props:{numArgs:0},handler:e=>(Yt(e),function(t){let n=[];for(t.gullet.beginGroup(),t.gullet.macros.set("\\cr","\\\\\\relax"),t.gullet.beginGroup();;){n.push(t.parseExpression(!1,"\\\\")),t.gullet.endGroup(),t.gullet.beginGroup();let p=t.fetch().text;if(p!=="&"&&p!=="\\\\"){if(p==="\\end"){n[n.length-1].length===0&&n.pop();break}throw new r("Expected \\\\ or \\cr or \\end",t.nextToken)}t.consume()}let a=[],c=[a];for(let p=0;p<n.length;p++){let g=n[p],x=Ye();for(let q=0;q<g.length;q++)if(ut(g[q])){a.push(x),q+=1;let j=fe(g[q]).text,ie=new Array(2);if(ie[0]={type:"ordgroup",mode:"math",body:[]},ie[1]={type:"ordgroup",mode:"math",body:[]},!("=|.".indexOf(j)>-1)){if(!("<>AV".indexOf(j)>-1))throw new r('Expected one of "<>AV=|." after @.');for(let ee=0;ee<2;ee++){let lt=!0;for(let We=q+1;We<g.length;We++){if(dt(g[We],j)){lt=!1,q=We;break}if(ut(g[We]))throw new r("Missing a "+j+" character to complete a CD arrow.",g[We]);ie[ee].body.push(g[We])}if(lt)throw new r("Missing a "+j+" character to complete a CD arrow.",g[q])}}let he=pt(j,ie,t);a.push(he),x=Ye()}else x.body.push(g[q]);p%2==0?a.push(x):a.shift(),a=[],c.push(a)}return c.pop(),t.gullet.endGroup(),t.gullet.endGroup(),{type:"array",mode:"math",body:c,tags:null,labels:new Array(c.length+1).fill(""),envClasses:["jot","cd"],cols:[],hLinesBeforeRow:new Array(c.length+1).fill([])}}(e.parser)),mathmlBuilder:kt}),C({type:"text",names:["\\hline","\\hdashline"],props:{numArgs:0,allowedInText:!0,allowedInMath:!0},handler(e,t){throw new r(`${e.funcName} valid only within array environment`)}});let un=$;C({type:"bordermatrix",names:["\\bordermatrix","\\matrix"],props:{numArgs:0,numOptionalArgs:1},handler:({parser:e,funcName:t},n,a)=>{let c=["(",")"];if(t==="\\bordermatrix"&&a[0]&&a[0].body){let q=a[0].body;q.length===1&&q[0].type==="delimiter"&&(c=[q[0].left,q[0].right])}e.consumeSpaces(),e.consume();let p=un.bordermatrix,g={mode:e.mode,envName:t.slice(1),delimiters:c,parser:e},x=p.handler(g);return e.expect("}",!0),x}}),C({type:"cancelto",names:["\\cancelto"],props:{numArgs:2},handler({parser:e},t){let n=t[0],a=t[1];return{type:"cancelto",mode:e.mode,body:a,to:n,isCharacterBox:b(a)}},mathmlBuilder(e,t){let n=new _("mrow",[He(e.body,t)],["ff-narrow"]),a=new _("mphantom",[He(e.body,t)]),c=new _("mrow",[a],["tml-cancelto"]);c.style.color=t.color,e.isCharacterBox&&A.indexOf(e.body.body[0].text)>-1&&(c.style.left="0.1em",c.style.width="90%");let p=new _("mrow",[n,c],["menclose"]);if(!e.isCharacterBox||/[f∫∑]/.test(e.body.body[0].text))a.style.paddingRight="0.2em";else{a.style.padding="0.5ex 0.1em 0 0";let he=new _("mspace",[]);he.setAttribute("height","0.85em"),n.children.push(he)}let g;if(e.isCharacterBox)g=new _("mspace",[]),g.setAttribute("height","1em");else{let he=He(e.body,t),ee=new _("mpadded",[he]);ee.setAttribute("width","0.1px"),g=new _("mphantom",[ee])}let x=He(e.to,t);x.style.color=t.color;let q=new _("mpadded",[x]);if(!e.isCharacterBox||/[f∫∑]/.test(e.body.body[0].text)){let he=new _("mspace",[]);he.setAttribute("width","0.2em"),q.children.unshift(he)}q.setAttribute("width","0.1px");let j=new _("mover",[g,q]),ie=new _("mrow",[],["ff-nudge-left"]);return at([me([p,j]),ie])}}),C({type:"textord",names:["\\@char"],props:{numArgs:1,allowedInText:!0},handler({parser:e,token:t},n){let a=te(n[0],"ordgroup").body,c="";for(let g=0;g<a.length;g++)c+=te(a[g],"textord").text;let p=parseInt(c);if(isNaN(p))throw new r(`\\@char has non-numeric argument ${c}`,t);return{type:"textord",mode:e.mode,text:String.fromCodePoint(p)}}});let bn=/^(#[a-f0-9]{3}|#?[a-f0-9]{6})$/i,On=/^(#[a-f0-9]{3}|#?[a-f0-9]{6}|[a-z]+)$/i,yn=/^ *\d{1,3} *(?:, *\d{1,3} *){2}$/,wn=/^ *[10](?:\.\d*)? *(?:, *[10](?:\.\d*)? *){2}$/,v=/^[a-f0-9]{6}$/i,H=e=>{let t=e.toString(16);return t.length===1&&(t="0"+t),t},G=JSON.parse(`{
1
+ /*! Decklight v0.7.0 — Copyright 2026 Gilles Philippart — SPDX-License-Identifier: Apache-2.0 */
2
+ var Decklight=(()=>{var ll=Object.create;var fs=Object.defineProperty;var cl=Object.getOwnPropertyDescriptor;var dl=Object.getOwnPropertyNames;var ul=Object.getPrototypeOf,pl=Object.prototype.hasOwnProperty;var Po=(t,o)=>()=>(t&&(o=t(t=0)),o);var hl=(t,o)=>()=>(o||t((o={exports:{}}).exports,o),o.exports),ml=(t,o)=>{for(var a in o)fs(t,a,{get:o[a],enumerable:!0})},Bo=(t,o,a,c)=>{if(o&&typeof o=="object"||typeof o=="function")for(let d of dl(o))!pl.call(t,d)&&d!==a&&fs(t,d,{get:()=>o[d],enumerable:!(c=cl(o,d))||c.enumerable});return t};var fl=(t,o,a)=>(a=t!=null?ll(ul(t)):{},Bo(o||!t||!t.__esModule?fs(a,"default",{value:t,enumerable:!0}):a,t)),gl=t=>Bo(fs({},"__esModule",{value:!0}),t);var it,ge=Po(()=>{it={order:["default","classics"],labels:{default:"Default",classics:"Classics"},packs:{default:["aurora","eclipse","midnight","fjord","cosmos","ink","storm","carbon","synthwave","obsidian","graphite","ember","moss","velvet","porcelain","paper","linen","sepia","glacier","mint","latte","dune","coastal","harvest","meadow","orchid","peony","slate","berry","citrus","ibm-modern","yamabuki"],classics:["reveal-black","reveal-white","reveal-league","reveal-beige","reveal-sky","reveal-night","reveal-serif","reveal-simple","reveal-solarized","reveal-moon","reveal-blood","reveal-dracula","metropolis","seriph"]}}});var rt,be=Po(()=>{rt=["aurora","berry","carbon","citrus","coastal","cosmos","dune","eclipse","ember","fjord","glacier","graphite","harvest","ibm-modern","ink","latte","linen","meadow","metropolis","midnight","mint","moss","obsidian","orchid","paper","peony","porcelain","reveal-beige","reveal-black","reveal-blood","reveal-dracula","reveal-league","reveal-moon","reveal-night","reveal-serif","reveal-simple","reveal-sky","reveal-solarized","reveal-white","sepia","seriph","slate","storm","synthwave","velvet","yamabuki"]});var Ai=hl((qu,Si)=>{ge();be();function pi(t){return t instanceof Map?t.clear=t.delete=t.set=function(){throw new Error("map is read-only")}:t instanceof Set&&(t.add=t.clear=t.delete=function(){throw new Error("set is read-only")}),Object.freeze(t),Object.getOwnPropertyNames(t).forEach(o=>{let a=t[o],c=typeof a;(c==="object"||c==="function")&&!Object.isFrozen(a)&&pi(a)}),t}var vs=class{constructor(o){o.data===void 0&&(o.data={}),this.data=o.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function hi(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function nr(t,...o){let a=Object.create(null);for(let c in t)a[c]=t[c];return o.forEach(function(c){for(let d in c)a[d]=c[d]}),a}var Wl="</span>",ii=t=>!!t.scope,Vl=(t,{prefix:o})=>{if(t.startsWith("language:"))return t.replace("language:","language-");if(t.includes(".")){let a=t.split(".");return[`${o}${a.shift()}`,...a.map((c,d)=>`${c}${"_".repeat(d+1)}`)].join(" ")}return`${o}${t}`},eo=class{constructor(o,a){this.buffer="",this.classPrefix=a.classPrefix,o.walk(this)}addText(o){this.buffer+=hi(o)}openNode(o){if(!ii(o))return;let a=Vl(o.scope,{prefix:this.classPrefix});this.span(a)}closeNode(o){ii(o)&&(this.buffer+=Wl)}value(){return this.buffer}span(o){this.buffer+=`<span class="${o}">`}},ai=(t={})=>{let o={children:[]};return Object.assign(o,t),o},to=class t{constructor(){this.rootNode=ai(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(o){this.top.children.push(o)}openNode(o){let a=ai({scope:o});this.add(a),this.stack.push(a)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(o){return this.constructor._walk(o,this.rootNode)}static _walk(o,a){return typeof a=="string"?o.addText(a):a.children&&(o.openNode(a),a.children.forEach(c=>this._walk(o,c)),o.closeNode(a)),o}static _collapse(o){typeof o!="string"&&o.children&&(o.children.every(a=>typeof a=="string")?o.children=[o.children.join("")]:o.children.forEach(a=>{t._collapse(a)}))}},no=class extends to{constructor(o){super(),this.options=o}addText(o){o!==""&&this.add(o)}startScope(o){this.openNode(o)}endScope(){this.closeNode()}__addSublanguage(o,a){let c=o.root;a&&(c.scope=`language:${a}`),this.add(c)}toHTML(){return new eo(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}};function Vr(t){return t?typeof t=="string"?t:t.source:null}function mi(t){return br("(?=",t,")")}function Zl(t){return br("(?:",t,")*")}function Yl(t){return br("(?:",t,")?")}function br(...t){return t.map(a=>Vr(a)).join("")}function Xl(t){let o=t[t.length-1];return typeof o=="object"&&o.constructor===Object?(t.splice(t.length-1,1),o):{}}function so(...t){return"("+(Xl(t).capture?"":"?:")+t.map(c=>Vr(c)).join("|")+")"}function fi(t){return new RegExp(t.toString()+"|").exec("").length-1}function Jl(t,o){let a=t&&t.exec(o);return a&&a.index===0}var Ql=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function oo(t,{joinWith:o}){let a=0;return t.map(c=>{a+=1;let d=a,p=Vr(c),g="";for(;p.length>0;){let m=Ql.exec(p);if(!m){g+=p;break}g+=p.substring(0,m.index),p=p.substring(m.index+m[0].length),m[0][0]==="\\"&&m[1]?g+="\\"+String(Number(m[1])+d):(g+=m[0],m[0]==="("&&a++)}return g}).map(c=>`(${c})`).join(o)}var ec=/\b\B/,gi="[a-zA-Z]\\w*",io="[a-zA-Z_]\\w*",bi="\\b\\d+(\\.\\d+)?",yi="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",wi="\\b(0b[01]+)",tc="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",nc=(t={})=>{let o=/^#![ ]*\//;return t.binary&&(t.begin=br(o,/.*\b/,t.binary,/\b.*/)),nr({scope:"meta",begin:o,end:/$/,relevance:0,"on:begin":(a,c)=>{a.index!==0&&c.ignoreMatch()}},t)},Zr={begin:"\\\\[\\s\\S]",relevance:0},rc={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[Zr]},sc={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[Zr]},oc={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},ks=function(t,o,a={}){let c=nr({scope:"comment",begin:t,end:o,contains:[]},a);c.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});let d=so("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return c.contains.push({begin:br(/[ ]+/,"(",d,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),c},ic=ks("//","$"),ac=ks("/\\*","\\*/"),lc=ks("#","$"),cc={scope:"number",begin:bi,relevance:0},dc={scope:"number",begin:yi,relevance:0},uc={scope:"number",begin:wi,relevance:0},pc={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[Zr,{begin:/\[/,end:/\]/,relevance:0,contains:[Zr]}]},hc={scope:"title",begin:gi,relevance:0},mc={scope:"title",begin:io,relevance:0},fc={begin:"\\.\\s*"+io,relevance:0},gc=function(t){return Object.assign(t,{"on:begin":(o,a)=>{a.data._beginMatch=o[1]},"on:end":(o,a)=>{a.data._beginMatch!==o[1]&&a.ignoreMatch()}})},ws=Object.freeze({__proto__:null,APOS_STRING_MODE:rc,BACKSLASH_ESCAPE:Zr,BINARY_NUMBER_MODE:uc,BINARY_NUMBER_RE:wi,COMMENT:ks,C_BLOCK_COMMENT_MODE:ac,C_LINE_COMMENT_MODE:ic,C_NUMBER_MODE:dc,C_NUMBER_RE:yi,END_SAME_AS_BEGIN:gc,HASH_COMMENT_MODE:lc,IDENT_RE:gi,MATCH_NOTHING_RE:ec,METHOD_GUARD:fc,NUMBER_MODE:cc,NUMBER_RE:bi,PHRASAL_WORDS_MODE:oc,QUOTE_STRING_MODE:sc,REGEXP_MODE:pc,RE_STARTERS_RE:tc,SHEBANG:nc,TITLE_MODE:hc,UNDERSCORE_IDENT_RE:io,UNDERSCORE_TITLE_MODE:mc});function bc(t,o){t.input[t.index-1]==="."&&o.ignoreMatch()}function yc(t,o){t.className!==void 0&&(t.scope=t.className,delete t.className)}function wc(t,o){o&&t.beginKeywords&&(t.begin="\\b("+t.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",t.__beforeBegin=bc,t.keywords=t.keywords||t.beginKeywords,delete t.beginKeywords,t.relevance===void 0&&(t.relevance=0))}function vc(t,o){Array.isArray(t.illegal)&&(t.illegal=so(...t.illegal))}function xc(t,o){if(t.match){if(t.begin||t.end)throw new Error("begin & end are not supported with match");t.begin=t.match,delete t.match}}function kc(t,o){t.relevance===void 0&&(t.relevance=1)}var Ec=(t,o)=>{if(!t.beforeMatch)return;if(t.starts)throw new Error("beforeMatch cannot be used with starts");let a=Object.assign({},t);Object.keys(t).forEach(c=>{delete t[c]}),t.keywords=a.keywords,t.begin=br(a.beforeMatch,mi(a.begin)),t.starts={relevance:0,contains:[Object.assign(a,{endsParent:!0})]},t.relevance=0,delete a.beforeMatch},Sc=["of","and","for","in","not","or","if","then","parent","list","value"],Ac="keyword";function vi(t,o,a=Ac){let c=Object.create(null);return typeof t=="string"?d(a,t.split(" ")):Array.isArray(t)?d(a,t):Object.keys(t).forEach(function(p){Object.assign(c,vi(t[p],o,p))}),c;function d(p,g){o&&(g=g.map(m=>m.toLowerCase())),g.forEach(function(m){let w=m.split("|");c[w[0]]=[p,_c(w[0],w[1])]})}}function _c(t,o){return o?Number(o):Tc(t)?0:1}function Tc(t){return Sc.includes(t.toLowerCase())}var li={},gr=t=>{console.error(t)},ci=(t,...o)=>{console.log(`WARN: ${t}`,...o)},$r=(t,o)=>{li[`${t}/${o}`]||(console.log(`Deprecated as of ${t}. ${o}`),li[`${t}/${o}`]=!0)},xs=new Error;function xi(t,o,{key:a}){let c=0,d=t[a],p={},g={};for(let m=1;m<=o.length;m++)g[m+c]=d[m],p[m+c]=!0,c+=fi(o[m-1]);t[a]=g,t[a]._emit=p,t[a]._multi=!0}function $c(t){if(Array.isArray(t.begin)){if(t.skip||t.excludeBegin||t.returnBegin)throw gr("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),xs;if(typeof t.beginScope!="object"||t.beginScope===null)throw gr("beginScope must be object"),xs;xi(t,t.begin,{key:"beginScope"}),t.begin=oo(t.begin,{joinWith:""})}}function Cc(t){if(Array.isArray(t.end)){if(t.skip||t.excludeEnd||t.returnEnd)throw gr("skip, excludeEnd, returnEnd not compatible with endScope: {}"),xs;if(typeof t.endScope!="object"||t.endScope===null)throw gr("endScope must be object"),xs;xi(t,t.end,{key:"endScope"}),t.end=oo(t.end,{joinWith:""})}}function Nc(t){t.scope&&typeof t.scope=="object"&&t.scope!==null&&(t.beginScope=t.scope,delete t.scope)}function Mc(t){Nc(t),typeof t.beginScope=="string"&&(t.beginScope={_wrap:t.beginScope}),typeof t.endScope=="string"&&(t.endScope={_wrap:t.endScope}),$c(t),Cc(t)}function Oc(t){function o(g,m){return new RegExp(Vr(g),"m"+(t.case_insensitive?"i":"")+(t.unicodeRegex?"u":"")+(m?"g":""))}class a{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(m,w){w.position=this.position++,this.matchIndexes[this.matchAt]=w,this.regexes.push([w,m]),this.matchAt+=fi(m)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);let m=this.regexes.map(w=>w[1]);this.matcherRe=o(oo(m,{joinWith:"|"}),!0),this.lastIndex=0}exec(m){this.matcherRe.lastIndex=this.lastIndex;let w=this.matcherRe.exec(m);if(!w)return null;let E=w.findIndex((P,$)=>$>0&&P!==void 0),S=this.matchIndexes[E];return w.splice(0,E),Object.assign(w,S)}}class c{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(m){if(this.multiRegexes[m])return this.multiRegexes[m];let w=new a;return this.rules.slice(m).forEach(([E,S])=>w.addRule(E,S)),w.compile(),this.multiRegexes[m]=w,w}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(m,w){this.rules.push([m,w]),w.type==="begin"&&this.count++}exec(m){let w=this.getMatcher(this.regexIndex);w.lastIndex=this.lastIndex;let E=w.exec(m);if(this.resumingScanAtSamePosition()&&!(E&&E.index===this.lastIndex)){let S=this.getMatcher(0);S.lastIndex=this.lastIndex+1,E=S.exec(m)}return E&&(this.regexIndex+=E.position+1,this.regexIndex===this.count&&this.considerAll()),E}}function d(g){let m=new c;return g.contains.forEach(w=>m.addRule(w.begin,{rule:w,type:"begin"})),g.terminatorEnd&&m.addRule(g.terminatorEnd,{type:"end"}),g.illegal&&m.addRule(g.illegal,{type:"illegal"}),m}function p(g,m){let w=g;if(g.isCompiled)return w;[yc,xc,Mc,Ec].forEach(S=>S(g,m)),t.compilerExtensions.forEach(S=>S(g,m)),g.__beforeBegin=null,[wc,vc,kc].forEach(S=>S(g,m)),g.isCompiled=!0;let E=null;return typeof g.keywords=="object"&&g.keywords.$pattern&&(g.keywords=Object.assign({},g.keywords),E=g.keywords.$pattern,delete g.keywords.$pattern),E=E||/\w+/,g.keywords&&(g.keywords=vi(g.keywords,t.case_insensitive)),w.keywordPatternRe=o(E,!0),m&&(g.begin||(g.begin=/\B|\b/),w.beginRe=o(w.begin),!g.end&&!g.endsWithParent&&(g.end=/\B|\b/),g.end&&(w.endRe=o(w.end)),w.terminatorEnd=Vr(w.end)||"",g.endsWithParent&&m.terminatorEnd&&(w.terminatorEnd+=(g.end?"|":"")+m.terminatorEnd)),g.illegal&&(w.illegalRe=o(g.illegal)),g.contains||(g.contains=[]),g.contains=[].concat(...g.contains.map(function(S){return Lc(S==="self"?g:S)})),g.contains.forEach(function(S){p(S,w)}),g.starts&&p(g.starts,m),w.matcher=d(w),w}if(t.compilerExtensions||(t.compilerExtensions=[]),t.contains&&t.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return t.classNameAliases=nr(t.classNameAliases||{}),p(t)}function ki(t){return t?t.endsWithParent||ki(t.starts):!1}function Lc(t){return t.variants&&!t.cachedVariants&&(t.cachedVariants=t.variants.map(function(o){return nr(t,{variants:null},o)})),t.cachedVariants?t.cachedVariants:ki(t)?nr(t,{starts:t.starts?nr(t.starts):null}):Object.isFrozen(t)?nr(t):t}var Rc="11.11.1",ro=class extends Error{constructor(o,a){super(o),this.name="HTMLInjectionError",this.html=a}},Qs=hi,di=nr,ui=Symbol("nomatch"),Ic=7,Ei=function(t){let o=Object.create(null),a=Object.create(null),c=[],d=!0,p="Could not find the language '{}', did you forget to load/include a language module?",g={disableAutodetect:!0,name:"Plain text",contains:[]},m={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:no};function w(G){return m.noHighlightRe.test(G)}function E(G){let J=G.className+" ";J+=G.parentNode?G.parentNode.className:"";let ne=m.languageDetectRe.exec(J);if(ne){let fe=_e(ne[1]);return fe||(ci(p.replace("{}",ne[1])),ci("Falling back to no-highlight mode for this block.",G)),fe?ne[1]:"no-highlight"}return J.split(/\s+/).find(fe=>w(fe)||_e(fe))}function S(G,J,ne){let fe="",ue="";typeof J=="object"?(fe=G,ne=J.ignoreIllegals,ue=J.language):($r("10.7.0","highlight(lang, code, ...args) has been deprecated."),$r("10.7.0",`Please use highlight(code, options) instead.
3
+ https://github.com/highlightjs/highlight.js/issues/2277`),ue=G,fe=J),ne===void 0&&(ne=!0);let Ie={code:fe,language:ue};mt("before:highlight",Ie);let Q=Ie.result?Ie.result:P(Ie.language,Ie.code,ne);return Q.code=Ie.code,mt("after:highlight",Q),Q}function P(G,J,ne,fe){let ue=Object.create(null);function Ie(ke,Ee){return ke.keywords[Ee]}function Q(){if(!F.keywords){ce.addText(Ne);return}let ke=0;F.keywordPatternRe.lastIndex=0;let Ee=F.keywordPatternRe.exec(Ne),re="";for(;Ee;){re+=Ne.substring(ke,Ee.index);let Ge=ze.case_insensitive?Ee[0].toLowerCase():Ee[0],ht=Ie(F,Ge);if(ht){let[tt,He]=ht;if(ce.addText(re),re="",ue[Ge]=(ue[Ge]||0)+1,ue[Ge]<=Ic&&(ee+=He),tt.startsWith("_"))re+=Ee[0];else{let gt=ze.classNameAliases[tt]||tt;O(Ee[0],gt)}}else re+=Ee[0];ke=F.keywordPatternRe.lastIndex,Ee=F.keywordPatternRe.exec(Ne)}re+=Ne.substring(ke),ce.addText(re)}function s(){if(Ne==="")return;let ke=null;if(typeof F.subLanguage=="string"){if(!o[F.subLanguage]){ce.addText(Ne);return}ke=P(F.subLanguage,Ne,!0,Ce[F.subLanguage]),Ce[F.subLanguage]=ke._top}else ke=_(Ne,F.subLanguage.length?F.subLanguage:null);F.relevance>0&&(ee+=ke.relevance),ce.__addSublanguage(ke._emitter,ke.language)}function i(){F.subLanguage!=null?s():Q(),Ne=""}function O(ke,Ee){ke!==""&&(ce.startScope(Ee),ce.addText(ke),ce.endScope())}function De(ke,Ee){let re=1,Ge=Ee.length-1;for(;re<=Ge;){if(!ke._emit[re]){re++;continue}let ht=ze.classNameAliases[ke[re]]||ke[re],tt=Ee[re];ht?O(tt,ht):(Ne=tt,Q(),Ne=""),re++}}function B(ke,Ee){return ke.scope&&typeof ke.scope=="string"&&ce.openNode(ze.classNameAliases[ke.scope]||ke.scope),ke.beginScope&&(ke.beginScope._wrap?(O(Ne,ze.classNameAliases[ke.beginScope._wrap]||ke.beginScope._wrap),Ne=""):ke.beginScope._multi&&(De(ke.beginScope,Ee),Ne="")),F=Object.create(ke,{parent:{value:F}}),F}function Pe(ke,Ee,re){let Ge=Jl(ke.endRe,re);if(Ge){if(ke["on:end"]){let ht=new vs(ke);ke["on:end"](Ee,ht),ht.isMatchIgnored&&(Ge=!1)}if(Ge){for(;ke.endsParent&&ke.parent;)ke=ke.parent;return ke}}if(ke.endsWithParent)return Pe(ke.parent,Ee,re)}function _t(ke){return F.matcher.regexIndex===0?(Ne+=ke[0],1):(ut=!0,0)}function W(ke){let Ee=ke[0],re=ke.rule,Ge=new vs(re),ht=[re.__beforeBegin,re["on:begin"]];for(let tt of ht)if(tt&&(tt(ke,Ge),Ge.isMatchIgnored))return _t(Ee);return re.skip?Ne+=Ee:(re.excludeBegin&&(Ne+=Ee),i(),!re.returnBegin&&!re.excludeBegin&&(Ne=Ee)),B(re,ke),re.returnBegin?0:Ee.length}function ye(ke){let Ee=ke[0],re=J.substring(ke.index),Ge=Pe(F,ke,re);if(!Ge)return ui;let ht=F;F.endScope&&F.endScope._wrap?(i(),O(Ee,F.endScope._wrap)):F.endScope&&F.endScope._multi?(i(),De(F.endScope,ke)):ht.skip?Ne+=Ee:(ht.returnEnd||ht.excludeEnd||(Ne+=Ee),i(),ht.excludeEnd&&(Ne=Ee));do F.scope&&ce.closeNode(),!F.skip&&!F.subLanguage&&(ee+=F.relevance),F=F.parent;while(F!==Ge.parent);return Ge.starts&&B(Ge.starts,ke),ht.returnEnd?0:Ee.length}function ie(){let ke=[];for(let Ee=F;Ee!==ze;Ee=Ee.parent)Ee.scope&&ke.unshift(Ee.scope);ke.forEach(Ee=>ce.openNode(Ee))}let Ze={};function v(ke,Ee){let re=Ee&&Ee[0];if(Ne+=ke,re==null)return i(),0;if(Ze.type==="begin"&&Ee.type==="end"&&Ze.index===Ee.index&&re===""){if(Ne+=J.slice(Ee.index,Ee.index+1),!d){let Ge=new Error(`0 width match regex (${G})`);throw Ge.languageName=G,Ge.badRule=Ze.rule,Ge}return 1}if(Ze=Ee,Ee.type==="begin")return W(Ee);if(Ee.type==="illegal"&&!ne){let Ge=new Error('Illegal lexeme "'+re+'" for mode "'+(F.scope||"<unnamed>")+'"');throw Ge.mode=F,Ge}else if(Ee.type==="end"){let Ge=ye(Ee);if(Ge!==ui)return Ge}if(Ee.type==="illegal"&&re==="")return Ne+=`
4
+ `,1;if(pt>1e5&&pt>Ee.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Ne+=re,re.length}let ze=_e(G);if(!ze)throw gr(p.replace("{}",G)),new Error('Unknown language: "'+G+'"');let f=Oc(ze),Y="",F=fe||f,Ce={},ce=new m.__emitter(m);ie();let Ne="",ee=0,nt=0,pt=0,ut=!1;try{if(ze.__emitTokens)ze.__emitTokens(J,ce);else{for(F.matcher.considerAll();;){pt++,ut?ut=!1:F.matcher.considerAll(),F.matcher.lastIndex=nt;let ke=F.matcher.exec(J);if(!ke)break;let Ee=J.substring(nt,ke.index),re=v(Ee,ke);nt=ke.index+re}v(J.substring(nt))}return ce.finalize(),Y=ce.toHTML(),{language:G,value:Y,relevance:ee,illegal:!1,_emitter:ce,_top:F}}catch(ke){if(ke.message&&ke.message.includes("Illegal"))return{language:G,value:Qs(J),illegal:!0,relevance:0,_illegalBy:{message:ke.message,index:nt,context:J.slice(nt-100,nt+100),mode:ke.mode,resultSoFar:Y},_emitter:ce};if(d)return{language:G,value:Qs(J),illegal:!1,relevance:0,errorRaised:ke,_emitter:ce,_top:F};throw ke}}function $(G){let J={value:Qs(G),illegal:!1,relevance:0,_top:g,_emitter:new m.__emitter(m)};return J._emitter.addText(G),J}function _(G,J){J=J||m.languages||Object.keys(o);let ne=$(G),fe=J.filter(_e).filter(st).map(i=>P(i,G,!1));fe.unshift(ne);let ue=fe.sort((i,O)=>{if(i.relevance!==O.relevance)return O.relevance-i.relevance;if(i.language&&O.language){if(_e(i.language).supersetOf===O.language)return 1;if(_e(O.language).supersetOf===i.language)return-1}return 0}),[Ie,Q]=ue,s=Ie;return s.secondBest=Q,s}function C(G,J,ne){let fe=J&&a[J]||ne;G.classList.add("hljs"),G.classList.add(`language-${fe}`)}function I(G){let J=null,ne=E(G);if(w(ne))return;if(mt("before:highlightElement",{el:G,language:ne}),G.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",G);return}if(G.children.length>0&&(m.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(G)),m.throwUnescapedHTML))throw new ro("One of your code blocks includes unescaped HTML.",G.innerHTML);J=G;let fe=J.textContent,ue=ne?S(fe,{language:ne,ignoreIllegals:!0}):_(fe);G.innerHTML=ue.value,G.dataset.highlighted="yes",C(G,ne,ue.language),G.result={language:ue.language,re:ue.relevance,relevance:ue.relevance},ue.secondBest&&(G.secondBest={language:ue.secondBest.language,relevance:ue.secondBest.relevance}),mt("after:highlightElement",{el:G,result:ue,text:fe})}function Se(G){m=di(m,G)}let de=()=>{ae(),$r("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function $e(){ae(),$r("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let te=!1;function ae(){function G(){ae()}if(document.readyState==="loading"){te||window.addEventListener("DOMContentLoaded",G,!1),te=!0;return}document.querySelectorAll(m.cssSelector).forEach(I)}function Re(G,J){let ne=null;try{ne=J(t)}catch(fe){if(gr("Language definition for '{}' could not be registered.".replace("{}",G)),d)gr(fe);else throw fe;ne=g}ne.name||(ne.name=G),o[G]=ne,ne.rawDefinition=J.bind(null,t),ne.aliases&&Ae(ne.aliases,{languageName:G})}function Fe(G){delete o[G];for(let J of Object.keys(a))a[J]===G&&delete a[J]}function je(){return Object.keys(o)}function _e(G){return G=(G||"").toLowerCase(),o[G]||o[a[G]]}function Ae(G,{languageName:J}){typeof G=="string"&&(G=[G]),G.forEach(ne=>{a[ne.toLowerCase()]=J})}function st(G){let J=_e(G);return J&&!J.disableAutodetect}function bt(G){G["before:highlightBlock"]&&!G["before:highlightElement"]&&(G["before:highlightElement"]=J=>{G["before:highlightBlock"](Object.assign({block:J.el},J))}),G["after:highlightBlock"]&&!G["after:highlightElement"]&&(G["after:highlightElement"]=J=>{G["after:highlightBlock"](Object.assign({block:J.el},J))})}function T(G){bt(G),c.push(G)}function Ke(G){let J=c.indexOf(G);J!==-1&&c.splice(J,1)}function mt(G,J){let ne=G;c.forEach(function(fe){fe[ne]&&fe[ne](J)})}function dt(G){return $r("10.7.0","highlightBlock will be removed entirely in v12.0"),$r("10.7.0","Please use highlightElement now."),I(G)}Object.assign(t,{highlight:S,highlightAuto:_,highlightAll:ae,highlightElement:I,highlightBlock:dt,configure:Se,initHighlighting:de,initHighlightingOnLoad:$e,registerLanguage:Re,unregisterLanguage:Fe,listLanguages:je,getLanguage:_e,registerAliases:Ae,autoDetection:st,inherit:di,addPlugin:T,removePlugin:Ke}),t.debugMode=function(){d=!1},t.safeMode=function(){d=!0},t.versionString=Rc,t.regex={concat:br,lookahead:mi,either:so,optional:Yl,anyNumberOfTimes:Zl};for(let G in ws)typeof ws[G]=="object"&&pi(ws[G]);return Object.assign(t,ws),t},Cr=Ei({});Cr.newInstance=()=>Ei({});Si.exports=Cr;Cr.HighlightJS=Cr;Cr.default=Cr});var au={};ml(au,{init:()=>ou,initTerminals:()=>iu,registerBuildProvider:()=>Qr,version:()=>su});ge();be();ge();be();ge();be();var wl=new Set(["UL","OL","TABLE","TBODY","DL","SVG"]),vl=new Set(["defs","title","desc","style","metadata"]),Fo=new Map;function zo(t,o){Fo.set(t,o)}function bs(t){return[...t.children].filter(o=>{let a=o.tagName.toLowerCase();return!(vl.has(a)||a==="aside"&&o.classList.contains("notes")||o.hasAttribute("data-build-stay"))})}function xl(t){if(t.hasAttribute("data-build-self"))return!1;let o=t.tagName.toUpperCase();return wl.has(o)?!0:o==="DIV"||o==="G"?bs(t).length>=2:!1}function kl(t){if(t.tagName.toUpperCase()==="TABLE"){let a=t.querySelector(":scope > tbody");return a?bs(a):bs(t).filter(c=>c.tagName==="TR")}return bs(t)}function El(t){let o=t.map((g,m)=>({...g,i:m}));o.sort((g,m)=>g.key-m.key||g.i-m.i);let a=[],c=null,d=null,p=!1;for(let g of o){if(c&&g.explicit&&p&&g.key===d){c.push(g.i);continue}c=[g.i],d=g.key,p=g.explicit,a.push(c)}return a}function Do(t,o){t.classList.add("build-step"),t.setAttribute("data-build-style",o),t.setAttribute("data-build-state","pending"),o==="draw"&&Sl(t)}var qo="path, line, polyline, polygon, circle, ellipse, rect";function Sl(t){let o=t.matches?.(qo)?[t]:[...t.querySelectorAll(qo)],a=!1;for(let d of o){let p=d.getAttribute("stroke")??getComputedStyle(d).stroke;if(!p||p==="none")continue;let g=0;try{g=d.getTotalLength()}catch{continue}if(!g)continue;a=!0;let m=d.getAttribute("stroke-dasharray")||d.style.strokeDasharray;m&&(d.dataset.drawOrig=m);for(let[w,E]of Ys){let S=d.getAttribute(w);S&&(d.dataset[E]=S)}d.classList.add("draw-stroke"),d.style.setProperty("--draw-len",String(Math.ceil(g)))}t.querySelectorAll("text, tspan").forEach(d=>d.classList.add("draw-fade")),a||t.setAttribute("data-build-style","fade")}var Ys=[["marker-start","drawMarkerStart"],["marker-mid","drawMarkerMid"],["marker-end","drawMarkerEnd"]];function gs(t,o){for(let[a,c]of Ys)c in t.dataset&&(o?t.setAttribute(a,t.dataset[c]):t.removeAttribute(a))}function Al(t,o){for(let a of t.querySelectorAll(".draw-stroke")){let c=a.dataset.drawOrig,d=Ys.some(([,p])=>p in a.dataset);if(!(!c&&!d))if(o==="done")c&&(a.style.strokeDasharray=c,a.style.strokeDashoffset="0"),gs(a,!0);else if(o==="pending")a.style.removeProperty("stroke-dasharray"),a.style.removeProperty("stroke-dashoffset"),gs(a,!1);else{a.style.removeProperty("stroke-dasharray"),a.style.removeProperty("stroke-dashoffset"),gs(a,!1);let p=()=>{t.getAttribute("data-build-state")!=="pending"&&(c&&(a.style.strokeDasharray=c,a.style.strokeDashoffset="0"),gs(a,!0))},g=parseFloat(getComputedStyle(a).transitionDuration)||0;g===0?p():(a.addEventListener("transitionend",p,{once:!0}),setTimeout(p,g*1e3+150))}}}function Xs(t){let o=[],a=[],c=new Set,d=0,p=(S,P)=>{let $=P!=null&&P!=="",_=$?parseInt(P,10):d;o.push(S),a.push({key:Number.isFinite(_)?_:d,explicit:$}),d++},g=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);for(let S=g.nextNode();S;S=g.nextNode()){if(c.has(S))continue;let P=Fo.get(S);if(P){for(let _=0;_<P.count;_++)p({kind:"provider",provider:P,el:S,sub:_},null);S.querySelectorAll("*").forEach(_=>c.add(_));continue}if(!S.hasAttribute("data-build"))continue;let $=S.getAttribute("data-build")||"fade";if(xl(S)){for(let _ of kl(S)){c.add(_),_.querySelectorAll("[data-build]").forEach(I=>c.add(I));let C=_.getAttribute("data-build")||$;Do(_,C),p({kind:"dom",el:_,container:S},_.getAttribute("data-build-order"))}S.setAttribute("data-build-container","")}else Do(S,$),p({kind:"dom",el:S,container:null},S.getAttribute("data-build-order"))}let m=El(a),w=[],E=new Map;return o.forEach((S,P)=>{if(S.kind==="provider"){if(!E.has(S.provider)){let $={el:S.el,provider:S.provider,stepIdxs:[]};E.set(S.provider,$),w.push($)}E.get(S.provider).stepIdxs.push(P)}}),{steps:o,groups:m,providers:w}}function tr(t,o){let a=new Set;t.groups.forEach((g,m)=>{for(let w of g)m<o&&a.add(w)});let c=o>0?t.groups[o-1]??[]:[],d=new Set(c),p=new Set;t.steps.forEach((g,m)=>{if(g.kind!=="dom")return;let w=d.has(m)?"current":a.has(m)?"done":"pending";g.el.setAttribute("data-build-state",w),g.el.getAttribute("data-build-style")==="draw"&&Al(g.el,w),g.container&&p.add(g.container)});for(let g of p){let m=!!g.querySelector(':scope [data-build-style="highlight"][data-build-state="current"]');g.classList.toggle("has-current-highlight",m)}for(let g of t.providers){let m=g.stepIdxs.filter(w=>a.has(w)||d.has(w)).length;g._last!==m&&(g._last=m,g.provider.apply(m))}}function Uo(t){return t.groups.map(o=>{let a=t.steps[o[0]];if(a.kind==="provider"){let d=a.sub;return a.provider.label?a.provider.label(d+1):"step"}return a.el.textContent.trim().replace(/\s+/g," ").slice(0,60)||a.el.tagName.toLowerCase()})}ge();be();var Ho="rect, circle, ellipse, polygon, polyline, path";function _l(t){let o=5381;for(let a of String(t))o=(o*33^a.charCodeAt(0))>>>0;return 1+o%6}function Tl(t,o={}){let a=o[t];return typeof a=="number"?`var(--d-fill-${a})`:typeof a=="string"?a:`var(--d-fill-${_l(t)})`}function jo(t,o={}){let a=new Map;t.querySelectorAll("svg [data-concept]").forEach(c=>{let d=c.getAttribute("data-concept");if(!d)return;let p=Tl(d,o),g=p.match(/--d-fill-(\d)/);if(g){let w=a.get(g[1]);w&&w!==d?console.warn(`Decklight: concepts "${w}" and "${d}" share fill slot ${g[1]} \u2014 pin one explicitly via init({ concepts: { ${d}: <1-6> } })`):a.set(g[1],d)}let m=c.matches(Ho)?[c]:[...c.children].filter(w=>w.matches(Ho));for(let w of m){let E=w.getAttribute("fill")==="none"||w.style.fill==="none";w.style.setProperty(E?"stroke":"fill",p)}})}var $l=["fill","stroke","filter","clip-path","mask","marker-start","marker-mid","marker-end","style"];function Go(t){t.querySelectorAll("svg").forEach((o,a)=>{let c=`svg${a}-`,d=new Map;if(o.querySelectorAll("[id]").forEach(g=>{let m=g.id;d.set(m,c+m),g.id=c+m}),d.size===0)return;let p=g=>g.replace(/url\(['"]?#([^'")]+)['"]?\)/g,(m,w)=>d.has(w)?`url(#${d.get(w)})`:m);o.querySelectorAll("*").forEach(g=>{for(let m of $l){let w=g.getAttribute(m);w&&w.includes("url(#")&&g.setAttribute(m,p(w))}for(let m of["href","xlink:href"]){let w=g.getAttribute(m);w&&w.startsWith("#")&&d.has(w.slice(1))&&g.setAttribute(m,"#"+d.get(w.slice(1)))}})})}ge();be();ge();be();var $t=t=>String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");var Ko=640,Cl=360,Wo=["bar","line","area","pie","donut"],Ue=t=>{let o=Math.round(t*100)/100;return Object.is(o,-0)?"0":String(o)},_r=t=>`var(--d-fill-${t%6+1})`;function Nl(t,o={}){let a;if(typeof t=="string")try{a=JSON.parse(t)}catch(E){throw new Error(`invalid JSON \u2014 ${E.message}`)}else if(t&&typeof t=="object")a=t;else throw new Error('no data \u2014 expected a <script type="application/json"> child (or the fence body)');let c=String(o.type||a.type||"").toLowerCase();if(!Wo.includes(c))throw new Error(`unknown type "${c}" \u2014 use ${Wo.join(" | ")}`);if(!Array.isArray(a.labels)||a.labels.length===0)throw new Error('"labels" must be a non-empty array');if(!Array.isArray(a.series)||a.series.length===0)throw new Error('"series" must be a non-empty array');let d=a.labels.map(String),p=a.series.map((E,S)=>{if(!E||!Array.isArray(E.data))throw new Error(`series ${S+1}: "data" must be an array of numbers`);return{name:E.name!=null?String(E.name):`series ${S+1}`,concept:E.concept!=null?String(E.concept):null,data:d.map((P,$)=>{let _=Number(E.data[$]);return Number.isFinite(_)?_:null})}}),g=c==="pie"||c==="donut";if(g&&p.length>1)throw new Error("pie takes exactly one series (labels are the slices)");if(g&&!p[0].data.some(E=>E>0))throw new Error("pie needs at least one positive value");let m=Cl,w=o.aspect??a.aspect??null;if(w!=null){let E=String(w).match(/^\s*(\d+(?:\.\d+)?)\s*[:x]\s*(\d+(?:\.\d+)?)\s*$/i);if(!E||+E[1]==0)throw new Error(`bad aspect "${w}" \u2014 use "w:h", e.g. "4:3"`);m=Math.round(Ko*+E[2]/+E[1])}return{type:g?"pie":c,donut:c==="donut"||a.donut===!0,title:o.title??(a.title!=null?String(a.title):null),labels:d,series:p,legend:a.legend,width:Ko,height:m,build:a.build}}function Ml(t,o,a=5){if(!Number.isFinite(t)||!Number.isFinite(o))throw new Error("niceTicks: non-finite range");if(t>o&&([t,o]=[o,t]),t===o){let P=t===0?1:Math.abs(t)/2;t-=t===0?0:P,o+=P}let c=(o-t)/Math.max(1,a-1),d=10**Math.floor(Math.log10(c)),p=c/d,g=(p<=1?1:p<=2?2:p<=2.5?2.5:p<=5?5:10)*d,m=Math.floor(t/g+1e-9)*g,w=Math.ceil(o/g-1e-9)*g,E=Math.max(1,Math.round((w-m)/g)),S=Array.from({length:E+1},(P,$)=>+(m+$*g).toPrecision(12));return{min:S[0],max:S[E],step:g,ticks:S}}function Ol(t,o){let a=0;for(;a<6&&Math.abs(Math.round(o*10**a)-o*10**a)>1e-9;)a++;return t.toFixed(a)}function Ll(t,o,a,c){let d=c.max-c.min||1,p=S=>a.y+a.h*(1-(S-c.min)/d),g=p(Math.max(c.min,Math.min(c.max,0))),m=a.w/o,w=m*.72,E=w/t.length;return t.map((S,P)=>Array.from({length:o},($,_)=>{let C=S.data[_];if(C==null||!Number.isFinite(C))return null;let I=p(C);return{x:a.x+_*m+(m-w)/2+P*E+1,y:Math.min(I,g),w:Math.max(1,E-2),h:Math.abs(g-I),value:C}}))}function Rl(t){let o="",a=!1;for(let c of t){if(!c){a=!1;continue}o+=`${a?"L":"M"}${Ue(c.x)} ${Ue(c.y)}`,a=!0}return o}function Il(t,o){let a=t.filter(Boolean);if(!a.length)return"";let c=`M${Ue(a[0].x)} ${Ue(o)}`;for(let d of a)c+=`L${Ue(d.x)} ${Ue(d.y)}`;return c+=`L${Ue(a[a.length-1].x)} ${Ue(o)}Z`,c}function Pl(t,o,a,c,d=0){let p=t.map(E=>Math.max(0,Number(E)||0)),g=p.reduce((E,S)=>E+S,0);if(g<=0)throw new Error("pie needs at least one positive value");let m=(E,S)=>[o+S*Math.cos(E),a+S*Math.sin(E)],w=-Math.PI/2;return p.map(E=>{let S=E/g,P=w,$=w+S*2*Math.PI;w=$;let _=(P+$)/2,C=d>0?(c+d)/2:c*.66,[I,Se]=m(_,C),[de,$e]=m(_,c+14),te={value:E,frac:S,mid:_,labelX:I,labelY:Se,outX:de,outY:$e,anchor:Math.cos(_)<-1e-6?"end":Math.cos(_)>1e-6?"start":"middle"};if(S===0)return{...te,d:""};let ae;if(S>=.9999){let[Re,Fe]=m(P,c),[je,_e]=m(P+Math.PI,c);if(ae=`M${Ue(Re)} ${Ue(Fe)}A${Ue(c)} ${Ue(c)} 0 1 1 ${Ue(je)} ${Ue(_e)}A${Ue(c)} ${Ue(c)} 0 1 1 ${Ue(Re)} ${Ue(Fe)}Z`,d>0){let[Ae,st]=m(P,d),[bt,T]=m(P+Math.PI,d);ae+=`M${Ue(Ae)} ${Ue(st)}A${Ue(d)} ${Ue(d)} 0 1 0 ${Ue(bt)} ${Ue(T)}A${Ue(d)} ${Ue(d)} 0 1 0 ${Ue(Ae)} ${Ue(st)}Z`}}else{let Re=$-P>Math.PI?1:0,[Fe,je]=m(P,c),[_e,Ae]=m($,c);if(d>0){let[st,bt]=m($,d),[T,Ke]=m(P,d);ae=`M${Ue(Fe)} ${Ue(je)}A${Ue(c)} ${Ue(c)} 0 ${Re} 1 ${Ue(_e)} ${Ue(Ae)}L${Ue(st)} ${Ue(bt)}A${Ue(d)} ${Ue(d)} 0 ${Re} 0 ${Ue(T)} ${Ue(Ke)}Z`}else ae=`M${Ue(o)} ${Ue(a)}L${Ue(Fe)} ${Ue(je)}A${Ue(c)} ${Ue(c)} 0 ${Re} 1 ${Ue(_e)} ${Ue(Ae)}Z`}return{...te,d:ae}})}var Tr='fill="var(--d-text)"';function Js(t,o){return`<g class="chart-series" data-series="${o+1}" data-name="${$t(t.name)}"`+(t.concept?` data-concept="${$t(t.concept)}"`:"")+">"}function Bl(t,o,a){let c=t.series.flatMap(C=>C.data).filter(C=>C!=null),d=Math.min(0,...c),p=Math.max(0,...c),g=Ml(d,p===d?d+1:p,5),m=g.ticks.map(C=>Ol(C,g.step)),w=14+Math.max(...m.map(C=>C.length))*6.6+8,E={x:w,y:t.title||Vo(t)?40:18,w:t.width-w-14,h:0};E.h=t.height-E.y-34;let S=g.max-g.min||1,P=C=>E.y+E.h*(1-(C-g.min)/S);g.ticks.forEach((C,I)=>{let Se=P(C);o.push(`<line class="chart-grid" x1="${Ue(E.x)}" y1="${Ue(Se)}" x2="${Ue(E.x+E.w)}" y2="${Ue(Se)}" stroke="var(--d-muted)" stroke-opacity="0.35" stroke-width="1"/>`),o.push(`<text class="chart-tick" x="${Ue(E.x-8)}" y="${Ue(Se+4)}" text-anchor="end" font-size="11" ${Tr}>${$t(m[I])}</text>`)}),o.push(`<line class="chart-axis" x1="${Ue(E.x)}" y1="${Ue(E.y)}" x2="${Ue(E.x)}" y2="${Ue(E.y+E.h)}" stroke="var(--d-stroke)" stroke-width="1.5"/>`);let $=P(Math.max(g.min,Math.min(g.max,0)));o.push(`<line class="chart-axis" x1="${Ue(E.x)}" y1="${Ue($)}" x2="${Ue(E.x+E.w)}" y2="${Ue($)}" stroke="var(--d-stroke)" stroke-width="1.5"/>`);let _=E.w/t.labels.length;if(t.labels.forEach((C,I)=>{o.push(`<text class="chart-cat" x="${Ue(E.x+(I+.5)*_)}" y="${Ue(E.y+E.h+20)}" text-anchor="middle" font-size="12" ${Tr}>${$t(C)}</text>`)}),t.type==="bar"){let C=Ll(t.series,t.labels.length,E,g);t.series.forEach((I,Se)=>{a.push(Js(I,Se)),C[Se].forEach(de=>{de&&a.push(`<rect class="chart-bar draw-fade" x="${Ue(de.x)}" y="${Ue(de.y)}" width="${Ue(de.w)}" height="${Ue(de.h)}" rx="2" fill="${_r(Se)}" stroke="var(--d-stroke)" stroke-width="1.5"/>`)}),a.push("</g>")})}else t.series.forEach((C,I)=>{let Se=C.data.map((te,ae)=>te==null?null:{x:E.x+(ae+.5)*_,y:P(te)}),de=Rl(Se),$e='stroke-linejoin="round" stroke-linecap="round"';if(a.push(Js(C,I)),t.type==="area"&&a.push(`<path class="chart-area draw-fade" d="${Il(Se,$)}" fill="${_r(I)}" fill-opacity="0.35"/>`),a.push(`<g class="chart-casing"><path d="${de}" fill="none" stroke="var(--d-stroke)" stroke-width="4.5" ${$e}/></g>`),a.push(`<path class="chart-line" d="${de}" fill="none" stroke="${_r(I)}" stroke-width="2.5" ${$e}/>`),t.type==="line")for(let te of Se)te&&a.push(`<circle class="chart-dot draw-fade" cx="${Ue(te.x)}" cy="${Ue(te.y)}" r="4" fill="${_r(I)}" stroke="var(--d-stroke)" stroke-width="1"/>`);a.push("</g>")})}function Dl(t,o){let a=t.title?40:16,c=t.width/2,d=a+(t.height-a-12)/2,p=Math.max(24,Math.min((t.height-a-12)/2-26,t.width/2-110)),g=Pl(t.series[0].data.map(m=>m??0),c,d,p,t.donut?p*.55:0);o.push(Js(t.series[0],0)),g.forEach((m,w)=>{m.d&&(o.push(`<path class="chart-slice draw-fade" d="${m.d}" fill="${_r(w)}" fill-rule="evenodd" stroke="var(--d-stroke)" stroke-width="1.5" stroke-linejoin="round"/>`),o.push(`<text class="chart-cat draw-fade" x="${Ue(m.outX)}" y="${Ue(m.outY+4)}" text-anchor="${m.anchor}" font-size="12" ${Tr}>${$t(t.labels[w])}</text>`),m.frac>=.05&&o.push(`<text class="chart-value draw-fade" x="${Ue(m.labelX)}" y="${Ue(m.labelY+4)}" text-anchor="middle" font-size="12" font-weight="600" ${Tr}>${Math.round(m.frac*100)}%</text>`))}),o.push("</g>")}function Vo(t){return t.legend===!0?!0:t.legend===!1?!1:t.type!=="pie"&&t.series.length>1}function ql(t){let o=[],a=[];if(t.title&&o.push(`<text class="chart-title" x="14" y="24" font-size="15" font-weight="600" ${Tr}>${$t(t.title)}</text>`),Vo(t)){let d=t.series.map(g=>({name:g.name,w:g.name.length*6.6+24})),p=t.width-14-d.reduce((g,m)=>g+m.w,0);t.series.forEach((g,m)=>{o.push(`<rect class="chart-swatch" x="${Ue(p)}" y="14" width="11" height="11" rx="2" fill="${_r(m)}" stroke="var(--d-stroke)" stroke-width="1"/>`),o.push(`<text class="chart-legend" x="${Ue(p+16)}" y="24" font-size="12" ${Tr}>${$t(g.name)}</text>`),p+=d[m].w})}t.type==="pie"?Dl(t,a):Bl(t,o,a);let c=t.title?`${t.title} \u2014 ${t.type} chart`:`${t.type} chart`;return`<svg class="chart-svg" viewBox="0 0 ${t.width} ${t.height}" role="img" aria-label="${$t(c)}" preserveAspectRatio="xMidYMid meet"><g class="chart-chrome" data-build-stay>${o.join("")}</g>`+a.join("")+"</svg>"}function Zo(t){t.querySelectorAll("[data-chart]").forEach(o=>{if(o.querySelector(":scope > svg.chart-svg, :scope > .chart-broken"))return;o.classList.add("chart");let a=o.querySelector('script[type="application/json"]');try{let c=Nl(a?a.textContent:null,{type:o.getAttribute("data-chart")||void 0,title:o.getAttribute("data-title")||void 0,aspect:o.getAttribute("data-aspect")||void 0}),d=document.createElement("template");d.innerHTML=ql(c);let p=d.content.firstElementChild;o.hasAttribute("data-build")?(p.setAttribute("data-build",o.getAttribute("data-build")),o.removeAttribute("data-build")):c.build!=null&&c.build!==!1&&p.setAttribute("data-build",c.build===!0?"":String(c.build)),o.getAttribute("data-chart")||o.setAttribute("data-chart",c.donut?"donut":c.type),o.insertBefore(p,a)}catch(c){let d=document.createElement("div");d.className="chart-broken",d.textContent=`chart: ${c.message||c}`,o.insertBefore(d,a)}})}ge();be();ge();be();function ys(t,o){let a=String(t??"").trim(),c=parseFloat(a);return!Number.isFinite(c)||c<=0?o:a.endsWith("ms")?c:a.endsWith("s")?c*1e3:c}var Wr=["opacity","color","backgroundColor","borderRadius","fontSize"],Yo=(t=Wr)=>["transform",...t.map(o=>o.replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`))];function Xo(t,o,a,c=!1){let d=a?.x||1,p=a?.y||1,g=(t.rect.left-o.rect.left)/d,m=(t.rect.top-o.rect.top)/p,w=c||!o.rect.width?1:t.rect.width/o.rect.width,E=c||!o.rect.height?1:t.rect.height/o.rect.height;return{dx:g,dy:m,sx:w,sy:E}}function Jo({dx:t,dy:o,sx:a,sy:c}){return!t&&!o&&a===1&&c===1?"":`translate(${t}px, ${o}px) scale(${a}, ${c})`}var Qo=(t,o)=>t||o||"fade";function ei(t,o){if(t==="none")return null;let a=`dir-${o}`;return{entering:["entering",`tr-${t}`,a],leaving:["leaving",`tr-${t}`,a,"active-out"]}}var Fl=Yo();function ti(t){let o=getComputedStyle(t),a={rect:t.getBoundingClientRect()};for(let c of Wr)a[c]=o[c];return a}function zl(t,o){if(t.ownerSVGElement){let a=t.getScreenCTM?.();if(a&&a.a&&a.d)return{x:a.a,y:a.d}}return{x:o,y:o}}function ni(t,o,a){let c=ys(getComputedStyle(o).getPropertyValue("--auto-animate-duration"),500),d=new Map;t.querySelectorAll("[data-id]").forEach(m=>{d.set(m.getAttribute("data-id"),ti(m))});let p=[];o.querySelectorAll("[data-id]").forEach(m=>{let w=d.get(m.getAttribute("data-id"));w&&p.push({el:m,o:w})});for(let{el:m,o:w}of p){let E=ti(m),S=zl(m,a),P=m.children.length===0&&w.fontSize!==E.fontSize,$=Xo(w,E,S,P),_=m.getAttribute("style")??"";m.style.transition="none",m.ownerSVGElement&&(m.style.transformBox="fill-box"),m.style.transformOrigin="0 0",m.style.transform=Jo($);for(let I of Wr)m.style[I]=w[I];m.offsetWidth,m.style.transition=Fl.map(I=>`${I} ${c}ms ease`).join(", "),m.style.transform="";for(let I of Wr)m.style[I]=E[I];let C=()=>{_?m.setAttribute("style",_):m.removeAttribute("style"),m.removeEventListener("transitionend",C)};m.addEventListener("transitionend",C),setTimeout(C,c+80)}let g=new Set(p.map(m=>m.el));return[...o.children].forEach(m=>{m.matches("aside.notes")||g.has(m)||[...g].some(E=>m.contains(E))||(m.classList.add("aa-fresh"),requestAnimationFrame(()=>requestAnimationFrame(()=>m.classList.add("aa-in"))),setTimeout(()=>m.classList.remove("aa-fresh","aa-in"),c+120))}),c}ge();be();ge();be();var ri=function(){"use strict";class t{constructor(n,r){let l,u=" "+n,h=r&&r.loc;if(h&&h.start<=h.end){let x=h.lexer.input;l=h.start;let q=h.end;l===x.length?u+=" at end of input: ":u+=" at position "+(l+1)+`:
5
+ `;let Z=x.slice(l,q).replace(/[^]/g,"$&\u0332"),ve,Te;ve=l>15?"\u2026"+x.slice(l-15,l):x.slice(0,l),Te=q+15<x.length?x.slice(q,q+15)+"\u2026":x.slice(q),u+=ve+Z+Te}let y=new Error(u);return y.name="ParseError",y.__proto__=t.prototype,y.position=l,y}}t.prototype.__proto__=Error.prototype;let o=function(e,n){return e===void 0?n:e},a=/([A-Z])/g,c=function(e){return e.replace(a,"-$1").toLowerCase()},d={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},p=/[&><"']/g;function g(e){return String(e).replace(p,n=>d[n])}let m=function(e){return e.type==="ordgroup"||e.type==="color"?e.body.length===1?m(e.body[0]):e:e.type==="font"?m(e.body):e},w=function(e){let n=m(e);return n.type==="mathord"||n.type==="textord"||n.type==="atom"},E=function(e){return+e.toFixed(4)},S="aceg\u0131\u0237mnopqrsuvwxyz\u03B1\u03B3\u03B5\u03B7\u03B9\u03BA\u03BC\u03BD\u03BF\u03C0\u03C1\u03C2\u03C3\u03C4\u03C5\u03C7\u03C9\u03D5\u{1D41A}\u{1D41C}\u{1D41E}\u{1D420}\u{1D426}\u{1D427}\u{1D428}\u{1D429}\u{1D42A}\u{1D42B}\u{1D42C}\u{1D42E}\u{1D42F}\u{1D430}\u{1D431}\u{1D432}\u{1D433}";class P{constructor(n){n=n||{},this.displayMode=o(n.displayMode,!1),this.annotate=o(n.annotate,!1),this.leqno=o(n.leqno,!1),this.throwOnError=o(n.throwOnError,!1),this.errorColor=o(n.errorColor,"#b22222"),this.macros=n.macros||{},this.wrap=o(n.wrap,"none"),this.xml=o(n.xml,!1),this.colorIsTextColor=o(n.colorIsTextColor,!1),this.strict=o(n.strict,!1),this.trust=o(n.trust,!1),this.maxSize=n.maxSize===void 0?[1/0,1/0]:Array.isArray(n.maxSize)?n.maxSize:[1/0,1/0],this.maxExpand=Math.max(0,o(n.maxExpand,1e3)),this.wrapDelimiterPairs=!0}isTrusted(n){if(n.url&&!n.protocol){let l=function(u){let h=/^[\x00-\x20]*([^\\/#?]*?)(:|&#0*58|&#x0*3a|&colon)/i.exec(u);return h?h[2]!==":"?null:/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(h[1])?h[1].toLowerCase():null:"_relative"}(n.url);if(l==null)return!1;n.protocol=l}return!!(typeof this.trust=="function"?this.trust(n):this.trust)}}let $={},_={};function C({type:e,names:n,props:r,handler:l,mathmlBuilder:u}){let h={type:e,numArgs:r.numArgs,argTypes:r.argTypes,allowedInArgument:!!r.allowedInArgument,allowedInText:!!r.allowedInText,allowedInMath:r.allowedInMath===void 0||r.allowedInMath,numOptionalArgs:r.numOptionalArgs||0,infix:!!r.infix,primitive:!!r.primitive,handler:l};for(let y=0;y<n.length;++y)$[n[y]]=h;e&&u&&(_[e]=u)}function I({type:e,mathmlBuilder:n}){C({type:e,names:[],props:{numArgs:0},handler(){throw new Error("Should never be called.")},mathmlBuilder:n})}let Se=function(e){return e.type==="ordgroup"&&e.body.length===1?e.body[0]:e},de=function(e){return e.type==="ordgroup"?e.body:[e]};class $e{constructor(n){this.children=n,this.classes=[],this.style={}}hasClass(n){return this.classes.includes(n)}toNode(){let n=document.createDocumentFragment();for(let r=0;r<this.children.length;r++)n.appendChild(this.children[r].toNode());return n}toMarkup(){let n="";for(let r=0;r<this.children.length;r++)n+=this.children[r].toMarkup();return n}toText(){return this.children.map(n=>n.toText()).join("")}}let te=function(e){return e.filter(n=>n).join(" ")},ae=function(e,n){this.classes=e||[],this.attributes={},this.style=n||{}},Re=function(e){let n=document.createElement(e);n.className=te(this.classes);for(let r in this.style)Object.prototype.hasOwnProperty.call(this.style,r)&&(n.style[r]=this.style[r]);for(let r in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,r)&&n.setAttribute(r,this.attributes[r]);for(let r=0;r<this.children.length;r++)n.appendChild(this.children[r].toNode());return n},Fe=function(e){let n=`<${e}`;this.classes.length&&(n+=` class="${g(te(this.classes))}"`);let r="";for(let l in this.style)Object.prototype.hasOwnProperty.call(this.style,l)&&(r+=`${c(l)}:${this.style[l]};`);r&&(n+=` style="${r}"`);for(let l in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,l)&&(n+=` ${l}="${g(this.attributes[l])}"`);n+=">";for(let l=0;l<this.children.length;l++)n+=this.children[l].toMarkup();return n+=`</${e}>`,n};class je{constructor(n,r,l){ae.call(this,n,l),this.children=r||[]}setAttribute(n,r){this.attributes[n]=r}toNode(){return Re.call(this,"span")}toMarkup(){return Fe.call(this,"span")}}let _e=class{constructor(e){this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return g(this.text)}};class Ae{constructor(n,r,l){this.href=n,this.classes=r,this.children=l||[]}toNode(){let n=document.createElement("a");n.setAttribute("href",this.href),this.classes.length>0&&(n.className=te(this.classes));for(let r=0;r<this.children.length;r++)n.appendChild(this.children[r].toNode());return n}toMarkup(){let n=`<a href='${g(this.href)}'`;this.classes.length>0&&(n+=` class="${g(te(this.classes))}"`),n+=">";for(let r=0;r<this.children.length;r++)n+=this.children[r].toMarkup();return n+="</a>",n}}class st{constructor(n,r,l){this.alt=r,this.src=n,this.classes=["mord"],this.style=l}hasClass(n){return this.classes.includes(n)}toNode(){let n=document.createElement("img");n.src=this.src,n.alt=this.alt,n.className="mord";for(let r in this.style)Object.prototype.hasOwnProperty.call(this.style,r)&&(n.style[r]=this.style[r]);return n}toMarkup(){let n=`<img src='${this.src}' alt='${this.alt}'`,r="";for(let l in this.style)Object.prototype.hasOwnProperty.call(this.style,l)&&(r+=`${c(l)}:${this.style[l]};`);return r&&(n+=` style="${g(r)}"`),n+=">",n}}function bt(e){return new $e(e)}class T{constructor(n,r,l,u){this.type=n,this.attributes={},this.children=r||[],this.classes=l||[],this.style=u||{},this.label=""}setAttribute(n,r){this.attributes[n]=r}getAttribute(n){return this.attributes[n]}setLabel(n){this.label=n}toNode(){let n=document.createElementNS("http://www.w3.org/1998/Math/MathML",this.type);for(let r in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,r)&&n.setAttribute(r,this.attributes[r]);this.classes.length>0&&(n.className=te(this.classes));for(let r in this.style)Object.prototype.hasOwnProperty.call(this.style,r)&&(n.style[r]=this.style[r]);for(let r=0;r<this.children.length;r++)n.appendChild(this.children[r].toNode());return n}toMarkup(){let n="<"+this.type;for(let l in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,l)&&(n+=" "+l+'="',n+=g(this.attributes[l]),n+='"');this.classes.length>0&&(n+=` class="${g(te(this.classes))}"`);let r="";for(let l in this.style)Object.prototype.hasOwnProperty.call(this.style,l)&&(r+=`${c(l)}:${this.style[l]};`);r&&(n+=` style="${r}"`),n+=">";for(let l=0;l<this.children.length;l++)n+=this.children[l].toMarkup();return n+="</"+this.type+">",n}toText(){return this.children.map(n=>n.toText()).join("")}}class Ke{constructor(n){this.text=n}toNode(){return document.createTextNode(this.text)}toMarkup(){return g(this.toText())}toText(){return this.text}}let mt=e=>{let n;return e.length===1&&e[0].type==="mrow"?(n=e.pop(),n.type="mstyle"):n=new T("mstyle",e),n},dt=e=>{let n=0;if(e.body&&Array.isArray(e.body))for(let r of e.body)n+=dt(r);else if(e.body)n+=dt(e.body);else if(e.type==="supsub")n+=dt(e.base),e.sub&&(n+=.7*dt(e.sub)),e.sup&&(n+=.7*dt(e.sup));else if(e.type==="mathord"||e.type==="textord")for(let r of e.text.split("")){let l=r.codePointAt(0);n+=96<l&&l<123||944<l&&l<970?.56:47<l&&l<58?.5:.92}else n+=1;return n},G={widehat:"^",widecheck:"\u02C7",widetilde:"~",wideparen:"\u23DC",utilde:"~",overleftarrow:"\u2190",underleftarrow:"\u2190",xleftarrow:"\u2190",overrightarrow:"\u2192",underrightarrow:"\u2192",xrightarrow:"\u2192",underbrace:"\u23DF",overbrace:"\u23DE",overbracket:"\u23B4",underbracket:"\u23B5",overgroup:"\u23E0",overparen:"\u23DC",undergroup:"\u23E1",underparen:"\u23DD",overleftrightarrow:"\u2194",underleftrightarrow:"\u2194",xleftrightarrow:"\u2194",Overrightarrow:"\u21D2",xRightarrow:"\u21D2",overleftharpoon:"\u21BC",xleftharpoonup:"\u21BC",overrightharpoon:"\u21C0",xrightharpoonup:"\u21C0",xLeftarrow:"\u21D0",xLeftrightarrow:"\u21D4",xhookleftarrow:"\u21A9",xhookrightarrow:"\u21AA",xmapsto:"\u21A6",xrightharpoondown:"\u21C1",xleftharpoondown:"\u21BD",xtwoheadleftarrow:"\u219E",xtwoheadrightarrow:"\u21A0",xlongequal:"=",xrightleftarrows:"\u21C4",xtofrom:"\u21C4",xleftrightharpoons:"\u21CB",xrightleftharpoons:"\u21CC",yields:"\u2192",yieldsLeft:"\u2190",mesomerism:"\u2194",longrightharpoonup:"\u21C0",longleftharpoondown:"\u21BD",eqrightharpoonup:"\u21C0",eqleftharpoondown:"\u21BD","\\cdrightarrow":"\u2192","\\cdleftarrow":"\u2190","\\cdlongequal":"=",yieldsLeftRight:"\u21C4",chemequilibrium:"\u21CC"},J=function(e){let n=new Ke(G[e.slice(1)]),r=new T("mo",[n]);return r.setAttribute("stretchy","true"),r},ne=["\\widetilde","\\widehat","\\widecheck","\\utilde"],fe=e=>{let n=J(e.label);if(ne.includes(e.label)){let r=dt(e.base);1<r&&r<1.6?n.classes.push("tml-crooked-2"):1.6<=r&&r<2.5?n.classes.push("tml-crooked-3"):2.5<=r&&n.classes.push("tml-crooked-4")}return n},ue={bin:1,close:1,inner:1,open:1,punct:1,rel:1},Ie={"accent-token":1,mathord:1,"op-token":1,spacing:1,textord:1},Q={math:{},text:{}};function s(e,n,r,l,u){Q[e][l]={group:n,replace:r},u&&r&&(Q[e][r]=Q[e][l])}let i="math",O="text",De="accent-token",B="bin",Pe="close",_t="inner",W="mathord",ye="op-token",ie="open",Ze="punct",v="rel",ze="spacing",f="textord";s(i,v,"\u2261","\\equiv",!0),s(i,v,"\u227A","\\prec",!0),s(i,v,"\u227B","\\succ",!0),s(i,v,"\u223C","\\sim",!0),s(i,v,"\u27C2","\\perp",!0),s(i,v,"\u2AAF","\\preceq",!0),s(i,v,"\u2AB0","\\succeq",!0),s(i,v,"\u2243","\\simeq",!0),s(i,v,"\u224C","\\backcong",!0),s(i,v,"|","\\mid",!0),s(i,v,"\u226A","\\ll",!0),s(i,v,"\u226B","\\gg",!0),s(i,v,"\u224D","\\asymp",!0),s(i,v,"\u2225","\\parallel"),s(i,v,"\u2323","\\smile",!0),s(i,v,"\u2291","\\sqsubseteq",!0),s(i,v,"\u2292","\\sqsupseteq",!0),s(i,v,"\u2250","\\doteq",!0),s(i,v,"\u2322","\\frown",!0),s(i,v,"\u220B","\\ni",!0),s(i,v,"\u220C","\\notni",!0),s(i,v,"\u221D","\\propto",!0),s(i,v,"\u22A2","\\vdash",!0),s(i,v,"\u22A3","\\dashv",!0),s(i,v,"\u220B","\\owns"),s(i,v,"\u2258","\\arceq",!0),s(i,v,"\u2259","\\wedgeq",!0),s(i,v,"\u225A","\\veeeq",!0),s(i,v,"\u225B","\\stareq",!0),s(i,v,"\u225D","\\eqdef",!0),s(i,v,"\u225E","\\measeq",!0),s(i,v,"\u225F","\\questeq",!0),s(i,v,"\u2260","\\ne",!0),s(i,v,"\u2260","\\neq"),s(i,v,"\u2A75","\\eqeq",!0),s(i,v,"\u2A76","\\eqeqeq",!0),s(i,v,"\u2237","\\dblcolon",!0),s(i,v,"\u2254","\\coloneqq",!0),s(i,v,"\u2255","\\eqqcolon",!0),s(i,v,"\u2239","\\eqcolon",!0),s(i,v,"\u2A74","\\Coloneqq",!0),s(i,Ze,".","\\ldotp"),s(i,Ze,"\xB7","\\cdotp"),s(i,f,"#","\\#"),s(O,f,"#","\\#"),s(i,f,"&","\\&"),s(O,f,"&","\\&"),s(i,f,"\u2135","\\aleph",!0),s(i,f,"\u2200","\\forall",!0),s(i,f,"\u210F","\\hbar",!0),s(i,f,"\u2203","\\exists",!0),s(i,ie,"\u2207","\\nabla",!0),s(i,f,"\u266D","\\flat",!0),s(i,f,"\u2113","\\ell",!0),s(i,f,"\u266E","\\natural",!0),s(i,f,"\u212B","\\Angstrom",!0),s(O,f,"\u212B","\\Angstrom",!0),s(i,f,"\u2663","\\clubsuit",!0),s(i,f,"\u2667","\\varclubsuit",!0),s(i,f,"\u2118","\\wp",!0),s(i,f,"\u266F","\\sharp",!0),s(i,f,"\u2662","\\diamondsuit",!0),s(i,f,"\u2666","\\vardiamondsuit",!0),s(i,f,"\u211C","\\Re",!0),s(i,f,"\u2661","\\heartsuit",!0),s(i,f,"\u2665","\\varheartsuit",!0),s(i,f,"\u2111","\\Im",!0),s(i,f,"\u2660","\\spadesuit",!0),s(i,f,"\u2664","\\varspadesuit",!0),s(i,f,"\u2640","\\female",!0),s(i,f,"\u2642","\\male",!0),s(i,f,"\xA7","\\S",!0),s(O,f,"\xA7","\\S"),s(i,f,"\xB6","\\P",!0),s(O,f,"\xB6","\\P"),s(O,f,"\u263A","\\smiley",!0),s(i,f,"\u263A","\\smiley",!0),s(i,f,"\u2020","\\dag"),s(O,f,"\u2020","\\dag"),s(O,f,"\u2020","\\textdagger"),s(i,f,"\u2021","\\ddag"),s(O,f,"\u2021","\\ddag"),s(O,f,"\u2021","\\textdaggerdbl"),s(i,Pe,"\u23B1","\\rmoustache",!0),s(i,ie,"\u23B0","\\lmoustache",!0),s(i,Pe,"\u27EF","\\rgroup",!0),s(i,ie,"\u27EE","\\lgroup",!0),s(i,B,"\u2213","\\mp",!0),s(i,B,"\u2296","\\ominus",!0),s(i,B,"\u228E","\\uplus",!0),s(i,B,"\u2293","\\sqcap",!0),s(i,B,"\u2217","\\ast"),s(i,B,"\u2294","\\sqcup",!0),s(i,B,"\u25EF","\\bigcirc",!0),s(i,B,"\u2219","\\bullet",!0),s(i,B,"\u2021","\\ddagger"),s(i,B,"\u2240","\\wr",!0),s(i,B,"\u2A3F","\\amalg"),s(i,B,"&","\\And"),s(i,B,"\u2AFD","\\sslash",!0),s(i,v,"\u27F5","\\longleftarrow",!0),s(i,v,"\u21D0","\\Leftarrow",!0),s(i,v,"\u27F8","\\Longleftarrow",!0),s(i,v,"\u27F6","\\longrightarrow",!0),s(i,v,"\u21D2","\\Rightarrow",!0),s(i,v,"\u27F9","\\Longrightarrow",!0),s(i,v,"\u2194","\\leftrightarrow",!0),s(i,v,"\u27F7","\\longleftrightarrow",!0),s(i,v,"\u21D4","\\Leftrightarrow",!0),s(i,v,"\u27FA","\\Longleftrightarrow",!0),s(i,v,"\u21A4","\\mapsfrom",!0),s(i,v,"\u21A6","\\mapsto",!0),s(i,v,"\u27FC","\\longmapsto",!0),s(i,v,"\u2197","\\nearrow",!0),s(i,v,"\u21A9","\\hookleftarrow",!0),s(i,v,"\u21AA","\\hookrightarrow",!0),s(i,v,"\u2198","\\searrow",!0),s(i,v,"\u21BC","\\leftharpoonup",!0),s(i,v,"\u21C0","\\rightharpoonup",!0),s(i,v,"\u2199","\\swarrow",!0),s(i,v,"\u21BD","\\leftharpoondown",!0),s(i,v,"\u21C1","\\rightharpoondown",!0),s(i,v,"\u2196","\\nwarrow",!0),s(i,v,"\u21CC","\\rightleftharpoons",!0),s(i,W,"\u21AF","\\lightning",!0),s(i,W,"\u220E","\\QED",!0),s(i,W,"\u2030","\\permil",!0),s(O,f,"\u2030","\\permil"),s(i,W,"\u2609","\\astrosun",!0),s(i,W,"\u263C","\\sun",!0),s(i,W,"\u263E","\\leftmoon",!0),s(i,W,"\u263D","\\rightmoon",!0),s(i,W,"\u2295","\\Earth"),s(i,v,"\u226E","\\nless",!0),s(i,v,"\u2A87","\\lneq",!0),s(i,v,"\u2268","\\lneqq",!0),s(i,v,"\u2268\uFE00","\\lvertneqq"),s(i,v,"\u22E6","\\lnsim",!0),s(i,v,"\u2A89","\\lnapprox",!0),s(i,v,"\u2280","\\nprec",!0),s(i,v,"\u22E0","\\npreceq",!0),s(i,v,"\u22E8","\\precnsim",!0),s(i,v,"\u2AB9","\\precnapprox",!0),s(i,v,"\u2241","\\nsim",!0),s(i,v,"\u2224","\\nmid",!0),s(i,v,"\u2224","\\nshortmid"),s(i,v,"\u22AC","\\nvdash",!0),s(i,v,"\u22AD","\\nvDash",!0),s(i,v,"\u22EA","\\ntriangleleft"),s(i,v,"\u22EC","\\ntrianglelefteq",!0),s(i,v,"\u2284","\\nsubset",!0),s(i,v,"\u2285","\\nsupset",!0),s(i,v,"\u228A","\\subsetneq",!0),s(i,v,"\u228A\uFE00","\\varsubsetneq"),s(i,v,"\u2ACB","\\subsetneqq",!0),s(i,v,"\u2ACB\uFE00","\\varsubsetneqq"),s(i,v,"\u226F","\\ngtr",!0),s(i,v,"\u2A88","\\gneq",!0),s(i,v,"\u2269","\\gneqq",!0),s(i,v,"\u2269\uFE00","\\gvertneqq"),s(i,v,"\u22E7","\\gnsim",!0),s(i,v,"\u2A8A","\\gnapprox",!0),s(i,v,"\u2281","\\nsucc",!0),s(i,v,"\u22E1","\\nsucceq",!0),s(i,v,"\u22E9","\\succnsim",!0),s(i,v,"\u2ABA","\\succnapprox",!0),s(i,v,"\u2246","\\ncong",!0),s(i,v,"\u2226","\\nparallel",!0),s(i,v,"\u2226","\\nshortparallel"),s(i,v,"\u22AF","\\nVDash",!0),s(i,v,"\u22EB","\\ntriangleright"),s(i,v,"\u22ED","\\ntrianglerighteq",!0),s(i,v,"\u228B","\\supsetneq",!0),s(i,v,"\u228B","\\varsupsetneq"),s(i,v,"\u2ACC","\\supsetneqq",!0),s(i,v,"\u2ACC\uFE00","\\varsupsetneqq"),s(i,v,"\u22AE","\\nVdash",!0),s(i,v,"\u2AB5","\\precneqq",!0),s(i,v,"\u2AB6","\\succneqq",!0),s(i,B,"\u22B4","\\unlhd"),s(i,B,"\u22B5","\\unrhd"),s(i,v,"\u219A","\\nleftarrow",!0),s(i,v,"\u219B","\\nrightarrow",!0),s(i,v,"\u21CD","\\nLeftarrow",!0),s(i,v,"\u21CF","\\nRightarrow",!0),s(i,v,"\u21AE","\\nleftrightarrow",!0),s(i,v,"\u21CE","\\nLeftrightarrow",!0),s(i,v,"\u25B3","\\vartriangle"),s(i,f,"\u210F","\\hslash"),s(i,f,"\u25BD","\\triangledown"),s(i,f,"\u25CA","\\lozenge"),s(i,f,"\u24C8","\\circledS"),s(i,f,"\xAE","\\circledR",!0),s(O,f,"\xAE","\\circledR"),s(O,f,"\xAE","\\textregistered"),s(i,f,"\u2221","\\measuredangle",!0),s(i,f,"\u2204","\\nexists"),s(i,f,"\u2127","\\mho"),s(i,f,"\u2132","\\Finv",!0),s(i,f,"\u2141","\\Game",!0),s(i,f,"\u2035","\\backprime"),s(i,f,"\u2036","\\backdprime"),s(i,f,"\u2037","\\backtrprime"),s(i,f,"\u25B2","\\blacktriangle"),s(i,f,"\u25BC","\\blacktriangledown"),s(i,f,"\u25A0","\\blacksquare"),s(i,f,"\u29EB","\\blacklozenge"),s(i,f,"\u2605","\\bigstar"),s(i,f,"\u2222","\\sphericalangle",!0),s(i,f,"\u2201","\\complement",!0),s(i,f,"\u2571","\\diagup"),s(i,f,"\u2572","\\diagdown"),s(i,f,"\u25A1","\\square"),s(i,f,"\u25A1","\\Box"),s(i,f,"\u25CA","\\Diamond"),s(i,f,"\xA5","\\yen",!0),s(O,f,"\xA5","\\yen",!0),s(i,f,"\u2713","\\checkmark",!0),s(O,f,"\u2713","\\checkmark"),s(i,f,"\u2717","\\ballotx",!0),s(O,f,"\u2717","\\ballotx"),s(O,f,"\u2022","\\textbullet"),s(i,f,"\u2136","\\beth",!0),s(i,f,"\u2138","\\daleth",!0),s(i,f,"\u2137","\\gimel",!0),s(i,f,"\u03DD","\\digamma",!0),s(i,f,"\u03F0","\\varkappa"),s(i,ie,"\u231C","\\ulcorner",!0),s(i,Pe,"\u231D","\\urcorner",!0),s(i,ie,"\u231E","\\llcorner",!0),s(i,Pe,"\u231F","\\lrcorner",!0),s(i,v,"\u2266","\\leqq",!0),s(i,v,"\u2A7D","\\leqslant",!0),s(i,v,"\u2A95","\\eqslantless",!0),s(i,v,"\u2272","\\lesssim",!0),s(i,v,"\u2A85","\\lessapprox",!0),s(i,v,"\u224A","\\approxeq",!0),s(i,B,"\u22D6","\\lessdot"),s(i,v,"\u22D8","\\lll",!0),s(i,v,"\u2276","\\lessgtr",!0),s(i,v,"\u22DA","\\lesseqgtr",!0),s(i,v,"\u2A8B","\\lesseqqgtr",!0),s(i,v,"\u2251","\\doteqdot"),s(i,v,"\u2253","\\risingdotseq",!0),s(i,v,"\u2252","\\fallingdotseq",!0),s(i,v,"\u223D","\\backsim",!0),s(i,v,"\u22CD","\\backsimeq",!0),s(i,v,"\u2AC5","\\subseteqq",!0),s(i,v,"\u22D0","\\Subset",!0),s(i,v,"\u228F","\\sqsubset",!0),s(i,v,"\u227C","\\preccurlyeq",!0),s(i,v,"\u22DE","\\curlyeqprec",!0),s(i,v,"\u227E","\\precsim",!0),s(i,v,"\u2AB7","\\precapprox",!0),s(i,v,"\u22B2","\\vartriangleleft"),s(i,v,"\u22B4","\\trianglelefteq"),s(i,v,"\u22A8","\\vDash",!0),s(i,v,"\u22AB","\\VDash",!0),s(i,v,"\u22AA","\\Vvdash",!0),s(i,v,"\u2323","\\smallsmile"),s(i,v,"\u2322","\\smallfrown"),s(i,v,"\u224F","\\bumpeq",!0),s(i,v,"\u224E","\\Bumpeq",!0),s(i,v,"\u2267","\\geqq",!0),s(i,v,"\u2A7E","\\geqslant",!0),s(i,v,"\u2A96","\\eqslantgtr",!0),s(i,v,"\u2273","\\gtrsim",!0),s(i,v,"\u2A86","\\gtrapprox",!0),s(i,B,"\u22D7","\\gtrdot"),s(i,v,"\u22D9","\\ggg",!0),s(i,v,"\u2277","\\gtrless",!0),s(i,v,"\u22DB","\\gtreqless",!0),s(i,v,"\u2A8C","\\gtreqqless",!0),s(i,v,"\u2256","\\eqcirc",!0),s(i,v,"\u2257","\\circeq",!0),s(i,v,"\u225C","\\triangleq",!0),s(i,v,"\u223C","\\thicksim"),s(i,v,"\u2248","\\thickapprox"),s(i,v,"\u2AC6","\\supseteqq",!0),s(i,v,"\u22D1","\\Supset",!0),s(i,v,"\u2290","\\sqsupset",!0),s(i,v,"\u227D","\\succcurlyeq",!0),s(i,v,"\u22DF","\\curlyeqsucc",!0),s(i,v,"\u227F","\\succsim",!0),s(i,v,"\u2AB8","\\succapprox",!0),s(i,v,"\u22B3","\\vartriangleright"),s(i,v,"\u22B5","\\trianglerighteq"),s(i,v,"\u22A9","\\Vdash",!0),s(i,v,"\u2223","\\shortmid"),s(i,v,"\u2225","\\shortparallel"),s(i,v,"\u226C","\\between",!0),s(i,v,"\u22D4","\\pitchfork",!0),s(i,v,"\u221D","\\varpropto"),s(i,v,"\u25C0","\\blacktriangleleft"),s(i,v,"\u2234","\\therefore",!0),s(i,v,"\u220D","\\backepsilon"),s(i,v,"\u25B6","\\blacktriangleright"),s(i,v,"\u2235","\\because",!0),s(i,v,"\u22D8","\\llless"),s(i,v,"\u22D9","\\gggtr"),s(i,B,"\u22B2","\\lhd"),s(i,B,"\u22B3","\\rhd"),s(i,v,"\u2242","\\eqsim",!0),s(i,v,"\u2251","\\Doteq",!0),s(i,v,"\u297D","\\strictif",!0),s(i,v,"\u297C","\\strictfi",!0),s(i,B,"\u2214","\\dotplus",!0),s(i,B,"\u2216","\\smallsetminus"),s(i,B,"\u22D2","\\Cap",!0),s(i,B,"\u22D3","\\Cup",!0),s(i,B,"\u2A5E","\\doublebarwedge",!0),s(i,B,"\u229F","\\boxminus",!0),s(i,B,"\u229E","\\boxplus",!0),s(i,B,"\u29C4","\\boxslash",!0),s(i,B,"\u22C7","\\divideontimes",!0),s(i,B,"\u22C9","\\ltimes",!0),s(i,B,"\u22CA","\\rtimes",!0),s(i,B,"\u22CB","\\leftthreetimes",!0),s(i,B,"\u22CC","\\rightthreetimes",!0),s(i,B,"\u22CF","\\curlywedge",!0),s(i,B,"\u22CE","\\curlyvee",!0),s(i,B,"\u229D","\\circleddash",!0),s(i,B,"\u229B","\\circledast",!0),s(i,B,"\u22BA","\\intercal",!0),s(i,B,"\u22D2","\\doublecap"),s(i,B,"\u22D3","\\doublecup"),s(i,B,"\u22A0","\\boxtimes",!0),s(i,B,"\u22C8","\\bowtie",!0),s(i,B,"\u22C8","\\Join"),s(i,B,"\u27D5","\\leftouterjoin",!0),s(i,B,"\u27D6","\\rightouterjoin",!0),s(i,B,"\u27D7","\\fullouterjoin",!0),s(i,B,"\u2238","\\dotminus",!0),s(i,B,"\u27D1","\\wedgedot",!0),s(i,B,"\u27C7","\\veedot",!0),s(i,B,"\u2A62","\\doublebarvee",!0),s(i,B,"\u2A63","\\veedoublebar",!0),s(i,B,"\u2A5F","\\wedgebar",!0),s(i,B,"\u2A60","\\wedgedoublebar",!0),s(i,B,"\u2A54","\\Vee",!0),s(i,B,"\u2A53","\\Wedge",!0),s(i,B,"\u2A43","\\barcap",!0),s(i,B,"\u2A42","\\barcup",!0),s(i,B,"\u2A48","\\capbarcup",!0),s(i,B,"\u2A40","\\capdot",!0),s(i,B,"\u2A47","\\capovercup",!0),s(i,B,"\u2A46","\\cupovercap",!0),s(i,B,"\u2A4D","\\closedvarcap",!0),s(i,B,"\u2A4C","\\closedvarcup",!0),s(i,B,"\u2A2A","\\minusdot",!0),s(i,B,"\u2A2B","\\minusfdots",!0),s(i,B,"\u2A2C","\\minusrdots",!0),s(i,B,"\u22BB","\\Xor",!0),s(i,B,"\u22BC","\\Nand",!0),s(i,B,"\u22BD","\\Nor",!0),s(i,B,"\u22BD","\\barvee"),s(i,B,"\u2AF4","\\interleave",!0),s(i,B,"\u29E2","\\shuffle",!0),s(i,B,"\u2AF6","\\threedotcolon",!0),s(i,B,"\u2982","\\typecolon",!0),s(i,B,"\u223E","\\invlazys",!0),s(i,B,"\u2A4B","\\twocaps",!0),s(i,B,"\u2A4A","\\twocups",!0),s(i,B,"\u2A4E","\\Sqcap",!0),s(i,B,"\u2A4F","\\Sqcup",!0),s(i,B,"\u2A56","\\veeonvee",!0),s(i,B,"\u2A55","\\wedgeonwedge",!0),s(i,B,"\u29D7","\\blackhourglass",!0),s(i,B,"\u29C6","\\boxast",!0),s(i,B,"\u29C8","\\boxbox",!0),s(i,B,"\u29C7","\\boxcircle",!0),s(i,B,"\u229C","\\circledequal",!0),s(i,B,"\u29B7","\\circledparallel",!0),s(i,B,"\u29B6","\\circledvert",!0),s(i,B,"\u29B5","\\circlehbar",!0),s(i,B,"\u27E1","\\concavediamond",!0),s(i,B,"\u27E2","\\concavediamondtickleft",!0),s(i,B,"\u27E3","\\concavediamondtickright",!0),s(i,B,"\u22C4","\\diamond",!0),s(i,B,"\u29D6","\\hourglass",!0),s(i,B,"\u27E0","\\lozengeminus",!0),s(i,B,"\u233D","\\obar",!0),s(i,B,"\u29B8","\\obslash",!0),s(i,B,"\u2A38","\\odiv",!0),s(i,B,"\u29C1","\\ogreaterthan",!0),s(i,B,"\u29C0","\\olessthan",!0),s(i,B,"\u29B9","\\operp",!0),s(i,B,"\u2A37","\\Otimes",!0),s(i,B,"\u2A36","\\otimeshat",!0),s(i,B,"\u22C6","\\star",!0),s(i,B,"\u25B3","\\triangle",!0),s(i,B,"\u2A3A","\\triangleminus",!0),s(i,B,"\u2A39","\\triangleplus",!0),s(i,B,"\u2A3B","\\triangletimes",!0),s(i,B,"\u27E4","\\whitesquaretickleft",!0),s(i,B,"\u27E5","\\whitesquaretickright",!0),s(i,B,"\u2A33","\\smashtimes",!0),s(i,v,"\u21E2","\\dashrightarrow",!0),s(i,v,"\u21E0","\\dashleftarrow",!0),s(i,v,"\u21C7","\\leftleftarrows",!0),s(i,v,"\u21C6","\\leftrightarrows",!0),s(i,v,"\u21DA","\\Lleftarrow",!0),s(i,v,"\u219E","\\twoheadleftarrow",!0),s(i,v,"\u21A2","\\leftarrowtail",!0),s(i,v,"\u21AB","\\looparrowleft",!0),s(i,v,"\u21CB","\\leftrightharpoons",!0),s(i,v,"\u21B6","\\curvearrowleft",!0),s(i,v,"\u21BA","\\circlearrowleft",!0),s(i,v,"\u21B0","\\Lsh",!0),s(i,v,"\u21C8","\\upuparrows",!0),s(i,v,"\u21BF","\\upharpoonleft",!0),s(i,v,"\u21C3","\\downharpoonleft",!0),s(i,v,"\u22B6","\\origof",!0),s(i,v,"\u22B7","\\imageof",!0),s(i,v,"\u22B8","\\multimap",!0),s(i,v,"\u21AD","\\leftrightsquigarrow",!0),s(i,v,"\u21C9","\\rightrightarrows",!0),s(i,v,"\u21C4","\\rightleftarrows",!0),s(i,v,"\u21A0","\\twoheadrightarrow",!0),s(i,v,"\u21A3","\\rightarrowtail",!0),s(i,v,"\u21AC","\\looparrowright",!0),s(i,v,"\u21B7","\\curvearrowright",!0),s(i,v,"\u21BB","\\circlearrowright",!0),s(i,v,"\u21B1","\\Rsh",!0),s(i,v,"\u21CA","\\downdownarrows",!0),s(i,v,"\u21BE","\\upharpoonright",!0),s(i,v,"\u21C2","\\downharpoonright",!0),s(i,v,"\u21DD","\\rightsquigarrow",!0),s(i,v,"\u21DD","\\leadsto"),s(i,v,"\u21DB","\\Rrightarrow",!0),s(i,v,"\u21BE","\\restriction"),s(i,f,"\u2018","`"),s(i,f,"$","\\$"),s(O,f,"$","\\$"),s(O,f,"$","\\textdollar"),s(i,f,"\xA2","\\cent"),s(O,f,"\xA2","\\cent"),s(i,f,"%","\\%"),s(O,f,"%","\\%"),s(i,f,"_","\\_"),s(O,f,"_","\\_"),s(O,f,"_","\\textunderscore"),s(O,f,"\u2423","\\textvisiblespace",!0),s(i,f,"\u2220","\\angle",!0),s(i,f,"\u221E","\\infty",!0),s(i,f,"\u2032","\\prime"),s(i,f,"\u2033","\\dprime"),s(i,f,"\u2034","\\trprime"),s(i,f,"\u2057","\\qprime"),s(i,f,"\u25B3","\\triangle"),s(O,f,"\u0391","\\Alpha",!0),s(O,f,"\u0392","\\Beta",!0),s(O,f,"\u0393","\\Gamma",!0),s(O,f,"\u0394","\\Delta",!0),s(O,f,"\u0395","\\Epsilon",!0),s(O,f,"\u0396","\\Zeta",!0),s(O,f,"\u0397","\\Eta",!0),s(O,f,"\u0398","\\Theta",!0),s(O,f,"\u0399","\\Iota",!0),s(O,f,"\u039A","\\Kappa",!0),s(O,f,"\u039B","\\Lambda",!0),s(O,f,"\u039C","\\Mu",!0),s(O,f,"\u039D","\\Nu",!0),s(O,f,"\u039E","\\Xi",!0),s(O,f,"\u039F","\\Omicron",!0),s(O,f,"\u03A0","\\Pi",!0),s(O,f,"\u03A1","\\Rho",!0),s(O,f,"\u03A3","\\Sigma",!0),s(O,f,"\u03A4","\\Tau",!0),s(O,f,"\u03A5","\\Upsilon",!0),s(O,f,"\u03A6","\\Phi",!0),s(O,f,"\u03A7","\\Chi",!0),s(O,f,"\u03A8","\\Psi",!0),s(O,f,"\u03A9","\\Omega",!0),s(i,W,"\u0391","\\Alpha",!0),s(i,W,"\u0392","\\Beta",!0),s(i,W,"\u0393","\\Gamma",!0),s(i,W,"\u0394","\\Delta",!0),s(i,W,"\u0395","\\Epsilon",!0),s(i,W,"\u0396","\\Zeta",!0),s(i,W,"\u0397","\\Eta",!0),s(i,W,"\u0398","\\Theta",!0),s(i,W,"\u0399","\\Iota",!0),s(i,W,"\u039A","\\Kappa",!0),s(i,W,"\u039B","\\Lambda",!0),s(i,W,"\u039C","\\Mu",!0),s(i,W,"\u039D","\\Nu",!0),s(i,W,"\u039E","\\Xi",!0),s(i,W,"\u039F","\\Omicron",!0),s(i,W,"\u03A0","\\Pi",!0),s(i,W,"\u03A1","\\Rho",!0),s(i,W,"\u03A3","\\Sigma",!0),s(i,W,"\u03A4","\\Tau",!0),s(i,W,"\u03A5","\\Upsilon",!0),s(i,W,"\u03A6","\\Phi",!0),s(i,W,"\u03A7","\\Chi",!0),s(i,W,"\u03A8","\\Psi",!0),s(i,W,"\u03A9","\\Omega",!0),s(i,ie,"\xAC","\\neg",!0),s(i,ie,"\xAC","\\lnot"),s(i,f,"\u22A4","\\top"),s(i,f,"\u22A5","\\bot"),s(i,f,"\u2205","\\emptyset"),s(i,f,"\u2300","\\varnothing"),s(i,W,"\u03B1","\\alpha",!0),s(i,W,"\u03B2","\\beta",!0),s(i,W,"\u03B3","\\gamma",!0),s(i,W,"\u03B4","\\delta",!0),s(i,W,"\u03F5","\\epsilon",!0),s(i,W,"\u03B6","\\zeta",!0),s(i,W,"\u03B7","\\eta",!0),s(i,W,"\u03B8","\\theta",!0),s(i,W,"\u03B9","\\iota",!0),s(i,W,"\u03BA","\\kappa",!0),s(i,W,"\u03BB","\\lambda",!0),s(i,W,"\u03BC","\\mu",!0),s(i,W,"\u03BD","\\nu",!0),s(i,W,"\u03BE","\\xi",!0),s(i,W,"\u03BF","\\omicron",!0),s(i,W,"\u03C0","\\pi",!0),s(i,W,"\u03C1","\\rho",!0),s(i,W,"\u03C3","\\sigma",!0),s(i,W,"\u03C4","\\tau",!0),s(i,W,"\u03C5","\\upsilon",!0),s(i,W,"\u03D5","\\phi",!0),s(i,W,"\u03C7","\\chi",!0),s(i,W,"\u03C8","\\psi",!0),s(i,W,"\u03C9","\\omega",!0),s(i,W,"\u03B5","\\varepsilon",!0),s(i,W,"\u03D1","\\vartheta",!0),s(i,W,"\u03D6","\\varpi",!0),s(i,W,"\u03F1","\\varrho",!0),s(i,W,"\u03C2","\\varsigma",!0),s(i,W,"\u03C6","\\varphi",!0),s(i,W,"\u03D8","\\Coppa",!0),s(i,W,"\u03D9","\\coppa",!0),s(i,W,"\u03D9","\\varcoppa",!0),s(i,W,"\u03DE","\\Koppa",!0),s(i,W,"\u03DF","\\koppa",!0),s(i,W,"\u03E0","\\Sampi",!0),s(i,W,"\u03E1","\\sampi",!0),s(i,W,"\u03DA","\\Stigma",!0),s(i,W,"\u03DB","\\stigma",!0),s(i,W,"\u2AEB","\\Bot"),s(i,f,"\xF0","\\eth",!0),s(O,f,"\xF0","\xF0"),s(i,f,"\xC5","\\AA"),s(O,f,"\xC5","\\AA",!0),s(i,f,"\xC6","\\AE",!0),s(O,f,"\xC6","\\AE",!0),s(i,f,"\xD0","\\DH",!0),s(O,f,"\xD0","\\DH",!0),s(i,f,"\xDE","\\TH",!0),s(O,f,"\xDE","\\TH",!0),s(i,f,"\xDF","\\ss",!0),s(O,f,"\xDF","\\ss",!0),s(i,f,"\xE5","\\aa"),s(O,f,"\xE5","\\aa",!0),s(i,f,"\xE6","\\ae",!0),s(O,f,"\xE6","\\ae",!0),s(i,f,"\xF0","\\dh"),s(O,f,"\xF0","\\dh",!0),s(i,f,"\xFE","\\th",!0),s(O,f,"\xFE","\\th",!0),s(i,f,"\u0110","\\DJ",!0),s(O,f,"\u0110","\\DJ",!0),s(i,f,"\u0111","\\dj",!0),s(O,f,"\u0111","\\dj",!0),s(i,f,"\u0141","\\L",!0),s(O,f,"\u0141","\\L",!0),s(i,f,"\u0141","\\l",!0),s(O,f,"\u0141","\\l",!0),s(i,f,"\u014A","\\NG",!0),s(O,f,"\u014A","\\NG",!0),s(i,f,"\u014B","\\ng",!0),s(O,f,"\u014B","\\ng",!0),s(i,f,"\u0152","\\OE",!0),s(O,f,"\u0152","\\OE",!0),s(i,f,"\u0153","\\oe",!0),s(O,f,"\u0153","\\oe",!0),s(i,B,"\u2217","\u2217",!0),s(i,B,"+","+"),s(i,B,"\u2217","*"),s(i,B,"\u2044","/",!0),s(i,B,"\u2044","\u2044"),s(i,B,"\u2212","-",!0),s(i,B,"\u22C5","\\cdot",!0),s(i,B,"\u2218","\\circ",!0),s(i,B,"\xF7","\\div",!0),s(i,B,"\xB1","\\pm",!0),s(i,B,"\xD7","\\times",!0),s(i,B,"\u2229","\\cap",!0),s(i,B,"\u222A","\\cup",!0),s(i,B,"\u2216","\\setminus",!0),s(i,B,"\u2227","\\land"),s(i,B,"\u2228","\\lor"),s(i,B,"\u2227","\\wedge",!0),s(i,B,"\u2228","\\vee",!0),s(i,ie,"\u27E6","\\llbracket",!0),s(i,Pe,"\u27E7","\\rrbracket",!0),s(i,ie,"\u27E8","\\langle",!0),s(i,ie,"\u27EA","\\lAngle",!0),s(i,ie,"\u2989","\\llangle",!0),s(i,ie,"|","\\lvert"),s(i,ie,"\u2016","\\lVert",!0),s(i,f,"!","\\oc"),s(i,f,"?","\\wn"),s(i,f,"\u2193","\\shpos"),s(i,f,"\u2195","\\shift"),s(i,f,"\u2191","\\shneg"),s(i,Pe,"?","?"),s(i,Pe,"!","!"),s(i,Pe,"\u203C","\u203C"),s(i,Pe,"\u27E9","\\rangle",!0),s(i,Pe,"\u27EB","\\rAngle",!0),s(i,Pe,"\u298A","\\rrangle",!0),s(i,Pe,"|","\\rvert"),s(i,Pe,"\u2016","\\rVert"),s(i,ie,"\u2983","\\lBrace",!0),s(i,Pe,"\u2984","\\rBrace",!0),s(i,v,"=","\\equal",!0),s(i,v,":",":"),s(i,v,"\u2248","\\approx",!0),s(i,v,"\u2245","\\cong",!0),s(i,v,"\u2265","\\ge"),s(i,v,"\u2265","\\geq",!0),s(i,v,"\u2190","\\gets"),s(i,v,">","\\gt",!0),s(i,v,"\u2208","\\in",!0),s(i,v,"\u2209","\\notin",!0),s(i,v,"\uE020","\\@not"),s(i,v,"\u2282","\\subset",!0),s(i,v,"\u2283","\\supset",!0),s(i,v,"\u2286","\\subseteq",!0),s(i,v,"\u2287","\\supseteq",!0),s(i,v,"\u2288","\\nsubseteq",!0),s(i,v,"\u2288","\\nsubseteqq"),s(i,v,"\u2289","\\nsupseteq",!0),s(i,v,"\u2289","\\nsupseteqq"),s(i,v,"\u22A8","\\models"),s(i,v,"\u2190","\\leftarrow",!0),s(i,v,"\u2264","\\le"),s(i,v,"\u2264","\\leq",!0),s(i,v,"<","\\lt",!0),s(i,v,"\u2192","\\rightarrow",!0),s(i,v,"\u2192","\\to"),s(i,v,"\u2271","\\ngeq",!0),s(i,v,"\u2271","\\ngeqq"),s(i,v,"\u2271","\\ngeqslant"),s(i,v,"\u2270","\\nleq",!0),s(i,v,"\u2270","\\nleqq"),s(i,v,"\u2270","\\nleqslant"),s(i,v,"\u2AEB","\\Perp",!0),s(i,ze,"\xA0","\\ "),s(i,ze,"\xA0","\\space"),s(i,ze,"\xA0","\\nobreakspace"),s(O,ze,"\xA0","\\ "),s(O,ze,"\xA0"," "),s(O,ze,"\xA0","\\space"),s(O,ze,"\xA0","\\nobreakspace"),s(i,ze,null,"\\nobreak"),s(i,ze,null,"\\allowbreak"),s(i,Ze,",",","),s(O,Ze,":",":"),s(i,Ze,";",";"),s(i,B,"\u22BC","\\barwedge"),s(i,B,"\u22BB","\\veebar"),s(i,B,"\u2299","\\odot",!0),s(i,B,"\u2295\uFE0E","\\oplus"),s(i,B,"\u2297","\\otimes",!0),s(i,f,"\u2202","\\partial",!0),s(i,B,"\u2298","\\oslash",!0),s(i,B,"\u229A","\\circledcirc",!0),s(i,B,"\u22A1","\\boxdot",!0),s(i,B,"\u25B3","\\bigtriangleup"),s(i,B,"\u25BD","\\bigtriangledown"),s(i,B,"\u2020","\\dagger"),s(i,B,"\u22C4","\\diamond"),s(i,B,"\u25C3","\\triangleleft"),s(i,B,"\u25B9","\\triangleright"),s(i,ie,"{","\\{"),s(O,f,"{","\\{"),s(O,f,"{","\\textbraceleft"),s(i,Pe,"}","\\}"),s(O,f,"}","\\}"),s(O,f,"}","\\textbraceright"),s(i,ie,"{","\\lbrace"),s(i,Pe,"}","\\rbrace"),s(i,ie,"[","\\lbrack",!0),s(O,f,"[","\\lbrack",!0),s(i,Pe,"]","\\rbrack",!0),s(O,f,"]","\\rbrack",!0),s(i,ie,"(","\\lparen",!0),s(i,Pe,")","\\rparen",!0),s(i,ie,"\u2987","\\llparenthesis",!0),s(i,Pe,"\u2988","\\rrparenthesis",!0),s(O,f,"<","\\textless",!0),s(O,f,">","\\textgreater",!0),s(i,ie,"\u230A","\\lfloor",!0),s(i,Pe,"\u230B","\\rfloor",!0),s(i,ie,"\u2308","\\lceil",!0),s(i,Pe,"\u2309","\\rceil",!0),s(i,f,"\\","\\backslash"),s(i,f,"|","|"),s(i,f,"|","\\vert"),s(O,f,"|","\\textbar",!0),s(i,f,"\u2016","\\|"),s(i,f,"\u2016","\\Vert"),s(O,f,"\u2016","\\textbardbl"),s(O,f,"~","\\textasciitilde"),s(O,f,"\\","\\textbackslash"),s(O,f,"^","\\textasciicircum"),s(i,v,"\u2191","\\uparrow",!0),s(i,v,"\u21D1","\\Uparrow",!0),s(i,v,"\u2193","\\downarrow",!0),s(i,v,"\u21D3","\\Downarrow",!0),s(i,v,"\u2195","\\updownarrow",!0),s(i,v,"\u21D5","\\Updownarrow",!0),s(i,ye,"\u2210","\\coprod"),s(i,ye,"\u22C1","\\bigvee"),s(i,ye,"\u22C0","\\bigwedge"),s(i,ye,"\u2A04","\\biguplus"),s(i,ye,"\u2A04","\\bigcupplus"),s(i,ye,"\u2A03","\\bigcupdot"),s(i,ye,"\u2A07","\\bigdoublevee"),s(i,ye,"\u2A08","\\bigdoublewedge"),s(i,ye,"\u22C2","\\bigcap"),s(i,ye,"\u22C3","\\bigcup"),s(i,ye,"\u222B","\\int"),s(i,ye,"\u222B","\\intop"),s(i,ye,"\u222C","\\iint"),s(i,ye,"\u222D","\\iiint"),s(i,ye,"\u220F","\\prod"),s(i,ye,"\u2211","\\sum"),s(i,ye,"\u2A02","\\bigotimes"),s(i,ye,"\u2A01","\\bigoplus"),s(i,ye,"\u2A00","\\bigodot"),s(i,ye,"\u2A09","\\bigtimes"),s(i,ye,"\u222E","\\oint"),s(i,ye,"\u222F","\\oiint"),s(i,ye,"\u2230","\\oiiint"),s(i,ye,"\u2231","\\intclockwise"),s(i,ye,"\u2232","\\varointclockwise"),s(i,ye,"\u2A0C","\\iiiint"),s(i,ye,"\u2A0D","\\intbar"),s(i,ye,"\u2A0E","\\intBar"),s(i,ye,"\u2A0F","\\fint"),s(i,ye,"\u2A12","\\rppolint"),s(i,ye,"\u2A13","\\scpolint"),s(i,ye,"\u2A15","\\pointint"),s(i,ye,"\u2A16","\\sqint"),s(i,ye,"\u2A17","\\intlarhk"),s(i,ye,"\u2A18","\\intx"),s(i,ye,"\u2A19","\\intcap"),s(i,ye,"\u2A1A","\\intcup"),s(i,ye,"\u2A05","\\bigsqcap"),s(i,ye,"\u2A06","\\bigsqcup"),s(i,ye,"\u222B","\\smallint"),s(O,_t,"\u2026","\\textellipsis"),s(i,_t,"\u2026","\\mathellipsis"),s(O,_t,"\u2026","\\ldots",!0),s(i,_t,"\u2026","\\ldots",!0),s(i,_t,"\u22F0","\\iddots",!0),s(i,_t,"\u22EF","\\@cdots",!0),s(i,_t,"\u22F1","\\ddots",!0),s(i,f,"\u22EE","\\varvdots"),s(O,f,"\u22EE","\\varvdots"),s(i,De,"\xB4","\\acute"),s(i,De,"`","\\grave"),s(i,De,"\xA8","\\ddot"),s(i,De,"\u2026","\\dddot"),s(i,De,"\u2026.","\\ddddot"),s(i,De,"~","\\tilde"),s(i,De,"\u203E","\\bar"),s(i,De,"\u02D8","\\breve"),s(i,De,"\u02C7","\\check"),s(i,De,"^","\\hat"),s(i,De,"\u2192","\\vec"),s(i,De,"\u02D9","\\dot"),s(i,De,"\u02DA","\\mathring"),s(i,W,"\u0131","\\imath",!0),s(i,W,"\u0237","\\jmath",!0),s(i,f,"\u0131","\u0131"),s(i,f,"\u0237","\u0237"),s(O,f,"\u0131","\\i",!0),s(O,f,"\u0237","\\j",!0),s(O,f,"\xF8","\\o",!0),s(i,W,"\xF8","\\o",!0),s(O,f,"\xD8","\\O",!0),s(i,W,"\xD8","\\O",!0),s(O,De,"\u02CA","\\'"),s(O,De,"\u02CB","\\`"),s(O,De,"\u02C6","\\^"),s(O,De,"~","\\~"),s(O,De,"\u02C9","\\="),s(O,De,"\u02D8","\\u"),s(O,De,"\u02D9","\\."),s(O,De,"\xB8","\\c"),s(O,De,"\u02DA","\\r"),s(O,De,"\u02C7","\\v"),s(O,De,"\xA8",'\\"'),s(O,De,"\u02DD","\\H"),s(i,De,"\u02CA","\\'"),s(i,De,"\u02CB","\\`"),s(i,De,"\u02C6","\\^"),s(i,De,"~","\\~"),s(i,De,"\u02C9","\\="),s(i,De,"\u02D8","\\u"),s(i,De,"\u02D9","\\."),s(i,De,"\xB8","\\c"),s(i,De,"\u02DA","\\r"),s(i,De,"\u02C7","\\v"),s(i,De,"\xA8",'\\"'),s(i,De,"\u02DD","\\H");let Y={"--":!0,"---":!0,"``":!0,"''":!0};s(O,f,"\u2013","--",!0),s(O,f,"\u2013","\\textendash"),s(O,f,"\u2014","---",!0),s(O,f,"\u2014","\\textemdash"),s(O,f,"\u2018","`",!0),s(O,f,"\u2018","\\textquoteleft"),s(O,f,"\u2019","'",!0),s(O,f,"\u2019","\\textquoteright"),s(O,f,"\u201C","``",!0),s(O,f,"\u201C","\\textquotedblleft"),s(O,f,"\u201D","''",!0),s(O,f,"\u201D","\\textquotedblright"),s(i,f,"\xB0","\\degree",!0),s(O,f,"\xB0","\\degree"),s(O,f,"\xB0","\\textdegree",!0),s(i,f,"\xA3","\\pounds"),s(i,f,"\xA3","\\mathsterling",!0),s(O,f,"\xA3","\\pounds"),s(O,f,"\xA3","\\textsterling",!0),s(i,f,"\u2720","\\maltese"),s(O,f,"\u2720","\\maltese"),s(i,f,"\u20AC","\\euro",!0),s(O,f,"\u20AC","\\euro",!0),s(O,f,"\u20AC","\\texteuro"),s(i,f,"\xA9","\\copyright",!0),s(O,f,"\xA9","\\textcopyright"),s(i,f,"\u2300","\\diameter",!0),s(O,f,"\u2300","\\diameter"),s(i,f,"\u{1D6E4}","\\varGamma"),s(i,f,"\u{1D6E5}","\\varDelta"),s(i,f,"\u{1D6E9}","\\varTheta"),s(i,f,"\u{1D6EC}","\\varLambda"),s(i,f,"\u{1D6EF}","\\varXi"),s(i,f,"\u{1D6F1}","\\varPi"),s(i,f,"\u{1D6F4}","\\varSigma"),s(i,f,"\u{1D6F6}","\\varUpsilon"),s(i,f,"\u{1D6F7}","\\varPhi"),s(i,f,"\u{1D6F9}","\\varPsi"),s(i,f,"\u{1D6FA}","\\varOmega"),s(O,f,"\u{1D6E4}","\\varGamma"),s(O,f,"\u{1D6E5}","\\varDelta"),s(O,f,"\u{1D6E9}","\\varTheta"),s(O,f,"\u{1D6EC}","\\varLambda"),s(O,f,"\u{1D6EF}","\\varXi"),s(O,f,"\u{1D6F1}","\\varPi"),s(O,f,"\u{1D6F4}","\\varSigma"),s(O,f,"\u{1D6F6}","\\varUpsilon"),s(O,f,"\u{1D6F7}","\\varPhi"),s(O,f,"\u{1D6F9}","\\varPsi"),s(O,f,"\u{1D6FA}","\\varOmega");let F='0123456789/@."';for(let e=0;e<14;e++){let n=F.charAt(e);s(i,f,n,n)}let Ce='0123456789!@*()-=+";:?/.,';for(let e=0;e<25;e++){let n=Ce.charAt(e);s(O,f,n,n)}let ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";for(let e=0;e<52;e++){let n=ce.charAt(e);s(i,W,n,n),s(O,f,n,n)}let Ne="\xC7\xD0\xDE\xE7\xFE\u2102\u210D\u2115\u2119\u211A\u211D\u2124\u210E\u210F\u210A\u210B\u210C\u2110\u2111\u2112\u2113\u2118\u211B\u211C\u212C\u2130\u2131\u2133\u212D\u2128";for(let e=0;e<30;e++){let n=Ne.charAt(e);s(i,W,n,n),s(O,f,n,n)}let ee="";for(let e=0;e<52;e++){ee=String.fromCharCode(55349,56320+e),s(i,W,ee,ee),s(O,f,ee,ee),ee=String.fromCharCode(55349,56372+e),s(i,W,ee,ee),s(O,f,ee,ee),ee=String.fromCharCode(55349,56424+e),s(i,W,ee,ee),s(O,f,ee,ee),ee=String.fromCharCode(55349,56580+e),s(i,W,ee,ee),s(O,f,ee,ee),ee=String.fromCharCode(55349,56736+e),s(i,W,ee,ee),s(O,f,ee,ee),ee=String.fromCharCode(55349,56788+e),s(i,W,ee,ee),s(O,f,ee,ee),ee=String.fromCharCode(55349,56840+e),s(i,W,ee,ee),s(O,f,ee,ee),ee=String.fromCharCode(55349,56944+e),s(i,W,ee,ee),s(O,f,ee,ee),ee=String.fromCharCode(55349,56632+e),s(i,W,ee,ee),s(O,f,ee,ee);let n=ce.charAt(e);ee=String.fromCharCode(55349,56476+e),s(i,W,n,ee),s(O,f,n,ee)}for(let e=0;e<10;e++)ee=String.fromCharCode(55349,57294+e),s(i,W,ee,ee),s(O,f,ee,ee),ee=String.fromCharCode(55349,57314+e),s(i,W,ee,ee),s(O,f,ee,ee),ee=String.fromCharCode(55349,57324+e),s(i,W,ee,ee),s(O,f,ee,ee),ee=String.fromCharCode(55349,57334+e),s(i,W,ee,ee),s(O,f,ee,ee);let nt=function(e,n,r){return!Q[n][e]||!Q[n][e].replace||e.charCodeAt(0)===55349||Object.prototype.hasOwnProperty.call(Y,e)&&r&&(r.fontFamily&&r.fontFamily.slice(4,6)==="tt"||r.font&&r.font.slice(4,6)==="tt")||(e=Q[n][e].replace),new Ke(e)},pt=(e,n)=>{if(e.children.length===0||e.children[e.children.length-1].type!=="mtext"){let r=new T("mtext",[new Ke(n.children[0].text)]);e.children.push(r)}else e.children[e.children.length-1].children[0].text+=n.children[0].text},ut=e=>{if(e.type!=="mrow"&&e.type!=="mstyle"||e.children.length===0)return e;let n=new T("mrow");for(let r=0;r<e.children.length;r++){let l=e.children[r];if(l.type==="mtext"&&Object.keys(l.attributes).length===0)pt(n,l);else if(l.type==="mrow"){let u=!0;for(let h=0;h<l.children.length;h++)if(l.children[h].type!=="mtext"||Object.keys(l.attributes).length!==0){u=!1;break}if(u)for(let h=0;h<l.children.length;h++){let y=l.children[h];pt(n,y)}else n.children.push(l)}else n.children.push(l)}for(let r=0;r<n.children.length;r++)if(n.children[r].type==="mtext"){let l=n.children[r];l.children[0].text.charAt(0)===" "&&(l.children[0].text="\xA0"+l.children[0].text.slice(1));let u=l.children[0].text.length;u>0&&l.children[0].text.charAt(u-1)===" "&&(l.children[0].text=l.children[0].text.slice(0,-1)+"\xA0");for(let[h,y]of Object.entries(e.attributes))l.attributes[h]=y}return n.children.length===1&&n.children[0].type==="mtext"?n.children[0]:n},ke=function(e,n=!1){if(!(e.length!==1||e[0]instanceof $e))return e[0];if(!n){e[0]instanceof T&&e[0].type==="mo"&&!e[0].attributes.fence&&(e[0].attributes.lspace="0em",e[0].attributes.rspace="0em");let r=e.length-1;e[r]instanceof T&&e[r].type==="mo"&&!e[r].attributes.fence&&(e[r].attributes.lspace="0em",e[r].attributes.rspace="0em")}return new T("mrow",e)};function Ee(e){if(!e)return!1;if(e.type==="mi"&&e.children.length===1){let n=e.children[0];return n instanceof Ke&&n.text==="."}if(e.type==="mtext"&&e.children.length===1){let n=e.children[0];return n instanceof Ke&&n.text==="\u2008"}if(e.type==="mo"&&e.children.length===1&&e.getAttribute("separator")==="true"&&e.getAttribute("lspace")==="0em"&&e.getAttribute("rspace")==="0em"){let n=e.children[0];return n instanceof Ke&&n.text===","}return!1}let re=(e,n)=>{let r=e[n],l=e[n+1];return r.type==="atom"&&r.text===","&&r.loc&&l.loc&&r.loc.end===l.loc.start},Ge=e=>e.type==="atom"&&e.family==="rel"||e.type==="mclass"&&e.mclass==="mrel",ht=function(e,n,r=!1){if(!r&&e.length===1){let y=He(e[0],n);return y instanceof T&&y.type==="mo"&&(y.setAttribute("lspace","0em"),y.setAttribute("rspace","0em")),[y]}let l=[],u=[],h;for(let y=0;y<e.length;y++)u.push(He(e[y],n));for(let y=0;y<u.length;y++){let x=u[y];if(y<e.length-1&&Ge(e[y])&&Ge(e[y+1])&&x.setAttribute("rspace","0em"),y>0&&Ge(e[y])&&Ge(e[y-1])&&x.setAttribute("lspace","0em"),x.type==="mn"&&h&&h.type==="mn")h.children.push(...x.children);else if(Ee(x)&&h&&h.type==="mn")h.children.push(...x.children);else if(h&&h.type==="mn"&&y<u.length-1&&u[y+1].type==="mn"&&re(e,y))h.children.push(...x.children);else{if(x.type==="mn"&&Ee(h))x.children=[...h.children,...x.children],l.pop();else if((x.type==="msup"||x.type==="msub")&&x.children.length>=1&&h&&(h.type==="mn"||Ee(h))){let q=x.children[0];q instanceof T&&q.type==="mn"&&h&&(q.children=[...h.children,...q.children],l.pop())}l.push(x),h=x}}return l},tt=function(e,n,r=!1){return ke(ht(e,n,r),r)},He=function(e,n){if(!e)return new T("mrow");if(_[e.type])return _[e.type](e,n);throw new t("Got group of unknown type: '"+e.type+"'")},gt=e=>new T("mtd",[],[],{padding:"0",width:"50%"}),Yt=["mrow","mtd","mtable","mtr"],nn=e=>{for(let n of e.children)if(n.type&&Yt.includes(n.type)){if(n.classes&&n.classes[0]==="tml-label")return n.label;{let r=nn(n);if(r)return r}}else if(!n.type){let r=nn(n);if(r)return r}};function It(e,n,r,l){let u=null;e.length===1&&e[0].type==="tag"&&(u=e[0].tag,e=e[0].body);let h=ht(e,r);if(h.length===1&&h[0]instanceof Ae)return h[0];let y=l.displayMode||l.annotate?"none":l.wrap,x=h.length===0?null:h[0],q=h.length===1&&u===null&&x instanceof T?h[0]:function(ve,Te,le){let xt=[],lt=[],kt=[],zt=0,ct=0;for(;ct<ve.length;){for(;ve[ct]instanceof $e;)ve.splice(ct,1,...ve[ct].children);let ft=ve[ct];if(ft.attributes&&ft.attributes.linebreak&&ft.attributes.linebreak==="newline"){kt.length>0&&lt.push(new T("mrow",kt)),lt.push(ft),kt=[];let En=new T("mtd",lt);En.style.textAlign="left",xt.push(new T("mtr",[En])),lt=[],ct+=1;continue}if(kt.push(ft),ft.type&&ft.type==="mo"&&ft.children.length===1&&(!ft.attributes.form||ft.attributes.form!=="prefix")&&!Object.prototype.hasOwnProperty.call(ft.attributes,"movablelimits")){let En=ft.children[0].text;if(Te==="="&&En==="="){if(zt+=1,zt>1){kt.pop();let ln=new T("mrow",kt);lt.push(ln),kt=[ft]}}else if(Te==="tex"){let ln=ct<ve.length-1?ve[ct+1]:null,Ar=!0;if(!ln||ln.type!=="mtext"||!ln.attributes.linebreak||ln.attributes.linebreak!=="nobreak")for(let Hn=ct+1;Hn<ve.length;Hn++){let er=ve[Hn];if(!er.type||er.type!=="mspace"||er.attributes.linebreak&&er.attributes.linebreak==="newline")break;kt.push(er),ct+=1,er.attributes&&er.attributes.linebreak&&er.attributes.linebreak==="nobreak"&&(Ar=!1)}if(Ar){let Hn=new T("mrow",kt);lt.push(Hn),kt=[]}}}ct+=1}if(kt.length>0){let ft=new T("mrow",kt);lt.push(ft)}if(xt.length>0){let ft=new T("mtd",lt);ft.style.textAlign="left";let En=new T("mtr",[ft]);xt.push(En);let ln=new T("mtable",xt);return le||(ln.setAttribute("columnalign","left"),ln.setAttribute("rowspacing","0em")),ln}return bt(lt)}(h,y,l.displayMode);if(u&&(q=((ve,Te,le,xt)=>{Te=tt(Te[0].body,le),(Te=ut(Te)).classes.push("tml-tag");let lt=nn(ve);ve=new T("mtd",[ve]);let kt=[gt(),ve,gt()];kt[xt?0:2].children.push(Te);let zt=new T("mtr",kt,["tml-tageqn"]);lt&&zt.setAttribute("id",lt);let ct=new T("mtable",[zt]);return ct.style.width="100%",ct.setAttribute("displaystyle","true"),ct})(q,u,r,l.leqno)),l.annotate){let ve=new T("annotation",[new Ke(n)]);ve.setAttribute("encoding","application/x-tex"),q=new T("semantics",[q,ve])}let Z=new T("math",[q]);return l.xml&&Z.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML"),l.displayMode&&(Z.setAttribute("display","block"),Z.style.display="block math",Z.classes=["tml-display"]),Z}let Wt=(e,n)=>{let r=e.isStretchy?fe(e):new T("mo",[nt(e.label,e.mode)]);e.isStretchy||r.setAttribute("stretchy","false"),e.label!=="\\vec"&&(r.style.mathDepth="0");let l=e.label==="\\c"?"munder":"mover",u=pn.has(e.label);if(l==="mover"&&e.mode==="math"&&!e.isStretchy&&e.base.text&&e.base.text.length===1){let h=e.base.text,y=e.label==="\\vec",x=y==="\\vec"?"-vec":"";y&&r.classes.push("tml-vec");let q=y?"-vec":u?"-acc":"";"DHKLUcegorsuvxyz\u03A0\u03A5\u03A8\u03B1\u03B4\u03B7\u03B9\u03BC\u03BD\u03BF\u03C4\u03C5\u03C7\u03F5".indexOf(h)>-1?(r.classes.push(`chr-sml${x}`),r.classes.push(`wbk-sml${q}`)):"BCEGIMNOPQRSTXZlpqtw\u0393\u0398\u039E\u03A3\u03A6\u03A9\u03B2\u03B5\u03B6\u03B8\u03BE\u03C1\u03C2\u03C6\u03C8\u03D1\u03D5\u03F1".indexOf(h)>-1?(r.classes.push(`chr-med${x}`),r.classes.push(`wbk-med${q}`)):"AFJdf\u0394\u039B".indexOf(h)>-1?(r.classes.push(`chr-lrg${x}`),r.classes.push(`wbk-lrg${q}`)):y?r.classes.push("wbk-vec"):u&&r.classes.push("wbk-acc")}else u&&r.classes.push("wbk-acc");return new T(l,[He(e.base,n),r])},oe=new Set(["\\acute","\\check","\\grave","\\ddot","\\dddot","\\ddddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring"]),pn=new Set(["\\acute","\\bar","\\breve","\\check","\\dot","\\ddot","\\grave","\\hat","\\mathring","\\`","\\'","\\^","\\=","\\u","\\.",'\\"',"\\r","\\H","\\v"]),Bt={"\\`":"\u0300","\\'":"\u0301","\\^":"\u0302","\\~":"\u0303","\\=":"\u0304","\\u":"\u0306","\\.":"\u0307",'\\"':"\u0308","\\r":"\u030A","\\H":"\u030B","\\v":"\u030C","\\c":"\u0327"};C({type:"accent",names:["\\acute","\\grave","\\ddot","\\dddot","\\ddddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring","\\overparen","\\widecheck","\\widehat","\\wideparen","\\widetilde","\\overrightarrow","\\overleftarrow","\\Overrightarrow","\\overleftrightarrow","\\overgroup","\\overleftharpoon","\\overrightharpoon"],props:{numArgs:1},handler:(e,n)=>{let r=Se(n[0]),l=!oe.has(e.funcName);return{type:"accent",mode:e.parser.mode,label:e.funcName,isStretchy:l,base:r}},mathmlBuilder:Wt}),C({type:"accent",names:["\\'","\\`","\\^","\\~","\\=","\\c","\\u","\\.",'\\"',"\\r","\\H","\\v"],props:{numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["primitive"]},handler:(e,n)=>{let r=Se(n[0]),l=e.parser.mode;return l==="math"&&e.parser.settings.strict&&console.log(`Temml parse error: Command ${e.funcName} is invalid in math mode.`),l==="text"&&r.text&&r.text.length===1&&e.funcName in Bt&&S.indexOf(r.text)>-1?{type:"textord",mode:"text",text:r.text+Bt[e.funcName]}:e.funcName==="\\c"&&l==="text"&&r.text&&r.text.length===1?{type:"textord",mode:"text",text:r.text+"\u0327"}:{type:"accent",mode:l,label:e.funcName,isStretchy:!1,base:r}},mathmlBuilder:Wt}),C({type:"accentUnder",names:["\\underleftarrow","\\underrightarrow","\\underleftrightarrow","\\undergroup","\\underparen","\\utilde"],props:{numArgs:1},handler:({parser:e,funcName:n},r)=>{let l=r[0];return{type:"accentUnder",mode:e.mode,label:n,base:l}},mathmlBuilder:(e,n)=>{let r=fe(e);return r.style["math-depth"]=0,new T("munder",[He(e.base,n),r])}});let rn={pt:800/803,pc:9600/803,dd:1238/1157*800/803,cc:12.792133216944668,nd:685/642*800/803,nc:1370/107*800/803,sp:1/65536*800/803,mm:25.4/72,cm:2.54/72,in:1/72,px:96/72},gn=["em","ex","mu","pt","mm","cm","in","px","bp","pc","dd","cc","nd","nc","sp"],Lt=function(e){return typeof e!="string"&&(e=e.unit),gn.indexOf(e)>-1},mn=e=>[1,.7,.5][Math.max(e-1,0)],Dt=function(e,n){let r=e.number;if(n.maxSize[0]<0&&r>0)return{number:0,unit:"em"};let l=e.unit;switch(l){case"mm":case"cm":case"in":case"px":return r*rn[l]>n.maxSize[1]?{number:n.maxSize[1],unit:"pt"}:{number:r,unit:l};case"em":case"ex":return l==="ex"&&(r*=.431),r=Math.min(r/mn(n.level),n.maxSize[0]),{number:E(r),unit:"em"};case"bp":return r>n.maxSize[1]&&(r=n.maxSize[1]),{number:r,unit:"pt"};case"pt":case"pc":case"dd":case"cc":case"nd":case"nc":case"sp":return r=Math.min(r*rn[l],n.maxSize[1]),{number:E(r),unit:"pt"};case"mu":return r=Math.min(r/18,n.maxSize[0]),{number:E(r),unit:"em"};default:throw new t("Invalid unit: '"+l+"'")}},Ct=e=>{let n=new T("mspace");return n.setAttribute("width",e+"em"),n},Kt=(e,n=.3,r=0,l=!1)=>{if(e==null&&r===0)return Ct(n);let u=e?[e]:[];if(n!==0&&u.unshift(Ct(n)),r>0&&u.push(Ct(r)),l){let h=new T("mpadded",u);return h.setAttribute("height","0.1px"),h}return new T("mrow",u)},Rt=(e,n)=>Number(e)/mn(n),N=(e,n,r,l)=>{let u=J(e),h=e.slice(1,3)==="eq",y=e.charAt(1)==="x"?"1.75":e.slice(2,4)==="cd"?"3.0":h?"1.0":"2.0";u.setAttribute("lspace","0"),u.setAttribute("rspace",h?"0.5em":"0");let x=l.withLevel(l.level<2?2:3),q=Rt(y,x.level),Z=Rt(y,3),ve=Kt(null,q.toFixed(4),0),Te=Kt(null,Z.toFixed(4),0),le=Rt(h?0:.3,x.level).toFixed(4),xt,lt,kt=n&&n.body&&(n.body.body||n.body.length>0);if(kt){let ft=He(n,x);ft=Kt(ft,le,le,e==="\\\\cdrightarrow"||e==="\\\\cdleftarrow"),xt=new T("mover",[ft,Te])}let zt=r&&r.body&&(r.body.body||r.body.length>0);if(zt){let ft=He(r,x);ft=Kt(ft,le,le),lt=new T("munder",[ft,Te])}let ct;return ct=kt||zt?kt&&zt?new T("munderover",[u,lt,xt]):kt?new T("mover",[u,xt]):new T("munder",[u,lt]):new T("mover",[u,ve]),y==="3.0"&&(ct.style.height="1em"),ct.setAttribute("accent","false"),ct};C({type:"xArrow",names:["\\xleftarrow","\\xrightarrow","\\xLeftarrow","\\xRightarrow","\\xleftrightarrow","\\xLeftrightarrow","\\xhookleftarrow","\\xhookrightarrow","\\xmapsto","\\xrightharpoondown","\\xrightharpoonup","\\xleftharpoondown","\\xleftharpoonup","\\xlongequal","\\xtwoheadrightarrow","\\xtwoheadleftarrow","\\xtofrom","\\xleftrightharpoons","\\xrightleftharpoons","\\yields","\\yieldsLeft","\\mesomerism","\\longrightharpoonup","\\longleftharpoondown","\\yieldsLeftRight","\\chemequilibrium","\\\\cdrightarrow","\\\\cdleftarrow","\\\\cdlongequal"],props:{numArgs:1,numOptionalArgs:1},handler:({parser:e,funcName:n},r,l)=>({type:"xArrow",mode:e.mode,name:n,body:r[0],below:l[0]}),mathmlBuilder(e,n){let r=[N(e.name,e.body,e.below,n)];return r.unshift(Ct(.2778)),r.push(Ct(.2778)),new T("mrow",r)}});let X={"\\equilibriumRight":["\\longrightharpoonup","\\eqleftharpoondown"],"\\equilibriumLeft":["\\eqrightharpoonup","\\longleftharpoondown"]};C({type:"stackedArrow",names:["\\equilibriumRight","\\equilibriumLeft"],props:{numArgs:1,numOptionalArgs:1},handler({parser:e,funcName:n},r,l){let u=r[0]?{type:"hphantom",mode:e.mode,body:r[0]}:null,h=l[0]?{type:"hphantom",mode:e.mode,body:l[0]}:null;return{type:"stackedArrow",mode:e.mode,name:n,body:r[0],upperArrowBelow:h,lowerArrowBody:u,below:l[0]}},mathmlBuilder(e,n){let r=X[e.name][0],l=X[e.name][1],u=N(r,e.body,e.upperArrowBelow,n),h=N(l,e.lowerArrowBody,e.below,n),y,x=new T("mpadded",[u]);if(x.setAttribute("voffset","0.3em"),x.setAttribute("height","+0.3em"),x.setAttribute("depth","-0.3em"),e.name==="\\equilibriumLeft"){let q=new T("mpadded",[h]);q.setAttribute("width","0.5em"),y=new T("mpadded",[Ct(.2778),q,x,Ct(.2778)])}else x.setAttribute("width",e.name==="\\equilibriumRight"?"0.5em":"0"),y=new T("mpadded",[Ct(.2778),x,h,Ct(.2778)]);return y.setAttribute("voffset","-0.18em"),y.setAttribute("height","-0.18em"),y.setAttribute("depth","+0.18em"),y}});let pe={};function Me({type:e,names:n,props:r,handler:l,mathmlBuilder:u}){let h={type:e,numArgs:r.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:l};for(let y=0;y<n.length;++y)pe[n[y]]=h;u&&(_[e]=u)}function Le(e,n){if(!e||e.type!==n)throw new Error(`Expected node of type ${n}, but got `+(e?`node of type ${e.type}`:String(e)));return e}function qe(e){let n=M(e);if(!n)throw new Error("Expected node of symbol group type, but got "+(e?`node of type ${e.type}`:String(e)));return n}function M(e){return e&&(e.type==="atom"||e.type==="delimiter"||Object.prototype.hasOwnProperty.call(Ie,e.type))?e:null}let j={">":"\\\\cdrightarrow","<":"\\\\cdleftarrow","=":"\\\\cdlongequal",A:"\\uparrow",V:"\\downarrow","|":"\\Vert",".":"no arrow"},H=()=>({type:"styling",body:[],mode:"math",scriptLevel:"display"}),we=e=>e.type==="textord"&&e.text==="@",Ye=(e,n)=>(e.type==="mathord"||e.type==="atom")&&e.text===n;function We(e,n,r){let l=j[e];switch(l){case"\\\\cdrightarrow":case"\\\\cdleftarrow":return r.callFunction(l,[n[0]],[n[1]]);case"\\uparrow":case"\\downarrow":{let u={type:"atom",text:l,mode:"math",family:"rel"},h={type:"ordgroup",mode:"math",body:[r.callFunction("\\\\cdleft",[n[0]],[]),r.callFunction("\\Big",[u],[]),r.callFunction("\\\\cdright",[n[1]],[])],semisimple:!0};return r.callFunction("\\\\cdparent",[h],[])}case"\\\\cdlongequal":return r.callFunction("\\\\cdlongequal",[],[]);case"\\Vert":{let u={type:"textord",text:"\\Vert",mode:"math"};return r.callFunction("\\Big",[u],[])}default:return{type:"textord",text:" ",mode:"math"}}}C({type:"cdlabel",names:["\\\\cdleft","\\\\cdright"],props:{numArgs:1},handler:({parser:e,funcName:n},r)=>({type:"cdlabel",mode:e.mode,side:n.slice(4),label:r[0]}),mathmlBuilder(e,n){if(e.label.body.length===0)return new T("mrow",n);let r=He(e.label,n);e.side==="left"&&r.classes.push("tml-shift-left");let l=new T("mtd",[r]);l.style.padding="0";let u=new T("mtr",[l]),h=new T("mtable",[u]),y=new T("mpadded",[h]);return y.setAttribute("width","0.1px"),y.setAttribute("displaystyle","false"),y.setAttribute("scriptlevel","1"),y}}),C({type:"cdlabelparent",names:["\\\\cdparent"],props:{numArgs:1},handler:({parser:e},n)=>({type:"cdlabelparent",mode:e.mode,fragment:n[0]}),mathmlBuilder:(e,n)=>new T("mrow",[He(e.fragment,n)])});let Ve=e=>({type:"ordgroup",mode:"math",body:e,semisimple:!0}),xe=(e,n)=>({type:n,mode:"math",body:Ve(e)});class Oe{constructor(n,r,l){this.lexer=n,this.start=r,this.end=l}static range(n,r){return r?n&&n.loc&&r.loc&&n.loc.lexer===r.loc.lexer?new Oe(n.loc.lexer,n.loc.start,r.loc.end):null:n&&n.loc}}class ot{constructor(n,r){this.text=n,this.loc=r}range(n,r){return new ot(r,Oe.range(this,n))}}let Et=0,Tt=1,yt=2,Qe=3,wt={};function L(e,n){wt[e]=n}let Pt=wt;L("\\noexpand",function(e){let n=e.popToken();return e.isExpandable(n.text)&&(n.noexpand=!0,n.treatAsRelax=!0),{tokens:[n],numArgs:0}}),L("\\expandafter",function(e){let n=e.popToken();return e.expandOnce(!0),{tokens:[n],numArgs:0}}),L("\\@firstoftwo",function(e){return{tokens:e.consumeArgs(2)[0],numArgs:0}}),L("\\@secondoftwo",function(e){return{tokens:e.consumeArgs(2)[1],numArgs:0}}),L("\\@ifnextchar",function(e){let n=e.consumeArgs(3);e.consumeSpaces();let r=e.future();return n[0].length===1&&n[0][0].text===r.text?{tokens:n[1],numArgs:0}:{tokens:n[2],numArgs:0}}),L("\\@ifstar","\\@ifnextchar *{\\@firstoftwo{#1}}"),L("\\TextOrMath",function(e){let n=e.consumeArgs(2);return e.mode==="text"?{tokens:n[0],numArgs:0}:{tokens:n[1],numArgs:0}});let sn=e=>{let n="";for(let r=e.length-1;r>-1;r--)n+=e[r].text;return n},on={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15},Sn=e=>{let n=e.future().text;return n==="EOF"?[null,""]:[on[n.charAt(0)],n]},jn=(e,n,r)=>{for(let l=1;l<n.length;l++)e*=r,e+=on[n.charAt(l)];return e};function or(e){let n=e.consumeArgs(1)[0],r="",l=n[n.length-1].loc.start;for(let u=n.length-1;u>=0;u--){let h=n[u].loc.start;h>l&&(r+=" ",l=h),r+=n[u].text,l+=n[u].text.length}return r}L("\\char",function(e){let n,r=e.popToken(),l="";if(r.text==="'")n=8,r=e.popToken();else if(r.text==='"')n=16,r=e.popToken();else if(r.text==="`")if(r=e.popToken(),r.text[0]==="\\")l=r.text.charCodeAt(1);else{if(r.text==="EOF")throw new t("\\char` missing argument");l=r.text.charCodeAt(0)}else n=10;if(n){let u,h=r.text;if(l=on[h.charAt(0)],l==null||l>=n)throw new t(`Invalid base-${n} digit ${r.text}`);for(l=jn(l,h,n),[u,h]=Sn(e);u!=null&&u<n;)l*=n,l+=u,l=jn(l,h,n),e.popToken(),[u,h]=Sn(e)}return`\\@char{${l}}`}),L("\\surd","\\sqrt{\\vphantom{|}}"),L("\u2295","\\oplus"),L("\\long",""),L("\\bgroup","{"),L("\\egroup","}"),L("~","\\nobreakspace"),L("\\lq","`"),L("\\rq","'"),L("\\aa","\\r a"),L("\\Bbbk","\\Bbb{k}"),L("\\mathstrut","\\vphantom{(}"),L("\\underbar","\\underline{\\text{#1}}"),L("\\vdots","{\\varvdots\\rule{0pt}{15pt}}"),L("\u22EE","\\vdots"),L("\\arraystretch","1"),L("\\arraycolsep","6pt"),L("\\substack","\\begin{subarray}{c}#1\\end{subarray}"),L("\\iff","\\DOTSB\\;\\Longleftrightarrow\\;"),L("\\implies","\\DOTSB\\;\\Longrightarrow\\;"),L("\\impliedby","\\DOTSB\\;\\Longleftarrow\\;");let qt={",":"\\dotsc","\\not":"\\dotsb","+":"\\dotsb","=":"\\dotsb","<":"\\dotsb",">":"\\dotsb","-":"\\dotsb","*":"\\dotsb",":":"\\dotsb","\\DOTSB":"\\dotsb","\\coprod":"\\dotsb","\\bigvee":"\\dotsb","\\bigwedge":"\\dotsb","\\biguplus":"\\dotsb","\\bigcap":"\\dotsb","\\bigcup":"\\dotsb","\\prod":"\\dotsb","\\sum":"\\dotsb","\\bigotimes":"\\dotsb","\\bigoplus":"\\dotsb","\\bigodot":"\\dotsb","\\bigsqcap":"\\dotsb","\\bigsqcup":"\\dotsb","\\bigtimes":"\\dotsb","\\And":"\\dotsb","\\longrightarrow":"\\dotsb","\\Longrightarrow":"\\dotsb","\\longleftarrow":"\\dotsb","\\Longleftarrow":"\\dotsb","\\longleftrightarrow":"\\dotsb","\\Longleftrightarrow":"\\dotsb","\\mapsto":"\\dotsb","\\longmapsto":"\\dotsb","\\hookrightarrow":"\\dotsb","\\doteq":"\\dotsb","\\mathbin":"\\dotsb","\\mathrel":"\\dotsb","\\relbar":"\\dotsb","\\Relbar":"\\dotsb","\\xrightarrow":"\\dotsb","\\xleftarrow":"\\dotsb","\\DOTSI":"\\dotsi","\\int":"\\dotsi","\\oint":"\\dotsi","\\iint":"\\dotsi","\\iiint":"\\dotsi","\\iiiint":"\\dotsi","\\DOTSX":"\\dotsx"};L("\\dots",function(e){let n="\\dotso",r=e.expandAfterFuture().text;return r in qt?n=qt[r]:(r.slice(0,4)==="\\not"||r in Q.math&&["bin","rel"].includes(Q.math[r].group))&&(n="\\dotsb"),n});let bn={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};L("\\dotso",function(e){return e.future().text in bn?"\\ldots\\,":"\\ldots"}),L("\\dotsc",function(e){let n=e.future().text;return n in bn&&n!==","?"\\ldots\\,":"\\ldots"}),L("\\cdots",function(e){return e.future().text in bn?"\\@cdots\\,":"\\@cdots"}),L("\\dotsb","\\cdots"),L("\\dotsm","\\cdots"),L("\\dotsi","\\!\\cdots"),L("\\idotsint","\\int\\!\\cdots\\!\\int"),L("\\dotsx","\\ldots\\,"),L("\\DOTSI","\\relax"),L("\\DOTSB","\\relax"),L("\\DOTSX","\\relax"),L("\\tmspace","\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"),L("\\,","{\\tmspace+{3mu}{.1667em}}"),L("\\thinspace","\\,"),L("\\>","\\mskip{4mu}"),L("\\:","{\\tmspace+{4mu}{.2222em}}"),L("\\medspace","\\:"),L("\\;","{\\tmspace+{5mu}{.2777em}}"),L("\\thickspace","\\;"),L("\\!","{\\tmspace-{3mu}{.1667em}}"),L("\\negthinspace","\\!"),L("\\negmedspace","{\\tmspace-{4mu}{.2222em}}"),L("\\negthickspace","{\\tmspace-{5mu}{.277em}}"),L("\\enspace","\\kern.5em "),L("\\enskip","\\hskip.5em\\relax"),L("\\quad","\\hskip1em\\relax"),L("\\qquad","\\hskip2em\\relax"),L("\\AA","\\TextOrMath{\\Angstrom}{\\mathring{A}}\\relax"),L("\\tag","\\@ifstar\\tag@literal\\tag@paren"),L("\\tag@paren","\\tag@literal{({#1})}"),L("\\tag@literal",e=>{if(e.macros.get("\\df@tag"))throw new t("Multiple \\tag");return"\\gdef\\df@tag{\\text{#1}}"}),L("\\notag","\\nonumber"),L("\\nonumber","\\gdef\\@eqnsw{0}"),L("\\bmod","\\mathbin{\\text{mod}}"),L("\\pod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"),L("\\pmod","\\pod{{\\rm mod}\\mkern6mu#1}"),L("\\mod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1"),L("\\newline","\\\\\\relax"),L("\\TeX","\\textrm{T}\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125em\\textrm{X}"),L("\\LaTeX","\\textrm{L}\\kern-.35em\\raisebox{0.2em}{\\scriptstyle A}\\kern-.15em\\TeX"),L("\\Temml","\\textrm{T}\\kern-0.2em\\lower{0.2em}{\\textrm{E}}\\kern-0.08em{\\textrm{M}\\kern-0.08em\\raise{0.2em}\\textrm{M}\\kern-0.08em\\textrm{L}}"),L("\\hspace","\\@ifstar\\@hspacer\\@hspace"),L("\\@hspace","\\hskip #1\\relax"),L("\\@hspacer","\\rule{0pt}{0pt}\\hskip #1\\relax"),L("\\colon",'\\mathpunct{\\char"3a}'),L("\\prescript","\\pres@cript{_{#1}^{#2}}{}{#3}"),L("\\ordinarycolon",'\\char"3a'),L("\\vcentcolon","\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}}"),L("\\coloneq",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"2212}'),L("\\Coloneq",'\\mathrel{\\char"2237\\char"2212}'),L("\\Eqqcolon",'\\mathrel{\\char"3d\\char"2237}'),L("\\Eqcolon",'\\mathrel{\\char"2212\\char"2237}'),L("\\colonapprox",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"2248}'),L("\\Colonapprox",'\\mathrel{\\char"2237\\char"2248}'),L("\\colonsim",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"223c}'),L("\\Colonsim",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"223c}'),L("\\ratio","\\vcentcolon"),L("\\coloncolon","\\dblcolon"),L("\\colonequals","\\coloneqq"),L("\\coloncolonequals","\\Coloneqq"),L("\\equalscolon","\\eqqcolon"),L("\\equalscoloncolon","\\Eqqcolon"),L("\\colonminus","\\coloneq"),L("\\coloncolonminus","\\Coloneq"),L("\\minuscolon","\\eqcolon"),L("\\minuscoloncolon","\\Eqcolon"),L("\\coloncolonapprox","\\Colonapprox"),L("\\coloncolonsim","\\Colonsim"),L("\\notni","\\mathrel{\\char`\u220C}"),L("\\limsup","\\DOTSB\\operatorname*{lim\\,sup}"),L("\\liminf","\\DOTSB\\operatorname*{lim\\,inf}"),L("\\injlim","\\DOTSB\\operatorname*{inj\\,lim}"),L("\\projlim","\\DOTSB\\operatorname*{proj\\,lim}"),L("\\varlimsup","\\DOTSB\\operatorname*{\\overline{\\text{lim}}}"),L("\\varliminf","\\DOTSB\\operatorname*{\\underline{\\text{lim}}}"),L("\\varinjlim","\\DOTSB\\operatorname*{\\underrightarrow{\\text{lim}}}"),L("\\varprojlim","\\DOTSB\\operatorname*{\\underleftarrow{\\text{lim}}}"),L("\\centerdot","{\\medspace\\rule{0.167em}{0.189em}\\medspace}"),L("\\argmin","\\DOTSB\\operatorname*{arg\\,min}"),L("\\argmax","\\DOTSB\\operatorname*{arg\\,max}"),L("\\plim","\\DOTSB\\operatorname*{plim}"),L("\\leftmodels","\\mathop{\\reflectbox{$\\models$}}"),L("\\bra","\\mathinner{\\langle{#1}|}"),L("\\ket","\\mathinner{|{#1}\\rangle}"),L("\\braket","\\mathinner{\\langle{#1}\\rangle}"),L("\\Bra","\\left\\langle#1\\right|"),L("\\Ket","\\left|#1\\right\\rangle");let St=(e,n)=>{let r=`}\\,\\middle${n[0]==="|"?"\\vert":"\\Vert"}\\,{`;return e.slice(0,n.index)+r+e.slice(n.index+n[0].length)};L("\\Braket",function(e){let n=or(e),r=/\|\||\||\\\|/g,l;for(;(l=r.exec(n))!==null;)n=St(n,l);return"\\left\\langle{"+n+"}\\right\\rangle"}),L("\\Set",function(e){let n=or(e),r=/\|\||\||\\\|/.exec(n);return r&&(n=St(n,r)),"\\left\\{\\:{"+n+"}\\:\\right\\}"}),L("\\set",function(e){return"\\{{"+or(e).replace(/\|/,"}\\mid{")+"}\\}"}),L("\\angln","{\\angl n}"),L("\\odv","\\@ifstar\\odv@next\\odv@numerator"),L("\\odv@numerator","\\frac{\\mathrm{d}#1}{\\mathrm{d}#2}"),L("\\odv@next","\\frac{\\mathrm{d}}{\\mathrm{d}#2}#1"),L("\\pdv","\\@ifstar\\pdv@next\\pdv@numerator");let At=e=>{let n=e[0][0].text,r=sn(e[1]).split(","),l=String(r.length),u=l==="1"?"\\partial":`\\partial^${l}`,h="";return r.map(y=>{h+="\\partial "+y.trim()+"\\,"}),[n,u,h.replace(/\\,$/,"")]};function yn(e){let n=[];e.consumeSpaces();let r=e.fetch().text;for(r==="\\relax"&&(e.consume(),e.consumeSpaces(),r=e.fetch().text);r==="\\hline"||r==="\\hdashline";)e.consume(),n.push(r==="\\hdashline"),e.consumeSpaces(),r=e.fetch().text;return n}L("\\pdv@numerator",function(e){let[n,r,l]=At(e.consumeArgs(2));return`\\frac{${r} ${n}}{${l}}`}),L("\\pdv@next",function(e){let[n,r,l]=At(e.consumeArgs(2));return`\\frac{${r}}{${l}} ${n}`}),L("\\upalpha","\\up@greek{\\alpha}"),L("\\upbeta","\\up@greek{\\beta}"),L("\\upgamma","\\up@greek{\\gamma}"),L("\\updelta","\\up@greek{\\delta}"),L("\\upepsilon","\\up@greek{\\epsilon}"),L("\\upzeta","\\up@greek{\\zeta}"),L("\\upeta","\\up@greek{\\eta}"),L("\\uptheta","\\up@greek{\\theta}"),L("\\upiota","\\up@greek{\\iota}"),L("\\upkappa","\\up@greek{\\kappa}"),L("\\uplambda","\\up@greek{\\lambda}"),L("\\upmu","\\up@greek{\\mu}"),L("\\upnu","\\up@greek{\\nu}"),L("\\upxi","\\up@greek{\\xi}"),L("\\upomicron","\\up@greek{\\omicron}"),L("\\uppi","\\up@greek{\\pi}"),L("\\upalpha","\\up@greek{\\alpha}"),L("\\uprho","\\up@greek{\\rho}"),L("\\upsigma","\\up@greek{\\sigma}"),L("\\uptau","\\up@greek{\\tau}"),L("\\upupsilon","\\up@greek{\\upsilon}"),L("\\upphi","\\up@greek{\\phi}"),L("\\upchi","\\up@greek{\\chi}"),L("\\uppsi","\\up@greek{\\psi}"),L("\\upomega","\\up@greek{\\omega}"),L("\\invamp",'\\mathbin{\\char"214b}'),L("\\parr",'\\mathbin{\\char"214b}'),L("\\upand",'\\mathbin{\\char"214b}'),L("\\with",'\\mathbin{\\char"26}'),L("\\multimapinv",'\\mathrel{\\char"27dc}'),L("\\multimapboth",'\\mathrel{\\char"29df}'),L("\\scoh",'{\\mkern5mu\\char"2322\\mkern5mu}'),L("\\sincoh",'{\\mkern5mu\\char"2323\\mkern5mu}'),L("\\coh",`{\\mkern5mu\\rule{}{0.7em}\\mathrlap{\\smash{\\raise2mu{\\char"2322}}}
6
+ {\\smash{\\lower4mu{\\char"2323}}}\\mkern5mu}`),L("\\incoh",`{\\mkern5mu\\rule{}{0.7em}\\mathrlap{\\smash{\\raise2mu{\\char"2323}}}
7
+ {\\smash{\\lower4mu{\\char"2322}}}\\mkern5mu}`),L("\\standardstate","\\text{\\tiny\\char`\u29B5}");let $n=e=>{if(!e.parser.settings.displayMode)throw new t(`{${e.envName}} can be used only in display mode.`)},Cn=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/,xn=e=>{let n=e.get("\\arraystretch");typeof n!="string"&&(n=sn(n.tokens)),n=isNaN(n)?null:Number(n);let r=e.get("\\arraycolsep");typeof r!="string"&&(r=sn(r.tokens));let l=Cn.exec(r);return[n,l?{number:+(l[1]+l[2]),unit:l[3]}:null]},wr=e=>{let n="";for(let r=0;r<e.length;r++)if(e[r].type==="label"){if(n)throw new t("Multiple \\labels in one row");n=e[r].string}return n};function An(e){if(e.indexOf("ed")===-1)return e.indexOf("*")===-1}function cn(e,{cols:n,envClasses:r,autoTag:l,singleRow:u,emptySingleRow:h,maxNumCols:y,leqno:x,arraystretch:q,arraycolsep:Z},ve){let Te=r&&r.includes("bordermatrix")?"}":"\\end";e.gullet.beginGroup(),u||e.gullet.macros.set("\\cr","\\\\\\relax"),e.gullet.beginGroup();let le=[],xt=[le],lt=[],kt=[],zt=[],ct=l!=null?[]:void 0;function ft(){l&&e.gullet.macros.set("\\@eqnsw","1",!0)}function En(){ct&&(e.gullet.macros.get("\\df@tag")?(ct.push(e.subparse([new ot("\\df@tag")])),e.gullet.macros.set("\\df@tag",void 0,!0)):ct.push(!!l&&e.gullet.macros.get("\\@eqnsw")==="1"))}for(ft(),zt.push(yn(e));;){let ln=e.parseExpression(!1,u?"\\end":"\\\\");e.gullet.endGroup(),e.gullet.beginGroup(),ln={type:"ordgroup",mode:e.mode,body:ln,semisimple:!0},le.push(ln);let Ar=e.fetch().text;if(Ar==="&"){if(y&&le.length===y){if(!r.includes("array"))throw new t(y===2?"The split environment accepts no more than two columns":"The equation environment accepts only one column",e.nextToken);if(e.settings.strict)throw new t("Too few columns specified in the {array} column argument.",e.nextToken)}e.consume()}else{if(Ar===Te){En(),le.length===1&&ln.body.length===0&&(xt.length>1||!h)&&xt.pop(),kt.push(wr(ln.body)),zt.length<xt.length+1&&zt.push([]);break}if(Ar!=="\\\\")throw new t("Expected & or \\\\ or \\cr or "+Te,e.nextToken);{let Hn;e.consume(),e.gullet.future().text!==" "&&(Hn=e.parseSizeGroup(!0)),lt.push(Hn?Hn.value:null),En(),kt.push(wr(ln.body)),zt.push(yn(e)),le=[],xt.push(le),ft()}}}return e.gullet.endGroup(),e.gullet.endGroup(),{type:"array",mode:e.mode,body:xt,cols:n,rowGaps:lt,hLinesBeforeRow:zt,envClasses:r,autoTag:l,scriptLevel:ve,tags:ct,labels:kt,leqno:x,arraystretch:q,arraycolsep:Z}}function _n(e){return e.slice(0,1)==="d"?"display":"text"}let Nn={c:"center ",l:"left ",r:"right "},dn=e=>{let n=new T("mtd",[]);return n.style={padding:"0",width:"50%"},e.envClasses.includes("multline")&&(n.style.width="7.5%"),n},Xt=function(e,n){let r=[],l=e.body.length,u=e.hLinesBeforeRow,h=e.tags&&e.tags.some(Z=>Z);for(let Z=0;Z<l;Z++){let ve=e.body[Z],Te=[],le=e.scriptLevel==="text"?Tt:e.scriptLevel==="script"?yt:Et;for(let ct=0;ct<ve.length;ct++){let ft=new T("mtd",[He(ve[ct],n.withLevel(le))]);if(e.envClasses.includes("multline")){let En=Z===0?"left":Z===l-1?"right":"center";En!=="center"&&ft.classes.push("tml-"+En)}Te.push(ft)}let xt=e.body[0].length;for(let ct=0;ct<xt-ve.length;ct++)Te.push(new T("mtd",[],[],n));if(h){let ct=e.tags[Z],ft;ct===!0?ft=new T("mtext",[new je(["tml-eqn"])]):ct===!1?ft=new T("mtext",[],[]):(ft=tt(ct[0].body,n.withLevel(le),!0),ft=ut(ft),ft.classes=["tml-tag"]),ft&&(Te.unshift(dn(e)),Te.push(dn(e)),e.leqno?Te[0].children.push(ft):Te[Te.length-1].children.push(ft))}let lt=new T("mtr",Te,[]),kt=e.labels.shift();kt&&e.tags&&e.tags[Z]&&(lt.setAttribute("id",kt),Array.isArray(e.tags[Z])&&lt.classes.push("tml-tageqn")),Z===0&&u[0].length>0&&(u[0].length===2?lt.children.forEach(ct=>{ct.style.borderTop="0.15em double"}):lt.children.forEach(ct=>{ct.style.borderTop=u[0][0]?"0.06em dashed":"0.06em solid"})),u[Z+1].length>0&&(u[Z+1].length===2?lt.children.forEach(ct=>{ct.style.borderBottom="0.15em double"}):lt.children.forEach(ct=>{ct.style.borderBottom=u[Z+1][0]?"0.06em dashed":"0.06em solid"}));let zt=!0;for(let ct=0;ct<lt.children.length;ct++){let ft=lt.children[ct].children[0];if(!ft||ft.type!=="mpadded"||ft.attributes.height!=="0px"){zt=!1;break}}if(zt){lt.classes.push("ff-squash");for(let ct=0;ct<lt.children.length;ct++)lt.children[ct].style.paddingTop="0",lt.children[ct].style.paddingBottom="0"}r.push(lt)}if(e.arraystretch&&e.arraystretch!==1){let Z=String(1.4*e.arraystretch-.8)+"ex";for(let ve=0;ve<r.length;ve++)for(let Te=0;Te<r[ve].children.length;Te++)r[ve].children[Te].style.paddingTop=Z,r[ve].children[Te].style.paddingBottom=Z}let y,x;if(e.envClasses.length>0&&(y=e.envClasses.includes("abut")||e.envClasses.includes("cases")?"0":e.envClasses.includes("small")?"0.1389":e.envClasses.includes("cd")?"0.25":"0.4",x="em"),e.arraycolsep){let Z=Dt(e.arraycolsep,n);y=Z.number.toFixed(4),x=Z.unit}if(y){let Z=r.length===0?0:r[0].children.length,ve=(Te,le)=>Te===0&&le===0||Te===Z-1&&le===1?"0":e.envClasses[0]!=="align"?y:le===1?"0":h?Te%2?"1":"0":Te%2?"0":"1";for(let Te=0;Te<r.length;Te++)for(let le=0;le<r[Te].children.length;le++)r[Te].children[le].style.paddingLeft=`${ve(le,0)}${x}`,r[Te].children[le].style.paddingRight=`${ve(le,1)}${x}`}if(e.envClasses.length===0)for(let Z=0;Z<r.length;Z++)r[Z].children[0].style.paddingLeft="0em",r[Z].children.length===r[0].children.length&&(r[Z].children[r[Z].children.length-1].style.paddingRight="0em");if(e.envClasses.length>0){let Z=e.envClasses.includes("align")||e.envClasses.includes("alignat");for(let ve=0;ve<r.length;ve++){let Te=r[ve];if(Z){for(let le=0;le<Te.children.length;le++)Te.children[le].classes=["tml-"+(le%2?"left":"right")];if(h){let le=e.leqno?0:Te.children.length-1;Te.children[le].classes=[]}}if(Te.children.length>1&&e.envClasses.includes("cases")&&(Te.children[1].style.paddingLeft="1em"),e.envClasses.includes("cases")||e.envClasses.includes("subarray"))for(let le of Te.children)le.classes.push("tml-left")}}let q=new T("mtable",r);if(e.envClasses.length>0&&(e.envClasses.includes("jot")?q.classes.push("tml-jot"):e.envClasses.includes("small")&&q.classes.push("tml-small")),e.scriptLevel==="display"&&q.setAttribute("displaystyle","true"),(e.autoTag||e.envClasses.includes("multline"))&&(q.style.width="100%"),e.cols&&e.cols.length>0){let Z=e.cols,ve=!1,Te=0,le=Z.length;for(;Z[Te].type==="separator";)Te+=1;for(;Z[le-1].type==="separator";)le-=1;if(Z[0].type==="separator"){let lt=Z[1].type==="separator"?"0.15em double":Z[0].separator==="|"?"0.06em solid ":"0.06em dashed ";for(let kt of q.children)kt.children[0].style.borderLeft=lt}let xt=h?0:-1;for(let lt=Te;lt<le;lt++)if(Z[lt].type==="align"){let kt=Nn[Z[lt].align];xt+=1;for(let zt of q.children)kt.trim()!=="center"&&xt<zt.children.length&&(zt.children[xt].classes=["tml-"+kt.trim()]);ve=!0}else if(Z[lt].type==="separator"){if(ve){let kt=Z[lt+1].type==="separator"?"0.15em double":Z[lt].separator==="|"?"0.06em solid":"0.06em dashed";for(let zt of q.children)xt<zt.children.length&&(zt.children[xt].style.borderRight=kt)}ve=!1}if(Z[Z.length-1].type==="separator"){let lt=Z[Z.length-2].type==="separator"?"0.15em double":Z[Z.length-1].separator==="|"?"0.06em solid":"0.06em dashed";for(let kt of q.children)kt.children[kt.children.length-1].style.borderRight=lt,kt.children[kt.children.length-1].style.paddingRight="0.4em"}}return e.envClasses.includes("small")&&(q=new T("mstyle",[q]),q.setAttribute("scriptlevel","1")),q},wn=function(e,n){e.envName.indexOf("ed")===-1&&$n(e);let r=e.envName==="split",l=[],u=cn(e.parser,{cols:l,emptySingleRow:!0,autoTag:r?void 0:An(e.envName),envClasses:["abut","jot"],maxNumCols:e.envName==="split"?2:void 0,leqno:e.parser.settings.leqno},"display"),h,y=0,x=e.envName.indexOf("at")>-1;if(n[0]&&x){let q="";for(let Z=0;Z<n[0].body.length;Z++)q+=Le(n[0].body[Z],"textord").text;if(isNaN(q))throw new t("The alignat enviroment requires a numeric first argument.");h=Number(q),y=2*h}u.body.forEach(function(q){if(x){let Z=q.length/2;if(h<Z)throw new t(`Too many math in a row: expected ${h}, but got ${Z}`,q[0])}else y<q.length&&(y=q.length)});for(let q=0;q<y;++q){let Z="r";q%2==1&&(Z="l"),l[q]={type:"align",align:Z}}return e.envName==="split"||(x?u.envClasses.push("alignat"):u.envClasses[0]="align"),u};Me({type:"array",names:["array","darray"],props:{numArgs:1},handler(e,n){let r=(M(n[0])?[n[0]]:Le(n[0],"ordgroup").body).map(function(y){let x=qe(y).text;if("lcr".indexOf(x)!==-1)return{type:"align",align:x};if(x==="|")return{type:"separator",separator:"|"};if(x===":")return{type:"separator",separator:":"};throw new t("Unknown column alignment: "+x,y)}),[l,u]=xn(e.parser.gullet.macros),h={cols:r,envClasses:["array"],maxNumCols:r.length,arraystretch:l,arraycolsep:u};return cn(e.parser,h,_n(e.envName))},mathmlBuilder:Xt}),Me({type:"array",names:["matrix","pmatrix","bmatrix","Bmatrix","vmatrix","Vmatrix","matrix*","pmatrix*","bmatrix*","Bmatrix*","vmatrix*","Vmatrix*"],props:{numArgs:0},handler(e){let n={matrix:null,pmatrix:["(",")"],bmatrix:["[","]"],Bmatrix:["\\{","\\}"],vmatrix:["|","|"],Vmatrix:["\\Vert","\\Vert"]}[e.envName.replace("*","")],r="c",l={envClasses:[],cols:[]};if(e.envName.charAt(e.envName.length-1)==="*"){let x=e.parser;if(x.consumeSpaces(),x.fetch().text==="["){if(x.consume(),x.consumeSpaces(),r=x.fetch().text,"lcr".indexOf(r)===-1)throw new t("Expected l or c or r",x.nextToken);x.consume(),x.consumeSpaces(),x.expect("]"),x.consume(),l.cols=[]}}let u=cn(e.parser,l,"text");u.cols=u.body.length>0?new Array(u.body[0].length).fill({type:"align",align:r}):[];let[h,y]=xn(e.parser.gullet.macros);return u.arraystretch=h,!y||y===6&&y==="pt"||(u.arraycolsep=y),n?{type:"leftright",mode:e.mode,body:[u],left:n[0],right:n[1],rightColor:void 0}:u},mathmlBuilder:Xt}),Me({type:"array",names:["bordermatrix"],props:{numArgs:0},handler(e){let n=cn(e.parser,{cols:[],envClasses:["bordermatrix"]},"text");return n.cols=n.body.length>0?new Array(n.body[0].length).fill({type:"align",align:"c"}):[],n.envClasses=[],n.arraystretch=1,e.envName==="matrix"?n:((r,l)=>{let u=r.body;u[0].shift();let h=new Array(u.length-1).fill().map(()=>[]);for(let ve=1;ve<u.length;ve++){h[ve-1].push(u[ve].shift());let Te=[];for(let le=0;le<u[ve].length;le++)Te.push(u[ve][le]);h[ve-1].push(xe(Te,"vphantom"))}let y=new Array(u.length).fill().map(()=>[]);for(let ve=0;ve<u[0].length;ve++)y[0].push(u[0][ve]);for(let ve=1;ve<u.length;ve++)for(let Te=0;Te<u[0].length;Te++)y[ve].push(xe(u[ve][Te].body,"hphantom"));for(let ve=0;ve<u[0].length;ve++)u[0][ve]=xe(u[0][ve].body,"hphantom");let x={type:"array",mode:"math",body:h,cols:[{type:"align",align:"c"}],rowGaps:new Array(h.length-1).fill(null),hLinesBeforeRow:new Array(h.length+1).fill().map(()=>[]),envClasses:[],scriptLevel:"text",arraystretch:1,labels:new Array(h.length).fill(""),arraycolsep:{number:.04,unit:"em"}},q={type:"styling",mode:"math",scriptLevel:"text",body:[{type:"array",mode:"math",body:y,cols:new Array(y.length).fill({type:"align",align:"c"}),rowGaps:new Array(y.length-1).fill(null),hLinesBeforeRow:new Array(y.length+1).fill().map(()=>[]),envClasses:[],scriptLevel:"text",arraystretch:1,labels:new Array(y.length).fill(""),arraycolsep:null}]},Z={type:"leftright",mode:"math",body:[r],left:l?l[0]:"(",right:l?l[1]:")",rightColor:void 0};return Ve([x,{type:"supsub",mode:"math",stack:!0,base:{type:"op",mode:"math",limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!0,symbol:!1,suppressBaseShift:!0,body:[Z]},sup:q,sub:null}])})(n,e.delimiters)},mathmlBuilder:Xt}),Me({type:"array",names:["smallmatrix"],props:{numArgs:0},handler:e=>cn(e.parser,{envClasses:["small"]},"script"),mathmlBuilder:Xt}),Me({type:"array",names:["subarray"],props:{numArgs:1},handler(e,n){let r=(M(n[0])?[n[0]]:Le(n[0],"ordgroup").body).map(function(u){let h=qe(u).text;if("lc".indexOf(h)!==-1)return{type:"align",align:h};throw new t("Unknown column alignment: "+h,u)});if(r.length>1)throw new t("{subarray} can contain only one column");let l={cols:r,envClasses:["small"]};if(l=cn(e.parser,l,"script"),l.body.length>0&&l.body[0].length>1)throw new t("{subarray} can contain only one column");return l},mathmlBuilder:Xt}),Me({type:"array",names:["cases","dcases","rcases","drcases"],props:{numArgs:0},handler(e){let n=cn(e.parser,{cols:[],envClasses:["cases"]},_n(e.envName));return{type:"leftright",mode:e.mode,body:[n],left:e.envName.indexOf("r")>-1?".":"\\{",right:e.envName.indexOf("r")>-1?"\\}":".",rightColor:void 0}},mathmlBuilder:Xt}),Me({type:"array",names:["align","align*","aligned","split"],props:{numArgs:0},handler:wn,mathmlBuilder:Xt}),Me({type:"array",names:["alignat","alignat*","alignedat"],props:{numArgs:1},handler:wn,mathmlBuilder:Xt}),Me({type:"array",names:["gathered","gather","gather*"],props:{numArgs:0},handler(e){e.envName!=="gathered"&&$n(e);let n={cols:[],envClasses:["abut","jot"],autoTag:An(e.envName),emptySingleRow:!0,leqno:e.parser.settings.leqno};return cn(e.parser,n,"display")},mathmlBuilder:Xt}),Me({type:"array",names:["equation","equation*"],props:{numArgs:0},handler(e){$n(e);let n={autoTag:An(e.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,envClasses:["align"],leqno:e.parser.settings.leqno};return cn(e.parser,n,"display")},mathmlBuilder:Xt}),Me({type:"array",names:["multline","multline*"],props:{numArgs:0},handler(e){$n(e);let n={autoTag:e.envName==="multline",maxNumCols:1,envClasses:["jot","multline"],leqno:e.parser.settings.leqno};return cn(e.parser,n,"display")},mathmlBuilder:Xt}),Me({type:"array",names:["CD"],props:{numArgs:0},handler:e=>($n(e),function(n){let r=[];for(n.gullet.beginGroup(),n.gullet.macros.set("\\cr","\\\\\\relax"),n.gullet.beginGroup();;){r.push(n.parseExpression(!1,"\\\\")),n.gullet.endGroup(),n.gullet.beginGroup();let h=n.fetch().text;if(h!=="&"&&h!=="\\\\"){if(h==="\\end"){r[r.length-1].length===0&&r.pop();break}throw new t("Expected \\\\ or \\cr or \\end",n.nextToken)}n.consume()}let l=[],u=[l];for(let h=0;h<r.length;h++){let y=r[h],x=H();for(let q=0;q<y.length;q++)if(we(y[q])){l.push(x),q+=1;let Z=qe(y[q]).text,ve=new Array(2);if(ve[0]={type:"ordgroup",mode:"math",body:[]},ve[1]={type:"ordgroup",mode:"math",body:[]},!("=|.".indexOf(Z)>-1)){if(!("<>AV".indexOf(Z)>-1))throw new t('Expected one of "<>AV=|." after @.');for(let le=0;le<2;le++){let xt=!0;for(let lt=q+1;lt<y.length;lt++){if(Ye(y[lt],Z)){xt=!1,q=lt;break}if(we(y[lt]))throw new t("Missing a "+Z+" character to complete a CD arrow.",y[lt]);ve[le].body.push(y[lt])}if(xt)throw new t("Missing a "+Z+" character to complete a CD arrow.",y[q])}}let Te=We(Z,ve,n);l.push(Te),x=H()}else x.body.push(y[q]);h%2==0?l.push(x):l.shift(),l=[],u.push(l)}return u.pop(),n.gullet.endGroup(),n.gullet.endGroup(),{type:"array",mode:"math",body:u,tags:null,labels:new Array(u.length+1).fill(""),envClasses:["jot","cd"],cols:[],hLinesBeforeRow:new Array(u.length+1).fill([])}}(e.parser)),mathmlBuilder:Xt}),C({type:"text",names:["\\hline","\\hdashline"],props:{numArgs:0,allowedInText:!0,allowedInMath:!0},handler(e,n){throw new t(`${e.funcName} valid only within array environment`)}});let fn=pe;C({type:"bordermatrix",names:["\\bordermatrix","\\matrix"],props:{numArgs:0,numOptionalArgs:1},handler:({parser:e,funcName:n},r,l)=>{let u=["(",")"];if(n==="\\bordermatrix"&&l[0]&&l[0].body){let q=l[0].body;q.length===1&&q[0].type==="delimiter"&&(u=[q[0].left,q[0].right])}e.consumeSpaces(),e.consume();let h=fn.bordermatrix,y={mode:e.mode,envName:n.slice(1),delimiters:u,parser:e},x=h.handler(y);return e.expect("}",!0),x}}),C({type:"cancelto",names:["\\cancelto"],props:{numArgs:2},handler({parser:e},n){let r=n[0],l=n[1];return{type:"cancelto",mode:e.mode,body:l,to:r,isCharacterBox:w(l)}},mathmlBuilder(e,n){let r=new T("mrow",[He(e.body,n)],["ff-narrow"]),l=new T("mphantom",[He(e.body,n)]),u=new T("mrow",[l],["tml-cancelto"]);u.style.color=n.color,e.isCharacterBox&&S.indexOf(e.body.body[0].text)>-1&&(u.style.left="0.1em",u.style.width="90%");let h=new T("mrow",[r,u],["menclose"]);if(!e.isCharacterBox||/[f∫∑]/.test(e.body.body[0].text))l.style.paddingRight="0.2em";else{l.style.padding="0.5ex 0.1em 0 0";let Te=new T("mspace",[]);Te.setAttribute("height","0.85em"),r.children.push(Te)}let y;if(e.isCharacterBox)y=new T("mspace",[]),y.setAttribute("height","1em");else{let Te=He(e.body,n),le=new T("mpadded",[Te]);le.setAttribute("width","0.1px"),y=new T("mphantom",[le])}let x=He(e.to,n);x.style.color=n.color;let q=new T("mpadded",[x]);if(!e.isCharacterBox||/[f∫∑]/.test(e.body.body[0].text)){let Te=new T("mspace",[]);Te.setAttribute("width","0.2em"),q.children.unshift(Te)}q.setAttribute("width","0.1px");let Z=new T("mover",[y,q]),ve=new T("mrow",[],["ff-nudge-left"]);return bt([ke([h,Z]),ve])}}),C({type:"textord",names:["\\@char"],props:{numArgs:1,allowedInText:!0},handler({parser:e,token:n},r){let l=Le(r[0],"ordgroup").body,u="";for(let y=0;y<l.length;y++)u+=Le(l[y],"textord").text;let h=parseInt(u);if(isNaN(h))throw new t(`\\@char has non-numeric argument ${u}`,n);return{type:"textord",mode:e.mode,text:String.fromCodePoint(h)}}});let ir=/^(#[a-f0-9]{3}|#?[a-f0-9]{6})$/i,Nt=/^(#[a-f0-9]{3}|#?[a-f0-9]{6}|[a-z]+)$/i,Mn=/^ *\d{1,3} *(?:, *\d{1,3} *){2}$/,ar=/^ *[10](?:\.\d*)? *(?:, *[10](?:\.\d*)? *){2}$/,Gn=/^[a-f0-9]{6}$/i,Kn=e=>{let n=e.toString(16);return n.length===1&&(n="0"+n),n},On=JSON.parse(`{
8
8
  "Apricot": "#ffb484",
9
9
  "Aquamarine": "#08b4bc",
10
10
  "Bittersweet": "#c84c14",
@@ -88,16 +88,16 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Ae=O,re=D),V===void 0&
88
88
  "Yellow": "#fff404",
89
89
  "YellowGreen": "#98cc6c",
90
90
  "YellowOrange": "#ffa41c"
91
- }`),ve=(e,t)=>{let n="";if(e==="HTML"){if(!bn.test(t))throw new r("Invalid HTML input.");n=t}else if(e==="RGB"){if(!yn.test(t))throw new r("Invalid RGB input.");t.split(",").map(a=>{n+=H(Number(a.trim()))})}else{if(!wn.test(t))throw new r("Invalid rbg input.");t.split(",").map(a=>{let c=Number(a.trim());if(c>1)throw new r("Color rgb input must be < 1.");n+=H(Number((255*c).toFixed(0)))})}return n.charAt(0)!=="#"&&(n="#"+n),n},Ue=(e,t,n)=>{let a=`\\\\color@${e}`;if(!On.exec(e))throw new r("Invalid color: '"+e+"'",n);return v.test(e)?"#"+e:(e.charAt(0)==="#"||(t.has(a)?e=t.get(a).tokens[0].text:G[e]&&(e=G[e])),e)},Ct=(e,t)=>{let n=tt(e.body,t.withColor(e.color));return n.length===0&&n.push(new _("mrow")),n=n.map(a=>(a.style.color=e.color,a)),at(n)};C({type:"color",names:["\\textcolor"],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw","original"]},handler({parser:e,token:t},n,a){let c=a[0]&&te(a[0],"raw").string,p="";if(c){let x=te(n[0],"raw").string;p=ve(c,x)}else p=Ue(te(n[0],"raw").string,e.gullet.macros,t);let g=n[1];return{type:"color",mode:e.mode,color:p,isTextColor:!0,body:ge(g)}},mathmlBuilder:Ct}),C({type:"color",names:["\\color"],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw"]},handler({parser:e,breakOnTokenText:t,token:n},a,c){let p=c[0]&&te(c[0],"raw").string,g="";if(p){let q=te(a[0],"raw").string;g=ve(p,q)}else g=Ue(te(a[0],"raw").string,e.gullet.macros,n);let x=e.parseExpression(!0,t,!0);return{type:"color",mode:e.mode,color:g,isTextColor:!1,body:x}},mathmlBuilder:Ct}),C({type:"color",names:["\\definecolor"],props:{numArgs:3,allowedInText:!0,argTypes:["raw","raw","raw"]},handler({parser:e,funcName:t,token:n},a){let c=te(a[0],"raw").string;if(!/^[A-Za-z]+$/.test(c))throw new r("Color name must be latin letters.",n);let p=te(a[1],"raw").string;if(!["HTML","RGB","rgb"].includes(p))throw new r("Color model must be HTML, RGB, or rgb.",n);let g=te(a[2],"raw").string,x=ve(p,g);return e.gullet.macros.set(`\\\\color@${c}`,{tokens:[{text:x}],numArgs:0}),{type:"internal",mode:e.mode}}}),C({type:"cr",names:["\\\\"],props:{numArgs:0,numOptionalArgs:0,allowedInText:!0},handler({parser:e},t,n){let a=e.gullet.future().text==="["?e.parseSizeGroup(!0):null,c=!e.settings.displayMode;return{type:"cr",mode:e.mode,newLine:c,size:a&&te(a,"size").value}},mathmlBuilder(e,t){let n=new _("mo");if(e.newLine&&(n.setAttribute("linebreak","newline"),e.size)){let a=W(e.size,t);n.setAttribute("height",a.number+a.unit)}return n}});let zt={"\\global":"\\global","\\long":"\\\\globallong","\\\\globallong":"\\\\globallong","\\def":"\\gdef","\\gdef":"\\gdef","\\edef":"\\xdef","\\xdef":"\\xdef","\\let":"\\\\globallet","\\futurelet":"\\\\globalfuture"},xn=e=>{let t=e.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(t))throw new r("Expected a control sequence",e);return t},Jt=(e,t,n,a)=>{let c=e.gullet.macros.get(n.text);c==null&&(n.noexpand=!0,c={tokens:[n],numArgs:0,unexpandable:!e.gullet.isExpandable(n.text)}),e.gullet.macros.set(t,c,a)};C({type:"internal",names:["\\global","\\long","\\\\globallong"],props:{numArgs:0,allowedInText:!0},handler({parser:e,funcName:t}){e.consumeSpaces();let n=e.fetch();if(zt[n.text])return t!=="\\global"&&t!=="\\\\globallong"||(n.text=zt[n.text]),te(e.parseFunction(),"internal");throw new r("Invalid token after macro prefix",n)}}),C({type:"internal",names:["\\def","\\gdef","\\edef","\\xdef"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){let n=e.gullet.popToken(),a=n.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(a))throw new r("Expected a control sequence",n);let c,p=0,g=[[]];for(;e.gullet.future().text!=="{";)if(n=e.gullet.popToken(),n.text==="#"){if(e.gullet.future().text==="{"){c=e.gullet.future(),g[p].push("{");break}if(n=e.gullet.popToken(),!/^[1-9]$/.test(n.text))throw new r(`Invalid argument number "${n.text}"`);if(parseInt(n.text)!==p+1)throw new r(`Argument number "${n.text}" out of order`);p++,g.push([])}else{if(n.text==="EOF")throw new r("Expected a macro definition");g[p].push(n.text)}let{tokens:x}=e.gullet.consumeArg();if(c&&x.unshift(c),t==="\\edef"||t==="\\xdef"){if(x=e.gullet.expandTokens(x),x.length>e.gullet.settings.maxExpand)throw new r("Too many expansions in an "+t);x.reverse()}return e.gullet.macros.set(a,{tokens:x,numArgs:p,delimiters:g},t===zt[t]),{type:"internal",mode:e.mode}}}),C({type:"internal",names:["\\let","\\\\globallet"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){let n=xn(e.gullet.popToken());e.gullet.consumeSpaces();let a=(c=>{let p=c.gullet.popToken();return p.text==="="&&(p=c.gullet.popToken(),p.text===" "&&(p=c.gullet.popToken())),p})(e);return Jt(e,n,a,t==="\\\\globallet"),{type:"internal",mode:e.mode}}}),C({type:"internal",names:["\\futurelet","\\\\globalfuture"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){let n=xn(e.gullet.popToken()),a=e.gullet.popToken(),c=e.gullet.popToken();return Jt(e,n,c,t==="\\\\globalfuture"),e.gullet.pushToken(c),e.gullet.pushToken(a),{type:"internal",mode:e.mode}}}),C({type:"internal",names:["\\newcommand","\\renewcommand","\\providecommand"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){let n="",a=e.gullet.popToken();a.text==="{"?(n=xn(e.gullet.popToken()),e.gullet.popToken()):n=xn(a);let c=e.gullet.isDefined(n);if(c&&t==="\\newcommand")throw new r(`\\newcommand{${n}} attempting to redefine ${n}; use \\renewcommand`);if(!c&&t==="\\renewcommand")throw new r(`\\renewcommand{${n}} when command ${n} does not yet exist; use \\newcommand`);let p=0;if(e.gullet.future().text==="["){let x=e.gullet.popToken();if(x=e.gullet.popToken(),!/^[0-9]$/.test(x.text))throw new r(`Invalid number of arguments: "${x.text}"`);if(p=parseInt(x.text),x=e.gullet.popToken(),x.text!=="]")throw new r(`Invalid argument "${x.text}"`)}let{tokens:g}=e.gullet.consumeArg();return t==="\\providecommand"&&e.gullet.macros.has(n)||e.gullet.macros.set(n,{tokens:g,numArgs:p}),{type:"internal",mode:e.mode}}});let E={"\\bigl":{mclass:"mopen",size:1},"\\Bigl":{mclass:"mopen",size:2},"\\biggl":{mclass:"mopen",size:3},"\\Biggl":{mclass:"mopen",size:4},"\\bigr":{mclass:"mclose",size:1},"\\Bigr":{mclass:"mclose",size:2},"\\biggr":{mclass:"mclose",size:3},"\\Biggr":{mclass:"mclose",size:4},"\\bigm":{mclass:"mrel",size:1},"\\Bigm":{mclass:"mrel",size:2},"\\biggm":{mclass:"mrel",size:3},"\\Biggm":{mclass:"mrel",size:4},"\\big":{mclass:"mord",size:1},"\\Big":{mclass:"mord",size:2},"\\bigg":{mclass:"mord",size:3},"\\Bigg":{mclass:"mord",size:4}},z={"(":")","\\lparen":"\\rparen","[":"]","\\lbrack":"\\rbrack","\\{":"\\}","\\lbrace":"\\rbrace","\u2987":"\u2988","\\llparenthesis":"\\rrparenthesis","\\lfloor":"\\rfloor","\u230A":"\u230B","\\lceil":"\\rceil","\u2308":"\u2309","\\langle":"\\rangle","\u27E8":"\u27E9","\\lAngle":"\\rAngle","\u27EA":"\u27EB","\\llangle":"\\rrangle","\u2989":"\u298A","\\lvert":"\\rvert","\\lVert":"\\rVert","\\lgroup":"\\rgroup","\u27EE":"\u27EF","\\lmoustache":"\\rmoustache","\u23B0":"\u23B1","\\llbracket":"\\rrbracket","\u27E6":"\u27E7","\\lBrace":"\\rBrace","\u2983":"\u2984"},ne=new Set(Object.keys(z));new Set(Object.values(z));let ae=new Set(["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\u2987","\\llparenthesis","\u2988","\\rrparenthesis","\\lfloor","\\rfloor","\u230A","\u230B","\\lceil","\\rceil","\u2308","\u2309","<",">","\\langle","\u27E8","\\rangle","\u27E9","\\lAngle","\u27EA","\\rAngle","\u27EB","\\llangle","\u2989","\\rrangle","\u298A","\\lt","\\gt","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","\u27EE","\u27EF","\\lmoustache","\\rmoustache","\u23B0","\u23B1","\\llbracket","\\rrbracket","\u27E6","\u27E7","\\lBrace","\\rBrace","\u2983","\u2984","/","\\backslash","|","\\vert","\\|","\\Vert","\u2016","\\uparrow","\\Uparrow","\\downarrow","\\Downarrow","\\updownarrow","\\Updownarrow","."]),X=new Set(["}","\\left","\\middle","\\right"]),ue=e=>e.length>0&&(ae.has(e)||E[e]||X.has(e)),we=[0,1.2,1.8,2.4,3];function Me(e,t){e.type==="ordgroup"&&e.body.length===1&&(e=e.body[0]);let n=Qe(e);if(n&&ae.has(n.text))return n.text!=="<"&&n.text!=="\\lt"||(n.text="\u27E8"),n.text!==">"&&n.text!=="\\gt"||(n.text="\u27E9"),n;throw new r(n?`Invalid delimiter '${n.text}' after '${t.funcName}'`:`Invalid delimiter type '${e.type}'`,e)}let nt=new Set(["/","\\","\\backslash","\u2216","\\vert","|"]),wt=(e,t,n,a)=>{let c=new _("mo",[Xe(e==="."?"":e,t)]);return c.setAttribute("fence","true"),c.setAttribute("form",n),c.setAttribute("stretchy",a?"true":"false"),c};function vn(e){if(!e.body)throw new Error("Bug: The delim ParseNode wasn't fully parsed.")}C({type:"delimsizing",names:["\\bigl","\\Bigl","\\biggl","\\Biggl","\\bigr","\\Bigr","\\biggr","\\Biggr","\\bigm","\\Bigm","\\biggm","\\Biggm","\\big","\\Big","\\bigg","\\Bigg"],props:{numArgs:1,argTypes:["primitive"]},handler:(e,t)=>{let n=Me(t[0],e),a={type:"delimsizing",mode:e.parser.mode,size:E[e.funcName].size,mclass:E[e.funcName].mclass,delim:n.text},c=e.parser.fetch().text;return c!=="^"&&c!=="_"?a:{type:"ordgroup",mode:"math",body:[a,{type:"ordgroup",mode:"math",body:[]}]}},mathmlBuilder:e=>{let t=[],n=e.delim==="."?"":e.delim;t.push(Xe(n,e.mode));let a=new _("mo",t);return e.mclass==="mopen"||e.mclass==="mclose"?a.setAttribute("fence","true"):a.setAttribute("fence","false"),(nt.has(n)||n.indexOf("arrow")>-1)&&a.setAttribute("stretchy","true"),a.setAttribute("symmetric","true"),a.setAttribute("minsize",we[e.size]+"em"),a.setAttribute("maxsize",we[e.size]+"em"),a}}),C({type:"leftright-right",names:["\\right"],props:{numArgs:1,argTypes:["primitive"]},handler:(e,t)=>({type:"leftright-right",mode:e.parser.mode,delim:Me(t[0],e).text})}),C({type:"leftright",names:["\\left"],props:{numArgs:1,argTypes:["primitive"]},handler:(e,t)=>{let n=Me(t[0],e),a=e.parser;++a.leftrightDepth;let c=a.parseExpression(!1,"\\right",!0),p=a.fetch();for(;p.text==="\\middle";){a.consume();let x=a.fetch().text;if(!Ce.math[x])throw new r(`Invalid delimiter '${x}' after '\\middle'`);Me({type:"atom",mode:"math",text:x},{funcName:"\\middle"}),c.push({type:"middle",mode:"math",delim:x}),a.consume(),c=c.concat(a.parseExpression(!1,"\\right",!0)),p=a.fetch()}--a.leftrightDepth,a.expect("\\right",!1);let g=te(a.parseFunction(),"leftright-right");return{type:"leftright",mode:a.mode,body:c,left:n.text,right:g.delim,isStretchy:!0}},mathmlBuilder:(e,t)=>{vn(e);let n=tt(e.body,t),a=wt(e.left,e.mode,"prefix",!0);n.unshift(a);let c=wt(e.right,e.mode,"postfix",!0);if(e.body.length>0){let p=e.body[e.body.length-1];p.type!=="color"||p.isTextColor||c.setAttribute("mathcolor",p.color)}return n.push(c),me(n)}}),C({type:"delimiter",names:Array.from(ne),props:{numArgs:0,allowedInText:!0,allowedInMath:!0,allowedInArgument:!0},handler:({parser:e,funcName:t,token:n})=>{if(e.mode==="text")return{type:"textord",mode:"text",text:t,loc:n.loc};if(!e.settings.wrapDelimiterPairs)return{type:"atom",mode:"math",family:"open",loc:n.loc,text:t};let a=z[t],c=e.parseExpression(!1,a,!1);if(e.fetch().text!==a)throw new r("Unmatched delimiter");return e.consume(),{type:"delimiter",mode:e.mode,body:c,left:t,right:a}},mathmlBuilder:(e,t)=>{vn(e);let n=tt(e.body,t),a=wt(e.left,e.mode,"prefix",!1);n.unshift(a);let c=wt(e.right,e.mode,"postfix",!1);if(e.body.length>0){let p=e.body[e.body.length-1];p.type!=="color"||p.isTextColor||c.setAttribute("mathcolor",p.color)}return n.push(c),me(n)}}),C({type:"middle",names:["\\middle"],props:{numArgs:1,argTypes:["primitive"]},handler:(e,t)=>{let n=Me(t[0],e);if(!e.parser.leftrightDepth)throw new r("\\middle without preceding \\left",n);return{type:"middle",mode:e.parser.mode,delim:n.text}},mathmlBuilder:e=>{let t=Xe(e.delim,e.mode),n=new _("mo",[t]);return n.setAttribute("stretchy","true"),n.setAttribute("form","infix"),t.text!=="/"&&(n.setAttribute("lspace","0.05em"),n.setAttribute("rspace","0.05em")),n}});let lr=["\\boxed","\\fcolorbox","\\colorbox"],Pn=(e,t)=>{let n=lr.includes(e.label)?"mrow":"menclose",a=new _(n,[He(e.body,t)]);switch(e.label){case"\\overline":a.setAttribute("notation","top"),a.classes.push("tml-overline");break;case"\\underline":a.setAttribute("notation","bottom"),a.classes.push("tml-underline");break;case"\\cancel":a.setAttribute("notation","updiagonalstrike"),a.children.push(new _("mrow",[],["tml-cancel","upstrike"]));break;case"\\bcancel":a.setAttribute("notation","downdiagonalstrike"),a.children.push(new _("mrow",[],["tml-cancel","downstrike"]));break;case"\\sout":a.setAttribute("notation","horizontalstrike"),a.children.push(new _("mrow",[],["tml-cancel","sout"]));break;case"\\xcancel":a.setAttribute("notation","updiagonalstrike downdiagonalstrike"),a.children.push(new _("mrow",[],["tml-cancel","tml-xcancel"]));break;case"\\longdiv":a.setAttribute("notation","longdiv"),a.classes.push("longdiv-top"),a.children.push(new _("mrow",[],["longdiv-arc"]));break;case"\\phase":a.setAttribute("notation","phasorangle"),a.classes.push("phasor-bottom"),a.children.push(new _("mrow",[],["phasor-angle"]));break;case"\\textcircled":a.setAttribute("notation","circle"),a.classes.push("circle-pad"),a.children.push(new _("mrow",[],["textcircle"]));break;case"\\angl":a.setAttribute("notation","actuarial"),a.classes.push("actuarial");break;case"\\boxed":a.style.padding="3pt",a.style.border="1px solid",a.setAttribute("scriptlevel","0"),a.setAttribute("displaystyle","true");break;case"\\fbox":a.setAttribute("notation","box"),a.classes.push("tml-fbox");break;case"\\fcolorbox":case"\\colorbox":a.style.padding="0.3em",e.label==="\\fcolorbox"&&(a.style.border="0.0667em solid "+String(e.borderColor))}return e.backgroundColor&&a.setAttribute("mathbackground",e.backgroundColor),a};C({type:"enclose",names:["\\colorbox"],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw","text"]},handler({parser:e,funcName:t},n,a){let c=a[0]&&te(a[0],"raw").string,p="";if(c){let x=te(n[0],"raw").string;p=ve(c,x)}else p=Ue(te(n[0],"raw").string,e.gullet.macros);let g=n[1];return{type:"enclose",mode:e.mode,label:t,backgroundColor:p,body:g}},mathmlBuilder:Pn}),C({type:"enclose",names:["\\fcolorbox"],props:{numArgs:3,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw","raw","text"]},handler({parser:e,funcName:t},n,a){let c=a[0]&&te(a[0],"raw").string,p,g="";if(c){let q=te(n[0],"raw").string,j=te(n[0],"raw").string;g=ve(c,q),p=ve(c,j)}else g=Ue(te(n[0],"raw").string,e.gullet.macros),p=Ue(te(n[1],"raw").string,e.gullet.macros);let x=n[2];return{type:"enclose",mode:e.mode,label:t,backgroundColor:p,borderColor:g,body:x}},mathmlBuilder:Pn}),C({type:"enclose",names:["\\fbox"],props:{numArgs:1,argTypes:["hbox"],allowedInText:!0},handler:({parser:e},t)=>({type:"enclose",mode:e.mode,label:"\\fbox",body:t[0]})}),C({type:"enclose",names:["\\angl","\\cancel","\\bcancel","\\xcancel","\\overline","\\boxed","\\longdiv","\\phase"],props:{numArgs:1},handler({parser:e,funcName:t},n){let a=n[0];return{type:"enclose",mode:e.mode,label:t,body:a}},mathmlBuilder:Pn}),C({type:"enclose",names:["\\sout"],props:{numArgs:1,allowedInText:!0},handler({parser:e,funcName:t},n){let a=n[0];return{type:"enclose",mode:e.mode,label:t,body:a}},mathmlBuilder:Pn}),C({type:"enclose",names:["\\underline"],props:{numArgs:1,allowedInText:!0},handler({parser:e,funcName:t},n){let a=n[0];return{type:"enclose",mode:e.mode,label:t,body:a}},mathmlBuilder:Pn}),C({type:"enclose",names:["\\textcircled"],props:{numArgs:1,argTypes:["text"],allowedInArgument:!0,allowedInText:!0},handler({parser:e,funcName:t},n){let a=n[0];return{type:"enclose",mode:e.mode,label:t,body:a}},mathmlBuilder:Pn}),C({type:"environment",names:["\\begin","\\end"],props:{numArgs:1,argTypes:["text"]},handler({parser:e,funcName:t},n){let a=n[0];if(a.type!=="ordgroup")throw new r("Invalid environment name",a);let c="";for(let p=0;p<a.body.length;++p)c+=te(a.body[p],"textord").text;if(t==="\\begin"){if(!Object.prototype.hasOwnProperty.call(un,c))throw new r("No such environment: "+c,a);let p=un[c],{args:g,optArgs:x}=e.parseArguments("\\begin{"+c+"}",p),q={mode:e.mode,envName:c,parser:e},j=p.handler(q,g,x);e.expect("\\end",!1);let ie=e.nextToken,he=te(e.parseFunction(),"environment");if(he.name!==c)throw new r(`Mismatch: \\begin{${c}} matched by \\end{${he.name}}`,ie);return j}return{type:"environment",mode:e.mode,name:c,nameGroup:a}}}),C({type:"envTag",names:["\\env@tag"],props:{numArgs:1,argTypes:["math"]},handler:({parser:e},t)=>({type:"envTag",mode:e.mode,body:t[0]}),mathmlBuilder:(e,t)=>new _("mrow")}),C({type:"noTag",names:["\\env@notag"],props:{numArgs:0},handler:({parser:e})=>({type:"noTag",mode:e.mode}),mathmlBuilder:(e,t)=>new _("mrow")});let fs=Object.freeze({B:8426,E:8427,F:8427,H:8387,I:8391,L:8390,M:8422,R:8393,e:8394,g:8355,o:8389}),sa=Object.freeze({C:8426,H:8388,I:8392,R:8394,Z:8398}),oa=Object.freeze({C:8383,H:8389,N:8391,P:8393,Q:8393,R:8395,Z:8394}),gs=Object.freeze({"\u03F5":119527,\u03D1:119564,\u03F0:119534,\u03C6:119577,\u03F1:119535,\u03D6:119563}),ia=Object.freeze({"\u03F5":119643,\u03D1:119680,\u03F0:119650,\u03C6:119693,\u03F1:119651,\u03D6:119679}),bs=Object.freeze({"\u03F5":119701,\u03D1:119738,\u03F0:119708,\u03C6:119751,\u03F1:119709,\u03D6:119737}),aa=Object.freeze({"\u03F5":119759,\u03D1:119796,\u03F0:119766,\u03C6:119809,\u03F1:119767,\u03D6:119795}),la=Object.freeze({upperCaseLatin:{normal:e=>0,bold:e=>119743,italic:e=>119795,"bold-italic":e=>119847,script:e=>fs[e]||119899,"script-bold":e=>119951,fraktur:e=>sa[e]||120003,"fraktur-bold":e=>120107,"double-struck":e=>oa[e]||120055,"sans-serif":e=>120159,"sans-serif-bold":e=>120211,"sans-serif-italic":e=>120263,"sans-serif-bold-italic":e=>120380,monospace:e=>120367},lowerCaseLatin:{normal:e=>0,bold:e=>119737,italic:e=>e==="h"?8358:119789,"bold-italic":e=>119841,script:e=>fs[e]||119893,"script-bold":e=>119945,fraktur:e=>119997,"fraktur-bold":e=>120101,"double-struck":e=>120049,"sans-serif":e=>120153,"sans-serif-bold":e=>120205,"sans-serif-italic":e=>120257,"sans-serif-bold-italic":e=>120309,monospace:e=>120361},upperCaseGreek:{normal:e=>0,bold:e=>119575,italic:e=>119633,"bold-italic":e=>119575,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>0,"sans-serif":e=>119749,"sans-serif-bold":e=>119749,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>119807,monospace:e=>0},lowerCaseGreek:{normal:e=>0,bold:e=>119569,italic:e=>119627,"bold-italic":e=>e==="\u03D5"?119678:119685,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>0,"sans-serif":e=>119743,"sans-serif-bold":e=>119743,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>119801,monospace:e=>0},varGreek:{normal:e=>0,bold:e=>gs[e]||-51,italic:e=>0,"bold-italic":e=>ia[e]||58,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>0,"sans-serif":e=>bs[e]||116,"sans-serif-bold":e=>bs[e]||116,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>aa[e]||174,monospace:e=>0},numeral:{normal:e=>0,bold:e=>120734,italic:e=>0,"bold-italic":e=>0,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>120744,"sans-serif":e=>120754,"sans-serif-bold":e=>120764,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>0,monospace:e=>120774}}),Dn=(e,t)=>{let n=e.codePointAt(0),a=64<n&&n<91?"upperCaseLatin":96<n&&n<123?"lowerCaseLatin":912<n&&n<938?"upperCaseGreek":944<n&&n<970||e==="\u03D5"?"lowerCaseGreek":120545<n&&n<120572||gs[e]?"varGreek":47<n&&n<58?"numeral":"other";return a==="other"?e:String.fromCodePoint(n+la[a][t](e))},ca=Object.freeze({a:"\u1D00",b:"\u0299",c:"\u1D04",d:"\u1D05",e:"\u1D07",f:"\uA730",g:"\u0262",h:"\u029C",i:"\u026A",j:"\u1D0A",k:"\u1D0B",l:"\u029F",m:"\u1D0D",n:"\u0274",o:"\u1D0F",p:"\u1D18",q:"\u01EB",r:"\u0280",s:"s",t:"\u1D1B",u:"\u1D1C",v:"\u1D20",w:"\u1D21",x:"x",y:"\u028F",z:"\u1D22"}),da=["mathrm","mathit"],ys=(e,t)=>{let n=e.font,a=t.withFont(n),c=He(e.body,a);if(c.children.length===0)return c;if(n==="boldsymbol"&&["mo","mpadded","mrow"].includes(c.type))return c.style.fontWeight="bold",c;if(((x,q)=>{if(!da.includes(q)||!x.body||x.body.type!=="ordgroup"||x.body.body.length===1||x.body.body[0].type!=="mathord")return!1;for(let j=1;j<x.body.body.length;j++){let ie=x.body.body[j].type;if(ie!=="mathord"&&(ie!=="textord"||isNaN(x.body.body[j].text)))return!1}return!0})(e,n)){let x=c.children[0].children[0].children?c.children[0].children[0]:c.children[0];delete x.attributes.mathvariant;for(let j=1;j<c.children.length;j++)x.children[0].text+=c.children[j].children[0].children?c.children[j].children[0].children[0].text:c.children[j].children[0].text;if(n==="mathit")return x.children[0].text=x.children[0].text.split("").map(j=>Dn(j,"italic")).join(""),x;let q=new _("mpadded",[x]);return q.setAttribute("lspace","0"),q}let p=c.children[0].type==="mo";for(let x=1;x<c.children.length;x++)c.children[x].type==="mo"&&n==="boldsymbol"&&(c.children[x].style.fontWeight="bold"),c.children[x].type!=="mi"&&(p=!1),(c.children[x].attributes&&c.children[x].attributes.mathvariant||"")!=="normal"&&(p=!1);if(!p)return c;let g=c.children[0];for(let x=1;x<c.children.length;x++)g.children.push(c.children[x].children[0]);if(g.attributes.mathvariant&&g.attributes.mathvariant==="normal"){let x=new _("mtext",new qe("\u200B"));return new _("mrow",[x,g])}return g},ws={"\\Bbb":"\\mathbb","\\bold":"\\mathbf","\\frak":"\\mathfrak","\\bm":"\\boldsymbol"};C({type:"font",names:["\\mathrm","\\mathit","\\mathbf","\\mathnormal","\\up@greek","\\boldsymbol","\\mathbb","\\mathcal","\\mathfrak","\\mathscr","\\mathsf","\\mathsfit","\\mathtt","\\Bbb","\\bm","\\bold","\\frak"],props:{numArgs:1,allowedInArgument:!0},handler:({parser:e,funcName:t},n)=>{let a=ye(n[0]),c=t;return c in ws&&(c=ws[c]),{type:"font",mode:e.mode,font:c.slice(1),body:a}},mathmlBuilder:ys}),C({type:"font",names:["\\rm","\\sf","\\tt","\\bf","\\it","\\cal"],props:{numArgs:0,allowedInText:!0},handler:({parser:e,funcName:t,breakOnTokenText:n},a)=>{let{mode:c}=e,p=e.parseExpression(!0,n,!0);return{type:"font",mode:c,font:`math${t.slice(1)}`,body:{type:"ordgroup",mode:e.mode,body:p}}},mathmlBuilder:ys});let xs=["display","text","script","scriptscript"],ua={auto:-1,display:0,text:0,script:1,scriptscript:2},Br=(e,t)=>{t=((p,g)=>{let x=g;if(p==="display"){let q=x.level>=an?Pt:Ft;x=x.withLevel(q)}else p==="text"&&x.level===Ft?x=x.withLevel(Pt):p==="auto"?x=x.incrementLevel():p==="script"?x=x.withLevel(an):p==="scriptscript"&&(x=x.withLevel(ln));return x})(e.scriptLevel,t);let n=He(e.numer,t),a=He(e.denom,t);t.level===3&&(n.style.mathDepth="2",n.setAttribute("scriptlevel","2"),a.style.mathDepth="2",a.setAttribute("scriptlevel","2"));let c=new _("mfrac",[n,a]);if(e.hasBarLine){if(e.barSize){let p=W(e.barSize,t);c.setAttribute("linethickness",p.number+p.unit)}}else c.setAttribute("linethickness","0px");if(e.leftDelim!=null||e.rightDelim!=null){let p=[];if(e.leftDelim!=null){let g=new _("mo",[new qe(e.leftDelim.replace("\\",""))]);g.setAttribute("fence","true"),p.push(g)}if(p.push(c),e.rightDelim!=null){let g=new _("mo",[new qe(e.rightDelim.replace("\\",""))]);g.setAttribute("fence","true"),p.push(g)}c=me(p)}return e.scriptLevel!=="auto"&&(c=new _("mstyle",[c]),c.setAttribute("displaystyle",String(e.scriptLevel==="display")),c.setAttribute("scriptlevel",ua[e.scriptLevel])),c};C({type:"genfrac",names:["\\cfrac","\\dfrac","\\frac","\\tfrac","\\dbinom","\\binom","\\tbinom","\\\\atopfrac","\\\\bracefrac","\\\\brackfrac"],props:{numArgs:2,allowedInArgument:!0},handler:({parser:e,funcName:t},n)=>{let a=n[0],c=n[1],p=!1,g=null,x=null,q="auto";switch(t){case"\\cfrac":case"\\dfrac":case"\\frac":case"\\tfrac":p=!0;break;case"\\\\atopfrac":p=!1;break;case"\\dbinom":case"\\binom":case"\\tbinom":g="(",x=")";break;case"\\\\bracefrac":g="\\{",x="\\}";break;case"\\\\brackfrac":g="[",x="]";break;default:throw new Error("Unrecognized genfrac command")}return t==="\\cfrac"||t.startsWith("\\d")?q="display":t.startsWith("\\t")&&(q="text"),{type:"genfrac",mode:e.mode,continued:!1,numer:a,denom:c,hasBarLine:p,leftDelim:g,rightDelim:x,scriptLevel:q,barSize:null}},mathmlBuilder:Br}),C({type:"infix",names:["\\over","\\choose","\\atop","\\brace","\\brack"],props:{numArgs:0,infix:!0},handler({parser:e,funcName:t,token:n}){let a;switch(t){case"\\over":a="\\frac";break;case"\\choose":a="\\binom";break;case"\\atop":a="\\\\atopfrac";break;case"\\brace":a="\\\\bracefrac";break;case"\\brack":a="\\\\brackfrac";break;default:throw new Error("Unrecognized infix genfrac command")}return{type:"infix",mode:e.mode,replaceWith:a,token:n}}});let vs=function(e){let t=null;return e.length>0&&(t=e,t=t==="."?null:t),t};C({type:"genfrac",names:["\\genfrac"],props:{numArgs:6,allowedInArgument:!0,argTypes:["math","math","size","text","math","math"]},handler({parser:e},t){let n=t[4],a=t[5],c=ye(t[0]),p=c.type==="atom"&&c.family==="open"?vs(c.text):null,g=ye(t[1]),x=g.type==="atom"&&g.family==="close"?vs(g.text):null,q=te(t[2],"size"),j,ie=null;q.isBlank?j=!0:(ie=q.value,j=ie.number>0);let he="auto",ee=t[3];if(ee.type==="ordgroup"){if(ee.body.length>0){let lt=te(ee.body[0],"textord");he=xs[Number(lt.text)]}}else ee=te(ee,"textord"),he=xs[Number(ee.text)];return{type:"genfrac",mode:e.mode,numer:n,denom:a,continued:!1,hasBarLine:j,barSize:ie,leftDelim:p,rightDelim:x,scriptLevel:he}},mathmlBuilder:Br}),C({type:"infix",names:["\\above"],props:{numArgs:1,argTypes:["size"],infix:!0},handler:({parser:e,funcName:t,token:n},a)=>({type:"infix",mode:e.mode,replaceWith:"\\\\abovefrac",barSize:te(a[0],"size").value,token:n})}),C({type:"genfrac",names:["\\\\abovefrac"],props:{numArgs:3,argTypes:["math","size","math"]},handler:({parser:e,funcName:t},n)=>{let a=n[0],c=function(x){if(!x)throw new Error("Expected non-null, but got "+String(x));return x}(te(n[1],"infix").barSize),p=n[2],g=c.number>0;return{type:"genfrac",mode:e.mode,numer:a,denom:p,continued:!1,hasBarLine:g,barSize:c,leftDelim:null,rightDelim:null,scriptLevel:"auto"}},mathmlBuilder:Br}),C({type:"hbox",names:["\\hbox"],props:{numArgs:1,argTypes:["hbox"],allowedInArgument:!0,allowedInText:!1},handler:({parser:e},t)=>({type:"hbox",mode:e.mode,body:ge(t[0])}),mathmlBuilder(e,t){let n=t.withLevel(Pt),a=bt(e.body,n);return Et(a)}}),C({type:"horizBracket",names:["\\overbrace","\\underbrace","\\overbracket","\\underbracket"],props:{numArgs:1},handler:({parser:e,funcName:t},n)=>({type:"horizBracket",mode:e.mode,label:t,isOver:/^\\over/.test(t),base:n[0]}),mathmlBuilder:(e,t)=>{let n=D(e.label);return n.style["math-depth"]=0,new _(e.isOver?"mover":"munder",[He(e.base,t),n])}}),C({type:"html",names:["\\class","\\id","\\style","\\data"],props:{numArgs:2,argTypes:["raw","original"],allowedInText:!0},handler:({parser:e,funcName:t,token:n},a)=>{let c=te(a[0],"raw").string,p=a[1];if(e.settings.strict)throw new r(`Function "${t}" is disabled in strict mode`,n);let g,x={};switch(t){case"\\class":x.class=c,g={command:"\\class",class:c};break;case"\\id":x.id=c,g={command:"\\id",id:c};break;case"\\style":x.style=c,g={command:"\\style",style:c};break;case"\\data":{let q=c.split(",");for(let j=0;j<q.length;j++){let ie=q[j].split("=");if(ie.length!==2)throw new r("Error parsing key-value for \\data");x["data-"+ie[0].trim()]=ie[1].trim()}g={command:"\\data",attributes:x};break}default:throw new Error("Unrecognized html command")}if(!e.settings.isTrusted(g))throw new r(`Function "${t}" is not trusted`,n);return{type:"html",mode:e.mode,attributes:x,body:ge(p)}},mathmlBuilder:(e,t)=>{let n=bt(e.body,t),a=[];e.attributes.class&&a.push(...e.attributes.class.trim().split(/\s+/)),n.classes=a;for(let c in e.attributes)c!=="class"&&Object.prototype.hasOwnProperty.call(e.attributes,c)&&n.setAttribute(c,e.attributes[c]);return n}});let Pr=function(e){if(/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(e))return{number:+e,unit:"bp"};{let t=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(e);if(!t)throw new r("Invalid size: '"+e+"' in \\includegraphics");let n={number:+(t[1]+t[2]),unit:t[3]};if(!Ht(n))throw new r("Invalid unit: '"+n.unit+"' in \\includegraphics.");return n}};C({type:"includegraphics",names:["\\includegraphics"],props:{numArgs:1,numOptionalArgs:1,argTypes:["raw","url"],allowedInText:!1},handler:({parser:e,token:t},n,a)=>{let c={number:0,unit:"em"},p={number:.9,unit:"em"},g={number:0,unit:"em"},x="";if(a[0]){let j=te(a[0],"raw").string.split(",");for(let ie=0;ie<j.length;ie++){let he=j[ie].split("=");if(he.length===2){let ee=he[1].trim();switch(he[0].trim()){case"alt":x=ee;break;case"width":c=Pr(ee);break;case"height":p=Pr(ee);break;case"totalheight":g=Pr(ee);break;default:throw new r("Invalid key: '"+he[0]+"' in \\includegraphics.")}}}}let q=te(n[0],"url").url;if(x===""&&(x=q,x=x.replace(/^.*[\\/]/,""),x=x.substring(0,x.lastIndexOf("."))),!e.settings.isTrusted({command:"\\includegraphics",url:q}))throw new r('Function "\\includegraphics" is not trusted',t);return{type:"includegraphics",mode:e.mode,alt:x,width:c,height:p,totalheight:g,src:q}},mathmlBuilder:(e,t)=>{let n=W(e.height,t),a={number:0,unit:"em"};e.totalheight.number>0&&e.totalheight.unit===n.unit&&e.totalheight.number>n.number&&(a.number=e.totalheight.number-n.number,a.unit=n.unit);let c=0;e.width.number>0&&(c=W(e.width,t));let p={height:n.number+a.number+"em"};c.number>0&&(p.width=c.number+c.unit),a.number>0&&(p.verticalAlign=-a.number+a.unit);let g=new st(e.src,e.alt,p);return g.height=n,g.depth=a,new _("mtext",[g])}}),C({type:"kern",names:["\\kern","\\mkern","\\hskip","\\mskip"],props:{numArgs:1,argTypes:["size"],primitive:!0,allowedInText:!0},handler({parser:e,funcName:t,token:n},a){let c=te(a[0],"size");if(e.settings.strict){let p=t[1]==="m",g=c.value.unit==="mu";if(p){if(!g)throw new r(`LaTeX's ${t} supports only mu units, not ${c.value.unit} units`,n);if(e.mode!=="math")throw new r(`LaTeX's ${t} works only in math mode`,n)}else if(g)throw new r(`LaTeX's ${t} doesn't support mu units`,n)}return{type:"kern",mode:e.mode,dimension:c.value}},mathmlBuilder(e,t){let n=W(e.dimension,t),a=n.number>0&&n.unit==="em"?ks(n.number):"";if(e.mode==="text"&&a.length>0){let c=new qe(a);return new _("mtext",[c])}if(n.number>=0){let c=new _("mspace");return c.setAttribute("width",n.number+n.unit),c}{let c=new _("mrow");return c.style.marginLeft=n.number+n.unit,c}}});let ks=function(e){return e>=.05555&&e<=.05556?"\u200A":e>=.1666&&e<=.1667?"\u2009":e>=.2222&&e<=.2223?"\u2005":e>=.2777&&e<=.2778?"\u2005\u200A":""},Es=/[^A-Za-z_0-9-]/g;C({type:"label",names:["\\label"],props:{numArgs:1,argTypes:["raw"]},handler:({parser:e},t)=>({type:"label",mode:e.mode,string:t[0].string.replace(Es,"")}),mathmlBuilder(e,t){let n=new _("mrow",[],["tml-label"]);return e.string.length>0&&n.setLabel(e.string),n}});let pa=["\\clap","\\llap","\\rlap"];C({type:"lap",names:["\\mathllap","\\mathrlap","\\mathclap","\\clap","\\llap","\\rlap"],props:{numArgs:1,allowedInText:!0},handler:({parser:e,funcName:t,token:n},a)=>{if(pa.includes(t)){if(e.settings.strict&&e.mode!=="text")throw new r(`{${t}} can be used only in text mode.
92
- Try \\math${t.slice(1)}`,n);t=t.slice(1)}else t=t.slice(5);let c=a[0];return{type:"lap",mode:e.mode,alignment:t,body:c}},mathmlBuilder:(e,t)=>{let n;if(e.alignment==="llap"){let p=tt(ge(e.body),t),g=new _("mphantom",p);n=new _("mpadded",[g]),n.setAttribute("width","0.1px")}let a=He(e.body,t),c;if(e.alignment==="llap"?(a.style.position="absolute",a.style.right="0",a.style.bottom="0",c=new _("mpadded",[n,a])):c=new _("mpadded",[a]),e.alignment==="rlap")e.body.body.length>0&&e.body.body[0].type==="genfrac"&&c.setAttribute("lspace","0.16667em");else{let p=e.alignment==="llap"?"-1":"-0.5";c.setAttribute("lspace",p+"width"),e.alignment==="llap"?c.style.position="relative":(c.style.display="flex",c.style.justifyContent="center")}return c.setAttribute("width","0.1px"),c}}),C({type:"ordgroup",names:["\\(","$"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler({funcName:e,parser:t},n){let a=t.mode;t.switchMode("math");let c=e==="\\("?"\\)":"$",p=t.parseExpression(!1,c);return t.expect(c),t.switchMode(a),{type:"ordgroup",mode:t.mode,body:p}}}),C({type:"text",names:["\\)","\\]"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(e,t){throw new r(`Mismatched ${e.funcName}`,t)}}),C({type:"mathchoice",names:["\\mathchoice"],props:{numArgs:4,primitive:!0},handler:({parser:e},t)=>({type:"mathchoice",mode:e.mode,display:ge(t[0]),text:ge(t[1]),script:ge(t[2]),scriptscript:ge(t[3])}),mathmlBuilder:(e,t)=>{let n=((a,c)=>{switch(c.level){case Ft:return a.display;case Pt:return a.text;case an:return a.script;case ln:return a.scriptscript;default:return a.text}})(e,t);return bt(n,t)}});let ha=["text","textord","mathord","atom"];function Ss(e,t){let n,a=tt(e.body,t);if(e.mclass==="minner")n=new _("mpadded",a);else if(e.mclass==="mord")e.isCharacterBox||a[0].type==="mathord"?(n=a[0],n.type="mi",n.children.length===1&&n.children[0].text&&n.children[0].text==="\u2207"&&n.setAttribute("mathvariant","normal")):n=new _("mi",a);else{n=new _("mrow",a),e.mustPromote?(n=a[0],n.type="mo",e.isCharacterBox&&e.body[0].text&&/[A-Za-z]/.test(e.body[0].text)&&n.setAttribute("mathvariant","italic")):n=new _("mrow",a);let c=t.level<2;n.type==="mrow"?c&&(e.mclass==="mbin"?(n.children.unshift(U(.2222)),n.children.push(U(.2222))):e.mclass==="mrel"?(n.children.unshift(U(.2778)),n.children.push(U(.2778))):e.mclass==="mpunct"?n.children.push(U(.1667)):e.mclass==="minner"&&(n.children.unshift(U(.0556)),n.children.push(U(.0556)))):e.mclass==="mbin"?(n.attributes.lspace=c?"0.2222em":"0",n.attributes.rspace=c?"0.2222em":"0"):e.mclass==="mrel"?(n.attributes.lspace=c?"0.2778em":"0",n.attributes.rspace=c?"0.2778em":"0"):e.mclass==="mpunct"?(n.attributes.lspace="0em",n.attributes.rspace=c?"0.1667em":"0"):e.mclass==="mopen"||e.mclass==="mclose"?(n.attributes.lspace="0em",n.attributes.rspace="0em"):e.mclass==="minner"&&c&&(n.attributes.lspace="0.0556em",n.attributes.width="+0.1111em"),e.mclass!=="mopen"&&e.mclass!=="mclose"&&(delete n.attributes.stretchy,delete n.attributes.form)}return n}C({type:"mclass",names:["\\mathord","\\mathbin","\\mathrel","\\mathopen","\\mathclose","\\mathpunct","\\mathinner"],props:{numArgs:1,primitive:!0},handler({parser:e,funcName:t},n){let a=n[0],c=b(a),p=!0,g={type:"mathord",text:"",mode:e.mode},x=a.body?a.body:[a];for(let q of x){if(!ha.includes(q.type)){p=!1;break}Ce[e.mode][q.text]?g.text+=Ce[e.mode][q.text].replace:q.text?g.text+=q.text:q.body&&q.body.map(j=>{g.text+=j.text})}return p&&t==="\\mathord"&&g.type==="mathord"&&g.text.length>1?g:{type:"mclass",mode:e.mode,mclass:"m"+t.slice(5),body:ge(p?g:a),isCharacterBox:c,mustPromote:p}},mathmlBuilder:Ss});let As=e=>{let t=e.type==="ordgroup"&&e.body.length&&e.body.length===1?e.body[0]:e;if(t.type==="atom"){let n=e.body.length>0&&e.body[0].text&&Ce.math[e.body[0].text]?Ce.math[e.body[0].text].group:t.family;return n==="bin"||n==="rel"?"m"+n:"mord"}return"mord"};C({type:"mclass",names:["\\@binrel"],props:{numArgs:2},handler:({parser:e},t)=>({type:"mclass",mode:e.mode,mclass:As(t[0]),body:ge(t[1]),isCharacterBox:b(t[1])})}),C({type:"mclass",names:["\\stackrel","\\overset","\\underset"],props:{numArgs:2},handler({parser:e,funcName:t},n){let a=n[1],c=n[0],p;p=t!=="\\stackrel"?As(a):"mrel";let g={type:p==="mrel"||p==="mbin"?"op":"ordgroup",mode:a.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:t!=="\\stackrel",body:ge(a)};return{type:"supsub",mode:c.mode,stack:!0,base:g,sup:t==="\\underset"?null:c,sub:t==="\\underset"?c:null}},mathmlBuilder:Ss});let cr=(e,t,n)=>{if(!e)return n;let a=He(e,t);return a.type==="mrow"&&a.children.length===0?n:a};C({type:"multiscript",names:["\\sideset","\\pres@cript"],props:{numArgs:3},handler({parser:e,funcName:t,token:n},a){if(a[2].body.length===0)throw new r(t+"cannot parse an empty base.");let c=a[2].body[0];if(e.settings.strict&&t==="\\sideset"&&!c.symbol)throw new r("The base of \\sideset must be a big operator. Try \\prescript.");if(a[0].body.length>0&&a[0].body[0].type!=="supsub"||a[1].body.length>0&&a[1].body[0].type!=="supsub")throw new r("\\sideset can parse only subscripts and superscripts in its first two arguments",n);let p=a[0].body.length>0?a[0].body[0]:null,g=a[1].body.length>0?a[1].body[0]:null;return p||g?p?{type:"multiscript",mode:e.mode,isSideset:t==="\\sideset",prescripts:p,postscripts:g,base:c}:{type:"styling",mode:e.mode,scriptLevel:"text",body:[{type:"supsub",mode:e.mode,base:c,sup:g.sup,sub:g.sub}]}:c},mathmlBuilder(e,t){let n=He(e.base,t),a=new _("mprescripts"),c=new _("none"),p=[],g=cr(e.prescripts.sub,t,c),x=cr(e.prescripts.sup,t,c);return e.isSideset&&(g.setAttribute("style","text-align: left;"),x.setAttribute("style","text-align: left;")),e.postscripts?p=[n,cr(e.postscripts.sub,t,c),cr(e.postscripts.sup,t,c),a,g,x]:p=[n,a,g,x],new _("mmultiscripts",p)}}),C({type:"not",names:["\\not"],props:{numArgs:1,primitive:!0,allowedInText:!1},handler({parser:e},t){let n=b(t[0]),a;return n?(a=ge(t[0]),a[0].text.charAt(0)==="\\"&&(a[0].text=Ce.math[a[0].text].replace),a[0].text=a[0].text.slice(0,1)+"\u0338"+a[0].text.slice(1)):a=[{type:"textord",mode:"math",text:"\u0338"},{type:"kern",mode:"math",dimension:{number:-.6,unit:"em"}},t[0]],{type:"not",mode:e.mode,body:a,isCharacterBox:n}},mathmlBuilder(e,t){return e.isCharacterBox?tt(e.body,t,!0)[0]:bt(e.body,t)}});let ma=["textord","mathord","atom"],fa=["\\smallint"],Dr=["textord","mathord","ordgroup","close","leftright","font"],_s=e=>{e.attributes.lspace="0.1667em",e.attributes.rspace="0.1667em"},Jn=(e,t)=>{let n;if(e.symbol)n=new _("mo",[Xe(e.name,e.mode)]),fa.includes(e.name)?n.setAttribute("largeop","false"):n.setAttribute("movablelimits","false"),e.fromMathOp&&_s(n);else if(e.body)n=new _("mo",tt(e.body,t)),e.fromMathOp&&_s(n);else if(n=new _("mi",[new qe(e.name.slice(1))]),!e.parentIsSupSub){let a=[n,new _("mo",[Xe("\u2061","text")])];if(e.needsLeadingSpace){let c=new _("mspace");c.setAttribute("width","0.1667em"),a.unshift(c)}if(!e.isFollowedByDelimiter){let c=new _("mspace");c.setAttribute("width","0.1667em"),a.push(c)}n=new _("mrow",a)}return n},ga={"\u220F":"\\prod","\u2210":"\\coprod","\u2211":"\\sum","\u22C0":"\\bigwedge","\u22C1":"\\bigvee","\u22C2":"\\bigcap","\u22C3":"\\bigcup","\u2A00":"\\bigodot","\u2A01":"\\bigoplus","\u2A02":"\\bigotimes","\u2A04":"\\biguplus","\u2A05":"\\bigsqcap","\u2A06":"\\bigsqcup","\u2A03":"\\bigcupdot","\u2A07":"\\bigdoublevee","\u2A08":"\\bigdoublewedge","\u2A09":"\\bigtimes"};C({type:"op",names:["\\coprod","\\bigvee","\\bigwedge","\\biguplus","\\bigcupplus","\\bigcupdot","\\bigcap","\\bigcup","\\bigdoublevee","\\bigdoublewedge","\\intop","\\prod","\\sum","\\bigotimes","\\bigoplus","\\bigodot","\\bigsqcap","\\bigsqcup","\\bigtimes","\\smallint","\u220F","\u2210","\u2211","\u22C0","\u22C1","\u22C2","\u22C3","\u2A00","\u2A01","\u2A02","\u2A03","\u2A04","\u2A05","\u2A06","\u2A07","\u2A08","\u2A09"],props:{numArgs:0},handler:({parser:e,funcName:t},n)=>{let a=t;return a.length===1&&(a=ga[a]),{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:!0,stack:!1,name:a}},mathmlBuilder:Jn}),C({type:"op",names:["\\mathop"],props:{numArgs:1,primitive:!0},handler:({parser:e},t)=>{let n=t[0],a=n.body?n.body:[n],c=a.length===1&&ma.includes(a[0].type);return{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:c,fromMathOp:!0,stack:!1,name:c?a[0].text:null,body:c?null:ge(n)}},mathmlBuilder:Jn});let ba={"\u222B":"\\int","\u222C":"\\iint","\u222D":"\\iiint","\u222E":"\\oint","\u222F":"\\oiint","\u2230":"\\oiiint","\u2231":"\\intclockwise","\u2232":"\\varointclockwise","\u2A0C":"\\iiiint","\u2A0D":"\\intbar","\u2A0E":"\\intBar","\u2A0F":"\\fint","\u2A12":"\\rppolint","\u2A13":"\\scpolint","\u2A15":"\\pointint","\u2A16":"\\sqint","\u2A17":"\\intlarhk","\u2A18":"\\intx","\u2A19":"\\intcap","\u2A1A":"\\intcup"};C({type:"op",names:["\\arcsin","\\arccos","\\arctan","\\arctg","\\arcctg","\\arg","\\ch","\\cos","\\cosec","\\cosh","\\cot","\\cotg","\\coth","\\csc","\\ctg","\\cth","\\deg","\\dim","\\exp","\\hom","\\ker","\\lg","\\ln","\\log","\\sec","\\sin","\\sinh","\\sh","\\sgn","\\tan","\\tanh","\\tg","\\th"],props:{numArgs:0},handler({parser:e,funcName:t}){let n=e.prevAtomType,a=e.gullet.future().text;return{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!1,stack:!1,isFollowedByDelimiter:ue(a),needsLeadingSpace:n.length>0&&Dr.includes(n),name:t}},mathmlBuilder:Jn}),C({type:"op",names:["\\det","\\gcd","\\inf","\\lim","\\max","\\min","\\Pr","\\sup"],props:{numArgs:0},handler({parser:e,funcName:t}){let n=e.prevAtomType,a=e.gullet.future().text;return{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:!1,stack:!1,isFollowedByDelimiter:ue(a),needsLeadingSpace:n.length>0&&Dr.includes(n),name:t}},mathmlBuilder:Jn}),C({type:"op",names:["\\int","\\iint","\\iiint","\\iiiint","\\oint","\\oiint","\\oiiint","\\intclockwise","\\varointclockwise","\\intbar","\\intBar","\\fint","\\rppolint","\\scpolint","\\pointint","\\sqint","\\intlarhk","\\intx","\\intcap","\\intcup","\u222B","\u222C","\u222D","\u222E","\u222F","\u2230","\u2231","\u2232","\u2A0C","\u2A0D","\u2A0E","\u2A0F","\u2A12","\u2A13","\u2A15","\u2A16","\u2A17","\u2A18","\u2A19","\u2A1A"],props:{numArgs:0,allowedInArgument:!0},handler({parser:e,funcName:t}){let n=t;return n.length===1&&(n=ba[n]),{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!0,stack:!1,name:n}},mathmlBuilder:Jn}),C({type:"operatorname",names:["\\operatorname@","\\operatornamewithlimits"],props:{numArgs:1,allowedInArgument:!0},handler:({parser:e,funcName:t},n)=>{let a=n[0],c=e.prevAtomType,p=e.gullet.future().text;return{type:"operatorname",mode:e.mode,body:ge(a),alwaysHandleSupSub:t==="\\operatornamewithlimits",limits:!1,parentIsSupSub:!1,isFollowedByDelimiter:ue(p),needsLeadingSpace:c.length>0&&Dr.includes(c)}},mathmlBuilder:(e,t)=>{let n,a=tt(e.body,t.withFont("mathrm")),c=!0;for(let p=0;p<a.length;p++){let g=a[p];if(g instanceof _)switch(((g.type==="mrow"||g.type==="mpadded")&&g.children.length===1&&g.children[0]instanceof _||g.type==="mrow"&&g.children.length===2&&g.children[0]instanceof _&&g.children[1]instanceof _&&g.children[1].type==="mspace"&&!g.children[1].attributes.width&&g.children[1].children.length===0)&&(g=g.children[0]),g.type){case"mi":case"mn":case"ms":case"mtext":break;case"mspace":if(g.attributes.width){let x=g.attributes.width.replace("em",""),q=ks(Number(x));q===""?c=!1:a[p]=new _("mtext",[new qe(q)])}break;case"mo":{let x=g.children[0];g.children.length===1&&x instanceof qe?x.text=x.text.replace(/\u2212/,"-").replace(/\u2217/,"*"):c=!1;break}default:c=!1}else c=!1}if(c){let p=a.map(g=>g.toText()).join("");a=[new qe(p)]}else if(a.length===1&&["mover","munder"].includes(a[0].type)&&(a[0].children[0].type==="mi"||a[0].children[0].type==="mtext")){if(a[0].children[0].type="mi",e.parentIsSupSub)return new _("mrow",a);{let p=new _("mo",[Xe("\u2061","text")]);return at([a[0],p])}}if(c?(n=new _("mi",a),a[0].text.length===1&&n.setAttribute("mathvariant","normal")):n=new _("mrow",a),!e.parentIsSupSub){let p=[n,new _("mo",[Xe("\u2061","text")])];if(e.needsLeadingSpace){let g=new _("mspace");g.setAttribute("width","0.1667em"),p.unshift(g)}if(!e.isFollowedByDelimiter){let g=new _("mspace");g.setAttribute("width","0.1667em"),p.push(g)}return at(p)}return n}}),I("\\operatorname","\\@ifstar\\operatornamewithlimits\\operatorname@"),F({type:"ordgroup",mathmlBuilder:(e,t)=>bt(e.body,t,e.semisimple)}),C({type:"phantom",names:["\\phantom"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>{let n=t[0];return{type:"phantom",mode:e.mode,body:ge(n)}},mathmlBuilder:(e,t)=>{let n=tt(e.body,t);return new _("mphantom",n)}}),C({type:"hphantom",names:["\\hphantom"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>{let n=t[0];return{type:"hphantom",mode:e.mode,body:n}},mathmlBuilder:(e,t)=>{let n=tt(ge(e.body),t),a=new _("mphantom",n),c=new _("mpadded",[a]);return c.setAttribute("height","0px"),c.setAttribute("depth","0px"),c}}),C({type:"vphantom",names:["\\vphantom"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>{let n=t[0];return{type:"vphantom",mode:e.mode,body:n}},mathmlBuilder:(e,t)=>{let n=tt(ge(e.body),t),a=new _("mphantom",n),c=new _("mpadded",[a]);return c.setAttribute("width","0.1px"),c}}),C({type:"pmb",names:["\\pmb"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>({type:"pmb",mode:e.mode,body:ge(t[0])}),mathmlBuilder(e,t){let n=tt(e.body,t),a=Je(n);return a.setAttribute("style","font-weight:bold"),a}});let Ts=(e,t)=>{let n=t.withLevel(Pt),a=new _("mpadded",[He(e.body,n)]),c=W(e.dy,t);return a.setAttribute("voffset",c.number+c.unit),c.number>0?a.style.padding=c.number+c.unit+" 0 0 0":a.style.padding="0 0 "+Math.abs(c.number)+c.unit+" 0",a};C({type:"raise",names:["\\raise","\\lower"],props:{numArgs:2,argTypes:["size","primitive"],primitive:!0},handler({parser:e,funcName:t},n){let a=te(n[0],"size").value;t==="\\lower"&&(a.number*=-1);let c=n[1];return{type:"raise",mode:e.mode,dy:a,body:c}},mathmlBuilder:Ts}),C({type:"raise",names:["\\raisebox"],props:{numArgs:2,argTypes:["size","hbox"],allowedInText:!0},handler({parser:e,funcName:t},n){let a=te(n[0],"size").value,c=n[1];return{type:"raise",mode:e.mode,dy:a,body:c}},mathmlBuilder:Ts}),C({type:"ref",names:["\\ref","\\eqref"],props:{numArgs:1,argTypes:["raw"]},handler:({parser:e,funcName:t},n)=>({type:"ref",mode:e.mode,funcName:t,string:n[0].string.replace(Es,"")}),mathmlBuilder(e,t){let n=e.funcName==="\\ref"?["tml-ref"]:["tml-ref","tml-eqref"];return new Le("#"+e.string,n,null)}}),C({type:"reflect",names:["\\reflectbox"],props:{numArgs:1,argTypes:["hbox"],allowedInText:!0},handler:({parser:e},t)=>({type:"reflect",mode:e.mode,body:t[0]}),mathmlBuilder(e,t){let n=He(e.body,t);return n.style.transform="scaleX(-1)",n}}),C({type:"internal",names:["\\relax"],props:{numArgs:0,allowedInText:!0,allowedInArgument:!0},handler:({parser:e})=>({type:"internal",mode:e.mode})}),C({type:"rule",names:["\\rule"],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["size","size","size"]},handler({parser:e},t,n){let a=n[0],c=te(t[0],"size"),p=te(t[1],"size");return{type:"rule",mode:e.mode,shift:a&&te(a,"size").value,width:c.value,height:p.value}},mathmlBuilder(e,t){let n=W(e.width,t),a=W(e.height,t),c=e.shift?W(e.shift,t):{number:0,unit:"em"},p=t.color&&t.getColor()||"black",g=new _("mspace");if(n.number>0&&a.number>0&&g.setAttribute("mathbackground",p),g.setAttribute("width",n.number+n.unit),g.setAttribute("height",a.number+a.unit),c.number===0)return g;let x=new _("mpadded",[g]);return c.number>=0?x.setAttribute("height","+"+c.number+c.unit):(x.setAttribute("height",c.number+c.unit),x.setAttribute("depth","+"+-c.number+c.unit)),x.setAttribute("voffset",c.number+c.unit),x}});let Cs=/^[0-9]$/,ya={0:"\u2080",1:"\u2081",2:"\u2082",3:"\u2083",4:"\u2084",5:"\u2085",6:"\u2086",7:"\u2087",8:"\u2088",9:"\u2089"},wa={0:"\u2070",1:"\xB9",2:"\xB2",3:"\xB3",4:"\u2074",5:"\u2075",6:"\u2076",7:"\u2077",8:"\u2078",9:"\u2079"};C({type:"sfrac",names:["\\sfrac"],props:{numArgs:2,allowedInText:!0,allowedInMath:!0},handler({parser:e},t){let n="";for(let c of t[0].body){if(c.type!=="textord"||!Cs.test(c.text))throw new r("Numerator must be an integer.",c);n+=c.text}let a="";for(let c of t[1].body){if(c.type!=="textord"||!Cs.test(c.text))throw new r("Denominator must be an integer.",c);a+=c.text}return{type:"sfrac",mode:e.mode,numerator:n,denominator:a}},mathmlBuilder(e,t){let n=e.numerator.split("").map(p=>wa[p]).join(""),a=e.denominator.split("").map(p=>ya[p]).join(""),c=new qe(n+"\u2044"+a,e.mode,t);return new _("mn",[c],["special-fraction"])}});let Ns={"\\tiny":.5,"\\sixptsize":.6,"\\Tiny":.6,"\\scriptsize":.7,"\\footnotesize":.8,"\\small":.9,"\\normalsize":1,"\\large":1.2,"\\Large":1.44,"\\LARGE":1.728,"\\huge":2.074,"\\Huge":2.488};C({type:"sizing",names:["\\tiny","\\sixptsize","\\Tiny","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"],props:{numArgs:0,allowedInText:!0},handler:({breakOnTokenText:e,funcName:t,parser:n},a)=>{n.settings.strict&&n.mode==="math"&&console.log(`Temml strict-mode warning: Command ${t} is invalid in math mode.`);let c=n.parseExpression(!1,e,!0);return{type:"sizing",mode:n.mode,funcName:t,body:c}},mathmlBuilder:(e,t)=>{let n=t.withFontSize(Ns[e.funcName]),a=tt(e.body,n),c=Je(a),p=(Ns[e.funcName]/t.fontSize).toFixed(4);return c.setAttribute("mathsize",p+"em"),c}}),C({type:"smash",names:["\\smash"],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0},handler:({parser:e},t,n)=>{let a=!1,c=!1,p=n[0]&&te(n[0],"ordgroup");if(p){let x="";for(let q=0;q<p.body.length;++q)if(x=p.body[q].text,x==="t")a=!0;else{if(x!=="b"){a=!1,c=!1;break}c=!0}}else a=!0,c=!0;let g=t[0];return{type:"smash",mode:e.mode,body:g,smashHeight:a,smashDepth:c}},mathmlBuilder:(e,t)=>{let n=new _("mpadded",[He(e.body,t)]);return e.smashHeight&&n.setAttribute("height","0px"),e.smashDepth&&n.setAttribute("depth","0px"),n}});let xa=["a","c","e","\u0131","m","n","o","r","s","u","v","w","x","z","\u03B1","\u03B5","\u03B9","\u03BA","\u03BD","\u03BF","\u03C0","\u03C3","\u03C4","\u03C5","\u03C9","\\alpha","\\epsilon","\\iota","\\kappa","\\nu","\\omega","\\pi","\\tau","\\omega"];C({type:"sqrt",names:["\\sqrt"],props:{numArgs:1,numOptionalArgs:1},handler({parser:e},t,n){let a=n[0],c=t[0];return c.body&&c.body.length===1&&c.body[0].text&&xa.includes(c.body[0].text)&&c.body.push({type:"rule",mode:"math",shift:null,width:{number:0,unit:"pt"},height:{number:.5,unit:"em"}}),{type:"sqrt",mode:e.mode,body:c,index:a}},mathmlBuilder(e,t){let{body:n,index:a}=e;return a?new _("mroot",[He(n,t),He(a,t.incrementLevel())]):new _("msqrt",[He(n,t)])}});let va={display:0,text:1,script:2,scriptscript:3},ka={display:["0","true"],text:["0","false"],script:["1","false"],scriptscript:["2","false"]};C({type:"styling",names:["\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({breakOnTokenText:e,funcName:t,parser:n},a){let c=n.parseExpression(!0,e,!0),p=t.slice(1,t.length-5);return{type:"styling",mode:n.mode,scriptLevel:p,body:c}},mathmlBuilder(e,t){let n=t.withLevel(va[e.scriptLevel]),a=tt(e.body,n),c=Je(a),p=ka[e.scriptLevel];return c.setAttribute("scriptlevel",p[0]),c.setAttribute("displaystyle",p[1]),c}});let Ea=/^m(over|under|underover)$/;F({type:"supsub",mathmlBuilder(e,t){let n,a,c=!1,p=!1,g=!1,x=!1;e.base&&e.base.type==="horizBracket"&&(a=!!e.sup,a===e.base.isOver&&(c=!0,n=e.base.isOver)),!e.base||e.stack||e.base.type!=="op"&&e.base.type!=="operatorname"||(e.base.parentIsSupSub=!0,p=!e.base.symbol,g=p&&!e.isFollowedByDelimiter,x=e.base.needsLeadingSpace);let q=e.stack&&e.base.body.length===1?[He(e.base.body[0],t)]:[He(e.base,t)],j=t.inSubOrSup();if(e.sub){let ee=He(e.sub,j);t.level===3&&ee.setAttribute("scriptlevel","2"),q.push(ee)}if(e.sup){let ee=He(e.sup,j);if(t.level===3&&ee.setAttribute("scriptlevel","2"),e.base&&e.base.text&&e.base.text.length===1){let lt=e.base.text;"DHKLUcegorsuvxyz\u03A0\u03A5\u03A8\u03B1\u03B4\u03B7\u03B9\u03BC\u03BD\u03BF\u03C4\u03C5\u03C7\u03F5".indexOf(lt)>-1?ee.classes.push("tml-sml-pad"):"BCEFGIMNOPQRSTXZlpqtw\u0393\u0398\u039E\u03A3\u03A6\u03A9\u03B2\u03B5\u03B6\u03B8\u03BE\u03C1\u03C2\u03C6\u03C8\u03D1\u03D5\u03F1".indexOf(lt)>-1?ee.classes.push("tml-med-pad"):"AJdf\u0394\u039B".indexOf(lt)>-1&&ee.classes.push("tml-lrg-pad")}q.push(ee)}let ie;if(c)ie=n?"mover":"munder";else if(e.sub)if(e.sup){let ee=e.base;ie=ee&&(ee.type==="op"&&ee.limits||ee.type==="multiscript")&&(t.level===Ft||ee.alwaysHandleSupSub)||ee&&ee.type==="operatorname"&&ee.alwaysHandleSupSub&&(t.level===Ft||ee.limits)?"munderover":"msubsup"}else{let ee=e.base;ie=e.stack||ee&&ee.type==="op"&&ee.limits&&(t.level===Ft||ee.alwaysHandleSupSub)||ee&&ee.type==="operatorname"&&ee.alwaysHandleSupSub&&(ee.limits||t.level===Ft)?"munder":"msub"}else{let ee=e.base;ie=ee&&ee.type==="op"&&ee.limits&&(t.level===Ft||ee.alwaysHandleSupSub)||ee&&ee.type==="operatorname"&&ee.alwaysHandleSupSub&&(ee.limits||t.level===Ft)?"mover":"msup"}let he=new _(ie,q);if(p){let ee=new _("mo",[Xe("\u2061","text")]);if(x){let lt=new _("mspace");lt.setAttribute("width","0.1667em"),he=at([lt,he,ee])}else he=at([he,ee]);if(g){let lt=new _("mspace");lt.setAttribute("width","0.1667em"),he.children.push(lt)}}else Ea.test(ie)&&(he=new _("mrow",[he]));return he}});let Sa=["\\shortmid","\\nshortmid","\\shortparallel","\\nshortparallel","\\smallsetminus"],Aa=["\\Rsh","\\Lsh","\\restriction"];F({type:"atom",mathmlBuilder(e,t){let n=new _("mo",[Xe(e.text,e.mode)]);if(e.family==="punct")n.setAttribute("separator","true");else if(e.family==="open"||e.family==="close")e.family==="open"?(n.setAttribute("form","prefix"),n.setAttribute("stretchy","false")):e.family==="close"&&(n.setAttribute("form","postfix"),n.setAttribute("stretchy","false"));else if(e.text==="\\mid")n.setAttribute("lspace","0.22em"),n.setAttribute("rspace","0.22em"),n.setAttribute("stretchy","false");else if(e.family==="rel"&&(a=>{if(a.length===1){let c=a.codePointAt(0);return 8591<c&&c<8704}return a.indexOf("arrow")>-1||a.indexOf("harpoon")>-1||Aa.includes(a)})(e.text))n.setAttribute("stretchy","false");else if(Sa.includes(e.text))n.setAttribute("mathsize","70%");else if(e.text===":")n.attributes.lspace="0.2222em",n.attributes.rspace="0.2222em";else if(e.needsSpacing)return e.family==="bin"?new _("mrow",[U(.222),n,U(.222)]):new _("mrow",[U(.2778),n,U(.2778)]);return n}});let $s={mathbf:"bold",mathrm:"normal",textit:"italic",mathit:"italic",mathnormal:"italic",mathbb:"double-struck",mathcal:"script",mathfrak:"fraktur",mathscr:"script",mathsf:"sans-serif",mathtt:"monospace"},Os=function(e,t){if(t.fontFamily==="texttt")return"monospace";if(t.fontFamily==="textsc")return"normal";if(t.fontFamily==="textsf")return t.fontShape==="textit"&&t.fontWeight==="textbf"?"sans-serif-bold-italic":t.fontShape==="textit"?"sans-serif-italic":t.fontWeight==="textbf"?"sans-serif-bold":"sans-serif";if(t.fontShape==="textit"&&t.fontWeight==="textbf")return"bold-italic";if(t.fontShape==="textit")return"italic";if(t.fontWeight==="textbf")return"bold";let n=t.font;if(!n||n==="mathnormal")return null;let a=e.mode;switch(n){case"mathit":case"greekItalic":return"italic";case"mathrm":{let p=e.text.codePointAt(0);return 939<p&&p<975?"italic":"normal"}case"up@greek":return"normal";case"boldsymbol":case"mathboldsymbol":return"bold-italic";case"mathbf":return"bold";case"mathbb":return"double-struck";case"mathfrak":return"fraktur";case"mathscr":case"mathcal":return"script";case"mathsf":return"sans-serif";case"mathsfit":return"sans-serif-italic";case"mathtt":return"monospace"}let c=e.text;return Ce[a][c]&&Ce[a][c].replace&&(c=Ce[a][c].replace),Object.prototype.hasOwnProperty.call($s,n)?$s[n]:null},_a=/^\d(?:[\d,.]*\d)?$/,Ta=/[A-Ba-z]/,Ca=new Set(["\\prime","\\dprime","\\trprime","\\qprime","\\backprime","\\backdprime","\\backtrprime"]);F({type:"mathord",mathmlBuilder(e,t){let n=Xe(e.text,e.mode,t),a=n.text.codePointAt(0),c=912<a&&a<938?"normal":"italic",p=Os(e,t)||c;if(p==="script")return n.text=Dn(n.text,p),new _("mi",[n],[t.font]);p!=="italic"&&(n.text=Dn(n.text,p));let g=new _("mi",[n]);if(p==="normal"&&(g.setAttribute("mathvariant","normal"),n.text.length===1)){let x=new _("mspace",[]);g=new _("mrow",[g,x])}return g}}),F({type:"textord",mathmlBuilder(e,t){let n=e.text,a=n.codePointAt(0);t.fontFamily==="textsc"&&96<a&&a<123&&(n=ca[n]);let c=Xe(n,e.mode,t),p=Os(e,t)||"normal",g;if(_a.test(e.text)){let x=e.mode==="text"?"mtext":"mn";if(p==="italic"||p==="bold-italic")return((q,j,ie)=>{let he=new _(ie,[q]),ee=new _("mstyle",[he]);return ee.style["font-style"]="italic",ee.style["font-family"]="Cambria, 'Times New Roman', serif",j==="bold-italic"&&(ee.style["font-weight"]="bold"),ee})(c,p,x);p!=="normal"&&(c.text=c.text.split("").map(q=>Dn(q,p)).join("")),g=new _(x,[c])}else if(e.mode==="text")p!=="normal"&&(c.text=Dn(c.text,p)),g=new _("mtext",[c]);else if(Ca.has(e.text))g=new _("mo",[c]),g.classes.push("tml-prime");else{let x=c.text;p!=="italic"&&(c.text=Dn(c.text,p)),g=new _("mi",[c]),c.text===x&&Ta.test(x)&&g.setAttribute("mathvariant","italic")}return g}});let Na={"\\nobreak":"nobreak","\\allowbreak":"allowbreak"},$a={" ":{},"\\ ":{},"~":{className:"nobreak"},"\\space":{},"\\nobreakspace":{className:"nobreak"}};F({type:"spacing",mathmlBuilder(e,t){let n;if(Object.prototype.hasOwnProperty.call($a,e.text))n=new _("mtext",[new qe("\xA0")]);else{if(!Object.prototype.hasOwnProperty.call(Na,e.text))throw new r(`Unknown type of space "${e.text}"`);n=new _("mo"),e.text==="\\nobreak"&&n.setAttribute("linebreak","nobreak")}return n}}),F({type:"tag"});let Ms={"\\text":void 0,"\\textrm":"textrm","\\textsf":"textsf","\\texttt":"texttt","\\textnormal":"textrm","\\textsc":"textsc"},Ls={"\\textbf":"textbf","\\textmd":"textmd"},Oa={"\\textit":"textit","\\textup":"textup"};C({type:"text",names:["\\text","\\textrm","\\textsf","\\texttt","\\textnormal","\\textsc","\\textbf","\\textmd","\\textit","\\textup","\\emph"],props:{numArgs:1,argTypes:["text"],allowedInArgument:!0,allowedInText:!0},handler({parser:e,funcName:t},n){let a=n[0];return{type:"text",mode:e.mode,body:ge(a),font:t}},mathmlBuilder(e,t){let n=((c,p)=>{let g=c.font;return g?Ms[g]?p.withTextFontFamily(Ms[g]):Ls[g]?p.withTextFontWeight(Ls[g]):g==="\\emph"?p.fontShape==="textit"?p.withTextFontShape("textup"):p.withTextFontShape("textit"):p.withTextFontShape(Oa[g]):p})(e,t),a=bt(e.body,n);return Et(a)}}),C({type:"vcenter",names:["\\vcenter"],props:{numArgs:1,argTypes:["original"],allowedInText:!1},handler:({parser:e},t)=>({type:"vcenter",mode:e.mode,body:t[0]}),mathmlBuilder(e,t){let n=new _("mtd",[He(e.body,t)]);n.style.padding="0";let a=new _("mtr",[n]);return new _("mtable",[a])}}),C({type:"verb",names:["\\verb"],props:{numArgs:0,allowedInText:!0},handler(e,t,n){throw new r("\\verb ended by end of line instead of matching delimiter")},mathmlBuilder(e,t){let n=new qe(Ma(e)),a=new _("mtext",[n]);return a.setAttribute("mathvariant","monospace"),a}});let Ma=e=>e.body.replace(/ /g,e.star?"\u2423":"\xA0"),Mn=M,Rs=`[ \r
93
- ]`,La=`(\\\\[a-zA-Z@]+)${Rs}*`,qr="[\u0300-\u036F]",Is=new RegExp(`${qr}+$`),Ra=`(${Rs}+)|\\\\(
91
+ }`),k=(e,n)=>{let r="";if(e==="HTML"){if(!ir.test(n))throw new t("Invalid HTML input.");r=n}else if(e==="RGB"){if(!Mn.test(n))throw new t("Invalid RGB input.");n.split(",").map(l=>{r+=Kn(Number(l.trim()))})}else{if(!ar.test(n))throw new t("Invalid rbg input.");n.split(",").map(l=>{let u=Number(l.trim());if(u>1)throw new t("Color rgb input must be < 1.");r+=Kn(Number((255*u).toFixed(0)))})}return r.charAt(0)!=="#"&&(r="#"+r),r},z=(e,n,r)=>{let l=`\\\\color@${e}`;if(!Nt.exec(e))throw new t("Invalid color: '"+e+"'",r);return Gn.test(e)?"#"+e:(e.charAt(0)==="#"||(n.has(l)?e=n.get(l).tokens[0].text:On[e]&&(e=On[e])),e)},K=(e,n)=>{let r=ht(e.body,n.withColor(e.color));return r.length===0&&r.push(new T("mrow")),r=r.map(l=>(l.style.color=e.color,l)),bt(r)};C({type:"color",names:["\\textcolor"],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw","original"]},handler({parser:e,token:n},r,l){let u=l[0]&&Le(l[0],"raw").string,h="";if(u){let x=Le(r[0],"raw").string;h=k(u,x)}else h=z(Le(r[0],"raw").string,e.gullet.macros,n);let y=r[1];return{type:"color",mode:e.mode,color:h,isTextColor:!0,body:de(y)}},mathmlBuilder:K}),C({type:"color",names:["\\color"],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw"]},handler({parser:e,breakOnTokenText:n,token:r},l,u){let h=u[0]&&Le(u[0],"raw").string,y="";if(h){let q=Le(l[0],"raw").string;y=k(h,q)}else y=z(Le(l[0],"raw").string,e.gullet.macros,r);let x=e.parseExpression(!0,n,!0);return{type:"color",mode:e.mode,color:y,isTextColor:!1,body:x}},mathmlBuilder:K}),C({type:"color",names:["\\definecolor"],props:{numArgs:3,allowedInText:!0,argTypes:["raw","raw","raw"]},handler({parser:e,funcName:n,token:r},l){let u=Le(l[0],"raw").string;if(!/^[A-Za-z]+$/.test(u))throw new t("Color name must be latin letters.",r);let h=Le(l[1],"raw").string;if(!["HTML","RGB","rgb"].includes(h))throw new t("Color model must be HTML, RGB, or rgb.",r);let y=Le(l[2],"raw").string,x=k(h,y);return e.gullet.macros.set(`\\\\color@${u}`,{tokens:[{text:x}],numArgs:0}),{type:"internal",mode:e.mode}}}),C({type:"cr",names:["\\\\"],props:{numArgs:0,numOptionalArgs:0,allowedInText:!0},handler({parser:e},n,r){let l=e.gullet.future().text==="["?e.parseSizeGroup(!0):null,u=!e.settings.displayMode;return{type:"cr",mode:e.mode,newLine:u,size:l&&Le(l,"size").value}},mathmlBuilder(e,n){let r=new T("mo");if(e.newLine&&(r.setAttribute("linebreak","newline"),e.size)){let l=Dt(e.size,n);r.setAttribute("height",l.number+l.unit)}return r}});let me={"\\global":"\\global","\\long":"\\\\globallong","\\\\globallong":"\\\\globallong","\\def":"\\gdef","\\gdef":"\\gdef","\\edef":"\\xdef","\\xdef":"\\xdef","\\let":"\\\\globallet","\\futurelet":"\\\\globalfuture"},et=e=>{let n=e.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(n))throw new t("Expected a control sequence",e);return n},Ht=(e,n,r,l)=>{let u=e.gullet.macros.get(r.text);u==null&&(r.noexpand=!0,u={tokens:[r],numArgs:0,unexpandable:!e.gullet.isExpandable(r.text)}),e.gullet.macros.set(n,u,l)};C({type:"internal",names:["\\global","\\long","\\\\globallong"],props:{numArgs:0,allowedInText:!0},handler({parser:e,funcName:n}){e.consumeSpaces();let r=e.fetch();if(me[r.text])return n!=="\\global"&&n!=="\\\\globallong"||(r.text=me[r.text]),Le(e.parseFunction(),"internal");throw new t("Invalid token after macro prefix",r)}}),C({type:"internal",names:["\\def","\\gdef","\\edef","\\xdef"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:n}){let r=e.gullet.popToken(),l=r.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(l))throw new t("Expected a control sequence",r);let u,h=0,y=[[]];for(;e.gullet.future().text!=="{";)if(r=e.gullet.popToken(),r.text==="#"){if(e.gullet.future().text==="{"){u=e.gullet.future(),y[h].push("{");break}if(r=e.gullet.popToken(),!/^[1-9]$/.test(r.text))throw new t(`Invalid argument number "${r.text}"`);if(parseInt(r.text)!==h+1)throw new t(`Argument number "${r.text}" out of order`);h++,y.push([])}else{if(r.text==="EOF")throw new t("Expected a macro definition");y[h].push(r.text)}let{tokens:x}=e.gullet.consumeArg();if(u&&x.unshift(u),n==="\\edef"||n==="\\xdef"){if(x=e.gullet.expandTokens(x),x.length>e.gullet.settings.maxExpand)throw new t("Too many expansions in an "+n);x.reverse()}return e.gullet.macros.set(l,{tokens:x,numArgs:h,delimiters:y},n===me[n]),{type:"internal",mode:e.mode}}}),C({type:"internal",names:["\\let","\\\\globallet"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:n}){let r=et(e.gullet.popToken());e.gullet.consumeSpaces();let l=(u=>{let h=u.gullet.popToken();return h.text==="="&&(h=u.gullet.popToken(),h.text===" "&&(h=u.gullet.popToken())),h})(e);return Ht(e,r,l,n==="\\\\globallet"),{type:"internal",mode:e.mode}}}),C({type:"internal",names:["\\futurelet","\\\\globalfuture"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:n}){let r=et(e.gullet.popToken()),l=e.gullet.popToken(),u=e.gullet.popToken();return Ht(e,r,u,n==="\\\\globalfuture"),e.gullet.pushToken(u),e.gullet.pushToken(l),{type:"internal",mode:e.mode}}}),C({type:"internal",names:["\\newcommand","\\renewcommand","\\providecommand"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:n}){let r="",l=e.gullet.popToken();l.text==="{"?(r=et(e.gullet.popToken()),e.gullet.popToken()):r=et(l);let u=e.gullet.isDefined(r);if(u&&n==="\\newcommand")throw new t(`\\newcommand{${r}} attempting to redefine ${r}; use \\renewcommand`);if(!u&&n==="\\renewcommand")throw new t(`\\renewcommand{${r}} when command ${r} does not yet exist; use \\newcommand`);let h=0;if(e.gullet.future().text==="["){let x=e.gullet.popToken();if(x=e.gullet.popToken(),!/^[0-9]$/.test(x.text))throw new t(`Invalid number of arguments: "${x.text}"`);if(h=parseInt(x.text),x=e.gullet.popToken(),x.text!=="]")throw new t(`Invalid argument "${x.text}"`)}let{tokens:y}=e.gullet.consumeArg();return n==="\\providecommand"&&e.gullet.macros.has(r)||e.gullet.macros.set(r,{tokens:y,numArgs:h}),{type:"internal",mode:e.mode}}});let un={"\\bigl":{mclass:"mopen",size:1},"\\Bigl":{mclass:"mopen",size:2},"\\biggl":{mclass:"mopen",size:3},"\\Biggl":{mclass:"mopen",size:4},"\\bigr":{mclass:"mclose",size:1},"\\Bigr":{mclass:"mclose",size:2},"\\biggr":{mclass:"mclose",size:3},"\\Biggr":{mclass:"mclose",size:4},"\\bigm":{mclass:"mrel",size:1},"\\Bigm":{mclass:"mrel",size:2},"\\biggm":{mclass:"mrel",size:3},"\\Biggm":{mclass:"mrel",size:4},"\\big":{mclass:"mord",size:1},"\\Big":{mclass:"mord",size:2},"\\bigg":{mclass:"mord",size:3},"\\Bigg":{mclass:"mord",size:4}},an={"(":")","\\lparen":"\\rparen","[":"]","\\lbrack":"\\rbrack","\\{":"\\}","\\lbrace":"\\rbrace","\u2987":"\u2988","\\llparenthesis":"\\rrparenthesis","\\lfloor":"\\rfloor","\u230A":"\u230B","\\lceil":"\\rceil","\u2308":"\u2309","\\langle":"\\rangle","\u27E8":"\u27E9","\\lAngle":"\\rAngle","\u27EA":"\u27EB","\\llangle":"\\rrangle","\u2989":"\u298A","\\lvert":"\\rvert","\\lVert":"\\rVert","\\lgroup":"\\rgroup","\u27EE":"\u27EF","\\lmoustache":"\\rmoustache","\u23B0":"\u23B1","\\llbracket":"\\rrbracket","\u27E6":"\u27E7","\\lBrace":"\\rBrace","\u2983":"\u2984"},Vt=new Set(Object.keys(an));new Set(Object.values(an));let qn=new Set(["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\u2987","\\llparenthesis","\u2988","\\rrparenthesis","\\lfloor","\\rfloor","\u230A","\u230B","\\lceil","\\rceil","\u2308","\u2309","<",">","\\langle","\u27E8","\\rangle","\u27E9","\\lAngle","\u27EA","\\rAngle","\u27EB","\\llangle","\u2989","\\rrangle","\u298A","\\lt","\\gt","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","\u27EE","\u27EF","\\lmoustache","\\rmoustache","\u23B0","\u23B1","\\llbracket","\\rrbracket","\u27E6","\u27E7","\\lBrace","\\rBrace","\u2983","\u2984","/","\\backslash","|","\\vert","\\|","\\Vert","\u2016","\\uparrow","\\Uparrow","\\downarrow","\\Downarrow","\\updownarrow","\\Updownarrow","."]),en=new Set(["}","\\left","\\middle","\\right"]),Ln=e=>e.length>0&&(qn.has(e)||un[e]||en.has(e)),Wn=[0,1.2,1.8,2.4,3];function Vn(e,n){e.type==="ordgroup"&&e.body.length===1&&(e=e.body[0]);let r=M(e);if(r&&qn.has(r.text))return r.text!=="<"&&r.text!=="\\lt"||(r.text="\u27E8"),r.text!==">"&&r.text!=="\\gt"||(r.text="\u27E9"),r;throw new t(r?`Invalid delimiter '${r.text}' after '${n.funcName}'`:`Invalid delimiter type '${e.type}'`,e)}let lr=new Set(["/","\\","\\backslash","\u2216","\\vert","|"]),cr=(e,n,r,l)=>{let u=new T("mo",[nt(e==="."?"":e,n)]);return u.setAttribute("fence","true"),u.setAttribute("form",r),u.setAttribute("stretchy",l?"true":"false"),u};function dr(e){if(!e.body)throw new Error("Bug: The delim ParseNode wasn't fully parsed.")}C({type:"delimsizing",names:["\\bigl","\\Bigl","\\biggl","\\Biggl","\\bigr","\\Bigr","\\biggr","\\Biggr","\\bigm","\\Bigm","\\biggm","\\Biggm","\\big","\\Big","\\bigg","\\Bigg"],props:{numArgs:1,argTypes:["primitive"]},handler:(e,n)=>{let r=Vn(n[0],e),l={type:"delimsizing",mode:e.parser.mode,size:un[e.funcName].size,mclass:un[e.funcName].mclass,delim:r.text},u=e.parser.fetch().text;return u!=="^"&&u!=="_"?l:{type:"ordgroup",mode:"math",body:[l,{type:"ordgroup",mode:"math",body:[]}]}},mathmlBuilder:e=>{let n=[],r=e.delim==="."?"":e.delim;n.push(nt(r,e.mode));let l=new T("mo",n);return e.mclass==="mopen"||e.mclass==="mclose"?l.setAttribute("fence","true"):l.setAttribute("fence","false"),(lr.has(r)||r.indexOf("arrow")>-1)&&l.setAttribute("stretchy","true"),l.setAttribute("symmetric","true"),l.setAttribute("minsize",Wn[e.size]+"em"),l.setAttribute("maxsize",Wn[e.size]+"em"),l}}),C({type:"leftright-right",names:["\\right"],props:{numArgs:1,argTypes:["primitive"]},handler:(e,n)=>({type:"leftright-right",mode:e.parser.mode,delim:Vn(n[0],e).text})}),C({type:"leftright",names:["\\left"],props:{numArgs:1,argTypes:["primitive"]},handler:(e,n)=>{let r=Vn(n[0],e),l=e.parser;++l.leftrightDepth;let u=l.parseExpression(!1,"\\right",!0),h=l.fetch();for(;h.text==="\\middle";){l.consume();let x=l.fetch().text;if(!Q.math[x])throw new t(`Invalid delimiter '${x}' after '\\middle'`);Vn({type:"atom",mode:"math",text:x},{funcName:"\\middle"}),u.push({type:"middle",mode:"math",delim:x}),l.consume(),u=u.concat(l.parseExpression(!1,"\\right",!0)),h=l.fetch()}--l.leftrightDepth,l.expect("\\right",!1);let y=Le(l.parseFunction(),"leftright-right");return{type:"leftright",mode:l.mode,body:u,left:r.text,right:y.delim,isStretchy:!0}},mathmlBuilder:(e,n)=>{dr(e);let r=ht(e.body,n),l=cr(e.left,e.mode,"prefix",!0);r.unshift(l);let u=cr(e.right,e.mode,"postfix",!0);if(e.body.length>0){let h=e.body[e.body.length-1];h.type!=="color"||h.isTextColor||u.setAttribute("mathcolor",h.color)}return r.push(u),ke(r)}}),C({type:"delimiter",names:Array.from(Vt),props:{numArgs:0,allowedInText:!0,allowedInMath:!0,allowedInArgument:!0},handler:({parser:e,funcName:n,token:r})=>{if(e.mode==="text")return{type:"textord",mode:"text",text:n,loc:r.loc};if(!e.settings.wrapDelimiterPairs)return{type:"atom",mode:"math",family:"open",loc:r.loc,text:n};let l=an[n],u=e.parseExpression(!1,l,!1);if(e.fetch().text!==l)throw new t("Unmatched delimiter");return e.consume(),{type:"delimiter",mode:e.mode,body:u,left:n,right:l}},mathmlBuilder:(e,n)=>{dr(e);let r=ht(e.body,n),l=cr(e.left,e.mode,"prefix",!1);r.unshift(l);let u=cr(e.right,e.mode,"postfix",!1);if(e.body.length>0){let h=e.body[e.body.length-1];h.type!=="color"||h.isTextColor||u.setAttribute("mathcolor",h.color)}return r.push(u),ke(r)}}),C({type:"middle",names:["\\middle"],props:{numArgs:1,argTypes:["primitive"]},handler:(e,n)=>{let r=Vn(n[0],e);if(!e.parser.leftrightDepth)throw new t("\\middle without preceding \\left",r);return{type:"middle",mode:e.parser.mode,delim:r.text}},mathmlBuilder:e=>{let n=nt(e.delim,e.mode),r=new T("mo",[n]);return r.setAttribute("stretchy","true"),r.setAttribute("form","infix"),n.text!=="/"&&(r.setAttribute("lspace","0.05em"),r.setAttribute("rspace","0.05em")),r}});let rs=["\\boxed","\\fcolorbox","\\colorbox"],Fn=(e,n)=>{let r=rs.includes(e.label)?"mrow":"menclose",l=new T(r,[He(e.body,n)]);switch(e.label){case"\\overline":l.setAttribute("notation","top"),l.classes.push("tml-overline");break;case"\\underline":l.setAttribute("notation","bottom"),l.classes.push("tml-underline");break;case"\\cancel":l.setAttribute("notation","updiagonalstrike"),l.children.push(new T("mrow",[],["tml-cancel","upstrike"]));break;case"\\bcancel":l.setAttribute("notation","downdiagonalstrike"),l.children.push(new T("mrow",[],["tml-cancel","downstrike"]));break;case"\\sout":l.setAttribute("notation","horizontalstrike"),l.children.push(new T("mrow",[],["tml-cancel","sout"]));break;case"\\xcancel":l.setAttribute("notation","updiagonalstrike downdiagonalstrike"),l.children.push(new T("mrow",[],["tml-cancel","tml-xcancel"]));break;case"\\longdiv":l.setAttribute("notation","longdiv"),l.classes.push("longdiv-top"),l.children.push(new T("mrow",[],["longdiv-arc"]));break;case"\\phase":l.setAttribute("notation","phasorangle"),l.classes.push("phasor-bottom"),l.children.push(new T("mrow",[],["phasor-angle"]));break;case"\\textcircled":l.setAttribute("notation","circle"),l.classes.push("circle-pad"),l.children.push(new T("mrow",[],["textcircle"]));break;case"\\angl":l.setAttribute("notation","actuarial"),l.classes.push("actuarial");break;case"\\boxed":l.style.padding="3pt",l.style.border="1px solid",l.setAttribute("scriptlevel","0"),l.setAttribute("displaystyle","true");break;case"\\fbox":l.setAttribute("notation","box"),l.classes.push("tml-fbox");break;case"\\fcolorbox":case"\\colorbox":l.style.padding="0.3em",e.label==="\\fcolorbox"&&(l.style.border="0.0667em solid "+String(e.borderColor))}return e.backgroundColor&&l.setAttribute("mathbackground",e.backgroundColor),l};C({type:"enclose",names:["\\colorbox"],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw","text"]},handler({parser:e,funcName:n},r,l){let u=l[0]&&Le(l[0],"raw").string,h="";if(u){let x=Le(r[0],"raw").string;h=k(u,x)}else h=z(Le(r[0],"raw").string,e.gullet.macros);let y=r[1];return{type:"enclose",mode:e.mode,label:n,backgroundColor:h,body:y}},mathmlBuilder:Fn}),C({type:"enclose",names:["\\fcolorbox"],props:{numArgs:3,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw","raw","text"]},handler({parser:e,funcName:n},r,l){let u=l[0]&&Le(l[0],"raw").string,h,y="";if(u){let q=Le(r[0],"raw").string,Z=Le(r[0],"raw").string;y=k(u,q),h=k(u,Z)}else y=z(Le(r[0],"raw").string,e.gullet.macros),h=z(Le(r[1],"raw").string,e.gullet.macros);let x=r[2];return{type:"enclose",mode:e.mode,label:n,backgroundColor:h,borderColor:y,body:x}},mathmlBuilder:Fn}),C({type:"enclose",names:["\\fbox"],props:{numArgs:1,argTypes:["hbox"],allowedInText:!0},handler:({parser:e},n)=>({type:"enclose",mode:e.mode,label:"\\fbox",body:n[0]})}),C({type:"enclose",names:["\\angl","\\cancel","\\bcancel","\\xcancel","\\overline","\\boxed","\\longdiv","\\phase"],props:{numArgs:1},handler({parser:e,funcName:n},r){let l=r[0];return{type:"enclose",mode:e.mode,label:n,body:l}},mathmlBuilder:Fn}),C({type:"enclose",names:["\\sout"],props:{numArgs:1,allowedInText:!0},handler({parser:e,funcName:n},r){let l=r[0];return{type:"enclose",mode:e.mode,label:n,body:l}},mathmlBuilder:Fn}),C({type:"enclose",names:["\\underline"],props:{numArgs:1,allowedInText:!0},handler({parser:e,funcName:n},r){let l=r[0];return{type:"enclose",mode:e.mode,label:n,body:l}},mathmlBuilder:Fn}),C({type:"enclose",names:["\\textcircled"],props:{numArgs:1,argTypes:["text"],allowedInArgument:!0,allowedInText:!0},handler({parser:e,funcName:n},r){let l=r[0];return{type:"enclose",mode:e.mode,label:n,body:l}},mathmlBuilder:Fn}),C({type:"environment",names:["\\begin","\\end"],props:{numArgs:1,argTypes:["text"]},handler({parser:e,funcName:n},r){let l=r[0];if(l.type!=="ordgroup")throw new t("Invalid environment name",l);let u="";for(let h=0;h<l.body.length;++h)u+=Le(l.body[h],"textord").text;if(n==="\\begin"){if(!Object.prototype.hasOwnProperty.call(fn,u))throw new t("No such environment: "+u,l);let h=fn[u],{args:y,optArgs:x}=e.parseArguments("\\begin{"+u+"}",h),q={mode:e.mode,envName:u,parser:e},Z=h.handler(q,y,x);e.expect("\\end",!1);let ve=e.nextToken,Te=Le(e.parseFunction(),"environment");if(Te.name!==u)throw new t(`Mismatch: \\begin{${u}} matched by \\end{${Te.name}}`,ve);return Z}return{type:"environment",mode:e.mode,name:u,nameGroup:l}}}),C({type:"envTag",names:["\\env@tag"],props:{numArgs:1,argTypes:["math"]},handler:({parser:e},n)=>({type:"envTag",mode:e.mode,body:n[0]}),mathmlBuilder:(e,n)=>new T("mrow")}),C({type:"noTag",names:["\\env@notag"],props:{numArgs:0},handler:({parser:e})=>({type:"noTag",mode:e.mode}),mathmlBuilder:(e,n)=>new T("mrow")});let ss=Object.freeze({B:8426,E:8427,F:8427,H:8387,I:8391,L:8390,M:8422,R:8393,e:8394,g:8355,o:8389}),qs=Object.freeze({C:8426,H:8388,I:8392,R:8394,Z:8398}),vr=Object.freeze({C:8383,H:8389,N:8391,P:8393,Q:8393,R:8395,Z:8394}),ur=Object.freeze({"\u03F5":119527,\u03D1:119564,\u03F0:119534,\u03C6:119577,\u03F1:119535,\u03D6:119563}),Fs=Object.freeze({"\u03F5":119643,\u03D1:119680,\u03F0:119650,\u03C6:119693,\u03F1:119651,\u03D6:119679}),Zn=Object.freeze({"\u03F5":119701,\u03D1:119738,\u03F0:119708,\u03C6:119751,\u03F1:119709,\u03D6:119737}),zs=Object.freeze({"\u03F5":119759,\u03D1:119796,\u03F0:119766,\u03C6:119809,\u03F1:119767,\u03D6:119795}),Yn=Object.freeze({upperCaseLatin:{normal:e=>0,bold:e=>119743,italic:e=>119795,"bold-italic":e=>119847,script:e=>ss[e]||119899,"script-bold":e=>119951,fraktur:e=>qs[e]||120003,"fraktur-bold":e=>120107,"double-struck":e=>vr[e]||120055,"sans-serif":e=>120159,"sans-serif-bold":e=>120211,"sans-serif-italic":e=>120263,"sans-serif-bold-italic":e=>120380,monospace:e=>120367},lowerCaseLatin:{normal:e=>0,bold:e=>119737,italic:e=>e==="h"?8358:119789,"bold-italic":e=>119841,script:e=>ss[e]||119893,"script-bold":e=>119945,fraktur:e=>119997,"fraktur-bold":e=>120101,"double-struck":e=>120049,"sans-serif":e=>120153,"sans-serif-bold":e=>120205,"sans-serif-italic":e=>120257,"sans-serif-bold-italic":e=>120309,monospace:e=>120361},upperCaseGreek:{normal:e=>0,bold:e=>119575,italic:e=>119633,"bold-italic":e=>119575,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>0,"sans-serif":e=>119749,"sans-serif-bold":e=>119749,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>119807,monospace:e=>0},lowerCaseGreek:{normal:e=>0,bold:e=>119569,italic:e=>119627,"bold-italic":e=>e==="\u03D5"?119678:119685,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>0,"sans-serif":e=>119743,"sans-serif-bold":e=>119743,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>119801,monospace:e=>0},varGreek:{normal:e=>0,bold:e=>ur[e]||-51,italic:e=>0,"bold-italic":e=>Fs[e]||58,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>0,"sans-serif":e=>Zn[e]||116,"sans-serif-bold":e=>Zn[e]||116,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>zs[e]||174,monospace:e=>0},numeral:{normal:e=>0,bold:e=>120734,italic:e=>0,"bold-italic":e=>0,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>120744,"sans-serif":e=>120754,"sans-serif-bold":e=>120764,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>0,monospace:e=>120774}}),zn=(e,n)=>{let r=e.codePointAt(0),l=64<r&&r<91?"upperCaseLatin":96<r&&r<123?"lowerCaseLatin":912<r&&r<938?"upperCaseGreek":944<r&&r<970||e==="\u03D5"?"lowerCaseGreek":120545<r&&r<120572||ur[e]?"varGreek":47<r&&r<58?"numeral":"other";return l==="other"?e:String.fromCodePoint(r+Yn[l][n](e))},os=Object.freeze({a:"\u1D00",b:"\u0299",c:"\u1D04",d:"\u1D05",e:"\u1D07",f:"\uA730",g:"\u0262",h:"\u029C",i:"\u026A",j:"\u1D0A",k:"\u1D0B",l:"\u029F",m:"\u1D0D",n:"\u0274",o:"\u1D0F",p:"\u1D18",q:"\u01EB",r:"\u0280",s:"s",t:"\u1D1B",u:"\u1D1C",v:"\u1D20",w:"\u1D21",x:"x",y:"\u028F",z:"\u1D22"}),Us=["mathrm","mathit"],qr=(e,n)=>{let r=e.font,l=n.withFont(r),u=He(e.body,l);if(u.children.length===0)return u;if(r==="boldsymbol"&&["mo","mpadded","mrow"].includes(u.type))return u.style.fontWeight="bold",u;if(((x,q)=>{if(!Us.includes(q)||!x.body||x.body.type!=="ordgroup"||x.body.body.length===1||x.body.body[0].type!=="mathord")return!1;for(let Z=1;Z<x.body.body.length;Z++){let ve=x.body.body[Z].type;if(ve!=="mathord"&&(ve!=="textord"||isNaN(x.body.body[Z].text)))return!1}return!0})(e,r)){let x=u.children[0].children[0].children?u.children[0].children[0]:u.children[0];delete x.attributes.mathvariant;for(let Z=1;Z<u.children.length;Z++)x.children[0].text+=u.children[Z].children[0].children?u.children[Z].children[0].children[0].text:u.children[Z].children[0].text;if(r==="mathit")return x.children[0].text=x.children[0].text.split("").map(Z=>zn(Z,"italic")).join(""),x;let q=new T("mpadded",[x]);return q.setAttribute("lspace","0"),q}let h=u.children[0].type==="mo";for(let x=1;x<u.children.length;x++)u.children[x].type==="mo"&&r==="boldsymbol"&&(u.children[x].style.fontWeight="bold"),u.children[x].type!=="mi"&&(h=!1),(u.children[x].attributes&&u.children[x].attributes.mathvariant||"")!=="normal"&&(h=!1);if(!h)return u;let y=u.children[0];for(let x=1;x<u.children.length;x++)y.children.push(u.children[x].children[0]);if(y.attributes.mathvariant&&y.attributes.mathvariant==="normal"){let x=new T("mtext",new Ke("\u200B"));return new T("mrow",[x,y])}return y},pr={"\\Bbb":"\\mathbb","\\bold":"\\mathbf","\\frak":"\\mathfrak","\\bm":"\\boldsymbol"};C({type:"font",names:["\\mathrm","\\mathit","\\mathbf","\\mathnormal","\\up@greek","\\boldsymbol","\\mathbb","\\mathcal","\\mathfrak","\\mathscr","\\mathsf","\\mathsfit","\\mathtt","\\Bbb","\\bm","\\bold","\\frak"],props:{numArgs:1,allowedInArgument:!0},handler:({parser:e,funcName:n},r)=>{let l=Se(r[0]),u=n;return u in pr&&(u=pr[u]),{type:"font",mode:e.mode,font:u.slice(1),body:l}},mathmlBuilder:qr}),C({type:"font",names:["\\rm","\\sf","\\tt","\\bf","\\it","\\cal"],props:{numArgs:0,allowedInText:!0},handler:({parser:e,funcName:n,breakOnTokenText:r},l)=>{let{mode:u}=e,h=e.parseExpression(!0,r,!0);return{type:"font",mode:u,font:`math${n.slice(1)}`,body:{type:"ordgroup",mode:e.mode,body:h}}},mathmlBuilder:qr});let Fr=["display","text","script","scriptscript"],is={auto:-1,display:0,text:0,script:1,scriptscript:2},hr=(e,n)=>{n=((h,y)=>{let x=y;if(h==="display"){let q=x.level>=yt?Tt:Et;x=x.withLevel(q)}else h==="text"&&x.level===Et?x=x.withLevel(Tt):h==="auto"?x=x.incrementLevel():h==="script"?x=x.withLevel(yt):h==="scriptscript"&&(x=x.withLevel(Qe));return x})(e.scriptLevel,n);let r=He(e.numer,n),l=He(e.denom,n);n.level===3&&(r.style.mathDepth="2",r.setAttribute("scriptlevel","2"),l.style.mathDepth="2",l.setAttribute("scriptlevel","2"));let u=new T("mfrac",[r,l]);if(e.hasBarLine){if(e.barSize){let h=Dt(e.barSize,n);u.setAttribute("linethickness",h.number+h.unit)}}else u.setAttribute("linethickness","0px");if(e.leftDelim!=null||e.rightDelim!=null){let h=[];if(e.leftDelim!=null){let y=new T("mo",[new Ke(e.leftDelim.replace("\\",""))]);y.setAttribute("fence","true"),h.push(y)}if(h.push(u),e.rightDelim!=null){let y=new T("mo",[new Ke(e.rightDelim.replace("\\",""))]);y.setAttribute("fence","true"),h.push(y)}u=ke(h)}return e.scriptLevel!=="auto"&&(u=new T("mstyle",[u]),u.setAttribute("displaystyle",String(e.scriptLevel==="display")),u.setAttribute("scriptlevel",is[e.scriptLevel])),u};C({type:"genfrac",names:["\\cfrac","\\dfrac","\\frac","\\tfrac","\\dbinom","\\binom","\\tbinom","\\\\atopfrac","\\\\bracefrac","\\\\brackfrac"],props:{numArgs:2,allowedInArgument:!0},handler:({parser:e,funcName:n},r)=>{let l=r[0],u=r[1],h=!1,y=null,x=null,q="auto";switch(n){case"\\cfrac":case"\\dfrac":case"\\frac":case"\\tfrac":h=!0;break;case"\\\\atopfrac":h=!1;break;case"\\dbinom":case"\\binom":case"\\tbinom":y="(",x=")";break;case"\\\\bracefrac":y="\\{",x="\\}";break;case"\\\\brackfrac":y="[",x="]";break;default:throw new Error("Unrecognized genfrac command")}return n==="\\cfrac"||n.startsWith("\\d")?q="display":n.startsWith("\\t")&&(q="text"),{type:"genfrac",mode:e.mode,continued:!1,numer:l,denom:u,hasBarLine:h,leftDelim:y,rightDelim:x,scriptLevel:q,barSize:null}},mathmlBuilder:hr}),C({type:"infix",names:["\\over","\\choose","\\atop","\\brace","\\brack"],props:{numArgs:0,infix:!0},handler({parser:e,funcName:n,token:r}){let l;switch(n){case"\\over":l="\\frac";break;case"\\choose":l="\\binom";break;case"\\atop":l="\\\\atopfrac";break;case"\\brace":l="\\\\bracefrac";break;case"\\brack":l="\\\\brackfrac";break;default:throw new Error("Unrecognized infix genfrac command")}return{type:"infix",mode:e.mode,replaceWith:l,token:r}}});let zr=function(e){let n=null;return e.length>0&&(n=e,n=n==="."?null:n),n};C({type:"genfrac",names:["\\genfrac"],props:{numArgs:6,allowedInArgument:!0,argTypes:["math","math","size","text","math","math"]},handler({parser:e},n){let r=n[4],l=n[5],u=Se(n[0]),h=u.type==="atom"&&u.family==="open"?zr(u.text):null,y=Se(n[1]),x=y.type==="atom"&&y.family==="close"?zr(y.text):null,q=Le(n[2],"size"),Z,ve=null;q.isBlank?Z=!0:(ve=q.value,Z=ve.number>0);let Te="auto",le=n[3];if(le.type==="ordgroup"){if(le.body.length>0){let xt=Le(le.body[0],"textord");Te=Fr[Number(xt.text)]}}else le=Le(le,"textord"),Te=Fr[Number(le.text)];return{type:"genfrac",mode:e.mode,numer:r,denom:l,continued:!1,hasBarLine:Z,barSize:ve,leftDelim:h,rightDelim:x,scriptLevel:Te}},mathmlBuilder:hr}),C({type:"infix",names:["\\above"],props:{numArgs:1,argTypes:["size"],infix:!0},handler:({parser:e,funcName:n,token:r},l)=>({type:"infix",mode:e.mode,replaceWith:"\\\\abovefrac",barSize:Le(l[0],"size").value,token:r})}),C({type:"genfrac",names:["\\\\abovefrac"],props:{numArgs:3,argTypes:["math","size","math"]},handler:({parser:e,funcName:n},r)=>{let l=r[0],u=function(x){if(!x)throw new Error("Expected non-null, but got "+String(x));return x}(Le(r[1],"infix").barSize),h=r[2],y=u.number>0;return{type:"genfrac",mode:e.mode,numer:l,denom:h,continued:!1,hasBarLine:y,barSize:u,leftDelim:null,rightDelim:null,scriptLevel:"auto"}},mathmlBuilder:hr}),C({type:"hbox",names:["\\hbox"],props:{numArgs:1,argTypes:["hbox"],allowedInArgument:!0,allowedInText:!1},handler:({parser:e},n)=>({type:"hbox",mode:e.mode,body:de(n[0])}),mathmlBuilder(e,n){let r=n.withLevel(Tt),l=tt(e.body,r);return ut(l)}}),C({type:"horizBracket",names:["\\overbrace","\\underbrace","\\overbracket","\\underbracket"],props:{numArgs:1},handler:({parser:e,funcName:n},r)=>({type:"horizBracket",mode:e.mode,label:n,isOver:/^\\over/.test(n),base:r[0]}),mathmlBuilder:(e,n)=>{let r=J(e.label);return r.style["math-depth"]=0,new T(e.isOver?"mover":"munder",[He(e.base,n),r])}}),C({type:"html",names:["\\class","\\id","\\style","\\data"],props:{numArgs:2,argTypes:["raw","original"],allowedInText:!0},handler:({parser:e,funcName:n,token:r},l)=>{let u=Le(l[0],"raw").string,h=l[1];if(e.settings.strict)throw new t(`Function "${n}" is disabled in strict mode`,r);let y,x={};switch(n){case"\\class":x.class=u,y={command:"\\class",class:u};break;case"\\id":x.id=u,y={command:"\\id",id:u};break;case"\\style":x.style=u,y={command:"\\style",style:u};break;case"\\data":{let q=u.split(",");for(let Z=0;Z<q.length;Z++){let ve=q[Z].split("=");if(ve.length!==2)throw new t("Error parsing key-value for \\data");x["data-"+ve[0].trim()]=ve[1].trim()}y={command:"\\data",attributes:x};break}default:throw new Error("Unrecognized html command")}if(!e.settings.isTrusted(y))throw new t(`Function "${n}" is not trusted`,r);return{type:"html",mode:e.mode,attributes:x,body:de(h)}},mathmlBuilder:(e,n)=>{let r=tt(e.body,n),l=[];e.attributes.class&&l.push(...e.attributes.class.trim().split(/\s+/)),r.classes=l;for(let u in e.attributes)u!=="class"&&Object.prototype.hasOwnProperty.call(e.attributes,u)&&r.setAttribute(u,e.attributes[u]);return r}});let xr=function(e){if(/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(e))return{number:+e,unit:"bp"};{let n=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(e);if(!n)throw new t("Invalid size: '"+e+"' in \\includegraphics");let r={number:+(n[1]+n[2]),unit:n[3]};if(!Lt(r))throw new t("Invalid unit: '"+r.unit+"' in \\includegraphics.");return r}};C({type:"includegraphics",names:["\\includegraphics"],props:{numArgs:1,numOptionalArgs:1,argTypes:["raw","url"],allowedInText:!1},handler:({parser:e,token:n},r,l)=>{let u={number:0,unit:"em"},h={number:.9,unit:"em"},y={number:0,unit:"em"},x="";if(l[0]){let Z=Le(l[0],"raw").string.split(",");for(let ve=0;ve<Z.length;ve++){let Te=Z[ve].split("=");if(Te.length===2){let le=Te[1].trim();switch(Te[0].trim()){case"alt":x=le;break;case"width":u=xr(le);break;case"height":h=xr(le);break;case"totalheight":y=xr(le);break;default:throw new t("Invalid key: '"+Te[0]+"' in \\includegraphics.")}}}}let q=Le(r[0],"url").url;if(x===""&&(x=q,x=x.replace(/^.*[\\/]/,""),x=x.substring(0,x.lastIndexOf("."))),!e.settings.isTrusted({command:"\\includegraphics",url:q}))throw new t('Function "\\includegraphics" is not trusted',n);return{type:"includegraphics",mode:e.mode,alt:x,width:u,height:h,totalheight:y,src:q}},mathmlBuilder:(e,n)=>{let r=Dt(e.height,n),l={number:0,unit:"em"};e.totalheight.number>0&&e.totalheight.unit===r.unit&&e.totalheight.number>r.number&&(l.number=e.totalheight.number-r.number,l.unit=r.unit);let u=0;e.width.number>0&&(u=Dt(e.width,n));let h={height:r.number+l.number+"em"};u.number>0&&(h.width=u.number+u.unit),l.number>0&&(h.verticalAlign=-l.number+l.unit);let y=new st(e.src,e.alt,h);return y.height=r,y.depth=l,new T("mtext",[y])}}),C({type:"kern",names:["\\kern","\\mkern","\\hskip","\\mskip"],props:{numArgs:1,argTypes:["size"],primitive:!0,allowedInText:!0},handler({parser:e,funcName:n,token:r},l){let u=Le(l[0],"size");if(e.settings.strict){let h=n[1]==="m",y=u.value.unit==="mu";if(h){if(!y)throw new t(`LaTeX's ${n} supports only mu units, not ${u.value.unit} units`,r);if(e.mode!=="math")throw new t(`LaTeX's ${n} works only in math mode`,r)}else if(y)throw new t(`LaTeX's ${n} doesn't support mu units`,r)}return{type:"kern",mode:e.mode,dimension:u.value}},mathmlBuilder(e,n){let r=Dt(e.dimension,n),l=r.number>0&&r.unit==="em"?mr(r.number):"";if(e.mode==="text"&&l.length>0){let u=new Ke(l);return new T("mtext",[u])}if(r.number>=0){let u=new T("mspace");return u.setAttribute("width",r.number+r.unit),u}{let u=new T("mrow");return u.style.marginLeft=r.number+r.unit,u}}});let mr=function(e){return e>=.05555&&e<=.05556?"\u200A":e>=.1666&&e<=.1667?"\u2009":e>=.2222&&e<=.2223?"\u2005":e>=.2777&&e<=.2778?"\u2005\u200A":""},tn=/[^A-Za-z_0-9-]/g;C({type:"label",names:["\\label"],props:{numArgs:1,argTypes:["raw"]},handler:({parser:e},n)=>({type:"label",mode:e.mode,string:n[0].string.replace(tn,"")}),mathmlBuilder(e,n){let r=new T("mrow",[],["tml-label"]);return e.string.length>0&&r.setLabel(e.string),r}});let fr=["\\clap","\\llap","\\rlap"];C({type:"lap",names:["\\mathllap","\\mathrlap","\\mathclap","\\clap","\\llap","\\rlap"],props:{numArgs:1,allowedInText:!0},handler:({parser:e,funcName:n,token:r},l)=>{if(fr.includes(n)){if(e.settings.strict&&e.mode!=="text")throw new t(`{${n}} can be used only in text mode.
92
+ Try \\math${n.slice(1)}`,r);n=n.slice(1)}else n=n.slice(5);let u=l[0];return{type:"lap",mode:e.mode,alignment:n,body:u}},mathmlBuilder:(e,n)=>{let r;if(e.alignment==="llap"){let h=ht(de(e.body),n),y=new T("mphantom",h);r=new T("mpadded",[y]),r.setAttribute("width","0.1px")}let l=He(e.body,n),u;if(e.alignment==="llap"?(l.style.position="absolute",l.style.right="0",l.style.bottom="0",u=new T("mpadded",[r,l])):u=new T("mpadded",[l]),e.alignment==="rlap")e.body.body.length>0&&e.body.body[0].type==="genfrac"&&u.setAttribute("lspace","0.16667em");else{let h=e.alignment==="llap"?"-1":"-0.5";u.setAttribute("lspace",h+"width"),e.alignment==="llap"?u.style.position="relative":(u.style.display="flex",u.style.justifyContent="center")}return u.setAttribute("width","0.1px"),u}}),C({type:"ordgroup",names:["\\(","$"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler({funcName:e,parser:n},r){let l=n.mode;n.switchMode("math");let u=e==="\\("?"\\)":"$",h=n.parseExpression(!1,u);return n.expect(u),n.switchMode(l),{type:"ordgroup",mode:n.mode,body:h}}}),C({type:"text",names:["\\)","\\]"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(e,n){throw new t(`Mismatched ${e.funcName}`,n)}}),C({type:"mathchoice",names:["\\mathchoice"],props:{numArgs:4,primitive:!0},handler:({parser:e},n)=>({type:"mathchoice",mode:e.mode,display:de(n[0]),text:de(n[1]),script:de(n[2]),scriptscript:de(n[3])}),mathmlBuilder:(e,n)=>{let r=((l,u)=>{switch(u.level){case Et:return l.display;case Tt:return l.text;case yt:return l.script;case Qe:return l.scriptscript;default:return l.text}})(e,n);return tt(r,n)}});let Tn=["text","textord","mathord","atom"];function Xn(e,n){let r,l=ht(e.body,n);if(e.mclass==="minner")r=new T("mpadded",l);else if(e.mclass==="mord")e.isCharacterBox||l[0].type==="mathord"?(r=l[0],r.type="mi",r.children.length===1&&r.children[0].text&&r.children[0].text==="\u2207"&&r.setAttribute("mathvariant","normal")):r=new T("mi",l);else{r=new T("mrow",l),e.mustPromote?(r=l[0],r.type="mo",e.isCharacterBox&&e.body[0].text&&/[A-Za-z]/.test(e.body[0].text)&&r.setAttribute("mathvariant","italic")):r=new T("mrow",l);let u=n.level<2;r.type==="mrow"?u&&(e.mclass==="mbin"?(r.children.unshift(Ct(.2222)),r.children.push(Ct(.2222))):e.mclass==="mrel"?(r.children.unshift(Ct(.2778)),r.children.push(Ct(.2778))):e.mclass==="mpunct"?r.children.push(Ct(.1667)):e.mclass==="minner"&&(r.children.unshift(Ct(.0556)),r.children.push(Ct(.0556)))):e.mclass==="mbin"?(r.attributes.lspace=u?"0.2222em":"0",r.attributes.rspace=u?"0.2222em":"0"):e.mclass==="mrel"?(r.attributes.lspace=u?"0.2778em":"0",r.attributes.rspace=u?"0.2778em":"0"):e.mclass==="mpunct"?(r.attributes.lspace="0em",r.attributes.rspace=u?"0.1667em":"0"):e.mclass==="mopen"||e.mclass==="mclose"?(r.attributes.lspace="0em",r.attributes.rspace="0em"):e.mclass==="minner"&&u&&(r.attributes.lspace="0.0556em",r.attributes.width="+0.1111em"),e.mclass!=="mopen"&&e.mclass!=="mclose"&&(delete r.attributes.stretchy,delete r.attributes.form)}return r}C({type:"mclass",names:["\\mathord","\\mathbin","\\mathrel","\\mathopen","\\mathclose","\\mathpunct","\\mathinner"],props:{numArgs:1,primitive:!0},handler({parser:e,funcName:n},r){let l=r[0],u=w(l),h=!0,y={type:"mathord",text:"",mode:e.mode},x=l.body?l.body:[l];for(let q of x){if(!Tn.includes(q.type)){h=!1;break}Q[e.mode][q.text]?y.text+=Q[e.mode][q.text].replace:q.text?y.text+=q.text:q.body&&q.body.map(Z=>{y.text+=Z.text})}return h&&n==="\\mathord"&&y.type==="mathord"&&y.text.length>1?y:{type:"mclass",mode:e.mode,mclass:"m"+n.slice(5),body:de(h?y:l),isCharacterBox:u,mustPromote:h}},mathmlBuilder:Xn});let hn=e=>{let n=e.type==="ordgroup"&&e.body.length&&e.body.length===1?e.body[0]:e;if(n.type==="atom"){let r=e.body.length>0&&e.body[0].text&&Q.math[e.body[0].text]?Q.math[e.body[0].text].group:n.family;return r==="bin"||r==="rel"?"m"+r:"mord"}return"mord"};C({type:"mclass",names:["\\@binrel"],props:{numArgs:2},handler:({parser:e},n)=>({type:"mclass",mode:e.mode,mclass:hn(n[0]),body:de(n[1]),isCharacterBox:w(n[1])})}),C({type:"mclass",names:["\\stackrel","\\overset","\\underset"],props:{numArgs:2},handler({parser:e,funcName:n},r){let l=r[1],u=r[0],h;h=n!=="\\stackrel"?hn(l):"mrel";let y={type:h==="mrel"||h==="mbin"?"op":"ordgroup",mode:l.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:n!=="\\stackrel",body:de(l)};return{type:"supsub",mode:u.mode,stack:!0,base:y,sup:n==="\\underset"?null:u,sub:n==="\\underset"?u:null}},mathmlBuilder:Xn});let Un=(e,n,r)=>{if(!e)return r;let l=He(e,n);return l.type==="mrow"&&l.children.length===0?r:l};C({type:"multiscript",names:["\\sideset","\\pres@cript"],props:{numArgs:3},handler({parser:e,funcName:n,token:r},l){if(l[2].body.length===0)throw new t(n+"cannot parse an empty base.");let u=l[2].body[0];if(e.settings.strict&&n==="\\sideset"&&!u.symbol)throw new t("The base of \\sideset must be a big operator. Try \\prescript.");if(l[0].body.length>0&&l[0].body[0].type!=="supsub"||l[1].body.length>0&&l[1].body[0].type!=="supsub")throw new t("\\sideset can parse only subscripts and superscripts in its first two arguments",r);let h=l[0].body.length>0?l[0].body[0]:null,y=l[1].body.length>0?l[1].body[0]:null;return h||y?h?{type:"multiscript",mode:e.mode,isSideset:n==="\\sideset",prescripts:h,postscripts:y,base:u}:{type:"styling",mode:e.mode,scriptLevel:"text",body:[{type:"supsub",mode:e.mode,base:u,sup:y.sup,sub:y.sub}]}:u},mathmlBuilder(e,n){let r=He(e.base,n),l=new T("mprescripts"),u=new T("none"),h=[],y=Un(e.prescripts.sub,n,u),x=Un(e.prescripts.sup,n,u);return e.isSideset&&(y.setAttribute("style","text-align: left;"),x.setAttribute("style","text-align: left;")),e.postscripts?h=[r,Un(e.postscripts.sub,n,u),Un(e.postscripts.sup,n,u),l,y,x]:h=[r,l,y,x],new T("mmultiscripts",h)}}),C({type:"not",names:["\\not"],props:{numArgs:1,primitive:!0,allowedInText:!1},handler({parser:e},n){let r=w(n[0]),l;return r?(l=de(n[0]),l[0].text.charAt(0)==="\\"&&(l[0].text=Q.math[l[0].text].replace),l[0].text=l[0].text.slice(0,1)+"\u0338"+l[0].text.slice(1)):l=[{type:"textord",mode:"math",text:"\u0338"},{type:"kern",mode:"math",dimension:{number:-.6,unit:"em"}},n[0]],{type:"not",mode:e.mode,body:l,isCharacterBox:r}},mathmlBuilder(e,n){return e.isCharacterBox?ht(e.body,n,!0)[0]:tt(e.body,n)}});let Rn=["textord","mathord","atom"],kr=["\\smallint"],In=["textord","mathord","ordgroup","close","leftright","font"],Ur=e=>{e.attributes.lspace="0.1667em",e.attributes.rspace="0.1667em"},kn=(e,n)=>{let r;if(e.symbol)r=new T("mo",[nt(e.name,e.mode)]),kr.includes(e.name)?r.setAttribute("largeop","false"):r.setAttribute("movablelimits","false"),e.fromMathOp&&Ur(r);else if(e.body)r=new T("mo",ht(e.body,n)),e.fromMathOp&&Ur(r);else if(r=new T("mi",[new Ke(e.name.slice(1))]),!e.parentIsSupSub){let l=[r,new T("mo",[nt("\u2061","text")])];if(e.needsLeadingSpace){let u=new T("mspace");u.setAttribute("width","0.1667em"),l.unshift(u)}if(!e.isFollowedByDelimiter){let u=new T("mspace");u.setAttribute("width","0.1667em"),l.push(u)}r=new T("mrow",l)}return r},Hr={"\u220F":"\\prod","\u2210":"\\coprod","\u2211":"\\sum","\u22C0":"\\bigwedge","\u22C1":"\\bigvee","\u22C2":"\\bigcap","\u22C3":"\\bigcup","\u2A00":"\\bigodot","\u2A01":"\\bigoplus","\u2A02":"\\bigotimes","\u2A04":"\\biguplus","\u2A05":"\\bigsqcap","\u2A06":"\\bigsqcup","\u2A03":"\\bigcupdot","\u2A07":"\\bigdoublevee","\u2A08":"\\bigdoublewedge","\u2A09":"\\bigtimes"};C({type:"op",names:["\\coprod","\\bigvee","\\bigwedge","\\biguplus","\\bigcupplus","\\bigcupdot","\\bigcap","\\bigcup","\\bigdoublevee","\\bigdoublewedge","\\intop","\\prod","\\sum","\\bigotimes","\\bigoplus","\\bigodot","\\bigsqcap","\\bigsqcup","\\bigtimes","\\smallint","\u220F","\u2210","\u2211","\u22C0","\u22C1","\u22C2","\u22C3","\u2A00","\u2A01","\u2A02","\u2A03","\u2A04","\u2A05","\u2A06","\u2A07","\u2A08","\u2A09"],props:{numArgs:0},handler:({parser:e,funcName:n},r)=>{let l=n;return l.length===1&&(l=Hr[l]),{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:!0,stack:!1,name:l}},mathmlBuilder:kn}),C({type:"op",names:["\\mathop"],props:{numArgs:1,primitive:!0},handler:({parser:e},n)=>{let r=n[0],l=r.body?r.body:[r],u=l.length===1&&Rn.includes(l[0].type);return{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:u,fromMathOp:!0,stack:!1,name:u?l[0].text:null,body:u?null:de(r)}},mathmlBuilder:kn});let Er={"\u222B":"\\int","\u222C":"\\iint","\u222D":"\\iiint","\u222E":"\\oint","\u222F":"\\oiint","\u2230":"\\oiiint","\u2231":"\\intclockwise","\u2232":"\\varointclockwise","\u2A0C":"\\iiiint","\u2A0D":"\\intbar","\u2A0E":"\\intBar","\u2A0F":"\\fint","\u2A12":"\\rppolint","\u2A13":"\\scpolint","\u2A15":"\\pointint","\u2A16":"\\sqint","\u2A17":"\\intlarhk","\u2A18":"\\intx","\u2A19":"\\intcap","\u2A1A":"\\intcup"};C({type:"op",names:["\\arcsin","\\arccos","\\arctan","\\arctg","\\arcctg","\\arg","\\ch","\\cos","\\cosec","\\cosh","\\cot","\\cotg","\\coth","\\csc","\\ctg","\\cth","\\deg","\\dim","\\exp","\\hom","\\ker","\\lg","\\ln","\\log","\\sec","\\sin","\\sinh","\\sh","\\sgn","\\tan","\\tanh","\\tg","\\th"],props:{numArgs:0},handler({parser:e,funcName:n}){let r=e.prevAtomType,l=e.gullet.future().text;return{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!1,stack:!1,isFollowedByDelimiter:Ln(l),needsLeadingSpace:r.length>0&&In.includes(r),name:n}},mathmlBuilder:kn}),C({type:"op",names:["\\det","\\gcd","\\inf","\\lim","\\max","\\min","\\Pr","\\sup"],props:{numArgs:0},handler({parser:e,funcName:n}){let r=e.prevAtomType,l=e.gullet.future().text;return{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:!1,stack:!1,isFollowedByDelimiter:Ln(l),needsLeadingSpace:r.length>0&&In.includes(r),name:n}},mathmlBuilder:kn}),C({type:"op",names:["\\int","\\iint","\\iiint","\\iiiint","\\oint","\\oiint","\\oiiint","\\intclockwise","\\varointclockwise","\\intbar","\\intBar","\\fint","\\rppolint","\\scpolint","\\pointint","\\sqint","\\intlarhk","\\intx","\\intcap","\\intcup","\u222B","\u222C","\u222D","\u222E","\u222F","\u2230","\u2231","\u2232","\u2A0C","\u2A0D","\u2A0E","\u2A0F","\u2A12","\u2A13","\u2A15","\u2A16","\u2A17","\u2A18","\u2A19","\u2A1A"],props:{numArgs:0,allowedInArgument:!0},handler({parser:e,funcName:n}){let r=n;return r.length===1&&(r=Er[r]),{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!0,stack:!1,name:r}},mathmlBuilder:kn}),C({type:"operatorname",names:["\\operatorname@","\\operatornamewithlimits"],props:{numArgs:1,allowedInArgument:!0},handler:({parser:e,funcName:n},r)=>{let l=r[0],u=e.prevAtomType,h=e.gullet.future().text;return{type:"operatorname",mode:e.mode,body:de(l),alwaysHandleSupSub:n==="\\operatornamewithlimits",limits:!1,parentIsSupSub:!1,isFollowedByDelimiter:Ln(h),needsLeadingSpace:u.length>0&&In.includes(u)}},mathmlBuilder:(e,n)=>{let r,l=ht(e.body,n.withFont("mathrm")),u=!0;for(let h=0;h<l.length;h++){let y=l[h];if(y instanceof T)switch(((y.type==="mrow"||y.type==="mpadded")&&y.children.length===1&&y.children[0]instanceof T||y.type==="mrow"&&y.children.length===2&&y.children[0]instanceof T&&y.children[1]instanceof T&&y.children[1].type==="mspace"&&!y.children[1].attributes.width&&y.children[1].children.length===0)&&(y=y.children[0]),y.type){case"mi":case"mn":case"ms":case"mtext":break;case"mspace":if(y.attributes.width){let x=y.attributes.width.replace("em",""),q=mr(Number(x));q===""?u=!1:l[h]=new T("mtext",[new Ke(q)])}break;case"mo":{let x=y.children[0];y.children.length===1&&x instanceof Ke?x.text=x.text.replace(/\u2212/,"-").replace(/\u2217/,"*"):u=!1;break}default:u=!1}else u=!1}if(u){let h=l.map(y=>y.toText()).join("");l=[new Ke(h)]}else if(l.length===1&&["mover","munder"].includes(l[0].type)&&(l[0].children[0].type==="mi"||l[0].children[0].type==="mtext")){if(l[0].children[0].type="mi",e.parentIsSupSub)return new T("mrow",l);{let h=new T("mo",[nt("\u2061","text")]);return bt([l[0],h])}}if(u?(r=new T("mi",l),l[0].text.length===1&&r.setAttribute("mathvariant","normal")):r=new T("mrow",l),!e.parentIsSupSub){let h=[r,new T("mo",[nt("\u2061","text")])];if(e.needsLeadingSpace){let y=new T("mspace");y.setAttribute("width","0.1667em"),h.unshift(y)}if(!e.isFollowedByDelimiter){let y=new T("mspace");y.setAttribute("width","0.1667em"),h.push(y)}return bt(h)}return r}}),L("\\operatorname","\\@ifstar\\operatornamewithlimits\\operatorname@"),I({type:"ordgroup",mathmlBuilder:(e,n)=>tt(e.body,n,e.semisimple)}),C({type:"phantom",names:["\\phantom"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},n)=>{let r=n[0];return{type:"phantom",mode:e.mode,body:de(r)}},mathmlBuilder:(e,n)=>{let r=ht(e.body,n);return new T("mphantom",r)}}),C({type:"hphantom",names:["\\hphantom"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},n)=>{let r=n[0];return{type:"hphantom",mode:e.mode,body:r}},mathmlBuilder:(e,n)=>{let r=ht(de(e.body),n),l=new T("mphantom",r),u=new T("mpadded",[l]);return u.setAttribute("height","0px"),u.setAttribute("depth","0px"),u}}),C({type:"vphantom",names:["\\vphantom"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},n)=>{let r=n[0];return{type:"vphantom",mode:e.mode,body:r}},mathmlBuilder:(e,n)=>{let r=ht(de(e.body),n),l=new T("mphantom",r),u=new T("mpadded",[l]);return u.setAttribute("width","0.1px"),u}}),C({type:"pmb",names:["\\pmb"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},n)=>({type:"pmb",mode:e.mode,body:de(n[0])}),mathmlBuilder(e,n){let r=ht(e.body,n),l=mt(r);return l.setAttribute("style","font-weight:bold"),l}});let Sr=(e,n)=>{let r=n.withLevel(Tt),l=new T("mpadded",[He(e.body,r)]),u=Dt(e.dy,n);return l.setAttribute("voffset",u.number+u.unit),u.number>0?l.style.padding=u.number+u.unit+" 0 0 0":l.style.padding="0 0 "+Math.abs(u.number)+u.unit+" 0",l};C({type:"raise",names:["\\raise","\\lower"],props:{numArgs:2,argTypes:["size","primitive"],primitive:!0},handler({parser:e,funcName:n},r){let l=Le(r[0],"size").value;n==="\\lower"&&(l.number*=-1);let u=r[1];return{type:"raise",mode:e.mode,dy:l,body:u}},mathmlBuilder:Sr}),C({type:"raise",names:["\\raisebox"],props:{numArgs:2,argTypes:["size","hbox"],allowedInText:!0},handler({parser:e,funcName:n},r){let l=Le(r[0],"size").value,u=r[1];return{type:"raise",mode:e.mode,dy:l,body:u}},mathmlBuilder:Sr}),C({type:"ref",names:["\\ref","\\eqref"],props:{numArgs:1,argTypes:["raw"]},handler:({parser:e,funcName:n},r)=>({type:"ref",mode:e.mode,funcName:n,string:r[0].string.replace(tn,"")}),mathmlBuilder(e,n){let r=e.funcName==="\\ref"?["tml-ref"]:["tml-ref","tml-eqref"];return new Ae("#"+e.string,r,null)}}),C({type:"reflect",names:["\\reflectbox"],props:{numArgs:1,argTypes:["hbox"],allowedInText:!0},handler:({parser:e},n)=>({type:"reflect",mode:e.mode,body:n[0]}),mathmlBuilder(e,n){let r=He(e.body,n);return r.style.transform="scaleX(-1)",r}}),C({type:"internal",names:["\\relax"],props:{numArgs:0,allowedInText:!0,allowedInArgument:!0},handler:({parser:e})=>({type:"internal",mode:e.mode})}),C({type:"rule",names:["\\rule"],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["size","size","size"]},handler({parser:e},n,r){let l=r[0],u=Le(n[0],"size"),h=Le(n[1],"size");return{type:"rule",mode:e.mode,shift:l&&Le(l,"size").value,width:u.value,height:h.value}},mathmlBuilder(e,n){let r=Dt(e.width,n),l=Dt(e.height,n),u=e.shift?Dt(e.shift,n):{number:0,unit:"em"},h=n.color&&n.getColor()||"black",y=new T("mspace");if(r.number>0&&l.number>0&&y.setAttribute("mathbackground",h),y.setAttribute("width",r.number+r.unit),y.setAttribute("height",l.number+l.unit),u.number===0)return y;let x=new T("mpadded",[y]);return u.number>=0?x.setAttribute("height","+"+u.number+u.unit):(x.setAttribute("height",u.number+u.unit),x.setAttribute("depth","+"+-u.number+u.unit)),x.setAttribute("voffset",u.number+u.unit),x}});let as=/^[0-9]$/,Hs={0:"\u2080",1:"\u2081",2:"\u2082",3:"\u2083",4:"\u2084",5:"\u2085",6:"\u2086",7:"\u2087",8:"\u2088",9:"\u2089"},ls={0:"\u2070",1:"\xB9",2:"\xB2",3:"\xB3",4:"\u2074",5:"\u2075",6:"\u2076",7:"\u2077",8:"\u2078",9:"\u2079"};C({type:"sfrac",names:["\\sfrac"],props:{numArgs:2,allowedInText:!0,allowedInMath:!0},handler({parser:e},n){let r="";for(let u of n[0].body){if(u.type!=="textord"||!as.test(u.text))throw new t("Numerator must be an integer.",u);r+=u.text}let l="";for(let u of n[1].body){if(u.type!=="textord"||!as.test(u.text))throw new t("Denominator must be an integer.",u);l+=u.text}return{type:"sfrac",mode:e.mode,numerator:r,denominator:l}},mathmlBuilder(e,n){let r=e.numerator.split("").map(h=>ls[h]).join(""),l=e.denominator.split("").map(h=>Hs[h]).join(""),u=new Ke(r+"\u2044"+l,e.mode,n);return new T("mn",[u],["special-fraction"])}});let cs={"\\tiny":.5,"\\sixptsize":.6,"\\Tiny":.6,"\\scriptsize":.7,"\\footnotesize":.8,"\\small":.9,"\\normalsize":1,"\\large":1.2,"\\Large":1.44,"\\LARGE":1.728,"\\huge":2.074,"\\Huge":2.488};C({type:"sizing",names:["\\tiny","\\sixptsize","\\Tiny","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"],props:{numArgs:0,allowedInText:!0},handler:({breakOnTokenText:e,funcName:n,parser:r},l)=>{r.settings.strict&&r.mode==="math"&&console.log(`Temml strict-mode warning: Command ${n} is invalid in math mode.`);let u=r.parseExpression(!1,e,!0);return{type:"sizing",mode:r.mode,funcName:n,body:u}},mathmlBuilder:(e,n)=>{let r=n.withFontSize(cs[e.funcName]),l=ht(e.body,r),u=mt(l),h=(cs[e.funcName]/n.fontSize).toFixed(4);return u.setAttribute("mathsize",h+"em"),u}}),C({type:"smash",names:["\\smash"],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0},handler:({parser:e},n,r)=>{let l=!1,u=!1,h=r[0]&&Le(r[0],"ordgroup");if(h){let x="";for(let q=0;q<h.body.length;++q)if(x=h.body[q].text,x==="t")l=!0;else{if(x!=="b"){l=!1,u=!1;break}u=!0}}else l=!0,u=!0;let y=n[0];return{type:"smash",mode:e.mode,body:y,smashHeight:l,smashDepth:u}},mathmlBuilder:(e,n)=>{let r=new T("mpadded",[He(e.body,n)]);return e.smashHeight&&r.setAttribute("height","0px"),e.smashDepth&&r.setAttribute("depth","0px"),r}});let ds=["a","c","e","\u0131","m","n","o","r","s","u","v","w","x","z","\u03B1","\u03B5","\u03B9","\u03BA","\u03BD","\u03BF","\u03C0","\u03C3","\u03C4","\u03C5","\u03C9","\\alpha","\\epsilon","\\iota","\\kappa","\\nu","\\omega","\\pi","\\tau","\\omega"];C({type:"sqrt",names:["\\sqrt"],props:{numArgs:1,numOptionalArgs:1},handler({parser:e},n,r){let l=r[0],u=n[0];return u.body&&u.body.length===1&&u.body[0].text&&ds.includes(u.body[0].text)&&u.body.push({type:"rule",mode:"math",shift:null,width:{number:0,unit:"pt"},height:{number:.5,unit:"em"}}),{type:"sqrt",mode:e.mode,body:u,index:l}},mathmlBuilder(e,n){let{body:r,index:l}=e;return l?new T("mroot",[He(r,n),He(l,n.incrementLevel())]):new T("msqrt",[He(r,n)])}});let js={display:0,text:1,script:2,scriptscript:3},jr={display:["0","true"],text:["0","false"],script:["1","false"],scriptscript:["2","false"]};C({type:"styling",names:["\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({breakOnTokenText:e,funcName:n,parser:r},l){let u=r.parseExpression(!0,e,!0),h=n.slice(1,n.length-5);return{type:"styling",mode:r.mode,scriptLevel:h,body:u}},mathmlBuilder(e,n){let r=n.withLevel(js[e.scriptLevel]),l=ht(e.body,r),u=mt(l),h=jr[e.scriptLevel];return u.setAttribute("scriptlevel",h[0]),u.setAttribute("displaystyle",h[1]),u}});let Gs=/^m(over|under|underover)$/;I({type:"supsub",mathmlBuilder(e,n){let r,l,u=!1,h=!1,y=!1,x=!1;e.base&&e.base.type==="horizBracket"&&(l=!!e.sup,l===e.base.isOver&&(u=!0,r=e.base.isOver)),!e.base||e.stack||e.base.type!=="op"&&e.base.type!=="operatorname"||(e.base.parentIsSupSub=!0,h=!e.base.symbol,y=h&&!e.isFollowedByDelimiter,x=e.base.needsLeadingSpace);let q=e.stack&&e.base.body.length===1?[He(e.base.body[0],n)]:[He(e.base,n)],Z=n.inSubOrSup();if(e.sub){let le=He(e.sub,Z);n.level===3&&le.setAttribute("scriptlevel","2"),q.push(le)}if(e.sup){let le=He(e.sup,Z);if(n.level===3&&le.setAttribute("scriptlevel","2"),e.base&&e.base.text&&e.base.text.length===1){let xt=e.base.text;"DHKLUcegorsuvxyz\u03A0\u03A5\u03A8\u03B1\u03B4\u03B7\u03B9\u03BC\u03BD\u03BF\u03C4\u03C5\u03C7\u03F5".indexOf(xt)>-1?le.classes.push("tml-sml-pad"):"BCEFGIMNOPQRSTXZlpqtw\u0393\u0398\u039E\u03A3\u03A6\u03A9\u03B2\u03B5\u03B6\u03B8\u03BE\u03C1\u03C2\u03C6\u03C8\u03D1\u03D5\u03F1".indexOf(xt)>-1?le.classes.push("tml-med-pad"):"AJdf\u0394\u039B".indexOf(xt)>-1&&le.classes.push("tml-lrg-pad")}q.push(le)}let ve;if(u)ve=r?"mover":"munder";else if(e.sub)if(e.sup){let le=e.base;ve=le&&(le.type==="op"&&le.limits||le.type==="multiscript")&&(n.level===Et||le.alwaysHandleSupSub)||le&&le.type==="operatorname"&&le.alwaysHandleSupSub&&(n.level===Et||le.limits)?"munderover":"msubsup"}else{let le=e.base;ve=e.stack||le&&le.type==="op"&&le.limits&&(n.level===Et||le.alwaysHandleSupSub)||le&&le.type==="operatorname"&&le.alwaysHandleSupSub&&(le.limits||n.level===Et)?"munder":"msub"}else{let le=e.base;ve=le&&le.type==="op"&&le.limits&&(n.level===Et||le.alwaysHandleSupSub)||le&&le.type==="operatorname"&&le.alwaysHandleSupSub&&(le.limits||n.level===Et)?"mover":"msup"}let Te=new T(ve,q);if(h){let le=new T("mo",[nt("\u2061","text")]);if(x){let xt=new T("mspace");xt.setAttribute("width","0.1667em"),Te=bt([xt,Te,le])}else Te=bt([Te,le]);if(y){let xt=new T("mspace");xt.setAttribute("width","0.1667em"),Te.children.push(xt)}}else Gs.test(ve)&&(Te=new T("mrow",[Te]));return Te}});let Jn=["\\shortmid","\\nshortmid","\\shortparallel","\\nshortparallel","\\smallsetminus"],us=["\\Rsh","\\Lsh","\\restriction"];I({type:"atom",mathmlBuilder(e,n){let r=new T("mo",[nt(e.text,e.mode)]);if(e.family==="punct")r.setAttribute("separator","true");else if(e.family==="open"||e.family==="close")e.family==="open"?(r.setAttribute("form","prefix"),r.setAttribute("stretchy","false")):e.family==="close"&&(r.setAttribute("form","postfix"),r.setAttribute("stretchy","false"));else if(e.text==="\\mid")r.setAttribute("lspace","0.22em"),r.setAttribute("rspace","0.22em"),r.setAttribute("stretchy","false");else if(e.family==="rel"&&(l=>{if(l.length===1){let u=l.codePointAt(0);return 8591<u&&u<8704}return l.indexOf("arrow")>-1||l.indexOf("harpoon")>-1||us.includes(l)})(e.text))r.setAttribute("stretchy","false");else if(Jn.includes(e.text))r.setAttribute("mathsize","70%");else if(e.text===":")r.attributes.lspace="0.2222em",r.attributes.rspace="0.2222em";else if(e.needsSpacing)return e.family==="bin"?new T("mrow",[Ct(.222),r,Ct(.222)]):new T("mrow",[Ct(.2778),r,Ct(.2778)]);return r}});let Gr={mathbf:"bold",mathrm:"normal",textit:"italic",mathit:"italic",mathnormal:"italic",mathbb:"double-struck",mathcal:"script",mathfrak:"fraktur",mathscr:"script",mathsf:"sans-serif",mathtt:"monospace"},Qn=function(e,n){if(n.fontFamily==="texttt")return"monospace";if(n.fontFamily==="textsc")return"normal";if(n.fontFamily==="textsf")return n.fontShape==="textit"&&n.fontWeight==="textbf"?"sans-serif-bold-italic":n.fontShape==="textit"?"sans-serif-italic":n.fontWeight==="textbf"?"sans-serif-bold":"sans-serif";if(n.fontShape==="textit"&&n.fontWeight==="textbf")return"bold-italic";if(n.fontShape==="textit")return"italic";if(n.fontWeight==="textbf")return"bold";let r=n.font;if(!r||r==="mathnormal")return null;let l=e.mode;switch(r){case"mathit":case"greekItalic":return"italic";case"mathrm":{let h=e.text.codePointAt(0);return 939<h&&h<975?"italic":"normal"}case"up@greek":return"normal";case"boldsymbol":case"mathboldsymbol":return"bold-italic";case"mathbf":return"bold";case"mathbb":return"double-struck";case"mathfrak":return"fraktur";case"mathscr":case"mathcal":return"script";case"mathsf":return"sans-serif";case"mathsfit":return"sans-serif-italic";case"mathtt":return"monospace"}let u=e.text;return Q[l][u]&&Q[l][u].replace&&(u=Q[l][u].replace),Object.prototype.hasOwnProperty.call(Gr,r)?Gr[r]:null},b=/^\d(?:[\d,.]*\d)?$/,A=/[A-Ba-z]/,R=new Set(["\\prime","\\dprime","\\trprime","\\qprime","\\backprime","\\backdprime","\\backtrprime"]);I({type:"mathord",mathmlBuilder(e,n){let r=nt(e.text,e.mode,n),l=r.text.codePointAt(0),u=912<l&&l<938?"normal":"italic",h=Qn(e,n)||u;if(h==="script")return r.text=zn(r.text,h),new T("mi",[r],[n.font]);h!=="italic"&&(r.text=zn(r.text,h));let y=new T("mi",[r]);if(h==="normal"&&(y.setAttribute("mathvariant","normal"),r.text.length===1)){let x=new T("mspace",[]);y=new T("mrow",[y,x])}return y}}),I({type:"textord",mathmlBuilder(e,n){let r=e.text,l=r.codePointAt(0);n.fontFamily==="textsc"&&96<l&&l<123&&(r=os[r]);let u=nt(r,e.mode,n),h=Qn(e,n)||"normal",y;if(b.test(e.text)){let x=e.mode==="text"?"mtext":"mn";if(h==="italic"||h==="bold-italic")return((q,Z,ve)=>{let Te=new T(ve,[q]),le=new T("mstyle",[Te]);return le.style["font-style"]="italic",le.style["font-family"]="Cambria, 'Times New Roman', serif",Z==="bold-italic"&&(le.style["font-weight"]="bold"),le})(u,h,x);h!=="normal"&&(u.text=u.text.split("").map(q=>zn(q,h)).join("")),y=new T(x,[u])}else if(e.mode==="text")h!=="normal"&&(u.text=zn(u.text,h)),y=new T("mtext",[u]);else if(R.has(e.text))y=new T("mo",[u]),y.classes.push("tml-prime");else{let x=u.text;h!=="italic"&&(u.text=zn(u.text,h)),y=new T("mi",[u]),u.text===x&&A.test(x)&&y.setAttribute("mathvariant","italic")}return y}});let U={"\\nobreak":"nobreak","\\allowbreak":"allowbreak"},V={" ":{},"\\ ":{},"~":{className:"nobreak"},"\\space":{},"\\nobreakspace":{className:"nobreak"}};I({type:"spacing",mathmlBuilder(e,n){let r;if(Object.prototype.hasOwnProperty.call(V,e.text))r=new T("mtext",[new Ke("\xA0")]);else{if(!Object.prototype.hasOwnProperty.call(U,e.text))throw new t(`Unknown type of space "${e.text}"`);r=new T("mo"),e.text==="\\nobreak"&&r.setAttribute("linebreak","nobreak")}return r}}),I({type:"tag"});let he={"\\text":void 0,"\\textrm":"textrm","\\textsf":"textsf","\\texttt":"texttt","\\textnormal":"textrm","\\textsc":"textsc"},D={"\\textbf":"textbf","\\textmd":"textmd"},se={"\\textit":"textit","\\textup":"textup"};C({type:"text",names:["\\text","\\textrm","\\textsf","\\texttt","\\textnormal","\\textsc","\\textbf","\\textmd","\\textit","\\textup","\\emph"],props:{numArgs:1,argTypes:["text"],allowedInArgument:!0,allowedInText:!0},handler({parser:e,funcName:n},r){let l=r[0];return{type:"text",mode:e.mode,body:de(l),font:n}},mathmlBuilder(e,n){let r=((u,h)=>{let y=u.font;return y?he[y]?h.withTextFontFamily(he[y]):D[y]?h.withTextFontWeight(D[y]):y==="\\emph"?h.fontShape==="textit"?h.withTextFontShape("textup"):h.withTextFontShape("textit"):h.withTextFontShape(se[y]):h})(e,n),l=tt(e.body,r);return ut(l)}}),C({type:"vcenter",names:["\\vcenter"],props:{numArgs:1,argTypes:["original"],allowedInText:!1},handler:({parser:e},n)=>({type:"vcenter",mode:e.mode,body:n[0]}),mathmlBuilder(e,n){let r=new T("mtd",[He(e.body,n)]);r.style.padding="0";let l=new T("mtr",[r]);return new T("mtable",[l])}}),C({type:"verb",names:["\\verb"],props:{numArgs:0,allowedInText:!0},handler(e,n,r){throw new t("\\verb ended by end of line instead of matching delimiter")},mathmlBuilder(e,n){let r=new Ke(Xe(e)),l=new T("mtext",[r]);return l.setAttribute("mathvariant","monospace"),l}});let Xe=e=>e.body.replace(/ /g,e.star?"\u2423":"\xA0"),Je=$,Be=`[ \r
93
+ ]`,at=`(\\\\[a-zA-Z@]+)${Be}*`,Mt="[\u0300-\u036F]",Ot=new RegExp(`${Mt}+$`),Jt=`(${Be}+)|\\\\(
94
94
  |[ \r ]+
95
- ?)[ \r ]*|([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]${qr}*|[\uD800-\uDBFF][\uDC00-\uDFFF]${qr}*|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5|${La}|\\\\[^\uD800-\uDFFF])`;class Bs{constructor(t,n){this.input=t,this.settings=n,this.tokenRegex=new RegExp(Ra,"g"),this.catcodes={"%":14,"~":13}}setCatcode(t,n){this.catcodes[t]=n}lex(){let t=this.input,n=this.tokenRegex.lastIndex;if(n===t.length)return new qt("EOF",new yt(this,n,n));let a=this.tokenRegex.exec(t);if(a===null||a.index!==n)throw new r(`Unexpected character: '${t[n]}'`,new qt(t[n],new yt(this,n,n+1)));let c=a[6]||a[3]||(a[2]?"\\ ":" ");if(this.catcodes[c]===14){let p=t.indexOf(`
96
- `,this.tokenRegex.lastIndex);if(p===-1){if(this.tokenRegex.lastIndex=t.length,this.settings.strict)throw new r("% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode")}else this.tokenRegex.lastIndex=p+1;return this.lex()}return new qt(c,new yt(this,n,this.tokenRegex.lastIndex))}}class Ia{constructor(t={},n={}){this.current=n,this.builtins=t,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(this.undefStack.length===0)throw new r("Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug");let t=this.undefStack.pop();for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(t[n]===void 0?delete this.current[n]:this.current[n]=t[n])}has(t){return Object.prototype.hasOwnProperty.call(this.current,t)||Object.prototype.hasOwnProperty.call(this.builtins,t)}get(t){return Object.prototype.hasOwnProperty.call(this.current,t)?this.current[t]:this.builtins[t]}set(t,n,a=!1){if(a){for(let c=0;c<this.undefStack.length;c++)delete this.undefStack[c][t];this.undefStack.length>0&&(this.undefStack[this.undefStack.length-1][t]=n)}else{let c=this.undefStack[this.undefStack.length-1];c&&!Object.prototype.hasOwnProperty.call(c,t)&&(c[t]=this.current[t])}this.current[t]=n}}let Ps={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0};class Ba{constructor(t,n,a){this.settings=n,this.expansionCount=0,this.feed(t),this.macros=new Ia(Tn,n.macros),this.mode=a,this.stack=[]}feed(t){this.lexer=new Bs(t,this.settings)}switchMode(t){this.mode=t}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}future(){return this.stack.length===0&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(t){this.stack.push(t)}pushTokens(t){this.stack.push(...t)}scanArgument(t){let n,a,c;if(t){if(this.consumeSpaces(),this.future().text!=="[")return null;n=this.popToken(),{tokens:c,end:a}=this.consumeArg(["]"])}else({tokens:c,start:n,end:a}=this.consumeArg());return this.pushToken(new qt("EOF",a.loc)),this.pushTokens(c),new qt("",yt.range(n,a))}consumeSpaces(){for(;this.future().text===" ";)this.stack.pop()}consumeArg(t){let n=[],a=t&&t.length>0;a||this.consumeSpaces();let c=this.future(),p,g=0,x=0;do{if(p=this.popToken(),n.push(p),p.text==="{")++g;else if(p.text==="}"){if(--g,g===-1)throw new r("Extra }",p)}else if(p.text==="EOF")throw new r("Unexpected end of input in a macro argument, expected '"+(t&&a?t[x]:"}")+"'",p);if(t&&a)if((g===0||g===1&&t[x]==="{")&&p.text===t[x]){if(++x,x===t.length){n.splice(-x,x);break}}else x=0}while(g!==0||a);return c.text==="{"&&n[n.length-1].text==="}"&&(n.pop(),n.shift()),n.reverse(),{tokens:n,start:c,end:p}}consumeArgs(t,n){if(n){if(n.length!==t+1)throw new r("The length of delimiters doesn't match the number of args!");let c=n[0];for(let p=0;p<c.length;p++){let g=this.popToken();if(c[p]!==g.text)throw new r("Use of the macro doesn't match its definition",g)}}let a=[];for(let c=0;c<t;c++)a.push(this.consumeArg(n&&n[c+1]).tokens);return a}expandOnce(t){let n=this.popToken(),a=n.text,c=n.noexpand?null:this._getExpansion(a);if(c==null||t&&c.unexpandable){if(t&&c==null&&a[0]==="\\"&&!this.isDefined(a))throw new r("Undefined control sequence: "+a);return this.pushToken(n),!1}if(this.expansionCount++,this.expansionCount>this.settings.maxExpand)throw new r("Too many expansions: infinite loop or need to increase maxExpand setting");let p=c.tokens,g=this.consumeArgs(c.numArgs,c.delimiters);if(c.numArgs){p=p.slice();for(let x=p.length-1;x>=0;--x){let q=p[x];if(q.text==="#"){if(x===0)throw new r("Incomplete placeholder at end of macro body",q);if(q=p[--x],q.text==="#")p.splice(x+1,1);else{if(!/^[1-9]$/.test(q.text))throw new r("Not a valid argument number",q);p.splice(x,2,...g[+q.text-1])}}}}return this.pushTokens(p),p.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(this.expandOnce()===!1){let t=this.stack.pop();return t.treatAsRelax&&(t.text="\\relax"),t}throw new Error}expandMacro(t){return this.macros.has(t)?this.expandTokens([new qt(t)]):void 0}expandTokens(t){let n=[],a=this.stack.length;for(this.pushTokens(t);this.stack.length>a;)if(this.expandOnce(!0)===!1){let c=this.stack.pop();c.treatAsRelax&&(c.noexpand=!1,c.treatAsRelax=!1),n.push(c)}return n}expandMacroAsText(t){let n=this.expandMacro(t);return n&&n.map(a=>a.text).join("")}_getExpansion(t){let n=this.macros.get(t);if(n==null)return n;if(t.length===1){let c=this.lexer.catcodes[t];if(c!=null&&c!==13)return}let a=typeof n=="function"?n(this):n;if(typeof a=="string"){let c=0;if(a.indexOf("#")!==-1){let q=a.replace(/##/g,"");for(;q.indexOf("#"+(c+1))!==-1;)++c}let p=new Bs(a,this.settings),g=[],x=p.lex();for(;x.text!=="EOF";)g.push(x),x=p.lex();return g.reverse(),{tokens:g,numArgs:c}}return a}isDefined(t){return this.macros.has(t)||Object.prototype.hasOwnProperty.call(Mn,t)||Object.prototype.hasOwnProperty.call(Ce.math,t)||Object.prototype.hasOwnProperty.call(Ce.text,t)||Object.prototype.hasOwnProperty.call(Ps,t)}isExpandable(t){let n=this.macros.get(t);return n!=null?typeof n=="string"||typeof n=="function"||!n.unexpandable:Object.prototype.hasOwnProperty.call(Mn,t)&&!Mn[t].primitive}}let Ds=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,dr=Object.freeze({"\u208A":"+","\u208B":"-","\u208C":"=","\u208D":"(","\u208E":")","\u2080":"0","\u2081":"1","\u2082":"2","\u2083":"3","\u2084":"4","\u2085":"5","\u2086":"6","\u2087":"7","\u2088":"8","\u2089":"9","\u2090":"a","\u2091":"e","\u2095":"h","\u1D62":"i","\u2C7C":"j","\u2096":"k","\u2097":"l","\u2098":"m","\u2099":"n","\u2092":"o","\u209A":"p","\u1D63":"r","\u209B":"s","\u209C":"t","\u1D64":"u","\u1D65":"v","\u2093":"x","\u1D66":"\u03B2","\u1D67":"\u03B3","\u1D68":"\u03C1","\u1D69":"\u03D5","\u1D6A":"\u03C7","\u207A":"+","\u207B":"-","\u207C":"=","\u207D":"(","\u207E":")","\u2070":"0","\xB9":"1","\xB2":"2","\xB3":"3","\u2074":"4","\u2075":"5","\u2076":"6","\u2077":"7","\u2078":"8","\u2079":"9","\u1D2C":"A","\u1D2E":"B","\u1D30":"D","\u1D31":"E","\u1D33":"G","\u1D34":"H","\u1D35":"I","\u1D36":"J","\u1D37":"K","\u1D38":"L","\u1D39":"M","\u1D3A":"N","\u1D3C":"O","\u1D3E":"P","\u1D3F":"R","\u1D40":"T","\u1D41":"U","\u2C7D":"V","\u1D42":"W","\u1D43":"a","\u1D47":"b","\u1D9C":"c","\u1D48":"d","\u1D49":"e","\u1DA0":"f","\u1D4D":"g",\u02B0:"h","\u2071":"i",\u02B2:"j","\u1D4F":"k",\u02E1:"l","\u1D50":"m",\u207F:"n","\u1D52":"o","\u1D56":"p",\u02B3:"r",\u02E2:"s","\u1D57":"t","\u1D58":"u","\u1D5B":"v",\u02B7:"w",\u02E3:"x",\u02B8:"y","\u1DBB":"z","\u1D5D":"\u03B2","\u1D5E":"\u03B3","\u1D5F":"\u03B4","\u1D60":"\u03D5","\u1D61":"\u03C7","\u1DBF":"\u03B8"}),qs=Object.freeze({"\u{1D49C}":"A",\u212C:"B","\u{1D49E}":"C","\u{1D49F}":"D",\u2130:"E",\u2131:"F","\u{1D4A2}":"G",\u210B:"H",\u2110:"I","\u{1D4A5}":"J","\u{1D4A6}":"K",\u2112:"L",\u2133:"M","\u{1D4A9}":"N","\u{1D4AA}":"O","\u{1D4AB}":"P","\u{1D4AC}":"Q",\u211B:"R","\u{1D4AE}":"S","\u{1D4AF}":"T","\u{1D4B0}":"U","\u{1D4B1}":"V","\u{1D4B2}":"W","\u{1D4B3}":"X","\u{1D4B4}":"Y","\u{1D4B5}":"Z"});var Fr={"\u0301":{text:"\\'",math:"\\acute"},"\u0300":{text:"\\`",math:"\\grave"},"\u0308":{text:'\\"',math:"\\ddot"},"\u0303":{text:"\\~",math:"\\tilde"},"\u0304":{text:"\\=",math:"\\bar"},"\u0306":{text:"\\u",math:"\\breve"},"\u030C":{text:"\\v",math:"\\check"},"\u0302":{text:"\\^",math:"\\hat"},"\u0307":{text:"\\.",math:"\\dot"},"\u030A":{text:"\\r",math:"\\mathring"},"\u030B":{text:"\\H"},"\u0327":{text:"\\c"}},Fs={\u00E1:"a\u0301",\u00E0:"a\u0300",\u00E4:"a\u0308",\u01DF:"a\u0308\u0304",\u00E3:"a\u0303",\u0101:"a\u0304",\u0103:"a\u0306",\u1EAF:"a\u0306\u0301",\u1EB1:"a\u0306\u0300",\u1EB5:"a\u0306\u0303",\u01CE:"a\u030C",\u00E2:"a\u0302",\u1EA5:"a\u0302\u0301",\u1EA7:"a\u0302\u0300",\u1EAB:"a\u0302\u0303",\u0227:"a\u0307",\u01E1:"a\u0307\u0304",\u00E5:"a\u030A",\u01FB:"a\u030A\u0301",\u1E03:"b\u0307",\u0107:"c\u0301",\u010D:"c\u030C",\u0109:"c\u0302",\u010B:"c\u0307",\u010F:"d\u030C",\u1E0B:"d\u0307",\u00E9:"e\u0301",\u00E8:"e\u0300",\u00EB:"e\u0308",\u1EBD:"e\u0303",\u0113:"e\u0304",\u1E17:"e\u0304\u0301",\u1E15:"e\u0304\u0300",\u0115:"e\u0306",\u011B:"e\u030C",\u00EA:"e\u0302",\u1EBF:"e\u0302\u0301",\u1EC1:"e\u0302\u0300",\u1EC5:"e\u0302\u0303",\u0117:"e\u0307",\u1E1F:"f\u0307",\u01F5:"g\u0301",\u1E21:"g\u0304",\u011F:"g\u0306",\u01E7:"g\u030C",\u011D:"g\u0302",\u0121:"g\u0307",\u1E27:"h\u0308",\u021F:"h\u030C",\u0125:"h\u0302",\u1E23:"h\u0307",\u00ED:"i\u0301",\u00EC:"i\u0300",\u00EF:"i\u0308",\u1E2F:"i\u0308\u0301",\u0129:"i\u0303",\u012B:"i\u0304",\u012D:"i\u0306",\u01D0:"i\u030C",\u00EE:"i\u0302",\u01F0:"j\u030C",\u0135:"j\u0302",\u1E31:"k\u0301",\u01E9:"k\u030C",\u013A:"l\u0301",\u013E:"l\u030C",\u1E3F:"m\u0301",\u1E41:"m\u0307",\u0144:"n\u0301",\u01F9:"n\u0300",\u00F1:"n\u0303",\u0148:"n\u030C",\u1E45:"n\u0307",\u00F3:"o\u0301",\u00F2:"o\u0300",\u00F6:"o\u0308",\u022B:"o\u0308\u0304",\u00F5:"o\u0303",\u1E4D:"o\u0303\u0301",\u1E4F:"o\u0303\u0308",\u022D:"o\u0303\u0304",\u014D:"o\u0304",\u1E53:"o\u0304\u0301",\u1E51:"o\u0304\u0300",\u014F:"o\u0306",\u01D2:"o\u030C",\u00F4:"o\u0302",\u1ED1:"o\u0302\u0301",\u1ED3:"o\u0302\u0300",\u1ED7:"o\u0302\u0303",\u022F:"o\u0307",\u0231:"o\u0307\u0304",\u0151:"o\u030B",\u1E55:"p\u0301",\u1E57:"p\u0307",\u0155:"r\u0301",\u0159:"r\u030C",\u1E59:"r\u0307",\u015B:"s\u0301",\u1E65:"s\u0301\u0307",\u0161:"s\u030C",\u1E67:"s\u030C\u0307",\u015D:"s\u0302",\u1E61:"s\u0307",\u1E97:"t\u0308",\u0165:"t\u030C",\u1E6B:"t\u0307",\u00FA:"u\u0301",\u00F9:"u\u0300",\u00FC:"u\u0308",\u01D8:"u\u0308\u0301",\u01DC:"u\u0308\u0300",\u01D6:"u\u0308\u0304",\u01DA:"u\u0308\u030C",\u0169:"u\u0303",\u1E79:"u\u0303\u0301",\u016B:"u\u0304",\u1E7B:"u\u0304\u0308",\u016D:"u\u0306",\u01D4:"u\u030C",\u00FB:"u\u0302",\u016F:"u\u030A",\u0171:"u\u030B",\u1E7D:"v\u0303",\u1E83:"w\u0301",\u1E81:"w\u0300",\u1E85:"w\u0308",\u0175:"w\u0302",\u1E87:"w\u0307",\u1E98:"w\u030A",\u1E8D:"x\u0308",\u1E8B:"x\u0307",\u00FD:"y\u0301",\u1EF3:"y\u0300",\u00FF:"y\u0308",\u1EF9:"y\u0303",\u0233:"y\u0304",\u0177:"y\u0302",\u1E8F:"y\u0307",\u1E99:"y\u030A",\u017A:"z\u0301",\u017E:"z\u030C",\u1E91:"z\u0302",\u017C:"z\u0307",\u00C1:"A\u0301",\u00C0:"A\u0300",\u00C4:"A\u0308",\u01DE:"A\u0308\u0304",\u00C3:"A\u0303",\u0100:"A\u0304",\u0102:"A\u0306",\u1EAE:"A\u0306\u0301",\u1EB0:"A\u0306\u0300",\u1EB4:"A\u0306\u0303",\u01CD:"A\u030C",\u00C2:"A\u0302",\u1EA4:"A\u0302\u0301",\u1EA6:"A\u0302\u0300",\u1EAA:"A\u0302\u0303",\u0226:"A\u0307",\u01E0:"A\u0307\u0304",\u00C5:"A\u030A",\u01FA:"A\u030A\u0301",\u1E02:"B\u0307",\u0106:"C\u0301",\u010C:"C\u030C",\u0108:"C\u0302",\u010A:"C\u0307",\u010E:"D\u030C",\u1E0A:"D\u0307",\u00C9:"E\u0301",\u00C8:"E\u0300",\u00CB:"E\u0308",\u1EBC:"E\u0303",\u0112:"E\u0304",\u1E16:"E\u0304\u0301",\u1E14:"E\u0304\u0300",\u0114:"E\u0306",\u011A:"E\u030C",\u00CA:"E\u0302",\u1EBE:"E\u0302\u0301",\u1EC0:"E\u0302\u0300",\u1EC4:"E\u0302\u0303",\u0116:"E\u0307",\u1E1E:"F\u0307",\u01F4:"G\u0301",\u1E20:"G\u0304",\u011E:"G\u0306",\u01E6:"G\u030C",\u011C:"G\u0302",\u0120:"G\u0307",\u1E26:"H\u0308",\u021E:"H\u030C",\u0124:"H\u0302",\u1E22:"H\u0307",\u00CD:"I\u0301",\u00CC:"I\u0300",\u00CF:"I\u0308",\u1E2E:"I\u0308\u0301",\u0128:"I\u0303",\u012A:"I\u0304",\u012C:"I\u0306",\u01CF:"I\u030C",\u00CE:"I\u0302",\u0130:"I\u0307",\u0134:"J\u0302",\u1E30:"K\u0301",\u01E8:"K\u030C",\u0139:"L\u0301",\u013D:"L\u030C",\u1E3E:"M\u0301",\u1E40:"M\u0307",\u0143:"N\u0301",\u01F8:"N\u0300",\u00D1:"N\u0303",\u0147:"N\u030C",\u1E44:"N\u0307",\u00D3:"O\u0301",\u00D2:"O\u0300",\u00D6:"O\u0308",\u022A:"O\u0308\u0304",\u00D5:"O\u0303",\u1E4C:"O\u0303\u0301",\u1E4E:"O\u0303\u0308",\u022C:"O\u0303\u0304",\u014C:"O\u0304",\u1E52:"O\u0304\u0301",\u1E50:"O\u0304\u0300",\u014E:"O\u0306",\u01D1:"O\u030C",\u00D4:"O\u0302",\u1ED0:"O\u0302\u0301",\u1ED2:"O\u0302\u0300",\u1ED6:"O\u0302\u0303",\u022E:"O\u0307",\u0230:"O\u0307\u0304",\u0150:"O\u030B",\u1E54:"P\u0301",\u1E56:"P\u0307",\u0154:"R\u0301",\u0158:"R\u030C",\u1E58:"R\u0307",\u015A:"S\u0301",\u1E64:"S\u0301\u0307",\u0160:"S\u030C",\u1E66:"S\u030C\u0307",\u015C:"S\u0302",\u1E60:"S\u0307",\u0164:"T\u030C",\u1E6A:"T\u0307",\u00DA:"U\u0301",\u00D9:"U\u0300",\u00DC:"U\u0308",\u01D7:"U\u0308\u0301",\u01DB:"U\u0308\u0300",\u01D5:"U\u0308\u0304",\u01D9:"U\u0308\u030C",\u0168:"U\u0303",\u1E78:"U\u0303\u0301",\u016A:"U\u0304",\u1E7A:"U\u0304\u0308",\u016C:"U\u0306",\u01D3:"U\u030C",\u00DB:"U\u0302",\u016E:"U\u030A",\u0170:"U\u030B",\u1E7C:"V\u0303",\u1E82:"W\u0301",\u1E80:"W\u0300",\u1E84:"W\u0308",\u0174:"W\u0302",\u1E86:"W\u0307",\u1E8C:"X\u0308",\u1E8A:"X\u0307",\u00DD:"Y\u0301",\u1EF2:"Y\u0300",\u0178:"Y\u0308",\u1EF8:"Y\u0303",\u0232:"Y\u0304",\u0176:"Y\u0302",\u1E8E:"Y\u0307",\u0179:"Z\u0301",\u017D:"Z\u030C",\u1E90:"Z\u0302",\u017B:"Z\u0307",\u03AC:"\u03B1\u0301",\u1F70:"\u03B1\u0300",\u1FB1:"\u03B1\u0304",\u1FB0:"\u03B1\u0306",\u03AD:"\u03B5\u0301",\u1F72:"\u03B5\u0300",\u03AE:"\u03B7\u0301",\u1F74:"\u03B7\u0300",\u03AF:"\u03B9\u0301",\u1F76:"\u03B9\u0300",\u03CA:"\u03B9\u0308",\u0390:"\u03B9\u0308\u0301",\u1FD2:"\u03B9\u0308\u0300",\u1FD1:"\u03B9\u0304",\u1FD0:"\u03B9\u0306",\u03CC:"\u03BF\u0301",\u1F78:"\u03BF\u0300",\u03CD:"\u03C5\u0301",\u1F7A:"\u03C5\u0300",\u03CB:"\u03C5\u0308",\u03B0:"\u03C5\u0308\u0301",\u1FE2:"\u03C5\u0308\u0300",\u1FE1:"\u03C5\u0304",\u1FE0:"\u03C5\u0306",\u03CE:"\u03C9\u0301",\u1F7C:"\u03C9\u0300",\u038E:"\u03A5\u0301",\u1FEA:"\u03A5\u0300",\u03AB:"\u03A5\u0308",\u1FE9:"\u03A5\u0304",\u1FE8:"\u03A5\u0306",\u038F:"\u03A9\u0301",\u1FFA:"\u03A9\u0300"};let Pa=["bin","op","open","punct","rel"],Da=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/,qa=/^ *\\text/;class Qn{constructor(t,n,a=!1){this.mode="math",this.gullet=new Ba(t,n,this.mode),this.settings=n,this.isPreamble=a,this.leftrightDepth=0,this.prevAtomType=""}expect(t,n=!0){if(this.fetch().text!==t)throw new r(`Expected '${t}', got '${this.fetch().text}'`,this.fetch());n&&this.consume()}consume(){this.nextToken=null}fetch(){return this.nextToken==null&&(this.nextToken=this.gullet.expandNextToken()),this.nextToken}switchMode(t){this.mode=t,this.gullet.switchMode(t)}parse(){this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set("\\color","\\textcolor");let t=this.parseExpression(!1);if(this.expect("EOF"),this.isPreamble){let a=Object.create(null);return Object.entries(this.gullet.macros.current).forEach(([c,p])=>{a[c]=p}),this.gullet.endGroup(),a}let n=this.gullet.macros.get("\\df@tag");return this.gullet.endGroup(),n&&(this.gullet.macros.current["\\df@tag"]=n),t}static get endOfExpression(){return["}","\\endgroup","\\end","\\right","\\endtoggle","&"]}subparse(t){let n=this.nextToken;this.consume(),this.gullet.pushToken(new qt("}")),this.gullet.pushTokens(t);let a=this.parseExpression(!1);return this.expect("}"),this.nextToken=n,a}parseExpression(t,n,a){let c=[];for(this.prevAtomType="";;){this.mode==="math"&&this.consumeSpaces();let p=this.fetch();if(Qn.endOfExpression.indexOf(p.text)!==-1||n&&p.text===n||a&&p.text==="\\middle"||t&&Mn[p.text]&&Mn[p.text].infix)break;let g=this.parseAtom(n);if(!g)break;g.type!=="internal"&&(c.push(g),this.prevAtomType=g.type==="atom"?g.family:g.type)}return this.mode==="text"&&this.formLigatures(c),this.handleInfixNodes(c)}handleInfixNodes(t){let n,a=-1;for(let c=0;c<t.length;c++)if(t[c].type==="infix"){if(a!==-1)throw new r("only one infix operator per group",t[c].token);a=c,n=t[c].replaceWith}if(a!==-1&&n){let c,p,g=t.slice(0,a),x=t.slice(a+1),q;return c=g.length===1&&g[0].type==="ordgroup"?g[0]:{type:"ordgroup",mode:this.mode,body:g},p=x.length===1&&x[0].type==="ordgroup"?x[0]:{type:"ordgroup",mode:this.mode,body:x},q=n==="\\\\abovefrac"?this.callFunction(n,[c,t[a],p],[]):this.callFunction(n,[c,p],[]),[q]}return t}handleSupSubscript(t){let n=this.fetch(),a=n.text,c;this.consume(),this.consumeSpaces();do c=this.parseGroup(t);while(c.type&&c.type==="internal");if(!c)throw new r("Expected group after '"+a+"'",n);return c}formatUnsupportedCmd(t){let n=[];for(let c=0;c<t.length;c++)n.push({type:"textord",mode:"text",text:t[c]});let a={type:"text",mode:this.mode,body:n};return{type:"color",mode:this.mode,color:this.settings.errorColor,body:[a]}}parseAtom(t){let n=this.parseGroup("atom",t);if(n&&n.type==="internal"||this.mode==="text")return n;let a,c;for(;;){this.consumeSpaces();let p=this.fetch();if(p.text==="\\limits"||p.text==="\\nolimits"){if(n&&n.type==="op"){let g=p.text==="\\limits";n.limits=g,n.alwaysHandleSupSub=!0}else{if(!n||n.type!=="operatorname")throw new r("Limit controls must follow a math operator",p);n.alwaysHandleSupSub&&(n.limits=p.text==="\\limits")}this.consume()}else if(p.text==="^"){if(a)throw new r("Double superscript",p);a=this.handleSupSubscript("superscript")}else if(p.text==="_"){if(c)throw new r("Double subscript",p);c=this.handleSupSubscript("subscript")}else if(p.text==="'"){if(a)throw new r("Double superscript",p);let g={type:"textord",mode:this.mode,text:"\\prime"},x=[g];for(this.consume();this.fetch().text==="'";)x.push(g),this.consume();this.fetch().text==="^"&&x.push(this.handleSupSubscript("superscript")),a={type:"ordgroup",mode:this.mode,body:x}}else{if(!dr[p.text])break;{let g=Ds.test(p.text),x=[];for(x.push(new qt(dr[p.text])),this.consume();;){let j=this.fetch().text;if(!dr[j]||Ds.test(j)!==g)break;x.unshift(new qt(dr[j])),this.consume()}let q=this.subparse(x);g?c={type:"ordgroup",mode:"math",body:q}:a={type:"ordgroup",mode:"math",body:q}}}}if(a||c){if(n&&n.type==="multiscript"&&!n.postscripts)return n.postscripts={sup:a,sub:c},n;{let p=!n||n.type!=="op"&&n.type!=="operatorname"?void 0:ue(this.nextToken.text);return{type:"supsub",mode:this.mode,base:n,sup:a,sub:c,isFollowedByDelimiter:p}}}return n}parseFunction(t,n){let a=this.fetch(),c=a.text,p=Mn[c];if(!p)return null;if(this.consume(),n&&n!=="atom"&&!p.allowedInArgument)throw new r("Got function '"+c+"' with no arguments"+(n?" as "+n:""),a);if(this.mode==="text"&&!p.allowedInText)throw new r("Can't use function '"+c+"' in text mode",a);if(this.mode==="math"&&p.allowedInMath===!1)throw new r("Can't use function '"+c+"' in math mode",a);let g=this.prevAtomType,{args:x,optArgs:q}=this.parseArguments(c,p);return this.prevAtomType=g,this.callFunction(c,x,q,a,t)}callFunction(t,n,a,c,p){let g={funcName:t,parser:this,token:c,breakOnTokenText:p},x=Mn[t];if(x&&x.handler)return x.handler(g,n,a);throw new r(`No function handler for ${t}`)}parseArguments(t,n){let a=n.numArgs+n.numOptionalArgs;if(a===0)return{args:[],optArgs:[]};let c=[],p=[];for(let g=0;g<a;g++){let x=n.argTypes&&n.argTypes[g],q=g<n.numOptionalArgs;(n.primitive&&x==null||n.type==="sqrt"&&g===1&&p[0]==null)&&(x="primitive");let j=this.parseGroupOfType(`argument to '${t}'`,x,q);if(q)p.push(j);else{if(j==null)throw new r("Null argument, please report this as a bug");c.push(j)}}return{args:c,optArgs:p}}parseGroupOfType(t,n,a){switch(n){case"size":return this.parseSizeGroup(a);case"url":return this.parseUrlGroup(a);case"math":case"text":return this.parseArgumentGroup(a,n);case"hbox":{let c=this.parseArgumentGroup(a,"text");return c!=null?{type:"styling",mode:c.mode,body:[c],scriptLevel:"text"}:null}case"raw":{let c=this.parseStringGroup("raw",a);return c!=null?{type:"raw",mode:"text",string:c.text}:null}case"primitive":{if(a)throw new r("A primitive argument cannot be optional");let c=this.parseGroup(t);if(c==null)throw new r("Expected group as "+t,this.fetch());return c}case"original":case null:case void 0:return this.parseArgumentGroup(a);default:throw new r("Unknown group type as "+t,this.fetch())}}consumeSpaces(){for(;;){let t=this.fetch().text;if(t!==" "&&t!=="\xA0"&&t!=="\uFE0E")break;this.consume()}}parseStringGroup(t,n){let a=this.gullet.scanArgument(n);if(a==null)return null;let c,p="";for(;(c=this.fetch()).text!=="EOF";)p+=c.text,this.consume();return this.consume(),a.text=p,a}parseRegexGroup(t,n){let a=this.fetch(),c,p=a,g="";for(;(c=this.fetch()).text!=="EOF"&&t.test(g+c.text);)p=c,g+=p.text,this.consume();if(g==="")throw new r("Invalid "+n+": '"+a.text+"'",a);return a.range(p,g)}parseSizeGroup(t){let n,a=!1;if(this.gullet.consumeSpaces(),n=t||this.gullet.future().text==="{"?this.parseStringGroup("size",t):this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/,"size"),!n)return null;t||n.text.length!==0||(n.text="0pt",a=!0);let c=Da.exec(n.text);if(!c)throw new r("Invalid size: '"+n.text+"'",n);let p={number:+(c[1]+c[2]),unit:c[3]};if(!Ht(p))throw new r("Invalid unit: '"+p.unit+"'",n);return{type:"size",mode:this.mode,value:p,isBlank:a}}parseUrlGroup(t){this.gullet.lexer.setCatcode("%",13),this.gullet.lexer.setCatcode("~",12);let n=this.parseStringGroup("url",t);if(this.gullet.lexer.setCatcode("%",14),this.gullet.lexer.setCatcode("~",13),n==null)return null;let a=n.text.replace(/\\([#$%&~_^{}])/g,"$1");return a=n.text.replace(/{\u2044}/g,"/"),{type:"url",mode:this.mode,url:a}}parseArgumentGroup(t,n){let a=this.gullet.scanArgument(t);if(a==null)return null;let c=this.mode;n&&this.switchMode(n),this.gullet.beginGroup();let p=this.parseExpression(!1,"EOF");this.expect("EOF"),this.gullet.endGroup();let g={type:"ordgroup",mode:this.mode,loc:a.loc,body:p};return n&&this.switchMode(c),g}parseGroup(t,n){let a=this.fetch(),c=a.text;if(t==="argument to '\\left'")return this.parseSymbol();let p;if(c==="{"||c==="\\begingroup"||c==="\\toggle"){this.consume();let g=c==="{"?"}":c==="\\begingroup"?"\\endgroup":"\\endtoggle";this.gullet.beginGroup();let x=this.parseExpression(!1,g),q=this.fetch();this.expect(g),this.gullet.endGroup(),p={type:q.text==="\\endtoggle"?"toggle":"ordgroup",mode:this.mode,loc:yt.range(a,q),body:x,semisimple:c==="\\begingroup"||void 0}}else if(p=this.parseFunction(n,t)||this.parseSymbol(),p==null&&c[0]==="\\"&&!Object.prototype.hasOwnProperty.call(Ps,c)){if(this.settings.throwOnError)throw new r("Unsupported function name: "+c,a);p=this.formatUnsupportedCmd(c),this.consume()}return p}formLigatures(t){let n=t.length-1;for(let a=0;a<n;++a){let c=t[a],p=c.text;p==="-"&&t[a+1].text==="-"&&(a+1<n&&t[a+2].text==="-"?(t.splice(a,3,{type:"textord",mode:"text",loc:yt.range(c,t[a+2]),text:"---"}),n-=2):(t.splice(a,2,{type:"textord",mode:"text",loc:yt.range(c,t[a+1]),text:"--"}),n-=1)),p!=="'"&&p!=="`"||t[a+1].text!==p||(t.splice(a,2,{type:"textord",mode:"text",loc:yt.range(c,t[a+1]),text:p+p}),n-=1)}}parseSymbol(){let t=this.fetch(),n=t.text;if(/^\\verb[^a-zA-Z]/.test(n)){this.consume();let p=n.slice(5),g=p.charAt(0)==="*";if(g&&(p=p.slice(1)),p.length<2||p.charAt(0)!==p.slice(-1))throw new r(`\\verb assertion failed --
97
- please report what input caused this bug`);return p=p.slice(1,-1),{type:"verb",mode:"text",body:p,star:g}}if(Object.prototype.hasOwnProperty.call(Fs,n[0])&&this.mode==="math"&&!Ce[this.mode][n[0]]){if(this.settings.strict&&this.mode==="math")throw new r(`Accented Unicode text character "${n[0]}" used in math mode`,t);n=Fs[n[0]]+n.slice(1)}let a=this.mode==="math"?Is.exec(n):null,c;if(a&&(n=n.substring(0,a.index),n==="i"?n="\u0131":n==="j"&&(n="\u0237")),Ce[this.mode][n]){let p=Ce[this.mode][n].group;p!=="bin"||!Pa.includes(this.prevAtomType)&&this.prevAtomType!==""||(p="open");let g=yt.range(t),x;if(Object.prototype.hasOwnProperty.call(Ae,p)){let q=p;x={type:"atom",mode:this.mode,family:q,loc:g,text:n},q!=="rel"&&q!=="bin"||this.prevAtomType!=="text"||qa.test(g.lexer.input.slice(g.end))&&(x.needsSpacing=!0)}else{if(qs[n]){this.consume();let q=this.fetch().text.charCodeAt(0),j=q===65025?"mathscr":"mathcal";return q!==65024&&q!==65025||this.consume(),{type:"font",mode:"math",font:j,body:{type:"mathord",mode:"math",loc:g,text:qs[n]}}}x={type:p,mode:this.mode,loc:g,text:n}}c=x}else{if(!(n.charCodeAt(0)>=128||Is.exec(n)))return null;if(this.settings.strict&&this.mode==="math")throw new r(`Unicode text character "${n[0]}" used in math mode`,t);c={type:"textord",mode:"text",loc:yt.range(t),text:n}}if(this.consume(),a)for(let p=0;p<a[0].length;p++){let g=a[0][p];if(!Fr[g])throw new r(`Unknown accent ' ${g}'`,t);let x=Fr[g][this.mode]||Fr[g].text;if(!x)throw new r(`Accent ${g} unsupported in ${this.mode} mode`,t);c={type:"accent",mode:this.mode,loc:yt.range(t),label:x,isStretchy:!1,base:c}}return c}}let zs=function(e,t){if(!(typeof e=="string"||e instanceof String))throw new TypeError("Temml can only parse string typed expression");let n,a;try{a=new Qn(e,t),delete a.gullet.macros.current["\\df@tag"],n=a.parse()}catch(c){if(c.toString()!=="ParseError: Unmatched delimiter")throw c;t.wrapDelimiterPairs=!1,a=new Qn(e,t),delete a.gullet.macros.current["\\df@tag"],n=a.parse()}if(!(n.length>0&&n[0].type&&n[0].type==="array"&&n[0].addEqnNum)&&a.gullet.macros.get("\\df@tag")){if(!t.displayMode)throw new r("\\tag works only in display mode");a.gullet.feed("\\df@tag"),n=[{type:"tag",mode:"text",body:n,tag:a.parse()}]}return n},Fa=[2,2,3,3];class zr{constructor(t){this.level=t.level,this.color=t.color,this.font=t.font||"",this.fontFamily=t.fontFamily||"",this.fontSize=t.fontSize||1,this.fontWeight=t.fontWeight||"",this.fontShape=t.fontShape||"",this.maxSize=t.maxSize}extend(t){let n={level:this.level,color:this.color,font:this.font,fontFamily:this.fontFamily,fontSize:this.fontSize,fontWeight:this.fontWeight,fontShape:this.fontShape,maxSize:this.maxSize};for(let a in t)Object.prototype.hasOwnProperty.call(t,a)&&(n[a]=t[a]);return new zr(n)}withLevel(t){return this.extend({level:t})}incrementLevel(){return this.extend({level:Math.min(this.level+1,3)})}inSubOrSup(){return this.extend({level:Fa[this.level]})}withColor(t){return this.extend({color:t})}withFont(t){return this.extend({font:t})}withTextFontFamily(t){return this.extend({fontFamily:t,font:""})}withFontSize(t){return this.extend({fontSize:t})}withTextFontWeight(t){return this.extend({fontWeight:t,font:""})}withTextFontShape(t){return this.extend({fontShape:t,font:""})}getColor(){return this.color}}function Us(e){let t={},n=0,a=document.getElementsByClassName("tml-eqn");for(let p of a)for(n+=1,p.setAttribute("id","tml-eqn-"+String(n));p.tagName!=="mtable";){if(p.getElementsByClassName("tml-label").length>0){let g=p.attributes.id.value;t[g]=String(n);break}p=p.parentElement}let c=document.getElementsByClassName("tml-tageqn");for(let p of c)if(p.getElementsByClassName("tml-label").length>0){let g=p.getElementsByClassName("tml-tag");if(g.length>0){let x=p.attributes.id.value;t[x]=g[0].textContent}}[...e.getElementsByClassName("tml-ref")].forEach(p=>{let g=p.getAttribute("href"),x=t[g.slice(1)];p.className.indexOf("tml-eqref")===-1?(x=x.replace(/^\(/,""),x=x.replace(/\)$/,"")):(x.charAt(0)!=="("&&(x="("+x),x.slice(-1)!==")"&&(x+=")"));let q=document.createElementNS("http://www.w3.org/1998/Math/MathML","mtext");q.appendChild(document.createTextNode(x));let j=document.createElementNS("http://www.w3.org/1998/Math/MathML","math");j.appendChild(q),p.textContent="",p.appendChild(j)})}let za=function(e,t,n){let a=n,c=0,p=e.length;for(;a<t.length;){let g=t[a];if(c<=0&&t.slice(a,a+p)===e)return a;g==="\\"?a++:g==="{"?c++:g==="}"&&c--,a++}return-1},Ua=/^\\(?:begin|(?:eq)?ref){/,Hs=[{left:"$$",right:"$$",display:!0},{left:"\\(",right:"\\)",display:!1},{left:"\\begin{equation}",right:"\\end{equation}",display:!0},{left:"\\begin{equation*}",right:"\\end{equation*}",display:!0},{left:"\\begin{align}",right:"\\end{align}",display:!0},{left:"\\begin{align*}",right:"\\end{align*}",display:!0},{left:"\\begin{alignat}",right:"\\end{alignat}",display:!0},{left:"\\begin{alignat*}",right:"\\end{alignat*}",display:!0},{left:"\\begin{gather}",right:"\\end{gather}",display:!0},{left:"\\begin{gather*}",right:"\\end{gather*}",display:!0},{left:"\\begin{CD}",right:"\\end{CD}",display:!0},{left:"\\ref{",right:"}",display:!1},{left:"\\eqref{",right:"}",display:!1},{left:"\\[",right:"\\]",display:!0}],ur={$:[{left:"$$",right:"$$",display:!0},{left:"$`",right:"`$",display:!1},{left:"$",right:"$",display:!1}],"(":[{left:"\\[",right:"\\]",display:!0},{left:"\\(",right:"\\)",display:!1}]},Ur=[{left:"\\begin{equation}",right:"\\end{equation}",display:!0},{left:"\\begin{equation*}",right:"\\end{equation*}",display:!0},{left:"\\begin{align}",right:"\\end{align}",display:!0},{left:"\\begin{align*}",right:"\\end{align*}",display:!0},{left:"\\begin{alignat}",right:"\\end{alignat}",display:!0},{left:"\\begin{alignat*}",right:"\\end{alignat*}",display:!0},{left:"\\begin{gather}",right:"\\end{gather}",display:!0},{left:"\\begin{gather*}",right:"\\end{gather*}",display:!0},{left:"\\begin{CD}",right:"\\end{CD}",display:!0},{left:"\\ref{",right:"}",display:!1},{left:"\\eqref{",right:"}",display:!1}],Ha=function(e,t){let n=function(c,p){let g,x=[],q=new RegExp("("+p.map(j=>j.left.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")+")");for(;g=c.search(q),g!==-1;){g>0&&(x.push({type:"text",data:c.slice(0,g)}),c=c.slice(g));let j=p.findIndex(ee=>c.startsWith(ee.left));if(g=za(p[j].right,c,p[j].left.length),g===-1)break;let ie=c.slice(0,g+p[j].right.length),he=Ua.test(ie)?ie:c.slice(p[j].left.length,g);x.push({type:"math",data:he,rawData:ie,display:p[j].display}),c=c.slice(g+p[j].right.length)}return c!==""&&x.push({type:"text",data:c}),x}(e,t.delimiters);if(n.length===1&&n[0].type==="text")return null;let a=document.createDocumentFragment();for(let c=0;c<n.length;c++)if(n[c].type==="text")a.appendChild(document.createTextNode(n[c].data));else{let p=document.createElement("span"),g=n[c].data;t.displayMode=n[c].display;try{t.preProcess&&(g=t.preProcess(g)),mo.render(g,p,t)}catch(x){if(!(x instanceof r))throw x;t.errorCallback("Temml auto-render: Failed to parse `"+n[c].data+"` with ",x),a.appendChild(document.createTextNode(n[c].rawData));continue}a.appendChild(p)}return a},Gs=function(e,t){for(let n=0;n<e.childNodes.length;n++){let a=e.childNodes[n];if(a.nodeType===3){let c=Ha(a.textContent,t);c&&(n+=c.childNodes.length-1,e.replaceChild(c,a))}else if(a.nodeType===1){let c=" "+a.className+" ";t.ignoredTags.indexOf(a.nodeName.toLowerCase())===-1&&t.ignoredClasses.every(p=>c.indexOf(" "+p+" ")===-1)&&Gs(a,t)}}},js=function(e,t,n={}){t.textContent="";let a=t.tagName.toLowerCase()==="math";a&&(n.wrap="none");let c=Hr(e,n);a||c.children.length>1?(t.textContent="",c.children.forEach(p=>{t.appendChild(p.toNode())})):t.appendChild(c.toNode())};typeof document<"u"&&document.compatMode!=="CSS1Compat"&&(typeof console<"u"&&console.warn("Warning: Temml doesn't work in quirks mode. Make sure your website has a suitable doctype."),js=function(){throw new r("Temml doesn't work in quirks mode.")});let Hr=function(e,t){let n=new P(t);try{let a=zs(e,n);return Vt(a,e,new zr({level:n.displayMode?Ft:Pt,maxSize:n.maxSize}),n)}catch(a){return function(c,p,g){if(g.throwOnError||!(c instanceof r))throw c;let x=new De(["temml-error"],[new xe(p+`
95
+ ?)[ \r ]*|([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]${Mt}*|[\uD800-\uDBFF][\uDC00-\uDFFF]${Mt}*|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5|${at}|\\\\[^\uD800-\uDFFF])`;class vt{constructor(n,r){this.input=n,this.settings=r,this.tokenRegex=new RegExp(Jt,"g"),this.catcodes={"%":14,"~":13}}setCatcode(n,r){this.catcodes[n]=r}lex(){let n=this.input,r=this.tokenRegex.lastIndex;if(r===n.length)return new ot("EOF",new Oe(this,r,r));let l=this.tokenRegex.exec(n);if(l===null||l.index!==r)throw new t(`Unexpected character: '${n[r]}'`,new ot(n[r],new Oe(this,r,r+1)));let u=l[6]||l[3]||(l[2]?"\\ ":" ");if(this.catcodes[u]===14){let h=n.indexOf(`
96
+ `,this.tokenRegex.lastIndex);if(h===-1){if(this.tokenRegex.lastIndex=n.length,this.settings.strict)throw new t("% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode")}else this.tokenRegex.lastIndex=h+1;return this.lex()}return new ot(u,new Oe(this,r,this.tokenRegex.lastIndex))}}class Ft{constructor(n={},r={}){this.current=r,this.builtins=n,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(this.undefStack.length===0)throw new t("Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug");let n=this.undefStack.pop();for(let r in n)Object.prototype.hasOwnProperty.call(n,r)&&(n[r]===void 0?delete this.current[r]:this.current[r]=n[r])}has(n){return Object.prototype.hasOwnProperty.call(this.current,n)||Object.prototype.hasOwnProperty.call(this.builtins,n)}get(n){return Object.prototype.hasOwnProperty.call(this.current,n)?this.current[n]:this.builtins[n]}set(n,r,l=!1){if(l){for(let u=0;u<this.undefStack.length;u++)delete this.undefStack[u][n];this.undefStack.length>0&&(this.undefStack[this.undefStack.length-1][n]=r)}else{let u=this.undefStack[this.undefStack.length-1];u&&!Object.prototype.hasOwnProperty.call(u,n)&&(u[n]=this.current[n])}this.current[n]=r}}let jt={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0};class Pn{constructor(n,r,l){this.settings=r,this.expansionCount=0,this.feed(n),this.macros=new Ft(Pt,r.macros),this.mode=l,this.stack=[]}feed(n){this.lexer=new vt(n,this.settings)}switchMode(n){this.mode=n}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}future(){return this.stack.length===0&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(n){this.stack.push(n)}pushTokens(n){this.stack.push(...n)}scanArgument(n){let r,l,u;if(n){if(this.consumeSpaces(),this.future().text!=="[")return null;r=this.popToken(),{tokens:u,end:l}=this.consumeArg(["]"])}else({tokens:u,start:r,end:l}=this.consumeArg());return this.pushToken(new ot("EOF",l.loc)),this.pushTokens(u),new ot("",Oe.range(r,l))}consumeSpaces(){for(;this.future().text===" ";)this.stack.pop()}consumeArg(n){let r=[],l=n&&n.length>0;l||this.consumeSpaces();let u=this.future(),h,y=0,x=0;do{if(h=this.popToken(),r.push(h),h.text==="{")++y;else if(h.text==="}"){if(--y,y===-1)throw new t("Extra }",h)}else if(h.text==="EOF")throw new t("Unexpected end of input in a macro argument, expected '"+(n&&l?n[x]:"}")+"'",h);if(n&&l)if((y===0||y===1&&n[x]==="{")&&h.text===n[x]){if(++x,x===n.length){r.splice(-x,x);break}}else x=0}while(y!==0||l);return u.text==="{"&&r[r.length-1].text==="}"&&(r.pop(),r.shift()),r.reverse(),{tokens:r,start:u,end:h}}consumeArgs(n,r){if(r){if(r.length!==n+1)throw new t("The length of delimiters doesn't match the number of args!");let u=r[0];for(let h=0;h<u.length;h++){let y=this.popToken();if(u[h]!==y.text)throw new t("Use of the macro doesn't match its definition",y)}}let l=[];for(let u=0;u<n;u++)l.push(this.consumeArg(r&&r[u+1]).tokens);return l}expandOnce(n){let r=this.popToken(),l=r.text,u=r.noexpand?null:this._getExpansion(l);if(u==null||n&&u.unexpandable){if(n&&u==null&&l[0]==="\\"&&!this.isDefined(l))throw new t("Undefined control sequence: "+l);return this.pushToken(r),!1}if(this.expansionCount++,this.expansionCount>this.settings.maxExpand)throw new t("Too many expansions: infinite loop or need to increase maxExpand setting");let h=u.tokens,y=this.consumeArgs(u.numArgs,u.delimiters);if(u.numArgs){h=h.slice();for(let x=h.length-1;x>=0;--x){let q=h[x];if(q.text==="#"){if(x===0)throw new t("Incomplete placeholder at end of macro body",q);if(q=h[--x],q.text==="#")h.splice(x+1,1);else{if(!/^[1-9]$/.test(q.text))throw new t("Not a valid argument number",q);h.splice(x,2,...y[+q.text-1])}}}}return this.pushTokens(h),h.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(this.expandOnce()===!1){let n=this.stack.pop();return n.treatAsRelax&&(n.text="\\relax"),n}throw new Error}expandMacro(n){return this.macros.has(n)?this.expandTokens([new ot(n)]):void 0}expandTokens(n){let r=[],l=this.stack.length;for(this.pushTokens(n);this.stack.length>l;)if(this.expandOnce(!0)===!1){let u=this.stack.pop();u.treatAsRelax&&(u.noexpand=!1,u.treatAsRelax=!1),r.push(u)}return r}expandMacroAsText(n){let r=this.expandMacro(n);return r&&r.map(l=>l.text).join("")}_getExpansion(n){let r=this.macros.get(n);if(r==null)return r;if(n.length===1){let u=this.lexer.catcodes[n];if(u!=null&&u!==13)return}let l=typeof r=="function"?r(this):r;if(typeof l=="string"){let u=0;if(l.indexOf("#")!==-1){let q=l.replace(/##/g,"");for(;q.indexOf("#"+(u+1))!==-1;)++u}let h=new vt(l,this.settings),y=[],x=h.lex();for(;x.text!=="EOF";)y.push(x),x=h.lex();return y.reverse(),{tokens:y,numArgs:u}}return l}isDefined(n){return this.macros.has(n)||Object.prototype.hasOwnProperty.call(Je,n)||Object.prototype.hasOwnProperty.call(Q.math,n)||Object.prototype.hasOwnProperty.call(Q.text,n)||Object.prototype.hasOwnProperty.call(jt,n)}isExpandable(n){let r=this.macros.get(n);return r!=null?typeof r=="string"||typeof r=="function"||!r.unexpandable:Object.prototype.hasOwnProperty.call(Je,n)&&!Je[n].primitive}}let ps=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,hs=Object.freeze({"\u208A":"+","\u208B":"-","\u208C":"=","\u208D":"(","\u208E":")","\u2080":"0","\u2081":"1","\u2082":"2","\u2083":"3","\u2084":"4","\u2085":"5","\u2086":"6","\u2087":"7","\u2088":"8","\u2089":"9","\u2090":"a","\u2091":"e","\u2095":"h","\u1D62":"i","\u2C7C":"j","\u2096":"k","\u2097":"l","\u2098":"m","\u2099":"n","\u2092":"o","\u209A":"p","\u1D63":"r","\u209B":"s","\u209C":"t","\u1D64":"u","\u1D65":"v","\u2093":"x","\u1D66":"\u03B2","\u1D67":"\u03B3","\u1D68":"\u03C1","\u1D69":"\u03D5","\u1D6A":"\u03C7","\u207A":"+","\u207B":"-","\u207C":"=","\u207D":"(","\u207E":")","\u2070":"0","\xB9":"1","\xB2":"2","\xB3":"3","\u2074":"4","\u2075":"5","\u2076":"6","\u2077":"7","\u2078":"8","\u2079":"9","\u1D2C":"A","\u1D2E":"B","\u1D30":"D","\u1D31":"E","\u1D33":"G","\u1D34":"H","\u1D35":"I","\u1D36":"J","\u1D37":"K","\u1D38":"L","\u1D39":"M","\u1D3A":"N","\u1D3C":"O","\u1D3E":"P","\u1D3F":"R","\u1D40":"T","\u1D41":"U","\u2C7D":"V","\u1D42":"W","\u1D43":"a","\u1D47":"b","\u1D9C":"c","\u1D48":"d","\u1D49":"e","\u1DA0":"f","\u1D4D":"g",\u02B0:"h","\u2071":"i",\u02B2:"j","\u1D4F":"k",\u02E1:"l","\u1D50":"m",\u207F:"n","\u1D52":"o","\u1D56":"p",\u02B3:"r",\u02E2:"s","\u1D57":"t","\u1D58":"u","\u1D5B":"v",\u02B7:"w",\u02E3:"x",\u02B8:"y","\u1DBB":"z","\u1D5D":"\u03B2","\u1D5E":"\u03B3","\u1D5F":"\u03B4","\u1D60":"\u03D5","\u1D61":"\u03C7","\u1DBF":"\u03B8"}),Co=Object.freeze({"\u{1D49C}":"A",\u212C:"B","\u{1D49E}":"C","\u{1D49F}":"D",\u2130:"E",\u2131:"F","\u{1D4A2}":"G",\u210B:"H",\u2110:"I","\u{1D4A5}":"J","\u{1D4A6}":"K",\u2112:"L",\u2133:"M","\u{1D4A9}":"N","\u{1D4AA}":"O","\u{1D4AB}":"P","\u{1D4AC}":"Q",\u211B:"R","\u{1D4AE}":"S","\u{1D4AF}":"T","\u{1D4B0}":"U","\u{1D4B1}":"V","\u{1D4B2}":"W","\u{1D4B3}":"X","\u{1D4B4}":"Y","\u{1D4B5}":"Z"});var Ks={"\u0301":{text:"\\'",math:"\\acute"},"\u0300":{text:"\\`",math:"\\grave"},"\u0308":{text:'\\"',math:"\\ddot"},"\u0303":{text:"\\~",math:"\\tilde"},"\u0304":{text:"\\=",math:"\\bar"},"\u0306":{text:"\\u",math:"\\breve"},"\u030C":{text:"\\v",math:"\\check"},"\u0302":{text:"\\^",math:"\\hat"},"\u0307":{text:"\\.",math:"\\dot"},"\u030A":{text:"\\r",math:"\\mathring"},"\u030B":{text:"\\H"},"\u0327":{text:"\\c"}},No={\u00E1:"a\u0301",\u00E0:"a\u0300",\u00E4:"a\u0308",\u01DF:"a\u0308\u0304",\u00E3:"a\u0303",\u0101:"a\u0304",\u0103:"a\u0306",\u1EAF:"a\u0306\u0301",\u1EB1:"a\u0306\u0300",\u1EB5:"a\u0306\u0303",\u01CE:"a\u030C",\u00E2:"a\u0302",\u1EA5:"a\u0302\u0301",\u1EA7:"a\u0302\u0300",\u1EAB:"a\u0302\u0303",\u0227:"a\u0307",\u01E1:"a\u0307\u0304",\u00E5:"a\u030A",\u01FB:"a\u030A\u0301",\u1E03:"b\u0307",\u0107:"c\u0301",\u010D:"c\u030C",\u0109:"c\u0302",\u010B:"c\u0307",\u010F:"d\u030C",\u1E0B:"d\u0307",\u00E9:"e\u0301",\u00E8:"e\u0300",\u00EB:"e\u0308",\u1EBD:"e\u0303",\u0113:"e\u0304",\u1E17:"e\u0304\u0301",\u1E15:"e\u0304\u0300",\u0115:"e\u0306",\u011B:"e\u030C",\u00EA:"e\u0302",\u1EBF:"e\u0302\u0301",\u1EC1:"e\u0302\u0300",\u1EC5:"e\u0302\u0303",\u0117:"e\u0307",\u1E1F:"f\u0307",\u01F5:"g\u0301",\u1E21:"g\u0304",\u011F:"g\u0306",\u01E7:"g\u030C",\u011D:"g\u0302",\u0121:"g\u0307",\u1E27:"h\u0308",\u021F:"h\u030C",\u0125:"h\u0302",\u1E23:"h\u0307",\u00ED:"i\u0301",\u00EC:"i\u0300",\u00EF:"i\u0308",\u1E2F:"i\u0308\u0301",\u0129:"i\u0303",\u012B:"i\u0304",\u012D:"i\u0306",\u01D0:"i\u030C",\u00EE:"i\u0302",\u01F0:"j\u030C",\u0135:"j\u0302",\u1E31:"k\u0301",\u01E9:"k\u030C",\u013A:"l\u0301",\u013E:"l\u030C",\u1E3F:"m\u0301",\u1E41:"m\u0307",\u0144:"n\u0301",\u01F9:"n\u0300",\u00F1:"n\u0303",\u0148:"n\u030C",\u1E45:"n\u0307",\u00F3:"o\u0301",\u00F2:"o\u0300",\u00F6:"o\u0308",\u022B:"o\u0308\u0304",\u00F5:"o\u0303",\u1E4D:"o\u0303\u0301",\u1E4F:"o\u0303\u0308",\u022D:"o\u0303\u0304",\u014D:"o\u0304",\u1E53:"o\u0304\u0301",\u1E51:"o\u0304\u0300",\u014F:"o\u0306",\u01D2:"o\u030C",\u00F4:"o\u0302",\u1ED1:"o\u0302\u0301",\u1ED3:"o\u0302\u0300",\u1ED7:"o\u0302\u0303",\u022F:"o\u0307",\u0231:"o\u0307\u0304",\u0151:"o\u030B",\u1E55:"p\u0301",\u1E57:"p\u0307",\u0155:"r\u0301",\u0159:"r\u030C",\u1E59:"r\u0307",\u015B:"s\u0301",\u1E65:"s\u0301\u0307",\u0161:"s\u030C",\u1E67:"s\u030C\u0307",\u015D:"s\u0302",\u1E61:"s\u0307",\u1E97:"t\u0308",\u0165:"t\u030C",\u1E6B:"t\u0307",\u00FA:"u\u0301",\u00F9:"u\u0300",\u00FC:"u\u0308",\u01D8:"u\u0308\u0301",\u01DC:"u\u0308\u0300",\u01D6:"u\u0308\u0304",\u01DA:"u\u0308\u030C",\u0169:"u\u0303",\u1E79:"u\u0303\u0301",\u016B:"u\u0304",\u1E7B:"u\u0304\u0308",\u016D:"u\u0306",\u01D4:"u\u030C",\u00FB:"u\u0302",\u016F:"u\u030A",\u0171:"u\u030B",\u1E7D:"v\u0303",\u1E83:"w\u0301",\u1E81:"w\u0300",\u1E85:"w\u0308",\u0175:"w\u0302",\u1E87:"w\u0307",\u1E98:"w\u030A",\u1E8D:"x\u0308",\u1E8B:"x\u0307",\u00FD:"y\u0301",\u1EF3:"y\u0300",\u00FF:"y\u0308",\u1EF9:"y\u0303",\u0233:"y\u0304",\u0177:"y\u0302",\u1E8F:"y\u0307",\u1E99:"y\u030A",\u017A:"z\u0301",\u017E:"z\u030C",\u1E91:"z\u0302",\u017C:"z\u0307",\u00C1:"A\u0301",\u00C0:"A\u0300",\u00C4:"A\u0308",\u01DE:"A\u0308\u0304",\u00C3:"A\u0303",\u0100:"A\u0304",\u0102:"A\u0306",\u1EAE:"A\u0306\u0301",\u1EB0:"A\u0306\u0300",\u1EB4:"A\u0306\u0303",\u01CD:"A\u030C",\u00C2:"A\u0302",\u1EA4:"A\u0302\u0301",\u1EA6:"A\u0302\u0300",\u1EAA:"A\u0302\u0303",\u0226:"A\u0307",\u01E0:"A\u0307\u0304",\u00C5:"A\u030A",\u01FA:"A\u030A\u0301",\u1E02:"B\u0307",\u0106:"C\u0301",\u010C:"C\u030C",\u0108:"C\u0302",\u010A:"C\u0307",\u010E:"D\u030C",\u1E0A:"D\u0307",\u00C9:"E\u0301",\u00C8:"E\u0300",\u00CB:"E\u0308",\u1EBC:"E\u0303",\u0112:"E\u0304",\u1E16:"E\u0304\u0301",\u1E14:"E\u0304\u0300",\u0114:"E\u0306",\u011A:"E\u030C",\u00CA:"E\u0302",\u1EBE:"E\u0302\u0301",\u1EC0:"E\u0302\u0300",\u1EC4:"E\u0302\u0303",\u0116:"E\u0307",\u1E1E:"F\u0307",\u01F4:"G\u0301",\u1E20:"G\u0304",\u011E:"G\u0306",\u01E6:"G\u030C",\u011C:"G\u0302",\u0120:"G\u0307",\u1E26:"H\u0308",\u021E:"H\u030C",\u0124:"H\u0302",\u1E22:"H\u0307",\u00CD:"I\u0301",\u00CC:"I\u0300",\u00CF:"I\u0308",\u1E2E:"I\u0308\u0301",\u0128:"I\u0303",\u012A:"I\u0304",\u012C:"I\u0306",\u01CF:"I\u030C",\u00CE:"I\u0302",\u0130:"I\u0307",\u0134:"J\u0302",\u1E30:"K\u0301",\u01E8:"K\u030C",\u0139:"L\u0301",\u013D:"L\u030C",\u1E3E:"M\u0301",\u1E40:"M\u0307",\u0143:"N\u0301",\u01F8:"N\u0300",\u00D1:"N\u0303",\u0147:"N\u030C",\u1E44:"N\u0307",\u00D3:"O\u0301",\u00D2:"O\u0300",\u00D6:"O\u0308",\u022A:"O\u0308\u0304",\u00D5:"O\u0303",\u1E4C:"O\u0303\u0301",\u1E4E:"O\u0303\u0308",\u022C:"O\u0303\u0304",\u014C:"O\u0304",\u1E52:"O\u0304\u0301",\u1E50:"O\u0304\u0300",\u014E:"O\u0306",\u01D1:"O\u030C",\u00D4:"O\u0302",\u1ED0:"O\u0302\u0301",\u1ED2:"O\u0302\u0300",\u1ED6:"O\u0302\u0303",\u022E:"O\u0307",\u0230:"O\u0307\u0304",\u0150:"O\u030B",\u1E54:"P\u0301",\u1E56:"P\u0307",\u0154:"R\u0301",\u0158:"R\u030C",\u1E58:"R\u0307",\u015A:"S\u0301",\u1E64:"S\u0301\u0307",\u0160:"S\u030C",\u1E66:"S\u030C\u0307",\u015C:"S\u0302",\u1E60:"S\u0307",\u0164:"T\u030C",\u1E6A:"T\u0307",\u00DA:"U\u0301",\u00D9:"U\u0300",\u00DC:"U\u0308",\u01D7:"U\u0308\u0301",\u01DB:"U\u0308\u0300",\u01D5:"U\u0308\u0304",\u01D9:"U\u0308\u030C",\u0168:"U\u0303",\u1E78:"U\u0303\u0301",\u016A:"U\u0304",\u1E7A:"U\u0304\u0308",\u016C:"U\u0306",\u01D3:"U\u030C",\u00DB:"U\u0302",\u016E:"U\u030A",\u0170:"U\u030B",\u1E7C:"V\u0303",\u1E82:"W\u0301",\u1E80:"W\u0300",\u1E84:"W\u0308",\u0174:"W\u0302",\u1E86:"W\u0307",\u1E8C:"X\u0308",\u1E8A:"X\u0307",\u00DD:"Y\u0301",\u1EF2:"Y\u0300",\u0178:"Y\u0308",\u1EF8:"Y\u0303",\u0232:"Y\u0304",\u0176:"Y\u0302",\u1E8E:"Y\u0307",\u0179:"Z\u0301",\u017D:"Z\u030C",\u1E90:"Z\u0302",\u017B:"Z\u0307",\u03AC:"\u03B1\u0301",\u1F70:"\u03B1\u0300",\u1FB1:"\u03B1\u0304",\u1FB0:"\u03B1\u0306",\u03AD:"\u03B5\u0301",\u1F72:"\u03B5\u0300",\u03AE:"\u03B7\u0301",\u1F74:"\u03B7\u0300",\u03AF:"\u03B9\u0301",\u1F76:"\u03B9\u0300",\u03CA:"\u03B9\u0308",\u0390:"\u03B9\u0308\u0301",\u1FD2:"\u03B9\u0308\u0300",\u1FD1:"\u03B9\u0304",\u1FD0:"\u03B9\u0306",\u03CC:"\u03BF\u0301",\u1F78:"\u03BF\u0300",\u03CD:"\u03C5\u0301",\u1F7A:"\u03C5\u0300",\u03CB:"\u03C5\u0308",\u03B0:"\u03C5\u0308\u0301",\u1FE2:"\u03C5\u0308\u0300",\u1FE1:"\u03C5\u0304",\u1FE0:"\u03C5\u0306",\u03CE:"\u03C9\u0301",\u1F7C:"\u03C9\u0300",\u038E:"\u03A5\u0301",\u1FEA:"\u03A5\u0300",\u03AB:"\u03A5\u0308",\u1FE9:"\u03A5\u0304",\u1FE8:"\u03A5\u0306",\u038F:"\u03A9\u0301",\u1FFA:"\u03A9\u0300"};let tl=["bin","op","open","punct","rel"],nl=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/,rl=/^ *\\text/;class Kr{constructor(n,r,l=!1){this.mode="math",this.gullet=new Pn(n,r,this.mode),this.settings=r,this.isPreamble=l,this.leftrightDepth=0,this.prevAtomType=""}expect(n,r=!0){if(this.fetch().text!==n)throw new t(`Expected '${n}', got '${this.fetch().text}'`,this.fetch());r&&this.consume()}consume(){this.nextToken=null}fetch(){return this.nextToken==null&&(this.nextToken=this.gullet.expandNextToken()),this.nextToken}switchMode(n){this.mode=n,this.gullet.switchMode(n)}parse(){this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set("\\color","\\textcolor");let n=this.parseExpression(!1);if(this.expect("EOF"),this.isPreamble){let l=Object.create(null);return Object.entries(this.gullet.macros.current).forEach(([u,h])=>{l[u]=h}),this.gullet.endGroup(),l}let r=this.gullet.macros.get("\\df@tag");return this.gullet.endGroup(),r&&(this.gullet.macros.current["\\df@tag"]=r),n}static get endOfExpression(){return["}","\\endgroup","\\end","\\right","\\endtoggle","&"]}subparse(n){let r=this.nextToken;this.consume(),this.gullet.pushToken(new ot("}")),this.gullet.pushTokens(n);let l=this.parseExpression(!1);return this.expect("}"),this.nextToken=r,l}parseExpression(n,r,l){let u=[];for(this.prevAtomType="";;){this.mode==="math"&&this.consumeSpaces();let h=this.fetch();if(Kr.endOfExpression.indexOf(h.text)!==-1||r&&h.text===r||l&&h.text==="\\middle"||n&&Je[h.text]&&Je[h.text].infix)break;let y=this.parseAtom(r);if(!y)break;y.type!=="internal"&&(u.push(y),this.prevAtomType=y.type==="atom"?y.family:y.type)}return this.mode==="text"&&this.formLigatures(u),this.handleInfixNodes(u)}handleInfixNodes(n){let r,l=-1;for(let u=0;u<n.length;u++)if(n[u].type==="infix"){if(l!==-1)throw new t("only one infix operator per group",n[u].token);l=u,r=n[u].replaceWith}if(l!==-1&&r){let u,h,y=n.slice(0,l),x=n.slice(l+1),q;return u=y.length===1&&y[0].type==="ordgroup"?y[0]:{type:"ordgroup",mode:this.mode,body:y},h=x.length===1&&x[0].type==="ordgroup"?x[0]:{type:"ordgroup",mode:this.mode,body:x},q=r==="\\\\abovefrac"?this.callFunction(r,[u,n[l],h],[]):this.callFunction(r,[u,h],[]),[q]}return n}handleSupSubscript(n){let r=this.fetch(),l=r.text,u;this.consume(),this.consumeSpaces();do u=this.parseGroup(n);while(u.type&&u.type==="internal");if(!u)throw new t("Expected group after '"+l+"'",r);return u}formatUnsupportedCmd(n){let r=[];for(let u=0;u<n.length;u++)r.push({type:"textord",mode:"text",text:n[u]});let l={type:"text",mode:this.mode,body:r};return{type:"color",mode:this.mode,color:this.settings.errorColor,body:[l]}}parseAtom(n){let r=this.parseGroup("atom",n);if(r&&r.type==="internal"||this.mode==="text")return r;let l,u;for(;;){this.consumeSpaces();let h=this.fetch();if(h.text==="\\limits"||h.text==="\\nolimits"){if(r&&r.type==="op"){let y=h.text==="\\limits";r.limits=y,r.alwaysHandleSupSub=!0}else{if(!r||r.type!=="operatorname")throw new t("Limit controls must follow a math operator",h);r.alwaysHandleSupSub&&(r.limits=h.text==="\\limits")}this.consume()}else if(h.text==="^"){if(l)throw new t("Double superscript",h);l=this.handleSupSubscript("superscript")}else if(h.text==="_"){if(u)throw new t("Double subscript",h);u=this.handleSupSubscript("subscript")}else if(h.text==="'"){if(l)throw new t("Double superscript",h);let y={type:"textord",mode:this.mode,text:"\\prime"},x=[y];for(this.consume();this.fetch().text==="'";)x.push(y),this.consume();this.fetch().text==="^"&&x.push(this.handleSupSubscript("superscript")),l={type:"ordgroup",mode:this.mode,body:x}}else{if(!hs[h.text])break;{let y=ps.test(h.text),x=[];for(x.push(new ot(hs[h.text])),this.consume();;){let Z=this.fetch().text;if(!hs[Z]||ps.test(Z)!==y)break;x.unshift(new ot(hs[Z])),this.consume()}let q=this.subparse(x);y?u={type:"ordgroup",mode:"math",body:q}:l={type:"ordgroup",mode:"math",body:q}}}}if(l||u){if(r&&r.type==="multiscript"&&!r.postscripts)return r.postscripts={sup:l,sub:u},r;{let h=!r||r.type!=="op"&&r.type!=="operatorname"?void 0:Ln(this.nextToken.text);return{type:"supsub",mode:this.mode,base:r,sup:l,sub:u,isFollowedByDelimiter:h}}}return r}parseFunction(n,r){let l=this.fetch(),u=l.text,h=Je[u];if(!h)return null;if(this.consume(),r&&r!=="atom"&&!h.allowedInArgument)throw new t("Got function '"+u+"' with no arguments"+(r?" as "+r:""),l);if(this.mode==="text"&&!h.allowedInText)throw new t("Can't use function '"+u+"' in text mode",l);if(this.mode==="math"&&h.allowedInMath===!1)throw new t("Can't use function '"+u+"' in math mode",l);let y=this.prevAtomType,{args:x,optArgs:q}=this.parseArguments(u,h);return this.prevAtomType=y,this.callFunction(u,x,q,l,n)}callFunction(n,r,l,u,h){let y={funcName:n,parser:this,token:u,breakOnTokenText:h},x=Je[n];if(x&&x.handler)return x.handler(y,r,l);throw new t(`No function handler for ${n}`)}parseArguments(n,r){let l=r.numArgs+r.numOptionalArgs;if(l===0)return{args:[],optArgs:[]};let u=[],h=[];for(let y=0;y<l;y++){let x=r.argTypes&&r.argTypes[y],q=y<r.numOptionalArgs;(r.primitive&&x==null||r.type==="sqrt"&&y===1&&h[0]==null)&&(x="primitive");let Z=this.parseGroupOfType(`argument to '${n}'`,x,q);if(q)h.push(Z);else{if(Z==null)throw new t("Null argument, please report this as a bug");u.push(Z)}}return{args:u,optArgs:h}}parseGroupOfType(n,r,l){switch(r){case"size":return this.parseSizeGroup(l);case"url":return this.parseUrlGroup(l);case"math":case"text":return this.parseArgumentGroup(l,r);case"hbox":{let u=this.parseArgumentGroup(l,"text");return u!=null?{type:"styling",mode:u.mode,body:[u],scriptLevel:"text"}:null}case"raw":{let u=this.parseStringGroup("raw",l);return u!=null?{type:"raw",mode:"text",string:u.text}:null}case"primitive":{if(l)throw new t("A primitive argument cannot be optional");let u=this.parseGroup(n);if(u==null)throw new t("Expected group as "+n,this.fetch());return u}case"original":case null:case void 0:return this.parseArgumentGroup(l);default:throw new t("Unknown group type as "+n,this.fetch())}}consumeSpaces(){for(;;){let n=this.fetch().text;if(n!==" "&&n!=="\xA0"&&n!=="\uFE0E")break;this.consume()}}parseStringGroup(n,r){let l=this.gullet.scanArgument(r);if(l==null)return null;let u,h="";for(;(u=this.fetch()).text!=="EOF";)h+=u.text,this.consume();return this.consume(),l.text=h,l}parseRegexGroup(n,r){let l=this.fetch(),u,h=l,y="";for(;(u=this.fetch()).text!=="EOF"&&n.test(y+u.text);)h=u,y+=h.text,this.consume();if(y==="")throw new t("Invalid "+r+": '"+l.text+"'",l);return l.range(h,y)}parseSizeGroup(n){let r,l=!1;if(this.gullet.consumeSpaces(),r=n||this.gullet.future().text==="{"?this.parseStringGroup("size",n):this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/,"size"),!r)return null;n||r.text.length!==0||(r.text="0pt",l=!0);let u=nl.exec(r.text);if(!u)throw new t("Invalid size: '"+r.text+"'",r);let h={number:+(u[1]+u[2]),unit:u[3]};if(!Lt(h))throw new t("Invalid unit: '"+h.unit+"'",r);return{type:"size",mode:this.mode,value:h,isBlank:l}}parseUrlGroup(n){this.gullet.lexer.setCatcode("%",13),this.gullet.lexer.setCatcode("~",12);let r=this.parseStringGroup("url",n);if(this.gullet.lexer.setCatcode("%",14),this.gullet.lexer.setCatcode("~",13),r==null)return null;let l=r.text.replace(/\\([#$%&~_^{}])/g,"$1");return l=r.text.replace(/{\u2044}/g,"/"),{type:"url",mode:this.mode,url:l}}parseArgumentGroup(n,r){let l=this.gullet.scanArgument(n);if(l==null)return null;let u=this.mode;r&&this.switchMode(r),this.gullet.beginGroup();let h=this.parseExpression(!1,"EOF");this.expect("EOF"),this.gullet.endGroup();let y={type:"ordgroup",mode:this.mode,loc:l.loc,body:h};return r&&this.switchMode(u),y}parseGroup(n,r){let l=this.fetch(),u=l.text;if(n==="argument to '\\left'")return this.parseSymbol();let h;if(u==="{"||u==="\\begingroup"||u==="\\toggle"){this.consume();let y=u==="{"?"}":u==="\\begingroup"?"\\endgroup":"\\endtoggle";this.gullet.beginGroup();let x=this.parseExpression(!1,y),q=this.fetch();this.expect(y),this.gullet.endGroup(),h={type:q.text==="\\endtoggle"?"toggle":"ordgroup",mode:this.mode,loc:Oe.range(l,q),body:x,semisimple:u==="\\begingroup"||void 0}}else if(h=this.parseFunction(r,n)||this.parseSymbol(),h==null&&u[0]==="\\"&&!Object.prototype.hasOwnProperty.call(jt,u)){if(this.settings.throwOnError)throw new t("Unsupported function name: "+u,l);h=this.formatUnsupportedCmd(u),this.consume()}return h}formLigatures(n){let r=n.length-1;for(let l=0;l<r;++l){let u=n[l],h=u.text;h==="-"&&n[l+1].text==="-"&&(l+1<r&&n[l+2].text==="-"?(n.splice(l,3,{type:"textord",mode:"text",loc:Oe.range(u,n[l+2]),text:"---"}),r-=2):(n.splice(l,2,{type:"textord",mode:"text",loc:Oe.range(u,n[l+1]),text:"--"}),r-=1)),h!=="'"&&h!=="`"||n[l+1].text!==h||(n.splice(l,2,{type:"textord",mode:"text",loc:Oe.range(u,n[l+1]),text:h+h}),r-=1)}}parseSymbol(){let n=this.fetch(),r=n.text;if(/^\\verb[^a-zA-Z]/.test(r)){this.consume();let h=r.slice(5),y=h.charAt(0)==="*";if(y&&(h=h.slice(1)),h.length<2||h.charAt(0)!==h.slice(-1))throw new t(`\\verb assertion failed --
97
+ please report what input caused this bug`);return h=h.slice(1,-1),{type:"verb",mode:"text",body:h,star:y}}if(Object.prototype.hasOwnProperty.call(No,r[0])&&this.mode==="math"&&!Q[this.mode][r[0]]){if(this.settings.strict&&this.mode==="math")throw new t(`Accented Unicode text character "${r[0]}" used in math mode`,n);r=No[r[0]]+r.slice(1)}let l=this.mode==="math"?Ot.exec(r):null,u;if(l&&(r=r.substring(0,l.index),r==="i"?r="\u0131":r==="j"&&(r="\u0237")),Q[this.mode][r]){let h=Q[this.mode][r].group;h!=="bin"||!tl.includes(this.prevAtomType)&&this.prevAtomType!==""||(h="open");let y=Oe.range(n),x;if(Object.prototype.hasOwnProperty.call(ue,h)){let q=h;x={type:"atom",mode:this.mode,family:q,loc:y,text:r},q!=="rel"&&q!=="bin"||this.prevAtomType!=="text"||rl.test(y.lexer.input.slice(y.end))&&(x.needsSpacing=!0)}else{if(Co[r]){this.consume();let q=this.fetch().text.charCodeAt(0),Z=q===65025?"mathscr":"mathcal";return q!==65024&&q!==65025||this.consume(),{type:"font",mode:"math",font:Z,body:{type:"mathord",mode:"math",loc:y,text:Co[r]}}}x={type:h,mode:this.mode,loc:y,text:r}}u=x}else{if(!(r.charCodeAt(0)>=128||Ot.exec(r)))return null;if(this.settings.strict&&this.mode==="math")throw new t(`Unicode text character "${r[0]}" used in math mode`,n);u={type:"textord",mode:"text",loc:Oe.range(n),text:r}}if(this.consume(),l)for(let h=0;h<l[0].length;h++){let y=l[0][h];if(!Ks[y])throw new t(`Unknown accent ' ${y}'`,n);let x=Ks[y][this.mode]||Ks[y].text;if(!x)throw new t(`Accent ${y} unsupported in ${this.mode} mode`,n);u={type:"accent",mode:this.mode,loc:Oe.range(n),label:x,isStretchy:!1,base:u}}return u}}let Mo=function(e,n){if(!(typeof e=="string"||e instanceof String))throw new TypeError("Temml can only parse string typed expression");let r,l;try{l=new Kr(e,n),delete l.gullet.macros.current["\\df@tag"],r=l.parse()}catch(u){if(u.toString()!=="ParseError: Unmatched delimiter")throw u;n.wrapDelimiterPairs=!1,l=new Kr(e,n),delete l.gullet.macros.current["\\df@tag"],r=l.parse()}if(!(r.length>0&&r[0].type&&r[0].type==="array"&&r[0].addEqnNum)&&l.gullet.macros.get("\\df@tag")){if(!n.displayMode)throw new t("\\tag works only in display mode");l.gullet.feed("\\df@tag"),r=[{type:"tag",mode:"text",body:r,tag:l.parse()}]}return r},sl=[2,2,3,3];class Ws{constructor(n){this.level=n.level,this.color=n.color,this.font=n.font||"",this.fontFamily=n.fontFamily||"",this.fontSize=n.fontSize||1,this.fontWeight=n.fontWeight||"",this.fontShape=n.fontShape||"",this.maxSize=n.maxSize}extend(n){let r={level:this.level,color:this.color,font:this.font,fontFamily:this.fontFamily,fontSize:this.fontSize,fontWeight:this.fontWeight,fontShape:this.fontShape,maxSize:this.maxSize};for(let l in n)Object.prototype.hasOwnProperty.call(n,l)&&(r[l]=n[l]);return new Ws(r)}withLevel(n){return this.extend({level:n})}incrementLevel(){return this.extend({level:Math.min(this.level+1,3)})}inSubOrSup(){return this.extend({level:sl[this.level]})}withColor(n){return this.extend({color:n})}withFont(n){return this.extend({font:n})}withTextFontFamily(n){return this.extend({fontFamily:n,font:""})}withFontSize(n){return this.extend({fontSize:n})}withTextFontWeight(n){return this.extend({fontWeight:n,font:""})}withTextFontShape(n){return this.extend({fontShape:n,font:""})}getColor(){return this.color}}function Oo(e){let n={},r=0,l=document.getElementsByClassName("tml-eqn");for(let h of l)for(r+=1,h.setAttribute("id","tml-eqn-"+String(r));h.tagName!=="mtable";){if(h.getElementsByClassName("tml-label").length>0){let y=h.attributes.id.value;n[y]=String(r);break}h=h.parentElement}let u=document.getElementsByClassName("tml-tageqn");for(let h of u)if(h.getElementsByClassName("tml-label").length>0){let y=h.getElementsByClassName("tml-tag");if(y.length>0){let x=h.attributes.id.value;n[x]=y[0].textContent}}[...e.getElementsByClassName("tml-ref")].forEach(h=>{let y=h.getAttribute("href"),x=n[y.slice(1)];h.className.indexOf("tml-eqref")===-1?(x=x.replace(/^\(/,""),x=x.replace(/\)$/,"")):(x.charAt(0)!=="("&&(x="("+x),x.slice(-1)!==")"&&(x+=")"));let q=document.createElementNS("http://www.w3.org/1998/Math/MathML","mtext");q.appendChild(document.createTextNode(x));let Z=document.createElementNS("http://www.w3.org/1998/Math/MathML","math");Z.appendChild(q),h.textContent="",h.appendChild(Z)})}let ol=function(e,n,r){let l=r,u=0,h=e.length;for(;l<n.length;){let y=n[l];if(u<=0&&n.slice(l,l+h)===e)return l;y==="\\"?l++:y==="{"?u++:y==="}"&&u--,l++}return-1},il=/^\\(?:begin|(?:eq)?ref){/,Lo=[{left:"$$",right:"$$",display:!0},{left:"\\(",right:"\\)",display:!1},{left:"\\begin{equation}",right:"\\end{equation}",display:!0},{left:"\\begin{equation*}",right:"\\end{equation*}",display:!0},{left:"\\begin{align}",right:"\\end{align}",display:!0},{left:"\\begin{align*}",right:"\\end{align*}",display:!0},{left:"\\begin{alignat}",right:"\\end{alignat}",display:!0},{left:"\\begin{alignat*}",right:"\\end{alignat*}",display:!0},{left:"\\begin{gather}",right:"\\end{gather}",display:!0},{left:"\\begin{gather*}",right:"\\end{gather*}",display:!0},{left:"\\begin{CD}",right:"\\end{CD}",display:!0},{left:"\\ref{",right:"}",display:!1},{left:"\\eqref{",right:"}",display:!1},{left:"\\[",right:"\\]",display:!0}],ms={$:[{left:"$$",right:"$$",display:!0},{left:"$`",right:"`$",display:!1},{left:"$",right:"$",display:!1}],"(":[{left:"\\[",right:"\\]",display:!0},{left:"\\(",right:"\\)",display:!1}]},Vs=[{left:"\\begin{equation}",right:"\\end{equation}",display:!0},{left:"\\begin{equation*}",right:"\\end{equation*}",display:!0},{left:"\\begin{align}",right:"\\end{align}",display:!0},{left:"\\begin{align*}",right:"\\end{align*}",display:!0},{left:"\\begin{alignat}",right:"\\end{alignat}",display:!0},{left:"\\begin{alignat*}",right:"\\end{alignat*}",display:!0},{left:"\\begin{gather}",right:"\\end{gather}",display:!0},{left:"\\begin{gather*}",right:"\\end{gather*}",display:!0},{left:"\\begin{CD}",right:"\\end{CD}",display:!0},{left:"\\ref{",right:"}",display:!1},{left:"\\eqref{",right:"}",display:!1}],al=function(e,n){let r=function(u,h){let y,x=[],q=new RegExp("("+h.map(Z=>Z.left.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")+")");for(;y=u.search(q),y!==-1;){y>0&&(x.push({type:"text",data:u.slice(0,y)}),u=u.slice(y));let Z=h.findIndex(le=>u.startsWith(le.left));if(y=ol(h[Z].right,u,h[Z].left.length),y===-1)break;let ve=u.slice(0,y+h[Z].right.length),Te=il.test(ve)?ve:u.slice(h[Z].left.length,y);x.push({type:"math",data:Te,rawData:ve,display:h[Z].display}),u=u.slice(y+h[Z].right.length)}return u!==""&&x.push({type:"text",data:u}),x}(e,n.delimiters);if(r.length===1&&r[0].type==="text")return null;let l=document.createDocumentFragment();for(let u=0;u<r.length;u++)if(r[u].type==="text")l.appendChild(document.createTextNode(r[u].data));else{let h=document.createElement("span"),y=r[u].data;n.displayMode=r[u].display;try{n.preProcess&&(y=n.preProcess(y)),ri.render(y,h,n)}catch(x){if(!(x instanceof t))throw x;n.errorCallback("Temml auto-render: Failed to parse `"+r[u].data+"` with ",x),l.appendChild(document.createTextNode(r[u].rawData));continue}l.appendChild(h)}return l},Ro=function(e,n){for(let r=0;r<e.childNodes.length;r++){let l=e.childNodes[r];if(l.nodeType===3){let u=al(l.textContent,n);u&&(r+=u.childNodes.length-1,e.replaceChild(u,l))}else if(l.nodeType===1){let u=" "+l.className+" ";n.ignoredTags.indexOf(l.nodeName.toLowerCase())===-1&&n.ignoredClasses.every(h=>u.indexOf(" "+h+" ")===-1)&&Ro(l,n)}}},Io=function(e,n,r={}){n.textContent="";let l=n.tagName.toLowerCase()==="math";l&&(r.wrap="none");let u=Zs(e,r);l||u.children.length>1?(n.textContent="",u.children.forEach(h=>{n.appendChild(h.toNode())})):n.appendChild(u.toNode())};typeof document<"u"&&document.compatMode!=="CSS1Compat"&&(typeof console<"u"&&console.warn("Warning: Temml doesn't work in quirks mode. Make sure your website has a suitable doctype."),Io=function(){throw new t("Temml doesn't work in quirks mode.")});let Zs=function(e,n){let r=new P(n);try{let l=Mo(e,r);return It(l,e,new Ws({level:r.displayMode?Et:Tt,maxSize:r.maxSize}),r)}catch(l){return function(u,h,y){if(y.throwOnError||!(u instanceof t))throw u;let x=new je(["temml-error"],[new _e(h+`
98
98
 
99
- `+c.toString())]);return x.style.color=g.errorColor,x.style.whiteSpace="pre-line",x}(a,e,n)}};return{version:"0.13.3",render:js,renderToString:function(e,t){return Hr(e,t).toMarkup()},renderMathInElement:function(e,t){if(!e)throw new Error("No element provided to render");let n={};for(let a in t)Object.prototype.hasOwnProperty.call(t,a)&&(n[a]=t[a]);n.fences?n.delimiters=(a=>a==="$"||a==="("?ur[a]:a==="$+"||a==="(+"?ur[a.slice(0,1)].concat(Ur):a==="ams"?Ur:a==="all"?ur["("].concat(ur.$).concat(Ur):Hs)(n.fences):n.delimiters=n.delimiters||Hs,n.ignoredTags=n.ignoredTags||["script","noscript","style","textarea","pre","code","option"],n.ignoredClasses=n.ignoredClasses||[],n.errorCallback=n.errorCallback||console.error,n.macros=n.macros||{},Gs(e,n),Us(e)},postProcess:Us,ParseError:r,definePreamble:function(e,t){let n=new P(t);if(n.macros={},!(typeof e=="string"||e instanceof String))throw new TypeError("Temml can only parse string typed expression");let a=new Qn(e,n,!0);return delete a.gullet.macros.current["\\df@tag"],a.parse()},__parse:function(e,t){let n=new P(t);return zs(e,n)},__renderToMathMLTree:Hr,__defineSymbol:s,__defineMacro:I}}(),fo=mo;function Sl(r,i){return fo.renderToString(r,{displayMode:i,throwOnError:!1})}function Al(r,i){let l=i;for(;(l=r.indexOf("$$",l))!==-1;){if(r[l-1]!=="\\")return l;l+=1}return-1}function _l(r){let i=[],l="",d=()=>{l&&(i.push({type:"text",value:l}),l="")},u=0;for(;u<r.length;){let m=r[u];if(m==="\\"){let f=r[u+1];if(f==="$"){l+="$",u+=2;continue}if(f==="("){let h=r.indexOf("\\)",u+2);if(h!==-1){d(),i.push({type:"math",tex:r.slice(u+2,h),display:!1}),u=h+2;continue}}l+=f===void 0?m:m+f,u+=f===void 0?1:2;continue}if(m==="$"&&r[u+1]==="$"){let f=Al(r,u+2);if(f!==-1){d(),i.push({type:"math",tex:r.slice(u+2,f),display:!0}),u=f+2;continue}}l+=m,u+=1}return d(),i}var Tl="code, pre, script, style, svg, aside, math";function Cl(r){let i=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,{acceptNode:d=>d.parentElement&&d.parentElement.closest(Tl)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}),l=[];for(let d=i.nextNode();d;d=i.nextNode())(d.nodeValue.includes("$")||d.nodeValue.includes("\\("))&&l.push(d);for(let d of l){let u=_l(d.nodeValue);if(u.length===1&&u[0].type==="text"&&u[0].value===d.nodeValue)continue;let m=document.createDocumentFragment();for(let f of u)if(f.type==="text")m.appendChild(document.createTextNode(f.value));else{let h=document.createElement("span");h.innerHTML=Sl(f.tex,f.display),m.appendChild(h.firstElementChild??document.createTextNode(""))}d.parentNode.replaceChild(m,d)}}function go(r){r.querySelectorAll("section[data-math]").forEach(i=>Cl(i))}le();ce();le();ce();var Po=Ya(Bo(),1);var Nt=Po.default;le();ce();function Do(r){let i=r.regex,l=r.COMMENT("--","$"),d={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},u={begin:/"/,end:/"/,contains:[{match:/""/}]},m=["true","false","unknown"],f=["double precision","large object","with timezone","without timezone"],h=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],b=["add","asc","collation","desc","final","first","last","view"],k=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],A=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],P=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],M=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],T=A,C=[...k,...b].filter(Oe=>!A.includes(Oe)),F={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},ye={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},ge={match:i.concat(/\b/,i.either(...T),/\s*\(/),relevance:0,keywords:{built_in:T}};function be(Oe){return i.concat(/\b/,i.either(...Oe.map(ke=>ke.replace(/\s+/,"\\s+"))),/\b/)}let J={scope:"keyword",match:be(M),relevance:0};function de(Oe,{exceptions:ke,when:De}={}){let xe=De;return ke=ke||[],Oe.map(Le=>Le.match(/\|\d+$/)||ke.includes(Le)?Le:xe(Le)?`${Le}|0`:Le)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:de(C,{when:Oe=>Oe.length<3}),literal:m,type:h,built_in:P},contains:[{scope:"type",match:be(f)},J,ge,F,d,u,r.C_NUMBER_MODE,r.C_BLOCK_COMMENT_MODE,l,ye]}}le();ce();var qo="[A-Za-z$_][0-9A-Za-z$_]*",yc=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],wc=["true","false","null","undefined","NaN","Infinity"],Fo=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],zo=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Uo=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],xc=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],vc=[].concat(Uo,Fo,zo);function Ho(r){let i=r.regex,l=(V,{after:re})=>{let Ae="</"+V[0].slice(1);return V.input.indexOf(Ae,re)!==-1},d=qo,u={begin:"<>",end:"</>"},m=/<[A-Za-z0-9\\._:-]+\s*\/>/,f={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(V,re)=>{let Ae=V[0].length+V.index,Ke=V.input[Ae];if(Ke==="<"||Ke===","){re.ignoreMatch();return}Ke===">"&&(l(V,{after:Ae})||re.ignoreMatch());let Ce,s=V.input.substring(Ae);if(Ce=s.match(/^\s*=/)){re.ignoreMatch();return}if((Ce=s.match(/^\s+extends\s+/))&&Ce.index===0){re.ignoreMatch();return}}},h={$pattern:qo,keyword:yc,literal:wc,built_in:vc,"variable.language":xc},b="[0-9](_?[0-9])*",k=`\\.(${b})`,A="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",P={className:"number",variants:[{begin:`(\\b(${A})((${k})|\\.)?|(${k}))[eE][+-]?(${b})\\b`},{begin:`\\b(${A})\\b((${k})\\b|\\.)?|(${k})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},M={className:"subst",begin:"\\$\\{",end:"\\}",keywords:h,contains:[]},T={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[r.BACKSLASH_ESCAPE,M],subLanguage:"xml"}},C={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[r.BACKSLASH_ESCAPE,M],subLanguage:"css"}},F={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[r.BACKSLASH_ESCAPE,M],subLanguage:"graphql"}},ye={className:"string",begin:"`",end:"`",contains:[r.BACKSLASH_ESCAPE,M]},be={className:"comment",variants:[r.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:d+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),r.C_BLOCK_COMMENT_MODE,r.C_LINE_COMMENT_MODE]},J=[r.APOS_STRING_MODE,r.QUOTE_STRING_MODE,T,C,F,ye,{match:/\$\d+/},P];M.contains=J.concat({begin:/\{/,end:/\}/,keywords:h,contains:["self"].concat(J)});let de=[].concat(be,M.contains),Oe=de.concat([{begin:/(\s*)\(/,end:/\)/,keywords:h,contains:["self"].concat(de)}]),ke={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:h,contains:Oe},De={variants:[{match:[/class/,/\s+/,d,/\s+/,/extends/,/\s+/,i.concat(d,"(",i.concat(/\./,d),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,d],scope:{1:"keyword",3:"title.class"}}]},xe={relevance:0,match:i.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...Fo,...zo]}},Le={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},st={variants:[{match:[/function/,/\s+/,d,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[ke],illegal:/%/},at={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function _(V){return i.concat("(?!",V.join("|"),")")}let qe={match:i.concat(/\b/,_([...Uo,"super","import"].map(V=>`${V}\\s*\\(`)),d,i.lookahead(/\s*\(/)),className:"title.function",relevance:0},Je={begin:i.concat(/\./,i.lookahead(i.concat(d,/(?![0-9A-Za-z$_(])/))),end:d,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},je={match:[/get|set/,/\s+/,d,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},ke]},O="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+r.UNDERSCORE_IDENT_RE+")\\s*=>",D={match:[/const|var|let/,/\s+/,d,/\s*/,/=\s*/,/(async\s*)?/,i.lookahead(O)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[ke]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:h,exports:{PARAMS_CONTAINS:Oe,CLASS_REFERENCE:xe},illegal:/#(?![$_A-z])/,contains:[r.SHEBANG({label:"shebang",binary:"node",relevance:5}),Le,r.APOS_STRING_MODE,r.QUOTE_STRING_MODE,T,C,F,ye,be,{match:/\$\d+/},P,xe,{scope:"attr",match:d+i.lookahead(":"),relevance:0},D,{begin:"("+r.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[be,r.REGEXP_MODE,{className:"function",begin:O,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:r.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:h,contains:Oe}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:u.begin,end:u.end},{match:m},{begin:f.begin,"on:begin":f.isTrulyOpeningTag,end:f.end}],subLanguage:"xml",contains:[{begin:f.begin,end:f.end,skip:!0,contains:["self"]}]}]},st,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+r.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[ke,r.inherit(r.TITLE_MODE,{begin:d,className:"title.function"})]},{match:/\.\.\./,relevance:0},Je,{match:"\\$"+d,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[ke]},qe,at,De,je,{match:/\$[(.]/}]}}le();ce();var xr="[A-Za-z$_][0-9A-Za-z$_]*",Go=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],jo=["true","false","null","undefined","NaN","Infinity"],Ko=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],Wo=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Vo=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Zo=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],Xo=[].concat(Vo,Ko,Wo);function kc(r){let i=r.regex,l=(V,{after:re})=>{let Ae="</"+V[0].slice(1);return V.input.indexOf(Ae,re)!==-1},d=xr,u={begin:"<>",end:"</>"},m=/<[A-Za-z0-9\\._:-]+\s*\/>/,f={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(V,re)=>{let Ae=V[0].length+V.index,Ke=V.input[Ae];if(Ke==="<"||Ke===","){re.ignoreMatch();return}Ke===">"&&(l(V,{after:Ae})||re.ignoreMatch());let Ce,s=V.input.substring(Ae);if(Ce=s.match(/^\s*=/)){re.ignoreMatch();return}if((Ce=s.match(/^\s+extends\s+/))&&Ce.index===0){re.ignoreMatch();return}}},h={$pattern:xr,keyword:Go,literal:jo,built_in:Xo,"variable.language":Zo},b="[0-9](_?[0-9])*",k=`\\.(${b})`,A="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",P={className:"number",variants:[{begin:`(\\b(${A})((${k})|\\.)?|(${k}))[eE][+-]?(${b})\\b`},{begin:`\\b(${A})\\b((${k})\\b|\\.)?|(${k})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},M={className:"subst",begin:"\\$\\{",end:"\\}",keywords:h,contains:[]},T={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[r.BACKSLASH_ESCAPE,M],subLanguage:"xml"}},C={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[r.BACKSLASH_ESCAPE,M],subLanguage:"css"}},F={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[r.BACKSLASH_ESCAPE,M],subLanguage:"graphql"}},ye={className:"string",begin:"`",end:"`",contains:[r.BACKSLASH_ESCAPE,M]},be={className:"comment",variants:[r.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:d+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),r.C_BLOCK_COMMENT_MODE,r.C_LINE_COMMENT_MODE]},J=[r.APOS_STRING_MODE,r.QUOTE_STRING_MODE,T,C,F,ye,{match:/\$\d+/},P];M.contains=J.concat({begin:/\{/,end:/\}/,keywords:h,contains:["self"].concat(J)});let de=[].concat(be,M.contains),Oe=de.concat([{begin:/(\s*)\(/,end:/\)/,keywords:h,contains:["self"].concat(de)}]),ke={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:h,contains:Oe},De={variants:[{match:[/class/,/\s+/,d,/\s+/,/extends/,/\s+/,i.concat(d,"(",i.concat(/\./,d),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,d],scope:{1:"keyword",3:"title.class"}}]},xe={relevance:0,match:i.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...Ko,...Wo]}},Le={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},st={variants:[{match:[/function/,/\s+/,d,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[ke],illegal:/%/},at={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function _(V){return i.concat("(?!",V.join("|"),")")}let qe={match:i.concat(/\b/,_([...Vo,"super","import"].map(V=>`${V}\\s*\\(`)),d,i.lookahead(/\s*\(/)),className:"title.function",relevance:0},Je={begin:i.concat(/\./,i.lookahead(i.concat(d,/(?![0-9A-Za-z$_(])/))),end:d,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},je={match:[/get|set/,/\s+/,d,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},ke]},O="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+r.UNDERSCORE_IDENT_RE+")\\s*=>",D={match:[/const|var|let/,/\s+/,d,/\s*/,/=\s*/,/(async\s*)?/,i.lookahead(O)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[ke]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:h,exports:{PARAMS_CONTAINS:Oe,CLASS_REFERENCE:xe},illegal:/#(?![$_A-z])/,contains:[r.SHEBANG({label:"shebang",binary:"node",relevance:5}),Le,r.APOS_STRING_MODE,r.QUOTE_STRING_MODE,T,C,F,ye,be,{match:/\$\d+/},P,xe,{scope:"attr",match:d+i.lookahead(":"),relevance:0},D,{begin:"("+r.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[be,r.REGEXP_MODE,{className:"function",begin:O,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:r.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:h,contains:Oe}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:u.begin,end:u.end},{match:m},{begin:f.begin,"on:begin":f.isTrulyOpeningTag,end:f.end}],subLanguage:"xml",contains:[{begin:f.begin,end:f.end,skip:!0,contains:["self"]}]}]},st,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+r.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[ke,r.inherit(r.TITLE_MODE,{begin:d,className:"title.function"})]},{match:/\.\.\./,relevance:0},Je,{match:"\\$"+d,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[ke]},qe,at,De,je,{match:/\$[(.]/}]}}function Yo(r){let i=r.regex,l=kc(r),d=xr,u=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],m={begin:[/namespace/,/\s+/,r.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},f={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:u},contains:[l.exports.CLASS_REFERENCE]},h={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},b=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],k={$pattern:xr,keyword:Go.concat(b),literal:jo,built_in:Xo.concat(u),"variable.language":Zo},A={className:"meta",begin:"@"+d},P=(F,ye,ge)=>{let be=F.contains.findIndex(J=>J.label===ye);if(be===-1)throw new Error("can not find mode to replace");F.contains.splice(be,1,ge)};Object.assign(l.keywords,k),l.exports.PARAMS_CONTAINS.push(A);let M=l.contains.find(F=>F.scope==="attr"),T=Object.assign({},M,{match:i.concat(d,i.lookahead(/\s*\?:/))});l.exports.PARAMS_CONTAINS.push([l.exports.CLASS_REFERENCE,M,T]),l.contains=l.contains.concat([A,m,f,T]),P(l,"shebang",r.SHEBANG()),P(l,"use_strict",h);let C=l.contains.find(F=>F.label==="func.def");return C.relevance=0,Object.assign(l,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),l}le();ce();function Jo(r){let i=r.regex,l=/[\p{XID_Start}_]\p{XID_Continue}*/u,d=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],h={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:d,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},b={className:"meta",begin:/^(>>>|\.\.\.) /},k={className:"subst",begin:/\{/,end:/\}/,keywords:h,illegal:/#/},A={begin:/\{\{/,relevance:0},P={className:"string",contains:[r.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[r.BACKSLASH_ESCAPE,b],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[r.BACKSLASH_ESCAPE,b],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[r.BACKSLASH_ESCAPE,b,A,k]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[r.BACKSLASH_ESCAPE,b,A,k]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[r.BACKSLASH_ESCAPE,A,k]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[r.BACKSLASH_ESCAPE,A,k]},r.APOS_STRING_MODE,r.QUOTE_STRING_MODE]},M="[0-9](_?[0-9])*",T=`(\\b(${M}))?\\.(${M})|\\b(${M})\\.`,C=`\\b|${d.join("|")}`,F={className:"number",relevance:0,variants:[{begin:`(\\b(${M})|(${T}))[eE][+-]?(${M})[jJ]?(?=${C})`},{begin:`(${T})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${C})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${C})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${C})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${C})`},{begin:`\\b(${M})[jJ](?=${C})`}]},ye={className:"comment",begin:i.lookahead(/# type:/),end:/$/,keywords:h,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},ge={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:h,contains:["self",b,F,P,r.HASH_COMMENT_MODE]}]};return k.contains=[P,F,b],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:h,illegal:/(<\/|\?)|=>/,contains:[b,F,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},P,ye,r.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,l],scope:{1:"keyword",3:"title.function"},contains:[ge]},{variants:[{match:[/\bclass/,/\s+/,l,/\s*/,/\(\s*/,l,/\s*\)/]},{match:[/\bclass/,/\s+/,l]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[F,ge,P]}]}}le();ce();function Qo(r){let i=r.regex,l={},d={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[l]}]};Object.assign(l,{className:"variable",variants:[{begin:i.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},d]});let u={className:"subst",begin:/\$\(/,end:/\)/,contains:[r.BACKSLASH_ESCAPE]},m=r.inherit(r.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),f={begin:/<<-?\s*(?=\w+)/,starts:{contains:[r.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},h={className:"string",begin:/"/,end:/"/,contains:[r.BACKSLASH_ESCAPE,l,u]};u.contains.push(h);let b={match:/\\"/},k={className:"string",begin:/'/,end:/'/},A={match:/\\'/},P={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},r.NUMBER_MODE,l]},M=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],T=r.SHEBANG({binary:`(${M.join("|")})`,relevance:10}),C={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[r.inherit(r.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},F=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],ye=["true","false"],ge={match:/(\/[a-z._-]+)+/},be=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],J=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],de=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],Oe=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:F,literal:ye,built_in:[...be,...J,"set","shopt",...de,...Oe]},contains:[T,r.SHEBANG(),C,P,m,f,ge,h,b,k,A,l]}}le();ce();function ei(r){let i="true false yes no null",l="[\\w#;/?:@&=+$,.~*'()[\\]]+",d={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},u={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},m={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},f={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[r.BACKSLASH_ESCAPE,u]},h=r.inherit(f,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),M={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},T={end:",",endsWithParent:!0,excludeEnd:!0,keywords:i,relevance:0},C={begin:/\{/,end:/\}/,contains:[T],illegal:"\\n",relevance:0},F={begin:"\\[",end:"\\]",contains:[T],illegal:"\\n",relevance:0},ye=[d,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+l},{className:"type",begin:"!<"+l+">"},{className:"type",begin:"!"+l},{className:"type",begin:"!!"+l},{className:"meta",begin:"&"+r.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+r.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},r.HASH_COMMENT_MODE,{beginKeywords:i,keywords:{literal:i}},M,{className:"number",begin:r.C_NUMBER_RE+"\\b",relevance:0},C,F,m,f],ge=[...ye];return ge.pop(),ge.push(h),T.contains=ge,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:ye}}le();ce();function ti(r){let i={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},l={match:/[{}[\],:]/,className:"punctuation",relevance:0},d=["true","false","null"],u={scope:"literal",beginKeywords:d.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:d},contains:[i,l,r.QUOTE_STRING_MODE,u,r.C_NUMBER_MODE,r.C_LINE_COMMENT_MODE,r.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}le();ce();var Gn="[0-9](_*[0-9])*",vr=`\\.(${Gn})`,kr="[0-9a-fA-F](_*[0-9a-fA-F])*",ni={className:"number",variants:[{begin:`(\\b(${Gn})((${vr})|\\.)?|(${vr}))[eE][+-]?(${Gn})[fFdD]?\\b`},{begin:`\\b(${Gn})((${vr})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${vr})[fFdD]?\\b`},{begin:`\\b(${Gn})[fFdD]\\b`},{begin:`\\b0[xX]((${kr})\\.?|(${kr})?\\.(${kr}))[pP][+-]?(${Gn})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${kr})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function ri(r,i,l){return l===-1?"":r.replace(i,d=>ri(r,i,l-1))}function si(r){let i=r.regex,l="[\xC0-\u02B8a-zA-Z_$][\xC0-\u02B8a-zA-Z_$0-9]*",d=l+ri("(?:<"+l+"~~~(?:\\s*,\\s*"+l+"~~~)*>)?",/~~~/g,2),b={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},k={className:"meta",begin:"@"+l,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},A={className:"params",begin:/\(/,end:/\)/,keywords:b,relevance:0,contains:[r.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:b,illegal:/<\/|#/,contains:[r.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},r.C_LINE_COMMENT_MODE,r.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[r.BACKSLASH_ESCAPE]},r.APOS_STRING_MODE,r.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,l],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[i.concat(/(?!else)/,l),/\s+/,l,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,l],className:{1:"keyword",3:"title.class"},contains:[A,r.C_LINE_COMMENT_MODE,r.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+d+"\\s+)",r.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:b,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:b,relevance:0,contains:[k,r.APOS_STRING_MODE,r.QUOTE_STRING_MODE,ni,r.C_BLOCK_COMMENT_MODE]},r.C_LINE_COMMENT_MODE,r.C_BLOCK_COMMENT_MODE]},ni,k]}}le();ce();function oi(r){let m={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:m,illegal:"</",contains:[r.C_LINE_COMMENT_MODE,r.C_BLOCK_COMMENT_MODE,{className:"string",variants:[r.QUOTE_STRING_MODE,r.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:"number",variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[r.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:m,illegal:/["']/}]}]}}le();ce();function ii(r){let i=r.regex,l=/(r#)?/,d=i.concat(l,r.UNDERSCORE_IDENT_RE),u=i.concat(l,r.IDENT_RE),m={className:"title.function.invoke",relevance:0,begin:i.concat(/\b/,/(?!let|for|while|if|else|match\b)/,u,i.lookahead(/\s*\(/))},f="([ui](8|16|32|64|128|size)|f(32|64))?",h=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],b=["true","false","Some","None","Ok","Err"],k=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],A=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:r.IDENT_RE+"!?",type:A,keyword:h,literal:b,built_in:k},illegal:"</",contains:[r.C_LINE_COMMENT_MODE,r.COMMENT("/\\*","\\*/",{contains:["self"]}),r.inherit(r.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"number",variants:[{begin:"\\b0b([01_]+)"+f},{begin:"\\b0o([0-7_]+)"+f},{begin:"\\b0x([A-Fa-f0-9_]+)"+f},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+f}],relevance:0},{begin:[/fn/,/\s+/,d],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[r.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,d],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,d,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,d],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,d],className:{1:"keyword",3:"title.class"}},{begin:r.IDENT_RE+"::",keywords:{keyword:"Self",built_in:k,type:A}},{className:"punctuation",begin:"->"},m]}}le();ce();function ai(r){let i=r.regex,l=i.concat(/[\p{L}_]/u,i.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),d=/[\p{L}0-9._:-]+/u,u={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},m={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},f=r.inherit(m,{begin:/\(/,end:/\)/}),h=r.inherit(r.APOS_STRING_MODE,{className:"string"}),b=r.inherit(r.QUOTE_STRING_MODE,{className:"string"}),k={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:d,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[u]},{begin:/'/,end:/'/,contains:[u]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[m,b,h,f,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[m,f,b,h]}]}]},r.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},u,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[b]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[k],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[k],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:i.concat(/</,i.lookahead(i.concat(l,i.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:l,relevance:0,starts:k}]},{className:"tag",begin:i.concat(/<\//,i.lookahead(i.concat(l,/>/))),contains:[{className:"name",begin:l,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}le();ce();var Ec=r=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:r.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[r.APOS_STRING_MODE,r.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:r.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),Sc=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],Ac=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],_c=[...Sc,...Ac],Tc=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),Cc=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),Nc=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),$c=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function li(r){let i=r.regex,l=Ec(r),d={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},u="and or not only",m=/@-?\w[\w]*(-\w+)*/,f="[a-zA-Z-][a-zA-Z0-9_-]*",h=[r.APOS_STRING_MODE,r.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[l.BLOCK_COMMENT,d,l.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+f,relevance:0},l.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+Cc.join("|")+")"},{begin:":(:)?("+Nc.join("|")+")"}]},l.CSS_VARIABLE,{className:"attribute",begin:"\\b("+$c.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[l.BLOCK_COMMENT,l.HEXCOLOR,l.IMPORTANT,l.CSS_NUMBER_MODE,...h,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...h,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},l.FUNCTION_DISPATCH]},{begin:i.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:m},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:u,attribute:Tc.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...h,l.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+_c.join("|")+")\\b"}]}}le();ce();function ci(r){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}Nt.registerLanguage("sql",Do);Nt.registerLanguage("javascript",Ho);Nt.registerLanguage("typescript",Yo);Nt.registerLanguage("python",Jo);Nt.registerLanguage("bash",Qo);Nt.registerLanguage("yaml",ei);Nt.registerLanguage("json",ti);Nt.registerLanguage("java",si);Nt.registerLanguage("go",oi);Nt.registerLanguage("rust",ii);Nt.registerLanguage("xml",ai);Nt.registerLanguage("css",li);Nt.registerLanguage("plaintext",ci);Nt.registerAliases(["js"],{languageName:"javascript"});Nt.registerAliases(["ts"],{languageName:"typescript"});Nt.registerAliases(["shell","sh","zsh"],{languageName:"bash"});Nt.registerAliases(["html"],{languageName:"xml"});Nt.registerAliases(["text","plain"],{languageName:"plaintext"});function Oc(r,i){return r.split("|").map(l=>{if(l=l.trim(),l===""||l==="all")return Array.from({length:i},(u,m)=>m+1);let d=[];for(let u of l.split(",")){let m=u.trim().match(/^(\d+)(?:-(\d+))?$/);if(!m)continue;let f=parseInt(m[1],10),h=m[2]?parseInt(m[2],10):f;for(let b=f;b<=Math.min(h,i);b++)d.push(b)}return d})}function Mc(r){let i=[[]];for(function l(d,u){for(let m of d.childNodes)m.nodeType===Node.TEXT_NODE?m.nodeValue.split(`
100
- `).forEach((h,b)=>{b>0&&i.push([]),h&&i[i.length-1].push({path:u,text:h})}):m.nodeType===Node.ELEMENT_NODE&&l(m,[...u,m])}(r,[]);i.length&&i[i.length-1].length===0;)i.pop();r.textContent="";for(let l of i){let d=document.createElement("span");d.className="code-line";for(let{path:u,text:m}of l){let f=d;for(let h of u){let b=f.lastChild;b&&b.__orig===h||(b=h.cloneNode(!1),b.__orig=h,f.appendChild(b)),f=b}f.appendChild(document.createTextNode(m))}r.appendChild(d)}return r.querySelectorAll(":scope > .code-line")}function Lc(r,i){if(r.length===i)return"all lines";let l=[...r],d=[],u=l[0],m=l[0];for(let f of l.slice(1)){if(f===m+1){m=f;continue}d.push(u===m?`${u}`:`${u}-${m}`),u=m=f}return d.push(u===m?`${u}`:`${u}-${m}`),`lines ${d.join(",")}`}function di(r,i){r.querySelectorAll("pre > code").forEach(l=>{let d=[...l.classList].find(A=>A.startsWith("language-")),u=d?d.slice(9):null,m=l.textContent.replace(/^\n/,"").replace(/\s+$/,"");u&&Nt.getLanguage(u)?l.innerHTML=Nt.highlight(m,{language:u}).value:l.textContent=m,l.classList.add("hljs");let f=l.parentElement,h=Mc(l);f.hasAttribute("data-lines-numbers")&&f.classList.add("line-numbers");let b=f.getAttribute("data-lines");if(!b)return;let k=Oc(b,h.length);f.classList.add("stepping"),i(f,{count:k.length,label:A=>A===0?"code":Lc(k[A-1],h.length),apply(A){if(h.forEach(T=>T.classList.remove("line-hl","line-dim")),A===0)return;let P=new Set(k[A-1]),M=P.size===h.length;h.forEach((T,C)=>{P.has(C+1)?T.classList.add("line-hl"):M||T.classList.add("line-dim")})}})})}le();ce();var Rc=/⟨CLICK⟩|&lt;CLICK&gt;|<click(?:\s[^>]*)?>(?:<\/click>)?/gi;function ui(r){return(r||"").split(Rc)}function ts(r){let i="width=1100,height=700",l=window.open("","decklight-speaker",i);if(!l)return null;let d=!1;try{d=l.document.body?l.document.body.childNodes.length>0:!1}catch{d=!0}if(d){try{l.close()}catch{}if(l=window.open("","decklight-speaker",i),!l)return null;try{l.document}catch{return null}}let u=()=>{let f=new URL(location.href);return f.searchParams.set("embedded",""),f.hash="",f.href};window.__decklightBridge={subscribe(f){r.__speakerCb=f},getState:()=>pi(r,u()),next:()=>r.next(),prev:()=>r.prev()},r.__notifySpeaker=()=>{r.__speakerCb&&!l.closed&&r.__speakerCb(pi(r,u()))};let m=`${r.config.width} / ${r.config.height}`;return l.document.write(`<!doctype html><html><head><meta charset="utf-8">
99
+ `+u.toString())]);return x.style.color=y.errorColor,x.style.whiteSpace="pre-line",x}(l,e,r)}};return{version:"0.13.3",render:Io,renderToString:function(e,n){return Zs(e,n).toMarkup()},renderMathInElement:function(e,n){if(!e)throw new Error("No element provided to render");let r={};for(let l in n)Object.prototype.hasOwnProperty.call(n,l)&&(r[l]=n[l]);r.fences?r.delimiters=(l=>l==="$"||l==="("?ms[l]:l==="$+"||l==="(+"?ms[l.slice(0,1)].concat(Vs):l==="ams"?Vs:l==="all"?ms["("].concat(ms.$).concat(Vs):Lo)(r.fences):r.delimiters=r.delimiters||Lo,r.ignoredTags=r.ignoredTags||["script","noscript","style","textarea","pre","code","option"],r.ignoredClasses=r.ignoredClasses||[],r.errorCallback=r.errorCallback||console.error,r.macros=r.macros||{},Ro(e,r),Oo(e)},postProcess:Oo,ParseError:t,definePreamble:function(e,n){let r=new P(n);if(r.macros={},!(typeof e=="string"||e instanceof String))throw new TypeError("Temml can only parse string typed expression");let l=new Kr(e,r,!0);return delete l.gullet.macros.current["\\df@tag"],l.parse()},__parse:function(e,n){let r=new P(n);return Mo(e,r)},__renderToMathMLTree:Zs,__defineSymbol:s,__defineMacro:L}}(),si=ri;function Ul(t,o){return si.renderToString(t,{displayMode:o,throwOnError:!1})}function Hl(t,o){let a=o;for(;(a=t.indexOf("$$",a))!==-1;){if(t[a-1]!=="\\")return a;a+=1}return-1}function jl(t){let o=[],a="",c=()=>{a&&(o.push({type:"text",value:a}),a="")},d=0;for(;d<t.length;){let p=t[d];if(p==="\\"){let g=t[d+1];if(g==="$"){a+="$",d+=2;continue}if(g==="("){let m=t.indexOf("\\)",d+2);if(m!==-1){c(),o.push({type:"math",tex:t.slice(d+2,m),display:!1}),d=m+2;continue}}a+=g===void 0?p:p+g,d+=g===void 0?1:2;continue}if(p==="$"&&t[d+1]==="$"){let g=Hl(t,d+2);if(g!==-1){c(),o.push({type:"math",tex:t.slice(d+2,g),display:!0}),d=g+2;continue}}a+=p,d+=1}return c(),o}var Gl="code, pre, script, style, svg, aside, math";function Kl(t){let o=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,{acceptNode:c=>c.parentElement&&c.parentElement.closest(Gl)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}),a=[];for(let c=o.nextNode();c;c=o.nextNode())(c.nodeValue.includes("$")||c.nodeValue.includes("\\("))&&a.push(c);for(let c of a){let d=jl(c.nodeValue);if(d.length===1&&d[0].type==="text"&&d[0].value===c.nodeValue)continue;let p=document.createDocumentFragment();for(let g of d)if(g.type==="text")p.appendChild(document.createTextNode(g.value));else{let m=document.createElement("span");m.innerHTML=Ul(g.tex,g.display),p.appendChild(m.firstElementChild??document.createTextNode(""))}c.parentNode.replaceChild(p,c)}}function oi(t){t.querySelectorAll("section[data-math]").forEach(o=>Kl(o))}ge();be();ge();be();var _i=fl(Ai(),1);var Gt=_i.default;ge();be();function Ti(t){let o=t.regex,a=t.COMMENT("--","$"),c={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},d={begin:/"/,end:/"/,contains:[{match:/""/}]},p=["true","false","unknown"],g=["double precision","large object","with timezone","without timezone"],m=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],w=["add","asc","collation","desc","final","first","last","view"],E=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],S=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],P=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],$=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],_=S,C=[...E,...w].filter(Re=>!S.includes(Re)),I={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},Se={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},de={match:o.concat(/\b/,o.either(..._),/\s*\(/),relevance:0,keywords:{built_in:_}};function $e(Re){return o.concat(/\b/,o.either(...Re.map(Fe=>Fe.replace(/\s+/,"\\s+"))),/\b/)}let te={scope:"keyword",match:$e($),relevance:0};function ae(Re,{exceptions:Fe,when:je}={}){let _e=je;return Fe=Fe||[],Re.map(Ae=>Ae.match(/\|\d+$/)||Fe.includes(Ae)?Ae:_e(Ae)?`${Ae}|0`:Ae)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:ae(C,{when:Re=>Re.length<3}),literal:p,type:m,built_in:P},contains:[{scope:"type",match:$e(g)},te,de,I,c,d,t.C_NUMBER_MODE,t.C_BLOCK_COMMENT_MODE,a,Se]}}ge();be();var $i="[A-Za-z$_][0-9A-Za-z$_]*",Pc=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],Bc=["true","false","null","undefined","NaN","Infinity"],Ci=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],Ni=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Mi=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Dc=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],qc=[].concat(Mi,Ci,Ni);function Oi(t){let o=t.regex,a=(ne,{after:fe})=>{let ue="</"+ne[0].slice(1);return ne.input.indexOf(ue,fe)!==-1},c=$i,d={begin:"<>",end:"</>"},p=/<[A-Za-z0-9\\._:-]+\s*\/>/,g={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(ne,fe)=>{let ue=ne[0].length+ne.index,Ie=ne.input[ue];if(Ie==="<"||Ie===","){fe.ignoreMatch();return}Ie===">"&&(a(ne,{after:ue})||fe.ignoreMatch());let Q,s=ne.input.substring(ue);if(Q=s.match(/^\s*=/)){fe.ignoreMatch();return}if((Q=s.match(/^\s+extends\s+/))&&Q.index===0){fe.ignoreMatch();return}}},m={$pattern:$i,keyword:Pc,literal:Bc,built_in:qc,"variable.language":Dc},w="[0-9](_?[0-9])*",E=`\\.(${w})`,S="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",P={className:"number",variants:[{begin:`(\\b(${S})((${E})|\\.)?|(${E}))[eE][+-]?(${w})\\b`},{begin:`\\b(${S})\\b((${E})\\b|\\.)?|(${E})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},$={className:"subst",begin:"\\$\\{",end:"\\}",keywords:m,contains:[]},_={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,$],subLanguage:"xml"}},C={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,$],subLanguage:"css"}},I={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,$],subLanguage:"graphql"}},Se={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,$]},$e={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:c+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},te=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,_,C,I,Se,{match:/\$\d+/},P];$.contains=te.concat({begin:/\{/,end:/\}/,keywords:m,contains:["self"].concat(te)});let ae=[].concat($e,$.contains),Re=ae.concat([{begin:/(\s*)\(/,end:/\)/,keywords:m,contains:["self"].concat(ae)}]),Fe={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:m,contains:Re},je={variants:[{match:[/class/,/\s+/,c,/\s+/,/extends/,/\s+/,o.concat(c,"(",o.concat(/\./,c),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,c],scope:{1:"keyword",3:"title.class"}}]},_e={relevance:0,match:o.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...Ci,...Ni]}},Ae={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},st={variants:[{match:[/function/,/\s+/,c,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[Fe],illegal:/%/},bt={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function T(ne){return o.concat("(?!",ne.join("|"),")")}let Ke={match:o.concat(/\b/,T([...Mi,"super","import"].map(ne=>`${ne}\\s*\\(`)),c,o.lookahead(/\s*\(/)),className:"title.function",relevance:0},mt={begin:o.concat(/\./,o.lookahead(o.concat(c,/(?![0-9A-Za-z$_(])/))),end:c,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},dt={match:[/get|set/,/\s+/,c,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},Fe]},G="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",J={match:[/const|var|let/,/\s+/,c,/\s*/,/=\s*/,/(async\s*)?/,o.lookahead(G)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[Fe]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:m,exports:{PARAMS_CONTAINS:Re,CLASS_REFERENCE:_e},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),Ae,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,_,C,I,Se,$e,{match:/\$\d+/},P,_e,{scope:"attr",match:c+o.lookahead(":"),relevance:0},J,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[$e,t.REGEXP_MODE,{className:"function",begin:G,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:m,contains:Re}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:d.begin,end:d.end},{match:p},{begin:g.begin,"on:begin":g.isTrulyOpeningTag,end:g.end}],subLanguage:"xml",contains:[{begin:g.begin,end:g.end,skip:!0,contains:["self"]}]}]},st,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[Fe,t.inherit(t.TITLE_MODE,{begin:c,className:"title.function"})]},{match:/\.\.\./,relevance:0},mt,{match:"\\$"+c,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[Fe]},Ke,bt,je,dt,{match:/\$[(.]/}]}}ge();be();var Es="[A-Za-z$_][0-9A-Za-z$_]*",Li=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],Ri=["true","false","null","undefined","NaN","Infinity"],Ii=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],Pi=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Bi=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Di=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],qi=[].concat(Bi,Ii,Pi);function Fc(t){let o=t.regex,a=(ne,{after:fe})=>{let ue="</"+ne[0].slice(1);return ne.input.indexOf(ue,fe)!==-1},c=Es,d={begin:"<>",end:"</>"},p=/<[A-Za-z0-9\\._:-]+\s*\/>/,g={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(ne,fe)=>{let ue=ne[0].length+ne.index,Ie=ne.input[ue];if(Ie==="<"||Ie===","){fe.ignoreMatch();return}Ie===">"&&(a(ne,{after:ue})||fe.ignoreMatch());let Q,s=ne.input.substring(ue);if(Q=s.match(/^\s*=/)){fe.ignoreMatch();return}if((Q=s.match(/^\s+extends\s+/))&&Q.index===0){fe.ignoreMatch();return}}},m={$pattern:Es,keyword:Li,literal:Ri,built_in:qi,"variable.language":Di},w="[0-9](_?[0-9])*",E=`\\.(${w})`,S="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",P={className:"number",variants:[{begin:`(\\b(${S})((${E})|\\.)?|(${E}))[eE][+-]?(${w})\\b`},{begin:`\\b(${S})\\b((${E})\\b|\\.)?|(${E})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},$={className:"subst",begin:"\\$\\{",end:"\\}",keywords:m,contains:[]},_={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,$],subLanguage:"xml"}},C={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,$],subLanguage:"css"}},I={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,$],subLanguage:"graphql"}},Se={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,$]},$e={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:c+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},te=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,_,C,I,Se,{match:/\$\d+/},P];$.contains=te.concat({begin:/\{/,end:/\}/,keywords:m,contains:["self"].concat(te)});let ae=[].concat($e,$.contains),Re=ae.concat([{begin:/(\s*)\(/,end:/\)/,keywords:m,contains:["self"].concat(ae)}]),Fe={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:m,contains:Re},je={variants:[{match:[/class/,/\s+/,c,/\s+/,/extends/,/\s+/,o.concat(c,"(",o.concat(/\./,c),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,c],scope:{1:"keyword",3:"title.class"}}]},_e={relevance:0,match:o.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...Ii,...Pi]}},Ae={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},st={variants:[{match:[/function/,/\s+/,c,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[Fe],illegal:/%/},bt={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function T(ne){return o.concat("(?!",ne.join("|"),")")}let Ke={match:o.concat(/\b/,T([...Bi,"super","import"].map(ne=>`${ne}\\s*\\(`)),c,o.lookahead(/\s*\(/)),className:"title.function",relevance:0},mt={begin:o.concat(/\./,o.lookahead(o.concat(c,/(?![0-9A-Za-z$_(])/))),end:c,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},dt={match:[/get|set/,/\s+/,c,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},Fe]},G="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",J={match:[/const|var|let/,/\s+/,c,/\s*/,/=\s*/,/(async\s*)?/,o.lookahead(G)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[Fe]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:m,exports:{PARAMS_CONTAINS:Re,CLASS_REFERENCE:_e},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),Ae,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,_,C,I,Se,$e,{match:/\$\d+/},P,_e,{scope:"attr",match:c+o.lookahead(":"),relevance:0},J,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[$e,t.REGEXP_MODE,{className:"function",begin:G,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:m,contains:Re}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:d.begin,end:d.end},{match:p},{begin:g.begin,"on:begin":g.isTrulyOpeningTag,end:g.end}],subLanguage:"xml",contains:[{begin:g.begin,end:g.end,skip:!0,contains:["self"]}]}]},st,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[Fe,t.inherit(t.TITLE_MODE,{begin:c,className:"title.function"})]},{match:/\.\.\./,relevance:0},mt,{match:"\\$"+c,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[Fe]},Ke,bt,je,dt,{match:/\$[(.]/}]}}function Fi(t){let o=t.regex,a=Fc(t),c=Es,d=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],p={begin:[/namespace/,/\s+/,t.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},g={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:d},contains:[a.exports.CLASS_REFERENCE]},m={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},w=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],E={$pattern:Es,keyword:Li.concat(w),literal:Ri,built_in:qi.concat(d),"variable.language":Di},S={className:"meta",begin:"@"+c},P=(I,Se,de)=>{let $e=I.contains.findIndex(te=>te.label===Se);if($e===-1)throw new Error("can not find mode to replace");I.contains.splice($e,1,de)};Object.assign(a.keywords,E),a.exports.PARAMS_CONTAINS.push(S);let $=a.contains.find(I=>I.scope==="attr"),_=Object.assign({},$,{match:o.concat(c,o.lookahead(/\s*\?:/))});a.exports.PARAMS_CONTAINS.push([a.exports.CLASS_REFERENCE,$,_]),a.contains=a.contains.concat([S,p,g,_]),P(a,"shebang",t.SHEBANG()),P(a,"use_strict",m);let C=a.contains.find(I=>I.label==="func.def");return C.relevance=0,Object.assign(a,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),a}ge();be();function zi(t){let o=t.regex,a=/[\p{XID_Start}_]\p{XID_Continue}*/u,c=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],m={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:c,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},w={className:"meta",begin:/^(>>>|\.\.\.) /},E={className:"subst",begin:/\{/,end:/\}/,keywords:m,illegal:/#/},S={begin:/\{\{/,relevance:0},P={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,w],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,w],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,w,S,E]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,w,S,E]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[t.BACKSLASH_ESCAPE,S,E]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,S,E]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},$="[0-9](_?[0-9])*",_=`(\\b(${$}))?\\.(${$})|\\b(${$})\\.`,C=`\\b|${c.join("|")}`,I={className:"number",relevance:0,variants:[{begin:`(\\b(${$})|(${_}))[eE][+-]?(${$})[jJ]?(?=${C})`},{begin:`(${_})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${C})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${C})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${C})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${C})`},{begin:`\\b(${$})[jJ](?=${C})`}]},Se={className:"comment",begin:o.lookahead(/# type:/),end:/$/,keywords:m,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},de={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:m,contains:["self",w,I,P,t.HASH_COMMENT_MODE]}]};return E.contains=[P,I,w],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:m,illegal:/(<\/|\?)|=>/,contains:[w,I,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},P,Se,t.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,a],scope:{1:"keyword",3:"title.function"},contains:[de]},{variants:[{match:[/\bclass/,/\s+/,a,/\s*/,/\(\s*/,a,/\s*\)/]},{match:[/\bclass/,/\s+/,a]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[I,de,P]}]}}ge();be();function Ui(t){let o=t.regex,a={},c={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[a]}]};Object.assign(a,{className:"variable",variants:[{begin:o.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},c]});let d={className:"subst",begin:/\$\(/,end:/\)/,contains:[t.BACKSLASH_ESCAPE]},p=t.inherit(t.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),g={begin:/<<-?\s*(?=\w+)/,starts:{contains:[t.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},m={className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,a,d]};d.contains.push(m);let w={match:/\\"/},E={className:"string",begin:/'/,end:/'/},S={match:/\\'/},P={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},t.NUMBER_MODE,a]},$=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],_=t.SHEBANG({binary:`(${$.join("|")})`,relevance:10}),C={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[t.inherit(t.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},I=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],Se=["true","false"],de={match:/(\/[a-z._-]+)+/},$e=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],te=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],ae=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],Re=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:I,literal:Se,built_in:[...$e,...te,"set","shopt",...ae,...Re]},contains:[_,t.SHEBANG(),C,P,p,g,de,m,w,E,S,a]}}ge();be();function Hi(t){let o="true false yes no null",a="[\\w#;/?:@&=+$,.~*'()[\\]]+",c={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},d={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},p={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},g={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[t.BACKSLASH_ESCAPE,d]},m=t.inherit(g,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),$={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},_={end:",",endsWithParent:!0,excludeEnd:!0,keywords:o,relevance:0},C={begin:/\{/,end:/\}/,contains:[_],illegal:"\\n",relevance:0},I={begin:"\\[",end:"\\]",contains:[_],illegal:"\\n",relevance:0},Se=[c,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+a},{className:"type",begin:"!<"+a+">"},{className:"type",begin:"!"+a},{className:"type",begin:"!!"+a},{className:"meta",begin:"&"+t.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+t.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},t.HASH_COMMENT_MODE,{beginKeywords:o,keywords:{literal:o}},$,{className:"number",begin:t.C_NUMBER_RE+"\\b",relevance:0},C,I,p,g],de=[...Se];return de.pop(),de.push(m),_.contains=de,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:Se}}ge();be();function ji(t){let o={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},a={match:/[{}[\],:]/,className:"punctuation",relevance:0},c=["true","false","null"],d={scope:"literal",beginKeywords:c.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:c},contains:[o,a,t.QUOTE_STRING_MODE,d,t.C_NUMBER_MODE,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}ge();be();var Nr="[0-9](_*[0-9])*",Ss=`\\.(${Nr})`,As="[0-9a-fA-F](_*[0-9a-fA-F])*",Gi={className:"number",variants:[{begin:`(\\b(${Nr})((${Ss})|\\.)?|(${Ss}))[eE][+-]?(${Nr})[fFdD]?\\b`},{begin:`\\b(${Nr})((${Ss})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${Ss})[fFdD]?\\b`},{begin:`\\b(${Nr})[fFdD]\\b`},{begin:`\\b0[xX]((${As})\\.?|(${As})?\\.(${As}))[pP][+-]?(${Nr})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${As})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function Ki(t,o,a){return a===-1?"":t.replace(o,c=>Ki(t,o,a-1))}function Wi(t){let o=t.regex,a="[\xC0-\u02B8a-zA-Z_$][\xC0-\u02B8a-zA-Z_$0-9]*",c=a+Ki("(?:<"+a+"~~~(?:\\s*,\\s*"+a+"~~~)*>)?",/~~~/g,2),w={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},E={className:"meta",begin:"@"+a,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},S={className:"params",begin:/\(/,end:/\)/,keywords:w,relevance:0,contains:[t.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:w,illegal:/<\/|#/,contains:[t.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[t.BACKSLASH_ESCAPE]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,a],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[o.concat(/(?!else)/,a),/\s+/,a,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,a],className:{1:"keyword",3:"title.class"},contains:[S,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+c+"\\s+)",t.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:w,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:w,relevance:0,contains:[E,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,Gi,t.C_BLOCK_COMMENT_MODE]},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},Gi,E]}}ge();be();function Vi(t){let p={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:p,illegal:"</",contains:[t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,{className:"string",variants:[t.QUOTE_STRING_MODE,t.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:"number",variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[t.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:p,illegal:/["']/}]}]}}ge();be();function Zi(t){let o=t.regex,a=/(r#)?/,c=o.concat(a,t.UNDERSCORE_IDENT_RE),d=o.concat(a,t.IDENT_RE),p={className:"title.function.invoke",relevance:0,begin:o.concat(/\b/,/(?!let|for|while|if|else|match\b)/,d,o.lookahead(/\s*\(/))},g="([ui](8|16|32|64|128|size)|f(32|64))?",m=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],w=["true","false","Some","None","Ok","Err"],E=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],S=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:t.IDENT_RE+"!?",type:S,keyword:m,literal:w,built_in:E},illegal:"</",contains:[t.C_LINE_COMMENT_MODE,t.COMMENT("/\\*","\\*/",{contains:["self"]}),t.inherit(t.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"number",variants:[{begin:"\\b0b([01_]+)"+g},{begin:"\\b0o([0-7_]+)"+g},{begin:"\\b0x([A-Fa-f0-9_]+)"+g},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+g}],relevance:0},{begin:[/fn/,/\s+/,c],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,c],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,c,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,c],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,c],className:{1:"keyword",3:"title.class"}},{begin:t.IDENT_RE+"::",keywords:{keyword:"Self",built_in:E,type:S}},{className:"punctuation",begin:"->"},p]}}ge();be();function Yi(t){let o=t.regex,a=o.concat(/[\p{L}_]/u,o.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),c=/[\p{L}0-9._:-]+/u,d={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},p={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},g=t.inherit(p,{begin:/\(/,end:/\)/}),m=t.inherit(t.APOS_STRING_MODE,{className:"string"}),w=t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),E={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:c,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[d]},{begin:/'/,end:/'/,contains:[d]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[p,w,m,g,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[p,g,w,m]}]}]},t.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},d,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[w]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[E],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[E],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:o.concat(/</,o.lookahead(o.concat(a,o.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:a,relevance:0,starts:E}]},{className:"tag",begin:o.concat(/<\//,o.lookahead(o.concat(a,/>/))),contains:[{className:"name",begin:a,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}ge();be();var zc=t=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:t.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:t.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),Uc=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],Hc=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],jc=[...Uc,...Hc],Gc=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),Kc=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),Wc=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),Vc=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function Xi(t){let o=t.regex,a=zc(t),c={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},d="and or not only",p=/@-?\w[\w]*(-\w+)*/,g="[a-zA-Z-][a-zA-Z0-9_-]*",m=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[a.BLOCK_COMMENT,c,a.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+g,relevance:0},a.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+Kc.join("|")+")"},{begin:":(:)?("+Wc.join("|")+")"}]},a.CSS_VARIABLE,{className:"attribute",begin:"\\b("+Vc.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[a.BLOCK_COMMENT,a.HEXCOLOR,a.IMPORTANT,a.CSS_NUMBER_MODE,...m,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...m,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},a.FUNCTION_DISPATCH]},{begin:o.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:p},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:d,attribute:Gc.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...m,a.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+jc.join("|")+")\\b"}]}}ge();be();function Ji(t){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}Gt.registerLanguage("sql",Ti);Gt.registerLanguage("javascript",Oi);Gt.registerLanguage("typescript",Fi);Gt.registerLanguage("python",zi);Gt.registerLanguage("bash",Ui);Gt.registerLanguage("yaml",Hi);Gt.registerLanguage("json",ji);Gt.registerLanguage("java",Wi);Gt.registerLanguage("go",Vi);Gt.registerLanguage("rust",Zi);Gt.registerLanguage("xml",Yi);Gt.registerLanguage("css",Xi);Gt.registerLanguage("plaintext",Ji);Gt.registerAliases(["js"],{languageName:"javascript"});Gt.registerAliases(["ts"],{languageName:"typescript"});Gt.registerAliases(["shell","sh","zsh"],{languageName:"bash"});Gt.registerAliases(["html"],{languageName:"xml"});Gt.registerAliases(["text","plain"],{languageName:"plaintext"});function Zc(t,o){return t.split("|").map(a=>{if(a=a.trim(),a===""||a==="all")return Array.from({length:o},(d,p)=>p+1);let c=[];for(let d of a.split(",")){let p=d.trim().match(/^(\d+)(?:-(\d+))?$/);if(!p)continue;let g=parseInt(p[1],10),m=p[2]?parseInt(p[2],10):g;for(let w=g;w<=Math.min(m,o);w++)c.push(w)}return c})}function Yc(t){let o=[[]];for(function a(c,d){for(let p of c.childNodes)p.nodeType===Node.TEXT_NODE?p.nodeValue.split(`
100
+ `).forEach((m,w)=>{w>0&&o.push([]),m&&o[o.length-1].push({path:d,text:m})}):p.nodeType===Node.ELEMENT_NODE&&a(p,[...d,p])}(t,[]);o.length&&o[o.length-1].length===0;)o.pop();t.textContent="";for(let a of o){let c=document.createElement("span");c.className="code-line";for(let{path:d,text:p}of a){let g=c;for(let m of d){let w=g.lastChild;w&&w.__orig===m||(w=m.cloneNode(!1),w.__orig=m,g.appendChild(w)),g=w}g.appendChild(document.createTextNode(p))}t.appendChild(c)}return t.querySelectorAll(":scope > .code-line")}function Xc(t,o){if(t.length===o)return"all lines";let a=[...t],c=[],d=a[0],p=a[0];for(let g of a.slice(1)){if(g===p+1){p=g;continue}c.push(d===p?`${d}`:`${d}-${p}`),d=p=g}return c.push(d===p?`${d}`:`${d}-${p}`),`lines ${c.join(",")}`}function Qi(t,o){t.querySelectorAll("pre > code").forEach(a=>{let c=[...a.classList].find(S=>S.startsWith("language-")),d=c?c.slice(9):null,p=a.textContent.replace(/^\n/,"").replace(/\s+$/,"");d&&Gt.getLanguage(d)?a.innerHTML=Gt.highlight(p,{language:d}).value:a.textContent=p,a.classList.add("hljs");let g=a.parentElement,m=Yc(a);g.hasAttribute("data-lines-numbers")&&g.classList.add("line-numbers");let w=g.getAttribute("data-lines");if(!w)return;let E=Zc(w,m.length);g.classList.add("stepping"),o(g,{count:E.length,label:S=>S===0?"code":Xc(E[S-1],m.length),apply(S){if(m.forEach(_=>_.classList.remove("line-hl","line-dim")),S===0)return;let P=new Set(E[S-1]),$=P.size===m.length;m.forEach((_,C)=>{P.has(C+1)?_.classList.add("line-hl"):$||_.classList.add("line-dim")})}})})}ge();be();var Jc=/⟨CLICK⟩|&lt;CLICK&gt;|<click(?:\s[^>]*)?>(?:<\/click>)?/gi;function ea(t){return(t||"").split(Jc)}function ao(t){let o="width=1100,height=700",a=window.open("","decklight-speaker",o);if(!a)return null;let c=!1;try{c=a.document.body?a.document.body.childNodes.length>0:!1}catch{c=!0}if(c){try{a.close()}catch{}if(a=window.open("","decklight-speaker",o),!a)return null;try{a.document}catch{return null}}let d=()=>{let g=new URL(location.href);return g.searchParams.set("embedded",""),g.hash="",g.href};window.__decklightBridge={subscribe(g){t.__speakerCb=g},getState:()=>ta(t,d()),next:()=>t.next(),prev:()=>t.prev()},t.__notifySpeaker=()=>{t.__speakerCb&&!a.closed&&t.__speakerCb(ta(t,d()))};let p=`${t.config.width} / ${t.config.height}`;return a.document.write(`<!doctype html><html><head><meta charset="utf-8">
101
101
  <title>Decklight \u2014 speaker view</title>
102
102
  <style>
103
103
  body { margin:0; background:#111; color:#eee; font:14px/1.5 -apple-system, system-ui, sans-serif;
@@ -123,7 +123,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Ae=O,re=D),V===void 0&
123
123
  .thumbs { display:flex; flex-direction:column; gap:10px; min-height:0; align-items:start; }
124
124
  /* Panes keep the presentation's aspect ratio: width-driven, capped so a
125
125
  short window can't push the notes off screen. */
126
- .thumb { width:min(100%, calc(42vh * (${m}))); aspect-ratio:${m}; border:1px solid #333; border-radius:8px; overflow:hidden; position:relative; }
126
+ .thumb { width:min(100%, calc(42vh * (${p}))); aspect-ratio:${p}; border:1px solid #333; border-radius:8px; overflow:hidden; position:relative; }
127
127
  .thumb .tag { position:absolute; top:6px; left:8px; z-index:2; background:#0009; padding:1px 8px; border-radius:4px; font-size:11px; }
128
128
  iframe { width:100%; height:100%; border:0; background:#000; }
129
129
  aside { grid-column:1/3; overflow:auto; background:#1b1b1b; border-radius:8px; padding:14px 16px; font-size:16px; line-height:1.65; }
@@ -227,30 +227,30 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Ae=O,re=D),V===void 0&
227
227
  }
228
228
  connect(30);
229
229
  <\/script>
230
- </body></html>`),l.document.close(),l}function pi(r,i){let{slide:l,step:d,totalSlides:u}=r.state,m=r._records[l-1],f=m?m.groups.length:0,h=d<f?`/${l}/${d+1}`:l<u?`/${l+1}/0`:`/${l}/${d}`,b=r._sections[l-1]?.querySelector("aside.notes"),k=r._sections[l-1]?.querySelector("aside.rehearse");return{slide:l,step:d,totalSlides:u,totalSteps:f,url:i,nextHash:h,notesSegments:ui(b?b.innerHTML:""),rehearseSegments:k?ui(k.innerHTML):null,labels:r._stepLabels(l-1),qr:r.__remoteQr??null}}le();ce();function It(r,i){r.addEventListener("click",l=>{l.target===r&&i()})}function on(r,i,l,{scroll:d=!0}={}){let u=(i+r.length)%r.length;return r.forEach((m,f)=>m.classList.toggle(l,f===u)),d&&r[u]?.scrollIntoView({block:"nearest"}),u}function Er(r,{query:i="",onMove:l,onCommit:d,onType:u,onBackspace:m,onClear:f,onClose:h}){switch(r.key){case"ArrowDown":return l?.(1),!0;case"ArrowUp":return l?.(-1),!0;case"Enter":return d?.(),!0;case"Backspace":return m?(m(),!0):!1;case"Escape":return i&&f?f():h?.(),!0;default:return r.key.length===1&&u?(u(r.key),!0):!1}}function hi(){let r=[];return{register(i){return r.push(i),i},active:()=>r.find(i=>i.isOpen()),closeOthers(i){for(let l of r)l!==i&&l.isOpen()&&l.close()}}}le();ce();le();ce();function Ic(r){return function(){r|=0,r=r+1831565813|0;let i=Math.imul(r^r>>>15,1|r);return i=i+Math.imul(i^i>>>7,61|i)^i,((i^i>>>14)>>>0)/4294967296}}function pn(r,i,l){r=(r%360+360)%360,i=Math.max(0,Math.min(100,i))/100,l=Math.max(0,Math.min(100,l))/100;let d=(1-Math.abs(2*l-1))*i,u=d*(1-Math.abs(r/60%2-1)),m=l-d/2,f=Math.floor(r/60)%6;return[[d,u,0],[u,d,0],[0,d,u],[0,u,d],[u,0,d],[d,0,u]][f].map(b=>Math.round((b+m)*255))}function An([r,i,l]){return"#"+[r,i,l].map(d=>d.toString(16).padStart(2,"0")).join("")}function Kn([r,i,l]){let d=[r,i,l].map(u=>(u/=255,u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4)));return .2126*d[0]+.7152*d[1]+.0722*d[2]}function Bc(r,i){let[l,d]=[Kn(r),Kn(i)].sort((u,m)=>m-u);return(l+.05)/(d+.05)}var jn=(r,i)=>Math.min(...i.map(l=>Bc(r,l)));function Lt(r,i,l,d,u){let f=d.reduce((A,P)=>A+Kn(P),0)/d.length<.5?1:-1,h=[];for(let A=i;A>0;A-=15)h.push(A);h.push(0);for(let A of[f,-f])for(let P of h)for(let M=l;M>=2&&M<=98;M+=A){let T=pn(r,P,M);if(jn(T,d)>=u)return T}let b=[253,253,254],k=[8,9,10];return jn(b,d)>=jn(k,d)?b:k}var Pc=["amber","boreal","cinder","coral","drift","ember","fable","fjord","gale","harbor","iris","juniper","kelp","lumen","mesa","nectar","onyx","pluma","quartz","reef","sable","tundra","umbra","verdant","wisp","yonder","zephyr"],ns='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',Dc='ui-rounded, "SF Pro Rounded", "Segoe UI", Roboto, Helvetica, Arial, sans-serif',qc='"Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif',Fc='"SF Mono", SFMono-Regular, ui-monospace, "Cascadia Code", Menlo, Consolas, monospace',zc=[ns,ns,Dc,qc],Uc=[600,650,700,750,800],Hc=["4px","6px","8px","10px","12px","14px","18px"],mi={analogous:[30,-30,60,15,-15],complementary:[180,150,210,30,-30],split:[150,210,30,180,-30],triadic:[120,240,60,180,300]},In={bgSatMax:{dark:18,light:12},accentSat:[42,68],hlSat:[36,58],ansiSat:[46,66],gradientChance:.15,gradientHueDrift:[8,20]};function Sr(r){r=(r??Math.floor(Math.random()*4294967295))>>>0;let i=Ic(r),l=it=>it[Math.floor(i()*it.length)],d=(it,Ee)=>it+i()*(Ee-it),u=i()<.5,m=Math.floor(i()*360),f=l(Object.keys(mi)),h=mi[f],b=m+h[0],k=i()*i(),A=(it,Ee)=>it+k*(Ee-it),P=A(5,In.bgSatMax[u?"dark":"light"]),M=u?d(6,13):d(94,97.5),T=pn(m,P,M),C=An(T),F=[T];if(i()<In.gradientChance){let it=pn(m+d(...In.gradientHueDrift),P+d(0,8),M+(u?d(2.5,5):-d(2,4)));C=`linear-gradient(${Math.round(d(120,210))}deg, ${An(T)} 0%, ${An(it)} 100%)`,F=[T,it]}let ye=pn(m,Math.min(P+4,35),u?M+4:M-4),ge=Lt(m,12,u?86:18,F,4.6),be=Lt(m,10,u?64:44,F,3.1),de=i()<.5?Lt(b,A(20,55),u?80:26,F,3.2):Lt(m,8,u?92:12,F,4.6),Oe=A(...In.accentSat),ke=u?d(55,68):d(34,48),De=pn(b,Oe,ke);for(;Math.max(jn([253,253,254],[De]),jn([8,9,10],[De]))<4.7;)ke+=u?1:-1,De=pn(b,Oe,ke);let xe=Lt(b,18,Kn(De)<.4?96:10,[De],4.6),Le=Lt(i()<.5?b:m+(h[1]??30),A(35,60),u?70:34,F,3.2),st=An(ye),at=`1px solid ${An(pn(m,Math.min(P+6,40),u?M+10:M-10))}`,_=l(Hc),qe=u?`0 ${Math.round(d(4,10))}px ${Math.round(d(18,30))}px rgba(0, 0, 0, 0.${Math.round(d(35,55))})`:`0 ${Math.round(d(3,6))}px ${Math.round(d(12,20))}px rgba(30, 30, 40, 0.${String(Math.round(d(8,14))).padStart(2,"0")})`,Je=pn(m,Math.min(P+2,28),u?Math.max(M-3,3):Math.min(M-3,93)),je=[Je],O=Lt(m,8,u?85:20,je,4.6),D={keyword:h[0],string:h[3]??120,number:h[2]??60,function:h[1]??210,type:h[4]??280},V=A(...In.hlSat),re=u?68:36,Ae={};for(let[it,Ee]of Object.entries(D))Ae[it]=Lt(m+Ee,V,re,je,4.6);Ae.comment=Lt(m,12,u?60:46,je,3.2),Ae.punct=Lt(m,10,u?74:32,je,4.6);let Ce=[0,h[0],h[1]??40,h[2]??90,h[3]??160,h[4]??230].map((it,Ee)=>pn(m+it,A(14,34),u?M+8+Ee%3*2:M-6-Ee%3*2)),s=[...F,...Ce],o=Lt(m,14,u?60:42,F,2.2),N=Lt(m,10,u?84:20,s,3.4),Fe=Lt(m,10,u?62:46,s,2.7),B=Lt(b,Oe,u?68:38,s,2.7),ot=Ce.map(An),mt=pn(m,Math.min(P+4,30),u?Math.max(M-4,3):d(12,18)),K=[mt],_e=Lt(m,8,82,K,4.6),Y=Lt(b,A(...In.ansiSat),66,K,3.2),Re={red:8,green:125,yellow:45,blue:215,magenta:290,cyan:175},y={black:Lt(m,10,58,K,3.1),white:Lt(m,6,88,K,4.6)};for(let[it,Ee]of Object.entries(Re))y[it]=Lt(Ee+m%16-8,A(...In.ansiSat),66,K,3.1);let Be=it=>{let[Ee,ze,oe]=it.map(Xe=>Math.min(255,Math.round(Xe+(255-Xe)*.35)));return jn([Ee,ze,oe],K)>=3?[Ee,ze,oe]:Lt(m,8,90,K,3.1)},w=`gen-${l(Pc)}-${(r%65535).toString(16).padStart(4,"0")}`,pe=An,Se={"--bg":C,"--bg-accent":An(ye),"--fg":pe(ge),"--muted":pe(be),"--font-body":ns,"--font-heading":l(zc),"--font-mono":Fc,"--heading-color":pe(de),"--heading-weight":String(l(Uc)),"--link":pe(Le),"--accent":pe(De),"--accent-contrast":pe(xe),"--block-bg":st,"--block-border":at,"--block-radius":_,"--shadow":qe,"--code-bg":pe(Je),"--code-fg":pe(O),"--hl-keyword":pe(Ae.keyword),"--hl-string":pe(Ae.string),"--hl-number":pe(Ae.number),"--hl-comment":pe(Ae.comment),"--hl-function":pe(Ae.function),"--hl-type":pe(Ae.type),"--hl-punct":pe(Ae.punct),"--d-stroke":pe(o),"--d-text":pe(N),"--d-muted":pe(Fe),"--d-accent":pe(B),"--d-fill-1":ot[0],"--d-fill-2":ot[1],"--d-fill-3":ot[2],"--d-fill-4":ot[3],"--d-fill-5":ot[4],"--d-fill-6":ot[5],"--term-bg":pe(mt),"--term-fg":pe(_e),"--term-prompt":pe(Y),"--term-cursor":pe(Y),"--term-selection":`rgba(${De[0]}, ${De[1]}, ${De[2]}, 0.30)`,"--ansi-black":pe(y.black),"--ansi-red":pe(y.red),"--ansi-green":pe(y.green),"--ansi-yellow":pe(y.yellow),"--ansi-blue":pe(y.blue),"--ansi-magenta":pe(y.magenta),"--ansi-cyan":pe(y.cyan),"--ansi-white":pe(y.white),"--ansi-bright-black":pe(Be(y.black)),"--ansi-bright-red":pe(Be(y.red)),"--ansi-bright-green":pe(Be(y.green)),"--ansi-bright-yellow":pe(Be(y.yellow)),"--ansi-bright-blue":pe(Be(y.blue)),"--ansi-bright-magenta":pe(Be(y.magenta)),"--ansi-bright-cyan":pe(Be(y.cyan)),"--ansi-bright-white":pe(Lt(m,6,97,K,3.1)),"--dim-opacity":(.25+Math.round(i()*15)/100).toFixed(2)};return{name:w,seed:r,dark:u,harmony:f,tokens:Se}}var fi=[["canvas",["--bg","--bg-accent","--fg","--muted"]],["type",["--font-body","--font-heading","--font-mono","--heading-color","--heading-weight","--link"]],["accent",["--accent","--accent-contrast"]],["blocks",["--block-bg","--block-border","--block-radius","--shadow"]],["code",["--code-bg","--code-fg","--hl-keyword","--hl-string","--hl-number","--hl-comment","--hl-function","--hl-type","--hl-punct"]],["diagram",["--d-stroke","--d-text","--d-muted","--d-accent","--d-fill-1","--d-fill-2","--d-fill-3","--d-fill-4","--d-fill-5","--d-fill-6"]],["terminal",["--term-bg","--term-fg","--term-prompt","--term-cursor","--term-selection","--ansi-black","--ansi-red","--ansi-green","--ansi-yellow","--ansi-blue","--ansi-magenta","--ansi-cyan","--ansi-white","--ansi-bright-black","--ansi-bright-red","--ansi-bright-green","--ansi-bright-yellow","--ansi-bright-blue","--ansi-bright-magenta","--ansi-bright-cyan","--ansi-bright-white"]],["builds",["--dim-opacity"]]];function rs(r,i){let l=`/* \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
231
- Decklight theme \xB7 ${r}
230
+ </body></html>`),a.document.close(),a}function ta(t,o){let{slide:a,step:c,totalSlides:d}=t.state,p=t._records[a-1],g=p?p.groups.length:0,m=c<g?`/${a}/${c+1}`:a<d?`/${a+1}/0`:`/${a}/${c}`,w=t._sections[a-1]?.querySelector("aside.notes"),E=t._sections[a-1]?.querySelector("aside.rehearse");return{slide:a,step:c,totalSlides:d,totalSteps:g,url:o,nextHash:m,notesSegments:ea(w?w.innerHTML:""),rehearseSegments:E?ea(E.innerHTML):null,labels:t._stepLabels(a-1),qr:t.__remoteQr??null}}ge();be();function Ut(t,o){t.addEventListener("click",a=>{a.target===t&&o()})}function vn(t,o,a,{scroll:c=!0}={}){let d=(o+t.length)%t.length;return t.forEach((p,g)=>p.classList.toggle(a,g===d)),c&&t[d]?.scrollIntoView({block:"nearest"}),d}function _s(t,{query:o="",onMove:a,onCommit:c,onType:d,onBackspace:p,onClear:g,onClose:m}){switch(t.key){case"ArrowDown":return a?.(1),!0;case"ArrowUp":return a?.(-1),!0;case"Enter":return c?.(),!0;case"Backspace":return p?(p(),!0):!1;case"Escape":return o&&g?g():m?.(),!0;default:return t.key.length===1&&d?(d(t.key),!0):!1}}function na(){let t=[];return{register(o){return t.push(o),o},active:()=>t.find(o=>o.isOpen()),closeOthers(o){for(let a of t)a!==o&&a.isOpen()&&a.close()}}}ge();be();ge();be();function Qc(t){return function(){t|=0,t=t+1831565813|0;let o=Math.imul(t^t>>>15,1|t);return o=o+Math.imul(o^o>>>7,61|o)^o,((o^o>>>14)>>>0)/4294967296}}function Bn(t,o,a){t=(t%360+360)%360,o=Math.max(0,Math.min(100,o))/100,a=Math.max(0,Math.min(100,a))/100;let c=(1-Math.abs(2*a-1))*o,d=c*(1-Math.abs(t/60%2-1)),p=a-c/2,g=Math.floor(t/60)%6;return[[c,d,0],[d,c,0],[0,c,d],[0,d,c],[d,0,c],[c,0,d]][g].map(w=>Math.round((w+p)*255))}function rr([t,o,a]){return"#"+[t,o,a].map(c=>c.toString(16).padStart(2,"0")).join("")}function Or([t,o,a]){let c=[t,o,a].map(d=>(d/=255,d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4)));return .2126*c[0]+.7152*c[1]+.0722*c[2]}function ed(t,o){let[a,c]=[Or(t),Or(o)].sort((d,p)=>p-d);return(a+.05)/(c+.05)}var Mr=(t,o)=>Math.min(...o.map(a=>ed(t,a)));function Zt(t,o,a,c,d){let g=c.reduce((S,P)=>S+Or(P),0)/c.length<.5?1:-1,m=[];for(let S=o;S>0;S-=15)m.push(S);m.push(0);for(let S of[g,-g])for(let P of m)for(let $=a;$>=2&&$<=98;$+=S){let _=Bn(t,P,$);if(Mr(_,c)>=d)return _}let w=[253,253,254],E=[8,9,10];return Mr(w,c)>=Mr(E,c)?w:E}var td=["amber","boreal","cinder","coral","drift","ember","fable","fjord","gale","harbor","iris","juniper","kelp","lumen","mesa","nectar","onyx","pluma","quartz","reef","sable","tundra","umbra","verdant","wisp","yonder","zephyr"],lo='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',nd='ui-rounded, "SF Pro Rounded", "Segoe UI", Roboto, Helvetica, Arial, sans-serif',rd='"Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif',sd='"SF Mono", SFMono-Regular, ui-monospace, "Cascadia Code", Menlo, Consolas, monospace',od=[lo,lo,nd,rd],id=[600,650,700,750,800],ad=["4px","6px","8px","10px","12px","14px","18px"],ra={analogous:[30,-30,60,15,-15],complementary:[180,150,210,30,-30],split:[150,210,30,180,-30],triadic:[120,240,60,180,300]},yr={bgSatMax:{dark:18,light:12},accentSat:[42,68],hlSat:[36,58],ansiSat:[46,66],gradientChance:.15,gradientHueDrift:[8,20]};function Ts(t){t=(t??Math.floor(Math.random()*4294967295))>>>0;let o=Qc(t),a=Ce=>Ce[Math.floor(o()*Ce.length)],c=(Ce,ce)=>Ce+o()*(ce-Ce),d=o()<.5,p=Math.floor(o()*360),g=a(Object.keys(ra)),m=ra[g],w=p+m[0],E=o()*o(),S=(Ce,ce)=>Ce+E*(ce-Ce),P=S(5,yr.bgSatMax[d?"dark":"light"]),$=d?c(6,13):c(94,97.5),_=Bn(p,P,$),C=rr(_),I=[_];if(o()<yr.gradientChance){let Ce=Bn(p+c(...yr.gradientHueDrift),P+c(0,8),$+(d?c(2.5,5):-c(2,4)));C=`linear-gradient(${Math.round(c(120,210))}deg, ${rr(_)} 0%, ${rr(Ce)} 100%)`,I=[_,Ce]}let Se=Bn(p,Math.min(P+4,35),d?$+4:$-4),de=Zt(p,12,d?86:18,I,4.6),$e=Zt(p,10,d?64:44,I,3.1),ae=o()<.5?Zt(w,S(20,55),d?80:26,I,3.2):Zt(p,8,d?92:12,I,4.6),Re=S(...yr.accentSat),Fe=d?c(55,68):c(34,48),je=Bn(w,Re,Fe);for(;Math.max(Mr([253,253,254],[je]),Mr([8,9,10],[je]))<4.7;)Fe+=d?1:-1,je=Bn(w,Re,Fe);let _e=Zt(w,18,Or(je)<.4?96:10,[je],4.6),Ae=Zt(o()<.5?w:p+(m[1]??30),S(35,60),d?70:34,I,3.2),st=rr(Se),bt=`1px solid ${rr(Bn(p,Math.min(P+6,40),d?$+10:$-10))}`,T=a(ad),Ke=d?`0 ${Math.round(c(4,10))}px ${Math.round(c(18,30))}px rgba(0, 0, 0, 0.${Math.round(c(35,55))})`:`0 ${Math.round(c(3,6))}px ${Math.round(c(12,20))}px rgba(30, 30, 40, 0.${String(Math.round(c(8,14))).padStart(2,"0")})`,mt=Bn(p,Math.min(P+2,28),d?Math.max($-3,3):Math.min($-3,93)),dt=[mt],G=Zt(p,8,d?85:20,dt,4.6),J={keyword:m[0],string:m[3]??120,number:m[2]??60,function:m[1]??210,type:m[4]??280},ne=S(...yr.hlSat),fe=d?68:36,ue={};for(let[Ce,ce]of Object.entries(J))ue[Ce]=Zt(p+ce,ne,fe,dt,4.6);ue.comment=Zt(p,12,d?60:46,dt,3.2),ue.punct=Zt(p,10,d?74:32,dt,4.6);let Q=[0,m[0],m[1]??40,m[2]??90,m[3]??160,m[4]??230].map((Ce,ce)=>Bn(p+Ce,S(14,34),d?$+8+ce%3*2:$-6-ce%3*2)),s=[...I,...Q],i=Zt(p,14,d?60:42,I,2.2),O=Zt(p,10,d?84:20,s,3.4),De=Zt(p,10,d?62:46,s,2.7),B=Zt(w,Re,d?68:38,s,2.7),Pe=Q.map(rr),_t=Bn(p,Math.min(P+4,30),d?Math.max($-4,3):c(12,18)),W=[_t],ye=Zt(p,8,82,W,4.6),ie=Zt(w,S(...yr.ansiSat),66,W,3.2),Ze={red:8,green:125,yellow:45,blue:215,magenta:290,cyan:175},v={black:Zt(p,10,58,W,3.1),white:Zt(p,6,88,W,4.6)};for(let[Ce,ce]of Object.entries(Ze))v[Ce]=Zt(ce+p%16-8,S(...yr.ansiSat),66,W,3.1);let ze=Ce=>{let[ce,Ne,ee]=Ce.map(nt=>Math.min(255,Math.round(nt+(255-nt)*.35)));return Mr([ce,Ne,ee],W)>=3?[ce,Ne,ee]:Zt(p,8,90,W,3.1)},f=`gen-${a(td)}-${(t%65535).toString(16).padStart(4,"0")}`,Y=rr,F={"--bg":C,"--bg-accent":rr(Se),"--fg":Y(de),"--muted":Y($e),"--font-body":lo,"--font-heading":a(od),"--font-mono":sd,"--heading-color":Y(ae),"--heading-weight":String(a(id)),"--link":Y(Ae),"--accent":Y(je),"--accent-contrast":Y(_e),"--block-bg":st,"--block-border":bt,"--block-radius":T,"--shadow":Ke,"--code-bg":Y(mt),"--code-fg":Y(G),"--hl-keyword":Y(ue.keyword),"--hl-string":Y(ue.string),"--hl-number":Y(ue.number),"--hl-comment":Y(ue.comment),"--hl-function":Y(ue.function),"--hl-type":Y(ue.type),"--hl-punct":Y(ue.punct),"--d-stroke":Y(i),"--d-text":Y(O),"--d-muted":Y(De),"--d-accent":Y(B),"--d-fill-1":Pe[0],"--d-fill-2":Pe[1],"--d-fill-3":Pe[2],"--d-fill-4":Pe[3],"--d-fill-5":Pe[4],"--d-fill-6":Pe[5],"--term-bg":Y(_t),"--term-fg":Y(ye),"--term-prompt":Y(ie),"--term-cursor":Y(ie),"--term-selection":`rgba(${je[0]}, ${je[1]}, ${je[2]}, 0.30)`,"--ansi-black":Y(v.black),"--ansi-red":Y(v.red),"--ansi-green":Y(v.green),"--ansi-yellow":Y(v.yellow),"--ansi-blue":Y(v.blue),"--ansi-magenta":Y(v.magenta),"--ansi-cyan":Y(v.cyan),"--ansi-white":Y(v.white),"--ansi-bright-black":Y(ze(v.black)),"--ansi-bright-red":Y(ze(v.red)),"--ansi-bright-green":Y(ze(v.green)),"--ansi-bright-yellow":Y(ze(v.yellow)),"--ansi-bright-blue":Y(ze(v.blue)),"--ansi-bright-magenta":Y(ze(v.magenta)),"--ansi-bright-cyan":Y(ze(v.cyan)),"--ansi-bright-white":Y(Zt(p,6,97,W,3.1)),"--dim-opacity":(.25+Math.round(o()*15)/100).toFixed(2)};return{name:f,seed:t,dark:d,harmony:g,tokens:F}}var sa=[["canvas",["--bg","--bg-accent","--fg","--muted"]],["type",["--font-body","--font-heading","--font-mono","--heading-color","--heading-weight","--link"]],["accent",["--accent","--accent-contrast"]],["blocks",["--block-bg","--block-border","--block-radius","--shadow"]],["code",["--code-bg","--code-fg","--hl-keyword","--hl-string","--hl-number","--hl-comment","--hl-function","--hl-type","--hl-punct"]],["diagram",["--d-stroke","--d-text","--d-muted","--d-accent","--d-fill-1","--d-fill-2","--d-fill-3","--d-fill-4","--d-fill-5","--d-fill-6"]],["terminal",["--term-bg","--term-fg","--term-prompt","--term-cursor","--term-selection","--ansi-black","--ansi-red","--ansi-green","--ansi-yellow","--ansi-blue","--ansi-magenta","--ansi-cyan","--ansi-white","--ansi-bright-black","--ansi-bright-red","--ansi-bright-green","--ansi-bright-yellow","--ansi-bright-blue","--ansi-bright-magenta","--ansi-bright-cyan","--ansi-bright-white"]],["builds",["--dim-opacity"]]];function co(t,o){let a=`/* \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
231
+ Decklight theme \xB7 ${t}
232
232
  generated by Decklight (\u2303T) \u2014 token contract: SPEC.md THEMING
233
233
  All values derived with WCAG luminance math; passes test/contrast.mjs
234
234
  \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550 */
235
235
 
236
236
  .decklight {
237
- `;for(let[u,m]of fi){let f=m.filter(h=>i[h]!==void 0);if(f.length){l+=` /* \u2500\u2500 ${u} ${"\u2500".repeat(Math.max(1,26-u.length))} */
238
- `;for(let h of f)l+=` ${h}: ${i[h]};
239
- `;l+=`
240
- `}}let d=new Set(fi.flatMap(([,u])=>u));for(let[u,m]of Object.entries(i))d.has(u)||(l+=` ${u}: ${m};
241
- `);return l.replace(/\n$/,"")+`}
242
- `}function gi({root:r,config:i,params:l,toast:d,debugLog:u,overlays:m,deck:f,editmode:h}){let b=[...document.querySelectorAll("style[data-theme]:not([data-theme-added])")],k=[...document.querySelectorAll("style[data-theme][data-theme-added]")],A=new Set(k.map(S=>S.dataset.theme).filter(Boolean)),P=new Map;for(let S of k){let L=S.dataset.themeMarketplace;S.dataset.theme&&L&&P.set(S.dataset.theme,{pack:`mkt:${L}`,label:S.dataset.themeSource||L})}let M=b.length>0,T=M?null:document.querySelector('link[rel="stylesheet"][href*="themes/"]');if(M){let S=b.find(L=>!L.hasAttribute("disabled")&&L.media!=="not all");S=S||b[0],b.forEach(L=>{L.removeAttribute("disabled"),L.media=L===S?"all":"not all"})}let C=M||!!T,F=S=>(S.match(/themes\/([\w-]+)\.css/)||[])[1],ye="decklight-theme:"+location.pathname,ge="decklight-custom-themes",be={};try{be=JSON.parse(localStorage.getItem(ge)||"{}")||{}}catch{}let J=null,de=null,Oe={};function ke(S,L,$){let Z=$==="generated"?J:Oe[S];return Z||(Z=document.createElement("style"),Z.media="not all",$==="generated"?Z.dataset.generated="":Z.dataset.custom=""),Z.dataset.theme=S,Z.textContent=rs(S,L),document.head.appendChild(Z),$==="generated"?J=Z:Oe[S]=Z,Z}let De=()=>[J,...Object.values(Oe),...k];function xe(S){for(let L of De())L&&L!==S&&(L.media="not all")}let Le=()=>De().find(S=>S&&S.media!=="not all")||null,st=()=>{let S=Le();return S?S.dataset.theme:M?b.find(L=>L.media!=="not all")?.dataset.theme:T?F(T.href):void 0};function at(){let S=getComputedStyle(r),L=te=>te?.match(/rgba?\(([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[\s,/]+([\d.]+))?\)/),$=L(S.backgroundColor);(!$||$[4]!==void 0&&+$[4]==0)&&($=L(S.backgroundImage));let Z=$?Kn([+$[1],+$[2],+$[3]])<.5:!1;r.setAttribute("data-canvas",Z?"dark":"light")}T?.addEventListener("load",at);function _(S,L=!1){if(!S||!/^[\w-]+$/.test(S))return;let $=!1;if(de&&J&&S===de.name)J.media="all",xe(J),$=!be[S];else if(be[S]){let Z=ke(S,be[S],"custom");Z.media="all",xe(Z)}else if(A.has(S)){let Z=k.find(te=>te.dataset.theme===S);Z.media="all",xe(Z)}else{if(!C)return;if(xe(null),M){let Z=b.find(te=>te.dataset.theme===S);if(!Z)return;b.forEach(te=>{te.media=te===Z?"all":"not all"})}else T.href=T.href.replace(/themes\/[\w-]+\.css(\?.*)?$/,`themes/${S}.css`)}if(!l.has("embedded")&&!$)try{localStorage.setItem(ye,S)}catch{}L||d(S),u("theme",S),at()}let qe=typeof Ze<"u"?Ze:null,Je={added:"Added",custom:"Custom",generated:"Generated"},je=new Map([...P.values()].map(S=>[S.pack,S.label])),O=S=>je.get(S)??qe?.labels?.[S]??Je[S]??S;function D(S){if(be[S])return"custom";if(de&&S===de.name)return"generated";if(P.has(S))return P.get(S).pack;if(A.has(S))return"added";if(qe){for(let[L,$]of Object.entries(qe.packs))if($.includes(S))return L}return"other"}let V=()=>{let S;if(M){let $=b.map(Z=>Z.dataset.theme);S=i.themes?.length?i.themes.filter(Z=>$.includes(Z)):$}else S=i.themes?.length?i.themes:typeof Ge<"u"?Ge:[];let L=[...A,...Object.keys(be)];if(de&&!be[de.name]&&L.push(de.name),S=[...S,...L.filter($=>!S.includes($))],qe){let $=new Map,Z=0;for(let te of qe.order)for(let fe of qe.packs[te]??[])$.set(fe,Z++);S=[...S].sort((te,fe)=>($.get(te)??1e9)-($.get(fe)??1e9))}return S};function re(S){let L=[];for(let $ of qe.order){let Z=(qe.packs[$]??[]).filter(te=>S.includes(te));Z.length&&L.push([$,Z])}for(let $ of new Set([...P.values()].map(Z=>Z.pack))){let Z=S.filter(te=>D(te)===$);Z.length&&L.push([$,Z])}for(let $ of["added","custom","generated"]){let Z=S.filter(te=>D(te)===$);Z.length&&L.push([$,Z])}return L}let Ae=S=>btoa(unescape(encodeURIComponent(JSON.stringify(S)))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),Ke=S=>JSON.parse(decodeURIComponent(escape(atob(S.replace(/-/g,"+").replace(/_/g,"/")))));function Ce(S,L=!1){de={name:S.name,tokens:S.tokens};let $=ke(S.name,S.tokens,"generated");return $.media="all",xe($),L||d(`\u2728 ${S.name} \u2014 \u2303T re-roll \xB7 \u2303\u21E7T save`,2800),at(),S.name}function s(){return Ce(Sr())}function o(S){if(!de||!J||J.media==="not all")return d("no generated theme to save \u2014 \u2303T to generate one"),null;let L=S??(window.prompt?.("Save theme as:",de.name.replace(/^gen-/,""))||"");if(L=String(L).toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40),!L)return null;((typeof Ge<"u"?Ge:[]).includes(L)||b.some(te=>te.dataset.theme===L))&&(L="custom-"+L),be[L]=de.tokens;try{localStorage.setItem(ge,JSON.stringify(be))}catch{}let Z=ke(L,be[L],"custom");if(Z.media="all",J?.remove(),J=null,de=null,xe(Z),!l.has("embedded"))try{localStorage.setItem(ye,L)}catch{}try{let te=new Blob([rs(L,be[L])],{type:"text/css"}),fe=document.createElement("a");fe.href=URL.createObjectURL(te),fe.download=`${L}.css`,fe.click(),setTimeout(()=>URL.revokeObjectURL(fe.href),5e3)}catch{}return d(`saved ${L} \u2014 ${L}.css downloaded`,2200),L}let N=null;function Fe(S=!1){return N?(clearTimeout(N.timer),N=null,S||d("theme cycle cancelled"),!0):!1}function B(S){let L=V();if(!C||L.length<2)return;if(N){let fe=N;clearTimeout(fe.timer),N=null,fe.dir===S?_(fe.name):d("theme cycle cancelled");return}let $=st(),Z=Math.max(0,L.indexOf($)),te=L[(Z+S+L.length)%L.length];if(qe&&D(te)!==D($)){let fe=S>0?".":",",Qe=S>0?",":".";N={dir:S,name:te,timer:setTimeout(()=>{N=null},4e3)},d(`\u2933 ${O(D(te))} pack next (${te}) \u2014 ${fe} confirms \xB7 ${Qe} or Esc cancels`,4e3);return}_(te)}l.has("embedded")&&window.addEventListener("message",S=>{let L=S.data&&S.data.__decklightPreview;!L||S.source!==window.parent||(L.gen?Ce(L.gen,!0):L.theme?_(L.theme,!0):L.goto&&f().goto(L.goto[0],L.goto[1]??0))});function ot(){let S=st(),L=be[S]?{name:S,tokens:be[S]}:de&&S===de.name?de:null;return L?"?embedded&gen="+Ae(L):S?"?embedded&theme="+encodeURIComponent(S):"?embedded"}function mt(){let S=l.get("gen");if(S)try{let Z=Ke(S);if(Z&&Z.tokens){Ce({name:Z.name||"gen-preview",tokens:Z.tokens},!0);return}}catch{}let L=null;try{L=localStorage.getItem(ye)}catch{}let $=l.get("theme")||L;$&&_($,!0)}let K="\0generate",_e="pack:",Y="back",Re="all",y="browse",Be="",w=S=>S.charCodeAt(0)<32,pe=null,Se=0,it,Ee=[],ze=null,oe="",Xe="packs",gt=()=>qe?"packs":"all",Et=()=>h?.()?.available()===!0,me=()=>h?.()?.base()??"",Ne=()=>Et()?[y]:[],Ie=null,et=S=>(Ie?.themes??[]).find(L=>L.qualified===S);async function tt(){Ie={loading:!0,themes:[],stale:[]},Ot("browse");let S;try{let L=await fetch(me()+"/edit/theme/browse"),$=await L.json().catch(()=>({}));S=L.ok&&$.ok?{themes:$.themes??[],stale:$.stale??[],cacheOnly:$.cacheOnly!==!1}:{themes:[],stale:[],error:$.error||`the author server said ${L.status}`}}catch{S={themes:[],stale:[],error:"the author server did not answer"}}!pe||Xe!=="browse"||(Ie=S,Ot("browse"))}async function bt(S){let L=pe?.querySelector(".tp-caption");L&&(L.textContent=`installing ${S}\u2026`);try{let $=await fetch(me()+"/edit/theme/add",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ref:S})}),Z=await $.json().catch(()=>({}));if(!$.ok){let te=[Z.error,...Z.problems??[]].filter(Boolean).join(" \xB7 ");L&&(L.textContent=te||`install failed (${$.status})`),d(`${S}: ${Z.error||"install refused"}`,3600);return}se(),d(`installed ${Z.name}${Z.replaced?" (replaced)":""} \u2014 Z takes it back`,2800),u("theme",`${S} installed from a marketplace`)}catch{L&&(L.textContent="the author server did not answer")}}function He(S){let L=f().state,$="#/"+L.slide+"/"+L.step;if(S===K||be[S]||de&&S===de.name){let Z=S===K?ze:be[S]?{name:S,tokens:be[S]}:de;return location.pathname+"?embedded&gen="+Ae(Z)+$}return location.pathname+"?embedded&theme="+encodeURIComponent(S)+$}function ft(S){S.textContent=ze?`\u2728 ${ze.name} \u2014 \u2303T re-rolls`:"\u2728 Generate new\u2026"}function Dt(){ze=Sr();let S=Ee.indexOf(K);S<0||(ft(pe.querySelectorAll(".tp-row")[S]),_t(S,!0))}function Kt(){let S=pe.querySelector(".tp-list"),L=st(),$=V();if(Xe==="browse"){let fe=(Ie?.themes??[]).filter(Qe=>!oe||Qe.qualified.includes(oe));Ee=[Y,...fe.map(Qe=>Be+Qe.qualified)]}else if(oe)Ee=$.filter(fe=>fe.includes(oe));else if(!qe||Xe==="all")Ee=qe?[K,Y,...$]:[K,...$,...Ne()];else if(Xe==="packs")Ee=[K,...re($).map(([fe])=>_e+fe),Re,...Ne()];else{let fe=Xe.slice(5);Ee=[Y,...re($).find(([Qe])=>Qe===fe)?.[1]??[]]}S.textContent="";let Z=(fe,Qe)=>{let Pe=document.createElement("span");Pe.className="tp-tag",Pe.textContent=Qe,fe.appendChild(Pe)};if(Ee.forEach((fe,Qe)=>{let Pe=document.createElement("div");if(Pe.setAttribute("role","option"),fe===K)Pe.className="tp-row tp-gen",ft(Pe);else if(fe===Y)Pe.className="tp-row tp-back",Pe.textContent=gt()==="packs"?"\u2190 packs":"\u2190 themes";else if(fe===y)Pe.className="tp-row tp-browse",Pe.textContent="\u2315 Browse marketplaces\u2026";else if(fe.startsWith(Be)){let Ye=et(fe.slice(Be.length));Pe.className="tp-row tp-mkt",Pe.textContent=Ye?.name??fe.slice(Be.length);let ut=A.has(Ye?.name)?"installed":Ye?.marketplace;ut&&Z(Pe,ut)}else if(fe===Re)Pe.className="tp-row tp-all",Pe.textContent="\u2733 all themes",Z(Pe,String($.length));else if(fe.startsWith(_e)){let Ye=fe.slice(_e.length),ut=re($).find(([dt])=>dt===Ye)?.[1]??[];Pe.className="tp-row tp-pack"+(ut.includes(L)?" tp-current":""),Pe.textContent=`\u25B8 ${O(Ye)}`,Z(Pe,String(ut.length))}else{Pe.className="tp-row"+(fe===L?" tp-current":""),Pe.textContent=fe;let Ye=be[fe]?"custom":de&&fe===de.name?"generated":P.has(fe)?P.get(fe).label:A.has(fe)?"added":oe&&qe?O(D(fe)):null;Ye&&Z(Pe,Ye)}Pe.addEventListener("mouseenter",()=>_t(Qe,!1)),Pe.addEventListener("click",()=>{_t(Qe,!0),U()}),S.appendChild(Pe)}),!Ee.length){let fe=document.createElement("div");fe.className="tp-none",fe.textContent="no themes match",S.appendChild(fe)}if(Xe==="browse"){let fe=document.createElement("div");fe.className="tp-none",fe.textContent=Ie?.loading?"reading the catalogs\u2026":Ie?.error?Ie.error:Ee.some(Qe=>Qe.startsWith(Be))?Ie.stale?.length?`from the cache \xB7 never fetched: ${Ie.stale.join(", ")} \u2014 marketplace update`:"from the cache \u2014 listing never goes to the network":oe?"no marketplace theme matches":"no themes in the marketplaces you have registered",S.appendChild(fe)}let te=pe.querySelector(".tp-filter");te.textContent=oe||"type to filter\u2026",te.classList.toggle("tp-active",!!oe)}function Vt(){let S=st(),L=Ee.indexOf(S);if(L>=0)return L;let $=Ee.indexOf(_e+D(S));return $>=0?$:Math.min(1,Ee.length-1)}function Ot(S,L=!1){Xe=S,Kt(),Ee.length&&_t(Vt(),L)}function Q(S){oe=S.toLowerCase(),Kt(),Ee.length?_t(oe?0:Vt(),!1):pe.querySelector(".tp-caption").textContent="no match"}function Zt(){if(pe)return se();m.closeOthers($e);let S=V();if(!C&&!S.length)return;oe="",Xe=gt(),Ie=null,pe=document.createElement("div"),pe.className="decklight-theme-picker",pe.innerHTML='<div class="tp-panel"><div class="tp-side"><div class="tp-filter"></div><div class="tp-list" role="listbox" aria-label="Themes"></div></div><div class="tp-preview"><iframe title="Theme preview"></iframe><div class="tp-caption"></div></div></div>',Kt(),It(pe,se),r.appendChild(pe);let L=st();L&&W(pe.querySelector("iframe"),L),_t(Vt(),!L)}function _t(S,L){if(!Ee.length)return;Se=(S+Ee.length)%Ee.length;let $=Ee[Se];$===K&&!ze&&(ze=Sr(),ft(pe.querySelectorAll(".tp-row")[Se])),on(pe.querySelectorAll(".tp-row"),Se,"tp-selected");let Z=V(),te=$===K?ze?`\u2728 ${ze.name}`:"generate new":$===Y?gt()==="packs"?"back to packs":"back to the theme list":$===y?"themes from the marketplaces you have registered":$.startsWith(Be)?vt($.slice(Be.length)):$===Re?`all ${Z.length} themes, flattened`:$.startsWith(_e)?`${O($.slice(_e.length))} \xB7 ${re(Z).find(([Qe])=>Qe===$.slice(_e.length))?.[1].length??0} themes`:qe?`${O(D($))} \xB7 ${$}`:$;if(pe.querySelector(".tp-caption").textContent=te,clearTimeout(it),$!==K&&w($))return;let fe=pe.querySelector("iframe");L?W(fe,$):it=setTimeout(()=>W(fe,$),60)}function vt(S){let L=et(S);return L?[L.qualified,L.description,A.has(L.name)?"installed \u2014 \u23CE re-installs it":"\u23CE installs it"].filter(Boolean).join(" \xB7 "):S}let Wt=!1,Ht=null;function R(S){return S===K||be[S]||de&&S===de.name?{gen:S===K?ze:be[S]?{name:S,tokens:be[S]}:de}:{theme:S}}function W(S,L){if(!S.dataset.booted){S.dataset.booted="1",Wt=!1,S.addEventListener("load",()=>{if(Wt=!0,Ht!==null&&pe){let $=Ht;Ht=null,W(S,$)}},{once:!0}),S.src=He(L);return}if(!Wt){Ht=L;return}S.contentWindow?.postMessage({__decklightPreview:R(L)},"*")}function U(){let S=Ee[Se];if(S!==void 0){if(S===K){ze&&Ce(ze),se();return}if(S===Y){Ot(gt());return}if(S===Re){Ot("all");return}if(S===y){tt();return}if(S.startsWith(Be)){bt(S.slice(Be.length));return}if(S.startsWith(_e)){Ot("pack:"+S.slice(_e.length),!0);return}_(S),se()}}function se(){clearTimeout(it),pe?.remove(),pe=null}let $e=m.register({isOpen:()=>!!pe,close:se,keydown(S){switch(S.key){case"ArrowDown":_t(Se+1,!1);break;case"ArrowUp":_t(Se-1,!1);break;case"Enter":U();break;case"Backspace":Q(oe.slice(0,-1));break;case"Escape":oe?Q(""):Xe!==gt()?Ot(gt()):se();break;default:if(S.key.length===1&&/[a-z0-9-]/i.test(S.key)){Q(oe+S.key);break}return!1}return!0}});return{applyTheme:_,currentTheme:st,themeList:V,cycleTheme:B,cancelCyclePending:Fe,rollTheme:s,saveGeneratedTheme:o,adoptGenerated:Ce,updateCanvas:at,restoreSaved:mt,previewQuery:ot,openPicker:Zt,closePicker:se,browse(){pe||Zt(),pe&&tt()},hasGenerated:()=>!!de,rollFromPicker(){return pe&&Ee[Se]===K?(Dt(),!0):!1}}}le();ce();le();ce();le();ce();var ss=["A","B","C","D","E","F","G","H","X"],Wn="#edb58e",bi="#c98f6d",Gc="#43302a",Vn="#b96b58",Zn="#57262c",Ar="#f6f1ea",yi="#d17a70",os=`<svg viewBox="0 0 240 240" role="img" aria-label="Narrator" xmlns="http://www.w3.org/2000/svg">
237
+ `;for(let[d,p]of sa){let g=p.filter(m=>o[m]!==void 0);if(g.length){a+=` /* \u2500\u2500 ${d} ${"\u2500".repeat(Math.max(1,26-d.length))} */
238
+ `;for(let m of g)a+=` ${m}: ${o[m]};
239
+ `;a+=`
240
+ `}}let c=new Set(sa.flatMap(([,d])=>d));for(let[d,p]of Object.entries(o))c.has(d)||(a+=` ${d}: ${p};
241
+ `);return a.replace(/\n$/,"")+`}
242
+ `}function oa({root:t,config:o,params:a,toast:c,debugLog:d,overlays:p,deck:g,editmode:m}){let w=[...document.querySelectorAll("style[data-theme]:not([data-theme-added])")],E=[...document.querySelectorAll("style[data-theme][data-theme-added]")],S=new Set(E.map(N=>N.dataset.theme).filter(Boolean)),P=new Map;for(let N of E){let X=N.dataset.themeMarketplace;N.dataset.theme&&X&&P.set(N.dataset.theme,{pack:`mkt:${X}`,label:N.dataset.themeSource||X})}let $=w.length>0,_=$?null:document.querySelector('link[rel="stylesheet"][href*="themes/"]');if($){let N=w.find(X=>!X.hasAttribute("disabled")&&X.media!=="not all");N=N||w[0],w.forEach(X=>{X.removeAttribute("disabled"),X.media=X===N?"all":"not all"})}let C=$||!!_,I=N=>(N.match(/themes\/([\w-]+)\.css/)||[])[1],Se="decklight-theme:"+location.pathname,de="decklight-custom-themes",$e={};try{$e=JSON.parse(localStorage.getItem(de)||"{}")||{}}catch{}let te=null,ae=null,Re={};function Fe(N,X,pe){let Me=pe==="generated"?te:Re[N];return Me||(Me=document.createElement("style"),Me.media="not all",pe==="generated"?Me.dataset.generated="":Me.dataset.custom=""),Me.dataset.theme=N,Me.textContent=co(N,X),document.head.appendChild(Me),pe==="generated"?te=Me:Re[N]=Me,Me}let je=()=>[te,...Object.values(Re),...E];function _e(N){for(let X of je())X&&X!==N&&(X.media="not all")}let Ae=()=>je().find(N=>N&&N.media!=="not all")||null,st=()=>{let N=Ae();return N?N.dataset.theme:$?w.find(X=>X.media!=="not all")?.dataset.theme:_?I(_.href):void 0};function bt(){let N=getComputedStyle(t),X=Le=>Le?.match(/rgba?\(([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[\s,/]+([\d.]+))?\)/),pe=X(N.backgroundColor);(!pe||pe[4]!==void 0&&+pe[4]==0)&&(pe=X(N.backgroundImage));let Me=pe?Or([+pe[1],+pe[2],+pe[3]])<.5:!1;t.setAttribute("data-canvas",Me?"dark":"light")}_?.addEventListener("load",bt);function T(N,X=!1){if(!N||!/^[\w-]+$/.test(N))return;let pe=!1;if(ae&&te&&N===ae.name)te.media="all",_e(te),pe=!$e[N];else if($e[N]){let Me=Fe(N,$e[N],"custom");Me.media="all",_e(Me)}else if(S.has(N)){let Me=E.find(Le=>Le.dataset.theme===N);Me.media="all",_e(Me)}else{if(!C)return;if(_e(null),$){let Me=w.find(Le=>Le.dataset.theme===N);if(!Me)return;w.forEach(Le=>{Le.media=Le===Me?"all":"not all"})}else _.href=_.href.replace(/themes\/[\w-]+\.css(\?.*)?$/,`themes/${N}.css`)}if(!a.has("embedded")&&!pe)try{localStorage.setItem(Se,N)}catch{}X||c(N),d("theme",N),bt()}let Ke=typeof it<"u"?it:null,mt={added:"Added",custom:"Custom",generated:"Generated"},dt=new Map([...P.values()].map(N=>[N.pack,N.label])),G=N=>dt.get(N)??Ke?.labels?.[N]??mt[N]??N;function J(N){if($e[N])return"custom";if(ae&&N===ae.name)return"generated";if(P.has(N))return P.get(N).pack;if(S.has(N))return"added";if(Ke){for(let[X,pe]of Object.entries(Ke.packs))if(pe.includes(N))return X}return"other"}let ne=()=>{let N;if($){let pe=w.map(Me=>Me.dataset.theme);N=o.themes?.length?o.themes.filter(Me=>pe.includes(Me)):pe}else N=o.themes?.length?o.themes:typeof rt<"u"?rt:[];let X=[...S,...Object.keys($e)];if(ae&&!$e[ae.name]&&X.push(ae.name),N=[...N,...X.filter(pe=>!N.includes(pe))],Ke){let pe=new Map,Me=0;for(let Le of Ke.order)for(let qe of Ke.packs[Le]??[])pe.set(qe,Me++);N=[...N].sort((Le,qe)=>(pe.get(Le)??1e9)-(pe.get(qe)??1e9))}return N};function fe(N){let X=[];for(let pe of Ke.order){let Me=(Ke.packs[pe]??[]).filter(Le=>N.includes(Le));Me.length&&X.push([pe,Me])}for(let pe of new Set([...P.values()].map(Me=>Me.pack))){let Me=N.filter(Le=>J(Le)===pe);Me.length&&X.push([pe,Me])}for(let pe of["added","custom","generated"]){let Me=N.filter(Le=>J(Le)===pe);Me.length&&X.push([pe,Me])}return X}let ue=N=>btoa(unescape(encodeURIComponent(JSON.stringify(N)))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),Ie=N=>JSON.parse(decodeURIComponent(escape(atob(N.replace(/-/g,"+").replace(/_/g,"/")))));function Q(N,X=!1){ae={name:N.name,tokens:N.tokens};let pe=Fe(N.name,N.tokens,"generated");return pe.media="all",_e(pe),X||c(`\u2728 ${N.name} \u2014 \u2303T re-roll \xB7 \u2303\u21E7T save`,2800),bt(),N.name}function s(){return Q(Ts())}function i(N){if(!ae||!te||te.media==="not all")return c("no generated theme to save \u2014 \u2303T to generate one"),null;let X=N??(window.prompt?.("Save theme as:",ae.name.replace(/^gen-/,""))||"");if(X=String(X).toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40),!X)return null;((typeof rt<"u"?rt:[]).includes(X)||w.some(Le=>Le.dataset.theme===X))&&(X="custom-"+X),$e[X]=ae.tokens;try{localStorage.setItem(de,JSON.stringify($e))}catch{}let Me=Fe(X,$e[X],"custom");if(Me.media="all",te?.remove(),te=null,ae=null,_e(Me),!a.has("embedded"))try{localStorage.setItem(Se,X)}catch{}try{let Le=new Blob([co(X,$e[X])],{type:"text/css"}),qe=document.createElement("a");qe.href=URL.createObjectURL(Le),qe.download=`${X}.css`,qe.click(),setTimeout(()=>URL.revokeObjectURL(qe.href),5e3)}catch{}return c(`saved ${X} \u2014 ${X}.css downloaded`,2200),X}let O=null;function De(N=!1){return O?(clearTimeout(O.timer),O=null,N||c("theme cycle cancelled"),!0):!1}function B(N){let X=ne();if(!C||X.length<2)return;if(O){let qe=O;clearTimeout(qe.timer),O=null,qe.dir===N?T(qe.name):c("theme cycle cancelled");return}let pe=st(),Me=Math.max(0,X.indexOf(pe)),Le=X[(Me+N+X.length)%X.length];if(Ke&&J(Le)!==J(pe)){let qe=N>0?".":",",M=N>0?",":".";O={dir:N,name:Le,timer:setTimeout(()=>{O=null},4e3)},c(`\u2933 ${G(J(Le))} pack next (${Le}) \u2014 ${qe} confirms \xB7 ${M} or Esc cancels`,4e3);return}T(Le)}a.has("embedded")&&window.addEventListener("message",N=>{let X=N.data&&N.data.__decklightPreview;!X||N.source!==window.parent||(X.gen?Q(X.gen,!0):X.theme?T(X.theme,!0):X.goto&&g().goto(X.goto[0],X.goto[1]??0))});function Pe(){let N=st(),X=$e[N]?{name:N,tokens:$e[N]}:ae&&N===ae.name?ae:null;return X?"?embedded&gen="+ue(X):N?"?embedded&theme="+encodeURIComponent(N):"?embedded"}function _t(){let N=a.get("gen");if(N)try{let Me=Ie(N);if(Me&&Me.tokens){Q({name:Me.name||"gen-preview",tokens:Me.tokens},!0);return}}catch{}let X=null;try{X=localStorage.getItem(Se)}catch{}let pe=a.get("theme")||X;pe&&T(pe,!0)}let W="\0generate",ye="pack:",ie="back",Ze="all",v="browse",ze="",f=N=>N.charCodeAt(0)<32,Y=null,F=0,Ce,ce=[],Ne=null,ee="",nt="packs",pt=()=>Ke?"packs":"all",ut=()=>m?.()?.available()===!0,ke=()=>m?.()?.base()??"",Ee=()=>ut()?[v]:[],re=null,Ge=N=>(re?.themes??[]).find(X=>X.qualified===N);async function ht(){re={loading:!0,themes:[],stale:[]},Wt("browse");let N;try{let X=await fetch(ke()+"/edit/theme/browse"),pe=await X.json().catch(()=>({}));N=X.ok&&pe.ok?{themes:pe.themes??[],stale:pe.stale??[],cacheOnly:pe.cacheOnly!==!1}:{themes:[],stale:[],error:pe.error||`the author server said ${X.status}`}}catch{N={themes:[],stale:[],error:"the author server did not answer"}}!Y||nt!=="browse"||(re=N,Wt("browse"))}async function tt(N){let X=Y?.querySelector(".tp-caption");X&&(X.textContent=`installing ${N}\u2026`);try{let pe=await fetch(ke()+"/edit/theme/add",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ref:N})}),Me=await pe.json().catch(()=>({}));if(!pe.ok){let Le=[Me.error,...Me.problems??[]].filter(Boolean).join(" \xB7 ");X&&(X.textContent=Le||`install failed (${pe.status})`),c(`${N}: ${Me.error||"install refused"}`,3600);return}Kt(),c(`installed ${Me.name}${Me.replaced?" (replaced)":""} \u2014 Z takes it back`,2800),d("theme",`${N} installed from a marketplace`)}catch{X&&(X.textContent="the author server did not answer")}}function He(N){let X=g().state,pe="#/"+X.slide+"/"+X.step;if(N===W||$e[N]||ae&&N===ae.name){let Me=N===W?Ne:$e[N]?{name:N,tokens:$e[N]}:ae;return location.pathname+"?embedded&gen="+ue(Me)+pe}return location.pathname+"?embedded&theme="+encodeURIComponent(N)+pe}function gt(N){N.textContent=Ne?`\u2728 ${Ne.name} \u2014 \u2303T re-rolls`:"\u2728 Generate new\u2026"}function Yt(){Ne=Ts();let N=ce.indexOf(W);N<0||(gt(Y.querySelectorAll(".tp-row")[N]),Bt(N,!0))}function nn(){let N=Y.querySelector(".tp-list"),X=st(),pe=ne();if(nt==="browse"){let qe=(re?.themes??[]).filter(M=>!ee||M.qualified.includes(ee));ce=[ie,...qe.map(M=>ze+M.qualified)]}else if(ee)ce=pe.filter(qe=>qe.includes(ee));else if(!Ke||nt==="all")ce=Ke?[W,ie,...pe]:[W,...pe,...Ee()];else if(nt==="packs")ce=[W,...fe(pe).map(([qe])=>ye+qe),Ze,...Ee()];else{let qe=nt.slice(5);ce=[ie,...fe(pe).find(([M])=>M===qe)?.[1]??[]]}N.textContent="";let Me=(qe,M)=>{let j=document.createElement("span");j.className="tp-tag",j.textContent=M,qe.appendChild(j)};if(ce.forEach((qe,M)=>{let j=document.createElement("div");if(j.setAttribute("role","option"),qe===W)j.className="tp-row tp-gen",gt(j);else if(qe===ie)j.className="tp-row tp-back",j.textContent=pt()==="packs"?"\u2190 packs":"\u2190 themes";else if(qe===v)j.className="tp-row tp-browse",j.textContent="\u2315 Browse marketplaces\u2026";else if(qe.startsWith(ze)){let H=Ge(qe.slice(ze.length));j.className="tp-row tp-mkt",j.textContent=H?.name??qe.slice(ze.length);let we=S.has(H?.name)?"installed":H?.marketplace;we&&Me(j,we)}else if(qe===Ze)j.className="tp-row tp-all",j.textContent="\u2733 all themes",Me(j,String(pe.length));else if(qe.startsWith(ye)){let H=qe.slice(ye.length),we=fe(pe).find(([Ye])=>Ye===H)?.[1]??[];j.className="tp-row tp-pack"+(we.includes(X)?" tp-current":""),j.textContent=`\u25B8 ${G(H)}`,Me(j,String(we.length))}else{j.className="tp-row"+(qe===X?" tp-current":""),j.textContent=qe;let H=$e[qe]?"custom":ae&&qe===ae.name?"generated":P.has(qe)?P.get(qe).label:S.has(qe)?"added":ee&&Ke?G(J(qe)):null;H&&Me(j,H)}j.addEventListener("mouseenter",()=>Bt(M,!1)),j.addEventListener("click",()=>{Bt(M,!0),Ct()}),N.appendChild(j)}),!ce.length){let qe=document.createElement("div");qe.className="tp-none",qe.textContent="no themes match",N.appendChild(qe)}if(nt==="browse"){let qe=document.createElement("div");qe.className="tp-none",qe.textContent=re?.loading?"reading the catalogs\u2026":re?.error?re.error:ce.some(M=>M.startsWith(ze))?re.stale?.length?`from the cache \xB7 never fetched: ${re.stale.join(", ")} \u2014 marketplace update`:"from the cache \u2014 listing never goes to the network":ee?"no marketplace theme matches":"no themes in the marketplaces you have registered",N.appendChild(qe)}let Le=Y.querySelector(".tp-filter");Le.textContent=ee||"type to filter\u2026",Le.classList.toggle("tp-active",!!ee)}function It(){let N=st(),X=ce.indexOf(N);if(X>=0)return X;let pe=ce.indexOf(ye+J(N));return pe>=0?pe:Math.min(1,ce.length-1)}function Wt(N,X=!1){nt=N,nn(),ce.length&&Bt(It(),X)}function oe(N){ee=N.toLowerCase(),nn(),ce.length?Bt(ee?0:It(),!1):Y.querySelector(".tp-caption").textContent="no match"}function pn(){if(Y)return Kt();p.closeOthers(Rt);let N=ne();if(!C&&!N.length)return;ee="",nt=pt(),re=null,Y=document.createElement("div"),Y.className="decklight-theme-picker",Y.innerHTML='<div class="tp-panel"><div class="tp-side"><div class="tp-filter"></div><div class="tp-list" role="listbox" aria-label="Themes"></div></div><div class="tp-preview"><iframe title="Theme preview"></iframe><div class="tp-caption"></div></div></div>',nn(),Ut(Y,Kt),t.appendChild(Y);let X=st();X&&Dt(Y.querySelector("iframe"),X),Bt(It(),!X)}function Bt(N,X){if(!ce.length)return;F=(N+ce.length)%ce.length;let pe=ce[F];pe===W&&!Ne&&(Ne=Ts(),gt(Y.querySelectorAll(".tp-row")[F])),vn(Y.querySelectorAll(".tp-row"),F,"tp-selected");let Me=ne(),Le=pe===W?Ne?`\u2728 ${Ne.name}`:"generate new":pe===ie?pt()==="packs"?"back to packs":"back to the theme list":pe===v?"themes from the marketplaces you have registered":pe.startsWith(ze)?rn(pe.slice(ze.length)):pe===Ze?`all ${Me.length} themes, flattened`:pe.startsWith(ye)?`${G(pe.slice(ye.length))} \xB7 ${fe(Me).find(([M])=>M===pe.slice(ye.length))?.[1].length??0} themes`:Ke?`${G(J(pe))} \xB7 ${pe}`:pe;if(Y.querySelector(".tp-caption").textContent=Le,clearTimeout(Ce),pe!==W&&f(pe))return;let qe=Y.querySelector("iframe");X?Dt(qe,pe):Ce=setTimeout(()=>Dt(qe,pe),60)}function rn(N){let X=Ge(N);return X?[X.qualified,X.description,S.has(X.name)?"installed \u2014 \u23CE re-installs it":"\u23CE installs it"].filter(Boolean).join(" \xB7 "):N}let gn=!1,Lt=null;function mn(N){return N===W||$e[N]||ae&&N===ae.name?{gen:N===W?Ne:$e[N]?{name:N,tokens:$e[N]}:ae}:{theme:N}}function Dt(N,X){if(!N.dataset.booted){N.dataset.booted="1",gn=!1,N.addEventListener("load",()=>{if(gn=!0,Lt!==null&&Y){let pe=Lt;Lt=null,Dt(N,pe)}},{once:!0}),N.src=He(X);return}if(!gn){Lt=X;return}N.contentWindow?.postMessage({__decklightPreview:mn(X)},"*")}function Ct(){let N=ce[F];if(N!==void 0){if(N===W){Ne&&Q(Ne),Kt();return}if(N===ie){Wt(pt());return}if(N===Ze){Wt("all");return}if(N===v){ht();return}if(N.startsWith(ze)){tt(N.slice(ze.length));return}if(N.startsWith(ye)){Wt("pack:"+N.slice(ye.length),!0);return}T(N),Kt()}}function Kt(){clearTimeout(Ce),Y?.remove(),Y=null}let Rt=p.register({isOpen:()=>!!Y,close:Kt,keydown(N){switch(N.key){case"ArrowDown":Bt(F+1,!1);break;case"ArrowUp":Bt(F-1,!1);break;case"Enter":Ct();break;case"Backspace":oe(ee.slice(0,-1));break;case"Escape":ee?oe(""):nt!==pt()?Wt(pt()):Kt();break;default:if(N.key.length===1&&/[a-z0-9-]/i.test(N.key)){oe(ee+N.key);break}return!1}return!0}});return{applyTheme:T,currentTheme:st,themeList:ne,cycleTheme:B,cancelCyclePending:De,rollTheme:s,saveGeneratedTheme:i,adoptGenerated:Q,updateCanvas:bt,restoreSaved:_t,previewQuery:Pe,openPicker:pn,closePicker:Kt,browse(){Y||pn(),Y&&ht()},hasGenerated:()=>!!ae,rollFromPicker(){return Y&&ce[F]===W?(Yt(),!0):!1}}}ge();be();ge();be();ge();be();var uo=["A","B","C","D","E","F","G","H","X"],Lr="#edb58e",ia="#c98f6d",ld="#43302a",Rr="#b96b58",Ir="#57262c",$s="#f6f1ea",aa="#d17a70",po=`<svg viewBox="0 0 240 240" role="img" aria-label="Narrator" xmlns="http://www.w3.org/2000/svg">
243
243
  <circle cx="120" cy="120" r="116" fill="var(--block-bg, rgba(128,128,128,.14))" stroke="var(--accent, #6b7f9e)" stroke-opacity=".35" stroke-width="2"/>
244
244
  <clipPath id="dlc-bust"><circle cx="120" cy="120" r="114"/></clipPath>
245
245
  <g clip-path="url(#dlc-bust)">
246
246
  <path d="M120 164 C 94 164 71 178 61 198 L 56 240 L 184 240 L 179 198 C 169 178 146 164 120 164 Z" fill="var(--accent, #4f6fae)"/>
247
- <path d="M106 142 L 106 176 C 106 185 134 185 134 176 L 134 142 Z" fill="${Wn}"/>
248
- <path d="M106 142 L 106 156 C 114 162 126 162 134 156 L 134 142 Z" fill="${bi}"/>
247
+ <path d="M106 142 L 106 176 C 106 185 134 185 134 176 L 134 142 Z" fill="${Lr}"/>
248
+ <path d="M106 142 L 106 156 C 114 162 126 162 134 156 L 134 142 Z" fill="${ia}"/>
249
249
  <g data-idle>
250
- <circle cx="75" cy="98" r="9" fill="${Wn}"/>
251
- <circle cx="165" cy="98" r="9" fill="${Wn}"/>
252
- <path d="M120 38 C 91 38 76 62 76 93 C 76 123 96 149 120 149 C 144 149 164 123 164 93 C 164 62 149 38 120 38 Z" fill="${Wn}"/>
253
- <path d="M120 28 C 87 28 69 51 72 90 C 80 60 96 50 120 50 C 144 50 160 60 168 90 C 171 51 153 28 120 28 Z" fill="${Gc}"/>
250
+ <circle cx="75" cy="98" r="9" fill="${Lr}"/>
251
+ <circle cx="165" cy="98" r="9" fill="${Lr}"/>
252
+ <path d="M120 38 C 91 38 76 62 76 93 C 76 123 96 149 120 149 C 144 149 164 123 164 93 C 164 62 149 38 120 38 Z" fill="${Lr}"/>
253
+ <path d="M120 28 C 87 28 69 51 72 90 C 80 60 96 50 120 50 C 144 50 160 60 168 90 C 171 51 153 28 120 28 Z" fill="${ld}"/>
254
254
  <path d="M92 84 Q 103 78 114 83" stroke="#4a352c" stroke-width="4" fill="none" stroke-linecap="round"/>
255
255
  <path d="M126 83 Q 137 78 148 84" stroke="#4a352c" stroke-width="4" fill="none" stroke-linecap="round"/>
256
256
  <ellipse cx="103" cy="97" rx="7" ry="5.5" fill="#fbf7f2"/>
@@ -261,41 +261,63 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Ae=O,re=D),V===void 0&
261
261
  <circle cx="137" cy="97" r="3.2" fill="#5a4030"/>
262
262
  <circle cx="137" cy="97" r="1.5" fill="#241a14"/>
263
263
  <circle cx="138.3" cy="95.6" r=".8" fill="#fff"/>
264
- <g data-eyelid><rect x="95" y="90.5" width="16" height="12" rx="6" fill="${Wn}"/></g>
265
- <g data-eyelid><rect x="129" y="90.5" width="16" height="12" rx="6" fill="${Wn}"/></g>
266
- <path d="M120 101 L 117 115 Q 120 119 124 116" stroke="${bi}" stroke-width="3" fill="none" stroke-linecap="round"/>
264
+ <g data-eyelid><rect x="95" y="90.5" width="16" height="12" rx="6" fill="${Lr}"/></g>
265
+ <g data-eyelid><rect x="129" y="90.5" width="16" height="12" rx="6" fill="${Lr}"/></g>
266
+ <path d="M120 101 L 117 115 Q 120 119 124 116" stroke="${ia}" stroke-width="3" fill="none" stroke-linecap="round"/>
267
267
  <ellipse cx="96" cy="115" rx="6.5" ry="4" fill="#e59e7d" opacity=".4"/>
268
268
  <ellipse cx="144" cy="115" rx="6.5" ry="4" fill="#e59e7d" opacity=".4"/>
269
- <g data-mouth="X"><path d="M106 130 Q 120 136 134 130" stroke="${Vn}" stroke-width="4" fill="none" stroke-linecap="round"/></g>
270
- <g data-mouth="A"><path d="M105 130 Q 120 124 135 130 Q 120 137 105 130 Z" fill="${Vn}"/></g>
271
- <g data-mouth="B"><path d="M104 129 Q 120 122 136 129 Q 120 141 104 129 Z" fill="${Zn}"/><rect x="110" y="126" width="20" height="5" rx="2" fill="${Ar}"/></g>
272
- <g data-mouth="C"><ellipse cx="120" cy="131" rx="13" ry="8.5" fill="${Zn}"/><rect x="109" y="124.5" width="22" height="4.5" rx="2" fill="${Ar}"/></g>
273
- <g data-mouth="D"><ellipse cx="120" cy="132" rx="16" ry="12" fill="${Zn}"/><rect x="106" y="122" width="28" height="6" rx="2.5" fill="${Ar}"/><ellipse cx="120" cy="140" rx="9" ry="4.5" fill="${yi}"/></g>
274
- <g data-mouth="E"><ellipse cx="120" cy="131" rx="9" ry="7" fill="${Zn}" stroke="${Vn}" stroke-width="3"/></g>
275
- <g data-mouth="F"><ellipse cx="120" cy="131" rx="6" ry="5.5" fill="${Zn}" stroke="${Vn}" stroke-width="3.5"/></g>
276
- <g data-mouth="G"><path d="M105 128 Q 120 123 135 128 Q 120 134 105 128 Z" fill="${Vn}"/><rect x="110" y="127" width="20" height="5" rx="2" fill="${Ar}"/><path d="M108 134 Q 120 139 132 134" stroke="${Vn}" stroke-width="3" fill="none" stroke-linecap="round"/></g>
277
- <g data-mouth="H"><ellipse cx="120" cy="131" rx="12" ry="9" fill="${Zn}"/><path d="M113 125 Q 120 122 127 125 Q 127 132 120 133 Q 113 132 113 125 Z" fill="${yi}"/></g>
269
+ <g data-mouth="X"><path d="M106 130 Q 120 136 134 130" stroke="${Rr}" stroke-width="4" fill="none" stroke-linecap="round"/></g>
270
+ <g data-mouth="A"><path d="M105 130 Q 120 124 135 130 Q 120 137 105 130 Z" fill="${Rr}"/></g>
271
+ <g data-mouth="B"><path d="M104 129 Q 120 122 136 129 Q 120 141 104 129 Z" fill="${Ir}"/><rect x="110" y="126" width="20" height="5" rx="2" fill="${$s}"/></g>
272
+ <g data-mouth="C"><ellipse cx="120" cy="131" rx="13" ry="8.5" fill="${Ir}"/><rect x="109" y="124.5" width="22" height="4.5" rx="2" fill="${$s}"/></g>
273
+ <g data-mouth="D"><ellipse cx="120" cy="132" rx="16" ry="12" fill="${Ir}"/><rect x="106" y="122" width="28" height="6" rx="2.5" fill="${$s}"/><ellipse cx="120" cy="140" rx="9" ry="4.5" fill="${aa}"/></g>
274
+ <g data-mouth="E"><ellipse cx="120" cy="131" rx="9" ry="7" fill="${Ir}" stroke="${Rr}" stroke-width="3"/></g>
275
+ <g data-mouth="F"><ellipse cx="120" cy="131" rx="6" ry="5.5" fill="${Ir}" stroke="${Rr}" stroke-width="3.5"/></g>
276
+ <g data-mouth="G"><path d="M105 128 Q 120 123 135 128 Q 120 134 105 128 Z" fill="${Rr}"/><rect x="110" y="127" width="20" height="5" rx="2" fill="${$s}"/><path d="M108 134 Q 120 139 132 134" stroke="${Rr}" stroke-width="3" fill="none" stroke-linecap="round"/></g>
277
+ <g data-mouth="H"><ellipse cx="120" cy="131" rx="12" ry="9" fill="${Ir}"/><path d="M113 125 Q 120 122 127 125 Q 127 132 120 133 Q 113 132 113 125 Z" fill="${aa}"/></g>
278
278
  </g>
279
279
  </g>
280
- </svg>`;function jc(r,i){let l=r?.cues;if(!l?.length||!(i>=0)||r.duration&&i>=r.duration)return"X";let d=0,u=l.length-1,m=-1;for(;d<=u;){let h=d+u>>1;l[h].t<=i?(m=h,d=h+1):u=h-1}if(m<0)return"X";let f=l[m].v;return ss.includes(f)?f:"X"}function wi(r){let i=m=>Math.round(m*1e3)/1e3,l=[],d=(m,f)=>{l.length&&l[l.length-1].v===f||l.push({t:i(m),v:f})},u=0;for(let{timeline:m,gap:f=0}of r){f>0&&(d(u,"X"),u+=f);for(let h of m?.cues??[])d(u+h.t,h.v);u+=m?.duration??0}return{v:1,kind:"visemes",duration:i(u),source:"stitch",cues:l}}function xi({root:r,config:i,debugLog:l,toast:d}){let u=i.narration?.character??{},m=u.bridgeUrl??"http://127.0.0.1:8789",f=u.fallback??"amplitude",h="decklight-character:"+location.pathname,b=u.mode??"off",k=u.engine??"wav2lip",A=u.portrait??"default",P=u.solo??!1;try{let Y=JSON.parse(localStorage.getItem(h));Y?.mode&&(b=Y.mode,k=Y.engine??k,A=Y.portrait??A),typeof Y?.solo=="boolean"&&(P=Y.solo)}catch{}let M=null,T=null,C=null,F=null,ye=null,ge=null,be=null,J=0,de=!1,Oe,ke=new Map,De=new Map,xe=Y=>`${Y}|${k}|${A}`;function Le(){try{localStorage.setItem(h,JSON.stringify({mode:b,engine:k,portrait:A,solo:P}))}catch{}}function st(){r.classList.toggle("decklight-solo",P&&b!=="off"&&!!M?.classList.contains("show"))}function at(){de||(de=!0,d("lipsync bridge unreachable \u2014 run: decklight lipsync"),l("lipsync","bridge unreachable \u2014 amplitude fallback"))}function _(){if(M||(M=document.createElement("div"),M.className="decklight-character pos-"+(u.position??"br"),M.setAttribute("aria-hidden","true"),u.size&&M.style.setProperty("--character-size",u.size+"px"),r.appendChild(M)),C!==b)if(C=b,M.classList.toggle("mode-video",b==="video"),T=null,b==="video")M.innerHTML="",T=document.createElement("video"),T.muted=!0,T.playsInline=!0,T.preload="auto",M.appendChild(T);else if(u.sprites){M.innerHTML="";for(let Y of ss){if(!u.sprites[Y])continue;let Re=document.createElement("img");Re.src=u.sprites[Y],Re.setAttribute("data-mouth",Y),Re.alt="",M.appendChild(Re)}}else if(typeof u.svg=="string"&&u.svg.startsWith("#")){M.innerHTML="";let Y=document.querySelector(u.svg);Y&&M.appendChild(Y.cloneNode(!0))}else typeof u.svg=="string"&&/^\s*</.test(u.svg)?M.innerHTML=u.svg:u.svg?(M.innerHTML=os,fetch(u.svg).then(Y=>Y.text()).then(Y=>{M&&C==="viseme"&&(M.innerHTML=Y)}).catch(()=>{})):M.innerHTML=os}function qe(){_(),M.classList.add("show"),J||(J=setInterval(Ce,33)),st()}function Je(){J&&(clearInterval(J),J=0),M?.classList.remove("show"),T?.pause(),ye=null,ge=null,je("X"),st()}function je(Y){Y===be||!M||(be=Y,M.setAttribute("data-viseme",Y))}let O=null,D=null,V=null,re=null;function Ae(){if(f!=="amplitude"||!F)return!1;if(V===F)return!!D;V=F;try{O??=new(window.AudioContext||window.webkitAudioContext);let Y=O.createMediaElementSource(F);D=O.createAnalyser(),D.fftSize=512,Y.connect(D),D.connect(O.destination),re=new Uint8Array(D.fftSize)}catch{D=null}return!!D}function Ke(){D.getByteTimeDomainData(re);let Y=0;for(let y=0;y<re.length;y++){let Be=(re[y]-128)/128;Y+=Be*Be}let Re=Math.sqrt(Y/re.length);return Re<.02?"X":Re<.06?"B":Re<.12?"C":"D"}function Ce(){if(M?.classList.contains("show")){if(b==="video"){T&&F&&T.readyState>=2&&!F.paused&&Math.abs(T.currentTime-F.currentTime)>.15&&(T.currentTime=F.currentTime);return}if(!F||F.paused||F.ended){je("X");return}ye?je(jc(ye,F.currentTime)):f==="hide"?je("X"):Ae()?je(Ke()):je("X")}}function s(Y,Re,y){if(!ke.has(Y)){let Be=(async()=>{let w=await Re;if(!w)return null;let pe=Date.now(),Se=await fetch(`${m}/viseme?text=${encodeURIComponent(y??"")}`,{method:"POST",headers:{"content-type":"audio/wav"},body:w.blob});if(!Se.ok)throw new Error(String(Se.status));let it=await Se.json();return l("lipsync",`visemes ${Y} \xB7 ${it.cues?.length??0} cues \u2192 ${((Date.now()-pe)/1e3).toFixed(1)}s`),it})();Be.catch(()=>{ke.get(Y)===Be&&ke.delete(Y)}),ke.set(Y,Be)}return ke.get(Y)}function o(Y,Re){let y=xe(Y);if(!De.has(y)){let Be=(async()=>{let w=await Re;if(!w)return null;let pe=Date.now(),Se=await fetch(`${m}/video?engine=${k}&portrait=${encodeURIComponent(A)}`,{method:"POST",headers:{"content-type":"audio/wav"},body:w.blob});if(!Se.ok)throw new Error(String(Se.status));let it=await Se.blob(),Ee=Se.headers?.get?.("x-lipsync-cached")==="1";return l("lipsync",`video ${Y} \xB7 ${k} \u2192 ${((Date.now()-pe)/1e3).toFixed(1)}s${Ee?" (cached)":""}`),URL.createObjectURL(it)})();Be.catch(()=>{De.get(y)===Be&&De.delete(y)}),De.set(y,Be)}return De.get(y)}function N(Y,Re,y){b==="viseme"?s(Y,Re,y).catch(()=>{}):b==="video"&&o(Y,Re).catch(()=>{})}function Fe(Y,Re,y){b!=="off"&&(qe(),ge=Y,b==="viseme"?(ye=null,s(Y,Promise.resolve(Re),y).then(Be=>{ge===Y&&(ye=Be)}).catch(()=>at())):o(Y,Promise.resolve(Re)).then(Be=>{ge!==Y||!Be||!T||(T.src=Be,T.playbackRate=F?.playbackRate??1,F&&!F.paused&&(T.currentTime=F.currentTime,T.play().catch(()=>{})))}).catch(()=>at()))}function B(Y,Re){if(b==="off"||!Y||Y.live)return;qe();let y=String(Re).padStart(2,"0"),Be=`file|${Y.dir}|${y}`;ge=Be,b==="viseme"?(ye=null,(async()=>{let w=document.querySelector(`script[data-decklight-visemes="slide-${y}"]`);if(w)return JSON.parse(w.textContent);let pe=await fetch(`${Y.dir}/slide-${y}.visemes.json`);if(!pe.ok)throw new Error(String(pe.status));return pe.json()})().then(w=>{ge===Be&&(ye=w)}).catch(()=>{})):T&&(T.src=`${Y.dir}/slide-${y}.mp4`,T.playbackRate=F?.playbackRate??1,T.play().catch(()=>{}))}function ot(Y){!Y||F===Y||(F=Y,Y.addEventListener("pause",()=>{b==="video"&&T?.pause()}),Y.addEventListener("play",()=>{b==="video"&&T?.src&&T.play().catch(()=>{})}),Y.addEventListener("ratechange",()=>{T&&(T.playbackRate=Y.playbackRate)}))}async function mt(){try{let Y=await fetch(m+"/ping");Oe=Y.ok?await Y.json():null}catch{Oe=null}return Oe}function K(Y,Re={}){b=Y,Re.engine&&(k=Re.engine),Re.portrait&&(A=Re.portrait),Le(),b==="off"?Je():(de=!1,_(),P&&qe()),st(),l("lipsync",b==="off"?"character off":`character ${b}${b==="video"?` \xB7 ${k} \xB7 ${A}`:""}`)}function _e(Y){P=!!Y,Le();let Re=!!F&&!F.paused&&!F.ended;P&&b!=="off"?qe():!P&&!Re&&Je(),st(),l("lipsync",`character solo ${P?"on":"off"}`)}return{get mode(){return b},get engine(){return k},get portrait(){return A},get solo(){return P},get bridgeInfo(){return Oe},setMode:K,setSolo:_e,prefetchSentence:N,beginSentence:Fe,beginSlide:B,attachAudio:ot,stop:Je,probe:mt,ensureTimeline:s}}le();ce();function Kc(r){let i=String(r??"").replace(/[?#].*$/,"");return i.slice(0,i.lastIndexOf("/")+1)}var Wc=/^[a-z][a-z0-9+.-]*:|^\/\//i;function vi(r,i,l){let d=r?.slides?.[l-1];return d?d.url?d.url:d.file?Wc.test(d.file)?d.file:Kc(i)+d.file:null:null}function _r(r,i=Date.now()){let l=r?.expires;if(!l)return{at:null,msLeft:1/0,expired:!1};let d=new Date(l);if(Number.isNaN(d.getTime()))return{at:null,msLeft:1/0,expired:!1};let u=d.getTime()-i;return{at:d,msLeft:u,expired:u<=0}}function ki(r){if(!Number.isFinite(r))return"";if(r<=0)return"expired";let i=Math.floor(r/6e4),l=Math.floor(i/60),d=Math.floor(l/24);return d?`${d}d ${l%24}h left`:l?`${l}h ${i%60}m left`:`${Math.max(1,i)}m left`}var Tr=r=>r.toISOString().slice(0,16).replace("T"," ")+"Z";function is(r){let i=r?.source??"<voice-dir>",l=r?.bucket??"gs://<bucket>/<prefix>",d=r?.signDuration??"7d";return`node tools/publish-voices.mjs ${i} --bucket ${l} --sign ${d}`}function as(r){return r?.manifest??r?.dir??null}function Vc({hasTracks:r,used:i,printMode:l,embedded:d,voiceover:u,captionsOn:m,narrating:f}={}){return!!r&&!i&&!l&&!d&&!u&&!m&&!f}function Zc(r){let i=Number(r);return Number.isFinite(i)&&i>0?i:0}function Xc(r){let i=r?.files;if(!i)return[];if(Array.isArray(i))return i;let l={label:"Narration",dir:i};return r.ext!==void 0&&(l.ext=r.ext),r.segments!==void 0&&(l.segments=r.segments),[l]}function Ei({root:r,stage:i,config:l,params:d,printMode:u,toast:m,logOnly:f,debugLog:h,overlays:b,instance:k,syncSoundBtn:A,updateDebugState:P,downloadFromUrl:M,authorBase:T=()=>null}){let C=0,F="decklight-narration:"+location.pathname,ye=l.narration?.liveUrl??"http://127.0.0.1:8787/tts",ge=[["Zephyr","bright"],["Puck","upbeat"],["Charon","informative"],["Kore","firm"],["Fenrir","excitable"],["Leda","youthful"],["Orus","firm"],["Aoede","breezy"],["Callirrhoe","easy-going"],["Autonoe","bright"],["Enceladus","breathy"],["Iapetus","clear"],["Umbriel","easy-going"],["Algieba","smooth"],["Despina","smooth"],["Erinome","clear"],["Algenib","gravelly"],["Rasalgethi","informative"],["Laomedeia","upbeat"],["Achernar","soft"],["Alnilam","firm"],["Schedar","even"],["Gacrux","mature"],["Pulcherrima","forward"],["Achird","friendly"],["Zubenelgenubi","casual"],["Vindemiatrix","gentle"],["Sadachbia","lively"],["Sadaltager","knowledgeable"],["Sulafat","warm"]],be=ye.replace(/\/tts\/?$/,"/ping"),J=ye.replace(/\/tts\/?$/,"/engines"),de=ye.replace(/\/tts\/?$/,"/engine"),Oe=ge,ke=!0,De=null,xe=null,Le=null;function st(){return xe??=fetch(be).then(E=>E.ok?E.json():null).then(E=>E?(at(E),h("tts",`bridge: ${E.engine} \xB7 ${E.model} \xB7 ${Oe.length} voice(s)`+(ke?"":" \xB7 no style")),E):null).catch(()=>null),xe}function at(E){if(!E)return null;if(De=E.engine??null,Array.isArray(E.voices)&&E.voices.length&&(Oe=E.voices),ke=E.stylable!==!1,Oe.length&&!Oe.some(([z])=>z===O.voice)){let z=O.voice;O={...O,voice:Oe[0][0]},qt(),h("tts",`voice ${z} is not on this bridge \u2014 using ${O.voice}`),D?.live&&m(`voice ${z} \u2192 ${O.voice} (this bridge speaks its own roster)`,2600)}return E}let _=[["Warm senior engineer","Read in a warm, welcoming tone, like a friendly battle-hardened senior engineer who is still curious about new technology.","warmly"],["Professional","Read in a clear, professional tone \u2014 measured, confident, and articulate.","professionally"],["Too serious","Read in an extremely grave, deadly serious tone, as if announcing news of the utmost importance.","serious"],["Joyful","Read in a joyful, light-hearted tone, smiling through every sentence.","joyfully"],["Super excited","Read in a super-excited, high-energy tone, barely containing your enthusiasm.","excited"],["Sad","Read in a somber, melancholic tone, on the verge of a sigh.","sad"]],qe=([,E,z])=>De==="elevenlabs"?z:E,Je=Xc(l.narration),je={live:!0},O={voice:"Alnilam",tone:_[0][0],style:_[0][1]},D=Je[0]??null;try{let E=JSON.parse(localStorage.getItem(F));if(E?.live?.voice)O=E.live,D=je;else{let z=E?.track??E?.dir,ne=Je.find(ae=>as(ae)===z);ne&&(D=ne)}}catch{}let V=!1,re=null,Ae="decklight-narr-rate:"+location.pathname,Ke=1;try{let E=parseFloat(localStorage.getItem(Ae)??"");E>=.25&&E<=2&&(Ke=E)}catch{}function Ce(E){Ke=Math.round(Math.min(2,Math.max(.25,Ke+E))*100)/100;try{localStorage.setItem(Ae,String(Ke))}catch{}re&&(re.playbackRate=Ke),m(`voice speed ${Ke}\xD7`),h("narr",`rate ${Ke}\xD7`),P()}let s=xi({root:r,config:l,debugLog:h,toast:m}),o=new Map;function N(E){return(k._sections?.[E-1]?.querySelector("aside.notes")?.textContent??"").replace(/⟨CLICK⟩/g," ").replace(/\s+/g," ").trim()}function Fe(E){return(k._sections?.[E-1]?.querySelector("aside.notes")?.textContent??"").split("\u27E8CLICK\u27E9").map(ne=>ne.replace(/\s+/g," ").trim())}function B(E,z,ne){if(!E)return Promise.resolve(null);if(!o.has(z)){let ae=(async()=>{let X=Date.now();try{let ue=await fetch(ye,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:E,voice:O.voice,style:O.style})});if(!ue.ok)throw new Error(String(ue.status));let we=await ue.blob(),Me=parseFloat(ue.headers?.get?.("x-tts-cost")??"")||0;return Me&&(C+=Me),h("tts",`${ne} \xB7 ${O.voice} \xB7 ${E.length} chars \u2192 ${((Date.now()-X)/1e3).toFixed(1)}s`+(Me?` \xB7 ~$${Me.toFixed(4)}`:"")),{url:URL.createObjectURL(we),blob:we}}catch(ue){throw h("tts",`${ne} \xB7 ${O.voice} FAILED after ${((Date.now()-X)/1e3).toFixed(1)}s (${String(ue.message||ue)})`),ue}})();ae.catch(()=>{o.get(z)===ae&&o.delete(z)}),o.set(z,ae)}return o.get(z)}function ot(E){return((E??"").match(/[^.!?…]+[.!?…]+[”’"')\]]*|[^.!?…]+$/g)??[]).map(z=>z.trim()).filter(Boolean)}let mt=E=>k._records?.[E-1]?.groups.length??0;function K(E,z){let ne=Fe(E),ae=z<mt(E)?[ne[z]]:ne.slice(z),X=[],ue=new Set;for(let we of ae){let Me=ot(we);Me.length&&ue.add(X.length),X.push(...Me)}return{sentences:X,segStarts:ue}}let _e=(E,z)=>K(E,z).sentences,Y=new Set;function Re(E){if(Y.has(E))return;let z=Fe(E).length,ne=mt(E)+1;if(z<=ne)return;Y.add(E);let ae=`slide ${E}: ${z} \u27E8CLICK\u27E9 segments but ${ne} build step${ne===1?"":"s"} \u2014 the last ${z-ne} ${z-ne===1?"is":"are"} spoken on the final step`;f?.(ae),h("narr",ae)}let y=(E,z,ne)=>`${E}|s${z}|n${ne}|${O.voice}|${O.style}`;function Be(E,z,ne){let ae=_e(E,z)[ne]??"";return B(ae,y(E,z,ne),`slide ${E} seg ${z} #${ne+1}`)}let w=E=>k._sections[E-1]?.dataset.narration==="hold",pe=E=>Zc(k._sections[E-1]?.dataset.narrationPause),Se=10,it=3,Ee=0;function ze(E){let z=[],ne=k.state.slide,ae=k.state.step;for(;z.length<E&&ne<=k.state.totalSlides;){let X=mt(ne);for(;ae<=X&&z.length<E;ae++){let ue=_e(ne,ae).length;for(let we=0;we<ue&&z.length<E;we++)z.push([ne,ae,we])}ne+=1,ae=0}return z}async function oe(){let E=++Ee,z=async()=>{for(;E===Ee&&V&&D?.live;){let ne=ze(Se).find(([ae,X,ue])=>!o.has(y(ae,X,ue)));if(!ne)return;try{if(await Be(ne[0],ne[1],ne[2]),s.mode!=="off"){let[ae,X,ue]=ne;s.prefetchSentence(y(ae,X,ue),o.get(y(ae,X,ue)),ot(Fe(ae)[X])[ue]??"")}}catch{return}await new Promise(ae=>setTimeout(ae,30))}};await Promise.all(Array.from({length:it},z))}let Xe=0,gt=!1,Et=!1,me=0;function Ne(){if(!V){m("narration is off \u2014 V starts it");return}gt=!gt,gt?re?.pause():re?.src&&re.paused&&!re.ended&&re.currentTime>0?re.play().catch(()=>{}):Et||et(),m(gt?"\u23F8 narration paused \u2014 P resumes":"\u25B6 narration resumed"),h("narr",gt?"paused":"resumed"),P()}async function Ie(E,z){let ne=Xe,ae=()=>ne!==Xe||!V||!D?.live||k.state.slide!==E||k.state.step!==z;if(gt||ae())return;let X=k._records[E-1];if(z<(X?X.groups.length:0)){k.next();return}if(w(E)||E>=k.state.totalSlides)return;let ue=pe(E);if(ue>0){h("narr",`slide ${E} \u2014 holding ${ue}s before the next slide`);for(let we=ue*1e3;we>0;){if(ae())return;let Me=Date.now();await new Promise(nt=>setTimeout(nt,Math.min(150,we))),gt||(we-=Date.now()-Me)}if(gt||ae())return}k.goto(E+1,0)}async function et(){let E=k.state.slide,z=k.state.step,ne=++Xe;if(oe(),!N(E)){if(w(E)){h("narr",`hold on slide ${E} \u2014 manual advance`);return}setTimeout(()=>{ne!==Xe||!V||!D?.live||k.state.slide===E&&E<k.state.totalSlides&&k.goto(E+1,0)},400);return}Re(E);let ae=_e(E,z);if(!ae.length){setTimeout(()=>{ne===Xe&&Ie(E,z)},600);return}let X=()=>ne!==Xe||!V||k.state.slide!==E||k.state.step!==z;me=ne,Et=!0;let ue=0;try{for(let we=0;we<ae.length;we++){for(;gt;){if(X())return;await new Promise(wt=>setTimeout(wt,150))}if(X())return;let Me;try{Me=await Be(E,z,we)}catch(wt){h("narr",`sentence failed (slide ${E} seg ${z} #${we+1}) \u2014 narration stopped`),vt(tt(wt));return}if(X())return;if(!Me)continue;U(ae[we]),re??=new Audio,s.mode!=="off"&&(s.attachAudio(re),s.beginSentence(y(E,z,we),Me,ae[we])),re.src=Me.url,re.playbackRate=Ke;let nt=!1;if(await new Promise(wt=>{re.onended=wt,re.play().catch(()=>{nt=!0,wt()})}),nt){vt("\u{1F507} the browser blocked audio \u2014 click the deck once, then V \u2014 the slides wait for the voice");return}ue++}if(X())return;if(!ue&&ae.length){vt("\u{1F507} the voice did not play \u2014 auto-advance stopped \xB7 press the key left of 1 for messages");return}await Ie(E,z)}finally{me===ne&&(Et=!1)}}function tt(E){let z=String(E?.message??E);return z.startsWith("429")?"\u{1F507} voice quota exceeded (429) \u2014 auto-advance stopped \xB7 a free engine: decklight author --tts-engine chirp":/^\d{3}/.test(z)?`\u{1F507} voice bridge error ${z.slice(0,3)} \u2014 auto-advance stopped \xB7 press the key left of 1 for messages`:"\u{1F507} voice bridge unreachable \u2014 auto-advance stopped \xB7 start it with: decklight tts"}let bt=new Map,He=new Map,ft=new Set,Dt=null;function Kt(E){for(let z of document.querySelectorAll('script[type="application/json"][data-decklight-voices]'))if(z.getAttribute("data-decklight-voices")===E)try{return JSON.parse(z.textContent)}catch{return null}return null}function Vt(E){if(!bt.has(E)){let z=Kt(E);bt.set(E,z?Promise.resolve(z):fetch(E).then(ne=>{if(!ne.ok)throw new Error(`HTTP ${ne.status}`);return ne.json()}).catch(ne=>{throw bt.delete(E),ne})),bt.get(E).then(ne=>He.set(E,ne)).catch(()=>{})}return bt.get(E)}function Ot(E){let z=He.get(E.manifest);if(!z)return ft.has(E.manifest)?"hosted \u2014 the voice list did not load":(Vt(E.manifest).catch(()=>ft.add(E.manifest)).then(()=>{dt&&xt==="tracks"&&St("tracks")}),"hosted \u2014 checking\u2026");let ne=_r(z);return ne.at?ne.expired?`EXPIRED ${Tr(ne.at)} \u2014 re-sign to play`:`signed \xB7 ${ki(ne.msLeft)}`:"hosted \xB7 no expiry"}async function Q(){if(!D||D.live||!D.manifest)return Dt=null,!0;if(Dt?.track!==D)try{Dt={track:D,data:await Vt(D.manifest)}}catch(z){return Dt=null,vt(`\u{1F507} could not load the voice list for \u201C${D.label}\u201D (${D.manifest} \u2014 ${z.message}) \u2014 auto-advance stopped`),!1}let E=_r(Dt.data);return E.expired?(vt(`\u{1F507} the signed voices for \u201C${D.label}\u201D expired ${Tr(E.at)} \u2014 auto-advance stopped \xB7 re-sign: ${is(Dt.data)}`),!1):!0}function Zt(E){return D.manifest?vi(Dt?.data,D.manifest,E):`${D.dir}/slide-${String(E).padStart(2,"0")}.${D.ext??"m4a"}`}function _t(){if(!D)return;if(D.live)return et();if(!N(k.state.slide)){re?.pause();return}let E=Zt(k.state.slide);if(!E){re?.pause();return}re??=new Audio,re.src=E,re.playbackRate=Ke,s.mode!=="off"&&(s.attachAudio(re),s.beginSlide(D,k.state.slide)),re.onerror=()=>{h("narr",`no audio: ${E}`);let z=D.manifest?_r(Dt?.data):null;if(z?.at){h("narr","signed url failed \u2014 a media element cannot report the status"),vt(`\u{1F507} slide ${k.state.slide} of \u201C${D.label}\u201D would not load (signed until ${Tr(z.at)}) \u2014 auto-advance stopped \xB7 re-sign: ${is(Dt?.data)}`);return}m(`\u{1F507} no narration for slide ${k.state.slide} (${E}) \xB7 press the key left of 1 for messages`)},re.play().catch(()=>{m("\u{1F507} the browser blocked audio \u2014 click the deck once, then V")})}function vt(E="narration off"){V=!1,Xe++,Ee++,gt=!1,re?.pause(),s.stop(),m(E),h("narr",E),A()}async function Wt(){if(!D){Mt(Je.length?"tracks":"voices");return}if(V)return vt();if(Ye(),D.live&&await st(),!await Q())return;V=!0;let E=D.live?`\u26A1 ${O.voice} \xB7 ${O.tone}`:D.label;m(`\u{1F50A} ${E} \u2014 V stops \xB7 N picks`),h("narr",`on \u2014 ${E}`),_t(),A()}k.on("slide",()=>{V&&_t()}),k.on("build",()=>{V&&D?.live&&et()});let Ht="decklight-captions:"+location.pathname,R=!1;try{R=localStorage.getItem(Ht)==="1"}catch{}let W=null;function U(E){W&&(W.textContent=E,W.classList.toggle("show",!!E))}function se(){if(W){if(V&&D?.live){U("");return}U(_e(k.state.slide,k.state.step).join(" "))}}function $e(){W=document.createElement("div"),W.className="decklight-captions",W.setAttribute("aria-live","polite"),r.appendChild(W),se()}function S(){R=!R;try{localStorage.setItem(Ht,R?"1":"0")}catch{}R?($e(),Pe()):(W?.remove(),W=null),m(`captions ${R?"on":"off"}`),h("narr",`captions ${R?"on":"off"}`)}k.on("slide",se),k.on("build",se),R&&!u&&$e();let L="\u{1F50A} this deck has a voice-over \u2014 V plays it",$=900,Z=12e3,te="decklight-narr-used:"+location.pathname,fe=!1;try{fe=localStorage.getItem(te)==="1"}catch{}let Qe=null;function Pe(){if(!Qe)return;let E=Qe;Qe=null,E.classList.remove("show"),setTimeout(()=>E.remove(),260)}function Ye(){if(Pe(),!fe){fe=!0;try{localStorage.setItem(te,"1")}catch{}}}function ut(){let E=document.createElement("button");E.type="button",E.className="decklight-narr-hint",E.setAttribute("aria-label","Play this deck\u2019s voice-over");let z=document.createElement("kbd");z.textContent="V",E.append("\u{1F50A} this deck has a voice-over \u2014 ",z," plays it"),E.addEventListener("click",()=>{Pe(),Wt()}),Qe=E,r.appendChild(E),E.offsetWidth,E.classList.add("show"),f?.(L),h("narr","voice-over hint shown"),setTimeout(Pe,Z)}Vc({hasTracks:Je.length>0,used:fe,printMode:u,embedded:!!d?.has("embedded"),voiceover:!!d?.has("voiceover"),captionsOn:R})&&setTimeout(()=>{V||ut()},$);let dt=null,pt=0,xt="tracks",ht=[],yt=null;function qt(){try{localStorage.setItem(F,JSON.stringify(D?.live?{live:O}:{track:as(D),dir:D?.dir}))}catch{}}function Ft(E,z){O={voice:yt??O.voice,tone:E,style:z},D=je,qt(),Gt(),V||(V=!0),m(`\u26A1 live voice: ${O.voice} \xB7 ${O.tone} \u2014 V stops`),h("narr",`live config \u2014 ${O.voice} \xB7 ${O.tone}`),_t()}function Pt(E,{scroll:z=!1}={}){ht.length&&(pt=on(dt.querySelectorAll(".narr-row"),E,"narr-sel",{scroll:z}))}function an(){ht[pt]?.commit()}function ln(){xt==="custom"?St("tones"):xt==="tones"||xt==="engines"?St("voices"):xt==="charvideo"?St("character"):(xt==="voices"||xt==="character")&&Je.length?St("tracks"):Gt()}let tn=!1;function I(E,z){s.setMode(E,z),Gt(),m(E==="off"?"character off":E==="viseme"?`\u{1F3AD} character on \u2014 lips follow the narration${V?"":" \xB7 V starts it"}`:`\u{1F3A5} character video \u2014 ${s.engine} \xB7 ${s.portrait}${V?"":" \xB7 V starts narration"}`)}function Tn(E){if(s.mode==="off"){m("turn the character on first \u2014 N \xB7 Character\u2026");return}s.setSolo(E),Gt(),m(E?"\u{1F3AD} solo \u2014 the narrator has the stage \xB7 N brings the slides back":"solo off \u2014 the slides are back")}let nn="Hey, this is Decklight",Xt=nn,hn=null,Cn=new Map,Qt=new Map,cn=null,Rt=new Set;function Nn(E){if(E===nn)return Cn;if(E!==cn){for(let z of Qt.values())z.then(ne=>URL.revokeObjectURL(ne)).catch(()=>{});Qt=new Map,cn=E}return Qt}let rn=(E,z)=>`${E}|${z||""}`;function gn(E,z,ne,ae=""){let X=rn(z,ae);if(!E.has(X)){let ue=(async()=>{let we=Date.now(),Me=await fetch(ye,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:ne,voice:z,style:ae})});if(!Me.ok)throw new Error(String(Me.status));let nt=await Me.blob(),wt=parseFloat(Me.headers?.get?.("x-tts-cost")??"")||0;return wt&&(C+=wt),h("tts",`preview ${z}${ae?" (styled)":""} \xB7 ${((Date.now()-we)/1e3).toFixed(1)}s`+(wt?` \xB7 ~$${wt.toFixed(4)}`:"")),URL.createObjectURL(nt)})();ue.catch(()=>{E.get(X)===ue&&E.delete(X)}),E.set(X,ue)}return E.get(X)}async function Yt(E,z,ne){let ae=`${ne}|${E}`;if(Rt.has(ae))return;Rt.add(ae);let X=E===nn,ue=X?Cn:Qt;try{h("narr",`preview prefetch ${ne} (${X?"default":"custom"} sentence)`);for(let{voice:we,style:Me}of z){if(!X&&cn!==E)return;ue.has(rn(we,Me))||await gn(ue,we,E,Me).catch(()=>{})}h("narr",`preview prefetch ${ne} complete`)}finally{Rt.delete(ae)}}function $n({voice:E,style:z="",prefetch:ne},ae){let X=Xt.trim();if(!X)return;let ue=Nn(X);ae&&(ae.textContent="\u2026"),gn(ue,E,X,z).then(we=>{ae?.isConnected&&(ae.textContent="\u25B6"),hn??=new Audio,hn.src=we,hn.play().catch(()=>{}),h("narr",`preview ${E}${z?" \xB7 styled":""}`),ne==="voices"?Yt(X,Oe.map(([Me])=>({voice:Me,style:""})),"voices"):ne==="tones"&&Yt(X,_.map(Me=>({voice:E,style:qe(Me)})),`tones:${E}`)}).catch(()=>{ae?.isConnected&&(ae.textContent="\u25B6"),m("live voice bridge unreachable \u2014 run: decklight tts"),h("narr",`preview ${E} failed`)})}function St(E){xt=E;let z=dt.querySelector(".narr-card");z.innerHTML="";let ne=document.createElement("div");if(ne.className="narr-head",z.appendChild(ne),ht=[],E==="tracks")ne.textContent="narration",Je.forEach(X=>ht.push({text:X.manifest?`\u2601 ${X.label}`:`\u{1F50A} ${X.label} (${X.dir}/)`,flavor:X.manifest?Ot(X):"",cur:X===D,commit:()=>{D=X,qt(),Gt(),m(`\u{1F50A} track: ${X.label}`),V&&Q().then(ue=>{ue&&_t()})}})),ht.push({text:"\u26A1 Live voice \u2014 synthesize on the fly\u2026",cur:D?.live,commit:()=>St("voices")}),ht.push({text:"\u{1F9D1} Character \u2014 animated narrator\u2026",cur:s.mode!=="off",commit:()=>St("character")});else if(E==="character"){ne.textContent="character \u2014 an animated narrator lip-syncs the voice",tn||(tn=!0,s.probe().then(()=>{dt&&xt==="character"&&St("character")}));let X=s.bridgeInfo,ue=X?.engines?.video??[];ht.push({text:"Off",cur:s.mode==="off",commit:()=>I("off")}),ht.push({text:"\u{1F3AD} 2D character \u2014 offline visemes",flavor:X?.engines?.viseme?"":"bridge offline \u2014 amplitude fallback",cur:s.mode==="viseme",commit:()=>I("viseme")}),ht.push({text:`\u{1F3A5} Neural video \u2014 local GPU${ue.length?"\u2026":""}`,flavor:ue.length?"":"needs the bridge \u2014 run: decklight lipsync",cur:s.mode==="video",commit:()=>{ue.length?St("charvideo"):m("video needs wav2lip/sadtalker on the bridge \u2014 run: decklight lipsync")}}),s.mode!=="off"&&ht.push({text:`${s.solo?"\u25C9":"\u25CB"} Solo \u2014 the narrator takes the stage`,flavor:"slide content steps aside",cur:s.solo,commit:()=>Tn(!s.solo)})}else if(E==="charvideo"){ne.textContent="neural video \u2014 pick engine \xB7 portrait";let X=s.bridgeInfo;for(let ue of X?.engines?.video??[])for(let we of X?.portraits?.length?X.portraits:["default"])ht.push({text:`\u{1F3A5} ${ue} \xB7 ${we}`,cur:s.mode==="video"&&s.engine===ue&&s.portrait===we,commit:()=>I("video",{engine:ue,portrait:we})})}else if(E==="engines")ne.textContent="live voice \u2014 which engine speaks",Le||fetch(J).then(X=>X.ok?X.json():{stale:!0}).then(X=>{Le=X?.stale?"stale":X?.engines??[]}).catch(()=>{Le=[]}).then(()=>{dt&&xt==="engines"&&St("engines")}),Le?Le==="stale"?ht.push({text:`\u26A1 ${De??"the bridge"} \u2014 and it cannot be changed from here`,flavor:"this voice bridge predates the engine picker",blocked:"restart it: decklight author",cur:!0,commit:()=>{}}):Le.length||ht.push({text:"no voice bridge is answering",flavor:"the engine list comes from it",blocked:"decklight author",cur:!1,commit:()=>{}}):ht.push({text:"asking the bridge\u2026",cur:!1,commit:()=>{}}),(Array.isArray(Le)?Le:[]).forEach(X=>ht.push({text:X.name,flavor:X.ready?X.cost??"":X.why??"unavailable",blocked:X.ready?null:X.fix??null,cur:!!X.current,commit:()=>Bn(X)}));else if(E==="voices"){ne.textContent="live voice \u2014 pick a voice \xB7 \u25B6 previews",ht.push({text:`\u2699 engine: ${De??"the bridge"}\u2026`,flavor:"changes which voices exist",cur:!1,commit:()=>St("engines")});let X=document.createElement("div");X.className="narr-preview-row";let ue=document.createElement("input");ue.className="narr-input narr-preview-text",ue.value=Xt,ue.placeholder="Preview sentence",ue.setAttribute("aria-label","Preview sentence"),ue.addEventListener("input",()=>{Xt=ue.value}),ue.addEventListener("keydown",Me=>{Me.key==="Escape"&&(ln(),Me.preventDefault()),Me.stopPropagation()});let we=document.createElement("button");we.type="button",we.className="narr-prev-btn narr-reset-btn",we.textContent="\u21BA",we.title="restore the default sentence",we.setAttribute("aria-label","restore the default preview sentence"),we.addEventListener("click",Me=>{Me.stopPropagation(),Xt=nn,ue.value=nn}),X.append(ue,we),z.appendChild(X),Oe.forEach(([Me,nt])=>ht.push({text:Me,flavor:nt,preview:{voice:Me,style:"",prefetch:"voices"},cur:D?.live&&O.voice===Me,commit:()=>{if(yt=Me,ke)return St("tones");Ft(De??"plain","")}}))}else if(E==="tones")ne.textContent=`live voice \xB7 ${yt??O.voice} \u2014 pick a tone \xB7 \u25B6 previews`,_.forEach(X=>{let[ue]=X,we=qe(X);ht.push({text:ue,preview:{voice:yt??O.voice,style:we,prefetch:"tones"},cur:D?.live&&O.tone===ue,commit:()=>Ft(ue,we)})}),ht.push({text:"Custom\u2026",cur:D?.live&&O.tone==="Custom",commit:()=>St("custom")});else{ne.textContent=`live voice \xB7 ${yt??O.voice} \u2014 type the delivery instruction \xB7 \u25B6 previews`;let X=document.createElement("div");X.className="narr-preview-row";let ue=document.createElement("input");ue.className="narr-input",ue.value=O.style,ue.placeholder="Read in a \u2026",ue.addEventListener("keydown",Me=>{Me.key==="Enter"?(sn(),Me.preventDefault()):Me.key==="Escape"&&(ln(),Me.preventDefault()),Me.stopPropagation()});let we=document.createElement("button");we.type="button",we.className="narr-prev-btn narr-reset-btn",we.textContent="\u25B6",we.title="preview this delivery instruction",we.setAttribute("aria-label","preview this delivery instruction"),we.addEventListener("click",Me=>{Me.stopPropagation();let nt=ue.value.trim();nt&&$n({voice:yt??O.voice,style:nt},we)}),X.append(ue,we),z.appendChild(X),setTimeout(()=>{ue.focus(),ue.select()},0),ht=[],pt=0;return}ht.forEach((X,ue)=>{let we=document.createElement("div");we.className="narr-row"+(X.cur?" narr-cur":"")+(X.blocked||X.blocked===""?" narr-blocked":"");let Me=document.createElement("span");if(Me.className="narr-row-label",Me.textContent=X.text,X.flavor){let nt=document.createElement("span");nt.className="narr-flavor",nt.textContent=X.flavor,Me.appendChild(nt)}if(we.appendChild(Me),X.blocked){let nt=document.createElement("div");nt.className="narr-fix",nt.textContent=X.blocked,we.appendChild(nt)}if(X.preview){let nt=document.createElement("button");nt.type="button",nt.className="narr-prev-btn",nt.textContent="\u25B6",nt.title=`preview ${X.preview.voice}`,nt.setAttribute("aria-label",`preview ${X.preview.voice}`),nt.addEventListener("click",wt=>{wt.stopPropagation(),$n(X.preview,nt)}),we.appendChild(nt)}we.addEventListener("mouseenter",()=>Pt(ue)),we.addEventListener("click",()=>{Pt(ue),an()}),z.appendChild(we)});let ae=ht.findIndex(X=>X.cur);Pt(Math.max(0,ae),{scroll:!0})}async function Bn(E){if(E?.name){if(!E.ready)return m(E.fix?`${E.name}: ${E.why} \u2014 ${E.fix}`:`${E.name}: ${E.why??"unavailable"}`,5e3);if(E.current)return St("voices");try{let ne=await(await fetch(de,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({engine:E.name})})).json();if(!ne.ok)return m(`${E.name}: ${ne.why??ne.error}${ne.fix?` \u2014 ${ne.fix}`:""}`,5e3);xe=Promise.resolve(at(ne)),Le=null,h("tts",`engine \u2192 ${ne.engine} \xB7 ${ne.model} \xB7 ${Oe.length} voice(s)`),m(`\u26A1 engine: ${ne.engine}${ne.cost?` \xB7 ${ne.cost}`:""} \u2014 this session only`,3200),ne.caveat&&m(ne.caveat,6e3),St("voices")}catch{m(`${E.name}: the voice bridge did not answer`,3e3)}}}function sn(){let E=dt?.querySelector(".narr-input")?.value.trim();E&&Ft("Custom",E)}function Mt(E){if(dt&&E===void 0)return Gt();dt||(dt=document.createElement("div"),dt.className="decklight-narr",dt.innerHTML='<div class="narr-card" role="listbox" aria-label="Narration"></div>',It(dt,Gt),r.appendChild(dt)),St(E??(Je.length?"tracks":"voices")),st().then(z=>{z&&dt&&xt==="voices"&&St("voices")})}function Gt(){dt?.remove(),dt=null,tn=!1}let jt=null,dn="confirm",kt=0;function Tt(){let E=[];for(let z=1;z<=k.state.totalSlides;z++)N(z)&&E.push(z);return E}function un(E){let z=Math.round(E/1e3);return z<60?`${z}s`:`${Math.floor(z/60)}m${String(z%60).padStart(2,"0")}s`}function bn(E,z={}){dn=E;let ne=jt.querySelector(".narr-card");if(E==="confirm"){let ae=z.total;ne.innerHTML=`<div class="narr-head">record offline narration</div>
281
- <div class="rec-line">\u26A1 ${O.voice} \xB7 ${O.tone}</div>
282
- <div class="rec-line">${ae} slide${ae===1?"":"s"} stitched from the sentence cache \u2014 only unheard sentences synthesize</div>
280
+ </svg>`;function cd(t,o){let a=t?.cues;if(!a?.length||!(o>=0)||t.duration&&o>=t.duration)return"X";let c=0,d=a.length-1,p=-1;for(;c<=d;){let m=c+d>>1;a[m].t<=o?(p=m,c=m+1):d=m-1}if(p<0)return"X";let g=a[p].v;return uo.includes(g)?g:"X"}function ho(t){let o=p=>Math.round(p*1e3)/1e3,a=[],c=(p,g)=>{a.length&&a[a.length-1].v===g||a.push({t:o(p),v:g})},d=0;for(let{timeline:p,gap:g=0}of t){g>0&&(c(d,"X"),d+=g);for(let m of p?.cues??[])c(d+m.t,m.v);d+=p?.duration??0}return{v:1,kind:"visemes",duration:o(d),source:"stitch",cues:a}}function la({root:t,config:o,debugLog:a,toast:c}){let d=o.narration?.character??{},p=d.bridgeUrl??"http://127.0.0.1:8789",g=d.fallback??"amplitude",m="decklight-character:"+location.pathname,w=d.mode??"off",E=d.engine??"wav2lip",S=d.portrait??"default",P=d.solo??!1;try{let ie=JSON.parse(localStorage.getItem(m));ie?.mode&&(w=ie.mode,E=ie.engine??E,S=ie.portrait??S),typeof ie?.solo=="boolean"&&(P=ie.solo)}catch{}let $=null,_=null,C=null,I=null,Se=null,de=null,$e=null,te=0,ae=!1,Re,Fe=new Map,je=new Map,_e=ie=>`${ie}|${E}|${S}`;function Ae(){try{localStorage.setItem(m,JSON.stringify({mode:w,engine:E,portrait:S,solo:P}))}catch{}}function st(){t.classList.toggle("decklight-solo",P&&w!=="off"&&!!$?.classList.contains("show"))}function bt(){ae||(ae=!0,c("lipsync bridge unreachable \u2014 run: decklight lipsync"),a("lipsync","bridge unreachable \u2014 amplitude fallback"))}function T(){if($||($=document.createElement("div"),$.className="decklight-character pos-"+(d.position??"br"),$.setAttribute("aria-hidden","true"),d.size&&$.style.setProperty("--character-size",d.size+"px"),t.appendChild($)),C!==w)if(C=w,$.classList.toggle("mode-video",w==="video"),_=null,w==="video")$.innerHTML="",_=document.createElement("video"),_.muted=!0,_.playsInline=!0,_.preload="auto",$.appendChild(_);else if(d.sprites){$.innerHTML="";for(let ie of uo){if(!d.sprites[ie])continue;let Ze=document.createElement("img");Ze.src=d.sprites[ie],Ze.setAttribute("data-mouth",ie),Ze.alt="",$.appendChild(Ze)}}else if(typeof d.svg=="string"&&d.svg.startsWith("#")){$.innerHTML="";let ie=document.querySelector(d.svg);ie&&$.appendChild(ie.cloneNode(!0))}else typeof d.svg=="string"&&/^\s*</.test(d.svg)?$.innerHTML=d.svg:d.svg?($.innerHTML=po,fetch(d.svg).then(ie=>ie.text()).then(ie=>{$&&C==="viseme"&&($.innerHTML=ie)}).catch(()=>{})):$.innerHTML=po}function Ke(){T(),$.classList.add("show"),te||(te=setInterval(Q,33)),st()}function mt(){te&&(clearInterval(te),te=0),$?.classList.remove("show"),_?.pause(),Se=null,de=null,dt("X"),st()}function dt(ie){ie===$e||!$||($e=ie,$.setAttribute("data-viseme",ie))}let G=null,J=null,ne=null,fe=null;function ue(){if(g!=="amplitude"||!I)return!1;if(ne===I)return!!J;ne=I;try{G??=new(window.AudioContext||window.webkitAudioContext);let ie=G.createMediaElementSource(I);J=G.createAnalyser(),J.fftSize=512,ie.connect(J),J.connect(G.destination),fe=new Uint8Array(J.fftSize)}catch{J=null}return!!J}function Ie(){J.getByteTimeDomainData(fe);let ie=0;for(let v=0;v<fe.length;v++){let ze=(fe[v]-128)/128;ie+=ze*ze}let Ze=Math.sqrt(ie/fe.length);return Ze<.02?"X":Ze<.06?"B":Ze<.12?"C":"D"}function Q(){if($?.classList.contains("show")){if(w==="video"){_&&I&&_.readyState>=2&&!I.paused&&Math.abs(_.currentTime-I.currentTime)>.15&&(_.currentTime=I.currentTime);return}if(!I||I.paused||I.ended){dt("X");return}Se?dt(cd(Se,I.currentTime)):g==="hide"?dt("X"):ue()?dt(Ie()):dt("X")}}function s(ie,Ze,v){if(!Fe.has(ie)){let ze=(async()=>{let f=await Ze;if(!f)return null;let Y=Date.now(),F=await fetch(`${p}/viseme?text=${encodeURIComponent(v??"")}`,{method:"POST",headers:{"content-type":"audio/wav"},body:f.blob});if(!F.ok)throw new Error(String(F.status));let Ce=await F.json();return a("lipsync",`visemes ${ie} \xB7 ${Ce.cues?.length??0} cues \u2192 ${((Date.now()-Y)/1e3).toFixed(1)}s`),Ce})();ze.catch(()=>{Fe.get(ie)===ze&&Fe.delete(ie)}),Fe.set(ie,ze)}return Fe.get(ie)}function i(ie,Ze){let v=_e(ie);if(!je.has(v)){let ze=(async()=>{let f=await Ze;if(!f)return null;let Y=Date.now(),F=await fetch(`${p}/video?engine=${E}&portrait=${encodeURIComponent(S)}`,{method:"POST",headers:{"content-type":"audio/wav"},body:f.blob});if(!F.ok)throw new Error(String(F.status));let Ce=await F.blob(),ce=F.headers?.get?.("x-lipsync-cached")==="1";return a("lipsync",`video ${ie} \xB7 ${E} \u2192 ${((Date.now()-Y)/1e3).toFixed(1)}s${ce?" (cached)":""}`),URL.createObjectURL(Ce)})();ze.catch(()=>{je.get(v)===ze&&je.delete(v)}),je.set(v,ze)}return je.get(v)}function O(ie,Ze,v){w==="viseme"?s(ie,Ze,v).catch(()=>{}):w==="video"&&i(ie,Ze).catch(()=>{})}function De(ie,Ze,v){w!=="off"&&(Ke(),de=ie,w==="viseme"?(Se=null,s(ie,Promise.resolve(Ze),v).then(ze=>{de===ie&&(Se=ze)}).catch(()=>bt())):i(ie,Promise.resolve(Ze)).then(ze=>{de!==ie||!ze||!_||(_.src=ze,_.playbackRate=I?.playbackRate??1,I&&!I.paused&&(_.currentTime=I.currentTime,_.play().catch(()=>{})))}).catch(()=>bt()))}function B(ie,Ze,v=null){if(w==="off"||!ie||ie.live)return;Ke();let ze=String(Ze).padStart(2,"0"),f=v==null?`slide-${ze}`:`slide-${ze}-${String(v).padStart(2,"0")}`,Y=`file|${ie.dir}|${f}`;if(de!==Y){if(de=Y,w==="viseme")Se=null,(async()=>{let F=document.querySelector(`script[data-decklight-visemes="${f}"]`);if(F)return JSON.parse(F.textContent);let Ce=await fetch(`${ie.dir}/${f}.visemes.json`);if(!Ce.ok)throw new Error(String(Ce.status));return Ce.json()})().then(F=>{de===Y&&(Se=F)}).catch(()=>{});else if(_){let F=`${ie.dir}/slide-${ze}.mp4`;if(_.src===new URL(F,location.href).href)return;_.src=F,_.playbackRate=I?.playbackRate??1,_.play().catch(()=>{})}}}function Pe(ie){!ie||I===ie||(I=ie,ie.addEventListener("pause",()=>{w==="video"&&_?.pause()}),ie.addEventListener("play",()=>{w==="video"&&_?.src&&_.play().catch(()=>{})}),ie.addEventListener("ratechange",()=>{_&&(_.playbackRate=ie.playbackRate)}))}async function _t(){try{let ie=await fetch(p+"/ping");Re=ie.ok?await ie.json():null}catch{Re=null}return Re}function W(ie,Ze={}){w=ie,Ze.engine&&(E=Ze.engine),Ze.portrait&&(S=Ze.portrait),Ae(),w==="off"?mt():(ae=!1,T(),P&&Ke()),st(),a("lipsync",w==="off"?"character off":`character ${w}${w==="video"?` \xB7 ${E} \xB7 ${S}`:""}`)}function ye(ie){P=!!ie,Ae();let Ze=!!I&&!I.paused&&!I.ended;P&&w!=="off"?Ke():!P&&!Ze&&mt(),st(),a("lipsync",`character solo ${P?"on":"off"}`)}return{get mode(){return w},get engine(){return E},get portrait(){return S},get solo(){return P},get bridgeInfo(){return Re},setMode:W,setSolo:ye,prefetchSentence:O,beginSentence:De,beginSlide:B,attachAudio:Pe,stop:mt,probe:_t,ensureTimeline:s}}ge();be();function ca(t){let o=String(t??"").replace(/[?#].*$/,"");return o.slice(0,o.lastIndexOf("/")+1)}var da=/^[a-z][a-z0-9+.-]*:|^\/\//i;function ua(t,o,a){let c=t?.slides?.[a-1];return c?c.url?c.url:c.file?da.test(c.file)?c.file:ca(o)+c.file:null:null}function pa(t,o,a,c){let d=t?.slides?.[a-1]?.segments?.[c-1];return d?d.url?d.url:d.file?da.test(d.file)?d.file:ca(o)+d.file:null:null}function Yr(t,o=Date.now()){let a=t?.expires;if(!a)return{at:null,msLeft:1/0,expired:!1};let c=new Date(a);if(Number.isNaN(c.getTime()))return{at:null,msLeft:1/0,expired:!1};let d=c.getTime()-o;return{at:c,msLeft:d,expired:d<=0}}function ha(t){if(!Number.isFinite(t))return"";if(t<=0)return"expired";let o=Math.floor(t/6e4),a=Math.floor(o/60),c=Math.floor(a/24);return c?`${c}d ${a%24}h left`:a?`${a}h ${o%60}m left`:`${Math.max(1,o)}m left`}var Cs=t=>t.toISOString().slice(0,16).replace("T"," ")+"Z";function mo(t){let o=t?.source??"<voice-dir>",a=t?.bucket??"gs://<bucket>/<prefix>",c=t?.signDuration??"7d";return`node tools/publish-voices.mjs ${o} --bucket ${a} --sign ${c}`}function fo(t){return t?.manifest??t?.dir??null}function dd({hasTracks:t,used:o,printMode:a,embedded:c,voiceover:d,captionsOn:p,narrating:g}={}){return!!t&&!o&&!a&&!c&&!d&&!p&&!g}var ud=.25,pd=.5,hd=1;function go(t,o,a){if(t!=null&&String(t).trim()!==""){let c=Number(t);if(Number.isFinite(c)&&c>=0)return c}return typeof o=="number"&&Number.isFinite(o)&&o>=0?o:a}var md=(t,o)=>go(t,o,ud);function Ns(t){let o=(t??[]).map(c=>String(c??"").replace(/\s+/g," ").trim());if(o.filter(Boolean).length<2)return null;let a=0;return o.map(c=>c?++a:null)}var bo=t=>String(t??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/-/g,"_").toLowerCase();function ga(t){return bo(t).split(/\s+/).filter(Boolean).map(o=>o.startsWith("lang:")?{lang:o.slice(5)}:{any:o}).filter(o=>o.lang!=="")}function fd(t,o,a){let c=Array.isArray(a)?a:ga(a);if(!c.length)return!0;let d=bo(t),p=bo(o);return c.every(g=>g.lang!==void 0?p.startsWith(g.lang):d.includes(g.any)||p.includes(g.any))}function ma(t,o=0){let a=(t??[]).map(d=>String(d??"").replace(/\s+/g," ").trim()),c=Ns(a);if(!c){let d=a.filter(Boolean).join(" ");return d?[{seg:0,step:0,file:null,text:d}]:[]}return a.map((d,p)=>d?{seg:p,step:Math.min(p,o),file:c[p],text:d}:null).filter(Boolean)}function gd(t){let o=new Uint8Array(t.length*2),a=new DataView(o.buffer);for(let c=0;c<t.length;c++){let d=Math.max(-1,Math.min(1,t[c]));a.setInt16(c*2,Math.round(d*(d<0?32768:32767)),!0)}return o}function fa({engine:t,voice:o,mine:a=!1}={},c=[]){let d=S=>String(S??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40),p=a?"voices/me":`voices/${d(o)||d(t)||"take"}`,g=new Set(c),m=p;for(let S=2;g.has(m);S++)m=`${p}-${S}`;let w=m===p?"":`, take ${m.slice(p.length+1)}`,E=a?`My voice${w}`:`${o||"Narration"}${t?` \xB7 ${t}`:""}${w}`;return{dir:m,label:E}}function bd(t){let o=t?.files;if(!o)return[];if(Array.isArray(o))return o;let a={label:"Narration",dir:o};return t.ext!==void 0&&(a.ext=t.ext),t.segments!==void 0&&(a.segments=t.segments),[a]}function ba({root:t,stage:o,config:a,params:c,printMode:d,toast:p,logOnly:g,debugLog:m,overlays:w,instance:E,syncSoundBtn:S,updateDebugState:P,downloadFromUrl:$,authorBase:_=()=>null,authorReady:C=()=>Promise.resolve()}){let I=0,Se="decklight-narration:"+location.pathname,de=a.narration?.liveUrl??"http://127.0.0.1:8787/tts",$e=[["Zephyr","bright"],["Puck","upbeat"],["Charon","informative"],["Kore","firm"],["Fenrir","excitable"],["Leda","youthful"],["Orus","firm"],["Aoede","breezy"],["Callirrhoe","easy-going"],["Autonoe","bright"],["Enceladus","breathy"],["Iapetus","clear"],["Umbriel","easy-going"],["Algieba","smooth"],["Despina","smooth"],["Erinome","clear"],["Algenib","gravelly"],["Rasalgethi","informative"],["Laomedeia","upbeat"],["Achernar","soft"],["Alnilam","firm"],["Schedar","even"],["Gacrux","mature"],["Pulcherrima","forward"],["Achird","friendly"],["Zubenelgenubi","casual"],["Vindemiatrix","gentle"],["Sadachbia","lively"],["Sadaltager","knowledgeable"],["Sulafat","warm"]],te=de.replace(/\/tts\/?$/,"/ping"),ae=de.replace(/\/tts\/?$/,"/voices/install"),Re=de.replace(/\/tts\/?$/,"/engines"),Fe=de.replace(/\/tts\/?$/,"/engine"),je=$e,_e=!0,Ae=null,st=null,bt=new Set,T=null,Ke=!1,mt=null;function dt(){return T??=fetch(te).then(b=>b.ok?b.json():null).then(b=>b?(Ke=!0,G(b),m("tts",`bridge: ${b.engine} \xB7 ${b.model} \xB7 ${je.length} voice(s)`+(_e?"":" \xB7 no style")),b):null).catch(()=>null),T}function G(b){if(!b)return null;if(Ae=b.engine??null,st=typeof b.caveat=="string"?b.caveat:null,Array.isArray(b.voices)&&b.voices.length&&(je=b.voices),_e=b.stylable!==!1,je.length&&!je.some(([A])=>A===Ie.voice)){let A=Ie.voice;Ie={...Ie,voice:je[0][0]},$n(),m("tts",`voice ${A} is not on this bridge \u2014 using ${Ie.voice}`),Q?.live&&p(`voice ${A} \u2192 ${Ie.voice} (this bridge speaks its own roster)`,2600)}return b}let J=[["Warm senior engineer","Read in a warm, welcoming tone, like a friendly battle-hardened senior engineer who is still curious about new technology.","warmly"],["Professional","Read in a clear, professional tone \u2014 measured, confident, and articulate.","professionally"],["Too serious","Read in an extremely grave, deadly serious tone, as if announcing news of the utmost importance.","serious"],["Joyful","Read in a joyful, light-hearted tone, smiling through every sentence.","joyfully"],["Super excited","Read in a super-excited, high-energy tone, barely containing your enthusiasm.","excited"],["Sad","Read in a somber, melancholic tone, on the verge of a sigh.","sad"]],ne=([,b,A])=>Ae==="elevenlabs"?A:b,fe=bd(a.narration),ue={live:!0},Ie={voice:"Alnilam",tone:J[0][0],style:J[0][1]},Q=fe[0]??null;try{let b=JSON.parse(localStorage.getItem(Se));if(b?.live?.voice)Ie=b.live,Q=ue;else{let A=b?.track??b?.dir,R=fe.find(U=>fo(U)===A);R&&(Q=R)}}catch{}let s=!1,i=null,O="decklight-narr-rate:"+location.pathname,De=1;try{let b=parseFloat(localStorage.getItem(O)??"");b>=.25&&b<=2&&(De=b)}catch{}function B(b){De=Math.round(Math.min(2,Math.max(.25,De+b))*100)/100;try{localStorage.setItem(O,String(De))}catch{}i&&(i.playbackRate=De),p(`voice speed ${De}\xD7`),m("narr",`rate ${De}\xD7`),P()}let Pe=la({root:t,config:a,debugLog:m,toast:p}),_t=new Map;function W(b){return(E._sections?.[b-1]?.querySelector("aside.notes")?.textContent??"").replace(/⟨CLICK⟩/g," ").replace(/\s+/g," ").trim()}function ye(b){return(E._sections?.[b-1]?.querySelector("aside.notes")?.textContent??"").split("\u27E8CLICK\u27E9").map(R=>R.replace(/\s+/g," ").trim())}function ie(b,A,R){if(!b)return Promise.resolve(null);if(!_t.has(A)){let U=(async()=>{let V=Date.now();try{let he=await fetch(de,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:b,voice:Ie.voice,style:Ie.style})});if(!he.ok)throw new Error(String(he.status));let D=await he.blob(),se=parseFloat(he.headers?.get?.("x-tts-cost")??"")||0;return se&&(I+=se),m("tts",`${R} \xB7 ${Ie.voice} \xB7 ${b.length} chars \u2192 ${((Date.now()-V)/1e3).toFixed(1)}s`+(se?` \xB7 ~$${se.toFixed(4)}`:"")),{url:URL.createObjectURL(D),blob:D}}catch(he){throw m("tts",`${R} \xB7 ${Ie.voice} FAILED after ${((Date.now()-V)/1e3).toFixed(1)}s (${String(he.message||he)})`),he}})();U.catch(()=>{_t.get(A)===U&&_t.delete(A)}),_t.set(A,U)}return _t.get(A)}function Ze(b){return((b??"").match(/[^.!?…]+[.!?…]+[”’"')\]]*|[^.!?…]+$/g)??[]).map(A=>A.trim()).filter(Boolean)}let v=b=>E._records?.[b-1]?.groups.length??0;function ze(b,A){let R=ye(b),U=A<v(b)?[R[A]]:R.slice(A),V=[],he=new Set;for(let D of U){let se=Ze(D);se.length&&he.add(V.length),V.push(...se)}return{sentences:V,segStarts:he}}let f=(b,A)=>ze(b,A).sentences,Y=new Set;function F(b){if(Y.has(b))return;let A=ye(b).length,R=v(b)+1;if(A<=R)return;Y.add(b);let U=`slide ${b}: ${A} \u27E8CLICK\u27E9 segments but ${R} build step${R===1?"":"s"} \u2014 the last ${A-R} ${A-R===1?"is":"are"} spoken on the final step`;g?.(U),m("narr",U)}let Ce=(b,A,R)=>`${b}|s${A}|n${R}|${Ie.voice}|${Ie.style}`;function ce(b,A,R){let U=f(b,A)[R]??"";return ie(U,Ce(b,A,R),`slide ${b} seg ${A} #${R+1}`)}let Ne=b=>E._sections[b-1]?.dataset.narration==="hold",ee=b=>go(E._sections[b-1]?.dataset.narrationPause,a.narration?.slidePause,hd),nt=b=>go(E._sections[b-1]?.dataset.narrationBeatPause,a.narration?.beatPause,pd),pt=b=>md(E._sections[b-1]?.dataset.narrationSentencePause,a.narration?.sentencePause);async function ut(b,A){if(!(b>0))return!He&&!A();for(let R=b*1e3;R>0;){if(A())return!1;let U=Date.now();await new Promise(V=>setTimeout(V,Math.min(150,R))),He||(R-=Date.now()-U)}return!He&&!A()}let ke=10,Ee=3,re=0;function Ge(b){let A=[],R=E.state.slide,U=E.state.step;for(;A.length<b&&R<=E.state.totalSlides;){let V=v(R);for(;U<=V&&A.length<b;U++){let he=f(R,U).length;for(let D=0;D<he&&A.length<b;D++)A.push([R,U,D])}R+=1,U=0}return A}async function ht(){let b=++re,A=async()=>{for(;b===re&&s&&Q?.live;){let R=Ge(ke).find(([U,V,he])=>!_t.has(Ce(U,V,he)));if(!R)return;try{if(await ce(R[0],R[1],R[2]),Pe.mode!=="off"){let[U,V,he]=R;Pe.prefetchSentence(Ce(U,V,he),_t.get(Ce(U,V,he)),Ze(ye(U)[V])[he]??"")}}catch{return}await new Promise(U=>setTimeout(U,30))}};await Promise.all(Array.from({length:Ee},A))}let tt=0,He=!1,gt=!1,Yt=0;function nn(){if(!s){p("narration is off \u2014 \u23B5 starts it");return}He=!He,He?i?.pause():i?.src&&i.paused&&!i.ended&&i.currentTime>0?i.play().catch(()=>{}):gt||oe(),p(He?"\u23F8 narration paused \u2014 \u23B5 resumes":"\u25B6 narration resumed"),m("narr",He?"paused":"resumed"),P()}let It=()=>Q?.live?"live":Q?"file":null;async function Wt(b,A,{mode:R="live",endOfSlide:U=!1}={}){let V=tt,he=()=>V!==tt||!s||It()!==R||E.state.slide!==b||E.state.step!==A;if(He||he())return;let D=async(Xe,Je)=>(Xe>0&&m("narr",`slide ${b} \u2014 holding ${Xe}s before ${Je}`),ut(Xe,he)),se=E._records[b-1];if(!U&&A<(se?se.groups.length:0)){if(!await D(nt(b),"the next build"))return;E.next();return}Ne(b)||b>=E.state.totalSlides||await D(ee(b),"the next slide")&&E.goto(b+1,0)}async function oe(){let b=E.state.slide,A=E.state.step,R=++tt;if(ht(),!W(b)){if(Ne(b)){m("narr",`hold on slide ${b} \u2014 manual advance`);return}setTimeout(()=>{R!==tt||!s||!Q?.live||E.state.slide===b&&b<E.state.totalSlides&&E.goto(b+1,0)},400);return}F(b);let U=f(b,A);if(!U.length){setTimeout(()=>{R===tt&&Wt(b,A)},600);return}let V=()=>R!==tt||!s||E.state.slide!==b||E.state.step!==A;Yt=R,gt=!0;let he=0;try{for(let D=0;D<U.length;D++){for(;He;){if(V())return;await new Promise(Je=>setTimeout(Je,150))}if(V())return;let se;try{se=await ce(b,A,D)}catch(Je){m("narr",`sentence failed (slide ${b} seg ${A} #${D+1}) \u2014 narration stopped`),H(pn(Je));return}if(V())return;if(!se)continue;ot(U[D]),i??=new Audio,Pe.mode!=="off"&&(Pe.attachAudio(i),Pe.beginSentence(Ce(b,A,D),se,U[D])),i.onended=null,i.onerror=null,i.src=se.url,i.playbackRate=De;let Xe=!1;if(await new Promise(Je=>{i.onended=Je,i.play().catch(()=>{Xe=!0,Je()})}),Xe){H("\u{1F507} the browser blocked audio \u2014 click the deck once, then V \u2014 the slides wait for the voice");return}if(he++,D<U.length-1&&!await ut(pt(b),V))return}if(V())return;if(!he&&U.length){H("\u{1F507} the voice did not play \u2014 auto-advance stopped \xB7 press the key left of 1 for messages");return}await Wt(b,A)}finally{Yt===R&&(gt=!1)}}function pn(b){let A=String(b?.message??b);return A.startsWith("429")?"\u{1F507} voice quota exceeded (429) \u2014 auto-advance stopped \xB7 a free engine: decklight author --tts-engine chirp":/^\d{3}/.test(A)?`\u{1F507} voice bridge error ${A.slice(0,3)} \u2014 auto-advance stopped \xB7 press the key left of 1 for messages`:"\u{1F507} voice bridge unreachable \u2014 auto-advance stopped \xB7 start it with: decklight tts"}let Bt=new Map,rn=new Map,gn=new Set,Lt=null;function mn(b){for(let A of document.querySelectorAll('script[type="application/json"][data-decklight-voices]'))if(A.getAttribute("data-decklight-voices")===b)try{return JSON.parse(A.textContent)}catch{return null}return null}function Dt(b){if(!Bt.has(b)){let A=mn(b);Bt.set(b,A?Promise.resolve(A):fetch(b).then(R=>{if(!R.ok)throw new Error(`HTTP ${R.status}`);return R.json()}).catch(R=>{throw Bt.delete(b),R})),Bt.get(b).then(R=>rn.set(b,R)).catch(()=>{})}return Bt.get(b)}function Ct(b){let A=rn.get(b.manifest);if(!A)return gn.has(b.manifest)?"hosted \u2014 the voice list did not load":(Dt(b.manifest).catch(()=>gn.add(b.manifest)).then(()=>{qt&&St==="tracks"&&me("tracks")}),"hosted \u2014 checking\u2026");let R=Yr(A);return R.at?R.expired?`EXPIRED ${Cs(R.at)} \u2014 re-sign to play`:`signed \xB7 ${ha(R.msLeft)}`:"hosted \xB7 no expiry"}async function Kt(){if(!Q||Q.live||!Q.manifest)return Lt=null,X=Rt(),!0;if(Lt?.track!==Q)try{Lt={track:Q,data:await Dt(Q.manifest)}}catch(A){return Lt=null,H(`\u{1F507} could not load the voice list for \u201C${Q.label}\u201D (${Q.manifest} \u2014 ${A.message}) \u2014 auto-advance stopped`),!1}let b=Yr(Lt.data);return b.expired?(H(`\u{1F507} the signed voices for \u201C${Q.label}\u201D expired ${Cs(b.at)} \u2014 auto-advance stopped \xB7 re-sign: ${mo(Lt.data)}`),!1):(X=Rt(),!0)}function Rt(){if(N.clear(),!Q||Q.live||Q.segments===!1)return!1;if(Q.manifest){let b=Lt?.data,A=b?.slides??[],R=!!Yr(b).at;return A.some(U=>Array.isArray(U?.segments)&&U.segments.length&&(!R||U.segments.every(V=>V?.url)))}return Q.segments===!0}let N=new Set,X=!1;function pe(b,A){if(!X||N.has(b))return null;let R=ye(b),U=Ns(R);if(!U)return null;let V=A>=v(b),he=Math.min(A,U.length),D=(V?U.slice(he):U.slice(he,he+1)).filter(se=>se!==null).map(se=>({file:se,url:Q.manifest?pa(Lt?.data,Q.manifest,b,se):`${Q.dir}/slide-${String(b).padStart(2,"0")}-${String(se).padStart(2,"0")}.${Q.ext??"m4a"}`}));return D.every(se=>se.url)?D:null}function Me(b){return Q.manifest?ua(Lt?.data,Q.manifest,b):`${Q.dir}/slide-${String(b).padStart(2,"0")}.${Q.ext??"m4a"}`}function Le(){if(Q)return Q.live?oe():X?j():qe()}function qe({selfDriving:b=!1,gen:A=tt}={}){let R=E.state.slide,U=E.state.step;if(!W(R)){i?.pause();return}let V=Me(R);if(!V){i?.pause();return}i??=new Audio,i.onended=null,i.onerror=null,i.src=V,i.playbackRate=De,Pe.mode!=="off"&&(Pe.attachAudio(i),Pe.beginSlide(Q,R)),b&&(i.onended=()=>{A===tt&&Wt(R,U,{mode:"file",endOfSlide:!0})});let he=!1;i.onerror=()=>{he=!0,M(R,V)},i.play().catch(D=>{D?.name==="NotAllowedError"?p("\u{1F507} the browser blocked audio \u2014 click the deck once, then V"):he||M(R,V)})}function M(b,A,{fatal:R=!1}={}){m("narr",`no audio: ${A}`);let U=Q?.manifest?Yr(Lt?.data):null;if(U?.at){m("narr","signed url failed \u2014 a media element cannot report the status"),H(`\u{1F507} slide ${b} of \u201C${Q.label}\u201D would not load (signed until ${Cs(U.at)}) \u2014 auto-advance stopped \xB7 re-sign: ${mo(Lt?.data)}`);return}if(R){H(`\u{1F507} no audio for slide ${b} (${A}) \u2014 auto-advance stopped \xB7 press the key left of 1 for messages`);return}p(`\u{1F507} no narration for slide ${b} (${A}) \xB7 press the key left of 1 for messages`)}async function j(){let b=E.state.slide,A=E.state.step,R=++tt;if(!W(b)){if(Ne(b)){m("narr",`hold on slide ${b} \u2014 manual advance`);return}setTimeout(()=>{R!==tt||!s||It()!=="file"||E.state.slide===b&&b<E.state.totalSlides&&E.goto(b+1,0)},400);return}F(b);let U=pe(b,A);if(!U){qe({selfDriving:!0,gen:R});return}if(!U.length){setTimeout(()=>{R===tt&&Wt(b,A,{mode:"file"})},600);return}let V=()=>R!==tt||!s||It()!=="file"||E.state.slide!==b||E.state.step!==A;Yt=R,gt=!0;try{for(let he=0;he<U.length;he++){for(;He;){if(V())return;await new Promise(se=>setTimeout(se,150))}if(V())return;i??=new Audio,Pe.mode!=="off"&&(Pe.attachAudio(i),Pe.beginSlide(Q,b,U[he].file)),i.onended=null,i.onerror=null,i.src=U[he].url,i.playbackRate=De;let D=await new Promise(se=>{i.onended=()=>se("ended"),i.onerror=()=>se("error"),i.play().catch(Xe=>se(Xe?.name==="NotAllowedError"?"blocked":"error"))});if(V())return;if(D==="blocked"){H("\u{1F507} the browser blocked audio \u2014 click the deck once, then V \u2014 the slides wait for the voice");return}if(D==="error"){if(A===0&&he===0){m("narr",`no segments for slide ${b} \u2014 falling back to the whole-slide file`),N.add(b),qe({selfDriving:!0,gen:R});return}M(b,U[he].url,{fatal:!0});return}}if(V())return;await Wt(b,A,{mode:"file"})}finally{Yt===R&&(gt=!1)}}function H(b="narration off"){s=!1,tt++,re++,He=!1,i?.pause(),Pe.stop(),p(b),m("narr",b),S()}function we(){return s?nn():We()}let Ye=()=>s||He;async function We(){if(!Q){p(fe.length||Ke?"no voice chosen \u2014 V picks one":"no narration here \u2014 V shows what is available");return}if(s)return H();if(jn(),Q.live&&await dt(),!await Kt())return;s=!0;let b=Q.live?`\u26A1 ${Ie.voice} \xB7 ${Ie.tone}`:Q.label;p(`\u{1F50A} ${b} \u2014 \u23B5 pauses \xB7 V picks`),m("narr",`on \u2014 ${b}`),Le(),S()}E.on("slide",()=>{s&&Le()}),E.on("build",()=>{s&&(Q?.live?oe():X&&j())});let Ve="decklight-captions:"+location.pathname,xe=!1;try{xe=localStorage.getItem(Ve)==="1"}catch{}let Oe=null;function ot(b){Oe&&(Oe.textContent=b,Oe.classList.toggle("show",!!b))}function Et(){if(Oe){if(s&&Q?.live){ot("");return}ot(f(E.state.slide,E.state.step).join(" "))}}function Tt(){Oe=document.createElement("div"),Oe.className="decklight-captions",Oe.setAttribute("aria-live","polite"),t.appendChild(Oe),Et()}function yt(){xe=!xe;try{localStorage.setItem(Ve,xe?"1":"0")}catch{}xe?(Tt(),Sn()):(Oe?.remove(),Oe=null),p(`captions ${xe?"on":"off"}`),m("narr",`captions ${xe?"on":"off"}`)}E.on("slide",Et),E.on("build",Et),xe&&!d&&Tt();let Qe="\u{1F50A} this deck has a voice-over \u2014 V plays it",wt=900,L=12e3,Pt="decklight-narr-used:"+location.pathname,sn=!1;try{sn=localStorage.getItem(Pt)==="1"}catch{}let on=null;function Sn(){if(!on)return;let b=on;on=null,b.classList.remove("show"),setTimeout(()=>b.remove(),260)}function jn(){if(Sn(),!sn){sn=!0;try{localStorage.setItem(Pt,"1")}catch{}}}function or(){let b=document.createElement("button");b.type="button",b.className="decklight-narr-hint",b.setAttribute("aria-label","Play this deck\u2019s voice-over");let A=document.createElement("kbd");A.textContent="V",b.append("\u{1F50A} this deck has a voice-over \u2014 ",A," plays it"),b.addEventListener("click",()=>{Sn(),We()}),on=b,t.appendChild(b),b.offsetWidth,b.classList.add("show"),g?.(Qe),m("narr","voice-over hint shown"),setTimeout(Sn,L)}dd({hasTracks:fe.length>0,used:sn,printMode:d,embedded:!!c?.has("embedded"),voiceover:!!c?.has("voiceover"),captionsOn:xe})&&setTimeout(()=>{s||or()},wt);let qt=null,bn=0,St="tracks",At=[],yn=null;function $n(){try{localStorage.setItem(Se,JSON.stringify(Q?.live?{live:Ie}:{track:fo(Q),dir:Q?.dir}))}catch{}}function Cn(b,A){Ie={voice:yn??Ie.voice,tone:b,style:A},Q=ue,$n(),an(),s||(s=!0),p(`\u26A1 live voice: ${Ie.voice} \xB7 ${Ie.tone} \u2014 V stops`),m("narr",`live config \u2014 ${Ie.voice} \xB7 ${Ie.tone}`),Le()}function xn(b,{scroll:A=!1}={}){At.length&&(bn=vn(qt.querySelectorAll(".narr-row"),b,"narr-sel",{scroll:A}))}function wr(){At[bn]?.commit()}function An(){St==="custom"?me("tones"):St==="tones"||St==="engines"?me("voices"):St==="charvideo"?me("character"):St==="record"||St==="voices"||St==="character"?me("tracks"):an()}let cn=!1;function _n(b,A){Pe.setMode(b,A),an(),p(b==="off"?"character off":b==="viseme"?`\u{1F3AD} character on \u2014 lips follow the narration${s?"":" \xB7 V starts it"}`:`\u{1F3A5} character video \u2014 ${Pe.engine} \xB7 ${Pe.portrait}${s?"":" \xB7 V starts narration"}`)}function Nn(b){if(Pe.mode==="off"){p("turn the character on first \u2014 N \xB7 Character\u2026");return}Pe.setSolo(b),an(),p(b?"\u{1F3AD} solo \u2014 the narrator has the stage \xB7 N brings the slides back":"solo off \u2014 the slides are back")}let dn="Hey, this is Decklight",Xt=dn,wn="",fn=!1,ir=null,Nt=new Map,Mn=new Map,ar=null,Gn=new Set;function Kn(b){if(b===dn)return Nt;if(b!==ar){for(let A of Mn.values())A.then(R=>URL.revokeObjectURL(R)).catch(()=>{});Mn=new Map,ar=b}return Mn}let On=(b,A)=>`${b}|${A||""}`;function k(b,A,R,U=""){let V=On(A,U);if(!b.has(V)){let he=(async()=>{let D=Date.now(),se=await fetch(de,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:R,voice:A,style:U})});if(!se.ok)throw new Error(String(se.status));let Xe=await se.blob(),Je=parseFloat(se.headers?.get?.("x-tts-cost")??"")||0;return Je&&(I+=Je),m("tts",`preview ${A}${U?" (styled)":""} \xB7 ${((Date.now()-D)/1e3).toFixed(1)}s`+(Je?` \xB7 ~$${Je.toFixed(4)}`:"")),URL.createObjectURL(Xe)})();he.catch(()=>{b.get(V)===he&&b.delete(V)}),b.set(V,he)}return b.get(V)}async function z(b,A,R){let U=`${R}|${b}`;if(Gn.has(U))return;Gn.add(U);let V=b===dn,he=V?Nt:Mn;try{m("narr",`preview prefetch ${R} (${V?"default":"custom"} sentence)`);for(let{voice:D,style:se}of A){if(!V&&ar!==b)return;he.has(On(D,se))||await k(he,D,b,se).catch(()=>{})}m("narr",`preview prefetch ${R} complete`)}finally{Gn.delete(U)}}function K({voice:b,style:A="",prefetch:R},U){let V=Xt.trim();if(!V)return;let he=Kn(V);U&&(U.textContent="\u2026"),k(he,b,V,A).then(D=>{if(U?.isConnected&&(U.textContent="\u25B6"),ir??=new Audio,ir.src=D,ir.play().catch(()=>{}),m("narr",`preview ${b}${A?" \xB7 styled":""}`),R==="voices"){let se=At.filter(Xe=>Xe.preview).map(Xe=>({voice:Xe.preview.voice,style:""}));z(V,se,"voices")}else R==="tones"&&z(V,J.map(se=>({voice:b,style:ne(se)})),`tones:${b}`)}).catch(()=>{U?.isConnected&&(U.textContent="\u25B6"),p("live voice bridge unreachable \u2014 run: decklight tts"),m("narr",`preview ${b} failed`)})}function me(b){let A=St;St=b,b==="voices"&&A!=="voices"&&(fn=!0);let R=qt.querySelector(".narr-card");R.innerHTML="";let U=document.createElement("div");if(U.className="narr-head",R.appendChild(U),At=[],b==="tracks")U.textContent="narration",fe.forEach(D=>At.push({text:D.manifest?`\u2601 ${D.label}`:`\u{1F50A} ${D.label} (${D.dir}/)`,flavor:D.manifest?Ct(D):"",cur:D===Q,commit:()=>{Q=D,$n(),an(),p(`\u{1F50A} track: ${D.label}`),s&&Kt().then(se=>{se&&Le()})}})),At.push({text:"\u26A1 Live voice \u2014 synthesize on the fly\u2026",cur:Q?.live,commit:()=>me("voices")}),At.push({text:"\u{1F9D1} Character \u2014 animated narrator\u2026",cur:Pe.mode!=="off",commit:()=>me("character")}),At.push({text:"\u{1F399} Record this deck\u2026",flavor:fe.some(D=>!D.live)?"re-record, or add another take":"write the audio to a folder",commit:()=>me("record")}),At.push({text:`${xe?"\u2611":"\u2610"} Captions \u2014 follow the voice on screen`,flavor:"C",toggle:!0,commit:()=>{yt(),me("tracks")}}),At.push({text:`\u23E9 Speed \u2014 ${De}\xD7`,flavor:"< slower \xB7 > faster",toggle:!0,commit:()=>{B(De>=2?-1.75:.25),me("tracks")}});else if(b==="record"){U.textContent="record this deck \u2014 writes wav files beside it";let D=Sr();At.push({text:"\u{1F3A4} With your voice \u2014 read it aloud, beat by beat",flavor:D?"":"the deck turns pages as you speak",blocked:D||null,commit:()=>{if(D)return p(D,5e3);an(),Gr()}});let se=Q?.live?null:"pick a live voice first \u2014 \u26A1 Live voice, above";At.push({text:"\u{1F50A} With the synthesized voice \u2014 unattended",flavor:se?"":`speaks every slide as ${Ie.voice}`,blocked:se,commit:()=>{if(se)return p(se,5e3);an(),xr()}})}else if(b==="character"){U.textContent="character \u2014 an animated narrator lip-syncs the voice",cn||(cn=!0,Pe.probe().then(()=>{qt&&St==="character"&&me("character")}));let D=Pe.bridgeInfo,se=D?.engines?.video??[];At.push({text:"Off",cur:Pe.mode==="off",commit:()=>_n("off")}),At.push({text:"\u{1F3AD} 2D character \u2014 offline visemes",flavor:D?.engines?.viseme?"":"bridge offline \u2014 amplitude fallback",cur:Pe.mode==="viseme",commit:()=>_n("viseme")}),At.push({text:`\u{1F3A5} Neural video \u2014 local GPU${se.length?"\u2026":""}`,flavor:se.length?"":"needs the bridge \u2014 run: decklight lipsync",cur:Pe.mode==="video",commit:()=>{se.length?me("charvideo"):p("video needs wav2lip/sadtalker on the bridge \u2014 run: decklight lipsync")}}),Pe.mode!=="off"&&At.push({text:`${Pe.solo?"\u25C9":"\u25CB"} Solo \u2014 the narrator takes the stage`,flavor:"slide content steps aside",cur:Pe.solo,commit:()=>Nn(!Pe.solo)})}else if(b==="charvideo"){U.textContent="neural video \u2014 pick engine \xB7 portrait";let D=Pe.bridgeInfo;for(let se of D?.engines?.video??[])for(let Xe of D?.portraits?.length?D.portraits:["default"])At.push({text:`\u{1F3A5} ${se} \xB7 ${Xe}`,cur:Pe.mode==="video"&&Pe.engine===se&&Pe.portrait===Xe,commit:()=>_n("video",{engine:se,portrait:Xe})})}else if(b==="engines")U.textContent="live voice \u2014 which engine speaks",mt||fetch(Re).then(D=>D.ok?D.json():{stale:!0}).then(D=>{mt=D?.stale?"stale":D?.engines??[]}).catch(()=>{mt=[]}).then(()=>{qt&&St==="engines"&&me("engines")}),mt?mt==="stale"?At.push({text:`\u26A1 ${Ae??"the bridge"} \u2014 and it cannot be changed from here`,flavor:"this voice bridge predates the engine picker",blocked:"restart it: decklight author",cur:!0,commit:()=>{}}):mt.length||At.push({text:"no voice bridge is answering",flavor:"the engine list comes from it",blocked:"decklight author",cur:!1,commit:()=>{}}):At.push({text:"asking the bridge\u2026",cur:!1,commit:()=>{}}),(Array.isArray(mt)?mt:[]).forEach(D=>At.push({text:D.name,flavor:D.ready?D.cost??"":D.why??"unavailable",blocked:D.ready?null:D.fix??null,cur:!!D.current,commit:()=>et(D)}));else if(b==="voices"){let D=ga(wn),se=D.length?je.filter(([vt,Ft])=>fd(vt,Ft,D)):je;U.textContent=D.length?`live voice \u2014 ${se.length} of ${je.length} \xB7 \u25B6 previews`:"live voice \u2014 pick a voice \xB7 \u25B6 previews",At.push({text:`\u2699 engine: ${Ae??"the bridge"}\u2026`,flavor:"changes which voices exist",cur:!1,commit:()=>me("engines")});let Xe=document.createElement("div");Xe.className="narr-preview-row narr-filter-row";let Je=document.createElement("input");Je.className="narr-input narr-filter",Je.value=wn,Je.placeholder="Filter voices \u2014 try fr, or lang:fr",Je.setAttribute("aria-label","Filter voices by name or language"),Je.addEventListener("input",()=>{wn=Je.value,fn=!0,me("voices")}),Je.addEventListener("keydown",vt=>{vt.key==="Escape"?(wn?(wn="",fn=!0,me("voices")):An(),vt.preventDefault()):(vt.key==="ArrowDown"||vt.key==="Enter")&&(fn=!1,Je.blur(),xn(0,{scroll:!0}),vt.preventDefault()),vt.stopPropagation()}),Xe.appendChild(Je),R.appendChild(Xe);let Be=document.createElement("div");Be.className="narr-preview-row";let at=document.createElement("input");at.className="narr-input narr-preview-text",at.value=Xt,at.placeholder="Preview sentence",at.setAttribute("aria-label","Preview sentence"),at.addEventListener("input",()=>{Xt=at.value}),at.addEventListener("keydown",vt=>{vt.key==="Escape"&&(An(),vt.preventDefault()),vt.stopPropagation()});let Mt=document.createElement("button");Mt.type="button",Mt.className="narr-prev-btn narr-reset-btn",Mt.textContent="\u21BA",Mt.title="restore the default sentence",Mt.setAttribute("aria-label","restore the default preview sentence"),Mt.addEventListener("click",vt=>{vt.stopPropagation(),Xt=dn,at.value=dn}),Be.append(at,Mt),R.appendChild(Be),(Ae==="say"||Ae==="sapi")&&st&&!je.some(([,,vt])=>vt==="best")&&At.push({text:Ae==="sapi"?"\u2B07 Get natural voices \u2014 free download":"\u2B07 Get Siri voices \u2014 free download",flavor:Ae==="sapi"?"opens Settings \u2192 Narrator":"opens System Settings",group:"best",commit:()=>{fetch(ae,{method:"POST"}).then(vt=>vt.json()).then(vt=>{if(!vt?.ok)throw new Error(vt?.error||"refused")}).then(()=>p("System Settings opened \u2014 download a Siri voice, then restart decklight tts",5200)).catch(()=>p(st,6e3))}});let Ot=["novelty","other languages"],Jt=new Set;se.forEach(([vt,Ft,jt])=>{if(!D.length&&jt&&Ot.includes(jt)&&!bt.has(jt)){if(!Jt.has(jt)){Jt.add(jt);let Pn=se.filter(([,,ps])=>ps===jt).length;At.push({text:`\u2023 ${jt==="novelty"?"novelty voices":jt} (${Pn})`,toggle:!0,cur:!1,commit:()=>{bt.add(jt),me("voices")}})}return}At.push({text:vt,flavor:Ft,group:jt??null,preview:{voice:vt,style:"",prefetch:"voices"},cur:Q?.live&&Ie.voice===vt,commit:()=>{if(yn=vt,_e)return me("tones");Cn(Ae??"plain","")}})}),D.length&&!se.length&&At.push({text:"no voice matches",flavor:"Esc clears the filter \xB7 lang:fr narrows to a language",blocked:!0,commit:()=>{}})}else if(b==="tones")U.textContent=`live voice \xB7 ${yn??Ie.voice} \u2014 pick a tone \xB7 \u25B6 previews`,J.forEach(D=>{let[se]=D,Xe=ne(D);At.push({text:se,preview:{voice:yn??Ie.voice,style:Xe,prefetch:"tones"},cur:Q?.live&&Ie.tone===se,commit:()=>Cn(se,Xe)})}),At.push({text:"Custom\u2026",cur:Q?.live&&Ie.tone==="Custom",commit:()=>me("custom")});else{U.textContent=`live voice \xB7 ${yn??Ie.voice} \u2014 type the delivery instruction \xB7 \u25B6 previews`;let D=document.createElement("div");D.className="narr-preview-row";let se=document.createElement("input");se.className="narr-input",se.value=Ie.style,se.placeholder="Read in a \u2026",se.addEventListener("keydown",Je=>{Je.key==="Enter"?(Ht(),Je.preventDefault()):Je.key==="Escape"&&(An(),Je.preventDefault()),Je.stopPropagation()});let Xe=document.createElement("button");Xe.type="button",Xe.className="narr-prev-btn narr-reset-btn",Xe.textContent="\u25B6",Xe.title="preview this delivery instruction",Xe.setAttribute("aria-label","preview this delivery instruction"),Xe.addEventListener("click",Je=>{Je.stopPropagation();let Be=se.value.trim();Be&&K({voice:yn??Ie.voice,style:Be},Xe)}),D.append(se,Xe),R.appendChild(D),setTimeout(()=>{se.focus(),se.select()},0),At=[],bn=0;return}let V=null;At.forEach((D,se)=>{if(D.group!==V&&(V=D.group??null,D.group)){let Be=document.createElement("div");Be.className="narr-group",Be.textContent=D.group,R.appendChild(Be)}let Xe=document.createElement("div");Xe.className="narr-row"+(D.cur?" narr-cur":"")+(D.toggle?" narr-toggle":"")+(D.blocked||D.blocked===""?" narr-blocked":"");let Je=document.createElement("span");if(Je.className="narr-row-label",Je.textContent=D.text,D.flavor){let Be=document.createElement("span");Be.className="narr-flavor",Be.textContent=D.flavor,Je.appendChild(Be)}if(Xe.appendChild(Je),D.blocked){let Be=document.createElement("div");Be.className="narr-fix",Be.textContent=D.blocked,Xe.appendChild(Be)}if(D.preview){let Be=document.createElement("button");Be.type="button",Be.className="narr-prev-btn",Be.textContent="\u25B6",Be.title=`preview ${D.preview.voice}`,Be.setAttribute("aria-label",`preview ${D.preview.voice}`),Be.addEventListener("click",at=>{at.stopPropagation(),K(D.preview,Be)}),Xe.appendChild(Be)}Xe.addEventListener("mouseenter",()=>xn(se)),Xe.addEventListener("click",()=>{xn(se),wr()}),R.appendChild(Xe)});let he=At.findIndex(D=>D.cur);if(xn(Math.max(0,he),{scroll:!0}),fn){let D=R.querySelector(".narr-filter");D&&(D.focus(),D.setSelectionRange(D.value.length,D.value.length))}}async function et(b){if(b?.name){if(!b.ready)return p(b.fix?`${b.name}: ${b.why} \u2014 ${b.fix}`:`${b.name}: ${b.why??"unavailable"}`,5e3);if(b.current)return me("voices");try{let R=await(await fetch(Fe,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({engine:b.name})})).json();if(!R.ok)return p(`${b.name}: ${R.why??R.error}${R.fix?` \u2014 ${R.fix}`:""}`,5e3);T=Promise.resolve(G(R)),mt=null,m("tts",`engine \u2192 ${R.engine} \xB7 ${R.model} \xB7 ${je.length} voice(s)`),p(`\u26A1 engine: ${R.engine}${R.cost?` \xB7 ${R.cost}`:""} \u2014 this session only`,3200),R.caveat&&p(R.caveat,6e3),me("voices")}catch{p(`${b.name}: the voice bridge did not answer`,3e3)}}}function Ht(){let b=qt?.querySelector(".narr-input")?.value.trim();b&&Cn("Custom",b)}function un(b){if(qt&&b===void 0)return an();qt||(qt=document.createElement("div"),qt.className="decklight-narr",qt.innerHTML='<div class="narr-card" role="listbox" aria-label="Narration"></div>',Ut(qt,an),t.appendChild(qt)),me(b??"tracks"),dt().then(A=>{A&&qt&&St==="voices"&&me("voices")})}function an(){qt?.remove(),qt=null,bt.clear(),wn="",fn=!1,cn=!1}let Vt=null,qn="confirm",en=0,Ln=null;function Wn(){let b=[];for(let V=1;V<=E.state.totalSlides;V++)W(V)&&b.push(V);let A=/^(\d+)(?:-(\d+))?$/.exec(c?.get?.("slides")??"");if(!A)return b;let R=Number(A[1]),U=A[2]?Number(A[2]):R;return b.filter(V=>V>=R&&V<=U)}function Vn(b){let A=Math.round(b/1e3);return A<60?`${A}s`:`${Math.floor(A/60)}m${String(A%60).padStart(2,"0")}s`}function lr(b,A={}){qn=b;let R=Vt.querySelector(".narr-card");if(b==="confirm"){let U=A.total;R.innerHTML=`<div class="narr-head">record offline narration</div>
281
+ <div class="rec-line">\u26A1 ${Ie.voice} \xB7 ${Ie.tone}</div>
282
+ <div class="rec-line">${U} slide${U===1?"":"s"} stitched from the sentence cache \u2014 only unheard sentences synthesize</div>
283
+ ${zn(A.target)}
283
284
  <div class="narr-row narr-sel">Start recording</div>
284
- <div class="rec-hint">Enter to start \xB7 Esc to cancel</div>`,ne.querySelector(".narr-row").addEventListener("click",zt)}else if(E==="progress"){let{done:ae,total:X,elapsedMs:ue}=z,we=X?Math.round(ae/X*100):0,Me=ae?un(ue/ae*(X-ae)):"\u2026";ne.innerHTML=`<div class="narr-head">recording\u2026</div>
285
- <div class="rec-bar"><div class="rec-bar-fill" style="width:${we}%"></div></div>
286
- <div class="rec-line">${ae} / ${X} slides \xB7 ${un(ue)} elapsed \xB7 ~${Me} left</div>
287
- <div class="rec-hint">Esc to cancel</div>`}else{let{saved:ae,total:X,cancelled:ue,dir:we}=z,Me=we?`saved as slide-NN.wav in <code>${$t(we)}/</code>, next to the deck`:"saved as slide-NN.wav to your downloads",nt=we?`Set <code>narration: { files: '${$t(we)}', ext: 'wav' }</code> to play them back without the bridge \u2014 <code>decklight bundle</code> picks the folder up from there.`:"Move them next to the deck and point <code>narration.files</code> at that folder with <code>ext: 'wav'</code> to play them back without the bridge.";ne.innerHTML=`<div class="narr-head">${ue?"recording cancelled":"recording done"}</div>
288
- <div class="rec-line">${ae} / ${X} slide${X===1?"":"s"} ${Me}</div>
289
- <div class="rec-line">${nt}</div>
290
- <div class="rec-hint">Enter or Esc to close</div>`}}let On=.15,yn=.35;function wn(E,z){let ne=E.reduce((ue,we)=>ue+we.length,0),ae=new DataView(new ArrayBuffer(44)),X=(ue,we)=>{for(let Me=0;Me<we.length;Me++)ae.setUint8(ue+Me,we.charCodeAt(Me))};return X(0,"RIFF"),ae.setUint32(4,36+ne,!0),X(8,"WAVE"),X(12,"fmt "),ae.setUint32(16,16,!0),ae.setUint16(20,1,!0),ae.setUint16(22,1,!0),ae.setUint32(24,z,!0),ae.setUint32(28,z*2,!0),ae.setUint16(32,2,!0),ae.setUint16(34,16,!0),X(36,"data"),ae.setUint32(40,ne,!0),new Blob([ae.buffer,...E],{type:"audio/wav"})}let v=(E,z)=>new Uint8Array(2*Math.round(E*z));async function H(E,z){let ne=mt(E),ae=[],X=24e3;for(let we=0;we<=ne;we++){let{sentences:Me,segStarts:nt}=K(E,we);for(let wt=0;wt<Me.length;wt++){let vn=await Be(E,we,wt);if(z!==kt)return null;if(!vn)continue;let lr=await vn.blob.arrayBuffer();ae.length===0?X=new DataView(lr).getUint32(24,!0)||24e3:ae.push(v(X,wt===0||nt.has(wt)?yn:On)),ae.push(new Uint8Array(lr.slice(44)))}}let ue=pe(E);return ae.length&&ue>0&&ae.push(v(X,ue)),ae.length?wn(ae,X):null}async function G(E,z){if(s.mode!=="viseme")return null;let ne=mt(E),ae=[];try{for(let ue=0;ue<=ne;ue++){let{sentences:we,segStarts:Me}=K(E,ue);for(let nt=0;nt<we.length;nt++){let wt=await s.ensureTimeline(y(E,ue,nt),Be(E,ue,nt),we[nt]);if(z!==kt)return null;wt&&ae.push({timeline:wt,gap:ae.length?nt===0||Me.has(nt)?yn:On:0})}}}catch{return h("lipsync",`slide ${E}: viseme sidecar skipped (bridge unreachable)`),null}let X=pe(E);return ae.length&&X>0&&ae.push({timeline:{cues:[],duration:0},gap:X}),ae.length?wi(ae):null}let ve="voiceover";function Ue(){let E=l.narration?.files,z=typeof E=="string"?E:Array.isArray(E)?E.find(ne=>typeof ne?.dir=="string")?.dir:null;return z&&!/^[a-z][a-z0-9+.-]*:/i.test(z)&&!/^[/\\]/.test(z)&&!z.split(/[/\\]/).includes("..")?z:ve}async function Ct(E,z,ne,ae){if(ae)try{if((await(await fetch(`${ae.base}/edit/record?slide=${E}&kind=${z}&dir=${encodeURIComponent(ae.name)}`,{method:"POST",body:ne})).json())?.ok)return!0}catch{}let X=`slide-${String(E).padStart(2,"0")}.${z==="wav"?"wav":"visemes.json"}`,ue=URL.createObjectURL(ne);return M(ue,X),setTimeout(()=>URL.revokeObjectURL(ue),5e3),!1}async function zt(){let E=Tt(),z=++kt,ne=Date.now(),ae=0,X=0,ue=0,we=T(),Me=we==null?null:{base:we,name:Ue()};bn("progress",{done:ae,total:E.length,elapsedMs:0});for(let nt of E){if(z!==kt)return;try{let wt=await H(nt,z);if(z!==kt)return;if(wt){if(await Ct(nt,"wav",wt,Me)&&ue++,z!==kt)return;X++;let vn=await G(nt,z);if(z!==kt)return;vn&&await Ct(nt,"visemes",new Blob([JSON.stringify(vn)],{type:"application/json"}),Me)}}catch{m(`slide ${nt}: recording failed`)}ae++,z===kt&&bn("progress",{done:ae,total:E.length,elapsedMs:Date.now()-ne})}z===kt&&bn("done",{saved:X,total:E.length,dir:ue?Me.name:null})}function xn(){if(!D?.live){m("live voice only \u2014 pick a voice with N first");return}jt||(jt=document.createElement("div"),jt.className="decklight-narr decklight-record",jt.innerHTML='<div class="narr-card" role="dialog" aria-label="Record offline narration"></div>',It(jt,Jt),r.appendChild(jt),bn("confirm",{total:Tt().length}))}function Jt(){kt++,jt?.remove(),jt=null}return b.register({isOpen:()=>!!jt,close:Jt,keydown(E){if(E.key==="Escape")Jt();else if(E.key==="Enter")dn==="confirm"?zt():dn!=="progress"&&Jt();else return!1;return!0}}),b.register({isOpen:()=>!!dt,close:Gt,keydown(E){if(xt==="custom")return E.key==="Enter"?(sn(),!0):E.key==="Escape"?(ln(),!0):!1;switch(E.key){case"ArrowDown":Pt(pt+1,{scroll:!0});break;case"ArrowUp":Pt(pt-1,{scroll:!0});break;case"Enter":an();break;case"Escape":ln();break;case"n":case"N":Gt();break;default:return!1}return!0}}),{character:s,toggleNarration:Wt,toggleNarrPause:Ne,changeNarrRate:Ce,toggleCaptions:S,openPicker:Mt,openRecordDialog:xn,applySolo:Tn,notesSegs:Fe,status:()=>({narrating:V,paused:gt,rate:Ke,captionsOn:R,track:D,live:!!D?.live,voice:O.voice,tone:O.tone,hasTracks:Je.length>0,spend:C})}}le();ce();function Yc(r,i){let l=[];for(let d=0;d<r;d+=i){let u=[];for(let m=d;m<r&&m<d+i;m++)u.push(m);l.push(u)}return l}function Si(r,i,l){let d=r.ownerDocument,u=h=>{let b=d.createElement("div");return b.className=h,b},m=h=>{let b=u("print-slot"),k=u("decklight-stage print-slide");return k.appendChild(h),b.appendChild(k),b};if(l==="handout")for(let h of Yc(i.length,3)){let b=u("print-page print-handout");for(let k of h){let A=u("print-row");A.appendChild(m(i[k])),A.appendChild(u("print-notelines")),b.appendChild(A)}r.appendChild(b)}else i.forEach(h=>{let b=u("print-page print-notes-page"),k=u("print-notes"),A=h.querySelector("aside.notes");A&&(k.innerHTML=A.innerHTML),b.appendChild(m(h)),b.appendChild(k),r.appendChild(b)});let f=d.createElement("style");f.textContent="@media print { @page { size: 816px 1056px; margin: 0; } html, body { margin: 0; padding: 0; } }",d.head.appendChild(f)}le();ce();le();ce();function Jc(r,i,l,d){let u=d||1;return{x:(r-l.left)/u,y:(i-l.top)/u}}function Qc(r,i,l=300){return r.filter(d=>i-d.t<l)}function Ai(r,i){let l=i.querySelector(":scope > .decklight-stage"),d=null,u=null,m=null,f=[],h=null,b=[],k=null,A=0,P=()=>getComputedStyle(i).getPropertyValue("--accent").trim()||"#fff",M=xe=>Jc(xe.clientX,xe.clientY,l.getBoundingClientRect(),r._scale);function T(){if(!u)return;let xe=window.devicePixelRatio||1,Le=i.getBoundingClientRect(),st=l.getBoundingClientRect(),at=r._scale||1;u.setTransform(1,0,0,1,0,0),u.clearRect(0,0,d.width,d.height),u.setTransform(xe*at,0,0,xe*at,(st.left-Le.left)*xe,(st.top-Le.top)*xe),u.lineCap=u.lineJoin="round",u.lineWidth=3.5;for(let _ of h?[...f,h]:f)if(_.points.length){u.strokeStyle=_.color,u.beginPath(),u.moveTo(_.points[0].x,_.points[0].y);for(let qe of _.points)u.lineTo(qe.x,qe.y);u.stroke()}if(m==="laser"&&k){let _=P(),qe=performance.now();u.fillStyle=_;for(let Je of b){let je=1-(qe-Je.t)/300;u.globalAlpha=je*.4,u.beginPath(),u.arc(Je.x,Je.y,3+4*je,0,Math.PI*2),u.fill()}u.globalAlpha=1,u.shadowColor=_,u.shadowBlur=22,u.beginPath(),u.arc(k.x,k.y,7,0,Math.PI*2),u.fill(),u.shadowBlur=0}}function C(){A=0,b=Qc(b,performance.now()),T(),b.length&&(A=requestAnimationFrame(C))}let F=()=>{A||(A=requestAnimationFrame(C))};function ye(xe){if(!(m!=="pen"||xe.button>0)){try{d.setPointerCapture(xe.pointerId)}catch{}h={color:P(),points:[M(xe)]},T(),xe.preventDefault()}}function ge(xe){m==="pen"&&h?(h.points.push(M(xe)),T()):m==="laser"&&(k=M(xe),b.push({...k,t:performance.now()}),F())}function be(){h&&(f.push(h),h=null)}function J(){let xe=i.getBoundingClientRect(),Le=window.devicePixelRatio||1;d.width=Math.max(1,Math.round(xe.width*Le)),d.height=Math.max(1,Math.round(xe.height*Le)),T()}function de(){d||(d=document.createElement("canvas"),d.className="decklight-annotate",d.setAttribute("aria-hidden","true"),i.appendChild(d),u=d.getContext("2d"),d.addEventListener("pointerdown",ye),d.addEventListener("pointermove",ge),d.addEventListener("pointerup",be),d.addEventListener("pointercancel",be),d.addEventListener("touchstart",xe=>xe.stopPropagation(),{passive:!0}),J(),new ResizeObserver(()=>{J(),requestAnimationFrame(T)}).observe(i))}function Oe(xe="pen"){return m=m===xe?null:xe,m&&de(),d&&(d.classList.toggle("tool-pen",m==="pen"),d.classList.toggle("tool-laser",m==="laser")),h&&(f.push(h),h=null),m!=="laser"&&(b=[],k=null,u&&T()),m}function ke(){f=[],h=null,b=[],k=null,u&&T()}function De(xe){de(),f.push({color:P(),points:xe.map(Le=>({x:Le.x,y:Le.y}))}),T()}return r.on("slide",ke),{toggle:Oe,laser:()=>Oe("laser"),clear:ke,stroke:De,get tool(){return m},get active(){return m!==null}}}function _i({root:r,printMode:i,toast:l,debugLog:d,overlays:u,instance:m,narration:f,downloadFromUrl:h,setProgressBar:b}){let k="decklight-clock:"+location.pathname,A=!1;try{A=localStorage.getItem(k)==="1"}catch{}let P=null,M=null,T=null,C=!1,F=D=>String(D).padStart(2,"0");function ye(D){let V=Math.floor(D/1e3),re=Math.floor(V/3600);return(re?re+":":"")+F(Math.floor(V/60)%60)+":"+F(V%60)}function ge(){if(!P)return;let D=new Date;P.querySelector(".clk-time").textContent=F(D.getHours())+":"+F(D.getMinutes()),P.querySelector(".clk-elapsed").textContent="+"+ye(T==null?0:Date.now()-T)}function be(){P=document.createElement("div"),P.className="decklight-clock",P.innerHTML='<span class="clk-time"></span><span class="clk-elapsed"></span>',r.appendChild(P),ge(),M=setInterval(ge,1e3)}function J(){A=!A;try{localStorage.setItem(k,A?"1":"0")}catch{}A?be():(clearInterval(M),M=null,P?.remove(),P=null),l(`clock ${A?"on":"off"}`),d("nav",`clock ${A?"on":"off"}`)}m.on("ready",()=>{C=!0});let de=()=>{!C||T!=null||(T=Date.now(),ge())};m.on("slide",de),m.on("build",de),m.toggleClock=J,A&&!i&&be();let Oe="decklight-progress:"+location.pathname,ke=!1;try{ke=localStorage.getItem(Oe)==="1"}catch{}let De=null;function xe(){De=document.createElement("div"),De.className="decklight-progress",De.innerHTML='<div class="bar"></div>',r.appendChild(De),b(De.querySelector(".bar")),m._updateChrome()}function Le(){ke=!ke;try{localStorage.setItem(Oe,ke?"1":"0")}catch{}ke?xe():(De?.remove(),De=null,b(null)),l(`progress bar ${ke?"on":"off"}`),d("nav",`progress bar ${ke?"on":"off"}`)}m.toggleProgress=Le,ke&&!i&&xe();let st=null;i||(st=Ai(m,r),m.annotate=st);function at(D){if(!st)return;let V=D==="laser"?st.laser():st.toggle();l(V==="pen"?"pen on \u2014 drag to draw \xB7 \u232B clears \xB7 W off":V==="laser"?"laser on \u2014 \u21E7W off":"ink off"),d("nav",`ink ${V??"off"}`)}function _(){return(m._sections||[]).map((D,V)=>({n:V+1,title:D.querySelector("h1, h2, h3")?.textContent.trim()||`Slide ${V+1}`,segs:f.notesSegs(V+1).filter(Boolean)}))}function qe(D){let V=(document.title||"Deck").trim(),re=D?[`# ${V} \u2014 transcript`,""]:[`${V} \u2014 transcript`,""];for(let{n:Ae,title:Ke,segs:Ce}of _())if(Ce.length){re.push(D?`## ${Ae}. ${Ke}`:`${Ae}. ${Ke}`,"");for(let s of Ce)re.push(s,"")}return re.join(`
291
- `)}function Je(D){let V=D==="md",re=URL.createObjectURL(new Blob([qe(V)],{type:V?"text/markdown":"text/plain"})),Ae=(location.pathname.split("/").pop()||"deck").replace(/\.html?$/i,"");h(re,`${Ae}-transcript.${V?"md":"txt"}`),setTimeout(()=>URL.revokeObjectURL(re),5e3),d("narr",`transcript exported (.${V?"md":"txt"})`)}let je=null;function O(){if(je){je.remove(),je=null;return}je=document.createElement("div"),je.className="decklight-narr decklight-transcript";let D=document.createElement("div");D.className="narr-card";let V=document.createElement("div");V.className="narr-head",V.textContent="transcript \u2014 the deck\u2019s spoken notes \xB7 Esc closes";let re=document.createElement("div");re.className="tr-actions";for(let[Ae,Ke]of[["\u2B07 export .txt","txt"],["\u2B07 export .md","md"]]){let Ce=document.createElement("button");Ce.type="button",Ce.className="narr-prev-btn",Ce.textContent=Ae,Ce.addEventListener("click",()=>Je(Ke)),re.appendChild(Ce)}D.append(V,re);for(let{n:Ae,title:Ke,segs:Ce}of _()){if(!Ce.length)continue;let s=document.createElement("div");s.className="tr-slide";let o=document.createElement("div");o.className="tr-title",o.textContent=`${Ae} \xB7 ${Ke}`,o.title="jump to this slide",o.addEventListener("click",()=>{O(),m.goto(Ae,0,{force:!0})}),s.appendChild(o);for(let N of Ce){let Fe=document.createElement("p");Fe.className="tr-seg",Fe.textContent=N,s.appendChild(Fe)}D.appendChild(s)}je.appendChild(D),It(je,O),r.appendChild(je)}return m.transcript={open:O,text:()=>qe(!1),markdown:()=>qe(!0)},u.register({isOpen:()=>!!je,close:O,keydown:D=>D.key==="Escape"&&(O(),!0)}),{toggleClock:J,toggleProgress:Le,toggleInk:at,toggleTranscript:O,get annotator(){return st},status:()=>({clockOn:A,progressOn:ke})}}le();ce();var ed=["data-background-image","data-background-video","data-background-poster","data-background-size","data-background-position","data-background-dim"];function td(r){let i=r["data-background-image"]||null,l=r["data-background-video"]||null;if(!i&&!l)return null;let d=parseFloat(r["data-background-dim"]);return{image:i,video:l,poster:r["data-background-poster"]||null,size:r["data-background-size"]==="contain"?"contain":"cover",position:r["data-background-position"]||"center",dim:Number.isFinite(d)?Math.min(Math.max(d,0),1):0}}var nd=r=>`url("${String(r).replace(/["\\]/g,"\\$&")}")`;function rd(r){let i={};for(let l of ed){let d=r.getAttribute(l);d!==null&&(i[l]=d)}return i}function Ti(r,{printMode:i=!1}={}){r.forEach(l=>{let d=td(rd(l)),u=l.querySelector(":scope > .slide-bg");if(!d){u?.remove();return}let m=JSON.stringify(d)+(i?"\xB7print":"");if(u&&u.dataset.sig===m){u!==l.firstElementChild&&l.prepend(u);return}u||(u=document.createElement("div"),u.className="slide-bg",u.setAttribute("aria-hidden","true")),u.dataset.sig=m,u.textContent="",u.style.backgroundSize=d.size,u.style.backgroundPosition=d.position;let f=d.image||(i?d.poster:null);if(u.style.backgroundImage=f?nd(f):"",d.video&&!i){let h=document.createElement("video");h.muted=!0,h.loop=!0,h.setAttribute("muted",""),h.setAttribute("loop",""),h.setAttribute("playsinline",""),h.preload="auto",d.poster&&(h.poster=d.poster),h.style.objectFit=d.size,h.style.objectPosition=d.position,h.src=d.video,u.appendChild(h)}if(d.dim>0){let h=document.createElement("div");h.className="slide-bg-dim",h.style.opacity=String(d.dim),u.appendChild(h)}l.prepend(u)})}le();ce();le();ce();var sd="npx decklight author";function od(r){let i=r||"";try{i=decodeURIComponent(i)}catch{}/^\/[A-Za-z]:/.test(i)&&(i=i.slice(1));let l=i.lastIndexOf("/");return{dir:l>0?i.slice(0,l):"",file:l>=0?i.slice(l+1):i}}function fn(r,i={}){let{protocol:l="",pathname:d=""}=i,{dir:u,file:m}=od(d),f=/\.html?$/i.test(m)?m:"<deck.html>",h=l==="file:"&&u?`from ${u}, `:"";return`${r} needs author mode: ${h}run ${sd} ${f}, then reopen the URL it prints`}function id(r){let i=Math.max(0,Math.floor((Number(r)||0)/1e3)),l=String(i%60).padStart(2,"0"),d=Math.floor(i/60);return d<60?`${d}:${l}`:`${Math.floor(d/60)}:${String(d%60).padStart(2,"0")}:${l}`}var ad={second:"s",minute:"m",hour:"h",day:"d",week:"w",month:"mo",year:"y"};function Ci(r){let i=/^(\d+)\s+(second|minute|hour|day|week|month|year)s?\s+ago$/.exec(String(r??"").trim());return i?`${i[1]}${ad[i[2]]}`:String(r??"")}function Ni(r,i=Date.now()){if(!r||!r.agent)return null;let l=Number(r.startedAt);return!Number.isFinite(l)||l<=0||l>i?r.agent:`${r.agent} \xB7 ${id(i-l)}`}function $i(r,{shown:i=!1,threshold:l=10}={}){if(i||!r||!["ok","no-upstream"].includes(r.state))return null;let d=r.state==="ok"?r.ahead:r.unpushed;return!d||d<l?null:`\u2191${d} commits are only on this machine \u2014 H shows them`}le();ce();var ld=/<\s*(pre|textarea|script|style)\b/i,cd=r=>!ld.test(String(r??""));function Oi(r){let i=String(r??"");if(!cd(i))return i;let l=i.split(`
292
- `);if(l.length<2)return i;let d=1/0;for(let u of l.slice(1))if(u.trim()&&(/^\s*\t/.test(u)||(d=Math.min(d,/^ */.exec(u)[0].length),d===0)))return i;return Number.isFinite(d)?l.map((u,m)=>m===0?u:u.trim()?u.slice(d):"").join(`
293
- `):i}function Mi({root:r,config:i,params:l,printMode:d,toast:u,debugLog:m,overlays:f,instance:h,notesSegs:b,dismissOthers:k}){let A=!1,P="",M=[],T=null,C=[],F=null,ye=!1,ge=null,be=0;function J(){let R=Ni(F);if(!R){clearInterval(be),be=0,ge?.remove(),ge=null;return}ge||(ge=document.createElement("div"),ge.className="decklight-agent-chip",ge.setAttribute("role","status"),ge.setAttribute("aria-live","polite"),r.appendChild(ge)),ge.textContent=`\u{1F916} ${R}`,ge.title=F.prompt?`asked: ${F.prompt}`:"",be||(be=setInterval(J,1e3))}if(!d&&!l.has("embedded")){let R=i.edit?.url?[i.edit.url]:/^https?:$/.test(location.protocol)?[""]:["http://127.0.0.1:8788"];(async()=>{for(let W of R)try{let U=await fetch(W+"/edit/ping");if(!U.ok)continue;let se=await U.json();if(!se?.ok)continue;let $e=decodeURIComponent(location.pathname.split("/").pop()||"");if($e&&se.name&&$e!==se.name){m("edit",`server edits ${se.name}, this deck is ${$e} \u2014 not wiring up`);continue}P=W,A=!0,M=Array.isArray(se.agents)?se.agents:[],T=typeof se.preferredAgent=="string"?se.preferredAgent:null,C=Array.isArray(se.wizards)?se.wizards:[];let S=$i(se.remote);S&&(ye=!0,u(S,4200)),F=se.agentBusy||null,F&&u(`${F.agent} is editing the deck\u2026`,2e3),J();let L=new EventSource(W+"/edit/events");L.onmessage=()=>location.reload(),L.addEventListener("agent",$=>{try{let Z=JSON.parse($.data);if(Z.state==="start")F=Z,J(),u(`\u{1F916} ${Z.agent} is editing the deck\u2026`,2200),m("agent",`${Z.agent} start: ${(Z.prompt||"").slice(0,80)}`);else if(Z.state==="done"){F=null,J();let te=Z.ok?"":Z.error?` \u2014 ${Z.error}`:` (exit ${Z.code})`;u(Z.changed?`\u{1F916} ${Z.agent} edited the deck \u2014 Z undoes${te}`:`\u{1F916} ${Z.agent} finished \u2014 no changes${te}`,3e3),m("agent",`${Z.agent} done ok=${Z.ok} changed=${Z.changed}${te}`)}}catch{}}),m("edit",`live reload connected${W?` (${W})`:""}`+(M.length?` \xB7 agents: ${M.map($=>$.name).join(", ")}`:""));return}catch{}await _()})()}let de=null,Oe=!1,ke=null;function De(){ke?.remove(),ke=null}function xe(R,W){let U=document.createElement("div");return U.className=W,U.textContent=R,U}async function Le(R){let W=ke?.querySelector(".tp-list");if(!W)return;W.textContent="",W.appendChild(xe(R.message??R.state,"hs-remote"));for(let $e of R.commits??[])W.appendChild(xe(`${$e.hash} ${$e.subject}`,"tp-row"));let U=ke.querySelector(".up-actions");U.textContent="";let se=($e,S)=>{let L=document.createElement("button");return L.type="button",L.className="narr-prev-btn",L.textContent=$e,L.addEventListener("click",S),U.appendChild(L),L};se("check now",async()=>{U.textContent="checking\u2026",await Le(await st("/present/upstream/check"))}),R.state==="behind"&&R.pull?.offered?se("update the deck",async()=>{U.textContent="pulling\u2026";let $e=await st("/present/upstream/pull");if($e.reload)return location.reload();await Le({...$e,commits:[],message:$e.message}),$e.state==="pulled"&&se("show it anyway",()=>location.reload())}):R.pull&&!R.pull.offered&&R.state==="behind"&&U.appendChild(xe(`update control off \u2014 ${R.pull.reason}`,"hs-remote"))}async function st(R){try{return await(await fetch(de+R,{method:"POST"})).json()}catch{return{state:"error",message:"the presenting server did not answer"}}}async function at(){if(ke)return De();let R;try{let W=await fetch(de+"/present/upstream");if(!W.ok)return u("this deck is not a tracked file in a git clone \u2014 nothing to update from",3400);R=await W.json()}catch{return u("deck update: the presenting server did not answer",3e3)}k(),ke=document.createElement("div"),ke.className="decklight-theme-picker decklight-finder decklight-restore decklight-history",ke.innerHTML='<div class="tp-panel"><div class="tp-side"><div class="tp-filter">Deck update \u2014 Esc closes</div><div class="tp-list" role="listbox" aria-label="Upstream commits"></div><div class="up-actions tr-actions"></div></div></div>',It(ke,De),r.appendChild(ke),await Le(R)}f.register({isOpen:()=>!!ke,close:De,keydown:R=>R.key==="Escape"&&(De(),!0)});async function _(){let R=/^https?:$/.test(location.protocol)?"":"http://127.0.0.1:8790";try{let W=await fetch(R+"/present/ping");if(!W.ok)return;let U=await W.json();if(!U?.ok||!U.present)return;let se=decodeURIComponent(location.pathname.split("/").pop()||"");if(se&&U.name&&se!==U.name){m("present",`server presents ${U.name}, this deck is ${se} \u2014 not wiring up`);return}h.__remoteQr=U.remote?`${R||location.origin}/remote/qr.svg`:null,de=R,Oe=!0,new EventSource(R+"/present/events").addEventListener("remote",L=>{try{let{key:$}=JSON.parse(L.data);$==="next"?h.next():$==="prev"&&h.prev()}catch{}});let S=()=>{fetch(R+"/remote/pos",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({i:h.state.slide,n:h.state.totalSlides})}).catch(()=>{})};h.on("slide",S),h.on("build",S),S(),m("present",`remote connected${R?` (${R})`:""} \u2014 no edit surface`)}catch{}}async function qe(R){if(!A){u(fn(R,location),3200);return}try{let W=await fetch(P+"/edit/"+R,{method:"POST"}),U=await W.json().catch(()=>({}));if(!W.ok){u(U.error||`${R} failed`);return}u(`${R} \u2014 ${U.undo} back \xB7 ${U.redo} forward`),m("edit",`${R} \u2192 ${U.undo} back, ${U.redo} forward`)}catch{u(`${R} failed \u2014 is the dev server still up?`,2200)}}let Je=null;function je(){if(Je){Je.remove(),Je=null;return}if(!A){u(fn("asking an agent",location),3200);return}if(!M.length){u("no agent CLI detected on the dev machine (claude, codex, bob, \u2026)",2600);return}if(F){u(`${F.agent} is still working on the last ask`,2200);return}Je=document.createElement("div"),Je.className="decklight-narr decklight-editor";let R=document.createElement("div");R.className="narr-card";let W=document.createElement("div");W.className="narr-head",W.textContent="ask an agent \u2014 edits the deck file \xB7 \u2318\u23CE sends \xB7 Esc closes";let U=document.createElement("textarea");U.className="narr-input edit-notes",U.placeholder=`e.g. "make slide ${h.state.slide} a split layout with the diagram on the left"`,U.spellcheck=!1;let se=T&&M.some($=>$.name===T)?T:M[0].name,$e=document.createElement("div");if($e.className="tr-actions",M.length>1){let $=document.createElement("select");$.className="narr-prev-btn";for(let Z of M){let te=document.createElement("option");te.value=Z.name,te.textContent=Z.label,$.appendChild(te)}$.value=se,$.addEventListener("change",()=>{se=$.value,T=$.value,fetch(P+"/edit/agent/prefer",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({agent:$.value})}).catch(()=>{}),m("agent",`preferred agent \u2192 ${$.value}`)}),$.addEventListener("keydown",Z=>Z.stopPropagation()),$e.appendChild($)}let S=async()=>{let $=U.value.trim();if($)try{let Z=await fetch(P+"/edit/agent",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({prompt:$,agent:se})}),te=await Z.json().catch(()=>({}));if(!Z.ok)throw new Error(te.error||Z.status);je()}catch(Z){u(`ask failed: ${String(Z.message||Z).slice(0,60)}`,2200)}};U.addEventListener("keydown",$=>{$.key==="Enter"&&($.metaKey||$.ctrlKey)?(S(),$.preventDefault()):$.key==="Escape"&&(je(),$.preventDefault()),$.stopPropagation()});let L=document.createElement("button");L.type="button",L.className="narr-prev-btn",L.textContent="\u{1F916} send to agent",L.addEventListener("click",S),$e.appendChild(L),R.append(W,U,$e),Je.appendChild(R),It(Je,je),r.appendChild(Je),setTimeout(()=>U.focus(),0)}let O=null;function D(){if(O){O.remove(),O=null;return}let R=h.state.slide;if(!A){u(fn("editing notes",location),3200);return}O=document.createElement("div"),O.className="decklight-narr decklight-editor";let W=document.createElement("div");W.className="narr-card";let U=document.createElement("div");U.className="narr-head",U.textContent=`edit notes \u2014 slide ${R} \xB7 \u2318\u23CE saves \xB7 Esc closes`;let se=document.createElement("textarea");se.className="narr-input edit-notes",se.value=b(R).filter(($,Z,te)=>$||Z<te.length).join(`
285
+ <div class="rec-hint">Enter to start \xB7 Esc to cancel</div>`,os(R,V=>{Ln=V}),R.querySelector(".narr-row").addEventListener("click",zr)}else if(b==="progress"){let{done:U,total:V,elapsedMs:he}=A,D=V?Math.round(U/V*100):0,se=U?Vn(he/U*(V-U)):"\u2026";R.innerHTML=`<div class="narr-head">recording\u2026</div>
286
+ <div class="rec-bar"><div class="rec-bar-fill" style="width:${D}%"></div></div>
287
+ <div class="rec-line">${U} / ${V} slides \xB7 ${Vn(he)} elapsed \xB7 ~${se} left</div>
288
+ <div class="rec-hint">Esc to cancel</div>`}else{let{saved:U,total:V,cancelled:he,dir:D}=A,se=A.segmented?"slide-NN.wav + one slide-NN-KK.wav per \u27E8CLICK\u27E9":"slide-NN.wav",Xe=D?`saved as ${se} in <code>${$t(D)}/</code>, next to the deck`:`saved as ${se} to your downloads \u2014 ${hr()}`,Je=A.segmented?", segments: true":"",Be=D?`Set <code>narration: { files: '${$t(D)}', ext: 'wav'${Je} }</code> to play them back without the bridge \u2014 <code>decklight bundle</code> picks the folder up from there.`+(A.segmented?" <strong>segments</strong> is what makes them step the builds.":""):`Move them next to the deck and point <code>narration.files</code> at that folder with <code>ext: 'wav'${Je}</code> to play them back without the bridge.`;R.innerHTML=`<div class="narr-head">${he?"recording cancelled":"recording done"}</div>
289
+ <div class="rec-line">${U} / ${V} slide${V===1?"":"s"} ${Xe}</div>
290
+ <div class="rec-line">${Be}</div>
291
+ ${qr(D)}
292
+ ${Fr(D)}`,is(R,D,{ext:"wav",label:A.label,...A.segmented?{segments:!0}:{}})}}let cr=.35;function dr(b,A){let R=b.reduce((he,D)=>he+D.length,0),U=new DataView(new ArrayBuffer(44)),V=(he,D)=>{for(let se=0;se<D.length;se++)U.setUint8(he+se,D.charCodeAt(se))};return V(0,"RIFF"),U.setUint32(4,36+R,!0),V(8,"WAVE"),V(12,"fmt "),U.setUint32(16,16,!0),U.setUint16(20,1,!0),U.setUint16(22,1,!0),U.setUint32(24,A,!0),U.setUint32(28,A*2,!0),U.setUint16(32,2,!0),U.setUint16(34,16,!0),V(36,"data"),U.setUint32(40,R,!0),new Blob([U.buffer,...b],{type:"audio/wav"})}let rs=(b,A)=>new Uint8Array(2*Math.round(b*A));function Fn(b,A){let R=ye(b),U=A<v(b)?[[A,R[A]]]:R.slice(A).map((D,se)=>[A+se,D]),V=[],he=0;for(let[D,se]of U){let Xe=Ze(se??"");Xe.length&&V.push({seg:D,from:he,count:Xe.length}),he+=Xe.length}return V}async function ss(b,A){let R=v(b),U=Ns(ye(b)),V=[],he=new Map,D=24e3;for(let se=0;se<=R;se++){let{sentences:Xe,segStarts:Je}=ze(b,se),Be=Fn(b,se);for(let at=0;at<Xe.length;at++){let Mt=await ce(b,se,at);if(A!==en)return null;if(!Mt)continue;let Ot=await Mt.blob.arrayBuffer();V.length===0?D=new DataView(Ot).getUint32(24,!0)||24e3:V.push(rs(D,at===0||Je.has(at)?cr:pt(b)));let Jt=new Uint8Array(Ot.slice(44));V.push(Jt);let vt=Be.find(Pn=>at>=Pn.from&&at<Pn.from+Pn.count),Ft=vt&&U?U[vt.seg]:null;if(Ft==null)continue;let jt=he.get(Ft);jt||he.set(Ft,jt=[]),jt.length&&jt.push(rs(D,pt(b))),jt.push(Jt)}}return{wav:V.length?dr(V,D):null,segments:[...he].map(([se,Xe])=>({file:se,wav:dr(Xe,D)}))}}async function qs(b,A){if(Pe.mode!=="viseme")return null;let R=v(b),U=Ns(ye(b)),V=[],he=new Map;try{for(let D=0;D<=R;D++){let{sentences:se,segStarts:Xe}=ze(b,D),Je=Fn(b,D);for(let Be=0;Be<se.length;Be++){let at=await Pe.ensureTimeline(Ce(b,D,Be),ce(b,D,Be),se[Be]);if(A!==en)return null;if(!at)continue;V.push({timeline:at,gap:V.length?Be===0||Xe.has(Be)?cr:pt(b):0});let Mt=Je.find(vt=>Be>=vt.from&&Be<vt.from+vt.count),Ot=Mt&&U?U[Mt.seg]:null;if(Ot==null)continue;let Jt=he.get(Ot);Jt||he.set(Ot,Jt=[]),Jt.push({timeline:at,gap:Jt.length?pt(b):0})}}}catch{return m("lipsync",`slide ${b}: viseme sidecar skipped (bridge unreachable)`),null}return{slide:V.length?ho(V):null,segments:[...he].map(([D,se])=>({file:D,timeline:ho(se)}))}}async function vr(){let b=_();if(b==null)return[];try{let R=await(await fetch(`${b}/edit/tracks`)).json();return Array.isArray(R?.tracks)?R.tracks:[]}catch{return[]}}function ur({mine:b},A){let R=b?null:Ae,U=b?null:Ie?.voice,V=b?{mine:!0}:{engine:R,voice:U},he=fa(V,A.map(Be=>Be.dir)),D=fa(V,[]).label,se=(Be,at)=>({dir:Be,label:at==="new"?he.label:D,why:at,clash:A.find(Mt=>Mt.dir===Be)??null}),Xe=Zn(c?.get?.("dir"));if(Xe)return se(Xe,"asked");if(!b&&U){let Be=A.find(at=>at.voice&&at.voice===U&&(!at.engine||!R||at.engine===R));if(Be)return se(Be.dir,"refresh")}let Je=Zn(zs({configOnly:!0}));return Je?se(Je,"configured"):se(he.dir,"new")}let Fs="voiceover",Zn=b=>typeof b=="string"&&b&&!/^[a-z][a-z0-9+.-]*:/i.test(b)&&!/^[/\\]/.test(b)&&!b.split(/[/\\]/).includes("..")?b:null;function zs({configOnly:b=!1}={}){let A=Zn(c?.get?.("dir"));if(A)return A;let R=a.narration?.files,U=typeof R=="string"?R:Array.isArray(R)?R.find(he=>typeof he?.dir=="string")?.dir:null;return Zn(U)??(b?null:Fs)}async function Yn(b,A,R,U,V=null){if(U)try{if((await(await fetch(`${U.base}/edit/record?slide=${b}&kind=${A}`+(V==null?"":`&seg=${V}`)+`&dir=${encodeURIComponent(U.name)}`,{method:"POST",body:R})).json())?.ok)return!0}catch{}let he=`slide-${String(b).padStart(2,"0")}`+(V==null?"":`-${String(V).padStart(2,"0")}`)+`.${A==="wav"?"wav":"visemes.json"}`,D=URL.createObjectURL(R);return $(D,he),setTimeout(()=>URL.revokeObjectURL(D),5e3),!1}function zn(b){if(!b)return"";let A=b.clash&&b.why!=="refresh"?`<div class="rec-line rec-warn">${b.clash.files} file(s) are already in <code>${$t(b.dir)}/</code>${b.clash.voice?` (${$t(b.clash.voice)})`:""} and will be replaced.</div>`:"";return`<div class="rec-line rec-folder"><label>folder
293
+ <input class="rec-dir" value="${$t(b.dir)}" spellcheck="false"
294
+ aria-label="folder to record into"></label></div>${A}`}function os(b,A){let R=b?.querySelector(".rec-dir");if(!R)return;let U=()=>{let V=Zn(R.value.trim());return R.classList.toggle("rec-bad",!V),V};R.addEventListener("input",()=>{let V=U();V&&A({dir:V,label:R.dataset.label||V,clash:null})}),R.addEventListener("keydown",V=>{V.key==="Enter"&&V.stopPropagation()})}async function Us(b,A,R){let U=_();if(U!=null){b.textContent="saving\u2026";try{let V=await fetch(`${U}/edit/narration`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({files:A,...R})}),he=await V.json();if(!he?.ok)throw new Error(he?.error||`HTTP ${V.status}`);b.textContent="\u2713 the deck now plays this track \u2014 Z undoes it",b.classList.add("rec-done"),m("narr",`narration config \u2192 ${A}`)}catch(V){b.classList.add("rec-failed"),b.textContent=`couldn't write it \u2014 ${String(V.message||V)}`}}}function qr(b){return _()==null||!b?"":'<div class="narr-row narr-sel rec-use" role="button" tabindex="0">Use this track in the deck</div>'}function pr(b){let A=b?.querySelector(".rec-use");return A&&!A.classList.contains("rec-done")&&!A.classList.contains("rec-failed")?A:null}function Fr(b){return _()==null||!b?'<div class="rec-hint">Enter or Esc to close</div>':'<div class="rec-hint">\u23CE uses this track in the deck \xB7 Esc closes</div>'}function is(b,A,R){let U=b?.querySelector(".rec-use");if(!U)return;let V=()=>Us(U,A,R);U.addEventListener("click",V),U.addEventListener("keydown",he=>{(he.key==="Enter"||he.key===" ")&&(he.preventDefault(),V())})}function hr(){return c?.has?.("record")?"no author server answered, though <code>decklight record</code> started one \u2014 something else is holding the port for another deck. Stop it and record again; press D for the log.":location.protocol==="file:"?"this deck was opened from a file, so nothing may write beside it. <code>decklight record deck.html</code> serves it and writes them for you.":"no author server owns this deck file \u2014 <code>decklight record deck.html</code> writes them next to the deck instead."}async function zr(){let b=Wn(),A=++en,R=Date.now(),U=0,V=0,he=0,D=!1;if(await C(),A!==en)return;let se=_(),Xe=Ln??ur({mine:!1},await vr());if(A!==en)return;let Je=se==null?null:{base:se,name:Xe.dir};lr("progress",{done:U,total:b.length,elapsedMs:0});for(let Be of b){if(A!==en)return;try{let at=await ss(Be,A);if(A!==en)return;if(at?.wav){if(await Yn(Be,"wav",at.wav,Je)&&he++,A!==en)return;V++;for(let Ot of at.segments){if(await Yn(Be,"wav",Ot.wav,Je,Ot.file),A!==en)return;D=!0}let Mt=await qs(Be,A);if(A!==en||Mt?.slide&&(await Yn(Be,"visemes",new Blob([JSON.stringify(Mt.slide)],{type:"application/json"}),Je),A!==en))return;for(let Ot of Mt?.segments??[])if(await Yn(Be,"visemes",new Blob([JSON.stringify(Ot.timeline)],{type:"application/json"}),Je,Ot.file),A!==en)return}}catch{p(`slide ${Be}: recording failed`)}U++,A===en&&lr("progress",{done:U,total:b.length,elapsedMs:Date.now()-R})}A===en&&lr("done",{saved:V,total:b.length,dir:he?Je.name:null,segmented:D,label:Xe.label})}function xr(){if(!Q?.live){p("live voice only \u2014 pick a voice with N first");return}Vt||(Vt=document.createElement("div"),Vt.className="decklight-narr decklight-record",Vt.innerHTML='<div class="narr-card" role="dialog" aria-label="Record offline narration"></div>',Ut(Vt,mr),t.appendChild(Vt),Ln=null,lr("confirm",{total:Wn().length}),C().then(()=>vr()).then(b=>{!Vt||qn!=="confirm"||(Ln=ur({mine:!1},b),lr("confirm",{total:Wn().length,target:Ln}))}))}function mr(){en++,Vt?.remove(),Vt=null}let tn=null,fr="intro",Tn=0,Xn=null,hn=null,Un=null,Rn=null,kr=null,In=null,Ur=null,kn=0,Hr=null,Er=null;function Sr(){return navigator.mediaDevices?.getUserMedia?null:location.protocol==="file:"?"a browser will not open a microphone for a page loaded from a file. Serve the deck instead \u2014 <code>decklight record "+$t(as())+"</code> \u2014 and this works: 127.0.0.1 is a secure context, file:// is not.":"this browser exposes no microphone (getUserMedia needs a secure context \u2014 http://127.0.0.1 or https://)"}let as=()=>decodeURIComponent(location.pathname.split("/").pop()||"deck.html");function Hs(b){let A=b?.name??"";return A==="NotAllowedError"||A==="SecurityError"?"the microphone was blocked. Allow it for this page (the \u2699 or \u{1F3A4} in the address bar), then open it again from V \u2192 Record this deck\u2026":A==="NotFoundError"||A==="OverconstrainedError"?"no microphone was found. Plug one in, or pick one as the system input, then open it again from V \u2192 Record this deck\u2026":A==="NotReadableError"?"the microphone is busy \u2014 another app (a call, a recorder) is holding it. Close it and open it again from V \u2192 Record this deck\u2026":`the microphone could not be opened (${$t(String(b?.message||A||b))}).`}let ls=24e3;async function cs(){Un=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}});let b=window.AudioContext??window.webkitAudioContext;try{hn=new b({sampleRate:ls})}catch{hn=new b}kr=hn.createMediaStreamSource(Un),Rn=hn.createScriptProcessor(4096,1,1),Rn.onaudioprocess=R=>{let U=R.inputBuffer.getChannelData(0),V=0;for(let he=0;he<U.length;he++){let D=Math.abs(U[he]);D>V&&(V=D)}kn=Math.max(kn,V),In&&In.push(gd(U))};let A=hn.createGain();A.gain.value=0,kr.connect(Rn),Rn.connect(A),A.connect(hn.destination),hn.state==="suspended"&&await hn.resume(),m("narr",`mic open at ${hn.sampleRate} Hz`)}function ds(){try{Rn?.disconnect(),kr?.disconnect()}catch{}Rn&&(Rn.onaudioprocess=null),Un?.getTracks().forEach(b=>b.stop()),hn?.close?.(),hn=Un=Rn=kr=null,In=null,clearInterval(Hr),Hr=null}function js(){return In=[],kn=0,new Promise(b=>{Er=b})}function jr(b){if(!Er)return;Ur=In??[],In=null;let A=Er;Er=null,A(b)}function Gs(b){let A=Math.min(100,Math.round(b*140));return`<div class="rec-level${b>.95?" hot":""}"><div class="rec-level-fill" style="width:${A}%"></div></div>`}function Jn(b,A={}){fr=b;let R=tn?.querySelector(".narr-card");if(!R)return;if(b==="intro"){let{slides:Be,beats:at,why:Mt}=A;if(Mt){R.innerHTML=`<div class="narr-head">record your voice</div>
295
+ <div class="rec-line">${Mt}</div>
296
+ <div class="rec-hint">Esc to close</div>`;return}let{range:Ot,warn:Jt}=A;R.innerHTML=`<div class="narr-head">record your voice</div>
297
+ <div class="rec-line">${Be} slide${Be===1?"":"s"} \xB7 ${at} beat${at===1?"":"s"} \u2014 the deck reads you the notes, one \u27E8CLICK\u27E9 at a time${Ot?` <strong>(slides ${$t(Ot)} only \u2014 everything else is left alone)</strong>`:""}</div>
298
+ ${at===0?`<div class="rec-line rec-warn">Nothing to record${Ot?` in slides ${$t(Ot)}`:""} \u2014 no slide there has notes to read.</div>`:'<div class="rec-line">Press <kbd>\u2192</kbd> when you finish a beat: it ends the file <em>and</em> reveals the next build, so your voice paces the deck exactly as it will on the night.</div>'}
299
+ ${zn(A.target)}
300
+ ${Jt?`<div class="rec-line rec-warn">${Jt}</div>`:""}
301
+ ${at===0?"":'<div class="narr-row narr-sel">Start recording</div>'}
302
+ <div class="rec-hint">${at===0?"Esc to close":"Enter to start \xB7 Esc to cancel"}</div>`,os(R,vt=>{Xn=vt}),R.querySelector(".narr-row")?.addEventListener("click",()=>us());return}if(b==="capture"){let{sl:Be,nth:at,slides:Mt,beat:Ot,i:Jt,of:vt,note:Ft}=A;R.innerHTML=`<div class="narr-head">recording \xB7 slide ${at} of ${Mt}</div>
303
+ <div class="rec-line rec-where">slide ${Be} \xB7 beat ${Jt+1} of ${vt}</div>
304
+ <div class="rec-read">${$t(Ot.text)}</div>
305
+ ${Ft?`<div class="rec-line rec-note">${Ft}</div>`:""}
306
+ ${Gs(0)}
307
+ <div class="rec-hint"><kbd>\u2192</kbd> next beat \xB7 <kbd>\u232B</kbd> retake this one \xB7 <kbd>Esc</kbd> stop</div>`;return}if(b==="saving"){R.innerHTML=`<div class="narr-head">saving slide ${A.sl}\u2026</div>
308
+ <div class="rec-line">${A.files} file${A.files===1?"":"s"}</div>`;return}let{slides:U,files:V,dir:he,segmented:D,stopped:se}=A,Xe=he?`saved to <code>${$t(he)}/</code>, next to the deck`:`saved to your downloads \u2014 ${hr()}`,Je=`narration: { files: '${$t(he??"voiceover")}', ext: 'wav'${D?", segments: true":""} }`;R.innerHTML=`<div class="narr-head">${se?"recording stopped":"recording done"}</div>
309
+ <div class="rec-line">${U} slide${U===1?"":"s"} \xB7 ${V} file${V===1?"":"s"} ${Xe}</div>
310
+ <div class="rec-line">Play it back with <code>${Je}</code>${D?" \u2014 <strong>segments</strong> is what makes your voice step the builds.":"."}</div>
311
+ ${qr(he)}
312
+ ${Fr(he)}`,is(R,he,{ext:"wav",label:A.label,...D?{segments:!0}:{}})}async function us(){let b=++Tn,A=Wn();if(await C(),b!==Tn)return;let R=_(),U=Xn??ur({mine:!0},await vr());if(b!==Tn)return;let V=R==null?null:{base:R,name:U.dir},he=0,D=0,se=0,Xe=!1,Je=!1;s&&We();try{await cs()}catch(Be){Jn("intro",{why:Hs(Be)});return}Hr=setInterval(()=>{let Be=tn?.querySelector(".rec-level-fill"),at=tn?.querySelector(".rec-level");Be&&(Be.style.width=`${Math.min(100,Math.round(kn*140))}%`,at.classList.toggle("hot",kn>.95),kn*=.7)},100);e:for(let Be of A){if(b!==Tn)return;let at=ma(ye(Be),v(Be));if(!at.length)continue;let Mt=at.length===1&&v(Be)>0?`this slide has ${v(Be)} build${v(Be)===1?"":"s"} but no \u27E8CLICK\u27E9 in its notes \u2014 one take for the whole slide; add \u27E8CLICK\u27E9 between the beats to pace them`:null,Ot=[];for(let Ft=0;Ft<at.length;Ft++){let jt=at[Ft];E.goto(Be,jt.step),Jn("capture",{sl:Be,nth:he+1,slides:A.length,beat:jt,i:Ft,of:at.length,note:Mt});let Pn=await js();if(b!==Tn)return;if(Pn==="stop"){Je=!0;break e}if(Pn==="retake"){Ft--;continue}Ot.push({file:jt.file,pcm:Ur})}if(!Ot.length)continue;Jn("saving",{sl:Be,files:Ot.length+1});let Jt=hn?.sampleRate??ls,vt=Ot.flatMap(Ft=>Ft.pcm);if(await Yn(Be,"wav",dr(vt,Jt),V)&&se++,D++,b!==Tn)return;for(let Ft of Ot)if(Ft.file!=null){if(await Yn(Be,"wav",dr(Ft.pcm,Jt),V,Ft.file),b!==Tn)return;D++,Xe=!0}he++}ds(),b===Tn&&Jn("done",{slides:he,files:D,dir:se?V.name:null,segmented:Xe,stopped:Je,label:U.label})}function Gr(){if(tn)return;tn=document.createElement("div"),tn.className="decklight-narr decklight-record decklight-mic",tn.innerHTML='<div class="narr-card" role="dialog" aria-label="Record your voice"></div>',Ut(tn,Qn),t.appendChild(tn);let b=Sr(),A=Wn(),R=A.reduce((V,he)=>V+ma(ye(he),v(he)).length,0),U=c?.get?.("slides");Xn=null,Jn("intro",b?{why:b}:{slides:A.length,beats:R,range:U}),!b&&C().then(()=>vr()).then(V=>{!tn||fr!=="intro"||(Xn=_()==null?null:ur({mine:!0},V),Jn("intro",{slides:A.length,beats:R,range:U,target:Xn,warn:_()==null?hr():null}))})}function Qn(){Tn++,jr("stop"),ds(),tn?.remove(),tn=null}return w.register({isOpen:()=>!!tn,close:Qn,keydown(b){if(fr==="capture"){if(b.key==="ArrowRight"||b.key==="Enter"||b.key===" "||b.key==="PageDown")jr("next");else if(b.key==="Backspace")jr("retake");else if(b.key==="Escape")Qn();else return!1;return!0}if(b.key==="Escape")Qn();else if(b.key==="Enter")fr==="intro"&&!Sr()&&tn?.querySelector(".narr-row")?us():pr(tn)?pr(tn).click():fr!=="saving"&&Qn();else return!1;return!0}}),w.register({isOpen:()=>!!Vt,close:mr,keydown(b){if(b.key==="Escape")mr();else if(b.key==="Enter")qn==="confirm"?zr():pr(Vt)?pr(Vt).click():qn!=="progress"&&mr();else return!1;return!0}}),w.register({isOpen:()=>!!qt,close:an,keydown(b){if(St==="custom")return b.key==="Enter"?(Ht(),!0):b.key==="Escape"?(An(),!0):!1;switch(b.key){case"ArrowDown":xn(bn+1,{scroll:!0});break;case"ArrowUp":xn(bn-1,{scroll:!0});break;case"Enter":wr();break;case"Escape":An();break;case"v":case"V":an();break;default:return!1}return!0}}),{character:Pe,playPause:we,toggleNarration:We,toggleNarrPause:nn,changeNarrRate:B,toggleCaptions:yt,openPicker:un,openRecordDialog:xr,openMicRecorder:Gr,applySolo:Nn,notesSegs:ye,status:()=>({narrating:s,paused:He,rate:De,captionsOn:xe,track:Q,live:!!Q?.live,voice:Ie.voice,tone:Ie.tone,hasTracks:fe.length>0,voiceInPlay:Ye(),spend:I})}}ge();be();function yd(t,o){let a=[];for(let c=0;c<t;c+=o){let d=[];for(let p=c;p<t&&p<c+o;p++)d.push(p);a.push(d)}return a}function ya(t,o,a){let c=t.ownerDocument,d=m=>{let w=c.createElement("div");return w.className=m,w},p=m=>{let w=d("print-slot"),E=d("decklight-stage print-slide");return E.appendChild(m),w.appendChild(E),w};if(a==="handout")for(let m of yd(o.length,3)){let w=d("print-page print-handout");for(let E of m){let S=d("print-row");S.appendChild(p(o[E])),S.appendChild(d("print-notelines")),w.appendChild(S)}t.appendChild(w)}else o.forEach(m=>{let w=d("print-page print-notes-page"),E=d("print-notes"),S=m.querySelector("aside.notes");S&&(E.innerHTML=S.innerHTML),w.appendChild(p(m)),w.appendChild(E),t.appendChild(w)});let g=c.createElement("style");g.textContent="@media print { @page { size: 816px 1056px; margin: 0; } html, body { margin: 0; padding: 0; } }",c.head.appendChild(g)}ge();be();ge();be();function wd(t,o,a,c){let d=c||1;return{x:(t-a.left)/d,y:(o-a.top)/d}}function vd(t,o,a=300){return t.filter(c=>o-c.t<a)}function wa(t,o){let a=o.querySelector(":scope > .decklight-stage"),c=null,d=null,p=null,g=[],m=null,w=[],E=null,S=0,P=()=>getComputedStyle(o).getPropertyValue("--accent").trim()||"#fff",$=_e=>wd(_e.clientX,_e.clientY,a.getBoundingClientRect(),t._scale);function _(){if(!d)return;let _e=window.devicePixelRatio||1,Ae=o.getBoundingClientRect(),st=a.getBoundingClientRect(),bt=t._scale||1;d.setTransform(1,0,0,1,0,0),d.clearRect(0,0,c.width,c.height),d.setTransform(_e*bt,0,0,_e*bt,(st.left-Ae.left)*_e,(st.top-Ae.top)*_e),d.lineCap=d.lineJoin="round",d.lineWidth=3.5;for(let T of m?[...g,m]:g)if(T.points.length){d.strokeStyle=T.color,d.beginPath(),d.moveTo(T.points[0].x,T.points[0].y);for(let Ke of T.points)d.lineTo(Ke.x,Ke.y);d.stroke()}if(p==="laser"&&E){let T=P(),Ke=performance.now();d.fillStyle=T;for(let mt of w){let dt=1-(Ke-mt.t)/300;d.globalAlpha=dt*.4,d.beginPath(),d.arc(mt.x,mt.y,3+4*dt,0,Math.PI*2),d.fill()}d.globalAlpha=1,d.shadowColor=T,d.shadowBlur=22,d.beginPath(),d.arc(E.x,E.y,7,0,Math.PI*2),d.fill(),d.shadowBlur=0}}function C(){S=0,w=vd(w,performance.now()),_(),w.length&&(S=requestAnimationFrame(C))}let I=()=>{S||(S=requestAnimationFrame(C))};function Se(_e){if(!(p!=="pen"||_e.button>0)){try{c.setPointerCapture(_e.pointerId)}catch{}m={color:P(),points:[$(_e)]},_(),_e.preventDefault()}}function de(_e){p==="pen"&&m?(m.points.push($(_e)),_()):p==="laser"&&(E=$(_e),w.push({...E,t:performance.now()}),I())}function $e(){m&&(g.push(m),m=null)}function te(){let _e=o.getBoundingClientRect(),Ae=window.devicePixelRatio||1;c.width=Math.max(1,Math.round(_e.width*Ae)),c.height=Math.max(1,Math.round(_e.height*Ae)),_()}function ae(){c||(c=document.createElement("canvas"),c.className="decklight-annotate",c.setAttribute("aria-hidden","true"),o.appendChild(c),d=c.getContext("2d"),c.addEventListener("pointerdown",Se),c.addEventListener("pointermove",de),c.addEventListener("pointerup",$e),c.addEventListener("pointercancel",$e),c.addEventListener("touchstart",_e=>_e.stopPropagation(),{passive:!0}),te(),new ResizeObserver(()=>{te(),requestAnimationFrame(_)}).observe(o))}function Re(_e="pen"){return p=p===_e?null:_e,p&&ae(),c&&(c.classList.toggle("tool-pen",p==="pen"),c.classList.toggle("tool-laser",p==="laser")),m&&(g.push(m),m=null),p!=="laser"&&(w=[],E=null,d&&_()),p}function Fe(){g=[],m=null,w=[],E=null,d&&_()}function je(_e){ae(),g.push({color:P(),points:_e.map(Ae=>({x:Ae.x,y:Ae.y}))}),_()}return t.on("slide",Fe),{toggle:Re,laser:()=>Re("laser"),clear:Fe,stroke:je,get tool(){return p},get active(){return p!==null}}}function va({root:t,printMode:o,toast:a,debugLog:c,overlays:d,instance:p,narration:g,downloadFromUrl:m,setProgressBar:w}){let E="decklight-clock:"+location.pathname,S=!1;try{S=localStorage.getItem(E)==="1"}catch{}let P=null,$=null,_=null,C=!1,I=J=>String(J).padStart(2,"0");function Se(J){let ne=Math.floor(J/1e3),fe=Math.floor(ne/3600);return(fe?fe+":":"")+I(Math.floor(ne/60)%60)+":"+I(ne%60)}function de(){if(!P)return;let J=new Date;P.querySelector(".clk-time").textContent=I(J.getHours())+":"+I(J.getMinutes()),P.querySelector(".clk-elapsed").textContent="+"+Se(_==null?0:Date.now()-_)}function $e(){P=document.createElement("div"),P.className="decklight-clock",P.innerHTML='<span class="clk-time"></span><span class="clk-elapsed"></span>',t.appendChild(P),de(),$=setInterval(de,1e3)}function te(){S=!S;try{localStorage.setItem(E,S?"1":"0")}catch{}S?$e():(clearInterval($),$=null,P?.remove(),P=null),a(`clock ${S?"on":"off"}`),c("nav",`clock ${S?"on":"off"}`)}p.on("ready",()=>{C=!0});let ae=()=>{!C||_!=null||(_=Date.now(),de())};p.on("slide",ae),p.on("build",ae),p.toggleClock=te,S&&!o&&$e();let Re="decklight-progress:"+location.pathname,Fe=!1;try{Fe=localStorage.getItem(Re)==="1"}catch{}let je=null;function _e(){je=document.createElement("div"),je.className="decklight-progress",je.innerHTML='<div class="bar"></div>',t.appendChild(je),w(je.querySelector(".bar")),p._updateChrome()}function Ae(){Fe=!Fe;try{localStorage.setItem(Re,Fe?"1":"0")}catch{}Fe?_e():(je?.remove(),je=null,w(null)),a(`progress bar ${Fe?"on":"off"}`),c("nav",`progress bar ${Fe?"on":"off"}`)}p.toggleProgress=Ae,Fe&&!o&&_e();let st=null;o||(st=wa(p,t),p.annotate=st);function bt(J){if(!st)return;let ne=J==="laser"?st.laser():st.toggle();a(ne==="pen"?"pen on \u2014 drag to draw \xB7 \u232B clears \xB7 W off":ne==="laser"?"laser on \u2014 \u21E7W off":"ink off"),c("nav",`ink ${ne??"off"}`)}function T(){return(p._sections||[]).map((J,ne)=>({n:ne+1,title:J.querySelector("h1, h2, h3")?.textContent.trim()||`Slide ${ne+1}`,segs:g.notesSegs(ne+1).filter(Boolean)}))}function Ke(J){let ne=(document.title||"Deck").trim(),fe=J?[`# ${ne} \u2014 transcript`,""]:[`${ne} \u2014 transcript`,""];for(let{n:ue,title:Ie,segs:Q}of T())if(Q.length){fe.push(J?`## ${ue}. ${Ie}`:`${ue}. ${Ie}`,"");for(let s of Q)fe.push(s,"")}return fe.join(`
313
+ `)}function mt(J){let ne=J==="md",fe=URL.createObjectURL(new Blob([Ke(ne)],{type:ne?"text/markdown":"text/plain"})),ue=(location.pathname.split("/").pop()||"deck").replace(/\.html?$/i,"");m(fe,`${ue}-transcript.${ne?"md":"txt"}`),setTimeout(()=>URL.revokeObjectURL(fe),5e3),c("narr",`transcript exported (.${ne?"md":"txt"})`)}let dt=null;function G(){if(dt){dt.remove(),dt=null;return}dt=document.createElement("div"),dt.className="decklight-narr decklight-transcript";let J=document.createElement("div");J.className="narr-card";let ne=document.createElement("div");ne.className="narr-head",ne.textContent="transcript \u2014 the deck\u2019s spoken notes \xB7 Esc closes";let fe=document.createElement("div");fe.className="tr-actions";for(let[ue,Ie]of[["\u2B07 export .txt","txt"],["\u2B07 export .md","md"]]){let Q=document.createElement("button");Q.type="button",Q.className="narr-prev-btn",Q.textContent=ue,Q.addEventListener("click",()=>mt(Ie)),fe.appendChild(Q)}J.append(ne,fe);for(let{n:ue,title:Ie,segs:Q}of T()){if(!Q.length)continue;let s=document.createElement("div");s.className="tr-slide";let i=document.createElement("div");i.className="tr-title",i.textContent=`${ue} \xB7 ${Ie}`,i.title="jump to this slide",i.addEventListener("click",()=>{G(),p.goto(ue,0,{force:!0})}),s.appendChild(i);for(let O of Q){let De=document.createElement("p");De.className="tr-seg",De.textContent=O,s.appendChild(De)}J.appendChild(s)}dt.appendChild(J),Ut(dt,G),t.appendChild(dt)}return p.transcript={open:G,text:()=>Ke(!1),markdown:()=>Ke(!0)},d.register({isOpen:()=>!!dt,close:G,keydown:J=>J.key==="Escape"&&(G(),!0)}),{toggleClock:te,toggleProgress:Ae,toggleInk:bt,toggleTranscript:G,get annotator(){return st},status:()=>({clockOn:S,progressOn:Fe})}}ge();be();var xd=["data-background-image","data-background-video","data-background-poster","data-background-size","data-background-position","data-background-dim"];function kd(t){let o=t["data-background-image"]||null,a=t["data-background-video"]||null;if(!o&&!a)return null;let c=parseFloat(t["data-background-dim"]);return{image:o,video:a,poster:t["data-background-poster"]||null,size:t["data-background-size"]==="contain"?"contain":"cover",position:t["data-background-position"]||"center",dim:Number.isFinite(c)?Math.min(Math.max(c,0),1):0}}var Ed=t=>`url("${String(t).replace(/["\\]/g,"\\$&")}")`;function Sd(t){let o={};for(let a of xd){let c=t.getAttribute(a);c!==null&&(o[a]=c)}return o}function xa(t,{printMode:o=!1}={}){t.forEach(a=>{let c=kd(Sd(a)),d=a.querySelector(":scope > .slide-bg");if(!c){d?.remove();return}let p=JSON.stringify(c)+(o?"\xB7print":"");if(d&&d.dataset.sig===p){d!==a.firstElementChild&&a.prepend(d);return}d||(d=document.createElement("div"),d.className="slide-bg",d.setAttribute("aria-hidden","true")),d.dataset.sig=p,d.textContent="",d.style.backgroundSize=c.size,d.style.backgroundPosition=c.position;let g=c.image||(o?c.poster:null);if(d.style.backgroundImage=g?Ed(g):"",c.video&&!o){let m=document.createElement("video");m.muted=!0,m.loop=!0,m.setAttribute("muted",""),m.setAttribute("loop",""),m.setAttribute("playsinline",""),m.preload="auto",c.poster&&(m.poster=c.poster),m.style.objectFit=c.size,m.style.objectPosition=c.position,m.src=c.video,d.appendChild(m)}if(c.dim>0){let m=document.createElement("div");m.className="slide-bg-dim",m.style.opacity=String(c.dim),d.appendChild(m)}a.prepend(d)})}ge();be();ge();be();var Ad="npx decklight author";function _d(t){let o=t||"";try{o=decodeURIComponent(o)}catch{}/^\/[A-Za-z]:/.test(o)&&(o=o.slice(1));let a=o.lastIndexOf("/");return{dir:a>0?o.slice(0,a):"",file:a>=0?o.slice(a+1):o}}function Dn(t,o={}){let{protocol:a="",pathname:c=""}=o,{dir:d,file:p}=_d(c),g=/\.html?$/i.test(p)?p:"<deck.html>",m=a==="file:"&&d?`from ${d}, `:"";return`${t} needs author mode: ${m}run ${Ad} ${g}, then reopen the URL it prints`}function Td(t){let o=Math.max(0,Math.floor((Number(t)||0)/1e3)),a=String(o%60).padStart(2,"0"),c=Math.floor(o/60);return c<60?`${c}:${a}`:`${Math.floor(c/60)}:${String(c%60).padStart(2,"0")}:${a}`}var $d={second:"s",minute:"m",hour:"h",day:"d",week:"w",month:"mo",year:"y"};function ka(t){let o=/^(\d+)\s+(second|minute|hour|day|week|month|year)s?\s+ago$/.exec(String(t??"").trim());return o?`${o[1]}${$d[o[2]]}`:String(t??"")}function Ea(t,o=Date.now()){if(!t||!t.agent)return null;let a=typeof t.activity=="string"&&t.activity.trim()?` \u2014 ${t.activity.trim().slice(0,60)}`:"",c=Number(t.startedAt);return!Number.isFinite(c)||c<=0||c>o?`${t.agent}${a}`:`${t.agent} \xB7 ${Td(o-c)}${a}`}function Sa(t,{shown:o=!1,threshold:a=10}={}){if(o||!t||!["ok","no-upstream"].includes(t.state))return null;let c=t.state==="ok"?t.ahead:t.unpushed;return!c||c<a?null:`\u2191${c} commits are only on this machine \u2014 H shows them`}function Aa(t){if(!t||!t.nag||!t.dirty||!t.canWrite)return null;let o=Math.floor((Number(t.sinceMs)||0)/6e4),a=o>=60?` \xB7 ${Math.floor(o/60)}h`:o>=1?` \xB7 ${o}m`:"",c=Number(t.lines)||0;return`${c?`${c} line${c===1?"":"s"}`:"changes"} uncommitted${a} \u2014 K commits`}ge();be();var Cd=/<\s*(pre|textarea|script|style)\b/i,Nd=t=>!Cd.test(String(t??""));function _a(t){let o=String(t??"");if(!Nd(o))return o;let a=o.split(`
314
+ `);if(a.length<2)return o;let c=1/0;for(let d of a.slice(1))if(d.trim()&&(/^\s*\t/.test(d)||(c=Math.min(c,/^ */.exec(d)[0].length),c===0)))return o;return Number.isFinite(c)?a.map((d,p)=>p===0?d:d.trim()?d.slice(c):"").join(`
315
+ `):o}function Ta({root:t,config:o,params:a,printMode:c,toast:d,debugLog:p,overlays:g,instance:m,notesSegs:w,dismissOthers:E}){let S=!1,P="",$=[],_=null,C=[],I=null,Se=!1,de=null,$e=0;function te(){let M=Ea(I);if(!M){clearInterval($e),$e=0,de?.remove(),de=null;return}de||(de=document.createElement("div"),de.className="decklight-agent-chip",de.setAttribute("role","status"),de.setAttribute("aria-live","polite"),t.appendChild(de)),de.textContent=`\u{1F916} ${M}`,de.title=I.prompt?`asked: ${I.prompt}`:"",$e||($e=setInterval(te,1e3))}let ae=null,Re=null;function Fe(){let M=Aa(ae);if(!M){Re?.remove(),Re=null;return}if(!Re){Re=document.createElement("div"),Re.className="decklight-commit-chip",Re.setAttribute("role","status"),Re.setAttribute("aria-live","polite"),Re.tabIndex=0;let j=()=>bt();Re.addEventListener("click",j),Re.addEventListener("keydown",H=>{(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),j())}),t.appendChild(Re)}Re.textContent=`\u2325 ${M}`,Re.title="commit this \u2014 the work is snapshotted either way"}async function je(){if(!S)return null;try{let j=await(await fetch(P+"/edit/commit")).json();if(j?.ok)return ae=j,Fe(),j}catch{}return null}let _e=null,Ae=!1;function st(){_e?.remove(),_e=null,Ae=!1}async function bt(){if(_e)return st();if(!S){d(Dn("committing",location),3200);return}let M=await je()??ae;if(!M?.canWrite){d("this session is not committing \u2014 start author with --git",3e3);return}if(!M.dirty){d("nothing to commit \u2014 the deck matches its last commit",2400);return}E(),_e=document.createElement("div"),_e.className="decklight-narr decklight-commit",_e.innerHTML='<div class="narr-card" role="dialog" aria-label="Commit"></div>',Ut(_e,st),t.appendChild(_e);let j=_e.querySelector(".narr-card"),H=document.createElement("div");H.className="narr-head",H.textContent="commit";let we=document.createElement("div");we.className="cm-what";let Ye=Number(M.lines)||0,We=Math.floor((Number(M.sinceMs)||0)/6e4);we.textContent=`${Ye?`${Ye} line${Ye===1?"":"s"}`:"changes"} in ${M.deck||"the deck"}`+(We>=1?`, ${We>=60?`${Math.floor(We/60)}h`:`${We}m`} old`:"");let Ve=document.createElement("textarea");Ve.className="narr-input cm-input",Ve.rows=3,Ve.placeholder="what changed, in one line\u2026";let xe=document.createElement("div");xe.className="cm-row";let Oe=document.createElement("div");Oe.className="narr-row narr-sel cm-write",Oe.setAttribute("role","button"),Oe.tabIndex=0,Oe.textContent=M.messages?"writing one\u2026":"write one for me";let ot=document.createElement("div");ot.className="narr-row narr-sel cm-go",ot.setAttribute("role","button"),ot.tabIndex=0,ot.textContent="Commit",xe.append(Oe,ot);let Et=document.createElement("div");Et.className="rec-hint",Et.textContent="\u2318\u23CE commits \xB7 Esc closes \u2014 the work is snapshotted either way",j.append(H,we,Ve,xe,Et),setTimeout(()=>Ve.focus(),0);let Tt=async()=>{if(!Ae){Ae=!0,Oe.textContent="writing one\u2026";try{let Qe=await fetch(P+"/edit/commit/subject",{method:"POST"}),wt=await Qe.json();if(!wt?.ok)throw new Error(wt?.error||`HTTP ${Qe.status}`);if(!_e)return;wt.subject&&!Ve.value.trim()&&(Ve.value=wt.subject),Oe.textContent=wt.subject?"write another":"nothing to say about it"}catch(Qe){_e&&(Oe.textContent=`couldn't \u2014 ${String(Qe.message||Qe).slice(0,40)}`)}finally{Ae=!1}}};Oe.addEventListener("click",Tt),M.messages&&Tt();let yt=async()=>{let Qe=Ve.value.trim();if(!Qe){Ve.focus();return}ot.textContent="committing\u2026";try{let wt=await fetch(P+"/edit/commit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({message:Qe})}),L=await wt.json();if(!L?.ok)throw new Error(L?.error||`HTTP ${wt.status}`);st(),ae=L.committed?{...L,nag:!1}:ae,Fe(),d(L.committed?`committed \u2014 "${L.subject}"`:"nothing to commit",2600),p("git",L.committed?`commit: ${L.subject}`:"commit: nothing to do")}catch(wt){ot.textContent=`couldn't commit \u2014 ${String(wt.message||wt).slice(0,40)}`}};ot.addEventListener("click",yt),Ve.addEventListener("keydown",Qe=>{Qe.key==="Enter"&&(Qe.metaKey||Qe.ctrlKey)&&(Qe.preventDefault(),yt()),!((Qe.metaKey||Qe.ctrlKey)&&(Qe.key==="k"||Qe.key==="K"))&&Qe.stopPropagation()}),T??=g.register({isOpen:()=>!!_e,close:st,keydown(Qe){return Qe.key==="Escape"?(st(),!0):/^(input|textarea)$/i.test(Qe.target?.tagName??"")?!1:Qe.key==="Enter"?(_e?.querySelector(".cm-go")?.click(),!0):Qe.key==="k"||Qe.key==="K"?(st(),!0):!1}})}let T=null,Ke,mt=new Promise(M=>{Ke=M});if(!c&&!a.has("embedded")){let M=o.edit?.url?[o.edit.url]:/^https?:$/.test(location.protocol)?[""]:["http://127.0.0.1:8788"];(async()=>{for(let j of M)try{let H=await fetch(j+"/edit/ping");if(!H.ok)continue;let we=await H.json();if(!we?.ok)continue;let Ye=decodeURIComponent(location.pathname.split("/").pop()||"");if(Ye&&we.name&&Ye!==we.name){p("edit",`server edits ${we.name}, this deck is ${Ye} \u2014 not wiring up`);continue}P=j,S=!0,$=Array.isArray(we.agents)?we.agents:[],_=typeof we.preferredAgent=="string"?we.preferredAgent:null,C=Array.isArray(we.wizards)?we.wizards:[];let We=Sa(we.remote);We&&(Se=!0,d(We,4200)),we.commit&&(ae=we.commit,Fe()),I=we.agentBusy||null,I&&d(`${I.agent} is editing the deck\u2026`,2e3),te();let Ve=new EventSource(j+"/edit/events");Ve.onmessage=()=>location.reload(),Ve.addEventListener("commit",xe=>{try{ae=JSON.parse(xe.data),Fe(),p("git",`uncommitted: ${ae.lines} lines`)}catch{}}),Ve.addEventListener("agent",xe=>{try{let Oe=JSON.parse(xe.data);if(Oe.state==="activity")I&&(I.activity=Oe.text,te()),p("agent",`activity: ${Oe.text}`);else if(Oe.state==="start")I=Oe,te(),d(`\u{1F916} ${Oe.agent} is editing the deck\u2026`,2200),p("agent",`${Oe.agent} start: ${(Oe.prompt||"").slice(0,80)}`);else if(Oe.state==="done"){I=null,te();let ot=Oe.ok?"":Oe.error?` \u2014 ${Oe.error}`:` (exit ${Oe.code})`;d(Oe.changed?`\u{1F916} ${Oe.agent} edited the deck \u2014 Z undoes${ot}`:`\u{1F916} ${Oe.agent} finished \u2014 no changes${ot}`,3e3),p("agent",`${Oe.agent} done ok=${Oe.ok} changed=${Oe.changed}${ot}`),typeof Oe.recordingWarning=="string"&&(d(Oe.recordingWarning,9e3),p("agent",Oe.recordingWarning))}}catch{}}),p("edit",`live reload connected${j?` (${j})`:""}`+($.length?` \xB7 agents: ${$.map(xe=>xe.name).join(", ")}`:"")),Ke();return}catch{}Ke(),await s()})()}let dt=null,G=!1,J=null;function ne(){J?.remove(),J=null}function fe(M,j){let H=document.createElement("div");return H.className=j,H.textContent=M,H}async function ue(M){let j=J?.querySelector(".tp-list");if(!j)return;j.textContent="",j.appendChild(fe(M.message??M.state,"hs-remote"));for(let Ye of M.commits??[])j.appendChild(fe(`${Ye.hash} ${Ye.subject}`,"tp-row"));let H=J.querySelector(".up-actions");H.textContent="";let we=(Ye,We)=>{let Ve=document.createElement("button");return Ve.type="button",Ve.className="narr-prev-btn",Ve.textContent=Ye,Ve.addEventListener("click",We),H.appendChild(Ve),Ve};we("check now",async()=>{H.textContent="checking\u2026",await ue(await Ie("/present/upstream/check"))}),M.state==="behind"&&M.pull?.offered?we("update the deck",async()=>{H.textContent="pulling\u2026";let Ye=await Ie("/present/upstream/pull");if(Ye.reload)return location.reload();await ue({...Ye,commits:[],message:Ye.message}),Ye.state==="pulled"&&we("show it anyway",()=>location.reload())}):M.pull&&!M.pull.offered&&M.state==="behind"&&H.appendChild(fe(`update control off \u2014 ${M.pull.reason}`,"hs-remote"))}async function Ie(M){try{return await(await fetch(dt+M,{method:"POST"})).json()}catch{return{state:"error",message:"the presenting server did not answer"}}}async function Q(){if(J)return ne();let M;try{let j=await fetch(dt+"/present/upstream");if(!j.ok)return d("this deck is not a tracked file in a git clone \u2014 nothing to update from",3400);M=await j.json()}catch{return d("deck update: the presenting server did not answer",3e3)}E(),J=document.createElement("div"),J.className="decklight-theme-picker decklight-finder decklight-restore decklight-history",J.innerHTML='<div class="tp-panel"><div class="tp-side"><div class="tp-filter">Deck update \u2014 Esc closes</div><div class="tp-list" role="listbox" aria-label="Upstream commits"></div><div class="up-actions tr-actions"></div></div></div>',Ut(J,ne),t.appendChild(J),await ue(M)}g.register({isOpen:()=>!!J,close:ne,keydown:M=>M.key==="Escape"&&(ne(),!0)});async function s(){let M=/^https?:$/.test(location.protocol)?"":"http://127.0.0.1:8790";try{let j=await fetch(M+"/present/ping");if(!j.ok)return;let H=await j.json();if(!H?.ok||!H.present)return;let we=decodeURIComponent(location.pathname.split("/").pop()||"");if(we&&H.name&&we!==H.name){p("present",`server presents ${H.name}, this deck is ${we} \u2014 not wiring up`);return}m.__remoteQr=H.remote?`${M||location.origin}/remote/qr.svg`:null,dt=M,G=!0,new EventSource(M+"/present/events").addEventListener("remote",Ve=>{try{let{key:xe}=JSON.parse(Ve.data);xe==="next"?m.next():xe==="prev"&&m.prev()}catch{}});let We=()=>{fetch(M+"/remote/pos",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({i:m.state.slide,n:m.state.totalSlides})}).catch(()=>{})};m.on("slide",We),m.on("build",We),We(),p("present",`remote connected${M?` (${M})`:""} \u2014 no edit surface`)}catch{}}async function i(M){if(!S){d(Dn(M,location),3200);return}try{let j=await fetch(P+"/edit/"+M,{method:"POST"}),H=await j.json().catch(()=>({}));if(!j.ok){d(H.error||`${M} failed`);return}d(`${M} \u2014 ${H.undo} back \xB7 ${H.redo} forward`),p("edit",`${M} \u2192 ${H.undo} back, ${H.redo} forward`)}catch{d(`${M} failed \u2014 is the dev server still up?`,2200)}}let O=null;function De(){if(O){O.remove(),O=null;return}if(!S){d(Dn("asking an agent",location),3200);return}if(!$.length){d("no agent CLI detected on the dev machine (claude, codex, bob, \u2026)",2600);return}if(I){d(`${I.agent} is still working on the last ask`,2200);return}O=document.createElement("div"),O.className="decklight-narr decklight-editor";let M=document.createElement("div");M.className="narr-card";let j=document.createElement("div");j.className="narr-head",j.textContent="ask an agent \u2014 edits the deck file \xB7 \u2318\u23CE sends \xB7 Esc closes";let H=document.createElement("textarea");H.className="narr-input edit-notes",H.placeholder=`e.g. "make slide ${m.state.slide} a split layout with the diagram on the left"`,H.spellcheck=!1;let we=_&&$.some(xe=>xe.name===_)?_:$[0].name,Ye=document.createElement("div");if(Ye.className="tr-actions",$.length>1){let xe=document.createElement("select");xe.className="narr-prev-btn";for(let Oe of $){let ot=document.createElement("option");ot.value=Oe.name,ot.textContent=Oe.label,xe.appendChild(ot)}xe.value=we,xe.addEventListener("change",()=>{we=xe.value,_=xe.value,fetch(P+"/edit/agent/prefer",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({agent:xe.value})}).catch(()=>{}),p("agent",`preferred agent \u2192 ${xe.value}`)}),xe.addEventListener("keydown",Oe=>Oe.stopPropagation()),Ye.appendChild(xe)}let We=async()=>{let xe=H.value.trim();if(xe)try{let Oe=await fetch(P+"/edit/agent",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({prompt:xe,agent:we})}),ot=await Oe.json().catch(()=>({}));if(!Oe.ok)throw new Error(ot.error||Oe.status);De()}catch(Oe){d(`ask failed: ${String(Oe.message||Oe).slice(0,60)}`,2200)}};H.addEventListener("keydown",xe=>{xe.key==="Enter"&&(xe.metaKey||xe.ctrlKey)?(We(),xe.preventDefault()):xe.key==="Escape"&&(De(),xe.preventDefault()),xe.stopPropagation()});let Ve=document.createElement("button");Ve.type="button",Ve.className="narr-prev-btn",Ve.textContent="\u{1F916} send to agent",Ve.addEventListener("click",We),Ye.appendChild(Ve),M.append(j,H,Ye),O.appendChild(M),Ut(O,De),t.appendChild(O),setTimeout(()=>H.focus(),0)}let B=null;function Pe(){if(B){B.remove(),B=null;return}let M=m.state.slide;if(!S){d(Dn("editing notes",location),3200);return}B=document.createElement("div"),B.className="decklight-narr decklight-editor";let j=document.createElement("div");j.className="narr-card";let H=document.createElement("div");H.className="narr-head",H.textContent=`edit notes \u2014 slide ${M} \xB7 \u2318\u23CE saves \xB7 Esc closes`;let we=document.createElement("textarea");we.className="narr-input edit-notes",we.value=w(M).filter((xe,Oe,ot)=>xe||Oe<ot.length).join(`
294
316
 
295
317
  \u27E8CLICK\u27E9
296
318
 
297
- `),se.spellcheck=!1;let $e=async()=>{try{let $=await fetch(P+"/edit/notes",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:R,text:se.value})});if(!$.ok)throw new Error(await $.text());m("edit",`notes saved \u2014 slide ${R}`),u("notes saved \u2014 reloading")}catch($){u(`save failed: ${String($.message||$).slice(0,60)}`)}};se.addEventListener("keydown",$=>{$.key==="Enter"&&($.metaKey||$.ctrlKey)?($e(),$.preventDefault()):$.key==="Escape"&&(D(),$.preventDefault()),$.stopPropagation()});let S=document.createElement("div");S.className="tr-actions";let L=document.createElement("button");L.type="button",L.className="narr-prev-btn",L.textContent="\u{1F4BE} save to file",L.addEventListener("click",$e),S.appendChild(L),W.append(U,se,S),O.appendChild(W),It(O,D),r.appendChild(O),setTimeout(()=>se.focus(),0)}let V=["fade","fade-up","fade-down","zoom","pop","draw","highlight"],re=!1,Ae=null,Ke=[],Ce=0,s="main",o=null;function N(){if(!A){u(fn("editing an element",location),3200);return}re=!re,B(),u(re?"element edit mode on \u2014 right-click a slide element":"element edit mode off",2200)}function Fe(R,W){let U=W;for(;U&&U!==R&&U.parentElement!==R;)U=U.parentElement;return U&&U!==R?U:null}r.addEventListener("contextmenu",R=>{if(!re)return;let W=R.target.closest("section"),U=W?h._sections.indexOf(W)+1:0;if(!W||!U)return;if(R.preventDefault(),W.hasAttribute("data-markdown-removed")){u("this slide has no per-element source mapping (data-markdown, removed in 0.3.0) \u2014 edit the file directly",3400);return}let se=Fe(W,R.target),$e=se?[...W.children].indexOf(se):null;k?.(),K(R.clientX,R.clientY,{sec:W,slide:U,index:$e})});function B(){Ae?.remove(),Ae=null,s="main"}function ot(){let R=Ae.querySelector(".cm-list");R.textContent="";let W=[];if(s==="effects"){W.push({label:"\u2190 back",back:!0,run:()=>{s="main",ot()}});for(let U of V)W.push({label:U,run:()=>Y(U)});W.push({label:"none (instant)",run:()=>Y("none")}),W.push({label:"remove effect",run:()=>Y(null)})}else o.index===null?W.push({label:"Edit speaker notes",run:()=>{B(),D()}}):(W.push({label:"Edit speaker notes",run:()=>{B(),D()}}),W.push({label:"Remove element",run:_e}),W.push({label:"Edit content (HTML)",run:()=>{B(),Be(o)}}),W.push({label:"Add text effect \u25B8",run:()=>{s="effects",ot()}}));Ke=W,W.forEach((U,se)=>{let $e=document.createElement("div");$e.className="cm-row"+(U.back?" cm-back":""),$e.setAttribute("role","option"),$e.textContent=U.label,$e.addEventListener("mouseenter",()=>mt(se,!1)),$e.addEventListener("click",U.run),R.appendChild($e)}),mt(0,!1)}function mt(R,W){let U=Ae.querySelectorAll(".cm-row");U.length&&(Ce=on(U,R,"cm-selected",{scroll:W}))}function K(R,W,U){o=U,s="main",Ae=document.createElement("div"),Ae.className="decklight-ctxmenu";let se=document.createElement("div");se.className="cm-card";let $e=document.createElement("div");$e.className="cm-list",$e.setAttribute("role","listbox"),$e.setAttribute("aria-label","Element edit menu"),se.appendChild($e),Ae.appendChild(se),r.appendChild(Ae),ot();let S=r.getBoundingClientRect(),L=Math.min(R-S.left,S.width-se.offsetWidth-4),$=Math.min(W-S.top,S.height-se.offsetHeight-4);se.style.left=Math.max(4,L)+"px",se.style.top=Math.max(4,$)+"px",It(Ae,B)}async function _e(){let{slide:R,index:W}=o;B();try{let U=await fetch(P+"/edit/element/remove",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:R,index:W})}),se=await U.json().catch(()=>({}));if(!U.ok)throw new Error(se.error||U.status);u(se.changed?"element removed \u2014 reloading":"nothing to remove")}catch(U){u(`remove failed: ${String(U.message||U).slice(0,60)}`,2200)}}async function Y(R){let{slide:W,index:U}=o;B();try{let se=await fetch(P+"/edit/element/effect",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:W,index:U,effect:R})}),$e=await se.json().catch(()=>({}));if(!se.ok)throw new Error($e.error||se.status);u(R===null?"effect removed \u2014 reloading":`effect: ${R} \u2014 reloading`)}catch(se){u(`effect save failed: ${String(se.message||se).slice(0,60)}`,2200)}}let Re=null;function y(){Re?.remove(),Re=null}function Be({slide:R,index:W}){Re=document.createElement("div"),Re.className="decklight-narr decklight-editor";let U=document.createElement("div");U.className="narr-card";let se=document.createElement("div");se.className="narr-head",se.textContent=`edit content \u2014 slide ${R}, element ${W} \xB7 \u2318\u23CE saves \xB7 Esc closes`;let $e=document.createElement("div");$e.className="edit-code";let S=document.createElement("pre");S.setAttribute("aria-hidden","true");let L=document.createElement("code");L.className="hljs language-xml",S.appendChild(L);let $=document.createElement("textarea");$.className="narr-input edit-notes",$.value="loading\u2026",$.disabled=!0,$.spellcheck=!1,$e.append(S,$);let Z=()=>{L.innerHTML=Nt.highlight(`${$.value}
298
- `,{language:"xml"}).value};$.addEventListener("input",Z),$.addEventListener("scroll",()=>{S.scrollTop=$.scrollTop,S.scrollLeft=$.scrollLeft});let te=async()=>{try{let Pe=await fetch(P+"/edit/element/content",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:R,index:W,html:$.value})});if(!Pe.ok)throw new Error(await Pe.text());u("element content saved \u2014 reloading")}catch(Pe){u(`save failed: ${String(Pe.message||Pe).slice(0,60)}`)}};$.addEventListener("keydown",Pe=>{Pe.key==="Enter"&&(Pe.metaKey||Pe.ctrlKey)?(te(),Pe.preventDefault()):Pe.key==="Escape"&&(y(),Pe.preventDefault()),Pe.stopPropagation()});let fe=document.createElement("div");fe.className="tr-actions";let Qe=document.createElement("button");Qe.type="button",Qe.className="narr-prev-btn",Qe.textContent="\u{1F4BE} save to file",Qe.addEventListener("click",te),fe.appendChild(Qe),U.append(se,$e,fe),Re.appendChild(U),It(Re,y),r.appendChild(Re),(async()=>{try{let Pe=await fetch(`${P}/edit/element/source?slide=${R}&index=${W}`),Ye=await Pe.json().catch(()=>({}));if(!Pe.ok||!Ye.ok)throw new Error(Ye.error||Pe.status);$.value=Oi(Ye.html),$.disabled=!1,Z(),$.focus()}catch(Pe){$.value="",u(`could not read the element's source: ${String(Pe.message||Pe).slice(0,60)}`,2600)}})()}f.register({isOpen:()=>!!Ae,close:B,keydown(R){switch(R.key){case"ArrowDown":mt(Ce+1,!0);break;case"ArrowUp":mt(Ce-1,!0);break;case"Enter":Ke[Ce]?.run();break;case"Escape":B();break;default:return!1}return!0}}),f.register({isOpen:()=>!!Re,close:y,keydown:R=>R.key==="Escape"&&(y(),!0)});let w=null,pe=[],Se=0,it=null,Ee=1,ze=!1,oe=null,Xe=!1,gt={first:'<path d="M17 6l-6 6 6 6"/><path d="M7 6v12"/>',prev:'<path d="M15 6l-6 6 6 6"/>',next:'<path d="M9 6l6 6-6 6"/>',last:'<path d="M7 6l6 6-6 6"/><path d="M17 6v12"/>'},Et={first:"first slide (Home)",prev:"previous slide (\u2190)",next:"next slide (\u2192)",last:"last slide (End)"},me=R=>`<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${R}</svg>`,Ne=()=>Number(pe[Se]?.slides)||0;function Ie(R){let W=Ne();Ee=Math.max(1,W?Math.min(R,W):R);let U=w?.querySelector("iframe");ze?U?.contentWindow?.postMessage({__decklightPreview:{goto:[Ee,0]}},"*"):oe=Ee,et()}function et(){let R=w?.querySelector(".hs-nav");if(!R)return;let W=Ne();R.querySelector(".hs-pos").textContent=W?`${Ee} / ${W}`:`${Ee}`;for(let U of R.querySelectorAll(".hs-btn")){let se=U.dataset.go;U.disabled=Ee<=1&&(se==="first"||se==="prev")||!!W&&Ee>=W&&(se==="next"||se==="last")}}function tt(R){return Ie(R==="first"?1:R==="prev"?Ee-1:R==="next"?Ee+1:Ne()||Ee+1)}function bt(R,W){W&&(ze=!1,oe=null,Ee=1,R.addEventListener("load",()=>{if(ze=!0,oe!=null){let U=oe;oe=null,Ie(U)}},{once:!0}),R.src=`${P}/edit/at?ref=${encodeURIComponent(W.hash)}&embedded`,et())}function He(R,W){let U=[...w.querySelectorAll(".tp-row")];if(!U.length)return;Zt(),Se=on(U,R,"tp-selected");let se=pe[Se];w.querySelector(".tp-caption").textContent=se?`${se.hash} \xB7 ${se.when} \xB7 ${se.subject}${ft(se)}`:"";let $e=w.querySelector("iframe");clearTimeout(it),W?bt($e,se):it=setTimeout(()=>bt($e,se),60)}function ft(R){let W=[];Number.isFinite(R.slides)&&W.push(`${R.slides} slide${R.slides===1?"":"s"}`);let U=[R.add?`+${R.add}`:"",R.del?`\u2212${R.del}`:""].filter(Boolean);return U.length&&W.push(`${U.join(" ")} lines`),W.length?` \xB7 ${W.join(" \xB7 ")}`:""}async function Dt(){if(w)return Ot();if(!A)return u(`the progress bar moved to J \u2014 ${fn("history",location)}`,3800);let R="history",W=[],U=null;try{let L=await(await fetch(P+"/edit/history")).json();if(!L.ok)return u(`${R}: ${L.error}`,3e3);W=L.entries||[],U=L.remote||null}catch{return u(`${R}: could not read the deck history`,3e3)}if(!W.length)return u(`${R}: git has no record of this deck yet`,3e3);k(),pe=W,Xe=!1,w=document.createElement("div"),w.className="decklight-theme-picker decklight-finder decklight-restore decklight-history",w.innerHTML='<div class="tp-panel"><div class="tp-side"><div class="tp-filter"></div><div class="hs-remote"></div><div class="tp-list" role="listbox" aria-label="Deck history"></div><div class="hs-confirm" hidden></div></div><div class="tp-preview"><iframe title="Version preview"></iframe><div class="hs-nav" role="group" aria-label="Preview navigation">'+["first","prev"].map(S=>Kt(S)).join("")+'<span class="hs-pos" aria-live="polite"></span>'+["next","last"].map(S=>Kt(S)).join("")+'</div><div class="tp-caption"></div></div></div>',w.querySelector(".tp-filter").textContent="History \u2014 \u2191\u2193 browse \xB7 \u2190\u2192 preview \xB7 \u23CE restore";let se=w.querySelector(".hs-remote");U?.line?se.textContent=U.line:se.remove();for(let S of w.querySelectorAll(".hs-btn"))S.addEventListener("click",()=>tt(S.dataset.go));let $e=w.querySelector(".tp-list");pe.forEach((S,L)=>{let $=document.createElement("div");$.className="tp-row",$.setAttribute("role","option");let Z=document.createElement("span");Z.className="rs-subject",Z.textContent=S.subject;let te=document.createElement("span");te.className="hs-meta";let fe=document.createElement("span");if(fe.className="rs-hash",fe.textContent=S.hash,te.append(fe,Vt(S)),S.pushed===!1){let Pe=document.createElement("span");Pe.className="hs-push",Pe.title="only on this machine",Pe.textContent="\u2191",te.append(Pe)}let Qe=document.createElement("span");Qe.className="rs-when",Qe.title=S.when,Qe.textContent=Ci(S.when),te.append(Qe),$.append(Z,te),$.addEventListener("click",()=>{He(L,!0),Q()}),$e.appendChild($)}),It(w,Ot),r.appendChild(w),He(0,!0)}function Kt(R){return`<button type="button" class="hs-btn" data-go="${R}" title="${Et[R]}" aria-label="${Et[R]}">${me(gt[R])}</button>`}function Vt(R){let W=document.createElement("span");if(W.className="hs-stat",Number.isFinite(R.slides)){let U=document.createElement("span");U.className="hs-slides",U.title=`${R.slides} slide${R.slides===1?"":"s"} in this version`,U.textContent=String(R.slides),W.append(U)}if(R.add){let U=document.createElement("span");U.className="hs-add",U.title=`${R.add} line${R.add===1?"":"s"} added`,U.textContent=`+${R.add}`,W.append(U)}if(R.del){let U=document.createElement("span");U.className="hs-del",U.title=`${R.del} line${R.del===1?"":"s"} removed`,U.textContent=`\u2212${R.del}`,W.append(U)}return W}function Ot(){clearTimeout(it),w?.remove(),w=null,Xe=!1,ze=!1,oe=null}function Q(){let R=pe[Se];if(!R)return;Xe=!0;let W=w.querySelector(".hs-confirm");W.hidden=!1,W.textContent="";let U=document.createElement("div");U.className="hs-q",U.append("restore ",Object.assign(document.createElement("span"),{className:"hs-q-hash",textContent:R.hash}),Object.assign(document.createElement("span"),{className:"hs-q-sub",textContent:` ${R.subject}`}),"?");let se=document.createElement("div");se.className="hs-why",se.textContent=`${Number.isFinite(R.slides)?`${R.slides} slides. `:""}Written as a NEW commit \u2014 nothing is rewritten, and where you are now stays in this list.`;let $e=document.createElement("div");$e.className="hs-buttons";let S=document.createElement("button");S.type="button",S.className="hs-yes",S.textContent="restore this version",S.addEventListener("click",_t);let L=document.createElement("button");L.type="button",L.className="hs-no",L.textContent="cancel",L.addEventListener("click",Zt),$e.append(S,L);let $=document.createElement("div");$.className="hs-keys",$.textContent="\u23CE confirms \xB7 Esc cancels",W.append(U,se,$e,$)}function Zt(){Xe=!1;let R=w?.querySelector(".hs-confirm");R&&(R.hidden=!0,R.textContent="")}async function _t(){let R=pe[Se];if(!(!R||!Xe)){Ot();try{let U=await(await fetch(P+"/edit/restore",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ref:R.hash})})).json();if(!U.ok)return u(`restore failed: ${U.error}`,3e3);if(!U.changed)return u(`already at ${R.hash}`,2e3);u(`restored ${R.hash} \u2014 Z takes it back`,2600)}catch{u("restore failed: the edit server did not answer",3e3)}}}f.register({isOpen:()=>!!O,close:D,keydown:R=>R.key==="Escape"&&(D(),!0)}),f.register({isOpen:()=>!!Je,close:je,keydown:R=>R.key==="Escape"&&(je(),!0)}),f.register({isOpen:()=>!!w,close:Ot,keydown(R){switch(R.key){case"ArrowDown":He(Se+1,!1);break;case"ArrowUp":He(Se-1,!1);break;case"ArrowLeft":tt("prev");break;case"ArrowRight":tt("next");break;case"Home":tt("first");break;case"End":tt("last");break;case"Enter":Xe?_t():Q();break;case"Escape":Xe?Zt():Ot();break;default:return!1}return!0}});let vt=null;function Wt(){vt?.remove(),vt=null}async function Ht(R){if(vt){Wt();return}if(!A){u(fn("configuring an engine",location),3200);return}let W,U;try{let Ye=await fetch(`${P}/edit/wizard?engine=${encodeURIComponent(R)}`),ut=await Ye.json().catch(()=>({}));if(!Ye.ok||!ut?.schema){u(ut.error||`no wizard for ${R}`,3200);return}if(typeof ut.from!="string"||!ut.from||typeof ut.provenance?.askedBy!="string"||typeof ut.provenance?.sentTo!="string"){u("the server did not say who is asking for these answers \u2014 not prompting",3200);return}W=ut.schema,U=ut.provenance}catch{u("the author server did not answer",2600);return}k?.(),vt=document.createElement("div"),vt.className="decklight-narr decklight-editor";let se=document.createElement("div");se.className="narr-card";let $e=document.createElement("div");$e.className="narr-head",$e.textContent=`${W.title} \u2014 \u2318\u23CE saves \xB7 Esc closes`;let S=document.createElement("div");S.className="wiz-src";let L=document.createElement("div");L.textContent=U.askedBy;let $=document.createElement("div");$.textContent=U.sentTo,S.append(L,$),se.append($e,S);let Z=new Map;for(let Ye of W.fields){let ut=document.createElement("label");ut.className="tr-actions";let dt=document.createElement("span");dt.textContent=Ye.required?`${Ye.label} *`:Ye.label;let pt;if(Ye.type==="choice"){pt=document.createElement("select");for(let xt of Ye.options){let ht=document.createElement("option");ht.value=xt,ht.textContent=xt,pt.append(ht)}Ye.default&&(pt.value=Ye.default)}else Ye.type==="boolean"?(pt=document.createElement("input"),pt.type="checkbox",pt.checked=Ye.default===!0):(pt=document.createElement("input"),pt.type=Ye.type==="secret"?"password":"text",pt.autocomplete=Ye.type==="secret"?"off":"on",pt.spellcheck=!1,Ye.default!==void 0&&(pt.value=String(Ye.default)));pt.className="narr-input",Z.set(Ye.name,{field:Ye,input:pt}),ut.append(dt,pt),se.append(ut)}let te=document.createElement("div");te.className="narr-head";let fe=document.createElement("button");fe.className="narr-prev-btn",fe.textContent="save";let Qe=document.createElement("div");Qe.className="tr-actions",Qe.append(fe),se.append(Qe,te),vt.append(se),r.append(vt),Z.values().next().value?.input.focus();async function Pe(){let Ye={};for(let[ut,{field:dt,input:pt}]of Z){let xt=dt.type==="boolean"?pt.checked:pt.value;xt!==""&&xt!==void 0&&(Ye[ut]=xt)}fe.disabled=!0,te.textContent="checking\u2026";try{let ut=await fetch(`${P}/edit/wizard`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({engine:W.engine,answers:Ye})}),dt=await ut.json().catch(()=>({}));if(!ut.ok){te.textContent=dt.state==="unreachable"?`could not reach it \u2014 ${dt.error??"try again"}`:dt.state==="prerequisite"?`not ready on this machine \u2014 ${dt.error??"something it needs is missing"}`:`not accepted \u2014 ${dt.error??"check the answers"}`,fe.disabled=!1;return}m("wizard",`${W.engine} configured: ${JSON.stringify(dt.stored)}`),Wt(),u(`${W.title} configured`,2200)}catch(ut){te.textContent=`could not reach the author server \u2014 ${String(ut.message||ut).slice(0,50)}`,fe.disabled=!1}}fe.addEventListener("click",Pe),vt.addEventListener("keydown",Ye=>{Ye.key==="Enter"&&(Ye.metaKey||Ye.ctrlKey)&&(Ye.preventDefault(),Pe())})}return f.register({isOpen:()=>!!vt,close:Wt,keydown:R=>R.key==="Escape"&&(Wt(),!0)}),{deckHistory:qe,toggleEditor:D,toggleAgentAsk:je,toggleElementEdit:N,elementEditOn:()=>re,wizard:Ht,wizards:()=>C.slice(),history:{open:()=>!A&&Oe?at():Dt(),close:()=>{Ot(),De()},list:()=>pe.slice()},restore:{open:Dt,close:Ot,list:()=>pe.slice()},available:()=>A,base:()=>P}}le();ce();var rr=[{id:"palette",text:"press / for the command palette \u2014 every command, type to filter"},{id:"help",text:"press ? for the keyboard shortcuts"},{id:"goto",text:"press G to jump to any slide by name"},{id:"theme",text:"press T to browse themes \u2014 the deck restyles live"},{id:"overview",text:"press O for the slide overview grid"},{id:"speaker",text:"press S for speaker view \u2014 notes, next slide and a timer"},{id:"narrate",text:"press V to have the deck narrate itself from its speaker notes"},{id:"messages",text:"press ` (left of 1) for the message log \u2014 every message the deck has shown"},{id:"fullscreen",text:"press F for fullscreen, B to black out the screen mid-talk"},{id:"author",text:"author mode (decklight author <deck.html>) turns this player into an editor \u2014 A asks an AI agent"}],Li="decklight-onboarded",ls="decklight-tips-seen",Ri="decklight-tips-off";function cs(r){try{return localStorage.getItem(r)}catch{return null}}function Cr(r,i){try{localStorage.setItem(r,i)}catch{}}function Ii({root:r,printMode:i,params:l,toast:d,debugLog:u,overlays:m,deck:f}){let h=l.has("embedded"),b=i||h,k=null;function A(){k&&(k.remove(),k=null,Cr(Li,"1"),u?.("nav","welcome dismissed"))}function P(){k||i||(k=document.createElement("div"),k.className="decklight-welcome",k.innerHTML=`<div class="wel-card">
319
+ `),we.spellcheck=!1;let Ye=async()=>{try{let xe=await fetch(P+"/edit/notes",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:M,text:we.value})});if(!xe.ok)throw new Error(await xe.text());p("edit",`notes saved \u2014 slide ${M}`),d("notes saved \u2014 reloading")}catch(xe){d(`save failed: ${String(xe.message||xe).slice(0,60)}`)}};we.addEventListener("keydown",xe=>{xe.key==="Enter"&&(xe.metaKey||xe.ctrlKey)?(Ye(),xe.preventDefault()):xe.key==="Escape"&&(Pe(),xe.preventDefault()),xe.stopPropagation()});let We=document.createElement("div");We.className="tr-actions";let Ve=document.createElement("button");Ve.type="button",Ve.className="narr-prev-btn",Ve.textContent="\u{1F4BE} save to file",Ve.addEventListener("click",Ye),We.appendChild(Ve),j.append(H,we,We),B.appendChild(j),Ut(B,Pe),t.appendChild(B),setTimeout(()=>we.focus(),0)}let _t=["fade","fade-up","fade-down","zoom","pop","draw","highlight"],W=!1,ye=null,ie=[],Ze=0,v="main",ze=null;function f(){if(!S){d(Dn("editing an element",location),3200);return}W=!W,F(),d(W?"element edit mode on \u2014 right-click a slide element":"element edit mode off",2200)}function Y(M,j){let H=j;for(;H&&H!==M&&H.parentElement!==M;)H=H.parentElement;return H&&H!==M?H:null}t.addEventListener("contextmenu",M=>{if(!W)return;let j=M.target.closest("section"),H=j?m._sections.indexOf(j)+1:0;if(!j||!H)return;if(M.preventDefault(),j.hasAttribute("data-markdown-removed")){d("this slide has no per-element source mapping (data-markdown, removed in 0.3.0) \u2014 edit the file directly",3400);return}let we=Y(j,M.target),Ye=we?[...j.children].indexOf(we):null;E?.(),Ne(M.clientX,M.clientY,{sec:j,slide:H,index:Ye})});function F(){ye?.remove(),ye=null,v="main"}function Ce(){let M=ye.querySelector(".cm-list");M.textContent="";let j=[];if(v==="effects"){j.push({label:"\u2190 back",back:!0,run:()=>{v="main",Ce()}});for(let H of _t)j.push({label:H,run:()=>nt(H)});j.push({label:"none (instant)",run:()=>nt("none")}),j.push({label:"remove effect",run:()=>nt(null)})}else ze.index===null?j.push({label:"Edit speaker notes",run:()=>{F(),Pe()}}):(j.push({label:"Edit speaker notes",run:()=>{F(),Pe()}}),j.push({label:"Remove element",run:ee}),j.push({label:"Edit content (HTML)",run:()=>{F(),ke(ze)}}),j.push({label:"Add text effect \u25B8",run:()=>{v="effects",Ce()}}));ie=j,j.forEach((H,we)=>{let Ye=document.createElement("div");Ye.className="cm-row"+(H.back?" cm-back":""),Ye.setAttribute("role","option"),Ye.textContent=H.label,Ye.addEventListener("mouseenter",()=>ce(we,!1)),Ye.addEventListener("click",H.run),M.appendChild(Ye)}),ce(0,!1)}function ce(M,j){let H=ye.querySelectorAll(".cm-row");H.length&&(Ze=vn(H,M,"cm-selected",{scroll:j}))}function Ne(M,j,H){ze=H,v="main",ye=document.createElement("div"),ye.className="decklight-ctxmenu";let we=document.createElement("div");we.className="cm-card";let Ye=document.createElement("div");Ye.className="cm-list",Ye.setAttribute("role","listbox"),Ye.setAttribute("aria-label","Element edit menu"),we.appendChild(Ye),ye.appendChild(we),t.appendChild(ye),Ce();let We=t.getBoundingClientRect(),Ve=Math.min(M-We.left,We.width-we.offsetWidth-4),xe=Math.min(j-We.top,We.height-we.offsetHeight-4);we.style.left=Math.max(4,Ve)+"px",we.style.top=Math.max(4,xe)+"px",Ut(ye,F)}async function ee(){let{slide:M,index:j}=ze;F();try{let H=await fetch(P+"/edit/element/remove",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:M,index:j})}),we=await H.json().catch(()=>({}));if(!H.ok)throw new Error(we.error||H.status);d(we.changed?"element removed \u2014 reloading":"nothing to remove")}catch(H){d(`remove failed: ${String(H.message||H).slice(0,60)}`,2200)}}async function nt(M){let{slide:j,index:H}=ze;F();try{let we=await fetch(P+"/edit/element/effect",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:j,index:H,effect:M})}),Ye=await we.json().catch(()=>({}));if(!we.ok)throw new Error(Ye.error||we.status);d(M===null?"effect removed \u2014 reloading":`effect: ${M} \u2014 reloading`)}catch(we){d(`effect save failed: ${String(we.message||we).slice(0,60)}`,2200)}}let pt=null;function ut(){pt?.remove(),pt=null}function ke({slide:M,index:j}){pt=document.createElement("div"),pt.className="decklight-narr decklight-editor";let H=document.createElement("div");H.className="narr-card";let we=document.createElement("div");we.className="narr-head",we.textContent=`edit content \u2014 slide ${M}, element ${j} \xB7 \u2318\u23CE saves \xB7 Esc closes`;let Ye=document.createElement("div");Ye.className="edit-code";let We=document.createElement("pre");We.setAttribute("aria-hidden","true");let Ve=document.createElement("code");Ve.className="hljs language-xml",We.appendChild(Ve);let xe=document.createElement("textarea");xe.className="narr-input edit-notes",xe.value="loading\u2026",xe.disabled=!0,xe.spellcheck=!1,Ye.append(We,xe);let Oe=()=>{Ve.innerHTML=Gt.highlight(`${xe.value}
320
+ `,{language:"xml"}).value};xe.addEventListener("input",Oe),xe.addEventListener("scroll",()=>{We.scrollTop=xe.scrollTop,We.scrollLeft=xe.scrollLeft});let ot=async()=>{try{let yt=await fetch(P+"/edit/element/content",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:M,index:j,html:xe.value})});if(!yt.ok)throw new Error(await yt.text());d("element content saved \u2014 reloading")}catch(yt){d(`save failed: ${String(yt.message||yt).slice(0,60)}`)}};xe.addEventListener("keydown",yt=>{yt.key==="Enter"&&(yt.metaKey||yt.ctrlKey)?(ot(),yt.preventDefault()):yt.key==="Escape"&&(ut(),yt.preventDefault()),yt.stopPropagation()});let Et=document.createElement("div");Et.className="tr-actions";let Tt=document.createElement("button");Tt.type="button",Tt.className="narr-prev-btn",Tt.textContent="\u{1F4BE} save to file",Tt.addEventListener("click",ot),Et.appendChild(Tt),H.append(we,Ye,Et),pt.appendChild(H),Ut(pt,ut),t.appendChild(pt),(async()=>{try{let yt=await fetch(`${P}/edit/element/source?slide=${M}&index=${j}`),Qe=await yt.json().catch(()=>({}));if(!yt.ok||!Qe.ok)throw new Error(Qe.error||yt.status);xe.value=_a(Qe.html),xe.disabled=!1,Oe(),xe.focus()}catch(yt){xe.value="",d(`could not read the element's source: ${String(yt.message||yt).slice(0,60)}`,2600)}})()}g.register({isOpen:()=>!!ye,close:F,keydown(M){switch(M.key){case"ArrowDown":ce(Ze+1,!0);break;case"ArrowUp":ce(Ze-1,!0);break;case"Enter":ie[Ze]?.run();break;case"Escape":F();break;default:return!1}return!0}}),g.register({isOpen:()=>!!pt,close:ut,keydown:M=>M.key==="Escape"&&(ut(),!0)});let Ee=null,re=[],Ge=0,ht=null,tt=1,He=!1,gt=null,Yt=!1,nn={first:'<path d="M17 6l-6 6 6 6"/><path d="M7 6v12"/>',prev:'<path d="M15 6l-6 6 6 6"/>',next:'<path d="M9 6l6 6-6 6"/>',last:'<path d="M7 6l6 6-6 6"/><path d="M17 6v12"/>'},It={first:"first slide (Home)",prev:"previous slide (\u2190)",next:"next slide (\u2192)",last:"last slide (End)"},Wt=M=>`<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${M}</svg>`,oe=()=>Number(re[Ge]?.slides)||0;function pn(M){let j=oe();tt=Math.max(1,j?Math.min(M,j):M);let H=Ee?.querySelector("iframe");He?H?.contentWindow?.postMessage({__decklightPreview:{goto:[tt,0]}},"*"):gt=tt,Bt()}function Bt(){let M=Ee?.querySelector(".hs-nav");if(!M)return;let j=oe();M.querySelector(".hs-pos").textContent=j?`${tt} / ${j}`:`${tt}`;for(let H of M.querySelectorAll(".hs-btn")){let we=H.dataset.go;H.disabled=tt<=1&&(we==="first"||we==="prev")||!!j&&tt>=j&&(we==="next"||we==="last")}}function rn(M){return pn(M==="first"?1:M==="prev"?tt-1:M==="next"?tt+1:oe()||tt+1)}function gn(M,j){j&&(He=!1,gt=null,tt=1,M.addEventListener("load",()=>{if(He=!0,gt!=null){let H=gt;gt=null,pn(H)}},{once:!0}),M.src=`${P}/edit/at?ref=${encodeURIComponent(j.hash)}&embedded`,Bt())}function Lt(M,j){let H=[...Ee.querySelectorAll(".tp-row")];if(!H.length)return;X(),Ge=vn(H,M,"tp-selected");let we=re[Ge];Ee.querySelector(".tp-caption").textContent=we?`${we.hash} \xB7 ${we.when} \xB7 ${we.subject}${mn(we)}`:"";let Ye=Ee.querySelector("iframe");clearTimeout(ht),j?gn(Ye,we):ht=setTimeout(()=>gn(Ye,we),60)}function mn(M){let j=[];Number.isFinite(M.slides)&&j.push(`${M.slides} slide${M.slides===1?"":"s"}`);let H=[M.add?`+${M.add}`:"",M.del?`\u2212${M.del}`:""].filter(Boolean);return H.length&&j.push(`${H.join(" ")} lines`),j.length?` \xB7 ${j.join(" \xB7 ")}`:""}async function Dt(){if(Ee)return Rt();if(!S)return d(`the progress bar moved to J \u2014 ${Dn("history",location)}`,3800);let M="history",j=[],H=null;try{let Ve=await(await fetch(P+"/edit/history")).json();if(!Ve.ok)return d(`${M}: ${Ve.error}`,3e3);j=Ve.entries||[],H=Ve.remote||null}catch{return d(`${M}: could not read the deck history`,3e3)}if(!j.length)return d(`${M}: git has no record of this deck yet`,3e3);E(),re=j,Yt=!1,Ee=document.createElement("div"),Ee.className="decklight-theme-picker decklight-finder decklight-restore decklight-history",Ee.innerHTML='<div class="tp-panel"><div class="tp-side"><div class="tp-filter"></div><div class="hs-remote"></div><div class="tp-list" role="listbox" aria-label="Deck history"></div><div class="hs-confirm" hidden></div></div><div class="tp-preview"><iframe title="Version preview"></iframe><div class="hs-nav" role="group" aria-label="Preview navigation">'+["first","prev"].map(We=>Ct(We)).join("")+'<span class="hs-pos" aria-live="polite"></span>'+["next","last"].map(We=>Ct(We)).join("")+'</div><div class="tp-caption"></div></div></div>',Ee.querySelector(".tp-filter").textContent="History \u2014 \u2191\u2193 browse \xB7 \u2190\u2192 preview \xB7 \u23CE restore";let we=Ee.querySelector(".hs-remote");H?.line?we.textContent=H.line:we.remove();for(let We of Ee.querySelectorAll(".hs-btn"))We.addEventListener("click",()=>rn(We.dataset.go));let Ye=Ee.querySelector(".tp-list");re.forEach((We,Ve)=>{let xe=document.createElement("div");xe.className="tp-row",xe.setAttribute("role","option");let Oe=document.createElement("span");Oe.className="rs-subject",Oe.textContent=We.subject;let ot=document.createElement("span");ot.className="hs-meta";let Et=document.createElement("span");if(Et.className="rs-hash",Et.textContent=We.hash,ot.append(Et,Kt(We)),We.pushed===!1){let yt=document.createElement("span");yt.className="hs-push",yt.title="only on this machine",yt.textContent="\u2191",ot.append(yt)}let Tt=document.createElement("span");Tt.className="rs-when",Tt.title=We.when,Tt.textContent=ka(We.when),ot.append(Tt),xe.append(Oe,ot),xe.addEventListener("click",()=>{Lt(Ve,!0),N()}),Ye.appendChild(xe)}),Ut(Ee,Rt),t.appendChild(Ee),Lt(0,!0)}function Ct(M){return`<button type="button" class="hs-btn" data-go="${M}" title="${It[M]}" aria-label="${It[M]}">${Wt(nn[M])}</button>`}function Kt(M){let j=document.createElement("span");if(j.className="hs-stat",Number.isFinite(M.slides)){let H=document.createElement("span");H.className="hs-slides",H.title=`${M.slides} slide${M.slides===1?"":"s"} in this version`,H.textContent=String(M.slides),j.append(H)}if(M.add){let H=document.createElement("span");H.className="hs-add",H.title=`${M.add} line${M.add===1?"":"s"} added`,H.textContent=`+${M.add}`,j.append(H)}if(M.del){let H=document.createElement("span");H.className="hs-del",H.title=`${M.del} line${M.del===1?"":"s"} removed`,H.textContent=`\u2212${M.del}`,j.append(H)}return j}function Rt(){clearTimeout(ht),Ee?.remove(),Ee=null,Yt=!1,He=!1,gt=null}function N(){let M=re[Ge];if(!M)return;Yt=!0;let j=Ee.querySelector(".hs-confirm");j.hidden=!1,j.textContent="";let H=document.createElement("div");H.className="hs-q",H.append("restore ",Object.assign(document.createElement("span"),{className:"hs-q-hash",textContent:M.hash}),Object.assign(document.createElement("span"),{className:"hs-q-sub",textContent:` ${M.subject}`}),"?");let we=document.createElement("div");we.className="hs-why",we.textContent=`${Number.isFinite(M.slides)?`${M.slides} slides. `:""}Written as a NEW commit \u2014 nothing is rewritten, and where you are now stays in this list.`;let Ye=document.createElement("div");Ye.className="hs-buttons";let We=document.createElement("button");We.type="button",We.className="hs-yes",We.textContent="restore this version",We.addEventListener("click",pe);let Ve=document.createElement("button");Ve.type="button",Ve.className="hs-no",Ve.textContent="cancel",Ve.addEventListener("click",X),Ye.append(We,Ve);let xe=document.createElement("div");xe.className="hs-keys",xe.textContent="\u23CE confirms \xB7 Esc cancels",j.append(H,we,Ye,xe)}function X(){Yt=!1;let M=Ee?.querySelector(".hs-confirm");M&&(M.hidden=!0,M.textContent="")}async function pe(){let M=re[Ge];if(!(!M||!Yt)){Rt();try{let H=await(await fetch(P+"/edit/restore",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ref:M.hash})})).json();if(!H.ok)return d(`restore failed: ${H.error}`,3e3);if(!H.changed)return d(`already at ${M.hash}`,2e3);d(`restored ${M.hash} \u2014 Z takes it back`,2600)}catch{d("restore failed: the edit server did not answer",3e3)}}}g.register({isOpen:()=>!!B,close:Pe,keydown:M=>M.key==="Escape"&&(Pe(),!0)}),g.register({isOpen:()=>!!O,close:De,keydown:M=>M.key==="Escape"&&(De(),!0)}),g.register({isOpen:()=>!!Ee,close:Rt,keydown(M){switch(M.key){case"ArrowDown":Lt(Ge+1,!1);break;case"ArrowUp":Lt(Ge-1,!1);break;case"ArrowLeft":rn("prev");break;case"ArrowRight":rn("next");break;case"Home":rn("first");break;case"End":rn("last");break;case"Enter":Yt?pe():N();break;case"Escape":Yt?X():Rt();break;default:return!1}return!0}});let Me=null;function Le(){Me?.remove(),Me=null}async function qe(M){if(Me){Le();return}if(!S){d(Dn("configuring an engine",location),3200);return}let j,H;try{let Qe=await fetch(`${P}/edit/wizard?engine=${encodeURIComponent(M)}`),wt=await Qe.json().catch(()=>({}));if(!Qe.ok||!wt?.schema){d(wt.error||`no wizard for ${M}`,3200);return}if(typeof wt.from!="string"||!wt.from||typeof wt.provenance?.askedBy!="string"||typeof wt.provenance?.sentTo!="string"){d("the server did not say who is asking for these answers \u2014 not prompting",3200);return}j=wt.schema,H=wt.provenance}catch{d("the author server did not answer",2600);return}E?.(),Me=document.createElement("div"),Me.className="decklight-narr decklight-editor";let we=document.createElement("div");we.className="narr-card";let Ye=document.createElement("div");Ye.className="narr-head",Ye.textContent=`${j.title} \u2014 \u2318\u23CE saves \xB7 Esc closes`;let We=document.createElement("div");We.className="wiz-src";let Ve=document.createElement("div");Ve.textContent=H.askedBy;let xe=document.createElement("div");xe.textContent=H.sentTo,We.append(Ve,xe),we.append(Ye,We);let Oe=new Map;for(let Qe of j.fields){let wt=document.createElement("label");wt.className="tr-actions";let L=document.createElement("span");L.textContent=Qe.required?`${Qe.label} *`:Qe.label;let Pt;if(Qe.type==="choice"){Pt=document.createElement("select");for(let sn of Qe.options){let on=document.createElement("option");on.value=sn,on.textContent=sn,Pt.append(on)}Qe.default&&(Pt.value=Qe.default)}else Qe.type==="boolean"?(Pt=document.createElement("input"),Pt.type="checkbox",Pt.checked=Qe.default===!0):(Pt=document.createElement("input"),Pt.type=Qe.type==="secret"?"password":"text",Pt.autocomplete=Qe.type==="secret"?"off":"on",Pt.spellcheck=!1,Qe.default!==void 0&&(Pt.value=String(Qe.default)));Pt.className="narr-input",Oe.set(Qe.name,{field:Qe,input:Pt}),wt.append(L,Pt),we.append(wt)}let ot=document.createElement("div");ot.className="narr-head";let Et=document.createElement("button");Et.className="narr-prev-btn",Et.textContent="save";let Tt=document.createElement("div");Tt.className="tr-actions",Tt.append(Et),we.append(Tt,ot),Me.append(we),t.append(Me),Oe.values().next().value?.input.focus();async function yt(){let Qe={};for(let[wt,{field:L,input:Pt}]of Oe){let sn=L.type==="boolean"?Pt.checked:Pt.value;sn!==""&&sn!==void 0&&(Qe[wt]=sn)}Et.disabled=!0,ot.textContent="checking\u2026";try{let wt=await fetch(`${P}/edit/wizard`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({engine:j.engine,answers:Qe})}),L=await wt.json().catch(()=>({}));if(!wt.ok){ot.textContent=L.state==="unreachable"?`could not reach it \u2014 ${L.error??"try again"}`:L.state==="prerequisite"?`not ready on this machine \u2014 ${L.error??"something it needs is missing"}`:`not accepted \u2014 ${L.error??"check the answers"}`,Et.disabled=!1;return}p("wizard",`${j.engine} configured: ${JSON.stringify(L.stored)}`),Le(),d(`${j.title} configured`,2200)}catch(wt){ot.textContent=`could not reach the author server \u2014 ${String(wt.message||wt).slice(0,50)}`,Et.disabled=!1}}Et.addEventListener("click",yt),Me.addEventListener("keydown",Qe=>{Qe.key==="Enter"&&(Qe.metaKey||Qe.ctrlKey)&&(Qe.preventDefault(),yt())})}return g.register({isOpen:()=>!!Me,close:Le,keydown:M=>M.key==="Escape"&&(Le(),!0)}),{deckHistory:i,toggleEditor:Pe,toggleAgentAsk:De,toggleElementEdit:f,elementEditOn:()=>W,wizard:qe,wizards:()=>C.slice(),history:{open:()=>!S&&G?Q():Dt(),close:()=>{Rt(),ne()},list:()=>re.slice()},restore:{open:Dt,close:Rt,list:()=>re.slice()},available:()=>S,settled:()=>((c||a.has("embedded"))&&Ke(),mt),base:()=>P,commit:{open:bt,close:st,state:()=>ae}}}ge();be();var Xr=[{id:"palette",text:"press / for the command palette \u2014 every command, type to filter"},{id:"help",text:"press ? for the keyboard shortcuts"},{id:"goto",text:"press G to jump to any slide by name"},{id:"theme",text:"press T to browse themes \u2014 the deck restyles live"},{id:"overview",text:"press O for the slide overview grid"},{id:"speaker",text:"press S for speaker view \u2014 notes, next slide and a timer"},{id:"narrate",text:"press V to have the deck narrate itself from its speaker notes"},{id:"messages",text:"press ` (left of 1) for the message log \u2014 every message the deck has shown"},{id:"fullscreen",text:"press F for fullscreen, B to black out the screen mid-talk"},{id:"author",text:"author mode (decklight author <deck.html>) turns this player into an editor \u2014 A asks an AI agent"}],$a="decklight-onboarded",yo="decklight-tips-seen",Ca="decklight-tips-off";function wo(t){try{return localStorage.getItem(t)}catch{return null}}function Ms(t,o){try{localStorage.setItem(t,o)}catch{}}function Na({root:t,printMode:o,params:a,toast:c,debugLog:d,overlays:p,deck:g}){let m=a.has("embedded"),w=o||m,E=null;function S(){E&&(E.remove(),E=null,Ms($a,"1"),d?.("nav","welcome dismissed"))}function P(){E||o||(E=document.createElement("div"),E.className="decklight-welcome",E.innerHTML=`<div class="wel-card">
299
321
  <h3>Welcome to Decklight</h3>
300
322
  <p class="wel-lead">This deck is a single HTML file \u2014 no build step, authored by you or an AI agent, and provable by a headless render.</p>
301
323
  <table>
@@ -309,17 +331,17 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Ae=O,re=D),V===void 0&
309
331
  <span>Press any key to dismiss \u2014 reopen anytime from the <code>/</code> palette.</span>
310
332
  <button type="button" class="wel-go">Got it</button>
311
333
  </div>
312
- </div>`,k.addEventListener("click",J=>{J.stopPropagation(),A()}),It(k,A),r.appendChild(k),u?.("nav","welcome shown"))}m.register({isOpen:()=>!!k,close:A,keydown:()=>(A(),!0)});function M(){return cs(Ri)!=="1"}function T(){try{let J=JSON.parse(cs(ls)||"[]");return new Set(Array.isArray(J)?J:[])}catch{return new Set}}function C(){let J=T();return rr.find(de=>!J.has(de.id))||null}function F(){let J=C();if(!J)return null;let de=T();return de.add(J.id),Cr(ls,JSON.stringify([...de])),d(`tip \xB7 ${J.text}`,5200),J.id}function ye(J){Cr(Ri,J?"0":"1"),d(J?"tips on \u2014 one per deck you open":"tips off")}function ge(){Cr(ls,"[]"),d(`tips reset \u2014 all ${rr.length} will show again, one per deck`)}function be(J){if(!b&&(f().on("slide",A),f().on("build",A),!(J.slide!==1||J.step!==0))){if(cs(Li)!=="1"){P();return}M()&&F()}}return{start:be,showWelcome:P,dismissWelcome:A,showTip:F,setTips:ye,resetTips:ge,status:()=>({tipsOn:M(),tipsLeft:C()?rr.length-T().size:0})}}le();ce();function Bi({sectionsOf:r,checkOverflow:i,ResizeObs:l=typeof ResizeObserver=="function"?ResizeObserver:null,MutationObs:d=typeof MutationObserver=="function"?MutationObserver:null,schedule:u=m=>setTimeout(m)}){let m=[],f=0;function h(){f||(f=u(()=>{f=0;let M=r();for(let T of m)i(T,M.indexOf(T)+1)})||1)}let b=l?new l(h):null;function k(M){if(b)for(let T of[M,...M.querySelectorAll("*")])T.parentElement?.closest(".terminal")||b.observe(T)}let A=d?new d(M=>{let T=F=>!(F.nodeType===1?F:F.parentElement)?.closest(".terminal"),C=!1;for(let F of M)if(T(F.target)){C=!0;for(let ye of F.addedNodes)ye.nodeType===1&&ye.isConnected&&k(ye)}C&&h()}):null,P=M=>{M.target.closest?.(".terminal")||h()};return{watch(M){b?.disconnect(),A?.disconnect();for(let T of m)for(let C of["load","error"])T.removeEventListener(C,P,!0);m=M.filter(Boolean);for(let T of m){k(T),A?.observe(T,{childList:!0,subtree:!0,characterData:!0});for(let C of["load","error"])T.addEventListener(C,P,!0)}h()},get watched(){return m.slice()}}}le();ce();function Pi({config:r,root:i,embedded:l,sectionsOf:d,slideOf:u,navigate:m}){let f=!l&&r.playlist?.modules?.length?r.playlist:null,h=f?f.index??0:0,b=!!i.querySelector("section[data-module]");function k(){let P=[];return(d()||[]).forEach((M,T)=>{M.hasAttribute("data-module")&&P.push({title:M.getAttribute("data-module"),slide:T+1})}),P}function A(P=k()){let M=-1;return P.forEach((T,C)=>{T.slide<=u()&&(M=C)}),M}return{get playlist(){return f},get index(){return h},get hasMarkers(){return b},get any(){return b||!!f},markers:k,currentMarkerIndex:A,gotoModule(P){if(!f)return!1;let M=f.modules[h+P];return M?(m(M.href+(P>0?"#/1/0":"#/999/999")),!0):!1},navigateToModule(P){let M=f?.modules[P];M&&m(M.href+"#/1/0")},title(){if(b){let P=k();return P[A(P)]?.title||""}return f?.modules[h]?.title||""}}}le();ce();function dd(r,i,l){return(r.querySelector("h1, h2, h3")?.textContent||"").replace(/\s+/g," ").trim()||l.slice(0,60)||`slide ${i+1}`}function ud(r){return[...r.children].filter(l=>!l.matches("aside, script, style")).map(l=>l.textContent).join(" ").replace(/\s+/g," ").trim()}function Di({sections:r,modules:i=[],skipModule:l=-1}){let d=r.map((m,f)=>{let h=ud(m);return{slide:f+1,title:dd(m,f,h),haystack:h.toLowerCase()}}),u=i.map((m,f)=>({module:f,title:m.title,href:m.href,haystack:(m.title||"").toLowerCase()})).filter(m=>m.module!==l);return[...d,...u]}function qi(r,i){let l=String(i??"").toLowerCase().split(/\s+/).filter(Boolean),d=[],u=[];for(let m of r){let f=m.title.toLowerCase();l.every(h=>f.includes(h))?d.push(m):l.every(h=>m.haystack.includes(h))&&u.push(m)}return[...d,...u]}le();ce();function Fi({now:r=Date.now,keep:i=200}={}){let l=r(),d=[],u=null;function m(f,h){let b={t:((r()-l)/1e3).toFixed(3),kind:f,msg:h};return d.push(b),d.length>i&&d.shift(),u?.(b),b}return{log:m,get entries(){return d.slice()},onEntry(f){u=f}}}le();ce();var pd=["auto","centered","pinned","top","split","split-flip"];function hd({autoPins:r,hasSplitPair:i}){return pd.filter(l=>(l!=="pinned"||!r)&&(l!=="split-flip"||i))}function md(r,i,l){if(!r.length)return null;let d=Math.max(0,r.indexOf(i));return r[(d+l+r.length)%r.length]}function zi({slideOf:r,sectionAt:i,describe:l,available:d,unavailableMessage:u,apply:m,relayout:f,post:h,toast:b,debugLog:k,schedule:A=setTimeout,cancel:P=clearTimeout,delay:M=600}){let T=null,C=null;function F(){P(C);let be=T;T=null,be&&h({slide:be.slide,layout:be.name}).then(()=>k("layout",`slide ${be.slide}: ${be.name} \u2192 saved to file`)).catch(()=>b("layout save failed \u2014 is the dev server still up?",2200))}function ye(be=r()){let J=i(be);return J?hd(l(J)):[]}function ge(be){if(!d()){b(u(),3200);return}let J=r(),de=i(J);if(!de)return;let Oe=md(ye(J),de.getAttribute("data-layout")||"auto",be);if(!Oe)return;m(de,Oe),T&&T.slide!==J&&F(),T={slide:J,name:Oe},P(C),C=A(F,M);let ke=f(de,J);b(ke?`layout: ${Oe} \u2014 fights this slide's own column flexbox; pick one`:`layout: ${Oe}`),k("layout",`slide ${J}: ${Oe}`)}return{ring:ye,cycle:ge,flush:F}}le();ce();function Ui({commands:r,query:i="",totalSlides:l=0,makeGotoRow:d,makeSearchRow:u}){let m=String(i).toLowerCase(),f=r.filter(b=>!m||(b.label+" "+(b.alias??"")).toLowerCase().includes(m)),h=String(i).trim().match(/^(?:goto\s*)?(\d+)$/i);if(h&&d){let b=Math.max(1,Math.min(parseInt(h[1],10),l));f.unshift(d(b,l))}return m&&!h&&u&&!f.some(b=>b.label.toLowerCase().startsWith(m))&&f.push(u(i)),f}var fd={transition:"fade",hash:!0,controls:!0,slideNumber:!1,width:1280,height:720,pinTitles:!0},$r=99,gd=18,Hi=6,bd="ul, ol, svg, pre, table, .terminal, img, .columns",Xn=null;function sr(r,i){Ys(r,i),Xn&&Xn._rescanFor(r)}function yd(r){let i=getComputedStyle(r).position;return i==="absolute"||i==="fixed"}function wd(r){for(let i of r.children)if(!i.matches("aside, script, style, .decklight-hero-logo, .slide-bg")){if(i.matches("h1, h2"))return i;if(!yd(i))return null}return null}function xd(r,i){if(!i||r.getAttribute("data-subtitle")==="none")return null;let l=i.nextElementSibling;return l&&l.matches("p")&&!l.hasAttribute("data-build")?(l.classList.add("subtitle"),l):r.querySelector(":scope > p.subtitle")}function ji(r){return r.pinTitles===!0?$r:typeof r.pinTitles=="number"&&isFinite(r.pinTitles)?r.pinTitles:null}function Ki(r,i){let l=ji(i),d=r.getAttribute("data-pin");if(d==="none")return null;if(d!==null&&d!==""){let m=parseFloat(d);return isFinite(m)?m:l??$r}return d===""?l??$r:l===null?null:[...r.querySelectorAll(bd)].some(m=>!m.closest("aside")&&!m.closest(".decklight-hero-logo"))?l:null}function Nr(r,i){r.forEach(l=>{let d=wd(l),u=l.getAttribute("data-layout"),m;if(u==="pinned"){let k=parseFloat(l.getAttribute("data-pin"));m=isFinite(k)?k:ji(i)??$r}else u==="centered"||u==="top"?m=null:m=Ki(l,i);let f=xd(l,d);if(l.querySelector(":scope > .pin-title")?.classList.remove("pin-title"),l.querySelector(":scope > .pin-subtitle")?.classList.remove("pin-subtitle"),m===null||!d){l.removeAttribute("data-pinned"),l.style.removeProperty("--pin-y"),l.style.removeProperty("--pin-sub-y"),l.style.removeProperty("--pin-space");return}d.classList.add("pin-title"),l.setAttribute("data-pinned",""),l.style.setProperty("--pin-y",m+"px"),l.classList.add("pin-measure");let h=d.offsetHeight||0,b=m+h;f&&(f.classList.add("pin-subtitle"),l.style.setProperty("--pin-sub-y",Math.round(b+Hi)+"px"),b+=Hi+(f.offsetHeight||0)),l.classList.remove("pin-measure"),l.style.setProperty("--pin-space",Math.round(b+gd)+"px")})}function Wi(r){return[...r.children].filter(i=>!i.matches("h1, h2, .subtitle, aside, script, style, .decklight-hero-logo, .slide-bg"))}function Gi(r){r.forEach((i,l)=>{if(i.querySelectorAll(":scope > .split-columns, :scope > .split-footer").forEach(u=>u.classList.remove("split-columns","split-footer")),!/^split/.test(i.getAttribute("data-layout")||"")){i.removeAttribute("data-split-conflict");return}let d=Wi(i);if(vd(i,d,l+1),d.length===1&&d[0].matches("ul, ol")){d[0].classList.add("split-columns");return}for(let u of d.slice(2))u.classList.add("split-footer")})}function vd(r,i,l){let d=i.some(m=>{let f=getComputedStyle(m);return/flex$/.test(f.display)&&f.flexDirection.startsWith("row")}),u=r.hasAttribute("data-split-conflict");r.toggleAttribute("data-split-conflict",d),d&&!u&&console.warn(`Decklight: slide ${l} combines data-layout="split" with its own column flexbox \u2014 two layout systems fight; drop the data-layout or the flex shell (SPEC COMPARISON_SLIDES)`)}function ds(r,i){if(!r)return;let l=[r,...r.querySelectorAll("pre, table, svg, ul, ol, blockquote")].some(u=>u.scrollHeight>u.clientHeight+2&&getComputedStyle(u).overflowY!=="visible"&&!u.closest(".terminal")&&!u.hasAttribute("data-scroll-ok")),d=r.hasAttribute("data-overflow");r.toggleAttribute("data-overflow",l),l&&!d&&console.warn(`Decklight: slide ${i} content overflows and is clipped \u2014 reduce content or font size`)}function kd(r){r.querySelectorAll("section[data-markdown]").forEach((i,l)=>{i.setAttribute("data-markdown-removed","");let d=[...r.children].indexOf(i)+1||l+1;console.warn(`Decklight: slide ${d} uses data-markdown, which was removed in 0.3.0 \u2014 its content is in a <script type="text/template"> the browser will not render. Author the slide in HTML (SPEC DECK_ANATOMY).`)})}function Vi(r={}){let i=new URLSearchParams(location.search),l={...fd,...r};i.has("embedded")&&(l.controls=!1);let d=i.has("print"),u=i.get("print")||"",m=Fi(),f=null,h=(v,H)=>m.log(v,H),b=document.querySelector(".decklight");if(!b)throw new Error("Decklight: no .decklight element found");let k=hi(),A=Pi({config:l,root:b,embedded:i.has("embedded"),sectionsOf:()=>Q._sections,slideOf:()=>Q.state.slide,navigate:v=>{location.href=v}}),P=A.playlist,M=A.index,T=A.hasMarkers,C=v=>A.gotoModule(v),F=v=>A.navigateToModule(v),ye=200,ge=4,be=[],J=null,de=null;function Oe(){return be}function ke(v){be.push({at:new Date,text:String(v)}),be.length>ye&&be.shift(),de&&ln()}function De(v,H=3200){if(ke(v),d)return;J||(J=document.createElement("div"),J.className="decklight-messages",b.appendChild(J));let G=document.createElement("div");for(G.className="decklight-toast",G.textContent=v,J.appendChild(G),requestAnimationFrame(()=>G.classList.add("show"));J.children.length>ge;)J.firstChild.remove();setTimeout(()=>{G.classList.remove("show"),setTimeout(()=>G.remove(),260)},H)}let xe=Ii({root:b,printMode:d,params:i,toast:De,debugLog:h,overlays:k,deck:()=>Q}),Le=gi({root:b,config:l,params:i,toast:De,debugLog:h,overlays:k,deck:()=>Q,editmode:()=>Tt}),{applyTheme:st,currentTheme:at,cycleTheme:_,cancelCyclePending:qe,rollTheme:Je,saveGeneratedTheme:je}=Le,O=null,D=0,V="",re=[],Ae,Ke=!1,Ce=null;function s(){return Di({sections:Q._sections,modules:P?.modules??[],skipModule:M})}function o(){let v=O.querySelector(".tp-list");if(re=qi(O.__index,V),v.textContent="",re.forEach((G,ve)=>{let Ue=document.createElement("div");Ue.className="tp-row"+(G.slide===Q.state.slide?" tp-current":"")+(G.href?" tp-module":""),Ue.textContent=G.href?`\u25B8 ${G.title} \u2014 module`:`${G.slide} \xB7 ${G.title}`,Ue.addEventListener("mouseenter",()=>Fe(ve,!1)),Ue.addEventListener("click",()=>{Fe(ve,!0),ot()}),v.appendChild(Ue)}),!re.length){let G=document.createElement("div");G.className="tp-none",G.textContent="no matches",v.appendChild(G)}let H=O.querySelector(".tp-filter");H.textContent=V||(P?"type to find a slide or module\u2026":"type to find a slide\u2026"),H.classList.toggle("tp-active",!!V)}function N(v,H){let G=H.href??location.pathname,ve=H.slide??1;if(v.dataset.doc!==G){v.dataset.doc=G,Ke=!1,v.addEventListener("load",()=>{if(Ke=!0,Ce&&O){let Ue=Ce;Ce=null,N(v,Ue)}},{once:!0}),v.src=G+Le.previewQuery()+"#/"+ve+"/0";return}if(!Ke){Ce=H;return}v.contentWindow?.postMessage({__decklightPreview:{goto:[ve,0]}},"*")}function Fe(v,H){if(!re.length)return;D=on(O.querySelectorAll(".tp-row"),v,"tp-selected");let G=re[D];O.querySelector(".tp-caption").textContent=G.href?`module \u2014 ${G.title} (${G.href})`:`slide ${G.slide} \u2014 ${G.title}`,clearTimeout(Ae);let ve=O.querySelector("iframe");H?N(ve,G):Ae=setTimeout(()=>N(ve,G),60)}function B(v){V=v,o(),re.length?Fe(0,!1):O.querySelector(".tp-caption").textContent="no match"}function ot(){let v=re[D];if(K(),!!v){if(v.href)return F(v.module);Q.goto(v.slide,0)}}function mt(){if(O)return K();Le.closePicker(),Tt.restore.close(),V="",O=document.createElement("div"),O.className="decklight-theme-picker decklight-finder",O.innerHTML='<div class="tp-panel"><div class="tp-side"><div class="tp-filter"></div><div class="tp-list" role="listbox" aria-label="Slides"></div></div><div class="tp-preview"><iframe title="Slide preview"></iframe><div class="tp-caption"></div></div></div>',O.__index=s(),o(),It(O,K),b.appendChild(O),Fe(Math.max(0,re.findIndex(v=>v.slide===Q.state.slide)),!0)}function K(){clearTimeout(Ae),O?.remove(),O=null}let _e=null,Y=0,Re="",y=[];function Be(){let v=G=>typeof G=="function";return[{label:"Find slide\u2026",hint:"G",alias:"search grep goto module chapter jump",run:()=>{mt(),Re&&B(Re)}},{label:"History\u2026 (dev)",hint:"H",alias:"restore version rollback revert back git log commits unpushed push remote when changed",run:()=>Tt.history.open()},{label:"Go to slide\u2026",hint:"#",alias:"goto",keepOpen:!0,run:()=>{Re="goto ",w()}},{label:"Theme\u2026",hint:"T",run:Le.openPicker},{label:"Cycle theme",hint:", \xB7 .",run:()=>_(1)},{label:"Generate a theme",hint:"\u2303T",run:Je},Le.hasGenerated()&&{label:"Save the generated theme\u2026",hint:"\u2303\u21E7T",run:()=>je()},Tt.available()&&{label:"Browse marketplace themes\u2026",alias:"marketplace install add third-party download catalog",run:Le.browse},...Tt.wizards().map(G=>({label:`Configure ${G.title}\u2026 (dev)`,alias:"engine wizard setup api key credential token marketplace",run:()=>Tt.wizard(G.qualified)})),{label:"Font\u2026",hint:"[ \xB7 ]",run:Xe},{label:"Cycle slide layout (dev)",hint:"L",alias:"pin pinned centered top auto split columns two sides arrange",run:()=>Vt(1)},{label:"Undo deck edit (dev)",hint:"Z",alias:"revert back history",run:()=>un("undo")},{label:"Redo deck edit (dev)",hint:"\u21E7Z",alias:"forward history repeat",run:()=>un("redo")},{label:"Ask agent\u2026 (dev)",hint:"A",alias:"ai claude codex bob gemini prompt edit",run:On},{label:"Messages",hint:"`",alias:"log toast notifications warnings why voice stopped history",run:tn},{label:`Narration ${Rt.status().narrating?"off":"on"}`,hint:"V",run:rn},{label:"Narration track\u2026",hint:"N",alias:"voice audio",run:()=>sn("tracks")},{label:"Live voice\u2026",alias:"tts synthesize tone gemini",run:()=>sn("voices")},{label:"Character\u2026",alias:"avatar lipsync face talking head visemes",run:()=>sn("character")},{label:`Character solo ${Nn.solo?"off":"on"}`,alias:"centre center stage narrator only fullscreen avatar",run:()=>Rt.applySolo(!Nn.solo)},{label:"Record offline narration\u2026",hint:"\u21E7V",alias:"export download batch wav tts",run:St},{label:"Voice faster",hint:">",alias:"speed rate playback",run:()=>Yt(.25)},{label:"Voice slower",hint:"<",alias:"speed rate playback",run:()=>Yt(-.25)},{label:"Speaker view",hint:"S",run:()=>{let G=Q.__speakerWin;G&&!G.closed?G.__decklightSpeakerToggle?.():Q.__speakerWin=ts(Q)}},{label:"Overview",hint:"O",run:pt},{label:"Blackout",hint:"B",run:ht},{label:`Pen ${Mt.annotator?.tool==="pen"?"off":"on"} \u2014 draw on the slide`,hint:"W",alias:"ink annotate draw scribble marker highlight",run:()=>dn("pen")},{label:`Laser pointer ${Mt.annotator?.tool==="laser"?"off":"on"}`,hint:"\u21E7W",alias:"ink dot glow point at",run:()=>dn("laser")},{label:"Debug log",hint:"D",alias:"console events state",run:an},{label:`Captions ${Rt.status().captionsOn?"off":"on"}`,hint:"C",alias:"cc subtitles closed caption",run:$n},{label:`Clock ${Mt.status().clockOn?"off":"on"}`,hint:"K",alias:"time elapsed timer talk wall watch",run:Gt},{label:`Progress bar ${Mt.status().progressOn?"off":"on"}`,hint:"J",alias:"bar bottom edge position how far through shape of the talk",run:jt},{label:"Transcript\u2026",alias:"notes script export text markdown spoken",run:kt},{label:`Narration ${Rt.status().paused?"resume":"pause"}`,hint:"P",alias:"pause resume voice",run:gn},{label:"Edit speaker notes\u2026",alias:"edit mode notes write right-click background",run:bn},{label:`Element edit mode ${Tt.elementEditOn()?"off":"on"} (dev)`,hint:"E",alias:"right-click remove delete html content build animation entrance effect context menu",run:yn},{label:"Fullscreen",hint:"F",run:()=>Z()},{label:"Print view (all slides, new tab)",hint:"",run:()=>window.open(location.pathname+"?print")},{label:"First slide",hint:"Home",run:()=>Q.goto(1,0)},{label:"Last slide",hint:"End",run:()=>Q.goto(Q.state.totalSlides,0)},{label:"Keyboard help",hint:"?",run:I},{label:"Welcome to Decklight",alias:"onboarding intro getting started first run tour what is this help me",run:xe.showWelcome},{label:`Tips ${xe.status().tipsOn?"off":"on"}`,alias:"hints teach shortcuts learn stop showing quiet",run:()=>xe.setTips(!xe.status().tipsOn)},xe.status().tipsLeft<rr.length&&{label:"Reset tips",alias:"hints again start over show all unsee replay",run:xe.resetTips}].filter(Boolean).filter(G=>v(G.run))}function w(){let v=_e.querySelector(".narr-card");v.textContent="",y=Ui({commands:Be(),query:Re,totalSlides:Q.state.totalSlides,makeGotoRow:(G,ve)=>({label:`Go to slide ${G} / ${ve}`,hint:"\u23CE",run:()=>Q.goto(G,0)}),makeSearchRow:G=>({label:`Search slides for \u201C${G}\u201D`,hint:"",run:()=>{mt(),B(G)}})});let H=document.createElement("div");if(H.className="pal-input"+(Re?" tp-active":""),H.textContent=Re||"type a command\u2026",v.appendChild(H),y.forEach((G,ve)=>{let Ue=document.createElement("div");Ue.className="narr-row pal-row";let Ct=document.createElement("span");if(Ct.textContent=G.label,Ue.appendChild(Ct),G.hint){let zt=document.createElement("span");zt.className="pal-kbd",zt.textContent=G.hint,Ue.appendChild(zt)}Ue.addEventListener("mouseenter",()=>pe(ve)),Ue.addEventListener("click",()=>{pe(ve),Se()}),v.appendChild(Ue)}),!y.length){let G=document.createElement("div");G.className="tp-none",G.textContent="no matching command",v.appendChild(G)}pe(0)}function pe(v){y.length&&(Y=on(_e.querySelectorAll(".pal-row"),v,"narr-sel"))}function Se(){let v=y[Y];v&&(v.keepOpen||Ee(),v.run())}function it(){if(_e)return Ee();O&&K(),Tt.restore.close(),Re="",_e=document.createElement("div"),_e.className="decklight-narr decklight-palette",_e.innerHTML='<div class="narr-card" role="listbox" aria-label="Commands"></div>',It(_e,Ee),b.appendChild(_e),w()}function Ee(){_e?.remove(),_e=null}let ze=null,oe=0;function Xe(){if(ze)return Et();ze=document.createElement("div"),ze.className="decklight-narr decklight-font-picker",ze.innerHTML='<div class="narr-card" role="listbox" aria-label="Fonts"></div>';let v=ze.querySelector(".narr-card");me.forEach(([H],G)=>{let ve=document.createElement("div");ve.className="narr-row"+(G===Ie?" narr-cur":""),ve.textContent=H,G>0&&(ve.style.fontFamily=me[G][1]),ve.addEventListener("mouseenter",()=>gt(G)),ve.addEventListener("click",()=>{et(G),Et()}),v.appendChild(ve)}),It(ze,Et),b.appendChild(ze),gt(Ie)}function gt(v){oe=on(ze.querySelectorAll(".narr-row"),v,"narr-sel")}function Et(){ze?.remove(),ze=null}Le.restoreSaved();let me=[["theme default",null],["system sans","-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif"],["rounded","ui-rounded, 'SF Pro Rounded', 'Hiragino Maru Gothic ProN', Quicksand, Comfortaa, 'Arial Rounded MT Bold', Calibri, sans-serif"],["humanist","Seravek, 'Gill Sans Nova', Ubuntu, Calibri, 'DejaVu Sans', source-sans-pro, sans-serif"],["geometric","'Avenir Next', Avenir, Montserrat, Corbel, 'URW Gothic', source-sans-pro, sans-serif"],["classical serif","'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif"],["transitional serif","Charter, 'Bitstream Charter', 'Sitka Text', Cambria, Georgia, serif"],["slab serif","Rockwell, 'Rockwell Nova', 'Roboto Slab', 'DejaVu Serif', 'Sitka Small', serif"],["monospace","'SF Mono', SFMono-Regular, ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace"]],Ne="decklight-font:"+location.pathname,Ie=0;function et(v,{silent:H=!1,remeasure:G=!0}={}){Ie=(v%me.length+me.length)%me.length;let[ve,Ue]=me[Ie];if(Ue?(b.style.setProperty("--font-body",Ue),b.style.setProperty("--font-heading",Ue)):(b.style.removeProperty("--font-body"),b.style.removeProperty("--font-heading")),!i.has("embedded"))try{Ue?localStorage.setItem(Ne,String(Ie)):localStorage.removeItem(Ne)}catch{}G&&(Nr(Q._sections,l),ds(Q._sections[Q.state.slide-1],Q.state.slide)),H||De(`font: ${ve}`),h("font",ve)}function tt(v){et(Ie+v)}try{let v=parseInt(localStorage.getItem(Ne),10);v>0&&v<me.length&&et(v,{silent:!0,remeasure:!1})}catch{}function bt(v){if(!v)return null;if(v.startsWith("#")){let G=document.querySelector(v);if(!G)return null;let ve=G.cloneNode(!0);return ve.removeAttribute("id"),ve.style.removeProperty("display"),ve}if(v.trim().startsWith("<")){let G=document.createElement("div");return G.innerHTML=v,G.firstElementChild}let H=document.createElement("img");return H.src=v,H.alt="",H}let He=null;Le.updateCanvas();let ft=b.querySelector(":scope > .decklight-stage");if(!ft){for(ft=document.createElement("div"),ft.className="decklight-stage";b.firstChild;)ft.appendChild(b.firstChild);b.appendChild(ft)}if(ft.style.width=l.width+"px",ft.style.height=l.height+"px",l.logo&&(l.logo.src||l.logo.onLight||l.logo.onDark)){He=document.createElement("div"),He.className="decklight-logo",He.setAttribute("data-pos",l.logo.position||"bottom-left"),l.logo.height&&He.style.setProperty("--logo-h",l.logo.height+"px");for(let[v,H]of[["src","on-any"],["onLight","on-light"],["onDark","on-dark"]]){let G=bt(l.logo[v]);if(!G)continue;let ve=document.createElement("span");ve.className=H,ve.appendChild(G),He.appendChild(ve)}b.appendChild(He)}function Dt(v){He&&v.forEach(H=>{if(!H.hasAttribute("data-logo")||H.querySelector(":scope > .decklight-hero-logo"))return;let G=document.createElement("div");G.className="decklight-hero-logo";let ve=parseFloat(H.getAttribute("data-logo"));ve&&G.style.setProperty("--hero-logo-h",ve+"px"),G.innerHTML=He.innerHTML,H.prepend(G)})}kd(ft),oo(ft),go(ft),to(ft),di(ft,sr);let Kt=zi({slideOf:()=>Q.state.slide,sectionAt:v=>Q._sections[v-1],describe:v=>({autoPins:Ki(v,l)!==null,hasSplitPair:Wi(v).length>1}),available:()=>Tt.available(),unavailableMessage:()=>fn("layout",location),apply:(v,H)=>{H==="auto"?v.removeAttribute("data-layout"):v.setAttribute("data-layout",H)},relayout:(v,H)=>(Nr(Q._sections,l),Gi(Q._sections),ds(v,H),v.hasAttribute("data-split-conflict")),post:v=>fetch(Tt.base()+"/edit/layout",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(v)}).then(H=>{if(!H.ok)throw new Error(H.status)}),toast:De,debugLog:h}),Vt=v=>Kt.cycle(v),Ot=v=>Kt.ring(v),Q={root:b,stage:ft,config:l,_sections:[],_records:[],state:{slide:1,step:0,totalSlides:0},_listeners:new Map,_scale:1,on(v,H){return this._listeners.has(v)||this._listeners.set(v,new Set),this._listeners.get(v).add(H),this},_emit(v,H){(this._listeners.get(v)||[]).forEach(G=>G(H)),b.dispatchEvent(new CustomEvent("decklight:"+v,{detail:H}))},sync(){this._sections=[...ft.querySelectorAll(":scope > section")],this._sections.forEach((H,G)=>H.setAttribute("data-slide-index",String(G+1))),eo(ft,l.concepts),Dt(this._sections),Ti(this._sections,{printMode:d}),Nr(this._sections,l),Gi(this._sections),this._records=this._sections.map(H=>jr(H)),this.state.totalSlides=this._sections.length,this.state.slide=Math.min(this.state.slide,this.state.totalSlides||1);let v=this._records[this.state.slide-1];v&&(this.state.step=Math.min(this.state.step,v.groups.length)),Qt(d?this._sections:[this._sections[this.state.slide-1]])},_rescanFor(v){let H=v.closest("section"),G=this._sections.indexOf(H);if(G!==-1){if(this._records[G]=jr(H),d){En(this._records[G],this._records[G].groups.length);return}G===this.state.slide-1?(this.state.step=Math.min(this._requestedStep??this.state.step,this._records[G].groups.length),this._requestedStep=null,_t(()=>En(this._records[G],this.state.step)),this._updateHash(!1)):_t(()=>En(this._records[G],0)),this._notify()}},_stepLabels(v){let H=this._records[v];return H?Js(H):[]},next(){let v=this._records[this.state.slide-1];v&&this.state.step<v.groups.length?this.goto(this.state.slide,this.state.step+1,{direction:"fwd"}):this.state.slide<this.state.totalSlides?this.goto(this.state.slide+1,0,{direction:"fwd"}):C(1)},prev(){if(this.state.step>0)this.goto(this.state.slide,this.state.step-1,{direction:"back"});else if(this.state.slide>1){let v=this._records[this.state.slide-2];this.goto(this.state.slide-1,v.groups.length,{direction:"back"})}else C(-1)},goto(v,H=0,G={}){v=Math.max(1,Math.min(v,this.state.totalSlides));let ve=this._records[v-1];this._requestedStep=H,H=Math.max(0,Math.min(H,ve?ve.groups.length:0));let Ue=v===this.state.slide;if(Ue&&H===this.state.step&&!G.force)return;let Ct=G.direction||(v>this.state.slide||Ue&&H>this.state.step?"fwd":"back");!Ue||G.force?(this._activateSlide(v,Ct,G),this.state.slide=v,this.state.step=H,_t(()=>En(ve,H)),this._emit("slide",{slide:v,total:this.state.totalSlides,direction:Ct}),Qt([this._sections[v-1]])):(this.state.step=H,En(ve,H),this._emit("build",{slide:v,index:H,total:ve.groups.length,direction:Ct})),this._updateChrome(),this._updateHash(!Ue),this._notify()},_activateSlide(v,H,G={}){let ve=this._sections[this.state.slide-1],Ue=this._sections[v-1];if(b.classList.toggle("has-hero-logo",Ue?.hasAttribute("data-logo")??!1),ve===Ue){Ue.classList.add("active");return}let Ct=!ve||!ve.classList.contains("active"),zt=ve&&Ue&&!Ct&&ve.hasAttribute("data-auto-animate")&&Ue.hasAttribute("data-auto-animate")&&Math.abs(this._sections.indexOf(Ue)-this._sections.indexOf(ve))===1;if(this._sections.forEach(z=>z.classList.remove("active","entering","leaving","dir-fwd","dir-back","tr-none","tr-fade","tr-slide","tr-scale","tr-flip")),Ue.classList.add("active"),Ct||d)return;if(zt){ve.classList.add("leaving"),ve.style.visibility="hidden",Ue.style.visibility="hidden",Ue.offsetWidth,Ue.style.visibility="",ho(ve,Ue,this._scale),ve.classList.remove("leaving"),ve.style.visibility="";return}let xn=co(Ue.getAttribute("data-transition"),this.config.transition),Jt=uo(xn,H);if(!Jt)return;Ue.classList.add(...Jt.entering),ve.classList.add(...Jt.leaving);let E=fr(getComputedStyle(Ue).getPropertyValue("--transition-duration"),350);setTimeout(()=>{ve.classList.remove(...Jt.leaving),Ue.classList.remove(...Jt.entering)},E+60)},_updateChrome(){if(se){let v=this._records[this.state.slide-1],H=v?v.groups.length:0,G=this.state.totalSlides<=1?1:(this.state.slide-1+(H?this.state.step/(H+1):0))/(this.state.totalSlides-1);se.style.width=(Math.min(G,1)*100).toFixed(2)+"%"}if($e){let v=this.config.slideNumber?this.config.slideNumber==="n/N"?`${this.state.slide} / ${this.state.totalSlides}`:String(this.state.slide):"";if($e.textContent=v,A.any){let H=A.title(),G=document.createElement("span");G.className="mod",G.textContent=H,$e.prepend(G)}}},_updateHash(v){!this.config.hash||d||(R=R||!!v,!Ht&&(Ht=setTimeout(()=>{Ht=null,W()},Wt)))},_notify(){this.__notifySpeaker&&this.__notifySpeaker()}};function Zt(v,H){let G=document.createElement("a");G.href=v,G.download=H,document.body.appendChild(G),G.click(),G.remove()}function _t(v){b.classList.add("decklight-no-anim"),v(),b.offsetWidth,b.classList.remove("decklight-no-anim")}function vt(v){return(v||"").replace(/^#/,"")}let Wt=90,Ht=null,R=!1;function W(v=!0){if(!Q||!l.hash||d)return;let H=`#/${Q.state.slide}/${Q.state.step}`,G=R;if(R=!1,"#"+vt(location.hash)!==H){cn=!0;try{G?history.pushState(null,"",H):history.replaceState(null,"",H)}catch{}setTimeout(()=>{cn=!1}),v&&"#"+vt(location.hash)!==H&&(R=G,requestAnimationFrame(()=>W(!1)))}}function U(){let v=vt(location.hash).match(/^\/(\d+)(?:\/(\d+))?/);return v?{slide:parseInt(v[1],10),step:v[2]?parseInt(v[2],10):0}:null}let se=null,$e=null;if(l.controls&&!d){let v=document.createElement("div");v.className="decklight-controls",v.innerHTML=`
334
+ </div>`,E.addEventListener("click",te=>{te.stopPropagation(),S()}),Ut(E,S),t.appendChild(E),d?.("nav","welcome shown"))}p.register({isOpen:()=>!!E,close:S,keydown:()=>(S(),!0)});function $(){return wo(Ca)!=="1"}function _(){try{let te=JSON.parse(wo(yo)||"[]");return new Set(Array.isArray(te)?te:[])}catch{return new Set}}function C(){let te=_();return Xr.find(ae=>!te.has(ae.id))||null}function I(){let te=C();if(!te)return null;let ae=_();return ae.add(te.id),Ms(yo,JSON.stringify([...ae])),c(`tip \xB7 ${te.text}`,5200),te.id}function Se(te){Ms(Ca,te?"0":"1"),c(te?"tips on \u2014 one per deck you open":"tips off")}function de(){Ms(yo,"[]"),c(`tips reset \u2014 all ${Xr.length} will show again, one per deck`)}function $e(te){if(!w&&(g().on("slide",S),g().on("build",S),!(te.slide!==1||te.step!==0))){if(wo($a)!=="1"){P();return}$()&&I()}}return{start:$e,showWelcome:P,dismissWelcome:S,showTip:I,setTips:Se,resetTips:de,status:()=>({tipsOn:$(),tipsLeft:C()?Xr.length-_().size:0})}}ge();be();function Ma({sectionsOf:t,checkOverflow:o,ResizeObs:a=typeof ResizeObserver=="function"?ResizeObserver:null,MutationObs:c=typeof MutationObserver=="function"?MutationObserver:null,schedule:d=p=>setTimeout(p)}){let p=[],g=0;function m(){g||(g=d(()=>{g=0;let $=t();for(let _ of p)o(_,$.indexOf(_)+1)})||1)}let w=a?new a(m):null;function E($){if(w)for(let _ of[$,...$.querySelectorAll("*")])_.parentElement?.closest(".terminal")||w.observe(_)}let S=c?new c($=>{let _=I=>!(I.nodeType===1?I:I.parentElement)?.closest(".terminal"),C=!1;for(let I of $)if(_(I.target)){C=!0;for(let Se of I.addedNodes)Se.nodeType===1&&Se.isConnected&&E(Se)}C&&m()}):null,P=$=>{$.target.closest?.(".terminal")||m()};return{watch($){w?.disconnect(),S?.disconnect();for(let _ of p)for(let C of["load","error"])_.removeEventListener(C,P,!0);p=$.filter(Boolean);for(let _ of p){E(_),S?.observe(_,{childList:!0,subtree:!0,characterData:!0});for(let C of["load","error"])_.addEventListener(C,P,!0)}m()},get watched(){return p.slice()}}}ge();be();function Oa({config:t,root:o,embedded:a,sectionsOf:c,slideOf:d,navigate:p}){let g=!a&&t.playlist?.modules?.length?t.playlist:null,m=g?g.index??0:0,w=!!o.querySelector("section[data-module]");function E(){let P=[];return(c()||[]).forEach(($,_)=>{$.hasAttribute("data-module")&&P.push({title:$.getAttribute("data-module"),slide:_+1})}),P}function S(P=E()){let $=-1;return P.forEach((_,C)=>{_.slide<=d()&&($=C)}),$}return{get playlist(){return g},get index(){return m},get hasMarkers(){return w},get any(){return w||!!g},markers:E,currentMarkerIndex:S,gotoModule(P){if(!g)return!1;let $=g.modules[m+P];return $?(p($.href+(P>0?"#/1/0":"#/999/999")),!0):!1},navigateToModule(P){let $=g?.modules[P];$&&p($.href+"#/1/0")},title(){if(w){let P=E();return P[S(P)]?.title||""}return g?.modules[m]?.title||""}}}ge();be();function vo(t,o,a){return(t.querySelector("h1, h2, h3")?.textContent||"").replace(/\s+/g," ").trim()||a.slice(0,60)||`slide ${o+1}`}function xo(t){return[...t.children].filter(a=>!a.matches("aside, script, style")).map(a=>a.textContent).join(" ").replace(/\s+/g," ").trim()}function La({sections:t,modules:o=[],skipModule:a=-1}){let c=t.map((p,g)=>{let m=xo(p);return{slide:g+1,title:vo(p,g,m),haystack:m.toLowerCase()}}),d=o.map((p,g)=>({module:g,title:p.title,href:p.href,haystack:(p.title||"").toLowerCase()})).filter(p=>p.module!==a);return[...c,...d]}function Ra(t,o){let a=String(o??"").toLowerCase().split(/\s+/).filter(Boolean),c=[],d=[];for(let p of t){let g=p.title.toLowerCase();a.every(m=>g.includes(m))?c.push(p):a.every(m=>p.haystack.includes(m))&&d.push(p)}return[...c,...d]}ge();be();ge();be();function Ia(t){let o=2166136261,a=String(t??"").replace(/\s+/g,"");for(let c=0;c<a.length;c++)o^=a.charCodeAt(c),o=Math.imul(o,16777619)>>>0;return o.toString(16).padStart(8,"0")}function Jr(t,o){let a=Array.isArray(o)?o:[],c=Number(t?.slide);if(t?.fp){let p=a.find(g=>g.fp===t.fp);if(p)return{verdict:"exact",slide:p.slide,movedFrom:p.slide===c?null:c}}let d=String(t?.title??"").trim();if(d){let p=a.filter(g=>String(g.title??"").trim()===d);if(p.length===1)return{verdict:"stale",slide:p[0].slide,movedFrom:p[0].slide===c?null:c}}return!t?.fp&&Number.isInteger(c)&&c>=1&&c<=a.length?{verdict:"unanchored",slide:c,movedFrom:null}:{verdict:"orphaned",slide:null,movedFrom:null}}var ko={exact:null,stale:"this slide changed since the comment was written",unanchored:"could not find the slide this was written on \u2014 showing it where it used to be",orphaned:"the slide this was written on is gone"};function Eo(t,{titleOf:o,bodyOf:a}){return t.map((c,d)=>{let p=a(c);return{slide:d+1,title:o(c,d,p),fp:Ia(p)}})}function Pr(t){let o=new Map,a=[],c=[],d=[];for(let p of t){if(p.op==="resolve"){c.push(p);continue}if(p.op==="anchor"){d.push(p);continue}if(p.re){a.push(p);continue}o.has(p.id)||o.set(p.id,{...p,replies:[],resolved:null})}for(let p of a)o.get(p.re)?.replies.push(p);for(let p of c){let g=o.get(p.re);g&&(g.resolved={at:p.at??null,by:p.by??null})}for(let p of d){let g=o.get(p.re);!g||!Number.isInteger(p.slide)||(g.slide=p.slide,g.title=p.title??null,g.fp=p.fp??null,g.anchored={at:p.at??null,by:p.by??null})}return[...o.values()]}function Pa({root:t,params:o,overlays:a,instance:c,toast:d,debugLog:p,dismissOthers:g=()=>{},sections:m=()=>[],titleOf:w,bodyOf:E,authorBase:S=()=>null,authorReady:P=()=>Promise.resolve()}){let $=null,_=[],C=0,I=null,Se=!1,de=null,$e=[],te=null,ae=null,Re=!1,Fe=null,je=null,_e="decklight-review-dock:"+location.pathname,Ae={mode:"float",x:null,y:null};try{let f=JSON.parse(localStorage.getItem(_e));f?.mode&&(Ae.mode=f.mode,Ae.x=f.x??null,Ae.y=f.y??null)}catch{}let st=()=>{try{localStorage.setItem(_e,JSON.stringify(Ae))}catch{}},bt={float:"\u274F",left:"\u25E7",right:"\u25E8",bottom:"\u2B13"},T=()=>({w:Math.min(360,Math.round(t.clientWidth*.32)),h:Math.min(320,Math.round(t.clientHeight*.4))});function Ke(){if(!$)return;$.dataset.dock=Ae.mode;let f=T();t.style.setProperty("--dock-left",Ae.mode==="left"?f.w+"px":"0px"),t.style.setProperty("--dock-right",Ae.mode==="right"?f.w+"px":"0px"),t.style.setProperty("--dock-bottom",Ae.mode==="bottom"?f.h+"px":"0px"),$.style.setProperty("--dock-size",Ae.mode==="bottom"?f.h+"px":f.w+"px");let Y=$.querySelector(".narr-card");Y&&Ae.mode!=="float"&&(Y.style.left="",Y.style.top=""),c._reflow?.(),Ae.mode==="float"&&mt()}function mt(){let f=$?.querySelector(".narr-card");if(!f||Ae.mode!=="float")return;let Y=f.offsetWidth||460,F=f.offsetHeight||400,Ce=Ae.x,ce=Ae.y;(Ce==null||ce==null)&&(Ce=t.clientWidth-Y-24,ce=24),Ce=Math.max(8,Math.min(Ce,t.clientWidth-Y-8)),ce=Math.max(8,Math.min(ce,t.clientHeight-F-8)),Ae.x=Ce,Ae.y=ce,f.style.left=Ce+"px",f.style.top=ce+"px"}function dt(f){Ae.mode=f,st(),Ke(),$?.querySelectorAll(".rv-dock-btn").forEach(F=>F.classList.toggle("rv-dock-on",F.dataset.mode===f));let Y=$?.querySelector(".narr-head");Y&&(Y.style.cursor=f==="float"?"move":"")}function G(f,Y){if(Ae.mode!=="float"||f.button!=null&&f.button!==0||f.target.closest(".rv-dock-ctl"))return;let F=$.querySelector(".narr-card");if(!F)return;f.preventDefault();let Ce=f.clientX,ce=f.clientY,Ne=parseFloat(F.style.left)||0,ee=parseFloat(F.style.top)||0,nt=ut=>{let ke=F.offsetWidth,Ee=F.offsetHeight;Ae.x=Math.max(8,Math.min(Ne+ut.clientX-Ce,t.clientWidth-ke-8)),Ae.y=Math.max(8,Math.min(ee+ut.clientY-ce,t.clientHeight-Ee-8)),F.style.left=Ae.x+"px",F.style.top=Ae.y+"px"},pt=()=>{window.removeEventListener("pointermove",nt),window.removeEventListener("pointerup",pt),st()};window.addEventListener("pointermove",nt),window.addEventListener("pointerup",pt)}let J=()=>Eo(m(),{titleOf:w,bodyOf:E});async function ne(){if(ae!==null)return ae||(ae===""?"":null);try{let f=await fetch("/review/ping"),Y=f.ok?await f.json():null;ae=Y?.ok&&Y.review?"":!1}catch{ae=!1}return ae===!1?null:ae}async function fe(){let f=await ne(),Y=f!==null?`${f}/review/comments`:`${S()??""}/edit/review`;if(f===null&&S()==null)return{records:[],skipped:0,can:"none"};try{let Ce=await(await fetch(Y)).json();if(!Ce?.ok)throw new Error(Ce?.error||"unreadable");let ce={records:Ce.records??[],skipped:Ce.skipped??0,can:f!==null?"comment":"resolve"};if(ce.can==="resolve")try{let ee=await(await fetch(`${S()??""}/edit/review/incoming`)).json();ee?.ok&&(ce.incoming=ee)}catch{}return ce}catch(F){return p("review",`could not read comments: ${String(F.message||F)}`),{records:[],skipped:0,can:"none",error:String(F.message||F)}}}let ue=(f,Y,F)=>{let Ce=document.createElement(f);return Y&&(Ce.className=Y),F!=null&&(Ce.textContent=F),Ce},Ie=f=>f.by?f.by.replace(/\s*<[^>]*>$/,""):"someone";function Q(f,Y,{branch:F=null,done:Ce=!1}={}){let ce=Jr(f,Y),Ne=ue("div",`rv-row${f.resolved?" rv-resolved":""}${F?" rv-inc":""}${Ce?" rv-done":""}`);Ne.setAttribute("role","option");let ee=ue("div","rv-head");ee.append(ue("span","rv-slide",ce.slide?`slide ${ce.slide}`:"slide gone")),ee.append(ue("span","rv-who",Ie(f))),f.deck&&ee.append(ue("span","rv-at",`@${f.deck}`)),ce.movedFrom&&ee.append(ue("span","rv-moved",`was ${ce.movedFrom}`)),f.resolved&&ee.append(ue("span","rv-tick","\u2713")),Ne.append(ee),Ne.append(ue("div","rv-body",f.body??""));let nt=ko[ce.verdict];nt&&Ne.append(ue("div","rv-note",`\u26A0 ${nt}`));for(let ut of f.replies)Ne.append(ue("div","rv-reply",`\u21B3 ${Ie(ut)}: ${ut.body??""}`));if(te?.id===f.id){let ut=te.data;Ne.append(ue("div","rv-then",ut.known?`what it said \u2014 slide ${ut.slide}${ut.title?` \xB7 ${ut.title}`:""}${ut.deck?` \xB7 @${ut.deck}`:""}:
335
+ ${ut.text||"(nothing)"}`:`cannot show what it said \u2014 ${ut.why}`))}I===f.id&&Ne.append(ue("div","rv-arm","resolve this comment? \u23CE again to confirm \xB7 Esc to back out")),de===f.id&&Ne.append(ue("div","rv-arm",`move this comment to slide ${c.state.slide} (the one on screen)? A again to confirm \xB7 Esc backs out`));let pt={id:f.id,slide:ce.slide,node:Ne,resolved:!!f.resolved,branch:F,done:Ce};return Ne.addEventListener("click",()=>{i(_.indexOf(pt)),O()}),_.push(pt),Ne}function s(f){let Y=_[C]?.id??null,F=$.querySelector(".narr-card");F.replaceChildren();let Ce=J(),ce=c.state.slide;_=[],$e=f.incoming?.reviews??[];let Ne=ue("div","narr-head");Ne.append(ue("span","rv-heading","comments"));let ee=ue("div","rv-dock-ctl");for(let re of["float","left","right","bottom"]){let Ge=ue("button","rv-dock-btn"+(Ae.mode===re?" rv-dock-on":""),bt[re]);Ge.dataset.mode=re,Ge.title=re==="float"?"float (movable)":`dock ${re}`,Ge.setAttribute("aria-label",re==="float"?"float":`dock ${re}`),Ge.addEventListener("click",()=>dt(re)),ee.append(Ge)}let nt=ue("button","rv-dock-btn rv-close","\xD7");if(nt.title="close (M)",nt.setAttribute("aria-label","close"),nt.addEventListener("click",ze),ee.append(nt),Ne.append(ee),Ne.style.cursor=Ae.mode==="float"?"move":"",Ne.addEventListener("pointerdown",re=>G(re,Ne)),F.append(Ne),f.incoming){let re=f.incoming;if(re.reviews?.length){let Ge=ue("div","rv-incoming"),ht=[...re.reviews].sort((tt,He)=>Number(tt.done)-Number(He.done));for(let tt of ht){let He=new Set(tt.doneIds??[]),gt=Pr(tt.records??[]).filter(It=>!It.resolved),Yt=gt.filter(It=>!He.has(It.id)).length;Ge.append(ue("div",`rv-src${tt.done?" rv-done":""}`,tt.done?`\u2713 ${tt.who} \u2014 all ${gt.length} done \xB7 ${tt.branch}`:`\u2193 ${tt.who} \u2014 ${Yt} of ${gt.length} left \xB7 ${tt.branch}`));let nn=[...gt].sort((It,Wt)=>Number(He.has(It.id))-Number(He.has(Wt.id)));for(let It of nn)Ge.append(Q(It,Ce,{branch:tt.branch,done:He.has(It.id)}))}F.append(Ge)}else re.state&&!["ok","none","no-repo","untracked","no-remote","suppressed"].includes(re.state)&&F.append(ue("div","rv-inc-how",`incoming reviews: not checked \u2014 ${re.state}`))}let pt=ue("div","rv-list");pt.setAttribute("role","listbox");let ut=Pr(f.records);if(f.error?pt.append(ue("div","rv-none",`could not read the comments \u2014 ${f.error}`)):ut.length||pt.append(ue("div","rv-none",f.can==="none"?"no comments, and nothing here can take one \u2014 a reviewer leaves them with: decklight review <deck>":"no comments yet")),f.skipped&&pt.append(ue("div","rv-skipped",`${f.skipped} line(s) could not be read and were skipped`)),f.incoming?.reviews?.length&&ut.length){let re=ut.filter(Ge=>!Ge.resolved).length;pt.append(ue("div","rv-src",re?`\u270E your comments \u2014 ${re} of ${ut.length} left`:`\u2713 your comments \u2014 all ${ut.length} done`))}let ke=[...ut].sort((re,Ge)=>+!!re.resolved-+!!Ge.resolved);for(let re of ke)pt.append(Q(re,Ce));if(F.append(pt),f.can==="comment"){let re=ue("div",`rv-submit${Se?" rv-arm":""}`,Se?"push this review to the author? S again to confirm \xB7 Esc backs out":"S sends this review to the author (a review/\u2026 branch on the remote)");re.setAttribute("role","button"),re.tabIndex=0,re.addEventListener("click",()=>W()),F.append(re)}F.append(ue("div","rec-hint",f.can==="resolve"?$e.length?"\u23CE jumps \xB7 R marks one done (again reopens a reviewer's) \xB7 A moves here \xB7 Esc closes":"\u23CE jumps (on a gone slide: shows what it said) \xB7 R marks one done \xB7 A moves here \xB7 Esc closes":f.can==="comment"?"\u23CE jumps to the slide \xB7 S submits the review \xB7 Esc closes":"\u23CE jumps to the slide \xB7 Esc closes"));let Ee=Y===null?-1:_.findIndex(re=>re.id===Y);i(Ee>=0?Ee:Math.min(C,Math.max(0,_.length-1))),mt()}function i(f){_.length&&(C=vn(_.map(Y=>Y.node),f,"rv-sel"))}function O(){let f=_[C];if(f){if(!f.slide){De(f);return}c.goto(f.slide,0,{force:!0})}}async function De(f){if(te?.id===f.id){te=null,s(await fe());return}let Y=S();if(Y==null){d("only the author server can look that far back");return}try{let F=await fetch(`${Y}/edit/review/at?id=${encodeURIComponent(f.id)}`),Ce=await F.json();if(!Ce?.ok)throw new Error(Ce?.error||`HTTP ${F.status}`);te={id:f.id,data:Ce}}catch(F){te={id:f.id,data:{known:!1,why:String(F.message||F)}}}s(await fe())}async function B(){let f=_[C];if(!f||f.resolved)return;let Y=S();if(Y==null)return;if(de!==f.id){de=f.id,I=null,s(await fe());return}if(de=null,f.branch){d("this comment is on a review branch \u2014 only your own comments can be moved");return}let F=c.state.slide,Ce=J()[F-1];try{if(!(await(await fetch(`${Y}/edit/review`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({op:"anchor",re:f.id,slide:F,title:Ce?.title,fp:Ce?.fp})})).json())?.ok)throw new Error("refused");d(`moved to slide ${F}`),te=null}catch(ce){d(`could not move that \u2014 ${String(ce.message||ce)}`)}s(await fe())}async function Pe(f,Y,F){let Ce=String(f??"").trim();if(!Ce)return;let ce=await ne(),Ne=ce!==null?{url:`${ce}/review/comments`,mine:!1}:S()!=null?{url:`${S()}/edit/review`,mine:!0}:null;if(Ne)try{let ee=await fetch(Ne.url,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:Y,title:F?.title,fp:F?.fp,body:Ce})}),nt=await ee.json();if(!nt?.ok)throw new Error(nt?.error||`HTTP ${ee.status}`);d(`comment left on slide ${Y}`),p("review",`comment ${nt.id} on slide ${Y}`),$&&s(await fe())}catch(ee){d(`could not leave that comment \u2014 ${String(ee.message||ee)}`)}}async function _t(){let f=_[C];if(!f)return;let Y=S();if(Y!=null){if(f.branch){try{let Ce=await(await fetch(`${Y}/edit/review/done`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({branch:f.branch,id:f.id,done:!f.done})})).json();if(!Ce?.ok)throw new Error(Ce?.error||"refused");d(Ce.done?"done":"reopened"),p("review",`${f.branch} ${f.id} ${Ce.done?"done":"reopened"}`)}catch(F){d(`could not mark that \u2014 ${String(F.message||F)}`)}s(await fe());return}if(!f.resolved){if(I!==f.id){I=f.id,s(await fe());return}I=null;try{if(!(await(await fetch(`${Y}/edit/review`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({op:"resolve",re:f.id})})).json())?.ok)throw new Error("refused");d("resolved")}catch(F){d(`could not resolve that \u2014 ${String(F.message||F)}`)}s(await fe())}}}async function W(){let f=await ne();if(f===null){d("nothing here can submit \u2014 run: decklight review <deck>");return}if(!Se){Se=!0,s(await fe());return}Se=!1;try{let Y=await fetch(`${f}/review/submit`,{method:"POST"}),F=await Y.json();if(!F?.ok)throw new Error(F?.error||`HTTP ${Y.status}`);d(`review pushed \u2192 ${F.branch}`),p("review",`submitted ${F.comments} comment(s) to ${F.branch}`)}catch(Y){d(`could not submit \u2014 ${String(Y.message||Y)}`)}s(await fe())}let ye=null;function ie(){ye?.remove(),ye=null}async function Ze(){if(ye)return ie();let f=await ne(),Y=S();if(f===null&&Y==null){d("nothing here can take a comment \u2014 decklight author, or decklight review");return}g(),ze();let F=c.state.slide;ye=document.createElement("div"),ye.className="decklight-narr decklight-compose",ye.innerHTML='<div class="narr-card" role="dialog" aria-label="Leave a comment"></div>',Ut(ye,ie),t.appendChild(ye);let Ce=ye.querySelector(".narr-card"),ce=J();Ce.append(ue("div","narr-head","leave a comment")),Ce.append(ue("div","rv-on",`on slide ${F}${ce[F-1]?.title?` \xB7 ${ce[F-1].title}`:""}`));let Ne=ue("textarea","narr-input rv-input");Ne.placeholder="what you want remembered about this slide\u2026",Ne.rows=3;let ee=ue("div","narr-row narr-sel rv-send","Leave this comment");ee.setAttribute("role","button"),ee.tabIndex=0;let nt=async()=>{if(!Ne.value.trim()){Ne.focus();return}await Pe(Ne.value,F,ce[F-1]),ie()};ee.addEventListener("click",nt),Ne.addEventListener("keydown",re=>{re.key==="Enter"&&(re.metaKey||re.ctrlKey)&&(re.preventDefault(),nt()),re.stopPropagation()}),Ce.append(Ne,ee),Ce.append(ue("div","rec-hint","\u2318\u23CE leaves it \xB7 Esc closes \xB7 M reads them all")),setTimeout(()=>Ne.focus(),0);let pt=await fe();if(!ye)return;let ut=Pr(pt.records??[]).filter(re=>!re.resolved&&Jr(re,ce).slide===F),ke=(pt.incoming?.reviews??[]).flatMap(re=>Pr(re.records??[]).filter(Ge=>!Ge.resolved&&Jr(Ge,ce).slide===F).map(Ge=>({c:Ge,who:re.who})));if(!ut.length&&!ke.length)return;let Ee=ue("div","rv-already");Ee.append(ue("div","rv-src",`already on this slide \u2014 ${ut.length+ke.length}`));for(let re of ut)Ee.append(ue("div","rv-said",`${Ie(re)}: ${re.body}`));for(let{c:re,who:Ge}of ke)Ee.append(ue("div","rv-said",`${Ge}: ${re.body}`));Ce.append(Ee)}async function v(){if($)return ze();g(),I=null,Se=!1,de=null,te=null,C=0,$=document.createElement("div"),$.className="decklight-narr decklight-review",$.dataset.dock=Ae.mode,$.innerHTML='<div class="narr-card" role="dialog" aria-label="Review comments"></div>',t.appendChild($),Re=Ae.mode==="float",je=f=>{Re=!!$&&$.contains(f.target)},document.addEventListener("pointerdown",je,!0),document.addEventListener("focusin",je,!0),Fe=()=>Ke(),window.addEventListener("resize",Fe),Ke(),s({records:[],skipped:0,can:"none"}),await P(),$&&s(await fe())}function ze(){$?.remove(),$=null,I=null,Se=!1,de=null,te=null,Re=!1,t.style.removeProperty("--dock-left"),t.style.removeProperty("--dock-right"),t.style.removeProperty("--dock-bottom"),c._reflow?.(),Fe&&(window.removeEventListener("resize",Fe),Fe=null),je&&(document.removeEventListener("pointerdown",je,!0),document.removeEventListener("focusin",je,!0),je=null)}return a.register({isOpen:()=>!!ye,close:ie,keydown(f){return f.key==="Escape"?(ie(),!0):!1}}),a.register({isOpen:()=>!!$,close:ze,modal:()=>Re,keydown(f){let Y=/^(input|textarea)$/i.test(f.target?.tagName??"");if(f.key!=="Escape"&&!(f.key==="m"||f.key==="M")&&!Re)return!1;if(f.key==="Escape")return I||Se||de?(I=null,Se=!1,de=null,fe().then(F=>$&&s(F)),!0):(ze(),!0);if(Y)return!1;switch(f.key){case"ArrowDown":i(C+1);break;case"ArrowUp":i(C-1);break;case"Enter":I&&_[C]?.id===I?_t():O();break;case"r":case"R":_t();break;case"s":case"S":W();break;case"a":case"A":B();break;case"m":case"M":ze();break;default:return!1}return!0}}),o?.has?.("review")&&setTimeout(()=>{a.active()||v()},700),{open:v,close:ze,isOpen:()=>!!$,compose:Ze,submit:async()=>{$||await v(),Se=!0,$&&s(await fe())}}}ge();be();function Ba({now:t=Date.now,keep:o=200}={}){let a=t(),c=[],d=null;function p(g,m){let w={t:((t()-a)/1e3).toFixed(3),kind:g,msg:m};return c.push(w),c.length>o&&c.shift(),d?.(w),w}return{log:p,get entries(){return c.slice()},onEntry(g){d=g}}}ge();be();var Md=["auto","centered","pinned","top","split","split-flip"];function Od({autoPins:t,hasSplitPair:o}){return Md.filter(a=>(a!=="pinned"||!t)&&(a!=="split-flip"||o))}function Ld(t,o,a){if(!t.length)return null;let c=Math.max(0,t.indexOf(o));return t[(c+a+t.length)%t.length]}function Da({slideOf:t,sectionAt:o,describe:a,available:c,unavailableMessage:d,apply:p,relayout:g,post:m,toast:w,debugLog:E,schedule:S=setTimeout,cancel:P=clearTimeout,delay:$=600}){let _=null,C=null;function I(){P(C);let $e=_;_=null,$e&&m({slide:$e.slide,layout:$e.name}).then(()=>E("layout",`slide ${$e.slide}: ${$e.name} \u2192 saved to file`)).catch(()=>w("layout save failed \u2014 is the dev server still up?",2200))}function Se($e=t()){let te=o($e);return te?Od(a(te)):[]}function de($e){if(!c()){w(d(),3200);return}let te=t(),ae=o(te);if(!ae)return;let Re=Ld(Se(te),ae.getAttribute("data-layout")||"auto",$e);if(!Re)return;p(ae,Re),_&&_.slide!==te&&I(),_={slide:te,name:Re},P(C),C=S(I,$);let Fe=g(ae,te);w(Fe?`layout: ${Re} \u2014 fights this slide's own column flexbox; pick one`:`layout: ${Re}`),E("layout",`slide ${te}: ${Re}`)}return{ring:Se,cycle:de,flush:I}}ge();be();function qa({commands:t,query:o="",totalSlides:a=0,makeGotoRow:c,makeSearchRow:d}){let p=String(o).toLowerCase(),g=t.filter(w=>!p||(w.label+" "+(w.alias??"")).toLowerCase().includes(p)),m=String(o).trim().match(/^(?:goto\s*)?(\d+)$/i);if(m&&c){let w=Math.max(1,Math.min(parseInt(m[1],10),a));g.unshift(c(w,a))}return p&&!m&&d&&!g.some(w=>w.label.toLowerCase().startsWith(p))&&g.push(d(o)),g}var Rd={transition:"fade",hash:!0,controls:!0,slideNumber:!1,width:1280,height:720,pinTitles:!0},Ls=99,Id=18,Fa=6,Pd="ul, ol, svg, pre, table, .terminal, img, .columns",Br=null;function Qr(t,o){zo(t,o),Br&&Br._rescanFor(t)}function Bd(t){let o=getComputedStyle(t).position;return o==="absolute"||o==="fixed"}function Dd(t){for(let o of t.children)if(!o.matches("aside, script, style, .decklight-hero-logo, .slide-bg")){if(o.matches("h1, h2"))return o;if(!Bd(o))return null}return null}function qd(t,o){if(!o||t.getAttribute("data-subtitle")==="none")return null;let a=o.nextElementSibling;return a&&a.matches("p")&&!a.hasAttribute("data-build")?(a.classList.add("subtitle"),a):t.querySelector(":scope > p.subtitle")}function Ua(t){return t.pinTitles===!0?Ls:typeof t.pinTitles=="number"&&isFinite(t.pinTitles)?t.pinTitles:null}function Ha(t,o){let a=Ua(o),c=t.getAttribute("data-pin");if(c==="none")return null;if(c!==null&&c!==""){let p=parseFloat(c);return isFinite(p)?p:a??Ls}return c===""?a??Ls:a===null?null:[...t.querySelectorAll(Pd)].some(p=>!p.closest("aside")&&!p.closest(".decklight-hero-logo"))?a:null}function Os(t,o){t.forEach(a=>{let c=Dd(a),d=a.getAttribute("data-layout"),p;if(d==="pinned"){let E=parseFloat(a.getAttribute("data-pin"));p=isFinite(E)?E:Ua(o)??Ls}else d==="centered"||d==="top"?p=null:p=Ha(a,o);let g=qd(a,c);if(a.querySelector(":scope > .pin-title")?.classList.remove("pin-title"),a.querySelector(":scope > .pin-subtitle")?.classList.remove("pin-subtitle"),p===null||!c){a.removeAttribute("data-pinned"),a.style.removeProperty("--pin-y"),a.style.removeProperty("--pin-sub-y"),a.style.removeProperty("--pin-space");return}c.classList.add("pin-title"),a.setAttribute("data-pinned",""),a.style.setProperty("--pin-y",p+"px"),a.classList.add("pin-measure");let m=c.offsetHeight||0,w=p+m;g&&(g.classList.add("pin-subtitle"),a.style.setProperty("--pin-sub-y",Math.round(w+Fa)+"px"),w+=Fa+(g.offsetHeight||0)),a.classList.remove("pin-measure"),a.style.setProperty("--pin-space",Math.round(w+Id)+"px")})}function ja(t){return[...t.children].filter(o=>!o.matches("h1, h2, .subtitle, aside, script, style, .decklight-hero-logo, .slide-bg"))}function za(t){t.forEach((o,a)=>{if(o.querySelectorAll(":scope > .split-columns, :scope > .split-footer").forEach(d=>d.classList.remove("split-columns","split-footer")),!/^split/.test(o.getAttribute("data-layout")||"")){o.removeAttribute("data-split-conflict");return}let c=ja(o);if(Fd(o,c,a+1),c.length===1&&c[0].matches("ul, ol")){c[0].classList.add("split-columns");return}for(let d of c.slice(2))d.classList.add("split-footer")})}function Fd(t,o,a){let c=o.some(p=>{let g=getComputedStyle(p);return/flex$/.test(g.display)&&g.flexDirection.startsWith("row")}),d=t.hasAttribute("data-split-conflict");t.toggleAttribute("data-split-conflict",c),c&&!d&&console.warn(`Decklight: slide ${a} combines data-layout="split" with its own column flexbox \u2014 two layout systems fight; drop the data-layout or the flex shell (SPEC COMPARISON_SLIDES)`)}function So(t,o){if(!t)return;let a=[t,...t.querySelectorAll("pre, table, svg, ul, ol, blockquote")].some(d=>d.scrollHeight>d.clientHeight+2&&getComputedStyle(d).overflowY!=="visible"&&!d.closest(".terminal")&&!d.hasAttribute("data-scroll-ok")),c=t.hasAttribute("data-overflow");t.toggleAttribute("data-overflow",a),a&&!c&&console.warn(`Decklight: slide ${o} content overflows and is clipped \u2014 reduce content or font size`)}function zd(t){t.querySelectorAll("section[data-markdown]").forEach((o,a)=>{o.setAttribute("data-markdown-removed","");let c=[...t.children].indexOf(o)+1||a+1;console.warn(`Decklight: slide ${c} uses data-markdown, which was removed in 0.3.0 \u2014 its content is in a <script type="text/template"> the browser will not render. Author the slide in HTML (SPEC DECK_ANATOMY).`)})}function Ga(t={}){let o=new URLSearchParams(location.search),a={...Rd,...t};o.has("embedded")&&(a.controls=!1);let c=o.has("print"),d=o.get("print")||"",p=Ba(),g=null,m=(k,z)=>p.log(k,z),w=document.querySelector(".decklight");if(!w)throw new Error("Decklight: no .decklight element found");let E=na(),S=Oa({config:a,root:w,embedded:o.has("embedded"),sectionsOf:()=>oe._sections,slideOf:()=>oe.state.slide,navigate:k=>{location.href=k}}),P=S.playlist,$=S.index,_=S.hasMarkers,C=k=>S.gotoModule(k),I=k=>S.navigateToModule(k),Se=200,de=4,$e=[],te=null,ae=null;function Re(){return $e}function Fe(k){$e.push({at:new Date,text:String(k)}),$e.length>Se&&$e.shift(),ae&&Qe()}function je(k,z=3200){if(Fe(k),c)return;te||(te=document.createElement("div"),te.className="decklight-messages",w.appendChild(te));let K=document.createElement("div");for(K.className="decklight-toast",K.textContent=k,te.appendChild(K),requestAnimationFrame(()=>K.classList.add("show"));te.children.length>de;)te.firstChild.remove();setTimeout(()=>{K.classList.remove("show"),setTimeout(()=>K.remove(),260)},z)}let _e=Na({root:w,printMode:c,params:o,toast:je,debugLog:m,overlays:E,deck:()=>oe}),Ae=oa({root:w,config:a,params:o,toast:je,debugLog:m,overlays:E,deck:()=>oe,editmode:()=>Nt}),{applyTheme:st,currentTheme:bt,cycleTheme:T,cancelCyclePending:Ke,rollTheme:mt,saveGeneratedTheme:dt}=Ae,G=null,J=0,ne="",fe=[],ue,Ie=!1,Q=null;function s(){return La({sections:oe._sections,modules:P?.modules??[],skipModule:$})}function i(){let k=G.querySelector(".tp-list");if(fe=Ra(G.__index,ne),k.textContent="",fe.forEach((K,me)=>{let et=document.createElement("div");et.className="tp-row"+(K.slide===oe.state.slide?" tp-current":"")+(K.href?" tp-module":""),et.textContent=K.href?`\u25B8 ${K.title} \u2014 module`:`${K.slide} \xB7 ${K.title}`,et.addEventListener("mouseenter",()=>De(me,!1)),et.addEventListener("click",()=>{De(me,!0),Pe()}),k.appendChild(et)}),!fe.length){let K=document.createElement("div");K.className="tp-none",K.textContent="no matches",k.appendChild(K)}let z=G.querySelector(".tp-filter");z.textContent=ne||(P?"type to find a slide or module\u2026":"type to find a slide\u2026"),z.classList.toggle("tp-active",!!ne)}function O(k,z){let K=z.href??location.pathname,me=z.slide??1;if(k.dataset.doc!==K){k.dataset.doc=K,Ie=!1,k.addEventListener("load",()=>{if(Ie=!0,Q&&G){let et=Q;Q=null,O(k,et)}},{once:!0}),k.src=K+Ae.previewQuery()+"#/"+me+"/0";return}if(!Ie){Q=z;return}k.contentWindow?.postMessage({__decklightPreview:{goto:[me,0]}},"*")}function De(k,z){if(!fe.length)return;J=vn(G.querySelectorAll(".tp-row"),k,"tp-selected");let K=fe[J];G.querySelector(".tp-caption").textContent=K.href?`module \u2014 ${K.title} (${K.href})`:`slide ${K.slide} \u2014 ${K.title}`,clearTimeout(ue);let me=G.querySelector("iframe");z?O(me,K):ue=setTimeout(()=>O(me,K),60)}function B(k){ne=k,i(),fe.length?De(0,!1):G.querySelector(".tp-caption").textContent="no match"}function Pe(){let k=fe[J];if(W(),!!k){if(k.href)return I(k.module);oe.goto(k.slide,0)}}function _t(){if(G)return W();Ae.closePicker(),Nt.restore.close(),ne="",G=document.createElement("div"),G.className="decklight-theme-picker decklight-finder",G.innerHTML='<div class="tp-panel"><div class="tp-side"><div class="tp-filter"></div><div class="tp-list" role="listbox" aria-label="Slides"></div></div><div class="tp-preview"><iframe title="Slide preview"></iframe><div class="tp-caption"></div></div></div>',G.__index=s(),i(),Ut(G,W),w.appendChild(G),De(Math.max(0,fe.findIndex(k=>k.slide===oe.state.slide)),!0)}function W(){clearTimeout(ue),G?.remove(),G=null}let ye=null,ie=0,Ze="",v=[];function ze(){let k=K=>typeof K=="function";return[{label:"Find slide\u2026",hint:"G",alias:"search grep goto module chapter jump",run:()=>{_t(),Ze&&B(Ze)}},{label:"Comments\u2026",hint:"M",alias:"feedback remarks reviewer notes critique review read",run:()=>Nn.open()},{label:"Leave a comment\u2026",hint:"\u21E7M",alias:"comment note remark feedback add write say",run:()=>Nn.compose()},{label:"Submit review\u2026",alias:"send review push comments submit feedback",run:()=>Nn.submit()},{label:"History\u2026 (dev)",hint:"H",alias:"restore version rollback revert back git log commits unpushed push remote when changed",run:()=>Nt.history.open()},{label:"Go to slide\u2026",hint:"#",alias:"goto",keepOpen:!0,run:()=>{Ze="goto ",f()}},{label:"Theme\u2026",hint:"T",run:Ae.openPicker},{label:"Cycle theme",hint:", \xB7 .",run:()=>T(1)},{label:"Generate a theme",hint:"\u2303T",run:mt},Ae.hasGenerated()&&{label:"Save the generated theme\u2026",hint:"\u2303\u21E7T",run:()=>dt()},Nt.available()&&{label:"Browse marketplace themes\u2026",alias:"marketplace install add third-party download catalog",run:Ae.browse},...Nt.wizards().map(K=>({label:`Configure ${K.title}\u2026 (dev)`,alias:"engine wizard setup api key credential token marketplace",run:()=>Nt.wizard(K.qualified)})),{label:"Font\u2026",hint:"[ \xB7 ]",run:nt},{label:"Cycle slide layout (dev)",hint:"L",alias:"pin pinned centered top auto split columns two sides arrange",run:()=>It(1)},{label:"Undo deck edit (dev)",hint:"Z",alias:"revert back history",run:()=>Mn("undo")},{label:"Redo deck edit (dev)",hint:"\u21E7Z",alias:"forward history repeat",run:()=>Mn("redo")},{label:"Ask agent\u2026 (dev)",hint:"A",alias:"ai claude codex bob gemini prompt edit",run:Gn},{label:"Messages",hint:"`",alias:"log toast notifications warnings why voice stopped history",run:wt},{label:`Narration ${St.status().paused?"resume":St.status().narrating?"pause":"play"}`,hint:"\u23B5",alias:"play pause resume voice narration speak start stop",run:()=>St.playPause()},{label:"Narration\u2026",hint:"V",alias:"voice audio track picker settings",run:()=>_n("tracks")},{label:"Live voice\u2026",hint:"V",alias:"tts synthesize tone gemini",run:()=>_n("voices")},{label:"Character\u2026",hint:"V",alias:"avatar lipsync face talking head visemes",run:()=>_n("character")},{label:"Record this deck\u2026",hint:"V",alias:"record narrate microphone mic voice wav offline batch teleprompter",run:()=>_n("record")},{label:`Character solo ${At.solo?"off":"on"}`,alias:"centre center stage narrator only fullscreen avatar",run:()=>St.applySolo(!At.solo)},{label:"Voice faster",hint:">",alias:"speed rate playback",run:()=>Cn(.25)},{label:"Voice slower",hint:"<",alias:"speed rate playback",run:()=>Cn(-.25)},{label:"Speaker view",hint:"S",run:()=>{let K=oe.__speakerWin;K&&!K.closed?K.__decklightSpeakerToggle?.():oe.__speakerWin=ao(oe)}},{label:"Overview",hint:"O",run:We},{label:"Blackout",hint:"B",run:xe},{label:`Pen ${dn.annotator?.tool==="pen"?"off":"on"} \u2014 draw on the slide`,hint:"W",alias:"ink annotate draw scribble marker highlight",run:()=>fn("pen")},{label:`Laser pointer ${dn.annotator?.tool==="laser"?"off":"on"}`,hint:"\u21E7W",alias:"ink dot glow point at",run:()=>fn("laser")},{label:"Debug log",hint:"D",alias:"console events state",run:yt},{label:`Captions ${St.status().captionsOn?"off":"on"}`,hint:"C",alias:"cc subtitles closed caption",run:xn},{label:`Clock ${dn.status().clockOn?"off":"on"}`,alias:"time elapsed timer talk wall watch clock",run:Xt},{label:"Commit\u2026",hint:"K",alias:"git save commit message history",run:()=>Nt.commit.open()},{label:`Progress bar ${dn.status().progressOn?"off":"on"}`,hint:"J",alias:"bar bottom edge position how far through shape of the talk",run:wn},{label:"Transcript\u2026",alias:"notes script export text markdown spoken",run:ir},{label:"Edit speaker notes\u2026",alias:"edit mode notes write right-click background",run:ar},{label:`Element edit mode ${Nt.elementEditOn()?"off":"on"} (dev)`,hint:"E",alias:"right-click remove delete html content build animation entrance effect context menu",run:Kn},{label:"Fullscreen",hint:"F",run:()=>Me()},{label:"Print view (all slides, new tab)",hint:"",run:()=>window.open(location.pathname+"?print")},{label:"First slide",hint:"Home",run:()=>oe.goto(1,0)},{label:"Last slide",hint:"End",run:()=>oe.goto(oe.state.totalSlides,0)},{label:"Keyboard help",hint:"?",run:L},{label:"Welcome to Decklight",alias:"onboarding intro getting started first run tour what is this help me",run:_e.showWelcome},{label:`Tips ${_e.status().tipsOn?"off":"on"}`,alias:"hints teach shortcuts learn stop showing quiet",run:()=>_e.setTips(!_e.status().tipsOn)},_e.status().tipsLeft<Xr.length&&{label:"Reset tips",alias:"hints again start over show all unsee replay",run:_e.resetTips}].filter(Boolean).filter(K=>k(K.run))}function f(){let k=ye.querySelector(".narr-card");k.textContent="",v=qa({commands:ze(),query:Ze,totalSlides:oe.state.totalSlides,makeGotoRow:(K,me)=>({label:`Go to slide ${K} / ${me}`,hint:"\u23CE",run:()=>oe.goto(K,0)}),makeSearchRow:K=>({label:`Search slides for \u201C${K}\u201D`,hint:"",run:()=>{_t(),B(K)}})});let z=document.createElement("div");if(z.className="pal-input"+(Ze?" tp-active":""),z.textContent=Ze||"type a command\u2026",k.appendChild(z),v.forEach((K,me)=>{let et=document.createElement("div");et.className="narr-row pal-row";let Ht=document.createElement("span");if(Ht.textContent=K.label,et.appendChild(Ht),K.hint){let un=document.createElement("span");un.className="pal-kbd",un.textContent=K.hint,et.appendChild(un)}et.addEventListener("mouseenter",()=>Y(me)),et.addEventListener("click",()=>{Y(me),F()}),k.appendChild(et)}),!v.length){let K=document.createElement("div");K.className="tp-none",K.textContent="no matching command",k.appendChild(K)}Y(0)}function Y(k){v.length&&(ie=vn(ye.querySelectorAll(".pal-row"),k,"narr-sel"))}function F(){let k=v[ie];k&&(k.keepOpen||ce(),k.run())}function Ce(){if(ye)return ce();G&&W(),Nt.restore.close(),Ze="",ye=document.createElement("div"),ye.className="decklight-narr decklight-palette",ye.innerHTML='<div class="narr-card" role="listbox" aria-label="Commands"></div>',Ut(ye,ce),w.appendChild(ye),f()}function ce(){ye?.remove(),ye=null}let Ne=null,ee=0;function nt(){if(Ne)return ut();Ne=document.createElement("div"),Ne.className="decklight-narr decklight-font-picker",Ne.innerHTML='<div class="narr-card" role="listbox" aria-label="Fonts"></div>';let k=Ne.querySelector(".narr-card");ke.forEach(([z],K)=>{let me=document.createElement("div");me.className="narr-row"+(K===re?" narr-cur":""),me.textContent=z,K>0&&(me.style.fontFamily=ke[K][1]),me.addEventListener("mouseenter",()=>pt(K)),me.addEventListener("click",()=>{Ge(K),ut()}),k.appendChild(me)}),Ut(Ne,ut),w.appendChild(Ne),pt(re)}function pt(k){ee=vn(Ne.querySelectorAll(".narr-row"),k,"narr-sel")}function ut(){Ne?.remove(),Ne=null}Ae.restoreSaved();let ke=[["theme default",null],["system sans","-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif"],["rounded","ui-rounded, 'SF Pro Rounded', 'Hiragino Maru Gothic ProN', Quicksand, Comfortaa, 'Arial Rounded MT Bold', Calibri, sans-serif"],["humanist","Seravek, 'Gill Sans Nova', Ubuntu, Calibri, 'DejaVu Sans', source-sans-pro, sans-serif"],["geometric","'Avenir Next', Avenir, Montserrat, Corbel, 'URW Gothic', source-sans-pro, sans-serif"],["classical serif","'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif"],["transitional serif","Charter, 'Bitstream Charter', 'Sitka Text', Cambria, Georgia, serif"],["slab serif","Rockwell, 'Rockwell Nova', 'Roboto Slab', 'DejaVu Serif', 'Sitka Small', serif"],["monospace","'SF Mono', SFMono-Regular, ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace"]],Ee="decklight-font:"+location.pathname,re=0;function Ge(k,{silent:z=!1,remeasure:K=!0}={}){re=(k%ke.length+ke.length)%ke.length;let[me,et]=ke[re];if(et?(w.style.setProperty("--font-body",et),w.style.setProperty("--font-heading",et)):(w.style.removeProperty("--font-body"),w.style.removeProperty("--font-heading")),!o.has("embedded"))try{et?localStorage.setItem(Ee,String(re)):localStorage.removeItem(Ee)}catch{}K&&(Os(oe._sections,a),So(oe._sections[oe.state.slide-1],oe.state.slide)),z||je(`font: ${me}`),m("font",me)}function ht(k){Ge(re+k)}try{let k=parseInt(localStorage.getItem(Ee),10);k>0&&k<ke.length&&Ge(k,{silent:!0,remeasure:!1})}catch{}function tt(k){if(!k)return null;if(k.startsWith("#")){let K=document.querySelector(k);if(!K)return null;let me=K.cloneNode(!0);return me.removeAttribute("id"),me.style.removeProperty("display"),me}if(k.trim().startsWith("<")){let K=document.createElement("div");return K.innerHTML=k,K.firstElementChild}let z=document.createElement("img");return z.src=k,z.alt="",z}let He=null;Ae.updateCanvas();let gt=w.querySelector(":scope > .decklight-stage");if(!gt){for(gt=document.createElement("div"),gt.className="decklight-stage";w.firstChild;)gt.appendChild(w.firstChild);w.appendChild(gt)}if(gt.style.width=a.width+"px",gt.style.height=a.height+"px",a.logo&&(a.logo.src||a.logo.onLight||a.logo.onDark)){He=document.createElement("div"),He.className="decklight-logo",He.setAttribute("data-pos",a.logo.position||"bottom-left"),a.logo.height&&He.style.setProperty("--logo-h",a.logo.height+"px");for(let[k,z]of[["src","on-any"],["onLight","on-light"],["onDark","on-dark"]]){let K=tt(a.logo[k]);if(!K)continue;let me=document.createElement("span");me.className=z,me.appendChild(K),He.appendChild(me)}w.appendChild(He)}function Yt(k){He&&k.forEach(z=>{if(!z.hasAttribute("data-logo")||z.querySelector(":scope > .decklight-hero-logo"))return;let K=document.createElement("div");K.className="decklight-hero-logo";let me=parseFloat(z.getAttribute("data-logo"));me&&K.style.setProperty("--hero-logo-h",me+"px"),K.innerHTML=He.innerHTML,z.prepend(K)})}zd(gt),Zo(gt),oi(gt),Go(gt),Qi(gt,Qr);let nn=Da({slideOf:()=>oe.state.slide,sectionAt:k=>oe._sections[k-1],describe:k=>({autoPins:Ha(k,a)!==null,hasSplitPair:ja(k).length>1}),available:()=>Nt.available(),unavailableMessage:()=>Dn("layout",location),apply:(k,z)=>{z==="auto"?k.removeAttribute("data-layout"):k.setAttribute("data-layout",z)},relayout:(k,z)=>(Os(oe._sections,a),za(oe._sections),So(k,z),k.hasAttribute("data-split-conflict")),post:k=>fetch(Nt.base()+"/edit/layout",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(k)}).then(z=>{if(!z.ok)throw new Error(z.status)}),toast:je,debugLog:m}),It=k=>nn.cycle(k),Wt=k=>nn.ring(k),oe={root:w,stage:gt,config:a,_sections:[],_records:[],state:{slide:1,step:0,totalSlides:0},_listeners:new Map,_scale:1,on(k,z){return this._listeners.has(k)||this._listeners.set(k,new Set),this._listeners.get(k).add(z),this},off(k,z){return this._listeners.get(k)?.delete(z),this},_emit(k,z){(this._listeners.get(k)||[]).forEach(K=>K(z)),w.dispatchEvent(new CustomEvent("decklight:"+k,{detail:z}))},sync(){this._sections=[...gt.querySelectorAll(":scope > section")],this._sections.forEach((z,K)=>z.setAttribute("data-slide-index",String(K+1))),jo(gt,a.concepts),Yt(this._sections),xa(this._sections,{printMode:c}),Os(this._sections,a),za(this._sections),this._records=this._sections.map(z=>Xs(z)),this.state.totalSlides=this._sections.length,this.state.slide=Math.min(this.state.slide,this.state.totalSlides||1);let k=this._records[this.state.slide-1];k&&(this.state.step=Math.min(this.state.step,k.groups.length)),qt(c?this._sections:[this._sections[this.state.slide-1]])},_rescanFor(k){let z=k.closest("section"),K=this._sections.indexOf(z);if(K!==-1){if(this._records[K]=Xs(z),c){tr(this._records[K],this._records[K].groups.length);return}K===this.state.slide-1?(this.state.step=Math.min(this._requestedStep??this.state.step,this._records[K].groups.length),this._requestedStep=null,Bt(()=>tr(this._records[K],this.state.step)),this._updateHash(!1)):Bt(()=>tr(this._records[K],0)),this._notify()}},_stepLabels(k){let z=this._records[k];return z?Uo(z):[]},next(){let k=this._records[this.state.slide-1];k&&this.state.step<k.groups.length?this.goto(this.state.slide,this.state.step+1,{direction:"fwd"}):this.state.slide<this.state.totalSlides?this.goto(this.state.slide+1,0,{direction:"fwd"}):C(1)},prev(){if(this.state.step>0)this.goto(this.state.slide,this.state.step-1,{direction:"back"});else if(this.state.slide>1){let k=this._records[this.state.slide-2];this.goto(this.state.slide-1,k.groups.length,{direction:"back"})}else C(-1)},goto(k,z=0,K={}){k=Math.max(1,Math.min(k,this.state.totalSlides));let me=this._records[k-1];this._requestedStep=z,z=Math.max(0,Math.min(z,me?me.groups.length:0));let et=k===this.state.slide;if(et&&z===this.state.step&&!K.force)return;let Ht=K.direction||(k>this.state.slide||et&&z>this.state.step?"fwd":"back");!et||K.force?(this._activateSlide(k,Ht,K),this.state.slide=k,this.state.step=z,Bt(()=>tr(me,z)),this._emit("slide",{slide:k,total:this.state.totalSlides,direction:Ht}),qt([this._sections[k-1]])):(this.state.step=z,tr(me,z),this._emit("build",{slide:k,index:z,total:me.groups.length,direction:Ht})),this._updateChrome(),this._updateHash(!et),this._notify()},_activateSlide(k,z,K={}){let me=this._sections[this.state.slide-1],et=this._sections[k-1];if(w.classList.toggle("has-hero-logo",et?.hasAttribute("data-logo")??!1),me===et){et.classList.add("active");return}let Ht=!me||!me.classList.contains("active"),un=me&&et&&!Ht&&me.hasAttribute("data-auto-animate")&&et.hasAttribute("data-auto-animate")&&Math.abs(this._sections.indexOf(et)-this._sections.indexOf(me))===1;if(this._sections.forEach(en=>en.classList.remove("active","entering","leaving","dir-fwd","dir-back","tr-none","tr-fade","tr-slide","tr-scale","tr-flip")),et.classList.add("active"),Ht||c)return;if(un){me.classList.add("leaving"),me.style.visibility="hidden",et.style.visibility="hidden",et.offsetWidth,et.style.visibility="",ni(me,et,this._scale),me.classList.remove("leaving"),me.style.visibility="";return}let an=Qo(et.getAttribute("data-transition"),this.config.transition),Vt=ei(an,z);if(!Vt)return;et.classList.add(...Vt.entering),me.classList.add(...Vt.leaving);let qn=ys(getComputedStyle(et).getPropertyValue("--transition-duration"),350);setTimeout(()=>{me.classList.remove(...Vt.leaving),et.classList.remove(...Vt.entering)},qn+60)},_updateChrome(){if(Kt){let k=this._records[this.state.slide-1],z=k?k.groups.length:0,K=this.state.totalSlides<=1?1:(this.state.slide-1+(z?this.state.step/(z+1):0))/(this.state.totalSlides-1);Kt.style.width=(Math.min(K,1)*100).toFixed(2)+"%"}if(Rt){let k=this.config.slideNumber?this.config.slideNumber==="n/N"?`${this.state.slide} / ${this.state.totalSlides}`:String(this.state.slide):"";if(Rt.textContent=k,S.any){let z=S.title(),K=document.createElement("span");K.className="mod",K.textContent=z,Rt.prepend(K)}}},_updateHash(k){!this.config.hash||c||(mn=mn||!!k,!Lt&&(Lt=setTimeout(()=>{Lt=null,Dt()},gn)))},_notify(){this.__notifySpeaker&&this.__notifySpeaker()}};function pn(k,z){let K=document.createElement("a");K.href=k,K.download=z,document.body.appendChild(K),K.click(),K.remove()}function Bt(k){w.classList.add("decklight-no-anim"),k(),w.offsetWidth,w.classList.remove("decklight-no-anim")}function rn(k){return(k||"").replace(/^#/,"")}let gn=90,Lt=null,mn=!1;function Dt(k=!0){if(!oe||!a.hash||c)return;let z=`#/${oe.state.slide}/${oe.state.step}`,K=mn;if(mn=!1,"#"+rn(location.hash)!==z){bn=!0;try{K?history.pushState(null,"",z):history.replaceState(null,"",z)}catch{}setTimeout(()=>{bn=!1}),k&&"#"+rn(location.hash)!==z&&(mn=K,requestAnimationFrame(()=>Dt(!1)))}}function Ct(){let k=rn(location.hash).match(/^\/(\d+)(?:\/(\d+))?/);return k?{slide:parseInt(k[1],10),step:k[2]?parseInt(k[2],10):0}:null}let Kt=null,Rt=null;if(a.controls&&!c){let k=document.createElement("div");k.className="decklight-controls",k.innerHTML=`
313
336
  <button class="decklight-arrow prev" aria-label="Previous">\u2039</button>
314
- <button class="decklight-arrow next" aria-label="Next">\u203A</button>`,b.appendChild(v),v.querySelector(".prev").addEventListener("click",()=>Q.prev()),v.querySelector(".next").addEventListener("click",()=>Q.next())}let S={full:'<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5"/></svg>',unfull:'<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5"/></svg>',sound:'<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 5 6 9H3v6h3l5 4z"/><path d="M15.5 8.5a5 5 0 0 1 0 7"/><path d="M18.5 5.5a9 9 0 0 1 0 13"/></svg>',mute:'<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 5 6 9H3v6h3l5 4z"/><path d="M17 10l5 4M22 10l-5 4"/></svg>'},L=null,$=null;function Z(){let v=b||document.documentElement;document.fullscreenElement?document.exitFullscreen?.():v.requestFullscreen?.()?.catch?.(()=>{})}document.addEventListener("fullscreenchange",()=>{L&&(L.innerHTML=document.fullscreenElement?S.unfull:S.full)});function te(){if(!$)return;let v=Rt.status().narrating;$.innerHTML=v?S.sound:S.mute,$.setAttribute("aria-label",v?"Mute narration":"Play narration"),$.setAttribute("aria-pressed",String(v))}(l.slideNumber||P||T)&&!d&&($e=document.createElement("div"),$e.className="decklight-slide-number",(P||T)&&($e.title="G \u2014 find a slide or module",$e.style.cursor="pointer",$e.addEventListener("click",()=>mt())),b.appendChild($e));let fe=null,Qe=0;function Pe(){return getComputedStyle(fe).gridTemplateColumns.split(" ").length||1}function Ye(v){let H=fe.querySelectorAll(".ov-cell");Qe=Math.max(0,Math.min(v,H.length-1)),H.forEach((G,ve)=>G.classList.toggle("ov-selected",ve===Qe)),H[Qe]?.scrollIntoView({block:"nearest"})}function ut(){let v=Qe+1;pt(),Q.goto(v,0,{force:!0})}function dt(){if(!fe)return;let v=fe.querySelector(".ov-cell");if(!v)return;fe.style.gridAutoRows=Math.round(v.clientWidth*l.height/l.width)+"px";let H=v.clientWidth/l.width;fe.querySelectorAll(".ov-frame").forEach(G=>{G.style.transform=`scale(${H})`})}function pt(){if(fe){window.removeEventListener("resize",dt),fe.remove(),fe=null,b.classList.remove("decklight-overview");return}fe=document.createElement("div"),fe.className="decklight-overview-grid",Q._sections.forEach((v,H)=>{let G=document.createElement("div");G.className="ov-cell"+(H===Q.state.slide-1?" ov-current":"");let ve=document.createElement("div");ve.className="ov-frame",ve.style.width=l.width+"px",ve.style.height=l.height+"px";let Ue=v.cloneNode(!0);Ue.classList.add("active","ov-clone"),Ue.querySelectorAll("aside.notes, aside.rehearse").forEach(zt=>zt.remove()),Ue.querySelectorAll("input, button, select, textarea").forEach(zt=>{zt.removeAttribute("name"),zt.disabled=!0}),ve.appendChild(Ue),G.appendChild(ve);let Ct=document.createElement("span");Ct.className="ov-num",Ct.textContent=String(H+1),G.appendChild(Ct),G.addEventListener("click",()=>{pt(),Q.goto(H+1,0,{force:!0})}),fe.appendChild(G)}),b.classList.add("decklight-overview"),b.appendChild(fe),dt(),Ye(Q.state.slide-1),window.addEventListener("resize",dt)}let xt=null;function ht(){if(xt){xt.remove(),xt=null;return}xt=document.createElement("div"),xt.className="decklight-blackout",b.appendChild(xt)}let yt=null;function qt(){let v=Q._records?.[Q.state.slide-1],H=Rt.status(),G=H.live?`\u26A1 ${H.voice} \xB7 ${H.tone}`:H.track?`\u{1F50A} ${H.track.label}`:"none";return`slide ${Q.state.slide}/${Q.state.totalSlides} \xB7 step ${Q.state.step}/${v?v.groups.length:0} \xB7 theme ${at()??"\u2014"} \xB7 narration ${H.narrating?H.paused?"paused":"on":"off"} (${G})`+(H.rate!==1?` \xB7 ${H.rate}\xD7`:"")+(H.spend>0?` \xB7 tts ~$${H.spend.toFixed(4)}`:"")}function Ft(v){let H=document.createElement("div");H.className="dbg-row dbg-"+v.kind;for(let[G,ve]of[["dbg-t",v.t],["dbg-k",v.kind],["dbg-m",v.msg]]){let Ue=document.createElement("span");Ue.className=G,Ue.textContent=ve,H.appendChild(Ue)}f.querySelector(".dbg-log").appendChild(H)}function Pt(){let v=f?.querySelector(".dbg-state");v&&(v.textContent=qt())}function an(){if(f){f.remove(),f=null,m.onEntry(null);return}f=document.createElement("div"),f.className="decklight-debug",f.innerHTML='<div class="dbg-head">debug log \u2014 D closes</div><div class="dbg-state"></div><div class="dbg-log"></div>',b.appendChild(f),m.entries.forEach(Ft),Pt();let v=f.querySelector(".dbg-log");v.scrollTop=v.scrollHeight,m.onEntry(H=>{Ft(H),Pt();let G=f.querySelector(".dbg-log");G.scrollTop=G.scrollHeight})}function ln(){let v=de?.querySelector(".msg-log");if(v){if(v.innerHTML="",!be.length){let H=document.createElement("div");H.className="msg-empty",H.textContent="no messages yet",v.appendChild(H);return}be.forEach(({at:H,text:G})=>{let ve=document.createElement("div");ve.className="msg-row";let Ue=document.createElement("span");Ue.className="msg-time",Ue.textContent=H.toLocaleTimeString([],{hour12:!1});let Ct=document.createElement("span");Ct.className="msg-text",Ct.textContent=G,ve.append(Ue,Ct),v.appendChild(ve)}),v.scrollTop=v.scrollHeight}}function tn(){if(de){de.remove(),de=null;return}de=document.createElement("div"),de.className="decklight-msglog",de.innerHTML='<div class="msg-head">messages \u2014 the key left of 1 closes</div><div class="msg-log"></div>',b.appendChild(de),ln()}Q.on("ready",v=>h("ready",`${v.slides} slides${v.print?" \xB7 print":""}`)),Q.on("slide",v=>{h("slide",`\u2192 ${v.slide}/${v.total} (${v.direction})`),Pt()}),Q.on("build",v=>{h("build",`slide ${v.slide} step ${v.index}/${v.total} (${v.direction})`),Pt()}),window.addEventListener("error",v=>h("error",String(v.message)));function I(){if(yt){yt.remove(),yt=null;return}yt=document.createElement("div"),yt.className="decklight-help",yt.innerHTML=`<div class="help-card"><h3>Keyboard</h3><table>
315
- <tr><td>\u2192 / Space</td><td>next build / slide</td></tr>
316
- <tr><td>\u2190</td><td>previous</td></tr>
337
+ <button class="decklight-arrow next" aria-label="Next">\u203A</button>`,w.appendChild(k),k.querySelector(".prev").addEventListener("click",()=>oe.prev()),k.querySelector(".next").addEventListener("click",()=>oe.next())}let N={full:'<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5"/></svg>',unfull:'<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5"/></svg>',sound:'<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 5 6 9H3v6h3l5 4z"/><path d="M15.5 8.5a5 5 0 0 1 0 7"/><path d="M18.5 5.5a9 9 0 0 1 0 13"/></svg>',mute:'<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 5 6 9H3v6h3l5 4z"/><path d="M17 10l5 4M22 10l-5 4"/></svg>'},X=null,pe=null;function Me(){let k=w||document.documentElement;document.fullscreenElement?document.exitFullscreen?.():k.requestFullscreen?.()?.catch?.(()=>{})}document.addEventListener("fullscreenchange",()=>{X&&(X.innerHTML=document.fullscreenElement?N.unfull:N.full)});function Le(){if(!pe)return;let k=St.status().narrating;pe.innerHTML=k?N.sound:N.mute,pe.setAttribute("aria-label",k?"Mute narration":"Play narration"),pe.setAttribute("aria-pressed",String(k))}(a.slideNumber||P||_)&&!c&&(Rt=document.createElement("div"),Rt.className="decklight-slide-number",(P||_)&&(Rt.title="G \u2014 find a slide or module",Rt.style.cursor="pointer",Rt.addEventListener("click",()=>_t())),w.appendChild(Rt));let qe=null,M=0;function j(){return getComputedStyle(qe).gridTemplateColumns.split(" ").length||1}function H(k){let z=qe.querySelectorAll(".ov-cell");M=Math.max(0,Math.min(k,z.length-1)),z.forEach((K,me)=>K.classList.toggle("ov-selected",me===M)),z[M]?.scrollIntoView({block:"nearest"})}function we(){let k=M+1;We(),oe.goto(k,0,{force:!0})}function Ye(){if(!qe)return;let k=qe.querySelector(".ov-cell");if(!k)return;qe.style.gridAutoRows=Math.round(k.clientWidth*a.height/a.width)+"px";let z=k.clientWidth/a.width;qe.querySelectorAll(".ov-frame").forEach(K=>{K.style.transform=`scale(${z})`})}function We(){if(qe){window.removeEventListener("resize",Ye),qe.remove(),qe=null,w.classList.remove("decklight-overview");return}qe=document.createElement("div"),qe.className="decklight-overview-grid",oe._sections.forEach((k,z)=>{let K=document.createElement("div");K.className="ov-cell"+(z===oe.state.slide-1?" ov-current":"");let me=document.createElement("div");me.className="ov-frame",me.style.width=a.width+"px",me.style.height=a.height+"px";let et=k.cloneNode(!0);et.classList.add("active","ov-clone"),et.querySelectorAll("aside.notes, aside.rehearse").forEach(un=>un.remove()),et.querySelectorAll("input, button, select, textarea").forEach(un=>{un.removeAttribute("name"),un.disabled=!0}),me.appendChild(et),K.appendChild(me);let Ht=document.createElement("span");Ht.className="ov-num",Ht.textContent=String(z+1),K.appendChild(Ht),K.addEventListener("click",()=>{We(),oe.goto(z+1,0,{force:!0})}),qe.appendChild(K)}),w.classList.add("decklight-overview"),w.appendChild(qe),Ye(),H(oe.state.slide-1),window.addEventListener("resize",Ye)}let Ve=null;function xe(){if(Ve){Ve.remove(),Ve=null;return}Ve=document.createElement("div"),Ve.className="decklight-blackout",w.appendChild(Ve)}let Oe=null;function ot(){let k=oe._records?.[oe.state.slide-1],z=St.status(),K=z.live?`\u26A1 ${z.voice} \xB7 ${z.tone}`:z.track?`\u{1F50A} ${z.track.label}`:"none";return`slide ${oe.state.slide}/${oe.state.totalSlides} \xB7 step ${oe.state.step}/${k?k.groups.length:0} \xB7 theme ${bt()??"\u2014"} \xB7 narration ${z.narrating?z.paused?"paused":"on":"off"} (${K})`+(z.rate!==1?` \xB7 ${z.rate}\xD7`:"")+(z.spend>0?` \xB7 tts ~$${z.spend.toFixed(4)}`:"")}function Et(k){let z=document.createElement("div");z.className="dbg-row dbg-"+k.kind;for(let[K,me]of[["dbg-t",k.t],["dbg-k",k.kind],["dbg-m",k.msg]]){let et=document.createElement("span");et.className=K,et.textContent=me,z.appendChild(et)}g.querySelector(".dbg-log").appendChild(z)}function Tt(){let k=g?.querySelector(".dbg-state");k&&(k.textContent=ot())}function yt(){if(g){g.remove(),g=null,p.onEntry(null);return}g=document.createElement("div"),g.className="decklight-debug",g.innerHTML='<div class="dbg-head">debug log \u2014 D closes</div><div class="dbg-state"></div><div class="dbg-log"></div>',w.appendChild(g),p.entries.forEach(Et),Tt();let k=g.querySelector(".dbg-log");k.scrollTop=k.scrollHeight,p.onEntry(z=>{Et(z),Tt();let K=g.querySelector(".dbg-log");K.scrollTop=K.scrollHeight})}function Qe(){let k=ae?.querySelector(".msg-log");if(k){if(k.innerHTML="",!$e.length){let z=document.createElement("div");z.className="msg-empty",z.textContent="no messages yet",k.appendChild(z);return}$e.forEach(({at:z,text:K})=>{let me=document.createElement("div");me.className="msg-row";let et=document.createElement("span");et.className="msg-time",et.textContent=z.toLocaleTimeString([],{hour12:!1});let Ht=document.createElement("span");Ht.className="msg-text",Ht.textContent=K,me.append(et,Ht),k.appendChild(me)}),k.scrollTop=k.scrollHeight}}function wt(){if(ae){ae.remove(),ae=null;return}ae=document.createElement("div"),ae.className="decklight-msglog",ae.innerHTML='<div class="msg-head">messages \u2014 the key left of 1 closes</div><div class="msg-log"></div>',w.appendChild(ae),Qe()}oe.on("ready",k=>m("ready",`${k.slides} slides${k.print?" \xB7 print":""}`)),oe.on("slide",k=>{m("slide",`\u2192 ${k.slide}/${k.total} (${k.direction})`),Tt()}),oe.on("build",k=>{m("build",`slide ${k.slide} step ${k.index}/${k.total} (${k.direction})`),Tt()}),window.addEventListener("error",k=>m("error",String(k.message)));function L(){if(Oe){Oe.remove(),Oe=null;return}Oe=document.createElement("div"),Oe.className="decklight-help",Oe.innerHTML=`<div class="help-card"><h3>Keyboard</h3><table>
338
+ <tr><td>\u2192 / PageDown</td><td>next build / slide</td></tr>
339
+ <tr><td>\u23B5</td><td>pause / resume the voice while it is speaking \u2014 otherwise it advances</td></tr>
340
+ <tr><td>\u2190 / PageUp</td><td>previous</td></tr>
317
341
  <tr><td>Home / End</td><td>first / last slide</td></tr>
318
342
  <tr><td>O</td><td>overview</td></tr>
319
343
  <tr><td>S</td><td>speaker view (again: rehearse mode)</td></tr>
320
- <tr><td>V</td><td>narration on/off</td></tr>
321
- <tr><td>N</td><td>narration track</td></tr>
322
- <tr><td>\u21E7V</td><td>record offline narration (live voice)</td></tr>
344
+ <tr><td>V</td><td>narration \u2014 track, voice, character, recording, captions, speed</td></tr>
323
345
  <tr><td>&lt; / &gt;</td><td>voice speed (0.25\xD7 steps)</td></tr>
324
346
  <tr><td>B</td><td>blackout</td></tr>
325
347
  <tr><td>D</td><td>debug log</td></tr>
@@ -327,13 +349,15 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Ae=O,re=D),V===void 0&
327
349
  <tr><td>C</td><td>captions (follow the voice)</td></tr>
328
350
  <tr><td>W</td><td>pen \u2014 draw on the slide (\u232B clears)</td></tr>
329
351
  <tr><td>\u21E7W</td><td>laser pointer</td></tr>
330
- <tr><td>K</td><td>clock \u2014 wall time + elapsed talk</td></tr>
352
+ <tr><td>K</td><td>commit \u2014 what changed, and what to call it (\u2318K / \u2303K also works while typing)</td></tr>
331
353
  <tr><td>J</td><td>progress bar \u2014 position in the deck, bottom edge</td></tr>
332
- <tr><td>H</td><td>history \u2014 commits, slides and diff per version, \u23CE restores one (author mode; R too)</td></tr>
333
- <tr><td>P</td><td>pause / resume narration</td></tr>
354
+ <tr><td>H / R</td><td>history \u2014 commits, slides and diff per version, \u23CE restores one (author mode)</td></tr>
355
+ <tr><td>M</td><td>comments \u2014 yours and every review's, grouped by who said them, \u23CE jumps</td></tr>
356
+ <tr><td>\u21E7M</td><td>leave a comment on the slide you are looking at</td></tr>
357
+ <tr><td>P</td><td>narration play / pause \u2014 \u23B5's alias</td></tr>
334
358
  <tr><td>F</td><td>fullscreen</td></tr>
335
359
  <tr><td>T</td><td>theme picker (type to filter)</td></tr>
336
- <tr><td>/</td><td>command palette (find, themes, everything)</td></tr>
360
+ <tr><td>/</td><td>command palette \u2014 find, themes, everything (\u201CWelcome to Decklight\u201D reopens the intro)</td></tr>
337
361
  <tr><td>G</td><td>slide finder (live preview)</td></tr>
338
362
  <tr><td>E</td><td>element edit mode \u2014 right-click a slide element (author mode)</td></tr>
339
363
  <tr><td>, / .</td><td>cycle theme</td></tr>
@@ -343,17 +367,16 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Ae=O,re=D),V===void 0&
343
367
  <tr><td>A</td><td>ask an AI agent to edit the deck (author mode)</td></tr>
344
368
  <tr><td>\u2303T</td><td>generate a theme (repeat to re-roll)</td></tr>
345
369
  <tr><td>\u2303\u21E7T</td><td>save the generated theme</td></tr>
346
- <tr><td>?</td><td>this help</td></tr>
347
- <tr><td>/</td><td>command palette \u2014 \u201CWelcome to Decklight\u201D reopens the intro</td></tr></table></div>`,yt.addEventListener("click",I),b.appendChild(yt)}k.register({isOpen:()=>!!_e,close:Ee,keydown:v=>Er(v,{query:Re,onMove:H=>pe(Y+H),onCommit:Se,onType:H=>{Re+=H,w()},onBackspace:()=>{Re=Re.slice(0,-1),w()},onClear:()=>{Re="",w()},onClose:Ee})}),k.register({isOpen:()=>!!ze,close:Et,keydown:v=>Er(v,{onMove:H=>gt(oe+H),onCommit:()=>{et(oe),Et()},onClose:Et})}),k.register({isOpen:()=>!!O,close:K,keydown:v=>Er(v,{query:V,onMove:H=>Fe(D+H,!1),onCommit:ot,onType:H=>B(V+H),onBackspace:()=>B(V.slice(0,-1)),onClear:()=>B(""),onClose:K})}),k.register({isOpen:()=>!!fe,close:pt,keydown(v){switch(v.key){case"ArrowRight":Ye(Qe+1);break;case"ArrowLeft":Ye(Qe-1);break;case"ArrowDown":Ye(Qe+Pe());break;case"ArrowUp":Ye(Qe-Pe());break;case"Enter":case" ":ut();break;case"o":case"O":case"Escape":pt();break;default:return!1}return!0}});let Tn=v=>v.code==="Backquote"||v.key==="`"||v.key==="~"||v.key==="\xB2";function nn(v){if(Tn(v)&&(v.metaKey||v.ctrlKey||v.altKey)){tn(),v.preventDefault();return}if(/^(input|textarea|select)$/i.test(v.target.tagName))return;if(v.ctrlKey&&!v.metaKey&&!v.altKey&&(v.key==="T"||v.key==="t")){v.shiftKey?je():Le.rollFromPicker()||Je(),v.preventDefault();return}if(v.metaKey||v.ctrlKey||v.altKey)return;let H=k.active();if(H){H.keydown(v)&&v.preventDefault();return}if(Tn(v)){tn(),v.preventDefault();return}switch(v.key){case"ArrowRight":case" ":case"PageDown":Q.next();break;case"ArrowLeft":case"PageUp":Q.prev();break;case"Home":Q.goto(1,0);break;case"End":Q.goto(Q.state.totalSlides,0);break;case"o":case"O":pt();break;case"b":case"B":ht();break;case"d":case"D":an();break;case"c":case"C":$n();break;case"k":case"K":Gt();break;case"j":case"J":jt();break;case"h":case"H":Tt.history.open();break;case"p":case"P":gn();break;case"g":case"G":mt();break;case"r":case"R":Tt.history.open();break;case"e":case"E":yn();break;case"f":case"F":Z();break;case"v":case"V":v.shiftKey?St():rn();break;case"n":case"N":sn();break;case"s":case"S":{let G=Q.__speakerWin;G&&!G.closed?G.__decklightSpeakerToggle?.():Q.__speakerWin=ts(Q);break}case"t":case"T":Le.openPicker();break;case"/":it();break;case".":_(1);break;case",":_(-1);break;case">":Yt(.25);break;case"<":Yt(-.25);break;case"]":tt(1);break;case"[":tt(-1);break;case"l":case"L":Vt(v.shiftKey?-1:1);break;case"z":case"Z":un(v.shiftKey?"redo":"undo");break;case"a":case"A":On();break;case"w":case"W":dn(v.shiftKey?"laser":"pen");break;case"Backspace":if(!Mt.annotator?.active)return;Mt.annotator.clear();break;case"?":I();break;case"Escape":if(qe())break;fe&&pt();break;default:return}v.preventDefault()}d||document.addEventListener("keydown",nn);let Xt=null;b.addEventListener("touchstart",v=>{Xt=v.touches[0].clientX},{passive:!0}),b.addEventListener("touchend",v=>{if(Xt==null)return;let H=v.changedTouches[0].clientX-Xt;Math.abs(H)>40&&(H<0?Q.next():Q.prev()),Xt=null},{passive:!0});function hn(){let v=b.getBoundingClientRect(),H=Math.min(v.width/l.width,v.height/l.height)||1;Q._scale=H,ft.style.transform=`translate(-50%, -50%) scale(${H})`}d||(new ResizeObserver(hn).observe(b),hn());let Cn=Bi({sectionsOf:()=>Q._sections,checkOverflow:ds}),Qt=v=>Cn.watch(v),cn=!1;if(l.hash&&!d&&window.addEventListener("hashchange",()=>{if(cn)return;let v=U();v&&Q.goto(v.slide,v.step,{force:!0})}),!d){let v=()=>{Q._sections.forEach((H,G)=>{let ve=H.querySelector(":scope > .slide-bg > video");ve&&(G===Q.state.slide-1?ve.play()?.catch?.(()=>{}):ve.paused||ve.pause())})};Q.on("slide",v)}Q.sync(),d&&He&&(Q._sections.forEach(v=>{v.hasAttribute("data-logo")||v.appendChild(He.cloneNode(!0))}),He.remove()),document.fonts?.ready?.then(()=>{(Xn===Q||!Xn)&&Nr(Q._sections,l)}),Q.theme=v=>st(v),Q.themePicker={open:Le.openPicker,close:Le.closePicker},Q.generateTheme=Je,Q.cycleFont=tt,Q.cycleLayout=Vt,Q.layoutRing=Ot,Q.toggleMessages=tn,Q.messages=Oe,Q.showWelcome=xe.showWelcome,Q.tips={show:xe.showTip,reset:xe.resetTips,set:xe.setTips,status:xe.status};let Rt=Ei({root:b,stage:ft,config:l,params:i,printMode:d,toast:De,logOnly:ke,debugLog:h,overlays:k,instance:Q,syncSoundBtn:te,updateDebugState:Pt,downloadFromUrl:Zt,authorBase:()=>Tt?.available()?Tt.base():null}),{character:Nn,toggleNarration:rn,toggleNarrPause:gn,changeNarrRate:Yt,toggleCaptions:$n,openRecordDialog:St,notesSegs:Bn}=Rt,sn=Rt.openPicker;Q.toggleNarration=rn;let Mt=_i({root:b,printMode:d,toast:De,debugLog:h,overlays:k,instance:Q,narration:Rt,downloadFromUrl:Zt,setProgressBar:v=>{se=v}}),{toggleClock:Gt,toggleProgress:jt,toggleInk:dn,toggleTranscript:kt}=Mt;Q.toggleClock=Gt,Q.toggleProgress=jt;let Tt=Mi({root:b,config:l,params:i,printMode:d,toast:De,debugLog:h,overlays:k,instance:Q,notesSegs:Bn,dismissOthers:()=>{Le.closePicker(),O&&K(),_e&&Ee()}}),{deckHistory:un,toggleEditor:bn,toggleAgentAsk:On,toggleElementEdit:yn}=Tt;if(Q.restore=Tt.restore,Q.wizard=Tt.wizard,Q.toggleElementEdit=yn,i.has("voiceover")&&Rt.status().track&&!d){let v=()=>{window.removeEventListener("pointerdown",v),window.removeEventListener("keydown",v),Rt.status().narrating||rn()};window.addEventListener("pointerdown",v,{once:!0}),window.addEventListener("keydown",v,{once:!0})}if(!d){let v=document.createElement("div");v.className="decklight-touch-controls",L=document.createElement("button"),L.type="button",L.className="decklight-touch-btn",L.setAttribute("aria-label","Fullscreen"),L.innerHTML=S.full,L.addEventListener("click",Z),v.appendChild(L),Rt.status().hasTracks&&($=document.createElement("button"),$.type="button",$.className="decklight-touch-btn",$.addEventListener("pointerdown",H=>H.stopPropagation()),$.addEventListener("click",()=>rn()),v.appendChild($),te()),b.appendChild(v)}if(Q.saveGeneratedTheme=v=>je(v),d)return b.classList.add("decklight-print"),Q._sections.forEach((v,H)=>{v.classList.add("active"),En(Q._records[H],Q._records[H].groups.length)}),(u==="handout"||u==="notes")&&(b.classList.add("decklight-print-"+u),Si(ft,Q._sections,u)),Qt(Q._sections),b.__decklight=Q,Xn=Q,Q._emit("ready",{slides:Q.state.totalSlides,print:!0}),Q;let wn=l.hash&&U()||{slide:1,step:0};return Q._sections.forEach((v,H)=>{H!==wn.slide-1&&En(Q._records[H],0)}),Q.goto(wn.slide,wn.step,{force:!0}),b.__decklight=Q,Xn=Q,Q._emit("ready",{slides:Q.state.totalSlides}),xe.start(wn),Q}le();ce();le();ce();var us="\x1B",Or=Object.freeze({fg:null,bg:null,bold:!1,dim:!1,italic:!1,underline:!1,inverse:!1});function Ed(r){if(r<16)return null;if(r>=16&&r<=231){let l=r-16,d=[0,95,135,175,215,255];return[d[Math.floor(l/36)%6],d[Math.floor(l/6)%6],d[l%6]]}let i=8+(r-232)*10;return[i,i,i]}var Yn=class{constructor(){this.rows=[[]],this.row=0,this.col=0,this.style={...Or},this._pending=""}write(i){let l=this._pending+i;this._pending="";let d=0;for(;d<l.length;){let u=l[d];if(u===us){let m=this._consumeEscape(l,d);if(m===0){this._pending=l.slice(d);return}d+=m;continue}if(d+=1,u===`
348
- `){this._lineFeed();continue}if(u==="\r"){this.col=0;continue}if(u==="\b"){this.col=Math.max(0,this.col-1);continue}if(u===" "){this.col=(Math.floor(this.col/8)+1)*8;continue}u!=="\x07"&&(u<" "&&u!==" "||this._putChar(u))}}_lineFeed(){this.row+=1,this.rows[this.row]||(this.rows[this.row]=[])}_putChar(i){let l=this.rows[this.row];for(;l.length<this.col;)l.push({ch:" ",style:Or});l[this.col]={ch:i,style:{...this.style}},this.col+=1}_consumeEscape(i,l){if(l+1>=i.length)return 0;let d=i[l+1];if(d==="["){let u=l+2;for(;u<i.length;){let m=i.charCodeAt(u);if(m>=64&&m<=126)return this._handleCsi(i.slice(l+2,u),i[u]),u-l+1;u+=1}return 0}if(d==="]"){let u=l+2;for(;u<i.length;){if(i[u]==="\x07")return u-l+1;if(i[u]===us&&i[u+1]==="\\")return u-l+2;if(i[u]===us&&u+1>=i.length)return 0;u+=1}return 0}return d==="("||d===")"?l+2<i.length?3:0:2}_handleCsi(i,l){if(!i.startsWith("?"))switch(l){case"m":this._sgr(i);return;case"K":this._eraseLine(i);return;case"C":this.col+=Math.max(1,parseInt(i||"1",10)||1);return;case"D":this.col=Math.max(0,this.col-Math.max(1,parseInt(i||"1",10)||1));return;default:return}}_eraseLine(i){let l=parseInt(i||"0",10)||0,d=this.rows[this.row];if(l===0){d.length=Math.min(d.length,this.col);return}if(l===1){for(let u=0;u<=Math.min(this.col,d.length-1);u++)d[u]={ch:" ",style:Or};return}if(l===2){d.length=0;return}}_sgr(i){let l=i===""?[0]:i.split(";").map(u=>parseInt(u,10)||0),d=0;for(;d<l.length;){let u=l[d];if(u===0)this.style={...Or};else if(u===1)this.style.bold=!0;else if(u===2)this.style.dim=!0;else if(u===3)this.style.italic=!0;else if(u===4)this.style.underline=!0;else if(u===7)this.style.inverse=!0;else if(u===22)this.style.bold=!1,this.style.dim=!1;else if(u===23)this.style.italic=!1;else if(u===24)this.style.underline=!1;else if(u===27)this.style.inverse=!1;else if(u>=30&&u<=37)this.style.fg={type:"ansi",idx:u-30};else if(u>=90&&u<=97)this.style.fg={type:"ansi",idx:u-90+8};else if(u===39)this.style.fg=null;else if(u>=40&&u<=47)this.style.bg={type:"ansi",idx:u-40};else if(u>=100&&u<=107)this.style.bg={type:"ansi",idx:u-100+8};else if(u===49)this.style.bg=null;else if(u===38||u===48){let m=u===38?"fg":"bg";l[d+1]===5&&l.length>d+2?(this.style[m]={type:"256",idx:l[d+2]},d+=2):l[d+1]===2&&l.length>d+4&&(this.style[m]={type:"rgb",r:l[d+2],g:l[d+3],b:l[d+4]},d+=4)}d+=1}}get lines(){return this.rows.map(i=>{let l=[];for(let d of i){let u=l[l.length-1];u&&Sd(u.style,d.style)?u.text+=d.ch:l.push({text:d.ch,style:d.style})}return l})}toHtml(){return this.lines.map(i=>_d(i)).join(`
349
- `)}};function Sd(r,i){return r.bold===i.bold&&r.dim===i.dim&&r.italic===i.italic&&r.underline===i.underline&&r.inverse===i.inverse&&Zi(r.fg,i.fg)&&Zi(r.bg,i.bg)}function Zi(r,i){return r===i?!0:!r||!i?!1:r.type===i.type&&r.idx===i.idx&&r.r===i.r&&r.g===i.g&&r.b===i.b}function Ad(r){if(r.type==="256"){if(r.idx<16)return null;let[i,l,d]=Ed(r.idx);return`rgb(${i},${l},${d})`}return r.type==="rgb"?`rgb(${r.r},${r.g},${r.b})`:null}function _d(r){return r.map(({text:i,style:l})=>{let d=[],u=[],{fg:m,bg:f}=l;l.inverse&&([m,f]=[f??{type:"inv-default-bg"},m??{type:"inv-default-fg"}]);for(let[A,P]of[[m,"fg"],[f,"bg"]])if(A)if(A.type==="ansi"||A.type==="256"&&A.idx<16)d.push(`ansi-${P}-${A.idx}`);else if(A.type==="inv-default-bg")d.push("ansi-inv-fg");else if(A.type==="inv-default-fg")d.push("ansi-inv-bg");else{let M=Ad(A);M&&u.push(`${P==="fg"?"color":"background-color"}:${M}`)}l.bold&&d.push("ansi-bold"),l.dim&&d.push("ansi-dim"),l.italic&&d.push("ansi-italic"),l.underline&&d.push("ansi-underline");let h=$t(i);if(!d.length&&!u.length)return h;let b=d.length?` class="${d.join(" ")}"`:"",k=u.length?` style="${u.join(";")}"`:"";return`<span${b}${k}>${h}</span>`}).join("")}var Xi=24,Td=r=>Math.max(1,Math.min(10,r)),Cd=r=>2**((r-5)/2.5),Yi=55,ar=[120,160],Ji="decklight-term-wpm:"+location.pathname,Nd=r=>ar.reduce((i,l)=>Math.abs(l-r)<Math.abs(i-r)?l:i),or=["thocky","creamy","clacky","off"],Qi="decklight-term-typesound:"+location.pathname,ea="decklight-term-fontsize:"+location.pathname,ir=[.75,.9,1,1.15,1.35,1.6],ta={thocky:{click:.17,clickF:[680,1250],clickQ:.9,lp:1800,clickDecay:[.012,.017],thump:.008,thumpF:[130,185],thumpF2:[58,85],thumpF2Prob:.22,ring:[.005,.009]},creamy:{click:.3,clickF:[1400,2850],clickQ:.95,lp:3800,clickDecay:[.007,.011],thump:.0056,thumpF:[60,110],ring:[.065,.095]},clacky:{click:.34,clickF:[2300,3900],clickQ:1.1,lp:6800,clickDecay:[.005,.008],thump:.003,thumpF:[90,140],ring:[.035,.055]}};function ps(r){let i=90+Math.random()*120;return Math.random()<.15&&(i+=Math.random()*240),r===" "?i+=70+Math.random()*220:".,:;/|&>-_=\"'`()".includes(r)&&(i+=40+Math.random()*140),Math.random()<.035&&(i+=300+Math.random()*440),i}var $d=.012,Bt=null,Mr=null,Rr=new Set,na=r=>{Rr.add(r),r.addEventListener("ended",()=>Rr.delete(r),{once:!0})};function Od(){if(!Bt)return;let r=Bt.currentTime;for(let i of Rr)try{i.stop(r)}catch{}Rr.clear()}function Lr(r="",i="thocky",l=.12){try{let d=window.AudioContext||window.webkitAudioContext;if(!d)return;if(Bt??=new d,Bt.state==="suspended"&&Bt.resume(),!Mr){let F=Math.floor(Bt.sampleRate*.06);Mr=Bt.createBuffer(1,F,Bt.sampleRate);let ye=Mr.getChannelData(0);for(let ge=0;ge<F;ge++)ye[ge]=Math.random()*2-1}let u=ta[i]??ta.thocky,m=(F,ye)=>F+Math.random()*(ye-F),f=Bt.currentTime+$d,h=r===" ",b=m(.45,1.3)*(h?1.25:1),k=m(...u.clickF)*(h?.7:1),A=m(...u.ring)*(h?1.5:1),P=(F,ye,ge,be)=>{let J=Bt.createBufferSource();J.buffer=Mr;let de=Bt.createBiquadFilter();de.type="bandpass",de.frequency.value=ge,de.Q.value=u.clickQ;let Oe=Bt.createBiquadFilter();Oe.type="lowpass",Oe.frequency.value=u.lp;let ke=Bt.createGain();ke.gain.setValueAtTime(1e-4,F),ke.gain.exponentialRampToValueAtTime(ye,F+7e-4),ke.gain.exponentialRampToValueAtTime(1e-4,F+be),J.connect(de),de.connect(Oe),Oe.connect(ke),ke.connect(Bt.destination),J.start(F),J.stop(F+be+.01),na(J)},M=(F,ye,ge,be)=>{let J=Bt.createOscillator();J.type="sine",J.frequency.setValueAtTime(ge,F),J.frequency.exponentialRampToValueAtTime(ge*.6,F+be*.6);let de=Bt.createGain();de.gain.setValueAtTime(1e-4,F),de.gain.exponentialRampToValueAtTime(ye,F+m(.003,.011)),de.gain.exponentialRampToValueAtTime(ye*.25,F+be),de.gain.exponentialRampToValueAtTime(1e-4,F+be*2),J.connect(de),de.connect(Bt.destination),J.start(F),J.stop(F+be*2+.01),na(J)},T=u.thumpF2&&Math.random()<(u.thumpF2Prob??.4)?u.thumpF2:u.thumpF;P(f,u.click*b*(h?.82:1),k,m(...u.clickDecay)*(h?1.2:1)),M(f,u.thump*b*(h?2.4:1),m(...T)*(h?.7:1),A);let C=f+Math.max(.01,Math.min(m(.035,.08),l*.55));P(C,u.click*b*m(.35,.55),k*1.15,m(...u.clickDecay)*.8),M(C,u.thump*b*(h?.5:.25),m(...T)*(h?.7:1),A*.6)}catch{}}function Md(){try{let r=window.AudioContext||window.webkitAudioContext;if(!r)return;Bt??=new r,Bt.state==="suspended"&&Bt.resume()}catch{}}var ra=!1;function Ld(){if(ra||typeof document>"u")return;ra=!0;let r=()=>{Md(),document.removeEventListener("pointerdown",r,!0),document.removeEventListener("keydown",r,!0)};document.addEventListener("pointerdown",r,!0),document.addEventListener("keydown",r,!0)}function ms(r,i=document){let l=[...i.querySelectorAll(".terminal[data-cast], .terminal[data-cast-inline]")];return l.length&&Ld(),Promise.all(l.map(d=>Rd(d,r).catch(u=>{Dd(d,u)})))}async function Rd(r,i){if(r.dataset.decklightTerminal)return;r.dataset.decklightTerminal="1";let l,d,u=r.dataset.castInline;if(u){d=u;let b=document.querySelector(u);if(!b&&document.readyState==="loading"&&(await new Promise(k=>document.addEventListener("DOMContentLoaded",k,{once:!0})),b=document.querySelector(u)),!b)throw new Error(`inline cast not found: ${u}`);l=b.textContent}else{d=r.dataset.cast;let b=await fetch(d);if(!b.ok)throw new Error(`failed to load cast: ${d} (${b.status})`);l=await b.text()}let m=Id(l,d),f=new hs(r,m);r._decklightTerminal=f;let h=r.dataset.mode||"step";m.imported&&h==="step"&&!m.hasMarkers&&(h="play"),h==="play"?f.mountPlayMode():f.mountStepMode(i)}function Id(r,i){let l=null;try{l=JSON.parse(r)}catch{}if(l){if(l.decklightCast===1&&Array.isArray(l.steps))return l;throw new Error(`not a decklight cast (v1): ${i}`)}return Bd(r,i)}function Bd(r,i){let l=r.split(`
350
- `).filter(b=>b.trim()),d;try{d=JSON.parse(l[0])}catch{d=null}if(!d||d.version!==2)throw new Error(`not a decklight cast or asciicast v2: ${i}`);let u=[],m={cmd:"",raw:!0,output:[]},f=0,h=!1;for(let b of l.slice(1)){let k;try{k=JSON.parse(b)}catch{continue}if(!Array.isArray(k)||k.length<3)continue;let[A,P,M]=k;P==="m"?(h=!0,m.output.length&&u.push(m),m={cmd:String(M||""),raw:!0,output:[]},f=A):P==="o"&&m.output.push([Math.max(0,Pd(A-f)),M])}if(m.output.length&&u.push(m),!u.length)throw new Error(`asciicast has no output events: ${i}`);return{decklightCast:1,imported:!0,hasMarkers:h,meta:{cols:d.width||100,rows:d.height||28,prompt:""},steps:u}}function Pd(r){return Math.round(r*1e3)/1e3}function Dd(r,i){r.innerHTML=`<div class="terminal-window terminal-broken"><div class="terminal-titlebar"><span class="terminal-dot"></span><span class="terminal-dot"></span><span class="terminal-dot"></span><span class="terminal-title">terminal</span></div><div class="terminal-screen"><pre class="terminal-lines">\u26A0 ${$t(String(i.message||i))}</pre></div></div>`}var hs=class{constructor(i,l){this.el=i,this.cast=l,this.prompt=l.meta.prompt??"$ ";let d=Td(parseInt(i.dataset.typeSpeed??"5",10)||5);this.typeWpm=Nd(Yi*Cd(d));try{let m=parseInt(localStorage.getItem(Ji)??"",10);ar.includes(m)&&(this.typeWpm=m)}catch{}i.dataset.typeWpm=String(this.typeWpm),this.fontIdx=ir.indexOf(1);try{let m=parseInt(localStorage.getItem(ea)??"",10);m>=0&&m<ir.length&&(this.fontIdx=m)}catch{}this._applyFont();let u=(i.dataset.typeSound||"thocky").toLowerCase();this.soundName=or.includes(u)?u:"thocky";try{let m=localStorage.getItem(Qi);m&&or.includes(m)&&(this.soundName=m)}catch{}this.typeSound=this.soundName==="off"?null:this.soundName,this.maxStep=(parseFloat(i.dataset.maxStep||"2.5")||2.5)*1e3,this.visibleRows=parseInt(i.dataset.rows||"",10)||Math.min(l.meta.rows||Xi,Xi),this.epoch=0,this.applied=0,this.playable=l.steps.filter(m=>!m.hidden&&m.sleep==null),this._mountChrome(),this._watchSlide()}stop(){if(this.epoch+=1,Od(),this.playing){this.playing=!1;let i=this.controlsEl?.querySelector(".terminal-play");i&&(i.textContent="\u25B6")}}_watchSlide(){let i=this.el.closest("section");if(!i||typeof MutationObserver!="function")return;new MutationObserver(()=>{i.classList.contains("active")||this.stop()}).observe(i,{attributes:!0,attributeFilter:["class"]})}_mountChrome(){let i=this.el.dataset.title||"Terminal";this.el.innerHTML=`<div class="terminal-window"><div class="terminal-titlebar"><span class="terminal-dot"></span><span class="terminal-dot"></span><span class="terminal-dot"></span><span class="terminal-title">${$t(i)}</span><span class="terminal-controls"></span></div><div class="terminal-screen"><pre class="terminal-lines"></pre></div></div>`,this.linesEl=this.el.querySelector(".terminal-lines"),this.screenEl=this.el.querySelector(".terminal-screen"),this.controlsEl=this.el.querySelector(".terminal-controls"),this.screenEl.style.maxHeight=`calc(${this.visibleRows} * var(--term-line-height, 1.45em))`}_renderComplete(i,{withCursor:l=!0}={}){let d=[];for(let u=0;u<i;u++)d.push(this._stepHtml(this.playable[u]));l&&!this.cast.imported&&d.push(this._promptHtml()+'<span class="terminal-cursor"></span>'),this.linesEl.innerHTML=d.join(`
351
- `),this._scrollToEnd()}_stepEvents(i){return[...(i.output||[]).map(([l,d])=>({t:l,kind:"o",d})),...(i.input||[]).map(([l,d])=>({t:l,kind:"i",d:d.replace(/\r?\n$/,"")}))].sort((l,d)=>l.t-d.t)}_stepHtml(i){let l=new Yn;for(let u of this._stepEvents(i))l.write(u.d);let d=l.toHtml();return i.raw?d:this._promptHtml()+`<span class="terminal-cmd">${$t(i.cmd)}</span>`+(d?`
352
- `+d:"")}_promptHtml(){return`<span class="terminal-prompt">${$t(this.prompt)}</span>`}_scrollToEnd(){this.screenEl.scrollTop=this.screenEl.scrollHeight}_applyFont(){let i=ir[this.fontIdx];this.el.style.fontSize=i===1?"":`${i}em`}_mountFontButton(){let i=document.createElement("button");i.className="terminal-btn terminal-fontsize",i.title="font size: click cycles 75% to 160%",i.setAttribute("aria-label","font size");let l=()=>{i.textContent=`A ${Math.round(ir[this.fontIdx]*100)}%`};l(),i.addEventListener("click",()=>{this.fontIdx=(this.fontIdx+1)%ir.length,this._applyFont();try{localStorage.setItem(ea,String(this.fontIdx))}catch{}l()}),this.controlsEl.appendChild(i)}_mountSpeedButton(){let i=document.createElement("button");i.className="terminal-btn terminal-typespeed",i.title="typing speed: click cycles words per minute",i.setAttribute("aria-label","typing speed");let l=()=>{i.textContent=`\u2328 ${this.typeWpm} wpm`};l(),i.addEventListener("click",()=>{let d=(ar.indexOf(this.typeWpm)+1)%ar.length;this.typeWpm=ar[d],this.el.dataset.typeWpm=String(this.typeWpm);try{localStorage.setItem(Ji,String(this.typeWpm))}catch{}l()}),this.controlsEl.appendChild(i)}_mountSoundButton(){let i=document.createElement("button");i.className="terminal-btn terminal-typesound",i.title="key sound: click cycles thocky, creamy, clacky, off",i.setAttribute("aria-label","key sound");let l=()=>{i.textContent=`\u266A ${this.soundName}`};l(),i.addEventListener("click",()=>{let d=(or.indexOf(this.soundName)+1)%or.length;this.soundName=or[d],this.typeSound=this.soundName==="off"?null:this.soundName,this.el.dataset.typeSound=this.soundName;try{localStorage.setItem(Qi,this.soundName)}catch{}this.typeSound&&Lr("a",this.typeSound,.12),l()}),this.controlsEl.appendChild(i)}_typeFactor(i,l=!1){return(l&&this.speed||1)*(this.typeWpm/Yi)*(i.typeSpeed||1)}async _typeCmd(i,l,d,u,m=!1){for(let f=1;f<=i.length;f++){if(this.epoch!==u)return!1;let h=i[f-1],b=ps(h)/this._typeFactor(d,m);this.typeSound&&Lr(h,this.typeSound,b/1e3),this.linesEl.innerHTML=l+this._promptHtml()+`<span class="terminal-cmd">${$t(i.slice(0,f))}</span><span class="terminal-cursor"></span>`,this._scrollToEnd(),await _n(b)}return!0}mountStepMode(i){this.controlsEl.innerHTML="",this._mountSpeedButton(),this._mountSoundButton(),this._mountFontButton();let l=this.playable,d=Math.min(Math.max(parseInt(this.el.dataset.poster||"0",10)||0,0),l.length);if(this.applied=d,this._renderComplete(d),!i||typeof i.registerBuildProvider!="function"){this._renderComplete(l.length,{withCursor:!1});return}i.registerBuildProvider(this.el,{count:l.length-d,label:u=>l[d+u]?`${this.prompt}${l[d+u].cmd||"\u25B6 recording"}`:"",apply:u=>this.applyStep(d+Math.max(0,Math.min(u,l.length-d)))})}applyStep(i){this.epoch+=1;let l=i===this.applied+1;if(this.applied=i,!l){this._renderComplete(i);return}this._animateStep(i-1,this.epoch)}async _animateStep(i,l){let d=this.playable[i],u=[];for(let T=0;T<i;T++)u.push(this._stepHtml(this.playable[T]));let m=u.length?u.join(`
370
+ <tr><td>?</td><td>this help</td></tr></table></div>`,Oe.addEventListener("click",L),w.appendChild(Oe)}E.register({isOpen:()=>!!ye,close:ce,keydown:k=>_s(k,{query:Ze,onMove:z=>Y(ie+z),onCommit:F,onType:z=>{Ze+=z,f()},onBackspace:()=>{Ze=Ze.slice(0,-1),f()},onClear:()=>{Ze="",f()},onClose:ce})}),E.register({isOpen:()=>!!Ne,close:ut,keydown:k=>_s(k,{onMove:z=>pt(ee+z),onCommit:()=>{Ge(ee),ut()},onClose:ut})}),E.register({isOpen:()=>!!G,close:W,keydown:k=>_s(k,{query:ne,onMove:z=>De(J+z,!1),onCommit:Pe,onType:z=>B(ne+z),onBackspace:()=>B(ne.slice(0,-1)),onClear:()=>B(""),onClose:W})}),E.register({isOpen:()=>!!qe,close:We,keydown(k){switch(k.key){case"ArrowRight":H(M+1);break;case"ArrowLeft":H(M-1);break;case"ArrowDown":H(M+j());break;case"ArrowUp":H(M-j());break;case"Enter":case" ":we();break;case"o":case"O":case"Escape":We();break;default:return!1}return!0}});let Pt=k=>k.code==="Backquote"||k.key==="`"||k.key==="~"||k.key==="\xB2";function sn(k){if(Pt(k)&&(k.metaKey||k.ctrlKey||k.altKey)){wt(),k.preventDefault();return}if((k.metaKey||k.ctrlKey)&&!k.altKey&&!k.shiftKey&&(k.key==="k"||k.key==="K")){Nt.commit.open(),k.preventDefault();return}if(/^(input|textarea|select)$/i.test(k.target.tagName))return;if(k.ctrlKey&&!k.metaKey&&!k.altKey&&(k.key==="T"||k.key==="t")){k.shiftKey?dt():Ae.rollFromPicker()||mt(),k.preventDefault();return}if(k.metaKey||k.ctrlKey||k.altKey)return;let z=E.active();if(z){if(z.keydown(k)){k.preventDefault();return}if((typeof z.modal=="function"?z.modal():z.modal)!==!1)return}if(Pt(k)){wt(),k.preventDefault();return}switch(k.key){case" ":St.status().voiceInPlay?St.playPause():oe.next();break;case"ArrowRight":case"PageDown":oe.next();break;case"ArrowLeft":case"PageUp":oe.prev();break;case"Home":oe.goto(1,0);break;case"End":oe.goto(oe.state.totalSlides,0);break;case"o":case"O":We();break;case"b":case"B":xe();break;case"d":case"D":yt();break;case"c":case"C":xn();break;case"k":case"K":Nt.commit.open();break;case"j":case"J":wn();break;case"h":case"H":Nt.history.open();break;case"p":case"P":St.playPause();break;case"g":case"G":_t();break;case"m":case"M":k.shiftKey?Nn.compose():Nn.open();break;case"r":case"R":Nt.history.open();break;case"e":case"E":Kn();break;case"f":case"F":Me();break;case"v":case"V":St.openPicker();break;case"s":case"S":{let K=oe.__speakerWin;K&&!K.closed?K.__decklightSpeakerToggle?.():oe.__speakerWin=ao(oe);break}case"t":case"T":Ae.openPicker();break;case"/":Ce();break;case".":T(1);break;case",":T(-1);break;case">":Cn(.25);break;case"<":Cn(-.25);break;case"]":ht(1);break;case"[":ht(-1);break;case"l":case"L":It(k.shiftKey?-1:1);break;case"z":case"Z":Mn(k.shiftKey?"redo":"undo");break;case"a":case"A":Gn();break;case"w":case"W":fn(k.shiftKey?"laser":"pen");break;case"Backspace":if(!dn.annotator?.active)return;dn.annotator.clear();break;case"?":L();break;case"Escape":if(Ke())break;qe&&We();break;default:return}k.preventDefault()}c||document.addEventListener("keydown",sn);let on=null;w.addEventListener("touchstart",k=>{on=k.touches[0].clientX},{passive:!0}),w.addEventListener("touchend",k=>{if(on==null)return;let z=k.changedTouches[0].clientX-on;Math.abs(z)>40&&(z<0?oe.next():oe.prev()),on=null},{passive:!0});let Sn=k=>parseFloat(getComputedStyle(w).getPropertyValue(k))||0;function jn(){let k=w.getBoundingClientRect(),z=Sn("--dock-left"),K=Sn("--dock-right"),me=Sn("--dock-bottom"),et=Math.min((k.width-z-K)/a.width,(k.height-me)/a.height)||1;oe._scale=et,gt.style.transform=`translate(-50%, -50%) translate(${(z-K)/2}px, ${-me/2}px) scale(${et})`}oe._reflow=()=>{c||jn()},c||(new ResizeObserver(jn).observe(w),jn());let or=Ma({sectionsOf:()=>oe._sections,checkOverflow:So}),qt=k=>or.watch(k),bn=!1;if(a.hash&&!c&&window.addEventListener("hashchange",()=>{if(bn)return;let k=Ct();k&&oe.goto(k.slide,k.step,{force:!0})}),!c){let k=()=>{oe._sections.forEach((z,K)=>{let me=z.querySelector(":scope > .slide-bg > video");me&&(K===oe.state.slide-1?me.play()?.catch?.(()=>{}):me.paused||me.pause())})};oe.on("slide",k)}oe.sync(),c&&He&&(oe._sections.forEach(k=>{k.hasAttribute("data-logo")||k.appendChild(He.cloneNode(!0))}),He.remove()),document.fonts?.ready?.then(()=>{(Br===oe||!Br)&&Os(oe._sections,a)}),oe.theme=k=>st(k),oe.themePicker={open:Ae.openPicker,close:Ae.closePicker},oe.generateTheme=mt,oe.cycleFont=ht,oe.cycleLayout=It,oe.layoutRing=Wt,oe.toggleMessages=wt,oe.messages=Re,oe.showWelcome=_e.showWelcome,oe.tips={show:_e.showTip,reset:_e.resetTips,set:_e.setTips,status:_e.status};let St=ba({root:w,stage:gt,config:a,params:o,printMode:c,toast:je,logOnly:Fe,debugLog:m,overlays:E,instance:oe,syncSoundBtn:Le,updateDebugState:Tt,downloadFromUrl:pn,authorBase:()=>Nt?.available()?Nt.base():null,authorReady:()=>Nt?.settled?.()??Promise.resolve()}),{character:At,toggleNarration:yn,toggleNarrPause:$n,changeNarrRate:Cn,toggleCaptions:xn,openRecordDialog:wr,openMicRecorder:An,notesSegs:cn}=St,_n=St.openPicker;oe.toggleNarration=yn,oe.narration={playPause:()=>St.playPause(),openPicker:k=>St.openPicker(k),status:()=>St.status()},o.has("record")&&!c&&setTimeout(()=>{E.active()||An()},700);let Nn=Pa({root:w,params:o,overlays:E,instance:oe,toast:je,debugLog:m,dismissOthers:()=>{Ae.closePicker(),G&&W(),ye&&ce(),Nt.restore.close()},sections:()=>oe._sections??[],titleOf:vo,bodyOf:xo,authorBase:()=>Nt?.available()?Nt.base():null,authorReady:()=>Nt?.settled?.()??Promise.resolve()}),dn=va({root:w,printMode:c,toast:je,debugLog:m,overlays:E,instance:oe,narration:St,downloadFromUrl:pn,setProgressBar:k=>{Kt=k}}),{toggleClock:Xt,toggleProgress:wn,toggleInk:fn,toggleTranscript:ir}=dn;oe.toggleClock=Xt,oe.toggleProgress=wn;let Nt=Ta({root:w,config:a,params:o,printMode:c,toast:je,debugLog:m,overlays:E,instance:oe,notesSegs:cn,dismissOthers:()=>{Ae.closePicker(),G&&W(),ye&&ce()}}),{deckHistory:Mn,toggleEditor:ar,toggleAgentAsk:Gn,toggleElementEdit:Kn}=Nt;if(oe.restore=Nt.restore,oe.wizard=Nt.wizard,oe.toggleElementEdit=Kn,o.has("voiceover")&&St.status().track&&!c){let k=()=>{window.removeEventListener("pointerdown",k),window.removeEventListener("keydown",k),St.status().narrating||yn()};window.addEventListener("pointerdown",k,{once:!0}),window.addEventListener("keydown",k,{once:!0})}if(!c){let k=document.createElement("div");k.className="decklight-touch-controls",X=document.createElement("button"),X.type="button",X.className="decklight-touch-btn",X.setAttribute("aria-label","Fullscreen"),X.innerHTML=N.full,X.addEventListener("click",Me),k.appendChild(X),St.status().hasTracks&&(pe=document.createElement("button"),pe.type="button",pe.className="decklight-touch-btn",pe.addEventListener("pointerdown",z=>z.stopPropagation()),pe.addEventListener("click",()=>yn()),k.appendChild(pe),Le()),w.appendChild(k)}if(oe.saveGeneratedTheme=k=>dt(k),c)return w.classList.add("decklight-print"),oe._sections.forEach((k,z)=>{k.classList.add("active"),tr(oe._records[z],oe._records[z].groups.length)}),(d==="handout"||d==="notes")&&(w.classList.add("decklight-print-"+d),ya(gt,oe._sections,d)),qt(oe._sections),w.__decklight=oe,Br=oe,oe._emit("ready",{slides:oe.state.totalSlides,print:!0}),oe;let On=a.hash&&Ct()||{slide:1,step:0};return oe._sections.forEach((k,z)=>{z!==On.slide-1&&tr(oe._records[z],0)}),oe.goto(On.slide,On.step,{force:!0}),w.__decklight=oe,Br=oe,oe._emit("ready",{slides:oe.state.totalSlides}),_e.start(On),oe}ge();be();ge();be();var Ao="\x1B",Rs=Object.freeze({fg:null,bg:null,bold:!1,dim:!1,italic:!1,underline:!1,inverse:!1});function Ud(t){if(t<16)return null;if(t>=16&&t<=231){let a=t-16,c=[0,95,135,175,215,255];return[c[Math.floor(a/36)%6],c[Math.floor(a/6)%6],c[a%6]]}let o=8+(t-232)*10;return[o,o,o]}var Dr=class{constructor(){this.rows=[[]],this.row=0,this.col=0,this.style={...Rs},this._pending=""}write(o){let a=this._pending+o;this._pending="";let c=0;for(;c<a.length;){let d=a[c];if(d===Ao){let p=this._consumeEscape(a,c);if(p===0){this._pending=a.slice(c);return}c+=p;continue}if(c+=1,d===`
371
+ `){this._lineFeed();continue}if(d==="\r"){this.col=0;continue}if(d==="\b"){this.col=Math.max(0,this.col-1);continue}if(d===" "){this.col=(Math.floor(this.col/8)+1)*8;continue}d!=="\x07"&&(d<" "&&d!==" "||this._putChar(d))}}_lineFeed(){this.row+=1,this.rows[this.row]||(this.rows[this.row]=[])}_putChar(o){let a=this.rows[this.row];for(;a.length<this.col;)a.push({ch:" ",style:Rs});a[this.col]={ch:o,style:{...this.style}},this.col+=1}_consumeEscape(o,a){if(a+1>=o.length)return 0;let c=o[a+1];if(c==="["){let d=a+2;for(;d<o.length;){let p=o.charCodeAt(d);if(p>=64&&p<=126)return this._handleCsi(o.slice(a+2,d),o[d]),d-a+1;d+=1}return 0}if(c==="]"){let d=a+2;for(;d<o.length;){if(o[d]==="\x07")return d-a+1;if(o[d]===Ao&&o[d+1]==="\\")return d-a+2;if(o[d]===Ao&&d+1>=o.length)return 0;d+=1}return 0}return c==="("||c===")"?a+2<o.length?3:0:2}_handleCsi(o,a){if(!o.startsWith("?"))switch(a){case"m":this._sgr(o);return;case"K":this._eraseLine(o);return;case"C":this.col+=Math.max(1,parseInt(o||"1",10)||1);return;case"D":this.col=Math.max(0,this.col-Math.max(1,parseInt(o||"1",10)||1));return;default:return}}_eraseLine(o){let a=parseInt(o||"0",10)||0,c=this.rows[this.row];if(a===0){c.length=Math.min(c.length,this.col);return}if(a===1){for(let d=0;d<=Math.min(this.col,c.length-1);d++)c[d]={ch:" ",style:Rs};return}if(a===2){c.length=0;return}}_sgr(o){let a=o===""?[0]:o.split(";").map(d=>parseInt(d,10)||0),c=0;for(;c<a.length;){let d=a[c];if(d===0)this.style={...Rs};else if(d===1)this.style.bold=!0;else if(d===2)this.style.dim=!0;else if(d===3)this.style.italic=!0;else if(d===4)this.style.underline=!0;else if(d===7)this.style.inverse=!0;else if(d===22)this.style.bold=!1,this.style.dim=!1;else if(d===23)this.style.italic=!1;else if(d===24)this.style.underline=!1;else if(d===27)this.style.inverse=!1;else if(d>=30&&d<=37)this.style.fg={type:"ansi",idx:d-30};else if(d>=90&&d<=97)this.style.fg={type:"ansi",idx:d-90+8};else if(d===39)this.style.fg=null;else if(d>=40&&d<=47)this.style.bg={type:"ansi",idx:d-40};else if(d>=100&&d<=107)this.style.bg={type:"ansi",idx:d-100+8};else if(d===49)this.style.bg=null;else if(d===38||d===48){let p=d===38?"fg":"bg";a[c+1]===5&&a.length>c+2?(this.style[p]={type:"256",idx:a[c+2]},c+=2):a[c+1]===2&&a.length>c+4&&(this.style[p]={type:"rgb",r:a[c+2],g:a[c+3],b:a[c+4]},c+=4)}c+=1}}get lines(){return this.rows.map(o=>{let a=[];for(let c of o){let d=a[a.length-1];d&&Hd(d.style,c.style)?d.text+=c.ch:a.push({text:c.ch,style:c.style})}return a})}toHtml(){return this.lines.map(o=>Gd(o)).join(`
372
+ `)}};function Hd(t,o){return t.bold===o.bold&&t.dim===o.dim&&t.italic===o.italic&&t.underline===o.underline&&t.inverse===o.inverse&&Ka(t.fg,o.fg)&&Ka(t.bg,o.bg)}function Ka(t,o){return t===o?!0:!t||!o?!1:t.type===o.type&&t.idx===o.idx&&t.r===o.r&&t.g===o.g&&t.b===o.b}function jd(t){if(t.type==="256"){if(t.idx<16)return null;let[o,a,c]=Ud(t.idx);return`rgb(${o},${a},${c})`}return t.type==="rgb"?`rgb(${t.r},${t.g},${t.b})`:null}function Gd(t){return t.map(({text:o,style:a})=>{let c=[],d=[],{fg:p,bg:g}=a;a.inverse&&([p,g]=[g??{type:"inv-default-bg"},p??{type:"inv-default-fg"}]);for(let[S,P]of[[p,"fg"],[g,"bg"]])if(S)if(S.type==="ansi"||S.type==="256"&&S.idx<16)c.push(`ansi-${P}-${S.idx}`);else if(S.type==="inv-default-bg")c.push("ansi-inv-fg");else if(S.type==="inv-default-fg")c.push("ansi-inv-bg");else{let $=jd(S);$&&d.push(`${P==="fg"?"color":"background-color"}:${$}`)}a.bold&&c.push("ansi-bold"),a.dim&&c.push("ansi-dim"),a.italic&&c.push("ansi-italic"),a.underline&&c.push("ansi-underline");let m=$t(o);if(!c.length&&!d.length)return m;let w=c.length?` class="${c.join(" ")}"`:"",E=d.length?` style="${d.join(";")}"`:"";return`<span${w}${E}>${m}</span>`}).join("")}var Wa=24,Kd=t=>Math.max(1,Math.min(10,t)),Wd=t=>2**((t-5)/2.5),Va=55,ns=[120,160],Za="decklight-term-wpm:"+location.pathname,Vd=t=>ns.reduce((o,a)=>Math.abs(a-t)<Math.abs(o-t)?a:o),es=["thocky","creamy","clacky","off"],Ya="decklight-term-typesound:"+location.pathname,Xa="decklight-term-fontsize:"+location.pathname,ts=[.75,.9,1,1.15,1.35,1.6],Ja={thocky:{click:.17,clickF:[680,1250],clickQ:.9,lp:1800,clickDecay:[.012,.017],thump:.008,thumpF:[130,185],thumpF2:[58,85],thumpF2Prob:.22,ring:[.005,.009]},creamy:{click:.3,clickF:[1400,2850],clickQ:.95,lp:3800,clickDecay:[.007,.011],thump:.0056,thumpF:[60,110],ring:[.065,.095]},clacky:{click:.34,clickF:[2300,3900],clickQ:1.1,lp:6800,clickDecay:[.005,.008],thump:.003,thumpF:[90,140],ring:[.035,.055]}};function _o(t){let o=90+Math.random()*120;return Math.random()<.15&&(o+=Math.random()*240),t===" "?o+=70+Math.random()*220:".,:;/|&>-_=\"'`()".includes(t)&&(o+=40+Math.random()*140),Math.random()<.035&&(o+=300+Math.random()*440),o}var Zd=.012,Qt=null,Is=null,Bs=new Set,Qa=t=>{Bs.add(t),t.addEventListener("ended",()=>Bs.delete(t),{once:!0})};function Yd(){if(!Qt)return;let t=Qt.currentTime;for(let o of Bs)try{o.stop(t)}catch{}Bs.clear()}function Ps(t="",o="thocky",a=.12){try{let c=window.AudioContext||window.webkitAudioContext;if(!c)return;if(Qt??=new c,Qt.state==="suspended"&&Qt.resume(),!Is){let I=Math.floor(Qt.sampleRate*.06);Is=Qt.createBuffer(1,I,Qt.sampleRate);let Se=Is.getChannelData(0);for(let de=0;de<I;de++)Se[de]=Math.random()*2-1}let d=Ja[o]??Ja.thocky,p=(I,Se)=>I+Math.random()*(Se-I),g=Qt.currentTime+Zd,m=t===" ",w=p(.45,1.3)*(m?1.25:1),E=p(...d.clickF)*(m?.7:1),S=p(...d.ring)*(m?1.5:1),P=(I,Se,de,$e)=>{let te=Qt.createBufferSource();te.buffer=Is;let ae=Qt.createBiquadFilter();ae.type="bandpass",ae.frequency.value=de,ae.Q.value=d.clickQ;let Re=Qt.createBiquadFilter();Re.type="lowpass",Re.frequency.value=d.lp;let Fe=Qt.createGain();Fe.gain.setValueAtTime(1e-4,I),Fe.gain.exponentialRampToValueAtTime(Se,I+7e-4),Fe.gain.exponentialRampToValueAtTime(1e-4,I+$e),te.connect(ae),ae.connect(Re),Re.connect(Fe),Fe.connect(Qt.destination),te.start(I),te.stop(I+$e+.01),Qa(te)},$=(I,Se,de,$e)=>{let te=Qt.createOscillator();te.type="sine",te.frequency.setValueAtTime(de,I),te.frequency.exponentialRampToValueAtTime(de*.6,I+$e*.6);let ae=Qt.createGain();ae.gain.setValueAtTime(1e-4,I),ae.gain.exponentialRampToValueAtTime(Se,I+p(.003,.011)),ae.gain.exponentialRampToValueAtTime(Se*.25,I+$e),ae.gain.exponentialRampToValueAtTime(1e-4,I+$e*2),te.connect(ae),ae.connect(Qt.destination),te.start(I),te.stop(I+$e*2+.01),Qa(te)},_=d.thumpF2&&Math.random()<(d.thumpF2Prob??.4)?d.thumpF2:d.thumpF;P(g,d.click*w*(m?.82:1),E,p(...d.clickDecay)*(m?1.2:1)),$(g,d.thump*w*(m?2.4:1),p(..._)*(m?.7:1),S);let C=g+Math.max(.01,Math.min(p(.035,.08),a*.55));P(C,d.click*w*p(.35,.55),E*1.15,p(...d.clickDecay)*.8),$(C,d.thump*w*(m?.5:.25),p(..._)*(m?.7:1),S*.6)}catch{}}function Xd(){try{let t=window.AudioContext||window.webkitAudioContext;if(!t)return;Qt??=new t,Qt.state==="suspended"&&Qt.resume()}catch{}}var el=!1;function Jd(){if(el||typeof document>"u")return;el=!0;let t=()=>{Xd(),document.removeEventListener("pointerdown",t,!0),document.removeEventListener("keydown",t,!0)};document.addEventListener("pointerdown",t,!0),document.addEventListener("keydown",t,!0)}function $o(t,o=document){let a=[...o.querySelectorAll(".terminal[data-cast], .terminal[data-cast-inline]")];return a.length&&Jd(),Promise.all(a.map(c=>Qd(c,t).catch(d=>{ru(c,d)})))}async function Qd(t,o){if(t.dataset.decklightTerminal)return;t.dataset.decklightTerminal="1";let a,c,d=t.dataset.castInline;if(d){c=d;let w=document.querySelector(d);if(!w&&document.readyState==="loading"&&(await new Promise(E=>document.addEventListener("DOMContentLoaded",E,{once:!0})),w=document.querySelector(d)),!w)throw new Error(`inline cast not found: ${d}`);a=w.textContent}else{c=t.dataset.cast;let w=await fetch(c);if(!w.ok)throw new Error(`failed to load cast: ${c} (${w.status})`);a=await w.text()}let p=eu(a,c),g=new To(t,p);t._decklightTerminal=g;let m=t.dataset.mode||"step";p.imported&&m==="step"&&!p.hasMarkers&&(m="play"),m==="play"?g.mountPlayMode():g.mountStepMode(o)}function eu(t,o){let a=null;try{a=JSON.parse(t)}catch{}if(a){if(a.decklightCast===1&&Array.isArray(a.steps))return a;throw new Error(`not a decklight cast (v1): ${o}`)}return tu(t,o)}function tu(t,o){let a=t.split(`
373
+ `).filter(w=>w.trim()),c;try{c=JSON.parse(a[0])}catch{c=null}if(!c||c.version!==2)throw new Error(`not a decklight cast or asciicast v2: ${o}`);let d=[],p={cmd:"",raw:!0,output:[]},g=0,m=!1;for(let w of a.slice(1)){let E;try{E=JSON.parse(w)}catch{continue}if(!Array.isArray(E)||E.length<3)continue;let[S,P,$]=E;P==="m"?(m=!0,p.output.length&&d.push(p),p={cmd:String($||""),raw:!0,output:[]},g=S):P==="o"&&p.output.push([Math.max(0,nu(S-g)),$])}if(p.output.length&&d.push(p),!d.length)throw new Error(`asciicast has no output events: ${o}`);return{decklightCast:1,imported:!0,hasMarkers:m,meta:{cols:c.width||100,rows:c.height||28,prompt:""},steps:d}}function nu(t){return Math.round(t*1e3)/1e3}function ru(t,o){t.innerHTML=`<div class="terminal-window terminal-broken"><div class="terminal-titlebar"><span class="terminal-dot"></span><span class="terminal-dot"></span><span class="terminal-dot"></span><span class="terminal-title">terminal</span></div><div class="terminal-screen"><pre class="terminal-lines">\u26A0 ${$t(String(o.message||o))}</pre></div></div>`}var To=class{constructor(o,a){this.el=o,this.cast=a,this.prompt=a.meta.prompt??"$ ";let c=Kd(parseInt(o.dataset.typeSpeed??"5",10)||5);this.typeWpm=Vd(Va*Wd(c));try{let p=parseInt(localStorage.getItem(Za)??"",10);ns.includes(p)&&(this.typeWpm=p)}catch{}o.dataset.typeWpm=String(this.typeWpm),this.fontIdx=ts.indexOf(1);try{let p=parseInt(localStorage.getItem(Xa)??"",10);p>=0&&p<ts.length&&(this.fontIdx=p)}catch{}this._applyFont();let d=(o.dataset.typeSound||"thocky").toLowerCase();this.soundName=es.includes(d)?d:"thocky";try{let p=localStorage.getItem(Ya);p&&es.includes(p)&&(this.soundName=p)}catch{}this.typeSound=this.soundName==="off"?null:this.soundName,this.maxStep=(parseFloat(o.dataset.maxStep||"2.5")||2.5)*1e3,this.visibleRows=parseInt(o.dataset.rows||"",10)||Math.min(a.meta.rows||Wa,Wa),this.epoch=0,this.applied=0,this.playable=a.steps.filter(p=>!p.hidden&&p.sleep==null),this._mountChrome(),this._watchSlide()}stop(){if(this.epoch+=1,Yd(),this.playing){this.playing=!1;let o=this.controlsEl?.querySelector(".terminal-play");o&&(o.textContent="\u25B6")}}_watchSlide(){let o=this.el.closest("section");if(!o||typeof MutationObserver!="function")return;new MutationObserver(()=>{o.classList.contains("active")||this.stop()}).observe(o,{attributes:!0,attributeFilter:["class"]})}_mountChrome(){let o=this.el.dataset.title||"Terminal";this.el.innerHTML=`<div class="terminal-window"><div class="terminal-titlebar"><span class="terminal-dot"></span><span class="terminal-dot"></span><span class="terminal-dot"></span><span class="terminal-title">${$t(o)}</span><span class="terminal-controls"></span></div><div class="terminal-screen"><pre class="terminal-lines"></pre></div></div>`,this.linesEl=this.el.querySelector(".terminal-lines"),this.screenEl=this.el.querySelector(".terminal-screen"),this.controlsEl=this.el.querySelector(".terminal-controls"),this.screenEl.style.maxHeight=`calc(${this.visibleRows} * var(--term-line-height, 1.45em))`}_renderComplete(o,{withCursor:a=!0}={}){let c=[];for(let d=0;d<o;d++)c.push(this._stepHtml(this.playable[d]));a&&!this.cast.imported&&c.push(this._promptHtml()+'<span class="terminal-cursor"></span>'),this.linesEl.innerHTML=c.join(`
374
+ `),this._scrollToEnd()}_stepEvents(o){return[...(o.output||[]).map(([a,c])=>({t:a,kind:"o",d:c})),...(o.input||[]).map(([a,c])=>({t:a,kind:"i",d:c.replace(/\r?\n$/,"")}))].sort((a,c)=>a.t-c.t)}_stepHtml(o){let a=new Dr;for(let d of this._stepEvents(o))a.write(d.d);let c=a.toHtml();return o.raw?c:this._promptHtml()+`<span class="terminal-cmd">${$t(o.cmd)}</span>`+(c?`
375
+ `+c:"")}_promptHtml(){return`<span class="terminal-prompt">${$t(this.prompt)}</span>`}_scrollToEnd(){this.screenEl.scrollTop=this.screenEl.scrollHeight}_applyFont(){let o=ts[this.fontIdx];this.el.style.fontSize=o===1?"":`${o}em`}_mountFontButton(){let o=document.createElement("button");o.className="terminal-btn terminal-fontsize",o.title="font size: click cycles 75% to 160%",o.setAttribute("aria-label","font size");let a=()=>{o.textContent=`A ${Math.round(ts[this.fontIdx]*100)}%`};a(),o.addEventListener("click",()=>{this.fontIdx=(this.fontIdx+1)%ts.length,this._applyFont();try{localStorage.setItem(Xa,String(this.fontIdx))}catch{}a()}),this.controlsEl.appendChild(o)}_mountSpeedButton(){let o=document.createElement("button");o.className="terminal-btn terminal-typespeed",o.title="typing speed: click cycles words per minute",o.setAttribute("aria-label","typing speed");let a=()=>{o.textContent=`\u2328 ${this.typeWpm} wpm`};a(),o.addEventListener("click",()=>{let c=(ns.indexOf(this.typeWpm)+1)%ns.length;this.typeWpm=ns[c],this.el.dataset.typeWpm=String(this.typeWpm);try{localStorage.setItem(Za,String(this.typeWpm))}catch{}a()}),this.controlsEl.appendChild(o)}_mountSoundButton(){let o=document.createElement("button");o.className="terminal-btn terminal-typesound",o.title="key sound: click cycles thocky, creamy, clacky, off",o.setAttribute("aria-label","key sound");let a=()=>{o.textContent=`\u266A ${this.soundName}`};a(),o.addEventListener("click",()=>{let c=(es.indexOf(this.soundName)+1)%es.length;this.soundName=es[c],this.typeSound=this.soundName==="off"?null:this.soundName,this.el.dataset.typeSound=this.soundName;try{localStorage.setItem(Ya,this.soundName)}catch{}this.typeSound&&Ps("a",this.typeSound,.12),a()}),this.controlsEl.appendChild(o)}_typeFactor(o,a=!1){return(a&&this.speed||1)*(this.typeWpm/Va)*(o.typeSpeed||1)}async _typeCmd(o,a,c,d,p=!1){for(let g=1;g<=o.length;g++){if(this.epoch!==d)return!1;let m=o[g-1],w=_o(m)/this._typeFactor(c,p);this.typeSound&&Ps(m,this.typeSound,w/1e3),this.linesEl.innerHTML=a+this._promptHtml()+`<span class="terminal-cmd">${$t(o.slice(0,g))}</span><span class="terminal-cursor"></span>`,this._scrollToEnd(),await sr(w)}return!0}mountStepMode(o){this.controlsEl.innerHTML="",this._mountSpeedButton(),this._mountSoundButton(),this._mountFontButton();let a=this.playable,c=Math.min(Math.max(parseInt(this.el.dataset.poster||"0",10)||0,0),a.length);if(this.applied=c,this._renderComplete(c),!o||typeof o.registerBuildProvider!="function"){this._renderComplete(a.length,{withCursor:!1});return}o.registerBuildProvider(this.el,{count:a.length-c,label:d=>a[c+d]?`${this.prompt}${a[c+d].cmd||"\u25B6 recording"}`:"",apply:d=>this.applyStep(c+Math.max(0,Math.min(d,a.length-c)))})}applyStep(o){this.epoch+=1;let a=o===this.applied+1;if(this.applied=o,!a){this._renderComplete(o);return}this._animateStep(o-1,this.epoch)}async _animateStep(o,a){let c=this.playable[o],d=[];for(let _=0;_<o;_++)d.push(this._stepHtml(this.playable[_]));let p=d.length?d.join(`
353
376
  `)+`
354
- `:"",f=d.cmd||"";if(!d.raw){if(!await this._typeCmd(f,m,d,l))return;await _n(120/this._typeFactor(d))}let h=this._stepEvents(d),b=h.length?h[h.length-1].t*1e3:0,k=b>this.maxStep?this.maxStep/b:1,A=new Yn,P=()=>{let T=A.toHtml();this.linesEl.innerHTML=d.raw?m+T:m+this._promptHtml()+`<span class="terminal-cmd">${$t(f)}</span>`+(T?`
355
- `+T:""),this._scrollToEnd()},M=0;for(let T of h){let C=Math.min((T.t-M)*1e3*k,400);if(M=T.t,C>8&&await _n(C),this.epoch!==l)return;if(T.kind==="i")for(let F of T.d){if(this.epoch!==l)return;let ye=ps(F)/this._typeFactor(d);this.typeSound&&Lr(F,this.typeSound,ye/1e3),A.write(F),P(),await _n(ye)}else A.write(T.d),P()}this.epoch===l&&this._renderComplete(i+1)}mountPlayMode(){let i=[1,2,4],l=parseFloat(this.el.dataset.speed);this.speed=i.includes(l)?l:1,this.playing=!1,this.controlsEl.innerHTML=`<button class="terminal-btn terminal-play" aria-label="play">\u25B6</button><button class="terminal-btn terminal-speed" aria-label="speed">${this.speed}\xD7</button><button class="terminal-btn terminal-restart" aria-label="restart">\u21BA</button>`,this._mountSoundButton(),this._mountFontButton();let d=this.controlsEl.querySelector(".terminal-play"),u=this.controlsEl.querySelector(".terminal-speed");this.controlsEl.querySelector(".terminal-restart").addEventListener("click",()=>this._restart(d)),u.addEventListener("click",()=>{this.speed=this.speed>=4?1:this.speed*2,u.textContent=`${this.speed}\xD7`}),d.addEventListener("click",()=>{this.playing?this.stop():(d.textContent="\u23F8",this._playAll(d))}),this._renderComplete(0)}_restart(i){this.stop(),i.textContent="\u25B6",this._playedUpTo=0,this._renderComplete(0)}async _playAll(i){this.playing=!0;let l=++this.epoch,d=this._playedUpTo||0;for(let u=d;u<this.cast.steps.length;u++){let m=this.cast.steps[u];if(m.hidden){this._playedUpTo=u+1;continue}if(m.sleep!=null){if(await _n(m.sleep*1e3/this.speed),this.epoch!==l){this._playedUpTo=u;return}this._playedUpTo=u+1;continue}let h=this.cast.steps.slice(0,u).filter(T=>!T.hidden&&T.sleep==null).map(T=>this._stepHtml(T)),b=h.length?h.join(`
377
+ `:"",g=c.cmd||"";if(!c.raw){if(!await this._typeCmd(g,p,c,a))return;await sr(120/this._typeFactor(c))}let m=this._stepEvents(c),w=m.length?m[m.length-1].t*1e3:0,E=w>this.maxStep?this.maxStep/w:1,S=new Dr,P=()=>{let _=S.toHtml();this.linesEl.innerHTML=c.raw?p+_:p+this._promptHtml()+`<span class="terminal-cmd">${$t(g)}</span>`+(_?`
378
+ `+_:""),this._scrollToEnd()},$=0;for(let _ of m){let C=Math.min((_.t-$)*1e3*E,400);if($=_.t,C>8&&await sr(C),this.epoch!==a)return;if(_.kind==="i")for(let I of _.d){if(this.epoch!==a)return;let Se=_o(I)/this._typeFactor(c);this.typeSound&&Ps(I,this.typeSound,Se/1e3),S.write(I),P(),await sr(Se)}else S.write(_.d),P()}this.epoch===a&&this._renderComplete(o+1)}mountPlayMode(){let o=[1,2,4],a=parseFloat(this.el.dataset.speed);this.speed=o.includes(a)?a:1,this.playing=!1,this.controlsEl.innerHTML=`<button class="terminal-btn terminal-play" aria-label="play">\u25B6</button><button class="terminal-btn terminal-speed" aria-label="speed">${this.speed}\xD7</button><button class="terminal-btn terminal-restart" aria-label="restart">\u21BA</button>`,this._mountSoundButton(),this._mountFontButton();let c=this.controlsEl.querySelector(".terminal-play"),d=this.controlsEl.querySelector(".terminal-speed");this.controlsEl.querySelector(".terminal-restart").addEventListener("click",()=>this._restart(c)),d.addEventListener("click",()=>{this.speed=this.speed>=4?1:this.speed*2,d.textContent=`${this.speed}\xD7`}),c.addEventListener("click",()=>{this.playing?this.stop():(c.textContent="\u23F8",this._playAll(c))}),this._renderComplete(0)}_restart(o){this.stop(),o.textContent="\u25B6",this._playedUpTo=0,this._renderComplete(0)}async _playAll(o){this.playing=!0;let a=++this.epoch,c=this._playedUpTo||0;for(let d=c;d<this.cast.steps.length;d++){let p=this.cast.steps[d];if(p.hidden){this._playedUpTo=d+1;continue}if(p.sleep!=null){if(await sr(p.sleep*1e3/this.speed),this.epoch!==a){this._playedUpTo=d;return}this._playedUpTo=d+1;continue}let m=this.cast.steps.slice(0,d).filter(_=>!_.hidden&&_.sleep==null).map(_=>this._stepHtml(_)),w=m.length?m.join(`
356
379
  `)+`
357
- `:"",k=m.cmd||"";if(!m.raw&&!await this._typeCmd(k,b,m,l,!0)){this._playedUpTo=u;return}let A=new Yn,P=()=>{let T=A.toHtml();this.linesEl.innerHTML=m.raw?b+T:b+this._promptHtml()+`<span class="terminal-cmd">${$t(k)}</span>`+(T?`
358
- `+T:""),this._scrollToEnd()},M=0;for(let T of this._stepEvents(m)){let C=(T.t-M)*1e3/this.speed;if(M=T.t,C>4&&await _n(C),this.epoch!==l){this._playedUpTo=u;return}if(T.kind==="i")for(let F of T.d){if(this.epoch!==l){this._playedUpTo=u;return}let ye=ps(F)/this._typeFactor(m,!0);this.typeSound&&Lr(F,this.typeSound,ye/1e3),A.write(F),P(),await _n(ye)}else A.write(T.d),P()}await _n(350/this.speed),this._playedUpTo=u+1}this.playing=!1,i.textContent="\u25B6",this._playedUpTo=0,this._renderComplete(this.playable.length,{withCursor:!0})}};function _n(r){return new Promise(i=>setTimeout(i,r))}var qd="0.6.0";function Fd(r={}){let i=Vi(r),l=ms||(void 0)?.registerTerminals;return typeof l=="function"&&Promise.resolve(l({registerBuildProvider:sr},document)).catch(d=>console.error("Decklight: terminal subsystem failed to initialize",d)),i}function zd(r=document){let i=ms||(void 0)?.registerTerminals;return typeof i=="function"?Promise.resolve(i({registerBuildProvider:sr},r)):Promise.resolve()}return Ja(Ud);})();
380
+ `:"",E=p.cmd||"";if(!p.raw&&!await this._typeCmd(E,w,p,a,!0)){this._playedUpTo=d;return}let S=new Dr,P=()=>{let _=S.toHtml();this.linesEl.innerHTML=p.raw?w+_:w+this._promptHtml()+`<span class="terminal-cmd">${$t(E)}</span>`+(_?`
381
+ `+_:""),this._scrollToEnd()},$=0;for(let _ of this._stepEvents(p)){let C=(_.t-$)*1e3/this.speed;if($=_.t,C>4&&await sr(C),this.epoch!==a){this._playedUpTo=d;return}if(_.kind==="i")for(let I of _.d){if(this.epoch!==a){this._playedUpTo=d;return}let Se=_o(I)/this._typeFactor(p,!0);this.typeSound&&Ps(I,this.typeSound,Se/1e3),S.write(I),P(),await sr(Se)}else S.write(_.d),P()}await sr(350/this.speed),this._playedUpTo=d+1}this.playing=!1,o.textContent="\u25B6",this._playedUpTo=0,this._renderComplete(this.playable.length,{withCursor:!0})}};function sr(t){return new Promise(o=>setTimeout(o,t))}var su="0.7.0";function ou(t={}){let o=Ga(t),a=$o||(void 0)?.registerTerminals;return typeof a=="function"&&Promise.resolve(a({registerBuildProvider:Qr},document)).catch(c=>console.error("Decklight: terminal subsystem failed to initialize",c)),o}function iu(t=document){let o=$o||(void 0)?.registerTerminals;return typeof o=="function"?Promise.resolve(o({registerBuildProvider:Qr},t)):Promise.resolve()}return gl(au);})();
359
382
  //# sourceMappingURL=decklight.js.map