var __awaiter=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function l(e){try{s(r["throw"](e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(a,l)}s((r=r.apply(e,t||[])).next())})};var __generator=this&&this.__generator||function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:l(0),throw:l(1),return:l(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(e){return function(t){return s([e,t])}}function s(a){if(r)throw new TypeError("Generator is already executing.");while(n)try{if(r=1,i&&(o=a[0]&2?i["return"]:a[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;if(i=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;i=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(o=n.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){n.label=a[1];break}if(a[0]===6&&n.label<o[1]){n.label=o[1];o=a;break}if(o&&n.label<o[2]){n.label=o[2];n.ops.push(a);break}if(o[2])n.ops.pop();n.trys.pop();continue}a=t.call(e,n)}catch(e){a=[6,e];i=0}finally{r=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};System.register(["./p-b236363f.system.js","./p-9089e441.system.js"],function(e){"use strict";var t,n;return{setters:[function(e){t=e.r},function(e){n=e.g}],execute:function(){var r=function(){function e(e){t(this,e);this.defaultOptions={type:"point",multiple:false,combine:false,delete:false,mode:"draw"}}e.prototype.create=function(e,t){return __awaiter(this,void 0,void 0,function(){var r,i;return __generator(this,function(o){switch(o.label){case 0:r=n(t.mapId);if(!r)throw"Draw action map not found";i=document.querySelector("gl-draw-toolbar");if(i&&t.toolbarLabel)i.label=t.toolbarLabel;r.drawOptions=this.getControlOptions(t);r.drawing=true;if(e)r.draw.set(e);return[4,new Promise(function(e){var t=function(){r.drawing=false;e();i.removeEventListener("glDrawCancel",t);i.removeEventListener("glDrawConfirm",n)};var n=function(){var t=r.draw.getAll();r.drawing=false;e(t);i.removeEventListener("glDrawConfirm",n);i.removeEventListener("glDrawConfirm",n)};i.addEventListener("glDrawCancel",t);i.addEventListener("glDrawConfirm",n)})];case 1:return[2,o.sent()]}})})};e.prototype.getControlOptions=function(e){var t=Object.assign({},this.defaultOptions,e||{});var n="simple_select";if(t.mode==="direct")n="direct_select";if(t.mode==="draw"){if(t.type==="point")n="draw_point";if(t.type==="line")n="draw_line_string";if(t.type==="polygon")n="draw_polygon"}var r={controls:{point:t.multiple&&t.type==="point",line_string:t.multiple&&t.type==="line",polygon:t.multiple&&t.type==="polygon",trash:t.delete,combine_features:t.multiple&&t.combine,uncombine_features:t.multiple&&t.combine},defaultMode:n};if(t.styles)r.styles=t.styles;return r};return e}();e("gl_draw_controller",r)}}});