class p{config;constructor(t){this.config={defaultCenterX:500,defaultCenterY:400,groupPadding:40,minGroupWidth:300,minGroupHeight:200,sizeChangeThreshold:5,logicalViewAdditionalHeight:100,entityHeaderHeight:80,defaultEntityHeight:300,...t}}calculateCenter(t){const e=t.filter(n=>n.type==="entity");if(e.length===0)return{x:this.config.defaultCenterX,y:this.config.defaultCenterY};const i=e.map(n=>n.position.x),a=e.map(n=>n.position.y),s=(Math.min(...i)+Math.max(...i))/2,o=(Math.min(...a)+Math.max(...a))/2;return{x:s,y:o}}calculateFactPosition(t){const i=(Math.random()-.5)*2*200,a=(Math.random()-.5)*2*200;return{x:t.x+i,y:t.y+a}}calculateDimensionPosition(t){const a=500+Math.random()*300,s=Math.random()*2*Math.PI;return{x:t.x+Math.cos(s)*a,y:t.y+Math.sin(s)*a}}calculateUnclassifiedPosition(){return{x:100+Math.random()*200,y:100+Math.random()*200}}calculateSmartPosition(t,e){const i=this.calculateCenter(e);switch(t){case"fact":return this.calculateFactPosition(i);case"dimension":return this.calculateDimensionPosition(i);case"unclassified":return this.calculateUnclassifiedPosition();default:return this.calculateUnclassifiedPosition()}}}class H{config;constructor(t){this.config={defaultCenterX:500,defaultCenterY:400,groupPadding:40,minGroupWidth:300,minGroupHeight:200,sizeChangeThreshold:5,logicalViewAdditionalHeight:100,entityHeaderHeight:80,defaultEntityHeight:300,...t}}calculateChildHeight(t,e){const i=t.measured?.height;if(i!==void 0&&i>=50)return i;if(t.data?.collapsed===!1){const s=t.data?.panelHeight,o=t.data?.height;let n;return s&&s>0?n=s:o!==void 0?n=o:n=this.config.defaultEntityHeight,s&&s>0&&(n+=this.config.entityHeaderHeight),e==="logical"&&t.data?.dbt_model&&(n+=this.config.logicalViewAdditionalHeight),n}const a=i??0;return a>0?a:200}calculateChildWidth(t){const e=t.measured?.width;return e&&e>0?e:t.data?.width??320}calculateGroupSize(t,e,i){if(t.data?.manuallyResized)return null;const a=e.filter(r=>r.parentId===t.id&&!r.hidden);if(a.length===0)return null;let s=0,o=0;for(const r of a){const g=this.calculateChildWidth(r),m=this.calculateChildHeight(r,i),h=r.position.x+g,d=r.position.y+m;h>s&&(s=h),d>o&&(o=d)}const n=Math.max(s+this.config.groupPadding,this.config.minGroupWidth),c=Math.max(o+this.config.groupPadding,this.config.minGroupHeight),u=t.data.width??0,f=t.data.height??0;return Math.abs(n-u)>this.config.sizeChangeThreshold||Math.abs(c-f)>this.config.sizeChangeThreshold?{groupId:t.id,width:n,height:c}:null}calculateGroupSizes(t,e,i){if(i||t.some(o=>o.dragging))return{sizes:new Map,needsUpdate:!1};const a=t.filter(o=>o.type==="group"&&!o.data.collapsed);if(a.length===0)return{sizes:new Map,needsUpdate:!1};const s=new Map;for(const o of a){const n=this.calculateGroupSize(o,t,e);n&&s.set(n.groupId,n)}return{sizes:s,needsUpdate:s.size>0}}applyGroupSizes(t,e){return e.size===0?t:t.map(i=>{if(e.has(i.id)){const a=e.get(i.id);return{...i,data:{...i.data,width:a.width,height:a.height}}}return i})}}export{p as D,H as G};
