(self.webpackChunkttgtcanvas=self.webpackChunkttgtcanvas||[]).push([[568],{1568:(e,t,n)=>{e.exports=n(1367),e.exports.version=n(306).version},6454:(e,t,n)=>{var o=n(1337),i=n(5431),s=o.DOMWidgetModel.extend({defaults:i.extend(o.DOMWidgetModel.prototype.defaults(),{_model_name:"BaseModel",_view_name:"BaseView",_model_module:"ttgtcanvas",_view_module:"ttgtcanvas",_model_module_version:"0.2.1",_view_module_version:"0.2.1",current_call:"{}",method_return:"{}"})}),a=o.DOMWidgetView.extend({init:function(){this.model.on("change:current_call",this.method_changed,this)},method_changed:function(){console.log("current_call");let e=JSON.parse(this.model.get("current_call"));console.log("current_call",this);let t="function"==typeof this[e.method_name]?this[e.method_name].apply(this,e.params):null;console.log("current_call",e);let n=this;return Promise.resolve(t).then((function(t){console.log("reached in promise");let o=JSON.stringify({value:t,cb:+new Date,params:e.params,method:e.method_name});return console.log("setting return",o),n.model.set("method_return",o),n.model.save_changes(),o}))}});e.exports={BaseModel:s,BaseView:a}},7795:(e,t,n)=>{var o=n(6454),i=n(4827),s=o.BaseModel.extend({defaults:_.extend(o.BaseModel.defaults,{_model_name:"MazeModel",_view_name:"MazeView"})});class a{constructor(e){Object.assign(this,e),this.points=[],this.trace_enabled=!1,this.traceColor="black",this.trace=null,this.pending_moves=[],this.delay=.2;let t=this;new i.Image.fromURL(this.src,(function(e){t.set_node(e),e.setAttrs({x:100,y:100}),t.layer.add(e),t.layer.batchDraw()}))}set_node(e){for(this.node=e;this.pending_moves.length>0;){let[e,t]=this.pending_moves.shift();this.move_to(e,t)}}add_point(e,t){this.points=this.points.concat([e,t]),console.log(this.points)}clear_trace(){this.points=[],this.line_layer.destroyChildren(),this.line_layer.draw()}enable_trace(){this.trace_enabled=!0}draw_trace(){let e=new i.Line({points:this.points.slice(Math.max(this.points.length-4,0)),stroke:this.traceColor});this.line_layer.add(e),this.line_layer.draw()}move_to(e,t){if(!this.node)return void this.pending_moves.push([e,t]);let n=this;var o=new i.Animation((function(o){n.node.x(e-15),n.node.y(t-15)}),this.layer);o.start();let s=this.node.position();s.x===e&&s.y===t&&o.stop()}}var r=o.BaseView.extend({render:function(){this.init(),console.log("🚀 ~ file: maze.js ~ line 167 ~ this.el",this.el),this._elem=document.createElement("div"),this._elem.setAttribute("id","container"),this.layer=new i.Layer,this.line_layer=new i.Layer,this.el.appendChild(this._elem),this.robots=[]},add_robot:function(e,t,n,o,i,s){this.robots[e]=this.robots[e]||new a({layer:this.layer,line_layer:this.line_layer,avenue:n,street:o,orientation:i,beepers:s,src:t})},move_to:function(e,t,n){this.robots[e].move_to(t,n)},add_point:function(e,t,n){let o=this.robots[e];o.add_point(t,n),o.draw_trace()},remove_trace:function(e){let t=this.robots[e];t.trace_enabled=!1,t.clear_trace()},set_pause:function(e,t){this.robots[e].delay=t},set_trace:function(e,t,n,o="blue"){let i=this.robots[e];i.enable_trace(),i.traceColor=o,i.add_point(t,n)},init_robot:function(e){this.robots[e].clear_trace()},add_beeper:function(){},update_beeper:function(){},remove_beeper:function(){},draw_grid:function(e,t,n,o,s,a,r){this.stage=new i.Stage({container:"container",width:e,height:t}),console.log(this.stage),this.stage.add(this.layer),this.stage.add(this.line_layer),this.ts=s;let l=2*s,d=l+2*s*n,h=t-2*s,c=h-2*s*o;!function(e,t,n,o,s,a){for(let r=1;r<t;r++){let t=o+n*(2*r);console.log(t);let l=new i.Line({stroke:"gray",points:[t,a,t,s]}),d=new i.Text({text:r,x:t-2,y:s+n-10});e.add(l),e.add(d)}}(this.layer,n,s,l,h,c),function(e,t,n,o,s,a){for(let r=1;r<t;r++){let t=s-n*(2*r),l=new i.Line({stroke:"gray",points:[o,t,a,t]}),d=new i.Text({text:r,y:t-2,x:o-n+5});e.add(l),e.add(d)}}(this.layer,o,s,l,h,d);let _=new i.Line({stroke:"darkred",points:[l,h,d,h,d,c,l,c],strokeWidth:10,closed:!0});this.layer.add(_),function(e,t,n,o,s){const a=function(e,t){return[n+s*e,o-s*t]};t.map((function([t,n]){let o=[];o=t%2==0?[...a(t,n-1),...a(t,n+1)]:[...a(t-1,n),...a(t+1,n)];let s=new i.Line({stroke:"darkred",strokeWidth:10,closed:!0,points:o});e.add(s)}))}(this.layer,a,l,h,s),function(e,t,n,o,s){t.map((function(t){console.log("🚀 ~ file: konwa.html ~ line 156 ~ beeper",t);let a=.6*s,r=t.key[0],l=t.key[1];const[d,h]=[n+s*(2*r-1),o-s*(2*l-1)];let c=t.value,_=new i.Circle({radius:a,x:d,y:h,fill:"yellow",stroke:"orange",strokeWidth:5,name:`beeper-${r}-${l}-circle`}),u=new i.Text({text:c,x:d-5,y:h-7,fontSize:18,name:`beeper-${r}-${l}-text`});e.add(_,u)}))}(this.layer,r,l,h,s),this.layer.draw()}});e.exports={MazeModel:s,MazeView:r}},1367:(e,t,n)=>{var o=n(6454),i=n(7795);e.exports={...o,...i}},306:e=>{"use strict";e.exports={version:"0.2.1"}}}]);