PageSourceSearch

https://fieldstudies.org/wp-content/plugins/bricksforge/assets/js/bricksforge_nodes_editor.js?ver=1789697562

js fieldstudies.org collected 2026-09-24 09:07:02 UTC 53,543 bytes, 1 lines download raw bytes

1var brfNodeEditor;class BricksforgeNodeEditor extends BricksforgePanel{nodes=[];dataFlow={};canvases=[];folders=[];structure=[];constructor(e){super(e,!0),this.domContentLoadedEvent=e,this.elementSelector=new ElementSelector(this.maxQueryNodes),this.templateVariables=new TemplateVariables,this.validator=new ValidationHelper(this.templateVariables),this.timelineManager=new TimelineManager(this),this.animationBuilder=new AnimationBuilder(this),this.actionDispatcher=new ActionDispatcher(this),this.instanceManager=new InstanceManager(this)}async handlePanelNodes(e){const t=e.nodes,n=e.connections;this.canvases=e.canvases||[],this.folders=e.folders||[],this.structure=await this.combineCanvasesAndFolders();const a=await this.prepareNodes(t,n);this.nodes=a;await this.prepareVariables(t,n);a.filter((e=>"event"==e.category)).forEach((e=>{this.shouldSkip(e.settings)||this.startNode(e,a,n)}))}async combineCanvasesAndFolders(){const e=this.canvases,t=this.folders,n=[];return e.forEach((e=>{n.push({...e})})),t.forEach((e=>{n.push({...e})})),n}async prepareNodes(e,t){return await Promise.all(e.map((async n=>{const a=n.settings?n.settings:{},i=this.findNodeEvent(n,e,t);i&&"event"!=n.category&&(n.event=i);const o=await this.getEventTriggerElement(n.event);let r,s=!1;o&&(r=o.target,s=o.queryAll);let c=a.target,l=a.targetElement,u=!1;const d=await this.getEventTargetElement(c,l,a,null,n);switch(d&&(l=d.target,u=d.queryAll),"document"!=a.targetElement&&"document"!=a.target||(l=document),"window"!=a.targetElement&&"window"!=a.target||(l=window),n.key){case"followCursor":{if(!!!a.forceHideWhenLeaves)break;const e=()=>{l&&NodeList.prototype.isPrototypeOf(l)?l.forEach((e=>{e&&(e.style.visibility="hidden")})):l&&(l.style.visibility="hidden")};s&&"object"==typeof r?r.forEach((t=>{t.addEventListener("mouseleave",e)})):r.addEventListener("mouseleave",e);break}}return n})))}async prepareVariables(){const e=this.nodes.filter((e=>"variable"===e.type));e&&0!=e.length&&e.forEach((e=>{const t=e.settings;if(!t)return;const n=t.variableName?t.variableName:t.id;let a=t.value?t.value:"";const i=t.variableType?t.variableType:"string";"number"===i&&(a=parseFloat(a)),"boolean"===i&&(a="true"===a),this.dataFlow[n]=a,window.bricksforgeData?.globalVariables&&(window.bricksforgeData.globalVariables[e.id]=a)}))}findNodeEvent(e,t,n){let a=new Set;const i=e=>{if(a.add(e.id),"event"==e.category)return e;let o=n.find((t=>t.toNode==e.id));if(!o)return e;let r=t.find((e=>e.id==o.fromNode));return r?"event"===r.category?r:a.has(r.id)?null:i(r):null};return i(e)}async startNode(e,t,n){if(!this.checkCanvasLoadingConditions(e))return;let a=n.find((t=>t.fromNode==e.id&&this._isExecutionConnection(t)));if(!a)return;let i=t.find((e=>e.id==a.toNode));if(!i)return;let o=e.key;this.currentRunningEvent=o;let r=e.settings?e.settings:{},s=(r.target,r.targetElement),c=!1;const l=await this.getEventTriggerElement(e);switch(l&&(s=l.target,c=l.queryAll),"document"!=r.targetElement&&"document"!=r.target||(s=document),"window"!=r.targetElement&&"window"!=r.target||(s=window),o){case"pageLoad":await this.runNode(i,t,n,"document",this.domContentLoadedEvent);break;case"scrollPosition":{const e=e=>{const a=window.scrollY,o=r.scrollPositionOperator||"==",s=parseInt(r.scrollPosition)||0;let c=!1;switch(o){case"==":c=a===s;break;case"!=":c=a!==s;break;case">":c=a>s;break;case">=":c=a>=s;break;case"<":c=a<s;break;case"<=":c=a<=s}c&&this.runNode(i,t,n,document,e)};window.addEventListener("scroll",e),(window.scrollY>0||r.scrollPosition&&0===parseInt(r.scrollPosition))&&e();break}case"scrollUp":{let e=0;const a=a=>{const o=window.scrollY;o<e&&this.runNode(i,t,n,document,a),e=o<=0?0:o};window.addEventListener("scroll",a),e=window.scrollY;break}case"scrollDown":{let e=0;const a=a=>{const o=window.scrollY;o>e&&this.runNode(i,t,n,document,a),e=o};window.addEventListener("scroll",a),e=window.scrollY;break}case"scroll":{const e=e=>{this.runNode(i,t,n,document,e)};window.addEventListener("scroll",e);break}case"visibilitychange":{const e=e=>{document.visibilityState===r.visibilityState&&this.runNode(i,t,n,document,e)};document.addEventListener("visibilitychange",e),e();break}case"resize":{const e=e=>{const{resizeDimension:a,resizeOperator:o,resizeValue:s}=r;if(!a||!o||!s)return void this.runNode(i,t,n,document,e);const c="width"===a?window.innerWidth:window.innerHeight;let l=!1;switch(o){case"==":l=c==s;break;case">":l=c>s;break;case"<":l=c<s;break;case">=":l=c>=s;break;case"<=":l=c<=s}l&&this.runNode(i,t,n,document,e)};window.addEventListener("resize",e);break}case"mousemove":if(c){if(!s)return;
1s.forEach((e=>{e.addEventListener("mousemove",(async a=>{await this.runNode(i,t,n,e,a)}))}))}else s.addEventListener("mousemove",(async e=>{await this.runNode(i,t,n,s,e)}));case"resizeObserver":if(!s)return;new ResizeObserver((async e=>{for(let a of e)await this.runNode(i,t,n,a.target,a)})).observe(s);break;case"mutationObserver":{if(!s)return;const e={attributes:r.mutationObserverAttributes||!1,childList:r.mutationObserverChildList||!1,characterData:r.mutationObserverCharacterData||!1,subtree:r.mutationObserverSubtree||!1},a=new MutationObserver((async e=>{for(let a of e)await this.runNode(i,t,n,a.target,a)}));c?s.forEach((t=>{a.observe(t,e)})):a.observe(s,e);break}case"inViewport":case"notInViewport":{const e=new IntersectionObserver((async e=>{e.forEach((async e=>{("inViewport"===o&&e.isIntersecting||"notInViewport"===o&&!e.isIntersecting)&&await this.runNode(i,t,n,e.target,e)}))}),r.observerOptions);if(!s)return;c?s.forEach((t=>e.observe(t))):e.observe(s);break}case"sliderReady":case"sliderMove":case"sliderMoved":case"sliderVisible":case"sliderHidden":case"sliderClick":case"sliderResize":case"sliderResized":case"sliderDrag":case"sliderDragging":case"sliderDragged":case"sliderOverflow":{if(!r.sliderId)break;if(r.sliderId.startsWith("#brxe-")&&(r.sliderId=r.sliderId.replace("#brxe-","")),r.sliderId.includes(".")||r.sliderId.includes("#")){const e=document.querySelector(r.sliderId);if(!e){console.warn(`Slider element not found for selector: ${r.sliderId}`);break}r.sliderId=e.getAttribute("data-script-id")}const e=await this.handleSliderEvent(r.sliderId);if(e){const a=e.state.is(Splide.STATES.IDLE);"sliderReady"==o&&a&&await this.runNode(i,t,n,e.root,null),e.on(o.replace("slider","").toLowerCase(),(async a=>{await this.runNode(i,t,n,e.root,a)}))}break}case"wpgbFacetInit":case"wpgbFacetLoaded":case"wpgbFacetAppended":case"wpgbFacetRefresh":case"wpgbFacetChange":case"wpgbFacetReset":"undefined"!=typeof WP_Grid_Builder&&WP_Grid_Builder.instances&&Object.values(WP_Grid_Builder.instances).forEach((e=>{e.facets&&e.facets.on(o.replace("wpgbFacet","").toLowerCase(),(async a=>{await this.runNode(i,t,n,e.facets,a)}))}));break;case"submit":if(r.submitState||(r.submitState="success"),!s)break;c?s.forEach((e=>{e.addEventListener("brf_submit",(async a=>{const o=a.detail.success;(o||"success"!==r.submitState)&&(o&&"error"===r.submitState||await this.runNode(i,t,n,e,a))}))})):s.addEventListener("brf_submit",(async e=>{const a=e.detail.success;(a||"success"!==r.submitState)&&(a&&"error"===r.submitState||await this.runNode(i,t,n,s,e))}));break;case"custom":if(!r.customEventName)break;if(!s)break;c?s.forEach((e=>{e.addEventListener(r.customEventName,(async a=>{await this.runNode(i,t,n,e,a)}))})):s.addEventListener(r.customEventName,(async e=>{await this.runNode(i,t,n,s,e)}));break;default:if(!s)break;c?s.forEach((e=>{e.addEventListener(o,(async a=>{await this.runNode(i,t,n,e,a)}))})):s.addEventListener(o,(async e=>{await this.runNode(i,t,n,s,e)}))}}async getEventTriggerElement(e){if(!e)return;let t=!1,n=e.settings?e.settings:{},a=n.target,i=n.targetElement;switch(a){case"exactly":default:i=document.querySelector(i);break;case"all":i=document.querySelectorAll(i),t=!0;break;case"siblings":const e=document.querySelector(i);e&&e.parentNode?(i=e.parentNode.children,t=!0):i=null;break;case"parent":const a=document.querySelector(i);i=a&&a.parentNode?a.parentNode:null;break;case"children":const o=document.querySelector(selector);o?(i=o.children,t=!0):i=null;break;case"closest":if(!n.closestValue)break;const r=document.querySelector(i);i=r?r.closest(n.closestValue):null}return{target:i,queryAll:t}}async getEventTargetElement(e,t,n,a,i){let o=!1,r=n.targetElement;const s=i.event?i.event:null;let c=s&&s.settings?s.settings.targetElement:null;switch(e){case"same":if(!t||!a||!a.target)break;r=a.target;break;case"triggered":r="triggered";break;case"all":if(!t)break;r=document.querySelectorAll(c),o=!0;break;case"siblings":if(!(t&&a&&a.target&&a.target.parentNode))break;r=a.target.parentNode.children,o=!0;break;case"parent":if(!(t&&a&&a.target&&a.target.parentNode))break;r=a.target.parentNode;break;case"children":if(!t||!a||!a.target)break;r=a.target.children,o=!0;break;case"closest":if(!t||!a||!a.target)break;r=a.target.closest(r);break;case"querySelector":if(!t||!a||!a.target)break;const e=a.target.closest(c);r=e?e.querySelector(r):null;break;
1case"custom":r=document.querySelector(r);break;case"customAll":r=document.querySelectorAll(r),o=!0;break;case"window":r=window;break;default:if(!t)break;r=document.querySelector(c)}return{target:r,queryAll:o}}getConnectedOutputPin(e,t,n){const a=n.find((t=>t.to===e||t.from===e||null));if(!a)return null;const i=a.to===e?a.fromNode:a.toNode,o=t.find((e=>e.id===i));if(!o)return null;const r=o.outputs.find((e=>e.id===a.from||e.id===a.to));return r||null}getConnectedInputPin(e,t,n){const a=n.find((t=>t.from===e||t.to===e||null));if(!a)return null;const i=t.find((e=>e.id===a.fromNode||e.id===a.toNode));if(!i)return null;const o=i.inputs.find((e=>e.id===a.from||e.id===a.to));return o||null}async parsePinData(e,t={}){if(!e)return null;const n=await this.isPinVariable(e.id),a=n;if(n&&(this.dataFlow?.[a]||window.bricksforgeData.globalVariables?.[a]))return this.dataFlow?.[a]||window.bricksforgeData.globalVariables?.[a];if(!e.executeString)return null;const i=t.event,o=new Function("return "+e.executeString)();return o?o(i):null}async _collectNodeDataForInputs(e,t,n,a){const i={};let o=e.inputs;if(!o||0==o.length)return{};for(let e of o){const o=e.id,r=this.getConnectedOutputPin(o,t,n);if(!r)continue;const s=r,c=await this.parsePinData(s,{event:a});void 0!==c&&(i[o]=c,this.dataFlow[o]=c)}return i}async _collectNodeDataForOutputs(e,t,n,a,i){const o=t.data.outputs,r=t.outputs[0].id;o&&r&&(o[r]=e,this.dataFlow[r]=e)}async organizeNodeControls(e,t,n){const a=e.controls;if(!a||0==a.length)return a;for(let e of a){const a=e.controlPinId?e.controlPinId:e.id,i=this.getConnectedOutputPin(a,t,n);if(!i)continue;const o=i;e.connectedPin=o}return a}getVariableNodes(){return this.nodes.filter((e=>"variable"===e.type))}async isPinVariable(e){const t=this.getVariableNodes();if(!t||0==t.length)return!1;for(let n of t)if(n.outputs.find((t=>e&&e.id&&t.id===e.id||e==t.id)))return n.settings.variableName;return!1}async getVariableNameFromPinId(e){const t=this.getVariableNodes();if(!t||0==t.length)return null;for(let n of t)if(n.outputs.find((t=>t.id===e)))return n.settings.variableName}async updateSettingsWithDataFlow(e){if(!e.settings)return e.settings;if(!e.controls)return e.settings;for(let t of e.controls){await this.isPinVariable(t.connectedPin)||t.connectedPin&&this.dataFlow[t.connectedPin.id]&&(e.settings[t.key]=this.dataFlow[t.connectedPin.id])}return e.settings}async runNode(e,t,n,a,i){if("event"===e.category)return;this.checkCanvasLoadingConditions(e);let o=e.key;const r=e.settings?{...e.settings}:{};let s={...r};try{s=await this.resolvePinData(e,t,n,s,i)}catch(e){console.error("Error resolving pin data:",e)}try{s=await this.resolveNodeVariables(e,t,n,s)}catch(e){}if(this.dataFlow)for(const[e,t]of Object.entries(s))this.dataFlow.hasOwnProperty(e)&&(s[e]=this.dataFlow[e]);e.controls&&(e.controls=await this.organizeNodeControls(e,t,n)),s=await this.updateSettingsWithDataFlow({...e,settings:s});let c,l;JSON.stringify(r).includes("{{")&&(s=this.parseJavaScriptExpressionsInSettings(r,{node:e,nodes:t,connections:n,triggerSelector:a,event:i,data:e.data})),e.data={inputs:{},outputs:{}},e.data.inputs=await this._collectNodeDataForInputs(e,t,n,i);!!s.exceptTriggered&&s.exceptTriggered;if(s.target){const t=this.getTargetElement(s.target,s.targetElement,a,e,i);t&&(c=t[0],l=t[1])}if(e.execute)try{const o=new Function("return "+e.execute)(),r=await o.call(this,{node:e,nodes:t,connections:n,triggerSelector:a,event:i,settings:s,target:c,queryAll:l,data:e.data});r&&this._collectNodeDataForOutputs(r,e,t,n,i)}catch(e){console.error("Error executing custom node function:",e)}switch(o){case"branch":{let o=null,r=e.inputs.find((e=>"condition"==e.key));r&&(o=r.id);let s=await this.getOppositePins(r,n);if(!s||0==s.length)return void console.error("No conditions found for condition node");let c=s[0],l=await this.getNodeFromPin(c,t);if(await this.handleNodeCondition(l,t,n)){let o=e.executionPins.true.id,r=await this.getOppositePins(o,n);if(!r||0==r.length)return;let s=r[0],c=await this.getNodeFromPin(s,t);if(!c)return;await this.runNode(c,t,n,a,i)}else{let o=e.executionPins.false.id,r=await this.getOppositePins(o,n);if(!r||0==r.length)return;let s=r[0],c=await this.getNodeFromPin(s,t);if(!c)return;await this.runNode(c,t,n,a,i)}return}case"show":this.fireAction({action:"show",selector:a,instance:e,actionData:s,event:i,actionDataRaw:null,isNode:!0});break;case"hide":this.fireAction({action:"hide",selector:a,instance:e,actionData:s,event:i,actionDataRaw:null,isNode:!0});break;case"addClass":this.fireAction({action:"addClass",selector:a,instance:e,actionData:s,event:i,actionDataRaw:null,isNode:!0});break;case"removeClass":this.fireAction({action:"removeClass",selector:a,instance:e,actionData:s,event:i,actionDataRaw:null,isNode:!0});break;case"toggleClass":this.fireAction({action:"toggleClass",selector:a,instance:e,actionData:e.settings,event:i,actionDataRaw:null,isNode:!0});break;case"setAttribute":this.fireAction({action:"setAttribute",selector:a,instance:e,actionData:s,event:i,actionDataRaw:null,isNode:!0});break;case"removeAttribute":this.fireAction({action:"removeAttribute",selector:a,instance:e,actionData:e.settings,event:i,actionDataRaw:null,isNode:!0});break;case"innerText":this.fireAction({action:"innerText",selector:a,instance:e,actionData:s,event:i,actionDataRaw:null,isNode:!0});break;case"gsap":{if(!s.timelineAction||!s.timeline)return;"pageLoad"==this.currentRunningEvent&&await this.wait(0);let e=s.timelineAction,t=s.timeline,n=null!=s.timescale?s.timescale:1,a=!!s.playOnlyTriggeredElement&&s.playOnlyTriggeredElement,o=[];o=this.timelines.filter((e=>e.id==t)),a&&(o=o.filter((e=>{let t=[...i.target.getElementsByTagName("*")].includes(e.trigger),n=e.trigger.contains(i.target);return e.trigger==i.target||t||n})));const r=o.map((async t=>{let a=t.tl;if(1!=n&&a.timeScale(n),this.currentRunningEvent.includes("wpgb")){let e=a.getChildren();return a.clear(),e.forEach((e=>{let t=e.vars,n=(e.delay(),e.data.method),i=e._start,o=e.data.selector;switch(n){case"to":t.autoAlpha=1,a.to(o,{...t},i);break;case"from":t.autoAlpha=0,a.from(o,{...t},i);break;case"fromTo":t.autoAlpha=1,a.fromTo(o,{...t.startAt},{...t},i)}})),a.restart(),new Promise((e=>{a.eventCallback("onComplete",e)}))}return new Promise((async t=>{switch(a.eventCallback("onComplete",t),e){case"play":await a.play(),t();break;case"pause":await a.pause(),t();break;case"restart":await a.restart(),t();break;case"resume":await a.resume(),t();break;case"reverse":await a.reverse(),t();break;default:t()}}))}));await Promise.all(r);break}case"gsapFlip":this.fireAction({action:"gsapFlip",selector:a,instance:e,actionData:s,event:i,actionDataRaw:null,isNode:!0});break;case"gsapSet":this.fireAction({action:"gsapSet",selector:a,instance:e,actionData:s,event:i,actionDataRaw:null,isNode:!0});break;case"gsapFrom":this.fireAction({action:"gsapFrom",selector:a,instance:e,actionData:s,event:i,actionDataRaw:null,isNode:!0});break;case"gsapTo":this.fireAction({action:"gsapTo",selector:a,instance:e,actionData:s,event:i,actionDataRaw:null,isNode:!0});break;case"followCursor":this.fireAction({action:"followCursor",selector:a,instance:e,actionData:e.settings,event:i,actionDataRaw:null,isNode:!0});break;case"video_self_hosted_play":this.fireAction({action:"video_self_hosted_play",selector:a,instance:e,actionData:s,event:i,actionDataRaw:null,isNode:!0});break;case"video_self_hosted_pause":this.fireAction({action:"video_self_hosted_pause",selector:a,instance:e,actionData:s,event:i,actionDataRaw:null,isNode:!0});break;case"video_self_hosted_stop":this.fireAction({action:"video_self_hosted_stop",selector:a,instance:e,actionData:s,event:i,actionDataRaw:null,isNode:!0});break;case"storageSetItem":this.fireAction({action:"storageSetItem",selector:a,instance:e,actionData:s,event:i,actionDataRaw:null,isNode:!0});break;case"storageRemoveItem":this.fireAction({action:"storageRemoveItem",selector:a,instance:e,actionData:s,event:i,actionDataRaw:null,isNode:!0});break;case"sessionStorageSetItem":this.fireAction({action:"sessionStorageSetItem",selector:a,instance:e,actionData:s,event:i,actionDataRaw:null,isNode:!0});break;case"sessionStorageRemoveItem":this.fireAction({action:"sessionStorageRemoveItem",selector:a,instance:e,actionData:e.settings,event:i,actionDataRaw:null,isNode:!0});break;case"previousSlide":this.fireAction({action:"previousSlide",selector:a,instance:e,actionData:s,event:i,actionDataRaw:null,isNode:!0});break;case"nextSlide":this.fireAction({action:"nextSlide",selector:a,instance:e,actionData:s,event:i,actionDataRaw:null,isNode:!0});break;
1case"syncSliders":this.fireAction({action:"syncSliders",selector:a,instance:e,actionData:s,event:i,actionDataRaw:null,isNode:!0});break;case"openPopup":this.fireAction({action:"openPopup",selector:a,instance:e,actionData:s,event:i,actionDataRaw:null,isNode:!0});break;case"closePopup":this.fireAction({action:"closePopup",selector:a,instance:e,actionData:e.settings,event:i,actionDataRaw:null,isNode:!0});break;case"populateFormField":this.fireAction({action:"populateFormField",selector:a,instance:e,actionData:s,event:i,actionDataRaw:null,isNode:!0});break;case"jsFunction":{if(!e.settings?.jsFunctionName)return;let t=e.settings.jsFunctionName,n=new Function("return (async (trigger, event, timelines, getTimeline, dataFlow) => {"+t+"})")();if("function"==typeof n){const e=await this.getTimelines();let t=async e=>await this.getTimelineById(e);await n(a,i,e,t,this.dataFlow)}break}case"ajaxFunction":this.fireAction({action:"ajaxFunction",selector:a,instance:e,actionData:s,event:i,actionDataRaw:null,isNode:!0});break;case"sendEmail":this.fireAction({action:"sendEmail",selector:a,instance:e,actionData:s,event:i,actionDataRaw:null,isNode:!0});break;case"updateOption":this.fireAction({action:"updateOption",selector:a,instance:e,actionData:s,event:i,actionDataRaw:null,isNode:!0});break;case"deleteOption":this.fireAction({action:"deleteOption",selector:a,instance:e,actionData:s,event:i,actionDataRaw:null,isNode:!0});break;case"makeConfetti":this.fireAction({action:"makeConfetti",selector:a,instance:e,actionData:s,event:this.domContentLoadedEvent,actionDataRaw:null,isNode:!0});break;case"updateGlobalVariable":{let e=s?.variableName,t=s?.variableValue;if(!e||!s?.hasOwnProperty("variableValue"))break;e=this.handleTemplateVars(e,{event:i}),t=this.handleTemplateVars(t,{event:i}),window.bricksforgeData?.globalVariables||(window.bricksforgeData.globalVariables={}),window.bricksforgeData.globalVariables[e]=t,this.dataFlow[e]=t;break}}this.checkForNextNode(e,t,n,a,i)}async checkForNextNode(e,t,n,a,i){let o=n.find((t=>t.fromNode==e.id&&this._isExecutionConnection(t)));if(!o)return;let r=t.find((e=>e.id==o.toNode));r&&await this.runNode(r,t,n,a,i)}async handleNodeCondition(e,t,n){let a=e.key,i=!1,o=e.settings?{...e.settings}:{};try{o=await this.resolvePinData(e,t,n,o,null)}catch(e){console.error("Error resolving pin data for condition node:",e)}try{o=await this.resolveNodeVariables(e,t,n,o)}catch(e){console.error("Error resolving node variables for condition node:",e)}if(this.dataFlow)for(const[e,t]of Object.entries(o))this.dataFlow.hasOwnProperty(e)&&(o[e]=this.dataFlow[e]);if(o=await this.updateSettingsWithDataFlow({...e,settings:o}),o=this.parseJavaScriptExpressionsInSettings(o,{node:e,nodes:t,connections:n,triggerSelector:null,event:null,data:e.data||{inputs:{},outputs:{}}}),!0===e.ready&&e.execute)try{const a=new Function("return "+e.execute)(),r=await a.call(this,{node:e,nodes:t,connections:n,settings:o,triggerSelector:null,event:null,target:null,queryAll:null,data:e.data||{inputs:{},outputs:{}}});return i=Boolean(r),i}catch(t){return console.error(`Error executing condition node "${e.key}":`,t),i=!1,i}switch(a){case"conditionGroup":{const a=o?.relation||"and",r=(e.id,e.inputs||[]);if(!r.length){i=!1;break}let s=[];for(let e of r){if(!await this.getNodeFromPin(e.id,t))continue;const a=await this.getOppositePins(e.id,n);if(!a.length)continue;const i=await this.getNodeFromPin(a[0],t);if(i){const e=await this.handleNodeCondition(i,t,n);s.push(e)}}i="and"===a?s.every((e=>!0===e)):s.some((e=>!0===e));break}case"localStorageItemExists":case"sessionStorageItemExists":{let r=this.processConditionSetting(o?.name,e,t,n);if(!r){i=!1;break}("localStorageItemExists"==a?localStorage.getItem(r):sessionStorage.getItem(r))&&(i=!0);break}case"localStorageItemValueIs":case"sessionStorageItemValueIs":{let r=this.processConditionSetting(o?.name,e,t,n),s=this.processConditionSetting(o?.value,e,t,n),c=o?.operator?o.operator:"equalTo";if(!r||!s){i=!1;break}let l="localStorageItemValueIs"==a?localStorage.getItem(r):sessionStorage.getItem(r);i=this.compareDefaultOperators(l,s,c);break}case"localStorageItemValueIncludes":case"sessionStorageItemValueIncludes":{let r=this.processConditionSetting(o?.name,e,t,n),s=this.processConditionSetting(o?.value,e,t,n),c=o?.operator?o.operator:"exact";if(!r||!s){i=!1;break}let l="localStorageItemValueIncludes"==a?localStorage.getItem(r):sessionStorage.getItem(r);switch(c){case"exact":l&&l==s&&(i=!0);break;case"contains":l&&l.includes(s)&&(i=!0)}break}case"cookieExists":{let a=this.processConditionSetting(o?.name,e,t,n);if(!a){i=!1;break}document.cookie.split("; ").find((e=>e.startsWith(a)))&&(i=!0);break}case"cookieValueIs":{let a=this.processConditionSetting(o?.name,e,t,n),r=this.processConditionSetting(o?.value,e,t,n),s=o?.operator?o.operator:"equalTo";if(!a||!r){i=!1;break}let c=document.cookie.split("; ").find((e=>e.split("=")[1]==r));i=this.compareDefaultOperators(c,r,s);break}case"cookieValueIncludes":{let a=this.processConditionSetting(o?.name,e,t,n),r=this.processConditionSetting(o?.value,e,t,n);if(!a||!r){i=!1;break}document.cookie.split("; ").find((e=>e.split("=")[1].includes(r)))&&(i=!0);break}case"urlIncludes":{let a=this.processConditionSetting(o?.value,e,t,n),r=o?.operator?o.operator:"contains";if(!a){i=!1;break}let s=window.location.href;switch(r){case"contains":s.includes(a)&&(i=!0);break;case"exact":s==a&&(i=!0)}break}case"queryParamExists":{let a=this.processConditionSetting(o?.name,e,t,n);if(!a){i=!1;break}new URLSearchParams(window.location.search).has(a)&&(i=!0);break}case"queryParamValueIs":{let a=this.processConditionSetting(o?.name,e,t,n),r=this.processConditionSetting(o?.value,e,t,n),s=o?.operator?o.operator:"equalTo";if(!a||!r){i=!1;break}let c=new URLSearchParams(window.location.search);if(c.has(a)){let e=c.get(a);i=this.compareDefaultOperators(e,r,s)}break}case"queryParamValueIncludes":{let a=this.processConditionSetting(o?.name,e,t,n),r=this.processConditionSetting(o?.value,e,t,n),s=o?.operator?o.operator:"contains";if(!a||!r){i=!1;break}let c=new URLSearchParams(window.location.search);if(c.has(a)){let e=c.get(a);switch(s){case"contains":e.includes(r)&&(i=!0);break;case"exact":e===r&&(i=!0)}}break}case"windowWidth":{let a=o?.operator?o?.operator:"greaterThan",r=this.processConditionSetting(o?.value,e,t,n);if(!r){i=!1;break}let s=window.innerWidth;switch(a){case"greaterThan":s>r&&(i=!0);break;case"lessThan":s<r&&(i=!0);break;case"equalTo":s==r&&(i=!0)}break}case"windowHeight":{let a=o?.operator?o?.operator:"greaterThan",r=this.processConditionSetting(o?.value,e,t,n);if(!r){i=!1;break}let s=window.innerHeight;switch(a){case"greaterThan":s>r&&(i=!0);break;case"lessThan":s<r&&(i=!0);break;case"equalTo":s==r&&(i=!0)}break}case"elementExists":{let a=this.processConditionSetting(o?.selector,e,t,n);if(!a){i=!1;break}try{document.querySelector(a)&&(i=!0)}catch(e){i=!1}break}case"elementIsVisible":{let a=this.processConditionSetting(o?.selector,e,t,n);if(!a){i=!1;break}try{let e=document.querySelector(a);if(!e){i=!1;break}let t=e.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight,o=window.innerWidth||document.documentElement.clientWidth,r=t.top<=n&&t.top+t.height>=0,s=t.left<=o&&t.left+t.width>=0,c="none"!==window.getComputedStyle(e).display;i=r&&s&&c}catch(e){i=!1}break}case"elementHasClass":{let a=this.processConditionSetting(o?.selector,e,t,n),r=this.processConditionSetting(o?.class,e,t,n);if(!a||!r){i=!1;break}try{let e=document.querySelector(a);if(!e){i=!1;break}e.className.includes(r)&&(i=!0)}catch(e){i=!1}break}case"elementHasAttribute":{let a=this.processConditionSetting(o?.selector,e,t,n),r=this.processConditionSetting(o?.attribute,e,t,n);if(!a||!r){i=!1;break}try{let e=document.querySelector(a);if(!e){i=!1;break}e.getAttribute(r)&&(i=!0)}catch(e){i=!1}break}case"elementAttributeIs":{let a=this.processConditionSetting(o?.selector,e,t,n),r=this.processConditionSetting(o?.attribute,e,t,n),s=this.processConditionSetting(o?.value,e,t,n),c=o?.operator?o.operator:"equalTo";if(!a||!r||!s){i=!1;break}try{let e=document.querySelector(a);if(!e){i=!1;break}let t=e.getAttribute(r);i=this.compareDefaultOperators(t,s,c)}catch(e){i=!1}break}case"elementAttributeIncludes":{let a=this.processConditionSetting(o?.selector,e,t,n),r=this.processConditionSetting(o?.attribute,e,t,n),s=this.processConditionSetting(o?.value,e,t,n),c=o?.operator?o.operator:"exact";if(!a||!r||!s){i=!1;break}try{let e=document.querySelector(a);if(!e){i=!1;break}let t=e.getAttribute(r);if(!t){i=!1;break}switch(c){case"exact":i=t===s;break;case"contains":i=t.includes(s);break;default:i=!1}}catch(e){i=!1}break}case"globalVariableExists":{let a=this.processConditionSetting(o?.name,e,t,n);if(!a){i=!1;break}window.bricksforgeData?.globalVariables?.[a]&&(i=!0);break}case"globalVariableIs":{let a=this.processConditionSetting(o?.name,e,t,n),r=this.processConditionSetting(o?.value,e,t,n),s=o?.operator?o.operator:"equalTo";if(!a||!r){i=!1;break}i=this.compareDefaultOperators(window.bricksforgeData?.globalVariables?.[a],r,s);break}case"globalVariableValueIncludes":{let a=this.processConditionSetting(o?.name,e,t,n),r=this.processConditionSetting(o?.value,e,t,n);if(!a||!r){i=!1;break}window.bricksforgeData?.globalVariables?.[a]?.includes(r)&&(i=!0);break}}return i}processConditionSetting(e,t,n,a){return"string"!=typeof e?e:this.handleJavaScriptExpressions(e,{node:t,nodes:n,connections:a,triggerSelector:null,event:null,data:t.data||{inputs:{},outputs:{}}})}
1compareDefaultOperators(e,t,n){let a=!1;const i=e=>parseFloat(e);switch(n){case"equalTo":a=e==t;break;case"greaterThan":a=i(e)>i(t);break;case"lessThan":a=i(e)<i(t);break;case"greaterThanOrEqualTo":a=i(e)>=i(t);break;case"lessThanOrEqualTo":a=i(e)<=i(t)}return a}async getOppositePins(e,t){let n=[],a="string"==typeof e?e:e.id;return t.filter((e=>e.from==a||e.to==a)).forEach((e=>{e.from==a?n.push(e.to):n.push(e.from)})),n}async getNodeFromPin(e,t){return t.find((t=>t.inputs&&t.inputs.find((t=>t.id==e))||t.outputs&&t.outputs.find((t=>t.id==e))||t.executionPins&&t.executionPins.in&&t.executionPins.in.id==e||t.executionPins&&t.executionPins.out&&t.executionPins.out.id==e||t.executionPins&&t.executionPins.true&&t.executionPins.true.id==e||t.executionPins&&t.executionPins.false&&t.executionPins.false.id==e))}async resolveNodeVariables(e,t,n,a){const i=n.filter((e=>e.isVariable));return 0===i.length||await Promise.all(i.map((async t=>{try{if(t.variableOppositeNode?.id==e.id){const n=t.variableNode;if(!n)return;const i=n.settings;if(!i)return;i.variableKey=t.variableKey;const o=i.variableName,r=i.variableKey;if(!r)return;if("updateGlobalVariable"===e.key&&"variableName"===r)a[r]=o;else{const e=await this.getGlobalVariableValue(o,i.value);null!=e&&(a[r]=e)}}}catch(e){console.error("Error processing variable connection:",e)}}))),a}getDataConnections(e){return e.filter((e=>e.from.includes("data-input")||e.to.includes("data-input")))}getDataConnectionsFromNode(e,t){return e.filter((e=>e.fromNode==t.id||e.toNode==t.id))}getDataKeyFromConnection(e){return e.from.includes("data-input")?e.from.split("-").pop():e.to.includes("data-input")?e.to.split("-").pop():null}async parseDataFromOutputKey(e,t=null){if(!e)return null;const n=t.event,a=t.dataNode;if(!a||!a.outputs)return null;const i=a.outputs.find((t=>t.key==e));if(!i||!i.executeString)return null;try{const e=new Function("return "+i.executeString)();if(!e||"function"!=typeof e)return null;const t=e(n);return await Promise.resolve(t)}catch(e){return console.error("Error executing parseDataFromOutputKey:",e),null}}async resolvePinData(e,t,n,a,i){let o=this.getDataConnections(n);const r=this.getDataConnectionsFromNode(o,e);return 0===r.length||await Promise.all(r.map((async n=>{try{let o=null;if(n.fromNode==e.id?o=t.find((e=>e.id==n.toNode)):n.toNode==e.id&&(o=t.find((e=>e.id==n.fromNode))),!o)return;const r=o.outputs;if(!r)return;const s=r.find((e=>e.id==n.from||e.id==n.to));if(!s)return;const c=s.key,l=this.getDataKeyFromConnection(n);if(!l)return;const u=await this.parseDataFromOutputKey(c,{event:i,dataNode:o});null!=u&&(a[l]=u)}catch(e){console.error("Error processing connection:",e)}}))),a}async getGlobalVariableValue(e,t){return await new Promise((e=>setTimeout(e,0))),this.dataFlow&&this.dataFlow.hasOwnProperty(e)?this.dataFlow[e]:window.bricksforgeData?.globalVariables?.hasOwnProperty(e)?window.bricksforgeData.globalVariables[e]:t}async findPinData(e,t,n,a={},i=new Set,o=10){if(o<=0)return console.warn("findPinData: Maximum recursion depth reached"),null;const r="string"==typeof e?e:e?.id;if(!r)return null;if(i.has(r))return null;i.add(r);try{const e=await this._findNodeByPin(r,t);if(!e)return null;const s=this._findPinInNode(r,e);if(!s)return null;let c=null;switch(s.type){case"output":c=await this._resolveOutputPin(s,e,t,n,a,i,o-1);break;case"input":c=await this._resolveInputPin(s,e,t,n,a,i,o-1);break;case"execution":c=await this._resolveExecutionPin(s,e,t,n,a,i,o-1);break;default:c=await this._resolveGenericPin(s,e,t,n,a,i,o-1)}return c}catch(e){return console.error("findPinData error:",e),null}}async _findNodeByPin(e,t){return t.find((t=>t.inputs&&t.inputs.some((t=>t.id===e))||t.outputs&&t.outputs.some((t=>t.id===e))||t.executionPins&&Object.values(t.executionPins).some((t=>t?.id===e))))}_findPinInNode(e,t){if(t.inputs){const n=t.inputs.find((t=>t.id===e));if(n)return{...n,type:"input"}}if(t.outputs){const n=t.outputs.find((t=>t.id===e));if(n)return{...n,type:"output"}}if(t.executionPins)for(const[n,a]of Object.entries(t.executionPins))if(a?.id===e)return{...a,type:"execution",execType:n};return null}async _resolveOutputPin(e,t,n,a,i,o,r){if(e.executeString)try{const t=new Function("return "+e.executeString)();if(t&&"function"==typeof t)return t(i.event,i)}catch(e){console.error("Error executing pin function:",e)}switch(e.key){case"scrollDirection":return this._getScrollDirection(i.event);case"scrollPosition":return i.event?.scrollPosition||window.scrollY;case"elementValue":return this._getElementValue(t,i);case"globalVariable":return this._getGlobalVariableFromNode(t);default:return t.settings?.[e.key]||e.defaultValue||null}}async _resolveInputPin(e,t,n,a,i,o,r){const s=a.filter((t=>t.to===e.id));if(0===s.length)return t.settings?.[e.key]||e.defaultValue||null;const c=s[0].from;return await this.findPinData(c,n,a,i,o,r)}async _resolveExecutionPin(e,t,n,a,i,o,r){return{nodeId:t.id,nodeType:t.key,execType:e.execType,timestamp:Date.now()}}async _resolveGenericPin(e,t,n,a,i,o,r){const s=a.some((t=>t.to===e.id)),c=a.some((t=>t.from===e.id));return s&&!c?await this._resolveInputPin(e,t,n,a,i,o,r):!s&&c?await this._resolveOutputPin(e,t,n,a,i,o,r):t.settings?.[e.key]||e.defaultValue||null}_getScrollDirection(e){if(!e)return null;const t=window.bricksforgeData?.panel;if(!t)return null;const n=t.lastScrollY||0,a=t.lastScrollX||0,i=window.scrollY,o=window.scrollX;return t.lastScrollY=i,t.lastScrollX=o,i>n?"down":i<n?"up":o>a?"right":o<a?"left":"none"}_getElementValue(e,t){const n=e.settings?.selector||e.settings?.target;if(!n)return null;const a=document.querySelector(n);return a?"INPUT"===a.tagName||"TEXTAREA"===a.tagName?a.value:"SELECT"===a.tagName?a.selectedOptions[0]?.value||null:a.textContent||a.innerText:null}_getGlobalVariableFromNode(e){const t=e.settings?.variableName;return t?this.getGlobalVariableValue(t,e.settings?.defaultValue):null}_getNestedValue(e,t){return t.split(".").reduce(((e,t)=>e?.[t]),e)}getConnectedNodesInOrder(e,t,n){if(!e||!t||!n)return[];const a=this._findAllConnectedNodes(e,t,n),i=t.filter((e=>a.has(e.id))),o=this._findRootNode(i,n);if(!o)return i;return this._buildExecutionOrder(o,i,n)}_findAllConnectedNodes(e,t,n){const a=new Set,i=[e];for(;i.length>0;){const e=i.shift();if(a.has(e))continue;a.add(e);n.filter((t=>
1t.fromNode===e||t.toNode===e)).forEach((t=>{const n=t.fromNode===e?t.toNode:t.fromNode;a.has(n)||i.push(n)}))}return a}_findRootNode(e,t){const n=e.find((e=>e.key&&(e.key.includes("Event")||"click"===e.key||"scroll"===e.key||"resize"===e.key||"load"===e.key||"hover"===e.key||"focus"===e.key||"submit"===e.key||e.key.startsWith("on")||this._isEventNode(e))));if(n)return n;for(const n of e){if(!t.some((e=>e.toNode===n.id&&this._isExecutionConnection(e,t))))return n}return e[0]||null}_isEventNode(e){if("event"===e.type)return!0;if("events"===e.category)return!0;if(e.executionPins&&e.executionPins.out&&!e.executionPins.in)return!0;const t=e.executionPins?.out,n=e.executionPins?.in;return t&&!n}_isExecutionConnection(e){return!e.from.includes("data-input")&&!e.to.includes("data-input")}_buildExecutionOrder(e,t,n){const a=[],i=new Set,o=[e];for(;o.length>0;){const e=o.shift();if(i.has(e.id))continue;i.add(e.id),a.push(e);this._getNextExecutionNodes(e,t,n).forEach((e=>{i.has(e.id)||o.push(e)}))}return t.forEach((e=>{i.has(e.id)||a.push(e)})),a}_getNextExecutionNodes(e,t,n){const a=[];if(n.filter((t=>t.fromNode===e.id&&this._isExecutionConnection(t))).forEach((e=>{const n=t.find((t=>t.id===e.toNode));n&&a.push(n)})),"branch"===e.key||"condition"===e.key){n.filter((t=>t.fromNode===e.id&&(t.from.includes("true")||t.from.includes("false")||t.from.includes("out")))).forEach((e=>{const n=t.find((t=>t.id===e.toNode));n&&!a.includes(n)&&a.push(n)}))}return a}visualizeConnectedFlow(e,t,n){const a=this.getConnectedNodesInOrder(e,t,n);if(0===a.length)return"No connected nodes found";const i=a.map(((e,t)=>{const n=e.key||"unknown";return`${t+1}. [${n}] ${e.label||e.name||n} (ID: ${e.id})`}));return`Connected Flow (${a.length} nodes):\n${i.join("\n")}`}getVariableConnectionsMapping(e,t,n=!1){if(!e||!t)return n?[]:{variableNodes:[],connectionsByVariable:{},connectionsByNode:{},allConnections:[],summary:{totalVariables:0,totalConnections:0,unconnectedVariables:0}};const a=e.filter((e=>"variable"===e.type||"variable"===e.key)),i=t.filter((e=>!0===e.isVariable));if(n){const e=[];return i.forEach((t=>{const n=t.variableNode.settings?.variableName||"Unnamed Variable",a=t.variableOppositeNode.key,i=t.variableKey,o=t.variableOppositeNode.title||a;e.push({variable:n,value:t.variableNode.settings?.value,type:t.variableNode.settings?.variableType,connectedTo:`${o}.${i}`,connectedToNodeId:t.variableOppositeNode.id,nodeKey:a,settingKey:i})})),e}const o={},r={},s=[];i.forEach((e=>{const t=e.variableNode,n=e.variableOppositeNode,a=e.variableKey,i=this._parseDataInputField(e.to),c={variable:{id:t.id,name:t.settings?.variableName||"Unnamed Variable",type:t.settings?.variableType||"unknown",value:t.settings?.value,node:t},connectedNode:{id:n.id,key:n.key,type:n.type,category:n.category,title:n.title||n.key,node:n},connection:{settingKey:a,connectionId:e.id,fromPin:e.from,toPin:e.to,dataType:e.type,parsedToField:i},rawConnection:e};s.push(c);const l=t.id;o[l]||(o[l]={variable:c.variable,connections:[]}),o[l].connections.push({connectedNode:c.connectedNode,connection:c.connection});const u=n.id;r[u]||(r[u]={node:c.connectedNode,variableInputs:[]}),r[u].variableInputs.push({variable:c.variable,connection:c.connection})}));const c=new Set(i.map((e=>e.variableNode.id))),l=a.filter((e=>!c.has(e.id))),u={totalVariables:a.length,totalConnections:i.length,unconnectedVariables:l.length,connectedVariables:c.size,nodesUsingVariables:Object.keys(r).length};return{variableNodes:a,connectionsByVariable:o,connectionsByNode:r,allConnections:s,unconnectedVariables:l,summary:u}}_parseDataInputField(e){if(!e||!e.startsWith("data-input-"))return{nodeId:null,settingKey:null,isValid:!1,original:e};const t=e.substring(11).split("-");if(t.length<2)return{nodeId:null,settingKey:null,isValid:!1,original:e};const n=t.pop();return{nodeId:t.join("-"),settingKey:n,isValid:!0,original:e}}getVariableConnections(e,t,n){const a=this.getVariableConnectionsMapping(t,n);for(const[t,n]of Object.entries(a.connectionsByVariable))if(t===e)return n;for(const[t,n]of Object.entries(a.connectionsByVariable))if(n.variable.name===e)return n;return null}getNodeVariableInputs(e,t,n){return this.getVariableConnectionsMapping(t,n).connectionsByNode[e]||null}summarizeVariableConnections(e,t){const n=this.getVariableConnectionsMapping(e,t);let a="=== Variable Connections Summary ===\n";return a+=`Total Variables: ${n.summary.totalVariables}\n`,a+=`Connected Variables: ${n.summary.connectedVariables}\n`,a+=`Unconnected Variables: ${n.summary.unconnectedVariables}\n`,a+=`Total Connections: ${n.summary.totalConnections}\n`,a+=`Nodes Using Variables: ${n.summary.nodesUsingVariables}\n\n`,n.allConnections.length>0&&(a+="=== Connection Details ===\n",n.allConnections.forEach(((e,t)=>{a+=`${t+1}. Variable "${e.variable.name}" (${e.variable.type}) → `,a+=`Node "${e.connectedNode.title}" (${e.connectedNode.key}) → `,a+=`Setting "${e.connection.settingKey}"\n`,a+=`   Value: ${JSON.stringify(e.variable.value)}\n`}))),n.unconnectedVariables.length>0&&(a+="\n=== Unconnected Variables ===\n",n.unconnectedVariables.forEac
1h(((e,t)=>{const n=e.settings?.variableName||"Unnamed",i=e.settings?.variableType||"unknown",o=e.settings?.value;a+=`${t+1}. "${n}" (${i}) = ${JSON.stringify(o)}\n`}))),a}getOutputPinConnectionsMapping(e,t,n=!1){if(!e||!t)return n?[]:{outputPinConnections:[],connectionsBySourceNode:{},connectionsByTargetNode:{},allConnections:[],summary:{totalConnections:0,sourceNodes:0,targetNodes:0}};const a=t.filter((e=>!1===e.isVariable));if(n){const t=[];return a.forEach((n=>{const a=this._parseDataInputField(n.to);if(!a)return;const i=e.find((e=>e.id===n.fromNode));if(!i)return;const o=i.outputs?.find((e=>e.id===n.from));if(!o)return;const r=e.find((e=>e.id===n.toNode));if(!r)return;const s=i.title||i.key,c=r.title||r.key;t.push({source:`${s}.${o.key}`,target:`${c}.${a.settingKey}`,sourceNodeId:i.id,sourceNodeKey:i.key,sourceOutputKey:o.key,sourceOutputName:o.name,sourceOutputType:o.type,targetNodeId:r.id,targetNodeKey:r.key,targetSettingKey:a.settingKey,connectionType:n.type})})),t}const i={},o={},r=[];a.forEach((t=>{const n=this._parseDataInputField(t.to);if(!n)return;const a=e.find((e=>e.id===t.fromNode));if(!a)return;const s=a.outputs?.find((e=>e.id===t.from));if(!s)return;const c=e.find((e=>e.id===t.toNode));if(!c)return;const l=c.controls?.find((e=>e.key===n.settingKey)),u={source:{node:{id:a.id,key:a.key,type:a.type,category:a.category,title:a.title||a.key,node:a},outputPin:{id:s.id,key:s.key,name:s.name,type:s.type,description:s.description,executeString:s.executeString,pin:s}},target:{node:{id:c.id,key:c.key,type:c.type,category:c.category,title:c.title||c.key,node:c},setting:{key:n.settingKey,nodeId:n.nodeId,control:l,currentValue:c.settings?.[n.settingKey]}},connection:{id:t.id,fromPin:t.from,toPin:t.to,dataType:t.type,parsedToField:n},rawConnection:t};r.push(u);const d=a.id;i[d]||(i[d]={node:u.source.node,outputConnections:[]}),i[d].outputConnections.push({outputPin:u.source.outputPin,target:u.target,connection:u.connection});const p=c.id;o[p]||(o[p]={node:u.target.node,inputConnections:[]}),o[p].inputConnections.push({source:u.source,setting:u.target.setting,connection:u.connection})}));const s={totalConnections:a.length,sourceNodes:Object.keys(i).length,targetNodes:Object.keys(o).length,nodesWithOutputs:Object.keys(i).length,nodesWithInputs:Object.keys(o).length};return{outputPinConnections:a,connectionsBySourceNode:i,connectionsByTargetNode:o,allConnections:r,summary:s}}getNodeOutputPinConnections(e,t,n,a="both"){const i=this.getOutputPinConnectionsMapping(t,n,!1),o=[];if("output"===a||"both"===a){const t=i.connectionsBySourceNode[e];t&&o.push(...t.outputConnections.map((e=>({direction:"output",...e}))))}if("input"===a||"both"===a){const t=i.connectionsByTargetNode[e];t&&o.push(...t.inputConnections.map((e=>({direction:"input",...e}))))}return o}summarizeOutputPinConnections(e,t){const n=this.getOutputPinConnectionsMapping(e,t,!0);if(0===n.length)return"No output pin connections found.";let a=`Found ${n.length} output pin connections:\n\n`;return n.forEach(((e,t)=>{a+=`${t+1}. ${e.source} → ${e.target}\n`,a+=`   Type: ${e.sourceOutputType} → ${e.connectionType?.to||"unknown"}\n`,e.sourceOutputName!==e.sourceOutputKey&&(a+=`   Output: "${e.sourceOutputName}"\n`),a+="\n"})),a}traceDataSourceChain(e,t,n,a,i=!1,o=new Set,r=10){if(r<=0)return console.warn("Maximum recursion depth reached in traceDataSourceChain"),i?[]:{chain:[],ultimateSource:null,error:"Max depth reached"};const s=`data-input-${e}-${t}`,c=a.find((e=>e.to===s&&!o.has(e.id)));if(!c)return i?[]:{chain:[],ultimateSource:null,targetNode:n.find((t=>t.id===e)),targetSetting:t,error:"No connection found"};o.add(c.id);const l=n.find((e=>e.id===c.fromNode));if(!l)return i?[]:{chain:[],ultimateSource:null,error:"Source node not found"};if(c.isVariable){const a=c.variableNode,o={stepType:"variable",source:{node:a,outputPin:null,variableName:a.settings?.variableName,variableValue:a.settings?.value,variableType:a.settings?.variableType},target:{node:n.find((t=>t.id===e)),settingKey:t},connection:c};return i?[{source:`Variable: ${a.settings?.variableName||"Unnamed"}`,target:`${n.find((t=>t.id===e))?.title||"Unknown"}.${t}`,sourceType:"variable",value:a.settings?.value,dataType:a.settings?.variableType}]:{chain:[o],ultimateSource:{type:"variable",node:a,variableName:a.settings?.variableName,value:a.settings?.value},targetNode:n.find((t=>t.id===e)),targetSetting:t,totalSteps:1}}let u=null;if(l.outputs&&(u=l.outputs.find((e=>e.id===c.from))),!u)return i?[]:{chain:[],ultimateSource:null,error:"Source output pin not found"};const d={stepType:"output_pin",source:{node:l,outputPin:u,outputKey:u.key,outputName:u.name,outputType:u.type},target:{node:n.find((t=>t.id===e)),settingKey:t},connection:c};let p=null;
1if(l.inputs&&l.inputs.length>0){const e=a.filter((e=>l.inputs.some((t=>t.id===e.to))&&!o.has(e.id)));if(e.length>0){const t=e[0],i=l.inputs.find((e=>e.id===t.to));i&&(p=this.traceInputPinDataSource(l.id,i.key,n,a,!1,new Set(o),r-1))}}if(!p){const e=a.filter((e=>e.toNode===l.id&&!o.has(e.id)));if(e.length>0){const t=e.find((e=>e.to&&e.to.includes(`data-input-${l.id}-`)));if(t){const e=this._parseDataInputField(t.to);e&&e.settingKey&&(p=this.traceDataSourceChain(l.id,e.settingKey,n,a,!1,new Set(o),r-1))}}}const g=[d];let f={type:"output_pin",node:l,outputPin:u};return p&&p.chain&&p.chain.length>0&&(g.unshift(...p.chain),f=p.ultimateSource),i?g.map(((e,t)=>{const n=t===g.length-1;return{step:t+1,source:"variable"===e.stepType?`Variable: ${e.source.variableName||"Unnamed"}`:`${e.source.node.title||e.source.node.key}.${e.source.outputKey}`,target:n?`${e.target.node.title||e.target.node.key}.${e.target.settingKey}`:`${g[t+1].source.node.title||g[t+1].source.node.key}.input`,sourceType:e.stepType,dataType:"variable"===e.stepType?e.source.variableType:e.source.outputType,value:"variable"===e.stepType?e.source.variableValue:void 0}})):{chain:g,ultimateSource:f,targetNode:n.find((t=>t.id===e)),targetSetting:t,totalSteps:g.length}}traceInputPinDataSource(e,t,n,a,i=!1,o=new Set,r=10){if(r<=0)return console.warn("Maximum recursion depth reached in traceInputPinDataSource"),i?[]:{chain:[],ultimateSource:null,error:"Max depth reached"};const s=n.find((t=>t.id===e));if(!s||!s.inputs)return i?[]:{chain:[],ultimateSource:null,error:"Target node or inputs not found"};const c=s.inputs.find((e=>e.key===t));if(!c)return i?[]:{chain:[],ultimateSource:null,error:"Input pin not found"};const l=a.find((e=>e.to===c.id&&!o.has(e.id)));if(!l)return i?[]:{chain:[],ultimateSource:null,error:"No connection to input pin found"};o.add(l.id);const u=n.find((e=>e.id===l.fromNode));if(!u)return i?[]:{chain:[],ultimateSource:null,error:"Source node not found"};let d=null;if(u.outputs&&(d=u.outputs.find((e=>e.id===l.from))),!d)return i?[]:{chain:[],ultimateSource:null,error:"Source output pin not found"};const p={stepType:"output_pin",source:{node:u,outputPin:d,outputKey:d.key,outputName:d.name,outputType:d.type},target:{node:s,settingKey:t,isInputPin:!0},connection:l};let g=null;if(u.inputs&&u.inputs.length>0){const e=a.filter((e=>u.inputs.some((t=>t.id===e.to))&&!o.has(e.id)));if(e.length>0){const t=e[0],i=u.inputs.find((e=>e.id===t.to));i&&(g=this.traceInputPinDataSource(u.id,i.key,n,a,!1,new Set(o),r-1))}}const f=[p];let h={type:"output_pin",node:u,outputPin:d};return g&&g.chain&&g.chain.length>0&&(f.unshift(...g.chain),h=g.ultimateSource),i?f.map(((e,t)=>{const n=t===f.length-1;return{step:t+1,source:`${e.source.node.title||e.source.node.key}.${e.source.outputKey}`,target:n?`${e.target.node.title||e.target.node.key}.${e.target.settingKey}`:`${f[t+1].source.node.title||f[t+1].source.node.key}.input`,sourceType:"output_pin",dataType:e.source.outputType,isInputPin:e.target.isInputPin||!1}})):{chain:f,ultimateSource:h,targetNode:s,targetSetting:t,totalSteps:f.length}}handleTemplateVars(e,t){if(void 0===e||null==e)return e;if("string"!=typeof e&&(e=e.toString()||""),!(e=this.handleJavaScriptExpressions(e,t)).includes("{"))return e;[{name:"{eventType}",value:t.event?t.event.type:""},{name:"{eventTarget}",value:t.event&&t.event.target?t.event.target.toString():""},{name:"{eventTimestamp}",value:t.event?t.event.timeStamp:""},{name:"{eventCharCode}",value:t.event&&"keypress"===t.event.type?t.event.charCode:""},{name:"{eventAltKey}",value:t.event?t.event.altKey:""},{name:"{eventCtrlKey}",value:t.event?t.event.ctrlKey:""},{name:"{eventShiftKey}",value:t.event?t.event.shiftKey:""},{name:"{eventRepeat}",value:t.event?t.event.repeat:""},{name:"{eventKey}",value:t.event?t.event.key:""},{name:"{eventCode}",value:t.event?t.event.code:""},{name:"{eventLocation}",value:!t.event||"keydown"!==t.event.type&&"keyup"!==t.event.type?"":t.event.location},{name:"{eventButton}",value:t.event?t.event.button:""},{name:"{eventClientX}",value:t.event?t.event.clientX:""},{name:"{eventClientY}",value:t.event?t.event.clientY:""},{name:"{eventPageX}",value:t.event?t.event.pageX:""},{name:"{eventPageY}",value:t.event?t.event.pageY:""},{name:"{eventScreenX}",value:t.event?t.event.screenX:""},{name:"{eventScreenY}",value:t.event?t.event.screenY:""},{name:"{eventX}",value:t.event?t.event.x:""},{name:"{eventY}",value:t.event?t.event.y:""},{name:"{eventTouchCount}",value:t.event&&t.event.touches?t.event.touches.length:""},{name:"{eventScale}",value:t.event&&t.event.scale?t.event.scale:""},{name:"{eventRotation}",value:t.event&&t.event.rotation?t.event.rotation:""},{name:"{eventTargetName}",value:t.event&&t.event.target?t.event.target.name:""},{name:"{eventTargetType}",value:t.event&&t.event.target?t.event.target.type:""},{name:"{eventTargetValue}",value:t.event&&t.event.target?t.event.target.value:""},{name:"{eventTargetValidity}",value:t.event&&t.event.target&&t.event.target.validity?t.event.target.validity.valid?"valid":"invalid":""},{name:"{eventTargetChecked}",value:t.event&&t.event.target&&("checkbox"===t.event.target.type||"radio"===t.event.target.type)?t.event.target.checked:""},{name:"{eventTargetFilesCount}",value:t.event&&t.event.target&&"file"===t.event.target.type&&t.event.target.files?t.event.target.files.length:""},{name:"{eventDataTransferTypesCount}",value:t.event&&t.event.dataTransfer?t.event.dataTransfer.types.length:""},{name:"{eventDataTransferFilesCount}",value:t.event&&t.event.dataTransfer?t.event.dataTransfer.files.length:""},{name:"{eventDataTransferText}",value:t.event&&t.event.dataTransfer&&t.event.dataTransfer.types.indexOf("text/plain")>=0?t.event.dataTransfer.getData("text/plain"):""},{name:"{windowScrollX}",value:window.scrollX},{name:"{windowScrollY}",value:window.scrollY},{name:"{windowInnerWidth}",value:window.innerWidth},{name:"{windowInnerHeight}",value:window.innerHeight},{name:"{windowOuterWidth}",value:window.outerWidth},{name:"{windowOuterHeight}",value:window.outerHeight},{name:"{eventTargetOffsetTop}",value:t.event&&t.event.target?t.event.target.offsetTop:""},{name:"{eventTargetOffsetLeft}",value:t.event&&t.event.target?t.event.target.offsetLeft:""},{name:"{eventTargetOffsetWidth}",value:t.event&&t.event.target?t.event.target.offsetWidth:""},{name:"{eventTargetOffsetHeight}",value:t.event&&t.event.target?t.event.target.offsetHeight:""},{name:"{postId}",value:window.bricksData?window.bricksData.postId:""}
1].forEach((t=>{e=e.replace(t.name,t.value)}));let n=["formField","formData"].some((t=>e.includes(`{${t}:`)));e.includes("{")&&e.includes(":")&&n&&(e=e.replace(/{(.*?):(.*?)}/g,((e,t,n)=>{let a="";switch(t){case"formField":a=this.getFormFieldValue(n);break;case"formData":a=this.getFormData(n)}return a})));const a=e.match(/{event:(.*?)}/);if(a){const n=a[1].split(/\.|:/).reduce(((e,t)=>e instanceof HTMLElement&&"value"===t?e.value:e&&void 0!==e[t]?e[t]:void 0),t.event);void 0!==n&&(e=e.replace(a[0],n))}return e}handleJavaScriptExpressions(e,t){if(!e.includes("{{"))return e;const n={window:window,document:document,event:t.event,dataFlow:this.dataFlow,nodes:this.nodes,globalVariables:window.bricksforgeData?.globalVariables||{},Math:Math,Date:Date,JSON:JSON,parseInt:parseInt,parseFloat:parseFloat,String:String,Number:Number,Boolean:Boolean,Array:Array,Object:Object,getElement:e=>document.querySelector(e),getElements:e=>document.querySelectorAll(e),getGlobalVariable:e=>this.dataFlow?.[e]||window.bricksforgeData?.globalVariables?.[e],...t};return e=e.replace(/\{\{(.*?)\}\}/g,((e,t)=>{try{t=t.trim();const e=new Function(...Object.keys(n),`return ${t};`)(...Object.values(n));return null!=e?String(e):""}catch(n){return console.warn(`Error evaluating JavaScript expression "{{${t}}}":`,n),e}}
1))}parseJavaScriptExpressionsInSettings(e,t){if(!e||"object"!=typeof e)return e;const n={...e};for(const e in n){const a=n[e];"string"==typeof a?n[e]=this.handleJavaScriptExpressions(a,t):"object"!=typeof a||null===a||Array.isArray(a)?Array.isArray(a)&&(n[e]=a.map((e=>"string"==typeof e?this.handleJavaScriptExpressions(e,t):"object"==typeof e&&null!==e?this.parseJavaScriptExpressionsInSettings(e,t):e))):n[e]=this.parseJavaScriptExpressionsInSettings(a,t)}return n}checkCanvasLoadingConditions(e){const t=e.canvasId||"global",n=this.canvases.find((e=>e.id===t));if(!n)return!0;if(!n.conditions||!n.conditions.hasLoadingCondition)return!0;const a=n.conditions,i=BRFPANEL&&BRFPANEL.postId?BRFPANEL.postId.toString():null,o=BRFPANEL.activeTemplate.content||null;switch(a.loadOnChoice){case"everywhere":return this.checkEverywhereConditions(a,i,o);case"specificPages":return this.checkSpecificPagesConditions(a,i);case"bricksActiveTemplate":return this.checkBricksTemplateConditions(a,o);case"custom":return this.checkCustomConditions(a,i);default:return!0}}checkEverywhereConditions(e,t,n){return!(e.loadOnExceptPages&&e.loadOnExceptPages.length>0&&t&&this.isIdInList(t,e.loadOnExceptPages))&&!(e.loadOnExceptBricksTemplates&&e.loadOnExceptBricksTemplates.length>0&&n&&this.isIdInList(n,e.loadOnExceptBricksTemplates))}checkSpecificPagesConditions(e,t){return!(!e.loadOn||0===e.loadOn.length)&&(!!t&&this.isIdInList(t,e.loadOn))}checkBricksTemplateConditions(e,t){return!(!e.loadOnBricksTemplate||0===e.loadOnBricksTemplate.length)&&(!!t&&this.isIdInList(t,e.loadOnBricksTemplate))}checkCustomConditions(e,t){if(!e.loadOnCustom)return!1;if(!t)return!1;const n=e.loadOnCustom.split(",").map((e=>e.trim())).filter((e=>e.length>0));return this.isIdInList(t,n)}isIdInList(e,t){if(!e||!t||!Array.isArray(t))return!1;const n=e.toString(),a=parseInt(e,10);return t.some((e=>{if(null==e)return!1;const t=e.toString(),i=parseInt(e,10);return t===n||!isNaN(a)&&!isNaN(i)&&a===i}))}}document.addEventListener("brf-panel-nodes",(e=>{void 0===brfNodeEditor&&(brfNodeEditor=new BricksforgeNodeEditor(e.detail.domEvent)),"undefined"!=typeof brfPanel&&brfPanel.timelines&&(brfNodeEditor.timelines=brfPanel.timelines,brfNodeEditor.splitTextInstances=brfPanel.splitTextInstances||[],brfNodeEditor.timelineActions=brfPanel.timelineActions||[],window.bricksforgeData&&window.bricksforgeData.panel&&(window.bricksforgeData.panel.timelines=brfPanel.timelines)),brfNodeEditor.handlePanelNodes(e.detail.nodes)}));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.