Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@limble/limble-tree

Package Overview
Dependencies
Maintainers
2
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@limble/limble-tree - npm Package Compare versions

Comparing version 0.11.6 to 0.11.7

2

bundles/limble-limble-tree.umd.min.js

@@ -15,3 +15,3 @@ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("rxjs"),require("rxjs/operators"),require("@angular/common")):"function"==typeof define&&define.amd?define("@limble/limble-tree",["exports","@angular/core","rxjs","rxjs/operators","@angular/common"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).limble=e.limble||{},e.limble["limble-tree"]={}),e.ng.core,e.rxjs,e.rxjs.operators,e.ng.common)}(this,(function(e,t,n,r,o){"use strict";

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */Object.create;function i(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function s(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(a(arguments[t]));return e}Object.create;function l(e,t){var n,r;if(e.length!==t.length)return!1;try{for(var o=i(e.entries()),s=o.next();!s.done;s=o.next()){var d=a(s.value,2),c=d[0],h=d[1],p=t[c];if(h instanceof Array&&p instanceof Array){if(!l(h,p))return!1}else if(h!==p)return!1}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return!0}function d(e,t){return void 0!==e&&(!0===e.allowNesting||"function"==typeof e.allowNesting&&void 0!==t&&!0===e.allowNesting(t))}var c=function(){function e(e,t){this.parentCoordinates=e,this.insertIndex=t}return e.prototype.getFullInsertCoordinates=function(){return s(this.parentCoordinates,[this.insertIndex])},e.prototype.setParentCoordinates=function(e){this.parentCoordinates=e},e.prototype.setInsertIndex=function(e){this.insertIndex=e},e}(),h=function(){function e(e,t){this.location=new c(e,t),this.rendered=!1,this.visible=!1,this.active=!1,this.commChannel=new n.Subject}return e.dropZoneLocationsAreEqual=function(e,t){return l(e.getFullInsertCoordinates(),t.getFullInsertCoordinates())},e.prototype.isRendered=function(e){return void 0===e&&(e=void 0),void 0!==e&&(this.rendered=e,void 0!==this.commChannel&&this.commChannel.next("checkRendered"),!1===this.rendered&&this.isVisible(!1)),this.rendered},e.prototype.isVisible=function(e){return void 0===e&&(e=void 0),void 0!==e&&(this.visible=e,void 0!==this.commChannel&&this.commChannel.next("checkVisible"),!1===this.visible&&this.isActive(!1)),this.visible},e.prototype.isActive=function(e){return void 0===e&&(e=void 0),void 0!==e&&(this.active=e,void 0!==this.commChannel&&this.commChannel.next("checkActive")),this.active},e.prototype.getLocation=function(){return this.location},e.prototype.getFamily=function(){return this.family},e.prototype.setFamily=function(e){this.family=e},e.prototype.getCommChannel=function(){return this.commChannel},e.prototype.getFullInsertCoordinates=function(){return this.location.getFullInsertCoordinates()},e.prototype.setHost=function(e){return this.host=e,this.host},e.prototype.getHost=function(){return this.host},e}(),p=function(){function e(){this.state="idle",this.state$=new n.BehaviorSubject(this.state)}return e.prototype.dragging=function(e,t){this._tempData={branch:e,parentContainer:t},this.state="dragging",this.state$.next(this.state)},e.prototype.droppable=function(){if("dragging"!==this.state)throw new Error("Can only call `droppable` when state is `dragging`");this.state="droppable",this.state$.next(this.state)},e.prototype.notDroppable=function(){if("droppable"!==this.state)throw new Error("Can only call `notDroppable` when state is `droppable`");this.state="dragging",this.state$.next(this.state)},e.prototype.capture=function(){var e;if("droppable"!==this.state)throw new Error("Can only move to `captured` state from `droppable` state");return this.state="captured",this.state$.next(this.state),null===(e=this._tempData)||void 0===e?void 0:e.branch},e.prototype.release=function(){this._tempData=void 0,this.state="idle",this.state$.next(this.state)},e.prototype.getData=function(){return this._tempData},e.prototype.getState=function(){return this.state},e}();p.ɵfac=function(e){return new(e||p)},p.ɵprov=t.ɵɵdefineInjectable({token:p,factory:p.ɵfac}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(p,[{type:t.Injectable}],(function(){return[]}),null);var u=function(){function e(){this.beingBuilt=0,this.isReady=!1,this.stable$=new n.BehaviorSubject(this.treeIsStable())}return e.prototype.constructing=function(){this.beingBuilt++,this.emit()},e.prototype.doneConstructing=function(){this.beingBuilt--,this.emit()},e.prototype.treeIsStable=function(){return!0===this.isReady&&0===this.beingBuilt},e.prototype.ready=function(e){this.isReady=e},e.prototype.emit=function(){this.stable$.next(this.treeIsStable())},e}();function v(e,t){var n=e.getFullInsertCoordinates(),r=t.getFullInsertCoordinates();return n.length>r.length?-1:n.length<r.length?1:0}u.ɵfac=function(e){return new(e||u)},u.ɵprov=t.ɵɵdefineInjectable({token:u,factory:u.ɵfac}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(u,[{type:t.Injectable}],(function(){return[]}),null);var f=function(){function e(e,t){var o=this;this.dragStateService=e,this.dropZoneArchive=new Set,this.dropZoneInventory=[],this.dropZoneFamilies=[],this.visibleFamily=null,this.activeDropZone=null,this.tempFamilies=[],this.setActiveDropZone(null);var i=!1,a=t.stable$.pipe(r.tap((function(e){i=e})),r.filter((function(e){return!0===e})));this.update$=new n.Subject,this.update$.pipe(r.debounce((function(){return!0===i?n.EMPTY:a}))).subscribe((function(){setTimeout((function(){o.updateDropZones()}))}))}return e.prototype.addDropZone=function(e){this.dropZoneArchive.add(e)},e.prototype.clearVisibleZones=function(){var e,t;if(null!==this.visibleFamily){try{for(var n=i(this.visibleFamily.members),r=n.next();!r.done;r=n.next()){r.value.isVisible(!1)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this.visibleFamily=null}this.setActiveDropZone(null)},e.prototype.getActiveDropZone=function(){return this.activeDropZone},e.prototype.getDropZone=function(e){var t=s(e);t.pop();var n=e[e.length-1],r=new c(t,n);return this.dropZoneInventory.find((function(e){return h.dropZoneLocationsAreEqual(e,r)}))},e.prototype.init=function(e,t){this.tree=e,this.treeOptions=t,this.update()},e.prototype.removeDropZone=function(e){this.dropZoneArchive.delete(e)},e.prototype.reset=function(){this.clearVisibleZones(),this.dropZoneFamilies.length=0,this.dropZoneInventory.length=0},e.prototype.restart=function(){this.reset(),this.dropZoneArchive.clear()},e.prototype.restoreFamilies=function(){var e,t,n,r;if(2===this.tempFamilies.length){this.dropZoneFamilies.pop(),this.dropZoneFamilies.push(this.tempFamilies[0]);try{for(var o=i(this.tempFamilies[0].members),a=o.next();!a.done;a=o.next()){a.value.setFamily(this.tempFamilies[0])}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}if(null!==this.tempFamilies[1]){this.dropZoneFamilies.push(this.tempFamilies[1]);try{for(var s=i(this.tempFamilies[1].members),l=s.next();!l.done;l=s.next()){l.value.setFamily(this.tempFamilies[1])}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}}this.tempFamilies=[]}},e.prototype.showDropZoneFamily=function(e,t){var n,r,o,a,l,d;if(void 0===t&&(t={joinFamilies:!1,activateLowestInsteadOfFounder:!1}),null===this.activeDropZone||!h.dropZoneLocationsAreEqual(this.activeDropZone,e)){null===this.visibleFamily&&null===this.activeDropZone||this.clearVisibleZones();var p=this.dropZoneInventory.find((function(t){return h.dropZoneLocationsAreEqual(t,e)}));if(void 0===p)throw new Error("Could not find drop zone to show. location: "+JSON.stringify(e.getLocation()));var u=p.getFamily();if(!0===t.joinFamilies){var f=e.getLocation(),g=new c(s(f.parentCoordinates),f.insertIndex+1),y=this.dropZoneInventory.find((function(e){return h.dropZoneLocationsAreEqual(e,g)}));if(void 0===y)throw new Error("Could not find drop zone to show");var m=y.getFamily();if(void 0===u||void 0===m)throw new Error("No family");var b={founder:u.founder,members:s(u.members)};this.showDropZone(u.founder,!0);try{for(var w=i(u.members.sort(v)),Z=w.next();!Z.done;Z=w.next()){(M=Z.value).setFamily(b),M!==u.founder&&(null===this.activeDropZone?this.showDropZone(M,!0):this.showDropZone(M))}}catch(e){n={error:e}}finally{try{Z&&!Z.done&&(r=w.return)&&r.call(w)}finally{if(n)throw n.error}}try{for(var C=i(m.members),D=C.next();!D.done;D=C.next()){(M=D.value).setFamily(b),M.getLocation().parentCoordinates.length<y.getLocation().parentCoordinates.length&&(b.members.push(M),this.showDropZone(M))}}catch(e){o={error:e}}finally{try{D&&!D.done&&(a=C.return)&&a.call(C)}finally{if(o)throw o.error}}this.tempFamilies=[u,m];var S=this.dropZoneFamilies.indexOf(u);this.dropZoneFamilies.splice(S,1);var I=this.dropZoneFamilies.indexOf(m);this.dropZoneFamilies.splice(I,1),this.dropZoneFamilies.push(b),this.visibleFamily=b}else{if(void 0===u)throw new Error("No family");if(this.visibleFamily=u,this.showDropZone(u.founder,!0),u.members.length>1)try{for(var x=i(u.members.sort(v)),E=x.next();!E.done;E=x.next()){var M;(M=E.value)!==u.founder&&(null===this.activeDropZone?this.showDropZone(M,!0):this.showDropZone(M))}}catch(e){l={error:e}}finally{try{E&&!E.done&&(d=x.return)&&d.call(x)}finally{if(l)throw l.error}}}if(!0===t.activateLowestInsteadOfFounder&&this.visibleFamily.members.length>1){var F=s(this.visibleFamily.members).sort(v).pop();if(void 0===F)throw new Error("Could not get lowest member");this.swapActiveDropZone(F)}}},e.prototype.swapActiveDropZone=function(e){if(null===this.visibleFamily)throw new Error("No visible family available for swapping");if(-1===this.visibleFamily.members.findIndex((function(t){return t===e})))throw new Error("failed to swap active drop zone");this.setActiveDropZone(e)},e.prototype.update=function(){this.update$.next(null)},e.prototype.assignFamilies=function(){var e,t,n,r,o,a,d=s(this.dropZoneInventory),c=d.filter((function(e){var t=e.getLocation();return 0===t.insertIndex&&t.parentCoordinates.length>0})).sort((function(e,t){for(var n,r,o,i,a=e.getFullInsertCoordinates(),s=t.getFullInsertCoordinates(),l=Math.max(a.length,s.length),d=0;d<l;d++){if((null!==(n=a[d])&&void 0!==n?n:-1)>(null!==(r=s[d])&&void 0!==r?r:-1))return-1;if((null!==(o=a[d])&&void 0!==o?o:-1)<(null!==(i=s[d])&&void 0!==i?i:-1))return 1}return 0})),h=function(e){if(!d.includes(e))return"continue";var t={founder:e,members:[]};e.setFamily(t);for(var n=s(e.getFullInsertCoordinates());n.length>0;){var r=d.findIndex((function(e){return l(e.getFullInsertCoordinates(),n)}));if(-1!==r){var o=d.splice(r,1)[0];t.members.push(o),o.setFamily(t)}n.pop(),n[n.length-1]++}p.dropZoneFamilies.push(t)},p=this;try{for(var u=i(c),v=u.next();!v.done;v=u.next()){h(y=v.value)}}catch(t){e={error:t}}finally{try{v&&!v.done&&(t=u.return)&&t.call(u)}finally{if(e)throw e.error}}try{for(var f=i(d.filter((function(e){return 1===e.getFullInsertCoordinates().length}))),g=f.next();!g.done;g=f.next()){var y,m={founder:y=g.value,members:[y]};y.setFamily(m),this.dropZoneFamilies.push(m),d.splice(d.indexOf(y),1)}}catch(e){n={error:e}}finally{try{g&&!g.done&&(r=f.return)&&r.call(f)}finally{if(n)throw n.error}}if(0!==d.length){var b="";try{for(var w=i(d),Z=w.next();!Z.done;Z=w.next()){var C=Z.value;b+=JSON.stringify(C.getLocation())+", "}}catch(e){o={error:e}}finally{try{Z&&!Z.done&&(a=w.return)&&a.call(w)}finally{if(o)throw o.error}}throw b=b.slice(0,b.length-2),new Error("Some zones were not assigned to a family. The orphan zones have the following locations: "+b)}},e.prototype.buildInventory=function(){var e,t,n=[];try{for(var r=i(this.dropZoneArchive),o=r.next();!o.done;o=r.next()){var a=o.value,s=a.getFullInsertCoordinates().join(",");n.includes(s)?a.isRendered(!1):(this.dropZoneInventory.push(a),n.push(s),a.isRendered(!0))}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},e.prototype.setActiveDropZone=function(e){null!==this.activeDropZone&&this.activeDropZone.isActive(!1),this.activeDropZone=e,null!==this.activeDropZone&&"droppable"!==this.dragStateService.getState()?this.dragStateService.droppable():null===this.activeDropZone&&"droppable"===this.dragStateService.getState()&&this.dragStateService.notDroppable(),null!==this.activeDropZone&&this.activeDropZone.isActive(!0)},e.prototype.showDropZone=function(e,t){if(void 0===t&&(t=!1),void 0===this.tree)throw new Error("DropZoneService not initialized");if(!this.zoneIsAllowed(e))return!1;if(void 0===this.tree.findByCoordinates(e.getLocation().parentCoordinates))throw new Error("Bad family member");return e.isVisible(!0),!0===t&&this.setActiveDropZone(e),!0},e.prototype.updateDropZones=function(){this.reset(),this.buildInventory(),this.assignFamilies()},e.prototype.zoneIsAllowed=function(e){if(void 0===this.treeOptions||void 0===this.tree)throw new Error("dropZoneService not initialized");var t=this.dragStateService.getData();if(void 0===t)throw new Error("Can't get dragged node");var n=this.tree.findByCoordinates(e.getLocation().parentCoordinates);if(void 0===n)throw new Error("Could not get drop zone parent");var r=e.getLocation().insertIndex;if(void 0===r)throw new Error("Could not get drop zone index");var o=t.branch;return!!this.treeOptions.allowDrop(o.data,n.data,r)},e}();f.ɵfac=function(e){return new(e||f)(t.ɵɵinject(p),t.ɵɵinject(u))},f.ɵprov=t.ɵɵdefineInjectable({token:f,factory:f.ɵfac}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(f,[{type:t.Injectable}],(function(){return[{type:p},{type:u}]}),null);var g=function(){function e(e){this.data=e,this.children=[],this.parent=null}return e.prototype.isRoot=function(){return null===this.parent},e.prototype.getParent=function(){return this.parent},e.prototype.setParent=function(e){this.parent=e},e.prototype.findByCoordinates=function(e){var t,n,r=this;try{for(var o=i(e.values()),a=o.next();!a.done;a=o.next()){var s=a.value;if(void 0===(r=r.getChild(s)))return}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return r},e.prototype.getCoordinates=function(){for(var e=[],t=this;null!==t.parent;){var n=t.getIndex();if(null==n)throw new Error("Could not get cursor index");e.unshift(n),t=t.parent}return e},e.prototype.getChild=function(e){return this.children[e]},e.prototype.getChildren=function(){return this.children},e.prototype.clearChildren=function(){var e,t;try{for(var n=i(this.children),r=n.next();!r.done;r=n.next()){r.value.setParent(null)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this.children.length=0},e.prototype.getIndex=function(){var e=this;if(null===this.parent)return null;var t=this.parent.children.findIndex((function(t){return t===e}));return-1!==t?t:void 0},e.prototype.getDescendant=function(e){var t,n,r=this;try{for(var o=i(e),a=o.next();!a.done;a=o.next()){var s=a.value;if(void 0===(r=r.children[s]))return}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return r},e.prototype.findDescendant=function(e){var t,n;if(!0===e(this.data))return this;if(this.children.length>0)try{for(var r=i(this.children),o=r.next();!o.done;o=r.next()){var a=o.value.findDescendant(e);if(void 0!==a)return a}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},e.prototype.getAncestors=function(){for(var e=[],t=this;null!==t.parent;)e.push(t.parent),t=t.parent;return e},e.prototype.appendChild=function(e){return null!==e.getParent()&&e.remove(),e.setParent(this),this.children.push(e),e},e.prototype.insertChild=function(e,t){var n=this.children.indexOf(e);return-1===n?(null!==e.getParent()&&e.remove(),e.setParent(this),this.children.splice(t,0,e)):t>n?(this.children.splice(t,0,e),this.removeChild(n),e.setParent(this)):(e.remove(),this.children.splice(t,0,e),e.setParent(this)),e},e.prototype.removeChild=function(e){var t=this.children.splice(e,1)[0];return t.setParent(null),t},e.prototype.remove=function(){var e=this.getIndex();if(null===this.parent||null==e)throw new Error("can't remove root");return this.parent.removeChild(e)},e.prototype.copy=function(){var e=this.copyHelper();return e.setParent(null),e},e.prototype.copyHelper=function(){var t,n,r=new e(this.data);try{for(var o=i(this.children),a=o.next();!a.done;a=o.next()){var s=a.value;r.appendChild(s.copyHelper()).parent=r}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return r},e}(),y=["children"];function m(e,n){if(1&e&&t.ɵɵelement(0,"drop-zone",3),2&e){var r=t.ɵɵnextContext();t.ɵɵproperty("dropZone",r.dropZoneInside)}}function b(e,t){}var w=function(){function e(e,t,n,r,o){var i;this.treeService=e,this.changeDetectorRef=t,this.dropZoneService=n,this.treeConstructionStatus=r,this.ngZone=o,this.treeConstructionStatus.constructing(),this.indent=null===(i=this.treeService.treeOptions)||void 0===i?void 0:i.indent,this.renderDropZoneInside=!1}return e.prototype.ngOnInit=function(){var e=this;this.addDropZoneInside(),this.ngZone.runOutsideAngular((function(){if(void 0===e.dropZoneInside)throw new Error("drop zone inside is not defined");e.dropZoneInside.getCommChannel().pipe(r.filter((function(e){return"checkRendered"===e}))).subscribe((function(){if(void 0===e.dropZoneInside||void 0===e.branch)throw new Error("Zones not registered");d(e.treeService.treeOptions,e.branch.data)&&(e.renderDropZoneInside=e.dropZoneInside.isRendered())}))}))},e.prototype.ngAfterViewInit=function(){this.reRender(),this.setDropZoneHost(),this.treeConstructionStatus.doneConstructing(),this.changeDetectorRef.detectChanges()},e.prototype.ngOnDestroy=function(){void 0!==this.dropZoneInside&&this.dropZoneService.removeDropZone(this.dropZoneInside),this.treeService.cleanupSignal$.next(!0)},e.prototype.addDropZoneInside=function(){if(void 0===this.branch)throw new Error("failed to register drop zone inside");this.dropZoneInside=new h(s(this.branch.getCoordinates()),0),this.dropZoneService.addDropZone(this.dropZoneInside)},e.prototype.reRender=function(){if(void 0===this.children||void 0===this.branch)throw new Error("Failed to render limble tree branch");this.treeService.renderBranch(this.children,this.branch)},e.prototype.setDropZoneHost=function(){if(void 0===this.children||void 0===this.dropZoneInside)throw new Error("Failed to add drop zone host");this.dropZoneInside.setHost(this.children)},e}();w.ɵfac=function(e){return new(e||w)(t.ɵɵdirectiveInject(R),t.ɵɵdirectiveInject(t.ChangeDetectorRef),t.ɵɵdirectiveInject(f),t.ɵɵdirectiveInject(u),t.ɵɵdirectiveInject(t.NgZone))},w.ɵcmp=t.ɵɵdefineComponent({type:w,selectors:[["limble-tree-branch"]],viewQuery:function(e,n){if(1&e&&t.ɵɵviewQuery(y,1,t.ViewContainerRef),2&e){var r;t.ɵɵqueryRefresh(r=t.ɵɵloadQuery())&&(n.children=r.first)}},inputs:{branch:"branch"},decls:5,vars:4,consts:[[3,"dropZone",4,"ngIf"],[1,"limble-child-nodes",3,"hidden"],["children",""],[3,"dropZone"]],template:function(e,n){1&e&&(t.ɵɵelementStart(0,"div"),t.ɵɵtemplate(1,m,1,1,"drop-zone",0),t.ɵɵelementStart(2,"span",1),t.ɵɵtemplate(3,b,0,0,"ng-template",null,2,t.ɵɵtemplateRefExtractor),t.ɵɵelementEnd(),t.ɵɵelementEnd()),2&e&&(t.ɵɵstyleProp("margin-left",n.indent,"px"),t.ɵɵadvance(1),t.ɵɵproperty("ngIf",n.renderDropZoneInside),t.ɵɵadvance(1),t.ɵɵproperty("hidden",n.branch&&n.branch.data.collapsed))},styles:["./limble-tree-branch.component.scss"]}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(w,[{type:t.Component,args:[{selector:"limble-tree-branch",templateUrl:"./limble-tree-branch.component.html",styles:["./limble-tree-branch.component.scss"]}]}],(function(){return[{type:R},{type:t.ChangeDetectorRef},{type:f},{type:u},{type:t.NgZone}]}),{branch:[{type:t.Input}],children:[{type:t.ViewChild,args:["children",{read:t.ViewContainerRef}]}]});var Z=function(){function e(e){this.factoryResolver=e,this.factoryResolver=e}return e.prototype.appendComponent=function(e,t,n){void 0===n&&(n=void 0);var r=this.factoryResolver.resolveComponentFactory(e);return t.createComponent(r,n)},e}();function C(e){var t,n,r,o=/(auto|scroll)/,a=function(e,t){return null===e||null===e.parentNode?t:a(e.parentElement,t.concat([e]))},s=function(e,t){return getComputedStyle(e,null).getPropertyValue(t)},l=function(e){return o.test(function(e){return s(e,"overflow")+s(e,"overflow-y")+s(e,"overflow-x")}(e))},d=a(e.parentElement,[]);try{for(var c=i(d),h=c.next();!h.done;h=c.next()){var p=h.value;if(l(p))return p}}catch(e){t={error:e}}finally{try{h&&!h.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}return null!==(r=document.scrollingElement)&&void 0!==r?r:document.documentElement}Z.ɵfac=function(e){return new(e||Z)(t.ɵɵinject(t.ComponentFactoryResolver))},Z.ɵprov=t.ɵɵdefineInjectable({token:Z,factory:Z.ɵfac}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(Z,[{type:t.Injectable}],(function(){return[{type:t.ComponentFactoryResolver}]}),null);var D=function(){function e(e){var t=this;this.ngZone=e,this.ngZone.runOutsideAngular((function(){t.globalDrag$=n.fromEvent(document,"drag")})),this.scrolling=!1}return e.prototype.addScrolling=function(){var e=this;this.ngZone.runOutsideAngular((function(){if(void 0===e.globalDragSubscription){if(void 0===e.globalDrag$)throw new Error("Could not get observable");var t,n,o,i,a,s,l,d,c;e.globalDragSubscription=e.globalDrag$.pipe(r.throttleTime(25),r.filter((function(e){if(!e.target)return!1;d=C(e.target),t=d.clientHeight;var r,l=d.clientWidth;if("fixed"===window.getComputedStyle(d).getPropertyValue("position").toLowerCase())r=e.clientX,c=e.clientY;else{var h=d.getBoundingClientRect(),p=C(d);r=e.clientX-(h.left+p.scrollLeft),c=e.clientY-(h.top+p.scrollTop)}return!(r<0||r>l||c<0||c>t)&&(n=Math.max(.1*t,100),s=c>(i=t-n),(a=c<(o=n))||s)}))).subscribe((function(){if(null!==d){var r,h=d.scrollHeight-t,p=d.scrollTop;if(a&&p>0){r=p-75*((o-c)/n)}else{if(!s||!(p<h))return;r=p+75*((c-i)/n)}(r=Math.max(0,Math.min(h,r)))!==p&&(d.scrollTo({top:r}),e.scrolling=!0,clearTimeout(l),l=setTimeout((function(){e.scrolling=!1}),100))}}))}}))},e.prototype.removeScrolling=function(){void 0!==this.globalDragSubscription&&this.globalDragSubscription.unsubscribe()},e}();D.ɵfac=function(e){return new(e||D)(t.ɵɵinject(t.NgZone))},D.ɵprov=t.ɵɵdefineInjectable({token:D,factory:D.ɵfac}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(D,[{type:t.Injectable}],(function(){return[{type:t.NgZone}]}),null);var S=["nodeHost"],I=["draggableDiv"],x=["nodeHostContainer"],E=["innerBranch"];function M(e,n){if(1&e&&t.ɵɵelement(0,"drop-zone",7),2&e){var r=t.ɵɵnextContext();t.ɵɵproperty("dropZone",r.dropZoneAbove)}}function F(e,t){}function A(e,n){if(1&e&&t.ɵɵelement(0,"limble-tree-branch",8,9),2&e){var r=t.ɵɵnextContext();t.ɵɵproperty("branch",r.branch)}}function O(e,n){if(1&e&&t.ɵɵelement(0,"drop-zone",7),2&e){var r=t.ɵɵnextContext();t.ɵɵproperty("dropZone",r.dropZoneBelow)}}var j=function(){function e(e,t,n,o,i,a,s,l){var d=this;this.componentCreatorService=e,this.changeDetectorRef=t,this.dragStateService=n,this.dropZoneService=o,this.treeService=i,this.globalEventsService=a,this.ngZone=s,this.treeConstructionStatus=l,this.treeConstructionStatus.constructing(),void 0!==this.treeService.treeOptions&&!0!==this.treeService.treeOptions.listMode?this.renderInnerBranch=!0:this.renderInnerBranch=!1,this.renderDropZoneBelow=!1,this.renderDropZoneAbove=!1,this.treeChangeSubscription=this.treeService.changes$.pipe(r.skip(1)).subscribe((function(){d.treeChangeHandler()}))}return e.prototype.treeChangeHandler=function(){void 0===this.branch||void 0===this.currentBranchCoordinates||l(this.branch.getCoordinates(),this.currentBranchCoordinates)||this.updateDropZones()},e.prototype.ngOnInit=function(){var e,t,o,i=this;if(!1!==(null===(e=this.treeService.treeOptions)||void 0===e?void 0:e.allowDragging)){var a=null===(t=this.branch)||void 0===t?void 0:t.getParent();if(null!==(null==a?void 0:a.data)){var s=null==a?void 0:a.data;if(!d(this.treeService.treeOptions,s))return void(this.renderInnerBranch=!1)}this.registerDropZones(),this.currentBranchCoordinates=null===(o=this.branch)||void 0===o?void 0:o.getCoordinates(),this.ngZone.runOutsideAngular((function(){if(void 0===i.dropZoneAbove||void 0===i.dropZoneBelow)throw new Error("Zones not registered");n.merge(i.dropZoneAbove.getCommChannel(),i.dropZoneBelow.getCommChannel()).pipe(r.filter((function(e){return"checkRendered"===e}))).subscribe((function(){if(void 0===i.dropZoneAbove||void 0===i.dropZoneBelow||void 0===i.branch)throw new Error("Zones not registered");i.renderDropZoneAbove=i.dropZoneAbove.isRendered(),i.renderDropZoneBelow=i.dropZoneBelow.isRendered()}))}))}},e.prototype.ngAfterViewInit=function(){this.renderNode(),this.setDropZoneHosts(),this.checkForHandle(),this.treeConstructionStatus.doneConstructing(),this.changeDetectorRef.detectChanges()},e.prototype.ngOnDestroy=function(){this.treeChangeSubscription.unsubscribe(),void 0!==this.dropZoneAbove&&this.dropZoneService.removeDropZone(this.dropZoneAbove),void 0!==this.dropZoneBelow&&this.dropZoneService.removeDropZone(this.dropZoneBelow),this.treeService.cleanupSignal$.next(!0)},e.prototype.dragstartHandler=function(e){var t,o=this;if(e.stopPropagation(),null===e.dataTransfer||void 0===this.branch||void 0===this.parentHost)throw new Error("failed to run dragstartHandler");var i=e.target;if("LIMBLE-TREE-NODE"===(null===(t=i.parentElement)||void 0===t?void 0:t.tagName)){e.dataTransfer.effectAllowed="move",this.dragStateService.dragging(this.branch,this.parentHost);var a=i.closest("limble-tree-root");if(null===a)throw new Error("could not get root of tree");this.ngZone.runOutsideAngular((function(){setTimeout((function(){var e,t;i.classList.add("dragging"),1===(null===(e=o.treeService.treeData)||void 0===e?void 0:e.length)&&1===(null===(t=o.branch)||void 0===t?void 0:t.getCoordinates().length)&&o.treeService.placeholder$.next(!0)}));var e=n.fromEvent(a,"dragover").pipe(r.first()).subscribe((function(e){if(e.stopPropagation(),void 0===o.branch)throw new Error("Could not show surrounding drop zones");var t,n=o.branch.getParent(),r=!0;null!==(null==n?void 0:n.data)&&(t=null==n?void 0:n.data,r=d(o.treeService.treeOptions,t)),void 0!==o.dropZoneAbove&&r&&o.dropZoneService.showDropZoneFamily(o.dropZoneAbove,{joinFamilies:!0})}));setTimeout((function(){e.closed||e.unsubscribe()}),500)}))}else e.preventDefault()},e.prototype.dragendHandler=function(e){var t,n;if(null==e||e.stopPropagation(),void 0===this.draggableDiv)throw new Error("could not get draggable div");if(this.draggableDiv.nativeElement.classList.remove("dragging"),"captured"===this.dragStateService.getState()){if(!1===this.treeService.captured){if(void 0===this.branch)throw new Error("could not get branch in dragendHandler");this.treeService.cleanupSignal$.next(!0),this.treeService.captured=!1}this.dragStateService.release()}else this.dragStateService.release(),this.dropZoneService.clearVisibleZones(),this.dropZoneService.restoreFamilies(),1===(null===(t=this.treeService.treeData)||void 0===t?void 0:t.length)&&1===(null===(n=this.branch)||void 0===n?void 0:n.getCoordinates().length)&&this.treeService.placeholder$.next(!1)},e.prototype.dragoverHandler=function(e){var t,n;if(!0!==this.globalEventsService.scrolling){if(void 0===this.branch)throw new Error("Can't get current branch during dragover event");var r=this.dragStateService.getData();if(void 0!==r){var o=r.branch;if(o!==this.branch&&!this.branch.getAncestors().includes(o)){var i,a,s=e.currentTarget;a=void 0===(null===(t=this.innerBranch)||void 0===t?void 0:t.dropZoneInside)?i=s.offsetHeight/2-6:2*(i=s.offsetHeight/3-3);var l,c=this.branch.getParent(),p=!0;null!==(null==c?void 0:c.data)&&(l=null==c?void 0:c.data,p=d(this.treeService.treeOptions,l));var u=this.dropZoneService.getActiveDropZone();if(e.offsetY<i&&void 0!==this.dropZoneAbove&&(null===u||!h.dropZoneLocationsAreEqual(u,this.dropZoneAbove))&&p){if(null==this.branch.getIndex())throw new Error("can't get branch index");this.dropZoneService.showDropZoneFamily(this.dropZoneAbove,{activateLowestInsteadOfFounder:!0})}else if(e.offsetY<a&&void 0!==(null===(n=this.innerBranch)||void 0===n?void 0:n.dropZoneInside)&&(null===u||!h.dropZoneLocationsAreEqual(u,this.innerBranch.dropZoneInside)))this.dropZoneService.showDropZoneFamily(this.innerBranch.dropZoneInside);else if(e.offsetY>=a&&void 0!==this.dropZoneBelow&&(null===u||!h.dropZoneLocationsAreEqual(u,this.dropZoneBelow))&&0===this.branch.getChildren().length&&p){if(null==this.branch.getIndex())throw new Error("can't get branch index");this.dropZoneService.showDropZoneFamily(this.dropZoneBelow)}}}}},e.prototype.renderNode=function(){var e;if(void 0===this.nodeHost||void 0===this.branch)throw new Error("Failed to render tree node");var t=this.branch.data.component;if(void 0===t&&(t=null===(e=this.treeService.treeOptions)||void 0===e?void 0:e.defaultComponent),void 0===t)throw new Error("limbleTree requires a component to render");var n=this.componentCreatorService.appendComponent(t.class,this.nodeHost);for(var r in n.instance.nodeData=this.branch.data,t.bindings)n.instance[r]=t.bindings[r]},e.prototype.registerDropZones=function(){this.addDropZoneAbove(),this.addDropZoneBelow()},e.prototype.addDropZoneAbove=function(){var e;if(void 0===this.branch)throw new Error("failed to register drop zone above");var t=this.branch.getParent(),n=this.branch.getCoordinates(),r=n[n.length-1];this.dropZoneAbove=new h(s(null!==(e=null==t?void 0:t.getCoordinates())&&void 0!==e?e:[]),r),this.dropZoneService.addDropZone(this.dropZoneAbove)},e.prototype.addDropZoneBelow=function(){var e;if(void 0===this.branch)throw new Error("failed to register drop zone below");var t=this.branch.getParent(),n=this.branch.getCoordinates(),r=n[n.length-1];this.dropZoneBelow=new h(s(null!==(e=null==t?void 0:t.getCoordinates())&&void 0!==e?e:[]),r+1),this.dropZoneService.addDropZone(this.dropZoneBelow)},e.prototype.updateDropZones=function(){var e;this.currentBranchCoordinates=null===(e=this.branch)||void 0===e?void 0:e.getCoordinates(),this.updateDropZoneAbove(),this.updateDropZoneBelow(),this.updateDropZoneInside(),this.setDropZoneHosts()},e.prototype.updateDropZoneAbove=function(){var e;if(void 0===this.branch||void 0===this.dropZoneAbove)throw new Error("failed to update drop zone above");var t=this.branch.getParent(),n=this.branch.getCoordinates(),r=n[n.length-1],o=this.dropZoneAbove.getLocation();o.setParentCoordinates(s(null!==(e=null==t?void 0:t.getCoordinates())&&void 0!==e?e:[])),o.setInsertIndex(r)},e.prototype.updateDropZoneBelow=function(){var e;if(void 0===this.branch||void 0===this.dropZoneBelow)throw new Error("failed to update drop zone below");var t=this.branch.getParent(),n=this.branch.getCoordinates(),r=n[n.length-1],o=this.dropZoneBelow.getLocation();o.setParentCoordinates(s(null!==(e=null==t?void 0:t.getCoordinates())&&void 0!==e?e:[])),o.setInsertIndex(r+1)},e.prototype.updateDropZoneInside=function(){var e;if(void 0!==(null===(e=this.innerBranch)||void 0===e?void 0:e.dropZoneInside)){if(void 0===this.branch)throw new Error("failed to update drop zone inside");this.innerBranch.dropZoneInside.getLocation().setParentCoordinates(s(this.branch.getCoordinates()))}},e.prototype.setDropZoneHosts=function(){if(void 0===this.dropZoneAbove||void 0===this.dropZoneBelow)throw new Error("could not set drop zone hosts");this.dropZoneAbove.setHost(this.parentHost),this.dropZoneBelow.setHost(this.parentHost)},e.prototype.checkForHandle=function(){var e,t=this;if(void 0!==this.nodeHostContainer&&void 0!==this.draggableDiv){var n,o,i=this.nodeHostContainer.nativeElement.querySelector(".limble-tree-handle"),a=this.draggableDiv.nativeElement;n=this.treeService.treeOptions,o=null===(e=this.branch)||void 0===e?void 0:e.data,void 0===n||!0!==n.allowDragging&&("function"!=typeof n.allowDragging||void 0===o||!0!==n.allowDragging(o))?a.setAttribute("draggable","false"):null===i?a.setAttribute("draggable","true"):i.addEventListener("mousedown",(function(){a.setAttribute("draggable","true");var e=t.dragStateService.state$.pipe(r.filter((function(e){return"dragging"===e})),r.first());t.dragStateService.state$.pipe(r.skipUntil(e),r.filter((function(e){return"idle"===e})),r.first()).subscribe((function(){a.setAttribute("draggable","false")}))}))}},e}();j.ɵfac=function(e){return new(e||j)(t.ɵɵdirectiveInject(Z),t.ɵɵdirectiveInject(t.ChangeDetectorRef),t.ɵɵdirectiveInject(p),t.ɵɵdirectiveInject(f),t.ɵɵdirectiveInject(R),t.ɵɵdirectiveInject(D),t.ɵɵdirectiveInject(t.NgZone),t.ɵɵdirectiveInject(u))},j.ɵcmp=t.ɵɵdefineComponent({type:j,selectors:[["limble-tree-node"]],viewQuery:function(e,n){if(1&e&&(t.ɵɵviewQuery(S,1,t.ViewContainerRef),t.ɵɵviewQuery(I,1,t.ElementRef),t.ɵɵviewQuery(x,1,t.ElementRef),t.ɵɵviewQuery(E,1,w)),2&e){var r=void 0;t.ɵɵqueryRefresh(r=t.ɵɵloadQuery())&&(n.nodeHost=r.first),t.ɵɵqueryRefresh(r=t.ɵɵloadQuery())&&(n.draggableDiv=r.first),t.ɵɵqueryRefresh(r=t.ɵɵloadQuery())&&(n.nodeHostContainer=r.first),t.ɵɵqueryRefresh(r=t.ɵɵloadQuery())&&(n.innerBranch=r.first)}},inputs:{branch:"branch",parentHost:"parentHost"},decls:9,vars:4,consts:[[3,"dropZone",4,"ngIf"],[1,"limble-parent-container",3,"dragstart","dragend"],["draggableDiv",""],[3,"dragoverEventThrottle","dragoverNoChangeDetect"],["nodeHostContainer",""],["nodeHost",""],[3,"branch",4,"ngIf"],[3,"dropZone"],[3,"branch"],["innerBranch",""]],template:function(e,n){1&e&&(t.ɵɵtemplate(0,M,1,1,"drop-zone",0),t.ɵɵelementStart(1,"div",1,2),t.ɵɵlistener("dragstart",(function(e){return n.dragstartHandler(e)}))("dragend",(function(e){return n.dragendHandler(e)})),t.ɵɵelementStart(3,"div",3,4),t.ɵɵlistener("dragoverNoChangeDetect",(function(e){return n.dragoverHandler(e)})),t.ɵɵtemplate(5,F,0,0,"ng-template",null,5,t.ɵɵtemplateRefExtractor),t.ɵɵelementEnd(),t.ɵɵtemplate(7,A,2,1,"limble-tree-branch",6),t.ɵɵelementEnd(),t.ɵɵtemplate(8,O,1,1,"drop-zone",0)),2&e&&(t.ɵɵproperty("ngIf",!0===n.renderDropZoneAbove),t.ɵɵadvance(3),t.ɵɵproperty("dragoverEventThrottle",10),t.ɵɵadvance(4),t.ɵɵproperty("ngIf",void 0!==n.branch&&!0===n.renderInnerBranch),t.ɵɵadvance(1),t.ɵɵproperty("ngIf",!0===n.renderDropZoneBelow))},styles:[".dragging[_ngcontent-%COMP%]{position:absolute;transition:transform .01s;transform:translateX(-9999px)}"]}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(j,[{type:t.Component,args:[{selector:"limble-tree-node",templateUrl:"./limble-tree-node.component.html",styleUrls:["./limble-tree-node.component.scss"]}]}],(function(){return[{type:Z},{type:t.ChangeDetectorRef},{type:p},{type:f},{type:R},{type:D},{type:t.NgZone},{type:u}]}),{branch:[{type:t.Input}],nodeHost:[{type:t.ViewChild,args:["nodeHost",{read:t.ViewContainerRef}]}],draggableDiv:[{type:t.ViewChild,args:["draggableDiv",{read:t.ElementRef}]}],nodeHostContainer:[{type:t.ViewChild,args:["nodeHostContainer",{read:t.ElementRef}]}],parentHost:[{type:t.Input}],innerBranch:[{type:t.ViewChild,args:["innerBranch",{read:w}]}]});var R=function(){function e(e,t,o,i){var a=this;this.componentCreatorService=e,this.dropZoneService=t,this.dragStateService=o,this.treeConstructionStatus=i,this.changes$=new n.Subject,this.drops$=new n.Subject,this.treeModel=new g(null),this.placeholder=!1,this.captured=!1,this.cleanupSignal$=new n.Subject;var s=!1,l=!1,d=this.treeConstructionStatus.stable$.pipe(r.tap((function(e){l=e})),r.filter((function(e){return!0===e})));this.cleanupSignal$.pipe(r.tap((function(e){s=e})),r.debounce((function(){return!0===l?n.EMPTY:d})),r.debounceTime(5)).subscribe((function(){a.cleanup(s),s=!1})),this.placeholder$=new n.BehaviorSubject(!1),this.placeholder$.subscribe((function(e){a.placeholder=e}))}return e.prototype.drop=function(e,t){var n,r=e.getParent();if(null===r)throw new Error("can't drop root of tree");var o,i,a=e.getIndex();if(null==a)throw new Error("Cannot move the hidden root node");if(!0===this.placeholder?(o=[],i=0):i=(o=s(t)).pop(),void 0===i)throw new Error("target coordinates are empty");var d=this.treeModel.getDescendant(o);if(void 0===d)throw new Error("could not get to target");var c=this.dropZoneService.getDropZone(t),h=null==c?void 0:c.getLocation().insertIndex,p=null==c?void 0:c.getHost(),u=null===(n=this.dragStateService.getData())||void 0===n?void 0:n.parentContainer;if(!0===this.placeholder&&this.placeholder$.next(!1),d.insertChild(e,i),void 0===p||void 0===u||void 0===h)return console.warn("Could not perform a precise update. Re-rendering the entire tree instead"),this.render(),void this.changes$.next(null);var v=u.length,f=this.componentCreatorService.appendComponent(j,p,i);f.instance.branch=e,f.instance.parentHost=p,h<a&&u.length>v&&l(r.getCoordinates(),o)?u.remove(a+1):u.remove(a),this.rebuildTreeData(),this.drops$.next({target:e.data,oldParent:r.data,oldIndex:a,newParent:d.data,newIndex:i}),this.cleanupSignal$.next(!1)},e.prototype.init=function(e,t,n,r,o){if(this.host=e,this.originalData=t,this.treeOptions=this.processOptions(n,r,o),!0===this.treeOptions.listMode){var i=this.treeOptions.itemsPerPage*(this.treeOptions.page-1);isNaN(i)&&(i=0);var a=i+this.treeOptions.itemsPerPage;this.treeData=this.originalData.slice(i,a)}else this.treeData=s(this.originalData);this.render()},e.prototype.cleanup=function(e){var t;void 0===e&&(e=!1),e&&this.rebuildTreeData(),0===(null===(t=this.treeData)||void 0===t?void 0:t.length)?this.render():(this.changes$.next(null),this.dropZoneService.update())},e.prototype.render=function(){var e,t,n,r;if(void 0===this.host||void 0===this.treeData||void 0===this.treeOptions)throw new Error("TreeModel not initialized");if(this.treeConstructionStatus.ready(!1),this.host.clear(),this.dropZoneService.restart(),this.placeholder$.next(!1),this.treeModel=new g(null),0===this.treeData.length)this.placeholder$.next(!0);else{try{for(var o=i(this.treeData),a=o.next();!a.done;a=o.next()){var s=a.value,l=new g(s);this.treeModel.appendChild(l)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}try{for(var d=i(this.treeModel.getChildren()),c=d.next();!c.done;c=d.next()){l=c.value;var h=this.componentCreatorService.appendComponent(j,this.host);h.instance.branch=l,h.instance.parentHost=this.host}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}}this.treeConstructionStatus.ready(!0),this.changes$.next(null),this.dropZoneService.init(this.treeModel,this.treeOptions)},e.prototype.renderBranch=function(e,t){var n,r,o,a;if(void 0===this.treeModel)throw new Error("TreeModel not initialized");e.clear(),t.clearChildren();try{for(var s=i(null!==(a=null===(o=t.data)||void 0===o?void 0:o.nodes)&&void 0!==a?a:[]),l=s.next();!l.done;l=s.next()){var d=l.value,c=new g(d);t.appendChild(c);var h=this.componentCreatorService.appendComponent(j,e);h.instance.branch=c,h.instance.parentHost=e}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype.processOptions=function(e,t,n){var r,o,i,a,s;return void 0===e&&(e={}),void 0===t&&(t=1/0),void 0===n&&(n=1),!0===e.listMode&&void 0!==e.allowNesting&&!1!==e.allowNesting&&console.warn("The value of `allowNesting` will be ignored; it must be false when `listMode` is true"),{defaultComponent:e.defaultComponent,indent:null!==(r=e.indent)&&void 0!==r?r:45,allowNesting:!0!==e.listMode&&(null===(o=e.allowNesting)||void 0===o||o),allowDragging:null===(i=e.allowDragging)||void 0===i||i,allowDrop:null!==(a=e.allowDrop)&&void 0!==a?a:function(){return!0},listMode:null!==(s=e.listMode)&&void 0!==s&&s,itemsPerPage:e.listMode?t:void 0,page:e.listMode?n:void 0}},e.prototype.rebuildTreeData=function(){var e,t,n,r;if(void 0===this.originalData||void 0===this.treeData||void 0===this.treeOptions||void 0===this.host)throw new Error("Tree data not initialized");this.treeData=[];try{for(var o=i(this.treeModel.getChildren()),a=o.next();!a.done;a=o.next()){var l=a.value;this.treeData.push(this.rebuildBranch(l))}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}if(!0===this.treeOptions.listMode&&this.treeOptions.itemsPerPage<1/0){var d=this.treeOptions.itemsPerPage,c=d*(this.treeOptions.page-1);if((n=this.originalData).splice.apply(n,s([c,d],this.treeData)),this.treeData.length!==d){var h=!1;if(this.treeData.length<d&&c+d<=this.originalData.length){for(var p=d-this.treeData.length,u=d-1;u<d+p-1;u++){l=new g(this.originalData[c+u]);this.treeModel.appendChild(l);var v=this.componentCreatorService.appendComponent(j,this.host);v.instance.branch=l,v.instance.parentHost=this.host}h=!0}else if(this.treeData.length>d){for(u=d+(p=this.treeData.length-d)-1;u>=d;u--)this.treeModel.removeChild(u),this.host.remove(u);h=!0}if(!0===h){var f=c+d;this.treeData=this.originalData.slice(c,f)}}}else this.originalData.length=0,(r=this.originalData).push.apply(r,s(this.treeData))},e.prototype.rebuildBranch=function(e){var t,n,r=e.data;r.nodes=[];try{for(var o=i(e.getChildren()),a=o.next();!a.done;a=o.next()){var s=a.value;r.nodes.push(this.rebuildBranch(s))}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return r},e}();R.ɵfac=function(e){return new(e||R)(t.ɵɵinject(Z),t.ɵɵinject(f),t.ɵɵinject(p),t.ɵɵinject(u))},R.ɵprov=t.ɵɵdefineInjectable({token:R,factory:R.ɵfac}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(R,[{type:t.Injectable}],(function(){return[{type:Z},{type:f},{type:p},{type:u}]}),null);var H=function(){function e(e,n){this.ngZone=e,this.el=n,this.dragoverNoChangeDetect=new t.EventEmitter,this.dragoverEventThrottle=0}return e.prototype.ngOnInit=function(){var e=this;this.ngZone.runOutsideAngular((function(){e.eventSubscription=n.fromEvent(e.el.nativeElement,"dragover").pipe(r.throttleTime(e.dragoverEventThrottle)).subscribe((function(t){e.dragoverNoChangeDetect.emit(t)}))}))},e.prototype.ngOnDestroy=function(){void 0!==this.eventSubscription&&this.eventSubscription.unsubscribe()},e}();H.ɵfac=function(e){return new(e||H)(t.ɵɵdirectiveInject(t.NgZone),t.ɵɵdirectiveInject(t.ElementRef))},H.ɵdir=t.ɵɵdefineDirective({type:H,selectors:[["","dragoverNoChangeDetect",""]],inputs:{dragoverEventThrottle:"dragoverEventThrottle"},outputs:{dragoverNoChangeDetect:"dragoverNoChangeDetect"}}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(H,[{type:t.Directive,args:[{selector:"[dragoverNoChangeDetect]"}]}],(function(){return[{type:t.NgZone},{type:t.ElementRef}]}),{dragoverEventThrottle:[{type:t.Input}],dragoverNoChangeDetect:[{type:t.Output}]});var P=function(){function e(e,n){this.ngZone=e,this.el=n,this.dragleaveNoChangeDetect=new t.EventEmitter}return e.prototype.ngOnInit=function(){var e=this;this.ngZone.runOutsideAngular((function(){e.eventSubscription=n.fromEvent(e.el.nativeElement,"dragleave").subscribe((function(t){e.dragleaveNoChangeDetect.emit(t)}))}))},e.prototype.ngOnDestroy=function(){void 0!==this.eventSubscription&&this.eventSubscription.unsubscribe()},e}();P.ɵfac=function(e){return new(e||P)(t.ɵɵdirectiveInject(t.NgZone),t.ɵɵdirectiveInject(t.ElementRef))},P.ɵdir=t.ɵɵdefineDirective({type:P,selectors:[["","dragleaveNoChangeDetect",""]],outputs:{dragleaveNoChangeDetect:"dragleaveNoChangeDetect"}}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(P,[{type:t.Directive,args:[{selector:"[dragleaveNoChangeDetect]"}]}],(function(){return[{type:t.NgZone},{type:t.ElementRef}]}),{dragleaveNoChangeDetect:[{type:t.Output}]});var N=function(e,t){return{active:e,related:t}};function B(e,n){if(1&e){var r=t.ɵɵgetCurrentView();t.ɵɵelementStart(0,"div",1),t.ɵɵlistener("dragenter",(function(){return t.ɵɵrestoreView(r),t.ɵɵnextContext().dragenterHandler()})),t.ɵɵelement(1,"div",2),t.ɵɵelementEnd()}if(2&e){var o=t.ɵɵnextContext();t.ɵɵadvance(1),t.ɵɵproperty("ngClass",t.ɵɵpureFunction2(1,N,o.active,!o.active))}}var T=function(){function e(e,t){this.dropZoneService=e,this.changeDetectorRef=t,this.visible=!1,this.active=!1}return e.prototype.dragenterHandler=function(){void 0!==this.dropZone&&!0!==this.active&&this.dropZoneService.swapActiveDropZone(this.dropZone)},e.prototype.ngOnInit=function(){var e=this;if(void 0===this.dropZone)throw new Error("No drop zone object at component initialization");this.commSubscription=this.dropZone.getCommChannel().subscribe((function(t){var n,r,o,i;switch(t){case"checkVisible":e.visible=null!==(r=null===(n=e.dropZone)||void 0===n?void 0:n.isVisible())&&void 0!==r&&r;break;case"checkActive":e.active=null!==(i=null===(o=e.dropZone)||void 0===o?void 0:o.isActive())&&void 0!==i&&i;break;case"checkRendered":break;default:throw new Error("unhandled comm message")}e.changeDetectorRef.detectChanges()}))},e.prototype.ngOnDestroy=function(){void 0!==this.commSubscription&&this.commSubscription.unsubscribe()},e}();T.ɵfac=function(e){return new(e||T)(t.ɵɵdirectiveInject(f),t.ɵɵdirectiveInject(t.ChangeDetectorRef))},T.ɵcmp=t.ɵɵdefineComponent({type:T,selectors:[["drop-zone"]],inputs:{dropZone:"dropZone"},decls:1,vars:1,consts:[["class","dropZoneContainer",3,"dragenter",4,"ngIf"],[1,"dropZoneContainer",3,"dragenter"],[3,"ngClass"]],template:function(e,n){1&e&&t.ɵɵtemplate(0,B,2,4,"div",0),2&e&&t.ɵɵproperty("ngIf",n.visible)},directives:[o.NgIf,o.NgClass],styles:[".active[_ngcontent-%COMP%]{height:105px;border-radius:5px;background:#f0f9ff;border:2px dashed #bed2db}.active[_ngcontent-%COMP%], .related[_ngcontent-%COMP%]{margin:10px 0;width:calc(100% - 20px);box-sizing:border-box}.related[_ngcontent-%COMP%]{height:30px;border-radius:5px;background:#fff6f0;border:1px dashed #dbccbe;opacity:.8}.dropZoneContainer[_ngcontent-%COMP%]{position:relative}"],changeDetection:0}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(T,[{type:t.Component,args:[{selector:"drop-zone",templateUrl:"./drop-zone.component.html",styleUrls:["./drop-zone.component.scss"],changeDetection:t.ChangeDetectionStrategy.OnPush}]}],(function(){return[{type:f},{type:t.ChangeDetectorRef}]}),{dropZone:[{type:t.Input}]});var $=function(){function e(e,t,n,r){var o=this;this.dropZoneService=e,this.changeDetectorRef=t,this.treeService=n,this.treeConstructionStatus=r,this.treeConstructionStatus.constructing(),this.placeholderSubscription=this.treeService.placeholder$.subscribe((function(e){void 0!==o.dropZone&&(o.dropZoneService.removeDropZone(o.dropZone),!0===e&&(o.dropZoneService.addDropZone(o.dropZone),o.dropZone.setHost(o.treeService.host)))}))}return e.prototype.ngOnInit=function(){this.dropZone=new h([],0),this.dropZoneService.addDropZone(this.dropZone)},e.prototype.ngAfterViewInit=function(){if(void 0===this.dropZone)throw new Error("placeholder drop zone is not defined");this.dropZone.setHost(this.treeService.host),this.treeConstructionStatus.doneConstructing(),this.changeDetectorRef.detectChanges()},e.prototype.dragoverHandler=function(){void 0!==this.dropZone&&this.dropZoneService.showDropZoneFamily(this.dropZone)},e.prototype.ngOnDestroy=function(){if(this.placeholderSubscription.unsubscribe(),void 0===this.dropZone)throw new Error("could not remove placeholder drop zone");this.dropZoneService.removeDropZone(this.dropZone)},e}();$.ɵfac=function(e){return new(e||$)(t.ɵɵdirectiveInject(f),t.ɵɵdirectiveInject(t.ChangeDetectorRef),t.ɵɵdirectiveInject(R),t.ɵɵdirectiveInject(u))},$.ɵcmp=t.ɵɵdefineComponent({type:$,selectors:[["limble-tree-placeholder"]],decls:2,vars:1,consts:[[3,"dropZone"],[1,"placeholder",3,"dragoverNoChangeDetect"]],template:function(e,n){1&e&&(t.ɵɵelement(0,"drop-zone",0),t.ɵɵelementStart(1,"div",1),t.ɵɵlistener("dragoverNoChangeDetect",(function(){return n.dragoverHandler()})),t.ɵɵelementEnd()),2&e&&t.ɵɵproperty("dropZone",n.dropZone)},directives:[T,H],styles:[".placeholder[_ngcontent-%COMP%]{width:100%;height:20px}"],changeDetection:0}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata($,[{type:t.Component,args:[{selector:"limble-tree-placeholder",templateUrl:"./limble-tree-placeholder.component.html",styleUrls:["./limble-tree-placeholder.component.scss"],changeDetection:t.ChangeDetectionStrategy.OnPush}]}],(function(){return[{type:f},{type:t.ChangeDetectorRef},{type:R},{type:u}]}),null);var z=["host"];function L(e,n){1&e&&t.ɵɵelement(0,"limble-tree-placeholder")}function V(e,t){}var k=function(){function e(e,n,r,o,i){var a=this;this.treeService=e,this.dropZoneService=n,this.dragStateService=r,this.globalEventsService=o,this.changeDetectorRef=i,this.treeChange=new t.EventEmitter,this.treeDrop=new t.EventEmitter,this.changesSubscription=this.treeService.changes$.subscribe((function(){setTimeout((function(){a.treeChange.emit()}))})),this.dropSubscription=this.treeService.drops$.subscribe((function(e){setTimeout((function(){a.treeDrop.emit(e)}))})),this.placeholder=!1,this.treeService.placeholder$.subscribe((function(e){a.placeholder=e,t.NgZone.isInAngularZone()||a.changeDetectorRef.detectChanges()}))}return e.prototype.ngAfterViewInit=function(){var e;!0===(null===(e=this.options)||void 0===e?void 0:e.listMode)||void 0===this.itemsPerPage&&void 0===this.page||console.warn("pagination is only allowed in listMode; `itemsPerPage` and `page` inputs will be ignored"),this.update(),this.changeDetectorRef.detectChanges()},e.prototype.ngOnChanges=function(){void 0!==this.host&&void 0!==this.data&&this.update()},e.prototype.update=function(){if(void 0===this.host)throw new Error("Failed to render limble tree. Failure occurred at root.");if(void 0===this.data)throw new Error("limbleTree requires a data object");this.treeService.init(this.host,this.data,this.options,this.itemsPerPage,this.page),this.globalEventsService.addScrolling()},e.prototype.dragoverHandler=function(e){null!==e.dataTransfer&&(e.stopPropagation(),e.preventDefault(),e.dataTransfer.dropEffect="move")},e.prototype.dragleaveHandler=function(e){var t=e.currentTarget,n=e.relatedTarget;t instanceof Node&&n instanceof Node&&!1===function(e,t){if(e===t)return!0;for(var n=t.parentNode;n!==document;){if(null===n)return;if(n===e)return!0;n=n.parentNode}return!1}(t,n)&&(this.dropZoneService.clearVisibleZones(),this.changeDetectorRef.detectChanges())},e.prototype.dropHandler=function(e){var t=this;if(e.stopPropagation(),"droppable"===this.dragStateService.getState()){var n=this.dragStateService.capture();if(void 0===n)throw new Error("failed to get current branch in dragendHandler");var o=this.dropZoneService.getActiveDropZone();if(null===o)throw new Error("failed to get active drop zone at drop handler");this.treeService.captured=!0,this.dragStateService.state$.pipe(r.first((function(e){return"idle"===e}))).subscribe((function(){t.treeService.captured=!1})),this.dropZoneService.clearVisibleZones(),this.treeService.drop(n,o.getFullInsertCoordinates())}},e.prototype.ngOnDestroy=function(){this.changesSubscription.unsubscribe(),this.dropSubscription.unsubscribe()},e}();k.ɵfac=function(e){return new(e||k)(t.ɵɵdirectiveInject(R),t.ɵɵdirectiveInject(f),t.ɵɵdirectiveInject(p),t.ɵɵdirectiveInject(D),t.ɵɵdirectiveInject(t.ChangeDetectorRef))},k.ɵcmp=t.ɵɵdefineComponent({type:k,selectors:[["limble-tree-root"]],viewQuery:function(e,n){if(1&e&&t.ɵɵviewQuery(z,1,t.ViewContainerRef),2&e){var r;t.ɵɵqueryRefresh(r=t.ɵɵloadQuery())&&(n.host=r.first)}},inputs:{data:"data",options:"options",itemsPerPage:"itemsPerPage",page:"page"},outputs:{treeChange:"treeChange",treeDrop:"treeDrop"},features:[t.ɵɵProvidersFeature([R,f,u]),t.ɵɵNgOnChangesFeature],decls:4,vars:1,consts:[[3,"dragoverNoChangeDetect","dragleaveNoChangeDetect","drop"],[4,"ngIf"],["host",""]],template:function(e,n){1&e&&(t.ɵɵelementStart(0,"div",0),t.ɵɵlistener("dragoverNoChangeDetect",(function(e){return n.dragoverHandler(e)}))("dragleaveNoChangeDetect",(function(e){return n.dragleaveHandler(e)}))("drop",(function(e){return n.dropHandler(e)})),t.ɵɵtemplate(1,L,1,0,"limble-tree-placeholder",1),t.ɵɵtemplate(2,V,0,0,"ng-template",null,2,t.ɵɵtemplateRefExtractor),t.ɵɵelementEnd()),2&e&&(t.ɵɵadvance(1),t.ɵɵproperty("ngIf",!0===n.placeholder))},directives:[H,P,o.NgIf,$],styles:[""]}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(k,[{type:t.Component,args:[{selector:"limble-tree-root",templateUrl:"./limble-tree-root.component.html",styleUrls:["./limble-tree-root.component.scss"],providers:[R,f,u]}]}],(function(){return[{type:R},{type:f},{type:p},{type:D},{type:t.ChangeDetectorRef}]}),{data:[{type:t.Input}],options:[{type:t.Input}],itemsPerPage:[{type:t.Input}],page:[{type:t.Input}],host:[{type:t.ViewChild,args:["host",{read:t.ViewContainerRef}]}],treeChange:[{type:t.Output}],treeDrop:[{type:t.Output}]});var q=function(){};q.ɵfac=function(e){return new(e||q)},q.ɵmod=t.ɵɵdefineNgModule({type:q}),q.ɵinj=t.ɵɵdefineInjector({providers:[Z,p,D],imports:[[o.CommonModule]]}),("undefined"==typeof ngJitMode||ngJitMode)&&t.ɵɵsetNgModuleScope(q,{declarations:[w,T,j,k,$,H,P],imports:[o.CommonModule],exports:[k]}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(q,[{type:t.NgModule,args:[{declarations:[w,T,j,k,$,H,P],imports:[o.CommonModule],exports:[k],providers:[Z,p,D]}]}],null,null),t.ɵɵsetComponentScope(w,[o.NgIf,T],[]),t.ɵɵsetComponentScope(j,[o.NgIf,T,H,w],[]),e.LimbleTreeModule=q,e.LimbleTreeRootComponent=k,Object.defineProperty(e,"__esModule",{value:!0})}));
***************************************************************************** */Object.create;function i(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function s(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(a(arguments[t]));return e}Object.create;function l(e,t){var n,r;if(e.length!==t.length)return!1;try{for(var o=i(e.entries()),s=o.next();!s.done;s=o.next()){var d=a(s.value,2),c=d[0],h=d[1],p=t[c];if(h instanceof Array&&p instanceof Array){if(!l(h,p))return!1}else if(h!==p)return!1}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return!0}function d(e,t){return void 0!==e&&(!0===e.allowNesting||"function"==typeof e.allowNesting&&void 0!==t&&!0===e.allowNesting(t))}var c=function(){function e(e,t){this.parentCoordinates=e,this.insertIndex=t}return e.prototype.getFullInsertCoordinates=function(){return s(this.parentCoordinates,[this.insertIndex])},e.prototype.setParentCoordinates=function(e){this.parentCoordinates=e},e.prototype.setInsertIndex=function(e){this.insertIndex=e},e}(),h=function(){function e(e,t){this.location=new c(e,t),this.rendered=!1,this.visible=!1,this.active=!1,this.commChannel=new n.Subject}return e.dropZoneLocationsAreEqual=function(e,t){return l(e.getFullInsertCoordinates(),t.getFullInsertCoordinates())},e.prototype.isRendered=function(e){return void 0===e&&(e=void 0),void 0!==e&&(this.rendered=e,void 0!==this.commChannel&&this.commChannel.next("checkRendered"),!1===this.rendered&&this.isVisible(!1)),this.rendered},e.prototype.isVisible=function(e){return void 0===e&&(e=void 0),void 0!==e&&(this.visible=e,void 0!==this.commChannel&&this.commChannel.next("checkVisible"),!1===this.visible&&this.isActive(!1)),this.visible},e.prototype.isActive=function(e){return void 0===e&&(e=void 0),void 0!==e&&(this.active=e,void 0!==this.commChannel&&this.commChannel.next("checkActive")),this.active},e.prototype.getLocation=function(){return this.location},e.prototype.getFamily=function(){return this.family},e.prototype.setFamily=function(e){this.family=e},e.prototype.getCommChannel=function(){return this.commChannel},e.prototype.getFullInsertCoordinates=function(){return this.location.getFullInsertCoordinates()},e.prototype.setHost=function(e){return this.host=e,this.host},e.prototype.getHost=function(){return this.host},e}(),p=function(){function e(){this.state="idle",this.state$=new n.BehaviorSubject(this.state)}return e.prototype.dragging=function(e,t){this._tempData={branch:e,parentContainer:t},this.state="dragging",this.state$.next(this.state)},e.prototype.droppable=function(){if("dragging"!==this.state)throw new Error("Can only call `droppable` when state is `dragging`");this.state="droppable",this.state$.next(this.state)},e.prototype.notDroppable=function(){if("droppable"!==this.state)throw new Error("Can only call `notDroppable` when state is `droppable`");this.state="dragging",this.state$.next(this.state)},e.prototype.capture=function(){var e;if("droppable"!==this.state)throw new Error("Can only move to `captured` state from `droppable` state");return this.state="captured",this.state$.next(this.state),null===(e=this._tempData)||void 0===e?void 0:e.branch},e.prototype.release=function(){this._tempData=void 0,this.state="idle",this.state$.next(this.state)},e.prototype.getData=function(){return this._tempData},e.prototype.getState=function(){return this.state},e}();p.ɵfac=function(e){return new(e||p)},p.ɵprov=t.ɵɵdefineInjectable({token:p,factory:p.ɵfac}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(p,[{type:t.Injectable}],(function(){return[]}),null);var u=function(){function e(){this.beingBuilt=0,this.isReady=!1,this.stable$=new n.BehaviorSubject(this.treeIsStable())}return e.prototype.constructing=function(){this.beingBuilt++,this.emit()},e.prototype.doneConstructing=function(){this.beingBuilt--,this.emit()},e.prototype.treeIsStable=function(){return!0===this.isReady&&0===this.beingBuilt},e.prototype.ready=function(e){this.isReady=e},e.prototype.emit=function(){this.stable$.next(this.treeIsStable())},e}();function v(e,t){var n=e.getFullInsertCoordinates(),r=t.getFullInsertCoordinates();return n.length>r.length?-1:n.length<r.length?1:0}u.ɵfac=function(e){return new(e||u)},u.ɵprov=t.ɵɵdefineInjectable({token:u,factory:u.ɵfac}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(u,[{type:t.Injectable}],(function(){return[]}),null);var f=function(){function e(e,t){var o=this;this.dragStateService=e,this.dropZoneArchive=new Set,this.dropZoneInventory=[],this.dropZoneFamilies=[],this.visibleFamily=null,this.activeDropZone=null,this.tempFamilies=[],this.setActiveDropZone(null);var i=!1,a=t.stable$.pipe(r.tap((function(e){i=e})),r.filter((function(e){return!0===e})));this.update$=new n.Subject,this.update$.pipe(r.debounce((function(){return!0===i?n.EMPTY:a}))).subscribe((function(){setTimeout((function(){o.updateDropZones()}))}))}return e.prototype.addDropZone=function(e){this.dropZoneArchive.add(e)},e.prototype.clearVisibleZones=function(){var e,t;if(null!==this.visibleFamily){try{for(var n=i(this.visibleFamily.members),r=n.next();!r.done;r=n.next()){r.value.isVisible(!1)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this.visibleFamily=null}this.setActiveDropZone(null)},e.prototype.getActiveDropZone=function(){return this.activeDropZone},e.prototype.getDropZone=function(e){var t=s(e);t.pop();var n=e[e.length-1],r=new c(t,n);return this.dropZoneInventory.find((function(e){return h.dropZoneLocationsAreEqual(e,r)}))},e.prototype.init=function(e,t){this.tree=e,this.treeOptions=t,this.update()},e.prototype.removeDropZone=function(e){this.dropZoneArchive.delete(e)},e.prototype.reset=function(){this.clearVisibleZones(),this.dropZoneFamilies.length=0,this.dropZoneInventory.length=0},e.prototype.restart=function(){this.reset(),this.dropZoneArchive.clear()},e.prototype.restoreFamilies=function(){var e,t,n,r;if(2===this.tempFamilies.length){this.dropZoneFamilies.pop(),this.dropZoneFamilies.push(this.tempFamilies[0]);try{for(var o=i(this.tempFamilies[0].members),a=o.next();!a.done;a=o.next()){a.value.setFamily(this.tempFamilies[0])}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}if(null!==this.tempFamilies[1]){this.dropZoneFamilies.push(this.tempFamilies[1]);try{for(var s=i(this.tempFamilies[1].members),l=s.next();!l.done;l=s.next()){l.value.setFamily(this.tempFamilies[1])}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}}this.tempFamilies=[]}},e.prototype.showDropZoneFamily=function(e,t){var n,r,o,a,l,d;if(void 0===t&&(t={joinFamilies:!1,activateLowestInsteadOfFounder:!1}),null===this.activeDropZone||!h.dropZoneLocationsAreEqual(this.activeDropZone,e)){null===this.visibleFamily&&null===this.activeDropZone||this.clearVisibleZones();var p=this.dropZoneInventory.find((function(t){return h.dropZoneLocationsAreEqual(t,e)}));if(void 0===p)throw new Error("Could not find drop zone to show. location: "+JSON.stringify(e.getLocation()));var u=p.getFamily();if(!0===t.joinFamilies){var f=e.getLocation(),g=new c(s(f.parentCoordinates),f.insertIndex+1),y=this.dropZoneInventory.find((function(e){return h.dropZoneLocationsAreEqual(e,g)}));if(void 0===y)throw new Error("Could not find drop zone to show");var m=y.getFamily();if(void 0===u||void 0===m)throw new Error("No family");var b={founder:u.founder,members:s(u.members)};this.showDropZone(u.founder,!0);try{for(var w=i(u.members.sort(v)),Z=w.next();!Z.done;Z=w.next()){(M=Z.value).setFamily(b),M!==u.founder&&(null===this.activeDropZone?this.showDropZone(M,!0):this.showDropZone(M))}}catch(e){n={error:e}}finally{try{Z&&!Z.done&&(r=w.return)&&r.call(w)}finally{if(n)throw n.error}}try{for(var C=i(m.members),D=C.next();!D.done;D=C.next()){(M=D.value).setFamily(b),M.getLocation().parentCoordinates.length<y.getLocation().parentCoordinates.length&&(b.members.push(M),this.showDropZone(M))}}catch(e){o={error:e}}finally{try{D&&!D.done&&(a=C.return)&&a.call(C)}finally{if(o)throw o.error}}this.tempFamilies=[u,m];var S=this.dropZoneFamilies.indexOf(u);this.dropZoneFamilies.splice(S,1);var I=this.dropZoneFamilies.indexOf(m);this.dropZoneFamilies.splice(I,1),this.dropZoneFamilies.push(b),this.visibleFamily=b}else{if(void 0===u)throw new Error("No family");if(this.visibleFamily=u,this.showDropZone(u.founder,!0),u.members.length>1)try{for(var x=i(u.members.sort(v)),E=x.next();!E.done;E=x.next()){var M;(M=E.value)!==u.founder&&(null===this.activeDropZone?this.showDropZone(M,!0):this.showDropZone(M))}}catch(e){l={error:e}}finally{try{E&&!E.done&&(d=x.return)&&d.call(x)}finally{if(l)throw l.error}}}if(!0===t.activateLowestInsteadOfFounder&&this.visibleFamily.members.length>1){var F=s(this.visibleFamily.members).sort(v).pop();if(void 0===F)throw new Error("Could not get lowest member");this.swapActiveDropZone(F)}}},e.prototype.swapActiveDropZone=function(e){if(null===this.visibleFamily)throw new Error("No visible family available for swapping");if(-1===this.visibleFamily.members.findIndex((function(t){return t===e})))throw new Error("failed to swap active drop zone");this.setActiveDropZone(e)},e.prototype.update=function(){this.update$.next(null)},e.prototype.assignFamilies=function(){var e,t,n,r,o,a,d=s(this.dropZoneInventory),c=d.filter((function(e){var t=e.getLocation();return 0===t.insertIndex&&t.parentCoordinates.length>0})).sort((function(e,t){for(var n,r,o,i,a=e.getFullInsertCoordinates(),s=t.getFullInsertCoordinates(),l=Math.max(a.length,s.length),d=0;d<l;d++){if((null!==(n=a[d])&&void 0!==n?n:-1)>(null!==(r=s[d])&&void 0!==r?r:-1))return-1;if((null!==(o=a[d])&&void 0!==o?o:-1)<(null!==(i=s[d])&&void 0!==i?i:-1))return 1}return 0})),h=function(e){if(!d.includes(e))return"continue";var t={founder:e,members:[]};e.setFamily(t);for(var n=s(e.getFullInsertCoordinates());n.length>0;){var r=d.findIndex((function(e){return l(e.getFullInsertCoordinates(),n)}));if(-1!==r){var o=d.splice(r,1)[0];t.members.push(o),o.setFamily(t)}n.pop(),n[n.length-1]++}p.dropZoneFamilies.push(t)},p=this;try{for(var u=i(c),v=u.next();!v.done;v=u.next()){h(y=v.value)}}catch(t){e={error:t}}finally{try{v&&!v.done&&(t=u.return)&&t.call(u)}finally{if(e)throw e.error}}try{for(var f=i(d.filter((function(e){return 1===e.getFullInsertCoordinates().length}))),g=f.next();!g.done;g=f.next()){var y,m={founder:y=g.value,members:[y]};y.setFamily(m),this.dropZoneFamilies.push(m),d.splice(d.indexOf(y),1)}}catch(e){n={error:e}}finally{try{g&&!g.done&&(r=f.return)&&r.call(f)}finally{if(n)throw n.error}}if(0!==d.length){var b="";try{for(var w=i(d),Z=w.next();!Z.done;Z=w.next()){var C=Z.value;b+=JSON.stringify(C.getLocation())+", "}}catch(e){o={error:e}}finally{try{Z&&!Z.done&&(a=w.return)&&a.call(w)}finally{if(o)throw o.error}}throw b=b.slice(0,b.length-2),new Error("Some zones were not assigned to a family. The orphan zones have the following locations: "+b)}},e.prototype.buildInventory=function(){var e,t,n=[];try{for(var r=i(this.dropZoneArchive),o=r.next();!o.done;o=r.next()){var a=o.value,s=a.getFullInsertCoordinates().join(",");n.includes(s)?a.isRendered(!1):(this.dropZoneInventory.push(a),n.push(s),a.isRendered(!0))}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},e.prototype.setActiveDropZone=function(e){null!==this.activeDropZone&&this.activeDropZone.isActive(!1),this.activeDropZone=e,null!==this.activeDropZone&&"droppable"!==this.dragStateService.getState()?this.dragStateService.droppable():null===this.activeDropZone&&"droppable"===this.dragStateService.getState()&&this.dragStateService.notDroppable(),null!==this.activeDropZone&&this.activeDropZone.isActive(!0)},e.prototype.showDropZone=function(e,t){if(void 0===t&&(t=!1),void 0===this.tree)throw new Error("DropZoneService not initialized");if(!this.zoneIsAllowed(e))return!1;if(void 0===this.tree.findByCoordinates(e.getLocation().parentCoordinates))throw new Error("Bad family member");return e.isVisible(!0),!0===t&&this.setActiveDropZone(e),!0},e.prototype.updateDropZones=function(){this.reset(),this.buildInventory(),this.assignFamilies()},e.prototype.zoneIsAllowed=function(e){if(void 0===this.treeOptions||void 0===this.tree)throw new Error("dropZoneService not initialized");var t=this.dragStateService.getData();if(void 0===t)throw new Error("Can't get dragged node");var n=this.tree.findByCoordinates(e.getLocation().parentCoordinates);if(void 0===n)throw new Error("Could not get drop zone parent");var r=e.getLocation().insertIndex;if(void 0===r)throw new Error("Could not get drop zone index");var o=t.branch;return!!this.treeOptions.allowDrop(o.data,n.data,r)},e}();f.ɵfac=function(e){return new(e||f)(t.ɵɵinject(p),t.ɵɵinject(u))},f.ɵprov=t.ɵɵdefineInjectable({token:f,factory:f.ɵfac}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(f,[{type:t.Injectable}],(function(){return[{type:p},{type:u}]}),null);var g=function(){function e(e){this.data=e,this.children=[],this.parent=null}return e.prototype.isRoot=function(){return null===this.parent},e.prototype.getParent=function(){return this.parent},e.prototype.setParent=function(e){this.parent=e},e.prototype.findByCoordinates=function(e){var t,n,r=this;try{for(var o=i(e.values()),a=o.next();!a.done;a=o.next()){var s=a.value;if(void 0===(r=r.getChild(s)))return}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return r},e.prototype.getCoordinates=function(){for(var e=[],t=this;null!==t.parent;){var n=t.getIndex();if(null==n)throw new Error("Could not get cursor index");e.unshift(n),t=t.parent}return e},e.prototype.getChild=function(e){return this.children[e]},e.prototype.getChildren=function(){return this.children},e.prototype.clearChildren=function(){var e,t;try{for(var n=i(this.children),r=n.next();!r.done;r=n.next()){r.value.setParent(null)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this.children.length=0},e.prototype.getIndex=function(){var e=this;if(null===this.parent)return null;var t=this.parent.children.findIndex((function(t){return t===e}));return-1!==t?t:void 0},e.prototype.getDescendant=function(e){var t,n,r=this;try{for(var o=i(e),a=o.next();!a.done;a=o.next()){var s=a.value;if(void 0===(r=r.children[s]))return}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return r},e.prototype.findDescendant=function(e){var t,n;if(!0===e(this.data))return this;if(this.children.length>0)try{for(var r=i(this.children),o=r.next();!o.done;o=r.next()){var a=o.value.findDescendant(e);if(void 0!==a)return a}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},e.prototype.getAncestors=function(){for(var e=[],t=this;null!==t.parent;)e.push(t.parent),t=t.parent;return e},e.prototype.appendChild=function(e){return null!==e.getParent()&&e.remove(),e.setParent(this),this.children.push(e),e},e.prototype.insertChild=function(e,t){var n=this.children.indexOf(e);return-1===n?(null!==e.getParent()&&e.remove(),e.setParent(this),this.children.splice(t,0,e)):t>n?(this.children.splice(t,0,e),this.removeChild(n),e.setParent(this)):(e.remove(),this.children.splice(t,0,e),e.setParent(this)),e},e.prototype.removeChild=function(e){var t=this.children.splice(e,1)[0];return t.setParent(null),t},e.prototype.remove=function(){var e=this.getIndex();if(null===this.parent||null==e)throw new Error("can't remove root");return this.parent.removeChild(e)},e.prototype.copy=function(){var e=this.copyHelper();return e.setParent(null),e},e.prototype.copyHelper=function(){var t,n,r=new e(this.data);try{for(var o=i(this.children),a=o.next();!a.done;a=o.next()){var s=a.value;r.appendChild(s.copyHelper()).parent=r}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return r},e}(),y=["children"];function m(e,n){if(1&e&&t.ɵɵelement(0,"drop-zone",3),2&e){var r=t.ɵɵnextContext();t.ɵɵproperty("dropZone",r.dropZoneInside)}}function b(e,t){}var w=function(){function e(e,t,n,r,o){var i;this.treeService=e,this.changeDetectorRef=t,this.dropZoneService=n,this.treeConstructionStatus=r,this.ngZone=o,this.treeConstructionStatus.constructing(),this.indent=null===(i=this.treeService.treeOptions)||void 0===i?void 0:i.indent,this.renderDropZoneInside=!1}return e.prototype.ngOnInit=function(){var e=this;this.addDropZoneInside(),this.ngZone.runOutsideAngular((function(){if(void 0===e.dropZoneInside)throw new Error("drop zone inside is not defined");e.dropZoneInside.getCommChannel().pipe(r.filter((function(e){return"checkRendered"===e}))).subscribe((function(){if(void 0===e.dropZoneInside||void 0===e.branch)throw new Error("Zones not registered");d(e.treeService.treeOptions,e.branch.data)&&(e.renderDropZoneInside=e.dropZoneInside.isRendered())}))}))},e.prototype.ngAfterViewInit=function(){this.reRender(),this.setDropZoneHost(),this.treeConstructionStatus.doneConstructing(),this.changeDetectorRef.detectChanges()},e.prototype.ngOnDestroy=function(){void 0!==this.dropZoneInside&&this.dropZoneService.removeDropZone(this.dropZoneInside),this.treeService.cleanupSignal$.next(!0)},e.prototype.addDropZoneInside=function(){if(void 0===this.branch)throw new Error("failed to register drop zone inside");this.dropZoneInside=new h(s(this.branch.getCoordinates()),0),this.dropZoneService.addDropZone(this.dropZoneInside)},e.prototype.reRender=function(){if(void 0===this.children||void 0===this.branch)throw new Error("Failed to render limble tree branch");this.treeService.renderBranch(this.children,this.branch)},e.prototype.setDropZoneHost=function(){if(void 0===this.children||void 0===this.dropZoneInside)throw new Error("Failed to add drop zone host");this.dropZoneInside.setHost(this.children)},e}();w.ɵfac=function(e){return new(e||w)(t.ɵɵdirectiveInject(R),t.ɵɵdirectiveInject(t.ChangeDetectorRef),t.ɵɵdirectiveInject(f),t.ɵɵdirectiveInject(u),t.ɵɵdirectiveInject(t.NgZone))},w.ɵcmp=t.ɵɵdefineComponent({type:w,selectors:[["limble-tree-branch"]],viewQuery:function(e,n){if(1&e&&t.ɵɵviewQuery(y,1,t.ViewContainerRef),2&e){var r;t.ɵɵqueryRefresh(r=t.ɵɵloadQuery())&&(n.children=r.first)}},inputs:{branch:"branch"},decls:5,vars:4,consts:[[3,"dropZone",4,"ngIf"],[1,"limble-child-nodes",3,"hidden"],["children",""],[3,"dropZone"]],template:function(e,n){1&e&&(t.ɵɵelementStart(0,"div"),t.ɵɵtemplate(1,m,1,1,"drop-zone",0),t.ɵɵelementStart(2,"span",1),t.ɵɵtemplate(3,b,0,0,"ng-template",null,2,t.ɵɵtemplateRefExtractor),t.ɵɵelementEnd(),t.ɵɵelementEnd()),2&e&&(t.ɵɵstyleProp("margin-left",n.indent,"px"),t.ɵɵadvance(1),t.ɵɵproperty("ngIf",n.renderDropZoneInside),t.ɵɵadvance(1),t.ɵɵproperty("hidden",n.branch&&n.branch.data.collapsed))},styles:["./limble-tree-branch.component.scss"]}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(w,[{type:t.Component,args:[{selector:"limble-tree-branch",templateUrl:"./limble-tree-branch.component.html",styles:["./limble-tree-branch.component.scss"]}]}],(function(){return[{type:R},{type:t.ChangeDetectorRef},{type:f},{type:u},{type:t.NgZone}]}),{branch:[{type:t.Input}],children:[{type:t.ViewChild,args:["children",{read:t.ViewContainerRef}]}]});var Z=function(){function e(e){this.factoryResolver=e,this.factoryResolver=e}return e.prototype.appendComponent=function(e,t,n){void 0===n&&(n=void 0);var r=this.factoryResolver.resolveComponentFactory(e);return t.createComponent(r,n)},e}();function C(e){var t,n,r,o=/(auto|scroll)/,a=function(e,t){return null===e||null===e.parentNode?t:a(e.parentElement,t.concat([e]))},s=function(e,t){return getComputedStyle(e,null).getPropertyValue(t)},l=function(e){return o.test(function(e){return s(e,"overflow")+s(e,"overflow-y")+s(e,"overflow-x")}(e))},d=a(e.parentElement,[]);try{for(var c=i(d),h=c.next();!h.done;h=c.next()){var p=h.value;if(l(p))return p}}catch(e){t={error:e}}finally{try{h&&!h.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}return null!==(r=document.scrollingElement)&&void 0!==r?r:document.documentElement}Z.ɵfac=function(e){return new(e||Z)(t.ɵɵinject(t.ComponentFactoryResolver))},Z.ɵprov=t.ɵɵdefineInjectable({token:Z,factory:Z.ɵfac}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(Z,[{type:t.Injectable}],(function(){return[{type:t.ComponentFactoryResolver}]}),null);var D=function(){function e(e){var t=this;this.ngZone=e,this.ngZone.runOutsideAngular((function(){t.globalDrag$=n.fromEvent(document,"drag")})),this.scrolling=!1}return e.prototype.addScrolling=function(){var e=this;this.ngZone.runOutsideAngular((function(){if(void 0===e.globalDragSubscription){if(void 0===e.globalDrag$)throw new Error("Could not get observable");var t,n,o,i,a,s,l,d,c;e.globalDragSubscription=e.globalDrag$.pipe(r.throttleTime(25),r.filter((function(e){if(!e.target)return!1;d=C(e.target),t=d.clientHeight;var r,l=d.clientWidth;if("fixed"===window.getComputedStyle(d).getPropertyValue("position").toLowerCase())r=e.clientX,c=e.clientY;else{var h=d.getBoundingClientRect(),p=C(d);r=e.clientX-(h.left+p.scrollLeft),c=e.clientY-(h.top+p.scrollTop)}return!(r<0||r>l||c<0||c>t)&&(n=Math.max(.1*t,100),s=c>(i=t-n),(a=c<(o=n))||s)}))).subscribe((function(){if(null!==d){var r,h=d.scrollHeight-t,p=d.scrollTop;if(a&&p>0){r=p-75*((o-c)/n)}else{if(!s||!(p<h))return;r=p+75*((c-i)/n)}(r=Math.max(0,Math.min(h,r)))!==p&&(d.scrollTo({top:r}),e.scrolling=!0,clearTimeout(l),l=setTimeout((function(){e.scrolling=!1}),100))}}))}}))},e.prototype.removeScrolling=function(){void 0!==this.globalDragSubscription&&this.globalDragSubscription.unsubscribe()},e}();D.ɵfac=function(e){return new(e||D)(t.ɵɵinject(t.NgZone))},D.ɵprov=t.ɵɵdefineInjectable({token:D,factory:D.ɵfac}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(D,[{type:t.Injectable}],(function(){return[{type:t.NgZone}]}),null);var S=["nodeHost"],I=["draggableDiv"],x=["nodeHostContainer"],E=["innerBranch"];function M(e,n){if(1&e&&t.ɵɵelement(0,"drop-zone",7),2&e){var r=t.ɵɵnextContext();t.ɵɵproperty("dropZone",r.dropZoneAbove)}}function F(e,t){}function A(e,n){if(1&e&&t.ɵɵelement(0,"limble-tree-branch",8,9),2&e){var r=t.ɵɵnextContext();t.ɵɵproperty("branch",r.branch)}}function O(e,n){if(1&e&&t.ɵɵelement(0,"drop-zone",7),2&e){var r=t.ɵɵnextContext();t.ɵɵproperty("dropZone",r.dropZoneBelow)}}var j=function(){function e(e,t,n,o,i,a,s,l){var d=this;this.componentCreatorService=e,this.changeDetectorRef=t,this.dragStateService=n,this.dropZoneService=o,this.treeService=i,this.globalEventsService=a,this.ngZone=s,this.treeConstructionStatus=l,this.treeConstructionStatus.constructing(),void 0!==this.treeService.treeOptions&&!0!==this.treeService.treeOptions.listMode?this.renderInnerBranch=!0:this.renderInnerBranch=!1,this.renderDropZoneBelow=!1,this.renderDropZoneAbove=!1,this.treeChangeSubscription=this.treeService.changes$.pipe(r.skip(1)).subscribe((function(){d.treeChangeHandler()}))}return e.prototype.treeChangeHandler=function(){void 0===this.branch||void 0===this.currentBranchCoordinates||l(this.branch.getCoordinates(),this.currentBranchCoordinates)||this.updateDropZones()},e.prototype.ngOnInit=function(){var e,t,o,i=this;if(!1!==(null===(e=this.treeService.treeOptions)||void 0===e?void 0:e.allowDragging)){var a=null===(t=this.branch)||void 0===t?void 0:t.getParent();if(null!==(null==a?void 0:a.data)){var s=null==a?void 0:a.data;if(!d(this.treeService.treeOptions,s))return void(this.renderInnerBranch=!1)}this.registerDropZones(),this.currentBranchCoordinates=null===(o=this.branch)||void 0===o?void 0:o.getCoordinates(),this.ngZone.runOutsideAngular((function(){if(void 0===i.dropZoneAbove||void 0===i.dropZoneBelow)throw new Error("Zones not registered");n.merge(i.dropZoneAbove.getCommChannel(),i.dropZoneBelow.getCommChannel()).pipe(r.filter((function(e){return"checkRendered"===e}))).subscribe((function(){if(void 0===i.dropZoneAbove||void 0===i.dropZoneBelow||void 0===i.branch)throw new Error("Zones not registered");i.renderDropZoneAbove=i.dropZoneAbove.isRendered(),i.renderDropZoneBelow=i.dropZoneBelow.isRendered()}))}))}},e.prototype.ngAfterViewInit=function(){this.renderNode(),this.setDropZoneHosts(),this.checkForHandle(),this.treeConstructionStatus.doneConstructing(),this.changeDetectorRef.detectChanges()},e.prototype.ngOnDestroy=function(){this.treeChangeSubscription.unsubscribe(),void 0!==this.dropZoneAbove&&this.dropZoneService.removeDropZone(this.dropZoneAbove),void 0!==this.dropZoneBelow&&this.dropZoneService.removeDropZone(this.dropZoneBelow),this.treeService.cleanupSignal$.next(!0)},e.prototype.dragstartHandler=function(e){var t,o=this;if(e.stopPropagation(),null===e.dataTransfer||void 0===this.branch||void 0===this.parentHost)throw new Error("failed to run dragstartHandler");var i=e.target;if("LIMBLE-TREE-NODE"===(null===(t=i.parentElement)||void 0===t?void 0:t.tagName)){e.dataTransfer.effectAllowed="move",this.dragStateService.dragging(this.branch,this.parentHost);var a=i.closest("limble-tree-root");if(null===a)throw new Error("could not get root of tree");this.ngZone.runOutsideAngular((function(){setTimeout((function(){var e,t;i.classList.add("dragging"),1===(null===(e=o.treeService.treeData)||void 0===e?void 0:e.length)&&1===(null===(t=o.branch)||void 0===t?void 0:t.getCoordinates().length)&&o.treeService.placeholder$.next(!0)}));var e=n.fromEvent(a,"dragover").pipe(r.first()).subscribe((function(e){if(e.stopPropagation(),void 0===o.branch)throw new Error("Could not show surrounding drop zones");var t,n=o.branch.getParent(),r=!0;null!==(null==n?void 0:n.data)&&(t=null==n?void 0:n.data,r=d(o.treeService.treeOptions,t)),void 0!==o.dropZoneAbove&&r&&o.dropZoneService.showDropZoneFamily(o.dropZoneAbove,{joinFamilies:!0})}));setTimeout((function(){e.closed||e.unsubscribe()}),500)}))}else e.preventDefault()},e.prototype.dragendHandler=function(e){var t,n;if(null==e||e.stopPropagation(),void 0===this.draggableDiv)throw new Error("could not get draggable div");if(this.draggableDiv.nativeElement.classList.remove("dragging"),"captured"===this.dragStateService.getState()){if(!1===this.treeService.captured){if(void 0===this.branch)throw new Error("could not get branch in dragendHandler");this.treeService.cleanupSignal$.next(!0),this.treeService.captured=!1}this.dragStateService.release()}else this.dragStateService.release(),this.dropZoneService.clearVisibleZones(),this.dropZoneService.restoreFamilies(),1===(null===(t=this.treeService.treeData)||void 0===t?void 0:t.length)&&1===(null===(n=this.branch)||void 0===n?void 0:n.getCoordinates().length)&&this.treeService.placeholder$.next(!1)},e.prototype.dragoverHandler=function(e){var t,n;if(!0!==this.globalEventsService.scrolling){if(void 0===this.branch)throw new Error("Can't get current branch during dragover event");var r=this.dragStateService.getData();if(void 0!==r){var o=r.branch;if(o!==this.branch&&!this.branch.getAncestors().includes(o)){var i,a,s=e.currentTarget;a=void 0===(null===(t=this.innerBranch)||void 0===t?void 0:t.dropZoneInside)?i=s.offsetHeight/2-6:2*(i=s.offsetHeight/3-3);var l,c=this.branch.getParent(),p=!0;null!==(null==c?void 0:c.data)&&(l=null==c?void 0:c.data,p=d(this.treeService.treeOptions,l));var u=this.dropZoneService.getActiveDropZone();if(e.offsetY<i&&void 0!==this.dropZoneAbove&&(null===u||!h.dropZoneLocationsAreEqual(u,this.dropZoneAbove))&&p){if(null==this.branch.getIndex())throw new Error("can't get branch index");this.dropZoneService.showDropZoneFamily(this.dropZoneAbove,{activateLowestInsteadOfFounder:!0})}else if(e.offsetY<a&&void 0!==(null===(n=this.innerBranch)||void 0===n?void 0:n.dropZoneInside)&&(null===u||!h.dropZoneLocationsAreEqual(u,this.innerBranch.dropZoneInside)))this.dropZoneService.showDropZoneFamily(this.innerBranch.dropZoneInside);else if(e.offsetY>=a&&void 0!==this.dropZoneBelow&&(null===u||!h.dropZoneLocationsAreEqual(u,this.dropZoneBelow))&&0===this.branch.getChildren().length&&p){if(null==this.branch.getIndex())throw new Error("can't get branch index");this.dropZoneService.showDropZoneFamily(this.dropZoneBelow)}}}}},e.prototype.renderNode=function(){var e;if(void 0===this.nodeHost||void 0===this.branch)throw new Error("Failed to render tree node");var t=this.branch.data.component;if(void 0===t&&(t=null===(e=this.treeService.treeOptions)||void 0===e?void 0:e.defaultComponent),void 0===t)throw new Error("limbleTree requires a component to render");var n=this.componentCreatorService.appendComponent(t.class,this.nodeHost);for(var r in n.instance.nodeData=this.branch.data,t.bindings)n.instance[r]=t.bindings[r]},e.prototype.registerDropZones=function(){this.addDropZoneAbove(),this.addDropZoneBelow()},e.prototype.addDropZoneAbove=function(){var e;if(void 0===this.branch)throw new Error("failed to register drop zone above");var t=this.branch.getParent(),n=this.branch.getCoordinates(),r=n[n.length-1];this.dropZoneAbove=new h(s(null!==(e=null==t?void 0:t.getCoordinates())&&void 0!==e?e:[]),r),this.dropZoneService.addDropZone(this.dropZoneAbove)},e.prototype.addDropZoneBelow=function(){var e;if(void 0===this.branch)throw new Error("failed to register drop zone below");var t=this.branch.getParent(),n=this.branch.getCoordinates(),r=n[n.length-1];this.dropZoneBelow=new h(s(null!==(e=null==t?void 0:t.getCoordinates())&&void 0!==e?e:[]),r+1),this.dropZoneService.addDropZone(this.dropZoneBelow)},e.prototype.updateDropZones=function(){var e;this.currentBranchCoordinates=null===(e=this.branch)||void 0===e?void 0:e.getCoordinates(),this.updateDropZoneAbove(),this.updateDropZoneBelow(),this.updateDropZoneInside(),this.setDropZoneHosts()},e.prototype.updateDropZoneAbove=function(){var e;if(void 0===this.branch||void 0===this.dropZoneAbove)throw new Error("failed to update drop zone above");var t=this.branch.getParent(),n=this.branch.getCoordinates(),r=n[n.length-1],o=this.dropZoneAbove.getLocation();o.setParentCoordinates(s(null!==(e=null==t?void 0:t.getCoordinates())&&void 0!==e?e:[])),o.setInsertIndex(r)},e.prototype.updateDropZoneBelow=function(){var e;if(void 0===this.branch||void 0===this.dropZoneBelow)throw new Error("failed to update drop zone below");var t=this.branch.getParent(),n=this.branch.getCoordinates(),r=n[n.length-1],o=this.dropZoneBelow.getLocation();o.setParentCoordinates(s(null!==(e=null==t?void 0:t.getCoordinates())&&void 0!==e?e:[])),o.setInsertIndex(r+1)},e.prototype.updateDropZoneInside=function(){var e;if(void 0!==(null===(e=this.innerBranch)||void 0===e?void 0:e.dropZoneInside)){if(void 0===this.branch)throw new Error("failed to update drop zone inside");this.innerBranch.dropZoneInside.getLocation().setParentCoordinates(s(this.branch.getCoordinates()))}},e.prototype.setDropZoneHosts=function(){void 0!==this.dropZoneAbove&&void 0!==this.dropZoneBelow&&(this.dropZoneAbove.setHost(this.parentHost),this.dropZoneBelow.setHost(this.parentHost))},e.prototype.checkForHandle=function(){var e,t=this;if(void 0!==this.nodeHostContainer&&void 0!==this.draggableDiv){var n,o,i=this.nodeHostContainer.nativeElement.querySelector(".limble-tree-handle"),a=this.draggableDiv.nativeElement;n=this.treeService.treeOptions,o=null===(e=this.branch)||void 0===e?void 0:e.data,void 0===n||!0!==n.allowDragging&&("function"!=typeof n.allowDragging||void 0===o||!0!==n.allowDragging(o))?a.setAttribute("draggable","false"):null===i?a.setAttribute("draggable","true"):i.addEventListener("mousedown",(function(){a.setAttribute("draggable","true");var e=t.dragStateService.state$.pipe(r.filter((function(e){return"dragging"===e})),r.first());t.dragStateService.state$.pipe(r.skipUntil(e),r.filter((function(e){return"idle"===e})),r.first()).subscribe((function(){a.setAttribute("draggable","false")}))}))}},e}();j.ɵfac=function(e){return new(e||j)(t.ɵɵdirectiveInject(Z),t.ɵɵdirectiveInject(t.ChangeDetectorRef),t.ɵɵdirectiveInject(p),t.ɵɵdirectiveInject(f),t.ɵɵdirectiveInject(R),t.ɵɵdirectiveInject(D),t.ɵɵdirectiveInject(t.NgZone),t.ɵɵdirectiveInject(u))},j.ɵcmp=t.ɵɵdefineComponent({type:j,selectors:[["limble-tree-node"]],viewQuery:function(e,n){if(1&e&&(t.ɵɵviewQuery(S,1,t.ViewContainerRef),t.ɵɵviewQuery(I,1,t.ElementRef),t.ɵɵviewQuery(x,1,t.ElementRef),t.ɵɵviewQuery(E,1,w)),2&e){var r=void 0;t.ɵɵqueryRefresh(r=t.ɵɵloadQuery())&&(n.nodeHost=r.first),t.ɵɵqueryRefresh(r=t.ɵɵloadQuery())&&(n.draggableDiv=r.first),t.ɵɵqueryRefresh(r=t.ɵɵloadQuery())&&(n.nodeHostContainer=r.first),t.ɵɵqueryRefresh(r=t.ɵɵloadQuery())&&(n.innerBranch=r.first)}},inputs:{branch:"branch",parentHost:"parentHost"},decls:9,vars:4,consts:[[3,"dropZone",4,"ngIf"],[1,"limble-parent-container",3,"dragstart","dragend"],["draggableDiv",""],[3,"dragoverEventThrottle","dragoverNoChangeDetect"],["nodeHostContainer",""],["nodeHost",""],[3,"branch",4,"ngIf"],[3,"dropZone"],[3,"branch"],["innerBranch",""]],template:function(e,n){1&e&&(t.ɵɵtemplate(0,M,1,1,"drop-zone",0),t.ɵɵelementStart(1,"div",1,2),t.ɵɵlistener("dragstart",(function(e){return n.dragstartHandler(e)}))("dragend",(function(e){return n.dragendHandler(e)})),t.ɵɵelementStart(3,"div",3,4),t.ɵɵlistener("dragoverNoChangeDetect",(function(e){return n.dragoverHandler(e)})),t.ɵɵtemplate(5,F,0,0,"ng-template",null,5,t.ɵɵtemplateRefExtractor),t.ɵɵelementEnd(),t.ɵɵtemplate(7,A,2,1,"limble-tree-branch",6),t.ɵɵelementEnd(),t.ɵɵtemplate(8,O,1,1,"drop-zone",0)),2&e&&(t.ɵɵproperty("ngIf",!0===n.renderDropZoneAbove),t.ɵɵadvance(3),t.ɵɵproperty("dragoverEventThrottle",10),t.ɵɵadvance(4),t.ɵɵproperty("ngIf",void 0!==n.branch&&!0===n.renderInnerBranch),t.ɵɵadvance(1),t.ɵɵproperty("ngIf",!0===n.renderDropZoneBelow))},styles:[".dragging[_ngcontent-%COMP%]{position:absolute;transition:transform .01s;transform:translateX(-9999px)}"]}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(j,[{type:t.Component,args:[{selector:"limble-tree-node",templateUrl:"./limble-tree-node.component.html",styleUrls:["./limble-tree-node.component.scss"]}]}],(function(){return[{type:Z},{type:t.ChangeDetectorRef},{type:p},{type:f},{type:R},{type:D},{type:t.NgZone},{type:u}]}),{branch:[{type:t.Input}],nodeHost:[{type:t.ViewChild,args:["nodeHost",{read:t.ViewContainerRef}]}],draggableDiv:[{type:t.ViewChild,args:["draggableDiv",{read:t.ElementRef}]}],nodeHostContainer:[{type:t.ViewChild,args:["nodeHostContainer",{read:t.ElementRef}]}],parentHost:[{type:t.Input}],innerBranch:[{type:t.ViewChild,args:["innerBranch",{read:w}]}]});var R=function(){function e(e,t,o,i){var a=this;this.componentCreatorService=e,this.dropZoneService=t,this.dragStateService=o,this.treeConstructionStatus=i,this.changes$=new n.Subject,this.drops$=new n.Subject,this.treeModel=new g(null),this.placeholder=!1,this.captured=!1,this.cleanupSignal$=new n.Subject;var s=!1,l=!1,d=this.treeConstructionStatus.stable$.pipe(r.tap((function(e){l=e})),r.filter((function(e){return!0===e})));this.cleanupSignal$.pipe(r.tap((function(e){s=e})),r.debounce((function(){return!0===l?n.EMPTY:d})),r.debounceTime(5)).subscribe((function(){a.cleanup(s),s=!1})),this.placeholder$=new n.BehaviorSubject(!1),this.placeholder$.subscribe((function(e){a.placeholder=e}))}return e.prototype.drop=function(e,t){var n,r=e.getParent();if(null===r)throw new Error("can't drop root of tree");var o,i,a=e.getIndex();if(null==a)throw new Error("Cannot move the hidden root node");if(!0===this.placeholder?(o=[],i=0):i=(o=s(t)).pop(),void 0===i)throw new Error("target coordinates are empty");var d=this.treeModel.getDescendant(o);if(void 0===d)throw new Error("could not get to target");var c=this.dropZoneService.getDropZone(t),h=null==c?void 0:c.getLocation().insertIndex,p=null==c?void 0:c.getHost(),u=null===(n=this.dragStateService.getData())||void 0===n?void 0:n.parentContainer;if(!0===this.placeholder&&this.placeholder$.next(!1),d.insertChild(e,i),void 0===p||void 0===u||void 0===h)return console.warn("Could not perform a precise update. Re-rendering the entire tree instead"),this.render(),void this.changes$.next(null);var v=u.length,f=this.componentCreatorService.appendComponent(j,p,i);f.instance.branch=e,f.instance.parentHost=p,h<a&&u.length>v&&l(r.getCoordinates(),o)?u.remove(a+1):u.remove(a),this.rebuildTreeData(),this.drops$.next({target:e.data,oldParent:r.data,oldIndex:a,newParent:d.data,newIndex:i}),this.cleanupSignal$.next(!1)},e.prototype.init=function(e,t,n,r,o){if(this.host=e,this.originalData=t,this.treeOptions=this.processOptions(n,r,o),!0===this.treeOptions.listMode){var i=this.treeOptions.itemsPerPage*(this.treeOptions.page-1);isNaN(i)&&(i=0);var a=i+this.treeOptions.itemsPerPage;this.treeData=this.originalData.slice(i,a)}else this.treeData=s(this.originalData);this.render()},e.prototype.cleanup=function(e){var t;void 0===e&&(e=!1),e&&this.rebuildTreeData(),0===(null===(t=this.treeData)||void 0===t?void 0:t.length)?this.render():(this.changes$.next(null),this.dropZoneService.update())},e.prototype.render=function(){var e,t,n,r;if(void 0===this.host||void 0===this.treeData||void 0===this.treeOptions)throw new Error("TreeModel not initialized");if(this.treeConstructionStatus.ready(!1),this.host.clear(),this.dropZoneService.restart(),this.placeholder$.next(!1),this.treeModel=new g(null),0===this.treeData.length)this.placeholder$.next(!0);else{try{for(var o=i(this.treeData),a=o.next();!a.done;a=o.next()){var s=a.value,l=new g(s);this.treeModel.appendChild(l)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}try{for(var d=i(this.treeModel.getChildren()),c=d.next();!c.done;c=d.next()){l=c.value;var h=this.componentCreatorService.appendComponent(j,this.host);h.instance.branch=l,h.instance.parentHost=this.host}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}}this.treeConstructionStatus.ready(!0),this.changes$.next(null),this.dropZoneService.init(this.treeModel,this.treeOptions)},e.prototype.renderBranch=function(e,t){var n,r,o,a;if(void 0===this.treeModel)throw new Error("TreeModel not initialized");e.clear(),t.clearChildren();try{for(var s=i(null!==(a=null===(o=t.data)||void 0===o?void 0:o.nodes)&&void 0!==a?a:[]),l=s.next();!l.done;l=s.next()){var d=l.value,c=new g(d);t.appendChild(c);var h=this.componentCreatorService.appendComponent(j,e);h.instance.branch=c,h.instance.parentHost=e}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype.processOptions=function(e,t,n){var r,o,i,a,s;return void 0===e&&(e={}),void 0===t&&(t=1/0),void 0===n&&(n=1),!0===e.listMode&&void 0!==e.allowNesting&&!1!==e.allowNesting&&console.warn("The value of `allowNesting` will be ignored; it must be false when `listMode` is true"),{defaultComponent:e.defaultComponent,indent:null!==(r=e.indent)&&void 0!==r?r:45,allowNesting:!0!==e.listMode&&(null===(o=e.allowNesting)||void 0===o||o),allowDragging:null===(i=e.allowDragging)||void 0===i||i,allowDrop:null!==(a=e.allowDrop)&&void 0!==a?a:function(){return!0},listMode:null!==(s=e.listMode)&&void 0!==s&&s,itemsPerPage:e.listMode?t:void 0,page:e.listMode?n:void 0}},e.prototype.rebuildTreeData=function(){var e,t,n,r;if(void 0===this.originalData||void 0===this.treeData||void 0===this.treeOptions||void 0===this.host)throw new Error("Tree data not initialized");this.treeData=[];try{for(var o=i(this.treeModel.getChildren()),a=o.next();!a.done;a=o.next()){var l=a.value;this.treeData.push(this.rebuildBranch(l))}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}if(!0===this.treeOptions.listMode&&this.treeOptions.itemsPerPage<1/0){var d=this.treeOptions.itemsPerPage,c=d*(this.treeOptions.page-1);if((n=this.originalData).splice.apply(n,s([c,d],this.treeData)),this.treeData.length!==d){var h=!1;if(this.treeData.length<d&&c+d<=this.originalData.length){for(var p=d-this.treeData.length,u=d-1;u<d+p-1;u++){l=new g(this.originalData[c+u]);this.treeModel.appendChild(l);var v=this.componentCreatorService.appendComponent(j,this.host);v.instance.branch=l,v.instance.parentHost=this.host}h=!0}else if(this.treeData.length>d){for(u=d+(p=this.treeData.length-d)-1;u>=d;u--)this.treeModel.removeChild(u),this.host.remove(u);h=!0}if(!0===h){var f=c+d;this.treeData=this.originalData.slice(c,f)}}}else this.originalData.length=0,(r=this.originalData).push.apply(r,s(this.treeData))},e.prototype.rebuildBranch=function(e){var t,n,r=e.data;r.nodes=[];try{for(var o=i(e.getChildren()),a=o.next();!a.done;a=o.next()){var s=a.value;r.nodes.push(this.rebuildBranch(s))}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return r},e}();R.ɵfac=function(e){return new(e||R)(t.ɵɵinject(Z),t.ɵɵinject(f),t.ɵɵinject(p),t.ɵɵinject(u))},R.ɵprov=t.ɵɵdefineInjectable({token:R,factory:R.ɵfac}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(R,[{type:t.Injectable}],(function(){return[{type:Z},{type:f},{type:p},{type:u}]}),null);var H=function(){function e(e,n){this.ngZone=e,this.el=n,this.dragoverNoChangeDetect=new t.EventEmitter,this.dragoverEventThrottle=0}return e.prototype.ngOnInit=function(){var e=this;this.ngZone.runOutsideAngular((function(){e.eventSubscription=n.fromEvent(e.el.nativeElement,"dragover").pipe(r.throttleTime(e.dragoverEventThrottle)).subscribe((function(t){e.dragoverNoChangeDetect.emit(t)}))}))},e.prototype.ngOnDestroy=function(){void 0!==this.eventSubscription&&this.eventSubscription.unsubscribe()},e}();H.ɵfac=function(e){return new(e||H)(t.ɵɵdirectiveInject(t.NgZone),t.ɵɵdirectiveInject(t.ElementRef))},H.ɵdir=t.ɵɵdefineDirective({type:H,selectors:[["","dragoverNoChangeDetect",""]],inputs:{dragoverEventThrottle:"dragoverEventThrottle"},outputs:{dragoverNoChangeDetect:"dragoverNoChangeDetect"}}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(H,[{type:t.Directive,args:[{selector:"[dragoverNoChangeDetect]"}]}],(function(){return[{type:t.NgZone},{type:t.ElementRef}]}),{dragoverEventThrottle:[{type:t.Input}],dragoverNoChangeDetect:[{type:t.Output}]});var P=function(){function e(e,n){this.ngZone=e,this.el=n,this.dragleaveNoChangeDetect=new t.EventEmitter}return e.prototype.ngOnInit=function(){var e=this;this.ngZone.runOutsideAngular((function(){e.eventSubscription=n.fromEvent(e.el.nativeElement,"dragleave").subscribe((function(t){e.dragleaveNoChangeDetect.emit(t)}))}))},e.prototype.ngOnDestroy=function(){void 0!==this.eventSubscription&&this.eventSubscription.unsubscribe()},e}();P.ɵfac=function(e){return new(e||P)(t.ɵɵdirectiveInject(t.NgZone),t.ɵɵdirectiveInject(t.ElementRef))},P.ɵdir=t.ɵɵdefineDirective({type:P,selectors:[["","dragleaveNoChangeDetect",""]],outputs:{dragleaveNoChangeDetect:"dragleaveNoChangeDetect"}}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(P,[{type:t.Directive,args:[{selector:"[dragleaveNoChangeDetect]"}]}],(function(){return[{type:t.NgZone},{type:t.ElementRef}]}),{dragleaveNoChangeDetect:[{type:t.Output}]});var N=function(e,t){return{active:e,related:t}};function B(e,n){if(1&e){var r=t.ɵɵgetCurrentView();t.ɵɵelementStart(0,"div",1),t.ɵɵlistener("dragenter",(function(){return t.ɵɵrestoreView(r),t.ɵɵnextContext().dragenterHandler()})),t.ɵɵelement(1,"div",2),t.ɵɵelementEnd()}if(2&e){var o=t.ɵɵnextContext();t.ɵɵadvance(1),t.ɵɵproperty("ngClass",t.ɵɵpureFunction2(1,N,o.active,!o.active))}}var T=function(){function e(e,t){this.dropZoneService=e,this.changeDetectorRef=t,this.visible=!1,this.active=!1}return e.prototype.dragenterHandler=function(){void 0!==this.dropZone&&!0!==this.active&&this.dropZoneService.swapActiveDropZone(this.dropZone)},e.prototype.ngOnInit=function(){var e=this;if(void 0===this.dropZone)throw new Error("No drop zone object at component initialization");this.commSubscription=this.dropZone.getCommChannel().subscribe((function(t){var n,r,o,i;switch(t){case"checkVisible":e.visible=null!==(r=null===(n=e.dropZone)||void 0===n?void 0:n.isVisible())&&void 0!==r&&r;break;case"checkActive":e.active=null!==(i=null===(o=e.dropZone)||void 0===o?void 0:o.isActive())&&void 0!==i&&i;break;case"checkRendered":break;default:throw new Error("unhandled comm message")}e.changeDetectorRef.detectChanges()}))},e.prototype.ngOnDestroy=function(){void 0!==this.commSubscription&&this.commSubscription.unsubscribe()},e}();T.ɵfac=function(e){return new(e||T)(t.ɵɵdirectiveInject(f),t.ɵɵdirectiveInject(t.ChangeDetectorRef))},T.ɵcmp=t.ɵɵdefineComponent({type:T,selectors:[["drop-zone"]],inputs:{dropZone:"dropZone"},decls:1,vars:1,consts:[["class","dropZoneContainer",3,"dragenter",4,"ngIf"],[1,"dropZoneContainer",3,"dragenter"],[3,"ngClass"]],template:function(e,n){1&e&&t.ɵɵtemplate(0,B,2,4,"div",0),2&e&&t.ɵɵproperty("ngIf",n.visible)},directives:[o.NgIf,o.NgClass],styles:[".active[_ngcontent-%COMP%]{height:105px;border-radius:5px;background:#f0f9ff;border:2px dashed #bed2db}.active[_ngcontent-%COMP%], .related[_ngcontent-%COMP%]{margin:10px 0;width:calc(100% - 20px);box-sizing:border-box}.related[_ngcontent-%COMP%]{height:30px;border-radius:5px;background:#fff6f0;border:1px dashed #dbccbe;opacity:.8}.dropZoneContainer[_ngcontent-%COMP%]{position:relative}"],changeDetection:0}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(T,[{type:t.Component,args:[{selector:"drop-zone",templateUrl:"./drop-zone.component.html",styleUrls:["./drop-zone.component.scss"],changeDetection:t.ChangeDetectionStrategy.OnPush}]}],(function(){return[{type:f},{type:t.ChangeDetectorRef}]}),{dropZone:[{type:t.Input}]});var $=function(){function e(e,t,n,r){var o=this;this.dropZoneService=e,this.changeDetectorRef=t,this.treeService=n,this.treeConstructionStatus=r,this.treeConstructionStatus.constructing(),this.placeholderSubscription=this.treeService.placeholder$.subscribe((function(e){void 0!==o.dropZone&&(o.dropZoneService.removeDropZone(o.dropZone),!0===e&&(o.dropZoneService.addDropZone(o.dropZone),o.dropZone.setHost(o.treeService.host)))}))}return e.prototype.ngOnInit=function(){this.dropZone=new h([],0),this.dropZoneService.addDropZone(this.dropZone)},e.prototype.ngAfterViewInit=function(){if(void 0===this.dropZone)throw new Error("placeholder drop zone is not defined");this.dropZone.setHost(this.treeService.host),this.treeConstructionStatus.doneConstructing(),this.changeDetectorRef.detectChanges()},e.prototype.dragoverHandler=function(){void 0!==this.dropZone&&this.dropZoneService.showDropZoneFamily(this.dropZone)},e.prototype.ngOnDestroy=function(){if(this.placeholderSubscription.unsubscribe(),void 0===this.dropZone)throw new Error("could not remove placeholder drop zone");this.dropZoneService.removeDropZone(this.dropZone)},e}();$.ɵfac=function(e){return new(e||$)(t.ɵɵdirectiveInject(f),t.ɵɵdirectiveInject(t.ChangeDetectorRef),t.ɵɵdirectiveInject(R),t.ɵɵdirectiveInject(u))},$.ɵcmp=t.ɵɵdefineComponent({type:$,selectors:[["limble-tree-placeholder"]],decls:2,vars:1,consts:[[3,"dropZone"],[1,"placeholder",3,"dragoverNoChangeDetect"]],template:function(e,n){1&e&&(t.ɵɵelement(0,"drop-zone",0),t.ɵɵelementStart(1,"div",1),t.ɵɵlistener("dragoverNoChangeDetect",(function(){return n.dragoverHandler()})),t.ɵɵelementEnd()),2&e&&t.ɵɵproperty("dropZone",n.dropZone)},directives:[T,H],styles:[".placeholder[_ngcontent-%COMP%]{width:100%;height:20px}"],changeDetection:0}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata($,[{type:t.Component,args:[{selector:"limble-tree-placeholder",templateUrl:"./limble-tree-placeholder.component.html",styleUrls:["./limble-tree-placeholder.component.scss"],changeDetection:t.ChangeDetectionStrategy.OnPush}]}],(function(){return[{type:f},{type:t.ChangeDetectorRef},{type:R},{type:u}]}),null);var z=["host"];function L(e,n){1&e&&t.ɵɵelement(0,"limble-tree-placeholder")}function V(e,t){}var k=function(){function e(e,n,r,o,i){var a=this;this.treeService=e,this.dropZoneService=n,this.dragStateService=r,this.globalEventsService=o,this.changeDetectorRef=i,this.treeChange=new t.EventEmitter,this.treeDrop=new t.EventEmitter,this.changesSubscription=this.treeService.changes$.subscribe((function(){setTimeout((function(){a.treeChange.emit()}))})),this.dropSubscription=this.treeService.drops$.subscribe((function(e){setTimeout((function(){a.treeDrop.emit(e)}))})),this.placeholder=!1,this.treeService.placeholder$.subscribe((function(e){a.placeholder=e,t.NgZone.isInAngularZone()||a.changeDetectorRef.detectChanges()}))}return e.prototype.ngAfterViewInit=function(){var e;!0===(null===(e=this.options)||void 0===e?void 0:e.listMode)||void 0===this.itemsPerPage&&void 0===this.page||console.warn("pagination is only allowed in listMode; `itemsPerPage` and `page` inputs will be ignored"),this.update(),this.changeDetectorRef.detectChanges()},e.prototype.ngOnChanges=function(){void 0!==this.host&&void 0!==this.data&&this.update()},e.prototype.update=function(){if(void 0===this.host)throw new Error("Failed to render limble tree. Failure occurred at root.");if(void 0===this.data)throw new Error("limbleTree requires a data object");this.treeService.init(this.host,this.data,this.options,this.itemsPerPage,this.page),this.globalEventsService.addScrolling()},e.prototype.dragoverHandler=function(e){null!==e.dataTransfer&&(e.stopPropagation(),e.preventDefault(),e.dataTransfer.dropEffect="move")},e.prototype.dragleaveHandler=function(e){var t=e.currentTarget,n=e.relatedTarget;t instanceof Node&&n instanceof Node&&!1===function(e,t){if(e===t)return!0;for(var n=t.parentNode;n!==document;){if(null===n)return;if(n===e)return!0;n=n.parentNode}return!1}(t,n)&&(this.dropZoneService.clearVisibleZones(),this.changeDetectorRef.detectChanges())},e.prototype.dropHandler=function(e){var t=this;if(e.stopPropagation(),"droppable"===this.dragStateService.getState()){var n=this.dragStateService.capture();if(void 0===n)throw new Error("failed to get current branch in dragendHandler");var o=this.dropZoneService.getActiveDropZone();if(null===o)throw new Error("failed to get active drop zone at drop handler");this.treeService.captured=!0,this.dragStateService.state$.pipe(r.first((function(e){return"idle"===e}))).subscribe((function(){t.treeService.captured=!1})),this.dropZoneService.clearVisibleZones(),this.treeService.drop(n,o.getFullInsertCoordinates())}},e.prototype.ngOnDestroy=function(){this.changesSubscription.unsubscribe(),this.dropSubscription.unsubscribe()},e}();k.ɵfac=function(e){return new(e||k)(t.ɵɵdirectiveInject(R),t.ɵɵdirectiveInject(f),t.ɵɵdirectiveInject(p),t.ɵɵdirectiveInject(D),t.ɵɵdirectiveInject(t.ChangeDetectorRef))},k.ɵcmp=t.ɵɵdefineComponent({type:k,selectors:[["limble-tree-root"]],viewQuery:function(e,n){if(1&e&&t.ɵɵviewQuery(z,1,t.ViewContainerRef),2&e){var r;t.ɵɵqueryRefresh(r=t.ɵɵloadQuery())&&(n.host=r.first)}},inputs:{data:"data",options:"options",itemsPerPage:"itemsPerPage",page:"page"},outputs:{treeChange:"treeChange",treeDrop:"treeDrop"},features:[t.ɵɵProvidersFeature([R,f,u]),t.ɵɵNgOnChangesFeature],decls:4,vars:1,consts:[[3,"dragoverNoChangeDetect","dragleaveNoChangeDetect","drop"],[4,"ngIf"],["host",""]],template:function(e,n){1&e&&(t.ɵɵelementStart(0,"div",0),t.ɵɵlistener("dragoverNoChangeDetect",(function(e){return n.dragoverHandler(e)}))("dragleaveNoChangeDetect",(function(e){return n.dragleaveHandler(e)}))("drop",(function(e){return n.dropHandler(e)})),t.ɵɵtemplate(1,L,1,0,"limble-tree-placeholder",1),t.ɵɵtemplate(2,V,0,0,"ng-template",null,2,t.ɵɵtemplateRefExtractor),t.ɵɵelementEnd()),2&e&&(t.ɵɵadvance(1),t.ɵɵproperty("ngIf",!0===n.placeholder))},directives:[H,P,o.NgIf,$],styles:[""]}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(k,[{type:t.Component,args:[{selector:"limble-tree-root",templateUrl:"./limble-tree-root.component.html",styleUrls:["./limble-tree-root.component.scss"],providers:[R,f,u]}]}],(function(){return[{type:R},{type:f},{type:p},{type:D},{type:t.ChangeDetectorRef}]}),{data:[{type:t.Input}],options:[{type:t.Input}],itemsPerPage:[{type:t.Input}],page:[{type:t.Input}],host:[{type:t.ViewChild,args:["host",{read:t.ViewContainerRef}]}],treeChange:[{type:t.Output}],treeDrop:[{type:t.Output}]});var q=function(){};q.ɵfac=function(e){return new(e||q)},q.ɵmod=t.ɵɵdefineNgModule({type:q}),q.ɵinj=t.ɵɵdefineInjector({providers:[Z,p,D],imports:[[o.CommonModule]]}),("undefined"==typeof ngJitMode||ngJitMode)&&t.ɵɵsetNgModuleScope(q,{declarations:[w,T,j,k,$,H,P],imports:[o.CommonModule],exports:[k]}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(q,[{type:t.NgModule,args:[{declarations:[w,T,j,k,$,H,P],imports:[o.CommonModule],exports:[k],providers:[Z,p,D]}]}],null,null),t.ɵɵsetComponentScope(w,[o.NgIf,T],[]),t.ɵɵsetComponentScope(j,[o.NgIf,T,H,w],[]),e.LimbleTreeModule=q,e.LimbleTreeRootComponent=k,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=limble-limble-tree.umd.min.js.map
{
"name": "@limble/limble-tree",
"version": "0.11.6",
"version": "0.11.7",
"peerDependencies": {

@@ -5,0 +5,0 @@ "@angular/common": "^11.2.5",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc