{"version":3,"sources":["https://lively-kernel.org/lively4/BP2019RH-stable/components/bp2019-data-source-widget.js"],"names":["Morph","d3","AVFParser","DataProcessor","ColorStore","GeoData","Bp2019DataSourceWidget","initialize","colorStore","dataProcessor","setColorStore","currentActions","dataSetSelection","get","addEventListener","_handleDataSetSelection","dispatchEvent","Event","applyAction","action","setData","data","getData","getColorStore","getDataProcessor","setExtent","extent","_hideUserInstructions","_showLoadingAnimation","rawGeoData","options","selectedIndex","value","loadCovidData","initializeWithIndividualsFromKenia","json","bp2019url","loadCovidSomDataMessageThemes","initializeWithIndividualsFromSomalia","geoData","features","initializeWithValuesByAttribute","getValuesByAttribute","_hideLoadingAnimation","_showUserInstructions","_dispatchDataLoadedEvent","CustomEvent","detail","bubbles","style","display"],"mappings":";;;;;;AAAOA,W;;AAEAC,Q;;AAEEC,e,qDAAAA,S;;AACFC,mB;;AACAC,gB;;AAEAC,a;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEQ,YAAMC,sBAAN,SAAqCN,KAArC,CAA2C;AACxD,cAAMO,UAAN,GAAmB;AACjB,eAAKC,UAAL,GAAkB,IAAIJ,UAAJ,EAAlB;AACA,eAAKK,aAAL,GAAqB,IAAIN,aAAJ,EAArB;AACA,eAAKM,aAAL,CAAmBC,aAAnB,CAAiC,KAAKF;;AAEtC;AAFA,YAGA,KAAKG,cAAL,GAAsB,EAAtB;;AAEA,eAAKC,gBAAL,GAAwB,KAAKC,GAAL,CAAS,YAAT,CAAxB;AACA,eAAKD,gBAAL,CAAsBE,gBAAtB,CAAuC,QAAvC,EAAiD,YAAY,MAAM,KAAKC,uBAAL,EAAnE;;AAEA,eAAKH,gBAAL,CAAsBI,aAAtB,CAAoC,IAAIC,KAAJ,CAAU,QAAV,CAApC;AACD;;AAEDC,oBAAYC,MAAZ,EAAoB,CAEnB;;AAEDC,gBAAQC,IAAR,EAAc;AACZ;AAC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AOhDS,qBAAS;AAPuC,WAA/B,CAAnB;AASD;;AAEDpB,gCAAwB;AACtB,eAAKf,GAAL,CAAS,oBAAT,EAA+BoC,KAA/B,CAAqCC,OAArC,GAA+C,OAA/C;AACD;;AAEDP,gCAAwB;AACtB,eAAK9B,GAAL,CAAS,oBAAT,EAA+BoC,KAA/B,CAAqCC,OAArC,GAA+C,MAA/C;AACD;;AAEDN,gCAAwB;AACtB,eAAK/B,GAAL,CAAS,oBAAT,EAA+BoC,KAA/B,CAAqCC,OAArC,GAA+C,OAA/C;AACD;;AAEDvB,gCAAwB;AACtB,eAAKd,GAAL,CAAS,oBAAT,EAA+BoC,KAA/B,CAAqCC,OAArC,GAA+C,MAA/C;AACD;AA7FuD;;yBAArC5C,sB","file":"bp2019-data-source-widget.js","sourcesContent":["import Morph from 'src/components/widgets/lively-morph.js';\n\nimport d3 from \"src/external/d3.v5.js\"\n\nimport { AVFParser } from \"https://lively-kernel.org/voices/parsing-data/avf-parser.js\"\nimport DataProcessor from '../src/internal/individuals-as-points/common/data-processor.js'\nimport ColorStore from '../src/internal/individuals-as-points/common/color-store.js'\n\nimport GeoData from \"https://lively-kernel.org/lively4/BP2019RH1/src/geodata/geoData.js\"\n\nexport default class Bp2019DataSourceWidget extends Morph {\n  async initialize() {      \n    this.colorStore = new ColorStore()\n    this.dataProcessor = new DataProcessor()\n    this.dataProcessor.setColorStore(this.colorStore)\n    \n    //for compatibility with current implementation for cloning of local actions\n    this.currentActions = []\n    \n    this.dataSetSelection = this.get(\"#data-sets\")\n    this.dataSetSelection.addEventListener(\"change\", async () => await this._handleDataSetSelection())\n        \n    this.dataSetSelection.dispatchEvent(new Event(\"change\"))\n  }\n  \n  applyAction(action) {\n    \n  }\n  \n  setData(data) {\n    return\n  }\n  \n  getData() {\n    return this.data\n  }\n  \n  getColorStore() {\n    return this.colorStore\n  }\n  \n  getDataProcessor() {\n    return this.dataProcessor\n  }\n  \n  setExtent(extent) {\n    \n  }\n  \n  async _handleDataSetSelection() {\n    this._hideUserInstructions()\n    this._showLoadingAnimation()\n    \n    let rawGeoData\n  \n    switch (this.dataSetSelection.options[this.dataSetSelection.selectedIndex].value) {\n      case \"kenya\":\n        this.data = await AVFParser.loadCovidData()\n        this.dataProcessor.initializeWithIndividualsFromKenia(this.data)\n        rawGeoData = await d3.json(bp2019url + \"/src/geodata/kenya-simplified-repaired.geojson\")\n        break;\n      case \"somalia\":\n        this.data = await AVFParser.loadCovidSomDataMessageThemes()\n        this.dataProcessor.initializeWithIndividualsFromSomalia(this.data)\n        rawGeoData = await d3.json(bp2019url + \"/src/geodata/somalia-simplified.geojson\")\n        break;\n    }\n    \n    this.geoData = new GeoData(rawGeoData.features)\n    this.colorStore.initializeWithValuesByAttribute(this.dataProcessor.getValuesByAttribute())\n    \n    this._hideLoadingAnimation()\n    this._showUserInstructions()\n    \n    this._dispatchDataLoadedEvent()\n  }\n  \n  _dispatchDataLoadedEvent() {\n    this.dispatchEvent(new CustomEvent(\"data-loaded\", {\n      detail: {\n        \"data\": this.data,\n        \"dataProcessor\": this.dataProcessor,\n        \"colorStore\": this.colorStore,\n        \"geoData\": this.geoData\n      },\n      bubbles: true\n    }))\n  }\n  \n  _showLoadingAnimation() {\n    this.get(\"#loading-animation\").style.display = \"block\"\n  }\n  \n  _hideLoadingAnimation() {\n    this.get(\"#loading-animation\").style.display = \"none\"\n  }\n  \n  _showUserInstructions() {\n    this.get(\"#user-instructions\").style.display = \"block\"\n  }\n  \n  _hideUserInstructions() {\n    this.get(\"#user-instructions\").style.display = \"none\"\n  }\n}"]}