decklight 0.8.0 → 0.9.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.
- package/PLATFORM.md +666 -0
- package/README.md +224 -150
- package/SPEC.md +732 -886
- package/cli/agent-review.mjs +245 -0
- package/cli/agents.mjs +25 -5
- package/cli/associate.mjs +12 -12
- package/cli/audit.mjs +42 -10
- package/cli/banner.mjs +41 -17
- package/cli/bundle-audio.mjs +183 -0
- package/cli/bundle.mjs +383 -31
- package/cli/cast.mjs +7 -7
- package/cli/check.mjs +961 -0
- package/cli/clone-deck.mjs +179 -0
- package/cli/commands.mjs +345 -0
- package/cli/comments.mjs +64 -18
- package/cli/commit-flow.mjs +44 -19
- package/cli/commit-message.mjs +51 -74
- package/cli/commit-split.mjs +601 -0
- package/cli/deck-refs.mjs +59 -0
- package/cli/deck-routes.mjs +67 -0
- package/cli/deckfile.mjs +3 -5
- package/cli/decklight.mjs +68 -289
- package/cli/design-system-deps.mjs +209 -0
- package/cli/design-system-edit.mjs +194 -0
- package/cli/design-system-refs.mjs +409 -0
- package/cli/design-system.mjs +429 -0
- package/cli/doctor.mjs +115 -0
- package/cli/edit-git.mjs +353 -0
- package/cli/edit-handover.mjs +445 -0
- package/cli/edit-look.mjs +388 -0
- package/cli/edit-slides.mjs +683 -0
- package/cli/edit.mjs +2126 -842
- package/cli/enhance.mjs +483 -0
- package/cli/extension.mjs +10 -10
- package/cli/font-refs.mjs +273 -0
- package/cli/font.mjs +246 -0
- package/cli/git-tree.mjs +1 -1
- package/cli/git.mjs +65 -11
- package/cli/import.mjs +56 -10
- package/cli/init.mjs +400 -234
- package/cli/library.mjs +127 -0
- package/cli/loader.mjs +3 -1
- package/cli/marketplace.mjs +215 -21
- package/cli/narrate.mjs +176 -0
- package/cli/open-browser.mjs +63 -0
- package/cli/open.mjs +943 -0
- package/cli/pdf.mjs +41 -13
- package/cli/pkg.mjs +44 -2
- package/cli/plugin.mjs +43 -41
- package/cli/port-conflict.mjs +53 -23
- package/cli/pptx-export.mjs +71 -26
- package/cli/publish.mjs +8 -4
- package/cli/qr.mjs +1 -1
- package/cli/record.mjs +14 -12
- package/cli/remote.mjs +11 -11
- package/cli/restore.mjs +11 -4
- package/cli/review-ref.mjs +125 -0
- package/cli/review-remote.mjs +92 -48
- package/cli/review-routes.mjs +254 -0
- package/cli/review-store.mjs +47 -7
- package/cli/review-submit.mjs +47 -57
- package/cli/runtime-link.mjs +560 -0
- package/cli/serve.mjs +235 -44
- package/cli/setup.mjs +112 -0
- package/cli/sign.mjs +1 -1
- package/cli/skill-content.mjs +190 -33
- package/cli/skills.mjs +107 -24
- package/cli/start.mjs +110 -0
- package/cli/supervise.mjs +6 -6
- package/cli/theme-refs.mjs +515 -0
- package/cli/theme.mjs +181 -137
- package/cli/trust.mjs +83 -0
- package/cli/units.mjs +39 -42
- package/cli/update-check.mjs +1 -5
- package/cli/upgrade.mjs +194 -28
- package/cli/upstream.mjs +4 -3
- package/cli/util.mjs +4 -4
- package/cli/wizard.mjs +6 -6
- package/dist/build-info.json +1 -1
- package/dist/decklight.css +1126 -49
- package/dist/decklight.js +212 -115
- package/dist/decklight.js.map +4 -4
- package/docs/GLOSSARY.md +141 -0
- package/docs/architecture.svg +17 -17
- package/package.json +4 -2
- package/themes/README.md +9 -8
- package/themes/reveal-solarized.css +10 -0
- package/tools/args.mjs +20 -0
- package/tools/atomic-write.mjs +48 -0
- package/tools/brand-palette.mjs +717 -0
- package/tools/bridge.mjs +1 -1
- package/tools/build-groups.mjs +42 -0
- package/tools/color.mjs +48 -0
- package/tools/deck-html.mjs +396 -11
- package/tools/design-system-format.mjs +753 -0
- package/tools/elevenlabs-tts.mjs +110 -17
- package/tools/exec.mjs +35 -2
- package/tools/extension-check.mjs +31 -7
- package/tools/font-format.mjs +190 -0
- package/tools/font-stacks.mjs +24 -0
- package/tools/gemini-tts.mjs +3 -0
- package/tools/lipsync-config.mjs +103 -0
- package/tools/lipsync-engines.mjs +205 -2
- package/tools/lipsync-server.mjs +264 -41
- package/tools/lipsync.mjs +37 -18
- package/tools/local-voice.mjs +32 -42
- package/tools/narration-manifest.mjs +196 -0
- package/tools/narration-synth.mjs +416 -0
- package/tools/pptx.mjs +776 -19
- package/tools/publish-targets.mjs +1 -1
- package/tools/publish-voices.mjs +3 -3
- package/tools/recording-impact.mjs +7 -3
- package/tools/render-theme.mjs +33 -0
- package/tools/review-anchor.mjs +28 -12
- package/tools/semver.mjs +40 -0
- package/tools/sentences.mjs +180 -0
- package/tools/shot.mjs +14 -7
- package/tools/site-voices.mjs +232 -0
- package/tools/template-theme.mjs +1 -1
- package/tools/test-impact.mjs +19 -10
- package/tools/theme-check.mjs +30 -3
- package/tools/tts-cache.mjs +4 -3
- package/tools/tts-engines.mjs +38 -20
- package/tools/tts-setup.mjs +7 -7
- package/tools/video-options.mjs +34 -0
- package/tools/video.mjs +461 -48
- package/tools/voiceover-server.mjs +185 -104
- package/tools/voiceover.mjs +119 -261
- package/tools/zip.mjs +1 -1
- package/cli/dev.mjs +0 -623
- package/cli/present.mjs +0 -853
- package/cli/review.mjs +0 -361
- package/tools/publish-site-voices.mjs +0 -75
package/dist/decklight.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/*! Decklight v0.
|
|
2
|
-
var Decklight=(()=>{var wl=Object.create;var gs=Object.defineProperty;var vl=Object.getOwnPropertyDescriptor;var xl=Object.getOwnPropertyNames;var kl=Object.getPrototypeOf,El=Object.prototype.hasOwnProperty;var zo=(t,o)=>()=>(t&&(o=t(t=0)),o);var Sl=(t,o)=>()=>(o||t((o={exports:{}}).exports,o),o.exports),Al=(t,o)=>{for(var a in o)gs(t,a,{get:o[a],enumerable:!0})},Uo=(t,o,a,c)=>{if(o&&typeof o=="object"||typeof o=="function")for(let d of xl(o))!El.call(t,d)&&d!==a&&gs(t,d,{get:()=>o[d],enumerable:!(c=vl(o,d))||c.enumerable});return t};var _l=(t,o,a)=>(a=t!=null?wl(kl(t)):{},Uo(o||!t||!t.__esModule?gs(a,"default",{value:t,enumerable:!0}):a,t)),Tl=t=>Uo(gs({},"__esModule",{value:!0}),t);var at,me=zo(()=>{at={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 it,fe=zo(()=>{it=["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 Ni=Sl((Xu,Ci)=>{me();fe();function bi(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)&&bi(a)}),t}var xs=class{constructor(o){o.data===void 0&&(o.data={}),this.data=o.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function yi(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ar(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 sc="</span>",ui=t=>!!t.scope,oc=(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}`},to=class{constructor(o,a){this.buffer="",this.classPrefix=a.classPrefix,o.walk(this)}addText(o){this.buffer+=yi(o)}openNode(o){if(!ui(o))return;let a=oc(o.scope,{prefix:this.classPrefix});this.span(a)}closeNode(o){ui(o)&&(this.buffer+=sc)}value(){return this.buffer}span(o){this.buffer+=`<span class="${o}">`}},pi=(t={})=>{let o={children:[]};return Object.assign(o,t),o},no=class t{constructor(){this.rootNode=pi(),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=pi({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)}))}},ro=class extends no{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 to(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}};function Zr(t){return t?typeof t=="string"?t:t.source:null}function wi(t){return br("(?=",t,")")}function ic(t){return br("(?:",t,")*")}function ac(t){return br("(?:",t,")?")}function br(...t){return t.map(a=>Zr(a)).join("")}function lc(t){let o=t[t.length-1];return typeof o=="object"&&o.constructor===Object?(t.splice(t.length-1,1),o):{}}function oo(...t){return"("+(lc(t).capture?"":"?:")+t.map(c=>Zr(c)).join("|")+")"}function vi(t){return new RegExp(t.toString()+"|").exec("").length-1}function cc(t,o){let a=t&&t.exec(o);return a&&a.index===0}var dc=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function io(t,{joinWith:o}){let a=0;return t.map(c=>{a+=1;let d=a,p=Zr(c),f="";for(;p.length>0;){let m=dc.exec(p);if(!m){f+=p;break}f+=p.substring(0,m.index),p=p.substring(m.index+m[0].length),m[0][0]==="\\"&&m[1]?f+="\\"+String(Number(m[1])+d):(f+=m[0],m[0]==="("&&a++)}return f}).map(c=>`(${c})`).join(o)}var uc=/\b\B/,xi="[a-zA-Z]\\w*",ao="[a-zA-Z_]\\w*",ki="\\b\\d+(\\.\\d+)?",Ei="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",Si="\\b(0b[01]+)",pc="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",hc=(t={})=>{let o=/^#![ ]*\//;return t.binary&&(t.begin=br(o,/.*\b/,t.binary,/\b.*/)),ar({scope:"meta",begin:o,end:/$/,relevance:0,"on:begin":(a,c)=>{a.index!==0&&c.ignoreMatch()}},t)},Jr={begin:"\\\\[\\s\\S]",relevance:0},mc={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[Jr]},fc={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[Jr]},gc={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/},Es=function(t,o,a={}){let c=ar({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=oo("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},bc=Es("//","$"),yc=Es("/\\*","\\*/"),wc=Es("#","$"),vc={scope:"number",begin:ki,relevance:0},xc={scope:"number",begin:Ei,relevance:0},kc={scope:"number",begin:Si,relevance:0},Ec={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[Jr,{begin:/\[/,end:/\]/,relevance:0,contains:[Jr]}]},Sc={scope:"title",begin:xi,relevance:0},Ac={scope:"title",begin:ao,relevance:0},_c={begin:"\\.\\s*"+ao,relevance:0},Tc=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()}})},vs=Object.freeze({__proto__:null,APOS_STRING_MODE:mc,BACKSLASH_ESCAPE:Jr,BINARY_NUMBER_MODE:kc,BINARY_NUMBER_RE:Si,COMMENT:Es,C_BLOCK_COMMENT_MODE:yc,C_LINE_COMMENT_MODE:bc,C_NUMBER_MODE:xc,C_NUMBER_RE:Ei,END_SAME_AS_BEGIN:Tc,HASH_COMMENT_MODE:wc,IDENT_RE:xi,MATCH_NOTHING_RE:uc,METHOD_GUARD:_c,NUMBER_MODE:vc,NUMBER_RE:ki,PHRASAL_WORDS_MODE:gc,QUOTE_STRING_MODE:fc,REGEXP_MODE:Ec,RE_STARTERS_RE:pc,SHEBANG:hc,TITLE_MODE:Sc,UNDERSCORE_IDENT_RE:ao,UNDERSCORE_TITLE_MODE:Ac});function $c(t,o){t.input[t.index-1]==="."&&o.ignoreMatch()}function Cc(t,o){t.className!==void 0&&(t.scope=t.className,delete t.className)}function Nc(t,o){o&&t.beginKeywords&&(t.begin="\\b("+t.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",t.__beforeBegin=$c,t.keywords=t.keywords||t.beginKeywords,delete t.beginKeywords,t.relevance===void 0&&(t.relevance=0))}function Mc(t,o){Array.isArray(t.illegal)&&(t.illegal=oo(...t.illegal))}function Oc(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 Lc(t,o){t.relevance===void 0&&(t.relevance=1)}var Rc=(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,wi(a.begin)),t.starts={relevance:0,contains:[Object.assign(a,{endsParent:!0})]},t.relevance=0,delete a.beforeMatch},Ic=["of","and","for","in","not","or","if","then","parent","list","value"],Pc="keyword";function Ai(t,o,a=Pc){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,Ai(t[p],o,p))}),c;function d(p,f){o&&(f=f.map(m=>m.toLowerCase())),f.forEach(function(m){let v=m.split("|");c[v[0]]=[p,Bc(v[0],v[1])]})}}function Bc(t,o){return o?Number(o):Dc(t)?0:1}function Dc(t){return Ic.includes(t.toLowerCase())}var hi={},gr=t=>{console.error(t)},mi=(t,...o)=>{console.log(`WARN: ${t}`,...o)},Cr=(t,o)=>{hi[`${t}/${o}`]||(console.log(`Deprecated as of ${t}. ${o}`),hi[`${t}/${o}`]=!0)},ks=new Error;function _i(t,o,{key:a}){let c=0,d=t[a],p={},f={};for(let m=1;m<=o.length;m++)f[m+c]=d[m],p[m+c]=!0,c+=vi(o[m-1]);t[a]=f,t[a]._emit=p,t[a]._multi=!0}function qc(t){if(Array.isArray(t.begin)){if(t.skip||t.excludeBegin||t.returnBegin)throw gr("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),ks;if(typeof t.beginScope!="object"||t.beginScope===null)throw gr("beginScope must be object"),ks;_i(t,t.begin,{key:"beginScope"}),t.begin=io(t.begin,{joinWith:""})}}function Fc(t){if(Array.isArray(t.end)){if(t.skip||t.excludeEnd||t.returnEnd)throw gr("skip, excludeEnd, returnEnd not compatible with endScope: {}"),ks;if(typeof t.endScope!="object"||t.endScope===null)throw gr("endScope must be object"),ks;_i(t,t.end,{key:"endScope"}),t.end=io(t.end,{joinWith:""})}}function zc(t){t.scope&&typeof t.scope=="object"&&t.scope!==null&&(t.beginScope=t.scope,delete t.scope)}function Uc(t){zc(t),typeof t.beginScope=="string"&&(t.beginScope={_wrap:t.beginScope}),typeof t.endScope=="string"&&(t.endScope={_wrap:t.endScope}),qc(t),Fc(t)}function Hc(t){function o(f,m){return new RegExp(Zr(f),"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,v){v.position=this.position++,this.matchIndexes[this.matchAt]=v,this.regexes.push([v,m]),this.matchAt+=vi(m)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);let m=this.regexes.map(v=>v[1]);this.matcherRe=o(io(m,{joinWith:"|"}),!0),this.lastIndex=0}exec(m){this.matcherRe.lastIndex=this.lastIndex;let v=this.matcherRe.exec(m);if(!v)return null;let k=v.findIndex((P,T)=>T>0&&P!==void 0),S=this.matchIndexes[k];return v.splice(0,k),Object.assign(v,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 v=new a;return this.rules.slice(m).forEach(([k,S])=>v.addRule(k,S)),v.compile(),this.multiRegexes[m]=v,v}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(m,v){this.rules.push([m,v]),v.type==="begin"&&this.count++}exec(m){let v=this.getMatcher(this.regexIndex);v.lastIndex=this.lastIndex;let k=v.exec(m);if(this.resumingScanAtSamePosition()&&!(k&&k.index===this.lastIndex)){let S=this.getMatcher(0);S.lastIndex=this.lastIndex+1,k=S.exec(m)}return k&&(this.regexIndex+=k.position+1,this.regexIndex===this.count&&this.considerAll()),k}}function d(f){let m=new c;return f.contains.forEach(v=>m.addRule(v.begin,{rule:v,type:"begin"})),f.terminatorEnd&&m.addRule(f.terminatorEnd,{type:"end"}),f.illegal&&m.addRule(f.illegal,{type:"illegal"}),m}function p(f,m){let v=f;if(f.isCompiled)return v;[Cc,Oc,Uc,Rc].forEach(S=>S(f,m)),t.compilerExtensions.forEach(S=>S(f,m)),f.__beforeBegin=null,[Nc,Mc,Lc].forEach(S=>S(f,m)),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=Ai(f.keywords,t.case_insensitive)),v.keywordPatternRe=o(k,!0),m&&(f.begin||(f.begin=/\B|\b/),v.beginRe=o(v.begin),!f.end&&!f.endsWithParent&&(f.end=/\B|\b/),f.end&&(v.endRe=o(v.end)),v.terminatorEnd=Zr(v.end)||"",f.endsWithParent&&m.terminatorEnd&&(v.terminatorEnd+=(f.end?"|":"")+m.terminatorEnd)),f.illegal&&(v.illegalRe=o(f.illegal)),f.contains||(f.contains=[]),f.contains=[].concat(...f.contains.map(function(S){return jc(S==="self"?f:S)})),f.contains.forEach(function(S){p(S,v)}),f.starts&&p(f.starts,m),v.matcher=d(v),v}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=ar(t.classNameAliases||{}),p(t)}function Ti(t){return t?t.endsWithParent||Ti(t.starts):!1}function jc(t){return t.variants&&!t.cachedVariants&&(t.cachedVariants=t.variants.map(function(o){return ar(t,{variants:null},o)})),t.cachedVariants?t.cachedVariants:Ti(t)?ar(t,{starts:t.starts?ar(t.starts):null}):Object.isFrozen(t)?ar(t):t}var Gc="11.11.1",so=class extends Error{constructor(o,a){super(o),this.name="HTMLInjectionError",this.html=a}},eo=yi,fi=ar,gi=Symbol("nomatch"),Kc=7,$i=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?",f={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:ro};function v(Q){return m.noHighlightRe.test(Q)}function k(Q){let j=Q.className+" ";j+=Q.parentNode?Q.parentNode.className:"";let oe=m.languageDetectRe.exec(j);if(oe){let he=$e(oe[1]);return he||(mi(p.replace("{}",oe[1])),mi("Falling back to no-highlight mode for this block.",Q)),he?oe[1]:"no-highlight"}return j.split(/\s+/).find(he=>v(he)||$e(he))}function S(Q,j,oe){let he="",le="";typeof j=="object"?(he=Q,oe=j.ignoreIllegals,le=j.language):(Cr("10.7.0","highlight(lang, code, ...args) has been deprecated."),Cr("10.7.0",`Please use highlight(code, options) instead.
|
|
3
|
-
https://github.com/highlightjs/highlight.js/issues/2277`),
|
|
4
|
-
`,1;if(mt>1e5&&mt>ue.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Pe+=ie,ie.length}let Ie=$e(Q);if(!Ie)throw gr(p.replace("{}",Q)),new Error('Unknown language: "'+Q+'"');let g=Hc(Ie),J="",z=he||g,Ce={},ye=new m.__emitter(m);ee();let Pe="",X=0,Xe=0,mt=0,ft=!1;try{if(Ie.__emitTokens)Ie.__emitTokens(j,ye);else{for(z.matcher.considerAll();;){mt++,ft?ft=!1:z.matcher.considerAll(),z.matcher.lastIndex=Xe;let ke=z.matcher.exec(j);if(!ke)break;let ue=j.substring(Xe,ke.index),ie=w(ue,ke);Xe=ke.index+ie}w(j.substring(Xe))}return ye.finalize(),J=ye.toHTML(),{language:Q,value:J,relevance:X,illegal:!1,_emitter:ye,_top:z}}catch(ke){if(ke.message&&ke.message.includes("Illegal"))return{language:Q,value:eo(j),illegal:!0,relevance:0,_illegalBy:{message:ke.message,index:Xe,context:j.slice(Xe-100,Xe+100),mode:ke.mode,resultSoFar:J},_emitter:ye};if(d)return{language:Q,value:eo(j),illegal:!1,relevance:0,errorRaised:ke,_emitter:ye,_top:z};throw ke}}function T(Q){let j={value:eo(Q),illegal:!1,relevance:0,_top:f,_emitter:new m.__emitter(m)};return j._emitter.addText(Q),j}function A(Q,j){j=j||m.languages||Object.keys(o);let oe=T(Q),he=j.filter($e).filter(Ze).map(i=>P(i,Q,!1));he.unshift(oe);let le=he.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}),[Re,Y]=le,s=Re;return s.secondBest=Y,s}function N(Q,j,oe){let he=j&&a[j]||oe;Q.classList.add("hljs"),Q.classList.add(`language-${he}`)}function I(Q){let j=null,oe=k(Q);if(v(oe))return;if(gt("before:highlightElement",{el:Q,language:oe}),Q.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",Q);return}if(Q.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(Q)),m.throwUnescapedHTML))throw new so("One of your code blocks includes unescaped HTML.",Q.innerHTML);j=Q;let he=j.textContent,le=oe?S(he,{language:oe,ignoreIllegals:!0}):A(he);Q.innerHTML=le.value,Q.dataset.highlighted="yes",N(Q,oe,le.language),Q.result={language:le.language,re:le.relevance,relevance:le.relevance},le.secondBest&&(Q.secondBest={language:le.secondBest.language,relevance:le.secondBest.relevance}),gt("after:highlightElement",{el:Q,result:le,text:he})}function Se(Q){m=fi(m,Q)}let pe=()=>{ce(),Cr("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Oe(){ce(),Cr("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let re=!1;function ce(){function Q(){ce()}if(document.readyState==="loading"){re||window.addEventListener("DOMContentLoaded",Q,!1),re=!0;return}document.querySelectorAll(m.cssSelector).forEach(I)}function Me(Q,j){let oe=null;try{oe=j(t)}catch(he){if(gr("Language definition for '{}' could not be registered.".replace("{}",Q)),d)gr(he);else throw he;oe=f}oe.name||(oe.name=Q),o[Q]=oe,oe.rawDefinition=j.bind(null,t),oe.aliases&&_e(oe.aliases,{languageName:Q})}function ze(Q){delete o[Q];for(let j of Object.keys(a))a[j]===Q&&delete a[j]}function Ve(){return Object.keys(o)}function $e(Q){return Q=(Q||"").toLowerCase(),o[Q]||o[a[Q]]}function _e(Q,{languageName:j}){typeof Q=="string"&&(Q=[Q]),Q.forEach(oe=>{a[oe.toLowerCase()]=j})}function Ze(Q){let j=$e(Q);return j&&!j.disableAutodetect}function bt(Q){Q["before:highlightBlock"]&&!Q["before:highlightElement"]&&(Q["before:highlightElement"]=j=>{Q["before:highlightBlock"](Object.assign({block:j.el},j))}),Q["after:highlightBlock"]&&!Q["after:highlightElement"]&&(Q["after:highlightElement"]=j=>{Q["after:highlightBlock"](Object.assign({block:j.el},j))})}function _(Q){bt(Q),c.push(Q)}function je(Q){let j=c.indexOf(Q);j!==-1&&c.splice(j,1)}function gt(Q,j){let oe=Q;c.forEach(function(he){he[oe]&&he[oe](j)})}function ut(Q){return Cr("10.7.0","highlightBlock will be removed entirely in v12.0"),Cr("10.7.0","Please use highlightElement now."),I(Q)}Object.assign(t,{highlight:S,highlightAuto:A,highlightAll:ce,highlightElement:I,highlightBlock:ut,configure:Se,initHighlighting:pe,initHighlightingOnLoad:Oe,registerLanguage:Me,unregisterLanguage:ze,listLanguages:Ve,getLanguage:$e,registerAliases:_e,autoDetection:Ze,inherit:fi,addPlugin:_,removePlugin:je}),t.debugMode=function(){d=!1},t.safeMode=function(){d=!0},t.versionString=Gc,t.regex={concat:br,lookahead:wi,either:oo,optional:ac,anyNumberOfTimes:ic};for(let Q in vs)typeof vs[Q]=="object"&&bi(vs[Q]);return Object.assign(t,vs),t},Nr=$i({});Nr.newInstance=()=>$i({});Ci.exports=Nr;Nr.HighlightJS=Nr;Nr.default=Nr});var vu={};Al(vu,{init:()=>yu,initTerminals:()=>wu,registerBuildProvider:()=>es,version:()=>bu});me();fe();me();fe();me();fe();var Nl=new Set(["UL","OL","TABLE","TBODY","DL","SVG"]),Ml=new Set(["defs","title","desc","style","metadata"]),Go=new Map;function Ko(t,o){Go.set(t,o)}function ys(t){return[...t.children].filter(o=>{let a=o.tagName.toLowerCase();return!(Ml.has(a)||a==="aside"&&o.classList.contains("notes")||o.hasAttribute("data-build-stay"))})}function Ol(t){if(t.hasAttribute("data-build-self"))return!1;let o=t.tagName.toUpperCase();return Nl.has(o)?!0:o==="DIV"||o==="G"?ys(t).length>=2:!1}function Ll(t){if(t.tagName.toUpperCase()==="TABLE"){let a=t.querySelector(":scope > tbody");return a?ys(a):ys(t).filter(c=>c.tagName==="TR")}return ys(t)}function Rl(t){let o=t.map((f,m)=>({...f,i:m}));o.sort((f,m)=>f.key-m.key||f.i-m.i);let a=[],c=null,d=null,p=!1;for(let f of o){if(c&&f.explicit&&p&&f.key===d){c.push(f.i);continue}c=[f.i],d=f.key,p=f.explicit,a.push(c)}return a}function Ho(t,o){t.classList.add("build-step"),t.setAttribute("data-build-style",o),t.setAttribute("data-build-state","pending"),o==="draw"&&Il(t)}var jo="path, line, polyline, polygon, circle, ellipse, rect";function Il(t){let o=t.matches?.(jo)?[t]:[...t.querySelectorAll(jo)],a=!1;for(let d of o){let p=d.getAttribute("stroke")??getComputedStyle(d).stroke;if(!p||p==="none")continue;let f=0;try{f=d.getTotalLength()}catch{continue}if(!f)continue;a=!0;let m=d.getAttribute("stroke-dasharray")||d.style.strokeDasharray;m&&(d.dataset.drawOrig=m);for(let[v,k]of Ys){let S=d.getAttribute(v);S&&(d.dataset[k]=S)}d.classList.add("draw-stroke"),d.style.setProperty("--draw-len",String(Math.ceil(f)))}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 bs(t,o){for(let[a,c]of Ys)c in t.dataset&&(o?t.setAttribute(a,t.dataset[c]):t.removeAttribute(a))}function Pl(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"),bs(a,!0);else if(o==="pending")a.style.removeProperty("stroke-dasharray"),a.style.removeProperty("stroke-dashoffset"),bs(a,!1);else{a.style.removeProperty("stroke-dasharray"),a.style.removeProperty("stroke-dashoffset"),bs(a,!1);let p=()=>{t.getAttribute("data-build-state")!=="pending"&&(c&&(a.style.strokeDasharray=c,a.style.strokeDashoffset="0"),bs(a,!0))},f=parseFloat(getComputedStyle(a).transitionDuration)||0;f===0?p():(a.addEventListener("transitionend",p,{once:!0}),setTimeout(p,f*1e3+150))}}}function Xs(t){let o=[],a=[],c=new Set,d=0,p=(S,P)=>{let T=P!=null&&P!=="",A=T?parseInt(P,10):d;o.push(S),a.push({key:Number.isFinite(A)?A:d,explicit:T}),d++},f=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);for(let S=f.nextNode();S;S=f.nextNode()){if(c.has(S))continue;let P=Go.get(S);if(P){for(let A=0;A<P.count;A++)p({kind:"provider",provider:P,el:S,sub:A},null);S.querySelectorAll("*").forEach(A=>c.add(A));continue}if(!S.hasAttribute("data-build"))continue;let T=S.getAttribute("data-build")||"fade";if(Ol(S)){for(let A of Ll(S)){c.add(A),A.querySelectorAll("[data-build]").forEach(I=>c.add(I));let N=A.getAttribute("data-build")||T;Ho(A,N),p({kind:"dom",el:A,container:S},A.getAttribute("data-build-order"))}S.setAttribute("data-build-container","")}else Ho(S,T),p({kind:"dom",el:S,container:null},S.getAttribute("data-build-order"))}let m=Rl(a),v=[],k=new Map;return o.forEach((S,P)=>{if(S.kind==="provider"){if(!k.has(S.provider)){let T={el:S.el,provider:S.provider,stepIdxs:[]};k.set(S.provider,T),v.push(T)}k.get(S.provider).stepIdxs.push(P)}}),{steps:o,groups:m,providers:v}}function ir(t,o){let a=new Set;t.groups.forEach((f,m)=>{for(let v of f)m<o&&a.add(v)});let c=o>0?t.groups[o-1]??[]:[],d=new Set(c),p=new Set;t.steps.forEach((f,m)=>{if(f.kind!=="dom")return;let v=d.has(m)?"current":a.has(m)?"done":"pending";f.el.setAttribute("data-build-state",v),f.el.getAttribute("data-build-style")==="draw"&&Pl(f.el,v),f.container&&p.add(f.container)});for(let f of p){let m=!!f.querySelector(':scope [data-build-style="highlight"][data-build-state="current"]');f.classList.toggle("has-current-highlight",m)}for(let f of t.providers){let m=f.stepIdxs.filter(v=>a.has(v)||d.has(v)).length;f._last!==m&&(f._last=m,f.provider.apply(m))}}function Wo(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()})}me();fe();var Vo="rect, circle, ellipse, polygon, polyline, path";function Bl(t){let o=5381;for(let a of String(t))o=(o*33^a.charCodeAt(0))>>>0;return 1+o%6}function Dl(t,o={}){let a=o[t];return typeof a=="number"?`var(--d-fill-${a})`:typeof a=="string"?a:`var(--d-fill-${Bl(t)})`}function Zo(t,o={}){let a=new Map;t.querySelectorAll("svg [data-concept]").forEach(c=>{let d=c.getAttribute("data-concept");if(!d)return;let p=Dl(d,o),f=p.match(/--d-fill-(\d)/);if(f){let v=a.get(f[1]);v&&v!==d?console.warn(`Decklight: concepts "${v}" and "${d}" share fill slot ${f[1]} \u2014 pin one explicitly via init({ concepts: { ${d}: <1-6> } })`):a.set(f[1],d)}let m=c.matches(Vo)?[c]:[...c.children].filter(v=>v.matches(Vo));for(let v of m){let k=v.getAttribute("fill")==="none"||v.style.fill==="none";v.style.setProperty(k?"stroke":"fill",p)}})}var ql=["fill","stroke","filter","clip-path","mask","marker-start","marker-mid","marker-end","style"];function Jo(t){t.querySelectorAll("svg").forEach((o,a)=>{let c=`svg${a}-`,d=new Map;if(o.querySelectorAll("[id]").forEach(f=>{let m=f.id;d.set(m,c+m),f.id=c+m}),d.size===0)return;let p=f=>f.replace(/url\(['"]?#([^'")]+)['"]?\)/g,(m,v)=>d.has(v)?`url(#${d.get(v)})`:m);o.querySelectorAll("*").forEach(f=>{for(let m of ql){let v=f.getAttribute(m);v&&v.includes("url(#")&&f.setAttribute(m,p(v))}for(let m of["href","xlink:href"]){let v=f.getAttribute(m);v&&v.startsWith("#")&&d.has(v.slice(1))&&f.setAttribute(m,"#"+d.get(v.slice(1)))}})})}me();fe();me();fe();var Nt=t=>String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");var Yo=640,Fl=360,Xo=["bar","line","area","pie","donut"],He=t=>{let o=Math.round(t*100)/100;return Object.is(o,-0)?"0":String(o)},Tr=t=>`var(--d-fill-${t%6+1})`;function zl(t,o={}){let a;if(typeof t=="string")try{a=JSON.parse(t)}catch(k){throw new Error(`invalid JSON \u2014 ${k.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(!Xo.includes(c))throw new Error(`unknown type "${c}" \u2014 use ${Xo.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((k,S)=>{if(!k||!Array.isArray(k.data))throw new Error(`series ${S+1}: "data" must be an array of numbers`);return{name:k.name!=null?String(k.name):`series ${S+1}`,concept:k.concept!=null?String(k.concept):null,data:d.map((P,T)=>{let A=Number(k.data[T]);return Number.isFinite(A)?A:null})}}),f=c==="pie"||c==="donut";if(f&&p.length>1)throw new Error("pie takes exactly one series (labels are the slices)");if(f&&!p[0].data.some(k=>k>0))throw new Error("pie needs at least one positive value");let m=Fl,v=o.aspect??a.aspect??null;if(v!=null){let k=String(v).match(/^\s*(\d+(?:\.\d+)?)\s*[:x]\s*(\d+(?:\.\d+)?)\s*$/i);if(!k||+k[1]==0)throw new Error(`bad aspect "${v}" \u2014 use "w:h", e.g. "4:3"`);m=Math.round(Yo*+k[2]/+k[1])}return{type:f?"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:Yo,height:m,build:a.build}}function Ul(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,f=(p<=1?1:p<=2?2:p<=2.5?2.5:p<=5?5:10)*d,m=Math.floor(t/f+1e-9)*f,v=Math.ceil(o/f-1e-9)*f,k=Math.max(1,Math.round((v-m)/f)),S=Array.from({length:k+1},(P,T)=>+(m+T*f).toPrecision(12));return{min:S[0],max:S[k],step:f,ticks:S}}function Hl(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 jl(t,o,a,c){let d=c.max-c.min||1,p=S=>a.y+a.h*(1-(S-c.min)/d),f=p(Math.max(c.min,Math.min(c.max,0))),m=a.w/o,v=m*.72,k=v/t.length;return t.map((S,P)=>Array.from({length:o},(T,A)=>{let N=S.data[A];if(N==null||!Number.isFinite(N))return null;let I=p(N);return{x:a.x+A*m+(m-v)/2+P*k+1,y:Math.min(I,f),w:Math.max(1,k-2),h:Math.abs(f-I),value:N}}))}function Gl(t){let o="",a=!1;for(let c of t){if(!c){a=!1;continue}o+=`${a?"L":"M"}${He(c.x)} ${He(c.y)}`,a=!0}return o}function Kl(t,o){let a=t.filter(Boolean);if(!a.length)return"";let c=`M${He(a[0].x)} ${He(o)}`;for(let d of a)c+=`L${He(d.x)} ${He(d.y)}`;return c+=`L${He(a[a.length-1].x)} ${He(o)}Z`,c}function Wl(t,o,a,c,d=0){let p=t.map(k=>Math.max(0,Number(k)||0)),f=p.reduce((k,S)=>k+S,0);if(f<=0)throw new Error("pie needs at least one positive value");let m=(k,S)=>[o+S*Math.cos(k),a+S*Math.sin(k)],v=-Math.PI/2;return p.map(k=>{let S=k/f,P=v,T=v+S*2*Math.PI;v=T;let A=(P+T)/2,N=d>0?(c+d)/2:c*.66,[I,Se]=m(A,N),[pe,Oe]=m(A,c+14),re={value:k,frac:S,mid:A,labelX:I,labelY:Se,outX:pe,outY:Oe,anchor:Math.cos(A)<-1e-6?"end":Math.cos(A)>1e-6?"start":"middle"};if(S===0)return{...re,d:""};let ce;if(S>=.9999){let[Me,ze]=m(P,c),[Ve,$e]=m(P+Math.PI,c);if(ce=`M${He(Me)} ${He(ze)}A${He(c)} ${He(c)} 0 1 1 ${He(Ve)} ${He($e)}A${He(c)} ${He(c)} 0 1 1 ${He(Me)} ${He(ze)}Z`,d>0){let[_e,Ze]=m(P,d),[bt,_]=m(P+Math.PI,d);ce+=`M${He(_e)} ${He(Ze)}A${He(d)} ${He(d)} 0 1 0 ${He(bt)} ${He(_)}A${He(d)} ${He(d)} 0 1 0 ${He(_e)} ${He(Ze)}Z`}}else{let Me=T-P>Math.PI?1:0,[ze,Ve]=m(P,c),[$e,_e]=m(T,c);if(d>0){let[Ze,bt]=m(T,d),[_,je]=m(P,d);ce=`M${He(ze)} ${He(Ve)}A${He(c)} ${He(c)} 0 ${Me} 1 ${He($e)} ${He(_e)}L${He(Ze)} ${He(bt)}A${He(d)} ${He(d)} 0 ${Me} 0 ${He(_)} ${He(je)}Z`}else ce=`M${He(o)} ${He(a)}L${He(ze)} ${He(Ve)}A${He(c)} ${He(c)} 0 ${Me} 1 ${He($e)} ${He(_e)}Z`}return{...re,d:ce}})}var $r='fill="var(--d-text)"';function Qs(t,o){return`<g class="chart-series" data-series="${o+1}" data-name="${Nt(t.name)}"`+(t.concept?` data-concept="${Nt(t.concept)}"`:"")+">"}function Vl(t,o,a){let c=t.series.flatMap(N=>N.data).filter(N=>N!=null),d=Math.min(0,...c),p=Math.max(0,...c),f=Ul(d,p===d?d+1:p,5),m=f.ticks.map(N=>Hl(N,f.step)),v=14+Math.max(...m.map(N=>N.length))*6.6+8,k={x:v,y:t.title||Qo(t)?40:18,w:t.width-v-14,h:0};k.h=t.height-k.y-34;let S=f.max-f.min||1,P=N=>k.y+k.h*(1-(N-f.min)/S);f.ticks.forEach((N,I)=>{let Se=P(N);o.push(`<line class="chart-grid" x1="${He(k.x)}" y1="${He(Se)}" x2="${He(k.x+k.w)}" y2="${He(Se)}" stroke="var(--d-muted)" stroke-opacity="0.35" stroke-width="1"/>`),o.push(`<text class="chart-tick" x="${He(k.x-8)}" y="${He(Se+4)}" text-anchor="end" font-size="11" ${$r}>${Nt(m[I])}</text>`)}),o.push(`<line class="chart-axis" x1="${He(k.x)}" y1="${He(k.y)}" x2="${He(k.x)}" y2="${He(k.y+k.h)}" stroke="var(--d-stroke)" stroke-width="1.5"/>`);let T=P(Math.max(f.min,Math.min(f.max,0)));o.push(`<line class="chart-axis" x1="${He(k.x)}" y1="${He(T)}" x2="${He(k.x+k.w)}" y2="${He(T)}" stroke="var(--d-stroke)" stroke-width="1.5"/>`);let A=k.w/t.labels.length;if(t.labels.forEach((N,I)=>{o.push(`<text class="chart-cat" x="${He(k.x+(I+.5)*A)}" y="${He(k.y+k.h+20)}" text-anchor="middle" font-size="12" ${$r}>${Nt(N)}</text>`)}),t.type==="bar"){let N=jl(t.series,t.labels.length,k,f);t.series.forEach((I,Se)=>{a.push(Qs(I,Se)),N[Se].forEach(pe=>{pe&&a.push(`<rect class="chart-bar draw-fade" x="${He(pe.x)}" y="${He(pe.y)}" width="${He(pe.w)}" height="${He(pe.h)}" rx="2" fill="${Tr(Se)}" stroke="var(--d-stroke)" stroke-width="1.5"/>`)}),a.push("</g>")})}else t.series.forEach((N,I)=>{let Se=N.data.map((re,ce)=>re==null?null:{x:k.x+(ce+.5)*A,y:P(re)}),pe=Gl(Se),Oe='stroke-linejoin="round" stroke-linecap="round"';if(a.push(Qs(N,I)),t.type==="area"&&a.push(`<path class="chart-area draw-fade" d="${Kl(Se,T)}" fill="${Tr(I)}" fill-opacity="0.35"/>`),a.push(`<g class="chart-casing"><path d="${pe}" fill="none" stroke="var(--d-stroke)" stroke-width="4.5" ${Oe}/></g>`),a.push(`<path class="chart-line" d="${pe}" fill="none" stroke="${Tr(I)}" stroke-width="2.5" ${Oe}/>`),t.type==="line")for(let re of Se)re&&a.push(`<circle class="chart-dot draw-fade" cx="${He(re.x)}" cy="${He(re.y)}" r="4" fill="${Tr(I)}" stroke="var(--d-stroke)" stroke-width="1"/>`);a.push("</g>")})}function Zl(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)),f=Wl(t.series[0].data.map(m=>m??0),c,d,p,t.donut?p*.55:0);o.push(Qs(t.series[0],0)),f.forEach((m,v)=>{m.d&&(o.push(`<path class="chart-slice draw-fade" d="${m.d}" fill="${Tr(v)}" fill-rule="evenodd" stroke="var(--d-stroke)" stroke-width="1.5" stroke-linejoin="round"/>`),o.push(`<text class="chart-cat draw-fade" x="${He(m.outX)}" y="${He(m.outY+4)}" text-anchor="${m.anchor}" font-size="12" ${$r}>${Nt(t.labels[v])}</text>`),m.frac>=.05&&o.push(`<text class="chart-value draw-fade" x="${He(m.labelX)}" y="${He(m.labelY+4)}" text-anchor="middle" font-size="12" font-weight="600" ${$r}>${Math.round(m.frac*100)}%</text>`))}),o.push("</g>")}function Qo(t){return t.legend===!0?!0:t.legend===!1?!1:t.type!=="pie"&&t.series.length>1}function Jl(t){let o=[],a=[];if(t.title&&o.push(`<text class="chart-title" x="14" y="24" font-size="15" font-weight="600" ${$r}>${Nt(t.title)}</text>`),Qo(t)){let d=t.series.map(f=>({name:f.name,w:f.name.length*6.6+24})),p=t.width-14-d.reduce((f,m)=>f+m.w,0);t.series.forEach((f,m)=>{o.push(`<rect class="chart-swatch" x="${He(p)}" y="14" width="11" height="11" rx="2" fill="${Tr(m)}" stroke="var(--d-stroke)" stroke-width="1"/>`),o.push(`<text class="chart-legend" x="${He(p+16)}" y="24" font-size="12" ${$r}>${Nt(f.name)}</text>`),p+=d[m].w})}t.type==="pie"?Zl(t,a):Vl(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="${Nt(c)}" preserveAspectRatio="xMidYMid meet"><g class="chart-chrome" data-build-stay>${o.join("")}</g>`+a.join("")+"</svg>"}function ei(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=zl(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=Jl(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)}})}me();fe();me();fe();function ws(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 Vr=["opacity","color","backgroundColor","borderRadius","fontSize"],ti=(t=Vr)=>["transform",...t.map(o=>o.replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`))];function ni(t,o,a,c=!1){let d=a?.x||1,p=a?.y||1,f=(t.rect.left-o.rect.left)/d,m=(t.rect.top-o.rect.top)/p,v=c||!o.rect.width?1:t.rect.width/o.rect.width,k=c||!o.rect.height?1:t.rect.height/o.rect.height;return{dx:f,dy:m,sx:v,sy:k}}function ri({dx:t,dy:o,sx:a,sy:c}){return!t&&!o&&a===1&&c===1?"":`translate(${t}px, ${o}px) scale(${a}, ${c})`}var si=(t,o)=>t||o||"fade";function oi(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 Yl=ti();function ii(t){let o=getComputedStyle(t),a={rect:t.getBoundingClientRect()};for(let c of Vr)a[c]=o[c];return a}function Xl(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 ai(t,o,a){let c=ws(getComputedStyle(o).getPropertyValue("--auto-animate-duration"),500),d=new Map;t.querySelectorAll("[data-id]").forEach(m=>{d.set(m.getAttribute("data-id"),ii(m))});let p=[];o.querySelectorAll("[data-id]").forEach(m=>{let v=d.get(m.getAttribute("data-id"));v&&p.push({el:m,o:v})});for(let{el:m,o:v}of p){let k=ii(m),S=Xl(m,a),P=m.children.length===0&&v.fontSize!==k.fontSize,T=ni(v,k,S,P),A=m.getAttribute("style")??"";m.style.transition="none",m.ownerSVGElement&&(m.style.transformBox="fill-box"),m.style.transformOrigin="0 0",m.style.transform=ri(T);for(let I of Vr)m.style[I]=v[I];m.offsetWidth,m.style.transition=Yl.map(I=>`${I} ${c}ms ease`).join(", "),m.style.transform="";for(let I of Vr)m.style[I]=k[I];let N=()=>{A?m.setAttribute("style",A):m.removeAttribute("style"),m.removeEventListener("transitionend",N)};m.addEventListener("transitionend",N),setTimeout(N,c+80)}let f=new Set(p.map(m=>m.el));return[...o.children].forEach(m=>{m.matches("aside.notes")||f.has(m)||[...f].some(k=>m.contains(k))||(m.classList.add("aa-fresh"),requestAnimationFrame(()=>requestAnimationFrame(()=>m.classList.add("aa-in"))),setTimeout(()=>m.classList.remove("aa-fresh","aa-in"),c+120))}),c}me();fe();me();fe();var li=function(){"use strict";class t{constructor(n,r){let l,u=" "+n,h=r&&r.loc;if(h&&h.start<=h.end){let E=h.lexer.input;l=h.start;let U=h.end;l===E.length?u+=" at end of input: ":u+=" at position "+(l+1)+`:
|
|
5
|
-
`;let V=E.slice(l,U).replace(/[^]/g,"$&\u0332"),be,Te;be=l>15?"\u2026"+E.slice(l-15,l):E.slice(0,l),Te=U+15<E.length?E.slice(U,U+15)+"\u2026":E.slice(U),u+=be+V+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={"&":"&",">":">","<":"<",'"':""","'":"'"},p=/[&><"']/g;function f(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},v=function(e){let n=m(e);return n.type==="mathord"||n.type==="textord"||n.type==="atom"},k=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]*([^\\/#?]*?)(:|�*58|�*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 T={},A={};function N({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)T[n[y]]=h;e&&u&&(A[e]=u)}function I({type:e,mathmlBuilder:n}){N({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},pe=function(e){return e.type==="ordgroup"?e.body:[e]};class Oe{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 re=function(e){return e.filter(n=>n).join(" ")},ce=function(e,n){this.classes=e||[],this.attributes={},this.style=n||{}},Me=function(e){let n=document.createElement(e);n.className=re(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},ze=function(e){let n=`<${e}`;this.classes.length&&(n+=` class="${f(re(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}="${f(this.attributes[l])}"`);n+=">";for(let l=0;l<this.children.length;l++)n+=this.children[l].toMarkup();return n+=`</${e}>`,n};class Ve{constructor(n,r,l){ce.call(this,n,l),this.children=r||[]}setAttribute(n,r){this.attributes[n]=r}toNode(){return Me.call(this,"span")}toMarkup(){return ze.call(this,"span")}}let $e=class{constructor(e){this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return f(this.text)}};class _e{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=re(this.classes));for(let r=0;r<this.children.length;r++)n.appendChild(this.children[r].toNode());return n}toMarkup(){let n=`<a href='${f(this.href)}'`;this.classes.length>0&&(n+=` class="${f(re(this.classes))}"`),n+=">";for(let r=0;r<this.children.length;r++)n+=this.children[r].toMarkup();return n+="</a>",n}}class Ze{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="${f(r)}"`),n+=">",n}}function bt(e){return new Oe(e)}class _{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=re(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+=f(this.attributes[l]),n+='"');this.classes.length>0&&(n+=` class="${f(re(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 je{constructor(n){this.text=n}toNode(){return document.createTextNode(this.text)}toMarkup(){return f(this.toText())}toText(){return this.text}}let gt=e=>{let n;return e.length===1&&e[0].type==="mrow"?(n=e.pop(),n.type="mstyle"):n=new _("mstyle",e),n},ut=e=>{let n=0;if(e.body&&Array.isArray(e.body))for(let r of e.body)n+=ut(r);else if(e.body)n+=ut(e.body);else if(e.type==="supsub")n+=ut(e.base),e.sub&&(n+=.7*ut(e.sub)),e.sup&&(n+=.7*ut(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},Q={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 je(Q[e.slice(1)]),r=new _("mo",[n]);return r.setAttribute("stretchy","true"),r},oe=["\\widetilde","\\widehat","\\widecheck","\\utilde"],he=e=>{let n=j(e.label);if(oe.includes(e.label)){let r=ut(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},le={bin:1,close:1,inner:1,open:1,punct:1,rel:1},Re={"accent-token":1,mathord:1,"op-token":1,spacing:1,textord:1},Y={math:{},text:{}};function s(e,n,r,l,u){Y[e][l]={group:n,replace:r},u&&r&&(Y[e][r]=Y[e][l])}let i="math",O="text",Ue="accent-token",B="bin",Le="close",$t="inner",W="mathord",Ae="op-token",ee="open",We="punct",w="rel",Ie="spacing",g="textord";s(i,w,"\u2261","\\equiv",!0),s(i,w,"\u227A","\\prec",!0),s(i,w,"\u227B","\\succ",!0),s(i,w,"\u223C","\\sim",!0),s(i,w,"\u27C2","\\perp",!0),s(i,w,"\u2AAF","\\preceq",!0),s(i,w,"\u2AB0","\\succeq",!0),s(i,w,"\u2243","\\simeq",!0),s(i,w,"\u224C","\\backcong",!0),s(i,w,"|","\\mid",!0),s(i,w,"\u226A","\\ll",!0),s(i,w,"\u226B","\\gg",!0),s(i,w,"\u224D","\\asymp",!0),s(i,w,"\u2225","\\parallel"),s(i,w,"\u2323","\\smile",!0),s(i,w,"\u2291","\\sqsubseteq",!0),s(i,w,"\u2292","\\sqsupseteq",!0),s(i,w,"\u2250","\\doteq",!0),s(i,w,"\u2322","\\frown",!0),s(i,w,"\u220B","\\ni",!0),s(i,w,"\u220C","\\notni",!0),s(i,w,"\u221D","\\propto",!0),s(i,w,"\u22A2","\\vdash",!0),s(i,w,"\u22A3","\\dashv",!0),s(i,w,"\u220B","\\owns"),s(i,w,"\u2258","\\arceq",!0),s(i,w,"\u2259","\\wedgeq",!0),s(i,w,"\u225A","\\veeeq",!0),s(i,w,"\u225B","\\stareq",!0),s(i,w,"\u225D","\\eqdef",!0),s(i,w,"\u225E","\\measeq",!0),s(i,w,"\u225F","\\questeq",!0),s(i,w,"\u2260","\\ne",!0),s(i,w,"\u2260","\\neq"),s(i,w,"\u2A75","\\eqeq",!0),s(i,w,"\u2A76","\\eqeqeq",!0),s(i,w,"\u2237","\\dblcolon",!0),s(i,w,"\u2254","\\coloneqq",!0),s(i,w,"\u2255","\\eqqcolon",!0),s(i,w,"\u2239","\\eqcolon",!0),s(i,w,"\u2A74","\\Coloneqq",!0),s(i,We,".","\\ldotp"),s(i,We,"\xB7","\\cdotp"),s(i,g,"#","\\#"),s(O,g,"#","\\#"),s(i,g,"&","\\&"),s(O,g,"&","\\&"),s(i,g,"\u2135","\\aleph",!0),s(i,g,"\u2200","\\forall",!0),s(i,g,"\u210F","\\hbar",!0),s(i,g,"\u2203","\\exists",!0),s(i,ee,"\u2207","\\nabla",!0),s(i,g,"\u266D","\\flat",!0),s(i,g,"\u2113","\\ell",!0),s(i,g,"\u266E","\\natural",!0),s(i,g,"\u212B","\\Angstrom",!0),s(O,g,"\u212B","\\Angstrom",!0),s(i,g,"\u2663","\\clubsuit",!0),s(i,g,"\u2667","\\varclubsuit",!0),s(i,g,"\u2118","\\wp",!0),s(i,g,"\u266F","\\sharp",!0),s(i,g,"\u2662","\\diamondsuit",!0),s(i,g,"\u2666","\\vardiamondsuit",!0),s(i,g,"\u211C","\\Re",!0),s(i,g,"\u2661","\\heartsuit",!0),s(i,g,"\u2665","\\varheartsuit",!0),s(i,g,"\u2111","\\Im",!0),s(i,g,"\u2660","\\spadesuit",!0),s(i,g,"\u2664","\\varspadesuit",!0),s(i,g,"\u2640","\\female",!0),s(i,g,"\u2642","\\male",!0),s(i,g,"\xA7","\\S",!0),s(O,g,"\xA7","\\S"),s(i,g,"\xB6","\\P",!0),s(O,g,"\xB6","\\P"),s(O,g,"\u263A","\\smiley",!0),s(i,g,"\u263A","\\smiley",!0),s(i,g,"\u2020","\\dag"),s(O,g,"\u2020","\\dag"),s(O,g,"\u2020","\\textdagger"),s(i,g,"\u2021","\\ddag"),s(O,g,"\u2021","\\ddag"),s(O,g,"\u2021","\\textdaggerdbl"),s(i,Le,"\u23B1","\\rmoustache",!0),s(i,ee,"\u23B0","\\lmoustache",!0),s(i,Le,"\u27EF","\\rgroup",!0),s(i,ee,"\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,w,"\u27F5","\\longleftarrow",!0),s(i,w,"\u21D0","\\Leftarrow",!0),s(i,w,"\u27F8","\\Longleftarrow",!0),s(i,w,"\u27F6","\\longrightarrow",!0),s(i,w,"\u21D2","\\Rightarrow",!0),s(i,w,"\u27F9","\\Longrightarrow",!0),s(i,w,"\u2194","\\leftrightarrow",!0),s(i,w,"\u27F7","\\longleftrightarrow",!0),s(i,w,"\u21D4","\\Leftrightarrow",!0),s(i,w,"\u27FA","\\Longleftrightarrow",!0),s(i,w,"\u21A4","\\mapsfrom",!0),s(i,w,"\u21A6","\\mapsto",!0),s(i,w,"\u27FC","\\longmapsto",!0),s(i,w,"\u2197","\\nearrow",!0),s(i,w,"\u21A9","\\hookleftarrow",!0),s(i,w,"\u21AA","\\hookrightarrow",!0),s(i,w,"\u2198","\\searrow",!0),s(i,w,"\u21BC","\\leftharpoonup",!0),s(i,w,"\u21C0","\\rightharpoonup",!0),s(i,w,"\u2199","\\swarrow",!0),s(i,w,"\u21BD","\\leftharpoondown",!0),s(i,w,"\u21C1","\\rightharpoondown",!0),s(i,w,"\u2196","\\nwarrow",!0),s(i,w,"\u21CC","\\rightleftharpoons",!0),s(i,W,"\u21AF","\\lightning",!0),s(i,W,"\u220E","\\QED",!0),s(i,W,"\u2030","\\permil",!0),s(O,g,"\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,w,"\u226E","\\nless",!0),s(i,w,"\u2A87","\\lneq",!0),s(i,w,"\u2268","\\lneqq",!0),s(i,w,"\u2268\uFE00","\\lvertneqq"),s(i,w,"\u22E6","\\lnsim",!0),s(i,w,"\u2A89","\\lnapprox",!0),s(i,w,"\u2280","\\nprec",!0),s(i,w,"\u22E0","\\npreceq",!0),s(i,w,"\u22E8","\\precnsim",!0),s(i,w,"\u2AB9","\\precnapprox",!0),s(i,w,"\u2241","\\nsim",!0),s(i,w,"\u2224","\\nmid",!0),s(i,w,"\u2224","\\nshortmid"),s(i,w,"\u22AC","\\nvdash",!0),s(i,w,"\u22AD","\\nvDash",!0),s(i,w,"\u22EA","\\ntriangleleft"),s(i,w,"\u22EC","\\ntrianglelefteq",!0),s(i,w,"\u2284","\\nsubset",!0),s(i,w,"\u2285","\\nsupset",!0),s(i,w,"\u228A","\\subsetneq",!0),s(i,w,"\u228A\uFE00","\\varsubsetneq"),s(i,w,"\u2ACB","\\subsetneqq",!0),s(i,w,"\u2ACB\uFE00","\\varsubsetneqq"),s(i,w,"\u226F","\\ngtr",!0),s(i,w,"\u2A88","\\gneq",!0),s(i,w,"\u2269","\\gneqq",!0),s(i,w,"\u2269\uFE00","\\gvertneqq"),s(i,w,"\u22E7","\\gnsim",!0),s(i,w,"\u2A8A","\\gnapprox",!0),s(i,w,"\u2281","\\nsucc",!0),s(i,w,"\u22E1","\\nsucceq",!0),s(i,w,"\u22E9","\\succnsim",!0),s(i,w,"\u2ABA","\\succnapprox",!0),s(i,w,"\u2246","\\ncong",!0),s(i,w,"\u2226","\\nparallel",!0),s(i,w,"\u2226","\\nshortparallel"),s(i,w,"\u22AF","\\nVDash",!0),s(i,w,"\u22EB","\\ntriangleright"),s(i,w,"\u22ED","\\ntrianglerighteq",!0),s(i,w,"\u228B","\\supsetneq",!0),s(i,w,"\u228B","\\varsupsetneq"),s(i,w,"\u2ACC","\\supsetneqq",!0),s(i,w,"\u2ACC\uFE00","\\varsupsetneqq"),s(i,w,"\u22AE","\\nVdash",!0),s(i,w,"\u2AB5","\\precneqq",!0),s(i,w,"\u2AB6","\\succneqq",!0),s(i,B,"\u22B4","\\unlhd"),s(i,B,"\u22B5","\\unrhd"),s(i,w,"\u219A","\\nleftarrow",!0),s(i,w,"\u219B","\\nrightarrow",!0),s(i,w,"\u21CD","\\nLeftarrow",!0),s(i,w,"\u21CF","\\nRightarrow",!0),s(i,w,"\u21AE","\\nleftrightarrow",!0),s(i,w,"\u21CE","\\nLeftrightarrow",!0),s(i,w,"\u25B3","\\vartriangle"),s(i,g,"\u210F","\\hslash"),s(i,g,"\u25BD","\\triangledown"),s(i,g,"\u25CA","\\lozenge"),s(i,g,"\u24C8","\\circledS"),s(i,g,"\xAE","\\circledR",!0),s(O,g,"\xAE","\\circledR"),s(O,g,"\xAE","\\textregistered"),s(i,g,"\u2221","\\measuredangle",!0),s(i,g,"\u2204","\\nexists"),s(i,g,"\u2127","\\mho"),s(i,g,"\u2132","\\Finv",!0),s(i,g,"\u2141","\\Game",!0),s(i,g,"\u2035","\\backprime"),s(i,g,"\u2036","\\backdprime"),s(i,g,"\u2037","\\backtrprime"),s(i,g,"\u25B2","\\blacktriangle"),s(i,g,"\u25BC","\\blacktriangledown"),s(i,g,"\u25A0","\\blacksquare"),s(i,g,"\u29EB","\\blacklozenge"),s(i,g,"\u2605","\\bigstar"),s(i,g,"\u2222","\\sphericalangle",!0),s(i,g,"\u2201","\\complement",!0),s(i,g,"\u2571","\\diagup"),s(i,g,"\u2572","\\diagdown"),s(i,g,"\u25A1","\\square"),s(i,g,"\u25A1","\\Box"),s(i,g,"\u25CA","\\Diamond"),s(i,g,"\xA5","\\yen",!0),s(O,g,"\xA5","\\yen",!0),s(i,g,"\u2713","\\checkmark",!0),s(O,g,"\u2713","\\checkmark"),s(i,g,"\u2717","\\ballotx",!0),s(O,g,"\u2717","\\ballotx"),s(O,g,"\u2022","\\textbullet"),s(i,g,"\u2136","\\beth",!0),s(i,g,"\u2138","\\daleth",!0),s(i,g,"\u2137","\\gimel",!0),s(i,g,"\u03DD","\\digamma",!0),s(i,g,"\u03F0","\\varkappa"),s(i,ee,"\u231C","\\ulcorner",!0),s(i,Le,"\u231D","\\urcorner",!0),s(i,ee,"\u231E","\\llcorner",!0),s(i,Le,"\u231F","\\lrcorner",!0),s(i,w,"\u2266","\\leqq",!0),s(i,w,"\u2A7D","\\leqslant",!0),s(i,w,"\u2A95","\\eqslantless",!0),s(i,w,"\u2272","\\lesssim",!0),s(i,w,"\u2A85","\\lessapprox",!0),s(i,w,"\u224A","\\approxeq",!0),s(i,B,"\u22D6","\\lessdot"),s(i,w,"\u22D8","\\lll",!0),s(i,w,"\u2276","\\lessgtr",!0),s(i,w,"\u22DA","\\lesseqgtr",!0),s(i,w,"\u2A8B","\\lesseqqgtr",!0),s(i,w,"\u2251","\\doteqdot"),s(i,w,"\u2253","\\risingdotseq",!0),s(i,w,"\u2252","\\fallingdotseq",!0),s(i,w,"\u223D","\\backsim",!0),s(i,w,"\u22CD","\\backsimeq",!0),s(i,w,"\u2AC5","\\subseteqq",!0),s(i,w,"\u22D0","\\Subset",!0),s(i,w,"\u228F","\\sqsubset",!0),s(i,w,"\u227C","\\preccurlyeq",!0),s(i,w,"\u22DE","\\curlyeqprec",!0),s(i,w,"\u227E","\\precsim",!0),s(i,w,"\u2AB7","\\precapprox",!0),s(i,w,"\u22B2","\\vartriangleleft"),s(i,w,"\u22B4","\\trianglelefteq"),s(i,w,"\u22A8","\\vDash",!0),s(i,w,"\u22AB","\\VDash",!0),s(i,w,"\u22AA","\\Vvdash",!0),s(i,w,"\u2323","\\smallsmile"),s(i,w,"\u2322","\\smallfrown"),s(i,w,"\u224F","\\bumpeq",!0),s(i,w,"\u224E","\\Bumpeq",!0),s(i,w,"\u2267","\\geqq",!0),s(i,w,"\u2A7E","\\geqslant",!0),s(i,w,"\u2A96","\\eqslantgtr",!0),s(i,w,"\u2273","\\gtrsim",!0),s(i,w,"\u2A86","\\gtrapprox",!0),s(i,B,"\u22D7","\\gtrdot"),s(i,w,"\u22D9","\\ggg",!0),s(i,w,"\u2277","\\gtrless",!0),s(i,w,"\u22DB","\\gtreqless",!0),s(i,w,"\u2A8C","\\gtreqqless",!0),s(i,w,"\u2256","\\eqcirc",!0),s(i,w,"\u2257","\\circeq",!0),s(i,w,"\u225C","\\triangleq",!0),s(i,w,"\u223C","\\thicksim"),s(i,w,"\u2248","\\thickapprox"),s(i,w,"\u2AC6","\\supseteqq",!0),s(i,w,"\u22D1","\\Supset",!0),s(i,w,"\u2290","\\sqsupset",!0),s(i,w,"\u227D","\\succcurlyeq",!0),s(i,w,"\u22DF","\\curlyeqsucc",!0),s(i,w,"\u227F","\\succsim",!0),s(i,w,"\u2AB8","\\succapprox",!0),s(i,w,"\u22B3","\\vartriangleright"),s(i,w,"\u22B5","\\trianglerighteq"),s(i,w,"\u22A9","\\Vdash",!0),s(i,w,"\u2223","\\shortmid"),s(i,w,"\u2225","\\shortparallel"),s(i,w,"\u226C","\\between",!0),s(i,w,"\u22D4","\\pitchfork",!0),s(i,w,"\u221D","\\varpropto"),s(i,w,"\u25C0","\\blacktriangleleft"),s(i,w,"\u2234","\\therefore",!0),s(i,w,"\u220D","\\backepsilon"),s(i,w,"\u25B6","\\blacktriangleright"),s(i,w,"\u2235","\\because",!0),s(i,w,"\u22D8","\\llless"),s(i,w,"\u22D9","\\gggtr"),s(i,B,"\u22B2","\\lhd"),s(i,B,"\u22B3","\\rhd"),s(i,w,"\u2242","\\eqsim",!0),s(i,w,"\u2251","\\Doteq",!0),s(i,w,"\u297D","\\strictif",!0),s(i,w,"\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,w,"\u21E2","\\dashrightarrow",!0),s(i,w,"\u21E0","\\dashleftarrow",!0),s(i,w,"\u21C7","\\leftleftarrows",!0),s(i,w,"\u21C6","\\leftrightarrows",!0),s(i,w,"\u21DA","\\Lleftarrow",!0),s(i,w,"\u219E","\\twoheadleftarrow",!0),s(i,w,"\u21A2","\\leftarrowtail",!0),s(i,w,"\u21AB","\\looparrowleft",!0),s(i,w,"\u21CB","\\leftrightharpoons",!0),s(i,w,"\u21B6","\\curvearrowleft",!0),s(i,w,"\u21BA","\\circlearrowleft",!0),s(i,w,"\u21B0","\\Lsh",!0),s(i,w,"\u21C8","\\upuparrows",!0),s(i,w,"\u21BF","\\upharpoonleft",!0),s(i,w,"\u21C3","\\downharpoonleft",!0),s(i,w,"\u22B6","\\origof",!0),s(i,w,"\u22B7","\\imageof",!0),s(i,w,"\u22B8","\\multimap",!0),s(i,w,"\u21AD","\\leftrightsquigarrow",!0),s(i,w,"\u21C9","\\rightrightarrows",!0),s(i,w,"\u21C4","\\rightleftarrows",!0),s(i,w,"\u21A0","\\twoheadrightarrow",!0),s(i,w,"\u21A3","\\rightarrowtail",!0),s(i,w,"\u21AC","\\looparrowright",!0),s(i,w,"\u21B7","\\curvearrowright",!0),s(i,w,"\u21BB","\\circlearrowright",!0),s(i,w,"\u21B1","\\Rsh",!0),s(i,w,"\u21CA","\\downdownarrows",!0),s(i,w,"\u21BE","\\upharpoonright",!0),s(i,w,"\u21C2","\\downharpoonright",!0),s(i,w,"\u21DD","\\rightsquigarrow",!0),s(i,w,"\u21DD","\\leadsto"),s(i,w,"\u21DB","\\Rrightarrow",!0),s(i,w,"\u21BE","\\restriction"),s(i,g,"\u2018","`"),s(i,g,"$","\\$"),s(O,g,"$","\\$"),s(O,g,"$","\\textdollar"),s(i,g,"\xA2","\\cent"),s(O,g,"\xA2","\\cent"),s(i,g,"%","\\%"),s(O,g,"%","\\%"),s(i,g,"_","\\_"),s(O,g,"_","\\_"),s(O,g,"_","\\textunderscore"),s(O,g,"\u2423","\\textvisiblespace",!0),s(i,g,"\u2220","\\angle",!0),s(i,g,"\u221E","\\infty",!0),s(i,g,"\u2032","\\prime"),s(i,g,"\u2033","\\dprime"),s(i,g,"\u2034","\\trprime"),s(i,g,"\u2057","\\qprime"),s(i,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(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,ee,"\xAC","\\neg",!0),s(i,ee,"\xAC","\\lnot"),s(i,g,"\u22A4","\\top"),s(i,g,"\u22A5","\\bot"),s(i,g,"\u2205","\\emptyset"),s(i,g,"\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,g,"\xF0","\\eth",!0),s(O,g,"\xF0","\xF0"),s(i,g,"\xC5","\\AA"),s(O,g,"\xC5","\\AA",!0),s(i,g,"\xC6","\\AE",!0),s(O,g,"\xC6","\\AE",!0),s(i,g,"\xD0","\\DH",!0),s(O,g,"\xD0","\\DH",!0),s(i,g,"\xDE","\\TH",!0),s(O,g,"\xDE","\\TH",!0),s(i,g,"\xDF","\\ss",!0),s(O,g,"\xDF","\\ss",!0),s(i,g,"\xE5","\\aa"),s(O,g,"\xE5","\\aa",!0),s(i,g,"\xE6","\\ae",!0),s(O,g,"\xE6","\\ae",!0),s(i,g,"\xF0","\\dh"),s(O,g,"\xF0","\\dh",!0),s(i,g,"\xFE","\\th",!0),s(O,g,"\xFE","\\th",!0),s(i,g,"\u0110","\\DJ",!0),s(O,g,"\u0110","\\DJ",!0),s(i,g,"\u0111","\\dj",!0),s(O,g,"\u0111","\\dj",!0),s(i,g,"\u0141","\\L",!0),s(O,g,"\u0141","\\L",!0),s(i,g,"\u0141","\\l",!0),s(O,g,"\u0141","\\l",!0),s(i,g,"\u014A","\\NG",!0),s(O,g,"\u014A","\\NG",!0),s(i,g,"\u014B","\\ng",!0),s(O,g,"\u014B","\\ng",!0),s(i,g,"\u0152","\\OE",!0),s(O,g,"\u0152","\\OE",!0),s(i,g,"\u0153","\\oe",!0),s(O,g,"\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,ee,"\u27E6","\\llbracket",!0),s(i,Le,"\u27E7","\\rrbracket",!0),s(i,ee,"\u27E8","\\langle",!0),s(i,ee,"\u27EA","\\lAngle",!0),s(i,ee,"\u2989","\\llangle",!0),s(i,ee,"|","\\lvert"),s(i,ee,"\u2016","\\lVert",!0),s(i,g,"!","\\oc"),s(i,g,"?","\\wn"),s(i,g,"\u2193","\\shpos"),s(i,g,"\u2195","\\shift"),s(i,g,"\u2191","\\shneg"),s(i,Le,"?","?"),s(i,Le,"!","!"),s(i,Le,"\u203C","\u203C"),s(i,Le,"\u27E9","\\rangle",!0),s(i,Le,"\u27EB","\\rAngle",!0),s(i,Le,"\u298A","\\rrangle",!0),s(i,Le,"|","\\rvert"),s(i,Le,"\u2016","\\rVert"),s(i,ee,"\u2983","\\lBrace",!0),s(i,Le,"\u2984","\\rBrace",!0),s(i,w,"=","\\equal",!0),s(i,w,":",":"),s(i,w,"\u2248","\\approx",!0),s(i,w,"\u2245","\\cong",!0),s(i,w,"\u2265","\\ge"),s(i,w,"\u2265","\\geq",!0),s(i,w,"\u2190","\\gets"),s(i,w,">","\\gt",!0),s(i,w,"\u2208","\\in",!0),s(i,w,"\u2209","\\notin",!0),s(i,w,"\uE020","\\@not"),s(i,w,"\u2282","\\subset",!0),s(i,w,"\u2283","\\supset",!0),s(i,w,"\u2286","\\subseteq",!0),s(i,w,"\u2287","\\supseteq",!0),s(i,w,"\u2288","\\nsubseteq",!0),s(i,w,"\u2288","\\nsubseteqq"),s(i,w,"\u2289","\\nsupseteq",!0),s(i,w,"\u2289","\\nsupseteqq"),s(i,w,"\u22A8","\\models"),s(i,w,"\u2190","\\leftarrow",!0),s(i,w,"\u2264","\\le"),s(i,w,"\u2264","\\leq",!0),s(i,w,"<","\\lt",!0),s(i,w,"\u2192","\\rightarrow",!0),s(i,w,"\u2192","\\to"),s(i,w,"\u2271","\\ngeq",!0),s(i,w,"\u2271","\\ngeqq"),s(i,w,"\u2271","\\ngeqslant"),s(i,w,"\u2270","\\nleq",!0),s(i,w,"\u2270","\\nleqq"),s(i,w,"\u2270","\\nleqslant"),s(i,w,"\u2AEB","\\Perp",!0),s(i,Ie,"\xA0","\\ "),s(i,Ie,"\xA0","\\space"),s(i,Ie,"\xA0","\\nobreakspace"),s(O,Ie,"\xA0","\\ "),s(O,Ie,"\xA0"," "),s(O,Ie,"\xA0","\\space"),s(O,Ie,"\xA0","\\nobreakspace"),s(i,Ie,null,"\\nobreak"),s(i,Ie,null,"\\allowbreak"),s(i,We,",",","),s(O,We,":",":"),s(i,We,";",";"),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,g,"\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,ee,"{","\\{"),s(O,g,"{","\\{"),s(O,g,"{","\\textbraceleft"),s(i,Le,"}","\\}"),s(O,g,"}","\\}"),s(O,g,"}","\\textbraceright"),s(i,ee,"{","\\lbrace"),s(i,Le,"}","\\rbrace"),s(i,ee,"[","\\lbrack",!0),s(O,g,"[","\\lbrack",!0),s(i,Le,"]","\\rbrack",!0),s(O,g,"]","\\rbrack",!0),s(i,ee,"(","\\lparen",!0),s(i,Le,")","\\rparen",!0),s(i,ee,"\u2987","\\llparenthesis",!0),s(i,Le,"\u2988","\\rrparenthesis",!0),s(O,g,"<","\\textless",!0),s(O,g,">","\\textgreater",!0),s(i,ee,"\u230A","\\lfloor",!0),s(i,Le,"\u230B","\\rfloor",!0),s(i,ee,"\u2308","\\lceil",!0),s(i,Le,"\u2309","\\rceil",!0),s(i,g,"\\","\\backslash"),s(i,g,"|","|"),s(i,g,"|","\\vert"),s(O,g,"|","\\textbar",!0),s(i,g,"\u2016","\\|"),s(i,g,"\u2016","\\Vert"),s(O,g,"\u2016","\\textbardbl"),s(O,g,"~","\\textasciitilde"),s(O,g,"\\","\\textbackslash"),s(O,g,"^","\\textasciicircum"),s(i,w,"\u2191","\\uparrow",!0),s(i,w,"\u21D1","\\Uparrow",!0),s(i,w,"\u2193","\\downarrow",!0),s(i,w,"\u21D3","\\Downarrow",!0),s(i,w,"\u2195","\\updownarrow",!0),s(i,w,"\u21D5","\\Updownarrow",!0),s(i,Ae,"\u2210","\\coprod"),s(i,Ae,"\u22C1","\\bigvee"),s(i,Ae,"\u22C0","\\bigwedge"),s(i,Ae,"\u2A04","\\biguplus"),s(i,Ae,"\u2A04","\\bigcupplus"),s(i,Ae,"\u2A03","\\bigcupdot"),s(i,Ae,"\u2A07","\\bigdoublevee"),s(i,Ae,"\u2A08","\\bigdoublewedge"),s(i,Ae,"\u22C2","\\bigcap"),s(i,Ae,"\u22C3","\\bigcup"),s(i,Ae,"\u222B","\\int"),s(i,Ae,"\u222B","\\intop"),s(i,Ae,"\u222C","\\iint"),s(i,Ae,"\u222D","\\iiint"),s(i,Ae,"\u220F","\\prod"),s(i,Ae,"\u2211","\\sum"),s(i,Ae,"\u2A02","\\bigotimes"),s(i,Ae,"\u2A01","\\bigoplus"),s(i,Ae,"\u2A00","\\bigodot"),s(i,Ae,"\u2A09","\\bigtimes"),s(i,Ae,"\u222E","\\oint"),s(i,Ae,"\u222F","\\oiint"),s(i,Ae,"\u2230","\\oiiint"),s(i,Ae,"\u2231","\\intclockwise"),s(i,Ae,"\u2232","\\varointclockwise"),s(i,Ae,"\u2A0C","\\iiiint"),s(i,Ae,"\u2A0D","\\intbar"),s(i,Ae,"\u2A0E","\\intBar"),s(i,Ae,"\u2A0F","\\fint"),s(i,Ae,"\u2A12","\\rppolint"),s(i,Ae,"\u2A13","\\scpolint"),s(i,Ae,"\u2A15","\\pointint"),s(i,Ae,"\u2A16","\\sqint"),s(i,Ae,"\u2A17","\\intlarhk"),s(i,Ae,"\u2A18","\\intx"),s(i,Ae,"\u2A19","\\intcap"),s(i,Ae,"\u2A1A","\\intcup"),s(i,Ae,"\u2A05","\\bigsqcap"),s(i,Ae,"\u2A06","\\bigsqcup"),s(i,Ae,"\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,g,"\u22EE","\\varvdots"),s(O,g,"\u22EE","\\varvdots"),s(i,Ue,"\xB4","\\acute"),s(i,Ue,"`","\\grave"),s(i,Ue,"\xA8","\\ddot"),s(i,Ue,"\u2026","\\dddot"),s(i,Ue,"\u2026.","\\ddddot"),s(i,Ue,"~","\\tilde"),s(i,Ue,"\u203E","\\bar"),s(i,Ue,"\u02D8","\\breve"),s(i,Ue,"\u02C7","\\check"),s(i,Ue,"^","\\hat"),s(i,Ue,"\u2192","\\vec"),s(i,Ue,"\u02D9","\\dot"),s(i,Ue,"\u02DA","\\mathring"),s(i,W,"\u0131","\\imath",!0),s(i,W,"\u0237","\\jmath",!0),s(i,g,"\u0131","\u0131"),s(i,g,"\u0237","\u0237"),s(O,g,"\u0131","\\i",!0),s(O,g,"\u0237","\\j",!0),s(O,g,"\xF8","\\o",!0),s(i,W,"\xF8","\\o",!0),s(O,g,"\xD8","\\O",!0),s(i,W,"\xD8","\\O",!0),s(O,Ue,"\u02CA","\\'"),s(O,Ue,"\u02CB","\\`"),s(O,Ue,"\u02C6","\\^"),s(O,Ue,"~","\\~"),s(O,Ue,"\u02C9","\\="),s(O,Ue,"\u02D8","\\u"),s(O,Ue,"\u02D9","\\."),s(O,Ue,"\xB8","\\c"),s(O,Ue,"\u02DA","\\r"),s(O,Ue,"\u02C7","\\v"),s(O,Ue,"\xA8",'\\"'),s(O,Ue,"\u02DD","\\H"),s(i,Ue,"\u02CA","\\'"),s(i,Ue,"\u02CB","\\`"),s(i,Ue,"\u02C6","\\^"),s(i,Ue,"~","\\~"),s(i,Ue,"\u02C9","\\="),s(i,Ue,"\u02D8","\\u"),s(i,Ue,"\u02D9","\\."),s(i,Ue,"\xB8","\\c"),s(i,Ue,"\u02DA","\\r"),s(i,Ue,"\u02C7","\\v"),s(i,Ue,"\xA8",'\\"'),s(i,Ue,"\u02DD","\\H");let J={"--":!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(i,g,"\xB0","\\degree",!0),s(O,g,"\xB0","\\degree"),s(O,g,"\xB0","\\textdegree",!0),s(i,g,"\xA3","\\pounds"),s(i,g,"\xA3","\\mathsterling",!0),s(O,g,"\xA3","\\pounds"),s(O,g,"\xA3","\\textsterling",!0),s(i,g,"\u2720","\\maltese"),s(O,g,"\u2720","\\maltese"),s(i,g,"\u20AC","\\euro",!0),s(O,g,"\u20AC","\\euro",!0),s(O,g,"\u20AC","\\texteuro"),s(i,g,"\xA9","\\copyright",!0),s(O,g,"\xA9","\\textcopyright"),s(i,g,"\u2300","\\diameter",!0),s(O,g,"\u2300","\\diameter"),s(i,g,"\u{1D6E4}","\\varGamma"),s(i,g,"\u{1D6E5}","\\varDelta"),s(i,g,"\u{1D6E9}","\\varTheta"),s(i,g,"\u{1D6EC}","\\varLambda"),s(i,g,"\u{1D6EF}","\\varXi"),s(i,g,"\u{1D6F1}","\\varPi"),s(i,g,"\u{1D6F4}","\\varSigma"),s(i,g,"\u{1D6F6}","\\varUpsilon"),s(i,g,"\u{1D6F7}","\\varPhi"),s(i,g,"\u{1D6F9}","\\varPsi"),s(i,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 z='0123456789/@."';for(let e=0;e<14;e++){let n=z.charAt(e);s(i,g,n,n)}let Ce='0123456789!@*()-=+";:?/.,';for(let e=0;e<25;e++){let n=Ce.charAt(e);s(O,g,n,n)}let ye="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";for(let e=0;e<52;e++){let n=ye.charAt(e);s(i,W,n,n),s(O,g,n,n)}let Pe="\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=Pe.charAt(e);s(i,W,n,n),s(O,g,n,n)}let X="";for(let e=0;e<52;e++){X=String.fromCharCode(55349,56320+e),s(i,W,X,X),s(O,g,X,X),X=String.fromCharCode(55349,56372+e),s(i,W,X,X),s(O,g,X,X),X=String.fromCharCode(55349,56424+e),s(i,W,X,X),s(O,g,X,X),X=String.fromCharCode(55349,56580+e),s(i,W,X,X),s(O,g,X,X),X=String.fromCharCode(55349,56736+e),s(i,W,X,X),s(O,g,X,X),X=String.fromCharCode(55349,56788+e),s(i,W,X,X),s(O,g,X,X),X=String.fromCharCode(55349,56840+e),s(i,W,X,X),s(O,g,X,X),X=String.fromCharCode(55349,56944+e),s(i,W,X,X),s(O,g,X,X),X=String.fromCharCode(55349,56632+e),s(i,W,X,X),s(O,g,X,X);let n=ye.charAt(e);X=String.fromCharCode(55349,56476+e),s(i,W,n,X),s(O,g,n,X)}for(let e=0;e<10;e++)X=String.fromCharCode(55349,57294+e),s(i,W,X,X),s(O,g,X,X),X=String.fromCharCode(55349,57314+e),s(i,W,X,X),s(O,g,X,X),X=String.fromCharCode(55349,57324+e),s(i,W,X,X),s(O,g,X,X),X=String.fromCharCode(55349,57334+e),s(i,W,X,X),s(O,g,X,X);let Xe=function(e,n,r){return!Y[n][e]||!Y[n][e].replace||e.charCodeAt(0)===55349||Object.prototype.hasOwnProperty.call(J,e)&&r&&(r.fontFamily&&r.fontFamily.slice(4,6)==="tt"||r.font&&r.font.slice(4,6)==="tt")||(e=Y[n][e].replace),new je(e)},mt=(e,n)=>{if(e.children.length===0||e.children[e.children.length-1].type!=="mtext"){let r=new _("mtext",[new je(n.children[0].text)]);e.children.push(r)}else e.children[e.children.length-1].children[0].text+=n.children[0].text},ft=e=>{if(e.type!=="mrow"&&e.type!=="mstyle"||e.children.length===0)return e;let n=new _("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)mt(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];mt(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 Oe))return e[0];if(!n){e[0]instanceof _&&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 _&&e[r].type==="mo"&&!e[r].attributes.fence&&(e[r].attributes.lspace="0em",e[r].attributes.rspace="0em")}return new _("mrow",e)};function ue(e){if(!e)return!1;if(e.type==="mi"&&e.children.length===1){let n=e.children[0];return n instanceof je&&n.text==="."}if(e.type==="mtext"&&e.children.length===1){let n=e.children[0];return n instanceof je&&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 je&&n.text===","}return!1}let ie=(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},Ke=e=>e.type==="atom"&&e.family==="rel"||e.type==="mclass"&&e.mclass==="mrel",rt=function(e,n,r=!1){if(!r&&e.length===1){let y=tt(e[0],n);return y instanceof _&&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(tt(e[y],n));for(let y=0;y<u.length;y++){let E=u[y];if(y<e.length-1&&Ke(e[y])&&Ke(e[y+1])&&E.setAttribute("rspace","0em"),y>0&&Ke(e[y])&&Ke(e[y-1])&&E.setAttribute("lspace","0em"),E.type==="mn"&&h&&h.type==="mn")h.children.push(...E.children);else if(ue(E)&&h&&h.type==="mn")h.children.push(...E.children);else if(h&&h.type==="mn"&&y<u.length-1&&u[y+1].type==="mn"&&ie(e,y))h.children.push(...E.children);else{if(E.type==="mn"&&ue(h))E.children=[...h.children,...E.children],l.pop();else if((E.type==="msup"||E.type==="msub")&&E.children.length>=1&&h&&(h.type==="mn"||ue(h))){let U=E.children[0];U instanceof _&&U.type==="mn"&&h&&(U.children=[...h.children,...U.children],l.pop())}l.push(E),h=E}}return l},Je=function(e,n,r=!1){return ke(rt(e,n,r),r)},tt=function(e,n){if(!e)return new _("mrow");if(A[e.type])return A[e.type](e,n);throw new t("Got group of unknown type: '"+e.type+"'")},Rt=e=>new _("mtd",[],[],{padding:"0",width:"50%"}),jt=["mrow","mtd","mtable","mtr"],en=e=>{for(let n of e.children)if(n.type&&jt.includes(n.type)){if(n.classes&&n.classes[0]==="tml-label")return n.label;{let r=en(n);if(r)return r}}else if(!n.type){let r=en(n);if(r)return r}};function Pt(e,n,r,l){let u=null;e.length===1&&e[0].type==="tag"&&(u=e[0].tag,e=e[0].body);let h=rt(e,r);if(h.length===1&&h[0]instanceof _e)return h[0];let y=l.displayMode||l.annotate?"none":l.wrap,E=h.length===0?null:h[0],U=h.length===1&&u===null&&E instanceof _?h[0]:function(be,Te,de){let kt=[],ct=[],Et=[],Ut=0,dt=0;for(;dt<be.length;){for(;be[dt]instanceof Oe;)be.splice(dt,1,...be[dt].children);let ht=be[dt];if(ht.attributes&&ht.attributes.linebreak&&ht.attributes.linebreak==="newline"){Et.length>0&&ct.push(new _("mrow",Et)),ct.push(ht),Et=[];let An=new _("mtd",ct);An.style.textAlign="left",kt.push(new _("mtr",[An])),ct=[],dt+=1;continue}if(Et.push(ht),ht.type&&ht.type==="mo"&&ht.children.length===1&&(!ht.attributes.form||ht.attributes.form!=="prefix")&&!Object.prototype.hasOwnProperty.call(ht.attributes,"movablelimits")){let An=ht.children[0].text;if(Te==="="&&An==="="){if(Ut+=1,Ut>1){Et.pop();let dn=new _("mrow",Et);ct.push(dn),Et=[ht]}}else if(Te==="tex"){let dn=dt<be.length-1?be[dt+1]:null,_r=!0;if(!dn||dn.type!=="mtext"||!dn.attributes.linebreak||dn.attributes.linebreak!=="nobreak")for(let Zn=dt+1;Zn<be.length;Zn++){let or=be[Zn];if(!or.type||or.type!=="mspace"||or.attributes.linebreak&&or.attributes.linebreak==="newline")break;Et.push(or),dt+=1,or.attributes&&or.attributes.linebreak&&or.attributes.linebreak==="nobreak"&&(_r=!1)}if(_r){let Zn=new _("mrow",Et);ct.push(Zn),Et=[]}}}dt+=1}if(Et.length>0){let ht=new _("mrow",Et);ct.push(ht)}if(kt.length>0){let ht=new _("mtd",ct);ht.style.textAlign="left";let An=new _("mtr",[ht]);kt.push(An);let dn=new _("mtable",kt);return de||(dn.setAttribute("columnalign","left"),dn.setAttribute("rowspacing","0em")),dn}return bt(ct)}(h,y,l.displayMode);if(u&&(U=((be,Te,de,kt)=>{Te=Je(Te[0].body,de),(Te=ft(Te)).classes.push("tml-tag");let ct=en(be);be=new _("mtd",[be]);let Et=[Rt(),be,Rt()];Et[kt?0:2].children.push(Te);let Ut=new _("mtr",Et,["tml-tageqn"]);ct&&Ut.setAttribute("id",ct);let dt=new _("mtable",[Ut]);return dt.style.width="100%",dt.setAttribute("displaystyle","true"),dt})(U,u,r,l.leqno)),l.annotate){let be=new _("annotation",[new je(n)]);be.setAttribute("encoding","application/x-tex"),U=new _("semantics",[U,be])}let V=new _("math",[U]);return l.xml&&V.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML"),l.displayMode&&(V.setAttribute("display","block"),V.style.display="block math",V.classes=["tml-display"]),V}let sn=(e,n)=>{let r=e.isStretchy?he(e):new _("mo",[Xe(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=At.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",E=y==="\\vec"?"-vec":"";y&&r.classes.push("tml-vec");let U=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${E}`),r.classes.push(`wbk-sml${U}`)):"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${E}`),r.classes.push(`wbk-med${U}`)):"AFJdf\u0394\u039B".indexOf(h)>-1?(r.classes.push(`chr-lrg${E}`),r.classes.push(`wbk-lrg${U}`)):y?r.classes.push("wbk-vec"):u&&r.classes.push("wbk-acc")}else u&&r.classes.push("wbk-acc");return new _(l,[tt(e.base,n),r])},Gt=new Set(["\\acute","\\check","\\grave","\\ddot","\\dddot","\\ddddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring"]),At=new Set(["\\acute","\\bar","\\breve","\\check","\\dot","\\ddot","\\grave","\\hat","\\mathring","\\`","\\'","\\^","\\=","\\u","\\.",'\\"',"\\r","\\H","\\v"]),on={"\\`":"\u0300","\\'":"\u0301","\\^":"\u0302","\\~":"\u0303","\\=":"\u0304","\\u":"\u0306","\\.":"\u0307",'\\"':"\u0308","\\r":"\u030A","\\H":"\u030B","\\v":"\u030C","\\c":"\u0327"};N({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=!Gt.has(e.funcName);return{type:"accent",mode:e.parser.mode,label:e.funcName,isStretchy:l,base:r}},mathmlBuilder:sn}),N({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 on&&S.indexOf(r.text)>-1?{type:"textord",mode:"text",text:r.text+on[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:sn}),N({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=he(e);return r.style["math-depth"]=0,new _("munder",[tt(e.base,n),r])}});let un={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},qt=["em","ex","mu","pt","mm","cm","in","px","bp","pc","dd","cc","nd","nc","sp"],pn=function(e){return typeof e!="string"&&(e=e.unit),qt.indexOf(e)>-1},te=e=>[1,.7,.5][Math.max(e-1,0)],Kt=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*un[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/te(n.level),n.maxSize[0]),{number:k(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*un[l],n.maxSize[1]),{number:k(r),unit:"pt"};case"mu":return r=Math.min(r/18,n.maxSize[0]),{number:k(r),unit:"em"};default:throw new t("Invalid unit: '"+l+"'")}},_t=e=>{let n=new _("mspace");return n.setAttribute("width",e+"em"),n},tn=(e,n=.3,r=0,l=!1)=>{if(e==null&&r===0)return _t(n);let u=e?[e]:[];if(n!==0&&u.unshift(_t(n)),r>0&&u.push(_t(r)),l){let h=new _("mpadded",u);return h.setAttribute("height","0.1px"),h}return new _("mrow",u)},Yt=(e,n)=>Number(e)/te(n),C=(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 E=l.withLevel(l.level<2?2:3),U=Yt(y,E.level),V=Yt(y,3),be=tn(null,U.toFixed(4),0),Te=tn(null,V.toFixed(4),0),de=Yt(h?0:.3,E.level).toFixed(4),kt,ct,Et=n&&n.body&&(n.body.body||n.body.length>0);if(Et){let ht=tt(n,E);ht=tn(ht,de,de,e==="\\\\cdrightarrow"||e==="\\\\cdleftarrow"),kt=new _("mover",[ht,Te])}let Ut=r&&r.body&&(r.body.body||r.body.length>0);if(Ut){let ht=tt(r,E);ht=tn(ht,de,de),ct=new _("munder",[ht,Te])}let dt;return dt=Et||Ut?Et&&Ut?new _("munderover",[u,ct,kt]):Et?new _("mover",[u,kt]):new _("munder",[u,ct]):new _("mover",[u,be]),y==="3.0"&&(dt.style.height="1em"),dt.setAttribute("accent","false"),dt};N({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=[C(e.name,e.body,e.below,n)];return r.unshift(_t(.2778)),r.push(_t(.2778)),new _("mrow",r)}});let ne={"\\equilibriumRight":["\\longrightharpoonup","\\eqleftharpoondown"],"\\equilibriumLeft":["\\eqrightharpoonup","\\longleftharpoondown"]};N({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=ne[e.name][0],l=ne[e.name][1],u=C(r,e.body,e.upperArrowBelow,n),h=C(l,e.lowerArrowBody,e.below,n),y,E=new _("mpadded",[u]);if(E.setAttribute("voffset","0.3em"),E.setAttribute("height","+0.3em"),E.setAttribute("depth","-0.3em"),e.name==="\\equilibriumLeft"){let U=new _("mpadded",[h]);U.setAttribute("width","0.5em"),y=new _("mpadded",[_t(.2778),U,E,_t(.2778)])}else E.setAttribute("width",e.name==="\\equilibriumRight"?"0.5em":"0"),y=new _("mpadded",[_t(.2778),E,h,_t(.2778)]);return y.setAttribute("voffset","-0.18em"),y.setAttribute("height","-0.18em"),y.setAttribute("depth","+0.18em"),y}});let Ee={};function we({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)Ee[n[y]]=h;u&&(A[e]=u)}function Ne(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 Ge(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(Re,e.type))?e:null}let H={">":"\\\\cdrightarrow","<":"\\\\cdleftarrow","=":"\\\\cdlongequal",A:"\\uparrow",V:"\\downarrow","|":"\\Vert",".":"no arrow"},K=()=>({type:"styling",body:[],mode:"math",scriptLevel:"display"}),se=e=>e.type==="textord"&&e.text==="@",qe=(e,n)=>(e.type==="mathord"||e.type==="atom")&&e.text===n;function Qe(e,n,r){let l=H[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"}}}N({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 _("mrow",n);let r=tt(e.label,n);e.side==="left"&&r.classes.push("tml-shift-left");let l=new _("mtd",[r]);l.style.padding="0";let u=new _("mtr",[l]),h=new _("mtable",[u]),y=new _("mpadded",[h]);return y.setAttribute("width","0.1px"),y.setAttribute("displaystyle","false"),y.setAttribute("scriptlevel","1"),y}}),N({type:"cdlabelparent",names:["\\\\cdparent"],props:{numArgs:1},handler:({parser:e},n)=>({type:"cdlabelparent",mode:e.mode,fragment:n[0]}),mathmlBuilder:(e,n)=>new _("mrow",[tt(e.fragment,n)])});let Fe=e=>({type:"ordgroup",mode:"math",body:e,semisimple:!0}),ge=(e,n)=>({type:n,mode:"math",body:Fe(e)});class Be{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 Be(n.loc.lexer,n.loc.start,r.loc.end):null:n&&n.loc}}class st{constructor(n,r){this.text=n,this.loc=r}range(n,r){return new st(r,Be.range(this,n))}}let wt=0,Mt=1,pt=2,nt=3,vt={};function L(e,n){vt[e]=n}let Bt=vt;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 ln=e=>{let n="";for(let r=e.length-1;r>-1;r--)n+=e[r].text;return n},cn={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},Jn=e=>{let n=e.future().text;return n==="EOF"?[null,""]:[cn[n.charAt(0)],n]},dr=(e,n,r)=>{for(let l=1;l<n.length;l++)e*=r,e+=cn[n.charAt(l)];return e};function Wt(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=cn[h.charAt(0)],l==null||l>=n)throw new t(`Invalid base-${n} digit ${r.text}`);for(l=dr(l,h,n),[u,h]=Jn(e);u!=null&&u<n;)l*=n,l+=u,l=dr(l,h,n),e.popToken(),[u,h]=Jn(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 yn={",":"\\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 yn?n=yn[r]:(r.slice(0,4)==="\\not"||r in Y.math&&["bin","rel"].includes(Y.math[r].group))&&(n="\\dotsb"),n});let Zt={")":!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 Zt?"\\ldots\\,":"\\ldots"}),L("\\dotsc",function(e){let n=e.future().text;return n in Zt&&n!==","?"\\ldots\\,":"\\ldots"}),L("\\cdots",function(e){return e.future().text in Zt?"\\@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 xt=(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=Wt(e),r=/\|\||\||\\\|/g,l;for(;(l=r.exec(n))!==null;)n=xt(n,l);return"\\left\\langle{"+n+"}\\right\\rangle"}),L("\\Set",function(e){let n=Wt(e),r=/\|\||\||\\\|/.exec(n);return r&&(n=xt(n,r)),"\\left\\{\\:{"+n+"}\\:\\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 _n=e=>{let n=e[0][0].text,r=ln(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 Tn(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]=_n(e.consumeArgs(2));return`\\frac{${r} ${n}}{${l}}`}),L("\\pdv@next",function(e){let[n,r,l]=_n(e.consumeArgs(2));return`\\frac{${r}}{${l}} ${n}`}),L("\\upalpha","\\up@greek{\\alpha}"),L("\\upbeta","\\up@greek{\\beta}"),L("\\upgamma","\\up@greek{\\gamma}"),L("\\updelta","\\up@greek{\\delta}"),L("\\upepsilon","\\up@greek{\\epsilon}"),L("\\upzeta","\\up@greek{\\zeta}"),L("\\upeta","\\up@greek{\\eta}"),L("\\uptheta","\\up@greek{\\theta}"),L("\\upiota","\\up@greek{\\iota}"),L("\\upkappa","\\up@greek{\\kappa}"),L("\\uplambda","\\up@greek{\\lambda}"),L("\\upmu","\\up@greek{\\mu}"),L("\\upnu","\\up@greek{\\nu}"),L("\\upxi","\\up@greek{\\xi}"),L("\\upomicron","\\up@greek{\\omicron}"),L("\\uppi","\\up@greek{\\pi}"),L("\\upalpha","\\up@greek{\\alpha}"),L("\\uprho","\\up@greek{\\rho}"),L("\\upsigma","\\up@greek{\\sigma}"),L("\\uptau","\\up@greek{\\tau}"),L("\\upupsilon","\\up@greek{\\upsilon}"),L("\\upphi","\\up@greek{\\phi}"),L("\\upchi","\\up@greek{\\chi}"),L("\\uppsi","\\up@greek{\\psi}"),L("\\upomega","\\up@greek{\\omega}"),L("\\invamp",'\\mathbin{\\char"214b}'),L("\\parr",'\\mathbin{\\char"214b}'),L("\\upand",'\\mathbin{\\char"214b}'),L("\\with",'\\mathbin{\\char"26}'),L("\\multimapinv",'\\mathrel{\\char"27dc}'),L("\\multimapboth",'\\mathrel{\\char"29df}'),L("\\scoh",'{\\mkern5mu\\char"2322\\mkern5mu}'),L("\\sincoh",'{\\mkern5mu\\char"2323\\mkern5mu}'),L("\\coh",`{\\mkern5mu\\rule{}{0.7em}\\mathrlap{\\smash{\\raise2mu{\\char"2322}}}
|
|
6
|
-
{\\smash{\\lower4mu{\\char"2323}}}\\mkern5mu}`),
|
|
7
|
-
{\\smash{\\lower4mu{\\char"2322}}}\\mkern5mu}`),L("\\standardstate","\\text{\\tiny\\char`\u29B5}");let wn=e=>{if(!e.parser.settings.displayMode)throw new t(`{${e.envName}} can be used only in display mode.`)},Ot=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/,Yn=e=>{let n=e.get("\\arraystretch");typeof n!="string"&&(n=ln(n.tokens)),n=isNaN(n)?null:Number(n);let r=e.get("\\arraycolsep");typeof r!="string"&&(r=ln(r.tokens));let l=Ot.exec(r);return[n,l?{number:+(l[1]+l[2]),unit:l[3]}:null]},Ln=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 Xn(e){if(e.indexOf("ed")===-1)return e.indexOf("*")===-1}function an(e,{cols:n,envClasses:r,autoTag:l,singleRow:u,emptySingleRow:h,maxNumCols:y,leqno:E,arraystretch:U,arraycolsep:V},be){let Te=r&&r.includes("bordermatrix")?"}":"\\end";e.gullet.beginGroup(),u||e.gullet.macros.set("\\cr","\\\\\\relax"),e.gullet.beginGroup();let de=[],kt=[de],ct=[],Et=[],Ut=[],dt=l!=null?[]:void 0;function ht(){l&&e.gullet.macros.set("\\@eqnsw","1",!0)}function An(){dt&&(e.gullet.macros.get("\\df@tag")?(dt.push(e.subparse([new st("\\df@tag")])),e.gullet.macros.set("\\df@tag",void 0,!0)):dt.push(!!l&&e.gullet.macros.get("\\@eqnsw")==="1"))}for(ht(),Ut.push(Tn(e));;){let dn=e.parseExpression(!1,u?"\\end":"\\\\");e.gullet.endGroup(),e.gullet.beginGroup(),dn={type:"ordgroup",mode:e.mode,body:dn,semisimple:!0},de.push(dn);let _r=e.fetch().text;if(_r==="&"){if(y&&de.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(_r===Te){An(),de.length===1&&dn.body.length===0&&(kt.length>1||!h)&&kt.pop(),Et.push(Ln(dn.body)),Ut.length<kt.length+1&&Ut.push([]);break}if(_r!=="\\\\")throw new t("Expected & or \\\\ or \\cr or "+Te,e.nextToken);{let Zn;e.consume(),e.gullet.future().text!==" "&&(Zn=e.parseSizeGroup(!0)),ct.push(Zn?Zn.value:null),An(),Et.push(Ln(dn.body)),Ut.push(Tn(e)),de=[],kt.push(de),ht()}}}return e.gullet.endGroup(),e.gullet.endGroup(),{type:"array",mode:e.mode,body:kt,cols:n,rowGaps:ct,hLinesBeforeRow:Ut,envClasses:r,autoTag:l,scriptLevel:be,tags:dt,labels:Et,leqno:E,arraystretch:U,arraycolsep:V}}function Qn(e){return e.slice(0,1)==="d"?"display":"text"}let er={c:"center ",l:"left ",r:"right "},zn=e=>{let n=new _("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(V=>V);for(let V=0;V<l;V++){let be=e.body[V],Te=[],de=e.scriptLevel==="text"?Mt:e.scriptLevel==="script"?pt:wt;for(let dt=0;dt<be.length;dt++){let ht=new _("mtd",[tt(be[dt],n.withLevel(de))]);if(e.envClasses.includes("multline")){let An=V===0?"left":V===l-1?"right":"center";An!=="center"&&ht.classes.push("tml-"+An)}Te.push(ht)}let kt=e.body[0].length;for(let dt=0;dt<kt-be.length;dt++)Te.push(new _("mtd",[],[],n));if(h){let dt=e.tags[V],ht;dt===!0?ht=new _("mtext",[new Ve(["tml-eqn"])]):dt===!1?ht=new _("mtext",[],[]):(ht=Je(dt[0].body,n.withLevel(de),!0),ht=ft(ht),ht.classes=["tml-tag"]),ht&&(Te.unshift(zn(e)),Te.push(zn(e)),e.leqno?Te[0].children.push(ht):Te[Te.length-1].children.push(ht))}let ct=new _("mtr",Te,[]),Et=e.labels.shift();Et&&e.tags&&e.tags[V]&&(ct.setAttribute("id",Et),Array.isArray(e.tags[V])&&ct.classes.push("tml-tageqn")),V===0&&u[0].length>0&&(u[0].length===2?ct.children.forEach(dt=>{dt.style.borderTop="0.15em double"}):ct.children.forEach(dt=>{dt.style.borderTop=u[0][0]?"0.06em dashed":"0.06em solid"})),u[V+1].length>0&&(u[V+1].length===2?ct.children.forEach(dt=>{dt.style.borderBottom="0.15em double"}):ct.children.forEach(dt=>{dt.style.borderBottom=u[V+1][0]?"0.06em dashed":"0.06em solid"}));let Ut=!0;for(let dt=0;dt<ct.children.length;dt++){let ht=ct.children[dt].children[0];if(!ht||ht.type!=="mpadded"||ht.attributes.height!=="0px"){Ut=!1;break}}if(Ut){ct.classes.push("ff-squash");for(let dt=0;dt<ct.children.length;dt++)ct.children[dt].style.paddingTop="0",ct.children[dt].style.paddingBottom="0"}r.push(ct)}if(e.arraystretch&&e.arraystretch!==1){let V=String(1.4*e.arraystretch-.8)+"ex";for(let be=0;be<r.length;be++)for(let Te=0;Te<r[be].children.length;Te++)r[be].children[Te].style.paddingTop=V,r[be].children[Te].style.paddingBottom=V}let y,E;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",E="em"),e.arraycolsep){let V=Kt(e.arraycolsep,n);y=V.number.toFixed(4),E=V.unit}if(y){let V=r.length===0?0:r[0].children.length,be=(Te,de)=>Te===0&&de===0||Te===V-1&&de===1?"0":e.envClasses[0]!=="align"?y:de===1?"0":h?Te%2?"1":"0":Te%2?"0":"1";for(let Te=0;Te<r.length;Te++)for(let de=0;de<r[Te].children.length;de++)r[Te].children[de].style.paddingLeft=`${be(de,0)}${E}`,r[Te].children[de].style.paddingRight=`${be(de,1)}${E}`}if(e.envClasses.length===0)for(let V=0;V<r.length;V++)r[V].children[0].style.paddingLeft="0em",r[V].children.length===r[0].children.length&&(r[V].children[r[V].children.length-1].style.paddingRight="0em");if(e.envClasses.length>0){let V=e.envClasses.includes("align")||e.envClasses.includes("alignat");for(let be=0;be<r.length;be++){let Te=r[be];if(V){for(let de=0;de<Te.children.length;de++)Te.children[de].classes=["tml-"+(de%2?"left":"right")];if(h){let de=e.leqno?0:Te.children.length-1;Te.children[de].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 de of Te.children)de.classes.push("tml-left")}}let U=new _("mtable",r);if(e.envClasses.length>0&&(e.envClasses.includes("jot")?U.classes.push("tml-jot"):e.envClasses.includes("small")&&U.classes.push("tml-small")),e.scriptLevel==="display"&&U.setAttribute("displaystyle","true"),(e.autoTag||e.envClasses.includes("multline"))&&(U.style.width="100%"),e.cols&&e.cols.length>0){let V=e.cols,be=!1,Te=0,de=V.length;for(;V[Te].type==="separator";)Te+=1;for(;V[de-1].type==="separator";)de-=1;if(V[0].type==="separator"){let ct=V[1].type==="separator"?"0.15em double":V[0].separator==="|"?"0.06em solid ":"0.06em dashed ";for(let Et of U.children)Et.children[0].style.borderLeft=ct}let kt=h?0:-1;for(let ct=Te;ct<de;ct++)if(V[ct].type==="align"){let Et=er[V[ct].align];kt+=1;for(let Ut of U.children)Et.trim()!=="center"&&kt<Ut.children.length&&(Ut.children[kt].classes=["tml-"+Et.trim()]);be=!0}else if(V[ct].type==="separator"){if(be){let Et=V[ct+1].type==="separator"?"0.15em double":V[ct].separator==="|"?"0.06em solid":"0.06em dashed";for(let Ut of U.children)kt<Ut.children.length&&(Ut.children[kt].style.borderRight=Et)}be=!1}if(V[V.length-1].type==="separator"){let ct=V[V.length-2].type==="separator"?"0.15em double":V[V.length-1].separator==="|"?"0.06em solid":"0.06em dashed";for(let Et of U.children)Et.children[Et.children.length-1].style.borderRight=ct,Et.children[Et.children.length-1].style.paddingRight="0.4em"}}return e.envClasses.includes("small")&&(U=new _("mstyle",[U]),U.setAttribute("scriptlevel","1")),U},gn=function(e,n){e.envName.indexOf("ed")===-1&&wn(e);let r=e.envName==="split",l=[],u=an(e.parser,{cols:l,emptySingleRow:!0,autoTag:r?void 0:Xn(e.envName),envClasses:["abut","jot"],maxNumCols:e.envName==="split"?2:void 0,leqno:e.parser.settings.leqno},"display"),h,y=0,E=e.envName.indexOf("at")>-1;if(n[0]&&E){let U="";for(let V=0;V<n[0].body.length;V++)U+=Ne(n[0].body[V],"textord").text;if(isNaN(U))throw new t("The alignat enviroment requires a numeric first argument.");h=Number(U),y=2*h}u.body.forEach(function(U){if(E){let V=U.length/2;if(h<V)throw new t(`Too many math in a row: expected ${h}, but got ${V}`,U[0])}else y<U.length&&(y=U.length)});for(let U=0;U<y;++U){let V="r";U%2==1&&(V="l"),l[U]={type:"align",align:V}}return e.envName==="split"||(E?u.envClasses.push("alignat"):u.envClasses[0]="align"),u};we({type:"array",names:["array","darray"],props:{numArgs:1},handler(e,n){let r=(M(n[0])?[n[0]]:Ne(n[0],"ordgroup").body).map(function(y){let E=Ge(y).text;if("lcr".indexOf(E)!==-1)return{type:"align",align:E};if(E==="|")return{type:"separator",separator:"|"};if(E===":")return{type:"separator",separator:":"};throw new t("Unknown column alignment: "+E,y)}),[l,u]=Yn(e.parser.gullet.macros),h={cols:r,envClasses:["array"],maxNumCols:r.length,arraystretch:l,arraycolsep:u};return an(e.parser,h,Qn(e.envName))},mathmlBuilder:Xt}),we({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 E=e.parser;if(E.consumeSpaces(),E.fetch().text==="["){if(E.consume(),E.consumeSpaces(),r=E.fetch().text,"lcr".indexOf(r)===-1)throw new t("Expected l or c or r",E.nextToken);E.consume(),E.consumeSpaces(),E.expect("]"),E.consume(),l.cols=[]}}let u=an(e.parser,l,"text");u.cols=u.body.length>0?new Array(u.body[0].length).fill({type:"align",align:r}):[];let[h,y]=Yn(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}),we({type:"array",names:["bordermatrix"],props:{numArgs:0},handler(e){let n=an(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 be=1;be<u.length;be++){h[be-1].push(u[be].shift());let Te=[];for(let de=0;de<u[be].length;de++)Te.push(u[be][de]);h[be-1].push(ge(Te,"vphantom"))}let y=new Array(u.length).fill().map(()=>[]);for(let be=0;be<u[0].length;be++)y[0].push(u[0][be]);for(let be=1;be<u.length;be++)for(let Te=0;Te<u[0].length;Te++)y[be].push(ge(u[be][Te].body,"hphantom"));for(let be=0;be<u[0].length;be++)u[0][be]=ge(u[0][be].body,"hphantom");let E={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"}},U={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}]},V={type:"leftright",mode:"math",body:[r],left:l?l[0]:"(",right:l?l[1]:")",rightColor:void 0};return Fe([E,{type:"supsub",mode:"math",stack:!0,base:{type:"op",mode:"math",limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!0,symbol:!1,suppressBaseShift:!0,body:[V]},sup:U,sub:null}])})(n,e.delimiters)},mathmlBuilder:Xt}),we({type:"array",names:["smallmatrix"],props:{numArgs:0},handler:e=>an(e.parser,{envClasses:["small"]},"script"),mathmlBuilder:Xt}),we({type:"array",names:["subarray"],props:{numArgs:1},handler(e,n){let r=(M(n[0])?[n[0]]:Ne(n[0],"ordgroup").body).map(function(u){let h=Ge(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=an(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}),we({type:"array",names:["cases","dcases","rcases","drcases"],props:{numArgs:0},handler(e){let n=an(e.parser,{cols:[],envClasses:["cases"]},Qn(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}),we({type:"array",names:["align","align*","aligned","split"],props:{numArgs:0},handler:gn,mathmlBuilder:Xt}),we({type:"array",names:["alignat","alignat*","alignedat"],props:{numArgs:1},handler:gn,mathmlBuilder:Xt}),we({type:"array",names:["gathered","gather","gather*"],props:{numArgs:0},handler(e){e.envName!=="gathered"&&wn(e);let n={cols:[],envClasses:["abut","jot"],autoTag:Xn(e.envName),emptySingleRow:!0,leqno:e.parser.settings.leqno};return an(e.parser,n,"display")},mathmlBuilder:Xt}),we({type:"array",names:["equation","equation*"],props:{numArgs:0},handler(e){wn(e);let n={autoTag:Xn(e.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,envClasses:["align"],leqno:e.parser.settings.leqno};return an(e.parser,n,"display")},mathmlBuilder:Xt}),we({type:"array",names:["multline","multline*"],props:{numArgs:0},handler(e){wn(e);let n={autoTag:e.envName==="multline",maxNumCols:1,envClasses:["jot","multline"],leqno:e.parser.settings.leqno};return an(e.parser,n,"display")},mathmlBuilder:Xt}),we({type:"array",names:["CD"],props:{numArgs:0},handler:e=>(wn(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],E=K();for(let U=0;U<y.length;U++)if(se(y[U])){l.push(E),U+=1;let V=Ge(y[U]).text,be=new Array(2);if(be[0]={type:"ordgroup",mode:"math",body:[]},be[1]={type:"ordgroup",mode:"math",body:[]},!("=|.".indexOf(V)>-1)){if(!("<>AV".indexOf(V)>-1))throw new t('Expected one of "<>AV=|." after @.');for(let de=0;de<2;de++){let kt=!0;for(let ct=U+1;ct<y.length;ct++){if(qe(y[ct],V)){kt=!1,U=ct;break}if(se(y[ct]))throw new t("Missing a "+V+" character to complete a CD arrow.",y[ct]);be[de].body.push(y[ct])}if(kt)throw new t("Missing a "+V+" character to complete a CD arrow.",y[U])}}let Te=Qe(V,be,n);l.push(Te),E=K()}else E.body.push(y[U]);h%2==0?l.push(E):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}),N({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 vn=Ee;N({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 U=l[0].body;U.length===1&&U[0].type==="delimiter"&&(u=[U[0].left,U[0].right])}e.consumeSpaces(),e.consume();let h=vn.bordermatrix,y={mode:e.mode,envName:n.slice(1),delimiters:u,parser:e},E=h.handler(y);return e.expect("}",!0),E}}),N({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:v(l)}},mathmlBuilder(e,n){let r=new _("mrow",[tt(e.body,n)],["ff-narrow"]),l=new _("mphantom",[tt(e.body,n)]),u=new _("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 _("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 _("mspace",[]);Te.setAttribute("height","0.85em"),r.children.push(Te)}let y;if(e.isCharacterBox)y=new _("mspace",[]),y.setAttribute("height","1em");else{let Te=tt(e.body,n),de=new _("mpadded",[Te]);de.setAttribute("width","0.1px"),y=new _("mphantom",[de])}let E=tt(e.to,n);E.style.color=n.color;let U=new _("mpadded",[E]);if(!e.isCharacterBox||/[f∫∑]/.test(e.body.body[0].text)){let Te=new _("mspace",[]);Te.setAttribute("width","0.2em"),U.children.unshift(Te)}U.setAttribute("width","0.1px");let V=new _("mover",[y,U]),be=new _("mrow",[],["ff-nudge-left"]);return bt([ke([h,V]),be])}}),N({type:"textord",names:["\\@char"],props:{numArgs:1,allowedInText:!0},handler({parser:e,token:n},r){let l=Ne(r[0],"ordgroup").body,u="";for(let y=0;y<l.length;y++)u+=Ne(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 Sn=/^(#[a-f0-9]{3}|#?[a-f0-9]{6})$/i,Un=/^(#[a-f0-9]{3}|#?[a-f0-9]{6}|[a-z]+)$/i,Hn=/^ *\d{1,3} *(?:, *\d{1,3} *){2}$/,jn=/^ *[10](?:\.\d*)? *(?:, *[10](?:\.\d*)? *){2}$/,Fr=/^[a-f0-9]{6}$/i,Tt=e=>{let n=e.toString(16);return n.length===1&&(n="0"+n),n},Gn=JSON.parse(`{
|
|
1
|
+
/*! Decklight v0.9.0 — Copyright 2026 Gilles Philippart — SPDX-License-Identifier: Apache-2.0 */
|
|
2
|
+
var Decklight=(()=>{var Xu=Object.create;var Wo=Object.defineProperty;var Qu=Object.getOwnPropertyDescriptor;var ep=Object.getOwnPropertyNames;var tp=Object.getPrototypeOf,np=Object.prototype.hasOwnProperty;var Ya=(e,t)=>()=>(e&&(t=e(e=0)),t);var rp=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),sp=(e,t)=>{for(var n in t)Wo(e,n,{get:t[n],enumerable:!0})},Za=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of ep(t))!np.call(e,a)&&a!==n&&Wo(e,a,{get:()=>t[a],enumerable:!(s=Qu(t,a))||s.enumerable});return e};var op=(e,t,n)=>(n=e!=null?Xu(tp(e)):{},Za(t||!e||!e.__esModule?Wo(n,"default",{value:e,enumerable:!0}):n,e)),ip=e=>Za(Wo({},"__esModule",{value:!0}),e);var gt,Se=Ya(()=>{gt={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 pt,Ae=Ya(()=>{pt=["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 Kl=rp((Lb,Gl)=>{Se();Ae();function Ml(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw new Error("map is read-only")}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw new Error("set is read-only")}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach(t=>{let n=e[t],s=typeof n;(s==="object"||s==="function")&&!Object.isFrozen(n)&&Ml(n)}),e}var ri=class{constructor(t){t.data===void 0&&(t.data={}),this.data=t.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function Rl(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ts(e,...t){let n=Object.create(null);for(let s in e)n[s]=e[s];return t.forEach(function(s){for(let a in s)n[a]=s[a]}),n}var Zp="</span>",Cl=e=>!!e.scope,Xp=(e,{prefix:t})=>{if(e.startsWith("language:"))return e.replace("language:","language-");if(e.includes(".")){let n=e.split(".");return[`${t}${n.shift()}`,...n.map((s,a)=>`${s}${"_".repeat(a+1)}`)].join(" ")}return`${t}${e}`},Xi=class{constructor(t,n){this.buffer="",this.classPrefix=n.classPrefix,t.walk(this)}addText(t){this.buffer+=Rl(t)}openNode(t){if(!Cl(t))return;let n=Xp(t.scope,{prefix:this.classPrefix});this.span(n)}closeNode(t){Cl(t)&&(this.buffer+=Zp)}value(){return this.buffer}span(t){this.buffer+=`<span class="${t}">`}},Tl=(e={})=>{let t={children:[]};return Object.assign(t,e),t},Qi=class e{constructor(){this.rootNode=Tl(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(t){this.top.children.push(t)}openNode(t){let n=Tl({scope:t});this.add(n),this.stack.push(n)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(t){return this.constructor._walk(t,this.rootNode)}static _walk(t,n){return typeof n=="string"?t.addText(n):n.children&&(t.openNode(n),n.children.forEach(s=>this._walk(t,s)),t.closeNode(n)),t}static _collapse(t){typeof t!="string"&&t.children&&(t.children.every(n=>typeof n=="string")?t.children=[t.children.join("")]:t.children.forEach(n=>{e._collapse(n)}))}},ea=class extends Qi{constructor(t){super(),this.options=t}addText(t){t!==""&&this.add(t)}startScope(t){this.openNode(t)}endScope(){this.closeNode()}__addSublanguage(t,n){let s=t.root;n&&(s.scope=`language:${n}`),this.add(s)}toHTML(){return new Xi(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}};function Eo(e){return e?typeof e=="string"?e:e.source:null}function Il(e){return Fs("(?=",e,")")}function Qp(e){return Fs("(?:",e,")*")}function eh(e){return Fs("(?:",e,")?")}function Fs(...e){return e.map(n=>Eo(n)).join("")}function th(e){let t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function na(...e){return"("+(th(e).capture?"":"?:")+e.map(s=>Eo(s)).join("|")+")"}function Pl(e){return new RegExp(e.toString()+"|").exec("").length-1}function nh(e,t){let n=e&&e.exec(t);return n&&n.index===0}var rh=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function ra(e,{joinWith:t}){let n=0;return e.map(s=>{n+=1;let a=n,c=Eo(s),h="";for(;c.length>0;){let f=rh.exec(c);if(!f){h+=c;break}h+=c.substring(0,f.index),c=c.substring(f.index+f[0].length),f[0][0]==="\\"&&f[1]?h+="\\"+String(Number(f[1])+a):(h+=f[0],f[0]==="("&&n++)}return h}).map(s=>`(${s})`).join(t)}var sh=/\b\B/,Dl="[a-zA-Z]\\w*",sa="[a-zA-Z_]\\w*",Bl="\\b\\d+(\\.\\d+)?",Fl="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",ql="\\b(0b[01]+)",oh="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",ih=(e={})=>{let t=/^#![ ]*\//;return e.binary&&(e.begin=Fs(t,/.*\b/,e.binary,/\b.*/)),Ts({scope:"meta",begin:t,end:/$/,relevance:0,"on:begin":(n,s)=>{n.index!==0&&s.ignoreMatch()}},e)},$o={begin:"\\\\[\\s\\S]",relevance:0},ah={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[$o]},lh={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[$o]},ch={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/},oi=function(e,t,n={}){let s=Ts({scope:"comment",begin:e,end:t,contains:[]},n);s.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 a=na("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 s.contains.push({begin:Fs(/[ ]+/,"(",a,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),s},dh=oi("//","$"),uh=oi("/\\*","\\*/"),ph=oi("#","$"),hh={scope:"number",begin:Bl,relevance:0},fh={scope:"number",begin:Fl,relevance:0},mh={scope:"number",begin:ql,relevance:0},gh={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[$o,{begin:/\[/,end:/\]/,relevance:0,contains:[$o]}]},bh={scope:"title",begin:Dl,relevance:0},yh={scope:"title",begin:sa,relevance:0},wh={begin:"\\.\\s*"+sa,relevance:0},vh=function(e){return Object.assign(e,{"on:begin":(t,n)=>{n.data._beginMatch=t[1]},"on:end":(t,n)=>{n.data._beginMatch!==t[1]&&n.ignoreMatch()}})},ni=Object.freeze({__proto__:null,APOS_STRING_MODE:ah,BACKSLASH_ESCAPE:$o,BINARY_NUMBER_MODE:mh,BINARY_NUMBER_RE:ql,COMMENT:oi,C_BLOCK_COMMENT_MODE:uh,C_LINE_COMMENT_MODE:dh,C_NUMBER_MODE:fh,C_NUMBER_RE:Fl,END_SAME_AS_BEGIN:vh,HASH_COMMENT_MODE:ph,IDENT_RE:Dl,MATCH_NOTHING_RE:sh,METHOD_GUARD:wh,NUMBER_MODE:hh,NUMBER_RE:Bl,PHRASAL_WORDS_MODE:ch,QUOTE_STRING_MODE:lh,REGEXP_MODE:gh,RE_STARTERS_RE:oh,SHEBANG:ih,TITLE_MODE:bh,UNDERSCORE_IDENT_RE:sa,UNDERSCORE_TITLE_MODE:yh});function kh(e,t){e.input[e.index-1]==="."&&t.ignoreMatch()}function xh(e,t){e.className!==void 0&&(e.scope=e.className,delete e.className)}function Eh(e,t){t&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=kh,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0&&(e.relevance=0))}function $h(e,t){Array.isArray(e.illegal)&&(e.illegal=na(...e.illegal))}function Sh(e,t){if(e.match){if(e.begin||e.end)throw new Error("begin & end are not supported with match");e.begin=e.match,delete e.match}}function Ah(e,t){e.relevance===void 0&&(e.relevance=1)}var Ch=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw new Error("beforeMatch cannot be used with starts");let n=Object.assign({},e);Object.keys(e).forEach(s=>{delete e[s]}),e.keywords=n.keywords,e.begin=Fs(n.beforeMatch,Il(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},Th=["of","and","for","in","not","or","if","then","parent","list","value"],Nh="keyword";function jl(e,t,n=Nh){let s=Object.create(null);return typeof e=="string"?a(n,e.split(" ")):Array.isArray(e)?a(n,e):Object.keys(e).forEach(function(c){Object.assign(s,jl(e[c],t,c))}),s;function a(c,h){t&&(h=h.map(f=>f.toLowerCase())),h.forEach(function(f){let g=f.split("|");s[g[0]]=[c,_h(g[0],g[1])]})}}function _h(e,t){return t?Number(t):Oh(e)?0:1}function Oh(e){return Th.includes(e.toLowerCase())}var Nl={},Bs=e=>{console.error(e)},_l=(e,...t)=>{console.log(`WARN: ${e}`,...t)},Ys=(e,t)=>{Nl[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),Nl[`${e}/${t}`]=!0)},si=new Error;function Hl(e,t,{key:n}){let s=0,a=e[n],c={},h={};for(let f=1;f<=t.length;f++)h[f+s]=a[f],c[f+s]=!0,s+=Pl(t[f-1]);e[n]=h,e[n]._emit=c,e[n]._multi=!0}function Lh(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw Bs("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),si;if(typeof e.beginScope!="object"||e.beginScope===null)throw Bs("beginScope must be object"),si;Hl(e,e.begin,{key:"beginScope"}),e.begin=ra(e.begin,{joinWith:""})}}function Mh(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw Bs("skip, excludeEnd, returnEnd not compatible with endScope: {}"),si;if(typeof e.endScope!="object"||e.endScope===null)throw Bs("endScope must be object"),si;Hl(e,e.end,{key:"endScope"}),e.end=ra(e.end,{joinWith:""})}}function Rh(e){e.scope&&typeof e.scope=="object"&&e.scope!==null&&(e.beginScope=e.scope,delete e.scope)}function Ih(e){Rh(e),typeof e.beginScope=="string"&&(e.beginScope={_wrap:e.beginScope}),typeof e.endScope=="string"&&(e.endScope={_wrap:e.endScope}),Lh(e),Mh(e)}function Ph(e){function t(h,f){return new RegExp(Eo(h),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(f?"g":""))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(f,g){g.position=this.position++,this.matchIndexes[this.matchAt]=g,this.regexes.push([g,f]),this.matchAt+=Pl(f)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);let f=this.regexes.map(g=>g[1]);this.matcherRe=t(ra(f,{joinWith:"|"}),!0),this.lastIndex=0}exec(f){this.matcherRe.lastIndex=this.lastIndex;let g=this.matcherRe.exec(f);if(!g)return null;let b=g.findIndex(($,S)=>S>0&&$!==void 0),y=this.matchIndexes[b];return g.splice(0,b),Object.assign(g,y)}}class s{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(f){if(this.multiRegexes[f])return this.multiRegexes[f];let g=new n;return this.rules.slice(f).forEach(([b,y])=>g.addRule(b,y)),g.compile(),this.multiRegexes[f]=g,g}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(f,g){this.rules.push([f,g]),g.type==="begin"&&this.count++}exec(f){let g=this.getMatcher(this.regexIndex);g.lastIndex=this.lastIndex;let b=g.exec(f);if(this.resumingScanAtSamePosition()&&!(b&&b.index===this.lastIndex)){let y=this.getMatcher(0);y.lastIndex=this.lastIndex+1,b=y.exec(f)}return b&&(this.regexIndex+=b.position+1,this.regexIndex===this.count&&this.considerAll()),b}}function a(h){let f=new s;return h.contains.forEach(g=>f.addRule(g.begin,{rule:g,type:"begin"})),h.terminatorEnd&&f.addRule(h.terminatorEnd,{type:"end"}),h.illegal&&f.addRule(h.illegal,{type:"illegal"}),f}function c(h,f){let g=h;if(h.isCompiled)return g;[xh,Sh,Ih,Ch].forEach(y=>y(h,f)),e.compilerExtensions.forEach(y=>y(h,f)),h.__beforeBegin=null,[Eh,$h,Ah].forEach(y=>y(h,f)),h.isCompiled=!0;let b=null;return typeof h.keywords=="object"&&h.keywords.$pattern&&(h.keywords=Object.assign({},h.keywords),b=h.keywords.$pattern,delete h.keywords.$pattern),b=b||/\w+/,h.keywords&&(h.keywords=jl(h.keywords,e.case_insensitive)),g.keywordPatternRe=t(b,!0),f&&(h.begin||(h.begin=/\B|\b/),g.beginRe=t(g.begin),!h.end&&!h.endsWithParent&&(h.end=/\B|\b/),h.end&&(g.endRe=t(g.end)),g.terminatorEnd=Eo(g.end)||"",h.endsWithParent&&f.terminatorEnd&&(g.terminatorEnd+=(h.end?"|":"")+f.terminatorEnd)),h.illegal&&(g.illegalRe=t(h.illegal)),h.contains||(h.contains=[]),h.contains=[].concat(...h.contains.map(function(y){return Dh(y==="self"?h:y)})),h.contains.forEach(function(y){c(y,g)}),h.starts&&c(h.starts,f),g.matcher=a(g),g}if(e.compilerExtensions||(e.compilerExtensions=[]),e.contains&&e.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=Ts(e.classNameAliases||{}),c(e)}function zl(e){return e?e.endsWithParent||zl(e.starts):!1}function Dh(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(t){return Ts(e,{variants:null},t)})),e.cachedVariants?e.cachedVariants:zl(e)?Ts(e,{starts:e.starts?Ts(e.starts):null}):Object.isFrozen(e)?Ts(e):e}var Bh="11.11.1",ta=class extends Error{constructor(t,n){super(t),this.name="HTMLInjectionError",this.html=n}},Zi=Rl,Ol=Ts,Ll=Symbol("nomatch"),Fh=7,Ul=function(e){let t=Object.create(null),n=Object.create(null),s=[],a=!0,c="Could not find the language '{}', did you forget to load/include a language module?",h={disableAutodetect:!0,name:"Plain text",contains:[]},f={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:ea};function g(V){return f.noHighlightRe.test(V)}function b(V){let Z=V.className+" ";Z+=V.parentNode?V.parentNode.className:"";let T=f.languageDetectRe.exec(Z);if(T){let F=ee(T[1]);return F||(_l(c.replace("{}",T[1])),_l("Falling back to no-highlight mode for this block.",V)),F?T[1]:"no-highlight"}return Z.split(/\s+/).find(F=>g(F)||ee(F))}function y(V,Z,T){let F="",se="";typeof Z=="object"?(F=V,T=Z.ignoreIllegals,se=Z.language):(Ys("10.7.0","highlight(lang, code, ...args) has been deprecated."),Ys("10.7.0",`Please use highlight(code, options) instead.
|
|
3
|
+
https://github.com/highlightjs/highlight.js/issues/2277`),se=V,F=Z),T===void 0&&(T=!0);let _e={code:F,language:se};de("before:highlight",_e);let Te=_e.result?_e.result:$(_e.language,_e.code,T);return Te.code=_e.code,de("after:highlight",Te),Te}function $(V,Z,T,F){let se=Object.create(null);function _e(ke,Fe){return ke.keywords[Fe]}function Te(){if(!te.keywords){Ee.addText(Ke);return}let ke=0;te.keywordPatternRe.lastIndex=0;let Fe=te.keywordPatternRe.exec(Ke),Ve="";for(;Fe;){Ve+=Ke.substring(ke,Fe.index);let et=ft.case_insensitive?Fe[0].toLowerCase():Fe[0],Y=_e(te,et);if(Y){let[ve,Ne]=Y;if(Ee.addText(Ve),Ve="",se[et]=(se[et]||0)+1,se[et]<=Fh&&(ae+=Ne),ve.startsWith("_"))Ve+=Fe[0];else{let ut=ft.classNameAliases[ve]||ve;G(Fe[0],ut)}}else Ve+=Fe[0];ke=te.keywordPatternRe.lastIndex,Fe=te.keywordPatternRe.exec(Ke)}Ve+=Ke.substring(ke),Ee.addText(Ve)}function l(){if(Ke==="")return;let ke=null;if(typeof te.subLanguage=="string"){if(!t[te.subLanguage]){Ee.addText(Ke);return}ke=$(te.subLanguage,Ke,!0,we[te.subLanguage]),we[te.subLanguage]=ke._top}else ke=A(Ke,te.subLanguage.length?te.subLanguage:null);te.relevance>0&&(ae+=ke.relevance),Ee.__addSublanguage(ke._emitter,ke.language)}function d(){te.subLanguage!=null?l():Te(),Ke=""}function G(ke,Fe){ke!==""&&(Ee.startScope(Fe),Ee.addText(ke),Ee.endScope())}function be(ke,Fe){let Ve=1,et=Fe.length-1;for(;Ve<=et;){if(!ke._emit[Ve]){Ve++;continue}let Y=ft.classNameAliases[ke[Ve]]||ke[Ve],ve=Fe[Ve];Y?G(ve,Y):(Ke=ve,Te(),Ke=""),Ve++}}function J(ke,Fe){return ke.scope&&typeof ke.scope=="string"&&Ee.openNode(ft.classNameAliases[ke.scope]||ke.scope),ke.beginScope&&(ke.beginScope._wrap?(G(Ke,ft.classNameAliases[ke.beginScope._wrap]||ke.beginScope._wrap),Ke=""):ke.beginScope._multi&&(be(ke.beginScope,Fe),Ke="")),te=Object.create(ke,{parent:{value:te}}),te}function Qe(ke,Fe,Ve){let et=nh(ke.endRe,Ve);if(et){if(ke["on:end"]){let Y=new ri(ke);ke["on:end"](Fe,Y),Y.isMatchIgnored&&(et=!1)}if(et){for(;ke.endsParent&&ke.parent;)ke=ke.parent;return ke}}if(ke.endsWithParent)return Qe(ke.parent,Fe,Ve)}function ot(ke){return te.matcher.regexIndex===0?(Ke+=ke[0],1):(Pe=!0,0)}function fe(ke){let Fe=ke[0],Ve=ke.rule,et=new ri(Ve),Y=[Ve.__beforeBegin,Ve["on:begin"]];for(let ve of Y)if(ve&&(ve(ke,et),et.isMatchIgnored))return ot(Fe);return Ve.skip?Ke+=Fe:(Ve.excludeBegin&&(Ke+=Fe),d(),!Ve.returnBegin&&!Ve.excludeBegin&&(Ke=Fe)),J(Ve,ke),Ve.returnBegin?0:Fe.length}function K(ke){let Fe=ke[0],Ve=Z.substring(ke.index),et=Qe(te,ke,Ve);if(!et)return Ll;let Y=te;te.endScope&&te.endScope._wrap?(d(),G(Fe,te.endScope._wrap)):te.endScope&&te.endScope._multi?(d(),be(te.endScope,ke)):Y.skip?Ke+=Fe:(Y.returnEnd||Y.excludeEnd||(Ke+=Fe),d(),Y.excludeEnd&&(Ke=Fe));do te.scope&&Ee.closeNode(),!te.skip&&!te.subLanguage&&(ae+=te.relevance),te=te.parent;while(te!==et.parent);return et.starts&&J(et.starts,ke),Y.returnEnd?0:Fe.length}function ue(){let ke=[];for(let Fe=te;Fe!==ft;Fe=Fe.parent)Fe.scope&&ke.unshift(Fe.scope);ke.forEach(Fe=>Ee.openNode(Fe))}let at={};function N(ke,Fe){let Ve=Fe&&Fe[0];if(Ke+=ke,Ve==null)return d(),0;if(at.type==="begin"&&Fe.type==="end"&&at.index===Fe.index&&Ve===""){if(Ke+=Z.slice(Fe.index,Fe.index+1),!a){let et=new Error(`0 width match regex (${V})`);throw et.languageName=V,et.badRule=at.rule,et}return 1}if(at=Fe,Fe.type==="begin")return fe(Fe);if(Fe.type==="illegal"&&!T){let et=new Error('Illegal lexeme "'+Ve+'" for mode "'+(te.scope||"<unnamed>")+'"');throw et.mode=te,et}else if(Fe.type==="end"){let et=K(Fe);if(et!==Ll)return et}if(Fe.type==="illegal"&&Ve==="")return Ke+=`
|
|
4
|
+
`,1;if(bt>1e5&&bt>Fe.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Ke+=Ve,Ve.length}let ft=ee(V);if(!ft)throw Bs(c.replace("{}",V)),new Error('Unknown language: "'+V+'"');let M=Ph(ft),H="",te=F||M,we={},Ee=new f.__emitter(f);ue();let Ke="",ae=0,Ze=0,bt=0,Pe=!1;try{if(ft.__emitTokens)ft.__emitTokens(Z,Ee);else{for(te.matcher.considerAll();;){bt++,Pe?Pe=!1:te.matcher.considerAll(),te.matcher.lastIndex=Ze;let ke=te.matcher.exec(Z);if(!ke)break;let Fe=Z.substring(Ze,ke.index),Ve=N(Fe,ke);Ze=ke.index+Ve}N(Z.substring(Ze))}return Ee.finalize(),H=Ee.toHTML(),{language:V,value:H,relevance:ae,illegal:!1,_emitter:Ee,_top:te}}catch(ke){if(ke.message&&ke.message.includes("Illegal"))return{language:V,value:Zi(Z),illegal:!0,relevance:0,_illegalBy:{message:ke.message,index:Ze,context:Z.slice(Ze-100,Ze+100),mode:ke.mode,resultSoFar:H},_emitter:Ee};if(a)return{language:V,value:Zi(Z),illegal:!1,relevance:0,errorRaised:ke,_emitter:Ee,_top:te};throw ke}}function S(V){let Z={value:Zi(V),illegal:!1,relevance:0,_top:h,_emitter:new f.__emitter(f)};return Z._emitter.addText(V),Z}function A(V,Z){Z=Z||f.languages||Object.keys(t);let T=S(V),F=Z.filter(ee).filter(le).map(d=>$(d,V,!1));F.unshift(T);let se=F.sort((d,G)=>{if(d.relevance!==G.relevance)return G.relevance-d.relevance;if(d.language&&G.language){if(ee(d.language).supersetOf===G.language)return 1;if(ee(G.language).supersetOf===d.language)return-1}return 0}),[_e,Te]=se,l=_e;return l.secondBest=Te,l}function E(V,Z,T){let F=Z&&n[Z]||T;V.classList.add("hljs"),V.classList.add(`language-${F}`)}function L(V){let Z=null,T=b(V);if(g(T))return;if(de("before:highlightElement",{el:V,language:T}),V.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",V);return}if(V.children.length>0&&(f.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(V)),f.throwUnescapedHTML))throw new ta("One of your code blocks includes unescaped HTML.",V.innerHTML);Z=V;let F=Z.textContent,se=T?y(F,{language:T,ignoreIllegals:!0}):A(F);V.innerHTML=se.value,V.dataset.highlighted="yes",E(V,T,se.language),V.result={language:se.language,re:se.relevance,relevance:se.relevance},se.secondBest&&(V.secondBest={language:se.secondBest.language,relevance:se.secondBest.relevance}),de("after:highlightElement",{el:V,result:se,text:F})}function P(V){f=Ol(f,V)}let j=()=>{pe(),Ys("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function U(){pe(),Ys("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let oe=!1;function pe(){function V(){pe()}if(document.readyState==="loading"){oe||window.addEventListener("DOMContentLoaded",V,!1),oe=!0;return}document.querySelectorAll(f.cssSelector).forEach(L)}function D(V,Z){let T=null;try{T=Z(e)}catch(F){if(Bs("Language definition for '{}' could not be registered.".replace("{}",V)),a)Bs(F);else throw F;T=h}T.name||(T.name=V),t[V]=T,T.rawDefinition=Z.bind(null,e),T.aliases&&re(T.aliases,{languageName:V})}function z(V){delete t[V];for(let Z of Object.keys(n))n[Z]===V&&delete n[Z]}function Ce(){return Object.keys(t)}function ee(V){return V=(V||"").toLowerCase(),t[V]||t[n[V]]}function re(V,{languageName:Z}){typeof V=="string"&&(V=[V]),V.forEach(T=>{n[T.toLowerCase()]=Z})}function le(V){let Z=ee(V);return Z&&!Z.disableAutodetect}function ie(V){V["before:highlightBlock"]&&!V["before:highlightElement"]&&(V["before:highlightElement"]=Z=>{V["before:highlightBlock"](Object.assign({block:Z.el},Z))}),V["after:highlightBlock"]&&!V["after:highlightElement"]&&(V["after:highlightElement"]=Z=>{V["after:highlightBlock"](Object.assign({block:Z.el},Z))})}function I(V){ie(V),s.push(V)}function ce(V){let Z=s.indexOf(V);Z!==-1&&s.splice(Z,1)}function de(V,Z){let T=V;s.forEach(function(F){F[T]&&F[T](Z)})}function Ie(V){return Ys("10.7.0","highlightBlock will be removed entirely in v12.0"),Ys("10.7.0","Please use highlightElement now."),L(V)}Object.assign(e,{highlight:y,highlightAuto:A,highlightAll:pe,highlightElement:L,highlightBlock:Ie,configure:P,initHighlighting:j,initHighlightingOnLoad:U,registerLanguage:D,unregisterLanguage:z,listLanguages:Ce,getLanguage:ee,registerAliases:re,autoDetection:le,inherit:Ol,addPlugin:I,removePlugin:ce}),e.debugMode=function(){a=!1},e.safeMode=function(){a=!0},e.versionString=Bh,e.regex={concat:Fs,lookahead:Il,either:na,optional:eh,anyNumberOfTimes:Qp};for(let V in ni)typeof ni[V]=="object"&&Ml(ni[V]);return Object.assign(e,ni),e},Zs=Ul({});Zs.newInstance=()=>Ul({});Gl.exports=Zs;Zs.HighlightJS=Zs;Zs.default=Zs});var Yg={};sp(Yg,{deckConfig:()=>Yu,init:()=>Zu,initTerminals:()=>Jg,registerBuildProvider:()=>mo,version:()=>Vg});Se();Ae();Se();Ae();Se();Ae();Se();Ae();function Xa(e){let t=e.map((h,f)=>({...h,i:f}));t.sort((h,f)=>h.key-f.key||h.i-f.i);let n=[],s=null,a=null,c=!1;for(let h of t){if(s&&h.explicit&&c&&h.key===a){s.push(h.i);continue}s=[h.i],a=h.key,c=h.explicit,n.push(s)}return n}function Qa(e,t){let n=e!=null&&e!=="",s=n?parseInt(e,10):t;return{key:Number.isFinite(s)?s:t,explicit:n}}var cp=new Set(["UL","OL","TABLE","TBODY","DL","SVG"]),dp=new Set(["defs","title","desc","style","metadata","mask","clippath"]),Bi=new Map;function Jo(e,t){Bi.set(e,t)}function Vo(e){return[...e.children].filter(t=>{let n=t.tagName.toLowerCase();return!(dp.has(n)||n==="aside"&&t.classList.contains("notes")||t.hasAttribute("data-build-stay")||t.classList.contains("draw-head")||t.classList.contains("draw-mask"))})}function up(e){if(e.hasAttribute("data-build-self"))return!1;let t=e.tagName.toUpperCase();return cp.has(t)?!0:t==="DIV"||t==="G"?Vo(e).length>=2:!1}function pp(e){if(e.tagName.toUpperCase()==="TABLE"){let n=e.querySelector(":scope > tbody");return n?Vo(n):Vo(e).filter(s=>s.tagName==="TR")}return Vo(e)}function el(e){let t=parseInt(e.getAttribute("data-build-order")??"",10);return Number.isFinite(t)?t:null}function tl(e,t){e.classList.add("build-step"),e.setAttribute("data-build-style",t),e.setAttribute("data-build-state","pending"),t==="draw"&&hp(e)}var nl="path, line, polyline, polygon, circle, ellipse, rect",Ws="http://www.w3.org/2000/svg";function hp(e){let t=(e.matches?.(nl)?[e]:[...e.querySelectorAll(nl)]).filter(a=>!a.closest(".draw-head, .draw-mask")),n=!1;for(let a of t)al(a)&&(n=!0);e.querySelectorAll("text, tspan").forEach(a=>a.classList.add("draw-fade")),n||e.setAttribute("data-build-style","fade")}function al(e){if(e.classList.contains("draw-stroke"))return!0;let t=e.getAttribute("stroke")??getComputedStyle(e).stroke;if(!t||t==="none")return!1;let n=0;try{n=e.getTotalLength()}catch{return!1}if(!n)return!1;let s=e.getAttribute("stroke-dasharray")||e.style.strokeDasharray;fp(s)?bp(e,n,s):s&&(e.dataset.drawOrig=s),e.classList.add("draw-stroke"),e.style.setProperty("--draw-len",String(Math.ceil(n))),e._drawLen=n;for(let[f,g]of Hi){let b=e.getAttribute(f);b&&(e.dataset[g]=b)}let a=Fi(e)&&rl(e,"marker-end","end"),c=Fi(e)&&rl(e,"marker-start","start");return(a||c||e._drawMask)&&(e.style.transition="none",Zo(e).style.strokeDasharray=String(n),e._drawHeads??={},yo(e,0,n)),!0}var fp=e=>!!e&&!/^(?:none|[0\s,.]+)$/i.test(String(e).trim()),Zo=e=>e._drawMask??e,mp=["d","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","width","height","points","pathLength"],gp=0;function bp(e,t,n){let a=(parseFloat(getComputedStyle(e).strokeWidth)||1)+2,c=document.createElementNS(Ws,"mask");c.setAttribute("id",`dl-draw-mask-${++gp}`),c.setAttribute("class","draw-mask"),c.setAttribute("maskUnits","userSpaceOnUse"),c.setAttribute("maskContentUnits","userSpaceOnUse");for(let[y,$]of Object.entries({x:-1e5,y:-1e5,width:2e5,height:2e5}))c.setAttribute(y,String($));let h=y=>{let $=document.createElementNS(Ws,e.tagName.toLowerCase());for(let S of mp)e.hasAttribute(S)&&$.setAttribute(S,e.getAttribute(S));return $.setAttribute("fill",y),$},f=(y,$)=>(y.setAttribute("stroke",$),y.setAttribute("stroke-width",String(a)),y.setAttribute("stroke-linecap","square"),y),g=getComputedStyle(e).fill;g&&g!=="none"&&(c.appendChild(h("white")),c.appendChild(f(h("none"),"black")));let b=f(h("none"),"white");b.setAttribute("class","draw-mask-stroke"),b.style.strokeDasharray=String(t),b.style.strokeDashoffset=String(t),c.appendChild(b),e.after(c),e.setAttribute("mask",`url(#${c.id})`),e.setAttribute("data-draw-masked",""),e.style.strokeDasharray=n,e.style.strokeDashoffset="0",e._drawMask=b}var Hi=[["marker-start","drawMarkerStart"],["marker-mid","drawMarkerMid"],["marker-end","drawMarkerEnd"]];function Ks(e,t){for(let[n,s]of Hi)s in e.dataset&&(e._drawHeads?.[s==="drawMarkerEnd"?"end":s==="drawMarkerStart"?"start":"mid"]||(t?e.setAttribute(n,e.dataset[s]):e.removeAttribute(n)))}var Fi=e=>/^(path|line|polyline|polygon)$/i.test(e.tagName)&&typeof e.getPointAtLength=="function",yp=["fill","stroke","stroke-width","fill-opacity","stroke-opacity","opacity","color","style","class"];function rl(e,t,n){let s=e.getAttribute(t),a=s&&/url\(\s*["']?#([^"')\s]+)["']?\s*\)/.exec(s);if(!a)return!1;let h=e.ownerSVGElement?.querySelector(`[id="${CSS.escape(a[1])}"]`)??document.getElementById(a[1]);if(!h||h.tagName.toLowerCase()!=="marker")return!1;let f=(z,Ce)=>{let ee=parseFloat(h.getAttribute(z));return Number.isFinite(ee)?ee:Ce},g=parseFloat(getComputedStyle(e).strokeWidth)||1,b=(h.getAttribute("markerUnits")??"strokeWidth")==="userSpaceOnUse"?1:g,y=h.viewBox?.baseVal;y&&y.width>0&&y.height>0&&(b*=Math.min(f("markerWidth",3)/y.width,f("markerHeight",3)/y.height));let $=(h.getAttribute("orient")??"0").trim(),S=$==="auto"||$==="auto-start-reverse",A=document.createElementNS(Ws,"g");A.setAttribute("class","draw-head"),A.setAttribute("aria-hidden","true");let E=document.createElementNS(Ws,"g");E.setAttribute("transform",`scale(${b}) translate(${-f("refX",0)} ${-f("refY",0)})`);for(let z of yp)h.hasAttribute(z)&&E.setAttribute(z,h.getAttribute(z));let L=getComputedStyle(e).stroke,P=getComputedStyle(e).fill;for(let z of h.children){let Ce=z.cloneNode(!0);for(let ee of[Ce,...Ce.querySelectorAll("*")]){ee.removeAttribute("id");for(let re of["fill","stroke"]){let le=ee.getAttribute(re);le==="context-stroke"?ee.setAttribute(re,L):le==="context-fill"&&ee.setAttribute(re,P)}}E.appendChild(Ce)}A.appendChild(E),A.style.visibility="hidden",e.after(A);let j=f("refX",0),U=j*b,oe=(f("markerWidth",3)-j)*b;try{let z=E.getBBox();z.width>0&&(U=(j-z.x)*b,oe=(z.x+z.width-j)*b)}catch{}let pe=document.createElementNS(Ws,"clipPath");pe.setAttribute("id",`dl-head-clip-${++wp}`),pe.setAttribute("clipPathUnits","userSpaceOnUse");let D=document.createElementNS(Ws,"rect");return D.setAttribute("y",String(-bo)),D.setAttribute("height",String(2*bo)),pe.appendChild(D),A.appendChild(pe),e._drawHeads??={},e._drawHeads[n]={el:A,prefix:e.getAttribute("transform")?`${e.getAttribute("transform")} `:"",angle:S?null:parseFloat($)||0,reverse:$==="auto-start-reverse"&&n==="start",back:U,front:oe,clipId:pe.id,clipRect:D},e.removeAttribute(t),!0}var wp=0,bo=1e5;function qi(e,t,n){let s=e.el,a=n==="end"||e.reverse,c=a?e.back:e.front;if(!(t>0)||t>=c){s.removeAttribute("clip-path");return}a?(e.clipRect.setAttribute("x",String(-t)),e.clipRect.setAttribute("width",String(bo))):(e.clipRect.setAttribute("x",String(-bo)),e.clipRect.setAttribute("width",String(bo+t))),s.setAttribute("clip-path",`url(#${e.clipId})`)}function vp(e,t,n){let s=Math.max(0,Math.min(n,t)),a=e.getPointAtLength(s),c=e.getPointAtLength(Math.max(0,s-.5)),h=e.getPointAtLength(Math.min(n,s+.5));return{x:a.x,y:a.y,angle:Math.atan2(h.y-c.y,h.x-c.x)*180/Math.PI}}function Yo(e,t,n,s){let{x:a,y:c,angle:h}=vp(e,n,s),f=t.angle??h+(t.reverse?180:0);t.el.setAttribute("transform",`${t.prefix}translate(${a.toFixed(2)} ${c.toFixed(2)}) rotate(${f.toFixed(2)})`)}function yo(e,t,n){Zo(e).style.strokeDashoffset=String(Math.max(0,n-t)),e._drawnLen=t;let s=e._drawHeads??{},a=t>0;s.end&&(Yo(e,s.end,a?t:e._drawFinal??n,n),qi(s.end,t,"end"),s.end.el.style.visibility=a?"":"hidden"),s.start&&(Yo(e,s.start,0,n),qi(s.start,t,"start"),s.start.el.style.visibility=a?"":"hidden")}function kp(e){let t=c=>.75*c*(1-c)*(1-c)+.75*c*c*(1-c)+c*c*c,n=c=>.30000000000000004*c*(1-c)*(1-c)+3*c*c*(1-c)+c*c*c,s=0,a=1;for(let c=0;c<20;c++){let h=(s+a)/2;t(h)<e?s=h:a=h}return n((s+a)/2)}var xp=300;function Ep(e,t){let n=e._drawHeads?.end?.el??e._drawHeads?.start?.el??e._drawMask??e,s=parseFloat(getComputedStyle(n).transitionDuration)*1e3||0;if(!s)return 0;let a=parseFloat(e.getAttribute("data-draw-speed"));return a>0?t/a*1e3:e._drawStops?Math.max(s,t/xp*1e3):s}function ji(e,t,n,s){let a=e._drawnLen??0;e._drawAnim&&($p(e._drawAnim),e._drawAnim=null);let c=Ep(e,Math.abs(t-a));if(!c||a===t){yo(e,t,n),s?.();return}for(let g of Object.values(e._drawHeads??{}))g.el.style.visibility="";a===0&&e._drawHeads?.end&&Yo(e,e._drawHeads.end,0,n);let h=performance.now(),f=g=>{let b=Math.min(1,(g-h)/c),y=a+(t-a)*kp(b);if(b<1){Zo(e).style.strokeDashoffset=String(Math.max(0,n-y)),e._drawnLen=y;for(let[$,S]of Object.entries(e._drawHeads??{}))Yo(e,S,$==="end"?y:0,n),qi(S,y,$);e._drawAnim=sl(f)}else e._drawAnim=null,yo(e,t,n),s?.()};e._drawAnim=sl(f)}var ll=e=>e._drawLen??(parseFloat(e.style.getPropertyValue("--draw-len"))||0);function sl(e){let t={done:!1,raf:0,timer:0},n=()=>{t.done||(t.done=!0,e(performance.now()))};return t.raf=requestAnimationFrame(n),t.timer=setTimeout(n,40),t}function $p(e){e&&(e.done=!0,cancelAnimationFrame(e.raf),clearTimeout(e.timer))}function Sp(e,t){for(let n of e.querySelectorAll(".draw-stroke"))ol(n,t);e.matches?.(".draw-stroke")&&ol(e,t)}function ol(e,t){let n=e.dataset.drawOrig,s=Hi.some(([,a])=>a in e.dataset);if(e._drawHeads){let a=ll(e);t==="pending"?(n&&(e.style.strokeDasharray=String(a)),Ks(e,!1),ji(e,0,a)):ji(e,a,a,()=>{n&&(e.style.strokeDasharray=n,e.style.strokeDashoffset="0"),Ks(e,!0)});return}if(!(!n&&!s))if(t==="done")n&&(e.style.strokeDasharray=n,e.style.strokeDashoffset="0"),Ks(e,!0);else if(t==="pending")e.style.removeProperty("stroke-dasharray"),e.style.removeProperty("stroke-dashoffset"),Ks(e,!1);else{e.style.removeProperty("stroke-dasharray"),e.style.removeProperty("stroke-dashoffset"),Ks(e,!1);let a=()=>{e.closest(".build-step")?.getAttribute("data-build-state")!=="pending"&&(n&&(e.style.strokeDasharray=n,e.style.strokeDashoffset="0"),Ks(e,!0))},c=parseFloat(getComputedStyle(e).transitionDuration)||0;c===0?a():(e.addEventListener("transitionend",a,{once:!0}),setTimeout(a,c*1e3+150))}}function Ap(e,t){let n=String(e??"").trim().split(/[\s,]+/).filter(Boolean),s=n.map(c=>c.endsWith("%")?parseFloat(c)/100:parseFloat(c));if(!s.length||s.some(c=>!Number.isFinite(c)||c<0))return[];let a=n.some(c=>c.endsWith("%"))||s.every(c=>c<=1);return s.map(c=>Math.min(t,a?c*t:c))}function il(e){if(!Fi(e)||!al(e))return null;let t=ll(e),n=Ap(e.getAttribute("data-draw-stops"),t);return n.length?(e._drawHeads||(e.style.transition="none",Zo(e).style.strokeDasharray=String(t),e._drawHeads={},yo(e,0,t)),e._drawFinal=n[n.length-1],e._drawStops=!0,yo(e,0,t),{count:n.length,apply(s){let a=s>0?n[Math.min(s,n.length)-1]:0,c=e.dataset.drawOrig;c&&a<t&&(e.style.strokeDasharray=String(t)),ji(e,a,t,()=>{c&&a>=t&&(e.style.strokeDasharray=c,e.style.strokeDashoffset="0")})},label:s=>`draw to stop ${s}`}):null}function zi(e){let t=[],n=[],s=new Set,a=0,c=(y,$)=>{t.push(y),n.push(Qa($,a)),a++},h=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);for(let y=h.nextNode();y;y=h.nextNode()){if(s.has(y))continue;let $=Bi.get(y);if(!$&&y.hasAttribute("data-draw-stops")&&($=il(y),$&&Jo(y,$)),$){let A=el(y);for(let E=0;E<$.count;E++)c({kind:"provider",provider:$,el:y,sub:E},A===null?null:String(A+E));y.querySelectorAll("*").forEach(E=>s.add(E));continue}if(!y.hasAttribute("data-build"))continue;let S=y.getAttribute("data-build")||"fade";if(up(y)){for(let A of pp(y)){if(s.add(A),A.querySelectorAll("[data-build]").forEach(L=>s.add(L)),A.hasAttribute("data-draw-stops")){let L=Bi.get(A)??il(A);if(L){Jo(A,L);let P=el(A);for(let j=0;j<L.count;j++)c({kind:"provider",provider:L,el:A,sub:j},P===null?null:String(P+j));continue}}let E=A.getAttribute("data-build")||S;tl(A,E),c({kind:"dom",el:A,container:y},A.getAttribute("data-build-order"))}y.setAttribute("data-build-container","")}else tl(y,S),c({kind:"dom",el:y,container:null},y.getAttribute("data-build-order"))}let f=Xa(n),g=[],b=new Map;return t.forEach((y,$)=>{if(y.kind==="provider"){if(!b.has(y.provider)){let S={el:y.el,provider:y.provider,stepIdxs:[]};b.set(y.provider,S),g.push(S)}b.get(y.provider).stepIdxs.push($)}}),{steps:t,groups:f,providers:g}}function As(e,t){let n=new Set;e.groups.forEach((h,f)=>{for(let g of h)f<t&&n.add(g)});let s=t>0?e.groups[t-1]??[]:[],a=new Set(s),c=new Set;e.steps.forEach((h,f)=>{if(h.kind!=="dom")return;let g=a.has(f)?"current":n.has(f)?"done":"pending";h.el.setAttribute("data-build-state",g),h.el.getAttribute("data-build-style")==="draw"&&Sp(h.el,g),h.container&&c.add(h.container)});for(let h of c){let f=!!h.querySelector(':scope [data-build-style="highlight"][data-build-state="current"]');h.classList.toggle("has-current-highlight",f)}for(let h of e.providers){let f=h.stepIdxs.filter(g=>n.has(g)||a.has(g)).length;h._last!==f&&(h._last=f,h.provider.apply(f))}}function Xo(e){return e.groups.map(t=>{let n=e.steps[t[0]];if(n.kind==="provider"){let a=n.sub;return n.provider.label?n.provider.label(a+1):"step"}return n.el.textContent.trim().replace(/\s+/g," ").slice(0,60)||n.el.tagName.toLowerCase()})}Se();Ae();var Ui="rect, circle, ellipse, polygon, polyline, path",cl=/^--d-fill-[1-6](?:-in)?$/,wo=new Map,Gi=new Map;function dl(e){let t={};for(let n of e??[]){let s=new Map((n?.roles??[]).map(a=>[a.id,a.token]));for(let[a,c]of Object.entries(n?.contract??{})){let h=s.get(c);cl.test(a)&&typeof h=="string"&&!(a in t)&&(t[a]=h)}}return t}function ul(e={}){wo=new Map,Gi=new Map;for(let[t,n]of Object.entries(e??{}))!cl.test(t)||!/^--[A-Za-z0-9_-]+$/.test(String(n))||wo.has(n)||(wo.set(n,t),Gi.set(t,n))}var Cp=/^\s*var\(\s*(--[A-Za-z0-9_-]+)\s*(?:,\s*(?:#[0-9a-f]{3,8}|var\(\s*--d-fill-[1-6](?:-in2?)?\s*\))\s*)?\)\s*$/i;function Vs(e){let t=wo.size?Cp.exec(e??""):null,n=t&&wo.get(t[1]);return n?`var(${n})`:e}function Qo(e){let t=Gi.get(e);return t?`var(${t}, var(${e}))`:`var(${e})`}function ei(e){let t=5381;for(let n of String(e))t=(t*33^n.charCodeAt(0))>>>0;return 1+t%6}function Cs(e,t={}){let n=t[e];return typeof n=="number"?Qo(`--d-fill-${n}`):typeof n=="string"?n:Qo(`--d-fill-${ei(e)}`)}function Js(e,t={}){let n=new Map;e.querySelectorAll("svg [data-concept]").forEach(s=>{let a=s.getAttribute("data-concept");if(!a)return;let c=Cs(a,t),h=Vs(c).match(/--d-fill-(\d)/);if(h){let g=n.get(h[1]);g&&g!==a?console.warn(`Decklight: concepts "${g}" and "${a}" share fill slot ${h[1]} \u2014 pin one explicitly via init({ concepts: { ${a}: <1-6> } })`):n.set(h[1],a)}let f=s.matches(Ui)?[s]:[...s.children].filter(g=>g.matches(Ui));for(let g of f){let b=g.getAttribute("fill")==="none"||g.style.fill==="none";g.style.setProperty(b?"stroke":"fill",c)}})}var Tp=["fill","stroke","filter","clip-path","mask","marker-start","marker-mid","marker-end","style"];function pl(e){e.querySelectorAll("svg").forEach((t,n)=>{let s=`svg${n}-`,a=new Map;if(t.querySelectorAll("[id]").forEach(h=>{let f=h.id;a.set(f,s+f),h.id=s+f}),a.size===0)return;let c=h=>h.replace(/url\(['"]?#([^'")]+)['"]?\)/g,(f,g)=>a.has(g)?`url(#${a.get(g)})`:f);t.querySelectorAll("*").forEach(h=>{for(let f of Tp){let g=h.getAttribute(f);g&&g.includes("url(#")&&h.setAttribute(f,c(g))}for(let f of["href","xlink:href"]){let g=h.getAttribute(f);g&&g.startsWith("#")&&a.has(g.slice(1))&&h.setAttribute(f,"#"+a.get(g.slice(1)))}})})}var hl=/^\s*var\(\s*--d-fill-([1-6])\s*\)\s*$/,Np=/^\s*var\(\s*--d-fill-in\s*\)\s*$/;function fl(e){return e.dataset.nestFill!==void 0?e.dataset.nestFill:e.style.fill||e.getAttribute("fill")||""}function _p(e){if(e.hasAttribute("data-concept")?e:e.parentElement?.hasAttribute("data-concept")?e.parentElement:null){let s=/var\(--d-fill-(\d)\)/.exec(Vs(e.style.fill||""));return s?{slot:Number(s[1]),concept:!0}:{slot:null,concept:!0}}let n=hl.exec(Vs(fl(e)));return n?{slot:Number(n[1]),concept:!1}:null}function Op(e){let t;try{t=e.getBBox()}catch{return null}if(!t||!(t.width>0)||!(t.height>0))return null;let n=e.getCTM();if(!n)return{x:t.x,y:t.y,w:t.width,h:t.height};let s=[[t.x,t.y],[t.x+t.width,t.y],[t.x,t.y+t.height],[t.x+t.width,t.y+t.height]].map(([g,b])=>({x:n.a*g+n.c*b+n.e,y:n.b*g+n.d*b+n.f})),a=s.map(g=>g.x),c=s.map(g=>g.y),h=Math.min(...a),f=Math.min(...c);return{x:h,y:f,w:Math.max(...a)-h,h:Math.max(...c)-f}}var Lp=(e,t,n=.5)=>t.x>=e.x-n&&t.y>=e.y-n&&t.x+t.w<=e.x+e.w+n&&t.y+t.h<=e.y+e.h+n,Mp=(e,t)=>{let n=t.x+t.w/2,s=t.y+t.h/2;return n>=e.x&&n<=e.x+e.w&&s>=e.y&&s<=e.y+e.h};function vo(e){e.querySelectorAll("svg").forEach(t=>{if(t.classList.contains("chart-svg"))return;let n=[...t.querySelectorAll(Ui)].filter(c=>!c.closest('[data-nest="off"], mask')),s=new Map,a=[];for(let c of n){let h=fl(c),f=Np.test(h),g=_p(c),b=h==="none"||c.getAttribute("fill")==="none";if(!g&&!f){!b&&!hl.test(Vs(h))&&a.push(null);continue}let y=Op(c);if(!y)continue;let $=null;if(!g?.concept){let E=c.getAttribute("data-nest")==="on";for(let L of a)!L||!(E?Mp(L.box,y):Lp(L.box,y))||L.box.w*L.box.h>=y.w*y.h&&(!$||L.box.w*L.box.h<$.box.w*$.box.h)&&($=L)}c.dataset.nestFill===void 0&&(c.dataset.nestFill=h);let S=g?.slot??null,A=0;$&&$.slot?(S=$.slot,A=Math.min(2,$.depth+1),c.style.fill=Qo(`--d-fill-${S}-in${A===2?"2":""}`)):f?(S=1,A=1,c.style.fill=Qo("--d-fill-1-in")):g?.concept||(c.style.fill=h),s.set(c,{slot:S,depth:A}),!b&&S&&a.push({el:c,box:y,slot:S,depth:A})}})}Se();Ae();Se();Ae();var Et=e=>String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");var ml=640,Rp=360,gl=["bar","line","area","pie","donut","scatter"],Ki=e=>e==="scatter",dt=e=>{let t=Math.round(e*100)/100;return Object.is(t,-0)?"0":String(t)},Ds=e=>`var(--d-fill-${e%6+1})`;function Ip(e,t={}){let n;if(typeof e=="string")try{n=JSON.parse(e)}catch(b){throw new Error(`invalid JSON \u2014 ${b.message}`)}else if(e&&typeof e=="object")n=e;else throw new Error('no data \u2014 expected a <script type="application/json"> child (or the fence body)');let s=String(t.type||n.type||"").toLowerCase();if(!gl.includes(s))throw new Error(`unknown type "${s}" \u2014 use ${gl.join(" | ")}`);if(!Ki(s)&&(!Array.isArray(n.labels)||n.labels.length===0))throw new Error('"labels" must be a non-empty array');if(!Array.isArray(n.series)||n.series.length===0)throw new Error('"series" must be a non-empty array');let a=Ki(s)?[]:n.labels.map(String),c=n.series.map((b,y)=>{if(Ki(s)){if(!b||!Array.isArray(b.points))throw new Error(`series ${y+1}: "points" must be an array of [x, y] pairs`);let $=b.points.map(S=>Array.isArray(S)?[Number(S[0]),Number(S[1])]:[NaN,NaN]).filter(([S,A])=>Number.isFinite(S)&&Number.isFinite(A));if(!$.length)throw new Error(`series ${y+1}: no usable [x, y] pairs`);return{name:b.name!=null?String(b.name):`series ${y+1}`,concept:b.concept!=null?String(b.concept):null,points:$,data:$.map(([,S])=>S)}}if(!b||!Array.isArray(b.data))throw new Error(`series ${y+1}: "data" must be an array of numbers`);return{name:b.name!=null?String(b.name):`series ${y+1}`,concept:b.concept!=null?String(b.concept):null,data:a.map(($,S)=>{let A=Number(b.data[S]);return Number.isFinite(A)?A:null})}}),h=s==="pie"||s==="donut";if(h&&c.length>1)throw new Error("pie takes exactly one series (labels are the slices)");if(h&&!c[0].data.some(b=>b>0))throw new Error("pie needs at least one positive value");let f=Rp,g=t.aspect??n.aspect??null;if(g!=null){let b=String(g).match(/^\s*(\d+(?:\.\d+)?)\s*[:x]\s*(\d+(?:\.\d+)?)\s*$/i);if(!b||+b[1]==0)throw new Error(`bad aspect "${g}" \u2014 use "w:h", e.g. "4:3"`);f=Math.round(ml*+b[2]/+b[1])}return{type:h?"pie":s,donut:s==="donut"||n.donut===!0,title:t.title??(n.title!=null?String(n.title):null),xTitle:n.x!=null?String(n.x):null,yTitle:n.y!=null?String(n.y):null,labels:a,series:c,legend:n.legend,width:ml,height:f,build:n.build}}function Wi(e,t,n=5){if(!Number.isFinite(e)||!Number.isFinite(t))throw new Error("niceTicks: non-finite range");if(e>t&&([e,t]=[t,e]),e===t){let $=e===0?1:Math.abs(e)/2;e-=e===0?0:$,t+=$}let s=(t-e)/Math.max(1,n-1),a=10**Math.floor(Math.log10(s)),c=s/a,h=(c<=1?1:c<=2?2:c<=2.5?2.5:c<=5?5:10)*a,f=Math.floor(e/h+1e-9)*h,g=Math.ceil(t/h-1e-9)*h,b=Math.max(1,Math.round((g-f)/h)),y=Array.from({length:b+1},($,S)=>+(f+S*h).toPrecision(12));return{min:y[0],max:y[b],step:h,ticks:y}}function Vi(e,t){let n=0;for(;n<6&&Math.abs(Math.round(t*10**n)-t*10**n)>1e-9;)n++;return e.toFixed(n)}function Pp(e,t,n,s){let a=s.max-s.min||1,c=y=>n.y+n.h*(1-(y-s.min)/a),h=c(Math.max(s.min,Math.min(s.max,0))),f=n.w/t,g=f*.72,b=g/e.length;return e.map((y,$)=>Array.from({length:t},(S,A)=>{let E=y.data[A];if(E==null||!Number.isFinite(E))return null;let L=c(E);return{x:n.x+A*f+(f-g)/2+$*b+1,y:Math.min(L,h),w:Math.max(1,b-2),h:Math.abs(h-L),value:E}}))}function Dp(e){let t="",n=!1;for(let s of e){if(!s){n=!1;continue}t+=`${n?"L":"M"}${dt(s.x)} ${dt(s.y)}`,n=!0}return t}function Bp(e,t){let n=e.filter(Boolean);if(!n.length)return"";let s=`M${dt(n[0].x)} ${dt(t)}`;for(let a of n)s+=`L${dt(a.x)} ${dt(a.y)}`;return s+=`L${dt(n[n.length-1].x)} ${dt(t)}Z`,s}function Fp(e,t,n,s,a=0){let c=e.map(b=>Math.max(0,Number(b)||0)),h=c.reduce((b,y)=>b+y,0);if(h<=0)throw new Error("pie needs at least one positive value");let f=(b,y)=>[t+y*Math.cos(b),n+y*Math.sin(b)],g=-Math.PI/2;return c.map(b=>{let y=b/h,$=g,S=g+y*2*Math.PI;g=S;let A=($+S)/2,E=a>0?(s+a)/2:s*.66,[L,P]=f(A,E),[j,U]=f(A,s+14),oe={value:b,frac:y,mid:A,labelX:L,labelY:P,outX:j,outY:U,anchor:Math.cos(A)<-1e-6?"end":Math.cos(A)>1e-6?"start":"middle"};if(y===0)return{...oe,d:""};let pe;if(y>=.9999){let[D,z]=f($,s),[Ce,ee]=f($+Math.PI,s);if(pe=`M${dt(D)} ${dt(z)}A${dt(s)} ${dt(s)} 0 1 1 ${dt(Ce)} ${dt(ee)}A${dt(s)} ${dt(s)} 0 1 1 ${dt(D)} ${dt(z)}Z`,a>0){let[re,le]=f($,a),[ie,I]=f($+Math.PI,a);pe+=`M${dt(re)} ${dt(le)}A${dt(a)} ${dt(a)} 0 1 0 ${dt(ie)} ${dt(I)}A${dt(a)} ${dt(a)} 0 1 0 ${dt(re)} ${dt(le)}Z`}}else{let D=S-$>Math.PI?1:0,[z,Ce]=f($,s),[ee,re]=f(S,s);if(a>0){let[le,ie]=f(S,a),[I,ce]=f($,a);pe=`M${dt(z)} ${dt(Ce)}A${dt(s)} ${dt(s)} 0 ${D} 1 ${dt(ee)} ${dt(re)}L${dt(le)} ${dt(ie)}A${dt(a)} ${dt(a)} 0 ${D} 0 ${dt(I)} ${dt(ce)}Z`}else pe=`M${dt(t)} ${dt(n)}L${dt(z)} ${dt(Ce)}A${dt(s)} ${dt(s)} 0 ${D} 1 ${dt(ee)} ${dt(re)}Z`}return{...oe,d:pe}})}var ms='fill="var(--d-text)"';function ti(e,t){return`<g class="chart-series" data-series="${t+1}" data-name="${Et(e.name)}"`+(e.concept?` data-concept="${Et(e.concept)}"`:"")+">"}function qp(e,t,n){let s=e.series.flatMap(E=>E.data).filter(E=>E!=null),a=Math.min(0,...s),c=Math.max(0,...s),h=Wi(a,c===a?a+1:c,5),f=h.ticks.map(E=>Vi(E,h.step)),g=14+Math.max(...f.map(E=>E.length))*6.6+8,b={x:g,y:e.title||Ji(e)?40:18,w:e.width-g-14,h:0};b.h=e.height-b.y-34;let y=h.max-h.min||1,$=E=>b.y+b.h*(1-(E-h.min)/y);h.ticks.forEach((E,L)=>{let P=$(E);t.push(`<line class="chart-grid" x1="${dt(b.x)}" y1="${dt(P)}" x2="${dt(b.x+b.w)}" y2="${dt(P)}" stroke="var(--d-muted)" stroke-opacity="0.35" stroke-width="1"/>`),t.push(`<text class="chart-tick" x="${dt(b.x-8)}" y="${dt(P+4)}" text-anchor="end" font-size="11" ${ms}>${Et(f[L])}</text>`)}),t.push(`<line class="chart-axis" x1="${dt(b.x)}" y1="${dt(b.y)}" x2="${dt(b.x)}" y2="${dt(b.y+b.h)}" stroke="var(--d-stroke)" stroke-width="1.5"/>`);let S=$(Math.max(h.min,Math.min(h.max,0)));t.push(`<line class="chart-axis" x1="${dt(b.x)}" y1="${dt(S)}" x2="${dt(b.x+b.w)}" y2="${dt(S)}" stroke="var(--d-stroke)" stroke-width="1.5"/>`);let A=b.w/e.labels.length;if(e.labels.forEach((E,L)=>{t.push(`<text class="chart-cat" x="${dt(b.x+(L+.5)*A)}" y="${dt(b.y+b.h+20)}" text-anchor="middle" font-size="12" ${ms}>${Et(E)}</text>`)}),e.type==="bar"){let E=Pp(e.series,e.labels.length,b,h);e.series.forEach((L,P)=>{n.push(ti(L,P)),E[P].forEach(j=>{j&&n.push(`<rect class="chart-bar draw-fade" x="${dt(j.x)}" y="${dt(j.y)}" width="${dt(j.w)}" height="${dt(j.h)}" rx="2" fill="${Ds(P)}" stroke="var(--d-stroke)" stroke-width="1.5"/>`)}),n.push("</g>")})}else e.series.forEach((E,L)=>{let P=E.data.map((oe,pe)=>oe==null?null:{x:b.x+(pe+.5)*A,y:$(oe)}),j=Dp(P),U='stroke-linejoin="round" stroke-linecap="round"';if(n.push(ti(E,L)),e.type==="area"&&n.push(`<path class="chart-area draw-fade" d="${Bp(P,S)}" fill="${Ds(L)}" fill-opacity="0.35"/>`),n.push(`<g class="chart-casing"><path d="${j}" fill="none" stroke="var(--d-stroke)" stroke-width="4.5" ${U}/></g>`),n.push(`<path class="chart-line" d="${j}" fill="none" stroke="${Ds(L)}" stroke-width="2.5" ${U}/>`),e.type==="line")for(let oe of P)oe&&n.push(`<circle class="chart-dot draw-fade" cx="${dt(oe.x)}" cy="${dt(oe.y)}" r="4" fill="${Ds(L)}" stroke="var(--d-stroke)" stroke-width="1"/>`);n.push("</g>")})}function jp(e,t,n){let s=e.series.flatMap(P=>P.points.map(([j])=>j)),a=e.series.flatMap(P=>P.points.map(([,j])=>j)),c=Wi(Math.min(...s),Math.max(...s)===Math.min(...s)?Math.min(...s)+1:Math.max(...s),5),h=Wi(Math.min(0,...a),Math.max(...a)===Math.min(0,...a)?Math.max(...a)+1:Math.max(...a),5),f=h.ticks.map(P=>Vi(P,h.step)),g=c.ticks.map(P=>Vi(P,c.step)),b=14+Math.max(...f.map(P=>P.length))*6.6+8+(e.yTitle?16:0),y=34+(e.xTitle?18:0),$={x:b,y:e.title||Ji(e)?40:18,w:e.width-b-18,h:0};$.h=e.height-$.y-y;let S=c.max-c.min||1,A=h.max-h.min||1,E=P=>$.x+$.w*((P-c.min)/S),L=P=>$.y+$.h*(1-(P-h.min)/A);if(h.ticks.forEach((P,j)=>{let U=L(P);t.push(`<line class="chart-grid" x1="${dt($.x)}" y1="${dt(U)}" x2="${dt($.x+$.w)}" y2="${dt(U)}" stroke="var(--d-muted)" stroke-opacity="0.35" stroke-width="1"/>`),t.push(`<text class="chart-tick" x="${dt($.x-8)}" y="${dt(U+4)}" text-anchor="end" font-size="11" ${ms}>${Et(f[j])}</text>`)}),c.ticks.forEach((P,j)=>{let U=E(P);t.push(`<line class="chart-grid" x1="${dt(U)}" y1="${dt($.y)}" x2="${dt(U)}" y2="${dt($.y+$.h)}" stroke="var(--d-muted)" stroke-opacity="0.35" stroke-width="1"/>`),t.push(`<text class="chart-cat" x="${dt(U)}" y="${dt($.y+$.h+20)}" text-anchor="middle" font-size="12" ${ms}>${Et(g[j])}</text>`)}),t.push(`<line class="chart-axis" x1="${dt($.x)}" y1="${dt($.y)}" x2="${dt($.x)}" y2="${dt($.y+$.h)}" stroke="var(--d-stroke)" stroke-width="1.5"/>`),t.push(`<line class="chart-axis" x1="${dt($.x)}" y1="${dt($.y+$.h)}" x2="${dt($.x+$.w)}" y2="${dt($.y+$.h)}" stroke="var(--d-stroke)" stroke-width="1.5"/>`),e.xTitle&&t.push(`<text class="chart-axis-title" x="${dt($.x+$.w/2)}" y="${dt(e.height-8)}" text-anchor="middle" font-size="12" ${ms}>${Et(e.xTitle)}</text>`),e.yTitle){let j=$.y+$.h/2;t.push(`<text class="chart-axis-title" x="${dt(16)}" y="${dt(j)}" text-anchor="middle" font-size="12" ${ms} transform="rotate(-90 ${dt(16)} ${dt(j)})">${Et(e.yTitle)}</text>`)}e.series.forEach((P,j)=>{n.push(ti(P,j));for(let[U,oe]of P.points)n.push(`<circle class="chart-dot draw-fade" cx="${dt(E(U))}" cy="${dt(L(oe))}" r="5" fill="${Ds(j)}" stroke="var(--d-stroke)" stroke-width="1.5"/>`);n.push("</g>")})}function Hp(e,t){let n=e.title?40:16,s=e.width/2,a=n+(e.height-n-12)/2,c=Math.max(24,Math.min((e.height-n-12)/2-26,e.width/2-110)),h=Fp(e.series[0].data.map(f=>f??0),s,a,c,e.donut?c*.55:0);t.push(ti(e.series[0],0)),h.forEach((f,g)=>{f.d&&(t.push(`<path class="chart-slice draw-fade" d="${f.d}" fill="${Ds(g)}" fill-rule="evenodd" stroke="var(--d-stroke)" stroke-width="1.5" stroke-linejoin="round"/>`),t.push(`<text class="chart-cat draw-fade" x="${dt(f.outX)}" y="${dt(f.outY+4)}" text-anchor="${f.anchor}" font-size="12" ${ms}>${Et(e.labels[g])}</text>`),f.frac>=.05&&t.push(`<text class="chart-value draw-fade" x="${dt(f.labelX)}" y="${dt(f.labelY+4)}" text-anchor="middle" font-size="12" font-weight="600" ${ms}>${Math.round(f.frac*100)}%</text>`))}),t.push("</g>")}function Ji(e){return e.legend===!0?!0:e.legend===!1?!1:e.type!=="pie"&&e.series.length>1}function zp(e){let t=[],n=[];if(e.title&&t.push(`<text class="chart-title" x="14" y="24" font-size="15" font-weight="600" ${ms}>${Et(e.title)}</text>`),Ji(e)){let a=e.series.map(h=>({name:h.name,w:h.name.length*6.6+24})),c=e.width-14-a.reduce((h,f)=>h+f.w,0);e.series.forEach((h,f)=>{t.push(`<rect class="chart-swatch" x="${dt(c)}" y="14" width="11" height="11" rx="2" fill="${Ds(f)}" stroke="var(--d-stroke)" stroke-width="1"/>`),t.push(`<text class="chart-legend" x="${dt(c+16)}" y="24" font-size="12" ${ms}>${Et(h.name)}</text>`),c+=a[f].w})}e.type==="pie"?Hp(e,n):e.type==="scatter"?jp(e,t,n):qp(e,t,n);let s=e.title?`${e.title} \u2014 ${e.type} chart`:`${e.type} chart`;return`<svg class="chart-svg" viewBox="0 0 ${e.width} ${e.height}" role="img" aria-label="${Et(s)}" preserveAspectRatio="xMidYMid meet"><g class="chart-chrome" data-build-stay>${t.join("")}</g>`+n.join("")+"</svg>"}function bl(e){e.querySelectorAll("[data-chart]").forEach(t=>{if(t.querySelector(":scope > svg.chart-svg, :scope > .chart-broken"))return;t.classList.add("chart");let n=t.querySelector('script[type="application/json"]');try{let s=Ip(n?n.textContent:null,{type:t.getAttribute("data-chart")||void 0,title:t.getAttribute("data-title")||void 0,aspect:t.getAttribute("data-aspect")||void 0}),a=document.createElement("template");a.innerHTML=zp(s);let c=a.content.firstElementChild;t.hasAttribute("data-build")?(c.setAttribute("data-build",t.getAttribute("data-build")),t.removeAttribute("data-build")):s.build!=null&&s.build!==!1&&c.setAttribute("data-build",s.build===!0?"":String(s.build)),t.getAttribute("data-chart")||t.setAttribute("data-chart",s.donut?"donut":s.type),t.insertBefore(c,n)}catch(s){let a=document.createElement("div");a.className="chart-broken",a.textContent=`chart: ${s.message||s}`,t.insertBefore(a,n)}})}Se();Ae();Se();Ae();function ko(e,t){let n=String(e??"").trim(),s=parseFloat(n);return!Number.isFinite(s)||s<=0?t:n.endsWith("ms")?s:n.endsWith("s")?s*1e3:s}var xo=["opacity","color","backgroundColor","borderRadius","fontSize"],yl=(e=xo)=>["transform",...e.map(t=>t.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`))];function wl(e,t,n,s=!1){let a=n?.x||1,c=n?.y||1,h=(e.rect.left-t.rect.left)/a,f=(e.rect.top-t.rect.top)/c,g=s||!t.rect.width?1:e.rect.width/t.rect.width,b=s||!t.rect.height?1:e.rect.height/t.rect.height;return{dx:h,dy:f,sx:g,sy:b}}function vl({dx:e,dy:t,sx:n,sy:s}){return!e&&!t&&n===1&&s===1?"":`translate(${e}px, ${t}px) scale(${n}, ${s})`}var Yi=(e,t)=>e||t||"fade";function kl(e,t){if(e==="none")return null;let n=`dir-${t}`;return{entering:["entering",`tr-${e}`,n],leaving:["leaving",`tr-${e}`,n,"active-out"]}}var Up=yl();function xl(e){let t=getComputedStyle(e),n={rect:e.getBoundingClientRect()};for(let s of xo)n[s]=t[s];return n}function Gp(e,t){if(e.ownerSVGElement){let n=e.getScreenCTM?.();if(n&&n.a&&n.d)return{x:n.a,y:n.d}}return{x:t,y:t}}function El(e,t,n){let s=ko(getComputedStyle(t).getPropertyValue("--auto-animate-duration"),500),a=new Map;e.querySelectorAll("[data-id]").forEach(f=>{a.set(f.getAttribute("data-id"),xl(f))});let c=[];t.querySelectorAll("[data-id]").forEach(f=>{let g=a.get(f.getAttribute("data-id"));g&&c.push({el:f,o:g})});for(let{el:f,o:g}of c){let b=xl(f),y=Gp(f,n),$=f.children.length===0&&g.fontSize!==b.fontSize,S=wl(g,b,y,$),A=f.getAttribute("style")??"";f.style.transition="none",f.ownerSVGElement&&(f.style.transformBox="fill-box"),f.style.transformOrigin="0 0",f.style.transform=vl(S);for(let L of xo)f.style[L]=g[L];f.offsetWidth,f.style.transition=Up.map(L=>`${L} ${s}ms ease`).join(", "),f.style.transform="";for(let L of xo)f.style[L]=b[L];let E=()=>{A?f.setAttribute("style",A):f.removeAttribute("style"),f.removeEventListener("transitionend",E)};f.addEventListener("transitionend",E),setTimeout(E,s+80)}let h=new Set(c.map(f=>f.el));return[...t.children].forEach(f=>{f.matches("aside.notes")||h.has(f)||[...h].some(b=>f.contains(b))||(f.classList.add("aa-fresh"),requestAnimationFrame(()=>requestAnimationFrame(()=>f.classList.add("aa-in"))),setTimeout(()=>f.classList.remove("aa-fresh","aa-in"),s+120))}),s}Se();Ae();Se();Ae();var $l=function(){"use strict";class e{constructor(o,i){let u,p=" "+o,v=i&&i.loc;if(v&&v.start<=v.end){let R=v.lexer.input;u=v.start;let ge=v.end;u===R.length?p+=" at end of input: ":p+=" at position "+(u+1)+`:
|
|
5
|
+
`;let Me=R.slice(u,ge).replace(/[^]/g,"$&\u0332"),We,rt;We=u>15?"\u2026"+R.slice(u-15,u):R.slice(0,u),rt=ge+15<R.length?R.slice(ge,ge+15)+"\u2026":R.slice(ge),p+=We+Me+rt}let C=new Error(p);return C.name="ParseError",C.__proto__=e.prototype,C.position=u,C}}e.prototype.__proto__=Error.prototype;let t=function(r,o){return r===void 0?o:r},n=/([A-Z])/g,s=function(r){return r.replace(n,"-$1").toLowerCase()},a={"&":"&",">":">","<":"<",'"':""","'":"'"},c=/[&><"']/g;function h(r){return String(r).replace(c,o=>a[o])}let f=function(r){return r.type==="ordgroup"||r.type==="color"?r.body.length===1?f(r.body[0]):r:r.type==="font"?f(r.body):r},g=function(r){let o=f(r);return o.type==="mathord"||o.type==="textord"||o.type==="atom"},b=function(r){return+r.toFixed(4)},y="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 ${constructor(o){o=o||{},this.displayMode=t(o.displayMode,!1),this.annotate=t(o.annotate,!1),this.leqno=t(o.leqno,!1),this.throwOnError=t(o.throwOnError,!1),this.errorColor=t(o.errorColor,"#b22222"),this.macros=o.macros||{},this.wrap=t(o.wrap,"none"),this.xml=t(o.xml,!1),this.colorIsTextColor=t(o.colorIsTextColor,!1),this.strict=t(o.strict,!1),this.trust=t(o.trust,!1),this.maxSize=o.maxSize===void 0?[1/0,1/0]:Array.isArray(o.maxSize)?o.maxSize:[1/0,1/0],this.maxExpand=Math.max(0,t(o.maxExpand,1e3)),this.wrapDelimiterPairs=!0}isTrusted(o){if(o.url&&!o.protocol){let u=function(p){let v=/^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(p);return v?v[2]!==":"?null:/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(v[1])?v[1].toLowerCase():null:"_relative"}(o.url);if(u==null)return!1;o.protocol=u}return!!(typeof this.trust=="function"?this.trust(o):this.trust)}}let S={},A={};function E({type:r,names:o,props:i,handler:u,mathmlBuilder:p}){let v={type:r,numArgs:i.numArgs,argTypes:i.argTypes,allowedInArgument:!!i.allowedInArgument,allowedInText:!!i.allowedInText,allowedInMath:i.allowedInMath===void 0||i.allowedInMath,numOptionalArgs:i.numOptionalArgs||0,infix:!!i.infix,primitive:!!i.primitive,handler:u};for(let C=0;C<o.length;++C)S[o[C]]=v;r&&p&&(A[r]=p)}function L({type:r,mathmlBuilder:o}){E({type:r,names:[],props:{numArgs:0},handler(){throw new Error("Should never be called.")},mathmlBuilder:o})}let P=function(r){return r.type==="ordgroup"&&r.body.length===1?r.body[0]:r},j=function(r){return r.type==="ordgroup"?r.body:[r]};class U{constructor(o){this.children=o,this.classes=[],this.style={}}hasClass(o){return this.classes.includes(o)}toNode(){let o=document.createDocumentFragment();for(let i=0;i<this.children.length;i++)o.appendChild(this.children[i].toNode());return o}toMarkup(){let o="";for(let i=0;i<this.children.length;i++)o+=this.children[i].toMarkup();return o}toText(){return this.children.map(o=>o.toText()).join("")}}let oe=function(r){return r.filter(o=>o).join(" ")},pe=function(r,o){this.classes=r||[],this.attributes={},this.style=o||{}},D=function(r){let o=document.createElement(r);o.className=oe(this.classes);for(let i in this.style)Object.prototype.hasOwnProperty.call(this.style,i)&&(o.style[i]=this.style[i]);for(let i in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,i)&&o.setAttribute(i,this.attributes[i]);for(let i=0;i<this.children.length;i++)o.appendChild(this.children[i].toNode());return o},z=function(r){let o=`<${r}`;this.classes.length&&(o+=` class="${h(oe(this.classes))}"`);let i="";for(let u in this.style)Object.prototype.hasOwnProperty.call(this.style,u)&&(i+=`${s(u)}:${this.style[u]};`);i&&(o+=` style="${i}"`);for(let u in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,u)&&(o+=` ${u}="${h(this.attributes[u])}"`);o+=">";for(let u=0;u<this.children.length;u++)o+=this.children[u].toMarkup();return o+=`</${r}>`,o};class Ce{constructor(o,i,u){pe.call(this,o,u),this.children=i||[]}setAttribute(o,i){this.attributes[o]=i}toNode(){return D.call(this,"span")}toMarkup(){return z.call(this,"span")}}let ee=class{constructor(r){this.text=r}toNode(){return document.createTextNode(this.text)}toMarkup(){return h(this.text)}};class re{constructor(o,i,u){this.href=o,this.classes=i,this.children=u||[]}toNode(){let o=document.createElement("a");o.setAttribute("href",this.href),this.classes.length>0&&(o.className=oe(this.classes));for(let i=0;i<this.children.length;i++)o.appendChild(this.children[i].toNode());return o}toMarkup(){let o=`<a href='${h(this.href)}'`;this.classes.length>0&&(o+=` class="${h(oe(this.classes))}"`),o+=">";for(let i=0;i<this.children.length;i++)o+=this.children[i].toMarkup();return o+="</a>",o}}class le{constructor(o,i,u){this.alt=i,this.src=o,this.classes=["mord"],this.style=u}hasClass(o){return this.classes.includes(o)}toNode(){let o=document.createElement("img");o.src=this.src,o.alt=this.alt,o.className="mord";for(let i in this.style)Object.prototype.hasOwnProperty.call(this.style,i)&&(o.style[i]=this.style[i]);return o}toMarkup(){let o=`<img src='${this.src}' alt='${this.alt}'`,i="";for(let u in this.style)Object.prototype.hasOwnProperty.call(this.style,u)&&(i+=`${s(u)}:${this.style[u]};`);return i&&(o+=` style="${h(i)}"`),o+=">",o}}function ie(r){return new U(r)}class I{constructor(o,i,u,p){this.type=o,this.attributes={},this.children=i||[],this.classes=u||[],this.style=p||{},this.label=""}setAttribute(o,i){this.attributes[o]=i}getAttribute(o){return this.attributes[o]}setLabel(o){this.label=o}toNode(){let o=document.createElementNS("http://www.w3.org/1998/Math/MathML",this.type);for(let i in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,i)&&o.setAttribute(i,this.attributes[i]);this.classes.length>0&&(o.className=oe(this.classes));for(let i in this.style)Object.prototype.hasOwnProperty.call(this.style,i)&&(o.style[i]=this.style[i]);for(let i=0;i<this.children.length;i++)o.appendChild(this.children[i].toNode());return o}toMarkup(){let o="<"+this.type;for(let u in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,u)&&(o+=" "+u+'="',o+=h(this.attributes[u]),o+='"');this.classes.length>0&&(o+=` class="${h(oe(this.classes))}"`);let i="";for(let u in this.style)Object.prototype.hasOwnProperty.call(this.style,u)&&(i+=`${s(u)}:${this.style[u]};`);i&&(o+=` style="${i}"`),o+=">";for(let u=0;u<this.children.length;u++)o+=this.children[u].toMarkup();return o+="</"+this.type+">",o}toText(){return this.children.map(o=>o.toText()).join("")}}class ce{constructor(o){this.text=o}toNode(){return document.createTextNode(this.text)}toMarkup(){return h(this.toText())}toText(){return this.text}}let de=r=>{let o;return r.length===1&&r[0].type==="mrow"?(o=r.pop(),o.type="mstyle"):o=new I("mstyle",r),o},Ie=r=>{let o=0;if(r.body&&Array.isArray(r.body))for(let i of r.body)o+=Ie(i);else if(r.body)o+=Ie(r.body);else if(r.type==="supsub")o+=Ie(r.base),r.sub&&(o+=.7*Ie(r.sub)),r.sup&&(o+=.7*Ie(r.sup));else if(r.type==="mathord"||r.type==="textord")for(let i of r.text.split("")){let u=i.codePointAt(0);o+=96<u&&u<123||944<u&&u<970?.56:47<u&&u<58?.5:.92}else o+=1;return o},V={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"},Z=function(r){let o=new ce(V[r.slice(1)]),i=new I("mo",[o]);return i.setAttribute("stretchy","true"),i},T=["\\widetilde","\\widehat","\\widecheck","\\utilde"],F=r=>{let o=Z(r.label);if(T.includes(r.label)){let i=Ie(r.base);1<i&&i<1.6?o.classes.push("tml-crooked-2"):1.6<=i&&i<2.5?o.classes.push("tml-crooked-3"):2.5<=i&&o.classes.push("tml-crooked-4")}return o},se={bin:1,close:1,inner:1,open:1,punct:1,rel:1},_e={"accent-token":1,mathord:1,"op-token":1,spacing:1,textord:1},Te={math:{},text:{}};function l(r,o,i,u,p){Te[r][u]={group:o,replace:i},p&&i&&(Te[r][i]=Te[r][u])}let d="math",G="text",be="accent-token",J="bin",Qe="close",ot="inner",fe="mathord",K="op-token",ue="open",at="punct",N="rel",ft="spacing",M="textord";l(d,N,"\u2261","\\equiv",!0),l(d,N,"\u227A","\\prec",!0),l(d,N,"\u227B","\\succ",!0),l(d,N,"\u223C","\\sim",!0),l(d,N,"\u27C2","\\perp",!0),l(d,N,"\u2AAF","\\preceq",!0),l(d,N,"\u2AB0","\\succeq",!0),l(d,N,"\u2243","\\simeq",!0),l(d,N,"\u224C","\\backcong",!0),l(d,N,"|","\\mid",!0),l(d,N,"\u226A","\\ll",!0),l(d,N,"\u226B","\\gg",!0),l(d,N,"\u224D","\\asymp",!0),l(d,N,"\u2225","\\parallel"),l(d,N,"\u2323","\\smile",!0),l(d,N,"\u2291","\\sqsubseteq",!0),l(d,N,"\u2292","\\sqsupseteq",!0),l(d,N,"\u2250","\\doteq",!0),l(d,N,"\u2322","\\frown",!0),l(d,N,"\u220B","\\ni",!0),l(d,N,"\u220C","\\notni",!0),l(d,N,"\u221D","\\propto",!0),l(d,N,"\u22A2","\\vdash",!0),l(d,N,"\u22A3","\\dashv",!0),l(d,N,"\u220B","\\owns"),l(d,N,"\u2258","\\arceq",!0),l(d,N,"\u2259","\\wedgeq",!0),l(d,N,"\u225A","\\veeeq",!0),l(d,N,"\u225B","\\stareq",!0),l(d,N,"\u225D","\\eqdef",!0),l(d,N,"\u225E","\\measeq",!0),l(d,N,"\u225F","\\questeq",!0),l(d,N,"\u2260","\\ne",!0),l(d,N,"\u2260","\\neq"),l(d,N,"\u2A75","\\eqeq",!0),l(d,N,"\u2A76","\\eqeqeq",!0),l(d,N,"\u2237","\\dblcolon",!0),l(d,N,"\u2254","\\coloneqq",!0),l(d,N,"\u2255","\\eqqcolon",!0),l(d,N,"\u2239","\\eqcolon",!0),l(d,N,"\u2A74","\\Coloneqq",!0),l(d,at,".","\\ldotp"),l(d,at,"\xB7","\\cdotp"),l(d,M,"#","\\#"),l(G,M,"#","\\#"),l(d,M,"&","\\&"),l(G,M,"&","\\&"),l(d,M,"\u2135","\\aleph",!0),l(d,M,"\u2200","\\forall",!0),l(d,M,"\u210F","\\hbar",!0),l(d,M,"\u2203","\\exists",!0),l(d,ue,"\u2207","\\nabla",!0),l(d,M,"\u266D","\\flat",!0),l(d,M,"\u2113","\\ell",!0),l(d,M,"\u266E","\\natural",!0),l(d,M,"\u212B","\\Angstrom",!0),l(G,M,"\u212B","\\Angstrom",!0),l(d,M,"\u2663","\\clubsuit",!0),l(d,M,"\u2667","\\varclubsuit",!0),l(d,M,"\u2118","\\wp",!0),l(d,M,"\u266F","\\sharp",!0),l(d,M,"\u2662","\\diamondsuit",!0),l(d,M,"\u2666","\\vardiamondsuit",!0),l(d,M,"\u211C","\\Re",!0),l(d,M,"\u2661","\\heartsuit",!0),l(d,M,"\u2665","\\varheartsuit",!0),l(d,M,"\u2111","\\Im",!0),l(d,M,"\u2660","\\spadesuit",!0),l(d,M,"\u2664","\\varspadesuit",!0),l(d,M,"\u2640","\\female",!0),l(d,M,"\u2642","\\male",!0),l(d,M,"\xA7","\\S",!0),l(G,M,"\xA7","\\S"),l(d,M,"\xB6","\\P",!0),l(G,M,"\xB6","\\P"),l(G,M,"\u263A","\\smiley",!0),l(d,M,"\u263A","\\smiley",!0),l(d,M,"\u2020","\\dag"),l(G,M,"\u2020","\\dag"),l(G,M,"\u2020","\\textdagger"),l(d,M,"\u2021","\\ddag"),l(G,M,"\u2021","\\ddag"),l(G,M,"\u2021","\\textdaggerdbl"),l(d,Qe,"\u23B1","\\rmoustache",!0),l(d,ue,"\u23B0","\\lmoustache",!0),l(d,Qe,"\u27EF","\\rgroup",!0),l(d,ue,"\u27EE","\\lgroup",!0),l(d,J,"\u2213","\\mp",!0),l(d,J,"\u2296","\\ominus",!0),l(d,J,"\u228E","\\uplus",!0),l(d,J,"\u2293","\\sqcap",!0),l(d,J,"\u2217","\\ast"),l(d,J,"\u2294","\\sqcup",!0),l(d,J,"\u25EF","\\bigcirc",!0),l(d,J,"\u2219","\\bullet",!0),l(d,J,"\u2021","\\ddagger"),l(d,J,"\u2240","\\wr",!0),l(d,J,"\u2A3F","\\amalg"),l(d,J,"&","\\And"),l(d,J,"\u2AFD","\\sslash",!0),l(d,N,"\u27F5","\\longleftarrow",!0),l(d,N,"\u21D0","\\Leftarrow",!0),l(d,N,"\u27F8","\\Longleftarrow",!0),l(d,N,"\u27F6","\\longrightarrow",!0),l(d,N,"\u21D2","\\Rightarrow",!0),l(d,N,"\u27F9","\\Longrightarrow",!0),l(d,N,"\u2194","\\leftrightarrow",!0),l(d,N,"\u27F7","\\longleftrightarrow",!0),l(d,N,"\u21D4","\\Leftrightarrow",!0),l(d,N,"\u27FA","\\Longleftrightarrow",!0),l(d,N,"\u21A4","\\mapsfrom",!0),l(d,N,"\u21A6","\\mapsto",!0),l(d,N,"\u27FC","\\longmapsto",!0),l(d,N,"\u2197","\\nearrow",!0),l(d,N,"\u21A9","\\hookleftarrow",!0),l(d,N,"\u21AA","\\hookrightarrow",!0),l(d,N,"\u2198","\\searrow",!0),l(d,N,"\u21BC","\\leftharpoonup",!0),l(d,N,"\u21C0","\\rightharpoonup",!0),l(d,N,"\u2199","\\swarrow",!0),l(d,N,"\u21BD","\\leftharpoondown",!0),l(d,N,"\u21C1","\\rightharpoondown",!0),l(d,N,"\u2196","\\nwarrow",!0),l(d,N,"\u21CC","\\rightleftharpoons",!0),l(d,fe,"\u21AF","\\lightning",!0),l(d,fe,"\u220E","\\QED",!0),l(d,fe,"\u2030","\\permil",!0),l(G,M,"\u2030","\\permil"),l(d,fe,"\u2609","\\astrosun",!0),l(d,fe,"\u263C","\\sun",!0),l(d,fe,"\u263E","\\leftmoon",!0),l(d,fe,"\u263D","\\rightmoon",!0),l(d,fe,"\u2295","\\Earth"),l(d,N,"\u226E","\\nless",!0),l(d,N,"\u2A87","\\lneq",!0),l(d,N,"\u2268","\\lneqq",!0),l(d,N,"\u2268\uFE00","\\lvertneqq"),l(d,N,"\u22E6","\\lnsim",!0),l(d,N,"\u2A89","\\lnapprox",!0),l(d,N,"\u2280","\\nprec",!0),l(d,N,"\u22E0","\\npreceq",!0),l(d,N,"\u22E8","\\precnsim",!0),l(d,N,"\u2AB9","\\precnapprox",!0),l(d,N,"\u2241","\\nsim",!0),l(d,N,"\u2224","\\nmid",!0),l(d,N,"\u2224","\\nshortmid"),l(d,N,"\u22AC","\\nvdash",!0),l(d,N,"\u22AD","\\nvDash",!0),l(d,N,"\u22EA","\\ntriangleleft"),l(d,N,"\u22EC","\\ntrianglelefteq",!0),l(d,N,"\u2284","\\nsubset",!0),l(d,N,"\u2285","\\nsupset",!0),l(d,N,"\u228A","\\subsetneq",!0),l(d,N,"\u228A\uFE00","\\varsubsetneq"),l(d,N,"\u2ACB","\\subsetneqq",!0),l(d,N,"\u2ACB\uFE00","\\varsubsetneqq"),l(d,N,"\u226F","\\ngtr",!0),l(d,N,"\u2A88","\\gneq",!0),l(d,N,"\u2269","\\gneqq",!0),l(d,N,"\u2269\uFE00","\\gvertneqq"),l(d,N,"\u22E7","\\gnsim",!0),l(d,N,"\u2A8A","\\gnapprox",!0),l(d,N,"\u2281","\\nsucc",!0),l(d,N,"\u22E1","\\nsucceq",!0),l(d,N,"\u22E9","\\succnsim",!0),l(d,N,"\u2ABA","\\succnapprox",!0),l(d,N,"\u2246","\\ncong",!0),l(d,N,"\u2226","\\nparallel",!0),l(d,N,"\u2226","\\nshortparallel"),l(d,N,"\u22AF","\\nVDash",!0),l(d,N,"\u22EB","\\ntriangleright"),l(d,N,"\u22ED","\\ntrianglerighteq",!0),l(d,N,"\u228B","\\supsetneq",!0),l(d,N,"\u228B","\\varsupsetneq"),l(d,N,"\u2ACC","\\supsetneqq",!0),l(d,N,"\u2ACC\uFE00","\\varsupsetneqq"),l(d,N,"\u22AE","\\nVdash",!0),l(d,N,"\u2AB5","\\precneqq",!0),l(d,N,"\u2AB6","\\succneqq",!0),l(d,J,"\u22B4","\\unlhd"),l(d,J,"\u22B5","\\unrhd"),l(d,N,"\u219A","\\nleftarrow",!0),l(d,N,"\u219B","\\nrightarrow",!0),l(d,N,"\u21CD","\\nLeftarrow",!0),l(d,N,"\u21CF","\\nRightarrow",!0),l(d,N,"\u21AE","\\nleftrightarrow",!0),l(d,N,"\u21CE","\\nLeftrightarrow",!0),l(d,N,"\u25B3","\\vartriangle"),l(d,M,"\u210F","\\hslash"),l(d,M,"\u25BD","\\triangledown"),l(d,M,"\u25CA","\\lozenge"),l(d,M,"\u24C8","\\circledS"),l(d,M,"\xAE","\\circledR",!0),l(G,M,"\xAE","\\circledR"),l(G,M,"\xAE","\\textregistered"),l(d,M,"\u2221","\\measuredangle",!0),l(d,M,"\u2204","\\nexists"),l(d,M,"\u2127","\\mho"),l(d,M,"\u2132","\\Finv",!0),l(d,M,"\u2141","\\Game",!0),l(d,M,"\u2035","\\backprime"),l(d,M,"\u2036","\\backdprime"),l(d,M,"\u2037","\\backtrprime"),l(d,M,"\u25B2","\\blacktriangle"),l(d,M,"\u25BC","\\blacktriangledown"),l(d,M,"\u25A0","\\blacksquare"),l(d,M,"\u29EB","\\blacklozenge"),l(d,M,"\u2605","\\bigstar"),l(d,M,"\u2222","\\sphericalangle",!0),l(d,M,"\u2201","\\complement",!0),l(d,M,"\u2571","\\diagup"),l(d,M,"\u2572","\\diagdown"),l(d,M,"\u25A1","\\square"),l(d,M,"\u25A1","\\Box"),l(d,M,"\u25CA","\\Diamond"),l(d,M,"\xA5","\\yen",!0),l(G,M,"\xA5","\\yen",!0),l(d,M,"\u2713","\\checkmark",!0),l(G,M,"\u2713","\\checkmark"),l(d,M,"\u2717","\\ballotx",!0),l(G,M,"\u2717","\\ballotx"),l(G,M,"\u2022","\\textbullet"),l(d,M,"\u2136","\\beth",!0),l(d,M,"\u2138","\\daleth",!0),l(d,M,"\u2137","\\gimel",!0),l(d,M,"\u03DD","\\digamma",!0),l(d,M,"\u03F0","\\varkappa"),l(d,ue,"\u231C","\\ulcorner",!0),l(d,Qe,"\u231D","\\urcorner",!0),l(d,ue,"\u231E","\\llcorner",!0),l(d,Qe,"\u231F","\\lrcorner",!0),l(d,N,"\u2266","\\leqq",!0),l(d,N,"\u2A7D","\\leqslant",!0),l(d,N,"\u2A95","\\eqslantless",!0),l(d,N,"\u2272","\\lesssim",!0),l(d,N,"\u2A85","\\lessapprox",!0),l(d,N,"\u224A","\\approxeq",!0),l(d,J,"\u22D6","\\lessdot"),l(d,N,"\u22D8","\\lll",!0),l(d,N,"\u2276","\\lessgtr",!0),l(d,N,"\u22DA","\\lesseqgtr",!0),l(d,N,"\u2A8B","\\lesseqqgtr",!0),l(d,N,"\u2251","\\doteqdot"),l(d,N,"\u2253","\\risingdotseq",!0),l(d,N,"\u2252","\\fallingdotseq",!0),l(d,N,"\u223D","\\backsim",!0),l(d,N,"\u22CD","\\backsimeq",!0),l(d,N,"\u2AC5","\\subseteqq",!0),l(d,N,"\u22D0","\\Subset",!0),l(d,N,"\u228F","\\sqsubset",!0),l(d,N,"\u227C","\\preccurlyeq",!0),l(d,N,"\u22DE","\\curlyeqprec",!0),l(d,N,"\u227E","\\precsim",!0),l(d,N,"\u2AB7","\\precapprox",!0),l(d,N,"\u22B2","\\vartriangleleft"),l(d,N,"\u22B4","\\trianglelefteq"),l(d,N,"\u22A8","\\vDash",!0),l(d,N,"\u22AB","\\VDash",!0),l(d,N,"\u22AA","\\Vvdash",!0),l(d,N,"\u2323","\\smallsmile"),l(d,N,"\u2322","\\smallfrown"),l(d,N,"\u224F","\\bumpeq",!0),l(d,N,"\u224E","\\Bumpeq",!0),l(d,N,"\u2267","\\geqq",!0),l(d,N,"\u2A7E","\\geqslant",!0),l(d,N,"\u2A96","\\eqslantgtr",!0),l(d,N,"\u2273","\\gtrsim",!0),l(d,N,"\u2A86","\\gtrapprox",!0),l(d,J,"\u22D7","\\gtrdot"),l(d,N,"\u22D9","\\ggg",!0),l(d,N,"\u2277","\\gtrless",!0),l(d,N,"\u22DB","\\gtreqless",!0),l(d,N,"\u2A8C","\\gtreqqless",!0),l(d,N,"\u2256","\\eqcirc",!0),l(d,N,"\u2257","\\circeq",!0),l(d,N,"\u225C","\\triangleq",!0),l(d,N,"\u223C","\\thicksim"),l(d,N,"\u2248","\\thickapprox"),l(d,N,"\u2AC6","\\supseteqq",!0),l(d,N,"\u22D1","\\Supset",!0),l(d,N,"\u2290","\\sqsupset",!0),l(d,N,"\u227D","\\succcurlyeq",!0),l(d,N,"\u22DF","\\curlyeqsucc",!0),l(d,N,"\u227F","\\succsim",!0),l(d,N,"\u2AB8","\\succapprox",!0),l(d,N,"\u22B3","\\vartriangleright"),l(d,N,"\u22B5","\\trianglerighteq"),l(d,N,"\u22A9","\\Vdash",!0),l(d,N,"\u2223","\\shortmid"),l(d,N,"\u2225","\\shortparallel"),l(d,N,"\u226C","\\between",!0),l(d,N,"\u22D4","\\pitchfork",!0),l(d,N,"\u221D","\\varpropto"),l(d,N,"\u25C0","\\blacktriangleleft"),l(d,N,"\u2234","\\therefore",!0),l(d,N,"\u220D","\\backepsilon"),l(d,N,"\u25B6","\\blacktriangleright"),l(d,N,"\u2235","\\because",!0),l(d,N,"\u22D8","\\llless"),l(d,N,"\u22D9","\\gggtr"),l(d,J,"\u22B2","\\lhd"),l(d,J,"\u22B3","\\rhd"),l(d,N,"\u2242","\\eqsim",!0),l(d,N,"\u2251","\\Doteq",!0),l(d,N,"\u297D","\\strictif",!0),l(d,N,"\u297C","\\strictfi",!0),l(d,J,"\u2214","\\dotplus",!0),l(d,J,"\u2216","\\smallsetminus"),l(d,J,"\u22D2","\\Cap",!0),l(d,J,"\u22D3","\\Cup",!0),l(d,J,"\u2A5E","\\doublebarwedge",!0),l(d,J,"\u229F","\\boxminus",!0),l(d,J,"\u229E","\\boxplus",!0),l(d,J,"\u29C4","\\boxslash",!0),l(d,J,"\u22C7","\\divideontimes",!0),l(d,J,"\u22C9","\\ltimes",!0),l(d,J,"\u22CA","\\rtimes",!0),l(d,J,"\u22CB","\\leftthreetimes",!0),l(d,J,"\u22CC","\\rightthreetimes",!0),l(d,J,"\u22CF","\\curlywedge",!0),l(d,J,"\u22CE","\\curlyvee",!0),l(d,J,"\u229D","\\circleddash",!0),l(d,J,"\u229B","\\circledast",!0),l(d,J,"\u22BA","\\intercal",!0),l(d,J,"\u22D2","\\doublecap"),l(d,J,"\u22D3","\\doublecup"),l(d,J,"\u22A0","\\boxtimes",!0),l(d,J,"\u22C8","\\bowtie",!0),l(d,J,"\u22C8","\\Join"),l(d,J,"\u27D5","\\leftouterjoin",!0),l(d,J,"\u27D6","\\rightouterjoin",!0),l(d,J,"\u27D7","\\fullouterjoin",!0),l(d,J,"\u2238","\\dotminus",!0),l(d,J,"\u27D1","\\wedgedot",!0),l(d,J,"\u27C7","\\veedot",!0),l(d,J,"\u2A62","\\doublebarvee",!0),l(d,J,"\u2A63","\\veedoublebar",!0),l(d,J,"\u2A5F","\\wedgebar",!0),l(d,J,"\u2A60","\\wedgedoublebar",!0),l(d,J,"\u2A54","\\Vee",!0),l(d,J,"\u2A53","\\Wedge",!0),l(d,J,"\u2A43","\\barcap",!0),l(d,J,"\u2A42","\\barcup",!0),l(d,J,"\u2A48","\\capbarcup",!0),l(d,J,"\u2A40","\\capdot",!0),l(d,J,"\u2A47","\\capovercup",!0),l(d,J,"\u2A46","\\cupovercap",!0),l(d,J,"\u2A4D","\\closedvarcap",!0),l(d,J,"\u2A4C","\\closedvarcup",!0),l(d,J,"\u2A2A","\\minusdot",!0),l(d,J,"\u2A2B","\\minusfdots",!0),l(d,J,"\u2A2C","\\minusrdots",!0),l(d,J,"\u22BB","\\Xor",!0),l(d,J,"\u22BC","\\Nand",!0),l(d,J,"\u22BD","\\Nor",!0),l(d,J,"\u22BD","\\barvee"),l(d,J,"\u2AF4","\\interleave",!0),l(d,J,"\u29E2","\\shuffle",!0),l(d,J,"\u2AF6","\\threedotcolon",!0),l(d,J,"\u2982","\\typecolon",!0),l(d,J,"\u223E","\\invlazys",!0),l(d,J,"\u2A4B","\\twocaps",!0),l(d,J,"\u2A4A","\\twocups",!0),l(d,J,"\u2A4E","\\Sqcap",!0),l(d,J,"\u2A4F","\\Sqcup",!0),l(d,J,"\u2A56","\\veeonvee",!0),l(d,J,"\u2A55","\\wedgeonwedge",!0),l(d,J,"\u29D7","\\blackhourglass",!0),l(d,J,"\u29C6","\\boxast",!0),l(d,J,"\u29C8","\\boxbox",!0),l(d,J,"\u29C7","\\boxcircle",!0),l(d,J,"\u229C","\\circledequal",!0),l(d,J,"\u29B7","\\circledparallel",!0),l(d,J,"\u29B6","\\circledvert",!0),l(d,J,"\u29B5","\\circlehbar",!0),l(d,J,"\u27E1","\\concavediamond",!0),l(d,J,"\u27E2","\\concavediamondtickleft",!0),l(d,J,"\u27E3","\\concavediamondtickright",!0),l(d,J,"\u22C4","\\diamond",!0),l(d,J,"\u29D6","\\hourglass",!0),l(d,J,"\u27E0","\\lozengeminus",!0),l(d,J,"\u233D","\\obar",!0),l(d,J,"\u29B8","\\obslash",!0),l(d,J,"\u2A38","\\odiv",!0),l(d,J,"\u29C1","\\ogreaterthan",!0),l(d,J,"\u29C0","\\olessthan",!0),l(d,J,"\u29B9","\\operp",!0),l(d,J,"\u2A37","\\Otimes",!0),l(d,J,"\u2A36","\\otimeshat",!0),l(d,J,"\u22C6","\\star",!0),l(d,J,"\u25B3","\\triangle",!0),l(d,J,"\u2A3A","\\triangleminus",!0),l(d,J,"\u2A39","\\triangleplus",!0),l(d,J,"\u2A3B","\\triangletimes",!0),l(d,J,"\u27E4","\\whitesquaretickleft",!0),l(d,J,"\u27E5","\\whitesquaretickright",!0),l(d,J,"\u2A33","\\smashtimes",!0),l(d,N,"\u21E2","\\dashrightarrow",!0),l(d,N,"\u21E0","\\dashleftarrow",!0),l(d,N,"\u21C7","\\leftleftarrows",!0),l(d,N,"\u21C6","\\leftrightarrows",!0),l(d,N,"\u21DA","\\Lleftarrow",!0),l(d,N,"\u219E","\\twoheadleftarrow",!0),l(d,N,"\u21A2","\\leftarrowtail",!0),l(d,N,"\u21AB","\\looparrowleft",!0),l(d,N,"\u21CB","\\leftrightharpoons",!0),l(d,N,"\u21B6","\\curvearrowleft",!0),l(d,N,"\u21BA","\\circlearrowleft",!0),l(d,N,"\u21B0","\\Lsh",!0),l(d,N,"\u21C8","\\upuparrows",!0),l(d,N,"\u21BF","\\upharpoonleft",!0),l(d,N,"\u21C3","\\downharpoonleft",!0),l(d,N,"\u22B6","\\origof",!0),l(d,N,"\u22B7","\\imageof",!0),l(d,N,"\u22B8","\\multimap",!0),l(d,N,"\u21AD","\\leftrightsquigarrow",!0),l(d,N,"\u21C9","\\rightrightarrows",!0),l(d,N,"\u21C4","\\rightleftarrows",!0),l(d,N,"\u21A0","\\twoheadrightarrow",!0),l(d,N,"\u21A3","\\rightarrowtail",!0),l(d,N,"\u21AC","\\looparrowright",!0),l(d,N,"\u21B7","\\curvearrowright",!0),l(d,N,"\u21BB","\\circlearrowright",!0),l(d,N,"\u21B1","\\Rsh",!0),l(d,N,"\u21CA","\\downdownarrows",!0),l(d,N,"\u21BE","\\upharpoonright",!0),l(d,N,"\u21C2","\\downharpoonright",!0),l(d,N,"\u21DD","\\rightsquigarrow",!0),l(d,N,"\u21DD","\\leadsto"),l(d,N,"\u21DB","\\Rrightarrow",!0),l(d,N,"\u21BE","\\restriction"),l(d,M,"\u2018","`"),l(d,M,"$","\\$"),l(G,M,"$","\\$"),l(G,M,"$","\\textdollar"),l(d,M,"\xA2","\\cent"),l(G,M,"\xA2","\\cent"),l(d,M,"%","\\%"),l(G,M,"%","\\%"),l(d,M,"_","\\_"),l(G,M,"_","\\_"),l(G,M,"_","\\textunderscore"),l(G,M,"\u2423","\\textvisiblespace",!0),l(d,M,"\u2220","\\angle",!0),l(d,M,"\u221E","\\infty",!0),l(d,M,"\u2032","\\prime"),l(d,M,"\u2033","\\dprime"),l(d,M,"\u2034","\\trprime"),l(d,M,"\u2057","\\qprime"),l(d,M,"\u25B3","\\triangle"),l(G,M,"\u0391","\\Alpha",!0),l(G,M,"\u0392","\\Beta",!0),l(G,M,"\u0393","\\Gamma",!0),l(G,M,"\u0394","\\Delta",!0),l(G,M,"\u0395","\\Epsilon",!0),l(G,M,"\u0396","\\Zeta",!0),l(G,M,"\u0397","\\Eta",!0),l(G,M,"\u0398","\\Theta",!0),l(G,M,"\u0399","\\Iota",!0),l(G,M,"\u039A","\\Kappa",!0),l(G,M,"\u039B","\\Lambda",!0),l(G,M,"\u039C","\\Mu",!0),l(G,M,"\u039D","\\Nu",!0),l(G,M,"\u039E","\\Xi",!0),l(G,M,"\u039F","\\Omicron",!0),l(G,M,"\u03A0","\\Pi",!0),l(G,M,"\u03A1","\\Rho",!0),l(G,M,"\u03A3","\\Sigma",!0),l(G,M,"\u03A4","\\Tau",!0),l(G,M,"\u03A5","\\Upsilon",!0),l(G,M,"\u03A6","\\Phi",!0),l(G,M,"\u03A7","\\Chi",!0),l(G,M,"\u03A8","\\Psi",!0),l(G,M,"\u03A9","\\Omega",!0),l(d,fe,"\u0391","\\Alpha",!0),l(d,fe,"\u0392","\\Beta",!0),l(d,fe,"\u0393","\\Gamma",!0),l(d,fe,"\u0394","\\Delta",!0),l(d,fe,"\u0395","\\Epsilon",!0),l(d,fe,"\u0396","\\Zeta",!0),l(d,fe,"\u0397","\\Eta",!0),l(d,fe,"\u0398","\\Theta",!0),l(d,fe,"\u0399","\\Iota",!0),l(d,fe,"\u039A","\\Kappa",!0),l(d,fe,"\u039B","\\Lambda",!0),l(d,fe,"\u039C","\\Mu",!0),l(d,fe,"\u039D","\\Nu",!0),l(d,fe,"\u039E","\\Xi",!0),l(d,fe,"\u039F","\\Omicron",!0),l(d,fe,"\u03A0","\\Pi",!0),l(d,fe,"\u03A1","\\Rho",!0),l(d,fe,"\u03A3","\\Sigma",!0),l(d,fe,"\u03A4","\\Tau",!0),l(d,fe,"\u03A5","\\Upsilon",!0),l(d,fe,"\u03A6","\\Phi",!0),l(d,fe,"\u03A7","\\Chi",!0),l(d,fe,"\u03A8","\\Psi",!0),l(d,fe,"\u03A9","\\Omega",!0),l(d,ue,"\xAC","\\neg",!0),l(d,ue,"\xAC","\\lnot"),l(d,M,"\u22A4","\\top"),l(d,M,"\u22A5","\\bot"),l(d,M,"\u2205","\\emptyset"),l(d,M,"\u2300","\\varnothing"),l(d,fe,"\u03B1","\\alpha",!0),l(d,fe,"\u03B2","\\beta",!0),l(d,fe,"\u03B3","\\gamma",!0),l(d,fe,"\u03B4","\\delta",!0),l(d,fe,"\u03F5","\\epsilon",!0),l(d,fe,"\u03B6","\\zeta",!0),l(d,fe,"\u03B7","\\eta",!0),l(d,fe,"\u03B8","\\theta",!0),l(d,fe,"\u03B9","\\iota",!0),l(d,fe,"\u03BA","\\kappa",!0),l(d,fe,"\u03BB","\\lambda",!0),l(d,fe,"\u03BC","\\mu",!0),l(d,fe,"\u03BD","\\nu",!0),l(d,fe,"\u03BE","\\xi",!0),l(d,fe,"\u03BF","\\omicron",!0),l(d,fe,"\u03C0","\\pi",!0),l(d,fe,"\u03C1","\\rho",!0),l(d,fe,"\u03C3","\\sigma",!0),l(d,fe,"\u03C4","\\tau",!0),l(d,fe,"\u03C5","\\upsilon",!0),l(d,fe,"\u03D5","\\phi",!0),l(d,fe,"\u03C7","\\chi",!0),l(d,fe,"\u03C8","\\psi",!0),l(d,fe,"\u03C9","\\omega",!0),l(d,fe,"\u03B5","\\varepsilon",!0),l(d,fe,"\u03D1","\\vartheta",!0),l(d,fe,"\u03D6","\\varpi",!0),l(d,fe,"\u03F1","\\varrho",!0),l(d,fe,"\u03C2","\\varsigma",!0),l(d,fe,"\u03C6","\\varphi",!0),l(d,fe,"\u03D8","\\Coppa",!0),l(d,fe,"\u03D9","\\coppa",!0),l(d,fe,"\u03D9","\\varcoppa",!0),l(d,fe,"\u03DE","\\Koppa",!0),l(d,fe,"\u03DF","\\koppa",!0),l(d,fe,"\u03E0","\\Sampi",!0),l(d,fe,"\u03E1","\\sampi",!0),l(d,fe,"\u03DA","\\Stigma",!0),l(d,fe,"\u03DB","\\stigma",!0),l(d,fe,"\u2AEB","\\Bot"),l(d,M,"\xF0","\\eth",!0),l(G,M,"\xF0","\xF0"),l(d,M,"\xC5","\\AA"),l(G,M,"\xC5","\\AA",!0),l(d,M,"\xC6","\\AE",!0),l(G,M,"\xC6","\\AE",!0),l(d,M,"\xD0","\\DH",!0),l(G,M,"\xD0","\\DH",!0),l(d,M,"\xDE","\\TH",!0),l(G,M,"\xDE","\\TH",!0),l(d,M,"\xDF","\\ss",!0),l(G,M,"\xDF","\\ss",!0),l(d,M,"\xE5","\\aa"),l(G,M,"\xE5","\\aa",!0),l(d,M,"\xE6","\\ae",!0),l(G,M,"\xE6","\\ae",!0),l(d,M,"\xF0","\\dh"),l(G,M,"\xF0","\\dh",!0),l(d,M,"\xFE","\\th",!0),l(G,M,"\xFE","\\th",!0),l(d,M,"\u0110","\\DJ",!0),l(G,M,"\u0110","\\DJ",!0),l(d,M,"\u0111","\\dj",!0),l(G,M,"\u0111","\\dj",!0),l(d,M,"\u0141","\\L",!0),l(G,M,"\u0141","\\L",!0),l(d,M,"\u0141","\\l",!0),l(G,M,"\u0141","\\l",!0),l(d,M,"\u014A","\\NG",!0),l(G,M,"\u014A","\\NG",!0),l(d,M,"\u014B","\\ng",!0),l(G,M,"\u014B","\\ng",!0),l(d,M,"\u0152","\\OE",!0),l(G,M,"\u0152","\\OE",!0),l(d,M,"\u0153","\\oe",!0),l(G,M,"\u0153","\\oe",!0),l(d,J,"\u2217","\u2217",!0),l(d,J,"+","+"),l(d,J,"\u2217","*"),l(d,J,"\u2044","/",!0),l(d,J,"\u2044","\u2044"),l(d,J,"\u2212","-",!0),l(d,J,"\u22C5","\\cdot",!0),l(d,J,"\u2218","\\circ",!0),l(d,J,"\xF7","\\div",!0),l(d,J,"\xB1","\\pm",!0),l(d,J,"\xD7","\\times",!0),l(d,J,"\u2229","\\cap",!0),l(d,J,"\u222A","\\cup",!0),l(d,J,"\u2216","\\setminus",!0),l(d,J,"\u2227","\\land"),l(d,J,"\u2228","\\lor"),l(d,J,"\u2227","\\wedge",!0),l(d,J,"\u2228","\\vee",!0),l(d,ue,"\u27E6","\\llbracket",!0),l(d,Qe,"\u27E7","\\rrbracket",!0),l(d,ue,"\u27E8","\\langle",!0),l(d,ue,"\u27EA","\\lAngle",!0),l(d,ue,"\u2989","\\llangle",!0),l(d,ue,"|","\\lvert"),l(d,ue,"\u2016","\\lVert",!0),l(d,M,"!","\\oc"),l(d,M,"?","\\wn"),l(d,M,"\u2193","\\shpos"),l(d,M,"\u2195","\\shift"),l(d,M,"\u2191","\\shneg"),l(d,Qe,"?","?"),l(d,Qe,"!","!"),l(d,Qe,"\u203C","\u203C"),l(d,Qe,"\u27E9","\\rangle",!0),l(d,Qe,"\u27EB","\\rAngle",!0),l(d,Qe,"\u298A","\\rrangle",!0),l(d,Qe,"|","\\rvert"),l(d,Qe,"\u2016","\\rVert"),l(d,ue,"\u2983","\\lBrace",!0),l(d,Qe,"\u2984","\\rBrace",!0),l(d,N,"=","\\equal",!0),l(d,N,":",":"),l(d,N,"\u2248","\\approx",!0),l(d,N,"\u2245","\\cong",!0),l(d,N,"\u2265","\\ge"),l(d,N,"\u2265","\\geq",!0),l(d,N,"\u2190","\\gets"),l(d,N,">","\\gt",!0),l(d,N,"\u2208","\\in",!0),l(d,N,"\u2209","\\notin",!0),l(d,N,"\uE020","\\@not"),l(d,N,"\u2282","\\subset",!0),l(d,N,"\u2283","\\supset",!0),l(d,N,"\u2286","\\subseteq",!0),l(d,N,"\u2287","\\supseteq",!0),l(d,N,"\u2288","\\nsubseteq",!0),l(d,N,"\u2288","\\nsubseteqq"),l(d,N,"\u2289","\\nsupseteq",!0),l(d,N,"\u2289","\\nsupseteqq"),l(d,N,"\u22A8","\\models"),l(d,N,"\u2190","\\leftarrow",!0),l(d,N,"\u2264","\\le"),l(d,N,"\u2264","\\leq",!0),l(d,N,"<","\\lt",!0),l(d,N,"\u2192","\\rightarrow",!0),l(d,N,"\u2192","\\to"),l(d,N,"\u2271","\\ngeq",!0),l(d,N,"\u2271","\\ngeqq"),l(d,N,"\u2271","\\ngeqslant"),l(d,N,"\u2270","\\nleq",!0),l(d,N,"\u2270","\\nleqq"),l(d,N,"\u2270","\\nleqslant"),l(d,N,"\u2AEB","\\Perp",!0),l(d,ft,"\xA0","\\ "),l(d,ft,"\xA0","\\space"),l(d,ft,"\xA0","\\nobreakspace"),l(G,ft,"\xA0","\\ "),l(G,ft,"\xA0"," "),l(G,ft,"\xA0","\\space"),l(G,ft,"\xA0","\\nobreakspace"),l(d,ft,null,"\\nobreak"),l(d,ft,null,"\\allowbreak"),l(d,at,",",","),l(G,at,":",":"),l(d,at,";",";"),l(d,J,"\u22BC","\\barwedge"),l(d,J,"\u22BB","\\veebar"),l(d,J,"\u2299","\\odot",!0),l(d,J,"\u2295\uFE0E","\\oplus"),l(d,J,"\u2297","\\otimes",!0),l(d,M,"\u2202","\\partial",!0),l(d,J,"\u2298","\\oslash",!0),l(d,J,"\u229A","\\circledcirc",!0),l(d,J,"\u22A1","\\boxdot",!0),l(d,J,"\u25B3","\\bigtriangleup"),l(d,J,"\u25BD","\\bigtriangledown"),l(d,J,"\u2020","\\dagger"),l(d,J,"\u22C4","\\diamond"),l(d,J,"\u25C3","\\triangleleft"),l(d,J,"\u25B9","\\triangleright"),l(d,ue,"{","\\{"),l(G,M,"{","\\{"),l(G,M,"{","\\textbraceleft"),l(d,Qe,"}","\\}"),l(G,M,"}","\\}"),l(G,M,"}","\\textbraceright"),l(d,ue,"{","\\lbrace"),l(d,Qe,"}","\\rbrace"),l(d,ue,"[","\\lbrack",!0),l(G,M,"[","\\lbrack",!0),l(d,Qe,"]","\\rbrack",!0),l(G,M,"]","\\rbrack",!0),l(d,ue,"(","\\lparen",!0),l(d,Qe,")","\\rparen",!0),l(d,ue,"\u2987","\\llparenthesis",!0),l(d,Qe,"\u2988","\\rrparenthesis",!0),l(G,M,"<","\\textless",!0),l(G,M,">","\\textgreater",!0),l(d,ue,"\u230A","\\lfloor",!0),l(d,Qe,"\u230B","\\rfloor",!0),l(d,ue,"\u2308","\\lceil",!0),l(d,Qe,"\u2309","\\rceil",!0),l(d,M,"\\","\\backslash"),l(d,M,"|","|"),l(d,M,"|","\\vert"),l(G,M,"|","\\textbar",!0),l(d,M,"\u2016","\\|"),l(d,M,"\u2016","\\Vert"),l(G,M,"\u2016","\\textbardbl"),l(G,M,"~","\\textasciitilde"),l(G,M,"\\","\\textbackslash"),l(G,M,"^","\\textasciicircum"),l(d,N,"\u2191","\\uparrow",!0),l(d,N,"\u21D1","\\Uparrow",!0),l(d,N,"\u2193","\\downarrow",!0),l(d,N,"\u21D3","\\Downarrow",!0),l(d,N,"\u2195","\\updownarrow",!0),l(d,N,"\u21D5","\\Updownarrow",!0),l(d,K,"\u2210","\\coprod"),l(d,K,"\u22C1","\\bigvee"),l(d,K,"\u22C0","\\bigwedge"),l(d,K,"\u2A04","\\biguplus"),l(d,K,"\u2A04","\\bigcupplus"),l(d,K,"\u2A03","\\bigcupdot"),l(d,K,"\u2A07","\\bigdoublevee"),l(d,K,"\u2A08","\\bigdoublewedge"),l(d,K,"\u22C2","\\bigcap"),l(d,K,"\u22C3","\\bigcup"),l(d,K,"\u222B","\\int"),l(d,K,"\u222B","\\intop"),l(d,K,"\u222C","\\iint"),l(d,K,"\u222D","\\iiint"),l(d,K,"\u220F","\\prod"),l(d,K,"\u2211","\\sum"),l(d,K,"\u2A02","\\bigotimes"),l(d,K,"\u2A01","\\bigoplus"),l(d,K,"\u2A00","\\bigodot"),l(d,K,"\u2A09","\\bigtimes"),l(d,K,"\u222E","\\oint"),l(d,K,"\u222F","\\oiint"),l(d,K,"\u2230","\\oiiint"),l(d,K,"\u2231","\\intclockwise"),l(d,K,"\u2232","\\varointclockwise"),l(d,K,"\u2A0C","\\iiiint"),l(d,K,"\u2A0D","\\intbar"),l(d,K,"\u2A0E","\\intBar"),l(d,K,"\u2A0F","\\fint"),l(d,K,"\u2A12","\\rppolint"),l(d,K,"\u2A13","\\scpolint"),l(d,K,"\u2A15","\\pointint"),l(d,K,"\u2A16","\\sqint"),l(d,K,"\u2A17","\\intlarhk"),l(d,K,"\u2A18","\\intx"),l(d,K,"\u2A19","\\intcap"),l(d,K,"\u2A1A","\\intcup"),l(d,K,"\u2A05","\\bigsqcap"),l(d,K,"\u2A06","\\bigsqcup"),l(d,K,"\u222B","\\smallint"),l(G,ot,"\u2026","\\textellipsis"),l(d,ot,"\u2026","\\mathellipsis"),l(G,ot,"\u2026","\\ldots",!0),l(d,ot,"\u2026","\\ldots",!0),l(d,ot,"\u22F0","\\iddots",!0),l(d,ot,"\u22EF","\\@cdots",!0),l(d,ot,"\u22F1","\\ddots",!0),l(d,M,"\u22EE","\\varvdots"),l(G,M,"\u22EE","\\varvdots"),l(d,be,"\xB4","\\acute"),l(d,be,"`","\\grave"),l(d,be,"\xA8","\\ddot"),l(d,be,"\u2026","\\dddot"),l(d,be,"\u2026.","\\ddddot"),l(d,be,"~","\\tilde"),l(d,be,"\u203E","\\bar"),l(d,be,"\u02D8","\\breve"),l(d,be,"\u02C7","\\check"),l(d,be,"^","\\hat"),l(d,be,"\u2192","\\vec"),l(d,be,"\u02D9","\\dot"),l(d,be,"\u02DA","\\mathring"),l(d,fe,"\u0131","\\imath",!0),l(d,fe,"\u0237","\\jmath",!0),l(d,M,"\u0131","\u0131"),l(d,M,"\u0237","\u0237"),l(G,M,"\u0131","\\i",!0),l(G,M,"\u0237","\\j",!0),l(G,M,"\xF8","\\o",!0),l(d,fe,"\xF8","\\o",!0),l(G,M,"\xD8","\\O",!0),l(d,fe,"\xD8","\\O",!0),l(G,be,"\u02CA","\\'"),l(G,be,"\u02CB","\\`"),l(G,be,"\u02C6","\\^"),l(G,be,"~","\\~"),l(G,be,"\u02C9","\\="),l(G,be,"\u02D8","\\u"),l(G,be,"\u02D9","\\."),l(G,be,"\xB8","\\c"),l(G,be,"\u02DA","\\r"),l(G,be,"\u02C7","\\v"),l(G,be,"\xA8",'\\"'),l(G,be,"\u02DD","\\H"),l(d,be,"\u02CA","\\'"),l(d,be,"\u02CB","\\`"),l(d,be,"\u02C6","\\^"),l(d,be,"~","\\~"),l(d,be,"\u02C9","\\="),l(d,be,"\u02D8","\\u"),l(d,be,"\u02D9","\\."),l(d,be,"\xB8","\\c"),l(d,be,"\u02DA","\\r"),l(d,be,"\u02C7","\\v"),l(d,be,"\xA8",'\\"'),l(d,be,"\u02DD","\\H");let H={"--":!0,"---":!0,"``":!0,"''":!0};l(G,M,"\u2013","--",!0),l(G,M,"\u2013","\\textendash"),l(G,M,"\u2014","---",!0),l(G,M,"\u2014","\\textemdash"),l(G,M,"\u2018","`",!0),l(G,M,"\u2018","\\textquoteleft"),l(G,M,"\u2019","'",!0),l(G,M,"\u2019","\\textquoteright"),l(G,M,"\u201C","``",!0),l(G,M,"\u201C","\\textquotedblleft"),l(G,M,"\u201D","''",!0),l(G,M,"\u201D","\\textquotedblright"),l(d,M,"\xB0","\\degree",!0),l(G,M,"\xB0","\\degree"),l(G,M,"\xB0","\\textdegree",!0),l(d,M,"\xA3","\\pounds"),l(d,M,"\xA3","\\mathsterling",!0),l(G,M,"\xA3","\\pounds"),l(G,M,"\xA3","\\textsterling",!0),l(d,M,"\u2720","\\maltese"),l(G,M,"\u2720","\\maltese"),l(d,M,"\u20AC","\\euro",!0),l(G,M,"\u20AC","\\euro",!0),l(G,M,"\u20AC","\\texteuro"),l(d,M,"\xA9","\\copyright",!0),l(G,M,"\xA9","\\textcopyright"),l(d,M,"\u2300","\\diameter",!0),l(G,M,"\u2300","\\diameter"),l(d,M,"\u{1D6E4}","\\varGamma"),l(d,M,"\u{1D6E5}","\\varDelta"),l(d,M,"\u{1D6E9}","\\varTheta"),l(d,M,"\u{1D6EC}","\\varLambda"),l(d,M,"\u{1D6EF}","\\varXi"),l(d,M,"\u{1D6F1}","\\varPi"),l(d,M,"\u{1D6F4}","\\varSigma"),l(d,M,"\u{1D6F6}","\\varUpsilon"),l(d,M,"\u{1D6F7}","\\varPhi"),l(d,M,"\u{1D6F9}","\\varPsi"),l(d,M,"\u{1D6FA}","\\varOmega"),l(G,M,"\u{1D6E4}","\\varGamma"),l(G,M,"\u{1D6E5}","\\varDelta"),l(G,M,"\u{1D6E9}","\\varTheta"),l(G,M,"\u{1D6EC}","\\varLambda"),l(G,M,"\u{1D6EF}","\\varXi"),l(G,M,"\u{1D6F1}","\\varPi"),l(G,M,"\u{1D6F4}","\\varSigma"),l(G,M,"\u{1D6F6}","\\varUpsilon"),l(G,M,"\u{1D6F7}","\\varPhi"),l(G,M,"\u{1D6F9}","\\varPsi"),l(G,M,"\u{1D6FA}","\\varOmega");let te='0123456789/@."';for(let r=0;r<14;r++){let o=te.charAt(r);l(d,M,o,o)}let we='0123456789!@*()-=+";:?/.,';for(let r=0;r<25;r++){let o=we.charAt(r);l(G,M,o,o)}let Ee="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";for(let r=0;r<52;r++){let o=Ee.charAt(r);l(d,fe,o,o),l(G,M,o,o)}let Ke="\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 r=0;r<30;r++){let o=Ke.charAt(r);l(d,fe,o,o),l(G,M,o,o)}let ae="";for(let r=0;r<52;r++){ae=String.fromCharCode(55349,56320+r),l(d,fe,ae,ae),l(G,M,ae,ae),ae=String.fromCharCode(55349,56372+r),l(d,fe,ae,ae),l(G,M,ae,ae),ae=String.fromCharCode(55349,56424+r),l(d,fe,ae,ae),l(G,M,ae,ae),ae=String.fromCharCode(55349,56580+r),l(d,fe,ae,ae),l(G,M,ae,ae),ae=String.fromCharCode(55349,56736+r),l(d,fe,ae,ae),l(G,M,ae,ae),ae=String.fromCharCode(55349,56788+r),l(d,fe,ae,ae),l(G,M,ae,ae),ae=String.fromCharCode(55349,56840+r),l(d,fe,ae,ae),l(G,M,ae,ae),ae=String.fromCharCode(55349,56944+r),l(d,fe,ae,ae),l(G,M,ae,ae),ae=String.fromCharCode(55349,56632+r),l(d,fe,ae,ae),l(G,M,ae,ae);let o=Ee.charAt(r);ae=String.fromCharCode(55349,56476+r),l(d,fe,o,ae),l(G,M,o,ae)}for(let r=0;r<10;r++)ae=String.fromCharCode(55349,57294+r),l(d,fe,ae,ae),l(G,M,ae,ae),ae=String.fromCharCode(55349,57314+r),l(d,fe,ae,ae),l(G,M,ae,ae),ae=String.fromCharCode(55349,57324+r),l(d,fe,ae,ae),l(G,M,ae,ae),ae=String.fromCharCode(55349,57334+r),l(d,fe,ae,ae),l(G,M,ae,ae);let Ze=function(r,o,i){return!Te[o][r]||!Te[o][r].replace||r.charCodeAt(0)===55349||Object.prototype.hasOwnProperty.call(H,r)&&i&&(i.fontFamily&&i.fontFamily.slice(4,6)==="tt"||i.font&&i.font.slice(4,6)==="tt")||(r=Te[o][r].replace),new ce(r)},bt=(r,o)=>{if(r.children.length===0||r.children[r.children.length-1].type!=="mtext"){let i=new I("mtext",[new ce(o.children[0].text)]);r.children.push(i)}else r.children[r.children.length-1].children[0].text+=o.children[0].text},Pe=r=>{if(r.type!=="mrow"&&r.type!=="mstyle"||r.children.length===0)return r;let o=new I("mrow");for(let i=0;i<r.children.length;i++){let u=r.children[i];if(u.type==="mtext"&&Object.keys(u.attributes).length===0)bt(o,u);else if(u.type==="mrow"){let p=!0;for(let v=0;v<u.children.length;v++)if(u.children[v].type!=="mtext"||Object.keys(u.attributes).length!==0){p=!1;break}if(p)for(let v=0;v<u.children.length;v++){let C=u.children[v];bt(o,C)}else o.children.push(u)}else o.children.push(u)}for(let i=0;i<o.children.length;i++)if(o.children[i].type==="mtext"){let u=o.children[i];u.children[0].text.charAt(0)===" "&&(u.children[0].text="\xA0"+u.children[0].text.slice(1));let p=u.children[0].text.length;p>0&&u.children[0].text.charAt(p-1)===" "&&(u.children[0].text=u.children[0].text.slice(0,-1)+"\xA0");for(let[v,C]of Object.entries(r.attributes))u.attributes[v]=C}return o.children.length===1&&o.children[0].type==="mtext"?o.children[0]:o},ke=function(r,o=!1){if(!(r.length!==1||r[0]instanceof U))return r[0];if(!o){r[0]instanceof I&&r[0].type==="mo"&&!r[0].attributes.fence&&(r[0].attributes.lspace="0em",r[0].attributes.rspace="0em");let i=r.length-1;r[i]instanceof I&&r[i].type==="mo"&&!r[i].attributes.fence&&(r[i].attributes.lspace="0em",r[i].attributes.rspace="0em")}return new I("mrow",r)};function Fe(r){if(!r)return!1;if(r.type==="mi"&&r.children.length===1){let o=r.children[0];return o instanceof ce&&o.text==="."}if(r.type==="mtext"&&r.children.length===1){let o=r.children[0];return o instanceof ce&&o.text==="\u2008"}if(r.type==="mo"&&r.children.length===1&&r.getAttribute("separator")==="true"&&r.getAttribute("lspace")==="0em"&&r.getAttribute("rspace")==="0em"){let o=r.children[0];return o instanceof ce&&o.text===","}return!1}let Ve=(r,o)=>{let i=r[o],u=r[o+1];return i.type==="atom"&&i.text===","&&i.loc&&u.loc&&i.loc.end===u.loc.start},et=r=>r.type==="atom"&&r.family==="rel"||r.type==="mclass"&&r.mclass==="mrel",Y=function(r,o,i=!1){if(!i&&r.length===1){let C=Ne(r[0],o);return C instanceof I&&C.type==="mo"&&(C.setAttribute("lspace","0em"),C.setAttribute("rspace","0em")),[C]}let u=[],p=[],v;for(let C=0;C<r.length;C++)p.push(Ne(r[C],o));for(let C=0;C<p.length;C++){let R=p[C];if(C<r.length-1&&et(r[C])&&et(r[C+1])&&R.setAttribute("rspace","0em"),C>0&&et(r[C])&&et(r[C-1])&&R.setAttribute("lspace","0em"),R.type==="mn"&&v&&v.type==="mn")v.children.push(...R.children);else if(Fe(R)&&v&&v.type==="mn")v.children.push(...R.children);else if(v&&v.type==="mn"&&C<p.length-1&&p[C+1].type==="mn"&&Ve(r,C))v.children.push(...R.children);else{if(R.type==="mn"&&Fe(v))R.children=[...v.children,...R.children],u.pop();else if((R.type==="msup"||R.type==="msub")&&R.children.length>=1&&v&&(v.type==="mn"||Fe(v))){let ge=R.children[0];ge instanceof I&&ge.type==="mn"&&v&&(ge.children=[...v.children,...ge.children],u.pop())}u.push(R),v=R}}return u},ve=function(r,o,i=!1){return ke(Y(r,o,i),i)},Ne=function(r,o){if(!r)return new I("mrow");if(A[r.type])return A[r.type](r,o);throw new e("Got group of unknown type: '"+r.type+"'")},ut=r=>new I("mtd",[],[],{padding:"0",width:"50%"}),ht=["mrow","mtd","mtable","mtr"],vt=r=>{for(let o of r.children)if(o.type&&ht.includes(o.type)){if(o.classes&&o.classes[0]==="tml-label")return o.label;{let i=vt(o);if(i)return i}}else if(!o.type){let i=vt(o);if(i)return i}};function mt(r,o,i,u){let p=null;r.length===1&&r[0].type==="tag"&&(p=r[0].tag,r=r[0].body);let v=Y(r,i);if(v.length===1&&v[0]instanceof re)return v[0];let C=u.displayMode||u.annotate?"none":u.wrap,R=v.length===0?null:v[0],ge=v.length===1&&p===null&&R instanceof I?v[0]:function(We,rt,Je){let qt=[],ze=[],Ye=[],st=0,lt=0;for(;lt<We.length;){for(;We[lt]instanceof U;)We.splice(lt,1,...We[lt].children);let xt=We[lt];if(xt.attributes&&xt.attributes.linebreak&&xt.attributes.linebreak==="newline"){Ye.length>0&&ze.push(new I("mrow",Ye)),ze.push(xt),Ye=[];let Zt=new I("mtd",ze);Zt.style.textAlign="left",qt.push(new I("mtr",[Zt])),ze=[],lt+=1;continue}if(Ye.push(xt),xt.type&&xt.type==="mo"&&xt.children.length===1&&(!xt.attributes.form||xt.attributes.form!=="prefix")&&!Object.prototype.hasOwnProperty.call(xt.attributes,"movablelimits")){let Zt=xt.children[0].text;if(rt==="="&&Zt==="="){if(st+=1,st>1){Ye.pop();let Jn=new I("mrow",Ye);ze.push(Jn),Ye=[xt]}}else if(rt==="tex"){let Jn=lt<We.length-1?We[lt+1]:null,An=!0;if(!Jn||Jn.type!=="mtext"||!Jn.attributes.linebreak||Jn.attributes.linebreak!=="nobreak")for(let br=lt+1;br<We.length;br++){let Ss=We[br];if(!Ss.type||Ss.type!=="mspace"||Ss.attributes.linebreak&&Ss.attributes.linebreak==="newline")break;Ye.push(Ss),lt+=1,Ss.attributes&&Ss.attributes.linebreak&&Ss.attributes.linebreak==="nobreak"&&(An=!1)}if(An){let br=new I("mrow",Ye);ze.push(br),Ye=[]}}}lt+=1}if(Ye.length>0){let xt=new I("mrow",Ye);ze.push(xt)}if(qt.length>0){let xt=new I("mtd",ze);xt.style.textAlign="left";let Zt=new I("mtr",[xt]);qt.push(Zt);let Jn=new I("mtable",qt);return Je||(Jn.setAttribute("columnalign","left"),Jn.setAttribute("rowspacing","0em")),Jn}return ie(ze)}(v,C,u.displayMode);if(p&&(ge=((We,rt,Je,qt)=>{rt=ve(rt[0].body,Je),(rt=Pe(rt)).classes.push("tml-tag");let ze=vt(We);We=new I("mtd",[We]);let Ye=[ut(),We,ut()];Ye[qt?0:2].children.push(rt);let st=new I("mtr",Ye,["tml-tageqn"]);ze&&st.setAttribute("id",ze);let lt=new I("mtable",[st]);return lt.style.width="100%",lt.setAttribute("displaystyle","true"),lt})(ge,p,i,u.leqno)),u.annotate){let We=new I("annotation",[new ce(o)]);We.setAttribute("encoding","application/x-tex"),ge=new I("semantics",[ge,We])}let Me=new I("math",[ge]);return u.xml&&Me.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML"),u.displayMode&&(Me.setAttribute("display","block"),Me.style.display="block math",Me.classes=["tml-display"]),Me}let Ue=(r,o)=>{let i=r.isStretchy?F(r):new I("mo",[Ze(r.label,r.mode)]);r.isStretchy||i.setAttribute("stretchy","false"),r.label!=="\\vec"&&(i.style.mathDepth="0");let u=r.label==="\\c"?"munder":"mover",p=Ct.has(r.label);if(u==="mover"&&r.mode==="math"&&!r.isStretchy&&r.base.text&&r.base.text.length===1){let v=r.base.text,C=r.label==="\\vec",R=C==="\\vec"?"-vec":"";C&&i.classes.push("tml-vec");let ge=C?"-vec":p?"-acc":"";"DHKLUcegorsuvxyz\u03A0\u03A5\u03A8\u03B1\u03B4\u03B7\u03B9\u03BC\u03BD\u03BF\u03C4\u03C5\u03C7\u03F5".indexOf(v)>-1?(i.classes.push(`chr-sml${R}`),i.classes.push(`wbk-sml${ge}`)):"BCEGIMNOPQRSTXZlpqtw\u0393\u0398\u039E\u03A3\u03A6\u03A9\u03B2\u03B5\u03B6\u03B8\u03BE\u03C1\u03C2\u03C6\u03C8\u03D1\u03D5\u03F1".indexOf(v)>-1?(i.classes.push(`chr-med${R}`),i.classes.push(`wbk-med${ge}`)):"AFJdf\u0394\u039B".indexOf(v)>-1?(i.classes.push(`chr-lrg${R}`),i.classes.push(`wbk-lrg${ge}`)):C?i.classes.push("wbk-vec"):p&&i.classes.push("wbk-acc")}else p&&i.classes.push("wbk-acc");return new I(u,[Ne(r.base,o),i])},Dt=new Set(["\\acute","\\check","\\grave","\\ddot","\\dddot","\\ddddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring"]),Ct=new Set(["\\acute","\\bar","\\breve","\\check","\\dot","\\ddot","\\grave","\\hat","\\mathring","\\`","\\'","\\^","\\=","\\u","\\.",'\\"',"\\r","\\H","\\v"]),Pt={"\\`":"\u0300","\\'":"\u0301","\\^":"\u0302","\\~":"\u0303","\\=":"\u0304","\\u":"\u0306","\\.":"\u0307",'\\"':"\u0308","\\r":"\u030A","\\H":"\u030B","\\v":"\u030C","\\c":"\u0327"};E({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:(r,o)=>{let i=P(o[0]),u=!Dt.has(r.funcName);return{type:"accent",mode:r.parser.mode,label:r.funcName,isStretchy:u,base:i}},mathmlBuilder:Ue}),E({type:"accent",names:["\\'","\\`","\\^","\\~","\\=","\\c","\\u","\\.",'\\"',"\\r","\\H","\\v"],props:{numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["primitive"]},handler:(r,o)=>{let i=P(o[0]),u=r.parser.mode;return u==="math"&&r.parser.settings.strict&&console.log(`Temml parse error: Command ${r.funcName} is invalid in math mode.`),u==="text"&&i.text&&i.text.length===1&&r.funcName in Pt&&y.indexOf(i.text)>-1?{type:"textord",mode:"text",text:i.text+Pt[r.funcName]}:r.funcName==="\\c"&&u==="text"&&i.text&&i.text.length===1?{type:"textord",mode:"text",text:i.text+"\u0327"}:{type:"accent",mode:u,label:r.funcName,isStretchy:!1,base:i}},mathmlBuilder:Ue}),E({type:"accentUnder",names:["\\underleftarrow","\\underrightarrow","\\underleftrightarrow","\\undergroup","\\underparen","\\utilde"],props:{numArgs:1},handler:({parser:r,funcName:o},i)=>{let u=i[0];return{type:"accentUnder",mode:r.mode,label:o,base:u}},mathmlBuilder:(r,o)=>{let i=F(r);return i.style["math-depth"]=0,new I("munder",[Ne(r.base,o),i])}});let Kt={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},hn=["em","ex","mu","pt","mm","cm","in","px","bp","pc","dd","cc","nd","nc","sp"],Xt=function(r){return typeof r!="string"&&(r=r.unit),hn.indexOf(r)>-1},Mt=r=>[1,.7,.5][Math.max(r-1,0)],Wt=function(r,o){let i=r.number;if(o.maxSize[0]<0&&i>0)return{number:0,unit:"em"};let u=r.unit;switch(u){case"mm":case"cm":case"in":case"px":return i*Kt[u]>o.maxSize[1]?{number:o.maxSize[1],unit:"pt"}:{number:i,unit:u};case"em":case"ex":return u==="ex"&&(i*=.431),i=Math.min(i/Mt(o.level),o.maxSize[0]),{number:b(i),unit:"em"};case"bp":return i>o.maxSize[1]&&(i=o.maxSize[1]),{number:i,unit:"pt"};case"pt":case"pc":case"dd":case"cc":case"nd":case"nc":case"sp":return i=Math.min(i*Kt[u],o.maxSize[1]),{number:b(i),unit:"pt"};case"mu":return i=Math.min(i/18,o.maxSize[0]),{number:b(i),unit:"em"};default:throw new e("Invalid unit: '"+u+"'")}},St=r=>{let o=new I("mspace");return o.setAttribute("width",r+"em"),o},Vt=(r,o=.3,i=0,u=!1)=>{if(r==null&&i===0)return St(o);let p=r?[r]:[];if(o!==0&&p.unshift(St(o)),i>0&&p.push(St(i)),u){let v=new I("mpadded",p);return v.setAttribute("height","0.1px"),v}return new I("mrow",p)},on=(r,o)=>Number(r)/Mt(o),Yt=(r,o,i,u)=>{let p=Z(r),v=r.slice(1,3)==="eq",C=r.charAt(1)==="x"?"1.75":r.slice(2,4)==="cd"?"3.0":v?"1.0":"2.0";p.setAttribute("lspace","0"),p.setAttribute("rspace",v?"0.5em":"0");let R=u.withLevel(u.level<2?2:3),ge=on(C,R.level),Me=on(C,3),We=Vt(null,ge.toFixed(4),0),rt=Vt(null,Me.toFixed(4),0),Je=on(v?0:.3,R.level).toFixed(4),qt,ze,Ye=o&&o.body&&(o.body.body||o.body.length>0);if(Ye){let xt=Ne(o,R);xt=Vt(xt,Je,Je,r==="\\\\cdrightarrow"||r==="\\\\cdleftarrow"),qt=new I("mover",[xt,rt])}let st=i&&i.body&&(i.body.body||i.body.length>0);if(st){let xt=Ne(i,R);xt=Vt(xt,Je,Je),ze=new I("munder",[xt,rt])}let lt;return lt=Ye||st?Ye&&st?new I("munderover",[p,ze,qt]):Ye?new I("mover",[p,qt]):new I("munder",[p,ze]):new I("mover",[p,We]),C==="3.0"&&(lt.style.height="1em"),lt.setAttribute("accent","false"),lt};E({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:r,funcName:o},i,u)=>({type:"xArrow",mode:r.mode,name:o,body:i[0],below:u[0]}),mathmlBuilder(r,o){let i=[Yt(r.name,r.body,r.below,o)];return i.unshift(St(.2778)),i.push(St(.2778)),new I("mrow",i)}});let an={"\\equilibriumRight":["\\longrightharpoonup","\\eqleftharpoondown"],"\\equilibriumLeft":["\\eqrightharpoonup","\\longleftharpoondown"]};E({type:"stackedArrow",names:["\\equilibriumRight","\\equilibriumLeft"],props:{numArgs:1,numOptionalArgs:1},handler({parser:r,funcName:o},i,u){let p=i[0]?{type:"hphantom",mode:r.mode,body:i[0]}:null,v=u[0]?{type:"hphantom",mode:r.mode,body:u[0]}:null;return{type:"stackedArrow",mode:r.mode,name:o,body:i[0],upperArrowBelow:v,lowerArrowBody:p,below:u[0]}},mathmlBuilder(r,o){let i=an[r.name][0],u=an[r.name][1],p=Yt(i,r.body,r.upperArrowBelow,o),v=Yt(u,r.lowerArrowBody,r.below,o),C,R=new I("mpadded",[p]);if(R.setAttribute("voffset","0.3em"),R.setAttribute("height","+0.3em"),R.setAttribute("depth","-0.3em"),r.name==="\\equilibriumLeft"){let ge=new I("mpadded",[v]);ge.setAttribute("width","0.5em"),C=new I("mpadded",[St(.2778),ge,R,St(.2778)])}else R.setAttribute("width",r.name==="\\equilibriumRight"?"0.5em":"0"),C=new I("mpadded",[St(.2778),R,v,St(.2778)]);return C.setAttribute("voffset","-0.18em"),C.setAttribute("height","-0.18em"),C.setAttribute("depth","+0.18em"),C}});let Cn={};function wn({type:r,names:o,props:i,handler:u,mathmlBuilder:p}){let v={type:r,numArgs:i.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:u};for(let C=0;C<o.length;++C)Cn[o[C]]=v;p&&(A[r]=p)}function Nt(r,o){if(!r||r.type!==o)throw new Error(`Expected node of type ${o}, but got `+(r?`node of type ${r.type}`:String(r)));return r}function Ln(r){let o=ar(r);if(!o)throw new Error("Expected node of symbol group type, but got "+(r?`node of type ${r.type}`:String(r)));return o}function ar(r){return r&&(r.type==="atom"||r.type==="delimiter"||Object.prototype.hasOwnProperty.call(_e,r.type))?r:null}let Er={">":"\\\\cdrightarrow","<":"\\\\cdleftarrow","=":"\\\\cdlongequal",A:"\\uparrow",V:"\\downarrow","|":"\\Vert",".":"no arrow"},kn=()=>({type:"styling",body:[],mode:"math",scriptLevel:"display"}),Bn=r=>r.type==="textord"&&r.text==="@",wr=(r,o)=>(r.type==="mathord"||r.type==="atom")&&r.text===o;function Nr(r,o,i){let u=Er[r];switch(u){case"\\\\cdrightarrow":case"\\\\cdleftarrow":return i.callFunction(u,[o[0]],[o[1]]);case"\\uparrow":case"\\downarrow":{let p={type:"atom",text:u,mode:"math",family:"rel"},v={type:"ordgroup",mode:"math",body:[i.callFunction("\\\\cdleft",[o[0]],[]),i.callFunction("\\Big",[p],[]),i.callFunction("\\\\cdright",[o[1]],[])],semisimple:!0};return i.callFunction("\\\\cdparent",[v],[])}case"\\\\cdlongequal":return i.callFunction("\\\\cdlongequal",[],[]);case"\\Vert":{let p={type:"textord",text:"\\Vert",mode:"math"};return i.callFunction("\\Big",[p],[])}default:return{type:"textord",text:" ",mode:"math"}}}E({type:"cdlabel",names:["\\\\cdleft","\\\\cdright"],props:{numArgs:1},handler:({parser:r,funcName:o},i)=>({type:"cdlabel",mode:r.mode,side:o.slice(4),label:i[0]}),mathmlBuilder(r,o){if(r.label.body.length===0)return new I("mrow",o);let i=Ne(r.label,o);r.side==="left"&&i.classes.push("tml-shift-left");let u=new I("mtd",[i]);u.style.padding="0";let p=new I("mtr",[u]),v=new I("mtable",[p]),C=new I("mpadded",[v]);return C.setAttribute("width","0.1px"),C.setAttribute("displaystyle","false"),C.setAttribute("scriptlevel","1"),C}}),E({type:"cdlabelparent",names:["\\\\cdparent"],props:{numArgs:1},handler:({parser:r},o)=>({type:"cdlabelparent",mode:r.mode,fragment:o[0]}),mathmlBuilder:(r,o)=>new I("mrow",[Ne(r.fragment,o)])});let tn=r=>({type:"ordgroup",mode:"math",body:r,semisimple:!0}),Mn=(r,o)=>({type:o,mode:"math",body:tn(r)});class un{constructor(o,i,u){this.lexer=o,this.start=i,this.end=u}static range(o,i){return i?o&&o.loc&&i.loc&&o.loc.lexer===i.loc.lexer?new un(o.loc.lexer,o.loc.start,i.loc.end):null:o&&o.loc}}class dn{constructor(o,i){this.text=o,this.loc=i}range(o,i){return new dn(i,un.range(this,o))}}let Rn=0,nn=1,Tt=2,fn=3,xn={};function xe(r,o){xn[r]=o}let B=xn;xe("\\noexpand",function(r){let o=r.popToken();return r.isExpandable(o.text)&&(o.noexpand=!0,o.treatAsRelax=!0),{tokens:[o],numArgs:0}}),xe("\\expandafter",function(r){let o=r.popToken();return r.expandOnce(!0),{tokens:[o],numArgs:0}}),xe("\\@firstoftwo",function(r){return{tokens:r.consumeArgs(2)[0],numArgs:0}}),xe("\\@secondoftwo",function(r){return{tokens:r.consumeArgs(2)[1],numArgs:0}}),xe("\\@ifnextchar",function(r){let o=r.consumeArgs(3);r.consumeSpaces();let i=r.future();return o[0].length===1&&o[0][0].text===i.text?{tokens:o[1],numArgs:0}:{tokens:o[2],numArgs:0}}),xe("\\@ifstar","\\@ifnextchar *{\\@firstoftwo{#1}}"),xe("\\TextOrMath",function(r){let o=r.consumeArgs(2);return r.mode==="text"?{tokens:o[0],numArgs:0}:{tokens:o[1],numArgs:0}});let Le=r=>{let o="";for(let i=r.length-1;i>-1;i--)o+=r[i].text;return o},je={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},tt=r=>{let o=r.future().text;return o==="EOF"?[null,""]:[je[o.charAt(0)],o]},yt=(r,o,i)=>{for(let u=1;u<o.length;u++)r*=i,r+=je[o.charAt(u)];return r};function wt(r){let o=r.consumeArgs(1)[0],i="",u=o[o.length-1].loc.start;for(let p=o.length-1;p>=0;p--){let v=o[p].loc.start;v>u&&(i+=" ",u=v),i+=o[p].text,u+=o[p].text.length}return i}xe("\\char",function(r){let o,i=r.popToken(),u="";if(i.text==="'")o=8,i=r.popToken();else if(i.text==='"')o=16,i=r.popToken();else if(i.text==="`")if(i=r.popToken(),i.text[0]==="\\")u=i.text.charCodeAt(1);else{if(i.text==="EOF")throw new e("\\char` missing argument");u=i.text.charCodeAt(0)}else o=10;if(o){let p,v=i.text;if(u=je[v.charAt(0)],u==null||u>=o)throw new e(`Invalid base-${o} digit ${i.text}`);for(u=yt(u,v,o),[p,v]=tt(r);p!=null&&p<o;)u*=o,u+=p,u=yt(u,v,o),r.popToken(),[p,v]=tt(r)}return`\\@char{${u}}`}),xe("\\surd","\\sqrt{\\vphantom{|}}"),xe("\u2295","\\oplus"),xe("\\long",""),xe("\\bgroup","{"),xe("\\egroup","}"),xe("~","\\nobreakspace"),xe("\\lq","`"),xe("\\rq","'"),xe("\\aa","\\r a"),xe("\\Bbbk","\\Bbb{k}"),xe("\\mathstrut","\\vphantom{(}"),xe("\\underbar","\\underline{\\text{#1}}"),xe("\\vdots","{\\varvdots\\rule{0pt}{15pt}}"),xe("\u22EE","\\vdots"),xe("\\arraystretch","1"),xe("\\arraycolsep","6pt"),xe("\\substack","\\begin{subarray}{c}#1\\end{subarray}"),xe("\\iff","\\DOTSB\\;\\Longleftrightarrow\\;"),xe("\\implies","\\DOTSB\\;\\Longrightarrow\\;"),xe("\\impliedby","\\DOTSB\\;\\Longleftarrow\\;");let It={",":"\\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"};xe("\\dots",function(r){let o="\\dotso",i=r.expandAfterFuture().text;return i in It?o=It[i]:(i.slice(0,4)==="\\not"||i in Te.math&&["bin","rel"].includes(Te.math[i].group))&&(o="\\dotsb"),o});let At={")":!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};xe("\\dotso",function(r){return r.future().text in At?"\\ldots\\,":"\\ldots"}),xe("\\dotsc",function(r){let o=r.future().text;return o in At&&o!==","?"\\ldots\\,":"\\ldots"}),xe("\\cdots",function(r){return r.future().text in At?"\\@cdots\\,":"\\@cdots"}),xe("\\dotsb","\\cdots"),xe("\\dotsm","\\cdots"),xe("\\dotsi","\\!\\cdots"),xe("\\idotsint","\\int\\!\\cdots\\!\\int"),xe("\\dotsx","\\ldots\\,"),xe("\\DOTSI","\\relax"),xe("\\DOTSB","\\relax"),xe("\\DOTSX","\\relax"),xe("\\tmspace","\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"),xe("\\,","{\\tmspace+{3mu}{.1667em}}"),xe("\\thinspace","\\,"),xe("\\>","\\mskip{4mu}"),xe("\\:","{\\tmspace+{4mu}{.2222em}}"),xe("\\medspace","\\:"),xe("\\;","{\\tmspace+{5mu}{.2777em}}"),xe("\\thickspace","\\;"),xe("\\!","{\\tmspace-{3mu}{.1667em}}"),xe("\\negthinspace","\\!"),xe("\\negmedspace","{\\tmspace-{4mu}{.2222em}}"),xe("\\negthickspace","{\\tmspace-{5mu}{.277em}}"),xe("\\enspace","\\kern.5em "),xe("\\enskip","\\hskip.5em\\relax"),xe("\\quad","\\hskip1em\\relax"),xe("\\qquad","\\hskip2em\\relax"),xe("\\AA","\\TextOrMath{\\Angstrom}{\\mathring{A}}\\relax"),xe("\\tag","\\@ifstar\\tag@literal\\tag@paren"),xe("\\tag@paren","\\tag@literal{({#1})}"),xe("\\tag@literal",r=>{if(r.macros.get("\\df@tag"))throw new e("Multiple \\tag");return"\\gdef\\df@tag{\\text{#1}}"}),xe("\\notag","\\nonumber"),xe("\\nonumber","\\gdef\\@eqnsw{0}"),xe("\\bmod","\\mathbin{\\text{mod}}"),xe("\\pod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"),xe("\\pmod","\\pod{{\\rm mod}\\mkern6mu#1}"),xe("\\mod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1"),xe("\\newline","\\\\\\relax"),xe("\\TeX","\\textrm{T}\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125em\\textrm{X}"),xe("\\LaTeX","\\textrm{L}\\kern-.35em\\raisebox{0.2em}{\\scriptstyle A}\\kern-.15em\\TeX"),xe("\\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}}"),xe("\\hspace","\\@ifstar\\@hspacer\\@hspace"),xe("\\@hspace","\\hskip #1\\relax"),xe("\\@hspacer","\\rule{0pt}{0pt}\\hskip #1\\relax"),xe("\\colon",'\\mathpunct{\\char"3a}'),xe("\\prescript","\\pres@cript{_{#1}^{#2}}{}{#3}"),xe("\\ordinarycolon",'\\char"3a'),xe("\\vcentcolon","\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}}"),xe("\\coloneq",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"2212}'),xe("\\Coloneq",'\\mathrel{\\char"2237\\char"2212}'),xe("\\Eqqcolon",'\\mathrel{\\char"3d\\char"2237}'),xe("\\Eqcolon",'\\mathrel{\\char"2212\\char"2237}'),xe("\\colonapprox",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"2248}'),xe("\\Colonapprox",'\\mathrel{\\char"2237\\char"2248}'),xe("\\colonsim",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"223c}'),xe("\\Colonsim",'\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"223c}'),xe("\\ratio","\\vcentcolon"),xe("\\coloncolon","\\dblcolon"),xe("\\colonequals","\\coloneqq"),xe("\\coloncolonequals","\\Coloneqq"),xe("\\equalscolon","\\eqqcolon"),xe("\\equalscoloncolon","\\Eqqcolon"),xe("\\colonminus","\\coloneq"),xe("\\coloncolonminus","\\Coloneq"),xe("\\minuscolon","\\eqcolon"),xe("\\minuscoloncolon","\\Eqcolon"),xe("\\coloncolonapprox","\\Colonapprox"),xe("\\coloncolonsim","\\Colonsim"),xe("\\notni","\\mathrel{\\char`\u220C}"),xe("\\limsup","\\DOTSB\\operatorname*{lim\\,sup}"),xe("\\liminf","\\DOTSB\\operatorname*{lim\\,inf}"),xe("\\injlim","\\DOTSB\\operatorname*{inj\\,lim}"),xe("\\projlim","\\DOTSB\\operatorname*{proj\\,lim}"),xe("\\varlimsup","\\DOTSB\\operatorname*{\\overline{\\text{lim}}}"),xe("\\varliminf","\\DOTSB\\operatorname*{\\underline{\\text{lim}}}"),xe("\\varinjlim","\\DOTSB\\operatorname*{\\underrightarrow{\\text{lim}}}"),xe("\\varprojlim","\\DOTSB\\operatorname*{\\underleftarrow{\\text{lim}}}"),xe("\\centerdot","{\\medspace\\rule{0.167em}{0.189em}\\medspace}"),xe("\\argmin","\\DOTSB\\operatorname*{arg\\,min}"),xe("\\argmax","\\DOTSB\\operatorname*{arg\\,max}"),xe("\\plim","\\DOTSB\\operatorname*{plim}"),xe("\\leftmodels","\\mathop{\\reflectbox{$\\models$}}"),xe("\\bra","\\mathinner{\\langle{#1}|}"),xe("\\ket","\\mathinner{|{#1}\\rangle}"),xe("\\braket","\\mathinner{\\langle{#1}\\rangle}"),xe("\\Bra","\\left\\langle#1\\right|"),xe("\\Ket","\\left|#1\\right\\rangle");let In=(r,o)=>{let i=`}\\,\\middle${o[0]==="|"?"\\vert":"\\Vert"}\\,{`;return r.slice(0,o.index)+i+r.slice(o.index+o[0].length)};xe("\\Braket",function(r){let o=wt(r),i=/\|\||\||\\\|/g,u;for(;(u=i.exec(o))!==null;)o=In(o,u);return"\\left\\langle{"+o+"}\\right\\rangle"}),xe("\\Set",function(r){let o=wt(r),i=/\|\||\||\\\|/.exec(o);return i&&(o=In(o,i)),"\\left\\{\\:{"+o+"}\\:\\right\\}"}),xe("\\set",function(r){return"\\{{"+wt(r).replace(/\|/,"}\\mid{")+"}\\}"}),xe("\\angln","{\\angl n}"),xe("\\odv","\\@ifstar\\odv@next\\odv@numerator"),xe("\\odv@numerator","\\frac{\\mathrm{d}#1}{\\mathrm{d}#2}"),xe("\\odv@next","\\frac{\\mathrm{d}}{\\mathrm{d}#2}#1"),xe("\\pdv","\\@ifstar\\pdv@next\\pdv@numerator");let Rt=r=>{let o=r[0][0].text,i=Le(r[1]).split(","),u=String(i.length),p=u==="1"?"\\partial":`\\partial^${u}`,v="";return i.map(C=>{v+="\\partial "+C.trim()+"\\,"}),[o,p,v.replace(/\\,$/,"")]};function mn(r){let o=[];r.consumeSpaces();let i=r.fetch().text;for(i==="\\relax"&&(r.consume(),r.consumeSpaces(),i=r.fetch().text);i==="\\hline"||i==="\\hdashline";)r.consume(),o.push(i==="\\hdashline"),r.consumeSpaces(),i=r.fetch().text;return o}xe("\\pdv@numerator",function(r){let[o,i,u]=Rt(r.consumeArgs(2));return`\\frac{${i} ${o}}{${u}}`}),xe("\\pdv@next",function(r){let[o,i,u]=Rt(r.consumeArgs(2));return`\\frac{${i}}{${u}} ${o}`}),xe("\\upalpha","\\up@greek{\\alpha}"),xe("\\upbeta","\\up@greek{\\beta}"),xe("\\upgamma","\\up@greek{\\gamma}"),xe("\\updelta","\\up@greek{\\delta}"),xe("\\upepsilon","\\up@greek{\\epsilon}"),xe("\\upzeta","\\up@greek{\\zeta}"),xe("\\upeta","\\up@greek{\\eta}"),xe("\\uptheta","\\up@greek{\\theta}"),xe("\\upiota","\\up@greek{\\iota}"),xe("\\upkappa","\\up@greek{\\kappa}"),xe("\\uplambda","\\up@greek{\\lambda}"),xe("\\upmu","\\up@greek{\\mu}"),xe("\\upnu","\\up@greek{\\nu}"),xe("\\upxi","\\up@greek{\\xi}"),xe("\\upomicron","\\up@greek{\\omicron}"),xe("\\uppi","\\up@greek{\\pi}"),xe("\\upalpha","\\up@greek{\\alpha}"),xe("\\uprho","\\up@greek{\\rho}"),xe("\\upsigma","\\up@greek{\\sigma}"),xe("\\uptau","\\up@greek{\\tau}"),xe("\\upupsilon","\\up@greek{\\upsilon}"),xe("\\upphi","\\up@greek{\\phi}"),xe("\\upchi","\\up@greek{\\chi}"),xe("\\uppsi","\\up@greek{\\psi}"),xe("\\upomega","\\up@greek{\\omega}"),xe("\\invamp",'\\mathbin{\\char"214b}'),xe("\\parr",'\\mathbin{\\char"214b}'),xe("\\upand",'\\mathbin{\\char"214b}'),xe("\\with",'\\mathbin{\\char"26}'),xe("\\multimapinv",'\\mathrel{\\char"27dc}'),xe("\\multimapboth",'\\mathrel{\\char"29df}'),xe("\\scoh",'{\\mkern5mu\\char"2322\\mkern5mu}'),xe("\\sincoh",'{\\mkern5mu\\char"2323\\mkern5mu}'),xe("\\coh",`{\\mkern5mu\\rule{}{0.7em}\\mathrlap{\\smash{\\raise2mu{\\char"2322}}}
|
|
6
|
+
{\\smash{\\lower4mu{\\char"2323}}}\\mkern5mu}`),xe("\\incoh",`{\\mkern5mu\\rule{}{0.7em}\\mathrlap{\\smash{\\raise2mu{\\char"2323}}}
|
|
7
|
+
{\\smash{\\lower4mu{\\char"2322}}}\\mkern5mu}`),xe("\\standardstate","\\text{\\tiny\\char`\u29B5}");let ye=r=>{if(!r.parser.settings.displayMode)throw new e(`{${r.envName}} can be used only in display mode.`)},lr=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/,Dr=r=>{let o=r.get("\\arraystretch");typeof o!="string"&&(o=Le(o.tokens)),o=isNaN(o)?null:Number(o);let i=r.get("\\arraycolsep");typeof i!="string"&&(i=Le(i.tokens));let u=lr.exec(i);return[o,u?{number:+(u[1]+u[2]),unit:u[3]}:null]},Ur=r=>{let o="";for(let i=0;i<r.length;i++)if(r[i].type==="label"){if(o)throw new e("Multiple \\labels in one row");o=r[i].string}return o};function Gr(r){if(r.indexOf("ed")===-1)return r.indexOf("*")===-1}function Zn(r,{cols:o,envClasses:i,autoTag:u,singleRow:p,emptySingleRow:v,maxNumCols:C,leqno:R,arraystretch:ge,arraycolsep:Me},We){let rt=i&&i.includes("bordermatrix")?"}":"\\end";r.gullet.beginGroup(),p||r.gullet.macros.set("\\cr","\\\\\\relax"),r.gullet.beginGroup();let Je=[],qt=[Je],ze=[],Ye=[],st=[],lt=u!=null?[]:void 0;function xt(){u&&r.gullet.macros.set("\\@eqnsw","1",!0)}function Zt(){lt&&(r.gullet.macros.get("\\df@tag")?(lt.push(r.subparse([new dn("\\df@tag")])),r.gullet.macros.set("\\df@tag",void 0,!0)):lt.push(!!u&&r.gullet.macros.get("\\@eqnsw")==="1"))}for(xt(),st.push(mn(r));;){let Jn=r.parseExpression(!1,p?"\\end":"\\\\");r.gullet.endGroup(),r.gullet.beginGroup(),Jn={type:"ordgroup",mode:r.mode,body:Jn,semisimple:!0},Je.push(Jn);let An=r.fetch().text;if(An==="&"){if(C&&Je.length===C){if(!i.includes("array"))throw new e(C===2?"The split environment accepts no more than two columns":"The equation environment accepts only one column",r.nextToken);if(r.settings.strict)throw new e("Too few columns specified in the {array} column argument.",r.nextToken)}r.consume()}else{if(An===rt){Zt(),Je.length===1&&Jn.body.length===0&&(qt.length>1||!v)&&qt.pop(),Ye.push(Ur(Jn.body)),st.length<qt.length+1&&st.push([]);break}if(An!=="\\\\")throw new e("Expected & or \\\\ or \\cr or "+rt,r.nextToken);{let br;r.consume(),r.gullet.future().text!==" "&&(br=r.parseSizeGroup(!0)),ze.push(br?br.value:null),Zt(),Ye.push(Ur(Jn.body)),st.push(mn(r)),Je=[],qt.push(Je),xt()}}}return r.gullet.endGroup(),r.gullet.endGroup(),{type:"array",mode:r.mode,body:qt,cols:o,rowGaps:ze,hLinesBeforeRow:st,envClasses:i,autoTag:u,scriptLevel:We,tags:lt,labels:Ye,leqno:R,arraystretch:ge,arraycolsep:Me}}function Qr(r){return r.slice(0,1)==="d"?"display":"text"}let Kr={c:"center ",l:"left ",r:"right "},nr=r=>{let o=new I("mtd",[]);return o.style={padding:"0",width:"50%"},r.envClasses.includes("multline")&&(o.style.width="7.5%"),o},sn=function(r,o){let i=[],u=r.body.length,p=r.hLinesBeforeRow,v=r.tags&&r.tags.some(Me=>Me);for(let Me=0;Me<u;Me++){let We=r.body[Me],rt=[],Je=r.scriptLevel==="text"?nn:r.scriptLevel==="script"?Tt:Rn;for(let lt=0;lt<We.length;lt++){let xt=new I("mtd",[Ne(We[lt],o.withLevel(Je))]);if(r.envClasses.includes("multline")){let Zt=Me===0?"left":Me===u-1?"right":"center";Zt!=="center"&&xt.classes.push("tml-"+Zt)}rt.push(xt)}let qt=r.body[0].length;for(let lt=0;lt<qt-We.length;lt++)rt.push(new I("mtd",[],[],o));if(v){let lt=r.tags[Me],xt;lt===!0?xt=new I("mtext",[new Ce(["tml-eqn"])]):lt===!1?xt=new I("mtext",[],[]):(xt=ve(lt[0].body,o.withLevel(Je),!0),xt=Pe(xt),xt.classes=["tml-tag"]),xt&&(rt.unshift(nr(r)),rt.push(nr(r)),r.leqno?rt[0].children.push(xt):rt[rt.length-1].children.push(xt))}let ze=new I("mtr",rt,[]),Ye=r.labels.shift();Ye&&r.tags&&r.tags[Me]&&(ze.setAttribute("id",Ye),Array.isArray(r.tags[Me])&&ze.classes.push("tml-tageqn")),Me===0&&p[0].length>0&&(p[0].length===2?ze.children.forEach(lt=>{lt.style.borderTop="0.15em double"}):ze.children.forEach(lt=>{lt.style.borderTop=p[0][0]?"0.06em dashed":"0.06em solid"})),p[Me+1].length>0&&(p[Me+1].length===2?ze.children.forEach(lt=>{lt.style.borderBottom="0.15em double"}):ze.children.forEach(lt=>{lt.style.borderBottom=p[Me+1][0]?"0.06em dashed":"0.06em solid"}));let st=!0;for(let lt=0;lt<ze.children.length;lt++){let xt=ze.children[lt].children[0];if(!xt||xt.type!=="mpadded"||xt.attributes.height!=="0px"){st=!1;break}}if(st){ze.classes.push("ff-squash");for(let lt=0;lt<ze.children.length;lt++)ze.children[lt].style.paddingTop="0",ze.children[lt].style.paddingBottom="0"}i.push(ze)}if(r.arraystretch&&r.arraystretch!==1){let Me=String(1.4*r.arraystretch-.8)+"ex";for(let We=0;We<i.length;We++)for(let rt=0;rt<i[We].children.length;rt++)i[We].children[rt].style.paddingTop=Me,i[We].children[rt].style.paddingBottom=Me}let C,R;if(r.envClasses.length>0&&(C=r.envClasses.includes("abut")||r.envClasses.includes("cases")?"0":r.envClasses.includes("small")?"0.1389":r.envClasses.includes("cd")?"0.25":"0.4",R="em"),r.arraycolsep){let Me=Wt(r.arraycolsep,o);C=Me.number.toFixed(4),R=Me.unit}if(C){let Me=i.length===0?0:i[0].children.length,We=(rt,Je)=>rt===0&&Je===0||rt===Me-1&&Je===1?"0":r.envClasses[0]!=="align"?C:Je===1?"0":v?rt%2?"1":"0":rt%2?"0":"1";for(let rt=0;rt<i.length;rt++)for(let Je=0;Je<i[rt].children.length;Je++)i[rt].children[Je].style.paddingLeft=`${We(Je,0)}${R}`,i[rt].children[Je].style.paddingRight=`${We(Je,1)}${R}`}if(r.envClasses.length===0)for(let Me=0;Me<i.length;Me++)i[Me].children[0].style.paddingLeft="0em",i[Me].children.length===i[0].children.length&&(i[Me].children[i[Me].children.length-1].style.paddingRight="0em");if(r.envClasses.length>0){let Me=r.envClasses.includes("align")||r.envClasses.includes("alignat");for(let We=0;We<i.length;We++){let rt=i[We];if(Me){for(let Je=0;Je<rt.children.length;Je++)rt.children[Je].classes=["tml-"+(Je%2?"left":"right")];if(v){let Je=r.leqno?0:rt.children.length-1;rt.children[Je].classes=[]}}if(rt.children.length>1&&r.envClasses.includes("cases")&&(rt.children[1].style.paddingLeft="1em"),r.envClasses.includes("cases")||r.envClasses.includes("subarray"))for(let Je of rt.children)Je.classes.push("tml-left")}}let ge=new I("mtable",i);if(r.envClasses.length>0&&(r.envClasses.includes("jot")?ge.classes.push("tml-jot"):r.envClasses.includes("small")&&ge.classes.push("tml-small")),r.scriptLevel==="display"&&ge.setAttribute("displaystyle","true"),(r.autoTag||r.envClasses.includes("multline"))&&(ge.style.width="100%"),r.cols&&r.cols.length>0){let Me=r.cols,We=!1,rt=0,Je=Me.length;for(;Me[rt].type==="separator";)rt+=1;for(;Me[Je-1].type==="separator";)Je-=1;if(Me[0].type==="separator"){let ze=Me[1].type==="separator"?"0.15em double":Me[0].separator==="|"?"0.06em solid ":"0.06em dashed ";for(let Ye of ge.children)Ye.children[0].style.borderLeft=ze}let qt=v?0:-1;for(let ze=rt;ze<Je;ze++)if(Me[ze].type==="align"){let Ye=Kr[Me[ze].align];qt+=1;for(let st of ge.children)Ye.trim()!=="center"&&qt<st.children.length&&(st.children[qt].classes=["tml-"+Ye.trim()]);We=!0}else if(Me[ze].type==="separator"){if(We){let Ye=Me[ze+1].type==="separator"?"0.15em double":Me[ze].separator==="|"?"0.06em solid":"0.06em dashed";for(let st of ge.children)qt<st.children.length&&(st.children[qt].style.borderRight=Ye)}We=!1}if(Me[Me.length-1].type==="separator"){let ze=Me[Me.length-2].type==="separator"?"0.15em double":Me[Me.length-1].separator==="|"?"0.06em solid":"0.06em dashed";for(let Ye of ge.children)Ye.children[Ye.children.length-1].style.borderRight=ze,Ye.children[Ye.children.length-1].style.paddingRight="0.4em"}}return r.envClasses.includes("small")&&(ge=new I("mstyle",[ge]),ge.setAttribute("scriptlevel","1")),ge},Un=function(r,o){r.envName.indexOf("ed")===-1&&ye(r);let i=r.envName==="split",u=[],p=Zn(r.parser,{cols:u,emptySingleRow:!0,autoTag:i?void 0:Gr(r.envName),envClasses:["abut","jot"],maxNumCols:r.envName==="split"?2:void 0,leqno:r.parser.settings.leqno},"display"),v,C=0,R=r.envName.indexOf("at")>-1;if(o[0]&&R){let ge="";for(let Me=0;Me<o[0].body.length;Me++)ge+=Nt(o[0].body[Me],"textord").text;if(isNaN(ge))throw new e("The alignat enviroment requires a numeric first argument.");v=Number(ge),C=2*v}p.body.forEach(function(ge){if(R){let Me=ge.length/2;if(v<Me)throw new e(`Too many math in a row: expected ${v}, but got ${Me}`,ge[0])}else C<ge.length&&(C=ge.length)});for(let ge=0;ge<C;++ge){let Me="r";ge%2==1&&(Me="l"),u[ge]={type:"align",align:Me}}return r.envName==="split"||(R?p.envClasses.push("alignat"):p.envClasses[0]="align"),p};wn({type:"array",names:["array","darray"],props:{numArgs:1},handler(r,o){let i=(ar(o[0])?[o[0]]:Nt(o[0],"ordgroup").body).map(function(C){let R=Ln(C).text;if("lcr".indexOf(R)!==-1)return{type:"align",align:R};if(R==="|")return{type:"separator",separator:"|"};if(R===":")return{type:"separator",separator:":"};throw new e("Unknown column alignment: "+R,C)}),[u,p]=Dr(r.parser.gullet.macros),v={cols:i,envClasses:["array"],maxNumCols:i.length,arraystretch:u,arraycolsep:p};return Zn(r.parser,v,Qr(r.envName))},mathmlBuilder:sn}),wn({type:"array",names:["matrix","pmatrix","bmatrix","Bmatrix","vmatrix","Vmatrix","matrix*","pmatrix*","bmatrix*","Bmatrix*","vmatrix*","Vmatrix*"],props:{numArgs:0},handler(r){let o={matrix:null,pmatrix:["(",")"],bmatrix:["[","]"],Bmatrix:["\\{","\\}"],vmatrix:["|","|"],Vmatrix:["\\Vert","\\Vert"]}[r.envName.replace("*","")],i="c",u={envClasses:[],cols:[]};if(r.envName.charAt(r.envName.length-1)==="*"){let R=r.parser;if(R.consumeSpaces(),R.fetch().text==="["){if(R.consume(),R.consumeSpaces(),i=R.fetch().text,"lcr".indexOf(i)===-1)throw new e("Expected l or c or r",R.nextToken);R.consume(),R.consumeSpaces(),R.expect("]"),R.consume(),u.cols=[]}}let p=Zn(r.parser,u,"text");p.cols=p.body.length>0?new Array(p.body[0].length).fill({type:"align",align:i}):[];let[v,C]=Dr(r.parser.gullet.macros);return p.arraystretch=v,!C||C===6&&C==="pt"||(p.arraycolsep=C),o?{type:"leftright",mode:r.mode,body:[p],left:o[0],right:o[1],rightColor:void 0}:p},mathmlBuilder:sn}),wn({type:"array",names:["bordermatrix"],props:{numArgs:0},handler(r){let o=Zn(r.parser,{cols:[],envClasses:["bordermatrix"]},"text");return o.cols=o.body.length>0?new Array(o.body[0].length).fill({type:"align",align:"c"}):[],o.envClasses=[],o.arraystretch=1,r.envName==="matrix"?o:((i,u)=>{let p=i.body;p[0].shift();let v=new Array(p.length-1).fill().map(()=>[]);for(let We=1;We<p.length;We++){v[We-1].push(p[We].shift());let rt=[];for(let Je=0;Je<p[We].length;Je++)rt.push(p[We][Je]);v[We-1].push(Mn(rt,"vphantom"))}let C=new Array(p.length).fill().map(()=>[]);for(let We=0;We<p[0].length;We++)C[0].push(p[0][We]);for(let We=1;We<p.length;We++)for(let rt=0;rt<p[0].length;rt++)C[We].push(Mn(p[We][rt].body,"hphantom"));for(let We=0;We<p[0].length;We++)p[0][We]=Mn(p[0][We].body,"hphantom");let R={type:"array",mode:"math",body:v,cols:[{type:"align",align:"c"}],rowGaps:new Array(v.length-1).fill(null),hLinesBeforeRow:new Array(v.length+1).fill().map(()=>[]),envClasses:[],scriptLevel:"text",arraystretch:1,labels:new Array(v.length).fill(""),arraycolsep:{number:.04,unit:"em"}},ge={type:"styling",mode:"math",scriptLevel:"text",body:[{type:"array",mode:"math",body:C,cols:new Array(C.length).fill({type:"align",align:"c"}),rowGaps:new Array(C.length-1).fill(null),hLinesBeforeRow:new Array(C.length+1).fill().map(()=>[]),envClasses:[],scriptLevel:"text",arraystretch:1,labels:new Array(C.length).fill(""),arraycolsep:null}]},Me={type:"leftright",mode:"math",body:[i],left:u?u[0]:"(",right:u?u[1]:")",rightColor:void 0};return tn([R,{type:"supsub",mode:"math",stack:!0,base:{type:"op",mode:"math",limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!0,symbol:!1,suppressBaseShift:!0,body:[Me]},sup:ge,sub:null}])})(o,r.delimiters)},mathmlBuilder:sn}),wn({type:"array",names:["smallmatrix"],props:{numArgs:0},handler:r=>Zn(r.parser,{envClasses:["small"]},"script"),mathmlBuilder:sn}),wn({type:"array",names:["subarray"],props:{numArgs:1},handler(r,o){let i=(ar(o[0])?[o[0]]:Nt(o[0],"ordgroup").body).map(function(p){let v=Ln(p).text;if("lc".indexOf(v)!==-1)return{type:"align",align:v};throw new e("Unknown column alignment: "+v,p)});if(i.length>1)throw new e("{subarray} can contain only one column");let u={cols:i,envClasses:["small"]};if(u=Zn(r.parser,u,"script"),u.body.length>0&&u.body[0].length>1)throw new e("{subarray} can contain only one column");return u},mathmlBuilder:sn}),wn({type:"array",names:["cases","dcases","rcases","drcases"],props:{numArgs:0},handler(r){let o=Zn(r.parser,{cols:[],envClasses:["cases"]},Qr(r.envName));return{type:"leftright",mode:r.mode,body:[o],left:r.envName.indexOf("r")>-1?".":"\\{",right:r.envName.indexOf("r")>-1?"\\}":".",rightColor:void 0}},mathmlBuilder:sn}),wn({type:"array",names:["align","align*","aligned","split"],props:{numArgs:0},handler:Un,mathmlBuilder:sn}),wn({type:"array",names:["alignat","alignat*","alignedat"],props:{numArgs:1},handler:Un,mathmlBuilder:sn}),wn({type:"array",names:["gathered","gather","gather*"],props:{numArgs:0},handler(r){r.envName!=="gathered"&&ye(r);let o={cols:[],envClasses:["abut","jot"],autoTag:Gr(r.envName),emptySingleRow:!0,leqno:r.parser.settings.leqno};return Zn(r.parser,o,"display")},mathmlBuilder:sn}),wn({type:"array",names:["equation","equation*"],props:{numArgs:0},handler(r){ye(r);let o={autoTag:Gr(r.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,envClasses:["align"],leqno:r.parser.settings.leqno};return Zn(r.parser,o,"display")},mathmlBuilder:sn}),wn({type:"array",names:["multline","multline*"],props:{numArgs:0},handler(r){ye(r);let o={autoTag:r.envName==="multline",maxNumCols:1,envClasses:["jot","multline"],leqno:r.parser.settings.leqno};return Zn(r.parser,o,"display")},mathmlBuilder:sn}),wn({type:"array",names:["CD"],props:{numArgs:0},handler:r=>(ye(r),function(o){let i=[];for(o.gullet.beginGroup(),o.gullet.macros.set("\\cr","\\\\\\relax"),o.gullet.beginGroup();;){i.push(o.parseExpression(!1,"\\\\")),o.gullet.endGroup(),o.gullet.beginGroup();let v=o.fetch().text;if(v!=="&"&&v!=="\\\\"){if(v==="\\end"){i[i.length-1].length===0&&i.pop();break}throw new e("Expected \\\\ or \\cr or \\end",o.nextToken)}o.consume()}let u=[],p=[u];for(let v=0;v<i.length;v++){let C=i[v],R=kn();for(let ge=0;ge<C.length;ge++)if(Bn(C[ge])){u.push(R),ge+=1;let Me=Ln(C[ge]).text,We=new Array(2);if(We[0]={type:"ordgroup",mode:"math",body:[]},We[1]={type:"ordgroup",mode:"math",body:[]},!("=|.".indexOf(Me)>-1)){if(!("<>AV".indexOf(Me)>-1))throw new e('Expected one of "<>AV=|." after @.');for(let Je=0;Je<2;Je++){let qt=!0;for(let ze=ge+1;ze<C.length;ze++){if(wr(C[ze],Me)){qt=!1,ge=ze;break}if(Bn(C[ze]))throw new e("Missing a "+Me+" character to complete a CD arrow.",C[ze]);We[Je].body.push(C[ze])}if(qt)throw new e("Missing a "+Me+" character to complete a CD arrow.",C[ge])}}let rt=Nr(Me,We,o);u.push(rt),R=kn()}else R.body.push(C[ge]);v%2==0?u.push(R):u.shift(),u=[],p.push(u)}return p.pop(),o.gullet.endGroup(),o.gullet.endGroup(),{type:"array",mode:"math",body:p,tags:null,labels:new Array(p.length+1).fill(""),envClasses:["jot","cd"],cols:[],hLinesBeforeRow:new Array(p.length+1).fill([])}}(r.parser)),mathmlBuilder:sn}),E({type:"text",names:["\\hline","\\hdashline"],props:{numArgs:0,allowedInText:!0,allowedInMath:!0},handler(r,o){throw new e(`${r.funcName} valid only within array environment`)}});let Gn=Cn;E({type:"bordermatrix",names:["\\bordermatrix","\\matrix"],props:{numArgs:0,numOptionalArgs:1},handler:({parser:r,funcName:o},i,u)=>{let p=["(",")"];if(o==="\\bordermatrix"&&u[0]&&u[0].body){let ge=u[0].body;ge.length===1&&ge[0].type==="delimiter"&&(p=[ge[0].left,ge[0].right])}r.consumeSpaces(),r.consume();let v=Gn.bordermatrix,C={mode:r.mode,envName:o.slice(1),delimiters:p,parser:r},R=v.handler(C);return r.expect("}",!0),R}}),E({type:"cancelto",names:["\\cancelto"],props:{numArgs:2},handler({parser:r},o){let i=o[0],u=o[1];return{type:"cancelto",mode:r.mode,body:u,to:i,isCharacterBox:g(u)}},mathmlBuilder(r,o){let i=new I("mrow",[Ne(r.body,o)],["ff-narrow"]),u=new I("mphantom",[Ne(r.body,o)]),p=new I("mrow",[u],["tml-cancelto"]);p.style.color=o.color,r.isCharacterBox&&y.indexOf(r.body.body[0].text)>-1&&(p.style.left="0.1em",p.style.width="90%");let v=new I("mrow",[i,p],["menclose"]);if(!r.isCharacterBox||/[f∫∑]/.test(r.body.body[0].text))u.style.paddingRight="0.2em";else{u.style.padding="0.5ex 0.1em 0 0";let rt=new I("mspace",[]);rt.setAttribute("height","0.85em"),i.children.push(rt)}let C;if(r.isCharacterBox)C=new I("mspace",[]),C.setAttribute("height","1em");else{let rt=Ne(r.body,o),Je=new I("mpadded",[rt]);Je.setAttribute("width","0.1px"),C=new I("mphantom",[Je])}let R=Ne(r.to,o);R.style.color=o.color;let ge=new I("mpadded",[R]);if(!r.isCharacterBox||/[f∫∑]/.test(r.body.body[0].text)){let rt=new I("mspace",[]);rt.setAttribute("width","0.2em"),ge.children.unshift(rt)}ge.setAttribute("width","0.1px");let Me=new I("mover",[C,ge]),We=new I("mrow",[],["ff-nudge-left"]);return ie([ke([v,Me]),We])}}),E({type:"textord",names:["\\@char"],props:{numArgs:1,allowedInText:!0},handler({parser:r,token:o},i){let u=Nt(i[0],"ordgroup").body,p="";for(let C=0;C<u.length;C++)p+=Nt(u[C],"textord").text;let v=parseInt(p);if(isNaN(v))throw new e(`\\@char has non-numeric argument ${p}`,o);return{type:"textord",mode:r.mode,text:String.fromCodePoint(v)}}});let _r=/^(#[a-f0-9]{3}|#?[a-f0-9]{6})$/i,ln=/^(#[a-f0-9]{3}|#?[a-f0-9]{6}|[a-z]+)$/i,cr=/^ *\d{1,3} *(?:, *\d{1,3} *){2}$/,cn=/^ *[10](?:\.\d*)? *(?:, *[10](?:\.\d*)? *){2}$/,Ot=/^[a-f0-9]{6}$/i,Jt=r=>{let o=r.toString(16);return o.length===1&&(o="0"+o),o},Fn=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`),le=Q,he=j),oe===void 0
|
|
|
88
88
|
"Yellow": "#fff404",
|
|
89
89
|
"YellowGreen": "#98cc6c",
|
|
90
90
|
"YellowOrange": "#ffa41c"
|
|
91
|
-
}`),$n=(e,n)=>{let r="";if(e==="HTML"){if(!Sn.test(n))throw new t("Invalid HTML input.");r=n}else if(e==="RGB"){if(!Hn.test(n))throw new t("Invalid RGB input.");n.split(",").map(l=>{r+=Tt(Number(l.trim()))})}else{if(!jn.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+=Tt(Number((255*u).toFixed(0)))})}return r.charAt(0)!=="#"&&(r="#"+r),r},Cn=(e,n,r)=>{let l=`\\\\color@${e}`;if(!Un.exec(e))throw new t("Invalid color: '"+e+"'",r);return Fr.test(e)?"#"+e:(e.charAt(0)==="#"||(n.has(l)?e=n.get(l).tokens[0].text:Gn[e]&&(e=Gn[e])),e)},Ct=(e,n)=>{let r=rt(e.body,n.withColor(e.color));return r.length===0&&r.push(new _("mrow")),r=r.map(l=>(l.style.color=e.color,l)),bt(r)};N({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]&&Ne(l[0],"raw").string,h="";if(u){let E=Ne(r[0],"raw").string;h=$n(u,E)}else h=Cn(Ne(r[0],"raw").string,e.gullet.macros,n);let y=r[1];return{type:"color",mode:e.mode,color:h,isTextColor:!0,body:pe(y)}},mathmlBuilder:Ct}),N({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]&&Ne(u[0],"raw").string,y="";if(h){let U=Ne(l[0],"raw").string;y=$n(h,U)}else y=Cn(Ne(l[0],"raw").string,e.gullet.macros,r);let E=e.parseExpression(!0,n,!0);return{type:"color",mode:e.mode,color:y,isTextColor:!1,body:E}},mathmlBuilder:Ct}),N({type:"color",names:["\\definecolor"],props:{numArgs:3,allowedInText:!0,argTypes:["raw","raw","raw"]},handler({parser:e,funcName:n,token:r},l){let u=Ne(l[0],"raw").string;if(!/^[A-Za-z]+$/.test(u))throw new t("Color name must be latin letters.",r);let h=Ne(l[1],"raw").string;if(!["HTML","RGB","rgb"].includes(h))throw new t("Color model must be HTML, RGB, or rgb.",r);let y=Ne(l[2],"raw").string,E=$n(h,y);return e.gullet.macros.set(`\\\\color@${u}`,{tokens:[{text:E}],numArgs:0}),{type:"internal",mode:e.mode}}}),N({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&&Ne(l,"size").value}},mathmlBuilder(e,n){let r=new _("mo");if(e.newLine&&(r.setAttribute("linebreak","newline"),e.size)){let l=Kt(e.size,n);r.setAttribute("height",l.number+l.unit)}return r}});let Rn={"\\global":"\\global","\\long":"\\\\globallong","\\\\globallong":"\\\\globallong","\\def":"\\gdef","\\gdef":"\\gdef","\\edef":"\\xdef","\\xdef":"\\xdef","\\let":"\\\\globallet","\\futurelet":"\\\\globalfuture"},x=e=>{let n=e.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(n))throw new t("Expected a control sequence",e);return n},q=(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)};N({type:"internal",names:["\\global","\\long","\\\\globallong"],props:{numArgs:0,allowedInText:!0},handler({parser:e,funcName:n}){e.consumeSpaces();let r=e.fetch();if(Rn[r.text])return n!=="\\global"&&n!=="\\\\globallong"||(r.text=Rn[r.text]),Ne(e.parseFunction(),"internal");throw new t("Invalid token after macro prefix",r)}}),N({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:E}=e.gullet.consumeArg();if(u&&E.unshift(u),n==="\\edef"||n==="\\xdef"){if(E=e.gullet.expandTokens(E),E.length>e.gullet.settings.maxExpand)throw new t("Too many expansions in an "+n);E.reverse()}return e.gullet.macros.set(l,{tokens:E,numArgs:h,delimiters:y},n===Rn[n]),{type:"internal",mode:e.mode}}}),N({type:"internal",names:["\\let","\\\\globallet"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:n}){let r=x(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 q(e,r,l,n==="\\\\globallet"),{type:"internal",mode:e.mode}}}),N({type:"internal",names:["\\futurelet","\\\\globalfuture"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:n}){let r=x(e.gullet.popToken()),l=e.gullet.popToken(),u=e.gullet.popToken();return q(e,r,u,n==="\\\\globalfuture"),e.gullet.pushToken(u),e.gullet.pushToken(l),{type:"internal",mode:e.mode}}}),N({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=x(e.gullet.popToken()),e.gullet.popToken()):r=x(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 E=e.gullet.popToken();if(E=e.gullet.popToken(),!/^[0-9]$/.test(E.text))throw new t(`Invalid number of arguments: "${E.text}"`);if(h=parseInt(E.text),E=e.gullet.popToken(),E.text!=="]")throw new t(`Invalid argument "${E.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 D={"\\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}},ve={"(":")","\\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"},et=new Set(Object.keys(ve));new Set(Object.values(ve));let St=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","."]),Jt=new Set(["}","\\left","\\middle","\\right"]),hn=e=>e.length>0&&(St.has(e)||D[e]||Jt.has(e)),bn=[0,1.2,1.8,2.4,3];function In(e,n){e.type==="ordgroup"&&e.body.length===1&&(e=e.body[0]);let r=M(e);if(r&&St.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 wr=new Set(["/","\\","\\backslash","\u2216","\\vert","|"]),vr=(e,n,r,l)=>{let u=new _("mo",[Xe(e==="."?"":e,n)]);return u.setAttribute("fence","true"),u.setAttribute("form",r),u.setAttribute("stretchy",l?"true":"false"),u};function ss(e){if(!e.body)throw new Error("Bug: The delim ParseNode wasn't fully parsed.")}N({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=In(n[0],e),l={type:"delimsizing",mode:e.parser.mode,size:D[e.funcName].size,mclass:D[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(Xe(r,e.mode));let l=new _("mo",n);return e.mclass==="mopen"||e.mclass==="mclose"?l.setAttribute("fence","true"):l.setAttribute("fence","false"),(wr.has(r)||r.indexOf("arrow")>-1)&&l.setAttribute("stretchy","true"),l.setAttribute("symmetric","true"),l.setAttribute("minsize",bn[e.size]+"em"),l.setAttribute("maxsize",bn[e.size]+"em"),l}}),N({type:"leftright-right",names:["\\right"],props:{numArgs:1,argTypes:["primitive"]},handler:(e,n)=>({type:"leftright-right",mode:e.parser.mode,delim:In(n[0],e).text})}),N({type:"leftright",names:["\\left"],props:{numArgs:1,argTypes:["primitive"]},handler:(e,n)=>{let r=In(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 E=l.fetch().text;if(!Y.math[E])throw new t(`Invalid delimiter '${E}' after '\\middle'`);In({type:"atom",mode:"math",text:E},{funcName:"\\middle"}),u.push({type:"middle",mode:"math",delim:E}),l.consume(),u=u.concat(l.parseExpression(!1,"\\right",!0)),h=l.fetch()}--l.leftrightDepth,l.expect("\\right",!1);let y=Ne(l.parseFunction(),"leftright-right");return{type:"leftright",mode:l.mode,body:u,left:r.text,right:y.delim,isStretchy:!0}},mathmlBuilder:(e,n)=>{ss(e);let r=rt(e.body,n),l=vr(e.left,e.mode,"prefix",!0);r.unshift(l);let u=vr(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)}}),N({type:"delimiter",names:Array.from(et),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=ve[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)=>{ss(e);let r=rt(e.body,n),l=vr(e.left,e.mode,"prefix",!1);r.unshift(l);let u=vr(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)}}),N({type:"middle",names:["\\middle"],props:{numArgs:1,argTypes:["primitive"]},handler:(e,n)=>{let r=In(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=Xe(e.delim,e.mode),r=new _("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 xr=["\\boxed","\\fcolorbox","\\colorbox"],Nn=(e,n)=>{let r=xr.includes(e.label)?"mrow":"menclose",l=new _(r,[tt(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 _("mrow",[],["tml-cancel","upstrike"]));break;case"\\bcancel":l.setAttribute("notation","downdiagonalstrike"),l.children.push(new _("mrow",[],["tml-cancel","downstrike"]));break;case"\\sout":l.setAttribute("notation","horizontalstrike"),l.children.push(new _("mrow",[],["tml-cancel","sout"]));break;case"\\xcancel":l.setAttribute("notation","updiagonalstrike downdiagonalstrike"),l.children.push(new _("mrow",[],["tml-cancel","tml-xcancel"]));break;case"\\longdiv":l.setAttribute("notation","longdiv"),l.classes.push("longdiv-top"),l.children.push(new _("mrow",[],["longdiv-arc"]));break;case"\\phase":l.setAttribute("notation","phasorangle"),l.classes.push("phasor-bottom"),l.children.push(new _("mrow",[],["phasor-angle"]));break;case"\\textcircled":l.setAttribute("notation","circle"),l.classes.push("circle-pad"),l.children.push(new _("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};N({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]&&Ne(l[0],"raw").string,h="";if(u){let E=Ne(r[0],"raw").string;h=$n(u,E)}else h=Cn(Ne(r[0],"raw").string,e.gullet.macros);let y=r[1];return{type:"enclose",mode:e.mode,label:n,backgroundColor:h,body:y}},mathmlBuilder:Nn}),N({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]&&Ne(l[0],"raw").string,h,y="";if(u){let U=Ne(r[0],"raw").string,V=Ne(r[0],"raw").string;y=$n(u,U),h=$n(u,V)}else y=Cn(Ne(r[0],"raw").string,e.gullet.macros),h=Cn(Ne(r[1],"raw").string,e.gullet.macros);let E=r[2];return{type:"enclose",mode:e.mode,label:n,backgroundColor:h,borderColor:y,body:E}},mathmlBuilder:Nn}),N({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]})}),N({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:Nn}),N({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:Nn}),N({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:Nn}),N({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:Nn}),N({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+=Ne(l.body[h],"textord").text;if(n==="\\begin"){if(!Object.prototype.hasOwnProperty.call(vn,u))throw new t("No such environment: "+u,l);let h=vn[u],{args:y,optArgs:E}=e.parseArguments("\\begin{"+u+"}",h),U={mode:e.mode,envName:u,parser:e},V=h.handler(U,y,E);e.expect("\\end",!1);let be=e.nextToken,Te=Ne(e.parseFunction(),"environment");if(Te.name!==u)throw new t(`Mismatch: \\begin{${u}} matched by \\end{${Te.name}}`,be);return V}return{type:"environment",mode:e.mode,name:u,nameGroup:l}}}),N({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 _("mrow")}),N({type:"noTag",names:["\\env@notag"],props:{numArgs:0},handler:({parser:e})=>({type:"noTag",mode:e.mode}),mathmlBuilder:(e,n)=>new _("mrow")});let os=Object.freeze({B:8426,E:8427,F:8427,H:8387,I:8391,L:8390,M:8422,R:8393,e:8394,g:8355,o:8389}),ur=Object.freeze({C:8426,H:8388,I:8392,R:8394,Z:8398}),Us=Object.freeze({C:8383,H:8389,N:8391,P:8393,Q:8393,R:8395,Z:8394}),Kn=Object.freeze({"\u03F5":119527,\u03D1:119564,\u03F0:119534,\u03C6:119577,\u03F1:119535,\u03D6:119563}),is=Object.freeze({"\u03F5":119643,\u03D1:119680,\u03F0:119650,\u03C6:119693,\u03F1:119651,\u03D6:119679}),zr=Object.freeze({"\u03F5":119701,\u03D1:119738,\u03F0:119708,\u03C6:119751,\u03F1:119709,\u03D6:119737}),Hs=Object.freeze({"\u03F5":119759,\u03D1:119796,\u03F0:119766,\u03C6:119809,\u03F1:119767,\u03D6:119795}),as=Object.freeze({upperCaseLatin:{normal:e=>0,bold:e=>119743,italic:e=>119795,"bold-italic":e=>119847,script:e=>os[e]||119899,"script-bold":e=>119951,fraktur:e=>ur[e]||120003,"fraktur-bold":e=>120107,"double-struck":e=>Us[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=>os[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=>Kn[e]||-51,italic:e=>0,"bold-italic":e=>is[e]||58,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>0,"sans-serif":e=>zr[e]||116,"sans-serif-bold":e=>zr[e]||116,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>Hs[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}}),Mn=(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||Kn[e]?"varGreek":47<r&&r<58?"numeral":"other";return l==="other"?e:String.fromCodePoint(r+as[l][n](e))},ls=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"}),cs=["mathrm","mathit"],kr=(e,n)=>{let r=e.font,l=n.withFont(r),u=tt(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(((E,U)=>{if(!cs.includes(U)||!E.body||E.body.type!=="ordgroup"||E.body.body.length===1||E.body.body[0].type!=="mathord")return!1;for(let V=1;V<E.body.body.length;V++){let be=E.body.body[V].type;if(be!=="mathord"&&(be!=="textord"||isNaN(E.body.body[V].text)))return!1}return!0})(e,r)){let E=u.children[0].children[0].children?u.children[0].children[0]:u.children[0];delete E.attributes.mathvariant;for(let V=1;V<u.children.length;V++)E.children[0].text+=u.children[V].children[0].children?u.children[V].children[0].children[0].text:u.children[V].children[0].text;if(r==="mathit")return E.children[0].text=E.children[0].text.split("").map(V=>Mn(V,"italic")).join(""),E;let U=new _("mpadded",[E]);return U.setAttribute("lspace","0"),U}let h=u.children[0].type==="mo";for(let E=1;E<u.children.length;E++)u.children[E].type==="mo"&&r==="boldsymbol"&&(u.children[E].style.fontWeight="bold"),u.children[E].type!=="mi"&&(h=!1),(u.children[E].attributes&&u.children[E].attributes.mathvariant||"")!=="normal"&&(h=!1);if(!h)return u;let y=u.children[0];for(let E=1;E<u.children.length;E++)y.children.push(u.children[E].children[0]);if(y.attributes.mathvariant&&y.attributes.mathvariant==="normal"){let E=new _("mtext",new je("\u200B"));return new _("mrow",[E,y])}return y},Ur={"\\Bbb":"\\mathbb","\\bold":"\\mathbf","\\frak":"\\mathfrak","\\bm":"\\boldsymbol"};N({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 Ur&&(u=Ur[u]),{type:"font",mode:e.mode,font:u.slice(1),body:l}},mathmlBuilder:kr}),N({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:kr});let Hr=["display","text","script","scriptscript"],Er={auto:-1,display:0,text:0,script:1,scriptscript:2},nn=(e,n)=>{n=((h,y)=>{let E=y;if(h==="display"){let U=E.level>=pt?Mt:wt;E=E.withLevel(U)}else h==="text"&&E.level===wt?E=E.withLevel(Mt):h==="auto"?E=E.incrementLevel():h==="script"?E=E.withLevel(pt):h==="scriptscript"&&(E=E.withLevel(nt));return E})(e.scriptLevel,n);let r=tt(e.numer,n),l=tt(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 _("mfrac",[r,l]);if(e.hasBarLine){if(e.barSize){let h=Kt(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 _("mo",[new je(e.leftDelim.replace("\\",""))]);y.setAttribute("fence","true"),h.push(y)}if(h.push(u),e.rightDelim!=null){let y=new _("mo",[new je(e.rightDelim.replace("\\",""))]);y.setAttribute("fence","true"),h.push(y)}u=ke(h)}return e.scriptLevel!=="auto"&&(u=new _("mstyle",[u]),u.setAttribute("displaystyle",String(e.scriptLevel==="display")),u.setAttribute("scriptlevel",Er[e.scriptLevel])),u};N({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,E=null,U="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="(",E=")";break;case"\\\\bracefrac":y="\\{",E="\\}";break;case"\\\\brackfrac":y="[",E="]";break;default:throw new Error("Unrecognized genfrac command")}return n==="\\cfrac"||n.startsWith("\\d")?U="display":n.startsWith("\\t")&&(U="text"),{type:"genfrac",mode:e.mode,continued:!1,numer:l,denom:u,hasBarLine:h,leftDelim:y,rightDelim:E,scriptLevel:U,barSize:null}},mathmlBuilder:nn}),N({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 tr=function(e){let n=null;return e.length>0&&(n=e,n=n==="."?null:n),n};N({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"?tr(u.text):null,y=Se(n[1]),E=y.type==="atom"&&y.family==="close"?tr(y.text):null,U=Ne(n[2],"size"),V,be=null;U.isBlank?V=!0:(be=U.value,V=be.number>0);let Te="auto",de=n[3];if(de.type==="ordgroup"){if(de.body.length>0){let kt=Ne(de.body[0],"textord");Te=Hr[Number(kt.text)]}}else de=Ne(de,"textord"),Te=Hr[Number(de.text)];return{type:"genfrac",mode:e.mode,numer:r,denom:l,continued:!1,hasBarLine:V,barSize:be,leftDelim:h,rightDelim:E,scriptLevel:Te}},mathmlBuilder:nn}),N({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:Ne(l[0],"size").value,token:r})}),N({type:"genfrac",names:["\\\\abovefrac"],props:{numArgs:3,argTypes:["math","size","math"]},handler:({parser:e,funcName:n},r)=>{let l=r[0],u=function(E){if(!E)throw new Error("Expected non-null, but got "+String(E));return E}(Ne(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:nn}),N({type:"hbox",names:["\\hbox"],props:{numArgs:1,argTypes:["hbox"],allowedInArgument:!0,allowedInText:!1},handler:({parser:e},n)=>({type:"hbox",mode:e.mode,body:pe(n[0])}),mathmlBuilder(e,n){let r=n.withLevel(Mt),l=Je(e.body,r);return ft(l)}}),N({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 _(e.isOver?"mover":"munder",[tt(e.base,n),r])}}),N({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=Ne(l[0],"raw").string,h=l[1];if(e.settings.strict)throw new t(`Function "${n}" is disabled in strict mode`,r);let y,E={};switch(n){case"\\class":E.class=u,y={command:"\\class",class:u};break;case"\\id":E.id=u,y={command:"\\id",id:u};break;case"\\style":E.style=u,y={command:"\\style",style:u};break;case"\\data":{let U=u.split(",");for(let V=0;V<U.length;V++){let be=U[V].split("=");if(be.length!==2)throw new t("Error parsing key-value for \\data");E["data-"+be[0].trim()]=be[1].trim()}y={command:"\\data",attributes:E};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:E,body:pe(h)}},mathmlBuilder:(e,n)=>{let r=Je(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 xn=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(!pn(r))throw new t("Invalid unit: '"+r.unit+"' in \\includegraphics.");return r}};N({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"},E="";if(l[0]){let V=Ne(l[0],"raw").string.split(",");for(let be=0;be<V.length;be++){let Te=V[be].split("=");if(Te.length===2){let de=Te[1].trim();switch(Te[0].trim()){case"alt":E=de;break;case"width":u=xn(de);break;case"height":h=xn(de);break;case"totalheight":y=xn(de);break;default:throw new t("Invalid key: '"+Te[0]+"' in \\includegraphics.")}}}}let U=Ne(r[0],"url").url;if(E===""&&(E=U,E=E.replace(/^.*[\\/]/,""),E=E.substring(0,E.lastIndexOf("."))),!e.settings.isTrusted({command:"\\includegraphics",url:U}))throw new t('Function "\\includegraphics" is not trusted',n);return{type:"includegraphics",mode:e.mode,alt:E,width:u,height:h,totalheight:y,src:U}},mathmlBuilder:(e,n)=>{let r=Kt(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=Kt(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 Ze(e.src,e.alt,h);return y.height=r,y.depth=l,new _("mtext",[y])}}),N({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=Ne(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=Kt(e.dimension,n),l=r.number>0&&r.unit==="em"?nr(r.number):"";if(e.mode==="text"&&l.length>0){let u=new je(l);return new _("mtext",[u])}if(r.number>=0){let u=new _("mspace");return u.setAttribute("width",r.number+r.unit),u}{let u=new _("mrow");return u.style.marginLeft=r.number+r.unit,u}}});let nr=function(e){return e>=.05555&&e<=.05556?"\u200A":e>=.1666&&e<=.1667?"\u2009":e>=.2222&&e<=.2223?"\u2005":e>=.2777&&e<=.2778?"\u2005\u200A":""},mn=/[^A-Za-z_0-9-]/g;N({type:"label",names:["\\label"],props:{numArgs:1,argTypes:["raw"]},handler:({parser:e},n)=>({type:"label",mode:e.mode,string:n[0].string.replace(mn,"")}),mathmlBuilder(e,n){let r=new _("mrow",[],["tml-label"]);return e.string.length>0&&r.setLabel(e.string),r}});let Sr=["\\clap","\\llap","\\rlap"];N({type:"lap",names:["\\mathllap","\\mathrlap","\\mathclap","\\clap","\\llap","\\rlap"],props:{numArgs:1,allowedInText:!0},handler:({parser:e,funcName:n,token:r},l)=>{if(Sr.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=rt(pe(e.body),n),y=new _("mphantom",h);r=new _("mpadded",[y]),r.setAttribute("width","0.1px")}let l=tt(e.body,n),u;if(e.alignment==="llap"?(l.style.position="absolute",l.style.right="0",l.style.bottom="0",u=new _("mpadded",[r,l])):u=new _("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}}),N({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}}}),N({type:"text",names:["\\)","\\]"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(e,n){throw new t(`Mismatched ${e.funcName}`,n)}}),N({type:"mathchoice",names:["\\mathchoice"],props:{numArgs:4,primitive:!0},handler:({parser:e},n)=>({type:"mathchoice",mode:e.mode,display:pe(n[0]),text:pe(n[1]),script:pe(n[2]),scriptscript:pe(n[3])}),mathmlBuilder:(e,n)=>{let r=((l,u)=>{switch(u.level){case wt:return l.display;case Mt:return l.text;case pt:return l.script;case nt:return l.scriptscript;default:return l.text}})(e,n);return Je(r,n)}});let Pn=["text","textord","mathord","atom"];function pr(e,n){let r,l=rt(e.body,n);if(e.mclass==="minner")r=new _("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 _("mi",l);else{r=new _("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 _("mrow",l);let u=n.level<2;r.type==="mrow"?u&&(e.mclass==="mbin"?(r.children.unshift(_t(.2222)),r.children.push(_t(.2222))):e.mclass==="mrel"?(r.children.unshift(_t(.2778)),r.children.push(_t(.2778))):e.mclass==="mpunct"?r.children.push(_t(.1667)):e.mclass==="minner"&&(r.children.unshift(_t(.0556)),r.children.push(_t(.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}N({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=v(l),h=!0,y={type:"mathord",text:"",mode:e.mode},E=l.body?l.body:[l];for(let U of E){if(!Pn.includes(U.type)){h=!1;break}Y[e.mode][U.text]?y.text+=Y[e.mode][U.text].replace:U.text?y.text+=U.text:U.body&&U.body.map(V=>{y.text+=V.text})}return h&&n==="\\mathord"&&y.type==="mathord"&&y.text.length>1?y:{type:"mclass",mode:e.mode,mclass:"m"+n.slice(5),body:pe(h?y:l),isCharacterBox:u,mustPromote:h}},mathmlBuilder:pr});let Wn=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&&Y.math[e.body[0].text]?Y.math[e.body[0].text].group:n.family;return r==="bin"||r==="rel"?"m"+r:"mord"}return"mord"};N({type:"mclass",names:["\\@binrel"],props:{numArgs:2},handler:({parser:e},n)=>({type:"mclass",mode:e.mode,mclass:Wn(n[0]),body:pe(n[1]),isCharacterBox:v(n[1])})}),N({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"?Wn(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:pe(l)};return{type:"supsub",mode:u.mode,stack:!0,base:y,sup:n==="\\underset"?null:u,sub:n==="\\underset"?u:null}},mathmlBuilder:pr});let hr=(e,n,r)=>{if(!e)return r;let l=tt(e,n);return l.type==="mrow"&&l.children.length===0?r:l};N({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=tt(e.base,n),l=new _("mprescripts"),u=new _("none"),h=[],y=hr(e.prescripts.sub,n,u),E=hr(e.prescripts.sup,n,u);return e.isSideset&&(y.setAttribute("style","text-align: left;"),E.setAttribute("style","text-align: left;")),e.postscripts?h=[r,hr(e.postscripts.sub,n,u),hr(e.postscripts.sup,n,u),l,y,E]:h=[r,l,y,E],new _("mmultiscripts",h)}}),N({type:"not",names:["\\not"],props:{numArgs:1,primitive:!0,allowedInText:!1},handler({parser:e},n){let r=v(n[0]),l;return r?(l=pe(n[0]),l[0].text.charAt(0)==="\\"&&(l[0].text=Y.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?rt(e.body,n,!0)[0]:Je(e.body,n)}});let rr=["textord","mathord","atom"],jr=["\\smallint"],sr=["textord","mathord","ordgroup","close","leftright","font"],Ar=e=>{e.attributes.lspace="0.1667em",e.attributes.rspace="0.1667em"},mr=(e,n)=>{let r;if(e.symbol)r=new _("mo",[Xe(e.name,e.mode)]),jr.includes(e.name)?r.setAttribute("largeop","false"):r.setAttribute("movablelimits","false"),e.fromMathOp&&Ar(r);else if(e.body)r=new _("mo",rt(e.body,n)),e.fromMathOp&&Ar(r);else if(r=new _("mi",[new je(e.name.slice(1))]),!e.parentIsSupSub){let l=[r,new _("mo",[Xe("\u2061","text")])];if(e.needsLeadingSpace){let u=new _("mspace");u.setAttribute("width","0.1667em"),l.unshift(u)}if(!e.isFollowedByDelimiter){let u=new _("mspace");u.setAttribute("width","0.1667em"),l.push(u)}r=new _("mrow",l)}return r},ds={"\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"};N({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=ds[l]),{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:!0,stack:!1,name:l}},mathmlBuilder:mr}),N({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&&rr.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:pe(r)}},mathmlBuilder:mr});let js={"\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"};N({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:hn(l),needsLeadingSpace:r.length>0&&sr.includes(r),name:n}},mathmlBuilder:mr}),N({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:hn(l),needsLeadingSpace:r.length>0&&sr.includes(r),name:n}},mathmlBuilder:mr}),N({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=js[r]),{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!0,stack:!1,name:r}},mathmlBuilder:mr}),N({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:pe(l),alwaysHandleSupSub:n==="\\operatornamewithlimits",limits:!1,parentIsSupSub:!1,isFollowedByDelimiter:hn(h),needsLeadingSpace:u.length>0&&sr.includes(u)}},mathmlBuilder:(e,n)=>{let r,l=rt(e.body,n.withFont("mathrm")),u=!0;for(let h=0;h<l.length;h++){let y=l[h];if(y instanceof _)switch(((y.type==="mrow"||y.type==="mpadded")&&y.children.length===1&&y.children[0]instanceof _||y.type==="mrow"&&y.children.length===2&&y.children[0]instanceof _&&y.children[1]instanceof _&&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 E=y.attributes.width.replace("em",""),U=nr(Number(E));U===""?u=!1:l[h]=new _("mtext",[new je(U)])}break;case"mo":{let E=y.children[0];y.children.length===1&&E instanceof je?E.text=E.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 je(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 _("mrow",l);{let h=new _("mo",[Xe("\u2061","text")]);return bt([l[0],h])}}if(u?(r=new _("mi",l),l[0].text.length===1&&r.setAttribute("mathvariant","normal")):r=new _("mrow",l),!e.parentIsSupSub){let h=[r,new _("mo",[Xe("\u2061","text")])];if(e.needsLeadingSpace){let y=new _("mspace");y.setAttribute("width","0.1667em"),h.unshift(y)}if(!e.isFollowedByDelimiter){let y=new _("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)=>Je(e.body,n,e.semisimple)}),N({type:"phantom",names:["\\phantom"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},n)=>{let r=n[0];return{type:"phantom",mode:e.mode,body:pe(r)}},mathmlBuilder:(e,n)=>{let r=rt(e.body,n);return new _("mphantom",r)}}),N({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=rt(pe(e.body),n),l=new _("mphantom",r),u=new _("mpadded",[l]);return u.setAttribute("height","0px"),u.setAttribute("depth","0px"),u}}),N({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=rt(pe(e.body),n),l=new _("mphantom",r),u=new _("mpadded",[l]);return u.setAttribute("width","0.1px"),u}}),N({type:"pmb",names:["\\pmb"],props:{numArgs:1,allowedInText:!0},handler:({parser:e},n)=>({type:"pmb",mode:e.mode,body:pe(n[0])}),mathmlBuilder(e,n){let r=rt(e.body,n),l=gt(r);return l.setAttribute("style","font-weight:bold"),l}});let Gr=(e,n)=>{let r=n.withLevel(Mt),l=new _("mpadded",[tt(e.body,r)]),u=Kt(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};N({type:"raise",names:["\\raise","\\lower"],props:{numArgs:2,argTypes:["size","primitive"],primitive:!0},handler({parser:e,funcName:n},r){let l=Ne(r[0],"size").value;n==="\\lower"&&(l.number*=-1);let u=r[1];return{type:"raise",mode:e.mode,dy:l,body:u}},mathmlBuilder:Gr}),N({type:"raise",names:["\\raisebox"],props:{numArgs:2,argTypes:["size","hbox"],allowedInText:!0},handler({parser:e,funcName:n},r){let l=Ne(r[0],"size").value,u=r[1];return{type:"raise",mode:e.mode,dy:l,body:u}},mathmlBuilder:Gr}),N({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(mn,"")}),mathmlBuilder(e,n){let r=e.funcName==="\\ref"?["tml-ref"]:["tml-ref","tml-eqref"];return new _e("#"+e.string,r,null)}}),N({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=tt(e.body,n);return r.style.transform="scaleX(-1)",r}}),N({type:"internal",names:["\\relax"],props:{numArgs:0,allowedInText:!0,allowedInArgument:!0},handler:({parser:e})=>({type:"internal",mode:e.mode})}),N({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=Ne(n[0],"size"),h=Ne(n[1],"size");return{type:"rule",mode:e.mode,shift:l&&Ne(l,"size").value,width:u.value,height:h.value}},mathmlBuilder(e,n){let r=Kt(e.width,n),l=Kt(e.height,n),u=e.shift?Kt(e.shift,n):{number:0,unit:"em"},h=n.color&&n.getColor()||"black",y=new _("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 E=new _("mpadded",[y]);return u.number>=0?E.setAttribute("height","+"+u.number+u.unit):(E.setAttribute("height",u.number+u.unit),E.setAttribute("depth","+"+-u.number+u.unit)),E.setAttribute("voffset",u.number+u.unit),E}});let us=/^[0-9]$/,Kr={0:"\u2080",1:"\u2081",2:"\u2082",3:"\u2083",4:"\u2084",5:"\u2085",6:"\u2086",7:"\u2087",8:"\u2088",9:"\u2089"},Gs={0:"\u2070",1:"\xB9",2:"\xB2",3:"\xB3",4:"\u2074",5:"\u2075",6:"\u2076",7:"\u2077",8:"\u2078",9:"\u2079"};N({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"||!us.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"||!us.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=>Gs[h]).join(""),l=e.denominator.split("").map(h=>Kr[h]).join(""),u=new je(r+"\u2044"+l,e.mode,n);return new _("mn",[u],["special-fraction"])}});let Vn={"\\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};N({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(Vn[e.funcName]),l=rt(e.body,r),u=gt(l),h=(Vn[e.funcName]/n.fontSize).toFixed(4);return u.setAttribute("mathsize",h+"em"),u}}),N({type:"smash",names:["\\smash"],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0},handler:({parser:e},n,r)=>{let l=!1,u=!1,h=r[0]&&Ne(r[0],"ordgroup");if(h){let E="";for(let U=0;U<h.body.length;++U)if(E=h.body[U].text,E==="t")l=!0;else{if(E!=="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 _("mpadded",[tt(e.body,n)]);return e.smashHeight&&r.setAttribute("height","0px"),e.smashDepth&&r.setAttribute("depth","0px"),r}});let ps=["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"];N({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&&ps.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 _("mroot",[tt(r,n),tt(l,n.incrementLevel())]):new _("msqrt",[tt(r,n)])}});let hs={display:0,text:1,script:2,scriptscript:3},fr={display:["0","true"],text:["0","false"],script:["1","false"],scriptscript:["2","false"]};N({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(hs[e.scriptLevel]),l=rt(e.body,r),u=gt(l),h=fr[e.scriptLevel];return u.setAttribute("scriptlevel",h[0]),u.setAttribute("displaystyle",h[1]),u}});let b=/^m(over|under|underover)$/;I({type:"supsub",mathmlBuilder(e,n){let r,l,u=!1,h=!1,y=!1,E=!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,E=e.base.needsLeadingSpace);let U=e.stack&&e.base.body.length===1?[tt(e.base.body[0],n)]:[tt(e.base,n)],V=n.inSubOrSup();if(e.sub){let de=tt(e.sub,V);n.level===3&&de.setAttribute("scriptlevel","2"),U.push(de)}if(e.sup){let de=tt(e.sup,V);if(n.level===3&&de.setAttribute("scriptlevel","2"),e.base&&e.base.text&&e.base.text.length===1){let kt=e.base.text;"DHKLUcegorsuvxyz\u03A0\u03A5\u03A8\u03B1\u03B4\u03B7\u03B9\u03BC\u03BD\u03BF\u03C4\u03C5\u03C7\u03F5".indexOf(kt)>-1?de.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(kt)>-1?de.classes.push("tml-med-pad"):"AJdf\u0394\u039B".indexOf(kt)>-1&&de.classes.push("tml-lrg-pad")}U.push(de)}let be;if(u)be=r?"mover":"munder";else if(e.sub)if(e.sup){let de=e.base;be=de&&(de.type==="op"&&de.limits||de.type==="multiscript")&&(n.level===wt||de.alwaysHandleSupSub)||de&&de.type==="operatorname"&&de.alwaysHandleSupSub&&(n.level===wt||de.limits)?"munderover":"msubsup"}else{let de=e.base;be=e.stack||de&&de.type==="op"&&de.limits&&(n.level===wt||de.alwaysHandleSupSub)||de&&de.type==="operatorname"&&de.alwaysHandleSupSub&&(de.limits||n.level===wt)?"munder":"msub"}else{let de=e.base;be=de&&de.type==="op"&&de.limits&&(n.level===wt||de.alwaysHandleSupSub)||de&&de.type==="operatorname"&&de.alwaysHandleSupSub&&(de.limits||n.level===wt)?"mover":"msup"}let Te=new _(be,U);if(h){let de=new _("mo",[Xe("\u2061","text")]);if(E){let kt=new _("mspace");kt.setAttribute("width","0.1667em"),Te=bt([kt,Te,de])}else Te=bt([Te,de]);if(y){let kt=new _("mspace");kt.setAttribute("width","0.1667em"),Te.children.push(kt)}}else b.test(be)&&(Te=new _("mrow",[Te]));return Te}});let $=["\\shortmid","\\nshortmid","\\shortparallel","\\nshortparallel","\\smallsetminus"],R=["\\Rsh","\\Lsh","\\restriction"];I({type:"atom",mathmlBuilder(e,n){let r=new _("mo",[Xe(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||R.includes(l)})(e.text))r.setAttribute("stretchy","false");else if($.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 _("mrow",[_t(.222),r,_t(.222)]):new _("mrow",[_t(.2778),r,_t(.2778)]);return r}});let G={mathbf:"bold",mathrm:"normal",textit:"italic",mathit:"italic",mathnormal:"italic",mathbb:"double-struck",mathcal:"script",mathfrak:"fraktur",mathscr:"script",mathsf:"sans-serif",mathtt:"monospace"},Z=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 Y[l][u]&&Y[l][u].replace&&(u=Y[l][u].replace),Object.prototype.hasOwnProperty.call(G,r)?G[r]:null},xe=/^\d(?:[\d,.]*\d)?$/,F=/[A-Ba-z]/,ae=new Set(["\\prime","\\dprime","\\trprime","\\qprime","\\backprime","\\backdprime","\\backtrprime"]);I({type:"mathord",mathmlBuilder(e,n){let r=Xe(e.text,e.mode,n),l=r.text.codePointAt(0),u=912<l&&l<938?"normal":"italic",h=Z(e,n)||u;if(h==="script")return r.text=Mn(r.text,h),new _("mi",[r],[n.font]);h!=="italic"&&(r.text=Mn(r.text,h));let y=new _("mi",[r]);if(h==="normal"&&(y.setAttribute("mathvariant","normal"),r.text.length===1)){let E=new _("mspace",[]);y=new _("mrow",[y,E])}return y}}),I({type:"textord",mathmlBuilder(e,n){let r=e.text,l=r.codePointAt(0);n.fontFamily==="textsc"&&96<l&&l<123&&(r=ls[r]);let u=Xe(r,e.mode,n),h=Z(e,n)||"normal",y;if(xe.test(e.text)){let E=e.mode==="text"?"mtext":"mn";if(h==="italic"||h==="bold-italic")return((U,V,be)=>{let Te=new _(be,[U]),de=new _("mstyle",[Te]);return de.style["font-style"]="italic",de.style["font-family"]="Cambria, 'Times New Roman', serif",V==="bold-italic"&&(de.style["font-weight"]="bold"),de})(u,h,E);h!=="normal"&&(u.text=u.text.split("").map(U=>Mn(U,h)).join("")),y=new _(E,[u])}else if(e.mode==="text")h!=="normal"&&(u.text=Mn(u.text,h)),y=new _("mtext",[u]);else if(ae.has(e.text))y=new _("mo",[u]),y.classes.push("tml-prime");else{let E=u.text;h!=="italic"&&(u.text=Mn(u.text,h)),y=new _("mi",[u]),u.text===E&&F.test(E)&&y.setAttribute("mathvariant","italic")}return y}});let Ye={"\\nobreak":"nobreak","\\allowbreak":"allowbreak"},ot={" ":{},"\\ ":{},"~":{className:"nobreak"},"\\space":{},"\\nobreakspace":{className:"nobreak"}};I({type:"spacing",mathmlBuilder(e,n){let r;if(Object.prototype.hasOwnProperty.call(ot,e.text))r=new _("mtext",[new je("\xA0")]);else{if(!Object.prototype.hasOwnProperty.call(Ye,e.text))throw new t(`Unknown type of space "${e.text}"`);r=new _("mo"),e.text==="\\nobreak"&&r.setAttribute("linebreak","nobreak")}return r}}),I({type:"tag"});let De={"\\text":void 0,"\\textrm":"textrm","\\textsf":"textsf","\\texttt":"texttt","\\textnormal":"textrm","\\textsc":"textsc"},lt={"\\textbf":"textbf","\\textmd":"textmd"},It={"\\textit":"textit","\\textup":"textup"};N({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:pe(l),font:n}},mathmlBuilder(e,n){let r=((u,h)=>{let y=u.font;return y?De[y]?h.withTextFontFamily(De[y]):lt[y]?h.withTextFontWeight(lt[y]):y==="\\emph"?h.fontShape==="textit"?h.withTextFontShape("textup"):h.withTextFontShape("textit"):h.withTextFontShape(It[y]):h})(e,n),l=Je(e.body,r);return ft(l)}}),N({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 _("mtd",[tt(e.body,n)]);r.style.padding="0";let l=new _("mtr",[r]);return new _("mtable",[l])}}),N({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 je(Lt(e)),l=new _("mtext",[r]);return l.setAttribute("mathvariant","monospace"),l}});let Lt=e=>e.body.replace(/ /g,e.star?"\u2423":"\xA0"),Dt=T,yt=`[ \r
|
|
93
|
-
]`,
|
|
91
|
+
}`),jt=(r,o)=>{let i="";if(r==="HTML"){if(!_r.test(o))throw new e("Invalid HTML input.");i=o}else if(r==="RGB"){if(!cr.test(o))throw new e("Invalid RGB input.");o.split(",").map(u=>{i+=Jt(Number(u.trim()))})}else{if(!cn.test(o))throw new e("Invalid rbg input.");o.split(",").map(u=>{let p=Number(u.trim());if(p>1)throw new e("Color rgb input must be < 1.");i+=Jt(Number((255*p).toFixed(0)))})}return i.charAt(0)!=="#"&&(i="#"+i),i},En=(r,o,i)=>{let u=`\\\\color@${r}`;if(!ln.exec(r))throw new e("Invalid color: '"+r+"'",i);return Ot.test(r)?"#"+r:(r.charAt(0)==="#"||(o.has(u)?r=o.get(u).tokens[0].text:Fn[r]&&(r=Fn[r])),r)},qn=(r,o)=>{let i=Y(r.body,o.withColor(r.color));return i.length===0&&i.push(new I("mrow")),i=i.map(u=>(u.style.color=r.color,u)),ie(i)};E({type:"color",names:["\\textcolor"],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw","original"]},handler({parser:r,token:o},i,u){let p=u[0]&&Nt(u[0],"raw").string,v="";if(p){let R=Nt(i[0],"raw").string;v=jt(p,R)}else v=En(Nt(i[0],"raw").string,r.gullet.macros,o);let C=i[1];return{type:"color",mode:r.mode,color:v,isTextColor:!0,body:j(C)}},mathmlBuilder:qn}),E({type:"color",names:["\\color"],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw"]},handler({parser:r,breakOnTokenText:o,token:i},u,p){let v=p[0]&&Nt(p[0],"raw").string,C="";if(v){let ge=Nt(u[0],"raw").string;C=jt(v,ge)}else C=En(Nt(u[0],"raw").string,r.gullet.macros,i);let R=r.parseExpression(!0,o,!0);return{type:"color",mode:r.mode,color:C,isTextColor:!1,body:R}},mathmlBuilder:qn}),E({type:"color",names:["\\definecolor"],props:{numArgs:3,allowedInText:!0,argTypes:["raw","raw","raw"]},handler({parser:r,funcName:o,token:i},u){let p=Nt(u[0],"raw").string;if(!/^[A-Za-z]+$/.test(p))throw new e("Color name must be latin letters.",i);let v=Nt(u[1],"raw").string;if(!["HTML","RGB","rgb"].includes(v))throw new e("Color model must be HTML, RGB, or rgb.",i);let C=Nt(u[2],"raw").string,R=jt(v,C);return r.gullet.macros.set(`\\\\color@${p}`,{tokens:[{text:R}],numArgs:0}),{type:"internal",mode:r.mode}}}),E({type:"cr",names:["\\\\"],props:{numArgs:0,numOptionalArgs:0,allowedInText:!0},handler({parser:r},o,i){let u=r.gullet.future().text==="["?r.parseSizeGroup(!0):null,p=!r.settings.displayMode;return{type:"cr",mode:r.mode,newLine:p,size:u&&Nt(u,"size").value}},mathmlBuilder(r,o){let i=new I("mo");if(r.newLine&&(i.setAttribute("linebreak","newline"),r.size)){let u=Wt(r.size,o);i.setAttribute("height",u.number+u.unit)}return i}});let dr={"\\global":"\\global","\\long":"\\\\globallong","\\\\globallong":"\\\\globallong","\\def":"\\gdef","\\gdef":"\\gdef","\\edef":"\\xdef","\\xdef":"\\xdef","\\let":"\\\\globallet","\\futurelet":"\\\\globalfuture"},rn=r=>{let o=r.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(o))throw new e("Expected a control sequence",r);return o},jn=(r,o,i,u)=>{let p=r.gullet.macros.get(i.text);p==null&&(i.noexpand=!0,p={tokens:[i],numArgs:0,unexpandable:!r.gullet.isExpandable(i.text)}),r.gullet.macros.set(o,p,u)};E({type:"internal",names:["\\global","\\long","\\\\globallong"],props:{numArgs:0,allowedInText:!0},handler({parser:r,funcName:o}){r.consumeSpaces();let i=r.fetch();if(dr[i.text])return o!=="\\global"&&o!=="\\\\globallong"||(i.text=dr[i.text]),Nt(r.parseFunction(),"internal");throw new e("Invalid token after macro prefix",i)}}),E({type:"internal",names:["\\def","\\gdef","\\edef","\\xdef"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:r,funcName:o}){let i=r.gullet.popToken(),u=i.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(u))throw new e("Expected a control sequence",i);let p,v=0,C=[[]];for(;r.gullet.future().text!=="{";)if(i=r.gullet.popToken(),i.text==="#"){if(r.gullet.future().text==="{"){p=r.gullet.future(),C[v].push("{");break}if(i=r.gullet.popToken(),!/^[1-9]$/.test(i.text))throw new e(`Invalid argument number "${i.text}"`);if(parseInt(i.text)!==v+1)throw new e(`Argument number "${i.text}" out of order`);v++,C.push([])}else{if(i.text==="EOF")throw new e("Expected a macro definition");C[v].push(i.text)}let{tokens:R}=r.gullet.consumeArg();if(p&&R.unshift(p),o==="\\edef"||o==="\\xdef"){if(R=r.gullet.expandTokens(R),R.length>r.gullet.settings.maxExpand)throw new e("Too many expansions in an "+o);R.reverse()}return r.gullet.macros.set(u,{tokens:R,numArgs:v,delimiters:C},o===dr[o]),{type:"internal",mode:r.mode}}}),E({type:"internal",names:["\\let","\\\\globallet"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:r,funcName:o}){let i=rn(r.gullet.popToken());r.gullet.consumeSpaces();let u=(p=>{let v=p.gullet.popToken();return v.text==="="&&(v=p.gullet.popToken(),v.text===" "&&(v=p.gullet.popToken())),v})(r);return jn(r,i,u,o==="\\\\globallet"),{type:"internal",mode:r.mode}}}),E({type:"internal",names:["\\futurelet","\\\\globalfuture"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:r,funcName:o}){let i=rn(r.gullet.popToken()),u=r.gullet.popToken(),p=r.gullet.popToken();return jn(r,i,p,o==="\\\\globalfuture"),r.gullet.pushToken(p),r.gullet.pushToken(u),{type:"internal",mode:r.mode}}}),E({type:"internal",names:["\\newcommand","\\renewcommand","\\providecommand"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:r,funcName:o}){let i="",u=r.gullet.popToken();u.text==="{"?(i=rn(r.gullet.popToken()),r.gullet.popToken()):i=rn(u);let p=r.gullet.isDefined(i);if(p&&o==="\\newcommand")throw new e(`\\newcommand{${i}} attempting to redefine ${i}; use \\renewcommand`);if(!p&&o==="\\renewcommand")throw new e(`\\renewcommand{${i}} when command ${i} does not yet exist; use \\newcommand`);let v=0;if(r.gullet.future().text==="["){let R=r.gullet.popToken();if(R=r.gullet.popToken(),!/^[0-9]$/.test(R.text))throw new e(`Invalid number of arguments: "${R.text}"`);if(v=parseInt(R.text),R=r.gullet.popToken(),R.text!=="]")throw new e(`Invalid argument "${R.text}"`)}let{tokens:C}=r.gullet.consumeArg();return o==="\\providecommand"&&r.gullet.macros.has(i)||r.gullet.macros.set(i,{tokens:C,numArgs:v}),{type:"internal",mode:r.mode}}});let Kn={"\\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}},$r={"(":")","\\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"},vr=new Set(Object.keys($r));new Set(Object.values($r));let es=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","."]),ur=new Set(["}","\\left","\\middle","\\right"]),rr=r=>r.length>0&&(es.has(r)||Kn[r]||ur.has(r)),Br=[0,1.2,1.8,2.4,3];function pn(r,o){r.type==="ordgroup"&&r.body.length===1&&(r=r.body[0]);let i=ar(r);if(i&&es.has(i.text))return i.text!=="<"&&i.text!=="\\lt"||(i.text="\u27E8"),i.text!==">"&&i.text!=="\\gt"||(i.text="\u27E9"),i;throw new e(i?`Invalid delimiter '${i.text}' after '${o.funcName}'`:`Invalid delimiter type '${r.type}'`,r)}let Fr=new Set(["/","\\","\\backslash","\u2216","\\vert","|"]),Or=(r,o,i,u)=>{let p=new I("mo",[Ze(r==="."?"":r,o)]);return p.setAttribute("fence","true"),p.setAttribute("form",i),p.setAttribute("stretchy",u?"true":"false"),p};function Sr(r){if(!r.body)throw new Error("Bug: The delim ParseNode wasn't fully parsed.")}E({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:(r,o)=>{let i=pn(o[0],r),u={type:"delimsizing",mode:r.parser.mode,size:Kn[r.funcName].size,mclass:Kn[r.funcName].mclass,delim:i.text},p=r.parser.fetch().text;return p!=="^"&&p!=="_"?u:{type:"ordgroup",mode:"math",body:[u,{type:"ordgroup",mode:"math",body:[]}]}},mathmlBuilder:r=>{let o=[],i=r.delim==="."?"":r.delim;o.push(Ze(i,r.mode));let u=new I("mo",o);return r.mclass==="mopen"||r.mclass==="mclose"?u.setAttribute("fence","true"):u.setAttribute("fence","false"),(Fr.has(i)||i.indexOf("arrow")>-1)&&u.setAttribute("stretchy","true"),u.setAttribute("symmetric","true"),u.setAttribute("minsize",Br[r.size]+"em"),u.setAttribute("maxsize",Br[r.size]+"em"),u}}),E({type:"leftright-right",names:["\\right"],props:{numArgs:1,argTypes:["primitive"]},handler:(r,o)=>({type:"leftright-right",mode:r.parser.mode,delim:pn(o[0],r).text})}),E({type:"leftright",names:["\\left"],props:{numArgs:1,argTypes:["primitive"]},handler:(r,o)=>{let i=pn(o[0],r),u=r.parser;++u.leftrightDepth;let p=u.parseExpression(!1,"\\right",!0),v=u.fetch();for(;v.text==="\\middle";){u.consume();let R=u.fetch().text;if(!Te.math[R])throw new e(`Invalid delimiter '${R}' after '\\middle'`);pn({type:"atom",mode:"math",text:R},{funcName:"\\middle"}),p.push({type:"middle",mode:"math",delim:R}),u.consume(),p=p.concat(u.parseExpression(!1,"\\right",!0)),v=u.fetch()}--u.leftrightDepth,u.expect("\\right",!1);let C=Nt(u.parseFunction(),"leftright-right");return{type:"leftright",mode:u.mode,body:p,left:i.text,right:C.delim,isStretchy:!0}},mathmlBuilder:(r,o)=>{Sr(r);let i=Y(r.body,o),u=Or(r.left,r.mode,"prefix",!0);i.unshift(u);let p=Or(r.right,r.mode,"postfix",!0);if(r.body.length>0){let v=r.body[r.body.length-1];v.type!=="color"||v.isTextColor||p.setAttribute("mathcolor",v.color)}return i.push(p),ke(i)}}),E({type:"delimiter",names:Array.from(vr),props:{numArgs:0,allowedInText:!0,allowedInMath:!0,allowedInArgument:!0},handler:({parser:r,funcName:o,token:i})=>{if(r.mode==="text")return{type:"textord",mode:"text",text:o,loc:i.loc};if(!r.settings.wrapDelimiterPairs)return{type:"atom",mode:"math",family:"open",loc:i.loc,text:o};let u=$r[o],p=r.parseExpression(!1,u,!1);if(r.fetch().text!==u)throw new e("Unmatched delimiter");return r.consume(),{type:"delimiter",mode:r.mode,body:p,left:o,right:u}},mathmlBuilder:(r,o)=>{Sr(r);let i=Y(r.body,o),u=Or(r.left,r.mode,"prefix",!1);i.unshift(u);let p=Or(r.right,r.mode,"postfix",!1);if(r.body.length>0){let v=r.body[r.body.length-1];v.type!=="color"||v.isTextColor||p.setAttribute("mathcolor",v.color)}return i.push(p),ke(i)}}),E({type:"middle",names:["\\middle"],props:{numArgs:1,argTypes:["primitive"]},handler:(r,o)=>{let i=pn(o[0],r);if(!r.parser.leftrightDepth)throw new e("\\middle without preceding \\left",i);return{type:"middle",mode:r.parser.mode,delim:i.text}},mathmlBuilder:r=>{let o=Ze(r.delim,r.mode),i=new I("mo",[o]);return i.setAttribute("stretchy","true"),i.setAttribute("form","infix"),o.text!=="/"&&(i.setAttribute("lspace","0.05em"),i.setAttribute("rspace","0.05em")),i}});let gn=["\\boxed","\\fcolorbox","\\colorbox"],bn=(r,o)=>{let i=gn.includes(r.label)?"mrow":"menclose",u=new I(i,[Ne(r.body,o)]);switch(r.label){case"\\overline":u.setAttribute("notation","top"),u.classes.push("tml-overline");break;case"\\underline":u.setAttribute("notation","bottom"),u.classes.push("tml-underline");break;case"\\cancel":u.setAttribute("notation","updiagonalstrike"),u.children.push(new I("mrow",[],["tml-cancel","upstrike"]));break;case"\\bcancel":u.setAttribute("notation","downdiagonalstrike"),u.children.push(new I("mrow",[],["tml-cancel","downstrike"]));break;case"\\sout":u.setAttribute("notation","horizontalstrike"),u.children.push(new I("mrow",[],["tml-cancel","sout"]));break;case"\\xcancel":u.setAttribute("notation","updiagonalstrike downdiagonalstrike"),u.children.push(new I("mrow",[],["tml-cancel","tml-xcancel"]));break;case"\\longdiv":u.setAttribute("notation","longdiv"),u.classes.push("longdiv-top"),u.children.push(new I("mrow",[],["longdiv-arc"]));break;case"\\phase":u.setAttribute("notation","phasorangle"),u.classes.push("phasor-bottom"),u.children.push(new I("mrow",[],["phasor-angle"]));break;case"\\textcircled":u.setAttribute("notation","circle"),u.classes.push("circle-pad"),u.children.push(new I("mrow",[],["textcircle"]));break;case"\\angl":u.setAttribute("notation","actuarial"),u.classes.push("actuarial");break;case"\\boxed":u.style.padding="3pt",u.style.border="1px solid",u.setAttribute("scriptlevel","0"),u.setAttribute("displaystyle","true");break;case"\\fbox":u.setAttribute("notation","box"),u.classes.push("tml-fbox");break;case"\\fcolorbox":case"\\colorbox":u.style.padding="0.3em",r.label==="\\fcolorbox"&&(u.style.border="0.0667em solid "+String(r.borderColor))}return r.backgroundColor&&u.setAttribute("mathbackground",r.backgroundColor),u};E({type:"enclose",names:["\\colorbox"],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw","text"]},handler({parser:r,funcName:o},i,u){let p=u[0]&&Nt(u[0],"raw").string,v="";if(p){let R=Nt(i[0],"raw").string;v=jt(p,R)}else v=En(Nt(i[0],"raw").string,r.gullet.macros);let C=i[1];return{type:"enclose",mode:r.mode,label:o,backgroundColor:v,body:C}},mathmlBuilder:bn}),E({type:"enclose",names:["\\fcolorbox"],props:{numArgs:3,numOptionalArgs:1,allowedInText:!0,argTypes:["raw","raw","raw","text"]},handler({parser:r,funcName:o},i,u){let p=u[0]&&Nt(u[0],"raw").string,v,C="";if(p){let ge=Nt(i[0],"raw").string,Me=Nt(i[0],"raw").string;C=jt(p,ge),v=jt(p,Me)}else C=En(Nt(i[0],"raw").string,r.gullet.macros),v=En(Nt(i[1],"raw").string,r.gullet.macros);let R=i[2];return{type:"enclose",mode:r.mode,label:o,backgroundColor:v,borderColor:C,body:R}},mathmlBuilder:bn}),E({type:"enclose",names:["\\fbox"],props:{numArgs:1,argTypes:["hbox"],allowedInText:!0},handler:({parser:r},o)=>({type:"enclose",mode:r.mode,label:"\\fbox",body:o[0]})}),E({type:"enclose",names:["\\angl","\\cancel","\\bcancel","\\xcancel","\\overline","\\boxed","\\longdiv","\\phase"],props:{numArgs:1},handler({parser:r,funcName:o},i){let u=i[0];return{type:"enclose",mode:r.mode,label:o,body:u}},mathmlBuilder:bn}),E({type:"enclose",names:["\\sout"],props:{numArgs:1,allowedInText:!0},handler({parser:r,funcName:o},i){let u=i[0];return{type:"enclose",mode:r.mode,label:o,body:u}},mathmlBuilder:bn}),E({type:"enclose",names:["\\underline"],props:{numArgs:1,allowedInText:!0},handler({parser:r,funcName:o},i){let u=i[0];return{type:"enclose",mode:r.mode,label:o,body:u}},mathmlBuilder:bn}),E({type:"enclose",names:["\\textcircled"],props:{numArgs:1,argTypes:["text"],allowedInArgument:!0,allowedInText:!0},handler({parser:r,funcName:o},i){let u=i[0];return{type:"enclose",mode:r.mode,label:o,body:u}},mathmlBuilder:bn}),E({type:"environment",names:["\\begin","\\end"],props:{numArgs:1,argTypes:["text"]},handler({parser:r,funcName:o},i){let u=i[0];if(u.type!=="ordgroup")throw new e("Invalid environment name",u);let p="";for(let v=0;v<u.body.length;++v)p+=Nt(u.body[v],"textord").text;if(o==="\\begin"){if(!Object.prototype.hasOwnProperty.call(Gn,p))throw new e("No such environment: "+p,u);let v=Gn[p],{args:C,optArgs:R}=r.parseArguments("\\begin{"+p+"}",v),ge={mode:r.mode,envName:p,parser:r},Me=v.handler(ge,C,R);r.expect("\\end",!1);let We=r.nextToken,rt=Nt(r.parseFunction(),"environment");if(rt.name!==p)throw new e(`Mismatch: \\begin{${p}} matched by \\end{${rt.name}}`,We);return Me}return{type:"environment",mode:r.mode,name:p,nameGroup:u}}}),E({type:"envTag",names:["\\env@tag"],props:{numArgs:1,argTypes:["math"]},handler:({parser:r},o)=>({type:"envTag",mode:r.mode,body:o[0]}),mathmlBuilder:(r,o)=>new I("mrow")}),E({type:"noTag",names:["\\env@notag"],props:{numArgs:0},handler:({parser:r})=>({type:"noTag",mode:r.mode}),mathmlBuilder:(r,o)=>new I("mrow")});let pr=Object.freeze({B:8426,E:8427,F:8427,H:8387,I:8391,L:8390,M:8422,R:8393,e:8394,g:8355,o:8389}),Lr=Object.freeze({C:8426,H:8388,I:8392,R:8394,Z:8398}),Pn=Object.freeze({C:8383,H:8389,N:8391,P:8393,Q:8393,R:8395,Z:8394}),ts=Object.freeze({"\u03F5":119527,\u03D1:119564,\u03F0:119534,\u03C6:119577,\u03F1:119535,\u03D6:119563}),or=Object.freeze({"\u03F5":119643,\u03D1:119680,\u03F0:119650,\u03C6:119693,\u03F1:119651,\u03D6:119679}),qr=Object.freeze({"\u03F5":119701,\u03D1:119738,\u03F0:119708,\u03C6:119751,\u03F1:119709,\u03D6:119737}),Wr=Object.freeze({"\u03F5":119759,\u03D1:119796,\u03F0:119766,\u03C6:119809,\u03F1:119767,\u03D6:119795}),Mr=Object.freeze({upperCaseLatin:{normal:r=>0,bold:r=>119743,italic:r=>119795,"bold-italic":r=>119847,script:r=>pr[r]||119899,"script-bold":r=>119951,fraktur:r=>Lr[r]||120003,"fraktur-bold":r=>120107,"double-struck":r=>Pn[r]||120055,"sans-serif":r=>120159,"sans-serif-bold":r=>120211,"sans-serif-italic":r=>120263,"sans-serif-bold-italic":r=>120380,monospace:r=>120367},lowerCaseLatin:{normal:r=>0,bold:r=>119737,italic:r=>r==="h"?8358:119789,"bold-italic":r=>119841,script:r=>pr[r]||119893,"script-bold":r=>119945,fraktur:r=>119997,"fraktur-bold":r=>120101,"double-struck":r=>120049,"sans-serif":r=>120153,"sans-serif-bold":r=>120205,"sans-serif-italic":r=>120257,"sans-serif-bold-italic":r=>120309,monospace:r=>120361},upperCaseGreek:{normal:r=>0,bold:r=>119575,italic:r=>119633,"bold-italic":r=>119575,script:r=>0,"script-bold":r=>0,fraktur:r=>0,"fraktur-bold":r=>0,"double-struck":r=>0,"sans-serif":r=>119749,"sans-serif-bold":r=>119749,"sans-serif-italic":r=>0,"sans-serif-bold-italic":r=>119807,monospace:r=>0},lowerCaseGreek:{normal:r=>0,bold:r=>119569,italic:r=>119627,"bold-italic":r=>r==="\u03D5"?119678:119685,script:r=>0,"script-bold":r=>0,fraktur:r=>0,"fraktur-bold":r=>0,"double-struck":r=>0,"sans-serif":r=>119743,"sans-serif-bold":r=>119743,"sans-serif-italic":r=>0,"sans-serif-bold-italic":r=>119801,monospace:r=>0},varGreek:{normal:r=>0,bold:r=>ts[r]||-51,italic:r=>0,"bold-italic":r=>or[r]||58,script:r=>0,"script-bold":r=>0,fraktur:r=>0,"fraktur-bold":r=>0,"double-struck":r=>0,"sans-serif":r=>qr[r]||116,"sans-serif-bold":r=>qr[r]||116,"sans-serif-italic":r=>0,"sans-serif-bold-italic":r=>Wr[r]||174,monospace:r=>0},numeral:{normal:r=>0,bold:r=>120734,italic:r=>0,"bold-italic":r=>0,script:r=>0,"script-bold":r=>0,fraktur:r=>0,"fraktur-bold":r=>0,"double-struck":r=>120744,"sans-serif":r=>120754,"sans-serif-bold":r=>120764,"sans-serif-italic":r=>0,"sans-serif-bold-italic":r=>0,monospace:r=>120774}}),hr=(r,o)=>{let i=r.codePointAt(0),u=64<i&&i<91?"upperCaseLatin":96<i&&i<123?"lowerCaseLatin":912<i&&i<938?"upperCaseGreek":944<i&&i<970||r==="\u03D5"?"lowerCaseGreek":120545<i&&i<120572||ts[r]?"varGreek":47<i&&i<58?"numeral":"other";return u==="other"?r:String.fromCodePoint(i+Mr[u][o](r))},ps=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"}),ns=["mathrm","mathit"],rs=(r,o)=>{let i=r.font,u=o.withFont(i),p=Ne(r.body,u);if(p.children.length===0)return p;if(i==="boldsymbol"&&["mo","mpadded","mrow"].includes(p.type))return p.style.fontWeight="bold",p;if(((R,ge)=>{if(!ns.includes(ge)||!R.body||R.body.type!=="ordgroup"||R.body.body.length===1||R.body.body[0].type!=="mathord")return!1;for(let Me=1;Me<R.body.body.length;Me++){let We=R.body.body[Me].type;if(We!=="mathord"&&(We!=="textord"||isNaN(R.body.body[Me].text)))return!1}return!0})(r,i)){let R=p.children[0].children[0].children?p.children[0].children[0]:p.children[0];delete R.attributes.mathvariant;for(let Me=1;Me<p.children.length;Me++)R.children[0].text+=p.children[Me].children[0].children?p.children[Me].children[0].children[0].text:p.children[Me].children[0].text;if(i==="mathit")return R.children[0].text=R.children[0].text.split("").map(Me=>hr(Me,"italic")).join(""),R;let ge=new I("mpadded",[R]);return ge.setAttribute("lspace","0"),ge}let v=p.children[0].type==="mo";for(let R=1;R<p.children.length;R++)p.children[R].type==="mo"&&i==="boldsymbol"&&(p.children[R].style.fontWeight="bold"),p.children[R].type!=="mi"&&(v=!1),(p.children[R].attributes&&p.children[R].attributes.mathvariant||"")!=="normal"&&(v=!1);if(!v)return p;let C=p.children[0];for(let R=1;R<p.children.length;R++)C.children.push(p.children[R].children[0]);if(C.attributes.mathvariant&&C.attributes.mathvariant==="normal"){let R=new I("mtext",new ce("\u200B"));return new I("mrow",[R,C])}return C},Ht={"\\Bbb":"\\mathbb","\\bold":"\\mathbf","\\frak":"\\mathfrak","\\bm":"\\boldsymbol"};E({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:r,funcName:o},i)=>{let u=P(i[0]),p=o;return p in Ht&&(p=Ht[p]),{type:"font",mode:r.mode,font:p.slice(1),body:u}},mathmlBuilder:rs}),E({type:"font",names:["\\rm","\\sf","\\tt","\\bf","\\it","\\cal"],props:{numArgs:0,allowedInText:!0},handler:({parser:r,funcName:o,breakOnTokenText:i},u)=>{let{mode:p}=r,v=r.parseExpression(!0,i,!0);return{type:"font",mode:p,font:`math${o.slice(1)}`,body:{type:"ordgroup",mode:r.mode,body:v}}},mathmlBuilder:rs});let Ar=["display","text","script","scriptscript"],Cr={auto:-1,display:0,text:0,script:1,scriptscript:2},Hn=(r,o)=>{o=((v,C)=>{let R=C;if(v==="display"){let ge=R.level>=Tt?nn:Rn;R=R.withLevel(ge)}else v==="text"&&R.level===Rn?R=R.withLevel(nn):v==="auto"?R=R.incrementLevel():v==="script"?R=R.withLevel(Tt):v==="scriptscript"&&(R=R.withLevel(fn));return R})(r.scriptLevel,o);let i=Ne(r.numer,o),u=Ne(r.denom,o);o.level===3&&(i.style.mathDepth="2",i.setAttribute("scriptlevel","2"),u.style.mathDepth="2",u.setAttribute("scriptlevel","2"));let p=new I("mfrac",[i,u]);if(r.hasBarLine){if(r.barSize){let v=Wt(r.barSize,o);p.setAttribute("linethickness",v.number+v.unit)}}else p.setAttribute("linethickness","0px");if(r.leftDelim!=null||r.rightDelim!=null){let v=[];if(r.leftDelim!=null){let C=new I("mo",[new ce(r.leftDelim.replace("\\",""))]);C.setAttribute("fence","true"),v.push(C)}if(v.push(p),r.rightDelim!=null){let C=new I("mo",[new ce(r.rightDelim.replace("\\",""))]);C.setAttribute("fence","true"),v.push(C)}p=ke(v)}return r.scriptLevel!=="auto"&&(p=new I("mstyle",[p]),p.setAttribute("displaystyle",String(r.scriptLevel==="display")),p.setAttribute("scriptlevel",Cr[r.scriptLevel])),p};E({type:"genfrac",names:["\\cfrac","\\dfrac","\\frac","\\tfrac","\\dbinom","\\binom","\\tbinom","\\\\atopfrac","\\\\bracefrac","\\\\brackfrac"],props:{numArgs:2,allowedInArgument:!0},handler:({parser:r,funcName:o},i)=>{let u=i[0],p=i[1],v=!1,C=null,R=null,ge="auto";switch(o){case"\\cfrac":case"\\dfrac":case"\\frac":case"\\tfrac":v=!0;break;case"\\\\atopfrac":v=!1;break;case"\\dbinom":case"\\binom":case"\\tbinom":C="(",R=")";break;case"\\\\bracefrac":C="\\{",R="\\}";break;case"\\\\brackfrac":C="[",R="]";break;default:throw new Error("Unrecognized genfrac command")}return o==="\\cfrac"||o.startsWith("\\d")?ge="display":o.startsWith("\\t")&&(ge="text"),{type:"genfrac",mode:r.mode,continued:!1,numer:u,denom:p,hasBarLine:v,leftDelim:C,rightDelim:R,scriptLevel:ge,barSize:null}},mathmlBuilder:Hn}),E({type:"infix",names:["\\over","\\choose","\\atop","\\brace","\\brack"],props:{numArgs:0,infix:!0},handler({parser:r,funcName:o,token:i}){let u;switch(o){case"\\over":u="\\frac";break;case"\\choose":u="\\binom";break;case"\\atop":u="\\\\atopfrac";break;case"\\brace":u="\\\\bracefrac";break;case"\\brack":u="\\\\brackfrac";break;default:throw new Error("Unrecognized infix genfrac command")}return{type:"infix",mode:r.mode,replaceWith:u,token:i}}});let Ft=function(r){let o=null;return r.length>0&&(o=r,o=o==="."?null:o),o};E({type:"genfrac",names:["\\genfrac"],props:{numArgs:6,allowedInArgument:!0,argTypes:["math","math","size","text","math","math"]},handler({parser:r},o){let i=o[4],u=o[5],p=P(o[0]),v=p.type==="atom"&&p.family==="open"?Ft(p.text):null,C=P(o[1]),R=C.type==="atom"&&C.family==="close"?Ft(C.text):null,ge=Nt(o[2],"size"),Me,We=null;ge.isBlank?Me=!0:(We=ge.value,Me=We.number>0);let rt="auto",Je=o[3];if(Je.type==="ordgroup"){if(Je.body.length>0){let qt=Nt(Je.body[0],"textord");rt=Ar[Number(qt.text)]}}else Je=Nt(Je,"textord"),rt=Ar[Number(Je.text)];return{type:"genfrac",mode:r.mode,numer:i,denom:u,continued:!1,hasBarLine:Me,barSize:We,leftDelim:v,rightDelim:R,scriptLevel:rt}},mathmlBuilder:Hn}),E({type:"infix",names:["\\above"],props:{numArgs:1,argTypes:["size"],infix:!0},handler:({parser:r,funcName:o,token:i},u)=>({type:"infix",mode:r.mode,replaceWith:"\\\\abovefrac",barSize:Nt(u[0],"size").value,token:i})}),E({type:"genfrac",names:["\\\\abovefrac"],props:{numArgs:3,argTypes:["math","size","math"]},handler:({parser:r,funcName:o},i)=>{let u=i[0],p=function(R){if(!R)throw new Error("Expected non-null, but got "+String(R));return R}(Nt(i[1],"infix").barSize),v=i[2],C=p.number>0;return{type:"genfrac",mode:r.mode,numer:u,denom:v,continued:!1,hasBarLine:C,barSize:p,leftDelim:null,rightDelim:null,scriptLevel:"auto"}},mathmlBuilder:Hn}),E({type:"hbox",names:["\\hbox"],props:{numArgs:1,argTypes:["hbox"],allowedInArgument:!0,allowedInText:!1},handler:({parser:r},o)=>({type:"hbox",mode:r.mode,body:j(o[0])}),mathmlBuilder(r,o){let i=o.withLevel(nn),u=ve(r.body,i);return Pe(u)}}),E({type:"horizBracket",names:["\\overbrace","\\underbrace","\\overbracket","\\underbracket"],props:{numArgs:1},handler:({parser:r,funcName:o},i)=>({type:"horizBracket",mode:r.mode,label:o,isOver:/^\\over/.test(o),base:i[0]}),mathmlBuilder:(r,o)=>{let i=Z(r.label);return i.style["math-depth"]=0,new I(r.isOver?"mover":"munder",[Ne(r.base,o),i])}}),E({type:"html",names:["\\class","\\id","\\style","\\data"],props:{numArgs:2,argTypes:["raw","original"],allowedInText:!0},handler:({parser:r,funcName:o,token:i},u)=>{let p=Nt(u[0],"raw").string,v=u[1];if(r.settings.strict)throw new e(`Function "${o}" is disabled in strict mode`,i);let C,R={};switch(o){case"\\class":R.class=p,C={command:"\\class",class:p};break;case"\\id":R.id=p,C={command:"\\id",id:p};break;case"\\style":R.style=p,C={command:"\\style",style:p};break;case"\\data":{let ge=p.split(",");for(let Me=0;Me<ge.length;Me++){let We=ge[Me].split("=");if(We.length!==2)throw new e("Error parsing key-value for \\data");R["data-"+We[0].trim()]=We[1].trim()}C={command:"\\data",attributes:R};break}default:throw new Error("Unrecognized html command")}if(!r.settings.isTrusted(C))throw new e(`Function "${o}" is not trusted`,i);return{type:"html",mode:r.mode,attributes:R,body:j(v)}},mathmlBuilder:(r,o)=>{let i=ve(r.body,o),u=[];r.attributes.class&&u.push(...r.attributes.class.trim().split(/\s+/)),i.classes=u;for(let p in r.attributes)p!=="class"&&Object.prototype.hasOwnProperty.call(r.attributes,p)&&i.setAttribute(p,r.attributes[p]);return i}});let ws=function(r){if(/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(r))return{number:+r,unit:"bp"};{let o=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(r);if(!o)throw new e("Invalid size: '"+r+"' in \\includegraphics");let i={number:+(o[1]+o[2]),unit:o[3]};if(!Xt(i))throw new e("Invalid unit: '"+i.unit+"' in \\includegraphics.");return i}};E({type:"includegraphics",names:["\\includegraphics"],props:{numArgs:1,numOptionalArgs:1,argTypes:["raw","url"],allowedInText:!1},handler:({parser:r,token:o},i,u)=>{let p={number:0,unit:"em"},v={number:.9,unit:"em"},C={number:0,unit:"em"},R="";if(u[0]){let Me=Nt(u[0],"raw").string.split(",");for(let We=0;We<Me.length;We++){let rt=Me[We].split("=");if(rt.length===2){let Je=rt[1].trim();switch(rt[0].trim()){case"alt":R=Je;break;case"width":p=ws(Je);break;case"height":v=ws(Je);break;case"totalheight":C=ws(Je);break;default:throw new e("Invalid key: '"+rt[0]+"' in \\includegraphics.")}}}}let ge=Nt(i[0],"url").url;if(R===""&&(R=ge,R=R.replace(/^.*[\\/]/,""),R=R.substring(0,R.lastIndexOf("."))),!r.settings.isTrusted({command:"\\includegraphics",url:ge}))throw new e('Function "\\includegraphics" is not trusted',o);return{type:"includegraphics",mode:r.mode,alt:R,width:p,height:v,totalheight:C,src:ge}},mathmlBuilder:(r,o)=>{let i=Wt(r.height,o),u={number:0,unit:"em"};r.totalheight.number>0&&r.totalheight.unit===i.unit&&r.totalheight.number>i.number&&(u.number=r.totalheight.number-i.number,u.unit=i.unit);let p=0;r.width.number>0&&(p=Wt(r.width,o));let v={height:i.number+u.number+"em"};p.number>0&&(v.width=p.number+p.unit),u.number>0&&(v.verticalAlign=-u.number+u.unit);let C=new le(r.src,r.alt,v);return C.height=i,C.depth=u,new I("mtext",[C])}}),E({type:"kern",names:["\\kern","\\mkern","\\hskip","\\mskip"],props:{numArgs:1,argTypes:["size"],primitive:!0,allowedInText:!0},handler({parser:r,funcName:o,token:i},u){let p=Nt(u[0],"size");if(r.settings.strict){let v=o[1]==="m",C=p.value.unit==="mu";if(v){if(!C)throw new e(`LaTeX's ${o} supports only mu units, not ${p.value.unit} units`,i);if(r.mode!=="math")throw new e(`LaTeX's ${o} works only in math mode`,i)}else if(C)throw new e(`LaTeX's ${o} doesn't support mu units`,i)}return{type:"kern",mode:r.mode,dimension:p.value}},mathmlBuilder(r,o){let i=Wt(r.dimension,o),u=i.number>0&&i.unit==="em"?Vr(i.number):"";if(r.mode==="text"&&u.length>0){let p=new ce(u);return new I("mtext",[p])}if(i.number>=0){let p=new I("mspace");return p.setAttribute("width",i.number+i.unit),p}{let p=new I("mrow");return p.style.marginLeft=i.number+i.unit,p}}});let Vr=function(r){return r>=.05555&&r<=.05556?"\u200A":r>=.1666&&r<=.1667?"\u2009":r>=.2222&&r<=.2223?"\u2005":r>=.2777&&r<=.2778?"\u2005\u200A":""},ss=/[^A-Za-z_0-9-]/g;E({type:"label",names:["\\label"],props:{numArgs:1,argTypes:["raw"]},handler:({parser:r},o)=>({type:"label",mode:r.mode,string:o[0].string.replace(ss,"")}),mathmlBuilder(r,o){let i=new I("mrow",[],["tml-label"]);return r.string.length>0&&i.setLabel(r.string),i}});let Xn=["\\clap","\\llap","\\rlap"];E({type:"lap",names:["\\mathllap","\\mathrlap","\\mathclap","\\clap","\\llap","\\rlap"],props:{numArgs:1,allowedInText:!0},handler:({parser:r,funcName:o,token:i},u)=>{if(Xn.includes(o)){if(r.settings.strict&&r.mode!=="text")throw new e(`{${o}} can be used only in text mode.
|
|
92
|
+
Try \\math${o.slice(1)}`,i);o=o.slice(1)}else o=o.slice(5);let p=u[0];return{type:"lap",mode:r.mode,alignment:o,body:p}},mathmlBuilder:(r,o)=>{let i;if(r.alignment==="llap"){let v=Y(j(r.body),o),C=new I("mphantom",v);i=new I("mpadded",[C]),i.setAttribute("width","0.1px")}let u=Ne(r.body,o),p;if(r.alignment==="llap"?(u.style.position="absolute",u.style.right="0",u.style.bottom="0",p=new I("mpadded",[i,u])):p=new I("mpadded",[u]),r.alignment==="rlap")r.body.body.length>0&&r.body.body[0].type==="genfrac"&&p.setAttribute("lspace","0.16667em");else{let v=r.alignment==="llap"?"-1":"-0.5";p.setAttribute("lspace",v+"width"),r.alignment==="llap"?p.style.position="relative":(p.style.display="flex",p.style.justifyContent="center")}return p.setAttribute("width","0.1px"),p}}),E({type:"ordgroup",names:["\\(","$"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler({funcName:r,parser:o},i){let u=o.mode;o.switchMode("math");let p=r==="\\("?"\\)":"$",v=o.parseExpression(!1,p);return o.expect(p),o.switchMode(u),{type:"ordgroup",mode:o.mode,body:v}}}),E({type:"text",names:["\\)","\\]"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(r,o){throw new e(`Mismatched ${r.funcName}`,o)}}),E({type:"mathchoice",names:["\\mathchoice"],props:{numArgs:4,primitive:!0},handler:({parser:r},o)=>({type:"mathchoice",mode:r.mode,display:j(o[0]),text:j(o[1]),script:j(o[2]),scriptscript:j(o[3])}),mathmlBuilder:(r,o)=>{let i=((u,p)=>{switch(p.level){case Rn:return u.display;case nn:return u.text;case Tt:return u.script;case fn:return u.scriptscript;default:return u.text}})(r,o);return ve(i,o)}});let $n=["text","textord","mathord","atom"];function jr(r,o){let i,u=Y(r.body,o);if(r.mclass==="minner")i=new I("mpadded",u);else if(r.mclass==="mord")r.isCharacterBox||u[0].type==="mathord"?(i=u[0],i.type="mi",i.children.length===1&&i.children[0].text&&i.children[0].text==="\u2207"&&i.setAttribute("mathvariant","normal")):i=new I("mi",u);else{i=new I("mrow",u),r.mustPromote?(i=u[0],i.type="mo",r.isCharacterBox&&r.body[0].text&&/[A-Za-z]/.test(r.body[0].text)&&i.setAttribute("mathvariant","italic")):i=new I("mrow",u);let p=o.level<2;i.type==="mrow"?p&&(r.mclass==="mbin"?(i.children.unshift(St(.2222)),i.children.push(St(.2222))):r.mclass==="mrel"?(i.children.unshift(St(.2778)),i.children.push(St(.2778))):r.mclass==="mpunct"?i.children.push(St(.1667)):r.mclass==="minner"&&(i.children.unshift(St(.0556)),i.children.push(St(.0556)))):r.mclass==="mbin"?(i.attributes.lspace=p?"0.2222em":"0",i.attributes.rspace=p?"0.2222em":"0"):r.mclass==="mrel"?(i.attributes.lspace=p?"0.2778em":"0",i.attributes.rspace=p?"0.2778em":"0"):r.mclass==="mpunct"?(i.attributes.lspace="0em",i.attributes.rspace=p?"0.1667em":"0"):r.mclass==="mopen"||r.mclass==="mclose"?(i.attributes.lspace="0em",i.attributes.rspace="0em"):r.mclass==="minner"&&p&&(i.attributes.lspace="0.0556em",i.attributes.width="+0.1111em"),r.mclass!=="mopen"&&r.mclass!=="mclose"&&(delete i.attributes.stretchy,delete i.attributes.form)}return i}E({type:"mclass",names:["\\mathord","\\mathbin","\\mathrel","\\mathopen","\\mathclose","\\mathpunct","\\mathinner"],props:{numArgs:1,primitive:!0},handler({parser:r,funcName:o},i){let u=i[0],p=g(u),v=!0,C={type:"mathord",text:"",mode:r.mode},R=u.body?u.body:[u];for(let ge of R){if(!$n.includes(ge.type)){v=!1;break}Te[r.mode][ge.text]?C.text+=Te[r.mode][ge.text].replace:ge.text?C.text+=ge.text:ge.body&&ge.body.map(Me=>{C.text+=Me.text})}return v&&o==="\\mathord"&&C.type==="mathord"&&C.text.length>1?C:{type:"mclass",mode:r.mode,mclass:"m"+o.slice(5),body:j(v?C:u),isCharacterBox:p,mustPromote:v}},mathmlBuilder:jr});let Sn=r=>{let o=r.type==="ordgroup"&&r.body.length&&r.body.length===1?r.body[0]:r;if(o.type==="atom"){let i=r.body.length>0&&r.body[0].text&&Te.math[r.body[0].text]?Te.math[r.body[0].text].group:o.family;return i==="bin"||i==="rel"?"m"+i:"mord"}return"mord"};E({type:"mclass",names:["\\@binrel"],props:{numArgs:2},handler:({parser:r},o)=>({type:"mclass",mode:r.mode,mclass:Sn(o[0]),body:j(o[1]),isCharacterBox:g(o[1])})}),E({type:"mclass",names:["\\stackrel","\\overset","\\underset"],props:{numArgs:2},handler({parser:r,funcName:o},i){let u=i[1],p=i[0],v;v=o!=="\\stackrel"?Sn(u):"mrel";let C={type:v==="mrel"||v==="mbin"?"op":"ordgroup",mode:u.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:o!=="\\stackrel",body:j(u)};return{type:"supsub",mode:p.mode,stack:!0,base:C,sup:o==="\\underset"?null:p,sub:o==="\\underset"?p:null}},mathmlBuilder:jr});let Gt=(r,o,i)=>{if(!r)return i;let u=Ne(r,o);return u.type==="mrow"&&u.children.length===0?i:u};E({type:"multiscript",names:["\\sideset","\\pres@cript"],props:{numArgs:3},handler({parser:r,funcName:o,token:i},u){if(u[2].body.length===0)throw new e(o+"cannot parse an empty base.");let p=u[2].body[0];if(r.settings.strict&&o==="\\sideset"&&!p.symbol)throw new e("The base of \\sideset must be a big operator. Try \\prescript.");if(u[0].body.length>0&&u[0].body[0].type!=="supsub"||u[1].body.length>0&&u[1].body[0].type!=="supsub")throw new e("\\sideset can parse only subscripts and superscripts in its first two arguments",i);let v=u[0].body.length>0?u[0].body[0]:null,C=u[1].body.length>0?u[1].body[0]:null;return v||C?v?{type:"multiscript",mode:r.mode,isSideset:o==="\\sideset",prescripts:v,postscripts:C,base:p}:{type:"styling",mode:r.mode,scriptLevel:"text",body:[{type:"supsub",mode:r.mode,base:p,sup:C.sup,sub:C.sub}]}:p},mathmlBuilder(r,o){let i=Ne(r.base,o),u=new I("mprescripts"),p=new I("none"),v=[],C=Gt(r.prescripts.sub,o,p),R=Gt(r.prescripts.sup,o,p);return r.isSideset&&(C.setAttribute("style","text-align: left;"),R.setAttribute("style","text-align: left;")),r.postscripts?v=[i,Gt(r.postscripts.sub,o,p),Gt(r.postscripts.sup,o,p),u,C,R]:v=[i,u,C,R],new I("mmultiscripts",v)}}),E({type:"not",names:["\\not"],props:{numArgs:1,primitive:!0,allowedInText:!1},handler({parser:r},o){let i=g(o[0]),u;return i?(u=j(o[0]),u[0].text.charAt(0)==="\\"&&(u[0].text=Te.math[u[0].text].replace),u[0].text=u[0].text.slice(0,1)+"\u0338"+u[0].text.slice(1)):u=[{type:"textord",mode:"math",text:"\u0338"},{type:"kern",mode:"math",dimension:{number:-.6,unit:"em"}},o[0]],{type:"not",mode:r.mode,body:u,isCharacterBox:i}},mathmlBuilder(r,o){return r.isCharacterBox?Y(r.body,o,!0)[0]:ve(r.body,o)}});let Tn=["textord","mathord","atom"],Rr=["\\smallint"],Jr=["textord","mathord","ordgroup","close","leftright","font"],Hr=r=>{r.attributes.lspace="0.1667em",r.attributes.rspace="0.1667em"},sr=(r,o)=>{let i;if(r.symbol)i=new I("mo",[Ze(r.name,r.mode)]),Rr.includes(r.name)?i.setAttribute("largeop","false"):i.setAttribute("movablelimits","false"),r.fromMathOp&&Hr(i);else if(r.body)i=new I("mo",Y(r.body,o)),r.fromMathOp&&Hr(i);else if(i=new I("mi",[new ce(r.name.slice(1))]),!r.parentIsSupSub){let u=[i,new I("mo",[Ze("\u2061","text")])];if(r.needsLeadingSpace){let p=new I("mspace");p.setAttribute("width","0.1667em"),u.unshift(p)}if(!r.isFollowedByDelimiter){let p=new I("mspace");p.setAttribute("width","0.1667em"),u.push(p)}i=new I("mrow",u)}return i},Ps={"\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"};E({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:r,funcName:o},i)=>{let u=o;return u.length===1&&(u=Ps[u]),{type:"op",mode:r.mode,limits:!0,parentIsSupSub:!1,symbol:!0,stack:!1,name:u}},mathmlBuilder:sr}),E({type:"op",names:["\\mathop"],props:{numArgs:1,primitive:!0},handler:({parser:r},o)=>{let i=o[0],u=i.body?i.body:[i],p=u.length===1&&Tn.includes(u[0].type);return{type:"op",mode:r.mode,limits:!0,parentIsSupSub:!1,symbol:p,fromMathOp:!0,stack:!1,name:p?u[0].text:null,body:p?null:j(i)}},mathmlBuilder:sr});let os={"\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"};E({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:r,funcName:o}){let i=r.prevAtomType,u=r.gullet.future().text;return{type:"op",mode:r.mode,limits:!1,parentIsSupSub:!1,symbol:!1,stack:!1,isFollowedByDelimiter:rr(u),needsLeadingSpace:i.length>0&&Jr.includes(i),name:o}},mathmlBuilder:sr}),E({type:"op",names:["\\det","\\gcd","\\inf","\\lim","\\max","\\min","\\Pr","\\sup"],props:{numArgs:0},handler({parser:r,funcName:o}){let i=r.prevAtomType,u=r.gullet.future().text;return{type:"op",mode:r.mode,limits:!0,parentIsSupSub:!1,symbol:!1,stack:!1,isFollowedByDelimiter:rr(u),needsLeadingSpace:i.length>0&&Jr.includes(i),name:o}},mathmlBuilder:sr}),E({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:r,funcName:o}){let i=o;return i.length===1&&(i=os[i]),{type:"op",mode:r.mode,limits:!1,parentIsSupSub:!1,symbol:!0,stack:!1,name:i}},mathmlBuilder:sr}),E({type:"operatorname",names:["\\operatorname@","\\operatornamewithlimits"],props:{numArgs:1,allowedInArgument:!0},handler:({parser:r,funcName:o},i)=>{let u=i[0],p=r.prevAtomType,v=r.gullet.future().text;return{type:"operatorname",mode:r.mode,body:j(u),alwaysHandleSupSub:o==="\\operatornamewithlimits",limits:!1,parentIsSupSub:!1,isFollowedByDelimiter:rr(v),needsLeadingSpace:p.length>0&&Jr.includes(p)}},mathmlBuilder:(r,o)=>{let i,u=Y(r.body,o.withFont("mathrm")),p=!0;for(let v=0;v<u.length;v++){let C=u[v];if(C instanceof I)switch(((C.type==="mrow"||C.type==="mpadded")&&C.children.length===1&&C.children[0]instanceof I||C.type==="mrow"&&C.children.length===2&&C.children[0]instanceof I&&C.children[1]instanceof I&&C.children[1].type==="mspace"&&!C.children[1].attributes.width&&C.children[1].children.length===0)&&(C=C.children[0]),C.type){case"mi":case"mn":case"ms":case"mtext":break;case"mspace":if(C.attributes.width){let R=C.attributes.width.replace("em",""),ge=Vr(Number(R));ge===""?p=!1:u[v]=new I("mtext",[new ce(ge)])}break;case"mo":{let R=C.children[0];C.children.length===1&&R instanceof ce?R.text=R.text.replace(/\u2212/,"-").replace(/\u2217/,"*"):p=!1;break}default:p=!1}else p=!1}if(p){let v=u.map(C=>C.toText()).join("");u=[new ce(v)]}else if(u.length===1&&["mover","munder"].includes(u[0].type)&&(u[0].children[0].type==="mi"||u[0].children[0].type==="mtext")){if(u[0].children[0].type="mi",r.parentIsSupSub)return new I("mrow",u);{let v=new I("mo",[Ze("\u2061","text")]);return ie([u[0],v])}}if(p?(i=new I("mi",u),u[0].text.length===1&&i.setAttribute("mathvariant","normal")):i=new I("mrow",u),!r.parentIsSupSub){let v=[i,new I("mo",[Ze("\u2061","text")])];if(r.needsLeadingSpace){let C=new I("mspace");C.setAttribute("width","0.1667em"),v.unshift(C)}if(!r.isFollowedByDelimiter){let C=new I("mspace");C.setAttribute("width","0.1667em"),v.push(C)}return ie(v)}return i}}),xe("\\operatorname","\\@ifstar\\operatornamewithlimits\\operatorname@"),L({type:"ordgroup",mathmlBuilder:(r,o)=>ve(r.body,o,r.semisimple)}),E({type:"phantom",names:["\\phantom"],props:{numArgs:1,allowedInText:!0},handler:({parser:r},o)=>{let i=o[0];return{type:"phantom",mode:r.mode,body:j(i)}},mathmlBuilder:(r,o)=>{let i=Y(r.body,o);return new I("mphantom",i)}}),E({type:"hphantom",names:["\\hphantom"],props:{numArgs:1,allowedInText:!0},handler:({parser:r},o)=>{let i=o[0];return{type:"hphantom",mode:r.mode,body:i}},mathmlBuilder:(r,o)=>{let i=Y(j(r.body),o),u=new I("mphantom",i),p=new I("mpadded",[u]);return p.setAttribute("height","0px"),p.setAttribute("depth","0px"),p}}),E({type:"vphantom",names:["\\vphantom"],props:{numArgs:1,allowedInText:!0},handler:({parser:r},o)=>{let i=o[0];return{type:"vphantom",mode:r.mode,body:i}},mathmlBuilder:(r,o)=>{let i=Y(j(r.body),o),u=new I("mphantom",i),p=new I("mpadded",[u]);return p.setAttribute("width","0.1px"),p}}),E({type:"pmb",names:["\\pmb"],props:{numArgs:1,allowedInText:!0},handler:({parser:r},o)=>({type:"pmb",mode:r.mode,body:j(o[0])}),mathmlBuilder(r,o){let i=Y(r.body,o),u=de(i);return u.setAttribute("style","font-weight:bold"),u}});let is=(r,o)=>{let i=o.withLevel(nn),u=new I("mpadded",[Ne(r.body,i)]),p=Wt(r.dy,o);return u.setAttribute("voffset",p.number+p.unit),p.number>0?u.style.padding=p.number+p.unit+" 0 0 0":u.style.padding="0 0 "+Math.abs(p.number)+p.unit+" 0",u};E({type:"raise",names:["\\raise","\\lower"],props:{numArgs:2,argTypes:["size","primitive"],primitive:!0},handler({parser:r,funcName:o},i){let u=Nt(i[0],"size").value;o==="\\lower"&&(u.number*=-1);let p=i[1];return{type:"raise",mode:r.mode,dy:u,body:p}},mathmlBuilder:is}),E({type:"raise",names:["\\raisebox"],props:{numArgs:2,argTypes:["size","hbox"],allowedInText:!0},handler({parser:r,funcName:o},i){let u=Nt(i[0],"size").value,p=i[1];return{type:"raise",mode:r.mode,dy:u,body:p}},mathmlBuilder:is}),E({type:"ref",names:["\\ref","\\eqref"],props:{numArgs:1,argTypes:["raw"]},handler:({parser:r,funcName:o},i)=>({type:"ref",mode:r.mode,funcName:o,string:i[0].string.replace(ss,"")}),mathmlBuilder(r,o){let i=r.funcName==="\\ref"?["tml-ref"]:["tml-ref","tml-eqref"];return new re("#"+r.string,i,null)}}),E({type:"reflect",names:["\\reflectbox"],props:{numArgs:1,argTypes:["hbox"],allowedInText:!0},handler:({parser:r},o)=>({type:"reflect",mode:r.mode,body:o[0]}),mathmlBuilder(r,o){let i=Ne(r.body,o);return i.style.transform="scaleX(-1)",i}}),E({type:"internal",names:["\\relax"],props:{numArgs:0,allowedInText:!0,allowedInArgument:!0},handler:({parser:r})=>({type:"internal",mode:r.mode})}),E({type:"rule",names:["\\rule"],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["size","size","size"]},handler({parser:r},o,i){let u=i[0],p=Nt(o[0],"size"),v=Nt(o[1],"size");return{type:"rule",mode:r.mode,shift:u&&Nt(u,"size").value,width:p.value,height:v.value}},mathmlBuilder(r,o){let i=Wt(r.width,o),u=Wt(r.height,o),p=r.shift?Wt(r.shift,o):{number:0,unit:"em"},v=o.color&&o.getColor()||"black",C=new I("mspace");if(i.number>0&&u.number>0&&C.setAttribute("mathbackground",v),C.setAttribute("width",i.number+i.unit),C.setAttribute("height",u.number+u.unit),p.number===0)return C;let R=new I("mpadded",[C]);return p.number>=0?R.setAttribute("height","+"+p.number+p.unit):(R.setAttribute("height",p.number+p.unit),R.setAttribute("depth","+"+-p.number+p.unit)),R.setAttribute("voffset",p.number+p.unit),R}});let as=/^[0-9]$/,Tr={0:"\u2080",1:"\u2081",2:"\u2082",3:"\u2083",4:"\u2084",5:"\u2085",6:"\u2086",7:"\u2087",8:"\u2088",9:"\u2089"},fr={0:"\u2070",1:"\xB9",2:"\xB2",3:"\xB3",4:"\u2074",5:"\u2075",6:"\u2076",7:"\u2077",8:"\u2078",9:"\u2079"};E({type:"sfrac",names:["\\sfrac"],props:{numArgs:2,allowedInText:!0,allowedInMath:!0},handler({parser:r},o){let i="";for(let p of o[0].body){if(p.type!=="textord"||!as.test(p.text))throw new e("Numerator must be an integer.",p);i+=p.text}let u="";for(let p of o[1].body){if(p.type!=="textord"||!as.test(p.text))throw new e("Denominator must be an integer.",p);u+=p.text}return{type:"sfrac",mode:r.mode,numerator:i,denominator:u}},mathmlBuilder(r,o){let i=r.numerator.split("").map(v=>fr[v]).join(""),u=r.denominator.split("").map(v=>Tr[v]).join(""),p=new ce(i+"\u2044"+u,r.mode,o);return new I("mn",[p],["special-fraction"])}});let mr={"\\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};E({type:"sizing",names:["\\tiny","\\sixptsize","\\Tiny","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"],props:{numArgs:0,allowedInText:!0},handler:({breakOnTokenText:r,funcName:o,parser:i},u)=>{i.settings.strict&&i.mode==="math"&&console.log(`Temml strict-mode warning: Command ${o} is invalid in math mode.`);let p=i.parseExpression(!1,r,!0);return{type:"sizing",mode:i.mode,funcName:o,body:p}},mathmlBuilder:(r,o)=>{let i=o.withFontSize(mr[r.funcName]),u=Y(r.body,i),p=de(u),v=(mr[r.funcName]/o.fontSize).toFixed(4);return p.setAttribute("mathsize",v+"em"),p}}),E({type:"smash",names:["\\smash"],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0},handler:({parser:r},o,i)=>{let u=!1,p=!1,v=i[0]&&Nt(i[0],"ordgroup");if(v){let R="";for(let ge=0;ge<v.body.length;++ge)if(R=v.body[ge].text,R==="t")u=!0;else{if(R!=="b"){u=!1,p=!1;break}p=!0}}else u=!0,p=!0;let C=o[0];return{type:"smash",mode:r.mode,body:C,smashHeight:u,smashDepth:p}},mathmlBuilder:(r,o)=>{let i=new I("mpadded",[Ne(r.body,o)]);return r.smashHeight&&i.setAttribute("height","0px"),r.smashDepth&&i.setAttribute("depth","0px"),i}});let Ir=["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"];E({type:"sqrt",names:["\\sqrt"],props:{numArgs:1,numOptionalArgs:1},handler({parser:r},o,i){let u=i[0],p=o[0];return p.body&&p.body.length===1&&p.body[0].text&&Ir.includes(p.body[0].text)&&p.body.push({type:"rule",mode:"math",shift:null,width:{number:0,unit:"pt"},height:{number:.5,unit:"em"}}),{type:"sqrt",mode:r.mode,body:p,index:u}},mathmlBuilder(r,o){let{body:i,index:u}=r;return u?new I("mroot",[Ne(i,o),Ne(u,o.incrementLevel())]):new I("msqrt",[Ne(i,o)])}});let ls={display:0,text:1,script:2,scriptscript:3},Qn={display:["0","true"],text:["0","false"],script:["1","false"],scriptscript:["2","false"]};E({type:"styling",names:["\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({breakOnTokenText:r,funcName:o,parser:i},u){let p=i.parseExpression(!0,r,!0),v=o.slice(1,o.length-5);return{type:"styling",mode:i.mode,scriptLevel:v,body:p}},mathmlBuilder(r,o){let i=o.withLevel(ls[r.scriptLevel]),u=Y(r.body,i),p=de(u),v=Qn[r.scriptLevel];return p.setAttribute("scriptlevel",v[0]),p.setAttribute("displaystyle",v[1]),p}});let hs=/^m(over|under|underover)$/;L({type:"supsub",mathmlBuilder(r,o){let i,u,p=!1,v=!1,C=!1,R=!1;r.base&&r.base.type==="horizBracket"&&(u=!!r.sup,u===r.base.isOver&&(p=!0,i=r.base.isOver)),!r.base||r.stack||r.base.type!=="op"&&r.base.type!=="operatorname"||(r.base.parentIsSupSub=!0,v=!r.base.symbol,C=v&&!r.isFollowedByDelimiter,R=r.base.needsLeadingSpace);let ge=r.stack&&r.base.body.length===1?[Ne(r.base.body[0],o)]:[Ne(r.base,o)],Me=o.inSubOrSup();if(r.sub){let Je=Ne(r.sub,Me);o.level===3&&Je.setAttribute("scriptlevel","2"),ge.push(Je)}if(r.sup){let Je=Ne(r.sup,Me);if(o.level===3&&Je.setAttribute("scriptlevel","2"),r.base&&r.base.text&&r.base.text.length===1){let qt=r.base.text;"DHKLUcegorsuvxyz\u03A0\u03A5\u03A8\u03B1\u03B4\u03B7\u03B9\u03BC\u03BD\u03BF\u03C4\u03C5\u03C7\u03F5".indexOf(qt)>-1?Je.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(qt)>-1?Je.classes.push("tml-med-pad"):"AJdf\u0394\u039B".indexOf(qt)>-1&&Je.classes.push("tml-lrg-pad")}ge.push(Je)}let We;if(p)We=i?"mover":"munder";else if(r.sub)if(r.sup){let Je=r.base;We=Je&&(Je.type==="op"&&Je.limits||Je.type==="multiscript")&&(o.level===Rn||Je.alwaysHandleSupSub)||Je&&Je.type==="operatorname"&&Je.alwaysHandleSupSub&&(o.level===Rn||Je.limits)?"munderover":"msubsup"}else{let Je=r.base;We=r.stack||Je&&Je.type==="op"&&Je.limits&&(o.level===Rn||Je.alwaysHandleSupSub)||Je&&Je.type==="operatorname"&&Je.alwaysHandleSupSub&&(Je.limits||o.level===Rn)?"munder":"msub"}else{let Je=r.base;We=Je&&Je.type==="op"&&Je.limits&&(o.level===Rn||Je.alwaysHandleSupSub)||Je&&Je.type==="operatorname"&&Je.alwaysHandleSupSub&&(Je.limits||o.level===Rn)?"mover":"msup"}let rt=new I(We,ge);if(v){let Je=new I("mo",[Ze("\u2061","text")]);if(R){let qt=new I("mspace");qt.setAttribute("width","0.1667em"),rt=ie([qt,rt,Je])}else rt=ie([rt,Je]);if(C){let qt=new I("mspace");qt.setAttribute("width","0.1667em"),rt.children.push(qt)}}else hs.test(We)&&(rt=new I("mrow",[rt]));return rt}});let Xe=["\\shortmid","\\nshortmid","\\shortparallel","\\nshortparallel","\\smallsetminus"],Wn=["\\Rsh","\\Lsh","\\restriction"];L({type:"atom",mathmlBuilder(r,o){let i=new I("mo",[Ze(r.text,r.mode)]);if(r.family==="punct")i.setAttribute("separator","true");else if(r.family==="open"||r.family==="close")r.family==="open"?(i.setAttribute("form","prefix"),i.setAttribute("stretchy","false")):r.family==="close"&&(i.setAttribute("form","postfix"),i.setAttribute("stretchy","false"));else if(r.text==="\\mid")i.setAttribute("lspace","0.22em"),i.setAttribute("rspace","0.22em"),i.setAttribute("stretchy","false");else if(r.family==="rel"&&(u=>{if(u.length===1){let p=u.codePointAt(0);return 8591<p&&p<8704}return u.indexOf("arrow")>-1||u.indexOf("harpoon")>-1||Wn.includes(u)})(r.text))i.setAttribute("stretchy","false");else if(Xe.includes(r.text))i.setAttribute("mathsize","70%");else if(r.text===":")i.attributes.lspace="0.2222em",i.attributes.rspace="0.2222em";else if(r.needsSpacing)return r.family==="bin"?new I("mrow",[St(.222),i,St(.222)]):new I("mrow",[St(.2778),i,St(.2778)]);return i}});let zr={mathbf:"bold",mathrm:"normal",textit:"italic",mathit:"italic",mathnormal:"italic",mathbb:"double-struck",mathcal:"script",mathfrak:"fraktur",mathscr:"script",mathsf:"sans-serif",mathtt:"monospace"},cs=function(r,o){if(o.fontFamily==="texttt")return"monospace";if(o.fontFamily==="textsc")return"normal";if(o.fontFamily==="textsf")return o.fontShape==="textit"&&o.fontWeight==="textbf"?"sans-serif-bold-italic":o.fontShape==="textit"?"sans-serif-italic":o.fontWeight==="textbf"?"sans-serif-bold":"sans-serif";if(o.fontShape==="textit"&&o.fontWeight==="textbf")return"bold-italic";if(o.fontShape==="textit")return"italic";if(o.fontWeight==="textbf")return"bold";let i=o.font;if(!i||i==="mathnormal")return null;let u=r.mode;switch(i){case"mathit":case"greekItalic":return"italic";case"mathrm":{let v=r.text.codePointAt(0);return 939<v&&v<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 p=r.text;return Te[u][p]&&Te[u][p].replace&&(p=Te[u][p].replace),Object.prototype.hasOwnProperty.call(zr,i)?zr[i]:null},fs=/^\d(?:[\d,.]*\d)?$/,kr=/[A-Ba-z]/,ds=new Set(["\\prime","\\dprime","\\trprime","\\qprime","\\backprime","\\backdprime","\\backtrprime"]);L({type:"mathord",mathmlBuilder(r,o){let i=Ze(r.text,r.mode,o),u=i.text.codePointAt(0),p=912<u&&u<938?"normal":"italic",v=cs(r,o)||p;if(v==="script")return i.text=hr(i.text,v),new I("mi",[i],[o.font]);v!=="italic"&&(i.text=hr(i.text,v));let C=new I("mi",[i]);if(v==="normal"&&(C.setAttribute("mathvariant","normal"),i.text.length===1)){let R=new I("mspace",[]);C=new I("mrow",[C,R])}return C}}),L({type:"textord",mathmlBuilder(r,o){let i=r.text,u=i.codePointAt(0);o.fontFamily==="textsc"&&96<u&&u<123&&(i=ps[i]);let p=Ze(i,r.mode,o),v=cs(r,o)||"normal",C;if(fs.test(r.text)){let R=r.mode==="text"?"mtext":"mn";if(v==="italic"||v==="bold-italic")return((ge,Me,We)=>{let rt=new I(We,[ge]),Je=new I("mstyle",[rt]);return Je.style["font-style"]="italic",Je.style["font-family"]="Cambria, 'Times New Roman', serif",Me==="bold-italic"&&(Je.style["font-weight"]="bold"),Je})(p,v,R);v!=="normal"&&(p.text=p.text.split("").map(ge=>hr(ge,v)).join("")),C=new I(R,[p])}else if(r.mode==="text")v!=="normal"&&(p.text=hr(p.text,v)),C=new I("mtext",[p]);else if(ds.has(r.text))C=new I("mo",[p]),C.classes.push("tml-prime");else{let R=p.text;v!=="italic"&&(p.text=hr(p.text,v)),C=new I("mi",[p]),p.text===R&&kr.test(R)&&C.setAttribute("mathvariant","italic")}return C}});let Yr={"\\nobreak":"nobreak","\\allowbreak":"allowbreak"},_n={" ":{},"\\ ":{},"~":{className:"nobreak"},"\\space":{},"\\nobreakspace":{className:"nobreak"}};L({type:"spacing",mathmlBuilder(r,o){let i;if(Object.prototype.hasOwnProperty.call(_n,r.text))i=new I("mtext",[new ce("\xA0")]);else{if(!Object.prototype.hasOwnProperty.call(Yr,r.text))throw new e(`Unknown type of space "${r.text}"`);i=new I("mo"),r.text==="\\nobreak"&&i.setAttribute("linebreak","nobreak")}return i}}),L({type:"tag"});let Zr={"\\text":void 0,"\\textrm":"textrm","\\textsf":"textsf","\\texttt":"texttt","\\textnormal":"textrm","\\textsc":"textsc"},gr={"\\textbf":"textbf","\\textmd":"textmd"},On={"\\textit":"textit","\\textup":"textup"};E({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:r,funcName:o},i){let u=i[0];return{type:"text",mode:r.mode,body:j(u),font:o}},mathmlBuilder(r,o){let i=((p,v)=>{let C=p.font;return C?Zr[C]?v.withTextFontFamily(Zr[C]):gr[C]?v.withTextFontWeight(gr[C]):C==="\\emph"?v.fontShape==="textit"?v.withTextFontShape("textup"):v.withTextFontShape("textit"):v.withTextFontShape(On[C]):v})(r,o),u=ve(r.body,i);return Pe(u)}}),E({type:"vcenter",names:["\\vcenter"],props:{numArgs:1,argTypes:["original"],allowedInText:!1},handler:({parser:r},o)=>({type:"vcenter",mode:r.mode,body:o[0]}),mathmlBuilder(r,o){let i=new I("mtd",[Ne(r.body,o)]);i.style.padding="0";let u=new I("mtr",[i]);return new I("mtable",[u])}}),E({type:"verb",names:["\\verb"],props:{numArgs:0,allowedInText:!0},handler(r,o,i){throw new e("\\verb ended by end of line instead of matching delimiter")},mathmlBuilder(r,o){let i=new ce(ir(r)),u=new I("mtext",[i]);return u.setAttribute("mathvariant","monospace"),u}});let ir=r=>r.body.replace(/ /g,r.star?"\u2423":"\xA0"),Vn=S,zn=`[ \r
|
|
93
|
+
]`,w=`(\\\\[a-zA-Z@]+)${zn}*`,O="[\u0300-\u036F]",Q=new RegExp(`${O}+$`),m=`(${zn}+)|\\\\(
|
|
94
94
|
|[ \r ]+
|
|
95
|
-
?)[ \r ]*|([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]${
|
|
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 st(u,new Be(this,r,this.tokenRegex.lastIndex))}}class dl{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 Oo={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0};class ul{constructor(n,r,l){this.settings=r,this.expansionCount=0,this.feed(n),this.macros=new dl(Bt,r.macros),this.mode=l,this.stack=[]}feed(n){this.lexer=new Mo(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 st("EOF",l.loc)),this.pushTokens(u),new st("",Be.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,E=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[E]:"}")+"'",h);if(n&&l)if((y===0||y===1&&n[E]==="{")&&h.text===n[E]){if(++E,E===n.length){r.splice(-E,E);break}}else E=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 E=h.length-1;E>=0;--E){let U=h[E];if(U.text==="#"){if(E===0)throw new t("Incomplete placeholder at end of macro body",U);if(U=h[--E],U.text==="#")h.splice(E+1,1);else{if(!/^[1-9]$/.test(U.text))throw new t("Not a valid argument number",U);h.splice(E,2,...y[+U.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 st(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 U=l.replace(/##/g,"");for(;U.indexOf("#"+(u+1))!==-1;)++u}let h=new Mo(l,this.settings),y=[],E=h.lex();for(;E.text!=="EOF";)y.push(E),E=h.lex();return y.reverse(),{tokens:y,numArgs:u}}return l}isDefined(n){return this.macros.has(n)||Object.prototype.hasOwnProperty.call(Dt,n)||Object.prototype.hasOwnProperty.call(Y.math,n)||Object.prototype.hasOwnProperty.call(Y.text,n)||Object.prototype.hasOwnProperty.call(Oo,n)}isExpandable(n){let r=this.macros.get(n);return r!=null?typeof r=="string"||typeof r=="function"||!r.unexpandable:Object.prototype.hasOwnProperty.call(Dt,n)&&!Dt[n].primitive}}let Lo=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,ms=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"}),Ro=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 Ws={"\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"}},Io={\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 pl=["bin","op","open","punct","rel"],hl=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/,ml=/^ *\\text/;class Wr{constructor(n,r,l=!1){this.mode="math",this.gullet=new ul(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 st("}")),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(Wr.endOfExpression.indexOf(h.text)!==-1||r&&h.text===r||l&&h.text==="\\middle"||n&&Dt[h.text]&&Dt[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),E=n.slice(l+1),U;return u=y.length===1&&y[0].type==="ordgroup"?y[0]:{type:"ordgroup",mode:this.mode,body:y},h=E.length===1&&E[0].type==="ordgroup"?E[0]:{type:"ordgroup",mode:this.mode,body:E},U=r==="\\\\abovefrac"?this.callFunction(r,[u,n[l],h],[]):this.callFunction(r,[u,h],[]),[U]}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"},E=[y];for(this.consume();this.fetch().text==="'";)E.push(y),this.consume();this.fetch().text==="^"&&E.push(this.handleSupSubscript("superscript")),l={type:"ordgroup",mode:this.mode,body:E}}else{if(!ms[h.text])break;{let y=Lo.test(h.text),E=[];for(E.push(new st(ms[h.text])),this.consume();;){let V=this.fetch().text;if(!ms[V]||Lo.test(V)!==y)break;E.unshift(new st(ms[V])),this.consume()}let U=this.subparse(E);y?u={type:"ordgroup",mode:"math",body:U}:l={type:"ordgroup",mode:"math",body:U}}}}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:hn(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=Dt[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:E,optArgs:U}=this.parseArguments(u,h);return this.prevAtomType=y,this.callFunction(u,E,U,l,n)}callFunction(n,r,l,u,h){let y={funcName:n,parser:this,token:u,breakOnTokenText:h},E=Dt[n];if(E&&E.handler)return E.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 E=r.argTypes&&r.argTypes[y],U=y<r.numOptionalArgs;(r.primitive&&E==null||r.type==="sqrt"&&y===1&&h[0]==null)&&(E="primitive");let V=this.parseGroupOfType(`argument to '${n}'`,E,U);if(U)h.push(V);else{if(V==null)throw new t("Null argument, please report this as a bug");u.push(V)}}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=hl.exec(r.text);if(!u)throw new t("Invalid size: '"+r.text+"'",r);let h={number:+(u[1]+u[2]),unit:u[3]};if(!pn(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 E=this.parseExpression(!1,y),U=this.fetch();this.expect(y),this.gullet.endGroup(),h={type:U.text==="\\endtoggle"?"toggle":"ordgroup",mode:this.mode,loc:Be.range(l,U),body:E,semisimple:u==="\\begingroup"||void 0}}else if(h=this.parseFunction(r,n)||this.parseSymbol(),h==null&&u[0]==="\\"&&!Object.prototype.hasOwnProperty.call(Oo,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:Be.range(u,n[l+2]),text:"---"}),r-=2):(n.splice(l,2,{type:"textord",mode:"text",loc:Be.range(u,n[l+1]),text:"--"}),r-=1)),h!=="'"&&h!=="`"||n[l+1].text!==h||(n.splice(l,2,{type:"textord",mode:"text",loc:Be.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
|
|
95
|
+
?)[ \r ]*|([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]${O}*|[\uD800-\uDBFF][\uDC00-\uDFFF]${O}*|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5|${w}|\\\\[^\uD800-\uDFFF])`;class k{constructor(o,i){this.input=o,this.settings=i,this.tokenRegex=new RegExp(m,"g"),this.catcodes={"%":14,"~":13}}setCatcode(o,i){this.catcodes[o]=i}lex(){let o=this.input,i=this.tokenRegex.lastIndex;if(i===o.length)return new dn("EOF",new un(this,i,i));let u=this.tokenRegex.exec(o);if(u===null||u.index!==i)throw new e(`Unexpected character: '${o[i]}'`,new dn(o[i],new un(this,i,i+1)));let p=u[6]||u[3]||(u[2]?"\\ ":" ");if(this.catcodes[p]===14){let v=o.indexOf(`
|
|
96
|
+
`,this.tokenRegex.lastIndex);if(v===-1){if(this.tokenRegex.lastIndex=o.length,this.settings.strict)throw new e("% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode")}else this.tokenRegex.lastIndex=v+1;return this.lex()}return new dn(p,new un(this,i,this.tokenRegex.lastIndex))}}class _{constructor(o={},i={}){this.current=i,this.builtins=o,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(this.undefStack.length===0)throw new e("Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug");let o=this.undefStack.pop();for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&(o[i]===void 0?delete this.current[i]:this.current[i]=o[i])}has(o){return Object.prototype.hasOwnProperty.call(this.current,o)||Object.prototype.hasOwnProperty.call(this.builtins,o)}get(o){return Object.prototype.hasOwnProperty.call(this.current,o)?this.current[o]:this.builtins[o]}set(o,i,u=!1){if(u){for(let p=0;p<this.undefStack.length;p++)delete this.undefStack[p][o];this.undefStack.length>0&&(this.undefStack[this.undefStack.length-1][o]=i)}else{let p=this.undefStack[this.undefStack.length-1];p&&!Object.prototype.hasOwnProperty.call(p,o)&&(p[o]=this.current[o])}this.current[o]=i}}let W={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0};class he{constructor(o,i,u){this.settings=i,this.expansionCount=0,this.feed(o),this.macros=new _(B,i.macros),this.mode=u,this.stack=[]}feed(o){this.lexer=new k(o,this.settings)}switchMode(o){this.mode=o}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(o){this.stack.push(o)}pushTokens(o){this.stack.push(...o)}scanArgument(o){let i,u,p;if(o){if(this.consumeSpaces(),this.future().text!=="[")return null;i=this.popToken(),{tokens:p,end:u}=this.consumeArg(["]"])}else({tokens:p,start:i,end:u}=this.consumeArg());return this.pushToken(new dn("EOF",u.loc)),this.pushTokens(p),new dn("",un.range(i,u))}consumeSpaces(){for(;this.future().text===" ";)this.stack.pop()}consumeArg(o){let i=[],u=o&&o.length>0;u||this.consumeSpaces();let p=this.future(),v,C=0,R=0;do{if(v=this.popToken(),i.push(v),v.text==="{")++C;else if(v.text==="}"){if(--C,C===-1)throw new e("Extra }",v)}else if(v.text==="EOF")throw new e("Unexpected end of input in a macro argument, expected '"+(o&&u?o[R]:"}")+"'",v);if(o&&u)if((C===0||C===1&&o[R]==="{")&&v.text===o[R]){if(++R,R===o.length){i.splice(-R,R);break}}else R=0}while(C!==0||u);return p.text==="{"&&i[i.length-1].text==="}"&&(i.pop(),i.shift()),i.reverse(),{tokens:i,start:p,end:v}}consumeArgs(o,i){if(i){if(i.length!==o+1)throw new e("The length of delimiters doesn't match the number of args!");let p=i[0];for(let v=0;v<p.length;v++){let C=this.popToken();if(p[v]!==C.text)throw new e("Use of the macro doesn't match its definition",C)}}let u=[];for(let p=0;p<o;p++)u.push(this.consumeArg(i&&i[p+1]).tokens);return u}expandOnce(o){let i=this.popToken(),u=i.text,p=i.noexpand?null:this._getExpansion(u);if(p==null||o&&p.unexpandable){if(o&&p==null&&u[0]==="\\"&&!this.isDefined(u))throw new e("Undefined control sequence: "+u);return this.pushToken(i),!1}if(this.expansionCount++,this.expansionCount>this.settings.maxExpand)throw new e("Too many expansions: infinite loop or need to increase maxExpand setting");let v=p.tokens,C=this.consumeArgs(p.numArgs,p.delimiters);if(p.numArgs){v=v.slice();for(let R=v.length-1;R>=0;--R){let ge=v[R];if(ge.text==="#"){if(R===0)throw new e("Incomplete placeholder at end of macro body",ge);if(ge=v[--R],ge.text==="#")v.splice(R+1,1);else{if(!/^[1-9]$/.test(ge.text))throw new e("Not a valid argument number",ge);v.splice(R,2,...C[+ge.text-1])}}}}return this.pushTokens(v),v.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(this.expandOnce()===!1){let o=this.stack.pop();return o.treatAsRelax&&(o.text="\\relax"),o}throw new Error}expandMacro(o){return this.macros.has(o)?this.expandTokens([new dn(o)]):void 0}expandTokens(o){let i=[],u=this.stack.length;for(this.pushTokens(o);this.stack.length>u;)if(this.expandOnce(!0)===!1){let p=this.stack.pop();p.treatAsRelax&&(p.noexpand=!1,p.treatAsRelax=!1),i.push(p)}return i}expandMacroAsText(o){let i=this.expandMacro(o);return i&&i.map(u=>u.text).join("")}_getExpansion(o){let i=this.macros.get(o);if(i==null)return i;if(o.length===1){let p=this.lexer.catcodes[o];if(p!=null&&p!==13)return}let u=typeof i=="function"?i(this):i;if(typeof u=="string"){let p=0;if(u.indexOf("#")!==-1){let ge=u.replace(/##/g,"");for(;ge.indexOf("#"+(p+1))!==-1;)++p}let v=new k(u,this.settings),C=[],R=v.lex();for(;R.text!=="EOF";)C.push(R),R=v.lex();return C.reverse(),{tokens:C,numArgs:p}}return u}isDefined(o){return this.macros.has(o)||Object.prototype.hasOwnProperty.call(Vn,o)||Object.prototype.hasOwnProperty.call(Te.math,o)||Object.prototype.hasOwnProperty.call(Te.text,o)||Object.prototype.hasOwnProperty.call(W,o)}isExpandable(o){let i=this.macros.get(o);return i!=null?typeof i=="string"||typeof i=="function"||!i.unexpandable:Object.prototype.hasOwnProperty.call(Vn,o)&&!Vn[o].primitive}}let Be=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,Re=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"}),ct=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 Oe={"\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"}},$t={\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 Lt=["bin","op","open","punct","rel"],Ut=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/,en=/^ *\\text/;class _t{constructor(o,i,u=!1){this.mode="math",this.gullet=new he(o,i,this.mode),this.settings=i,this.isPreamble=u,this.leftrightDepth=0,this.prevAtomType=""}expect(o,i=!0){if(this.fetch().text!==o)throw new e(`Expected '${o}', got '${this.fetch().text}'`,this.fetch());i&&this.consume()}consume(){this.nextToken=null}fetch(){return this.nextToken==null&&(this.nextToken=this.gullet.expandNextToken()),this.nextToken}switchMode(o){this.mode=o,this.gullet.switchMode(o)}parse(){this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set("\\color","\\textcolor");let o=this.parseExpression(!1);if(this.expect("EOF"),this.isPreamble){let u=Object.create(null);return Object.entries(this.gullet.macros.current).forEach(([p,v])=>{u[p]=v}),this.gullet.endGroup(),u}let i=this.gullet.macros.get("\\df@tag");return this.gullet.endGroup(),i&&(this.gullet.macros.current["\\df@tag"]=i),o}static get endOfExpression(){return["}","\\endgroup","\\end","\\right","\\endtoggle","&"]}subparse(o){let i=this.nextToken;this.consume(),this.gullet.pushToken(new dn("}")),this.gullet.pushTokens(o);let u=this.parseExpression(!1);return this.expect("}"),this.nextToken=i,u}parseExpression(o,i,u){let p=[];for(this.prevAtomType="";;){this.mode==="math"&&this.consumeSpaces();let v=this.fetch();if(_t.endOfExpression.indexOf(v.text)!==-1||i&&v.text===i||u&&v.text==="\\middle"||o&&Vn[v.text]&&Vn[v.text].infix)break;let C=this.parseAtom(i);if(!C)break;C.type!=="internal"&&(p.push(C),this.prevAtomType=C.type==="atom"?C.family:C.type)}return this.mode==="text"&&this.formLigatures(p),this.handleInfixNodes(p)}handleInfixNodes(o){let i,u=-1;for(let p=0;p<o.length;p++)if(o[p].type==="infix"){if(u!==-1)throw new e("only one infix operator per group",o[p].token);u=p,i=o[p].replaceWith}if(u!==-1&&i){let p,v,C=o.slice(0,u),R=o.slice(u+1),ge;return p=C.length===1&&C[0].type==="ordgroup"?C[0]:{type:"ordgroup",mode:this.mode,body:C},v=R.length===1&&R[0].type==="ordgroup"?R[0]:{type:"ordgroup",mode:this.mode,body:R},ge=i==="\\\\abovefrac"?this.callFunction(i,[p,o[u],v],[]):this.callFunction(i,[p,v],[]),[ge]}return o}handleSupSubscript(o){let i=this.fetch(),u=i.text,p;this.consume(),this.consumeSpaces();do p=this.parseGroup(o);while(p.type&&p.type==="internal");if(!p)throw new e("Expected group after '"+u+"'",i);return p}formatUnsupportedCmd(o){let i=[];for(let p=0;p<o.length;p++)i.push({type:"textord",mode:"text",text:o[p]});let u={type:"text",mode:this.mode,body:i};return{type:"color",mode:this.mode,color:this.settings.errorColor,body:[u]}}parseAtom(o){let i=this.parseGroup("atom",o);if(i&&i.type==="internal"||this.mode==="text")return i;let u,p;for(;;){this.consumeSpaces();let v=this.fetch();if(v.text==="\\limits"||v.text==="\\nolimits"){if(i&&i.type==="op"){let C=v.text==="\\limits";i.limits=C,i.alwaysHandleSupSub=!0}else{if(!i||i.type!=="operatorname")throw new e("Limit controls must follow a math operator",v);i.alwaysHandleSupSub&&(i.limits=v.text==="\\limits")}this.consume()}else if(v.text==="^"){if(u)throw new e("Double superscript",v);u=this.handleSupSubscript("superscript")}else if(v.text==="_"){if(p)throw new e("Double subscript",v);p=this.handleSupSubscript("subscript")}else if(v.text==="'"){if(u)throw new e("Double superscript",v);let C={type:"textord",mode:this.mode,text:"\\prime"},R=[C];for(this.consume();this.fetch().text==="'";)R.push(C),this.consume();this.fetch().text==="^"&&R.push(this.handleSupSubscript("superscript")),u={type:"ordgroup",mode:this.mode,body:R}}else{if(!Re[v.text])break;{let C=Be.test(v.text),R=[];for(R.push(new dn(Re[v.text])),this.consume();;){let Me=this.fetch().text;if(!Re[Me]||Be.test(Me)!==C)break;R.unshift(new dn(Re[Me])),this.consume()}let ge=this.subparse(R);C?p={type:"ordgroup",mode:"math",body:ge}:u={type:"ordgroup",mode:"math",body:ge}}}}if(u||p){if(i&&i.type==="multiscript"&&!i.postscripts)return i.postscripts={sup:u,sub:p},i;{let v=!i||i.type!=="op"&&i.type!=="operatorname"?void 0:rr(this.nextToken.text);return{type:"supsub",mode:this.mode,base:i,sup:u,sub:p,isFollowedByDelimiter:v}}}return i}parseFunction(o,i){let u=this.fetch(),p=u.text,v=Vn[p];if(!v)return null;if(this.consume(),i&&i!=="atom"&&!v.allowedInArgument)throw new e("Got function '"+p+"' with no arguments"+(i?" as "+i:""),u);if(this.mode==="text"&&!v.allowedInText)throw new e("Can't use function '"+p+"' in text mode",u);if(this.mode==="math"&&v.allowedInMath===!1)throw new e("Can't use function '"+p+"' in math mode",u);let C=this.prevAtomType,{args:R,optArgs:ge}=this.parseArguments(p,v);return this.prevAtomType=C,this.callFunction(p,R,ge,u,o)}callFunction(o,i,u,p,v){let C={funcName:o,parser:this,token:p,breakOnTokenText:v},R=Vn[o];if(R&&R.handler)return R.handler(C,i,u);throw new e(`No function handler for ${o}`)}parseArguments(o,i){let u=i.numArgs+i.numOptionalArgs;if(u===0)return{args:[],optArgs:[]};let p=[],v=[];for(let C=0;C<u;C++){let R=i.argTypes&&i.argTypes[C],ge=C<i.numOptionalArgs;(i.primitive&&R==null||i.type==="sqrt"&&C===1&&v[0]==null)&&(R="primitive");let Me=this.parseGroupOfType(`argument to '${o}'`,R,ge);if(ge)v.push(Me);else{if(Me==null)throw new e("Null argument, please report this as a bug");p.push(Me)}}return{args:p,optArgs:v}}parseGroupOfType(o,i,u){switch(i){case"size":return this.parseSizeGroup(u);case"url":return this.parseUrlGroup(u);case"math":case"text":return this.parseArgumentGroup(u,i);case"hbox":{let p=this.parseArgumentGroup(u,"text");return p!=null?{type:"styling",mode:p.mode,body:[p],scriptLevel:"text"}:null}case"raw":{let p=this.parseStringGroup("raw",u);return p!=null?{type:"raw",mode:"text",string:p.text}:null}case"primitive":{if(u)throw new e("A primitive argument cannot be optional");let p=this.parseGroup(o);if(p==null)throw new e("Expected group as "+o,this.fetch());return p}case"original":case null:case void 0:return this.parseArgumentGroup(u);default:throw new e("Unknown group type as "+o,this.fetch())}}consumeSpaces(){for(;;){let o=this.fetch().text;if(o!==" "&&o!=="\xA0"&&o!=="\uFE0E")break;this.consume()}}parseStringGroup(o,i){let u=this.gullet.scanArgument(i);if(u==null)return null;let p,v="";for(;(p=this.fetch()).text!=="EOF";)v+=p.text,this.consume();return this.consume(),u.text=v,u}parseRegexGroup(o,i){let u=this.fetch(),p,v=u,C="";for(;(p=this.fetch()).text!=="EOF"&&o.test(C+p.text);)v=p,C+=v.text,this.consume();if(C==="")throw new e("Invalid "+i+": '"+u.text+"'",u);return u.range(v,C)}parseSizeGroup(o){let i,u=!1;if(this.gullet.consumeSpaces(),i=o||this.gullet.future().text==="{"?this.parseStringGroup("size",o):this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/,"size"),!i)return null;o||i.text.length!==0||(i.text="0pt",u=!0);let p=Ut.exec(i.text);if(!p)throw new e("Invalid size: '"+i.text+"'",i);let v={number:+(p[1]+p[2]),unit:p[3]};if(!Xt(v))throw new e("Invalid unit: '"+v.unit+"'",i);return{type:"size",mode:this.mode,value:v,isBlank:u}}parseUrlGroup(o){this.gullet.lexer.setCatcode("%",13),this.gullet.lexer.setCatcode("~",12);let i=this.parseStringGroup("url",o);if(this.gullet.lexer.setCatcode("%",14),this.gullet.lexer.setCatcode("~",13),i==null)return null;let u=i.text.replace(/\\([#$%&~_^{}])/g,"$1");return u=i.text.replace(/{\u2044}/g,"/"),{type:"url",mode:this.mode,url:u}}parseArgumentGroup(o,i){let u=this.gullet.scanArgument(o);if(u==null)return null;let p=this.mode;i&&this.switchMode(i),this.gullet.beginGroup();let v=this.parseExpression(!1,"EOF");this.expect("EOF"),this.gullet.endGroup();let C={type:"ordgroup",mode:this.mode,loc:u.loc,body:v};return i&&this.switchMode(p),C}parseGroup(o,i){let u=this.fetch(),p=u.text;if(o==="argument to '\\left'")return this.parseSymbol();let v;if(p==="{"||p==="\\begingroup"||p==="\\toggle"){this.consume();let C=p==="{"?"}":p==="\\begingroup"?"\\endgroup":"\\endtoggle";this.gullet.beginGroup();let R=this.parseExpression(!1,C),ge=this.fetch();this.expect(C),this.gullet.endGroup(),v={type:ge.text==="\\endtoggle"?"toggle":"ordgroup",mode:this.mode,loc:un.range(u,ge),body:R,semisimple:p==="\\begingroup"||void 0}}else if(v=this.parseFunction(i,o)||this.parseSymbol(),v==null&&p[0]==="\\"&&!Object.prototype.hasOwnProperty.call(W,p)){if(this.settings.throwOnError)throw new e("Unsupported function name: "+p,u);v=this.formatUnsupportedCmd(p),this.consume()}return v}formLigatures(o){let i=o.length-1;for(let u=0;u<i;++u){let p=o[u],v=p.text;v==="-"&&o[u+1].text==="-"&&(u+1<i&&o[u+2].text==="-"?(o.splice(u,3,{type:"textord",mode:"text",loc:un.range(p,o[u+2]),text:"---"}),i-=2):(o.splice(u,2,{type:"textord",mode:"text",loc:un.range(p,o[u+1]),text:"--"}),i-=1)),v!=="'"&&v!=="`"||o[u+1].text!==v||(o.splice(u,2,{type:"textord",mode:"text",loc:un.range(p,o[u+1]),text:v+v}),i-=1)}}parseSymbol(){let o=this.fetch(),i=o.text;if(/^\\verb[^a-zA-Z]/.test(i)){this.consume();let v=i.slice(5),C=v.charAt(0)==="*";if(C&&(v=v.slice(1)),v.length<2||v.charAt(0)!==v.slice(-1))throw new e(`\\verb assertion failed --
|
|
97
|
+
please report what input caused this bug`);return v=v.slice(1,-1),{type:"verb",mode:"text",body:v,star:C}}if(Object.prototype.hasOwnProperty.call($t,i[0])&&this.mode==="math"&&!Te[this.mode][i[0]]){if(this.settings.strict&&this.mode==="math")throw new e(`Accented Unicode text character "${i[0]}" used in math mode`,o);i=$t[i[0]]+i.slice(1)}let u=this.mode==="math"?Q.exec(i):null,p;if(u&&(i=i.substring(0,u.index),i==="i"?i="\u0131":i==="j"&&(i="\u0237")),Te[this.mode][i]){let v=Te[this.mode][i].group;v!=="bin"||!Lt.includes(this.prevAtomType)&&this.prevAtomType!==""||(v="open");let C=un.range(o),R;if(Object.prototype.hasOwnProperty.call(se,v)){let ge=v;R={type:"atom",mode:this.mode,family:ge,loc:C,text:i},ge!=="rel"&&ge!=="bin"||this.prevAtomType!=="text"||en.test(C.lexer.input.slice(C.end))&&(R.needsSpacing=!0)}else{if(ct[i]){this.consume();let ge=this.fetch().text.charCodeAt(0),Me=ge===65025?"mathscr":"mathcal";return ge!==65024&&ge!==65025||this.consume(),{type:"font",mode:"math",font:Me,body:{type:"mathord",mode:"math",loc:C,text:ct[i]}}}R={type:v,mode:this.mode,loc:C,text:i}}p=R}else{if(!(i.charCodeAt(0)>=128||Q.exec(i)))return null;if(this.settings.strict&&this.mode==="math")throw new e(`Unicode text character "${i[0]}" used in math mode`,o);p={type:"textord",mode:"text",loc:un.range(o),text:i}}if(this.consume(),u)for(let v=0;v<u[0].length;v++){let C=u[0][v];if(!Oe[C])throw new e(`Unknown accent ' ${C}'`,o);let R=Oe[C][this.mode]||Oe[C].text;if(!R)throw new e(`Accent ${C} unsupported in ${this.mode} mode`,o);p={type:"accent",mode:this.mode,loc:un.range(o),label:R,isStretchy:!1,base:p}}return p}}let kt=function(r,o){if(!(typeof r=="string"||r instanceof String))throw new TypeError("Temml can only parse string typed expression");let i,u;try{u=new _t(r,o),delete u.gullet.macros.current["\\df@tag"],i=u.parse()}catch(p){if(p.toString()!=="ParseError: Unmatched delimiter")throw p;o.wrapDelimiterPairs=!1,u=new _t(r,o),delete u.gullet.macros.current["\\df@tag"],i=u.parse()}if(!(i.length>0&&i[0].type&&i[0].type==="array"&&i[0].addEqnNum)&&u.gullet.macros.get("\\df@tag")){if(!o.displayMode)throw new e("\\tag works only in display mode");u.gullet.feed("\\df@tag"),i=[{type:"tag",mode:"text",body:i,tag:u.parse()}]}return i},x=[2,2,3,3];class q{constructor(o){this.level=o.level,this.color=o.color,this.font=o.font||"",this.fontFamily=o.fontFamily||"",this.fontSize=o.fontSize||1,this.fontWeight=o.fontWeight||"",this.fontShape=o.fontShape||"",this.maxSize=o.maxSize}extend(o){let i={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 u in o)Object.prototype.hasOwnProperty.call(o,u)&&(i[u]=o[u]);return new q(i)}withLevel(o){return this.extend({level:o})}incrementLevel(){return this.extend({level:Math.min(this.level+1,3)})}inSubOrSup(){return this.extend({level:x[this.level]})}withColor(o){return this.extend({color:o})}withFont(o){return this.extend({font:o})}withTextFontFamily(o){return this.extend({fontFamily:o,font:""})}withFontSize(o){return this.extend({fontSize:o})}withTextFontWeight(o){return this.extend({fontWeight:o,font:""})}withTextFontShape(o){return this.extend({fontShape:o,font:""})}getColor(){return this.color}}function X(r){let o={},i=0,u=document.getElementsByClassName("tml-eqn");for(let v of u)for(i+=1,v.setAttribute("id","tml-eqn-"+String(i));v.tagName!=="mtable";){if(v.getElementsByClassName("tml-label").length>0){let C=v.attributes.id.value;o[C]=String(i);break}v=v.parentElement}let p=document.getElementsByClassName("tml-tageqn");for(let v of p)if(v.getElementsByClassName("tml-label").length>0){let C=v.getElementsByClassName("tml-tag");if(C.length>0){let R=v.attributes.id.value;o[R]=C[0].textContent}}[...r.getElementsByClassName("tml-ref")].forEach(v=>{let C=v.getAttribute("href"),R=o[C.slice(1)];v.className.indexOf("tml-eqref")===-1?(R=R.replace(/^\(/,""),R=R.replace(/\)$/,"")):(R.charAt(0)!=="("&&(R="("+R),R.slice(-1)!==")"&&(R+=")"));let ge=document.createElementNS("http://www.w3.org/1998/Math/MathML","mtext");ge.appendChild(document.createTextNode(R));let Me=document.createElementNS("http://www.w3.org/1998/Math/MathML","math");Me.appendChild(ge),v.textContent="",v.appendChild(Me)})}let me=function(r,o,i){let u=i,p=0,v=r.length;for(;u<o.length;){let C=o[u];if(p<=0&&o.slice(u,u+v)===r)return u;C==="\\"?u++:C==="{"?p++:C==="}"&&p--,u++}return-1},De=/^\\(?:begin|(?:eq)?ref){/,Ge=[{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}],ne={$:[{left:"$$",right:"$$",display:!0},{left:"$`",right:"`$",display:!1},{left:"$",right:"$",display:!1}],"(":[{left:"\\[",right:"\\]",display:!0},{left:"\\(",right:"\\)",display:!1}]},$e=[{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}],He=function(r,o){let i=function(p,v){let C,R=[],ge=new RegExp("("+v.map(Me=>Me.left.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")+")");for(;C=p.search(ge),C!==-1;){C>0&&(R.push({type:"text",data:p.slice(0,C)}),p=p.slice(C));let Me=v.findIndex(Je=>p.startsWith(Je.left));if(C=me(v[Me].right,p,v[Me].left.length),C===-1)break;let We=p.slice(0,C+v[Me].right.length),rt=De.test(We)?We:p.slice(v[Me].left.length,C);R.push({type:"math",data:rt,rawData:We,display:v[Me].display}),p=p.slice(C+v[Me].right.length)}return p!==""&&R.push({type:"text",data:p}),R}(r,o.delimiters);if(i.length===1&&i[0].type==="text")return null;let u=document.createDocumentFragment();for(let p=0;p<i.length;p++)if(i[p].type==="text")u.appendChild(document.createTextNode(i[p].data));else{let v=document.createElement("span"),C=i[p].data;o.displayMode=i[p].display;try{o.preProcess&&(C=o.preProcess(C)),$l.render(C,v,o)}catch(R){if(!(R instanceof e))throw R;o.errorCallback("Temml auto-render: Failed to parse `"+i[p].data+"` with ",R),u.appendChild(document.createTextNode(i[p].rawData));continue}u.appendChild(v)}return u},it=function(r,o){for(let i=0;i<r.childNodes.length;i++){let u=r.childNodes[i];if(u.nodeType===3){let p=He(u.textContent,o);p&&(i+=p.childNodes.length-1,r.replaceChild(p,u))}else if(u.nodeType===1){let p=" "+u.className+" ";o.ignoredTags.indexOf(u.nodeName.toLowerCase())===-1&&o.ignoredClasses.every(v=>p.indexOf(" "+v+" ")===-1)&&it(u,o)}}},qe=function(r,o,i={}){o.textContent="";let u=o.tagName.toLowerCase()==="math";u&&(i.wrap="none");let p=nt(r,i);u||p.children.length>1?(o.textContent="",p.children.forEach(v=>{o.appendChild(v.toNode())})):o.appendChild(p.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."),qe=function(){throw new e("Temml doesn't work in quirks mode.")});let nt=function(r,o){let i=new $(o);try{let u=kt(r,i);return mt(u,r,new q({level:i.displayMode?Rn:nn,maxSize:i.maxSize}),i)}catch(u){return function(p,v,C){if(C.throwOnError||!(p instanceof e))throw p;let R=new Ce(["temml-error"],[new ee(v+`
|
|
98
98
|
|
|
99
|
-
`+u.toString())]);return E.style.color=y.errorColor,E.style.whiteSpace="pre-line",E}(l,e,r)}};return{version:"0.13.3",render:Fo,renderToString:function(e,n){return Js(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==="("?fs[l]:l==="$+"||l==="(+"?fs[l.slice(0,1)].concat(Zs):l==="ams"?Zs:l==="all"?fs["("].concat(fs.$).concat(Zs):Do)(r.fences):r.delimiters=r.delimiters||Do,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||{},qo(e,r),Bo(e)},postProcess:Bo,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 Wr(e,r,!0);return delete l.gullet.macros.current["\\df@tag"],l.parse()},__parse:function(e,n){let r=new P(n);return Po(e,r)},__renderToMathMLTree:Js,__defineSymbol:s,__defineMacro:L}}(),ci=li;function Ql(t,o){return ci.renderToString(t,{displayMode:o,throwOnError:!1})}function ec(t,o){let a=o;for(;(a=t.indexOf("$$",a))!==-1;){if(t[a-1]!=="\\")return a;a+=1}return-1}function tc(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 f=t[d+1];if(f==="$"){a+="$",d+=2;continue}if(f==="("){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+=f===void 0?p:p+f,d+=f===void 0?1:2;continue}if(p==="$"&&t[d+1]==="$"){let f=ec(t,d+2);if(f!==-1){c(),o.push({type:"math",tex:t.slice(d+2,f),display:!0}),d=f+2;continue}}a+=p,d+=1}return c(),o}var nc="code, pre, script, style, svg, aside, math";function rc(t){let o=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,{acceptNode:c=>c.parentElement&&c.parentElement.closest(nc)?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=tc(c.nodeValue);if(d.length===1&&d[0].type==="text"&&d[0].value===c.nodeValue)continue;let p=document.createDocumentFragment();for(let f of d)if(f.type==="text")p.appendChild(document.createTextNode(f.value));else{let m=document.createElement("span");m.innerHTML=Ql(f.tex,f.display),p.appendChild(m.firstElementChild??document.createTextNode(""))}c.parentNode.replaceChild(p,c)}}function di(t){t.querySelectorAll("section[data-math]").forEach(o=>rc(o))}me();fe();me();fe();var Mi=_l(Ni(),1);var Vt=Mi.default;me();fe();function Oi(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"],f=["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"],v=["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"],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"],T=["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"],A=S,N=[...k,...v].filter(Me=>!S.includes(Me)),I={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},Se={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},pe={match:o.concat(/\b/,o.either(...A),/\s*\(/),relevance:0,keywords:{built_in:A}};function Oe(Me){return o.concat(/\b/,o.either(...Me.map(ze=>ze.replace(/\s+/,"\\s+"))),/\b/)}let re={scope:"keyword",match:Oe(T),relevance:0};function ce(Me,{exceptions:ze,when:Ve}={}){let $e=Ve;return ze=ze||[],Me.map(_e=>_e.match(/\|\d+$/)||ze.includes(_e)?_e:$e(_e)?`${_e}|0`:_e)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:ce(N,{when:Me=>Me.length<3}),literal:p,type:m,built_in:P},contains:[{scope:"type",match:Oe(f)},re,pe,I,c,d,t.C_NUMBER_MODE,t.C_BLOCK_COMMENT_MODE,a,Se]}}me();fe();var Li="[A-Za-z$_][0-9A-Za-z$_]*",Wc=["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"],Vc=["true","false","null","undefined","NaN","Infinity"],Ri=["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"],Ii=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Pi=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Zc=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],Jc=[].concat(Pi,Ri,Ii);function Bi(t){let o=t.regex,a=(oe,{after:he})=>{let le="</"+oe[0].slice(1);return oe.input.indexOf(le,he)!==-1},c=Li,d={begin:"<>",end:"</>"},p=/<[A-Za-z0-9\\._:-]+\s*\/>/,f={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(oe,he)=>{let le=oe[0].length+oe.index,Re=oe.input[le];if(Re==="<"||Re===","){he.ignoreMatch();return}Re===">"&&(a(oe,{after:le})||he.ignoreMatch());let Y,s=oe.input.substring(le);if(Y=s.match(/^\s*=/)){he.ignoreMatch();return}if((Y=s.match(/^\s+extends\s+/))&&Y.index===0){he.ignoreMatch();return}}},m={$pattern:Li,keyword:Wc,literal:Vc,built_in:Jc,"variable.language":Zc},v="[0-9](_?[0-9])*",k=`\\.(${v})`,S="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",P={className:"number",variants:[{begin:`(\\b(${S})((${k})|\\.)?|(${k}))[eE][+-]?(${v})\\b`},{begin:`\\b(${S})\\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},T={className:"subst",begin:"\\$\\{",end:"\\}",keywords:m,contains:[]},A={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,T],subLanguage:"xml"}},N={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,T],subLanguage:"css"}},I={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,T],subLanguage:"graphql"}},Se={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,T]},Oe={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]},re=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,A,N,I,Se,{match:/\$\d+/},P];T.contains=re.concat({begin:/\{/,end:/\}/,keywords:m,contains:["self"].concat(re)});let ce=[].concat(Oe,T.contains),Me=ce.concat([{begin:/(\s*)\(/,end:/\)/,keywords:m,contains:["self"].concat(ce)}]),ze={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:m,contains:Me},Ve={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:{_:[...Ri,...Ii]}},_e={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},Ze={variants:[{match:[/function/,/\s+/,c,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[ze],illegal:/%/},bt={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function _(oe){return o.concat("(?!",oe.join("|"),")")}let je={match:o.concat(/\b/,_([...Pi,"super","import"].map(oe=>`${oe}\\s*\\(`)),c,o.lookahead(/\s*\(/)),className:"title.function",relevance:0},gt={begin:o.concat(/\./,o.lookahead(o.concat(c,/(?![0-9A-Za-z$_(])/))),end:c,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},ut={match:[/get|set/,/\s+/,c,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},ze]},Q="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",j={match:[/const|var|let/,/\s+/,c,/\s*/,/=\s*/,/(async\s*)?/,o.lookahead(Q)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[ze]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:m,exports:{PARAMS_CONTAINS:Me,CLASS_REFERENCE:$e},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),_e,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,A,N,I,Se,Oe,{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:[Oe,t.REGEXP_MODE,{className:"function",begin:Q,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:Me}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:d.begin,end:d.end},{match:p},{begin:f.begin,"on:begin":f.isTrulyOpeningTag,end:f.end}],subLanguage:"xml",contains:[{begin:f.begin,end:f.end,skip:!0,contains:["self"]}]}]},Ze,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[ze,t.inherit(t.TITLE_MODE,{begin:c,className:"title.function"})]},{match:/\.\.\./,relevance:0},gt,{match:"\\$"+c,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[ze]},je,bt,Ve,ut,{match:/\$[(.]/}]}}me();fe();var Ss="[A-Za-z$_][0-9A-Za-z$_]*",Di=["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"],qi=["true","false","null","undefined","NaN","Infinity"],Fi=["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"],zi=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Ui=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Hi=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],ji=[].concat(Ui,Fi,zi);function Yc(t){let o=t.regex,a=(oe,{after:he})=>{let le="</"+oe[0].slice(1);return oe.input.indexOf(le,he)!==-1},c=Ss,d={begin:"<>",end:"</>"},p=/<[A-Za-z0-9\\._:-]+\s*\/>/,f={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(oe,he)=>{let le=oe[0].length+oe.index,Re=oe.input[le];if(Re==="<"||Re===","){he.ignoreMatch();return}Re===">"&&(a(oe,{after:le})||he.ignoreMatch());let Y,s=oe.input.substring(le);if(Y=s.match(/^\s*=/)){he.ignoreMatch();return}if((Y=s.match(/^\s+extends\s+/))&&Y.index===0){he.ignoreMatch();return}}},m={$pattern:Ss,keyword:Di,literal:qi,built_in:ji,"variable.language":Hi},v="[0-9](_?[0-9])*",k=`\\.(${v})`,S="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",P={className:"number",variants:[{begin:`(\\b(${S})((${k})|\\.)?|(${k}))[eE][+-]?(${v})\\b`},{begin:`\\b(${S})\\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},T={className:"subst",begin:"\\$\\{",end:"\\}",keywords:m,contains:[]},A={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,T],subLanguage:"xml"}},N={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,T],subLanguage:"css"}},I={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,T],subLanguage:"graphql"}},Se={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,T]},Oe={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]},re=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,A,N,I,Se,{match:/\$\d+/},P];T.contains=re.concat({begin:/\{/,end:/\}/,keywords:m,contains:["self"].concat(re)});let ce=[].concat(Oe,T.contains),Me=ce.concat([{begin:/(\s*)\(/,end:/\)/,keywords:m,contains:["self"].concat(ce)}]),ze={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:m,contains:Me},Ve={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:{_:[...Fi,...zi]}},_e={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},Ze={variants:[{match:[/function/,/\s+/,c,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[ze],illegal:/%/},bt={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function _(oe){return o.concat("(?!",oe.join("|"),")")}let je={match:o.concat(/\b/,_([...Ui,"super","import"].map(oe=>`${oe}\\s*\\(`)),c,o.lookahead(/\s*\(/)),className:"title.function",relevance:0},gt={begin:o.concat(/\./,o.lookahead(o.concat(c,/(?![0-9A-Za-z$_(])/))),end:c,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},ut={match:[/get|set/,/\s+/,c,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},ze]},Q="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",j={match:[/const|var|let/,/\s+/,c,/\s*/,/=\s*/,/(async\s*)?/,o.lookahead(Q)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[ze]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:m,exports:{PARAMS_CONTAINS:Me,CLASS_REFERENCE:$e},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),_e,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,A,N,I,Se,Oe,{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:[Oe,t.REGEXP_MODE,{className:"function",begin:Q,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:Me}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:d.begin,end:d.end},{match:p},{begin:f.begin,"on:begin":f.isTrulyOpeningTag,end:f.end}],subLanguage:"xml",contains:[{begin:f.begin,end:f.end,skip:!0,contains:["self"]}]}]},Ze,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[ze,t.inherit(t.TITLE_MODE,{begin:c,className:"title.function"})]},{match:/\.\.\./,relevance:0},gt,{match:"\\$"+c,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[ze]},je,bt,Ve,ut,{match:/\$[(.]/}]}}function Gi(t){let o=t.regex,a=Yc(t),c=Ss,d=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],p={begin:[/namespace/,/\s+/,t.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},f={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['"]/},v=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],k={$pattern:Ss,keyword:Di.concat(v),literal:qi,built_in:ji.concat(d),"variable.language":Hi},S={className:"meta",begin:"@"+c},P=(I,Se,pe)=>{let Oe=I.contains.findIndex(re=>re.label===Se);if(Oe===-1)throw new Error("can not find mode to replace");I.contains.splice(Oe,1,pe)};Object.assign(a.keywords,k),a.exports.PARAMS_CONTAINS.push(S);let T=a.contains.find(I=>I.scope==="attr"),A=Object.assign({},T,{match:o.concat(c,o.lookahead(/\s*\?:/))});a.exports.PARAMS_CONTAINS.push([a.exports.CLASS_REFERENCE,T,A]),a.contains=a.contains.concat([S,p,f,A]),P(a,"shebang",t.SHEBANG()),P(a,"use_strict",m);let N=a.contains.find(I=>I.label==="func.def");return N.relevance=0,Object.assign(a,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),a}me();fe();function Ki(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"]},v={className:"meta",begin:/^(>>>|\.\.\.) /},k={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,v],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,v],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,v,S,k]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,v,S,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:[t.BACKSLASH_ESCAPE,S,k]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,S,k]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},T="[0-9](_?[0-9])*",A=`(\\b(${T}))?\\.(${T})|\\b(${T})\\.`,N=`\\b|${c.join("|")}`,I={className:"number",relevance:0,variants:[{begin:`(\\b(${T})|(${A}))[eE][+-]?(${T})[jJ]?(?=${N})`},{begin:`(${A})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${N})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${N})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${N})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${N})`},{begin:`\\b(${T})[jJ](?=${N})`}]},Se={className:"comment",begin:o.lookahead(/# type:/),end:/$/,keywords:m,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},pe={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:m,contains:["self",v,I,P,t.HASH_COMMENT_MODE]}]};return k.contains=[P,I,v],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:m,illegal:/(<\/|\?)|=>/,contains:[v,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:[pe]},{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,pe,P]}]}}me();fe();function Wi(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"}}),f={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 v={match:/\\"/},k={className:"string",begin:/'/,end:/'/},S={match:/\\'/},P={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},t.NUMBER_MODE,a]},T=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],A=t.SHEBANG({binary:`(${T.join("|")})`,relevance:10}),N={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"],pe={match:/(\/[a-z._-]+)+/},Oe=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],re=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],ce=["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"],Me=["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:[...Oe,...re,"set","shopt",...ce,...Me]},contains:[A,t.SHEBANG(),N,P,p,f,pe,m,v,k,S,a]}}me();fe();function Vi(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}]},f={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[t.BACKSLASH_ESCAPE,d]},m=t.inherit(f,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),T={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"},A={end:",",endsWithParent:!0,excludeEnd:!0,keywords:o,relevance:0},N={begin:/\{/,end:/\}/,contains:[A],illegal:"\\n",relevance:0},I={begin:"\\[",end:"\\]",contains:[A],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}},T,{className:"number",begin:t.C_NUMBER_RE+"\\b",relevance:0},N,I,p,f],pe=[...Se];return pe.pop(),pe.push(m),A.contains=pe,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:Se}}me();fe();function Zi(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"}}me();fe();var Mr="[0-9](_*[0-9])*",As=`\\.(${Mr})`,_s="[0-9a-fA-F](_*[0-9a-fA-F])*",Ji={className:"number",variants:[{begin:`(\\b(${Mr})((${As})|\\.)?|(${As}))[eE][+-]?(${Mr})[fFdD]?\\b`},{begin:`\\b(${Mr})((${As})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${As})[fFdD]?\\b`},{begin:`\\b(${Mr})[fFdD]\\b`},{begin:`\\b0[xX]((${_s})\\.?|(${_s})?\\.(${_s}))[pP][+-]?(${Mr})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${_s})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function Yi(t,o,a){return a===-1?"":t.replace(o,c=>Yi(t,o,a-1))}function Xi(t){let o=t.regex,a="[\xC0-\u02B8a-zA-Z_$][\xC0-\u02B8a-zA-Z_$0-9]*",c=a+Yi("(?:<"+a+"~~~(?:\\s*,\\s*"+a+"~~~)*>)?",/~~~/g,2),v={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:"@"+a,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},S={className:"params",begin:/\(/,end:/\)/,keywords:v,relevance:0,contains:[t.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:v,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:v,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:v,relevance:0,contains:[k,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,Ji,t.C_BLOCK_COMMENT_MODE]},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},Ji,k]}}me();fe();function Qi(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:/["']/}]}]}}me();fe();function ea(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*\(/))},f="([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"],v=["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!"],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:v,built_in:k},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_]+)"+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+/,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:k,type:S}},{className:"punctuation",begin:"->"},p]}}me();fe();function ta(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/}]},f=t.inherit(p,{begin:/\(/,end:/\)/}),m=t.inherit(t.APOS_STRING_MODE,{className:"string"}),v=t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),k={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,v,m,f,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[p,f,v,m]}]}]},t.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},d,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[v]},{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:o.concat(/</,o.lookahead(o.concat(a,o.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:a,relevance:0,starts:k}]},{className:"tag",begin:o.concat(/<\//,o.lookahead(o.concat(a,/>/))),contains:[{className:"name",begin:a,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}me();fe();var Xc=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_-]*/}}),Qc=["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"],ed=["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"],td=[...Qc,...ed],nd=["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(),rd=["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(),sd=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),od=["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 na(t){let o=t.regex,a=Xc(t),c={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},d="and or not only",p=/@-?\w[\w]*(-\w+)*/,f="[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:"\\."+f,relevance:0},a.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+rd.join("|")+")"},{begin:":(:)?("+sd.join("|")+")"}]},a.CSS_VARIABLE,{className:"attribute",begin:"\\b("+od.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:nd.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...m,a.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+td.join("|")+")\\b"}]}}me();fe();function ra(t){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}Vt.registerLanguage("sql",Oi);Vt.registerLanguage("javascript",Bi);Vt.registerLanguage("typescript",Gi);Vt.registerLanguage("python",Ki);Vt.registerLanguage("bash",Wi);Vt.registerLanguage("yaml",Vi);Vt.registerLanguage("json",Zi);Vt.registerLanguage("java",Xi);Vt.registerLanguage("go",Qi);Vt.registerLanguage("rust",ea);Vt.registerLanguage("xml",ta);Vt.registerLanguage("css",na);Vt.registerLanguage("plaintext",ra);Vt.registerAliases(["js"],{languageName:"javascript"});Vt.registerAliases(["ts"],{languageName:"typescript"});Vt.registerAliases(["shell","sh","zsh"],{languageName:"bash"});Vt.registerAliases(["html"],{languageName:"xml"});Vt.registerAliases(["text","plain"],{languageName:"plaintext"});function id(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 f=parseInt(p[1],10),m=p[2]?parseInt(p[2],10):f;for(let v=f;v<=Math.min(m,o);v++)c.push(v)}return c})}function ad(t){let o=[[]];for(function a(c,d){for(let p of c.childNodes)p.nodeType===Node.TEXT_NODE?p.nodeValue.split(`
|
|
100
|
-
`).forEach((
|
|
99
|
+
`+p.toString())]);return R.style.color=C.errorColor,R.style.whiteSpace="pre-line",R}(u,r,i)}};return{version:"0.13.3",render:qe,renderToString:function(r,o){return nt(r,o).toMarkup()},renderMathInElement:function(r,o){if(!r)throw new Error("No element provided to render");let i={};for(let u in o)Object.prototype.hasOwnProperty.call(o,u)&&(i[u]=o[u]);i.fences?i.delimiters=(u=>u==="$"||u==="("?ne[u]:u==="$+"||u==="(+"?ne[u.slice(0,1)].concat($e):u==="ams"?$e:u==="all"?ne["("].concat(ne.$).concat($e):Ge)(i.fences):i.delimiters=i.delimiters||Ge,i.ignoredTags=i.ignoredTags||["script","noscript","style","textarea","pre","code","option"],i.ignoredClasses=i.ignoredClasses||[],i.errorCallback=i.errorCallback||console.error,i.macros=i.macros||{},it(r,i),X(r)},postProcess:X,ParseError:e,definePreamble:function(r,o){let i=new $(o);if(i.macros={},!(typeof r=="string"||r instanceof String))throw new TypeError("Temml can only parse string typed expression");let u=new _t(r,i,!0);return delete u.gullet.macros.current["\\df@tag"],u.parse()},__parse:function(r,o){let i=new $(o);return kt(r,i)},__renderToMathMLTree:nt,__defineSymbol:l,__defineMacro:xe}}(),Sl=$l;function Kp(e,t){return Sl.renderToString(e,{displayMode:t,throwOnError:!1})}function Wp(e,t){let n=t;for(;(n=e.indexOf("$$",n))!==-1;){if(e[n-1]!=="\\")return n;n+=1}return-1}function Vp(e){let t=[],n="",s=()=>{n&&(t.push({type:"text",value:n}),n="")},a=0;for(;a<e.length;){let c=e[a];if(c==="\\"){let h=e[a+1];if(h==="$"){n+="$",a+=2;continue}if(h==="("){let f=e.indexOf("\\)",a+2);if(f!==-1){s(),t.push({type:"math",tex:e.slice(a+2,f),display:!1}),a=f+2;continue}}n+=h===void 0?c:c+h,a+=h===void 0?1:2;continue}if(c==="$"&&e[a+1]==="$"){let h=Wp(e,a+2);if(h!==-1){s(),t.push({type:"math",tex:e.slice(a+2,h),display:!0}),a=h+2;continue}}n+=c,a+=1}return s(),t}var Jp="code, pre, script, style, svg, aside, math";function Yp(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:s=>s.parentElement&&s.parentElement.closest(Jp)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}),n=[];for(let s=t.nextNode();s;s=t.nextNode())(s.nodeValue.includes("$")||s.nodeValue.includes("\\("))&&n.push(s);for(let s of n){let a=Vp(s.nodeValue);if(a.length===1&&a[0].type==="text"&&a[0].value===s.nodeValue)continue;let c=document.createDocumentFragment();for(let h of a)if(h.type==="text")c.appendChild(document.createTextNode(h.value));else{let f=document.createElement("span");f.innerHTML=Kp(h.tex,h.display),c.appendChild(f.firstElementChild??document.createTextNode(""))}s.parentNode.replaceChild(c,s)}}function Al(e){e.querySelectorAll("section[data-math]").forEach(t=>Yp(t))}Se();Ae();Se();Ae();var Wl=op(Kl(),1);var Dn=Wl.default;Se();Ae();function Vl(e){let t=e.regex,n=e.COMMENT("--","$"),s={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},a={begin:/"/,end:/"/,contains:[{match:/""/}]},c=["true","false","unknown"],h=["double precision","large object","with timezone","without timezone"],f=["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"],g=["add","asc","collation","desc","final","first","last","view"],b=["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"],y=["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"],$=["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"],S=["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"],A=y,E=[...b,...g].filter(D=>!y.includes(D)),L={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},P={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},j={match:t.concat(/\b/,t.either(...A),/\s*\(/),relevance:0,keywords:{built_in:A}};function U(D){return t.concat(/\b/,t.either(...D.map(z=>z.replace(/\s+/,"\\s+"))),/\b/)}let oe={scope:"keyword",match:U(S),relevance:0};function pe(D,{exceptions:z,when:Ce}={}){let ee=Ce;return z=z||[],D.map(re=>re.match(/\|\d+$/)||z.includes(re)?re:ee(re)?`${re}|0`:re)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:pe(E,{when:D=>D.length<3}),literal:c,type:f,built_in:$},contains:[{scope:"type",match:U(h)},oe,j,L,s,a,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,P]}}Se();Ae();var Jl="[A-Za-z$_][0-9A-Za-z$_]*",qh=["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"],jh=["true","false","null","undefined","NaN","Infinity"],Yl=["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"],Zl=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Xl=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Hh=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],zh=[].concat(Xl,Yl,Zl);function Ql(e){let t=e.regex,n=(T,{after:F})=>{let se="</"+T[0].slice(1);return T.input.indexOf(se,F)!==-1},s=Jl,a={begin:"<>",end:"</>"},c=/<[A-Za-z0-9\\._:-]+\s*\/>/,h={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(T,F)=>{let se=T[0].length+T.index,_e=T.input[se];if(_e==="<"||_e===","){F.ignoreMatch();return}_e===">"&&(n(T,{after:se})||F.ignoreMatch());let Te,l=T.input.substring(se);if(Te=l.match(/^\s*=/)){F.ignoreMatch();return}if((Te=l.match(/^\s+extends\s+/))&&Te.index===0){F.ignoreMatch();return}}},f={$pattern:Jl,keyword:qh,literal:jh,built_in:zh,"variable.language":Hh},g="[0-9](_?[0-9])*",b=`\\.(${g})`,y="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",$={className:"number",variants:[{begin:`(\\b(${y})((${b})|\\.)?|(${b}))[eE][+-]?(${g})\\b`},{begin:`\\b(${y})\\b((${b})\\b|\\.)?|(${b})\\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},S={className:"subst",begin:"\\$\\{",end:"\\}",keywords:f,contains:[]},A={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,S],subLanguage:"xml"}},E={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,S],subLanguage:"css"}},L={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,S],subLanguage:"graphql"}},P={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,S]},U={className:"comment",variants:[e.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:s+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},oe=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,A,E,L,P,{match:/\$\d+/},$];S.contains=oe.concat({begin:/\{/,end:/\}/,keywords:f,contains:["self"].concat(oe)});let pe=[].concat(U,S.contains),D=pe.concat([{begin:/(\s*)\(/,end:/\)/,keywords:f,contains:["self"].concat(pe)}]),z={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:f,contains:D},Ce={variants:[{match:[/class/,/\s+/,s,/\s+/,/extends/,/\s+/,t.concat(s,"(",t.concat(/\./,s),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,s],scope:{1:"keyword",3:"title.class"}}]},ee={relevance:0,match:t.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:{_:[...Yl,...Zl]}},re={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},le={variants:[{match:[/function/,/\s+/,s,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[z],illegal:/%/},ie={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function I(T){return t.concat("(?!",T.join("|"),")")}let ce={match:t.concat(/\b/,I([...Xl,"super","import"].map(T=>`${T}\\s*\\(`)),s,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},de={begin:t.concat(/\./,t.lookahead(t.concat(s,/(?![0-9A-Za-z$_(])/))),end:s,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},Ie={match:[/get|set/,/\s+/,s,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},z]},V="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",Z={match:[/const|var|let/,/\s+/,s,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(V)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[z]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:f,exports:{PARAMS_CONTAINS:D,CLASS_REFERENCE:ee},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),re,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,A,E,L,P,U,{match:/\$\d+/},$,ee,{scope:"attr",match:s+t.lookahead(":"),relevance:0},Z,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[U,e.REGEXP_MODE,{className:"function",begin:V,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:f,contains:D}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:a.begin,end:a.end},{match:c},{begin:h.begin,"on:begin":h.isTrulyOpeningTag,end:h.end}],subLanguage:"xml",contains:[{begin:h.begin,end:h.end,skip:!0,contains:["self"]}]}]},le,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[z,e.inherit(e.TITLE_MODE,{begin:s,className:"title.function"})]},{match:/\.\.\./,relevance:0},de,{match:"\\$"+s,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[z]},ce,ie,Ce,Ie,{match:/\$[(.]/}]}}Se();Ae();var ii="[A-Za-z$_][0-9A-Za-z$_]*",ec=["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"],tc=["true","false","null","undefined","NaN","Infinity"],nc=["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"],rc=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],sc=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],oc=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],ic=[].concat(sc,nc,rc);function Uh(e){let t=e.regex,n=(T,{after:F})=>{let se="</"+T[0].slice(1);return T.input.indexOf(se,F)!==-1},s=ii,a={begin:"<>",end:"</>"},c=/<[A-Za-z0-9\\._:-]+\s*\/>/,h={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(T,F)=>{let se=T[0].length+T.index,_e=T.input[se];if(_e==="<"||_e===","){F.ignoreMatch();return}_e===">"&&(n(T,{after:se})||F.ignoreMatch());let Te,l=T.input.substring(se);if(Te=l.match(/^\s*=/)){F.ignoreMatch();return}if((Te=l.match(/^\s+extends\s+/))&&Te.index===0){F.ignoreMatch();return}}},f={$pattern:ii,keyword:ec,literal:tc,built_in:ic,"variable.language":oc},g="[0-9](_?[0-9])*",b=`\\.(${g})`,y="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",$={className:"number",variants:[{begin:`(\\b(${y})((${b})|\\.)?|(${b}))[eE][+-]?(${g})\\b`},{begin:`\\b(${y})\\b((${b})\\b|\\.)?|(${b})\\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},S={className:"subst",begin:"\\$\\{",end:"\\}",keywords:f,contains:[]},A={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,S],subLanguage:"xml"}},E={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,S],subLanguage:"css"}},L={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,S],subLanguage:"graphql"}},P={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,S]},U={className:"comment",variants:[e.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:s+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},oe=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,A,E,L,P,{match:/\$\d+/},$];S.contains=oe.concat({begin:/\{/,end:/\}/,keywords:f,contains:["self"].concat(oe)});let pe=[].concat(U,S.contains),D=pe.concat([{begin:/(\s*)\(/,end:/\)/,keywords:f,contains:["self"].concat(pe)}]),z={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:f,contains:D},Ce={variants:[{match:[/class/,/\s+/,s,/\s+/,/extends/,/\s+/,t.concat(s,"(",t.concat(/\./,s),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,s],scope:{1:"keyword",3:"title.class"}}]},ee={relevance:0,match:t.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:{_:[...nc,...rc]}},re={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},le={variants:[{match:[/function/,/\s+/,s,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[z],illegal:/%/},ie={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function I(T){return t.concat("(?!",T.join("|"),")")}let ce={match:t.concat(/\b/,I([...sc,"super","import"].map(T=>`${T}\\s*\\(`)),s,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},de={begin:t.concat(/\./,t.lookahead(t.concat(s,/(?![0-9A-Za-z$_(])/))),end:s,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},Ie={match:[/get|set/,/\s+/,s,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},z]},V="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",Z={match:[/const|var|let/,/\s+/,s,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(V)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[z]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:f,exports:{PARAMS_CONTAINS:D,CLASS_REFERENCE:ee},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),re,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,A,E,L,P,U,{match:/\$\d+/},$,ee,{scope:"attr",match:s+t.lookahead(":"),relevance:0},Z,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[U,e.REGEXP_MODE,{className:"function",begin:V,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:f,contains:D}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:a.begin,end:a.end},{match:c},{begin:h.begin,"on:begin":h.isTrulyOpeningTag,end:h.end}],subLanguage:"xml",contains:[{begin:h.begin,end:h.end,skip:!0,contains:["self"]}]}]},le,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[z,e.inherit(e.TITLE_MODE,{begin:s,className:"title.function"})]},{match:/\.\.\./,relevance:0},de,{match:"\\$"+s,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[z]},ce,ie,Ce,Ie,{match:/\$[(.]/}]}}function ac(e){let t=e.regex,n=Uh(e),s=ii,a=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],c={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},h={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:a},contains:[n.exports.CLASS_REFERENCE]},f={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},g=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],b={$pattern:ii,keyword:ec.concat(g),literal:tc,built_in:ic.concat(a),"variable.language":oc},y={className:"meta",begin:"@"+s},$=(L,P,j)=>{let U=L.contains.findIndex(oe=>oe.label===P);if(U===-1)throw new Error("can not find mode to replace");L.contains.splice(U,1,j)};Object.assign(n.keywords,b),n.exports.PARAMS_CONTAINS.push(y);let S=n.contains.find(L=>L.scope==="attr"),A=Object.assign({},S,{match:t.concat(s,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,S,A]),n.contains=n.contains.concat([y,c,h,A]),$(n,"shebang",e.SHEBANG()),$(n,"use_strict",f);let E=n.contains.find(L=>L.label==="func.def");return E.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}Se();Ae();function lc(e){let t=e.regex,n=/[\p{XID_Start}_]\p{XID_Continue}*/u,s=["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"],f={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:s,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"]},g={className:"meta",begin:/^(>>>|\.\.\.) /},b={className:"subst",begin:/\{/,end:/\}/,keywords:f,illegal:/#/},y={begin:/\{\{/,relevance:0},$={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,g],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,g],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,g,y,b]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,g,y,b]},{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:[e.BACKSLASH_ESCAPE,y,b]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,y,b]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},S="[0-9](_?[0-9])*",A=`(\\b(${S}))?\\.(${S})|\\b(${S})\\.`,E=`\\b|${s.join("|")}`,L={className:"number",relevance:0,variants:[{begin:`(\\b(${S})|(${A}))[eE][+-]?(${S})[jJ]?(?=${E})`},{begin:`(${A})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${E})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${E})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${E})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${E})`},{begin:`\\b(${S})[jJ](?=${E})`}]},P={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:f,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},j={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:f,contains:["self",g,L,$,e.HASH_COMMENT_MODE]}]};return b.contains=[$,L,g],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:f,illegal:/(<\/|\?)|=>/,contains:[g,L,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},$,P,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[j]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[L,j,$]}]}}Se();Ae();function cc(e){let t=e.regex,n={},s={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},s]});let a={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},c=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),h={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},f={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,a]};a.contains.push(f);let g={match:/\\"/},b={className:"string",begin:/'/,end:/'/},y={match:/\\'/},$={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},S=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],A=e.SHEBANG({binary:`(${S.join("|")})`,relevance:10}),E={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},L=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],P=["true","false"],j={match:/(\/[a-z._-]+)+/},U=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],oe=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],pe=["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"],D=["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:L,literal:P,built_in:[...U,...oe,"set","shopt",...pe,...D]},contains:[A,e.SHEBANG(),E,$,c,h,j,f,g,b,y,n]}}Se();Ae();function dc(e){let t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",s={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},a={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},c={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},h={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,a]},f=e.inherit(h,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),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"},A={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},E={begin:/\{/,end:/\}/,contains:[A],illegal:"\\n",relevance:0},L={begin:"\\[",end:"\\]",contains:[A],illegal:"\\n",relevance:0},P=[s,{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+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},S,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},E,L,c,h],j=[...P];return j.pop(),j.push(f),A.contains=j,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:P}}Se();Ae();function uc(e){let t={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},s=["true","false","null"],a={scope:"literal",beginKeywords:s.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:s},contains:[t,n,e.QUOTE_STRING_MODE,a,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}Se();Ae();var Xs="[0-9](_*[0-9])*",ai=`\\.(${Xs})`,li="[0-9a-fA-F](_*[0-9a-fA-F])*",pc={className:"number",variants:[{begin:`(\\b(${Xs})((${ai})|\\.)?|(${ai}))[eE][+-]?(${Xs})[fFdD]?\\b`},{begin:`\\b(${Xs})((${ai})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${ai})[fFdD]?\\b`},{begin:`\\b(${Xs})[fFdD]\\b`},{begin:`\\b0[xX]((${li})\\.?|(${li})?\\.(${li}))[pP][+-]?(${Xs})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${li})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function hc(e,t,n){return n===-1?"":e.replace(t,s=>hc(e,t,n-1))}function fc(e){let t=e.regex,n="[\xC0-\u02B8a-zA-Z_$][\xC0-\u02B8a-zA-Z_$0-9]*",s=n+hc("(?:<"+n+"~~~(?:\\s*,\\s*"+n+"~~~)*>)?",/~~~/g,2),g={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"]},b={className:"meta",begin:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},y={className:"params",begin:/\(/,end:/\)/,keywords:g,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:g,illegal:/<\/|#/,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[e.BACKSLASH_ESCAPE]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,n],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[t.concat(/(?!else)/,n),/\s+/,n,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,n],className:{1:"keyword",3:"title.class"},contains:[y,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+s+"\\s+)",e.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:g,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:g,relevance:0,contains:[b,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,pc,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},pc,b]}}Se();Ae();function mc(e){let c={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:c,illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"string",variants:[e.QUOTE_STRING_MODE,e.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:[e.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:c,illegal:/["']/}]}]}}Se();Ae();function gc(e){let t=e.regex,n=/(r#)?/,s=t.concat(n,e.UNDERSCORE_IDENT_RE),a=t.concat(n,e.IDENT_RE),c={className:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!let|for|while|if|else|match\b)/,a,t.lookahead(/\s*\(/))},h="([ui](8|16|32|64|128|size)|f(32|64))?",f=["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"],g=["true","false","Some","None","Ok","Err"],b=["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!"],y=["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:e.IDENT_RE+"!?",type:y,keyword:f,literal:g,built_in:b},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.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_]+)"+h},{begin:"\\b0o([0-7_]+)"+h},{begin:"\\b0x([A-Fa-f0-9_]+)"+h},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+h}],relevance:0},{begin:[/fn/,/\s+/,s],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,s],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,s,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,s],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,s],className:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:b,type:y}},{className:"punctuation",begin:"->"},c]}}Se();Ae();function bc(e){let t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),s=/[\p{L}0-9._:-]+/u,a={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},c={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},h=e.inherit(c,{begin:/\(/,end:/\)/}),f=e.inherit(e.APOS_STRING_MODE,{className:"string"}),g=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),b={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:s,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[a]},{begin:/'/,end:/'/,contains:[a]},{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:[c,g,f,h,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[c,h,g,f]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},a,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[g]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[b],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[b],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:b}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}Se();Ae();var Gh=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.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:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.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_-]*/}}),Kh=["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"],Wh=["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"],Vh=[...Kh,...Wh],Jh=["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(),Yh=["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(),Zh=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),Xh=["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 yc(e){let t=e.regex,n=Gh(e),s={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},a="and or not only",c=/@-?\w[\w]*(-\w+)*/,h="[a-zA-Z-][a-zA-Z0-9_-]*",f=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,s,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+h,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+Yh.join("|")+")"},{begin:":(:)?("+Zh.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+Xh.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...f,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...f,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:c},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:a,attribute:Jh.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...f,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+Vh.join("|")+")\\b"}]}}Se();Ae();function wc(e){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}Dn.registerLanguage("sql",Vl);Dn.registerLanguage("javascript",Ql);Dn.registerLanguage("typescript",ac);Dn.registerLanguage("python",lc);Dn.registerLanguage("bash",cc);Dn.registerLanguage("yaml",dc);Dn.registerLanguage("json",uc);Dn.registerLanguage("java",fc);Dn.registerLanguage("go",mc);Dn.registerLanguage("rust",gc);Dn.registerLanguage("xml",bc);Dn.registerLanguage("css",yc);Dn.registerLanguage("plaintext",wc);Dn.registerAliases(["js"],{languageName:"javascript"});Dn.registerAliases(["ts"],{languageName:"typescript"});Dn.registerAliases(["shell","sh","zsh"],{languageName:"bash"});Dn.registerAliases(["html"],{languageName:"xml"});Dn.registerAliases(["text","plain"],{languageName:"plaintext"});function Qh(e,t){return e.split("|").map(n=>{if(n=n.trim(),n===""||n==="all")return Array.from({length:t},(a,c)=>c+1);let s=[];for(let a of n.split(",")){let c=a.trim().match(/^(\d+)(?:-(\d+))?$/);if(!c)continue;let h=parseInt(c[1],10),f=c[2]?parseInt(c[2],10):h;for(let g=h;g<=Math.min(f,t);g++)s.push(g)}return s})}function ef(e){let t=[[]];for(function n(s,a){for(let c of s.childNodes)c.nodeType===Node.TEXT_NODE?c.nodeValue.split(`
|
|
100
|
+
`).forEach((f,g)=>{g>0&&t.push([]),f&&t[t.length-1].push({path:a,text:f})}):c.nodeType===Node.ELEMENT_NODE&&n(c,[...a,c])}(e,[]);t.length&&t[t.length-1].length===0;)t.pop();e.textContent="";for(let n of t){let s=document.createElement("span");s.className="code-line";for(let{path:a,text:c}of n){let h=s;for(let f of a){let g=h.lastChild;g&&g.__orig===f||(g=f.cloneNode(!1),g.__orig=f,h.appendChild(g)),h=g}h.appendChild(document.createTextNode(c))}e.appendChild(s)}return e.querySelectorAll(":scope > .code-line")}function tf(e,t){if(e.length===t)return"all lines";let n=[...e],s=[],a=n[0],c=n[0];for(let h of n.slice(1)){if(h===c+1){c=h;continue}s.push(a===c?`${a}`:`${a}-${c}`),a=c=h}return s.push(a===c?`${a}`:`${a}-${c}`),`lines ${s.join(",")}`}function oa(e,t){e.querySelectorAll("pre > code").forEach(n=>{let s=[...n.classList].find(y=>y.startsWith("language-")),a=s?s.slice(9):null,c=n.textContent.replace(/^\n/,"").replace(/\s+$/,"");a&&Dn.getLanguage(a)?n.innerHTML=Dn.highlight(c,{language:a}).value:n.textContent=c,n.classList.add("hljs");let h=n.parentElement,f=ef(n);h.hasAttribute("data-lines-numbers")&&h.classList.add("line-numbers");let g=h.getAttribute("data-lines");if(!g)return;let b=Qh(g,f.length);h.classList.add("stepping"),t(h,{count:b.length,label:y=>y===0?"code":tf(b[y-1],f.length),apply(y){if(f.forEach(A=>A.classList.remove("line-hl","line-dim")),y===0)return;let $=new Set(b[y-1]),S=$.size===f.length;f.forEach((A,E)=>{$.has(E+1)?A.classList.add("line-hl"):S||A.classList.add("line-dim")})}})})}Se();Ae();Se();Ae();function Nn(e,t=null){try{let n=localStorage.getItem(e);return n??t}catch{return t}}function er(e,t=null){try{let n=localStorage.getItem(e);if(n==null)return t;let s=JSON.parse(n);return s??t}catch{return t}}function yn(e,t){try{return t==null?localStorage.removeItem(e):localStorage.setItem(e,String(t)),!0}catch{return!1}}function xr(e,t){return yn(e,JSON.stringify(t))}Se();Ae();function vc(e){let t=[];for(let n of((e??"").match(/[^.!?…]+[.!?…]+[”’"')\]]*|[^.!?…]+$/g)??[]).map(s=>s.trim()).filter(Boolean)){let s=t.length?cf.exec(n):null;s&&(t[t.length-1]+=` ${s[1]}`,n=n.slice(s[0].length)),n&&(t.length&&lf.test(n)?t[t.length-1]+=` ${n}`:t.push(n))}return t}var Xr="\u27E8PAUSE\u27E9",vs="\u27E8CLICK\u27E9",ia=Xr+Xr,nf="[slow]",rf={pause:Xr,"short pause":Xr,click:vs,slow:nf,"long pause":ia},kc=(e,t)=>e?"":rf[t.toLowerCase().replace(/\s+/g," ")],sf=/\[\s*(\/?)\s*(long\s+pause|short\s+pause|pause|click|slow)\s*\]|<\s*(\/?)\s*(long\s+pause|short\s+pause|pause|click|slow)\s*\/?\s*>|<\s*(\/?)\s*(long\s+pause|short\s+pause|pause|click|slow)\s*\/?\s*>|⟨\s*(\/?)\s*(long\s+pause|short\s+pause|pause|click|slow)\s*⟩/gi,aa=e=>String(e??"").replace(sf,(t,n,s,a,c,h,f,g,b)=>kc(n||a||h||g,s||c||f||b)),of=/<(\/?)\s*(pause|click|slow)\b[^>]*>/gi,af=e=>String(e??"").replace(of,(t,n,s)=>kc(n,s)),xc=e=>aa(af(e)),Ec=e=>String(e??"").replaceAll(ia,"[long pause]").replaceAll(Xr,"[pause]").replaceAll(vs,"[click]"),$c=e=>So(e)?String(e??"").replaceAll(ia," [long pause] ").replaceAll(Xr," [pause] ").replace(/[ \t]+/g," ").trim():String(e??""),Sc=/\[\s*\p{L}[\p{L}' -]{0,38}\]/gu,lf=/^(?:\[\s*\p{L}[\p{L}' -]{0,38}\]\s*)+$/u,cf=/^((?:\[\s*\p{L}[\p{L}' -]{0,38}\]\s*)*\[\s*(?:long\s+|short\s+)?pause\s*\])\s*/iu,qs=e=>String(e??"").replace(Sc," ").replace(/[ \t]+/g," ").replace(/ ([.,;:!?…])/g,"$1").trim(),Ac=(e,t)=>String(e??"").replace(Sc,n=>t(n.slice(1,-1).trim()));var df=e=>String(e??"").replaceAll(Xr," "),ci=e=>df(e).replace(/\s+/g," ").trim(),uf=e=>qs(ci(e)),So=e=>uf(e)!=="";function Cc(e){let t=[],n=0;return String(e??"").split(Xr).forEach((s,a)=>{a>0&&(t.length?t[t.length-1].pause++:n++);let c=s.replace(/\s+/g," ").trim();c&&t.push({text:c,pause:0})}),{lead:n,runs:t}}var Nc=()=>"decklight-timings:"+(typeof location<"u"?location.pathname:"");function pf(e,t=null){let n=e.map(s=>{let a=Number(s?.dataset?.timing);return Number.isFinite(a)&&a>0?a:null});return n.some(s=>s!=null)||!t?n:e.map((s,a)=>{let c=Number(t[a]);return Number.isFinite(c)&&c>0?c:null})}function Qs(e){return xc(e||"").split(vs).map(t=>Ac(t,n=>`<span class="cue tag">${n}</span>`).replaceAll(Xr,'<span class="cue">PAUSE</span>'))}function la(e){let t="width=1100,height=700",n=window.open("","decklight-speaker",t);if(!n)return null;let s=!1;try{s=n.document.body?n.document.body.childNodes.length>0:!1}catch{s=!0}if(s){try{n.close()}catch{}if(n=window.open("","decklight-speaker",t),!n)return null;try{n.document}catch{return null}}let a=()=>{let h=new URL(location.href);return h.searchParams.set("embedded",""),h.hash="",h.href};window.__decklightBridge={subscribe(h){e.__speakerCb=h},async saveTimings(h){let f=h.map((g,b)=>({slide:b+1,seconds:Math.round(g||0)})).filter(g=>g.seconds>0);return e.__saveTimings?(await e.__saveTimings(f),"deck"):(xr(Nc(),h.map(g=>Math.round(g||0))),"browser")},getState:()=>Tc(e,a()),next:()=>e.next(),prev:()=>e.prev(),transcript:()=>e.transcript?.data?.()??[],goto:h=>e.goto(h,0,{force:!0})},e.__notifySpeaker=()=>{e.__speakerCb&&!n.closed&&e.__speakerCb(Tc(e,a()))};let c=`${e.config.width} / ${e.config.height}`;return n.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;
|
|
@@ -126,7 +126,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),le=Q,he=j),oe===void 0
|
|
|
126
126
|
.thumbs { display:flex; flex-direction:column; gap:10px; min-height:0; align-items:start; }
|
|
127
127
|
/* Panes keep the presentation's aspect ratio: width-driven, capped so a
|
|
128
128
|
short window can't push the notes off screen. */
|
|
129
|
-
.thumb { width:min(100%, calc(42vh * (${
|
|
129
|
+
.thumb { width:min(100%, calc(42vh * (${c}))); aspect-ratio:${c}; border:1px solid #333; border-radius:8px; overflow:hidden; position:relative; }
|
|
130
130
|
.thumb .tag { position:absolute; top:6px; left:8px; z-index:2; background:#0009; padding:1px 8px; border-radius:4px; font-size:11px; }
|
|
131
131
|
iframe { width:100%; height:100%; border:0; background:#000; }
|
|
132
132
|
aside { grid-column:1/3; overflow:auto; background:#1b1b1b; border-radius:8px; padding:14px 16px; font-size:16px; line-height:1.65; }
|
|
@@ -134,6 +134,16 @@ https://github.com/highlightjs/highlight.js/issues/2277`),le=Q,he=j),oe===void 0
|
|
|
134
134
|
aside .seg.now { opacity:1; background:#2d2d00; outline:2px solid #665; border-radius:4px; }
|
|
135
135
|
aside .seg.said { opacity:.8; }
|
|
136
136
|
.cue { display:inline-block; background:#553; color:#ffc; font-size:11px; border-radius:4px; padding:0 6px; margin:0 4px; }
|
|
137
|
+
.cue.tag { background:#354; color:#dfe; font-style:italic; }
|
|
138
|
+
/* the script view (SPEC PRESENTING_CHROME, the transcript): the whole deck's
|
|
139
|
+
notes in the notes pane, the slide on screen lit and kept in view */
|
|
140
|
+
#script.on { background:#173a5c; color:#cfe6ff; }
|
|
141
|
+
.sc-slide { margin:0 0 1.1em; opacity:.6; }
|
|
142
|
+
.sc-slide.now { opacity:1; }
|
|
143
|
+
.sc-title { font-weight:700; cursor:pointer; color:#9ecbff; margin-bottom:.2em; }
|
|
144
|
+
.sc-slide.now .sc-title { color:#ffe38a; }
|
|
145
|
+
.sc-title:hover { text-decoration:underline; }
|
|
146
|
+
.sc-seg { margin:.25em 0; }
|
|
137
147
|
footer { grid-column:1/3; color:#888; font-size:12px; display:flex; gap:14px; overflow:auto; white-space:nowrap; }
|
|
138
148
|
footer .step.now { color:#ffc; }
|
|
139
149
|
</style></head><body>
|
|
@@ -143,7 +153,8 @@ https://github.com/highlightjs/highlight.js/issues/2277`),le=Q,he=j),oe===void 0
|
|
|
143
153
|
<span id="pos"></span>
|
|
144
154
|
<button id="prev">\u25C0 prev</button>
|
|
145
155
|
<button id="next">next \u25B6</button>
|
|
146
|
-
<button id="mode" title="S toggles rehearse mode (cue cards instead of prose)">speak</button>
|
|
156
|
+
<button id="mode" title="S or \u2325\u23CE toggles rehearse mode (cue cards instead of prose)">speak</button>
|
|
157
|
+
<button id="script" title="the whole deck's notes, the slide on screen lit; a slide's title goes there">script</button>
|
|
147
158
|
<button id="rec" title="record how long each slide takes, then save the timings onto the deck">\u23F1 rehearse timings</button>
|
|
148
159
|
<span id="pace" class="pace"></span>
|
|
149
160
|
<img id="qr" alt="scan to use your phone as a remote" title="scan to use your phone as a remote \u2014 click to enlarge" hidden>
|
|
@@ -190,7 +201,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),le=Q,he=j),oe===void 0
|
|
|
190
201
|
rec.cur = slide; rec.since = Date.now();
|
|
191
202
|
};
|
|
192
203
|
// Start/stop from the button, or from the deck's palette via
|
|
193
|
-
// window.__decklightSpeakerRec (like __decklightSpeakerToggle for
|
|
204
|
+
// window.__decklightSpeakerRec (like __decklightSpeakerToggle for \u2325\u23CE).
|
|
194
205
|
// start === true only ever starts: a palette row that opened this window
|
|
195
206
|
// to begin a rehearsal must not stop one already running.
|
|
196
207
|
const toggleRec = async (start) => {
|
|
@@ -205,7 +216,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),le=Q,he=j),oe===void 0
|
|
|
205
216
|
$('#rec').classList.remove('on'); $('#rec').textContent = '\u23F1 rehearse timings';
|
|
206
217
|
try {
|
|
207
218
|
const where = api ? await api.saveTimings(rec.spent) : 'nowhere';
|
|
208
|
-
$('#pace').textContent = where === 'deck' ? 'timings saved onto the deck' : where === 'browser' ? 'timings kept in this browser (no
|
|
219
|
+
$('#pace').textContent = where === 'deck' ? 'timings saved onto the deck' : where === 'browser' ? 'timings kept in this browser (no edit server to write the deck)' : 'timings not saved';
|
|
209
220
|
$('#pace').classList.remove('over');
|
|
210
221
|
} catch (e) { $('#pace').textContent = 'could not save timings: ' + String(e.message || e); }
|
|
211
222
|
};
|
|
@@ -215,7 +226,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),le=Q,he=j),oe===void 0
|
|
|
215
226
|
$('#next').onclick = () => api && api.next();
|
|
216
227
|
// speak = full prose notes; rehearse = the deck's aside.rehearse cue cards
|
|
217
228
|
// (same \u27E8CLICK\u27E9 segmentation, a few words per segment). S toggles \u2014 from
|
|
218
|
-
// this window or remotely via window.__decklightSpeakerToggle (deck's
|
|
229
|
+
// this window or remotely via window.__decklightSpeakerToggle (the deck's \u2325\u23CE).
|
|
219
230
|
let mode = 'speak', lastSt = null;
|
|
220
231
|
window.__decklightSpeakerToggle = () => {
|
|
221
232
|
mode = mode === 'speak' ? 'rehearse' : 'speak';
|
|
@@ -225,21 +236,49 @@ https://github.com/highlightjs/highlight.js/issues/2277`),le=Q,he=j),oe===void 0
|
|
|
225
236
|
if (lastSt) render(lastSt);
|
|
226
237
|
};
|
|
227
238
|
$('#mode').onclick = window.__decklightSpeakerToggle;
|
|
239
|
+
// the script view: the deck's whole transcript in the notes pane. On from
|
|
240
|
+
// the button, or from the deck's palette (Transcript\u2026) through
|
|
241
|
+
// window.__decklightSpeakerScript(true), which only ever turns it on.
|
|
242
|
+
let script = false;
|
|
243
|
+
window.__decklightSpeakerScript = (on) => {
|
|
244
|
+
script = on === true ? true : !script;
|
|
245
|
+
$('#script').classList.toggle('on', script);
|
|
246
|
+
if (lastSt) render(lastSt);
|
|
247
|
+
};
|
|
248
|
+
$('#script').onclick = () => window.__decklightSpeakerScript();
|
|
249
|
+
const esc = (t) => String(t).replace(/[&<>]/g, (c) => ({ '&': '&', '<': '<', '>': '>' }[c]));
|
|
250
|
+
function renderScript(st) {
|
|
251
|
+
const data = (api && api.transcript ? api.transcript() : []).filter((d) => d.segs.length);
|
|
252
|
+
$('#notes').innerHTML = data.map((d) => '<div class="sc-slide' + (d.n === st.slide ? ' now' : '') + '" data-n="' + d.n + '">'
|
|
253
|
+
+ '<div class="sc-title">' + d.n + ' \xB7 ' + esc(d.title) + '</div>'
|
|
254
|
+
+ d.segs.map((g) => '<p class="sc-seg">' + esc(g) + '</p>').join('') + '</div>').join('')
|
|
255
|
+
|| '<p>this deck has no speaker notes</p>';
|
|
256
|
+
$('#notes').querySelectorAll('.sc-title').forEach((t) => {
|
|
257
|
+
t.onclick = () => api && api.goto(Number(t.parentNode.dataset.n));
|
|
258
|
+
});
|
|
259
|
+
const now = $('#notes .sc-slide.now');
|
|
260
|
+
if (now) now.scrollIntoView({ block: 'start', behavior: 'smooth' });
|
|
261
|
+
}
|
|
228
262
|
$('#qr').onclick = () => $('#qr').classList.toggle('big');
|
|
229
263
|
document.addEventListener('keydown', (e) => {
|
|
230
264
|
if (e.key === 'ArrowRight' || e.key === ' ') api && api.next();
|
|
231
265
|
if (e.key === 'ArrowLeft') api && api.prev();
|
|
232
|
-
|
|
266
|
+
// S here, or the same \u2325\u23CE that opened this window: speak \u21C4 rehearse
|
|
267
|
+
if (e.key === 's' || e.key === 'S' || (e.altKey && e.key === 'Enter')) { window.__decklightSpeakerToggle(); e.preventDefault(); }
|
|
233
268
|
});
|
|
234
|
-
let last = { slide: -1, nextHash: '' };
|
|
269
|
+
let last = { slide: -1, step: -1, nextHash: '' };
|
|
235
270
|
function render(st) {
|
|
236
271
|
plan = st.timings || [];
|
|
237
272
|
if (st.slide !== last.slide) arrive(st.slide);
|
|
238
273
|
lastSt = st;
|
|
239
274
|
$('#pos').textContent = 'slide ' + st.slide + ' / ' + st.totalSlides + ' \xB7 step ' + st.step + ' / ' + st.totalSteps;
|
|
240
|
-
|
|
275
|
+
// CURRENT is what the audience sees: the slide at the step the deck is on,
|
|
276
|
+
// not the slide fully built. Only the fragment changes, so the pane steps
|
|
277
|
+
// through its builds in place instead of reloading.
|
|
278
|
+
if (st.slide !== last.slide || st.step !== last.step) $('#cur').src = st.url + '#/' + st.slide + '/' + st.step;
|
|
241
279
|
if (st.nextHash !== last.nextHash) $('#nxt').src = st.url + '#' + st.nextHash;
|
|
242
|
-
last = { slide: st.slide, nextHash: st.nextHash };
|
|
280
|
+
last = { slide: st.slide, step: st.step, nextHash: st.nextHash };
|
|
281
|
+
if (script) { renderScript(st); } else {
|
|
243
282
|
const segs = (mode === 'rehearse' && st.rehearseSegments) ? st.rehearseSegments : st.notesSegments;
|
|
244
283
|
// Splitting on \u27E8CLICK\u27E9 can cut through a paragraph, leaving fragments
|
|
245
284
|
// with dangling open tags that would swallow the following segments \u2014
|
|
@@ -254,6 +293,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),le=Q,he=j),oe===void 0
|
|
|
254
293
|
// be out of view.
|
|
255
294
|
const now = $('#notes .seg.now');
|
|
256
295
|
if (now) now.scrollIntoView({ block: mode === 'rehearse' ? 'center' : 'nearest', behavior: 'smooth' });
|
|
296
|
+
}
|
|
257
297
|
// Only set src once: reassigning it every render would refetch the QR on
|
|
258
298
|
// every build step, and a flickering code is one nobody can scan.
|
|
259
299
|
const qr = $('#qr');
|
|
@@ -278,30 +318,30 @@ https://github.com/highlightjs/highlight.js/issues/2277`),le=Q,he=j),oe===void 0
|
|
|
278
318
|
}
|
|
279
319
|
connect(30);
|
|
280
320
|
<\/script>
|
|
281
|
-
</body></html>`),
|
|
282
|
-
Decklight theme \xB7 ${
|
|
321
|
+
</body></html>`),n.document.close(),n}function Tc(e,t){let{slide:n,step:s,totalSlides:a}=e.state,c=e._records[n-1],h=c?c.groups.length:0,f=s<h?`/${n}/${s+1}`:n<a?`/${n+1}/0`:`/${n}/${s}`,g=e._sections[n-1]?.querySelector("aside.notes"),b=e._sections[n-1]?.querySelector("aside.rehearse");return{slide:n,step:s,totalSlides:a,totalSteps:h,url:t,nextHash:f,notesSegments:Qs(g?g.innerHTML:""),rehearseSegments:b?Qs(b.innerHTML):null,labels:e._stepLabels(n-1),timings:pf(e._sections,er(Nc())),qr:e.__remoteQr??null}}Se();Ae();function Qt(e,t){e.addEventListener("click",n=>{n.target===e&&t()})}function vn(e,t,n,{scroll:s=!0}={}){let a=(t+e.length)%e.length;return e.forEach((c,h)=>c.classList.toggle(n,h===a)),s&&e[a]?.scrollIntoView({block:"nearest"}),a}function eo(e,{query:t="",onMove:n,onCommit:s,onType:a,onBackspace:c,onClear:h,onClose:f}){switch(e.key){case"ArrowDown":return n?.(1),!0;case"ArrowUp":return n?.(-1),!0;case"Enter":return s?.(),!0;case"Backspace":return c?(c(),!0):!1;case"Escape":return t&&h?h():f?.(),!0;default:return e.key.length===1&&a?(a(e.key),!0):!1}}function _c(){let e=[];return{register(t){return e.push(t),t},active:()=>e.find(t=>t.isOpen()),opening(t=null){for(let n of e)n!==t&&n.transient&&n.isOpen()&&n.close()}}}Se();Ae();Se();Ae();function hf(e){return function(){e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function gs(e,t,n){e=(e%360+360)%360,t=Math.max(0,Math.min(100,t))/100,n=Math.max(0,Math.min(100,n))/100;let s=(1-Math.abs(2*n-1))*t,a=s*(1-Math.abs(e/60%2-1)),c=n-s/2,h=Math.floor(e/60)%6;return[[s,a,0],[a,s,0],[0,s,a],[0,a,s],[a,0,s],[s,0,a]][h].map(g=>Math.round((g+c)*255))}function Ns([e,t,n]){return"#"+[e,t,n].map(s=>s.toString(16).padStart(2,"0")).join("")}function no([e,t,n]){let s=[e,t,n].map(a=>(a/=255,a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)));return .2126*s[0]+.7152*s[1]+.0722*s[2]}function ff(e,t){let[n,s]=[no(e),no(t)].sort((a,c)=>c-a);return(n+.05)/(s+.05)}var to=(e,t)=>Math.min(...t.map(n=>ff(e,n)));function Yn(e,t,n,s,a){let h=s.reduce((y,$)=>y+no($),0)/s.length<.5?1:-1,f=[];for(let y=t;y>0;y-=15)f.push(y);f.push(0);for(let y of[h,-h])for(let $ of f)for(let S=n;S>=2&&S<=98;S+=y){let A=gs(e,$,S);if(to(A,s)>=a)return A}let g=[253,253,254],b=[8,9,10];return to(g,s)>=to(b,s)?g:b}var mf=["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"],ca='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',gf='ui-rounded, "SF Pro Rounded", "Segoe UI", Roboto, Helvetica, Arial, sans-serif',bf='"Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif',yf='"SF Mono", SFMono-Regular, ui-monospace, "Cascadia Code", Menlo, Consolas, monospace',wf=[ca,ca,gf,bf],vf=[600,650,700,750,800],kf=["4px","6px","8px","10px","12px","14px","18px"],Oc={analogous:[30,-30,60,15,-15],complementary:[180,150,210,30,-30],split:[150,210,30,180,-30],triadic:[120,240,60,180,300]},js={bgSatMax:{dark:18,light:12},accentSat:[42,68],hlSat:[36,58],ansiSat:[46,66],gradientChance:.15,gradientHueDrift:[8,20]};function di(e){e=(e??Math.floor(Math.random()*4294967295))>>>0;let t=hf(e),n=we=>we[Math.floor(t()*we.length)],s=(we,Ee)=>we+t()*(Ee-we),a=t()<.5,c=Math.floor(t()*360),h=n(Object.keys(Oc)),f=Oc[h],g=c+f[0],b=t()*t(),y=(we,Ee)=>we+b*(Ee-we),$=y(5,js.bgSatMax[a?"dark":"light"]),S=a?s(6,13):s(94,97.5),A=gs(c,$,S),E=Ns(A),L=[A];if(t()<js.gradientChance){let we=gs(c+s(...js.gradientHueDrift),$+s(0,8),S+(a?s(2.5,5):-s(2,4)));E=`linear-gradient(${Math.round(s(120,210))}deg, ${Ns(A)} 0%, ${Ns(we)} 100%)`,L=[A,we]}let P=gs(c,Math.min($+4,35),a?S+4:S-4),j=Yn(c,12,a?86:18,L,4.6),U=Yn(c,10,a?64:44,L,3.1),pe=t()<.5?Yn(g,y(20,55),a?80:26,L,3.2):Yn(c,8,a?92:12,L,4.6),D=y(...js.accentSat),z=a?s(55,68):s(34,48),Ce=gs(g,D,z);for(;Math.max(to([253,253,254],[Ce]),to([8,9,10],[Ce]))<4.7;)z+=a?1:-1,Ce=gs(g,D,z);let ee=Yn(g,18,no(Ce)<.4?96:10,[Ce],4.6),re=Yn(t()<.5?g:c+(f[1]??30),y(35,60),a?70:34,L,3.2),le=Ns(P),ie=`1px solid ${Ns(gs(c,Math.min($+6,40),a?S+10:S-10))}`,I=n(kf),ce=a?`0 ${Math.round(s(4,10))}px ${Math.round(s(18,30))}px rgba(0, 0, 0, 0.${Math.round(s(35,55))})`:`0 ${Math.round(s(3,6))}px ${Math.round(s(12,20))}px rgba(30, 30, 40, 0.${String(Math.round(s(8,14))).padStart(2,"0")})`,de=gs(c,Math.min($+2,28),a?Math.max(S-3,3):Math.min(S-3,93)),Ie=[de],V=Yn(c,8,a?85:20,Ie,4.6),Z={keyword:f[0],string:f[3]??120,number:f[2]??60,function:f[1]??210,type:f[4]??280},T=y(...js.hlSat),F=a?68:36,se={};for(let[we,Ee]of Object.entries(Z))se[we]=Yn(c+Ee,T,F,Ie,4.6);se.comment=Yn(c,12,a?60:46,Ie,3.2),se.punct=Yn(c,10,a?74:32,Ie,4.6);let Te=[0,f[0],f[1]??40,f[2]??90,f[3]??160,f[4]??230].map((we,Ee)=>gs(c+we,y(14,34),a?S+8+Ee%3*2:S-6-Ee%3*2)),l=[...L,...Te],d=Yn(c,14,a?60:42,L,2.2),G=Yn(c,10,a?84:20,l,3.4),be=Yn(c,10,a?62:46,l,2.7),J=Yn(g,D,a?68:38,l,2.7),Qe=Te.map(Ns),ot=gs(c,Math.min($+4,30),a?Math.max(S-4,3):s(12,18)),fe=[ot],K=Yn(c,8,82,fe,4.6),ue=Yn(g,y(...js.ansiSat),66,fe,3.2),at={red:8,green:125,yellow:45,blue:215,magenta:290,cyan:175},N={black:Yn(c,10,58,fe,3.1),white:Yn(c,6,88,fe,4.6)};for(let[we,Ee]of Object.entries(at))N[we]=Yn(Ee+c%16-8,y(...js.ansiSat),66,fe,3.1);let ft=we=>{let[Ee,Ke,ae]=we.map(Ze=>Math.min(255,Math.round(Ze+(255-Ze)*.35)));return to([Ee,Ke,ae],fe)>=3?[Ee,Ke,ae]:Yn(c,8,90,fe,3.1)},M=`gen-${n(mf)}-${(e%65535).toString(16).padStart(4,"0")}`,H=Ns,te={"--bg":E,"--bg-accent":Ns(P),"--fg":H(j),"--muted":H(U),"--font-body":ca,"--font-heading":n(wf),"--font-mono":yf,"--heading-color":H(pe),"--heading-weight":String(n(vf)),"--link":H(re),"--accent":H(Ce),"--accent-contrast":H(ee),"--block-bg":le,"--block-border":ie,"--block-radius":I,"--shadow":ce,"--code-bg":H(de),"--code-fg":H(V),"--hl-keyword":H(se.keyword),"--hl-string":H(se.string),"--hl-number":H(se.number),"--hl-comment":H(se.comment),"--hl-function":H(se.function),"--hl-type":H(se.type),"--hl-punct":H(se.punct),"--d-stroke":H(d),"--d-text":H(G),"--d-muted":H(be),"--d-accent":H(J),"--d-fill-1":Qe[0],"--d-fill-2":Qe[1],"--d-fill-3":Qe[2],"--d-fill-4":Qe[3],"--d-fill-5":Qe[4],"--d-fill-6":Qe[5],"--term-bg":H(ot),"--term-fg":H(K),"--term-prompt":H(ue),"--term-cursor":H(ue),"--term-selection":`rgba(${Ce[0]}, ${Ce[1]}, ${Ce[2]}, 0.30)`,"--ansi-black":H(N.black),"--ansi-red":H(N.red),"--ansi-green":H(N.green),"--ansi-yellow":H(N.yellow),"--ansi-blue":H(N.blue),"--ansi-magenta":H(N.magenta),"--ansi-cyan":H(N.cyan),"--ansi-white":H(N.white),"--ansi-bright-black":H(ft(N.black)),"--ansi-bright-red":H(ft(N.red)),"--ansi-bright-green":H(ft(N.green)),"--ansi-bright-yellow":H(ft(N.yellow)),"--ansi-bright-blue":H(ft(N.blue)),"--ansi-bright-magenta":H(ft(N.magenta)),"--ansi-bright-cyan":H(ft(N.cyan)),"--ansi-bright-white":H(Yn(c,6,97,fe,3.1)),"--dim-opacity":(.25+Math.round(t()*15)/100).toFixed(2)};return{name:M,seed:e,dark:a,harmony:h,tokens:te}}var Lc=[["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"]]],xf=/^--[\w-]+$/,Ef=e=>!/[{};<>]|\/\*|\*\//.test(String(e)),$f=e=>Object.fromEntries(Object.entries(e??{}).filter(([t,n])=>xf.test(t)&&Ef(n)));function da(e,t){t=$f(t);let s=`/* \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
|
|
322
|
+
Decklight theme \xB7 ${String(e??"").replace(/\*\//g,"* /")}
|
|
283
323
|
generated by Decklight (\u2303T) \u2014 token contract: SPEC.md THEMING
|
|
284
324
|
All values derived with WCAG luminance math; passes test/contrast.mjs
|
|
285
325
|
\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 */
|
|
286
326
|
|
|
287
327
|
.decklight {
|
|
288
|
-
`;for(let[
|
|
289
|
-
`;for(let
|
|
290
|
-
`;
|
|
291
|
-
`}}let
|
|
292
|
-
`);return
|
|
293
|
-
`}function ua({root:t,config:o,params:a,toast:c,debugLog:d,overlays:p,deck:f,editmode:m}){let v=[...document.querySelectorAll("style[data-theme]:not([data-theme-added])")],k=[...document.querySelectorAll("style[data-theme][data-theme-added]")],S=new Set(k.map(C=>C.dataset.theme).filter(Boolean)),P=new Map;for(let C of k){let ne=C.dataset.themeMarketplace;C.dataset.theme&&ne&&P.set(C.dataset.theme,{pack:`mkt:${ne}`,label:C.dataset.themeSource||ne})}let T=v.length>0,A=T?null:document.querySelector('link[rel="stylesheet"][href*="themes/"]');if(T){let C=v.find(ne=>!ne.hasAttribute("disabled")&&ne.media!=="not all");C=C||v[0],v.forEach(ne=>{ne.removeAttribute("disabled"),ne.media=ne===C?"all":"not all"})}let N=T||!!A,I=C=>(C.match(/themes\/([\w-]+)\.css/)||[])[1],Se="decklight-theme:"+location.pathname,pe="decklight-custom-themes",Oe={};Oe=Bn(pe,{})||{};let re=null,ce=null,Me={};function ze(C,ne,Ee){let we=Ee==="generated"?re:Me[C];return we||(we=document.createElement("style"),we.media="not all",Ee==="generated"?we.dataset.generated="":we.dataset.custom=""),we.dataset.theme=C,we.textContent=co(C,ne),document.head.appendChild(we),Ee==="generated"?re=we:Me[C]=we,we}let Ve=()=>[re,...Object.values(Me),...k];function $e(C){for(let ne of Ve())ne&&ne!==C&&(ne.media="not all")}let _e=()=>Ve().find(C=>C&&C.media!=="not all")||null,Ze=()=>{let C=_e();return C?C.dataset.theme:T?v.find(ne=>ne.media!=="not all")?.dataset.theme:A?I(A.href):void 0};function bt(){let C=getComputedStyle(t),ne=Ne=>Ne?.match(/rgba?\(([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[\s,/]+([\d.]+))?\)/),Ee=ne(C.backgroundColor);(!Ee||Ee[4]!==void 0&&+Ee[4]==0)&&(Ee=ne(C.backgroundImage));let we=Ee?Lr([+Ee[1],+Ee[2],+Ee[3]])<.5:!1;t.setAttribute("data-canvas",we?"dark":"light")}A?.addEventListener("load",bt);function _(C,ne=!1){if(!C||!/^[\w-]+$/.test(C))return;let Ee=!1;if(ce&&re&&C===ce.name)re.media="all",$e(re),Ee=!Oe[C];else if(Oe[C]){let we=ze(C,Oe[C],"custom");we.media="all",$e(we)}else if(S.has(C)){let we=k.find(Ne=>Ne.dataset.theme===C);we.media="all",$e(we)}else{if(!N)return;if($e(null),T){let we=v.find(Ne=>Ne.dataset.theme===C);if(!we)return;v.forEach(Ne=>{Ne.media=Ne===we?"all":"not all"})}else A.href=A.href.replace(/themes\/[\w-]+\.css(\?.*)?$/,`themes/${C}.css`)}!a.has("embedded")&&!Ee&&fn(Se,C),ne||c(C),d("theme",C),bt()}let je=typeof at<"u"?at:null,gt={added:"Added",custom:"Custom",generated:"Generated"},ut=new Map([...P.values()].map(C=>[C.pack,C.label])),Q=C=>ut.get(C)??je?.labels?.[C]??gt[C]??C;function j(C){if(Oe[C])return"custom";if(ce&&C===ce.name)return"generated";if(P.has(C))return P.get(C).pack;if(S.has(C))return"added";if(je){for(let[ne,Ee]of Object.entries(je.packs))if(Ee.includes(C))return ne}return"other"}let oe=()=>{let C;if(T){let Ee=v.map(we=>we.dataset.theme);C=o.themes?.length?o.themes.filter(we=>Ee.includes(we)):Ee}else C=o.themes?.length?o.themes:typeof it<"u"?it:[];let ne=[...S,...Object.keys(Oe)];if(ce&&!Oe[ce.name]&&ne.push(ce.name),C=[...C,...ne.filter(Ee=>!C.includes(Ee))],je){let Ee=new Map,we=0;for(let Ne of je.order)for(let Ge of je.packs[Ne]??[])Ee.set(Ge,we++);C=[...C].sort((Ne,Ge)=>(Ee.get(Ne)??1e9)-(Ee.get(Ge)??1e9))}return C};function he(C){let ne=[];for(let Ee of je.order){let we=(je.packs[Ee]??[]).filter(Ne=>C.includes(Ne));we.length&&ne.push([Ee,we])}for(let Ee of new Set([...P.values()].map(we=>we.pack))){let we=C.filter(Ne=>j(Ne)===Ee);we.length&&ne.push([Ee,we])}for(let Ee of["added","custom","generated"]){let we=C.filter(Ne=>j(Ne)===Ee);we.length&&ne.push([Ee,we])}return ne}let le=C=>btoa(unescape(encodeURIComponent(JSON.stringify(C)))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),Re=C=>JSON.parse(decodeURIComponent(escape(atob(C.replace(/-/g,"+").replace(/_/g,"/")))));function Y(C,ne=!1){ce={name:C.name,tokens:C.tokens};let Ee=ze(C.name,C.tokens,"generated");return Ee.media="all",$e(Ee),ne||c(`\u2728 ${C.name} \u2014 \u2303T re-roll \xB7 \u2303\u21E7T save`,2800),bt(),C.name}function s(){return Y(Cs())}function i(C){if(!ce||!re||re.media==="not all")return c("no generated theme to save \u2014 \u2303T to generate one"),null;let ne=C??(window.prompt?.("Save theme as:",ce.name.replace(/^gen-/,""))||"");if(ne=String(ne).toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40),!ne)return null;((typeof it<"u"?it:[]).includes(ne)||v.some(Ne=>Ne.dataset.theme===ne))&&(ne="custom-"+ne),Oe[ne]=ce.tokens,Dn(pe,Oe);let we=ze(ne,Oe[ne],"custom");we.media="all",re?.remove(),re=null,ce=null,$e(we),a.has("embedded")||fn(Se,ne);try{let Ne=new Blob([co(ne,Oe[ne])],{type:"text/css"}),Ge=document.createElement("a");Ge.href=URL.createObjectURL(Ne),Ge.download=`${ne}.css`,Ge.click(),setTimeout(()=>URL.revokeObjectURL(Ge.href),5e3)}catch{}return c(`saved ${ne} \u2014 ${ne}.css downloaded`,2200),ne}let O=null;function Ue(C=!1){return O?(clearTimeout(O.timer),O=null,C||c("theme cycle cancelled"),!0):!1}function B(C){let ne=oe();if(!N||ne.length<2)return;if(O){let Ge=O;clearTimeout(Ge.timer),O=null,Ge.dir===C?_(Ge.name):c("theme cycle cancelled");return}let Ee=Ze(),we=Math.max(0,ne.indexOf(Ee)),Ne=ne[(we+C+ne.length)%ne.length];if(je&&j(Ne)!==j(Ee)){let Ge=C>0?".":",",M=C>0?",":".";O={dir:C,name:Ne,timer:setTimeout(()=>{O=null},4e3)},c(`\u2933 ${Q(j(Ne))} pack next (${Ne}) \u2014 ${Ge} confirms \xB7 ${M} or Esc cancels`,4e3);return}_(Ne)}a.has("embedded")&&window.addEventListener("message",C=>{let ne=C.data&&C.data.__decklightPreview;!ne||C.source!==window.parent||(ne.gen?Y(ne.gen,!0):ne.theme?_(ne.theme,!0):ne.goto&&f().goto(ne.goto[0],ne.goto[1]??0))});function Le(){let C=Ze(),ne=Oe[C]?{name:C,tokens:Oe[C]}:ce&&C===ce.name?ce:null;return ne?"?embedded&gen="+le(ne):C?"?embedded&theme="+encodeURIComponent(C):"?embedded"}function $t(){let C=a.get("gen");if(C)try{let we=Re(C);if(we&&we.tokens){Y({name:we.name||"gen-preview",tokens:we.tokens},!0);return}}catch{}let ne=null;ne=kn(Se);let Ee=a.get("theme")||ne;Ee&&_(Ee,!0)}let W="\0generate",Ae="pack:",ee="back",We="all",w="browse",Ie="",g=C=>C.charCodeAt(0)<32,J=null,z=0,Ce,ye=[],Pe=null,X="",Xe="packs",mt=()=>je?"packs":"all",ft=()=>m?.()?.available()===!0,ke=()=>m?.()?.base()??"",ue=()=>ft()?[w]:[],ie=null,Ke=C=>(ie?.themes??[]).find(ne=>ne.qualified===C);async function rt(){ie={loading:!0,themes:[],stale:[]},sn("browse");let C;try{let ne=await fetch(ke()+"/edit/theme/browse"),Ee=await ne.json().catch(()=>({}));C=ne.ok&&Ee.ok?{themes:Ee.themes??[],stale:Ee.stale??[],cacheOnly:Ee.cacheOnly!==!1}:{themes:[],stale:[],error:Ee.error||`the author server said ${ne.status}`}}catch{C={themes:[],stale:[],error:"the author server did not answer"}}!J||Xe!=="browse"||(ie=C,sn("browse"))}async function Je(C){let ne=J?.querySelector(".tp-caption");ne&&(ne.textContent=`installing ${C}\u2026`);try{let Ee=await fetch(ke()+"/edit/theme/add",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ref:C})}),we=await Ee.json().catch(()=>({}));if(!Ee.ok){let Ne=[we.error,...we.problems??[]].filter(Boolean).join(" \xB7 ");ne&&(ne.textContent=Ne||`install failed (${Ee.status})`),c(`${C}: ${we.error||"install refused"}`,3600);return}tn(),c(`installed ${we.name}${we.replaced?" (replaced)":""} \u2014 Z takes it back`,2800),d("theme",`${C} installed from a marketplace`)}catch{ne&&(ne.textContent="the author server did not answer")}}function tt(C){let ne=f().state,Ee="#/"+ne.slide+"/"+ne.step;if(C===W||Oe[C]||ce&&C===ce.name){let we=C===W?Pe:Oe[C]?{name:C,tokens:Oe[C]}:ce;return location.pathname+"?embedded&gen="+le(we)+Ee}return location.pathname+"?embedded&theme="+encodeURIComponent(C)+Ee}function Rt(C){C.textContent=Pe?`\u2728 ${Pe.name} \u2014 \u2303T re-rolls`:"\u2728 Generate new\u2026"}function jt(){Pe=Cs();let C=ye.indexOf(W);C<0||(Rt(J.querySelectorAll(".tp-row")[C]),on(C,!0))}function en(){let C=J.querySelector(".tp-list"),ne=Ze(),Ee=oe();if(Xe==="browse"){let Ge=(ie?.themes??[]).filter(M=>!X||M.qualified.includes(X));ye=[ee,...Ge.map(M=>Ie+M.qualified)]}else if(X)ye=Ee.filter(Ge=>Ge.includes(X));else if(!je||Xe==="all")ye=je?[W,ee,...Ee]:[W,...Ee,...ue()];else if(Xe==="packs")ye=[W,...he(Ee).map(([Ge])=>Ae+Ge),We,...ue()];else{let Ge=Xe.slice(5);ye=[ee,...he(Ee).find(([M])=>M===Ge)?.[1]??[]]}C.textContent="";let we=(Ge,M)=>{let H=document.createElement("span");H.className="tp-tag",H.textContent=M,Ge.appendChild(H)};if(ye.forEach((Ge,M)=>{let H=document.createElement("div");if(H.setAttribute("role","option"),Ge===W)H.className="tp-row tp-gen",Rt(H);else if(Ge===ee)H.className="tp-row tp-back",H.textContent=mt()==="packs"?"\u2190 packs":"\u2190 themes";else if(Ge===w)H.className="tp-row tp-browse",H.textContent="\u2315 Browse marketplaces\u2026";else if(Ge.startsWith(Ie)){let K=Ke(Ge.slice(Ie.length));H.className="tp-row tp-mkt",H.textContent=K?.name??Ge.slice(Ie.length);let se=S.has(K?.name)?"installed":K?.marketplace;se&&we(H,se)}else if(Ge===We)H.className="tp-row tp-all",H.textContent="\u2733 all themes",we(H,String(Ee.length));else if(Ge.startsWith(Ae)){let K=Ge.slice(Ae.length),se=he(Ee).find(([qe])=>qe===K)?.[1]??[];H.className="tp-row tp-pack"+(se.includes(ne)?" tp-current":""),H.textContent=`\u25B8 ${Q(K)}`,we(H,String(se.length))}else{H.className="tp-row"+(Ge===ne?" tp-current":""),H.textContent=Ge;let K=Oe[Ge]?"custom":ce&&Ge===ce.name?"generated":P.has(Ge)?P.get(Ge).label:S.has(Ge)?"added":X&&je?Q(j(Ge)):null;K&&we(H,K)}H.addEventListener("mouseenter",()=>on(M,!1)),H.addEventListener("click",()=>{on(M,!0),_t()}),C.appendChild(H)}),!ye.length){let Ge=document.createElement("div");Ge.className="tp-none",Ge.textContent="no themes match",C.appendChild(Ge)}if(Xe==="browse"){let Ge=document.createElement("div");Ge.className="tp-none",Ge.textContent=ie?.loading?"reading the catalogs\u2026":ie?.error?ie.error:ye.some(M=>M.startsWith(Ie))?ie.stale?.length?`from the cache \xB7 never fetched: ${ie.stale.join(", ")} \u2014 marketplace update`:"from the cache \u2014 listing never goes to the network":X?"no marketplace theme matches":"no themes in the marketplaces you have registered",C.appendChild(Ge)}let Ne=J.querySelector(".tp-filter");Ne.textContent=X||"type to filter\u2026",Ne.classList.toggle("tp-active",!!X)}function Pt(){let C=Ze(),ne=ye.indexOf(C);if(ne>=0)return ne;let Ee=ye.indexOf(Ae+j(C));return Ee>=0?Ee:Math.min(1,ye.length-1)}function sn(C,ne=!1){Xe=C,en(),ye.length&&on(Pt(),ne)}function Gt(C){X=C.toLowerCase(),en(),ye.length?on(X?0:Pt(),!1):J.querySelector(".tp-caption").textContent="no match"}function At(){if(J)return tn();p.closeOthers(Yt);let C=oe();if(!N&&!C.length)return;X="",Xe=mt(),ie=null,J=document.createElement("div"),J.className="decklight-theme-picker",J.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>',en(),Ht(J,tn),t.appendChild(J);let ne=Ze();ne&&Kt(J.querySelector("iframe"),ne),on(Pt(),!ne)}function on(C,ne){if(!ye.length)return;z=(C+ye.length)%ye.length;let Ee=ye[z];Ee===W&&!Pe&&(Pe=Cs(),Rt(J.querySelectorAll(".tp-row")[z])),En(J.querySelectorAll(".tp-row"),z,"tp-selected");let we=oe(),Ne=Ee===W?Pe?`\u2728 ${Pe.name}`:"generate new":Ee===ee?mt()==="packs"?"back to packs":"back to the theme list":Ee===w?"themes from the marketplaces you have registered":Ee.startsWith(Ie)?un(Ee.slice(Ie.length)):Ee===We?`all ${we.length} themes, flattened`:Ee.startsWith(Ae)?`${Q(Ee.slice(Ae.length))} \xB7 ${he(we).find(([M])=>M===Ee.slice(Ae.length))?.[1].length??0} themes`:je?`${Q(j(Ee))} \xB7 ${Ee}`:Ee;if(J.querySelector(".tp-caption").textContent=Ne,clearTimeout(Ce),Ee!==W&&g(Ee))return;let Ge=J.querySelector("iframe");ne?Kt(Ge,Ee):Ce=setTimeout(()=>Kt(Ge,Ee),60)}function un(C){let ne=Ke(C);return ne?[ne.qualified,ne.description,S.has(ne.name)?"installed \u2014 \u23CE re-installs it":"\u23CE installs it"].filter(Boolean).join(" \xB7 "):C}let qt=!1,pn=null;function te(C){return C===W||Oe[C]||ce&&C===ce.name?{gen:C===W?Pe:Oe[C]?{name:C,tokens:Oe[C]}:ce}:{theme:C}}function Kt(C,ne){if(!C.dataset.booted){C.dataset.booted="1",qt=!1,C.addEventListener("load",()=>{if(qt=!0,pn!==null&&J){let Ee=pn;pn=null,Kt(C,Ee)}},{once:!0}),C.src=tt(ne);return}if(!qt){pn=ne;return}C.contentWindow?.postMessage({__decklightPreview:te(ne)},"*")}function _t(){let C=ye[z];if(C!==void 0){if(C===W){Pe&&Y(Pe),tn();return}if(C===ee){sn(mt());return}if(C===We){sn("all");return}if(C===w){rt();return}if(C.startsWith(Ie)){Je(C.slice(Ie.length));return}if(C.startsWith(Ae)){sn("pack:"+C.slice(Ae.length),!0);return}_(C),tn()}}function tn(){clearTimeout(Ce),J?.remove(),J=null}let Yt=p.register({isOpen:()=>!!J,close:tn,keydown(C){switch(C.key){case"ArrowDown":on(z+1,!1);break;case"ArrowUp":on(z-1,!1);break;case"Enter":_t();break;case"Backspace":Gt(X.slice(0,-1));break;case"Escape":X?Gt(""):Xe!==mt()?sn(mt()):tn();break;default:if(C.key.length===1&&/[a-z0-9-]/i.test(C.key)){Gt(X+C.key);break}return!1}return!0}});return{applyTheme:_,currentTheme:Ze,themeList:oe,cycleTheme:B,cancelCyclePending:Ue,rollTheme:s,saveGeneratedTheme:i,adoptGenerated:Y,updateCanvas:bt,restoreSaved:$t,previewQuery:Le,openPicker:At,closePicker:tn,browse(){J||At(),J&&rt()},hasGenerated:()=>!!ce,rollFromPicker(){return J&&ye[z]===W?(jt(),!0):!1}}}me();fe();me();fe();me();fe();var uo=["A","B","C","D","E","F","G","H","X"],Rr="#edb58e",pa="#c98f6d",vd="#43302a",Ir="#b96b58",Pr="#57262c",Ns="#f6f1ea",ha="#d17a70",po=`<svg viewBox="0 0 240 240" role="img" aria-label="Narrator" xmlns="http://www.w3.org/2000/svg">
|
|
328
|
+
`;for(let[c,h]of Lc){let f=h.filter(g=>t[g]!==void 0);if(f.length){s+=` /* \u2500\u2500 ${c} ${"\u2500".repeat(Math.max(1,26-c.length))} */
|
|
329
|
+
`;for(let g of f)s+=` ${g}: ${t[g]};
|
|
330
|
+
`;s+=`
|
|
331
|
+
`}}let a=new Set(Lc.flatMap(([,c])=>c));for(let[c,h]of Object.entries(t))a.has(c)||(s+=` ${c}: ${h};
|
|
332
|
+
`);return s.replace(/\n$/,"")+`}
|
|
333
|
+
`}Se();Ae();function ro({docOf:e,srcFor:t,messageFor:n}){let s=new WeakMap,a=h=>{let f=s.get(h);return f||(f={doc:void 0,ready:!1,pending:null},s.set(h,f)),f};function c(h,f){if(!h||f==null)return;let g=a(h),b=e(f);if(g.doc!==b){g.doc=b,g.ready=!1,g.pending=null,h.addEventListener("load",()=>{if(g.doc===b&&(g.ready=!0,g.pending!=null&&h.isConnected)){let y=g.pending;g.pending=null,c(h,y)}},{once:!0}),h.src=t(f);return}if(!g.ready){g.pending=f;return}h.contentWindow?.postMessage(n(f),"*")}return{show:c}}Se();Ae();Se();Ae();Se();Ae();Se();Ae();Se();Ae();var Sf=e=>(e/=255,e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4));function so([e,t,n]){let[s,a,c]=[e,t,n].map(Sf),h=Math.cbrt(.4122214708*s+.5363325363*a+.0514459929*c),f=Math.cbrt(.2119034982*s+.6806995451*a+.1073969566*c),g=Math.cbrt(.0883024619*s+.2817188376*a+.6299787005*c);return[.2104542553*h+.793617785*f-.0040720468*g,1.9779984951*h-2.428592205*f+.4505937099*g,.0259040371*h+.7827717662*f-.808675766*g]}Se();Ae();var Cf=["black","red","green","yellow","blue","magenta","cyan","white"],g0=[["fg","bg",4.5],["muted","bg",3],["heading-color","bg",3],["link","bg",3],["d-text","bg",3],...[1,2,3,4,5,6].flatMap(e=>[["d-text",`d-fill-${e}`,3],["d-muted",`d-fill-${e}`,2.6],["d-accent",`d-fill-${e}`,2.6]]),["accent-contrast","accent",4.5],["code-fg","code-bg",4.5],...["keyword","string","number","function","type","punct"].map(e=>[`hl-${e}`,"code-bg",4.5]),["hl-comment","code-bg",3],["term-fg","term-bg",3],["term-prompt","term-bg",3],...Cf.flatMap(e=>[[`ansi-${e}`,"term-bg",3],[`ansi-bright-${e}`,"term-bg",3]])];var Tf=new Set(["--bg","--bg-accent","--fg","--muted","--heading-color","--link","--accent","--accent-contrast","--block-bg","--block-border","--code-bg","--code-fg","--hl-keyword","--hl-string","--hl-number","--hl-comment","--hl-function","--hl-type","--hl-punct","--d-stroke","--d-text","--d-muted","--d-accent",...[1,2,3,4,5,6].flatMap(e=>[`--d-fill-${e}`,`--d-fill-${e}-in`]),"--term-bg","--term-fg","--term-prompt","--term-cursor","--term-selection",...["black","red","green","yellow","blue","magenta","cyan","white"].flatMap(e=>[`--ansi-${e}`,`--ansi-bright-${e}`])]);var C0=new Set(["--bg","--fg","--muted","--heading-color","--link","--accent","--accent-contrast","--code-bg","--code-fg","--hl-keyword","--hl-string","--hl-number","--hl-comment","--hl-function","--hl-type","--hl-punct","--d-text","--d-muted","--d-accent",...[1,2,3,4,5,6].flatMap(e=>[`--d-fill-${e}`,`--d-fill-${e}-in`]),"--term-bg","--term-fg","--term-prompt",...["black","red","green","yellow","blue","magenta","cyan","white"].flatMap(e=>[`--ansi-${e}`,`--ansi-bright-${e}`])]);var H0=2*1024*1024,ui=/^[a-z][a-z0-9-]*$/,oo=e=>typeof e=="string"&&e.includes("/");function Mc(e){let t=/^([^/\s]+)\/([^/\s]+)$/.exec(String(e??""));return t&&ui.test(t[1])&&ui.test(t[2])?{system:t[1],template:t[2]}:null}var Nf=["bg","bg-accent","fg","muted","font-body","font-heading","font-mono","heading-color","heading-weight","link","accent","accent-contrast","block-bg","block-border","block-radius","shadow","code-bg","code-fg","hl-keyword","hl-string","hl-number","hl-comment","hl-function","hl-type","hl-punct","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","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"].map(e=>`--${e}`),z0=new Set(Nf);var _f=[{name:"eyebrow",hint:"p"},{name:"title",hint:"h1,h2"},{name:"subtitle",hint:"p"},{name:"number",hint:"p"},{name:"points",hint:"ul,ol"},{name:"body",hint:"p,div"},{name:"diagram",hint:"div,svg,img"},{name:"table",hint:"table"},{name:"quote",hint:"blockquote,p"},{name:"code",hint:"pre"},{name:"image",hint:"img,figure"},{name:"caption",hint:"p,figcaption"}],U0=new Set(_f.map(e=>e.name));var Of=["h1","h2","h3","p","ul","ol","li","table","blockquote","pre","code","a","figcaption"],G0=new Set(Of);var pi="aside.notes, aside.sources, aside.rehearse, script, style, .slide-bg",Lf=new Set(["SCRIPT","STYLE","IFRAME","OBJECT","EMBED","FOREIGNOBJECT","LINK","META","BASE","FRAME","FRAMESET"]),Mf=new Set(["src","srcset","href","xlink:href","poster","action","formaction","data","background","srcdoc"]);function Rf(e){let t=0;for(let n of[...e.querySelectorAll("*")]){if(Lf.has(n.tagName.toUpperCase())){n.remove(),t++;continue}for(let s of[...n.attributes]){let a=s.name.toLowerCase();(a.startsWith("on")||Mf.has(a)&&!s.value.trim().startsWith("#"))&&(n.removeAttribute(s.name),t++)}}return t}function Pr(e=document){let t=new Map;for(let n of e.querySelectorAll('script[type="application/json"][data-design-system-meta]')){let s=n.getAttribute("data-design-system-meta"),a;try{a=JSON.parse(n.textContent)}catch{continue}let c=e.querySelector(`template[data-design-system-templates="${CSS.escape(s)}"]`),h=new Map;for(let f of c?.content.querySelectorAll("template[data-template]")??[]){let g=f.getAttribute("data-template");ui.test(g)&&!h.has(g)&&h.set(g,f)}t.set(s,{name:s,version:a?.version??"",title:a?.title??s,palette:Array.isArray(a?.palette)?a.palette:[],scales:a?.scales===!0,themes:Array.isArray(a?.themes)?a.themes.filter(f=>f&&typeof f.name=="string"):[],roles:Array.isArray(a?.roles)?a.roles.filter(f=>f&&typeof f.id=="string"&&typeof f.token=="string"):[],contract:a?.contract&&typeof a.contract=="object"&&!Array.isArray(a.contract)?Object.fromEntries(Object.entries(a.contract).filter(([f,g])=>typeof f=="string"&&typeof g=="string")):{},recommendedThemes:Array.isArray(a?.recommendedThemes)?a.recommendedThemes.filter(f=>typeof f=="string"):[],recommendedFonts:Array.isArray(a?.recommendedFonts)?a.recommendedFonts.filter(f=>typeof f=="string"):[],templates:h})}return t}var pa=new WeakMap,ua=new WeakMap;function ks(e,t){for(let n=t;n&&n!==e;n=n.parentElement){if(pa.has(n))return n;if(n.parentElement===e)return n.hasAttribute("data-ds-injected")?null:n}return null}var xs=(e,t)=>pa.get(t)??Array.prototype.indexOf.call(e.children,t);function If(e,t){let n=ua.get(e);return!n||n.key!==t||e.getAttribute("data-ds-expanded")!==t||!n.authored.every(s=>e.contains(s))?!1:![...e.children].some(s=>!s.matches(pi)&&!s.hasAttribute("data-ds-injected")&&!n.authored.includes(s))}function hi(e,{systems:t=Pr(),warn:n=()=>{}}={}){let s=[];for(let a of e){let c=a.getAttribute("data-template");if(!oo(c))continue;let h=Mc(c),f=h?t.get(h.system):null,g=f?.templates.get(h.template);if(!g){let D=h?f?`${h.system} has no template "${h.template}"`:`design system "${h.system}" is not available on this page`:`"${c}" is not a slide template (name/template)`;a.setAttribute("data-ds-missing",D),s.push({sec:a,reason:D});continue}let b=`${h.template}@${f.version}`;if(If(a,b))continue;a.removeAttribute("data-ds-missing");let y=ua.get(a),$;if(y){$=y.authored.filter(D=>a.contains(D));for(let D of[...a.children])!D.matches(pi)&&!D.hasAttribute("data-ds-injected")&&!$.includes(D)&&$.push(D);for(let D of[...a.querySelectorAll(":scope > [data-ds-injected]")]){for(let z of $)D.contains(z)&&a.appendChild(z);D.remove()}}else $=[...a.children].filter(D=>!D.matches(pi)),[...a.children].forEach((D,z)=>{D.matches(pi)||pa.set(D,z)});let S=g.content.cloneNode(!0),A=Rf(S);A&&n(`slide template ${c}: ${A} unsafe thing(s) removed from the template \u2014 the package should not have passed its check`);for(let D of[...S.children,...S.querySelectorAll("*")])D.setAttribute("data-ds-injected","");let E=new Map;for(let D of S.querySelectorAll("[data-slot]"))E.has(D.getAttribute("data-slot"))||E.set(D.getAttribute("data-slot"),D);let L=S.querySelector("[data-slot-default]"),P=new Set,j=(D,z)=>{P.has(D)||(D.replaceChildren(),P.add(D)),D.appendChild(z)},U=null;for(let D of $){let z=D.getAttribute("data-slot"),Ce=z?E.get(z):null;if(Ce){j(Ce,D);continue}if(L){j(L,D);continue}U||(U=document.createElement("div"),U.className="ds-unslotted",U.setAttribute("data-ds-injected","")),U.appendChild(D)}U&&S.appendChild(U);let oe=[...S.querySelectorAll("[data-slot-required]")].filter(D=>!P.has(D)&&!D.textContent.trim()&&!D.children.length).map(D=>D.getAttribute("data-slot"));oe.length?(a.setAttribute("data-ds-required-empty",oe.join(" ")),n(`slide template ${c}: required slot${oe.length===1?"":"s"} ${oe.join(", ")} left empty`)):a.removeAttribute("data-ds-required-empty");let pe=[...a.children].find(D=>D.matches("aside, script, style"));a.insertBefore(S,pe??null),a.setAttribute("data-ds-expanded",b),ua.set(a,{key:b,authored:$})}return s}Se();Ae();var Pf=e=>/mac|iphone|ipad/i.test(String(e??"")),bs=typeof navigator<"u"&&Pf(navigator.userAgentData?.platform??navigator.platform),zt=bs?"\u2318Z":"Ctrl+Z",Ao=bs?"\u2318\u21E7Z":"Ctrl+\u21E7Z";function Rc({root:e,config:t,params:n,toast:s,debugLog:a,overlays:c,deck:h,editmode:f}){let g=[...document.querySelectorAll("style[data-theme]:not([data-theme-added])")],b=[...document.querySelectorAll("style[data-theme][data-theme-added], link[data-theme][data-theme-added]")],y=new Set(b.map(B=>B.dataset.theme).filter(Boolean)),$=new Set(b.filter(B=>B.tagName==="LINK").map(B=>B.dataset.theme)),S=typeof pt<"u"?pt:[];for(let B of Array.isArray(t.markedThemes)?t.markedThemes:[])typeof B=="string"&&S.includes(B)&&$.add(B);let A=new Map;for(let B of b){let Le=B.dataset.themeMarketplace;B.dataset.theme&&Le&&A.set(B.dataset.theme,{pack:`mkt:${Le}`,label:B.dataset.themeSource||Le})}let E=new Map;for(let B of b){let Le=B.dataset.designSystemTheme;if(!Le||!B.dataset.theme)continue;let je=B.dataset.themeSource||Le;E.set(B.dataset.theme,{system:Le,title:je}),A.set(B.dataset.theme,{pack:`ds:${Le}`,label:je})}let L=t.brandThemesOnly!==!1,P=()=>E.size>0&&L,j=()=>[...new Set([...E.values()].map(B=>B.title))].join(" and "),U=new Map,oe=g.length>0,pe=oe?null:document.querySelector('link[rel="stylesheet"][href*="themes/"]:not([data-theme-added])');if(oe){let B=g.find(Le=>!Le.hasAttribute("disabled")&&Le.media!=="not all");B=B||g[0],g.forEach(Le=>{Le.removeAttribute("disabled"),Le.media=Le===B?"all":"not all"})}let D=oe||!!pe,z=B=>(B.match(/themes\/([\w-]+)\.css/)||[])[1],Ce="decklight-theme:"+location.pathname,ee="decklight-custom-themes",re={};re=er(ee,{})||{};let le=null,ie=null,I={};function ce(B,Le,je){let tt=je==="generated"?le:I[B];return tt||(tt=document.createElement("style"),tt.media="not all",je==="generated"?tt.dataset.generated="":tt.dataset.custom=""),tt.dataset.theme=B,tt.textContent=da(B,Le),document.head.appendChild(tt),je==="generated"?le=tt:I[B]=tt,tt}let de=()=>[le,...Object.values(I),...b];function Ie(B){for(let Le of de())Le&&Le!==B&&(Le.media="not all")}let V=()=>de().find(B=>B&&B.media!=="not all")||null,Z=()=>{let B=V();return B?B.dataset.theme:oe?g.find(Le=>Le.media!=="not all")?.dataset.theme:pe?z(pe.href):void 0};function T(){let B=getComputedStyle(e),Le=yt=>yt?.match(/rgba?\(([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[\s,/]+([\d.]+))?\)/),je=Le(B.backgroundColor);(!je||je[4]!==void 0&&+je[4]==0)&&(je=Le(B.backgroundImage));let tt=je?no([+je[1],+je[2],+je[3]])<.5:!1;e.setAttribute("data-canvas",tt?"dark":"light")}pe?.addEventListener("load",T);for(let B of b)B.tagName==="LINK"&&B.addEventListener("load",T);function F({name:B,marketplace:Le,title:je=null}){if(!/^[\w-]+$/.test(B??"")||!/^[\w-]+$/.test(Le??""))return null;let tt=b.find(wt=>wt.dataset.theme===B);if(tt)return tt;let yt=document.createElement("link");return yt.rel="stylesheet",yt.href=`decklight-theme/${Le}/${B}.css`,yt.media="not all",yt.dataset.theme=B,yt.dataset.themeAdded="",yt.dataset.themeMarketplace=Le,je&&(yt.dataset.themeSource=je),yt.addEventListener("load",T),document.head.appendChild(yt),b.push(yt),y.add(B),A.set(B,{pack:`mkt:${Le}`,label:je||Le}),yt}async function se(B){let Le=f?.();if(!(!Le?.available?.()||!(!y.has(B)&&!U.has(B)&&!re[B]&&!(ie&&B===ie.name))&&!$.has(B)&&!E.has(B)))try{let tt=await fetch(Wt()+"/deck/edit/theme",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({theme:B,quiet:!0,from:Le.pageId?.()??null})});if(!tt.ok)throw new Error((await tt.json().catch(()=>({}))).error||`the server said ${tt.status}`)}catch(tt){s(`the theme is on screen but not in the file \u2014 ${String(tt.message||tt).slice(0,100)}`,4e3)}}let _e=null,Te=null;function l(B){clearTimeout(_e),_e=setTimeout(()=>{_e=null,B!==Te&&d(B)},600)}function d(B){clearTimeout(_e),_e=null,Te=B,se(B)}function G(B,Le=!1,{persist:je=!0,deck:tt=!1}={}){if(!B||!/^[\w-]+$/.test(B))return!1;let yt=!1;if(ie&&le&&B===ie.name)le.media="all",Ie(le),yt=!re[B];else if(re[B]){let wt=ce(B,re[B],"custom");wt.media="all",Ie(wt)}else if(y.has(B)||U.has(B)){let wt=U.get(B);if(!y.has(B)&&wt.remote)return!1;let It=b.find(At=>At.dataset.theme===B)??F(wt);It.media="all",Ie(It)}else{if(!D||oe&&!g.some(wt=>wt.dataset.theme===B))return!1;if(Ie(null),oe){let wt=g.find(It=>It.dataset.theme===B);g.forEach(It=>{It.media=It===wt?"all":"not all"})}else pe.href=pe.href.replace(/themes\/[\w-]+\.css(\?.*)?$/,`themes/${B}.css`)}return je&&!n.has("embedded")&&!n.has("capture")&&!yt&&yn(Ce,B),Le||s(B),a("theme",B),T(),je&&tt==="later"?l(B):je&&tt&&d(B),!0}let be=typeof gt<"u"?gt:null,J={added:"Added",custom:"Custom",generated:"Generated"},Qe=B=>[...A.values()].find(Le=>Le.pack===B)?.label,ot=B=>B==="recommended"?"\u2605 Recommended":B===N?"\u25CF Marked":Qe(B)??be?.labels?.[B]??J[B]??B;function fe(B){if(re[B])return"custom";if(ie&&B===ie.name)return"generated";if(A.has(B))return A.get(B).pack;if(y.has(B))return"added";if(be){for(let[Le,je]of Object.entries(be.packs))if(je.includes(B))return Le}return"other"}let K=()=>{let B;if(oe){let je=g.map(tt=>tt.dataset.theme);B=t.themes?.length?t.themes.filter(tt=>je.includes(tt)):je}else B=t.themes?.length?t.themes:typeof pt<"u"?pt:[];let Le=[...y,...U.keys(),...Object.keys(re)];if(ie&&!re[ie.name]&&Le.push(ie.name),B=[...new Set([...B,...Le])],P())return B.filter(je=>E.has(je));if(be){let je=new Map,tt=0;for(let yt of be.order)for(let wt of be.packs[yt]??[])je.set(wt,tt++);B=[...B].sort((yt,wt)=>(je.get(yt)??1e9)-(je.get(wt)??1e9))}return B};function ue(B){let Le=[],je=[];for(let tt of Pr().values()){let yt=(tt.recommendedThemes??[]).map(wt=>String(wt).split("@")[0]).filter(wt=>B.includes(wt));yt.length&&je.push(tt.title||tt.name);for(let wt of yt)Le.includes(wt)||Le.push(wt)}return{names:Le,by:je}}let at="recommended",N="marked",ft=B=>B.filter(Le=>$.has(Le));function M(B){let Le=[],je=ft(B);je.length&&Le.push([N,je]);for(let yt of new Set([...E.values()].map(wt=>`ds:${wt.system}`))){let wt=B.filter(It=>fe(It)===yt);wt.length&&Le.push([yt,wt])}let tt=ue(B);tt.names.length&&Le.push([at,tt.names]);for(let yt of be.order){let wt=(be.packs[yt]??[]).filter(It=>B.includes(It));wt.length&&Le.push([yt,wt])}for(let yt of new Set([...A.values()].map(wt=>wt.pack).filter(wt=>!wt.startsWith("ds:")))){let wt=B.filter(It=>fe(It)===yt);wt.length&&Le.push([yt,wt])}for(let yt of["added","custom","generated"]){let wt=B.filter(It=>fe(It)===yt);wt.length&&Le.push([yt,wt])}return Le}let H=B=>btoa(unescape(encodeURIComponent(JSON.stringify(B)))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),te=B=>JSON.parse(decodeURIComponent(escape(atob(B.replace(/-/g,"+").replace(/_/g,"/")))));function we(B,Le=!1){ie={name:B.name,tokens:B.tokens};let je=ce(B.name,B.tokens,"generated");return je.media="all",Ie(je),Le||s(`\u2728 ${B.name} \u2014 \u2303T re-roll \xB7 \u2303\u21E7T save`,2800),T(),B.name}function Ee(){return P()?(s(`this deck keeps to ${j()}'s themes \u2014 a generated theme is not on its palette`,3200),null):we(di())}function Ke(B){if(!ie||!le||le.media==="not all")return s("no generated theme to save \u2014 \u2303T to generate one"),null;let Le=B??(window.prompt?.("Save theme as:",ie.name.replace(/^gen-/,""))||"");if(Le=String(Le).toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40),!Le)return null;((typeof pt<"u"?pt:[]).includes(Le)||g.some(yt=>yt.dataset.theme===Le))&&(Le="custom-"+Le),re[Le]=ie.tokens,xr(ee,re);let tt=ce(Le,re[Le],"custom");tt.media="all",le?.remove(),le=null,ie=null,Ie(tt),n.has("embedded")||yn(Ce,Le);try{let yt=new Blob([da(Le,re[Le])],{type:"text/css"}),wt=document.createElement("a");wt.href=URL.createObjectURL(yt),wt.download=`${Le}.css`,wt.click(),setTimeout(()=>URL.revokeObjectURL(wt.href),5e3)}catch{}return s(`saved ${Le} \u2014 ${Le}.css downloaded`,2200),Le}let ae=null;function Ze(B=!1){return ae?(clearTimeout(ae.timer),ae=null,B||s("theme cycle cancelled"),!0):!1}function bt(B){let Le=K();if(!D&&!P()||Le.length<2)return;if(ae){let wt=ae;clearTimeout(wt.timer),ae=null,wt.dir===B?G(wt.name,!1,{deck:"later"}):s("theme cycle cancelled");return}let je=Z(),tt=Math.max(0,Le.indexOf(je)),yt=Le[(tt+B+Le.length)%Le.length];if(be&&fe(yt)!==fe(je)){let wt=B>0?".":",",It=B>0?",":".";ae={dir:B,name:yt,timer:setTimeout(()=>{ae=null},4e3)},s(`\u2933 ${ot(fe(yt))} pack next (${yt}) \u2014 ${wt} confirms \xB7 ${It} or Esc cancels`,4e3);return}G(yt,!1,{deck:"later"})}n.has("embedded")&&window.addEventListener("message",B=>{let Le=B.data&&B.data.__decklightPreview;!Le||B.source!==window.parent||(Le.gen?we(Le.gen,!0):Le.theme?(Le.from&&!y.has(Le.theme)&&F({name:Le.theme,marketplace:Le.from}),G(Le.theme,!0)):Le.goto&&h().goto(Le.goto[0],Le.goto[1]??0))});function Pe(){let B=Z(),Le=re[B]?{name:B,tokens:re[B]}:ie&&B===ie.name?ie:null;if(Le)return"?embedded&gen="+H(Le);if(!B)return"?embedded";let je=ke(B);return"?embedded&theme="+encodeURIComponent(B)+(je?"&from="+encodeURIComponent(je):"")}function ke(B){let Le=b.find(tt=>tt.tagName==="LINK"&&tt.dataset.theme===B);return(Le&&/decklight-theme\/([\w-]+)\//.exec(Le.getAttribute("href")??""))?.[1]??U.get(B)?.marketplace??null}function Fe(){let B=n.get("gen");if(B)try{let wt=te(B);if(wt&&wt.tokens){we({name:wt.name||"gen-preview",tokens:wt.tokens},!0);return}}catch{}let Le=n.get("theme"),je=n.get("from");if(Le&&je&&!y.has(Le)&&F({name:Le,marketplace:je}),Le&&G(Le,!0))return;let tt=Nn(Ce);if(tt&&!(P()&&!E.has(tt))&&G(tt,!0))return;let yt=t.theme;if(P()&&!E.has(yt)){let wt=E.keys().next().value;G(wt,!0,{persist:!1}),yt&&(a("theme",`configured ${yt} is not the brand's: opened on ${wt}`),Promise.resolve().then(()=>f?.()?.settled?.()).then(()=>{if(!Mt())return;let It=`decklight-theme-off-brand:${location.pathname}:${yt}`;try{if(sessionStorage.getItem(It))return;sessionStorage.setItem(It,"1")}catch{}s(`"theme": "${yt}" is not one of ${j()}'s themes \u2014 opened on ${wt}; pick one with T, or show every theme to wear ${yt}`,7e3)}).catch(()=>{}));return}yt&&(oe||y.has(yt))&&G(yt,!0,{persist:!1})}function Ve(){if(n.has("embedded")||n.has("capture"))return;let B=[...document.querySelectorAll('meta[name="decklight-theme-missing"]')].map(Le=>Le.content);if(B.length){s(`${B.length===1?"theme":"themes"} not on this machine: ${B.join("; ")}`,7e3);for(let Le of B)a("theme",`missing ${Le}`)}}let et="\0generate",Y="pack:",ve="back",Ne="all",ut="unlock",ht="lock",vt=B=>B.charCodeAt(0)<32,mt=null,Ue=0,Dt,Ct=[],Pt=null,Kt="",hn="packs",Xt=()=>be&&!P()?"packs":"all",Mt=()=>f?.()?.available()===!0,Wt=()=>f?.()?.base()??"",St=null,Vt=()=>typeof pt<"u"?pt:[];async function on(){if(!Mt()||St)return;St={loading:!0};let B;try{let Le=await fetch(Wt()+"/deck/edit/theme/browse"),je=await Le.json().catch(()=>({}));if(Le.ok&&je.ok){for(let tt of je.themes??[])y.has(tt.name)||U.has(tt.name)||re[tt.name]||Vt().includes(tt.name)||g.some(yt=>yt.dataset.theme===tt.name)||(U.set(tt.name,tt),A.set(tt.name,{pack:`mkt:${tt.marketplace}`,label:tt.title||tt.marketplace}));B={stale:je.stale??[]}}else B={error:je.error||`the edit server said ${Le.status}`}}catch{B={error:"the edit server did not answer"}}St=B,mt&&Bn(hn)}let Yt=B=>A.get(B)?.pack?.startsWith("mkt:")===!0;function an(B){return Yt(B)?`${B}@${A.get(B).pack.slice(4)}`:S.includes(B)&&!re[B]?B:null}function Cn(B){return!Mt()||!an(B)?!1:(wn(B),!0)}async function wn(B){let Le=an(B);if(b.find(wt=>wt.dataset.theme===B)?.tagName==="STYLE"&&!$.has(B)){s(`${B} is carried inside the deck \u2014 decklight theme add ${Le} to mark it instead`,4200);return}let tt=!$.has(B),yt=mt?.querySelector(".tp-caption");yt&&(yt.textContent=`${tt?"marking":"unmarking"} ${Le}\u2026`);try{let wt=await fetch(Wt()+"/deck/edit/theme/mark",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ref:Le,marked:tt,quiet:!0})}),It=await wt.json().catch(()=>({}));if(!wt.ok||!It.ok){let At=[It.error,...It.problems??[]].filter(Boolean).join(" \xB7 ");yt&&(yt.textContent=At||`the edit server said ${wt.status}`),s(`${Le}: ${It.error||"refused"}`,3600);return}if(tt)$.add(B);else{$.delete(B);let At=A.get(B);!U.has(B)&&At?.pack.startsWith("mkt:")&&U.set(B,{name:B,marketplace:At.pack.slice(4),title:At.label,qualified:Le})}if(mt){let At=Ue;Er(),tn(At,!0)}s(tt?`${B} marked \u2014 it will be part of the bundle \xB7 ${zt} takes it back`:`${B} unmarked \u2014 the bundle will leave it out`,2800),a("theme",`${Le} ${tt?"marked":"unmarked"}`)}catch{yt&&(yt.textContent="the edit server did not answer")}}function Nt(B){let Le=h().state,je="#/"+Le.slide+"/"+Le.step;if(B===et||re[B]||ie&&B===ie.name){let yt=B===et?Pt:re[B]?{name:B,tokens:re[B]}:ie;return location.pathname+"?embedded&gen="+H(yt)+je}let tt=U.get(B);return location.pathname+"?embedded&theme="+encodeURIComponent(B)+(tt?"&from="+encodeURIComponent(tt.marketplace):"")+je}function Ln(B){B.textContent=Pt?`\u2728 ${Pt.name} \u2014 \u2303T re-rolls`:"\u2728 Generate new\u2026"}function ar(){Pt=di();let B=Ct.indexOf(et);B<0||(Ln(mt.querySelectorAll(".tp-row")[B]),tn(B,!0))}function Er(){let B=mt.querySelector(".tp-list"),Le=Z(),je=K(),tt=new Set(ue(je).names);if(Kt)Ct=je.filter(At=>At.includes(Kt));else if(P())Ct=[...je,...Mt()?[ut]:[]];else if(!be||hn==="all"){let At=[...new Set([...ft(je),...ue(je).names])],In=[...At,...je.filter(Rt=>!At.includes(Rt))];Ct=be?[et,ve,...In]:[et,...In]}else if(hn==="packs")Ct=[et,...M(je).map(([At])=>Y+At),Ne,...E.size&&Mt()?[ht]:[]];else{let At=hn.slice(5);Ct=[ve,...M(je).find(([In])=>In===At)?.[1]??[]]}B.textContent="";let yt=(At,In)=>{let Rt=document.createElement("span");Rt.className="tp-tag",Rt.textContent=In,At.appendChild(Rt)};if(Ct.forEach((At,In)=>{let Rt=document.createElement("div");if(Rt.setAttribute("role","option"),At===et)Rt.className="tp-row tp-gen",Ln(Rt);else if(At===ve)Rt.className="tp-row tp-back",Rt.textContent=Xt()==="packs"?"\u2190 packs":"\u2190 themes";else if(At===Ne)Rt.className="tp-row tp-all",Rt.textContent="\u2733 all themes",yt(Rt,String(je.length));else if(At===ut||At===ht)Rt.className="tp-row tp-brandlock",Rt.textContent=At===ut?"\u25C7 Show every theme\u2026":`\u25C6 Only ${j()}'s themes`;else if(At.startsWith(Y)){let mn=At.slice(Y.length),ye=M(je).find(([lr])=>lr===mn)?.[1]??[];Rt.className="tp-row tp-pack"+(ye.includes(Le)?" tp-current":""),Rt.textContent=`\u25B8 ${ot(mn)}`,yt(Rt,String(ye.length))}else{Rt.className="tp-row"+(At===Le?" tp-current":""),Rt.textContent=At;let mn=Yt(At),ye=an(At)?$.has(At)?"\u25CF":Mt()&&mn?"\u25CB":"":"";mn&&ye&&Rt.classList.add($.has(At)?"tp-marked":"tp-unmarked");let lr=re[At]?"custom":ie&&At===ie.name?"generated":A.has(At)?A.get(At).label:y.has(At)?"added":Kt&&be?ot(fe(At)):null,Ur=[tt.has(At)?"\u2605":"",ye,lr].filter(Boolean).join(" ");Ur&&yt(Rt,Ur)}Rt.addEventListener("mouseenter",()=>tn(In,!1)),Rt.addEventListener("click",()=>{tn(In,!0),Tt()}),B.appendChild(Rt)}),!Ct.length){let At=document.createElement("div");At.className="tp-none",At.textContent="no themes match",B.appendChild(At)}let wt=!Mt()||!St||P()?null:St.loading?"reading the marketplaces\u2026":St.error?St.error:St.stale?.length?`not listed: ${St.stale.join(", ")} \u2014 decklight marketplace update`:null;if(wt&&!hn.startsWith("pack:")){let At=document.createElement("div");At.className="tp-none",At.textContent=wt,B.appendChild(At)}let It=mt.querySelector(".tp-filter");It.textContent=Kt||"type to filter\u2026",It.classList.toggle("tp-active",!!Kt)}function kn(){let B=Z(),Le=Ct.indexOf(B);if(Le>=0)return Le;let je=Ct.indexOf(Y+fe(B));return je>=0?je:P()?0:Math.min(1,Ct.length-1)}function Bn(B,Le=!1){hn=B,Er(),Ct.length&&tn(kn(),Le)}function wr(B){Kt=B.toLowerCase(),Er(),Ct.length?tn(Kt?0:kn(),!1):mt.querySelector(".tp-caption").textContent="no match"}function Nr(){if(mt)return xn();c.opening(xe);let B=K();if(!D&&!B.length)return;Kt="",hn=Xt(),on(),mt=document.createElement("div"),mt.className="decklight-theme-picker",mt.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>',Er(),Qt(mt,xn),e.appendChild(mt);let Le=Z();Le&&nn(mt.querySelector("iframe"),Le),tn(kn(),!Le)}function tn(B,Le){if(!Ct.length)return;Ue=(B+Ct.length)%Ct.length;let je=Ct[Ue];je===et&&!Pt&&(Pt=di(),Ln(mt.querySelectorAll(".tp-row")[Ue])),vn(mt.querySelectorAll(".tp-row"),Ue,"tp-selected");let tt=K(),yt=je===et?Pt?`\u2728 ${Pt.name}`:"generate new":je===ve?Xt()==="packs"?"back to packs":"back to the theme list":je===Ne?`all ${tt.length} themes, flattened`:je===ut?`this deck keeps to ${j()}'s themes \u2014 \u23CE lists every theme, for a room the brand does not suit (writes brandThemesOnly: false)`:je===ht?`\u23CE keeps this deck to ${j()}'s themes again`:je===Y+N?"marked by the deck \u2014 the themes its bundle carries":je===Y+at?`recommended by ${ue(tt).by.join(", ")} \u2014 the themes it was drawn for`:je.startsWith(Y)?`${ot(je.slice(Y.length))} \xB7 ${M(tt).find(([At])=>At===je.slice(Y.length))?.[1].length??0} themes`:Mn(je)?un(je):be?`${ot(fe(je))} \xB7 ${je}`:je,wt=mt.querySelector(".tp-caption");if(wt.textContent=yt,wt.classList.toggle("tp-plain",Mn(je)||je===Y+at||je===Y+N),clearTimeout(Dt),je!==et&&vt(je)||U.get(je)?.remote)return;let It=mt.querySelector("iframe");Le?nn(It,je):Dt=setTimeout(()=>nn(It,je),60)}let Mn=B=>!!an(B)&&(Mt()||$.has(B));function un(B){let Le=U.get(B);return[Yt(B)?an(B):`${ot(fe(B))} \xB7 ${B}`,Le?.description,$.has(B)?Mt()?"marked \u2014 part of the bundle \xB7 Space unmarks":"marked \u2014 part of the bundle":Le?.remote?"lives at a URL \u2014 Space marks it, which reads it once":"not marked \u2014 Space marks it to include it in the bundle"].filter(Boolean).join(" \xB7 ")}function dn(B){if(B===et||re[B]||ie&&B===ie.name)return{gen:B===et?Pt:re[B]?{name:B,tokens:re[B]}:ie};let Le=U.get(B);return Le?{theme:B,from:Le.marketplace}:{theme:B}}let Rn=ro({docOf:()=>"picker",srcFor:Nt,messageFor:B=>({__decklightPreview:dn(B)})}),nn=(B,Le)=>Rn.show(B,Le);function Tt(){let B=Ct[Ue];if(B!==void 0){if(B===et){Pt&&we(Pt),xn();return}if(B===ve){Bn(Xt());return}if(B===Ne){Bn("all");return}if(B===ut||B===ht){fn(B===ht);return}if(B.startsWith(Y)){Bn("pack:"+B.slice(Y.length),!0);return}if(!y.has(B)&&U.get(B)?.remote){s(`${B} is not on this machine yet \u2014 Space marks it, which reads it`,3200);return}G(B,!1,{deck:!0}),xn()}}async function fn(B){let Le=f?.();if(Le?.available?.()){try{let je=await fetch(Wt()+"/deck/edit/brand-themes",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({only:B,quiet:!0,from:Le.pageId?.()??null})}),tt=await je.json().catch(()=>({}));if(!je.ok||!tt.ok)throw new Error(tt.error||`the server said ${je.status}`)}catch(je){s(`not changed \u2014 ${String(je.message||je).slice(0,100)}`,4e3);return}L=B,s(B?`keeping to ${j()}'s themes \xB7 ${zt} takes it back`:`every theme listed \xB7 ${zt} takes it back`,2600),mt?Bn(Xt(),!0):hn=Xt()}}function xn(){clearTimeout(Dt),mt?.remove(),mt=null}let xe=c.register({isOpen:()=>!!mt,close:xn,transient:!0,keydown(B){switch(B.key){case"ArrowDown":tn(Ue+1,!1);break;case"ArrowUp":tn(Ue-1,!1);break;case"Enter":Tt();break;case" ":if(!Cn(Ct[Ue]))return!1;break;case"Backspace":wr(Kt.slice(0,-1));break;case"Escape":Kt?wr(""):hn!==Xt()?Bn(Xt()):xn();break;default:if(B.key.length===1&&/[a-z0-9-]/i.test(B.key)){wr(Kt+B.key);break}return!1}return!0}});return{applyTheme:G,currentTheme:Z,brandLocked:P,renderTheme(){let B=Z();return B?re[B]?{gen:H({name:B,tokens:re[B]})}:ie&&B===ie.name?{gen:H(ie)}:{theme:B}:{}},themeList:K,cycleTheme:bt,cancelCyclePending:Ze,rollTheme:Ee,saveGeneratedTheme:Ke,adoptGenerated:we,updateCanvas:T,restoreSaved:Fe,reportMissing:Ve,previewQuery:Pe,openPicker:Nr,closePicker:xn,browse(){mt||Nr()},hasGenerated:()=>!!ie,rollFromPicker(){return mt&&Ct[Ue]===et?(ar(),!0):!1}}}Se();Ae();Se();Ae();Se();Ae();var ha=["A","B","C","D","E","F","G","H","X"],io="#edb58e",Ic="#c98f6d",Df="#43302a",ao="#b96b58",lo="#57262c",fi="#f6f1ea",Pc="#d17a70",fa=`<svg viewBox="0 0 240 240" role="img" aria-label="Narrator" xmlns="http://www.w3.org/2000/svg">
|
|
294
334
|
<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"/>
|
|
295
335
|
<clipPath id="dlc-bust"><circle cx="120" cy="120" r="114"/></clipPath>
|
|
296
336
|
<g clip-path="url(#dlc-bust)">
|
|
297
337
|
<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)"/>
|
|
298
|
-
<path d="M106 142 L 106 176 C 106 185 134 185 134 176 L 134 142 Z" fill="${
|
|
299
|
-
<path d="M106 142 L 106 156 C 114 162 126 162 134 156 L 134 142 Z" fill="${
|
|
338
|
+
<path d="M106 142 L 106 176 C 106 185 134 185 134 176 L 134 142 Z" fill="${io}"/>
|
|
339
|
+
<path d="M106 142 L 106 156 C 114 162 126 162 134 156 L 134 142 Z" fill="${Ic}"/>
|
|
300
340
|
<g data-idle>
|
|
301
|
-
<circle cx="75" cy="98" r="9" fill="${
|
|
302
|
-
<circle cx="165" cy="98" r="9" fill="${
|
|
303
|
-
<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="${
|
|
304
|
-
<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="${
|
|
341
|
+
<circle cx="75" cy="98" r="9" fill="${io}"/>
|
|
342
|
+
<circle cx="165" cy="98" r="9" fill="${io}"/>
|
|
343
|
+
<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="${io}"/>
|
|
344
|
+
<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="${Df}"/>
|
|
305
345
|
<path d="M92 84 Q 103 78 114 83" stroke="#4a352c" stroke-width="4" fill="none" stroke-linecap="round"/>
|
|
306
346
|
<path d="M126 83 Q 137 78 148 84" stroke="#4a352c" stroke-width="4" fill="none" stroke-linecap="round"/>
|
|
307
347
|
<ellipse cx="103" cy="97" rx="7" ry="5.5" fill="#fbf7f2"/>
|
|
@@ -312,122 +352,179 @@ https://github.com/highlightjs/highlight.js/issues/2277`),le=Q,he=j),oe===void 0
|
|
|
312
352
|
<circle cx="137" cy="97" r="3.2" fill="#5a4030"/>
|
|
313
353
|
<circle cx="137" cy="97" r="1.5" fill="#241a14"/>
|
|
314
354
|
<circle cx="138.3" cy="95.6" r=".8" fill="#fff"/>
|
|
315
|
-
<g data-eyelid><rect x="95" y="90.5" width="16" height="12" rx="6" fill="${
|
|
316
|
-
<g data-eyelid><rect x="129" y="90.5" width="16" height="12" rx="6" fill="${
|
|
317
|
-
<path d="M120 101 L 117 115 Q 120 119 124 116" stroke="${
|
|
355
|
+
<g data-eyelid><rect x="95" y="90.5" width="16" height="12" rx="6" fill="${io}"/></g>
|
|
356
|
+
<g data-eyelid><rect x="129" y="90.5" width="16" height="12" rx="6" fill="${io}"/></g>
|
|
357
|
+
<path d="M120 101 L 117 115 Q 120 119 124 116" stroke="${Ic}" stroke-width="3" fill="none" stroke-linecap="round"/>
|
|
318
358
|
<ellipse cx="96" cy="115" rx="6.5" ry="4" fill="#e59e7d" opacity=".4"/>
|
|
319
359
|
<ellipse cx="144" cy="115" rx="6.5" ry="4" fill="#e59e7d" opacity=".4"/>
|
|
320
|
-
<g data-mouth="X"><path d="M106 130 Q 120 136 134 130" stroke="${
|
|
321
|
-
<g data-mouth="A"><path d="M105 130 Q 120 124 135 130 Q 120 137 105 130 Z" fill="${
|
|
322
|
-
<g data-mouth="B"><path d="M104 129 Q 120 122 136 129 Q 120 141 104 129 Z" fill="${
|
|
323
|
-
<g data-mouth="C"><ellipse cx="120" cy="131" rx="13" ry="8.5" fill="${
|
|
324
|
-
<g data-mouth="D"><ellipse cx="120" cy="132" rx="16" ry="12" fill="${
|
|
325
|
-
<g data-mouth="E"><ellipse cx="120" cy="131" rx="9" ry="7" fill="${
|
|
326
|
-
<g data-mouth="F"><ellipse cx="120" cy="131" rx="6" ry="5.5" fill="${
|
|
327
|
-
<g data-mouth="G"><path d="M105 128 Q 120 123 135 128 Q 120 134 105 128 Z" fill="${
|
|
328
|
-
<g data-mouth="H"><ellipse cx="120" cy="131" rx="12" ry="9" fill="${
|
|
360
|
+
<g data-mouth="X"><path d="M106 130 Q 120 136 134 130" stroke="${ao}" stroke-width="4" fill="none" stroke-linecap="round"/></g>
|
|
361
|
+
<g data-mouth="A"><path d="M105 130 Q 120 124 135 130 Q 120 137 105 130 Z" fill="${ao}"/></g>
|
|
362
|
+
<g data-mouth="B"><path d="M104 129 Q 120 122 136 129 Q 120 141 104 129 Z" fill="${lo}"/><rect x="110" y="126" width="20" height="5" rx="2" fill="${fi}"/></g>
|
|
363
|
+
<g data-mouth="C"><ellipse cx="120" cy="131" rx="13" ry="8.5" fill="${lo}"/><rect x="109" y="124.5" width="22" height="4.5" rx="2" fill="${fi}"/></g>
|
|
364
|
+
<g data-mouth="D"><ellipse cx="120" cy="132" rx="16" ry="12" fill="${lo}"/><rect x="106" y="122" width="28" height="6" rx="2.5" fill="${fi}"/><ellipse cx="120" cy="140" rx="9" ry="4.5" fill="${Pc}"/></g>
|
|
365
|
+
<g data-mouth="E"><ellipse cx="120" cy="131" rx="9" ry="7" fill="${lo}" stroke="${ao}" stroke-width="3"/></g>
|
|
366
|
+
<g data-mouth="F"><ellipse cx="120" cy="131" rx="6" ry="5.5" fill="${lo}" stroke="${ao}" stroke-width="3.5"/></g>
|
|
367
|
+
<g data-mouth="G"><path d="M105 128 Q 120 123 135 128 Q 120 134 105 128 Z" fill="${ao}"/><rect x="110" y="127" width="20" height="5" rx="2" fill="${fi}"/><path d="M108 134 Q 120 139 132 134" stroke="${ao}" stroke-width="3" fill="none" stroke-linecap="round"/></g>
|
|
368
|
+
<g data-mouth="H"><ellipse cx="120" cy="131" rx="12" ry="9" fill="${lo}"/><path d="M113 125 Q 120 122 127 125 Q 127 132 120 133 Q 113 132 113 125 Z" fill="${Pc}"/></g>
|
|
329
369
|
</g>
|
|
330
370
|
</g>
|
|
331
|
-
</svg>`;function xd(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 f=a[p].v;return uo.includes(f)?f:"X"}function ho(t){let o=p=>Math.round(p*1e3)/1e3,a=[],c=(p,f)=>{a.length&&a[a.length-1].v===f||a.push({t:o(p),v:f})},d=0;for(let{timeline:p,gap:f=0}of t){f>0&&(c(d,"X"),d+=f);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 ma({root:t,config:o,debugLog:a,toast:c}){let d=o.narration?.character??{},p=d.bridgeUrl??"http://127.0.0.1:8789",f=d.fallback??"amplitude",m="decklight-character:"+location.pathname,v=d.mode??"off",k=d.engine??"wav2lip",S=d.portrait??"default",P=d.solo??!1;{let ee=Bn(m);ee?.mode&&(v=ee.mode,k=ee.engine??k,S=ee.portrait??S),typeof ee?.solo=="boolean"&&(P=ee.solo)}let T=null,A=null,N=null,I=null,Se=null,pe=null,Oe=null,re=0,ce=!1,Me,ze=new Map,Ve=new Map,$e=ee=>`${ee}|${k}|${S}`;function _e(){Dn(m,{mode:v,engine:k,portrait:S,solo:P})}function Ze(){t.classList.toggle("decklight-solo",P&&v!=="off"&&!!T?.classList.contains("show"))}function bt(){ce||(ce=!0,c("lipsync bridge unreachable \u2014 run: decklight lipsync"),a("lipsync","bridge unreachable \u2014 amplitude fallback"))}function _(){if(T||(T=document.createElement("div"),T.className="decklight-character pos-"+(d.position??"br"),T.setAttribute("aria-hidden","true"),d.size&&T.style.setProperty("--character-size",d.size+"px"),t.appendChild(T)),N!==v)if(N=v,T.classList.toggle("mode-video",v==="video"),A=null,v==="video")T.innerHTML="",A=document.createElement("video"),A.muted=!0,A.playsInline=!0,A.preload="auto",T.appendChild(A);else if(d.sprites){T.innerHTML="";for(let ee of uo){if(!d.sprites[ee])continue;let We=document.createElement("img");We.src=d.sprites[ee],We.setAttribute("data-mouth",ee),We.alt="",T.appendChild(We)}}else if(typeof d.svg=="string"&&d.svg.startsWith("#")){T.innerHTML="";let ee=document.querySelector(d.svg);ee&&T.appendChild(ee.cloneNode(!0))}else typeof d.svg=="string"&&/^\s*</.test(d.svg)?T.innerHTML=d.svg:d.svg?(T.innerHTML=po,fetch(d.svg).then(ee=>ee.text()).then(ee=>{T&&N==="viseme"&&(T.innerHTML=ee)}).catch(()=>{})):T.innerHTML=po}function je(){_(),T.classList.add("show"),re||(re=setInterval(Y,33)),Ze()}function gt(){re&&(clearInterval(re),re=0),T?.classList.remove("show"),A?.pause(),Se=null,pe=null,ut("X"),Ze()}function ut(ee){ee===Oe||!T||(Oe=ee,T.setAttribute("data-viseme",ee))}let Q=null,j=null,oe=null,he=null;function le(){if(f!=="amplitude"||!I)return!1;if(oe===I)return!!j;oe=I;try{Q??=new(window.AudioContext||window.webkitAudioContext);let ee=Q.createMediaElementSource(I);j=Q.createAnalyser(),j.fftSize=512,ee.connect(j),j.connect(Q.destination),he=new Uint8Array(j.fftSize)}catch{j=null}return!!j}function Re(){j.getByteTimeDomainData(he);let ee=0;for(let w=0;w<he.length;w++){let Ie=(he[w]-128)/128;ee+=Ie*Ie}let We=Math.sqrt(ee/he.length);return We<.02?"X":We<.06?"B":We<.12?"C":"D"}function Y(){if(T?.classList.contains("show")){if(v==="video"){A&&I&&A.readyState>=2&&!I.paused&&Math.abs(A.currentTime-I.currentTime)>.15&&(A.currentTime=I.currentTime);return}if(!I||I.paused||I.ended){ut("X");return}Se?ut(xd(Se,I.currentTime)):f==="hide"?ut("X"):le()?ut(Re()):ut("X")}}function s(ee,We,w){if(!ze.has(ee)){let Ie=(async()=>{let g=await We;if(!g)return null;let J=Date.now(),z=await fetch(`${p}/viseme?text=${encodeURIComponent(w??"")}`,{method:"POST",headers:{"content-type":"audio/wav"},body:g.blob});if(!z.ok)throw new Error(String(z.status));let Ce=await z.json();return a("lipsync",`visemes ${ee} \xB7 ${Ce.cues?.length??0} cues \u2192 ${((Date.now()-J)/1e3).toFixed(1)}s`),Ce})();Ie.catch(()=>{ze.get(ee)===Ie&&ze.delete(ee)}),ze.set(ee,Ie)}return ze.get(ee)}function i(ee,We){let w=$e(ee);if(!Ve.has(w)){let Ie=(async()=>{let g=await We;if(!g)return null;let J=Date.now(),z=await fetch(`${p}/video?engine=${k}&portrait=${encodeURIComponent(S)}`,{method:"POST",headers:{"content-type":"audio/wav"},body:g.blob});if(!z.ok)throw new Error(String(z.status));let Ce=await z.blob(),ye=z.headers?.get?.("x-lipsync-cached")==="1";return a("lipsync",`video ${ee} \xB7 ${k} \u2192 ${((Date.now()-J)/1e3).toFixed(1)}s${ye?" (cached)":""}`),URL.createObjectURL(Ce)})();Ie.catch(()=>{Ve.get(w)===Ie&&Ve.delete(w)}),Ve.set(w,Ie)}return Ve.get(w)}function O(ee,We,w){v==="viseme"?s(ee,We,w).catch(()=>{}):v==="video"&&i(ee,We).catch(()=>{})}function Ue(ee,We,w){v!=="off"&&(je(),pe=ee,v==="viseme"?(Se=null,s(ee,Promise.resolve(We),w).then(Ie=>{pe===ee&&(Se=Ie)}).catch(()=>bt())):i(ee,Promise.resolve(We)).then(Ie=>{pe!==ee||!Ie||!A||(A.src=Ie,A.playbackRate=I?.playbackRate??1,I&&!I.paused&&(A.currentTime=I.currentTime,A.play().catch(()=>{})))}).catch(()=>bt()))}function B(ee,We,w=null){if(v==="off"||!ee||ee.live)return;je();let Ie=String(We).padStart(2,"0"),g=w==null?`slide-${Ie}`:`slide-${Ie}-${String(w).padStart(2,"0")}`,J=`file|${ee.dir}|${g}`;if(pe!==J){if(pe=J,v==="viseme")Se=null,(async()=>{let z=document.querySelector(`script[data-decklight-visemes="${g}"]`);if(z)return JSON.parse(z.textContent);let Ce=await fetch(`${ee.dir}/${g}.visemes.json`);if(!Ce.ok)throw new Error(String(Ce.status));return Ce.json()})().then(z=>{pe===J&&(Se=z)}).catch(()=>{});else if(A){let z=`${ee.dir}/slide-${Ie}.mp4`;if(A.src===new URL(z,location.href).href)return;A.src=z,A.playbackRate=I?.playbackRate??1,A.play().catch(()=>{})}}}function Le(ee){!ee||I===ee||(I=ee,ee.addEventListener("pause",()=>{v==="video"&&A?.pause()}),ee.addEventListener("play",()=>{v==="video"&&A?.src&&A.play().catch(()=>{})}),ee.addEventListener("ratechange",()=>{A&&(A.playbackRate=ee.playbackRate)}))}async function $t(){try{let ee=await fetch(p+"/ping");Me=ee.ok?await ee.json():null}catch{Me=null}return Me}function W(ee,We={}){v=ee,We.engine&&(k=We.engine),We.portrait&&(S=We.portrait),_e(),v==="off"?gt():(ce=!1,_(),P&&je()),Ze(),a("lipsync",v==="off"?"character off":`character ${v}${v==="video"?` \xB7 ${k} \xB7 ${S}`:""}`)}function Ae(ee){P=!!ee,_e();let We=!!I&&!I.paused&&!I.ended;P&&v!=="off"?je():!P&&!We&>(),Ze(),a("lipsync",`character solo ${P?"on":"off"}`)}return{get mode(){return v},get engine(){return k},get portrait(){return S},get solo(){return P},get bridgeInfo(){return Me},setMode:W,setSolo:Ae,prefetchSentence:O,beginSentence:Ue,beginSlide:B,attachAudio:Le,stop:gt,probe:$t,ensureTimeline:s}}me();fe();function fa(t){let o=String(t??"").replace(/[?#].*$/,"");return o.slice(0,o.lastIndexOf("/")+1)}var ga=/^[a-z][a-z0-9+.-]*:|^\/\//i;function ba(t,o,a){let c=t?.slides?.[a-1];return c?c.url?c.url:c.file?ga.test(c.file)?c.file:fa(o)+c.file:null:null}function ya(t,o,a,c){let d=t?.slides?.[a-1]?.segments?.[c-1];return d?d.url?d.url:d.file?ga.test(d.file)?d.file:fa(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 wa(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 Ms=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 kd({hasTracks:t,used:o,printMode:a,embedded:c,voiceover:d,captionsOn:p,narrating:f}={}){return!!t&&!o&&!a&&!c&&!d&&!p&&!f}var Ed=.25,Sd=.5,Ad=1;function bo(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 _d=(t,o)=>bo(t,o,Ed);function Ls(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 yo=t=>String(t??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/-/g,"_").toLowerCase();function Sa(t){return yo(t).split(/\s+/).filter(Boolean).map(o=>o.startsWith("lang:")?{lang:o.slice(5)}:{any:o}).filter(o=>o.lang!=="")}function Td(t,o,a){let c=Array.isArray(a)?a:Sa(a);if(!c.length)return!0;let d=yo(t),p=yo(o);return c.every(f=>f.lang!==void 0?p.startsWith(f.lang):d.includes(f.any)||p.includes(f.any))}function va(t,o=0){let a=(t??[]).map(d=>String(d??"").replace(/\s+/g," ").trim()),c=Ls(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 $d(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 xa({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"}`,f=new Set(c),m=p;for(let S=2;f.has(m);S++)m=`${p}-${S}`;let v=m===p?"":`, take ${m.slice(p.length+1)}`,k=a?`My voice${v}`:`${o||"Narration"}${t?` \xB7 ${t}`:""}${v}`;return{dir:m,label:k}}function Cd(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 go(t){return((t??"").match(/[^.!?…]+[.!?…]+[”’"')\]]*|[^.!?…]+$/g)??[]).map(o=>o.trim()).filter(Boolean)}function ka(t){let o=Math.round(t/1e3);return o<60?`${o}s`:`${Math.floor(o/60)}m${String(o%60).padStart(2,"0")}s`}function Os(t,o){let a=t.reduce((p,f)=>p+f.length,0),c=new DataView(new ArrayBuffer(44)),d=(p,f)=>{for(let m=0;m<f.length;m++)c.setUint8(p+m,f.charCodeAt(m))};return d(0,"RIFF"),c.setUint32(4,36+a,!0),d(8,"WAVE"),d(12,"fmt "),c.setUint32(16,16,!0),c.setUint16(20,1,!0),c.setUint16(22,1,!0),c.setUint32(24,o,!0),c.setUint32(28,o*2,!0),c.setUint16(32,2,!0),c.setUint16(34,16,!0),d(36,"data"),c.setUint32(40,a,!0),new Blob([c.buffer,...t],{type:"audio/wav"})}var Ea=(t,o)=>new Uint8Array(2*Math.round(t*o));function Nd(t){let o=t?.name??"";return o==="NotAllowedError"||o==="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":o==="NotFoundError"||o==="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":o==="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 (${Nt(String(t?.message||o||t))}).`}function Aa({root:t,stage:o,config:a,params:c,printMode:d,toast:p,logOnly:f,debugLog:m,overlays:v,instance:k,syncSoundBtn:S,updateDebugState:P,downloadFromUrl:T,authorBase:A=()=>null,authorReady:N=()=>Promise.resolve()}){let I=0,Se="decklight-narration:"+location.pathname,pe=a.narration?.liveUrl??"http://127.0.0.1:8787/tts",Oe=[["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"]],re=pe.replace(/\/tts\/?$/,"/ping"),ce=pe.replace(/\/tts\/?$/,"/voices/install"),Me=pe.replace(/\/tts\/?$/,"/engines"),ze=pe.replace(/\/tts\/?$/,"/engine"),Ve=Oe,$e=!0,_e=null,Ze=null,bt=new Set,_=null,je=!1,gt=null;function ut(){return _??=fetch(re).then(b=>b.ok?b.json():null).then(b=>b?(je=!0,Q(b),m("tts",`bridge: ${b.engine} \xB7 ${b.model} \xB7 ${Ve.length} voice(s)`+($e?"":" \xB7 no style")),b):null).catch(()=>null),_}function Q(b){if(!b)return null;if(_e=b.engine??null,Ze=typeof b.caveat=="string"?b.caveat:null,Array.isArray(b.voices)&&b.voices.length&&(Ve=b.voices),$e=b.stylable!==!1,Ve.length&&!Ve.some(([$])=>$===Re.voice)){let $=Re.voice;Re={...Re,voice:Ve[0][0]},Tn(),m("tts",`voice ${$} is not on this bridge \u2014 using ${Re.voice}`),Y?.live&&p(`voice ${$} \u2192 ${Re.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"]],oe=([,b,$])=>_e==="elevenlabs"?$:b,he=Cd(a.narration),le={live:!0},Re={voice:"Alnilam",tone:j[0][0],style:j[0][1]},Y=null;try{let b=Bn(Se);if(b?.live?.voice)Re=b.live,Y=le;else if(!b?.off){let $=b?.track??b?.dir,R=he.find(G=>fo(G)===$);R&&(Y=R)}}catch{}let s=!1,i=null,O="decklight-narr-rate:"+location.pathname,Ue=1;try{let b=parseFloat(kn(O)??"");b>=.25&&b<=2&&(Ue=b)}catch{}function B(b){Ue=Math.round(Math.min(2,Math.max(.25,Ue+b))*100)/100,fn(O,String(Ue)),i&&(i.playbackRate=Ue),p(`voice speed ${Ue}\xD7`),m("narr",`rate ${Ue}\xD7`),P()}let Le=ma({root:t,config:a,debugLog:m,toast:p}),$t=new Map;function W(b){return(k._sections?.[b-1]?.querySelector("aside.notes")?.textContent??"").replace(/⟨CLICK⟩/g," ").replace(/\s+/g," ").trim()}function Ae(b){return(k._sections?.[b-1]?.querySelector("aside.notes")?.textContent??"").split("\u27E8CLICK\u27E9").map(R=>R.replace(/\s+/g," ").trim())}function ee(b,$,R){if(!b)return Promise.resolve(null);if(!$t.has($)){let G=(async()=>{let Z=Date.now();try{let xe=await fetch(pe,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:b,voice:Re.voice,style:Re.style})});if(!xe.ok)throw new Error(String(xe.status));let F=await xe.blob(),ae=parseFloat(xe.headers?.get?.("x-tts-cost")??"")||0;return ae&&(I+=ae),m("tts",`${R} \xB7 ${Re.voice} \xB7 ${b.length} chars \u2192 ${((Date.now()-Z)/1e3).toFixed(1)}s`+(ae?` \xB7 ~$${ae.toFixed(4)}`:"")),{url:URL.createObjectURL(F),blob:F}}catch(xe){throw m("tts",`${R} \xB7 ${Re.voice} FAILED after ${((Date.now()-Z)/1e3).toFixed(1)}s (${String(xe.message||xe)})`),xe}})();G.catch(()=>{$t.get($)===G&&$t.delete($)}),$t.set($,G)}return $t.get($)}let We=b=>k._records?.[b-1]?.groups.length??0;function w(b,$){let R=Ae(b),G=$<We(b)?[R[$]]:R.slice($),Z=[],xe=new Set;for(let F of G){let ae=go(F);ae.length&&xe.add(Z.length),Z.push(...ae)}return{sentences:Z,segStarts:xe}}let Ie=(b,$)=>w(b,$).sentences,g=new Set;function J(b){if(g.has(b))return;let $=Ae(b).length,R=We(b)+1;if($<=R)return;g.add(b);let G=`slide ${b}: ${$} \u27E8CLICK\u27E9 segments but ${R} build step${R===1?"":"s"} \u2014 the last ${$-R} ${$-R===1?"is":"are"} spoken on the final step`;f?.(G),m("narr",G)}let z=(b,$,R)=>`${b}|s${$}|n${R}|${Re.voice}|${Re.style}`;function Ce(b,$,R){let G=Ie(b,$)[R]??"";return ee(G,z(b,$,R),`slide ${b} seg ${$} #${R+1}`)}let ye=b=>k._sections[b-1]?.dataset.narration==="hold",Pe=b=>bo(k._sections[b-1]?.dataset.narrationPause,a.narration?.slidePause,Ad),X=b=>bo(k._sections[b-1]?.dataset.narrationBeatPause,a.narration?.beatPause,Sd),Xe=b=>_d(k._sections[b-1]?.dataset.narrationSentencePause,a.narration?.sentencePause);async function mt(b,$){if(!(b>0))return!Je&&!$();for(let R=b*1e3;R>0;){if($())return!1;let G=Date.now();await new Promise(Z=>setTimeout(Z,Math.min(150,R))),Je||(R-=Date.now()-G)}return!Je&&!$()}let ft=10,ke=3,ue=0;function ie(b){let $=[],R=k.state.slide,G=k.state.step;for(;$.length<b&&R<=k.state.totalSlides;){let Z=We(R);for(;G<=Z&&$.length<b;G++){let xe=Ie(R,G).length;for(let F=0;F<xe&&$.length<b;F++)$.push([R,G,F])}R+=1,G=0}return $}async function Ke(){let b=++ue,$=async()=>{for(;b===ue&&s&&Y?.live;){let R=ie(ft).find(([G,Z,xe])=>!$t.has(z(G,Z,xe)));if(!R)return;try{if(await Ce(R[0],R[1],R[2]),Le.mode!=="off"){let[G,Z,xe]=R;Le.prefetchSentence(z(G,Z,xe),$t.get(z(G,Z,xe)),go(Ae(G)[Z])[xe]??"")}}catch{return}await new Promise(G=>setTimeout(G,30))}};await Promise.all(Array.from({length:ke},$))}let rt=0,Je=!1,tt=!1,Rt=0;function jt(){if(!s){p("narration is off \u2014 \u23B5 starts it");return}Je=!Je,Je?i?.pause():i?.src&&i.paused&&!i.ended&&i.currentTime>0?i.play().catch(()=>{}):tt||sn(),p(Je?"\u23F8 narration paused \u2014 \u23B5 resumes":"\u25B6 narration resumed"),m("narr",Je?"paused":"resumed"),P()}let en=()=>Y?.live?"live":Y?"file":null;async function Pt(b,$,{mode:R="live",endOfSlide:G=!1}={}){let Z=rt,xe=()=>Z!==rt||!s||en()!==R||k.state.slide!==b||k.state.step!==$;if(Je||xe())return;let F=async(Ye,ot)=>(Ye>0&&m("narr",`slide ${b} \u2014 holding ${Ye}s before ${ot}`),mt(Ye,xe)),ae=k._records[b-1];if(!G&&$<(ae?ae.groups.length:0)){if(!await F(X(b),"the next build"))return;k.next();return}ye(b)||b>=k.state.totalSlides||await F(Pe(b),"the next slide")&&k.goto(b+1,0)}async function sn(){let b=k.state.slide,$=k.state.step,R=++rt;if(Ke(),!W(b)){if(ye(b)){m("narr",`hold on slide ${b} \u2014 manual advance`);return}setTimeout(()=>{R!==rt||!s||!Y?.live||k.state.slide===b&&b<k.state.totalSlides&&k.goto(b+1,0)},400);return}J(b);let G=Ie(b,$);if(!G.length){setTimeout(()=>{R===rt&&Pt(b,$)},600);return}let Z=()=>R!==rt||!s||k.state.slide!==b||k.state.step!==$;Rt=R,tt=!0;let xe=0;try{for(let F=0;F<G.length;F++){for(;Je;){if(Z())return;await new Promise(ot=>setTimeout(ot,150))}if(Z())return;let ae;try{ae=await Ce(b,$,F)}catch(ot){m("narr",`sentence failed (slide ${b} seg ${$} #${F+1}) \u2014 narration stopped`),H(Gt(ot));return}if(Z())return;if(!ae)continue;Be(G[F]),i??=new Audio,Le.mode!=="off"&&(Le.attachAudio(i),Le.beginSentence(z(b,$,F),ae,G[F])),i.onended=null,i.onerror=null,i.src=ae.url,i.playbackRate=Ue;let Ye=!1;if(await new Promise(ot=>{i.onended=ot,i.play().catch(()=>{Ye=!0,ot()})}),Ye){H("\u{1F507} the browser blocked audio \u2014 click the deck once, then V \u2014 the slides wait for the voice");return}if(xe++,F<G.length-1&&!await mt(Xe(b),Z))return}if(Z())return;if(!xe&&G.length){H("\u{1F507} the voice did not play \u2014 auto-advance stopped \xB7 press the key left of 1 for messages");return}await Pt(b,$)}finally{Rt===R&&(tt=!1)}}function Gt(b){let $=String(b?.message??b);return $.startsWith("429")?"\u{1F507} voice quota exceeded (429) \u2014 auto-advance stopped \xB7 a free engine: decklight author --tts-engine chirp":/^\d{3}/.test($)?`\u{1F507} voice bridge error ${$.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 At=new Map,on=new Map,un=new Set,qt=null;function pn(b){for(let $ of document.querySelectorAll('script[type="application/json"][data-decklight-voices]'))if($.getAttribute("data-decklight-voices")===b)try{return JSON.parse($.textContent)}catch{return null}return null}function te(b){if(!At.has(b)){let $=pn(b);At.set(b,$?Promise.resolve($):fetch(b).then(R=>{if(!R.ok)throw new Error(`HTTP ${R.status}`);return R.json()}).catch(R=>{throw At.delete(b),R})),At.get(b).then(R=>on.set(b,R)).catch(()=>{})}return At.get(b)}function Kt(b){let $=on.get(b.manifest);if(!$)return un.has(b.manifest)?"hosted \u2014 the voice list did not load":(te(b.manifest).catch(()=>un.add(b.manifest)).then(()=>{Wt&&Zt==="tracks"&&Ct("tracks")}),"hosted \u2014 checking\u2026");let R=Yr($);return R.at?R.expired?`EXPIRED ${Ms(R.at)} \u2014 re-sign to play`:`signed \xB7 ${wa(R.msLeft)}`:"hosted \xB7 no expiry"}async function _t(){if(!Y||Y.live||!Y.manifest)return qt=null,C=tn(),!0;if(qt?.track!==Y)try{qt={track:Y,data:await te(Y.manifest)}}catch($){return qt=null,H(`\u{1F507} could not load the voice list for \u201C${Y.label}\u201D (${Y.manifest} \u2014 ${$.message}) \u2014 auto-advance stopped`),!1}let b=Yr(qt.data);return b.expired?(H(`\u{1F507} the signed voices for \u201C${Y.label}\u201D expired ${Ms(b.at)} \u2014 auto-advance stopped \xB7 re-sign: ${mo(qt.data)}`),!1):(C=tn(),!0)}function tn(){if(Yt.clear(),!Y||Y.live||Y.segments===!1)return!1;if(Y.manifest){let b=qt?.data,$=b?.slides??[],R=!!Yr(b).at;return $.some(G=>Array.isArray(G?.segments)&&G.segments.length&&(!R||G.segments.every(Z=>Z?.url)))}return Y.segments===!0}let Yt=new Set,C=!1;function ne(b,$){if(!C||Yt.has(b))return null;let R=Ae(b),G=Ls(R);if(!G)return null;let Z=$>=We(b),xe=Math.min($,G.length),F=(Z?G.slice(xe):G.slice(xe,xe+1)).filter(ae=>ae!==null).map(ae=>({file:ae,url:Y.manifest?ya(qt?.data,Y.manifest,b,ae):`${Y.dir}/slide-${String(b).padStart(2,"0")}-${String(ae).padStart(2,"0")}.${Y.ext??"m4a"}`}));return F.every(ae=>ae.url)?F:null}function Ee(b){return Y.manifest?ba(qt?.data,Y.manifest,b):`${Y.dir}/slide-${String(b).padStart(2,"0")}.${Y.ext??"m4a"}`}function we(){if(Y)return Y.live?sn():C?M():Ne()}function Ne({selfDriving:b=!1,gen:$=rt}={}){let R=k.state.slide,G=k.state.step;if(!W(R)){i?.pause();return}let Z=Ee(R);if(!Z){i?.pause();return}i??=new Audio,i.onended=null,i.onerror=null,i.src=Z,i.playbackRate=Ue,Le.mode!=="off"&&(Le.attachAudio(i),Le.beginSlide(Y,R)),b&&(i.onended=()=>{$===rt&&Pt(R,G,{mode:"file",endOfSlide:!0})});let xe=!1;i.onerror=()=>{xe=!0,Ge(R,Z)},i.play().catch(F=>{F?.name==="NotAllowedError"?p("\u{1F507} the browser blocked audio \u2014 click the deck once, then V"):xe||Ge(R,Z)})}function Ge(b,$,{fatal:R=!1}={}){m("narr",`no audio: ${$}`);let G=Y?.manifest?Yr(qt?.data):null;if(G?.at){m("narr","signed url failed \u2014 a media element cannot report the status"),H(`\u{1F507} slide ${b} of \u201C${Y.label}\u201D would not load (signed until ${Ms(G.at)}) \u2014 auto-advance stopped \xB7 re-sign: ${mo(qt?.data)}`);return}if(R){H(`\u{1F507} no audio for slide ${b} (${$}) \u2014 auto-advance stopped \xB7 press the key left of 1 for messages`);return}p(`\u{1F507} no narration for slide ${b} (${$}) \xB7 press the key left of 1 for messages`)}async function M(){let b=k.state.slide,$=k.state.step,R=++rt;if(!W(b)){if(ye(b)){m("narr",`hold on slide ${b} \u2014 manual advance`);return}setTimeout(()=>{R!==rt||!s||en()!=="file"||k.state.slide===b&&b<k.state.totalSlides&&k.goto(b+1,0)},400);return}J(b);let G=ne(b,$);if(!G){Ne({selfDriving:!0,gen:R});return}if(!G.length){setTimeout(()=>{R===rt&&Pt(b,$,{mode:"file"})},600);return}let Z=()=>R!==rt||!s||en()!=="file"||k.state.slide!==b||k.state.step!==$;Rt=R,tt=!0;try{for(let xe=0;xe<G.length;xe++){for(;Je;){if(Z())return;await new Promise(ae=>setTimeout(ae,150))}if(Z())return;i??=new Audio,Le.mode!=="off"&&(Le.attachAudio(i),Le.beginSlide(Y,b,G[xe].file)),i.onended=null,i.onerror=null,i.src=G[xe].url,i.playbackRate=Ue;let F=await new Promise(ae=>{i.onended=()=>ae("ended"),i.onerror=()=>ae("error"),i.play().catch(Ye=>ae(Ye?.name==="NotAllowedError"?"blocked":"error"))});if(Z())return;if(F==="blocked"){H("\u{1F507} the browser blocked audio \u2014 click the deck once, then V \u2014 the slides wait for the voice");return}if(F==="error"){if($===0&&xe===0){m("narr",`no segments for slide ${b} \u2014 falling back to the whole-slide file`),Yt.add(b),Ne({selfDriving:!0,gen:R});return}Ge(b,G[xe].url,{fatal:!0});return}}if(Z())return;await Pt(b,$,{mode:"file"})}finally{Rt===R&&(tt=!1)}}function H(b="narration off"){s=!1,rt++,ue++,Je=!1,i?.pause(),Le.stop(),p(b),m("narr",b),S()}function K(){return s?jt():qe()}let se=()=>s||Je||!!Y;async function qe(){if(!Y){p(he.length||je?"no voice chosen \u2014 V picks one":"no narration here \u2014 V shows what is available");return}if(s)return H();if(Jn(),Y.live&&await ut(),!await _t())return;s=!0;let b=Y.live?`\u26A1 ${Re.voice} \xB7 ${Re.tone}`:Y.label;p(`\u{1F50A} ${b} \u2014 \u23B5 pauses \xB7 V picks`),m("narr",`on \u2014 ${b}`),we(),S()}k.on("slide",()=>{s&&we()}),k.on("build",()=>{s&&(Y?.live?sn():C&&M())});let Qe="decklight-captions:"+location.pathname,Fe=!1;Fe=kn(Qe)==="1";let ge=null;function Be(b){ge&&(ge.textContent=b,ge.classList.toggle("show",!!b))}function st(){if(ge){if(s&&Y?.live){Be("");return}Be(Ie(k.state.slide,k.state.step).join(" "))}}function wt(){ge=document.createElement("div"),ge.className="decklight-captions",ge.setAttribute("aria-live","polite"),t.appendChild(ge),st()}function Mt(){Fe=!Fe,fn(Qe,Fe?"1":"0"),Fe?(wt(),cn()):(ge?.remove(),ge=null),p(`captions ${Fe?"on":"off"}`),m("narr",`captions ${Fe?"on":"off"}`)}k.on("slide",st),k.on("build",st),Fe&&!d&&wt();let pt="\u{1F50A} this deck has a voice-over \u2014 V plays it",nt=900,vt=12e3,L="decklight-narr-used:"+location.pathname,Bt=!1;Bt=kn(L)==="1";let ln=null;function cn(){if(!ln)return;let b=ln;ln=null,b.classList.remove("show"),setTimeout(()=>b.remove(),260)}function Jn(){cn(),!Bt&&(Bt=!0,fn(L,"1"))}function dr(){let b=document.createElement("button");b.type="button",b.className="decklight-narr-hint",b.setAttribute("aria-label","Play this deck\u2019s voice-over");let $=document.createElement("kbd");$.textContent="V",b.append("\u{1F50A} this deck has a voice-over \u2014 ",$," plays it"),b.addEventListener("click",()=>{cn(),qe()}),ln=b,t.appendChild(b),b.offsetWidth,b.classList.add("show"),f?.(pt),m("narr","voice-over hint shown"),setTimeout(cn,vt)}kd({hasTracks:he.length>0,used:Bt,printMode:d,embedded:!!c?.has("embedded"),voiceover:!!c?.has("voiceover"),captionsOn:Fe})&&setTimeout(()=>{s||dr()},nt);let Wt=null,yn=0,Zt="tracks",xt=[],_n=null;function Tn(){try{Dn(Se,Y?.live?{live:Re}:Y?{track:fo(Y),dir:Y.dir}:{off:!0})}catch{}}function wn(b,$){Re={voice:_n??Re.voice,tone:b,style:$},Y=le,Tn(),D(),s||(s=!0),p(`\u26A1 live voice: ${Re.voice} \xB7 ${Re.tone} \u2014 V stops`),m("narr",`live config \u2014 ${Re.voice} \xB7 ${Re.tone}`),we()}function Ot(b,{scroll:$=!1}={}){xt.length&&(yn=En(Wt.querySelectorAll(".narr-row"),b,"narr-sel",{scroll:$}))}function Yn(){xt[yn]?.commit()}function Ln(){Zt==="custom"?Ct("tones"):Zt==="tones"||Zt==="engines"?Ct("voices"):Zt==="charvideo"?Ct("character"):Zt==="record"||Zt==="voices"||Zt==="character"?Ct("tracks"):D()}let Xn=!1;function an(b,$){Le.setMode(b,$),D(),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 ${Le.engine} \xB7 ${Le.portrait}${s?"":" \xB7 V starts narration"}`)}function Qn(b){if(Le.mode==="off"){p("turn the character on first \u2014 N \xB7 Character\u2026");return}Le.setSolo(b),D(),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 er="Hey, this is Decklight",zn=er,Xt="",gn=!1,vn=null,Sn=new Map,Un=new Map,Hn=null,jn=new Set;function Fr(b){if(b===er)return Sn;if(b!==Hn){for(let $ of Un.values())$.then(R=>URL.revokeObjectURL(R)).catch(()=>{});Un=new Map,Hn=b}return Un}let Tt=(b,$)=>`${b}|${$||""}`;function Gn(b,$,R,G=""){let Z=Tt($,G);if(!b.has(Z)){let xe=(async()=>{let F=Date.now(),ae=await fetch(pe,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:R,voice:$,style:G})});if(!ae.ok)throw new Error(String(ae.status));let Ye=await ae.blob(),ot=parseFloat(ae.headers?.get?.("x-tts-cost")??"")||0;return ot&&(I+=ot),m("tts",`preview ${$}${G?" (styled)":""} \xB7 ${((Date.now()-F)/1e3).toFixed(1)}s`+(ot?` \xB7 ~$${ot.toFixed(4)}`:"")),URL.createObjectURL(Ye)})();xe.catch(()=>{b.get(Z)===xe&&b.delete(Z)}),b.set(Z,xe)}return b.get(Z)}async function $n(b,$,R){let G=`${R}|${b}`;if(jn.has(G))return;jn.add(G);let Z=b===er,xe=Z?Sn:Un;try{m("narr",`preview prefetch ${R} (${Z?"default":"custom"} sentence)`);for(let{voice:F,style:ae}of $){if(!Z&&Hn!==b)return;xe.has(Tt(F,ae))||await Gn(xe,F,b,ae).catch(()=>{})}m("narr",`preview prefetch ${R} complete`)}finally{jn.delete(G)}}function Cn({voice:b,style:$="",prefetch:R},G){let Z=zn.trim();if(!Z)return;let xe=Fr(Z);G&&(G.textContent="\u2026"),Gn(xe,b,Z,$).then(F=>{if(G?.isConnected&&(G.textContent="\u25B6"),vn??=new Audio,vn.src=F,vn.play().catch(()=>{}),m("narr",`preview ${b}${$?" \xB7 styled":""}`),R==="voices"){let ae=xt.filter(Ye=>Ye.preview).map(Ye=>({voice:Ye.preview.voice,style:""}));$n(Z,ae,"voices")}else R==="tones"&&$n(Z,j.map(ae=>({voice:b,style:oe(ae)})),`tones:${b}`)}).catch(()=>{G?.isConnected&&(G.textContent="\u25B6"),p("live voice bridge unreachable \u2014 run: decklight tts"),m("narr",`preview ${b} failed`)})}function Ct(b){let $=Zt;Zt=b,b==="voices"&&$!=="voices"&&(gn=!0);let R=Wt.querySelector(".narr-card");R.innerHTML="";let G=document.createElement("div");if(G.className="narr-head",R.appendChild(G),xt=[],b==="tracks")G.textContent="narration",xt.push({text:"\u{1F507} Off \u2014 no voice",flavor:he.length||je?"\u23B5 advances the deck":"",cur:!Y,commit:()=>{let F=s||Je;Y=null,Tn(),D(),F?H("\u{1F507} narration off"):p("\u{1F507} narration off")}}),he.forEach(F=>xt.push({text:F.manifest?`\u2601 ${F.label}`:`\u{1F50A} ${F.label} (${F.dir}/)`,flavor:F.manifest?Kt(F):"",cur:F===Y,commit:()=>{Y=F,Tn(),D(),p(`\u{1F50A} track: ${F.label}`),s&&_t().then(ae=>{ae&&we()})}})),xt.push({text:"\u26A1 Live voice \u2014 synthesize on the fly\u2026",cur:Y?.live,commit:()=>Ct("voices")}),xt.push({text:"\u{1F9D1} Character \u2014 animated narrator\u2026",cur:Le.mode!=="off",commit:()=>Ct("character")}),xt.push({text:"\u{1F399} Record this deck\u2026",flavor:he.some(F=>!F.live)?"re-record, or add another take":"write the audio to a folder",commit:()=>Ct("record")}),xt.push({text:`${Fe?"\u2611":"\u2610"} Captions \u2014 follow the voice on screen`,flavor:"C",toggle:!0,commit:()=>{Mt(),Ct("tracks")}}),xt.push({text:`\u23E9 Speed \u2014 ${Ue}\xD7`,flavor:"< slower \xB7 > faster",toggle:!0,commit:()=>{B(Ue>=2?-1.75:.25),Ct("tracks")}});else if(b==="record"){G.textContent="record this deck \u2014 writes wav files beside it";let F=Ar();xt.push({text:"\u{1F3A4} With your voice \u2014 read it aloud, beat by beat",flavor:F?"":"the deck turns pages as you speak",blocked:F||null,commit:()=>{if(F)return p(F,5e3);D(),hs()}});let ae=Y?.live?null:"pick a live voice first \u2014 \u26A1 Live voice, above";xt.push({text:"\u{1F50A} With the synthesized voice \u2014 unattended",flavor:ae?"":`speaks every slide as ${Re.voice}`,blocked:ae,commit:()=>{if(ae)return p(ae,5e3);D(),Hr()}})}else if(b==="character"){G.textContent="character \u2014 an animated narrator lip-syncs the voice",Xn||(Xn=!0,Le.probe().then(()=>{Wt&&Zt==="character"&&Ct("character")}));let F=Le.bridgeInfo,ae=F?.engines?.video??[];xt.push({text:"Off",cur:Le.mode==="off",commit:()=>an("off")}),xt.push({text:"\u{1F3AD} 2D character \u2014 offline visemes",flavor:F?.engines?.viseme?"":"bridge offline \u2014 amplitude fallback",cur:Le.mode==="viseme",commit:()=>an("viseme")}),xt.push({text:`\u{1F3A5} Neural video \u2014 local GPU${ae.length?"\u2026":""}`,flavor:ae.length?"":"needs the bridge \u2014 run: decklight lipsync",cur:Le.mode==="video",commit:()=>{ae.length?Ct("charvideo"):p("video needs wav2lip/sadtalker on the bridge \u2014 run: decklight lipsync")}}),Le.mode!=="off"&&xt.push({text:`${Le.solo?"\u25C9":"\u25CB"} Solo \u2014 the narrator takes the stage`,flavor:"slide content steps aside",cur:Le.solo,commit:()=>Qn(!Le.solo)})}else if(b==="charvideo"){G.textContent="neural video \u2014 pick engine \xB7 portrait";let F=Le.bridgeInfo;for(let ae of F?.engines?.video??[])for(let Ye of F?.portraits?.length?F.portraits:["default"])xt.push({text:`\u{1F3A5} ${ae} \xB7 ${Ye}`,cur:Le.mode==="video"&&Le.engine===ae&&Le.portrait===Ye,commit:()=>an("video",{engine:ae,portrait:Ye})})}else if(b==="engines")G.textContent="live voice \u2014 which engine speaks",gt||fetch(Me).then(F=>F.ok?F.json():{stale:!0}).then(F=>{gt=F?.stale?"stale":F?.engines??[]}).catch(()=>{gt=[]}).then(()=>{Wt&&Zt==="engines"&&Ct("engines")}),gt?gt==="stale"?xt.push({text:`\u26A1 ${_e??"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:()=>{}}):gt.length||xt.push({text:"no voice bridge is answering",flavor:"the engine list comes from it",blocked:"decklight author",cur:!1,commit:()=>{}}):xt.push({text:"asking the bridge\u2026",cur:!1,commit:()=>{}}),(Array.isArray(gt)?gt:[]).forEach(F=>xt.push({text:F.name,flavor:F.ready?F.cost??"":F.why??"unavailable",blocked:F.ready?null:F.fix??null,cur:!!F.current,commit:()=>Rn(F)}));else if(b==="voices"){let F=Sa(Xt),ae=F.length?Ve.filter(([yt,Ft])=>Td(yt,Ft,F)):Ve;G.textContent=F.length?`live voice \u2014 ${ae.length} of ${Ve.length} \xB7 \u25B6 previews`:"live voice \u2014 pick a voice \xB7 \u25B6 previews",xt.push({text:`\u2699 engine: ${_e??"the bridge"}\u2026`,flavor:"changes which voices exist",cur:!1,commit:()=>Ct("engines")});let Ye=document.createElement("div");Ye.className="narr-preview-row narr-filter-row";let ot=document.createElement("input");ot.className="narr-input narr-filter",ot.value=Xt,ot.placeholder="Filter voices \u2014 try fr, or lang:fr",ot.setAttribute("aria-label","Filter voices by name or language"),ot.addEventListener("input",()=>{Xt=ot.value,gn=!0,Ct("voices")}),ot.addEventListener("keydown",yt=>{yt.key==="Escape"?(Xt?(Xt="",gn=!0,Ct("voices")):Ln(),yt.preventDefault()):(yt.key==="ArrowDown"||yt.key==="Enter")&&(gn=!1,ot.blur(),Ot(0,{scroll:!0}),yt.preventDefault()),yt.stopPropagation()}),Ye.appendChild(ot),R.appendChild(Ye);let De=document.createElement("div");De.className="narr-preview-row";let lt=document.createElement("input");lt.className="narr-input narr-preview-text",lt.value=zn,lt.placeholder="Preview sentence",lt.setAttribute("aria-label","Preview sentence"),lt.addEventListener("input",()=>{zn=lt.value}),lt.addEventListener("keydown",yt=>{yt.key==="Escape"&&(Ln(),yt.preventDefault()),yt.stopPropagation()});let It=document.createElement("button");It.type="button",It.className="narr-prev-btn narr-reset-btn",It.textContent="\u21BA",It.title="restore the default sentence",It.setAttribute("aria-label","restore the default preview sentence"),It.addEventListener("click",yt=>{yt.stopPropagation(),zn=er,lt.value=er}),De.append(lt,It),R.appendChild(De),(_e==="say"||_e==="sapi")&&Ze&&!Ve.some(([,,yt])=>yt==="best")&&xt.push({text:_e==="sapi"?"\u2B07 Get natural voices \u2014 free download":"\u2B07 Get Siri voices \u2014 free download",flavor:_e==="sapi"?"opens Settings \u2192 Narrator":"opens System Settings",group:"best",commit:()=>{fetch(ce,{method:"POST"}).then(yt=>yt.json()).then(yt=>{if(!yt?.ok)throw new Error(yt?.error||"refused")}).then(()=>p("System Settings opened \u2014 download a Siri voice, then restart decklight tts",5200)).catch(()=>p(Ze,6e3))}});let Lt=["novelty","other languages"],Dt=new Set;ae.forEach(([yt,Ft,zt])=>{if(!F.length&&zt&&Lt.includes(zt)&&!bt.has(zt)){if(!Dt.has(zt)){Dt.add(zt);let On=ae.filter(([,,Ks])=>Ks===zt).length;xt.push({text:`\u2023 ${zt==="novelty"?"novelty voices":zt} (${On})`,toggle:!0,cur:!1,commit:()=>{bt.add(zt),Ct("voices")}})}return}xt.push({text:yt,flavor:Ft,group:zt??null,preview:{voice:yt,style:"",prefetch:"voices"},cur:Y?.live&&Re.voice===yt,commit:()=>{if(_n=yt,$e)return Ct("tones");wn(_e??"plain","")}})}),F.length&&!ae.length&&xt.push({text:"no voice matches",flavor:"Esc clears the filter \xB7 lang:fr narrows to a language",blocked:!0,commit:()=>{}})}else if(b==="tones")G.textContent=`live voice \xB7 ${_n??Re.voice} \u2014 pick a tone \xB7 \u25B6 previews`,j.forEach(F=>{let[ae]=F,Ye=oe(F);xt.push({text:ae,preview:{voice:_n??Re.voice,style:Ye,prefetch:"tones"},cur:Y?.live&&Re.tone===ae,commit:()=>wn(ae,Ye)})}),xt.push({text:"Custom\u2026",cur:Y?.live&&Re.tone==="Custom",commit:()=>Ct("custom")});else{G.textContent=`live voice \xB7 ${_n??Re.voice} \u2014 type the delivery instruction \xB7 \u25B6 previews`;let F=document.createElement("div");F.className="narr-preview-row";let ae=document.createElement("input");ae.className="narr-input",ae.value=Re.style,ae.placeholder="Read in a \u2026",ae.addEventListener("keydown",ot=>{ot.key==="Enter"?(x(),ot.preventDefault()):ot.key==="Escape"&&(Ln(),ot.preventDefault()),ot.stopPropagation()});let Ye=document.createElement("button");Ye.type="button",Ye.className="narr-prev-btn narr-reset-btn",Ye.textContent="\u25B6",Ye.title="preview this delivery instruction",Ye.setAttribute("aria-label","preview this delivery instruction"),Ye.addEventListener("click",ot=>{ot.stopPropagation();let De=ae.value.trim();De&&Cn({voice:_n??Re.voice,style:De},Ye)}),F.append(ae,Ye),R.appendChild(F),setTimeout(()=>{ae.focus(),ae.select()},0),xt=[],yn=0;return}let Z=null;xt.forEach((F,ae)=>{if(F.group!==Z&&(Z=F.group??null,F.group)){let De=document.createElement("div");De.className="narr-group",De.textContent=F.group,R.appendChild(De)}let Ye=document.createElement("div");Ye.className="narr-row"+(F.cur?" narr-cur":"")+(F.toggle?" narr-toggle":"")+(F.blocked||F.blocked===""?" narr-blocked":"");let ot=document.createElement("span");if(ot.className="narr-row-label",ot.textContent=F.text,F.flavor){let De=document.createElement("span");De.className="narr-flavor",De.textContent=F.flavor,ot.appendChild(De)}if(Ye.appendChild(ot),F.blocked){let De=document.createElement("div");De.className="narr-fix",De.textContent=F.blocked,Ye.appendChild(De)}if(F.preview){let De=document.createElement("button");De.type="button",De.className="narr-prev-btn",De.textContent="\u25B6",De.title=`preview ${F.preview.voice}`,De.setAttribute("aria-label",`preview ${F.preview.voice}`),De.addEventListener("click",lt=>{lt.stopPropagation(),Cn(F.preview,De)}),Ye.appendChild(De)}Ye.addEventListener("mouseenter",()=>Ot(ae)),Ye.addEventListener("click",()=>{Ot(ae),Yn()}),R.appendChild(Ye)});let xe=xt.findIndex(F=>F.cur);if(Ot(Math.max(0,xe),{scroll:!0}),gn){let F=R.querySelector(".narr-filter");F&&(F.focus(),F.setSelectionRange(F.value.length,F.value.length))}}async function Rn(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 Ct("voices");try{let R=await(await fetch(ze,{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);_=Promise.resolve(Q(R)),gt=null,m("tts",`engine \u2192 ${R.engine} \xB7 ${R.model} \xB7 ${Ve.length} voice(s)`),p(`\u26A1 engine: ${R.engine}${R.cost?` \xB7 ${R.cost}`:""} \u2014 this session only`,3200),R.caveat&&p(R.caveat,6e3),Ct("voices")}catch{p(`${b.name}: the voice bridge did not answer`,3e3)}}}function x(){let b=Wt?.querySelector(".narr-input")?.value.trim();b&&wn("Custom",b)}function q(b){if(Wt&&b===void 0)return D();Wt||(Wt=document.createElement("div"),Wt.className="decklight-narr",Wt.innerHTML='<div class="narr-card" role="listbox" aria-label="Narration"></div>',Ht(Wt,D),t.appendChild(Wt)),Ct(b??"tracks"),ut().then($=>{$&&Wt&&Zt==="voices"&&Ct("voices")})}function D(){Wt?.remove(),Wt=null,bt.clear(),Xt="",gn=!1,Xn=!1}let ve=null,et="confirm",St=0,Jt=null;function hn(){let b=[];for(let Z=1;Z<=k.state.totalSlides;Z++)W(Z)&&b.push(Z);let $=/^(\d+)(?:-(\d+))?$/.exec(c?.get?.("slides")??"");if(!$)return b;let R=Number($[1]),G=$[2]?Number($[2]):R;return b.filter(Z=>Z>=R&&Z<=G)}function bn(b,$={}){et=b;let R=ve.querySelector(".narr-card");if(b==="confirm"){let G=$.total;R.innerHTML=`<div class="narr-head">record offline narration</div>
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
371
|
+
</svg>`;function Bf(e,t){let n=e?.cues;if(!n?.length||!(t>=0)||e.duration&&t>=e.duration)return"X";let s=0,a=n.length-1,c=-1;for(;s<=a;){let f=s+a>>1;n[f].t<=t?(c=f,s=f+1):a=f-1}if(c<0)return"X";let h=n[c].v;return ha.includes(h)?h:"X"}function ma(e){let t=c=>Math.round(c*1e3)/1e3,n=[],s=(c,h)=>{n.length&&n[n.length-1].v===h||n.push({t:t(c),v:h})},a=0;for(let{timeline:c,gap:h=0}of e){h>0&&(s(a,"X"),a+=h);for(let f of c?.cues??[])s(a+f.t,f.v);a+=c?.duration??0}return{v:1,kind:"visemes",duration:t(a),source:"stitch",cues:n}}function Ff(e,t=1){return Math.abs(e)>.25?{seek:!0,rate:t}:Math.abs(e)>.015?{seek:!1,rate:t*(e>0?.92:1.08)}:{seek:!1,rate:t}}function Dc({root:e,config:t,debugLog:n,toast:s}){let a=t.narration?.character??{},c=a.bridgeUrl??(/^https?:$/.test(location.protocol)?`${location.origin}/deck/lipsync`:"http://127.0.0.1:8789"),h=a.fallback??"amplitude",f="decklight-character:"+location.pathname,g=a.mode??"off",b=a.engine??"wav2lip",y=a.portrait??"default",$=a.solo??!1;{let Pe=er(f);Pe?.mode&&(g=Pe.mode,b=Pe.engine??b,y=Pe.portrait??y),typeof Pe?.solo=="boolean"&&($=Pe.solo)}let S=null,A=null,E=null,L=null,P=null,j=null,U=null,oe=0,pe=!1,D,z=new Map,Ce=new Map,ee=Pe=>`${Pe}|${b}|${y}`,re=null,le=()=>{re&&(re.src=`${c}/portrait?name=${encodeURIComponent(y)}`)};function ie(){xr(f,{mode:g,engine:b,portrait:y,solo:$})}function I(){e.classList.toggle("decklight-solo",$&&g!=="off"&&!!S?.classList.contains("show"))}function ce(){pe||(pe=!0,s("the lip-sync bridge is not running \u2014 the mouth follows the voice's loudness instead. decklight starts it once rhubarb is installed or a talking head is set up (V \u2192 Character says how)",6e3),n("lipsync","bridge unreachable \u2014 amplitude fallback"))}function de(){if(S||(S=document.createElement("div"),S.className="decklight-character pos-"+(a.position??"br"),S.setAttribute("aria-hidden","true"),a.size&&S.style.setProperty("--character-size",a.size+"px"),e.appendChild(S)),E!==g)if(E=g,S.classList.toggle("mode-video",g==="video"),A=null,re=null,g==="video"){S.innerHTML="",re=document.createElement("img"),re.className="still",re.alt="",re.addEventListener("error",()=>re?.classList.add("missing")),re.addEventListener("load",()=>re?.classList.remove("missing")),S.appendChild(re),le(),A=document.createElement("video"),A.muted=!0,A.playsInline=!0,A.preload="auto",A.addEventListener("playing",()=>A?.classList.add("live"));for(let Pe of["ended","emptied","error"])A.addEventListener(Pe,()=>A?.classList.remove("live"));S.appendChild(A)}else if(a.sprites){S.innerHTML="";for(let Pe of ha){if(!a.sprites[Pe])continue;let ke=document.createElement("img");ke.src=a.sprites[Pe],ke.setAttribute("data-mouth",Pe),ke.alt="",S.appendChild(ke)}}else if(typeof a.svg=="string"&&a.svg.startsWith("#")){S.innerHTML="";let Pe=document.querySelector(a.svg);Pe&&S.appendChild(Pe.cloneNode(!0))}else typeof a.svg=="string"&&/^\s*</.test(a.svg)?S.innerHTML=a.svg:a.svg?(S.innerHTML=fa,fetch(a.svg).then(Pe=>Pe.text()).then(Pe=>{S&&E==="viseme"&&(S.innerHTML=Pe)}).catch(()=>{})):S.innerHTML=fa}function Ie(){de(),S.classList.add("show"),oe||(oe=setInterval(fe,33)),I()}function V(){oe&&(clearInterval(oe),oe=0),S?.classList.remove("show"),A?.pause(),P=null,j=null,Z("X"),I()}function Z(Pe){Pe===U||!S||(U=Pe,S.setAttribute("data-viseme",Pe))}let T=null,F=null,se=null,_e=null;function Te(){if(h!=="amplitude"||!L)return!1;if(se===L)return!!F;se=L;try{T??=new(window.AudioContext||window.webkitAudioContext);let Pe=T.createMediaElementSource(L);F=T.createAnalyser(),F.fftSize=512,Pe.connect(F),F.connect(T.destination),_e=new Uint8Array(F.fftSize)}catch{F=null}return!!F}function l(){F.getByteTimeDomainData(_e);let Pe=0;for(let Fe=0;Fe<_e.length;Fe++){let Ve=(_e[Fe]-128)/128;Pe+=Ve*Ve}let ke=Math.sqrt(Pe/_e.length);return ke<.02?"X":ke<.06?"B":ke<.12?"C":"D"}let d=(Number(a.lipOffsetMs)||0)/1e3,G=null;function be(){try{return G??=new(window.AudioContext||window.webkitAudioContext),G.state==="suspended"&&G.resume().catch(()=>{}),(G.outputLatency||0)+(G.baseLatency||0)}catch{return 0}}let J=()=>Math.max(0,L.currentTime-be()-d),Qe=!1;function ot(){if(!A||!L||A.readyState<2||L.paused||A.paused)return;let Pe=J();Qe||(Qe=!0,n("lipsync",`lips follow what is heard: audio output delay ${Math.round(be()*1e3)} ms`+(d?` \xB7 lipOffsetMs ${Math.round(d*1e3)}`:"")));let ke=Ff(A.currentTime-Pe,L.playbackRate||1);ke.seek&&(A.currentTime=Pe),A.playbackRate!==ke.rate&&(A.playbackRate=ke.rate)}function fe(){if(S?.classList.contains("show")){if(g==="video"){ot();return}if(!L||L.paused||L.ended){Z("X");return}P?Z(Bf(P,L.currentTime)):h==="hide"?Z("X"):Te()?Z(l()):Z("X")}}function K(Pe,ke,Fe){if(!z.has(Pe)){let Ve=(async()=>{let et=await ke;if(!et)return null;let Y=Date.now(),ve=await fetch(`${c}/viseme?text=${encodeURIComponent(Fe??"")}`,{method:"POST",headers:{"content-type":"audio/wav"},body:et.blob});if(!ve.ok)throw new Error(String(ve.status));let Ne=await ve.json();return n("lipsync",`visemes ${Pe} \xB7 ${Ne.cues?.length??0} cues \u2192 ${((Date.now()-Y)/1e3).toFixed(1)}s`),Ne})();Ve.catch(()=>{z.get(Pe)===Ve&&z.delete(Pe)}),z.set(Pe,Ve)}return z.get(Pe)}function ue(Pe,ke){let Fe=ee(Pe);if(!Ce.has(Fe)){let Ve=(async()=>{let et=await ke;if(!et)return null;let Y=Date.now(),ve=await fetch(`${c}/video?engine=${b}&portrait=${encodeURIComponent(y)}`,{method:"POST",headers:{"content-type":"audio/wav"},body:et.blob});if(!ve.ok)throw new Error(String(ve.status));let Ne=await ve.blob(),ut=ve.headers?.get?.("x-lipsync-cached")==="1";return n("lipsync",`video ${Pe} \xB7 ${b} \u2192 ${((Date.now()-Y)/1e3).toFixed(1)}s${ut?" (cached)":""}`),URL.createObjectURL(Ne)})();Ve.catch(()=>{Ce.get(Fe)===Ve&&Ce.delete(Fe)}),Ce.set(Fe,Ve)}return Ce.get(Fe)}function at(Pe,ke,Fe){g==="viseme"?K(Pe,ke,Fe).catch(()=>{}):g==="video"&&ue(Pe,ke).catch(()=>{})}function N(Pe,ke,Fe){g!=="off"&&(Ie(),j=Pe,g==="viseme"?(P=null,K(Pe,Promise.resolve(ke),Fe).then(Ve=>{j===Pe&&(P=Ve)}).catch(()=>ce())):(A?.classList.remove("live"),ue(Pe,Promise.resolve(ke)).then(Ve=>{j!==Pe||!Ve||!A||(A.src=Ve,A.playbackRate=L?.playbackRate??1,L&&!L.paused&&(A.currentTime=J(),A.play().catch(()=>{})))}).catch(()=>ce())))}let ft=new Map;function M(Pe){return ft.has(Pe)||ft.set(Pe,fetch(Pe).then(ke=>(ke.body?.cancel?.().catch?.(()=>{}),ke.ok)).catch(()=>!0)),ft.get(Pe)}async function H(){return((D===void 0?await ae():D)?.engines?.video??[]).includes(b)}function te(Pe){let ke=`rec|${Pe}`;return Ce.has(ee(ke))?ue(ke,Promise.resolve(null)):ue(ke,fetch(Pe).then(Fe=>Fe.ok?Fe.blob():null).then(Fe=>Fe&&{blob:Fe}))}function we(Pe,ke,Fe){if(g!=="video"||!Pe||Pe.live||!Fe?.length)return;let Ve=`${Pe.dir}/slide-${String(ke).padStart(2,"0")}.mp4`;M(Ve).then(async et=>{if(!(et||g!=="video"||!await H()))for(let Y of Fe)te(Y).catch(()=>{})})}function Ee(Pe,ke,Fe=null,Ve=null){if(g==="off"||!Pe||Pe.live)return;Ie();let et=String(ke).padStart(2,"0"),Y=Fe==null?`slide-${et}`:`slide-${et}-${String(Fe).padStart(2,"0")}`,ve=`file|${Pe.dir}|${Y}`;if(j!==ve){if(j=ve,g==="viseme")P=null,(async()=>{let Ne=document.querySelector(`script[data-decklight-visemes="${Y}"]`);if(Ne)return JSON.parse(Ne.textContent);let ut=await fetch(`${Pe.dir}/${Y}.visemes.json`);if(!ut.ok)throw new Error(String(ut.status));return ut.json()})().then(Ne=>{j===ve&&(P=Ne)}).catch(()=>{});else if(A){let Ne=`${Pe.dir}/slide-${et}.mp4`;M(Ne).then(async ut=>{if(j!==ve||g!=="video")return;if(ut||!Ve){if(A.src===new URL(Ne,location.href).href)return;A.src=Ne,A.playbackRate=L?.playbackRate??1,A.play().catch(()=>{});return}if(A.removeAttribute("src"),A.load(),!await H())return;let ht=await te(Ve).catch(()=>(ce(),null));j!==ve||!ht||g!=="video"||(A.src=ht,A.playbackRate=L?.playbackRate??1,L&&!L.paused&&(A.currentTime=J(),A.play().catch(()=>{})))})}}}function Ke(Pe){!Pe||L===Pe||(L=Pe,Pe.addEventListener("pause",()=>{g==="video"&&A?.pause()}),Pe.addEventListener("play",()=>{g==="video"&&A?.src&&A.play().catch(()=>{})}),Pe.addEventListener("ratechange",()=>{A&&(A.playbackRate=Pe.playbackRate)}))}async function ae(){try{let Pe=await fetch(c+"/ping");D=Pe.ok?await Pe.json():null}catch{D=null}return D}function Ze(Pe,ke={}){g=Pe,ke.engine&&(b=ke.engine),ke.portrait&&(y=ke.portrait),ie(),le(),g==="off"?V():(pe=!1,de(),$&&Ie()),I(),n("lipsync",g==="off"?"character off":`character ${g}${g==="video"?` \xB7 ${b} \xB7 ${y}`:""}`)}function bt(Pe){$=!!Pe,ie();let ke=!!L&&!L.paused&&!L.ended;$&&g!=="off"?Ie():!$&&!ke&&V(),I(),n("lipsync",`character solo ${$?"on":"off"}`)}return{get mode(){return g},get engine(){return b},get portrait(){return y},get solo(){return $},get bridgeInfo(){return D},get bridge(){return c},setMode:Ze,setSolo:bt,prefetchSentence:at,beginSentence:N,beginSlide:Ee,prefetchFiles:we,attachAudio:Ke,stop:V,probe:ae,ensureTimeline:K}}Se();Ae();Se();Ae();var Bc=["|","/","-","\\"];function Es(e,{label:t="thinking",every:n=120}={}){let s=globalThis.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches===!0,a=Date.now(),c=0,h=()=>{let b=Math.floor((Date.now()-a)/1e3),y=s?".".repeat(1+c%3).padEnd(3):Bc[c%Bc.length];e(`${t} ${y}${b>=2?` ${b}s`:""}`),c++};h();let f=setInterval(h,s?600:n),g=!1;return()=>{g||(g=!0,clearInterval(f))}}var qf=["video/mp4;codecs=avc1","video/mp4","video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"];function ga(e=globalThis){return e.MediaRecorder?e.navigator?.mediaDevices?.getUserMedia?null:e.location?.protocol==="file:"?"a browser will not open the camera for a page loaded from a file \u2014 run decklight <deck.html>":"this browser exposes no camera (getUserMedia needs http://127.0.0.1 or https://)":"this browser cannot record video (no MediaRecorder)"}function jf(e){let t=e?.name;return t==="NotAllowedError"||t==="SecurityError"?"the camera was refused \u2014 allow it for this page (the camera icon in the address bar), then try again":t==="NotFoundError"||t==="OverconstrainedError"?"no camera found on this machine":t==="NotReadableError"?"the camera is busy \u2014 another app is using it":`the camera would not open: ${e?.message??e}`}function Fc({root:e,bridge:t,debugLog:n=()=>{},onUse:s=()=>{},seconds:a=8,name:c="filmed",getUserMedia:h=y=>navigator.mediaDevices.getUserMedia(y),fetchFn:f=(...y)=>fetch(...y),createRecorder:g=(y,$)=>new MediaRecorder(y,$),countdownMs:b=700}){let y=null,$="closed",S=null,A=null,E=null,L=null,P=0,j=()=>{},U=()=>y?.querySelector(".narr-card"),oe=`<ul class="film-tips">
|
|
372
|
+
<li>face the camera, your face in the circle, evenly lit</li>
|
|
373
|
+
<li>mouth relaxed and closed \u2014 <strong>don't talk</strong></li>
|
|
374
|
+
<li>blink, breathe \u2014 but keep your head still</li></ul>`;function pe(ce,de={}){$=ce;let Ie=U();if(!Ie)return;j();let V=(Z="")=>`<div class="film-circle"><video class="film-video" muted playsinline autoplay></video>${Z}</div>`;if(ce==="why"){Ie.innerHTML=`<div class="narr-head">film yourself</div>
|
|
375
|
+
<div class="rec-line rec-warn">${Et(de.why)}</div>
|
|
376
|
+
<div class="rec-hint">Esc to close</div>`;return}if(ce==="opening"){Ie.innerHTML='<div class="narr-head">film yourself</div><div class="rec-line film-busy"></div>',j=Es(Z=>{let T=Ie.querySelector(".film-busy");T&&(T.textContent=Z)},{label:"opening the camera"});return}if(ce==="ready"){Ie.innerHTML=`<div class="narr-head">film yourself \u2014 ${a} s for your talking head</div>
|
|
377
|
+
${V('<div class="film-mark"></div>')}
|
|
378
|
+
<div class="film-below">${oe}<div class="narr-row narr-sel film-go">\u25CF Record ${a} s</div></div>
|
|
379
|
+
<div class="rec-hint">Enter to record \xB7 Esc to cancel</div>`;let Z=Ie.querySelector(".film-video");Z.classList.add("mirror"),Z.srcObject=S,Z.play?.().catch(()=>{}),Ie.querySelector(".film-go").addEventListener("click",ee);return}if(ce==="review"){Ie.innerHTML=`<div class="narr-head">your take \u2014 ${de.secs.toFixed(1)} s</div>
|
|
380
|
+
${V()}
|
|
381
|
+
<div class="narr-row narr-sel film-use">Use it \u2014 as \u201C${Et(c)}\u201D</div>
|
|
382
|
+
<div class="narr-row film-retake">Retake</div>
|
|
383
|
+
<div class="rec-hint">Enter to use it \xB7 R to retake \xB7 Esc to cancel</div>`;let Z=Ie.querySelector(".film-video");Z.src=L,Z.loop=!0,Z.play?.().catch(()=>{}),Ie.querySelector(".film-use").addEventListener("click",le),Ie.querySelector(".film-retake").addEventListener("click",re);return}if(ce==="saving"){Ie.innerHTML=`<div class="narr-head">film yourself</div>
|
|
384
|
+
<div class="rec-line film-busy"></div>
|
|
385
|
+
<div class="rec-line">finding your face in every second of it, and making the loop \u2014 once; a minute at most</div>`,j=Es(Z=>{let T=Ie.querySelector(".film-busy");T&&(T.textContent=Z)},{label:"the bridge is preparing it"});return}ce==="failed"&&(Ie.innerHTML=`<div class="narr-head">film yourself</div>
|
|
386
|
+
<div class="rec-line rec-warn">${Et(de.error)}</div>
|
|
387
|
+
${S?'<div class="narr-row narr-sel film-retake">Retake</div>':""}
|
|
388
|
+
<div class="rec-hint">${S?"Enter or R to retake \xB7 ":""}Esc to close</div>`,Ie.querySelector(".film-retake")?.addEventListener("click",re))}async function D(){if(y)return;y=document.createElement("div"),y.className="decklight-narr decklight-record decklight-film",y.innerHTML='<div class="narr-card" role="dialog" aria-label="Film yourself"></div>',Qt(y,ie),e.appendChild(y);let ce=++P,de=ga();if(de)return pe("why",{why:de});pe("opening");try{let Ie=await h({video:{width:{ideal:1280},height:{ideal:720},facingMode:"user"},audio:!1});if(ce!==P){Ie.getTracks().forEach(V=>V.stop());return}S=Ie,pe("ready")}catch(Ie){ce===P&&pe("why",{why:jf(Ie)})}}function z(ce,de){$=ce;let Ie=U();Ie&&(Ie.querySelector(".film-mark").textContent=de,Ie.querySelector(".film-circle").classList.toggle("rec",ce==="recording"),Ie.querySelector(".narr-head").textContent=ce==="recording"?`\u25CF recording \u2014 ${a} s`:"film yourself \u2014 get ready",Ie.querySelector(".film-below").innerHTML=`<div class="rec-line film-hold">hold still \u2014 mouth relaxed, don't talk</div>`,Ie.querySelector(".rec-hint").textContent="Esc to stop")}function Ce(ce,de){return new Promise(Ie=>setTimeout(()=>Ie(de===P),ce))}async function ee(){if($!=="ready"||!S)return;let ce=P;for(let F of[3,2,1])if(z("countdown",String(F)),!await Ce(b,ce))return;let de=qf.find(F=>globalThis.MediaRecorder?.isTypeSupported?.(F))??"",Ie=[];A=g(S,de?{mimeType:de}:void 0),A.ondataavailable=F=>{F.data?.size&&Ie.push(F.data)};let V=new Promise(F=>{A.onstop=F}),Z=performance.now();A.start(250);for(let F=a;F>0;F--)if(z("recording",`${F}s`),!await Ce(1e3,ce)){try{A.stop()}catch{}return}if(A.stop(),await V,ce!==P)return;let T=(performance.now()-Z)/1e3;E=new Blob(Ie,{type:(A.mimeType||de||"video/webm").split(";")[0]}),A=null,L&&URL.revokeObjectURL(L),L=URL.createObjectURL(E),n("character",`filmed ${T.toFixed(1)} s \xB7 ${(E.size/1024).toFixed(0)} KB \xB7 ${E.type}`),pe("review",{secs:T})}function re(){S&&(P++,E=null,pe("ready"))}async function le(){if($!=="review"||!E)return;let ce=P;pe("saving");try{let de=await f(`${t}/portrait?name=${encodeURIComponent(c)}`,{method:"POST",headers:{"content-type":E.type},body:E}),Ie=await de.json().catch(()=>({}));if(ce!==P)return;if(!de.ok||!Ie.ok)return pe("failed",{error:Ie.error??`the lip-sync bridge answered ${de.status}`});ie(),s({name:Ie.name??c,steady:Ie.steady,seconds:Ie.seconds})}catch(de){ce===P&&pe("failed",{error:`the lip-sync bridge did not answer (${de.message??de})`})}}function ie(){P++,j();try{A?.state==="recording"&&A.stop()}catch{}A=null,S?.getTracks().forEach(ce=>ce.stop()),S=null,L&&URL.revokeObjectURL(L),L=null,E=null,y?.remove(),y=null,$="closed"}function I(ce){if(ce.key==="Escape")return ie(),!0;if(ce.key==="Enter"){if($==="ready")ee();else if($==="review")le();else if($==="failed")re();else return!1;return!0}return(ce.key==="r"||ce.key==="R"||ce.key==="Backspace")&&($==="review"||$==="failed")?(re(),!0):!1}return{open:D,close:ie,keydown:I,isOpen:()=>!!y,get view(){return $}}}Se();Ae();function Hf(e,t){let n=/^(\d+)(?:-(\d+))?$/.exec(String(e??"").trim().replace(/\s*[-–—]\s*/,"-"));if(!n)return null;let s=Number(n[1]),a=n[2]?Number(n[2]):s;return s>=1&&s<=a&&a<=t?{from:s,to:a}:null}function qc({from:e,to:t},n){return e===1&&t===n?null:e===t?String(e):`${e}-${t}`}function Co(e){if(!e)return"all slides";let[t,n]=String(e).split("-");return n?`slides ${t}\u2013${n}`:`slide ${t}`}function zf({slide:e,total:t,chapters:n=[]}){let s=[],a=(h,f,g)=>{let b=qc({from:f,to:g},t);s.some(y=>y.slides===b)||s.push({label:h,slides:b})};a(`All slides \u2014 1\u2013${t}`,1,t),a(`This slide \u2014 ${e}`,e,e);let c=n.filter(h=>h.slide<=e).at(-1);if(c){let h=n.find(g=>g.slide>c.slide),f=h?h.slide-1:t;a(`This chapter \u2014 ${c.title} (${c.slide}\u2013${f})`,c.slide,f)}return e<t&&a(`From here to the end \u2014 ${e}\u2013${t}`,e,t),e>1&&a(`Up to here \u2014 1\u2013${e}`,1,e),s}function jc({root:e,overlays:t}){let n=null,s=[],a=[],c=0,h=null,f=null,g=null,b=[];function y(){n?.remove(),n=null,g=null,b=[]}function $(P){f.textContent=P,f.style.display=P?"":"none"}function S(P,j){let U=s[P]?.setting;!U||U.options.length<2||(U.index=(U.index+j+U.options.length)%U.options.length,a[P].querySelector(".range-setting-value").textContent=U.options[U.index].label)}function A(P,{focusBox:j=!0}={}){c=vn(a,P,"narr-sel"),s[c].custom&&j?h.focus():!s[c].custom&&document.activeElement===h&&h.blur()}function E(P=c){let j=s[P];if(!j||!g)return;if(j.setting){S(P,1);return}let U=j.slides;if(j.custom){let D=h.value.trim(),z=Hf(D,g.total);if(!z){$(D?`${D} is not a range of this deck \u2014 1 to ${g.total}, like 2-5`:"type a range first, like 2-5"),h.focus();return}U=qc(z,g.total)}let{onPick:oe}=g,pe=Object.fromEntries(b.map(D=>[D.key,D.options[D.index].value]));y(),oe(U,pe)}function L({title:P,lines:j=[],total:U,slide:oe,chapters:pe=[],current:D=null,settings:z=[],onPick:Ce}){n&&y(),g={total:U,onPick:Ce},b=z.filter(de=>de?.options?.length).map(de=>({...de,index:Math.min(Math.max(0,de.index??0),de.options.length-1)})),s=[...b.map(de=>({setting:de})),...zf({slide:oe,total:U,chapters:pe}),{label:"Slides\u2026",custom:!0}],n=document.createElement("div"),n.className="decklight-narr decklight-range";let ee=document.createElement("div");ee.className="narr-card",ee.setAttribute("role","dialog"),ee.setAttribute("aria-label",P);let re=document.createElement("div");re.className="narr-head",re.textContent=P,ee.append(re);for(let de of j){let Ie=document.createElement("div");Ie.className="rec-line",Ie.textContent=de,ee.append(Ie)}let le=de=>!de.custom&&!de.setting,ie=s.some(de=>le(de)&&de.slides===D);a=s.map((de,Ie)=>{let V=document.createElement("div");if(de.setting){V.className="narr-row range-setting"+(Ie===b.length-1?" range-setting-last":"");let T=document.createElement("span");T.className="range-setting-name",T.textContent=de.setting.name;let F=document.createElement("span");return F.className="narr-row-label range-setting-value",F.textContent=de.setting.options[de.setting.index].label,V.append(T,F),V.addEventListener("mouseenter",()=>{document.activeElement!==h&&A(Ie,{focusBox:!1})}),V.addEventListener("click",()=>{A(Ie,{focusBox:!1}),S(Ie,1)}),ee.append(V),V}V.className="narr-row"+(de.custom?" range-custom":"")+((de.custom?D&&!ie:de.slides===D)?" narr-cur":"");let Z=document.createElement("span");return Z.className="narr-row-label",Z.textContent=de.label,V.append(Z),de.custom&&(h=document.createElement("input"),h.type="text",h.inputMode="numeric",h.spellcheck=!1,h.placeholder=`like 2-${Math.min(U,5)}`,h.setAttribute("aria-label","slide range"),D&&!ie&&(h.value=D),h.addEventListener("focus",()=>{c!==Ie&&A(Ie,{focusBox:!1})}),h.addEventListener("keydown",T=>{T.key==="Enter"?(T.preventDefault(),E(Ie)):T.key==="Escape"?(T.preventDefault(),y()):T.key==="ArrowUp"||T.key==="ArrowDown"?(T.preventDefault(),A(c+(T.key==="ArrowDown"?1:-1))):$("")}),V.append(h)),V.addEventListener("mouseenter",()=>{document.activeElement!==h&&A(Ie,{focusBox:!1})}),V.addEventListener("click",T=>{if(de.custom){T.target!==h&&A(Ie);return}A(Ie,{focusBox:!1}),E(Ie)}),ee.append(V),V}),f=document.createElement("div"),f.className="rec-line rec-warn",$(""),ee.append(f);let I=document.createElement("div");I.className="rec-hint",I.textContent=b.length?"\u2191\u2193 choose \xB7 \u2190 \u2192 change a setting \xB7 Enter picks the slides \xB7 type a range, like 2-5 \xB7 Esc closes":"\u2191\u2193 choose \xB7 Enter picks \xB7 type a range, like 2-5 \xB7 Esc closes",ee.append(I),n.append(ee),Qt(n,y),e.appendChild(n);let ce=s.findIndex(de=>le(de)&&de.slides===D);A(ce>=0?ce:D?s.length-1:0,{focusBox:!1})}return t.register({isOpen:()=>!!n,close:y,keydown(P){return P.key==="ArrowDown"||P.key==="ArrowUp"?A(c+(P.key==="ArrowDown"?1:-1),{focusBox:!1}):P.key==="ArrowLeft"||P.key==="ArrowRight"?S(c,P.key==="ArrowRight"?1:-1):P.key==="Enter"?E():P.key==="Escape"?y():/^[0-9-]$/.test(P.key)&&(A(s.length-1,{focusBox:!1}),h.value+=P.key,h.focus(),$("")),!0}}),{open:L,close:y,isOpen:()=>!!n}}Se();Ae();function Hc(e){let t=String(e??"").replace(/[?#].*$/,"");return t.slice(0,t.lastIndexOf("/")+1)}var zc=/^[a-z][a-z0-9+.-]*:|^\/\//i;function Uc(e,t,n){let s=e?.slides?.[n-1];return s?s.url?s.url:s.file?zc.test(s.file)?s.file:Hc(t)+s.file:null:null}function Gc(e,t,n,s){let a=e?.slides?.[n-1]?.segments?.[s-1];return a?a.url?a.url:a.file?zc.test(a.file)?a.file:Hc(t)+a.file:null:null}function To(e,t=Date.now()){let n=e?.expires;if(!n)return{at:null,msLeft:1/0,expired:!1};let s=new Date(n);if(Number.isNaN(s.getTime()))return{at:null,msLeft:1/0,expired:!1};let a=s.getTime()-t;return{at:s,msLeft:a,expired:a<=0}}function Kc(e){if(!Number.isFinite(e))return"";if(e<=0)return"expired";let t=Math.floor(e/6e4),n=Math.floor(t/60),s=Math.floor(n/24);return s?`${s}d ${n%24}h left`:n?`${n}h ${t%60}m left`:`${Math.max(1,t)}m left`}var mi=e=>e.toISOString().slice(0,16).replace("T"," ")+"Z";function ba(e){let t=e?.source??"<voice-dir>",n=e?.bucket??"gs://<bucket>/<prefix>",s=e?.signDuration??"7d";return`node tools/publish-voices.mjs ${t} --bucket ${n} --sign ${s}`}function ya(e){return e?.manifest??e?.dir??null}function Uf({hasTracks:e,used:t,printMode:n,embedded:s,capture:a,openedMidTalk:c,voiceover:h,captionsOn:f,narrating:g}={}){return!!e&&!t&&!n&&!s&&!a&&!c&&!h&&!f&&!g}var Gf=.25,Kf=.5,Wf=1;function va(e,t,n){if(e!=null&&String(e).trim()!==""){let s=Number(e);if(Number.isFinite(s)&&s>=0)return s}return typeof t=="number"&&Number.isFinite(t)&&t>=0?t:n}var Vf=(e,t)=>va(e,t,Gf);function bi(e){let t=(e??[]).map(s=>So(s)?ci(s):"");if(t.filter(Boolean).length<2)return null;let n=0;return t.map(s=>s?++n:null)}var ka=e=>String(e??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/-/g,"_").toLowerCase();function yi(e){return ka(e).split(/\s+/).filter(Boolean).map(t=>t.startsWith("lang:")?{lang:t.slice(5)}:{any:t}).filter(t=>t.lang!=="")}function Jf(e,t,n,s=[]){let a=Array.isArray(n)?n:yi(n);if(!a.length)return!0;let c=ka(e),h=ka(t);return a.every(f=>f.lang!==void 0?h.startsWith(f.lang)||(s??[]).some(g=>g.startsWith(f.lang)):c.includes(f.any)||h.includes(f.any))}function Hs(e){try{return new Intl.DisplayNames(["en"],{type:"language"}).of(e)??e}catch{return e}}var Yf=["en","es","fr","de","pt","it","nl","pl","ja","zh","ko","hi","ar","ru","tr","sv","da","no","fi","cs","el","ro","hu","uk","id","ms","vi","fil","ta","bg","hr","sk"];function Wc(e,t=0){let n=(e??[]).map(a=>String(a??"").replace(/\s+/g," ").trim()),s=bi(n);if(!s){let a=n.filter(Boolean).join(" ");return So(a)?[{seg:0,step:0,file:null,text:a}]:[]}return n.map((a,c)=>So(a)?{seg:c,step:Math.min(c,t),file:s[c],text:a}:null).filter(Boolean)}function Zf(e){let t=new Uint8Array(e.length*2),n=new DataView(t.buffer);for(let s=0;s<e.length;s++){let a=Math.max(-1,Math.min(1,e[s]));n.setInt16(s*2,Math.round(a*(a<0?32768:32767)),!0)}return t}function wa({engine:e,voice:t,mine:n=!1}={},s=[]){let a=y=>String(y??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40),c=n?"voices/me":`voices/${a(t)||a(e)||"take"}`,h=new Set(s),f=c;for(let y=2;h.has(f);y++)f=`${c}-${y}`;let g=f===c?"":`, take ${f.slice(c.length+1)}`,b=n?`My voice${g}`:`${t||"Narration"}${e?` \xB7 ${e}`:""}${g}`;return{dir:f,label:b}}function xa(e){let t=e?.files;if(!t)return[];if(Array.isArray(t))return t;let n={label:"Narration",dir:t};return e.ext!==void 0&&(n.ext=e.ext),e.segments!==void 0&&(n.segments=e.segments),[n]}function Xf(e){let t=[],n=[],s=[],a=new Set,c=[],h=0;return e.forEach((f,g)=>{let{lead:b,runs:y}=Cc(f??""),$=t.length,S=b;for(let A of y){let E=vc(A.text);if(!E.length){S+=A.pause;continue}for(let L of E)t.push(L),n.push(0),s.push(0);n[t.length-E.length]+=S,S=0,s[t.length-1]+=A.pause}t.length>$&&(a.add($),c.push({seg:g,from:$,count:t.length-$})),S&&t.length?s[t.length-1]+=S:h+=S}),{sentences:t,segStarts:a,segRuns:c,before:n,after:s,bare:h}}function Qf(e,t,n,s,a,c){return`${e}|s${t}|n${n}|${a}|${c}|t${tm(s)}`}function em({reused:e=0,sent:t=0,cost:n=0}={},s=null){let a=e+t;if(!a)return"";let c=n>0?`~$${n.toFixed(n<.01?4:3)}`:"$0";return`${a} clip${a===1?"":"s"} \xB7 ${e} reused \xB7 ${t} sent to ${s??"the engine"} \xB7 ${c}`}function tm(e){let t=String(e??"").replace(/\s+/g," ").trim(),n=2166136261;for(let s=0;s<t.length;s++)n^=t.charCodeAt(s),n=Math.imul(n,16777619)>>>0;return n.toString(16).padStart(8,"0")}var Vc=new WeakMap;function nm(e){let t=e?.innerHTML??"",n=e&&Vc.get(e);if(n&&n.html===t)return n.segs;let s=Ea(e).split(vs).map(a=>a.replace(/\s+/g," ").trim());return e&&Vc.set(e,{html:t,segs:s}),s}function Ea(e,{blocks:t=!1}={}){let n="",s=a=>{for(let c of a.childNodes){if(c.nodeType===3||c.nodeType===4){n+=c.data;continue}if(c.nodeType!==1)continue;let h=c.localName;h==="pause"?n+=Xr:h==="click"?n+=vs:h==="slow"?n+="[slow]":t&&h==="br"&&(n+=`
|
|
389
|
+
`);let f=t&&rm.has(h);f&&(n+=`
|
|
390
|
+
|
|
391
|
+
`),s(c),f&&(n+=`
|
|
392
|
+
|
|
393
|
+
`)}};return e&&s(e),aa(n)}var rm=new Set(["p","div","li","ul","ol","blockquote","pre","h1","h2","h3","h4","h5","h6","table","tr"]);function sm(e){return Ea(e,{blocks:!0}).split(vs).map(t=>t.split(/\n[ \t]*\n/).map(n=>n.replace(/\s+/g," ").trim()).filter(Boolean).join(`
|
|
394
|
+
|
|
395
|
+
`)).join(`
|
|
396
|
+
|
|
397
|
+
\u27E8CLICK\u27E9
|
|
398
|
+
|
|
399
|
+
`).trim()}function Jc(e){let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m${String(t%60).padStart(2,"0")}s`}function gi(e,t){let n=e.reduce((c,h)=>c+h.length,0),s=new DataView(new ArrayBuffer(44)),a=(c,h)=>{for(let f=0;f<h.length;f++)s.setUint8(c+f,h.charCodeAt(f))};return a(0,"RIFF"),s.setUint32(4,36+n,!0),a(8,"WAVE"),a(12,"fmt "),s.setUint32(16,16,!0),s.setUint16(20,1,!0),s.setUint16(22,1,!0),s.setUint32(24,t,!0),s.setUint32(28,t*2,!0),s.setUint16(32,2,!0),s.setUint16(34,16,!0),a(36,"data"),s.setUint32(40,n,!0),new Blob([s.buffer,...e],{type:"audio/wav"})}var om=(e,t)=>new Uint8Array(2*Math.round(e*t));function im(e){let t=e?.name??"";return t==="NotAllowedError"||t==="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":t==="NotFoundError"||t==="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":t==="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 (${Et(String(e?.message||t||e))}).`}function Yc({root:e,stage:t,config:n,params:s,printMode:a,toast:c,logOnly:h,debugLog:f,overlays:g,instance:b,openedMidTalk:y=!1,rangePicker:$=null,chapters:S=()=>[],syncSoundBtn:A,updateDebugState:E,downloadFromUrl:L,editBase:P=()=>null,editReady:j=()=>Promise.resolve(),enhanceScript:U=()=>null,moduleOf:oe=()=>null}){let pe=0,D=null,z="decklight-narration:"+location.pathname,Ce=n.narration?.liveUrl??(/^https?:$/.test(location.protocol)?`${location.origin}/deck/tts`:"http://127.0.0.1:8787/tts"),ee=[["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"]],re=Ce.replace(/\/$/,""),le=`${re}/ping`,ie=`${re}/voices/install`,I=`${re}/engines`,ce=(x,q)=>q?`${x}${x.includes("?")?"&":"?"}engine=${encodeURIComponent(q)}`:x,de=ee,Ie=!0,V=!1,Z=null,T=null,F=null,se=new Set,_e=null,Te=!1,l=null;function d(){return _e??=G().then(async x=>x?(Te=!0,be(x),f("tts",`bridge: ${x.engine} \xB7 ${x.model} \xB7 ${de.length} voice(s)`+(Ie?"":" \xB7 no style")),x):null).catch(()=>null),_e}async function G(){let x=ue?.live?K.engine:null;try{let q=await fetch(ce(le,x));if(q.ok)return await q.json();if(!x||q.status!==409)return null;let X=await q.json().catch(()=>({})),me=await fetch(le).then(De=>De.ok?De.json():null).catch(()=>null);return me&&c(`${x}: ${X.why??X.error??"unavailable"} \u2014 speaking with ${me.engine}`,4e3),me}catch{return null}}function be(x){if(!x)return null;if(Z=x.engine??null,T=x.model??null,F=typeof x.caveat=="string"?x.caveat:null,Array.isArray(x.voices)&&x.voices.length&&(de=x.voices),Ie=x.stylable!==!1,V=x.audioTags===!0,de.length&&!de.some(([q])=>q===K.voice)){let q=K.voice;K={...K,voice:de[0][0]},qn(),f("tts",`voice ${q} is not on this bridge \u2014 using ${K.voice}`),ue?.live&&c(`voice ${q} \u2192 ${K.voice} (this bridge speaks its own roster)`,2600)}return x}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"]],Qe=([,x,q])=>Z==="elevenlabs"?q:x,ot=xa(n.narration),fe={live:!0},K={voice:"Alnilam",tone:J[0][0],style:J[0][1]},ue=null;try{let x=er(z);if(x?.live?.voice)K=x.live,ue=fe;else if(!x?.off){let q=x?.track??x?.dir,X=ot.find(me=>ya(me)===q);X&&(ue=X)}}catch{}let at=!1,N=null,ft="decklight-narr-rate:"+location.pathname,M=1;try{let x=parseFloat(Nn(ft)??"");x>=.25&&x<=2&&(M=x)}catch{}function H(x){M=Math.round(Math.min(2,Math.max(.25,M+x))*100)/100,yn(ft,String(M)),N&&(N.playbackRate=M),c(`voice speed ${M}\xD7`),f("narr",`rate ${M}\xD7`),E()}let te=Dc({root:e,config:n,debugLog:f,toast:c}),we=Fc({root:e,bridge:te.bridge,debugLog:f,seconds:Number(n.narration?.character?.filmSeconds)||8,onUse:({name:x,steady:q})=>{$r=!1,te.probe().then(()=>{let X=te.bridgeInfo?.engines?.video?.includes("wav2lip")?"wav2lip":te.bridgeInfo?.engines?.video?.[0];X&&te.setMode("video",{engine:X,portrait:x}),c(`\u{1F3A5} your talking head is \u201C${x}\u201D${q?"":" \u2014 your head moved, so the whole face is redrawn (softer): retake it holding still for a sharper one"}${at?"":" \xB7 V starts narration"}`,q?4e3:9e3)})}});g.register({isOpen:we.isOpen,close:we.close,keydown:we.keydown});let Ee=new Map;function Ke(x){let q=Ea(b._sections?.[x-1]?.querySelector("aside.notes"));return ci(q.replaceAll(vs," "))}function ae(x){return nm(b._sections?.[x-1]?.querySelector("aside.notes"))}let Ze=x=>sm(b._sections?.[x-1]?.querySelector("aside.notes"));function bt(x,q,X){if(V||(x=qs(x)),!x||!x.trim())return q&&!Ee.has(q)&&Ee.set(q,Promise.resolve(null)),Promise.resolve(null);let me=D,De=me&&!me.seen.has(q);if(De&&me.seen.add(q),Ee.has(q))De&&me.reused++;else{let Ge=(async()=>{let ne=Date.now();try{let $e=await fetch(Ce,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:x,voice:K.voice,style:K.style,...Z?{engine:Z}:{}})});if(!$e.ok)throw new Error(String($e.status));let He=await $e.blob(),it=parseFloat($e.headers?.get?.("x-tts-cost")??"")||0;return it&&(pe+=it),De&&($e.headers?.get?.("x-tts-cached")==="1"?me.reused++:(me.sent++,me.cost+=it)),f("tts",`${X} \xB7 ${K.voice} \xB7 ${x.length} chars \u2192 ${((Date.now()-ne)/1e3).toFixed(1)}s`+(it?` \xB7 ~$${it.toFixed(4)}`:"")),{url:URL.createObjectURL(He),blob:He}}catch($e){throw f("tts",`${X} \xB7 ${K.voice} FAILED after ${((Date.now()-ne)/1e3).toFixed(1)}s (${String($e.message||$e)})`),$e}})();Ge.catch(()=>{Ee.get(q)===Ge&&Ee.delete(q),De&&me.seen.delete(q)}),Ee.set(q,Ge)}return Ee.get(q)}let Pe=x=>b._records?.[x-1]?.groups.length??0;function ke(x,q){let X=ae(x),me=q<Pe(x)?[X[q]]:X.slice(q);return Xf(V?me.map($c):me)}let Fe=(x,q)=>ke(x,q).sentences,Ve=new Set;function et(x){if(Ve.has(x))return;let q=ae(x).length,X=Pe(x)+1;if(q<=X)return;Ve.add(x);let me=`slide ${x}: ${q} [click] segments but ${X} build step${X===1?"":"s"} \u2014 the last ${q-X} ${q-X===1?"is":"are"} spoken on the final step`;h?.(me),f("narr",me)}let Y=(x,q,X,me)=>Qf(x,q,X,me,K.voice,K.style);function ve(x,q,X,me){let De=me??Fe(x,q)[X]??"";return bt(De,Y(x,q,X,De),`slide ${x} seg ${q} #${X+1}`)}let Ne=x=>b._sections[x-1]?.dataset.narration==="hold",ut=x=>va(b._sections[x-1]?.dataset.narrationPause,n.narration?.slidePause,Wf),ht=x=>va(b._sections[x-1]?.dataset.narrationBeatPause,n.narration?.beatPause,Kf),vt=x=>Vf(b._sections[x-1]?.dataset.narrationSentencePause,n.narration?.sentencePause),mt=x=>2*ht(x);async function Ue(x,q){if(!(x>0))return!Mt&&!q();for(let X=x*1e3;X>0;){if(q())return!1;let me=Date.now();await new Promise(De=>setTimeout(De,Math.min(150,X))),Mt||(X-=Date.now()-me)}return!Mt&&!q()}let Dt=10,Ct=3,Pt=0;function Kt(x){let q=[],X=b.state.slide,me=b.state.step;for(;q.length<x&&X<=b.state.totalSlides;){let De=Pe(X);for(;me<=De&&q.length<x;me++){let Ge=Fe(X,me);for(let ne=0;ne<Ge.length&&q.length<x;ne++)q.push([X,me,ne,Ge[ne]])}X+=1,me=0}return q}async function hn(){let x=++Pt,q=async()=>{for(;x===Pt&&at&&ue?.live;){let X=Kt(Dt).find(([it,qe,nt,r])=>!Ee.has(Y(it,qe,nt,r)));if(!X)return;let[me,De,Ge,ne]=X,$e=Y(me,De,Ge,ne),He={[Ge]:ne};try{await ve(me,De,Ge,ne),te.mode!=="off"&&te.prefetchSentence($e,Ee.get($e),qs(He[Ge]??""))}catch{return}await new Promise(it=>setTimeout(it,30))}};await Promise.all(Array.from({length:Ct},q))}let Xt=0,Mt=!1,Wt=!1,St=0;function Vt(){if(!at){c("narration is off \u2014 \u23B5 starts it");return}Mt=!Mt,Mt?N?.pause():N?.src&&N.paused&&!N.ended&&N.currentTime>0?N.play().catch(()=>{}):Wt||wn(),c(Mt?"\u23F8 narration paused \u2014 \u23B5 resumes":"\u25B6 narration resumed"),f("narr",Mt?"paused":"resumed"),E()}let on=()=>ue?.live?"live":ue?"file":null;async function Yt(x,q,{mode:X="live",endOfSlide:me=!1}={}){let De=Xt,Ge=()=>De!==Xt||!at||on()!==X||b.state.slide!==x||b.state.step!==q;if(Mt||Ge())return;let ne=async(He,it)=>(He>0&&f("narr",`slide ${x} \u2014 holding ${He}s before ${it}`),Ue(He,Ge)),$e=b._records[x-1];if(!me&&q<($e?$e.groups.length:0)){if(!await ne(ht(x),"the next build"))return;b.next();return}if(!Ne(x)){if(x>=b.state.totalSlides)return tt(an);await ne(ut(x),"the next slide")&&b.goto(x+1,0)}}let an="\u{1F51A} end of the talk \u2014 narration off \xB7 Home goes back to the start";function Cn(x,q){for(let X=x;X<=b.state.totalSlides;X++)if(Ke(X)){for(let me=X===x?q:0;me<=Pe(X);me++)if(ke(X,me).sentences.length)return!0}return!1}async function wn(){let x=b.state.slide,q=b.state.step,X=++Xt;if(hn(),!Ke(x)){if(Ne(x)){f("narr",`hold on slide ${x} \u2014 manual advance`);return}setTimeout(()=>{X!==Xt||!at||!ue?.live||b.state.slide===x&&(x<b.state.totalSlides?b.goto(x+1,0):tt(an))},400);return}et(x);let{sentences:me,before:De,after:Ge,bare:ne}=ke(x,q),$e=()=>X!==Xt||!at||b.state.slide!==x||b.state.step!==q;if(!me.length){if(!ne){setTimeout(()=>{X===Xt&&Yt(x,q)},600);return}St=X,Wt=!0;try{await Ue(ne*mt(x),$e)&&await Yt(x,q)}finally{St===X&&(Wt=!1)}return}St=X,Wt=!0;let He=0;try{for(let it=0;it<me.length;it++){for(;Mt;){if($e())return;await new Promise(i=>setTimeout(i,150))}if($e()||De[it]&&!await Ue(De[it]*mt(x),$e))return;let qe;try{qe=await ve(x,q,it,me[it])}catch(i){f("narr",`sentence failed (slide ${x} seg ${q} #${it+1}) \u2014 narration stopped`),tt(Nt(i));return}if($e())return;if(!qe)continue;let nt=qs(me[it]);ye(nt),N??=new Audio,te.mode!=="off"&&(te.attachAudio(N),te.beginSentence(Y(x,q,it,me[it]),qe,nt)),N.onended=null,N.onerror=null,N.src=qe.url,N.playbackRate=M;let r=!1;if(await new Promise(i=>{N.onended=i,N.play().catch(()=>{r=!0,i()})}),r){tt("\u{1F507} the browser blocked audio \u2014 click the deck once, then V \u2014 the slides wait for the voice");return}He++;let o=(it<me.length-1?vt(x):0)+Ge[it]*mt(x);if((it<me.length-1||o>0)&&!await Ue(o,$e))return}if($e())return;if(!He&&me.length){tt("\u{1F507} the voice did not play \u2014 auto-advance stopped \xB7 press the key left of 1 for messages");return}await Yt(x,q)}finally{St===X&&(Wt=!1)}}function Nt(x){let q=String(x?.message??x);return q.startsWith("429")?"\u{1F507} voice quota exceeded (429) \u2014 auto-advance stopped \xB7 a free engine: decklight <deck> --tts-engine chirp":/^\d{3}/.test(q)?`\u{1F507} voice bridge error ${q.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 open the deck with: decklight <deck.html>"}let Ln=new Map,ar=new Map,Er=new Set,kn=null,Bn=new Map;function wr(x){if(!x)return x;if(Bn.has(x))return Bn.get(x);let q=x;for(let X of document.querySelectorAll('script[type="application/json"][data-decklight-audio]'))if(X.getAttribute("data-decklight-audio")===x){try{let me=/^data:([^;,]+);base64,(.*)$/s.exec(JSON.parse(X.textContent));if(me){let De=atob(me[2]),Ge=new Uint8Array(De.length);for(let ne=0;ne<De.length;ne++)Ge[ne]=De.charCodeAt(ne);q=URL.createObjectURL(new Blob([Ge],{type:me[1]}))}}catch{}break}return Bn.set(x,q),q}function Nr(x){for(let q of document.querySelectorAll('script[type="application/json"][data-decklight-voices]'))if(q.getAttribute("data-decklight-voices")===x)try{return JSON.parse(q.textContent)}catch{return null}return null}function tn(x){if(!Ln.has(x)){let q=Nr(x);Ln.set(x,q?Promise.resolve(q):fetch(x).then(X=>{if(!X.ok)throw new Error(`HTTP ${X.status}`);return X.json()}).catch(X=>{throw Ln.delete(x),X})),Ln.get(x).then(X=>ar.set(x,X)).catch(()=>{})}return Ln.get(x)}function Mn(x){let q=ar.get(x.manifest);if(!q)return Er.has(x.manifest)?"hosted \u2014 the voice list did not load":(tn(x.manifest).catch(()=>Er.add(x.manifest)).then(()=>{ln&&cn==="tracks"&&Ft("tracks")}),"hosted \u2014 checking\u2026");let X=To(q);return X.at?X.expired?`EXPIRED ${mi(X.at)} \u2014 re-sign to play`:`signed \xB7 ${Kc(X.msLeft)}`:"hosted \xB7 no expiry"}async function un(){if(!ue||ue.live||!ue.manifest)return kn=null,nn=dn(),!0;if(kn?.track!==ue)try{kn={track:ue,data:await tn(ue.manifest)}}catch(q){return kn=null,tt(`\u{1F507} could not load the voice list for \u201C${ue.label}\u201D (${ue.manifest} \u2014 ${q.message}) \u2014 auto-advance stopped`),!1}let x=To(kn.data);return x.expired?(tt(`\u{1F507} the signed voices for \u201C${ue.label}\u201D expired ${mi(x.at)} \u2014 auto-advance stopped \xB7 re-sign: ${ba(kn.data)}`),!1):(nn=dn(),!0)}function dn(){if(Rn.clear(),!ue||ue.live||ue.segments===!1)return!1;if(ue.manifest){let x=kn?.data,q=x?.slides??[],X=!!To(x).at;return q.some(me=>Array.isArray(me?.segments)&&me.segments.length&&(!X||me.segments.every(De=>De?.url)))}return ue.segments===!0}let Rn=new Set,nn=!1;function Tt(x,q){if(!nn||Rn.has(x))return null;let X=ae(x),me=bi(X);if(!me)return null;let De=q>=Pe(x),Ge=Math.min(q,me.length),ne=(De?me.slice(Ge):me.slice(Ge,Ge+1)).filter($e=>$e!==null).map($e=>({file:$e,url:wr(ue.manifest?Gc(kn?.data,ue.manifest,x,$e):`${ue.dir}/slide-${String(x).padStart(2,"0")}-${String($e).padStart(2,"0")}.${ue.ext??"m4a"}`)}));return ne.every($e=>$e.url)?ne:null}function fn(x,q){let X=[];for(let me of[x,x+1])if(!(me>b.state.totalSlides||!Ke(me)))for(let De=me===x?q:0;De<=Pe(me);De++){let Ge=Tt(me,De);if(Ge===null){let ne=xn(me);ne&&X.push(ne);break}X.push(...Ge.map(ne=>ne.url))}return[...new Set(X)]}function xn(x){return ue.manifest?wr(Uc(kn?.data,ue.manifest,x)):wr(`${ue.dir}/slide-${String(x).padStart(2,"0")}.${ue.ext??"m4a"}`)}function xe(){if(ue)return ue.live?wn():nn?je():B()}function B({selfDriving:x=!1,gen:q=Xt}={}){let X=b.state.slide,me=b.state.step;if(!Ke(X)){N?.pause();return}let De=xn(X);if(!De){N?.pause();return}if(N??=new Audio,N.onended=null,N.onerror=null,N.src=De,N.playbackRate=M,te.mode!=="off"){te.attachAudio(N),te.beginSlide(ue,X,null,De);let ne=X<b.state.totalSlides&&Ke(X+1)?xn(X+1):null;te.prefetchFiles(ue,X,[De,ne].filter(Boolean))}x&&(N.onended=()=>{q===Xt&&Yt(X,me,{mode:"file",endOfSlide:!0})});let Ge=!1;N.onerror=()=>{Ge=!0,Le(X,De)},N.play().catch(ne=>{ne?.name==="NotAllowedError"?c("\u{1F507} the browser blocked audio \u2014 click the deck once, then V"):Ge||Le(X,De)})}function Le(x,q,{fatal:X=!1}={}){f("narr",`no audio: ${q}`);let me=ue?.manifest?To(kn?.data):null;if(me?.at){f("narr","signed url failed \u2014 a media element cannot report the status"),tt(`\u{1F507} slide ${x} of \u201C${ue.label}\u201D would not load (signed until ${mi(me.at)}) \u2014 auto-advance stopped \xB7 re-sign: ${ba(kn?.data)}`);return}if(X){tt(`\u{1F507} no audio for slide ${x} (${q}) \u2014 auto-advance stopped \xB7 press the key left of 1 for messages`);return}c(`\u{1F507} no narration for slide ${x} (${q}) \xB7 press the key left of 1 for messages`)}async function je(){let x=b.state.slide,q=b.state.step,X=++Xt;if(!Ke(x)){if(Ne(x)){f("narr",`hold on slide ${x} \u2014 manual advance`);return}setTimeout(()=>{X!==Xt||!at||on()!=="file"||b.state.slide===x&&(x<b.state.totalSlides?b.goto(x+1,0):tt(an))},400);return}et(x);let me=Tt(x,q);if(!me){B({selfDriving:!0,gen:X});return}if(!me.length){setTimeout(()=>{X===Xt&&Yt(x,q,{mode:"file"})},600);return}let De=()=>X!==Xt||!at||on()!=="file"||b.state.slide!==x||b.state.step!==q;St=X,Wt=!0;try{for(let Ge=0;Ge<me.length;Ge++){for(;Mt;){if(De())return;await new Promise($e=>setTimeout($e,150))}if(De())return;N??=new Audio,te.mode!=="off"&&(te.attachAudio(N),te.beginSlide(ue,x,me[Ge].file,me[Ge].url),Ge===0&&te.prefetchFiles(ue,x,fn(x,q))),N.onended=null,N.onerror=null,N.src=me[Ge].url,N.playbackRate=M;let ne=await new Promise($e=>{N.onended=()=>$e("ended"),N.onerror=()=>$e("error"),N.play().catch(He=>$e(He?.name==="NotAllowedError"?"blocked":"error"))});if(De())return;if(ne==="blocked"){tt("\u{1F507} the browser blocked audio \u2014 click the deck once, then V \u2014 the slides wait for the voice");return}if(ne==="error"){if(q===0&&Ge===0){f("narr",`no segments for slide ${x} \u2014 falling back to the whole-slide file`),Rn.add(x),B({selfDriving:!0,gen:X});return}Le(x,me[Ge].url,{fatal:!0});return}}if(De())return;await Yt(x,q,{mode:"file"})}finally{St===X&&(Wt=!1)}}function tt(x="narration off"){at=!1,Xt++,Pt++,Mt=!1,N?.pause(),te.stop(),lr(),c(x),f("narr",x),A()}function yt(){return at?Vt():It()}let wt=()=>at||Mt||!!ue;async function It(){if(!ue){c(ot.length||Te?"no voice chosen \u2014 V picks one":"no narration here \u2014 V shows what is available");return}if(at)return tt();if(Gn(),ue.live&&!Cn(b.state.slide,b.state.step)){c(b.state.slide>=b.state.totalSlides?"nothing left to say \u2014 this is the end of the talk \xB7 \u2190 goes back, Home starts over":"nothing left to say from here \u2014 the rest of the deck has no notes",5e3);return}if(ue.live&&await d(),!await un())return;at=!0;let x=ue.live?`\u26A1 ${K.voice} \xB7 ${K.tone}`:ue.label;c(`\u{1F50A} ${x} \u2014 \u23B5 pauses \xB7 V picks`),f("narr",`on \u2014 ${x}`),xe(),A()}b.on("slide",()=>{at&&xe()}),b.on("build",()=>{at&&(ue?.live?wn():nn&&je())});let At="decklight-captions:"+location.pathname,In=!!s?.has("embedded"),Rt=!1;Rt=In?!!s.has("captions"):Nn(At)==="1";let mn=null;function ye(x){mn&&(mn.textContent=x,mn.classList.toggle("show",!!x))}function lr(){if(mn){if(at&&ue?.live){ye("");return}ye(qs(Fe(b.state.slide,b.state.step).join(" ")))}}function Dr(){mn=document.createElement("div"),mn.className="decklight-captions",mn.setAttribute("aria-live","polite"),e.appendChild(mn),lr()}function Ur(){In||(Rt=!Rt,yn(At,Rt?"1":"0"),Rt?(Dr(),Un()):(mn?.remove(),mn=null),c(`captions ${Rt?"on":"off"}`),f("narr",`captions ${Rt?"on":"off"}`))}b.on("slide",lr),b.on("build",lr),Rt&&!a&&Dr(),In&&typeof window<"u"&&window.addEventListener("message",x=>{let q=x.data&&x.data.__decklightPreview;!q||x.source!==window.parent||typeof q.captions!="boolean"||q.captions===Rt||(Rt=q.captions,Rt?Dr():(mn?.remove(),mn=null))});let Gr="\u{1F50A} this deck has a voice-over \u2014 V plays it",Zn=900,Qr=12e3,Kr="decklight-narr-used:"+location.pathname,nr=!1;nr=Nn(Kr)==="1";let sn=null;function Un(){if(!sn)return;let x=sn;sn=null,x.classList.remove("show"),setTimeout(()=>x.remove(),260)}function Gn(){Un(),!nr&&(nr=!0,yn(Kr,"1"))}function _r(){let x=document.createElement("button");x.type="button",x.className="decklight-narr-hint",x.setAttribute("aria-label","Play this deck\u2019s voice-over");let q=document.createElement("kbd");q.textContent="V",x.append("\u{1F50A} this deck has a voice-over \u2014 ",q," plays it"),x.addEventListener("click",()=>{Un(),It()}),sn=x,e.appendChild(x),x.offsetWidth,x.classList.add("show"),h?.(Gr),f("narr","voice-over hint shown"),setTimeout(Un,Qr)}Uf({hasTracks:ot.length>0,used:nr,printMode:a,embedded:!!s?.has("embedded"),capture:!!s?.has("capture"),openedMidTalk:y,voiceover:!!s?.has("voiceover"),captionsOn:Rt})&&setTimeout(()=>{at||_r()},Zn);let ln=null,cr=0,cn="tracks",Ot=[],Jt=null,Fn=[],jt=()=>{Fn.forEach(x=>x()),Fn=[]},En=new Set(["elevenlabs","gemini","chirp"]);function qn(){try{xr(z,ue?.live?{live:{...K,engine:Z??K.engine}}:ue?{track:ya(ue),dir:ue.dir}:{off:!0})}catch{}}function dr(x,q){K={voice:Jt??K.voice,tone:x,style:q},ue=fe,qn(),Xn(),at||(at=!0),c(`\u26A1 live voice: ${K.voice} \xB7 ${K.tone} \u2014 V stops`),f("narr",`live config \u2014 ${K.voice} \xB7 ${K.tone}`),xe()}function rn(x,{scroll:q=!1}={}){Ot.length&&(cr=vn(ln.querySelectorAll(".narr-row"),x,"narr-sel",{scroll:q}))}function jn(){Ot[cr]?.commit()}function Kn(){cn==="custom"?Ft("tones"):cn==="tones"||cn==="engines"||cn==="langs"||cn==="library"?Ft("voices"):cn==="charvideo"?Ft("character"):cn==="record"||cn==="enhance"||cn==="spoken"||cn==="voices"||cn==="character"?Ft("tracks"):Xn()}let $r=!1;function vr(x,q="yourself"){let X=x.film?ga():x.filmWhy;return{text:`\u{1F4F9} Film ${q} \u2014 a few seconds that become your talking head`,flavor:X??"face the camera, mouth relaxed \u2014 no photo needed",blocked:X??null,commit:()=>{if(X)return c(`film yourself: ${X}`,7e3);Xn(),we.open()}}}function es(x,q){te.setMode(x,q),Xn(),c(x==="off"?"character off":x==="viseme"?`\u{1F3AD} character on \u2014 lips follow the narration${at?"":" \xB7 V starts it"}`:`\u{1F3A5} character video \u2014 ${te.engine} \xB7 ${te.portrait}${at?"":" \xB7 V starts narration"}`)}function ur(x){if(te.mode==="off"){c("turn the character on first \u2014 N \xB7 Character\u2026");return}te.setSolo(x),Xn(),c(x?"\u{1F3AD} solo \u2014 the narrator has the stage \xB7 N brings the slides back":"solo off \u2014 the slides are back")}let rr="Hey, this is Decklight",Br=rr,pn="",Fr=!1,Or=!1,Sr=null,gn="",bn=null,pr=null,Lr=`${re}/voices/library`,Pn=()=>(document.documentElement.lang||"").toLowerCase().split("-")[0]||null,ts=()=>de.some(x=>Array.isArray(x[3])),or=null,qr=new Map,Wr=new Map,Mr=null,hr=new Set;function ps(x){if(x===rr)return qr;if(x!==Mr){for(let q of Wr.values())q.then(X=>URL.revokeObjectURL(X)).catch(()=>{});Wr=new Map,Mr=x}return Wr}let ns=(x,q)=>`${x}|${q||""}`;function rs(x,q,X,me=""){let De=ns(q,me);if(!x.has(De)){let Ge=(async()=>{let ne=Date.now(),$e=await fetch(Ce,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:X,voice:q,style:me,...Z?{engine:Z}:{}})});if(!$e.ok)throw new Error(String($e.status));let He=await $e.blob(),it=parseFloat($e.headers?.get?.("x-tts-cost")??"")||0;return it&&(pe+=it),f("tts",`preview ${q}${me?" (styled)":""} \xB7 ${((Date.now()-ne)/1e3).toFixed(1)}s`+(it?` \xB7 ~$${it.toFixed(4)}`:"")),URL.createObjectURL(He)})();Ge.catch(()=>{x.get(De)===Ge&&x.delete(De)}),x.set(De,Ge)}return x.get(De)}async function Ht(x,q,X){let me=`${X}|${x}`;if(hr.has(me))return;hr.add(me);let De=x===rr,Ge=De?qr:Wr;try{f("narr",`preview prefetch ${X} (${De?"default":"custom"} sentence)`);for(let{voice:ne,style:$e}of q){if(!De&&Mr!==x)return;Ge.has(ns(ne,$e))||await rs(Ge,ne,x,$e).catch(()=>{})}f("narr",`preview prefetch ${X} complete`)}finally{hr.delete(me)}}function Ar({voice:x,style:q="",prefetch:X},me){let De=Br.trim();if(!De)return;let Ge=ps(De);me&&(me.textContent="\u2026"),rs(Ge,x,De,q).then(ne=>{if(me?.isConnected&&(me.textContent="\u25B6"),or??=new Audio,or.src=ne,or.play().catch(()=>{}),f("narr",`preview ${x}${q?" \xB7 styled":""}`),X==="voices"){let $e=Ot.filter(He=>He.preview).map(He=>({voice:He.preview.voice,style:""}));Ht(De,$e,"voices")}else X==="tones"&&Ht(De,J.map($e=>({voice:x,style:Qe($e)})),`tones:${x}`)}).catch(()=>{me?.isConnected&&(me.textContent="\u25B6"),c("live voice bridge unreachable \u2014 open the deck with: decklight <deck.html>"),f("narr",`preview ${x} failed`)})}function Cr(x){Sr!==x&&(bn=null,gn=""),Sr=x||null,pr=null,Ft("library")}async function Hn(x){pr=null,c(`adding \u201C${x.name}\u201D to your ElevenLabs voices\u2026`,2400);try{let q=await fetch(Lr+"/add",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({engine:Z,owner:x.owner,id:x.id,name:x.name})}),X=await q.json().catch(()=>({}));if(!q.ok||!X.ok)throw new Error(X.error??`the bridge answered ${q.status}`);Array.isArray(X.voices)&&X.voices.length&&(de=X.voices),f("tts",`library: added ${x.name} (${x.id})`),c(`\u201C${x.name}\u201D is one of your ElevenLabs voices now`,3200),Jt=x.name,Ie?Ft("tones"):dr(Z??"plain","")}catch(q){c(`\u201C${x.name}\u201D was not added \u2014 ${String(q.message??q)}`,7e3),ln&&cn==="library"&&Ft("library")}}function Ft(x){let q=cn;cn=x,x==="voices"&&q!=="voices"&&(Fr=!0);let X=ln.querySelector(".narr-card");jt(),X.innerHTML="";let me=document.createElement("div");if(me.className="narr-head",X.appendChild(me),Ot=[],x==="tracks")me.textContent="narration",Ot.push({text:"\u{1F507} Off \u2014 no voice",flavor:ot.length||Te?"\u23B5 advances the deck":"",cur:!ue,commit:()=>{let ne=at||Mt;ue=null,qn(),Xn(),ne?tt("\u{1F507} narration off"):c("\u{1F507} narration off")}}),ot.forEach(ne=>Ot.push({text:ne.manifest?`\u2601 ${ne.label}`:`\u{1F50A} ${ne.label} (${ne.dir}/)`,flavor:ne.manifest?Mn(ne):"",cur:ne===ue,commit:()=>{ue=ne,qn(),Xn(),c(`\u{1F50A} track: ${ne.label}`),at&&un().then($e=>{$e&&xe()})}})),Ot.push({text:"\u26A1 Live voice \u2014 synthesize on the fly\u2026",flavor:Z?`${Z} \xB7 ${K.voice}`:"",cur:ue?.live,commit:()=>Ft("voices")}),Ot.push({text:"\u{1F9D1} Character \u2014 animated narrator\u2026",cur:te.mode!=="off",commit:()=>Ft("character")}),Ot.push({text:"\u2728 Enhance the script \u2014 ElevenLabs audio tags\u2026",flavor:U()?"your agent adds them, nothing reworded":"",blocked:U()?null:"needs write mode \u2014 it writes the notes",commit:()=>U()?Ft("enhance"):c("enhancing the script needs write mode \u2014 it writes the notes",4e3)}),Ot.push({text:"\u{1F5E3} Write the script for the ear\u2026",flavor:U()?"terse notes become sentences a person would say":"",blocked:U()?null:"needs write mode \u2014 it writes the notes",commit:()=>U()?Ft("spoken"):c("rewriting the script needs write mode \u2014 it writes the notes",4e3)}),Ot.push({text:"\u{1F399} Record this deck\u2026",flavor:ot.some(ne=>!ne.live)?"re-record, or add another take":"write the audio to a folder",commit:()=>Ft("record")}),Ot.push({text:`${Rt?"\u2611":"\u2610"} Captions \u2014 follow the voice on screen`,flavor:"C",toggle:!0,commit:()=>{Ur(),Ft("tracks")}}),Ot.push({text:`\u23E9 Speed \u2014 ${M}\xD7`,flavor:"< slower \xB7 > faster",toggle:!0,commit:()=>{H(M>=2?-1.75:.25),Ft("tracks")}});else if(x==="enhance"||x==="spoken"){let ne=x==="spoken"?"spoken":"tags";me.textContent=ne==="spoken"?"write the script for the ear \u2014 sentences a person would say":"enhance the script \u2014 audio tags ElevenLabs v4 performs";let $e=it=>{let qe=U();Xn(),qe?.(it,{kind:ne})},He=oe(b.state.slide);Ot.push({text:`This slide \u2014 ${b.state.slide}`,flavor:ne==="spoken"?"its notes, reworded to be said aloud":"its notes, with tags added where they help",commit:()=>$e("slide")}),He&&Ot.push({text:`This module \u2014 \u201C${He.title}\u201D`,flavor:`slides ${He.from}\u2013${He.to}`,commit:()=>$e("module")}),Ot.push({text:"Every slide with notes",flavor:"a few at a time \u2014 the agent is asked once per slide",commit:()=>$e("all")})}else if(x==="record"){me.textContent="record this deck \u2014 writes wav files beside it",$&&Ot.push({text:`\u{1F4D1} Slides \u2014 ${Co(Tn)}`,flavor:Tn?"only these are recorded \u2014 the rest are left alone":"or just part of the deck\u2026",cur:!!Tn,commit:()=>$.open({title:"record which slides?",total:b.state.totalSlides,slide:b.state.slide,chapters:S(),current:Tn,onPick:He=>{Tn=He,ln&&cn==="record"&&Ft("record")}})});let ne=W();Ot.push({text:"\u{1F3A4} With your voice \u2014 read it aloud, beat by beat",flavor:ne?"":"the deck turns pages as you speak",blocked:ne||null,commit:()=>{if(ne)return c(ne,5e3);Xn(),_t()}});let $e=ue?.live?null:"pick a live voice first \u2014 \u26A1 Live voice, above";Ot.push({text:"\u{1F50A} With the synthesized voice \u2014 unattended",flavor:$e?"":`speaks every slide as ${K.voice}`,blocked:$e,commit:()=>{if($e)return c($e,5e3);Xn(),ds()}})}else if(x==="character"){me.textContent="character \u2014 an animated narrator lip-syncs the voice",$r||($r=!0,te.probe().then(()=>{ln&&cn==="character"&&Ft("character")}));let ne=te.bridgeInfo,$e=ne?.engines?.video??[];Ot.push({text:"Off",cur:te.mode==="off",commit:()=>es("off")});let He="decklight lipsync --wav2lip-dir <Wav2Lip> --wav2lip-ckpt <wav2lip_gan.pth> --python <its python> --portrait me=<photo> --save",it=ne?ne.videoWhy??"no Wav2Lip or SadTalker set up":"the lip-sync bridge is not running",qe=!$e.length&&ne?.film===!0;Ot.push({text:"\u{1F3AD} 2D character \u2014 offline visemes",flavor:ne?.engines?.viseme?"":ne?"no rhubarb \u2014 amplitude fallback":"lip-sync bridge offline \u2014 amplitude fallback",cur:te.mode==="viseme",commit:()=>es("viseme")}),Ot.push({text:`\u{1F3A5} Neural video \u2014 local GPU${$e.length?"\u2026":""}`,flavor:$e.length?"":qe?"no portrait yet \u2014 film yourself, below":it,blocked:$e.length?null:qe?"film yourself first \u2014 the row below":`set it up once: ${He}, then restart decklight`,cur:te.mode==="video",commit:()=>{$e.length?Ft("charvideo"):qe?c("neural video needs a portrait \u2014 \u{1F4F9} Film yourself, below, makes one",6e3):c(`neural video: ${it} \u2014 set it up once with ${He}, then restart decklight`,9e3)}}),ne&&"film"in ne&&Ot.push(vr(ne)),te.mode!=="off"&&Ot.push({text:`${te.solo?"\u25C9":"\u25CB"} Solo \u2014 the narrator takes the stage`,flavor:"slide content steps aside",cur:te.solo,commit:()=>ur(!te.solo)})}else if(x==="charvideo"){me.textContent="neural video \u2014 pick engine \xB7 portrait";let ne=te.bridgeInfo;for(let $e of ne?.engines?.video??[])for(let He of ne?.portraits?.length?ne.portraits:["default"])Ot.push({text:`\u{1F3A5} ${$e} \xB7 ${He}`,cur:te.mode==="video"&&te.engine===$e&&te.portrait===He,commit:()=>es("video",{engine:$e,portrait:He})});ne&&"film"in ne&&Ot.push(vr(ne,"a new one"))}else if(x==="engines"){if(me.textContent="live voice \u2014 which engine speaks",!l){let ne=()=>fetch(le).then($e=>$e.ok?$e.json():null).then($e=>$e?.ok===!0&&!!$e.engine).catch(()=>!1);fetch(ce(I,Z)).then(async $e=>$e.ok?$e.json():{stale:!0,bridge:await ne()}).then($e=>{l=$e?.stale?$e.bridge?"stale":"foreign":$e?.engines??[]}).catch(()=>{l=[]}).then(()=>{ln&&cn==="engines"&&Ft("engines")})}l?l==="stale"?Ot.push({text:`\u26A1 ${Z??"the bridge"} \u2014 and it cannot be changed from here`,flavor:"this voice bridge predates the engine picker",blocked:"restart it: decklight <deck>",cur:!0,commit:()=>{}}):l==="foreign"?Ot.push({text:"another program is answering on the voice bridge's port",flavor:"not decklight \u2014 the bridge could not start there",blocked:"stop that program, or restart decklight (it moves the bridge)",cur:!1,commit:()=>{}}):l.length||Ot.push({text:"no voice bridge is answering",flavor:"the engine list comes from it",blocked:"set one up once: decklight setup voice \xB7 then open the deck with decklight <deck.html>",cur:!1,commit:()=>{}}):Ot.push({text:"asking the bridge",busy:"asking the bridge",cur:!1,commit:()=>{}}),(Array.isArray(l)?[...l].sort((ne,$e)=>($e.ready===!0)-(ne.ready===!0)):[]).forEach(ne=>Ot.push({group:ne.ready?"ready":"needs setup",text:ne.name,flavor:ne.ready?ne.cost??"":ne.why??"unavailable",blocked:ne.ready?null:ne.fix??null,cur:!!ne.current,commit:()=>ws(ne)}))}else if(x==="voices"){if(!Or&&ts()){Or=!0;let p=Pn();p&&p!=="en"&&!pn&&(pn=`lang:${p}`)}let ne=yi(pn),$e=ne.length?de.filter(([p,v,,C])=>Jf(p,v,ne,C)):de,He=ne.find(p=>p.lang!==void 0)?.lang??null;me.textContent=ne.length?`live voice \u2014 ${$e.length} of ${de.length} \xB7 \u25B6 previews`:"live voice \u2014 pick a voice \xB7 \u25B6 previews",Ot.push({bar:!0,text:Z??"no bridge",flavor:En.has(Z)&&T?T:"",cur:!1,commit:()=>Ft("engines")});let it=document.createElement("div");it.className="narr-preview-row narr-filter-row";let qe=document.createElement("input");qe.className="narr-input narr-filter",qe.value=pn,qe.placeholder="Filter voices \u2014 try fr, or lang:fr",qe.setAttribute("aria-label","Filter voices by name or language"),qe.addEventListener("input",()=>{pn=qe.value,Fr=!0,Ft("voices")}),qe.addEventListener("keydown",p=>{p.key==="Escape"?(pn?(pn="",Fr=!0,Ft("voices")):Kn(),p.preventDefault()):(p.key==="ArrowDown"||p.key==="Enter")&&(Fr=!1,qe.blur(),rn(0,{scroll:!0}),p.preventDefault()),p.stopPropagation()}),it.appendChild(qe),X.appendChild(it),ts()&&Ot.push({text:`\u{1F310} Language \u2014 ${He?Hs(He):"all"}`,flavor:He&&He===Pn()?"the deck's":Pn()&&Pn()!=="en"&&!He?`the deck is ${Hs(Pn())}`:"",toggle:!0,commit:()=>Ft("langs")});let nt=document.createElement("div");nt.className="narr-preview-row";let r=document.createElement("input");r.className="narr-input narr-preview-text",r.value=Br,r.placeholder="Preview sentence",r.setAttribute("aria-label","Preview sentence"),r.addEventListener("input",()=>{Br=r.value}),r.addEventListener("keydown",p=>{p.key==="Escape"&&(Kn(),p.preventDefault()),p.stopPropagation()});let o=document.createElement("button");o.type="button",o.className="narr-prev-btn narr-reset-btn",o.textContent="\u21BA",o.title="restore the default sentence",o.setAttribute("aria-label","restore the default preview sentence"),o.addEventListener("click",p=>{p.stopPropagation(),Br=rr,r.value=rr}),nt.append(r,o),X.appendChild(nt),(Z==="say"||Z==="sapi")&&F&&!de.some(([,,p])=>p==="best")&&Ot.push({text:Z==="sapi"?"\u2B07 Get natural voices \u2014 free download":"\u2B07 Get Siri voices \u2014 free download",flavor:Z==="sapi"?"opens Settings \u2192 Narrator":"opens System Settings",group:"best",commit:()=>{fetch(ie,{method:"POST"}).then(p=>p.json()).then(p=>{if(!p?.ok)throw new Error(p?.error||"refused")}).then(()=>c("System Settings opened \u2014 download a Siri voice, then restart decklight tts",5200)).catch(()=>c(F,6e3))}});let i=["novelty","other languages"],u=new Set;if($e.forEach(([p,v,C])=>{if(!ne.length&&C&&i.includes(C)&&!se.has(C)){if(!u.has(C)){u.add(C);let ge=$e.filter(([,,Me])=>Me===C).length;Ot.push({text:`\u2023 ${C==="novelty"?"novelty voices":C} (${ge})`,toggle:!0,cur:!1,commit:()=>{se.add(C),Ft("voices")}})}return}let R=$e.find(ge=>ge[0]===p)?.[3];Ot.push({text:p,flavor:Array.isArray(R)&&R.length?`${v?`${v} \xB7 `:""}${R.join(" ")}`:v,group:C??null,preview:{voice:p,style:"",prefetch:"voices"},cur:ue?.live&&K.voice===p,commit:()=>{if(Jt=p,Ie)return Ft("tones");dr(Z??"plain","")}})}),ne.length&&!$e.length&&Ot.push({text:He&&ts()?`none of your voices speaks ${Hs(He)}`:"no voice matches",flavor:"Esc clears the filter \xB7 lang:fr narrows to a language",blocked:!0,commit:()=>{}}),Z==="elevenlabs"){let p=He??(Pn()!=="en"?Pn():null);Ot.push({text:`\u{1F50E} Find ${p?`${Hs(p)} `:""}voices in the ElevenLabs library\u2026`,flavor:"native voices other people share \u2014 hear each one free, add the one you want",toggle:!0,commit:()=>{Cr(p)}})}}else if(x==="langs"){me.textContent="live voice \u2014 which language";let ne=new Map;for(let nt of de)for(let r of Array.isArray(nt[3])?nt[3]:[])ne.set(r,(ne.get(r)??0)+1);let $e=Pn(),He=yi(pn).find(nt=>nt.lang!==void 0)?.lang??null,it=nt=>{let r=yi(pn).filter(o=>o.lang===void 0).map(o=>o.any);pn=[...nt?[`lang:${nt}`]:[],...r].join(" "),Ft("voices")};Ot.push({text:"All languages",flavor:`${de.length} voices`,cur:!He,commit:()=>it(null)});let qe=[...new Set([...$e?[$e]:[],...[...ne.keys()].sort((nt,r)=>ne.get(r)-ne.get(nt)),...Yf])];for(let nt of qe){let r=ne.get(nt)??0;Ot.push({text:`${Hs(nt)}${nt===$e?" \u2014 the deck's":""}`,flavor:r?`${r} of your voices`:"none of yours yet \u2014 find some in the library",cur:He===nt,commit:()=>r?it(nt):Cr(nt)})}}else if(x==="library"){let ne=Sr;me.textContent=`ElevenLabs voice library${ne?` \u2014 ${Hs(ne)}`:""} \xB7 \u25B6 plays each voice's sample`;let $e=document.createElement("div");$e.className="narr-preview-row narr-filter-row";let He=document.createElement("input");He.className="narr-input narr-filter",He.value=gn,He.placeholder="Search \u2014 narrator, warm, castilian\u2026 \u23CE",He.setAttribute("aria-label","Search the ElevenLabs voice library"),He.addEventListener("keydown",qe=>{qe.key==="Enter"?(gn=He.value.trim(),bn=null,Ft("library"),qe.preventDefault()):qe.key==="Escape"?(Kn(),qe.preventDefault()):qe.key==="ArrowDown"&&(He.blur(),rn(0,{scroll:!0}),qe.preventDefault()),qe.stopPropagation()}),$e.appendChild(He),X.appendChild($e);let it=`${ne??""}|${gn}`;if(!bn||bn.key!==it){bn={key:it,pending:!0};let qe=new URLSearchParams({...ne?{language:ne}:{},...gn?{search:gn}:{}});fetch(ce(`${Lr}?${qe}`,Z)).then(async nt=>({r:nt,j:await nt.json().catch(()=>({}))})).then(({r:nt,j:r})=>{bn?.key===it&&(bn=nt.ok&&r.ok?{key:it,voices:r.voices??[]}:{key:it,error:r.error??`the bridge answered ${nt.status}`})}).catch(nt=>{bn?.key===it&&(bn={key:it,error:`the voice bridge did not answer (${nt.message??nt})`})}).then(()=>{ln&&cn==="library"&&Ft("library")})}if(bn.pending)Ot.push({text:"asking ElevenLabs",busy:"asking ElevenLabs",cur:!1,commit:()=>{}});else if(bn.error)Ot.push({text:"the library did not answer",flavor:bn.error,blocked:!0,commit:()=>{}});else if(!bn.voices.length)Ot.push({text:`no ${ne?`${Hs(ne)} `:""}voices${gn?` for \u201C${gn}\u201D`:""}`,flavor:"try fewer words",blocked:!0,commit:()=>{}});else{let qe=new Set(de.map(nt=>nt[0]));for(let nt of bn.voices){let r=pr===nt.id;Ot.push({text:r?`\u23CE again adds \u201C${nt.name}\u201D to your ElevenLabs voices`:nt.name,flavor:r?"it uses one of your plan's voice slots \xB7 Esc leaves it":qe.has(nt.name)?`already yours \xB7 ${nt.flavor}`:nt.flavor,title:nt.description,cur:r,...nt.preview?{preview:{url:nt.preview,voice:nt.name}}:{},commit:()=>{if(qe.has(nt.name))return Jt=nt.name,Ie?Ft("tones"):dr(Z??"plain","");if(!r)return pr=nt.id,Ft("library");Hn(nt)}})}}}else if(x==="tones")me.textContent=`live voice \xB7 ${Jt??K.voice} \u2014 pick a tone \xB7 \u25B6 previews`,J.forEach(ne=>{let[$e]=ne,He=Qe(ne);Ot.push({text:$e,preview:{voice:Jt??K.voice,style:He,prefetch:"tones"},cur:ue?.live&&K.tone===$e,commit:()=>dr($e,He)})}),Ot.push({text:"Custom\u2026",cur:ue?.live&&K.tone==="Custom",commit:()=>Ft("custom")});else{me.textContent=`live voice \xB7 ${Jt??K.voice} \u2014 type the delivery instruction \xB7 \u25B6 previews`;let ne=document.createElement("div");ne.className="narr-preview-row";let $e=document.createElement("input");$e.className="narr-input",$e.value=K.style,$e.placeholder="Read in a \u2026",$e.addEventListener("keydown",it=>{it.key==="Enter"?(Vr(),it.preventDefault()):it.key==="Escape"&&(Kn(),it.preventDefault()),it.stopPropagation()});let He=document.createElement("button");He.type="button",He.className="narr-prev-btn narr-reset-btn",He.textContent="\u25B6",He.title="preview this delivery instruction",He.setAttribute("aria-label","preview this delivery instruction"),He.addEventListener("click",it=>{it.stopPropagation();let qe=$e.value.trim();qe&&Ar({voice:Jt??K.voice,style:qe},He)}),ne.append($e,He),X.appendChild(ne),setTimeout(()=>{$e.focus(),$e.select()},0),Ot=[],cr=0;return}let De=null;Ot.forEach((ne,$e)=>{if(ne.group!==De&&(De=ne.group??null,ne.group)){let qe=document.createElement("div");qe.className="narr-group",qe.textContent=ne.group,X.appendChild(qe)}let He=document.createElement("div");if(ne.bar){He.className="narr-row narr-engine-bar";let qe=Object.assign(document.createElement("span"),{className:"eb-k",textContent:"engine"}),nt=Object.assign(document.createElement("span"),{className:"eb-name",textContent:ne.text}),r=Object.assign(document.createElement("span"),{className:"eb-model",textContent:ne.flavor||""}),o=Object.assign(document.createElement("span"),{className:"eb-go",textContent:"change engine \u203A"});He.title="the engine decides which voices exist \u2014 change it here",He.append(qe,nt,r,o),He.addEventListener("mouseenter",()=>rn($e)),He.addEventListener("click",()=>{rn($e),jn()}),X.insertBefore(He,me.nextSibling);return}He.className="narr-row"+(ne.cur?" narr-cur":"")+(ne.toggle?" narr-toggle":"")+(ne.blocked||ne.blocked===""?" narr-blocked":""),ne.title&&(He.title=ne.title);let it=document.createElement("span");if(it.className="narr-row-label",it.textContent=ne.text,ne.busy&&Fn.push(Es(qe=>{it.textContent=qe},{label:ne.busy})),ne.flavor){let qe=document.createElement("span");qe.className="narr-flavor",qe.textContent=ne.flavor,it.appendChild(qe)}if(He.appendChild(it),ne.blocked){let qe=document.createElement("div");qe.className="narr-fix",qe.textContent=ne.blocked,He.appendChild(qe)}if(ne.preview){let qe=document.createElement("button");qe.type="button",qe.className="narr-prev-btn",qe.textContent="\u25B6",qe.title=`preview ${ne.preview.voice}`,qe.setAttribute("aria-label",`preview ${ne.preview.voice}`),qe.addEventListener("click",nt=>{if(nt.stopPropagation(),ne.preview.url){or??=new Audio,or.src=ne.preview.url,or.play().catch(()=>c("the sample would not play",2400));return}Ar(ne.preview,qe)}),He.appendChild(qe)}He.addEventListener("mouseenter",()=>rn($e)),He.addEventListener("click",()=>{rn($e),jn()}),X.appendChild(He)});let Ge=Ot.findIndex(ne=>ne.cur);if(rn(Math.max(0,Ge),{scroll:!0}),Fr){let ne=X.querySelector(".narr-filter");ne&&(ne.focus(),ne.setSelectionRange(ne.value.length,ne.value.length))}}async function ws(x){if(x?.name){if(!x.ready)return c(x.fix?`${x.name}: ${x.why} \u2014 ${x.fix}`:`${x.name}: ${x.why??"unavailable"}`,5e3);if(x.current)return Ft("voices");try{let X=await(await fetch(ce(le,x.name))).json();if(!X.ok)return c(`${x.name}: ${X.why??X.error}${X.fix?` \u2014 ${X.fix}`:""}`,5e3);_e=Promise.resolve(be(X)),l=null,f("tts",`engine \u2192 ${X.engine} \xB7 ${X.model} \xB7 ${de.length} voice(s)`),ue?.live&&qn(),c(`\u26A1 engine: ${X.engine}${X.cost?` \xB7 ${X.cost}`:""}`+(ue?.live?" \u2014 this deck remembers it":" \u2014 pick a voice to keep it"),3200),X.caveat&&c(X.caveat,6e3),Ft("voices")}catch{c(`${x.name}: the voice bridge did not answer`,3e3)}}}function Vr(){let x=ln?.querySelector(".narr-input")?.value.trim();x&&dr("Custom",x)}function ss(x){if(ln&&x===void 0)return Xn();ln||(ln=document.createElement("div"),ln.className="decklight-narr",ln.innerHTML='<div class="narr-card" role="listbox" aria-label="Narration"></div>',Qt(ln,Xn),e.appendChild(ln)),Ft(x??"tracks"),d().then(q=>{q&&ln&&cn==="voices"&&Ft("voices")})}function Xn(){jt(),ln?.remove(),ln=null,se.clear(),pn="",Fr=!1,Or=!1,pr=null,$r=!1}let $n=null,jr="confirm",Sn=0,Gt=null,Tn=/^\d+(?:-\d+)?$/.test(s?.get?.("slides")??"")?s.get("slides"):null;function Rr(){let x=[];for(let De=1;De<=b.state.totalSlides;De++)Ke(De)&&x.push(De);let q=/^(\d+)(?:-(\d+))?$/.exec(Tn??"");if(!q)return x;let X=Number(q[1]),me=q[2]?Number(q[2]):X;return x.filter(De=>De>=X&&De<=me)}function Jr(x,q={}){jr=x;let X=$n.querySelector(".narr-card");if(x==="confirm"){let me=q.total;X.innerHTML=`<div class="narr-head">record offline narration</div>
|
|
400
|
+
<div class="rec-line">\u26A1 ${K.voice} \xB7 ${K.tone}</div>
|
|
401
|
+
<div class="rec-line">${me} slide${me===1?"":"s"} stitched from the sentence cache \u2014 only unheard sentences synthesize</div>
|
|
402
|
+
${Tn?`<div class="rec-line"><strong>${Et(Co(Tn))} only \u2014 everything else is left alone</strong></div>`:""}
|
|
403
|
+
${ls(q.target)}
|
|
335
404
|
<div class="narr-row narr-sel">Start recording</div>
|
|
336
|
-
<div class="rec-hint">Enter to start \xB7 Esc to cancel</div>`,
|
|
337
|
-
<div class="rec-bar"><div class="rec-bar-fill" style="width:${
|
|
338
|
-
<div class="rec-line">${
|
|
339
|
-
<div class="rec-hint">Esc to cancel</div>`}else{let{saved:
|
|
340
|
-
<div class="rec-line">${
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
${
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
<div class="rec-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
${
|
|
351
|
-
${
|
|
352
|
-
${
|
|
353
|
-
|
|
354
|
-
<div class="rec-
|
|
355
|
-
<div class="rec-
|
|
356
|
-
|
|
357
|
-
${
|
|
358
|
-
|
|
359
|
-
<div class="rec-
|
|
360
|
-
|
|
361
|
-
<div class="rec-line"
|
|
362
|
-
|
|
363
|
-
${
|
|
364
|
-
`)}function gt(j){let oe=j==="md",he=URL.createObjectURL(new Blob([je(oe)],{type:oe?"text/markdown":"text/plain"})),le=(location.pathname.split("/").pop()||"deck").replace(/\.html?$/i,"");m(he,`${le}-transcript.${oe?"md":"txt"}`),setTimeout(()=>URL.revokeObjectURL(he),5e3),c("narr",`transcript exported (.${oe?"md":"txt"})`)}let ut=null;function Q(){if(ut){ut.remove(),ut=null;return}ut=document.createElement("div"),ut.className="decklight-narr decklight-transcript";let j=document.createElement("div");j.className="narr-card";let oe=document.createElement("div");oe.className="narr-head",oe.textContent="transcript \u2014 the deck\u2019s spoken notes \xB7 Esc closes";let he=document.createElement("div");he.className="tr-actions";for(let[le,Re]of[["\u2B07 export .txt","txt"],["\u2B07 export .md","md"]]){let Y=document.createElement("button");Y.type="button",Y.className="narr-prev-btn",Y.textContent=le,Y.addEventListener("click",()=>gt(Re)),he.appendChild(Y)}j.append(oe,he);for(let{n:le,title:Re,segs:Y}of _()){if(!Y.length)continue;let s=document.createElement("div");s.className="tr-slide";let i=document.createElement("div");i.className="tr-title",i.textContent=`${le} \xB7 ${Re}`,i.title="jump to this slide",i.addEventListener("click",()=>{Q(),p.goto(le,0,{force:!0})}),s.appendChild(i);for(let O of Y){let Ue=document.createElement("p");Ue.className="tr-seg",Ue.textContent=O,s.appendChild(Ue)}j.appendChild(s)}ut.appendChild(j),Ht(ut,Q),t.appendChild(ut)}return p.transcript={open:Q,text:()=>je(!1),markdown:()=>je(!0)},d.register({isOpen:()=>!!ut,close:Q,keydown:j=>j.key==="Escape"&&(Q(),!0)}),{toggleClock:re,toggleProgress:_e,toggleInk:bt,toggleTranscript:Q,get annotator(){return Ze},status:()=>({clockOn:S,progressOn:ze})}}me();fe();var Rd=["data-background-image","data-background-video","data-background-poster","data-background-size","data-background-position","data-background-dim"];function Id(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 Pd=t=>`url("${String(t).replace(/["\\]/g,"\\$&")}")`;function Bd(t){let o={};for(let a of Rd){let c=t.getAttribute(a);c!==null&&(o[a]=c)}return o}function Ca(t,{printMode:o=!1}={}){t.forEach(a=>{let c=Id(Bd(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 f=c.image||(o?c.poster:null);if(d.style.backgroundImage=f?Pd(f):"",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)})}me();fe();me();fe();var Dd="npx decklight author";function qd(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 Fn(t,o={}){let{protocol:a="",pathname:c=""}=o,{dir:d,file:p}=qd(c),f=/\.html?$/i.test(p)?p:"<deck.html>",m=a==="file:"&&d?`from ${d}, `:"";return`${t} needs author mode: ${m}run ${Dd} ${f}, then reopen the URL it prints`}function Fd(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 zd={second:"s",minute:"m",hour:"h",day:"d",week:"w",month:"mo",year:"y"};function Na(t){let o=/^(\d+)\s+(second|minute|hour|day|week|month|year)s?\s+ago$/.exec(String(t??"").trim());return o?`${o[1]}${zd[o[2]]}`:String(t??"")}function Ma(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 ${Fd(o-c)}${a}`}function Oa(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 La(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`}me();fe();var Ud=/<\s*(pre|textarea|script|style)\b/i,Hd=t=>!Ud.test(String(t??""));function Ra(t){let o=String(t??"");if(!Hd(o))return o;let a=o.split(`
|
|
365
|
-
`);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(`
|
|
366
|
-
`):o}function Ia({root:t,config:o,params:a,printMode:c,toast:d,debugLog:p,overlays:f,instance:m,notesSegs:v,dismissOthers:k}){let S=!1,P="",T=[],A=null,N=[],I=null,Se=!1,pe=null,Oe=0;function re(){let M=Ma(I);if(!M){clearInterval(Oe),Oe=0,pe?.remove(),pe=null;return}pe||(pe=document.createElement("div"),pe.className="decklight-agent-chip",pe.setAttribute("role","status"),pe.setAttribute("aria-live","polite"),t.appendChild(pe)),pe.textContent=`\u{1F916} ${M}`,pe.title=I.prompt?`asked: ${I.prompt}`:"",Oe||(Oe=setInterval(re,1e3))}let ce=null,Me=null;function ze(){let M=La(ce);if(!M){Me?.remove(),Me=null;return}if(!Me){Me=document.createElement("div"),Me.className="decklight-commit-chip",Me.setAttribute("role","status"),Me.setAttribute("aria-live","polite"),Me.tabIndex=0;let H=()=>bt();Me.addEventListener("click",H),Me.addEventListener("keydown",K=>{(K.key==="Enter"||K.key===" ")&&(K.preventDefault(),H())}),t.appendChild(Me)}Me.textContent=`\u2325 ${M}`,Me.title="commit this \u2014 the work is snapshotted either way"}async function Ve(){if(!S)return null;try{let H=await(await fetch(P+"/edit/commit")).json();if(H?.ok)return ce=H,ze(),H}catch{}return null}let $e=null,_e=!1;function Ze(){$e?.remove(),$e=null,_e=!1}async function bt(){if($e)return Ze();if(!S){d(Fn("committing",location),3200);return}let M=await Ve()??ce;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}k(),$e=document.createElement("div"),$e.className="decklight-narr decklight-commit",$e.innerHTML='<div class="narr-card" role="dialog" aria-label="Commit"></div>',Ht($e,Ze),t.appendChild($e);let H=$e.querySelector(".narr-card"),K=document.createElement("div");K.className="narr-head",K.textContent="commit";let se=document.createElement("div");se.className="cm-what";let qe=Number(M.lines)||0,Qe=Math.floor((Number(M.sinceMs)||0)/6e4);se.textContent=`${qe?`${qe} line${qe===1?"":"s"}`:"changes"} in ${M.deck||"the deck"}`+(Qe>=1?`, ${Qe>=60?`${Math.floor(Qe/60)}h`:`${Qe}m`} old`:"");let Fe=document.createElement("textarea");Fe.className="narr-input cm-input",Fe.rows=3,Fe.placeholder="what changed, in one line\u2026";let ge=document.createElement("div");ge.className="cm-row";let Be=document.createElement("div");Be.className="narr-row narr-sel cm-write",Be.setAttribute("role","button"),Be.tabIndex=0,Be.textContent=M.messages?"writing one\u2026":"write one for me";let st=document.createElement("div");st.className="narr-row narr-sel cm-go",st.setAttribute("role","button"),st.tabIndex=0,st.textContent="Commit",ge.append(Be,st);let wt=document.createElement("div");wt.className="rec-hint",wt.textContent="\u2318\u23CE commits \xB7 Esc closes \u2014 the work is snapshotted either way",H.append(K,se,Fe,ge,wt),setTimeout(()=>Fe.focus(),0);let Mt=async()=>{if(!_e){_e=!0,Be.textContent="writing one\u2026";try{let nt=await fetch(P+"/edit/commit/subject",{method:"POST"}),vt=await nt.json();if(!vt?.ok)throw new Error(vt?.error||`HTTP ${nt.status}`);if(!$e)return;vt.subject&&!Fe.value.trim()&&(Fe.value=vt.subject),Be.textContent=vt.subject?"write another":"nothing to say about it"}catch(nt){$e&&(Be.textContent=`couldn't \u2014 ${String(nt.message||nt).slice(0,40)}`)}finally{_e=!1}}};Be.addEventListener("click",Mt),M.messages&&Mt();let pt=async()=>{let nt=Fe.value.trim();if(!nt){Fe.focus();return}st.textContent="committing\u2026";try{let vt=await fetch(P+"/edit/commit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({message:nt})}),L=await vt.json();if(!L?.ok)throw new Error(L?.error||`HTTP ${vt.status}`);Ze(),ce=L.committed?{...L,nag:!1}:ce,ze(),d(L.committed?`committed \u2014 "${L.subject}"`:"nothing to commit",2600),p("git",L.committed?`commit: ${L.subject}`:"commit: nothing to do")}catch(vt){st.textContent=`couldn't commit \u2014 ${String(vt.message||vt).slice(0,40)}`}};st.addEventListener("click",pt),Fe.addEventListener("keydown",nt=>{nt.key==="Enter"&&(nt.metaKey||nt.ctrlKey)&&(nt.preventDefault(),pt()),!((nt.metaKey||nt.ctrlKey)&&(nt.key==="k"||nt.key==="K"))&&nt.stopPropagation()}),_??=f.register({isOpen:()=>!!$e,close:Ze,keydown(nt){return nt.key==="Escape"?(Ze(),!0):/^(input|textarea)$/i.test(nt.target?.tagName??"")?!1:nt.key==="Enter"?($e?.querySelector(".cm-go")?.click(),!0):nt.key==="k"||nt.key==="K"?(Ze(),!0):!1}})}let _=null,je,gt=new Promise(M=>{je=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 H of M)try{let K=await fetch(H+"/edit/ping");if(!K.ok)continue;let se=await K.json();if(!se?.ok)continue;let qe=decodeURIComponent(location.pathname.split("/").pop()||"");if(qe&&se.name&&qe!==se.name){p("edit",`server edits ${se.name}, this deck is ${qe} \u2014 not wiring up`);continue}P=H,S=!0,m.__saveTimings=async ge=>{let Be=await fetch(P+"/edit/timings",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({timings:ge})});if(!Be.ok)throw new Error(await Be.text());p("edit",`rehearsal timings saved \u2014 ${ge.length} slides`)},T=Array.isArray(se.agents)?se.agents:[],A=typeof se.preferredAgent=="string"?se.preferredAgent:null,N=Array.isArray(se.wizards)?se.wizards:[];let Qe=Oa(se.remote);Qe&&(Se=!0,d(Qe,4200)),se.commit&&(ce=se.commit,ze()),I=se.agentBusy||null,I&&d(`${I.agent} is editing the deck\u2026`,2e3),re();let Fe=new EventSource(H+"/edit/events");Fe.onmessage=()=>location.reload(),Fe.addEventListener("commit",ge=>{try{ce=JSON.parse(ge.data),ze(),p("git",`uncommitted: ${ce.lines} lines`)}catch{}}),Fe.addEventListener("agent",ge=>{try{let Be=JSON.parse(ge.data);if(Be.state==="activity")I&&(I.activity=Be.text,re()),p("agent",`activity: ${Be.text}`);else if(Be.state==="start")I=Be,re(),d(`\u{1F916} ${Be.agent} is editing the deck\u2026`,2200),p("agent",`${Be.agent} start: ${(Be.prompt||"").slice(0,80)}`);else if(Be.state==="done"){I=null,re();let st=Be.ok?"":Be.error?` \u2014 ${Be.error}`:` (exit ${Be.code})`;d(Be.changed?`\u{1F916} ${Be.agent} edited the deck \u2014 Z undoes${st}`:`\u{1F916} ${Be.agent} finished \u2014 no changes${st}`,3e3),p("agent",`${Be.agent} done ok=${Be.ok} changed=${Be.changed}${st}`),typeof Be.recordingWarning=="string"&&(d(Be.recordingWarning,9e3),p("agent",Be.recordingWarning))}}catch{}}),p("edit",`live reload connected${H?` (${H})`:""}`+(T.length?` \xB7 agents: ${T.map(ge=>ge.name).join(", ")}`:"")),je();return}catch{}je(),await s()})()}let ut=null,Q=!1,j=null;function oe(){j?.remove(),j=null}function he(M,H){let K=document.createElement("div");return K.className=H,K.textContent=M,K}async function le(M){let H=j?.querySelector(".tp-list");if(!H)return;H.textContent="",H.appendChild(he(M.message??M.state,"hs-remote"));for(let qe of M.commits??[])H.appendChild(he(`${qe.hash} ${qe.subject}`,"tp-row"));let K=j.querySelector(".up-actions");K.textContent="";let se=(qe,Qe)=>{let Fe=document.createElement("button");return Fe.type="button",Fe.className="narr-prev-btn",Fe.textContent=qe,Fe.addEventListener("click",Qe),K.appendChild(Fe),Fe};se("check now",async()=>{K.textContent="checking\u2026",await le(await Re("/present/upstream/check"))}),M.state==="behind"&&M.pull?.offered?se("update the deck",async()=>{K.textContent="pulling\u2026";let qe=await Re("/present/upstream/pull");if(qe.reload)return location.reload();await le({...qe,commits:[],message:qe.message}),qe.state==="pulled"&&se("show it anyway",()=>location.reload())}):M.pull&&!M.pull.offered&&M.state==="behind"&&K.appendChild(he(`update control off \u2014 ${M.pull.reason}`,"hs-remote"))}async function Re(M){try{return await(await fetch(ut+M,{method:"POST"})).json()}catch{return{state:"error",message:"the presenting server did not answer"}}}async function Y(){if(j)return oe();let M;try{let H=await fetch(ut+"/present/upstream");if(!H.ok)return d("this deck is not a tracked file in a git clone \u2014 nothing to update from",3400);M=await H.json()}catch{return d("deck update: the presenting server did not answer",3e3)}k(),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>',Ht(j,oe),t.appendChild(j),await le(M)}f.register({isOpen:()=>!!j,close:oe,keydown:M=>M.key==="Escape"&&(oe(),!0)});async function s(){let M=/^https?:$/.test(location.protocol)?"":"http://127.0.0.1:8790";try{let H=await fetch(M+"/present/ping");if(!H.ok)return;let K=await H.json();if(!K?.ok||!K.present)return;let se=decodeURIComponent(location.pathname.split("/").pop()||"");if(se&&K.name&&se!==K.name){p("present",`server presents ${K.name}, this deck is ${se} \u2014 not wiring up`);return}m.__remoteQr=K.remote?`${M||location.origin}/remote/qr.svg`:null,ut=M,Q=!0,new EventSource(M+"/present/events").addEventListener("remote",Fe=>{try{let{key:ge}=JSON.parse(Fe.data);ge==="next"?m.next():ge==="prev"&&m.prev()}catch{}});let Qe=()=>{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",Qe),m.on("build",Qe),Qe(),p("present",`remote connected${M?` (${M})`:""} \u2014 no edit surface`)}catch{}}async function i(M){if(!S){d(Fn(M,location),3200);return}try{let H=await fetch(P+"/edit/"+M,{method:"POST"}),K=await H.json().catch(()=>({}));if(!H.ok){d(K.error||`${M} failed`);return}d(`${M} \u2014 ${K.undo} back \xB7 ${K.redo} forward`),p("edit",`${M} \u2192 ${K.undo} back, ${K.redo} forward`)}catch{d(`${M} failed \u2014 is the dev server still up?`,2200)}}let O=null;function Ue(){if(O){O.remove(),O=null;return}if(!S){d(Fn("asking an agent",location),3200);return}if(!T.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 H=document.createElement("div");H.className="narr-head",H.textContent="ask an agent \u2014 edits the deck file \xB7 \u2318\u23CE sends \xB7 Esc closes";let K=document.createElement("textarea");K.className="narr-input edit-notes",K.placeholder=`e.g. "make slide ${m.state.slide} a split layout with the diagram on the left"`,K.spellcheck=!1;let se=A&&T.some(ge=>ge.name===A)?A:T[0].name,qe=document.createElement("div");if(qe.className="tr-actions",T.length>1){let ge=document.createElement("select");ge.className="narr-prev-btn";for(let Be of T){let st=document.createElement("option");st.value=Be.name,st.textContent=Be.label,ge.appendChild(st)}ge.value=se,ge.addEventListener("change",()=>{se=ge.value,A=ge.value,fetch(P+"/edit/agent/prefer",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({agent:ge.value})}).catch(()=>{}),p("agent",`preferred agent \u2192 ${ge.value}`)}),ge.addEventListener("keydown",Be=>Be.stopPropagation()),qe.appendChild(ge)}let Qe=async()=>{let ge=K.value.trim();if(ge)try{let Be=await fetch(P+"/edit/agent",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({prompt:ge,agent:se})}),st=await Be.json().catch(()=>({}));if(!Be.ok)throw new Error(st.error||Be.status);Ue()}catch(Be){d(`ask failed: ${String(Be.message||Be).slice(0,60)}`,2200)}};K.addEventListener("keydown",ge=>{ge.key==="Enter"&&(ge.metaKey||ge.ctrlKey)?(Qe(),ge.preventDefault()):ge.key==="Escape"&&(Ue(),ge.preventDefault()),ge.stopPropagation()});let Fe=document.createElement("button");Fe.type="button",Fe.className="narr-prev-btn",Fe.textContent="\u{1F916} send to agent",Fe.addEventListener("click",Qe),qe.appendChild(Fe),M.append(H,K,qe),O.appendChild(M),Ht(O,Ue),t.appendChild(O),setTimeout(()=>K.focus(),0)}let B=null;function Le(){if(B){B.remove(),B=null;return}let M=m.state.slide;if(!S){d(Fn("editing notes",location),3200);return}B=document.createElement("div"),B.className="decklight-narr decklight-editor";let H=document.createElement("div");H.className="narr-card";let K=document.createElement("div");K.className="narr-head",K.textContent=`edit notes \u2014 slide ${M} \xB7 \u2318\u23CE saves \xB7 Esc closes`;let se=document.createElement("textarea");se.className="narr-input edit-notes",se.value=v(M).filter((ge,Be,st)=>ge||Be<st.length).join(`
|
|
405
|
+
<div class="rec-hint">Enter to start \xB7 Esc to cancel</div>`,Qn(X,De=>{Gt=De}),X.querySelector(".narr-row").addEventListener("click",kr)}else if(x==="progress"){let{done:me,total:De,elapsedMs:Ge}=q,ne=De?Math.round(me/De*100):0,$e=me?Jc(Ge/me*(De-me)):"\u2026";X.innerHTML=`<div class="narr-head">recording\u2026</div>
|
|
406
|
+
<div class="rec-bar"><div class="rec-bar-fill" style="width:${ne}%"></div></div>
|
|
407
|
+
<div class="rec-line">${me} / ${De} slides \xB7 ${Jc(Ge)} elapsed \xB7 ~${$e} left</div>
|
|
408
|
+
<div class="rec-hint">Esc to cancel</div>`}else{let{saved:me,total:De,cancelled:Ge,dir:ne}=q,$e=em(q.clips,q.engine),He=q.segmented?"slide-NN.wav + one slide-NN-KK.wav per [click]":"slide-NN.wav",it=ne?`saved as ${He} in <code>${Et(ne)}/</code>, next to the deck`:`saved as ${He} to your downloads \u2014 ${fs()}`,qe=q.segmented?", segments: true":"",nt=ne?`Set <code>narration: { files: '${Et(ne)}', ext: 'wav'${qe} }</code> to play them back without the bridge \u2014 <code>decklight bundle</code> picks the folder up from there.`+(q.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'${qe}</code> to play them back without the bridge.`;X.innerHTML=`<div class="narr-head">${Ge?"recording cancelled":"recording done"}</div>
|
|
409
|
+
<div class="rec-line">${me} / ${De} slide${De===1?"":"s"} ${it}</div>
|
|
410
|
+
${$e?`<div class="rec-line">${Et($e)}</div>`:""}
|
|
411
|
+
<div class="rec-line">${nt}</div>
|
|
412
|
+
${Xe(ne)}
|
|
413
|
+
${zr(ne)}`,cs(X,ne,{ext:"wav",label:q.label,...q.segmented?{segments:!0}:{}})}}let Hr=.35;async function sr(x,q){let X=Pe(x),me=bi(ae(x)),De=mt(x),Ge=[],ne=new Map,$e=qe=>qe.some(nt=>typeof nt!="number"),He=0;for(let qe=0;qe<=X;qe++){let{sentences:nt,segStarts:r,segRuns:o,before:i,after:u,bare:p}=ke(x,qe);p&&Ge.push(p*De);for(let v=0;v<nt.length;v++){let C=await ve(x,qe,v,nt[v]);if(q!==Sn)return null;if(!C)continue;let R=await C.blob.arrayBuffer();He||=new DataView(R).getUint32(24,!0)||24e3;let ge=vt(x);$e(Ge)&&Ge.push(v===0||r.has(v)?Hr:ge);let Me=new Uint8Array(R.slice(44));Ge.push(i[v]*De,Me,u[v]*De);let We=o.find(qt=>v>=qt.from&&v<qt.from+qt.count),rt=We&&me?me[qe+We.seg]:null;if(rt==null)continue;let Je=ne.get(rt);Je||ne.set(rt,Je=[]),$e(Je)&&Je.push(ge),Je.push(i[v]*De,Me,u[v]*De)}}He||=24e3;let it=qe=>qe.map(nt=>typeof nt=="number"?om(He,nt):nt).filter(nt=>nt.length);return{wav:$e(Ge)?gi(it(Ge),He):null,segments:[...ne].map(([qe,nt])=>({file:qe,wav:gi(it(nt),He)}))}}async function Ps(x,q){if(te.mode!=="viseme")return null;let X=Pe(x),me=bi(ae(x)),De=mt(x),Ge=[],ne=new Map,$e=0;try{for(let it=0;it<=X;it++){let{sentences:qe,segStarts:nt,segRuns:r,before:o,after:i,bare:u}=ke(x,it);$e+=u*De;for(let p=0;p<qe.length;p++){let v=await te.ensureTimeline(Y(x,it,p,qe[p]),ve(x,it,p,qe[p]),qs(qe[p]));if(q!==Sn)return null;if(!v)continue;let C=vt(x),R=Ge.length?p===0||nt.has(p)?Hr:C:0;Ge.push({timeline:v,gap:R+$e+o[p]*De}),$e=i[p]*De;let ge=r.find(rt=>p>=rt.from&&p<rt.from+rt.count),Me=ge&&me?me[it+ge.seg]:null;if(Me==null)continue;let We=ne.get(Me);We||ne.set(Me,We={parts:[],carry:0}),We.parts.push({timeline:v,gap:(We.parts.length?C:0)+We.carry+o[p]*De}),We.carry=i[p]*De}}}catch{return f("lipsync",`slide ${x}: viseme sidecar skipped (bridge unreachable)`),null}let He=(it,qe)=>qe>0?[...it,{timeline:null,gap:qe}]:it;return{slide:Ge.length?ma(He(Ge,$e)):null,segments:[...ne].map(([it,qe])=>({file:it,timeline:ma(He(qe.parts,qe.carry))}))}}async function os(){let x=P();if(x==null)return[];try{let X=await(await fetch(`${x}/deck/edit/narration/tracks`)).json();return Array.isArray(X?.tracks)?X.tracks:[]}catch{return[]}}function is({mine:x},q){let X=x?null:Z,me=x?null:K?.voice,De=x?{mine:!0}:{engine:X,voice:me},Ge=wa(De,q.map(qe=>qe.dir)),ne=wa(De,[]).label,$e=(qe,nt)=>({dir:qe,label:nt==="new"?Ge.label:ne,why:nt,clash:q.find(r=>r.dir===qe)??null}),He=fr(s?.get?.("dir"));if(He)return $e(He,"asked");if(!x&&me){let qe=q.find(nt=>nt.voice&&nt.voice===me&&(!nt.engine||!X||nt.engine===X));if(qe)return $e(qe.dir,"refresh")}let it=fr(mr({configOnly:!0}));return it?$e(it,"configured"):$e(Ge.dir,"new")}function as(x){let q=x.find(X=>X.manifest&&X.engine===Z&&X.voice===K.voice);return q?q.dir:wa({engine:Z,voice:K.voice},x.map(X=>X.dir)).dir}let Tr="voiceover",fr=x=>typeof x=="string"&&x&&!/^[a-z][a-z0-9+.-]*:/i.test(x)&&!/^[/\\]/.test(x)&&!x.split(/[/\\]/).includes("..")?x:null;function mr({configOnly:x=!1}={}){let q=fr(s?.get?.("dir"));if(q)return q;let X=n.narration?.files,me=typeof X=="string"?X:Array.isArray(X)?X.find(Ge=>typeof Ge?.dir=="string")?.dir:null;return fr(me)??(x?null:Tr)}async function Ir(x,q,X,me,De=null){if(me)try{if((await(await fetch(`${me.base}/deck/edit/narration/record?slide=${x}&kind=${q}`+(De==null?"":`&seg=${De}`)+`&dir=${encodeURIComponent(me.name)}`,{method:"POST",body:X})).json())?.ok)return!0}catch{}let Ge=`slide-${String(x).padStart(2,"0")}`+(De==null?"":`-${String(De).padStart(2,"0")}`)+`.${q==="wav"?"wav":"visemes.json"}`,ne=URL.createObjectURL(X);return L(ne,Ge),setTimeout(()=>URL.revokeObjectURL(ne),5e3),!1}function ls(x){if(!x)return"";let q=x.clash&&x.why!=="refresh"?`<div class="rec-line rec-warn">${x.clash.files} file(s) are already in <code>${Et(x.dir)}/</code>${x.clash.voice?` (${Et(x.clash.voice)})`:""} and will be replaced.</div>`:"";return`<div class="rec-line rec-folder"><label>folder
|
|
414
|
+
<input class="rec-dir" value="${Et(x.dir)}" spellcheck="false"
|
|
415
|
+
aria-label="folder to record into"></label></div>${q}`}function Qn(x,q){let X=x?.querySelector(".rec-dir");if(!X)return;let me=()=>{let De=fr(X.value.trim());return X.classList.toggle("rec-bad",!De),De};X.addEventListener("input",()=>{let De=me();De&&q({dir:De,label:X.dataset.label||De,clash:null})}),X.addEventListener("keydown",De=>{De.key==="Enter"&&De.stopPropagation()})}async function hs(x,q,X){let me=P();if(me!=null){x.textContent="saving\u2026";try{let De=await fetch(`${me}/deck/edit/narration`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({files:q,...X})}),Ge=await De.json();if(!Ge?.ok)throw new Error(Ge?.error||`HTTP ${De.status}`);x.textContent=`\u2713 the deck now plays this track \u2014 ${zt} undoes it`,x.classList.add("rec-done"),f("narr",`narration config \u2192 ${q}`)}catch(De){x.classList.add("rec-failed"),x.textContent=`couldn't write it \u2014 ${String(De.message||De)}`}}}function Xe(x){return P()==null||!x?"":'<div class="narr-row narr-sel rec-use" role="button" tabindex="0">Use this track in the deck</div>'}function Wn(x){let q=x?.querySelector(".rec-use");return q&&!q.classList.contains("rec-done")&&!q.classList.contains("rec-failed")?q:null}function zr(x){return P()==null||!x?'<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 cs(x,q,X){let me=x?.querySelector(".rec-use");if(!me)return;let De=()=>hs(me,q,X);me.addEventListener("click",De),me.addEventListener("keydown",Ge=>{(Ge.key==="Enter"||Ge.key===" ")&&(Ge.preventDefault(),De())})}function fs(){return s?.has?.("record")?"no edit server answered, though <code>decklight narrate --mic</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 narrate --mic deck.html</code> serves it and writes them for you.":"no edit server owns this deck file \u2014 <code>decklight narrate --mic deck.html</code> writes them next to the deck instead."}async function kr(){let x=Rr(),q=++Sn,X=Date.now(),me=0,De=0,Ge=0,ne=!1,$e=D={seen:new Set,reused:0,sent:0,cost:0};if(await j(),q!==Sn)return;let He=P(),it=Gt??is({mine:!1},await os());if(q!==Sn)return;let qe=He==null?null:{base:He,name:it.dir},nt={},r=(()=>{let i=/^(\d+)(?:-(\d+))?$/.exec(Tn??"");return i?[Number(i[1]),i[2]?Number(i[2]):Number(i[1])]:[1,b.state.totalSlides]})(),o=async()=>{if(qe)try{await fetch(`${qe.base}/deck/edit/narration/record?slide=1&kind=manifest&dir=${encodeURIComponent(qe.name)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({engine:Z,model:T,voice:K.voice,style:K.style,range:r,slides:nt})})}catch{}};Jr("progress",{done:me,total:x.length,elapsedMs:0});for(let i of x){if(q!==Sn)return;try{let u=await sr(i,q);if(q!==Sn)return;if(u?.wav){if(await Ir(i,"wav",u.wav,qe)&&Ge++,q!==Sn)return;De++,nt[i]={segments:u.segments.map(v=>v.file)};for(let v of u.segments){if(await Ir(i,"wav",v.wav,qe,v.file),q!==Sn)return;ne=!0}let p=await Ps(i,q);if(q!==Sn||p?.slide&&(await Ir(i,"visemes",new Blob([JSON.stringify(p.slide)],{type:"application/json"}),qe),q!==Sn))return;for(let v of p?.segments??[])if(await Ir(i,"visemes",new Blob([JSON.stringify(v.timeline)],{type:"application/json"}),qe,v.file),q!==Sn)return;if(await o(),q!==Sn)return}}catch{c(`slide ${i}: recording failed`)}me++,q===Sn&&Jr("progress",{done:me,total:x.length,elapsedMs:Date.now()-X})}q===Sn&&(D=null,Jr("done",{saved:De,total:x.length,dir:Ge?qe.name:null,segmented:ne,label:it.label,clips:$e,engine:Z}))}function ds(){if(!ue?.live){c("live voice only \u2014 pick a voice with N first");return}$n||($n=document.createElement("div"),$n.className="decklight-narr decklight-record",$n.innerHTML='<div class="narr-card" role="dialog" aria-label="Record offline narration"></div>',Qt($n,Yr),e.appendChild($n),Gt=null,Jr("confirm",{total:Rr().length}),j().then(()=>os()).then(x=>{!$n||jr!=="confirm"||(Gt=is({mine:!1},x),Jr("confirm",{total:Rr().length,target:Gt}))}))}function Yr(){Sn++,D=null,$n?.remove(),$n=null}let _n=null,Zr="intro",gr=0,On=null,ir=null,Vn=null,zn=null,w=null,O=null,Q=null,m=0,k=null,_=null;function W(){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 narrate --mic "+Et(he())+"</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 he=()=>decodeURIComponent(location.pathname.split("/").pop()||"deck.html"),Be=24e3;async function Re(){Vn=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}});let x=window.AudioContext??window.webkitAudioContext;try{ir=new x({sampleRate:Be})}catch{ir=new x}w=ir.createMediaStreamSource(Vn),zn=ir.createScriptProcessor(4096,1,1),zn.onaudioprocess=X=>{let me=X.inputBuffer.getChannelData(0),De=0;for(let Ge=0;Ge<me.length;Ge++){let ne=Math.abs(me[Ge]);ne>De&&(De=ne)}m=Math.max(m,De),O&&O.push(Zf(me))};let q=ir.createGain();q.gain.value=0,w.connect(zn),zn.connect(q),q.connect(ir.destination),ir.state==="suspended"&&await ir.resume(),f("narr",`mic open at ${ir.sampleRate} Hz`)}function ct(){try{zn?.disconnect(),w?.disconnect()}catch{}zn&&(zn.onaudioprocess=null),Vn?.getTracks().forEach(x=>x.stop()),ir?.close?.(),ir=Vn=zn=w=null,O=null,clearInterval(k),k=null}function Oe(){return O=[],m=0,new Promise(x=>{_=x})}function $t(x){if(!_)return;Q=O??[],O=null;let q=_;_=null,q(x)}function Lt(x){let q=Math.min(100,Math.round(x*140));return`<div class="rec-level${x>.95?" hot":""}"><div class="rec-level-fill" style="width:${q}%"></div></div>`}function Ut(x,q={}){Zr=x;let X=_n?.querySelector(".narr-card");if(!X)return;if(x==="intro"){let{slides:qe,beats:nt,why:r}=q;if(r){X.innerHTML=`<div class="narr-head">record your voice</div>
|
|
416
|
+
<div class="rec-line">${r}</div>
|
|
417
|
+
<div class="rec-hint">Esc to close</div>`;return}let{range:o,warn:i}=q;X.innerHTML=`<div class="narr-head">record your voice</div>
|
|
418
|
+
<div class="rec-line">${qe} slide${qe===1?"":"s"} \xB7 ${nt} beat${nt===1?"":"s"} \u2014 the deck reads you the notes, one [click] at a time${o?` <strong>(slides ${Et(o)} only \u2014 everything else is left alone)</strong>`:""}</div>
|
|
419
|
+
${nt===0?`<div class="rec-line rec-warn">Nothing to record${o?` in slides ${Et(o)}`:""} \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>'}
|
|
420
|
+
${ls(q.target)}
|
|
421
|
+
${i?`<div class="rec-line rec-warn">${i}</div>`:""}
|
|
422
|
+
${nt===0?"":'<div class="narr-row narr-sel">Start recording</div>'}
|
|
423
|
+
<div class="rec-hint">${nt===0?"Esc to close":"Enter to start \xB7 Esc to cancel"}</div>`,Qn(X,u=>{On=u}),X.querySelector(".narr-row")?.addEventListener("click",()=>en());return}if(x==="capture"){let{sl:qe,nth:nt,slides:r,beat:o,i,of:u,note:p}=q;X.innerHTML=`<div class="narr-head">recording \xB7 slide ${nt} of ${r}</div>
|
|
424
|
+
<div class="rec-line rec-where">slide ${qe} \xB7 beat ${i+1} of ${u}</div>
|
|
425
|
+
<div class="rec-read">${Et(o.text)}</div>
|
|
426
|
+
${p?`<div class="rec-line rec-note">${p}</div>`:""}
|
|
427
|
+
${Lt(0)}
|
|
428
|
+
<div class="rec-hint"><kbd>\u2192</kbd> next beat \xB7 <kbd>\u232B</kbd> retake this one \xB7 <kbd>Esc</kbd> stop</div>`;return}if(x==="saving"){X.innerHTML=`<div class="narr-head">saving slide ${q.sl}\u2026</div>
|
|
429
|
+
<div class="rec-line">${q.files} file${q.files===1?"":"s"}</div>`;return}let{slides:me,files:De,dir:Ge,segmented:ne,stopped:$e}=q,He=Ge?`saved to <code>${Et(Ge)}/</code>, next to the deck`:`saved to your downloads \u2014 ${fs()}`,it=`narration: { files: '${Et(Ge??"voiceover")}', ext: 'wav'${ne?", segments: true":""} }`;X.innerHTML=`<div class="narr-head">${$e?"recording stopped":"recording done"}</div>
|
|
430
|
+
<div class="rec-line">${me} slide${me===1?"":"s"} \xB7 ${De} file${De===1?"":"s"} ${He}</div>
|
|
431
|
+
<div class="rec-line">Play it back with <code>${it}</code>${ne?" \u2014 <strong>segments</strong> is what makes your voice step the builds.":"."}</div>
|
|
432
|
+
${Xe(Ge)}
|
|
433
|
+
${zr(Ge)}`,cs(X,Ge,{ext:"wav",label:q.label,...ne?{segments:!0}:{}})}async function en(){let x=++gr,q=Rr();if(await j(),x!==gr)return;let X=P(),me=On??is({mine:!0},await os());if(x!==gr)return;let De=X==null?null:{base:X,name:me.dir},Ge=0,ne=0,$e=0,He=!1,it=!1;at&&It();try{await Re()}catch(qe){Ut("intro",{why:im(qe)});return}k=setInterval(()=>{let qe=_n?.querySelector(".rec-level-fill"),nt=_n?.querySelector(".rec-level");qe&&(qe.style.width=`${Math.min(100,Math.round(m*140))}%`,nt.classList.toggle("hot",m>.95),m*=.7)},100);e:for(let qe of q){if(x!==gr)return;let nt=Wc(ae(qe),Pe(qe));if(!nt.length)continue;let r=nt.length===1&&Pe(qe)>0?`this slide has ${Pe(qe)} build${Pe(qe)===1?"":"s"} but no [click] in its notes \u2014 one take for the whole slide; add [click] between the beats to pace them`:null,o=[];for(let p=0;p<nt.length;p++){let v=nt[p];b.goto(qe,v.step),Ut("capture",{sl:qe,nth:Ge+1,slides:q.length,beat:v,i:p,of:nt.length,note:r});let C=await Oe();if(x!==gr)return;if(C==="stop"){it=!0;break e}if(C==="retake"){p--;continue}o.push({file:v.file,pcm:Q})}if(!o.length)continue;Ut("saving",{sl:qe,files:o.length+1});let i=ir?.sampleRate??Be,u=o.flatMap(p=>p.pcm);if(await Ir(qe,"wav",gi(u,i),De)&&$e++,ne++,x!==gr)return;for(let p of o)if(p.file!=null){if(await Ir(qe,"wav",gi(p.pcm,i),De,p.file),x!==gr)return;ne++,He=!0}Ge++}ct(),x===gr&&Ut("done",{slides:Ge,files:ne,dir:$e?De.name:null,segmented:He,stopped:it,label:me.label})}function _t(){if(_n)return;_n=document.createElement("div"),_n.className="decklight-narr decklight-record decklight-mic",_n.innerHTML='<div class="narr-card" role="dialog" aria-label="Record your voice"></div>',Qt(_n,kt),e.appendChild(_n);let x=W(),q=Rr(),X=q.reduce((De,Ge)=>De+Wc(ae(Ge),Pe(Ge)).length,0),me=Tn;On=null,Ut("intro",x?{why:x}:{slides:q.length,beats:X,range:me}),!x&&j().then(()=>os()).then(De=>{!_n||Zr!=="intro"||(On=P()==null?null:is({mine:!0},De),Ut("intro",{slides:q.length,beats:X,range:me,target:On,warn:P()==null?fs():null}))})}function kt(){gr++,$t("stop"),ct(),_n?.remove(),_n=null}return g.register({isOpen:()=>!!_n,close:kt,keydown(x){if(Zr==="capture"){if(x.key==="ArrowRight"||x.key==="Enter"||x.key===" "||x.key==="PageDown")$t("next");else if(x.key==="Backspace")$t("retake");else if(x.key==="Escape")kt();else return!1;return!0}if(x.key==="Escape")kt();else if(x.key==="Enter")Zr==="intro"&&!W()&&_n?.querySelector(".narr-row")?en():Wn(_n)?Wn(_n).click():Zr!=="saving"&&kt();else return!1;return!0}}),g.register({isOpen:()=>!!$n,close:Yr,keydown(x){if(x.key==="Escape")Yr();else if(x.key==="Enter")jr==="confirm"?kr():Wn($n)?Wn($n).click():jr!=="progress"&&Yr();else return!1;return!0}}),g.register({isOpen:()=>!!ln,close:Xn,keydown(x){if(cn==="custom")return x.key==="Enter"?(Vr(),!0):x.key==="Escape"?(Kn(),!0):!1;switch(x.key){case"ArrowDown":rn(cr+1,{scroll:!0});break;case"ArrowUp":rn(cr-1,{scroll:!0});break;case"Enter":jn();break;case"Escape":Kn();break;case"v":case"V":Xn();break;default:return!1}return!0}}),{character:te,playPause:yt,playDefault(){if(at)return It();ue||(ue=ot[0]??(Te?fe:null)),ue&&It()},toggleNarration:It,toggleNarrPause:Vt,changeNarrRate:H,toggleCaptions:Ur,openPicker:ss,async exportSources(){let[x,q]=await Promise.all([os(),d()]),X=[];for(let Ge of x.filter(ne=>ne.manifest)){let ne=Ge.voice?`${Ge.voice}${Ge.engine?` \xB7 ${Ge.engine}`:""}`:"recorded",$e=`${Ge.stale} slide${Ge.stale===1?"":"s"}`,He=Ge.stale>0?Ge.engine?` \xB7 ${$e} from older notes, re-voiced first`:` \xB7 recorded from older notes on ${$e}`:"";X.push({label:`\u{1F50A} ${ne} \u2014 ${Ge.dir}/${He}`,value:{kind:"recorded",dir:Ge.dir,stale:Ge.stale||0,engine:Ge.engine??null}})}if(q&&Z){let Ge=as(x);X.push({label:`\u26A1 Synthesize \u2014 ${K.voice} \xB7 ${Z} \u2192 ${Ge}/`,value:{kind:"live",engine:Z,model:T,voice:K.voice,style:K.style,dir:Ge}})}X.push({label:"\u{1F507} Silent",value:{kind:"silent"}});let me=Ge=>X.findIndex(ne=>Ge(ne.value)),De=ue?.live?me(Ge=>Ge.kind==="live"):-1;return De<0&&ue?.dir&&(De=me(Ge=>Ge.dir===ue.dir)),De<0&&(De=me(Ge=>Ge.dir==="voiceover")),De<0&&(De=X.length-1),{options:X,index:De}},openRecordDialog:ds,openMicRecorder:_t,applySolo:ur,notesSegs:ae,notesDraftOf:Ze,status:()=>({narrating:at,paused:Mt,rate:M,captionsOn:Rt,track:ue,live:!!ue?.live,voice:K.voice,tone:K.tone,hasTracks:ot.length>0,voiceInPlay:wt(),spend:pe})}}Se();Ae();function am(e,t){let n=[];for(let s=0;s<e;s+=t){let a=[];for(let c=s;c<e&&c<s+t;c++)a.push(c);n.push(a)}return n}function Zc(e,t,n){let s=e.ownerDocument,a=f=>{let g=s.createElement("div");return g.className=f,g},c=f=>{let g=a("print-slot"),b=a("decklight-stage print-slide");return b.appendChild(f),g.appendChild(b),g};if(n==="handout")for(let f of am(t.length,3)){let g=a("print-page print-handout");for(let b of f){let y=a("print-row");y.appendChild(c(t[b])),y.appendChild(a("print-notelines")),g.appendChild(y)}e.appendChild(g)}else t.forEach(f=>{let g=a("print-page print-notes-page"),b=a("print-notes"),y=f.querySelector("aside.notes");y&&(b.innerHTML=y.innerHTML),g.appendChild(c(f)),g.appendChild(b),e.appendChild(g)});let h=s.createElement("style");h.textContent="@media print { @page { size: 816px 1056px; margin: 0; } html, body { margin: 0; padding: 0; } }",s.head.appendChild(h)}Se();Ae();Se();Ae();function lm(e,t,n,s){let a=s||1;return{x:(e-n.left)/a,y:(t-n.top)/a}}function cm(e,t,n=300){return e.filter(s=>t-s.t<n)}function Xc(e,t){let n=t.querySelector(":scope > .decklight-stage"),s=null,a=null,c=null,h=[],f=null,g=[],b=null,y=0,$=()=>getComputedStyle(t).getPropertyValue("--accent").trim()||"#fff",S=ee=>lm(ee.clientX,ee.clientY,n.getBoundingClientRect(),e._scale);function A(){if(!a)return;let ee=window.devicePixelRatio||1,re=t.getBoundingClientRect(),le=n.getBoundingClientRect(),ie=e._scale||1;a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,s.width,s.height),a.setTransform(ee*ie,0,0,ee*ie,(le.left-re.left)*ee,(le.top-re.top)*ee),a.lineCap=a.lineJoin="round",a.lineWidth=3.5;for(let I of f?[...h,f]:h)if(I.points.length){a.strokeStyle=I.color,a.beginPath(),a.moveTo(I.points[0].x,I.points[0].y);for(let ce of I.points)a.lineTo(ce.x,ce.y);a.stroke()}if(c==="laser"&&b){let I=$(),ce=performance.now();a.fillStyle=I;for(let de of g){let Ie=1-(ce-de.t)/300;a.globalAlpha=Ie*.4,a.beginPath(),a.arc(de.x,de.y,3+4*Ie,0,Math.PI*2),a.fill()}a.globalAlpha=1,a.shadowColor=I,a.shadowBlur=22,a.beginPath(),a.arc(b.x,b.y,7,0,Math.PI*2),a.fill(),a.shadowBlur=0}}function E(){y=0,g=cm(g,performance.now()),A(),g.length&&(y=requestAnimationFrame(E))}let L=()=>{y||(y=requestAnimationFrame(E))};function P(ee){if(!(c!=="pen"||ee.button>0)){try{s.setPointerCapture(ee.pointerId)}catch{}f={color:$(),points:[S(ee)]},A(),ee.preventDefault()}}function j(ee){c==="pen"&&f?(f.points.push(S(ee)),A()):c==="laser"&&(b=S(ee),g.push({...b,t:performance.now()}),L())}function U(){f&&(h.push(f),f=null)}function oe(){let ee=t.getBoundingClientRect(),re=window.devicePixelRatio||1;s.width=Math.max(1,Math.round(ee.width*re)),s.height=Math.max(1,Math.round(ee.height*re)),A()}function pe(){s||(s=document.createElement("canvas"),s.className="decklight-annotate",s.setAttribute("aria-hidden","true"),t.appendChild(s),a=s.getContext("2d"),s.addEventListener("pointerdown",P),s.addEventListener("pointermove",j),s.addEventListener("pointerup",U),s.addEventListener("pointercancel",U),s.addEventListener("touchstart",ee=>ee.stopPropagation(),{passive:!0}),oe(),new ResizeObserver(()=>{oe(),requestAnimationFrame(A)}).observe(t))}function D(ee="pen"){return c=c===ee?null:ee,c&&pe(),s&&(s.classList.toggle("tool-pen",c==="pen"),s.classList.toggle("tool-laser",c==="laser")),f&&(h.push(f),f=null),c!=="laser"&&(g=[],b=null,a&&A()),c}function z(){h=[],f=null,g=[],b=null,a&&A()}function Ce(ee){pe(),h.push({color:$(),points:ee.map(re=>({x:re.x,y:re.y}))}),A()}return e.on("slide",z),{toggle:D,laser:()=>D("laser"),clear:z,stroke:Ce,get tool(){return c},get active(){return c!==null}}}function Qc({root:e,printMode:t,toast:n,debugLog:s,overlays:a,instance:c,narration:h,downloadFromUrl:f,setProgressBar:g}){let b="decklight-clock:"+location.pathname,y=!1;y=Nn(b)==="1";let $=null,S=null,A=null,E=!1,L=V=>String(V).padStart(2,"0");function P(V){let Z=Math.floor(V/1e3),T=Math.floor(Z/3600);return(T?T+":":"")+L(Math.floor(Z/60)%60)+":"+L(Z%60)}function j(){if(!$)return;let V=new Date;$.querySelector(".clk-time").textContent=L(V.getHours())+":"+L(V.getMinutes()),$.querySelector(".clk-elapsed").textContent="+"+P(A==null?0:Date.now()-A)}function U(){$=document.createElement("div"),$.className="decklight-clock",$.innerHTML='<span class="clk-time"></span><span class="clk-elapsed"></span>',e.appendChild($),j(),S=setInterval(j,1e3)}function oe(){y=!y,yn(b,y?"1":"0"),y?U():(clearInterval(S),S=null,$?.remove(),$=null),n(`clock ${y?"on":"off"}`),s("nav",`clock ${y?"on":"off"}`)}c.on("ready",()=>{E=!0});let pe=()=>{!E||A!=null||(A=Date.now(),j())};c.on("slide",pe),c.on("build",pe),c.toggleClock=oe,y&&!t&&U();let D="decklight-progress:"+location.pathname,z=!1;z=Nn(D)==="1";let Ce=null;function ee(){Ce=document.createElement("div"),Ce.className="decklight-progress",Ce.innerHTML='<div class="bar"></div>',e.appendChild(Ce),g(Ce.querySelector(".bar")),c._updateChrome()}function re(){z=!z,yn(D,z?"1":"0"),z?ee():(Ce?.remove(),Ce=null,g(null)),n(`progress bar ${z?"on":"off"}`),s("nav",`progress bar ${z?"on":"off"}`)}c.toggleProgress=re,z&&!t&&ee();let le=null;t||(le=Xc(c,e),c.annotate=le);function ie(V){if(!le)return;let Z=V==="laser"?le.laser():le.toggle();n(Z==="pen"?"pen on \u2014 drag to draw \xB7 \u232B clears \xB7 W off":Z==="laser"?"laser on \u2014 \u21E7W off":"ink off"),s("nav",`ink ${Z??"off"}`)}function I(){return(c._sections||[]).map((V,Z)=>({n:Z+1,title:V.querySelector("h1, h2, h3")?.textContent.trim()||`Slide ${Z+1}`,segs:h.notesSegs(Z+1).filter(Boolean)}))}function ce(V){let Z=(document.title||"Deck").trim(),T=V?[`# ${Z} \u2014 transcript`,""]:[`${Z} \u2014 transcript`,""];for(let{n:F,title:se,segs:_e}of I())if(_e.length){T.push(V?`## ${F}. ${se}`:`${F}. ${se}`,"");for(let Te of _e)T.push(Te,"")}return T.join(`
|
|
434
|
+
`)}function de(V){let Z=V==="md",T=URL.createObjectURL(new Blob([ce(Z)],{type:Z?"text/markdown":"text/plain"})),F=(location.pathname.split("/").pop()||"deck").replace(/\.html?$/i,"");f(T,`${F}-transcript.${Z?"md":"txt"}`),setTimeout(()=>URL.revokeObjectURL(T),5e3),s("narr",`transcript exported (.${Z?"md":"txt"})`)}let Ie=()=>{};return c.transcript={open:()=>Ie(),text:()=>ce(!1),markdown:()=>ce(!0),data:I,download:de,setOpener(V){Ie=V}},{toggleClock:oe,toggleProgress:re,toggleInk:ie,get annotator(){return le},status:()=>({clockOn:y,progressOn:z})}}Se();Ae();var dm=["data-background-image","data-background-video","data-background-poster","data-background-size","data-background-position","data-background-dim"];function um(e){let t=e["data-background-image"]||null,n=e["data-background-video"]||null;if(!t&&!n)return null;let s=parseFloat(e["data-background-dim"]);return{image:t,video:n,poster:e["data-background-poster"]||null,size:e["data-background-size"]==="contain"?"contain":"cover",position:e["data-background-position"]||"center",dim:Number.isFinite(s)?Math.min(Math.max(s,0),1):0}}var pm=e=>`url("${String(e).replace(/["\\]/g,"\\$&")}")`;function hm(e){let t={};for(let n of dm){let s=e.getAttribute(n);s!==null&&(t[n]=s)}return t}function ed(e,{printMode:t=!1}={}){e.forEach(n=>{let s=um(hm(n)),a=n.querySelector(":scope > .slide-bg");if(!s){a?.remove();return}let c=JSON.stringify(s)+(t?"\xB7print":"");if(a&&a.dataset.sig===c){a!==n.firstElementChild&&n.prepend(a);return}a||(a=document.createElement("div"),a.className="slide-bg",a.setAttribute("aria-hidden","true")),a.dataset.sig=c,a.textContent="",a.style.backgroundSize=s.size,a.style.backgroundPosition=s.position;let h=s.image||(t?s.poster:null);if(a.style.backgroundImage=h?pm(h):"",s.video&&!t){let f=document.createElement("video");f.muted=!0,f.loop=!0,f.setAttribute("muted",""),f.setAttribute("loop",""),f.setAttribute("playsinline",""),f.preload="auto",s.poster&&(f.poster=s.poster),f.style.objectFit=s.size,f.style.objectPosition=s.position,f.src=s.video,a.appendChild(f)}if(s.dim>0){let f=document.createElement("div");f.className="slide-bg-dim",f.style.opacity=String(s.dim),a.appendChild(f)}n.prepend(a)})}Se();Ae();Se();Ae();function td({now:e=Date.now,keep:t=200,seed:n=[],first:s=null}={}){let a=e(),c=n.slice(-t).map(g=>({t:String(g.t),kind:String(g.kind),msg:String(g.msg),prev:!0}));s&&c.push({t:0 .toFixed(3),kind:String(s.kind),msg:String(s.msg)}),c.length>t&&c.shift();let h=null;function f(g,b){let y={t:((e()-a)/1e3).toFixed(3),kind:g,msg:b};return c.push(y),c.length>t&&c.shift(),h?.(y),y}return{log:f,get entries(){return c.slice()},onEntry(g){h=g}}}var nd=e=>"decklight-debug:"+e,fm=6e4;function rd(e,t,n,s=null,a=Date.now){e.setItem(nd(t),JSON.stringify({t:a(),reason:s,entries:n.slice(-200)}))}function sd(e,t,n=Date.now){let s=nd(t),a=e.getItem(s);if(a===null)return null;e.removeItem(s);try{let c=JSON.parse(a);return!c||typeof c.t!="number"||n()-c.t>fm||!Array.isArray(c.entries)?null:{reason:typeof c.reason=="string"?c.reason:null,entries:c.entries}}catch{return null}}function od(e,t=null){let n=null;try{n=JSON.parse(e)}catch{}if(!n||typeof n!="object"||typeof n.reload!="string")return"the file changed";let s=typeof n.from=="string"&&n.from?n.from===t?" \xB7 this tab":" \xB7 another tab":"";return n.reload+s}Se();Ae();var co=(e,t,n)=>Math.min(n,Math.max(t,e));function $a(e,t,n){e=(e%360+360)%360,t=co(t,0,100)/100,n=co(n,0,100)/100;let s=n*t,a=s*(1-Math.abs(e/60%2-1)),c=n-s,[h,f,g]=e<60?[s,a,0]:e<120?[a,s,0]:e<180?[0,s,a]:e<240?[0,a,s]:e<300?[a,0,s]:[s,0,a];return{r:Math.round((h+c)*255),g:Math.round((f+c)*255),b:Math.round((g+c)*255)}}function Sa({r:e,g:t,b:n}){e/=255,t/=255,n/=255;let s=Math.max(e,t,n),a=Math.min(e,t,n),c=s-a,h=0;return c&&(h=s===e?(t-n)/c%6:s===t?(n-e)/c+2:(e-t)/c+4,h=(h*60+360)%360),{h:Math.round(h)%360,s:Math.round(s?c/s*100:0),v:Math.round(s*100)}}function yr({r:e,g:t,b:n}){return"#"+[e,t,n].map(s=>co(Math.round(s),0,255).toString(16).padStart(2,"0")).join("")}function Aa(e){let t=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(String(e??"").trim());if(!t)return null;let n=t[1].length===3?[...t[1]].map(s=>s+s).join(""):t[1];return{r:parseInt(n.slice(0,2),16),g:parseInt(n.slice(2,4),16),b:parseInt(n.slice(4,6),16)}}var cd=[{group:"Theme",items:[{label:"Primary",token:"--accent"},{label:"Secondary",token:"--link",unlessSameAs:"--accent"},{label:"On primary",token:"--accent-contrast"},{label:"Heading",token:"--heading-color"},{label:"Text",token:"--fg"},{label:"Muted",token:"--muted"},{label:"Background",token:"--bg"},{label:"Background alt",token:"--bg-accent"},{label:"Block",token:"--block-bg"}]},{group:"Diagram fills",compact:!0,items:[1,2,3,4,5,6].map(e=>({label:`Fill ${e}`,short:String(e),token:`--d-fill-${e}`}))},{group:"Diagram ink",items:[{label:"Diagram accent",token:"--d-accent"},{label:"Diagram text",token:"--d-text"},{label:"Diagram muted",token:"--d-muted"},{label:"Diagram stroke",token:"--d-stroke"}]}];function dd(e,t){let n=new Map(cd.flatMap(a=>a.items.map(c=>[c.token,c.label]))),s=new Map;for(let a of e??[]){let c=(a?.themes??[]).find(h=>h.name===t);for(let[h,f]of Object.entries(c?.refs??{})){let g=n.get(h);if(g)for(let b of String(f).split(" \u2192 ")){let y=b.replace(/\/\d+$/,"");s.has(y)||s.set(y,[]),s.get(y).includes(g)||s.get(y).push(g)}}}return s}function ud(e,t=null){let n=[];for(let s of e??[]){let a=(s?.themes??[]).find(c=>c.name===t);for(let c of Array.isArray(s?.roles)?s.roles:[]){let h=a?.roles?.[c.id],f=us(h);f&&_o.test(String(c.token))&&n.push({ref:c.label||c.id,token:c.token,hex:yr(f),lab:so([f.r,f.g,f.b]),role:!0})}}if(n.length){let s=new Set(n.map(f=>f.token)),a=id(n),c=new Map;for(let f of e??[])for(let[g,b]of Object.entries(f?.contract??{})){let y=n.find($=>$.token===(f.roles??[]).find(S=>S.id===b)?.token);y&&!c.has(g)&&c.set(g,y)}let h=f=>{let g=/^var\(\s*(--[a-z][a-z0-9-]*)\s*(?:,\s*([^()]*))?\)$/i.exec(String(f??"").trim());if(!g)return a(f);if(s.has(g[1]))return null;let b=c.get(g[1]);if(b)return{ref:b.ref,value:`var(${b.token}, ${b.hex})`,role:!0};let y=typeof document<"u"?document.querySelector(".decklight")??document.documentElement:null,$=y?getComputedStyle(y).getPropertyValue(g[1]).trim():"";return a($||g[2])};return h.roles=!0,h}for(let s of e??[])if(s?.scales)for(let a of s.palette??[]){let c=Aa(a?.hex);c&&_o.test(String(a.token))&&n.push({ref:a.ref??a.token,token:a.token,hex:a.hex,lab:so([c.r,c.g,c.b])})}return n.length?id(n):null}function id(e){return t=>{let n=us(t);if(!n)return null;let s=so([n.r,n.g,n.b]),a=null,c=1/0;for(let h of e){let f=Math.hypot(s[0]-h.lab[0],s[1]-h.lab[1],s[2]-h.lab[2]);f<c&&(c=f,a=h)}return{ref:a.ref,value:`var(${a.token}, ${a.hex})`,role:!!a.role}}}function mm(e,t,n){let s=c=>String(c??"").trim().toLowerCase(),a=[];for(let c of e??[]){let h=Array.isArray(c?.roles)?c.roles:[];if(!h.length)continue;let f=String(c.title||c.name||"Design system"),g=(c.themes??[]).find(y=>y.name===n)??null,b=new Map;for(let y of h){if(!y||!_o.test(String(y.token)))continue;let $=s(t(y.token))||s(g?.roles?.[y.id]);if(!$)continue;let S=String(y.group||"Roles");b.has(S)||b.set(S,[]),b.get(S).push({label:y.label||y.id,token:y.token,value:$,role:y.id})}for(let[y,$]of b)a.push({group:`${f} \xB7 ${y}`,system:c.name,fallback:!0,roles:!0,items:$})}return a}function gm(e){let t=n=>String(n??"").trim().toLowerCase();return cd.map(n=>({...n,items:n.items.map(s=>({...s,value:t(e(s.token))})).filter(s=>s.value&&!(s.unlessSameAs&&s.value===t(e(s.unlessSameAs))))})).filter(n=>n.items.length)}var _o=/^--[a-z][a-z0-9-]{0,40}$/i;function bm(e,t,{roles:n=null}={}){let s=c=>String(c??"").trim().toLowerCase(),a=[];for(let c of e??[]){if(c?.scales){let y=String(c.title||c.name||"Design system"),$=new Map;for(let S of Array.isArray(c.palette)?c.palette:[]){if(!S||!_o.test(String(S.token)))continue;let A=s(t(S.token))||s(S.hex);A&&($.has(S.group)||$.set(S.group,[]),$.get(S.group).push({label:S.label,short:S.short,token:S.token,value:A,derived:!!S.derived,roles:n?.get(S.ref)??[]}))}for(let[S,A]of $)a.push({group:`${y} \xB7 ${S}`,system:c.name,fallback:!0,compact:!0,scale:!0,items:A});continue}let h=(Array.isArray(c?.palette)?c.palette:[]).filter(y=>y&&typeof y.label=="string"&&_o.test(String(y.token))),f=String(c.title||c.name||"Design system"),g=new Set(h.map(y=>String(y.group??"").trim())),b=new Map;for(let y of h){let $=s(t(y.token));if(!$)continue;let S=String(y.group??"").trim();b.has(S)||b.set(S,[]),b.get(S).push({label:y.label,token:y.token,value:$})}for(let[y,$]of b)a.push({group:g.size>1&&y?`${f} \xB7 ${y}`:f,system:c.name,fallback:!0,items:$})}return a}function ym(e){return/^var\(\s*(--[a-z][a-z0-9-]*)\s*(?:,[^()]*)?\)$/i.exec(String(e??"").trim())?.[1]??null}function wm(e,t){return t?`var(${e}, ${yr(t)})`:`var(${e})`}var No="rect, circle, ellipse, polygon, path",Ca=".draw-head, .draw-mask",ad=".draw-head, .draw-mask, [data-ds-injected]";function zs(e,t){let n=[];for(let s=t;s!==e;s=s.parentElement){let a=s?.parentElement;if(!a||s.matches(ad))return null;n.unshift([...a.children].filter(c=>!c.matches(ad)).indexOf(s))}return n}function uo(e,t){let n=t.closest?.("svg");if(!n||!e.contains(n)||t===n)return null;let s=t.closest(No);if(!s){let g=t.closest("text")?.parentElement;s=g&&g!==n?[...g.children].find(b=>b.matches(No))??null:null}if(!s||s.closest(Ca+", defs"))return null;let a=s.closest("[data-concept]"),c=a&&n.contains(a)&&a!==n?a:s,h=zs(e,c);return h?{name:c.getAttribute("data-concept")||null,el:c,path:h,tag:c.tagName.toLowerCase()}:null}function ld(e,t){let n=e.getBoundingClientRect(),s=t.getBoundingClientRect(),a=s.left+s.width/2,c=s.top+s.height/2;return a>=n.left&&a<=n.right&&c>=n.top&&c<=n.bottom}function Oo(e,t){let n=(g,b)=>{let y=zs(e,g);return y?{el:g,path:y,tag:g.tagName.toLowerCase(),prop:b}:null},s=t.closest?.("svg");if(s&&e.contains(s)&&t!==s){let g=t.closest(No),b=t.closest("text"),y=P=>getComputedStyle(P).fill!=="none";if(!g&&b){let P=b.parentElement,j=P!==s?[...P.children].filter(pe=>pe.matches(No)):[],U=[...s.querySelectorAll(No)].filter(pe=>!pe.closest(Ca+", defs")&&y(pe)&&ld(pe,b)),oe=pe=>{let D=pe.getBoundingClientRect();return D.width*D.height};g=j.find(y)??U.sort((pe,D)=>oe(pe)-oe(D))[0]??null}g?.closest(Ca+", defs")&&(g=null);let $=[];if(g){let P=g.parentElement;$=P!==s&&P.tagName.toLowerCase()==="g"?[...P.children].filter(j=>j.tagName.toLowerCase()==="text"):[...s.querySelectorAll("text")].filter(j=>ld(g,j))}else b&&($=[b]);let S=g?[n(g,"fill")].filter(Boolean):[],A=g?[n(g,"stroke")].filter(Boolean):[],E=$.map(P=>n(P,"fill")).filter(Boolean),L=g?uo(e,g):null;return S.length||E.length?{fill:S,stroke:A,text:E,what:g?g.tagName.toLowerCase():"text",concept:L?.name?L:null,conceptAt:L}:null}let a=t.closest("pre")??t;for(;a!==e&&e.contains(a)&&getComputedStyle(a).display.startsWith("inline");)a=a.parentElement;e.contains(a)||(a=e);let c=[n(a,"background-color")].filter(Boolean),h=[n(a,"border-color")].filter(Boolean),f=[n(a,"color")].filter(Boolean);return c.length?{fill:c,stroke:h,text:f,what:a.tagName.toLowerCase()}:null}var _s=null;function us(e){if(!e||e==="none"||e==="transparent")return null;try{_s??=document.createElement("canvas").getContext("2d",{willReadFrequently:!0}),_s.canvas.width=_s.canvas.height=1,_s.clearRect(0,0,1,1),_s.fillStyle="#000",_s.fillStyle=e,_s.fillRect(0,0,1,1);let[t,n,s,a]=_s.getImageData(0,0,1,1).data;return a?{r:t,g:n,b:s}:null}catch{return null}}var Bt=(e,t,n)=>{let s=document.createElement(e);return t&&(s.className=t),n!==void 0&&(s.textContent=n),s},vm=[[2,10],[4,12],[6,14]].map(([e,t])=>{let n=(s,a,c)=>`<line x1="${a}" y1="${s}" x2="${c}" y2="${s}"/>`;return'<svg class="cp-seg-icon" viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true">'+n(4,2,14)+n(8,e,t)+n(12,2,14)+"</svg>"});function pd({root:e,targets:t,systems:n=[],side:s="fill",save:a,onDetach:c,concepts:h=null,brand:f=null,onError:g=()=>{},onEscape:b=()=>{}}){t.stroke??=[];let y=(H,te)=>[H.style.getPropertyValue(te),H.style.getPropertyPriority(te)],$=H=>H.prop==="stroke"?"stroke-width":"border-width",S=H=>H.el instanceof SVGElement,A=H=>S(H)?"text-anchor":"text-align",E=["font-size","font-weight","font-family","font-style","align"],L=(H,te)=>te==="align"?A(H):te,P=new Map,j=(H,te)=>`${t.text.includes(H)?"x":"s"}${[...t.fill,...t.stroke,...t.text].indexOf(H)}|${te}`,U=(H,te)=>{let we=j(H,te);P.has(we)||P.set(we,y(H.el,te))},oe={fill:void 0,stroke:void 0,text:void 0,width:void 0},pe={},D=t.fill.length?"fill":t.stroke.length?"stroke":"text",z=s==="type"?"type":t[s]?.length?s:D,Ce=z==="type"?D:z,ee="theme",re="rgb",le={r:128,g:128,b:128},ie=Sa(le),I=Promise.resolve(),ce=Bt("div","decklight-colorpicker cp-embedded"),de=Bt("div","cp-main");ce.appendChild(de);let Ie=H=>t[H][0]?.el.style.getPropertyValue(t[H][0].prop).trim()??"",V=H=>({"background-color":"backgroundColor","border-color":"borderColor"})[H]??H,Z=H=>{let te=t[H]?.[0];return te?us(getComputedStyle(te.el)[V(te.prop)]):null},T=()=>{if(oe.width!==void 0&&oe.width!==null)return oe.width;let H=t.stroke[0],te=H?parseFloat(getComputedStyle(H.el)[V($(H))==="border-width"?"borderWidth":"strokeWidth"]):NaN;return Number.isFinite(te)?String(te):"1"};function F(H,te,we){for(let Ee of H){let Ke=te??Ee.prop;U(Ee,Ke),we===null?Ee.el.style.removeProperty(Ke):Ee.el.style.setProperty(Ke,we)}}function se(H){if(!H.length)return I;let te=H.map(we=>({path:we.t.path,tag:we.t.tag,prop:we.prop,value:we.value}));return I=I.then(()=>a(te)).then(()=>{for(let we of H)P.set(j(we.t,we.prop),y(we.t.el,we.prop))},we=>{for(let Ee of H){let[Ke,ae]=P.get(j(Ee.t,Ee.prop))??["",""];Ke?Ee.t.el.style.setProperty(Ee.prop,Ke,ae):Ee.t.el.style.removeProperty(Ee.prop)}g(String(we?.message||we)),M()}),I}let _e=(H,te)=>t[H].map(we=>({t:we,prop:we.prop,value:te})),Te=(H,te)=>te===null?null:`${te}${H.prop==="stroke"?"":"px"}`;function l(H){oe[z]=H,F(t[z],null,H),M(),se(_e(z,H))}function d(){let H=Z(z);H&&(le=H,ie=Sa(H))}function G(H,te,we,Ee,Ke){let ae=Bt("div","cp-seg "+H);ae.setAttribute("role","tablist"),ae.setAttribute("aria-label",te);for(let Ze of we){let bt=Bt("button","cp-seg-btn",Ze.label);if(bt.type="button",Ze.chip!==void 0){let Pe=Bt("span",`cp-seg-chip cp-seg-${Ze.id}`);Pe.style.setProperty("--chip",Ze.chip??"transparent"),Ze.chip||Pe.classList.add("cp-seg-none"),bt.prepend(Pe)}else Ze.icon&&bt.insertAdjacentHTML("afterbegin",Ze.icon);Ze.style&&Object.assign(bt.style,Ze.style),bt.setAttribute("role","tab"),bt.setAttribute("aria-selected",String(Ze.id===Ee)),bt.dataset.id=Ze.id,bt.disabled=!!Ze.disabled,Ze.title&&(bt.title=Ze.title),bt.addEventListener("click",()=>Ke(Ze.id)),ae.appendChild(bt)}return ae}function be(H){let te=getComputedStyle(e),we=oe[z]===void 0?Ie(z):oe[z],Ee=bt=>te.getPropertyValue(bt),Ke=ym(we),ae=f?.locked?mm(n,Ee,f.theme):[],Ze=ae.length?ae:[...gm(Ee),...bm(n,Ee,{roles:f?.roles??null})];for(let bt of Ze){let Pe=Bt("div",bt.scale?"cp-groupbox cp-scalebox":"cp-groupbox");Pe.appendChild(Bt("div","cp-group",bt.group));let ke=Bt("div",bt.scale?"cp-swatches cp-compact cp-scale":bt.compact?"cp-swatches cp-compact":"cp-swatches");for(let Fe of bt.items){let Ve=Bt("button","cp-swatch");Ve.type="button",Ve.dataset.token=Fe.token,Fe.roles?.length&&(Ve.classList.add("cp-has-role"),Ve.dataset.roles=Fe.roles.join(", ")),Fe.derived&&Ve.classList.add("cp-derived"),Ve.title=`${Fe.label} \xB7 ${Fe.token} \xB7 ${Fe.value}${Fe.roles?.length?` \xB7 the theme's ${Fe.roles.join(", ")}`:""}${Fe.derived?" \xB7 derived (not in the brand's palette as written)":""}`,Ve.setAttribute("aria-label",`${Fe.label} (${Fe.token})`),Ve.setAttribute("aria-pressed",String(Ke===Fe.token));let et=Bt("span","cp-chip");et.style.background=`var(${Fe.token})`,Ve.append(et,Bt("span","cp-label",bt.compact?Fe.short:Fe.label)),Ve.addEventListener("click",()=>l(bt.fallback?wm(Fe.token,us(Fe.value)):`var(${Fe.token})`)),ke.appendChild(Ve)}Pe.appendChild(ke),H.appendChild(Pe)}}function J(H){le=H;let te=Sa(H);ie=te.s?te:{...te,h:ie.h}}function Qe(H,te){re==="rgb"?J({...le,[H]:te}):(ie={...ie,[H]:te},le=$a(ie.h,ie.s,ie.v))}function ot(H){let te=Ee=>[0,.16666666666666666,.3333333333333333,.5,.6666666666666666,.8333333333333334,1].map(Ee).join(", ");if(re==="rgb"){let Ee=Ke=>yr({...le,[H]:Ke});return`linear-gradient(to right, ${Ee(0)}, ${Ee(255)})`}if(H==="h")return`linear-gradient(to right, ${te(Ee=>yr($a(Ee*360,100,100)))})`;let we=Ee=>yr($a(ie.h,H==="s"?Ee:ie.s,H==="v"?Ee:ie.v));return`linear-gradient(to right, ${we(0)}, ${we(100)})`}let fe=()=>ce.querySelectorAll(".cp-range[data-chan]").forEach(H=>{/^[rgbhsv]$/.test(H.dataset.chan)&&H.style.setProperty("--track",ot(H.dataset.chan))});function K(H){H.appendChild(G("cp-model","Color model",[{id:"rgb",label:"RGB"},{id:"hsb",label:"HSB"}],re,Ze=>{re=Ze,M()}));let te=re==="rgb"?[["R","r",255],["G","g",255],["B","b",255]]:[["H","h",360],["S","s",100],["B","v",100]],we=re==="rgb"?le:ie;for(let[Ze,bt,Pe]of te){let ke=Bt("label","cp-chan");ke.appendChild(Bt("span","cp-chan-name",Ze));let Fe=Bt("input","cp-range cp-tracked");Fe.type="range",Fe.style.setProperty("--track",ot(bt));let Ve=Bt("input","cp-num");Ve.type="number";for(let et of[Fe,Ve])et.min="0",et.max=String(Pe),et.step="1",et.value=String(we[bt]),et.dataset.chan=bt;Fe.setAttribute("aria-label",Ze),Ve.setAttribute("aria-label",`${Ze} value`),Fe.addEventListener("input",()=>{Ve.value=Fe.value,Qe(bt,Number(Fe.value)),oe[z]=yr(le),F(t[z],null,oe[z]),ce.querySelector(".cp-hex").value=oe[z],ce.querySelector(".cp-now").style.background=oe[z],fe()}),Fe.addEventListener("change",()=>l(yr(le))),Ve.addEventListener("change",()=>{Qe(bt,co(Math.round(Number(Ve.value)||0),0,Pe)),l(yr(le))}),ke.append(Fe,Ve),H.appendChild(ke)}let Ee=Bt("label","cp-chan cp-hexrow");Ee.appendChild(Bt("span","cp-chan-name","Hex"));let Ke=Bt("span","cp-now");Ke.style.background=yr(le);let ae=Bt("input","cp-hex");ae.type="text",ae.spellcheck=!1,ae.maxLength=7,ae.value=yr(le),ae.setAttribute("aria-label","Hex color"),ae.addEventListener("change",()=>{let Ze=Aa(ae.value);if(!Ze){ae.value=yr(le);return}J(Ze),l(yr(le))}),Ee.append(Ke,ae),H.appendChild(Ee)}function ue(H){let te=Bt("label","cp-chan cp-widthrow");te.appendChild(Bt("span","cp-chan-name","Width"));let we=Bt("input","cp-range cp-width");we.type="range";let Ee=Bt("input","cp-num cp-width");Ee.type="number";for(let Ze of[we,Ee])Ze.min="0",Ze.max="24",Ze.step="0.5",Ze.value=T(),Ze.dataset.chan="w";we.setAttribute("aria-label","Stroke width"),Ee.setAttribute("aria-label","Stroke width value");let Ke=Ze=>{oe.width=String(co(Math.round(Number(Ze)*2)/2||0,0,24));for(let bt of t.stroke)F([bt],$(bt),Te(bt,oe.width));we.value=Ee.value=oe.width},ae=Ze=>{Ke(Ze),se(t.stroke.map(bt=>({t:bt,prop:$(bt),value:Te(bt,oe.width)})))};we.addEventListener("input",()=>Ke(we.value)),we.addEventListener("change",()=>ae(we.value)),Ee.addEventListener("change",()=>ae(Ee.value)),te.append(we,Ee),H.appendChild(te)}function at(H){let te=t.text[0];if(!te){H.appendChild(Bt("div","cp-notice","nothing here carries text: pick a label, or a block of text"));return}let we=getComputedStyle(te.el),Ee=(Ue,Dt)=>t.text.map(Ct=>({t:Ct,prop:L(Ct,Ue),value:Dt})),Ke=(Ue,Dt)=>{pe[Ue]=Dt;for(let Ct of t.text)F([Ct],L(Ct,Ue),Dt)},ae=(Ue,Dt)=>{Ke(Ue,Dt),M(),se(Ee(Ue,Dt))},Ze=(Ue,...Dt)=>{let Ct=Bt("div","cp-chan cp-typerow");Ct.append(Bt("span","cp-chan-name",Ue),...Dt),H.appendChild(Ct)},bt=String(Math.round(parseFloat(pe["font-size"]??we.fontSize)||16)),Pe=Bt("input","cp-range cp-size");Pe.type="range";let ke=Bt("input","cp-num cp-size");ke.type="number";for(let Ue of[Pe,ke])Ue.min="8",Ue.max="160",Ue.step="1",Ue.value=bt,Ue.dataset.chan="size";Pe.setAttribute("aria-label","Text size"),ke.setAttribute("aria-label","Text size value");let Fe=Ue=>{let Dt=co(Math.round(Number(Ue))||16,8,160);Ke("font-size",`${Dt}px`),Pe.value=ke.value=String(Dt)},Ve=Ue=>{Fe(Ue),se(Ee("font-size",pe["font-size"]))};Pe.addEventListener("input",()=>Fe(Pe.value)),Pe.addEventListener("change",()=>Ve(Pe.value)),ke.addEventListener("change",()=>Ve(ke.value)),Ze("Size",Pe,ke,Bt("span","cp-unit","px"));let et=String(pe["font-weight"]??Math.round((Number(we.fontWeight)||400)/100)*100);Ze("Weight",G("cp-weight","Weight",[{id:"400",label:"Regular",title:"400"},{id:"500",label:"Medium",title:"500"},{id:"600",label:"Semi",title:"semibold \xB7 600"},{id:"700",label:"Bold",title:"700"},{id:"800",label:"Heavy",title:"800"}].map(Ue=>({...Ue,style:{fontWeight:Ue.id}})),et,Ue=>ae("font-weight",Ue)));let Y=getComputedStyle(e),ve=Ue=>String(Ue).replace(/["']/g,"").replace(/\s*,\s*/g,",").trim().toLowerCase(),Ne=(pe["font-family"]??te.el.style.getPropertyValue("font-family")).match(/--font-(heading|body|mono)/)?.[1]??["heading","body","mono"].find(Ue=>Y.getPropertyValue(`--font-${Ue}`).trim()&&ve(Y.getPropertyValue(`--font-${Ue}`))===ve(we.fontFamily));Ze("Font",G("cp-family","Font",["heading","body","mono"].map(Ue=>({id:Ue,label:Ue[0].toUpperCase()+Ue.slice(1),title:`the theme's ${Ue} font \xB7 var(--font-${Ue})`,disabled:!Y.getPropertyValue(`--font-${Ue}`).trim(),style:{fontFamily:`var(--font-${Ue}), inherit`}})),Ne,Ue=>ae("font-family",`var(--font-${Ue})`)));let ut=(pe["font-style"]??we.fontStyle)==="italic",ht=Bt("button","cp-btn cp-italic","Italic");ht.type="button",ht.setAttribute("aria-pressed",String(ut)),ht.addEventListener("click",()=>ae("font-style",ut?"normal":"italic"));let vt=(S(te)?[{id:"start",label:"Start"},{id:"middle",label:"Middle"},{id:"end",label:"End"}]:[{id:"left",label:"Left"},{id:"center",label:"Center"},{id:"right",label:"Right"}]).map((Ue,Dt)=>({...Ue,icon:vm[Dt]})),mt=pe.align??(S(te)?we.textAnchor:{start:"left",end:"right",justify:"left"}[we.textAlign]??we.textAlign);Ze("Align",G("cp-align","Align",vt,mt,Ue=>ae("align",Ue)),ht)}function N(H){if(!h||!t.conceptAt)return;let te=t.conceptAt.name,we=Bt("div","cp-concept-row");we.append(Bt("span","cp-label cp-section","Concept"));let Ee=Bt("div","cp-concepts"),Ke=(Ze,bt,Pe,ke,Fe=null)=>{let Ve=Bt("button","cp-btn cp-concept-chip"+(Pe?" cp-on":""),Ze);if(Ve.type="button",Fe){let et=Bt("span","cp-concept-dot");et.style.background=Fe,Ve.prepend(et)}return Ve.setAttribute("aria-pressed",String(Pe)),Ve.title=ke,Ve.addEventListener("click",()=>h.set(bt)),Ve};for(let Ze of h.names())Ee.append(Ke(Ze,Ze===te?null:Ze,Ze===te,Ze===te?`this shape is \u201C${Ze}\u201D: click to take it off`:`make this shape the \u201C${Ze}\u201D concept: one colour for the idea, on every slide`,h.fill?.(Ze)));let ae=Bt("button","cp-btn cp-concept-chip cp-new","+ new");ae.type="button",ae.title="name a new concept and put this shape in it",ae.addEventListener("click",()=>{let Ze=Bt("input","cp-hex cp-concept-name");Ze.type="text",Ze.placeholder="agent, tools\u2026",Ze.spellcheck=!1,Ze.setAttribute("aria-label","New concept name"),Ze.addEventListener("keydown",bt=>{if(bt.stopPropagation(),bt.key==="Enter"){bt.preventDefault();let Pe=Ze.value.trim();Pe&&h.set(Pe)}else bt.key==="Escape"&&(bt.preventDefault(),M())}),ae.replaceWith(Ze),Ze.focus()}),Ee.append(ae),te&&Ee.append(Object.assign(Ke("none",null,!1,`take \u201C${te}\u201D off this shape, then colour it by hand`),{className:"cp-btn cp-concept-chip cp-none"})),we.append(Ee),H.appendChild(we)}function ft(H){let te=Bt("div","cp-notice cp-callout"),we=Bt("div","cp-callout-head"),Ee=Bt("span","cp-callout-chip");Ee.style.background=h?.fill?.(t.concept.name)??Cs(t.concept.name),we.append(Ee,Bt("span","cp-callout-title",`Filled by the \u201C${t.concept.name}\u201D concept`)),te.append(we,Bt("span","cp-notice-text","The deck colours every shape in it, so a fill picked here would be painted over on the next load. Pin its colour in / \u2192 Concept colors\u2026, or take this shape out of it."));let Ke=Bt("button","cp-btn cp-detach","Detach from concept");Ke.type="button",Ke.title=`take data-concept="${t.concept.name}" off this ${t.concept.tag}, then colour it by hand`,Ke.addEventListener("click",()=>c?.(t.concept)),te.appendChild(Ke),H.appendChild(te)}function M(){let H=document.activeElement?.dataset?.chan&&ce.contains(document.activeElement)?[document.activeElement.className,document.activeElement.dataset.chan]:null;if(de.textContent="",z==="type"){let Ee=Bt("div","cp-body cp-type");at(Ee),de.appendChild(Ee)}else{let Ee=ae=>{let Ze=t[ae].length?Z(ae):null;return Ze?yr(Ze):null};de.appendChild(G("cp-side","What to color",[{id:"fill",label:"Fill",chip:Ee("fill"),disabled:!t.fill.length,title:t.fill.length?"the shape\u2019s background":"nothing here has a background to color"},{id:"stroke",label:"Stroke",chip:Ee("stroke"),disabled:!t.stroke.length,title:t.stroke.length?"the shape\u2019s border, and how wide it is":"nothing here has a border"},{id:"text",label:"Text",chip:Ee("text"),disabled:!t.text.length,title:t.text.length?"the text on it":"this shape carries no text"}],z,ae=>{z=Ce=ae,oe[z]===void 0||oe[z]===null||oe[z].startsWith("var(")?d():J(Aa(oe[z])),M()})),z==="stroke"&&ue(de),z==="fill"&&N(de),f?.locked&&ee==="custom"&&(ee="theme"),f?.locked||de.appendChild(G("cp-tabs","Color source",[{id:"theme",label:"Theme"},{id:"custom",label:"Custom"}],ee,ae=>{ee=ae,ee==="custom"&&(oe[z]===void 0||oe[z]===null||oe[z].startsWith("var("))&&d(),M()}));let Ke=Bt("div","cp-body");Ke.dataset.tab=ee,z==="fill"&&t.concept?ft(Ke):(ee==="theme"?be:K)(Ke),de.appendChild(Ke)}let te=Bt("div","cp-foot"),we=Bt("button","cp-btn cp-reset","Reset");we.type="button",we.title=z==="type"?"take the type set here off \u2014 back to what the theme or the markup gives it":"take the colour set here off \u2014 back to what the theme or the markup gives it",we.addEventListener("click",()=>{let Ee=[];if(z==="type")for(let Ke of E){pe[Ke]=null;for(let ae of t.text)F([ae],L(ae,Ke),null),Ee.push({t:ae,prop:L(ae,Ke),value:null})}else if(oe[z]=null,F(t[z],null,null),Ee.push(..._e(z,null)),z==="stroke"){oe.width=null;for(let Ke of t.stroke)F([Ke],$(Ke),null),Ee.push({t:Ke,prop:$(Ke),value:null})}M(),se(Ee)}),te.append(we,Bt("span","cp-spacer"),Bt("span","cp-saved",`saved as you pick \xB7 ${zt} takes it back`)),de.appendChild(te),H&&ce.querySelector(`.${H[0].split(" ")[0]}[data-chan="${H[1]}"]`)?.focus()}return ce.addEventListener("keydown",H=>{(/^(input|textarea|select)$/i.test(H.target.tagName)||H.key===" "||H.key==="Enter"||H.key==="Escape")&&H.stopPropagation(),H.key==="Escape"?(H.preventDefault(),b()):H.key==="Enter"&&/^input$/i.test(H.target.tagName)&&(H.preventDefault(),H.target.dispatchEvent(new Event("change")))}),d(),M(),{el:ce,side:()=>z,setSide(H){let te=H==="type"?"type":H==="colors"?Ce:t[H]?.length?H:D;te!==z&&(z=te,d(),M())},settled:()=>I}}Se();Ae();var km="rect, circle, ellipse, polygon, polyline, path, line, text, image, use, foreignObject",xm="defs, marker, mask, .draw-head, .draw-mask, [data-ds-injected]";function Os(e,t){if(!e||!t?.closest||!e.contains(t))return e;let n=t.closest("svg");if(!n||!e.contains(n)||n.closest("[data-chart], .terminal"))return e;if(t.closest(xm))return n;let s=t.closest(km);return s&&n.contains(s)?s:n}var wi=e=>e instanceof SVGElement&&e.tagName.toLowerCase()!=="svg"&&!!e.closest?.("svg");function vi(e){let t=null,n=null;function s(){n?.classList.remove("dl-glow"),n=null,t?.remove(),t=null}function a(c,{dim:h=!0}={}){if(!c?.isConnected){s();return}n!==c&&(n?.classList.remove("dl-glow"),n=c,wi(c)&&c.classList.add("dl-glow")),t??=Object.assign(document.createElement("div"),{className:"dl-spot"}),t.isConnected||e.appendChild(t),t.classList.toggle("dl-spot-dim",h),t.classList.toggle("dl-spot-block",!wi(c));let f=c.getBoundingClientRect(),g=3;Object.assign(t.style,{left:`${f.left-g}px`,top:`${f.top-g}px`,width:`${f.width+g*2}px`,height:`${f.height+g*2}px`})}return{show:a,hide:s,node:()=>n}}function hd(e){let t=null,n=null;function s(){if(!t||!n?.isConnected)return;let a=n.getBoundingClientRect();Object.assign(t.style,{left:`${a.left-4}px`,top:`${a.top-4}px`,width:`${a.width+8}px`,height:`${a.height+8}px`})}return{on(a){n=a,t??=Object.assign(document.createElement("div"),{className:"dl-frame"}),t.isConnected||e.appendChild(t),s()},off(){t?.remove(),t=null,n=null},place:s}}Se();Ae();var Em="npx decklight";function $m(e){let t=e||"";try{t=decodeURIComponent(t)}catch{}/^\/[A-Za-z]:/.test(t)&&(t=t.slice(1));let n=t.lastIndexOf("/");return{dir:n>0?t.slice(0,n):"",file:n>=0?t.slice(n+1):t}}function fd(e,t={}){let{protocol:n="",pathname:s=""}=t,{dir:a,file:c}=$m(s),h=/\.html?$/i.test(c)?c:"<deck.html>",f=n==="file:"&&a?`from ${a}, `:"";return`${e} needs write mode: ${f}run ${Em} ${h}, then reopen the URL it prints`}function Sm(e){let t=Math.max(0,Math.floor((Number(e)||0)/1e3)),n=String(t%60).padStart(2,"0"),s=Math.floor(t/60);return s<60?`${s}:${n}`:`${Math.floor(s/60)}:${String(s%60).padStart(2,"0")}:${n}`}var Am={second:"s",minute:"m",hour:"h",day:"d",week:"w",month:"mo",year:"y"};function md(e){let t=/^(\d+)\s+(second|minute|hour|day|week|month|year)s?\s+ago$/.exec(String(e??"").trim());return t?`${t[1]}${Am[t[2]]}`:String(e??"")}function gd(e,t=Date.now()){if(!e||!e.agent)return null;let n=typeof e.activity=="string"&&e.activity.trim()?` \u2014 ${e.activity.trim().slice(0,60)}`:"",s=Number(e.startedAt);return!Number.isFinite(s)||s<=0||s>t?`${e.agent}${n}`:`${e.agent} \xB7 ${Sm(t-s)}${n}`}function bd(e,{shown:t=!1,threshold:n=10}={}){if(t||!e||!["ok","no-upstream"].includes(e.state))return null;let s=e.state==="ok"?e.ahead:e.unpushed;return!s||s<n?null:`\u2191${s} commits are only on this machine \u2014 H shows them`}function yd(e){let t=Ta(e);return t?t.slides.length?`${t.slides.map(n=>n.text).join(" ")} \xB7 ${t.text}`:t.text:null}function Ta(e){let t=Cm(e);if(t===null)return null;let n=e.slides??{};return{slides:["changed","added","removed"].map(a=>({kind:a,n:Number(n[a])||0})).filter(a=>a.n>0).map(a=>({...a,text:`${a.n} ${a.kind}`})),text:t}}function Cm(e){if(!e||!e.dirty||!e.canWrite)return null;let t=Number(e.lines)||0,n=t?`${t} line${t===1?"":"s"}`:"changes";if(!e.nag)return`${n} since the last commit \u2014 K commits`;let s=Math.floor((Number(e.sinceMs)||0)/6e4),a=s>=60?` \xB7 ${Math.floor(s/60)}h`:s>=1?` \xB7 ${s}m`:"";return`${n} uncommitted${a} \u2014 K commits`}function wd(e){return e?.nag?"asking":"quiet"}var vd=8e3;function Tm(e=vd){return`no answer in ${Math.round(e/1e3)}s \u2014 close other tabs of this deck and retry`}function Us(e,t={},{ms:n=vd,fetchFn:s=fetch}={}){let a=new AbortController,c=!1,h=setTimeout(()=>{c=!0,a.abort()},n),f=t.signal;return f&&(f.aborted?a.abort(f.reason):f.addEventListener("abort",()=>a.abort(f.reason),{once:!0})),s(e,{...t,signal:a.signal}).catch(g=>{throw c?new Error(Tm(n)):g}).finally(()=>clearTimeout(h))}Se();Ae();var Nm=/<\s*(pre|textarea|script|style)\b/i,_m=e=>!Nm.test(String(e??""));function kd(e){let t=String(e??"");if(!_m(t))return t;let n=t.split(`
|
|
435
|
+
`);if(n.length<2)return t;let s=1/0;for(let a of n.slice(1))if(a.trim()&&(/^\s*\t/.test(a)||(s=Math.min(s,/^ */.exec(a)[0].length),s===0)))return t;return Number.isFinite(s)?n.map((a,c)=>c===0?a:a.trim()?a.slice(s):"").join(`
|
|
436
|
+
`):t}Se();Ae();var Om={float:"\u274F",left:"\u25E7",right:"\u25E8",bottom:"\u2B13"},xd=["float","left","right","bottom"],$d=["left","right","bottom"],Lo=new WeakMap,Na=new WeakMap,Mo=e=>(Na.has(e)||Na.set(e,new Map),Na.get(e)),ki=()=>"decklight-panel-open:"+(typeof location<"u"?location.pathname:""),Lm=e=>{try{sessionStorage.setItem(ki(),e)}catch{}},Mm=e=>{try{sessionStorage.getItem(ki())===e&&sessionStorage.removeItem(ki())}catch{}};function Sd(e){let t=null;try{t=sessionStorage.getItem(ki())}catch{return!1}if(!t)return!1;let n=[...Mo(e).values()];if(n.some(a=>a.isOpen()))return!1;let s=n.find(a=>a.name===t);return!s?.opens||!s.available()?!1:(s.open(),s.isOpen())}function Rm(e,t){for(let[n,s]of Mo(e))n!==t&&s.isOpen()&&s.close()}function Im(e){let t=Lo.get(e);for(let n of $d){let s=0;for(let a of t?.values()??[])a.side===n&&(s=Math.max(s,a.px));e.style.setProperty("--dock-"+n,s+"px")}}function Ed(e,t,n,s){Lo.has(e)||Lo.set(e,new Map),n?Lo.get(e).set(t,{side:n,px:s}):Lo.get(e).delete(t),Im(e)}function ys({root:e,reflow:t,getEl:n,closeLabel:s="close",defaultMode:a="float",name:c=null,open:h=null,close:f=null,available:g=()=>!0,tab:b=!0}){let y="decklight-panel-dock:"+(typeof location<"u"?location.pathname:""),$={mode:xd.includes(a)?a:"float",x:null,y:null},S=()=>{let ee=er(y);ee?.mode&&($.mode=ee.mode,$.x=ee.x??null,$.y=ee.y??null)};S();let A=()=>xr(y,$),E={};Mo(e).set(E,{name:c,tab:b&&!!c&&!!h,available:g,opens:!!h,open:()=>h?.(),close:()=>f?.(),isOpen:()=>!!n()});let L=()=>({w:Math.min(360,Math.round(e.clientWidth*.32)),h:Math.min(320,Math.round(e.clientHeight*.4))});function P(){let ee=n();if(!ee)return;Rm(e,E),c&&Lm(c),S(),ee.dataset.dock=$.mode;let re=L(),le=$d.includes($.mode)?$.mode:null;Ed(e,E,le,$.mode==="bottom"?re.h:re.w),ee.style.setProperty("--dock-size",$.mode==="bottom"?re.h+"px":re.w+"px");let ie=ee.querySelector(".narr-card");ie&&$.mode!=="float"&&(ie.style.left="",ie.style.top=""),t?.(),$.mode==="float"&&j()}function j(){let ee=n()?.querySelector(".narr-card");if(!ee||$.mode!=="float")return;let re=ee.offsetWidth||460,le=ee.offsetHeight||400,ie=$.x,I=$.y;(ie==null||I==null)&&(ie=e.clientWidth-re-24,I=24),ie=Math.max(8,Math.min(ie,e.clientWidth-re-8)),I=Math.max(8,Math.min(I,e.clientHeight-le-8)),$.x=ie,$.y=I,ee.style.left=ie+"px",ee.style.top=I+"px"}function U(ee){$.mode=ee,A(),P();let re=n();re?.querySelectorAll(".dk-btn").forEach(ie=>ie.classList.toggle("dk-on",ie.dataset.mode===ee));let le=re?.querySelector(".narr-head");le&&(le.style.cursor=ee==="float"?"move":"")}function oe(ee){let re=n();if(!re||$.mode!=="float"||ee.button!=null&&ee.button!==0||ee.target.closest(".dk-ctl"))return;let le=re.querySelector(".narr-card");if(!le)return;ee.preventDefault();let ie=ee.clientX,I=ee.clientY,ce=parseFloat(le.style.left)||0,de=parseFloat(le.style.top)||0,Ie=Z=>{let T=le.offsetWidth,F=le.offsetHeight;$.x=Math.max(8,Math.min(ce+Z.clientX-ie,e.clientWidth-T-8)),$.y=Math.max(8,Math.min(de+Z.clientY-I,e.clientHeight-F-8)),le.style.left=$.x+"px",le.style.top=$.y+"px"},V=()=>{window.removeEventListener("pointermove",Ie),window.removeEventListener("pointerup",V),A()};window.addEventListener("pointermove",Ie),window.addEventListener("pointerup",V)}function pe(ee,re=s){let le=document.createElement("div");le.className="dk-ctl";for(let I of xd){let ce=document.createElement("button");ce.className="dk-btn"+($.mode===I?" dk-on":""),ce.type="button",ce.textContent=Om[I],ce.dataset.mode=I,ce.title=I==="float"?"float (movable)":`dock ${I}`,ce.setAttribute("aria-label",I==="float"?"float":`dock ${I}`),ce.addEventListener("click",()=>U(I)),le.append(ce)}let ie=document.createElement("button");return ie.className="dk-btn dk-close",ie.type="button",ie.textContent="\xD7",ie.title=re,ie.setAttribute("aria-label","close"),ie.addEventListener("click",ee),le.append(ie),le}function D(){let ee=[...Mo(e)].filter(([le,ie])=>ie.tab&&(le===E||ie.available()));if(!Mo(e).get(E)?.tab||ee.length<2)return null;let re=document.createElement("div");re.className="dk-tabs",re.setAttribute("role","tablist");for(let[le,ie]of ee){let I=document.createElement("button");I.type="button",I.className="dk-tab"+(le===E?" dk-tab-on":""),I.setAttribute("role","tab"),I.setAttribute("aria-selected",le===E?"true":"false"),I.textContent=ie.name,le!==E&&I.addEventListener("click",ce=>{ce.stopPropagation(),ie.open()}),re.append(I)}return re}function z(ee){ee.style.cursor=$.mode==="float"?"move":"",ee.addEventListener("pointerdown",oe),ee.querySelector(":scope > .dk-tabs")?.remove();let re=D();re&&ee.prepend(re)}function Ce(){c&&Mm(c),Ed(e,E,null),t?.()}return{get mode(){return $.mode},isFloat:()=>$.mode==="float",reserveGutter:P,placeCard:j,setDock:U,controls:pe,wireHeader:z,release:Ce}}Se();Ae();var Ad=/\s+|[^\s]+/g;function Cd(e,t){let n=String(e??"").match(Ad)??[],s=String(t??"").match(Ad)??[];n.length*s.length>4e6&&(n=String(e??"").split(/(?<=\n)/),s=String(t??"").split(/(?<=\n)/));let a=n.length,c=s.length,h=Array.from({length:a+1},()=>new Uint32Array(c+1));for(let $=a-1;$>=0;$--)for(let S=c-1;S>=0;S--)h[$][S]=n[$]===s[S]?h[$+1][S+1]+1:Math.max(h[$+1][S],h[$][S+1]);let f=[],g=($,S)=>{let A=f[f.length-1];A?.op===$?A.text+=S:f.push({op:$,text:S})},b=0,y=0;for(;b<a&&y<c;)n[b]===s[y]?(g("=",n[b]),b++,y++):h[b+1][y]>=h[b][y+1]?g("-",n[b++]):g("+",s[y++]);for(;b<a;)g("-",n[b++]);for(;y<c;)g("+",s[y++]);return f}function Td(e){let t=n=>(n.match(/[^\s]+/g)??[]).length;return e.reduce((n,s)=>(s.op==="-"&&(n.removed+=t(s.text)),s.op==="+"&&(n.added+=t(s.text)),n),{removed:0,added:0})}function Nd({root:e,config:t,params:n,printMode:s,toast:a,progress:c,debugLog:h,debugReload:f=()=>{},overlays:g,instance:b,notesSegs:y,notesDraft:$=j=>y(j).join(`
|
|
367
437
|
|
|
368
438
|
\u27E8CLICK\u27E9
|
|
369
439
|
|
|
370
|
-
`),se.spellcheck=!1;let qe=async()=>{try{let ge=await fetch(P+"/edit/notes",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:M,text:se.value})});if(!ge.ok)throw new Error(await ge.text());p("edit",`notes saved \u2014 slide ${M}`),d("notes saved \u2014 reloading")}catch(ge){d(`save failed: ${String(ge.message||ge).slice(0,60)}`)}};se.addEventListener("keydown",ge=>{ge.key==="Enter"&&(ge.metaKey||ge.ctrlKey)?(qe(),ge.preventDefault()):ge.key==="Escape"&&(Le(),ge.preventDefault()),ge.stopPropagation()});let Qe=document.createElement("div");Qe.className="tr-actions";let Fe=document.createElement("button");Fe.type="button",Fe.className="narr-prev-btn",Fe.textContent="\u{1F4BE} save to file",Fe.addEventListener("click",qe),Qe.appendChild(Fe),H.append(K,se,Qe),B.appendChild(H),Ht(B,Le),t.appendChild(B),setTimeout(()=>se.focus(),0)}let $t=["fade","fade-up","fade-down","zoom","pop","draw","highlight"],W=!1,Ae=null,ee=[],We=0,w="main",Ie=null;function g(){if(!S){d(Fn("editing an element",location),3200);return}W=!W,z(),d(W?"element edit mode on \u2014 right-click a slide element":"element edit mode off",2200)}function J(M,H){let K=H;for(;K&&K!==M&&K.parentElement!==M;)K=K.parentElement;return K&&K!==M?K:null}t.addEventListener("contextmenu",M=>{if(!W)return;let H=M.target.closest("section"),K=H?m._sections.indexOf(H)+1:0;if(!H||!K)return;if(M.preventDefault(),H.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 se=J(H,M.target),qe=se?[...H.children].indexOf(se):null;k?.(),Pe(M.clientX,M.clientY,{sec:H,slide:K,index:qe})});function z(){Ae?.remove(),Ae=null,w="main"}function Ce(){let M=Ae.querySelector(".cm-list");M.textContent="";let H=[];if(w==="effects"){H.push({label:"\u2190 back",back:!0,run:()=>{w="main",Ce()}});for(let K of $t)H.push({label:K,run:()=>Xe(K)});H.push({label:"none (instant)",run:()=>Xe("none")}),H.push({label:"remove effect",run:()=>Xe(null)})}else Ie.index===null?H.push({label:"Edit speaker notes",run:()=>{z(),Le()}}):(H.push({label:"Edit speaker notes",run:()=>{z(),Le()}}),H.push({label:"Remove element",run:X}),H.push({label:"Edit content (HTML)",run:()=>{z(),ke(Ie)}}),H.push({label:"Add text effect \u25B8",run:()=>{w="effects",Ce()}}));ee=H,H.forEach((K,se)=>{let qe=document.createElement("div");qe.className="cm-row"+(K.back?" cm-back":""),qe.setAttribute("role","option"),qe.textContent=K.label,qe.addEventListener("mouseenter",()=>ye(se,!1)),qe.addEventListener("click",K.run),M.appendChild(qe)}),ye(0,!1)}function ye(M,H){let K=Ae.querySelectorAll(".cm-row");K.length&&(We=En(K,M,"cm-selected",{scroll:H}))}function Pe(M,H,K){Ie=K,w="main",Ae=document.createElement("div"),Ae.className="decklight-ctxmenu";let se=document.createElement("div");se.className="cm-card";let qe=document.createElement("div");qe.className="cm-list",qe.setAttribute("role","listbox"),qe.setAttribute("aria-label","Element edit menu"),se.appendChild(qe),Ae.appendChild(se),t.appendChild(Ae),Ce();let Qe=t.getBoundingClientRect(),Fe=Math.min(M-Qe.left,Qe.width-se.offsetWidth-4),ge=Math.min(H-Qe.top,Qe.height-se.offsetHeight-4);se.style.left=Math.max(4,Fe)+"px",se.style.top=Math.max(4,ge)+"px",Ht(Ae,z)}async function X(){let{slide:M,index:H}=Ie;z();try{let K=await fetch(P+"/edit/element/remove",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:M,index:H})}),se=await K.json().catch(()=>({}));if(!K.ok)throw new Error(se.error||K.status);d(se.changed?"element removed \u2014 reloading":"nothing to remove")}catch(K){d(`remove failed: ${String(K.message||K).slice(0,60)}`,2200)}}async function Xe(M){let{slide:H,index:K}=Ie;z();try{let se=await fetch(P+"/edit/element/effect",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:H,index:K,effect:M})}),qe=await se.json().catch(()=>({}));if(!se.ok)throw new Error(qe.error||se.status);d(M===null?"effect removed \u2014 reloading":`effect: ${M} \u2014 reloading`)}catch(se){d(`effect save failed: ${String(se.message||se).slice(0,60)}`,2200)}}let mt=null;function ft(){mt?.remove(),mt=null}function ke({slide:M,index:H}){mt=document.createElement("div"),mt.className="decklight-narr decklight-editor";let K=document.createElement("div");K.className="narr-card";let se=document.createElement("div");se.className="narr-head",se.textContent=`edit content \u2014 slide ${M}, element ${H} \xB7 \u2318\u23CE saves \xB7 Esc closes`;let qe=document.createElement("div");qe.className="edit-code";let Qe=document.createElement("pre");Qe.setAttribute("aria-hidden","true");let Fe=document.createElement("code");Fe.className="hljs language-xml",Qe.appendChild(Fe);let ge=document.createElement("textarea");ge.className="narr-input edit-notes",ge.value="loading\u2026",ge.disabled=!0,ge.spellcheck=!1,qe.append(Qe,ge);let Be=()=>{Fe.innerHTML=Vt.highlight(`${ge.value}
|
|
371
|
-
`,{language:"xml"}).value};ge.addEventListener("input",Be),ge.addEventListener("scroll",()=>{Qe.scrollTop=ge.scrollTop,Qe.scrollLeft=ge.scrollLeft});let st=async()=>{try{let pt=await fetch(P+"/edit/element/content",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:M,index:H,html:ge.value})});if(!pt.ok)throw new Error(await pt.text());d("element content saved \u2014 reloading")}catch(pt){d(`save failed: ${String(pt.message||pt).slice(0,60)}`)}};ge.addEventListener("keydown",pt=>{pt.key==="Enter"&&(pt.metaKey||pt.ctrlKey)?(st(),pt.preventDefault()):pt.key==="Escape"&&(ft(),pt.preventDefault()),pt.stopPropagation()});let wt=document.createElement("div");wt.className="tr-actions";let Mt=document.createElement("button");Mt.type="button",Mt.className="narr-prev-btn",Mt.textContent="\u{1F4BE} save to file",Mt.addEventListener("click",st),wt.appendChild(Mt),K.append(se,qe,wt),mt.appendChild(K),Ht(mt,ft),t.appendChild(mt),(async()=>{try{let pt=await fetch(`${P}/edit/element/source?slide=${M}&index=${H}`),nt=await pt.json().catch(()=>({}));if(!pt.ok||!nt.ok)throw new Error(nt.error||pt.status);ge.value=Ra(nt.html),ge.disabled=!1,Be(),ge.focus()}catch(pt){ge.value="",d(`could not read the element's source: ${String(pt.message||pt).slice(0,60)}`,2600)}})()}f.register({isOpen:()=>!!Ae,close:z,keydown(M){switch(M.key){case"ArrowDown":ye(We+1,!0);break;case"ArrowUp":ye(We-1,!0);break;case"Enter":ee[We]?.run();break;case"Escape":z();break;default:return!1}return!0}}),f.register({isOpen:()=>!!mt,close:ft,keydown:M=>M.key==="Escape"&&(ft(),!0)});let ue=null,ie=[],Ke=0,rt=null,Je=1,tt=!1,Rt=null,jt=!1,en={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"/>'},Pt={first:"first slide (Home)",prev:"previous slide (\u2190)",next:"next slide (\u2192)",last:"last slide (End)"},sn=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>`,Gt=()=>Number(ie[Ke]?.slides)||0;function At(M){let H=Gt();Je=Math.max(1,H?Math.min(M,H):M);let K=ue?.querySelector("iframe");tt?K?.contentWindow?.postMessage({__decklightPreview:{goto:[Je,0]}},"*"):Rt=Je,on()}function on(){let M=ue?.querySelector(".hs-nav");if(!M)return;let H=Gt();M.querySelector(".hs-pos").textContent=H?`${Je} / ${H}`:`${Je}`;for(let K of M.querySelectorAll(".hs-btn")){let se=K.dataset.go;K.disabled=Je<=1&&(se==="first"||se==="prev")||!!H&&Je>=H&&(se==="next"||se==="last")}}function un(M){return At(M==="first"?1:M==="prev"?Je-1:M==="next"?Je+1:Gt()||Je+1)}function qt(M,H){H&&(tt=!1,Rt=null,Je=1,M.addEventListener("load",()=>{if(tt=!0,Rt!=null){let K=Rt;Rt=null,At(K)}},{once:!0}),M.src=`${P}/edit/at?ref=${encodeURIComponent(H.hash)}&embedded`,on())}function pn(M,H){let K=[...ue.querySelectorAll(".tp-row")];if(!K.length)return;ne(),Ke=En(K,M,"tp-selected");let se=ie[Ke];ue.querySelector(".tp-caption").textContent=se?`${se.hash} \xB7 ${se.when} \xB7 ${se.subject}${te(se)}`:"";let qe=ue.querySelector("iframe");clearTimeout(rt),H?qt(qe,se):rt=setTimeout(()=>qt(qe,se),60)}function te(M){let H=[];Number.isFinite(M.slides)&&H.push(`${M.slides} slide${M.slides===1?"":"s"}`);let K=[M.add?`+${M.add}`:"",M.del?`\u2212${M.del}`:""].filter(Boolean);return K.length&&H.push(`${K.join(" ")} lines`),H.length?` \xB7 ${H.join(" \xB7 ")}`:""}async function Kt(){if(ue)return Yt();if(!S)return d(`the progress bar moved to J \u2014 ${Fn("history",location)}`,3800);let M="history",H=[],K=null;try{let Fe=await(await fetch(P+"/edit/history")).json();if(!Fe.ok)return d(`${M}: ${Fe.error}`,3e3);H=Fe.entries||[],K=Fe.remote||null}catch{return d(`${M}: could not read the deck history`,3e3)}if(!H.length)return d(`${M}: git has no record of this deck yet`,3e3);k(),ie=H,jt=!1,ue=document.createElement("div"),ue.className="decklight-theme-picker decklight-finder decklight-restore decklight-history",ue.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(Qe=>_t(Qe)).join("")+'<span class="hs-pos" aria-live="polite"></span>'+["next","last"].map(Qe=>_t(Qe)).join("")+'</div><div class="tp-caption"></div></div></div>',ue.querySelector(".tp-filter").textContent="History \u2014 \u2191\u2193 browse \xB7 \u2190\u2192 preview \xB7 \u23CE restore";let se=ue.querySelector(".hs-remote");K?.line?se.textContent=K.line:se.remove();for(let Qe of ue.querySelectorAll(".hs-btn"))Qe.addEventListener("click",()=>un(Qe.dataset.go));let qe=ue.querySelector(".tp-list");ie.forEach((Qe,Fe)=>{let ge=document.createElement("div");ge.className="tp-row",ge.setAttribute("role","option");let Be=document.createElement("span");Be.className="rs-subject",Be.textContent=Qe.subject;let st=document.createElement("span");st.className="hs-meta";let wt=document.createElement("span");if(wt.className="rs-hash",wt.textContent=Qe.hash,st.append(wt,tn(Qe)),Qe.pushed===!1){let pt=document.createElement("span");pt.className="hs-push",pt.title="only on this machine",pt.textContent="\u2191",st.append(pt)}let Mt=document.createElement("span");Mt.className="rs-when",Mt.title=Qe.when,Mt.textContent=Na(Qe.when),st.append(Mt),ge.append(Be,st),ge.addEventListener("click",()=>{pn(Fe,!0),C()}),qe.appendChild(ge)}),Ht(ue,Yt),t.appendChild(ue),pn(0,!0)}function _t(M){return`<button type="button" class="hs-btn" data-go="${M}" title="${Pt[M]}" aria-label="${Pt[M]}">${sn(en[M])}</button>`}function tn(M){let H=document.createElement("span");if(H.className="hs-stat",Number.isFinite(M.slides)){let K=document.createElement("span");K.className="hs-slides",K.title=`${M.slides} slide${M.slides===1?"":"s"} in this version`,K.textContent=String(M.slides),H.append(K)}if(M.add){let K=document.createElement("span");K.className="hs-add",K.title=`${M.add} line${M.add===1?"":"s"} added`,K.textContent=`+${M.add}`,H.append(K)}if(M.del){let K=document.createElement("span");K.className="hs-del",K.title=`${M.del} line${M.del===1?"":"s"} removed`,K.textContent=`\u2212${M.del}`,H.append(K)}return H}function Yt(){clearTimeout(rt),ue?.remove(),ue=null,jt=!1,tt=!1,Rt=null}function C(){let M=ie[Ke];if(!M)return;jt=!0;let H=ue.querySelector(".hs-confirm");H.hidden=!1,H.textContent="";let K=document.createElement("div");K.className="hs-q",K.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 se=document.createElement("div");se.className="hs-why",se.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 qe=document.createElement("div");qe.className="hs-buttons";let Qe=document.createElement("button");Qe.type="button",Qe.className="hs-yes",Qe.textContent="restore this version",Qe.addEventListener("click",Ee);let Fe=document.createElement("button");Fe.type="button",Fe.className="hs-no",Fe.textContent="cancel",Fe.addEventListener("click",ne),qe.append(Qe,Fe);let ge=document.createElement("div");ge.className="hs-keys",ge.textContent="\u23CE confirms \xB7 Esc cancels",H.append(K,se,qe,ge)}function ne(){jt=!1;let M=ue?.querySelector(".hs-confirm");M&&(M.hidden=!0,M.textContent="")}async function Ee(){let M=ie[Ke];if(!(!M||!jt)){Yt();try{let K=await(await fetch(P+"/edit/restore",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ref:M.hash})})).json();if(!K.ok)return d(`restore failed: ${K.error}`,3e3);if(!K.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)}}}f.register({isOpen:()=>!!B,close:Le,keydown:M=>M.key==="Escape"&&(Le(),!0)}),f.register({isOpen:()=>!!O,close:Ue,keydown:M=>M.key==="Escape"&&(Ue(),!0)}),f.register({isOpen:()=>!!ue,close:Yt,keydown(M){switch(M.key){case"ArrowDown":pn(Ke+1,!1);break;case"ArrowUp":pn(Ke-1,!1);break;case"ArrowLeft":un("prev");break;case"ArrowRight":un("next");break;case"Home":un("first");break;case"End":un("last");break;case"Enter":jt?Ee():C();break;case"Escape":jt?ne():Yt();break;default:return!1}return!0}});let we=null;function Ne(){we?.remove(),we=null}async function Ge(M){if(we){Ne();return}if(!S){d(Fn("configuring an engine",location),3200);return}let H,K;try{let nt=await fetch(`${P}/edit/wizard?engine=${encodeURIComponent(M)}`),vt=await nt.json().catch(()=>({}));if(!nt.ok||!vt?.schema){d(vt.error||`no wizard for ${M}`,3200);return}if(typeof vt.from!="string"||!vt.from||typeof vt.provenance?.askedBy!="string"||typeof vt.provenance?.sentTo!="string"){d("the server did not say who is asking for these answers \u2014 not prompting",3200);return}H=vt.schema,K=vt.provenance}catch{d("the author server did not answer",2600);return}k?.(),we=document.createElement("div"),we.className="decklight-narr decklight-editor";let se=document.createElement("div");se.className="narr-card";let qe=document.createElement("div");qe.className="narr-head",qe.textContent=`${H.title} \u2014 \u2318\u23CE saves \xB7 Esc closes`;let Qe=document.createElement("div");Qe.className="wiz-src";let Fe=document.createElement("div");Fe.textContent=K.askedBy;let ge=document.createElement("div");ge.textContent=K.sentTo,Qe.append(Fe,ge),se.append(qe,Qe);let Be=new Map;for(let nt of H.fields){let vt=document.createElement("label");vt.className="tr-actions";let L=document.createElement("span");L.textContent=nt.required?`${nt.label} *`:nt.label;let Bt;if(nt.type==="choice"){Bt=document.createElement("select");for(let ln of nt.options){let cn=document.createElement("option");cn.value=ln,cn.textContent=ln,Bt.append(cn)}nt.default&&(Bt.value=nt.default)}else nt.type==="boolean"?(Bt=document.createElement("input"),Bt.type="checkbox",Bt.checked=nt.default===!0):(Bt=document.createElement("input"),Bt.type=nt.type==="secret"?"password":"text",Bt.autocomplete=nt.type==="secret"?"off":"on",Bt.spellcheck=!1,nt.default!==void 0&&(Bt.value=String(nt.default)));Bt.className="narr-input",Be.set(nt.name,{field:nt,input:Bt}),vt.append(L,Bt),se.append(vt)}let st=document.createElement("div");st.className="narr-head";let wt=document.createElement("button");wt.className="narr-prev-btn",wt.textContent="save";let Mt=document.createElement("div");Mt.className="tr-actions",Mt.append(wt),se.append(Mt,st),we.append(se),t.append(we),Be.values().next().value?.input.focus();async function pt(){let nt={};for(let[vt,{field:L,input:Bt}]of Be){let ln=L.type==="boolean"?Bt.checked:Bt.value;ln!==""&&ln!==void 0&&(nt[vt]=ln)}wt.disabled=!0,st.textContent="checking\u2026";try{let vt=await fetch(`${P}/edit/wizard`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({engine:H.engine,answers:nt})}),L=await vt.json().catch(()=>({}));if(!vt.ok){st.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"}`,wt.disabled=!1;return}p("wizard",`${H.engine} configured: ${JSON.stringify(L.stored)}`),Ne(),d(`${H.title} configured`,2200)}catch(vt){st.textContent=`could not reach the author server \u2014 ${String(vt.message||vt).slice(0,50)}`,wt.disabled=!1}}wt.addEventListener("click",pt),we.addEventListener("keydown",nt=>{nt.key==="Enter"&&(nt.metaKey||nt.ctrlKey)&&(nt.preventDefault(),pt())})}return f.register({isOpen:()=>!!we,close:Ne,keydown:M=>M.key==="Escape"&&(Ne(),!0)}),{deckHistory:i,toggleEditor:Le,toggleAgentAsk:Ue,toggleElementEdit:g,elementEditOn:()=>W,wizard:Ge,wizards:()=>N.slice(),history:{open:()=>!S&&Q?Y():Kt(),close:()=>{Yt(),oe()},list:()=>ie.slice()},restore:{open:Kt,close:Yt,list:()=>ie.slice()},available:()=>S,settled:()=>((c||a.has("embedded"))&&je(),gt),base:()=>P,commit:{open:bt,close:Ze,state:()=>ce}}}me();fe();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"}],Pa="decklight-onboarded",wo="decklight-tips-seen",Ba="decklight-tips-off",vo=t=>kn(t),Rs=(t,o)=>{fn(t,o)};function Da({root:t,printMode:o,params:a,toast:c,debugLog:d,overlays:p,deck:f}){let m=a.has("embedded"),v=o||m,k=null;function S(){k&&(k.remove(),k=null,Rs(Pa,"1"),d?.("nav","welcome dismissed"))}function P(){k||o||(k=document.createElement("div"),k.className="decklight-welcome",k.innerHTML=`<div class="wel-card">
|
|
440
|
+
`),renderTheme:S=()=>({}),previewQuery:A=()=>"?embedded",knownConcepts:E=()=>[],captionsOn:L=()=>!1,toggleCaptions:P=null}){let j=!1,U=!1,oe=!1,pe=!1,D="",z=[],Ce=null,ee=[],re=null,le=[],ie=null,I=!1,ce=null,de=0;function Ie(){let m=gd(re);if(!m){clearInterval(de),de=0,ce?.remove(),ce=null;return}ce||(ce=document.createElement("div"),ce.className="decklight-agent-chip",ce.setAttribute("role","status"),ce.setAttribute("aria-live","polite"),e.appendChild(ce)),ce.textContent=`\u{1F916} ${m}`,ce.title=re.prompt?`asked: ${re.prompt}`:"",de||(de=setInterval(Ie,1e3))}let V=null,Z=null;document.addEventListener("fullscreenchange",()=>{se(),F()});let T=null;function F(){let m=j&&!s&&!document.fullscreenElement;if(e.classList.toggle("has-slide-num",m),!m){T?.remove(),T=null;return}T||(T=document.createElement("div"),T.className="decklight-slide-num",T.setAttribute("aria-hidden","true"),e.appendChild(T)),T.textContent=`${b.state.slide} / ${b.state.totalSlides}`}b.on("slide",F);function se(){let m=yd(V),k=!!m&&!document.fullscreenElement;if(e.classList.toggle("has-commit-chip",k),!k){Z?.remove(),Z=null;return}if(!Z){Z=document.createElement("div"),Z.className="decklight-commit-chip",Z.setAttribute("role","status"),Z.setAttribute("aria-live","polite"),Z.tabIndex=0;let W=()=>G();Z.addEventListener("click",W),Z.addEventListener("keydown",he=>{(he.key==="Enter"||he.key===" ")&&(he.preventDefault(),W())}),e.appendChild(Z)}let _=Ta(V);Z.textContent="\u2325 ";for(let W of _.slides){let he=document.createElement("span");he.className=`cc-sl cc-sl-${W.kind}`,he.textContent=W.text,Z.append(he," ")}Z.append(_.slides.length?`\xB7 ${_.text}`:_.text),Z.setAttribute("aria-label",m),Z.dataset.tone=wd(V),Z.title="what has changed since the last commit \u2014 click or K to commit it; the work is snapshotted either way"}async function _e(){if(!j)return null;try{let k=await(await fetch(D+"/deck/edit/commit")).json();if(k?.ok)return V=k,se(),k}catch{}return null}let Te=null,l=!1;function d(){Te?.remove(),Te=null,l=!1}async function G(){if(Te)return d();if(!j){a(fe("committing"),3200);return}let m=await _e()??V;if(!m?.canWrite){a("this session is not committing \u2014 open the deck with --git",3e3);return}g.opening(),Te=document.createElement("div"),Te.className="decklight-narr decklight-commit",Te.innerHTML='<div class="narr-card" role="dialog" aria-label="Commit"></div>',Qt(Te,d),e.appendChild(Te);let k=Te.querySelector(".narr-card"),_=(ze,Ye,st)=>{let lt=document.createElement(ze);return Ye&&(lt.className=Ye),st!==void 0&&(lt.textContent=st),lt},W=(ze,Ye)=>{let st=_("div",`narr-row narr-sel ${ze}`,Ye);return st.setAttribute("role","button"),st.tabIndex=0,st.addEventListener("keydown",lt=>{(lt.key==="Enter"||lt.key===" ")&&(lt.preventDefault(),lt.stopPropagation(),st.click())}),st},he=(ze,Ye)=>ze.addEventListener("keydown",st=>{if(st.key==="Escape"&&!st.isComposing){st.preventDefault(),st.stopPropagation(),d();return}st.key==="Enter"&&(st.metaKey||st.ctrlKey)&&(st.preventDefault(),Ye()),!((st.metaKey||st.ctrlKey)&&(st.key==="k"||st.key==="K"))&&st.stopPropagation()}),Be=_("div","narr-head","commit"),Re=_("div","cm-what"),ct=_("div","cm-slides");ct.hidden=!0;let Oe=_("textarea","narr-input cm-input");Oe.rows=3,Oe.placeholder="what changed, in one line\u2026";let $t=_("div","cm-plan");$t.hidden=!0;let Lt=_("div","cm-row"),Ut=m.describer,en=W("cm-write",Ut?"write them for me":m.subjectsOff?"write them for me \u2014 off":"write them for me \u2014 no agent");Ut||en.classList.add("cm-off"),Ut&&(en.title=`Sends the deck's uncommitted changes to ${Ut.name} (${Ut.label}), the agent installed on this machine, which may pass them to its provider. It proposes one commit, or several when the changes are separate ideas.`);let _t=W("cm-single","one commit");_t.hidden=!0;let kt=W("cm-go","Commit");Lt.append(en,_t,kt);let x=_("div","cm-row cm-tagrow"),q=_("input","narr-input cm-tag");q.type="text",q.placeholder="tag the last commit, e.g. v1.0",q.setAttribute("aria-label","Tag name");let X=W("cm-tag-go","Tag"),me=_("span","cm-tags");x.append(q,X,me);let De=_("div","cm-row cm-pushrow"),Ge=_("span","cm-push-what"),ne=W("cm-push-go","Push");De.append(Ge,ne);let $e=_("div","rec-hint","\u2318\u23CE commits \xB7 Esc closes \u2014 the work is snapshotted either way");k.append(Be,Re,ct,Oe,$t,Lt,x,De,$e);let He=m,it=()=>{let ze=!!He.dirty;if(Oe.hidden=!ze,Lt.hidden=!ze,ct.hidden=!0,!ze){$t.hidden=!0,Re.textContent="nothing to commit \u2014 the deck matches its last commit";return}let Ye=Number(He.lines)||0,st=Math.floor((Number(He.sinceMs)||0)/6e4),lt=Array.isArray(He.files)&&He.files.length?He.files:[He.deck||"the deck"],xt=lt.length===1?lt[0]:`${lt.slice(0,-1).join(", ")} and ${lt[lt.length-1]}`;Re.textContent=`${Ye?`${Ye} line${Ye===1?"":"s"}`:"changes"} in ${xt}`+(st>=1?`, ${st>=60?`${Math.floor(st/60)}h`:`${st}m`} old`:"");let Zt=He.slides;if(Zt&&(Zt.changed||Zt.added||Zt.removed)){let Jn=Zt.changed+Zt.added+Zt.removed;ct.textContent="",ct.append(_("span","cm-sl-head",`${Jn===1?"1 slide":`${Jn} slides`}`));for(let An of["changed","added","removed"]){let br=_("span",`cm-sl cm-sl-${An}`,`${Zt[An]} ${An}`);Zt[An]||br.classList.add("cm-sl-zero"),ct.append(br)}ct.hidden=!1}},qe=()=>{let ze=Array.isArray(He.tags)?He.tags:[];me.textContent=ze.length?`on it: ${ze.join(", ")}${ur()?"":" \xB7 not pushed"}`:"",me.hidden=!ze.length;let Ye=He.push;if(ne.classList.toggle("cm-off",!Ye||!!Ye.blocked),!Ye){Ge.textContent="push: git cannot say where this branch stands";return}if(Ye.blocked){Ge.textContent=Ye.blocked;return}let st=Number(Ye.ahead)||0,lt=`${st} commit${st===1?"":"s"}`;Ge.textContent=Ye.state==="no-upstream"?`${Ye.branch} is not on ${Ye.remote} yet${st?` \xB7 \u2191${lt}`:""}`:st?`\u2191${lt} not on ${Ye.upstream}`:`up to date with ${Ye.upstream}`};it(),qe(),setTimeout(()=>(He.dirty?Oe:q).focus(),0);let nt=Oe.placeholder,r=$e.textContent,o=ze=>{$e.textContent=ze,$e.classList.add("cm-why")},i=()=>{$e.textContent="";let ze=Ye=>{let st=document.createElement("span");return st.className="cm-cmd",st.textContent=Ye,st};m.subjectsOff?$e.append("this session was started with ",ze("--no-commit-messages")," \u2014 restart without it to have one written"):$e.append("no agent is installed on this machine to write one \u2014 ",ze("decklight doctor")," lists the ones it can use"),$e.classList.add("cm-why")},u=null,p=ze=>{let Ye=ze.commits.length,st=ze.commits.filter(lt=>lt.take).length;return st===Ye?Ye===1?"Commit":`Commit all ${Ye}`:st?`Commit ${st} of ${Ye}`:"Commit"},v=()=>{kt.textContent=u?p(u):"Commit",kt.disabled=!!u&&!u.commits.some(ze=>ze.take)},C=ze=>{let Ye=new Map((u?.units??[]).map(An=>[An.id,An])),st=ze.map(An=>Ye.get(An)).filter(Boolean),lt=[...new Set(st.flatMap(An=>An.slides??[]))].sort((An,br)=>An-br),xt=[...new Set(st.filter(An=>!An.slides?.length).map(An=>An.where).filter(Boolean))],Zt=lt.every((An,br)=>br===0||An===lt[br-1]+1);return[...lt.length?lt.length===1?[`slide ${lt[0]}`]:[Zt?`slides ${lt[0]}-${lt[lt.length-1]}`:`slides ${lt.join(", ")}`]:[],...xt].join(" \xB7 ")},R=ze=>{if(u=ze,$t.textContent="",$t.hidden=!ze,Oe.hidden=!!ze,_t.hidden=!ze,!ze){v();return}ze.commits.forEach((Ye,st)=>{let lt=_("div","cm-plan-row");Ye.take===void 0&&(Ye.take=!0);let xt=_("input","cm-plan-take");xt.type="checkbox",xt.checked=Ye.take,xt.title="commit this one now \u2014 untick it to leave it uncommitted",xt.setAttribute("aria-label",`Include commit ${st+1}`),xt.addEventListener("change",()=>{Ye.take=xt.checked,lt.classList.toggle("cm-plan-off",!Ye.take),v()}),lt.classList.toggle("cm-plan-off",!Ye.take);let Zt=_("input","narr-input cm-plan-subject");Zt.type="text",Zt.value=Ye.subject,Zt.placeholder="what this commit changed\u2026",Zt.setAttribute("aria-label",`Commit ${st+1} of ${ze.commits.length}`),Zt.addEventListener("input",()=>{Ye.subject=Zt.value}),he(Zt,()=>We()),lt.append(xt,_("span","cm-plan-n",String(st+1)),Zt,_("span","cm-plan-where",C(Ye.units))),$t.append(lt)}),v(),setTimeout(()=>$t.querySelector("input")?.focus(),0)};_t.addEventListener("click",()=>{let ze=u?.commits?.[0]?.subject??"";R(null),ze&&!Oe.value.trim()&&(Oe.value=ze),Oe.focus()});let ge=async()=>{if(!Ut){i();return}if(l)return;$e.textContent=r,$e.classList.remove("cm-why"),l=!0,en.classList.add("cm-thinking");let ze=Es(Ye=>{en.textContent=Ye,Oe.placeholder=Ye});try{let Ye=await fetch(D+"/deck/edit/commit/plan",{method:"POST"}),st=await Ye.json();if(st?.code==="FIRST"&&(Ye=await fetch(D+"/deck/edit/commit/subject",{method:"POST"}),st=await Ye.json(),st?.ok&&(st={ok:!0,commits:st.subject?[{subject:st.subject,units:[]}]:[]})),!st?.ok)throw new Error(st?.error||`HTTP ${Ye.status}`);if(!Te)return;let lt=Array.isArray(st.commits)?st.commits:[];if(lt.length>1)R({base:st.base,units:st.units??[],commits:lt.map(xt=>({subject:String(xt.subject??""),units:xt.units??[]}))}),en.textContent="write them again";else{R(null);let xt=lt[0]?.subject;xt&&!Oe.value.trim()&&(Oe.value=xt),en.textContent=xt?"write them again":"nothing to say about it"}}catch(Ye){Te&&(en.textContent="couldn't write one",o(String(Ye.message||Ye)))}finally{ze(),en.classList.remove("cm-thinking"),Oe.placeholder=nt,l=!1}};en.addEventListener("click",ge),m.messages&&Ut&&m.dirty&&ge();let Me=(ze,Ye)=>{V={...ze,nag:!1},se(),a(Ye,2600);let st=!!ze.dirty;if(!st&&(!ze.push||ze.push.blocked)){d();return}He={...He,...ze,dirty:st},Oe.value="",it(),R(ze.left?{base:ze.left.base,units:ze.left.units??[],commits:ze.left.commits.map(lt=>({subject:String(lt.subject??""),units:lt.units??[]}))}:null),st&&!ze.left&&(en.textContent="write them again"),Re.textContent=st?`${Ye} \xB7 the rest is still uncommitted`:Ye,qe(),setTimeout(()=>(st?$t.querySelector(".cm-plan-subject")??Oe:ne).focus(),0)},We=async()=>{if(!He.dirty)return;let ze=u,Ye=Oe.value.trim(),st=ze?ze.commits.filter(lt=>lt.take):[];if(!(ze&&!st.length)){if(ze?st.some(lt=>!lt.subject.trim()):!Ye){(ze?[...$t.querySelectorAll(".cm-plan-row:not(.cm-plan-off) .cm-plan-subject")].find(lt=>!lt.value.trim()):Oe)?.focus();return}kt.textContent="committing\u2026";try{let lt=ze?await fetch(D+"/deck/edit/commit/split",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({base:ze.base,commits:ze.commits.map(Zt=>({message:Zt.subject.trim(),units:Zt.units,skip:!Zt.take}))})}):await fetch(D+"/deck/edit/commit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({message:Ye})}),xt=await lt.json();if(!xt?.ok)throw xt?.code==="STALE"&&(R(null),en.textContent="write them again"),new Error(xt?.error||`HTTP ${lt.status}`);if(!xt.committed){d(),a("nothing to commit",2600);return}h("git",ze?`commit: ${xt.count} commits`:`commit: ${xt.subject}`),Me(xt,ze&&xt.count>1?`committed ${xt.count} \u2014 "${xt.subjects[0]}" and ${xt.count-1} more`:`committed \u2014 "${xt.subject}"`)}catch(lt){v(),o(`couldn't commit \u2014 ${String(lt.message||lt)}`)}}};kt.addEventListener("click",We),he(Oe,We);let rt=async()=>{let ze=q.value.trim();if(!ze){q.focus();return}X.textContent="tagging\u2026";try{let Ye=await fetch(D+"/deck/edit/commit/tag",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({name:ze})}),st=await Ye.json();if(!st?.ok)throw new Error(st?.error||`HTTP ${Ye.status}`);He={...He,tags:st.tags,push:st.push},q.value="",qe(),a(`tagged ${st.tag} \u2014 Push sends it with the branch`,2600),h("git",`tag: ${st.tag}`)}catch(Ye){o(`couldn't tag \u2014 ${String(Ye.message||Ye)}`)}finally{X.textContent="Tag"}};X.addEventListener("click",rt),q.addEventListener("keydown",ze=>{if(ze.key==="Escape"&&!ze.isComposing){ze.preventDefault(),ze.stopPropagation(),d();return}if(ze.key==="Enter"){ze.preventDefault(),ze.stopPropagation(),rt();return}(ze.metaKey||ze.ctrlKey)&&(ze.key==="k"||ze.key==="K")||ze.stopPropagation()});let Je=!1,qt=async()=>{if(Je)return;if(!He.push||He.push.blocked){He.push?.blocked&&o(He.push.blocked);return}Je=!0;let ze=Es(Ye=>{ne.textContent=Ye},{label:"pushing"});try{let Ye=await fetch(D+"/deck/edit/commit/push",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tags:ur()})}),st=await Ye.json();if(!st?.ok)throw new Error(st?.error||`HTTP ${Ye.status}`);He={...He,tags:st.tags,push:st.push},qe(),a(`pushed ${st.branch} to ${st.remote}${st.pushedTags===!1?" \xB7 tags kept here":""}`,2600),h("git",`push: ${st.branch} \u2192 ${st.remote}`)}catch(Ye){o(`couldn't push \u2014 ${String(Ye.message||Ye)}`)}finally{ze(),ne.textContent="Push",Je=!1}};ne.addEventListener("click",qt),be??=g.register({isOpen:()=>!!Te,close:d,keydown(ze){if(ze.key==="Escape")return d(),!0;if(/^(input|textarea)$/i.test(ze.target?.tagName??""))return!1;if(ze.key==="Enter"){let Ye=Te?.querySelector(".cm-go");return Ye&&!Ye.closest("[hidden]")&&Ye.click(),!0}return ze.key==="k"||ze.key==="K"?(d(),!0):!1}})}let be=null,J,Qe=!1,ot=new Promise(m=>{J=()=>{Qe=!0,m()}});if(!s&&!n.has("embedded")){let m=t.edit?.url?[t.edit.url]:/^https?:$/.test(location.protocol)?[""]:["http://127.0.0.1:8788"];(async()=>{for(let k of m)try{let _=await fetch(k+"/deck/ping");if(!_.ok)continue;let W=await _.json();if(!W?.ok)continue;let he=decodeURIComponent(location.pathname.split("/").pop()||"");if(he&&W.name&&he!==W.name){h("edit",`server edits ${W.name}, this deck is ${he} \u2014 not wiring up`);continue}if(W.noTrust){oe=!0,pe=!0,J(),await Pe(k,W);return}oe=!0,D=k,U=W.locked===!0,j=!U,ue(),xe(),b.__saveTimings=async ct=>{let Oe=await Ve(D+"/deck/edit/timings",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({timings:ct})});if(!Oe.ok)throw new Error(await Oe.text());h("edit",`rehearsal timings saved \u2014 ${ct.length} slides`)},z=Array.isArray(W.agents)?W.agents:[],Ce=typeof W.preferredAgent=="string"?W.preferredAgent:null,ee=Array.isArray(W.wizards)?W.wizards:[];let Be=bd(W.remote);Be&&(I=!0,a(Be,4200)),W.commit&&(V=W.commit,se()),re=W.agentBusy||null,le=Array.isArray(W.agentAsks)?W.agentAsks:[],re&&a(`${re.agent} is editing the deck\u2026`,2e3),Ie(),Dt(),Ue(),Ot(),Sd(e);let Re=new EventSource(k+"/deck/events");Re.onmessage=ct=>{f(od(ct.data,Mt)),location.reload()},Re.addEventListener("lock",ct=>{try{at(JSON.parse(ct.data).locked===!0)}catch{}}),bt(k,Re,W),Re.addEventListener("theme",ct=>{try{let Oe=JSON.parse(ct.data);Oe.from!==Mt&&typeof Oe.theme=="string"&&e.dispatchEvent(new CustomEvent("decklight:theme",{detail:{theme:Oe.theme}}))}catch{}}),Re.addEventListener("styles",ct=>{try{JSON.parse(ct.data).from!==Mt&&location.reload()}catch{}}),Re.addEventListener("content",ct=>{try{JSON.parse(ct.data).from!==Mt&&location.reload()}catch{}}),Re.addEventListener("layout",ct=>{try{let Oe=JSON.parse(ct.data);Oe.from!==Mt&&e.dispatchEvent(new CustomEvent("decklight:layout",{detail:{slide:Oe.slide,layout:Oe.layout}}))}catch{}}),Re.addEventListener("concepts",ct=>{try{let Oe=JSON.parse(ct.data);Oe.from!==Mt&&Oe.concepts&&typeof Oe.concepts=="object"&&e.dispatchEvent(new CustomEvent("decklight:concepts",{detail:{concepts:Oe.concepts}}))}catch{}}),Re.addEventListener("notes",ct=>{try{let{slide:Oe,aside:$t,from:Lt}=JSON.parse(ct.data);Wt(Oe,$t,Lt)}catch{}}),Re.addEventListener("commit",ct=>{try{V=JSON.parse(ct.data),se(),h("git",`uncommitted: ${V.lines} lines`)}catch{}}),Re.addEventListener("agent",ct=>{try{let Oe=JSON.parse(ct.data),$t=le.find(Lt=>Lt.id!=null&&Lt.id===(Oe.id??re?.id));if(Oe.state==="activity")re&&(re.activity=Oe.text,Ie()),$t&&($t.activity=Oe.text),h("agent",`activity: ${Oe.text}`);else if(Oe.state==="start")re=Oe,$t||le.push({...Oe,state:"running"}),Ie(),a(`\u{1F916} ${Oe.agent} is editing the deck\u2026`,2200),h("agent",`${Oe.agent} start: ${(Oe.prompt||"").slice(0,80)}`);else if(Oe.state==="done"){re=null,$t&&Object.assign($t,Oe,{finishedAt:Date.now()}),Ie();let Lt=Oe.ok?"":Oe.error?` \u2014 ${Oe.error}`:` (exit ${Oe.code})`;a(Oe.changed?`\u{1F916} ${Oe.agent} edited the deck \u2014 ${zt} undoes${Lt}`:`\u{1F916} ${Oe.agent} finished \u2014 no changes${Lt}`,3e3),h("agent",`${Oe.agent} done ok=${Oe.ok} changed=${Oe.changed}${Lt}`),typeof Oe.recordingWarning=="string"&&(a(Oe.recordingWarning,9e3),h("agent",Oe.recordingWarning))}ie?.()}catch{}}),Re.addEventListener("enhance",ct=>{try{fs(JSON.parse(ct.data))}catch{}}),Re.addEventListener("review",ct=>{try{gr(JSON.parse(ct.data))}catch{}}),Re.addEventListener("export",ct=>{try{let Oe=JSON.parse(ct.data);Oe.state==="slide"&&sr&&sr.run.update(`${sr.doing} \u2014 ${Oe.phase==="voice"?"voicing ":""}slide ${Oe.n} of ${Oe.of}\u2026`),h("export",`${Oe.kind} ${Oe.state}${Oe.n?` ${Oe.n}/${Oe.of}`:""}`)}catch{}}),h("edit",`live reload connected${k?` (${k})`:""}`+(z.length?` \xB7 agents: ${z.map(ct=>ct.name).join(", ")}`:"")),J(),Ir(),ir(),_n().then(ct=>{for(let Oe of Yr)Oe(ct)});return}catch{}J()})()}function fe(m){return Qe?oe&&U?`the deck is locked \u2014 unlock it from the palette or the \u{1F512} chip, then ${m}`:oe&&pe?`this deck is open without trust \u2014 ${m} needs write mode: open it again and say you trust it, or pass --trust`:fd(m,location):`one moment \u2014 the deck is still connecting to its server; ${m} again`}let K=null;function ue(){if(!U||!oe||pe){K?.remove(),K=null;return}if(!K){K=document.createElement("div"),K.className="decklight-lock-chip",K.setAttribute("role","status"),K.tabIndex=0,K.title="the deck is locked: nothing you do here changes the file \u2014 click to unlock";let m=()=>ft();K.addEventListener("click",m),K.addEventListener("keydown",k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),m())}),e.appendChild(K)}K.textContent="\u{1F512} locked \u2014 click to unlock"}function at(m){if(m!==U){U=m,j=oe&&!pe&&!U,xe(),ue();for(let k of N)k(U);a(U?"deck locked \u2014 nothing changes the file until you unlock it":"deck unlocked",2600)}}let N=new Set;async function ft(m=!U){if(!oe||pe){a("this deck is open without trust (--no-trust) \u2014 there is no lock to turn",3e3);return}try{let k=await fetch(D+"/deck/edit/lock",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({locked:m})}),_=await k.json().catch(()=>({}));if(!k.ok||!_.ok)throw new Error(_.error||`the server said ${k.status}`);at(_.locked===!0)}catch(k){a(`could not ${m?"lock":"unlock"} the deck \u2014 ${k.message}`,4e3)}}let M=null,H=!1,te=null;function we(){te?.remove(),te=null}function Ee(m,k){let _=document.createElement("div");return _.className=k,_.textContent=m,_}async function Ke(m){let k=te?.querySelector(".tp-list");if(!k)return;k.textContent="",k.appendChild(Ee(m.message??m.state,"hs-remote"));for(let he of m.commits??[])k.appendChild(Ee(`${he.hash} ${he.subject}`,"tp-row"));let _=te.querySelector(".up-actions");_.textContent="";let W=(he,Be)=>{let Re=document.createElement("button");return Re.type="button",Re.className="narr-prev-btn",Re.textContent=he,Re.addEventListener("click",Be),_.appendChild(Re),Re};W("check now",async()=>{_.textContent="checking\u2026",await Ke(await ae("/deck/upstream/check"))}),m.state==="behind"&&m.pull?.offered?W("update the deck",async()=>{_.textContent="pulling\u2026";let he=await ae("/deck/upstream/pull");if(he.reload)return f("git pull"),location.reload();await Ke({...he,commits:[],message:he.message}),he.state==="pulled"&&W("show it anyway",()=>{f("git pull \u2014 shown anyway"),location.reload()})}):m.pull&&!m.pull.offered&&m.state==="behind"&&_.appendChild(Ee(`update control off \u2014 ${m.pull.reason}`,"hs-remote"))}async function ae(m){try{return await(await fetch(M+m,{method:"POST"})).json()}catch{return{state:"error",message:"the presenting server did not answer"}}}async function Ze(){if(te)return we();let m;try{let k=await fetch(M+"/deck/upstream");if(!k.ok)return a("this deck is not a tracked file in a git clone \u2014 nothing to update from",3400);m=await k.json()}catch{return a("deck update: the presenting server did not answer",3e3)}g.opening(),te=document.createElement("div"),te.className="decklight-theme-picker decklight-finder decklight-restore decklight-history",te.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>',Qt(te,we),e.appendChild(te),await Ke(m)}g.register({isOpen:()=>!!te,close:we,transient:!0,keydown:m=>m.key==="Escape"&&(we(),!0)});function bt(m,k,_){b.__remoteQr=_.phone?`${m||location.origin}/deck/remote/qr.svg`:null,k.addEventListener("remote",he=>{try{let{key:Be}=JSON.parse(he.data);Be==="next"?b.next():Be==="prev"&&b.prev()}catch{}});let W=()=>{fetch(m+"/deck/remote/pos",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({i:b.state.slide,n:b.state.totalSlides})}).catch(()=>{})};b.on("slide",W),b.on("build",W),W()}async function Pe(m,k){try{M=m,H=!0;let _=new EventSource(m+"/deck/events");bt(m,_,k),h("remote",`remote connected${m?` (${m})`:""} \u2014 no edit surface`)}catch{}}let ke=new Set;function Fe(m){ke.add(m);let k=()=>ke.delete(m);return m.then(k,k),m}let Ve=(m,k)=>Fe(Us(m,k));async function et(m){if(!j){a(fe(m),3200);return}ke.size&&await Promise.allSettled([...ke]);try{let k=await fetch(D+"/deck/edit/"+m,{method:"POST"}),_=await k.json().catch(()=>({}));if(!k.ok){a(_.error||`${m} failed`);return}a(`${m} \u2014 ${_.undo} back \xB7 ${_.redo} forward`),h("edit",`${m} \u2192 ${_.undo} back, ${_.redo} forward`)}catch{a(`${m} failed \u2014 is the dev server still up?`,2200)}}function Y(m,k,_,W){let he=document.createElement("div");he.className=`decklight-narr decklight-dockable decklight-editor decklight-${m}`;let Be=document.createElement("div");Be.className="narr-card";let Re=document.createElement("div");Re.className="narr-head";let ct=Object.assign(document.createElement("span"),{className:"ed-heading",textContent:_});return Re.append(ct,k.controls(W)),k.wireHeader(Re),Be.append(Re),he.append(Be),{el:he,card:Be,title:ct}}function ve(m,k){e.appendChild(m),k.reserveGutter();let _=()=>k.reserveGutter();return window.addEventListener("resize",_),()=>{m.remove(),window.removeEventListener("resize",_),k.release()}}let Ne=null,ut=null,ht=ys({root:e,reflow:()=>b._reflow?.(),getEl:()=>Ne,closeLabel:"close (esc)",name:"Agent",open:()=>{Ne||Pt()},close:()=>{Ne&&Pt()},available:()=>j&&z.length>0}),vt="decklight-agent-open:"+location.pathname,mt=m=>{try{m?sessionStorage.setItem(vt,"1"):sessionStorage.removeItem(vt)}catch{}};function Ue(){let m=null;try{m=JSON.parse(sessionStorage.getItem(St)??"null")}catch{}if(Nt(),!m||Date.now()-m.t>6e4||m.slide!==b.state.slide||Kt)return;tn();let k=Kt?.querySelector("textarea.edit-notes");if(!k)return;k.focus();let _=Math.min(Number(m.caret)||0,k.value.length);k.setSelectionRange(_,_),k.scrollTop=Number(m.scroll)||0}function Dt(){let m=!1;try{m=sessionStorage.getItem(vt)==="1"}catch{}m&&!Ne&&!ht.isFloat()&&z.length&&Pt()}function Ct(m){let k=document.createElement("div");k.className=`agent-ask agent-ask-${m.state==="running"?"running":m.ok?"ok":"failed"}`;let _=document.createElement("div");_.className="agent-ask-meta";let W=new Date(m.startedAt||Date.now());_.textContent=[m.slide?`slide ${m.slide}`:null,m.agent,`${String(W.getHours()).padStart(2,"0")}:${String(W.getMinutes()).padStart(2,"0")}`].filter(Boolean).join(" \xB7 "),m.slide&&(_.classList.add("agent-ask-link"),_.title=`go to slide ${m.slide}`,_.addEventListener("click",()=>b.goto(m.slide,0)));let he=document.createElement("div");he.className="agent-ask-prompt",he.textContent=m.prompt;let Be=document.createElement("div");return Be.className="agent-ask-out",Be.textContent=m.state==="running"?`working\u2026${m.activity?` ${m.activity}`:""}`:[m.error?`failed \u2014 ${m.error}`:m.ok?m.changed?"edited the deck":"no changes":`failed (exit ${m.code??"?"})`,(m.tail||"").trim()].filter(Boolean).join(`
|
|
441
|
+
`),k.append(_,he,Be),k}function Pt(){if(Ne){ut(),Ne=null,ut=null,ie=null,mt(!1);return}if(!j){a(fe("asking an agent"),3200);return}if(!z.length){a("no agent CLI detected on the dev machine (claude, codex, bob, \u2026)",2600);return}let{el:m,card:k}=Y("agent",ht,"ask an agent \u2014 edits the deck file \xB7 \u2318\u23CE sends",Pt);Ne=m;let _=document.createElement("div");_.className="agent-log";let W=document.createElement("textarea");W.className="narr-input edit-notes",W.placeholder=`e.g. "make slide ${b.state.slide} a split layout with the diagram on the left"`,W.spellcheck=!1;let he=Ce&&z.some(Oe=>Oe.name===Ce)?Ce:z[0].name,Be=document.createElement("div");if(Be.className="tr-actions",z.length>1){let Oe=document.createElement("select");Oe.className="narr-prev-btn";for(let $t of z){let Lt=document.createElement("option");Lt.value=$t.name,Lt.textContent=$t.label,Oe.appendChild(Lt)}Oe.value=he,Oe.addEventListener("change",()=>{he=Oe.value,Ce=Oe.value,fetch(D+"/deck/edit/agent/prefer",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({agent:Oe.value})}).catch(()=>{}),h("agent",`preferred agent \u2192 ${Oe.value}`)}),Oe.addEventListener("keydown",$t=>$t.stopPropagation()),Be.appendChild(Oe)}let Re=async()=>{let Oe=W.value.trim();if(Oe){if(re){a(`${re.agent} is still working on the last ask`,2200);return}try{let $t=await fetch(D+"/deck/edit/agent",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({prompt:Oe,agent:he,slide:b.state.slide})}),Lt=await $t.json().catch(()=>({}));if(!$t.ok)throw new Error(Lt.error||$t.status);ht.isFloat()?Pt():(W.value="",mt(!0))}catch($t){a(`ask failed: ${String($t.message||$t).slice(0,60)}`,2200)}}};W.addEventListener("keydown",Oe=>{Oe.key==="Enter"&&(Oe.metaKey||Oe.ctrlKey)?(Re(),Oe.preventDefault()):Oe.key==="Escape"&&(Pt(),Oe.preventDefault()),Oe.stopPropagation()});let ct=document.createElement("button");ct.type="button",ct.className="narr-prev-btn",ct.textContent="\u{1F916} send to agent",ct.addEventListener("click",Re),Be.appendChild(ct),ie=()=>{_.replaceChildren(...le.map(Ct)),_.hidden=!le.length,ct.disabled=!!re,_.scrollTop=_.scrollHeight},ie(),k.append(_,W,Be),ut=ve(m,ht),ht.isFloat()||mt(!0),setTimeout(()=>W.focus(),0)}let Kt=null,hn=null,Xt=null,Mt=Math.random().toString(36).slice(2,12);function Wt(m,k,_=null){let W=b._sections?.[m-1];if(!W||typeof k!="string")return;let he=W.querySelector(":scope > aside.notes");he||(he=document.createElement("aside"),he.className="notes",W.appendChild(he)),he.innerHTML=k,_!==Mt&&Xt?.(m),b._notify()}let St="decklight-notes-open:"+location.pathname,Vt="decklight-notes-quiet",on=[250,500,1e3,2e3,0],Yt=500,an=()=>{let m=Number(Nn(Vt));return Nn(Vt)!==null&&on.includes(m)?m:Yt},Cn=(m=an())=>m?`${m} ms after typing stops`:"on leaving only";function wn(){let m=on[(on.indexOf(an())+1)%on.length];return yn(Vt,m===Yt?null:String(m)),a(`notes autosave: ${Cn(m)}`,2200),m}let Nt=()=>{try{sessionStorage.removeItem(St)}catch{}},Ln=null,ar=null,Er=!1,kn=ys({root:e,reflow:()=>b._reflow?.(),getEl:()=>Kt,closeLabel:"close (esc)",defaultMode:"bottom",name:"Notes",open:()=>{Kt||tn()},close:()=>{Kt&&tn()}}),Bn=null,wr=null,Nr=!1;b.on("slide",()=>ar?.());function tn(){if(Kt){if(hn&&Bn?.()&&wr?.()){a("the agent's draft is unsaved \u2014 \u2318\u23CE saves it, \u21BA reset drops it",4200);return}if(!Nr&&hn&&Bn?.()){Nr=!0,hn().then(()=>{Nr=!1,Kt&&!Bn?.()&&tn()});return}Ln(),Kt=null,Ln=null,ar=null,hn=null,Xt=null,Bn=null,wr=null,Nt();return}let m=Er=!j,k=b.state.slide,_=()=>m?`notes \u2014 slide ${k} \xB7 read-only (write mode edits them)`:`notes \u2014 slide ${k} \xB7 saves itself`,{el:W,card:he,title:Be}=Y("notes",kn,_(),tn);Kt=W;let Re=document.createElement("textarea");Re.className="narr-input edit-notes";let ct=()=>Ec($(k)),Oe=Re.value=ct(),$t=Oe;Re.spellcheck=!1,Re.readOnly=m,m&&Re.classList.add("edit-notes-readonly");let Lt=()=>{},Ut=!1,en=!1,_t=0,kt=!1;m||(Bn=()=>Re.value!==Oe),m||(wr=()=>kt),ar=()=>{if(b.state.slide!==k){if(Re.value!==Oe){!m&&!Ut&&!kt&&x().then(()=>{Re.value===Oe&&ar?.()});return}k=b.state.slide,$t=Oe=Re.value=ct(),Be.textContent=_(),Lt()}},Xt=o=>{if(o!==k||Ut)return;let i=ct();Re.value===Oe&&($t=Re.value=i),Oe=i,Lt()};let x=async({auto:o=!1}={})=>{Ut=!0,en=o,Lt();try{sessionStorage.setItem(St,JSON.stringify({slide:k,caret:Re.selectionStart,scroll:Re.scrollTop,t:Date.now()}))}catch{}let i=Re.value;try{let u=await Ve(D+"/deck/edit/slide/notes",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:k,text:i,from:Mt})});if(!u.ok)throw new Error(await u.text());let p=await u.json().catch(()=>({}));if(p.changed===!1){Nt(),Ut=!1,kt=!1,Oe=i,Lt(),Re.value!==Oe&&De(),a("nothing to save \u2014 the notes already match the file",2600);return}h("edit",`notes ${o?"auto":""}saved \u2014 slide ${k}`),Ut=!1,kt=!1,Oe=i,p.inPlace&&Nt(),o&&p.inPlace?(clearTimeout(_t),_t=setTimeout(()=>{_t=0,Lt()},1600)):a(p.inPlace?"notes saved":"notes saved \u2014 reloading",1800),Lt(),Re.value!==Oe&&De()}catch(u){Nt(),Ut=!1,Lt(),a(`save failed: ${String(u.message||u).slice(0,90)}`,6e3)}};if(m||(hn=x),Re.addEventListener("keydown",o=>{o.key==="Enter"&&(o.metaKey||o.ctrlKey)?(m||x(),o.preventDefault()):o.key==="Escape"&&(tn(),o.preventDefault()),m||o.stopPropagation()}),m){he.append(Re),Ln=ve(W,kn);return}let q=()=>{!Ut&&!kt&&Re.value!==Oe&&x()},X=o=>{W.contains(o.target)||q()};e.addEventListener("pointerdown",X,!0),window.addEventListener("blur",q);let me=0,De=()=>{clearTimeout(me);let o=an();o&&(me=setTimeout(()=>{!Ut&&!kt&&Re.value!==Oe&&x({auto:!0})},o))},Ge=()=>{clearTimeout(me),clearTimeout(_t),e.removeEventListener("pointerdown",X,!0),window.removeEventListener("blur",q)},ne=document.createElement("div");ne.className="tr-actions";let $e=document.createElement("div");$e.className="notes-diff",$e.hidden=!0,$e.tabIndex=0;let He=document.createElement("button");He.type="button",He.className="narr-prev-btn notes-reset",He.textContent="\u21BA reset",He.title="back to the notes as the card opened on this slide \u2014 drops every change made since, typed, autosaved or drafted, and writes them back";let it=document.createElement("button");it.type="button",it.className="narr-prev-btn notes-compare",it.title="what saving would change: the notes as last saved, and this box, word by word";let qe=o=>{if($e.hidden=!o,Re.hidden=o,o){let i=Cd(Oe,Re.value),{removed:u,added:p}=Td(i);$e.replaceChildren();let v=document.createElement("div");v.className="notes-diff-head",v.textContent=`before \u2192 after \xB7 \u2212${u} +${p} word${p===1?"":"s"} \xB7 \u2318\u23CE saves the after`;let C=document.createElement("div");C.className="notes-diff-body";for(let R of i){let ge=document.createElement(R.op==="-"?"del":R.op==="+"?"ins":"span");ge.textContent=R.text,C.appendChild(ge)}$e.append(v,C),$e.focus()}else Re.focus();it.textContent=o?"\u270E back to editing":"\u21C4 before / after",it.classList.toggle("narr-sel",o)},nt=Object.assign(document.createElement("span"),{className:"notes-dirty-mark",title:"written on its own once you stop typing (Settings \u2192 Notes autosave), when you leave the box, move to another slide, or close the card \u2014 \u2318\u23CE saves now"});if(Be.after(nt),Lt=()=>{let o=Re.value!==Oe;nt.textContent=Ut?en?"autosaving\u2026":"saving\u2026":o?"\u25CF unsaved":_t?"saved":"",nt.classList.toggle("notes-saved-mark",!Ut&&!o&&!!_t),nt.hidden=!nt.textContent,He.disabled=!o&&Re.value===$t,it.disabled=!o&&$e.hidden,!o&&!$e.hidden&&qe(!1)},He.addEventListener("click",()=>{clearTimeout(me),Re.value=$t,kt=!1,it.classList.remove("notes-fresh"),qe(!1),Lt(),Re.value!==Oe&&!Ut&&x({auto:!0}),a("back to the notes as the card opened on this slide",2200)}),it.addEventListener("click",()=>{it.classList.remove("notes-fresh"),qe($e.hidden)}),$e.addEventListener("keydown",o=>{o.key==="Enter"&&(o.metaKey||o.ctrlKey)?(x(),o.preventDefault()):o.key==="Escape"&&(qe(!1),o.preventDefault()),o.stopPropagation()}),Re.addEventListener("input",()=>{kt=!1,Lt(),De()}),ne.append(He,it),qe(!1),Lt(),z.length){let o=z.find(v=>v.name===Ce)??z[0],i=[{kind:"tags",label:"\u2728 add audio tags",drafting:"drafting",title:`${o.label} drafts ElevenLabs v4 audio tags ([thoughtful], [sighs]) into the notes, with the prompt ElevenLabs publishes for it. Every word, [click] and [pause] must survive, or nothing changes.`,none:"found nothing to add",landed:"audio tags added"},{kind:"spoken",label:"\u{1F5E3} write it for the ear",drafting:"rewriting",title:`${o.label} rewrites terse notes as sentences a person would say out loud \u2014 "Fluffed a line? Backspace retakes it." becomes "And if you fluff a line, just press Backspace to take it again." Every [click] and [pause] must survive, and the length stay in proportion, or nothing changes.`,none:"found nothing to rewrite",landed:"rewritten for the ear"}],u=async(v,C)=>{let R=Re.value;if(!R.trim()){a("nothing to rewrite \u2014 the notes are empty");return}C.disabled=!0,Re.readOnly=!0;let ge=Es(Me=>{C.textContent=`${v.label.split(" ")[0]} ${Me}`},{label:v.drafting});try{let Me=await fetch(D+"/deck/edit/enhance/text",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:R,kind:v.kind})}),We=await Me.json().catch(()=>({}));if(!Me.ok||!We.ok)throw new Error(We.error||`the server said ${Me.status}`);We.changed?(Re.value=We.text,kt=!0,Lt(),it.classList.add("notes-fresh"),a(`${v.landed} \u2014 \u21C4 before / after shows what changed \xB7 \u2318\u23CE saves \xB7 \u21BA reset drops it`,6e3)):a(`${We.label||We.agent} ${v.none}`,3200),h("enhance",`notes editor (${v.kind}): ${We.changed?"drafted":"nothing to change"}`)}catch(Me){a(`nothing changed \u2014 ${String(Me.message||Me)}`,6e3)}finally{ge(),C.textContent=v.label,C.disabled=!1,Re.readOnly=!1,Re.focus()}},p=(v,C)=>{let R=Wn(k),ge=document.createElement("div");ge.className="tr-actions notes-scope";let Me=(Je,qt,ze)=>{let Ye=document.createElement("button");return Ye.type="button",Ye.className="narr-prev-btn",Ye.textContent=Je,qt&&(Ye.title=qt),Ye.addEventListener("click",()=>{ge.remove(),ne.hidden=!1,ze()}),ge.appendChild(Ye),Ye},We=Je=>()=>{if(Re.value!==Oe){a("save or leave this slide's edits first (\u2318\u23CE saves, Esc leaves) \u2014 this rewrites the file",5e3);return}tn(),zr(Je,{kind:v.kind})};Me("this slide","into the box above \u2014 read it, then \u2318\u23CE saves",()=>u(v,C)).classList.add("narr-sel"),R&&Me(`module \u201C${R.title}\u201D \xB7 ${R.to-R.from+1}`,`slides ${R.from}\u2013${R.to}, in the file \u2014 ${zt} undoes`,We("module")),Me(`whole deck \xB7 ${b.state.totalSlides}`,`every slide with notes, in the file \u2014 ${zt} undoes`,We("all")),Me("\u2715","never mind",()=>{});let rt=document.createElement("span");rt.className="notes-scope-what",rt.textContent=`${v.label} \u2014`,ge.prepend(rt),ne.hidden=!0,ne.after(ge),ge.querySelector(".narr-sel")?.focus()};for(let v of i){let C=document.createElement("button");C.type="button",C.className=`narr-prev-btn notes-${v.kind==="tags"?"enhance":"spoken"}`,C.textContent=v.label,C.title=`${v.title} The notes are sent to that agent, which may pass them to its provider.`,C.addEventListener("click",()=>p(v,C)),ne.appendChild(C)}}he.append(Re,$e,ne);let r=ve(W,kn);Ln=()=>{r(),Ge()},setTimeout(()=>Re.focus(),0)}let Mn=["fade","fade-up","fade-down","zoom","pop","draw","highlight"],un=!1,dn=null,Rn=[],nn=0,Tt="main",fn=null,xn=new Set;function xe(){let m=j;if(F(),m!==un){un=m,m||je();for(let k of xn)k(un)}}function B(m){let k=m?.closest?.("section"),_=k?b._sections.indexOf(k)+1:0;if(!k||!_)return null;if(k.hasAttribute("data-markdown-removed"))return a("this slide has no per-element source mapping (data-markdown, removed in 0.3.0) \u2014 edit the file directly",3400),null;let W=Le(k,m);return{sec:k,slide:_,index:W?xs(k,W):null,top:W,clicked:m,node:W?Os(W,m):null}}let Le=(m,k)=>ks(m,k);e.addEventListener("contextmenu",m=>{if(!un||!m.target.closest("section"))return;m.preventDefault();let k=B(m.target);k&&(g.opening(),wt(m.clientX,m.clientY,k))});function je(){dn?.remove(),dn=null,Tt="main"}function tt(){let m=dn.querySelector(".cm-list");m.textContent="";let k=[];if(Tt==="effects"){k.push({label:"\u2190 back",back:!0,run:()=>{Tt="main",tt()}});for(let _ of Mn)k.push({label:_,run:()=>In(_)});k.push({label:"none (instant)",run:()=>In("none")}),k.push({label:"remove effect",run:()=>In(null)})}else if(Tt==="concept"){k.push({label:"\u2190 back",back:!0,run:()=>{Tt="main",tt()}});let _=uo(fn.top,fn.clicked),W=[...new Set([...E(),..._?.name?[_.name]:[]])];for(let he of W)k.push({label:`${_?.name===he?"\u25CF ":"\u25CB "}${he}`,run:()=>Rt(_?.name===he?null:he)});k.push({label:"New concept\u2026",input:!0,run:()=>Zn()}),_?.name&&k.push({label:"none (detach)",run:()=>Rt(null)}),lr&&k.push({label:"Edit concepts\u2026",run:()=>{je(),lr(_?.name??null)}})}else if(Tt==="slide")fn.fromBar||k.push({label:"\u2190 back",back:!0,run:()=>{Tt="main",tt()}}),k.push({label:"New slide after this one",run:()=>{je(),It("new")}}),k.push({label:"Duplicate this slide",run:()=>{je(),It("duplicate")}}),k.push({label:"Move slide up",run:()=>{je(),It("up")}}),k.push({label:"Move slide down",run:()=>{je(),It("down")}}),k.push({label:"Delete this slide",run:()=>{je(),It("delete")}});else if(fn.index===null)k.push({label:"Edit speaker notes",run:()=>{je(),tn()}}),k.push({label:"Slide \u25B8",run:()=>{Tt="slide",tt()}});else{let _=fn.node&&fn.node!==fn.top;if(Qr&&k.push({label:"Inspect",run:()=>Kr()}),k.push({label:_?`Remove this ${fn.node.tagName.toLowerCase()}`:"Remove element",run:()=>At()}),_&&k.push({label:`Remove the whole ${fn.top.tagName.toLowerCase()}`,run:()=>At(fn,{whole:!0})}),k.push({label:"Edit content (HTML)",run:()=>{je(),Fn(fn)}}),k.push({label:"Colors\u2026",run:()=>Kr("colors")}),k.push({label:"Type\u2026",run:()=>Kr("type")}),ye){let W=fn;k.push({label:"Copy style",key:ye.keys.copy,run:()=>{je(),ye.copy(W)}}),ye.has()&&k.push({label:"Paste style",key:ye.keys.paste,run:()=>{je(),ye.paste(W)}})}uo(fn.top,fn.clicked)&&k.push({label:"Concept \u25B8",run:()=>{Tt="concept",tt()}}),k.push({label:"Add text effect \u25B8",run:()=>{Tt="effects",tt()}}),k.push({label:"Slide \u25B8",run:()=>{Tt="slide",tt()}})}Rn=k,k.forEach((_,W)=>{let he=document.createElement("div");he.className="cm-row"+(_.back?" cm-back":""),he.setAttribute("role","option"),he.textContent=_.label,_.key&&he.append(Object.assign(document.createElement("span"),{className:"cm-key",textContent:_.key})),he.addEventListener("mouseenter",()=>yt(W,!1)),he.addEventListener("click",_.run),m.appendChild(he)}),yt(0,!1)}function yt(m,k){let _=dn.querySelectorAll(".cm-row");_.length&&(nn=vn(_,m,"cm-selected",{scroll:k}))}function wt(m,k,_,W="main",{above:he=!1}={}){fn=_,Tt=W,dn=document.createElement("div"),dn.className="decklight-ctxmenu";let Be=document.createElement("div");Be.className="cm-card";let Re=document.createElement("div");Re.className="cm-list",Re.setAttribute("role","listbox"),Re.setAttribute("aria-label","Element edit menu"),Be.appendChild(Re),dn.appendChild(Be),e.appendChild(dn),tt();let ct=e.getBoundingClientRect(),Oe=Math.min(m-ct.left,ct.width-Be.offsetWidth-4),$t=Math.min(k-ct.top-(he?Be.offsetHeight:0),ct.height-Be.offsetHeight-4);Be.style.left=Math.max(4,Oe)+"px",Be.style.top=Math.max(4,$t)+"px",Qt(dn,je)}async function It(m,{slide:k=b.state.slide,to:_=null}={}){if(!j){a(fe("editing slides"),3200);return}try{let W=await Ve(D+"/deck/edit/slide",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({op:m,slide:k,...m==="move"?{to:_}:{}})}),he=await W.json().catch(()=>({}));if(!W.ok)throw new Error(he.error||String(W.status));let Be={new:`new slide added after ${k}`,duplicate:`slide ${k} duplicated`,delete:`slide ${k} deleted \u2014 ${zt} takes it back`,up:`slide ${k} moved up`,down:`slide ${k} moved down`,move:`slide ${k} moved to ${_}`}[m]??"done";a(`${Be} \u2014 reloading`,2e3),Number.isInteger(he.slide)&&(location.hash=`#/${he.slide}/0`)}catch(W){throw a(`could not ${m==="new"?"add a slide":`${m} the slide`}: ${String(W.message||W).slice(0,80)}`,3e3),W}}async function At(m=fn,{whole:k=!1}={}){let{slide:_,index:W}=m;if(je(),W===null){a("nothing selected to remove",2e3);return}let he=k?null:m.node&&m.node!==m.top?m.node:null,Be=he?zs(m.top,he):null;if(he&&!Be){a("that node is the engine\u2019s, not the file\u2019s \u2014 nothing to remove",2600);return}try{let Re=await Ve(D+"/deck/edit/element/remove",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(Be?{slide:_,index:W,path:Be,tag:he.tagName.toLowerCase()}:{slide:_,index:W})}),ct=await Re.json().catch(()=>({}));if(!Re.ok)throw new Error(ct.error||Re.status);a(ct.changed?"element removed \u2014 reloading":"nothing to remove")}catch(Re){a(`remove failed: ${String(Re.message||Re).slice(0,60)}`,2200)}}async function In(m){let{slide:k,index:_}=fn;je();try{let W=await Ve(D+"/deck/edit/element/effect",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:k,index:_,effect:m})}),he=await W.json().catch(()=>({}));if(!W.ok)throw new Error(he.error||W.status);a(m===null?"effect removed \u2014 reloading":`effect: ${m} \u2014 reloading`)}catch(W){a(`effect save failed: ${String(W.message||W).slice(0,60)}`,2200)}}async function Rt(m){let{slide:k,index:_,top:W,clicked:he}=fn,Be=uo(W,he);if(je(),!Be){a("nothing here to name \u2014 right-click a shape in a diagram",2600);return}if(m!==null&&!/^[a-z][a-z0-9-]{0,40}$/i.test(m)){a("a concept is a name: letters, digits and dashes, starting with a letter",3200);return}if(mn){await mn.attach([Be.el],m);return}await Gr({slide:k,index:_,path:Be.path,tag:Be.tag,concept:m},m)}let mn=null,ye=null,lr=null;function Dr(m){let k=B(m);if(!k?.top||k.index===null)return null;let _=m.hasAttribute?.("data-concept")?zs(k.top,m):null,W=_?{name:m.getAttribute("data-concept"),el:m,path:_,tag:m.tagName.toLowerCase()}:uo(k.top,m);return W?{slide:k.slide,index:k.index,path:W.path,tag:W.tag,name:W.name,el:W.el}:null}async function Ur(m,k){let _=m.map(({slide:he,index:Be,path:Re,tag:ct})=>({slide:he,index:Be,path:Re,tag:ct})),W=(async()=>{let he=await Ve(D+"/deck/edit/element/concepts",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({items:_,concept:k,quiet:!0,from:Mt})}),Be=await he.json().catch(()=>({}));if(!he.ok||!Be.ok)throw new Error(Be.error||`the edit server answered ${he.status}`);return Be})();return Fe(W),W}async function Gr({slide:m,index:k,path:_,tag:W,concept:he},Be){try{let Re=await Ve(D+"/deck/edit/element/concept",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:m,index:k,path:_,tag:W,concept:he})}),ct=await Re.json().catch(()=>({}));if(!Re.ok)throw new Error(ct.error||Re.status);a(ct.changed?Be===null?`detached from its concept \u2014 reloading \xB7 ${zt} takes it back`:`now the \u201C${Be}\u201D concept \u2014 reloading \xB7 ${zt} takes it back`:"concept unchanged")}catch(Re){a(`concept not saved: ${String(Re.message||Re).slice(0,90)}`,3400)}}function Zn(){let m=dn?.querySelector(".cm-list");if(!m)return;m.textContent="";let k=document.createElement("div");k.className="cm-row cm-input";let _=document.createElement("input");_.type="text",_.placeholder="concept name \u2014 agent, tools, data\u2026",_.setAttribute("aria-label","New concept name"),_.addEventListener("keydown",W=>{if(W.stopPropagation(),W.key==="Enter"){W.preventDefault();let he=_.value.trim();he&&Rt(he)}else W.key==="Escape"&&(W.preventDefault(),Tt="concept",tt())}),k.appendChild(_),m.appendChild(k),Rn=[],_.focus()}let Qr=null;function Kr(m="info"){let k=fn;je(),Qr?.(k,m)}async function nr({slide:m,index:k,edits:_,concept:W=null}){let he=await Ve(D+"/deck/edit/element/style",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:m,index:k,edits:_,concept:W,quiet:!0,from:Mt})}),Be=await he.json().catch(()=>({}));if(!he.ok)throw new Error(Be.error||he.status);return Be}let sn=null,Un=null,Gn=null,_r=null,ln=ys({root:e,reflow:()=>b._reflow?.(),getEl:()=>sn,closeLabel:"close (esc)",name:"HTML",tab:!1,close:()=>Jt()}),cr="decklight-editor-open:"+location.pathname,cn=()=>{try{sessionStorage.removeItem(cr)}catch{}};function Ot(){let m=null;try{m=JSON.parse(sessionStorage.getItem(cr)??"null")}catch{}if(cn(),!m||Date.now()-m.t>6e4||sn||m.slide!==b.state.slide)return;let k=b._sections[m.slide-1];!k||!k.children?.[m.index]||Fn({sec:k,slide:m.slide,index:m.index})}function Jt(){cn(),sn?.remove(),sn=null,Gn?.classList.remove("dl-editing"),Gn=null,_r&&(window.removeEventListener("resize",_r),_r=null),ln.release()}function Fn({sec:m,slide:k,index:_}){sn=document.createElement("div"),sn.className="decklight-narr decklight-dockable decklight-editor";let W=document.createElement("div");W.className="narr-card";let he=document.createElement("div");if(he.className="narr-head",he.append(Object.assign(document.createElement("span"),{className:"ed-heading",textContent:`edit content \u2014 slide ${k}, element ${_} \xB7 \u2318\u23CE saves`})),Un){let kt=document.createElement("button");kt.type="button",kt.className="ins-tab ed-to-inspector",kt.textContent="\u2190 Inspector",kt.title="back to the inspector, on this element",kt.addEventListener("click",x=>{x.stopPropagation(),Jt(),Un()}),he.prepend(kt)}he.append(ln.controls(Jt)),ln.wireHeader(he);let Be=document.createElement("div");Be.className="edit-code";let Re=document.createElement("pre");Re.setAttribute("aria-hidden","true");let ct=document.createElement("code");ct.className="hljs language-xml",Re.appendChild(ct);let Oe=document.createElement("textarea");Oe.className="narr-input edit-notes",Oe.value="loading\u2026",Oe.disabled=!0,Oe.spellcheck=!1,Be.append(Re,Oe);let $t=()=>{ct.innerHTML=Dn.highlight(`${Oe.value}
|
|
442
|
+
`,{language:"xml"}).value},Lt=()=>{Re.style.paddingRight=`${12+(Oe.offsetWidth-Oe.clientWidth)}px`};Oe.addEventListener("input",()=>{$t(),Lt()}),typeof ResizeObserver<"u"&&new ResizeObserver(Lt).observe(Oe),Oe.addEventListener("scroll",()=>{Re.scrollTop=Oe.scrollTop,Re.scrollLeft=Oe.scrollLeft});let Ut=async()=>{try{try{sessionStorage.setItem(cr,JSON.stringify({slide:k,index:_,t:Date.now()}))}catch{}let kt=await Ve(D+"/deck/edit/element/content",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:k,index:_,html:Oe.value})});if(!kt.ok)throw new Error(await kt.text());a("element content saved \u2014 reloading")}catch(kt){cn(),a(`save failed: ${String(kt.message||kt).slice(0,60)}`)}};Oe.addEventListener("keydown",kt=>{kt.key==="Enter"&&(kt.metaKey||kt.ctrlKey)?(Ut(),kt.preventDefault()):kt.key==="Escape"&&(Jt(),kt.preventDefault()),kt.stopPropagation()});let en=document.createElement("div");en.className="tr-actions";let _t=document.createElement("button");_t.type="button",_t.className="narr-prev-btn",_t.textContent="\u{1F4BE} save to file",_t.addEventListener("click",Ut),en.appendChild(_t),W.append(he,Be,en),sn.appendChild(W),e.appendChild(sn),ln.reserveGutter(),_r=()=>ln.reserveGutter(),window.addEventListener("resize",_r),Gn=_===null?null:m?.children?.[_]??null,Gn?.classList.add("dl-editing"),(async()=>{try{let kt=await Us(`${D}/deck/edit/element/source?slide=${k}&index=${_}`),x=await kt.json().catch(()=>({}));if(!kt.ok||!x.ok)throw new Error(x.error||kt.status);Oe.value=kd(x.html),Oe.disabled=!1,$t(),Lt(),Oe.focus(),Oe.setSelectionRange(0,0),Oe.scrollTop=0,Re.scrollTop=0}catch(kt){Oe.value="",a(`could not read the element's source: ${String(kt.message||kt).slice(0,60)}`,2600)}})()}g.register({isOpen:()=>!!dn,close:je,transient:!0,keydown(m){switch(m.key){case"ArrowDown":yt(nn+1,!0);break;case"ArrowUp":yt(nn-1,!0);break;case"Enter":Rn[nn]?.run();break;case"Escape":je();break;default:return!1}return!0}}),g.register({isOpen:()=>!!sn,close:Jt,panel:!0,modal:()=>ln.isFloat(),keydown:m=>m.key==="Escape"&&(Jt(),!0)});let jt=null,En=[],qn=0,dr=null,rn=1,jn=null,Kn=null,$r=ro({docOf:m=>m.doc,srcFor:m=>`${D}/deck/edit/history/at?ref=${encodeURIComponent(m.doc)}&${A().replace(/^\?/,"")}${L()?"&captions":""}#/${m.slide||1}`,messageFor:m=>({__decklightPreview:{goto:[m.slide,0]}})}),vr=!1,es="decklight-push-tags:"+location.pathname,ur=()=>Nn(es)!=="off";function rr(m){yn(es,m?null:"off"),a(m?"push: the branch and its tags":"push: the branch only \u2014 tags stay on this machine",2600)}let Br="decklight-history-details",pn=()=>Nn(Br)==="1";function Fr(){if(!jt)return;let m=pn();jt.querySelector(".tp-caption").hidden=!m;let k=jt.querySelector(".hs-details");k.setAttribute("aria-pressed",String(m)),k.title=`${m?"hide":"show"} the selected version in a sentence \u2014 hash, age, subject, slide and line counts (I)`}function Or(){if(!jt)return;let m=jt.querySelector(".hs-cc");if(!m)return;let k=L();m.setAttribute("aria-pressed",String(k)),m.title=k?"captions: this version's notes under the slide (C hides them)":"captions: show this version's notes under the slide (C)"}function Sr(){if(!P)return;P(),Or();let m=jt?.querySelector("iframe"),k=()=>m?.contentWindow?.postMessage({__decklightPreview:{captions:L()}},"*");k(),m?.addEventListener("load",k,{once:!0})}function gn(){yn(Br,pn()?"0":"1"),Fr()}let bn="decklight-history-changes",pr=()=>Nn(bn)==="1",Lr=new Map,Pn=0;async function ts(m){return Lr.has(m.hash)||Lr.set(m.hash,fetch(`${D}/deck/edit/history/changes?ref=${encodeURIComponent(m.hash)}`).then(k=>k.json()).then(k=>k?.ok?k:null).catch(()=>null).then(k=>(Lr.set(m.hash,k),k))),Lr.get(m.hash)}function or(){let m=En[qn],k=m&&Lr.get(m.hash);return pr()&&k&&!(k instanceof Promise)?k:null}function qr(){let m=jt?.querySelector(".hs-only");if(!m)return;let k=pr();m.setAttribute("aria-pressed",String(k)),m.textContent=k?"changes":"all slides",m.title=k?"showing only the slides this version changed, added or removed \u2014 D shows all of them":"showing every slide \u2014 D shows only the ones this version changed, added or removed"}function Wr(){yn(bn,pr()?"0":"1"),qr();let m=jt?.querySelector("iframe");m&&(Pn=0,rn=1,Hn(m,En[qn],{force:!0}))}function Mr(m){let k=or(),_=jt?.querySelector("iframe");if(!k||!_)return;let W=En[qn];Pn=Math.max(0,Math.min(m,k.stops.length-1));let he=k.stops[Pn],Be=he?.kind==="removed"&&k.parent?k.parent:W.hash;rn=he?he.kind==="removed"?he.was:he.slide:1,jn=Be,$r.show(_,{doc:Be,slide:rn}),Ar()}let hr={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"/>'},ps={first:"first slide (Home)",prev:"previous slide (\u2190)",next:"next slide (\u2192)",last:"last slide (End)"},ns=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>`,rs=()=>Number(En[qn]?.slides)||0;function Ht(m){if(or())return Mr(m-1);let k=rs();rn=Math.max(1,k?Math.min(m,k):m);let _=jt?.querySelector("iframe");_&&jn&&$r.show(_,{doc:jn,slide:rn}),Ar()}function Ar(){let m=jt?.querySelector(".hs-nav");if(!m)return;let k=m.querySelector(".hs-kind"),_=or();if(_){let he=_.stops.length,Be=_.stops[Pn];m.querySelector(".hs-pos").textContent=he?`${Pn+1} / ${he}`:"no slide changed",k.hidden=!Be,k.className=`hs-kind${Be?` hs-k-${Be.kind}`:""}`,k.textContent=Be?Be.kind==="removed"?`slide ${Be.was} removed`:`slide ${Be.slide} ${Be.kind}`:"";for(let Re of m.querySelectorAll(".hs-btn[data-go]")){let ct=Re.dataset.go;Re.disabled=!he||Pn<=0&&(ct==="first"||ct==="prev")||Pn>=he-1&&(ct==="next"||ct==="last")}return}k.hidden=!0;let W=rs();m.querySelector(".hs-pos").textContent=W?`${rn} / ${W}`:`${rn}`;for(let he of m.querySelectorAll(".hs-btn[data-go]")){let Be=he.dataset.go;he.disabled=rn<=1&&(Be==="first"||Be==="prev")||!!W&&rn>=W&&(Be==="next"||Be==="last")}}function Cr(m){let k=or();return k?Mr(m==="first"?0:m==="prev"?Pn-1:m==="next"?Pn+1:k.stops.length-1):Ht(m==="first"?1:m==="prev"?rn-1:m==="next"?rn+1:rs()||rn+1)}async function Hn(m,k,{force:_=!1}={}){if(k){if(pr()){let W=_||k.hash!==Kn;Kn=k.hash;let he=await ts(k);if(En[qn]!==k||!jt)return;if(he)return Mr(W?0:Pn)}Kn=k.hash,k.hash!==jn&&(rn=1),jn=k.hash,$r.show(m,{doc:jn,slide:rn}),Ar()}}function Ft(m,k){let _=[...jt.querySelectorAll(".tp-row")];if(!_.length)return;Sn(),qn=vn(_,m,"tp-selected");let W=En[qn];jt.querySelector(".tp-caption").textContent=W?`${W.hash} \xB7 ${W.when} \xB7 ${W.subject}${ws(W)}`:"";let he=jt.querySelector("iframe");clearTimeout(dr),k?Hn(he,W):dr=setTimeout(()=>Hn(he,W),60)}function ws(m){let k=[];Number.isFinite(m.slides)&&k.push(`${m.slides} slide${m.slides===1?"":"s"}`);let _=[m.add?`+${m.add}`:"",m.del?`\u2212${m.del}`:""].filter(Boolean);return _.length&&k.push(`${_.join(" ")} lines`),k.length?` \xB7 ${k.join(" \xB7 ")}`:""}async function Vr(){if(jt)return $n();if(!j)return a(`the progress bar moved to J \u2014 ${fe("history")}`,3800);let m="history",k=[],_=null;try{let Re=await(await fetch(D+"/deck/edit/history")).json();if(!Re.ok)return a(`${m}: ${Re.error}`,3e3);k=Re.entries||[],_=Re.remote||null}catch{return a(`${m}: could not read the deck history`,3e3)}if(!k.length)return a(`${m}: git has no record of this deck yet`,3e3);g.opening(),En=k,vr=!1,jt=document.createElement("div"),jt.className="decklight-theme-picker decklight-finder decklight-restore decklight-history",jt.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(Be=>ss(Be)).join("")+'<span class="hs-pos" aria-live="polite"></span>'+["next","last"].map(Be=>ss(Be)).join("")+'<span class="hs-kind" hidden></span><button type="button" class="hs-btn hs-only" aria-label="only the slides this version changed (D)"></button>'+(P?'<button type="button" class="hs-btn hs-cc" aria-label="captions (C)">CC</button>':"")+'<button type="button" class="hs-btn hs-details" aria-label="version details (I)">details</button></div><div class="tp-caption"></div></div></div>',jt.querySelector(".tp-filter").textContent="History \u2014 \u2191\u2193 browse \xB7 \u2190\u2192 preview \xB7 \u23CE restore \xB7 C\xA0captions \xB7 I\xA0details";let W=jt.querySelector(".hs-remote");_?.line?W.textContent=_.line:W.remove();for(let Be of jt.querySelectorAll(".hs-btn[data-go]"))Be.addEventListener("click",()=>Cr(Be.dataset.go));jt.querySelector(".hs-details").addEventListener("click",gn),Fr(),jt.querySelector(".hs-cc")?.addEventListener("click",Sr),Or(),jt.querySelector(".hs-only").addEventListener("click",Wr),qr();let he=jt.querySelector(".tp-list");En.forEach((Be,Re)=>{let ct=document.createElement("div");ct.className="tp-row",ct.setAttribute("role","option");let Oe=document.createElement("span");Oe.className="rs-subject",Oe.textContent=Be.subject;let $t=document.createElement("span");$t.className="hs-meta";let Lt=document.createElement("span");if(Lt.className="rs-hash",Lt.textContent=Be.hash,$t.append(Lt,Xn(Be)),Be.pushed===!1){let en=document.createElement("span");en.className="hs-push",en.title="only on this machine",en.textContent="\u2191",$t.append(en)}let Ut=document.createElement("span");Ut.className="rs-when",Ut.title=Be.when,Ut.textContent=md(Be.when),$t.append(Ut),ct.append(Oe,$t),ct.addEventListener("click",()=>{Ft(Re,!0),jr()}),he.appendChild(ct)}),Qt(jt,$n),e.appendChild(jt),Ft(0,!0)}function ss(m){return`<button type="button" class="hs-btn" data-go="${m}" title="${ps[m]}" aria-label="${ps[m]}">${ns(hr[m])}</button>`}function Xn(m){let k=document.createElement("span");if(k.className="hs-stat",Number.isFinite(m.slides)){let _=document.createElement("span");_.className="hs-slides",_.title=`${m.slides} slide${m.slides===1?"":"s"} in this version`,_.textContent=String(m.slides),k.append(_)}if(m.add){let _=document.createElement("span");_.className="hs-add",_.title=`${m.add} line${m.add===1?"":"s"} added`,_.textContent=`+${m.add}`,k.append(_)}if(m.del){let _=document.createElement("span");_.className="hs-del",_.title=`${m.del} line${m.del===1?"":"s"} removed`,_.textContent=`\u2212${m.del}`,k.append(_)}return k}function $n(){clearTimeout(dr),jt?.remove(),jt=null,vr=!1,jn=null,Kn=null}function jr(){let m=En[qn];if(!m)return;vr=!0;let k=jt.querySelector(".hs-confirm");k.hidden=!1,k.textContent="";let _=document.createElement("div");_.className="hs-q",_.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 W=document.createElement("div");W.className="hs-why",W.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 he=document.createElement("div");he.className="hs-buttons";let Be=document.createElement("button");Be.type="button",Be.className="hs-yes",Be.textContent="restore this version",Be.addEventListener("click",Gt);let Re=document.createElement("button");Re.type="button",Re.className="hs-no",Re.textContent="cancel",Re.addEventListener("click",Sn),he.append(Be,Re);let ct=document.createElement("div");ct.className="hs-keys",ct.textContent="\u23CE confirms \xB7 Esc cancels",k.append(_,W,he,ct)}function Sn(){vr=!1;let m=jt?.querySelector(".hs-confirm");m&&(m.hidden=!0,m.textContent="")}async function Gt(){let m=En[qn];if(!(!m||!vr)){$n();try{let _=await(await Ve(D+"/deck/edit/restore",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ref:m.hash})})).json();if(!_.ok)return a(`restore failed: ${_.error}`,3e3);if(!_.changed)return a(`already at ${m.hash}`,2e3);a(`restored ${m.hash} \u2014 ${zt} takes it back`,2600)}catch{a("restore failed: the edit server did not answer",3e3)}}}g.register({isOpen:()=>!!Kt,close:tn,panel:!0,modal:()=>!Er&&kn.isFloat(),keydown:m=>m.key==="Escape"&&(tn(),!0),save:()=>hn?(hn(),!0):!1}),g.register({isOpen:()=>!!Ne,close:Pt,panel:!0,modal:()=>ht.isFloat(),keydown:m=>m.key==="Escape"&&(Pt(),!0)}),g.register({isOpen:()=>!!jt,close:$n,transient:!0,keydown(m){switch(m.key){case"ArrowDown":Ft(qn+1,!1);break;case"ArrowUp":Ft(qn-1,!1);break;case"ArrowLeft":Cr("prev");break;case"ArrowRight":Cr("next");break;case"Home":Cr("first");break;case"End":Cr("last");break;case"i":case"I":gn();break;case"c":case"C":Sr();break;case"d":case"D":Wr();break;case"Enter":vr?Gt():jr();break;case"Escape":vr?Sn():$n();break;default:return!1}return!0}});let Tn=null;function Rr(){Tn?.remove(),Tn=null}async function Jr(m){if(Tn){Rr();return}if(!j){a(fe("configuring an engine"),3200);return}let k,_;try{let _t=await fetch(`${D}/deck/edit/wizard?engine=${encodeURIComponent(m)}`),kt=await _t.json().catch(()=>({}));if(!_t.ok||!kt?.schema){a(kt.error||`no wizard for ${m}`,3200);return}if(typeof kt.from!="string"||!kt.from||typeof kt.provenance?.askedBy!="string"||typeof kt.provenance?.sentTo!="string"){a("the server did not say who is asking for these answers \u2014 not prompting",3200);return}k=kt.schema,_=kt.provenance}catch{a("the edit server did not answer",2600);return}g.opening(),Tn=document.createElement("div"),Tn.className="decklight-narr decklight-editor";let W=document.createElement("div");W.className="narr-card";let he=document.createElement("div");he.className="narr-head",he.textContent=`${k.title} \u2014 \u2318\u23CE saves \xB7 Esc closes`;let Be=document.createElement("div");Be.className="wiz-src";let Re=document.createElement("div");Re.textContent=_.askedBy;let ct=document.createElement("div");ct.textContent=_.sentTo,Be.append(Re,ct),W.append(he,Be);let Oe=new Map;for(let _t of k.fields){let kt=document.createElement("label");kt.className="tr-actions";let x=document.createElement("span");x.textContent=_t.required?`${_t.label} *`:_t.label;let q;if(_t.type==="choice"){q=document.createElement("select");for(let X of _t.options){let me=document.createElement("option");me.value=X,me.textContent=X,q.append(me)}_t.default&&(q.value=_t.default)}else _t.type==="boolean"?(q=document.createElement("input"),q.type="checkbox",q.checked=_t.default===!0):(q=document.createElement("input"),q.type=_t.type==="secret"?"password":"text",q.autocomplete=_t.type==="secret"?"off":"on",q.spellcheck=!1,_t.default!==void 0&&(q.value=String(_t.default)));q.className="narr-input",Oe.set(_t.name,{field:_t,input:q}),kt.append(x,q),W.append(kt)}let $t=document.createElement("div");$t.className="narr-head";let Lt=document.createElement("button");Lt.className="narr-prev-btn",Lt.textContent="save";let Ut=document.createElement("div");Ut.className="tr-actions",Ut.append(Lt),W.append(Ut,$t),Tn.append(W),e.append(Tn),Oe.values().next().value?.input.focus();async function en(){let _t={};for(let[kt,{field:x,input:q}]of Oe){let X=x.type==="boolean"?q.checked:q.value;X!==""&&X!==void 0&&(_t[kt]=X)}Lt.disabled=!0,$t.textContent="checking\u2026";try{let kt=await fetch(`${D}/deck/edit/wizard`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({engine:k.engine,answers:_t})}),x=await kt.json().catch(()=>({}));if(!kt.ok){$t.textContent=x.state==="unreachable"?`could not reach it \u2014 ${x.error??"try again"}`:x.state==="prerequisite"?`not ready on this machine \u2014 ${x.error??"something it needs is missing"}`:`not accepted \u2014 ${x.error??"check the answers"}`,Lt.disabled=!1;return}h("wizard",`${k.engine} configured: ${JSON.stringify(x.stored)}`),Rr(),a(`${k.title} configured`,2200)}catch(kt){$t.textContent=`could not reach the edit server \u2014 ${String(kt.message||kt).slice(0,50)}`,Lt.disabled=!1}}Lt.addEventListener("click",en),Tn.addEventListener("keydown",_t=>{_t.key==="Enter"&&(_t.metaKey||_t.ctrlKey)&&(_t.preventDefault(),en())})}g.register({isOpen:()=>!!Tn,close:Rr,keydown:m=>m.key==="Escape"&&(Rr(),!0)});let Hr={pptx:"PowerPoint",pdf:"PDF","pdf-notes":"PDF with notes","pdf-handout":"PDF handout",video:"video",bundle:"one file"},sr=null,Ps={aac:"AAC",opus:"Opus"};async function os(){try{let{theme:m}=S()??{},k=await fetch(D+"/deck/edit/export/estimate?kind=bundle"+(m?`&theme=${encodeURIComponent(m)}`:"")),_=await k.json().catch(()=>({}));if(!k.ok||!_.ok)throw new Error(_.error||`the server said ${k.status}`);return _}catch(m){return a(`could not bundle \u2014 ${m.message}`,5200),null}}let is=m=>m?.kind==="recorded"?{narration:m.dir}:m?.kind==="live"?{synthesize:{engine:m.engine,model:m.model,voice:m.voice,style:m.style,dir:m.dir}}:m?.kind==="silent"?{silent:!0}:{},as="decklight-resume-handover:"+location.pathname,Tr=null;function fr(m,k,_,{bundles:W=!1}={}){Tr={ref:m,theme:k,at:Date.now()},_.done(W?`${m} is not marked, so it would not be part of the bundle \u2014 choose this again to mark it and bundle`:`${m} is not marked for this deck \u2014 choose this again to mark it and carry on`,9e3),h("export",`${m} unmarked \u2014 armed`)}function mr(m,k){let _=Tr;return!_||_.theme!==m||Date.now()-_.at>Vn?(Tr=null,!1):(Tr=null,(async()=>{try{sessionStorage.setItem(as,JSON.stringify({...k,at:Date.now()}))}catch{}try{let W=await fetch(D+"/deck/edit/theme/mark",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ref:_.ref,marked:!0})}),he=await W.json().catch(()=>({}));if(!W.ok||!he.ok)throw new Error(he.error||`the server said ${W.status}`);a(`${_.ref} marked \u2014 carrying on once the deck reloads`,4e3)}catch(W){try{sessionStorage.removeItem(as)}catch{}a(`could not mark ${_.ref} \u2014 ${W.message}`,5200)}})(),!0)}function Ir(){let m=null;try{m=JSON.parse(sessionStorage.getItem(as)||"null"),sessionStorage.removeItem(as)}catch{return}!m||Date.now()-m.at>6e4||(m.publish?O():m.kind&&ls(m.kind,m.opts??{}))}async function ls(m,{slides:k=null,voice:_=null,format:W=null,quality:he=null,subtitles:Be=null,audio:Re=!1}={}){let ct=Hr[m];if(!ct)return;if(sr){a("already exporting \u2014 one at a time");return}let Oe=m==="video"&&_?.kind==="live",$t=m==="video"&&_?.kind==="recorded"&&_.stale>0?_.engine?` \u2014 re-voicing ${_.stale} slide${_.stale===1?"":"s"} from older notes first, in its own voice`:` \u2014 its voice was recorded from older notes on ${_.stale} slide${_.stale===1?"":"s"}`:"",{theme:Lt,gen:Ut}=S()??{};if(mr(Lt,{kind:m,opts:{slides:k,voice:_,format:W,quality:he,subtitles:Be,audio:Re}}))return;let en=m==="video"?`${Oe?"voicing and rendering":"rendering"} a video of ${Co(k)}${$t}`:`exporting to ${ct}${Re?`, with the narration audio${Ps[Re]?` as ${Ps[Re]}`:""}`:""}`,_t=c(`${en} \u2014 this takes a moment\u2026`);sr={run:_t,what:ct,doing:en};try{let kt=await fetch(D+"/deck/edit/export",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({kind:m,...Lt?{theme:Lt}:Ut?{gen:Ut}:{},...m==="video"?{slides:k,format:W,quality:he,subtitles:Be,...is(_)}:{},...m==="bundle"&&Re?{audio:Re}:{}})}),x=await kt.json().catch(()=>({}));if(x.unmarked){fr(x.unmarked,Lt,_t,{bundles:m==="bundle"});return}if(!kt.ok||!x.ok)throw new Error(x.error||`the server said ${kt.status}`);_t.done(`wrote ${x.file}${x.seconds?` (${x.seconds}s)`:""}${x.subtitles?` \xB7 subtitles in ${x.subtitles}`:""}${x.voiced?` \u2014 its voice is in ${x.voiced}/`:""}`),h("export",`${m} \u2192 ${x.file}`)}catch(kt){_t.done(`could not export to ${ct} \u2014 ${kt.message}`,5200),h("export",`${m} failed: ${kt.message}`)}finally{sr=null}}let Qn=null,hs="decklight-enhance-done:"+location.pathname,Xe={tags:{doing:"enhancing",with:" with ElevenLabs audio tags",drafting:"drafting audio tags",done:m=>`enhanced ${m}`},spoken:{doing:"writing for the ear",with:"",drafting:"rewriting it as spoken sentences",done:m=>`wrote ${m} for the ear`}};function Wn(m=b.state.slide){let k=[...b._sections??[]],_=0,W=null;if(k.forEach((Be,Re)=>{Re+1<=m&&Be.hasAttribute("data-module")&&(_=Re+1,W=Be.getAttribute("data-module"))}),!_)return null;let he=k.length;for(let Be=_;Be<k.length;Be++)if(k[Be].hasAttribute("data-module")){he=Be;break}return{title:W,from:_,to:he}}async function zr(m="slide",{kind:k="tags"}={}){if(!j){a(fe(k==="spoken"?"rewriting the notes":"enhancing the script"),3200);return}if(!z.length){a("no agent CLI detected on the dev machine (claude, codex, bob, \u2026)",2600);return}if(Qn){a("the agent is already rewriting the script \u2014 one run at a time");return}let _=Xe[k]??Xe.tags,W=b.state.slide,he=m==="module"?Wn(W):null;if(m==="module"&&!he){a("this slide is not in a module \u2014 the deck marks none before it (data-module)",4e3);return}let Be=m==="all"?"all":he?Array.from({length:he.to-he.from+1},(Oe,$t)=>he.from+$t):[W],Re=m==="all"?"every slide's script":he?`the \u201C${he.title}\u201D module (slides ${he.from}\u2013${he.to})`:`slide ${W}'s script`,ct=c(`${_.doing}: ${Re}${_.with} \u2014 asking the agent\u2026`);Qn={run:ct,what:Re,kind:k};try{let Oe=await fetch(D+"/deck/edit/enhance",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slides:Be,kind:k})}),$t=await Oe.json().catch(()=>({}));if(!Oe.ok||!$t.ok)throw new Error($t.error||`the server said ${Oe.status}`);Qn.of=$t.of,ct.update(`${_.doing}: ${Re} \u2014 ${$t.label||$t.agent} is ${_.drafting} (read-only)\u2026`),h("enhance",`${k}: ${$t.of} slide(s) \u2192 ${$t.agent}`)}catch(Oe){ct.done(`could not rewrite ${Re} \u2014 ${Oe.message}`,5200),Qn=null}}function cs(m){let k=Xe[m.kind]??Xe.tags;if(!m.ok)return`could not rewrite the script \u2014 ${m.error}`;let _=m.changed.length,W=[_?`${k.done(_===1?`slide ${m.changed[0]}`:`${_} slides`)} \u2014 ${zt} undoes`:"no slide changed"];return m.failed.length&&W.push(m.failed.length===1?`slide ${m.failed[0].slide} left as it was: ${m.failed[0].why}`:`${m.failed.length} left as they were (the agent's answer did not pass the check)`),m.stale.length&&W.push(`${m.stale.length===1?`slide ${m.stale[0]}`:`${m.stale.length} slides`} edited meanwhile, kept`),W.join(" \xB7 ")}function fs(m){if(m.state==="slide"&&Qn)Qn.run.update(`${(Xe[Qn.kind]??Xe.tags).doing}: ${Qn.what} \u2014 ${m.done} of ${m.of} slide${m.of===1?"":"s"}\u2026`);else if(m.state==="done"){let k=cs(m);if(Qn?Qn.run.done(k,6e3):a(k,6e3),Qn=null,h("enhance",k),m.ok&&m.changed.length)try{sessionStorage.setItem(hs,JSON.stringify({line:k,at:Date.now()}))}catch{}}}let kr=null,ds={reviewed:!1,findings:[]},Yr=new Set;async function _n(){try{let m=await(await fetch(D+"/deck/edit/review")).json();m?.ok&&(ds={reviewed:!!m.reviewed,findings:Array.isArray(m.findings)?m.findings:[],failed:m.failed??[],agent:m.agent})}catch{}return ds}async function Zr(){if(!j){a(fe("reviewing the deck"),3200);return}if(!z.length){a("no agent CLI detected on the dev machine (claude, codex, bob, \u2026)",2600);return}if(kr){a("the agent is already reviewing the deck \u2014 one review at a time");return}let m=c("agent review: asking the agent\u2026");kr={run:m};try{let k=await fetch(D+"/deck/edit/review",{method:"POST",headers:{"content-type":"application/json"},body:"{}"}),_=await k.json().catch(()=>({}));if(!k.ok||!_.ok)throw new Error(_.error||`the server said ${k.status}`);m.update(`agent review: ${_.label||_.agent} is reading the deck (read-only)\u2026`),h("review",`${_.of} batch(es) \u2192 ${_.agent}`)}catch(k){m.done(`could not review the deck \u2014 ${k.message}`,5200),kr=null}}async function gr(m){if(m.state==="batch"&&kr)kr.run.update(`agent review: ${m.done} of ${m.of} part${m.of===1?"":"s"} read \xB7 ${m.found} finding${m.found===1?"":"s"} so far\u2026`);else if(m.state==="done"){let k=m.ok?`agent review: ${m.found?`${m.found} finding${m.found===1?"":"s"}, in Check deck\u2026`:"nothing to improve"}`+(m.failed?.length?` \xB7 ${m.failed.length} part${m.failed.length===1?"":"s"} went unanswered`:""):`could not review the deck \u2014 ${m.error}`;if(kr?kr.run.done(k,6e3):a(k,6e3),kr=null,h("review",k),m.ok){await _n();for(let _ of Yr)_(ds)}}}async function On(m){if(!j){a(fe("fixing it"),3200);return}if(re){a(`${re.agent} is still working on the last ask`,2200);return}try{let k=await fetch(D+"/deck/edit/agent",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({prompt:m.prompt,slide:m.slide,message:`review: ${m.label} on slide ${m.slide}`})}),_=await k.json().catch(()=>({}));if(!k.ok)throw new Error(_.error||k.status);h("review",`fix \u2192 ${_.agent}: slide ${m.slide} ${m.rule}`)}catch(k){a(`could not ask for the fix: ${String(k.message||k).slice(0,60)}`,2600)}}function ir(){let m=null;try{m=JSON.parse(sessionStorage.getItem(hs)||"null"),sessionStorage.removeItem(hs)}catch{}m&&Date.now()-m.at<15e3&&a(m.line,6e3)}let Vn=2e4,zn=0,w=null;async function O(){let{theme:m}=S()??{};if(mr(m,{publish:!0}))return;let k=c(w?.bundled===!1?"publishing \u2014 pushing the deck\u2026":"publishing \u2014 bundling the deck and pushing it\u2026");try{let _=await fetch(D+"/deck/edit/publish",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(m?{theme:m}:{})}),W=await _.json().catch(()=>({}));if(W.unmarked){fr(W.unmarked,m,k,{bundles:!0});return}if(!_.ok||!W.ok)throw new Error(W.error||`the server said ${_.status}`);k.done(W.url?`published \u2014 ${W.url}`:`published \u2014 pushed to ${W.remote} ${W.branch}`,9e3),h("publish",W.url??`${W.remote} ${W.branch}`)}catch(_){k.done(`could not publish \u2014 ${_.message}`,6e3),h("publish",`failed: ${_.message}`)}}async function Q(){if(Tr?.ref&&Date.now()-Tr.at<Vn||zn&&Date.now()-zn<Vn){zn=0,await O();return}try{let k=await fetch(D+"/deck/edit/publish/plan"),_=await k.json().catch(()=>({}));if(!k.ok||!_.ok)throw new Error(_.error||`the server said ${k.status}`);if(!_.signing){a(`cannot publish \u2014 ${_.why}`,8e3);return}zn=Date.now(),w=_,a(`publish to ${_.remote} ${_.branch}${_.url?` \u2192 ${_.url}`:""}? \u2014 pick the row again to confirm`,8e3)}catch(k){a(`could not publish \u2014 ${k.message}`,5200)}}return{deckHistory:et,pushTags:ur,setPushTags:rr,notesQuiet:an,notesQuietLabel:Cn,cycleNotesQuiet:wn,trackWrite:Fe,toggleEditor:tn,toggleAgentAsk:Pt,elementEditOn:()=>un,onElementEditChange:m=>{xn.add(m)},elementTargetOf:B,editContent:m=>{m&&m.index!=null&&Fn(m)},setInspectorOpener(m){Un=m},openElementMenuAt:(m,k,_,W="main",he={})=>{un&&(g.opening(),wt(m,k,_,W,he))},removeElement:m=>At(m),setInspect:m=>{Qr=m},saveStyles:m=>{let k=nr(m);return Fe(k),k},detachConcept:m=>mn&&m.el?mn.attach([m.el],null):Gr({...m,concept:null},null),conceptTarget:Dr,writeConcepts:Ur,setConceptTools:m=>{mn=m},setStyleClip:m=>{ye=m},setEditConcepts:m=>{lr=m},slideOp:It,wizard:Jr,wizards:()=>ee.slice(),history:{open:()=>!j&&H?Ze():Vr(),close:()=>{$n(),we()},list:()=>En.slice()},restore:{open:Vr,close:$n,list:()=>En.slice()},available:()=>j,served:()=>oe,noTrust:()=>pe,cannot:fe,locked:()=>U,toggleLock:ft,onLockChange:m=>{N.add(m)},settled:()=>((s||n.has("embedded"))&&J(),ot),pageId:()=>Mt,probed:()=>Qe,base:()=>pe?null:D,commit:{open:G,close:d,state:()=>V},exportDeck:ls,bundleEstimate:os,enhanceScript:zr,moduleOf:Wn,reviewDeck:Zr,reviewFindings:()=>ds.findings,fixFinding:On,onReview:m=>{Yr.add(m)},publishDeck:Q}}Se();Ae();var Pm="h1, h2, h3, h4, h5, h6, p, li, blockquote, figcaption, td, th, dt, dd",Dm="pre, code, svg, .terminal, [data-chart], [data-math], aside, table[data-chart]",xi="pre > code";function _d(e,t){let n=[],s=t;for(;s&&s!==e;){let a=s.parentElement;if(!a)return null;let c=Array.prototype.indexOf.call(a.children,s);if(c<0)return null;n.unshift(c),s=a}return s===e?n:null}function Ei(e,t){let n=e?.closest?.("tspan, text");return!n||!t?.contains?.(n)||!n.closest("svg")||n.closest("[data-chart], .terminal, aside, .draw-head, .draw-mask, [data-ds-injected]")?null:n}function Od(e,t){let n=e;for(let s of t??[])if(n=n?.children?.[s],!n)return null;return n}function Bm(e){return String(e??"").replace(/\.[a-z0-9]+$/i,"").replace(/[-_]+/g," ").trim()}function Ld(e){return Array.from(e??[]).filter(t=>/^image\/(png|jpeg|gif|webp|svg\+xml|avif)$/.test(t.type))}function Ro(e,t){let n=e?.closest?.(Pm);return!n||!t?.contains?.(n)||n.closest(Dm)?null:n}function Md({root:e,instance:t,toast:n,editmode:s,debugLog:a=()=>{}}){let c=()=>s.available?.()===!0,h=()=>s.base?.()??"",f=async(T,F)=>{let se=await Us(h()+T,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(F)}),_e=await se.json().catch(()=>({}));if(!se.ok)throw new Error(_e.error||String(se.status));return _e},g=()=>({quiet:!0,from:s.pageId?.()??null}),b=(T,F,se,_e=!1)=>e.dispatchEvent(new CustomEvent("decklight:content",{detail:{slide:T,index:F,el:se,code:_e}})),y=T=>{let F=T?.closest?.("section"),se=F?t._sections.indexOf(F)+1:0;return se?{sec:F,slide:se}:null},$=(T,F)=>ks(T,F),S=null;async function A(){let T=S;if(!T)return;if(T.code)return le(T);if(T.svg)return Ie(T);S=null,z(),T.el.removeAttribute("contenteditable"),T.el.classList.remove("dl-editing");let F=T.el.innerHTML;if(F!==T.original)try{let se=await Us(`${h()}/deck/edit/element/source?slide=${T.slide}&index=${T.index}`),_e=await se.json().catch(()=>({}));if(!se.ok||typeof _e.html!="string")throw new Error(_e.error||"no source for this element");let Te=document.createElement("template");Te.innerHTML=_e.html;let l=Te.content.firstElementChild,d=Od(l,T.path);if(!d)throw new Error("the source has no element where the click landed");d.innerHTML=F,await f("/deck/edit/element/content",{slide:T.slide,index:T.index,html:l.outerHTML,...g()}),n("saved",1200),b(T.slide,T.index,T.el)}catch(se){T.el.innerHTML=T.original,n(`could not save the text: ${String(se.message||se).slice(0,80)}`,3e3)}}function E(){let T=A();return s.trackWrite?.(T),T}function L(){let T=S;if(T){if(S=null,z(),T.svg){de(T);return}if(T.code){T.el.removeAttribute("contenteditable"),T.el.classList.remove("dl-editing"),ee(T);return}T.el.innerHTML=T.original,T.el.removeAttribute("contenteditable"),T.el.classList.remove("dl-editing")}}let P={b:"strong",i:"em",e:"code"},j=["strong","em","code"];function U(T){let F=window.getSelection();if(!F||F.rangeCount===0||F.isCollapsed)return null;let se=F.getRangeAt(0);return T.contains(se.commonAncestorContainer)?se:null}function oe(T,F,se){let _e=T.commonAncestorContainer;for(_e.nodeType===Node.TEXT_NODE&&(_e=_e.parentNode);_e&&_e!==se;){if(_e.tagName?.toLowerCase()===F)return _e;_e=_e.parentNode}return null}function pe(T){let F=S;if(!F||F.code||F.svg)return!1;let se=U(F.el);if(!se)return n("select some text first",1600),!1;let _e=window.getSelection(),Te=oe(se,T,F.el);if(Te){let l=Te.parentNode,d=Te.firstChild,G=Te.lastChild;for(;Te.firstChild;)l.insertBefore(Te.firstChild,Te);if(l.removeChild(Te),d&&G){let be=document.createRange();be.setStartBefore(d),be.setEndAfter(G),_e.removeAllRanges(),_e.addRange(be)}}else{let l=document.createElement(T);l.appendChild(se.extractContents()),se.insertNode(l);let d=document.createRange();d.selectNodeContents(l),_e.removeAllRanges(),_e.addRange(d)}for(let l of F.el.querySelectorAll(j.join(",")))l.textContent||l.remove();return F.el.normalize(),z(),!0}let D=null;function z(){let T=S,F=T&&!T.code&&!T.svg?U(T.el):null;if(!F){D?.remove(),D=null;return}if(!D){D=document.createElement("div"),D.className="dl-fmt",D.setAttribute("role","toolbar"),D.setAttribute("aria-label","emphasis");for(let[_e,Te,l]of[["b","strong","B"],["i","em","I"],["e","code","\u2039\u203A"]]){let d=document.createElement("button");d.type="button",d.className=`fmt-${Te}`,d.textContent=l,d.title=`${Te} \u2014 \u2318${_e.toUpperCase()} / Ctrl+${_e.toUpperCase()}`,d.addEventListener("mousedown",G=>{G.preventDefault(),pe(Te)}),D.appendChild(d)}document.body.appendChild(D)}let se=F.getBoundingClientRect();D.style.left=`${Math.max(48,se.left+se.width/2)}px`,D.style.top=`${Math.max(40,se.top-8)}px`;for(let _e of D.children)_e.classList.toggle("on",!!oe(F,_e.className.slice(4),T.el))}document.addEventListener("selectionchange",()=>{S&&z()});async function Ce(T,F,se){let _e=await Us(`${h()}/deck/edit/element/source?slide=${T}&index=${F}`),Te=await _e.json().catch(()=>({}));if(!_e.ok||typeof Te.html!="string")throw new Error(Te.error||"no source for this code block");let l=document.createElement("template");l.innerHTML=Te.html;let d=l.content.firstElementChild,G=Od(d,se);if(!G)throw new Error("the source has no code block where the click landed");return{top:d,node:G}}function ee(T){T.el.textContent="",T.el.appendChild(T.kept)}async function re(T,{sec:F,slide:se}){S&&await E();let _e=$(F,T);if(!_e)return;let Te=xs(F,_e),l=_d(_e,T);if(l===null)return;let d;try{let{node:Qe}=await Ce(se,Te,l);d=Qe.textContent.replace(/^\n/,"").replace(/\s+$/,"")}catch(Qe){n(`could not edit the code: ${String(Qe.message||Qe).slice(0,80)}`,3e3);return}let G=document.createDocumentFragment();for(;T.firstChild;)G.appendChild(T.firstChild);T.textContent=d,S={el:T,code:!0,kept:G,text:d,slide:se,index:Te,path:l},T.setAttribute("contenteditable","plaintext-only"),T.contentEditable!=="plaintext-only"&&T.setAttribute("contenteditable","true"),T.spellcheck=!1,T.classList.add("dl-editing"),T.focus();let be=document.createRange();be.selectNodeContents(T),be.collapse(!1);let J=window.getSelection();J.removeAllRanges(),J.addRange(be),a("info",`editing slide ${se} element #${Te}'s code`)}async function le(T){S=null;let F=T.el,se=F.getAttribute("contenteditable")==="plaintext-only";F.removeAttribute("contenteditable"),F.classList.remove("dl-editing");let _e=(se?F.textContent:F.innerText).replace(/\n$/,"");if(_e===T.text){ee(T);return}try{let{top:Te,node:l}=await Ce(T.slide,T.index,T.path),d=l.textContent;l.textContent=(d.startsWith(`
|
|
443
|
+
`)?`
|
|
444
|
+
`:"")+_e+d.match(/\s*$/)[0],await f("/deck/edit/element/content",{slide:T.slide,index:T.index,html:Te.outerHTML,...g()}),n("saved",1200);let G=l.closest("pre")??l;(F.closest("pre")??F).replaceWith(G),b(T.slide,T.index,G,!0)}catch(Te){ee(T),n(`could not save the code: ${String(Te.message||Te).slice(0,80)}`,3e3)}}let ie=null;function I(T,{again:F=!1}={}){let{input:se,el:_e}=T;if(F||!T.at){let Qe=getComputedStyle(_e),ot=_e.getScreenCTM?.(),fe=(parseFloat(Qe.fontSize)||16)*(ot?Math.hypot(ot.a,ot.b):1),K=_e.getBoundingClientRect(),ue=Qe.textAnchor==="middle"?"middle":Qe.textAnchor==="end"?"end":"start",at=ue==="middle"?K.left+K.width/2:ue==="end"?K.right:K.left;T.at={px:fe,anchor:ue,x:at,y:K.top+K.height/2,font:`${Qe.fontStyle} ${Qe.fontWeight} ${fe}px ${Qe.fontFamily}`},Object.assign(se.style,{font:T.at.font,lineHeight:"1.25",textAlign:ue==="middle"?"center":ue==="end"?"right":"left",color:/^rgb/.test(Qe.fill)?Qe.fill:"",height:`${fe*1.25+6}px`})}let{px:Te,anchor:l,x:d,y:G,font:be}=T.at;ie??=document.createElement("canvas").getContext("2d"),ie.font=be;let J=Math.ceil(ie.measureText(se.value||" ").width+Te*.6+8);se.style.width=`${J}px`,se.style.left=`${l==="middle"?d-J/2:l==="end"?d-J+4:d-4}px`,se.style.top=`${G-(Te*1.25+6)/2}px`}window.addEventListener("resize",()=>{S?.svg&&I(S,{again:!0})});async function ce(T,{sec:F,slide:se}){if(S&&await E(),T.firstElementChild){n("this label is several lines: double-click the one to change",2600);return}let _e=$(F,T);if(!_e)return;let Te=xs(F,_e),l=zs(_e,T);if(l===null)return;window.getSelection()?.removeAllRanges();let d=document.createElement("input");d.type="text",d.className="dl-label-edit",d.value=T.textContent.replace(/\s+/g," ").trim(),d.setAttribute("aria-label","diagram label");let G={svg:!0,el:T,input:d,was:T.textContent,vis:T.style.visibility,slide:se,index:Te,path:l,tag:T.tagName.toLowerCase()};S=G,e.appendChild(d),I(G),T.style.visibility="hidden",d.addEventListener("input",()=>I(G)),d.addEventListener("keydown",be=>{be.stopPropagation(),be.key==="Enter"?(be.preventDefault(),E()):be.key==="Escape"&&(be.preventDefault(),L())}),d.addEventListener("blur",()=>{S===G&&E()}),d.focus(),d.select(),a("info",`editing slide ${se} element #${Te}'s diagram label at ${l.join(".")}`)}function de(T){T.input.remove(),T.el.style.visibility=T.vis}async function Ie(T){S=null;let F=T.input.value.replace(/\s+/g," ").trim();if(de(T),F!==T.was.replace(/\s+/g," ").trim()){if(!F){n("kept the label: an empty one could not be clicked again (remove the shape instead)",3200);return}T.el.textContent=F;try{await f("/deck/edit/element/text",{slide:T.slide,index:T.index,path:T.path,tag:T.tag,was:T.was,text:F,...g()}),n("saved",1200),b(T.slide,T.index,T.el)}catch(se){T.el.textContent=T.was,n(`could not save the label: ${String(se.message||se).slice(0,80)}`,3e3)}}}function V(T,{sec:F,slide:se}){S&&E();let _e=$(F,T);if(!_e)return;let Te=xs(F,_e),l=_d(_e,T);if(l===null)return;S={el:T,original:T.innerHTML,slide:se,index:Te,path:l},T.setAttribute("contenteditable","true"),T.classList.add("dl-editing"),T.focus();let d=document.createRange();d.selectNodeContents(T),d.collapse(!1);let G=window.getSelection();G.removeAllRanges(),G.addRange(d),a("info",`editing slide ${se} element #${Te} inline`)}e.addEventListener("dblclick",T=>{if(!c())return;let F=y(T.target);if(!F||F.sec.hasAttribute("data-markdown-removed")||!s.elementEditOn?.())return;let se=T.target?.closest?.(xi);if(se&&F.sec.contains(se)&&!se.closest(".terminal, aside, [data-chart]")){T.preventDefault(),re(se,F);return}let _e=Ei(T.target,F.sec);if(_e){T.preventDefault(),ce(_e,F);return}let Te=Ro(T.target,F.sec);Te&&(T.preventDefault(),V(Te,F))}),e.addEventListener("keydown",T=>{if(!(!S||T.target!==S.el)){if(T.stopPropagation(),S.code){T.key==="Enter"&&(T.metaKey||T.ctrlKey)?(T.preventDefault(),E()):T.key==="Escape"?(T.preventDefault(),L()):T.key==="Tab"&&(T.preventDefault(),document.execCommand("insertText",!1," "));return}T.key==="Enter"&&!T.shiftKey?(T.preventDefault(),E()):T.key==="Escape"?(T.preventDefault(),L()):(T.metaKey||T.ctrlKey)&&!T.altKey&&P[T.key?.toLowerCase?.()]&&(T.preventDefault(),pe(P[T.key.toLowerCase()]))}},!0),e.addEventListener("focusout",T=>{S&&T.target===S.el&&E()}),e.addEventListener("dragover",T=>{!c()||!Array.from(T.dataTransfer?.types??[]).includes("Files")||(T.preventDefault(),T.dataTransfer.dropEffect="copy",e.classList.add("dl-dropping"))}),e.addEventListener("dragleave",T=>{(T.target===e||!e.contains(T.relatedTarget))&&e.classList.remove("dl-dropping")}),e.addEventListener("drop",async T=>{if(e.classList.remove("dl-dropping"),!c())return;let F=Ld(T.dataTransfer?.files);if(!F.length)return;T.preventDefault();let se=y(document.elementFromPoint(T.clientX,T.clientY))??y(t._sections[t.state.slide-1]);if(!se)return;let _e=$(se.sec,document.elementFromPoint(T.clientX,T.clientY)),Te=_e&&!_e.matches("aside")?xs(se.sec,_e):null;await Z(F,se,Te)});async function Z(T,F,se){let _e=(async()=>{for(let Te of T)try{let l=await fetch(h()+"/deck/edit/asset",{method:"POST",headers:{"content-type":Te.type,"x-decklight-name":Te.name},body:Te}),d=await l.json().catch(()=>({}));if(!l.ok)throw new Error(d.error||String(l.status));let G=await f("/deck/edit/element/image",{slide:F.slide,index:se,src:d.src,alt:Bm(Te.name)});Number.isInteger(G.index)&&(se=G.index),n(`${Te.name} added to slide ${F.slide} as ${d.src} \u2014 reloading`,2200)}catch(l){n(`could not add ${Te.name}: ${String(l.message||l).slice(0,80)}`,3200)}})();s.trackWrite?.(_e),await _e}return{editing:()=>!!S,editInline(T){if(!c())return!1;let F=y(T);if(!F||F.sec.hasAttribute("data-markdown-removed"))return!1;let se=T.closest?.(xi);if(se&&F.sec.contains(se)&&!se.closest(".terminal, aside, [data-chart]"))return re(se,F),!0;let _e=Ei(T,F.sec);if(_e)return ce(_e,F),!0;let Te=Ro(T,F.sec);return Te?(V(Te,F),!0):!1},addPictures(T,{afterIndex:F=null}={}){if(!c())return Promise.resolve();let se=Ld(T);if(!se.length)return n("that is not a picture \u2014 PNG, JPEG, GIF, WebP, SVG or AVIF",3e3),Promise.resolve();let _e=y(t._sections[t.state.slide-1]);return _e?Z(se,_e,F):Promise.resolve()}}}Se();Ae();var Fm=[{id:"text",label:"Text",key:"\u23CE",title:"select some text and press Enter, or double-click it"},{id:"picture",label:"Picture",key:"",title:"add a picture (or drop one onto the slide)"},{id:"layout",label:"Layout",key:"",title:"cycle this slide's layout (\u21E7-click backwards)"},{id:"notes",label:"Notes",key:"S",title:"edit the speaker notes"},{id:"slide",label:"Slide \u25BE",key:"",title:"new, duplicate, move or delete this slide"},{id:"undo",label:"Undo",key:zt,title:"take the last edit back"},{id:"redo",label:"Redo",key:Ao,title:"put it back"},{id:"lock",label:"Lock",key:"",title:"lock the deck: nothing changes the file until you unlock it"}];function Rd({root:e,instance:t,editmode:n,authoring:s,toast:a,debugLog:c=()=>{},toggleEditor:h,cycleLayout:f,deckHistory:g,enabled:b=()=>!0}){let y=null,$=null,S=null,A=null,E=null,L=vi(e),P=hd(e),j="decklight-editbar-hidden:"+location.pathname,U=!1;U=Nn(j)==="1";let oe=()=>!!document.fullscreenElement,pe=()=>n.elementEditOn()&&b(),D=()=>pe()&&!U&&!oe();function z(K){U=K,yn(j,K?"1":null),fe(),a(K?"the bar is hidden \u2014 editing stays on; Show the bar in the palette brings it back":"the bar is back",2600)}document.addEventListener("fullscreenchange",()=>fe());let Ce=K=>!!K?.closest?.(".decklight-narr, .decklight-ctxmenu, .decklight-palette, .decklight-editbar, .decklight-touch-controls, .decklight-controls");function ee(){return t._sections[t.state.slide-1]?.getAttribute("data-layout")||"auto"}function re(){if(!y){y=document.createElement("div"),y.className="decklight-editbar",y.setAttribute("role","toolbar"),y.setAttribute("aria-label","Editing"),y.append(de());for(let K of Fm){let ue=document.createElement("button");ue.type="button",ue.className=`eb-btn eb-${K.id}`,ue.title=K.title,ue.dataset.action=K.id;let at=document.createElement("span");if(at.className="eb-label",at.textContent=K.label,ue.append(at),K.key){let N=document.createElement("kbd");N.className="eb-key",N.textContent=K.key,ue.append(N)}ue.addEventListener("mousedown",N=>N.preventDefault()),ue.addEventListener("click",N=>{N.stopPropagation(),Z(K.id,ue,N)}),y.append(ue)}e.appendChild(y),ce(ie()),S=document.createElement("input"),S.type="file",S.accept="image/*",S.multiple=!0,S.className="eb-file",S.setAttribute("aria-label","picture to add"),S.addEventListener("change",()=>{let K=Array.from(S.files??[]);S.value="",K.length&&s.addPictures(K,{afterIndex:A?.index??null})}),y.append(S),V()}}let le="decklight-editbar-at:"+location.pathname;function ie(){let K=er(le);return K&&Number.isFinite(K.fx)&&Number.isFinite(K.fy)?K:null}function I(K){K?xr(le,K):yn(le,null)}function ce(K){if(!y)return;if(!K){y.classList.remove("eb-moved"),y.style.left="",y.style.top="";return}let ue=e.getBoundingClientRect(),at=y.getBoundingClientRect(),N=at.width||1,ft=at.height||1,M=Math.min(Math.max(K.fx*ue.width-N/2,4),Math.max(4,ue.width-N-4)),H=Math.min(Math.max(K.fy*ue.height-ft/2,4),Math.max(4,ue.height-ft-4));y.classList.add("eb-moved"),y.style.left=`${M}px`,y.style.top=`${H}px`}function de(){let K=document.createElement("span");K.className="eb-grip",K.setAttribute("role","button"),K.setAttribute("aria-label","move the bar"),K.title="drag to move the bar \xB7 double-click to put it back",K.textContent="\u283F";let ue=null,at=ft=>{if(!ue||ft.pointerId!==ue.id)return;let M=e.getBoundingClientRect(),H=y.getBoundingClientRect(),te=Math.min(Math.max(ft.clientX-M.left-ue.dx,4),Math.max(4,M.width-H.width-4)),we=Math.min(Math.max(ft.clientY-M.top-ue.dy,4),Math.max(4,M.height-H.height-4));y.classList.add("eb-moved"),y.style.left=`${te}px`,y.style.top=`${we}px`},N=ft=>{if(!ue||ft.pointerId!==ue.id)return;ue=null,window.removeEventListener("pointermove",at),window.removeEventListener("pointerup",N),window.removeEventListener("pointercancel",N),y.classList.remove("eb-dragging");let M=e.getBoundingClientRect(),H=y.getBoundingClientRect();y.classList.contains("eb-moved")&&I({fx:(H.left-M.left+H.width/2)/M.width,fy:(H.top-M.top+H.height/2)/M.height})};return K.addEventListener("pointerdown",ft=>{if(ft.button!==0)return;ft.preventDefault();let M=y.getBoundingClientRect();ue={id:ft.pointerId,dx:ft.clientX-M.left,dy:ft.clientY-M.top},y.classList.add("eb-dragging"),window.addEventListener("pointermove",at),window.addEventListener("pointerup",N),window.addEventListener("pointercancel",N)}),K.addEventListener("dblclick",ft=>{ft.preventDefault(),I(null),ce(null)}),K.addEventListener("mousedown",ft=>ft.preventDefault()),K}window.addEventListener("resize",()=>{y?.classList.contains("eb-moved")&&ce(ie())});function Ie(){J(),y?.remove(),y=null,S=null}function V(){if(!y)return;let K=y.querySelector(".eb-layout .eb-label");K&&(K.textContent=`Layout \xB7 ${ee()}`)}function Z(K,ue,at=null){switch(K){case"text":{let N=A&&T(A);N?s.editInline(N):a("double-click any text to edit it \u2014 or click it, then press \u23CE",3200);break}case"picture":S?.click();break;case"layout":f(at?.shiftKey?-1:1),V();break;case"notes":h();break;case"slide":{let N=ue.getBoundingClientRect(),ft={sec:t._sections[t.state.slide-1],slide:t.state.slide,index:null,top:null,clicked:null,fromBar:!0};n.openElementMenuAt(N.left,N.top-8,ft,"slide",{above:!0});break}case"undo":g("undo");break;case"redo":g("redo");break;case"lock":n.toggleLock(!0);break;default:break}}function T(K){let ue=K.clicked?.closest?.(xi);return ue&&K.sec.contains(ue)?ue:Ei(K.clicked,K.sec)??Ro(K.clicked,K.sec)??Ro(K.top,K.sec)}let F=K=>K.node??K.top;function se(){if(P.place(),!A||!$)return;let K=F(A).getBoundingClientRect(),ue=e.getBoundingClientRect();$.style.left=`${K.right-ue.left-4}px`,$.style.top=`${K.top-ue.top-10}px`}let _e=new Set,Te=()=>{for(let K of _e)K(A)};function l(K){J({quiet:!0}),K.node??=Os(K.top,K.clicked),A=K,K.node===K.top?K.top.classList.add("dl-selected"):P.on(K.node),$=document.createElement("button"),$.type="button",$.className="dl-handle",$.title="what you can do with this element",$.textContent="\u22EF",$.addEventListener("mousedown",ue=>ue.preventDefault()),$.addEventListener("click",ue=>{ue.stopPropagation(),n.openElementMenuAt(ue.clientX,ue.clientY,A)}),e.appendChild($),se(),be(),c("edit",`selected slide ${K.slide} element #${K.index}${K.node!==K.top?` \u203A <${K.node.tagName.toLowerCase()}>`:""}`),Te()}let d=0,G="";function be(){cancelAnimationFrame(d);let K=()=>{if(!A)return;let ue=F(A).getBoundingClientRect(),at=`${ue.left},${ue.top},${ue.width},${ue.height}`;at!==G&&(G=at,se()),d=requestAnimationFrame(K)};d=requestAnimationFrame(K)}function J({quiet:K=!1}={}){cancelAnimationFrame(d),G="";let ue=!!A;A?.top.classList.remove("dl-selected"),A=null,P.off(),$?.remove(),$=null,ue&&!K&&Te()}function Qe(K){E!==K&&(E?.classList.remove("dl-hover"),E=K,E?.classList.add("dl-hover"))}e.addEventListener("click",K=>{if(!D()||s.editing()||Ce(K.target))return;let ue=n.elementTargetOf(K.target);ue?.top?A?.node!==Os(ue.top,ue.clicked)&&l(ue):J()}),e.addEventListener("mousemove",K=>{if(!D()||Ce(K.target)||e.classList.contains("dl-picking")){Qe(null),L.hide();return}let ue=K.target.closest?.("section"),at=ue?ks(ue,K.target):null,N=at?Os(at,K.target):null;N&&wi(N)?(Qe(null),L.show(N,{dim:!0})):(L.hide(),Qe(at))}),e.addEventListener("mouseleave",()=>{Qe(null),L.hide()}),window.addEventListener("resize",se),t.on("slide",()=>{J(),V(),L.hide()}),t.on("build",se);function ot(K){if(!D()||!A||s.editing())return!1;if(K.key==="Enter"&&!K.metaKey&&!K.ctrlKey&&!K.altKey){let ue=T(A);if(ue)s.editInline(ue),J();else{let at=F(A).getBoundingClientRect();n.openElementMenuAt(at.left+12,at.top+12,A)}return!0}if(K.key==="Backspace"||K.key==="Delete"){let ue=A;return J(),n.removeElement(ue),!0}return K.key==="Escape"?(J(),!0):!1}function fe(){D()?re():Ie(),e.classList.toggle("dl-editmode",pe())}return n.onElementEditChange(fe),{sync:fe,keydown:ot,refresh:V,selected:()=>A,isOpen:()=>!!y,selectNode(K,{exact:ue=!1}={}){let at=n.elementTargetOf(K);return at?.top?(ue&&at.top.contains(K)&&(at.node=K),l(at),!0):!1},deselect:()=>J(),onSelect:K=>(_e.add(K),()=>_e.delete(K)),hidden:()=>U,toggleHidden:()=>z(!U)}}Se();Ae();function _a(e){let t=e?.querySelector?.(":scope > aside.sources");if(!t)return null;let n=[],s=[...t.querySelectorAll("dt")];for(let c of s){let h=c.nextElementSibling;h&&h.tagName==="DD"&&n.push([c.textContent.trim(),h.textContent.trim()])}let a=[...t.querySelectorAll("a[href]")].map(c=>{let f=(c.closest("li")??c).textContent.replace(/\s+/g," ").trim(),g=c.textContent.replace(/\s+/g," ").trim();return{href:c.getAttribute("href"),title:g,note:f.slice(g.length).replace(/^[\s—–-]+/,"")}});return n.length||a.length?{facts:n,links:a}:null}function Id({root:e,overlays:t,reflow:n,sectionAt:s,slideOf:a,editmode:c,toast:h}){let f=ys({root:e,reflow:()=>n?.(),getEl:()=>g,closeLabel:"close (esc)",name:"Sources",open:()=>{g||re()},close:()=>{g&&L()},available:()=>A()}),g=null,b=null,y=!1,$=null,S=()=>!!b,A=()=>c?.()?.available()===!0,E=()=>!!g,L=()=>{g?.remove(),g=null,b=null,$&&(window.removeEventListener("resize",$),$=null),f.release()},P=()=>_a(s(a()));function j(){g||(g=document.createElement("div"),g.className="decklight-narr decklight-dockable decklight-sources",g.innerHTML='<div class="narr-card"></div>',e.appendChild(g),f.reserveGutter(),$=()=>f.reserveGutter(),window.addEventListener("resize",$))}function U(ie){let I=document.createElement("div");return I.className="narr-head",I.append(Object.assign(document.createElement("span"),{className:"src-heading",textContent:ie})),I.append(f.controls(L)),f.wireHeader(I),I}let oe=(ie,I,ce,de=!1)=>{let Ie=document.createElement("input");return Ie.className="narr-input src-field"+(de?" src-wide":""),Ie.value=ie??"",Ie.placeholder=I,Ie.addEventListener("input",()=>ce(Ie.value)),Ie.addEventListener("keydown",V=>{V.key==="Escape"&&!V.isComposing&&(V.preventDefault(),V.stopPropagation(),L()),V.key==="Enter"&&!V.isComposing&&(V.preventDefault(),V.stopPropagation(),ee())}),Ie},pe=ie=>{let I=document.createElement("button");return I.className="src-drop",I.type="button",I.title="remove",I.textContent="\u2715",I.addEventListener("click",ie),I};function D(){let ie=g.querySelector(".narr-card");ie.textContent="",ie.append(U(`sources \u2014 slide ${a()}`));let I=de=>{let Ie=document.createElement("div");Ie.className="narr-group",Ie.textContent=de,ie.append(Ie)};I("named facts"),b.facts.forEach((de,Ie)=>{let V=document.createElement("div");V.className="src-edit-row",V.append(oe(de[0],"name",Z=>{de[0]=Z})),V.append(oe(de[1],"value",Z=>{de[1]=Z})),V.append(pe(()=>{b.facts.splice(Ie,1),D()})),ie.append(V)}),ie.append(z("+ a fact",()=>{b.facts.push(["",""]),D()})),I("links"),b.links.forEach((de,Ie)=>{let V=document.createElement("div");V.className="src-edit-row",V.append(oe(de.title,"what it is",Z=>{de.title=Z})),V.append(oe(de.href,"https://\u2026",Z=>{de.href=Z},!0)),V.append(oe(de.note,"a few words (optional)",Z=>{de.note=Z})),V.append(pe(()=>{b.links.splice(Ie,1),D()})),ie.append(V)}),ie.append(z("+ a link",()=>{b.links.push({title:"",href:"",note:""}),D()}));let ce=document.createElement("div");ce.className="narr-head",ce.textContent="\u23CE saves \xB7 esc leaves it as it was",ie.append(ce),ie.querySelector('.src-field[value=""], .src-field:placeholder-shown')?.focus()}function z(ie,I){let ce=document.createElement("button");return ce.className="narr-row src-add",ce.type="button",ce.textContent=ie,ce.addEventListener("click",I),ce}function Ce(){if(!A()){h("sources are written in write mode \u2014 decklight <deck.html>");return}let ie=P()??{facts:[],links:[]};b={facts:ie.facts.map(([I,ce])=>[I,ce]),links:ie.links.map(I=>({...I}))},!b.facts.length&&!b.links.length&&b.links.push({title:"",href:"",note:""}),g||j(),D()}async function ee(){if(y)return;y=!0;let ie=a();try{let I=await fetch(c().base()+"/deck/edit/slide/sources",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:ie,facts:b.facts,links:b.links})}),ce=await I.json().catch(()=>({}));if(!I.ok||!ce.ok)throw new Error(ce.error||`the edit server said ${I.status}`);L();let de=ce.dropped?.length?`. ${ce.dropped.join(", ")} was not written \u2014 a reference is a link somebody can follow, not something that runs`:"";h((ce.changed?`sources saved on slide ${ie} \u2014 ${zt} takes it back`:"nothing changed")+de,de?6e3:3e3)}catch(I){h(`could not save \u2014 ${I.message}`)}finally{y=!1}}function re(){t.opening(),Ce()}function le(ie){return ie.key==="Escape"?(L(),!0):ie.key==="Enter"?(ee(),!0):!1}return t.register({isOpen:E,close:L,keydown:le,modal:()=>S(),panel:!0}),{edit:re,close:L,isOpen:E,has:()=>!!P(),canEdit:A}}Se();Ae();Se();Ae();var $i=Object.freeze({bullets:5,paragraphs:2,paragraphWords:50,words:80}),qm="aside, script, style, template, pre, svg, canvas, .chart, .terminal, table, .slide-bg, .decklight-hero-logo, h1, h2, h3, h4, h5, h6, .pin-title",Pd=e=>(String(e??"").match(/[\p{L}\p{N}][\p{L}\p{N}'’.-]*/gu)??[]).length,Dd=(e,t)=>{for(let n=e;n&&n!==t;n=n.parentElement)if(n.matches?.(qm))return!0;return!1};function jm(e){let t=0,n=e.ownerDocument.createTreeWalker(e,4);for(let s=n.nextNode();s;s=n.nextNode())Dd(s.parentElement,e.parentElement)||(t+=Pd(s.data));return t}function Hm(e,t=1){let n=c=>[...e.matches(c)?[e]:[],...e.querySelectorAll(c)].filter(h=>!Dd(h,e.parentElement)),s=Math.ceil(n("li").length/t),a=n("p").filter(c=>!c.closest("li"));return{bullets:s,paragraphs:a.filter(c=>!c.matches(".subtitle, .pin-subtitle")).length,longest:a.reduce((c,h)=>Math.max(c,Pd(h.textContent)),0),words:Math.ceil(jm(e)/t)}}function zm(e){let t=e.getAttribute("data-layout")||"";if(/^split/.test(t)&&!e.hasAttribute("data-template")){let n=e.querySelector(":scope > .split-columns");if(n)return[{el:n,halves:2}];let s=[...e.children].filter(a=>!a.matches("h1, h2, .subtitle, aside, script, style, .decklight-hero-logo, .slide-bg, .split-footer, .pin-title, .pin-subtitle"));if(s.length>=2)return s.slice(0,2).map(a=>({el:a,halves:1}))}return[{el:e,halves:1}]}function Um(e){let t=(e.style?.fontSize||"").trim(),n=/^(\d*\.?\d+)(em|%)$/.exec(t);return n&&Number(n[1])/(n[2]==="%"?100:1)<1?t:null}function Io(e){if(!e||e.hasAttribute("data-dense-ok"))return[];let t=zm(e),n=t.length>1?" in one column":"",s=[],a=y=>Math.max(...t.map($=>$.m[y]));for(let y of t)y.m=Hm(y.el,y.halves);let c=a("bullets");c>$i.bullets&&s.push(`${c} bullets${n}`);let h=a("paragraphs");h>$i.paragraphs&&s.push(`${h} paragraphs${n}`);let f=a("longest");f>$i.paragraphWords&&s.push(`a ${f}-word paragraph`);let g=a("words");g>$i.words&&s.push(`${g} words${n}`);let b=Um(e);return b&&s.push(`type shrunk to ${b}`),s}function Bd(e){for(let t of e){let n=Io(t);n.length?t.setAttribute("data-dense",n.join(" \xB7 ")):t.removeAttribute("data-dense")}}Se();Ae();function Ls(e,t,n){let a=(e.querySelector("h1, h2, h3")?.textContent||"").replace(/\s+/g," ").trim(),c=n.slice(0,60).replace(/[\uD800-\uDBFF]$/,"");return a||c||`slide ${t+1}`}function Si(e){return[...e.children].filter(n=>!n.matches("aside, script, style")).map(n=>n.textContent).join(" ").replace(/\s+/g," ").trim()}function Fd({sections:e,modules:t=[],skipModule:n=-1}){let s=e.map((c,h)=>{let f=Si(c),g=Ls(c,h,f);return{slide:h+1,title:g,titleLc:g.toLowerCase(),haystack:f.toLowerCase()}}),a=t.map((c,h)=>({module:h,title:c.title,href:c.href,titleLc:(c.title||"").toLowerCase(),haystack:(c.title||"").toLowerCase()})).filter(c=>c.module!==n);return[...s,...a]}function qd(e,t){let n=String(t??"").toLowerCase().split(/\s+/).filter(Boolean),s=[],a=[];for(let c of e){let h=c.titleLc??String(c.title??"").toLowerCase();n.every(f=>h.includes(f))?s.push(c):n.every(f=>c.haystack.includes(f))&&a.push(c)}return[...s,...a]}Se();Ae();var Ai=/^[a-z][a-z0-9-]{0,40}$/i;function Ti(e,t={}){let n=new Map;e.querySelectorAll("svg [data-concept]").forEach(s=>{let a=s.getAttribute("data-concept");!a||!Ai.test(a)||n.set(a,(n.get(a)??0)+1)});for(let s of Object.keys(t))n.has(s)||n.set(s,0);return[...n].map(([s,a])=>({name:s,shapes:a}))}var Hd="rect, circle, ellipse, polygon, path",Gm="defs, marker, clipPath, mask, pattern, symbol, .draw-head, .draw-mask, [data-ds-injected], .chart, .terminal";function Ci(e){return[...e.querySelectorAll(":scope > section svg")].flatMap(t=>[...t.querySelectorAll(Hd)]).filter(t=>!t.closest(Gm))}function zd(e){let t=e.closest("svg"),n=e.closest("[data-concept]");return n&&n!==t&&t?.contains(n)?n:null}var po=e=>zd(e)?.getAttribute("data-concept")||null,Po=e=>{let t=parseFloat(String(e??"").trim().split(/[\s,]+/)[0]);return Number.isFinite(t)?t:null};function Km(e){let t=n=>Po(e.getAttribute(n));switch(e.tagName.toLowerCase()){case"rect":return t("width")!==null&&t("height")!==null?{x:t("x")??0,y:t("y")??0,w:t("width"),h:t("height")}:null;case"circle":return t("r")!==null?{x:(t("cx")??0)-t("r"),y:(t("cy")??0)-t("r"),w:2*t("r"),h:2*t("r")}:null;case"ellipse":return t("rx")!==null&&t("ry")!==null?{x:(t("cx")??0)-t("rx"),y:(t("cy")??0)-t("ry"),w:2*t("rx"),h:2*t("ry")}:null;default:return null}}function Wm(e){let t=e.querySelector("tspan"),n=Po(e.getAttribute("x"))??Po(t?.getAttribute("x")),s=Po(e.getAttribute("y"))??Po(t?.getAttribute("y"));return n===null||s===null?null:{x:n,y:s}}var Do=e=>String(e??"").replace(/\s+/g," ").trim();function Ms(e){let t=e.parentElement;if(!t)return"";let n=c=>[...c.children].filter(h=>h.tagName.toLowerCase()==="text");if(t.tagName.toLowerCase()==="g"&&[...t.children].filter(c=>c.matches(Hd)).length===1){let c=Do(n(t).map(h=>h.textContent).join(" "));if(c)return c}let s=Km(e);if(s){let c=n(t).filter(h=>{let f=Wm(h);return f&&f.x>=s.x&&f.x<=s.x+s.w&&f.y>=s.y&&f.y<=s.y+s.h});if(c.length)return Do(c.map(h=>h.textContent).join(" "))}let a=e.nextElementSibling;return a?.tagName.toLowerCase()==="text"?Do(a.textContent):""}var Vm=(e,t)=>!!e&&e.toLowerCase()===t.toLowerCase(),Jm=e=>{let t=e.closest("section");return t?[...t.parentElement.children].filter(n=>n.tagName==="SECTION").indexOf(t)+1:0};function Ud(e,t,n){let s=Ms(t);return s?Ci(e).filter(a=>a!==t&&po(a)!==n&&Vm(Ms(a),s)):[]}function Ym(e){let t=Do(e).toLowerCase().normalize("NFKD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,41).replace(/-+$/,"");return t?Ai.test(t)?t:Ai.test(`c-${t}`.slice(0,41))?`c-${t}`.slice(0,41):null:null}function Bo(e,{paintOf:t=n=>getComputedStyle(n).fill}={}){let n=new Map;for(let a of Ci(e)){let c=Ms(a);if(!c||c.length>40||!/\p{L}/u.test(c))continue;let h=c.toLowerCase();n.has(h)||n.set(h,{label:c,shapes:[]}),n.get(h).shapes.push(a)}let s=[];for(let{label:a,shapes:c}of n.values()){let h=[...new Set(c.map(Jm))].filter(Boolean).sort((y,$)=>y-$);if(h.length<2)continue;let f=new Set(c.map(po));if(f.size===1&&!f.has(null))continue;let g=new Set(c.map(y=>t(y)).filter(y=>y&&y!=="none")).size;if(g<2)continue;let b=[...f].find(Boolean)??Ym(a);b&&s.push({label:a,name:b,shapes:c,slides:h,colours:g})}return s.sort((a,c)=>c.slides.length-a.slides.length||a.slides[0]-c.slides[0])}function Gd(e,t){let n=Bo(t);if(!n.length){e.removeAttribute("data-concept-hints");return}e.setAttribute("data-concept-hints",n.map(s=>[encodeURIComponent(s.label),s.slides.join(","),s.name,s.colours].join("~")).join("|"))}function jd(e){let t=[];return{show(n){this.clear();for(let s of n){let a=s.getBoundingClientRect();if(!a.width&&!a.height)continue;let c=Object.assign(document.createElement("div"),{className:"dl-frame dl-concept-outline"});Object.assign(c.style,{left:`${a.left-4}px`,top:`${a.top-4}px`,width:`${a.width+8}px`,height:`${a.height+8}px`}),e.appendChild(c),t.push(c)}return t.length},clear(){for(let n of t)n.remove();t=[]}}}function Kd({root:e,base:t,toast:n,stage:s,concepts:a,apply:c,pageId:h=()=>"",debugLog:f=()=>{},tools:g=()=>null,slide:b=()=>1,goto:y=()=>{}}){let $=null,S=[],A=0,E=!1,L=null,P=!1,j=new Set,U=jd(e),oe=jd(e),pe=()=>$?.querySelector(".narr-card"),D=()=>[...s().querySelectorAll(":scope > section")],z=be=>{let J=a()?.[be];return typeof J=="number"?{slot:J,how:"pinned"}:typeof J=="string"?{slot:null,how:"custom",css:J}:{slot:ei(be),how:"auto"}},Ce=be=>{let J=D(),Qe=new Set;return s().querySelectorAll(`svg [data-concept="${CSS.escape(be)}"]`).forEach(ot=>{let fe=J.indexOf(ot.closest("section"));fe>=0&&Qe.add(fe+1)}),[...Qe].sort((ot,fe)=>ot-fe)},ee=be=>{let J=D()[b()-1];return!J||!be?[]:Ci(s()).filter(Qe=>Qe.closest("section")===J&&po(Qe)===be)},re=be=>be.length?be.length===1?`slide ${be[0]}`:`slides ${be.join(", ")}`:"on no slide yet";function le(){let be=pe();if(!be)return;S=Ti(s(),a());let J='<div class="narr-head">concept colors \u2014 one colour per idea, on every slide</div>';S.length||(J+='<div class="rec-line">No diagram on this deck names a concept yet. Make one below, then click the shapes that are it.</div>'),S.forEach((ot,fe)=>{let K=z(ot.name),ue=Cs(ot.name,a()),at=[1,2,3,4,5,6].map(ft=>`<button type="button" class="cc-slot${K.slot===ft?" cc-on":""}" data-i="${fe}" data-slot="${ft}" style="background: var(--d-fill-${ft})" title="Fill ${ft}" aria-label="${Et(ot.name)} \u2192 fill ${ft}" aria-pressed="${K.slot===ft}"></button>`).join(""),N=K.how==="pinned"?`pinned to fill ${K.slot}`:K.how==="custom"?`custom \xB7 ${Et(K.css)}`:`fill ${K.slot} by its name`;J+=`<div class="narr-row cc-row" data-i="${fe}" data-name="${Et(ot.name)}"><span class="cc-swatch" style="background: ${Et(ue)}"></span><span class="narr-row-label">${Et(ot.name)} <span class="narr-flavor">${ot.shapes} shape${ot.shapes===1?"":"s"} \xB7 ${re(Ce(ot.name))} \xB7 ${N}</span></span><span class="cc-slots">${at}<button type="button" class="cc-auto${K.how==="auto"?" cc-on":""}" data-i="${fe}" title="no pin \u2014 the name picks its own slot" aria-pressed="${K.how==="auto"}">auto</button><button type="button" class="cc-pick" data-i="${fe}" title="click shapes on the slides to put them in \u201C${Et(ot.name)}\u201D, or take them out">pick shapes</button></span></div>`}),J+=`<div class="narr-row cc-row cc-new" data-i="${S.length}">`+(P?'<input class="narr-input cc-new-name" type="text" placeholder="a name \u2014 agent, tools, data\u2026" aria-label="New concept name" spellcheck="false">':'<span class="narr-row-label">New concept\u2026 <span class="narr-flavor">name it, then click its shapes</span></span>')+"</div>",J+='<div class="rec-hint">\u2191/\u2193 \xB7 \u23CE picks shapes \xB7 \u2190/\u2192 the slides it is on \xB7 1\u20136 pins the slot, 0 takes the pin off \xB7 N new \xB7 Esc closes</div>',be.innerHTML=J,be.querySelectorAll(".cc-row").forEach(ot=>ot.addEventListener("mouseenter",()=>ie(Number(ot.dataset.i)))),be.querySelectorAll(".cc-slot").forEach(ot=>ot.addEventListener("click",()=>{ie(Number(ot.dataset.i)),I(Number(ot.dataset.slot))})),be.querySelectorAll(".cc-auto").forEach(ot=>ot.addEventListener("click",()=>{ie(Number(ot.dataset.i)),I(null)})),be.querySelectorAll(".cc-pick").forEach(ot=>ot.addEventListener("click",fe=>{fe.stopPropagation(),F(S[Number(ot.dataset.i)].name)})),be.querySelector(".cc-new")?.addEventListener("click",()=>{P||de()});let Qe=be.querySelector(".cc-new-name");Qe&&(Qe.addEventListener("keydown",ot=>{if(ot.stopPropagation(),ot.key==="Enter"){ot.preventDefault();let fe=Qe.value.trim();if(!Ai.test(fe)){n("a concept is a name: letters, digits and dashes, starting with a letter",3200);return}P=!1,F(fe)}else ot.key==="Escape"&&(ot.preventDefault(),P=!1,le())}),setTimeout(()=>Qe.focus(),0)),ie(Math.min(A,S.length))}function ie(be){A=Math.max(0,Math.min(be,S.length)),vn([...pe()?.querySelectorAll(".cc-row")??[]],A,"narr-sel"),U.show(ee(S[A]?.name))}async function I(be){let J=S[A];if(!J||E)return;let Qe={...a()??{}},ot={...Qe};if(be===null?delete ot[J.name]:ot[J.name]=be,JSON.stringify(ot)!==JSON.stringify(Qe)){E=!0,c(ot),le();try{let fe=await fetch(`${t()}/deck/edit/concepts`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({concepts:ot,quiet:!0,from:h()})}),K=await fe.json().catch(()=>({}));if(!fe.ok||!K.ok)throw new Error(K.error||`the edit server answered ${fe.status}`);f("concepts",`${J.name} \u2192 ${be===null?"auto":`fill ${be}`}`),n(be===null?`${J.name}: pin taken off \u2014 fill ${ei(J.name)} by its name \xB7 ${zt} takes it back`:`${J.name} \u2192 fill ${be}, deck-wide \xB7 ${zt} takes it back`,2600)}catch(fe){c(Qe),le(),n(`concept not saved: ${String(fe.message||fe).slice(0,90)}`,3400)}finally{E=!1}}}function ce(be){let J=S[A]?.name;if(!J)return;let Qe=Ce(J);if(!Qe.length){n(`\u201C${J}\u201D is on no slide yet \u2014 \u23CE to pick its shapes`,2200);return}let ot=b(),fe=be>0?Qe.find(K=>K>ot)??Qe[0]:[...Qe].reverse().find(K=>K<ot)??Qe.at(-1);y(fe),U.clear(),setTimeout(()=>{$&&ie(A)},450)}function de(){P=!0,A=S.length,le()}function Ie(be){let J=be?.closest?.("svg");if(!J||!J.closest("section")||!s().contains(J))return null;let Qe=Ci(s()),ot=be.closest("rect, circle, ellipse, polygon, path");if(ot&&Qe.includes(ot))return ot;let fe=be.closest("text");return fe?Qe.find(K=>K.closest("svg")===J&&Ms(K)&&Ms(K)===Do(fe.textContent)&&K.parentElement===fe.parentElement)??null:null}let V=be=>{if(!L)return;let J=Ie(be.target);J?oe.show([J]):oe.clear()},Z=async be=>{if(!L||be.target.closest?.(".decklight-concepts"))return;let J=Ie(be.target);if(!J)return;be.preventDefault(),be.stopPropagation();let Qe=L,ot=zd(J),fe=po(J)===Qe,K=g();if(!K)return;await K.attach([fe?ot??J:J],fe?null:Qe,{offer:!1});let ue=Ms(J);!fe&&ue&&!j.has(ue.toLowerCase())&&(j.add(ue.toLowerCase()),K.offerLookAlikes(J,Qe)),T()};function T(){let be=pe();if(!be||!L)return;let J=s().querySelectorAll(`svg [data-concept="${CSS.escape(L)}"]`).length;be.innerHTML=`<div class="cc-pickbar"><span class="cc-swatch" style="background: ${Et(Cs(L,a()))}"></span><span class="cc-pick-text">picking shapes for <b>${Et(L)}</b> \xB7 ${J} shape${J===1?"":"s"} \xB7 click a shape to put it in, click it again to take it out \xB7 \u2190/\u2192 slides</span><button type="button" class="cc-pick-done">Done</button></div>`,be.querySelector(".cc-pick-done").addEventListener("click",se),U.show(ee(L))}function F(be){$&&(L=be,$.classList.add("cc-picking"),document.addEventListener("click",Z,!0),document.addEventListener("pointermove",V,!0),T())}function se(){if(!L)return;let be=L;if(L=null,$?.classList.remove("cc-picking"),document.removeEventListener("click",Z,!0),document.removeEventListener("pointermove",V,!0),oe.clear(),!$)return;le();let J=S.findIndex(Qe=>Qe.name===be);J>=0&&ie(J)}function _e({select:be=null}={}){if($){be&&Te(be);return}if(t()===null){n("concept colors are set in write mode \u2014 decklight <deck.html>",3200);return}$=document.createElement("div"),$.className="decklight-narr decklight-record decklight-concepts",$.innerHTML='<div class="narr-card" role="listbox" aria-label="Concept colors"></div>',Qt($,l),e.appendChild($),A=0,P=!1,le(),be&&Te(be)}function Te(be){let J=S.findIndex(Qe=>Qe.name===be);J>=0&&ie(J)}function l(){L&&se(),$?.remove(),$=null,S=[],P=!1,U.clear(),oe.clear()}function d(be){return L?be.key==="Escape"||be.key==="Enter"?(se(),!0):be.key==="ArrowLeft"||be.key==="ArrowRight"||be.key==="PageUp"||be.key==="PageDown"||be.key===" "?(setTimeout(()=>{L&&T()},450),!1):!0:be.key==="Escape"?(l(),!0):be.key==="ArrowDown"?(ie(A+1),!0):be.key==="ArrowUp"?(ie(A-1),!0):be.key==="ArrowRight"?(ce(1),!0):be.key==="ArrowLeft"?(ce(-1),!0):be.key==="Enter"?(A>=S.length?de():F(S[A].name),!0):be.key==="n"||be.key==="N"?(de(),!0):/^[1-6]$/.test(be.key)?(I(Number(be.key)),!0):((be.key==="0"||be.key==="Backspace")&&I(null),!0)}function G(){$&&(L?T():P||le())}return{open:_e,close:l,keydown:d,refresh:G,isOpen:()=>!!$,modal:()=>!L,pick:be=>{_e(),$&&F(be)},picking:()=>L}}Se();Ae();function $s(e){let t=String(e??"").trim().toLowerCase(),n=t.match(/^#([0-9a-f]{3,8})$/);if(n){let s=n[1];if((s.length===3||s.length===4)&&(s=[...s].map(c=>c+c).join("")),s.length!==6&&s.length!==8)return null;let a=c=>parseInt(s.slice(c,c+2),16);return[a(0),a(2),a(4),s.length===8?a(6)/255:1]}if(n=t.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:[\s,/]+([\d.]+%?))?\s*\)$/),n){let s=n[4]==null?1:n[4].endsWith("%")?parseFloat(n[4])/100:parseFloat(n[4]);return[+n[1],+n[2],+n[3],s]}return t==="transparent"?[0,0,0,0]:null}function Vd(e,t){let n=e[3]??1;return[0,1,2].map(s=>Math.round(e[s]*n+t[s]*(1-n))).concat(1)}function Wd([e,t,n]){let s=a=>{let c=a/255;return c<=.03928?c/12.92:((c+.055)/1.055)**2.4};return .2126*s(e)+.7152*s(t)+.0722*s(n)}function Jd(e,t){let n=Wd(Vd(e,t)),s=Wd(t);return(Math.max(n,s)+.05)/(Math.min(n,s)+.05)}function Zm(e,t){return e>=24||e>=18.66&&Number(t)>=700}var Yd=(e,t)=>Zm(e,t)?3:4.5;function Fo([e,t,n]){return"#"+[e,t,n].map(s=>Math.round(s).toString(16).padStart(2,"0")).join("")}function Zd(e,t){let n=$s(e);if(!n||n[3]===0)return null;for(let[s,a]of t){let c=$s(a);if(c&&c[0]===n[0]&&c[1]===n[1]&&c[2]===n[2]&&Math.abs(c[3]-n[3])<.01)return s}return null}function Xd(e,t,n){let s=n||1;return{x:Math.round((e.left-t.left)/s),y:Math.round((e.top-t.top)/s),w:Math.round(e.width/s),h:Math.round(e.height/s)}}var Qd=(e,t,n)=>Math.round(100*Math.max(0,e.w)*Math.max(0,e.h)/Math.max(1,t*n));function eu(e){let t=String(e.fontFamily??"").split(",")[0].replace(/["']/g,"").trim()||"inherit",n=parseFloat(e.fontSize)||0,s=parseFloat(e.lineHeight),a=Number.isFinite(s)&&n?`/${+(s/n).toFixed(2)}`:"";return`${t} ${+n.toFixed(1)}${a} \xB7 ${e.fontWeight}`}function Oa(e){let t=Math.max(0,Math.round(e));return`${Math.floor(t/60)}:${String(t%60).padStart(2,"0")}`}function Xm(e){let t=String(e??"").match(/(rgba?\([^)]*\)|#[0-9a-f]{3,8}\b)/i);return t?$s(t[1]):null}function tu(e,{styleOf:t,stop:n,fallback:s=[255,255,255,1],seen:a={}}){let c=[];for(let f=e;f&&f.nodeType===1;f=f.parentElement){let g=t(f),b=$s(g.backgroundColor),y=g.backgroundImage&&g.backgroundImage!=="none"?g.backgroundImage:null;if(y&&(a.image=!0),(!b||b[3]===0)&&y){let $=Xm(y);$&&(b=[$[0],$[1],$[2],1])}if(b&&b[3]>0&&(c.push(b),b[3]>=1)||f===n)break}let h=c.length&&c[c.length-1][3]>=1?c.pop():s;for(;c.length;)h=Vd(c.pop(),h);return h}var nu=["--fg","--heading-color","--accent","--muted","--link","--bg","--bg-accent","--accent-contrast","--d-text","--d-accent","--d-stroke","--d-muted","--code-fg","--code-bg","--block-bg"],ru=/^--(ansi|hl|tm|term)-/;function su({root:e,overlays:t,toast:n,copyText:s,instance:a,stage:c,editmode:h,editbar:f,review:g,narration:b,sources:y,concepts:$=()=>null,brand:S=()=>null}){let A=ys({root:e,reflow:()=>a()._reflow?.(),getEl:()=>E,closeLabel:"close (I)",defaultMode:"right",name:"Inspector",open:()=>{E||T()},close:()=>{E&&V()}}),E=null,L=null,P=null,j=null,U=null,oe=null,pe=!1,D="info",z=null,Ce=!1,ee=vi(e),re={slide:0,data:null},le={slide:0,data:void 0},ie="",I=()=>a(),ce=()=>I().state.slide,de=Y=>I()._sections[Y-1],Ie=()=>!!E;function V(){ot(),Ke(),z=null,E?.remove(),E=null,L&&(window.removeEventListener("resize",L),L=null),j?.disconnect(),j=null,A.release()}let Z=Y=>Y?Y.node&&Y.top.contains(Y.node)?Y.node:Y.top:null;function T({tab:Y=null}={}){if(E&&!Y){V();return}if(!pe&&f()?.onSelect&&(pe=!0,f().onSelect(ve=>{U=ve,oe=Z(ve),E&&ae()})),Y&&(D=Y),E){U=f()?.selected?.()??U,oe=Z(U),ae();return}t.opening(),U=f()?.selected?.()??null,oe=Z(U),E=document.createElement("div"),E.className="decklight-narr decklight-dockable decklight-inspector",E.innerHTML='<div class="narr-card"></div>',E.addEventListener("click",ve=>ve.stopPropagation()),e.appendChild(E),A.reserveGutter(),L=()=>{A.reserveGutter(),clearTimeout(P),P=setTimeout(()=>{E&&ae()},120)},window.addEventListener("resize",L),j=new MutationObserver(()=>{E&&ae()}),j.observe(c(),{subtree:!0,attributes:!0,attributeFilter:["data-overflow","data-split-conflict"]}),ae()}let F=(Y,ve,Ne=null,ut=null,ht=null)=>({key:Y,value:ve,mark:Ne,extra:ut,look:ht});function se(){let Y=ce(),ve=de(Y),Ne=[];if(!ve)return Ne;let ut=ve.querySelector("h1, h2, h3");Ne.push(ut?F("title",Ls(ve,Y-1,""),null,ut.tagName.toLowerCase()):F("title",Ls(ve,Y-1,""),"warn","no heading"));let ht=ve.getAttribute("data-template");Ne.push(F("layout",[ve.getAttribute("data-layout")||"auto",ht].filter(Boolean).join(" \xB7 ")));let vt=I()._records[Y-1],mt=vt?.groups.length??0,Ue=mt?Xo(vt):[];Ne.push(F("builds",mt?`${mt} step${mt===1?"":"s"} \xB7 on ${I().state.step}`:"none",null,Ue.length?Ue.map((St,Vt)=>`${Vt+1} ${St}`).join(" \xB7 "):null));let Dt=Io(ve);Dt.length&&Ne.push(F("density","crowded","warn",Dt.join(" \xB7 ")));let Ct=ve.querySelector(":scope > aside.notes");if(Ct){let St=(Ct.textContent.match(/\S+/g)??[]).length,Vt=Qs(Ct.innerHTML).length-1,on=Vt>0&&Vt!==mt;Ne.push(F("notes",`${St} word${St===1?"":"s"}${Vt?` \xB7 ${Vt} \u27E8CLICK\u27E9`:""}`,on?"warn":null,on?`${Vt} \u27E8CLICK\u27E9 for ${mt} step${mt===1?"":"s"}`:null))}else Ne.push(F("notes","none"));let Pt=Number(ve.dataset.timing),Kt=Number(er("decklight-timings:"+location.pathname)?.[Y-1]),hn=[Pt>0&&`planned ${Oa(Pt)}`,Kt>0&&`rehearsed ${Oa(Kt)}`].filter(Boolean);Ne.push(F("time",hn.length?hn.join(" \xB7 "):"not planned",Pt>0&&Kt>Pt+5?"warn":null));let Xt=_e(ve);ve.hasAttribute("data-split-conflict")?Ne.push(F("fit","split layout fights a flex block","warn")):ve.hasAttribute("data-overflow")?Ne.push(F("fit",Xt?`clips by ${Xt}px`:"clips","warn")):Ne.push(F("fit","fits","ok"));let Mt=b()?.status?.();if(Mt){let St=!Mt.hasTracks&&!Mt.live?"no track":Mt.track?`${Mt.live?"live voice":"recorded"}${Mt.narrating?Mt.paused?" \xB7 paused":" \xB7 playing":""}`:"off";Ne.push(F("voice",St))}if(le.slide===Y&&le.data){let{open:St,resolved:Vt}=le.data;Ne.push(F("comments",St||Vt?`${St} open \xB7 ${Vt} resolved`:"none"))}let Wt=re.slide===Y?re.data:null;if(Wt){Ne.push(F("file",`${Wt.file} \xB7 lines ${Te(Wt.lines)}`));for(let St of Wt.findings)Ne.push(F("check",St.message,St.level==="error"||St.level==="warn"?"warn":null))}return Ne}function _e(Y){let ve=0;for(let Ne of[Y,...Y.querySelectorAll("pre, table, svg, ul, ol, blockquote")])Ne.closest(".terminal")||Ne.hasAttribute("data-scroll-ok")||getComputedStyle(Ne).overflowY!=="visible"&&(ve=Math.max(ve,Ne.scrollHeight-Ne.clientHeight));return ve>2?Math.round(ve):0}let Te=([Y,ve])=>Y===ve?`${Y}`:`${Y}\u2013${ve}`;function l(){let Y=oe,ve=Y.closest("section"),Ne=[];Ne.push(F("element",d(Y),null,Y===U.top?`block ${U.index+1}`:`inside block ${U.index+1}`));let ut=c(),ht=Xd(Y.getBoundingClientRect(),ut.getBoundingClientRect(),I()._scale),vt=parseFloat(ut.style.width)||I().config.width,mt=parseFloat(ut.style.height)||I().config.height;Ne.push(F("box",`x ${ht.x} y ${ht.y} \xB7 ${ht.w}\xD7${ht.h}`,null,`${Qd(ht,vt,mt)}% of the slide`));let Ue=getComputedStyle(Y);if(Y instanceof SVGElement&&!/^(svg|g|text|tspan)$/i.test(Y.tagName)){let St=Yt=>{let an=$s(Yt);return an&&an[3]>0?G(Yt,an):"none"},Vt=Yt=>{let an=$s(Yt);return an&&an[3]>0?Yt:null};if(Ne.push(F("fill",St(Ue.fill),null,null,Vt(Ue.fill)&&{fill:Ue.fill})),Y.closest("svg")&&/^(rect|circle|ellipse|polygon|path)$/i.test(Y.tagName)){let Yt=po(Y);Ne.push(F("concept",Yt??"none",null,Yt?"its colour is the concept\u2019s, on every slide":"Colors tab \u2192 Concept gives it one",Yt&&Vt(Ue.fill)?{fill:Ue.fill}:null))}let on=parseFloat(Ue.strokeWidth);Ne.push(F("stroke",St(Ue.stroke),null,St(Ue.stroke)!=="none"&&on?`${+on.toFixed(2)} wide`:null,Vt(Ue.stroke)&&{ring:Ue.stroke}))}if((Y.textContent??"").trim()){let Vt=Y instanceof SVGElement&&Y.tagName!=="svg"?Ue.fill:Ue.color,on=$s(Vt);if(Ne.push(F("type",eu(Ue),null,on?G(Vt,on):null,on&&on[3]>0?{fill:Vt}:null)),on){let Yt=$s(getComputedStyle(e).getPropertyValue("--bg")),an={},Cn=tu(Y,{styleOf:Ln=>getComputedStyle(Ln),stop:e,seen:an,fallback:Yt&&Yt[3]>=1?Yt:[255,255,255,1]}),wn=Jd(on,Cn),Nt=Yd(parseFloat(Ue.fontSize)||0,Ue.fontWeight);Ne.push(F("contrast",`${(Math.floor(wn*10)/10).toFixed(1)}:1`,wn>=Nt?"ok":"warn",`on ${an.image?"\u2248 ":""}${Fo(Cn)}${an.image?" (gradient)":""} \xB7 AA wants ${Nt}:1`,{ink:Vt,on:Fo(Cn),weight:Ue.fontWeight,family:Ue.fontFamily}))}}if(Ne.push(F("build",be(Y))),Y.tagName==="IMG"){let St=Y.getAttribute("src")??"",Vt=St.startsWith("data:")?"inline":St.split(/[?#]/)[0].split("/").pop()||"inline";Ne.push(F("image",`${Vt} \xB7 ${Y.naturalWidth}\xD7${Y.naturalHeight}`));let on=(Y.getAttribute("alt")??"").trim();Ne.push(F("alt",on||"missing",on?"ok":"warn"))}let Ct=Y.tagName==="svg"?Y:null;Ct?.getAttribute("viewBox")&&Ne.push(F("viewBox",Ct.getAttribute("viewBox")));let Pt=Y.getBoundingClientRect(),Kt=ve.getBoundingClientRect(),hn=Pt.left<Kt.left-1||Pt.top<Kt.top-1||Pt.right>Kt.right+1||Pt.bottom>Kt.bottom+1,Xt=Y.scrollHeight>Y.clientHeight+2&&Ue.overflowY!=="visible";Ne.push(Xt?F("fit",`clips by ${Math.round(Y.scrollHeight-Y.clientHeight)}px`,"warn"):hn?F("fit","runs off the slide","warn"):F("fit","fits","ok"));let Mt=re.slide===ce()?re.data:null,Wt=Mt?.blocks?.[U.index];return Wt&&Ne.push(F("file",`${Mt.file} \xB7 lines ${Te(Wt.lines)}`)),Ne}function d(Y){let ve=Y.tagName.toLowerCase(),ut=(typeof Y.className=="string"?Y.className:Y.getAttribute("class")??"").split(/\s+/).find(vt=>vt&&!vt.startsWith("dl-")),ht=ut?`${ve}.${ut}`:ve;return ve==="ul"||ve==="ol"?`${ht} \xB7 ${Y.querySelectorAll(":scope > li").length} items`:ve==="table"?`${ht} \xB7 ${Y.querySelectorAll("tr").length} rows`:ve==="svg"?`${ht} \xB7 ${Y.querySelectorAll("*").length} nodes`:ht}function G(Y,ve){let Ne=getComputedStyle(e),ut=[];for(let Ue of nu)ut.push([Ue,Ne.getPropertyValue(Ue)]);let ht=[];for(let Ue=0;Ue<Ne.length;Ue++){let Dt=Ne[Ue];Dt.startsWith("--")&&!nu.includes(Dt)&&ht.push([Dt,Ne.getPropertyValue(Dt)])}ht.sort((Ue,Dt)=>ru.test(Ue[0])-ru.test(Dt[0])),ut.push(...ht);let vt=Zd(Y,ut),mt=ve[3]<1?`${Fo(ve)} at ${Math.round(ve[3]*100)}%`:Fo(ve);return vt?`var(${vt}) \xB7 ${mt}`:mt}function be(Y){let ve=I()._records[ce()-1];if(!ve?.groups.length)return"always";let Ne=[];for(let vt=0;vt<ve.groups.length;vt++)for(let mt of ve.groups[vt]){let Ue=ve.steps[mt]?.el;if(Ue){if(Ue===Y||Ue.contains(Y))return`appears on step ${vt+1}`;Y.contains(Ue)&&Ne.push(vt+1)}}if(!Ne.length)return"always";let ut=Math.min(...Ne),ht=Math.max(...Ne);return ut===ht?`holds step ${ut}`:`holds steps ${ut}\u2013${ht}`}function J(){let Y=[],ve=U.node&&U.top.contains(U.node)?U.node:U.top;for(let Ne=ve;Ne&&(Y.unshift(Ne),Ne!==U.top);Ne=Ne.parentElement);return Y}function Qe(Y){if(!Y.children.length){let ve=(Y.textContent??"").trim().replace(/\s+/g," ");if(ve)return`"${ve.length>18?ve.slice(0,17)+"\u2026":ve}"`}return d(Y).split(" \xB7 ")[0]}function ot(){Ce||ee.hide()}function fe(Y){let ve=document.createElement("div");ve.className="narr-head ins-head";let Ne=document.createElement("span");Ne.className="ins-title";let ut=ce(),ht=de(ut);Ne.append(Object.assign(document.createElement("span"),{className:"ins-root",textContent:`slide ${ut} / ${I().state.totalSlides} \xB7 `}),Object.assign(document.createElement("span"),{className:"ins-name",textContent:ht?Ls(ht,ut-1,""):""}));let vt=null;U&&(vt=document.createElement("div"),vt.className="ins-path",J().forEach((Dt,Ct)=>{Ct&&vt.append(Object.assign(document.createElement("span"),{className:"ins-sep",textContent:"\u203A"}));let Pt=document.createElement("button");Pt.type="button",Pt.className="ins-crumb"+(Dt===oe?" ins-on":""),Pt.textContent=Qe(Dt),Pt.addEventListener("mouseenter",()=>ee.show(Dt,{dim:!1})),Pt.addEventListener("mouseleave",ot),Pt.addEventListener("click",Kt=>{Kt.stopPropagation(),ot(),N(Dt)}),vt.append(Pt)})),ve.append(Ne);let mt=document.createElement("button");mt.type="button",mt.className="dk-btn ins-pick"+(Ce?" ins-on":""),mt.title="select an element on the slide to inspect it",mt.setAttribute("aria-label","select an element to inspect"),mt.setAttribute("aria-pressed",String(Ce)),mt.innerHTML=Ve,mt.addEventListener("click",Dt=>{Dt.stopPropagation(),Ce?Ke():Ee()}),ve.append(mt);let Ue=document.createElement("button");Ue.type="button",Ue.className="dk-btn ins-copy",Ue.textContent="\u29C9",Ue.title="copy these facts",Ue.setAttribute("aria-label","copy"),Ue.addEventListener("click",()=>s(ie)),ve.append(Ue),ve.append(A.controls(V)),A.wireHeader(ve),Y.append(ve),vt&&Y.append(vt)}let K=()=>U&&h()?.available?.()&&h()?.elementEditOn?.()?Oo(U.top,oe):null;function ue(){let Y=!!K(),ve=document.createElement("div");ve.className="ins-tabs",ve.setAttribute("role","tablist");for(let[ut,ht]of[["info","Info"],["colors","Colors"],["type","Type"]]){let vt=document.createElement("button");vt.type="button",vt.className="ins-tab",vt.dataset.tab=ut,vt.textContent=ht,vt.setAttribute("role","tab"),vt.setAttribute("aria-selected",String(D===ut)),ut!=="info"&&!Y&&(vt.disabled=!0,vt.title=h()?.available?.()?"nothing here to restyle":"restyling is write mode\u2019s"),vt.addEventListener("click",mt=>{mt.stopPropagation(),D=ut,ae()}),ve.append(vt)}let Ne=h();if(U&&U.index!=null&&Ne?.available?.()&&Ne?.editContent){let ut=document.createElement("button");ut.type="button",ut.className="ins-tab",ut.dataset.tab="html",ut.textContent="HTML",ut.setAttribute("role","tab"),ut.setAttribute("aria-selected","false"),ut.title="edit this element as HTML, in this panel",ut.addEventListener("click",ht=>{ht.stopPropagation(),Ne.editContent(U)}),ve.append(ut)}return ve}function at(){if(!z||z.node!==oe){let Y=K();if(!Y)return D="info",Object.assign(document.createElement("div"),{className:"ins-none",textContent:"nothing here to restyle"});let{slide:ve,index:Ne}=U;z={...pd({root:e,targets:Y,side:D==="type"?"type":"fill",systems:[...Pr().values()],brand:(()=>{let ht=S();return ht?{locked:ht.locked,theme:ht.theme,roles:dd([...Pr().values()],ht.theme)}:null})(),save:ht=>h().saveStyles({slide:ve,index:Ne,edits:ht}),onError:ht=>n(`not saved: ${ht.slice(0,90)}`,3400),onDetach:ht=>h().detachConcept({slide:ve,index:Ne,path:ht.path,tag:ht.tag,el:ht.el}),concepts:h()?.available?.()&&$()?{names:()=>$().names(),fill:ht=>$().fill?.(ht)??null,set:ht=>$().set(Y.conceptAt.el,ht)}:null,onEscape:()=>Fe({key:"Escape"})}),node:oe}}return z.setSide(D==="type"?"type":"colors"),z.el.dataset.dock=E.dataset.dock??"",z.el}function N(Y){if(f()?.selectNode?.(Y,{exact:!0}))return;let ve=Y.closest("section"),Ne=ve?ks(ve,Y):null;Ne&&(U={sec:ve,slide:I()._sections.indexOf(ve)+1,index:xs(ve,Ne),top:Ne,clicked:Y,node:Y},oe=Y,ae())}let ft=Y=>{let ve=Y?.closest?.("section");return ve&&ve===de(ce())&&!Y.closest(".decklight-narr, .decklight-ctxmenu, .decklight-palette, .decklight-editbar, .dl-handle")?ve:null};function M(Y){let ve=ft(Y),Ne=ve?ks(ve,Y):null;if(!Ne)return null;let ut=Os(Ne,Y);return ut!==Ne?ut:Y}function H(Y){let ve=M(Y.target);ve?ee.show(ve,{dim:!0}):ee.hide()}function te(Y){if(E?.contains(Y.target)||(Y.preventDefault(),Y.stopPropagation(),Y.stopImmediatePropagation(),Y.type!=="click"))return;let ve=M(Y.target);Ke(),ve&&(D!=="info"&&!K()&&(D="info"),N(ve))}let we=["pointerdown","mousedown","mouseup","click","dblclick","contextmenu"];function Ee(){Ce=!0,e.classList.add("dl-picking"),document.addEventListener("mousemove",H,!0);for(let Y of we)window.addEventListener(Y,te,!0);ae()}function Ke(){if(Ce){Ce=!1,e.classList.remove("dl-picking"),document.removeEventListener("mousemove",H,!0);for(let Y of we)window.removeEventListener(Y,te,!0);ee.hide(),E&&ae()}}function ae(){if(!E)return;let Y=ce();U&&(!oe||!oe.isConnected||U.slide!==Y)&&(U=null,oe=null),z&&z.node!==oe&&(z=null);let ve=E.querySelector(".narr-card");if(ve.textContent="",fe(ve),U||(D="info"),U&&ve.append(ue()),U&&D!=="info"){ve.append(at());let Ue=document.createElement("div");Ue.className="narr-head ins-foot",Ue.textContent="esc lets go of it",ve.append(Ue);return}let Ne=U?l():se(),ut=document.createElement("dl");ut.className="ins-rows";for(let Ue of Ne){let Dt=Object.assign(document.createElement("dt"),{textContent:Ue.key}),Ct=document.createElement("dd");Ue.mark&&Ct.append(Object.assign(document.createElement("span"),{className:Ue.mark==="ok"?"ins-ok":"ins-warn",textContent:Ue.mark==="ok"?"\u2713":"!"})),Ue.look&&Ct.append(Ze(Ue.look)),Ct.append(Object.assign(document.createElement("span"),{className:"ins-value",textContent:Ue.value})),Ue.extra&&Ct.append(Object.assign(document.createElement("span"),{className:"ins-extra",textContent:Ue.extra})),Ct.dataset.key=Ue.key,ut.append(Dt,Ct)}ve.append(ut);let ht=Ne.map(Ue=>`${Ue.key}: ${Ue.mark==="warn"?"! ":""}${Ue.value}${Ue.extra?` (${Ue.extra})`:""}`);U||(ht=ht.concat(bt(ve,Y))),ie=[U?`slide ${Y}, ${J().map(Qe).join(" \u203A ")}`:`slide ${Y}`,...ht].join(`
|
|
445
|
+
`);let mt=document.createElement("div");mt.className="narr-head ins-foot",mt.textContent=[!U&&h()?.available?.()&&"e edits sources",U?"esc lets go of it":"esc closes"].filter(Boolean).join(" \xB7 "),ve.append(mt),U||Pe(Y)}function Ze(Y){let ve=document.createElement("span");return ve.setAttribute("aria-hidden","true"),Y.ink?(ve.className="ins-look ins-sample",ve.textContent="Aa",Object.assign(ve.style,{color:Y.ink,background:Y.on,fontWeight:Y.weight,fontFamily:Y.family})):Y.ring?(ve.className="ins-look ins-ring",ve.style.borderColor=Y.ring):(ve.className="ins-look ins-chip",ve.style.background=Y.fill),ve}function bt(Y,ve){let Ne=_a(de(ve)),ut=Object.assign(document.createElement("div"),{className:"narr-group",textContent:"sources"});if(Y.append(ut),!Ne)return Y.append(Object.assign(document.createElement("div"),{className:"ins-none",textContent:"none"})),["sources: none"];let ht=[];if(Ne.facts.length){let vt=document.createElement("dl");vt.className="ins-rows src-facts";for(let[mt,Ue]of Ne.facts)vt.append(Object.assign(document.createElement("dt"),{textContent:mt})),vt.append(Object.assign(document.createElement("dd"),{textContent:Ue})),ht.push(`${mt}: ${Ue}`);Y.append(vt)}for(let vt of Ne.links){let mt=document.createElement("a");mt.className="narr-row ins-link",mt.href=vt.href,mt.target="_blank",mt.rel="noopener noreferrer",mt.append(Object.assign(document.createElement("span"),{className:"narr-row-label",textContent:vt.title})),vt.note&&mt.append(Object.assign(document.createElement("span"),{className:"narr-tag",textContent:vt.note})),mt.append(Object.assign(document.createElement("span"),{className:"src-go",textContent:"\u2197"})),Y.append(mt),ht.push(`${vt.title}: ${vt.href}`)}return ht}function Pe(Y){le.slide!==Y&&(le={slide:Y,data:void 0},Promise.resolve(g()?.countFor?.(Y)).then(Ne=>{le.slide===Y&&(le.data=Ne??null,Ne&&E&&!U&&ce()===Y&&ae())}).catch(()=>{}));let ve=h();re.slide!==Y&&ve?.available?.()&&(re={slide:Y,data:null},fetch(`${ve.base()}/deck/edit/inspect?slide=${Y}`).then(Ne=>Ne.json()).then(Ne=>{re.slide!==Y||!Ne?.ok||(re.data=Ne,E&&ce()===Y&&ae())}).catch(()=>{}))}function ke(){E&&ae()}function Fe(Y){return Ce&&Y.key==="Escape"?(Ke(),!0):Y.key==="Escape"?U?(f()?.deselect?.(),!0):(V(),!0):(Y.key==="e"||Y.key==="E")&&!U&&h()?.available?.()?(V(),y().edit(),!0):!1}t.register({isOpen:Ie,close:V,keydown:Fe,modal:!1,panel:!0});let Ve='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><path d="M6.5 13.5h-4a1 1 0 0 1-1-1v-10a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v4" stroke-dasharray="2 1.6"/><path d="M8 8l6.5 2.4-2.8 1.1 2.3 2.3-.9.9-2.3-2.3-1.1 2.8z" fill="currentColor" stroke-linejoin="round"/></svg>';function et(){E&&(z=null,ae())}return{open:T,close:V,isOpen:Ie,onSlide:ke,refresh:et,text:()=>ie}}Se();Ae();var ou=bs,iu="decklight-onboarded",au="decklight-onboarded-tour",lu=e=>Nn(e),cu=(e,t)=>{yn(e,t)};function du({root:e,printMode:t,params:n,toast:s,debugLog:a,overlays:c,deck:h}){let f=n.has("embedded"),g=t||f||n.has("capture"),b=null;function y(){b&&(b.remove(),b=null,cu(iu,"1"),a?.("nav","welcome dismissed"))}function $(){b||t||(b=document.createElement("div"),b.className="decklight-welcome",b.innerHTML=`<div class="wel-card">
|
|
372
446
|
<h3>Welcome to Decklight</h3>
|
|
373
447
|
<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>
|
|
374
448
|
<table>
|
|
375
449
|
<tr><td>/</td><td><b>Command palette</b> \u2014 every command, type to filter. Start here.</td></tr>
|
|
376
450
|
<tr><td>?</td><td>All keyboard shortcuts.</td></tr>
|
|
377
|
-
<tr><td
|
|
378
|
-
<tr><td
|
|
379
|
-
<tr><td>A \xB7
|
|
451
|
+
<tr><td>${ou?"T \xB7 \u2303T":"T"}</td><td>Browse themes with a live preview${ou?"; <b>\u2303T</b> generates a brand-new one":""}.</td></tr>
|
|
452
|
+
<tr><td>\u2325\u23CE \xB7 V</td><td>Speaker view with notes & timer (<b>S</b> edits the notes); <b>V</b> narrates the deck aloud.</td></tr>
|
|
453
|
+
<tr><td>A \xB7 ${zt}</td><td><b>Write mode</b> (<code>decklight <deck.html></code>): live-reload editing \u2014 ask an AI agent to change the deck, edit any element, undo.</td></tr>
|
|
380
454
|
</table>
|
|
381
455
|
<div class="wel-foot">
|
|
382
456
|
<span>Press any key to dismiss \u2014 reopen anytime from the <code>/</code> palette.</span>
|
|
383
457
|
<button type="button" class="wel-go">Got it</button>
|
|
384
458
|
</div>
|
|
385
|
-
</div>`,
|
|
386
|
-
${ft.text||"(nothing)"}`:`cannot show what it said \u2014 ${ft.why}`))}I===g.id&&Pe.append(le("div","rv-arm","resolve this comment? \u23CE again to confirm \xB7 Esc to back out")),pe===g.id&&Pe.append(le("div","rv-arm",`move this comment to slide ${c.state.slide} (the one on screen)? A again to confirm \xB7 Esc backs out`));let mt={id:g.id,slide:ye.slide,node:Pe,resolved:!!g.resolved,branch:z,done:Ce};return Pe.addEventListener("click",()=>{i(A.indexOf(mt)),O()}),A.push(mt),Pe}function s(g){let J=A[N]?.id??null,z=T.querySelector(".narr-card");z.replaceChildren();let Ce=j(),ye=c.state.slide;A=[],Oe=g.incoming?.reviews??[];let Pe=le("div","narr-head");Pe.append(le("span","rv-heading","comments"));let X=le("div","rv-dock-ctl");for(let ie of["float","left","right","bottom"]){let Ke=le("button","rv-dock-btn"+(_e.mode===ie?" rv-dock-on":""),bt[ie]);Ke.dataset.mode=ie,Ke.title=ie==="float"?"float (movable)":`dock ${ie}`,Ke.setAttribute("aria-label",ie==="float"?"float":`dock ${ie}`),Ke.addEventListener("click",()=>ut(ie)),X.append(Ke)}let Xe=le("button","rv-dock-btn rv-close","\xD7");if(Xe.title="close (M)",Xe.setAttribute("aria-label","close"),Xe.addEventListener("click",Ie),X.append(Xe),Pe.append(X),Pe.style.cursor=_e.mode==="float"?"move":"",Pe.addEventListener("pointerdown",ie=>Q(ie,Pe)),z.append(Pe),g.incoming){let ie=g.incoming;if(ie.reviews?.length){let Ke=le("div","rv-incoming"),rt=[...ie.reviews].sort((Je,tt)=>Number(Je.done)-Number(tt.done));for(let Je of rt){let tt=new Set(Je.doneIds??[]),Rt=Br(Je.records??[]).filter(Pt=>!Pt.resolved),jt=Rt.filter(Pt=>!tt.has(Pt.id)).length;Ke.append(le("div",`rv-src${Je.done?" rv-done":""}`,Je.done?`\u2713 ${Je.who} \u2014 all ${Rt.length} done \xB7 ${Je.branch}`:`\u2193 ${Je.who} \u2014 ${jt} of ${Rt.length} left \xB7 ${Je.branch}`));let en=[...Rt].sort((Pt,sn)=>Number(tt.has(Pt.id))-Number(tt.has(sn.id)));for(let Pt of en)Ke.append(Y(Pt,Ce,{branch:Je.branch,done:tt.has(Pt.id)}))}z.append(Ke)}else ie.state&&!["ok","none","no-repo","untracked","no-remote","suppressed"].includes(ie.state)&&z.append(le("div","rv-inc-how",`incoming reviews: not checked \u2014 ${ie.state}`))}let mt=le("div","rv-list");mt.setAttribute("role","listbox");let ft=Br(g.records);if(g.error?mt.append(le("div","rv-none",`could not read the comments \u2014 ${g.error}`)):ft.length||mt.append(le("div","rv-none",g.can==="none"?"no comments, and nothing here can take one \u2014 a reviewer leaves them with: decklight review <deck>":"no comments yet")),g.skipped&&mt.append(le("div","rv-skipped",`${g.skipped} line(s) could not be read and were skipped`)),g.incoming?.reviews?.length&&ft.length){let ie=ft.filter(Ke=>!Ke.resolved).length;mt.append(le("div","rv-src",ie?`\u270E your comments \u2014 ${ie} of ${ft.length} left`:`\u2713 your comments \u2014 all ${ft.length} done`))}let ke=[...ft].sort((ie,Ke)=>+!!ie.resolved-+!!Ke.resolved);for(let ie of ke)mt.append(Y(ie,Ce));if(z.append(mt),g.can==="comment"){let ie=le("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)");ie.setAttribute("role","button"),ie.tabIndex=0,ie.addEventListener("click",()=>W()),z.append(ie)}z.append(le("div","rec-hint",g.can==="resolve"?Oe.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":g.can==="comment"?"\u23CE jumps to the slide \xB7 S submits the review \xB7 Esc closes":"\u23CE jumps to the slide \xB7 Esc closes"));let ue=J===null?-1:A.findIndex(ie=>ie.id===J);i(ue>=0?ue:Math.min(N,Math.max(0,A.length-1))),gt()}function i(g){A.length&&(N=En(A.map(J=>J.node),g,"rv-sel"))}function O(){let g=A[N];if(g){if(!g.slide){Ue(g);return}c.goto(g.slide,0,{force:!0})}}async function Ue(g){if(re?.id===g.id){re=null,s(await he());return}let J=S();if(J==null){d("only the author server can look that far back");return}try{let z=await fetch(`${J}/edit/review/at?id=${encodeURIComponent(g.id)}`),Ce=await z.json();if(!Ce?.ok)throw new Error(Ce?.error||`HTTP ${z.status}`);re={id:g.id,data:Ce}}catch(z){re={id:g.id,data:{known:!1,why:String(z.message||z)}}}s(await he())}async function B(){let g=A[N];if(!g||g.resolved)return;let J=S();if(J==null)return;if(pe!==g.id){pe=g.id,I=null,s(await he());return}if(pe=null,g.branch){d("this comment is on a review branch \u2014 only your own comments can be moved");return}let z=c.state.slide,Ce=j()[z-1];try{if(!(await(await fetch(`${J}/edit/review`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({op:"anchor",re:g.id,slide:z,title:Ce?.title,fp:Ce?.fp})})).json())?.ok)throw new Error("refused");d(`moved to slide ${z}`),re=null}catch(ye){d(`could not move that \u2014 ${String(ye.message||ye)}`)}s(await he())}async function Le(g,J,z){let Ce=String(g??"").trim();if(!Ce)return;let ye=await oe(),Pe=ye!==null?{url:`${ye}/review/comments`,mine:!1}:S()!=null?{url:`${S()}/edit/review`,mine:!0}:null;if(Pe)try{let X=await fetch(Pe.url,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:J,title:z?.title,fp:z?.fp,body:Ce})}),Xe=await X.json();if(!Xe?.ok)throw new Error(Xe?.error||`HTTP ${X.status}`);d(`comment left on slide ${J}`),p("review",`comment ${Xe.id} on slide ${J}`),T&&s(await he())}catch(X){d(`could not leave that comment \u2014 ${String(X.message||X)}`)}}async function $t(){let g=A[N];if(!g)return;let J=S();if(J!=null){if(g.branch){try{let Ce=await(await fetch(`${J}/edit/review/done`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({branch:g.branch,id:g.id,done:!g.done})})).json();if(!Ce?.ok)throw new Error(Ce?.error||"refused");d(Ce.done?"done":"reopened"),p("review",`${g.branch} ${g.id} ${Ce.done?"done":"reopened"}`)}catch(z){d(`could not mark that \u2014 ${String(z.message||z)}`)}s(await he());return}if(!g.resolved){if(I!==g.id){I=g.id,s(await he());return}I=null;try{if(!(await(await fetch(`${J}/edit/review`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({op:"resolve",re:g.id})})).json())?.ok)throw new Error("refused");d("resolved")}catch(z){d(`could not resolve that \u2014 ${String(z.message||z)}`)}s(await he())}}}async function W(){let g=await oe();if(g===null){d("nothing here can submit \u2014 run: decklight review <deck>");return}if(!Se){Se=!0,s(await he());return}Se=!1;try{let J=await fetch(`${g}/review/submit`,{method:"POST"}),z=await J.json();if(!z?.ok)throw new Error(z?.error||`HTTP ${J.status}`);d(`review pushed \u2192 ${z.branch}`),p("review",`submitted ${z.comments} comment(s) to ${z.branch}`)}catch(J){d(`could not submit \u2014 ${String(J.message||J)}`)}s(await he())}let Ae=null;function ee(){Ae?.remove(),Ae=null}async function We(){if(Ae)return ee();let g=await oe(),J=S();if(g===null&&J==null){d("nothing here can take a comment \u2014 decklight author, or decklight review");return}f(),Ie();let z=c.state.slide;Ae=document.createElement("div"),Ae.className="decklight-narr decklight-compose",Ae.innerHTML='<div class="narr-card" role="dialog" aria-label="Leave a comment"></div>',Ht(Ae,ee),t.appendChild(Ae);let Ce=Ae.querySelector(".narr-card"),ye=j();Ce.append(le("div","narr-head","leave a comment")),Ce.append(le("div","rv-on",`on slide ${z}${ye[z-1]?.title?` \xB7 ${ye[z-1].title}`:""}`));let Pe=le("textarea","narr-input rv-input");Pe.placeholder="what you want remembered about this slide\u2026",Pe.rows=3;let X=le("div","narr-row narr-sel rv-send","Leave this comment");X.setAttribute("role","button"),X.tabIndex=0;let Xe=async()=>{if(!Pe.value.trim()){Pe.focus();return}await Le(Pe.value,z,ye[z-1]),ee()};X.addEventListener("click",Xe),Pe.addEventListener("keydown",ie=>{ie.key==="Enter"&&(ie.metaKey||ie.ctrlKey)&&(ie.preventDefault(),Xe()),ie.stopPropagation()}),Ce.append(Pe,X),Ce.append(le("div","rec-hint","\u2318\u23CE leaves it \xB7 Esc closes \xB7 M reads them all")),setTimeout(()=>Pe.focus(),0);let mt=await he();if(!Ae)return;let ft=Br(mt.records??[]).filter(ie=>!ie.resolved&&Qr(ie,ye).slide===z),ke=(mt.incoming?.reviews??[]).flatMap(ie=>Br(ie.records??[]).filter(Ke=>!Ke.resolved&&Qr(Ke,ye).slide===z).map(Ke=>({c:Ke,who:ie.who})));if(!ft.length&&!ke.length)return;let ue=le("div","rv-already");ue.append(le("div","rv-src",`already on this slide \u2014 ${ft.length+ke.length}`));for(let ie of ft)ue.append(le("div","rv-said",`${Re(ie)}: ${ie.body}`));for(let{c:ie,who:Ke}of ke)ue.append(le("div","rv-said",`${Ke}: ${ie.body}`));Ce.append(ue)}async function w(){if(T)return Ie();f(),I=null,Se=!1,pe=null,re=null,N=0,T=document.createElement("div"),T.className="decklight-narr decklight-review",T.dataset.dock=_e.mode,T.innerHTML='<div class="narr-card" role="dialog" aria-label="Review comments"></div>',t.appendChild(T),Me=_e.mode==="float",Ve=g=>{Me=!!T&&T.contains(g.target)},document.addEventListener("pointerdown",Ve,!0),document.addEventListener("focusin",Ve,!0),ze=()=>je(),window.addEventListener("resize",ze),je(),s({records:[],skipped:0,can:"none"}),await P(),T&&s(await he())}function Ie(){T?.remove(),T=null,I=null,Se=!1,pe=null,re=null,Me=!1,t.style.removeProperty("--dock-left"),t.style.removeProperty("--dock-right"),t.style.removeProperty("--dock-bottom"),c._reflow?.(),ze&&(window.removeEventListener("resize",ze),ze=null),Ve&&(document.removeEventListener("pointerdown",Ve,!0),document.removeEventListener("focusin",Ve,!0),Ve=null)}return a.register({isOpen:()=>!!Ae,close:ee,keydown(g){return g.key==="Escape"?(ee(),!0):!1}}),a.register({isOpen:()=>!!T,close:Ie,modal:()=>Me,keydown(g){let J=/^(input|textarea)$/i.test(g.target?.tagName??"");if(g.key!=="Escape"&&!(g.key==="m"||g.key==="M")&&!Me)return!1;if(g.key==="Escape")return I||Se||pe?(I=null,Se=!1,pe=null,he().then(z=>T&&s(z)),!0):(Ie(),!0);if(J)return!1;switch(g.key){case"ArrowDown":i(N+1);break;case"ArrowUp":i(N-1);break;case"Enter":I&&A[N]?.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":Ie();break;default:return!1}return!0}}),o?.has?.("review")&&setTimeout(()=>{a.active()||w()},700),{open:w,close:Ie,isOpen:()=>!!T,compose:We,submit:async()=>{T||await w(),Se=!0,T&&s(await he())}}}me();fe();function Ga({now:t=Date.now,keep:o=200}={}){let a=t(),c=[],d=null;function p(f,m){let v={t:((t()-a)/1e3).toFixed(3),kind:f,msg:m};return c.push(v),c.length>o&&c.shift(),d?.(v),v}return{log:p,get entries(){return c.slice()},onEntry(f){d=f}}}me();fe();var jd=["auto","centered","pinned","top","split","split-flip"];function Gd({autoPins:t,hasSplitPair:o}){return jd.filter(a=>(a!=="pinned"||!t)&&(a!=="split-flip"||o))}function Kd(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 Ka({slideOf:t,sectionAt:o,describe:a,available:c,unavailableMessage:d,apply:p,relayout:f,post:m,toast:v,debugLog:k,schedule:S=setTimeout,cancel:P=clearTimeout,delay:T=600}){let A=null,N=null;function I(){P(N);let Oe=A;A=null,Oe&&m({slide:Oe.slide,layout:Oe.name}).then(()=>k("layout",`slide ${Oe.slide}: ${Oe.name} \u2192 saved to file`)).catch(()=>v("layout save failed \u2014 is the dev server still up?",2200))}function Se(Oe=t()){let re=o(Oe);return re?Gd(a(re)):[]}function pe(Oe){if(!c()){v(d(),3200);return}let re=t(),ce=o(re);if(!ce)return;let Me=Kd(Se(re),ce.getAttribute("data-layout")||"auto",Oe);if(!Me)return;p(ce,Me),A&&A.slide!==re&&I(),A={slide:re,name:Me},P(N),N=S(I,T);let ze=f(ce,re);v(ze?`layout: ${Me} \u2014 fights this slide's own column flexbox; pick one`:`layout: ${Me}`),k("layout",`slide ${re}: ${Me}`)}return{ring:Se,cycle:pe,flush:I}}me();fe();function Wa({commands:t,query:o="",totalSlides:a=0,makeGotoRow:c,makeSearchRow:d}){let p=String(o).toLowerCase(),f=t.filter(v=>!p||(v.label+" "+(v.alias??"")).toLowerCase().includes(p)),m=String(o).trim().match(/^(?:goto\s*)?(\d+)$/i);if(m&&c){let v=Math.max(1,Math.min(parseInt(m[1],10),a));f.unshift(c(v,a))}return p&&!m&&d&&!f.some(v=>v.label.toLowerCase().startsWith(p))&&f.push(d(o)),f}var Wd={transition:"fade",hash:!0,controls:!0,slideNumber:!1,width:1280,height:720,pinTitles:!0},Ps=99,Vd=18,Va=6,Zd="ul, ol, svg, pre, table, .terminal, img, .columns",Dr=null;function es(t,o){Ko(t,o),Dr&&Dr._rescanFor(t)}function Jd(t){let o=getComputedStyle(t).position;return o==="absolute"||o==="fixed"}function Yd(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(!Jd(o))return null}return null}function Xd(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 Ya(t){return t.pinTitles===!0?Ps:typeof t.pinTitles=="number"&&isFinite(t.pinTitles)?t.pinTitles:null}function Xa(t,o){let a=Ya(o),c=t.getAttribute("data-pin");if(c==="none")return null;if(c!==null&&c!==""){let p=parseFloat(c);return isFinite(p)?p:a??Ps}return c===""?a??Ps:a===null?null:[...t.querySelectorAll(Zd)].some(p=>!p.closest("aside")&&!p.closest(".decklight-hero-logo"))?a:null}function Is(t,o){t.forEach(a=>{let c=Yd(a),d=a.getAttribute("data-layout"),p;if(d==="pinned"){let k=parseFloat(a.getAttribute("data-pin"));p=isFinite(k)?k:Ya(o)??Ps}else d==="centered"||d==="top"?p=null:p=Xa(a,o);let f=Xd(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,v=p+m;f&&(f.classList.add("pin-subtitle"),a.style.setProperty("--pin-sub-y",Math.round(v+Va)+"px"),v+=Va+(f.offsetHeight||0)),a.classList.remove("pin-measure"),a.style.setProperty("--pin-space",Math.round(v+Vd)+"px")})}function Qa(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=Qa(o);if(Qd(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 Qd(t,o,a){let c=o.some(p=>{let f=getComputedStyle(p);return/flex$/.test(f.display)&&f.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 Ao(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 eu(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 _o(t){return(t||"").replace(/^#/,"")}function Ja(t){let o=_o(t).match(/^\/(\d+)(?:\/(\d+))?/);return o?{slide:parseInt(o[1],10),step:o[2]?parseInt(o[2],10):0}:null}function el(t={}){let o=new URLSearchParams(location.search),a={...Wd,...t};o.has("embedded")&&(a.controls=!1);let c=o.has("print"),d=o.has("all"),p=o.get("print")||"",f=Ga(),m=null,v=(x,q)=>f.log(x,q),k=document.querySelector(".decklight");if(!k)throw new Error("Decklight: no .decklight element found");let S=la(),P=Fa({config:a,root:k,embedded:o.has("embedded"),sectionsOf:()=>te._sections,slideOf:()=>te.state.slide,navigate:x=>{location.href=x}}),T=P.playlist,A=P.index,N=P.hasMarkers,I=x=>P.gotoModule(x),Se=x=>P.navigateToModule(x),pe=200,Oe=4,re=[],ce=null,Me=null;function ze(){return re}function Ve(x){re.push({at:new Date,text:String(x)}),re.length>pe&&re.shift(),Me&&ln()}function $e(x,q=3200){if(Ve(x),c)return;ce||(ce=document.createElement("div"),ce.className="decklight-messages",k.appendChild(ce));let D=document.createElement("div");for(D.className="decklight-toast",D.textContent=x,ce.appendChild(D),requestAnimationFrame(()=>D.classList.add("show"));ce.children.length>Oe;)ce.firstChild.remove();setTimeout(()=>{D.classList.remove("show"),setTimeout(()=>D.remove(),260)},q)}let _e=Da({root:k,printMode:c,params:o,toast:$e,debugLog:v,overlays:S,deck:()=>te}),Ze=ua({root:k,config:a,params:o,toast:$e,debugLog:v,overlays:S,deck:()=>te,editmode:()=>Tt}),{applyTheme:bt,currentTheme:_,cycleTheme:je,cancelCyclePending:gt,rollTheme:ut,saveGeneratedTheme:Q}=Ze,j=null,oe=0,he="",le=[],Re,Y=!1,s=null;function i(){return za({sections:te._sections,modules:T?.modules??[],skipModule:A})}function O(){let x=j.querySelector(".tp-list");if(le=Ua(j.__index,he),x.textContent="",le.forEach((D,ve)=>{let et=document.createElement("div");et.className="tp-row"+(D.slide===te.state.slide?" tp-current":"")+(D.href?" tp-module":""),et.textContent=D.href?`\u25B8 ${D.title} \u2014 module`:`${D.slide} \xB7 ${D.title}`,et.addEventListener("mouseenter",()=>B(ve,!1)),et.addEventListener("click",()=>{B(ve,!0),$t()}),x.appendChild(et)}),!le.length){let D=document.createElement("div");D.className="tp-none",D.textContent="no matches",x.appendChild(D)}let q=j.querySelector(".tp-filter");q.textContent=he||(T?"type to find a slide or module\u2026":"type to find a slide\u2026"),q.classList.toggle("tp-active",!!he)}function Ue(x,q){let D=q.href??location.pathname,ve=q.slide??1;if(x.dataset.doc!==D){x.dataset.doc=D,Y=!1,x.addEventListener("load",()=>{if(Y=!0,s&&j){let et=s;s=null,Ue(x,et)}},{once:!0}),x.src=D+Ze.previewQuery()+"#/"+ve+"/0";return}if(!Y){s=q;return}x.contentWindow?.postMessage({__decklightPreview:{goto:[ve,0]}},"*")}function B(x,q){if(!le.length)return;oe=En(j.querySelectorAll(".tp-row"),x,"tp-selected");let D=le[oe];j.querySelector(".tp-caption").textContent=D.href?`module \u2014 ${D.title} (${D.href})`:`slide ${D.slide} \u2014 ${D.title}`,clearTimeout(Re);let ve=j.querySelector("iframe");q?Ue(ve,D):Re=setTimeout(()=>Ue(ve,D),60)}function Le(x){he=x,O(),le.length?B(0,!1):j.querySelector(".tp-caption").textContent="no match"}function $t(){let x=le[oe];if(Ae(),!!x){if(x.href)return Se(x.module);te.goto(x.slide,0)}}function W(){if(j)return Ae();Ze.closePicker(),Tt.restore.close(),he="",j=document.createElement("div"),j.className="decklight-theme-picker decklight-finder",j.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>',j.__index=i(),O(),Ht(j,Ae),k.appendChild(j),B(Math.max(0,le.findIndex(x=>x.slide===te.state.slide)),!0)}function Ae(){clearTimeout(Re),j?.remove(),j=null}let ee=null,We=0,w="",Ie=[],g=()=>(te._sections??[]).some(x=>x.hasAttribute("data-hidden")),J=()=>!!te._sections?.[te.state.slide-1]?.hasAttribute("data-hidden");function z(){let x=new URL(location.href);d?x.searchParams.delete("all"):x.searchParams.set("all",""),location.href=x.href}async function Ce(x,q){let D=te._sections?.[x-1];if(D){try{let ve=await fetch(Tt.base()+"/edit/hidden",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:x,hidden:q})});if(!ve.ok)throw new Error(String(ve.status))}catch(ve){$e(`could not ${q?"hide":"unhide"} slide ${x} \u2014 ${ve.message}`);return}if(D.toggleAttribute("data-hidden",q),$e(q?`slide ${x} hidden \u2014 the audience will not see it (?all shows it)`:`slide ${x} shown again`),q&&!d&&te.state.slide===x){let ve=te._visibleFrom(x+1,1)??te._visibleFrom(x-1,-1);ve!=null&&te.goto(ve,0)}}}function ye(){let x=te.__speakerWin;return x&&!x.closed?x:te.__speakerWin=Ts(te)}function Pe(){let x=D=>typeof D=="function";return[{label:"Find slide\u2026",hint:"G",alias:"search grep goto module chapter jump",run:()=>{W(),w&&Le(w)}},{label:"Comments\u2026",hint:"M",alias:"feedback remarks reviewer notes critique review read",run:()=>vn.open()},{label:"Leave a comment\u2026",hint:"\u21E7M",alias:"comment note remark feedback add write say",run:()=>vn.compose()},{label:"Submit review\u2026",alias:"send review push comments submit feedback",run:()=>vn.submit()},{label:"History\u2026 (dev)",hint:"H",alias:"restore version rollback revert back git log commits unpushed push remote when changed",run:()=>Tt.history.open()},{label:"Go to slide\u2026",hint:"#",alias:"goto",keepOpen:!0,run:()=>{w="goto ",X()}},{label:"Theme\u2026",hint:"T",run:Ze.openPicker},{label:"Cycle theme",hint:", \xB7 .",run:()=>je(1)},{label:"Generate a theme",hint:"\u2303T",run:ut},Ze.hasGenerated()&&{label:"Save the generated theme\u2026",hint:"\u2303\u21E7T",run:()=>Q()},Tt.available()&&{label:"Browse marketplace themes\u2026",alias:"marketplace install add third-party download catalog",run:Ze.browse},...Tt.wizards().map(D=>({label:`Configure ${D.title}\u2026 (dev)`,alias:"engine wizard setup api key credential token marketplace",run:()=>Tt.wizard(D.qualified)})),{label:"Font\u2026",hint:"[ \xB7 ]",run:Ke},{label:"Cycle slide layout (dev)",hint:"L",alias:"pin pinned centered top auto split columns two sides arrange",run:()=>qt(1)},{label:"Undo deck edit (dev)",hint:"Z",alias:"revert back history",run:()=>Gn("undo")},{label:"Redo deck edit (dev)",hint:"\u21E7Z",alias:"forward history repeat",run:()=>Gn("redo")},{label:"Ask agent\u2026 (dev)",hint:"A",alias:"ai claude codex bob gemini prompt edit",run:Cn},{label:"Messages",hint:"`",alias:"log toast notifications warnings why voice stopped history",run:cn},{label:`Narration ${Ot.status().paused?"resume":Ot.status().narrating?"pause":"play"}`,hint:"\u23B5",alias:"play pause resume voice narration speak start stop",run:()=>Ot.playPause()},{label:"Narration\u2026",hint:"V",alias:"voice audio track picker settings",run:()=>gn("tracks")},{label:"Live voice\u2026",hint:"V",alias:"tts synthesize tone gemini",run:()=>gn("voices")},{label:"Character\u2026",hint:"V",alias:"avatar lipsync face talking head visemes",run:()=>gn("character")},{label:"Record this deck\u2026",hint:"V",alias:"record narrate microphone mic voice wav offline batch teleprompter",run:()=>gn("record")},{label:`Character solo ${Yn.solo?"off":"on"}`,alias:"centre center stage narrator only fullscreen avatar",run:()=>Ot.applySolo(!Yn.solo)},{label:"Voice faster",hint:">",alias:"speed rate playback",run:()=>an(.25)},{label:"Voice slower",hint:"<",alias:"speed rate playback",run:()=>an(-.25)},{label:"Speaker view",hint:"S",run:()=>{let D=te.__speakerWin;D&&!D.closed?D.__decklightSpeakerToggle?.():te.__speakerWin=Ts(te)}},{label:"Overview",hint:"O",run:st},{label:"Blackout",hint:"B",run:Mt},{label:`Pen ${Sn.annotator?.tool==="pen"?"off":"on"} \u2014 draw on the slide`,hint:"W",alias:"ink annotate draw scribble marker highlight",run:()=>jn("pen")},{label:`Laser pointer ${Sn.annotator?.tool==="laser"?"off":"on"}`,hint:"\u21E7W",alias:"ink dot glow point at",run:()=>jn("laser")},{label:"Debug log",hint:"D",alias:"console events state",run:Bt},{label:`Captions ${Ot.status().captionsOn?"off":"on"}`,hint:"C",alias:"cc subtitles closed caption",run:Qn},{label:`Clock ${Sn.status().clockOn?"off":"on"}`,alias:"time elapsed timer talk wall watch clock",run:Un},{label:"Commit\u2026",hint:"K",alias:"git save commit message history",run:()=>Tt.commit.open()},{label:`Progress bar ${Sn.status().progressOn?"off":"on"}`,hint:"J",alias:"bar bottom edge position how far through shape of the talk",run:Hn},{label:"Transcript\u2026",alias:"notes script export text markdown spoken",run:Fr},{label:"Edit speaker notes\u2026",alias:"edit mode notes write right-click background",run:$n},{label:`Element edit mode ${Tt.elementEditOn()?"off":"on"} (dev)`,hint:"E",alias:"right-click remove delete html content build animation entrance effect context menu",run:Ct},{label:"Fullscreen",hint:"F",run:()=>H()},{label:"Print view (all slides, new tab)",hint:"",run:()=>window.open(location.pathname+"?print")},{label:"Print with notes (one slide per page, new tab)",alias:"pdf print speaker notes script handout pages",run:()=>window.open(location.pathname+"?print=notes")},{label:"Print handout (three per page, new tab)",alias:"pdf print handout thumbnails audience note-taking lines",run:()=>window.open(location.pathname+"?print=handout")},(d||g())&&{label:`Hidden slides ${d?"skip":"show"}`,alias:"all cut backup skipped unhide reveal present hidden \u2298",run:z},Tt.available()&&{label:`${J()?"Unhide":"Hide"} this slide (dev)`,alias:"hidden hide skip cut backup keep out of the talk unhide show",run:()=>Ce(te.state.slide,!J())},{label:"Rehearse timings\u2026 (speaker view)",alias:"rehearsal timing time each slide record pace plan stopwatch",run:()=>{ye()?.__decklightSpeakerRec?.(!0)}},{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:Jn},{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(D=>x(D.run))}function X(){let x=ee.querySelector(".narr-card");x.textContent="",Ie=Wa({commands:Pe(),query:w,totalSlides:te.state.totalSlides,makeGotoRow:(D,ve)=>({label:`Go to slide ${D} / ${ve}`,hint:"\u23CE",run:()=>te.goto(D,0)}),makeSearchRow:D=>({label:`Search slides for \u201C${D}\u201D`,hint:"",run:()=>{W(),Le(D)}})});let q=document.createElement("div");if(q.className="pal-input"+(w?" tp-active":""),q.textContent=w||"type a command\u2026",x.appendChild(q),Ie.forEach((D,ve)=>{let et=document.createElement("div");et.className="narr-row pal-row";let St=document.createElement("span");if(St.textContent=D.label,et.appendChild(St),D.hint){let Jt=document.createElement("span");Jt.className="pal-kbd",Jt.textContent=D.hint,et.appendChild(Jt)}et.addEventListener("mouseenter",()=>Xe(ve)),et.addEventListener("click",()=>{Xe(ve),mt()}),x.appendChild(et)}),!Ie.length){let D=document.createElement("div");D.className="tp-none",D.textContent="no matching command",x.appendChild(D)}Xe(0)}function Xe(x){Ie.length&&(We=En(ee.querySelectorAll(".pal-row"),x,"narr-sel"))}function mt(){let x=Ie[We];x&&(x.keepOpen||ke(),x.run())}function ft(){if(ee)return ke();j&&Ae(),Tt.restore.close(),w="",ee=document.createElement("div"),ee.className="decklight-narr decklight-palette",ee.innerHTML='<div class="narr-card" role="listbox" aria-label="Commands"></div>',Ht(ee,ke),k.appendChild(ee),X()}function ke(){ee?.remove(),ee=null}let ue=null,ie=0;function Ke(){if(ue)return Je();ue=document.createElement("div"),ue.className="decklight-narr decklight-font-picker",ue.innerHTML='<div class="narr-card" role="listbox" aria-label="Fonts"></div>';let x=ue.querySelector(".narr-card");tt.forEach(([q],D)=>{let ve=document.createElement("div");ve.className="narr-row"+(D===jt?" narr-cur":""),ve.textContent=q,D>0&&(ve.style.fontFamily=tt[D][1]),ve.addEventListener("mouseenter",()=>rt(D)),ve.addEventListener("click",()=>{en(D),Je()}),x.appendChild(ve)}),Ht(ue,Je),k.appendChild(ue),rt(jt)}function rt(x){ie=En(ue.querySelectorAll(".narr-row"),x,"narr-sel")}function Je(){ue?.remove(),ue=null}Ze.restoreSaved();let tt=[["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"]],Rt="decklight-font:"+location.pathname,jt=0;function en(x,{silent:q=!1,remeasure:D=!0}={}){jt=(x%tt.length+tt.length)%tt.length;let[ve,et]=tt[jt];if(et?(k.style.setProperty("--font-body",et),k.style.setProperty("--font-heading",et)):(k.style.removeProperty("--font-body"),k.style.removeProperty("--font-heading")),!o.has("embedded"))try{fn(Rt,et?jt:null)}catch{}D&&(Is(te._sections,a),Ao(te._sections[te.state.slide-1],te.state.slide)),q||$e(`font: ${ve}`),v("font",ve)}function Pt(x){en(jt+x)}try{let x=parseInt(kn(Rt)??"",10);x>0&&x<tt.length&&en(x,{silent:!0,remeasure:!1})}catch{}function sn(x){if(!x)return null;if(x.startsWith("#")){let D=document.querySelector(x);if(!D)return null;let ve=D.cloneNode(!0);return ve.removeAttribute("id"),ve.style.removeProperty("display"),ve}if(x.trim().startsWith("<")){let D=document.createElement("div");return D.innerHTML=x,D.firstElementChild}let q=document.createElement("img");return q.src=x,q.alt="",q}let Gt=null;Ze.updateCanvas();let At=k.querySelector(":scope > .decklight-stage");if(!At){for(At=document.createElement("div"),At.className="decklight-stage";k.firstChild;)At.appendChild(k.firstChild);k.appendChild(At)}if(At.style.width=a.width+"px",At.style.height=a.height+"px",a.logo&&(a.logo.src||a.logo.onLight||a.logo.onDark)){Gt=document.createElement("div"),Gt.className="decklight-logo",Gt.setAttribute("data-pos",a.logo.position||"bottom-left"),a.logo.height&&Gt.style.setProperty("--logo-h",a.logo.height+"px");for(let[x,q]of[["src","on-any"],["onLight","on-light"],["onDark","on-dark"]]){let D=sn(a.logo[x]);if(!D)continue;let ve=document.createElement("span");ve.className=q,ve.appendChild(D),Gt.appendChild(ve)}k.appendChild(Gt)}function on(x){Gt&&x.forEach(q=>{if(!q.hasAttribute("data-logo")||q.querySelector(":scope > .decklight-hero-logo"))return;let D=document.createElement("div");D.className="decklight-hero-logo";let ve=parseFloat(q.getAttribute("data-logo"));ve&&D.style.setProperty("--hero-logo-h",ve+"px"),D.innerHTML=Gt.innerHTML,q.prepend(D)})}eu(At),ei(At),di(At),Jo(At),sa(At,es);let un=Ka({slideOf:()=>te.state.slide,sectionAt:x=>te._sections[x-1],describe:x=>({autoPins:Xa(x,a)!==null,hasSplitPair:Qa(x).length>1}),available:()=>Tt.available(),unavailableMessage:()=>Fn("layout",location),apply:(x,q)=>{q==="auto"?x.removeAttribute("data-layout"):x.setAttribute("data-layout",q)},relayout:(x,q)=>(Is(te._sections,a),Za(te._sections),Ao(x,q),x.hasAttribute("data-split-conflict")),post:x=>fetch(Tt.base()+"/edit/layout",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(x)}).then(q=>{if(!q.ok)throw new Error(q.status)}),toast:$e,debugLog:v}),qt=x=>un.cycle(x),pn=x=>un.ring(x),te={root:k,stage:At,config:a,_sections:[],_records:[],state:{slide:1,step:0,totalSlides:0},_listeners:new Map,_scale:1,on(x,q){return this._listeners.has(x)||this._listeners.set(x,new Set),this._listeners.get(x).add(q),this},off(x,q){return this._listeners.get(x)?.delete(q),this},_emit(x,q){(this._listeners.get(x)||[]).forEach(D=>D(q)),k.dispatchEvent(new CustomEvent("decklight:"+x,{detail:q}))},sync(){this._sections=[...At.querySelectorAll(":scope > section")],this._sections.forEach((q,D)=>q.setAttribute("data-slide-index",String(D+1))),Zo(At,a.concepts),on(this._sections),Ca(this._sections,{printMode:c}),Is(this._sections,a),Za(this._sections),this._records=this._sections.map(q=>Xs(q)),this.state.totalSlides=this._sections.length,this.state.slide=Math.min(this.state.slide,this.state.totalSlides||1);let x=this._records[this.state.slide-1];x&&(this.state.step=Math.min(this.state.step,x.groups.length)),Tn(c?this._sections:[this._sections[this.state.slide-1]])},_rescanFor(x){let q=x.closest("section"),D=this._sections.indexOf(q);if(D!==-1){if(this._records[D]=Xs(q),c){ir(this._records[D],this._records[D].groups.length);return}D===this.state.slide-1?(this.state.step=Math.min(this._requestedStep??this.state.step,this._records[D].groups.length),this._requestedStep=null,_t(()=>ir(this._records[D],this.state.step)),this._updateHash(!1)):_t(()=>ir(this._records[D],0)),this._notify()}},_stepLabels(x){let q=this._records[x];return q?Wo(q):[]},_hidden(x){return!d&&!!this._sections[x-1]?.hasAttribute("data-hidden")},_visibleFrom(x,q){for(let D=x;D>=1&&D<=this.state.totalSlides;D+=q)if(!this._hidden(D))return D;return null},next(){let x=this._records[this.state.slide-1];if(x&&this.state.step<x.groups.length){this.goto(this.state.slide,this.state.step+1,{direction:"fwd"});return}let q=this._visibleFrom(this.state.slide+1,1);q?this.goto(q,0,{direction:"fwd"}):I(1)},prev(){if(this.state.step>0){this.goto(this.state.slide,this.state.step-1,{direction:"back"});return}let x=this._visibleFrom(this.state.slide-1,-1);x?this.goto(x,this._records[x-1].groups.length,{direction:"back"}):I(-1)},goto(x,q=0,D={}){if(x=Math.max(1,Math.min(x,this.state.totalSlides)),this._hidden(x)){let Jt=D.direction==="back"?-1:1,hn=this._visibleFrom(x,Jt)??this._visibleFrom(x,-Jt);if(hn==null)return;x=hn,q=Jt<0?this._records[x-1]?.groups.length??0:0}let ve=this._records[x-1];this._requestedStep=q,q=Math.max(0,Math.min(q,ve?ve.groups.length:0));let et=x===this.state.slide;if(et&&q===this.state.step&&!D.force)return;let St=D.direction||(x>this.state.slide||et&&q>this.state.step?"fwd":"back");!et||D.force?(this._activateSlide(x,St,D),this.state.slide=x,this.state.step=q,_t(()=>ir(ve,q)),this._emit("slide",{slide:x,total:this.state.totalSlides,direction:St}),Tn([this._sections[x-1]])):(this.state.step=q,ir(ve,q),this._emit("build",{slide:x,index:q,total:ve.groups.length,direction:St})),this._updateChrome(),this._updateHash(!et),this._notify()},_activateSlide(x,q,D={}){let ve=this._sections[this.state.slide-1],et=this._sections[x-1];if(k.classList.toggle("has-hero-logo",et?.hasAttribute("data-logo")??!1),ve===et){et.classList.add("active");return}let St=!ve||!ve.classList.contains("active"),Jt=ve&&et&&!St&&ve.hasAttribute("data-auto-animate")&&et.hasAttribute("data-auto-animate")&&Math.abs(this._sections.indexOf(et)-this._sections.indexOf(ve))===1;if(this._sections.forEach(wr=>wr.classList.remove("active","entering","leaving","dir-fwd","dir-back","tr-none","tr-fade","tr-slide","tr-scale","tr-flip")),et.classList.add("active"),St||c)return;if(Jt){ve.classList.add("leaving"),ve.style.visibility="hidden",et.style.visibility="hidden",et.offsetWidth,et.style.visibility="",ai(ve,et,this._scale),ve.classList.remove("leaving"),ve.style.visibility="";return}let hn=si(et.getAttribute("data-transition"),this.config.transition),bn=oi(hn,q);if(!bn)return;et.classList.add(...bn.entering),ve.classList.add(...bn.leaving);let In=ws(getComputedStyle(et).getPropertyValue("--transition-duration"),350);setTimeout(()=>{ve.classList.remove(...bn.leaving),et.classList.remove(...bn.entering)},In+60)},_updateChrome(){if(Ee){let x=this._records[this.state.slide-1],q=x?x.groups.length:0,D=this.state.totalSlides<=1?1:(this.state.slide-1+(q?this.state.step/(q+1):0))/(this.state.totalSlides-1);Ee.style.width=(Math.min(D,1)*100).toFixed(2)+"%"}if(we){let x=this.config.slideNumber?this.config.slideNumber==="n/N"?`${this.state.slide} / ${this.state.totalSlides}`:String(this.state.slide):"";if(we.textContent=x,P.any){let q=P.title(),D=document.createElement("span");D.className="mod",D.textContent=q,we.prepend(D)}}},_updateHash(x){!this.config.hash||c||(C=C||!!x,!Yt&&(Yt=setTimeout(()=>{Yt=null,ne()},tn)))},_notify(){this.__notifySpeaker&&this.__notifySpeaker()}};function Kt(x,q){let D=document.createElement("a");D.href=x,D.download=q,document.body.appendChild(D),D.click(),D.remove()}function _t(x){k.classList.add("decklight-no-anim"),x(),k.offsetWidth,k.classList.remove("decklight-no-anim")}let tn=90,Yt=null,C=!1;function ne(x=!0){if(!te||!a.hash||c)return;let q=`#/${te.state.slide}/${te.state.step}`,D=C;if(C=!1,"#"+_o(location.hash)!==q){wn=!0;try{D?history.pushState(null,"",q):history.replaceState(null,"",q)}catch{}setTimeout(()=>{wn=!1}),x&&"#"+_o(location.hash)!==q&&(C=D,requestAnimationFrame(()=>ne(!1)))}}let Ee=null,we=null;if(a.controls&&!c){let x=document.createElement("div");x.className="decklight-controls",x.innerHTML=`
|
|
459
|
+
</div>`,b.addEventListener("click",U=>{U.stopPropagation(),y()}),Qt(b,y),e.appendChild(b),a?.("nav","welcome shown"))}let S=null;function A(){S&&(S.remove(),S=null,cu(au,"1"),a?.("nav","editing tour dismissed"))}function E(){S||b||t||(S=document.createElement("div"),S.className="decklight-welcome wel-tour",S.innerHTML=`<div class="wel-card">
|
|
460
|
+
<h3>Editing this deck</h3>
|
|
461
|
+
<p class="wel-lead">This deck is open in write mode (<code>decklight <deck.html></code>): what you change here is written to the file, snapshotted, and taken back with <b>${zt}</b>.</p>
|
|
462
|
+
<table>
|
|
463
|
+
<tr><td>double-click</td><td><b>Edit any text</b> in place; <b>\u2318B</b>, <b>\u2318I</b>, <b>\u2318E</b> emphasise a selection; <b>\u23CE</b> keeps it, <b>Esc</b> gives it up.</td></tr>
|
|
464
|
+
<tr><td>drop</td><td><b>Add a picture</b> by dropping a file onto the slide.</td></tr>
|
|
465
|
+
<tr><td>bar</td><td><b>Editing</b> is on: a bar names every door (Text, Picture, Layout, Notes, Slide\u2026); a click selects an element, \u232B removes it; <b>Lock</b> turns changes off.</td></tr>
|
|
466
|
+
<tr><td>S \xB7 O</td><td><b>S</b> opens the notes drawer, which saves itself; <b>O</b> is the overview, where slides are dragged, added and deleted.</td></tr>
|
|
467
|
+
<tr><td>A</td><td><b>Describe a change</b> and an AI agent makes it; ${zt} takes it back too.</td></tr>
|
|
468
|
+
<tr><td>K \xB7 /</td><td><b>K</b> commits what changed (the chip at the corner keeps count); <b>/</b> lists everything else.</td></tr>
|
|
469
|
+
</table>
|
|
470
|
+
<div class="wel-foot">
|
|
471
|
+
<span>Press any key to dismiss \u2014 reopen anytime from the <code>/</code> palette (Editing tour).</span>
|
|
472
|
+
<button type="button" class="wel-go">Got it</button>
|
|
473
|
+
</div>
|
|
474
|
+
</div>`,S.addEventListener("click",U=>{U.stopPropagation(),A()}),Qt(S,A),e.appendChild(S),a?.("nav","editing tour shown"))}function L(){y(),A()}function P(U){g||b||S||U.slide!==1||U.step!==0||lu(au)!=="1"&&E()}c.register({isOpen:()=>!!S,close:A,keydown:()=>(A(),!0)}),c.register({isOpen:()=>!!b,close:y,keydown:()=>(y(),!0)});function j(U){g||(h().on("slide",L),h().on("build",L),!(U.slide!==1||U.step!==0)&&lu(iu)!=="1"&&$())}return{start:j,startEditingTour:P,showWelcome:$,dismissWelcome:y,showEditingTour:E,dismissEditingTour:A}}Se();Ae();function uu({sectionsOf:e,checkOverflow:t,ResizeObs:n=typeof ResizeObserver=="function"?ResizeObserver:null,MutationObs:s=typeof MutationObserver=="function"?MutationObserver:null,schedule:a=c=>setTimeout(c)}){let c=[],h=new Set,f=0;function g(){f||(f=a(()=>{f=0;let oe=e();for(let pe of c)t(pe,oe.indexOf(pe)+1)})||1)}let b=n?new n(g):null,y=new Map,$=new WeakMap,S=new WeakSet,A=new WeakSet,E=oe=>[oe,...oe.querySelectorAll("*")].filter(pe=>!pe.parentElement?.closest(".terminal"));function L(oe,pe){if(!b)return;let D=y.get(oe);for(let z of pe)b.observe(z),D.push(z)}function P(oe){for(let pe=oe?.nodeType===1?oe:oe?.parentElement;pe;pe=pe.parentElement)if(h.has(pe))return pe;return null}let j=s?new s(oe=>{let pe=z=>!(z.nodeType===1?z:z.parentElement)?.closest(".terminal"),D=!1;for(let z of oe){let Ce=P(z.target);if(!(!Ce||!pe(z.target))){D=!0,z.type==="childList"&&($.delete(Ce),A.add(Ce));for(let ee of z.addedNodes)ee.nodeType===1&&ee.isConnected&&L(Ce,E(ee))}}D&&g()}):null,U=oe=>{oe.target.closest?.(".terminal")||g()};return{watch(oe){let pe=oe.filter(Boolean),D=new Set(pe);for(let[z,Ce]of y)if(!D.has(z)){for(let ee of Ce)b?.unobserve(ee);y.delete(z);for(let ee of["load","error"])z.removeEventListener(ee,U,!0)}c=pe,h=D;for(let z of c){let Ce=y.has(z);if(Ce&&!A.has(z))continue;if(Ce)for(let re of y.get(z))b?.unobserve(re);y.set(z,[]),A.delete(z);let ee=$.get(z);if(ee||$.set(z,ee=E(z)),L(z,ee),!Ce){S.has(z)||(S.add(z),j?.observe(z,{childList:!0,subtree:!0,characterData:!0}));for(let re of["load","error"])z.addEventListener(re,U,!0)}}g()},get watched(){return c.slice()}}}Se();Ae();function pu({config:e,root:t,embedded:n,sectionsOf:s,slideOf:a,navigate:c}){let h=!n&&e.playlist?.modules?.length?e.playlist:null,f=h?h.index??0:0,g=!!t.querySelector("section[data-module]");function b(){let $=[];return(s()||[]).forEach((S,A)=>{S.hasAttribute("data-module")&&$.push({title:S.getAttribute("data-module"),slide:A+1})}),$}function y($=b()){let S=-1;return $.forEach((A,E)=>{A.slide<=a()&&(S=E)}),S}return{get playlist(){return h},get index(){return f},get hasMarkers(){return g},get any(){return g||!!h},markers:b,currentMarkerIndex:y,gotoModule($){if(!h)return!1;let S=h.modules[f+$];return S?(c(S.href+($>0?"#/1/0":"#/999/999")),!0):!1},navigateToModule($){let S=h?.modules[$];S&&c(S.href+"#/1/0")},title(){if(g){let $=b();return $[y($)]?.title||""}return h?.modules[f]?.title||""}}}Se();Ae();function hu({root:e,overlays:t}){let n=null,s=[],a=[],c=0,h=null;function f(){n?.remove(),n=null,h=null}let g=S=>s[S]&&!s[S].blocked;function b(S,A=1){let E=s.length,L=P=>(P%E+E)%E;for(let P=0;P<E&&!g(L(S));P++)S+=A;c=vn(a,L(S),"narr-sel")}function y(S=c){if(!h||!g(S))return;let{onPick:A}=h,{value:E}=s[S];f(),A(E)}function $({title:S,lines:A=[],rows:E,current:L=null,onPick:P}){n&&f(),h={onPick:P},s=E,n=document.createElement("div"),n.className="decklight-narr decklight-choice";let j=document.createElement("div");j.className="narr-card",j.setAttribute("role","dialog"),j.setAttribute("aria-label",S);let U=document.createElement("div");U.className="narr-head",U.textContent=S,j.append(U);for(let D of A){let z=document.createElement("div");z.className="rec-line",z.textContent=D,j.append(z)}a=s.map((D,z)=>{let Ce=document.createElement("div");Ce.className="narr-row"+(D.blocked?" narr-blocked":"");let ee=document.createElement("span");if(ee.className="narr-row-label",ee.textContent=D.label,D.note||D.blocked){let re=document.createElement("span");re.className="narr-flavor",re.textContent=D.blocked||D.note,ee.append(re)}if(Ce.append(ee),D.figure){let re=document.createElement("span");re.className="choice-figure",re.textContent=D.figure,Ce.append(re)}return Ce.addEventListener("mouseenter",()=>{g(z)&&(c=vn(a,z,"narr-sel"))}),Ce.addEventListener("click",()=>y(z)),j.append(Ce),Ce});let oe=document.createElement("div");oe.className="rec-hint",oe.textContent="\u2191\u2193 choose \xB7 Enter picks \xB7 Esc closes",j.append(oe),n.append(j),Qt(n,f),e.appendChild(n);let pe=s.findIndex(D=>D.value===L&&!D.blocked);c=0,b(pe>=0?pe:0)}return t.register({isOpen:()=>!!n,close:f,keydown(S){if(S.key==="ArrowDown"||S.key==="ArrowUp"){let A=S.key==="ArrowDown"?1:-1;b(c+A,A)}else S.key==="Enter"?y():S.key==="Escape"&&f();return!0}}),{open:$,close:f,isOpen:()=>!!n}}Se();Ae();var Ni="rect, circle, ellipse, polygon, path",La=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`,fu=e=>e.length===1?`slide ${e[0]}`:`slides ${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function Qm(e){let t=e.matches(Ni)?[e]:[...e.children].filter(n=>n.matches(Ni));for(let n of t){let s=n.getAttribute("fill")==="none";n.style.removeProperty(s?"stroke":"fill")}}function mu({stage:e,editmode:t,choiceCard:n,toast:s,repaint:a,debugLog:c=()=>{}}){let h=b=>{let y=b.closest("section");return y?[...e().querySelectorAll(":scope > section")].indexOf(y)+1:0};async function f(b,y,{offer:$=!0}={}){let S=t();if(!S?.available?.())return s("concepts are set in write mode \u2014 decklight <deck.html>",3200),0;let A=new Set,E=b.map(j=>S.conceptTarget(j)).filter(j=>j&&!A.has(j.el)&&A.add(j.el)).filter(j=>j.name!==y);if(!E.length)return s(y?`already the \u201C${y}\u201D concept`:"no concept to take off",2200),0;try{await S.writeConcepts(E,y)}catch(j){return s(`concept not saved: ${String(j.message||j).slice(0,90)}`,3400),0}for(let j of E)y?j.el.setAttribute("data-concept",y):(j.el.removeAttribute("data-concept"),Qm(j.el));a();let L=[...new Set(E.map(j=>j.slide))].sort((j,U)=>j-U);c("concepts",`${La(E.length,"shape")} on ${fu(L)} \u2192 ${y??"(detached)"}`);let P=E.length===1&&$?"now":`${La(E.length,"shape")} now`;return s(y?`${P} the \u201C${y}\u201D concept \xB7 ${zt} takes it back`:`${E.length===1?"detached from its concept":`${E.length} shapes detached`} \xB7 ${zt} takes it back`,2600),y&&$&&b.length===1&&g(b[0],y),E.length}function g(b,y){let $=b.matches(Ni)?b:b.querySelector(Ni);if(!$)return!1;let S=Ud(e(),$,y);if(!S.length)return!1;let A=Ms($),E=[...new Set(S.map(h))].filter(Boolean).sort((L,P)=>L-P);return n.open({title:`the other \u201C${A}\u201D boxes`,lines:[`${La(S.length,"other shape")} on ${fu(E)} ${S.length===1?"says":"say"} \u201C${A}\u201D too.`],rows:[{label:`Make ${S.length===1?"it":`all ${S.length}`} the \u201C${y}\u201D concept`,value:"all",note:`one write \xB7 ${zt} takes it back`},{label:"Just this one",value:"one"}],onPick:L=>{L==="all"&&f(S,y,{offer:!1})}}),!0}return{attach:f,offerLookAlikes:g,suggestions:()=>Bo(e()),accept:b=>f(b.shapes,b.name,{offer:!1})}}Se();Ae();var gu="decklight-style-clip",bu=bs,Ma=Object.freeze({copy:bu?"\u2325\u2318C":"Ctrl+Alt+C",paste:bu?"\u2325\u2318V":"Ctrl+Alt+V"}),eg=/^(?:var\(--[a-z][a-z0-9-]{0,40}(?:,\s?#[0-9a-f]{3,8})?\)|#[0-9a-f]{3,8})$/i,tg={"font-size":/^(?:[1-9]\d{0,2}(?:\.\d)?)px$/,"font-weight":/^[1-9]00$/,"font-family":/^var\(--font-(?:heading|body|mono)\)$/,"font-style":/^(?:normal|italic)$/},ng=new Set(["fill","color","background-color","stroke","border-color"]),Pa={left:"start",center:"middle",right:"end",start:"start",middle:"middle",end:"end"},rg={start:"left",middle:"center",end:"right",left:"left",center:"center",right:"right"},_i=e=>typeof SVGElement<"u"&&e.el instanceof SVGElement,jo=(e,t)=>(t==="fill"&&e.dataset?.nestFill!==void 0&&!e.closest("[data-concept]")?e.dataset.nestFill:e.style.getPropertyValue(t)).trim(),qo=(e,t)=>getComputedStyle(e).getPropertyValue(t).trim(),Ra=(e,t)=>!!e&&!!t&&e.r===t.r&&e.g===t.g&&e.b===t.b;function Ia(e){if(!e)return null;let t=jo(e.el,e.prop),n=t&&!t.startsWith("var(")?us(t):null;return{token:eg.test(t)?t:n?yr(n):null,rgb:us(qo(e.el,e.prop))}}function sg(e){let t=e?.top&&Oo(e.top,e.clicked??e.node??e.top);if(!t)return null;let n=t.fill[0]??t.text[0],s=_i(n)?"svg":"html",a=t.stroke?.[0],c=s==="svg"?"stroke-width":"border-width",h=a?parseFloat(qo(a.el,c)):NaN,f=t.text[0],g={};if(f){for(let[y,$]of Object.entries(tg)){let S=jo(f.el,y);$.test(S)&&(g[y]=S)}let b=jo(f.el,_i(f)?"text-anchor":"text-align");Pa[b]&&(g.align=Pa[b])}return{kind:s,what:t.what,concept:t.concept?.name??null,fill:Ia(t.fill[0]),stroke:Ia(a),width:Number.isFinite(h)?String(Math.round(h*100)/100):null,text:Ia(f),type:g}}function og(e,t,{snap:n=null}={}){let s=t?.top&&Oo(t.top,t.clicked??t.node??t.top);if(!e||!s)return null;let a=[],c=[],h=A=>{if(!n||!A||A.startsWith("var(")&&!n.roles)return A;let E=n(A);return E?(c.push(E.ref),E.value):A},f=(A,E,L)=>{let P=jo(A.el,E);P!==(L??"")&&(ng.has(E)&&L&&P&&!L.startsWith("var(")&&!P.startsWith("var(")&&Ra(us(P),us(L))||a.push({t:A,prop:E,value:L}))},g=(A,E)=>{if(!A||!E)return;if(E.token){f(A,A.prop,h(E.token));return}let L=jo(A.el,A.prop),P=A.el.style.getPropertyValue(A.prop),j=A.el.style.getPropertyPriority(A.prop);P&&A.el.style.removeProperty(A.prop);let U=us(qo(A.el,A.prop));if(P&&A.el.style.setProperty(A.prop,P,j),!E.rgb){L&&!U&&f(A,A.prop,null);return}if(Ra(U,E.rgb)){L&&f(A,A.prop,null);return}Ra(us(qo(A.el,A.prop)),E.rgb)||f(A,A.prop,h(yr(E.rgb)))},b=s.fill[0],y=_i(b??s.text[0])?"svg":"html",$=null;if(y==="svg"&&s.conceptAt){let A=s.conceptAt;if(e.concept&&e.kind==="svg")A.name!==e.concept&&($={at:A,value:e.concept});else if(A.name&&b){$={at:A,value:null};let E=["fill","stroke"].map(L=>[L,b.el.style.getPropertyValue(L)]);for(let[L]of E)b.el.style.removeProperty(L);g(b,e.fill);for(let[L,P]of E)P&&b.el.style.setProperty(L,P)}else g(b,e.fill)}else g(b,e.fill);let S=s.stroke?.[0];if(S&&!($?.value&&S.el===b?.el&&b.el.getAttribute("fill")==="none")&&(g(S,e.stroke),e.stroke?.rgb&&e.width)){let A=y==="svg"?"stroke-width":"border-width";Math.abs(parseFloat(qo(S.el,A))-Number(e.width))>.01&&f(S,A,y==="svg"?e.width:`${e.width}px`)}for(let A of s.text){g(A,e.text);for(let E of["font-weight","font-family","font-style"])e.type[E]&&f(A,E,e.type[E]);if(e.type["font-size"]&&e.kind===y&&f(A,"font-size",e.type["font-size"]),e.type.align){let E=_i(A);f(A,E?"text-anchor":"text-align",(E?Pa:rg)[e.type.align])}}return{changes:a,concept:$,snapped:[...new Set(c)],snapRoles:!!n?.roles}}function yu(e){let t=a=>{let c=/^var\(--d-fill-(\d)\)$/.exec(Vs(a??""));return c?`fill ${c[1]}`:/^var\(--([a-z0-9-]+)/i.exec(a??"")?.[1]??a},n=e.concept?`\u201C${e.concept}\u201D`:t(e.fill?.token)??(e.fill?.rgb?yr(e.fill.rgb):null);return[/^(rect|circle|ellipse|polygon|path)$/.test(e.what)?"box":e.what,n].filter(Boolean).join(" \xB7 ")}function wu({save:e,toast:t,repaint:n=()=>{},snap:s=()=>null,debugLog:a=()=>{}}){let c=er(gu,null),h=()=>!!c;function f(b){let y=sg(b);return y?(c=y,yn(gu,JSON.stringify(y)),a("edit",`style copied: ${yu(y)}`),t(`style copied: ${yu(y)} \xB7 ${Ma.paste} pastes it on another shape`,2800),!0):(t("nothing here has a style to copy",2200),!1)}async function g(b){if(!c)return t(`no style copied yet: ${Ma.copy} on a shape copies its style`,2600),!1;let y=og(c,b,{snap:s()});if(!y)return t("nothing here takes a style",2200),!1;let{changes:$,concept:S}=y;if(!$.length&&!S)return t("already that style",2e3),!1;let A=$.map(P=>[P,P.t.el.style.getPropertyValue(P.prop),P.t.el.style.getPropertyPriority(P.prop),P.t.el.dataset?.nestFill]);for(let P of $)P.value===null?P.t.el.style.removeProperty(P.prop):P.t.el.style.setProperty(P.prop,P.value),P.prop==="fill"&&P.t.el.dataset?.nestFill!==void 0&&(P.t.el.dataset.nestFill=P.value??"");let E=S?.at.el,L=E?.getAttribute("data-concept")??null;E&&(S.value?E.setAttribute("data-concept",S.value):ig(E,$));try{await e({slide:b.slide,index:b.index,edits:$.map(P=>({path:P.t.path,tag:P.t.tag,prop:P.prop,value:P.value})),concept:S?{path:S.at.path,tag:S.at.tag,value:S.value}:null})}catch(P){for(let[j,U,oe,pe]of A)U?j.t.el.style.setProperty(j.prop,U,oe):j.t.el.style.removeProperty(j.prop),j.prop==="fill"&&pe!==void 0&&(j.t.el.dataset.nestFill=pe);return E&&(L?E.setAttribute("data-concept",L):E.removeAttribute("data-concept")),S&&n(),t(`style not pasted: ${String(P?.message||P).slice(0,90)}`,3400),!1}return S&&n(),a("edit",`style pasted on slide ${b.slide} #${b.index}: ${$.length} declaration${$.length===1?"":"s"}${S?`, concept ${S.value??"(detached)"}`:""}`),t(y.snapped.length?`style pasted, on the brand's ${y.snapRoles?"roles":"palette"}: ${y.snapped.join(", ")} \xB7 ${zt} takes it back`:`style pasted \xB7 ${zt} takes it back`,y.snapped.length?3200:2200),!0}return{copy:f,paste:g,has:h,clip:()=>c,keys:Ma}}function ig(e,t){e.removeAttribute("data-concept");let n=e.matches("rect, circle, ellipse, polygon, path")?[e]:[...e.children].filter(s=>s.matches("rect, circle, ellipse, polygon, path"));for(let s of n)for(let a of["fill","stroke"])t.some(c=>c.t.el===s&&c.prop===a)||s.style.removeProperty(a)}Se();Ae();var Da=[{value:"mp4",label:"MP4 \u2014 H.264, plays everywhere"},{value:"mov",label:"MOV \u2014 H.264, for QuickTime and Final Cut"},{value:"webm",label:"WebM \u2014 VP9, smaller, for the web"}],Ba=[{value:"draft",label:"Draft \u2014 quick and small, to check the timing"},{value:"standard",label:"Standard"},{value:"high",label:"High \u2014 slower to render, sharper, larger"}],Fa=[{value:"none",label:"None"},{value:"embed",label:"In the video \u2014 a track the player can turn on"},{value:"file",label:"Beside the video \u2014 .srt (.vtt for WebM)"}];Se();Ae();Se();Ae();function vu(e){let t=2166136261,n=String(e??"").replace(/\s+/g,"");for(let s=0;s<n.length;s++)t^=n.charCodeAt(s),t=Math.imul(t,16777619)>>>0;return t.toString(16).padStart(8,"0")}function ho(e,t){let n=Array.isArray(t)?t:[],s=Number(e?.slide);if(e?.fp){let c=n.find(h=>h.fp===e.fp);if(c)return{verdict:"exact",slide:c.slide,movedFrom:c.slide===s?null:s}}let a=String(e?.title??"").trim();if(a){let c=n.filter(h=>String(h.title??"").trim()===a);if(c.length===1)return{verdict:"stale",slide:c[0].slide,movedFrom:c[0].slide===s?null:s}}return!e?.fp&&Number.isInteger(s)&&s>=1&&s<=n.length?{verdict:"unanchored",slide:s,movedFrom:null}:{verdict:"orphaned",slide:null,movedFrom:null}}var qa={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 ja(e,{titleOf:t,bodyOf:n}){return e.map((s,a)=>{let c=n(s);return{slide:a+1,title:t(s,a,c),fp:vu(c)}})}function Gs(e){let t=new Map,n=[],s=[],a=[];for(let h of e){if(h.op==="resolve"||h.op==="reopen"){n.push(h);continue}if(h.op==="anchor"){s.push(h);continue}if(h.op==="delete"){a.push(h);continue}h.re||t.has(h.id)||t.set(h.id,{...h,resolved:null})}let c=n.map((h,f)=>({r:h,i:f})).sort((h,f)=>String(h.r.at??"").localeCompare(String(f.r.at??""))||h.i-f.i);for(let{r:h}of c){let f=t.get(h.re);f&&(f.resolved=h.op==="resolve"?{at:h.at??null,by:h.by??null}:null)}for(let h of s){let f=t.get(h.re);!f||!Number.isInteger(h.slide)||(f.slide=h.slide,f.title=h.title??null,f.fp=h.fp??null,f.anchored={at:h.at??null,by:h.by??null})}for(let h of a)t.delete(h.re);return[...t.values()]}function ku({root:e,params:t,overlays:n,instance:s,toast:a,debugLog:c,sections:h=()=>[],titleOf:f,bodyOf:g,editBase:b=()=>null,editReady:y=()=>Promise.resolve()}){let $=null,S=[],A=0,E=!1,L=null,P=null,j=[],U=null,oe=null,pe=!1,D=null,z=null,Ce=!1,ee=null,re=!1,le="decklight-review-hide-done:"+location.pathname,ie=er(le,!1)===!0,I=H=>Z("div","rv-skipped",`${H} done hidden \xB7 D shows them`),ce=ys({root:e,reflow:()=>s._reflow?.(),getEl:()=>$,closeLabel:"close (M)",name:"Comments",open:()=>{$||ft()},close:()=>{$&&M()}}),de=()=>ja(h(),{titleOf:f,bodyOf:g});async function Ie(){if(oe!==null)return oe||(oe===""?"":null);if(await y(),b()!=null)return oe=!1,null;try{let H=await fetch("/deck/ping"),te=H.ok?await H.json():null;oe=te?.ok&&te.review?"":!1}catch{oe=!1}return oe===!1?null:oe}async function V({incoming:H=!0}={}){let te=await Ie(),we=`${te!==null?te:b()??""}/deck/review/comments`;if(te===null&&b()==null)return{records:[],skipped:0,can:"none"};try{let Ke=await(await fetch(we)).json();if(!Ke?.ok)throw new Error(Ke?.error||"unreadable");let ae={records:Ke.records??[],skipped:Ke.skipped??0,can:te!==null?"comment":"resolve"};if(ae.can==="resolve"&&H)try{let bt=await(await fetch(`${b()??""}/deck/review/incoming`)).json();bt?.ok&&(ae.incoming=bt)}catch{}return ae}catch(Ee){return c("review",`could not read comments: ${String(Ee.message||Ee)}`),{records:[],skipped:0,can:"none",error:String(Ee.message||Ee)}}}let Z=(H,te,we)=>{let Ee=document.createElement(H);return te&&(Ee.className=te),we!=null&&(Ee.textContent=we),Ee},T=H=>H.by?H.by.replace(/\s*<[^>]*>$/,""):"someone";function F(H,te,{branch:we=null,done:Ee=!1}={}){let Ke=ho(H,te),ae=Z("div",`rv-row${H.resolved?" rv-resolved":""}${we?" rv-inc":""}${Ee?" rv-done":""}`);ae.setAttribute("role","option"),ae.dataset.id=H.id;let Ze=Z("div","rv-head");Ze.append(Z("span","rv-slide",Ke.slide?`slide ${Ke.slide}`:"slide gone")),Ze.append(Z("span","rv-who",T(H))),H.deck&&Ze.append(Z("span","rv-at",`@${H.deck}`)),Ke.movedFrom&&Ze.append(Z("span","rv-moved",`was ${Ke.movedFrom}`)),H.resolved&&Ze.append(Z("span","rv-tick","\u2713")),ae.append(Ze),ae.append(Z("div","rv-body",H.body??""));let bt=qa[Ke.verdict];if(bt&&ae.append(Z("div","rv-note",`\u26A0 ${bt}`)),U?.id===H.id){let ke=U.data;ae.append(Z("div","rv-then",ke.known?`what it said \u2014 slide ${ke.slide}${ke.title?` \xB7 ${ke.title}`:""}${ke.deck?` \xB7 @${ke.deck}`:""}:
|
|
475
|
+
${ke.text||"(nothing)"}`:`cannot show what it said \u2014 ${ke.why}`))}L===H.id&&ae.append(Z("div","rv-arm",`move this comment to slide ${s.state.slide} (the one on screen)? A again to confirm \xB7 Esc backs out`)),P===H.id&&ae.append(Z("div","rv-arm","delete this comment? \u232B again to confirm \xB7 Esc backs out"));let Pe={id:H.id,slide:Ke.slide,node:ae,resolved:!!H.resolved,branch:we,done:Ee};return ae.addEventListener("click",()=>{_e(S.indexOf(Pe)),G()}),S.push(Pe),ae}function se(H){let te=S[A]?.id??null,we=$.querySelector(".narr-card"),Ee=ee&&document.activeElement===ee.input,Ke=Ee?[ee.input.selectionStart,ee.input.selectionEnd]:null;we.replaceChildren();let ae=de(),Ze=s.state.slide;S=[],j=H.incoming?.reviews??[];let bt=Z("div","narr-head");if(bt.append(Z("span","rv-heading","comments")),bt.append(ce.controls(M)),ce.wireHeader(bt),we.append(bt),H.incoming){let Y=H.incoming;if(Y.reviews?.length){let ve=Z("div","rv-incoming"),Ne=[...Y.reviews].sort((ut,ht)=>Number(ut.done)-Number(ht.done));for(let ut of Ne){let ht=new Set(ut.doneIds??[]),vt=Gs(ut.records??[]).filter(Ct=>!Ct.resolved),mt=vt.filter(Ct=>!ht.has(Ct.id)).length;ve.append(Z("div",`rv-src${ut.done?" rv-done":""}`,ut.done?`\u2713 ${ut.who} \u2014 all ${vt.length} done \xB7 ${ut.branch}`:`\u2193 ${ut.who} \u2014 ${mt} of ${vt.length} left \xB7 ${ut.branch}`));let Ue=[...vt].sort((Ct,Pt)=>Number(ht.has(Ct.id))-Number(ht.has(Pt.id)));for(let Ct of Ue)ie&&ht.has(Ct.id)||ve.append(F(Ct,ae,{branch:ut.branch,done:ht.has(Ct.id)}));let Dt=ie?vt.length-mt:0;Dt&&ve.append(I(Dt))}we.append(ve)}else Y.state&&!["ok","none","no-repo","untracked","no-remote","suppressed"].includes(Y.state)&&we.append(Z("div","rv-inc-how",`incoming reviews: not checked \u2014 ${Y.state}`))}let Pe=Z("div","rv-list");Pe.setAttribute("role","listbox");let ke=Gs(H.records);if(H.error?Pe.append(Z("div","rv-none",`could not read the comments \u2014 ${H.error}`)):ke.length||Pe.append(Z("div","rv-none",H.can==="none"?"no comments, and nothing here can take one \u2014 open the deck with decklight to leave one":"no comments yet")),H.skipped&&Pe.append(Z("div","rv-skipped",`${H.skipped} line(s) could not be read and were skipped`)),H.incoming?.reviews?.length&&ke.length){let Y=ke.filter(ve=>!ve.resolved).length;Pe.append(Z("div","rv-src",Y?`\u270E your comments \u2014 ${Y} of ${ke.length} left`:`\u2713 your comments \u2014 all ${ke.length} done`))}let Fe=[...ke].sort((Y,ve)=>+!!Y.resolved-+!!ve.resolved);for(let Y of Fe)ie&&Y.resolved||Pe.append(F(Y,ae));let Ve=ie?ke.filter(Y=>Y.resolved).length:0;if(Ve&&Pe.append(I(Ve)),we.append(Pe),H.can==="comment"){let Y=Z("div",`rv-submit${E?" rv-arm":""}`,E?"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)");Y.setAttribute("role","button"),Y.tabIndex=0,Y.addEventListener("click",()=>K()),we.append(Y)}we.append(Z("div","rec-hint",H.can==="resolve"?j.length?"\u23CE jumps \xB7 R marks one done, again reopens it \xB7 D hides done \xB7 A moves here \xB7 \u232B deletes yours \xB7 \u21E7M writes \xB7 Esc closes":"\u23CE jumps (on a gone slide: shows what it said) \xB7 R marks one done, again reopens it \xB7 D hides done \xB7 A moves here \xB7 \u232B deletes yours \xB7 \u21E7M writes \xB7 Esc closes":H.can==="comment"?"\u23CE jumps to the slide \xB7 \u21E7M writes \xB7 \u232B deletes yours \xB7 S submits the review \xB7 Esc closes":"\u23CE jumps to the slide \xB7 Esc closes")),Ce&&(we.append(l()),Ee&&(ee.input.focus(),ee.input.setSelectionRange(...Ke)));let et=te===null?-1:S.findIndex(Y=>Y.id===te);_e(et>=0?et:Math.min(A,Math.max(0,S.length-1))),ce.placeCard()}function _e(H){S.length&&(A=vn(S.map(te=>te.node),H,"rv-sel"))}function Te(){if(!ee)return;let H=s.state.slide,te=de()[H-1]?.title;ee.on.textContent=`on slide ${H}${te?` \xB7 ${te}`:""}`}function l(){if(!ee){let H=Z("div","rv-compose"),te=Z("div","rv-on"),we=Z("textarea","narr-input rv-input");we.placeholder="leave a comment on this slide\u2026",we.rows=2,we.setAttribute("aria-label","Leave a comment on the slide on screen");let Ee=Z("div","narr-row narr-sel rv-send","Leave this comment");Ee.setAttribute("role","button"),Ee.tabIndex=0;let Ke=async()=>{let ae=we.value;if(!ae.trim()){we.focus();return}let Ze=s.state.slide;we.value="",!await ot(ae,Ze,de()[Ze-1])&&!we.value&&(we.value=ae)};Ee.addEventListener("click",Ke),we.addEventListener("keydown",ae=>{ae.key==="Enter"&&(ae.metaKey||ae.ctrlKey)?(ae.preventDefault(),Ke()):ae.key==="Escape"&&!ae.isComposing&&(ae.preventDefault(),M()),ae.stopPropagation()}),H.append(te,we,Ee),ee={box:H,on:te,input:we}}return Te(),ee.box}function d(){return ee?.box.isConnected?(pe=!0,ee.input.focus(),!0):!1}function G(){let H=S[A];if(H){if(!H.slide){be(H);return}s.goto(H.slide,0,{force:!0})}}async function be(H){if(U?.id===H.id){U=null,se(await V());return}let te=b();if(te==null){a("only the edit server can look that far back");return}try{let we=await fetch(`${te}/deck/review/at?id=${encodeURIComponent(H.id)}`),Ee=await we.json();if(!Ee?.ok)throw new Error(Ee?.error||`HTTP ${we.status}`);U={id:H.id,data:Ee}}catch(we){U={id:H.id,data:{known:!1,why:String(we.message||we)}}}se(await V())}async function J(){let H=S[A];if(!H||H.resolved)return;let te=b();if(te==null)return;if(L!==H.id){L=H.id,P=null,se(await V());return}if(L=null,H.branch){a("this comment is on a review branch \u2014 only your own comments can be moved");return}let we=s.state.slide,Ee=de()[we-1];try{if(!(await(await fetch(`${te}/deck/review/comments`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({op:"anchor",re:H.id,slide:we,title:Ee?.title,fp:Ee?.fp})})).json())?.ok)throw new Error("refused");a(`moved to slide ${we}`),U=null}catch(Ke){a(`could not move that \u2014 ${String(Ke.message||Ke)}`)}se(await V())}async function Qe(){let H=S[A];if(!H)return;let te=await Ie(),we=te!==null?te:b();if(we!=null){if(H.branch){a("this comment is on a review branch \u2014 only your own comments can be deleted");return}if(P!==H.id){P=H.id,L=null,se(await V());return}P=null;try{if(!(await(await fetch(`${we}/deck/review/comments`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({op:"delete",re:H.id})})).json())?.ok)throw new Error("refused");a("deleted"),c("review",`${H.id} deleted`),U=null}catch(Ee){a(`could not delete that \u2014 ${String(Ee.message||Ee)}`)}se(await V())}}async function ot(H,te,we){let Ee=String(H??"").trim();if(!Ee)return!1;let Ke=await Ie(),ae=Ke!==null?{url:`${Ke}/deck/review/comments`,mine:!1}:b()!=null?{url:`${b()}/deck/review/comments`,mine:!0}:null;if(!ae)return!1;try{let Ze=await fetch(ae.url,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:te,title:we?.title,fp:we?.fp,body:Ee})}),bt=await Ze.json();if(!bt?.ok)throw new Error(bt?.error||`HTTP ${Ze.status}`);return a(`comment left on slide ${te}`),c("review",`comment ${bt.id} on slide ${te}`),$&&se(await V()),!0}catch(Ze){return a(`could not leave that comment \u2014 ${String(Ze.message||Ze)}`),!1}}async function fe(){let H=S[A];if(!H)return;let te=b();if(te==null)return;let we=(H.branch?H.done:H.resolved)?"reopen":"resolve";try{if(!(await(await fetch(`${te}/deck/review/comments`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({op:we,re:H.id})})).json())?.ok)throw new Error("refused");a(we==="resolve"?H.branch?"done":"resolved":"reopened"),c("review",`${H.branch?`${H.branch} `:""}${H.id} ${we==="resolve"?"resolved":"reopened"}`)}catch(Ee){a(`could not ${we} that \u2014 ${String(Ee.message||Ee)}`)}se(await V())}async function K(){let H=await Ie();if(H===null){a("nothing here can submit \u2014 open the deck with decklight <deck> --no-trust");return}if(!E){E=!0,se(await V());return}E=!1;try{let te=await fetch(`${H}/deck/review/submit`,{method:"POST"}),we=await te.json();if(!we?.ok)throw new Error(we?.error||`HTTP ${te.status}`);a(`review pushed \u2192 ${we.branch}`),c("review",`submitted ${we.comments} comment(s) to ${we.branch}`)}catch(te){a(`could not submit \u2014 ${String(te.message||te)}`)}se(await V())}let ue=null;function at(){ue?.remove(),ue=null}async function N(){if(ue)return at();if($&&d())return;let H=await Ie(),te=b();if(H===null&&te==null){a("nothing here can take a comment \u2014 open the deck with decklight <deck>");return}n.opening(),M();let we=s.state.slide;ue=document.createElement("div"),ue.className="decklight-narr decklight-compose",ue.innerHTML='<div class="narr-card" role="dialog" aria-label="Leave a comment"></div>',Qt(ue,at),e.appendChild(ue);let Ee=ue.querySelector(".narr-card"),Ke=de();Ee.append(Z("div","narr-head","leave a comment")),Ee.append(Z("div","rv-on",`on slide ${we}${Ke[we-1]?.title?` \xB7 ${Ke[we-1].title}`:""}`));let ae=Z("textarea","narr-input rv-input");ae.placeholder="what you want remembered about this slide\u2026",ae.rows=3;let Ze=Z("div","narr-row narr-sel rv-send","Leave this comment");Ze.setAttribute("role","button"),Ze.tabIndex=0;let bt=async()=>{if(!ae.value.trim()){ae.focus();return}await ot(ae.value,we,Ke[we-1]),at()};Ze.addEventListener("click",bt),ae.addEventListener("keydown",et=>{et.key==="Enter"&&(et.metaKey||et.ctrlKey)&&(et.preventDefault(),bt()),et.key==="Escape"&&!et.isComposing&&(et.preventDefault(),at()),et.stopPropagation()}),Ee.append(ae,Ze),Ee.append(Z("div","rec-hint","\u2318\u23CE leaves it \xB7 Esc closes \xB7 M reads them all")),setTimeout(()=>ae.focus(),0);let Pe=await V();if(!ue)return;let ke=Gs(Pe.records??[]).filter(et=>!et.resolved&&ho(et,Ke).slide===we),Fe=(Pe.incoming?.reviews??[]).flatMap(et=>Gs(et.records??[]).filter(Y=>!Y.resolved&&ho(Y,Ke).slide===we).map(Y=>({c:Y,who:et.who})));if(!ke.length&&!Fe.length)return;let Ve=Z("div","rv-already");Ve.append(Z("div","rv-src",`already on this slide \u2014 ${ke.length+Fe.length}`));for(let et of ke)Ve.append(Z("div","rv-said",`${T(et)}: ${et.body}`));for(let{c:et,who:Y}of Fe)Ve.append(Z("div","rv-said",`${Y}: ${et.body}`));Ee.append(Ve)}async function ft(){if($)return M();n.opening(),E=!1,L=null,P=null,U=null,A=0,$=document.createElement("div"),$.className="decklight-narr decklight-dockable decklight-review",$.dataset.dock=ce.mode,$.innerHTML='<div class="narr-card" role="dialog" aria-label="Review comments"></div>',e.appendChild($),pe=ce.isFloat(),z=H=>{pe=!!$&&$.contains(H.target)},document.addEventListener("pointerdown",z,!0),document.addEventListener("focusin",z,!0),D=()=>ce.reserveGutter(),window.addEventListener("resize",D),ce.reserveGutter(),se({records:[],skipped:0,can:"none"}),re||(re=!0,s.on("slide",()=>{$&&Te()})),await y(),Ce=await Ie()!==null||b()!=null,$&&se(await V())}function M(){$?.remove(),$=null,E=!1,L=null,P=null,U=null,pe=!1,ce.release(),D&&(window.removeEventListener("resize",D),D=null),z&&(document.removeEventListener("pointerdown",z,!0),document.removeEventListener("focusin",z,!0),z=null)}return n.register({isOpen:()=>!!ue,close:at,keydown(H){return H.key==="Escape"?(at(),!0):!1}}),n.register({isOpen:()=>!!$,close:M,panel:!0,modal:()=>pe,keydown(H){let te=/^(input|textarea)$/i.test(H.target?.tagName??"");if(H.key!=="Escape"&&!(H.key==="m"||H.key==="M")&&!pe)return!1;if(H.key==="Escape")return E||L||P?(E=!1,L=null,P=null,V().then(we=>$&&se(we)),!0):(M(),!0);if(te)return!1;switch(H.key){case"ArrowDown":_e(A+1);break;case"ArrowUp":_e(A-1);break;case"Enter":G();break;case"r":case"R":fe();break;case"s":case"S":K();break;case"a":case"A":J();break;case"Backspace":case"Delete":Qe();break;case"d":case"D":ie=!ie,xr(le,ie),c("review",ie?"done comments hidden":"done comments shown"),V().then(we=>$&&se(we));break;case"m":case"M":H.shiftKey?d()||N():M();break;default:return!1}return!0}}),t?.has?.("review")&&setTimeout(()=>{n.active()||ft()},700),{open:ft,close:M,isOpen:()=>!!$,compose:N,submit:async()=>{$||await ft(),E=!0,$&&se(await V())},countFor:async H=>{let te=await V({incoming:!1});if(te.can==="none")return null;let we=de(),Ee=0,Ke=0;for(let ae of Gs(te.records??[]))ho(ae,we).slide===H&&(ae.resolved?Ke++:Ee++);return{open:Ee,resolved:Ke}}}}Se();Ae();var ag=["auto","centered","pinned","top","split","split-flip"];function lg({autoPins:e,hasSplitPair:t}){return ag.filter(n=>(n!=="pinned"||!e)&&(n!=="split-flip"||t))}function cg(e,t,n){if(!e.length)return null;let s=Math.max(0,e.indexOf(t));return e[(s+n+e.length)%e.length]}function xu({slideOf:e,sectionAt:t,describe:n,available:s,unavailableMessage:a,apply:c,relayout:h,post:f,toast:g,debugLog:b,schedule:y=setTimeout,cancel:$=clearTimeout,delay:S=600}){let A=null,E=null;function L(){$(E);let U=A;A=null,U&&f({slide:U.slide,layout:U.name}).then(()=>b("layout",`slide ${U.slide}: ${U.name} \u2192 saved to file`)).catch(()=>g("layout save failed \u2014 is the dev server still up?",2200))}function P(U=e()){let oe=t(U);return oe?lg(n(oe)):[]}function j(U){if(!s()){g(a(),3200);return}let oe=e(),pe=t(oe);if(!pe)return;let D=pe.getAttribute("data-template")||"";if(D){g(`layout: this slide is the ${D} template \u2014 the design system lays it out; L does not cycle it`,3200);return}let z=cg(P(oe),pe.getAttribute("data-layout")||"auto",U);if(!z)return;c(pe,z),A&&A.slide!==oe&&L(),A={slide:oe,name:z},$(E),E=y(L,S);let Ce=h(pe,oe);g(Ce?`layout: ${z} \u2014 fights this slide's own column flexbox; pick one`:`layout: ${z}`),b("layout",`slide ${oe}: ${z}`)}return{ring:P,cycle:j,flush:L}}Se();Ae();var dg=e=>e.cat?`${e.cat}: ${e.label}`:e.label,ug=e=>String(e).toLowerCase().replace(/:/g," ").split(/\s+/).filter(Boolean);function Eu(e,t){let n=ug(t);if(!n.length)return 1;let s=dg(e).toLowerCase(),a=`${s} ${String(e.alias??"").toLowerCase()}`;if(!n.every(h=>a.includes(h)))return 0;let c=String(t).trim().toLowerCase();return s.startsWith(c)||String(e.label).toLowerCase().startsWith(c)?3:n.every(h=>s.includes(h))?2:1}function $u({commands:e,query:t="",categories:n=[],totalSlides:s=0,makeGotoRow:a,makeSearchRow:c}){let h=String(t).trim(),f=y=>{let $=n.indexOf(y.cat);return $===-1?n.length:$},g=e.map((y,$)=>({c:y,i:$,rank:Eu(y,h)})).filter(y=>y.rank>0).sort((y,$)=>(h?$.rank-y.rank:0)||f(y.c)-f($.c)||y.i-$.i).map(y=>y.c),b=h.match(/^(?:goto\s*)?(\d+)$/i);if(b&&a){let y=Math.max(1,Math.min(parseInt(b[1],10),s));g=[a(y,s),...g]}return h&&!b&&c&&!g.some(y=>Eu(y,h)===3)&&g.push(c(t)),g}Se();Ae();function Su({root:e,base:t,toast:n,debugLog:s=()=>{}}){let a=null,c=[],h=0,f=!1,g=()=>a?.querySelector(".narr-card");function b(L){let P=g();if(!P)return;if(L.loading){P.innerHTML='<div class="narr-head">design systems</div><div class="rec-line">asking the edit server\u2026</div>';return}if(L.error){P.innerHTML=`<div class="narr-head">design systems</div><div class="rec-line rec-warn">${Et(L.error)}</div><div class="rec-hint">Esc to close</div>`;return}let{systems:j,stale:U,unfetched:oe=[]}=L,pe=new Map;for(let z of j)pe.has(z.group)||pe.set(z.group,[]),pe.get(z.group).push(z);let D='<div class="narr-head">design systems \u2014 \u25CF this deck uses it \xB7 Space toggles</div>';c=[];for(let[z,Ce]of pe){D+=`<div class="narr-group">${Et(z)}</div>`;for(let ee of Ce){let re=c.length;c.push(ee),D+=`<div class="narr-row ds-row${ee.used?" narr-cur":""}${ee.missing?" narr-blocked":""}" data-i="${re}"><span class="narr-row-label">${ee.used?"\u25CF":"\u25CB"} ${Et(ee.qualified)}${ee.version?` <span class="narr-flavor">${Et(ee.version)}</span>`:""}${ee.description?` <span class="narr-flavor">${Et(ee.description)}</span>`:""}</span>${ee.missing?`<div class="narr-fix">${Et(ee.missing)}</div>`:""}</div>`}}j.length||(D+='<div class="rec-line">No registered marketplace offers a design system \u2014 decklight marketplace add <owner/repo></div>');for(let z of oe)D+=`<div class="rec-line">${Et(z)} has not been fetched yet \u2014 decklight marketplace update ${Et(z)}</div>`;for(let z of U)D+=`<div class="rec-line rec-warn">${Et(z)}'s cached catalog could not be read \u2014 decklight marketplace update ${Et(z)}</div>`;D+='<div class="rec-hint">\u2191/\u2193 \xB7 Space or \u23CE toggles \u2014 with its recommended themes and fonts (\u21E7 for the design system alone) \xB7 Esc closes</div>',P.innerHTML=D,P.querySelectorAll(".ds-row").forEach(z=>{z.addEventListener("mouseenter",()=>y(Number(z.dataset.i))),z.addEventListener("click",Ce=>{y(Number(z.dataset.i)),S(Ce.shiftKey)})}),y(Math.min(h,Math.max(0,c.length-1)))}function y(L){h=L,vn([...g()?.querySelectorAll(".ds-row")??[]],L,"narr-sel")}async function $(){if(!a){if(t()===null){n("design systems are referenced in write mode \u2014 decklight <deck.html>",3200);return}a=document.createElement("div"),a.className="decklight-narr decklight-record decklight-design-systems",a.innerHTML='<div class="narr-card" role="listbox" aria-label="Design systems"></div>',Qt(a,A),e.appendChild(a),h=0,b({loading:!0});try{let L=await fetch(`${t()}/deck/edit/design-system/browse`),P=await L.json();if(!L.ok||!P.ok)throw new Error(P.error??`the edit server answered ${L.status}`);b({systems:P.systems??[],stale:P.stale??[],unfetched:P.unfetched??[]})}catch(L){b({error:`could not list design systems \u2014 ${L.message??L}`})}}}async function S(L=!1){let P=c[h];if(!(!P||f)){if(P.missing&&!P.used){n(`${P.qualified}: ${P.missing}`,6e3);return}f=!0;try{let j=await fetch(`${t()}/deck/edit/design-system/mark`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ref:P.qualified,used:!P.used,recommended:!L})}),U=await j.json().catch(()=>({}));if(!j.ok||!U.ok)throw new Error([U.error,...(U.problems??[]).slice(0,2)].filter(Boolean).join(" \xB7 ")||`the edit server answered ${j.status}`);s("design-system",`${U.used?"referenced":"dropped"} ${U.ref}`);let oe=(U.pulled??[]).filter(z=>z.status==="add"),pe=oe.length?` \u2014 with ${oe.map(z=>`${z.kind} ${z.family??z.ref}`).join(", ")}`:"",D=(U.pulled??[]).filter(z=>z.status==="skip");n(U.changed?U.used?`\u25CF this deck now uses ${U.ref}${pe}${D.length?` \xB7 \u26A0 not added: ${D.map(z=>`${z.rec} (${z.why})`).join("; ")}`:""} \u2014 its templates are in / \u2192 Use slide template\u2026 \xB7 ${zt} takes it back`:`\u25CB dropped ${U.ref} \u2014 ${zt} takes it back`:`${U.ref}: nothing to change`,U.used&&U.changed?7e3:3200),U.used&&U.look?.differs&&pg({ref:U.ref,...U.look}),A()}catch(j){n(`${P.qualified} \u2014 ${j.message??j}`,7e3)}finally{f=!1}}}function A(){a?.remove(),a=null,c=[]}function E(L){return L.key==="Escape"?(A(),!0):L.key==="ArrowDown"?(y(Math.min(c.length-1,h+1)),!0):L.key==="ArrowUp"?(y(Math.max(0,h-1)),!0):((L.key===" "||L.key==="Enter")&&S(L.shiftKey),!0)}return{open:$,close:A,keydown:E,isOpen:()=>!!a}}var Ha=()=>"decklight-look-offer:"+location.pathname;function pg(e){try{sessionStorage.setItem(Ha(),JSON.stringify(e))}catch{}}function hg(){try{let e=sessionStorage.getItem(Ha());return sessionStorage.removeItem(Ha()),e?JSON.parse(e):null}catch{return null}}function Au({root:e,base:t,toast:n,preview:s,restore:a,keep:c,debugLog:h=()=>{}}){let f=null,g=null,b=null,y=!1;function $(j){if(f||!j||!j.theme&&!j.font)return;g=j,b=s(j),f=document.createElement("div"),f.className="decklight-narr decklight-look-offer";let U=j.phrase||[j.themeChanges&&`theme ${j.theme}`,j.fontChanges&&`font ${j.font}`].filter(Boolean).join(", ");f.innerHTML=`<div class="narr-card" role="dialog" aria-label="Apply the design system's look"><div class="narr-head">apply ${Et(j.title||j.ref)}'s look?</div><div class="rec-line">${Et(U)} \u2014 the slide shows it now</div><div class="rec-hint">\u23CE Apply \xB7 Esc Keep current</div></div>`,Qt(f,A),e.appendChild(f)}function S(){f?.remove(),f=null}function A(){f&&(a(b),S(),n(`kept the current look \u2014 Use slide template\u2026 offers ${g.title||g.ref}'s again`,3600))}async function E(){if(!(!f||y)){y=!0;try{let j=await fetch(`${t()}/deck/edit/design-system/apply`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ref:g.ref})}),U=await j.json().catch(()=>({}));if(!j.ok||!U.ok)throw new Error(U.error||`the edit server answered ${j.status}`);c(U.look??g),S(),n(`${g.title||g.ref}'s look applied${U.look?.phrase?` \u2014 ${U.look.phrase}`:""} \xB7 Z puts the old look back`,4200),h("design-system",`applied ${g.ref}'s look`)}catch(j){a(b),S(),n(`could not apply the look \u2014 ${j.message??j}`,6e3)}finally{y=!1}}}function L(j){return j.key==="Enter"?(E(),!0):(j.key==="Escape"&&A(),!0)}function P(){let j=hg();j&&$(j)}return{show:$,resume:P,keydown:L,close:A,isOpen:()=>!!f}}function Cu({root:e,base:t,toast:n,deck:s,lookHint:a=()=>null,offerLook:c=()=>{},debugLog:h=()=>{}}){let f=null,g=[],b=0,y="templates",$=null,S=!1,A=()=>f?.querySelector(".narr-card");function E(){let Ce=[];for(let ee of document.querySelectorAll('script[type="application/json"][data-design-system-meta]')){let re;try{re=JSON.parse(ee.textContent)}catch{continue}for(let le of re.templates??[])Ce.push({system:re.name,title:re.title,ref:`${re.name}/${le.id}`,template:le})}return Ce}function L(Ce){let ee=A()?.querySelector(".dsl-preview");if(!ee||(ee.replaceChildren(),!Ce))return;let re=document.createElement("section");re.className="dsl-preview-slide",re.setAttribute("data-template",Ce),ee.appendChild(re),hi([re],{systems:Pr()});for(let le of re.querySelectorAll("[data-slot]"))!le.textContent.trim()&&!le.children.length&&(le.textContent=le.getAttribute("data-slot"),le.classList.add("dsl-placeholder"))}function P(){let Ce=A();if(!Ce)return;let ee=s().state.slide,re=s()._sections[ee-1]?.getAttribute("data-template")??"";g=[];let le="";if(y==="templates"){let ie=E();le+=`<div class="narr-head">use a slide template \u2014 slide ${ee}${oo(re)?` is ${Et(re)}`:""}</div>`,le+='<div class="dsl-split"><div class="dsl-list">';let I=a();I&&(g.push({look:I}),le+=`<div class="narr-row dsl-row dsl-look" data-i="${g.length-1}"><span class="narr-row-label">\u2726 Not in ${Et(I.title||I.ref)}'s look \u2014 apply? <span class="narr-flavor">${Et([I.themeChanges&&`theme ${I.theme}`,I.fontChanges&&`font ${I.fontLabel??I.font}`].filter(Boolean).join(" \xB7 "))}</span></span></div>`),oo(re)&&(g.push({remove:!0}),le+=`<div class="narr-row dsl-row" data-i="${g.length-1}"><span class="narr-row-label">\u21A9 Take slide ${ee} out of ${Et(re)} <span class="narr-flavor">back to a plain slide</span></span></div>`);let ce=null;for(let de of ie){de.system!==ce&&(ce=de.system,le+=`<div class="narr-group">${Et(de.title??de.system)}</div>`);let Ie=g.length;g.push(de);let V=de.template.slots.map(Z=>`${Z.name}${Z.required?"*":""}`).join(" \xB7 ");le+=`<div class="narr-row dsl-row${de.ref===re?" narr-cur":""}" data-i="${Ie}"><span class="narr-row-label">${Et(de.ref)} <span class="narr-flavor">${Et(V)}</span></span></div>`}ie.length||(le+='<div class="rec-line">This deck uses no design system \u2014 Design systems\u2026 adds one.</div>'),le+='</div><div class="dsl-preview" aria-hidden="true"></div></div>',le+='<div class="rec-hint">\u2191/\u2193 \xB7 \u23CE chooses \xB7 Esc closes</div>'}else{let ie=oo(re);g=[{act:"apply"},{act:"insert"}],le+=`<div class="narr-head">${Et($.ref)}</div><div class="narr-row dsl-row" data-i="0"><span class="narr-row-label">${ie?"Switch":"Put"} slide ${ee} ${ie?"to":"in"} it <span class="narr-flavor">${ie?"content stays by slot name":"its content assigned to slots by their hints"}</span></span></div><div class="narr-row dsl-row" data-i="1"><span class="narr-row-label">Insert a new slide in it after slide ${ee} <span class="narr-flavor">its required slots, ready to fill</span></span></div><div class="rec-hint">\u23CE does it \xB7 Esc back</div>`}Ce.innerHTML=le,Ce.querySelectorAll(".dsl-row").forEach(ie=>{ie.addEventListener("mouseenter",()=>j(Number(ie.dataset.i))),ie.addEventListener("click",()=>{j(Number(ie.dataset.i)),oe()})}),j(Math.min(b,Math.max(0,g.length-1)))}function j(Ce){b=Ce,vn([...A()?.querySelectorAll(".dsl-row")??[]],Ce,"narr-sel"),y==="templates"&&L(g[Ce]?.ref??null)}async function U(Ce,ee){if(!S){S=!0;try{let re=await fetch(`${t()}/deck/edit/slide/template`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(Ce)}),le=await re.json().catch(()=>({}));if(!re.ok||!le.ok)throw new Error(le.error??`the edit server answered ${re.status}`);h("design-system",`slide ${Ce.slide}: ${le.said}`),n(`${le.said} \u2014 ${zt} takes it back`,6e3),D()}catch(re){n(`${ee}: ${re.message??re}`,7e3)}finally{S=!1}}}function oe(){let Ce=s().state.slide,ee=g[b];if(ee)return y==="templates"?ee.look?(D(),c(ee.look)):ee.remove?U({slide:Ce,template:null},"could not take the slide out"):($=ee,y="actions",b=0,P()):ee.act==="insert"?U({slide:Ce,template:$.ref,insert:!0},"could not insert the slide"):U({slide:Ce,template:$.ref},"could not lay the slide out")}function pe(){if(!f){if(t()===null){n("slide templates are chosen in write mode \u2014 decklight <deck.html>",3200);return}f=document.createElement("div"),f.className="decklight-narr decklight-record decklight-ds-templates",f.innerHTML='<div class="narr-card" role="listbox" aria-label="Use slide template"></div>',Qt(f,D),e.appendChild(f),y="templates",b=0,P()}}function D(){f?.remove(),f=null,g=[]}function z(Ce){return Ce.key==="Escape"?(y==="actions"?(y="templates",b=0,P()):D(),!0):Ce.key==="ArrowDown"?(j(Math.min(g.length-1,b+1)),!0):Ce.key==="ArrowUp"?(j(Math.max(0,b-1)),!0):(Ce.key==="Enter"&&oe(),!0)}return{open:pe,close:D,keydown:z,isOpen:()=>!!f}}Se();Ae();Se();Ae();var Oi=[["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"]],Zx=Oi.map(([e])=>e);var Tu=/^[A-Za-z0-9][A-Za-z0-9 _-]{0,63}$/,Nu=/^[A-Za-z0-9 ,'"_-]{1,260}$/,fg=/^decklight-font\/[\w.-]+\/[\w.-]+\/[\w./-]+\.(woff2|woff)$/;function mg(e=document){let t=[];for(let n of e.querySelectorAll('script[type="application/json"][data-font-meta]')){let s;try{s=JSON.parse(n.textContent)}catch{continue}!s||!Tu.test(s.family??"")||!Nu.test(s.stack??"")||t.push({id:n.getAttribute("data-font-meta"),label:s.title||s.family,stack:s.stack,family:s.family,kind:"deck"})}return t}function gg(e=Pr()){let t=[],n=[];for(let s of e.values()){let a=(s.recommendedFonts??[]).map(c=>String(c).split("@")[0]);a.length&&n.push(s.title||s.name);for(let c of a)t.includes(c)||t.push(c)}return{ids:t,by:n}}function _u({root:e,config:t,params:n,toast:s,debugLog:a,overlays:c,editmode:h,remeasure:f}){let g="decklight-font:"+location.pathname,b=()=>h?.()?.available()===!0,y=()=>h?.()?.base()??"",$=[],S=null,A=Oi.map(([T,F])=>({id:T,label:T,stack:F,kind:"stack"}));function E(){let T=mg(),F=$.filter(se=>!T.some(_e=>_e.id===se.id));return[...A,...T,...F]}let L="theme default",P=T=>E().find(F=>F.id===T);function j(T){if(T.kind!=="offered"||document.querySelector(`style[data-font-preview="${CSS.escape(T.id)}"]`))return;let F=(T.faces??[]).filter(_e=>fg.test(_e.url)).map(_e=>`@font-face { font-family: '${T.family}'; src: url("${y()}/${_e.url}") format("${_e.format==="woff"?"woff":"woff2"}"); font-weight: ${/^\d{1,4}( \d{1,4})?$/.test(String(_e.weight))?_e.weight:400}; font-style: ${_e.style==="italic"?"italic":"normal"}; font-display: swap; }`),se=document.createElement("style");se.dataset.fontPreview=T.id,se.textContent=F.join(`
|
|
476
|
+
`),document.head.appendChild(se)}function U(T,{silent:F=!1,persist:se=!0,measure:_e=!0}={}){let Te=P(T)??A[0];if(j(Te),L=Te.id,Te.stack?(e.style.setProperty("--font-body",Te.stack),e.style.setProperty("--font-heading",Te.stack)):(e.style.removeProperty("--font-body"),e.style.removeProperty("--font-heading")),se&&!n.has("embedded"))try{yn(g,Te.kind==="stack"&&!Te.stack?null:Te.id)}catch{}_e&&f(),F||s(`font: ${Te.label}`),a("font",Te.label)}function oe(T){let F=E().filter(_e=>_e.kind!=="offered"),se=Math.max(0,F.findIndex(_e=>_e.id===L));U(F[(se+T+F.length)%F.length].id)}function pe(){let T=null;try{T=Nn(g)}catch{}let se=(/^\d+$/.test(String(T??""))?Oi[Number(T)]?.[0]:null)??T??(typeof t.font=="string"?t.font:null);se&&P(se)&&U(se,{silent:!0,persist:!1,measure:!1})}let D=null,z=0,Ce=[],ee=null;async function re(){if(!(!b()||S)){S={loading:!0};try{let T=await fetch(y()+"/deck/edit/font/browse"),F=await T.json().catch(()=>({}));if(!T.ok||!F.ok)throw new Error(F.error||`the edit server said ${T.status}`);$=(F.fonts??[]).filter(se=>!se.missing&&Tu.test(se.family??"")&&Nu.test(se.stack??"")).map(se=>({id:se.name,label:se.title||se.family,stack:se.stack,family:se.family,faces:se.faces??[],qualified:se.qualified,used:!!se.used,group:se.group,kind:"offered"})),S={done:!0,unfetched:F.unfetched??[],stale:F.stale??[]}}catch(T){S={error:String(T.message??T)}}D&&le()}}function le(){let T=D.querySelector(".narr-card"),F=E(),se=gg(),_e=G=>Math.min(...[se.ids.indexOf(G.id),se.ids.indexOf(G.label)].filter(be=>be>=0)),Te=F.filter(G=>se.ids.includes(G.id)||se.ids.includes(G.label)).sort((G,be)=>_e(G)-_e(be));if(Ce=[...Te,...F.filter(G=>!Te.includes(G))],T.textContent="",Te.length){let G=document.createElement("div");G.className="narr-group fp-rec",G.textContent=`\u2605 recommended by ${se.by.join(", ")}`,T.appendChild(G)}Ce.forEach((G,be)=>{if(be===Te.length&&Te.length){let fe=document.createElement("div");fe.className="narr-group",fe.textContent="all fonts",T.appendChild(fe)}let J=document.createElement("div");J.className="narr-row fp-row"+(G.id===(ee??L)?" narr-cur":""),J.dataset.font=G.id;let Qe=document.createElement("span");Qe.className="narr-row-label",Qe.textContent=G.label,G.stack&&(j(G),Qe.style.fontFamily=G.stack),J.appendChild(Qe);let ot=[Te.includes(G)?"\u2605":"",G.kind==="deck"?b()?"\u25CF in the deck":"in the deck":"",G.kind==="offered"?`${G.used?"\u25CF":"\u25CB"} ${G.group??""}`.trim():""].filter(Boolean).join(" \xB7 ");if(ot){let fe=document.createElement("span");fe.className="fp-tag",fe.textContent=ot,J.appendChild(fe)}J.addEventListener("mouseenter",()=>ie(be)),J.addEventListener("click",()=>{ie(be),I()}),T.appendChild(J)});let l=b()?S?.loading?"reading the marketplaces\u2026":S?.error?`marketplace fonts: ${S.error}`:S?.unfetched?.length?`not listed: ${S.unfetched.join(", ")} \u2014 not fetched yet (decklight marketplace update)`:null:null,d=document.createElement("div");d.className="rec-line fp-foot",d.textContent=[l,b()?"\u2191/\u2193 previews \xB7 \u23CE keeps \xB7 Space adds a marketplace font to the deck \xB7 Esc puts it back":"\u2191/\u2193 previews \xB7 \u23CE keeps \xB7 Esc puts it back"].filter(Boolean).join(" \u2014 "),T.appendChild(d),ie(Math.max(0,Math.min(z,Ce.length-1)),{preview:!1})}function ie(T,{preview:F=!0}={}){Ce.length&&(z=(T+Ce.length)%Ce.length,vn([...D.querySelectorAll(".fp-row")],z,"narr-sel"),F&&U(Ce[z].id,{silent:!0,persist:!1,measure:!1}))}function I(){let T=Ce[z];T&&(ee=null,U(T.id),ce())}function ce(){D?.remove(),D=null}function de(){D&&(ee!==null&&ee!==L&&U(ee,{silent:!0,persist:!1,measure:!1}),ee=null,ce())}function Ie(){if(D)return de();c.opening(),ee=L,D=document.createElement("div"),D.className="decklight-narr decklight-font-picker",D.innerHTML='<div class="narr-card" role="listbox" aria-label="Fonts"></div>',Qt(D,de),e.appendChild(D),z=0,le();let T=Ce.findIndex(F=>F.id===ee);ie(T<0?0:T,{preview:!1}),re()}async function V(){let T=Ce[z];if(!b()||!T||T.kind!=="offered")return!1;try{let F=await fetch(y()+"/deck/edit/font/mark",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ref:T.qualified,used:!T.used,quiet:!0})}),se=await F.json().catch(()=>({}));if(!F.ok||!se.ok)throw new Error([se.error,...(se.problems??[]).slice(0,1)].filter(Boolean).join(" \xB7 ")||`the edit server said ${F.status}`);T.used=se.used,s(se.used?`\u25CF the deck now uses ${se.ref} \u2014 its faces travel with it (bundle carries them) \xB7 ${zt} takes it back`:`\u25CB dropped ${se.ref}`,3600),D&&le()}catch(F){s(`${T.qualified} \u2014 ${F.message??F}`,6e3)}return!0}function Z(T){switch(T.key){case"ArrowDown":return ie(z+1),!0;case"ArrowUp":return ie(z-1),!0;case"Enter":return I(),!0;case"Escape":return de(),!0;case" ":return V(),!0;default:return!0}}return{apply:U,cycle:oe,restore:pe,open:Ie,close:de,isOpen:()=>!!D,keydown:Z,list:E,current:()=>L}}Se();Ae();var Li=["backgroundColor","backgroundImage","backgroundSize","backgroundPosition","backgroundRepeat"];function bg(e){let t=e?.querySelector(":scope > .slide-bg");if(t)return{kind:"media",el:t};let n=e?.querySelector("[data-ds-injected][data-ds-bleed]");return n?{kind:"ds",el:n}:null}function Ou({root:e,enabled:t}){if(!t)return{update(){},clear(){},layer:null};let n=document.createElement("div");n.className="decklight-bleed",n.setAttribute("aria-hidden","true"),e.insertBefore(n,e.firstChild);let s=null;function a(g,b){let y=document.createElement("div");y.className="bleed-piece";let $=getComputedStyle(b.el);for(let S of Li)y.style[S]=$[S];if(b.kind==="media"){b.el.style.backgroundSize||(y.style.backgroundSize="cover");let S=b.el.querySelector("video");if(S){let E=document.createElement("video");for(let L of["src","poster"])S.getAttribute(L)&&E.setAttribute(L,S.getAttribute(L));for(let L of S.querySelectorAll("source"))E.appendChild(L.cloneNode());Object.assign(E,{muted:!0,loop:S.loop,playsInline:!0,autoplay:!0}),E.muted=!0;try{E.currentTime=S.currentTime||0}catch{}y.appendChild(E),E.play?.()?.catch?.(()=>{})}let A=b.el.querySelector(".slide-bg-dim");if(A){let E=document.createElement("div");E.className="bleed-dim",E.style.background=getComputedStyle(A).background,E.style.opacity=getComputedStyle(A).opacity,y.appendChild(E)}}return y}function c(g,b){if(!g)return;let{sec:y,piece:$}=g;$.style.opacity="0";let S=()=>{$.querySelector("video")?.pause?.(),$.remove(),s?.sec!==y&&y.removeAttribute("data-bled")};b>0?setTimeout(S,b+40):S()}function h(g,{ms:b=0}={}){let y=bg(g);if(s?.sec===g){if(!y){c(s,0),s=null;return}if(Li.map(E=>getComputedStyle(y.el)[E]).join("|")===s.sig)return;g.removeAttribute("data-bled");let A=a(g,y);A.style.opacity="1",n.replaceChild(A,s.piece),g.setAttribute("data-bled",""),s={sec:g,piece:A,sig:Li.map(E=>getComputedStyle(y.el)[E]).join("|")};return}let $=s;if(s=null,y){g.removeAttribute("data-bled");let S=Li.map(E=>getComputedStyle(y.el)[E]).join("|"),A=a(g,y);A.style.transition=b>0?`opacity ${b}ms ease`:"",A.style.opacity=b>0?"0":"1",n.appendChild(A),g.setAttribute("data-bled",""),b>0&&requestAnimationFrame(()=>requestAnimationFrame(()=>{A.style.opacity="1"})),s={sec:g,piece:A,sig:S}}$&&($.piece.style.transition=b>0?`opacity ${b}ms ease`:"",c($,b))}function f(){for(let g of[...n.children])g.querySelector("video")?.pause?.(),g.remove();s?.sec.removeAttribute("data-bled"),s=null}return{update:h,clear:f,layer:n}}Se();Ae();var za=(e,t,n,s,a)=>({level:e,rule:t,slide:n,title:s,message:a}),Rs=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`,yg="aside, .chart, .terminal, [data-ds-injected]",wg="rect, circle, ellipse, polygon, polyline, path, line";function vg(e){return[...e.querySelectorAll("svg")].filter(t=>!t.parentElement.closest("svg")&&!t.closest(yg)&&t.querySelectorAll(wg).length>=3&&t.querySelector("text"))}function Lu({root:e,overlays:t,instance:n,goto:s,measureOverflow:a,slideTitle:c,suggestions:h=()=>[],accept:f=()=>null,agentFindings:g=()=>[],fix:b=()=>null}){let y=null,$=0,S=[];function A(){let pe=n(),D=pe?._sections??[],z=[];D.forEach((le,ie)=>{let I=ie+1,ce=c(le,ie),de=(F,se,_e)=>z.push(za(F,se,I,ce,_e));le.hasAttribute("data-markdown-removed")&&de("error","markdown-slide","a markdown slide, which comes up empty: data-markdown was removed in 0.3.0"),a(le,I)&&de("error","overflow","content is clipped: the audience never sees the rest");for(let F of le.querySelectorAll("img"))F.getAttribute("src")&&F.complete&&F.naturalWidth===0&&de("error","missing-media",`an image did not load: ${F.getAttribute("src")}`);for(let F of le.querySelectorAll("video, audio"))F.error&&de("error","missing-media",`a ${F.tagName.toLowerCase()} did not load: ${F.currentSrc||F.getAttribute("src")||"its source"}`);let Ie=Io(le);Ie.length&&de("warn","dense",`crowded: ${Ie.join(", ")}. Split it rather than shrink it`),le.hasAttribute("data-split-conflict")&&de("warn","split-conflict",'data-layout="split" is fighting its own column flexbox: drop one');let V=le.querySelector(":scope > aside.notes"),Z=V?Qs(V.innerHTML).length-1:0,T=pe._records?.[ie]?.groups.length??0;if(Z>0&&Z!==T&&de("warn","clicks-vs-builds",`${Rs(Z,"\u27E8CLICK\u27E9","\u27E8CLICK\u27E9s")} in the notes for ${Rs(T,"build step")}: narration and builds drift apart`),!le.hasAttribute("data-static-ok")){let F=(pe._records?.[ie]?.steps??[]).map(_e=>_e.el).filter(Boolean),se=vg(le).filter(_e=>!_e.hasAttribute("data-static-ok")&&!F.some(Te=>Te===_e||_e.contains(Te)));se.length&&de("hint","static-diagram",`${se.length===1?"a diagram":Rs(se.length,"diagram")} with no build: ${se.length===1?"it lands":"they land"} all at once. Reveal it in steps, or mark it data-static-ok`)}});for(let le of h()){let ie=D[le.slides[0]-1];z.push({...za("hint","concept-suggestion",le.slides[0],ie?c(ie,le.slides[0]-1):"",`\u201C${le.label}\u201D is on ${le.slides.length===1?`slide ${le.slides[0]}`:`slides ${le.slides.slice(0,-1).join(", ")} and ${le.slides.at(-1)}`} in ${le.colours} colours: make it the \u201C${le.name}\u201D concept`),suggestion:le})}let Ce={error:0,warn:1,hint:2},ee=z.map((le,ie)=>[le,ie]).sort((le,ie)=>le[0].slide-ie[0].slide||Ce[le[0].level]-Ce[ie[0].level]||le[1]-ie[1]).map(([le])=>le),re=g().filter(le=>le.slide>=1&&le.slide<=D.length).map(le=>({...za("agent",le.rule,le.slide,c(D[le.slide-1],le.slide-1),le.message),label:le.label,agentFinding:le}));return[...ee,...re]}function E(){if(y)return oe();t.opening(),y=document.createElement("div"),y.className="decklight-narr decklight-deckcheck",y.innerHTML='<div class="narr-card" role="listbox" aria-label="Check deck"></div>',Qt(y,oe),e.appendChild(y),L()}function L(){let pe=y.querySelector(".narr-card");pe.replaceChildren();let D=A(),z=n()?._sections?.length??0,Ce=D.filter(de=>de.level==="error").length,ee=D.filter(de=>de.level==="error"||de.level==="warn"),re=D.filter(de=>de.level==="hint").length,le=D.filter(de=>de.level==="agent").length,ie=document.createElement("div");if(ie.className="narr-head",ie.textContent=(ee.length?`check \xB7 ${Rs(ee.length,"issue")} on ${Rs(new Set(ee.map(de=>de.slide)).size,"slide")}`+(Ce?` \xB7 ${Rs(Ce,"error")}`:""):"check")+(re?` \xB7 ${Rs(re,"suggestion")}`:"")+(le?` \xB7 ${le} from the agent`:""),pe.appendChild(ie),S=D,!ee.length){let de=document.createElement("div");de.className="narr-row narr-fact dc-clean",de.textContent=`no issues: ${Rs(z,"slide")} checked`,pe.appendChild(de)}let I=!!b();D.forEach((de,Ie)=>{if(de.level==="agent"&&(Ie===0||D[Ie-1].level!=="agent")){let Te=document.createElement("div");Te.className="narr-group dc-agent-head",Te.textContent=`agent review \xB7 ${le}${I?" \xB7 f asks the agent to fix one":""}`,pe.appendChild(Te)}let V=document.createElement("div");V.className=`narr-row dc-row dc-${de.level}`,V.dataset.rule=de.rule;let Z=document.createElement("span");Z.className="dc-mark",Z.textContent=de.level==="error"?"\u2717":de.level==="hint"?"+":de.level==="agent"?"\u2726":"!";let T=document.createElement("span");T.className="dc-where",T.textContent=`${de.slide}`,T.title=de.title;let F=document.createElement("span");F.className="dc-text";let se=document.createElement("span");se.className="dc-title",se.textContent=de.title;let _e=document.createElement("span");if(_e.className="dc-msg",_e.textContent=de.message+(de.suggestion&&f()?" \xB7 \u23CE makes it":""),F.append(se,_e),de.label){let Te=document.createElement("span");Te.className="dc-rule",Te.textContent=de.label,F.append(Te)}V.append(Z,T,F),V.addEventListener("mouseenter",()=>P(Ie)),V.addEventListener("click",()=>j(Ie)),pe.appendChild(V)});let ce=document.createElement("div");ce.className="narr-foot dc-foot",ce.textContent="\u23CE goes to the slide \xB7 decklight check <deck> also reads the file: missing files, scripts",pe.appendChild(ce),D.length&&P(0)}function P(pe){let D=y.querySelectorAll(".dc-row");D.length&&($=vn(D,pe,"narr-sel"))}function j(pe){let D=S[pe];if(oe(),!D)return;s(D.slide);let z=D.suggestion&&f();z&&z(D.suggestion)}function U(pe){let D=S[pe],z=b();return!D?.agentFinding||!z?!1:(oe(),s(D.slide),z(D.agentFinding),!0)}function oe(){y?.remove(),y=null}return t.register({isOpen:()=>!!y,close:oe,transient:!0,keydown:pe=>(pe.key==="f"||pe.key==="F")&&!pe.metaKey&&!pe.ctrlKey&&!pe.altKey&&U($)||eo(pe,{onMove:D=>P($+D),onCommit:()=>j($),onClose:oe})}),{open:E,close:oe,check:A,isOpen:()=>!!y}}var kg=e=>(bs?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey)&&!e.altKey&&(e.key==="z"||e.key==="Z"),xg={transition:"fade",hash:!0,controls:!0,slideNumber:!1,width:1280,height:720,pinTitles:!0},Mi=99,Eg=18,Mu=6,$g="ul, ol, svg, pre, table, .terminal, img, .columns",fo=null;function mo(e,t){Jo(e,t),fo&&fo._rescanFor(e)}function Sg(e){let t=getComputedStyle(e).position;return t==="absolute"||t==="fixed"}function Ag(e){for(let t of e.children)if(!t.matches("aside, script, style, .decklight-hero-logo, .slide-bg")){if(t.matches("h1, h2"))return t;if(!Sg(t))return null}return null}function Cg(e,t){if(!t||e.getAttribute("data-subtitle")==="none")return null;let n=t.nextElementSibling;return n&&n.matches("p")&&!n.hasAttribute("data-build")?(n.classList.add("subtitle"),n):e.querySelector(":scope > p.subtitle")}function Iu(e){return e.pinTitles===!0?Mi:typeof e.pinTitles=="number"&&isFinite(e.pinTitles)?e.pinTitles:null}function Pu(e,t){let n=Iu(t),s=e.getAttribute("data-pin");if(s==="none")return null;if(s!==null&&s!==""){let c=parseFloat(s);return isFinite(c)?c:n??Mi}return s===""?n??Mi:n===null?null:[...e.querySelectorAll($g)].some(c=>!c.closest("aside")&&!c.closest(".decklight-hero-logo"))?n:null}function Tg(e,t){let n=e.getAttribute("data-layout");if(e.hasAttribute("data-template"))return null;if(n==="pinned"){let s=parseFloat(e.getAttribute("data-pin"));return isFinite(s)?s:Iu(t)??Mi}return n==="centered"||n==="top"?null:Pu(e,t)}function Ho(e,t){let n=[];for(let s of e){let a=Ag(s),c=Tg(s,t),h=Cg(s,a);if(s.querySelector(":scope > .pin-title")?.classList.remove("pin-title"),s.querySelector(":scope > .pin-subtitle")?.classList.remove("pin-subtitle"),c===null||!a){s.removeAttribute("data-pinned"),s.style.removeProperty("--pin-y"),s.style.removeProperty("--pin-sub-y"),s.style.removeProperty("--pin-space");continue}a.classList.add("pin-title"),h?.classList.add("pin-subtitle"),s.setAttribute("data-pinned",""),s.style.setProperty("--pin-y",c+"px"),s.classList.add("pin-measure"),n.push({sec:s,heading:a,subtitle:h,y:c})}for(let s of n)s.titleH=s.heading.offsetHeight||0,s.subH=s.subtitle&&s.subtitle.offsetHeight||0;for(let{sec:s,subtitle:a,y:c,titleH:h,subH:f}of n){let g=c+h;a&&(s.style.setProperty("--pin-sub-y",Math.round(g+Mu)+"px"),g+=Mu+f),s.classList.remove("pin-measure"),s.style.setProperty("--pin-space",Math.round(g+Eg)+"px")}}function Du(e){return[...e.children].filter(t=>!t.matches("h1, h2, .subtitle, aside, script, style, .decklight-hero-logo, .slide-bg"))}function Ru(e,t=n=>n+1){e.forEach((n,s)=>{n.querySelectorAll(":scope > .split-columns, :scope > .split-footer").forEach(h=>h.classList.remove("split-columns","split-footer"));let a=n.getAttribute("data-layout")||"";if(!/^split/.test(a)||n.hasAttribute("data-template")){n.removeAttribute("data-split-conflict");return}let c=Du(n);if(Ng(n,c,t(s)),c.length===1&&c[0].matches("ul, ol")){c[0].classList.add("split-columns");return}for(let h of c.slice(2))h.classList.add("split-footer")})}function Ng(e,t,n){let s=t.some(c=>{let h=getComputedStyle(c);return/flex$/.test(h.display)&&h.flexDirection.startsWith("row")}),a=e.hasAttribute("data-split-conflict");e.toggleAttribute("data-split-conflict",s),s&&!a&&console.warn(`Decklight: slide ${n} 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 zo(e,t){if(!e)return;let n=[e,...e.querySelectorAll("pre, table, svg, ul, ol, blockquote")].some(a=>a.scrollHeight>a.clientHeight+2&&getComputedStyle(a).overflowY!=="visible"&&!a.closest(".terminal")&&!a.hasAttribute("data-scroll-ok")),s=e.hasAttribute("data-overflow");e.toggleAttribute("data-overflow",n),n&&!s&&console.warn(`Decklight: slide ${t} content overflows and is clipped \u2014 reduce content or font size`)}function _g(e){e.querySelectorAll("section[data-markdown]").forEach((t,n)=>{t.setAttribute("data-markdown-removed","");let s=[...e.children].indexOf(t)+1||n+1;console.warn(`Decklight: slide ${s} 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(e){return(e||"").replace(/^#/,"")}function Ua(e){let t=Ga(e).match(/^\/(\d+)(?:\/(\d+))?/);return t?{slide:parseInt(t[1],10),step:t[2]?parseInt(t[2],10):0}:null}function Bu(e={}){let t=new URLSearchParams(location.search),n={...xg,...e};t.has("embedded")&&(n.controls=!1);let s=t.has("print"),a=t.has("capture");a&&(n.controls=!1);let c=t.has("all"),h=t.get("print")||"",f=null;try{f=sd(sessionStorage,location.pathname)}catch{}let g=td({seed:f?.entries??[],first:f&&{kind:"reload",msg:`\u21BB reloaded \u2014 ${f.reason??"by the browser (\u2318R, or a navigation)"}`}}),b=null,y=(w,O)=>g.log(w,O),$=null,S=()=>{try{rd(sessionStorage,location.pathname,g.entries,$)}catch{}},A=w=>{$=w,S()};window.addEventListener("pagehide",S);let E=document.querySelector(".decklight");if(!E)throw new Error("Decklight: no .decklight element found");if(E.__decklight)return console.warn("Decklight: init() called again on a running deck \u2014 returning the existing instance"),E.__decklight;let L=_c(),P=pu({config:n,root:E,embedded:t.has("embedded"),sectionsOf:()=>ye._sections,slideOf:()=>ye.state.slide,navigate:w=>{location.href=w}}),j=P.playlist,U=P.index,oe=P.hasMarkers,pe=w=>P.gotoModule(w),D=w=>P.navigateToModule(w),z=200,Ce=4,ee=[],re=null,le=null;function ie(){return ee}function I(w){ee.push({at:new Date,text:String(w)}),ee.length>z&&ee.shift(),le&&ts()}function ce(w,O=3200){if(I(w),s||a)return;re||(re=document.createElement("div"),re.className="decklight-messages",E.appendChild(re));let Q=document.createElement("div");for(Q.className="decklight-toast",Q.textContent=w,re.appendChild(Q),requestAnimationFrame(()=>Q.classList.add("show"));re.children.length>Ce;)re.firstChild.remove();setTimeout(()=>{Q.classList.remove("show"),setTimeout(()=>Q.remove(),260)},O)}function de(w){if(I(w),s||a)return{update(){},done(){}};re||(re=document.createElement("div"),re.className="decklight-messages",E.appendChild(re));let O=document.createElement("div");for(O.className="decklight-toast",O.textContent=w,re.appendChild(O),requestAnimationFrame(()=>O.classList.add("show"));re.children.length>Ce;)re.firstChild.remove();let Q=!1;return{update(m){Q||(O.textContent=m)},done(m,k=3600){Q=!0,m&&(O.textContent=m,I(m)),setTimeout(()=>{O.classList.remove("show"),setTimeout(()=>O.remove(),260)},k)}}}let Ie=du({root:E,printMode:s,params:t,toast:ce,debugLog:y,overlays:L,deck:()=>ye}),V=Rc({root:E,config:n,params:t,toast:ce,debugLog:y,overlays:L,deck:()=>ye,editmode:()=>Xe}),{applyTheme:Z,currentTheme:T,cycleTheme:F,cancelCyclePending:se,rollTheme:_e,saveGeneratedTheme:Te}=V;function l(){let w=ye.__speakerWin;w&&!w.closed?w.__decklightSpeakerToggle?.():ye.__speakerWin=la(ye)}let d=Id({root:E,overlays:L,toast:ce,reflow:()=>ye._reflow?.(),slideOf:()=>ye.state.slide,sectionAt:w=>ye._sections[w-1],editmode:()=>Xe}),G=null,be=Su({root:E,toast:ce,base:()=>Xe?.available()?Xe.base():null,debugLog:(...w)=>y(...w)});L.register({isOpen:be.isOpen,close:be.close,keydown:be.keydown});let J=null,Qe=!1,ot=Kd({root:E,toast:ce,stage:()=>Tt,base:()=>Xe?.available()?Xe.base():null,concepts:()=>n.concepts??{},apply:w=>{n.concepts=w,Js(Tt,n.concepts)},pageId:()=>Xe?.pageId?.()??"",debugLog:(...w)=>y(...w),tools:()=>J,slide:()=>ye?.state.slide??1,goto:w=>ye.goto(w,0)});L.register({isOpen:ot.isOpen,close:ot.close,keydown:ot.keydown,modal:ot.modal});let fe=Au({root:E,toast:ce,base:()=>Xe?.available()?Xe.base():"",debugLog:(...w)=>y(...w),preview:w=>{let O={theme:V.currentTheme(),font:Mn.current()};return w.themeChanges&&w.theme&&V.applyTheme(w.theme,!0,{persist:!1}),w.fontChanges&&w.font&&Mn.apply(w.font,{silent:!0,persist:!1}),O},restore:w=>{w?.theme&&V.applyTheme(w.theme,!0,{persist:!1}),w?.font&&Mn.apply(w.font,{silent:!0,persist:!1})},keep:w=>{w.themeChanges&&w.theme&&V.applyTheme(w.theme,!0),w.fontChanges&&w.font&&Mn.apply(w.font,{silent:!0})}});L.register({isOpen:fe.isOpen,close:fe.close,keydown:fe.keydown});function K(){let w=V.themeList(),O=Mn.list().map(Q=>Q.id);for(let Q of Pr().values()){let m=(Q.recommendedThemes??[]).map(Be=>Be.split("@")[0]).find(Be=>w.includes(Be))??null,k=(Q.recommendedFonts??[]).map(Be=>Be.split("@")[0]).map(Be=>Mn.list().find(Re=>Re.id===Be)).find(Boolean)??null,_=k&&O.includes(k.id)?k.id:null,W=!!m&&n.theme!==m,he=!!_&&n.font!==_;if(W||he)return{ref:Q.name,title:Q.title||Q.name,theme:m,font:_,fontLabel:k?.label,themeChanges:W,fontChanges:he}}return null}let ue=Cu({root:E,toast:ce,deck:()=>ye,base:()=>Xe?.available()?Xe.base():null,lookHint:K,offerLook:w=>fe.show(w),debugLog:(...w)=>y(...w)});L.register({isOpen:ue.isOpen,close:ue.close,keydown:ue.keydown});let at=null,N=0,ft="",M=[],H,te=ro({docOf:w=>w.href??location.pathname,srcFor:w=>(w.href??location.pathname)+V.previewQuery()+"#/"+(w.slide??1)+"/0",messageFor:w=>({__decklightPreview:{goto:[w.slide??1,0]}})});function we(){let w=Fd({sections:ye._sections,modules:j?.modules??[],skipModule:U});return!oe||j?w:[...P.markers().map(Q=>({slide:Q.slide,title:Q.title,chapter:!0,haystack:(Q.title||"").toLowerCase()})),...w]}let Ee=new Set,Ke=()=>oe&&!j&&!ft,ae=w=>{let O=null;for(let Q of P.markers())Q.slide<=w&&(O=Q.slide);return O};function Ze(){let w=at.__index.filter(m=>!m.chapter&&!m.href),O=P.markers(),Q=[];for(let m of w)(!O.length||m.slide<O[0].slide)&&Q.push(m);return O.forEach((m,k)=>{let _=O[k+1]?.slide??1/0,W=w.filter(Be=>Be.slide>=m.slide&&Be.slide<_),he=Ee.has(m.slide);if(Q.push({slide:m.slide,title:m.title,chapter:!0,count:W.length,open:he}),he)for(let Be of W)Q.push({...Be,child:!0,parent:m.slide})}),Q}function bt(w){ke();let O=M.findIndex(w);O>=0&&Ve(O,!1)}function Pe(w){let O=M[N];if(!O)return!0;if(w)return O.chapter&&!O.open?(Ee.add(O.slide),bt(m=>m.chapter&&m.slide===O.slide)):O.chapter&&M[N+1]?.child&&Ve(N+1,!1),!0;let Q=O.chapter?O.slide:O.parent;return Q==null||(Ee.delete(Q),bt(m=>m.chapter&&m.slide===Q)),!0}function ke(){let w=at.querySelector(".tp-list");if(M=Ke()?Ze():qd(at.__index,ft),w.textContent="",M.forEach((Q,m)=>{let k=document.createElement("div");if(k.className="tp-row"+(Q.slide===ye.state.slide&&!Q.chapter?" tp-current":"")+(Q.href||Q.chapter?" tp-module":"")+(Q.child?" tp-child":""),Q.chapter&&Q.count!=null){let _=document.createElement("span");_.className="tp-fold",_.textContent=Q.open?"\u25BE":"\u25B8",_.title=Q.open?"fold (\u2190)":"unfold (\u2192)",_.addEventListener("click",he=>{he.stopPropagation(),Q.open?Ee.delete(Q.slide):Ee.add(Q.slide),bt(Be=>Be.chapter&&Be.slide===Q.slide)}),k.append(_,` ${Q.title} \u2014 module`);let W=document.createElement("span");W.className="tp-count",W.textContent=` \xB7 ${Q.count} slide${Q.count===1?"":"s"}`,k.append(W)}else k.textContent=Q.href||Q.chapter?`\u25B8 ${Q.title} \u2014 module`:`${Q.slide} \xB7 ${Q.title}`;k.addEventListener("mouseenter",()=>Ve(m,!1)),k.addEventListener("click",()=>{Ve(m,!0),Y()}),w.appendChild(k)}),!M.length){let Q=document.createElement("div");Q.className="tp-none",Q.textContent="no matches",w.appendChild(Q)}let O=at.querySelector(".tp-filter");O.textContent=ft||(j||oe?"type to find a slide or module\u2026":"type to find a slide\u2026"),O.classList.toggle("tp-active",!!ft)}let Fe=(w,O)=>te.show(w,O);function Ve(w,O){if(!M.length)return;N=vn(at.querySelectorAll(".tp-row"),w,"tp-selected");let Q=M[N];at.querySelector(".tp-caption").textContent=Q.href?`module \u2014 ${Q.title} (${Q.href})`:Q.chapter?`module \u2014 ${Q.title} (slide ${Q.slide} of this deck)`:`slide ${Q.slide} \u2014 ${Q.title}`,clearTimeout(H);let m=at.querySelector("iframe");O?Fe(m,Q):H=setTimeout(()=>Fe(m,Q),60)}function et(w){let O=M[N],Q=ft;if(ft=w,Ke()&&O&&!O.href){let _=O.chapter?O.slide:ae(O.slide);_!=null&&Ee.add(_),ke();let W=M.findIndex(he=>he.slide===O.slide&&!!he.chapter==!!O.chapter);Ve(Math.max(0,W),!1);return}let m=w.length<Q.length&&Q.startsWith(w);if(ke(),!M.length){at.querySelector(".tp-caption").textContent="no match";return}let k=m&&O?M.findIndex(_=>_.slide===O.slide&&!!_.chapter==!!O.chapter&&_.href===O.href):-1;Ve(Math.max(0,k),!1)}function Y(){let w=M[N];if(Ne(),!!w){if(w.href)return D(w.module);ye.goto(w.slide,0)}}function ve(){if(at)return Ne();L.opening(),ft="",at=document.createElement("div"),at.className="decklight-theme-picker decklight-finder",at.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>',at.__index=we(),Ee=new Set;let w=oe&&!j?ae(ye.state.slide):null;w!=null&&Ee.add(w),ke(),Qt(at,Ne),E.appendChild(at),Ve(Math.max(0,M.findIndex(O=>!O.chapter&&O.slide===ye.state.slide)),!0)}function Ne(){clearTimeout(H),at?.remove(),at=null}let ut=null,ht=0,vt="",mt=[],Ue=[],Dt=()=>(ye._sections??[]).some(w=>w.hasAttribute("data-hidden")),Ct=()=>!!ye._sections?.[ye.state.slide-1]?.hasAttribute("data-hidden");function Pt(){let w=new URL(location.href);c?w.searchParams.delete("all"):w.searchParams.set("all",""),location.href=w.href}async function Kt(w,O){let Q=ye._sections?.[w-1];if(Q){try{let m=await fetch(Xe.base()+"/deck/edit/slide/hidden",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slide:w,hidden:O})});if(!m.ok)throw new Error(String(m.status))}catch(m){ce(`could not ${O?"hide":"unhide"} slide ${w} \u2014 ${m.message}`);return}if(Q.toggleAttribute("data-hidden",O),ce(O?`slide ${w} hidden \u2014 the audience will not see it (?all shows it)`:`slide ${w} shown again`),O&&!c&&ye.state.slide===w){let m=ye._visibleFrom(w+1,1)??ye._visibleFrom(w-1,-1);m!=null&&ye.goto(m,0)}}}function hn(){let w=ye.__speakerWin;return w&&!w.closed?w:ye.__speakerWin=la(ye)}let Xt=["Go to","Slide","Edit","Look","Voice","Present","Review","Git","Share","Help","Preferences"];function Mt(){let w=m=>typeof m=="function",O=m=>Xe.available()&&{...m,write:!0};return[{label:"Find slide\u2026",cat:"Go to",hint:"G",alias:"search grep goto module chapter jump",run:()=>{ve(),vt&&et(vt)}},{label:"Go to slide\u2026",cat:"Go to",hint:"#",alias:"goto jump number",keepOpen:!0,run:()=>{vt="goto ",Wt()}},{label:"Overview",cat:"Go to",hint:"O",alias:"grid thumbnails all slides rearrange",run:ur},{label:"First slide",cat:"Go to",hint:"Home",run:()=>ye.goto(1,0)},{label:"Last slide",cat:"Go to",hint:"End",run:()=>ye.goto(ye.state.totalSlides,0)},{label:Xe.available()?"Edit speaker notes\u2026":"Speaker notes (read-only)\u2026",cat:"Slide",hint:"S",alias:"edit mode notes write script read right-click background",run:cs},{label:"Inspector",cat:"Slide",hint:"I",alias:"inspect info information properties details facts sources references links provenance citation contrast box font",run:()=>G?.open()},d.canEdit()&&{label:d.has()?"Edit sources on this slide\u2026":"Add sources to this slide\u2026",cat:"Slide",write:!0,alias:"sources references links reading provenance where citation cite",run:()=>d.edit()},O({label:"New slide after this one",cat:"Slide",alias:"add slide insert blank create page",run:()=>Xe.slideOp("new")}),O({label:"Duplicate this slide",cat:"Slide",alias:"copy slide clone",run:()=>Xe.slideOp("duplicate")}),O({label:"Move slide up",cat:"Slide",alias:"reorder earlier before swap",run:()=>Xe.slideOp("up")}),O({label:"Move slide down",cat:"Slide",alias:"reorder later after swap",run:()=>Xe.slideOp("down")}),O({label:"Delete this slide",cat:"Slide",alias:"remove slide drop",run:()=>Xe.slideOp("delete")}),O({label:`${Ct()?"Unhide":"Hide"} this slide`,cat:"Slide",alias:"hidden hide skip cut backup keep out of the talk unhide show",run:()=>Kt(ye.state.slide,!Ct())}),O({label:"Cycle slide layout",cat:"Slide",alias:"pin pinned centered top auto split columns two sides arrange",run:()=>Rt(1)}),O({label:"Use slide template\u2026",cat:"Slide",alias:"slide template slots convert switch insert slide divider section structure design system",run:()=>ue.open()}),O({label:"Undo deck edit",cat:"Edit",hint:zt,alias:"revert back history",run:()=>zr("undo")}),O({label:"Redo deck edit",cat:"Edit",hint:Ao,alias:"forward history repeat",run:()=>zr("redo")}),O({label:"Ask agent\u2026",cat:"Edit",hint:"A",alias:"ai claude codex bob gemini prompt edit",run:fs}),Xe.elementEditOn()&&On.selected()&&O({label:"Copy style",cat:"Edit",hint:Wn.keys.copy,alias:"format painter copy formatting colours colors fill border font look match",run:()=>Wn.copy(On.selected())}),Xe.elementEditOn()&&On.selected()&&Wn.has()&&O({label:"Paste style",cat:"Edit",hint:Wn.keys.paste,alias:"format painter paste formatting apply colours colors fill border font look match same as",run:()=>Wn.paste(On.selected())}),O({label:"Concept colors\u2026",cat:"Edit",alias:"concept colours colors semantic diagram fill slot pin data-concept recurring same colour everywhere colour by meaning color by meaning legend idea shapes boxes attach group",run:()=>ot.open()}),O({label:On.hidden()?"Show the bar":"Hide the bar",cat:"Edit",alias:"editing bar toolbar hide show toggle chrome buttons",run:()=>On.toggleHidden()}),Xe.served()&&!Xe.noTrust()&&{label:Xe.locked()?"Unlock deck":"Lock deck \u2014 nothing changes the file until you unlock it",cat:"Edit",write:!0,alias:"lock unlock read only readonly protect freeze avoid changes by mistake editing off",run:()=>Xe.toggleLock()},{label:"Theme\u2026",cat:"Look",hint:"T",alias:"colours colors palette",run:V.openPicker},{label:"Cycle theme",cat:"Look",hint:", \xB7 .",run:()=>F(1)},!V.brandLocked()&&{label:"Generate a theme",cat:"Look",hint:"\u2303T",run:_e},V.hasGenerated()&&{label:"Save the generated theme\u2026",cat:"Look",hint:"\u2303\u21E7T",run:()=>Te()},O({label:"Marketplace themes\u2026",cat:"Look",alias:"browse marketplace install add mark third-party catalog",run:V.browse}),{label:"Font\u2026",cat:"Look",hint:"[ \xB7 ]",run:dn},O({label:"Design systems\u2026",cat:"Look",alias:"design system brand kit company tokens layouts slots marketplace corporate identity style guide",run:()=>be.open()}),{label:`Narration ${Gt.status().paused?"resume":Gt.status().narrating?"pause":"play"}`,cat:"Voice",hint:"\u23B5",alias:"play pause resume voice narration speak start stop",run:()=>Gt.playPause()},{label:"Narration\u2026",cat:"Voice",hint:"V",alias:"voice audio track picker panel",run:()=>Tr("tracks")},{label:"Live voice\u2026",cat:"Voice",alias:"tts synthesize tone gemini elevenlabs engine",run:()=>Tr("voices")},{label:"Character\u2026",cat:"Voice",alias:"avatar lipsync face talking head visemes",run:()=>Tr("character")},{label:`Character solo ${Tn.solo?"off":"on"}`,cat:"Voice",alias:"centre center stage narrator only fullscreen avatar",run:()=>Gt.applySolo(!Tn.solo)},{label:"Record this deck\u2026",cat:"Voice",alias:"record narrate microphone mic voice wav offline batch teleprompter",run:()=>Tr("record")},{label:`Captions ${Gt.status().captionsOn?"off":"on"}`,cat:"Voice",hint:"C",alias:"cc subtitles closed caption",run:sr},{label:"Voice faster",cat:"Voice",hint:">",alias:"speed rate playback",run:()=>Hr(.25)},{label:"Voice slower",cat:"Voice",hint:"<",alias:"speed rate playback",run:()=>Hr(-.25)},...Xe.wizards().map(m=>O({label:`Configure ${m.title}\u2026`,cat:"Voice",alias:"engine wizard setup api key credential token marketplace",run:()=>Xe.wizard(m.qualified)})),O({label:"Enhance this slide's voiceover script\u2026",cat:"Voice",alias:"enhance elevenlabs v4 audio tags expressive emotion notes narration voice script improve direction",run:()=>Xe.enhanceScript("slide")}),O({label:"Enhance this module's voiceover script\u2026",cat:"Voice",alias:"enhance module chapter section elevenlabs v4 audio tags expressive emotion notes narration voice script",run:()=>Xe.enhanceScript("module")}),O({label:"Enhance every slide's voiceover script\u2026",cat:"Voice",alias:"enhance all slides whole deck elevenlabs v4 audio tags expressive emotion notes narration voice script",run:()=>Xe.enhanceScript("all")}),O({label:"Write this slide's notes for the ear\u2026",cat:"Voice",alias:"spoken conversational natural sentences rewrite notes voiceover script say aloud human speakable ear",run:()=>Xe.enhanceScript("slide",{kind:"spoken"})}),O({label:"Write this module's notes for the ear\u2026",cat:"Voice",alias:"spoken conversational natural sentences rewrite module chapter notes voiceover script say aloud human speakable ear",run:()=>Xe.enhanceScript("module",{kind:"spoken"})}),O({label:"Write every slide's notes for the ear\u2026",cat:"Voice",alias:"spoken conversational natural sentences rewrite all slides whole deck notes voiceover script say aloud human speakable ear",run:()=>Xe.enhanceScript("all",{kind:"spoken"})}),{label:"Speaker view \u2014 second window",cat:"Present",hint:"\u2325\u23CE",alias:"presenter view display timer next slide rehearse popup",run:l},{label:"Fullscreen",cat:"Present",hint:"F",run:()=>_r()},{label:`${cr()?"Show":"Hide"} arrows and slide number in fullscreen`,cat:"Present",hint:"\u21E7F",alias:"chevrons controls prev next counter page number chrome clean distraction free",run:()=>cn(!cr())},{label:"Blackout",cat:"Present",hint:"B",run:Br},{label:`Pen ${mr.annotator?.tool==="pen"?"off":"on"} \u2014 draw on the slide`,cat:"Present",hint:"W",alias:"ink annotate draw scribble marker highlight",run:()=>Qn("pen")},{label:`Laser pointer ${mr.annotator?.tool==="laser"?"off":"on"}`,cat:"Present",hint:"\u21E7W",alias:"ink dot glow point at",run:()=>Qn("laser")},{label:`Clock ${mr.status().clockOn?"off":"on"}`,cat:"Present",alias:"time elapsed timer talk wall watch clock",run:Ir},{label:`Progress bar ${mr.status().progressOn?"off":"on"}`,cat:"Present",alias:"bar bottom edge position how far through shape of the talk",run:ls},{label:"Rehearse timings\u2026 (speaker view)",cat:"Present",alias:"rehearsal timing time each slide record pace plan stopwatch",run:()=>{hn()?.__decklightSpeakerRec?.(!0)}},(c||Dt())&&{label:`Hidden slides ${c?"skip":"show"}`,cat:"Present",alias:"all cut backup skipped unhide reveal present hidden \u2298",run:Pt},{label:"Transcript\u2026 (speaker view)",cat:"Present",alias:"notes script whole deck text spoken read",run:()=>hs()},{label:"Download the transcript (.md)",cat:"Share",alias:"transcript notes script markdown download spoken text",run:()=>ye.transcript.download("md")},{label:"Download the transcript (.txt)",cat:"Share",alias:"transcript notes script text download spoken plain",run:()=>ye.transcript.download("txt")},{label:"Comments\u2026",cat:"Review",hint:"M",alias:"feedback remarks reviewer notes critique review read",run:()=>fr.open()},{label:"Leave a comment\u2026",cat:"Review",hint:"\u21E7M",alias:"comment note remark feedback add write say",run:()=>fr.compose()},{label:"Submit review\u2026",cat:"Review",alias:"send review push comments submit feedback",run:()=>fr.submit()},{label:"Check deck\u2026",cat:"Review",alias:"lint check issues problems errors warnings crowded dense density overflow clipped validate verify report health",run:()=>Vn.open()},O({label:"Review deck with agent\u2026",cat:"Review",alias:"review improve critique feedback agent ai suggestions sources figures numbers voiceover notes titles diagram table better",run:()=>{Qe=!0,Xe.reviewDeck()}}),O({label:"History\u2026",cat:"Git",hint:"H",alias:"restore previous earlier rollback revert back git log commits unpushed push remote when changed",run:()=>Xe.history.open()}),O({label:"Commit\u2026",cat:"Git",hint:"K",alias:"git save commit message history",run:()=>Xe.commit.open()}),O({label:"Export to PowerPoint\u2026",cat:"Share",alias:"pptx powerpoint keynote google slides export file office send share hand over",run:()=>Xe.exportDeck("pptx")}),O({label:"Export to PDF\u2026",cat:"Share",alias:"pdf export file save send share hand over slides acrobat",run:()=>Xe.exportDeck("pdf")}),O({label:"Export a PDF with notes\u2026",cat:"Share",alias:"pdf notes script speaker one slide per page export file send rehearse",run:()=>Xe.exportDeck("pdf-notes")}),O({label:"Export a PDF handout\u2026",cat:"Share",alias:"pdf handout three per page audience note-taking export file send print",run:()=>Xe.exportDeck("pdf-handout")}),O({label:"Bundle into one file\u2026",cat:"Share",alias:"bundle standalone single file offline html send share email attach hand over export audio voice narration recorded track sound compressed small aac opus",run:()=>Zr()}),O({label:"Export a video\u2026",cat:"Share",alias:"video mp4 movie film render narrated voiceover export range chapter share upload youtube",run:()=>Yr()}),O({label:"Publish this deck\u2026",cat:"Share",alias:"publish share url link web site pages gh-pages github deploy send hand over",run:()=>Xe.publishDeck()}),{label:"Print view (all slides, new tab)",cat:"Share",alias:"print pdf pages",run:()=>window.open(location.pathname+"?print")},{label:"Print with notes (one slide per page, new tab)",cat:"Share",alias:"pdf print speaker notes script handout pages",run:()=>window.open(location.pathname+"?print=notes")},{label:"Print handout (three per page, new tab)",cat:"Share",alias:"pdf print handout thumbnails audience note-taking lines",run:()=>window.open(location.pathname+"?print=handout")},{label:"Keyboard help",cat:"Help",hint:"?",alias:"keys keyboard shortcuts",run:qr},{label:"Messages",cat:"Help",hint:"`",alias:"log toast notifications warnings why voice stopped history",run:or},{label:"Debug log",cat:"Help",alias:"console events state",run:Pn},{label:"Welcome to Decklight",cat:"Help",alias:"onboarding intro getting started first run tour what is this help me",run:Ie.showWelcome},O({label:"Editing tour",cat:"Help",alias:"onboarding intro getting started first run tour how do I edit write mode gestures",run:Ie.showEditingTour}),{label:"Settings\u2026",cat:"Preferences",alias:"config configuration preferences options about version build release which version",run:kn}].filter(Boolean).filter(m=>w(m.run))}function Wt(){let w=ut.querySelector(".narr-card");w.textContent="";let O=$u({commands:Ue,query:vt,categories:Xt,totalSlides:ye.state.totalSlides,makeGotoRow:(k,_)=>({label:`Go to slide ${k} / ${_}`,hint:"\u23CE",run:()=>ye.goto(k,0)}),makeSearchRow:k=>({label:`Search slides for \u201C${k}\u201D`,hint:"",run:()=>{ve(),et(k)}})});mt=O;let Q=document.createElement("div");Q.className="pal-input"+(vt?" tp-active":""),Q.textContent=vt||"type a command\u2026",w.appendChild(Q);let m=0;for(let k of O){let _=m++,W=document.createElement("div");W.className="narr-row pal-row";let he=document.createElement("span");if(k.cat){let Re=document.createElement("span");Re.className="pal-cat",Re.textContent=`${k.cat}: `,he.appendChild(Re)}he.appendChild(document.createTextNode(k.label)),W.appendChild(he);let Be=document.createElement("span");if(Be.className="pal-right",k.write){let Re=document.createElement("span");Re.className="pal-tag",Re.textContent="write",Be.appendChild(Re)}if(k.hint){let Re=document.createElement("span");Re.className="pal-kbd",Re.textContent=k.hint,Be.appendChild(Re)}Be.childNodes.length&&W.appendChild(Be),W.addEventListener("mouseenter",()=>St(_)),W.addEventListener("click",()=>{St(_),Vt()}),w.appendChild(W)}if(!mt.length){let k=document.createElement("div");k.className="tp-none",k.textContent="no matching command",w.appendChild(k)}St(0)}function St(w){mt.length&&(ht=vn(ut.querySelectorAll(".pal-row"),w,"narr-sel"))}function Vt(){let w=mt[ht];w&&(w.keepOpen||Yt(),w.run())}function on(){if(ut)return Yt();L.opening(),vt="",Ue=Mt(),ut=document.createElement("div"),ut.className="decklight-narr decklight-palette",ut.innerHTML='<div class="narr-card" role="listbox" aria-label="Commands"></div>',Qt(ut,Yt),E.appendChild(ut),Wt()}function Yt(){ut?.remove(),ut=null}let an="0.9.0",Cn=null,wn=0,Nt=[],Ln=[.75,1,1.25,1.5,2];function ar(){return[{label:"Decklight version",value:an||"unknown \u2014 not a built bundle",...an?{hint:"\u23CE copies",run:()=>Er(an)}:{}},...s?[]:[{label:"Display",value:xn?"fill screen":tt(),hint:"\u23CE switches",stays:!0,run:()=>yt(!xn)}],...s?[]:[{label:"Arrows and slide number in fullscreen",value:cr()?"hidden":"shown",hint:"\u23CE switches \xB7 \u21E7F",stays:!0,run:()=>cn(!cr())},{label:"Clock",value:mr.status().clockOn?"on":"off",hint:"\u23CE switches",stays:!0,run:()=>Ir()},{label:"Progress bar",value:mr.status().progressOn?"on":"off",hint:"\u23CE switches",stays:!0,run:()=>ls()},{label:"Captions",value:Gt.status().captionsOn?"on":"off",hint:"\u23CE switches",stays:!0,run:()=>sr()},{label:"Voice speed",value:`${Gt.status().rate}\xD7`,hint:"\u23CE cycles",stays:!0,run:()=>{let w=Gt.status().rate,O=Ln.find(Q=>Q>w+1e-6)??Ln[0];Hr(O-w)}}],...Xe?.available()?[{label:"Editing bar",value:On.hidden()?"hidden":"shown",hint:"\u23CE switches",stays:!0,run:()=>On.toggleHidden()}]:[],...Xe?.available()?[{label:"Push tags",value:Xe.pushTags()?"with the branch":"off",hint:"\u23CE switches",stays:!0,run:()=>Xe.setPushTags(!Xe.pushTags())}]:[],...Xe?.available()?[{label:"Notes autosave",value:Xe.notesQuietLabel(),hint:"\u23CE cycles",stays:!0,run:()=>Xe.cycleNotesQuiet()}]:[]]}async function Er(w){try{return await navigator.clipboard.writeText(w),ce(`copied ${w}`,2200),!0}catch{}let O=document.createElement("textarea");O.value=w,O.setAttribute("readonly",""),O.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(O),O.select();let Q=!1;try{Q=document.execCommand("copy")}catch{}return O.remove(),ce(Q?`copied ${w}`:`could not copy \u2014 ${w}`,Q?2200:6e3),Q}function kn(){if(Cn)return tn();L.opening(),Cn=document.createElement("div"),Cn.className="decklight-narr decklight-settings",Cn.innerHTML='<div class="narr-card" role="listbox" aria-label="Settings"></div>',Qt(Cn,tn),E.appendChild(Cn),wr(0)}function Bn(w){let O=Nt[w];O?.run?.(),O?.run&&O.stays?wr(w):tn()}function wr(w){let O=Cn.querySelector(".narr-card");O.replaceChildren();let Q=document.createElement("div");Q.className="narr-head",Q.textContent="settings",O.appendChild(Q),Nt=ar(),Nt.forEach((m,k)=>{let _=document.createElement("div");_.className="narr-row"+(m.run?"":" narr-fact");let W=document.createElement("span");if(W.className="narr-row-label",W.textContent=m.label,_.appendChild(W),m.value!==void 0){let he=document.createElement("span");he.className="narr-flavor",he.textContent=m.value,_.appendChild(he)}if(m.hint){let he=document.createElement("span");he.className="narr-flavor narr-hint",he.textContent=m.hint,_.appendChild(he)}_.addEventListener("mouseenter",()=>Nr(k)),m.run&&_.addEventListener("click",()=>Bn(k)),O.appendChild(_)}),Nr(Math.min(w,Nt.length-1))}function Nr(w){wn=vn(Cn.querySelectorAll(".narr-row"),w,"narr-sel")}function tn(){Cn?.remove(),Cn=null}V.restoreSaved(),V.reportMissing();let Mn=_u({root:E,config:n,params:t,toast:ce,debugLog:(...w)=>y(...w),overlays:L,editmode:()=>Xe,remeasure:()=>{ye?._sections&&(Ho(ye._sections,n),zo(ye._sections[ye.state.slide-1],ye.state.slide))}}),un=w=>Mn.cycle(w),dn=()=>Mn.open();try{Mn.restore()}catch{}function Rn(w){if(!w)return null;if(w.startsWith("#")){let Q=document.querySelector(w);if(!Q)return null;let m=Q.cloneNode(!0);return m.removeAttribute("id"),m.style.removeProperty("display"),m}if(w.trim().startsWith("<")){let Q=document.createElement("div");return Q.innerHTML=w,Q.firstElementChild}let O=document.createElement("img");return O.src=w,O.alt="",O}let nn=null;V.updateCanvas();let Tt=E.querySelector(":scope > .decklight-stage");if(!Tt){for(Tt=document.createElement("div"),Tt.className="decklight-stage";E.firstChild;)Tt.appendChild(E.firstChild);E.appendChild(Tt)}Tt.style.width=n.width+"px",Tt.style.height=n.height+"px";let fn="decklight-display:"+location.pathname,xn=!s&&Nn(fn)==="fill",xe=[1,2.4],B=null;function Le(w,O){let Q=n.width,m=n.height;if(xn&&w>0&&O>0){let k=Math.min(xe[1],Math.max(xe[0],w/O));k>Q/m?Q=Math.round(m*k):m=Math.round(Q/k)}return Tt.style.width===Q+"px"&&Tt.style.height===m+"px"?!1:(Tt.style.width=Q+"px",Tt.style.height=m+"px",!0)}function je(){clearTimeout(B),B=setTimeout(()=>{ye?._sections&&(Ho(ye._sections,n),zo(ye._sections[ye.state.slide-1],ye.state.slide))},150)}function tt(){let w=(Q,m)=>m?w(m,Q%m):Q,O=w(n.width,n.height)||1;return`${n.width/O}:${n.height/O}`}function yt(w){xn=!!w,yn(fn,xn?"fill":null),E.toggleAttribute("data-display-fill",xn),ye._reflow?.(),ce(xn?"display: fills the screen":`display: ${tt()}`,2200)}if(E.toggleAttribute("data-display-fill",xn),n.logo&&(n.logo.src||n.logo.onLight||n.logo.onDark)){nn=document.createElement("div"),nn.className="decklight-logo",nn.setAttribute("data-pos",n.logo.position||"bottom-left"),n.logo.height&&nn.style.setProperty("--logo-h",n.logo.height+"px");for(let[w,O]of[["src","on-any"],["onLight","on-light"],["onDark","on-dark"]]){let Q=Rn(n.logo[w]);if(!Q)continue;let m=document.createElement("span");m.className=O,m.appendChild(Q),nn.appendChild(m)}E.appendChild(nn)}function wt(w){nn&&w.forEach(O=>{if(!O.hasAttribute("data-logo")||O.querySelector(":scope > .decklight-hero-logo"))return;let Q=document.createElement("div");Q.className="decklight-hero-logo";let m=parseFloat(O.getAttribute("data-logo"));m&&Q.style.setProperty("--hero-logo-h",m+"px"),Q.innerHTML=nn.innerHTML,O.prepend(Q)})}_g(Tt),bl(Tt),Al(Tt),pl(Tt),oa(Tt,mo);function It(w,O){O==="auto"?w.removeAttribute("data-layout"):w.setAttribute("data-layout",O)}function At(w,O){return Ho([w],n),Ru([w],()=>O),zo(w,O),w.hasAttribute("data-split-conflict")}E.addEventListener("decklight:theme",w=>{let O=w.detail?.theme;typeof O=="string"&&V.applyTheme(O,!0)}),E.addEventListener("decklight:concepts",w=>{let O=w.detail?.concepts;!O||typeof O!="object"||(n.concepts=O,Js(Tt,n.concepts),ot.refresh())}),E.addEventListener("decklight:layout",w=>{let{slide:O,layout:Q}=w.detail??{},m=ye._sections?.[O-1];!m||typeof Q!="string"||(It(m,Q),At(m,O))}),E.addEventListener("decklight:content",w=>{let{slide:O,el:Q,code:m}=w.detail??{},k=ye._sections?.[O-1];k&&(m&&Q?.isConnected&&oa(Q,mo),ye._rescanFor(Q?.isConnected?Q:k),At(k,O))});let In=xu({slideOf:()=>ye.state.slide,sectionAt:w=>ye._sections[w-1],describe:w=>({autoPins:Pu(w,n)!==null,hasSplitPair:Du(w).length>1}),available:()=>Xe.available(),unavailableMessage:()=>Xe.cannot("picking a layout"),apply:It,relayout:At,post:w=>fetch(Xe.base()+"/deck/edit/slide/layout",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...w,quiet:!0,from:Xe.pageId()})}).then(O=>{if(!O.ok)throw new Error(O.status)}),toast:ce,debugLog:y}),Rt=w=>In.cycle(w),mn=w=>In.ring(w),ye={root:E,stage:Tt,config:n,_sections:[],_records:[],state:{slide:1,step:0,totalSlides:0},_listeners:new Map,_scale:1,on(w,O){return this._listeners.has(w)||this._listeners.set(w,new Set),this._listeners.get(w).add(O),this},off(w,O){return this._listeners.get(w)?.delete(O),this},_emit(w,O){(this._listeners.get(w)||[]).forEach(Q=>Q(O)),E.dispatchEvent(new CustomEvent("decklight:"+w,{detail:O}))},sync(){this._sections=[...Tt.querySelectorAll(":scope > section")],this._sections.forEach((O,Q)=>O.setAttribute("data-slide-index",String(Q+1))),hi(this._sections,{warn:O=>{console.warn(`decklight: ${O}`),y("design-system",O)}}),ul(dl(Pr().values())),Js(Tt,n.concepts),wt(this._sections),ed(this._sections,{printMode:s}),Ho(this._sections,n),Ru(this._sections),Bd(this._sections),s&&Gd(E,Tt),this._records=this._sections.map(O=>zi(O)),this.state.totalSlides=this._sections.length,this.state.slide=Math.min(this.state.slide,this.state.totalSlides||1);let w=this._records[this.state.slide-1];w&&(this.state.step=Math.min(this.state.step,w.groups.length)),Vr(s?this._sections:[this._sections[this.state.slide-1]]),this._afterSync?.()},_rescanFor(w){let O=w.closest("section"),Q=this._sections.indexOf(O);if(Q!==-1){if(this._records[Q]=zi(O),s){As(this._records[Q],this._records[Q].groups.length);return}Q===this.state.slide-1?(this.state.step=Math.min(this._requestedStep??this.state.step,this._records[Q].groups.length),this._requestedStep=null,Dr(()=>As(this._records[Q],this.state.step)),this._updateHash(!1)):Dr(()=>As(this._records[Q],0)),this._notify()}},_stepLabels(w){let O=this._records[w];return O?Xo(O):[]},_hidden(w){return!c&&!!this._sections[w-1]?.hasAttribute("data-hidden")},_visibleFrom(w,O){for(let Q=w;Q>=1&&Q<=this.state.totalSlides;Q+=O)if(!this._hidden(Q))return Q;return null},next(){let w=this._records[this.state.slide-1];if(w&&this.state.step<w.groups.length){this.goto(this.state.slide,this.state.step+1,{direction:"fwd"});return}let O=this._visibleFrom(this.state.slide+1,1);O?this.goto(O,0,{direction:"fwd"}):pe(1)},prev(){if(this.state.step>0){this.goto(this.state.slide,this.state.step-1,{direction:"back"});return}let w=this._visibleFrom(this.state.slide-1,-1);w?this.goto(w,this._records[w-1].groups.length,{direction:"back"}):pe(-1)},goto(w,O=0,Q={}){if(w=Math.max(1,Math.min(w,this.state.totalSlides)),this._hidden(w)){let W=Q.direction==="back"?-1:1,he=this._visibleFrom(w,W)??this._visibleFrom(w,-W);if(he==null)return;w=he,O=W<0?this._records[w-1]?.groups.length??0:0}let m=this._records[w-1];this._requestedStep=O,O=Math.max(0,Math.min(O,m?m.groups.length:0));let k=w===this.state.slide;if(k&&O===this.state.step&&!Q.force)return;let _=Q.direction||(w>this.state.slide||k&&O>this.state.step?"fwd":"back");!k||Q.force?(this._activateSlide(w,_,Q),this.state.slide=w,this.state.step=O,Dr(()=>As(m,O)),this._emit("slide",{slide:w,total:this.state.totalSlides,direction:_}),Vr([this._sections[w-1]])):(this.state.step=O,As(m,O),this._emit("build",{slide:w,index:O,total:m.groups.length,direction:_})),this._updateChrome(),this._updateHash(!k),this._notify()},_activateSlide(w,O,Q={}){let m=this._sections[this.state.slide-1],k=this._sections[w-1];if(E.classList.toggle("has-hero-logo",k?.hasAttribute("data-logo")??!1),m===k){k.classList.add("active"),vo(k);return}let _=!m||!m.classList.contains("active"),W=m&&k&&!_&&m.hasAttribute("data-auto-animate")&&k.hasAttribute("data-auto-animate")&&Math.abs(this._sections.indexOf(k)-this._sections.indexOf(m))===1;if(this._sections.forEach(ct=>ct.classList.remove("active","entering","leaving","dir-fwd","dir-back","tr-none","tr-fade","tr-slide","tr-scale","tr-flip")),k.classList.add("active"),vo(k),_||s)return;if(W){m.classList.add("leaving"),m.style.visibility="hidden",k.style.visibility="hidden",k.offsetWidth,k.style.visibility="",El(m,k,this._scale),m.classList.remove("leaving"),m.style.visibility="";return}let he=Yi(k.getAttribute("data-transition"),this.config.transition),Be=kl(he,O);if(!Be)return;k.classList.add(...Be.entering),m.classList.add(...Be.leaving);let Re=ko(getComputedStyle(k).getPropertyValue("--transition-duration"),350);clearTimeout(this._transitionTimer),this._transitionTimer=setTimeout(()=>{m.classList.remove(...Be.leaving),k.classList.remove(...Be.entering)},Re+60)},_updateChrome(){if(G?.onSlide(),Kr){let w=this._records[this.state.slide-1],O=w?w.groups.length:0,Q=this.state.totalSlides<=1?1:(this.state.slide-1+(O?this.state.step/(O+1):0))/(this.state.totalSlides-1);Kr.style.width=(Math.min(Q,1)*100).toFixed(2)+"%"}if(nr){let w=this.config.slideNumber?this.config.slideNumber==="n/N"?`${this.state.slide} / ${this.state.totalSlides}`:String(this.state.slide):"";if(nr.textContent=w,P.any){let O=P.title(),Q=document.createElement("span");Q.className="mod",Q.textContent=O,nr.prepend(Q)}}},_updateHash(w){!this.config.hash||s||(Zn=Zn||!!w,!Gr&&(Gr=setTimeout(()=>{Gr=null,Qr()},Ur)))},_notify(){this.__notifySpeaker&&this.__notifySpeaker()}};function lr(w,O){let Q=document.createElement("a");Q.href=w,Q.download=O,document.body.appendChild(Q),Q.click(),Q.remove()}function Dr(w){E.classList.add("decklight-no-anim"),w(),E.offsetWidth,E.classList.remove("decklight-no-anim")}let Ur=90,Gr=null,Zn=!1;function Qr(w=!0){if(!ye||!n.hash||s)return;let O=`#/${ye.state.slide}/${ye.state.step}`,Q=Zn;if(Zn=!1,"#"+Ga(location.hash)!==O){ss=!0;try{Q?history.pushState(null,"",O):history.replaceState(null,"",O)}catch{}setTimeout(()=>{ss=!1}),w&&"#"+Ga(location.hash)!==O&&(Zn=Q,requestAnimationFrame(()=>Qr(!1)))}}let Kr=null,nr=null;if(n.controls&&!s){let w=document.createElement("div");w.className="decklight-controls",w.innerHTML=`
|
|
387
477
|
<button class="decklight-arrow prev" aria-label="Previous">\u2039</button>
|
|
388
|
-
<button class="decklight-arrow next" aria-label="Next">\u203A</button>`,
|
|
389
|
-
<tr><td>\u2192 / PageDown</td><td>next build / slide</td></tr>
|
|
478
|
+
<button class="decklight-arrow next" aria-label="Next">\u203A</button>`,E.appendChild(w),w.querySelector(".prev").addEventListener("click",()=>ye.prev()),w.querySelector(".next").addEventListener("click",()=>ye.next())}let sn={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>'},Un=null,Gn=null;function _r(){let w=E||document.documentElement;document.fullscreenElement?document.exitFullscreen?.():w.requestFullscreen?.()?.catch?.(()=>{})}document.addEventListener("fullscreenchange",()=>{Un&&(Un.innerHTML=document.fullscreenElement?sn.unfull:sn.full)});let ln="decklight-fs-chrome:"+location.pathname,cr=()=>E.classList.contains("fs-chrome-hidden");function cn(w,{quiet:O=!1}={}){E.classList.toggle("fs-chrome-hidden",w),yn(ln,w?"hidden":null),O||ce(w?"arrows and slide number hidden in fullscreen":"arrows and slide number shown in fullscreen"),y("nav",`fullscreen chrome ${w?"hidden":"shown"}`)}Nn(ln)==="hidden"&&cn(!0,{quiet:!0});function Ot(){if(!Gn)return;let w=Gt.status().narrating;Gn.innerHTML=w?sn.sound:sn.mute,Gn.setAttribute("aria-label",w?"Mute narration":"Play narration"),Gn.setAttribute("aria-pressed",String(w))}(n.slideNumber||j||oe)&&!s&&(nr=document.createElement("div"),nr.className="decklight-slide-number",(j||oe)&&(nr.title="G \u2014 find a slide or module",nr.style.cursor="pointer",nr.addEventListener("click",()=>ve())),E.appendChild(nr));let Jt=null,Fn=0;function jt(){return getComputedStyle(Jt).gridTemplateColumns.split(" ").length||1}function En(w){let O=Jt.querySelectorAll(".ov-cell");Fn=Math.max(0,Math.min(w,O.length-1)),O.forEach((Q,m)=>Q.classList.toggle("ov-selected",m===Fn)),O[Fn]?.scrollIntoView({block:"nearest"})}function qn(){let w=Fn+1;ur(),ye.goto(w,0,{force:!0})}function dr(){if(!Jt)return;let w=Jt.querySelector(".ov-cell");if(!w)return;Jt.style.gridAutoRows=Math.round(w.clientWidth*n.height/n.width)+"px";let O=w.clientWidth/n.width;Jt.querySelectorAll(".ov-frame").forEach(Q=>{Q.style.transform=`scale(${O})`})}let rn="decklight-overview-open:"+location.pathname,jn=null;function Kn(w,O,Q=null){if(Xe.available()){try{sessionStorage.setItem(rn,"1")}catch{}Xe.slideOp(w,{slide:O+1,to:Q}).catch(()=>{try{sessionStorage.removeItem(rn)}catch{}})}}function $r(w,O,Q){let m=w.getBoundingClientRect(),k=Q.clientX<m.left+m.width/2;return{before:k,to:k?O+1:O+2}}function vr(){Jt?.querySelectorAll(".ov-drop-before, .ov-drop-after").forEach(w=>w.classList.remove("ov-drop-before","ov-drop-after"))}function es(w,O){let Q=document.createElement("div");Q.className="ov-tools";for(let[m,k,_]of[["new","+","new slide after this one"],["duplicate","\u29C9","duplicate this slide"],["delete","\u{1F5D1}",`delete this slide (${zt} takes it back)`]]){let W=document.createElement("button");W.type="button",W.className=`ov-tool ov-${m}`,W.title=_,W.textContent=k,W.addEventListener("click",he=>{he.stopPropagation(),Kn(m,O)}),Q.appendChild(W)}w.appendChild(Q),w.draggable=!0,w.addEventListener("dragstart",m=>{jn=O,w.classList.add("ov-dragging");try{m.dataTransfer.effectAllowed="move",m.dataTransfer.setData("text/plain",String(O+1))}catch{}}),w.addEventListener("dragend",()=>{jn=null,w.classList.remove("ov-dragging"),vr()}),w.addEventListener("dragover",m=>{if(jn===null||jn===O)return;m.preventDefault();try{m.dataTransfer.dropEffect="move"}catch{}let{before:k}=$r(w,O,m);vr(),w.classList.add(k?"ov-drop-before":"ov-drop-after")}),w.addEventListener("drop",m=>{if(jn===null||jn===O)return;m.preventDefault();let k=jn,{to:_}=$r(w,O,m);vr();let W=k+1<_?_-1:_;W!==k+1&&Kn("move",k,W)})}function ur(){if(Jt){window.removeEventListener("resize",dr),Jt.remove(),Jt=null,E.classList.remove("decklight-overview");return}Jt=document.createElement("div"),Jt.className="decklight-overview-grid";let w=Xe.available();Jt.classList.toggle("ov-editable",w),ye._sections.forEach((O,Q)=>{let m=document.createElement("div");m.className="ov-cell"+(Q===ye.state.slide-1?" ov-current":"")+(O.hasAttribute("data-hidden")?" ov-hidden":"");let k=document.createElement("div");k.className="ov-frame",k.style.width=n.width+"px",k.style.height=n.height+"px";let _=O.cloneNode(!0);_.classList.add("active","ov-clone"),_.querySelectorAll("aside.notes, aside.rehearse").forEach(he=>he.remove()),_.querySelectorAll("input, button, select, textarea").forEach(he=>{he.removeAttribute("name"),he.disabled=!0}),k.appendChild(_),vo(_),m.appendChild(k);let W=document.createElement("span");W.className="ov-num",W.textContent=String(Q+1),m.appendChild(W),m.addEventListener("click",()=>{ur(),ye.goto(Q+1,0,{force:!0})}),w&&es(m,Q),Jt.appendChild(m)}),E.classList.add("decklight-overview"),E.appendChild(Jt),dr(),En(ye.state.slide-1),window.addEventListener("resize",dr)}let rr=null;function Br(){if(rr){rr.remove(),rr=null;return}rr=document.createElement("div"),rr.className="decklight-blackout",E.appendChild(rr)}let pn=null;function Fr(){let w=ye._records?.[ye.state.slide-1],O=Gt.status(),Q=O.live?`\u26A1 ${O.voice} \xB7 ${O.tone}`:O.track?`\u{1F50A} ${O.track.label}`:"none";return`slide ${ye.state.slide}/${ye.state.totalSlides} \xB7 step ${ye.state.step}/${w?w.groups.length:0} \xB7 theme ${T()??"\u2014"} \xB7 narration ${O.narrating?O.paused?"paused":"on":"off"} (${Q})`+(O.rate!==1?` \xB7 ${O.rate}\xD7`:"")+(O.spend>0?` \xB7 tts ~$${O.spend.toFixed(4)}`:"")}function Or(w){let O=document.createElement("div");O.className="dbg-row dbg-"+w.kind+(w.prev?" dbg-prev":"");for(let[Q,m]of[["dbg-t",w.t],["dbg-k",w.kind],["dbg-m",w.msg]]){let k=document.createElement("span");k.className=Q,k.textContent=m,O.appendChild(k)}b.querySelector(".dbg-log").appendChild(O)}function Sr(){let w=b?.querySelector(".dbg-state");w&&(w.textContent=Fr())}let gn=null,bn=null;function pr(){gn&&(bn==="events"&&g.onEntry(null),gn.remove(),gn=null,bn=null,b=null,le=null)}function Lr(w){if(gn&&bn===w){pr();return}pr(),gn=document.createElement("div"),bn=w,gn.className="decklight-log "+(w==="events"?"decklight-debug":"decklight-msglog");let O=document.createElement("div");O.className="log-tabs";for(let[m,k]of[["messages","messages"],["events","events"]]){let _=document.createElement("button");_.type="button",_.className="log-tab"+(m===w?" log-tab-on":""),_.textContent=k,m!==w&&_.addEventListener("click",W=>{W.stopPropagation(),Lr(m)}),O.appendChild(_)}let Q=document.createElement("span");if(Q.className="log-hint",Q.innerHTML='<kbd title="the key left of 1">`</kbd> \xB7 Esc closes',O.appendChild(Q),gn.appendChild(O),w==="events"){b=gn,gn.insertAdjacentHTML("beforeend",'<div class="dbg-state"></div><div class="dbg-log"></div>'),E.appendChild(gn),g.entries.forEach(Or),Sr();let m=gn.querySelector(".dbg-log");m.scrollTop=m.scrollHeight,g.onEntry(k=>{Or(k),Sr();let _=b.querySelector(".dbg-log");_.scrollTop=_.scrollHeight})}else le=gn,gn.insertAdjacentHTML("beforeend",'<div class="msg-log"></div>'),E.appendChild(gn),ts()}function Pn(){Lr("events")}function ts(){let w=le?.querySelector(".msg-log");if(w){if(w.innerHTML="",!ee.length){let O=document.createElement("div");O.className="msg-empty",O.textContent="no messages yet",w.appendChild(O);return}ee.forEach(({at:O,text:Q})=>{let m=document.createElement("div");m.className="msg-row";let k=document.createElement("span");k.className="msg-time",k.textContent=O.toLocaleTimeString([],{hour12:!1});let _=document.createElement("span");_.className="msg-text",_.textContent=Q,m.append(k,_),w.appendChild(m)}),w.scrollTop=w.scrollHeight}}function or(){Lr("messages")}ye.on("ready",w=>y("ready",`${w.slides} slides${w.print?" \xB7 print":""}`)),ye.on("slide",w=>{y("slide",`\u2192 ${w.slide}/${w.total} (${w.direction})`),Sr()}),ye.on("build",w=>{y("build",`slide ${w.slide} step ${w.index}/${w.total} (${w.direction})`),Sr()}),window.addEventListener("error",w=>y("error",String(w.message)));function qr(){if(pn){pn.remove(),pn=null;return}pn=document.createElement("div"),pn.className="decklight-help",pn.innerHTML=`<div class="help-card"><h3>Keyboard</h3><table>
|
|
479
|
+
<tr><td>\u2192 / PageDown</td><td>next build / slide (\u2190 and \u2192 also while a panel beside the slide has the keyboard; a text field keeps them)</td></tr>
|
|
390
480
|
<tr><td>\u23B5</td><td>pause / resume the voice while it is speaking \u2014 otherwise it advances</td></tr>
|
|
391
481
|
<tr><td>\u2190 / PageUp</td><td>previous</td></tr>
|
|
392
482
|
<tr><td>Home / End</td><td>first / last slide</td></tr>
|
|
393
483
|
<tr><td>O</td><td>overview</td></tr>
|
|
394
|
-
<tr><td>S</td><td>speaker
|
|
484
|
+
<tr><td>S</td><td>this slide's speaker notes \u2014 editable in write mode, read-only elsewhere</td></tr>
|
|
485
|
+
<tr><td>\u2325\u23CE / Alt+Enter</td><td>speaker view \u2014 a second window with notes, next slide, timer (again: rehearse mode)</td></tr>
|
|
395
486
|
<tr><td>V</td><td>narration \u2014 track, voice, character, recording, captions, speed</td></tr>
|
|
487
|
+
<tr><td>I</td><td>inspector \u2014 all about this slide, or the element selected on it: layout, builds, notes, fit, contrast, sources; its colours and type; \u2B1A picks an element</td></tr>
|
|
396
488
|
<tr><td>< / ></td><td>voice speed (0.25\xD7 steps)</td></tr>
|
|
397
489
|
<tr><td>B</td><td>blackout</td></tr>
|
|
398
|
-
<tr><td>
|
|
399
|
-
<tr><td>`</td><td>messages \u2014 the key left of 1
|
|
490
|
+
<tr><td>pinch \xB7 0</td><td>zoom the slide (trackpad pinch, or two fingers; scroll pans) \xB7 0, Esc or a slide change fits it again</td></tr>
|
|
491
|
+
<tr><td>`</td><td>the log, on its messages tab (the events tab beside it is the debug stream) \u2014 the key left of 1; \u2303` / \u2325` also works while editing notes</td></tr>
|
|
400
492
|
<tr><td>C</td><td>captions (follow the voice)</td></tr>
|
|
401
493
|
<tr><td>W</td><td>pen \u2014 draw on the slide (\u232B clears)</td></tr>
|
|
402
494
|
<tr><td>\u21E7W</td><td>laser pointer</td></tr>
|
|
403
495
|
<tr><td>K</td><td>commit \u2014 what changed, and what to call it (\u2318K / \u2303K also works while typing)</td></tr>
|
|
404
|
-
<tr><td>
|
|
405
|
-
<tr><td>H / R</td><td>history \u2014 commits, slides and diff per version, \u23CE restores one (author mode)</td></tr>
|
|
496
|
+
<tr><td>H</td><td>history \u2014 commits, slides and diff per version, \u23CE restores one (write mode)</td></tr>
|
|
406
497
|
<tr><td>M</td><td>comments \u2014 yours and every review's, grouped by who said them, \u23CE jumps</td></tr>
|
|
407
498
|
<tr><td>\u21E7M</td><td>leave a comment on the slide you are looking at</td></tr>
|
|
408
|
-
<tr><td>
|
|
409
|
-
<tr><td
|
|
499
|
+
<tr><td>F / \u2318\u23CE / Ctrl+Enter</td><td>fullscreen (\u2318\u23CE is the present chord; the bar and the commit chip leave with it)</td></tr>
|
|
500
|
+
<tr><td>\u21E7F</td><td>show / hide the arrows and the slide number in fullscreen</td></tr>
|
|
410
501
|
<tr><td>T</td><td>theme picker (type to filter)</td></tr>
|
|
411
502
|
<tr><td>/</td><td>command palette \u2014 find, themes, everything (\u201CWelcome to Decklight\u201D reopens the intro)</td></tr>
|
|
412
503
|
<tr><td>G</td><td>slide finder (live preview)</td></tr>
|
|
413
|
-
<tr><td>E</td><td>element edit mode \u2014 right-click a slide element (author mode)</td></tr>
|
|
414
504
|
<tr><td>, / .</td><td>cycle theme</td></tr>
|
|
415
505
|
<tr><td>[ / ]</td><td>cycle font</td></tr>
|
|
416
|
-
<tr><td
|
|
417
|
-
<tr><td
|
|
418
|
-
<tr><td>A</td><td>ask an AI agent to edit the deck (
|
|
506
|
+
<tr><td>${bs?"\u2325\u2318C / \u2325\u2318V":"Ctrl+Alt+C / V"}</td><td>copy / paste a selected shape's style: colours, border, type (write mode)</td></tr>
|
|
507
|
+
<tr><td>${zt} / ${Ao}</td><td>undo / redo deck edits (write mode)</td></tr>
|
|
508
|
+
<tr><td>A</td><td>ask an AI agent to edit the deck (write mode)</td></tr>
|
|
419
509
|
<tr><td>\u2303T</td><td>generate a theme (repeat to re-roll)</td></tr>
|
|
420
510
|
<tr><td>\u2303\u21E7T</td><td>save the generated theme</td></tr>
|
|
421
|
-
<tr><td>?</td><td>this help</td></tr></table
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
511
|
+
<tr><td>?</td><td>this help</td></tr></table>
|
|
512
|
+
<h3>Write mode, in context</h3><table>
|
|
513
|
+
<tr class="help-ctx"><td>\u23CE \xB7 \u232B \xB7 Esc</td><td>on a selected element: edit its text (or open its menu) \xB7 remove it \xB7 let it go</td></tr>
|
|
514
|
+
<tr class="help-ctx"><td>\u23CE \xB7 \u21E7\u23CE \xB7 Esc</td><td>while editing text: save \xB7 new line \xB7 cancel</td></tr>
|
|
515
|
+
<tr class="help-ctx"><td>${bs?"\u2318B \xB7 \u2318I \xB7 \u2318E":"Ctrl+B \xB7 Ctrl+I \xB7 Ctrl+E"}</td><td>while editing text: bold \xB7 italic \xB7 code</td></tr>
|
|
516
|
+
<tr class="help-ctx"><td>N \xB7 D \xB7 \u232B</td><td>in the overview: new slide \xB7 duplicate \xB7 delete</td></tr>
|
|
517
|
+
<tr class="help-ctx"><td>E</td><td>in the inspector: edit this slide's sources</td></tr>
|
|
518
|
+
<tr class="help-ctx"><td>\u21E7-click Layout</td><td>on the bar: cycle the layout backwards</td></tr></table></div>`,pn.addEventListener("click",qr),E.appendChild(pn)}L.register({isOpen:()=>!!ut,close:Yt,transient:!0,keydown:w=>eo(w,{query:vt,onMove:O=>St(ht+O),onCommit:Vt,onType:O=>{vt+=O,Wt()},onBackspace:()=>{vt=vt.slice(0,-1),Wt()},onClear:()=>{vt="",Wt()},onClose:Yt})}),L.register({isOpen:Mn.isOpen,close:Mn.close,transient:!0,keydown:Mn.keydown}),L.register({isOpen:()=>!!Cn,close:tn,transient:!0,keydown:w=>eo(w,{onMove:O=>Nr(wn+O),onCommit:()=>Bn(wn),onClose:tn})}),L.register({isOpen:()=>!!at,close:Ne,transient:!0,keydown:w=>(w.key==="ArrowRight"||w.key==="ArrowLeft")&&Ke()?Pe(w.key==="ArrowRight"):eo(w,{query:ft,onMove:O=>Ve(N+O,!1),onCommit:Y,onType:O=>et(ft+O),onBackspace:()=>et(ft.slice(0,-1)),onClear:()=>et(""),onClose:Ne})}),L.register({isOpen:()=>!!Jt,close:ur,keydown(w){switch(w.key){case"ArrowRight":En(Fn+1);break;case"ArrowLeft":En(Fn-1);break;case"ArrowDown":En(Fn+jt());break;case"ArrowUp":En(Fn-jt());break;case"Enter":case" ":qn();break;case"o":case"O":case"Escape":ur();break;case"Backspace":case"Delete":Xe.available()&&Kn("delete",Fn);break;case"n":case"N":Xe.available()&&Kn("new",Fn);break;case"d":case"D":Xe.available()&&Kn("duplicate",Fn);break;default:return!1}return!0}});let Wr=w=>w.code==="Backquote"||w.key==="`"||w.key==="~"||w.key==="\xB2";function Mr(w){if(Wr(w)&&(w.metaKey||w.ctrlKey||w.altKey)){or(),w.preventDefault();return}if((w.metaKey||w.ctrlKey)&&!w.altKey&&!w.shiftKey&&(w.key==="k"||w.key==="K")){Xe.commit.open(),w.preventDefault();return}if(/^(input|textarea|select)$/i.test(w.target.tagName)&&!w.target.readOnly||w.target.isContentEditable||gr.editing())return;if(w.ctrlKey&&!w.metaKey&&!w.altKey&&(w.key==="T"||w.key==="t")){w.shiftKey?Te():V.rollFromPicker()||_e(),w.preventDefault();return}if((w.metaKey||w.ctrlKey)&&!w.altKey&&!w.shiftKey&&w.key==="Enter"&&L.active()?.save?.()){w.preventDefault();return}if((w.metaKey||w.ctrlKey)&&!w.altKey&&!w.shiftKey&&w.key==="Enter"){w.preventDefault(),_r();return}let O=kg(w),Q=w.altKey&&!w.metaKey&&!w.ctrlKey&&w.key==="Enter",m=w.altKey&&(w.metaKey||w.ctrlKey)&&!w.shiftKey&&(w.code==="KeyC"||w.code==="KeyV")&&Xe.elementEditOn()?w.code:null;if(!O&&!Q&&!m&&(w.metaKey||w.ctrlKey||w.altKey))return;let k=L.active();if(k?.panel&&!w.shiftKey&&(w.key==="ArrowLeft"||w.key==="ArrowRight")){w.key==="ArrowRight"?ye.next():ye.prev(),w.preventDefault();return}if(k){if(!O&&k.keydown(w)){w.preventDefault();return}if(w.key==="Escape"){k.close(),w.preventDefault();return}if((typeof k.modal=="function"?k.modal():k.modal)!==!1)return}if(Q){l(),w.preventDefault();return}if(m){let _=On.selected();_?m==="KeyC"?Wn?.copy(_):Wn?.paste(_).then(W=>{W&&On.refresh?.()}):ce(`select a shape first, then ${m==="KeyC"?`${Wn.keys.copy} copies`:`${Wn.keys.paste} pastes`} its style`,2600),w.preventDefault();return}if(O){zr(w.shiftKey?"redo":"undo"),w.preventDefault();return}if(Wr(w)){or(),w.preventDefault();return}if(On.keydown(w)){w.preventDefault();return}switch(w.key){case" ":Gt.status().voiceInPlay?Gt.playPause():ye.next();break;case"ArrowRight":case"PageDown":ye.next();break;case"ArrowLeft":case"PageUp":ye.prev();break;case"Home":ye.goto(1,0);break;case"End":ye.goto(ye.state.totalSlides,0);break;case"o":case"O":ur();break;case"b":case"B":Br();break;case"c":case"C":sr();break;case"k":case"K":Xe.commit.open();break;case"h":case"H":Xe.history.open();break;case"g":case"G":ve();break;case"m":case"M":w.shiftKey?fr.compose():fr.open();break;case"f":case"F":w.shiftKey?cn(!cr()):_r();break;case"v":case"V":Gt.openPicker();break;case"i":case"I":G?.open();break;case"s":case"S":cs();break;case"t":case"T":V.openPicker();break;case"/":on();break;case".":F(1);break;case",":F(-1);break;case">":Hr(.25);break;case"<":Hr(-.25);break;case"]":un(1);break;case"[":un(-1);break;case"a":case"A":fs();break;case"w":case"W":Qn(w.shiftKey?"laser":"pen");break;case"Backspace":if(!mr.annotator?.active)return;mr.annotator.clear();break;case"?":qr();break;case"Escape":if(se())break;if(Ht.k!==1&&!L.active()){Cr();break}Jt?ur():pn?qr():gn&&pr();break;case"0":if(Ht.k!==1)Cr();else return;break;default:return}w.preventDefault()}s||document.addEventListener("keydown",Mr);let hr=null;E.addEventListener("touchstart",w=>{hr=w.touches.length===1?w.touches[0].clientX:null},{passive:!0}),E.addEventListener("touchend",w=>{if(hr==null||Ht.k!==1)return;let O=w.changedTouches[0].clientX-hr;Math.abs(O)>40&&(O<0?ye.next():ye.prev()),hr=null},{passive:!0});let ps=w=>parseFloat(getComputedStyle(E).getPropertyValue(w))||0;function ns(){let w=E.getBoundingClientRect(),O=ps("--dock-left"),Q=ps("--dock-right"),m=ps("--dock-bottom"),k=w.width-O-Q,_=w.height-m;Le(k,_)&&je();let W=Math.min(k/parseFloat(Tt.style.width),_/parseFloat(Tt.style.height))||1;ye._scale=W,E.style.setProperty("--stage-scale",String(W)),Tt.style.transform=`translate(-50%, -50%) translate(${(O-Q)/2+Ht.x}px, ${-m/2+Ht.y}px) scale(${W*Ht.k})`}let rs=4,Ht={k:1,x:0,y:0};function Ar(w,{at:O=null,dx:Q=0,dy:m=0}={}){let k=Math.min(rs,Math.max(1,w));if(O&&k!==Ht.k){let _=E.getBoundingClientRect(),W=O.x-(_.left+_.width/2)-Ht.x,he=O.y-(_.top+_.height/2)-Ht.y,Be=k/Ht.k;Ht.x+=W-W*Be,Ht.y+=he-he*Be}if(Ht.k=k,Ht.x+=Q,Ht.y+=m,Ht.k===1)Ht.x=0,Ht.y=0;else{let _=E.getBoundingClientRect(),W=parseFloat(Tt.style.width)*ye._scale*Ht.k,he=parseFloat(Tt.style.height)*ye._scale*Ht.k,Be=Math.max(0,(W-_.width)/2),Re=Math.max(0,(he-_.height)/2);Ht.x=Math.min(Be,Math.max(-Be,Ht.x)),Ht.y=Math.min(Re,Math.max(-Re,Ht.y))}E.classList.toggle("is-zoomed",Ht.k!==1),ns(),Ft()}let Cr=()=>{Ht.k!==1&&Ar(1)},Hn=null;function Ft(){if(Ht.k===1){Hn?.remove(),Hn=null;return}Hn||(Hn=document.createElement("button"),Hn.type="button",Hn.className="decklight-zoom",Hn.title="zoomed \u2014 click, 0 or Esc fits the slide again",Hn.addEventListener("click",Cr),E.appendChild(Hn)),Hn.textContent=`${Math.round(Ht.k*100)}%`;let w=E.querySelector(".decklight-slide-num");Hn.style.right=w?`${16+w.offsetWidth+8}px`:""}if(new MutationObserver(()=>{Hn&&Ft()}).observe(E,{childList:!0}),ye.zoom=()=>({k:Ht.k,x:Ht.x,y:Ht.y}),ye.setZoom=(w,O)=>Ar(w,O),!s&&!t.has("embedded")){let w=k=>!Jt&&(k===E||Tt.contains(k));E.addEventListener("wheel",k=>{if(k.ctrlKey){if(k.preventDefault(),!w(k.target))return;Ar(Ht.k*Math.exp(-k.deltaY*.01),{at:{x:k.clientX,y:k.clientY}})}else Ht.k!==1&&w(k.target)&&(k.preventDefault(),Ar(Ht.k,{dx:-k.deltaX,dy:-k.deltaY}))},{passive:!1});let O=null,Q=k=>Math.hypot(k[0].clientX-k[1].clientX,k[0].clientY-k[1].clientY),m=k=>({x:(k[0].clientX+k[1].clientX)/2,y:(k[0].clientY+k[1].clientY)/2});E.addEventListener("touchstart",k=>{k.touches.length===2&&w(k.target)&&(O={d:Q(k.touches),k:Ht.k,m:m(k.touches)})},{passive:!0}),E.addEventListener("touchmove",k=>{if(!O||k.touches.length!==2)return;k.preventDefault();let _=m(k.touches);Ar(O.k*(Q(k.touches)/O.d),{at:_,dx:_.x-O.m.x,dy:_.y-O.m.y}),O.m=_},{passive:!1}),E.addEventListener("touchend",k=>{k.touches.length<2&&(O=null)},{passive:!0}),ye.on("slide",Cr)}ye._reflow=()=>{s||ns()},s||(new ResizeObserver(ns).observe(E),ns());let ws=uu({sectionsOf:()=>ye._sections,checkOverflow:zo}),Vr=w=>ws.watch(w),ss=!1;n.hash&&!s&&window.addEventListener("hashchange",()=>{if(ss)return;let w=Ua(location.hash);w&&ye.goto(w.slide,w.step,{force:!0})});let Xn=Ou({root:E,enabled:!s&&!t.has("embedded")&&n.bleed!==!1}),$n=(w=0)=>Xn.update(ye._sections[ye.state.slide-1],{ms:w});if(ye.on("slide",()=>{let w=ye._sections[ye.state.slide-1],O=Yi(w?.getAttribute("data-transition"),ye.config.transition);$n(O==="none"?0:ko(getComputedStyle(E).getPropertyValue("--transition-duration"),350))}),ye._afterSync=()=>$n(0),!s){let w=()=>{ye._sections.forEach((O,Q)=>{let m=O.querySelector(":scope > .slide-bg > video");m&&(Q===ye.state.slide-1&&!O.hasAttribute("data-bled")?m.play()?.catch?.(()=>{}):m.paused||m.pause())})};ye.on("slide",w)}ye.sync(),s&&nn&&(ye._sections.forEach(w=>{w.hasAttribute("data-logo")||w.appendChild(nn.cloneNode(!0))}),nn.remove()),document.fonts?.ready?.then(()=>{(fo===ye||!fo)&&Ho(ye._sections,n)}),ye.theme=w=>Z(w),ye.currentTheme=()=>T(),ye.themePicker={open:V.openPicker,close:V.closePicker},ye.generateTheme=_e,ye.cycleFont=un,ye.cycleLayout=Rt,ye.layoutRing=mn,ye.toggleMessages=or,ye.messages=ie,ye.showWelcome=Ie.showWelcome,ye.showEditingTour=Ie.showEditingTour,ye.settings={open:kn,close:tn,rows:ar};let jr=jc({root:E,overlays:L}),Sn=hu({root:E,overlays:L}),Gt=Yc({root:E,stage:Tt,config:n,params:t,printMode:s,toast:ce,logOnly:I,debugLog:y,overlays:L,instance:ye,openedMidTalk:(()=>{let w=n.hash&&Ua(location.hash);return!!w&&(w.slide!==1||w.step!==0)})(),rangePicker:jr,chapters:()=>P.markers(),syncSoundBtn:Ot,updateDebugState:Sr,downloadFromUrl:lr,editBase:()=>Xe?.available()?Xe.base():null,editReady:()=>Xe?.settled?.()??Promise.resolve(),enhanceScript:()=>Xe?.available()?Xe.enhanceScript:null,moduleOf:w=>Xe?.moduleOf?.(w)??null}),{character:Tn,toggleNarration:Rr,toggleNarrPause:Jr,changeNarrRate:Hr,toggleCaptions:sr,openRecordDialog:Ps,openMicRecorder:os,notesSegs:is,notesDraftOf:as}=Gt,Tr=Gt.openPicker;ye.toggleNarration=Rr,ye.narration={playPause:()=>Gt.playPause(),openPicker:w=>Gt.openPicker(w),status:()=>Gt.status()},t.has("record")&&!s&&setTimeout(()=>{L.active()||os()},700);let fr=ku({root:E,params:t,overlays:L,instance:ye,toast:ce,debugLog:y,sections:()=>ye._sections??[],titleOf:Ls,bodyOf:Si,editBase:()=>Xe?.available()?Xe.base():null,editReady:()=>Xe?.settled?.()??Promise.resolve()}),mr=Qc({root:E,printMode:s,toast:ce,debugLog:y,overlays:L,instance:ye,narration:Gt,downloadFromUrl:lr,setProgressBar:w=>{Kr=w}}),{toggleClock:Ir,toggleProgress:ls,toggleInk:Qn}=mr;function hs(){let w=hn();if(!w){ce("the speaker view could not open: allow pop-ups for this page, then try again",4200);return}w.__decklightSpeakerScript?.(!0)}ye.transcript.setOpener(hs),ye.toggleClock=Ir,ye.toggleProgress=ls;let Xe=Nd({root:E,config:n,params:t,printMode:s,toast:ce,progress:de,debugLog:y,debugReload:A,overlays:L,instance:ye,notesSegs:is,notesDraft:as,renderTheme:()=>V.renderTheme(),previewQuery:()=>V.previewQuery(),captionsOn:()=>Gt.status().captionsOn,toggleCaptions:sr,knownConcepts:()=>Ti(Tt,n.concepts??{}).map(w=>w.name)});J=mu({stage:()=>Tt,editmode:()=>Xe,choiceCard:Sn,toast:ce,repaint:()=>{Js(Tt,n.concepts??{}),ot.refresh(),G?.refresh?.()},debugLog:(...w)=>y(...w)}),Xe.setConceptTools(J);let Wn=wu({save:w=>Xe.saveStyles(w),toast:ce,repaint:()=>{Js(Tt,n.concepts??{}),ot.refresh(),G?.refresh?.()},snap:()=>V.brandLocked()?ud([...Pr().values()],V.currentTheme()):null,debugLog:(...w)=>y(...w)});Xe.setStyleClip(Wn),Xe.setEditConcepts(w=>ot.open({select:w})),ye._concepts={tools:J,editor:ot},Xe.settled().then(()=>{Xe.available()&&fe.resume()}),Xe.settled().then(()=>{let w=!1;try{w=sessionStorage.getItem(rn)==="1",sessionStorage.removeItem(rn)}catch{}w&&Xe.available()&&!Jt&&ur()});let{deckHistory:zr,toggleEditor:cs,toggleAgentAsk:fs}=Xe;Xe.settled?.().then(()=>{if(!Xe.available()||s||t.has("embedded")||t.has("capture"))return;E.classList.add("decklight-authoring");let w=[...document.querySelectorAll('meta[name="decklight-design-system-missing"]')].map(m=>m.content),O=ye._sections.map((m,k)=>[k+1,m.getAttribute("data-ds-missing")]).filter(([,m])=>m);if(!w.length&&!O.length)return;let Q=w.length?`design ${w.length===1?"system":"systems"} not on this machine: ${w.join("; ")}`:`slide ${O[0][0]}: ${O[0][1]}${O.length>1?` (and ${O.length-1} more)`:""} \u2014 shown as plain content`;ce(Q,7e3);for(let m of w)y("design-system",`missing ${m}`);for(let[m,k]of O)y("design-system",`slide ${m}: ${k}`)});let kr="decklight:video-export";function ds(){return er(kr,{})}async function Yr(){let w=await Gt.exportSources(),O=ds(),Q=(m,k,_)=>Math.max(0,m.findIndex(W=>W.value===(k??_)));jr.open({title:"export a video \u2014 which slides?",total:ye.state.totalSlides,slide:ye.state.slide,chapters:P.markers(),settings:[{key:"voice",name:"Voice",...w},{key:"format",name:"Format",options:Da,index:Q(Da,O.format,"mp4")},{key:"quality",name:"Quality",options:Ba,index:Q(Ba,O.quality,"standard")},{key:"subtitles",name:"Subtitles",options:Fa,index:Q(Fa,O.subtitles,"none")}],onPick:(m,{voice:k,format:_,quality:W,subtitles:he})=>{xr(kr,{format:_,quality:W,subtitles:he}),Xe.exportDeck("video",{slides:m,voice:k,format:_,quality:W,subtitles:he})}})}let _n="decklight:bundle-audio";async function Zr(){if(!xa(n.narration).length)return Xe.exportDeck("bundle");let w=await Xe.bundleEstimate();if(!w)return;if(!w.audio)return Xe.exportDeck("bundle");let{base:O,audio:Q}=w,m=W=>W<1048576?`${Math.max(1,Math.round(W/1024))} KB`:`${(W/1048576).toFixed(1)} MB`,k=Q.seconds==null?null:`${Math.floor(Q.seconds/60)}:${String(Math.round(Q.seconds%60)).padStart(2,"0")}`,_=Nn(_n);Sn.open({title:"bundle into one file \u2014 and the narration audio?",lines:[`${Q.files} recorded file${Q.files===1?"":"s"}${k?`, ${k} of voice`:""}, ${m(Q.bytes)} in ${Q.folders}`],rows:[{value:"none",label:"Leave it beside the deck",note:"send the folder with the file",figure:m(O)},{value:"original",label:"As recorded",note:"nothing lost",figure:m(O+Q.original)},{value:"aac",label:"AAC, mono 32 kbps",note:"plays in every browser",figure:Q.aac==null?"":`\u2248 ${m(O+Q.aac)}`,blocked:Q.aac==null?Q.why.aac:null},{value:"opus",label:"Opus, mono 24 kbps",note:"smallest, Safari from 17",figure:Q.opus==null?"":`\u2248 ${m(O+Q.opus)}`,blocked:Q.opus==null?Q.why.opus:null}],current:_??"aac",onPick:W=>{yn(_n,W),Xe.exportDeck("bundle",W==="none"?{}:{audio:W})}})}ye.restore=Xe.restore,ye.wizard=Xe.wizard;let gr=Md({root:E,instance:ye,toast:ce,editmode:Xe,debugLog:y}),On=Rd({root:E,instance:ye,editmode:Xe,authoring:gr,toast:ce,debugLog:y,toggleEditor:cs,cycleLayout:Rt,deckHistory:zr,enabled:()=>!s&&!t.has("embedded")&&!a});G=su({root:E,overlays:L,toast:ce,copyText:Er,concepts:()=>J?{names:()=>Ti(Tt,n.concepts??{}).map(w=>w.name),fill:w=>Cs(w,n.concepts??{}),set:(w,O)=>O!==null&&!/^[a-z][a-z0-9-]{0,40}$/i.test(O)?(ce("a concept is a name: letters, digits and dashes, starting with a letter",3200),null):J.attach([w],O)}:null,instance:()=>ye,stage:()=>Tt,editmode:()=>Xe,editbar:()=>On,review:()=>fr,narration:()=>Gt,sources:()=>d,brand:()=>({locked:V.brandLocked(),theme:V.currentTheme()})}),Xe.setInspectorOpener?.(()=>G?.open());function ir(w,O){let Q=getComputedStyle(w).display==="none";return Q&&w.classList.add("pin-measure"),zo(w,O),Q&&w.classList.remove("pin-measure"),w.hasAttribute("data-overflow")}let Vn=Lu({root:E,overlays:L,instance:()=>ye,goto:w=>ye.goto(w,0),measureOverflow:ir,slideTitle:(w,O)=>Ls(w,O,Si(w)),suggestions:()=>Bo(Tt),accept:()=>Xe?.available()&&J?w=>J.accept(w):null,agentFindings:()=>Xe?.reviewFindings?.()??[],fix:()=>Xe?.available()?w=>Xe.fixFinding(w):null});if(Xe.onReview?.(w=>{w.findings.length&&Qe&&(Qe=!1,Vn.open())}),ye.check=()=>Vn.check(),ye._deckCheck=Vn,ye._selection=()=>On.selected(),Xe.setInspect((w,O)=>{w?.node&&On.selectNode(w.node,{exact:!0}),G.open({tab:O})}),t.has("voiceover")&&Gt.status().hasTracks&&!s){let w=()=>{window.removeEventListener("pointerdown",w),window.removeEventListener("keydown",w),Gt.status().narrating||Gt.playDefault()};window.addEventListener("pointerdown",w,{once:!0}),window.addEventListener("keydown",w,{once:!0})}if(!s){let w=document.createElement("div");w.className="decklight-touch-controls",Un=document.createElement("button"),Un.type="button",Un.className="decklight-touch-btn",Un.setAttribute("aria-label","Fullscreen"),Un.innerHTML=sn.full,Un.addEventListener("click",_r),w.appendChild(Un),Gt.status().hasTracks&&(Gn=document.createElement("button"),Gn.type="button",Gn.className="decklight-touch-btn",Gn.addEventListener("pointerdown",O=>O.stopPropagation()),Gn.addEventListener("click",()=>Gt.playDefault()),w.appendChild(Gn),Ot()),E.appendChild(w)}if(ye.saveGeneratedTheme=w=>Te(w),s)return E.classList.add("decklight-print"),ye._sections.forEach((w,O)=>{w.classList.add("active"),As(ye._records[O],ye._records[O].groups.length),vo(w)}),c&&E.classList.add("decklight-show-hidden"),(h==="handout"||h==="notes")&&(E.classList.add("decklight-print-"+h),Zc(Tt,ye._sections.filter(w=>c||!w.hasAttribute("data-hidden")),h)),Vr(ye._sections),E.__decklight=ye,fo=ye,ye._emit("ready",{slides:ye.state.totalSlides,print:!0}),ye;let zn=n.hash&&Ua(location.hash)||{slide:1,step:0};return ye._sections.forEach((w,O)=>{O!==zn.slide-1&&As(ye._records[O],0)}),ye.goto(zn.slide,zn.step,{force:!0}),E.__decklight=ye,fo=ye,ye._emit("ready",{slides:ye.state.totalSlides}),Ie.start(zn),Xe.settled?.().then(()=>{Xe.available()&&Ie.startEditingTour(zn)}),ye}Se();Ae();Se();Ae();var Ka="\x1B",Ri=Object.freeze({fg:null,bg:null,bold:!1,dim:!1,italic:!1,underline:!1,inverse:!1});function Og(e){if(e<16)return null;if(e>=16&&e<=231){let n=e-16,s=[0,95,135,175,215,255];return[s[Math.floor(n/36)%6],s[Math.floor(n/6)%6],s[n%6]]}let t=8+(e-232)*10;return[t,t,t]}var go=class{constructor(){this.rows=[[]],this.row=0,this.col=0,this.style={...Ri},this._pending=""}write(t){let n=this._pending+t;this._pending="";let s=0;for(;s<n.length;){let a=n[s];if(a===Ka){let c=this._consumeEscape(n,s);if(c===0){this._pending=n.slice(s);return}s+=c;continue}if(s+=1,a===`
|
|
519
|
+
`){this._lineFeed();continue}if(a==="\r"){this.col=0;continue}if(a==="\b"){this.col=Math.max(0,this.col-1);continue}if(a===" "){this.col=(Math.floor(this.col/8)+1)*8;continue}a!=="\x07"&&(a<" "&&a!==" "||this._putChar(a))}}_lineFeed(){this.row+=1,this.rows[this.row]||(this.rows[this.row]=[])}_putChar(t){let n=this.rows[this.row];for(;n.length<this.col;)n.push({ch:" ",style:Ri});n[this.col]={ch:t,style:{...this.style}},this.col+=1}_consumeEscape(t,n){if(n+1>=t.length)return 0;let s=t[n+1];if(s==="["){let a=n+2;for(;a<t.length;){let c=t.charCodeAt(a);if(c>=64&&c<=126)return this._handleCsi(t.slice(n+2,a),t[a]),a-n+1;a+=1}return 0}if(s==="]"){let a=n+2;for(;a<t.length;){if(t[a]==="\x07")return a-n+1;if(t[a]===Ka&&t[a+1]==="\\")return a-n+2;if(t[a]===Ka&&a+1>=t.length)return 0;a+=1}return 0}return s==="("||s===")"?n+2<t.length?3:0:2}_handleCsi(t,n){if(!t.startsWith("?"))switch(n){case"m":this._sgr(t);return;case"K":this._eraseLine(t);return;case"C":this.col+=Math.max(1,parseInt(t||"1",10)||1);return;case"D":this.col=Math.max(0,this.col-Math.max(1,parseInt(t||"1",10)||1));return;default:return}}_eraseLine(t){let n=parseInt(t||"0",10)||0,s=this.rows[this.row];if(n===0){s.length=Math.min(s.length,this.col);return}if(n===1){for(let a=0;a<=Math.min(this.col,s.length-1);a++)s[a]={ch:" ",style:Ri};return}if(n===2){s.length=0;return}}_sgr(t){let n=t===""?[0]:t.split(";").map(a=>parseInt(a,10)||0),s=0;for(;s<n.length;){let a=n[s];if(a===0)this.style={...Ri};else if(a===1)this.style.bold=!0;else if(a===2)this.style.dim=!0;else if(a===3)this.style.italic=!0;else if(a===4)this.style.underline=!0;else if(a===7)this.style.inverse=!0;else if(a===22)this.style.bold=!1,this.style.dim=!1;else if(a===23)this.style.italic=!1;else if(a===24)this.style.underline=!1;else if(a===27)this.style.inverse=!1;else if(a>=30&&a<=37)this.style.fg={type:"ansi",idx:a-30};else if(a>=90&&a<=97)this.style.fg={type:"ansi",idx:a-90+8};else if(a===39)this.style.fg=null;else if(a>=40&&a<=47)this.style.bg={type:"ansi",idx:a-40};else if(a>=100&&a<=107)this.style.bg={type:"ansi",idx:a-100+8};else if(a===49)this.style.bg=null;else if(a===38||a===48){let c=a===38?"fg":"bg";n[s+1]===5&&n.length>s+2?(this.style[c]={type:"256",idx:n[s+2]},s+=2):n[s+1]===2&&n.length>s+4&&(this.style[c]={type:"rgb",r:n[s+2],g:n[s+3],b:n[s+4]},s+=4)}s+=1}}get lines(){return this.rows.map(t=>{let n=[];for(let s of t){let a=n[n.length-1];a&&Lg(a.style,s.style)?a.text+=s.ch:n.push({text:s.ch,style:s.style})}return n})}toHtml(){return this.lines.map(t=>Rg(t)).join(`
|
|
520
|
+
`)}};function Lg(e,t){return e.bold===t.bold&&e.dim===t.dim&&e.italic===t.italic&&e.underline===t.underline&&e.inverse===t.inverse&&Fu(e.fg,t.fg)&&Fu(e.bg,t.bg)}function Fu(e,t){return e===t?!0:!e||!t?!1:e.type===t.type&&e.idx===t.idx&&e.r===t.r&&e.g===t.g&&e.b===t.b}function Mg(e){if(e.type==="256"){if(e.idx<16)return null;let[t,n,s]=Og(e.idx);return`rgb(${t},${n},${s})`}return e.type==="rgb"?`rgb(${e.r},${e.g},${e.b})`:null}function Rg(e){return e.map(({text:t,style:n})=>{let s=[],a=[],{fg:c,bg:h}=n;n.inverse&&([c,h]=[h??{type:"inv-default-bg"},c??{type:"inv-default-fg"}]);for(let[y,$]of[[c,"fg"],[h,"bg"]])if(y)if(y.type==="ansi"||y.type==="256"&&y.idx<16)s.push(`ansi-${$}-${y.idx}`);else if(y.type==="inv-default-bg")s.push("ansi-inv-fg");else if(y.type==="inv-default-fg")s.push("ansi-inv-bg");else{let S=Mg(y);S&&a.push(`${$==="fg"?"color":"background-color"}:${S}`)}n.bold&&s.push("ansi-bold"),n.dim&&s.push("ansi-dim"),n.italic&&s.push("ansi-italic"),n.underline&&s.push("ansi-underline");let f=Et(t);if(!s.length&&!a.length)return f;let g=s.length?` class="${s.join(" ")}"`:"",b=a.length?` style="${a.join(";")}"`:"";return`<span${g}${b}>${f}</span>`}).join("")}var qu=24,Ig=e=>Math.max(1,Math.min(10,e)),Pg=e=>2**((e-5)/2.5),ju=55,Ko=[120,160],Hu="decklight-term-wpm:"+location.pathname,Dg=e=>Ko.reduce((t,n)=>Math.abs(n-e)<Math.abs(t-e)?n:t),Uo=["thocky","creamy","clacky","off"],zu="decklight-term-typesound:"+location.pathname,Uu="decklight-term-fontsize:"+location.pathname,Go=[.75,.9,1,1.15,1.35,1.6],Gu={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 Wa(e){let t=90+Math.random()*120;return Math.random()<.15&&(t+=Math.random()*240),e===" "?t+=70+Math.random()*220:".,:;/|&>-_=\"'`()".includes(e)&&(t+=40+Math.random()*140),Math.random()<.035&&(t+=300+Math.random()*440),t}var Bg=.012,tr=null,Ii=null,Di=new Set,Ku=e=>{Di.add(e),e.addEventListener("ended",()=>Di.delete(e),{once:!0})};function Fg(){if(!tr)return;let e=tr.currentTime;for(let t of Di)try{t.stop(e)}catch{}Di.clear()}function Pi(e="",t="thocky",n=.12){try{let s=window.AudioContext||window.webkitAudioContext;if(!s)return;if(tr??=new s,tr.state==="suspended"&&tr.resume(),!Ii){let L=Math.floor(tr.sampleRate*.06);Ii=tr.createBuffer(1,L,tr.sampleRate);let P=Ii.getChannelData(0);for(let j=0;j<L;j++)P[j]=Math.random()*2-1}let a=Gu[t]??Gu.thocky,c=(L,P)=>L+Math.random()*(P-L),h=tr.currentTime+Bg,f=e===" ",g=c(.45,1.3)*(f?1.25:1),b=c(...a.clickF)*(f?.7:1),y=c(...a.ring)*(f?1.5:1),$=(L,P,j,U)=>{let oe=tr.createBufferSource();oe.buffer=Ii;let pe=tr.createBiquadFilter();pe.type="bandpass",pe.frequency.value=j,pe.Q.value=a.clickQ;let D=tr.createBiquadFilter();D.type="lowpass",D.frequency.value=a.lp;let z=tr.createGain();z.gain.setValueAtTime(1e-4,L),z.gain.exponentialRampToValueAtTime(P,L+7e-4),z.gain.exponentialRampToValueAtTime(1e-4,L+U),oe.connect(pe),pe.connect(D),D.connect(z),z.connect(tr.destination),oe.start(L),oe.stop(L+U+.01),Ku(oe)},S=(L,P,j,U)=>{let oe=tr.createOscillator();oe.type="sine",oe.frequency.setValueAtTime(j,L),oe.frequency.exponentialRampToValueAtTime(j*.6,L+U*.6);let pe=tr.createGain();pe.gain.setValueAtTime(1e-4,L),pe.gain.exponentialRampToValueAtTime(P,L+c(.003,.011)),pe.gain.exponentialRampToValueAtTime(P*.25,L+U),pe.gain.exponentialRampToValueAtTime(1e-4,L+U*2),oe.connect(pe),pe.connect(tr.destination),oe.start(L),oe.stop(L+U*2+.01),Ku(oe)},A=a.thumpF2&&Math.random()<(a.thumpF2Prob??.4)?a.thumpF2:a.thumpF;$(h,a.click*g*(f?.82:1),b,c(...a.clickDecay)*(f?1.2:1)),S(h,a.thump*g*(f?2.4:1),c(...A)*(f?.7:1),y);let E=h+Math.max(.01,Math.min(c(.035,.08),n*.55));$(E,a.click*g*c(.35,.55),b*1.15,c(...a.clickDecay)*.8),S(E,a.thump*g*(f?.5:.25),c(...A)*(f?.7:1),y*.6)}catch{}}function qg(){try{let e=window.AudioContext||window.webkitAudioContext;if(!e)return;tr??=new e,tr.state==="suspended"&&tr.resume()}catch{}}var Wu=!1;function jg(){if(Wu||typeof document>"u")return;Wu=!0;let e=()=>{qg(),document.removeEventListener("pointerdown",e,!0),document.removeEventListener("keydown",e,!0)};document.addEventListener("pointerdown",e,!0),document.addEventListener("keydown",e,!0)}function Ja(e,t=document){let n=[...t.querySelectorAll(".terminal[data-cast], .terminal[data-cast-inline]")];return n.length&&jg(),Promise.all(n.map(s=>Hg(s,e).catch(a=>{Kg(s,a)})))}async function Hg(e,t){if(e.dataset.decklightTerminal)return;e.dataset.decklightTerminal="1";let n,s,a=e.dataset.castInline;if(a){s=a;let g=document.querySelector(a);if(!g&&document.readyState==="loading"&&(await new Promise(b=>document.addEventListener("DOMContentLoaded",b,{once:!0})),g=document.querySelector(a)),!g)throw new Error(`inline cast not found: ${a}`);n=g.textContent}else{s=e.dataset.cast;let g=await fetch(s);if(!g.ok)throw new Error(`failed to load cast: ${s} (${g.status})`);n=await g.text()}let c=zg(n,s),h=new Va(e,c);e._decklightTerminal=h;let f=e.dataset.mode||"step";c.imported&&f==="step"&&!c.hasMarkers&&(f="play"),f==="play"?h.mountPlayMode():h.mountStepMode(t)}function zg(e,t){let n=null;try{n=JSON.parse(e)}catch{}if(n){if(n.decklightCast===1&&Array.isArray(n.steps))return n;throw new Error(`not a decklight cast (v1): ${t}`)}return Ug(e,t)}function Ug(e,t){let n=e.split(`
|
|
521
|
+
`).filter(g=>g.trim()),s;try{s=JSON.parse(n[0])}catch{s=null}if(!s||s.version!==2)throw new Error(`not a decklight cast or asciicast v2: ${t}`);let a=[],c={cmd:"",raw:!0,output:[]},h=0,f=!1;for(let g of n.slice(1)){let b;try{b=JSON.parse(g)}catch{continue}if(!Array.isArray(b)||b.length<3)continue;let[y,$,S]=b;$==="m"?(f=!0,c.output.length&&a.push(c),c={cmd:String(S||""),raw:!0,output:[]},h=y):$==="o"&&c.output.push([Math.max(0,Gg(y-h)),S])}if(c.output.length&&a.push(c),!a.length)throw new Error(`asciicast has no output events: ${t}`);return{decklightCast:1,imported:!0,hasMarkers:f,meta:{cols:s.width||100,rows:s.height||28,prompt:""},steps:a}}function Gg(e){return Math.round(e*1e3)/1e3}function Kg(e,t){e.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 ${Et(String(t.message||t))}</pre></div></div>`}var Va=class{constructor(t,n){this.el=t,this.cast=n,this.prompt=n.meta.prompt??"$ ";let s=Ig(parseInt(t.dataset.typeSpeed??"5",10)||5);this.typeWpm=Dg(ju*Pg(s));try{let c=parseInt(localStorage.getItem(Hu)??"",10);Ko.includes(c)&&(this.typeWpm=c)}catch{}t.dataset.typeWpm=String(this.typeWpm),this.fontIdx=Go.indexOf(1);try{let c=parseInt(localStorage.getItem(Uu)??"",10);c>=0&&c<Go.length&&(this.fontIdx=c)}catch{}this._applyFont();let a=(t.dataset.typeSound||"thocky").toLowerCase();this.soundName=Uo.includes(a)?a:"thocky";try{let c=localStorage.getItem(zu);c&&Uo.includes(c)&&(this.soundName=c)}catch{}this.typeSound=this.soundName==="off"?null:this.soundName,this.maxStep=(parseFloat(t.dataset.maxStep||"2.5")||2.5)*1e3,this.visibleRows=parseInt(t.dataset.rows||"",10)||Math.min(n.meta.rows||qu,qu),this.epoch=0,this.applied=0,this.playable=n.steps.filter(c=>!c.hidden&&c.sleep==null),this._mountChrome(),this._watchSlide()}stop(){if(this.epoch+=1,Fg(),this.playing){this.playing=!1;let t=this.controlsEl?.querySelector(".terminal-play");t&&(t.textContent="\u25B6")}}_watchSlide(){let t=this.el.closest("section");if(!t||typeof MutationObserver!="function")return;new MutationObserver(()=>{t.classList.contains("active")||this.stop()}).observe(t,{attributes:!0,attributeFilter:["class"]})}_mountChrome(){let t=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">${Et(t)}</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(t,{withCursor:n=!0}={}){let s=[];for(let a=0;a<t;a++)s.push(this._stepHtml(this.playable[a]));n&&!this.cast.imported&&s.push(this._promptHtml()+'<span class="terminal-cursor"></span>'),this.linesEl.innerHTML=s.join(`
|
|
522
|
+
`),this._scrollToEnd()}_stepEvents(t){return[...(t.output||[]).map(([n,s])=>({t:n,kind:"o",d:s})),...(t.input||[]).map(([n,s])=>({t:n,kind:"i",d:s.replace(/\r?\n$/,"")}))].sort((n,s)=>n.t-s.t)}_stepHtml(t){let n=new go;for(let a of this._stepEvents(t))n.write(a.d);let s=n.toHtml();return t.raw?s:this._promptHtml()+`<span class="terminal-cmd">${Et(t.cmd)}</span>`+(s?`
|
|
523
|
+
`+s:"")}_promptHtml(){return`<span class="terminal-prompt">${Et(this.prompt)}</span>`}_scrollToEnd(){this.screenEl.scrollTop=this.screenEl.scrollHeight}_applyFont(){let t=Go[this.fontIdx];this.el.style.fontSize=t===1?"":`${t}em`}_mountFontButton(){let t=document.createElement("button");t.className="terminal-btn terminal-fontsize",t.title="font size: click cycles 75% to 160%",t.setAttribute("aria-label","font size");let n=()=>{t.textContent=`A ${Math.round(Go[this.fontIdx]*100)}%`};n(),t.addEventListener("click",()=>{this.fontIdx=(this.fontIdx+1)%Go.length,this._applyFont();try{localStorage.setItem(Uu,String(this.fontIdx))}catch{}n()}),this.controlsEl.appendChild(t)}_mountSpeedButton(){let t=document.createElement("button");t.className="terminal-btn terminal-typespeed",t.title="typing speed: click cycles words per minute",t.setAttribute("aria-label","typing speed");let n=()=>{t.textContent=`\u2328 ${this.typeWpm} wpm`};n(),t.addEventListener("click",()=>{let s=(Ko.indexOf(this.typeWpm)+1)%Ko.length;this.typeWpm=Ko[s],this.el.dataset.typeWpm=String(this.typeWpm);try{localStorage.setItem(Hu,String(this.typeWpm))}catch{}n()}),this.controlsEl.appendChild(t)}_mountSoundButton(){let t=document.createElement("button");t.className="terminal-btn terminal-typesound",t.title="key sound: click cycles thocky, creamy, clacky, off",t.setAttribute("aria-label","key sound");let n=()=>{t.textContent=`\u266A ${this.soundName}`};n(),t.addEventListener("click",()=>{let s=(Uo.indexOf(this.soundName)+1)%Uo.length;this.soundName=Uo[s],this.typeSound=this.soundName==="off"?null:this.soundName,this.el.dataset.typeSound=this.soundName;try{localStorage.setItem(zu,this.soundName)}catch{}this.typeSound&&Pi("a",this.typeSound,.12),n()}),this.controlsEl.appendChild(t)}_typeFactor(t,n=!1){return(n&&this.speed||1)*(this.typeWpm/ju)*(t.typeSpeed||1)}async _typeCmd(t,n,s,a,c=!1){for(let h=1;h<=t.length;h++){if(this.epoch!==a)return!1;let f=t[h-1],g=Wa(f)/this._typeFactor(s,c);this.typeSound&&Pi(f,this.typeSound,g/1e3),this.linesEl.innerHTML=n+this._promptHtml()+`<span class="terminal-cmd">${Et(t.slice(0,h))}</span><span class="terminal-cursor"></span>`,this._scrollToEnd(),await Is(g)}return!0}mountStepMode(t){this.controlsEl.innerHTML="",this._mountSpeedButton(),this._mountSoundButton(),this._mountFontButton();let n=this.playable,s=Math.min(Math.max(parseInt(this.el.dataset.poster||"0",10)||0,0),n.length);if(this.applied=s,this._renderComplete(s),!t||typeof t.registerBuildProvider!="function"){this._renderComplete(n.length,{withCursor:!1});return}t.registerBuildProvider(this.el,{count:n.length-s,label:a=>n[s+a]?`${this.prompt}${n[s+a].cmd||"\u25B6 recording"}`:"",apply:a=>this.applyStep(s+Math.max(0,Math.min(a,n.length-s)))})}applyStep(t){this.epoch+=1;let n=t===this.applied+1;if(this.applied=t,!n){this._renderComplete(t);return}this._animateStep(t-1,this.epoch)}async _animateStep(t,n){let s=this.playable[t],a=[];for(let A=0;A<t;A++)a.push(this._stepHtml(this.playable[A]));let c=a.length?a.join(`
|
|
427
524
|
`)+`
|
|
428
|
-
`:"",
|
|
429
|
-
`+A:""),this._scrollToEnd()},
|
|
525
|
+
`:"",h=s.cmd||"";if(!s.raw){if(!await this._typeCmd(h,c,s,n))return;await Is(120/this._typeFactor(s))}let f=this._stepEvents(s),g=f.length?f[f.length-1].t*1e3:0,b=g>this.maxStep?this.maxStep/g:1,y=new go,$=()=>{let A=y.toHtml();this.linesEl.innerHTML=s.raw?c+A:c+this._promptHtml()+`<span class="terminal-cmd">${Et(h)}</span>`+(A?`
|
|
526
|
+
`+A:""),this._scrollToEnd()},S=0;for(let A of f){let E=Math.min((A.t-S)*1e3*b,400);if(S=A.t,E>8&&await Is(E),this.epoch!==n)return;if(A.kind==="i")for(let L of A.d){if(this.epoch!==n)return;let P=Wa(L)/this._typeFactor(s);this.typeSound&&Pi(L,this.typeSound,P/1e3),y.write(L),$(),await Is(P)}else y.write(A.d),$()}this.epoch===n&&this._renderComplete(t+1)}mountPlayMode(){let t=[1,2,4],n=parseFloat(this.el.dataset.speed);this.speed=t.includes(n)?n: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 s=this.controlsEl.querySelector(".terminal-play"),a=this.controlsEl.querySelector(".terminal-speed");this.controlsEl.querySelector(".terminal-restart").addEventListener("click",()=>this._restart(s)),a.addEventListener("click",()=>{this.speed=this.speed>=4?1:this.speed*2,a.textContent=`${this.speed}\xD7`}),s.addEventListener("click",()=>{this.playing?this.stop():(s.textContent="\u23F8",this._playAll(s))}),this._renderComplete(0)}_restart(t){this.stop(),t.textContent="\u25B6",this._playedUpTo=0,this._renderComplete(0)}async _playAll(t){this.playing=!0;let n=++this.epoch,s=this._playedUpTo||0;for(let a=s;a<this.cast.steps.length;a++){let c=this.cast.steps[a];if(c.hidden){this._playedUpTo=a+1;continue}if(c.sleep!=null){if(await Is(c.sleep*1e3/this.speed),this.epoch!==n){this._playedUpTo=a;return}this._playedUpTo=a+1;continue}let f=this.cast.steps.slice(0,a).filter(A=>!A.hidden&&A.sleep==null).map(A=>this._stepHtml(A)),g=f.length?f.join(`
|
|
430
527
|
`)+`
|
|
431
|
-
`:"",
|
|
432
|
-
`+A:""),this._scrollToEnd()},
|
|
528
|
+
`:"",b=c.cmd||"";if(!c.raw&&!await this._typeCmd(b,g,c,n,!0)){this._playedUpTo=a;return}let y=new go,$=()=>{let A=y.toHtml();this.linesEl.innerHTML=c.raw?g+A:g+this._promptHtml()+`<span class="terminal-cmd">${Et(b)}</span>`+(A?`
|
|
529
|
+
`+A:""),this._scrollToEnd()},S=0;for(let A of this._stepEvents(c)){let E=(A.t-S)*1e3/this.speed;if(S=A.t,E>4&&await Is(E),this.epoch!==n){this._playedUpTo=a;return}if(A.kind==="i")for(let L of A.d){if(this.epoch!==n){this._playedUpTo=a;return}let P=Wa(L)/this._typeFactor(c,!0);this.typeSound&&Pi(L,this.typeSound,P/1e3),y.write(L),$(),await Is(P)}else y.write(A.d),$()}await Is(350/this.speed),this._playedUpTo=a+1}this.playing=!1,t.textContent="\u25B6",this._playedUpTo=0,this._renderComplete(this.playable.length,{withCursor:!0})}};function Is(e){return new Promise(t=>setTimeout(t,e))}var Vg="0.9.0";var Ju=()=>typeof Ja=="function"?Ja:null;function Yu(){let e=document.querySelector('script[type="application/json"][data-decklight-config]');if(!e)return null;try{let{decklight:t,theme:n,...s}=JSON.parse(e.textContent);return typeof n=="string"&&/^[\w-]+$/.test(n)?{...s,theme:n}:s}catch(t){return console.error("Decklight: the data-decklight-config block is not valid JSON \u2014 booting with defaults",t),{}}}function Zu(e){let t=Bu(e??Yu()??{}),n=Ju();return n&&Promise.resolve(n({registerBuildProvider:mo},document)).catch(s=>console.error("Decklight: terminal subsystem failed to initialize",s)),t}function Jg(e=document){let t=Ju();return t?Promise.resolve(t({registerBuildProvider:mo},e)):Promise.resolve()}function Vu(){let e=document.querySelector(".decklight");if(!(!e||e.__decklight||!document.querySelector('script[type="application/json"][data-decklight-config]')&&[...document.scripts].some(n=>!n.src&&/Decklight\s*\.\s*init\s*\(/.test(n.textContent))))try{Zu()}catch(n){console.error("Decklight: the deck did not boot",n)}}typeof document<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Vu):Vu());return ip(Yg);})();
|
|
433
530
|
//# sourceMappingURL=decklight.js.map
|