import{r as e}from"./p-23450e8b.js";import{g as t}from"./p-d8674de4.js";const n=class{constructor(t){e(this,t);this.defaultOptions={type:"point",multiple:false,combine:false,delete:false,mode:"draw"}}async create(e,n){let i=t(n.mapId);if(i==undefined)throw"Draw action map not found";let r=document.querySelector("gl-draw-toolbar");if(r!=undefined&&n.toolbarLabel!=undefined)r.label=n.toolbarLabel;i.drawOptions=this.getControlOptions(n);i.drawing=true;if(e!=undefined)i.draw.set(e);return await new Promise((e=>{let t=()=>{i.drawing=false;e(undefined);r.removeEventListener("glDrawCancel",t);r.removeEventListener("glDrawConfirm",n)};let n=()=>{let t=i.draw.getAll();i.drawing=false;e(t);r.removeEventListener("glDrawConfirm",n);r.removeEventListener("glDrawConfirm",n)};r.addEventListener("glDrawCancel",t);r.addEventListener("glDrawConfirm",n)}))}getControlOptions(e){let t=Object.assign(Object.assign({},this.defaultOptions),e||{});let 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"}let i={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!=undefined)i.styles=t.styles;return i}};export{n as gl_draw_controller};
//# sourceMappingURL=p-47516d22.entry.js.map