var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.View=exports.default=exports.Node=exports.ViewNode=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _get2=_interopRequireDefault(require("@babel/runtime/helpers/get"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));var _getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));var _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var _react=_interopRequireDefault(require("react"));var _tree=require("../helpers/tree");var _Row=_interopRequireDefault(require("../../modules/Row"));var _Col=_interopRequireDefault(require("../../modules/Col"));var _BaseHolder=_interopRequireDefault(require("../../modules/BaseHolder"));var _reactNative=require("react-native");var _jsxFileName="C:\\Users\\Karteri\\Desktop\\Development\\TrapiLib\\src\\lib\\systems\\ViewSystem.js";function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly)symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;});keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i3&&arguments[3]!==undefined?arguments[3]:"default";(0,_classCallCheck2.default)(this,ViewNode);_this=(0,_possibleConstructorReturn2.default)(this,(0,_getPrototypeOf2.default)(ViewNode).call(this,id));_this.value=value;_this.namespace=namespace;_this.props=props||{};return _this;}return ViewNode;}(_tree.TreeNode);exports.ViewNode=ViewNode;var Node=function(_TreeNode2){(0,_inherits2.default)(Node,_TreeNode2);function Node(id,props,content){var _this2;(0,_classCallCheck2.default)(this,Node);_this2=(0,_possibleConstructorReturn2.default)(this,(0,_getPrototypeOf2.default)(Node).call(this,id));_this2.ctor=_BaseHolder.default;_this2.props=props||{};if(content){_this2.content=content;}return _this2;}(0,_createClass2.default)(Node,[{key:"export",value:function _export(){delete this.props.selected;return(0,_get2.default)((0,_getPrototypeOf2.default)(Node.prototype),"export",this).call(this);}}]);return Node;}(_tree.TreeNode);exports.Node=Node;var ViewSystem=function(){function ViewSystem(CS){(0,_classCallCheck2.default)(this,ViewSystem);this.views={};this.CoreSystem=CS;this.ModuleSystem=CS.ModuleSystem;this.EventSystem=CS.EventSystem;this.ghosts={};}(0,_createClass2.default)(ViewSystem,[{key:"getNode",value:function getNode(ViewId,NodeId){return this.views[ViewId].getNode(NodeId);}},{key:"getView",value:function getView(name){return this.views[name];}},{key:"addView",value:function addView(name,view){this.views[name]=view;return view;}},{key:"removeView",value:function removeView(name){var view=this.views[name];delete this.views[name];return view;}},{key:"render",value:function render(name){return this.views[name].render(this.CoreSystem);}},{key:"renderModule",value:function renderModule(mod,id){var selfView=this.CoreSystem.getCurrentView();var nodeId="___"+id+"Node";var value=mod.value,props=mod.props,namespace=mod.namespace;if(!selfView.ghosts[nodeId]){var viewNode=new ViewNode(id,value,props,namespace);var node=new Node(nodeId,{},viewNode);selfView.ghosts[nodeId]=node;}var vn=selfView.ghosts[nodeId].content;vn.value=value;vn.namespace=namespace;var ViewNodeReact=renderContent(selfView.ghosts[nodeId],this.CoreSystem,selfView);return renderNode(selfView.ghosts[nodeId],this.CoreSystem,ViewNodeReact);}},{key:"export",value:function _export(){var views={};for(var i in this.views){views[i]=this.views[i].export();}return{views:views};}},{key:"import",value:function _import(data){var views=data.views;for(var i in views){this.views[i]=new View().import(views[i]);}return this;}},{key:"ray",value:function ray(viewId,x,y,id){var tree=this.views[viewId].ViewTree;}}]);return ViewSystem;}();exports.default=ViewSystem;var View=function(){function View(){(0,_classCallCheck2.default)(this,View);this.ViewTree=new _tree.Tree();var rootNode=new Node(Math.random(),{stretchContainer:false,selected:true});this.addViewNode(rootNode);this.defaultContainer=rootNode;this.ghosts={};}(0,_createClass2.default)(View,[{key:"getDefaultContainer",value:function getDefaultContainer(){return this.defaultContainer;}},{key:"getRoot",value:function getRoot(){return this.ViewTree.root;}},{key:"getNode",value:function getNode(id){return this.ghosts[id]||this.ViewTree.getNode(id);}},{key:"isRoot",value:function isRoot(node){return this.defaultContainer===node;}},{key:"has",value:function has(node){if(typeof node!=="object")return this.getNode(node);return this.getNode(node.id);}},{key:"render",value:function render(CS){var node=this.ViewTree.root;return _react.default.createElement(Renderer,{CoreSystem:CS,node:node,tree:this.ViewTree,selfView:this,__source:{fileName:_jsxFileName,lineNumber:145}});}},{key:"addViewNode",value:function addViewNode(node){var parentNode=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;this.ViewTree.insert(node,parentNode);return this;}},{key:"setContent",value:function setContent(content,container){container.content=content;return this;}},{key:"getParent",value:function getParent(node){if(!this.has(node))return false;return this.getNode(this.ViewTree.getParent(node));}},{key:"getRows",value:function getRows(column){log("Deprecated for now");return true;if(!column.isCol){throw new Error("You must pass a ColNode to this function");}return this.getChildren(column);}},{key:"setRows",value:function setRows(column){var rows=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;log("Deprecated for now");return true;if(!column.isCol)throw new Error("You must pass a ColNode to this function");if(rows<1)throw new Error("Only positive rows");var colChildren=this.getChildren(column);if(colChildren.length>rows){for(var i=rows;i1&&arguments[1]!==undefined?arguments[1]:1;log("Deprecated for now");return true;if(!row.isRow)throw new Error("You must pass a RowNode to this function");if(columns<1)throw new Error("Only positive cols");var rowChildren=this.getChildren(row);if(rowChildren.length>columns){for(var i=columns;i