define(["@jupyter-widgets/base","nbextensions/jupyter-vega/index"],(function(e,t){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function u(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,u)}c((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.VegaWidget=void 0;const o=n(1),i=n(2);class s extends o.DOMWidgetView{constructor(){super(...arguments),this.viewElement=document.createElement("div"),this.errorElement=document.createElement("div")}render(){this.el.appendChild(this.viewElement),this.errorElement.style.color="red",this.el.appendChild(this.errorElement);const e=()=>{this.result&&(this.result.finalize(),this.result=void 0);const e=JSON.parse(this.model.get("_spec_source")),t=JSON.parse(this.model.get("_opt_source"));null!=e&&i.vegaEmbed(this.viewElement,e,Object.assign({loader:{http:{credentials:"same-origin"}}},t)).then(e=>{this.result=e,this.send({type:"display"})}).catch(e=>console.error(e))},t=e=>r(this,void 0,void 0,(function*(){const t=this.result;if(null==t)throw new Error("Internal error: no view attached to widget");const n=new Function("datum","return ("+(e.remove||"false")+")"),r=e.insert||[],o=t.view.changeset().insert(r).remove(n);yield t.view.change(e.key,o).runAsync()})),n=e=>r(this,void 0,void 0,(function*(){for(const n of e.updates)yield t(n)}));this.model.on("change:_spec_source",e),this.model.on("change:_opt_source",e),this.model.on("msg:custom",e=>{const t=function(e){return"update"!=e.type?null:e}(e);null!=t&&n(t).catch(e=>{this.errorElement.textContent=""+e,console.error(e)})}),e()}}t.VegaWidget=s},function(t,n){t.exports=e},function(e,n){e.exports=t}])}));
//# sourceMappingURL=widget.js.map