var gdjs;(function(o){const s=class{constructor(r){this._variablesArray=[];this._variables=new Hashtable,r!==void 0&&this.initFrom(r)}initFrom(r,e){e===void 0&&(e=!1),e||(s._deletedVars=s._deletedVars||[],this._variables.keys(s._deletedVars));const a=this;let t=0;for(let n=0;n<r.length;++n){const i=r[n];if(!i.name)continue;const l=a.get(i.name);if(l.reinitialize(i),!e){t<a._variablesArray.length?a._variablesArray[t]=l:a._variablesArray.push(l),++t;const b=s._deletedVars.indexOf(i.name);b!==-1&&(s._deletedVars[b]=void 0)}}if(!e){this._variablesArray.length=t;for(let n=0,i=s._deletedVars.length;n<i;++n){const l=s._deletedVars[n];l!==void 0&&this._variables.get(l).setUndefinedInContainer()}}}rebuildIndexFrom(r){this._variablesArray.length=0;for(const e of r)if(e.name){const a=this._variables.get(e.name);this._variablesArray.push(a)}}_declare(r,e){this._variables.put(r,e),this._variablesArray.push(e)}add(r,e){const a=this._variables.get(r);if(this._variables.put(r,e),a){const t=this._variablesArray.indexOf(a);t!==-1&&(this._variablesArray[t]=e)}}remove(r){const e=this._variables.get(r);e&&e.setUndefinedInContainer()}get(r){let e=this._variables.get(r);return e?e.isUndefinedInContainer()&&e.reinitialize():(e=new o.Variable,this._variables.put(r,e)),e}getFromIndex(r){if(r>=this._variablesArray.length){let e=new o.Variable;return this._variables.put("",e),e}else{let e=this._variablesArray[r];return e.isUndefinedInContainer()&&e.reinitialize(),e}}has(r){const e=this._variables.get(r);return!!e&&!e.isUndefinedInContainer()}hasVariable(r){const e=this._variablesArray.find(a=>a===r);return!!e&&!e.isUndefinedInContainer()}getVariableNameInContainerByLoopingThroughAllVariables(r){const e=this._variables.items;for(const a in e)if(e.hasOwnProperty(a)&&e[a]===r)return a;return null}getVariablePathInContainerByLoopingThroughAllVariables(r,e=null){const a=e||this._variables.items;for(const t in a)if(a.hasOwnProperty(t)){const n=a[t];if(n===r)return[t];if(n.getType()==="structure"){const i=n.getAllChildren(),l=this.getVariablePathInContainerByLoopingThroughAllVariables(r,i);if(l)return[t,...l]}}return null}getVariableFromPath(r){let e=this._variables.items;for(let a=0;a<r.length;a++){const t=r[a],n=e[t];if(!n)return null;if(a===r.length-1)return n;e=n.getAllChildren()}return null}getNetworkSyncData(r){const e=[],a=[];return this._variables.keys(a),a.forEach(t=>{const i=this._variables.get(t).getNetworkSyncData(r);i&&e.push({name:t,...i})}),e}updateFromNetworkSyncData(r,e){const a=this;for(let t=0;t<r.length;++t){const n=r[t],l=o.Variable.getVariableDataFromNetworkSyncData(n).name;if(!l)continue;a.get(l).updateFromNetworkSyncData(n,e)}}};let u=s;u._deletedVars=[],u.badVariablesContainer={_variables:new Hashtable,_variablesArray:[],has:function(){return!1},getFromIndex:function(){return s.badVariable},get:function(){return s.badVariable},remove:function(){},add:function(){},_declare:function(){},initFrom:function(){},getNetworkSyncData:function(){return[]},updateFromNetworkSyncData:function(){},hasVariable:function(){return!1},getVariableNameInContainerByLoopingThroughAllVariables:function(){return""},getVariablePathInContainerByLoopingThroughAllVariables:function(){return[]},getVariableFromPath:function(){return null},rebuildIndexFrom:function(){}},u.badVariable={_type:"number",_bool:!1,_children:{},_childrenArray:[],_str:"",_undefinedInContainer:!0,_value:0,_playerNumber:0,fromJSON:()=>o.VariablesContainer.badVariable,toJSObject:()=>0,fromJSObject:()=>o.VariablesContainer.badVariable,reinitialize:()=>{},addChild:()=>o.VariablesContainer.badVariable,castTo:()=>{},clearChildren:()=>{},clone:()=>o.VariablesContainer.badVariable,getChildrenCount:()=>0,replaceChildren:()=>{},replaceChildrenArray:()=>{},getType:function(){return"number"},isPrimitive:function(){return!0},setValue:()=>{},toggle:()=>{},getValue:()=>0,getChild:()=>o.VariablesContainer.badVariable,getChildAt:()=>o.VariablesContainer.badVariable,getChildNamed:()=>o.VariablesContainer.badVariable,hasChild:function(){return!1},isStructure:function(){return!1},isNumber:function(){return!0},removeChild:function(){},setNumber:function(){},setString:function(){},setBoolean:function(){},getAsString:function(){return"0"},getAsNumber:function(){return 0},getAsNumberOrString:function(){return 0},getAsBoolean:function(){return!1},getAllChildren:function(){return{}},getAllChildrenArray:function(){return[]},pushVariableCopy:()=>{},_pushVariable:()=>{},pushValue:()=>{},removeAtIndex:function(){},add:function(){},sub:function(){},mul:function(){},div:function(){},concatenate:function(){},concatenateString:function(){},setUndefinedInContainer:function(){},isUndefinedInContainer:function(){return!0},getPlayerOwnership:function(){return 0},setPlayerOwnership:function(){},disableSynchronization:function(){},getNetworkSyncData:function(){},getStructureNetworkSyncData:function(){return[]},updateFromNetworkSyncData:function(){}},o.VariablesContainer=u})(gdjs||(gdjs={}));
//# sourceMappingURL=variablescontainer.js.map
