@textadventures/quest-viva-wasmplayer 6.1.2 → 6.2.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/_framework/Common.wasm +0 -0
  2. package/_framework/Engine.wasm +0 -0
  3. package/_framework/ExtendedNumerics.BigDecimal.wasm +0 -0
  4. package/_framework/Legacy.wasm +0 -0
  5. package/_framework/Microsoft.Extensions.Logging.Abstractions.wasm +0 -0
  6. package/_framework/NCalc.Core.wasm +0 -0
  7. package/_framework/NCalc.Domain.wasm +0 -0
  8. package/_framework/NCalc.Parser.wasm +0 -0
  9. package/_framework/Parlot.wasm +0 -0
  10. package/_framework/PlayerCore.wasm +0 -0
  11. package/_framework/System.Collections.Immutable.wasm +0 -0
  12. package/_framework/System.Collections.wasm +0 -0
  13. package/_framework/System.Linq.wasm +0 -0
  14. package/_framework/System.Net.Http.wasm +0 -0
  15. package/_framework/System.Private.CoreLib.wasm +0 -0
  16. package/_framework/System.Private.Xml.Linq.wasm +0 -0
  17. package/_framework/System.Private.Xml.wasm +0 -0
  18. package/_framework/System.Runtime.Numerics.wasm +0 -0
  19. package/_framework/System.Text.Json.wasm +0 -0
  20. package/_framework/System.Text.RegularExpressions.wasm +0 -0
  21. package/_framework/WasmPlayer.wasm +0 -0
  22. package/_framework/dotnet.js +40 -46
  23. package/_framework/dotnet.native.wasm +0 -0
  24. package/chrome.css +1 -1
  25. package/export-manifest.json +1 -1
  26. package/game-saver.js +5 -1
  27. package/gamepad.js +668 -0
  28. package/index.html +53 -11
  29. package/legacy/adapter.js +1 -0
  30. package/legacy/grid.js +4 -0
  31. package/legacy/playercore.js +8 -1
  32. package/legacy/questui.js +5 -1
  33. package/package.json +1 -1
  34. package/v2/map.js +1 -1
  35. package/v2/v2.css +1 -1
  36. package/v2/v2.js +1 -1
  37. package/wasm-player.js +226 -21
  38. package/_framework/System.Linq.Expressions.wasm +0 -0
