!function(e,t){function n(e){var t=this,n={autoplay:!0,erase:!0};t.events={},t.scene=-1,t.scenario=[],t.options=t.utils.merge(n,e||{}),t.casting={},t.current={},t.state="ready"}n.prototype={constructor:n,set:function(e,t){var n=this;switch(n.current.model=e,n.current.type){case"function":n.current.voice.apply(n,t);break;default:n.current.voice.innerHTML=e}return n},getSayingSpeed:function(e,t){"number"!=typeof e&&(t=e,e=0);var n=this,r=n.current.experience+e,i=t?r:n.utils.randomFloat(r,1);return n.utils.getPercentageBetween(1e3,50,i)},getInvincibility:function(){var e=this;return 10*e.current.experience},isMistaking:function(){var e=this;return e.current.experience<e.utils.randomFloat(0,1.4)},utils:{merge:function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},getPercentageBetween:function(e,t,n){return e-e*n+t*n},randomChar:function(){var e=this,t="abcdefghijklmnopqrstuvwxyz";return t.charAt(e.randomNumber(0,t.length-1))},randomNumber:function(e,t){return Math.floor(Math.random()*(t-e+1))+e},randomFloat:function(e,t){return Math.round(10*(Math.random()*(t-e)+e))/10},hasClass:function(e,t){return e.classList?e.classList.contains(t):new RegExp("(^| )"+t+"( |$)","gi").test(e.className)},addClass:function(e,t){e.classList?e.classList.add(t):e.className+=" "+t},removeClass:function(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\b)"+t.split(" ").join("|")+"(\\b|$)","gi")," ")}},train:function(e){var t=this,n={experience:.6,voice:function(e){console.log(e)},type:"function",model:""};return t.utils.merge(n,e)},describe:function(e,n,r){if("string"!=typeof e)throw"actor's name has wrong type: "+typeof e;var i=this,a={name:e};return void 0!==n&&(a.experience=n),void 0!==r&&(a.type="function"==typeof r?"function":"DOM",a.voice="DOM"===a.type&&"string"==typeof r?t.querySelector(r):r),i.casting[e]=i.train(a),i},write:function(){for(var e,t=this,n=Array.prototype.splice.apply(arguments,[0]),r=0,i=n.length;i>r;r++)if(e=n[r],"string"==typeof e){var a=e.split(":"),s=a.length>1,o=s?a[0].trim():null,c=s?a[1]:a[0];s&&t.write({name:"actor",args:[o]}),t.options.erase&&s&&t.write({name:"erase"}),t.write({name:"say",args:[c,!s]})}else"number"==typeof e?t.write(0>e?{name:"erase",args:[e]}:{name:"wait",args:[e]}):"function"==typeof e?t.write({name:"call",args:[e]}):e instanceof Object&&t.scenario.push(e);return t.options.autoplay&&t.play(),t},play:function(e){var t=this;return e===!0&&(t.scene=-1),"ready"===t.state&&t.next(),t},on:function(e,t){var n=this;e=e.split(",");for(var r,i=0,a=e.length;a>i;i++)r=e[i]=e[i].trim(),(n.events[r]||(n.events[r]=[])).push(t);return n},emit:function(e,t,n){if("string"!=typeof e)throw"emit: scope missing";"string"!=typeof t?t=void 0:void 0!==t&&void 0===n&&(n=t);var r=this,i=e+(t?":"+t:"");return r.trigger(i,n).trigger("*",[i].concat(n)),r},trigger:function(e,t){var n=this,r=n.events[e]||[];t instanceof Array||(t=[t]);for(var i=0,a=r.length;a>i;i++)r[i].apply(n,[e].concat(t));return n},call:function(e,t){var n=this;return e.apply(n),t?n:n.next()},next:function(){var e=this,t=e.scenario[e.scene];if(t&&e.emit(t.name,"end",[t.name].concat(t.args)),e.scene+1>=e.scenario.length)e.state="ready";else{e.state="playing";var n=e.scenario[++e.scene];e.emit(n.name,"start",[n.name].concat(n.args)),e[n.name].apply(e,n.args)}return e},actor:function(e){var t=this;return t.current=t.casting[e],t.next()},say:function(e,t){var n,r,i=this,a=!1,s=i.getInvincibility();t?(r=i.current.model,n=i.current.model.length-1,e=r+e):(r=i.current.model="",n=-1);var o=setTimeout(function c(){var t,u,l=r.charAt(n);a?(s=i.getInvincibility(),a=!1,t=null,u=r=r.substr(0,n),n--):(n++,t=--s<0&&i.isMistaking()?i.utils.randomChar():e.charAt(n),t!==e.charAt(n)&&(a=!0),u=r+=t),i.set(u,[u,t,l,e]),a||n<e.length?o=setTimeout(c,i.getSayingSpeed()):i.next()},i.getSayingSpeed());return i},erase:function(e){var t=this,n="string"==typeof t.current.model?t.current.model.length:-1,r="number"==typeof e&&0>e?n+1+e:0;if(0>n)return t.next();setTimeout(function i(){var e=t.current.model.charAt(n),a=t.current.model.substr(0,--n);t.set(a,[a,null,e,a]),n>=r?setTimeout(i,t.getSayingSpeed(.2,!0)):t.next()},t.getSayingSpeed(.2,!0));return t},wait:function(e){var t=this;return setTimeout(function(){t.next()},e),t}},e.TheaterJS=n}(window,document);
{'avg_line_length': 4325.0, 'max_line_length': 4325, 'alphanum_fraction': 0.6802312138728324, 'licenses': ['MIT'], 'repository_name': 'huangxi0606/hx_wechat', 'path': 'public/js/ac/theater.min.js', 'size': 4325, 'lang': 'JavaScript'}