(()=>{"use strict";const t=new class{constructor(){this.states=new Map}get(t){return this.states.get(t)}set(t,e){return this.states.set(t,e)}};class e{constructor(){this.inventory=[],this.currentRoom="start",this.context=null}addItem(t){this.inventory.push(t)}removeItem(t){this.inventory=this.inventory.filter((e=>e!=t))}getInventory(){return this.inventory.map((t=>this.context.getItem(t)))}}class i{speak(t){}stop(){}setOptions(t){}}class s extends i{constructor(t={}){super(),this.timeout=100,this.timeout=t.timeout||100,this.init()}init(){this.container=document.createElement("div"),this.container.setAttribute("aria-live","polite"),this.speechDisplay=document.createElement("div"),this.speechDisplay.setAttribute("aria-live","polite"),this.container.append(this.speechDisplay),document.body.appendChild(this.container),document.body.insertBefore(this.container,document.body.firstChild)}speak(t){this.clearDisplay();const e=document.createTextNode(t),i=document.createElement("p");i.appendChild(e),this.speechDisplay.appendChild(i),setTimeout(this.clearDisplay.bind(this),this.timeout)}stop(){this.clearDisplay()}clearDisplay(){this.speechDisplay.innerHTML=""}}class n extends i{}class o{constructor(t=function(t="aria"){return"webtts"===t?n:s}()){this.output=t}speak(t){this.output.speak(t)}stop(){this.output.stop()}}class a{constructor(){this.tts=new o(new s),this.history=document.getElementById("output-area")}say(t){const e=document.createElement("p");e.appendChild(document.createTextNode(t)),this.history.appendChild(e)}}class r{constructor(t,e){this.handler=t,this.output=e,this.echoInput=!0,this.inputField=document.getElementById("input-area"),this.init()}setEcho(t){this.echoInput=t}init(){this.inputField.addEventListener("keydown",(t=>{if(13==t.which){const t=this.inputField.value;this.inputField.value="",this.echoInput&&this.output.say(`> ${t}`),this.handler.doCommand(t)}}))}}const h=[[["look","l"],function(t,e){if(1==t.length)e.examineRoom();else{const i=e.getRoom(e.player.currentRoom).getItems();let s=null;for(let e of i)if(e.name.includes(t[1])){s=e;break}s?(e.output.say(s.name),e.output.say(s.description)):e.output.say(`I could not find a ${t[1]}`)}}],[["use","interact"],async function(t,e){const i=e.getRoom(e.player.currentRoom).getItems();let s=null;for(let e of i)if(e.name.includes(t[1])){s=e;break}s?await s.onUse():e.output.say(`I could not find a ${t[1]}`)}],[["take","get"],function(t,e){const i=e.getRoom(e.player.currentRoom),s=i.getItems();let n=null;for(let e of s)if(e.name.includes(t[1])){n=e;break}n?n.takeable?(i.removeItem(n.id),e.player.addItem(n.id),e.print(`You take ${n.name}`),n.onTake()):e.print(`You can't take ${n.name}`):e.print(`You can't find any ${t[1]}`)}],[["drop","put"],function(t,e){const i=e.getRoom(e.player.currentRoom),s=e.player.getInventory();let n=null;for(let e of s)if(e.name.includes(t[1])){n=e;break}n?(e.player.removeItem(n.id),i.addItem(n.id),e.print(`You set ${n.name} down on the floor.`),n.onDrop()):e.print(`You're not carrying a ${t[1]}`)}],["echo",function(t,e){"on"!=t[1]&&"off"!=t[1]?e.print("Usage: echo "):(e.setInputEcho("on"==t[1]),e.print(`Command echo is now ${t[1]}`))}]],c=[["n","north"],["ne","northeast"],["e","east"],["se","southeast"],["s","south"],["sw","southwest"],["w","west"],["nw","northwest"],["u","up"],["d","down"]];class l{constructor(t,e){this.context=t,this.commands=e||new Map,this.enabled=!0,this.addDefaultCommands()}doCommand(t){if(!this.enabled)return void this.context.print("You can't seem to do anything at the moment.");const e=this.context.getRoom(this.context.player.currentRoom),i=t.split(" ");this.commands.get(i[0])&&this.commands.get(i[0])(i,this.context);const s=this.matchDirection(i[0]);e.getExit(s)&&this.context.move(e.getExit(s))}addCommand(t,e){Array.isArray(t)?t.forEach((t=>this.commands.set(t,e))):this.commands.set(t,e)}addCommands(t){t.forEach((t=>{this.addCommand(t[0],t[1])}))}addDefaultCommands(){this.addCommands(h)}matchDirection(t){for(let e of c)if(e[0]==t)return e[1]}}class u{constructor(){this.id="room",this.title="A room",this.description="You see nothing special",this.firstDescription="As you walk into the room, you notice nothing special",this.objects=[],this.exits=new Map,this.enterCallback=null,this.exitCallback=null,this.canEnterLogic=null,this.canExitLogic=null,this.tickCallback=null,this.context=null}async onEnter(){if(this.enterCallback)return this.enterCallback(this.context)}async onExit(){if(this.exitCallback)return this.exitCallback(this.context)}canEnter(){return!this.canEnterLogic||this.canEnterLogic(this.context)}canExit(){return!this.canExitLogic||this.canExitLogic(this.context)}addExit(t,e){return this.exits.set(t,e),this}getExit(t){return this.exits.get(t)}addItem(t){this.objects.push(t)}removeItem(t){this.objects=this.objects.filter((e=>e!=t))}addEnterCallback(t){this.enterCallback=t.bind(this)}addExitCallback(t){this.exitCallback=t.bind(this)}addEnterLogic(t){this.canEnterLogic=t.bind(this)}addExitLogic(t){this.canExitLogic=t.bind(this)}addTickCallback(t){this.tickCallback=t.bind(this)}getItems(){return this.objects.map((t=>this.context.getItem(t)))}}class m{constructor(){this.room=new u}withID(t){return this.room.id=t,this}withTitle(t){return this.room.title=t,this}withFirstDescription(t){return this.room.firstDescription=t,this}withDescription(t){return this.room.description=t,this}withExit(t,e){return this.room.addExit(t,e),this}withItem(t){return this.room.addItem(t),this}withEnterCallback(t){return this.room.addEnterCallback(t),this}withExitCallback(t){return this.room.addExitCallback(t),this}withEnterLogic(t){return this.room.addEnterLogic(t),this}withExitLogic(t){return this.room.addExitLogic(t),this}withTick(t){return this.room.addTickCallback(t),this}create(){return this.room}}const d=[(new m).withID("start").withTitle("The starting room").withFirstDescription("You set foot in your very first room").withDescription("The first room. Nothing special about it.").withExit("north","tunnel_1").withEnterCallback((async function(t){const{output:e,wait:i}=t;t.enableCommandInput(!1),e.say("You slowly wake up"),await i(5e3),e.say("It's strange. You never used to be able to be conscious about the fact that you were waking up."),await i(5e3),e.say("Yet here we are."),t.enableCommandInput(!0)})).withItem("stone").create(),(new m).withID("tunnel_1").withTitle("A long dark tunnel").withFirstDescription("You first step foot in this dark loomy tunnel.").withDescription("The walls are wet. Everything is wet. Ugh. Why do you even.").withExit("south","start").create()];class p{constructor(){this.id="item",this.name="An item",this.description="You see nothing special about this item",this.usable=!0,this.takeable=!0,this.useCallback=null,this.takeCallback=null,this.dropCallback=null,this.tickCallback=null,this.context=null}async onUse(){if(this.useCallback)return this.useCallback(this.context)}async onTake(){if(this.takeCallback)return this.takeCallback()}addUseCallback(t){this.useCallback=t.bind(this)}addTakeCallback(t){this.takeCallback=t.bind(this)}addDropCallback(t){this.dropCallback=t.bind(this)}addTickCallback(t){this.tickCallback=t.bind(this)}}const b=[(new class{constructor(){this.item=new p}withID(t){return this.item.id=t,this}withName(t){return this.item.name=t,this}withDescription(t){return this.item.description=t,this}isUsable(t){return this.item.usable=t,this}isTakeable(t){return this.item.takeable=t,this}withUseCallback(t){return this.item.addUseCallback(t),this}withTakeCallback(t){return this.item.addTakeCallback(t),this}withTickCallback(t){return this.item.addTickCallback(t),this}create(){return this.item}}).withID("stone").withName("A dull stone").withDescription("There is nothing remarkable about this rough, bland stone.").isTakeable(!0).isUsable(!0).withTakeCallback((async function(t){t.print(`The ${this.id} feels heavy in your hands.`)})).withUseCallback((async function(t){t.print(`You can't really figure out what to do with ${this.name} yet`)})).create()];(new class{constructor(){this.player=new e,this.state=t,this.rooms=[],this.items=[],this.output=new a,this.commandHandler=new l(this),this.input=new r(this.commandHandler,this.output),this.visitedRooms=new Map}print(t){this.output.say(t)}init(t){console.log(t),this.rooms=t.rooms.map((t=>(t.context=this,t))),this.items=t.items.map((t=>(t.context=this,t))),this.state=t.state,this.commandHandler.addCommands(t.commands),this.player=new e,this.player.context=this,this.move(this.player.currentRoom)}examineRoom(){const t=this.getRoom(this.player.currentRoom);this.output.say(t.title),this.visitedRooms.get(this.player.currentRoom)||""==t.firstDescription?this.output.say(t.description):this.output.say(t.firstDescription),this.examineItems(),this.examineExits()}examineItems(){this.getRoom(this.player.currentRoom).getItems().forEach((t=>this.output.say(t.name)))}examineExits(){const t=this.getRoom(this.player.currentRoom);let e="You can go ";for(let i of t.exits.keys())e+=" "+i;this.output.say(e)}getRoom(t){return this.rooms.find((e=>e.id==t))}getItem(t){return this.items.find((e=>e.id==t))}wait(t){return new Promise(((e,i)=>{setTimeout(e,t)}))}async move(t){const e=this.getRoom(this.player.currentRoom),i=this.getRoom(t);e.canExit()&&i.canEnter()&&(await e.onExit(),await i.onEnter(),this.player.currentRoom=t,this.examineRoom(),this.visitedRooms.set(t,!0))}enableCommandInput(t){this.commandHandler.enabled=t}setInputEcho(t){this.input.setEcho(t)}}).init({rooms:d,commands:[[["meow","mew"],async function(t,e){e.print("You meow.")}]],items:b})})(); //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2FtZS5qcyIsIm1hcHBpbmdzIjoibUJBY0EsWUFkQSxNQUNJQSxjQUNJQyxLQUFLQyxPQUFTLElBQUlDLElBR3RCQyxJQUFJQyxHQUNBLE9BQU9KLEtBQUtDLE9BQU9FLElBQUlDLEdBRzNCQyxJQUFJRCxFQUFLRSxHQUNMLE9BQU9OLEtBQUtDLE9BQU9JLElBQUlELEVBQUtFLEtDVnJCLE1BQU1DLEVBQ2pCUixjQUNJQyxLQUFLUSxVQUFZLEdBQ2pCUixLQUFLUyxZQUFjLFFBQ25CVCxLQUFLVSxRQUFVLEtBR25CQyxRQUFRQyxHQUNKWixLQUFLUSxVQUFVSyxLQUFLRCxHQUd4QkUsV0FBV0YsR0FDUFosS0FBS1EsVUFBWVIsS0FBS1EsVUFBVU8sUUFBUUMsR0FBU0EsR0FBUUosSUFHN0RLLGVBQ0ksT0FBT2pCLEtBQUtRLFVBQVVVLEtBQUtGLEdBQVNoQixLQUFLVSxRQUFRUyxRQUFRSCxNQ2hCMUQsTUFBTUksRUFDVEMsTUFBTUMsSUFHTkMsUUFHQUMsV0FBV0MsS0NOUixNQUFNQyxVQUFtQk4sRUFDNUJyQixZQUFZMEIsRUFBVSxJQUNsQkUsUUFDQTNCLEtBQUs0QixRQUFVLElBQ2Y1QixLQUFLNEIsUUFBVUgsRUFBUUcsU0FBVyxJQUNsQzVCLEtBQUs2QixPQUVUQSxPQUNJN0IsS0FBSzhCLFVBQVlDLFNBQVNDLGNBQWMsT0FDeENoQyxLQUFLOEIsVUFBVUcsYUFBYSxZQUFhLFVBQ3pDakMsS0FBS2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ldChrZXkpIHtcclxuICAgICAgICByZXR1cm4gdGhpcy5zdGF0ZXMuZ2V0KGtleSk7XHJcbiAgICB9XHJcblxyXG4gICAgc2V0KGtleSwgdmFsdWUpIHtcclxuICAgICAgICByZXR1cm4gdGhpcy5zdGF0ZXMuc2V0KGtleSwgdmFsdWUpO1xyXG4gICAgfVxyXG59XHJcblxyXG5leHBvcnQgZGVmYXVsdCBuZXcgU3RhdGUoKTsiLCJleHBvcnQgZGVmYXVsdCBjbGFzcyBQbGF5ZXIge1xyXG4gICAgY29uc3RydWN0b3IoKSB7XHJcbiAgICAgICAgdGhpcy5pbnZlbnRvcnkgPSBbXTtcclxuICAgICAgICB0aGlzLmN1cnJlbnRSb29tID0gXCJzdGFydFwiO1xyXG4gICAgICAgIHRoaXMuY29udGV4dCA9IG51bGw7XHJcbiAgICB9XHJcblxyXG4gICAgYWRkSXRlbShpZCkge1xyXG4gICAgICAgIHRoaXMuaW52ZW50b3J5LnB1c2goaWQpO1xyXG4gICAgfVxyXG5cclxuICAgIHJlbW92ZUl0ZW0oaWQpIHtcclxuICAgICAgICB0aGlzLmludmVudG9yeSA9IHRoaXMuaW52ZW50b3J5LmZpbHRlcigoaXRlbSkgPT4gaXRlbSAhPSBpZCk7XHJcbiAgICB9XHJcblxyXG4gICAgZ2V0SW52ZW50b3J5KCkge1xyXG4gICAgICAgIHJldHVybiB0aGlzLmludmVudG9yeS5tYXAoKGl0ZW0pID0+IHRoaXMuY29udGV4dC5nZXRJdGVtKGl0ZW0pKTtcclxuICAgIH1cclxufSIsImV4cG9ydCBjbGFzcyBCYXNlT3V0cHV0IHtcclxuICAgIHNwZWFrKHRleHQpIHtcclxuICAgICAgICByZXR1cm47XHJcbiAgICB9XHJcbiAgICBzdG9wKCkge1xyXG4gICAgICAgIHJldHVybjtcclxuICAgIH1cclxuICAgIHNldE9wdGlvbnMob3B0aW9ucykge1xyXG4gICAgICAgIHJldHVybjtcclxuICAgIH1cclxufVxyXG4iLCJpbXBvcnQge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clxuICAgIFtcInVcIiwgXCJ1cFwiXSxcclxuICAgIFtcImRcIiwgXCJkb3duXCJdXHJcbl07XHJcblxyXG5leHBvcnQgZGVmYXVsdCBjbGFzcyBDb21tYW5kcyB7XHJcbiAgICBjb25zdHJ1Y3Rvcihjb250ZXh0LCBjb21tYW5kcykge1xyXG4gICAgICAgIHRoaXMuY29udGV4dCA9IGNvbnRleHQ7XHJcbiAgICAgICAgdGhpcy5jb21tYW5kcyA9IGNvbW1hbmRzIHx8IG5ldyBNYXAoKTtcclxuICAgICAgICB0aGlzLmVuYWJsZWQgPSB0cnVlO1xyXG4gICAgICAgIHRoaXMuYWRkRGVmYXVsdENvbW1hbmRzKCk7XHJcbiAgICB9XHJcblxyXG4gICAgZG9Db21tYW5kKHN0cikge1xyXG4gICAgICAgIGlmICghdGhpcy5lbmFibGVkKSB7XHJcbiAgICAgICAgICAgIHRoaXMuY29udGV4dC5wcmludChgWW91IGNhbid0IHNlZW0gdG8gZG8gYW55dGhpbmcgYXQgdGhlIG1vbWVudC5gKTtcclxuICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgIH1cclxuICAgICAgICBjb25zdCByb29tID0gdGhpcy5jb250ZXh0LmdldFJvb20odGhpcy5jb250ZXh0LnBsYXllci5jdXJyZW50Um9vbSk7XHJcbiAgICAgICAgY29uc3Qgc3BsaXQgPSBzdHIuc3BsaXQoXCIgXCIpO1xyXG4gICAgICAgIGlmICh0aGlzLmNvbW1hbmRzLmdldChzcGxpdFswXSkpIHtcclxuICAgICAgICAgICAgdGhpcy5jb21tYW5kcy5nZXQoc3BsaXRbMF0pKHNwbGl0LCB0aGlzLmNvbnRleHQpO1xyXG4gICAgICAgIH1cclxuICAgICAgICBcclxuICAgICAgICBjb25zdCBkaXJlY3Rpb24gPSB0aGlzLm1hdGNoRGlyZWN0aW9uKHNwbGl0WzBdKTtcclxuXHJcbiAgICAgICAgaWYgKHJvb20uZ2V0RXhpdChkaXJlY3Rpb24pKSB7XHJcbiAg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SBlbHNlIHtcclxuICAgICAgICBjb25zdCByb29tID0gY29udGV4dC5nZXRSb29tKGNvbnRleHQucGxheWVyLmN1cnJlbnRSb29tKTtcclxuICAgICAgICBjb25zdCBpdGVtcyA9IHJvb20uZ2V0SXRlbXMoKTtcclxuICAgICAgICBsZXQgaXRlbSA9IG51bGw7XHJcbiAgICAgICAgZm9yIChsZXQgaSBvZiBpdGVtcykge1xyXG4gICAgICAgICAgICBpZiAoaS5uYW1lLmluY2x1ZGVzKGFyZ3NbMV0pKSB7XHJcbiAgICAgICAgICAgICAgICBpdGVtID0gaTtcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGlmICghaXRlbSkge1xyXG4gICAgICAgICAgICBjb250ZXh0Lm91dHB1dC5zYXkoYEkgY291bGQgbm90IGZpbmQgYSAke2FyZ3NbMV19YCk7XHJcbiAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgY29udGV4dC5vdXRwdXQuc2F5KGl0ZW0ubmFtZSk7XHJcbiAgICAgICAgICAgIGNvbnRleHQub3V0cHV0LnNheShpdGVtLmRlc2NyaXB0aW9uKTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcbn0iLCJleHBvcnQgZGVmYXVsdCBhc3luYyBmdW5jdGlvbiBVc2VDb21tYW5kKGFyZ3MsIGNvbnRleHQpIHtcclxuICAgIGNvbnN0IHJvb20gPSBjb250ZXh0LmdldFJvb20oY29udGV4dC5wbGF5ZXIuY3VycmVudFJvb20pO1xyXG4gICAgY29uc3QgaXRlbXMgPSByb29tLmdldEl0ZW1zKCk7XHJcbiAgICBsZXQgaXRlbSA9IG51bGw7XHJcbiAgICBmb3IgKGxldCBpIG9mIGl0ZW1zKSB7XHJcbiAgICAgICAgaWYgKGkubmFtZS5pbmNsdWRlcyhhcmdzWzFdKSkge1xyXG4gICAgICAgICAgICBpdGVtID0gaTtcclxuICAgICAgICAgICAgYnJlYWs7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GRlZmF1bHQgY2xhc3MgR2FtZSB7XHJcbiAgICBjb25zdHJ1Y3RvcigpIHtcclxuICAgICAgICB0aGlzLnBsYXllciA9IG5ldyBQbGF5ZXIoKTtcclxuICAgICAgICB0aGlzLnN0YXRlID0gU3RhdGU7XHJcbiAgICAgICAgdGhpcy5yb29tcyA9IFtdO1xyXG4gICAgICAgIHRoaXMuaXRlbXMgPSBbXTtcclxuICAgICAgICB0aGlzLm91dHB1dCA9IG5ldyBPdXRwdXQoKTtcclxuICAgICAgICB0aGlzLmNvbW1hbmRIYW5kbGVyID0gbmV3IENvbW1hbmRzKHRoaXMpO1xyXG4gICAgICAgIHRoaXMuaW5wdXQgPSBuZXcgSW5wdXQodGhpcy5jb21tYW5kSGFuZGxlciwgdGhpcy5vdXRwdXQpO1xyXG4gICAgICAgIHRoaXMudmlzaXRlZFJvb21zID0gbmV3IE1hcCgpO1xyXG4gICAgfVxyXG5cclxuICAgIHByaW50KHN0cmluZykge1xyXG4gICAgICAgIHRoaXMub3V0cHV0LnNheShzdHJpbmcpO1xyXG4gICAgfVxyXG5cclxuICAgIGluaXQoZGF0YSkge1xyXG4gICAgICAgIGNvbnNvbGUubG9nKGRhdGEpO1xyXG4gICAgICAgIHRoaXMucm9vbXMgPSBkYXRhLnJvb21zLm1hcCgocm9vbSkgPT4ge1xyXG4gICAgICAgICAgICByb29tLmNvbnRleHQgPSB0aGlzO1xyXG4gICAgICAgICAgICByZXR1cm4gcm9vbTtcclxuICAgICAgICB9KTtcclxuICAgICAgICB0aGlzLml0ZW1zID0gZGF0YS5pdGVtcy5tYXAoKGl0ZW0pID0+IHtcclxuICAgICAgICAgICAgaXRlbS5jb250ZXh0ID0gdGhpcztcclxuICAgICAgICAgICAgcmV0dXJuIGl0ZW07XHJcbiAgICAgICAgfSk7XHJcbiAgICAgICAgdGhpcy5zdGF0ZSA9IGRhdGEuc3RhdGU7XHJcbiAgICAgICAgdGhpcy5jb21tYW5kSGFuZGxlci5hZGRDb21tYW5kcyhkYXRhLmNvbW1hbmRzKTtcclxuICAgICAgICB0aGlzLnBsYXllciA9IG5ldyBQbGF5ZXIoKTtcclxuICAgICAgICB0aGlzLnBsYXllci5jb250ZXh0ID0gdGhpcztcclxuICAgICAgICB0aGlzLm1vdmUodGhpcy5wbGF5ZXIuY3VycmVudFJvb20pO1xyXG4gICAgfVxyXG5cclxuICAgIGV4YW1pbmVSb29tKCkge1xyXG4gICAgICAgIGNvbnN0IHJvb20gPSB0aGlzLmdldFJvb20odGhpcy5wbGF5ZXIuY3VycmVudFJvb20pO1xyXG4gICAgICAgIHRoaXMub3V0cHV0LnNheShyb29tLnRpdGxlKTtcclxuICAgICAgICBpZiAoIXRoaXMudmlzaXRlZFJvb21zLmdldCh0aGlzLnBsYXllci5jdXJyZW50Um9vbSkgJiYgcm9vbS5maXJzdERlc2NyaXB0aW9uICE9IFwiXCIpIHtcclxuICAgICAgICAgICAgdGhpcy5vdXRwdXQuc2F5KHJvb20uZmlyc3REZXNjcmlwdGlvbik7XHJcbiAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgdGhpcy5vdXRwdXQuc2F5KHJvb20uZGVzY3JpcHRpb24pO1xyXG4gICAgICAgIH1cclxuICAgICAgICB0aGlzLmV4YW1pbmVJdGVtcygpO1xyXG4gICAgICAgIHRoaXMuZXhhbWluZUV4aXRzKCk7XHJcbiAgICB9XHJcblxyXG4gICAgZXhhbWluZUl0ZW1zKCkge1xyXG4gICAgICAgIGNvbnN0IHJvb20gPSB0aGlzLmdldFJvb20odGhpcy5wbGF5ZXIuY3VycmVudFJvb20pO1xyXG4gICAgICAgIGNvbnN0IGl0ZW1zID0gcm9vbS5nZXRJdGVtcygpO1xyXG4gICAgICAgIGl0ZW1zLmZvckVhY2goKGl0ZW0pID0+IHRoaXMub3V0cHV0LnNheShpdGVtLm5hbWUpKTtcclxuICAgIH1cclxuXHJcbiAgICBleGFtaW5lRXhpdHMoKSB7XHJcbiAgICAgICAgY29uc3Qgcm9vbSA9IHRoaXMuZ2V0Um9vbSh0aGlzLnBsYXllci5jdXJyZW50Um9vbSk7XHJcbiAgICAgICAgbGV0IGV4aXREZXNjcmlwdGlvbiA9IFwiWW91IGNhbiBnbyBcIjtcclxuICAgICAgICBmb3IgKGxldCBleGl0IG9mIHJvb20uZXhpdHMua2V5cygpKSB7XHJcbiAgICAgICAgICAgIGV4aXREZXNjcmlwdGlvbiArPSBcIiBcIiArIGV4aXQ7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHRoaXMub3V0cHV0LnNheShleGl0RGVzY3JpcHRpb24pO1xyXG4gICAgfVxyXG5cclxuICAgIGdldFJvb20oaWQpIHtcclxuICAgICAgICByZXR1cm4gdGhpcy5yb29tcy5maW5kKChyb29tKSA9PiByb29tLmlkID09IGlkKTtcclxuICAgIH1cclxuXHJcbiAgICBnZXRJdGVtKGlkKSB7XHJcbiAgICAgICAgcmV0dXJuIHRoaXMuaXRlbXMuZmluZCgoaXRlbSkgPT4gaXRlbS5pZCA9PSBpZCk7XHJcbiAgICB9XHJcblxyXG4gICAgd2FpdChtcykge1xyXG4gICAgICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7XHJcbiAgICAgICAgICAgIHNldFRpbWVvdXQocmVzb2x2ZSwgbXMpO1xyXG4gICAgICAgIH0pO1xyXG4gICAgfVxyXG5cclxuICAgIGFzeW5jIG1vdmUocm9vbUlEKSB7XHJcbiAgICAgICAgY29uc3QgY3VycmVudFJvb20gPSB0aGlzLmdldFJvb20odGhpcy5wbGF5ZXIuY3VycmVudFJvb20pO1xyXG4gICAgICAgIGNvbnN0IG5ld1Jvb20gPSB0aGlzLmdldFJvb20ocm9vbUlEKTtcclxuICAgICAgICBpZiAoY3VycmVudFJvb20uY2FuRXhpdCgpICYmIG5ld1Jvb20uY2FuRW50ZXIoKSkge1xyXG4gICAgICAgICAgICBhd2FpdCBjdXJyZW50Um9vbS5vbkV4aXQoKTtcclxuICAgICAgICA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