"use strict";var A=Object.defineProperty;var y=(a,e,t)=>e in a?A(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var l=(a,e,t)=>y(a,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("lodash"),m=require("./actions/pageAction.js"),h=require("./actions/linkAction.js"),x=require("./actions/moveAction.js"),g=require("./actions/sendApiAction.js"),q=require("./actions/scaleAction.js"),E=require("./actions/rotateAction.js"),S=require("./actions/updatePageAction.js"),b=require("./actions/invokeAction.js"),M=require("./actions/fullScreenAction.js"),k=require("./actions/updateVariableAction.js"),w=require("./actions/updateWidgetAction.js"),P=require("./actions/ueCommonsWebscoketAction.js"),W=require("./actions/ueShjExecMethodAction.js"),v=require("./actions/unityWebglExecMethodAction.js"),C=require("./actions/unityIframeExecMethodAction.js"),U=require("./actions/vrSceneMethodAction.js");class p{static addAction(e,t){this.actions.add({type:e,parser:t})}static getAction(e){const t=Array.from(this.actions).find(i=>i.type===e);return t==null?void 0:t.parser}static parseEvents(e,t,i){e!=null&&e.length&&e.forEach((r,d)=>{r.eventType===t&&setTimeout(()=>{const u=new CustomEvent("event-params-log",{detail:{eventId:r.id,params:i}});window.dispatchEvent(u);const s=this.filterEvent(r,i);if(!this.conditionLogic(r,s)||!r.actions)return;const c=this.getAction(r.actions);c&&c(r,s)},r.delay+d*10)})}static filterEvent(e,t){let i=f.cloneDeep(t);if(e.filterCode)try{const r=`
                 ${e.filterCode}
     
                 // 在这里调用 filter 函数，并传递 data 参数
                 return filter(data);
             `;i=new Function("data",r)(t)}catch{}return i}static conditionLogic(e,t){var u,s;if(!((s=(u=e.condition)==null?void 0:u.list)!=null&&s.length))return!0;const i=c=>{if(c.type==="field"){if(!c.conditionName)return!1;const n=t[c.conditionName];if(n===void 0)return!1;const o=c.conditionValue;switch(c.conditionExpression){case"eq":return n.toString()===(o||"").toString();case"neq":return n!==o;case"lt":return n<Number(o);case"gt":return n>Number(o);case"lte":return n<=Number(o);case"gte":return n>=Number(o);case"includes":return n.includes(o);case"noincludes":return!n.includes(o);default:return!1}}if(c.type==="custom")try{const n=`
                        ${c.customValue}
                        return condition(data);
                    `;return new Function("data",n)(t)}catch{return!1}return!1},r=e.condition.list.map(i);return e.condition.type==="and"?r.every(Boolean):r.some(Boolean)}}l(p,"actions",new Set([{type:"page",parser:m.executePageAction},{type:"link",parser:h.executeLinkAction},{type:"sendApi",parser:g.executeSendApiAction},{type:"move",parser:x.executeMoveAction},{type:"scale",parser:q.executeScaleAction},{type:"rotate",parser:E.executeRotateAction},{type:"updatePage",parser:S.executeUpdatePageAction},{type:"invoke",parser:b.executeInvokeAction},{type:"fullscreen",parser:M.executeFullScreenAction},{type:"updateVariable",parser:k.executeUpdateVariableAction},{type:"updateWidget",parser:w.executeUpdateWidgetAction},{type:"ueCommonsWebscoket",parser:P.executeUeCommonsWebscoketAction},{type:"ueShjExecMethod",parser:W.executeUeShjExecMethodAction},{type:"unityWebglExecMethod",parser:v.executeUnityWebglExecMethodAction},{type:"unityIframeExecMethod",parser:C.executeUnityIframeExecMethodAction},{type:"vrSceneMethod",parser:U.executeVrSceneMethodAction}]));exports.SHJParseEvent=p;
