{"version":3,"sources":["widgets/html/view/main.es6.js"],"names":["create","container","templateNameCustom","loadingTemplatePromise","rendered","node","find","templateName","Math","round","random","length","eq","attr","Promise","templates","get","domains","intercept","resolve","tpl","then","bus","sync","updatedText","render","model","dom","contents"],"mappings":";;;;YAKgBA,M,GAAAA,M;;;;;;;;;;;;;;;;AAAT,aAASA,MAAT,CAAgBC,SAAhB,EAA2BC,kBAA3B,EAA+C;AAClD,YAAIC,+BAAJ;AAAA,YACIC,iBADJ;;AAGA,YAAI,CAACF,kBAAL,EAAyB;AACrB,gBAAIG,OAAOJ,UAAUK,IAAV,CAAe,0BAAf,CAAX;AAAA,gBACIC,eAAe,MAAMC,KAAKC,KAAL,CAAWD,KAAKE,MAAL,KAAgB,KAA3B,CAAN,GAA0C,WAD7D;;AAGA,gBAAI,CAACL,KAAKM,MAAV,EAAkB;AACd;AACH;;AAEDN,mBAAOA,KAAKO,EAAL,CAAQ,CAAR,CAAP;AACAP,iBAAKQ,IAAL,CAAU,IAAV,EAAgBN,eAAe,WAA/B;;AAEAJ,qCAAyB,IAAIW,OAAJ,CAAY,mBAAW;AAC5CC,oCAAUC,GAAV,CAAcT,YAAd,EAA4BU,kBAAQF,SAAR,CAAkBG,SAAlB,CAA4B,eAAO;AAC3DC,4BAAQC,GAAR;AACH,iBAF2B,CAA5B;AAGH,aAJwB,CAAzB;AAMH,SAjBD,MAiBO;AACHjB,qCAAyB,IAAIW,OAAJ,CAAY,mBAAW;AAC5CC,oCAAUC,GAAV,CAAcd,kBAAd,EAAkCe,kBAAQF,SAAR,CAAkBG,SAAlB,CAA4B,eAAO;AACjEC,4BAAQC,GAAR;AACH,iBAFiC,CAAlC;AAGH,aAJwB,CAAzB;AAKH;;AAEDjB,+BAAuBkB,IAAvB,CAA4B,eAAO;AAC/BC,0BAAIC,IAAJ,CAAS,qBAAT,EAAgC,iBAAS;AACrC,oBAAIC,cAAcJ,IAAIK,MAAJ,CAAWC,KAAX,CAAlB;;AAEA,oBAAItB,aAAaoB,WAAjB,EAA8B;AAC1BpB,+BAAWoB,WAAX;AACAG,kCAAIC,QAAJ,CAAa3B,SAAb,EAAwBG,QAAxB;AACH;AAEJ,aARD;AASH,SAVD;AAWH","file":"widgets/html/view/main.js","sourceRoot":"/source/","sourcesContent":["import bus from 'bus';\r\nimport dom from 'modules/env/dom';\r\nimport domains from 'modules/domains';\r\nimport templates from 'modules/templates';\r\n\r\nexport function create(container, templateNameCustom) {\r\n let loadingTemplatePromise,\r\n rendered;\r\n\r\n if (!templateNameCustom) {\r\n let node = container.find('script[type=\"text/html\"]'),\r\n templateName = '_' + Math.round(Math.random() * 10000) + '-template';\r\n\r\n if (!node.length) {\r\n return;\r\n }\r\n\r\n node = node.eq(0);\r\n node.attr('id', templateName + '-template');\r\n\r\n loadingTemplatePromise = new Promise(resolve => {\r\n templates.get(templateName, domains.templates.intercept(tpl => {\r\n resolve(tpl);\r\n }));\r\n });\r\n\r\n } else {\r\n loadingTemplatePromise = new Promise(resolve => {\r\n templates.get(templateNameCustom, domains.templates.intercept(tpl => {\r\n resolve(tpl);\r\n }));\r\n });\r\n }\r\n\r\n loadingTemplatePromise.then(tpl => {\r\n bus.sync('command.view.change', model => {\r\n let updatedText = tpl.render(model);\r\n\r\n if (rendered !== updatedText) {\r\n rendered = updatedText;\r\n dom.contents(container, rendered);\r\n }\r\n\r\n });\r\n });\r\n}\r\n\r\n"]}