decklight 0.5.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 (53) hide show
  1. package/README.md +20 -9
  2. package/SPEC.md +239 -17
  3. package/cli/agents.mjs +97 -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 +475 -0
  10. package/cli/decklight.mjs +95 -25
  11. package/cli/dev.mjs +193 -25
  12. package/cli/edit.mjs +1055 -39
  13. package/cli/git-tree.mjs +87 -0
  14. package/cli/git.mjs +370 -0
  15. package/cli/history.mjs +145 -0
  16. package/cli/init.mjs +199 -7
  17. package/cli/marketplace.mjs +123 -17
  18. package/cli/port-conflict.mjs +228 -22
  19. package/cli/present.mjs +297 -12
  20. package/cli/publish.mjs +15 -40
  21. package/cli/record.mjs +154 -0
  22. package/cli/restore.mjs +120 -4
  23. package/cli/review-remote.mjs +330 -0
  24. package/cli/review-store.mjs +107 -0
  25. package/cli/review-submit.mjs +292 -0
  26. package/cli/review.mjs +361 -0
  27. package/cli/serve.mjs +60 -1
  28. package/cli/skill-content.mjs +12 -1
  29. package/cli/theme.mjs +78 -11
  30. package/cli/units.mjs +2 -2
  31. package/cli/upstream.mjs +256 -0
  32. package/cli/util.mjs +59 -0
  33. package/dist/build-info.json +1 -0
  34. package/dist/decklight.css +534 -3
  35. package/dist/decklight.js +102 -76
  36. package/dist/decklight.js.map +4 -4
  37. package/docs/architecture.svg +7 -0
  38. package/package.json +2 -1
  39. package/tools/args.mjs +20 -0
  40. package/tools/deck-html.mjs +84 -0
  41. package/tools/elevenlabs-tts.mjs +1 -1
  42. package/tools/lipsync-server.mjs +64 -2
  43. package/tools/lipsync.mjs +40 -24
  44. package/tools/local-voice.mjs +170 -16
  45. package/tools/publish-voices.mjs +78 -18
  46. package/tools/recording-impact.mjs +110 -0
  47. package/tools/review-anchor.mjs +180 -0
  48. package/tools/test-impact.mjs +259 -0
  49. package/tools/tts-engines.mjs +211 -12
  50. package/tools/tts-setup.mjs +2 -9
  51. package/tools/video.mjs +56 -12
  52. package/tools/voiceover-server.mjs +262 -11
  53. package/tools/voiceover.mjs +32 -13
package/dist/decklight.js CHANGED
@@ -1,10 +1,10 @@
1
- /*! Decklight v0.5.0 — Copyright 2026 Gilles Philippart — SPDX-License-Identifier: Apache-2.0 */
2
- var Decklight=(()=>{var Fa=Object.create;var nr=Object.defineProperty;var za=Object.getOwnPropertyDescriptor;var Ua=Object.getOwnPropertyNames;var Ha=Object.getPrototypeOf,Ga=Object.prototype.hasOwnProperty;var Us=(r,a)=>()=>(r&&(a=r(r=0)),a);var ja=(r,a)=>()=>(a||r((a={exports:{}}).exports,a),a.exports),Ka=(r,a)=>{for(var l in a)nr(r,l,{get:a[l],enumerable:!0})},Hs=(r,a,l,d)=>{if(a&&typeof a=="object"||typeof a=="function")for(let u of Ua(a))!Ga.call(r,u)&&u!==l&&nr(r,u,{get:()=>a[u],enumerable:!(d=za(a,u))||d.enumerable});return r};var Wa=(r,a,l)=>(l=r!=null?Fa(Ha(r)):{},Hs(a||!r||!r.__esModule?nr(l,"default",{value:r,enumerable:!0}):l,r)),Va=r=>Hs(nr({},"__esModule",{value:!0}),r);var We,ae=Us(()=>{We={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 Ke,le=Us(()=>{Ke=["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 Mo=ja((du,Oo)=>{ae();le();function wo(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(a=>{let l=r[a],d=typeof l;(d==="object"||d==="function")&&!Object.isFrozen(l)&&wo(l)}),r}var ar=class{constructor(a){a.data===void 0&&(a.data={}),this.data=a.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function xo(r){return r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function dn(r,...a){let l=Object.create(null);for(let d in r)l[d]=r[d];return a.forEach(function(d){for(let u in d)l[u]=d[u]}),l}var Al="</span>",ho=r=>!!r.scope,_l=(r,{prefix:a})=>{if(r.startsWith("language:"))return r.replace("language:","language-");if(r.includes(".")){let l=r.split(".");return[`${a}${l.shift()}`,...l.map((d,u)=>`${d}${"_".repeat(u+1)}`)].join(" ")}return`${a}${r}`},Fr=class{constructor(a,l){this.buffer="",this.classPrefix=l.classPrefix,a.walk(this)}addText(a){this.buffer+=xo(a)}openNode(a){if(!ho(a))return;let l=_l(a.scope,{prefix:this.classPrefix});this.span(l)}closeNode(a){ho(a)&&(this.buffer+=Al)}value(){return this.buffer}span(a){this.buffer+=`<span class="${a}">`}},mo=(r={})=>{let a={children:[]};return Object.assign(a,r),a},zr=class r{constructor(){this.rootNode=mo(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(a){this.top.children.push(a)}openNode(a){let l=mo({scope:a});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(a){return this.constructor._walk(a,this.rootNode)}static _walk(a,l){return typeof l=="string"?a.addText(l):l.children&&(a.openNode(l),l.children.forEach(d=>this._walk(a,d)),a.closeNode(l)),a}static _collapse(a){typeof a!="string"&&a.children&&(a.children.every(l=>typeof l=="string")?a.children=[a.children.join("")]:a.children.forEach(l=>{r._collapse(l)}))}},Ur=class extends zr{constructor(a){super(),this.options=a}addText(a){a!==""&&this.add(a)}startScope(a){this.openNode(a)}endScope(){this.closeNode()}__addSublanguage(a,l){let d=a.root;l&&(d.scope=`language:${l}`),this.add(d)}toHTML(){return new Fr(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}};function Hn(r){return r?typeof r=="string"?r:r.source:null}function vo(r){return bn("(?=",r,")")}function Tl(r){return bn("(?:",r,")*")}function Cl(r){return bn("(?:",r,")?")}function bn(...r){return r.map(l=>Hn(l)).join("")}function Nl(r){let a=r[r.length-1];return typeof a=="object"&&a.constructor===Object?(r.splice(r.length-1,1),a):{}}function Gr(...r){return"("+(Nl(r).capture?"":"?:")+r.map(d=>Hn(d)).join("|")+")"}function ko(r){return new RegExp(r.toString()+"|").exec("").length-1}function $l(r,a){let l=r&&r.exec(a);return l&&l.index===0}var Ol=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function jr(r,{joinWith:a}){let l=0;return r.map(d=>{l+=1;let u=l,m=Hn(d),f="";for(;m.length>0;){let h=Ol.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(a)}var Ml=/\b\B/,Eo="[a-zA-Z]\\w*",Kr="[a-zA-Z_]\\w*",So="\\b\\d+(\\.\\d+)?",Ao="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",_o="\\b(0b[01]+)",Ll="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",Rl=(r={})=>{let a=/^#![ ]*\//;return r.binary&&(r.begin=bn(a,/.*\b/,r.binary,/\b.*/)),dn({scope:"meta",begin:a,end:/$/,relevance:0,"on:begin":(l,d)=>{l.index!==0&&d.ignoreMatch()}},r)},Gn={begin:"\\\\[\\s\\S]",relevance:0},Il={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[Gn]},Bl={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[Gn]},Pl={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/},cr=function(r,a,l={}){let d=dn({scope:"comment",begin:r,end:a,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=Gr("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:bn(/[ ]+/,"(",u,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),d},Dl=cr("//","$"),ql=cr("/\\*","\\*/"),Fl=cr("#","$"),zl={scope:"number",begin:So,relevance:0},Ul={scope:"number",begin:Ao,relevance:0},Hl={scope:"number",begin:_o,relevance:0},Gl={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[Gn,{begin:/\[/,end:/\]/,relevance:0,contains:[Gn]}]},jl={scope:"title",begin:Eo,relevance:0},Kl={scope:"title",begin:Kr,relevance:0},Wl={begin:"\\.\\s*"+Kr,relevance:0},Vl=function(r){return Object.assign(r,{"on:begin":(a,l)=>{l.data._beginMatch=a[1]},"on:end":(a,l)=>{l.data._beginMatch!==a[1]&&l.ignoreMatch()}})},ir=Object.freeze({__proto__:null,APOS_STRING_MODE:Il,BACKSLASH_ESCAPE:Gn,BINARY_NUMBER_MODE:Hl,BINARY_NUMBER_RE:_o,COMMENT:cr,C_BLOCK_COMMENT_MODE:ql,C_LINE_COMMENT_MODE:Dl,C_NUMBER_MODE:Ul,C_NUMBER_RE:Ao,END_SAME_AS_BEGIN:Vl,HASH_COMMENT_MODE:Fl,IDENT_RE:Eo,MATCH_NOTHING_RE:Ml,METHOD_GUARD:Wl,NUMBER_MODE:zl,NUMBER_RE:So,PHRASAL_WORDS_MODE:Pl,QUOTE_STRING_MODE:Bl,REGEXP_MODE:Gl,RE_STARTERS_RE:Ll,SHEBANG:Rl,TITLE_MODE:jl,UNDERSCORE_IDENT_RE:Kr,UNDERSCORE_TITLE_MODE:Kl});function Zl(r,a){r.input[r.index-1]==="."&&a.ignoreMatch()}function Xl(r,a){r.className!==void 0&&(r.scope=r.className,delete r.className)}function Yl(r,a){a&&r.beginKeywords&&(r.begin="\\b("+r.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",r.__beforeBegin=Zl,r.keywords=r.keywords||r.beginKeywords,delete r.beginKeywords,r.relevance===void 0&&(r.relevance=0))}function Jl(r,a){Array.isArray(r.illegal)&&(r.illegal=Gr(...r.illegal))}function Ql(r,a){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 ec(r,a){r.relevance===void 0&&(r.relevance=1)}var tc=(r,a)=>{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=bn(l.beforeMatch,vo(l.begin)),r.starts={relevance:0,contains:[Object.assign(l,{endsParent:!0})]},r.relevance=0,delete l.beforeMatch},nc=["of","and","for","in","not","or","if","then","parent","list","value"],rc="keyword";function To(r,a,l=rc){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,To(r[m],a,m))}),d;function u(m,f){a&&(f=f.map(h=>h.toLowerCase())),f.forEach(function(h){let w=h.split("|");d[w[0]]=[m,sc(w[0],w[1])]})}}function sc(r,a){return a?Number(a):oc(r)?0:1}function oc(r){return nc.includes(r.toLowerCase())}var fo={},gn=r=>{console.error(r)},go=(r,...a)=>{console.log(`WARN: ${r}`,...a)},Cn=(r,a)=>{fo[`${r}/${a}`]||(console.log(`Deprecated as of ${r}. ${a}`),fo[`${r}/${a}`]=!0)},lr=new Error;function Co(r,a,{key:l}){let d=0,u=r[l],m={},f={};for(let h=1;h<=a.length;h++)f[h+d]=u[h],m[h+d]=!0,d+=ko(a[h-1]);r[l]=f,r[l]._emit=m,r[l]._multi=!0}function ic(r){if(Array.isArray(r.begin)){if(r.skip||r.excludeBegin||r.returnBegin)throw gn("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),lr;if(typeof r.beginScope!="object"||r.beginScope===null)throw gn("beginScope must be object"),lr;Co(r,r.begin,{key:"beginScope"}),r.begin=jr(r.begin,{joinWith:""})}}function ac(r){if(Array.isArray(r.end)){if(r.skip||r.excludeEnd||r.returnEnd)throw gn("skip, excludeEnd, returnEnd not compatible with endScope: {}"),lr;if(typeof r.endScope!="object"||r.endScope===null)throw gn("endScope must be object"),lr;Co(r,r.end,{key:"endScope"}),r.end=jr(r.end,{joinWith:""})}}function lc(r){r.scope&&typeof r.scope=="object"&&r.scope!==null&&(r.beginScope=r.scope,delete r.scope)}function cc(r){lc(r),typeof r.beginScope=="string"&&(r.beginScope={_wrap:r.beginScope}),typeof r.endScope=="string"&&(r.endScope={_wrap:r.endScope}),ic(r),ac(r)}function dc(r){function a(f,h){return new RegExp(Hn(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,w){w.position=this.position++,this.matchIndexes[this.matchAt]=w,this.regexes.push([w,h]),this.matchAt+=ko(h)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);let h=this.regexes.map(w=>w[1]);this.matcherRe=a(jr(h,{joinWith:"|"}),!0),this.lastIndex=0}exec(h){this.matcherRe.lastIndex=this.lastIndex;let w=this.matcherRe.exec(h);if(!w)return null;let k=w.findIndex((I,M)=>M>0&&I!==void 0),A=this.matchIndexes[k];return w.splice(0,k),Object.assign(w,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 w=new l;return this.rules.slice(h).forEach(([k,A])=>w.addRule(k,A)),w.compile(),this.multiRegexes[h]=w,w}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(h,w){this.rules.push([h,w]),w.type==="begin"&&this.count++}exec(h){let w=this.getMatcher(this.regexIndex);w.lastIndex=this.lastIndex;let k=w.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(w=>h.addRule(w.begin,{rule:w,type:"begin"})),f.terminatorEnd&&h.addRule(f.terminatorEnd,{type:"end"}),f.illegal&&h.addRule(f.illegal,{type:"illegal"}),h}function m(f,h){let w=f;if(f.isCompiled)return w;[Xl,Ql,cc,tc].forEach(A=>A(f,h)),r.compilerExtensions.forEach(A=>A(f,h)),f.__beforeBegin=null,[Yl,Jl,ec].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=To(f.keywords,r.case_insensitive)),w.keywordPatternRe=a(k,!0),h&&(f.begin||(f.begin=/\B|\b/),w.beginRe=a(w.begin),!f.end&&!f.endsWithParent&&(f.end=/\B|\b/),f.end&&(w.endRe=a(w.end)),w.terminatorEnd=Hn(w.end)||"",f.endsWithParent&&h.terminatorEnd&&(w.terminatorEnd+=(f.end?"|":"")+h.terminatorEnd)),f.illegal&&(w.illegalRe=a(f.illegal)),f.contains||(f.contains=[]),f.contains=[].concat(...f.contains.map(function(A){return uc(A==="self"?f:A)})),f.contains.forEach(function(A){m(A,w)}),f.starts&&m(f.starts,h),w.matcher=u(w),w}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=dn(r.classNameAliases||{}),m(r)}function No(r){return r?r.endsWithParent||No(r.starts):!1}function uc(r){return r.variants&&!r.cachedVariants&&(r.cachedVariants=r.variants.map(function(a){return dn(r,{variants:null},a)})),r.cachedVariants?r.cachedVariants:No(r)?dn(r,{starts:r.starts?dn(r.starts):null}):Object.isFrozen(r)?dn(r):r}var pc="11.11.1",Hr=class extends Error{constructor(a,l){super(a),this.name="HTMLInjectionError",this.html=l}},qr=xo,bo=dn,yo=Symbol("nomatch"),hc=7,$o=function(r){let a=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:Ur};function w(F){return h.noHighlightRe.test(F)}function k(F){let J=F.className+" ";J+=F.parentNode?F.parentNode.className:"";let U=h.languageDetectRe.exec(J);if(U){let fe=be(U[1]);return fe||(go(m.replace("{}",U[1])),go("Falling back to no-highlight mode for this block.",F)),fe?U[1]:"no-highlight"}return J.split(/\s+/).find(fe=>w(fe)||be(fe))}function A(F,J,U){let fe="",Ee="";typeof J=="object"?(fe=F,U=J.ignoreIllegals,Ee=J.language):(Cn("10.7.0","highlight(lang, code, ...args) has been deprecated."),Cn("10.7.0",`Please use highlight(code, options) instead.
3
- https://github.com/highlightjs/highlight.js/issues/2277`),Ee=F,fe=J),U===void 0&&(U=!0);let ze={code:fe,language:Ee};qe("before:highlight",ze);let Ne=ze.result?ze.result:I(ze.language,ze.code,U);return Ne.code=ze.code,qe("after:highlight",Ne),Ne}function I(F,J,U,fe){let Ee=Object.create(null);function ze(re,ke){return re.keywords[ke]}function Ne(){if(!B.keywords){Y.addText(ge);return}let re=0;B.keywordPatternRe.lastIndex=0;let ke=B.keywordPatternRe.exec(ge),He="";for(;ke;){He+=ge.substring(re,ke.index);let _e=we.case_insensitive?ke[0].toLowerCase():ke[0],Le=ze(B,_e);if(Le){let[Qe,Oe]=Le;if(Y.addText(He),He="",Ee[_e]=(Ee[_e]||0)+1,Ee[_e]<=hc&&(V+=Oe),Qe.startsWith("_"))He+=ke[0];else{let Ye=we.classNameAliases[Qe]||Qe;O(ke[0],Ye)}}else He+=ke[0];re=B.keywordPatternRe.lastIndex,ke=B.keywordPatternRe.exec(ge)}He+=ge.substring(re),Y.addText(He)}function s(){if(ge==="")return;let re=null;if(typeof B.subLanguage=="string"){if(!a[B.subLanguage]){Y.addText(ge);return}re=I(B.subLanguage,ge,!0,X[B.subLanguage]),X[B.subLanguage]=re._top}else re=C(ge,B.subLanguage.length?B.subLanguage:null);B.relevance>0&&(V+=re.relevance),Y.__addSublanguage(re._emitter,re.language)}function o(){B.subLanguage!=null?s():Ne(),ge=""}function O(re,ke){re!==""&&(Y.startScope(ke),Y.addText(re),Y.endScope())}function Be(re,ke){let He=1,_e=ke.length-1;for(;He<=_e;){if(!re._emit[He]){He++;continue}let Le=we.classNameAliases[re[He]]||re[He],Qe=ke[He];Le?O(Qe,Le):(ge=Qe,Ne(),ge=""),He++}}function P(re,ke){return re.scope&&typeof re.scope=="string"&&Y.openNode(we.classNameAliases[re.scope]||re.scope),re.beginScope&&(re.beginScope._wrap?(O(ge,we.classNameAliases[re.beginScope._wrap]||re.beginScope._wrap),ge=""):re.beginScope._multi&&(Be(re.beginScope,ke),ge="")),B=Object.create(re,{parent:{value:B}}),B}function Ue(re,ke,He){let _e=$l(re.endRe,He);if(_e){if(re["on:end"]){let Le=new ar(re);re["on:end"](ke,Le),Le.isMatchIgnored&&(_e=!1)}if(_e){for(;re.endsParent&&re.parent;)re=re.parent;return re}}if(re.endsWithParent)return Ue(re.parent,ke,He)}function nt(re){return B.matcher.regexIndex===0?(ge+=re[0],1):(Je=!0,0)}function W(re){let ke=re[0],He=re.rule,_e=new ar(He),Le=[He.__beforeBegin,He["on:begin"]];for(let Qe of Le)if(Qe&&(Qe(re,_e),_e.isMatchIgnored))return nt(ke);return He.skip?ge+=ke:(He.excludeBegin&&(ge+=ke),o(),!He.returnBegin&&!He.excludeBegin&&(ge=ke)),P(He,re),He.returnBegin?0:ke.length}function Ae(re){let ke=re[0],He=J.substring(re.index),_e=Ue(B,re,He);if(!_e)return yo;let Le=B;B.endScope&&B.endScope._wrap?(o(),O(ke,B.endScope._wrap)):B.endScope&&B.endScope._multi?(o(),Be(B.endScope,re)):Le.skip?ge+=ke:(Le.returnEnd||Le.excludeEnd||(ge+=ke),o(),Le.excludeEnd&&(ge=ke));do B.scope&&Y.closeNode(),!B.skip&&!B.subLanguage&&(V+=B.relevance),B=B.parent;while(B!==_e.parent);return _e.starts&&P(_e.starts,re),Le.returnEnd?0:ke.length}function Q(){let re=[];for(let ke=B;ke!==we;ke=ke.parent)ke.scope&&re.unshift(ke.scope);re.forEach(ke=>Y.openNode(ke))}let ye={};function x(re,ke){let He=ke&&ke[0];if(ge+=re,He==null)return o(),0;if(ye.type==="begin"&&ke.type==="end"&&ye.index===ke.index&&He===""){if(ge+=J.slice(ke.index,ke.index+1),!u){let _e=new Error(`0 width match regex (${F})`);throw _e.languageName=F,_e.badRule=ye.rule,_e}return 1}if(ye=ke,ke.type==="begin")return W(ke);if(ke.type==="illegal"&&!U){let _e=new Error('Illegal lexeme "'+He+'" for mode "'+(B.scope||"<unnamed>")+'"');throw _e.mode=B,_e}else if(ke.type==="end"){let _e=Ae(ke);if(_e!==yo)return _e}if(ke.type==="illegal"&&He==="")return ge+=`
4
- `,1;if(Fe>1e5&&Fe>ke.index*3)throw new Error("potential infinite loop, way more iterations than matches");return ge+=He,He.length}let we=be(F);if(!we)throw gn(m.replace("{}",F)),new Error('Unknown language: "'+F+'"');let g=dc(we),G="",B=fe||g,X={},Y=new h.__emitter(h);Q();let ge="",V=0,ne=0,Fe=0,Je=!1;try{if(we.__emitTokens)we.__emitTokens(J,Y);else{for(B.matcher.considerAll();;){Fe++,Je?Je=!1:B.matcher.considerAll(),B.matcher.lastIndex=ne;let re=B.matcher.exec(J);if(!re)break;let ke=J.substring(ne,re.index),He=x(ke,re);ne=re.index+He}x(J.substring(ne))}return Y.finalize(),G=Y.toHTML(),{language:F,value:G,relevance:V,illegal:!1,_emitter:Y,_top:B}}catch(re){if(re.message&&re.message.includes("Illegal"))return{language:F,value:qr(J),illegal:!0,relevance:0,_illegalBy:{message:re.message,index:ne,context:J.slice(ne-100,ne+100),mode:re.mode,resultSoFar:G},_emitter:Y};if(u)return{language:F,value:qr(J),illegal:!1,relevance:0,errorRaised:re,_emitter:Y,_top:B};throw re}}function M(F){let J={value:qr(F),illegal:!1,relevance:0,_top:f,_emitter:new h.__emitter(h)};return J._emitter.addText(F),J}function C(F,J){J=J||h.languages||Object.keys(a);let U=M(F),fe=J.filter(be).filter(Xe).map(o=>I(o,F,!1));fe.unshift(U);let Ee=fe.sort((o,O)=>{if(o.relevance!==O.relevance)return O.relevance-o.relevance;if(o.language&&O.language){if(be(o.language).supersetOf===O.language)return 1;if(be(O.language).supersetOf===o.language)return-1}return 0}),[ze,Ne]=Ee,s=ze;return s.secondBest=Ne,s}function $(F,J,U){let fe=J&&l[J]||U;F.classList.add("hljs"),F.classList.add(`language-${fe}`)}function q(F){let J=null,U=k(F);if(w(U))return;if(qe("before:highlightElement",{el:F,language:U}),F.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",F);return}if(F.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(F)),h.throwUnescapedHTML))throw new Hr("One of your code blocks includes unescaped HTML.",F.innerHTML);J=F;let fe=J.textContent,Ee=U?A(fe,{language:U,ignoreIllegals:!0}):C(fe);F.innerHTML=Ee.value,F.dataset.highlighted="yes",$(F,U,Ee.language),F.result={language:Ee.language,re:Ee.relevance,relevance:Ee.relevance},Ee.secondBest&&(F.secondBest={language:Ee.secondBest.language,relevance:Ee.secondBest.relevance}),qe("after:highlightElement",{el:F,result:Ee,text:fe})}function he(F){h=bo(h,F)}let oe=()=>{me(),Cn("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function de(){me(),Cn("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let j=!1;function me(){function F(){me()}if(document.readyState==="loading"){j||window.addEventListener("DOMContentLoaded",F,!1),j=!0;return}document.querySelectorAll(h.cssSelector).forEach(q)}function Te(F,J){let U=null;try{U=J(r)}catch(fe){if(gn("Language definition for '{}' could not be registered.".replace("{}",F)),u)gn(fe);else throw fe;U=f}U.name||(U.name=F),a[F]=U,U.rawDefinition=J.bind(null,r),U.aliases&&Ce(U.aliases,{languageName:F})}function $e(F){delete a[F];for(let J of Object.keys(l))l[J]===F&&delete l[J]}function Re(){return Object.keys(a)}function be(F){return F=(F||"").toLowerCase(),a[F]||a[l[F]]}function Ce(F,{languageName:J}){typeof F=="string"&&(F=[F]),F.forEach(U=>{l[U.toLowerCase()]=J})}function Xe(F){let J=be(F);return J&&!J.disableAutodetect}function xe(F){F["before:highlightBlock"]&&!F["before:highlightElement"]&&(F["before:highlightElement"]=J=>{F["before:highlightBlock"](Object.assign({block:J.el},J))}),F["after:highlightBlock"]&&!F["after:highlightElement"]&&(F["after:highlightElement"]=J=>{F["after:highlightBlock"](Object.assign({block:J.el},J))})}function E(F){xe(F),d.push(F)}function Ie(F){let J=d.indexOf(F);J!==-1&&d.splice(J,1)}function qe(F,J){let U=F;d.forEach(function(fe){fe[U]&&fe[U](J)})}function De(F){return Cn("10.7.0","highlightBlock will be removed entirely in v12.0"),Cn("10.7.0","Please use highlightElement now."),q(F)}Object.assign(r,{highlight:A,highlightAuto:C,highlightAll:me,highlightElement:q,highlightBlock:De,configure:he,initHighlighting:oe,initHighlightingOnLoad:de,registerLanguage:Te,unregisterLanguage:$e,listLanguages:Re,getLanguage:be,registerAliases:Ce,autoDetection:Xe,inherit:bo,addPlugin:E,removePlugin:Ie}),r.debugMode=function(){u=!1},r.safeMode=function(){u=!0},r.versionString=pc,r.regex={concat:bn,lookahead:vo,either:Gr,optional:Cl,anyNumberOfTimes:Tl};for(let F in ir)typeof ir[F]=="object"&&wo(ir[F]);return Object.assign(r,ir),r},Nn=$o({});Nn.newInstance=()=>$o({});Oo.exports=Nn;Nn.HighlightJS=Nn;Nn.default=Nn});var Md={};Ka(Md,{init:()=>$d,initTerminals:()=>Od,registerBuildProvider:()=>Kn,version:()=>Nd});ae();le();ae();le();ae();le();var Ya=new Set(["UL","OL","TABLE","TBODY","DL","SVG"]),Ja=new Set(["defs","title","desc","style","metadata"]),Ks=new Map;function Ws(r,a){Ks.set(r,a)}function sr(r){return[...r.children].filter(a=>{let l=a.tagName.toLowerCase();return!(Ja.has(l)||l==="aside"&&a.classList.contains("notes")||a.hasAttribute("data-build-stay"))})}function Qa(r){if(r.hasAttribute("data-build-self"))return!1;let a=r.tagName.toUpperCase();return Ya.has(a)?!0:a==="DIV"||a==="G"?sr(r).length>=2:!1}function el(r){if(r.tagName.toUpperCase()==="TABLE"){let l=r.querySelector(":scope > tbody");return l?sr(l):sr(r).filter(d=>d.tagName==="TR")}return sr(r)}function tl(r){let a=r.map((f,h)=>({...f,i:h}));a.sort((f,h)=>f.key-h.key||f.i-h.i);let l=[],d=null,u=null,m=!1;for(let f of a){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 Gs(r,a){r.classList.add("build-step"),r.setAttribute("data-build-style",a),r.setAttribute("data-build-state","pending"),a==="draw"&&nl(r)}var js="path, line, polyline, polygon, circle, ellipse, rect";function nl(r){let a=r.matches?.(js)?[r]:[...r.querySelectorAll(js)],l=!1;for(let u of a){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[w,k]of Br){let A=u.getAttribute(w);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 Br=[["marker-start","drawMarkerStart"],["marker-mid","drawMarkerMid"],["marker-end","drawMarkerEnd"]];function rr(r,a){for(let[l,d]of Br)d in r.dataset&&(a?r.setAttribute(l,r.dataset[d]):r.removeAttribute(l))}function rl(r,a){for(let l of r.querySelectorAll(".draw-stroke")){let d=l.dataset.drawOrig,u=Br.some(([,m])=>m in l.dataset);if(!(!d&&!u))if(a==="done")d&&(l.style.strokeDasharray=d,l.style.strokeDashoffset="0"),rr(l,!0);else if(a==="pending")l.style.removeProperty("stroke-dasharray"),l.style.removeProperty("stroke-dashoffset"),rr(l,!1);else{l.style.removeProperty("stroke-dasharray"),l.style.removeProperty("stroke-dashoffset"),rr(l,!1);let m=()=>{r.getAttribute("data-build-state")!=="pending"&&(d&&(l.style.strokeDasharray=d,l.style.strokeDashoffset="0"),rr(l,!0))},f=parseFloat(getComputedStyle(l).transitionDuration)||0;f===0?m():(l.addEventListener("transitionend",m,{once:!0}),setTimeout(m,f*1e3+150))}}}function Pr(r){let a=[],l=[],d=new Set,u=0,m=(A,I)=>{let M=I!=null&&I!=="",C=M?parseInt(I,10):u;a.push(A),l.push({key:Number.isFinite(C)?C: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 I=Ks.get(A);if(I){for(let C=0;C<I.count;C++)m({kind:"provider",provider:I,el:A,sub:C},null);A.querySelectorAll("*").forEach(C=>d.add(C));continue}if(!A.hasAttribute("data-build"))continue;let M=A.getAttribute("data-build")||"fade";if(Qa(A)){for(let C of el(A)){d.add(C),C.querySelectorAll("[data-build]").forEach(q=>d.add(q));let $=C.getAttribute("data-build")||M;Gs(C,$),m({kind:"dom",el:C,container:A},C.getAttribute("data-build-order"))}A.setAttribute("data-build-container","")}else Gs(A,M),m({kind:"dom",el:A,container:null},A.getAttribute("data-build-order"))}let h=tl(l),w=[],k=new Map;return a.forEach((A,I)=>{if(A.kind==="provider"){if(!k.has(A.provider)){let M={el:A.el,provider:A.provider,stepIdxs:[]};k.set(A.provider,M),w.push(M)}k.get(A.provider).stepIdxs.push(I)}}),{steps:a,groups:h,providers:w}}function cn(r,a){let l=new Set;r.groups.forEach((f,h)=>{for(let w of f)h<a&&l.add(w)});let d=a>0?r.groups[a-1]??[]:[],u=new Set(d),m=new Set;r.steps.forEach((f,h)=>{if(f.kind!=="dom")return;let w=u.has(h)?"current":l.has(h)?"done":"pending";f.el.setAttribute("data-build-state",w),f.el.getAttribute("data-build-style")==="draw"&&rl(f.el,w),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(w=>l.has(w)||u.has(w)).length;f._last!==h&&(f._last=h,f.provider.apply(h))}}function Vs(r){return r.groups.map(a=>{let l=r.steps[a[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()})}ae();le();var Zs="rect, circle, ellipse, polygon, polyline, path";function sl(r){let a=5381;for(let l of String(r))a=(a*33^l.charCodeAt(0))>>>0;return 1+a%6}function ol(r,a={}){let l=a[r];return typeof l=="number"?`var(--d-fill-${l})`:typeof l=="string"?l:`var(--d-fill-${sl(r)})`}function Xs(r,a={}){let l=new Map;r.querySelectorAll("svg [data-concept]").forEach(d=>{let u=d.getAttribute("data-concept");if(!u)return;let m=ol(u,a),f=m.match(/--d-fill-(\d)/);if(f){let w=l.get(f[1]);w&&w!==u?console.warn(`Decklight: concepts "${w}" 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(Zs)?[d]:[...d.children].filter(w=>w.matches(Zs));for(let w of h){let k=w.getAttribute("fill")==="none"||w.style.fill==="none";w.style.setProperty(k?"stroke":"fill",m)}})}var il=["fill","stroke","filter","clip-path","mask","marker-start","marker-mid","marker-end","style"];function Ys(r){r.querySelectorAll("svg").forEach((a,l)=>{let d=`svg${l}-`,u=new Map;if(a.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,w)=>u.has(w)?`url(#${u.get(w)})`:h);a.querySelectorAll("*").forEach(f=>{for(let h of il){let w=f.getAttribute(h);w&&w.includes("url(#")&&f.setAttribute(h,m(w))}for(let h of["href","xlink:href"]){let w=f.getAttribute(h);w&&w.startsWith("#")&&u.has(w.slice(1))&&f.setAttribute(h,"#"+u.get(w.slice(1)))}})})}ae();le();ae();le();var vt=r=>String(r).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");var Js=640,al=360,Qs=["bar","line","area","pie","donut"],ve=r=>{let a=Math.round(r*100)/100;return Object.is(a,-0)?"0":String(a)},_n=r=>`var(--d-fill-${r%6+1})`;function ll(r,a={}){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(a.type||l.type||"").toLowerCase();if(!Qs.includes(d))throw new Error(`unknown type "${d}" \u2014 use ${Qs.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((I,M)=>{let C=Number(k.data[M]);return Number.isFinite(C)?C: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=al,w=a.aspect??l.aspect??null;if(w!=null){let k=String(w).match(/^\s*(\d+(?:\.\d+)?)\s*[:x]\s*(\d+(?:\.\d+)?)\s*$/i);if(!k||+k[1]==0)throw new Error(`bad aspect "${w}" \u2014 use "w:h", e.g. "4:3"`);h=Math.round(Js*+k[2]/+k[1])}return{type:f?"pie":d,donut:d==="donut"||l.donut===!0,title:a.title??(l.title!=null?String(l.title):null),labels:u,series:m,legend:l.legend,width:Js,height:h,build:l.build}}function cl(r,a,l=5){if(!Number.isFinite(r)||!Number.isFinite(a))throw new Error("niceTicks: non-finite range");if(r>a&&([r,a]=[a,r]),r===a){let I=r===0?1:Math.abs(r)/2;r-=r===0?0:I,a+=I}let d=(a-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,w=Math.ceil(a/f-1e-9)*f,k=Math.max(1,Math.round((w-h)/f)),A=Array.from({length:k+1},(I,M)=>+(h+M*f).toPrecision(12));return{min:A[0],max:A[k],step:f,ticks:A}}function dl(r,a){let l=0;for(;l<6&&Math.abs(Math.round(a*10**l)-a*10**l)>1e-9;)l++;return r.toFixed(l)}function ul(r,a,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/a,w=h*.72,k=w/r.length;return r.map((A,I)=>Array.from({length:a},(M,C)=>{let $=A.data[C];if($==null||!Number.isFinite($))return null;let q=m($);return{x:l.x+C*h+(h-w)/2+I*k+1,y:Math.min(q,f),w:Math.max(1,k-2),h:Math.abs(f-q),value:$}}))}function pl(r){let a="",l=!1;for(let d of r){if(!d){l=!1;continue}a+=`${l?"L":"M"}${ve(d.x)} ${ve(d.y)}`,l=!0}return a}function hl(r,a){let l=r.filter(Boolean);if(!l.length)return"";let d=`M${ve(l[0].x)} ${ve(a)}`;for(let u of l)d+=`L${ve(u.x)} ${ve(u.y)}`;return d+=`L${ve(l[l.length-1].x)} ${ve(a)}Z`,d}function ml(r,a,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)=>[a+A*Math.cos(k),l+A*Math.sin(k)],w=-Math.PI/2;return m.map(k=>{let A=k/f,I=w,M=w+A*2*Math.PI;w=M;let C=(I+M)/2,$=u>0?(d+u)/2:d*.66,[q,he]=h(C,$),[oe,de]=h(C,d+14),j={value:k,frac:A,mid:C,labelX:q,labelY:he,outX:oe,outY:de,anchor:Math.cos(C)<-1e-6?"end":Math.cos(C)>1e-6?"start":"middle"};if(A===0)return{...j,d:""};let me;if(A>=.9999){let[Te,$e]=h(I,d),[Re,be]=h(I+Math.PI,d);if(me=`M${ve(Te)} ${ve($e)}A${ve(d)} ${ve(d)} 0 1 1 ${ve(Re)} ${ve(be)}A${ve(d)} ${ve(d)} 0 1 1 ${ve(Te)} ${ve($e)}Z`,u>0){let[Ce,Xe]=h(I,u),[xe,E]=h(I+Math.PI,u);me+=`M${ve(Ce)} ${ve(Xe)}A${ve(u)} ${ve(u)} 0 1 0 ${ve(xe)} ${ve(E)}A${ve(u)} ${ve(u)} 0 1 0 ${ve(Ce)} ${ve(Xe)}Z`}}else{let Te=M-I>Math.PI?1:0,[$e,Re]=h(I,d),[be,Ce]=h(M,d);if(u>0){let[Xe,xe]=h(M,u),[E,Ie]=h(I,u);me=`M${ve($e)} ${ve(Re)}A${ve(d)} ${ve(d)} 0 ${Te} 1 ${ve(be)} ${ve(Ce)}L${ve(Xe)} ${ve(xe)}A${ve(u)} ${ve(u)} 0 ${Te} 0 ${ve(E)} ${ve(Ie)}Z`}else me=`M${ve(a)} ${ve(l)}L${ve($e)} ${ve(Re)}A${ve(d)} ${ve(d)} 0 ${Te} 1 ${ve(be)} ${ve(Ce)}Z`}return{...j,d:me}})}var Tn='fill="var(--d-text)"';function Dr(r,a){return`<g class="chart-series" data-series="${a+1}" data-name="${vt(r.name)}"`+(r.concept?` data-concept="${vt(r.concept)}"`:"")+">"}function fl(r,a,l){let d=r.series.flatMap($=>$.data).filter($=>$!=null),u=Math.min(0,...d),m=Math.max(0,...d),f=cl(u,m===u?u+1:m,5),h=f.ticks.map($=>dl($,f.step)),w=14+Math.max(...h.map($=>$.length))*6.6+8,k={x:w,y:r.title||eo(r)?40:18,w:r.width-w-14,h:0};k.h=r.height-k.y-34;let A=f.max-f.min||1,I=$=>k.y+k.h*(1-($-f.min)/A);f.ticks.forEach(($,q)=>{let he=I($);a.push(`<line class="chart-grid" x1="${ve(k.x)}" y1="${ve(he)}" x2="${ve(k.x+k.w)}" y2="${ve(he)}" stroke="var(--d-muted)" stroke-opacity="0.35" stroke-width="1"/>`),a.push(`<text class="chart-tick" x="${ve(k.x-8)}" y="${ve(he+4)}" text-anchor="end" font-size="11" ${Tn}>${vt(h[q])}</text>`)}),a.push(`<line class="chart-axis" x1="${ve(k.x)}" y1="${ve(k.y)}" x2="${ve(k.x)}" y2="${ve(k.y+k.h)}" stroke="var(--d-stroke)" stroke-width="1.5"/>`);let M=I(Math.max(f.min,Math.min(f.max,0)));a.push(`<line class="chart-axis" x1="${ve(k.x)}" y1="${ve(M)}" x2="${ve(k.x+k.w)}" y2="${ve(M)}" stroke="var(--d-stroke)" stroke-width="1.5"/>`);let C=k.w/r.labels.length;if(r.labels.forEach(($,q)=>{a.push(`<text class="chart-cat" x="${ve(k.x+(q+.5)*C)}" y="${ve(k.y+k.h+20)}" text-anchor="middle" font-size="12" ${Tn}>${vt($)}</text>`)}),r.type==="bar"){let $=ul(r.series,r.labels.length,k,f);r.series.forEach((q,he)=>{l.push(Dr(q,he)),$[he].forEach(oe=>{oe&&l.push(`<rect class="chart-bar draw-fade" x="${ve(oe.x)}" y="${ve(oe.y)}" width="${ve(oe.w)}" height="${ve(oe.h)}" rx="2" fill="${_n(he)}" stroke="var(--d-stroke)" stroke-width="1.5"/>`)}),l.push("</g>")})}else r.series.forEach(($,q)=>{let he=$.data.map((j,me)=>j==null?null:{x:k.x+(me+.5)*C,y:I(j)}),oe=pl(he),de='stroke-linejoin="round" stroke-linecap="round"';if(l.push(Dr($,q)),r.type==="area"&&l.push(`<path class="chart-area draw-fade" d="${hl(he,M)}" fill="${_n(q)}" fill-opacity="0.35"/>`),l.push(`<g class="chart-casing"><path d="${oe}" fill="none" stroke="var(--d-stroke)" stroke-width="4.5" ${de}/></g>`),l.push(`<path class="chart-line" d="${oe}" fill="none" stroke="${_n(q)}" stroke-width="2.5" ${de}/>`),r.type==="line")for(let j of he)j&&l.push(`<circle class="chart-dot draw-fade" cx="${ve(j.x)}" cy="${ve(j.y)}" r="4" fill="${_n(q)}" stroke="var(--d-stroke)" stroke-width="1"/>`);l.push("</g>")})}function gl(r,a){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=ml(r.series[0].data.map(h=>h??0),d,u,m,r.donut?m*.55:0);a.push(Dr(r.series[0],0)),f.forEach((h,w)=>{h.d&&(a.push(`<path class="chart-slice draw-fade" d="${h.d}" fill="${_n(w)}" fill-rule="evenodd" stroke="var(--d-stroke)" stroke-width="1.5" stroke-linejoin="round"/>`),a.push(`<text class="chart-cat draw-fade" x="${ve(h.outX)}" y="${ve(h.outY+4)}" text-anchor="${h.anchor}" font-size="12" ${Tn}>${vt(r.labels[w])}</text>`),h.frac>=.05&&a.push(`<text class="chart-value draw-fade" x="${ve(h.labelX)}" y="${ve(h.labelY+4)}" text-anchor="middle" font-size="12" font-weight="600" ${Tn}>${Math.round(h.frac*100)}%</text>`))}),a.push("</g>")}function eo(r){return r.legend===!0?!0:r.legend===!1?!1:r.type!=="pie"&&r.series.length>1}function bl(r){let a=[],l=[];if(r.title&&a.push(`<text class="chart-title" x="14" y="24" font-size="15" font-weight="600" ${Tn}>${vt(r.title)}</text>`),eo(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)=>{a.push(`<rect class="chart-swatch" x="${ve(m)}" y="14" width="11" height="11" rx="2" fill="${_n(h)}" stroke="var(--d-stroke)" stroke-width="1"/>`),a.push(`<text class="chart-legend" x="${ve(m+16)}" y="24" font-size="12" ${Tn}>${vt(f.name)}</text>`),m+=u[h].w})}r.type==="pie"?gl(r,l):fl(r,a,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="${vt(d)}" preserveAspectRatio="xMidYMid meet"><g class="chart-chrome" data-build-stay>${a.join("")}</g>`+l.join("")+"</svg>"}function to(r){r.querySelectorAll("[data-chart]").forEach(a=>{if(a.querySelector(":scope > svg.chart-svg, :scope > .chart-broken"))return;a.classList.add("chart");let l=a.querySelector('script[type="application/json"]');try{let d=ll(l?l.textContent:null,{type:a.getAttribute("data-chart")||void 0,title:a.getAttribute("data-title")||void 0,aspect:a.getAttribute("data-aspect")||void 0}),u=document.createElement("template");u.innerHTML=bl(d);let m=u.content.firstElementChild;a.hasAttribute("data-build")?(m.setAttribute("data-build",a.getAttribute("data-build")),a.removeAttribute("data-build")):d.build!=null&&d.build!==!1&&m.setAttribute("data-build",d.build===!0?"":String(d.build)),a.getAttribute("data-chart")||a.setAttribute("data-chart",d.donut?"donut":d.type),a.insertBefore(m,l)}catch(d){let u=document.createElement("div");u.className="chart-broken",u.textContent=`chart: ${d.message||d}`,a.insertBefore(u,l)}})}ae();le();ae();le();function or(r,a){let l=String(r??"").trim(),d=parseFloat(l);return!Number.isFinite(d)||d<=0?a:l.endsWith("ms")?d:l.endsWith("s")?d*1e3:d}var Un=["opacity","color","backgroundColor","borderRadius","fontSize"],no=(r=Un)=>["transform",...r.map(a=>a.replace(/[A-Z]/g,l=>`-${l.toLowerCase()}`))];function ro(r,a,l,d=!1){let u=l?.x||1,m=l?.y||1,f=(r.rect.left-a.rect.left)/u,h=(r.rect.top-a.rect.top)/m,w=d||!a.rect.width?1:r.rect.width/a.rect.width,k=d||!a.rect.height?1:r.rect.height/a.rect.height;return{dx:f,dy:h,sx:w,sy:k}}function so({dx:r,dy:a,sx:l,sy:d}){return!r&&!a&&l===1&&d===1?"":`translate(${r}px, ${a}px) scale(${l}, ${d})`}var oo=(r,a)=>r||a||"fade";function io(r,a){if(r==="none")return null;let l=`dir-${a}`;return{entering:["entering",`tr-${r}`,l],leaving:["leaving",`tr-${r}`,l,"active-out"]}}var yl=no();function ao(r){let a=getComputedStyle(r),l={rect:r.getBoundingClientRect()};for(let d of Un)l[d]=a[d];return l}function wl(r,a){if(r.ownerSVGElement){let l=r.getScreenCTM?.();if(l&&l.a&&l.d)return{x:l.a,y:l.d}}return{x:a,y:a}}function lo(r,a,l){let d=or(getComputedStyle(a).getPropertyValue("--auto-animate-duration"),500),u=new Map;r.querySelectorAll("[data-id]").forEach(h=>{u.set(h.getAttribute("data-id"),ao(h))});let m=[];a.querySelectorAll("[data-id]").forEach(h=>{let w=u.get(h.getAttribute("data-id"));w&&m.push({el:h,o:w})});for(let{el:h,o:w}of m){let k=ao(h),A=wl(h,l),I=h.children.length===0&&w.fontSize!==k.fontSize,M=ro(w,k,A,I),C=h.getAttribute("style")??"";h.style.transition="none",h.ownerSVGElement&&(h.style.transformBox="fill-box"),h.style.transformOrigin="0 0",h.style.transform=so(M);for(let q of Un)h.style[q]=w[q];h.offsetWidth,h.style.transition=yl.map(q=>`${q} ${d}ms ease`).join(", "),h.style.transform="";for(let q of Un)h.style[q]=k[q];let $=()=>{C?h.setAttribute("style",C):h.removeAttribute("style"),h.removeEventListener("transitionend",$)};h.addEventListener("transitionend",$),setTimeout($,d+80)}let f=new Set(m.map(h=>h.el));return[...a.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}ae();le();ae();le();var co=function(){"use strict";class r{constructor(t,n){let i,c=" "+t,p=n&&n.loc;if(p&&p.start<=p.end){let v=p.lexer.input;i=p.start;let D=p.end;i===v.length?c+=" at end of input: ":c+=" at position "+(i+1)+`:
5
- `;let z=v.slice(i,D).replace(/[^]/g,"$&\u0332"),se,ce;se=i>15?"\u2026"+v.slice(i-15,i):v.slice(0,i),ce=D+15<v.length?v.slice(D,D+15)+"\u2026":v.slice(D),c+=se+z+ce}let b=new Error(c);return b.name="ParseError",b.__proto__=r.prototype,b.position=i,b}}r.prototype.__proto__=Error.prototype;let a=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},w=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 I{constructor(t){t=t||{},this.displayMode=a(t.displayMode,!1),this.annotate=a(t.annotate,!1),this.leqno=a(t.leqno,!1),this.throwOnError=a(t.throwOnError,!1),this.errorColor=a(t.errorColor,"#b22222"),this.macros=t.macros||{},this.wrap=a(t.wrap,"none"),this.xml=a(t.xml,!1),this.colorIsTextColor=a(t.colorIsTextColor,!1),this.strict=a(t.strict,!1),this.trust=a(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,a(t.maxExpand,1e3)),this.wrapDelimiterPairs=!0}isTrusted(t){if(t.url&&!t.protocol){let i=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(i==null)return!1;t.protocol=i}return!!(typeof this.trust=="function"?this.trust(t):this.trust)}}let M={},C={};function $({type:e,names:t,props:n,handler:i,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:i};for(let b=0;b<t.length;++b)M[t[b]]=p;e&&c&&(C[e]=c)}function q({type:e,mathmlBuilder:t}){$({type:e,names:[],props:{numArgs:0},handler(){throw new Error("Should never be called.")},mathmlBuilder:t})}let he=function(e){return e.type==="ordgroup"&&e.body.length===1?e.body[0]:e},oe=function(e){return e.type==="ordgroup"?e.body:[e]};class de{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(" ")},me=function(e,t){this.classes=e||[],this.attributes={},this.style=t||{}},Te=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},$e=function(e){let t=`<${e}`;this.classes.length&&(t+=` class="${f(j(this.classes))}"`);let n="";for(let i in this.style)Object.prototype.hasOwnProperty.call(this.style,i)&&(n+=`${d(i)}:${this.style[i]};`);n&&(t+=` style="${n}"`);for(let i in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,i)&&(t+=` ${i}="${f(this.attributes[i])}"`);t+=">";for(let i=0;i<this.children.length;i++)t+=this.children[i].toMarkup();return t+=`</${e}>`,t};class Re{constructor(t,n,i){me.call(this,t,i),this.children=n||[]}setAttribute(t,n){this.attributes[t]=n}toNode(){return Te.call(this,"span")}toMarkup(){return $e.call(this,"span")}}let be=class{constructor(e){this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return f(this.text)}};class Ce{constructor(t,n,i){this.href=t,this.classes=n,this.children=i||[]}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 Xe{constructor(t,n,i){this.alt=n,this.src=t,this.classes=["mord"],this.style=i}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 i in this.style)Object.prototype.hasOwnProperty.call(this.style,i)&&(n+=`${d(i)}:${this.style[i]};`);return n&&(t+=` style="${f(n)}"`),t+=">",t}}function xe(e){return new de(e)}class E{constructor(t,n,i,c){this.type=t,this.attributes={},this.children=n||[],this.classes=i||[],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 i in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,i)&&(t+=" "+i+'="',t+=f(this.attributes[i]),t+='"');this.classes.length>0&&(t+=` class="${f(j(this.classes))}"`);let n="";for(let i in this.style)Object.prototype.hasOwnProperty.call(this.style,i)&&(n+=`${d(i)}:${this.style[i]};`);n&&(t+=` style="${n}"`),t+=">";for(let i=0;i<this.children.length;i++)t+=this.children[i].toMarkup();return t+="</"+this.type+">",t}toText(){return this.children.map(t=>t.toText()).join("")}}class Ie{constructor(t){this.text=t}toNode(){return document.createTextNode(this.text)}toMarkup(){return f(this.toText())}toText(){return this.text}}let qe=e=>{let t;return e.length===1&&e[0].type==="mrow"?(t=e.pop(),t.type="mstyle"):t=new E("mstyle",e),t},De=e=>{let t=0;if(e.body&&Array.isArray(e.body))for(let n of e.body)t+=De(n);else if(e.body)t+=De(e.body);else if(e.type==="supsub")t+=De(e.base),e.sub&&(t+=.7*De(e.sub)),e.sup&&(t+=.7*De(e.sup));else if(e.type==="mathord"||e.type==="textord")for(let n of e.text.split("")){let i=n.codePointAt(0);t+=96<i&&i<123||944<i&&i<970?.56:47<i&&i<58?.5:.92}else t+=1;return t},F={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 t=new Ie(F[e.slice(1)]),n=new E("mo",[t]);return n.setAttribute("stretchy","true"),n},U=["\\widetilde","\\widehat","\\widecheck","\\utilde"],fe=e=>{let t=J(e.label);if(U.includes(e.label)){let n=De(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},Ee={bin:1,close:1,inner:1,open:1,punct:1,rel:1},ze={"accent-token":1,mathord:1,"op-token":1,spacing:1,textord:1},Ne={math:{},text:{}};function s(e,t,n,i,c){Ne[e][i]={group:t,replace:n},c&&n&&(Ne[e][n]=Ne[e][i])}let o="math",O="text",Be="accent-token",P="bin",Ue="close",nt="inner",W="mathord",Ae="op-token",Q="open",ye="punct",x="rel",we="spacing",g="textord";s(o,x,"\u2261","\\equiv",!0),s(o,x,"\u227A","\\prec",!0),s(o,x,"\u227B","\\succ",!0),s(o,x,"\u223C","\\sim",!0),s(o,x,"\u27C2","\\perp",!0),s(o,x,"\u2AAF","\\preceq",!0),s(o,x,"\u2AB0","\\succeq",!0),s(o,x,"\u2243","\\simeq",!0),s(o,x,"\u224C","\\backcong",!0),s(o,x,"|","\\mid",!0),s(o,x,"\u226A","\\ll",!0),s(o,x,"\u226B","\\gg",!0),s(o,x,"\u224D","\\asymp",!0),s(o,x,"\u2225","\\parallel"),s(o,x,"\u2323","\\smile",!0),s(o,x,"\u2291","\\sqsubseteq",!0),s(o,x,"\u2292","\\sqsupseteq",!0),s(o,x,"\u2250","\\doteq",!0),s(o,x,"\u2322","\\frown",!0),s(o,x,"\u220B","\\ni",!0),s(o,x,"\u220C","\\notni",!0),s(o,x,"\u221D","\\propto",!0),s(o,x,"\u22A2","\\vdash",!0),s(o,x,"\u22A3","\\dashv",!0),s(o,x,"\u220B","\\owns"),s(o,x,"\u2258","\\arceq",!0),s(o,x,"\u2259","\\wedgeq",!0),s(o,x,"\u225A","\\veeeq",!0),s(o,x,"\u225B","\\stareq",!0),s(o,x,"\u225D","\\eqdef",!0),s(o,x,"\u225E","\\measeq",!0),s(o,x,"\u225F","\\questeq",!0),s(o,x,"\u2260","\\ne",!0),s(o,x,"\u2260","\\neq"),s(o,x,"\u2A75","\\eqeq",!0),s(o,x,"\u2A76","\\eqeqeq",!0),s(o,x,"\u2237","\\dblcolon",!0),s(o,x,"\u2254","\\coloneqq",!0),s(o,x,"\u2255","\\eqqcolon",!0),s(o,x,"\u2239","\\eqcolon",!0),s(o,x,"\u2A74","\\Coloneqq",!0),s(o,ye,".","\\ldotp"),s(o,ye,"\xB7","\\cdotp"),s(o,g,"#","\\#"),s(O,g,"#","\\#"),s(o,g,"&","\\&"),s(O,g,"&","\\&"),s(o,g,"\u2135","\\aleph",!0),s(o,g,"\u2200","\\forall",!0),s(o,g,"\u210F","\\hbar",!0),s(o,g,"\u2203","\\exists",!0),s(o,Q,"\u2207","\\nabla",!0),s(o,g,"\u266D","\\flat",!0),s(o,g,"\u2113","\\ell",!0),s(o,g,"\u266E","\\natural",!0),s(o,g,"\u212B","\\Angstrom",!0),s(O,g,"\u212B","\\Angstrom",!0),s(o,g,"\u2663","\\clubsuit",!0),s(o,g,"\u2667","\\varclubsuit",!0),s(o,g,"\u2118","\\wp",!0),s(o,g,"\u266F","\\sharp",!0),s(o,g,"\u2662","\\diamondsuit",!0),s(o,g,"\u2666","\\vardiamondsuit",!0),s(o,g,"\u211C","\\Re",!0),s(o,g,"\u2661","\\heartsuit",!0),s(o,g,"\u2665","\\varheartsuit",!0),s(o,g,"\u2111","\\Im",!0),s(o,g,"\u2660","\\spadesuit",!0),s(o,g,"\u2664","\\varspadesuit",!0),s(o,g,"\u2640","\\female",!0),s(o,g,"\u2642","\\male",!0),s(o,g,"\xA7","\\S",!0),s(O,g,"\xA7","\\S"),s(o,g,"\xB6","\\P",!0),s(O,g,"\xB6","\\P"),s(O,g,"\u263A","\\smiley",!0),s(o,g,"\u263A","\\smiley",!0),s(o,g,"\u2020","\\dag"),s(O,g,"\u2020","\\dag"),s(O,g,"\u2020","\\textdagger"),s(o,g,"\u2021","\\ddag"),s(O,g,"\u2021","\\ddag"),s(O,g,"\u2021","\\textdaggerdbl"),s(o,Ue,"\u23B1","\\rmoustache",!0),s(o,Q,"\u23B0","\\lmoustache",!0),s(o,Ue,"\u27EF","\\rgroup",!0),s(o,Q,"\u27EE","\\lgroup",!0),s(o,P,"\u2213","\\mp",!0),s(o,P,"\u2296","\\ominus",!0),s(o,P,"\u228E","\\uplus",!0),s(o,P,"\u2293","\\sqcap",!0),s(o,P,"\u2217","\\ast"),s(o,P,"\u2294","\\sqcup",!0),s(o,P,"\u25EF","\\bigcirc",!0),s(o,P,"\u2219","\\bullet",!0),s(o,P,"\u2021","\\ddagger"),s(o,P,"\u2240","\\wr",!0),s(o,P,"\u2A3F","\\amalg"),s(o,P,"&","\\And"),s(o,P,"\u2AFD","\\sslash",!0),s(o,x,"\u27F5","\\longleftarrow",!0),s(o,x,"\u21D0","\\Leftarrow",!0),s(o,x,"\u27F8","\\Longleftarrow",!0),s(o,x,"\u27F6","\\longrightarrow",!0),s(o,x,"\u21D2","\\Rightarrow",!0),s(o,x,"\u27F9","\\Longrightarrow",!0),s(o,x,"\u2194","\\leftrightarrow",!0),s(o,x,"\u27F7","\\longleftrightarrow",!0),s(o,x,"\u21D4","\\Leftrightarrow",!0),s(o,x,"\u27FA","\\Longleftrightarrow",!0),s(o,x,"\u21A4","\\mapsfrom",!0),s(o,x,"\u21A6","\\mapsto",!0),s(o,x,"\u27FC","\\longmapsto",!0),s(o,x,"\u2197","\\nearrow",!0),s(o,x,"\u21A9","\\hookleftarrow",!0),s(o,x,"\u21AA","\\hookrightarrow",!0),s(o,x,"\u2198","\\searrow",!0),s(o,x,"\u21BC","\\leftharpoonup",!0),s(o,x,"\u21C0","\\rightharpoonup",!0),s(o,x,"\u2199","\\swarrow",!0),s(o,x,"\u21BD","\\leftharpoondown",!0),s(o,x,"\u21C1","\\rightharpoondown",!0),s(o,x,"\u2196","\\nwarrow",!0),s(o,x,"\u21CC","\\rightleftharpoons",!0),s(o,W,"\u21AF","\\lightning",!0),s(o,W,"\u220E","\\QED",!0),s(o,W,"\u2030","\\permil",!0),s(O,g,"\u2030","\\permil"),s(o,W,"\u2609","\\astrosun",!0),s(o,W,"\u263C","\\sun",!0),s(o,W,"\u263E","\\leftmoon",!0),s(o,W,"\u263D","\\rightmoon",!0),s(o,W,"\u2295","\\Earth"),s(o,x,"\u226E","\\nless",!0),s(o,x,"\u2A87","\\lneq",!0),s(o,x,"\u2268","\\lneqq",!0),s(o,x,"\u2268\uFE00","\\lvertneqq"),s(o,x,"\u22E6","\\lnsim",!0),s(o,x,"\u2A89","\\lnapprox",!0),s(o,x,"\u2280","\\nprec",!0),s(o,x,"\u22E0","\\npreceq",!0),s(o,x,"\u22E8","\\precnsim",!0),s(o,x,"\u2AB9","\\precnapprox",!0),s(o,x,"\u2241","\\nsim",!0),s(o,x,"\u2224","\\nmid",!0),s(o,x,"\u2224","\\nshortmid"),s(o,x,"\u22AC","\\nvdash",!0),s(o,x,"\u22AD","\\nvDash",!0),s(o,x,"\u22EA","\\ntriangleleft"),s(o,x,"\u22EC","\\ntrianglelefteq",!0),s(o,x,"\u2284","\\nsubset",!0),s(o,x,"\u2285","\\nsupset",!0),s(o,x,"\u228A","\\subsetneq",!0),s(o,x,"\u228A\uFE00","\\varsubsetneq"),s(o,x,"\u2ACB","\\subsetneqq",!0),s(o,x,"\u2ACB\uFE00","\\varsubsetneqq"),s(o,x,"\u226F","\\ngtr",!0),s(o,x,"\u2A88","\\gneq",!0),s(o,x,"\u2269","\\gneqq",!0),s(o,x,"\u2269\uFE00","\\gvertneqq"),s(o,x,"\u22E7","\\gnsim",!0),s(o,x,"\u2A8A","\\gnapprox",!0),s(o,x,"\u2281","\\nsucc",!0),s(o,x,"\u22E1","\\nsucceq",!0),s(o,x,"\u22E9","\\succnsim",!0),s(o,x,"\u2ABA","\\succnapprox",!0),s(o,x,"\u2246","\\ncong",!0),s(o,x,"\u2226","\\nparallel",!0),s(o,x,"\u2226","\\nshortparallel"),s(o,x,"\u22AF","\\nVDash",!0),s(o,x,"\u22EB","\\ntriangleright"),s(o,x,"\u22ED","\\ntrianglerighteq",!0),s(o,x,"\u228B","\\supsetneq",!0),s(o,x,"\u228B","\\varsupsetneq"),s(o,x,"\u2ACC","\\supsetneqq",!0),s(o,x,"\u2ACC\uFE00","\\varsupsetneqq"),s(o,x,"\u22AE","\\nVdash",!0),s(o,x,"\u2AB5","\\precneqq",!0),s(o,x,"\u2AB6","\\succneqq",!0),s(o,P,"\u22B4","\\unlhd"),s(o,P,"\u22B5","\\unrhd"),s(o,x,"\u219A","\\nleftarrow",!0),s(o,x,"\u219B","\\nrightarrow",!0),s(o,x,"\u21CD","\\nLeftarrow",!0),s(o,x,"\u21CF","\\nRightarrow",!0),s(o,x,"\u21AE","\\nleftrightarrow",!0),s(o,x,"\u21CE","\\nLeftrightarrow",!0),s(o,x,"\u25B3","\\vartriangle"),s(o,g,"\u210F","\\hslash"),s(o,g,"\u25BD","\\triangledown"),s(o,g,"\u25CA","\\lozenge"),s(o,g,"\u24C8","\\circledS"),s(o,g,"\xAE","\\circledR",!0),s(O,g,"\xAE","\\circledR"),s(O,g,"\xAE","\\textregistered"),s(o,g,"\u2221","\\measuredangle",!0),s(o,g,"\u2204","\\nexists"),s(o,g,"\u2127","\\mho"),s(o,g,"\u2132","\\Finv",!0),s(o,g,"\u2141","\\Game",!0),s(o,g,"\u2035","\\backprime"),s(o,g,"\u2036","\\backdprime"),s(o,g,"\u2037","\\backtrprime"),s(o,g,"\u25B2","\\blacktriangle"),s(o,g,"\u25BC","\\blacktriangledown"),s(o,g,"\u25A0","\\blacksquare"),s(o,g,"\u29EB","\\blacklozenge"),s(o,g,"\u2605","\\bigstar"),s(o,g,"\u2222","\\sphericalangle",!0),s(o,g,"\u2201","\\complement",!0),s(o,g,"\u2571","\\diagup"),s(o,g,"\u2572","\\diagdown"),s(o,g,"\u25A1","\\square"),s(o,g,"\u25A1","\\Box"),s(o,g,"\u25CA","\\Diamond"),s(o,g,"\xA5","\\yen",!0),s(O,g,"\xA5","\\yen",!0),s(o,g,"\u2713","\\checkmark",!0),s(O,g,"\u2713","\\checkmark"),s(o,g,"\u2717","\\ballotx",!0),s(O,g,"\u2717","\\ballotx"),s(O,g,"\u2022","\\textbullet"),s(o,g,"\u2136","\\beth",!0),s(o,g,"\u2138","\\daleth",!0),s(o,g,"\u2137","\\gimel",!0),s(o,g,"\u03DD","\\digamma",!0),s(o,g,"\u03F0","\\varkappa"),s(o,Q,"\u231C","\\ulcorner",!0),s(o,Ue,"\u231D","\\urcorner",!0),s(o,Q,"\u231E","\\llcorner",!0),s(o,Ue,"\u231F","\\lrcorner",!0),s(o,x,"\u2266","\\leqq",!0),s(o,x,"\u2A7D","\\leqslant",!0),s(o,x,"\u2A95","\\eqslantless",!0),s(o,x,"\u2272","\\lesssim",!0),s(o,x,"\u2A85","\\lessapprox",!0),s(o,x,"\u224A","\\approxeq",!0),s(o,P,"\u22D6","\\lessdot"),s(o,x,"\u22D8","\\lll",!0),s(o,x,"\u2276","\\lessgtr",!0),s(o,x,"\u22DA","\\lesseqgtr",!0),s(o,x,"\u2A8B","\\lesseqqgtr",!0),s(o,x,"\u2251","\\doteqdot"),s(o,x,"\u2253","\\risingdotseq",!0),s(o,x,"\u2252","\\fallingdotseq",!0),s(o,x,"\u223D","\\backsim",!0),s(o,x,"\u22CD","\\backsimeq",!0),s(o,x,"\u2AC5","\\subseteqq",!0),s(o,x,"\u22D0","\\Subset",!0),s(o,x,"\u228F","\\sqsubset",!0),s(o,x,"\u227C","\\preccurlyeq",!0),s(o,x,"\u22DE","\\curlyeqprec",!0),s(o,x,"\u227E","\\precsim",!0),s(o,x,"\u2AB7","\\precapprox",!0),s(o,x,"\u22B2","\\vartriangleleft"),s(o,x,"\u22B4","\\trianglelefteq"),s(o,x,"\u22A8","\\vDash",!0),s(o,x,"\u22AB","\\VDash",!0),s(o,x,"\u22AA","\\Vvdash",!0),s(o,x,"\u2323","\\smallsmile"),s(o,x,"\u2322","\\smallfrown"),s(o,x,"\u224F","\\bumpeq",!0),s(o,x,"\u224E","\\Bumpeq",!0),s(o,x,"\u2267","\\geqq",!0),s(o,x,"\u2A7E","\\geqslant",!0),s(o,x,"\u2A96","\\eqslantgtr",!0),s(o,x,"\u2273","\\gtrsim",!0),s(o,x,"\u2A86","\\gtrapprox",!0),s(o,P,"\u22D7","\\gtrdot"),s(o,x,"\u22D9","\\ggg",!0),s(o,x,"\u2277","\\gtrless",!0),s(o,x,"\u22DB","\\gtreqless",!0),s(o,x,"\u2A8C","\\gtreqqless",!0),s(o,x,"\u2256","\\eqcirc",!0),s(o,x,"\u2257","\\circeq",!0),s(o,x,"\u225C","\\triangleq",!0),s(o,x,"\u223C","\\thicksim"),s(o,x,"\u2248","\\thickapprox"),s(o,x,"\u2AC6","\\supseteqq",!0),s(o,x,"\u22D1","\\Supset",!0),s(o,x,"\u2290","\\sqsupset",!0),s(o,x,"\u227D","\\succcurlyeq",!0),s(o,x,"\u22DF","\\curlyeqsucc",!0),s(o,x,"\u227F","\\succsim",!0),s(o,x,"\u2AB8","\\succapprox",!0),s(o,x,"\u22B3","\\vartriangleright"),s(o,x,"\u22B5","\\trianglerighteq"),s(o,x,"\u22A9","\\Vdash",!0),s(o,x,"\u2223","\\shortmid"),s(o,x,"\u2225","\\shortparallel"),s(o,x,"\u226C","\\between",!0),s(o,x,"\u22D4","\\pitchfork",!0),s(o,x,"\u221D","\\varpropto"),s(o,x,"\u25C0","\\blacktriangleleft"),s(o,x,"\u2234","\\therefore",!0),s(o,x,"\u220D","\\backepsilon"),s(o,x,"\u25B6","\\blacktriangleright"),s(o,x,"\u2235","\\because",!0),s(o,x,"\u22D8","\\llless"),s(o,x,"\u22D9","\\gggtr"),s(o,P,"\u22B2","\\lhd"),s(o,P,"\u22B3","\\rhd"),s(o,x,"\u2242","\\eqsim",!0),s(o,x,"\u2251","\\Doteq",!0),s(o,x,"\u297D","\\strictif",!0),s(o,x,"\u297C","\\strictfi",!0),s(o,P,"\u2214","\\dotplus",!0),s(o,P,"\u2216","\\smallsetminus"),s(o,P,"\u22D2","\\Cap",!0),s(o,P,"\u22D3","\\Cup",!0),s(o,P,"\u2A5E","\\doublebarwedge",!0),s(o,P,"\u229F","\\boxminus",!0),s(o,P,"\u229E","\\boxplus",!0),s(o,P,"\u29C4","\\boxslash",!0),s(o,P,"\u22C7","\\divideontimes",!0),s(o,P,"\u22C9","\\ltimes",!0),s(o,P,"\u22CA","\\rtimes",!0),s(o,P,"\u22CB","\\leftthreetimes",!0),s(o,P,"\u22CC","\\rightthreetimes",!0),s(o,P,"\u22CF","\\curlywedge",!0),s(o,P,"\u22CE","\\curlyvee",!0),s(o,P,"\u229D","\\circleddash",!0),s(o,P,"\u229B","\\circledast",!0),s(o,P,"\u22BA","\\intercal",!0),s(o,P,"\u22D2","\\doublecap"),s(o,P,"\u22D3","\\doublecup"),s(o,P,"\u22A0","\\boxtimes",!0),s(o,P,"\u22C8","\\bowtie",!0),s(o,P,"\u22C8","\\Join"),s(o,P,"\u27D5","\\leftouterjoin",!0),s(o,P,"\u27D6","\\rightouterjoin",!0),s(o,P,"\u27D7","\\fullouterjoin",!0),s(o,P,"\u2238","\\dotminus",!0),s(o,P,"\u27D1","\\wedgedot",!0),s(o,P,"\u27C7","\\veedot",!0),s(o,P,"\u2A62","\\doublebarvee",!0),s(o,P,"\u2A63","\\veedoublebar",!0),s(o,P,"\u2A5F","\\wedgebar",!0),s(o,P,"\u2A60","\\wedgedoublebar",!0),s(o,P,"\u2A54","\\Vee",!0),s(o,P,"\u2A53","\\Wedge",!0),s(o,P,"\u2A43","\\barcap",!0),s(o,P,"\u2A42","\\barcup",!0),s(o,P,"\u2A48","\\capbarcup",!0),s(o,P,"\u2A40","\\capdot",!0),s(o,P,"\u2A47","\\capovercup",!0),s(o,P,"\u2A46","\\cupovercap",!0),s(o,P,"\u2A4D","\\closedvarcap",!0),s(o,P,"\u2A4C","\\closedvarcup",!0),s(o,P,"\u2A2A","\\minusdot",!0),s(o,P,"\u2A2B","\\minusfdots",!0),s(o,P,"\u2A2C","\\minusrdots",!0),s(o,P,"\u22BB","\\Xor",!0),s(o,P,"\u22BC","\\Nand",!0),s(o,P,"\u22BD","\\Nor",!0),s(o,P,"\u22BD","\\barvee"),s(o,P,"\u2AF4","\\interleave",!0),s(o,P,"\u29E2","\\shuffle",!0),s(o,P,"\u2AF6","\\threedotcolon",!0),s(o,P,"\u2982","\\typecolon",!0),s(o,P,"\u223E","\\invlazys",!0),s(o,P,"\u2A4B","\\twocaps",!0),s(o,P,"\u2A4A","\\twocups",!0),s(o,P,"\u2A4E","\\Sqcap",!0),s(o,P,"\u2A4F","\\Sqcup",!0),s(o,P,"\u2A56","\\veeonvee",!0),s(o,P,"\u2A55","\\wedgeonwedge",!0),s(o,P,"\u29D7","\\blackhourglass",!0),s(o,P,"\u29C6","\\boxast",!0),s(o,P,"\u29C8","\\boxbox",!0),s(o,P,"\u29C7","\\boxcircle",!0),s(o,P,"\u229C","\\circledequal",!0),s(o,P,"\u29B7","\\circledparallel",!0),s(o,P,"\u29B6","\\circledvert",!0),s(o,P,"\u29B5","\\circlehbar",!0),s(o,P,"\u27E1","\\concavediamond",!0),s(o,P,"\u27E2","\\concavediamondtickleft",!0),s(o,P,"\u27E3","\\concavediamondtickright",!0),s(o,P,"\u22C4","\\diamond",!0),s(o,P,"\u29D6","\\hourglass",!0),s(o,P,"\u27E0","\\lozengeminus",!0),s(o,P,"\u233D","\\obar",!0),s(o,P,"\u29B8","\\obslash",!0),s(o,P,"\u2A38","\\odiv",!0),s(o,P,"\u29C1","\\ogreaterthan",!0),s(o,P,"\u29C0","\\olessthan",!0),s(o,P,"\u29B9","\\operp",!0),s(o,P,"\u2A37","\\Otimes",!0),s(o,P,"\u2A36","\\otimeshat",!0),s(o,P,"\u22C6","\\star",!0),s(o,P,"\u25B3","\\triangle",!0),s(o,P,"\u2A3A","\\triangleminus",!0),s(o,P,"\u2A39","\\triangleplus",!0),s(o,P,"\u2A3B","\\triangletimes",!0),s(o,P,"\u27E4","\\whitesquaretickleft",!0),s(o,P,"\u27E5","\\whitesquaretickright",!0),s(o,P,"\u2A33","\\smashtimes",!0),s(o,x,"\u21E2","\\dashrightarrow",!0),s(o,x,"\u21E0","\\dashleftarrow",!0),s(o,x,"\u21C7","\\leftleftarrows",!0),s(o,x,"\u21C6","\\leftrightarrows",!0),s(o,x,"\u21DA","\\Lleftarrow",!0),s(o,x,"\u219E","\\twoheadleftarrow",!0),s(o,x,"\u21A2","\\leftarrowtail",!0),s(o,x,"\u21AB","\\looparrowleft",!0),s(o,x,"\u21CB","\\leftrightharpoons",!0),s(o,x,"\u21B6","\\curvearrowleft",!0),s(o,x,"\u21BA","\\circlearrowleft",!0),s(o,x,"\u21B0","\\Lsh",!0),s(o,x,"\u21C8","\\upuparrows",!0),s(o,x,"\u21BF","\\upharpoonleft",!0),s(o,x,"\u21C3","\\downharpoonleft",!0),s(o,x,"\u22B6","\\origof",!0),s(o,x,"\u22B7","\\imageof",!0),s(o,x,"\u22B8","\\multimap",!0),s(o,x,"\u21AD","\\leftrightsquigarrow",!0),s(o,x,"\u21C9","\\rightrightarrows",!0),s(o,x,"\u21C4","\\rightleftarrows",!0),s(o,x,"\u21A0","\\twoheadrightarrow",!0),s(o,x,"\u21A3","\\rightarrowtail",!0),s(o,x,"\u21AC","\\looparrowright",!0),s(o,x,"\u21B7","\\curvearrowright",!0),s(o,x,"\u21BB","\\circlearrowright",!0),s(o,x,"\u21B1","\\Rsh",!0),s(o,x,"\u21CA","\\downdownarrows",!0),s(o,x,"\u21BE","\\upharpoonright",!0),s(o,x,"\u21C2","\\downharpoonright",!0),s(o,x,"\u21DD","\\rightsquigarrow",!0),s(o,x,"\u21DD","\\leadsto"),s(o,x,"\u21DB","\\Rrightarrow",!0),s(o,x,"\u21BE","\\restriction"),s(o,g,"\u2018","`"),s(o,g,"$","\\$"),s(O,g,"$","\\$"),s(O,g,"$","\\textdollar"),s(o,g,"\xA2","\\cent"),s(O,g,"\xA2","\\cent"),s(o,g,"%","\\%"),s(O,g,"%","\\%"),s(o,g,"_","\\_"),s(O,g,"_","\\_"),s(O,g,"_","\\textunderscore"),s(O,g,"\u2423","\\textvisiblespace",!0),s(o,g,"\u2220","\\angle",!0),s(o,g,"\u221E","\\infty",!0),s(o,g,"\u2032","\\prime"),s(o,g,"\u2033","\\dprime"),s(o,g,"\u2034","\\trprime"),s(o,g,"\u2057","\\qprime"),s(o,g,"\u25B3","\\triangle"),s(O,g,"\u0391","\\Alpha",!0),s(O,g,"\u0392","\\Beta",!0),s(O,g,"\u0393","\\Gamma",!0),s(O,g,"\u0394","\\Delta",!0),s(O,g,"\u0395","\\Epsilon",!0),s(O,g,"\u0396","\\Zeta",!0),s(O,g,"\u0397","\\Eta",!0),s(O,g,"\u0398","\\Theta",!0),s(O,g,"\u0399","\\Iota",!0),s(O,g,"\u039A","\\Kappa",!0),s(O,g,"\u039B","\\Lambda",!0),s(O,g,"\u039C","\\Mu",!0),s(O,g,"\u039D","\\Nu",!0),s(O,g,"\u039E","\\Xi",!0),s(O,g,"\u039F","\\Omicron",!0),s(O,g,"\u03A0","\\Pi",!0),s(O,g,"\u03A1","\\Rho",!0),s(O,g,"\u03A3","\\Sigma",!0),s(O,g,"\u03A4","\\Tau",!0),s(O,g,"\u03A5","\\Upsilon",!0),s(O,g,"\u03A6","\\Phi",!0),s(O,g,"\u03A7","\\Chi",!0),s(O,g,"\u03A8","\\Psi",!0),s(O,g,"\u03A9","\\Omega",!0),s(o,W,"\u0391","\\Alpha",!0),s(o,W,"\u0392","\\Beta",!0),s(o,W,"\u0393","\\Gamma",!0),s(o,W,"\u0394","\\Delta",!0),s(o,W,"\u0395","\\Epsilon",!0),s(o,W,"\u0396","\\Zeta",!0),s(o,W,"\u0397","\\Eta",!0),s(o,W,"\u0398","\\Theta",!0),s(o,W,"\u0399","\\Iota",!0),s(o,W,"\u039A","\\Kappa",!0),s(o,W,"\u039B","\\Lambda",!0),s(o,W,"\u039C","\\Mu",!0),s(o,W,"\u039D","\\Nu",!0),s(o,W,"\u039E","\\Xi",!0),s(o,W,"\u039F","\\Omicron",!0),s(o,W,"\u03A0","\\Pi",!0),s(o,W,"\u03A1","\\Rho",!0),s(o,W,"\u03A3","\\Sigma",!0),s(o,W,"\u03A4","\\Tau",!0),s(o,W,"\u03A5","\\Upsilon",!0),s(o,W,"\u03A6","\\Phi",!0),s(o,W,"\u03A7","\\Chi",!0),s(o,W,"\u03A8","\\Psi",!0),s(o,W,"\u03A9","\\Omega",!0),s(o,Q,"\xAC","\\neg",!0),s(o,Q,"\xAC","\\lnot"),s(o,g,"\u22A4","\\top"),s(o,g,"\u22A5","\\bot"),s(o,g,"\u2205","\\emptyset"),s(o,g,"\u2300","\\varnothing"),s(o,W,"\u03B1","\\alpha",!0),s(o,W,"\u03B2","\\beta",!0),s(o,W,"\u03B3","\\gamma",!0),s(o,W,"\u03B4","\\delta",!0),s(o,W,"\u03F5","\\epsilon",!0),s(o,W,"\u03B6","\\zeta",!0),s(o,W,"\u03B7","\\eta",!0),s(o,W,"\u03B8","\\theta",!0),s(o,W,"\u03B9","\\iota",!0),s(o,W,"\u03BA","\\kappa",!0),s(o,W,"\u03BB","\\lambda",!0),s(o,W,"\u03BC","\\mu",!0),s(o,W,"\u03BD","\\nu",!0),s(o,W,"\u03BE","\\xi",!0),s(o,W,"\u03BF","\\omicron",!0),s(o,W,"\u03C0","\\pi",!0),s(o,W,"\u03C1","\\rho",!0),s(o,W,"\u03C3","\\sigma",!0),s(o,W,"\u03C4","\\tau",!0),s(o,W,"\u03C5","\\upsilon",!0),s(o,W,"\u03D5","\\phi",!0),s(o,W,"\u03C7","\\chi",!0),s(o,W,"\u03C8","\\psi",!0),s(o,W,"\u03C9","\\omega",!0),s(o,W,"\u03B5","\\varepsilon",!0),s(o,W,"\u03D1","\\vartheta",!0),s(o,W,"\u03D6","\\varpi",!0),s(o,W,"\u03F1","\\varrho",!0),s(o,W,"\u03C2","\\varsigma",!0),s(o,W,"\u03C6","\\varphi",!0),s(o,W,"\u03D8","\\Coppa",!0),s(o,W,"\u03D9","\\coppa",!0),s(o,W,"\u03D9","\\varcoppa",!0),s(o,W,"\u03DE","\\Koppa",!0),s(o,W,"\u03DF","\\koppa",!0),s(o,W,"\u03E0","\\Sampi",!0),s(o,W,"\u03E1","\\sampi",!0),s(o,W,"\u03DA","\\Stigma",!0),s(o,W,"\u03DB","\\stigma",!0),s(o,W,"\u2AEB","\\Bot"),s(o,g,"\xF0","\\eth",!0),s(O,g,"\xF0","\xF0"),s(o,g,"\xC5","\\AA"),s(O,g,"\xC5","\\AA",!0),s(o,g,"\xC6","\\AE",!0),s(O,g,"\xC6","\\AE",!0),s(o,g,"\xD0","\\DH",!0),s(O,g,"\xD0","\\DH",!0),s(o,g,"\xDE","\\TH",!0),s(O,g,"\xDE","\\TH",!0),s(o,g,"\xDF","\\ss",!0),s(O,g,"\xDF","\\ss",!0),s(o,g,"\xE5","\\aa"),s(O,g,"\xE5","\\aa",!0),s(o,g,"\xE6","\\ae",!0),s(O,g,"\xE6","\\ae",!0),s(o,g,"\xF0","\\dh"),s(O,g,"\xF0","\\dh",!0),s(o,g,"\xFE","\\th",!0),s(O,g,"\xFE","\\th",!0),s(o,g,"\u0110","\\DJ",!0),s(O,g,"\u0110","\\DJ",!0),s(o,g,"\u0111","\\dj",!0),s(O,g,"\u0111","\\dj",!0),s(o,g,"\u0141","\\L",!0),s(O,g,"\u0141","\\L",!0),s(o,g,"\u0141","\\l",!0),s(O,g,"\u0141","\\l",!0),s(o,g,"\u014A","\\NG",!0),s(O,g,"\u014A","\\NG",!0),s(o,g,"\u014B","\\ng",!0),s(O,g,"\u014B","\\ng",!0),s(o,g,"\u0152","\\OE",!0),s(O,g,"\u0152","\\OE",!0),s(o,g,"\u0153","\\oe",!0),s(O,g,"\u0153","\\oe",!0),s(o,P,"\u2217","\u2217",!0),s(o,P,"+","+"),s(o,P,"\u2217","*"),s(o,P,"\u2044","/",!0),s(o,P,"\u2044","\u2044"),s(o,P,"\u2212","-",!0),s(o,P,"\u22C5","\\cdot",!0),s(o,P,"\u2218","\\circ",!0),s(o,P,"\xF7","\\div",!0),s(o,P,"\xB1","\\pm",!0),s(o,P,"\xD7","\\times",!0),s(o,P,"\u2229","\\cap",!0),s(o,P,"\u222A","\\cup",!0),s(o,P,"\u2216","\\setminus",!0),s(o,P,"\u2227","\\land"),s(o,P,"\u2228","\\lor"),s(o,P,"\u2227","\\wedge",!0),s(o,P,"\u2228","\\vee",!0),s(o,Q,"\u27E6","\\llbracket",!0),s(o,Ue,"\u27E7","\\rrbracket",!0),s(o,Q,"\u27E8","\\langle",!0),s(o,Q,"\u27EA","\\lAngle",!0),s(o,Q,"\u2989","\\llangle",!0),s(o,Q,"|","\\lvert"),s(o,Q,"\u2016","\\lVert",!0),s(o,g,"!","\\oc"),s(o,g,"?","\\wn"),s(o,g,"\u2193","\\shpos"),s(o,g,"\u2195","\\shift"),s(o,g,"\u2191","\\shneg"),s(o,Ue,"?","?"),s(o,Ue,"!","!"),s(o,Ue,"\u203C","\u203C"),s(o,Ue,"\u27E9","\\rangle",!0),s(o,Ue,"\u27EB","\\rAngle",!0),s(o,Ue,"\u298A","\\rrangle",!0),s(o,Ue,"|","\\rvert"),s(o,Ue,"\u2016","\\rVert"),s(o,Q,"\u2983","\\lBrace",!0),s(o,Ue,"\u2984","\\rBrace",!0),s(o,x,"=","\\equal",!0),s(o,x,":",":"),s(o,x,"\u2248","\\approx",!0),s(o,x,"\u2245","\\cong",!0),s(o,x,"\u2265","\\ge"),s(o,x,"\u2265","\\geq",!0),s(o,x,"\u2190","\\gets"),s(o,x,">","\\gt",!0),s(o,x,"\u2208","\\in",!0),s(o,x,"\u2209","\\notin",!0),s(o,x,"\uE020","\\@not"),s(o,x,"\u2282","\\subset",!0),s(o,x,"\u2283","\\supset",!0),s(o,x,"\u2286","\\subseteq",!0),s(o,x,"\u2287","\\supseteq",!0),s(o,x,"\u2288","\\nsubseteq",!0),s(o,x,"\u2288","\\nsubseteqq"),s(o,x,"\u2289","\\nsupseteq",!0),s(o,x,"\u2289","\\nsupseteqq"),s(o,x,"\u22A8","\\models"),s(o,x,"\u2190","\\leftarrow",!0),s(o,x,"\u2264","\\le"),s(o,x,"\u2264","\\leq",!0),s(o,x,"<","\\lt",!0),s(o,x,"\u2192","\\rightarrow",!0),s(o,x,"\u2192","\\to"),s(o,x,"\u2271","\\ngeq",!0),s(o,x,"\u2271","\\ngeqq"),s(o,x,"\u2271","\\ngeqslant"),s(o,x,"\u2270","\\nleq",!0),s(o,x,"\u2270","\\nleqq"),s(o,x,"\u2270","\\nleqslant"),s(o,x,"\u2AEB","\\Perp",!0),s(o,we,"\xA0","\\ "),s(o,we,"\xA0","\\space"),s(o,we,"\xA0","\\nobreakspace"),s(O,we,"\xA0","\\ "),s(O,we,"\xA0"," "),s(O,we,"\xA0","\\space"),s(O,we,"\xA0","\\nobreakspace"),s(o,we,null,"\\nobreak"),s(o,we,null,"\\allowbreak"),s(o,ye,",",","),s(O,ye,":",":"),s(o,ye,";",";"),s(o,P,"\u22BC","\\barwedge"),s(o,P,"\u22BB","\\veebar"),s(o,P,"\u2299","\\odot",!0),s(o,P,"\u2295\uFE0E","\\oplus"),s(o,P,"\u2297","\\otimes",!0),s(o,g,"\u2202","\\partial",!0),s(o,P,"\u2298","\\oslash",!0),s(o,P,"\u229A","\\circledcirc",!0),s(o,P,"\u22A1","\\boxdot",!0),s(o,P,"\u25B3","\\bigtriangleup"),s(o,P,"\u25BD","\\bigtriangledown"),s(o,P,"\u2020","\\dagger"),s(o,P,"\u22C4","\\diamond"),s(o,P,"\u25C3","\\triangleleft"),s(o,P,"\u25B9","\\triangleright"),s(o,Q,"{","\\{"),s(O,g,"{","\\{"),s(O,g,"{","\\textbraceleft"),s(o,Ue,"}","\\}"),s(O,g,"}","\\}"),s(O,g,"}","\\textbraceright"),s(o,Q,"{","\\lbrace"),s(o,Ue,"}","\\rbrace"),s(o,Q,"[","\\lbrack",!0),s(O,g,"[","\\lbrack",!0),s(o,Ue,"]","\\rbrack",!0),s(O,g,"]","\\rbrack",!0),s(o,Q,"(","\\lparen",!0),s(o,Ue,")","\\rparen",!0),s(o,Q,"\u2987","\\llparenthesis",!0),s(o,Ue,"\u2988","\\rrparenthesis",!0),s(O,g,"<","\\textless",!0),s(O,g,">","\\textgreater",!0),s(o,Q,"\u230A","\\lfloor",!0),s(o,Ue,"\u230B","\\rfloor",!0),s(o,Q,"\u2308","\\lceil",!0),s(o,Ue,"\u2309","\\rceil",!0),s(o,g,"\\","\\backslash"),s(o,g,"|","|"),s(o,g,"|","\\vert"),s(O,g,"|","\\textbar",!0),s(o,g,"\u2016","\\|"),s(o,g,"\u2016","\\Vert"),s(O,g,"\u2016","\\textbardbl"),s(O,g,"~","\\textasciitilde"),s(O,g,"\\","\\textbackslash"),s(O,g,"^","\\textasciicircum"),s(o,x,"\u2191","\\uparrow",!0),s(o,x,"\u21D1","\\Uparrow",!0),s(o,x,"\u2193","\\downarrow",!0),s(o,x,"\u21D3","\\Downarrow",!0),s(o,x,"\u2195","\\updownarrow",!0),s(o,x,"\u21D5","\\Updownarrow",!0),s(o,Ae,"\u2210","\\coprod"),s(o,Ae,"\u22C1","\\bigvee"),s(o,Ae,"\u22C0","\\bigwedge"),s(o,Ae,"\u2A04","\\biguplus"),s(o,Ae,"\u2A04","\\bigcupplus"),s(o,Ae,"\u2A03","\\bigcupdot"),s(o,Ae,"\u2A07","\\bigdoublevee"),s(o,Ae,"\u2A08","\\bigdoublewedge"),s(o,Ae,"\u22C2","\\bigcap"),s(o,Ae,"\u22C3","\\bigcup"),s(o,Ae,"\u222B","\\int"),s(o,Ae,"\u222B","\\intop"),s(o,Ae,"\u222C","\\iint"),s(o,Ae,"\u222D","\\iiint"),s(o,Ae,"\u220F","\\prod"),s(o,Ae,"\u2211","\\sum"),s(o,Ae,"\u2A02","\\bigotimes"),s(o,Ae,"\u2A01","\\bigoplus"),s(o,Ae,"\u2A00","\\bigodot"),s(o,Ae,"\u2A09","\\bigtimes"),s(o,Ae,"\u222E","\\oint"),s(o,Ae,"\u222F","\\oiint"),s(o,Ae,"\u2230","\\oiiint"),s(o,Ae,"\u2231","\\intclockwise"),s(o,Ae,"\u2232","\\varointclockwise"),s(o,Ae,"\u2A0C","\\iiiint"),s(o,Ae,"\u2A0D","\\intbar"),s(o,Ae,"\u2A0E","\\intBar"),s(o,Ae,"\u2A0F","\\fint"),s(o,Ae,"\u2A12","\\rppolint"),s(o,Ae,"\u2A13","\\scpolint"),s(o,Ae,"\u2A15","\\pointint"),s(o,Ae,"\u2A16","\\sqint"),s(o,Ae,"\u2A17","\\intlarhk"),s(o,Ae,"\u2A18","\\intx"),s(o,Ae,"\u2A19","\\intcap"),s(o,Ae,"\u2A1A","\\intcup"),s(o,Ae,"\u2A05","\\bigsqcap"),s(o,Ae,"\u2A06","\\bigsqcup"),s(o,Ae,"\u222B","\\smallint"),s(O,nt,"\u2026","\\textellipsis"),s(o,nt,"\u2026","\\mathellipsis"),s(O,nt,"\u2026","\\ldots",!0),s(o,nt,"\u2026","\\ldots",!0),s(o,nt,"\u22F0","\\iddots",!0),s(o,nt,"\u22EF","\\@cdots",!0),s(o,nt,"\u22F1","\\ddots",!0),s(o,g,"\u22EE","\\varvdots"),s(O,g,"\u22EE","\\varvdots"),s(o,Be,"\xB4","\\acute"),s(o,Be,"`","\\grave"),s(o,Be,"\xA8","\\ddot"),s(o,Be,"\u2026","\\dddot"),s(o,Be,"\u2026.","\\ddddot"),s(o,Be,"~","\\tilde"),s(o,Be,"\u203E","\\bar"),s(o,Be,"\u02D8","\\breve"),s(o,Be,"\u02C7","\\check"),s(o,Be,"^","\\hat"),s(o,Be,"\u2192","\\vec"),s(o,Be,"\u02D9","\\dot"),s(o,Be,"\u02DA","\\mathring"),s(o,W,"\u0131","\\imath",!0),s(o,W,"\u0237","\\jmath",!0),s(o,g,"\u0131","\u0131"),s(o,g,"\u0237","\u0237"),s(O,g,"\u0131","\\i",!0),s(O,g,"\u0237","\\j",!0),s(O,g,"\xF8","\\o",!0),s(o,W,"\xF8","\\o",!0),s(O,g,"\xD8","\\O",!0),s(o,W,"\xD8","\\O",!0),s(O,Be,"\u02CA","\\'"),s(O,Be,"\u02CB","\\`"),s(O,Be,"\u02C6","\\^"),s(O,Be,"~","\\~"),s(O,Be,"\u02C9","\\="),s(O,Be,"\u02D8","\\u"),s(O,Be,"\u02D9","\\."),s(O,Be,"\xB8","\\c"),s(O,Be,"\u02DA","\\r"),s(O,Be,"\u02C7","\\v"),s(O,Be,"\xA8",'\\"'),s(O,Be,"\u02DD","\\H"),s(o,Be,"\u02CA","\\'"),s(o,Be,"\u02CB","\\`"),s(o,Be,"\u02C6","\\^"),s(o,Be,"~","\\~"),s(o,Be,"\u02C9","\\="),s(o,Be,"\u02D8","\\u"),s(o,Be,"\u02D9","\\."),s(o,Be,"\xB8","\\c"),s(o,Be,"\u02DA","\\r"),s(o,Be,"\u02C7","\\v"),s(o,Be,"\xA8",'\\"'),s(o,Be,"\u02DD","\\H");let G={"--":!0,"---":!0,"``":!0,"''":!0};s(O,g,"\u2013","--",!0),s(O,g,"\u2013","\\textendash"),s(O,g,"\u2014","---",!0),s(O,g,"\u2014","\\textemdash"),s(O,g,"\u2018","`",!0),s(O,g,"\u2018","\\textquoteleft"),s(O,g,"\u2019","'",!0),s(O,g,"\u2019","\\textquoteright"),s(O,g,"\u201C","``",!0),s(O,g,"\u201C","\\textquotedblleft"),s(O,g,"\u201D","''",!0),s(O,g,"\u201D","\\textquotedblright"),s(o,g,"\xB0","\\degree",!0),s(O,g,"\xB0","\\degree"),s(O,g,"\xB0","\\textdegree",!0),s(o,g,"\xA3","\\pounds"),s(o,g,"\xA3","\\mathsterling",!0),s(O,g,"\xA3","\\pounds"),s(O,g,"\xA3","\\textsterling",!0),s(o,g,"\u2720","\\maltese"),s(O,g,"\u2720","\\maltese"),s(o,g,"\u20AC","\\euro",!0),s(O,g,"\u20AC","\\euro",!0),s(O,g,"\u20AC","\\texteuro"),s(o,g,"\xA9","\\copyright",!0),s(O,g,"\xA9","\\textcopyright"),s(o,g,"\u2300","\\diameter",!0),s(O,g,"\u2300","\\diameter"),s(o,g,"\u{1D6E4}","\\varGamma"),s(o,g,"\u{1D6E5}","\\varDelta"),s(o,g,"\u{1D6E9}","\\varTheta"),s(o,g,"\u{1D6EC}","\\varLambda"),s(o,g,"\u{1D6EF}","\\varXi"),s(o,g,"\u{1D6F1}","\\varPi"),s(o,g,"\u{1D6F4}","\\varSigma"),s(o,g,"\u{1D6F6}","\\varUpsilon"),s(o,g,"\u{1D6F7}","\\varPhi"),s(o,g,"\u{1D6F9}","\\varPsi"),s(o,g,"\u{1D6FA}","\\varOmega"),s(O,g,"\u{1D6E4}","\\varGamma"),s(O,g,"\u{1D6E5}","\\varDelta"),s(O,g,"\u{1D6E9}","\\varTheta"),s(O,g,"\u{1D6EC}","\\varLambda"),s(O,g,"\u{1D6EF}","\\varXi"),s(O,g,"\u{1D6F1}","\\varPi"),s(O,g,"\u{1D6F4}","\\varSigma"),s(O,g,"\u{1D6F6}","\\varUpsilon"),s(O,g,"\u{1D6F7}","\\varPhi"),s(O,g,"\u{1D6F9}","\\varPsi"),s(O,g,"\u{1D6FA}","\\varOmega");let B='0123456789/@."';for(let e=0;e<14;e++){let t=B.charAt(e);s(o,g,t,t)}let X='0123456789!@*()-=+";:?/.,';for(let e=0;e<25;e++){let t=X.charAt(e);s(O,g,t,t)}let Y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";for(let e=0;e<52;e++){let t=Y.charAt(e);s(o,W,t,t),s(O,g,t,t)}let ge="\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=ge.charAt(e);s(o,W,t,t),s(O,g,t,t)}let V="";for(let e=0;e<52;e++){V=String.fromCharCode(55349,56320+e),s(o,W,V,V),s(O,g,V,V),V=String.fromCharCode(55349,56372+e),s(o,W,V,V),s(O,g,V,V),V=String.fromCharCode(55349,56424+e),s(o,W,V,V),s(O,g,V,V),V=String.fromCharCode(55349,56580+e),s(o,W,V,V),s(O,g,V,V),V=String.fromCharCode(55349,56736+e),s(o,W,V,V),s(O,g,V,V),V=String.fromCharCode(55349,56788+e),s(o,W,V,V),s(O,g,V,V),V=String.fromCharCode(55349,56840+e),s(o,W,V,V),s(O,g,V,V),V=String.fromCharCode(55349,56944+e),s(o,W,V,V),s(O,g,V,V),V=String.fromCharCode(55349,56632+e),s(o,W,V,V),s(O,g,V,V);let t=Y.charAt(e);V=String.fromCharCode(55349,56476+e),s(o,W,t,V),s(O,g,t,V)}for(let e=0;e<10;e++)V=String.fromCharCode(55349,57294+e),s(o,W,V,V),s(O,g,V,V),V=String.fromCharCode(55349,57314+e),s(o,W,V,V),s(O,g,V,V),V=String.fromCharCode(55349,57324+e),s(o,W,V,V),s(O,g,V,V),V=String.fromCharCode(55349,57334+e),s(o,W,V,V),s(O,g,V,V);let ne=function(e,t,n){return!Ne[t][e]||!Ne[t][e].replace||e.charCodeAt(0)===55349||Object.prototype.hasOwnProperty.call(G,e)&&n&&(n.fontFamily&&n.fontFamily.slice(4,6)==="tt"||n.font&&n.font.slice(4,6)==="tt")||(e=Ne[t][e].replace),new Ie(e)},Fe=(e,t)=>{if(e.children.length===0||e.children[e.children.length-1].type!=="mtext"){let n=new E("mtext",[new Ie(t.children[0].text)]);e.children.push(n)}else e.children[e.children.length-1].children[0].text+=t.children[0].text},Je=e=>{if(e.type!=="mrow"&&e.type!=="mstyle"||e.children.length===0)return e;let t=new E("mrow");for(let n=0;n<e.children.length;n++){let i=e.children[n];if(i.type==="mtext"&&Object.keys(i.attributes).length===0)Fe(t,i);else if(i.type==="mrow"){let c=!0;for(let p=0;p<i.children.length;p++)if(i.children[p].type!=="mtext"||Object.keys(i.attributes).length!==0){c=!1;break}if(c)for(let p=0;p<i.children.length;p++){let b=i.children[p];Fe(t,b)}else t.children.push(i)}else t.children.push(i)}for(let n=0;n<t.children.length;n++)if(t.children[n].type==="mtext"){let i=t.children[n];i.children[0].text.charAt(0)===" "&&(i.children[0].text="\xA0"+i.children[0].text.slice(1));let c=i.children[0].text.length;c>0&&i.children[0].text.charAt(c-1)===" "&&(i.children[0].text=i.children[0].text.slice(0,-1)+"\xA0");for(let[p,b]of Object.entries(e.attributes))i.attributes[p]=b}return t.children.length===1&&t.children[0].type==="mtext"?t.children[0]:t},re=function(e,t=!1){if(!(e.length!==1||e[0]instanceof de))return e[0];if(!t){e[0]instanceof E&&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&&e[n].type==="mo"&&!e[n].attributes.fence&&(e[n].attributes.lspace="0em",e[n].attributes.rspace="0em")}return new E("mrow",e)};function ke(e){if(!e)return!1;if(e.type==="mi"&&e.children.length===1){let t=e.children[0];return t instanceof Ie&&t.text==="."}if(e.type==="mtext"&&e.children.length===1){let t=e.children[0];return t instanceof Ie&&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 Ie&&t.text===","}return!1}let He=(e,t)=>{let n=e[t],i=e[t+1];return n.type==="atom"&&n.text===","&&n.loc&&i.loc&&n.loc.end===i.loc.start},_e=e=>e.type==="atom"&&e.family==="rel"||e.type==="mclass"&&e.mclass==="mrel",Le=function(e,t,n=!1){if(!n&&e.length===1){let b=Oe(e[0],t);return b instanceof E&&b.type==="mo"&&(b.setAttribute("lspace","0em"),b.setAttribute("rspace","0em")),[b]}let i=[],c=[],p;for(let b=0;b<e.length;b++)c.push(Oe(e[b],t));for(let b=0;b<c.length;b++){let v=c[b];if(b<e.length-1&&_e(e[b])&&_e(e[b+1])&&v.setAttribute("rspace","0em"),b>0&&_e(e[b])&&_e(e[b-1])&&v.setAttribute("lspace","0em"),v.type==="mn"&&p&&p.type==="mn")p.children.push(...v.children);else if(ke(v)&&p&&p.type==="mn")p.children.push(...v.children);else if(p&&p.type==="mn"&&b<c.length-1&&c[b+1].type==="mn"&&He(e,b))p.children.push(...v.children);else{if(v.type==="mn"&&ke(p))v.children=[...p.children,...v.children],i.pop();else if((v.type==="msup"||v.type==="msub")&&v.children.length>=1&&p&&(p.type==="mn"||ke(p))){let D=v.children[0];D instanceof E&&D.type==="mn"&&p&&(D.children=[...p.children,...D.children],i.pop())}i.push(v),p=v}}return i},Qe=function(e,t,n=!1){return re(Le(e,t,n),n)},Oe=function(e,t){if(!e)return new E("mrow");if(C[e.type])return C[e.type](e,t);throw new r("Got group of unknown type: '"+e.type+"'")},Ye=e=>new E("mtd",[],[],{padding:"0",width:"50%"}),ct=["mrow","mtd","mtable","mtr"],_t=e=>{for(let t of e.children)if(t.type&&ct.includes(t.type)){if(t.classes&&t.classes[0]==="tml-label")return t.label;{let n=_t(t);if(n)return n}}else if(!t.type){let n=_t(t);if(n)return n}};function Pt(e,t,n,i){let c=null;e.length===1&&e[0].type==="tag"&&(c=e[0].tag,e=e[0].body);let p=Le(e,n);if(p.length===1&&p[0]instanceof Ce)return p[0];let b=i.displayMode||i.annotate?"none":i.wrap,v=p.length===0?null:p[0],D=p.length===1&&c===null&&v instanceof E?p[0]:function(se,ce,ee){let et=[],Ge=[],tt=[],lt=0,je=0;for(;je<se.length;){for(;se[je]instanceof de;)se.splice(je,1,...se[je].children);let Ze=se[je];if(Ze.attributes&&Ze.attributes.linebreak&&Ze.attributes.linebreak==="newline"){tt.length>0&&Ge.push(new E("mrow",tt)),Ge.push(Ze),tt=[];let Ut=new E("mtd",Ge);Ut.style.textAlign="left",et.push(new E("mtr",[Ut])),Ge=[],je+=1;continue}if(tt.push(Ze),Ze.type&&Ze.type==="mo"&&Ze.children.length===1&&(!Ze.attributes.form||Ze.attributes.form!=="prefix")&&!Object.prototype.hasOwnProperty.call(Ze.attributes,"movablelimits")){let Ut=Ze.children[0].text;if(ce==="="&&Ut==="="){if(lt+=1,lt>1){tt.pop();let Tt=new E("mrow",tt);Ge.push(Tt),tt=[Ze]}}else if(ce==="tex"){let Tt=je<se.length-1?se[je+1]:null,An=!0;if(!Tt||Tt.type!=="mtext"||!Tt.attributes.linebreak||Tt.attributes.linebreak!=="nobreak")for(let en=je+1;en<se.length;en++){let ln=se[en];if(!ln.type||ln.type!=="mspace"||ln.attributes.linebreak&&ln.attributes.linebreak==="newline")break;tt.push(ln),je+=1,ln.attributes&&ln.attributes.linebreak&&ln.attributes.linebreak==="nobreak"&&(An=!1)}if(An){let en=new E("mrow",tt);Ge.push(en),tt=[]}}}je+=1}if(tt.length>0){let Ze=new E("mrow",tt);Ge.push(Ze)}if(et.length>0){let Ze=new E("mtd",Ge);Ze.style.textAlign="left";let Ut=new E("mtr",[Ze]);et.push(Ut);let Tt=new E("mtable",et);return ee||(Tt.setAttribute("columnalign","left"),Tt.setAttribute("rowspacing","0em")),Tt}return xe(Ge)}(p,b,i.displayMode);if(c&&(D=((se,ce,ee,et)=>{ce=Qe(ce[0].body,ee),(ce=Je(ce)).classes.push("tml-tag");let Ge=_t(se);se=new E("mtd",[se]);let tt=[Ye(),se,Ye()];tt[et?0:2].children.push(ce);let lt=new E("mtr",tt,["tml-tageqn"]);Ge&&lt.setAttribute("id",Ge);let je=new E("mtable",[lt]);return je.style.width="100%",je.setAttribute("displaystyle","true"),je})(D,c,n,i.leqno)),i.annotate){let se=new E("annotation",[new Ie(t)]);se.setAttribute("encoding","application/x-tex"),D=new E("semantics",[D,se])}let z=new E("math",[D]);return i.xml&&z.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML"),i.displayMode&&(z.setAttribute("display","block"),z.style.display="block math",z.classes=["tml-display"]),z}let Kt=(e,t)=>{let n=e.isStretchy?fe(e):new E("mo",[ne(e.label,e.mode)]);e.isStretchy||n.setAttribute("stretchy","false"),e.label!=="\\vec"&&(n.style.mathDepth="0");let i=e.label==="\\c"?"munder":"mover",c=nn.has(e.label);if(i==="mover"&&e.mode==="math"&&!e.isStretchy&&e.base.text&&e.base.text.length===1){let p=e.base.text,b=e.label==="\\vec",v=b==="\\vec"?"-vec":"";b&&n.classes.push("tml-vec");let D=b?"-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${v}`),n.classes.push(`wbk-sml${D}`)):"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${v}`),n.classes.push(`wbk-med${D}`)):"AFJdf\u0394\u039B".indexOf(p)>-1?(n.classes.push(`chr-lrg${v}`),n.classes.push(`wbk-lrg${D}`)):b?n.classes.push("wbk-vec"):c&&n.classes.push("wbk-acc")}else c&&n.classes.push("wbk-acc");return new E(i,[Oe(e.base,t),n])},te=new Set(["\\acute","\\check","\\grave","\\ddot","\\dddot","\\ddddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring"]),nn=new Set(["\\acute","\\bar","\\breve","\\check","\\dot","\\ddot","\\grave","\\hat","\\mathring","\\`","\\'","\\^","\\=","\\u","\\.",'\\"',"\\r","\\H","\\v"]),Dt={"\\`":"\u0300","\\'":"\u0301","\\^":"\u0302","\\~":"\u0303","\\=":"\u0304","\\u":"\u0306","\\.":"\u0307",'\\"':"\u0308","\\r":"\u030A","\\H":"\u030B","\\v":"\u030C","\\c":"\u0327"};$({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=he(t[0]),i=!te.has(e.funcName);return{type:"accent",mode:e.parser.mode,label:e.funcName,isStretchy:i,base:n}},mathmlBuilder:Kt}),$({type:"accent",names:["\\'","\\`","\\^","\\~","\\=","\\c","\\u","\\.",'\\"',"\\r","\\H","\\v"],props:{numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["primitive"]},handler:(e,t)=>{let n=he(t[0]),i=e.parser.mode;return i==="math"&&e.parser.settings.strict&&console.log(`Temml parse error: Command ${e.funcName} is invalid in math mode.`),i==="text"&&n.text&&n.text.length===1&&e.funcName in Dt&&A.indexOf(n.text)>-1?{type:"textord",mode:"text",text:n.text+Dt[e.funcName]}:e.funcName==="\\c"&&i==="text"&&n.text&&n.text.length===1?{type:"textord",mode:"text",text:n.text+"\u0327"}:{type:"accent",mode:i,label:e.funcName,isStretchy:!1,base:n}},mathmlBuilder:Kt}),$({type:"accentUnder",names:["\\underleftarrow","\\underrightarrow","\\underleftrightarrow","\\undergroup","\\underparen","\\utilde"],props:{numArgs:1},handler:({parser:e,funcName:t},n)=>{let i=n[0];return{type:"accentUnder",mode:e.mode,label:t,base:i}},mathmlBuilder:(e,t)=>{let n=fe(e);return n.style["math-depth"]=0,new E("munder",[Oe(e.base,t),n])}});let qt={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},Xt=["em","ex","mu","pt","mm","cm","in","px","bp","pc","dd","cc","nd","nc","sp"],Ct=function(e){return typeof e!="string"&&(e=e.unit),Xt.indexOf(e)>-1},gt=e=>[1,.7,.5][Math.max(e-1,0)],ot=function(e,t){let n=e.number;if(t.maxSize[0]<0&&n>0)return{number:0,unit:"em"};let i=e.unit;switch(i){case"mm":case"cm":case"in":case"px":return n*qt[i]>t.maxSize[1]?{number:t.maxSize[1],unit:"pt"}:{number:n,unit:i};case"em":case"ex":return i==="ex"&&(n*=.431),n=Math.min(n/gt(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*qt[i],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: '"+i+"'")}},st=e=>{let t=new E("mspace");return t.setAttribute("width",e+"em"),t},N=(e,t=.3,n=0,i=!1)=>{if(e==null&&n===0)return st(t);let c=e?[e]:[];if(t!==0&&c.unshift(st(t)),n>0&&c.push(st(n)),i){let p=new E("mpadded",c);return p.setAttribute("height","0.1px"),p}return new E("mrow",c)},H=(e,t)=>Number(e)/gt(t),ie=(e,t,n,i)=>{let c=J(e),p=e.slice(1,3)==="eq",b=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 v=i.withLevel(i.level<2?2:3),D=H(b,v.level),z=H(b,3),se=N(null,D.toFixed(4),0),ce=N(null,z.toFixed(4),0),ee=H(p?0:.3,v.level).toFixed(4),et,Ge,tt=t&&t.body&&(t.body.body||t.body.length>0);if(tt){let Ze=Oe(t,v);Ze=N(Ze,ee,ee,e==="\\\\cdrightarrow"||e==="\\\\cdleftarrow"),et=new E("mover",[Ze,ce])}let lt=n&&n.body&&(n.body.body||n.body.length>0);if(lt){let Ze=Oe(n,v);Ze=N(Ze,ee,ee),Ge=new E("munder",[Ze,ce])}let je;return je=tt||lt?tt&&lt?new E("munderover",[c,Ge,et]):tt?new E("mover",[c,et]):new E("munder",[c,Ge]):new E("mover",[c,se]),b==="3.0"&&(je.style.height="1em"),je.setAttribute("accent","false"),je};$({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,i)=>({type:"xArrow",mode:e.mode,name:t,body:n[0],below:i[0]}),mathmlBuilder(e,t){let n=[ie(e.name,e.body,e.below,t)];return n.unshift(st(.2778)),n.push(st(.2778)),new E("mrow",n)}});let pe={"\\equilibriumRight":["\\longrightharpoonup","\\eqleftharpoondown"],"\\equilibriumLeft":["\\eqrightharpoonup","\\longleftharpoondown"]};$({type:"stackedArrow",names:["\\equilibriumRight","\\equilibriumLeft"],props:{numArgs:1,numOptionalArgs:1},handler({parser:e,funcName:t},n,i){let c=n[0]?{type:"hphantom",mode:e.mode,body:n[0]}:null,p=i[0]?{type:"hphantom",mode:e.mode,body:i[0]}:null;return{type:"stackedArrow",mode:e.mode,name:t,body:n[0],upperArrowBelow:p,lowerArrowBody:c,below:i[0]}},mathmlBuilder(e,t){let n=pe[e.name][0],i=pe[e.name][1],c=ie(n,e.body,e.upperArrowBelow,t),p=ie(i,e.lowerArrowBody,e.below,t),b,v=new E("mpadded",[c]);if(v.setAttribute("voffset","0.3em"),v.setAttribute("height","+0.3em"),v.setAttribute("depth","-0.3em"),e.name==="\\equilibriumLeft"){let D=new E("mpadded",[p]);D.setAttribute("width","0.5em"),b=new E("mpadded",[st(.2778),D,v,st(.2778)])}else v.setAttribute("width",e.name==="\\equilibriumRight"?"0.5em":"0"),b=new E("mpadded",[st(.2778),v,p,st(.2778)]);return b.setAttribute("voffset","-0.18em"),b.setAttribute("height","-0.18em"),b.setAttribute("depth","+0.18em"),b}});let Pe={};function Se({type:e,names:t,props:n,handler:i,mathmlBuilder:c}){let p={type:e,numArgs:n.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:i};for(let b=0;b<t.length;++b)Pe[t[b]]=p;c&&(C[e]=c)}function Me(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 rt(e){let t=at(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 at(e){return e&&(e.type==="atom"||e.type==="delimiter"||Object.prototype.hasOwnProperty.call(ze,e.type))?e:null}let Et={">":"\\\\cdrightarrow","<":"\\\\cdleftarrow","=":"\\\\cdlongequal",A:"\\uparrow",V:"\\downarrow","|":"\\Vert",".":"no arrow"},Nt=()=>({type:"styling",body:[],mode:"math",scriptLevel:"display"}),Yt=e=>e.type==="textord"&&e.text==="@",Rt=(e,t)=>(e.type==="mathord"||e.type==="atom")&&e.text===t;function wn(e,t,n){let i=Et[e];switch(i){case"\\\\cdrightarrow":case"\\\\cdleftarrow":return n.callFunction(i,[t[0]],[t[1]]);case"\\uparrow":case"\\downarrow":{let c={type:"atom",text:i,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"}}}$({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 E("mrow",t);let n=Oe(e.label,t);e.side==="left"&&n.classes.push("tml-shift-left");let i=new E("mtd",[n]);i.style.padding="0";let c=new E("mtr",[i]),p=new E("mtable",[c]),b=new E("mpadded",[p]);return b.setAttribute("width","0.1px"),b.setAttribute("displaystyle","false"),b.setAttribute("scriptlevel","1"),b}}),$({type:"cdlabelparent",names:["\\\\cdparent"],props:{numArgs:1},handler:({parser:e},t)=>({type:"cdlabelparent",mode:e.mode,fragment:t[0]}),mathmlBuilder:(e,t)=>new E("mrow",[Oe(e.fragment,t)])});let Ht=e=>({type:"ordgroup",mode:"math",body:e,semisimple:!0}),It=(e,t)=>({type:t,mode:"math",body:Ht(e)});class dt{constructor(t,n,i){this.lexer=t,this.start=n,this.end=i}static range(t,n){return n?t&&t.loc&&n.loc&&t.loc.lexer===n.loc.lexer?new dt(t.loc.lexer,t.loc.start,n.loc.end):null:t&&t.loc}}class St{constructor(t,n){this.text=t,this.loc=n}range(t,n){return new St(n,dt.range(this,t))}}let ut=0,Ot=1,Gt=2,xn=3,Wt={};function L(e,t){Wt[e]=t}let vn=Wt;L("\\noexpand",function(e){let t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}}),L("\\expandafter",function(e){let t=e.popToken();return e.expandOnce(!0),{tokens:[t],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 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}}),L("\\@ifstar","\\@ifnextchar *{\\@firstoftwo{#1}}"),L("\\TextOrMath",function(e){let t=e.consumeArgs(2);return e.mode==="text"?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}});let Vt=e=>{let t="";for(let n=e.length-1;n>-1;n--)t+=e[n].text;return t},pt={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},At=e=>{let t=e.future().text;return t==="EOF"?[null,""]:[pt[t.charAt(0)],t]},rn=(e,t,n)=>{for(let i=1;i<t.length;i++)e*=n,e+=pt[t.charAt(i)];return e};function wt(e){let t=e.consumeArgs(1)[0],n="",i=t[t.length-1].loc.start;for(let c=t.length-1;c>=0;c--){let p=t[c].loc.start;p>i&&(n+=" ",i=p),n+=t[c].text,i+=t[c].text.length}return n}L("\\char",function(e){let t,n=e.popToken(),i="";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]==="\\")i=n.text.charCodeAt(1);else{if(n.text==="EOF")throw new r("\\char` missing argument");i=n.text.charCodeAt(0)}else t=10;if(t){let c,p=n.text;if(i=pt[p.charAt(0)],i==null||i>=t)throw new r(`Invalid base-${t} digit ${n.text}`);for(i=rn(i,p,t),[c,p]=At(e);c!=null&&c<t;)i*=t,i+=c,i=rn(i,p,t),e.popToken(),[c,p]=At(e)}return`\\@char{${i}}`}),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 $t={",":"\\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 t="\\dotso",n=e.expandAfterFuture().text;return n in $t?t=$t[n]:(n.slice(0,4)==="\\not"||n in Ne.math&&["bin","rel"].includes(Ne.math[n].group))&&(t="\\dotsb"),t});let Ft={")":!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 Ft?"\\ldots\\,":"\\ldots"}),L("\\dotsc",function(e){let t=e.future().text;return t in Ft&&t!==","?"\\ldots\\,":"\\ldots"}),L("\\cdots",function(e){return e.future().text in Ft?"\\@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 r("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 Mt=(e,t)=>{let n=`}\\,\\middle${t[0]==="|"?"\\vert":"\\Vert"}\\,{`;return e.slice(0,t.index)+n+e.slice(t.index+t[0].length)};L("\\Braket",function(e){let t=wt(e),n=/\|\||\||\\\|/g,i;for(;(i=n.exec(t))!==null;)t=Mt(t,i);return"\\left\\langle{"+t+"}\\right\\rangle"}),L("\\Set",function(e){let t=wt(e),n=/\|\||\||\\\|/.exec(t);return n&&(t=Mt(t,n)),"\\left\\{\\:{"+t+"}\\:\\right\\}"}),L("\\set",function(e){return"\\{{"+wt(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 sn=e=>{let t=e[0][0].text,n=Vt(e[1]).split(","),i=String(n.length),c=i==="1"?"\\partial":`\\partial^${i}`,p="";return n.map(b=>{p+="\\partial "+b.trim()+"\\,"}),[t,c,p.replace(/\\,$/,"")]};function hn(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}L("\\pdv@numerator",function(e){let[t,n,i]=sn(e.consumeArgs(2));return`\\frac{${n} ${t}}{${i}}`}),L("\\pdv@next",function(e){let[t,n,i]=sn(e.consumeArgs(2));return`\\frac{${n}}{${i}} ${t}`}),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}}}
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
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 Lt=e=>{if(!e.parser.settings.displayMode)throw new r(`{${e.envName}} can be used only in display mode.`)},zt=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/,Jt=e=>{let t=e.get("\\arraystretch");typeof t!="string"&&(t=Vt(t.tokens)),t=isNaN(t)?null:Number(t);let n=e.get("\\arraycolsep");typeof n!="string"&&(n=Vt(n.tokens));let i=zt.exec(n);return[t,i?{number:+(i[1]+i[2]),unit:i[3]}:null]},on=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 Qt(e){if(e.indexOf("ed")===-1)return e.indexOf("*")===-1}function Bt(e,{cols:t,envClasses:n,autoTag:i,singleRow:c,emptySingleRow:p,maxNumCols:b,leqno:v,arraystretch:D,arraycolsep:z},se){let ce=n&&n.includes("bordermatrix")?"}":"\\end";e.gullet.beginGroup(),c||e.gullet.macros.set("\\cr","\\\\\\relax"),e.gullet.beginGroup();let ee=[],et=[ee],Ge=[],tt=[],lt=[],je=i!=null?[]:void 0;function Ze(){i&&e.gullet.macros.set("\\@eqnsw","1",!0)}function Ut(){je&&(e.gullet.macros.get("\\df@tag")?(je.push(e.subparse([new St("\\df@tag")])),e.gullet.macros.set("\\df@tag",void 0,!0)):je.push(!!i&&e.gullet.macros.get("\\@eqnsw")==="1"))}for(Ze(),lt.push(hn(e));;){let Tt=e.parseExpression(!1,c?"\\end":"\\\\");e.gullet.endGroup(),e.gullet.beginGroup(),Tt={type:"ordgroup",mode:e.mode,body:Tt,semisimple:!0},ee.push(Tt);let An=e.fetch().text;if(An==="&"){if(b&&ee.length===b){if(!n.includes("array"))throw new r(b===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(An===ce){Ut(),ee.length===1&&Tt.body.length===0&&(et.length>1||!p)&&et.pop(),tt.push(on(Tt.body)),lt.length<et.length+1&&lt.push([]);break}if(An!=="\\\\")throw new r("Expected & or \\\\ or \\cr or "+ce,e.nextToken);{let en;e.consume(),e.gullet.future().text!==" "&&(en=e.parseSizeGroup(!0)),Ge.push(en?en.value:null),Ut(),tt.push(on(Tt.body)),lt.push(hn(e)),ee=[],et.push(ee),Ze()}}}return e.gullet.endGroup(),e.gullet.endGroup(),{type:"array",mode:e.mode,body:et,cols:t,rowGaps:Ge,hLinesBeforeRow:lt,envClasses:n,autoTag:i,scriptLevel:se,tags:je,labels:tt,leqno:v,arraystretch:D,arraycolsep:z}}function xt(e){return e.slice(0,1)==="d"?"display":"text"}let an={c:"center ",l:"left ",r:"right "},kn=e=>{let t=new E("mtd",[]);return t.style={padding:"0",width:"50%"},e.envClasses.includes("multline")&&(t.style.width="7.5%"),t},bt=function(e,t){let n=[],i=e.body.length,c=e.hLinesBeforeRow,p=e.tags&&e.tags.some(z=>z);for(let z=0;z<i;z++){let se=e.body[z],ce=[],ee=e.scriptLevel==="text"?Ot:e.scriptLevel==="script"?Gt:ut;for(let je=0;je<se.length;je++){let Ze=new E("mtd",[Oe(se[je],t.withLevel(ee))]);if(e.envClasses.includes("multline")){let Ut=z===0?"left":z===i-1?"right":"center";Ut!=="center"&&Ze.classes.push("tml-"+Ut)}ce.push(Ze)}let et=e.body[0].length;for(let je=0;je<et-se.length;je++)ce.push(new E("mtd",[],[],t));if(p){let je=e.tags[z],Ze;je===!0?Ze=new E("mtext",[new Re(["tml-eqn"])]):je===!1?Ze=new E("mtext",[],[]):(Ze=Qe(je[0].body,t.withLevel(ee),!0),Ze=Je(Ze),Ze.classes=["tml-tag"]),Ze&&(ce.unshift(kn(e)),ce.push(kn(e)),e.leqno?ce[0].children.push(Ze):ce[ce.length-1].children.push(Ze))}let Ge=new E("mtr",ce,[]),tt=e.labels.shift();tt&&e.tags&&e.tags[z]&&(Ge.setAttribute("id",tt),Array.isArray(e.tags[z])&&Ge.classes.push("tml-tageqn")),z===0&&c[0].length>0&&(c[0].length===2?Ge.children.forEach(je=>{je.style.borderTop="0.15em double"}):Ge.children.forEach(je=>{je.style.borderTop=c[0][0]?"0.06em dashed":"0.06em solid"})),c[z+1].length>0&&(c[z+1].length===2?Ge.children.forEach(je=>{je.style.borderBottom="0.15em double"}):Ge.children.forEach(je=>{je.style.borderBottom=c[z+1][0]?"0.06em dashed":"0.06em solid"}));let lt=!0;for(let je=0;je<Ge.children.length;je++){let Ze=Ge.children[je].children[0];if(!Ze||Ze.type!=="mpadded"||Ze.attributes.height!=="0px"){lt=!1;break}}if(lt){Ge.classes.push("ff-squash");for(let je=0;je<Ge.children.length;je++)Ge.children[je].style.paddingTop="0",Ge.children[je].style.paddingBottom="0"}n.push(Ge)}if(e.arraystretch&&e.arraystretch!==1){let z=String(1.4*e.arraystretch-.8)+"ex";for(let se=0;se<n.length;se++)for(let ce=0;ce<n[se].children.length;ce++)n[se].children[ce].style.paddingTop=z,n[se].children[ce].style.paddingBottom=z}let b,v;if(e.envClasses.length>0&&(b=e.envClasses.includes("abut")||e.envClasses.includes("cases")?"0":e.envClasses.includes("small")?"0.1389":e.envClasses.includes("cd")?"0.25":"0.4",v="em"),e.arraycolsep){let z=ot(e.arraycolsep,t);b=z.number.toFixed(4),v=z.unit}if(b){let z=n.length===0?0:n[0].children.length,se=(ce,ee)=>ce===0&&ee===0||ce===z-1&&ee===1?"0":e.envClasses[0]!=="align"?b:ee===1?"0":p?ce%2?"1":"0":ce%2?"0":"1";for(let ce=0;ce<n.length;ce++)for(let ee=0;ee<n[ce].children.length;ee++)n[ce].children[ee].style.paddingLeft=`${se(ee,0)}${v}`,n[ce].children[ee].style.paddingRight=`${se(ee,1)}${v}`}if(e.envClasses.length===0)for(let z=0;z<n.length;z++)n[z].children[0].style.paddingLeft="0em",n[z].children.length===n[0].children.length&&(n[z].children[n[z].children.length-1].style.paddingRight="0em");if(e.envClasses.length>0){let z=e.envClasses.includes("align")||e.envClasses.includes("alignat");for(let se=0;se<n.length;se++){let ce=n[se];if(z){for(let ee=0;ee<ce.children.length;ee++)ce.children[ee].classes=["tml-"+(ee%2?"left":"right")];if(p){let ee=e.leqno?0:ce.children.length-1;ce.children[ee].classes=[]}}if(ce.children.length>1&&e.envClasses.includes("cases")&&(ce.children[1].style.paddingLeft="1em"),e.envClasses.includes("cases")||e.envClasses.includes("subarray"))for(let ee of ce.children)ee.classes.push("tml-left")}}let D=new E("mtable",n);if(e.envClasses.length>0&&(e.envClasses.includes("jot")?D.classes.push("tml-jot"):e.envClasses.includes("small")&&D.classes.push("tml-small")),e.scriptLevel==="display"&&D.setAttribute("displaystyle","true"),(e.autoTag||e.envClasses.includes("multline"))&&(D.style.width="100%"),e.cols&&e.cols.length>0){let z=e.cols,se=!1,ce=0,ee=z.length;for(;z[ce].type==="separator";)ce+=1;for(;z[ee-1].type==="separator";)ee-=1;if(z[0].type==="separator"){let Ge=z[1].type==="separator"?"0.15em double":z[0].separator==="|"?"0.06em solid ":"0.06em dashed ";for(let tt of D.children)tt.children[0].style.borderLeft=Ge}let et=p?0:-1;for(let Ge=ce;Ge<ee;Ge++)if(z[Ge].type==="align"){let tt=an[z[Ge].align];et+=1;for(let lt of D.children)tt.trim()!=="center"&&et<lt.children.length&&(lt.children[et].classes=["tml-"+tt.trim()]);se=!0}else if(z[Ge].type==="separator"){if(se){let tt=z[Ge+1].type==="separator"?"0.15em double":z[Ge].separator==="|"?"0.06em solid":"0.06em dashed";for(let lt of D.children)et<lt.children.length&&(lt.children[et].style.borderRight=tt)}se=!1}if(z[z.length-1].type==="separator"){let Ge=z[z.length-2].type==="separator"?"0.15em double":z[z.length-1].separator==="|"?"0.06em solid":"0.06em dashed";for(let tt of D.children)tt.children[tt.children.length-1].style.borderRight=Ge,tt.children[tt.children.length-1].style.paddingRight="0.4em"}}return e.envClasses.includes("small")&&(D=new E("mstyle",[D]),D.setAttribute("scriptlevel","1")),D},T=function(e,t){e.envName.indexOf("ed")===-1&&Lt(e);let n=e.envName==="split",i=[],c=Bt(e.parser,{cols:i,emptySingleRow:!0,autoTag:n?void 0:Qt(e.envName),envClasses:["abut","jot"],maxNumCols:e.envName==="split"?2:void 0,leqno:e.parser.settings.leqno},"display"),p,b=0,v=e.envName.indexOf("at")>-1;if(t[0]&&v){let D="";for(let z=0;z<t[0].body.length;z++)D+=Me(t[0].body[z],"textord").text;if(isNaN(D))throw new r("The alignat enviroment requires a numeric first argument.");p=Number(D),b=2*p}c.body.forEach(function(D){if(v){let z=D.length/2;if(p<z)throw new r(`Too many math in a row: expected ${p}, but got ${z}`,D[0])}else b<D.length&&(b=D.length)});for(let D=0;D<b;++D){let z="r";D%2==1&&(z="l"),i[D]={type:"align",align:z}}return e.envName==="split"||(v?c.envClasses.push("alignat"):c.envClasses[0]="align"),c};Se({type:"array",names:["array","darray"],props:{numArgs:1},handler(e,t){let n=(at(t[0])?[t[0]]:Me(t[0],"ordgroup").body).map(function(b){let v=rt(b).text;if("lcr".indexOf(v)!==-1)return{type:"align",align:v};if(v==="|")return{type:"separator",separator:"|"};if(v===":")return{type:"separator",separator:":"};throw new r("Unknown column alignment: "+v,b)}),[i,c]=Jt(e.parser.gullet.macros),p={cols:n,envClasses:["array"],maxNumCols:n.length,arraystretch:i,arraycolsep:c};return Bt(e.parser,p,xt(e.envName))},mathmlBuilder:bt}),Se({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",i={envClasses:[],cols:[]};if(e.envName.charAt(e.envName.length-1)==="*"){let v=e.parser;if(v.consumeSpaces(),v.fetch().text==="["){if(v.consume(),v.consumeSpaces(),n=v.fetch().text,"lcr".indexOf(n)===-1)throw new r("Expected l or c or r",v.nextToken);v.consume(),v.consumeSpaces(),v.expect("]"),v.consume(),i.cols=[]}}let c=Bt(e.parser,i,"text");c.cols=c.body.length>0?new Array(c.body[0].length).fill({type:"align",align:n}):[];let[p,b]=Jt(e.parser.gullet.macros);return c.arraystretch=p,!b||b===6&&b==="pt"||(c.arraycolsep=b),t?{type:"leftright",mode:e.mode,body:[c],left:t[0],right:t[1],rightColor:void 0}:c},mathmlBuilder:bt}),Se({type:"array",names:["bordermatrix"],props:{numArgs:0},handler(e){let t=Bt(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,i)=>{let c=n.body;c[0].shift();let p=new Array(c.length-1).fill().map(()=>[]);for(let se=1;se<c.length;se++){p[se-1].push(c[se].shift());let ce=[];for(let ee=0;ee<c[se].length;ee++)ce.push(c[se][ee]);p[se-1].push(It(ce,"vphantom"))}let b=new Array(c.length).fill().map(()=>[]);for(let se=0;se<c[0].length;se++)b[0].push(c[0][se]);for(let se=1;se<c.length;se++)for(let ce=0;ce<c[0].length;ce++)b[se].push(It(c[se][ce].body,"hphantom"));for(let se=0;se<c[0].length;se++)c[0][se]=It(c[0][se].body,"hphantom");let v={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"}},D={type:"styling",mode:"math",scriptLevel:"text",body:[{type:"array",mode:"math",body:b,cols:new Array(b.length).fill({type:"align",align:"c"}),rowGaps:new Array(b.length-1).fill(null),hLinesBeforeRow:new Array(b.length+1).fill().map(()=>[]),envClasses:[],scriptLevel:"text",arraystretch:1,labels:new Array(b.length).fill(""),arraycolsep:null}]},z={type:"leftright",mode:"math",body:[n],left:i?i[0]:"(",right:i?i[1]:")",rightColor:void 0};return Ht([v,{type:"supsub",mode:"math",stack:!0,base:{type:"op",mode:"math",limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!0,symbol:!1,suppressBaseShift:!0,body:[z]},sup:D,sub:null}])})(t,e.delimiters)},mathmlBuilder:bt}),Se({type:"array",names:["smallmatrix"],props:{numArgs:0},handler:e=>Bt(e.parser,{envClasses:["small"]},"script"),mathmlBuilder:bt}),Se({type:"array",names:["subarray"],props:{numArgs:1},handler(e,t){let n=(at(t[0])?[t[0]]:Me(t[0],"ordgroup").body).map(function(c){let p=rt(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 i={cols:n,envClasses:["small"]};if(i=Bt(e.parser,i,"script"),i.body.length>0&&i.body[0].length>1)throw new r("{subarray} can contain only one column");return i},mathmlBuilder:bt}),Se({type:"array",names:["cases","dcases","rcases","drcases"],props:{numArgs:0},handler(e){let t=Bt(e.parser,{cols:[],envClasses:["cases"]},xt(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:bt}),Se({type:"array",names:["align","align*","aligned","split"],props:{numArgs:0},handler:T,mathmlBuilder:bt}),Se({type:"array",names:["alignat","alignat*","alignedat"],props:{numArgs:1},handler:T,mathmlBuilder:bt}),Se({type:"array",names:["gathered","gather","gather*"],props:{numArgs:0},handler(e){e.envName!=="gathered"&&Lt(e);let t={cols:[],envClasses:["abut","jot"],autoTag:Qt(e.envName),emptySingleRow:!0,leqno:e.parser.settings.leqno};return Bt(e.parser,t,"display")},mathmlBuilder:bt}),Se({type:"array",names:["equation","equation*"],props:{numArgs:0},handler(e){Lt(e);let t={autoTag:Qt(e.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,envClasses:["align"],leqno:e.parser.settings.leqno};return Bt(e.parser,t,"display")},mathmlBuilder:bt}),Se({type:"array",names:["multline","multline*"],props:{numArgs:0},handler(e){Lt(e);let t={autoTag:e.envName==="multline",maxNumCols:1,envClasses:["jot","multline"],leqno:e.parser.settings.leqno};return Bt(e.parser,t,"display")},mathmlBuilder:bt}),Se({type:"array",names:["CD"],props:{numArgs:0},handler:e=>(Lt(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 i=[],c=[i];for(let p=0;p<n.length;p++){let b=n[p],v=Nt();for(let D=0;D<b.length;D++)if(Yt(b[D])){i.push(v),D+=1;let z=rt(b[D]).text,se=new Array(2);if(se[0]={type:"ordgroup",mode:"math",body:[]},se[1]={type:"ordgroup",mode:"math",body:[]},!("=|.".indexOf(z)>-1)){if(!("<>AV".indexOf(z)>-1))throw new r('Expected one of "<>AV=|." after @.');for(let ee=0;ee<2;ee++){let et=!0;for(let Ge=D+1;Ge<b.length;Ge++){if(Rt(b[Ge],z)){et=!1,D=Ge;break}if(Yt(b[Ge]))throw new r("Missing a "+z+" character to complete a CD arrow.",b[Ge]);se[ee].body.push(b[Ge])}if(et)throw new r("Missing a "+z+" character to complete a CD arrow.",b[D])}}let ce=wn(z,se,t);i.push(ce),v=Nt()}else v.body.push(b[D]);p%2==0?i.push(v):i.shift(),i=[],c.push(i)}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:bt}),$({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 K=Pe;$({type:"bordermatrix",names:["\\bordermatrix","\\matrix"],props:{numArgs:0,numOptionalArgs:1},handler:({parser:e,funcName:t},n,i)=>{let c=["(",")"];if(t==="\\bordermatrix"&&i[0]&&i[0].body){let D=i[0].body;D.length===1&&D[0].type==="delimiter"&&(c=[D[0].left,D[0].right])}e.consumeSpaces(),e.consume();let p=K.bordermatrix,b={mode:e.mode,envName:t.slice(1),delimiters:c,parser:e},v=p.handler(b);return e.expect("}",!0),v}}),$({type:"cancelto",names:["\\cancelto"],props:{numArgs:2},handler({parser:e},t){let n=t[0],i=t[1];return{type:"cancelto",mode:e.mode,body:i,to:n,isCharacterBox:w(i)}},mathmlBuilder(e,t){let n=new E("mrow",[Oe(e.body,t)],["ff-narrow"]),i=new E("mphantom",[Oe(e.body,t)]),c=new E("mrow",[i],["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 E("mrow",[n,c],["menclose"]);if(!e.isCharacterBox||/[f∫∑]/.test(e.body.body[0].text))i.style.paddingRight="0.2em";else{i.style.padding="0.5ex 0.1em 0 0";let ce=new E("mspace",[]);ce.setAttribute("height","0.85em"),n.children.push(ce)}let b;if(e.isCharacterBox)b=new E("mspace",[]),b.setAttribute("height","1em");else{let ce=Oe(e.body,t),ee=new E("mpadded",[ce]);ee.setAttribute("width","0.1px"),b=new E("mphantom",[ee])}let v=Oe(e.to,t);v.style.color=t.color;let D=new E("mpadded",[v]);if(!e.isCharacterBox||/[f∫∑]/.test(e.body.body[0].text)){let ce=new E("mspace",[]);ce.setAttribute("width","0.2em"),D.children.unshift(ce)}D.setAttribute("width","0.1px");let z=new E("mover",[b,D]),se=new E("mrow",[],["ff-nudge-left"]);return xe([re([p,z]),se])}}),$({type:"textord",names:["\\@char"],props:{numArgs:1,allowedInText:!0},handler({parser:e,token:t},n){let i=Me(n[0],"ordgroup").body,c="";for(let b=0;b<i.length;b++)c+=Me(i[b],"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 y=/^(#[a-f0-9]{3}|#?[a-f0-9]{6})$/i,_=/^(#[a-f0-9]{3}|#?[a-f0-9]{6}|[a-z]+)$/i,S=/^ *\d{1,3} *(?:, *\d{1,3} *){2}$/,R=/^ *[10](?:\.\d*)? *(?:, *[10](?:\.\d*)? *){2}$/,Z=/^[a-f0-9]{6}$/i,ue=e=>{let t=e.toString(16);return t.length===1&&(t="0"+t),t},Ve=JSON.parse(`{
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`),Ee=F,fe=J),U===void 0&
88
88
  "Yellow": "#fff404",
89
89
  "YellowGreen": "#98cc6c",
90
90
  "YellowOrange": "#ffa41c"
91
- }`),it=(e,t)=>{let n="";if(e==="HTML"){if(!y.test(t))throw new r("Invalid HTML input.");n=t}else if(e==="RGB"){if(!S.test(t))throw new r("Invalid RGB input.");t.split(",").map(i=>{n+=ue(Number(i.trim()))})}else{if(!R.test(t))throw new r("Invalid rbg input.");t.split(",").map(i=>{let c=Number(i.trim());if(c>1)throw new r("Color rgb input must be < 1.");n+=ue(Number((255*c).toFixed(0)))})}return n.charAt(0)!=="#"&&(n="#"+n),n},ht=(e,t,n)=>{let i=`\\\\color@${e}`;if(!_.exec(e))throw new r("Invalid color: '"+e+"'",n);return Z.test(e)?"#"+e:(e.charAt(0)==="#"||(t.has(i)?e=t.get(i).tokens[0].text:Ve[e]&&(e=Ve[e])),e)},mn=(e,t)=>{let n=Le(e.body,t.withColor(e.color));return n.length===0&&n.push(new E("mrow")),n=n.map(i=>(i.style.color=e.color,i)),xe(n)};$({type:"color",names:["\\textcolor"],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw","original"]},handler({parser:e,token:t},n,i){let c=i[0]&&Me(i[0],"raw").string,p="";if(c){let v=Me(n[0],"raw").string;p=it(c,v)}else p=ht(Me(n[0],"raw").string,e.gullet.macros,t);let b=n[1];return{type:"color",mode:e.mode,color:p,isTextColor:!0,body:oe(b)}},mathmlBuilder:mn}),$({type:"color",names:["\\color"],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw"]},handler({parser:e,breakOnTokenText:t,token:n},i,c){let p=c[0]&&Me(c[0],"raw").string,b="";if(p){let D=Me(i[0],"raw").string;b=it(p,D)}else b=ht(Me(i[0],"raw").string,e.gullet.macros,n);let v=e.parseExpression(!0,t,!0);return{type:"color",mode:e.mode,color:b,isTextColor:!1,body:v}},mathmlBuilder:mn}),$({type:"color",names:["\\definecolor"],props:{numArgs:3,allowedInText:!0,argTypes:["raw","raw","raw"]},handler({parser:e,funcName:t,token:n},i){let c=Me(i[0],"raw").string;if(!/^[A-Za-z]+$/.test(c))throw new r("Color name must be latin letters.",n);let p=Me(i[1],"raw").string;if(!["HTML","RGB","rgb"].includes(p))throw new r("Color model must be HTML, RGB, or rgb.",n);let b=Me(i[2],"raw").string,v=it(p,b);return e.gullet.macros.set(`\\\\color@${c}`,{tokens:[{text:v}],numArgs:0}),{type:"internal",mode:e.mode}}}),$({type:"cr",names:["\\\\"],props:{numArgs:0,numOptionalArgs:0,allowedInText:!0},handler({parser:e},t,n){let i=e.gullet.future().text==="["?e.parseSizeGroup(!0):null,c=!e.settings.displayMode;return{type:"cr",mode:e.mode,newLine:c,size:i&&Me(i,"size").value}},mathmlBuilder(e,t){let n=new E("mo");if(e.newLine&&(n.setAttribute("linebreak","newline"),e.size)){let i=ot(e.size,t);n.setAttribute("height",i.number+i.unit)}return n}});let Dn={"\\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},as=(e,t,n,i)=>{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,i)};$({type:"internal",names:["\\global","\\long","\\\\globallong"],props:{numArgs:0,allowedInText:!0},handler({parser:e,funcName:t}){e.consumeSpaces();let n=e.fetch();if(Dn[n.text])return t!=="\\global"&&t!=="\\\\globallong"||(n.text=Dn[n.text]),Me(e.parseFunction(),"internal");throw new r("Invalid token after macro prefix",n)}}),$({type:"internal",names:["\\def","\\gdef","\\edef","\\xdef"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){let n=e.gullet.popToken(),i=n.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(i))throw new r("Expected a control sequence",n);let c,p=0,b=[[]];for(;e.gullet.future().text!=="{";)if(n=e.gullet.popToken(),n.text==="#"){if(e.gullet.future().text==="{"){c=e.gullet.future(),b[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++,b.push([])}else{if(n.text==="EOF")throw new r("Expected a macro definition");b[p].push(n.text)}let{tokens:v}=e.gullet.consumeArg();if(c&&v.unshift(c),t==="\\edef"||t==="\\xdef"){if(v=e.gullet.expandTokens(v),v.length>e.gullet.settings.maxExpand)throw new r("Too many expansions in an "+t);v.reverse()}return e.gullet.macros.set(i,{tokens:v,numArgs:p,delimiters:b},t===Dn[t]),{type:"internal",mode:e.mode}}}),$({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 i=(c=>{let p=c.gullet.popToken();return p.text==="="&&(p=c.gullet.popToken(),p.text===" "&&(p=c.gullet.popToken())),p})(e);return as(e,n,i,t==="\\\\globallet"),{type:"internal",mode:e.mode}}}),$({type:"internal",names:["\\futurelet","\\\\globalfuture"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){let n=Xn(e.gullet.popToken()),i=e.gullet.popToken(),c=e.gullet.popToken();return as(e,n,c,t==="\\\\globalfuture"),e.gullet.pushToken(c),e.gullet.pushToken(i),{type:"internal",mode:e.mode}}}),$({type:"internal",names:["\\newcommand","\\renewcommand","\\providecommand"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){let n="",i=e.gullet.popToken();i.text==="{"?(n=Xn(e.gullet.popToken()),e.gullet.popToken()):n=Xn(i);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 v=e.gullet.popToken();if(v=e.gullet.popToken(),!/^[0-9]$/.test(v.text))throw new r(`Invalid number of arguments: "${v.text}"`);if(p=parseInt(v.text),v=e.gullet.popToken(),v.text!=="]")throw new r(`Invalid argument "${v.text}"`)}let{tokens:b}=e.gullet.consumeArg();return t==="\\providecommand"&&e.gullet.macros.has(n)||e.gullet.macros.set(n,{tokens:b,numArgs:p}),{type:"internal",mode:e.mode}}});let _r={"\\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}},Tr={"(":")","\\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"},Xi=new Set(Object.keys(Tr));new Set(Object.values(Tr));let ls=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","."]),Yi=new Set(["}","\\left","\\middle","\\right"]),Yn=e=>e.length>0&&(ls.has(e)||_r[e]||Yi.has(e)),cs=[0,1.2,1.8,2.4,3];function qn(e,t){e.type==="ordgroup"&&e.body.length===1&&(e=e.body[0]);let n=at(e);if(n&&ls.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 Ji=new Set(["/","\\","\\backslash","\u2216","\\vert","|"]),Jn=(e,t,n,i)=>{let c=new E("mo",[ne(e==="."?"":e,t)]);return c.setAttribute("fence","true"),c.setAttribute("form",n),c.setAttribute("stretchy",i?"true":"false"),c};function ds(e){if(!e.body)throw new Error("Bug: The delim ParseNode wasn't fully parsed.")}$({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=qn(t[0],e),i={type:"delimsizing",mode:e.parser.mode,size:_r[e.funcName].size,mclass:_r[e.funcName].mclass,delim:n.text},c=e.parser.fetch().text;return c!=="^"&&c!=="_"?i:{type:"ordgroup",mode:"math",body:[i,{type:"ordgroup",mode:"math",body:[]}]}},mathmlBuilder:e=>{let t=[],n=e.delim==="."?"":e.delim;t.push(ne(n,e.mode));let i=new E("mo",t);return e.mclass==="mopen"||e.mclass==="mclose"?i.setAttribute("fence","true"):i.setAttribute("fence","false"),(Ji.has(n)||n.indexOf("arrow")>-1)&&i.setAttribute("stretchy","true"),i.setAttribute("symmetric","true"),i.setAttribute("minsize",cs[e.size]+"em"),i.setAttribute("maxsize",cs[e.size]+"em"),i}}),$({type:"leftright-right",names:["\\right"],props:{numArgs:1,argTypes:["primitive"]},handler:(e,t)=>({type:"leftright-right",mode:e.parser.mode,delim:qn(t[0],e).text})}),$({type:"leftright",names:["\\left"],props:{numArgs:1,argTypes:["primitive"]},handler:(e,t)=>{let n=qn(t[0],e),i=e.parser;++i.leftrightDepth;let c=i.parseExpression(!1,"\\right",!0),p=i.fetch();for(;p.text==="\\middle";){i.consume();let v=i.fetch().text;if(!Ne.math[v])throw new r(`Invalid delimiter '${v}' after '\\middle'`);qn({type:"atom",mode:"math",text:v},{funcName:"\\middle"}),c.push({type:"middle",mode:"math",delim:v}),i.consume(),c=c.concat(i.parseExpression(!1,"\\right",!0)),p=i.fetch()}--i.leftrightDepth,i.expect("\\right",!1);let b=Me(i.parseFunction(),"leftright-right");return{type:"leftright",mode:i.mode,body:c,left:n.text,right:b.delim,isStretchy:!0}},mathmlBuilder:(e,t)=>{ds(e);let n=Le(e.body,t),i=Jn(e.left,e.mode,"prefix",!0);n.unshift(i);let c=Jn(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),re(n)}}),$({type:"delimiter",names:Array.from(Xi),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 i=Tr[t],c=e.parseExpression(!1,i,!1);if(e.fetch().text!==i)throw new r("Unmatched delimiter");return e.consume(),{type:"delimiter",mode:e.mode,body:c,left:t,right:i}},mathmlBuilder:(e,t)=>{ds(e);let n=Le(e.body,t),i=Jn(e.left,e.mode,"prefix",!1);n.unshift(i);let c=Jn(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),re(n)}}),$({type:"middle",names:["\\middle"],props:{numArgs:1,argTypes:["primitive"]},handler:(e,t)=>{let n=qn(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=ne(e.delim,e.mode),n=new E("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 Qi=["\\boxed","\\fcolorbox","\\colorbox"],En=(e,t)=>{let n=Qi.includes(e.label)?"mrow":"menclose",i=new E(n,[Oe(e.body,t)]);switch(e.label){case"\\overline":i.setAttribute("notation","top"),i.classes.push("tml-overline");break;case"\\underline":i.setAttribute("notation","bottom"),i.classes.push("tml-underline");break;case"\\cancel":i.setAttribute("notation","updiagonalstrike"),i.children.push(new E("mrow",[],["tml-cancel","upstrike"]));break;case"\\bcancel":i.setAttribute("notation","downdiagonalstrike"),i.children.push(new E("mrow",[],["tml-cancel","downstrike"]));break;case"\\sout":i.setAttribute("notation","horizontalstrike"),i.children.push(new E("mrow",[],["tml-cancel","sout"]));break;case"\\xcancel":i.setAttribute("notation","updiagonalstrike downdiagonalstrike"),i.children.push(new E("mrow",[],["tml-cancel","tml-xcancel"]));break;case"\\longdiv":i.setAttribute("notation","longdiv"),i.classes.push("longdiv-top"),i.children.push(new E("mrow",[],["longdiv-arc"]));break;case"\\phase":i.setAttribute("notation","phasorangle"),i.classes.push("phasor-bottom"),i.children.push(new E("mrow",[],["phasor-angle"]));break;case"\\textcircled":i.setAttribute("notation","circle"),i.classes.push("circle-pad"),i.children.push(new E("mrow",[],["textcircle"]));break;case"\\angl":i.setAttribute("notation","actuarial"),i.classes.push("actuarial");break;case"\\boxed":i.style.padding="3pt",i.style.border="1px solid",i.setAttribute("scriptlevel","0"),i.setAttribute("displaystyle","true");break;case"\\fbox":i.setAttribute("notation","box"),i.classes.push("tml-fbox");break;case"\\fcolorbox":case"\\colorbox":i.style.padding="0.3em",e.label==="\\fcolorbox"&&(i.style.border="0.0667em solid "+String(e.borderColor))}return e.backgroundColor&&i.setAttribute("mathbackground",e.backgroundColor),i};$({type:"enclose",names:["\\colorbox"],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw","text"]},handler({parser:e,funcName:t},n,i){let c=i[0]&&Me(i[0],"raw").string,p="";if(c){let v=Me(n[0],"raw").string;p=it(c,v)}else p=ht(Me(n[0],"raw").string,e.gullet.macros);let b=n[1];return{type:"enclose",mode:e.mode,label:t,backgroundColor:p,body:b}},mathmlBuilder:En}),$({type:"enclose",names:["\\fcolorbox"],props:{numArgs:3,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw","raw","text"]},handler({parser:e,funcName:t},n,i){let c=i[0]&&Me(i[0],"raw").string,p,b="";if(c){let D=Me(n[0],"raw").string,z=Me(n[0],"raw").string;b=it(c,D),p=it(c,z)}else b=ht(Me(n[0],"raw").string,e.gullet.macros),p=ht(Me(n[1],"raw").string,e.gullet.macros);let v=n[2];return{type:"enclose",mode:e.mode,label:t,backgroundColor:p,borderColor:b,body:v}},mathmlBuilder:En}),$({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]})}),$({type:"enclose",names:["\\angl","\\cancel","\\bcancel","\\xcancel","\\overline","\\boxed","\\longdiv","\\phase"],props:{numArgs:1},handler({parser:e,funcName:t},n){let i=n[0];return{type:"enclose",mode:e.mode,label:t,body:i}},mathmlBuilder:En}),$({type:"enclose",names:["\\sout"],props:{numArgs:1,allowedInText:!0},handler({parser:e,funcName:t},n){let i=n[0];return{type:"enclose",mode:e.mode,label:t,body:i}},mathmlBuilder:En}),$({type:"enclose",names:["\\underline"],props:{numArgs:1,allowedInText:!0},handler({parser:e,funcName:t},n){let i=n[0];return{type:"enclose",mode:e.mode,label:t,body:i}},mathmlBuilder:En}),$({type:"enclose",names:["\\textcircled"],props:{numArgs:1,argTypes:["text"],allowedInArgument:!0,allowedInText:!0},handler({parser:e,funcName:t},n){let i=n[0];return{type:"enclose",mode:e.mode,label:t,body:i}},mathmlBuilder:En}),$({type:"environment",names:["\\begin","\\end"],props:{numArgs:1,argTypes:["text"]},handler({parser:e,funcName:t},n){let i=n[0];if(i.type!=="ordgroup")throw new r("Invalid environment name",i);let c="";for(let p=0;p<i.body.length;++p)c+=Me(i.body[p],"textord").text;if(t==="\\begin"){if(!Object.prototype.hasOwnProperty.call(K,c))throw new r("No such environment: "+c,i);let p=K[c],{args:b,optArgs:v}=e.parseArguments("\\begin{"+c+"}",p),D={mode:e.mode,envName:c,parser:e},z=p.handler(D,b,v);e.expect("\\end",!1);let se=e.nextToken,ce=Me(e.parseFunction(),"environment");if(ce.name!==c)throw new r(`Mismatch: \\begin{${c}} matched by \\end{${ce.name}}`,se);return z}return{type:"environment",mode:e.mode,name:c,nameGroup:i}}}),$({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 E("mrow")}),$({type:"noTag",names:["\\env@notag"],props:{numArgs:0},handler:({parser:e})=>({type:"noTag",mode:e.mode}),mathmlBuilder:(e,t)=>new E("mrow")});let us=Object.freeze({B:8426,E:8427,F:8427,H:8387,I:8391,L:8390,M:8422,R:8393,e:8394,g:8355,o:8389}),ea=Object.freeze({C:8426,H:8388,I:8392,R:8394,Z:8398}),ta=Object.freeze({C:8383,H:8389,N:8391,P:8393,Q:8393,R:8395,Z:8394}),ps=Object.freeze({"\u03F5":119527,\u03D1:119564,\u03F0:119534,\u03C6:119577,\u03F1:119535,\u03D6:119563}),na=Object.freeze({"\u03F5":119643,\u03D1:119680,\u03F0:119650,\u03C6:119693,\u03F1:119651,\u03D6:119679}),hs=Object.freeze({"\u03F5":119701,\u03D1:119738,\u03F0:119708,\u03C6:119751,\u03F1:119709,\u03D6:119737}),ra=Object.freeze({"\u03F5":119759,\u03D1:119796,\u03F0:119766,\u03C6:119809,\u03F1:119767,\u03D6:119795}),sa=Object.freeze({upperCaseLatin:{normal:e=>0,bold:e=>119743,italic:e=>119795,"bold-italic":e=>119847,script:e=>us[e]||119899,"script-bold":e=>119951,fraktur:e=>ea[e]||120003,"fraktur-bold":e=>120107,"double-struck":e=>ta[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=>us[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=>ps[e]||-51,italic:e=>0,"bold-italic":e=>na[e]||58,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>0,"sans-serif":e=>hs[e]||116,"sans-serif-bold":e=>hs[e]||116,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>ra[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}}),Sn=(e,t)=>{let n=e.codePointAt(0),i=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||ps[e]?"varGreek":47<n&&n<58?"numeral":"other";return i==="other"?e:String.fromCodePoint(n+sa[i][t](e))},oa=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"}),ia=["mathrm","mathit"],ms=(e,t)=>{let n=e.font,i=t.withFont(n),c=Oe(e.body,i);if(c.children.length===0)return c;if(n==="boldsymbol"&&["mo","mpadded","mrow"].includes(c.type))return c.style.fontWeight="bold",c;if(((v,D)=>{if(!ia.includes(D)||!v.body||v.body.type!=="ordgroup"||v.body.body.length===1||v.body.body[0].type!=="mathord")return!1;for(let z=1;z<v.body.body.length;z++){let se=v.body.body[z].type;if(se!=="mathord"&&(se!=="textord"||isNaN(v.body.body[z].text)))return!1}return!0})(e,n)){let v=c.children[0].children[0].children?c.children[0].children[0]:c.children[0];delete v.attributes.mathvariant;for(let z=1;z<c.children.length;z++)v.children[0].text+=c.children[z].children[0].children?c.children[z].children[0].children[0].text:c.children[z].children[0].text;if(n==="mathit")return v.children[0].text=v.children[0].text.split("").map(z=>Sn(z,"italic")).join(""),v;let D=new E("mpadded",[v]);return D.setAttribute("lspace","0"),D}let p=c.children[0].type==="mo";for(let v=1;v<c.children.length;v++)c.children[v].type==="mo"&&n==="boldsymbol"&&(c.children[v].style.fontWeight="bold"),c.children[v].type!=="mi"&&(p=!1),(c.children[v].attributes&&c.children[v].attributes.mathvariant||"")!=="normal"&&(p=!1);if(!p)return c;let b=c.children[0];for(let v=1;v<c.children.length;v++)b.children.push(c.children[v].children[0]);if(b.attributes.mathvariant&&b.attributes.mathvariant==="normal"){let v=new E("mtext",new Ie("\u200B"));return new E("mrow",[v,b])}return b},fs={"\\Bbb":"\\mathbb","\\bold":"\\mathbf","\\frak":"\\mathfrak","\\bm":"\\boldsymbol"};$({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 i=he(n[0]),c=t;return c in fs&&(c=fs[c]),{type:"font",mode:e.mode,font:c.slice(1),body:i}},mathmlBuilder:ms}),$({type:"font",names:["\\rm","\\sf","\\tt","\\bf","\\it","\\cal"],props:{numArgs:0,allowedInText:!0},handler:({parser:e,funcName:t,breakOnTokenText:n},i)=>{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:ms});let gs=["display","text","script","scriptscript"],aa={auto:-1,display:0,text:0,script:1,scriptscript:2},Cr=(e,t)=>{t=((p,b)=>{let v=b;if(p==="display"){let D=v.level>=Gt?Ot:ut;v=v.withLevel(D)}else p==="text"&&v.level===ut?v=v.withLevel(Ot):p==="auto"?v=v.incrementLevel():p==="script"?v=v.withLevel(Gt):p==="scriptscript"&&(v=v.withLevel(xn));return v})(e.scriptLevel,t);let n=Oe(e.numer,t),i=Oe(e.denom,t);t.level===3&&(n.style.mathDepth="2",n.setAttribute("scriptlevel","2"),i.style.mathDepth="2",i.setAttribute("scriptlevel","2"));let c=new E("mfrac",[n,i]);if(e.hasBarLine){if(e.barSize){let p=ot(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 b=new E("mo",[new Ie(e.leftDelim.replace("\\",""))]);b.setAttribute("fence","true"),p.push(b)}if(p.push(c),e.rightDelim!=null){let b=new E("mo",[new Ie(e.rightDelim.replace("\\",""))]);b.setAttribute("fence","true"),p.push(b)}c=re(p)}return e.scriptLevel!=="auto"&&(c=new E("mstyle",[c]),c.setAttribute("displaystyle",String(e.scriptLevel==="display")),c.setAttribute("scriptlevel",aa[e.scriptLevel])),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 i=n[0],c=n[1],p=!1,b=null,v=null,D="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":b="(",v=")";break;case"\\\\bracefrac":b="\\{",v="\\}";break;case"\\\\brackfrac":b="[",v="]";break;default:throw new Error("Unrecognized genfrac command")}return t==="\\cfrac"||t.startsWith("\\d")?D="display":t.startsWith("\\t")&&(D="text"),{type:"genfrac",mode:e.mode,continued:!1,numer:i,denom:c,hasBarLine:p,leftDelim:b,rightDelim:v,scriptLevel:D,barSize:null}},mathmlBuilder:Cr}),$({type:"infix",names:["\\over","\\choose","\\atop","\\brace","\\brack"],props:{numArgs:0,infix:!0},handler({parser:e,funcName:t,token:n}){let i;switch(t){case"\\over":i="\\frac";break;case"\\choose":i="\\binom";break;case"\\atop":i="\\\\atopfrac";break;case"\\brace":i="\\\\bracefrac";break;case"\\brack":i="\\\\brackfrac";break;default:throw new Error("Unrecognized infix genfrac command")}return{type:"infix",mode:e.mode,replaceWith:i,token:n}}});let bs=function(e){let t=null;return e.length>0&&(t=e,t=t==="."?null:t),t};$({type:"genfrac",names:["\\genfrac"],props:{numArgs:6,allowedInArgument:!0,argTypes:["math","math","size","text","math","math"]},handler({parser:e},t){let n=t[4],i=t[5],c=he(t[0]),p=c.type==="atom"&&c.family==="open"?bs(c.text):null,b=he(t[1]),v=b.type==="atom"&&b.family==="close"?bs(b.text):null,D=Me(t[2],"size"),z,se=null;D.isBlank?z=!0:(se=D.value,z=se.number>0);let ce="auto",ee=t[3];if(ee.type==="ordgroup"){if(ee.body.length>0){let et=Me(ee.body[0],"textord");ce=gs[Number(et.text)]}}else ee=Me(ee,"textord"),ce=gs[Number(ee.text)];return{type:"genfrac",mode:e.mode,numer:n,denom:i,continued:!1,hasBarLine:z,barSize:se,leftDelim:p,rightDelim:v,scriptLevel:ce}},mathmlBuilder:Cr}),$({type:"infix",names:["\\above"],props:{numArgs:1,argTypes:["size"],infix:!0},handler:({parser:e,funcName:t,token:n},i)=>({type:"infix",mode:e.mode,replaceWith:"\\\\abovefrac",barSize:Me(i[0],"size").value,token:n})}),$({type:"genfrac",names:["\\\\abovefrac"],props:{numArgs:3,argTypes:["math","size","math"]},handler:({parser:e,funcName:t},n)=>{let i=n[0],c=function(v){if(!v)throw new Error("Expected non-null, but got "+String(v));return v}(Me(n[1],"infix").barSize),p=n[2],b=c.number>0;return{type:"genfrac",mode:e.mode,numer:i,denom:p,continued:!1,hasBarLine:b,barSize:c,leftDelim:null,rightDelim:null,scriptLevel:"auto"}},mathmlBuilder:Cr}),$({type:"hbox",names:["\\hbox"],props:{numArgs:1,argTypes:["hbox"],allowedInArgument:!0,allowedInText:!1},handler:({parser:e},t)=>({type:"hbox",mode:e.mode,body:oe(t[0])}),mathmlBuilder(e,t){let n=t.withLevel(Ot),i=Qe(e.body,n);return Je(i)}}),$({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=J(e.label);return n.style["math-depth"]=0,new E(e.isOver?"mover":"munder",[Oe(e.base,t),n])}}),$({type:"html",names:["\\class","\\id","\\style","\\data"],props:{numArgs:2,argTypes:["raw","original"],allowedInText:!0},handler:({parser:e,funcName:t,token:n},i)=>{let c=Me(i[0],"raw").string,p=i[1];if(e.settings.strict)throw new r(`Function "${t}" is disabled in strict mode`,n);let b,v={};switch(t){case"\\class":v.class=c,b={command:"\\class",class:c};break;case"\\id":v.id=c,b={command:"\\id",id:c};break;case"\\style":v.style=c,b={command:"\\style",style:c};break;case"\\data":{let D=c.split(",");for(let z=0;z<D.length;z++){let se=D[z].split("=");if(se.length!==2)throw new r("Error parsing key-value for \\data");v["data-"+se[0].trim()]=se[1].trim()}b={command:"\\data",attributes:v};break}default:throw new Error("Unrecognized html command")}if(!e.settings.isTrusted(b))throw new r(`Function "${t}" is not trusted`,n);return{type:"html",mode:e.mode,attributes:v,body:oe(p)}},mathmlBuilder:(e,t)=>{let n=Qe(e.body,t),i=[];e.attributes.class&&i.push(...e.attributes.class.trim().split(/\s+/)),n.classes=i;for(let c in e.attributes)c!=="class"&&Object.prototype.hasOwnProperty.call(e.attributes,c)&&n.setAttribute(c,e.attributes[c]);return n}});let Nr=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(!Ct(n))throw new r("Invalid unit: '"+n.unit+"' in \\includegraphics.");return n}};$({type:"includegraphics",names:["\\includegraphics"],props:{numArgs:1,numOptionalArgs:1,argTypes:["raw","url"],allowedInText:!1},handler:({parser:e,token:t},n,i)=>{let c={number:0,unit:"em"},p={number:.9,unit:"em"},b={number:0,unit:"em"},v="";if(i[0]){let z=Me(i[0],"raw").string.split(",");for(let se=0;se<z.length;se++){let ce=z[se].split("=");if(ce.length===2){let ee=ce[1].trim();switch(ce[0].trim()){case"alt":v=ee;break;case"width":c=Nr(ee);break;case"height":p=Nr(ee);break;case"totalheight":b=Nr(ee);break;default:throw new r("Invalid key: '"+ce[0]+"' in \\includegraphics.")}}}}let D=Me(n[0],"url").url;if(v===""&&(v=D,v=v.replace(/^.*[\\/]/,""),v=v.substring(0,v.lastIndexOf("."))),!e.settings.isTrusted({command:"\\includegraphics",url:D}))throw new r('Function "\\includegraphics" is not trusted',t);return{type:"includegraphics",mode:e.mode,alt:v,width:c,height:p,totalheight:b,src:D}},mathmlBuilder:(e,t)=>{let n=ot(e.height,t),i={number:0,unit:"em"};e.totalheight.number>0&&e.totalheight.unit===n.unit&&e.totalheight.number>n.number&&(i.number=e.totalheight.number-n.number,i.unit=n.unit);let c=0;e.width.number>0&&(c=ot(e.width,t));let p={height:n.number+i.number+"em"};c.number>0&&(p.width=c.number+c.unit),i.number>0&&(p.verticalAlign=-i.number+i.unit);let b=new Xe(e.src,e.alt,p);return b.height=n,b.depth=i,new E("mtext",[b])}}),$({type:"kern",names:["\\kern","\\mkern","\\hskip","\\mskip"],props:{numArgs:1,argTypes:["size"],primitive:!0,allowedInText:!0},handler({parser:e,funcName:t,token:n},i){let c=Me(i[0],"size");if(e.settings.strict){let p=t[1]==="m",b=c.value.unit==="mu";if(p){if(!b)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(b)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=ot(e.dimension,t),i=n.number>0&&n.unit==="em"?ys(n.number):"";if(e.mode==="text"&&i.length>0){let c=new Ie(i);return new E("mtext",[c])}if(n.number>=0){let c=new E("mspace");return c.setAttribute("width",n.number+n.unit),c}{let c=new E("mrow");return c.style.marginLeft=n.number+n.unit,c}}});let ys=function(e){return e>=.05555&&e<=.05556?"\u200A":e>=.1666&&e<=.1667?"\u2009":e>=.2222&&e<=.2223?"\u2005":e>=.2777&&e<=.2778?"\u2005\u200A":""},ws=/[^A-Za-z_0-9-]/g;$({type:"label",names:["\\label"],props:{numArgs:1,argTypes:["raw"]},handler:({parser:e},t)=>({type:"label",mode:e.mode,string:t[0].string.replace(ws,"")}),mathmlBuilder(e,t){let n=new E("mrow",[],["tml-label"]);return e.string.length>0&&n.setLabel(e.string),n}});let la=["\\clap","\\llap","\\rlap"];$({type:"lap",names:["\\mathllap","\\mathrlap","\\mathclap","\\clap","\\llap","\\rlap"],props:{numArgs:1,allowedInText:!0},handler:({parser:e,funcName:t,token:n},i)=>{if(la.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=i[0];return{type:"lap",mode:e.mode,alignment:t,body:c}},mathmlBuilder:(e,t)=>{let n;if(e.alignment==="llap"){let p=Le(oe(e.body),t),b=new E("mphantom",p);n=new E("mpadded",[b]),n.setAttribute("width","0.1px")}let i=Oe(e.body,t),c;if(e.alignment==="llap"?(i.style.position="absolute",i.style.right="0",i.style.bottom="0",c=new E("mpadded",[n,i])):c=new E("mpadded",[i]),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}}),$({type:"ordgroup",names:["\\(","$"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler({funcName:e,parser:t},n){let i=t.mode;t.switchMode("math");let c=e==="\\("?"\\)":"$",p=t.parseExpression(!1,c);return t.expect(c),t.switchMode(i),{type:"ordgroup",mode:t.mode,body:p}}}),$({type:"text",names:["\\)","\\]"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(e,t){throw new r(`Mismatched ${e.funcName}`,t)}}),$({type:"mathchoice",names:["\\mathchoice"],props:{numArgs:4,primitive:!0},handler:({parser:e},t)=>({type:"mathchoice",mode:e.mode,display:oe(t[0]),text:oe(t[1]),script:oe(t[2]),scriptscript:oe(t[3])}),mathmlBuilder:(e,t)=>{let n=((i,c)=>{switch(c.level){case ut:return i.display;case Ot:return i.text;case Gt:return i.script;case xn:return i.scriptscript;default:return i.text}})(e,t);return Qe(n,t)}});let ca=["text","textord","mathord","atom"];function xs(e,t){let n,i=Le(e.body,t);if(e.mclass==="minner")n=new E("mpadded",i);else if(e.mclass==="mord")e.isCharacterBox||i[0].type==="mathord"?(n=i[0],n.type="mi",n.children.length===1&&n.children[0].text&&n.children[0].text==="\u2207"&&n.setAttribute("mathvariant","normal")):n=new E("mi",i);else{n=new E("mrow",i),e.mustPromote?(n=i[0],n.type="mo",e.isCharacterBox&&e.body[0].text&&/[A-Za-z]/.test(e.body[0].text)&&n.setAttribute("mathvariant","italic")):n=new E("mrow",i);let c=t.level<2;n.type==="mrow"?c&&(e.mclass==="mbin"?(n.children.unshift(st(.2222)),n.children.push(st(.2222))):e.mclass==="mrel"?(n.children.unshift(st(.2778)),n.children.push(st(.2778))):e.mclass==="mpunct"?n.children.push(st(.1667)):e.mclass==="minner"&&(n.children.unshift(st(.0556)),n.children.push(st(.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}$({type:"mclass",names:["\\mathord","\\mathbin","\\mathrel","\\mathopen","\\mathclose","\\mathpunct","\\mathinner"],props:{numArgs:1,primitive:!0},handler({parser:e,funcName:t},n){let i=n[0],c=w(i),p=!0,b={type:"mathord",text:"",mode:e.mode},v=i.body?i.body:[i];for(let D of v){if(!ca.includes(D.type)){p=!1;break}Ne[e.mode][D.text]?b.text+=Ne[e.mode][D.text].replace:D.text?b.text+=D.text:D.body&&D.body.map(z=>{b.text+=z.text})}return p&&t==="\\mathord"&&b.type==="mathord"&&b.text.length>1?b:{type:"mclass",mode:e.mode,mclass:"m"+t.slice(5),body:oe(p?b:i),isCharacterBox:c,mustPromote:p}},mathmlBuilder:xs});let vs=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&&Ne.math[e.body[0].text]?Ne.math[e.body[0].text].group:t.family;return n==="bin"||n==="rel"?"m"+n:"mord"}return"mord"};$({type:"mclass",names:["\\@binrel"],props:{numArgs:2},handler:({parser:e},t)=>({type:"mclass",mode:e.mode,mclass:vs(t[0]),body:oe(t[1]),isCharacterBox:w(t[1])})}),$({type:"mclass",names:["\\stackrel","\\overset","\\underset"],props:{numArgs:2},handler({parser:e,funcName:t},n){let i=n[1],c=n[0],p;p=t!=="\\stackrel"?vs(i):"mrel";let b={type:p==="mrel"||p==="mbin"?"op":"ordgroup",mode:i.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:t!=="\\stackrel",body:oe(i)};return{type:"supsub",mode:c.mode,stack:!0,base:b,sup:t==="\\underset"?null:c,sub:t==="\\underset"?c:null}},mathmlBuilder:xs});let Qn=(e,t,n)=>{if(!e)return n;let i=Oe(e,t);return i.type==="mrow"&&i.children.length===0?n:i};$({type:"multiscript",names:["\\sideset","\\pres@cript"],props:{numArgs:3},handler({parser:e,funcName:t,token:n},i){if(i[2].body.length===0)throw new r(t+"cannot parse an empty base.");let c=i[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(i[0].body.length>0&&i[0].body[0].type!=="supsub"||i[1].body.length>0&&i[1].body[0].type!=="supsub")throw new r("\\sideset can parse only subscripts and superscripts in its first two arguments",n);let p=i[0].body.length>0?i[0].body[0]:null,b=i[1].body.length>0?i[1].body[0]:null;return p||b?p?{type:"multiscript",mode:e.mode,isSideset:t==="\\sideset",prescripts:p,postscripts:b,base:c}:{type:"styling",mode:e.mode,scriptLevel:"text",body:[{type:"supsub",mode:e.mode,base:c,sup:b.sup,sub:b.sub}]}:c},mathmlBuilder(e,t){let n=Oe(e.base,t),i=new E("mprescripts"),c=new E("none"),p=[],b=Qn(e.prescripts.sub,t,c),v=Qn(e.prescripts.sup,t,c);return e.isSideset&&(b.setAttribute("style","text-align: left;"),v.setAttribute("style","text-align: left;")),e.postscripts?p=[n,Qn(e.postscripts.sub,t,c),Qn(e.postscripts.sup,t,c),i,b,v]:p=[n,i,b,v],new E("mmultiscripts",p)}}),$({type:"not",names:["\\not"],props:{numArgs:1,primitive:!0,allowedInText:!1},handler({parser:e},t){let n=w(t[0]),i;return n?(i=oe(t[0]),i[0].text.charAt(0)==="\\"&&(i[0].text=Ne.math[i[0].text].replace),i[0].text=i[0].text.slice(0,1)+"\u0338"+i[0].text.slice(1)):i=[{type:"textord",mode:"math",text:"\u0338"},{type:"kern",mode:"math",dimension:{number:-.6,unit:"em"}},t[0]],{type:"not",mode:e.mode,body:i,isCharacterBox:n}},mathmlBuilder(e,t){return e.isCharacterBox?Le(e.body,t,!0)[0]:Qe(e.body,t)}});let da=["textord","mathord","atom"],ua=["\\smallint"],$r=["textord","mathord","ordgroup","close","leftright","font"],ks=e=>{e.attributes.lspace="0.1667em",e.attributes.rspace="0.1667em"},Fn=(e,t)=>{let n;if(e.symbol)n=new E("mo",[ne(e.name,e.mode)]),ua.includes(e.name)?n.setAttribute("largeop","false"):n.setAttribute("movablelimits","false"),e.fromMathOp&&ks(n);else if(e.body)n=new E("mo",Le(e.body,t)),e.fromMathOp&&ks(n);else if(n=new E("mi",[new Ie(e.name.slice(1))]),!e.parentIsSupSub){let i=[n,new E("mo",[ne("\u2061","text")])];if(e.needsLeadingSpace){let c=new E("mspace");c.setAttribute("width","0.1667em"),i.unshift(c)}if(!e.isFollowedByDelimiter){let c=new E("mspace");c.setAttribute("width","0.1667em"),i.push(c)}n=new E("mrow",i)}return n},pa={"\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"};$({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 i=t;return i.length===1&&(i=pa[i]),{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:!0,stack:!1,name:i}},mathmlBuilder:Fn}),$({type:"op",names:["\\mathop"],props:{numArgs:1,primitive:!0},handler:({parser:e},t)=>{let n=t[0],i=n.body?n.body:[n],c=i.length===1&&da.includes(i[0].type);return{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:c,fromMathOp:!0,stack:!1,name:c?i[0].text:null,body:c?null:oe(n)}},mathmlBuilder:Fn});let ha={"\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"};$({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,i=e.gullet.future().text;return{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!1,stack:!1,isFollowedByDelimiter:Yn(i),needsLeadingSpace:n.length>0&&$r.includes(n),name:t}},mathmlBuilder:Fn}),$({type:"op",names:["\\det","\\gcd","\\inf","\\lim","\\max","\\min","\\Pr","\\sup"],props:{numArgs:0},handler({parser:e,funcName:t}){let n=e.prevAtomType,i=e.gullet.future().text;return{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:!1,stack:!1,isFollowedByDelimiter:Yn(i),needsLeadingSpace:n.length>0&&$r.includes(n),name:t}},mathmlBuilder:Fn}),$({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=ha[n]),{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!0,stack:!1,name:n}},mathmlBuilder:Fn}),$({type:"operatorname",names:["\\operatorname@","\\operatornamewithlimits"],props:{numArgs:1,allowedInArgument:!0},handler:({parser:e,funcName:t},n)=>{let i=n[0],c=e.prevAtomType,p=e.gullet.future().text;return{type:"operatorname",mode:e.mode,body:oe(i),alwaysHandleSupSub:t==="\\operatornamewithlimits",limits:!1,parentIsSupSub:!1,isFollowedByDelimiter:Yn(p),needsLeadingSpace:c.length>0&&$r.includes(c)}},mathmlBuilder:(e,t)=>{let n,i=Le(e.body,t.withFont("mathrm")),c=!0;for(let p=0;p<i.length;p++){let b=i[p];if(b instanceof E)switch(((b.type==="mrow"||b.type==="mpadded")&&b.children.length===1&&b.children[0]instanceof E||b.type==="mrow"&&b.children.length===2&&b.children[0]instanceof E&&b.children[1]instanceof E&&b.children[1].type==="mspace"&&!b.children[1].attributes.width&&b.children[1].children.length===0)&&(b=b.children[0]),b.type){case"mi":case"mn":case"ms":case"mtext":break;case"mspace":if(b.attributes.width){let v=b.attributes.width.replace("em",""),D=ys(Number(v));D===""?c=!1:i[p]=new E("mtext",[new Ie(D)])}break;case"mo":{let v=b.children[0];b.children.length===1&&v instanceof Ie?v.text=v.text.replace(/\u2212/,"-").replace(/\u2217/,"*"):c=!1;break}default:c=!1}else c=!1}if(c){let p=i.map(b=>b.toText()).join("");i=[new Ie(p)]}else if(i.length===1&&["mover","munder"].includes(i[0].type)&&(i[0].children[0].type==="mi"||i[0].children[0].type==="mtext")){if(i[0].children[0].type="mi",e.parentIsSupSub)return new E("mrow",i);{let p=new E("mo",[ne("\u2061","text")]);return xe([i[0],p])}}if(c?(n=new E("mi",i),i[0].text.length===1&&n.setAttribute("mathvariant","normal")):n=new E("mrow",i),!e.parentIsSupSub){let p=[n,new E("mo",[ne("\u2061","text")])];if(e.needsLeadingSpace){let b=new E("mspace");b.setAttribute("width","0.1667em"),p.unshift(b)}if(!e.isFollowedByDelimiter){let b=new E("mspace");b.setAttribute("width","0.1667em"),p.push(b)}return xe(p)}return n}}),L("\\operatorname","\\@ifstar\\operatornamewithlimits\\operatorname@"),q({type:"ordgroup",mathmlBuilder:(e,t)=>Qe(e.body,t,e.semisimple)}),$({type:"phantom",names:["\\phantom"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>{let n=t[0];return{type:"phantom",mode:e.mode,body:oe(n)}},mathmlBuilder:(e,t)=>{let n=Le(e.body,t);return new E("mphantom",n)}}),$({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=Le(oe(e.body),t),i=new E("mphantom",n),c=new E("mpadded",[i]);return c.setAttribute("height","0px"),c.setAttribute("depth","0px"),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=Le(oe(e.body),t),i=new E("mphantom",n),c=new E("mpadded",[i]);return c.setAttribute("width","0.1px"),c}}),$({type:"pmb",names:["\\pmb"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>({type:"pmb",mode:e.mode,body:oe(t[0])}),mathmlBuilder(e,t){let n=Le(e.body,t),i=qe(n);return i.setAttribute("style","font-weight:bold"),i}});let Es=(e,t)=>{let n=t.withLevel(Ot),i=new E("mpadded",[Oe(e.body,n)]),c=ot(e.dy,t);return i.setAttribute("voffset",c.number+c.unit),c.number>0?i.style.padding=c.number+c.unit+" 0 0 0":i.style.padding="0 0 "+Math.abs(c.number)+c.unit+" 0",i};$({type:"raise",names:["\\raise","\\lower"],props:{numArgs:2,argTypes:["size","primitive"],primitive:!0},handler({parser:e,funcName:t},n){let i=Me(n[0],"size").value;t==="\\lower"&&(i.number*=-1);let c=n[1];return{type:"raise",mode:e.mode,dy:i,body:c}},mathmlBuilder:Es}),$({type:"raise",names:["\\raisebox"],props:{numArgs:2,argTypes:["size","hbox"],allowedInText:!0},handler({parser:e,funcName:t},n){let i=Me(n[0],"size").value,c=n[1];return{type:"raise",mode:e.mode,dy:i,body:c}},mathmlBuilder:Es}),$({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(ws,"")}),mathmlBuilder(e,t){let n=e.funcName==="\\ref"?["tml-ref"]:["tml-ref","tml-eqref"];return new Ce("#"+e.string,n,null)}}),$({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=Oe(e.body,t);return n.style.transform="scaleX(-1)",n}}),$({type:"internal",names:["\\relax"],props:{numArgs:0,allowedInText:!0,allowedInArgument:!0},handler:({parser:e})=>({type:"internal",mode:e.mode})}),$({type:"rule",names:["\\rule"],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["size","size","size"]},handler({parser:e},t,n){let i=n[0],c=Me(t[0],"size"),p=Me(t[1],"size");return{type:"rule",mode:e.mode,shift:i&&Me(i,"size").value,width:c.value,height:p.value}},mathmlBuilder(e,t){let n=ot(e.width,t),i=ot(e.height,t),c=e.shift?ot(e.shift,t):{number:0,unit:"em"},p=t.color&&t.getColor()||"black",b=new E("mspace");if(n.number>0&&i.number>0&&b.setAttribute("mathbackground",p),b.setAttribute("width",n.number+n.unit),b.setAttribute("height",i.number+i.unit),c.number===0)return b;let v=new E("mpadded",[b]);return c.number>=0?v.setAttribute("height","+"+c.number+c.unit):(v.setAttribute("height",c.number+c.unit),v.setAttribute("depth","+"+-c.number+c.unit)),v.setAttribute("voffset",c.number+c.unit),v}});let Ss=/^[0-9]$/,ma={0:"\u2080",1:"\u2081",2:"\u2082",3:"\u2083",4:"\u2084",5:"\u2085",6:"\u2086",7:"\u2087",8:"\u2088",9:"\u2089"},fa={0:"\u2070",1:"\xB9",2:"\xB2",3:"\xB3",4:"\u2074",5:"\u2075",6:"\u2076",7:"\u2077",8:"\u2078",9:"\u2079"};$({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"||!Ss.test(c.text))throw new r("Numerator must be an integer.",c);n+=c.text}let i="";for(let c of t[1].body){if(c.type!=="textord"||!Ss.test(c.text))throw new r("Denominator must be an integer.",c);i+=c.text}return{type:"sfrac",mode:e.mode,numerator:n,denominator:i}},mathmlBuilder(e,t){let n=e.numerator.split("").map(p=>fa[p]).join(""),i=e.denominator.split("").map(p=>ma[p]).join(""),c=new Ie(n+"\u2044"+i,e.mode,t);return new E("mn",[c],["special-fraction"])}});let As={"\\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};$({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},i)=>{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(As[e.funcName]),i=Le(e.body,n),c=qe(i),p=(As[e.funcName]/t.fontSize).toFixed(4);return c.setAttribute("mathsize",p+"em"),c}}),$({type:"smash",names:["\\smash"],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0},handler:({parser:e},t,n)=>{let i=!1,c=!1,p=n[0]&&Me(n[0],"ordgroup");if(p){let v="";for(let D=0;D<p.body.length;++D)if(v=p.body[D].text,v==="t")i=!0;else{if(v!=="b"){i=!1,c=!1;break}c=!0}}else i=!0,c=!0;let b=t[0];return{type:"smash",mode:e.mode,body:b,smashHeight:i,smashDepth:c}},mathmlBuilder:(e,t)=>{let n=new E("mpadded",[Oe(e.body,t)]);return e.smashHeight&&n.setAttribute("height","0px"),e.smashDepth&&n.setAttribute("depth","0px"),n}});let ga=["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"];$({type:"sqrt",names:["\\sqrt"],props:{numArgs:1,numOptionalArgs:1},handler({parser:e},t,n){let i=n[0],c=t[0];return c.body&&c.body.length===1&&c.body[0].text&&ga.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:i}},mathmlBuilder(e,t){let{body:n,index:i}=e;return i?new E("mroot",[Oe(n,t),Oe(i,t.incrementLevel())]):new E("msqrt",[Oe(n,t)])}});let ba={display:0,text:1,script:2,scriptscript:3},ya={display:["0","true"],text:["0","false"],script:["1","false"],scriptscript:["2","false"]};$({type:"styling",names:["\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({breakOnTokenText:e,funcName:t,parser:n},i){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(ba[e.scriptLevel]),i=Le(e.body,n),c=qe(i),p=ya[e.scriptLevel];return c.setAttribute("scriptlevel",p[0]),c.setAttribute("displaystyle",p[1]),c}});let wa=/^m(over|under|underover)$/;q({type:"supsub",mathmlBuilder(e,t){let n,i,c=!1,p=!1,b=!1,v=!1;e.base&&e.base.type==="horizBracket"&&(i=!!e.sup,i===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,b=p&&!e.isFollowedByDelimiter,v=e.base.needsLeadingSpace);let D=e.stack&&e.base.body.length===1?[Oe(e.base.body[0],t)]:[Oe(e.base,t)],z=t.inSubOrSup();if(e.sub){let ee=Oe(e.sub,z);t.level===3&&ee.setAttribute("scriptlevel","2"),D.push(ee)}if(e.sup){let ee=Oe(e.sup,z);if(t.level===3&&ee.setAttribute("scriptlevel","2"),e.base&&e.base.text&&e.base.text.length===1){let et=e.base.text;"DHKLUcegorsuvxyz\u03A0\u03A5\u03A8\u03B1\u03B4\u03B7\u03B9\u03BC\u03BD\u03BF\u03C4\u03C5\u03C7\u03F5".indexOf(et)>-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(et)>-1?ee.classes.push("tml-med-pad"):"AJdf\u0394\u039B".indexOf(et)>-1&&ee.classes.push("tml-lrg-pad")}D.push(ee)}let se;if(c)se=n?"mover":"munder";else if(e.sub)if(e.sup){let ee=e.base;se=ee&&(ee.type==="op"&&ee.limits||ee.type==="multiscript")&&(t.level===ut||ee.alwaysHandleSupSub)||ee&&ee.type==="operatorname"&&ee.alwaysHandleSupSub&&(t.level===ut||ee.limits)?"munderover":"msubsup"}else{let ee=e.base;se=e.stack||ee&&ee.type==="op"&&ee.limits&&(t.level===ut||ee.alwaysHandleSupSub)||ee&&ee.type==="operatorname"&&ee.alwaysHandleSupSub&&(ee.limits||t.level===ut)?"munder":"msub"}else{let ee=e.base;se=ee&&ee.type==="op"&&ee.limits&&(t.level===ut||ee.alwaysHandleSupSub)||ee&&ee.type==="operatorname"&&ee.alwaysHandleSupSub&&(ee.limits||t.level===ut)?"mover":"msup"}let ce=new E(se,D);if(p){let ee=new E("mo",[ne("\u2061","text")]);if(v){let et=new E("mspace");et.setAttribute("width","0.1667em"),ce=xe([et,ce,ee])}else ce=xe([ce,ee]);if(b){let et=new E("mspace");et.setAttribute("width","0.1667em"),ce.children.push(et)}}else wa.test(se)&&(ce=new E("mrow",[ce]));return ce}});let xa=["\\shortmid","\\nshortmid","\\shortparallel","\\nshortparallel","\\smallsetminus"],va=["\\Rsh","\\Lsh","\\restriction"];q({type:"atom",mathmlBuilder(e,t){let n=new E("mo",[ne(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"&&(i=>{if(i.length===1){let c=i.codePointAt(0);return 8591<c&&c<8704}return i.indexOf("arrow")>-1||i.indexOf("harpoon")>-1||va.includes(i)})(e.text))n.setAttribute("stretchy","false");else if(xa.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 E("mrow",[st(.222),n,st(.222)]):new E("mrow",[st(.2778),n,st(.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"},Ts=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 i=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 Ne[i][c]&&Ne[i][c].replace&&(c=Ne[i][c].replace),Object.prototype.hasOwnProperty.call(_s,n)?_s[n]:null},ka=/^\d(?:[\d,.]*\d)?$/,Ea=/[A-Ba-z]/,Sa=new Set(["\\prime","\\dprime","\\trprime","\\qprime","\\backprime","\\backdprime","\\backtrprime"]);q({type:"mathord",mathmlBuilder(e,t){let n=ne(e.text,e.mode,t),i=n.text.codePointAt(0),c=912<i&&i<938?"normal":"italic",p=Ts(e,t)||c;if(p==="script")return n.text=Sn(n.text,p),new E("mi",[n],[t.font]);p!=="italic"&&(n.text=Sn(n.text,p));let b=new E("mi",[n]);if(p==="normal"&&(b.setAttribute("mathvariant","normal"),n.text.length===1)){let v=new E("mspace",[]);b=new E("mrow",[b,v])}return b}}),q({type:"textord",mathmlBuilder(e,t){let n=e.text,i=n.codePointAt(0);t.fontFamily==="textsc"&&96<i&&i<123&&(n=oa[n]);let c=ne(n,e.mode,t),p=Ts(e,t)||"normal",b;if(ka.test(e.text)){let v=e.mode==="text"?"mtext":"mn";if(p==="italic"||p==="bold-italic")return((D,z,se)=>{let ce=new E(se,[D]),ee=new E("mstyle",[ce]);return ee.style["font-style"]="italic",ee.style["font-family"]="Cambria, 'Times New Roman', serif",z==="bold-italic"&&(ee.style["font-weight"]="bold"),ee})(c,p,v);p!=="normal"&&(c.text=c.text.split("").map(D=>Sn(D,p)).join("")),b=new E(v,[c])}else if(e.mode==="text")p!=="normal"&&(c.text=Sn(c.text,p)),b=new E("mtext",[c]);else if(Sa.has(e.text))b=new E("mo",[c]),b.classes.push("tml-prime");else{let v=c.text;p!=="italic"&&(c.text=Sn(c.text,p)),b=new E("mi",[c]),c.text===v&&Ea.test(v)&&b.setAttribute("mathvariant","italic")}return b}});let Aa={"\\nobreak":"nobreak","\\allowbreak":"allowbreak"},_a={" ":{},"\\ ":{},"~":{className:"nobreak"},"\\space":{},"\\nobreakspace":{className:"nobreak"}};q({type:"spacing",mathmlBuilder(e,t){let n;if(Object.prototype.hasOwnProperty.call(_a,e.text))n=new E("mtext",[new Ie("\xA0")]);else{if(!Object.prototype.hasOwnProperty.call(Aa,e.text))throw new r(`Unknown type of space "${e.text}"`);n=new E("mo"),e.text==="\\nobreak"&&n.setAttribute("linebreak","nobreak")}return n}}),q({type:"tag"});let Cs={"\\text":void 0,"\\textrm":"textrm","\\textsf":"textsf","\\texttt":"texttt","\\textnormal":"textrm","\\textsc":"textsc"},Ns={"\\textbf":"textbf","\\textmd":"textmd"},Ta={"\\textit":"textit","\\textup":"textup"};$({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 i=n[0];return{type:"text",mode:e.mode,body:oe(i),font:t}},mathmlBuilder(e,t){let n=((c,p)=>{let b=c.font;return b?Cs[b]?p.withTextFontFamily(Cs[b]):Ns[b]?p.withTextFontWeight(Ns[b]):b==="\\emph"?p.fontShape==="textit"?p.withTextFontShape("textup"):p.withTextFontShape("textit"):p.withTextFontShape(Ta[b]):p})(e,t),i=Qe(e.body,n);return Je(i)}}),$({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 E("mtd",[Oe(e.body,t)]);n.style.padding="0";let i=new E("mtr",[n]);return new E("mtable",[i])}}),$({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 Ie(Ca(e)),i=new E("mtext",[n]);return i.setAttribute("mathvariant","monospace"),i}});let Ca=e=>e.body.replace(/ /g,e.star?"\u2423":"\xA0"),fn=M,$s=`[ \r
93
- ]`,Na=`(\\\\[a-zA-Z@]+)${$s}*`,Or="[\u0300-\u036F]",Os=new RegExp(`${Or}+$`),$a=`(${$s}+)|\\\\(
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]${Or}*|[\uD800-\uDBFF][\uDC00-\uDFFF]${Or}*|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5|${Na}|\\\\[^\uD800-\uDFFF])`;class Ms{constructor(t,n){this.input=t,this.settings=n,this.tokenRegex=new RegExp($a,"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 St("EOF",new dt(this,n,n));let i=this.tokenRegex.exec(t);if(i===null||i.index!==n)throw new r(`Unexpected character: '${t[n]}'`,new St(t[n],new dt(this,n,n+1)));let c=i[6]||i[3]||(i[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 St(c,new dt(this,n,this.tokenRegex.lastIndex))}}class Oa{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,i=!1){if(i){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 Ls={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0};class Ma{constructor(t,n,i){this.settings=n,this.expansionCount=0,this.feed(t),this.macros=new Oa(vn,n.macros),this.mode=i,this.stack=[]}feed(t){this.lexer=new Ms(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,i,c;if(t){if(this.consumeSpaces(),this.future().text!=="[")return null;n=this.popToken(),{tokens:c,end:i}=this.consumeArg(["]"])}else({tokens:c,start:n,end:i}=this.consumeArg());return this.pushToken(new St("EOF",i.loc)),this.pushTokens(c),new St("",dt.range(n,i))}consumeSpaces(){for(;this.future().text===" ";)this.stack.pop()}consumeArg(t){let n=[],i=t&&t.length>0;i||this.consumeSpaces();let c=this.future(),p,b=0,v=0;do{if(p=this.popToken(),n.push(p),p.text==="{")++b;else if(p.text==="}"){if(--b,b===-1)throw new r("Extra }",p)}else if(p.text==="EOF")throw new r("Unexpected end of input in a macro argument, expected '"+(t&&i?t[v]:"}")+"'",p);if(t&&i)if((b===0||b===1&&t[v]==="{")&&p.text===t[v]){if(++v,v===t.length){n.splice(-v,v);break}}else v=0}while(b!==0||i);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 b=this.popToken();if(c[p]!==b.text)throw new r("Use of the macro doesn't match its definition",b)}}let i=[];for(let c=0;c<t;c++)i.push(this.consumeArg(n&&n[c+1]).tokens);return i}expandOnce(t){let n=this.popToken(),i=n.text,c=n.noexpand?null:this._getExpansion(i);if(c==null||t&&c.unexpandable){if(t&&c==null&&i[0]==="\\"&&!this.isDefined(i))throw new r("Undefined control sequence: "+i);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,b=this.consumeArgs(c.numArgs,c.delimiters);if(c.numArgs){p=p.slice();for(let v=p.length-1;v>=0;--v){let D=p[v];if(D.text==="#"){if(v===0)throw new r("Incomplete placeholder at end of macro body",D);if(D=p[--v],D.text==="#")p.splice(v+1,1);else{if(!/^[1-9]$/.test(D.text))throw new r("Not a valid argument number",D);p.splice(v,2,...b[+D.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 St(t)]):void 0}expandTokens(t){let n=[],i=this.stack.length;for(this.pushTokens(t);this.stack.length>i;)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(i=>i.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 i=typeof n=="function"?n(this):n;if(typeof i=="string"){let c=0;if(i.indexOf("#")!==-1){let D=i.replace(/##/g,"");for(;D.indexOf("#"+(c+1))!==-1;)++c}let p=new Ms(i,this.settings),b=[],v=p.lex();for(;v.text!=="EOF";)b.push(v),v=p.lex();return b.reverse(),{tokens:b,numArgs:c}}return i}isDefined(t){return this.macros.has(t)||Object.prototype.hasOwnProperty.call(fn,t)||Object.prototype.hasOwnProperty.call(Ne.math,t)||Object.prototype.hasOwnProperty.call(Ne.text,t)||Object.prototype.hasOwnProperty.call(Ls,t)}isExpandable(t){let n=this.macros.get(t);return n!=null?typeof n=="string"||typeof n=="function"||!n.unexpandable:Object.prototype.hasOwnProperty.call(fn,t)&&!fn[t].primitive}}let Rs=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,er=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"}),Is=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 Mr={"\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"}},Bs={\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 La=["bin","op","open","punct","rel"],Ra=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/,Ia=/^ *\\text/;class zn{constructor(t,n,i=!1){this.mode="math",this.gullet=new Ma(t,n,this.mode),this.settings=n,this.isPreamble=i,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 i=Object.create(null);return Object.entries(this.gullet.macros.current).forEach(([c,p])=>{i[c]=p}),this.gullet.endGroup(),i}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 St("}")),this.gullet.pushTokens(t);let i=this.parseExpression(!1);return this.expect("}"),this.nextToken=n,i}parseExpression(t,n,i){let c=[];for(this.prevAtomType="";;){this.mode==="math"&&this.consumeSpaces();let p=this.fetch();if(zn.endOfExpression.indexOf(p.text)!==-1||n&&p.text===n||i&&p.text==="\\middle"||t&&fn[p.text]&&fn[p.text].infix)break;let b=this.parseAtom(n);if(!b)break;b.type!=="internal"&&(c.push(b),this.prevAtomType=b.type==="atom"?b.family:b.type)}return this.mode==="text"&&this.formLigatures(c),this.handleInfixNodes(c)}handleInfixNodes(t){let n,i=-1;for(let c=0;c<t.length;c++)if(t[c].type==="infix"){if(i!==-1)throw new r("only one infix operator per group",t[c].token);i=c,n=t[c].replaceWith}if(i!==-1&&n){let c,p,b=t.slice(0,i),v=t.slice(i+1),D;return c=b.length===1&&b[0].type==="ordgroup"?b[0]:{type:"ordgroup",mode:this.mode,body:b},p=v.length===1&&v[0].type==="ordgroup"?v[0]:{type:"ordgroup",mode:this.mode,body:v},D=n==="\\\\abovefrac"?this.callFunction(n,[c,t[i],p],[]):this.callFunction(n,[c,p],[]),[D]}return t}handleSupSubscript(t){let n=this.fetch(),i=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 '"+i+"'",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 i={type:"text",mode:this.mode,body:n};return{type:"color",mode:this.mode,color:this.settings.errorColor,body:[i]}}parseAtom(t){let n=this.parseGroup("atom",t);if(n&&n.type==="internal"||this.mode==="text")return n;let i,c;for(;;){this.consumeSpaces();let p=this.fetch();if(p.text==="\\limits"||p.text==="\\nolimits"){if(n&&n.type==="op"){let b=p.text==="\\limits";n.limits=b,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(i)throw new r("Double superscript",p);i=this.handleSupSubscript("superscript")}else if(p.text==="_"){if(c)throw new r("Double subscript",p);c=this.handleSupSubscript("subscript")}else if(p.text==="'"){if(i)throw new r("Double superscript",p);let b={type:"textord",mode:this.mode,text:"\\prime"},v=[b];for(this.consume();this.fetch().text==="'";)v.push(b),this.consume();this.fetch().text==="^"&&v.push(this.handleSupSubscript("superscript")),i={type:"ordgroup",mode:this.mode,body:v}}else{if(!er[p.text])break;{let b=Rs.test(p.text),v=[];for(v.push(new St(er[p.text])),this.consume();;){let z=this.fetch().text;if(!er[z]||Rs.test(z)!==b)break;v.unshift(new St(er[z])),this.consume()}let D=this.subparse(v);b?c={type:"ordgroup",mode:"math",body:D}:i={type:"ordgroup",mode:"math",body:D}}}}if(i||c){if(n&&n.type==="multiscript"&&!n.postscripts)return n.postscripts={sup:i,sub:c},n;{let p=!n||n.type!=="op"&&n.type!=="operatorname"?void 0:Yn(this.nextToken.text);return{type:"supsub",mode:this.mode,base:n,sup:i,sub:c,isFollowedByDelimiter:p}}}return n}parseFunction(t,n){let i=this.fetch(),c=i.text,p=fn[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:""),i);if(this.mode==="text"&&!p.allowedInText)throw new r("Can't use function '"+c+"' in text mode",i);if(this.mode==="math"&&p.allowedInMath===!1)throw new r("Can't use function '"+c+"' in math mode",i);let b=this.prevAtomType,{args:v,optArgs:D}=this.parseArguments(c,p);return this.prevAtomType=b,this.callFunction(c,v,D,i,t)}callFunction(t,n,i,c,p){let b={funcName:t,parser:this,token:c,breakOnTokenText:p},v=fn[t];if(v&&v.handler)return v.handler(b,n,i);throw new r(`No function handler for ${t}`)}parseArguments(t,n){let i=n.numArgs+n.numOptionalArgs;if(i===0)return{args:[],optArgs:[]};let c=[],p=[];for(let b=0;b<i;b++){let v=n.argTypes&&n.argTypes[b],D=b<n.numOptionalArgs;(n.primitive&&v==null||n.type==="sqrt"&&b===1&&p[0]==null)&&(v="primitive");let z=this.parseGroupOfType(`argument to '${t}'`,v,D);if(D)p.push(z);else{if(z==null)throw new r("Null argument, please report this as a bug");c.push(z)}}return{args:c,optArgs:p}}parseGroupOfType(t,n,i){switch(n){case"size":return this.parseSizeGroup(i);case"url":return this.parseUrlGroup(i);case"math":case"text":return this.parseArgumentGroup(i,n);case"hbox":{let c=this.parseArgumentGroup(i,"text");return c!=null?{type:"styling",mode:c.mode,body:[c],scriptLevel:"text"}:null}case"raw":{let c=this.parseStringGroup("raw",i);return c!=null?{type:"raw",mode:"text",string:c.text}:null}case"primitive":{if(i)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(i);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 i=this.gullet.scanArgument(n);if(i==null)return null;let c,p="";for(;(c=this.fetch()).text!=="EOF";)p+=c.text,this.consume();return this.consume(),i.text=p,i}parseRegexGroup(t,n){let i=this.fetch(),c,p=i,b="";for(;(c=this.fetch()).text!=="EOF"&&t.test(b+c.text);)p=c,b+=p.text,this.consume();if(b==="")throw new r("Invalid "+n+": '"+i.text+"'",i);return i.range(p,b)}parseSizeGroup(t){let n,i=!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",i=!0);let c=Ra.exec(n.text);if(!c)throw new r("Invalid size: '"+n.text+"'",n);let p={number:+(c[1]+c[2]),unit:c[3]};if(!Ct(p))throw new r("Invalid unit: '"+p.unit+"'",n);return{type:"size",mode:this.mode,value:p,isBlank:i}}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 i=n.text.replace(/\\([#$%&~_^{}])/g,"$1");return i=n.text.replace(/{\u2044}/g,"/"),{type:"url",mode:this.mode,url:i}}parseArgumentGroup(t,n){let i=this.gullet.scanArgument(t);if(i==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 b={type:"ordgroup",mode:this.mode,loc:i.loc,body:p};return n&&this.switchMode(c),b}parseGroup(t,n){let i=this.fetch(),c=i.text;if(t==="argument to '\\left'")return this.parseSymbol();let p;if(c==="{"||c==="\\begingroup"||c==="\\toggle"){this.consume();let b=c==="{"?"}":c==="\\begingroup"?"\\endgroup":"\\endtoggle";this.gullet.beginGroup();let v=this.parseExpression(!1,b),D=this.fetch();this.expect(b),this.gullet.endGroup(),p={type:D.text==="\\endtoggle"?"toggle":"ordgroup",mode:this.mode,loc:dt.range(i,D),body:v,semisimple:c==="\\begingroup"||void 0}}else if(p=this.parseFunction(n,t)||this.parseSymbol(),p==null&&c[0]==="\\"&&!Object.prototype.hasOwnProperty.call(Ls,c)){if(this.settings.throwOnError)throw new r("Unsupported function name: "+c,i);p=this.formatUnsupportedCmd(c),this.consume()}return p}formLigatures(t){let n=t.length-1;for(let i=0;i<n;++i){let c=t[i],p=c.text;p==="-"&&t[i+1].text==="-"&&(i+1<n&&t[i+2].text==="-"?(t.splice(i,3,{type:"textord",mode:"text",loc:dt.range(c,t[i+2]),text:"---"}),n-=2):(t.splice(i,2,{type:"textord",mode:"text",loc:dt.range(c,t[i+1]),text:"--"}),n-=1)),p!=="'"&&p!=="`"||t[i+1].text!==p||(t.splice(i,2,{type:"textord",mode:"text",loc:dt.range(c,t[i+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),b=p.charAt(0)==="*";if(b&&(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:b}}if(Object.prototype.hasOwnProperty.call(Bs,n[0])&&this.mode==="math"&&!Ne[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=Bs[n[0]]+n.slice(1)}let i=this.mode==="math"?Os.exec(n):null,c;if(i&&(n=n.substring(0,i.index),n==="i"?n="\u0131":n==="j"&&(n="\u0237")),Ne[this.mode][n]){let p=Ne[this.mode][n].group;p!=="bin"||!La.includes(this.prevAtomType)&&this.prevAtomType!==""||(p="open");let b=dt.range(t),v;if(Object.prototype.hasOwnProperty.call(Ee,p)){let D=p;v={type:"atom",mode:this.mode,family:D,loc:b,text:n},D!=="rel"&&D!=="bin"||this.prevAtomType!=="text"||Ia.test(b.lexer.input.slice(b.end))&&(v.needsSpacing=!0)}else{if(Is[n]){this.consume();let D=this.fetch().text.charCodeAt(0),z=D===65025?"mathscr":"mathcal";return D!==65024&&D!==65025||this.consume(),{type:"font",mode:"math",font:z,body:{type:"mathord",mode:"math",loc:b,text:Is[n]}}}v={type:p,mode:this.mode,loc:b,text:n}}c=v}else{if(!(n.charCodeAt(0)>=128||Os.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:dt.range(t),text:n}}if(this.consume(),i)for(let p=0;p<i[0].length;p++){let b=i[0][p];if(!Mr[b])throw new r(`Unknown accent ' ${b}'`,t);let v=Mr[b][this.mode]||Mr[b].text;if(!v)throw new r(`Accent ${b} unsupported in ${this.mode} mode`,t);c={type:"accent",mode:this.mode,loc:dt.range(t),label:v,isStretchy:!1,base:c}}return c}}let Ps=function(e,t){if(!(typeof e=="string"||e instanceof String))throw new TypeError("Temml can only parse string typed expression");let n,i;try{i=new zn(e,t),delete i.gullet.macros.current["\\df@tag"],n=i.parse()}catch(c){if(c.toString()!=="ParseError: Unmatched delimiter")throw c;t.wrapDelimiterPairs=!1,i=new zn(e,t),delete i.gullet.macros.current["\\df@tag"],n=i.parse()}if(!(n.length>0&&n[0].type&&n[0].type==="array"&&n[0].addEqnNum)&&i.gullet.macros.get("\\df@tag")){if(!t.displayMode)throw new r("\\tag works only in display mode");i.gullet.feed("\\df@tag"),n=[{type:"tag",mode:"text",body:n,tag:i.parse()}]}return n},Ba=[2,2,3,3];class Lr{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 i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);return new Lr(n)}withLevel(t){return this.extend({level:t})}incrementLevel(){return this.extend({level:Math.min(this.level+1,3)})}inSubOrSup(){return this.extend({level:Ba[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 Ds(e){let t={},n=0,i=document.getElementsByClassName("tml-eqn");for(let p of i)for(n+=1,p.setAttribute("id","tml-eqn-"+String(n));p.tagName!=="mtable";){if(p.getElementsByClassName("tml-label").length>0){let b=p.attributes.id.value;t[b]=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 b=p.getElementsByClassName("tml-tag");if(b.length>0){let v=p.attributes.id.value;t[v]=b[0].textContent}}[...e.getElementsByClassName("tml-ref")].forEach(p=>{let b=p.getAttribute("href"),v=t[b.slice(1)];p.className.indexOf("tml-eqref")===-1?(v=v.replace(/^\(/,""),v=v.replace(/\)$/,"")):(v.charAt(0)!=="("&&(v="("+v),v.slice(-1)!==")"&&(v+=")"));let D=document.createElementNS("http://www.w3.org/1998/Math/MathML","mtext");D.appendChild(document.createTextNode(v));let z=document.createElementNS("http://www.w3.org/1998/Math/MathML","math");z.appendChild(D),p.textContent="",p.appendChild(z)})}let Pa=function(e,t,n){let i=n,c=0,p=e.length;for(;i<t.length;){let b=t[i];if(c<=0&&t.slice(i,i+p)===e)return i;b==="\\"?i++:b==="{"?c++:b==="}"&&c--,i++}return-1},Da=/^\\(?:begin|(?:eq)?ref){/,qs=[{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}],tr={$:[{left:"$$",right:"$$",display:!0},{left:"$`",right:"`$",display:!1},{left:"$",right:"$",display:!1}],"(":[{left:"\\[",right:"\\]",display:!0},{left:"\\(",right:"\\)",display:!1}]},Rr=[{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}],qa=function(e,t){let n=function(c,p){let b,v=[],D=new RegExp("("+p.map(z=>z.left.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")+")");for(;b=c.search(D),b!==-1;){b>0&&(v.push({type:"text",data:c.slice(0,b)}),c=c.slice(b));let z=p.findIndex(ee=>c.startsWith(ee.left));if(b=Pa(p[z].right,c,p[z].left.length),b===-1)break;let se=c.slice(0,b+p[z].right.length),ce=Da.test(se)?se:c.slice(p[z].left.length,b);v.push({type:"math",data:ce,rawData:se,display:p[z].display}),c=c.slice(b+p[z].right.length)}return c!==""&&v.push({type:"text",data:c}),v}(e,t.delimiters);if(n.length===1&&n[0].type==="text")return null;let i=document.createDocumentFragment();for(let c=0;c<n.length;c++)if(n[c].type==="text")i.appendChild(document.createTextNode(n[c].data));else{let p=document.createElement("span"),b=n[c].data;t.displayMode=n[c].display;try{t.preProcess&&(b=t.preProcess(b)),co.render(b,p,t)}catch(v){if(!(v instanceof r))throw v;t.errorCallback("Temml auto-render: Failed to parse `"+n[c].data+"` with ",v),i.appendChild(document.createTextNode(n[c].rawData));continue}i.appendChild(p)}return i},Fs=function(e,t){for(let n=0;n<e.childNodes.length;n++){let i=e.childNodes[n];if(i.nodeType===3){let c=qa(i.textContent,t);c&&(n+=c.childNodes.length-1,e.replaceChild(c,i))}else if(i.nodeType===1){let c=" "+i.className+" ";t.ignoredTags.indexOf(i.nodeName.toLowerCase())===-1&&t.ignoredClasses.every(p=>c.indexOf(" "+p+" ")===-1)&&Fs(i,t)}}},zs=function(e,t,n={}){t.textContent="";let i=t.tagName.toLowerCase()==="math";i&&(n.wrap="none");let c=Ir(e,n);i||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."),zs=function(){throw new r("Temml doesn't work in quirks mode.")});let Ir=function(e,t){let n=new I(t);try{let i=Ps(e,n);return Pt(i,e,new Lr({level:n.displayMode?ut:Ot,maxSize:n.maxSize}),n)}catch(i){return function(c,p,b){if(b.throwOnError||!(c instanceof r))throw c;let v=new Re(["temml-error"],[new be(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 v.style.color=b.errorColor,v.style.whiteSpace="pre-line",v}(i,e,n)}};return{version:"0.13.3",render:zs,renderToString:function(e,t){return Ir(e,t).toMarkup()},renderMathInElement:function(e,t){if(!e)throw new Error("No element provided to render");let n={};for(let i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);n.fences?n.delimiters=(i=>i==="$"||i==="("?tr[i]:i==="$+"||i==="(+"?tr[i.slice(0,1)].concat(Rr):i==="ams"?Rr:i==="all"?tr["("].concat(tr.$).concat(Rr):qs)(n.fences):n.delimiters=n.delimiters||qs,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||{},Fs(e,n),Ds(e)},postProcess:Ds,ParseError:r,definePreamble:function(e,t){let n=new I(t);if(n.macros={},!(typeof e=="string"||e instanceof String))throw new TypeError("Temml can only parse string typed expression");let i=new zn(e,n,!0);return delete i.gullet.macros.current["\\df@tag"],i.parse()},__parse:function(e,t){let n=new I(t);return Ps(e,n)},__renderToMathMLTree:Ir,__defineSymbol:s,__defineMacro:L}}(),uo=co;function xl(r,a){return uo.renderToString(r,{displayMode:a,throwOnError:!1})}function vl(r,a){let l=a;for(;(l=r.indexOf("$$",l))!==-1;){if(r[l-1]!=="\\")return l;l+=1}return-1}function kl(r){let a=[],l="",d=()=>{l&&(a.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(),a.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=vl(r,u+2);if(f!==-1){d(),a.push({type:"math",tex:r.slice(u+2,f),display:!0}),u=f+2;continue}}l+=m,u+=1}return d(),a}var El="code, pre, script, style, svg, aside, math";function Sl(r){let a=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,{acceptNode:d=>d.parentElement&&d.parentElement.closest(El)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}),l=[];for(let d=a.nextNode();d;d=a.nextNode())(d.nodeValue.includes("$")||d.nodeValue.includes("\\("))&&l.push(d);for(let d of l){let u=kl(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=xl(f.tex,f.display),m.appendChild(h.firstElementChild??document.createTextNode(""))}d.parentNode.replaceChild(m,d)}}function po(r){r.querySelectorAll("section[data-math]").forEach(a=>Sl(a))}ae();le();ae();le();var Lo=Wa(Mo(),1);var mt=Lo.default;ae();le();function Ro(r){let a=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"],w=["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"],I=["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"],C=A,$=[...k,...w].filter(Te=>!A.includes(Te)),q={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},he={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},oe={match:a.concat(/\b/,a.either(...C),/\s*\(/),relevance:0,keywords:{built_in:C}};function de(Te){return a.concat(/\b/,a.either(...Te.map($e=>$e.replace(/\s+/,"\\s+"))),/\b/)}let j={scope:"keyword",match:de(M),relevance:0};function me(Te,{exceptions:$e,when:Re}={}){let be=Re;return $e=$e||[],Te.map(Ce=>Ce.match(/\|\d+$/)||$e.includes(Ce)?Ce:be(Ce)?`${Ce}|0`:Ce)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:me($,{when:Te=>Te.length<3}),literal:m,type:h,built_in:I},contains:[{scope:"type",match:de(f)},j,oe,q,d,u,r.C_NUMBER_MODE,r.C_BLOCK_COMMENT_MODE,l,he]}}ae();le();var Io="[A-Za-z$_][0-9A-Za-z$_]*",mc=["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"],fc=["true","false","null","undefined","NaN","Infinity"],Bo=["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"],Po=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Do=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],gc=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],bc=[].concat(Do,Bo,Po);function qo(r){let a=r.regex,l=(U,{after:fe})=>{let Ee="</"+U[0].slice(1);return U.input.indexOf(Ee,fe)!==-1},d=Io,u={begin:"<>",end:"</>"},m=/<[A-Za-z0-9\\._:-]+\s*\/>/,f={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(U,fe)=>{let Ee=U[0].length+U.index,ze=U.input[Ee];if(ze==="<"||ze===","){fe.ignoreMatch();return}ze===">"&&(l(U,{after:Ee})||fe.ignoreMatch());let Ne,s=U.input.substring(Ee);if(Ne=s.match(/^\s*=/)){fe.ignoreMatch();return}if((Ne=s.match(/^\s+extends\s+/))&&Ne.index===0){fe.ignoreMatch();return}}},h={$pattern:Io,keyword:mc,literal:fc,built_in:bc,"variable.language":gc},w="[0-9](_?[0-9])*",k=`\\.(${w})`,A="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",I={className:"number",variants:[{begin:`(\\b(${A})((${k})|\\.)?|(${k}))[eE][+-]?(${w})\\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:[]},C={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[r.BACKSLASH_ESCAPE,M],subLanguage:"xml"}},$={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[r.BACKSLASH_ESCAPE,M],subLanguage:"css"}},q={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[r.BACKSLASH_ESCAPE,M],subLanguage:"graphql"}},he={className:"string",begin:"`",end:"`",contains:[r.BACKSLASH_ESCAPE,M]},de={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,C,$,q,he,{match:/\$\d+/},I];M.contains=j.concat({begin:/\{/,end:/\}/,keywords:h,contains:["self"].concat(j)});let me=[].concat(de,M.contains),Te=me.concat([{begin:/(\s*)\(/,end:/\)/,keywords:h,contains:["self"].concat(me)}]),$e={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:h,contains:Te},Re={variants:[{match:[/class/,/\s+/,d,/\s+/,/extends/,/\s+/,a.concat(d,"(",a.concat(/\./,d),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,d],scope:{1:"keyword",3:"title.class"}}]},be={relevance:0,match:a.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:{_:[...Bo,...Po]}},Ce={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},Xe={variants:[{match:[/function/,/\s+/,d,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[$e],illegal:/%/},xe={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function E(U){return a.concat("(?!",U.join("|"),")")}let Ie={match:a.concat(/\b/,E([...Do,"super","import"].map(U=>`${U}\\s*\\(`)),d,a.lookahead(/\s*\(/)),className:"title.function",relevance:0},qe={begin:a.concat(/\./,a.lookahead(a.concat(d,/(?![0-9A-Za-z$_(])/))),end:d,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},De={match:[/get|set/,/\s+/,d,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},$e]},F="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+r.UNDERSCORE_IDENT_RE+")\\s*=>",J={match:[/const|var|let/,/\s+/,d,/\s*/,/=\s*/,/(async\s*)?/,a.lookahead(F)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[$e]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:h,exports:{PARAMS_CONTAINS:Te,CLASS_REFERENCE:be},illegal:/#(?![$_A-z])/,contains:[r.SHEBANG({label:"shebang",binary:"node",relevance:5}),Ce,r.APOS_STRING_MODE,r.QUOTE_STRING_MODE,C,$,q,he,de,{match:/\$\d+/},I,be,{scope:"attr",match:d+a.lookahead(":"),relevance:0},J,{begin:"("+r.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[de,r.REGEXP_MODE,{className:"function",begin:F,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:Te}]}]},{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"]}]}]},Xe,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+r.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[$e,r.inherit(r.TITLE_MODE,{begin:d,className:"title.function"})]},{match:/\.\.\./,relevance:0},qe,{match:"\\$"+d,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[$e]},Ie,xe,Re,De,{match:/\$[(.]/}]}}ae();le();var dr="[A-Za-z$_][0-9A-Za-z$_]*",Fo=["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"],zo=["true","false","null","undefined","NaN","Infinity"],Uo=["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"],Ho=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Go=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],jo=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],Ko=[].concat(Go,Uo,Ho);function yc(r){let a=r.regex,l=(U,{after:fe})=>{let Ee="</"+U[0].slice(1);return U.input.indexOf(Ee,fe)!==-1},d=dr,u={begin:"<>",end:"</>"},m=/<[A-Za-z0-9\\._:-]+\s*\/>/,f={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(U,fe)=>{let Ee=U[0].length+U.index,ze=U.input[Ee];if(ze==="<"||ze===","){fe.ignoreMatch();return}ze===">"&&(l(U,{after:Ee})||fe.ignoreMatch());let Ne,s=U.input.substring(Ee);if(Ne=s.match(/^\s*=/)){fe.ignoreMatch();return}if((Ne=s.match(/^\s+extends\s+/))&&Ne.index===0){fe.ignoreMatch();return}}},h={$pattern:dr,keyword:Fo,literal:zo,built_in:Ko,"variable.language":jo},w="[0-9](_?[0-9])*",k=`\\.(${w})`,A="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",I={className:"number",variants:[{begin:`(\\b(${A})((${k})|\\.)?|(${k}))[eE][+-]?(${w})\\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:[]},C={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[r.BACKSLASH_ESCAPE,M],subLanguage:"xml"}},$={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[r.BACKSLASH_ESCAPE,M],subLanguage:"css"}},q={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[r.BACKSLASH_ESCAPE,M],subLanguage:"graphql"}},he={className:"string",begin:"`",end:"`",contains:[r.BACKSLASH_ESCAPE,M]},de={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,C,$,q,he,{match:/\$\d+/},I];M.contains=j.concat({begin:/\{/,end:/\}/,keywords:h,contains:["self"].concat(j)});let me=[].concat(de,M.contains),Te=me.concat([{begin:/(\s*)\(/,end:/\)/,keywords:h,contains:["self"].concat(me)}]),$e={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:h,contains:Te},Re={variants:[{match:[/class/,/\s+/,d,/\s+/,/extends/,/\s+/,a.concat(d,"(",a.concat(/\./,d),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,d],scope:{1:"keyword",3:"title.class"}}]},be={relevance:0,match:a.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:{_:[...Uo,...Ho]}},Ce={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},Xe={variants:[{match:[/function/,/\s+/,d,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[$e],illegal:/%/},xe={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function E(U){return a.concat("(?!",U.join("|"),")")}let Ie={match:a.concat(/\b/,E([...Go,"super","import"].map(U=>`${U}\\s*\\(`)),d,a.lookahead(/\s*\(/)),className:"title.function",relevance:0},qe={begin:a.concat(/\./,a.lookahead(a.concat(d,/(?![0-9A-Za-z$_(])/))),end:d,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},De={match:[/get|set/,/\s+/,d,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},$e]},F="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+r.UNDERSCORE_IDENT_RE+")\\s*=>",J={match:[/const|var|let/,/\s+/,d,/\s*/,/=\s*/,/(async\s*)?/,a.lookahead(F)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[$e]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:h,exports:{PARAMS_CONTAINS:Te,CLASS_REFERENCE:be},illegal:/#(?![$_A-z])/,contains:[r.SHEBANG({label:"shebang",binary:"node",relevance:5}),Ce,r.APOS_STRING_MODE,r.QUOTE_STRING_MODE,C,$,q,he,de,{match:/\$\d+/},I,be,{scope:"attr",match:d+a.lookahead(":"),relevance:0},J,{begin:"("+r.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[de,r.REGEXP_MODE,{className:"function",begin:F,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:Te}]}]},{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"]}]}]},Xe,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+r.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[$e,r.inherit(r.TITLE_MODE,{begin:d,className:"title.function"})]},{match:/\.\.\./,relevance:0},qe,{match:"\\$"+d,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[$e]},Ie,xe,Re,De,{match:/\$[(.]/}]}}function Wo(r){let a=r.regex,l=yc(r),d=dr,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['"]/},w=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],k={$pattern:dr,keyword:Fo.concat(w),literal:zo,built_in:Ko.concat(u),"variable.language":jo},A={className:"meta",begin:"@"+d},I=(q,he,oe)=>{let de=q.contains.findIndex(j=>j.label===he);if(de===-1)throw new Error("can not find mode to replace");q.contains.splice(de,1,oe)};Object.assign(l.keywords,k),l.exports.PARAMS_CONTAINS.push(A);let M=l.contains.find(q=>q.scope==="attr"),C=Object.assign({},M,{match:a.concat(d,a.lookahead(/\s*\?:/))});l.exports.PARAMS_CONTAINS.push([l.exports.CLASS_REFERENCE,M,C]),l.contains=l.contains.concat([A,m,f,C]),I(l,"shebang",r.SHEBANG()),I(l,"use_strict",h);let $=l.contains.find(q=>q.label==="func.def");return $.relevance=0,Object.assign(l,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),l}ae();le();function Vo(r){let a=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"]},w={className:"meta",begin:/^(>>>|\.\.\.) /},k={className:"subst",begin:/\{/,end:/\}/,keywords:h,illegal:/#/},A={begin:/\{\{/,relevance:0},I={className:"string",contains:[r.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[r.BACKSLASH_ESCAPE,w],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[r.BACKSLASH_ESCAPE,w],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[r.BACKSLASH_ESCAPE,w,A,k]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[r.BACKSLASH_ESCAPE,w,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])*",C=`(\\b(${M}))?\\.(${M})|\\b(${M})\\.`,$=`\\b|${d.join("|")}`,q={className:"number",relevance:0,variants:[{begin:`(\\b(${M})|(${C}))[eE][+-]?(${M})[jJ]?(?=${$})`},{begin:`(${C})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${$})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${$})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${$})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${$})`},{begin:`\\b(${M})[jJ](?=${$})`}]},he={className:"comment",begin:a.lookahead(/# type:/),end:/$/,keywords:h,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},oe={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:h,contains:["self",w,q,I,r.HASH_COMMENT_MODE]}]};return k.contains=[I,q,w],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:h,illegal:/(<\/|\?)|=>/,contains:[w,q,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},I,he,r.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,l],scope:{1:"keyword",3:"title.function"},contains:[oe]},{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:[q,oe,I]}]}}ae();le();function Zo(r){let a=r.regex,l={},d={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[l]}]};Object.assign(l,{className:"variable",variants:[{begin:a.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 w={match:/\\"/},k={className:"string",begin:/'/,end:/'/},A={match:/\\'/},I={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},r.NUMBER_MODE,l]},M=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],C=r.SHEBANG({binary:`(${M.join("|")})`,relevance:10}),$={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[r.inherit(r.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},q=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],he=["true","false"],oe={match:/(\/[a-z._-]+)+/},de=["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"],me=["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"],Te=["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:q,literal:he,built_in:[...de,...j,"set","shopt",...me,...Te]},contains:[C,r.SHEBANG(),$,I,m,f,oe,h,w,k,A,l]}}ae();le();function Xo(r){let a="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"},C={end:",",endsWithParent:!0,excludeEnd:!0,keywords:a,relevance:0},$={begin:/\{/,end:/\}/,contains:[C],illegal:"\\n",relevance:0},q={begin:"\\[",end:"\\]",contains:[C],illegal:"\\n",relevance:0},he=[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:a,keywords:{literal:a}},M,{className:"number",begin:r.C_NUMBER_RE+"\\b",relevance:0},$,q,m,f],oe=[...he];return oe.pop(),oe.push(h),C.contains=oe,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:he}}ae();le();function Yo(r){let a={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:[a,l,r.QUOTE_STRING_MODE,u,r.C_NUMBER_MODE,r.C_LINE_COMMENT_MODE,r.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}ae();le();var $n="[0-9](_*[0-9])*",ur=`\\.(${$n})`,pr="[0-9a-fA-F](_*[0-9a-fA-F])*",Jo={className:"number",variants:[{begin:`(\\b(${$n})((${ur})|\\.)?|(${ur}))[eE][+-]?(${$n})[fFdD]?\\b`},{begin:`\\b(${$n})((${ur})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${ur})[fFdD]?\\b`},{begin:`\\b(${$n})[fFdD]\\b`},{begin:`\\b0[xX]((${pr})\\.?|(${pr})?\\.(${pr}))[pP][+-]?(${$n})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${pr})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function Qo(r,a,l){return l===-1?"":r.replace(a,d=>Qo(r,a,l-1))}function ei(r){let a=r.regex,l="[\xC0-\u02B8a-zA-Z_$][\xC0-\u02B8a-zA-Z_$0-9]*",d=l+Qo("(?:<"+l+"~~~(?:\\s*,\\s*"+l+"~~~)*>)?",/~~~/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"]},k={className:"meta",begin:"@"+l,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},A={className:"params",begin:/\(/,end:/\)/,keywords:w,relevance:0,contains:[r.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:w,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:[a.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:w,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:w,relevance:0,contains:[k,r.APOS_STRING_MODE,r.QUOTE_STRING_MODE,Jo,r.C_BLOCK_COMMENT_MODE]},r.C_LINE_COMMENT_MODE,r.C_BLOCK_COMMENT_MODE]},Jo,k]}}ae();le();function ti(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:/["']/}]}]}}ae();le();function ni(r){let a=r.regex,l=/(r#)?/,d=a.concat(l,r.UNDERSCORE_IDENT_RE),u=a.concat(l,r.IDENT_RE),m={className:"title.function.invoke",relevance:0,begin:a.concat(/\b/,/(?!let|for|while|if|else|match\b)/,u,a.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"],w=["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:w,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]}}ae();le();function ri(r){let a=r.regex,l=a.concat(/[\p{L}_]/u,a.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"}),w=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,w,h,f,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[m,f,w,h]}]}]},r.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},u,{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:[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:a.concat(/</,a.lookahead(a.concat(l,a.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:l,relevance:0,starts:k}]},{className:"tag",begin:a.concat(/<\//,a.lookahead(a.concat(l,/>/))),contains:[{className:"name",begin:l,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}ae();le();var wc=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_-]*/}}),xc=["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"],vc=["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"],kc=[...xc,...vc],Ec=["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(),Sc=["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(),Ac=["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 si(r){let a=r.regex,l=wc(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:":("+Sc.join("|")+")"},{begin:":(:)?("+Ac.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:a.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:Ec.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...h,l.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+kc.join("|")+")\\b"}]}}ae();le();function oi(r){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}mt.registerLanguage("sql",Ro);mt.registerLanguage("javascript",qo);mt.registerLanguage("typescript",Wo);mt.registerLanguage("python",Vo);mt.registerLanguage("bash",Zo);mt.registerLanguage("yaml",Xo);mt.registerLanguage("json",Yo);mt.registerLanguage("java",ei);mt.registerLanguage("go",ti);mt.registerLanguage("rust",ni);mt.registerLanguage("xml",ri);mt.registerLanguage("css",si);mt.registerLanguage("plaintext",oi);mt.registerAliases(["js"],{languageName:"javascript"});mt.registerAliases(["ts"],{languageName:"typescript"});mt.registerAliases(["shell","sh","zsh"],{languageName:"bash"});mt.registerAliases(["html"],{languageName:"xml"});mt.registerAliases(["text","plain"],{languageName:"plaintext"});function Tc(r,a){return r.split("|").map(l=>{if(l=l.trim(),l===""||l==="all")return Array.from({length:a},(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 w=f;w<=Math.min(h,a);w++)d.push(w)}return d})}function Cc(r){let a=[[]];for(function l(d,u){for(let m of d.childNodes)m.nodeType===Node.TEXT_NODE?m.nodeValue.split(`
100
- `).forEach((h,w)=>{w>0&&a.push([]),h&&a[a.length-1].push({path:u,text:h})}):m.nodeType===Node.ELEMENT_NODE&&l(m,[...u,m])}(r,[]);a.length&&a[a.length-1].length===0;)a.pop();r.textContent="";for(let l of a){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 w=f.lastChild;w&&w.__orig===h||(w=h.cloneNode(!1),w.__orig=h,f.appendChild(w)),f=w}f.appendChild(document.createTextNode(m))}r.appendChild(d)}return r.querySelectorAll(":scope > .code-line")}function Nc(r,a){if(r.length===a)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 ii(r,a){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&&mt.getLanguage(u)?l.innerHTML=mt.highlight(m,{language:u}).value:l.textContent=m,l.classList.add("hljs");let f=l.parentElement,h=Cc(l);f.hasAttribute("data-lines-numbers")&&f.classList.add("line-numbers");let w=f.getAttribute("data-lines");if(!w)return;let k=Tc(w,h.length);f.classList.add("stepping"),a(f,{count:k.length,label:A=>A===0?"code":Nc(k[A-1],h.length),apply(A){if(h.forEach(C=>C.classList.remove("line-hl","line-dim")),A===0)return;let I=new Set(k[A-1]),M=I.size===h.length;h.forEach((C,$)=>{I.has($+1)?C.classList.add("line-hl"):M||C.classList.add("line-dim")})}})})}ae();le();var $c=/⟨CLICK⟩|&lt;CLICK&gt;|<click(?:\s[^>]*)?>(?:<\/click>)?/gi;function ai(r){return(r||"").split($c)}function Wr(r){let a="width=1100,height=700",l=window.open("","decklight-speaker",a);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",a),!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:()=>li(r,u()),next:()=>r.next(),prev:()=>r.prev()},r.__notifySpeaker=()=>{r.__speakerCb&&!l.closed&&r.__speakerCb(li(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`),Ee=F,fe=J),U===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`),Ee=F,fe=J),U===void 0&
227
227
  }
228
228
  connect(30);
229
229
  <\/script>
230
- </body></html>`),l.document.close(),l}function li(r,a){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}`,w=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:a,nextHash:h,notesSegments:ai(w?w.innerHTML:""),rehearseSegments:k?ai(k.innerHTML):null,labels:r._stepLabels(l-1),qr:r.__remoteQr??null}}ae();le();function kt(r,a){r.addEventListener("click",l=>{l.target===r&&a()})}function jt(r,a,l,{scroll:d=!0}={}){let u=(a+r.length)%r.length;return r.forEach((m,f)=>m.classList.toggle(l,f===u)),d&&r[u]?.scrollIntoView({block:"nearest"}),u}function hr(r,{query:a="",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 a&&f?f():h?.(),!0;default:return r.key.length===1&&u?(u(r.key),!0):!1}}function ci(){let r=[];return{register(a){return r.push(a),a},active:()=>r.find(a=>a.isOpen()),closeOthers(a){for(let l of r)l!==a&&l.isOpen()&&l.close()}}}ae();le();ae();le();function Oc(r){return function(){r|=0,r=r+1831565813|0;let a=Math.imul(r^r>>>15,1|r);return a=a+Math.imul(a^a>>>7,61|a)^a,((a^a>>>14)>>>0)/4294967296}}function Zt(r,a,l){r=(r%360+360)%360,a=Math.max(0,Math.min(100,a))/100,l=Math.max(0,Math.min(100,l))/100;let d=(1-Math.abs(2*l-1))*a,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(w=>Math.round((w+m)*255))}function un([r,a,l]){return"#"+[r,a,l].map(d=>d.toString(16).padStart(2,"0")).join("")}function Mn([r,a,l]){let d=[r,a,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 Mc(r,a){let[l,d]=[Mn(r),Mn(a)].sort((u,m)=>m-u);return(l+.05)/(d+.05)}var On=(r,a)=>Math.min(...a.map(l=>Mc(r,l)));function ft(r,a,l,d,u){let f=d.reduce((A,I)=>A+Mn(I),0)/d.length<.5?1:-1,h=[];for(let A=a;A>0;A-=15)h.push(A);h.push(0);for(let A of[f,-f])for(let I of h)for(let M=l;M>=2&&M<=98;M+=A){let C=Zt(r,I,M);if(On(C,d)>=u)return C}let w=[253,253,254],k=[8,9,10];return On(w,d)>=On(k,d)?w:k}var Lc=["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"],Vr='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',Rc='ui-rounded, "SF Pro Rounded", "Segoe UI", Roboto, Helvetica, Arial, sans-serif',Ic='"Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif',Bc='"SF Mono", SFMono-Regular, ui-monospace, "Cascadia Code", Menlo, Consolas, monospace',Pc=[Vr,Vr,Rc,Ic],Dc=[600,650,700,750,800],qc=["4px","6px","8px","10px","12px","14px","18px"],di={analogous:[30,-30,60,15,-15],complementary:[180,150,210,30,-30],split:[150,210,30,180,-30],triadic:[120,240,60,180,300]},yn={bgSatMax:{dark:18,light:12},accentSat:[42,68],hlSat:[36,58],ansiSat:[46,66],gradientChance:.15,gradientHueDrift:[8,20]};function mr(r){r=(r??Math.floor(Math.random()*4294967295))>>>0;let a=Oc(r),l=X=>X[Math.floor(a()*X.length)],d=(X,Y)=>X+a()*(Y-X),u=a()<.5,m=Math.floor(a()*360),f=l(Object.keys(di)),h=di[f],w=m+h[0],k=a()*a(),A=(X,Y)=>X+k*(Y-X),I=A(5,yn.bgSatMax[u?"dark":"light"]),M=u?d(6,13):d(94,97.5),C=Zt(m,I,M),$=un(C),q=[C];if(a()<yn.gradientChance){let X=Zt(m+d(...yn.gradientHueDrift),I+d(0,8),M+(u?d(2.5,5):-d(2,4)));$=`linear-gradient(${Math.round(d(120,210))}deg, ${un(C)} 0%, ${un(X)} 100%)`,q=[C,X]}let he=Zt(m,Math.min(I+4,35),u?M+4:M-4),oe=ft(m,12,u?86:18,q,4.6),de=ft(m,10,u?64:44,q,3.1),me=a()<.5?ft(w,A(20,55),u?80:26,q,3.2):ft(m,8,u?92:12,q,4.6),Te=A(...yn.accentSat),$e=u?d(55,68):d(34,48),Re=Zt(w,Te,$e);for(;Math.max(On([253,253,254],[Re]),On([8,9,10],[Re]))<4.7;)$e+=u?1:-1,Re=Zt(w,Te,$e);let be=ft(w,18,Mn(Re)<.4?96:10,[Re],4.6),Ce=ft(a()<.5?w:m+(h[1]??30),A(35,60),u?70:34,q,3.2),Xe=un(he),xe=`1px solid ${un(Zt(m,Math.min(I+6,40),u?M+10:M-10))}`,E=l(qc),Ie=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")})`,qe=Zt(m,Math.min(I+2,28),u?Math.max(M-3,3):Math.min(M-3,93)),De=[qe],F=ft(m,8,u?85:20,De,4.6),J={keyword:h[0],string:h[3]??120,number:h[2]??60,function:h[1]??210,type:h[4]??280},U=A(...yn.hlSat),fe=u?68:36,Ee={};for(let[X,Y]of Object.entries(J))Ee[X]=ft(m+Y,U,fe,De,4.6);Ee.comment=ft(m,12,u?60:46,De,3.2),Ee.punct=ft(m,10,u?74:32,De,4.6);let Ne=[0,h[0],h[1]??40,h[2]??90,h[3]??160,h[4]??230].map((X,Y)=>Zt(m+X,A(14,34),u?M+8+Y%3*2:M-6-Y%3*2)),s=[...q,...Ne],o=ft(m,14,u?60:42,q,2.2),O=ft(m,10,u?84:20,s,3.4),Be=ft(m,10,u?62:46,s,2.7),P=ft(w,Te,u?68:38,s,2.7),Ue=Ne.map(un),nt=Zt(m,Math.min(I+4,30),u?Math.max(M-4,3):d(12,18)),W=[nt],Ae=ft(m,8,82,W,4.6),Q=ft(w,A(...yn.ansiSat),66,W,3.2),ye={red:8,green:125,yellow:45,blue:215,magenta:290,cyan:175},x={black:ft(m,10,58,W,3.1),white:ft(m,6,88,W,4.6)};for(let[X,Y]of Object.entries(ye))x[X]=ft(Y+m%16-8,A(...yn.ansiSat),66,W,3.1);let we=X=>{let[Y,ge,V]=X.map(ne=>Math.min(255,Math.round(ne+(255-ne)*.35)));return On([Y,ge,V],W)>=3?[Y,ge,V]:ft(m,8,90,W,3.1)},g=`gen-${l(Lc)}-${(r%65535).toString(16).padStart(4,"0")}`,G=un,B={"--bg":$,"--bg-accent":un(he),"--fg":G(oe),"--muted":G(de),"--font-body":Vr,"--font-heading":l(Pc),"--font-mono":Bc,"--heading-color":G(me),"--heading-weight":String(l(Dc)),"--link":G(Ce),"--accent":G(Re),"--accent-contrast":G(be),"--block-bg":Xe,"--block-border":xe,"--block-radius":E,"--shadow":Ie,"--code-bg":G(qe),"--code-fg":G(F),"--hl-keyword":G(Ee.keyword),"--hl-string":G(Ee.string),"--hl-number":G(Ee.number),"--hl-comment":G(Ee.comment),"--hl-function":G(Ee.function),"--hl-type":G(Ee.type),"--hl-punct":G(Ee.punct),"--d-stroke":G(o),"--d-text":G(O),"--d-muted":G(Be),"--d-accent":G(P),"--d-fill-1":Ue[0],"--d-fill-2":Ue[1],"--d-fill-3":Ue[2],"--d-fill-4":Ue[3],"--d-fill-5":Ue[4],"--d-fill-6":Ue[5],"--term-bg":G(nt),"--term-fg":G(Ae),"--term-prompt":G(Q),"--term-cursor":G(Q),"--term-selection":`rgba(${Re[0]}, ${Re[1]}, ${Re[2]}, 0.30)`,"--ansi-black":G(x.black),"--ansi-red":G(x.red),"--ansi-green":G(x.green),"--ansi-yellow":G(x.yellow),"--ansi-blue":G(x.blue),"--ansi-magenta":G(x.magenta),"--ansi-cyan":G(x.cyan),"--ansi-white":G(x.white),"--ansi-bright-black":G(we(x.black)),"--ansi-bright-red":G(we(x.red)),"--ansi-bright-green":G(we(x.green)),"--ansi-bright-yellow":G(we(x.yellow)),"--ansi-bright-blue":G(we(x.blue)),"--ansi-bright-magenta":G(we(x.magenta)),"--ansi-bright-cyan":G(we(x.cyan)),"--ansi-bright-white":G(ft(m,6,97,W,3.1)),"--dim-opacity":(.25+Math.round(a()*15)/100).toFixed(2)};return{name:g,seed:r,dark:u,harmony:f,tokens:B}}var ui=[["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 Zr(r,a){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 ui){let f=m.filter(h=>a[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}: ${a[h]};
239
- `;l+=`
240
- `}}let d=new Set(ui.flatMap(([,u])=>u));for(let[u,m]of Object.entries(a))d.has(u)||(l+=` ${u}: ${m};
241
- `);return l.replace(/\n$/,"")+`}
242
- `}function pi({root:r,config:a,params:l,toast:d,debugLog:u,overlays:m,deck:f,editmode:h}){let w=[...document.querySelectorAll("style[data-theme]:not([data-theme-added])")],k=[...document.querySelectorAll("style[data-theme][data-theme-added]")],A=new Set(k.map(N=>N.dataset.theme).filter(Boolean)),I=w.length>0,M=I?null:document.querySelector('link[rel="stylesheet"][href*="themes/"]');if(I){let N=w.find(H=>!H.hasAttribute("disabled")&&H.media!=="not all");N=N||w[0],w.forEach(H=>{H.removeAttribute("disabled"),H.media=H===N?"all":"not all"})}let C=I||!!M,$=N=>(N.match(/themes\/([\w-]+)\.css/)||[])[1],q="decklight-theme:"+location.pathname,he="decklight-custom-themes",oe={};try{oe=JSON.parse(localStorage.getItem(he)||"{}")||{}}catch{}let de=null,j=null,me={};function Te(N,H,ie){let pe=ie==="generated"?de:me[N];return pe||(pe=document.createElement("style"),pe.media="not all",ie==="generated"?pe.dataset.generated="":pe.dataset.custom=""),pe.dataset.theme=N,pe.textContent=Zr(N,H),document.head.appendChild(pe),ie==="generated"?de=pe:me[N]=pe,pe}let $e=()=>[de,...Object.values(me),...k];function Re(N){for(let H of $e())H&&H!==N&&(H.media="not all")}let be=()=>$e().find(N=>N&&N.media!=="not all")||null,Ce=()=>{let N=be();return N?N.dataset.theme:I?w.find(H=>H.media!=="not all")?.dataset.theme:M?$(M.href):void 0};function Xe(){let N=getComputedStyle(r),H=Pe=>Pe?.match(/rgba?\(([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[\s,/]+([\d.]+))?\)/),ie=H(N.backgroundColor);(!ie||ie[4]!==void 0&&+ie[4]==0)&&(ie=H(N.backgroundImage));let pe=ie?Mn([+ie[1],+ie[2],+ie[3]])<.5:!1;r.setAttribute("data-canvas",pe?"dark":"light")}M?.addEventListener("load",Xe);function xe(N,H=!1){if(!N||!/^[\w-]+$/.test(N))return;let ie=!1;if(j&&de&&N===j.name)de.media="all",Re(de),ie=!oe[N];else if(oe[N]){let pe=Te(N,oe[N],"custom");pe.media="all",Re(pe)}else if(A.has(N)){let pe=k.find(Pe=>Pe.dataset.theme===N);pe.media="all",Re(pe)}else{if(!C)return;if(Re(null),I){let pe=w.find(Pe=>Pe.dataset.theme===N);if(!pe)return;w.forEach(Pe=>{Pe.media=Pe===pe?"all":"not all"})}else M.href=M.href.replace(/themes\/[\w-]+\.css(\?.*)?$/,`themes/${N}.css`)}if(!l.has("embedded")&&!ie)try{localStorage.setItem(q,N)}catch{}H||d(N),u("theme",N),Xe()}let E=typeof We<"u"?We:null,Ie={added:"Added",custom:"Custom",generated:"Generated"},qe=N=>E?.labels?.[N]??Ie[N]??N;function De(N){if(oe[N])return"custom";if(j&&N===j.name)return"generated";if(A.has(N))return"added";if(E){for(let[H,ie]of Object.entries(E.packs))if(ie.includes(N))return H}return"other"}let F=()=>{let N;if(I){let ie=w.map(pe=>pe.dataset.theme);N=a.themes?.length?a.themes.filter(pe=>ie.includes(pe)):ie}else N=a.themes?.length?a.themes:typeof Ke<"u"?Ke:[];let H=[...A,...Object.keys(oe)];if(j&&!oe[j.name]&&H.push(j.name),N=[...N,...H.filter(ie=>!N.includes(ie))],E){let ie=new Map,pe=0;for(let Pe of E.order)for(let Se of E.packs[Pe]??[])ie.set(Se,pe++);N=[...N].sort((Pe,Se)=>(ie.get(Pe)??1e9)-(ie.get(Se)??1e9))}return N};function J(N){let H=[];for(let ie of E.order){let pe=(E.packs[ie]??[]).filter(Pe=>N.includes(Pe));pe.length&&H.push([ie,pe])}for(let ie of["added","custom","generated"]){let pe=N.filter(Pe=>De(Pe)===ie);pe.length&&H.push([ie,pe])}return H}let U=N=>btoa(unescape(encodeURIComponent(JSON.stringify(N)))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),fe=N=>JSON.parse(decodeURIComponent(escape(atob(N.replace(/-/g,"+").replace(/_/g,"/")))));function Ee(N,H=!1){j={name:N.name,tokens:N.tokens};let ie=Te(N.name,N.tokens,"generated");return ie.media="all",Re(ie),H||d(`\u2728 ${N.name} \u2014 \u2303T re-roll \xB7 \u2303\u21E7T save`,2800),Xe(),N.name}function ze(){return Ee(mr())}function Ne(N){if(!j||!de||de.media==="not all")return d("no generated theme to save \u2014 \u2303T to generate one"),null;let H=N??(window.prompt?.("Save theme as:",j.name.replace(/^gen-/,""))||"");if(H=String(H).toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40),!H)return null;((typeof Ke<"u"?Ke:[]).includes(H)||w.some(Pe=>Pe.dataset.theme===H))&&(H="custom-"+H),oe[H]=j.tokens;try{localStorage.setItem(he,JSON.stringify(oe))}catch{}let pe=Te(H,oe[H],"custom");if(pe.media="all",de?.remove(),de=null,j=null,Re(pe),!l.has("embedded"))try{localStorage.setItem(q,H)}catch{}try{let Pe=new Blob([Zr(H,oe[H])],{type:"text/css"}),Se=document.createElement("a");Se.href=URL.createObjectURL(Pe),Se.download=`${H}.css`,Se.click(),setTimeout(()=>URL.revokeObjectURL(Se.href),5e3)}catch{}return d(`saved ${H} \u2014 ${H}.css downloaded`,2200),H}let s=null;function o(N=!1){return s?(clearTimeout(s.timer),s=null,N||d("theme cycle cancelled"),!0):!1}function O(N){let H=F();if(!C||H.length<2)return;if(s){let Se=s;clearTimeout(Se.timer),s=null,Se.dir===N?xe(Se.name):d("theme cycle cancelled");return}let ie=Ce(),pe=Math.max(0,H.indexOf(ie)),Pe=H[(pe+N+H.length)%H.length];if(E&&De(Pe)!==De(ie)){let Se=N>0?".":",",Me=N>0?",":".";s={dir:N,name:Pe,timer:setTimeout(()=>{s=null},4e3)},d(`\u2933 ${qe(De(Pe))} pack next (${Pe}) \u2014 ${Se} confirms \xB7 ${Me} or Esc cancels`,4e3);return}xe(Pe)}l.has("embedded")&&window.addEventListener("message",N=>{let H=N.data&&N.data.__decklightPreview;!H||N.source!==window.parent||(H.gen?Ee(H.gen,!0):H.theme?xe(H.theme,!0):H.goto&&f().goto(H.goto[0],H.goto[1]??0))});function Be(){let N=Ce(),H=oe[N]?{name:N,tokens:oe[N]}:j&&N===j.name?j:null;return H?"?embedded&gen="+U(H):N?"?embedded&theme="+encodeURIComponent(N):"?embedded"}function P(){let N=l.get("gen");if(N)try{let pe=fe(N);if(pe&&pe.tokens){Ee({name:pe.name||"gen-preview",tokens:pe.tokens},!0);return}}catch{}let H=null;try{H=localStorage.getItem(q)}catch{}let ie=l.get("theme")||H;ie&&xe(ie,!0)}let Ue="\0generate",nt="pack:",W="back",Ae="all",Q="browse",ye="",x=N=>N.charCodeAt(0)<32,we=null,g=0,G,B=[],X=null,Y="",ge="packs",V=()=>E?"packs":"all",ne=()=>h?.()?.available()===!0,Fe=()=>h?.()?.base()??"",Je=()=>ne()?[Q]:[],re=null,ke=N=>(re?.themes??[]).find(H=>H.qualified===N);async function He(){re={loading:!0,themes:[],stale:[]},_t("browse");let N;try{let H=await fetch(Fe()+"/edit/theme/browse"),ie=await H.json().catch(()=>({}));N=H.ok&&ie.ok?{themes:ie.themes??[],stale:ie.stale??[],cacheOnly:ie.cacheOnly!==!1}:{themes:[],stale:[],error:ie.error||`the author server said ${H.status}`}}catch{N={themes:[],stale:[],error:"the author server did not answer"}}!we||ge!=="browse"||(re=N,_t("browse"))}async function _e(N){let H=we?.querySelector(".tp-caption");H&&(H.textContent=`installing ${N}\u2026`);try{let ie=await fetch(Fe()+"/edit/theme/add",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ref:N})}),pe=await ie.json().catch(()=>({}));if(!ie.ok){let Pe=[pe.error,...pe.problems??[]].filter(Boolean).join(" \xB7 ");H&&(H.textContent=Pe||`install failed (${ie.status})`),d(`${N}: ${pe.error||"install refused"}`,3600);return}ot(),d(`installed ${pe.name}${pe.replaced?" (replaced)":""} \u2014 Z takes it back`,2800),u("theme",`${N} installed from a marketplace`)}catch{H&&(H.textContent="the author server did not answer")}}function Le(N){let H=f().state,ie="#/"+H.slide+"/"+H.step;if(N===Ue||oe[N]||j&&N===j.name){let pe=N===Ue?X:oe[N]?{name:N,tokens:oe[N]}:j;return location.pathname+"?embedded&gen="+U(pe)+ie}return location.pathname+"?embedded&theme="+encodeURIComponent(N)+ie}function Qe(N){N.textContent=X?`\u2728 ${X.name} \u2014 \u2303T re-rolls`:"\u2728 Generate new\u2026"}function Oe(){X=mr();let N=B.indexOf(Ue);N<0||(Qe(we.querySelectorAll(".tp-row")[N]),te(N,!0))}function Ye(){let N=we.querySelector(".tp-list"),H=Ce(),ie=F();if(ge==="browse"){let Se=(re?.themes??[]).filter(Me=>!Y||Me.qualified.includes(Y));B=[W,...Se.map(Me=>ye+Me.qualified)]}else if(Y)B=ie.filter(Se=>Se.includes(Y));else if(!E||ge==="all")B=E?[Ue,W,...ie]:[Ue,...ie,...Je()];else if(ge==="packs")B=[Ue,...J(ie).map(([Se])=>nt+Se),Ae,...Je()];else{let Se=ge.slice(5);B=[W,...J(ie).find(([Me])=>Me===Se)?.[1]??[]]}N.textContent="";let pe=(Se,Me)=>{let rt=document.createElement("span");rt.className="tp-tag",rt.textContent=Me,Se.appendChild(rt)};if(B.forEach((Se,Me)=>{let rt=document.createElement("div");if(rt.setAttribute("role","option"),Se===Ue)rt.className="tp-row tp-gen",Qe(rt);else if(Se===W)rt.className="tp-row tp-back",rt.textContent=V()==="packs"?"\u2190 packs":"\u2190 themes";else if(Se===Q)rt.className="tp-row tp-browse",rt.textContent="\u2315 Browse marketplaces\u2026";else if(Se.startsWith(ye)){let at=ke(Se.slice(ye.length));rt.className="tp-row tp-mkt",rt.textContent=at?.name??Se.slice(ye.length);let Et=A.has(at?.name)?"installed":at?.marketplace;Et&&pe(rt,Et)}else if(Se===Ae)rt.className="tp-row tp-all",rt.textContent="\u2733 all themes",pe(rt,String(ie.length));else if(Se.startsWith(nt)){let at=Se.slice(nt.length),Et=J(ie).find(([Nt])=>Nt===at)?.[1]??[];rt.className="tp-row tp-pack"+(Et.includes(H)?" tp-current":""),rt.textContent=`\u25B8 ${qe(at)}`,pe(rt,String(Et.length))}else{rt.className="tp-row"+(Se===H?" tp-current":""),rt.textContent=Se;let at=oe[Se]?"custom":j&&Se===j.name?"generated":A.has(Se)?"added":Y&&E?qe(De(Se)):null;at&&pe(rt,at)}rt.addEventListener("mouseenter",()=>te(Me,!1)),rt.addEventListener("click",()=>{te(Me,!0),gt()}),N.appendChild(rt)}),!B.length){let Se=document.createElement("div");Se.className="tp-none",Se.textContent="no themes match",N.appendChild(Se)}if(ge==="browse"){let Se=document.createElement("div");Se.className="tp-none",Se.textContent=re?.loading?"reading the catalogs\u2026":re?.error?re.error:B.some(Me=>Me.startsWith(ye))?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":Y?"no marketplace theme matches":"no themes in the marketplaces you have registered",N.appendChild(Se)}let Pe=we.querySelector(".tp-filter");Pe.textContent=Y||"type to filter\u2026",Pe.classList.toggle("tp-active",!!Y)}function ct(){let N=Ce(),H=B.indexOf(N);if(H>=0)return H;let ie=B.indexOf(nt+De(N));return ie>=0?ie:Math.min(1,B.length-1)}function _t(N,H=!1){ge=N,Ye(),B.length&&te(ct(),H)}function Pt(N){Y=N.toLowerCase(),Ye(),B.length?te(Y?0:ct(),!1):we.querySelector(".tp-caption").textContent="no match"}function Kt(){if(we)return ot();m.closeOthers(st);let N=F();if(!C&&!N.length)return;Y="",ge=V(),re=null,we=document.createElement("div"),we.className="decklight-theme-picker",we.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>',Ye(),kt(we,ot),r.appendChild(we);let H=Ce();H&&Ct(we.querySelector("iframe"),H),te(ct(),!H)}function te(N,H){if(!B.length)return;g=(N+B.length)%B.length;let ie=B[g];ie===Ue&&!X&&(X=mr(),Qe(we.querySelectorAll(".tp-row")[g])),jt(we.querySelectorAll(".tp-row"),g,"tp-selected");let pe=F(),Pe=ie===Ue?X?`\u2728 ${X.name}`:"generate new":ie===W?V()==="packs"?"back to packs":"back to the theme list":ie===Q?"themes from the marketplaces you have registered":ie.startsWith(ye)?nn(ie.slice(ye.length)):ie===Ae?`all ${pe.length} themes, flattened`:ie.startsWith(nt)?`${qe(ie.slice(nt.length))} \xB7 ${J(pe).find(([Me])=>Me===ie.slice(nt.length))?.[1].length??0} themes`:E?`${qe(De(ie))} \xB7 ${ie}`:ie;if(we.querySelector(".tp-caption").textContent=Pe,clearTimeout(G),ie!==Ue&&x(ie))return;let Se=we.querySelector("iframe");H?Ct(Se,ie):G=setTimeout(()=>Ct(Se,ie),60)}function nn(N){let H=ke(N);return H?[H.qualified,H.description,A.has(H.name)?"installed \u2014 \u23CE re-installs it":"\u23CE installs it"].filter(Boolean).join(" \xB7 "):N}let Dt=!1,qt=null;function Xt(N){return N===Ue||oe[N]||j&&N===j.name?{gen:N===Ue?X:oe[N]?{name:N,tokens:oe[N]}:j}:{theme:N}}function Ct(N,H){if(!N.dataset.booted){N.dataset.booted="1",Dt=!1,N.addEventListener("load",()=>{if(Dt=!0,qt!==null&&we){let ie=qt;qt=null,Ct(N,ie)}},{once:!0}),N.src=Le(H);return}if(!Dt){qt=H;return}N.contentWindow?.postMessage({__decklightPreview:Xt(H)},"*")}function gt(){let N=B[g];if(N!==void 0){if(N===Ue){X&&Ee(X),ot();return}if(N===W){_t(V());return}if(N===Ae){_t("all");return}if(N===Q){He();return}if(N.startsWith(ye)){_e(N.slice(ye.length));return}if(N.startsWith(nt)){_t("pack:"+N.slice(nt.length),!0);return}xe(N),ot()}}function ot(){clearTimeout(G),we?.remove(),we=null}let st=m.register({isOpen:()=>!!we,close:ot,keydown(N){switch(N.key){case"ArrowDown":te(g+1,!1);break;case"ArrowUp":te(g-1,!1);break;case"Enter":gt();break;case"Backspace":Pt(Y.slice(0,-1));break;case"Escape":Y?Pt(""):ge!==V()?_t(V()):ot();break;default:if(N.key.length===1&&/[a-z0-9-]/i.test(N.key)){Pt(Y+N.key);break}return!1}return!0}});return{applyTheme:xe,currentTheme:Ce,themeList:F,cycleTheme:O,cancelCyclePending:o,rollTheme:ze,saveGeneratedTheme:Ne,adoptGenerated:Ee,updateCanvas:Xe,restoreSaved:P,previewQuery:Be,openPicker:Kt,closePicker:ot,browse(){we||Kt(),we&&He()},hasGenerated:()=>!!j,rollFromPicker(){return we&&B[g]===Ue?(Oe(),!0):!1}}}ae();le();ae();le();ae();le();var Xr=["A","B","C","D","E","F","G","H","X"],Ln="#edb58e",hi="#c98f6d",Fc="#43302a",Rn="#b96b58",In="#57262c",fr="#f6f1ea",mi="#d17a70",Yr=`<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="${Ln}"/>
248
- <path d="M106 142 L 106 156 C 114 162 126 162 134 156 L 134 142 Z" fill="${hi}"/>
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="${Ln}"/>
251
- <circle cx="165" cy="98" r="9" fill="${Ln}"/>
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="${Ln}"/>
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="${Fc}"/>
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,38 +261,63 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Ee=F,fe=J),U===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="${Ln}"/></g>
265
- <g data-eyelid><rect x="129" y="90.5" width="16" height="12" rx="6" fill="${Ln}"/></g>
266
- <path d="M120 101 L 117 115 Q 120 119 124 116" stroke="${hi}" 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="${Rn}" 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="${Rn}"/></g>
271
- <g data-mouth="B"><path d="M104 129 Q 120 122 136 129 Q 120 141 104 129 Z" fill="${In}"/><rect x="110" y="126" width="20" height="5" rx="2" fill="${fr}"/></g>
272
- <g data-mouth="C"><ellipse cx="120" cy="131" rx="13" ry="8.5" fill="${In}"/><rect x="109" y="124.5" width="22" height="4.5" rx="2" fill="${fr}"/></g>
273
- <g data-mouth="D"><ellipse cx="120" cy="132" rx="16" ry="12" fill="${In}"/><rect x="106" y="122" width="28" height="6" rx="2.5" fill="${fr}"/><ellipse cx="120" cy="140" rx="9" ry="4.5" fill="${mi}"/></g>
274
- <g data-mouth="E"><ellipse cx="120" cy="131" rx="9" ry="7" fill="${In}" stroke="${Rn}" stroke-width="3"/></g>
275
- <g data-mouth="F"><ellipse cx="120" cy="131" rx="6" ry="5.5" fill="${In}" stroke="${Rn}" 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="${Rn}"/><rect x="110" y="127" width="20" height="5" rx="2" fill="${fr}"/><path d="M108 134 Q 120 139 132 134" stroke="${Rn}" stroke-width="3" fill="none" stroke-linecap="round"/></g>
277
- <g data-mouth="H"><ellipse cx="120" cy="131" rx="12" ry="9" fill="${In}"/><path d="M113 125 Q 120 122 127 125 Q 127 132 120 133 Q 113 132 113 125 Z" fill="${mi}"/></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 zc(r,a){let l=r?.cues;if(!l?.length||!(a>=0)||r.duration&&a>=r.duration)return"X";let d=0,u=l.length-1,m=-1;for(;d<=u;){let h=d+u>>1;l[h].t<=a?(m=h,d=h+1):u=h-1}if(m<0)return"X";let f=l[m].v;return Xr.includes(f)?f:"X"}function fi(r){let a=m=>Math.round(m*1e3)/1e3,l=[],d=(m,f)=>{l.length&&l[l.length-1].v===f||l.push({t:a(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:a(u),source:"stitch",cues:l}}function gi({root:r,config:a,debugLog:l,toast:d}){let u=a.narration?.character??{},m=u.bridgeUrl??"http://127.0.0.1:8789",f=u.fallback??"amplitude",h="decklight-character:"+location.pathname,w=u.mode??"off",k=u.engine??"wav2lip",A=u.portrait??"default",I=u.solo??!1;try{let Q=JSON.parse(localStorage.getItem(h));Q?.mode&&(w=Q.mode,k=Q.engine??k,A=Q.portrait??A),typeof Q?.solo=="boolean"&&(I=Q.solo)}catch{}let M=null,C=null,$=null,q=null,he=null,oe=null,de=null,j=0,me=!1,Te,$e=new Map,Re=new Map,be=Q=>`${Q}|${k}|${A}`;function Ce(){try{localStorage.setItem(h,JSON.stringify({mode:w,engine:k,portrait:A,solo:I}))}catch{}}function Xe(){r.classList.toggle("decklight-solo",I&&w!=="off"&&!!M?.classList.contains("show"))}function xe(){me||(me=!0,d("lipsync bridge unreachable \u2014 run: decklight lipsync"),l("lipsync","bridge unreachable \u2014 amplitude fallback"))}function E(){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)),$!==w)if($=w,M.classList.toggle("mode-video",w==="video"),C=null,w==="video")M.innerHTML="",C=document.createElement("video"),C.muted=!0,C.playsInline=!0,C.preload="auto",M.appendChild(C);else if(u.sprites){M.innerHTML="";for(let Q of Xr){if(!u.sprites[Q])continue;let ye=document.createElement("img");ye.src=u.sprites[Q],ye.setAttribute("data-mouth",Q),ye.alt="",M.appendChild(ye)}}else if(typeof u.svg=="string"&&u.svg.startsWith("#")){M.innerHTML="";let Q=document.querySelector(u.svg);Q&&M.appendChild(Q.cloneNode(!0))}else typeof u.svg=="string"&&/^\s*</.test(u.svg)?M.innerHTML=u.svg:u.svg?(M.innerHTML=Yr,fetch(u.svg).then(Q=>Q.text()).then(Q=>{M&&$==="viseme"&&(M.innerHTML=Q)}).catch(()=>{})):M.innerHTML=Yr}function Ie(){E(),M.classList.add("show"),j||(j=setInterval(Ne,33)),Xe()}function qe(){j&&(clearInterval(j),j=0),M?.classList.remove("show"),C?.pause(),he=null,oe=null,De("X"),Xe()}function De(Q){Q===de||!M||(de=Q,M.setAttribute("data-viseme",Q))}let F=null,J=null,U=null,fe=null;function Ee(){if(f!=="amplitude"||!q)return!1;if(U===q)return!!J;U=q;try{F??=new(window.AudioContext||window.webkitAudioContext);let Q=F.createMediaElementSource(q);J=F.createAnalyser(),J.fftSize=512,Q.connect(J),J.connect(F.destination),fe=new Uint8Array(J.fftSize)}catch{J=null}return!!J}function ze(){J.getByteTimeDomainData(fe);let Q=0;for(let x=0;x<fe.length;x++){let we=(fe[x]-128)/128;Q+=we*we}let ye=Math.sqrt(Q/fe.length);return ye<.02?"X":ye<.06?"B":ye<.12?"C":"D"}function Ne(){if(M?.classList.contains("show")){if(w==="video"){C&&q&&C.readyState>=2&&!q.paused&&Math.abs(C.currentTime-q.currentTime)>.15&&(C.currentTime=q.currentTime);return}if(!q||q.paused||q.ended){De("X");return}he?De(zc(he,q.currentTime)):f==="hide"?De("X"):Ee()?De(ze()):De("X")}}function s(Q,ye,x){if(!$e.has(Q)){let we=(async()=>{let g=await ye;if(!g)return null;let G=Date.now(),B=await fetch(`${m}/viseme?text=${encodeURIComponent(x??"")}`,{method:"POST",headers:{"content-type":"audio/wav"},body:g.blob});if(!B.ok)throw new Error(String(B.status));let X=await B.json();return l("lipsync",`visemes ${Q} \xB7 ${X.cues?.length??0} cues \u2192 ${((Date.now()-G)/1e3).toFixed(1)}s`),X})();we.catch(()=>{$e.get(Q)===we&&$e.delete(Q)}),$e.set(Q,we)}return $e.get(Q)}function o(Q,ye){let x=be(Q);if(!Re.has(x)){let we=(async()=>{let g=await ye;if(!g)return null;let G=Date.now(),B=await fetch(`${m}/video?engine=${k}&portrait=${encodeURIComponent(A)}`,{method:"POST",headers:{"content-type":"audio/wav"},body:g.blob});if(!B.ok)throw new Error(String(B.status));let X=await B.blob(),Y=B.headers?.get?.("x-lipsync-cached")==="1";return l("lipsync",`video ${Q} \xB7 ${k} \u2192 ${((Date.now()-G)/1e3).toFixed(1)}s${Y?" (cached)":""}`),URL.createObjectURL(X)})();we.catch(()=>{Re.get(x)===we&&Re.delete(x)}),Re.set(x,we)}return Re.get(x)}function O(Q,ye,x){w==="viseme"?s(Q,ye,x).catch(()=>{}):w==="video"&&o(Q,ye).catch(()=>{})}function Be(Q,ye,x){w!=="off"&&(Ie(),oe=Q,w==="viseme"?(he=null,s(Q,Promise.resolve(ye),x).then(we=>{oe===Q&&(he=we)}).catch(()=>xe())):o(Q,Promise.resolve(ye)).then(we=>{oe!==Q||!we||!C||(C.src=we,C.playbackRate=q?.playbackRate??1,q&&!q.paused&&(C.currentTime=q.currentTime,C.play().catch(()=>{})))}).catch(()=>xe()))}function P(Q,ye){if(w==="off"||!Q||Q.live)return;Ie();let x=String(ye).padStart(2,"0"),we=`file|${Q.dir}|${x}`;oe=we,w==="viseme"?(he=null,(async()=>{let g=document.querySelector(`script[data-decklight-visemes="slide-${x}"]`);if(g)return JSON.parse(g.textContent);let G=await fetch(`${Q.dir}/slide-${x}.visemes.json`);if(!G.ok)throw new Error(String(G.status));return G.json()})().then(g=>{oe===we&&(he=g)}).catch(()=>{})):C&&(C.src=`${Q.dir}/slide-${x}.mp4`,C.playbackRate=q?.playbackRate??1,C.play().catch(()=>{}))}function Ue(Q){!Q||q===Q||(q=Q,Q.addEventListener("pause",()=>{w==="video"&&C?.pause()}),Q.addEventListener("play",()=>{w==="video"&&C?.src&&C.play().catch(()=>{})}),Q.addEventListener("ratechange",()=>{C&&(C.playbackRate=Q.playbackRate)}))}async function nt(){try{let Q=await fetch(m+"/ping");Te=Q.ok?await Q.json():null}catch{Te=null}return Te}function W(Q,ye={}){w=Q,ye.engine&&(k=ye.engine),ye.portrait&&(A=ye.portrait),Ce(),w==="off"?qe():(me=!1,E(),I&&Ie()),Xe(),l("lipsync",w==="off"?"character off":`character ${w}${w==="video"?` \xB7 ${k} \xB7 ${A}`:""}`)}function Ae(Q){I=!!Q,Ce();let ye=!!q&&!q.paused&&!q.ended;I&&w!=="off"?Ie():!I&&!ye&&qe(),Xe(),l("lipsync",`character solo ${I?"on":"off"}`)}return{get mode(){return w},get engine(){return k},get portrait(){return A},get solo(){return I},get bridgeInfo(){return Te},setMode:W,setSolo:Ae,prefetchSentence:O,beginSentence:Be,beginSlide:P,attachAudio:Ue,stop:qe,probe:nt,ensureTimeline:s}}ae();le();function Uc(r){let a=String(r??"").replace(/[?#].*$/,"");return a.slice(0,a.lastIndexOf("/")+1)}var Hc=/^[a-z][a-z0-9+.-]*:|^\/\//i;function bi(r,a,l){let d=r?.slides?.[l-1];return d?d.url?d.url:d.file?Hc.test(d.file)?d.file:Uc(a)+d.file:null:null}function gr(r,a=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()-a;return{at:d,msLeft:u,expired:u<=0}}function yi(r){if(!Number.isFinite(r))return"";if(r<=0)return"expired";let a=Math.floor(r/6e4),l=Math.floor(a/60),d=Math.floor(l/24);return d?`${d}d ${l%24}h left`:l?`${l}h ${a%60}m left`:`${Math.max(1,a)}m left`}var br=r=>r.toISOString().slice(0,16).replace("T"," ")+"Z";function Jr(r){let a=r?.source??"<voice-dir>",l=r?.bucket??"gs://<bucket>/<prefix>",d=r?.signDuration??"7d";return`node tools/publish-voices.mjs ${a} --bucket ${l} --sign ${d}`}function Qr(r){return r?.manifest??r?.dir??null}function Gc({hasTracks:r,used:a,printMode:l,embedded:d,voiceover:u,captionsOn:m,narrating:f}={}){return!!r&&!a&&!l&&!d&&!u&&!m&&!f}function wi({root:r,stage:a,config:l,params:d,printMode:u,toast:m,logOnly:f,debugLog:h,overlays:w,instance:k,syncSoundBtn:A,updateDebugState:I,downloadFromUrl:M}){let C=0,$="decklight-narration:"+location.pathname,q=l.narration?.liveUrl??"http://127.0.0.1:8787/tts",he=[["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"]],oe=q.replace(/\/tts\/?$/,"/ping"),de=he,j=!0,me=null,Te=null;function $e(){return Te??=fetch(oe).then(T=>T.ok?T.json():null).then(T=>{if(!T)return null;if(me=T.engine??null,Array.isArray(T.voices)&&T.voices.length&&(de=T.voices),j=T.stylable!==!1,h("tts",`bridge: ${T.engine} \xB7 ${T.model} \xB7 ${de.length} voice(s)`+(j?"":" \xB7 no style")),de.length&&!de.some(([K])=>K===xe.voice)){let K=xe.voice;xe={...xe,voice:de[0][0]},Me(),h("tts",`voice ${K} is not on this bridge \u2014 using ${xe.voice}`),E?.live&&m(`voice ${K} \u2192 ${xe.voice} (this bridge speaks its own roster)`,2600)}return T}).catch(()=>null),Te}let Re=[["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"]],be=([,T,K])=>me==="elevenlabs"?K:T,Ce=(()=>{let T=l.narration?.files;return T?Array.isArray(T)?T:[{label:"Narration",dir:T}]:[]})(),Xe={live:!0},xe={voice:"Alnilam",tone:Re[0][0],style:Re[0][1]},E=Ce[0]??null;try{let T=JSON.parse(localStorage.getItem($));if(T?.live?.voice)xe=T.live,E=Xe;else{let K=T?.track??T?.dir,y=Ce.find(_=>Qr(_)===K);y&&(E=y)}}catch{}let Ie=!1,qe=null,De="decklight-narr-rate:"+location.pathname,F=1;try{let T=parseFloat(localStorage.getItem(De)??"");T>=.25&&T<=2&&(F=T)}catch{}function J(T){F=Math.round(Math.min(2,Math.max(.25,F+T))*100)/100;try{localStorage.setItem(De,String(F))}catch{}qe&&(qe.playbackRate=F),m(`voice speed ${F}\xD7`),h("narr",`rate ${F}\xD7`),I()}let U=gi({root:r,config:l,debugLog:h,toast:m}),fe=new Map;function Ee(T){return(k._sections?.[T-1]?.querySelector("aside.notes")?.textContent??"").replace(/⟨CLICK⟩/g," ").replace(/\s+/g," ").trim()}function ze(T){return(k._sections?.[T-1]?.querySelector("aside.notes")?.textContent??"").split("\u27E8CLICK\u27E9").map(y=>y.replace(/\s+/g," ").trim())}function Ne(T,K,y){if(!T)return Promise.resolve(null);if(!fe.has(K)){let _=(async()=>{let S=Date.now();try{let R=await fetch(q,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:T,voice:xe.voice,style:xe.style})});if(!R.ok)throw new Error(String(R.status));let Z=await R.blob(),ue=parseFloat(R.headers?.get?.("x-tts-cost")??"")||0;return ue&&(C+=ue),h("tts",`${y} \xB7 ${xe.voice} \xB7 ${T.length} chars \u2192 ${((Date.now()-S)/1e3).toFixed(1)}s`+(ue?` \xB7 ~$${ue.toFixed(4)}`:"")),{url:URL.createObjectURL(Z),blob:Z}}catch(R){throw h("tts",`${y} \xB7 ${xe.voice} FAILED after ${((Date.now()-S)/1e3).toFixed(1)}s (${String(R.message||R)})`),R}})();_.catch(()=>{fe.get(K)===_&&fe.delete(K)}),fe.set(K,_)}return fe.get(K)}function s(T){return((T??"").match(/[^.!?…]+[.!?…]+[”’"')\]]*|[^.!?…]+$/g)??[]).map(K=>K.trim()).filter(Boolean)}let o=(T,K,y)=>`${T}|s${K}|n${y}|${xe.voice}|${xe.style}`;function O(T,K,y){let _=s(ze(T)[K])[y]??"";return Ne(_,o(T,K,y),`slide ${T} seg ${K} #${y+1}`)}let Be=T=>k._sections[T-1]?.dataset.narration==="hold",P=10,Ue=3,nt=0;function W(T){let K=[],y=k.state.slide,_=k.state.step;for(;K.length<T&&y<=k.state.totalSlides;){let S=ze(y),R=k._records[y-1]?k._records[y-1].groups.length:0;for(;_<=R&&K.length<T;_++){let Z=s(S[_]).length;for(let ue=0;ue<Z&&K.length<T;ue++)K.push([y,_,ue])}y+=1,_=0}return K}async function Ae(){let T=++nt,K=async()=>{for(;T===nt&&Ie&&E?.live;){let y=W(P).find(([_,S,R])=>!fe.has(o(_,S,R)));if(!y)return;try{if(await O(y[0],y[1],y[2]),U.mode!=="off"){let[_,S,R]=y;U.prefetchSentence(o(_,S,R),fe.get(o(_,S,R)),s(ze(_)[S])[R]??"")}}catch{return}await new Promise(_=>setTimeout(_,30))}};await Promise.all(Array.from({length:Ue},K))}let Q=0,ye=!1,x=!1,we=0;function g(){if(!Ie){m("narration is off \u2014 V starts it");return}ye=!ye,ye?qe?.pause():qe?.src&&qe.paused&&!qe.ended&&qe.currentTime>0?qe.play().catch(()=>{}):x||B(),m(ye?"\u23F8 narration paused \u2014 P resumes":"\u25B6 narration resumed"),h("narr",ye?"paused":"resumed"),I()}function G(T,K){if(!Ie||ye||!E?.live||k.state.slide!==T||k.state.step!==K)return;let y=k._records[T-1];K<(y?y.groups.length:0)?k.next():!Be(T)&&T<k.state.totalSlides&&k.goto(T+1,0)}async function B(){let T=k.state.slide,K=k.state.step,y=++Q;if(Ae(),!Ee(T)){if(Be(T)){h("narr",`hold on slide ${T} \u2014 manual advance`);return}setTimeout(()=>{y!==Q||!Ie||!E?.live||k.state.slide===T&&T<k.state.totalSlides&&k.goto(T+1,0)},400);return}let _=ze(T);if(!_[K]){setTimeout(()=>{y===Q&&G(T,K)},600);return}let S=s(_[K]),R=()=>y!==Q||!Ie||k.state.slide!==T||k.state.step!==K;we=y,x=!0;let Z=0;try{for(let ue=0;ue<S.length;ue++){for(;ye;){if(R())return;await new Promise(ht=>setTimeout(ht,150))}if(R())return;let Ve;try{Ve=await O(T,K,ue)}catch(ht){h("narr",`sentence failed (slide ${T} seg ${K} #${ue+1}) \u2014 narration stopped`),Le(X(ht));return}if(R())return;if(!Ve)continue;_t(S[ue]),qe??=new Audio,U.mode!=="off"&&(U.attachAudio(qe),U.beginSentence(o(T,K,ue),Ve,S[ue])),qe.src=Ve.url,qe.playbackRate=F;let it=!1;if(await new Promise(ht=>{qe.onended=ht,qe.play().catch(()=>{it=!0,ht()})}),it){Le("\u{1F507} the browser blocked audio \u2014 click the deck once, then V \u2014 the slides wait for the voice");return}Z++}if(R())return;if(!Z&&S.length){Le("\u{1F507} the voice did not play \u2014 auto-advance stopped \xB7 press the key left of 1 for messages");return}G(T,K)}finally{we===y&&(x=!1)}}function X(T){let K=String(T?.message??T);return K.startsWith("429")?"\u{1F507} voice quota exceeded (429) \u2014 auto-advance stopped \xB7 a free engine: decklight author --tts-engine chirp":/^\d{3}/.test(K)?`\u{1F507} voice bridge error ${K.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 Y=new Map,ge=new Map,V=new Set,ne=null;function Fe(T){for(let K of document.querySelectorAll('script[type="application/json"][data-decklight-voices]'))if(K.getAttribute("data-decklight-voices")===T)try{return JSON.parse(K.textContent)}catch{return null}return null}function Je(T){if(!Y.has(T)){let K=Fe(T);Y.set(T,K?Promise.resolve(K):fetch(T).then(y=>{if(!y.ok)throw new Error(`HTTP ${y.status}`);return y.json()}).catch(y=>{throw Y.delete(T),y})),Y.get(T).then(y=>ge.set(T,y)).catch(()=>{})}return Y.get(T)}function re(T){let K=ge.get(T.manifest);if(!K)return V.has(T.manifest)?"hosted \u2014 the voice list did not load":(Je(T.manifest).catch(()=>V.add(T.manifest)).then(()=>{H&&pe==="tracks"&&pt("tracks")}),"hosted \u2014 checking\u2026");let y=gr(K);return y.at?y.expired?`EXPIRED ${br(y.at)} \u2014 re-sign to play`:`signed \xB7 ${yi(y.msLeft)}`:"hosted \xB7 no expiry"}async function ke(){if(!E||E.live||!E.manifest)return ne=null,!0;if(ne?.track!==E)try{ne={track:E,data:await Je(E.manifest)}}catch(K){return ne=null,Le(`\u{1F507} could not load the voice list for \u201C${E.label}\u201D (${E.manifest} \u2014 ${K.message}) \u2014 auto-advance stopped`),!1}let T=gr(ne.data);return T.expired?(Le(`\u{1F507} the signed voices for \u201C${E.label}\u201D expired ${br(T.at)} \u2014 auto-advance stopped \xB7 re-sign: ${Jr(ne.data)}`),!1):!0}function He(T){return E.manifest?bi(ne?.data,E.manifest,T):`${E.dir}/slide-${String(T).padStart(2,"0")}.${E.ext??"m4a"}`}function _e(){if(!E)return;if(E.live)return B();if(!Ee(k.state.slide)){qe?.pause();return}let T=He(k.state.slide);if(!T){qe?.pause();return}qe??=new Audio,qe.src=T,qe.playbackRate=F,U.mode!=="off"&&(U.attachAudio(qe),U.beginSlide(E,k.state.slide)),qe.onerror=()=>{h("narr",`no audio: ${T}`);let K=E.manifest?gr(ne?.data):null;if(K?.at){h("narr","signed url failed \u2014 a media element cannot report the status"),Le(`\u{1F507} slide ${k.state.slide} of \u201C${E.label}\u201D would not load (signed until ${br(K.at)}) \u2014 auto-advance stopped \xB7 re-sign: ${Jr(ne?.data)}`);return}m(`\u{1F507} no narration for slide ${k.state.slide} (${T}) \xB7 press the key left of 1 for messages`)},qe.play().catch(()=>{m("\u{1F507} the browser blocked audio \u2014 click the deck once, then V")})}function Le(T="narration off"){Ie=!1,Q++,nt++,ye=!1,qe?.pause(),U.stop(),m(T),h("narr",T),A()}async function Qe(){if(!E){rn(Ce.length?"tracks":"voices");return}if(Ie)return Le();if(st(),E.live&&await $e(),!await ke())return;Ie=!0;let T=E.live?`\u26A1 ${xe.voice} \xB7 ${xe.tone}`:E.label;m(`\u{1F50A} ${T} \u2014 V stops \xB7 N picks`),h("narr",`on \u2014 ${T}`),_e(),A()}k.on("slide",()=>{Ie&&_e()}),k.on("build",()=>{Ie&&E?.live&&B()});let Oe="decklight-captions:"+location.pathname,Ye=!1;try{Ye=localStorage.getItem(Oe)==="1"}catch{}let ct=null;function _t(T){ct&&(ct.textContent=T,ct.classList.toggle("show",!!T))}function Pt(){if(ct){if(Ie&&E?.live){_t("");return}_t(ze(k.state.slide)[k.state.step]??"")}}function Kt(){ct=document.createElement("div"),ct.className="decklight-captions",ct.setAttribute("aria-live","polite"),r.appendChild(ct),Pt()}function te(){Ye=!Ye;try{localStorage.setItem(Oe,Ye?"1":"0")}catch{}Ye?(Kt(),ot()):(ct?.remove(),ct=null),m(`captions ${Ye?"on":"off"}`),h("narr",`captions ${Ye?"on":"off"}`)}k.on("slide",Pt),k.on("build",Pt),Ye&&!u&&Kt();let nn="\u{1F50A} this deck has a voice-over \u2014 V plays it",Dt=900,qt=12e3,Xt="decklight-narr-used:"+location.pathname,Ct=!1;try{Ct=localStorage.getItem(Xt)==="1"}catch{}let gt=null;function ot(){if(!gt)return;let T=gt;gt=null,T.classList.remove("show"),setTimeout(()=>T.remove(),260)}function st(){if(ot(),!Ct){Ct=!0;try{localStorage.setItem(Xt,"1")}catch{}}}function N(){let T=document.createElement("button");T.type="button",T.className="decklight-narr-hint",T.setAttribute("aria-label","Play this deck\u2019s voice-over");let K=document.createElement("kbd");K.textContent="V",T.append("\u{1F50A} this deck has a voice-over \u2014 ",K," plays it"),T.addEventListener("click",()=>{ot(),Qe()}),gt=T,r.appendChild(T),T.offsetWidth,T.classList.add("show"),f?.(nn),h("narr","voice-over hint shown"),setTimeout(ot,qt)}Gc({hasTracks:Ce.length>0,used:Ct,printMode:u,embedded:!!d?.has("embedded"),voiceover:!!d?.has("voiceover"),captionsOn:Ye})&&setTimeout(()=>{Ie||N()},Dt);let H=null,ie=0,pe="tracks",Pe=[],Se=null;function Me(){try{localStorage.setItem($,JSON.stringify(E?.live?{live:xe}:{track:Qr(E),dir:E?.dir}))}catch{}}function rt(T,K){xe={voice:Se??xe.voice,tone:T,style:K},E=Xe,Me(),wt(),Ie||(Ie=!0),m(`\u26A1 live voice: ${xe.voice} \xB7 ${xe.tone} \u2014 V stops`),h("narr",`live config \u2014 ${xe.voice} \xB7 ${xe.tone}`),_e()}function at(T){Pe.length&&(ie=jt(H.querySelectorAll(".narr-row"),T,"narr-sel",{scroll:!1}))}function Et(){Pe[ie]?.commit()}function Nt(){pe==="custom"?pt("tones"):pe==="tones"?pt("voices"):pe==="charvideo"?pt("character"):(pe==="voices"||pe==="character")&&Ce.length?pt("tracks"):wt()}let Yt=!1;function Rt(T,K){U.setMode(T,K),wt(),m(T==="off"?"character off":T==="viseme"?`\u{1F3AD} character on \u2014 lips follow the narration${Ie?"":" \xB7 V starts it"}`:`\u{1F3A5} character video \u2014 ${U.engine} \xB7 ${U.portrait}${Ie?"":" \xB7 V starts narration"}`)}function wn(T){if(U.mode==="off"){m("turn the character on first \u2014 N \xB7 Character\u2026");return}U.setSolo(T),wt(),m(T?"\u{1F3AD} solo \u2014 the narrator has the stage \xB7 N brings the slides back":"solo off \u2014 the slides are back")}let Ht="Hey, this is Decklight",It=Ht,dt=null,St=new Map,ut=new Map,Ot=null,Gt=new Set;function xn(T){if(T===Ht)return St;if(T!==Ot){for(let K of ut.values())K.then(y=>URL.revokeObjectURL(y)).catch(()=>{});ut=new Map,Ot=T}return ut}let Wt=(T,K)=>`${T}|${K||""}`;function L(T,K,y,_=""){let S=Wt(K,_);if(!T.has(S)){let R=(async()=>{let Z=Date.now(),ue=await fetch(q,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:y,voice:K,style:_})});if(!ue.ok)throw new Error(String(ue.status));let Ve=await ue.blob(),it=parseFloat(ue.headers?.get?.("x-tts-cost")??"")||0;return it&&(C+=it),h("tts",`preview ${K}${_?" (styled)":""} \xB7 ${((Date.now()-Z)/1e3).toFixed(1)}s`+(it?` \xB7 ~$${it.toFixed(4)}`:"")),URL.createObjectURL(Ve)})();R.catch(()=>{T.get(S)===R&&T.delete(S)}),T.set(S,R)}return T.get(S)}async function vn(T,K,y){let _=`${y}|${T}`;if(Gt.has(_))return;Gt.add(_);let S=T===Ht,R=S?St:ut;try{h("narr",`preview prefetch ${y} (${S?"default":"custom"} sentence)`);for(let{voice:Z,style:ue}of K){if(!S&&Ot!==T)return;R.has(Wt(Z,ue))||await L(R,Z,T,ue).catch(()=>{})}h("narr",`preview prefetch ${y} complete`)}finally{Gt.delete(_)}}function Vt({voice:T,style:K="",prefetch:y},_){let S=It.trim();if(!S)return;let R=xn(S);_&&(_.textContent="\u2026"),L(R,T,S,K).then(Z=>{_?.isConnected&&(_.textContent="\u25B6"),dt??=new Audio,dt.src=Z,dt.play().catch(()=>{}),h("narr",`preview ${T}${K?" \xB7 styled":""}`),y==="voices"?vn(S,he.map(([ue])=>({voice:ue,style:""})),"voices"):y==="tones"&&vn(S,Re.map(ue=>({voice:T,style:be(ue)})),`tones:${T}`)}).catch(()=>{_?.isConnected&&(_.textContent="\u25B6"),m("live voice bridge unreachable \u2014 run: decklight tts"),h("narr",`preview ${T} failed`)})}function pt(T){pe=T;let K=H.querySelector(".narr-card");K.innerHTML="";let y=document.createElement("div");if(y.className="narr-head",K.appendChild(y),Pe=[],T==="tracks")y.textContent="narration",Ce.forEach(S=>Pe.push({text:S.manifest?`\u2601 ${S.label}`:`\u{1F50A} ${S.label} (${S.dir}/)`,flavor:S.manifest?re(S):"",cur:S===E,commit:()=>{E=S,Me(),wt(),m(`\u{1F50A} track: ${S.label}`),Ie&&ke().then(R=>{R&&_e()})}})),Pe.push({text:"\u26A1 Live voice \u2014 synthesize on the fly\u2026",cur:E?.live,commit:()=>pt("voices")}),Pe.push({text:"\u{1F9D1} Character \u2014 animated narrator\u2026",cur:U.mode!=="off",commit:()=>pt("character")});else if(T==="character"){y.textContent="character \u2014 an animated narrator lip-syncs the voice",Yt||(Yt=!0,U.probe().then(()=>{H&&pe==="character"&&pt("character")}));let S=U.bridgeInfo,R=S?.engines?.video??[];Pe.push({text:"Off",cur:U.mode==="off",commit:()=>Rt("off")}),Pe.push({text:"\u{1F3AD} 2D character \u2014 offline visemes",flavor:S?.engines?.viseme?"":"bridge offline \u2014 amplitude fallback",cur:U.mode==="viseme",commit:()=>Rt("viseme")}),Pe.push({text:`\u{1F3A5} Neural video \u2014 local GPU${R.length?"\u2026":""}`,flavor:R.length?"":"needs the bridge \u2014 run: decklight lipsync",cur:U.mode==="video",commit:()=>{R.length?pt("charvideo"):m("video needs wav2lip/sadtalker on the bridge \u2014 run: decklight lipsync")}}),U.mode!=="off"&&Pe.push({text:`${U.solo?"\u25C9":"\u25CB"} Solo \u2014 the narrator takes the stage`,flavor:"slide content steps aside",cur:U.solo,commit:()=>wn(!U.solo)})}else if(T==="charvideo"){y.textContent="neural video \u2014 pick engine \xB7 portrait";let S=U.bridgeInfo;for(let R of S?.engines?.video??[])for(let Z of S?.portraits?.length?S.portraits:["default"])Pe.push({text:`\u{1F3A5} ${R} \xB7 ${Z}`,cur:U.mode==="video"&&U.engine===R&&U.portrait===Z,commit:()=>Rt("video",{engine:R,portrait:Z})})}else if(T==="voices"){y.textContent="live voice \u2014 pick a voice \xB7 \u25B6 previews";let S=document.createElement("div");S.className="narr-preview-row";let R=document.createElement("input");R.className="narr-input narr-preview-text",R.value=It,R.placeholder="Preview sentence",R.setAttribute("aria-label","Preview sentence"),R.addEventListener("input",()=>{It=R.value}),R.addEventListener("keydown",ue=>{ue.key==="Escape"&&(Nt(),ue.preventDefault()),ue.stopPropagation()});let Z=document.createElement("button");Z.type="button",Z.className="narr-prev-btn narr-reset-btn",Z.textContent="\u21BA",Z.title="restore the default sentence",Z.setAttribute("aria-label","restore the default preview sentence"),Z.addEventListener("click",ue=>{ue.stopPropagation(),It=Ht,R.value=Ht}),S.append(R,Z),K.appendChild(S),de.forEach(([ue,Ve])=>Pe.push({text:ue,flavor:Ve,preview:{voice:ue,style:"",prefetch:"voices"},cur:E?.live&&xe.voice===ue,commit:()=>{if(Se=ue,j)return pt("tones");rt(me??"plain","")}}))}else if(T==="tones")y.textContent=`live voice \xB7 ${Se??xe.voice} \u2014 pick a tone \xB7 \u25B6 previews`,Re.forEach(S=>{let[R]=S,Z=be(S);Pe.push({text:R,preview:{voice:Se??xe.voice,style:Z,prefetch:"tones"},cur:E?.live&&xe.tone===R,commit:()=>rt(R,Z)})}),Pe.push({text:"Custom\u2026",cur:E?.live&&xe.tone==="Custom",commit:()=>pt("custom")});else{y.textContent=`live voice \xB7 ${Se??xe.voice} \u2014 type the delivery instruction \xB7 \u25B6 previews`;let S=document.createElement("div");S.className="narr-preview-row";let R=document.createElement("input");R.className="narr-input",R.value=xe.style,R.placeholder="Read in a \u2026",R.addEventListener("keydown",ue=>{ue.key==="Enter"?(At(),ue.preventDefault()):ue.key==="Escape"&&(Nt(),ue.preventDefault()),ue.stopPropagation()});let Z=document.createElement("button");Z.type="button",Z.className="narr-prev-btn narr-reset-btn",Z.textContent="\u25B6",Z.title="preview this delivery instruction",Z.setAttribute("aria-label","preview this delivery instruction"),Z.addEventListener("click",ue=>{ue.stopPropagation();let Ve=R.value.trim();Ve&&Vt({voice:Se??xe.voice,style:Ve},Z)}),S.append(R,Z),K.appendChild(S),setTimeout(()=>{R.focus(),R.select()},0),Pe=[],ie=0;return}Pe.forEach((S,R)=>{let Z=document.createElement("div");Z.className="narr-row"+(S.cur?" narr-cur":"");let ue=document.createElement("span");if(ue.className="narr-row-label",ue.textContent=S.text,S.flavor){let Ve=document.createElement("span");Ve.className="narr-flavor",Ve.textContent=S.flavor,ue.appendChild(Ve)}if(Z.appendChild(ue),S.preview){let Ve=document.createElement("button");Ve.type="button",Ve.className="narr-prev-btn",Ve.textContent="\u25B6",Ve.title=`preview ${S.preview.voice}`,Ve.setAttribute("aria-label",`preview ${S.preview.voice}`),Ve.addEventListener("click",it=>{it.stopPropagation(),Vt(S.preview,Ve)}),Z.appendChild(Ve)}Z.addEventListener("mouseenter",()=>at(R)),Z.addEventListener("click",()=>{at(R),Et()}),K.appendChild(Z)});let _=Pe.findIndex(S=>S.cur);at(Math.max(0,_)),H.querySelector(".narr-sel")?.scrollIntoView({block:"nearest"})}function At(){let T=H?.querySelector(".narr-input")?.value.trim();T&&rt("Custom",T)}function rn(T){if(H&&T===void 0)return wt();H||(H=document.createElement("div"),H.className="decklight-narr",H.innerHTML='<div class="narr-card" role="listbox" aria-label="Narration"></div>',kt(H,wt),r.appendChild(H)),pt(T??(Ce.length?"tracks":"voices")),$e().then(K=>{K&&H&&pe==="voices"&&pt("voices")})}function wt(){H?.remove(),H=null,Yt=!1}let $t=null,Ft="confirm",Mt=0;function sn(){let T=[];for(let K=1;K<=k.state.totalSlides;K++)Ee(K)&&T.push(K);return T}function hn(T){let K=Math.round(T/1e3);return K<60?`${K}s`:`${Math.floor(K/60)}m${String(K%60).padStart(2,"0")}s`}function Lt(T,K={}){Ft=T;let y=$t.querySelector(".narr-card");if(T==="confirm"){let _=K.total;y.innerHTML=`<div class="narr-head">record offline narration</div>
281
- <div class="rec-line">\u26A1 ${xe.voice} \xB7 ${xe.tone}</div>
282
- <div class="rec-line">${_} slide${_===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>`,y.querySelector(".narr-row").addEventListener("click",an)}else if(T==="progress"){let{done:_,total:S,elapsedMs:R}=K,Z=S?Math.round(_/S*100):0,ue=_?hn(R/_*(S-_)):"\u2026";y.innerHTML=`<div class="narr-head">recording\u2026</div>
285
- <div class="rec-bar"><div class="rec-bar-fill" style="width:${Z}%"></div></div>
286
- <div class="rec-line">${_} / ${S} slides \xB7 ${hn(R)} elapsed \xB7 ~${ue} left</div>
287
- <div class="rec-hint">Esc to cancel</div>`}else{let{saved:_,total:S,cancelled:R}=K;y.innerHTML=`<div class="narr-head">${R?"recording cancelled":"recording done"}</div>
288
- <div class="rec-line">${_} / ${S} slide${S===1?"":"s"} saved as slide-NN.wav to your downloads</div>
289
- <div class="rec-line">Point <code>narration.files</code> at that folder with <code>ext: 'wav'</code> to play them back without the bridge.</div>
290
- <div class="rec-hint">Enter or Esc to close</div>`}}let zt=.15,Jt=.35;function on(T,K){let y=T.reduce((R,Z)=>R+Z.length,0),_=new DataView(new ArrayBuffer(44)),S=(R,Z)=>{for(let ue=0;ue<Z.length;ue++)_.setUint8(R+ue,Z.charCodeAt(ue))};return S(0,"RIFF"),_.setUint32(4,36+y,!0),S(8,"WAVE"),S(12,"fmt "),_.setUint32(16,16,!0),_.setUint16(20,1,!0),_.setUint16(22,1,!0),_.setUint32(24,K,!0),_.setUint32(28,K*2,!0),_.setUint16(32,2,!0),_.setUint16(34,16,!0),S(36,"data"),_.setUint32(40,y,!0),new Blob([_.buffer,...T],{type:"audio/wav"})}let Qt=(T,K)=>new Uint8Array(2*Math.round(T*K));async function Bt(T,K){let y=k._records[T-1],_=y?y.groups.length:0,S=ze(T),R=[],Z=24e3;for(let ue=0;ue<=_;ue++){let Ve=s(S[ue]);for(let it=0;it<Ve.length;it++){let ht=await O(T,ue,it);if(K!==Mt)return null;if(!ht)continue;let mn=await ht.blob.arrayBuffer();R.length===0?Z=new DataView(mn).getUint32(24,!0)||24e3:R.push(Qt(Z,it===0?Jt:zt)),R.push(new Uint8Array(mn.slice(44)))}}return R.length?on(R,Z):null}async function xt(T,K){if(U.mode!=="viseme")return null;let y=k._records[T-1],_=y?y.groups.length:0,S=ze(T),R=[];try{for(let Z=0;Z<=_;Z++){let ue=s(S[Z]);for(let Ve=0;Ve<ue.length;Ve++){let it=await U.ensureTimeline(o(T,Z,Ve),O(T,Z,Ve),ue[Ve]);if(K!==Mt)return null;it&&R.push({timeline:it,gap:R.length?Ve===0?Jt:zt:0})}}}catch{return h("lipsync",`slide ${T}: viseme sidecar skipped (bridge unreachable)`),null}return R.length?fi(R):null}async function an(){let T=sn(),K=++Mt,y=Date.now(),_=0,S=0;Lt("progress",{done:_,total:T.length,elapsedMs:0});for(let R of T){if(K!==Mt)return;try{let Z=await Bt(R,K);if(K!==Mt)return;if(Z){let ue=URL.createObjectURL(Z);M(ue,`slide-${String(R).padStart(2,"0")}.wav`),setTimeout(()=>URL.revokeObjectURL(ue),5e3),S++;let Ve=await xt(R,K);if(K!==Mt)return;if(Ve){let it=URL.createObjectURL(new Blob([JSON.stringify(Ve)],{type:"application/json"}));M(it,`slide-${String(R).padStart(2,"0")}.visemes.json`),setTimeout(()=>URL.revokeObjectURL(it),5e3)}}}catch{m(`slide ${R}: recording failed`)}_++,K===Mt&&Lt("progress",{done:_,total:T.length,elapsedMs:Date.now()-y})}K===Mt&&Lt("done",{saved:S,total:T.length})}function kn(){if(!E?.live){m("live voice only \u2014 pick a voice with N first");return}$t||($t=document.createElement("div"),$t.className="decklight-narr decklight-record",$t.innerHTML='<div class="narr-card" role="dialog" aria-label="Record offline narration"></div>',kt($t,bt),r.appendChild($t),Lt("confirm",{total:sn().length}))}function bt(){Mt++,$t?.remove(),$t=null}return w.register({isOpen:()=>!!$t,close:bt,keydown(T){if(T.key==="Escape")bt();else if(T.key==="Enter")Ft==="confirm"?an():Ft!=="progress"&&bt();else return!1;return!0}}),w.register({isOpen:()=>!!H,close:wt,keydown(T){if(pe==="custom")return T.key==="Enter"?(At(),!0):T.key==="Escape"?(Nt(),!0):!1;switch(T.key){case"ArrowDown":at(ie+1);break;case"ArrowUp":at(ie-1);break;case"Enter":Et();break;case"Escape":Nt();break;case"n":case"N":wt();break;default:return!1}return!0}}),{character:U,toggleNarration:Qe,toggleNarrPause:g,changeNarrRate:J,toggleCaptions:te,openPicker:rn,openRecordDialog:kn,applySolo:wn,notesSegs:ze,status:()=>({narrating:Ie,paused:ye,rate:F,captionsOn:Ye,track:E,live:!!E?.live,voice:xe.voice,tone:xe.tone,hasTracks:Ce.length>0,spend:C})}}ae();le();function jc(r,a){let l=[];for(let d=0;d<r;d+=a){let u=[];for(let m=d;m<r&&m<d+a;m++)u.push(m);l.push(u)}return l}function xi(r,a,l){let d=r.ownerDocument,u=h=>{let w=d.createElement("div");return w.className=h,w},m=h=>{let w=u("print-slot"),k=u("decklight-stage print-slide");return k.appendChild(h),w.appendChild(k),w};if(l==="handout")for(let h of jc(a.length,3)){let w=u("print-page print-handout");for(let k of h){let A=u("print-row");A.appendChild(m(a[k])),A.appendChild(u("print-notelines")),w.appendChild(A)}r.appendChild(w)}else a.forEach(h=>{let w=u("print-page print-notes-page"),k=u("print-notes"),A=h.querySelector("aside.notes");A&&(k.innerHTML=A.innerHTML),w.appendChild(m(h)),w.appendChild(k),r.appendChild(w)});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)}ae();le();ae();le();function Kc(r,a,l,d){let u=d||1;return{x:(r-l.left)/u,y:(a-l.top)/u}}function Wc(r,a,l=300){return r.filter(d=>a-d.t<l)}function vi(r,a){let l=a.querySelector(":scope > .decklight-stage"),d=null,u=null,m=null,f=[],h=null,w=[],k=null,A=0,I=()=>getComputedStyle(a).getPropertyValue("--accent").trim()||"#fff",M=be=>Kc(be.clientX,be.clientY,l.getBoundingClientRect(),r._scale);function C(){if(!u)return;let be=window.devicePixelRatio||1,Ce=a.getBoundingClientRect(),Xe=l.getBoundingClientRect(),xe=r._scale||1;u.setTransform(1,0,0,1,0,0),u.clearRect(0,0,d.width,d.height),u.setTransform(be*xe,0,0,be*xe,(Xe.left-Ce.left)*be,(Xe.top-Ce.top)*be),u.lineCap=u.lineJoin="round",u.lineWidth=3.5;for(let E of h?[...f,h]:f)if(E.points.length){u.strokeStyle=E.color,u.beginPath(),u.moveTo(E.points[0].x,E.points[0].y);for(let Ie of E.points)u.lineTo(Ie.x,Ie.y);u.stroke()}if(m==="laser"&&k){let E=I(),Ie=performance.now();u.fillStyle=E;for(let qe of w){let De=1-(Ie-qe.t)/300;u.globalAlpha=De*.4,u.beginPath(),u.arc(qe.x,qe.y,3+4*De,0,Math.PI*2),u.fill()}u.globalAlpha=1,u.shadowColor=E,u.shadowBlur=22,u.beginPath(),u.arc(k.x,k.y,7,0,Math.PI*2),u.fill(),u.shadowBlur=0}}function $(){A=0,w=Wc(w,performance.now()),C(),w.length&&(A=requestAnimationFrame($))}let q=()=>{A||(A=requestAnimationFrame($))};function he(be){if(!(m!=="pen"||be.button>0)){try{d.setPointerCapture(be.pointerId)}catch{}h={color:I(),points:[M(be)]},C(),be.preventDefault()}}function oe(be){m==="pen"&&h?(h.points.push(M(be)),C()):m==="laser"&&(k=M(be),w.push({...k,t:performance.now()}),q())}function de(){h&&(f.push(h),h=null)}function j(){let be=a.getBoundingClientRect(),Ce=window.devicePixelRatio||1;d.width=Math.max(1,Math.round(be.width*Ce)),d.height=Math.max(1,Math.round(be.height*Ce)),C()}function me(){d||(d=document.createElement("canvas"),d.className="decklight-annotate",d.setAttribute("aria-hidden","true"),a.appendChild(d),u=d.getContext("2d"),d.addEventListener("pointerdown",he),d.addEventListener("pointermove",oe),d.addEventListener("pointerup",de),d.addEventListener("pointercancel",de),d.addEventListener("touchstart",be=>be.stopPropagation(),{passive:!0}),j(),new ResizeObserver(()=>{j(),requestAnimationFrame(C)}).observe(a))}function Te(be="pen"){return m=m===be?null:be,m&&me(),d&&(d.classList.toggle("tool-pen",m==="pen"),d.classList.toggle("tool-laser",m==="laser")),h&&(f.push(h),h=null),m!=="laser"&&(w=[],k=null,u&&C()),m}function $e(){f=[],h=null,w=[],k=null,u&&C()}function Re(be){me(),f.push({color:I(),points:be.map(Ce=>({x:Ce.x,y:Ce.y}))}),C()}return r.on("slide",$e),{toggle:Te,laser:()=>Te("laser"),clear:$e,stroke:Re,get tool(){return m},get active(){return m!==null}}}function ki({root:r,printMode:a,toast:l,debugLog:d,overlays:u,instance:m,narration:f,downloadFromUrl:h,setProgressBar:w}){let k="decklight-clock:"+location.pathname,A=!1;try{A=localStorage.getItem(k)==="1"}catch{}let I=null,M=null,C=null,$=!1,q=J=>String(J).padStart(2,"0");function he(J){let U=Math.floor(J/1e3),fe=Math.floor(U/3600);return(fe?fe+":":"")+q(Math.floor(U/60)%60)+":"+q(U%60)}function oe(){if(!I)return;let J=new Date;I.querySelector(".clk-time").textContent=q(J.getHours())+":"+q(J.getMinutes()),I.querySelector(".clk-elapsed").textContent="+"+he(C==null?0:Date.now()-C)}function de(){I=document.createElement("div"),I.className="decklight-clock",I.innerHTML='<span class="clk-time"></span><span class="clk-elapsed"></span>',r.appendChild(I),oe(),M=setInterval(oe,1e3)}function j(){A=!A;try{localStorage.setItem(k,A?"1":"0")}catch{}A?de():(clearInterval(M),M=null,I?.remove(),I=null),l(`clock ${A?"on":"off"}`),d("nav",`clock ${A?"on":"off"}`)}m.on("ready",()=>{$=!0});let me=()=>{!$||C!=null||(C=Date.now(),oe())};m.on("slide",me),m.on("build",me),m.toggleClock=j,A&&!a&&de();let Te="decklight-progress:"+location.pathname,$e=!1;try{$e=localStorage.getItem(Te)==="1"}catch{}let Re=null;function be(){Re=document.createElement("div"),Re.className="decklight-progress",Re.innerHTML='<div class="bar"></div>',r.appendChild(Re),w(Re.querySelector(".bar")),m._updateChrome()}function Ce(){$e=!$e;try{localStorage.setItem(Te,$e?"1":"0")}catch{}$e?be():(Re?.remove(),Re=null,w(null)),l(`progress bar ${$e?"on":"off"}`),d("nav",`progress bar ${$e?"on":"off"}`)}m.toggleProgress=Ce,$e&&!a&&be();let Xe=null;a||(Xe=vi(m,r),m.annotate=Xe);function xe(J){if(!Xe)return;let U=J==="laser"?Xe.laser():Xe.toggle();l(U==="pen"?"pen on \u2014 drag to draw \xB7 \u232B clears \xB7 W off":U==="laser"?"laser on \u2014 \u21E7W off":"ink off"),d("nav",`ink ${U??"off"}`)}function E(){return(m._sections||[]).map((J,U)=>({n:U+1,title:J.querySelector("h1, h2, h3")?.textContent.trim()||`Slide ${U+1}`,segs:f.notesSegs(U+1).filter(Boolean)}))}function Ie(J){let U=(document.title||"Deck").trim(),fe=J?[`# ${U} \u2014 transcript`,""]:[`${U} \u2014 transcript`,""];for(let{n:Ee,title:ze,segs:Ne}of E())if(Ne.length){fe.push(J?`## ${Ee}. ${ze}`:`${Ee}. ${ze}`,"");for(let s of Ne)fe.push(s,"")}return fe.join(`
291
- `)}function qe(J){let U=J==="md",fe=URL.createObjectURL(new Blob([Ie(U)],{type:U?"text/markdown":"text/plain"})),Ee=(location.pathname.split("/").pop()||"deck").replace(/\.html?$/i,"");h(fe,`${Ee}-transcript.${U?"md":"txt"}`),setTimeout(()=>URL.revokeObjectURL(fe),5e3),d("narr",`transcript exported (.${U?"md":"txt"})`)}let De=null;function F(){if(De){De.remove(),De=null;return}De=document.createElement("div"),De.className="decklight-narr decklight-transcript";let J=document.createElement("div");J.className="narr-card";let U=document.createElement("div");U.className="narr-head",U.textContent="transcript \u2014 the deck\u2019s spoken notes \xB7 Esc closes";let fe=document.createElement("div");fe.className="tr-actions";for(let[Ee,ze]of[["\u2B07 export .txt","txt"],["\u2B07 export .md","md"]]){let Ne=document.createElement("button");Ne.type="button",Ne.className="narr-prev-btn",Ne.textContent=Ee,Ne.addEventListener("click",()=>qe(ze)),fe.appendChild(Ne)}J.append(U,fe);for(let{n:Ee,title:ze,segs:Ne}of E()){if(!Ne.length)continue;let s=document.createElement("div");s.className="tr-slide";let o=document.createElement("div");o.className="tr-title",o.textContent=`${Ee} \xB7 ${ze}`,o.title="jump to this slide",o.addEventListener("click",()=>{F(),m.goto(Ee,0,{force:!0})}),s.appendChild(o);for(let O of Ne){let Be=document.createElement("p");Be.className="tr-seg",Be.textContent=O,s.appendChild(Be)}J.appendChild(s)}De.appendChild(J),kt(De,F),r.appendChild(De)}return m.transcript={open:F,text:()=>Ie(!1),markdown:()=>Ie(!0)},u.register({isOpen:()=>!!De,close:F,keydown:J=>J.key==="Escape"&&(F(),!0)}),{toggleClock:j,toggleProgress:Ce,toggleInk:xe,toggleTranscript:F,get annotator(){return Xe},status:()=>({clockOn:A,progressOn:$e})}}ae();le();var Vc=["data-background-image","data-background-video","data-background-poster","data-background-size","data-background-position","data-background-dim"];function Zc(r){let a=r["data-background-image"]||null,l=r["data-background-video"]||null;if(!a&&!l)return null;let d=parseFloat(r["data-background-dim"]);return{image:a,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 Xc=r=>`url("${String(r).replace(/["\\]/g,"\\$&")}")`;function Yc(r){let a={};for(let l of Vc){let d=r.getAttribute(l);d!==null&&(a[l]=d)}return a}function Ei(r,{printMode:a=!1}={}){r.forEach(l=>{let d=Zc(Yc(l)),u=l.querySelector(":scope > .slide-bg");if(!d){u?.remove();return}let m=JSON.stringify(d)+(a?"\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||(a?d.poster:null);if(u.style.backgroundImage=f?Xc(f):"",d.video&&!a){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)})}ae();le();ae();le();var Jc="npx decklight author";function Qc(r){let a=r||"";try{a=decodeURIComponent(a)}catch{}/^\/[A-Za-z]:/.test(a)&&(a=a.slice(1));let l=a.lastIndexOf("/");return{dir:l>0?a.slice(0,l):"",file:l>=0?a.slice(l+1):a}}function tn(r,a={}){let{protocol:l="",pathname:d=""}=a,{dir:u,file:m}=Qc(d),f=/\.html?$/i.test(m)?m:"<deck.html>",h=l==="file:"&&u?`from ${u}, `:"";return`${r} needs author mode: ${h}run ${Jc} ${f}, then reopen the URL it prints`}function Si({root:r,config:a,params:l,printMode:d,toast:u,debugLog:m,overlays:f,instance:h,notesSegs:w,dismissOthers:k}){let A=!1,I="",M=[],C=null,$=[],q=null;if(!d&&!l.has("embedded")){let g=a.edit?.url?[a.edit.url]:/^https?:$/.test(location.protocol)?[""]:["http://127.0.0.1:8788"];(async()=>{for(let G of g)try{let B=await fetch(G+"/edit/ping");if(!B.ok)continue;let X=await B.json();if(!X?.ok)continue;let Y=decodeURIComponent(location.pathname.split("/").pop()||"");if(Y&&X.name&&Y!==X.name){m("edit",`server edits ${X.name}, this deck is ${Y} \u2014 not wiring up`);continue}I=G,A=!0,M=Array.isArray(X.agents)?X.agents:[],C=typeof X.preferredAgent=="string"?X.preferredAgent:null,$=Array.isArray(X.wizards)?X.wizards:[],q=X.agentBusy||null,q&&u(`${q.agent} is editing the deck\u2026`,2e3);let ge=new EventSource(G+"/edit/events");ge.onmessage=()=>location.reload(),ge.addEventListener("agent",V=>{try{let ne=JSON.parse(V.data);if(ne.state==="start")q=ne,u(`\u{1F916} ${ne.agent} is editing the deck\u2026`,2200),m("agent",`${ne.agent} start: ${(ne.prompt||"").slice(0,80)}`);else if(ne.state==="done"){q=null;let Fe=ne.ok?"":ne.error?` \u2014 ${ne.error}`:` (exit ${ne.code})`;u(ne.changed?`\u{1F916} ${ne.agent} edited the deck \u2014 Z undoes${Fe}`:`\u{1F916} ${ne.agent} finished \u2014 no changes${Fe}`,3e3),m("agent",`${ne.agent} done ok=${ne.ok} changed=${ne.changed}${Fe}`)}}catch{}}),m("edit",`live reload connected${G?` (${G})`:""}`+(M.length?` \xB7 agents: ${M.map(V=>V.name).join(", ")}`:""));return}catch{}await he()})()}async function he(){let g=/^https?:$/.test(location.protocol)?"":"http://127.0.0.1:8790";try{let G=await fetch(g+"/present/ping");if(!G.ok)return;let B=await G.json();if(!B?.ok||!B.present)return;let X=decodeURIComponent(location.pathname.split("/").pop()||"");if(X&&B.name&&X!==B.name){m("present",`server presents ${B.name}, this deck is ${X} \u2014 not wiring up`);return}h.__remoteQr=B.remote?`${g||location.origin}/remote/qr.svg`:null,new EventSource(g+"/present/events").addEventListener("remote",V=>{try{let{key:ne}=JSON.parse(V.data);ne==="next"?h.next():ne==="prev"&&h.prev()}catch{}});let ge=()=>{fetch(g+"/remote/pos",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({i:h.state.slide,n:h.state.totalSlides})}).catch(()=>{})};h.on("slide",ge),h.on("build",ge),ge(),m("present",`remote connected${g?` (${g})`:""} \u2014 no edit surface`)}catch{}}async function oe(g){if(!A){u(tn(g,location),3200);return}try{let G=await fetch(I+"/edit/"+g,{method:"POST"}),B=await G.json().catch(()=>({}));if(!G.ok){u(B.error||`${g} failed`);return}u(`${g} \u2014 ${B.undo} back \xB7 ${B.redo} forward`),m("edit",`${g} \u2192 ${B.undo} back, ${B.redo} forward`)}catch{u(`${g} failed \u2014 is the dev server still up?`,2200)}}let de=null;function j(){if(de){de.remove(),de=null;return}if(!A){u(tn("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(q){u(`${q.agent} is still working on the last ask`,2200);return}de=document.createElement("div"),de.className="decklight-narr decklight-editor";let g=document.createElement("div");g.className="narr-card";let G=document.createElement("div");G.className="narr-head",G.textContent="ask an agent \u2014 edits the deck file \xB7 \u2318\u23CE sends \xB7 Esc closes";let B=document.createElement("textarea");B.className="narr-input edit-notes",B.placeholder=`e.g. "make slide ${h.state.slide} a split layout with the diagram on the left"`,B.spellcheck=!1;let X=C&&M.some(ne=>ne.name===C)?C:M[0].name,Y=document.createElement("div");if(Y.className="tr-actions",M.length>1){let ne=document.createElement("select");ne.className="narr-prev-btn";for(let Fe of M){let Je=document.createElement("option");Je.value=Fe.name,Je.textContent=Fe.label,ne.appendChild(Je)}ne.value=X,ne.addEventListener("change",()=>{X=ne.value,C=ne.value,fetch(I+"/edit/agent/prefer",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({agent:ne.value})}).catch(()=>{}),m("agent",`preferred agent \u2192 ${ne.value}`)}),ne.addEventListener("keydown",Fe=>Fe.stopPropagation()),Y.appendChild(ne)}let ge=async()=>{let ne=B.value.trim();if(ne)try{let Fe=await fetch(I+"/edit/agent",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({prompt:ne,agent:X})}),Je=await Fe.json().catch(()=>({}));if(!Fe.ok)throw new Error(Je.error||Fe.status);j()}catch(Fe){u(`ask failed: ${String(Fe.message||Fe).slice(0,60)}`,2200)}};B.addEventListener("keydown",ne=>{ne.key==="Enter"&&(ne.metaKey||ne.ctrlKey)?(ge(),ne.preventDefault()):ne.key==="Escape"&&(j(),ne.preventDefault()),ne.stopPropagation()});let V=document.createElement("button");V.type="button",V.className="narr-prev-btn",V.textContent="\u{1F916} send to agent",V.addEventListener("click",ge),Y.appendChild(V),g.append(G,B,Y),de.appendChild(g),kt(de,j),r.appendChild(de),setTimeout(()=>B.focus(),0)}let me=null;function Te(){if(me){me.remove(),me=null;return}let g=h.state.slide;if(!A){u(tn("editing notes",location),3200);return}me=document.createElement("div"),me.className="decklight-narr decklight-editor";let G=document.createElement("div");G.className="narr-card";let B=document.createElement("div");B.className="narr-head",B.textContent=`edit notes \u2014 slide ${g} \xB7 \u2318\u23CE saves \xB7 Esc closes`;let X=document.createElement("textarea");X.className="narr-input edit-notes",X.value=w(g).filter((ne,Fe,Je)=>ne||Fe<Je.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(`
292
316
 
293
317
  \u27E8CLICK\u27E9
294
318
 
295
- `),X.spellcheck=!1;let Y=async()=>{try{let ne=await fetch(I+"/edit/notes",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:g,text:X.value})});if(!ne.ok)throw new Error(await ne.text());m("edit",`notes saved \u2014 slide ${g}`),u("notes saved \u2014 reloading")}catch(ne){u(`save failed: ${String(ne.message||ne).slice(0,60)}`)}};X.addEventListener("keydown",ne=>{ne.key==="Enter"&&(ne.metaKey||ne.ctrlKey)?(Y(),ne.preventDefault()):ne.key==="Escape"&&(Te(),ne.preventDefault()),ne.stopPropagation()});let ge=document.createElement("div");ge.className="tr-actions";let V=document.createElement("button");V.type="button",V.className="narr-prev-btn",V.textContent="\u{1F4BE} save to file",V.addEventListener("click",Y),ge.appendChild(V),G.append(B,X,ge),me.appendChild(G),kt(me,Te),r.appendChild(me),setTimeout(()=>X.focus(),0)}let $e=["fade","fade-up","fade-down","zoom","pop","draw","highlight"],Re=!1,be=null,Ce=[],Xe=0,xe="main",E=null;function Ie(){if(!A){u(tn("editing an element",location),3200);return}Re=!Re,De(),u(Re?"element edit mode on \u2014 right-click a slide element":"element edit mode off",2200)}function qe(g,G){let B=G;for(;B&&B!==g&&B.parentElement!==g;)B=B.parentElement;return B&&B!==g?B:null}r.addEventListener("contextmenu",g=>{if(!Re)return;let G=g.target.closest("section"),B=G?h._sections.indexOf(G)+1:0;if(!G||!B)return;if(g.preventDefault(),G.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 X=qe(G,g.target),Y=X?[...G.children].indexOf(X):null;k?.(),U(g.clientX,g.clientY,{sec:G,slide:B,index:Y})});function De(){be?.remove(),be=null,xe="main"}function F(){let g=be.querySelector(".cm-list");g.textContent="";let G=[];if(xe==="effects"){G.push({label:"\u2190 back",back:!0,run:()=>{xe="main",F()}});for(let B of $e)G.push({label:B,run:()=>Ee(B)});G.push({label:"none (instant)",run:()=>Ee("none")}),G.push({label:"remove effect",run:()=>Ee(null)})}else E.index===null?G.push({label:"Edit speaker notes",run:()=>{De(),Te()}}):(G.push({label:"Edit speaker notes",run:()=>{De(),Te()}}),G.push({label:"Remove element",run:fe}),G.push({label:"Edit content (HTML)",run:()=>{De(),s(E)}}),G.push({label:"Add text effect \u25B8",run:()=>{xe="effects",F()}}));Ce=G,G.forEach((B,X)=>{let Y=document.createElement("div");Y.className="cm-row"+(B.back?" cm-back":""),Y.setAttribute("role","option"),Y.textContent=B.label,Y.addEventListener("mouseenter",()=>J(X,!1)),Y.addEventListener("click",B.run),g.appendChild(Y)}),J(0,!1)}function J(g,G){let B=be.querySelectorAll(".cm-row");B.length&&(Xe=jt(B,g,"cm-selected",{scroll:G}))}function U(g,G,B){E=B,xe="main",be=document.createElement("div"),be.className="decklight-ctxmenu";let X=document.createElement("div");X.className="cm-card";let Y=document.createElement("div");Y.className="cm-list",Y.setAttribute("role","listbox"),Y.setAttribute("aria-label","Element edit menu"),X.appendChild(Y),be.appendChild(X),r.appendChild(be),F();let ge=r.getBoundingClientRect(),V=Math.min(g-ge.left,ge.width-X.offsetWidth-4),ne=Math.min(G-ge.top,ge.height-X.offsetHeight-4);X.style.left=Math.max(4,V)+"px",X.style.top=Math.max(4,ne)+"px",kt(be,De)}async function fe(){let{slide:g,index:G}=E;De();try{let B=await fetch(I+"/edit/element/remove",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:g,index:G})}),X=await B.json().catch(()=>({}));if(!B.ok)throw new Error(X.error||B.status);u(X.changed?"element removed \u2014 reloading":"nothing to remove")}catch(B){u(`remove failed: ${String(B.message||B).slice(0,60)}`,2200)}}async function Ee(g){let{slide:G,index:B}=E;De();try{let X=await fetch(I+"/edit/element/effect",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:G,index:B,effect:g})}),Y=await X.json().catch(()=>({}));if(!X.ok)throw new Error(Y.error||X.status);u(g===null?"effect removed \u2014 reloading":`effect: ${g} \u2014 reloading`)}catch(X){u(`effect save failed: ${String(X.message||X).slice(0,60)}`,2200)}}let ze=null;function Ne(){ze?.remove(),ze=null}function s({slide:g,index:G}){ze=document.createElement("div"),ze.className="decklight-narr decklight-editor";let B=document.createElement("div");B.className="narr-card";let X=document.createElement("div");X.className="narr-head",X.textContent=`edit content \u2014 slide ${g}, element ${G} \xB7 \u2318\u23CE saves \xB7 Esc closes`;let Y=document.createElement("textarea");Y.className="narr-input edit-notes",Y.value="loading\u2026",Y.disabled=!0,Y.spellcheck=!1;let ge=async()=>{try{let Fe=await fetch(I+"/edit/element/content",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:g,index:G,html:Y.value})});if(!Fe.ok)throw new Error(await Fe.text());u("element content saved \u2014 reloading")}catch(Fe){u(`save failed: ${String(Fe.message||Fe).slice(0,60)}`)}};Y.addEventListener("keydown",Fe=>{Fe.key==="Enter"&&(Fe.metaKey||Fe.ctrlKey)?(ge(),Fe.preventDefault()):Fe.key==="Escape"&&(Ne(),Fe.preventDefault()),Fe.stopPropagation()});let V=document.createElement("div");V.className="tr-actions";let ne=document.createElement("button");ne.type="button",ne.className="narr-prev-btn",ne.textContent="\u{1F4BE} save to file",ne.addEventListener("click",ge),V.appendChild(ne),B.append(X,Y,V),ze.appendChild(B),kt(ze,Ne),r.appendChild(ze),(async()=>{try{let Fe=await fetch(`${I}/edit/element/source?slide=${g}&index=${G}`),Je=await Fe.json().catch(()=>({}));if(!Fe.ok||!Je.ok)throw new Error(Je.error||Fe.status);Y.value=Je.html,Y.disabled=!1,Y.focus()}catch(Fe){Y.value="",u(`could not read the element's source: ${String(Fe.message||Fe).slice(0,60)}`,2600)}})()}f.register({isOpen:()=>!!be,close:De,keydown(g){switch(g.key){case"ArrowDown":J(Xe+1,!0);break;case"ArrowUp":J(Xe-1,!0);break;case"Enter":Ce[Xe]?.run();break;case"Escape":De();break;default:return!1}return!0}}),f.register({isOpen:()=>!!ze,close:Ne,keydown:g=>g.key==="Escape"&&(Ne(),!0)});let o=null,O=[],Be=0,P=null;function Ue(g,G){G&&(g.src=`${I}/edit/at?ref=${encodeURIComponent(G.hash)}&embedded`)}function nt(g,G){let B=[...o.querySelectorAll(".tp-row")];if(!B.length)return;Be=jt(B,g,"tp-selected");let X=O[Be];o.querySelector(".tp-caption").textContent=X?`${X.hash} \xB7 ${X.when} \xB7 ${X.subject}`:"";let Y=o.querySelector("iframe");clearTimeout(P),G?Ue(Y,X):P=setTimeout(()=>Ue(Y,X),60)}async function W(){if(o)return Ae();if(!A)return u(tn("restoring a version",location),3200);let g=[];try{let X=await(await fetch(I+"/edit/history")).json();if(!X.ok)return u(`restore: ${X.error}`,3e3);g=X.entries||[]}catch{return u("restore: could not read the deck history",3e3)}if(!g.length)return u("restore: git has no record of this deck yet",3e3);k(),O=g,o=document.createElement("div"),o.className="decklight-theme-picker decklight-finder decklight-restore",o.innerHTML='<div class="tp-panel"><div class="tp-side"><div class="tp-filter">Restore a version \u2014 \u2191\u2193 to browse, \u23CE to restore</div><div class="tp-list" role="listbox" aria-label="Deck history"></div></div><div class="tp-preview"><iframe title="Version preview"></iframe><div class="tp-caption"></div></div></div>';let G=o.querySelector(".tp-list");O.forEach((B,X)=>{let Y=document.createElement("div");Y.className="tp-row",Y.setAttribute("role","option");let ge=document.createElement("span");ge.className="rs-hash",ge.textContent=B.hash;let V=document.createElement("span");V.className="rs-when",V.textContent=B.when,Y.append(ge,` ${B.subject} `,V),Y.addEventListener("click",()=>{nt(X,!0),Q()}),G.appendChild(Y)}),kt(o,Ae),r.appendChild(o),nt(0,!0)}function Ae(){clearTimeout(P),o?.remove(),o=null}async function Q(){let g=O[Be];if(g){Ae();try{let B=await(await fetch(I+"/edit/restore",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ref:g.hash})})).json();if(!B.ok)return u(`restore failed: ${B.error}`,3e3);if(!B.changed)return u(`already at ${g.hash}`,2e3);u(`restored ${g.hash} \u2014 Z takes it back`,2600)}catch{u("restore failed: the edit server did not answer",3e3)}}}f.register({isOpen:()=>!!me,close:Te,keydown:g=>g.key==="Escape"&&(Te(),!0)}),f.register({isOpen:()=>!!de,close:j,keydown:g=>g.key==="Escape"&&(j(),!0)}),f.register({isOpen:()=>!!o,close:Ae,keydown(g){switch(g.key){case"ArrowDown":nt(Be+1,!1);break;case"ArrowUp":nt(Be-1,!1);break;case"Enter":Q();break;case"Escape":Ae();break;default:return!1}return!0}});let ye=null;function x(){ye?.remove(),ye=null}async function we(g){if(ye){x();return}if(!A){u(tn("configuring an engine",location),3200);return}let G,B;try{let _e=await fetch(`${I}/edit/wizard?engine=${encodeURIComponent(g)}`),Le=await _e.json().catch(()=>({}));if(!_e.ok||!Le?.schema){u(Le.error||`no wizard for ${g}`,3200);return}if(typeof Le.from!="string"||!Le.from||typeof Le.provenance?.askedBy!="string"||typeof Le.provenance?.sentTo!="string"){u("the server did not say who is asking for these answers \u2014 not prompting",3200);return}G=Le.schema,B=Le.provenance}catch{u("the author server did not answer",2600);return}k?.(),ye=document.createElement("div"),ye.className="decklight-narr decklight-editor";let X=document.createElement("div");X.className="narr-card";let Y=document.createElement("div");Y.className="narr-head",Y.textContent=`${G.title} \u2014 \u2318\u23CE saves \xB7 Esc closes`;let ge=document.createElement("div");ge.className="wiz-src";let V=document.createElement("div");V.textContent=B.askedBy;let ne=document.createElement("div");ne.textContent=B.sentTo,ge.append(V,ne),X.append(Y,ge);let Fe=new Map;for(let _e of G.fields){let Le=document.createElement("label");Le.className="tr-actions";let Qe=document.createElement("span");Qe.textContent=_e.required?`${_e.label} *`:_e.label;let Oe;if(_e.type==="choice"){Oe=document.createElement("select");for(let Ye of _e.options){let ct=document.createElement("option");ct.value=Ye,ct.textContent=Ye,Oe.append(ct)}_e.default&&(Oe.value=_e.default)}else _e.type==="boolean"?(Oe=document.createElement("input"),Oe.type="checkbox",Oe.checked=_e.default===!0):(Oe=document.createElement("input"),Oe.type=_e.type==="secret"?"password":"text",Oe.autocomplete=_e.type==="secret"?"off":"on",Oe.spellcheck=!1,_e.default!==void 0&&(Oe.value=String(_e.default)));Oe.className="narr-input",Fe.set(_e.name,{field:_e,input:Oe}),Le.append(Qe,Oe),X.append(Le)}let Je=document.createElement("div");Je.className="narr-head";let re=document.createElement("button");re.className="narr-prev-btn",re.textContent="save";let ke=document.createElement("div");ke.className="tr-actions",ke.append(re),X.append(ke,Je),ye.append(X),r.append(ye),Fe.values().next().value?.input.focus();async function He(){let _e={};for(let[Le,{field:Qe,input:Oe}]of Fe){let Ye=Qe.type==="boolean"?Oe.checked:Oe.value;Ye!==""&&Ye!==void 0&&(_e[Le]=Ye)}re.disabled=!0,Je.textContent="checking\u2026";try{let Le=await fetch(`${I}/edit/wizard`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({engine:G.engine,answers:_e})}),Qe=await Le.json().catch(()=>({}));if(!Le.ok){Je.textContent=Qe.state==="unreachable"?`could not reach it \u2014 ${Qe.error??"try again"}`:Qe.state==="prerequisite"?`not ready on this machine \u2014 ${Qe.error??"something it needs is missing"}`:`not accepted \u2014 ${Qe.error??"check the answers"}`,re.disabled=!1;return}m("wizard",`${G.engine} configured: ${JSON.stringify(Qe.stored)}`),x(),u(`${G.title} configured`,2200)}catch(Le){Je.textContent=`could not reach the author server \u2014 ${String(Le.message||Le).slice(0,50)}`,re.disabled=!1}}re.addEventListener("click",He),ye.addEventListener("keydown",_e=>{_e.key==="Enter"&&(_e.metaKey||_e.ctrlKey)&&(_e.preventDefault(),He())})}return f.register({isOpen:()=>!!ye,close:x,keydown:g=>g.key==="Escape"&&(x(),!0)}),{deckHistory:oe,toggleEditor:Te,toggleAgentAsk:j,toggleElementEdit:Ie,elementEditOn:()=>Re,wizard:we,wizards:()=>$.slice(),restore:{open:W,close:Ae,list:()=>O.slice()},available:()=>A,base:()=>I}}ae();le();var jn=[{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"}],Ai="decklight-onboarded",es="decklight-tips-seen",_i="decklight-tips-off";function ts(r){try{return localStorage.getItem(r)}catch{return null}}function yr(r,a){try{localStorage.setItem(r,a)}catch{}}function Ti({root:r,printMode:a,params:l,toast:d,debugLog:u,overlays:m,deck:f}){let h=l.has("embedded"),w=a||h,k=null;function A(){k&&(k.remove(),k=null,yr(Ai,"1"),u?.("nav","welcome dismissed"))}function I(){k||a||(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">
296
321
  <h3>Welcome to Decklight</h3>
297
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>
298
323
  <table>
@@ -306,17 +331,17 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Ee=F,fe=J),U===void 0&
306
331
  <span>Press any key to dismiss \u2014 reopen anytime from the <code>/</code> palette.</span>
307
332
  <button type="button" class="wel-go">Got it</button>
308
333
  </div>
309
- </div>`,k.addEventListener("click",j=>{j.stopPropagation(),A()}),kt(k,A),r.appendChild(k),u?.("nav","welcome shown"))}m.register({isOpen:()=>!!k,close:A,keydown:()=>(A(),!0)});function M(){return ts(_i)!=="1"}function C(){try{let j=JSON.parse(ts(es)||"[]");return new Set(Array.isArray(j)?j:[])}catch{return new Set}}function $(){let j=C();return jn.find(me=>!j.has(me.id))||null}function q(){let j=$();if(!j)return null;let me=C();return me.add(j.id),yr(es,JSON.stringify([...me])),d(`tip \xB7 ${j.text}`,5200),j.id}function he(j){yr(_i,j?"0":"1"),d(j?"tips on \u2014 one per deck you open":"tips off")}function oe(){yr(es,"[]"),d(`tips reset \u2014 all ${jn.length} will show again, one per deck`)}function de(j){if(!w&&(f().on("slide",A),f().on("build",A),!(j.slide!==1||j.step!==0))){if(ts(Ai)!=="1"){I();return}M()&&q()}}return{start:de,showWelcome:I,dismissWelcome:A,showTip:q,setTips:he,resetTips:oe,status:()=>({tipsOn:M(),tipsLeft:$()?jn.length-C().size:0})}}ae();le();function Ci({sectionsOf:r,checkOverflow:a,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 C of m)a(C,M.indexOf(C)+1)})||1)}let w=l?new l(h):null;function k(M){if(w)for(let C of[M,...M.querySelectorAll("*")])C.parentElement?.closest(".terminal")||w.observe(C)}let A=d?new d(M=>{let C=q=>!(q.nodeType===1?q:q.parentElement)?.closest(".terminal"),$=!1;for(let q of M)if(C(q.target)){$=!0;for(let he of q.addedNodes)he.nodeType===1&&he.isConnected&&k(he)}$&&h()}):null,I=M=>{M.target.closest?.(".terminal")||h()};return{watch(M){w?.disconnect(),A?.disconnect();for(let C of m)for(let $ of["load","error"])C.removeEventListener($,I,!0);m=M.filter(Boolean);for(let C of m){k(C),A?.observe(C,{childList:!0,subtree:!0,characterData:!0});for(let $ of["load","error"])C.addEventListener($,I,!0)}h()},get watched(){return m.slice()}}}ae();le();function Ni({config:r,root:a,embedded:l,sectionsOf:d,slideOf:u,navigate:m}){let f=!l&&r.playlist?.modules?.length?r.playlist:null,h=f?f.index??0:0,w=!!a.querySelector("section[data-module]");function k(){let I=[];return(d()||[]).forEach((M,C)=>{M.hasAttribute("data-module")&&I.push({title:M.getAttribute("data-module"),slide:C+1})}),I}function A(I=k()){let M=-1;return I.forEach((C,$)=>{C.slide<=u()&&(M=$)}),M}return{get playlist(){return f},get index(){return h},get hasMarkers(){return w},get any(){return w||!!f},markers:k,currentMarkerIndex:A,gotoModule(I){if(!f)return!1;let M=f.modules[h+I];return M?(m(M.href+(I>0?"#/1/0":"#/999/999")),!0):!1},navigateToModule(I){let M=f?.modules[I];M&&m(M.href+"#/1/0")},title(){if(w){let I=k();return I[A(I)]?.title||""}return f?.modules[h]?.title||""}}}ae();le();function ed(r,a,l){return(r.querySelector("h1, h2, h3")?.textContent||"").replace(/\s+/g," ").trim()||l.slice(0,60)||`slide ${a+1}`}function td(r){return[...r.children].filter(l=>!l.matches("aside, script, style")).map(l=>l.textContent).join(" ").replace(/\s+/g," ").trim()}function $i({sections:r,modules:a=[],skipModule:l=-1}){let d=r.map((m,f)=>{let h=td(m);return{slide:f+1,title:ed(m,f,h),haystack:h.toLowerCase()}}),u=a.map((m,f)=>({module:f,title:m.title,href:m.href,haystack:(m.title||"").toLowerCase()})).filter(m=>m.module!==l);return[...d,...u]}function Oi(r,a){let l=String(a??"").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]}ae();le();function Mi({now:r=Date.now,keep:a=200}={}){let l=r(),d=[],u=null;function m(f,h){let w={t:((r()-l)/1e3).toFixed(3),kind:f,msg:h};return d.push(w),d.length>a&&d.shift(),u?.(w),w}return{log:m,get entries(){return d.slice()},onEntry(f){u=f}}}ae();le();var nd=["auto","centered","pinned","top","split","split-flip"];function rd({autoPins:r,hasSplitPair:a}){return nd.filter(l=>(l!=="pinned"||!r)&&(l!=="split-flip"||a))}function sd(r,a,l){if(!r.length)return null;let d=Math.max(0,r.indexOf(a));return r[(d+l+r.length)%r.length]}function Li({slideOf:r,sectionAt:a,describe:l,available:d,unavailableMessage:u,apply:m,relayout:f,post:h,toast:w,debugLog:k,schedule:A=setTimeout,cancel:I=clearTimeout,delay:M=600}){let C=null,$=null;function q(){I($);let de=C;C=null,de&&h({slide:de.slide,layout:de.name}).then(()=>k("layout",`slide ${de.slide}: ${de.name} \u2192 saved to file`)).catch(()=>w("layout save failed \u2014 is the dev server still up?",2200))}function he(de=r()){let j=a(de);return j?rd(l(j)):[]}function oe(de){if(!d()){w(u(),3200);return}let j=r(),me=a(j);if(!me)return;let Te=sd(he(j),me.getAttribute("data-layout")||"auto",de);if(!Te)return;m(me,Te),C&&C.slide!==j&&q(),C={slide:j,name:Te},I($),$=A(q,M);let $e=f(me,j);w($e?`layout: ${Te} \u2014 fights this slide's own column flexbox; pick one`:`layout: ${Te}`),k("layout",`slide ${j}: ${Te}`)}return{ring:he,cycle:oe,flush:q}}ae();le();function Ri({commands:r,query:a="",totalSlides:l=0,makeGotoRow:d,makeSearchRow:u}){let m=String(a).toLowerCase(),f=r.filter(w=>!m||(w.label+" "+(w.alias??"")).toLowerCase().includes(m)),h=String(a).trim().match(/^(?:goto\s*)?(\d+)$/i);if(h&&d){let w=Math.max(1,Math.min(parseInt(h[1],10),l));f.unshift(d(w,l))}return m&&!h&&u&&!f.some(w=>w.label.toLowerCase().startsWith(m))&&f.push(u(a)),f}var od={transition:"fade",hash:!0,controls:!0,slideNumber:!1,width:1280,height:720,pinTitles:!0},xr=99,id=18,Ii=6,ad="ul, ol, svg, pre, table, .terminal, img, .columns",Bn=null;function Kn(r,a){Ws(r,a),Bn&&Bn._rescanFor(r)}function ld(r){let a=getComputedStyle(r).position;return a==="absolute"||a==="fixed"}function cd(r){for(let a of r.children)if(!a.matches("aside, script, style, .decklight-hero-logo, .slide-bg")){if(a.matches("h1, h2"))return a;if(!ld(a))return null}return null}function dd(r,a){if(!a||r.getAttribute("data-subtitle")==="none")return null;let l=a.nextElementSibling;return l&&l.matches("p")&&!l.hasAttribute("data-build")?(l.classList.add("subtitle"),l):r.querySelector(":scope > p.subtitle")}function Pi(r){return r.pinTitles===!0?xr:typeof r.pinTitles=="number"&&isFinite(r.pinTitles)?r.pinTitles:null}function Di(r,a){let l=Pi(a),d=r.getAttribute("data-pin");if(d==="none")return null;if(d!==null&&d!==""){let m=parseFloat(d);return isFinite(m)?m:l??xr}return d===""?l??xr:l===null?null:[...r.querySelectorAll(ad)].some(m=>!m.closest("aside")&&!m.closest(".decklight-hero-logo"))?l:null}function wr(r,a){r.forEach(l=>{let d=cd(l),u=l.getAttribute("data-layout"),m;if(u==="pinned"){let k=parseFloat(l.getAttribute("data-pin"));m=isFinite(k)?k:Pi(a)??xr}else u==="centered"||u==="top"?m=null:m=Di(l,a);let f=dd(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,w=m+h;f&&(f.classList.add("pin-subtitle"),l.style.setProperty("--pin-sub-y",Math.round(w+Ii)+"px"),w+=Ii+(f.offsetHeight||0)),l.classList.remove("pin-measure"),l.style.setProperty("--pin-space",Math.round(w+id)+"px")})}function qi(r){return[...r.children].filter(a=>!a.matches("h1, h2, .subtitle, aside, script, style, .decklight-hero-logo, .slide-bg"))}function Bi(r){r.forEach((a,l)=>{if(a.querySelectorAll(":scope > .split-columns, :scope > .split-footer").forEach(u=>u.classList.remove("split-columns","split-footer")),!/^split/.test(a.getAttribute("data-layout")||"")){a.removeAttribute("data-split-conflict");return}let d=qi(a);if(ud(a,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 ud(r,a,l){let d=a.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 ns(r,a){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 ${a} content overflows and is clipped \u2014 reduce content or font size`)}function pd(r){r.querySelectorAll("section[data-markdown]").forEach((a,l)=>{a.setAttribute("data-markdown-removed","");let d=[...r.children].indexOf(a)+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 Fi(r={}){let a=new URLSearchParams(location.search),l={...od,...r};a.has("embedded")&&(l.controls=!1);let d=a.has("print"),u=a.get("print")||"",m=Mi(),f=null,h=(y,_)=>m.log(y,_),w=document.querySelector(".decklight");if(!w)throw new Error("Decklight: no .decklight element found");let k=ci(),A=Ni({config:l,root:w,embedded:a.has("embedded"),sectionsOf:()=>te._sections,slideOf:()=>te.state.slide,navigate:y=>{location.href=y}}),I=A.playlist,M=A.index,C=A.hasMarkers,$=y=>A.gotoModule(y),q=y=>A.navigateToModule(y),he=200,oe=4,de=[],j=null,me=null;function Te(){return de}function $e(y){de.push({at:new Date,text:String(y)}),de.length>he&&de.shift(),me&&St()}function Re(y,_=3200){if($e(y),d)return;j||(j=document.createElement("div"),j.className="decklight-messages",w.appendChild(j));let S=document.createElement("div");for(S.className="decklight-toast",S.textContent=y,j.appendChild(S),requestAnimationFrame(()=>S.classList.add("show"));j.children.length>oe;)j.firstChild.remove();setTimeout(()=>{S.classList.remove("show"),setTimeout(()=>S.remove(),260)},_)}let be=Ti({root:w,printMode:d,params:a,toast:Re,debugLog:h,overlays:k,deck:()=>te}),Ce=pi({root:w,config:l,params:a,toast:Re,debugLog:h,overlays:k,deck:()=>te,editmode:()=>xt}),{applyTheme:Xe,currentTheme:xe,cycleTheme:E,cancelCyclePending:Ie,rollTheme:qe,saveGeneratedTheme:De}=Ce,F=null,J=0,U="",fe=[],Ee,ze=!1,Ne=null;function s(){return $i({sections:te._sections,modules:I?.modules??[],skipModule:M})}function o(){let y=F.querySelector(".tp-list");if(fe=Oi(F.__index,U),y.textContent="",fe.forEach((S,R)=>{let Z=document.createElement("div");Z.className="tp-row"+(S.slide===te.state.slide?" tp-current":"")+(S.href?" tp-module":""),Z.textContent=S.href?`\u25B8 ${S.title} \u2014 module`:`${S.slide} \xB7 ${S.title}`,Z.addEventListener("mouseenter",()=>Be(R,!1)),Z.addEventListener("click",()=>{Be(R,!0),Ue()}),y.appendChild(Z)}),!fe.length){let S=document.createElement("div");S.className="tp-none",S.textContent="no matches",y.appendChild(S)}let _=F.querySelector(".tp-filter");_.textContent=U||(I?"type to find a slide or module\u2026":"type to find a slide\u2026"),_.classList.toggle("tp-active",!!U)}function O(y,_){let S=_.href??location.pathname,R=_.slide??1;if(y.dataset.doc!==S){y.dataset.doc=S,ze=!1,y.addEventListener("load",()=>{if(ze=!0,Ne&&F){let Z=Ne;Ne=null,O(y,Z)}},{once:!0}),y.src=S+Ce.previewQuery()+"#/"+R+"/0";return}if(!ze){Ne=_;return}y.contentWindow?.postMessage({__decklightPreview:{goto:[R,0]}},"*")}function Be(y,_){if(!fe.length)return;J=jt(F.querySelectorAll(".tp-row"),y,"tp-selected");let S=fe[J];F.querySelector(".tp-caption").textContent=S.href?`module \u2014 ${S.title} (${S.href})`:`slide ${S.slide} \u2014 ${S.title}`,clearTimeout(Ee);let R=F.querySelector("iframe");_?O(R,S):Ee=setTimeout(()=>O(R,S),60)}function P(y){U=y,o(),fe.length?Be(0,!1):F.querySelector(".tp-caption").textContent="no match"}function Ue(){let y=fe[J];if(W(),!!y){if(y.href)return q(y.module);te.goto(y.slide,0)}}function nt(){if(F)return W();Ce.closePicker(),xt.restore.close(),U="",F=document.createElement("div"),F.className="decklight-theme-picker decklight-finder",F.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>',F.__index=s(),o(),kt(F,W),w.appendChild(F),Be(Math.max(0,fe.findIndex(y=>y.slide===te.state.slide)),!0)}function W(){clearTimeout(Ee),F?.remove(),F=null}let Ae=null,Q=0,ye="",x=[];function we(){let y=S=>typeof S=="function";return[{label:"Find slide\u2026",hint:"G",alias:"search grep goto module chapter jump",run:()=>{nt(),ye&&P(ye)}},{label:"Restore a version\u2026",hint:"R",alias:"history git rollback undo revert commit",run:()=>xt.restore.open()},{label:"Go to slide\u2026",hint:"#",alias:"goto",keepOpen:!0,run:()=>{ye="goto ",g()}},{label:"Theme\u2026",hint:"T",run:Ce.openPicker},{label:"Cycle theme",hint:", \xB7 .",run:()=>E(1)},{label:"Generate a theme",hint:"\u2303T",run:qe},Ce.hasGenerated()&&{label:"Save the generated theme\u2026",hint:"\u2303\u21E7T",run:()=>De()},xt.available()&&{label:"Browse marketplace themes\u2026",alias:"marketplace install add third-party download catalog",run:Ce.browse},...xt.wizards().map(S=>({label:`Configure ${S.title}\u2026 (dev)`,alias:"engine wizard setup api key credential token marketplace",run:()=>xt.wizard(S.qualified)})),{label:"Font\u2026",hint:"[ \xB7 ]",run:ne},{label:"Cycle slide layout (dev)",hint:"L",alias:"pin pinned centered top auto split columns two sides arrange",run:()=>Pt(1)},{label:"Undo deck edit (dev)",hint:"Z",alias:"revert back history",run:()=>an("undo")},{label:"Redo deck edit (dev)",hint:"\u21E7Z",alias:"forward history repeat",run:()=>an("redo")},{label:"Ask agent\u2026 (dev)",hint:"A",alias:"ai claude codex bob gemini prompt edit",run:bt},{label:"Messages",hint:"`",alias:"log toast notifications warnings why voice stopped history",run:ut},{label:`Narration ${At.status().narrating?"off":"on"}`,hint:"V",run:wt},{label:"Narration track\u2026",hint:"N",alias:"voice audio",run:()=>Lt("tracks")},{label:"Live voice\u2026",alias:"tts synthesize tone gemini",run:()=>Lt("voices")},{label:"Character\u2026",alias:"avatar lipsync face talking head visemes",run:()=>Lt("character")},{label:`Character solo ${rn.solo?"off":"on"}`,alias:"centre center stage narrator only fullscreen avatar",run:()=>At.applySolo(!rn.solo)},{label:"Record offline narration\u2026",hint:"\u21E7V",alias:"export download batch wav tts",run:sn},{label:"Voice faster",hint:">",alias:"speed rate playback",run:()=>Ft(.25)},{label:"Voice slower",hint:"<",alias:"speed rate playback",run:()=>Ft(-.25)},{label:"Speaker view",hint:"S",run:()=>{let S=te.__speakerWin;S&&!S.closed?S.__decklightSpeakerToggle?.():te.__speakerWin=Wr(te)}},{label:"Overview",hint:"O",run:Et},{label:"Blackout",hint:"B",run:Yt},{label:`Pen ${zt.annotator?.tool==="pen"?"off":"on"} \u2014 draw on the slide`,hint:"W",alias:"ink annotate draw scribble marker highlight",run:()=>Qt("pen")},{label:`Laser pointer ${zt.annotator?.tool==="laser"?"off":"on"}`,hint:"\u21E7W",alias:"ink dot glow point at",run:()=>Qt("laser")},{label:"Debug log",hint:"D",alias:"console events state",run:dt},{label:`Captions ${At.status().captionsOn?"off":"on"}`,hint:"C",alias:"cc subtitles closed caption",run:Mt},{label:`Clock ${zt.status().clockOn?"off":"on"}`,hint:"K",alias:"time elapsed timer talk wall watch",run:Jt},{label:`Progress bar ${zt.status().progressOn?"off":"on"}`,hint:"H",alias:"bar bottom edge position how far through shape of the talk",run:on},{label:"Transcript\u2026",alias:"notes script export text markdown spoken",run:Bt},{label:`Narration ${At.status().paused?"resume":"pause"}`,hint:"P",alias:"pause resume voice",run:$t},{label:"Edit speaker notes\u2026",alias:"edit mode notes write right-click background",run:kn},{label:`Element edit mode ${xt.elementEditOn()?"off":"on"} (dev)`,hint:"E",alias:"right-click remove delete html content build animation entrance effect context menu",run:T},{label:"Fullscreen",hint:"F",run:()=>H()},{label:"Print view (all slides, new tab)",hint:"",run:()=>window.open(location.pathname+"?print")},{label:"First slide",hint:"Home",run:()=>te.goto(1,0)},{label:"Last slide",hint:"End",run:()=>te.goto(te.state.totalSlides,0)},{label:"Keyboard help",hint:"?",run:Ot},{label:"Welcome to Decklight",alias:"onboarding intro getting started first run tour what is this help me",run:be.showWelcome},{label:`Tips ${be.status().tipsOn?"off":"on"}`,alias:"hints teach shortcuts learn stop showing quiet",run:()=>be.setTips(!be.status().tipsOn)},be.status().tipsLeft<jn.length&&{label:"Reset tips",alias:"hints again start over show all unsee replay",run:be.resetTips}].filter(Boolean).filter(S=>y(S.run))}function g(){let y=Ae.querySelector(".narr-card");y.textContent="",x=Ri({commands:we(),query:ye,totalSlides:te.state.totalSlides,makeGotoRow:(S,R)=>({label:`Go to slide ${S} / ${R}`,hint:"\u23CE",run:()=>te.goto(S,0)}),makeSearchRow:S=>({label:`Search slides for \u201C${S}\u201D`,hint:"",run:()=>{nt(),P(S)}})});let _=document.createElement("div");if(_.className="pal-input"+(ye?" tp-active":""),_.textContent=ye||"type a command\u2026",y.appendChild(_),x.forEach((S,R)=>{let Z=document.createElement("div");Z.className="narr-row pal-row";let ue=document.createElement("span");if(ue.textContent=S.label,Z.appendChild(ue),S.hint){let Ve=document.createElement("span");Ve.className="pal-kbd",Ve.textContent=S.hint,Z.appendChild(Ve)}Z.addEventListener("mouseenter",()=>G(R)),Z.addEventListener("click",()=>{G(R),B()}),y.appendChild(Z)}),!x.length){let S=document.createElement("div");S.className="tp-none",S.textContent="no matching command",y.appendChild(S)}G(0)}function G(y){x.length&&(Q=jt(Ae.querySelectorAll(".pal-row"),y,"narr-sel"))}function B(){let y=x[Q];y&&(y.keepOpen||Y(),y.run())}function X(){if(Ae)return Y();F&&W(),xt.restore.close(),ye="",Ae=document.createElement("div"),Ae.className="decklight-narr decklight-palette",Ae.innerHTML='<div class="narr-card" role="listbox" aria-label="Commands"></div>',kt(Ae,Y),w.appendChild(Ae),g()}function Y(){Ae?.remove(),Ae=null}let ge=null,V=0;function ne(){if(ge)return Je();ge=document.createElement("div"),ge.className="decklight-narr decklight-font-picker",ge.innerHTML='<div class="narr-card" role="listbox" aria-label="Fonts"></div>';let y=ge.querySelector(".narr-card");re.forEach(([_],S)=>{let R=document.createElement("div");R.className="narr-row"+(S===He?" narr-cur":""),R.textContent=_,S>0&&(R.style.fontFamily=re[S][1]),R.addEventListener("mouseenter",()=>Fe(S)),R.addEventListener("click",()=>{_e(S),Je()}),y.appendChild(R)}),kt(ge,Je),w.appendChild(ge),Fe(He)}function Fe(y){V=jt(ge.querySelectorAll(".narr-row"),y,"narr-sel")}function Je(){ge?.remove(),ge=null}Ce.restoreSaved();let re=[["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"]],ke="decklight-font:"+location.pathname,He=0;function _e(y,{silent:_=!1,remeasure:S=!0}={}){He=(y%re.length+re.length)%re.length;let[R,Z]=re[He];if(Z?(w.style.setProperty("--font-body",Z),w.style.setProperty("--font-heading",Z)):(w.style.removeProperty("--font-body"),w.style.removeProperty("--font-heading")),!a.has("embedded"))try{Z?localStorage.setItem(ke,String(He)):localStorage.removeItem(ke)}catch{}S&&(wr(te._sections,l),ns(te._sections[te.state.slide-1],te.state.slide)),_||Re(`font: ${R}`),h("font",R)}function Le(y){_e(He+y)}try{let y=parseInt(localStorage.getItem(ke),10);y>0&&y<re.length&&_e(y,{silent:!0,remeasure:!1})}catch{}function Qe(y){if(!y)return null;if(y.startsWith("#")){let S=document.querySelector(y);if(!S)return null;let R=S.cloneNode(!0);return R.removeAttribute("id"),R.style.removeProperty("display"),R}if(y.trim().startsWith("<")){let S=document.createElement("div");return S.innerHTML=y,S.firstElementChild}let _=document.createElement("img");return _.src=y,_.alt="",_}let Oe=null;Ce.updateCanvas();let Ye=w.querySelector(":scope > .decklight-stage");if(!Ye){for(Ye=document.createElement("div"),Ye.className="decklight-stage";w.firstChild;)Ye.appendChild(w.firstChild);w.appendChild(Ye)}if(Ye.style.width=l.width+"px",Ye.style.height=l.height+"px",l.logo&&(l.logo.src||l.logo.onLight||l.logo.onDark)){Oe=document.createElement("div"),Oe.className="decklight-logo",Oe.setAttribute("data-pos",l.logo.position||"bottom-left"),l.logo.height&&Oe.style.setProperty("--logo-h",l.logo.height+"px");for(let[y,_]of[["src","on-any"],["onLight","on-light"],["onDark","on-dark"]]){let S=Qe(l.logo[y]);if(!S)continue;let R=document.createElement("span");R.className=_,R.appendChild(S),Oe.appendChild(R)}w.appendChild(Oe)}function ct(y){Oe&&y.forEach(_=>{if(!_.hasAttribute("data-logo")||_.querySelector(":scope > .decklight-hero-logo"))return;let S=document.createElement("div");S.className="decklight-hero-logo";let R=parseFloat(_.getAttribute("data-logo"));R&&S.style.setProperty("--hero-logo-h",R+"px"),S.innerHTML=Oe.innerHTML,_.prepend(S)})}pd(Ye),to(Ye),po(Ye),Ys(Ye),ii(Ye,Kn);let _t=Li({slideOf:()=>te.state.slide,sectionAt:y=>te._sections[y-1],describe:y=>({autoPins:Di(y,l)!==null,hasSplitPair:qi(y).length>1}),available:()=>xt.available(),unavailableMessage:()=>tn("layout",location),apply:(y,_)=>{_==="auto"?y.removeAttribute("data-layout"):y.setAttribute("data-layout",_)},relayout:(y,_)=>(wr(te._sections,l),Bi(te._sections),ns(y,_),y.hasAttribute("data-split-conflict")),post:y=>fetch(xt.base()+"/edit/layout",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(y)}).then(_=>{if(!_.ok)throw new Error(_.status)}),toast:Re,debugLog:h}),Pt=y=>_t.cycle(y),Kt=y=>_t.ring(y),te={root:w,stage:Ye,config:l,_sections:[],_records:[],state:{slide:1,step:0,totalSlides:0},_listeners:new Map,_scale:1,on(y,_){return this._listeners.has(y)||this._listeners.set(y,new Set),this._listeners.get(y).add(_),this},_emit(y,_){(this._listeners.get(y)||[]).forEach(S=>S(_)),w.dispatchEvent(new CustomEvent("decklight:"+y,{detail:_}))},sync(){this._sections=[...Ye.querySelectorAll(":scope > section")],this._sections.forEach((_,S)=>_.setAttribute("data-slide-index",String(S+1))),Xs(Ye,l.concepts),ct(this._sections),Ei(this._sections,{printMode:d}),wr(this._sections,l),Bi(this._sections),this._records=this._sections.map(_=>Pr(_)),this.state.totalSlides=this._sections.length,this.state.slide=Math.min(this.state.slide,this.state.totalSlides||1);let y=this._records[this.state.slide-1];y&&(this.state.step=Math.min(this.state.step,y.groups.length)),Vt(d?this._sections:[this._sections[this.state.slide-1]])},_rescanFor(y){let _=y.closest("section"),S=this._sections.indexOf(_);if(S!==-1){if(this._records[S]=Pr(_),d){cn(this._records[S],this._records[S].groups.length);return}S===this.state.slide-1?(this.state.step=Math.min(this._requestedStep??this.state.step,this._records[S].groups.length),this._requestedStep=null,Dt(()=>cn(this._records[S],this.state.step)),this._updateHash(!1)):Dt(()=>cn(this._records[S],0)),this._notify()}},_stepLabels(y){let _=this._records[y];return _?Vs(_):[]},next(){let y=this._records[this.state.slide-1];y&&this.state.step<y.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"}):$(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 y=this._records[this.state.slide-2];this.goto(this.state.slide-1,y.groups.length,{direction:"back"})}else $(-1)},goto(y,_=0,S={}){y=Math.max(1,Math.min(y,this.state.totalSlides));let R=this._records[y-1];this._requestedStep=_,_=Math.max(0,Math.min(_,R?R.groups.length:0));let Z=y===this.state.slide;if(Z&&_===this.state.step&&!S.force)return;let ue=S.direction||(y>this.state.slide||Z&&_>this.state.step?"fwd":"back");!Z||S.force?(this._activateSlide(y,ue,S),this.state.slide=y,this.state.step=_,Dt(()=>cn(R,_)),this._emit("slide",{slide:y,total:this.state.totalSlides,direction:ue}),Vt([this._sections[y-1]])):(this.state.step=_,cn(R,_),this._emit("build",{slide:y,index:_,total:R.groups.length,direction:ue})),this._updateChrome(),this._updateHash(!Z),this._notify()},_activateSlide(y,_,S={}){let R=this._sections[this.state.slide-1],Z=this._sections[y-1];if(w.classList.toggle("has-hero-logo",Z?.hasAttribute("data-logo")??!1),R===Z){Z.classList.add("active");return}let ue=!R||!R.classList.contains("active"),Ve=R&&Z&&!ue&&R.hasAttribute("data-auto-animate")&&Z.hasAttribute("data-auto-animate")&&Math.abs(this._sections.indexOf(Z)-this._sections.indexOf(R))===1;if(this._sections.forEach(Dn=>Dn.classList.remove("active","entering","leaving","dir-fwd","dir-back","tr-none","tr-fade","tr-slide","tr-scale","tr-flip")),Z.classList.add("active"),ue||d)return;if(Ve){R.classList.add("leaving"),R.style.visibility="hidden",Z.style.visibility="hidden",Z.offsetWidth,Z.style.visibility="",lo(R,Z,this._scale),R.classList.remove("leaving"),R.style.visibility="";return}let it=oo(Z.getAttribute("data-transition"),this.config.transition),ht=io(it,_);if(!ht)return;Z.classList.add(...ht.entering),R.classList.add(...ht.leaving);let mn=or(getComputedStyle(Z).getPropertyValue("--transition-duration"),350);setTimeout(()=>{R.classList.remove(...ht.leaving),Z.classList.remove(...ht.entering)},mn+60)},_updateChrome(){if(Ct){let y=this._records[this.state.slide-1],_=y?y.groups.length:0,S=this.state.totalSlides<=1?1:(this.state.slide-1+(_?this.state.step/(_+1):0))/(this.state.totalSlides-1);Ct.style.width=(Math.min(S,1)*100).toFixed(2)+"%"}if(gt){let y=this.config.slideNumber?this.config.slideNumber==="n/N"?`${this.state.slide} / ${this.state.totalSlides}`:String(this.state.slide):"";if(gt.textContent=y,A.any){let _=A.title(),S=document.createElement("span");S.className="mod",S.textContent=_,gt.prepend(S)}}},_updateHash(y){if(!this.config.hash||d)return;let _=`#/${this.state.slide}/${this.state.step}`;"#"+qt(location.hash)!==_&&(pt=!0,y?history.pushState(null,"",_):history.replaceState(null,"",_),setTimeout(()=>{pt=!1}))},_notify(){this.__notifySpeaker&&this.__notifySpeaker()}};function nn(y,_){let S=document.createElement("a");S.href=y,S.download=_,document.body.appendChild(S),S.click(),S.remove()}function Dt(y){w.classList.add("decklight-no-anim"),y(),w.offsetWidth,w.classList.remove("decklight-no-anim")}function qt(y){return(y||"").replace(/^#/,"")}function Xt(){let y=qt(location.hash).match(/^\/(\d+)(?:\/(\d+))?/);return y?{slide:parseInt(y[1],10),step:y[2]?parseInt(y[2],10):0}:null}let Ct=null,gt=null;if(l.controls&&!d){let y=document.createElement("div");y.className="decklight-controls",y.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=`
310
336
  <button class="decklight-arrow prev" aria-label="Previous">\u2039</button>
311
- <button class="decklight-arrow next" aria-label="Next">\u203A</button>`,w.appendChild(y),y.querySelector(".prev").addEventListener("click",()=>te.prev()),y.querySelector(".next").addEventListener("click",()=>te.next())}let ot={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>'},st=null,N=null;function H(){let y=w||document.documentElement;document.fullscreenElement?document.exitFullscreen?.():y.requestFullscreen?.()?.catch?.(()=>{})}document.addEventListener("fullscreenchange",()=>{st&&(st.innerHTML=document.fullscreenElement?ot.unfull:ot.full)});function ie(){if(!N)return;let y=At.status().narrating;N.innerHTML=y?ot.sound:ot.mute,N.setAttribute("aria-label",y?"Mute narration":"Play narration"),N.setAttribute("aria-pressed",String(y))}(l.slideNumber||I||C)&&!d&&(gt=document.createElement("div"),gt.className="decklight-slide-number",(I||C)&&(gt.title="G \u2014 find a slide or module",gt.style.cursor="pointer",gt.addEventListener("click",()=>nt())),w.appendChild(gt));let pe=null,Pe=0;function Se(){return getComputedStyle(pe).gridTemplateColumns.split(" ").length||1}function Me(y){let _=pe.querySelectorAll(".ov-cell");Pe=Math.max(0,Math.min(y,_.length-1)),_.forEach((S,R)=>S.classList.toggle("ov-selected",R===Pe)),_[Pe]?.scrollIntoView({block:"nearest"})}function rt(){let y=Pe+1;Et(),te.goto(y,0,{force:!0})}function at(){if(!pe)return;let y=pe.querySelector(".ov-cell");if(!y)return;pe.style.gridAutoRows=Math.round(y.clientWidth*l.height/l.width)+"px";let _=y.clientWidth/l.width;pe.querySelectorAll(".ov-frame").forEach(S=>{S.style.transform=`scale(${_})`})}function Et(){if(pe){window.removeEventListener("resize",at),pe.remove(),pe=null,w.classList.remove("decklight-overview");return}pe=document.createElement("div"),pe.className="decklight-overview-grid",te._sections.forEach((y,_)=>{let S=document.createElement("div");S.className="ov-cell"+(_===te.state.slide-1?" ov-current":"");let R=document.createElement("div");R.className="ov-frame",R.style.width=l.width+"px",R.style.height=l.height+"px";let Z=y.cloneNode(!0);Z.classList.add("active","ov-clone"),Z.querySelectorAll("aside.notes, aside.rehearse").forEach(Ve=>Ve.remove()),Z.querySelectorAll("input, button, select, textarea").forEach(Ve=>{Ve.removeAttribute("name"),Ve.disabled=!0}),R.appendChild(Z),S.appendChild(R);let ue=document.createElement("span");ue.className="ov-num",ue.textContent=String(_+1),S.appendChild(ue),S.addEventListener("click",()=>{Et(),te.goto(_+1,0,{force:!0})}),pe.appendChild(S)}),w.classList.add("decklight-overview"),w.appendChild(pe),at(),Me(te.state.slide-1),window.addEventListener("resize",at)}let Nt=null;function Yt(){if(Nt){Nt.remove(),Nt=null;return}Nt=document.createElement("div"),Nt.className="decklight-blackout",w.appendChild(Nt)}let Rt=null;function wn(){let y=te._records?.[te.state.slide-1],_=At.status(),S=_.live?`\u26A1 ${_.voice} \xB7 ${_.tone}`:_.track?`\u{1F50A} ${_.track.label}`:"none";return`slide ${te.state.slide}/${te.state.totalSlides} \xB7 step ${te.state.step}/${y?y.groups.length:0} \xB7 theme ${xe()??"\u2014"} \xB7 narration ${_.narrating?_.paused?"paused":"on":"off"} (${S})`+(_.rate!==1?` \xB7 ${_.rate}\xD7`:"")+(_.spend>0?` \xB7 tts ~$${_.spend.toFixed(4)}`:"")}function Ht(y){let _=document.createElement("div");_.className="dbg-row dbg-"+y.kind;for(let[S,R]of[["dbg-t",y.t],["dbg-k",y.kind],["dbg-m",y.msg]]){let Z=document.createElement("span");Z.className=S,Z.textContent=R,_.appendChild(Z)}f.querySelector(".dbg-log").appendChild(_)}function It(){let y=f?.querySelector(".dbg-state");y&&(y.textContent=wn())}function dt(){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>',w.appendChild(f),m.entries.forEach(Ht),It();let y=f.querySelector(".dbg-log");y.scrollTop=y.scrollHeight,m.onEntry(_=>{Ht(_),It();let S=f.querySelector(".dbg-log");S.scrollTop=S.scrollHeight})}function St(){let y=me?.querySelector(".msg-log");if(y){if(y.innerHTML="",!de.length){let _=document.createElement("div");_.className="msg-empty",_.textContent="no messages yet",y.appendChild(_);return}de.forEach(({at:_,text:S})=>{let R=document.createElement("div");R.className="msg-row";let Z=document.createElement("span");Z.className="msg-time",Z.textContent=_.toLocaleTimeString([],{hour12:!1});let ue=document.createElement("span");ue.className="msg-text",ue.textContent=S,R.append(Z,ue),y.appendChild(R)}),y.scrollTop=y.scrollHeight}}function ut(){if(me){me.remove(),me=null;return}me=document.createElement("div"),me.className="decklight-msglog",me.innerHTML='<div class="msg-head">messages \u2014 the key left of 1 closes</div><div class="msg-log"></div>',w.appendChild(me),St()}te.on("ready",y=>h("ready",`${y.slides} slides${y.print?" \xB7 print":""}`)),te.on("slide",y=>{h("slide",`\u2192 ${y.slide}/${y.total} (${y.direction})`),It()}),te.on("build",y=>{h("build",`slide ${y.slide} step ${y.index}/${y.total} (${y.direction})`),It()}),window.addEventListener("error",y=>h("error",String(y.message)));function Ot(){if(Rt){Rt.remove(),Rt=null;return}Rt=document.createElement("div"),Rt.className="decklight-help",Rt.innerHTML=`<div class="help-card"><h3>Keyboard</h3><table>
312
- <tr><td>\u2192 / Space</td><td>next build / slide</td></tr>
313
- <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>
314
341
  <tr><td>Home / End</td><td>first / last slide</td></tr>
315
342
  <tr><td>O</td><td>overview</td></tr>
316
343
  <tr><td>S</td><td>speaker view (again: rehearse mode)</td></tr>
317
- <tr><td>V</td><td>narration on/off</td></tr>
318
- <tr><td>N</td><td>narration track</td></tr>
319
- <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>
320
345
  <tr><td>&lt; / &gt;</td><td>voice speed (0.25\xD7 steps)</td></tr>
321
346
  <tr><td>B</td><td>blackout</td></tr>
322
347
  <tr><td>D</td><td>debug log</td></tr>
@@ -324,14 +349,16 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Ee=F,fe=J),U===void 0&
324
349
  <tr><td>C</td><td>captions (follow the voice)</td></tr>
325
350
  <tr><td>W</td><td>pen \u2014 draw on the slide (\u232B clears)</td></tr>
326
351
  <tr><td>\u21E7W</td><td>laser pointer</td></tr>
327
- <tr><td>K</td><td>clock \u2014 wall time + elapsed talk</td></tr>
328
- <tr><td>H</td><td>progress bar \u2014 position in the deck, bottom edge</td></tr>
329
- <tr><td>P</td><td>pause / resume narration</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>
353
+ <tr><td>J</td><td>progress bar \u2014 position in the deck, bottom edge</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>
330
358
  <tr><td>F</td><td>fullscreen</td></tr>
331
359
  <tr><td>T</td><td>theme picker (type to filter)</td></tr>
332
- <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>
333
361
  <tr><td>G</td><td>slide finder (live preview)</td></tr>
334
- <tr><td>R</td><td>restore a version (author mode \u2014 git history, live preview)</td></tr>
335
362
  <tr><td>E</td><td>element edit mode \u2014 right-click a slide element (author mode)</td></tr>
336
363
  <tr><td>, / .</td><td>cycle theme</td></tr>
337
364
  <tr><td>[ / ]</td><td>cycle font</td></tr>
@@ -340,17 +367,16 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Ee=F,fe=J),U===void 0&
340
367
  <tr><td>A</td><td>ask an AI agent to edit the deck (author mode)</td></tr>
341
368
  <tr><td>\u2303T</td><td>generate a theme (repeat to re-roll)</td></tr>
342
369
  <tr><td>\u2303\u21E7T</td><td>save the generated theme</td></tr>
343
- <tr><td>?</td><td>this help</td></tr>
344
- <tr><td>/</td><td>command palette \u2014 \u201CWelcome to Decklight\u201D reopens the intro</td></tr></table></div>`,Rt.addEventListener("click",Ot),w.appendChild(Rt)}k.register({isOpen:()=>!!Ae,close:Y,keydown:y=>hr(y,{query:ye,onMove:_=>G(Q+_),onCommit:B,onType:_=>{ye+=_,g()},onBackspace:()=>{ye=ye.slice(0,-1),g()},onClear:()=>{ye="",g()},onClose:Y})}),k.register({isOpen:()=>!!ge,close:Je,keydown:y=>hr(y,{onMove:_=>Fe(V+_),onCommit:()=>{_e(V),Je()},onClose:Je})}),k.register({isOpen:()=>!!F,close:W,keydown:y=>hr(y,{query:U,onMove:_=>Be(J+_,!1),onCommit:Ue,onType:_=>P(U+_),onBackspace:()=>P(U.slice(0,-1)),onClear:()=>P(""),onClose:W})}),k.register({isOpen:()=>!!pe,close:Et,keydown(y){switch(y.key){case"ArrowRight":Me(Pe+1);break;case"ArrowLeft":Me(Pe-1);break;case"ArrowDown":Me(Pe+Se());break;case"ArrowUp":Me(Pe-Se());break;case"Enter":case" ":rt();break;case"o":case"O":case"Escape":Et();break;default:return!1}return!0}});let Gt=y=>y.code==="Backquote"||y.key==="`"||y.key==="~"||y.key==="\xB2";function xn(y){if(Gt(y)&&(y.metaKey||y.ctrlKey||y.altKey)){ut(),y.preventDefault();return}if(/^(input|textarea|select)$/i.test(y.target.tagName))return;if(y.ctrlKey&&!y.metaKey&&!y.altKey&&(y.key==="T"||y.key==="t")){y.shiftKey?De():Ce.rollFromPicker()||qe(),y.preventDefault();return}if(y.metaKey||y.ctrlKey||y.altKey)return;let _=k.active();if(_){_.keydown(y)&&y.preventDefault();return}if(Gt(y)){ut(),y.preventDefault();return}switch(y.key){case"ArrowRight":case" ":case"PageDown":te.next();break;case"ArrowLeft":case"PageUp":te.prev();break;case"Home":te.goto(1,0);break;case"End":te.goto(te.state.totalSlides,0);break;case"o":case"O":Et();break;case"b":case"B":Yt();break;case"d":case"D":dt();break;case"c":case"C":Mt();break;case"k":case"K":Jt();break;case"h":case"H":on();break;case"p":case"P":$t();break;case"g":case"G":nt();break;case"r":case"R":xt.restore.open();break;case"e":case"E":T();break;case"f":case"F":H();break;case"v":case"V":y.shiftKey?sn():wt();break;case"n":case"N":Lt();break;case"s":case"S":{let S=te.__speakerWin;S&&!S.closed?S.__decklightSpeakerToggle?.():te.__speakerWin=Wr(te);break}case"t":case"T":Ce.openPicker();break;case"/":X();break;case".":E(1);break;case",":E(-1);break;case">":Ft(.25);break;case"<":Ft(-.25);break;case"]":Le(1);break;case"[":Le(-1);break;case"l":case"L":Pt(y.shiftKey?-1:1);break;case"z":case"Z":an(y.shiftKey?"redo":"undo");break;case"a":case"A":bt();break;case"w":case"W":Qt(y.shiftKey?"laser":"pen");break;case"Backspace":if(!zt.annotator?.active)return;zt.annotator.clear();break;case"?":Ot();break;case"Escape":if(Ie())break;pe&&Et();break;default:return}y.preventDefault()}d||document.addEventListener("keydown",xn);let Wt=null;w.addEventListener("touchstart",y=>{Wt=y.touches[0].clientX},{passive:!0}),w.addEventListener("touchend",y=>{if(Wt==null)return;let _=y.changedTouches[0].clientX-Wt;Math.abs(_)>40&&(_<0?te.next():te.prev()),Wt=null},{passive:!0});function L(){let y=w.getBoundingClientRect(),_=Math.min(y.width/l.width,y.height/l.height)||1;te._scale=_,Ye.style.transform=`translate(-50%, -50%) scale(${_})`}d||(new ResizeObserver(L).observe(w),L());let vn=Ci({sectionsOf:()=>te._sections,checkOverflow:ns}),Vt=y=>vn.watch(y),pt=!1;if(l.hash&&!d&&window.addEventListener("hashchange",()=>{if(pt)return;let y=Xt();y&&te.goto(y.slide,y.step,{force:!0})}),!d){let y=()=>{te._sections.forEach((_,S)=>{let R=_.querySelector(":scope > .slide-bg > video");R&&(S===te.state.slide-1?R.play()?.catch?.(()=>{}):R.paused||R.pause())})};te.on("slide",y)}te.sync(),d&&Oe&&(te._sections.forEach(y=>{y.hasAttribute("data-logo")||y.appendChild(Oe.cloneNode(!0))}),Oe.remove()),document.fonts?.ready?.then(()=>{(Bn===te||!Bn)&&wr(te._sections,l)}),te.theme=y=>Xe(y),te.themePicker={open:Ce.openPicker,close:Ce.closePicker},te.generateTheme=qe,te.cycleFont=Le,te.cycleLayout=Pt,te.layoutRing=Kt,te.toggleMessages=ut,te.messages=Te,te.showWelcome=be.showWelcome,te.tips={show:be.showTip,reset:be.resetTips,set:be.setTips,status:be.status};let At=wi({root:w,stage:Ye,config:l,params:a,printMode:d,toast:Re,logOnly:$e,debugLog:h,overlays:k,instance:te,syncSoundBtn:ie,updateDebugState:It,downloadFromUrl:nn}),{character:rn,toggleNarration:wt,toggleNarrPause:$t,changeNarrRate:Ft,toggleCaptions:Mt,openRecordDialog:sn,notesSegs:hn}=At,Lt=At.openPicker;te.toggleNarration=wt;let zt=ki({root:w,printMode:d,toast:Re,debugLog:h,overlays:k,instance:te,narration:At,downloadFromUrl:nn,setProgressBar:y=>{Ct=y}}),{toggleClock:Jt,toggleProgress:on,toggleInk:Qt,toggleTranscript:Bt}=zt;te.toggleClock=Jt,te.toggleProgress=on;let xt=Si({root:w,config:l,params:a,printMode:d,toast:Re,debugLog:h,overlays:k,instance:te,notesSegs:hn,dismissOthers:()=>{Ce.closePicker(),F&&W(),Ae&&Y()}}),{deckHistory:an,toggleEditor:kn,toggleAgentAsk:bt,toggleElementEdit:T}=xt;if(te.restore=xt.restore,te.wizard=xt.wizard,te.toggleElementEdit=T,a.has("voiceover")&&At.status().track&&!d){let y=()=>{window.removeEventListener("pointerdown",y),window.removeEventListener("keydown",y),At.status().narrating||wt()};window.addEventListener("pointerdown",y,{once:!0}),window.addEventListener("keydown",y,{once:!0})}if(!d){let y=document.createElement("div");y.className="decklight-touch-controls",st=document.createElement("button"),st.type="button",st.className="decklight-touch-btn",st.setAttribute("aria-label","Fullscreen"),st.innerHTML=ot.full,st.addEventListener("click",H),y.appendChild(st),At.status().hasTracks&&(N=document.createElement("button"),N.type="button",N.className="decklight-touch-btn",N.addEventListener("pointerdown",_=>_.stopPropagation()),N.addEventListener("click",()=>wt()),y.appendChild(N),ie()),w.appendChild(y)}if(te.saveGeneratedTheme=y=>De(y),d)return w.classList.add("decklight-print"),te._sections.forEach((y,_)=>{y.classList.add("active"),cn(te._records[_],te._records[_].groups.length)}),(u==="handout"||u==="notes")&&(w.classList.add("decklight-print-"+u),xi(Ye,te._sections,u)),Vt(te._sections),w.__decklight=te,Bn=te,te._emit("ready",{slides:te.state.totalSlides,print:!0}),te;let K=l.hash&&Xt()||{slide:1,step:0};return te._sections.forEach((y,_)=>{_!==K.slide-1&&cn(te._records[_],0)}),te.goto(K.slide,K.step,{force:!0}),w.__decklight=te,Bn=te,te._emit("ready",{slides:te.state.totalSlides}),be.start(K),te}ae();le();ae();le();var rs="\x1B",vr=Object.freeze({fg:null,bg:null,bold:!1,dim:!1,italic:!1,underline:!1,inverse:!1});function hd(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 a=8+(r-232)*10;return[a,a,a]}var Pn=class{constructor(){this.rows=[[]],this.row=0,this.col=0,this.style={...vr},this._pending=""}write(a){let l=this._pending+a;this._pending="";let d=0;for(;d<l.length;){let u=l[d];if(u===rs){let m=this._consumeEscape(l,d);if(m===0){this._pending=l.slice(d);return}d+=m;continue}if(d+=1,u===`
345
- `){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(a){let l=this.rows[this.row];for(;l.length<this.col;)l.push({ch:" ",style:vr});l[this.col]={ch:a,style:{...this.style}},this.col+=1}_consumeEscape(a,l){if(l+1>=a.length)return 0;let d=a[l+1];if(d==="["){let u=l+2;for(;u<a.length;){let m=a.charCodeAt(u);if(m>=64&&m<=126)return this._handleCsi(a.slice(l+2,u),a[u]),u-l+1;u+=1}return 0}if(d==="]"){let u=l+2;for(;u<a.length;){if(a[u]==="\x07")return u-l+1;if(a[u]===rs&&a[u+1]==="\\")return u-l+2;if(a[u]===rs&&u+1>=a.length)return 0;u+=1}return 0}return d==="("||d===")"?l+2<a.length?3:0:2}_handleCsi(a,l){if(!a.startsWith("?"))switch(l){case"m":this._sgr(a);return;case"K":this._eraseLine(a);return;case"C":this.col+=Math.max(1,parseInt(a||"1",10)||1);return;case"D":this.col=Math.max(0,this.col-Math.max(1,parseInt(a||"1",10)||1));return;default:return}}_eraseLine(a){let l=parseInt(a||"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:vr};return}if(l===2){d.length=0;return}}_sgr(a){let l=a===""?[0]:a.split(";").map(u=>parseInt(u,10)||0),d=0;for(;d<l.length;){let u=l[d];if(u===0)this.style={...vr};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(a=>{let l=[];for(let d of a){let u=l[l.length-1];u&&md(u.style,d.style)?u.text+=d.ch:l.push({text:d.ch,style:d.style})}return l})}toHtml(){return this.lines.map(a=>gd(a)).join(`
346
- `)}};function md(r,a){return r.bold===a.bold&&r.dim===a.dim&&r.italic===a.italic&&r.underline===a.underline&&r.inverse===a.inverse&&zi(r.fg,a.fg)&&zi(r.bg,a.bg)}function zi(r,a){return r===a?!0:!r||!a?!1:r.type===a.type&&r.idx===a.idx&&r.r===a.r&&r.g===a.g&&r.b===a.b}function fd(r){if(r.type==="256"){if(r.idx<16)return null;let[a,l,d]=hd(r.idx);return`rgb(${a},${l},${d})`}return r.type==="rgb"?`rgb(${r.r},${r.g},${r.b})`:null}function gd(r){return r.map(({text:a,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,I]of[[m,"fg"],[f,"bg"]])if(A)if(A.type==="ansi"||A.type==="256"&&A.idx<16)d.push(`ansi-${I}-${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=fd(A);M&&u.push(`${I==="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=vt(a);if(!d.length&&!u.length)return h;let w=d.length?` class="${d.join(" ")}"`:"",k=u.length?` style="${u.join(";")}"`:"";return`<span${w}${k}>${h}</span>`}).join("")}var Ui=24,bd=r=>Math.max(1,Math.min(10,r)),yd=r=>2**((r-5)/2.5),Hi=55,Zn=[120,160],Gi="decklight-term-wpm:"+location.pathname,wd=r=>Zn.reduce((a,l)=>Math.abs(l-r)<Math.abs(a-r)?l:a),Wn=["thocky","creamy","clacky","off"],ji="decklight-term-typesound:"+location.pathname,Ki="decklight-term-fontsize:"+location.pathname,Vn=[.75,.9,1,1.15,1.35,1.6],Wi={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 ss(r){let a=90+Math.random()*120;return Math.random()<.15&&(a+=Math.random()*240),r===" "?a+=70+Math.random()*220:".,:;/|&>-_=\"'`()".includes(r)&&(a+=40+Math.random()*140),Math.random()<.035&&(a+=300+Math.random()*440),a}var xd=.012,yt=null,kr=null,Sr=new Set,Vi=r=>{Sr.add(r),r.addEventListener("ended",()=>Sr.delete(r),{once:!0})};function vd(){if(!yt)return;let r=yt.currentTime;for(let a of Sr)try{a.stop(r)}catch{}Sr.clear()}function Er(r="",a="thocky",l=.12){try{let d=window.AudioContext||window.webkitAudioContext;if(!d)return;if(yt??=new d,yt.state==="suspended"&&yt.resume(),!kr){let q=Math.floor(yt.sampleRate*.06);kr=yt.createBuffer(1,q,yt.sampleRate);let he=kr.getChannelData(0);for(let oe=0;oe<q;oe++)he[oe]=Math.random()*2-1}let u=Wi[a]??Wi.thocky,m=(q,he)=>q+Math.random()*(he-q),f=yt.currentTime+xd,h=r===" ",w=m(.45,1.3)*(h?1.25:1),k=m(...u.clickF)*(h?.7:1),A=m(...u.ring)*(h?1.5:1),I=(q,he,oe,de)=>{let j=yt.createBufferSource();j.buffer=kr;let me=yt.createBiquadFilter();me.type="bandpass",me.frequency.value=oe,me.Q.value=u.clickQ;let Te=yt.createBiquadFilter();Te.type="lowpass",Te.frequency.value=u.lp;let $e=yt.createGain();$e.gain.setValueAtTime(1e-4,q),$e.gain.exponentialRampToValueAtTime(he,q+7e-4),$e.gain.exponentialRampToValueAtTime(1e-4,q+de),j.connect(me),me.connect(Te),Te.connect($e),$e.connect(yt.destination),j.start(q),j.stop(q+de+.01),Vi(j)},M=(q,he,oe,de)=>{let j=yt.createOscillator();j.type="sine",j.frequency.setValueAtTime(oe,q),j.frequency.exponentialRampToValueAtTime(oe*.6,q+de*.6);let me=yt.createGain();me.gain.setValueAtTime(1e-4,q),me.gain.exponentialRampToValueAtTime(he,q+m(.003,.011)),me.gain.exponentialRampToValueAtTime(he*.25,q+de),me.gain.exponentialRampToValueAtTime(1e-4,q+de*2),j.connect(me),me.connect(yt.destination),j.start(q),j.stop(q+de*2+.01),Vi(j)},C=u.thumpF2&&Math.random()<(u.thumpF2Prob??.4)?u.thumpF2:u.thumpF;I(f,u.click*w*(h?.82:1),k,m(...u.clickDecay)*(h?1.2:1)),M(f,u.thump*w*(h?2.4:1),m(...C)*(h?.7:1),A);let $=f+Math.max(.01,Math.min(m(.035,.08),l*.55));I($,u.click*w*m(.35,.55),k*1.15,m(...u.clickDecay)*.8),M($,u.thump*w*(h?.5:.25),m(...C)*(h?.7:1),A*.6)}catch{}}function kd(){try{let r=window.AudioContext||window.webkitAudioContext;if(!r)return;yt??=new r,yt.state==="suspended"&&yt.resume()}catch{}}var Zi=!1;function Ed(){if(Zi||typeof document>"u")return;Zi=!0;let r=()=>{kd(),document.removeEventListener("pointerdown",r,!0),document.removeEventListener("keydown",r,!0)};document.addEventListener("pointerdown",r,!0),document.addEventListener("keydown",r,!0)}function is(r,a=document){let l=[...a.querySelectorAll(".terminal[data-cast], .terminal[data-cast-inline]")];return l.length&&Ed(),Promise.all(l.map(d=>Sd(d,r).catch(u=>{Cd(d,u)})))}async function Sd(r,a){if(r.dataset.decklightTerminal)return;r.dataset.decklightTerminal="1";let l,d,u=r.dataset.castInline;if(u){d=u;let w=document.querySelector(u);if(!w&&document.readyState==="loading"&&(await new Promise(k=>document.addEventListener("DOMContentLoaded",k,{once:!0})),w=document.querySelector(u)),!w)throw new Error(`inline cast not found: ${u}`);l=w.textContent}else{d=r.dataset.cast;let w=await fetch(d);if(!w.ok)throw new Error(`failed to load cast: ${d} (${w.status})`);l=await w.text()}let m=Ad(l,d),f=new os(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(a)}function Ad(r,a){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): ${a}`)}return _d(r,a)}function _d(r,a){let l=r.split(`
347
- `).filter(w=>w.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: ${a}`);let u=[],m={cmd:"",raw:!0,output:[]},f=0,h=!1;for(let w of l.slice(1)){let k;try{k=JSON.parse(w)}catch{continue}if(!Array.isArray(k)||k.length<3)continue;let[A,I,M]=k;I==="m"?(h=!0,m.output.length&&u.push(m),m={cmd:String(M||""),raw:!0,output:[]},f=A):I==="o"&&m.output.push([Math.max(0,Td(A-f)),M])}if(m.output.length&&u.push(m),!u.length)throw new Error(`asciicast has no output events: ${a}`);return{decklightCast:1,imported:!0,hasMarkers:h,meta:{cols:d.width||100,rows:d.height||28,prompt:""},steps:u}}function Td(r){return Math.round(r*1e3)/1e3}function Cd(r,a){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 ${vt(String(a.message||a))}</pre></div></div>`}var os=class{constructor(a,l){this.el=a,this.cast=l,this.prompt=l.meta.prompt??"$ ";let d=bd(parseInt(a.dataset.typeSpeed??"5",10)||5);this.typeWpm=wd(Hi*yd(d));try{let m=parseInt(localStorage.getItem(Gi)??"",10);Zn.includes(m)&&(this.typeWpm=m)}catch{}a.dataset.typeWpm=String(this.typeWpm),this.fontIdx=Vn.indexOf(1);try{let m=parseInt(localStorage.getItem(Ki)??"",10);m>=0&&m<Vn.length&&(this.fontIdx=m)}catch{}this._applyFont();let u=(a.dataset.typeSound||"thocky").toLowerCase();this.soundName=Wn.includes(u)?u:"thocky";try{let m=localStorage.getItem(ji);m&&Wn.includes(m)&&(this.soundName=m)}catch{}this.typeSound=this.soundName==="off"?null:this.soundName,this.maxStep=(parseFloat(a.dataset.maxStep||"2.5")||2.5)*1e3,this.visibleRows=parseInt(a.dataset.rows||"",10)||Math.min(l.meta.rows||Ui,Ui),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,vd(),this.playing){this.playing=!1;let a=this.controlsEl?.querySelector(".terminal-play");a&&(a.textContent="\u25B6")}}_watchSlide(){let a=this.el.closest("section");if(!a||typeof MutationObserver!="function")return;new MutationObserver(()=>{a.classList.contains("active")||this.stop()}).observe(a,{attributes:!0,attributeFilter:["class"]})}_mountChrome(){let a=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">${vt(a)}</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(a,{withCursor:l=!0}={}){let d=[];for(let u=0;u<a;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(`
348
- `),this._scrollToEnd()}_stepEvents(a){return[...(a.output||[]).map(([l,d])=>({t:l,kind:"o",d})),...(a.input||[]).map(([l,d])=>({t:l,kind:"i",d:d.replace(/\r?\n$/,"")}))].sort((l,d)=>l.t-d.t)}_stepHtml(a){let l=new Pn;for(let u of this._stepEvents(a))l.write(u.d);let d=l.toHtml();return a.raw?d:this._promptHtml()+`<span class="terminal-cmd">${vt(a.cmd)}</span>`+(d?`
349
- `+d:"")}_promptHtml(){return`<span class="terminal-prompt">${vt(this.prompt)}</span>`}_scrollToEnd(){this.screenEl.scrollTop=this.screenEl.scrollHeight}_applyFont(){let a=Vn[this.fontIdx];this.el.style.fontSize=a===1?"":`${a}em`}_mountFontButton(){let a=document.createElement("button");a.className="terminal-btn terminal-fontsize",a.title="font size: click cycles 75% to 160%",a.setAttribute("aria-label","font size");let l=()=>{a.textContent=`A ${Math.round(Vn[this.fontIdx]*100)}%`};l(),a.addEventListener("click",()=>{this.fontIdx=(this.fontIdx+1)%Vn.length,this._applyFont();try{localStorage.setItem(Ki,String(this.fontIdx))}catch{}l()}),this.controlsEl.appendChild(a)}_mountSpeedButton(){let a=document.createElement("button");a.className="terminal-btn terminal-typespeed",a.title="typing speed: click cycles words per minute",a.setAttribute("aria-label","typing speed");let l=()=>{a.textContent=`\u2328 ${this.typeWpm} wpm`};l(),a.addEventListener("click",()=>{let d=(Zn.indexOf(this.typeWpm)+1)%Zn.length;this.typeWpm=Zn[d],this.el.dataset.typeWpm=String(this.typeWpm);try{localStorage.setItem(Gi,String(this.typeWpm))}catch{}l()}),this.controlsEl.appendChild(a)}_mountSoundButton(){let a=document.createElement("button");a.className="terminal-btn terminal-typesound",a.title="key sound: click cycles thocky, creamy, clacky, off",a.setAttribute("aria-label","key sound");let l=()=>{a.textContent=`\u266A ${this.soundName}`};l(),a.addEventListener("click",()=>{let d=(Wn.indexOf(this.soundName)+1)%Wn.length;this.soundName=Wn[d],this.typeSound=this.soundName==="off"?null:this.soundName,this.el.dataset.typeSound=this.soundName;try{localStorage.setItem(ji,this.soundName)}catch{}this.typeSound&&Er("a",this.typeSound,.12),l()}),this.controlsEl.appendChild(a)}_typeFactor(a,l=!1){return(l&&this.speed||1)*(this.typeWpm/Hi)*(a.typeSpeed||1)}async _typeCmd(a,l,d,u,m=!1){for(let f=1;f<=a.length;f++){if(this.epoch!==u)return!1;let h=a[f-1],w=ss(h)/this._typeFactor(d,m);this.typeSound&&Er(h,this.typeSound,w/1e3),this.linesEl.innerHTML=l+this._promptHtml()+`<span class="terminal-cmd">${vt(a.slice(0,f))}</span><span class="terminal-cursor"></span>`,this._scrollToEnd(),await pn(w)}return!0}mountStepMode(a){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),!a||typeof a.registerBuildProvider!="function"){this._renderComplete(l.length,{withCursor:!1});return}a.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(a){this.epoch+=1;let l=a===this.applied+1;if(this.applied=a,!l){this._renderComplete(a);return}this._animateStep(a-1,this.epoch)}async _animateStep(a,l){let d=this.playable[a],u=[];for(let C=0;C<a;C++)u.push(this._stepHtml(this.playable[C]));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(`
350
376
  `)+`
351
- `:"",f=d.cmd||"";if(!d.raw){if(!await this._typeCmd(f,m,d,l))return;await pn(120/this._typeFactor(d))}let h=this._stepEvents(d),w=h.length?h[h.length-1].t*1e3:0,k=w>this.maxStep?this.maxStep/w:1,A=new Pn,I=()=>{let C=A.toHtml();this.linesEl.innerHTML=d.raw?m+C:m+this._promptHtml()+`<span class="terminal-cmd">${vt(f)}</span>`+(C?`
352
- `+C:""),this._scrollToEnd()},M=0;for(let C of h){let $=Math.min((C.t-M)*1e3*k,400);if(M=C.t,$>8&&await pn($),this.epoch!==l)return;if(C.kind==="i")for(let q of C.d){if(this.epoch!==l)return;let he=ss(q)/this._typeFactor(d);this.typeSound&&Er(q,this.typeSound,he/1e3),A.write(q),I(),await pn(he)}else A.write(C.d),I()}this.epoch===l&&this._renderComplete(a+1)}mountPlayMode(){let a=[1,2,4],l=parseFloat(this.el.dataset.speed);this.speed=a.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(a){this.stop(),a.textContent="\u25B6",this._playedUpTo=0,this._renderComplete(0)}async _playAll(a){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 pn(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(C=>!C.hidden&&C.sleep==null).map(C=>this._stepHtml(C)),w=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(`
353
379
  `)+`
354
- `:"",k=m.cmd||"";if(!m.raw&&!await this._typeCmd(k,w,m,l,!0)){this._playedUpTo=u;return}let A=new Pn,I=()=>{let C=A.toHtml();this.linesEl.innerHTML=m.raw?w+C:w+this._promptHtml()+`<span class="terminal-cmd">${vt(k)}</span>`+(C?`
355
- `+C:""),this._scrollToEnd()},M=0;for(let C of this._stepEvents(m)){let $=(C.t-M)*1e3/this.speed;if(M=C.t,$>4&&await pn($),this.epoch!==l){this._playedUpTo=u;return}if(C.kind==="i")for(let q of C.d){if(this.epoch!==l){this._playedUpTo=u;return}let he=ss(q)/this._typeFactor(m,!0);this.typeSound&&Er(q,this.typeSound,he/1e3),A.write(q),I(),await pn(he)}else A.write(C.d),I()}await pn(350/this.speed),this._playedUpTo=u+1}this.playing=!1,a.textContent="\u25B6",this._playedUpTo=0,this._renderComplete(this.playable.length,{withCursor:!0})}};function pn(r){return new Promise(a=>setTimeout(a,r))}var Nd="0.5.0";function $d(r={}){let a=Fi(r),l=is||(void 0)?.registerTerminals;return typeof l=="function"&&Promise.resolve(l({registerBuildProvider:Kn},document)).catch(d=>console.error("Decklight: terminal subsystem failed to initialize",d)),a}function Od(r=document){let a=is||(void 0)?.registerTerminals;return typeof a=="function"?Promise.resolve(a({registerBuildProvider:Kn},r)):Promise.resolve()}return Va(Md);})();
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);})();
356
382
  //# sourceMappingURL=decklight.js.map