-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.min.js
52 lines (50 loc) · 28.7 KB
/
script.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var App,app;App=require("./view/App"),app=new App,app.addTo(document.getElementById("jscontainer"));
},{"./view/App":12}],2:[function(require,module,exports){
module.exports=function(t){if(t>53)throw new RangeError("BitSet is only safe for up to 53 elements");return function(){function r(t){this.id=null!=t?t:0}return r.size=t,r.allId=(1<<t)-1,r.prototype.setId=function(t){return this.id=t,this},r.prototype.has=function(r){return this.id>>r%t&1},r.prototype.add=function(r){return this.id|=1<<r%t,this},r.prototype.remove=function(r){return this.id&=~(1<<r%t),this},r.prototype.clear=function(){return this.setId(0)},r.prototype.map=function(r,o){var n,i,e,s;for(null==o&&(o=this),s=[],n=i=0,e=t;0<=e?i<e:i>e;n=0<=e?++i:--i)this.has(n)&&s.push(r.call(o,n));return s},r.prototype.toArray=function(){var r,o,n,i;for(i=[],r=o=0,n=t;0<=n?o<n:o>n;r=0<=n?++o:--o)this.has(r)&&i.push(r);return i},r.prototype.filter=function(r,o){var n,i,e;for(null==o&&(o=this),n=i=0,e=t;0<=e?i<e:i>e;n=0<=e?++i:--i)this.has(n)&&(r.call(o,n)||this.remove(n));return this},r.prototype.addAll=function(t){var r,o,n;for(o=0,n=t.length;o<n;o++)r=t[o],this.add(r);return this},r.prototype.length=function(){var r,o,n,i;for(n=0,r=o=0,i=t;0<=i?o<i:o>i;r=0<=i?++o:--o)this.has(r)&&n++;return n},r.prototype.rotate=function(t){var r;return null==t&&(t=1),r=this.id>>this.constructor.size-t|this.id<<t&this.constructor.allId,this.setId(r)},r.prototype.clone=function(){return new this.constructor(this.id)},r}()};
},{}],3:[function(require,module,exports){
var Grid,GridBase,Quad,Square,extend=function(r,e){function t(){this.constructor=r}for(var o in e)hasProp.call(e,o)&&(r[o]=e[o]);return t.prototype=e.prototype,r.prototype=new t,r.__super__=e.prototype,r},hasProp={}.hasOwnProperty;GridBase=require("./GridBase"),Square=require("./Square"),Quad=require("./Quad"),module.exports=Grid=function(r){function e(){return e.__super__.constructor.apply(this,arguments)}return extend(e,r),e.prototype.newDefault=function(){return new Square(0)},e.prototype.checkAll=function(){var r,e,t,o,n,u,a,i,p,s,c;for(u=this.allCoordinates(),r=0,t=u.length;r<t;r++)for(a=u[r],s=a[0],c=a[1],p=this.getAt(s,c),i=Quad.all,e=0,o=i.length;e<o;e++)if(n=i[e],!p.checkMatch(this.getAtToQuad(s,c,n),n))return!1;return!0},e}(GridBase);
},{"./GridBase":4,"./Quad":6,"./Square":7}],4:[function(require,module,exports){
var GridBase,Quad;Quad=require("./Quad"),module.exports=GridBase=function(){function t(t,r,i){var n,o;this.w=t,this.h=r,this.gridParts=i,null==this.gridParts&&(this.gridParts=function(t,r){return this.newDefault()}),this.gridParts.call&&(this.gridParts=function(){var t,r,i;for(i=[],o=t=0,r=this.h;0<=r?t<r:t>r;o=0<=r?++t:--t)i.push(function(){var t,r,i;for(i=[],n=t=0,r=this.w;0<=r?t<r:t>r;n=0<=r?++t:--t)i.push(this.gridParts.call(this,n,o));return i}.call(this));return i}.call(this))}return t.prototype.contains=function(t,r){return t>=0&&r>=0&&t<this.w&&r<this.h},t.prototype.getAt=function(t,r){var i;return(null!=(i=this.gridParts[r])?i[t]:void 0)||this.newDefault()},t.prototype.getAtToQuad=function(t,r,i){var n;return n=Quad.direction(i),this.getAt(t+n[0],r+n[1])},t.prototype.toArray=function(){var t;return(t=[]).concat.apply(t,this.gridParts)},t.prototype.allCoordinates=function(){var t,r,i;return(t=[]).concat.apply(t,function(){var t,n,o;for(o=[],r=t=0,n=this.w;0<=n?t<n:t>n;r=0<=n?++t:--t)o.push(function(){var t,n,o;for(o=[],i=t=0,n=this.h;0<=n?t<n:t>n;i=0<=n?++t:--t)o.push([r,i]);return o}.call(this));return o}.call(this))},t.prototype.clone=function(){return new this.constructor(this.w,this.h,function(t){return function(r,i){return t.getAt(r,i).clone()}}(this))},t}();
},{"./Quad":6}],5:[function(require,module,exports){
var Grid,Levels,Quad,Square,slice=[].slice;Square=require("./Square"),Grid=require("./Grid"),Quad=require("./Quad"),module.exports=Levels=function(){function e(){}var t,r,n,a,u,o;return e.prototype.get=function(e){return t[e]||o(this.generateLevel(e))},e.prototype.generateLevel=function(e){var t,n,a,o,l,i,c;switch(a=u(e+1),o=a(),!1){case!(e<20):c=[3,3],n=[5,7];break;case!(e<50):c=[6,7],n=[6,7];break;case!(e<100):c=[6,7],n=[6,8];break;case!(e<200):c=[7,12],n=[7,9];break;default:c=[9,15],n=[9,9]}return t=.5,i=function(){switch(!1){case!(e<20):return.1;case!(e<30):return.9;default:return Math.min(10/e,.05)}}(),l=a()<i,r(c,n,t,l,a)},r=function(e,t,r,n,u){var o,l,i,c,s,d,f,h,p,Q,g,v,q,A,M;for(null==u&&(u=Math.random),n&&(r/=2),q=a.apply(null,slice.call(e).concat([u])),c=a.apply(null,slice.call(t).concat([u])),i=new Grid(q,c),g=i.allCoordinates(),s=0,f=g.length;s<f;s++)for(v=g[s],A=v[0],M=v[1],Q=[],A!==q-1&&Q.push(1),M!==c-1&&Q.push(2),d=0,h=Q.length;d<h;d++)p=Q[d],u()<r&&(l=Quad.oppositeOf(p),i.getAt(A,M).setQuad(p),i.getAtToQuad(A,M,p).setQuad(l),n&&(o=q-A-1,1===p?(i.getAt(o,M).setQuad(l),i.getAtToQuad(o,M,l).setQuad(p)):(i.getAt(o,M).setQuad(p),i.getAtToQuad(o,M,p).setQuad(l))));return i},u=function(e){return function(){return e=1e6*Math.sin(e),e-Math.floor(e)}},a=function(e,t,r){return null==r&&(r=Math.random),Math.floor(r()*(t-e)+e)},n=function(e,t,r){return new Grid(e,t,function(t,n){return new Square(r[t+n*e])})},o=function(e){var t,r,n,u;for(n=e.toArray(),t=0,r=n.length;t<r;t++)u=n[t],u.rotate(a(0,4));return e},t={0:n(2,1,[1,8]),1:n(2,2,[1,12,0,1]),2:n(3,2,[6,14,12,3,14,9]),3:n(4,2,[9,12,6,12,3,9,3,6]),4:o(n(3,2,[1,10,2,8,5,4])),5:n(3,3,[9,11,3,13,15,7,12,14,6]),6:o(n(4,5,[0,6,12,0,0,5,5,0,0,5,5,0,6,13,7,12,3,9,3,9])),7:o(n(3,3,[0,0,4,2,12,5,0,3,9])),8:n(6,4,[0,6,6,6,6,0,6,6,6,6,6,6,6,6,6,6,6,6,0,6,6,6,6,0]),9:o(n(4,4,[6,10,14,12,7,14,13,5,5,7,11,13,3,11,10,9])),10:o(n(6,4,[0,6,12,6,12,0,0,5,7,13,5,0,0,3,13,7,9,0,2,8,3,9,2,8])),13:o(n(4,5,[0,6,12,0,4,7,13,4,3,13,7,9,6,11,11,12,3,10,10,9])),15:o(n(5,5,[6,10,14,14,12,7,10,13,5,5,7,14,15,11,13,5,5,7,10,13,3,11,11,10,9])),19:o(n(6,6,[0,0,6,12,0,0,0,4,5,7,8,0,6,11,15,15,10,12,3,10,15,15,14,9,0,2,13,5,1,0,0,0,3,9,0,0])),21:o(n(6,6,[0,0,6,12,0,0,0,4,7,13,4,0,6,11,15,15,11,12,3,14,15,15,14,9,0,1,7,13,1,0,0,0,3,9,0,0])),25:o(n(7,6,[0,0,6,10,10,10,12,6,10,11,12,0,0,5,5,6,12,5,6,12,5,5,3,9,5,3,9,5,5,0,0,3,14,10,9,3,10,10,10,9,0,0])),28:o(n(8,5,[0,0,0,6,12,0,0,0,0,0,6,11,11,12,0,0,0,6,11,10,10,11,12,0,6,11,10,10,10,10,11,12,3,10,10,10,10,10,10,9])),33:o(n(8,6,[4,4,6,10,10,10,10,12,5,5,5,6,10,10,12,5,5,5,5,1,2,12,5,5,5,5,3,8,4,5,5,5,5,3,10,10,9,5,5,5,3,10,10,10,10,9,1,1])),42:o(n(6,5,[4,0,4,6,10,12,5,0,5,1,0,5,3,10,13,6,10,9,0,0,5,5,0,4,0,0,1,3,10,9])),100:o(n(5,3,[4,6,12,6,12,5,5,5,5,5,1,3,9,3,9]))},e}();
},{"./Grid":3,"./Quad":6,"./Square":7}],6:[function(require,module,exports){
var DIRECTIONS,Quad;DIRECTIONS=[[0,-1],[1,0],[0,1],[-1,0]],module.exports=Quad=function(){function n(){}var r;return n.all=[0,1,2,3],n.direction=function(n){return DIRECTIONS[n]},n.allDirections=function(){var t,o,i,u;for(i=n.all,u=[],t=0,o=i.length;t<o;t++)r=i[t],u.push(n.direction(r));return u}(),n.oppositeOf=function(n){return n+2&3},n.neighbors=function(r,t){var o,i,u,e,l,a,c;for(u=n.allDirections,l=[],o=0,i=u.length;o<i;o++)e=u[o],a=e[0],c=e[1],l.push([r+a,t+c]);return l},n}();
},{}],7:[function(require,module,exports){
var BitSet,Square,extend=function(t,r){function e(){this.constructor=t}for(var o in r)hasProp.call(r,o)&&(t[o]=r[o]);return e.prototype=r.prototype,t.prototype=new e,t.__super__=r.prototype,t},hasProp={}.hasOwnProperty;BitSet=require("./BitSet"),module.exports=Square=function(t){function r(){return r.__super__.constructor.apply(this,arguments)}return extend(r,t),r.prototype.getQuad=function(t){return this.has(t)},r.prototype.setQuad=function(t){return this.add(t)},r.prototype.checkMatch=function(t,r){var e;return e=t.clone().rotate(2),this.getQuad(r)===e.getQuad(r)},r}(BitSet(4));
},{"./BitSet":2}],8:[function(require,module,exports){
var DictSet;module.exports=DictSet=function(){function t(t){this.indexer=t,this.object={}}return t.prototype.has=function(t){return null!=this.object[this.indexer(t)]},t.prototype.add=function(t){return this.object[this.indexer(t)]=t},t.prototype.remove=function(t){return delete this.object[this.indexer(t)],this},t.prototype.clear=function(){return this.object={}},t.prototype.pop=function(t){var e,o;o=this.object;for(e in o)return t=o[e],delete this.object[e],t},t.prototype.toArray=function(){var t,e,o,r;e=this.object,o=[];for(t in e)r=e[t],o.push(r);return o},t.prototype.addAll=function(t){var e,o,r;for(e=0,o=t.length;e<o;e++)r=t[e],this.add(r);return this},t}();
},{}],9:[function(require,module,exports){
var BitSet,Possibilities,Square,extend=function(t,r){function e(){this.constructor=t}for(var n in r)hasProp.call(r,n)&&(t[n]=r[n]);return e.prototype=r.prototype,t.prototype=new e,t.__super__=r.prototype,t},hasProp={}.hasOwnProperty;BitSet=require("../BitSet"),Square=require("../Square"),module.exports=Possibilities=function(t){function r(){return r.__super__.constructor.apply(this,arguments)}var e,n;return extend(r,t),e=function(){var t,e,o,u;for(o=[1,278,1056,4680,26752,32768],u=[],t=0,e=o.length;t<e;t++)n=o[t],u.push(new r(n));return u}(),r.forSquare=function(t){return e.find(function(r){return r.has(t.id)}).clone()},r.prototype.getSquares=function(){return this.map(function(t){return new Square(t)})},r.prototype.eliminiate=function(t,r){return this.filter(function(e){var n;return n=new Square(e),t.getSquares().some(function(t){return n.checkMatch(t,r)})})},r}(BitSet(16));
},{"../BitSet":2,"../Square":7}],10:[function(require,module,exports){
var DictSet,GridBase,Possibilities,PossibilityGrid,Quad,extend=function(t,e){function i(){this.constructor=t}for(var r in e)hasProp.call(e,r)&&(t[r]=e[r]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},hasProp={}.hasOwnProperty;GridBase=require("../GridBase"),Possibilities=require("./Possibilities"),Quad=require("../Quad"),DictSet=require("./DictSet"),module.exports=PossibilityGrid=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return extend(e,t),e.prototype.createTodo=function(){return new DictSet(function(t){return function(e){var i,r;return i=e[0],r=e[1],r*t.w+i}}(this))},e.prototype.newDefault=function(){return new Possibilities(1)},e.prototype.eliminiateFrom=function(t){var e,i,r,o,n,s,u;for(s=t[0],u=t[1],n=this.createTodo(),o=Quad.neighbors(s,u),e=0,i=o.length;e<i;e++)r=o[e],n.add(r);return this.eliminiate(n)},e.prototype.eliminiateInitial=function(){var t,e,i,r,o,n,s;for(o=this.createTodo(),i=this.allCoordinates(),t=0,e=i.length;t<e;t++)r=i[t],n=r[0],s=r[1],0!==n&&0!==s&&n!==this.w-1&&s!==this.h-1&&1!==this.getAt(n,s).length()||o.add([n,s]);return this.eliminiate(o)},e.prototype.eliminiate=function(t){for(var e,i,r,o,n,s,u,a,p,l,h,d,c;i=t.pop();)if(d=i[0],c=i[1],this.contains(d,c))for(l=Quad.all,e=0,o=l.length;e<o;e++)if(p=l[e],u=this.getAt(d,c),a=u.id,u.eliminiate(this.getAtToQuad(d,c,p),p),a!==u.id)for(h=Quad.neighbors(d,c),r=0,n=h.length;r<n;r++)s=h[r],t.add(s);return this},e.prototype.solved=function(){return this.toArray().every(function(t){return 1===t.length()})},e.prototype.solvable=function(){return this.toArray().every(function(t){return t.length()>0})},e.prototype.applyToGrid=function(t){var e,i,r,o,n,s,u,a;for(o=t.allCoordinates(),s=[],e=0,i=o.length;e<i;e++)n=o[e],u=n[0],a=n[1],r=this.getAt(u,a).toArray(),1===r.length?s.push(t.getAt(u,a).setId(r[0])):s.push(void 0);return s},e}(GridBase);
},{"../GridBase":4,"../Quad":6,"./DictSet":8,"./Possibilities":9}],11:[function(require,module,exports){
var Possibilities,PossibilityGrid,Solver;PossibilityGrid=require("./PossibilityGrid"),Possibilities=require("./Possibilities"),module.exports=Solver=function(){function i(){}return i.prototype.solve=function(i){var t,e,r,o,s,l,n,u;for(o=new PossibilityGrid(i.w,i.h,function(t,e){return Possibilities.forSquare(i.getAt(t,e))}),o.eliminiateInitial(),u=[],u.push([0,o]);;){if(l=u.pop(),t=l[0],o=l[1],o.solved())break;if(o.solvable())for(n=this.fixPossibility(t,o),e=0,r=n.length;e<r;e++)s=n[e],u.push(s)}return o.applyToGrid(i),this},i.prototype.fixPossibility=function(i,t){var e,r,o,s,l,n,u,a,f,b,p;for(e=i,a=t.allCoordinates(),o=0,s=a.length;o<s;o++)if(f=a[o],b=f[0],p=f[1],n=t.getAt(b,p),u=n.toArray(),u.length>1&&(e-=u.length,e<0))return r=u.length+e,l=t.clone(),n.clear().add(u[r]),t.eliminiateFrom([b,p]),[[i+1,l],[0,t]];return[]},i}();
},{"./Possibilities":9,"./PossibilityGrid":10}],12:[function(require,module,exports){
var App,Button,Component,DesignChanger,GridView,Header,Instructions,Levels,Solve,bind=function(e,i){return function(){return e.apply(i,arguments)}},extend=function(e,i){function t(){this.constructor=e}for(var n in i)hasProp.call(i,n)&&(e[n]=i[n]);return t.prototype=i.prototype,e.prototype=new t,e.__super__=i.prototype,e},hasProp={}.hasOwnProperty;Component=require("../viewBase/Component"),Levels=require("../model/Levels"),Instructions=require("./Instructions"),Header=require("./Header"),DesignChanger=require("./DesignChanger"),Solve=require("./Solve"),Button=require("../viewBase/Button"),GridView=require("./GridView"),module.exports=App=function(e){function i(){this.loadLevel=bind(this.loadLevel,this),this.clicked=bind(this.clicked,this),i.__super__.constructor.call(this,"div"),this.dom.classList.add("app"),document.addEventListener("click",this.clicked),this.levels=new Levels,this.level=1*localStorage.getItem("adinfinitvm.level"),this.instructions=new Instructions,this.header=new Header,this.designChanger=new DesignChanger(function(e){return function(i){var t;return null!=(t=e.gridView)?t.changeSquareDesign(i):void 0}}(this)),this.add(this.designChanger),this.solve=new Solve(this),this.loadLevel()}var t;return extend(i,e),t="done",i.prototype.clicked=function(){var e;if(this.gridView.isDone())return e=document.body.classList,e.contains(t)?(e.remove(t),this.level=this.level+1,this.loadLevel()):(e.add(t),this.gridView.freeze(),this.instructions.end(this.level),this.persistLevelProgress())},i.prototype.loadLevel=function(){var e,i;if(null!=(i=this.gridView)&&i.remove(),e=this.levels.get(this.level),this.gridView=new GridView(e,this.designChanger.squareDesign()),this.add(this.gridView),this.instructions.start(this.level),this.level>=4)return this.header.hide()},i.prototype.persistLevelProgress=function(){var e;if(e=localStorage.getItem("adinfinitvm.level"),this.level>=e)return localStorage.setItem("adinfinitvm.level",this.level+1)},i}(Component);
},{"../model/Levels":5,"../viewBase/Button":22,"../viewBase/Component":24,"./DesignChanger":13,"./GridView":14,"./Header":15,"./Instructions":16,"./Solve":17}],13:[function(require,module,exports){
var Button,DesignChanger,PathySquareDesign,TriangularSquareDesign,squareDesigns,bind=function(e,n){return function(){return e.apply(n,arguments)}},extend=function(e,n){function t(){this.constructor=e}for(var i in n)hasProp.call(n,i)&&(e[i]=n[i]);return t.prototype=n.prototype,e.prototype=new t,e.__super__=n.prototype,e},hasProp={}.hasOwnProperty;Button=require("../viewBase/Button"),PathySquareDesign=require("./squareDesigns/PathySquareDesign"),TriangularSquareDesign=require("./squareDesigns/TriangularSquareDesign"),squareDesigns=[new PathySquareDesign(40,6),new TriangularSquareDesign(40,6)],module.exports=DesignChanger=function(e){function n(e){this.callback=e,this.clicked=bind(this.clicked,this),n.__super__.constructor.call(this),this.designIndex=1*localStorage.getItem("adinfinitvm.designIndex"),this.dom.innerHTML="♦",this.dom.className="button designChanger"}return extend(n,e),n.prototype.clicked=function(e){return e.stopPropagation(),this.designIndex=(this.designIndex+1)%squareDesigns.length,localStorage.setItem("adinfinitvm.designIndex",this.designIndex),this.callback(this.squareDesign())},n.prototype.squareDesign=function(){return squareDesigns[this.designIndex]},n}(Button);
},{"../viewBase/Button":22,"./squareDesigns/PathySquareDesign":19,"./squareDesigns/TriangularSquareDesign":21}],14:[function(require,module,exports){
var Component,GridView,SquareView,bind=function(e,i){return function(){return e.apply(i,arguments)}},extend=function(e,i){function t(){this.constructor=e}for(var n in i)hasProp.call(i,n)&&(e[n]=i[n]);return t.prototype=i.prototype,e.prototype=new t,e.__super__=i.prototype,e},hasProp={}.hasOwnProperty;Component=require("../viewBase/Component"),SquareView=require("./SquareView"),module.exports=GridView=function(e){function i(e,t){this.grid=e,this.squareDesign=t,this.isDone=bind(this.isDone,this),i.__super__.constructor.call(this,"div"),this.dom.classList.add("grid"),this.initializeGrid(),this.dom.addEventListener("keydown",this.keydown)}return extend(i,e),i.prototype.initializeGrid=function(){var e,i,t,n,r,o,s,u;for(this.squareViews=[],this.dom.innerHTML="",u=e=0,t=this.grid.h;0<=t?e<t:e>t;u=0<=t?++e:--e){for(r=document.createElement("div"),r.classList.add("grid-row"),s=i=0,n=this.grid.w;0<=n?i<n:i>n;s=0<=n?++i:--i)o=new SquareView(this.grid.getAt(s,u),this.squareDesign),this.squareViews.push(o),o.addTo(r);this.dom.appendChild(r)}},i.prototype.freeze=function(){var e,i,t,n,r;for(t=this.squareViews,n=[],e=0,i=t.length;e<i;e++)r=t[e],n.push(r.freeze());return n},i.prototype.changeSquareDesign=function(e){var i,t,n,r,o;for(this.squareDesign=e,n=this.squareViews,r=[],i=0,t=n.length;i<t;i++)o=n[i],r.push(o.changeSquareDesign(this.squareDesign));return r},i.prototype.isDone=function(){return this.grid.checkAll()},i.prototype.keydown=function(e){var i,t,n;return null!=(t=function(){try{switch(e.keyCode){case 37:return document.activeElement.previousSibling||document.activeElement.parentNode.previousSibling.lastChild;case 38:for(n=document.activeElement.parentNode.previousSibling.firstChild,i=document.activeElement.previousSibling;i;)i=i.previousSibling,n=n.nextSibling;return n;case 39:return document.activeElement.nextSibling||document.activeElement.parentNode.nextSibling.firstChild;case 40:for(n=document.activeElement.parentNode.nextSibling.firstChild,i=document.activeElement.previousSibling;i;)i=i.previousSibling,n=n.nextSibling;return n}}catch(e){}}())?t.focus():void 0},i}(Component);
},{"../viewBase/Component":24,"./SquareView":18}],15:[function(require,module,exports){
var Header;module.exports=Header=function(){function e(){this.dom=document.getElementsByTagName("h2")[0]}return e.prototype.hide=function(){return window.setTimeout(function(e){return function(){return e.dom.style.height=e.dom.clientHeight+"px",e.dom.offsetHeight,e.dom.style.height=0}}(this),1e3)},e}();
},{}],16:[function(require,module,exports){
var Instructions;module.exports=Instructions=function(){function e(){this.dom=document.getElementById("instructions")}var t;return t=function(e){return"— "+e+" —"},e.prototype.start=function(e){return this.setMessage(this.startMessage(e))},e.prototype.end=function(e){return this.setMessage(this.endMessage(e))},e.prototype.setMessage=function(e){if(null!=e)return this.dom.innerHTML=e},e.prototype.startMessage=function(e){switch(e){case 0:return null;case 1:return t("try this one");case 2:return t("looks nice right? click to bottom center piece to create two rings");case 3:return t("there may be multiple loops like in this example");case 4:return"(the game is called ADINFINITVM, okay?)";case 5:return t("let's see how far you can get");case 7:return"(hint: there's an alternate mode, hit the ♦ in the bottom right corner)";default:return" "}},e.prototype.endMessage=function(e){switch(e){case 0:return t("now click anywhere to start the next level");case 10:return t("#10 already, keep up the good work!");case 50:return t("oh nice! #50");case 1337:return t("#1337 — 11100010 10011101 10100100");default:return(""+e).match(/^[15]0+$/)?this.tweetMessage(e):t("#"+e)}},e.prototype.tweetMessage=function(e){var n,r;return r="I've just completed level "+e+" in @amoebe's #adinfinitvm game! https://bxt.github.io/adinfinitvm/",n="http://twitter.com/home?status="+encodeURIComponent(r),t("congratulations! you have completed #"+e+'.\n<a class="button" href="'+n+'" target="_blank">tweet</a>')},e}();
},{}],17:[function(require,module,exports){
var Cheat,Solve,Solver,bind=function(e,r){return function(){return e.apply(r,arguments)}};Cheat=require("../viewBase/Cheat.coffee"),Solver=require("../model/solve/Solver"),module.exports=Solve=function(){function e(e){this.app=e,this.solve=bind(this.solve,this),new Cheat([38,38,40,40,37,39,37,39,66,65],this.solve)}var r;return r=new Solver,e.prototype.solve=function(e){var i,o,t,n;for(r.solve(this.app.gridView.grid),t=this.app.gridView.squareViews,i=0,o=t.length;i<o;i++)n=t[i],n.refreshDom();return this.app.clicked()},e}();
},{"../model/solve/Solver":11,"../viewBase/Cheat.coffee":23}],18:[function(require,module,exports){
var Button,SquareView,bind=function(t,e){return function(){return t.apply(e,arguments)}},extend=function(t,e){function r(){this.constructor=t}for(var s in e)hasProp.call(e,s)&&(t[s]=e[s]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t},hasProp={}.hasOwnProperty;Button=require("../viewBase/Button"),module.exports=SquareView=function(t){function e(t,r){this.square=t,this.squareDesign=r,this.clicked=bind(this.clicked,this),e.__super__.constructor.call(this),this.refreshDom()}return extend(e,t),e.prototype.freeze=function(){return this.frozen=!0},e.prototype.changeSquareDesign=function(t){return this.squareDesign=t,this.refreshDom()},e.prototype.clicked=function(t){if(!this.frozen)return this.square.rotate(1),this.refreshDom(),this.dom.style.transform="rotate(-90deg)",this.dom.offsetHeight,this.dom.classList.add("transitioning"),this.dom.style.transform="rotate(0deg)"},e.prototype.refreshDom=function(){return this.add(this.squareDesign.setSquare(this.square)),this.dom.className="grid-square",this.dom.classList.add("grid-square-"+this.square.id)},e}(Button);
},{"../viewBase/Button":22}],19:[function(require,module,exports){
var PathySquareDesign,SquareDesign,extend=function(t,i){function s(){this.constructor=t}for(var h in i)hasProp.call(i,h)&&(t[h]=i[h]);return s.prototype=i.prototype,t.prototype=new s,t.__super__=i.prototype,t},hasProp={}.hasOwnProperty;SquareDesign=require("./SquareDesign"),module.exports=PathySquareDesign=function(t){function i(){return i.__super__.constructor.apply(this,arguments)}return extend(i,t),i.prototype.loadDesigns=function(){return i.__super__.loadDesigns.call(this),this.loadPaths(),this.load0Designs(),this.load1Designs(),this.load2Designs(),this.load3Designs(),this.load4Designs()},i.prototype.loadPaths=function(){return this.paths={1:"M"+this.halfSize+" 0 L"+this.halfSize+" "+(this.halfSize-this.circleRadius),2:"M"+this.size+" "+this.halfSize+" L"+(this.halfSize+this.circleRadius)+" "+this.halfSize,4:"M"+this.halfSize+" "+this.size+" L"+this.halfSize+" "+(this.halfSize+this.circleRadius),8:"M 0 "+this.halfSize+" L"+(this.halfSize-this.circleRadius)+" "+this.halfSize,5:"M"+this.halfSize+" 0 L"+this.halfSize+" "+this.size,10:"M0 "+this.halfSize+" L"+this.size+" "+this.halfSize,3:"M"+this.halfSize+" 0 A "+this.halfSize+" "+this.halfSize+" 0 0 0 "+this.size+" "+this.halfSize,6:"M"+this.halfSize+" "+this.size+" A "+this.halfSize+" "+this.halfSize+" 0 0 1 "+this.size+" "+this.halfSize,9:"M"+this.halfSize+" 0 A "+this.halfSize+" "+this.halfSize+" 0 0 1 0 "+this.halfSize,12:"M"+this.halfSize+" "+this.size+" A "+this.halfSize+" "+this.halfSize+" 0 0 0 0 "+this.halfSize}},i.prototype.load0Designs=function(){return this.designs[0]=this.layout("")},i.prototype.load1Designs=function(){var t,i,s,h,e;for(h=[1,2,4,8],e=[],i=0,s=h.length;i<s;i++)t=h[i],e.push(this.designs[t]=this.layout('<path d="'+this.paths[t]+'" '+this.styleWhite()+' />\n<circle cx="'+this.halfSize+'" cy="'+this.halfSize+'" r="'+this.circleRadius+'" '+this.styleWhite()+' />\n<path d="'+this.paths[t]+'" '+this.style()+' />\n<circle cx="'+this.halfSize+'" cy="'+this.halfSize+'" r="'+this.circleRadius+'" '+this.style()+" />"));return e},i.prototype.load2Designs=function(){var t,i,s,h,e;for(h=[5,10,3,6,9,12],e=[],i=0,s=h.length;i<s;i++)t=h[i],e.push(this.designs[t]=this.layout('<path d="'+this.paths[t]+'" '+this.styleWhite()+' />\n<path d="'+this.paths[t]+'" '+this.style()+" />"));return e},i.prototype.load3Designs=function(){var t,i,s,h,e,a,l;for(a=[7,11,13,14],l=[],i=0,h=a.length;i<h;i++)t=a[i],e=function(){var i,h,e,a;for(e=[3,6,9,12],a=[],i=0,h=e.length;i<h;i++)s=e[i],t&s^s||a.push('<path d="'+this.paths[s]+'" '+this.styleWhite()+' />\n<path d="'+this.paths[s]+'" '+this.style()+" />");return a}.call(this),l.push(this.designs[t]=this.layout(e.join("")));return l},i.prototype.load4Designs=function(){var t,i,s,h;return s=function(){var t,s,h,e;for(h=[3,6,12,9],e=[],t=0,s=h.length;t<s;t++)i=h[t],e.push('<path d="'+this.paths[i]+'" '+this.styleWhite()+' />\n<path d="'+this.paths[i]+'" '+this.style()+" />");return e}.call(this),h=this.halfSize*Math.PI/4,t='<path d="'+this.paths[3]+'" '+this.styleWhite("stroke-dasharray: "+(h-1)+"px, "+(h+1)+"px;")+'/>\n<path d="'+this.paths[3]+'" '+this.style("stroke-dasharray: "+h+"px;")+"/>",this.designs[15]=this.layout(s.join("")+t)},i.prototype.style=function(t){return'class="foreground" style="fill: none; stroke-width: '+this.width+"px; "+t+'"'},i.prototype.styleWhite=function(t){return'class="background" style="fill: none; stroke-width: '+8*this.width/6+"px; "+t+'"'},i}(SquareDesign);
},{"./SquareDesign":20}],20:[function(require,module,exports){
var SquareDesign;module.exports=SquareDesign=function(){function i(i,t){this.size=i,this.width=t,this.halfSize=this.size/2,this.circleRadius=7*this.size/32,this.loadDesigns()}return i.prototype.setSquare=function(i){return this.square=i,this},i.prototype.addTo=function(i){return i.innerHTML=this.designs[this.square.id]},i.prototype.loadDesigns=function(){var i;return this.designs=function(){var t,s;for(s=[],i=t=0;t<16;i=++t)s.push(""+i);return s}()},i.prototype.layout=function(i){return'<svg\n xmlns="http://www.w3.org/2000/svg"\n width="'+this.size+'"\n height="'+this.size+'"\n viewBox="0 0 '+this.size+" "+this.size+'">\n '+i+"\n</svg>"},i}();
},{}],21:[function(require,module,exports){
var SquareDesign,TriangularSquareDesign,extend=function(t,i){function s(){this.constructor=t}for(var e in i)hasProp.call(i,e)&&(t[e]=i[e]);return s.prototype=i.prototype,t.prototype=new s,t.__super__=i.prototype,t},hasProp={}.hasOwnProperty;SquareDesign=require("./SquareDesign"),module.exports=TriangularSquareDesign=function(t){function i(){return i.__super__.constructor.apply(this,arguments)}return extend(i,t),i.prototype.loadDesigns=function(){var t,s,e,r,h,n;for(i.__super__.loadDesigns.call(this),this.paths={1:"M0 0 L"+this.halfSize+" "+this.halfSize+" L"+this.size+" 0 Z",2:"M"+this.size+" 0 L"+this.halfSize+" "+this.halfSize+" L"+this.size+" "+this.size+" Z",4:"M"+this.size+" "+this.size+" L"+this.halfSize+" "+this.halfSize+" L0 "+this.size+" Z",8:"M0 "+this.size+" L"+this.halfSize+" "+this.halfSize+" L0 0 Z"},n=[],t=s=0;s<16;t=++s)h=function(){var i,s;i=this.paths,s=[];for(e in i)r=i[e],(t&e)>0&&s.push('<path d="'+r+'" '+this.style()+" />");return s}.call(this),n.push(this.designs[t]=this.layout(h.join("paths")));return n},i.prototype.style=function(t){return'class="filled"'},i}(SquareDesign);
},{"./SquareDesign":20}],22:[function(require,module,exports){
var Button,Component,bind=function(t,n){return function(){return t.apply(n,arguments)}},extend=function(t,n){function o(){this.constructor=t}for(var r in n)hasProp.call(n,r)&&(t[r]=n[r]);return o.prototype=n.prototype,t.prototype=new o,t.__super__=n.prototype,t},hasProp={}.hasOwnProperty;Component=require("./Component"),module.exports=Button=function(t){function n(t){null==t&&(t=!0),this.clickHandler=bind(this.clickHandler,this),n.__super__.constructor.call(this,"a"),this.dom.href="javascript:;",this.dom.addEventListener("click",this.clickHandler,!t)}return extend(n,t),n.prototype.clickHandler=function(t){return this.clicked(t)},n}(Component);
},{"./Component":24}],23:[function(require,module,exports){
var Cheat,bind=function(t,e){return function(){return t.apply(e,arguments)}};module.exports=Cheat=function(){function t(t,e){this.sequence=t,this.callback=e,this.keydown=bind(this.keydown,this),this.lastKeys=[],document.addEventListener("keydown",this.keydown)}return t.prototype.keydown=function(t){for(this.lastKeys.push(t.keyCode);this.lastKeys.length>this.sequence.length;)this.lastKeys.shift();if(this.sequence.every(function(t){return function(e,n){return e===t.lastKeys[n]}}(this)))return this.callback()},t}();
},{}],24:[function(require,module,exports){
var Component;module.exports=Component=function(){function o(o){this.dom=document.createElement(o)}return o.prototype.add=function(o){return o.addTo(this.dom)},o.prototype.addTo=function(o){return o.appendChild(this.dom)},o.prototype.remove=function(){return this.dom.parentNode.removeChild(this.dom)},o}();
},{}]},{},[1])
//# sourceMappingURL=script.min.js.map