@dynamix-layout/core 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/README.md +23 -192
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +519 -0
- package/dist/index.d.ts +519 -0
- package/dist/index.js +1338 -0
- package/dist/index.umd.js +1 -0
- package/package.json +12 -11
- package/dist/core.cjs +0 -57
- package/dist/core.es.js +0 -1381
- package/dist/core.iife.js +0 -57
- package/dist/core.umd.js +0 -57
- package/dist/types/index.d.cts +0 -522
- package/dist/types/index.d.ts +0 -522
package/dist/core.iife.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
this.dynamix=this.dynamix||{};this.dynamix.layout=this.dynamix.layout||{};this.dynamix.layout.core=(function(y){"use strict";class x{buffer;head=0;tail=0;count=0;capacity;constructor(t=16,e=[]){this.capacity=Math.max(t,e.length),this.buffer=new Array(this.capacity),e.forEach(n=>{this.enqueue(n)})}enqueue(t){this.count===this.capacity&&this.resize(),this.buffer[this.tail]=t,this.tail=(this.tail+1)%this.capacity,this.count++}enqueueFront(t){this.count===this.capacity&&this.resize(),this.head=(this.head-1+this.capacity)%this.capacity,this.buffer[this.head]=t,this.count++}insert(t,e){if(t<0||t>this.count)return!1;if(t===0)return this.enqueueFront(e),!0;if(t===this.count)return this.enqueue(e),!0;this.count===this.capacity&&this.resize();const n=t,i=this.count-t;return n<=i?this.shiftLeft(t,e):this.shiftRight(t,e),this.count++,!0}insertArray(t,e){if(t<0||t>this.count)return!1;if(e.length===0)return!0;if(t===0){for(let r=e.length-1;r>=0;r--)this.enqueueFront(e[r]);return!0}if(t===this.count)return e.forEach(r=>this.enqueue(r)),!0;for(;this.count+e.length>this.capacity;)this.resize();const n=t,i=this.count-t,s=e.length;return n<=i?this.shiftLeftArray(t,e):this.shiftRightArray(t,e),this.count+=s,!0}insertQueue(t,e){if(t<0||t>this.count)return!1;if(e.isEmpty())return!0;const n=e.size();if(t===0){const h=e.toArray();for(let u=h.length-1;u>=0;u--)this.enqueueFront(h[u]);return!0}if(t===this.count){for(const h of e)this.enqueue(h);return!0}for(;this.count+n>this.capacity;)this.resize();const i=e.toArray(),s=t,r=this.count-t;return s<=r?this.shiftLeftArray(t,i):this.shiftRightArray(t,i),this.count+=n,!0}push(t){this.enqueue(t)}unshift(t){this.enqueueFront(t)}dequeue(){if(this.count===0)return;const t=this.buffer[this.head];return this.head=(this.head+1)%this.capacity,this.count--,t}dequeueBack(){if(this.count===0)return;this.tail=(this.tail-1+this.capacity)%this.capacity;const t=this.buffer[this.tail];return this.count--,t}indexOf(t){for(let e=0;e<this.count;e++){const n=(this.head+e)%this.capacity;if(this.buffer[n]===t)return e}return-1}remove(t){const e=this.indexOf(t);return e===-1?!1:(this.removeAt(e),!0)}removeAt(t){if(t<0||t>=this.count)return;if(t===0)return this.dequeue();if(t===this.count-1)return this.dequeueBack();const e=(this.head+t)%this.capacity,n=this.buffer[e],i=t,s=this.count-t-1;return i<=s?this.shiftRightForRemoval(t):this.shiftLeftForRemoval(t),this.count--,n}shift(){return this.dequeue()}pop(){return this.dequeueBack()}fifoAdd(t){this.enqueue(t)}fifoRemove(){return this.dequeue()}filoAdd(t){this.enqueue(t)}filoRemove(){return this.dequeueBack()}lifoAdd(t){this.enqueueFront(t)}lifoRemove(){return this.dequeue()}liloAdd(t){this.enqueueFront(t)}liloRemove(){return this.dequeueBack()}get(t){if(t<0||t>=this.count)return;const e=(this.head+t)%this.capacity;return this.buffer[e]}set(t,e){if(t<0||t>=this.count)return!1;const n=(this.head+t)%this.capacity;return this.buffer[n]=e,!0}peek(){return this.count>0?this.buffer[this.head]:void 0}peekBack(){if(this.count===0)return;const t=(this.tail-1+this.capacity)%this.capacity;return this.buffer[t]}front(){return this.peek()}back(){return this.peekBack()}size(){return this.count}getCapacity(){return this.capacity}isEmpty(){return this.count===0}isFull(){return this.count===this.capacity}clear(){this.head=0,this.tail=0,this.count=0}toArray(){const t=[];for(let e=0;e<this.count;e++){const n=(this.head+e)%this.capacity;t.push(this.buffer[n])}return t}*[Symbol.iterator](){for(let t=0;t<this.count;t++){const e=(this.head+t)%this.capacity;yield this.buffer[e]}}*forward(){for(let t=0;t<this.count;t++){const e=(this.head+t)%this.capacity;yield this.buffer[e]}}*reverse(){for(let t=this.count-1;t>=0;t--){const e=(this.head+t)%this.capacity;yield this.buffer[e]}}*entries(){for(let t=0;t<this.count;t++){const e=(this.head+t)%this.capacity;yield[t,this.buffer[e]]}}*keys(){for(let t=0;t<this.count;t++)yield t}*values(){for(let t=0;t<this.count;t++){const e=(this.head+t)%this.capacity;yield this.buffer[e]}}toString(){return`Queue(${this.toArray().join(", ")})`}resize(){const t=this.capacity*2,e=new Array(t);for(let n=0;n<this.count;n++){const i=(this.head+n)%this.capacity;e[n]=this.buffer[i]}this.buffer=e,this.capacity=t,this.head=0,this.tail=this.count}shiftLeft(t,e){this.head=(this.head-1+this.capacity)%this.capacity;for(let i=0;i<t;i++){const s=(this.head+1+i)%this.capacity,r=(this.head+i)%this.capacity;this.buffer[r]=this.buffer[s]}const n=(this.head+t)%this.capacity;this.buffer[n]=e}shiftRight(t,e){for(let i=this.count-1;i>=t;i--){const s=(this.head+i)%this.capacity,r=(this.head+i+1)%this.capacity;this.buffer[r]=this.buffer[s]}const n=(this.head+t)%this.capacity;this.buffer[n]=e,this.tail=(this.tail+1)%this.capacity}shiftRightForRemoval(t){for(let e=t;e>0;e--){const n=(this.head+e-1)%this.capacity,i=(this.head+e)%this.capacity;this.buffer[i]=this.buffer[n]}this.head=(this.head+1)%this.capacity}shiftLeftForRemoval(t){for(let e=t;e<this.count-1;e++){const n=(this.head+e+1)%this.capacity,i=(this.head+e)%this.capacity;this.buffer[i]=this.buffer[n]}this.tail=(this.tail-1+this.capacity)%this.capacity}shiftLeftArray(t,e){const n=e.length;this.head=(this.head-n+this.capacity)%this.capacity;for(let i=0;i<t;i++){const s=(this.head+n+i)%this.capacity,r=(this.head+i)%this.capacity;this.buffer[r]=this.buffer[s]}for(let i=0;i<n;i++){const s=(this.head+t+i)%this.capacity;this.buffer[s]=e[i]}}shiftRightArray(t,e){const n=e.length;for(let i=this.count-1;i>=t;i--){const s=(this.head+i)%this.capacity,r=(this.head+i+n)%this.capacity;this.buffer[r]=this.buffer[s]}for(let i=0;i<n;i++){const s=(this.head+t+i)%this.capacity;this.buffer[s]=e[i]}this.tail=(this.tail+n)%this.capacity}}function T(o,t=(e,n)=>e===n){let e=o;const n=new Set;let i=[];const s=()=>e,r=(l,m=!1)=>{if(m){e=l;return}t(e,l)||(e=l,n.forEach(p=>p(e)),i.forEach(p=>p(e)),i=[])},h=()=>{n.forEach(l=>l(e)),i.forEach(l=>l(e)),i=[]},u=l=>(n.add(l),()=>n.delete(l)),f=()=>new Promise(l=>{i.push(l)});return{get:s,set:r,onChange:u,nextChange:f,triggerChange:h,onChangePromise:l=>{let m=!0;return(async()=>{for(;m;){const I=await f();if(!m)break;l(I)}})(),()=>{m=!1}}}}function v(o,t){if(o.size!==t.size)return!1;for(const[e,n]of o.entries()){const i=t.get(e);if(!i||!A(n,i))return!1}return!0}function A(o,t){if(o.typNode!==t.typNode||o.nodName!==t.nodName||o.uidNode!==t.uidNode||o.nodPart!==t.nodPart||o.nodFold!==t.nodFold||o.nodMaxd!==t.nodMaxd||o.nodHidden!==t.nodHidden||o.nodLocked!==t.nodLocked)return!1;const e=o.nodDims,n=t.nodDims;return e.x===n.x&&e.y===n.y&&e.w===n.w&&e.h===n.h}const S=()=>crypto.randomUUID(),R={set:(o,t)=>setTimeout(o,t),clear:o=>clearTimeout(o)},c={createId:S,timer:R,root:void 0,tree:null,minW:40,minH:40,bond:10,inst:null,maximized:null,collapsedSize:40,foldSeq:0};class a{static cache={dimMins:new Map,mapDirs:new Map,tabCnts:new Map,mapElem:new Map,tabOpts:T(new Map,v),nodOpts:T(new Map,v),bndOpts:T(new Map,v)};kids=new x;dims={w:0,h:0,x:0,y:0};unId;next=null;prev=null;type="row";name="";part=0;host=null;open="";collapsed=!1;foldedAt=0;constructor(t={}){const e={type:"row",host:null,name:"",part:100,dims:{w:0,h:0,x:0,y:0},unId:c.createId(),open:""};this.type=t.type??e.type,this.host=t.host??e.host,this.name=t.name??e.name,this.part=t.part??e.part,this.dims=t.dims??e.dims,this.open=t.open??e.open,this.unId=t.unId||e.unId}addBond(t,e=null){if(!e)return;const n=new D(t,this,e);a.cache.mapElem.set(n.unId,n)}getReqDimension(){const t=a.cache.dimMins.get(this.unId),e=a.cache.tabCnts.get(this.unId),n=Math.max(t.minWidth,e.horizontal*c.minW+Math.max(0,e.horizontal-1)*c.bond),i=Math.max(t.minHeight,e.vertical*c.minH+Math.max(0,e.vertical-1)*c.bond);return{width:n,height:i}}calcDimensions(){const t=a.cache.mapDirs.get(this.unId);if(!this.kids)return;let e=0;const n=a.cache.dimMins.get(this.unId)||{minWidth:0,minHeight:0};let i=0,s;for(const d of this.kids)d.collapsed||(e+=d.part,s=d);if(e===0)return;let r;t?r=this.dims.w-n.minWidth:r=this.dims.h-n.minHeight;const h=r<0;let u=0,f=0;for(const d of this.kids){const l=a.cache.dimMins.get(d.unId)||{minWidth:0,minHeight:0};let m=0;if(!h&&!d.collapsed){u+=d.part;const p=d===s?r:Math.round(r*u/e);m=p-f,f=p}t?(d.dims.w=l.minWidth+m,d.dims.h=this.dims.h,d.dims.x=this.dims.x+i,d.dims.y=this.dims.y,i+=d.dims.w+c.bond):(d.dims.h=l.minHeight+m,d.dims.w=this.dims.w,d.dims.y=this.dims.y+i,d.dims.x=this.dims.x,i+=d.dims.h+c.bond),d.next&&(t?d.next.dims={w:c.bond,h:d.dims.h,x:d.dims.x+d.dims.w,y:d.dims.y}:d.next.dims={w:d.dims.w,h:c.bond,x:d.dims.x,y:d.dims.y+d.dims.h})}}toJSON(){const t=[];for(const n of this.kids)t.push(n.toJSON());const e={typNode:this.type,nodPart:this.part,nodName:this.name,uidNode:this.unId};return this.open&&(e.nodOpen=this.open),this.collapsed&&(e.nodFold=!0),this===c.root&&c.maximized&&(e.nodMaxd=c.maximized),t.length>0&&(e.nodKids=t),e}}class D{dims={w:0,h:0,x:0,y:0};unId=c.createId();next=null;prev=null;host=null;constructor(t=null,e=null,n=null){this.host=t,this.next=e,this.prev=n,this.next&&(this.next.prev=this),this.prev&&(this.prev.next=this)}toJSON(){return{nodName:this.host?.name||"",typNode:"bond",uidNode:this.unId,nodPart:0,nodOpen:"",nodKids:[]}}}function*P(o){const t=new x;for(t.enqueue(o);!t.isEmpty();){const e=t.dequeue();if(e&&(yield e,e.nodKids&&e.nodKids.length>0))for(const n of e.nodKids)t.enqueue(n)}}function*K(o){const t=new x;for(t.enqueue(o);!t.isEmpty();){const e=t.dequeue();if(e&&(a.cache.mapElem.set(e.unId,e),yield e,e.kids.size()>0))for(const n of e.kids)t.enqueue(n)}}function*U(o,t){for(const e of t.kids)yield*o.NodeLayoutRecursiveIterator(e);yield t}function $(o,t){const e=a.cache.mapDirs.get(t.unId);if(e===void 0){console.warn(`Cannot update child directions for node ${t.unId}; its own direction is not set.`);return}for(const n of t.kids)a.cache.mapDirs.set(n.unId,!e),n.kids.size()>0&&(n.host=t,o.updateChildDirections(n),n.next&&a.cache.mapDirs.set(n.next.unId,!e))}function _(o,t=c.tree){if(!t)return;const e=o.JSONLayoutIterator(t),n=o.NodeLayoutIterator(c.root);for(a.cache.mapDirs.set(c.root.unId,!0);;){const i=e.next(),s=n.next();if(i.done||s.done)break;const r=i.value,h=s.value;!r||!h||o.createNodeTreeFromJSONTree(r,h)}o.calcTabsetCountAndMinDim()}function Y(o,t,e){const n=a.cache.mapDirs.get(e.unId);for(const i of t.nodKids||[]){const s=o.createNodeFromJSON(i),r=e.kids.peekBack();s.host=e,s.addBond(s.host,r),e.kids.enqueue(s),a.cache.mapDirs.set(s.unId,!n)}e.type==="tabset"&&a.cache.mapElem.set(e.unId,e),e.type==="tab"&&a.cache.mapElem.set(e.unId,e)}function G(o,t,e=c.root){const n=new x;for(n.enqueue(e),a.cache.mapDirs.set(c.root.unId,!0);!t.isEmpty();){const i=n.dequeue();if(!i)break;const s=a.cache.mapDirs.get(i.unId);if(t.size()===1){const d=t.dequeue(),l=new a({type:"tabset",host:i}),m=new a({type:"tab",host:l,name:d,unId:o.tabsIds.get(d??"")??c.createId()});l.open=m.name,l.kids.enqueue(m),i.kids.enqueue(l),a.cache.mapDirs.set(l.unId,!s),a.cache.mapDirs.set(m.unId,s),a.cache.mapElem.set(l.unId,l),a.cache.mapElem.set(m.unId,m);break}if(t.size()==2){const d=t.dequeue(),l=t.dequeue(),m=new a({type:"tabset",host:i}),p=new a({type:"tabset",host:i}),I=new a({type:"tab",host:m,name:d,unId:o.tabsIds.get(d??"")??c.createId()}),w=new a({type:"tab",host:p,name:l,unId:o.tabsIds.get(l??"")??c.createId()});m.open=I.name,p.open=w.name,m.kids.enqueue(I),p.kids.enqueue(w),i.kids.enqueue(m),i.kids.enqueue(p),p.addBond(i,m),a.cache.mapDirs.set(m.unId,!s),a.cache.mapDirs.set(p.unId,!s),a.cache.mapElem.set(m.unId,m),a.cache.mapElem.set(p.unId,p),a.cache.mapDirs.set(I.unId,s),a.cache.mapDirs.set(w.unId,s),a.cache.mapElem.set(I.unId,I),a.cache.mapElem.set(w.unId,w);break}const r=t.dequeue(),h=new a({type:"tabset",host:i}),u=new a({type:"row",host:i}),f=new a({type:"tab",host:h,name:r,unId:o.tabsIds.get(r??"")??c.createId()});h.open=f.name,h.kids.enqueue(f),i.kids.enqueue(h),i.kids.enqueue(u),u.addBond(i,h),a.cache.mapDirs.set(h.unId,!s),a.cache.mapDirs.set(u.unId,!s),a.cache.mapElem.set(h.unId,h),a.cache.mapDirs.set(f.unId,s),a.cache.mapElem.set(f.unId,f),n.enqueue(u)}o.calcTabsetCountAndMinDim()}function J(o,t){const e=new a({type:t.typNode,name:t.nodName,unId:t.uidNode,part:t.nodPart,dims:{w:0,h:0,x:0,y:0},open:typeof t.nodOpen=="string"?t.nodOpen:""});return e.collapsed=t.typNode==="tabset"&&t.nodFold===!0,t.typNode==="tab"&&(e.unId=o.tabsIds.get(t.nodName)||t.uidNode),e}function E(o){const t=a.cache.mapElem.get(o);return t instanceof a&&t.type==="tabset"?t:null}function Q(o=c.root){let t=0;const e=n=>{n.type==="tabset"&&t++;for(const i of n.kids)e(i)};return e(o),t}function O(o){return o.type==="tabset"&&!!o.host&&o.host.kids.size()>1}function H(){return Q()>1}function M(){const o=c.maximized;return o?E(o):null}function z(o,t){let e=null;for(const n of o.kids)n===t||!n.collapsed||(!e||n.foldedAt>e.foldedAt)&&(e=n);e&&(e.collapsed=!1)}function j(o=c.root){let t=!1;const e=n=>{n.type==="tabset"&&(n.unId===c.maximized&&(t=!0),n.collapsed&&!O(n)&&(n.collapsed=!1)),n.type!=="tab"&&n.kids.size()>0&&[...n.kids].every(s=>s.collapsed)&&z(n);for(const i of n.kids)e(i)};e(o),t||(c.maximized=null)}function q(o,t){return!E(t)||!H()||c.maximized===t?!1:(c.maximized=t,o.calcDimensions(),!0)}function F(o){return c.maximized?(c.maximized=null,o.calcDimensions(),!0):!1}function V(o,t){return c.maximized===t?F(o):q(o,t)}function B(o,t){const e=E(t);if(!e||e.collapsed||!O(e))return!1;c.maximized=null,e.collapsed=!0,e.foldedAt=++c.foldSeq;const n=e.host;return[...n.kids].every(i=>i.collapsed)&&z(n,e),o.calcTabsetCountAndMinDim(),o.calcDimensions(),!0}function C(o,t){const e=E(t);return!e||!e.collapsed?!1:(e.collapsed=!1,o.calcTabsetCountAndMinDim(),o.calcDimensions(),!0)}function X(o,t){const e=E(t);return e?e.collapsed?C(o,t):B(o,t):!1}function Z(o,t=c.root,e=!0){t===c.root&&e&&(j(t),a.cache.tabCnts.clear(),a.cache.dimMins.clear(),a.cache.mapElem.clear(),a.cache.nodOpts.get().clear(),a.cache.bndOpts.get().clear());for(const n of o.NodeLayoutRecursiveIterator(t)){const i=a.cache.tabCnts,s=a.cache.dimMins;a.cache.mapElem.set(n.unId,n);const r=i.set(n.unId,{horizontal:0,vertical:0}).get(n.unId),h=s.set(n.unId,{minWidth:0,minHeight:0}).get(n.unId),u=a.cache.mapDirs.get(n.unId);if(n.type==="tab"&&(a.cache.mapElem.set(n.unId,n),s.set(n.unId,{minWidth:0,minHeight:0})),n.next&&a.cache.mapElem.set(n.next.unId,n.next),n.type==="tabset"&&(a.cache.mapElem.set(n.unId,n),s.set(n.unId,{minWidth:c.minW,minHeight:c.minH}),u?i.set(n.unId,{horizontal:0,vertical:1}):i.set(n.unId,{horizontal:1,vertical:0}),n.collapsed&&n.host&&(a.cache.mapDirs.get(n.host.unId)?(s.set(n.unId,{minWidth:c.collapsedSize,minHeight:c.minH}),i.get(n.unId).horizontal=0):(s.set(n.unId,{minWidth:c.minW,minHeight:c.collapsedSize}),i.get(n.unId).vertical=0))),n.type==="row"){for(const f of n.kids){const d=i.get(f.unId),l=s.get(f.unId);d&&(r.horizontal+=d.horizontal,r.vertical+=d.vertical,u?(h.minHeight=Math.max(h.minHeight,l.minHeight),h.minWidth+=l.minWidth):(h.minHeight+=l.minHeight,h.minWidth=Math.max(h.minWidth,l.minWidth)))}u?h.minWidth+=(n.kids.size()-1)*c.bond:h.minHeight+=(n.kids.size()-1)*c.bond}}t===c.root&&e&&o.pruneStaleDirections()}function tt(){for(const o of a.cache.mapDirs.keys())a.cache.mapElem.has(o)||a.cache.mapDirs.delete(o)}function et(){const o=c.root.getReqDimension();let t=!1,e=c.root.dims.w,n=c.root.dims.h;return c.root.dims.w<o.width&&(e=o.width,t=!0),c.root.dims.h<o.height&&(n=o.height,t=!0),t&&(c.root.dims.w=e,c.root.dims.h=n),{adjustedW:e,adjustedH:n,wasAdjusted:t}}function nt(o,t=c.root,e=!1){const n=t===c.root,i=d=>n?new Map:new Map(d.get()),s=i(a.cache.nodOpts),r=i(a.cache.bndOpts),h=i(a.cache.tabOpts);n&&o.calculateRootAdjustment();const u=M(),f=H();for(const d of o.NodeLayoutIterator(t)){d.calcDimensions();const l=a.cache.mapDirs.get(d.unId);if(d.type==="tabset"){const m=d===u,p=!!u&&!m,I=m?{...c.root.dims}:{...d.dims},w={typNode:d.type,nodName:d.name,uidNode:d.unId,nodPart:d.part,nodOpen:d.open,nodeDir:l,nodFold:d.collapsed&&!m,nodMaxd:m,nodHidden:p,nodFoldable:O(d),nodMaximizable:f,nodKids:Array.from(d.kids).map(k=>{const g={typNode:k.type,nodName:k.name,uidNode:k.unId,nodPart:k.part,nodOpen:d.open===k.name,nodeDir:!l,nodHidden:p,nodFold:d.collapsed&&!m,nodDims:{...I}};return h.set(k.unId,g),g}),nodDims:I};s.set(d.unId,w)}if(d.next&&d.type!=="tab"){const m={typNode:"bond",nodName:d.name,uidNode:d.next.unId,nodeDir:l,nodPart:0,nodHidden:!!u,nodLocked:d.collapsed||!!d.next.next?.collapsed,nodDims:{...d.next.dims}};r.set(d.next.unId,m)}}a.cache.nodOpts.set(s,e),a.cache.bndOpts.set(r,e),a.cache.tabOpts.set(h,e)}function it(o,t,e=!1,n=2){if(c.root.dims=t,e){o.calcDimensions(c.root);return}o.cntdown&&(c.timer.clear(o.cntdown),o.cntdown=null),o.cntdown=c.timer.set(()=>{o.cntdown=null,o.calcDimensions()},n)}function ot(o,t,e,n=!1,i=2){if(n){o.updateSliderDimension(t,e);return}o.cntdown&&(c.timer.clear(o.cntdown),o.cntdown=null),o.cntdown=c.timer.set(()=>{o.cntdown=null,o.updateSliderDimension(t,e)},i)}function st(o,t,e){const n=a.cache.mapElem.get(t);if(!n||!(n instanceof D)){console.warn(`Bond with id ${t} not found or is not a Bond instance`);return}const i=a.cache.mapDirs.get(n.host.unId),s=n.prev,r=n.next,h=n.host;if(!s||!r||!h){console.warn("Missing prev, next, or host node",s,r,h);return}if(s.collapsed||r.collapsed||c.maximized)return;const u=a.cache.dimMins.get(s.unId)||{minWidth:0,minHeight:0},f=a.cache.dimMins.get(r.unId)||{minWidth:0,minHeight:0},d=c.bond/2;if(i){const l=r.dims.x+r.dims.w,m=s.dims.x+u.minWidth+d,p=l-f.minWidth-d,I=Math.max(m,Math.min(p,e.x));n.dims.x=I-d,s.dims.w=n.dims.x-s.dims.x,r.dims.x=I+d,r.dims.w=l-r.dims.x;const w=Math.max(0,s.dims.w-u.minWidth),k=Math.max(0,r.dims.w-f.minWidth),g=w+k,N=s.part+r.part;g>0?(s.part=w/g*N,r.part=k/g*N):(s.part=N/2,r.part=N/2)}else{const l=r.dims.y+r.dims.h,m=s.dims.y+u.minHeight+d,p=l-f.minHeight-d,I=Math.max(m,Math.min(p,e.y));n.dims.y=I-d,s.dims.h=n.dims.y-s.dims.y,r.dims.y=I+d,r.dims.h=l-r.dims.y;const w=Math.max(0,s.dims.h-u.minHeight),k=Math.max(0,r.dims.h-f.minHeight),g=w+k,N=s.part+r.part;g>0?(s.part=w/g*N,r.part=k/g*N):(s.part=N/2,r.part=N/2)}o.calcDimensions(h)}function at(o,t,e,n){const i=a.cache.mapElem.get(t);let s=a.cache.mapElem.get(e);return!i||!(i instanceof a)||!s||!(s instanceof a)?(console.warn(`Source node ${t} not found or is not a Node instance`),!1):i?.type=="tab"&&i.host===s&&s.kids.size()<2?(console.warn("Cannot move to self as it has only one tab"),!1):i?.type=="tabset"&&s?.host===i?(console.warn("Cannot move tabset to self as it is already a child"),!1):!i||!s?(console.warn(`Source or destination node not found: ${t}, ${e}`),!1):i===s?(console.warn("Source and destination nodes are the same, no action taken."),!1):!i.host||!s.host&&s.type!=="row"?(console.warn(`Source node or destination node's host is null: ${i.unId}, ${s.unId}`),!1):s.type==="row"&&s!==c.root?(console.warn(`Cannot move relative to a nested row: ${s.unId}`),!1):s.type==="row"&&n==="contain"?(console.warn(`Cannot move to a row with 'contain' layout: ${s.unId}`),!1):i.type==="row"||(s.type==="tabset"&&n==="contain"&&(s=s.kids.peekBack()||s),i===s)?!1:o.isOnlyContent(i)?(console.warn("Cannot move the only tabset or tab in the layout"),!1):(c.maximized=null,i.collapsed=!1,s.type==="tab"&&(n==="contain"||n==="left"||n==="right")?o.moveNodeAsTab(i,s,n):s.type==="row"&&n!=="contain"?o.moveRelativeToRoot(i,s,n):s.type==="tabset"&&n!=="contain"&&o.moveRelativeToTabset(i,s,n),o.calcTabsetCountAndMinDim(),o.calcDimensions(c.root,!0),!0)}function rt(o,t){let e=0;for(const n of o.NodeLayoutRecursiveIterator(c.root))n.type==="tabset"&&e++;return e!==1?!1:t.type==="tabset"||t.type==="tab"&&t.host?.kids.size()===1}function dt(o,t,e,n){if(!e||!e.host){console.warn(`Destination node ${e.unId} has no host, cannot move.`);return}o.removeNode(t);const i=e.host,s=i.kids.indexOf(e);if(s===void 0||s===-1)return;const r=n==="contain"||n==="left",h=r?s:s+1,u=i.kids.get(h+1),f=i.kids.get(h-1),d=e.next,l=e.prev;if(!r&&d?a.cache.mapElem.delete(d.unId):r&&l&&a.cache.mapElem.delete(l.unId),t.type=="tab")r?(f&&t.addBond(i,f),e.addBond(i,t)):(t.addBond(i,e),u&&u.addBond(i,t)),i.kids.insert(h,t),t.host=i,i.open=t.name,i.collapsed=!1;else if(t.type=="tabset"){const m=t.kids.peek(),p=t.kids.peekBack();r?(m&&f&&m.addBond(i,f),p&&e&&e.addBond(i,p)):(m&&e&&m.addBond(i,e),p&&u&&u.addBond(i,p)),i.kids.insertQueue(h,t.kids);for(const I of t.kids)I.host=i,I.next&&(I.next.host=i);i.open=p?p.name:"",i.collapsed=!1}o.updateChildDirections(i)}const ct={root:(o,t)=>o===t,tabset:(o,t)=>o!==t};function W(o,t,e,n,i){if(o.removeNode(t),t.type!=="tab"&&t.type!=="tabset")return;const s=a.cache.mapDirs.get(e.unId)===!1,r=n==="left"||n==="right",h=n==="top"||n==="left";let u=t;t.type==="tab"&&(u=new a({type:"tabset",host:e.host}),u.kids.enqueue(t),u.open=t.name,t.host=u),ct[i](s,r)?o.insertNodeWithNewParent(u,e,h):o.insertNode(e,u,h)}function ht(o,t,e,n){W(o,t,e,n,"root")}function ut(o,t,e,n){W(o,t,e,n,"tabset")}function lt(o,t,e,n){const i=t.host;if(t==c.root){const l=c.root.kids.peek(),m=c.root.kids.peekBack();n?(c.root.kids.enqueueFront(e),l&&l.addBond(c.root,e)):(c.root.kids.enqueue(e),m&&e.addBond(c.root,m)),e.host=c.root,o.updateChildDirections(c.root);return}if(!i){console.warn(`Destination node ${t.unId} has no host, cannot insert.`);return}const s=i.kids.indexOf(t);if(s===-1){console.warn(`Destination node ${t.unId} not found in its host's kids.`);return}const r=a.cache.mapDirs.get(i.unId);r&&a.cache.mapDirs.set(e.unId,!r);const h=i.kids.get(s+1),u=i.kids.get(s-1),f=t.next,d=t.prev;e.host=i,n?(i.kids.insert(s,e),t.addBond(i,e),u&&e.addBond(i,u),d&&a.cache.mapElem.delete(d.unId)):(i.kids.insert(s+1,e),e.addBond(i,t),h&&h.addBond(i,e),f&&a.cache.mapElem.delete(f.unId)),o.updateChildDirections(i)}function ft(o,t,e,n){const i=new x,s=new a({type:"tabset",host:e.host});if(!e||!t){console.warn(`Destination node ${e.unId} has no host, cannot insert.`);return}if(e===c.root){const h=new a({type:"row",host:e});if(e.kids.size()===0)e.kids.enqueue(t),t.host=e;else if(e.kids.size()==1&&e.kids.peek()?.type==="tabset"){const u=e.kids.dequeue();if(!u){console.warn(`No kid found in destination node ${e.unId}, cannot insert.`);return}n?(h.kids.enqueue(t),h.kids.enqueue(u),e.kids.enqueue(h),u.addBond(h,t)):(h.kids.enqueue(u),h.kids.enqueue(t),t.addBond(h,u),e.kids.enqueue(h)),t.host=h,u.host=h}else if(e.kids.size()==1&&e.kids.peek()?.type==="row"){const u=e.kids.peek(),f=u?.kids.peek(),d=u?.kids.peekBack();n&&u?(u.kids.enqueueFront(t),f&&f.addBond(u,t)):u&&(u.kids.enqueue(t),d&&t.addBond(u,d)),t.host=u}else if(e.kids.size()>1){const u=new a({type:"row",host:e}),f=new a({type:"row",host:u});for(const d of e.kids)f.kids.enqueue(d),d.host=f,d.next&&(d.next.host=f);t.host=u,e.kids.clear(),n?(u.kids.enqueueFront(t),u.kids.enqueue(f),f.addBond(u,t)):(u.kids.enqueue(f),u.kids.enqueue(t),t.addBond(u,f)),e.kids.enqueue(u)}o.updateChildDirections(e);return}t.host=e,s.host=e,s.kids=e.kids,s.open=e.open;const r=a.cache.mapDirs.get(e.unId);for(const h of s.kids)h.host=s,h.next&&(h.next.host=s),a.cache.mapDirs.set(h.unId,r);for(const h of t.kids)h.host=t,h.next&&(h.next.host=t),a.cache.mapDirs.set(h.unId,r);a.cache.mapDirs.set(s.unId,!r),a.cache.mapDirs.set(t.unId,!r),n?(i.enqueue(t),i.enqueue(s),e.kids=i,e.type="row",s.addBond(e,t)):(i.enqueue(s),i.enqueue(t),e.kids=i,e.type="row",t.addBond(e,s))}function mt(o,t){if(!t.host||!t.host.host){console.warn(`Source node ${t.unId} has no host, cannot move.`);return}const e=t.host,n=t.host.host,i=n.kids.indexOf(e),s=n.kids.get(i-1),r=n.kids.get(i+1),h=t.kids.peek(),u=t.kids.peekBack();o.removeKid(e);let f=i;if(t.type=="row"&&e){s&&h&&h.addBond(n,s),r&&u&&r.addBond(n,u);for(const d of t.kids)d.host=n,d.next&&(d.next.host=n),n.kids.insert(f,d),a.cache.mapDirs.set(d.unId,!a.cache.mapDirs.get(n.unId)),a.cache.dimMins.delete(d.unId),f++}else if(t.type=="tabset"){s&&t.addBond(n,s),r&&r.addBond(n,t),n.kids.insert(f,t),t.host=n,a.cache.mapDirs.set(t.unId,!a.cache.mapDirs.get(n.unId));for(const d of t.kids)a.cache.mapDirs.set(d.unId,a.cache.mapDirs.get(n.unId)),a.cache.dimMins.delete(d.unId)}}function pt(o,t=!0){const e=o.host,n=o.prev,i=o.next;if(o.host=null,o.next=null,o.prev=null,n&&(n.next=null),i&&(i.prev=null),!t)return o;n&&i&&n.prev&&i.next?n.prev.addBond(e,i.next):n&&n.prev?n.prev.next=null:i&&i.next&&(i.next.prev=null)}function It(o,t){if(!t.host){console.warn("Kid node has no host, cannot remove.");return}const e=t?.host,n=e?.host;if(o.removeKid(t),t.type==="tabset"&&e.kids.size()===1){const i=e.kids.peek();i&&o.moveAdjacentNodeToGrandParent(i)}else if(t.type==="tab"&&e.kids.size()===0&&n.kids.size()===2){o.removeKid(e);const i=n?.kids.peek();i&&o.moveAdjacentNodeToGrandParent(i)}else if(t.type==="tab"&&e.kids.size()===0&&n.kids.size()>2)o.removeKid(e);else if(t.type==="tab"&&e.open===t.name&&e.kids.size()>0){const i=e.kids.peek();i&&(e.open=i.name)}}function yt(o){if(!o.host){console.warn("Kid node has no host, cannot remove.");return}const t=o.host,e=t.kids.indexOf(o),n=t.kids.get(e+1),i=t.kids.get(e-1),s=o.next,r=o.prev;if(e===-1){console.warn("Kid node not found in its host's kids.");return}s&&a.cache.mapElem.delete(s.unId),r&&a.cache.mapElem.delete(r.unId),n&&i?n.addBond(t,i):n?n.prev=null:i&&(i.next=null),t.kids.removeAt(e),a.cache.mapElem.delete(o.unId),a.cache.dimMins.delete(o.unId),a.cache.mapDirs.delete(o.unId),a.cache.tabCnts.delete(o.unId),o.type==="tabset"&&a.cache.mapElem.delete(o.unId),o.type==="tab"&&a.cache.mapElem.delete(o.unId),o.host=null,o.next=null,o.prev=null}function wt(){a.cache.dimMins.clear(),a.cache.mapDirs.clear(),a.cache.tabCnts.clear(),a.cache.mapElem.clear(),a.cache.nodOpts.get().clear(),a.cache.bndOpts.get().clear()}class b{static get _root(){return c.root}static set _root(t){c.root=t}static get _tree(){return c.tree}static set _tree(t){c.tree=t}static get _minW(){return c.minW}static set _minW(t){c.minW=t}static get _minH(){return c.minH}static set _minH(t){c.minH=t}static get _bond(){return c.bond}static set _bond(t){c.bond=t}static get _inst(){return c.inst}static set _inst(t){c.inst=t}nodeOps;cntdown=null;tabsIds=new Map;constructor(t={}){const e={tabs:[],tree:null,minW:40,minH:40,bond:10,uqid:"dynamix-layout-root",tabsIds:new Map,...t};this.tabsIds=e.tabsIds,c.createId=e.createId??S,c.timer=e.timer??R,c.collapsedSize=e.collapsedSize??e.minH,b._tree=e.tree??null,c.maximized=e.tree?.nodMaxd??null,b._root=new a({unId:e.uqid,name:e.uqid,type:"row"}),this.nodeOps=T(new Map,v),b._minW=e.minW,b._minH=e.minH,b._bond=e.bond;const n=new x(e.tabs.length,e.tabs);b._tree?this.createNodeLayout():this.createBinaryNodeTreeFromQueue(n),b._inst=this}*JSONLayoutIterator(t){yield*P(t)}*NodeLayoutIterator(t){yield*K(t)}*NodeLayoutRecursiveIterator(t){yield*U(this,t)}updateChildDirections(t){return $(this,t)}createNodeLayout(t=b._tree){return _(this,t)}createNodeTreeFromJSONTree(t,e){return Y(this,t,e)}createBinaryNodeTreeFromQueue(t,e=b._root){return G(this,t,e)}createNodeFromJSON(t){return J(this,t)}calcTabsetCountAndMinDim(t=b._root,e=!0){return Z(this,t,e)}pruneStaleDirections(){return tt()}calculateRootAdjustment(){return et()}calcDimensions(t=b._root,e=!1){return nt(this,t,e)}updateDimension(t,e=!1,n=2){return it(this,t,e,n)}updateSlider(t,e,n=!1,i=2){return ot(this,t,e,n,i)}updateSliderDimension(t,e){return st(this,t,e)}updateTree(t,e,n){return at(this,t,e,n)}isOnlyContent(t){return rt(this,t)}moveNodeAsTab(t,e,n){return dt(this,t,e,n)}moveRelativeToRoot(t,e,n){return ht(this,t,e,n)}moveRelativeToTabset(t,e,n){return ut(this,t,e,n)}insertNode(t,e,n){return lt(this,t,e,n)}insertNodeWithNewParent(t,e,n){return ft(this,t,e,n)}moveAdjacentNodeToGrandParent(t){return mt(this,t)}removeRelation(t,e=!0){return pt(t,e)}removeNode(t){return It(this,t)}removeKid(t){return yt(t)}clearAllCache(){return wt()}get maximizedId(){return M()?.unId??null}maximize(t){return q(this,t)}restore(){return F(this)}toggleMaximize(t){return V(this,t)}collapse(t){return B(this,t)}expand(t){return C(this,t)}toggleCollapse(t){return X(this,t)}}const bt=6;function kt(o,t,e){const{left:n,top:i,width:s,height:r}=o,h=t-n,u=e-i;return h<s/3?{area:"left",left:n,top:i,width:s/2,height:r}:h>2*s/3?{area:"right",left:n+s/2,top:i,width:s/2,height:r}:u<r/3?{area:"top",left:n,top:i,width:s,height:r/2}:u>2*r/3?{area:"bottom",left:n,top:i+r/2,width:s,height:r/2}:{area:"contain",left:n+s*.1,top:i+r*.1,width:s*.8,height:r*.8}}function gt(o,t){const{x:e,y:n,w:i,h:s}=o;switch(t){case"left":return{area:t,left:e,top:n,width:i/2,height:s};case"right":return{area:t,left:e+i/2,top:n,width:i/2,height:s};case"top":return{area:t,left:e,top:n,width:i,height:s/2};case"bottom":return{area:t,left:e,top:n+s/2,width:i,height:s/2}}}function Nt(o,t,e,n){if(t.length===0||n<o.top||n>o.bottom)return null;const i=t[0],s=t[t.length-1];let r=bt;if(e>s.right)return{index:t.length-1,area:"right",left:s.right+1,top:s.top,width:r-2,height:s.height};if(e<i.left)return{index:0,area:"left",left:i.left-r+1,top:i.top,width:r-2,height:i.height};let h=0,u=1/0,f=!1;t.forEach((m,p)=>{const I=m.left+m.width/2,w=Math.abs(e-I);w<u&&(u=w,h=p,f=e<I)});const d=f?h>0:h<t.length-1;t.length>1&&d&&(r=t[1].left-i.right);const l=t[h];return{index:h,area:f?"left":"right",left:f?l.left-r+1:l.right+1,top:l.top,width:r-2,height:l.height}}function xt(o,t){return o.area===t.area&&o.left===t.left&&o.top===t.top&&o.width===t.width&&o.height===t.height}function L(o,{x:t,y:e,w:n,h:i}){o.style.left=`${t}px`,o.style.top=`${e}px`,o.style.width=`${n}px`,o.style.height=`${i}px`}function Tt(o,t){return{x:o.x,y:o.y+t,w:o.w,h:Math.max(0,o.h-t)}}function vt(o,t){const{x:e,y:n,w:i,h:s}=o.nodDims,r=o.nodeDir===!1;return o.nodFold&&r?{rect:{x:e+i,y:n,w:s,h:i},rotated:!0}:{rect:{x:e,y:n,w:i,h:t},rotated:!1}}function Et(o,t){L(o,t.rect),o.style.transformOrigin="0 0",o.style.transform=t.rotated?"rotate(90deg)":""}function Dt(o){let t=null,e=null;const n=()=>{e=null;const i=t;t=null,i&&o(i.value)};return{schedule(i){t={value:i},e===null&&(e=requestAnimationFrame(n))},flush(){e!==null&&(cancelAnimationFrame(e),n())},cancel(){e!==null&&cancelAnimationFrame(e),e=null,t=null}}}return(()=>{if(typeof window>"u")return;const o="color: #03A9F4; font-weight: bold; line-height: 1.2;",t="color: #E0E0E0; font-size: 12px;",e="color: #42a5f5; font-size: 12px;",n="color: #9E9E9E; font-size: 10px;",i=`
|
|
2
|
-
██████╗ ██╗ ██╗ ███╗ ██╗ █████╗ ███╗ ███╗ ██████╗ ██╗ ██╗
|
|
3
|
-
██╔══██╗╚██╗ ██╔╝ ████╗ ██║ ██╔══██╗ ████╗ ████║ ╚═██╔═╝ ╚██╗██╔╝
|
|
4
|
-
██║ ██║ ╚████╔╝ ██╔██╗ ██║ ███████║ ██╔████╔██║ ██║ ╚███╔╝
|
|
5
|
-
██║ ██║ ╚██╔╝ ██║╚██╗██║ ██╔══██║ ██║╚██╔╝██║ ██║ ██╔██╗
|
|
6
|
-
██████╔╝ ██║ ██║ ╚████║ ██║ ██║ ██║ ╚═╝ ██║ ██████╗ ██╔╝ ██╗
|
|
7
|
-
╚═════╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝
|
|
8
|
-
██╗ █████╗ ██╗ ██╗ ██████╗ ██╗ ██╗████████╗
|
|
9
|
-
██║ ██╔══██╗ ╚██╗ ██╔╝ ██╔═══██╗ ██║ ██║╚══██╔══╝
|
|
10
|
-
██║ ███████║ ╚████╔╝ ██║ ██║ ██║ ██║ ██║
|
|
11
|
-
██║ ██╔══██║ ╚██╔╝ ██║ ██║ ██║ ██║ ██║
|
|
12
|
-
███████╗ ██║ ██║ ██║ ╚██████╔╝ ╚█████╔╝ ██║
|
|
13
|
-
╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚════╝ ╚═╝
|
|
14
|
-
`;console.groupCollapsed("%cDYNAMIX LAYOUT (click to expand)","color: #03A9F4; font-weight: bold; font-size: 14px;"),console.log(`%c${i}`,o),console.log("%c A powerful, dynamic layout system 🚀",t),console.log(`%c ⚡ For docs and more info,
|
|
15
|
-
⚡ visit: https://github.com/xcode-studio/dynamix-layout`,e),console.log(`%cMIT License
|
|
16
|
-
|
|
17
|
-
Copyright (c) 2025 Akash Aman <sir.akashaman@gmail.com> (https://akash.cx)
|
|
18
|
-
|
|
19
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
20
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
21
|
-
in the Software without restriction, including without limitation the rights
|
|
22
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
23
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
24
|
-
furnished to do so, subject to the following conditions:
|
|
25
|
-
|
|
26
|
-
The above copyright notice and this permission notice shall be included in all
|
|
27
|
-
copies or substantial portions of the Software.
|
|
28
|
-
|
|
29
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
30
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
31
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
32
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
33
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
34
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
35
|
-
SOFTWARE.
|
|
36
|
-
`,n),console.groupEnd(),typeof window<"u"&&(window.__DYNAMIX_LAYOUT__={__LICENSE__:`MIT License
|
|
37
|
-
|
|
38
|
-
Copyright (c) 2025 Akash Aman <sir.akashaman@gmail.com> (https://akash.cx)
|
|
39
|
-
|
|
40
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
41
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
42
|
-
in the Software without restriction, including without limitation the rights
|
|
43
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
44
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
45
|
-
furnished to do so, subject to the following conditions:
|
|
46
|
-
|
|
47
|
-
The above copyright notice and this permission notice shall be included in all
|
|
48
|
-
copies or substantial portions of the Software.
|
|
49
|
-
|
|
50
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
51
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
52
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
53
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
54
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
55
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
56
|
-
SOFTWARE.
|
|
57
|
-
`,__LAYOUT__:b})})(),y.Bond=D,y.DynamixLayoutCore=b,y.Node=a,y.Queue=x,y.areNodeOptionsEqual=A,y.areNodeOptionsMapEqual=v,y.createFrameScheduler=Dt,y.createReactiveState=T,y.getNavbarDropPreview=Nt,y.getRootSplitPreview=gt,y.getTabBodyRect=Tt,y.getTabbarPlacement=vt,y.getTabsetDropPreview=kt,y.isSameDropPreview=xt,y.placeTabbar=Et,y.setElementRect=L,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"}),y})({});
|
package/dist/core.umd.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
(function(I,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(I=typeof globalThis<"u"?globalThis:I||self,g((I.dynamix=I.dynamix||{},I.dynamix.layout=I.dynamix.layout||{},I.dynamix.layout.core={})))})(this,(function(I){"use strict";class g{buffer;head=0;tail=0;count=0;capacity;constructor(t=16,e=[]){this.capacity=Math.max(t,e.length),this.buffer=new Array(this.capacity),e.forEach(n=>{this.enqueue(n)})}enqueue(t){this.count===this.capacity&&this.resize(),this.buffer[this.tail]=t,this.tail=(this.tail+1)%this.capacity,this.count++}enqueueFront(t){this.count===this.capacity&&this.resize(),this.head=(this.head-1+this.capacity)%this.capacity,this.buffer[this.head]=t,this.count++}insert(t,e){if(t<0||t>this.count)return!1;if(t===0)return this.enqueueFront(e),!0;if(t===this.count)return this.enqueue(e),!0;this.count===this.capacity&&this.resize();const n=t,i=this.count-t;return n<=i?this.shiftLeft(t,e):this.shiftRight(t,e),this.count++,!0}insertArray(t,e){if(t<0||t>this.count)return!1;if(e.length===0)return!0;if(t===0){for(let r=e.length-1;r>=0;r--)this.enqueueFront(e[r]);return!0}if(t===this.count)return e.forEach(r=>this.enqueue(r)),!0;for(;this.count+e.length>this.capacity;)this.resize();const n=t,i=this.count-t,s=e.length;return n<=i?this.shiftLeftArray(t,e):this.shiftRightArray(t,e),this.count+=s,!0}insertQueue(t,e){if(t<0||t>this.count)return!1;if(e.isEmpty())return!0;const n=e.size();if(t===0){const h=e.toArray();for(let u=h.length-1;u>=0;u--)this.enqueueFront(h[u]);return!0}if(t===this.count){for(const h of e)this.enqueue(h);return!0}for(;this.count+n>this.capacity;)this.resize();const i=e.toArray(),s=t,r=this.count-t;return s<=r?this.shiftLeftArray(t,i):this.shiftRightArray(t,i),this.count+=n,!0}push(t){this.enqueue(t)}unshift(t){this.enqueueFront(t)}dequeue(){if(this.count===0)return;const t=this.buffer[this.head];return this.head=(this.head+1)%this.capacity,this.count--,t}dequeueBack(){if(this.count===0)return;this.tail=(this.tail-1+this.capacity)%this.capacity;const t=this.buffer[this.tail];return this.count--,t}indexOf(t){for(let e=0;e<this.count;e++){const n=(this.head+e)%this.capacity;if(this.buffer[n]===t)return e}return-1}remove(t){const e=this.indexOf(t);return e===-1?!1:(this.removeAt(e),!0)}removeAt(t){if(t<0||t>=this.count)return;if(t===0)return this.dequeue();if(t===this.count-1)return this.dequeueBack();const e=(this.head+t)%this.capacity,n=this.buffer[e],i=t,s=this.count-t-1;return i<=s?this.shiftRightForRemoval(t):this.shiftLeftForRemoval(t),this.count--,n}shift(){return this.dequeue()}pop(){return this.dequeueBack()}fifoAdd(t){this.enqueue(t)}fifoRemove(){return this.dequeue()}filoAdd(t){this.enqueue(t)}filoRemove(){return this.dequeueBack()}lifoAdd(t){this.enqueueFront(t)}lifoRemove(){return this.dequeue()}liloAdd(t){this.enqueueFront(t)}liloRemove(){return this.dequeueBack()}get(t){if(t<0||t>=this.count)return;const e=(this.head+t)%this.capacity;return this.buffer[e]}set(t,e){if(t<0||t>=this.count)return!1;const n=(this.head+t)%this.capacity;return this.buffer[n]=e,!0}peek(){return this.count>0?this.buffer[this.head]:void 0}peekBack(){if(this.count===0)return;const t=(this.tail-1+this.capacity)%this.capacity;return this.buffer[t]}front(){return this.peek()}back(){return this.peekBack()}size(){return this.count}getCapacity(){return this.capacity}isEmpty(){return this.count===0}isFull(){return this.count===this.capacity}clear(){this.head=0,this.tail=0,this.count=0}toArray(){const t=[];for(let e=0;e<this.count;e++){const n=(this.head+e)%this.capacity;t.push(this.buffer[n])}return t}*[Symbol.iterator](){for(let t=0;t<this.count;t++){const e=(this.head+t)%this.capacity;yield this.buffer[e]}}*forward(){for(let t=0;t<this.count;t++){const e=(this.head+t)%this.capacity;yield this.buffer[e]}}*reverse(){for(let t=this.count-1;t>=0;t--){const e=(this.head+t)%this.capacity;yield this.buffer[e]}}*entries(){for(let t=0;t<this.count;t++){const e=(this.head+t)%this.capacity;yield[t,this.buffer[e]]}}*keys(){for(let t=0;t<this.count;t++)yield t}*values(){for(let t=0;t<this.count;t++){const e=(this.head+t)%this.capacity;yield this.buffer[e]}}toString(){return`Queue(${this.toArray().join(", ")})`}resize(){const t=this.capacity*2,e=new Array(t);for(let n=0;n<this.count;n++){const i=(this.head+n)%this.capacity;e[n]=this.buffer[i]}this.buffer=e,this.capacity=t,this.head=0,this.tail=this.count}shiftLeft(t,e){this.head=(this.head-1+this.capacity)%this.capacity;for(let i=0;i<t;i++){const s=(this.head+1+i)%this.capacity,r=(this.head+i)%this.capacity;this.buffer[r]=this.buffer[s]}const n=(this.head+t)%this.capacity;this.buffer[n]=e}shiftRight(t,e){for(let i=this.count-1;i>=t;i--){const s=(this.head+i)%this.capacity,r=(this.head+i+1)%this.capacity;this.buffer[r]=this.buffer[s]}const n=(this.head+t)%this.capacity;this.buffer[n]=e,this.tail=(this.tail+1)%this.capacity}shiftRightForRemoval(t){for(let e=t;e>0;e--){const n=(this.head+e-1)%this.capacity,i=(this.head+e)%this.capacity;this.buffer[i]=this.buffer[n]}this.head=(this.head+1)%this.capacity}shiftLeftForRemoval(t){for(let e=t;e<this.count-1;e++){const n=(this.head+e+1)%this.capacity,i=(this.head+e)%this.capacity;this.buffer[i]=this.buffer[n]}this.tail=(this.tail-1+this.capacity)%this.capacity}shiftLeftArray(t,e){const n=e.length;this.head=(this.head-n+this.capacity)%this.capacity;for(let i=0;i<t;i++){const s=(this.head+n+i)%this.capacity,r=(this.head+i)%this.capacity;this.buffer[r]=this.buffer[s]}for(let i=0;i<n;i++){const s=(this.head+t+i)%this.capacity;this.buffer[s]=e[i]}}shiftRightArray(t,e){const n=e.length;for(let i=this.count-1;i>=t;i--){const s=(this.head+i)%this.capacity,r=(this.head+i+n)%this.capacity;this.buffer[r]=this.buffer[s]}for(let i=0;i<n;i++){const s=(this.head+t+i)%this.capacity;this.buffer[s]=e[i]}this.tail=(this.tail+n)%this.capacity}}function T(o,t=(e,n)=>e===n){let e=o;const n=new Set;let i=[];const s=()=>e,r=(l,m=!1)=>{if(m){e=l;return}t(e,l)||(e=l,n.forEach(p=>p(e)),i.forEach(p=>p(e)),i=[])},h=()=>{n.forEach(l=>l(e)),i.forEach(l=>l(e)),i=[]},u=l=>(n.add(l),()=>n.delete(l)),f=()=>new Promise(l=>{i.push(l)});return{get:s,set:r,onChange:u,nextChange:f,triggerChange:h,onChangePromise:l=>{let m=!0;return(async()=>{for(;m;){const y=await f();if(!m)break;l(y)}})(),()=>{m=!1}}}}function v(o,t){if(o.size!==t.size)return!1;for(const[e,n]of o.entries()){const i=t.get(e);if(!i||!A(n,i))return!1}return!0}function A(o,t){if(o.typNode!==t.typNode||o.nodName!==t.nodName||o.uidNode!==t.uidNode||o.nodPart!==t.nodPart||o.nodFold!==t.nodFold||o.nodMaxd!==t.nodMaxd||o.nodHidden!==t.nodHidden||o.nodLocked!==t.nodLocked)return!1;const e=o.nodDims,n=t.nodDims;return e.x===n.x&&e.y===n.y&&e.w===n.w&&e.h===n.h}const S=()=>crypto.randomUUID(),R={set:(o,t)=>setTimeout(o,t),clear:o=>clearTimeout(o)},c={createId:S,timer:R,root:void 0,tree:null,minW:40,minH:40,bond:10,inst:null,maximized:null,collapsedSize:40,foldSeq:0};class a{static cache={dimMins:new Map,mapDirs:new Map,tabCnts:new Map,mapElem:new Map,tabOpts:T(new Map,v),nodOpts:T(new Map,v),bndOpts:T(new Map,v)};kids=new g;dims={w:0,h:0,x:0,y:0};unId;next=null;prev=null;type="row";name="";part=0;host=null;open="";collapsed=!1;foldedAt=0;constructor(t={}){const e={type:"row",host:null,name:"",part:100,dims:{w:0,h:0,x:0,y:0},unId:c.createId(),open:""};this.type=t.type??e.type,this.host=t.host??e.host,this.name=t.name??e.name,this.part=t.part??e.part,this.dims=t.dims??e.dims,this.open=t.open??e.open,this.unId=t.unId||e.unId}addBond(t,e=null){if(!e)return;const n=new D(t,this,e);a.cache.mapElem.set(n.unId,n)}getReqDimension(){const t=a.cache.dimMins.get(this.unId),e=a.cache.tabCnts.get(this.unId),n=Math.max(t.minWidth,e.horizontal*c.minW+Math.max(0,e.horizontal-1)*c.bond),i=Math.max(t.minHeight,e.vertical*c.minH+Math.max(0,e.vertical-1)*c.bond);return{width:n,height:i}}calcDimensions(){const t=a.cache.mapDirs.get(this.unId);if(!this.kids)return;let e=0;const n=a.cache.dimMins.get(this.unId)||{minWidth:0,minHeight:0};let i=0,s;for(const d of this.kids)d.collapsed||(e+=d.part,s=d);if(e===0)return;let r;t?r=this.dims.w-n.minWidth:r=this.dims.h-n.minHeight;const h=r<0;let u=0,f=0;for(const d of this.kids){const l=a.cache.dimMins.get(d.unId)||{minWidth:0,minHeight:0};let m=0;if(!h&&!d.collapsed){u+=d.part;const p=d===s?r:Math.round(r*u/e);m=p-f,f=p}t?(d.dims.w=l.minWidth+m,d.dims.h=this.dims.h,d.dims.x=this.dims.x+i,d.dims.y=this.dims.y,i+=d.dims.w+c.bond):(d.dims.h=l.minHeight+m,d.dims.w=this.dims.w,d.dims.y=this.dims.y+i,d.dims.x=this.dims.x,i+=d.dims.h+c.bond),d.next&&(t?d.next.dims={w:c.bond,h:d.dims.h,x:d.dims.x+d.dims.w,y:d.dims.y}:d.next.dims={w:d.dims.w,h:c.bond,x:d.dims.x,y:d.dims.y+d.dims.h})}}toJSON(){const t=[];for(const n of this.kids)t.push(n.toJSON());const e={typNode:this.type,nodPart:this.part,nodName:this.name,uidNode:this.unId};return this.open&&(e.nodOpen=this.open),this.collapsed&&(e.nodFold=!0),this===c.root&&c.maximized&&(e.nodMaxd=c.maximized),t.length>0&&(e.nodKids=t),e}}class D{dims={w:0,h:0,x:0,y:0};unId=c.createId();next=null;prev=null;host=null;constructor(t=null,e=null,n=null){this.host=t,this.next=e,this.prev=n,this.next&&(this.next.prev=this),this.prev&&(this.prev.next=this)}toJSON(){return{nodName:this.host?.name||"",typNode:"bond",uidNode:this.unId,nodPart:0,nodOpen:"",nodKids:[]}}}function*P(o){const t=new g;for(t.enqueue(o);!t.isEmpty();){const e=t.dequeue();if(e&&(yield e,e.nodKids&&e.nodKids.length>0))for(const n of e.nodKids)t.enqueue(n)}}function*K(o){const t=new g;for(t.enqueue(o);!t.isEmpty();){const e=t.dequeue();if(e&&(a.cache.mapElem.set(e.unId,e),yield e,e.kids.size()>0))for(const n of e.kids)t.enqueue(n)}}function*U(o,t){for(const e of t.kids)yield*o.NodeLayoutRecursiveIterator(e);yield t}function $(o,t){const e=a.cache.mapDirs.get(t.unId);if(e===void 0){console.warn(`Cannot update child directions for node ${t.unId}; its own direction is not set.`);return}for(const n of t.kids)a.cache.mapDirs.set(n.unId,!e),n.kids.size()>0&&(n.host=t,o.updateChildDirections(n),n.next&&a.cache.mapDirs.set(n.next.unId,!e))}function _(o,t=c.tree){if(!t)return;const e=o.JSONLayoutIterator(t),n=o.NodeLayoutIterator(c.root);for(a.cache.mapDirs.set(c.root.unId,!0);;){const i=e.next(),s=n.next();if(i.done||s.done)break;const r=i.value,h=s.value;!r||!h||o.createNodeTreeFromJSONTree(r,h)}o.calcTabsetCountAndMinDim()}function Y(o,t,e){const n=a.cache.mapDirs.get(e.unId);for(const i of t.nodKids||[]){const s=o.createNodeFromJSON(i),r=e.kids.peekBack();s.host=e,s.addBond(s.host,r),e.kids.enqueue(s),a.cache.mapDirs.set(s.unId,!n)}e.type==="tabset"&&a.cache.mapElem.set(e.unId,e),e.type==="tab"&&a.cache.mapElem.set(e.unId,e)}function G(o,t,e=c.root){const n=new g;for(n.enqueue(e),a.cache.mapDirs.set(c.root.unId,!0);!t.isEmpty();){const i=n.dequeue();if(!i)break;const s=a.cache.mapDirs.get(i.unId);if(t.size()===1){const d=t.dequeue(),l=new a({type:"tabset",host:i}),m=new a({type:"tab",host:l,name:d,unId:o.tabsIds.get(d??"")??c.createId()});l.open=m.name,l.kids.enqueue(m),i.kids.enqueue(l),a.cache.mapDirs.set(l.unId,!s),a.cache.mapDirs.set(m.unId,s),a.cache.mapElem.set(l.unId,l),a.cache.mapElem.set(m.unId,m);break}if(t.size()==2){const d=t.dequeue(),l=t.dequeue(),m=new a({type:"tabset",host:i}),p=new a({type:"tabset",host:i}),y=new a({type:"tab",host:m,name:d,unId:o.tabsIds.get(d??"")??c.createId()}),w=new a({type:"tab",host:p,name:l,unId:o.tabsIds.get(l??"")??c.createId()});m.open=y.name,p.open=w.name,m.kids.enqueue(y),p.kids.enqueue(w),i.kids.enqueue(m),i.kids.enqueue(p),p.addBond(i,m),a.cache.mapDirs.set(m.unId,!s),a.cache.mapDirs.set(p.unId,!s),a.cache.mapElem.set(m.unId,m),a.cache.mapElem.set(p.unId,p),a.cache.mapDirs.set(y.unId,s),a.cache.mapDirs.set(w.unId,s),a.cache.mapElem.set(y.unId,y),a.cache.mapElem.set(w.unId,w);break}const r=t.dequeue(),h=new a({type:"tabset",host:i}),u=new a({type:"row",host:i}),f=new a({type:"tab",host:h,name:r,unId:o.tabsIds.get(r??"")??c.createId()});h.open=f.name,h.kids.enqueue(f),i.kids.enqueue(h),i.kids.enqueue(u),u.addBond(i,h),a.cache.mapDirs.set(h.unId,!s),a.cache.mapDirs.set(u.unId,!s),a.cache.mapElem.set(h.unId,h),a.cache.mapDirs.set(f.unId,s),a.cache.mapElem.set(f.unId,f),n.enqueue(u)}o.calcTabsetCountAndMinDim()}function J(o,t){const e=new a({type:t.typNode,name:t.nodName,unId:t.uidNode,part:t.nodPart,dims:{w:0,h:0,x:0,y:0},open:typeof t.nodOpen=="string"?t.nodOpen:""});return e.collapsed=t.typNode==="tabset"&&t.nodFold===!0,t.typNode==="tab"&&(e.unId=o.tabsIds.get(t.nodName)||t.uidNode),e}function E(o){const t=a.cache.mapElem.get(o);return t instanceof a&&t.type==="tabset"?t:null}function Q(o=c.root){let t=0;const e=n=>{n.type==="tabset"&&t++;for(const i of n.kids)e(i)};return e(o),t}function O(o){return o.type==="tabset"&&!!o.host&&o.host.kids.size()>1}function H(){return Q()>1}function M(){const o=c.maximized;return o?E(o):null}function z(o,t){let e=null;for(const n of o.kids)n===t||!n.collapsed||(!e||n.foldedAt>e.foldedAt)&&(e=n);e&&(e.collapsed=!1)}function j(o=c.root){let t=!1;const e=n=>{n.type==="tabset"&&(n.unId===c.maximized&&(t=!0),n.collapsed&&!O(n)&&(n.collapsed=!1)),n.type!=="tab"&&n.kids.size()>0&&[...n.kids].every(s=>s.collapsed)&&z(n);for(const i of n.kids)e(i)};e(o),t||(c.maximized=null)}function q(o,t){return!E(t)||!H()||c.maximized===t?!1:(c.maximized=t,o.calcDimensions(),!0)}function F(o){return c.maximized?(c.maximized=null,o.calcDimensions(),!0):!1}function V(o,t){return c.maximized===t?F(o):q(o,t)}function B(o,t){const e=E(t);if(!e||e.collapsed||!O(e))return!1;c.maximized=null,e.collapsed=!0,e.foldedAt=++c.foldSeq;const n=e.host;return[...n.kids].every(i=>i.collapsed)&&z(n,e),o.calcTabsetCountAndMinDim(),o.calcDimensions(),!0}function C(o,t){const e=E(t);return!e||!e.collapsed?!1:(e.collapsed=!1,o.calcTabsetCountAndMinDim(),o.calcDimensions(),!0)}function X(o,t){const e=E(t);return e?e.collapsed?C(o,t):B(o,t):!1}function Z(o,t=c.root,e=!0){t===c.root&&e&&(j(t),a.cache.tabCnts.clear(),a.cache.dimMins.clear(),a.cache.mapElem.clear(),a.cache.nodOpts.get().clear(),a.cache.bndOpts.get().clear());for(const n of o.NodeLayoutRecursiveIterator(t)){const i=a.cache.tabCnts,s=a.cache.dimMins;a.cache.mapElem.set(n.unId,n);const r=i.set(n.unId,{horizontal:0,vertical:0}).get(n.unId),h=s.set(n.unId,{minWidth:0,minHeight:0}).get(n.unId),u=a.cache.mapDirs.get(n.unId);if(n.type==="tab"&&(a.cache.mapElem.set(n.unId,n),s.set(n.unId,{minWidth:0,minHeight:0})),n.next&&a.cache.mapElem.set(n.next.unId,n.next),n.type==="tabset"&&(a.cache.mapElem.set(n.unId,n),s.set(n.unId,{minWidth:c.minW,minHeight:c.minH}),u?i.set(n.unId,{horizontal:0,vertical:1}):i.set(n.unId,{horizontal:1,vertical:0}),n.collapsed&&n.host&&(a.cache.mapDirs.get(n.host.unId)?(s.set(n.unId,{minWidth:c.collapsedSize,minHeight:c.minH}),i.get(n.unId).horizontal=0):(s.set(n.unId,{minWidth:c.minW,minHeight:c.collapsedSize}),i.get(n.unId).vertical=0))),n.type==="row"){for(const f of n.kids){const d=i.get(f.unId),l=s.get(f.unId);d&&(r.horizontal+=d.horizontal,r.vertical+=d.vertical,u?(h.minHeight=Math.max(h.minHeight,l.minHeight),h.minWidth+=l.minWidth):(h.minHeight+=l.minHeight,h.minWidth=Math.max(h.minWidth,l.minWidth)))}u?h.minWidth+=(n.kids.size()-1)*c.bond:h.minHeight+=(n.kids.size()-1)*c.bond}}t===c.root&&e&&o.pruneStaleDirections()}function tt(){for(const o of a.cache.mapDirs.keys())a.cache.mapElem.has(o)||a.cache.mapDirs.delete(o)}function et(){const o=c.root.getReqDimension();let t=!1,e=c.root.dims.w,n=c.root.dims.h;return c.root.dims.w<o.width&&(e=o.width,t=!0),c.root.dims.h<o.height&&(n=o.height,t=!0),t&&(c.root.dims.w=e,c.root.dims.h=n),{adjustedW:e,adjustedH:n,wasAdjusted:t}}function nt(o,t=c.root,e=!1){const n=t===c.root,i=d=>n?new Map:new Map(d.get()),s=i(a.cache.nodOpts),r=i(a.cache.bndOpts),h=i(a.cache.tabOpts);n&&o.calculateRootAdjustment();const u=M(),f=H();for(const d of o.NodeLayoutIterator(t)){d.calcDimensions();const l=a.cache.mapDirs.get(d.unId);if(d.type==="tabset"){const m=d===u,p=!!u&&!m,y=m?{...c.root.dims}:{...d.dims},w={typNode:d.type,nodName:d.name,uidNode:d.unId,nodPart:d.part,nodOpen:d.open,nodeDir:l,nodFold:d.collapsed&&!m,nodMaxd:m,nodHidden:p,nodFoldable:O(d),nodMaximizable:f,nodKids:Array.from(d.kids).map(k=>{const N={typNode:k.type,nodName:k.name,uidNode:k.unId,nodPart:k.part,nodOpen:d.open===k.name,nodeDir:!l,nodHidden:p,nodFold:d.collapsed&&!m,nodDims:{...y}};return h.set(k.unId,N),N}),nodDims:y};s.set(d.unId,w)}if(d.next&&d.type!=="tab"){const m={typNode:"bond",nodName:d.name,uidNode:d.next.unId,nodeDir:l,nodPart:0,nodHidden:!!u,nodLocked:d.collapsed||!!d.next.next?.collapsed,nodDims:{...d.next.dims}};r.set(d.next.unId,m)}}a.cache.nodOpts.set(s,e),a.cache.bndOpts.set(r,e),a.cache.tabOpts.set(h,e)}function it(o,t,e=!1,n=2){if(c.root.dims=t,e){o.calcDimensions(c.root);return}o.cntdown&&(c.timer.clear(o.cntdown),o.cntdown=null),o.cntdown=c.timer.set(()=>{o.cntdown=null,o.calcDimensions()},n)}function ot(o,t,e,n=!1,i=2){if(n){o.updateSliderDimension(t,e);return}o.cntdown&&(c.timer.clear(o.cntdown),o.cntdown=null),o.cntdown=c.timer.set(()=>{o.cntdown=null,o.updateSliderDimension(t,e)},i)}function st(o,t,e){const n=a.cache.mapElem.get(t);if(!n||!(n instanceof D)){console.warn(`Bond with id ${t} not found or is not a Bond instance`);return}const i=a.cache.mapDirs.get(n.host.unId),s=n.prev,r=n.next,h=n.host;if(!s||!r||!h){console.warn("Missing prev, next, or host node",s,r,h);return}if(s.collapsed||r.collapsed||c.maximized)return;const u=a.cache.dimMins.get(s.unId)||{minWidth:0,minHeight:0},f=a.cache.dimMins.get(r.unId)||{minWidth:0,minHeight:0},d=c.bond/2;if(i){const l=r.dims.x+r.dims.w,m=s.dims.x+u.minWidth+d,p=l-f.minWidth-d,y=Math.max(m,Math.min(p,e.x));n.dims.x=y-d,s.dims.w=n.dims.x-s.dims.x,r.dims.x=y+d,r.dims.w=l-r.dims.x;const w=Math.max(0,s.dims.w-u.minWidth),k=Math.max(0,r.dims.w-f.minWidth),N=w+k,x=s.part+r.part;N>0?(s.part=w/N*x,r.part=k/N*x):(s.part=x/2,r.part=x/2)}else{const l=r.dims.y+r.dims.h,m=s.dims.y+u.minHeight+d,p=l-f.minHeight-d,y=Math.max(m,Math.min(p,e.y));n.dims.y=y-d,s.dims.h=n.dims.y-s.dims.y,r.dims.y=y+d,r.dims.h=l-r.dims.y;const w=Math.max(0,s.dims.h-u.minHeight),k=Math.max(0,r.dims.h-f.minHeight),N=w+k,x=s.part+r.part;N>0?(s.part=w/N*x,r.part=k/N*x):(s.part=x/2,r.part=x/2)}o.calcDimensions(h)}function at(o,t,e,n){const i=a.cache.mapElem.get(t);let s=a.cache.mapElem.get(e);return!i||!(i instanceof a)||!s||!(s instanceof a)?(console.warn(`Source node ${t} not found or is not a Node instance`),!1):i?.type=="tab"&&i.host===s&&s.kids.size()<2?(console.warn("Cannot move to self as it has only one tab"),!1):i?.type=="tabset"&&s?.host===i?(console.warn("Cannot move tabset to self as it is already a child"),!1):!i||!s?(console.warn(`Source or destination node not found: ${t}, ${e}`),!1):i===s?(console.warn("Source and destination nodes are the same, no action taken."),!1):!i.host||!s.host&&s.type!=="row"?(console.warn(`Source node or destination node's host is null: ${i.unId}, ${s.unId}`),!1):s.type==="row"&&s!==c.root?(console.warn(`Cannot move relative to a nested row: ${s.unId}`),!1):s.type==="row"&&n==="contain"?(console.warn(`Cannot move to a row with 'contain' layout: ${s.unId}`),!1):i.type==="row"||(s.type==="tabset"&&n==="contain"&&(s=s.kids.peekBack()||s),i===s)?!1:o.isOnlyContent(i)?(console.warn("Cannot move the only tabset or tab in the layout"),!1):(c.maximized=null,i.collapsed=!1,s.type==="tab"&&(n==="contain"||n==="left"||n==="right")?o.moveNodeAsTab(i,s,n):s.type==="row"&&n!=="contain"?o.moveRelativeToRoot(i,s,n):s.type==="tabset"&&n!=="contain"&&o.moveRelativeToTabset(i,s,n),o.calcTabsetCountAndMinDim(),o.calcDimensions(c.root,!0),!0)}function rt(o,t){let e=0;for(const n of o.NodeLayoutRecursiveIterator(c.root))n.type==="tabset"&&e++;return e!==1?!1:t.type==="tabset"||t.type==="tab"&&t.host?.kids.size()===1}function dt(o,t,e,n){if(!e||!e.host){console.warn(`Destination node ${e.unId} has no host, cannot move.`);return}o.removeNode(t);const i=e.host,s=i.kids.indexOf(e);if(s===void 0||s===-1)return;const r=n==="contain"||n==="left",h=r?s:s+1,u=i.kids.get(h+1),f=i.kids.get(h-1),d=e.next,l=e.prev;if(!r&&d?a.cache.mapElem.delete(d.unId):r&&l&&a.cache.mapElem.delete(l.unId),t.type=="tab")r?(f&&t.addBond(i,f),e.addBond(i,t)):(t.addBond(i,e),u&&u.addBond(i,t)),i.kids.insert(h,t),t.host=i,i.open=t.name,i.collapsed=!1;else if(t.type=="tabset"){const m=t.kids.peek(),p=t.kids.peekBack();r?(m&&f&&m.addBond(i,f),p&&e&&e.addBond(i,p)):(m&&e&&m.addBond(i,e),p&&u&&u.addBond(i,p)),i.kids.insertQueue(h,t.kids);for(const y of t.kids)y.host=i,y.next&&(y.next.host=i);i.open=p?p.name:"",i.collapsed=!1}o.updateChildDirections(i)}const ct={root:(o,t)=>o===t,tabset:(o,t)=>o!==t};function W(o,t,e,n,i){if(o.removeNode(t),t.type!=="tab"&&t.type!=="tabset")return;const s=a.cache.mapDirs.get(e.unId)===!1,r=n==="left"||n==="right",h=n==="top"||n==="left";let u=t;t.type==="tab"&&(u=new a({type:"tabset",host:e.host}),u.kids.enqueue(t),u.open=t.name,t.host=u),ct[i](s,r)?o.insertNodeWithNewParent(u,e,h):o.insertNode(e,u,h)}function ht(o,t,e,n){W(o,t,e,n,"root")}function ut(o,t,e,n){W(o,t,e,n,"tabset")}function lt(o,t,e,n){const i=t.host;if(t==c.root){const l=c.root.kids.peek(),m=c.root.kids.peekBack();n?(c.root.kids.enqueueFront(e),l&&l.addBond(c.root,e)):(c.root.kids.enqueue(e),m&&e.addBond(c.root,m)),e.host=c.root,o.updateChildDirections(c.root);return}if(!i){console.warn(`Destination node ${t.unId} has no host, cannot insert.`);return}const s=i.kids.indexOf(t);if(s===-1){console.warn(`Destination node ${t.unId} not found in its host's kids.`);return}const r=a.cache.mapDirs.get(i.unId);r&&a.cache.mapDirs.set(e.unId,!r);const h=i.kids.get(s+1),u=i.kids.get(s-1),f=t.next,d=t.prev;e.host=i,n?(i.kids.insert(s,e),t.addBond(i,e),u&&e.addBond(i,u),d&&a.cache.mapElem.delete(d.unId)):(i.kids.insert(s+1,e),e.addBond(i,t),h&&h.addBond(i,e),f&&a.cache.mapElem.delete(f.unId)),o.updateChildDirections(i)}function ft(o,t,e,n){const i=new g,s=new a({type:"tabset",host:e.host});if(!e||!t){console.warn(`Destination node ${e.unId} has no host, cannot insert.`);return}if(e===c.root){const h=new a({type:"row",host:e});if(e.kids.size()===0)e.kids.enqueue(t),t.host=e;else if(e.kids.size()==1&&e.kids.peek()?.type==="tabset"){const u=e.kids.dequeue();if(!u){console.warn(`No kid found in destination node ${e.unId}, cannot insert.`);return}n?(h.kids.enqueue(t),h.kids.enqueue(u),e.kids.enqueue(h),u.addBond(h,t)):(h.kids.enqueue(u),h.kids.enqueue(t),t.addBond(h,u),e.kids.enqueue(h)),t.host=h,u.host=h}else if(e.kids.size()==1&&e.kids.peek()?.type==="row"){const u=e.kids.peek(),f=u?.kids.peek(),d=u?.kids.peekBack();n&&u?(u.kids.enqueueFront(t),f&&f.addBond(u,t)):u&&(u.kids.enqueue(t),d&&t.addBond(u,d)),t.host=u}else if(e.kids.size()>1){const u=new a({type:"row",host:e}),f=new a({type:"row",host:u});for(const d of e.kids)f.kids.enqueue(d),d.host=f,d.next&&(d.next.host=f);t.host=u,e.kids.clear(),n?(u.kids.enqueueFront(t),u.kids.enqueue(f),f.addBond(u,t)):(u.kids.enqueue(f),u.kids.enqueue(t),t.addBond(u,f)),e.kids.enqueue(u)}o.updateChildDirections(e);return}t.host=e,s.host=e,s.kids=e.kids,s.open=e.open;const r=a.cache.mapDirs.get(e.unId);for(const h of s.kids)h.host=s,h.next&&(h.next.host=s),a.cache.mapDirs.set(h.unId,r);for(const h of t.kids)h.host=t,h.next&&(h.next.host=t),a.cache.mapDirs.set(h.unId,r);a.cache.mapDirs.set(s.unId,!r),a.cache.mapDirs.set(t.unId,!r),n?(i.enqueue(t),i.enqueue(s),e.kids=i,e.type="row",s.addBond(e,t)):(i.enqueue(s),i.enqueue(t),e.kids=i,e.type="row",t.addBond(e,s))}function mt(o,t){if(!t.host||!t.host.host){console.warn(`Source node ${t.unId} has no host, cannot move.`);return}const e=t.host,n=t.host.host,i=n.kids.indexOf(e),s=n.kids.get(i-1),r=n.kids.get(i+1),h=t.kids.peek(),u=t.kids.peekBack();o.removeKid(e);let f=i;if(t.type=="row"&&e){s&&h&&h.addBond(n,s),r&&u&&r.addBond(n,u);for(const d of t.kids)d.host=n,d.next&&(d.next.host=n),n.kids.insert(f,d),a.cache.mapDirs.set(d.unId,!a.cache.mapDirs.get(n.unId)),a.cache.dimMins.delete(d.unId),f++}else if(t.type=="tabset"){s&&t.addBond(n,s),r&&r.addBond(n,t),n.kids.insert(f,t),t.host=n,a.cache.mapDirs.set(t.unId,!a.cache.mapDirs.get(n.unId));for(const d of t.kids)a.cache.mapDirs.set(d.unId,a.cache.mapDirs.get(n.unId)),a.cache.dimMins.delete(d.unId)}}function pt(o,t=!0){const e=o.host,n=o.prev,i=o.next;if(o.host=null,o.next=null,o.prev=null,n&&(n.next=null),i&&(i.prev=null),!t)return o;n&&i&&n.prev&&i.next?n.prev.addBond(e,i.next):n&&n.prev?n.prev.next=null:i&&i.next&&(i.next.prev=null)}function It(o,t){if(!t.host){console.warn("Kid node has no host, cannot remove.");return}const e=t?.host,n=e?.host;if(o.removeKid(t),t.type==="tabset"&&e.kids.size()===1){const i=e.kids.peek();i&&o.moveAdjacentNodeToGrandParent(i)}else if(t.type==="tab"&&e.kids.size()===0&&n.kids.size()===2){o.removeKid(e);const i=n?.kids.peek();i&&o.moveAdjacentNodeToGrandParent(i)}else if(t.type==="tab"&&e.kids.size()===0&&n.kids.size()>2)o.removeKid(e);else if(t.type==="tab"&&e.open===t.name&&e.kids.size()>0){const i=e.kids.peek();i&&(e.open=i.name)}}function yt(o){if(!o.host){console.warn("Kid node has no host, cannot remove.");return}const t=o.host,e=t.kids.indexOf(o),n=t.kids.get(e+1),i=t.kids.get(e-1),s=o.next,r=o.prev;if(e===-1){console.warn("Kid node not found in its host's kids.");return}s&&a.cache.mapElem.delete(s.unId),r&&a.cache.mapElem.delete(r.unId),n&&i?n.addBond(t,i):n?n.prev=null:i&&(i.next=null),t.kids.removeAt(e),a.cache.mapElem.delete(o.unId),a.cache.dimMins.delete(o.unId),a.cache.mapDirs.delete(o.unId),a.cache.tabCnts.delete(o.unId),o.type==="tabset"&&a.cache.mapElem.delete(o.unId),o.type==="tab"&&a.cache.mapElem.delete(o.unId),o.host=null,o.next=null,o.prev=null}function wt(){a.cache.dimMins.clear(),a.cache.mapDirs.clear(),a.cache.tabCnts.clear(),a.cache.mapElem.clear(),a.cache.nodOpts.get().clear(),a.cache.bndOpts.get().clear()}class b{static get _root(){return c.root}static set _root(t){c.root=t}static get _tree(){return c.tree}static set _tree(t){c.tree=t}static get _minW(){return c.minW}static set _minW(t){c.minW=t}static get _minH(){return c.minH}static set _minH(t){c.minH=t}static get _bond(){return c.bond}static set _bond(t){c.bond=t}static get _inst(){return c.inst}static set _inst(t){c.inst=t}nodeOps;cntdown=null;tabsIds=new Map;constructor(t={}){const e={tabs:[],tree:null,minW:40,minH:40,bond:10,uqid:"dynamix-layout-root",tabsIds:new Map,...t};this.tabsIds=e.tabsIds,c.createId=e.createId??S,c.timer=e.timer??R,c.collapsedSize=e.collapsedSize??e.minH,b._tree=e.tree??null,c.maximized=e.tree?.nodMaxd??null,b._root=new a({unId:e.uqid,name:e.uqid,type:"row"}),this.nodeOps=T(new Map,v),b._minW=e.minW,b._minH=e.minH,b._bond=e.bond;const n=new g(e.tabs.length,e.tabs);b._tree?this.createNodeLayout():this.createBinaryNodeTreeFromQueue(n),b._inst=this}*JSONLayoutIterator(t){yield*P(t)}*NodeLayoutIterator(t){yield*K(t)}*NodeLayoutRecursiveIterator(t){yield*U(this,t)}updateChildDirections(t){return $(this,t)}createNodeLayout(t=b._tree){return _(this,t)}createNodeTreeFromJSONTree(t,e){return Y(this,t,e)}createBinaryNodeTreeFromQueue(t,e=b._root){return G(this,t,e)}createNodeFromJSON(t){return J(this,t)}calcTabsetCountAndMinDim(t=b._root,e=!0){return Z(this,t,e)}pruneStaleDirections(){return tt()}calculateRootAdjustment(){return et()}calcDimensions(t=b._root,e=!1){return nt(this,t,e)}updateDimension(t,e=!1,n=2){return it(this,t,e,n)}updateSlider(t,e,n=!1,i=2){return ot(this,t,e,n,i)}updateSliderDimension(t,e){return st(this,t,e)}updateTree(t,e,n){return at(this,t,e,n)}isOnlyContent(t){return rt(this,t)}moveNodeAsTab(t,e,n){return dt(this,t,e,n)}moveRelativeToRoot(t,e,n){return ht(this,t,e,n)}moveRelativeToTabset(t,e,n){return ut(this,t,e,n)}insertNode(t,e,n){return lt(this,t,e,n)}insertNodeWithNewParent(t,e,n){return ft(this,t,e,n)}moveAdjacentNodeToGrandParent(t){return mt(this,t)}removeRelation(t,e=!0){return pt(t,e)}removeNode(t){return It(this,t)}removeKid(t){return yt(t)}clearAllCache(){return wt()}get maximizedId(){return M()?.unId??null}maximize(t){return q(this,t)}restore(){return F(this)}toggleMaximize(t){return V(this,t)}collapse(t){return B(this,t)}expand(t){return C(this,t)}toggleCollapse(t){return X(this,t)}}const bt=6;function kt(o,t,e){const{left:n,top:i,width:s,height:r}=o,h=t-n,u=e-i;return h<s/3?{area:"left",left:n,top:i,width:s/2,height:r}:h>2*s/3?{area:"right",left:n+s/2,top:i,width:s/2,height:r}:u<r/3?{area:"top",left:n,top:i,width:s,height:r/2}:u>2*r/3?{area:"bottom",left:n,top:i+r/2,width:s,height:r/2}:{area:"contain",left:n+s*.1,top:i+r*.1,width:s*.8,height:r*.8}}function gt(o,t){const{x:e,y:n,w:i,h:s}=o;switch(t){case"left":return{area:t,left:e,top:n,width:i/2,height:s};case"right":return{area:t,left:e+i/2,top:n,width:i/2,height:s};case"top":return{area:t,left:e,top:n,width:i,height:s/2};case"bottom":return{area:t,left:e,top:n+s/2,width:i,height:s/2}}}function Nt(o,t,e,n){if(t.length===0||n<o.top||n>o.bottom)return null;const i=t[0],s=t[t.length-1];let r=bt;if(e>s.right)return{index:t.length-1,area:"right",left:s.right+1,top:s.top,width:r-2,height:s.height};if(e<i.left)return{index:0,area:"left",left:i.left-r+1,top:i.top,width:r-2,height:i.height};let h=0,u=1/0,f=!1;t.forEach((m,p)=>{const y=m.left+m.width/2,w=Math.abs(e-y);w<u&&(u=w,h=p,f=e<y)});const d=f?h>0:h<t.length-1;t.length>1&&d&&(r=t[1].left-i.right);const l=t[h];return{index:h,area:f?"left":"right",left:f?l.left-r+1:l.right+1,top:l.top,width:r-2,height:l.height}}function xt(o,t){return o.area===t.area&&o.left===t.left&&o.top===t.top&&o.width===t.width&&o.height===t.height}function L(o,{x:t,y:e,w:n,h:i}){o.style.left=`${t}px`,o.style.top=`${e}px`,o.style.width=`${n}px`,o.style.height=`${i}px`}function Tt(o,t){return{x:o.x,y:o.y+t,w:o.w,h:Math.max(0,o.h-t)}}function vt(o,t){const{x:e,y:n,w:i,h:s}=o.nodDims,r=o.nodeDir===!1;return o.nodFold&&r?{rect:{x:e+i,y:n,w:s,h:i},rotated:!0}:{rect:{x:e,y:n,w:i,h:t},rotated:!1}}function Et(o,t){L(o,t.rect),o.style.transformOrigin="0 0",o.style.transform=t.rotated?"rotate(90deg)":""}function Dt(o){let t=null,e=null;const n=()=>{e=null;const i=t;t=null,i&&o(i.value)};return{schedule(i){t={value:i},e===null&&(e=requestAnimationFrame(n))},flush(){e!==null&&(cancelAnimationFrame(e),n())},cancel(){e!==null&&cancelAnimationFrame(e),e=null,t=null}}}(()=>{if(typeof window>"u")return;const o="color: #03A9F4; font-weight: bold; line-height: 1.2;",t="color: #E0E0E0; font-size: 12px;",e="color: #42a5f5; font-size: 12px;",n="color: #9E9E9E; font-size: 10px;",i=`
|
|
2
|
-
██████╗ ██╗ ██╗ ███╗ ██╗ █████╗ ███╗ ███╗ ██████╗ ██╗ ██╗
|
|
3
|
-
██╔══██╗╚██╗ ██╔╝ ████╗ ██║ ██╔══██╗ ████╗ ████║ ╚═██╔═╝ ╚██╗██╔╝
|
|
4
|
-
██║ ██║ ╚████╔╝ ██╔██╗ ██║ ███████║ ██╔████╔██║ ██║ ╚███╔╝
|
|
5
|
-
██║ ██║ ╚██╔╝ ██║╚██╗██║ ██╔══██║ ██║╚██╔╝██║ ██║ ██╔██╗
|
|
6
|
-
██████╔╝ ██║ ██║ ╚████║ ██║ ██║ ██║ ╚═╝ ██║ ██████╗ ██╔╝ ██╗
|
|
7
|
-
╚═════╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝
|
|
8
|
-
██╗ █████╗ ██╗ ██╗ ██████╗ ██╗ ██╗████████╗
|
|
9
|
-
██║ ██╔══██╗ ╚██╗ ██╔╝ ██╔═══██╗ ██║ ██║╚══██╔══╝
|
|
10
|
-
██║ ███████║ ╚████╔╝ ██║ ██║ ██║ ██║ ██║
|
|
11
|
-
██║ ██╔══██║ ╚██╔╝ ██║ ██║ ██║ ██║ ██║
|
|
12
|
-
███████╗ ██║ ██║ ██║ ╚██████╔╝ ╚█████╔╝ ██║
|
|
13
|
-
╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚════╝ ╚═╝
|
|
14
|
-
`;console.groupCollapsed("%cDYNAMIX LAYOUT (click to expand)","color: #03A9F4; font-weight: bold; font-size: 14px;"),console.log(`%c${i}`,o),console.log("%c A powerful, dynamic layout system 🚀",t),console.log(`%c ⚡ For docs and more info,
|
|
15
|
-
⚡ visit: https://github.com/xcode-studio/dynamix-layout`,e),console.log(`%cMIT License
|
|
16
|
-
|
|
17
|
-
Copyright (c) 2025 Akash Aman <sir.akashaman@gmail.com> (https://akash.cx)
|
|
18
|
-
|
|
19
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
20
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
21
|
-
in the Software without restriction, including without limitation the rights
|
|
22
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
23
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
24
|
-
furnished to do so, subject to the following conditions:
|
|
25
|
-
|
|
26
|
-
The above copyright notice and this permission notice shall be included in all
|
|
27
|
-
copies or substantial portions of the Software.
|
|
28
|
-
|
|
29
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
30
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
31
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
32
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
33
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
34
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
35
|
-
SOFTWARE.
|
|
36
|
-
`,n),console.groupEnd(),typeof window<"u"&&(window.__DYNAMIX_LAYOUT__={__LICENSE__:`MIT License
|
|
37
|
-
|
|
38
|
-
Copyright (c) 2025 Akash Aman <sir.akashaman@gmail.com> (https://akash.cx)
|
|
39
|
-
|
|
40
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
41
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
42
|
-
in the Software without restriction, including without limitation the rights
|
|
43
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
44
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
45
|
-
furnished to do so, subject to the following conditions:
|
|
46
|
-
|
|
47
|
-
The above copyright notice and this permission notice shall be included in all
|
|
48
|
-
copies or substantial portions of the Software.
|
|
49
|
-
|
|
50
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
51
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
52
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
53
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
54
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
55
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
56
|
-
SOFTWARE.
|
|
57
|
-
`,__LAYOUT__:b})})(),I.Bond=D,I.DynamixLayoutCore=b,I.Node=a,I.Queue=g,I.areNodeOptionsEqual=A,I.areNodeOptionsMapEqual=v,I.createFrameScheduler=Dt,I.createReactiveState=T,I.getNavbarDropPreview=Nt,I.getRootSplitPreview=gt,I.getTabBodyRect=Tt,I.getTabbarPlacement=vt,I.getTabsetDropPreview=kt,I.isSameDropPreview=xt,I.placeTabbar=Et,I.setElementRect=L,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})}));
|