UNPKG

@glorious/demo

Version:

The easiest way to demonstrate your code in action

1 lines 26.1 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.GDemo=e():t.GDemo=e()}(window,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=18)}([function(t,e,n){window,t.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=10)}([function(t,e,n){"use strict";var r,i,o,a=n(3),u="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";function c(){o=!1}function l(t){if(t){if(t!==r){if(t.length!==u.length)throw new Error("Custom alphabet for shortid must be "+u.length+" unique characters. You submitted "+t.length+" characters: "+t);var e=t.split("").filter((function(t,e,n){return e!==n.lastIndexOf(t)}));if(e.length)throw new Error("Custom alphabet for shortid must be "+u.length+" unique characters. These characters were not unique: "+e.join(", "));r=t,c()}}else r!==u&&(r=u,c())}function s(){return o||(o=function(){r||l(u);for(var t,e=r.split(""),n=[],i=a.nextValue();e.length>0;)i=a.nextValue(),t=Math.floor(i*e.length),n.push(e.splice(t,1)[0]);return n.join("")}())}t.exports={get:function(){return r||u},characters:function(t){return l(t),r},seed:function(t){a.seed(t),i!==t&&(c(),i=t)},lookup:function(t){return s()[t]},shuffled:s}},function(t,e,n){"use strict";t.exports=n(2)},function(t,e,n){"use strict";var r=n(0),i=n(4),o=n(8),a=n(9)||0;function u(){return i(a)}t.exports=u,t.exports.generate=u,t.exports.seed=function(e){return r.seed(e),t.exports},t.exports.worker=function(e){return a=e,t.exports},t.exports.characters=function(t){return void 0!==t&&r.characters(t),r.shuffled()},t.exports.isValid=o},function(t,e,n){"use strict";var r=1;t.exports={nextValue:function(){return(r=(9301*r+49297)%233280)/233280},seed:function(t){r=t}}},function(t,e,n){"use strict";var r,i,o=n(5),a=(n(0),1567752802062);t.exports=function(t){var e="",n=Math.floor(.001*(Date.now()-a));return n===i?r++:(r=0,i=n),e+=o(7),e+=o(t),r>0&&(e+=o(r)),e+o(n)}},function(t,e,n){"use strict";var r=n(0),i=n(6),o=n(7);t.exports=function(t){for(var e,n=0,a="";!e;)a+=o(i,r.get(),1),e=t<Math.pow(16,n+1),n++;return a}},function(t,e,n){"use strict";var r,i="object"==typeof window&&(window.crypto||window.msCrypto);r=i&&i.getRandomValues?function(t){return i.getRandomValues(new Uint8Array(t))}:function(t){for(var e=[],n=0;n<t;n++)e.push(Math.floor(256*Math.random()));return e},t.exports=r},function(t,e){t.exports=function(t,e,n){for(var r=(2<<Math.log(e.length-1)/Math.LN2)-1,i=Math.ceil(1.6*r*n/e.length),o="";;)for(var a=i,u=t(a);a--;)if((o+=e[u[a]&r]||"").length===+n)return o}},function(t,e,n){"use strict";var r=n(0);t.exports=function(t){return!(!t||"string"!=typeof t||t.length<6||new RegExp("[^"+r.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]").test(t))}},function(t,e,n){"use strict";t.exports=0},function(t,e,n){"use strict";n.r(e);var r=n(1),i=n.n(r),o={init:function(){i.a.characters("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz$_")},generate:function(){return i.a.generate()}};o.init();var a=o,u={onScroll:function(t){window.addEventListener("scroll",t)},isElementAbovePageFold:function(t){return t.offsetTop-(u.getInnerHeight()+u.getPageYOffset())<0},getInnerHeight:function(){return window.innerHeight},getPageYOffset:function(){return window.pageYOffset}},c=u,l={},s=[];function f(){s.forEach((function(t){return p(t.element,t.onShowUp)}))}function p(t,e){c.isElementAbovePageFold(t)&&e()}l.init=function(){c.onScroll(f)},l.subscribe=function(t,e){return setTimeout((function(){return p(t,e)})),function(t,e){var n=a.generate();return s.push({id:n,element:t,onShowUp:e}),n}(t,e)},l.unsubscribe=function(t){var e;s.splice((e=t,s.find((function(t){return t.id===e}))),1)},l.init(),e.default=l}]).default},function(t,e){t.exports='<div class="application" data-application>\n <div class="application-topbar">\n <div class="application-actions-container">\n <div class="application-action application-action-close"></div>\n <div class="application-action application-action-minimize"></div>\n <div class="application-action application-action-maximize"></div>\n </div>\n <div class="application-title-container" data-title-container></div>\n </div>\n <div class="application-content-container" data-content-container></div>\n</div>\n'},function(t,e){t.exports='<span class="cursor"></span>\n'},function(t,e){t.exports='<div class="editor-line">\n <div class="editor-line-number" data-editor-line-number></div>\n <pre class="editor-line-text" data-editor-line-text></pre>\n</div>\n'},function(t,e){t.exports='<div class="terminal-line"></div>\n'},function(t,e){t.exports='<div>\n <div\n class="terminal-command-line-prompt-string"\n data-terminal-command-line-prompt-string>\n </div>\n <div\n class="terminal-command-line-text"\n data-terminal-command-line-text>\n </div>\n</div>\n'},function(t,e){t.exports='<div class="terminal-response-line-text" data-terminal-response-line-text></div>\n'},function(t,e){t.exports='<div class="desktop"></div>\n'},function(t,e,n){},function(t,e,n){},function(t,e,n){},function(t,e,n){},function(t,e,n){},function(t,e,n){},function(t,e,n){},function(t,e,n){},function(t,e,n){},function(t,e,n){},function(t,e,n){"use strict";n.r(e),n.d(e,"default",(function(){return Lt}));n(8),n(9);var r=n(0),i=n.n(r),o=(n(10),n(11),n(12),{parseHtml:function(t){return(new DOMParser).parseFromString(t,"text/html").querySelector("body").firstChild},wrapHtmlStringInHtmlTag:function(t,e){return"<".concat(e,">").concat(t,"</").concat(e,">")},clearNodeContent:function(t){return t.innerHTML="",t},containsClosingHtmlTag:function(t){return new RegExp("</.+>","gm").test(t)},isHtmlNodeTypeText:function(t){return t&&"#text"==t.nodeName.toLowerCase()}}),a=o,u={toKebabCase:function(t){return t.toLowerCase().replace(" ","-")},isEmptyString:function(t){return""===t.trim()},removeBlankFirstLine:function(t){var e=t.split("\n");return""===e[0].trim()&&e.splice(0,1),e}},c=u,l=n(1),s=n.n(l);function f(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if(!(Symbol.iterator in Object(t))&&"[object Arguments]"!==Object.prototype.toString.call(t))return;var n=[],r=!0,i=!1,o=void 0;try{for(var a,u=t[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==u.return||u.return()}finally{if(i)throw o}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function p(t,e){if(null==t)return{};var n,r,i=function(t,e){if(null==t)return{};var n,r,i={},o=Object.keys(t);for(r=0;r<o.length;r++)n=o[r],e.indexOf(n)>=0||(i[n]=t[n]);return i}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(r=0;r<o.length;r++)n=o[r],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function m(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function d(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var v=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.id,i=void 0===r?"_default":r,o=p(n,["id"]);m(this,t),this.type=e,this.id=i,this.options=o,this.element=y(e),this.setOptions(this.options)}var e,n,r;return e=t,(n=[{key:"setOptions",value:function(t){var e=this;Object.entries(t).forEach((function(t){var n=f(t,2),r=n[0],i=n[1],o=e.getOptionHandler(r);o&&o(i)}))}},{key:"getOptionHandler",value:function(t){var e=this;return{minHeight:function(t){return e.setMinHeight(t)},windowTitle:function(t){return e.setWindowTitle(t)},inanimate:function(t){return e.configAnimation(t)}}[t]}},{key:"setMinHeight",value:function(t){var e=h(this.element),n=parseInt(t)-26;e.style.minHeight="".concat(n,"px")}},{key:"setWindowTitle",value:function(t){this.element.querySelector("[data-title-container]").innerText=t,this.windowTitle=t}},{key:"configAnimation",value:function(t){this.setInanimate(t),t&&g(this.element).classList.add("application-inanimate")}},{key:"addContent",value:function(t){h(this.element).appendChild(t)}},{key:"setInanimate",value:function(t){this.inanimate=t}},{key:"minimize",value:function(){this.setMaximized(!1),b(this.element,"remove","application-maximized"),b(this.element,"add","application-minimized")}},{key:"maximize",value:function(){this.setMaximized(!0),b(this.element,"remove","application-minimized"),b(this.element,"add","application-maximized")}},{key:"setMaximized",value:function(t){this.isMaximized=t}}])&&d(e.prototype,n),r&&d(e,r),t}();function y(t){var e=function(t){var e=document.createElement("div"),n="".concat(c.toKebabCase(t),"-application");return e.setAttribute("class",n),e}(t);return e.appendChild(a.parseHtml(s.a)),e}function h(t){return t.querySelector("[data-content-container]")}function b(t,e,n){g(t).classList[e](n)}function g(t){return t.querySelector("[data-application]")}n(13),n(14);var w={};w.type=function(t,e,n){var r=e.split(""),i=r.shift();i?function(t,e,n,r){t.append(e),setTimeout((function(){w.type(t,n.join(""),r)}),75)}(t,i,r,n):n()};var O=w,x={};function S(t,e,n){O.type(e,t,n)}x.type=function(t,e,n){!function t(e,n,r){if(!n.length)return r();!function(t,e,n){a.isHtmlNodeTypeText(e)?S(e.textContent,t,n):S(e.textContent,function(t,e){var n=a.clearNodeContent(e);return t.appendChild(n),n}(t,e),n)}(e,n.shift(),(function(){t(e,n,r)}))}(t,function(t){var e=a.wrapHtmlStringInHtmlTag(t,"span"),n=a.parseHtml(e);return Array.from(n.childNodes)}(e),n)};var j=x,C={};function k(t,e,n){t.classList[e](n)}C.type=function(t,e,n){k(t,"add","is-typing"),function(t){return a.containsClosingHtmlTag(t)?j:O}(e).type(t,e,(function(){k(t,"remove","is-typing"),n()}))};var P=C,T=n(2),_=n.n(T);function E(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var A=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.element=a.parseHtml(_.a)}var e,n,r;return e=t,(n=[{key:"write",value:function(t,e){P.type(this.element,t,e)}},{key:"setActive",value:function(){H(this.element,"add","cursor-active")}},{key:"setInactive",value:function(){H(this.element,"remove","cursor-active")}}])&&E(e.prototype,n),r&&E(e,r),t}();function H(t,e,n){t.classList[e](n)}var M=n(3),L=n.n(M);function z(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var I=function(){function t(e,n){var r,i;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.cursor=new A,this.element=a.parseHtml(L.a),r=this.element,i=e,(function(t){return N(t,"[data-editor-line-number]")}(r)).innerText=i,function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";D(t).innerHTML=e}(this.element,n),n||D(this.element).appendChild(this.cursor.element)}var e,n,r;return e=t,(n=[{key:"write",value:function(t,e){this.cursor.write(t,e)}},{key:"setActive",value:function(){this.cursor.setActive()}},{key:"setInactive",value:function(){this.cursor.setInactive()}}])&&z(e.prototype,n),r&&z(e,r),t}();function D(t){return N(t,"[data-editor-line-text]")}function N(t,e){return t.querySelector(e)}function q(t){return(q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function R(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function F(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function V(t,e){return!e||"object"!==q(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function W(t){return(W=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function Y(t,e){return(Y=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var B=function(t){function e(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return R(this,e),(n=V(this,W(e).call(this,"editor",r))).container=t,n.container.appendChild(n.element),n.setupInitialContent(r.initialContent),n.setWindowTitle(G(r)),n}var n,r,i;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Y(t,e)}(e,t),n=e,(r=[{key:"setupInitialContent",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=U(t);this.setLines([]),this.appendLines(e)}},{key:"setLines",value:function(t){this.lines=[]}},{key:"appendLines",value:function(t){var e=this;t.forEach((function(t){var n=K(e.lines,t);$(e,n)}))}},{key:"write",value:function(t,e){!function t(e,n,r){var i,o=n.shift();void 0!==o?((i=e.lines).length&&i[i.length-1].setInactive(),function(t,e,n){var r=K(t.lines);$(t,r),r.setActive(),r.write(e,n)}(e,o,(function(){t(e,n,r)}))):r()}(this,U(t.codeSample),e)}}])&&F(n.prototype,r),i&&F(n,i),e}(v);function U(t){return c.removeBlankFirstLine(t)}function G(t){return t.windowTitle||"~/demo/demo.js"}function K(t,e){return new I(t.length+1,e)}function $(t,e){t.addContent(e.element),t.lines.push(e)}n(15),n(16);var J=n(4),Q=n.n(J);function X(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var Z=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.element=a.parseHtml(Q.a)}var e,n,r;return e=t,(n=[{key:"setContent",value:function(t){this.element.append(t)}}])&&X(e.prototype,n),r&&X(e,r),t}(),tt=n(5),et=n.n(tt);function nt(t){return(nt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function rt(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function it(t,e){return!e||"object"!==nt(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function ot(t){return(ot=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function at(t,e){return(at=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var ut=function(t){function e(t){var n,r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(n=it(this,ot(e).call(this))).cursor=new A,n.setContent(a.parseHtml(et.a)),n.setPromptString(t),(r=n.element,r.querySelector("[data-terminal-command-line-text]")).appendChild(n.cursor.element),n}var n,r,i;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&at(t,e)}(e,t),n=e,(r=[{key:"setPromptString",value:function(t){this.element.querySelector("[data-terminal-command-line-prompt-string]").appendChild(a.parseHtml(t))}},{key:"command",value:function(t,e){this.cursor.write(t,e)}},{key:"setActive",value:function(){this.cursor.setActive()}},{key:"setInactive",value:function(){this.cursor.setInactive()}}])&&rt(n.prototype,r),i&&rt(n,i),e}(Z);n(17);var ct=n(6),lt=n.n(ct);function st(t){return(st="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ft(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function pt(t,e){return!e||"object"!==st(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function mt(t){return(mt=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function dt(t,e){return(dt=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var vt=function(t){function e(){var t;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(t=pt(this,mt(e).call(this))).setContent(a.parseHtml(lt.a)),t}var n,r,i;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&dt(t,e)}(e,t),n=e,(r=[{key:"setText",value:function(t){var e,n,r=this.element.querySelector("[data-terminal-response-line-text]");return a.containsClosingHtmlTag(t)?(e=r,n=a.parseHtml(t),yt(e,"terminal-response-line-html-text"),void e.appendChild(n)):function(t,e){yt(t,"terminal-response-line-plain-text"),t.innerText=e}(r,t)}}])&&ft(n.prototype,r),i&&ft(n,i),e}(Z);function yt(t,e){t.classList.add(e)}function ht(t){return(ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function bt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function gt(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function wt(t,e){return!e||"object"!==ht(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function Ot(t){return(Ot=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function xt(t,e){return(xt=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var St=function(t){function e(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return bt(this,e),(n=wt(this,Ot(e).call(this,"terminal",r))).container=t,n.container.appendChild(n.element),n.setCommandLines([]),n.configOptions(r),n}var n,r,i;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&xt(t,e)}(e,t),n=e,(r=[{key:"configOptions",value:function(t){this.setWindowTitle(function(t){return t.windowTitle||"bash"}(t)),this.setPromptString(function(t){return t.promptString||"~/demo $"}(t))}},{key:"setCommandLines",value:function(t){this.commandLines=t}},{key:"setPromptString",value:function(t){this.promptString=t}},{key:"command",value:function(t,e){var n,r=t.command,i=t.promptString;i&&this.setPromptString(i),(n=this.commandLines).length&&n[n.length-1].setInactive(),function(t,e,n){var r=new ut(t.promptString);t.commandLines.push(r),t.addContent(r.element),r.setActive(),r.command(e,n)}(this,r,e)}},{key:"respond",value:function(t,e){for(var n=t.response,r=c.removeBlankFirstLine(n),i=0;i<r.length;i++)this.addContent(jt(r[i]));e()}}])&&gt(n.prototype,r),i&&gt(n,i),e}(v);function jt(t){var e=new vt;return e.setText(t),e.element}var Ct=n(7),kt=n.n(Ct);function Pt(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var Tt=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.element=a.parseHtml(kt.a),this.container=e,this.openApplications=[],this.container.appendChild(this.element)}var e,n,r;return e=t,(n=[{key:"openApplication",value:function(t,e){var n=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.id||"_default";return t.filter((function(t){return t.type===e})).find((function(t){return t.id===r}))}(this.openApplications,t,e);return n||function(t,e,n){var r=new("editor"==e?B:St)(t.element,n);return t.openApplications.push(r),t.element.appendChild(r.element),r}(this,t,e)}},{key:"minimizeAllApplications",value:function(t){this.openApplications.forEach((function(t){return t.minimize()})),t&&setTimeout(t,750)}},{key:"maximizeApplication",value:function(t,e){return t.maximize(),t.inanimate?e():setTimeout(e,750)}}])&&Pt(e.prototype,n),r&&Pt(e,r),t}();function _t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var Et=function(){function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.container=e,this.steps=n,this.desktop=new Tt(e),this.setCurrentStepNumber(0)}var e,n,r;return e=t,(n=[{key:"play",value:function(){var t=this,e=this.desktop,n=this.steps;return new Promise((function(r){return function t(e,n,r,i){var o=e.getCurrentStepNumber();if(o<r.length){var a=r[o];!function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;At(t,e.app,e.options,(function(t){var i=function(){return setTimeout(n,r)};return e.action?t[e.action](e.params,i):i()}))}(n,a,(function(){e.setCurrentStepNumber(o+1),t(e,n,r,i)}),a.onCompleteDelay)}else i()}(t,e,n,r)}))}},{key:"getCurrentStepNumber",value:function(){return this.currentStepNumber}},{key:"setCurrentStepNumber",value:function(t){this.currentStepNumber=t}}])&&_t(e.prototype,n),r&&_t(e,r),t}();function At(t,e,n,r){var i=t.openApplication(e,n),o=function(){return r(i)};i.isMaximized?r(i):i.inanimate?(t.minimizeAllApplications(),t.maximizeApplication(i,o)):t.minimizeAllApplications((function(){t.maximizeApplication(i,o)}))}function Ht(t,e){if(null==t)return{};var n,r,i=function(t,e){if(null==t)return{};var n,r,i={},o=Object.keys(t);for(r=0;r<o.length;r++)n=o[r],e.indexOf(n)>=0||(i[n]=t[n]);return i}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(r=0;r<o.length;r++)n=o[r],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Mt(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var Lt=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.container=document.querySelector(e),this.steps=[]}var e,n,r;return e=t,(n=[{key:"openApp",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.steps.push({app:t,options:e,onCompleteDelay:e.onCompleteDelay}),this}},{key:"write",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.onCompleteDelay,r=Ht(e,["onCompleteDelay"]);return this.steps.push({app:"editor",action:"write",params:{codeSample:t},onCompleteDelay:n,options:r}),this}},{key:"command",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.onCompleteDelay,r=e.promptString,i=Ht(e,["onCompleteDelay","promptString"]);return this.steps.push({app:"terminal",action:"command",params:{command:t,promptString:r},onCompleteDelay:n,options:i}),this}},{key:"respond",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.onCompleteDelay,r=Ht(e,["onCompleteDelay"]);return this.steps.push({app:"terminal",action:"respond",params:{response:t},onCompleteDelay:n,options:r}),this}},{key:"end",value:function(){var t=this;return new Promise((function(e){!function(t,e,n){var r=i.a.subscribe(t,(function(){var o=new Et(t,e);i.a.unsubscribe(r),o.play().then(n)}))}(t.container,t.steps,e)}))}}])&&Mt(e.prototype,n),r&&Mt(e,r),t}()}]).default}));