(()=>{"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"}}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){this.handler=t,this.inputField=document.getElementById("input-area"),this.init()}init(){this.inputField.addEventListener("keydown",(t=>{if(13==t.which){const t=this.inputField.value;this.inputField.value="",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]}`)}]],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)}addEnterCallback(t){this.enterCallback=t}addExitCallback(t){this.exitCallback=t}addEnterLogic(t){this.canEnterLogic=t}addExitLogic(t){this.canExitLogic=t}addTickCallback(t){this.tickCallback=t}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.context=null}async onUse(){if(this.useCallback)return this.useCallback(this.context)}async onTake(){if(this.takeCallback)return this.takeCallback()}}const w=[(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.useCallback=t,this}withTakeCallback(t){return this.item.takeCallback=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.output.say("It feels heavy in your hands.")})).withUseCallback((async function(t){t.output.say("You can't really figure out what to do with this 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.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.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}}).init({rooms:d,commands:[[["meow","mew"],async function(t,e){e.print("You meow.")}]],items:w})})(); //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2FtZS5qcyIsIm1hcHBpbmdzIjoibUJBY0EsWUFkQSxNQUNJQSxjQUNJQyxLQUFLQyxPQUFTLElBQUlDLElBR3RCQyxJQUFJQyxHQUNBLE9BQU9KLEtBQUtDLE9BQU9FLElBQUlDLEdBRzNCQyxJQUFJRCxFQUFLRSxHQUNMLE9BQU9OLEtBQUtDLE9BQU9JLElBQUlELEVBQUtFLEtDVnJCLE1BQU1DLEVBQ2pCUixjQUNJQyxLQUFLUSxVQUFZLEdBQ2pCUixLQUFLUyxZQUFjLFNDSHBCLE1BQU1DLEVBQ1RDLE1BQU1DLElBR05DLFFBR0FDLFdBQVdDLEtDTlIsTUFBTUMsVUFBbUJOLEVBQzVCWCxZQUFZZ0IsRUFBVSxJQUNsQkUsUUFDQWpCLEtBQUtrQixRQUFVLElBQ2ZsQixLQUFLa0IsUUFBVUgsRUFBUUcsU0FBVyxJQUNsQ2xCLEtBQUttQixPQUVUQSxPQUNJbkIsS0FBS29CLFVBQVlDLFNBQVNDLGNBQWMsT0FDeEN0QixLQUFLb0IsVUFBVUcsYUFBYSxZQUFhLFVBQ3pDdkIsS0FBS3dCL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ShuYW1lKSkge1xyXG4gICAgICAgICAgICBuYW1lLmZvckVhY2goKGNvbW1hbmQpID0+IHRoaXMuY29tbWFuZHMuc2V0KGNvbW1hbmQsIGZ1bmMpKTtcclxuICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICB0aGlzLmNvbW1hbmRzLnNldChuYW1lLCBmdW5jKTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcblxyXG4gICAgYWRkQ29tbWFuZHMoY29tbWFuZHMpIHtcclxuICAgICAgICBjb21tYW5kcy5mb3JFYWNoKChjb21tYW5kKSA9PiB7XHJcbiAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZChjb21tYW5kWzBdLCBjb21tYW5kWzFdKTtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxuXHJcbiAgICBhZGREZWZhdWx0Q29tbWFuZHMoKSB7XHJcbiAgICAgICAgdGhpcy5hZGRDb21tYW5kcyhkZWZhdWx0Q29tbWFuZHMpO1xyXG4gICAgfVxyXG5cclxuICAgIG1hdGNoRGlyZWN0aW9uKHN0cikge1xyXG4gICAgICAgIGZvciAobGV0IGRpciBvZiBkaXJlY3Rpb25NYXApIHtcclxuICAgICAgICAgICAgaWYgKGRpclswXSA9PSBzdHIpIHJldHVybiBkaXJbMV07XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG59IiwiZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gTG9va0NvbW1hbmQoYXJncywgY29udGV4dCkge1xyXG4gICAgaWYgKGFyZ3MubGVuZ3RoID09IDEpIHtcclxuICAgICAgICBjb250ZXh0LmV4YW1pbmVSb29tKCk7XHJcbiAgICB9IGVsc2Uge1xyXG4gICAgICAgIGNvbnN0IHJvb20gPSBjb250ZXh0LmdldFJvb20oY29udGV4dC5wbGF5ZXIuY3VycmVudFJvb20pO1xyXG4gICAgICAgIGNvbnN0IGl0ZW1zID0gcm9vbS5nZXRJdGVtcygpO1xyXG4gICAgICAgIGxldCBpdGVtID0gbnVsbDtcclxuICAgICAgICBmb3IgKGxldCBpIG9mIGl0ZW1zKSB7XHJcbiAgICAgICAgICAgIGlmIChpLm5hbWUuaW5jbHVkZXMoYXJnc1sxXSkpIHtcclxuICAgICAgICAgICAgICAgIGl0ZW0gPSBpO1xyXG4gICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcbiAgICAgICAgaWYgKCFpdGVtKSB7XHJcbiAgICAgICAgICAgIGNvbnRleHQub3V0cHV0LnNheShgSSBjb3VsZCBub3QgZmluZCBhICR7YXJnc1sxXX1gKTtcclxuICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICBjb250ZXh0Lm91dHB1dC5zYXkoaXRlbS5uYW1lKTtcclxuICAgICAgICAgICAgY29udGV4dC5vdXRwdXQuc2F5KGl0ZW0uZGVzY3JpcHRpb24pO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxufSIsImV4cG9ydCBkZWZhdWx0IGFzeW5jIGZ1bmN0aW9uIFVzZUNvbW1hbmQoYXJncywgY29udGV4dCkge1xyXG4gICAgY29uc3Qgcm9vbSA9IGNvbnRleHQuZ2V0Um9vbShjb250ZXh0LnBsYXllci5jdXJyZW50Um9vbSk7XHJcbiAgICBjb25zdCBpdGVtcyA9IHJvb20uZ2V0SXRlbXMoKTtcclxuICAgIGxldCBpdGVtID0gbnVsbDtcclxuICAgIGZvciAobGV0IGkgb2YgaXRlbXMpIHtcclxuICAgICAgICBpZiAoaS5uYW1lLmluY2x1ZGVzKGFyZ3NbMV0pKSB7XHJcbiAgICAgICAgICAgIGl0ZW0gPSBpO1xyXG4gICAgICAgICAgICBicmVhaztcclxuICAgICAgICB9XHJcbiAgICB9XHJcbiAgICBpZiAoIWl0ZW0pIHtcclxuICAgICAgICBjb250ZXh0Lm91dHB1dC5zYXkoYEkgY291bGQgbm90IGZpbmQgYSAke2FyZ3NbMV19YCk7XHJcbiAgICB9IGVsc2Uge1xyXG4gICAgICAgIGF3YWl0IG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vbjtcclxuICAgICAgICByZXR1cm4gdGhpcztcclxuICAgIH1cclxuXHJcbiAgICB3aXRoRXhpdChkaXJlY3Rpb24sIHJvb21JRCkge1xyXG4gICAgICAgIHRoaXMucm9vbS5hZGRFeGl0KGRpcmVjdGlvbiwgcm9vbUlEKTtcclxuICAgICAgICByZXR1cm4gdGhpcztcclxuICAgIH1cclxuXHJcbiAgICB3aXRoSXRlbShpdGVtSUQpIHtcclxuICAgICAgICB0aGlzLnJvb20uYWRkSXRlbShpdGVtSUQpO1xyXG4gICAgICAgIHJldHVybiB0aGlzO1xyXG4gICAgfVxyXG5cclxuICAgIHdpdGhFbnRlckNhbGxiYWNrKGNhbGxiYWNrKSB7XHJcbiAgICAgICAgdGhpcy5yb29tLmFkZEVudGVyQ2FsbGJhY2soY2FsbGJhY2spO1xyXG4gICAgICAgIHJldHVybiB0aGlzO1xyXG4gICAgfVxyXG5cclxuICAgIHdpdGhFeGl0Q2FsbGJhY2soY2FsbGJhY2spIHtcclxuICAgICAgICB0aGlzLnJvb20uYWRkRXhpdENhbGxiYWNrKGNhbGxiYWNrKTtcclxuICAgICAgICByZXR1cm4gdGhpcztcclxuICAgIH1cclxuXHJcbiAgICB3aXRoRW50ZXJMb2dpYyhmdW5jKSB7XHJcbiAgICAgICAgdGhpcy5yb29tLmFkZEVudGVyTG9naWMoZnVuYyk7XHJcbiAgICAgICAgcmV0dXJuIHRoaXM7XHJcbiAgICB9XHJcblxyXG4gICAgd2l0aEV4aXRMb2dpYyhmdW5jKSB7XHJcbiAgICAgICAgdGhpcy5yb29tLmFkZEV4aXRMb2dpYyhmdW5jKTtcclxuICAgICAgICByZXR1cm4gdGhpcztcclxuICAgIH1cclxuXHJcbiAgICB3aXRoVGljayhmdW5jKSB7XHJcbiAgICAgICAgdGhpcy5yb29tLmFkZFRpY2tDYWxsYmFjayhmdW5jKTtcclxuICAgICAgICByZXR1cm4gdGhpcztcclxuICAgIH1cclxuXHJcbiAgICBjcmVhdGUoKSB7XHJc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dGF0ZSA9IFN0YXRlO1xyXG4gICAgICAgIHRoaXMucm9vbXMgPSBbXTtcclxuICAgICAgICB0aGlzLml0ZW1zID0gW107XHJcbiAgICAgICAgdGhpcy5vdXRwdXQgPSBuZXcgT3V0cHV0KCk7XHJcbiAgICAgICAgdGhpcy5jb21tYW5kSGFuZGxlciA9IG5ldyBDb21tYW5kcyh0aGlzKTtcclxuICAgICAgICB0aGlzLmlucHV0ID0gbmV3IElucHV0KHRoaXMuY29tbWFuZEhhbmRsZXIpO1xyXG4gICAgICAgIHRoaXMudmlzaXRlZFJvb21zID0gbmV3IE1hcCgpO1xyXG4gICAgfVxyXG5cclxuICAgIHByaW50KHN0cmluZykge1xyXG4gICAgICAgIHRoaXMub3V0cHV0LnNheShzdHJpbmcpO1xyXG4gICAgfVxyXG5cclxuICAgIGluaXQoZGF0YSkge1xyXG4gICAgICAgIGNvbnNvbGUubG9nKGRhdGEpO1xyXG4gICAgICAgIHRoaXMucm9vbXMgPSBkYXRhLnJvb21zLm1hcCgocm9vbSkgPT4ge1xyXG4gICAgICAgICAgICByb29tLmNvbnRleHQgPSB0aGlzO1xyXG4gICAgICAgICAgICByZXR1cm4gcm9vbTtcclxuICAgICAgICB9KTtcclxuICAgICAgICB0aGlzLml0ZW1zID0gZGF0YS5pdGVtcy5tYXAoKGl0ZW0pID0+IHtcclxuICAgICAgICAgICAgaXRlbS5jb250ZXh0ID0gdGhpcztcclxuICAgICAgICAgICAgcmV0dXJuIGl0ZW07XHJcbiAgICAgICAgfSk7XHJcbiAgICAgICAgdGhpcy5zdGF0ZSA9IGRhdGEuc3RhdGU7XHJcbiAgICAgICAgdGhpcy5jb21tYW5kSGFuZGxlci5hZGRDb21tYW5kcyhkYXRhLmNvbW1hbmRzKTtcclxuICAgICAgICB0aGlzLnBsYXllciA9IG5ldyBQbGF5ZXIoKTtcclxuICAgICAgICB0aGlzLm1vdmUodGhpcy5wbGF5ZXIuY3VycmVudFJvb20pO1xyXG4gICAgfVxyXG5cclxuICAgIGV4YW1pbmVSb29tKCkge1xyXG4gICAgICAgIGNvbnN0IHJvb20gPSB0aGlzLmdldFJvb20odGhpcy5wbGF5ZXIuY3VycmVudFJvb20pO1xyXG4gICAgICAgIHRoaXMub3V0cHV0LnNheShyb29tLnRpdGxlKTtcclxuICAgICAgICBpZiAoIXRoaXMudmlzaXRlZFJvb21zLmdldCh0aGlzLnBsYXllci5jdXJyZW50Um9vbSkgJiYgcm9vbS5maXJzdERlc2NyaXB0aW9uICE9IFwiXCIpIHtcclxuICAgICAgICAgICAgdGhpcy5vdXRwdXQuc2F5KHJvb20uZmlyc3REZXNjcmlwdGlvbik7XHJcbiAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgdGhpcy5vdXRwdXQuc2F5KHJvb20uZGVzY3JpcHRpb24pO1xyXG4gICAgICAgIH1cclxuICAgICAgICB0aGlzLmV4YW1pbmVJdGVtcygpO1xyXG4gICAgICAgIHRoaXMuZXhhbWluZUV4aXRzKCk7XHJcbiAgICB9XHJcblxyXG4gICAgZXhhbWluZUl0ZW1zKCkge1xyXG4gICAgICAgIGNvbnN0IHJvb20gPSB0aGlzLmdldFJvb20odGhpcy5wbGF5ZXIuY3VycmVudFJvb20pO1xyXG4gICAgICAgIGNvbnN0IGl0ZW1zID0gcm9vbS5nZXRJdGVtcygpO1xyXG4gICAgICAgIGl0ZW1zLmZvckVhY2goKGl0ZW0pID0+IHRoaXMub3V0cHV0LnNheShpdGVtLm5hbWUpKTtcclxuICAgIH1cclxuXHJcbiAgICBleGFtaW5lRXhpdHMoKSB7XHJcbiAgICAgICAgY29uc3Qgcm9vbSA9IHRoaXMuZ2V0Um9vbSh0aGlzLnBsYXllci5jdXJyZW50Um9vbSk7XHJcbiAgICAgICAgbGV0IGV4aXREZXNjcmlwdGlvbiA9IFwiWW91IGNhbiBnbyBcIjtcclxuICAgICAgICBmb3IgKGxldCBleGl0IG9mIHJvb20uZXhpdHMua2V5cygpKSB7XHJcbiAgICAgICAgICAgIGV4aXREZXNjcmlwdGlvbiArPSBcIiBcIiArIGV4aXQ7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHRoaXMub3V0cHV0LnNheShleGl0RGVzY3JpcHRpb24pO1xyXG4gICAgfVxyXG5cclxuICAgIGdldFJvb20oaWQpIHtcclxuICAgICAgICByZXR1cm4gdGhpcy5yb29tcy5maW5kKChyb29tKSA9PiByb29tLmlkID09IGlkKTtcclxuICAgIH1cclxuXHJcbiAgICBnZXRJdGVtKGlkKSB7XHJcbiAgICAgICAgcmV0dXJuIHRoaXMuaXRlbXMuZmluZCgoaXRlbSkgPT4gaXRlbS5pZCA9PSBpZCk7XHJcbiAgICB9XHJcblxyXG4gICAgd2FpdChtcykge1xyXG4gICAgICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7XHJcbiAgICAgICAgICAgIHNldFRpbWVvdXQocmVzb2x2ZSwgbXMpO1xyXG4gICAgICAgIH0pO1xyXG4gICAgfVxyXG5cclxuICAgIGFzeW5jIG1vdmUocm9vbUlEKSB7XHJcbiAgICAgICAgY29uc3QgY3VycmVudFJvb20gPSB0aGlzLmdldFJvb20odGhpcy5wbGF5ZXIuY3VycmVudFJvb20pO1xyXG4gICAgICAgIGNvbnN0IG5ld1Jvb20gPSB0aGlzLmdldFJvb20ocm9vbUlEKTtcclxuICAgICAgICBpZiAoY3VycmVudFJvb20uY2FuRXhpdCgpICYmIG5ld1Jvb20uY2FuRW50ZXIoKSkge1xyXG4gICAgICAgICAgICBhd2FpdCBjdXJyZW50Um9vbS5vbkV4aXQoKTtcclxuICAgICAgICAgICAgYXdhaXQgbmV3Um9vbS5vbkVudGVyKCk7XHJcbiAgICAgICAgICAgIHRoaXMucGxheWVyLmN1cnJlbnRSb29tID0gcm9vbUlEO1xyXG4gICAgICAgICAgICB0aGlzLmV4YW1pbmVSb29tKCk7XHJcbiAgICAgICAgICAgIHRoaXMudmlzaXRlZFJvb21zLnNldChyb29tSUQs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