package/v2/v2.js CHANGED
@@ -1 +1 @@
1
- "use strict";(()=>{var s={autoScroll:!0,warnedAboutScript:!1,animateScroll:!0,fadePreviousOutput:!1,continueOnClick:!1,commandPlaceholder:null,compassDirections:[],interfaceStrings:new Map,gameFinished:!1,soundWait:!1,waiting:!1,pausing:!1,inDialog:!1,turnPending:!0,hasUnsavedProgress:!1,canSave:!1},V=new Map;function Xt(e,t){if(typeof t!="function")return;let n=V.get(e);n||V.set(e,n=new Set),n.add(t)}function te(e,t){V.get(e)?.delete(t)}function y(e,t){for(let n of V.get(e)??[])try{n(t)}catch(o){console.error(o)}}function ee(){s.autoScroll=!0,s.warnedAboutScript=!1,s.fadePreviousOutput=!1,s.continueOnClick=!1,s.commandPlaceholder=null,s.interfaceStrings.clear(),s.compassDirections=[],s.gameFinished=!1,s.soundWait=!1,s.waiting=!1,s.pausing=!1,s.inDialog=!1,s.turnPending=!0,s.hasUnsavedProgress=!1,V.clear()}var wn={inventory:"inventoryChanged",objects:"objectsChanged",exits:"exitsChanged",status:"statusChanged"},nt={inventory:[],objects:[],exits:[],status:[]},wt=new Set;function ne(){return structuredClone(nt)}function oe(){nt={inventory:[],objects:[],exits:[],status:[]},wt.clear()}function P(e,t){if(wt.has(e)&&JSON.stringify(t)===JSON.stringify(nt[e]))return;wt.add(e),nt[e]=t;let n=structuredClone(t);y(wn[e],e==="exits"?{exits:n}:{items:n})}function re(e){return{text:String(e.Text??""),name:String(e.ElementName??""),elementId:String(e.ElementId??""),verbs:(e.Verbs??[]).map(String)}}var C=typeof HTMLElement.prototype.showPopover=="function";function H(e){for(let t of e.querySelectorAll("a.cmdlink, a[data-qv-event]"))t.hasAttribute("tabindex")||(t.tabIndex=0),t.setAttribute("role","button"),t.classList.contains("elementmenu")&&(t.setAttribute("aria-haspopup","menu"),t.setAttribute("aria-expanded","false")),t.toggleAttribute("aria-disabled",t.classList.contains("disabled"));for(let t of e.querySelectorAll("[data-qv-popup]"))t.setAttribute("aria-controls",t.dataset.qvPopup??""),t.setAttribute("aria-expanded","false")}function ie(e){for(let t of e.querySelectorAll("[data-qv-popup-content].qv-popup-open"))t.classList.remove("qv-popup-open");for(let t of e.querySelectorAll('[aria-expanded="true"]'))t.setAttribute("aria-expanded","false")}function M(e,t){e.classList.toggle("disabled",!t),t?e.removeAttribute("aria-disabled"):e.setAttribute("aria-disabled","true")}var k=e=>e.classList.contains("disabled");function xt(e){e.setAttribute("data-qv-deactivated",""),M(e,!1)}function se(e){return Array.isArray(e)?e.map(String):[]}function ae(e,t,n){if(t==="object"){let o=n&&typeof n=="object"?n:{};for(let r of e.querySelectorAll("a.elementmenu")){let i=o[r.dataset.elementid??""];i&&(r.dataset.verbs=String(i)),M(r,!!i)}}else if(t==="exit"){let o=se(n);for(let r of e.querySelectorAll("a.exitlink"))M(r,o.includes(r.dataset.elementid??""))}else if(t==="command"){let o=se(n);for(let r of e.querySelectorAll("a.commandlink:not([data-qv-deactivated])")){let i=r.dataset.elementid??"";M(r,i===""||o.includes(i))}}}function le(e,t,n){let o=document.getElementById(e);o&&(o.classList.add("cmdlink","elementmenu"),o.dataset.verbs=t,o.dataset.elementid||(o.dataset.elementid=n),H(o.parentElement??o))}function ce(e,t){let n=e.target instanceof Element?e.target:null;if(!n)return;let o=n.closest("[data-qv-popup]");if(o){e.preventDefault(),Mn(o);return}let r=n.closest("[data-qv-direction]");if(r){r.disabled||v(r.dataset.qvDirection??"");return}let i=n.closest(".qv-pane-verb");if(i){pe(i);return}let l=n.closest(".qv-pane-item");if(l){me(l);return}let c=n.closest("[data-qv-popup-content]");c&&de(c);let u=n.closest("a");u&&(u.matches(".cmdlink, [data-qv-event]")?qn(e,u,t):u.hasAttribute("href")&&xn(e,u))}function qn(e,t,n){if(t.dataset.qvEvent!==void 0){if(e.preventDefault(),k(t))return;if(t.dataset.qvEvent==="ShowMenuResponse")for(let o of t.ownerDocument.querySelectorAll('a[data-qv-event="ShowMenuResponse"]'))M(o,!1);L(t.dataset.qvEvent,t.dataset.qvParam??"")}else if(t.classList.contains("elementmenu"))e.preventDefault(),k(t)||n?.toggle(t);else if(t.classList.contains("exitlink"))e.preventDefault(),k(t)||v(t.dataset.command??"");else if(t.classList.contains("commandlink")){if(e.preventDefault(),k(t)||!Q())return;t.dataset.deactivateonclick==="true"&&xt(t),v(t.dataset.command??"")}}function xn(e,t){let n=t.getAttribute("href")??"";n.startsWith("#")||/^\s*javascript:/i.test(n)||(e.preventDefault(),window.open(t.href,"_blank","noopener"))}function ue(e){if(e.key!=="Enter"&&e.key!==" ")return;let t=e.target instanceof HTMLAnchorElement?e.target:null;t?.matches(".cmdlink, [data-qv-event]")&&(e.preventDefault(),t.click())}function Tn(e){let t=document.getElementById(e.dataset.qvPopup??"");return t?.hasAttribute("data-qv-popup-content")?t:null}function Mn(e){let t=Tn(e);if(t){if(t.classList.contains("qv-popup-open")){de(t);return}C&&!t.popover&&(t.popover="auto",t.addEventListener("beforetoggle",n=>{n.newState==="closed"&&qt(t,!1)})),qt(t,!0),C&&t.showPopover()}}function de(e){C&&e.matches(":popover-open")&&e.hidePopover(),qt(e,!1)}function qt(e,t){e.classList.toggle("qv-popup-open",t);for(let n of document.querySelectorAll(`[data-qv-popup="${CSS.escape(e.id)}"]`))n.setAttribute("aria-expanded",String(t))}var Mt=["inventory","objects","status","compass","commands","customstatus"],Cn={InventoryLabel:"inventory",PlacesObjectsLabel:"objects",StatusLabel:"status",CompassLabel:"compass"},ot=class extends HTMLElement{#e;#t;#n;connectedCallback(){this.#e||(this.dataset.qvPart="pane",this.#e=document.createElement("details"),this.#e.open=!0,this.#t=document.createElement("summary"),this.#t.className="qv-pane-heading",this.#t.textContent=this.getAttribute("label")??"",this.#n=document.createElement("div"),this.#n.className="qv-pane-body",this.#n.append(...this.childNodes),this.#e.append(this.#t,this.#n),this.append(this.#e))}get name(){return this.dataset.qvPane??""}get body(){return this.#n}setLabel(t){this.#t.innerHTML=t}setContent(t){this.#n.innerHTML=t,H(this.#n)}};function f(e){return a()?.querySelector(`qv-pane[data-qv-pane="${CSS.escape(e)}"]`)??null}var An={inventory:"inventory",placesobjects:"objects"};function he(e,t){let n=An[e];if(!n)return;let o=new Set(s.compassDirections),r=Object.values(t).map(u=>JSON.parse(u)).filter(u=>e!=="placesobjects"||!o.has(u.Text));P(n,r.map(re));let i=f(n);if(!i)return;let l=I.get(n);l!==void 0&&!r.some(u=>Tt(u)===l)&&I.delete(n);let c=document.createElement("ul");if(c.className="qv-pane-list",r.forEach((u,d)=>c.append(Pn(n,u,`qv-${n}-verbs-${d}`))),c.childElementCount)i.body.replaceChildren(c);else{let u=document.createElement("p");u.className="qv-pane-empty",u.innerHTML=s.interfaceStrings.get(n==="inventory"?"InventoryEmptyLabel":"PlacesObjectsEmptyLabel")??s.interfaceStrings.get("EmptyListLabel")??"",i.body.replaceChildren(u)}a()?.verbMenu?.closeIfStale()}var I=new Map,Tt=e=>e.ElementId||e.ElementName;function ve(){I.clear()}function Pn(e,t,n){let o=document.createElement("li"),r=document.createElement("button");r.type="button",r.className="qv-pane-item",r.innerHTML=t.Text,r.dataset.qvKey=Tt(t),o.append(r);let i=(t.Verbs??[]).map(String).map(u=>u.trim()).filter(Boolean);if(!i.length)return o;let l=document.createElement("div");l.id=n,l.className="qv-pane-verbs",l.setAttribute("role","group"),l.setAttribute("aria-label",r.textContent?.trim()??"");for(let u of i){let d=document.createElement("button");d.type="button",d.className="qv-pane-verb",d.textContent=u,d.dataset.command=`${u.toLowerCase()} ${t.ElementName}`,d.dataset.qvName=t.ElementName,t.ElementId&&(d.dataset.elementid=t.ElementId),l.append(d)}let c=I.get(e)===Tt(t);return l.hidden=!c,r.setAttribute("aria-expanded",String(c)),r.setAttribute("aria-controls",n),o.append(l),o}function me(e){let t=e.closest("qv-pane"),n=e.nextElementSibling;if(!t||!n?.classList.contains("qv-pane-verbs"))return;let o=n.hidden;for(let r of t.body.querySelectorAll('.qv-pane-item[aria-expanded="true"]'))r.setAttribute("aria-expanded","false"),r.nextElementSibling.hidden=!0;o?(n.hidden=!1,e.setAttribute("aria-expanded","true"),I.set(t.name,e.dataset.qvKey??""),n.scrollIntoView({block:"nearest"})):I.delete(t.name)}function pe(e){let t=e.dataset.qvName??"",n={};e.dataset.elementid&&(n[t]=e.dataset.elementid),v(e.dataset.command??"",n)}function ge(e){let t=f("commands");if(!t)return;let o=(Array.isArray(e)?e.map(String):String(e??"").split(";")).filter(r=>r.trim()).map(r=>{let[i,l]=r.split(":"),c=u=>u.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;");return`<a class="cmdlink commandlink" data-elementid="" data-command="${c((l??i).trim().toLowerCase())}">${c(i.trim())}</a>`}).join(" ");t.setContent(o)}function be(e,t){e==="map"||e!=="customstatus"&&Mt.includes(e)||f(e)?.setContent(t)}function ye(e,t,n){let o=a()?.panes;if(!e||e==="map"||!o||f(e))return;let r=document.createElement("qv-pane");r.dataset.qvPane=e,r.setAttribute("label",t??e),o.append(r),r.setContent(n??"")}function Se(e){let t=a()?.panes;if(!t)return;let n=Array.isArray(e)?e.map(String):String(e??"").split(";");for(let o of[...n].reverse()){let r=f(o);r&&t.prepend(r)}}function Ee(e,t){let n=Cn[e];return n?(f(n)?.setLabel(t),!0):!1}function rt(){return!!a()?.panes?.classList.contains("qv-drawer-open")}function w(e,{restoreFocus:t=!0}={}){let n=a(),o=n?.panes,r=n?.panesButton;!o||!r||e===rt()||(o.classList.toggle("qv-drawer-open",e),r.setAttribute("aria-expanded",String(e)),e?(document.addEventListener("pointerdown",fe,!0),o.querySelector('summary, button, a[href], [tabindex="0"]')?.focus()):(document.removeEventListener("pointerdown",fe,!0),t&&o.contains(document.activeElement)&&r.focus()))}function fe(e){let t=a(),n=e.target instanceof Node?e.target:null;!n||t?.panes?.contains(n)||t?.panesButton?.contains(n)||t?.verbMenu?.contains(n)||w(!1,{restoreFocus:!1})}var kn=["northwest","north","northeast","west","east","southwest","south","southeast","up","down","in","out"],we=[315,0,45,270,90,225,180,135,null,null,null,null],Le="http://www.w3.org/2000/svg",Ct=[[1,1],[1,2],[1,3],[2,1],[2,3],[3,1],[3,2],[3,3]],W=[];function st(){return s.compassDirections.length===12?s.compassDirections:kn}function qe(e){let t=st()[e];return e===10?At(s.interfaceStrings.get("InButtonLabel"))||t:e===11&&At(s.interfaceStrings.get("OutButtonLabel"))||t}function At(e){if(!e)return"";let t=document.createElement("template");return t.innerHTML=e,t.content.textContent?.trim()??""}function xe(e,t){let n=st()[e],o=document.createElement("button");o.type="button",o.className=t,o.dataset.qvDirection=n;let r=we[e];return r!=null&&o.append(Hn(r)),o}function Hn(e){let t=document.createElementNS(Le,"svg");t.setAttribute("class","qv-direction-arrow"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("aria-hidden","true"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","2"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round");let n=document.createElementNS(Le,"path");return n.setAttribute("d","M12 19V5M5 12l7-7 7 7"),n.setAttribute("transform",`rotate(${e} 12 12)`),t.append(n),t}function B(){let e=f("compass");if(e){let t=document.createElement("div");t.className="qv-compass-points";let n=document.createElement("div");n.className="qv-compass-others",st().forEach((r,i)=>{let l=xe(i,"qv-compass-button"),c=qe(i);l.setAttribute("aria-label",c),l.title=c,we[i]==null&&l.append(c),l.disabled=!W.includes(r),Ct[i]?(l.style.gridRow=String(Ct[i][0]),l.style.gridColumn=String(Ct[i][1]),t.append(l)):n.append(l)});let o=document.createElement("div");o.className="qv-compass",o.append(t,n),e.body.replaceChildren(o)}h()}function Te(e){W=String(e??"").split("/").filter(Boolean),P("exits",[...W]),B()}function Me(){W=[]}function h(){let e=a(),t=e?.exits;if(!e||!t)return;let n=f("compass"),o=!!n&&!n.hidden&&!e.panes?.hidden,r=!s.turnPending&&!s.waiting&&!s.pausing&&!s.inDialog&&!s.gameFinished,i=[];o&&r&&st().forEach((l,c)=>{if(!W.includes(l))return;let u=xe(c,"qv-exit");u.append(qe(c)),i.push(u)}),t.replaceChildren(...i),t.setAttribute("aria-label",At(s.interfaceStrings.get("CompassLabel"))||(WebPlayer.chromeStrings?.CompassLabel??"Compass")),t.classList.toggle("qv-exits-active",i.length>0)}var N=[];function Pt(e){N=Array.isArray(e)?e.filter(t=>t&&typeof t=="object"):[],P("status",N),kt()}function Ce(e){Pt(String(e??"").split(/\r?\n|<br\s*\/?>/i).filter(t=>t.trim()).map(t=>({text:t})))}function Ae(){N=[]}function In(e){let t=Number(e.value),n=Number(e.max);return e.value==null||e.max==null||!Number.isFinite(t)||!Number.isFinite(n)||n<=0?null:{value:Math.min(Math.max(t,0),n),max:n}}var Bn=0;function Pe(e,t){let n=document.createElement(t);n.className="qv-status-item",e.name&&(n.dataset.qvStatus=String(e.name));let o=document.createElement("span");o.className="qv-status-text",o.id=`qv-status-${++Bn}`,o.innerHTML=String(e.text??""),n.append(o);let r=In(e);if(r){let i=document.createElement("span");i.className="qv-status-meter",i.setAttribute("role","meter"),i.setAttribute("aria-valuemin","0"),i.setAttribute("aria-valuemax",String(r.max)),i.setAttribute("aria-valuenow",String(r.value)),i.setAttribute("aria-labelledby",o.id);let l=document.createElement("span");l.className="qv-status-meter-fill",l.style.width=`${r.value/r.max*100}%`,i.append(l),n.append(i)}return n}function kt(){let e=f("status");if(e){let t=document.createElement("ul");t.className="qv-status-list",t.append(...N.map(n=>Pe(n,"li"))),e.body.replaceChildren(t),e.toggleAttribute("data-qv-empty",N.length===0)}it()}function it(){let e=a(),t=e?.statusBar;if(!e||!t)return;let n=f("status"),r=!!n&&!n.hidden&&!e.panes?.hidden?N.filter(i=>i.pinned):[];t.replaceChildren(...r.map(i=>Pe(i,"span"))),t.classList.toggle("qv-status-bar-active",r.length>0),e.updateTopbar()}var at=document.currentScript instanceof HTMLScriptElement?document.currentScript.src:"",Ht=null,D=null,lt=null,j=[],ct=0,It=!0,z=!1,Bt="header",$=(e,t)=>WebPlayer.chromeStrings?.[e]??t,Nn={gridSquareClicked:(e,t)=>{L("JS_GridSquareClick",`${e};${t}`)},animate:()=>s.animateScroll&&!matchMedia("(prefers-reduced-motion: reduce)").matches,strings:()=>({map:$("MapLabel","Map"),zoomIn:$("MapZoomIn","Zoom in"),zoomOut:$("MapZoomOut","Zoom out")})};function Dn(){return window.QuestUIV2Map?Promise.resolve():(Ht??=new Promise((e,t)=>{let n=new URL(at?"map.js":"v2/map.js",at||document.baseURI);at&&(n.search=new URL(at).search);let o=document.createElement("script");o.src=n.href,o.onload=()=>e(),o.onerror=()=>{Ht=null,t(new Error(`Failed to load ${n.href}`))},document.head.append(o)}),Ht)}function ke(){return a()?.map?.querySelector(".qv-map-view")??null}function Rn(){let e=ke();if(!e||!window.QuestUIV2Map)return;(!D||lt!==e)&&(D=window.QuestUIV2Map.create(e,Nn),lt=e);let t=j;j=[];for(let[n,o]of t)try{D.call(n,o)}catch(r){console.error(r)}}function Nt(e,t){if(a()?.map){if(e==="show"){let n=typeof t[0]=="number"?t[0]:parseFloat(String(t[0]));ct=Number.isFinite(n)?n:0,q()}if(D&&lt===ke()&&j.length===0){D.call(e,t);return}j.push([e,t]),Dn().then(Rn,n=>console.error(n))}}function He(e){It=e,q()}function Ie(e){e!=="header"&&e!=="panes"||(Bt=e,q())}function q(){let e=a(),t=e?.map;if(!e||!t)return;t.hidden=!(ct>0&&It),t.style.setProperty("--qv-map-height",`${ct}px`),t.classList.toggle("qv-map-collapsed",z);let n=On(t),o=e.mapButton;if(o){o.hidden=t.hidden||n||!e.hasAttribute("data-qv-narrow");let r=o.querySelector(".qv-button-label");r&&(r.textContent=$("MapLabel","Map")),o.setAttribute("aria-expanded",String(!z))}e.updateTopbar()}function On(e){let t=a();if(!t)return!1;let n=Bt==="panes"&&t.layout!=="none"&&!!t.panes&&!t.panes.hidden,o=f("map");if(n&&!o&&t.panes&&(o=document.createElement("qv-pane"),o.dataset.qvPane="map",o.setAttribute("label",$("MapLabel","Map")),t.panes.prepend(o)),n&&o)e.parentElement!==o.body&&o.body.append(e),o.hidden=e.hidden;else{let r=t.querySelector(".qv-header");r&&e.parentElement!==r&&r.append(e),o&&(o.hidden=!0)}return n}function Be(){z=!z,q()}function Ne(){D=null,lt=null,j=[],ct=0,It=!0,z=!1,Bt="header"}var Dt="questviva-colour-scheme",Un=["system","light","dark"],K=Fn(),Re=typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)"):null;function Fn(){try{let e=window.electronPlayerSettings?window.electronPlayerSettings.getColourScheme():localStorage.getItem(Dt);if(e&&Un.includes(e))return e}catch{}return"system"}function Vn(e){try{window.electronPlayerSettings?window.electronPlayerSettings.setColourScheme(e).catch(()=>{}):e==="system"?localStorage.removeItem(Dt):localStorage.setItem(Dt,e)}catch{}}function Qn(e){return!e.style.getPropertyValue("--qv-bg")}function Wn(e){let t=document.createElement("span");t.style.color=e.style.getPropertyValue("--qv-bg"),t.hidden=!0,e.append(t);let n=/rgba?\(([\d.]+),\s*([\d.]+),\s*([\d.]+)/.exec(getComputedStyle(t).color);if(t.remove(),!n)return!1;let[o,r,i]=n.slice(1,4).map(l=>{let c=Number(l)/255;return c<=.03928?c/12.92:((c+.055)/1.055)**2.4});return .2126*o+.7152*r+.0722*i<.18}function G(e){let t=Qn(e),n=t?K==="dark"||K==="system"&&!!Re?.matches:Wn(e);e.setAttribute("data-qv-scheme",n?"dark":"light"),e.toggleAttribute("data-qv-fixed-scheme",!t),document.documentElement.setAttribute("data-qv-scheme",n?"dark":"light");let o=e.querySelector(".qv-scheme");if(o){o.hidden===t&&(o.hidden=!t,t||A(e,!1));for(let r of o.querySelectorAll("[data-qv-scheme-icon]"))r.hidden=r.dataset.qvSchemeIcon!==K;for(let r of o.querySelectorAll("[data-qv-scheme-choice]"))r.setAttribute("aria-checked",String(r.dataset.qvSchemeChoice===K))}}function $n(e,t){K=t,Vn(t),G(e)}function Ut(e){return e.querySelector(".qv-scheme-menu")}function Rt(e){return[...e.querySelectorAll("[data-qv-scheme-choice]")]}function De(e){let t=Ut(e),n=e.querySelector(".qv-scheme-button");if(!t||!n)return;t.hidden=!1,n.setAttribute("aria-expanded","true"),(Rt(t).find(r=>r.getAttribute("aria-checked")==="true")??Rt(t)[0])?.focus()}function A(e,t){let n=Ut(e),o=e.querySelector(".qv-scheme-button");!n||n.hidden||(n.hidden=!0,o?.setAttribute("aria-expanded","false"),t&&o?.focus())}var Ot=null;Re?.addEventListener("change",()=>{Ot?.isConnected&&G(Ot)});function Oe(e){Ot=e,G(e);let t=e.querySelector(".qv-scheme-button"),n=Ut(e);!t||!n||(t.addEventListener("click",()=>{n.hidden?De(e):A(e,!0)}),t.addEventListener("keydown",o=>{(o.key==="ArrowDown"||o.key==="ArrowUp")&&(o.preventDefault(),De(e))}),n.addEventListener("click",o=>{let r=o.target instanceof Element?o.target.closest("[data-qv-scheme-choice]"):null;r&&($n(e,r.dataset.qvSchemeChoice),A(e,!0))}),n.addEventListener("keydown",o=>{let r=Rt(n),i=r.indexOf(document.activeElement),l=-1;if(o.key==="ArrowDown")l=(i+1)%r.length;else if(o.key==="ArrowUp")l=(i-1+r.length)%r.length;else if(o.key==="Home")l=0;else if(o.key==="End")l=r.length-1;else if(o.key==="Escape"){o.preventDefault(),o.stopPropagation(),A(e,!0);return}else if(o.key==="Tab"){A(e,!1);return}l>=0&&(o.preventDefault(),r[l]?.focus())}),document.addEventListener("pointerdown",o=>{!n.hidden&&o.target instanceof Node&&!n.contains(o.target)&&!t.contains(o.target)&&A(e,!1)}),n.addEventListener("focusout",o=>{o.relatedTarget instanceof Node&&!n.contains(o.relatedTarget)&&o.relatedTarget!==t&&A(e,!1)}))}var Ue=["sidepanes","nopanes","bottombar"],jn=900,zn=new Set(["--qv-font-size","--qv-output-width","--qv-padding-top","--qv-padding-bottom","--qv-padding-left","--qv-padding-right","--qv-menu-font-size","--qv-radius","--qv-space"]),ut=class extends HTMLElement{#e=!1;#t="sidepanes";#n="sidepanes";connectedCallback(){if(this.#e)return;this.#e=!0,this.addEventListener("click",n=>ce(n,this.verbMenu)),this.addEventListener("keydown",ue);for(let n of this.querySelectorAll(".qv-panes-button"))n.addEventListener("click",()=>w(!rt()));this.mapButton?.addEventListener("click",Be),Oe(this),new ResizeObserver(()=>this.#r()).observe(this),this.panes?.addEventListener("keydown",n=>{n.key==="Escape"&&rt()&&!this.verbMenu?.isOpen&&(n.preventDefault(),w(!1))});let t=this.querySelector(".qv-toolbar");t&&(new MutationObserver(()=>{Ve(t),this.updateTopbar()}).observe(t,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["style","hidden"]}),Ve(t)),this.addEventListener("pointerover",n=>{let o=n.target instanceof Element?n.target.closest("button"):null;if(!o?.querySelector(":scope > .qv-icon"))return;let r=o.querySelector(".qv-button-label")?.textContent?.trim()||o.getAttribute("aria-label");r&&(o.title=r)}),this.#r(),this.#s()}get topbar(){return this.querySelector(".qv-topbar")}get saveButton(){return this.querySelector("#cmdSave")}get panes(){return this.querySelector('[data-qv-part="panes"]')}get exits(){return this.querySelector('[data-qv-part="exits"]')}get statusBar(){return this.querySelector('[data-qv-part="status-bar"]')}get panesButton(){return this.querySelector(this.layout==="sheet"?".qv-footer .qv-panes-button":".qv-topbar .qv-panes-button")}get layout(){return this.dataset.qvLayout??"side"}setLayoutPreset(t,n){if(t==="gamebook"){this.toggleAttribute("data-qv-gamebook",!0),this.#t=this.#n="nopanes",this.setVisible("command-bar",!1),this.setVisible("location",!1),this.#r();return}Ue.includes(t)&&(this.removeAttribute("data-qv-gamebook"),this.#t=t,this.#n=n!=null&&Ue.includes(n)?n:t,this.#r())}#r(){let t=this.clientWidth<jn;t!==this.hasAttribute("data-qv-narrow")&&(this.toggleAttribute("data-qv-narrow",t),q());let n=t?this.#n:this.#t,o=n==="nopanes"?"none":n==="bottombar"?"sheet":t?"drawer":"side";this.dataset.qvLayout!==o&&(w(!1,{restoreFocus:!1}),this.toggleAttribute("data-qv-layout-changing",!0),this.dataset.qvLayout=o,q(),requestAnimationFrame(()=>requestAnimationFrame(()=>this.removeAttribute("data-qv-layout-changing"))),h(),it(),this.updateTopbar())}updateTopbar(){let t=this.topbar;if(!t)return;let n=this.location,o=[...t.querySelectorAll(".qv-toolbar > button, .qv-toolbar > .qv-scheme:not([hidden]) > button")].some(l=>!l.hidden&&l.style.display!=="none"&&getComputedStyle(l).display!=="none"),r=this.statusBar,i=!!r&&!r.hidden&&r.classList.contains("qv-status-bar-active")&&getComputedStyle(r).display!=="none";t.hidden=(!n||n.hidden)&&!o&&!i}focusFirstChoice(){if(!this.hasAttribute("data-qv-gamebook"))return;let t=document.activeElement;if(t&&t!==document.body&&this.contains(t)&&!t.closest(".qv-hiding")&&!t.classList.contains("disabled"))return;[...this.querySelectorAll('[data-qv-part="output"] [data-qv-sections] a.commandlink:not(.disabled)')].find(o=>!o.closest(".qv-hiding"))?.focus({preventScroll:!0})}get verbMenu(){return this.querySelector("qv-verb-menu")}updateLinks(t,n){ae(this,t,n),this.verbMenu?.closeIfStale()}get output(){return this.querySelector("qv-output")}get commandBar(){return this.querySelector("qv-command-bar")}get location(){return this.querySelector('[data-qv-part="location"]')}get pictureFrame(){return this.querySelector('[data-qv-part="picture-frame"]')}get map(){return this.querySelector('[data-qv-part="map"]')}get mapButton(){return this.querySelector(".qv-map-button")}get frame(){return this.querySelector('[data-qv-part="border"]')}setVisible(t,n){switch(t){case"output":this.#o(this.output,!n);break;case"command-bar":this.#o(this.commandBar,!n);break;case"location":this.#o(this.location,!n),this.updateTopbar();break;case"border":this.frame?.classList.toggle("qv-borderless",!n);break;case"picture-frame":this.#o(this.pictureFrame,!n);break;case"exits":this.#o(this.exits,!n);break;case"map":He(n);break;case"status-bar":this.#o(this.statusBar,!n);break;case"panes":this.#o(this.panes,!n),n||w(!1,{restoreFocus:!1}),q(),this.#s();break;default:(Mt.includes(t)||f(t))&&(this.#o(f(t),!n),this.#s())}h(),it()}#s(){let t=this.panes;if(!t)return;let n=[...t.querySelectorAll("qv-pane")].some(o=>!o.hidden&&!o.hasAttribute("data-qv-empty"));for(let o of this.querySelectorAll(".qv-panes-button"))o.hidden=t.hidden||!n;this.updateTopbar()}#o(t,n){t&&(t.hidden=n)}setTokens(t){for(let[n,o]of Object.entries(t)){if(!n.startsWith("--"))continue;let r=o==null?"":String(o).trim();if(r===""){this.style.removeProperty(n);continue}zn.has(n)&&/^-?(\d+\.?\d*|\.\d+)$/.test(r)&&(r+="px"),this.style.setProperty(n,r)}this.toggleAttribute("data-qv-own-accent",!!this.style.getPropertyValue("--qv-accent")),this.toggleAttribute("data-qv-own-background",["--qv-bg","--qv-bg-light","--qv-bg-dark"].some(n=>!!this.style.getPropertyValue(n))),this.toggleAttribute("data-qv-own-border",["--qv-border-colour","--qv-border-colour-light","--qv-border-colour-dark"].some(n=>!!this.style.getPropertyValue(n))),G(this),this.updateTopbar()}setLocation(t){let n=this.location;n&&(n.innerHTML=t,n.classList.toggle("qv-empty",t.trim()===""))}},Fe="http://www.w3.org/2000/svg";function Ve(e){let t=e.querySelector("#cmdRestart");if(!t||t.querySelector(".qv-icon"))return;let n=document.createElement("span");n.className="qv-button-label",n.textContent=t.textContent;let o=document.createElementNS(Fe,"svg");o.setAttribute("class","qv-icon"),o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("aria-hidden","true");for(let r of["M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8","M3 3v5h5"]){let i=document.createElementNS(Fe,"path");i.setAttribute("d",r),o.append(i)}t.replaceChildren(o,n)}function a(){return document.querySelector("qv-player")}var dt=0,Ft=0,Y,Qe=!1;function We(e){Ft=e,Kn()}function Vt(){return R(),dt}function $e(){Qe=!0,R()}function R(){Y!==void 0&&(clearInterval(Y),Y=void 0)}function Kn(){Qe||Y!==void 0||(dt=0,Y=setInterval(async()=>{dt++,Ft>0&&dt>=Ft&&await WebPlayer.uiTick(Vt())},1e3))}function Q(){return window.canSendCommand&&!s.gameFinished&&!s.soundWait&&!s.waiting&&!s.pausing&&!s.inDialog}function v(e,t){if(!Q())return!1;window.canSendCommand=!1,a()?.output?.markScrollPosition(),s.hasUnsavedProgress=!0;let n=Vt();return setTimeout(()=>{WebPlayer.sendCommand(e,n,t??null)},0),!0}function L(e,t){s.hasUnsavedProgress=!0;let n=""+t;return setTimeout(()=>{WebPlayer.uiSendEvent(e,n)},1),!0}var mt=new Set;function O(e,t){t?mt.add(e):mt.delete(e),a()?.toggleAttribute("data-qv-input-held",mt.size>0)}function ze(){mt.clear(),clearTimeout(pt),_=null}function Ke(){s.waiting=!0,h(),a()?.commandBar?.setMode("continue"),a()?.output?.markScrollPosition()}function J(){s.waiting&&(s.waiting=!1,a()?.commandBar?.setMode("none"),s.hasUnsavedProgress=!0,sendEndWait())}function Wt(){h(),!s.waiting&&ft()}var pt;function Ge(e){s.pausing=!0,h(),O("pause",!0),clearTimeout(pt),pt=setTimeout(Yn,e)}function Yn(){s.pausing&&(s.pausing=!1,sendEndPause())}function $t(){h(),!s.pausing&&(O("pause",!1),ft())}function Ye(){s.waiting&&(s.waiting=!1,Wt()),s.pausing&&(clearTimeout(pt),s.pausing=!1,$t()),_?.()}function ft(){let e=a()?.commandBar;!e||s.gameFinished||s.waiting||s.inDialog||(e.setMode("input"),e.focusInput())}var Qt={cancel:"Cancel",yes:"Yes",no:"No"},je=0,_=null;function _e(e,t,n){let o=a();if(!o)return;let r=++je;o.querySelector("dialog.qv-dialog")?.remove();let i=document.createElement("dialog");i.className="qv-dialog",i.dataset.qvPart="menu";let l="qv-dialog-caption";i.setAttribute("aria-labelledby",l);let c=document.createElement("div");c.id=l,c.className="qv-dialog-caption",c.innerHTML=e;let u=document.createElement("div");u.className="qv-dialog-choices";let d=!1,b=p=>{d||(d=!0,_=null,i.close(),i.remove(),s.hasUnsavedProgress=!0,setTimeout(async()=>{try{await p()}finally{je===r&&(s.inDialog=!1,h(),ft())}},100))};for(let p of t){let T=document.createElement("button");T.type="button",T.textContent=p.label,T.addEventListener("click",()=>b(p.choose)),u.append(T)}if(i.append(c,u),n){let p=document.createElement("button");p.type="button",p.className="qv-dialog-cancel",p.textContent=Qt.cancel,p.addEventListener("click",()=>b(n)),i.append(p)}i.addEventListener("cancel",p=>{p.preventDefault(),n&&b(n)}),i.addEventListener("close",()=>{!d&&i.isConnected&&i.showModal()}),_=()=>{d=!0,_=null,i.close(),i.remove(),s.inDialog=!1,h(),ft()},s.inDialog=!0,h(),o.commandBar?.setMode("none"),o.append(i),i.showModal(),u.querySelector("button")?.focus()}function Je(e,t,n){let o=Object.entries(t).map(([r,i])=>({label:i,choose:()=>WebPlayer.uiChoice(r)}));_e(e,o,n?()=>WebPlayer.uiChoiceCancel():null)}function Ze(e){_e(e,[{label:Qt.yes,choose:()=>WebPlayer.uiSetQuestionResponse(!0)},{label:Qt.no,choose:()=>WebPlayer.uiSetQuestionResponse(!1)}],null)}var tn=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches;document.addEventListener("pointerdown",e=>{tn=e.pointerType!=="mouse"&&!(e.target instanceof Element&&e.target.closest(".qv-command-input"))},!0);var ht=class extends HTMLElement{#e;#t;#n;#r;#s="input";#o=[];#i=0;#a="";connectedCallback(){if(this.#t)return;let t=this.#e=document.createElement("form");t.className="qv-command-form",this.#n=document.createElement("span"),this.#n.className="qv-command-prompt",this.#n.setAttribute("aria-hidden","true"),this.#t=document.createElement("input"),this.#t.type="text",this.#t.className="qv-command-input",this.#t.autocomplete="off",this.#t.spellcheck=!1,this.#t.setAttribute("autocapitalize","off"),this.#t.setAttribute("enterkeyhint","send"),this.#t.dataset.chromeKeyAriaLabel="CommandInputLabel",this.#t.setAttribute("aria-label","Type your command"),t.append(this.#n,this.#t),this.#r=document.createElement("button"),this.#r.type="button",this.#r.className="qv-continue",this.#r.hidden=!0,this.#r.addEventListener("click",J),this.append(t,this.#r),t.addEventListener("submit",n=>{n.preventDefault(),this.#c()}),this.#t.addEventListener("keydown",n=>this.#l(n)),this.updatePlaceholder(),this.updateContinueLabel()}setMode(t){this.#s=t,this.#e.hidden=t!=="input",this.#r.hidden=t!=="continue",t==="continue"&&this.#r.focus({preventScroll:!0})}get input(){return this.#t}focusInput(){if(this.hidden)return;let t=this.#s==="input"?this.#t:this.#s==="continue"?this.#r:null;t===this.#t&&tn||t&&document.activeElement!==t&&t.focus({preventScroll:!0})}setPrompt(t){this.#n.innerHTML=t}setStyle(t){this.#t.style.cssText=t}setPreset(t){(t==="borderless"||t==="shadow")&&(this.dataset.qvPreset=t)}updateContinueLabel(){this.#r.textContent=Xe(s.interfaceStrings.get("ContinueLabel")??"")||"Continue"}updatePlaceholder(){this.#t.placeholder=s.commandPlaceholder??Xe(s.interfaceStrings.get("TypeHereLabel")??"")}#c(){let t=this.#t.value;t.length===0||!Q()||v(t)&&(this.#o.at(-1)!==t&&this.#o.push(t),this.#i=this.#o.length,this.#a="",this.#t.value="")}#l(t){if(t.key!=="ArrowUp"&&t.key!=="ArrowDown"||t.altKey||t.ctrlKey||t.metaKey||t.shiftKey)return;let n=this.#i+(t.key==="ArrowUp"?-1:1);if(n<0||n>this.#o.length)return;t.preventDefault(),this.#i===this.#o.length&&(this.#a=this.#t.value),this.#i=n,this.#t.value=n===this.#o.length?this.#a:this.#o[n];let o=this.#t.value.length;this.#t.setSelectionRange(o,o)}};function Xe(e){let t=document.createElement("template");return t.innerHTML=e,t.content.textContent??""}var jt=new Set;function vt(e,t){let n=typeof e=="number"?e:parseFloat(String(e));return Number.isFinite(n)?n:t}function Jn(e){let t=document.createElement("template");return t.innerHTML=String(e??""),t.content.textContent??""}function en(){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";return e[Math.floor(Math.random()*e.length)]}function Zn(e){for(let t=e.length-1;t>0;t--){let n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}}function nn(e,t){if(e!=="typewriter"&&e!=="unscramble")return;let n=a()?.output;if(!n)return;let o=Jn(t[0]),r=Math.max(0,vt(t[1],100)),i=e==="unscramble"?Math.max(1,Math.floor(vt(t[2],1))):0,[l,c,u]=(e==="unscramble"?t.slice(3,6):t.slice(2,5)).map(g=>g==null?"":String(g).trim()),d=document.createElement("span");d.className="qv-text-effect",d.dataset.qvEffect=e,l&&d.style.setProperty("font-family",l),c&&d.style.setProperty("color",c),u&&vt(u,0)>0&&d.style.setProperty("font-size",`${vt(u,0)}pt`);let b=document.createElement("span");b.className="qv-text-effect-full",b.textContent=o;let p=document.createElement("span");p.className="qv-text-effect-shown",p.setAttribute("aria-hidden","true"),d.append(b,p);let T=document.createElement("span");if(T.textContent=o,n.addNodes([d,document.createElement("br")],`${T.innerHTML}<br/>`),!(s.animateScroll&&!matchMedia("(prefers-reduced-motion: reduce)").matches)||o===""){zt(d);return}d.classList.add("qv-text-effect-running");let Lt;if(e==="typewriter"){let g=0;Lt=()=>(g++,p.textContent=o.substring(0,g)+(g%2===1&&g<o.length?"_":""),g>=o.length)}else{let g=[...o],F=g.flatMap((E,et)=>/\s/.test(E)?[]:[et]);Zn(F);let tt=g.map(E=>/\s/.test(E)?E:en());p.textContent=tt.join(""),Lt=()=>{for(let E=0;E<i&&F.length;E++){let et=F.pop();tt[et]=g[et]}for(let E of F)tt[E]=en();return p.textContent=tt.join(""),F.length===0}}let U={timer:0,finish:()=>{clearInterval(U.timer),jt.delete(U),zt(d)}};U.timer=window.setInterval(()=>{(!d.isConnected||Lt())&&U.finish()},r),jt.add(U)}function zt(e){let t=e.querySelector(".qv-text-effect-shown");t&&(t.textContent=e.querySelector(".qv-text-effect-full")?.textContent??""),e.classList.remove("qv-text-effect-running")}function gt(){for(let e of[...jt])e.finish()}function on(e){for(let t of e.querySelectorAll(".qv-text-effect"))zt(t)}document.addEventListener("keydown",()=>gt(),!0);document.addEventListener("pointerdown",()=>gt(),!0);var rn=4,Xn=150,to=8,bt=class extends HTMLElement{#e=null;#t=0;#n=0;#r=null;#s=null;#o=!1;connectedCallback(){this.#e=this.querySelector("button"),this.#e?.addEventListener("click",this.#l),window.addEventListener("scroll",this.#i,{passive:!0}),window.addEventListener("resize",this.#i,{passive:!0}),this.#r=new ResizeObserver(this.#i);let t=a();for(let n of[t?.output,t?.commandBar,t?.querySelector(".qv-footer"),t?.querySelector(".qv-header")])n&&this.#r.observe(n);this.#s=new MutationObserver(n=>{n.some(o=>o.type==="characterData"||o.addedNodes.length>0)&&(this.#o=!1,this.#i())}),t?.output&&this.#s.observe(t.output,{childList:!0,characterData:!0,subtree:!0}),this.#i()}disconnectedCallback(){this.#e?.removeEventListener("click",this.#l),window.removeEventListener("scroll",this.#i),window.removeEventListener("resize",this.#i),this.#r?.disconnect(),this.#r=null,this.#s?.disconnect(),this.#s=null,cancelAnimationFrame(this.#t),clearTimeout(this.#n),this.#t=this.#n=0}#i=()=>{this.#t||(this.#t=requestAnimationFrame(()=>{this.#t=0,this.#a()}))};#a(){let t=this.#e;if(!t)return;let n=Kt();if(!n||this.#o){n||(this.#o=!0),clearTimeout(this.#n),this.#n=0,this.#c();return}this.style.setProperty("--qv-more-bottom",`${window.innerHeight-n.limit+to}px`),this.style.setProperty("--qv-more-x",`${n.centre}px`),t.hidden&&(clearTimeout(this.#n),this.#n=window.setTimeout(()=>{this.#n=0,!this.#o&&Kt()&&(t.hidden=!1)},Xn))}#c(){let t=this.#e;if(!t||t.hidden)return;let n=t.contains(document.activeElement);t.hidden=!0,n&&(a()?.commandBar?.focusInput(),document.activeElement===t&&t.blur())}#l=()=>{let t=Kt();if(!t)return;let n=document.querySelector("qv-player .qv-header"),o=Math.max(0,n?.getBoundingClientRect().bottom??0),r=a()?.output,i=r&&parseFloat(getComputedStyle(r).lineHeight)||24,l=Math.max(i,t.limit-o-2*i),c=!matchMedia("(prefers-reduced-motion: reduce)").matches;window.scrollBy({top:l,behavior:c?"smooth":"instant"})}};function Kt(){let e=a(),t=e?.output;if(!e||!t||t.hidden||!t.isConnected)return null;let n=window.innerHeight,o=e.querySelector(".qv-footer"),r=o&&getComputedStyle(o).display!=="contents"?o:e.commandBar,i=r&&!r.hidden&&r.offsetHeight>0?r.getBoundingClientRect():null,l=i?Math.min(n,i.top):n,c=t.lastElementChild;if(!((c?c.getBoundingClientRect().bottom:t.getBoundingClientRect().top)>l+rn||i!=null&&i.bottom>n+rn))return null;let b=t.getBoundingClientRect();return{limit:l,centre:b.left+b.width/2}}var an=(e,t)=>WebPlayer.chromeStrings?.[e]??t;function sn(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}function ln(e,t,n,o=""){let r=a()?.output;r&&r.addText(`<iframe class="qv-video" data-qv-video="${e}" src="${sn(t.href)}" title="${sn(n)}" allow="autoplay; fullscreen; picture-in-picture; encrypted-media" allowfullscreen${o}></iframe>`)}function cn(e){let t=new URL(`https://www.youtube-nocookie.com/embed/${encodeURIComponent(e.trim())}`);t.searchParams.set("autoplay","1"),t.searchParams.set("rel","0"),ln("youtube",t,an("YouTubeVideoTitle","YouTube video"))}function un(e){let[t,n]=e.trim().split("/"),o=new URL(`https://player.vimeo.com/video/${encodeURIComponent(t)}`);n&&o.searchParams.set("h",n),o.searchParams.set("autoplay","1"),o.searchParams.set("dnt","1"),ln("vimeo",o,an("VimeoVideoTitle","Vimeo video"),' sandbox="allow-same-origin allow-scripts allow-popups allow-presentation"')}function dn(e){for(let t of e.querySelectorAll("iframe[data-qv-video]")){let n;try{n=new URL(t.getAttribute("src")??"")}catch{continue}n.searchParams.has("autoplay")&&(n.searchParams.delete("autoplay"),t.setAttribute("src",n.href))}}function yt(e){let t=a()?.pictureFrame;if(t){t.innerHTML=e,t.classList.toggle("qv-empty",e.trim()==="");for(let n of t.querySelectorAll("img"))n.hasAttribute("alt")||(n.alt=""),n.complete||(n.addEventListener("load",Gt,{once:!0}),n.addEventListener("error",Gt,{once:!0}));Gt()}}function mn(){let e=a()?.pictureFrame;return!e||e.hidden||e.classList.contains("qv-empty")?!1:[...e.querySelectorAll("img")].some(t=>!t.complete)}function Gt(){a()?.output?.rescroll(!0)}var hn=new Map;function vn(e,t,n){hn.set(e,{width:t,height:n})}var eo=8;function no(e){s.warnedAboutScript||!/<script[\s>\/]/i.test(e)||(s.warnedAboutScript=!0,console.warn(`[Quest] This game printed a <script> element, which doesn't run in the new player interface. Call your own JavaScript with JS.yourFunction () or JS.eval instead, or tick "Use the classic interface" on the game's Interface tab.`))}var St=class extends HTMLElement{#e=null;#t=[];#n=0;#r=0;#s=!0;#o=0;connectedCallback(){this.setAttribute("role","log"),this.setAttribute("aria-live","polite"),this.addEventListener("load",this.#i,!0),this.addEventListener("error",this.#i,!0)}disconnectedCallback(){this.removeEventListener("load",this.#i,!0),this.removeEventListener("error",this.#i,!0)}#i=t=>{t.target instanceof HTMLImageElement&&this.rescroll()};addText(t){no(t);let n=this.#e??this.setAlignment("left");n.insertAdjacentHTML("beforeend",t),oo(n),ro(n),H(n),this.#s=!0,WebPlayer.transcript?.write(t),y("outputAdded",{html:t})}addNodes(t,n){(this.#e??this.setAlignment("left")).append(...t),this.#s=!0,WebPlayer.transcript?.write(n),y("outputAdded",{html:n})}setAlignment(t){this.#e&&!this.#e.hasChildNodes()&&this.#e.remove();let n=document.createElement("div");return n.className="qv-block",n.style.textAlign=t,this.#t.length&&(n.dataset.qvSections=this.#t.join(" ")),this.append(n),this.#e=n,n}clearScreen(){this.replaceChildren(),this.#e=null,this.setAlignment("left"),this.#n=0,this.#s=!0;let t=this.#u();window.scrollY>t&&window.scrollTo({top:t,behavior:"instant"})}loadHtml(t){let n=document.createElement("template");n.innerHTML=t,dn(n.content),on(n.content),this.replaceChildren(n.content),this.#s=!0,H(this),ie(this),requestAnimationFrame(()=>{let o=document.scrollingElement??document.documentElement;window.scrollTo({top:o.scrollHeight,behavior:"instant"})}),this.#e=null,this.#t=[]}getHtml(){return this.innerHTML}reset(){this.replaceChildren(),this.#e=null,this.#t=[],this.#n=0,this.#r=0,this.#s=!0,this.#o=0}startSection(t){this.#t.includes(t)||(this.#t.push(t),this.setAlignment("left"))}endSection(t){let n=this.#t.indexOf(t);n!==-1&&(this.#t.splice(n,1),this.setAlignment("left"))}hideSection(t){this.endSection(t);let n=this.getBoundingClientRect().top;for(let o of this.#a(t)){let r=o.getBoundingClientRect();r.bottom-n<=this.#n+1&&(this.#n=Math.max(0,this.#n-r.height)),o.classList.add("qv-hiding"),fn(o),setTimeout(()=>o.remove(),250)}}disableSection(t){for(let n of this.#a(t))fn(n)}disableCommandLinks(){for(let t of this.querySelectorAll("a.commandlink"))xt(t);a()?.verbMenu?.closeIfStale()}#a(t){return[...this.querySelectorAll("[data-qv-sections]")].filter(n=>n.dataset.qvSections.split(" ").includes(t))}beginTurn(){if(s.fadePreviousOutput)for(let t of this.children)t.classList.add("qv-previous-output")}clearPreviousOutputFade(){for(let t of this.querySelectorAll(".qv-previous-output"))t.classList.remove("qv-previous-output")}markScrollPosition(){this.#n=this.#c()}#c(){let t=this.lastElementChild;return t?t.getBoundingClientRect().bottom-this.getBoundingClientRect().top:0}scrollToEnd(){let t=this.#c();!this.#s&&t<=this.#o+1||(this.#s=!1,this.#o=t,this.#l(this.#n))}rescroll(t=!1){this.#l(this.#r,t)}#l(t,n=!1){if(!s.autoScroll||(this.#r=t,mn()))return;let r=(document.scrollingElement??document.documentElement).scrollHeight-window.innerHeight,i=s.animateScroll?Math.min(this.#u()+t-pn()-eo,r):r,l=this.#u()+t-window.scrollY,c=n&&l>=0&&l<pn();if(i<=window.scrollY&&!c)return;let u=s.animateScroll&&!matchMedia("(prefers-reduced-motion: reduce)").matches;window.scrollTo({top:i,behavior:u?"smooth":"instant"})}#u(){return this.getBoundingClientRect().top+window.scrollY}};function pn(){return document.querySelector("qv-player .qv-header")?.offsetHeight??0}function fn(e){for(let t of e.querySelectorAll("a.cmdlink, a[data-qv-event]"))M(t,!1);a()?.verbMenu?.closeIfStale()}function oo(e){for(let t of e.querySelectorAll("img:not([alt])"))t.setAttribute("alt","")}function ro(e){for(let t of e.querySelectorAll("img:not([width]):not([height]):not([style])")){let n=hn.get(t.getAttribute("src")??"");n&&(t.setAttribute("width",String(n.width)),t.setAttribute("height",String(n.height)),t.classList.add("qv-sized"))}}var x=()=>WebPlayer.transcript;function gn(e){let t=a()?.output;t?.addText(e),t?.scrollToEnd()}var bn={write:e=>x()?.write(String(e??"")),enable:e=>x()?.enable(e==null?void 0:String(e)),disable:()=>x()?.disable(),kill:()=>x()?.kill(),revive:()=>x()?.revive(),setName:e=>x()?.setName(String(e??"")),setPrefix:()=>{},stampDateAndTime:()=>gn(`<b>DATE AND TIME:</b> ${new Date().toLocaleString(navigator.language,{timeZoneName:"short"})}`),promptForName:()=>{let e=a()?.commandBar?.input;e&&(e.value=x()?.name||document.title,e.focus({preventScroll:!0}))},show:(e,t)=>{let n=document.createElement("a");n.href=x()?.viewerUrl??"TranscriptViewer/index.html",n.target="_blank",n.textContent=t==null||t===""?"Your Transcripts":String(t);let o=e==null||e===""?"Your transcripts are saved to the localStorage in your browser. You can view, download, or delete them here:":String(e);gn(`${o} ${n.outerHTML}<br/>`)}};var m=e=>(...t)=>Nt(e,t),so={show:m("show"),respondToClicks:m("respondToClicks"),setInteractive:m("setInteractive"),setScale:m("setScale"),setCentre:m("setCentre"),drawBox:m("drawBox"),drawLabel:m("drawLabel"),drawPlayer:m("drawPlayer"),drawLine:m("drawLine"),drawArrow:m("drawArrow"),drawSquare:m("drawSquare"),drawShape:m("drawShape"),addShapePoint:m("addShapePoint"),drawImage:m("drawImage"),drawSvg:m("drawSvg"),loadSvg:m("loadSvg"),drawGridLines:m("drawGridLines"),showCustomLayer:m("showCustomLayer"),clearCustomLayer:m("clearCustomLayer"),clearAllLayers:m("clearAllLayers")};function Z(e){return typeof e=="string"?JSON.parse(e):e}function Yt(e){let t=e??"";a()?.setLocation(t),y("locationChanged",{location:t})}function _t(e,t){s.interfaceStrings.set(e,t),e==="EmptyListLabel"&&(s.interfaceStrings.delete("InventoryEmptyLabel"),s.interfaceStrings.delete("PlacesObjectsEmptyLabel")),Ee(e,t),(e==="InButtonLabel"||e==="OutButtonLabel"||e==="CompassLabel")&&B(),e==="TypeHereLabel"&&a()?.commandBar?.updatePlaceholder(),e==="ContinueLabel"&&a()?.commandBar?.updateContinueLabel()}function Jt(e){s.compassDirections=Array.isArray(e)?e.map(String):String(e??"").split(";"),B()}var yn={sendCommand:v,sendEvent:L,restart:()=>window.RestartGame?.(),addText:e=>a()?.output?.addText(String(e)),clearScreen:()=>a()?.output?.clearScreen(),setAlignment:e=>{a()?.output?.setAlignment(String(e))},startSection:e=>a()?.output?.startSection(String(e)),endSection:e=>a()?.output?.endSection(String(e)),hideSection:e=>a()?.output?.hideSection(String(e)),disableSection:e=>a()?.output?.disableSection(String(e)),disableCommandLinks:()=>a()?.output?.disableCommandLinks(),updateLinks:(e,t)=>a()?.updateLinks(String(e),Z(t)),scrollToEnd:()=>a()?.output?.scrollToEnd(),addYouTube:e=>cn(String(e??"")),addVimeo:e=>un(String(e??"")),textEffect:(e,...t)=>nn(String(e),t),setVisible:(e,t)=>a()?.setVisible(String(e),!!t),setPaneOrder:e=>Se(Z(e)),setLayoutPreset:(e,t)=>a()?.setLayoutPreset(String(e),t==null?void 0:String(t)),setMapPosition:e=>Ie(String(e??"")),setPictureFrame:e=>yt(String(e??"")),setInterfaceString:_t,setCompassDirections:e=>Jt(Z(e)),setLocation:Yt,setStatusAttributes:e=>Pt(Z(e)),setTokens:e=>a()?.setTokens(Z(e)??{}),setCommandBarStyle:e=>a()?.commandBar?.setStyle(String(e??"")),setCommandBarPreset:e=>a()?.commandBar?.setPreset(String(e??"")),setCommandPrompt:e=>a()?.commandBar?.setPrompt(String(e??"")),addStylesheet:e=>addExternalStylesheet(String(e)),map:so,transcript:bn,addPane:(e,t,n)=>ye(String(e),t==null?void 0:String(t),n==null?void 0:String(n)),setPaneContent:(e,t)=>be(String(e),String(t??"")),setCommands:e=>ge(e),setAutoScroll:e=>{s.autoScroll=!!e},setContinueOnClick:e=>{s.continueOnClick=!!e},fadePreviousOutput:e=>{s.fadePreviousOutput=!!e,s.fadePreviousOutput||a()?.output?.clearPreviousOutputFade()},setCommandPlaceholder:e=>{s.commandPlaceholder=e==null?null:String(e),a()?.commandBar?.updatePlaceholder()},setMapInteractive:e=>Nt("setInteractive",[e]),lists:ne,on:Xt,off:te};function Sn(e){return(e.dataset.qvName??e.textContent??"").trim()}var Zt=4,X=8,Et=class extends HTMLElement{#e=null;connectedCallback(){this.setAttribute("role","menu"),C&&(this.popover="manual"),this.addEventListener("click",this.#n),this.addEventListener("keydown",this.#r)}get isOpen(){return this.#e!==null}toggle(t){if(this.#e===t){this.close();return}let n=(t.dataset.verbs??"").split("/").map(r=>r.trim()).filter(Boolean);if(!n.length)return;this.close({restoreFocus:!1});let o=Sn(t);this.setAttribute("aria-label",(t.textContent??"").trim()),this.replaceChildren(...n.map(r=>{let i=document.createElement("button");return i.type="button",i.setAttribute("role","menuitem"),i.textContent=r,i.dataset.command=`${r.toLowerCase()} ${o}`,i})),this.#e=t,t.setAttribute("aria-expanded","true"),this.classList.add("qv-open"),C&&this.showPopover(),this.#i(),this.querySelector("button")?.focus({preventScroll:!0}),document.addEventListener("pointerdown",this.#s,!0),window.addEventListener("scroll",this.#o,{passive:!0}),window.addEventListener("resize",this.#o)}close({restoreFocus:t=!0}={}){let n=this.#e;if(!n)return;this.#e=null,n.setAttribute("aria-expanded","false");let o=this.contains(document.activeElement);this.classList.remove("qv-open"),C&&this.matches(":popover-open")&&this.hidePopover(),this.replaceChildren(),document.removeEventListener("pointerdown",this.#s,!0),window.removeEventListener("scroll",this.#o),window.removeEventListener("resize",this.#o),t&&o&&n.isConnected&&n.focus({preventScroll:!0})}closeIfStale(){this.#e&&(!this.#e.isConnected||k(this.#e))&&this.close({restoreFocus:!1})}#t(t){let n=this.#e;if(!n)return;let o=Sn(n),r={};n.dataset.elementid&&(r[o]=n.dataset.elementid),this.close({restoreFocus:!1}),v(t.dataset.command??"",r)}#n=t=>{let n=t.target instanceof Element?t.target.closest('[role="menuitem"]'):null;n&&this.#t(n)};#r=t=>{let n=[...this.querySelectorAll('[role="menuitem"]')],o=n.indexOf(document.activeElement),r=null;switch(t.key){case"Escape":t.preventDefault(),this.close();return;case"Tab":this.close({restoreFocus:!1});return;case"ArrowDown":r=(o+1)%n.length;break;case"ArrowUp":r=(o-1+n.length)%n.length;break;case"Home":r=0;break;case"End":r=n.length-1;break;default:return}t.preventDefault(),n[r]?.focus()};#s=t=>{let n=t.target instanceof Node?t.target:null;n&&(this.contains(n)||this.#e?.contains(n))||this.close({restoreFocus:!1})};#o=()=>{this.closeIfStale(),this.#e&&this.#i()};#i(){if(!this.#e)return;let t=this.#e.getBoundingClientRect(),{offsetWidth:n,offsetHeight:o}=this,r=t.bottom+Zt;r+o>window.innerHeight-X&&t.top-Zt-o>=X&&(r=t.top-Zt-o);let i=Math.max(X,Math.min(t.left,window.innerWidth-n-X));this.style.top=`${Math.max(X,r)}px`,this.style.left=`${i}px`}};customElements.define("qv-player",ut);customElements.define("qv-output",St);customElements.define("qv-command-bar",ht);customElements.define("qv-verb-menu",Et);customElements.define("qv-pane",ot);customElements.define("qv-more",bt);window.QuestUI=yn;window.sendCommand=(e,t)=>{v(e,t)};window.ASLEvent=L;window.canSendCommand=!0;window.notifyQuestUITurn=e=>{let t=a()?.output;e?(w(!1,{restoreFocus:!1}),t?.beginTurn(),t?.setAttribute("aria-busy","true"),y("turnStarted")):(t?.removeAttribute("aria-busy"),y("turnEnded"),a()?.commandBar?.focusInput(),a()?.focusFirstChoice())};window.resetQuestUIState=()=>{ee(),R(),ze(),Me(),Ae(),oe(),ve(),Ne(),gt()};document.addEventListener("keydown",e=>{!s.waiting||e.repeat||["Tab","Shift","Control","Alt","Meta"].includes(e.key)||e.target instanceof Element&&e.target.closest("input, textarea, select, [contenteditable], dialog")||(e.preventDefault(),J())});window.addEventListener("beforeunload",e=>{!s.hasUnsavedProgress||!s.canSave||!a()||(e.preventDefault(),e.returnValue="")});document.addEventListener("click",e=>{!s.waiting||!s.continueOnClick||e.target instanceof Element&&e.target.closest("a, button, input, textarea, select, summary, dialog")||J()});var S=()=>a()?.output;function En(){let e=a()?.saveButton;e&&(e.disabled=s.turnPending)}var io=()=>{},Ln={"#gamePanes":"panes","#location":"location","#txtCommandDiv":"command-bar"},ao={addTextAndScroll(e){S()?.addText(e),S()?.scrollToEnd()},createNewDiv:e=>{S()?.setAlignment(e)},bindMenu:(e,t,n,o)=>le(e,t,o),showMenu:Je,showQuestion:Ze,beginWait:Ke,setTurnPending(e){s.turnPending=e,En(),h()},beginPause:Ge,updateLocation:Yt,setGameName(e){document.title=e},clearScreen:()=>S()?.clearScreen(),panesVisible:e=>a()?.setVisible("panes",e),updateStatus:Ce,setBackground:e=>a()?.setTokens({"--qv-bg":e}),setForeground:io,updateList:he,updateCompass:Te,updateObjectLinks:e=>a()?.updateLinks("object",e),gameFinished(){s.gameFinished=!0,R(),s.waiting=!1,O("finished",!0),h()},requestNextTimerTick:We,uiShow:e=>a()?.setVisible(Ln[e]??"",!0),uiHide:e=>a()?.setVisible(Ln[e]??"",!1),setCompassDirections:Jt,setInterfaceString:_t,setPanelContents:yt,loadHtml:e=>S()?.loadHtml(e),markScrollPosition:()=>S()?.markScrollPosition(),scrollToEnd:()=>S()?.scrollToEnd(),requestSave(){GameSaver.saveRequested()},start(){a()?.saveButton?.addEventListener("click",()=>{WebPlayer.onSaveClick?WebPlayer.onSaveClick():GameSaver.save()}),En(),B(),kt(),a()?.commandBar?.focusInput()},resetOutput(){S()?.reset(),R(),s.hasUnsavedProgress=!1},useManualClock:$e,getOutputHtml:()=>S()?.getHtml()??"",getLocation:()=>a()?.location?.textContent?.trim()??"",gameSaved(){S()?.addText(`<span data-qv-save-notice>${WebPlayer.chromeStrings?.GameSaved??"Game saved."}<br></span>`),s.hasUnsavedProgress=!1},clearUnsavedProgress(){s.hasUnsavedProgress=!1},setCanSave(e){s.canSave=e},waitEnded:Wt,pauseEnded:$t,dismissPrompt:Ye,beginSoundWait(){let e=!a()?.commandBar?.hidden;return s.soundWait=!0,O("sound",!0),e},endSoundWait(){s.soundWait=!1,setTimeout(async()=>{O("sound",!1),await WebPlayer.uiEndWait()},100)},rememberImageSize:vn,setAnimateScroll(e){s.animateScroll=e}};window.QuestPlayerUis=window.QuestPlayerUis??{};window.QuestPlayerUis.v2=ao;})();
1
+ "use strict";(()=>{var s={autoScroll:!0,warnedAboutScript:!1,animateScroll:!0,fadePreviousOutput:!1,continueOnClick:!1,commandPlaceholder:null,commands:[],commandsInExitStrip:!1,compassDirections:[],interfaceStrings:new Map,gameFinished:!1,soundWait:!1,waiting:!1,pausing:!1,inDialog:!1,turnPending:!0,hasUnsavedProgress:!1,canSave:!1},V=new Map;function ee(e,t){if(typeof t!="function")return;let n=V.get(e);n||V.set(e,n=new Set),n.add(t)}function ne(e,t){V.get(e)?.delete(t)}function E(e,t){for(let n of V.get(e)??[])try{n(t)}catch(o){console.error(o)}}function oe(){s.autoScroll=!0,s.warnedAboutScript=!1,s.fadePreviousOutput=!1,s.continueOnClick=!1,s.commandPlaceholder=null,s.interfaceStrings.clear(),s.compassDirections=[],s.commands=[],s.commandsInExitStrip=!1,s.gameFinished=!1,s.soundWait=!1,s.waiting=!1,s.pausing=!1,s.inDialog=!1,s.turnPending=!0,s.hasUnsavedProgress=!1,V.clear()}var xn={inventory:"inventoryChanged",objects:"objectsChanged",exits:"exitsChanged",status:"statusChanged"},ot={inventory:[],objects:[],exits:[],status:[]},qt=new Set;function re(){return structuredClone(ot)}function se(){ot={inventory:[],objects:[],exits:[],status:[]},qt.clear()}function P(e,t){if(qt.has(e)&&JSON.stringify(t)===JSON.stringify(ot[e]))return;qt.add(e),ot[e]=t;let n=structuredClone(t);E(xn[e],e==="exits"?{exits:n}:{items:n})}function ie(e){return{text:String(e.Text??""),name:String(e.ElementName??""),elementId:String(e.ElementId??""),verbs:(e.Verbs??[]).map(String)}}var C=typeof HTMLElement.prototype.showPopover=="function";function H(e){for(let t of e.querySelectorAll("a.cmdlink, a[data-qv-event]"))t.hasAttribute("tabindex")||(t.tabIndex=0),t.setAttribute("role","button"),t.classList.contains("elementmenu")&&(t.setAttribute("aria-haspopup","menu"),t.setAttribute("aria-expanded","false")),t.toggleAttribute("aria-disabled",t.classList.contains("disabled"));for(let t of e.querySelectorAll("[data-qv-popup]"))t.setAttribute("aria-controls",t.dataset.qvPopup??""),t.setAttribute("aria-expanded","false")}function le(e){for(let t of e.querySelectorAll("[data-qv-popup-content].qv-popup-open"))t.classList.remove("qv-popup-open");for(let t of e.querySelectorAll('[aria-expanded="true"]'))t.setAttribute("aria-expanded","false")}function M(e,t){e.classList.toggle("disabled",!t),t?e.removeAttribute("aria-disabled"):e.setAttribute("aria-disabled","true")}var k=e=>e.classList.contains("disabled");function rt(e){e.setAttribute("data-qv-deactivated",""),M(e,!1)}function ae(e){return Array.isArray(e)?e.map(String):[]}function ce(e,t,n){if(t==="object"){let o=n&&typeof n=="object"?n:{};for(let r of e.querySelectorAll("a.elementmenu")){let i=o[r.dataset.elementid??""];i&&(r.dataset.verbs=String(i)),M(r,!!i)}}else if(t==="exit"){let o=ae(n);for(let r of e.querySelectorAll("a.exitlink"))M(r,o.includes(r.dataset.elementid??""))}else if(t==="command"){let o=ae(n);for(let r of e.querySelectorAll("a.commandlink:not([data-qv-deactivated])")){let i=r.dataset.elementid??"";M(r,i===""||o.includes(i))}}}function ue(e,t,n){let o=document.getElementById(e);o&&(o.classList.add("cmdlink","elementmenu"),o.dataset.verbs=t,o.dataset.elementid||(o.dataset.elementid=n),H(o.parentElement??o))}function de(e,t){let n=e.target instanceof Element?e.target:null;if(!n)return;let o=n.closest("[data-qv-popup]");if(o){e.preventDefault(),An(o);return}let r=n.closest("[data-qv-direction]");if(r){r.disabled||v(r.dataset.qvDirection??"");return}let i=n.closest("[data-qv-command]");if(i){v(i.dataset.qvCommand??"");return}let l=n.closest(".qv-pane-verb");if(l){he(l);return}let d=n.closest(".qv-pane-item");if(d){fe(d);return}let u=n.closest("[data-qv-popup-content]");u&&pe(u);let c=n.closest("a");c&&(c.matches(".cmdlink, [data-qv-event]")?Tn(e,c,t):c.hasAttribute("href")&&Mn(e,c))}function Tn(e,t,n){if(t.dataset.qvEvent!==void 0){if(e.preventDefault(),k(t))return;if(t.dataset.qvEvent==="ShowMenuResponse")for(let o of t.ownerDocument.querySelectorAll('a[data-qv-event="ShowMenuResponse"]'))M(o,!1);w(t.dataset.qvEvent,t.dataset.qvParam??"")}else if(t.classList.contains("elementmenu"))e.preventDefault(),k(t)||n?.toggle(t);else if(t.classList.contains("exitlink"))e.preventDefault(),k(t)||v(t.dataset.command??"");else if(t.classList.contains("commandlink")){if(e.preventDefault(),k(t)||!Q())return;t.dataset.deactivateonclick==="true"&&rt(t),v(t.dataset.command??"")}}function Mn(e,t){let n=t.getAttribute("href")??"";n.startsWith("#")||/^\s*javascript:/i.test(n)||(e.preventDefault(),window.open(t.href,"_blank","noopener"))}function me(e){if(e.key!=="Enter"&&e.key!==" ")return;let t=e.target instanceof HTMLAnchorElement?e.target:null;t?.matches(".cmdlink, [data-qv-event]")&&(e.preventDefault(),t.click())}function Cn(e){let t=document.getElementById(e.dataset.qvPopup??"");return t?.hasAttribute("data-qv-popup-content")?t:null}function An(e){let t=Cn(e);if(t){if(t.classList.contains("qv-popup-open")){pe(t);return}C&&!t.popover&&(t.popover="auto",t.addEventListener("beforetoggle",n=>{n.newState==="closed"&&xt(t,!1)})),xt(t,!0),C&&t.showPopover()}}function pe(e){C&&e.matches(":popover-open")&&e.hidePopover(),xt(e,!1)}function xt(e,t){e.classList.toggle("qv-popup-open",t);for(let n of document.querySelectorAll(`[data-qv-popup="${CSS.escape(e.id)}"]`))n.setAttribute("aria-expanded",String(t))}var Mt=["inventory","objects","status","compass","commands","customstatus"],Pn={InventoryLabel:"inventory",PlacesObjectsLabel:"objects",StatusLabel:"status",CompassLabel:"compass"},st=class extends HTMLElement{#e;#t;#n;connectedCallback(){this.#e||(this.dataset.qvPart="pane",this.#e=document.createElement("details"),this.#e.open=!0,this.#t=document.createElement("summary"),this.#t.className="qv-pane-heading",this.#t.textContent=this.getAttribute("label")??"",this.#n=document.createElement("div"),this.#n.className="qv-pane-body",this.#n.append(...this.childNodes),this.#e.append(this.#t,this.#n),this.append(this.#e))}get name(){return this.dataset.qvPane??""}get body(){return this.#n}setLabel(t){this.#t.innerHTML=t}setContent(t){this.#n.innerHTML=t,H(this.#n)}};function h(e){return a()?.querySelector(`qv-pane[data-qv-pane="${CSS.escape(e)}"]`)??null}var kn={inventory:"inventory",placesobjects:"objects"};function ge(e,t){let n=kn[e];if(!n)return;let o=new Set(s.compassDirections),r=Object.values(t).map(u=>JSON.parse(u)).filter(u=>e!=="placesobjects"||!o.has(u.Text));P(n,r.map(ie));let i=h(n);if(!i)return;let l=I.get(n);l!==void 0&&!r.some(u=>Tt(u)===l)&&I.delete(n);let d=document.createElement("ul");if(d.className="qv-pane-list",r.forEach((u,c)=>d.append(Hn(n,u,`qv-${n}-verbs-${c}`))),d.childElementCount)i.body.replaceChildren(d);else{let u=document.createElement("p");u.className="qv-pane-empty",u.innerHTML=s.interfaceStrings.get(n==="inventory"?"InventoryEmptyLabel":"PlacesObjectsEmptyLabel")??s.interfaceStrings.get("EmptyListLabel")??"",i.body.replaceChildren(u)}a()?.verbMenu?.closeIfStale()}var I=new Map,Tt=e=>e.ElementId||e.ElementName;function be(){I.clear(),Ct=[]}function Hn(e,t,n){let o=document.createElement("li"),r=document.createElement("button");r.type="button",r.className="qv-pane-item",r.innerHTML=t.Text,r.dataset.qvKey=Tt(t),o.append(r);let i=(t.Verbs??[]).map(String).map(u=>u.trim()).filter(Boolean);if(!i.length)return o;let l=document.createElement("div");l.id=n,l.className="qv-pane-verbs",l.setAttribute("role","group"),l.setAttribute("aria-label",r.textContent?.trim()??"");for(let u of i){let c=document.createElement("button");c.type="button",c.className="qv-pane-verb",c.textContent=u,c.dataset.command=`${u.toLowerCase()} ${t.ElementName}`,c.dataset.qvName=t.ElementName,t.ElementId&&(c.dataset.elementid=t.ElementId),l.append(c)}let d=I.get(e)===Tt(t);return l.hidden=!d,r.setAttribute("aria-expanded",String(d)),r.setAttribute("aria-controls",n),o.append(l),o}function fe(e){let t=e.closest("qv-pane"),n=e.nextElementSibling;if(!t||!n?.classList.contains("qv-pane-verbs"))return;let o=n.hidden;for(let r of t.body.querySelectorAll('.qv-pane-item[aria-expanded="true"]'))r.setAttribute("aria-expanded","false"),r.nextElementSibling.hidden=!0;o?(n.hidden=!1,e.setAttribute("aria-expanded","true"),I.set(t.name,e.dataset.qvKey??""),n.scrollIntoView({block:"nearest"})):I.delete(t.name)}function he(e){let t=e.dataset.qvName??"",n={};e.dataset.elementid&&(n[t]=e.dataset.elementid),v(e.dataset.command??"",n)}function Se(e){let t=(Array.isArray(e)?e.map(String):String(e??"").split(";")).filter(o=>o.trim());s.commands=t.map(o=>{let[r,i]=o.split(":");return{label:r.trim(),command:(i??r).trim().toLowerCase()}});let n=o=>o.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;");h("commands")?.setContent(s.commands.map(({label:o,command:r})=>`<a class="cmdlink commandlink" data-elementid="" data-command="${n(r)}">${n(o)}</a>`).join(" ")),f()}function ye(e,t){e==="map"||e!=="customstatus"&&Mt.includes(e)||h(e)?.setContent(t)}function Ee(e,t,n){let o=a()?.panes;if(!e||e==="map"||!o||h(e))return;let r=document.createElement("qv-pane");r.dataset.qvPane=e,r.setAttribute("label",t??e),o.append(r),r.setContent(n??"")}var Ct=[];function Le(e){Ct=Array.isArray(e)?e.map(String):String(e??"").split(";"),At()}function At(){let e=a()?.panes;if(e)for(let t of[...Ct].reverse()){let n=h(t);n&&e.prepend(n)}}function we(e,t){let n=Pn[e];return n?(h(n)?.setLabel(t),!0):!1}function it(){return!!a()?.panes?.classList.contains("qv-drawer-open")}function q(e,{restoreFocus:t=!0}={}){let n=a(),o=n?.panes,r=n?.panesButton;!o||!r||e===it()||(o.classList.toggle("qv-drawer-open",e),r.setAttribute("aria-expanded",String(e)),e?(document.addEventListener("pointerdown",ve,!0),o.querySelector('summary, button, a[href], [tabindex="0"]')?.focus()):(document.removeEventListener("pointerdown",ve,!0),t&&o.contains(document.activeElement)&&r.focus()))}function ve(e){let t=a(),n=e.target instanceof Node?e.target:null;!n||t?.panes?.contains(n)||t?.panesButton?.contains(n)||t?.verbMenu?.contains(n)||q(!1,{restoreFocus:!1})}var In=["northwest","north","northeast","west","east","southwest","south","southeast","up","down","in","out"],xe=[315,0,45,270,90,225,180,135,null,null,null,null],qe="http://www.w3.org/2000/svg",Pt=[[1,1],[1,2],[1,3],[2,1],[2,3],[3,1],[3,2],[3,3]],W=[];function at(){return s.compassDirections.length===12?s.compassDirections:In}function Te(e){let t=at()[e];return e===10?kt(s.interfaceStrings.get("InButtonLabel"))||t:e===11&&kt(s.interfaceStrings.get("OutButtonLabel"))||t}function kt(e){if(!e)return"";let t=document.createElement("template");return t.innerHTML=e,t.content.textContent?.trim()??""}function Me(e,t){let n=at()[e],o=document.createElement("button");o.type="button",o.className=t,o.dataset.qvDirection=n;let r=xe[e];return r!=null&&o.append(Bn(r)),o}function Bn(e){let t=document.createElementNS(qe,"svg");t.setAttribute("class","qv-direction-arrow"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("aria-hidden","true"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","2"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round");let n=document.createElementNS(qe,"path");return n.setAttribute("d","M12 19V5M5 12l7-7 7 7"),n.setAttribute("transform",`rotate(${e} 12 12)`),t.append(n),t}function B(){let e=h("compass");if(e){let t=document.createElement("div");t.className="qv-compass-points";let n=document.createElement("div");n.className="qv-compass-others",at().forEach((r,i)=>{let l=Me(i,"qv-compass-button"),d=Te(i);l.setAttribute("aria-label",d),l.title=d,xe[i]==null&&l.append(d),l.disabled=!W.includes(r),Pt[i]?(l.style.gridRow=String(Pt[i][0]),l.style.gridColumn=String(Pt[i][1]),t.append(l)):n.append(l)});let o=document.createElement("div");o.className="qv-compass",o.append(t,n),e.body.replaceChildren(o)}f()}function Ce(e){W=String(e??"").split("/").filter(Boolean),P("exits",[...W]),B()}function Ae(){W=[]}function f(){let e=a(),t=e?.exits;if(!e||!t)return;let n=h("compass"),o=!!n&&!n.hidden&&!e.panes?.hidden,r=!s.turnPending&&!s.waiting&&!s.pausing&&!s.inDialog&&!s.gameFinished,i=[];o&&r&&at().forEach((u,c)=>{if(!W.includes(u))return;let g=Me(c,"qv-exit");g.append(Te(c)),i.push(g)});let l=h("commands");s.commandsInExitStrip&&l&&!l.hidden&&!e.panes?.hidden&&r&&s.commands.forEach(({label:u,command:c},g)=>{let m=document.createElement("button");m.type="button",m.className=g===0&&i.length>0?"qv-exit qv-exit-command qv-exit-command-first":"qv-exit qv-exit-command",m.dataset.qvCommand=c,m.append(u),i.push(m)}),t.replaceChildren(...i),t.setAttribute("aria-label",kt(s.interfaceStrings.get("CompassLabel"))||(WebPlayer.chromeStrings?.CompassLabel??"Compass")),t.classList.toggle("qv-exits-active",i.length>0)}var N=[];function Ht(e){N=Array.isArray(e)?e.filter(t=>t&&typeof t=="object"):[],P("status",N),$()}function ke(e){Ht(String(e??"").split(/\r?\n|<br\s*\/?>/i).filter(t=>t.trim()).map(t=>({text:t})))}function He(){N=[]}function Nn(e){let t=Number(e.value),n=Number(e.max);return e.value==null||e.max==null||!Number.isFinite(t)||!Number.isFinite(n)||n<=0?null:{value:Math.min(Math.max(t,0),n),max:n}}var Dn=0;function Pe(e,t){let n=document.createElement(t);n.className="qv-status-item",e.name&&(n.dataset.qvStatus=String(e.name));let o=document.createElement("span");o.className="qv-status-text",o.id=`qv-status-${++Dn}`,o.innerHTML=String(e.text??""),n.append(o);let r=Nn(e);if(r){let i=document.createElement("span");i.className="qv-status-meter",i.setAttribute("role","meter"),i.setAttribute("aria-valuemin","0"),i.setAttribute("aria-valuemax",String(r.max)),i.setAttribute("aria-valuenow",String(r.value)),i.setAttribute("aria-labelledby",o.id);let l=document.createElement("span");l.className="qv-status-meter-fill",l.style.width=`${r.value/r.max*100}%`,i.append(l),n.append(i)}return n}function $(){let e=a(),t=e?.statusBar??null,n=!!t&&!t.hidden&&!e?.hasAttribute("data-qv-gamebook"),o=n?N.filter(l=>l.pinned):[],r=n?N.filter(l=>!l.pinned):N,i=h("status");if(i){let l=document.createElement("ul");l.className="qv-status-list",l.append(...r.map(d=>Pe(d,"li"))),i.body.replaceChildren(l),i.hasAttribute("data-qv-empty")!==(r.length===0)&&(i.toggleAttribute("data-qv-empty",r.length===0),e?.updatePanesButton())}t&&(t.replaceChildren(...o.map(l=>Pe(l,"span"))),t.classList.toggle("qv-status-bar-active",o.length>0)),e?.updateTopbar()}var lt=document.currentScript instanceof HTMLScriptElement?document.currentScript.src:"",It=null,D=null,ct=null,z=[],ut=0,Bt=!0,K=!1,Nt="header",j=(e,t)=>WebPlayer.chromeStrings?.[e]??t,On={gridSquareClicked:(e,t)=>{w("JS_GridSquareClick",`${e};${t}`)},animate:()=>s.animateScroll&&!matchMedia("(prefers-reduced-motion: reduce)").matches,strings:()=>({map:j("MapLabel","Map"),zoomIn:j("MapZoomIn","Zoom in"),zoomOut:j("MapZoomOut","Zoom out")})};function Rn(){return window.QuestUIV2Map?Promise.resolve():(It??=new Promise((e,t)=>{let n=new URL(lt?"map.js":"v2/map.js",lt||document.baseURI);lt&&(n.search=new URL(lt).search);let o=document.createElement("script");o.src=n.href,o.onload=()=>e(),o.onerror=()=>{It=null,t(new Error(`Failed to load ${n.href}`))},document.head.append(o)}),It)}function Ie(){return a()?.map?.querySelector(".qv-map-view")??null}function Un(){let e=Ie();if(!e||!window.QuestUIV2Map)return;(!D||ct!==e)&&(D=window.QuestUIV2Map.create(e,On),ct=e);let t=z;z=[];for(let[n,o]of t)try{D.call(n,o)}catch(r){console.error(r)}}function Dt(e,t){if(a()?.map){if(e==="show"){let n=typeof t[0]=="number"?t[0]:parseFloat(String(t[0]));ut=Number.isFinite(n)?n:0,x()}if(D&&ct===Ie()&&z.length===0){D.call(e,t);return}z.push([e,t]),Rn().then(Un,n=>console.error(n))}}function Be(e){Bt=e,x()}function Ne(e){e!=="header"&&e!=="panes"||(Nt=e,x())}function x(){let e=a(),t=e?.map;if(!e||!t)return;t.hidden=!(ut>0&&Bt),t.style.setProperty("--qv-map-height",`${ut}px`),t.classList.toggle("qv-map-collapsed",K);let n=Fn(t),o=e.mapButton;if(o){o.hidden=t.hidden||n||!e.hasAttribute("data-qv-narrow");let r=o.querySelector(".qv-button-label");r&&(r.textContent=j("MapLabel","Map")),o.setAttribute("aria-expanded",String(!K))}e.updateTopbar()}function Fn(e){let t=a();if(!t)return!1;let n=Nt==="panes"&&t.layout!=="none"&&!!t.panes&&!t.panes.hidden,o=h("map");if(n&&!o&&t.panes&&(o=document.createElement("qv-pane"),o.dataset.qvPane="map",o.setAttribute("label",j("MapLabel","Map")),t.panes.prepend(o),At()),n&&o)e.parentElement!==o.body&&o.body.append(e),o.hidden=e.hidden;else{let r=t.querySelector(".qv-header");r&&e.parentElement!==r&&r.append(e),o&&(o.hidden=!0)}return n}function De(){K=!K,x()}function Oe(){D=null,ct=null,z=[],ut=0,Bt=!0,K=!1,Nt="header"}var Ot="questviva-colour-scheme",Vn=["system","light","dark"],G=Qn(),Ue=typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)"):null;function Qn(){try{let e=window.electronPlayerSettings?window.electronPlayerSettings.getColourScheme():localStorage.getItem(Ot);if(e&&Vn.includes(e))return e}catch{}return"system"}function Wn(e){try{window.electronPlayerSettings?window.electronPlayerSettings.setColourScheme(e).catch(()=>{}):e==="system"?localStorage.removeItem(Ot):localStorage.setItem(Ot,e)}catch{}}function $n(e){return!e.style.getPropertyValue("--qv-bg")}function jn(e){let t=document.createElement("span");t.style.color=e.style.getPropertyValue("--qv-bg"),t.hidden=!0,e.append(t);let n=/rgba?\(([\d.]+),\s*([\d.]+),\s*([\d.]+)/.exec(getComputedStyle(t).color);if(t.remove(),!n)return!1;let[o,r,i]=n.slice(1,4).map(l=>{let d=Number(l)/255;return d<=.03928?d/12.92:((d+.055)/1.055)**2.4});return .2126*o+.7152*r+.0722*i<.18}function Y(e){let t=$n(e),n=t?G==="dark"||G==="system"&&!!Ue?.matches:jn(e);e.setAttribute("data-qv-scheme",n?"dark":"light"),e.toggleAttribute("data-qv-fixed-scheme",!t),document.documentElement.setAttribute("data-qv-scheme",n?"dark":"light");let o=e.querySelector(".qv-scheme");if(o){o.hidden===t&&(o.hidden=!t,t||A(e,!1));for(let r of o.querySelectorAll("[data-qv-scheme-icon]"))r.hidden=r.dataset.qvSchemeIcon!==G;for(let r of o.querySelectorAll("[data-qv-scheme-choice]"))r.setAttribute("aria-checked",String(r.dataset.qvSchemeChoice===G))}}function zn(e,t){G=t,Wn(t),Y(e)}function Ft(e){return e.querySelector(".qv-scheme-menu")}function Rt(e){return[...e.querySelectorAll("[data-qv-scheme-choice]")]}function Re(e){let t=Ft(e),n=e.querySelector(".qv-scheme-button");if(!t||!n)return;t.hidden=!1,n.setAttribute("aria-expanded","true"),(Rt(t).find(r=>r.getAttribute("aria-checked")==="true")??Rt(t)[0])?.focus()}function A(e,t){let n=Ft(e),o=e.querySelector(".qv-scheme-button");!n||n.hidden||(n.hidden=!0,o?.setAttribute("aria-expanded","false"),t&&o?.focus())}var Ut=null;Ue?.addEventListener("change",()=>{Ut?.isConnected&&Y(Ut)});function Fe(e){Ut=e,Y(e);let t=e.querySelector(".qv-scheme-button"),n=Ft(e);!t||!n||(t.addEventListener("click",()=>{n.hidden?Re(e):A(e,!0)}),t.addEventListener("keydown",o=>{(o.key==="ArrowDown"||o.key==="ArrowUp")&&(o.preventDefault(),Re(e))}),n.addEventListener("click",o=>{let r=o.target instanceof Element?o.target.closest("[data-qv-scheme-choice]"):null;r&&(zn(e,r.dataset.qvSchemeChoice),A(e,!0))}),n.addEventListener("keydown",o=>{let r=Rt(n),i=r.indexOf(document.activeElement),l=-1;if(o.key==="ArrowDown")l=(i+1)%r.length;else if(o.key==="ArrowUp")l=(i-1+r.length)%r.length;else if(o.key==="Home")l=0;else if(o.key==="End")l=r.length-1;else if(o.key==="Escape"){o.preventDefault(),o.stopPropagation(),A(e,!0);return}else if(o.key==="Tab"){A(e,!1);return}l>=0&&(o.preventDefault(),r[l]?.focus())}),document.addEventListener("pointerdown",o=>{!n.hidden&&o.target instanceof Node&&!n.contains(o.target)&&!t.contains(o.target)&&A(e,!1)}),n.addEventListener("focusout",o=>{o.relatedTarget instanceof Node&&!n.contains(o.relatedTarget)&&o.relatedTarget!==t&&A(e,!1)}))}var Ve=["sidepanes","nopanes","bottombar"],Kn=900,Gn=new Set(["--qv-font-size","--qv-output-width","--qv-padding-top","--qv-padding-bottom","--qv-padding-left","--qv-padding-right","--qv-menu-font-size","--qv-radius","--qv-space"]),dt=class extends HTMLElement{#e=!1;#t="sidepanes";#n="sidepanes";connectedCallback(){if(this.#e)return;this.#e=!0,this.addEventListener("click",n=>de(n,this.verbMenu)),this.addEventListener("keydown",me);for(let n of this.querySelectorAll(".qv-panes-button"))n.addEventListener("click",()=>q(!it()));this.mapButton?.addEventListener("click",De),Fe(this),new ResizeObserver(()=>this.#o()).observe(this),this.panes?.addEventListener("keydown",n=>{n.key==="Escape"&&it()&&!this.verbMenu?.isOpen&&(n.preventDefault(),q(!1))});let t=this.querySelector(".qv-toolbar");t&&(new MutationObserver(()=>{We(t),this.updateTopbar()}).observe(t,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["style","hidden"]}),We(t)),this.addEventListener("pointerover",n=>{let o=n.target instanceof Element?n.target.closest("button"):null;if(!o?.querySelector(":scope > .qv-icon"))return;let r=o.querySelector(".qv-button-label")?.textContent?.trim()||o.getAttribute("aria-label");r&&(o.title=r)}),this.#o(),this.updatePanesButton()}get topbar(){return this.querySelector(".qv-topbar")}get saveButton(){return this.querySelector("#cmdSave")}get panes(){return this.querySelector('[data-qv-part="panes"]')}get exits(){return this.querySelector('[data-qv-part="exits"]')}get statusBar(){return this.querySelector('[data-qv-part="status-bar"]')}get panesButton(){return this.querySelector(this.layout==="sheet"?".qv-footer .qv-panes-button":".qv-topbar .qv-panes-button")}get layout(){return this.dataset.qvLayout??"side"}setLayoutPreset(t,n){if(t==="gamebook"){this.toggleAttribute("data-qv-gamebook",!0),this.#t=this.#n="nopanes",this.setVisible("command-bar",!1),this.setVisible("location",!1),this.#o();return}Ve.includes(t)&&(this.removeAttribute("data-qv-gamebook"),this.#t=t,this.#n=n!=null&&Ve.includes(n)?n:t,this.#o())}#o(){let t=this.clientWidth<Kn;t!==this.hasAttribute("data-qv-narrow")&&(this.toggleAttribute("data-qv-narrow",t),x());let n=t?this.#n:this.#t,o=n==="nopanes"?"none":n==="bottombar"?"sheet":t?"drawer":"side";this.dataset.qvLayout!==o&&(q(!1,{restoreFocus:!1}),this.toggleAttribute("data-qv-layout-changing",!0),this.dataset.qvLayout=o,x(),requestAnimationFrame(()=>requestAnimationFrame(()=>this.removeAttribute("data-qv-layout-changing"))),f(),this.updateTopbar())}updateTopbar(){let t=this.topbar;if(!t)return;let n=this.location,o=[...t.querySelectorAll(".qv-toolbar > button, .qv-toolbar > .qv-scheme:not([hidden]) > button")].some(l=>!l.hidden&&l.style.display!=="none"&&getComputedStyle(l).display!=="none"),r=this.statusBar,i=!!r&&!r.hidden&&r.classList.contains("qv-status-bar-active")&&getComputedStyle(r).display!=="none";t.hidden=(!n||n.hidden)&&!o&&!i}focusFirstChoice(){if(!this.hasAttribute("data-qv-gamebook"))return;let t=document.activeElement;if(t&&t!==document.body&&this.contains(t)&&!t.closest(".qv-hiding")&&!t.classList.contains("disabled"))return;[...this.querySelectorAll('[data-qv-part="output"] [data-qv-sections] a.commandlink:not(.disabled)')].find(o=>!o.closest(".qv-hiding"))?.focus({preventScroll:!0})}get verbMenu(){return this.querySelector("qv-verb-menu")}updateLinks(t,n){ce(this,t,n),this.verbMenu?.closeIfStale()}get output(){return this.querySelector("qv-output")}get commandBar(){return this.querySelector("qv-command-bar")}get location(){return this.querySelector('[data-qv-part="location"]')}get pictureFrame(){return this.querySelector('[data-qv-part="picture-frame"]')}get map(){return this.querySelector('[data-qv-part="map"]')}get mapButton(){return this.querySelector(".qv-map-button")}get frame(){return this.querySelector('[data-qv-part="border"]')}setVisible(t,n){switch(t){case"output":this.#r(this.output,!n);break;case"command-bar":this.#r(this.commandBar,!n);break;case"location":this.#r(this.location,!n),this.updateTopbar();break;case"border":this.frame?.classList.toggle("qv-borderless",!n);break;case"picture-frame":this.#r(this.pictureFrame,!n);break;case"exits":this.#r(this.exits,!n);break;case"map":Be(n);break;case"status-bar":this.#r(this.statusBar,!n);break;case"panes":this.#r(this.panes,!n),n||q(!1,{restoreFocus:!1}),x(),this.updatePanesButton();break;default:(Mt.includes(t)||h(t))&&(this.#r(h(t),!n),this.updatePanesButton())}f(),$()}updatePanesButton(){let t=this.panes;if(!t)return;let n=[...t.querySelectorAll("qv-pane")].some(o=>!o.hidden&&!o.hasAttribute("data-qv-empty"));for(let o of this.querySelectorAll(".qv-panes-button"))o.hidden=t.hidden||!n;this.updateTopbar()}#r(t,n){t&&(t.hidden=n)}setTokens(t){for(let[n,o]of Object.entries(t)){if(!n.startsWith("--"))continue;let r=o==null?"":String(o).trim();if(r===""){this.style.removeProperty(n);continue}Gn.has(n)&&/^-?(\d+\.?\d*|\.\d+)$/.test(r)&&(r+="px"),this.style.setProperty(n,r)}this.toggleAttribute("data-qv-own-accent",!!this.style.getPropertyValue("--qv-accent")),this.toggleAttribute("data-qv-own-background",["--qv-bg","--qv-bg-light","--qv-bg-dark"].some(n=>!!this.style.getPropertyValue(n))),this.toggleAttribute("data-qv-own-border",["--qv-border-colour","--qv-border-colour-light","--qv-border-colour-dark"].some(n=>!!this.style.getPropertyValue(n))),Y(this),this.updateTopbar()}setLocation(t){let n=this.location;n&&(n.innerHTML=t,n.classList.toggle("qv-empty",t.trim()===""))}},Qe="http://www.w3.org/2000/svg";function We(e){let t=e.querySelector("#cmdRestart");if(!t||t.querySelector(".qv-icon"))return;let n=document.createElement("span");n.className="qv-button-label",n.textContent=t.textContent;let o=document.createElementNS(Qe,"svg");o.setAttribute("class","qv-icon"),o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("aria-hidden","true");for(let r of["M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8","M3 3v5h5"]){let i=document.createElementNS(Qe,"path");i.setAttribute("d",r),o.append(i)}t.replaceChildren(o,n)}function a(){return document.querySelector("qv-player")}var mt=0,Vt=0,_,$e=!1;function je(e){Vt=e,Yn()}function Qt(){return O(),mt}function ze(){$e=!0,O()}function O(){_!==void 0&&(clearInterval(_),_=void 0)}function Yn(){$e||_!==void 0||(mt=0,_=setInterval(async()=>{mt++,Vt>0&&mt>=Vt&&await WebPlayer.uiTick(Qt())},1e3))}function Q(){return window.canSendCommand&&!s.gameFinished&&!s.soundWait&&!s.waiting&&!s.pausing&&!s.inDialog}function v(e,t){if(!Q())return!1;window.canSendCommand=!1,a()?.output?.markScrollPosition(),s.hasUnsavedProgress=!0;let n=Qt();return setTimeout(()=>{WebPlayer.sendCommand(e,n,t??null)},0),!0}function w(e,t){s.hasUnsavedProgress=!0;let n=""+t;return setTimeout(()=>{WebPlayer.uiSendEvent(e,n)},1),!0}var pt=new Set;function R(e,t){t?pt.add(e):pt.delete(e),a()?.toggleAttribute("data-qv-input-held",pt.size>0)}function Ge(){pt.clear(),clearTimeout(ft),J=null}function Ye(){s.waiting=!0,f(),a()?.commandBar?.setMode("continue"),a()?.output?.markScrollPosition()}function Z(){s.waiting&&(s.waiting=!1,a()?.commandBar?.setMode("none"),s.hasUnsavedProgress=!0,sendEndWait())}function $t(){f(),!s.waiting&&ht()}var ft;function _e(e){s.pausing=!0,f(),R("pause",!0),clearTimeout(ft),ft=setTimeout(Jn,e)}function Jn(){s.pausing&&(s.pausing=!1,sendEndPause())}function jt(){f(),!s.pausing&&(R("pause",!1),ht())}function Je(){s.waiting&&(s.waiting=!1,$t()),s.pausing&&(clearTimeout(ft),s.pausing=!1,jt()),J?.()}function ht(){let e=a()?.commandBar;!e||s.gameFinished||s.waiting||s.inDialog||(e.setMode("input"),e.focusInput())}var Wt={cancel:"Cancel",yes:"Yes",no:"No"},Ke=0,J=null;function Ze(e,t,n){let o=a();if(!o)return;let r=++Ke;o.querySelector("dialog.qv-dialog")?.remove();let i=document.createElement("dialog");i.className="qv-dialog",i.dataset.qvPart="menu";let l="qv-dialog-caption";i.setAttribute("aria-labelledby",l);let d=document.createElement("div");d.id=l,d.className="qv-dialog-caption",d.innerHTML=e;let u=document.createElement("div");u.className="qv-dialog-choices";let c=!1,g=m=>{c||(c=!0,J=null,i.close(),i.remove(),s.hasUnsavedProgress=!0,setTimeout(async()=>{try{await m()}finally{Ke===r&&(s.inDialog=!1,f(),ht())}},100))};for(let m of t){let y=document.createElement("button");y.type="button",y.textContent=m.label,y.addEventListener("click",()=>g(m.choose)),u.append(y)}if(i.append(d,u),n){let m=document.createElement("button");m.type="button",m.className="qv-dialog-cancel",m.textContent=Wt.cancel,m.addEventListener("click",()=>g(n)),i.append(m)}i.addEventListener("cancel",m=>{m.preventDefault(),n&&g(n)}),i.addEventListener("close",()=>{!c&&i.isConnected&&i.showModal()}),J=()=>{c=!0,J=null,i.close(),i.remove(),s.inDialog=!1,f(),ht()},s.inDialog=!0,f(),o.commandBar?.setMode("none"),o.append(i),i.showModal(),u.querySelector("button")?.focus()}function Xe(e,t,n){let o=Object.entries(t).map(([r,i])=>({label:i,choose:()=>WebPlayer.uiChoice(r)}));Ze(e,o,n?()=>WebPlayer.uiChoiceCancel():null)}function tn(e){Ze(e,[{label:Wt.yes,choose:()=>WebPlayer.uiSetQuestionResponse(!0)},{label:Wt.no,choose:()=>WebPlayer.uiSetQuestionResponse(!1)}],null)}var nn=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches;document.addEventListener("pointerdown",e=>{nn=e.pointerType!=="mouse"&&!(e.target instanceof Element&&e.target.closest(".qv-command-input"))},!0);var vt=class extends HTMLElement{#e;#t;#n;#o;#r="input";#s=[];#i=0;#l="";connectedCallback(){if(this.#t)return;let t=this.#e=document.createElement("form");t.className="qv-command-form",this.#n=document.createElement("span"),this.#n.className="qv-command-prompt",this.#n.setAttribute("aria-hidden","true"),this.#t=document.createElement("input"),this.#t.type="text",this.#t.className="qv-command-input",this.#t.autocomplete="off",this.#t.spellcheck=!1,this.#t.setAttribute("autocapitalize","off"),this.#t.setAttribute("enterkeyhint","send"),this.#t.dataset.chromeKeyAriaLabel="CommandInputLabel",this.#t.setAttribute("aria-label","Type your command"),t.append(this.#n,this.#t),this.#o=document.createElement("button"),this.#o.type="button",this.#o.className="qv-continue",this.#o.hidden=!0,this.#o.addEventListener("click",Z),this.append(t,this.#o),t.addEventListener("submit",n=>{n.preventDefault(),this.#a()}),this.#t.addEventListener("keydown",n=>this.#c(n)),this.updatePlaceholder(),this.updateContinueLabel()}setMode(t){this.#r=t,this.#e.hidden=t!=="input",this.#o.hidden=t!=="continue",t==="continue"&&this.#o.focus({preventScroll:!0})}get input(){return this.#t}focusInput(){if(this.hidden)return;let t=this.#r==="input"?this.#t:this.#r==="continue"?this.#o:null;t===this.#t&&nn||t&&document.activeElement!==t&&t.focus({preventScroll:!0})}setPrompt(t){this.#n.innerHTML=t}setStyle(t){this.#t.style.cssText=t}setPreset(t){(t==="borderless"||t==="shadow")&&(this.dataset.qvPreset=t)}updateContinueLabel(){this.#o.textContent=en(s.interfaceStrings.get("ContinueLabel")??"")||"Continue"}updatePlaceholder(){this.#t.placeholder=s.commandPlaceholder??en(s.interfaceStrings.get("TypeHereLabel")??"")}#a(){let t=this.#t.value;t.length===0||!Q()||v(t)&&(this.#s.at(-1)!==t&&this.#s.push(t),this.#i=this.#s.length,this.#l="",this.#t.value="")}#c(t){if(t.key!=="ArrowUp"&&t.key!=="ArrowDown"||t.altKey||t.ctrlKey||t.metaKey||t.shiftKey)return;let n=this.#i+(t.key==="ArrowUp"?-1:1);if(n<0||n>this.#s.length)return;t.preventDefault(),this.#i===this.#s.length&&(this.#l=this.#t.value),this.#i=n,this.#t.value=n===this.#s.length?this.#l:this.#s[n];let o=this.#t.value.length;this.#t.setSelectionRange(o,o)}};function en(e){let t=document.createElement("template");return t.innerHTML=e,t.content.textContent??""}var zt=new Set;function gt(e,t){let n=typeof e=="number"?e:parseFloat(String(e));return Number.isFinite(n)?n:t}function Xn(e){let t=document.createElement("template");return t.innerHTML=String(e??""),t.content.textContent??""}function on(){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";return e[Math.floor(Math.random()*e.length)]}function to(e){for(let t=e.length-1;t>0;t--){let n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}}function rn(e,t){if(e!=="typewriter"&&e!=="unscramble")return;let n=a()?.output;if(!n)return;let o=Xn(t[0]),r=Math.max(0,gt(t[1],100)),i=e==="unscramble"?Math.max(1,Math.floor(gt(t[2],1))):0,[l,d,u]=(e==="unscramble"?t.slice(3,6):t.slice(2,5)).map(b=>b==null?"":String(b).trim()),c=document.createElement("span");c.className="qv-text-effect",c.dataset.qvEffect=e,l&&c.style.setProperty("font-family",l),d&&c.style.setProperty("color",d),u&&gt(u,0)>0&&c.style.setProperty("font-size",`${gt(u,0)}pt`);let g=document.createElement("span");g.className="qv-text-effect-full",g.textContent=o;let m=document.createElement("span");m.className="qv-text-effect-shown",m.setAttribute("aria-hidden","true"),c.append(g,m);let y=document.createElement("span");if(y.textContent=o,n.addNodes([c,document.createElement("br")],`${y.innerHTML}<br/>`),!(s.animateScroll&&!matchMedia("(prefers-reduced-motion: reduce)").matches)||o===""){Kt(c);return}c.classList.add("qv-text-effect-running");let wt;if(e==="typewriter"){let b=0;wt=()=>(b++,m.textContent=o.substring(0,b)+(b%2===1&&b<o.length?"_":""),b>=o.length)}else{let b=[...o],F=b.flatMap((L,nt)=>/\s/.test(L)?[]:[nt]);to(F);let et=b.map(L=>/\s/.test(L)?L:on());m.textContent=et.join(""),wt=()=>{for(let L=0;L<i&&F.length;L++){let nt=F.pop();et[nt]=b[nt]}for(let L of F)et[L]=on();return m.textContent=et.join(""),F.length===0}}let U={timer:0,finish:()=>{clearInterval(U.timer),zt.delete(U),Kt(c)}};U.timer=window.setInterval(()=>{(!c.isConnected||wt())&&U.finish()},r),zt.add(U)}function Kt(e){let t=e.querySelector(".qv-text-effect-shown");t&&(t.textContent=e.querySelector(".qv-text-effect-full")?.textContent??""),e.classList.remove("qv-text-effect-running")}function bt(){for(let e of[...zt])e.finish()}function sn(e){for(let t of e.querySelectorAll(".qv-text-effect"))Kt(t)}document.addEventListener("keydown",()=>bt(),!0);document.addEventListener("pointerdown",()=>bt(),!0);var Gt=4,an=150,eo=8,St=class extends HTMLElement{#e=null;#t=0;#n=0;#o=0;#r=0;#s=null;#i=null;#l=!1;connectedCallback(){this.#e=this.querySelector("button"),this.#e?.addEventListener("click",this.#d),window.addEventListener("scroll",this.#a,{passive:!0}),window.addEventListener("resize",this.#a,{passive:!0}),this.#s=new ResizeObserver(this.#a);let t=a();for(let n of[t?.output,t?.commandBar,t?.querySelector(".qv-footer"),t?.querySelector(".qv-header")])n&&this.#s.observe(n);this.#i=new MutationObserver(n=>{n.some(o=>o.type==="characterData"||o.addedNodes.length>0)&&(this.#l=!1,this.#r++,this.#a())}),t?.output&&this.#i.observe(t.output,{childList:!0,characterData:!0,subtree:!0}),this.#a()}disconnectedCallback(){this.#e?.removeEventListener("click",this.#d),window.removeEventListener("scroll",this.#a),window.removeEventListener("resize",this.#a),this.#s?.disconnect(),this.#s=null,this.#i?.disconnect(),this.#i=null,cancelAnimationFrame(this.#t),clearTimeout(this.#n),clearTimeout(this.#o),this.#t=this.#n=this.#o=0}#a=()=>{this.#t||(this.#t=requestAnimationFrame(()=>{this.#t=0,this.#c()}))};#c(){let t=this.#e;if(!t)return;let n=Yt();if(!n||this.#l){n||(this.#l=!0),clearTimeout(this.#n),this.#n=0,this.#u();return}this.style.setProperty("--qv-more-bottom",`${window.innerHeight-n.limit+eo}px`),this.style.setProperty("--qv-more-x",`${n.centre}px`),t.hidden&&(clearTimeout(this.#n),this.#n=window.setTimeout(()=>{this.#n=0,!this.#l&&Yt()&&(t.hidden=!1)},an))}#u(){let t=this.#e;if(!t||t.hidden)return;let n=t.contains(document.activeElement);t.hidden=!0,n&&(a()?.commandBar?.focusInput(),document.activeElement===t&&t.blur())}#d=()=>{let t=Yt();if(!t)return;let n=document.querySelector("qv-player .qv-header"),o=Math.max(0,n?.getBoundingClientRect().bottom??0),r=a()?.output,i=r&&parseFloat(getComputedStyle(r).lineHeight)||24,l=Math.max(i,t.limit-o-2*i),d=!matchMedia("(prefers-reduced-motion: reduce)").matches,u=window.scrollY,c=this.#r;window.scrollBy({top:l,behavior:d?"smooth":"instant"}),clearTimeout(this.#o),this.#o=window.setTimeout(()=>{this.#o=0,!(window.scrollY!==u||this.#r!==c||!this.#e||this.#e.hidden)&&(this.#l=!0,this.#a())},an)}};function Yt(){let e=a(),t=e?.output;if(!e||!t||t.hidden||!t.isConnected)return null;let n=window.innerHeight,o=document.scrollingElement??document.documentElement;if((o.scrollTopMax??o.scrollHeight-o.clientHeight)-window.scrollY<=Gt)return null;let i=e.querySelector(".qv-footer"),l=i&&getComputedStyle(i).display!=="contents"?i:e.commandBar,d=l&&!l.hidden&&l.offsetHeight>0?l.getBoundingClientRect():null,u=d?Math.min(n,d.top):n,c=t.lastElementChild;if(!((c?c.getBoundingClientRect().bottom:t.getBoundingClientRect().top)>u+Gt||d!=null&&d.bottom>n+Gt))return null;let y=t.getBoundingClientRect();return{limit:u,centre:y.left+y.width/2}}var cn=(e,t)=>WebPlayer.chromeStrings?.[e]??t;function ln(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}function un(e,t,n,o=""){let r=a()?.output;r&&r.addText(`<iframe class="qv-video" data-qv-video="${e}" src="${ln(t.href)}" title="${ln(n)}" allow="autoplay; fullscreen; picture-in-picture; encrypted-media" allowfullscreen${o}></iframe>`)}function dn(e){let t=new URL(`https://www.youtube-nocookie.com/embed/${encodeURIComponent(e.trim())}`);t.searchParams.set("autoplay","1"),t.searchParams.set("rel","0"),un("youtube",t,cn("YouTubeVideoTitle","YouTube video"))}function mn(e){let[t,n]=e.trim().split("/"),o=new URL(`https://player.vimeo.com/video/${encodeURIComponent(t)}`);n&&o.searchParams.set("h",n),o.searchParams.set("autoplay","1"),o.searchParams.set("dnt","1"),un("vimeo",o,cn("VimeoVideoTitle","Vimeo video"),' sandbox="allow-same-origin allow-scripts allow-popups allow-presentation"')}function pn(e){for(let t of e.querySelectorAll("iframe[data-qv-video]")){let n;try{n=new URL(t.getAttribute("src")??"")}catch{continue}n.searchParams.has("autoplay")&&(n.searchParams.delete("autoplay"),t.setAttribute("src",n.href))}}function yt(e){let t=a()?.pictureFrame;if(t){t.innerHTML=e,t.classList.toggle("qv-empty",e.trim()==="");for(let n of t.querySelectorAll("img"))n.hasAttribute("alt")||(n.alt=""),n.complete||(n.addEventListener("load",_t,{once:!0}),n.addEventListener("error",_t,{once:!0}));_t()}}function fn(){let e=a()?.pictureFrame;return!e||e.hidden||e.classList.contains("qv-empty")?!1:[...e.querySelectorAll("img")].some(t=>!t.complete)}function _t(){a()?.output?.rescroll(!0)}var gn=new Map;function bn(e,t,n){gn.set(e,{width:t,height:n})}var no=8;function oo(e){s.warnedAboutScript||!/<script[\s>\/]/i.test(e)||(s.warnedAboutScript=!0,console.warn(`[Quest] This game printed a <script> element, which doesn't run in the new player interface. Call your own JavaScript with JS.yourFunction () or JS.eval instead, or tick "Use the classic interface" on the game's Interface tab.`))}var Et=class extends HTMLElement{#e=null;#t=[];#n=0;#o=0;#r=!0;#s=0;connectedCallback(){this.setAttribute("role","log"),this.setAttribute("aria-live","polite"),this.addEventListener("load",this.#i,!0),this.addEventListener("error",this.#i,!0)}disconnectedCallback(){this.removeEventListener("load",this.#i,!0),this.removeEventListener("error",this.#i,!0)}#i=t=>{t.target instanceof HTMLImageElement&&this.rescroll()};addText(t){oo(t);let n=this.#e??this.setAlignment("left");n.insertAdjacentHTML("beforeend",t),ro(n),so(n),H(n),this.#r=!0,WebPlayer.transcript?.write(t),E("outputAdded",{html:t})}addNodes(t,n){(this.#e??this.setAlignment("left")).append(...t),this.#r=!0,WebPlayer.transcript?.write(n),E("outputAdded",{html:n})}setAlignment(t){this.#e&&!this.#e.hasChildNodes()&&this.#e.remove();let n=document.createElement("div");return n.className="qv-block",n.style.textAlign=t,this.#t.length&&(n.dataset.qvSections=this.#t.join(" ")),this.append(n),this.#e=n,n}clearScreen(){this.replaceChildren(),this.#e=null,this.setAlignment("left"),this.#n=0,this.#r=!0;let t=this.#u();window.scrollY>t&&window.scrollTo({top:t,behavior:"instant"})}loadHtml(t){let n=document.createElement("template");n.innerHTML=t,pn(n.content),sn(n.content),this.replaceChildren(n.content),this.#r=!0,H(this),le(this),requestAnimationFrame(()=>{let o=document.scrollingElement??document.documentElement;window.scrollTo({top:o.scrollHeight,behavior:"instant"})}),this.#e=null,this.#t=[]}getHtml(){return this.innerHTML}reset(){this.replaceChildren(),this.#e=null,this.#t=[],this.#n=0,this.#o=0,this.#r=!0,this.#s=0}startSection(t){this.#t.includes(t)||(this.#t.push(t),this.setAlignment("left"))}endSection(t){let n=this.#t.indexOf(t);n!==-1&&(this.#t.splice(n,1),this.setAlignment("left"))}hideSection(t){this.endSection(t);let n=this.getBoundingClientRect().top;for(let o of this.#l(t)){let r=o.getBoundingClientRect();r.bottom-n<=this.#n+1&&(this.#n=Math.max(0,this.#n-r.height)),o.classList.add("qv-hiding"),vn(o),setTimeout(()=>o.remove(),250)}}disableSection(t){for(let n of this.#l(t))vn(n)}disableCommandLinks(){for(let t of this.querySelectorAll("a.commandlink"))rt(t);a()?.verbMenu?.closeIfStale()}#l(t){return[...this.querySelectorAll("[data-qv-sections]")].filter(n=>n.dataset.qvSections.split(" ").includes(t))}beginTurn(){if(s.fadePreviousOutput)for(let t of this.children)t.classList.add("qv-previous-output")}clearPreviousOutputFade(){for(let t of this.querySelectorAll(".qv-previous-output"))t.classList.remove("qv-previous-output")}markScrollPosition(){this.#n=this.#a()}#a(){let t=this.lastElementChild;return t?t.getBoundingClientRect().bottom-this.getBoundingClientRect().top:0}scrollToEnd(){let t=this.#a();!this.#r&&t<=this.#s+1||(this.#r=!1,this.#s=t,this.#c(this.#n))}rescroll(t=!1){this.#c(this.#o,t)}#c(t,n=!1){if(!s.autoScroll||(this.#o=t,fn()))return;let r=(document.scrollingElement??document.documentElement).scrollHeight-window.innerHeight,i=s.animateScroll?Math.min(this.#u()+t-hn()-no,r):r,l=this.#u()+t-window.scrollY,d=n&&l>=0&&l<hn();if(i<=window.scrollY&&!d)return;let u=s.animateScroll&&!matchMedia("(prefers-reduced-motion: reduce)").matches;window.scrollTo({top:i,behavior:u?"smooth":"instant"})}#u(){return this.getBoundingClientRect().top+window.scrollY}};function hn(){return document.querySelector("qv-player .qv-header")?.offsetHeight??0}function vn(e){for(let t of e.querySelectorAll("a.cmdlink, a[data-qv-event]"))t.classList.contains("commandlink")?rt(t):M(t,!1);a()?.verbMenu?.closeIfStale()}function ro(e){for(let t of e.querySelectorAll("img:not([alt])"))t.setAttribute("alt","")}function so(e){for(let t of e.querySelectorAll("img:not([width]):not([height]):not([style])")){let n=gn.get(t.getAttribute("src")??"");n&&(t.setAttribute("width",String(n.width)),t.setAttribute("height",String(n.height)),t.classList.add("qv-sized"))}}var T=()=>WebPlayer.transcript;function Sn(e){let t=a()?.output;t?.addText(e),t?.scrollToEnd()}var yn={write:e=>T()?.write(String(e??"")),enable:e=>T()?.enable(e==null?void 0:String(e)),disable:()=>T()?.disable(),kill:()=>T()?.kill(),revive:()=>T()?.revive(),setName:e=>T()?.setName(String(e??"")),setPrefix:()=>{},stampDateAndTime:()=>Sn(`<b>DATE AND TIME:</b> ${new Date().toLocaleString(navigator.language,{timeZoneName:"short"})}`),promptForName:()=>{let e=a()?.commandBar?.input;e&&(e.value=T()?.name||document.title,e.focus({preventScroll:!0}))},show:(e,t)=>{let n=document.createElement("a");n.href=T()?.viewerUrl??"TranscriptViewer/index.html",n.target="_blank",n.textContent=t==null||t===""?"Your Transcripts":String(t);let o=e==null||e===""?"Your transcripts are saved to the localStorage in your browser. You can view, download, or delete them here:":String(e);Sn(`${o} ${n.outerHTML}<br/>`)}};var p=e=>(...t)=>Dt(e,t),io={show:p("show"),respondToClicks:p("respondToClicks"),setInteractive:p("setInteractive"),setScale:p("setScale"),setCentre:p("setCentre"),drawBox:p("drawBox"),drawLabel:p("drawLabel"),drawPlayer:p("drawPlayer"),drawLine:p("drawLine"),drawArrow:p("drawArrow"),drawSquare:p("drawSquare"),drawShape:p("drawShape"),addShapePoint:p("addShapePoint"),drawImage:p("drawImage"),drawSvg:p("drawSvg"),loadSvg:p("loadSvg"),drawGridLines:p("drawGridLines"),showCustomLayer:p("showCustomLayer"),clearCustomLayer:p("clearCustomLayer"),removeDrawing:p("removeDrawing"),clearAllLayers:p("clearAllLayers"),setLevel:p("setLevel")};function X(e){return typeof e=="string"?JSON.parse(e):e}function Jt(e){let t=e??"";a()?.setLocation(t),E("locationChanged",{location:t})}function Zt(e,t){s.interfaceStrings.set(e,t),e==="EmptyListLabel"&&(s.interfaceStrings.delete("InventoryEmptyLabel"),s.interfaceStrings.delete("PlacesObjectsEmptyLabel")),we(e,t),(e==="InButtonLabel"||e==="OutButtonLabel"||e==="CompassLabel")&&B(),e==="TypeHereLabel"&&a()?.commandBar?.updatePlaceholder(),e==="ContinueLabel"&&a()?.commandBar?.updateContinueLabel()}function Xt(e){s.compassDirections=Array.isArray(e)?e.map(String):String(e??"").split(";"),B()}var En={sendCommand:v,sendEvent:w,restart:()=>window.RestartGame?.(),addText:e=>a()?.output?.addText(String(e)),clearScreen:()=>a()?.output?.clearScreen(),setAlignment:e=>{a()?.output?.setAlignment(String(e))},startSection:e=>a()?.output?.startSection(String(e)),endSection:e=>a()?.output?.endSection(String(e)),hideSection:e=>a()?.output?.hideSection(String(e)),disableSection:e=>a()?.output?.disableSection(String(e)),disableCommandLinks:()=>a()?.output?.disableCommandLinks(),updateLinks:(e,t)=>a()?.updateLinks(String(e),X(t)),scrollToEnd:()=>a()?.output?.scrollToEnd(),addYouTube:e=>dn(String(e??"")),addVimeo:e=>mn(String(e??"")),textEffect:(e,...t)=>rn(String(e),t),setVisible:(e,t)=>a()?.setVisible(String(e),!!t),setPaneOrder:e=>Le(X(e)),setLayoutPreset:(e,t)=>a()?.setLayoutPreset(String(e),t==null?void 0:String(t)),setMapPosition:e=>Ne(String(e??"")),setPictureFrame:e=>yt(String(e??"")),setInterfaceString:Zt,setCompassDirections:e=>Xt(X(e)),setLocation:Jt,setStatusAttributes:e=>Ht(X(e)),setTokens:e=>a()?.setTokens(X(e)??{}),setCommandBarStyle:e=>a()?.commandBar?.setStyle(String(e??"")),setCommandBarPreset:e=>a()?.commandBar?.setPreset(String(e??"")),setCommandPrompt:e=>a()?.commandBar?.setPrompt(String(e??"")),addStylesheet:e=>addExternalStylesheet(String(e)),map:io,transcript:yn,addPane:(e,t,n)=>Ee(String(e),t==null?void 0:String(t),n==null?void 0:String(n)),setPaneContent:(e,t)=>ye(String(e),String(t??"")),setCommands:e=>Se(e),setCommandsInExitStrip:e=>{s.commandsInExitStrip=!!e,f()},setAutoScroll:e=>{s.autoScroll=!!e},setContinueOnClick:e=>{s.continueOnClick=!!e},fadePreviousOutput:e=>{s.fadePreviousOutput=!!e,s.fadePreviousOutput||a()?.output?.clearPreviousOutputFade()},setCommandPlaceholder:e=>{s.commandPlaceholder=e==null?null:String(e),a()?.commandBar?.updatePlaceholder()},setMapInteractive:e=>Dt("setInteractive",[e]),lists:re,on:ee,off:ne};function Ln(e){return(e.dataset.qvName??e.textContent??"").trim()}var te=4,tt=8,Lt=class extends HTMLElement{#e=null;connectedCallback(){this.setAttribute("role","menu"),C&&(this.popover="manual"),this.addEventListener("click",this.#n),this.addEventListener("keydown",this.#o)}get isOpen(){return this.#e!==null}toggle(t){if(this.#e===t){this.close();return}let n=(t.dataset.verbs??"").split("/").map(r=>r.trim()).filter(Boolean);if(!n.length)return;this.close({restoreFocus:!1});let o=Ln(t);this.setAttribute("aria-label",(t.textContent??"").trim()),this.replaceChildren(...n.map(r=>{let i=document.createElement("button");return i.type="button",i.setAttribute("role","menuitem"),i.textContent=r,i.dataset.command=`${r.toLowerCase()} ${o}`,i})),this.#e=t,t.setAttribute("aria-expanded","true"),this.classList.add("qv-open"),C&&this.showPopover(),this.#i(),this.querySelector("button")?.focus({preventScroll:!0}),document.addEventListener("pointerdown",this.#r,!0),window.addEventListener("scroll",this.#s,{passive:!0}),window.addEventListener("resize",this.#s)}close({restoreFocus:t=!0}={}){let n=this.#e;if(!n)return;this.#e=null,n.setAttribute("aria-expanded","false");let o=this.contains(document.activeElement);this.classList.remove("qv-open"),C&&this.matches(":popover-open")&&this.hidePopover(),this.replaceChildren(),document.removeEventListener("pointerdown",this.#r,!0),window.removeEventListener("scroll",this.#s),window.removeEventListener("resize",this.#s),t&&o&&n.isConnected&&n.focus({preventScroll:!0})}closeIfStale(){this.#e&&(!this.#e.isConnected||k(this.#e))&&this.close({restoreFocus:!1})}#t(t){let n=this.#e;if(!n)return;let o=Ln(n),r={};n.dataset.elementid&&(r[o]=n.dataset.elementid),this.close({restoreFocus:!1}),v(t.dataset.command??"",r)}#n=t=>{let n=t.target instanceof Element?t.target.closest('[role="menuitem"]'):null;n&&this.#t(n)};#o=t=>{let n=[...this.querySelectorAll('[role="menuitem"]')],o=n.indexOf(document.activeElement),r=null;switch(t.key){case"Escape":t.preventDefault(),this.close();return;case"Tab":this.close({restoreFocus:!1});return;case"ArrowDown":r=(o+1)%n.length;break;case"ArrowUp":r=(o-1+n.length)%n.length;break;case"Home":r=0;break;case"End":r=n.length-1;break;default:return}t.preventDefault(),n[r]?.focus()};#r=t=>{let n=t.target instanceof Node?t.target:null;n&&(this.contains(n)||this.#e?.contains(n))||this.close({restoreFocus:!1})};#s=()=>{this.closeIfStale(),this.#e&&this.#i()};#i(){if(!this.#e)return;let t=this.#e.getBoundingClientRect(),{offsetWidth:n,offsetHeight:o}=this,r=t.bottom+te;r+o>window.innerHeight-tt&&t.top-te-o>=tt&&(r=t.top-te-o);let i=Math.max(tt,Math.min(t.left,window.innerWidth-n-tt));this.style.top=`${Math.max(tt,r)}px`,this.style.left=`${i}px`}};customElements.define("qv-player",dt);customElements.define("qv-output",Et);customElements.define("qv-command-bar",vt);customElements.define("qv-verb-menu",Lt);customElements.define("qv-pane",st);customElements.define("qv-more",St);window.QuestUI=En;window.sendCommand=(e,t)=>{v(e,t)};window.ASLEvent=w;window.canSendCommand=!0;window.notifyQuestUITurn=e=>{let t=a()?.output;e?(q(!1,{restoreFocus:!1}),t?.beginTurn(),t?.setAttribute("aria-busy","true"),E("turnStarted")):(t?.removeAttribute("aria-busy"),E("turnEnded"),a()?.commandBar?.focusInput(),a()?.focusFirstChoice())};window.resetQuestUIState=()=>{oe(),O(),Ge(),Ae(),He(),se(),be(),Oe(),bt()};document.addEventListener("keydown",e=>{!s.waiting||e.repeat||["Tab","Shift","Control","Alt","Meta"].includes(e.key)||e.target instanceof Element&&e.target.closest("input, textarea, select, [contenteditable], dialog")||(e.preventDefault(),Z())});window.addEventListener("beforeunload",e=>{!s.hasUnsavedProgress||!s.canSave||!a()||(e.preventDefault(),e.returnValue="")});document.addEventListener("click",e=>{!s.waiting||!s.continueOnClick||e.target instanceof Element&&e.target.closest("a, button, input, textarea, select, summary, dialog")||Z()});var S=()=>a()?.output;function wn(){let e=a()?.saveButton;e&&(e.disabled=s.turnPending)}var ao=()=>{},qn={"#gamePanes":"panes","#location":"location","#txtCommandDiv":"command-bar"},lo={addTextAndScroll(e){S()?.addText(e),S()?.scrollToEnd()},createNewDiv:e=>{S()?.setAlignment(e)},bindMenu:(e,t,n,o)=>ue(e,t,o),showMenu:Xe,showQuestion:tn,beginWait:Ye,setTurnPending(e){s.turnPending=e,wn(),f()},beginPause:_e,updateLocation:Jt,setGameName(e){document.title=e},clearScreen:()=>S()?.clearScreen(),panesVisible:e=>a()?.setVisible("panes",e),updateStatus:ke,setBackground:e=>a()?.setTokens({"--qv-bg":e}),setForeground:ao,updateList:ge,updateCompass:Ce,updateObjectLinks:e=>a()?.updateLinks("object",e),gameFinished(){s.gameFinished=!0,O(),s.waiting=!1,R("finished",!0),f()},requestNextTimerTick:je,uiShow:e=>a()?.setVisible(qn[e]??"",!0),uiHide:e=>a()?.setVisible(qn[e]??"",!1),setCompassDirections:Xt,setInterfaceString:Zt,setPanelContents:yt,loadHtml:e=>S()?.loadHtml(e),markScrollPosition:()=>S()?.markScrollPosition(),scrollToEnd:()=>S()?.scrollToEnd(),requestSave(){GameSaver.saveRequested()},start(){a()?.saveButton?.addEventListener("click",()=>{WebPlayer.onSaveClick?WebPlayer.onSaveClick():GameSaver.save()}),wn(),B(),$(),a()?.commandBar?.focusInput()},resetOutput(){S()?.reset(),O(),s.hasUnsavedProgress=!1},useManualClock:ze,getOutputHtml:()=>S()?.getHtml()??"",getLocation:()=>a()?.location?.textContent?.trim()??"",getOutputElement:()=>S()??null,gameSaved(){S()?.addText(`<span data-qv-save-notice>${WebPlayer.chromeStrings?.GameSaved??"Game saved."}<br></span>`),s.hasUnsavedProgress=!1},clearUnsavedProgress(){s.hasUnsavedProgress=!1},setCanSave(e){s.canSave=e},waitEnded:$t,pauseEnded:jt,dismissPrompt:Je,beginSoundWait(){let e=!a()?.commandBar?.hidden;return s.soundWait=!0,R("sound",!0),e},endSoundWait(){s.soundWait=!1,setTimeout(async()=>{R("sound",!1),await WebPlayer.uiEndWait()},100)},rememberImageSize:bn,setAnimateScroll(e){s.animateScroll=e}};window.QuestPlayerUis=window.QuestPlayerUis??{};window.QuestPlayerUis.v2=lo;})();