var __awaiter=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))(function(o,r){function a(t){try{u(n.next(t))}catch(t){r(t)}}function c(t){try{u(n.throw(t))}catch(t){r(t)}}function u(t){var e;t.done?o(t.value):((e=t.value)instanceof i?e:new i(function(t){t(e)})).then(a,c)}u((n=n.apply(t,e||[])).next())})};import{widgetTypes as t}from"../index";import{Util as e}from"@openremote/core";export class WidgetService{static getManifest(e){let i=t.get(e);if(!i)throw Error("Widget manifest could not be found during widget creation.");return i}static placeNew(t,e,i){return __awaiter(this,void 0,void 0,function*(){let n=(Math.random()+1).toString(36).substring(2),o=this.getManifest(t);return{id:n,displayName:o.displayName,gridItem:{id:n,x:e,y:i,w:2,h:2,minW:o.minColumnWidth,minH:o.minColumnHeight,minPixelW:o.minPixelWidth,minPixelH:o.minPixelHeight,noResize:!1,noMove:!1,locked:!1},widgetConfig:o.getDefaultConfig(),widgetTypeId:t}})}static correctToConfigSpec(t,i){let n=e.mergeObjects(t.getDefaultConfig(),i,!1);return e.objectsEqual(n,i)?i:n}}