import{q as l}from"./scene.17037962789732.js";import{u as p}from"./scene.1703796278973.js";const s=(t,n)=>new Promise(i=>{const r=n.branches.filter(c=>!!c);l({...n,branches:r},t).then(c=>{c.success&&i(c.result)})}),E="device_rules",P=t=>{const n=`branches_${t.branch}`,i=`then_${t.branchGroup}`,r=`then_${t.action}`;return`${n}_${i}_${r}`},T=t=>{var r,c;const n=p();let i=[];t.action===0&&i.push(E);for(let u=0;u<=t.action-1;u++){let o=(c=(r=n.data.branches)==null?void 0:r[t.branch].then[t.branchGroup].actions[u])==null?void 0:c.key;if(!o){const f=`branches_${t.branch}`,h=`then_${t.branchGroup}`,b=`then_${u}`;o=`${f}_${h}_${b}`}i.push(o)}return i},I={list:{},subscribe:function(t,n){const i=this.list;return t.forEach(r=>{(i[r]||(i[r]=[])).push(n)}),this},emit:function(t,n){const i=this.list,r=i[t]?[...i[t]]:[];return r.length?(r.forEach(c=>{c(n)}),this):!1},unSubscribe:function(t,n){const i=this.list;return t.forEach(r=>{if(r in i){const c=i[r];for(let u=0;u<c.length;u++)if(c[u]===n){c.splice(u,1);break}}}),this}},R=(t,n)=>{var c,u;const i=(t==null?void 0:t.properties)||[],r=(t==null?void 0:t.functions)||[];if((n==null?void 0:n.messageType)==="READ_PROPERTY"&&((c=n==null?void 0:n.properties)!=null&&c[0])){const o=i.find(f=>{var h;return f.id===((h=n==null?void 0:n.properties)==null?void 0:h[0])});return o==null?void 0:o.id}else if((n==null?void 0:n.messageType)==="INVOKE_FUNCTION"&&(n!=null&&n.functionId)){const o=r.find(f=>f.id===(n==null?void 0:n.functionId));return o==null?void 0:o.id}else if((n==null?void 0:n.messageType)==="WRITE_PROPERTY"){const o=(u=Object.keys(n==null?void 0:n.properties))==null?void 0:u[0];if(o){const f=i.find(h=>h.id===o);return f==null?void 0:f.id}return!1}return!1};export{E as D,I as E,P as a,T as b,s as g,R as i};
