{"version":3,"sources":["https://lively-kernel.org/lively4/lively4-livelyenergy/src/components/demo/lively-simulation-component.js"],"names":["Morph","LivelySimulationComponent","initialize","registerButtons","addEventListener","evt","onDblClick","get","getAttribute","animate","backgroundColor","duration","onKeyDown","notify","onPlusButton","onMinusButton","livelyPrepareSave","setAttribute","livelyPreMigrate","livelyMigrate","other","livelyInspect","contentNode","inspector","livelyExample","appendChild"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;AAEOA,W;;;;;;;;;;;;;;;;;;;;;AAEQ,YAAMC,yBAAN,SAAwCD,KAAxC,CAA8C;AAC3D,cAAME,UAAN,GAAmB;AACjB,0CAAmB,2BAAnB;AADiB;AAEjB,eAAKC,eAAL;;AAEA,4IAAyB,IAAzB,GAJiB,CAIe;;AAJf;AAMjB,oFAAOC,gBAAP,CAAwB,UAAxB,EAAoC,IAApC,EAA0C,UAA1C,EACEC;AAAA;AAAO,qGAAKC,UAAL,6EAAgBD,GAAhB;AAAP;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AATA,YAWC,uFAAKE,GAAL,CAAS,YAAT,aAA+B,qFAAKC,YAAL,CAAkB,aAAlB,MAAoC,CAAnE;AACF;;AAEDF,qBAAa;AAAA;;AACX,eAAKG,OAAL,CAAa,CACX,EAACC,iBAAiB,WAAlB,EADW,EAEX,EAACA,iBAAiB,KAAlB,EAFW,EAGX,EAACA,iBAAiB,WAAlB,EAHW,CAAb,EAIG;AACDC,sBAAU;AADT,WAJH;AAOD;;AAED;AACAC,kBAAUP,GAAV,EAAe;AAAA;AAAA;;AACb,oFAAOQ,MAAP,CAAc,qGAAcR,GAAd,cAAd;AACD;;AAED;AACAS,uBAAe;AACb,iGAAKP,GAAL,CAAS,YAAT,aAAgC,oKAAW,KAAKA,GAAL,CAAS,YAAT,CAAX,eAA2C,CAA3E;AACD;;AAEDQ,wBAAgB;AACd,iGAAKR,GAAL,CAAS,YAAT,aAAgC,oKAAW,KAAKA,GAAL,CAAS,YAAT,CAAX,eAA2C,CAA3E;AACD;;AAED;;AAEA;AACAS,4BAAoB;AAAA;;AAClB,eAAKC,YAAL,CAAkB,aAAlB,oFAAiC,KAAKV,GAAL,CAAS,YAAT,CAAjC;AACD;;AAEDW,2BAAmB;AACjB;AACD;;AAEDC,sBAAcC,KAAd,EAAqB;AAAA;;AACnB;AACA;AACA,gJAA8BA,KAA9B;AACD;;AAEDC,sBAAcC,WAAd,EAA2BC,SAA3B,EAAsC;AACpC;AACD;;AAED,cAAMC,aAAN,GAAsB;AACpB;AACA;AACA,mEAA6B,WAA7B;AACA,qDAA8B,EAA9B;AAJoB;AAKpB,eAAKC,WAAL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACD;;AAxE0D;;yBAAxCxB,yB","file":"lively-simulation-component.js","sourcesContent":["\"enable aexpr\";\n\nimport Morph from 'src/components/widgets/lively-morph.js';\n\nexport default class LivelySimulationComponent extends Morph {\n  async initialize() {\n    this.windowTitle = \"LivelySimulationComponent\";\n    this.registerButtons()\n\n    lively.html.registerKeys(this); // automatically installs handler for some methods\n    \n    lively.addEventListener(\"template\", this, \"dblclick\", \n      evt => this.onDblClick(evt))\n    // #Note 1\n    // ``lively.addEventListener`` automatically registers the listener\n    // so that the the handler can be deactivated using:\n    // ``lively.removeEventListener(\"template\", this)``\n    // #Note 1\n    // registering a closure instead of the function allows the class to make \n    // use of a dispatch at runtime. That means the ``onDblClick`` method can be\n    // replaced during development\n    \n     this.get(\"#textField\").value = this.getAttribute(\"data-mydata\") || 0\n  }\n  \n  onDblClick() {\n    this.animate([\n      {backgroundColor: \"lightgray\"},\n      {backgroundColor: \"red\"},\n      {backgroundColor: \"lightgray\"},\n    ], {\n      duration: 1000\n    })\n  }\n  \n  // this method is autmatically registered through the ``registerKeys`` method\n  onKeyDown(evt) {\n    lively.notify(\"Key Down!\" + evt.charCode)\n  }\n  \n  // this method is automatically registered as handler through ``registerButtons``\n  onPlusButton() {\n    this.get(\"#textField\").value =  parseFloat(this.get(\"#textField\").value) + 1\n  }\n  \n  onMinusButton() {\n    this.get(\"#textField\").value =  parseFloat(this.get(\"#textField\").value) - 1\n  }\n\n  /* Lively-specific API */\n\n  // store something that would be lost\n  livelyPrepareSave() {\n    this.setAttribute(\"data-mydata\", this.get(\"#textField\").value)\n  }\n  \n  livelyPreMigrate() {\n    // is called on the old object before the migration\n  }\n  \n  livelyMigrate(other) {\n    // whenever a component is replaced with a newer version during development\n    // this method is called on the new object during migration, but before initialization\n    this.someJavaScriptProperty = other.someJavaScriptProperty\n  }\n  \n  livelyInspect(contentNode, inspector) {\n    // do nothing\n  }\n  \n  async livelyExample() {\n    // this customizes a default instance to a pretty example\n    // this is used by the \n    this.style.backgroundColor = \"lightgray\"\n    this.someJavaScriptProperty = 42\n    this.appendChild(<div>This is my content</div>)\n  }\n  \n  \n}"]}