var __awaiter=this&&this.__awaiter||function(e,t,a,i){return new(a||(a=Promise))(function(r,s){function n(e){try{d(i.next(e))}catch(e){s(e)}}function o(e){try{d(i.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?r(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(n,o)}d((i=i.apply(e,t||[])).next())})};import e,{Util as t}from"@openremote/core";import{i18next as a}from"@openremote/or-translate";export var DashboardSizeOption;!function(e){e[e.DESKTOP=0]="DESKTOP",e[e.MOBILE=1]="MOBILE"}(DashboardSizeOption||(DashboardSizeOption={}));export class DashboardService{static create(a){return __awaiter(this,arguments,void 0,function*(a,i=DashboardSizeOption.DESKTOP,r=e.displayRealm,s=!0){var n;return(a?(a.id=void 0,a.template&&(a.template.id=t.generateUniqueUUID(),null==(n=a.template.widgets)||n.forEach(e=>e.id=t.generateUniqueUUID()))):a={realm:r,displayName:this.getDefaultDisplayName(i),template:{id:t.generateUniqueUUID(),columns:this.getDefaultColumns(i),maxScreenWidth:this.getDefaultMaxScreenWidth(i),refreshInterval:"OFF",screenPresets:this.getDefaultScreenPresets(i)}},s)?(yield e.rest.api.DashboardResource.create(a)).data:a})}static delete(t){return __awaiter(this,arguments,void 0,function*(t,a=e.displayRealm){return(yield e.rest.api.DashboardResource.delete(a,t)).data})}static getDefaultColumns(e){switch(e){case DashboardSizeOption.MOBILE:return 4;case DashboardSizeOption.DESKTOP:default:return 12}}static getDefaultDisplayName(e){switch(e){case DashboardSizeOption.DESKTOP:return a.t("dashboard.initialName");case DashboardSizeOption.MOBILE:return a.t("dashboard.initialName")+" ("+a.t("dashboard.size.mobile")+")"}}static getDefaultScreenPresets(e){return e===DashboardSizeOption.MOBILE?[{id:"mobile",displayName:"dashboard.size.mobile",breakpoint:640,scalingPreset:"KEEP_LAYOUT"}]:[{id:"mobile",displayName:"dashboard.size.mobile",breakpoint:640,scalingPreset:"WRAP_TO_SINGLE_COLUMN"}]}static getDefaultMaxScreenWidth(e){switch(e){case DashboardSizeOption.DESKTOP:return 4e3;case DashboardSizeOption.MOBILE:return 640}}}