UNPKG

homebridge-config-ui-x

Version:

A web based management, configuration and control platform for Homebridge.

10 lines • 223 kB
import {I as I$1}from'./chunk-MBL0f7eL.js';import {R as Ri,A as Ao$1}from'./chunk-DMIeeBQR.js';import {o as oe,j as jt,J as Jt,D as Dt}from'./chunk-B6VUt1El.js';import {v,Y,m as m$1}from'./chunk-CG3i5q02.js';import {N}from'./chunk-DBaXd1B9.js';import {p}from'./chunk-b_mHvpXA.js';import {E as E$1,Z}from'./chunk-BwPN3JEB.js';import {b as bn$1,k as kn,M as Mn}from'./chunk-CCTcrEQI.js';import {L as L$1}from'./chunk-DL7vVfE4.js';import {O as O$2}from'./chunk-BtxeAJ3m.js';import {p as pr$1}from'./chunk-vqqeWC6a.js';import {L,s,l,e,n,a,r,O,I,_,M,g as g$1,A}from'./chunk-BWu8OGjA.js';import {t as t$4}from'./chunk-Cy08K-Mh.js';import {s as s$2}from'./chunk-C8ZPrgbC.js';import {t as t$3}from'./chunk-doMANZyQ.js';import {t as t$2}from'./chunk-B2HnQlJt.js';import {t as t$1}from'./chunk-b3up2ArD.js';import {t}from'./chunk-7svcfPtx.js';import {d as dr$1}from'./chunk-KTYlT6lA.js';import {P,T,g as g$2,R,C as C$1,D,i as i$1,O as O$1,E as E$2,H,G,I as I$2,N as N$1,L as L$2}from'./chunk-WUyBXYN7.js';import {i}from'./chunk-C4ubcADd.js';import {s as s$5}from'./chunk-QDhEG-Xh.js';import {o}from'./chunk-BidAOGy6.js';import {t as t$7}from'./chunk-lMjhVFUB.js';import {t as t$6}from'./chunk-CzRg8YX8.js';import {t as t$5}from'./chunk-DAyV9xsz.js';import {s as s$4}from'./chunk-B41tnDbB.js';import {s as s$3}from'./chunk-DqdSMBKI.js';import {t as t$c}from'./chunk-DoPE3N3z.js';import {t as t$b}from'./chunk-D-E7ed-H.js';import {s as s$6}from'./chunk-Ds4JiOhb.js';import {i as i$2}from'./chunk-BaKTdomc.js';import {o as o$1}from'./chunk-CSWVRWgN.js';import {t as t$a}from'./chunk-u2FneiiB.js';import {t as t$9}from'./chunk-DuKttKIp.js';import {t as t$8}from'./chunk-CgMQTfWL.js';import {g,X as I3,ah as si,Z as m,z as zt$1,a1 as M0,a2 as bf,ag as we,aF as $$1,E,ai as ty,a5 as x,a4 as w,ae as C,a as ae,av as fe,l as le,W,J as Ja$1,aH as X,n as ne,S as Se,H as Hf,A as An,bA as Ou,aj as D$1,F as Fn,B as BH,bB as cE,c as Eo$1,bC as Nn,bD as y,ay as Qe,bE as t$,an as PH,bF as pa$1,bG as Ra$1,bH as ca$1,bI as Sn,aQ as LH,ao as ei,bJ as xt,bK as jr$1,bL as Od,u as Re,bM as tc,y as ie,O as Oe,bN as Qk,bj as Y$1,k as K8,m as La$1,s as At$1,R as Rd,t as f_,q as rc,o as dy,N as Ny,D as ly,a6 as vr$1,G as h_,I as Rt,M as Ey,P as ST,K as Kn$1,b7 as Xn$1,b8 as Yn$1,Y as Ye,bb as Vt,br as fn$1,e as Hn,be as ln$1,i as Jn$1,bs as mn$1,x as Cy,j as a$,bk as g_,a7 as s_,bO as vN,bP as ay,bQ as sy,bR as S$,bS as _N,bT as uy,bU as Vr$1,bV as KN,bW as M$,bX as WN,bY as k,bZ as UN,bo as xy,b9 as dn$1,ba as Mt,bc as Ht,bd as Gt$1,b_ as X$1,az as ke,aB as _i,aC as Dr$1,aA as Je,aD as bi,bw as a_,a8 as nc,a9 as Go$1,U as ye,aa as Wo$1,bt as Fy,bu as ky,b1 as dT,bv as lT,Q as KC,b4 as fT,T as JC,b$ as ay$1,at as MT,bz as Ay,by as t_,bq as pw,V as Ha$1,aw as Qt,c0 as u_,c1 as l_,bx as c_,ax as Wg}from'./main-ONDCASUV.js';import {s as s$8}from'./chunk-BC_vNxU2.js';import {t as t$e}from'./chunk-C-jJI3wF.js';import {o as o$2}from'./chunk-C3fDPXbF.js';import {t as t$d}from'./chunk-B09onH1d.js';import {s as s$1}from'./chunk-DIIPo35n.js';import {a as a$1}from'./chunk-BVt7fy49.js';import {s as s$7}from'./chunk-DcTLbPux.js';var Gi="plugins-list",We=(()=>{class i{$api=g(I3);$auth=g(ae);$cache=g(p);get(){let e=this.$auth.user.admin?"/plugins?include=config":"/plugins";return this.$cache.get(Gi,()=>this.$api.get(e))}invalidate(){this.$cache.invalidate(Gi);}static \u0275fac=function(n){return new(n||i)};static \u0275prov=C({token:i,factory:i.\u0275fac,providedIn:"root"})}return i})();var Ke=D$1(Ri());var Ki=(()=>{class i{host=g(Qe);jsonSchemaForm=g(t$,{host:true,self:true,optional:true});observer;patchingInProgress=false;jsfPatch=PH(false);constructor(){let e=this.jsonSchemaForm;if(!e)return;let n=e.jsf.buildLayout.bind(e.jsf);e.jsf.buildLayout=t=>(n(t),e.jsf.formValues&&this.jsfPatch()?this.fixNestedArrayLayout(e.jsf.layout,e.jsf.formValues):e.jsf.layout);}ngAfterViewInit(){this.patchAccessibility();let e=false;this.observer=new MutationObserver(n=>{if(!this.patchingInProgress){for(let t of n){let a=t.target;if(a?.closest&&(a.closest(".dropdown-menu")||a.closest("ngb-typeahead-window")||a.closest(".cdk-overlay-container")||a.closest('[role="listbox"]')))return}e||(e=true,requestAnimationFrame(()=>{e=false,this.patchAccessibility();}));}}),this.observer.observe(this.host.nativeElement,{childList:true,subtree:true,attributes:true,attributeFilter:["class","aria-expanded"]});}ngOnDestroy(){this.observer?.disconnect(),this.observer=void 0;}patchAccessibility(){if(this.patchingInProgress)return;this.patchingInProgress=true;let e=this.host.nativeElement;this.patchExpandableFieldsetLegends(e),this.patchExpandableSectionLegends(e),this.patchDeleteButtons(e),this.patchCheckboxRadioDuplicateText(e),this.patchBasicControlNames(e),this.patchingInProgress=false;}patchExpandableFieldsetLegends(e){e.querySelectorAll("fieldset").forEach(t=>{let a=t,m=a.querySelector("legend");if(!m)return;let u=this.cleanSectionTitle((m.textContent||"").trim());if(!u)return;let h=m.querySelector("button")||m.querySelector("a")||m.querySelector('[data-bs-toggle="collapse"]')||m.querySelector("[aria-expanded]")||m,v=this.findCollapseBody(a,h),T=a.querySelector(":scope > button.jsf-fieldset-proxy");T||(T=document.createElement("button"),T.type="button",T.className="jsf-fieldset-proxy visually-hidden-focusable",a.insertBefore(T,a.firstChild),T.addEventListener("click",L=>{L.preventDefault(),h.click(),window.setTimeout(()=>{this.syncProxyExpanded(a,T,h,v);},0);}),T.addEventListener("keydown",L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),T.click());})),T.textContent=u,T.setAttribute("role","button"),T.setAttribute("tabindex","0"),T.setAttribute("aria-label",u),T.removeAttribute("aria-describedby"),v?(v.id||(v.id=`jsf_collapse_${Math.random().toString(36).slice(2)}`),T.setAttribute("aria-controls",v.id)):T.removeAttribute("aria-controls"),a.setAttribute("role","presentation"),m.setAttribute("aria-hidden","true"),m.querySelectorAll("button, a, [tabindex]").forEach(L=>{L.setAttribute("tabindex","-1");}),this.syncProxyExpanded(a,T,h,v);});}syncProxyExpanded(e,n,t,a){let u=this.getExpandedState(e,a,t)?"true":"false";n.getAttribute("aria-expanded")!==u&&n.setAttribute("aria-expanded",u);}patchExpandableSectionLegends(e){e.querySelectorAll("section-widget").forEach(t=>{let a=t.querySelector(":scope > div");if(!a||!a.classList.contains("expandable")&&!a.classList.contains("expanded"))return;let m=a.querySelector(":scope > label.legend");if(!m)return;let u=this.cleanSectionTitle((m.textContent||"").trim());if(!u)return;let h=a.querySelector(":scope > root-widget"),v=a.querySelector(":scope > button.jsf-section-proxy");v||(v=document.createElement("button"),v.type="button",v.className="jsf-section-proxy visually-hidden-focusable",a.insertBefore(v,a.firstChild),v.addEventListener("click",T=>{T.preventDefault(),m.click(),window.setTimeout(()=>{this.syncSectionProxyExpanded(a,v,h);},0);}),v.addEventListener("keydown",T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),v.click());})),v.textContent=u,v.setAttribute("role","button"),v.setAttribute("tabindex","0"),v.setAttribute("aria-label",u),v.removeAttribute("aria-describedby"),h?(h.id||(h.id=`jsf_section_${Math.random().toString(36).slice(2)}`),v.setAttribute("aria-controls",h.id)):v.removeAttribute("aria-controls"),a.setAttribute("role","presentation"),m.setAttribute("aria-hidden","true"),m.querySelectorAll("button, a, [tabindex]").forEach(T=>{T.setAttribute("tabindex","-1");}),this.syncSectionProxyExpanded(a,v,h);});}syncSectionProxyExpanded(e,n,t){let m=this.getSectionExpandedState(e,t)?"true":"false";n.getAttribute("aria-expanded")!==m&&n.setAttribute("aria-expanded",m);}getSectionExpandedState(e,n){return e.classList.contains("expanded")?true:e.classList.contains("expandable")&&!e.classList.contains("expanded")?false:n?window.getComputedStyle(n).display!=="none":true}findCollapseBody(e,n){if(n){let t=n.getAttribute("aria-controls");if(t){let m=document.getElementById(t);if(m)return m}let a=n.getAttribute("data-bs-target")||n.getAttribute("data-target");if(a&&a.startsWith("#")){let m=document.getElementById(a.slice(1));if(m)return m}}return e.querySelector(":scope .collapse")}getExpandedState(e,n,t){let a=t?.getAttribute("aria-expanded");return a==="true"?true:a==="false"||t?.classList.contains("collapsed")?false:n?n.classList.contains("show"):this.isFieldsetExpanded(e)}isFieldsetExpanded(e){let n=e.querySelectorAll("input, select, textarea, button, a");for(let t of n){let a=t;if(this.isVisiblyRendered(a)){if(a.tagName.toLowerCase()==="legend"||a.classList.contains("jsf-fieldset-proxy"))continue;return true}}return false}isVisiblyRendered(e){let n=window.getComputedStyle(e);return n.display==="none"||n.visibility==="hidden"||e.getAttribute("aria-hidden")==="true"?false:e.getClientRects().length>0}patchDeleteButtons(e){e.querySelectorAll("button.btn-close").forEach(t=>{let a=t;if(a.hasAttribute("data-jsf-a11y-delete"))return;let m=this.findNearestItemName(a,e);a.setAttribute("aria-label",m?`Delete ${m}`:"Delete"),a.removeAttribute("title"),a.setAttribute("data-jsf-a11y-delete","true");});}findNearestItemName(e,n){let a=e.closest(".list-group-item")||e.closest(".card")||e.closest("li")||e.closest("fieldset")||e.parentElement||n,m=a.querySelector("legend");if(m){let h=this.cleanSectionTitle((m.textContent||"").trim());if(h)return h}let u=a.querySelector("h1, h2, h3, h4, h5, h6");if(u){let h=this.cleanSectionTitle((u.textContent||"").trim());if(h)return h}return ""}cleanSectionTitle(e){let n=(e||"").replace(H,"").trim();return n=n.replace(G,"").trim(),n.length>80&&(n=n.slice(0,80).trim()),n}patchCheckboxRadioDuplicateText(e){e.querySelectorAll("input").forEach(t=>{let a=t,m=(a.getAttribute("type")||"").toLowerCase();if(m!=="checkbox"&&m!=="radio"||a.hasAttribute("data-jsf-a11y-processed"))return;let u=a.id?e.querySelector(`label[for="${a.id}"]`):null,h=a.closest("label"),v=u||h,T=this.getLabelText(v);if(!T)return;this.hasExplicitA11yName(a)||a.setAttribute("aria-label",T),a.setAttribute("data-jsf-a11y-processed","true"),h&&h.contains(a)&&h.querySelectorAll("*").forEach(O=>{if(O===a||O.contains(a)||O.hasAttribute("data-jsf-a11y-hidden"))return;(O.classList.contains("hb-uix-slider")||O.classList.contains("hb-uix-round"))&&(O.setAttribute("aria-hidden","true"),O.setAttribute("data-jsf-a11y-hidden","true"));});let L=a.parentElement;if(L)for(let O=0;O<L.children.length;O+=1){let F=L.children[O];if(!(F instanceof HTMLElement)||F===a||v&&F===v||F.hasAttribute("data-jsf-a11y-hidden")||this.isInteractiveElement(F))continue;let it=(F.textContent||"").trim();it&&it===T&&(F.setAttribute("aria-hidden","true"),F.setAttribute("data-jsf-a11y-hidden","true"));}});}getLabelText(e){return e?(e.textContent||"").replace(I$2," ").trim():""}hasExplicitA11yName(e){let n=e.getAttribute("aria-label");if(n&&n.trim())return true;let t=e.getAttribute("aria-labelledby");if(t&&t.trim())return true;let a=e.getAttribute("title");return !!(a&&a.trim())}isInteractiveElement(e){let n=e.tagName.toLowerCase();if(["a","button","input","select","textarea"].includes(n))return true;let t=e.getAttribute("tabindex");if(t!==null&&Number.parseInt(t,10)>=0)return true;let a=e.getAttribute("role");return a!=null&&["button","link","menuitem","tab","option"].includes(a)}patchBasicControlNames(e){e.querySelectorAll("input, select, textarea").forEach(t=>{let a=t;if(a instanceof HTMLInputElement){let u=(a.getAttribute("type")||"").toLowerCase();if(u==="checkbox"||u==="radio")return}if(a.hasAttribute("data-jsf-a11y-labeled"))return;if(this.hasExplicitA11yName(a)){a.setAttribute("data-jsf-a11y-labeled","true");return}let m="";if(a.id&&(m=(e.querySelector(`label[for="${a.id}"]`)?.textContent||"").trim()),!m){let u=a.closest("label");m=this.getLabelText(u);}m&&(a.setAttribute("aria-label",m),a.setAttribute("data-jsf-a11y-labeled","true"));});}fixNestedArrayLayout(e,n){return this.fixArray(e,n,""),e}fixArray(e,n,t){if(Array.isArray(e)){let a=e.filter(h=>h.name!=="_bridge"),m=a.filter(h=>h.items&&Array.isArray(h.items)).flatMap(h=>h.items).filter(h=>h.dataType==="array"||h.arrayItem);[...a,...m].filter(h=>h.dataType==="array"||h.arrayItem).forEach(h=>{this.fixNestedArray(h,n,t);});}else this.fixNestedArray(e,n,t);}fixNestedArray(e,n,t){if(e.items&&Array.isArray(e.items)){let a=e.items.find(m=>m.type==="$ref");if(a){let m=e.items.filter(v=>v.type==="section"||v.type==="div"),u=m.length>0?m.reduce((v,T)=>v.id>T.id?v:T):this.getItemTemplateFromRef(a),h=this.getDataFromPointer(n,a.dataPointer.replace(t,""));if(h===null)return;if(Array.isArray(h)){for(;e.items.length-1<h.length;){let v=pa$1(u);v._id=Ra$1("new_"),e.items.unshift(v);}h.forEach((v,T)=>{this.fixArray(e.items[T],v,a.dataPointer);});}else this.fixArray(e.items,n,a.dataPointer);}else this.fixArray(e.items,n,t);e.items.filter(m=>m.items&&Array.isArray(m.items)).forEach(m=>{this.fixArray(m.items,n,t);});}}getDataFromPointer(e,n){let t=e;return n.substring(1).split(N$1).filter(a=>a!=="-").forEach(a=>{try{t=t[a];}catch(m){t=null;}}),t}getItemTemplateFromRef(e){let n={type:"section",items:[]},t=pa$1(e);return ca$1(t,n),t}static \u0275fac=function(n){return new(n||i)};static \u0275dir=Sn({type:i,selectors:[["","jsfPatch",""]],inputs:{jsfPatch:[1,"jsfPatch"]}})}return i})();function Kn(i,c){if(i&1){let e=nc();La$1(0,"json-schema-form",1),rc("onChanges",function(t){Go$1(e);let a=ye();return Wo$1(a.onChanges(t))})("isValid",function(t){Go$1(e);let a=ye();return Wo$1(a.validChange(t))}),Rd();}if(i&2){let e=ye();ly("jsfPatch",e.configSchema().fixArrays)("options",e.jsonFormOptions)("schema",e.configSchema().schema)("UISchema",e.configSchema().uiSchema)("layout",e.configSchema().layout)("form",e.configSchema().form)("data",e.currentData())("language",e.language());}}var $t=(()=>{class i{$settings=g(zt$1);availableLanguages=["de","en","es","fr","it","pt","zh"];configSchema=PH.required();data=PH.required();dataChange=LH();dataChanged=LH();isValid=LH();currentData=W(null);language=W("en");jsonFormOptions={addSubmit:false,loadExternalAssets:false,returnEmptyFields:false,setSchemaDefaults:true,autocomplete:false};lastValidState=void 0;validationTimeout=null;lastDataReference=null;processingInternalChange=false;constructor(){ei(()=>{let e=this.data();if(this.processingInternalChange){this.lastDataReference=e;return}this.lastDataReference!==e&&(this.lastDataReference=e,this.currentData.set(e));});}ngOnInit(){let e=this.$settings.env.lang?.split("-")[0];e&&this.availableLanguages.includes(e)&&this.language.set(e);}ngOnDestroy(){this.validationTimeout&&clearTimeout(this.validationTimeout);}onChanges(e){this.processingInternalChange=true;let n=this.data();if(n&&typeof n=="object"&&typeof e=="object"){let t=n._bridge;for(let a of Object.keys(n))a in e||delete n[a];Object.assign(n,e),t===void 0?delete n._bridge:n._bridge=t,this.dataChange.emit(n),this.dataChanged.emit(n);}else this.dataChange.emit(e),this.dataChanged.emit(e);queueMicrotask(()=>{this.processingInternalChange=false;});}validChange(e){this.validationTimeout&&clearTimeout(this.validationTimeout),this.validationTimeout=setTimeout(()=>{this.lastValidState!==e&&(this.lastValidState=e,this.isValid.emit(e));},50);}static \u0275fac=function(n){return new(n||i)};static \u0275cmp=Ja$1({type:i,selectors:[["app-schema-form"]],inputs:{configSchema:[1,"configSchema"],data:[1,"data"]},outputs:{dataChange:"dataChange",dataChanged:"dataChanged",isValid:"isValid"},decls:2,vars:1,consts:[["framework","bootstrap-5",1,"ng-bs5-validate",3,"jsfPatch","options","schema","UISchema","layout","form","data","language"],["framework","bootstrap-5",1,"ng-bs5-validate",3,"onChanges","isValid","jsfPatch","options","schema","UISchema","layout","form","data","language"]],template:function(n,t){n&1&&(Od(0),Re(1,Kn,1,8,"json-schema-form",0),tc()),n&2&&(ie(),Oe(t.configSchema().schema?1:-1));},dependencies:[jr$1,t$,Ki],encapsulation:2})}return i})();var Jn=y({"../../../../i18n/bg.json":()=>s$8(),"../../../../i18n/ca.json":()=>t$e(),"../../../../i18n/cs.json":()=>o$2(),"../../../../i18n/de.json":()=>t$d(),"../../../../i18n/en.json":()=>s$1(),"../../../../i18n/es.json":()=>a$1(),"../../../../i18n/fi.json":()=>s$7(),"../../../../i18n/fr.json":()=>t$c(),"../../../../i18n/he.json":()=>t$b(),"../../../../i18n/hu.json":()=>s$6(),"../../../../i18n/id.json":()=>i$2(),"../../../../i18n/it.json":()=>o$1(),"../../../../i18n/ja.json":()=>t$a(),"../../../../i18n/ko.json":()=>t$9(),"../../../../i18n/mk.json":()=>t$8(),"../../../../i18n/nl.json":()=>i(),"../../../../i18n/no.json":()=>s$5(),"../../../../i18n/pl.json":()=>o(),"../../../../i18n/pt-BR.json":()=>t$7(),"../../../../i18n/pt.json":()=>t$6(),"../../../../i18n/ru.json":()=>t$5(),"../../../../i18n/sl.json":()=>s$4(),"../../../../i18n/sv.json":()=>s$3(),"../../../../i18n/th.json":()=>t$4(),"../../../../i18n/tr.json":()=>s$2(),"../../../../i18n/uk.json":()=>t$3(),"../../../../i18n/vi.json":()=>t$2(),"../../../../i18n/zh-CN.json":()=>t$1(),"../../../../i18n/zh-TW.json":()=>t()});var Xn=["custompluginui"];function Qn(i,c){i&1&&(La$1(0,"div",6),dy(1,"i",18),Rd());}function Yn(i,c){if(i&1){let e=nc();La$1(0,"div",8)(1,"app-schema-form",19),Fy("dataChange",function(t){Go$1(e);let a=ye();return t_(a.pluginConfig[0],t)||(a.pluginConfig[0]=t),Wo$1(t)}),rc("dataChanged",function(t){Go$1(e);let a=ye();return Wo$1(a.schemaFormUpdatedSubject.next(t))})("isValid",function(t){Go$1(e);let a=ye();return Wo$1(a.onIsValid(t))}),Rd()();}if(i&2){let e=ye();ie(),ly("configSchema",e.schema),ky("data",e.pluginConfig[0]);}}function Zn(i,c){if(i&1){let e=nc();La$1(0,"button",23),rc("click",function(){Go$1(e);let t=ye(2);return Wo$1(t.formActionSubject.next("cancel"))}),At$1(1),Rd();}if(i&2){let e=ye(2);ie(),Rt(" ",e.formCancelButtonLabel()," ");}}function eo(i,c){if(i&1){let e=nc();La$1(0,"button",24),rc("click",function(){Go$1(e);let t=ye(2);return Wo$1(t.formActionSubject.next("submit"))}),At$1(1),Rd();}if(i&2){let e=ye(2);ly("disabled",!e.formValid()),ie(),Rt(" ",e.formSubmitButtonLabel()," ");}}function to(i,c){if(i&1){let e=nc();La$1(0,"div",8)(1,"app-schema-form",19),rc("dataChange",function(t){Go$1(e);let a=ye();return Wo$1(a.formData.set(t))})("dataChanged",function(t){Go$1(e);let a=ye();return Wo$1(a.formUpdatedSubject.next(t))})("isValid",function(t){Go$1(e);let a=ye();return Wo$1(a.formValidEvent(t))}),Rd(),La$1(2,"div",20),Re(3,Zn,2,1,"button",21),Re(4,eo,2,2,"button",22),Rd()();}if(i&2){let e=ye();ie(),ly("configSchema",e.formSchema())("data",e.formData()),ie(2),Oe(e.formCancelButtonLabel()?3:-1),ie(),Oe(e.formSubmitButtonLabel()?4:-1);}}function io(i,c){i&1&&(La$1(0,"div",9),dy(1,"i",18),Rd());}function no(i,c){if(i&1&&(dy(0,"i",25),f_(1,"translate")),i&2){let e=ye();Cy("fa-circle-check",e.formIsValid())("green-text",e.formIsValid())("fa-circle-exclamation",!e.formIsValid())("red-text",e.strictValidation()&&!e.formIsValid())("orange-text",!e.strictValidation()&&!e.formIsValid()),ly("ngbTooltip",h_(1,12,e.formIsValid()?"form.label_valid":e.strictValidation()?"form.label_invalid_strict":"form.label_invalid"))("openDelay",150);}}function oo(i,c){i&1&&(At$1(0),f_(1,"translate")),i&2&&Rt(" ",h_(1,1,"form.button_save")," ");}function ao(i,c){i&1&&dy(0,"i",17);}var Ji=(()=>{class i{$activeModal=g(fe);$accessoryCache=g(m$1);$api=g(I3);$cb=g(jt);$plugin=g(Me);$settings=g(zt$1);$toastr=g(M0);$translate=g(bf);$ws=g(dr$1);modalData=g(_);customPluginUiElementTarget=BH("custompluginui");plugin=this.modalData.plugin;schema=this.modalData.schema;pluginConfig=this.modalData.pluginConfig??[];pluginAlias=W("");pluginType=W("platform");loading=W(true);saveInProgress=W(false);pluginSpinner=W(false);saveButtonDisabled=W(false);uiLoaded=W(false);showSchemaForm=W(false);formId=W(void 0);formSchema=W(void 0);formData=W(void 0);formSubmitButtonLabel=W(void 0);formCancelButtonLabel=W(void 0);formValid=W(true);isFirstSave=W(false);formIsValid=W(true);strictValidation=W(false);io;basePath="";iframe;schemaFormRecentlyRefreshed=false;destroyRef=g(ne);schemaFormUpdatedSubject=new $$1;schemaFormRefreshSubject=new $$1;formUpdatedSubject=new $$1;formActionSubject=new $$1;ngOnInit(){let e=this.schema,n=this.plugin;if(!e||!n){console.error("CustomPluginsComponent: schema or plugin not provided"),this.$activeModal.dismiss("Missing required data");return}this.pluginAlias.set(e.pluginAlias),this.pluginType.set(e.pluginType),this.strictValidation.set(e.strictValidation),this.pluginConfig.length===0&&this.isFirstSave.set(true),this.io=this.$ws.connectToNamespace("plugins/settings-ui"),this.basePath=`/plugins/settings-ui/${encodeURIComponent(n.name)}`,this.initialize(),this.schemaFormRefreshSubject.pipe(Hf(250),An(this.destroyRef)).subscribe(this.schemaFormRefresh.bind(this)),this.schemaFormUpdatedSubject.pipe(Hf(250),cE(1),An(this.destroyRef)).subscribe(()=>{this.schemaFormUpdated();}),this.formUpdatedSubject.pipe(Hf(100),cE(1),An(this.destroyRef)).subscribe(this.formUpdated.bind(this)),this.formActionSubject.pipe(An(this.destroyRef)).subscribe(this.formActionEvent.bind(this)),window.addEventListener("message",this.handleMessage,false);}ngOnDestroy(){window.removeEventListener("message",this.handleMessage),this.io?.socket&&(this.io.socket.removeAllListeners("response"),this.io.socket.removeAllListeners("stream"),this.io.socket.removeAllListeners("ready")),this.io&&this.io.end?.(),this.schemaFormRefreshSubject.complete(),this.schemaFormUpdatedSubject.complete(),this.formUpdatedSubject.complete(),this.formActionSubject.complete();}onIsValid(e){this.formIsValid.set(e);}formValidEvent(e){this.formValid.set(e);}savePluginConfig(e=false){return E(this,null,function*(){let n=this.plugin;if(!n)return false;this.saveInProgress.set(true);try{let t=yield this.$api.post(`/config-editor/plugin/${encodeURIComponent(n.name)}?include=restart-info`,this.pluginConfig),a=t.config;if(this.saveInProgress.set(!1),e){if(this.isFirstSave()&&this.$settings.env.recommendChildBridges&&a[0]?.platform)return this.$activeModal.close(),this.$plugin.bridgeSettings(n,!0),!0;this.$activeModal.close(),this.$cb.openCorrectRestartModalWithBridges(t.affectedBridges);}return !0}catch(t){return console.error(t),this.$toastr.error(this.$translate.instant("config.failed_to_save_config"),this.$translate.instant("toast.title_error")),this.saveInProgress.set(false),false}})}dismissModal(){this.$activeModal.dismiss("Dismiss");}initialize(){return E(this,null,function*(){let e=this.plugin;e&&(this.io.socket.emit("start",e.name),this.io.socket.on("response",n=>{n.action="response",this.iframe?.contentWindow?.postMessage(n,Eo$1.api.origin);}),this.io.socket.on("stream",n=>{n.action="stream",this.iframe?.contentWindow?.postMessage(n,Eo$1.api.origin);}),this.io.socket.on("ready",()=>{this.loading.set(false),this.loadUi();}));})}loadUi(){let e=this.plugin;e&&(this.iframe=this.customPluginUiElementTarget()?.nativeElement,this.iframe&&(this.iframe.src=`${Eo$1.api.base+this.basePath}/index.html?origin=${encodeURIComponent(location.origin)}&v=${encodeURIComponent(e.installedVersion)}`));}handleMessage=e=>{if(e.origin===Eo$1.api.origin||e.origin===window.origin)switch(e.data.action){case "loaded":this.injectDefaultStyles(e),this.confirmReady(e);break;case "request":{this.handleRequest(e);break}case "scrollHeight":this.setiFrameHeight(e),this.uiLoaded.set(true);break;case "config.get":{this.requestResponse(e,this.getConfigBlocks());break}case "config.save":{this.savePluginConfig().then(n=>{n?this.requestResponse(e,this.getConfigBlocks()):this.requestResponse(e,{message:this.$translate.instant("config.failed_to_save_config")},false);});break}case "config.update":{this.handleUpdateConfig(e,e.data.pluginConfig);break}case "config.schema":{this.requestResponse(e,this.schema);break}case "cachedAccessories.get":{this.handleGetCachedAccessories(e);break}case "cachedMatterAccessories.get":{this.handleGetCachedMatterAccessories(e);break}case "schema.show":{this.formEnd(),this.showSchemaForm.set(true);break}case "schema.hide":{this.showSchemaForm.set(false);break}case "form.create":{this.showSchemaForm.set(false),this.formCreate(e.data.formId,e.data.schema,e.data.data,e.data.submitButton,e.data.cancelButton);break}case "form.end":{this.formEnd();break}case "user.lightingMode":{this.requestResponse(e,this.$settings.actualLightingMode);break}case "i18n.lang":{this.requestResponse(e,this.$translate.getCurrentLang());break}case "i18n.translations":{let n;try{n=Jn(`../../../../i18n/${this.$translate.getCurrentLang()}.json`);}catch(t){n=s$1();}this.requestResponse(e,n);break}case "close":{this.$activeModal.close();break}case "toast.success":this.$toastr.success(e.data.message,e.data.title);break;case "toast.error":this.$toastr.error(e.data.message,e.data.title);break;case "toast.warning":this.$toastr.warning(e.data.message,e.data.title);break;case "toast.info":this.$toastr.info(e.data.message,e.data.title);break;case "spinner.show":this.pluginSpinner.set(true);break;case "spinner.hide":this.pluginSpinner.set(false);break;case "button.save.disabled":this.saveButtonDisabled.set(true);break;case "button.save.enabled":this.saveButtonDisabled.set(false);break}};confirmReady(e){e.source.postMessage({action:"ready"},e.origin);}setiFrameHeight(e){this.iframe.style.height=`${e.data.scrollHeight+10}px`;}handleRequest(e){this.io.socket.emit("request",e.data);}handleUpdateConfig(e,n){if(!Array.isArray(n))return this.$toastr.error(this.$translate.instant("plugins.config.must_be_array"),this.$translate.instant("toast.title_error")),this.requestResponse(e,{message:this.$translate.instant("plugins.config.must_be_array")},false);for(let t of n)if(typeof t!="object"||Array.isArray(t))return this.$toastr.error(this.$translate.instant("plugins.config.must_be_array_objects"),this.$translate.instant("toast.title_error")),this.requestResponse(e,{message:this.$translate.instant("plugins.config.must_be_array_objects")},false);return this.updateConfigBlocks(n),this.pluginConfig[0]&&this.showSchemaForm()&&(this.pluginConfig[0]=w({},this.pluginConfig[0]),this.schemaFormRefreshSubject.next(void 0)),this.requestResponse(e,this.getConfigBlocks())}requestResponse(e,n,t=true){e.source.postMessage({action:"response",requestId:e.data.requestId,success:t,data:n},e.origin);}injectDefaultStyles(e){return E(this,null,function*(){let n=[...window.document.body.classList].find(v=>v.startsWith("config-ui-x-")),t=window.document.body.classList.contains("dark-mode"),a=e.source;a.postMessage({action:"body-class",class:n},e.origin),a.postMessage({action:"body-class",class:"modal-content"},e.origin),t&&a.postMessage({action:"body-class",class:"dark-mode"},e.origin);let m=[...document.querySelectorAll("link")];for(let v of m)if(v.getAttribute("rel")==="stylesheet"){let T=v.getAttribute("href"),L=document.baseURI+(T.startsWith("/")?T.substring(1):T);a.postMessage({action:"link-element",href:L,rel:"stylesheet"},e.origin);}let u=[...document.querySelectorAll("style")];for(let v of u)a.postMessage({action:"inline-style",style:v.innerHTML},e.origin);let h=` body { height: unset !important; background-color: ${t?"#242424":"#FFFFFF"} !important; color: ${t?"#FFFFFF":"#000000"} !important; } `;a.postMessage({action:"inline-style",style:h},e.origin);})}getConfigBlocks(){return this.pluginConfig}updateConfigBlocks(e){for(let n=0;n<e.length;n++){let t=e[n];t[this.pluginType()]=this.pluginAlias(),this.pluginConfig[n]?Object.assign(this.pluginConfig[n],t):this.pluginConfig[n]=t;}this.pluginConfig.length>e.length&&(this.pluginConfig.length=e.length);}schemaFormUpdated(){if(!(!this.iframe||!this.iframe.contentWindow)){if(this.schemaFormRecentlyRefreshed){this.schemaFormRecentlyRefreshed=false;return}this.iframe.contentWindow.postMessage({action:"stream",event:"configChanged",data:this.pluginConfig},Eo$1.api.origin);}}schemaFormRefresh(){this.schemaFormRecentlyRefreshed=true,this.showSchemaForm()&&(this.showSchemaForm.set(false),queueMicrotask(()=>{this.showSchemaForm.set(true);}));}formCreate(e,n,t,a,m){return E(this,null,function*(){yield this.formEnd(),this.formId.set(e),this.formSchema.set(n),this.formData.set(t),this.formSubmitButtonLabel.set(a),this.formCancelButtonLabel.set(m);})}formEnd(){return E(this,null,function*(){this.formId()&&(this.formId.set(void 0),this.formSchema.set(void 0),this.formData.set(void 0),this.formSubmitButtonLabel.set(void 0),this.formCancelButtonLabel.set(void 0),yield new Promise(e=>setTimeout(e)));})}formUpdated(e){this.iframe.contentWindow.postMessage({action:"stream",event:this.formId(),data:{formEvent:"change",formData:e}},Eo$1.api.origin);}formActionEvent(e){this.iframe.contentWindow.postMessage({action:"stream",event:this.formId(),data:{formEvent:e,formData:this.formData()}},Eo$1.api.origin);}handleGetCachedAccessories(e){return E(this,null,function*(){let n=this.plugin;if(n)try{let t=yield this.$accessoryCache.getHap();return this.requestResponse(e,t.filter(a=>a.plugin===n.name))}catch(t){console.error("Failed to get cached accessories:",t),this.$toastr.error(this.$translate.instant("toast.title_error"));}})}handleGetCachedMatterAccessories(e){return E(this,null,function*(){let n=this.plugin;if(n)try{let t=yield this.$accessoryCache.getMatter();return this.requestResponse(e,t.filter(a=>a.plugin===n.name))}catch(t){console.error("Failed to get cached Matter accessories:",t),this.$toastr.error(this.$translate.instant("toast.title_error"));}})}static \u0275fac=function(n){return new(n||i)};static \u0275cmp=Ja$1({type:i,selectors:[["app-custom-plugins"]],viewQuery:function(n,t){n&1&&Ey(t.customPluginUiElementTarget,Xn,5),n&2&&ST();},decls:26,vars:22,consts:[["custompluginui",""],[1,"modal-content"],[1,"modal-header"],[1,"modal-title"],["type","button","data-bs-dismiss","modal",1,"btn-close",3,"click","disabled"],[1,"modal-body","pb-0","modal-body-min-height"],[1,"text-center","primary-text","my-5","w-100"],["width","100%","height","1px;","sandbox","allow-same-origin allow-scripts allow-popups allow-popups-to-escape-sandbox allow-downloads allow-forms",1,"plugin-iframe"],[1,"card","card-body"],[1,"loading-overlay","text-center","primary-text","d-flex","align-items-center","justify-content-center"],[1,"modal-footer","justify-content-between"],[1,"text-start"],["type","button","data-bs-dismiss","modal",1,"btn","btn-elegant",3,"click","disabled"],[1,"text-center"],[1,"text-end","d-flex","align-items-center","justify-content-end"],["container","modal","placement","top","triggers","hover",1,"fas","fa-xl","me-2",3,"fa-circle-check","green-text","fa-circle-exclamation","red-text","orange-text","ngbTooltip","openDelay"],["type","button","data-bs-dismiss","modal",1,"btn","btn-primary",3,"click","disabled"],[1,"fas","fa-circle-notch","fa-spin"],[1,"fas","fa-circle-notch","fa-spin","icon-xl"],[3,"dataChange","dataChanged","isValid","configSchema","data"],[1,"text-end","custom-form-action-buttons"],["type","button",1,"btn","btn-elegant"],["type","button",1,"btn","btn-primary",3,"disabled"],["type","button",1,"btn","btn-elegant",3,"click"],["type","button",1,"btn","btn-primary",3,"click","disabled"],["container","modal","placement","top","triggers","hover",1,"fas","fa-xl","me-2",3,"ngbTooltip","openDelay"]],template:function(n,t){n&1&&(La$1(0,"div",1)(1,"div",2)(2,"h5",3),At$1(3),Rd(),La$1(4,"button",4),f_(5,"translate"),rc("click",function(){return t.dismissModal()}),Rd()(),La$1(6,"div",5),Re(7,Qn,2,0,"div",6),dy(8,"iframe",7,0),f_(10,"translate"),f_(11,"translate"),Re(12,Yn,2,2,"div",8),Re(13,to,5,4,"div",8),Re(14,io,2,0,"div",9),Rd(),La$1(15,"div",10)(16,"div",11)(17,"button",12),rc("click",function(){return t.dismissModal()}),At$1(18),f_(19,"translate"),Rd()(),dy(20,"div",13),La$1(21,"div",14),Re(22,no,2,14,"i",15),La$1(23,"button",16),rc("click",function(){return t.savePluginConfig(true)}),Re(24,oo,2,3)(25,ao,1,0,"i",17),Rd()()()()),n&2&&(ie(3),Ny(t.plugin.displayName||t.plugin.name),ie(),ly("disabled",t.saveInProgress()),vr$1("aria-label",h_(5,14,"form.button_close")),ie(3),Oe(t.loading()?7:-1),ie(),vr$1("title",h_(10,16,"plugins.button_settings"))("aria-label",h_(11,18,"plugins.button_settings")),ie(4),Oe(t.uiLoaded()&&t.pluginConfig.length&&t.schema.singular&&t.showSchemaForm()?12:-1),ie(),Oe(t.formId()?13:-1),ie(),Oe(t.pluginSpinner()?14:-1),ie(3),ly("disabled",t.saveInProgress()),ie(),Rt(" ",h_(19,20,"form.button_close")," "),ie(4),Oe(t.saveButtonDisabled()?-1:22),ie(),ly("disabled",t.saveInProgress()||t.saveButtonDisabled()),ie(),Oe(t.saveInProgress()?25:24));},dependencies:[$t,Qk,Y$1,K8],styles:[".manage-plugin-config-external-icons[_ngcontent-%COMP%]{font-size:1.5rem;font-weight:700;line-height:1;color:#000;opacity:.5;background-color:transparent;border:0}.modal-body-min-height[_ngcontent-%COMP%]{min-height:110px}.plugin-iframe[_ngcontent-%COMP%]{border:0}.loading-overlay[_ngcontent-%COMP%]{position:absolute;inset:16px;background-color:#ffffffb3}.custom-form-action-buttons[_ngcontent-%COMP%] button[_ngcontent-%COMP%]:last-child{margin-right:2px}"]})}return i})();var Xi=(()=>{class i{injector=g(we);$api=g(I3);$modal=g(si);plugins={};openSettings(e,n,t){return E(this,null,function*(){let a=t?.config??(yield this.loadPluginConfig(e.name)),m=ty([{provide:_,useValue:{plugin:e,schema:n,pluginConfig:a,editorContext:t}}],this.injector);return this.$modal.open(this.plugins[e.name],{size:"lg",backdrop:"static",injector:m}).result.catch(()=>{})})}openCustomSettingsUi(e,n,t){return E(this,null,function*(){let a=t?.config??(yield this.loadPluginConfig(e.name)),m=ty([{provide:_,useValue:{plugin:e,schema:n,pluginConfig:a,editorContext:t}}],this.injector);return this.$modal.open(Ji,{size:"lg",backdrop:"static",injector:m}).result.catch(()=>{})})}loadPluginConfig(e){return E(this,null,function*(){return this.$api.get(`/config-editor/plugin/${encodeURIComponent(e)}`)})}static \u0275fac=function(n){return new(n||i)};static \u0275prov=C({token:i,factory:i.\u0275fac,providedIn:"root"})}return i})();var on=D$1(L$1());var Qi=D$1(Ri());function ro(i,c){i&1&&(La$1(0,"div",5),dy(1,"i",12),Rd());}function lo(i,c){if(i&1&&(dy(0,"i",20),La$1(1,"h6",21),At$1(2),f_(3,"translate"),Rd(),La$1(4,"p",21),At$1(5),f_(6,"translate"),La$1(7,"span",22),At$1(8),Rd()()),i&2){let e=ye(2);ie(2),Ny(h_(3,3,"plugins.manage.select_version")),ie(3),Rt(" ",h_(6,5,"plugins.status_installed"),": "),ie(3),Rt("v",e.plugin?.installedVersion);}}function so(i,c){i&1&&(dy(0,"i",23),La$1(1,"h6",21),At$1(2),f_(3,"translate"),Rd()),i&2&&(ie(2),Ny(h_(3,1,"plugins.manage.select_version")));}function co(i,c){i&1&&dy(0,"i",26);}function po(i,c){i&1&&dy(0,"i",27);}function mo(i,c){if(i&1){let e=nc();La$1(0,"li",14)(1,"span",8),At$1(2),dy(3,"br"),La$1(4,"small",24),At$1(5),Rd()(),La$1(6,"button",25),f_(7,"translate"),f_(8,"translate"),rc("click",function(){let t=Go$1(e).$implicit,a=ye(2);return Wo$1(a.doInstall(t.version))}),Re(9,co,1,0,"i",26)(10,po,1,0,"i",27),Rd()();}if(i&2){let e=c.$implicit,n=ye(2);ie(2),Rt(" ",e.tag," "),ie(3),Rt("v",e.version),ie(),vr$1("aria-label",`${n.plugin?.installedVersion===e.version?h_(7,4,"plugins.manage.reinstall"):h_(8,6,"plugins.manage.install")} v${e.version}`),ie(3),Oe(n.plugin?.installedVersion===e.version?9:10);}}function go(i,c){i&1&&At$1(0," \u2713 ");}function uo(i,c){if(i&1&&(La$1(0,"option",17),At$1(1),Re(2,go,1,0),Rd()),i&2){let e=c.$implicit,n=ye(2);ly("value",e.version)("selected",n.versionSelect===e.version),ie(),Rt(" v",e.version," "),ie(),Oe(e.version===n.plugin?.installedVersion?2:-1);}}function _o(i,c){i&1&&dy(0,"i",26);}function fo(i,c){i&1&&dy(0,"i",27);}function ho(i,c){if(i&1){let e=nc();La$1(0,"button",25),f_(1,"translate"),f_(2,"translate"),rc("click",function(){Go$1(e);let t=ye(2);return Wo$1(t.doInstall(t.versionSelect))}),Re(3,_o,1,0,"i",26)(4,fo,1,0,"i",27),Rd();}if(i&2){let e=ye(2);vr$1("aria-label",`${e.plugin?.installedVersion===e.versionSelect?h_(1,2,"plugins.manage.reinstall"):h_(2,4,"plugins.manage.install")} v${e.versionSelect}`),ie(3),Oe(e.plugin?.installedVersion===e.versionSelect?3:4);}}function bo(i,c){i&1&&(La$1(0,"div",36),dy(1,"i",41),Rd());}function Co(i,c){i&1&&(La$1(0,"div",36),dy(1,"i",41),Rd());}function xo(i,c){i&1&&(La$1(0,"div",36),dy(1,"i",41),Rd());}function vo(i,c){if(i&1&&(La$1(0,"li",28)(1,"label",29),dy(2,"input",42),f_(3,"translate"),KC(),La$1(4,"div",31),dy(5,"i",43),Rd(),La$1(6,"div",33)(7,"div",34),At$1(8),f_(9,"translate"),Rd(),La$1(10,"small",35),At$1(11),f_(12,"translate"),Rd()(),Re(13,xo,2,0,"div",36),Rd()()),i&2){let e=ye(3);ie(2),ly("formControl",e.updatePreferenceControl),vr$1("aria-label",h_(3,9,"plugins.manage.notifications_major")),JC(),ie(3),Cy("primary-text",e.updatePreferenceControl.value==="major")("grey-text",e.updatePreferenceControl.value!=="major"),ie(3),Ny(h_(9,11,"plugins.manage.notifications_major")),ie(3),Ny(h_(12,13,"plugins.manage.notifications_major_desc")),ie(2),Oe(e.updatePreferenceControl.value==="major"?13:-1);}}function yo(i,c){i&1&&(La$1(0,"div",36),dy(1,"i",41),Rd());}function Bo(i,c){if(i&1&&(La$1(0,"ul",19),f_(1,"translate"),La$1(2,"li",28)(3,"label",29),dy(4,"input",30),f_(5,"translate"),KC(),La$1(6,"div",31),dy(7,"i",32),Rd(),La$1(8,"div",33)(9,"div",34),At$1(10),f_(11,"translate"),Rd(),La$1(12,"small",35),At$1(13),f_(14,"translate"),Rd()(),Re(15,bo,2,0,"div",36),Rd()(),La$1(16,"li",28)(17,"label",29),dy(18,"input",37),f_(19,"translate"),KC(),La$1(20,"div",31),dy(21,"i",38),Rd(),La$1(22,"div",33)(23,"div",34),At$1(24),f_(25,"translate"),Rd(),La$1(26,"small",35),At$1(27),f_(28,"translate"),Rd()(),Re(29,Co,2,0,"div",36),Rd()(),Re(30,vo,14,15,"li",28),La$1(31,"li",28)(32,"label",29),dy(33,"input",39),f_(34,"translate"),KC(),La$1(35,"div",31),dy(36,"i",40),Rd(),La$1(37,"div",33)(38,"div",34),At$1(39),f_(40,"translate"),Rd(),La$1(41,"small",35),At$1(42),f_(43,"translate"),Rd()(),Re(44,yo,2,0,"div",36),Rd()()()),i&2){let e=ye(2);vr$1("aria-label",h_(1,29,"plugins.manage.notifications")),ie(4),ly("formControl",e.updatePreferenceControl),vr$1("aria-label",h_(5,31,"plugins.manage.notifications_all")),JC(),ie(3),Cy("primary-text",e.updatePreferenceControl.value==="all")("grey-text",e.updatePreferenceControl.value!=="all"),ie(3),Ny(h_(11,33,"plugins.manage.notifications_all")),ie(3),Ny(h_(14,35,"plugins.manage.notifications_all_desc")),ie(2),Oe(e.updatePreferenceControl.value==="all"?15:-1),ie(3),ly("formControl",e.updatePreferenceControl),vr$1("aria-label",h_(19,37,"plugins.manage.notifications_beta")),JC(),ie(3),Cy("primary-text",e.updatePreferenceControl.value==="beta")("grey-text",e.updatePreferenceControl.value!=="beta"),ie(3),Ny(h_(25,39,"plugins.manage.notifications_beta")),ie(3),Ny(h_(28,41,"plugins.manage.notifications_beta_desc")),ie(2),Oe(e.updatePreferenceControl.value==="beta"?29:-1),ie(),Oe(e.plugin.name==="homebridge"||e.plugin.name==="homebridge-config-ui-x"?30:-1),ie(3),ly("formControl",e.updatePreferenceControl),vr$1("aria-label",h_(34,43,"plugins.manage.notifications_none")),JC(),ie(3),Cy("primary-text",e.updatePreferenceControl.value==="none")("grey-text",e.updatePreferenceControl.value!=="none"),ie(3),Ny(h_(40,45,"plugins.manage.notifications_none")),ie(3),Ny(h_(43,47,"plugins.manage.notifications_none_desc")),ie(2),Oe(e.updatePreferenceControl.value==="none"?44:-1);}}function So(i,c){if(i&1){let e=nc();La$1(0,"div",6),Re(1,lo,9,7)(2,so,4,3),La$1(3,"ul",13),dT(4,mo,11,8,"li",14,lT),La$1(6,"li",14)(7,"div",15),At$1(8),f_(9,"translate"),dy(10,"br"),La$1(11,"select",16),f_(12,"translate"),Fy("ngModelChange",function(t){Go$1(e);let a=ye();return t_(a.versionSelect,t)||(a.versionSelect=t),Wo$1(t)}),dT(13,uo,3,4,"option",17,lT),Rd(),KC(),Rd(),Re(15,ho,5,6,"button",18),Rd()(),Re(16,Bo,45,49,"ul",19),Rd();}if(i&2){let e=ye();ie(),Oe(e.plugin?.installedVersion?1:2),ie(3),fT(e.versionsWithTags()),ie(4),Rt(" ",h_(9,6,"plugins.manage.all_versions")," "),ie(3),ky("ngModel",e.versionSelect),vr$1("aria-label",h_(12,8,"plugins.manage.all_versions")),JC(),ie(2),fT(e.versions()),ie(2),Oe(e.versionSelect?15:-1),ie(),Oe(e.plugin?.installedVersion?16:-1);}}var At=(()=>{class i{$activeModal=g(fe);$api=g(I3);$pluginsCache=g(We);$settings=g(zt$1);$toastr=g(M0);$translate=g(bf);modalData=g(l);destroyRef=g(ne);plugin=this.modalData.plugin;onRefreshPluginList=this.modalData.onRefreshPluginList;onSettingsChange=this.modalData.onSettingsChange;_versionSelect=W("");loading=W(true);versions=W([]);versionsWithTags=W([]);get versionSelect(){return this._versionSelect()}set versionSelect(e){this._versionSelect.set(e);}updatePreferenceControl=new Se("all");ngOnInit(){let e=this.plugin;if(!e)return;this.versionSelect=e.installedVersion||e.latestVersion,this.lookupVersions();let n=this.getCurrentUpdatePreference();this.updatePreferenceControl.setValue(n),this.updatePreferenceControl.valueChanges.pipe(Hf(500),An(this.destroyRef)).subscribe(t=>{t!==null&&this.updatePreference(t);});}doInstall(e){let n=this.plugin;if(!n)return;let t=this.versions().find(a=>a.version===e);this.$activeModal.close({name:n.name,version:e,engines:t?.engines,action:n.installedVersion?"alternate":"install"});}getCurrentUpdatePreference(){let e=this.plugin;return e?e.name==="homebridge"?this.$settings.env.homebridgeUpdatePolicy||"all":e.name==="homebridge-config-ui-x"?this.$settings.env.homebridgeUiUpdatePolicy||"all":this.$settings.env.plugins?.hideUpdatesFor?.includes(e.name)?"none":this.$settings.env.plugins?.showBetasFor?.includes(e.name)?"beta":"all":"all"}updatePreference(e){return E(this,null,function*(){let n=this.plugin;if(n)try{if(n.name==="homebridge")yield this.$api.patch("/config-editor/ui",{homebridgeUpdatePolicy:e}),this.$settings.env.homebridgeUpdatePolicy=e,yield this.$api.post("/plugins/clear-cache",{});else if(n.name==="homebridge-config-ui-x")yield this.$api.patch("/config-editor/ui",{homebridgeUiUpdatePolicy:e}),this.$settings.env.homebridgeUiUpdatePolicy=e,yield this.$api.post("/plugins/clear-cache",{});else {let m=e==="none",u=e==="beta",h=this.$settings.env.plugins?.hideUpdatesFor||[];m&&!h.includes(n.name)?h=[...h,n.name].sort((T,L)=>T.localeCompare(L)):m||(h=h.filter(T=>T!==n.name));let v=this.$settings.env.plugins?.showBetasFor||[];u&&!v.includes(n.name)?v=[...v,n.name].sort((T,L)=>T.localeCompare(L)):u||(v=v.filter(T=>T!==n.name)),yield this.$api.put("/config-editor/ui/plugins/hide-updates-for",{body:h}),yield this.$api.patch("/config-editor/ui",{"plugins.showBetasFor":v}),this.$settings.setEnvItem("plugins.hideUpdatesFor",h),this.$settings.setEnvItem("plugins.showBetasFor",v),yield this.$api.post("/plugins/clear-cache",{});}this.$pluginsCache.invalidate();let t=this.onRefreshPluginList;t&&t();let a=this.onSettingsChange;a&&a(),this.$toastr.success(this.$translate.instant("config.config_saved"),this.$translate.instant("toast.title_success"));}catch(t){console.error(t);let a=t instanceof Error?t.message:this.$translate.instant("toast.title_error");this.$toastr.error(a,this.$translate.instant("toast.title_error")),this.updatePreferenceControl.setValue(this.getCurrentUpdatePreference(),{emitEvent:false});}})}dismissModal(){this.$activeModal.dismiss("Dismiss");}lookupVersions(){return E(this,null,function*(){let e=this.plugin;if(e)try{let n=yield this.$api.get(`/plugins/lookup/${encodeURIComponent(e.name)}/versions`),t=[],a=[];for(let[u,h]of Object.entries(n.versions))t.push({version:u,engines:h.engines||null}),Object.keys(n.tags).filter(v=>n.tags[v]===u).forEach(v=>{a.push({version:u,tag:v});});let m=this.plugin;m?.installedVersion&&!t.some(u=>u.version===m.installedVersion)&&t.push({version:m.installedVersion,engines:m.engines||null}),t.sort((u,h)=>(0,Qi.rcompare)(u.version,h.version)),a.sort((u,h)=>{let v=["latest","next","beta","alpha"],T=v.includes(u.tag)?v.indexOf(u.tag):999,L=v.includes(h.tag)?v.indexOf(h.tag):999;return T-L}),this.versions.set(t),this.versionsWithTags.set(a),!t.some(u=>u.version===this.versionSelect)&&n.tags.latest&&(this.versionSelect=n.tags.latest),this.loading.set(!1);}catch(n){console.error(n);let t=n instanceof Error?n.error?.message||n.message:this.$translate.instant("toast.title_error");this.$toastr.error(t,this.$translate.instant("toast.title_error")),this.$activeModal.dismiss();}})}static \u0275fac=function(n){return new(n||i)};static \u0275cmp=Ja$1({type:i,selectors:[["app-manage-version"]],decls:16,vars:8,consts:[[1,"modal-content"],[1,"modal-header"],[1,"modal-title"],["type","button","data-bs-dismiss","modal",1,"btn-close",3,"click"],[1,"modal-body","d-flex","flex-row","flex-grow-1","w-100"],[1,"w-100","text-center","primary-text","my-5","w-100"],[1,"w-100","text-center"],[1,"modal-footer","justify-content-between"],[1,"text-start"],[1,"text-center"],["type","button","data-bs-dismiss","modal",1,"btn","btn-elegant",3,"click"],[1,"text-end"],[1,"fas","fa-circle-notch","fa-spin","icon-xl"],[1,"list-group","list-group-box","mb-0"],[1,"list-group-item","d-flex","justify-content-between","align-items-center"],[1,"text-start","min-w-50"],[1,"custom-select","w-100","font-monospace","version-select",3,"ngModelChange","ngModel"],[3,"value","selected"],["type","button",1,"btn","btn-primary","m-0","ms-3","py-1"],["role","radiogroup",1,"list-group","list-group-box","mt-3","mb-0"],[1,"fas","fa-code-compare","primary-text","mb-3","icon-xl"],[1,"mb-3"],[1,"font-monospace"],[1,"far","fa-arrow-alt-circle-down","primary-text","mb-3","icon-xl"],[1,"grey-text","font-monospace"],["type","button",1,"btn","btn-primary","m-0","ms-3","py-1",3,"click"],[1,"fas","fa-rotate-right"],[1,"fas","fa-arrow-alt-circle-down"],[1,"list-group-item","text-start"],[1,"d-flex","align-items-center","w-100","mb-0","cursor-pointer"],["type","radio","name","updatePreference","value","all",1,"visually-hidden",3,"formControl"],[1,"me-3"],["aria-hidden","true",1,"fas","fa-bell","fa-2x"],[1,"flex-grow-1"],["aria-hidden","true"],[1,"grey-text"],[1,"ms-3"],["type","radio","name","updatePreference","value","beta",1,"visually-hidden",3,"formControl"],["aria-hidden","true",1,"fas","fa-vial","fa-2x"],["type","radio","name","updatePreference","value","none",1,"visually-hidden",3,"formControl"],["aria-hidden","true",1,"fas","fa-bell-slash","fa-2x"],["aria-hidden","true",1,"fas","fa-xl","fa-check-circle","primary-text"],["type","radio","name","updatePreference","value","major",1,"visually-hidden",3,"formControl"],["aria-hidden","true",1,"far","fa-bell","fa-2x"]],template:function(n,t){n&1&&(La$1(0,"div",0)(1,"div",1)(2,"h5",2),At$1(3),Rd(),La$1(4,"button",3),f_(5,"translate"),rc("click",function(){return t.dismissModal()}),Rd()(),La$1(6,"div",4),Re(7,ro,2,0,"div",5)(8,So,17,10,"div",6),Rd(),La$1(9,"div",7),dy(10,"div",8),La$1(11,"div",9)(12,"button",10),rc("click",function(){return t.dismissModal()}),At$1(13),f_(14,"translate"),Rd()(),dy(15,"div",11),Rd()()),n&2&&(ie(3),Ny(t.plugin?.displayName||t.plugin?.name),ie(),vr$1("aria-label",h_(5,4,"form.button_close")),ie(3),Oe(t.loading()?7:8),ie(6),Rt(" ",h_(14,6,"form.button_close")," "));},dependencies:[Kn$1,Xn$1,Yn$1,Ye,Vt,fn$1,Hn,ln$1,Jn$1,mn$1,K8],styles:[".version-select[_ngcontent-%COMP%]{font-size:.875rem}"]})}return i})();var Zi=D$1(L$1());var ko=["pluginlogoutput"];function wo(i,c){if(i&1){let e=nc();La$1(0,"button",15),f_(1,"translate"),f_(2,"translate"),rc("click",function(){Go$1(e);let t=ye();return Wo$1(t.restartChildBridges())}),dy(3,"i",16),Rd();}if(i&2){let e=ye();ly("ngbTooltip",h_(1,4,e.childBridges.length>1?"child_bridge.restart_plural":"child_bridge.restart"))("openDelay",150)("disabled",e.midAction()),vr$1("aria-label",h_(2,6,e.childBridges.length>1?"child_bridge.restart_plural":"child_bridge.restart"));}}var Yi=/\x1B\[(\d{1,3}(;\d{1,2})?)?[mGK]/g,Eo=/36m\[.*?\]/,en=(()=>{class i{$activeModal=g(fe);$api=g(I3);$log=g(Z);$modal=g(si);$toastr=g(M0);$translate=g(bf);$settings=g(zt$1);injector=g(we);modalData=g(M);termTarget=BH("pluginlogoutput");plugin=this.modalData.plugin;childBridges=this.modalData.childBridges??[];editorContext=this.modalData.editorContext;midAction=W(false);resizeEvent=new $$1;pluginAlias;get isLightTerminalTheme(){return this.$settings.getEffectiveTerminalLightingMode()==="light"}ngOnInit(){this.getPluginLog();}ngOnDestroy(){this.$log.destroyTerminal();}onWindowResize(){this.resizeEvent.next(void 0);}patchXtermLiveRegion(){let e=this.termTarget()?.nativeElement;if(!e)return;let n=e.querySelector("[aria-live]");n&&(n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),n.setAttribute("aria-atomic","true"));}restartChildBridges(){return E(this,null,function*(){this.midAction.set(true);try{for(let e of this.childBridges)yield this.$api.put(`/server/restart/${e.username}`,{});this.$toastr.success(this.$translate.instant("plugins.manage.child_bridge_restart"),this.$translate.instant("toast.title_success")),this.midAction.set(!1);}catch(e){console.error(e),this.$toastr.error(this.$translate.instant("plugins.manage.child_bridge_restart_failed"),this.$translate.instant("toast.title_error")),this.midAction.set(false);}})}downloadLogFile(){return E(this,null,function*(){this.midAction.set(true);let e=ty([{provide:A,useValue:{title:this.$translate.instant("logs.title_download_log_file"),message:this.$translate.instant("logs.download_warning"),confirmButtonLabel:this.$translate.instant("form.button_download"),faIconClass:"fas fa-user-secret primary-text"}}],this.injector),n=this.$modal.open(O$2,{size:"lg",backdrop:"static",injector:e});try{yield n.result;try{let t=yield this.$api.get("/platform-tools/hb-service/log/download?colour=yes",{observe:"response",responseType:"text"});if(!t.body)return;let a=t.body.split(` `),m="",u=!1;a.forEach(h=>{if(h){if(u)if(Eo.test(h))u=!1;else {m+=`${h.replace(Yi,"")}\r `;return}h.includes(`36m[${this.pluginAlias}]`)&&(m+=`${h.replace(Yi,"")}\r `,u=!0);}}),this.plugin&&(0,Zi.saveAs)(new Blob([m],{type:"text/plain;charset=utf-8"}),`${this.plugin.name}.log.txt`),this.midAction.set(!1);}catch(t){let a;try{t instanceof Nn&&t.error?.text&&(a=JSON.parse(yield t.error.text()).message);}catch(m){console.error(m);}this.$toastr.error(a||this.$translate.instant("logs.download.error"),this.$translate.instant("toast.title_error")),this.