@skill-map/cli 0.11.1 → 0.13.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.
@@ -0,0 +1,210 @@
1
+ import{c as Pi,d as Mi,e as Ri,u as Ni,v as ki,w as yh}from"./chunk-SKGGJQY3.js";import{b as Ai}from"./chunk-J3FDTSKA.js";import{d as qt,e as Xt}from"./chunk-ZTVMUEY2.js";import{$ as nt,$a as Et,A as J,Aa as ze,B as Se,C as $t,Ca as lt,Cb as ph,D as V,Da as Be,E as se,F as vi,Fa as Xe,Ga as x,Ha as T,I as g,Ia as ot,J as ah,K as ch,Ka as uh,L as dh,M as il,N as Ci,O as ee,Oa as hh,P as lh,Pa as Ei,Q as le,Qa as ut,Ra as me,S as ne,T as wi,W as K,Z as O,_ as F,_a as fh,aa as he,ab as z,ad as _h,ba as fe,bb as rt,bd as mh,ca as N,cb as R,d as p,da as m,db as ge,ea as y,eb as Di,fa as j,fb as rl,fd as Oi,ga as Ye,gb as Dt,gd as Fi,ha as qe,ia as Yt,ib as Q,ja as bi,jb as Ee,ka as xi,l as f,m as rh,ma as Ii,n as X,na as Si,o as Wt,oa as St,p as d,q as sh,qa as ye,r as oe,ra as I,rb as gh,s as re,sa as En,sb as Ti,t as ke,ta as ve,u as Pe,v as yi,w as We,x as $e,y as Sn,ya as ol,za as it}from"./chunk-NUUSKOAE.js";import{a as W,b as nl}from"./chunk-Q7L6LLAK.js";var Tt=class{constructor(i,e,n,o,r){this.center=i,this.radiusX=e,this.radiusY=n,this.startAngle=o,this.endAngle=r}},E=class t{static castToPoint(i){return i||t.initialize()}static initialize(i=0,e=0){return{x:i,y:e}}static copy(i){return t.initialize(i.x,i.y)}static isEqual(i,e){return i.x===e.x&&i.y===e.y}static sum(i,e){return{x:i.x+e.x,y:i.y+e.y}}static sub(i,e){return{x:i.x-e.x,y:i.y-e.y}}static div(i,e){return{x:i.x/e,y:i.y/e}}static mult(i,e){return{x:i.x*e,y:i.y*e}}static interpolatePoints(i,e,n){let o=1-n;return t.initialize(i.x*o+e.x*n,i.y*o+e.y*n)}static roundTo(i,e){let n=Math.trunc(i.x/e),o=Math.trunc(i.y/e);return{x:n*e,y:o*e}}static hypotenuse(i,e){let n=e.x-i.x,o=e.y-i.y;return Math.abs(Math.sqrt(n*n+o*o))}static distance(i,e){let n=i.x-e.x,o=i.y-e.y;return Math.sqrt(n*n+o*o)}static getMinimum(i,e){return t.initialize(Math.min(i.x,e.x),Math.min(i.y,e.y))}static getMaximum(i,e){return t.initialize(Math.max(i.x,e.x),Math.max(i.y,e.y))}static matrixTransform(i,e){let n=t.initialize(i.x,i.y),o=e.getScreenCTM();if(o){let r=e.createSVGPoint();r.x=i.x,r.y=i.y,n=r.matrixTransform(o.inverse())}return n}static elementTransform(i,e){let n=t.initialize(i.x,i.y),o=e.getBoundingClientRect();return n=t.sub(n,t.initialize(o.left,o.top)),n}},B=class t{constructor(i=0,e=0){this.x=i,this.y=e}static fromPoint(i){return new t(i.x,i.y)}add(i){let e=E.sum(this,i);return t.fromPoint(e)}sub(i){let e=E.sub(this,i);return t.fromPoint(e)}subNumber(i){let e=E.sub(this,new t(i,i));return t.fromPoint(e)}div(i){let e=E.div(this,i);return t.fromPoint(e)}mult(i){let e=E.mult(this,i);return t.fromPoint(e)}matrixTransform(i){let e=E.matrixTransform(this,i);return t.fromPoint(e)}elementTransform(i){let e=E.elementTransform(this,i);return t.fromPoint(e)}},Dn=class{static initialize(i=E.initialize(),e=E.initialize()){return{point1:i,point2:e}}static copy(i){return{point1:i.point1,point2:i.point2}}static hypotenuse(i){return Math.sqrt(Math.pow(i.point1.x-i.point2.x,2)+Math.pow(i.point1.y-i.point2.y,2))}},Pt=class{constructor(i,e){this.point1=i,this.point2=e}},A=class t{static initialize(i=0,e=0,n=0,o=0){n<0&&(i=i+n,n=-n),o<0&&(e=e+o,o=-o);let r=E.initialize(i+n/2,e+o/2);return{x:i,y:e,width:n,height:o,gravityCenter:r}}static copy(i){return t.initialize(i.x,i.y,i.width,i.height)}static fromElement(i){let{x:e,y:n,width:o,height:r}=i.getBoundingClientRect();return t.initialize(e,n,o,r)}static isIncludePoint(i,e){return e.x>=t.left(i)&&e.x<=t.right(i)&&e.y>=t.top(i)&&e.y<=t.bottom(i)}static intersectionWithRect(i,e){return!(i.x+i.width<e.x||e.x+e.width<i.x||i.y+i.height<e.y||e.y+e.height<i.y)}static left(i){return i.x}static top(i){return i.y}static right(i){return i.x+i.width}static bottom(i){return i.y+i.height}static addPoint(i,e){let n=t.copy(i);return n.x+=e.x,n.y+=e.y,this.initialize(n.x,n.y,n.width,n.height)}static mult(i,e){let n=t.copy(i);return n.x*=e,n.y*=e,n.width*=e,n.height*=e,this.initialize(n.x,n.y,n.width,n.height)}static div(i,e){let n=t.copy(i);return n.x/=e,n.y/=e,n.width/=e,n.height/=e,this.initialize(n.x,n.y,n.width,n.height)}static addPointToSize(i,e){let n=t.copy(i);return n.width+=e.x,n.height+=e.y,this.initialize(n.x,n.y,n.width,n.height)}static union(i){return!i||i.length===0?null:i.reduce((e,n)=>{let o=Math.min(e.x,n.x),r=Math.min(e.y,n.y),s=Math.max(e.x+e.width,n.x+n.width),a=Math.max(e.y+e.height,n.y+n.height);return t.initialize(o,r,s-o,a-r)},i[0])}static elementTransform(i,e){let n=e.getBoundingClientRect(),o=E.sub(i,E.initialize(n.left,n.top));return t.initialize(o.x,o.y,i.width,i.height)}static updateIsNotFinite(i){return!Number.isFinite(i.width)||!Number.isFinite(i.height)||!Number.isFinite(i.x)||!Number.isFinite(i.y)?t.initialize(0,0,0,0):i}};function vh(t,i){let e=Math.max(t.width,i),n=Math.max(t.height,i),o=(e-t.width)/2,r=(n-t.height)/2;return A.initialize(t.x-o,t.y-r,e,n)}function al(t,i){t=A.updateIsNotFinite(t),i.setAttribute("x",t.x.toString()),i.setAttribute("y",t.y.toString()),i.setAttribute("width",t.width.toString()),i.setAttribute("height",t.height.toString())}function Ch(t,i){t=A.updateIsNotFinite(t),i.setAttribute("viewBox",`${t.x} ${t.y} ${t.width} ${t.height}`)}var ae=class t{constructor(i=0,e=0,n=0,o=0,r=0,s=0,a=0,c=0){this.x=i,this.y=e,this.width=n,this.height=o,this.radius1=r,this.radius2=s,this.radius3=a,this.radius4=c,this.gravityCenter=E.initialize(),this.gravityCenter=this.calculateGravityCenter(this)}calculateGravityCenter(i){return new B(i.x+i.width/2,i.y+i.height/2)}static fromRect(i){return new t(i.x,i.y,i.width,i.height)}static fromRoundedRect(i){return new t(i.x,i.y,i.width,i.height,i.radius1,i.radius2,i.radius3,i.radius4)}static fromCenter(i,e,n){return new t(i.gravityCenter.x-e/2,i.gravityCenter.y-n/2,e,n,i.radius1,i.radius2,i.radius3,i.radius4)}static fromPoint(i){return new t(i.x,i.y)}addPoint(i){let e=t.fromRoundedRect(this);return e.x+=i.x,e.y+=i.y,e.gravityCenter=this.calculateGravityCenter(e),e}},Ge=class t{static initialize(i=0,e=0){return{width:i,height:e}}static isEqual(i,e){return i.width===e.width&&i.height===e.height}static offsetFromElement(i){if(i instanceof SVGGraphicsElement){let e=i.getBBox();return t.initialize(e.width,e.height)}else if(i instanceof HTMLElement)return t.initialize(i.offsetWidth,i.offsetHeight)}};function Ug(){return{position:E.initialize(),scaledPosition:E.initialize(),scale:1,rotate:0}}function Wg(t){let i;if(t){t=t.replace("matrix(",""),t=t.replace(")","");let e=t.split(" ");i={position:{x:Number(e[4]),y:Number(e[5])},scaledPosition:E.initialize(),scale:Number(e[0]),rotate:0}}return i}var ht=class{static toString(i){let e=E.sum(i.position,i.scaledPosition);return`matrix(${i.scale}, 0, 0, ${i.scale}, ${e.x}, ${e.y})`}static fromString(i){return Wg(i)}static default(){return Ug()}},Me=class t{static initialize(i=0,e=0){return E.initialize(i,e)}static fromPoints(i,e){return t.initialize(e.x-i.x,e.y-i.y)}static vectorLength(i){return Math.sqrt(t.magnitudeSquared(i))}static magnitudeSquared(i){return i.x*i.x+i.y*i.y}static dotProduct(i,e){return i.x*e.x+i.y*e.y}static crossProduct(i,e){return i.x*e.y-i.y*e.x}static subtract(i,e){return t.initialize(i.x-e.x,i.y-e.y)}static add(i,e){return t.initialize(i.x+e.x,i.y+e.y)}static scale(i,e){return t.initialize(i.x*e,i.y*e)}static angle(i,e){let n=Math.acos(Math.max(-1,Math.min(t.dotProduct(i,e)/(t.vectorLength(i)*t.vectorLength(e)),1)));return t.crossProduct(i,e)<0?-n:n}},sl=class{static parseRoundedRect(i){let e=Math.PI*.5,n=i.x,o=i.y,r=i.x+i.width,s=i.y+i.height,a=i.x+i.radius1,c=i.y+i.radius1,l=i.x+i.width-i.radius2,u=i.y+i.radius2,h=i.x+i.width-i.radius3,v=i.y+i.height-i.radius3,w=i.x+i.radius4,S=i.y+i.height-i.radius4;return[new Tt({x:a,y:c},i.radius1,i.radius1,2*e,3*e),new Pt({x:a,y:o},{x:l,y:o}),new Tt({x:l,y:u},i.radius2,i.radius2,3*e,4*e),new Pt({x:r,y:u},{x:r,y:v}),new Tt({x:h,y:v},i.radius3,i.radius3,0,e),new Pt({x:h,y:s},{x:w,y:s}),new Tt({x:w,y:S},i.radius4,i.radius4,e,2*e),new Pt({x:n,y:S},{x:n,y:c})]}},Kt=class{static getRoundedRectIntersections(i,e,n){let o=sl.parseRoundedRect(n);for(let r of o)if(r instanceof Tt){let s=this.intersectArcWithLine(r,i,e);if(s.length>0)return s}else if(r instanceof Pt){let s=this.intersectLineSegments(i,e,r.point1,r.point2);if(s)return[s]}return[]}static getRoundedRectIntersectionsWithSVGPath(i,e){let n=i.getTotalLength(),o=[];for(let r=0;r<=n;r+=1){let s=i.getPointAtLength(r);o.push({x:s.x,y:s.y})}for(let r=1;r<o.length;r++){let s=this.getRoundedRectIntersections(o[r-1],o[r],e);if(s.length>0)return s}return[]}static intersectArcWithLine(i,e,n){return this.filterPointsWithinArc(this.findEllipseLineIntersections(i.center,i.radiusX,i.radiusY,e,n),i)}static intersectLineSegments(i,e,n,o){let r=e.x-i.x,s=e.y-i.y,a=o.x-n.x,c=o.y-n.y,l=(-s*(i.x-n.x)+r*(i.y-n.y))/(-a*s+r*c),u=(a*(i.y-n.y)-c*(i.x-n.x))/(-a*s+r*c);return l>=0&&l<=1&&u>=0&&u<=1?{x:i.x+u*r,y:i.y+u*s}:null}static filterPointsWithinArc(i,e){let{center:n,startAngle:o,endAngle:r}=e;if(i.length===0)return i;r<o&&([o,r]=[r,o]),(o<0||r<0)&&(o+=2*Math.PI,r+=2*Math.PI);let s=[];for(let a of i){let c=this.normalizeAngle(Me.angle(Me.initialize(1,0),Me.initialize(a.x-n.x,a.y-n.y)));c<o&&(c+=2*Math.PI),o<=c&&c<=r&&s.push(a)}return s}static normalizeAngle(i){let e=i%(2*Math.PI);return e<0?e+2*Math.PI:e}static findEllipseLineIntersections(i,e,n,o,r){let s=Me.initialize(o.x,o.y),a=Me.fromPoints(o,r),c=Me.initialize(i.x,i.y),l=Me.subtract(s,c),u=Me.initialize(a.x/(e*e),a.y/(n*n)),h=Me.initialize(l.x/(e*e),l.y/(n*n)),v=Me.dotProduct(a,u),w=Me.dotProduct(a,h),S=Me.dotProduct(l,h)-1,P=w*w-v*S;return P<0?[]:this.calculateIntersectionPoints(P,v,w,o,r)}static calculateIntersectionPoints(i,e,n,o,r){let s=[];if(i>0){let a=Math.sqrt(i),c=(-n-a)/e,l=(-n+a)/e;c>=0&&c<=1&&s.push(E.interpolatePoints(o,r,c)),l>=0&&l<=1&&s.push(E.interpolatePoints(o,r,l))}else{let a=-n/e;a>=0&&a<=1&&s.push(E.interpolatePoints(o,r,a))}return s}};var cl=class{handle(i,e){let n=!0;if(this.validator&&(n=e.get(this.validator).handle(i)),!!n)return e.get(this.execution).handle(i)}execute(i,e){return e.get(this.execution).handle(i)}setValidator(i){this.validator=i}setExecution(i){this.execution=i}},b=class t{constructor(){this._injector=d(Pe)}static registerPipeline(i,e,n){if(!i||!i.fToken)throw new Error("Type must have a fToken static property.");let o=this.pipelines.get(i.fToken)||new cl;n?o.setValidator(e):o.setExecution(e),this.pipelines.set(i.fToken,o)}send(i){let e=t.pipelines.get(i.constructor.fToken);if(e)return e.handle(i,this._injector);throw new Error("Handler not registered for request type.")}execute(i){return t.pipelines.get(i.constructor.fToken).execute(i,this._injector)}};b.pipelines=new Map;b.\u0275fac=function(i){return new(i||b)};b.\u0275prov=f({token:b,factory:b.\u0275fac});function _(t){return function(i){b.registerPipeline(t,i,!1)}}var $g=(()=>{class t{setItem(e,n){localStorage.setItem(e,n)}getItem(e){return localStorage.getItem(e)}removeItem(e){localStorage.removeItem(e)}clear(){localStorage.clear()}static \u0275fac=function(n){return new(n||t)};static \u0275prov=f({token:t,factory:t.\u0275fac,providedIn:"root"})}return t})(),Yg=(()=>{class t{storage={};setItem(e,n){this.storage[e]=n}getItem(e){return this.storage[e]||null}removeItem(e){delete this.storage[e]}clear(){this.storage={}}static \u0275fac=function(n){return new(n||t)};static \u0275prov=f({token:t,factory:t.\u0275fac,providedIn:"root"})}return t})(),qg=new X("F_LOCAL_STORAGE",{providedIn:"root",factory:()=>Ti(d(vi))?d($g):d(Yg)}),Xg=(()=>{class t{getComputedStyle(e){return window.getComputedStyle(e)}get innerWidth(){return window.innerWidth}get innerHeight(){return window.innerHeight}get pageXOffset(){return window.pageXOffset}get pageYOffset(){return window.pageYOffset}isMediaQuery(e){return window.matchMedia(e).matches}requestAnimationFrame(e){return window.requestAnimationFrame(e)}get location(){return window.location}open(e,n,o){window.open(e,n,o)}static \u0275fac=function(n){return new(n||t)};static \u0275prov=f({token:t,factory:t.\u0275fac,providedIn:"root"})}return t})(),Kg=(()=>{class t{getComputedStyle(e){return new Proxy({getPropertyValue:n=>"0"},{get:(n,o)=>o==="getPropertyValue"?n.getPropertyValue:"0"})}get innerWidth(){return 0}get innerHeight(){return 0}get pageXOffset(){return 0}get pageYOffset(){return 0}isMediaQuery(e){return!1}requestAnimationFrame(e){return setTimeout(e,0)}get location(){return{href:"",pathname:"",search:"",hash:"",origin:""}}open(e,n,o){}static \u0275fac=function(n){return new(n||t)};static \u0275prov=f({token:t,factory:t.\u0275fac,providedIn:"root"})}return t})(),Zg=new X("F_WINDOW",{providedIn:"root",factory:()=>Ti(d(vi))?d(Xg):d(Kg)}),ft=(function(t){return t.MAC_OS="macos",t.IOS="ios",t.WINDOWS="windows",t.ANDROID="android",t.LINUX="linux",t})(ft||{}),dl;try{dl=typeof Intl<"u"&&Intl.v8BreakIterator}catch{dl=!1}var ll=(()=>{class t{_platformId;isBrowser=!1;EDGE=this.isBrowser&&/(edge)/i.test(navigator.userAgent);TRIDENT=this.isBrowser&&/(msie|trident)/i.test(navigator.userAgent);BLINK=this.isBrowser&&!!(window.chrome||dl)&&typeof CSS<"u"&&!this.EDGE&&!this.TRIDENT;WEBKIT=this.isBrowser&&/AppleWebKit/i.test(navigator.userAgent)&&!this.BLINK&&!this.EDGE&&!this.TRIDENT;IOS=this.isBrowser&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!("MSStream"in window);FIREFOX=this.isBrowser&&/(firefox|minefield)/i.test(navigator.userAgent);ANDROID=this.isBrowser&&/android/i.test(navigator.userAgent)&&!this.TRIDENT;SAFARI=this.isBrowser&&/safari/i.test(navigator.userAgent)&&this.WEBKIT;constructor(e){this._platformId=e,this.isBrowser=this._platformId?Ti(this._platformId):typeof document=="object"&&!!document}getOS(){let e=navigator.userAgent.toLowerCase(),n=/(macintosh|macintel|macppc|mac68k|macos)/i,o=/(win32|win64|windows|wince)/i,r;return n.test(e)?r=ft.MAC_OS:this.IOS?r=ft.IOS:o.test(e)?r=ft.WINDOWS:this.ANDROID?r=ft.ANDROID:!r&&/linux/.test(e)&&(r=ft.LINUX),r}static \u0275fac=function(n){return new(n||t)(Wt(vi))};static \u0275prov=f({token:t,factory:t.\u0275fac,providedIn:"root"})}return t})(),ce=(()=>{class t{injectedDocument;windowService;localStorageService;platformService;constructor(e,n,o,r){this.injectedDocument=e,this.windowService=n,this.localStorageService=o,this.platformService=r}isBrowser(){return this.platformService.isBrowser}get window(){return this.windowService}get localStorage(){return this.localStorageService}get document(){return this.injectedDocument}toPixels(e,n,o,r){if(e.endsWith("px"))return parseFloat(e);if(e.endsWith("%")){let s=parseFloat(e)/100;return Math.max(n,o)*s}else{if(e.endsWith("em"))return parseFloat(e)*parseFloat(r);if(e.endsWith("rem"))return parseFloat(e)*parseFloat(getComputedStyle(this.document.documentElement).fontSize);if(e.endsWith("vh")){let s=this.window.innerHeight/100;return parseFloat(e)*s}else if(e.endsWith("vw")){let s=this.window.innerWidth/100;return parseFloat(e)*s}}return parseFloat(e)||0}static \u0275fac=function(n){return new(n||t)(Wt(yi),Wt(Zg),Wt(qg),Wt(ll))};static \u0275prov=f({token:t,factory:t.\u0275fac,providedIn:"root"})}return t})();function ul(t,i){return t.reduce((e,n)=>[...e,...i(n)],[])}function hl(t){let i=t.cloneNode(!0),e=i.querySelectorAll("[id]"),n=t.nodeName.toLowerCase();i.removeAttribute("id");for(let o=0;o<e.length;o++)e[o].removeAttribute("id");return n==="canvas"?xh(t,i):(n==="input"||n==="select"||n==="textarea")&&bh(t,i),wh("canvas",t,i,xh),wh("input, textarea, select",t,i,bh),i}function wh(t,i,e,n){let o=i.querySelectorAll(t);if(o.length){let r=e.querySelectorAll(t);for(let s=0;s<o.length;s++)n(o[s],r[s])}}var Qg=0;function bh(t,i){i.type!=="file"&&(i.value=t.value),i.type==="radio"&&i.name&&(i.name=`mat-clone-${i.name}-${Qg++}`)}function xh(t,i){let e=i.getContext("2d");if(e)try{e.drawImage(t,0,0)}catch{}}function fl(t,i,e){for(let n in i)if(i.hasOwnProperty(n)){let o=i[n];o?t.setProperty(n,o,e?.has(n)?"important":""):t.removeProperty(n)}return t}function Ih(t){fl(t.style,{"touch-action":"none","-webkit-user-drag":"none","-webkit-tap-highlight-color":"transparent","user-select":"none","-ms-user-select":"none","-webkit-user-select":"none","-moz-user-select":"none"})}function Sh(t,i,e){return Jg(t,e).dataset[i]}function Jg(t,i){return t.closest(i)}function gl(t,i){let e=t.rootNodes;if(e.length===1&&e[0].nodeType===i.ELEMENT_NODE)return e[0];let n=i.createElement("div");return e.forEach(o=>n.appendChild(o)),n}function Tn(t,i){let e=ep(t,i);return!!e&&!e.classList.contains(i+"-disabled")}function ep(t,i){return t.closest(i)}function st(t){return t.match(/^[a-zA-Z_]/)||(t="_"+t),t.replace(/[^a-zA-Z0-9_\-:.]/g,"_")}function Zt(t,i,e){let n=e[t.toUpperCase()]||tp(e,t.toLowerCase());if(n===void 0)throw new Error(`Unknown ${i}: ${t}. Accepted values: ${Object.keys(e).join(", ")}`);return n}function tp(t,i){return Object.keys(t).find(e=>t[e]===i)}var np=["markerElement"],ip=["fConnectionGradientRenderer",""],op=["f-connection-path",""],rp=["fConnectionSelection",""],sp=["f-connection-drag-handle-start",""],ap=["f-connection-drag-handle-end",""],cp=["defs"],dp=["*"],lp=["fGroupsContainer"],up=["fNodesContainer"],hp=["fConnectionsContainer"],fp=[[["","fGroup",""],["","fGroups",""]],[["f-snap-connection"]],[["f-connection"],["","fConnections",""]],[["f-connection-for-create"]],[["","fNode",""],["","fNodes",""]]],gp=["[fGroup], [fGroups]","f-snap-connection","f-connection, [fConnections]","f-connection-for-create","[fNode], [fNodes]"],pp=[[["svg","fMarker",""]],[["f-connection-marker-circle"],["f-connection-marker-arrow"]],[["f-connection-gradient"]],[["f-connection-waypoints"]],[["","fConnectionContent",""]]],_p=["svg[fMarker]","f-connection-marker-circle, f-connection-marker-arrow","f-connection-gradient","f-connection-waypoints","[fConnectionContent]"];function mp(t,i){t&1&&(ke(),j(0,"linearGradient",3)),t&2&&N("fConnectionGradientRendererFor",i)}function yp(t,i){t&1&&(ke(),j(0,"circle",6))}function vp(t,i){t&1&&ve(0,4)}var Cp="[_nghost-%COMP%]{display:block;position:absolute;left:0;top:0;width:100%;height:100%;overflow:hidden;pointer-events:none;-webkit-user-select:none;user-select:none}",wp=[[["","fDefinitions",""]],[["f-background"]],[["f-line-alignment"]],[["f-canvas"]],[["f-selection-area"]],"*"],bp=["[fDefinitions]","f-background","f-line-alignment","f-canvas","f-selection-area","*"],vl=new X("F_BACKGROUND_PATTERN"),da=class{fPattern;static fToken=Symbol("AddPatternToBackgroundRequest");constructor(i){this.fPattern=i}},tn=class{_items=[];_byId=new Map;get(i){return this._byId.get(i)}require(i){let e=this._byId.get(i);if(!e)throw new Error(`${this.kind} not found: ${i}`);return e}has(i){return this._byId.has(i)}getAll(){return this._items}size(){return this._items.length}add(i){let e=i.fId();if(this._byId.has(e))throw new Error(`${this.kind} already exists: ${e}`);this._items.push(i),this._byId.set(e,i)}addMany(i){for(let e of i)this.add(e)}remove(i){let e=i.fId(),n=this._byId.get(e);if(!n)return!1;this._byId.delete(e);let o=this._items.indexOf(n);return o>=0&&this._items.splice(o,1),!0}removeById(i){let e=this._byId.get(i);if(!e)return;this._byId.delete(i);let n=this._items.indexOf(e);return n>=0&&this._items.splice(n,1),e}clear(){this._items.length=0,this._byId.clear()}};function Rt(t){return{name:t}}var Cl=class{_instances=new Map;get(i){return this._instances.get(i.name)}require(i){let e=this.get(i);if(!e)throw new Error(`Instance not found: ${i.name}`);return e}has(i){return this._instances.has(i.name)}add(i,e){if(this._instances.has(i.name))throw new Error(`${i.name} already exists`);this._instances.set(i.name,e)}remove(i){if(!this._instances.has(i.name))throw new Error(`${i.name} does not exist`);return this._instances.delete(i.name),!0}clear(){this._instances.clear()}},Rn=class extends tn{kind;constructor(i){super(),this.kind=i}},wl=class extends tn{kind="Connection Marker"},bl=class extends tn{kind="Connection";_instancesForCreate;_instancesForSnap;getForSnap(){return this._instancesForSnap}getForCreate(){return this._instancesForCreate}addForCreate(i){this._instancesForCreate=i}addForSnap(i){this._instancesForSnap=i}removeInstanceForCreate(){this._instancesForCreate=void 0}removeInstanceForSnap(){this._instancesForSnap=void 0}},xl=class extends tn{kind="Node"},Qt=class{notifyOnSubscribe;static fToken=Symbol("ListenConnectionsChangesRequest");constructor(i=!0){this.notifyOnSubscribe=i}};function xp(){return t=>{let i=null,e=null,n=()=>{i!==null&&cancelAnimationFrame(i),e!==null&&cancelAnimationFrame(e),i=e=null};return{callback:()=>{n(),i=requestAnimationFrame(()=>{i=null,e=requestAnimationFrame(()=>{e=null,t()})})},cleanup:n}}}function Ip(){return t=>{let i=null;return{callback:()=>{i!==null&&cancelAnimationFrame(i),i=requestAnimationFrame(()=>{i=null,t()})},cleanup:()=>{i!==null&&cancelAnimationFrame(i),i=null}}}}function la(t){return i=>{let e=null;return{callback:()=>{e!==null&&clearTimeout(e),e=setTimeout(()=>{e=null,i()},t)},cleanup:()=>{e!==null&&clearTimeout(e),e=null}}}}var Fe=class{_listeners=new Set;notify(){this._listeners.forEach(i=>i())}listen(i){return this._listeners.add(i),()=>this.stop(i)}stop(i){this._listeners.delete(i)}},Il=class extends Fe{_htmlElement;_observer=new ResizeObserver(()=>this.notify());_isObserving=!1;constructor(i){super(),this._htmlElement=i}listen(i){return this._isObserving||(this._observer.observe(this._htmlElement),this._isObserving=!0),super.listen(i)}stop(i){super.stop(i),this._listeners.size===0&&this._disconnect()}_disconnect(){this._observer.unobserve(this._htmlElement),this._observer.disconnect(),this._isObserving=!1}},Ze=class t{_channels=[];_operators=[];constructor(...i){this._channels=[...i]}pipe(...i){let e=new t(...this._channels);return e._operators=[...this._operators,...i],e}listen(i,e){let n=e,o=[],r=[],s=[];for(let h of[...this._operators].reverse()){let v=h(n);n=v.callback,v.cleanup&&o.push(v.cleanup),v.onSubscribe&&r.push(v.onSubscribe),v.setTeardown&&s.push(v.setTeardown)}let a=this._channels.map(h=>h.listen(()=>n())),c=null,l=!1,u=()=>{l||(l=!0,c?.(),c=null,a.forEach(h=>h()),o.forEach(h=>h()))};s.slice().reverse().forEach(h=>h(u)),r.slice().reverse().forEach(h=>h(n)),c=i.onDestroy(u)}};function Fd(){return t=>{let i=!0;return{callback:t,onSubscribe:e=>{queueMicrotask(()=>{i&&e()})},cleanup:()=>{i=!1}}}}function Eh(){return t=>{let i=!1,e=null;return{setTeardown:n=>e=n,callback:()=>{if(!i){i=!0;try{t()}finally{e?.()}}}}}}var Sp=(()=>{let t=class Bi{_store=d(C);handle({notifyOnSubscribe:e}){return e?new Ze(this._store.connectionsChanges$).pipe(Fd(),la(1)):new Ze(this._store.connectionsChanges$).pipe(la(1))}static \u0275fac=function(n){return new(n||Bi)};static \u0275prov=f({token:Bi,factory:Bi.\u0275fac})};return t=p([_(Qt)],t),t})(),Sl=class{static fToken=Symbol("ListenNodesChangesRequest")},Ep=(()=>{let t=class Gi{_store=d(C);handle(e){return new Ze(this._store.nodesChanges$)}static \u0275fac=function(n){return new(n||Gi)};static \u0275prov=f({token:Gi,factory:Gi.\u0275fac})};return t=p([_(Sl)],t),t})(),ua=class{static fToken=Symbol("ListenTransformChangesRequest")},Dp=(()=>{let t=class ji{_store=d(C);handle(e){return new Ze(this._store.transformChanges$,this._store.connectionsChanges$,this._store.nodesChanges$)}static \u0275fac=function(n){return new(n||ji)};static \u0275prov=f({token:ji,factory:ji.\u0275fac})};return t=p([_(ua)],t),t})(),Nt=class{static fToken=Symbol("EmitConnectionsChangesRequest")},Tp=(()=>{let t=class Hi{_store=d(C);handle(e){this._store.emitConnectionChanges()}static \u0275fac=function(n){return new(n||Hi)};static \u0275prov=f({token:Hi,factory:Hi.\u0275fac})};return t=p([_(Nt)],t),t})(),mt=class{static fToken=Symbol("NotifyTransformChangedRequest")},C=(()=>{class t{transformChanges$=new Fe;viewportAnimationChanges$=new Fe;connectionsChanges$=new Fe;_connectionsRevision=0;connectionsRenderedChanges$=new Fe;_connectionsRenderedRevision=0;_connectionsRenderedNodesRevision=0;_viewportAnimationCount=0;nodesChanges$=new Fe;_nodesRevision=0;progressiveRenderChanges$=new Fe;_pendingProgressiveRenderCount=0;get connectionsRevision(){return this._connectionsRevision}get connectionsRenderedRevision(){return this._connectionsRenderedRevision}get connectionsRenderedNodesRevision(){return this._connectionsRenderedNodesRevision}get nodesRevision(){return this._nodesRevision}get hasPendingProgressiveRender(){return this._pendingProgressiveRenderCount>0}get isViewportAnimating(){return this._viewportAnimationCount>0}get flowHost(){return this.fFlow?.hostElement}fFlow;fCanvas;get transform(){return this.fCanvas?.transform}nodes=new xl;connections=new bl;connectionMarkers=new wl;outputs=new Rn("Output");inputs=new Rn("Input");outlets=new Rn("Outlet");instances=new Cl;fDraggable;emitNodeChanges(){this._nodesRevision++,this.nodesChanges$.notify()}emitConnectionChanges(){this._connectionsRevision++,this.connectionsChanges$.notify()}completeConnectionsRender(e,n){e<this._connectionsRenderedRevision||e===this._connectionsRenderedRevision&&n<=this._connectionsRenderedNodesRevision||(this._connectionsRenderedRevision=Math.min(e,this._connectionsRevision),this._connectionsRenderedNodesRevision=n,this.connectionsRenderedChanges$.notify())}beginProgressiveRender(){this._pendingProgressiveRenderCount++,this.progressiveRenderChanges$.notify()}endProgressiveRender(){this._pendingProgressiveRenderCount&&(this._pendingProgressiveRenderCount--,this.progressiveRenderChanges$.notify())}transformChanged(){this.transformChanges$.notify()}beginViewportAnimation(){this._viewportAnimationCount++,this.viewportAnimationChanges$.notify()}endViewportAnimation(){this._viewportAnimationCount&&(this._viewportAnimationCount--,this.viewportAnimationChanges$.notify())}static \u0275fac=function(n){return new(n||t)};static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})(),te={MAGNETIC_LINES:Rt("magnetic-lines"),MAGNETIC_RECTS:Rt("magnetic-rects"),ZOOM:Rt("zoom-controls"),BACKGROUND:Rt("background"),SELECTION_AREA:Rt("selection-area"),MINIMAP:Rt("minimap"),AUTO_PAN:Rt("auto-pan")},Pp=(()=>{let t=class Vi{_store=d(C);handle(e){this._store.transformChanged()}static \u0275fac=function(n){return new(n||Vi)};static \u0275prov=f({token:Vi,factory:Vi.\u0275fac})};return t=p([_(mt)],t),t})(),kt=class{key;instance;static fToken=Symbol("RegisterPluginInstanceRequest");constructor(i,e){this.key=i,this.instance=e}},Mp=(()=>{let t=class Ui{_store=d(C);handle({key:e,instance:n}){this._store.instances.add(e,n)}static \u0275fac=function(n){return new(n||Ui)};static \u0275prov=f({token:Ui,factory:Ui.\u0275fac})};return t=p([_(kt)],t),t})(),Ot=class{key;static fToken=Symbol("RemovePluginInstanceRequest");constructor(i){this.key=i}},Rp=(()=>{let t=class Wi{_store=d(C);handle({key:e}){this._store.instances.remove(e)}static \u0275fac=function(n){return new(n||Wi)};static \u0275prov=f({token:Wi,factory:Wi.\u0275fac})};return t=p([_(Ot)],t),t})(),Np=[C,Ep,Sp,Dp,Tp,Pp,Mp,Rp],kp=0,Op=(()=>{let t=class $i{_store=d(C);_browser=d(ce);get _backgroundElement(){return this._store.instances.get(te.BACKGROUND)?.hostElement}handle(e){let n=this._getPatterns(e.fPattern?.hostElement);if(!n?.length)return;let o=en("defs",this._browser);if(e.fPattern?.hostElement.remove(),n.forEach(r=>{o.append(r)}),n.length){this._backgroundElement?.firstChild?.appendChild(o),n[n.length-1].id="f-background-pattern-"+kp++;let r=n[n.length-1].id,s=en("rect",this._browser);s.setAttribute("fill","url(#"+r+")"),s.setAttribute("width","100%"),s.setAttribute("height","100%"),this._backgroundElement?.firstChild?.appendChild(s);let a=this._store.fCanvas?.transform||ht.default();e.fPattern?.setTransform(a)}}_getPatterns(e){return Array.from(e?.getElementsByTagName("pattern")||[])}static \u0275fac=function(n){return new(n||$i)};static \u0275prov=f({token:$i,factory:$i.\u0275fac})};return t=p([_(da)],t),t})(),Nn=class{fTransform;static fToken=Symbol("SetBackgroundTransformRequest");constructor(i){this.fTransform=i}},Fp=(()=>{let t=class Yi{_store=d(C);handle(e){this._store.instances.get(te.BACKGROUND)?.setTransform(e.fTransform)}static \u0275fac=function(n){return new(n||Yi)};static \u0275prov=f({token:Yi,factory:Yi.\u0275fac})};return t=p([_(Nn)],t),t})(),Ap=[Op,Fp],ha=class{instance;static fToken=Symbol("AddCanvasToStoreRequest");constructor(i){this.instance=i}},Lp=(()=>{let t=class qi{_store=d(C);handle({instance:e}){this._store.fCanvas=e}static \u0275fac=function(n){return new(n||qi)};static \u0275prov=f({token:qi,factory:qi.\u0275fac})};return t=p([_(ha)],t),t})(),fa=class{id;animated;static fToken=Symbol("CenterGroupOrNodeRequest");constructor(i,e){this.id=i,this.animated=e}},zp=(()=>{let t=class Xi{_store=d(C);_mediator=d(b);get _transform(){return this._store.transform}handle({id:e,animated:n}){let o=this._store.nodes.get(e);o&&(this._toCenter(this._getNodeRect(o),this._getFlowRect(),o._position),this._mediator.execute(new nn(n,Ft.VIEWPORT_ONLY)))}_toCenter(e,n,o){this._transform.scaledPosition=E.initialize(),this._transform.position=E.initialize((n.width-e.width)/2-o.x*this._transform.scale,(n.height-e.height)/2-o.y*this._transform.scale)}_getNodeRect(e){return A.fromElement(e.hostElement)}_getFlowRect(){return A.fromElement(this._store.flowHost)}static \u0275fac=function(n){return new(n||Xi)};static \u0275prov=f({token:Xi,factory:Xi.\u0275fac})};return t=p([_(fa)],t),t})(),ga=class{toCenter;animated;static fToken=Symbol("FitToFlowRequest");constructor(i,e){this.toCenter=i,this.animated=e}},Bp=(()=>{let t=class Ki{_store=d(C);get _transform(){return this._store.transform}_mediator=d(b);handle({toCenter:e,animated:n}){let o=this._mediator.execute(new ln)||A.initialize();o.width===0||o.height===0||(this.fitToParent(o,A.fromElement(this._store.flowHost),this._store.nodes.getAll().map(r=>r._position),e),this._mediator.execute(new nn(n,Ft.VIEWPORT_ONLY)))}fitToParent(e,n,o,r){this._transform.scaledPosition=E.initialize(),this._transform.position=this._getZeroPositionWithoutScale(o);let s=e.width/this._transform.scale+r.x,a=e.height/this._transform.scale+r.y;(s>n.width||a>n.height||s<n.width&&a<n.height)&&(this._transform.scale=Math.min(n.width/s,n.height/a));let c=(n.width-s*this._transform.scale)/2-this._transform.position.x*this._transform.scale,l=(n.height-a*this._transform.scale)/2-this._transform.position.y*this._transform.scale;this._transform.position=E.initialize(c+r.x/2*this._transform.scale,l+r.y/2*this._transform.scale)}_getZeroPositionWithoutScale(e){let n=e.length?Math.min(...e.map(r=>r.x)):0,o=e.length?Math.min(...e.map(r=>r.y)):0;return E.initialize(n,o)}static \u0275fac=function(n){return new(n||Ki)};static \u0275prov=f({token:Ki,factory:Ki.\u0275fac})};return t=p([_(ga)],t),t})(),pa=class{transform;position;static fToken=Symbol("InputCanvasPositionRequest");constructor(i,e){this.transform=i,this.position=e}},Gp=(()=>{let t=class Zi{_store=d(C);handle({transform:e,position:n}){n&&(E.isEqual(this._calculateTransformPosition(e),n)||(e.position=n,e.scaledPosition=E.initialize(),this._store.fCanvas?.redraw()))}_calculateTransformPosition(e){return E.sum(e.position,e.scaledPosition)}static \u0275fac=function(n){return new(n||Zi)};static \u0275prov=f({token:Zi,factory:Zi.\u0275fac})};return t=p([_(pa)],t),t})(),_a=class{transform;scale;static fToken=Symbol("InputCanvasScaleRequest");constructor(i,e){this.transform=i,this.scale=e}},jp=(()=>{let t=class Qi{_store=d(C);handle(e){!e.scale&&e.scale!==0||(e.transform.scale=e.scale,this._store.fCanvas?.redraw())}static \u0275fac=function(n){return new(n||Qi)};static \u0275prov=f({token:Qi,factory:Qi.\u0275fac})};return t=p([_(_a)],t),t})(),Ft=(function(t){return t.VIEWPORT_ONLY="VIEWPORT_ONLY",t.WITH_CONNECTION_CHANGES="WITH_CONNECTION_CHANGES",t})(Ft||{}),nn=class{animated;context;static fToken=Symbol("RedrawCanvasWithAnimationRequest");constructor(i,e=Ft.WITH_CONNECTION_CHANGES){this.animated=i,this.context=e}};function Jh(t,i){let e=n=>{n.propertyName==="transform"&&(t.removeEventListener("transitionend",e),i(n))};t.addEventListener("transitionend",e)}var Hp=(()=>{let t=class Ji{_store=d(C);get _canvas(){return this._store.fCanvas}handle(e){e.animated?this._redrawWithAnimation(e.context):this._redraw(e.context),this._canvas?.emitCanvasChangeEvent()}_redrawWithAnimation(e){this._store.beginViewportAnimation(),this._canvas?.redrawWithAnimation(),Jh(this._canvas.hostElement,()=>{this._store.endViewportAnimation(),e===Ft.WITH_CONNECTION_CHANGES&&this._store.emitConnectionChanges()})}_redraw(e){this._canvas?.redraw(),e===Ft.WITH_CONNECTION_CHANGES&&this._store.emitConnectionChanges()}static \u0275fac=function(n){return new(n||Ji)};static \u0275prov=f({token:Ji,factory:Ji.\u0275fac})};return t=p([_(nn)],t),t})(),ma=class{static fToken=Symbol("RemoveCanvasFromStoreRequest")},Vp=(()=>{let t=class eo{_store=d(C);handle(e){this._store.fCanvas=void 0}static \u0275fac=function(n){return new(n||eo)};static \u0275prov=f({token:eo,factory:eo.\u0275fac})};return t=p([_(ma)],t),t})(),ya=class{static fToken=Symbol("ResetScaleRequest")},Up=(()=>{let t=class to{_store=d(C);get _transform(){return this._store.transform}handle(e){this._transform.scale=1,this._transform.scaledPosition=E.initialize()}static \u0275fac=function(n){return new(n||to)};static \u0275prov=f({token:to,factory:to.\u0275fac})};return t=p([_(ya)],t),t})(),va=class{animated;static fToken=Symbol("ResetScaleAndCenterRequest");constructor(i){this.animated=i}},Wp=(()=>{let t=class no{_mediator=d(b);_store=d(C);get _transform(){return this._store.transform}handle({animated:e}){let n=this._mediator.execute(new ln)||A.initialize();n.width===0||n.height===0||(this._oneToOneCentering(n,A.fromElement(this._store.flowHost),this._store.nodes.getAll().map(o=>o._position)),this._mediator.execute(new nn(e,Ft.VIEWPORT_ONLY)))}_oneToOneCentering(e,n,o){this._transform.scaledPosition=E.initialize(),this._transform.position=this._getZeroPositionWithoutScale(o);let r=(n.width-e.width/this._transform.scale)/2-this._transform.position.x,s=(n.height-e.height/this._transform.scale)/2-this._transform.position.y;this._transform.scale=1,this._transform.position=E.initialize(r,s)}_getZeroPositionWithoutScale(e){let n=e.length?Math.min(...e.map(r=>r.x)):0,o=e.length?Math.min(...e.map(r=>r.y)):0;return E.initialize(n,o)}static \u0275fac=function(n){return new(n||no)};static \u0275prov=f({token:no,factory:no.\u0275fac})};return t=p([_(va)],t),t})(),Ca=class{scale;toPosition;static fToken=Symbol("UpdateScaleRequest");constructor(i,e){this.scale=i,this.toPosition=e}},$p=(()=>{let t=class io{_store=d(C);get _transform(){return this._store.transform}handle({scale:e,toPosition:n}){if(e===this._transform.scale)return;let o=E.sum(this._transform.scaledPosition,this._transform.position),r=n.x-(n.x-o.x)*e/this._transform.scale,s=n.y-(n.y-o.y)*e/this._transform.scale;this._transform.scale=e,this._transform.scaledPosition=E.sub(E.initialize(r,s),this._transform.position)}static \u0275fac=function(n){return new(n||io)};static \u0275prov=f({token:io,factory:io.\u0275fac})};return t=p([_(Ca)],t),t})(),Yp=[Lp,zp,Bp,Gp,jp,Hp,Vp,Up,Wp,$p],El=class{connection;static fToken=Symbol("AddConnectionForCreateToStoreRequest");constructor(i){this.connection=i}},qp=(()=>{let t=class oo{_store=d(C);handle({connection:e}){this._store.connections.addForCreate(e)}static \u0275fac=function(n){return new(n||oo)};static \u0275prov=f({token:oo,factory:oo.\u0275fac})};return t=p([_(El)],t),t})(),Dl=class{instance;static fToken=Symbol("AddConnectionMarkerToStoreRequest");constructor(i){this.instance=i}},Xp=(()=>{let t=class ro{_store=d(C);handle({instance:e}){this._store.connectionMarkers.add(e),this._store.emitNodeChanges()}static \u0275fac=function(n){return new(n||ro)};static \u0275prov=f({token:ro,factory:ro.\u0275fac})};return t=p([_(Dl)],t),t})(),wa=class{connection;static fToken=Symbol("AddConnectionToStoreRequest");constructor(i){this.connection=i}},Kp=(()=>{let t=class so{_store=d(C);handle({connection:e}){this._store.connections.add(e),this._store.emitConnectionChanges()}static \u0275fac=function(n){return new(n||so)};static \u0275prov=f({token:so,factory:so.\u0275fac})};return t=p([_(wa)],t),t})(),Tl=class{connection;static fToken=Symbol("AddSnapConnectionToStoreRequest");constructor(i){this.connection=i}},Zp=(()=>{let t=class ao{_store=d(C);handle({connection:e}){this._store.connections.addForSnap(e)}static \u0275fac=function(n){return new(n||ao)};static \u0275prov=f({token:ao,factory:ao.\u0275fac})};return t=p([_(Tl)],t),t})(),on=class{connection;static fToken=Symbol("CreateConnectionMarkersRequest");constructor(i){this.connection=i}},Dh=new X("F_CONNECTION_CONTENT");var ba=class t{points;cumulativeLengths;segmentTangents;totalLength;constructor(i){let e=t._removeConsecutiveDuplicates(i);if(e.length<2){this.points=[{x:0,y:0},{x:1,y:0}],this.cumulativeLengths=[0,1],this.segmentTangents=[{x:1,y:0}],this.totalLength=1;return}this.points=e;let n=this.points.length,o=n-1,r=new Array(n).fill(0),s=new Array(o),a=0;for(let c=0;c<o;c++){let l=this.points[c+1].x-this.points[c].x,u=this.points[c+1].y-this.points[c].y,h=Math.hypot(l,u),v=h?l/h:1,w=h?u/h:0;s[c]={x:v,y:w},a+=h,r[c+1]=a}this.cumulativeLengths=r,this.segmentTangents=s,this.totalLength=a||1}static from(i){return new t(i.map(e=>({x:e.x,y:e.y})))}static _removeConsecutiveDuplicates(i){let e=[];for(let n of i){let o=e[e.length-1];(!o||o.x!==n.x||o.y!==n.y)&&e.push({x:n.x,y:n.y})}return e}},Pl=class t{_polyline;constructor(i=[]){this._polyline=new ba(i)}updatePoints(i){return this._polyline=new ba(i),this._polyline.totalLength}calculateTotalLength(i){return this.updatePoints(i)}get totalLength(){return this._polyline.totalLength}getPointAtProgress(i){let{points:e,cumulativeLengths:n,segmentTangents:o,totalLength:r}=this._polyline,a=t._clamp(i,0,1)*r,c=.5;if(a<=c)return{point:e[0],tangent:o[0]??{x:1,y:0},atEdge:!0};if(r-a<=c){let k=e.length-1;return{point:e[k],tangent:o[k-1]??{x:1,y:0},atEdge:!0}}let l=t._findRightIndex(n,a),u=Math.max(1,l),h=n[u-1],v=n[u],w=t._safeRatio(a-h,v-h),S=e[u-1],P=e[u],L={x:t._lerp(S.x,P.x,w),y:t._lerp(S.y,P.y,w)},M=o[u-1]??{x:1,y:0};return{point:L,tangent:M,atEdge:!1}}getPointAtLength(i){return this.getPointAtProgress(i)}getPointAtDistance(i){let e=this._polyline.totalLength?i/this._polyline.totalLength:0;return this.getPointAtProgress(e)}static _findRightIndex(i,e){let n=0,o=i.length-1;for(;n<o;){let r=n+o>>1;i[r]<e?n=r+1:o=r}return n}static _lerp(i,e,n){return i+(e-i)*n}static _clamp(i,e,n){return i<e?e:i>n?n:i}static _safeRatio(i,e){let n=Math.abs(e)<1e-6?1e-6:e;return i/n}},ef=(function(t){return t.NONE="none",t.ALONG="along",t})(ef||{}),Ml=class{compute(i,e){let n=this._clamp01(e.position()),{point:o,tangent:r}=i.getPointAtLength(n),s={x:-r.y,y:r.x},a=e.offset()??0,c=o.x+s.x*a,l=o.y+s.y*a,h=this._sizeAlongDirection(e.hostElement,r)*.5,v=n*i.totalLength,w=i.totalLength-v,S=this._applyEdgeGuard(c,l,r,v,w,h),P=this._calculateContentRotation(e.align(),r);return{position:S,rotationDeg:P}}_clamp01(i){return i<=0?0:i>=1?1:i}_applyEdgeGuard(i,e,n,o,r,s){if(o<=s){let a=s-o;return{x:i+n.x*a,y:e+n.y*a}}if(r<=s){let a=s-r;return{x:i-n.x*a,y:e-n.y*a}}return{x:i,y:e}}_sizeAlongDirection(i,e){let n=A.fromElement(i);return Math.abs(e.x)*n.width+Math.abs(e.y)*n.height}_normalize180(i){let e=(i+180)%360;return e<0&&(e+=360),e-180}_keepUpright(i){let e=this._normalize180(i);return e>90?e-=180:e<-90&&(e+=180),e}_calculateContentRotation(i,e){let n=0;return i===ef.ALONG&&(n=Math.atan2(e.y,e.x)*180/Math.PI,n=this._keepUpright(n)),n}},Rl=class{_placement;constructor(i=new Ml){this._placement=i}layout(i,e){let n=new Pl(i),o=n.totalLength;for(let r of e){let{position:s,rotationDeg:a}=this._placement.compute(n,r);r.hostElement.style.transform=this._createTransformString(s,a)}return o}_createTransformString(i,e){return`translate3d(${i.x}px, ${i.y}px, 0) translate(-50%, -50%) rotate(${e}deg)`}};var Th=new X("F_CONNECTION_WAYPOINTS");function tf(t,i,e){return(t.x-i.x)**2+(t.y-i.y)**2<=e**2}function Qp(t,i){let e=t.fWaypoints(),n=e?.radius()||8;return e?.candidates().find(o=>tf(i,o,n))}function Jp(t,i){let e=t.fWaypoints(),n=e?.radius()||8;return e?.waypoints().find(o=>tf(i,o,n))}function e_(t,i){for(let e of t){let n=Jp(e,i);if(n&&e.fWaypoints()?.visibility())return{connection:e,waypoint:n};let o=Qp(e,i);if(o&&e.fWaypoints()?.visibility())return{connection:e,candidate:o}}}var Ad=new X("F_CONNECTION_COMPONENTS_PARENT");var Z=(function(t){return t.START="f-connection-marker-start",t.END="f-connection-marker-end",t.SELECTED_START="f-connection-selected-marker-start",t.SELECTED_END="f-connection-selected-marker-end",t.START_ALL_STATES="f-connection-marker-start-all-states",t.END_ALL_STATES="f-connection-marker-end-all-states",t})(Z||{}),Nl=new X("F_CONNECTION_MARKER"),t_=0,kl=class{fId=J(`f-marker-${t_++}`);hostElement=d(se).nativeElement};function n_(t,i=Z.START){if(typeof t!="string")return i;let e=t.trim().toLowerCase();return e?i_(e)??i:i}function i_(t){switch(t){case"start":case"f-connection-marker-start":return Z.START;case"end":case"f-connection-marker-end":return Z.END;case"selected-start":case"f-connection-selected-marker-start":return Z.SELECTED_START;case"selected-end":case"f-connection-selected-marker-end":return Z.SELECTED_END;case"start-all-states":case"f-connection-marker-start-all-states":case"start-all":case"all-start":return Z.START_ALL_STATES;case"end-all-states":case"f-connection-marker-end-all-states":case"end-all":case"all-end":return Z.END_ALL_STATES;default:return null}}var nf=(()=>{class t extends kl{_markerElement=ge.required("markerElement");_type=R(Z.END_ALL_STATES,{alias:"type",transform:e=>n_(e,Z.END_ALL_STATES)});get markerElement(){return this._markerElement().nativeElement}width=6;height=7;refX=5.5;refY=3.5;get type(){return this._type()}orient="auto";markerUnits="strokeWidth";static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275cmp=ee({type:t,selectors:[["f-connection-marker-arrow"]],viewQuery:function(n,o){n&1&&it(o._markerElement,np,5),n&2&&ze()},hostAttrs:[1,"f-component",2,"display","none"],inputs:{_type:[1,"type","_type"]},features:[me([{provide:Nl,useExisting:t}]),ne],decls:3,vars:0,consts:[["markerElement",""],["viewBox","0 0 6 6",1,"f-marker"],["d","M0,0 L6,3 0,6Z"]],template:function(n,o){n&1&&(ke(),Ye(0,"svg",1,0),Yt(2,"path",2),qe())},encapsulation:2})}return t})();var pt=(function(t){return t.FIXED="fixed",t.FIXED_CENTER="fixed_center",t.FLOATING="floating",t})(pt||{}),De=(function(t){return t.DEFAULT="default",t.TOP="top",t.BOTTOM="bottom",t.LEFT="left",t.RIGHT="right",t.CALCULATE="calculate",t.CALCULATE_HORIZONTAL="calculate_horizontal",t.CALCULATE_VERTICAL="calculate_vertical",t})(De||{});function o_({sourceRect:t,targetRect:i}){return{point1:t.gravityCenter,point2:i.gravityCenter}}var D=(function(t){return t.LEFT="left",t.TOP="top",t.RIGHT="right",t.BOTTOM="bottom",t.CALCULATE="calculate",t.CALCULATE_HORIZONTAL="calculate_horizontal",t.CALCULATE_VERTICAL="calculate_vertical",t.AUTO="auto",t})(D||{}),gt=(function(t){return t.SEGMENT="segment",t.STRAIGHT="straight",t.BEZIER="bezier",t.ADAPTIVE_CURVE="adaptive-curve",t})(gt||{});function r_({sourceRect:t,sourceConnectableSide:i,targetRect:e,targetConnectableSide:n}){return{point1:Ph(t,i===D.AUTO?D.BOTTOM:i),point2:Ph(e,n===D.AUTO?D.TOP:n)}}function Ph(t,i){switch(i){case D.TOP:return{x:t.x+t.width/2,y:t.y};case D.BOTTOM:return{x:t.x+t.width/2,y:t.y+t.height};case D.LEFT:return{x:t.x,y:t.y+t.height/2};case D.RIGHT:return{x:t.x+t.width,y:t.y+t.height/2};default:throw new Error(`Unknown side: ${i}`)}}function of(t,i,e,n){if(!n||!n.rotationDeg)return Kt.getRoundedRectIntersections(t,i,e)[0];let o=co(t,-n.rotationDeg,n.pivot),r=co(i,-n.rotationDeg,n.pivot),s=s_(e,-n.rotationDeg,n.pivot),a=Kt.getRoundedRectIntersections(o,r,s)[0];return a?co(a,n.rotationDeg,n.pivot):void 0}function s_(t,i,e){let n=co(a_(t),i,e);return new ae(n.x-t.width/2,n.y-t.height/2,t.width,t.height,t.radius1,t.radius2,t.radius3,t.radius4)}function a_(t){return{x:t.x+t.width/2,y:t.y+t.height/2}}function co(t,i,e){let n=t.x-e.x,o=t.y-e.y,r=i*Math.PI/180,s=Math.cos(r),a=Math.sin(r);return{x:n*s-o*a+e.x,y:n*a+o*s+e.y}}function c_({sourceRect:t,targetRect:i,sourceRotationContext:e,targetRotationContext:n}){return u_(d_(t,i,e),l_(t,i,n),t,i)}function d_(t,i,e){return of(t.gravityCenter,i.gravityCenter,t,e)}function l_(t,i,e){return of(i.gravityCenter,t.gravityCenter,i,e)}function u_(t,i,e,n){return{point1:t||e.gravityCenter,point2:i||n.gravityCenter}}var Li=.5,h_={[pt.FLOATING]:c_,[pt.FIXED_CENTER]:o_,[pt.FIXED]:r_},_n=(()=>{class t{handle(e){let n=this._calculateDirectionalVectors(e.sourceRect.gravityCenter.x,e.sourceRect.gravityCenter.y,e.targetRect.gravityCenter.x,e.targetRect.gravityCenter.y),o=this._determineSourceSide(e,n),r=this._determineTargetSide(e,n);return e.connection._applyResolvedSidesToConnection(o,r),this._getBehaviorHandler(e.connection.fBehavior)({sourceRect:e.sourceRect,targetRect:e.targetRect,sourceConnectableSide:o,targetConnectableSide:r,sourceRotationContext:e.sourceRotationContext,targetRotationContext:e.targetRotationContext})}_calculateDirectionalVectors(e,n,o,r){let s=o-e,a=r-n;return{sourceToTargetX:s,sourceToTargetY:a,targetToSourceX:-s,targetToSourceY:-a}}_determineSourceSide(e,n){return this._resolveConnectableSide(e.connection.fOutputSide(),n.sourceToTargetX,n.sourceToTargetY,e.sourceConnectableSide)}_determineTargetSide(e,n){return this._resolveConnectableSide(e.connection.fInputSide(),n.targetToSourceX,n.targetToSourceY,e.targetConnectableSide)}_resolveConnectableSide(e,n,o,r){if(e===De.DEFAULT)return r;let s=Math.abs(n),a=Math.abs(o);if(s<Li&&a<Li)return r;let l=s>=a;switch(e){case De.CALCULATE:return l?n>=0?D.RIGHT:D.LEFT:o>=0?D.BOTTOM:D.TOP;case De.CALCULATE_HORIZONTAL:return s<Li?r:n>=0?D.RIGHT:D.LEFT;case De.CALCULATE_VERTICAL:return a<Li?r:o>=0?D.BOTTOM:D.TOP;case De.TOP:return D.TOP;case De.BOTTOM:return D.BOTTOM;case De.LEFT:return D.LEFT;case De.RIGHT:return D.RIGHT;default:return r}}_getBehaviorHandler(e){let n=h_[e];if(!n)throw new Error(`[Behavior] No handler for behavior: ${e}`);return n}static \u0275fac=function(n){return new(n||t)};static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})(),He=class{sourceRect;targetRect;connection;sourceConnectableSide;targetConnectableSide;sourceRotationContext;targetRotationContext;constructor(i,e,n,o,r,s,a){this.sourceRect=i,this.targetRect=e,this.connection=n,this.sourceConnectableSide=o,this.targetConnectableSide=r,this.sourceRotationContext=s,this.targetRotationContext=a}};function Ld(t,i,e){return[t,...e??[],i]}function f_(t,i){let e=Math.abs(i.x-t.x)/2,n=i.x<t.x?i.x+e:i.x-e,o=Math.abs(i.y-t.y)/2,r=i.y<t.y?i.y+o:i.y-o;return{x:n,y:r}}function g_(t,i=32){let e=new Array(i+1);e[0]=W({},t[0]);for(let n=1;n<=i;n++)e[n]=rf(t[0],t[1],t[2],t[3],n/i);return e}function rf(t,i,e,n,o){let r=1-o,s=o*o,a=r*r,c=a*r,l=s*o;return{x:c*t.x+3*a*o*i.x+3*r*s*e.x+l*n.x,y:c*t.y+3*a*o*i.y+3*r*s*e.y+l*n.y}}function sf(t){return t.map(i=>rf(i.p0,i.c1,i.c2,i.p3,.5))}function p_(t){if(t.length<2)throw new Error("Polylines must be at least two points");let i=__(t);return i<=0?[W({},t[0])]:[m_(t,i/2)]}function __(t){let i=0;for(let e=0;e<t.length-1;e++)i+=af(t[e],t[e+1]);return i}function m_(t,i){let e=0;for(let o=0;o<t.length-1;o++){let r=t[o],s=t[o+1],a=af(r,s);if(!(a<=0)){if(e+a>=i){let c=(i-e)/a;return{x:r.x+(s.x-r.x)*c,y:r.y+(s.y-r.y)*c}}e+=a}}let n=t[t.length-1];return{x:n.x,y:n.y}}function af(t,i){return Math.hypot(i.x-t.x,i.y-t.y)}function y_(t){let i=[];for(let e of t)for(let n of e){let o=i[i.length-1];(!o||o.x!==n.x||o.y!==n.y)&&i.push(n)}return i}function cf(t){if(!t.length)return"";let i=`M ${t[0].p0.x} ${t[0].p0.y}`;for(let e=0;e<t.length;e++){let n=t[e],o=e===t.length-1,r=o?n.p3.x+2e-4:n.p3.x,s=o?n.p3.y+2e-4:n.p3.y;i+=` C ${n.c1.x} ${n.c1.y}, ${n.c2.x} ${n.c2.y}, ${r} ${s}`}return i}function df(t,i=16){if(!t.length)return[];let e=[];for(let n=0;n<t.length;n++){let o=t[n],r=g_([o.p0,o.c1,o.c2,o.p3],i);n>0&&r.shift(),e.push(...r)}return e}function v_(t,i=1e-6){let e=t.length;if(e<=2)return t;let n=[];n.push(t[0]);for(let r=1;r<e;r++){let s=t[r],a=n[n.length-1];(Math.abs(s.x-a.x)>i||Math.abs(s.y-a.y)>i)&&n.push(s)}if(n.length<=2)return n;let o=[];o.push(n[0]);for(let r=1;r<n.length-1;r++){let s=o[o.length-1],a=n[r],c=n[r+1],l=Math.abs(s.x-a.x)<=i&&Math.abs(a.x-c.x)<=i,u=Math.abs(s.y-a.y)<=i&&Math.abs(a.y-c.y)<=i;!l&&!u&&o.push(a)}return o.push(n[n.length-1]),o}var Ol=class t{static _dir(i){switch(i){case D.LEFT:return{x:-1,y:0};case D.RIGHT:return{x:1,y:0};case D.TOP:return{x:0,y:-1};case D.BOTTOM:return{x:0,y:1};case D.AUTO:return{x:0,y:0}}return{x:0,y:0}}static _isHorizontal(i){return i===D.LEFT||i===D.RIGHT}static _handleLength(i,e,n,o){let r=Math.abs(e.x-i.x),s=Math.abs(e.y-i.y),a=Math.hypot(r,s),c=n===D.AUTO?Math.max(r,s):this._isHorizontal(n)?r:s,l=Math.max(8,o),u=o+.5*a,h=o*1.05+c*.3;return Math.min(u,Math.max(l,h))}static _softControl(i,e,n,o){let r=this._dir(i),s=n.x-e.x,a=n.y-e.y,c=Math.hypot(s,a)||1,l=s/c,u=a/c;if(i===D.AUTO)return{x:e.x+l*o,y:e.y+u*o};let h=r.x*l+r.y*u,v=.12,w=Math.max(0,-h)*.08,S=Math.min(.2,v+w),P=r.x*(1-S)+l*S,L=r.y*(1-S)+u*S,M=Math.hypot(P,L)||1;return{x:e.x+P/M*o,y:e.y+L/M*o}}handle({source:i,sourceSide:e,target:n,targetSide:o,offset:r,waypoints:s}){let a=Math.max(0,r??0),c=Ld(i,n,s),l=[];for(let h=0;h<c.length-1;h++){let v=c[h],w=c[h+1],S=t._handleLength(v,w,e,a),P=t._handleLength(w,v,o,a),L=t._softControl(e,v,w,S),M=t._softControl(o,w,v,P);l.push({p0:v,c1:L,c2:M,p3:w,chainIndex:h})}let u=df(l,12);return{path:cf(l),secondPoint:l[0]?.c1??i,penultimatePoint:l[l.length-1]?.c2??n,points:u,candidates:sf(l)}}},Fl=class{handle({source:i,sourceSide:e,target:n,targetSide:o,offset:r,waypoints:s}){let a=Ld(i,n,s),c=[];for(let u=0;u<a.length-1;u++){let h=a[u],v=a[u+1],w=Mh(e,h,v,r??0),S=Mh(o,v,h,r??0);c.push({p0:h,c1:w,c2:S,p3:v,chainIndex:u})}let l=df(c,12);return{path:cf(c),secondPoint:c[0]?.c1??i,penultimatePoint:c[c.length-1]?.c2??n,points:l,candidates:sf(c)}}};function Mh(t,i,e,n){let o={x:i.x,y:i.y};switch(t){case D.LEFT:o.x-=zi(i.x-e.x,n);break;case D.RIGHT:o.x+=zi(e.x-i.x,n);break;case D.TOP:o.y-=zi(i.y-e.y,n);break;case D.BOTTOM:o.y+=zi(e.y-i.y,n);break;case D.AUTO:break}return o}function zi(t,i){return t>=i?t:i*Math.sqrt(i-t)}function C_(t){let{axis:i,source:e,target:n,sourceSide:o,targetSide:r,sourceGap:s,targetGap:a,sourceDir:c,targetDir:l,currentDir:u,offset:h,sourceGapOffset:v,targetGapOffset:w}=t,S=w_(s,a),P=b_(i,c,u,S);return o===r?x_(i,e,n,h,c,u,s,a,v,w):P=I_(i,c,l,s,a,S,P),P}function w_(t,i){return{sourceTarget:[{x:t.x,y:i.y}],targetSource:[{x:i.x,y:t.y}]}}function b_(t,i,e,n){return t==="x"?i.x===e?n.targetSource:n.sourceTarget:i.y===e?n.sourceTarget:n.targetSource}function x_(t,i,e,n,o,r,s,a,c,l){let u=Math.abs(i[t]-e[t]);if(u>n)return;let h=Math.min(n-1,n-u);h<=0||(o[t]===r?c[t]=(s[t]>i[t]?-1:1)*h:l[t]=(a[t]>e[t]?-1:1)*h)}function I_(t,i,e,n,o,r,s){let a=t==="x"?"y":"x",c=i[t]===e[a],l=n[a]>o[a],u=n[a]<o[a];return i[t]===1&&(!c&&l||c&&u)||i[t]!==1&&(!c&&u||c&&l)?t==="x"?r.sourceTarget:r.targetSource:s}var Pn=1e-6,Rh=2e-4,S_=.75;function E_(t,i){let e=t.length,n=[];n.push(`M ${t[0].x} ${t[0].y}`);for(let r=1;r<e-1;r++)n.push(D_(t[r-1],t[r],t[r+1],i));let o=t[e-1];return n.push(`L ${o.x+Rh} ${o.y+Rh}`),n.join(" ")}function D_(t,i,e,n){let o=i.x,r=i.y;if(n<=0)return`L ${o} ${r}`;let s=Math.abs(t.x-o)<=Pn&&Math.abs(o-e.x)<=Pn,a=Math.abs(t.y-r)<=Pn&&Math.abs(r-e.y)<=Pn;if(s||a)return`L ${o} ${r}`;let c=Math.hypot(o-t.x,r-t.y),l=Math.hypot(e.x-o,e.y-r),u=Math.min(c*.5,l*.5,n);if(u<S_)return`L ${o} ${r}`;if(Math.abs(t.y-r)<=Pn){let L=t.x<e.x?-1:1,M=t.y<e.y?1:-1,k=o+u*L,H=r+u*M;return`L ${k} ${r} Q ${o} ${r} ${o} ${H}`}let v=t.x<e.x?1:-1,w=t.y<e.y?-1:1,S=r+u*w,P=o+u*v;return`L ${o} ${S} Q ${o} ${r} ${P} ${r}`}var Nh={[D.LEFT]:E.initialize(-1,0),[D.RIGHT]:E.initialize(1,0),[D.TOP]:E.initialize(0,-1),[D.BOTTOM]:E.initialize(0,1),[D.AUTO]:E.initialize(0,0)},Al=class{handle({source:i,sourceSide:e,target:n,targetSide:o,waypoints:r,offset:s,radius:a}){let c=Ld(i,n,r),l=[],u=[];for(let S=0;S<c.length-1;S++){let P=c[S],L=c[S+1],M=this._getPathPoints(P,e,L,o,s??0);l.push(M),u.push(...p_(M))}let h=v_(y_(l)),v=h.length>1?h[h.length-2]:i,w=h.length>1?h[1]:n;return{path:E_(h,a??0),penultimatePoint:v,secondPoint:w,points:h,candidates:u}}_getPathPoints(i,e,n,o,r){let s=Nh[e],a=Nh[o],c={x:i.x+s.x*r,y:i.y+s.y*r},l={x:n.x+a.x*r,y:n.y+a.y*r},u=this._getDirection(c,e,l),h=u.x!==0?"x":"y",v=u[h],w=[],S=E.initialize(),P=E.initialize(),L=f_(i,n);if(s[h]*a[h]===-1){let M=[{x:L.x,y:c.y},{x:L.x,y:l.y}],k=[{x:c.x,y:L.y},{x:l.x,y:L.y}];s[h]===v?w=h==="x"?M:k:w=h==="x"?k:M}else w=C_({axis:h,source:i,target:n,sourceSide:e,targetSide:o,sourceGap:c,targetGap:l,sourceDir:s,targetDir:a,currentDir:v,offset:r,sourceGapOffset:S,targetGapOffset:P});return[i,{x:c.x+S.x,y:c.y+S.y},...w,{x:l.x+P.x,y:l.y+P.y},n]}_getDirection(i,e,n){return e===D.LEFT||e===D.RIGHT?i.x<n.x?E.initialize(1,0):E.initialize(-1,0):i.y<n.y?E.initialize(0,1):E.initialize(0,-1)}},kh=2e-4,Ll=class{handle(i){let e=Ld(i.source,i.target,i.waypoints),n=e.length,o=e[0],r=`M ${o.x} ${o.y}`,s=new Array(n-1);for(let a=0;a<n-1;a++){let c=e[a],l=e[a+1],u=a===n-2,h=u?l.x+kh:l.x,v=u?l.y+kh:l.y;r+=` L ${h} ${v}`,s[a]={x:(c.x+l.x)*.5,y:(c.y+l.y)*.5}}return{path:r,candidates:s,points:e,secondPoint:e[1]??i.target,penultimatePoint:e[n-2]??i.source}}},T_=new X("F_CONNECTION_BUILDERS"),lf=(()=>{class t{_builtinBuilders={[gt.STRAIGHT]:new Ll,[gt.BEZIER]:new Fl,[gt.ADAPTIVE_CURVE]:new Ol,[gt.SEGMENT]:new Al};_providedBuilders;_builders;constructor(){this._providedBuilders=d(T_,{optional:!0})||{},this._builders=W(W({},this._builtinBuilders),this._providedBuilders)}handle({type:e,payload:n}){let o=this._builders[e];if(!o)throw this._createBuilderNotFoundError(e);return o.handle(n)}_createBuilderNotFoundError(e){let n=Object.keys(this._builtinBuilders).sort(),o=Object.keys(this._providedBuilders).sort(),r=Object.keys(this._builders).sort(),s=n.filter(c=>c in this._providedBuilders).sort(),a=[`Connection Builder Error: builder type "${e}" not found.`,`Registered types: ${r.length?r.join(", "):"(none)"}`,`Built-in types: ${n.length?n.join(", "):"(none)"}`,`Provided (F_CONNECTION_BUILDERS) types: ${o.length?o.join(", "):"(none)"}`,s.length?`Overridden built-ins: ${s.join(", ")}`:null,"Tip: ensure you pass a valid Connection Type or provide a builder via F_CONNECTION_BUILDERS."].filter(Boolean);return new Error(a.join(`
2
+ `))}static \u0275fac=function(n){return new(n||t)};static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})();function P_(t,i,e){return st("connection_"+t+i+e)}function M_(t,i,e){return st("connection_for_selection_"+t+i+e)}function uf(t){return st("connection_gradient_"+t)}function R_(t){return`url(#${uf(t)})`}var N_=(()=>{class t{_connection=d(Ad);_hostElement=d(se).nativeElement;_injector=d(Pe);_hostAttributes=new Map;_startColor;_endColor;gradientId=z(()=>uf(this._connection.fId()));ngOnInit(){this._listenColorChanges()}_listenColorChanges(){Se(()=>{this.gradient().fStartColor(),this.gradient().fEndColor(),Et(()=>{this._updateGradient()})},{injector:this._injector})}get stop1Element(){return this._hostElement.children.item(0)}get stop2Element(){return this._hostElement.children.item(1)}redraw(e){let n=e.point2.x-e.point1.x,o=e.point2.y-e.point1.y,r=Math.sqrt(n*n+o*o)||.01,s=new B(.5-.5*n/r,.5-.5*o/r);this._setHostAttribute("x1",s.x.toString()),this._setHostAttribute("y1",s.y.toString());let a=new B(.5+.5*n/r,.5+.5*o/r);this._setHostAttribute("x2",a.x.toString()),this._setHostAttribute("y2",a.y.toString()),this._updateGradient()}_updateGradient(){let e=this.gradient();this._setFromColor(e.fStartColor()),this._setToColor(e.fEndColor())}_setFromColor(e){let n=e||"transparent";this._startColor!==n&&(this._startColor=n,this.stop1Element.setAttribute("stop-color",n),this.stop1Element.style.setProperty("stop-color",n))}_setToColor(e){let n=e||"transparent";this._endColor!==n&&(this._endColor=n,this.stop2Element.setAttribute("stop-color",n),this.stop2Element.style.setProperty("stop-color",n))}_setHostAttribute(e,n){this._hostAttributes.get(e)!==n&&(this._hostAttributes.set(e,n),this._hostElement.setAttribute(e,n))}static \u0275fac=function(n){return new(n||t)};static \u0275dir=le({type:t,standalone:!1})}return t})(),zl=(()=>{class t extends N_{gradient=R.required({alias:"fConnectionGradientRendererFor"});static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275cmp=ee({type:t,selectors:[["linearGradient","fConnectionGradientRenderer",""]],hostVars:1,hostBindings:function(n,o){n&2&&K("id",o.gradientId())},inputs:{gradient:[1,"fConnectionGradientRendererFor","gradient"]},features:[ne],attrs:ip,decls:3,vars:0,consts:[[0,"xmlns","svg","http://www.w3.org/2000/svg"],["offset","0%"],["offset","100%"]],template:function(n,o){n&1&&(Ii(0,0),ke(),Yt(1,"stop",1)(2,"stop",2),Si())},encapsulation:2,changeDetection:0})}return t})(),Oh=new X("F_CONNECTION_GRADIENT");var Bl=new X("F_CONNECTION_PATH"),Gl=class{hostElement=d(se).nativeElement},k_=(()=>{class t extends Gl{_connection=d(Ad);useGradient=R(!1);linkToGradient=z(()=>this.useGradient()?R_(this._connection.fId()):null);get fPathId(){return this._connection.fId()}get attrConnectionId(){return P_(this._connection.fId(),this._connection.fOutputId(),this._connection.fInputId())}initialize(){this.deselect()}setPath(e){this.hostElement.setAttribute("d",`${e}`)}select(){this.hostElement.setAttribute("marker-start",`url(#${A_(this._connection.fId())})`),this.hostElement.setAttribute("marker-end",`url(#${L_(this._connection.fId())})`)}deselect(){this.hostElement.setAttribute("marker-start",`url(#${O_(this._connection.fId())})`),this.hostElement.setAttribute("marker-end",`url(#${F_(this._connection.fId())})`)}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275cmp=ee({type:t,selectors:[["path","f-connection-path",""]],hostAttrs:[1,"f-component","f-connection-path"],hostVars:4,hostBindings:function(n,o){n&2&&(K("id",o.attrConnectionId)("data-f-path-id",o.fPathId),lt("stroke",o.linkToGradient()))},inputs:{useGradient:[1,"useGradient"]},standalone:!1,features:[me([{provide:Bl,useExisting:t}]),ne],attrs:op,decls:0,vars:0,template:function(n,o){},styles:["[_nghost-%COMP%]{fill:none;pointer-events:stroke}"],changeDetection:0})}return t})();function O_(t){return st(`f-connection-marker-start-${t}`)}function F_(t){return st(`f-connection-marker-end-${t}`)}function A_(t){return st(`f-connection-selected-marker-start-${t}`)}function L_(t){return st(`f-connection-selected-marker-end-${t}`)}var jl=new X("F_CONNECTION_SELECTION"),Hl=class{hostElement=d(se).nativeElement},z_=(()=>{class t extends Hl{_connection=d(Ad);get connectionForSelectionId(){return M_(this._connection.fId(),this._connection.fOutputId(),this._connection.fInputId())}setPath(e){this.hostElement.setAttribute("d",`${e}`)}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275cmp=ee({type:t,selectors:[["path","fConnectionSelection",""]],hostAttrs:[1,"f-component","f-connection-selection"],hostVars:1,hostBindings:function(n,o){n&2&&K("id",o.connectionForSelectionId)},standalone:!1,features:[me([{provide:jl,useExisting:t}]),ne],attrs:rp,decls:0,vars:0,template:function(n,o){},styles:["[_nghost-%COMP%]{fill:none;pointer-events:stroke}"],changeDetection:0})}return t})(),Vl=new X("F_CONNECTION_DRAG_HANDLE_END"),Ul=new X("F_CONNECTION_DRAG_HANDLE_START"),xa=class{hostElement=d(se).nativeElement;point=E.initialize();class="f-connection-drag-handle";calculateCircleCenter(i,e,n){let o={x:e.x-i.x,y:e.y-i.y},r=Math.sqrt(o.x*o.x+o.y*o.y)||1,s={x:o.x/r,y:o.y/r},a={x:s.x*n,y:s.y*n};return{x:e.x-a.x,y:e.y-a.y}}},B_=(()=>{class t extends xa{redraw(e,n){this.point=this.calculateCircleCenter(e,n,8),this.hostElement.setAttribute("cx",this.point.x.toString()),this.hostElement.setAttribute("cy",this.point.y.toString())}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275cmp=ee({type:t,selectors:[["circle","f-connection-drag-handle-start",""]],hostVars:2,hostBindings:function(n,o){n&2&&Xe(o.class)},standalone:!1,features:[me([{provide:Ul,useExisting:t}]),ne],attrs:sp,decls:0,vars:0,template:function(n,o){},encapsulation:2,changeDetection:0})}return t})(),G_=(()=>{class t extends xa{redraw(e,n){this.point=this.calculateCircleCenter(e,n,8),this.hostElement.setAttribute("cx",this.point.x.toString()),this.hostElement.setAttribute("cy",this.point.y.toString())}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275cmp=ee({type:t,selectors:[["circle","f-connection-drag-handle-end",""]],hostVars:2,hostBindings:function(n,o){n&2&&Xe(o.class)},standalone:!1,features:[me([{provide:Vl,useExisting:t}]),ne],attrs:ap,decls:0,vars:0,template:function(n,o){},encapsulation:2,changeDetection:0})}return t})(),pl="f-selected";function hf(t){return class extends t{fId=J("");fSelectionDisabled=J(!1);unmarkAsSelected(){this.unmarkChildrenAsSelected?.(),this.hostElement.classList.remove(pl)}markAsSelected(){this.markChildrenAsSelected?.(),this.isSelected()||this.hostElement.classList.add(pl)}isSelected(){return this.hostElement.classList.contains(pl)}markChildrenAsSelected(){}unmarkChildrenAsSelected(){}constructor(...i){super(...i)}}}function j_(t){return class extends t{show(){this.hostElement.style.display="unset"}hide(){this.hostElement.style.display="none"}constructor(...i){super(...i)}}}var H_=hf(j_(class{hostElement;constructor(t){this.hostElement=t}})),V_=(()=>{class t extends H_{_fConnectionBuilder=d(lf);path="";line=Dn.initialize();fReassignableStart=J(!1);fDraggingDisabled=J(!1);fSelectionDisabled=J(!1);fDefs=ge.required("defs");fPath=ge.required(Bl);fDragHandleStart=ge(Ul);fDragHandleEnd=ge.required(Vl);fSelection=ge.required(jl);fContents=rl(Dh,{descendants:!0});fMarkers=rl(Nl,{descendants:!0});fGradient=Di(Oh);_fGradientRenderer=ge(zl);fWaypoints=Di(Th);fInputSide=J(De.DEFAULT);_contentLayoutEngine=new Rl;_sourceSide=D.AUTO;fOutputSide=J(De.DEFAULT);_targetSide=D.AUTO;_penultimatePoint=E.initialize();_secondPoint=E.initialize();constructor(){super(d(se).nativeElement)}initialize(){this.redraw(),this.isSelected()?this.markChildrenAsSelected():this.unmarkChildrenAsSelected()}isContains(e){return(this.hostElement.firstChild?.lastChild).contains(e)||Array.from(this.fContents()?.values()??[]).some(n=>n.hostElement?.contains(e))||this.fWaypoints()?.hostElement?.contains(e)}setLine({point1:e,point2:n}){this.line=Dn.initialize(e,n);let{path:o,points:r,penultimatePoint:s,secondPoint:a,candidates:c}=this._getPathResult(e,n);this.path=o,this._penultimatePoint=s||e,this._secondPoint=a||n,this.fWaypoints()?.candidates.set(c||[]),this._contentLayoutEngine.layout(r||[],this._contents())}_contents(){return Array.from(this.fContents()?.values()??[])}_getPathResult(e,n){return this._fConnectionBuilder.handle({type:this.fType,payload:{source:e,sourceSide:this._sourceSide,target:n,targetSide:this._targetSide,radius:this.fRadius,offset:this.fOffset,waypoints:this.fWaypoints()?.waypoints()||[]}})}markChildrenAsSelected(){this.fPath().select()}unmarkChildrenAsSelected(){this.fPath().deselect()}redraw(){this.fPath().setPath(this.path),this.fSelection().setPath(this.path),this.fDragHandleEnd().redraw(this._penultimatePoint,this.line.point2),this.fDragHandleStart()?.redraw(this._secondPoint,this.line.point1),this._fGradientRenderer()?.redraw(this.line)}getResolvedSides(){return{sourceSide:this._sourceSide,targetSide:this._targetSide}}_applyResolvedSidesToConnection(e,n){this._sourceSide=e,this._targetSide=n}static \u0275fac=function(n){return new(n||t)};static \u0275dir=le({type:t,contentQueries:function(n,o,r){n&1&&ol(r,o.fContents,Dh,5)(r,o.fMarkers,Nl,5)(r,o.fGradient,Oh,5)(r,o.fWaypoints,Th,5),n&2&&ze(4)},viewQuery:function(n,o){n&1&&it(o.fDefs,cp,5)(o.fPath,Bl,5)(o.fDragHandleStart,Ul,5)(o.fDragHandleEnd,Vl,5)(o.fSelection,jl,5)(o._fGradientRenderer,zl,5),n&2&&ze(6)},standalone:!1,features:[ne]})}return t})(),U_=(()=>{let t=class lo{_browser=d(ce);_markerCache=new WeakMap;handle({connection:e}){let n=this._findConnectionMarkers(e),o=e.fDefs();if(!o)return!1;let r=W_(n),s=this._markerCache.get(e);if(s?.signature===r&&s.defsElement===o.nativeElement)return!1;let a=gf("defs",this._browser);return n.forEach(c=>{ff(c.type).forEach(l=>{let u=$_(l,c,e.fId(),this._browser),h=c.markerElement.cloneNode(!0);h.setAttribute("height",`${c.height}`),h.setAttribute("width",`${c.width}`),h.removeAttribute("markerUnits"),h.style.display="unset",u.append(h),a.append(u)})}),o.nativeElement.innerHTML=a.innerHTML,this._markerCache.set(e,{signature:r,defsElement:o.nativeElement}),this._makeSafariCompatible(e),!0}_findConnectionMarkers(e){return Array.from(e.fMarkers()??[])}_makeSafariCompatible(e){e.fPath().hostElement.replaceWith(e.fPath().hostElement)}static \u0275fac=function(n){return new(n||lo)};static \u0275prov=f({token:lo,factory:lo.\u0275fac})};return t=p([_(on)],t),t})();function W_(t){return t.map(i=>[...ff(i.type),i.width,i.height,i.refX,i.refY,i.orient,i.markerUnits,i.markerElement.outerHTML].join("|")).join("||")}function $_(t,i,e,n){let o=gf("marker",n);return o.setAttribute("id",st(t+"-"+e)),o.setAttribute("markerHeight",`${i.height}`),o.setAttribute("markerWidth",`${i.width}`),o.setAttribute("orient",`${i.orient}`),o.setAttribute("refX",`${i.refX}`),o.setAttribute("refY",`${i.refY}`),o.setAttribute("markerUnits",`${i.markerUnits}`),o}function ff(t){switch(t){case Z.START:return[Z.START];case Z.END:return[Z.END];case Z.SELECTED_START:return[Z.SELECTED_START];case Z.SELECTED_END:return[Z.SELECTED_END];case Z.START_ALL_STATES:return[Z.START,Z.SELECTED_START];case Z.END_ALL_STATES:return[Z.END,Z.SELECTED_END];default:return[]}}function gf(t,i){return i.document.createElementNS("http://www.w3.org/2000/svg",t)}var zd=(()=>{class t{renderTicket=0;_connectedInPreviousRender=new Set;beginRender(){return++this.renderTicket}resetConnectedConnectors(){for(let e of this._connectedInPreviousRender)e.resetConnected();this._connectedInPreviousRender.clear()}trackConnectedConnectors(e,n){this._connectedInPreviousRender.add(e),this._connectedInPreviousRender.add(n)}static \u0275fac=function(n){return new(n||t)};static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})(),Y_=String.raw`
3
+ const EPSILON = 0.5;
4
+
5
+ addEventListener('message', (event) => {
6
+ const data = event?.data;
7
+ const requestId = data?.requestId;
8
+ const items = Array.isArray(data?.items) ? data.items : [];
9
+
10
+ try {
11
+ const results = items.map((item) => calculateItem(item));
12
+ postMessage({ requestId, results });
13
+ } catch (error) {
14
+ const message = error instanceof Error ? error.message : 'Connection worker failed.';
15
+ postMessage({ requestId, error: message });
16
+ }
17
+ });
18
+
19
+ function calculateItem(item) {
20
+ const sourceCenterX = item.sourceRect.x + item.sourceRect.width / 2;
21
+ const sourceCenterY = item.sourceRect.y + item.sourceRect.height / 2;
22
+ const targetCenterX = item.targetRect.x + item.targetRect.width / 2;
23
+ const targetCenterY = item.targetRect.y + item.targetRect.height / 2;
24
+
25
+ const sourceSide = resolveConnectableSide(
26
+ item.outputSide,
27
+ targetCenterX - sourceCenterX,
28
+ targetCenterY - sourceCenterY,
29
+ item.sourceConnectableSide,
30
+ );
31
+
32
+ const targetSide = resolveConnectableSide(
33
+ item.inputSide,
34
+ sourceCenterX - targetCenterX,
35
+ sourceCenterY - targetCenterY,
36
+ item.targetConnectableSide,
37
+ );
38
+
39
+ if (item.behavior === 'fixed_center') {
40
+ return {
41
+ originalIndex: item.originalIndex,
42
+ supported: true,
43
+ sourceSide,
44
+ targetSide,
45
+ line: {
46
+ point1: { x: sourceCenterX, y: sourceCenterY },
47
+ point2: { x: targetCenterX, y: targetCenterY },
48
+ },
49
+ };
50
+ }
51
+
52
+ if (item.sourceRotation || item.targetRotation) {
53
+ return { originalIndex: item.originalIndex, supported: false };
54
+ }
55
+
56
+ if (item.behavior !== 'fixed') {
57
+ if (item.behavior !== 'floating') {
58
+ return { originalIndex: item.originalIndex, supported: false };
59
+ }
60
+
61
+ if (hasRoundedCorners(item.sourceRect) || hasRoundedCorners(item.targetRect)) {
62
+ return { originalIndex: item.originalIndex, supported: false };
63
+ }
64
+
65
+ return {
66
+ originalIndex: item.originalIndex,
67
+ supported: true,
68
+ sourceSide,
69
+ targetSide,
70
+ line: buildFloatingLine(item.sourceRect, item.targetRect),
71
+ };
72
+ }
73
+
74
+ const line = buildFixedLine(item.sourceRect, item.targetRect, sourceSide, targetSide);
75
+ if (!line) {
76
+ return { originalIndex: item.originalIndex, supported: false };
77
+ }
78
+
79
+ return {
80
+ originalIndex: item.originalIndex,
81
+ supported: true,
82
+ sourceSide,
83
+ targetSide,
84
+ line,
85
+ };
86
+ }
87
+
88
+ function resolveConnectableSide(requestedSide, deltaX, deltaY, fallbackSide) {
89
+ if (requestedSide === 'default') {
90
+ return fallbackSide;
91
+ }
92
+
93
+ const absX = Math.abs(deltaX);
94
+ const absY = Math.abs(deltaY);
95
+ const nearZero = absX < EPSILON && absY < EPSILON;
96
+
97
+ if (nearZero) {
98
+ return fallbackSide;
99
+ }
100
+
101
+ const horizontalDominant = absX >= absY;
102
+
103
+ switch (requestedSide) {
104
+ case 'calculate':
105
+ return horizontalDominant ? (deltaX >= 0 ? 'right' : 'left') : deltaY >= 0 ? 'bottom' : 'top';
106
+
107
+ case 'calculate_horizontal':
108
+ if (absX < EPSILON) {
109
+ return fallbackSide;
110
+ }
111
+
112
+ return deltaX >= 0 ? 'right' : 'left';
113
+
114
+ case 'calculate_vertical':
115
+ if (absY < EPSILON) {
116
+ return fallbackSide;
117
+ }
118
+
119
+ return deltaY >= 0 ? 'bottom' : 'top';
120
+
121
+ case 'top':
122
+ case 'bottom':
123
+ case 'left':
124
+ case 'right':
125
+ return requestedSide;
126
+
127
+ default:
128
+ return fallbackSide;
129
+ }
130
+ }
131
+
132
+ function buildFixedLine(sourceRect, targetRect, sourceSide, targetSide) {
133
+ const sourceAnchor = sourceSide === 'auto' ? 'bottom' : sourceSide;
134
+ const targetAnchor = targetSide === 'auto' ? 'top' : targetSide;
135
+
136
+ const point1 = getSidePoint(sourceRect, sourceAnchor);
137
+ const point2 = getSidePoint(targetRect, targetAnchor);
138
+
139
+ if (!point1 || !point2) {
140
+ return null;
141
+ }
142
+
143
+ return { point1, point2 };
144
+ }
145
+
146
+ function buildFloatingLine(sourceRect, targetRect) {
147
+ const sourceCenter = getRectCenter(sourceRect);
148
+ const targetCenter = getRectCenter(targetRect);
149
+
150
+ return {
151
+ point1: getRectBorderIntersection(sourceRect, sourceCenter, targetCenter),
152
+ point2: getRectBorderIntersection(targetRect, targetCenter, sourceCenter),
153
+ };
154
+ }
155
+
156
+ function hasRoundedCorners(rect) {
157
+ return !!(rect.radius1 || rect.radius2 || rect.radius3 || rect.radius4);
158
+ }
159
+
160
+ function getRectCenter(rect) {
161
+ return {
162
+ x: rect.x + rect.width / 2,
163
+ y: rect.y + rect.height / 2,
164
+ };
165
+ }
166
+
167
+ function getRectBorderIntersection(rect, from, to) {
168
+ const halfWidth = rect.width / 2;
169
+ const halfHeight = rect.height / 2;
170
+ const center = getRectCenter(rect);
171
+
172
+ const dx = to.x - from.x;
173
+ const dy = to.y - from.y;
174
+
175
+ if (Math.abs(dx) < EPSILON && Math.abs(dy) < EPSILON) {
176
+ return center;
177
+ }
178
+
179
+ const scaleX = Math.abs(dx) < EPSILON ? Number.POSITIVE_INFINITY : halfWidth / Math.abs(dx);
180
+ const scaleY = Math.abs(dy) < EPSILON ? Number.POSITIVE_INFINITY : halfHeight / Math.abs(dy);
181
+ const scale = Math.min(scaleX, scaleY);
182
+
183
+ return {
184
+ x: center.x + dx * scale,
185
+ y: center.y + dy * scale,
186
+ };
187
+ }
188
+
189
+ function getSidePoint(rect, side) {
190
+ const centerX = rect.x + rect.width / 2;
191
+ const centerY = rect.y + rect.height / 2;
192
+
193
+ switch (side) {
194
+ case 'top':
195
+ return { x: centerX, y: rect.y };
196
+
197
+ case 'right':
198
+ return { x: rect.x + rect.width, y: centerY };
199
+
200
+ case 'bottom':
201
+ return { x: centerX, y: rect.y + rect.height };
202
+
203
+ case 'left':
204
+ return { x: rect.x, y: centerY };
205
+
206
+ default:
207
+ return null;
208
+ }
209
+ }
210
+ `.trim();function pf(t){return!!_f(t)}function _f(t){let i=t,e=i?.Blob,n=i?.Worker,o=i?.URL;return!e||!n||typeof o?.createObjectURL!="function"||typeof o.revokeObjectURL!="function"?null:{blobCtor:e,workerCtor:n,urlApi:o}}function q_(t){let i=new t.blobCtor([Y_],{type:"text/javascript"});return t.urlApi.createObjectURL(i)}function mf(t,i){if(!t)return;let e=i??(typeof URL>"u"?null:URL);typeof e?.revokeObjectURL=="function"&&e.revokeObjectURL(t)}var Vt=(()=>{class t{worker=null;workerUrl=null;nextRequestId=0;isDisabled=!1;pending=new Map;resetRuntime(e){this.pending.forEach(n=>n.reject(e)),this.pending.clear(),this.worker?.terminate(),this.worker=null,mf(this.workerUrl),this.workerUrl=null}dispose(){this.resetRuntime(new Error("Connection worker was destroyed."))}static \u0275fac=function(n){return new(n||t)};static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})(),Ia=class{connection;line;static fToken=Symbol("ApplyConnectionRenderRequest");constructor(i,e){this.connection=i,this.line=e}},X_=(()=>{let t=class uo{_mediator=d(b);_renderCache=new WeakMap;handle({connection:e,line:n}){!this._mediator.execute(new on(e))&&!this._shouldRender(e,n)||(e.setLine(n),e.initialize())}_shouldRender(e,n){let o=e.fPath().hostElement,r=this._createConnectionRenderSignature(e,n),s=this._renderCache.get(e);return s?.signature===r&&s.pathElement===o?!1:(this._renderCache.set(e,{signature:r,pathElement:o}),!0)}_createConnectionRenderSignature(e,n){let{sourceSide:o,targetSide:r}=e.getResolvedSides();return[e.fBehavior,e.fType,e.fRadius,e.fOffset,e.fReassignableStart(),this._serializeContents([...e.fContents()||[]]),o,r,this._serializePoint(n.point1),this._serializePoint(n.point2),this._serializeWaypoints(e.fWaypoints()?.waypoints()||[])].join("|")}_serializePoint(e){return`${e.x}:${e.y}`}_serializeWaypoints(e){return e.map(this._serializePoint).join(";")}_serializeContents(e){return e.map(n=>[n.position(),n.offset(),n.align()].join(":")).join(";")}static \u0275fac=function(n){return new(n||uo)};static \u0275prov=f({token:uo,factory:uo.\u0275fac})};return t=p([_(Ia)],t),t})(),Sa=class{source;target;static fToken=Symbol("MarkConnectionConnectorsAsConnectedRequest");constructor(i,e){this.source=i,this.target=e}},K_=(()=>{let t=class ho{_state=d(zd);handle({source:e,target:n}){e.setConnected(n),n.setConnected(e),this._state.trackConnectedConnectors(e,n)}static \u0275fac=function(n){return new(n||ho)};static \u0275prov=f({token:ho,factory:ho.\u0275fac})};return t=p([_(Sa)],t),t})(),yt=class{element;cache;static fToken=Symbol("GetNormalizedConnectorRectRequest");constructor(i,e=!0){this.element=i,this.cache=e}},Z_={enabled:!1},Qe=new X("F_CACHE_OPTIONS",{providedIn:"root",factory:()=>W({},Z_)});var Ea=class{id;nodeId;kind;element;static fToken=Symbol("RegisterFCacheConnectorRequest");constructor(i,e,n,o){this.id=i,this.nodeId=e,this.kind=n,this.element=o}},Je=(()=>{class t{nodeEntries=new Map;nodeIdByElement=new WeakMap;connectorEntries=new Map;connectorKeysByNodeId=new Map;connectorKeyByElement=new WeakMap;static \u0275fac=function(n){return new(n||t)};static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})(),Wl=class{key;id;kind;nodeId;element;rect;constructor(i,e,n,o,r,s){this.key=i,this.id=e,this.kind=n,this.nodeId=o,this.element=r,this.rect=s}},kn=class{static build(i,e){return`${i}:${e}`}},$l=class{id;element;reference;rect;constructor(i,e,n,o){this.id=i,this.element=e,this.reference=n,this.rect=o}},rn=class{nodeId;reason;static fToken=Symbol("InvalidateFCacheNodeRequest");constructor(i,e="manual"){this.nodeId=i,this.reason=e}},Q_=(()=>{let t=class fo{_store=d(Je);_options=d(Qe);handle({nodeId:e,reason:n}){if(!this._options.enabled)return;let o=this._store.nodeEntries.get(e);if(!o)return;o.rect=void 0;let r=this._store.connectorKeysByNodeId.get(e);if(r?.size)for(let s of r){let a=this._store.connectorEntries.get(s);a&&(a.rect=void 0)}}static \u0275fac=function(n){return new(n||fo)};static \u0275prov=f({token:fo,factory:fo.\u0275fac})};return t=p([_(rn)],t),t})(),Da=class{id;element;reference;static fToken=Symbol("RegisterFCacheNodeRequest");constructor(i,e,n){this.id=i,this.element=e,this.reference=n}},J_=(()=>{let t=class go{_store=d(Je);_options=d(Qe);handle({id:e,element:n,reference:o}){if(!this._options.enabled)return;let r=new $l(e,n,o);this._store.nodeEntries.set(e,r),this._store.nodeIdByElement.set(n,e),this._store.connectorKeysByNodeId.set(e,this._store.connectorKeysByNodeId.get(e)??new Set)}static \u0275fac=function(n){return new(n||go)};static \u0275prov=f({token:go,factory:go.\u0275fac})};return t=p([_(Da)],t),t})(),Ta=class{id;static fToken=Symbol("UnregisterFCacheNodeRequest");constructor(i){this.id=i}},em=(()=>{let t=class po{_store=d(Je);_mediator=d(b);_options=d(Qe);handle({id:e}){if(!this._options.enabled)return;let n=this._store.nodeEntries.get(e);if(!n)return;this._store.nodeEntries.delete(e),this._store.nodeIdByElement.delete(n.element);let o=Array.from(this._store.connectorKeysByNodeId.get(e)??[]);for(let r of o){let s=this._store.connectorEntries.get(r);s&&this._mediator.execute(new On(s.id,s.kind))}this._store.connectorKeysByNodeId.delete(e)}static \u0275fac=function(n){return new(n||po)};static \u0275prov=f({token:po,factory:po.\u0275fac})};return t=p([_(Ta)],t),t})(),tm=(()=>{let t=class _o{_store=d(Je);_mediator=d(b);_options=d(Qe);handle({id:e,nodeId:n,kind:o,element:r}){if(!this._options.enabled)return;let s=kn.build(e,o),a=this._store.connectorEntries.get(s);a&&(this._detachConnectorFromNode(a.key,a.nodeId),this._store.connectorKeyByElement.delete(a.element));let c=new Wl(s,e,o,n,r);this._store.connectorEntries.set(s,c),this._store.connectorKeyByElement.set(r,s);let l=this._store.connectorKeysByNodeId.get(n)??new Set;l.add(s),this._store.connectorKeysByNodeId.set(n,l),this._mediator.execute(new rn(n,"connector-registered"))}_detachConnectorFromNode(e,n){let o=this._store.connectorKeysByNodeId.get(n);o&&(o.delete(e),o.size||this._store.connectorKeysByNodeId.delete(n))}static \u0275fac=function(n){return new(n||_o)};static \u0275prov=f({token:_o,factory:_o.\u0275fac})};return t=p([_(Ea)],t),t})(),On=class{connectorId;kind;static fToken=Symbol("UnregisterFCacheConnectorRequest");constructor(i,e){this.connectorId=i,this.kind=e}},nm=(()=>{let t=class mo{_store=d(Je);_mediator=d(b);_options=d(Qe);handle({connectorId:e,kind:n}){if(!this._options.enabled)return;let o=kn.build(e,n),r=this._store.connectorEntries.get(o);r&&(this._store.connectorEntries.delete(o),this._store.connectorKeyByElement.delete(r.element),this._detachConnectorFromNode(o,r.nodeId),this._store.nodeEntries.has(r.nodeId)&&this._mediator.execute(new rn(r.nodeId,"connector-unregistered")))}_detachConnectorFromNode(e,n){let o=this._store.connectorKeysByNodeId.get(n);o&&(o.delete(e),o.size||this._store.connectorKeysByNodeId.delete(n))}static \u0275fac=function(n){return new(n||mo)};static \u0275prov=f({token:mo,factory:mo.\u0275fac})};return t=p([_(On)],t),t})(),sn=class{element;static fToken=Symbol("GetCachedFCacheRectRequest");constructor(i){this.element=i}},im=(()=>{let t=class yo{_store=d(Je);_options=d(Qe);handle({element:e}){if(!this._options.enabled)return;let n=this._store.nodeIdByElement.get(e);if(n){let r=this._store.nodeEntries.get(n)?.rect;if(r)return r}let o=this._store.connectorKeyByElement.get(e);if(o)return this._store.connectorEntries.get(o)?.rect??void 0}static \u0275fac=function(n){return new(n||yo)};static \u0275prov=f({token:yo,factory:yo.\u0275fac})};return t=p([_(sn)],t),t})(),At=class{connectorId;kind;rect;static fToken=Symbol("SetFCacheConnectorRectRequest");constructor(i,e,n){this.connectorId=i,this.kind=e,this.rect=n}},om=(()=>{let t=class vo{_store=d(Je);_options=d(Qe);handle({connectorId:e,kind:n,rect:o}){if(!this._options.enabled)return;let r=kn.build(e,n),s=this._store.connectorEntries.get(r);s&&(s.rect=ae.fromRoundedRect(o))}static \u0275fac=function(n){return new(n||vo)};static \u0275prov=f({token:vo,factory:vo.\u0275fac})};return t=p([_(At)],t),t})(),Lt=class{nodeId;rect;static fToken=Symbol("SetFCacheNodeRectRequest");constructor(i,e){this.nodeId=i,this.rect=e}},rm=(()=>{let t=class Co{_store=d(Je);_options=d(Qe);handle({nodeId:e,rect:n}){if(!this._options.enabled)return;let o=this._store.nodeEntries.get(e);if(!o)return;let r=o.rect;o.rect=A.initialize(n.x,n.y,n.width,n.height),r&&this._updateConnectorRectsByNodeRect(e,r,o.rect)}_updateConnectorRectsByNodeRect(e,n,o){let r=this._store.connectorKeysByNodeId.get(e);if(!r?.size)return;let s=o.x-n.x,a=o.y-n.y,c=n.width!==0,l=n.height!==0,u=c?o.width/n.width:1,h=l?o.height/n.height:1;for(let v of r){let w=this._store.connectorEntries.get(v);if(!w?.rect)continue;let S=w.rect,P=S.gravityCenter,L=c?o.x+(P.x-n.x)*u:P.x+s,M=l?o.y+(P.y-n.y)*h:P.y+a;w.rect=new ae(L-S.width/2,M-S.height/2,S.width,S.height,S.radius1,S.radius2,S.radius3,S.radius4)}}static \u0275fac=function(n){return new(n||Co)};static \u0275prov=f({token:Co,factory:Co.\u0275fac})};return t=p([_(Lt)],t),t})(),Fn=class{element;rect;static fToken=Symbol("UpdateFCacheRectByElementRequest");constructor(i,e){this.element=i,this.rect=e}},sm=(()=>{let t=class wo{_store=d(Je);_options=d(Qe);handle({element:e,rect:n}){if(!this._options.enabled)return;let o=this._store.nodeIdByElement.get(e);if(o){let a=this._store.nodeEntries.get(o);a&&(a.rect=n);return}let r=this._store.connectorKeyByElement.get(e);if(!r)return;let s=this._store.connectorEntries.get(r);s&&(s.rect=n)}static \u0275fac=function(n){return new(n||wo)};static \u0275prov=f({token:wo,factory:wo.\u0275fac})};return t=p([_(Fn)],t),t})(),am=[Je,J_,em,Q_,tm,nm,im,rm,om,sm];function mn(t,i,e){return i?B.fromPoint(t).elementTransform(i).sub(e.scaledPosition).sub(e.position).div(e.scale):B.fromPoint(t)}function yf(){return{min:{x:-1/0,y:-1/0},max:{x:1/0,y:1/0}}}function an(t){return t?`${t}`:void 0}var cm=(()=>{let t=class bo{_store=d(C);_mediator=d(b);_browser=d(ce);get _transform(){return this._store.transform}handle({element:e,cache:n}){let o=this._mediator.execute(new sn(e));if(o&&n)return o;let r=this._getElementRoundedRect(e),s=this._normalizePosition(r),a=this._unscaleSize(r),c=this._getUnscaledRect(s,a,r),l=this._getOffsetSize(e,a),u=ae.fromCenter(c,l.width,l.height);return this._mediator.execute(new Fn(e,u)),u}_getElementRoundedRect(e){return this._getRoundedRect(A.fromElement(e),e,this._getComputedStyle(e))}_getRoundedRect(e,n,o){let[r,s,a,c]=this._normalizeCircularBorderRadii(e.width,e.height,[this._getSystemRadius(o.borderTopLeftRadius,n,o.fontSize),this._getSystemRadius(o.borderTopRightRadius,n,o.fontSize),this._getSystemRadius(o.borderBottomRightRadius,n,o.fontSize),this._getSystemRadius(o.borderBottomLeftRadius,n,o.fontSize)]);return new ae(e.x,e.y,e.width,e.height,r,s,a,c)}_getComputedStyle(e){return this._browser.window.getComputedStyle(e)}_toPixels(e,n,o){return this._browser.toPixels(e,n.clientWidth,n.clientHeight,o)||0}_getSystemRadius(e,n,o){return this._toPixels(e,n,o)*this._transform.scale}_normalizeCircularBorderRadii(e,n,o){let[r,s,a,c]=o.map(u=>Math.max(0,u)),l=Math.min(1,this._getRadiusScaleFactor(e,r+s),this._getRadiusScaleFactor(n,s+a),this._getRadiusScaleFactor(e,a+c),this._getRadiusScaleFactor(n,c+r));return[r*l,s*l,a*l,c*l]}_getRadiusScaleFactor(e,n){return n<=0?1:e<=0?0:e/n}_normalizePosition(e){return mn(e,this._store.flowHost,this._transform)}_unscaleSize(e){return Ge.initialize(e.width/this._transform.scale,e.height/this._transform.scale)}_getUnscaledRect(e,n,o){return new ae(e.x,e.y,n.width,n.height,this._unscaleRadius(o.radius1),this._unscaleRadius(o.radius2),this._unscaleRadius(o.radius3),this._unscaleRadius(o.radius4))}_unscaleRadius(e){return e/this._transform.scale}_getOffsetSize(e,n){return Ge.offsetFromElement(e)||n}static \u0275fac=function(n){return new(n||bo)};static \u0275prov=f({token:bo,factory:bo.\u0275fac})};return t=p([_(yt)],t),t})(),Pa=class{connector;cache;static fToken=Symbol("ResolveConnectionEndpointRectRequest");constructor(i,e){this.connector=i,this.cache=e}},dm=(()=>{let t=class xo{_mediator=d(b);handle({connector:e,cache:n}){let o=this._buildCacheKey(e),r=n.get(o)??this._calculateRect(e);return n.set(o,r),r}_buildCacheKey(e){return`${e.kind}::${e.fId()}`}_calculateRect(e){return this._mediator.execute(new yt(e.hostElement))}static \u0275fac=function(n){return new(n||xo)};static \u0275prov=f({token:xo,factory:xo.\u0275fac})};return t=p([_(Pa)],t),t})(),Ma=class{connection;static fToken=Symbol("ResolveConnectionEndpointsRequest");constructor(i){this.connection=i}},lm=(()=>{let t=class Io{_store=d(C);handle({connection:e}){let n=this._store.outputs.get(e.fOutputId()),o=this._store.inputs.get(e.fInputId());return!n||!o?null:{source:n,target:o}}static \u0275fac=function(n){return new(n||Io)};static \u0275prov=f({token:Io,factory:Io.\u0275fac})};return t=p([_(Ma)],t),t})(),An=class{connection;cache;static fToken=Symbol("ResolveConnectionGeometryRequest");constructor(i,e){this.connection=i,this.cache=e}},um=(()=>{let t=class So{_mediator=d(b);handle({connection:e,cache:n}){let o=this._resolveConnectionEndpoints(e);return o?nl(W({},o),{sourceRect:this._resolveEndpointRect(o.source,n),targetRect:this._resolveEndpointRect(o.target,n)}):null}_resolveConnectionEndpoints(e){return this._mediator.execute(new Ma(e))}_resolveEndpointRect(e,n){return this._mediator.execute(new Pa(e,n))}static \u0275fac=function(n){return new(n||So)};static \u0275prov=f({token:So,factory:So.\u0275fac})};return t=p([_(An)],t),t})(),ie=class{element;static fToken=Symbol("GetNormalizedElementRectRequest");constructor(i){this.element=i}},hm=(()=>{let t=class Eo{_store=d(C);_mediator=d(b);get _transform(){return this._store.transform}handle({element:e}){let n=this._mediator.execute(new sn(e));if(n)return n;let o=A.fromElement(e),r=this._normalizePosition(o),s=this._unscaleSize(o),a=this._getUnscaledRect(r,s),c=this._getOffsetSize(e,s),l=this._fromCenter(a,c.width,c.height);return this._mediator.execute(new Fn(e,l)),l}_fromCenter(e,n,o){return A.initialize(e.gravityCenter.x-n/2,e.gravityCenter.y-o/2,n,o)}_normalizePosition(e){return mn(e,this._store.flowHost,this._transform)}_unscaleSize(e){return Ge.initialize(e.width/this._transform.scale,e.height/this._transform.scale)}_getUnscaledRect(e,n){return new ae(e.x,e.y,n.width,n.height)}_getOffsetSize(e,n){return Ge.offsetFromElement(e)||n}static \u0275fac=function(n){return new(n||Eo)};static \u0275prov=f({token:Eo,factory:Eo.\u0275fac})};return t=p([_(ie)],t),t})(),ct=class{connector;static fToken=Symbol("ResolveConnectionEndpointRotationContextRequest");constructor(i){this.connector=i}},fm=(()=>{let t=class Do{_store=d(C);_mediator=d(b);handle({connector:e}){if(!e)return;let n=this._store.nodes.get(e.fNodeId);if(!n||!n._rotate)return;let o=this._mediator.execute(new ie(n.hostElement));return{rotationDeg:n._rotate,pivot:o.gravityCenter}}static \u0275fac=function(n){return new(n||Do)};static \u0275prov=f({token:Do,factory:Do.\u0275fac})};return t=p([_(ct)],t),t})(),Ra=class{connection;geometry;static fToken=Symbol("BuildConnectionLineRequest");constructor(i,e){this.connection=i,this.geometry=e}},gm=(()=>{let t=class To{_mediator=d(b);_connectionBehaviour=d(_n);handle({connection:e,geometry:n}){return this._connectionBehaviour.handle(new He(n.sourceRect,n.targetRect,e,n.source.fConnectableSide,n.target.fConnectableSide,this._resolveRotationContext(n.source),this._resolveRotationContext(n.target)))}_resolveRotationContext(e){return this._mediator.execute(new ct(e))}static \u0275fac=function(n){return new(n||To)};static \u0275prov=f({token:To,factory:To.\u0275fac})};return t=p([_(Ra)],t),t})(),Ln=class{connection;source;target;line;static fToken=Symbol("RenderConnectionWithLineRequest");constructor(i,e,n,o){this.connection=i,this.source=e,this.target=n,this.line=o}},pm=(()=>{let t=class Po{_mediator=d(b);handle({connection:e,source:n,target:o,line:r}){this._mediator.execute(new Sa(n,o)),this._mediator.execute(new Ia(e,r))}static \u0275fac=function(n){return new(n||Po)};static \u0275prov=f({token:Po,factory:Po.\u0275fac})};return t=p([_(Ln)],t),t})(),zn=class{connection;geometry;static fToken=Symbol("RenderConnectionFromGeometryRequest");constructor(i,e){this.connection=i,this.geometry=e}},_m=(()=>{let t=class Mo{_mediator=d(b);handle({connection:e,geometry:n}){let o=this._mediator.execute(new Ra(e,n));this._mediator.execute(new Ln(e,n.source,n.target,o))}static \u0275fac=function(n){return new(n||Mo)};static \u0275prov=f({token:Mo,factory:Mo.\u0275fac})};return t=p([_(zn)],t),t})(),Na=class{connection;cache;static fToken=Symbol("RenderConnectionRequest");constructor(i,e){this.connection=i,this.cache=e}},mm=(()=>{let t=class Ro{_mediator=d(b);handle({connection:e,cache:n}){let o=this._mediator.execute(new An(e,n));o&&this._mediator.execute(new zn(e,o))}static \u0275fac=function(n){return new(n||Ro)};static \u0275prov=f({token:Ro,factory:Ro.\u0275fac})};return t=p([_(Na)],t),t})(),zt=class{session;static fToken=Symbol("IsConnectionRedrawCurrentRequest");constructor(i){this.session=i}},ym=(()=>{let t=class No{_store=d(C);_state=d(zd);handle({session:e}){return e.renderTicket===this._state.renderTicket&&e.nodesRevision===this._store.nodesRevision}static \u0275fac=function(n){return new(n||No)};static \u0275prov=f({token:No,factory:No.\u0275fac})};return t=p([_(zt)],t),t})(),Bn=class{session;static fToken=Symbol("CompleteConnectionRedrawRequest");constructor(i){this.session=i}},vm=(()=>{let t=class ko{_mediator=d(b);_store=d(C);handle({session:e}){this._mediator.execute(new zt(e))&&this._store.completeConnectionsRender(e.connectionsRevision,e.nodesRevision)}static \u0275fac=function(n){return new(n||ko)};static \u0275prov=f({token:ko,factory:ko.\u0275fac})};return t=p([_(Bn)],t),t})(),ka=class{batchItem;result;static fToken=Symbol("ApplyConnectionWorkerResultRequest");constructor(i,e){this.batchItem=i,this.result=e}},Cm=(()=>{let t=class Oo{_mediator=d(b);handle({batchItem:e,result:n}){if(e){if(!this._isSupportedWorkerResult(n)){this._fallbackToMainThread(e);return}try{e.connection._applyResolvedSidesToConnection(n.sourceSide,n.targetSide),this._mediator.execute(new Ln(e.connection,e.geometry.source,e.geometry.target,n.line))}catch{this._fallbackToMainThread(e)}}}_fallbackToMainThread(e){this._mediator.execute(new zn(e.connection,e.geometry))}_isSupportedWorkerResult(e){return!!(e?.supported&&e.sourceSide&&e.targetSide&&e.line)}static \u0275fac=function(n){return new(n||Oo)};static \u0275prov=f({token:Oo,factory:Oo.\u0275fac})};return t=p([_(ka)],t),t})(),_t=class{connections;cache;startIndex;session;batchItems;workerResults;static fToken=Symbol("RunConnectionRedrawSliceRequest");constructor(i,e,n,o,r,s){this.connections=i,this.cache=e,this.startIndex=n,this.session=o,this.batchItems=r,this.workerResults=s}},wm=500,bm=6,xm=(()=>{let t=class Fo{_mediator=d(b);_browser=d(ce);handle({connections:e,cache:n,startIndex:o,session:r,batchItems:s,workerResults:a}){if(!this._isCurrent(r))return;let c=this._now(),l=o,u=0;for(;l<e.length&&u<wm&&this._isWithinSliceBudget(c);){let h=e[l];if(s?this._mediator.execute(new ka(s[l]??null,a?.[l])):this._mediator.execute(new Na(h,n)),l++,u++,!this._isCurrent(r))return}if(l>=e.length){this._mediator.execute(new Bn(r));return}this._requestAnimationFrame(()=>this._mediator.execute(new _t(e,n,l,r,s,a)))}_isCurrent(e){return this._mediator.execute(new zt(e))}_requestAnimationFrame(e){let n=this._browser.document.defaultView;if(!n){e();return}n.requestAnimationFrame(e)}_now(){let e=this._browser.document.defaultView?.performance;return e?e.now():Date.now()}_isWithinSliceBudget(e){return this._browser.isBrowser()?this._now()-e<bm:!0}static \u0275fac=function(n){return new(n||Fo)};static \u0275prov=f({token:Fo,factory:Fo.\u0275fac})};return t=p([_(_t)],t),t})(),Oa=class{static fToken=Symbol("StartConnectionRedrawRequest")},Im=(()=>{let t=class Ao{_store=d(C);_state=d(zd);handle(e){return this._state.resetConnectedConnectors(),{renderTicket:this._state.beginRender(),connectionsRevision:this._store.connectionsRevision,nodesRevision:this._store.nodesRevision}}static \u0275fac=function(n){return new(n||Ao)};static \u0275prov=f({token:Ao,factory:Ao.\u0275fac})};return t=p([_(Oa)],t),t})(),Gn=class{static fToken=Symbol("RedrawConnectionsRequest")},Fa=class{connectionCount;static fToken=Symbol("ShouldUseConnectionWorkerRequest");constructor(i){this.connectionCount=i}},jn=class{static fToken=Symbol("IsConnectionWorkerEnabledRequest")},Sm=(()=>{let t=class Lo{_browser=d(ce);_state=d(Vt);handle(e){if(this._state.isDisabled||!this._isWorkerAvailable())return!1;let n=this._browser.document.defaultView;return pf(n)}_isWorkerAvailable(){return this._browser.isBrowser()}static \u0275fac=function(n){return new(n||Lo)};static \u0275prov=f({token:Lo,factory:Lo.\u0275fac})};return t=p([_(jn)],t),t})(),Em=(()=>{let t=class zo{_mediator=d(b);handle({connectionCount:e}){return e>0&&this._mediator.execute(new jn)}static \u0275fac=function(n){return new(n||zo)};static \u0275prov=f({token:zo,factory:zo.\u0275fac})};return t=p([_(Fa)],t),t})(),Aa=class{connection;geometry;originalIndex;static fToken=Symbol("BuildConnectionWorkerPayloadItemRequest");constructor(i,e,n){this.connection=i,this.geometry=e,this.originalIndex=n}},Dm=(()=>{let t=class Bo{_store=d(C);handle({connection:e,geometry:n,originalIndex:o}){let{source:r,target:s,sourceRect:a,targetRect:c}=n;return{originalIndex:o,behavior:e.fBehavior,outputSide:e.fOutputSide(),inputSide:e.fInputSide(),sourceConnectableSide:r.fConnectableSide,targetConnectableSide:s.fConnectableSide,sourceRotation:this._store.nodes.get(r.fNodeId)?._rotate||0,targetRotation:this._store.nodes.get(s.fNodeId)?._rotate||0,sourceRect:{x:a.x,y:a.y,width:a.width,height:a.height,radius1:a.radius1,radius2:a.radius2,radius3:a.radius3,radius4:a.radius4},targetRect:{x:c.x,y:c.y,width:c.width,height:c.height,radius1:c.radius1,radius2:c.radius2,radius3:c.radius3,radius4:c.radius4}}}static \u0275fac=function(n){return new(n||Bo)};static \u0275prov=f({token:Bo,factory:Bo.\u0275fac})};return t=p([_(Aa)],t),t})(),La=class{connections;cache;static fToken=Symbol("BuildConnectionWorkerBatchRequest");constructor(i,e){this.connections=i,this.cache=e}},Tm=(()=>{let t=class Go{_mediator=d(b);handle({connections:e,cache:n}){let o=new Array(e.length),r=[];for(let s=0;s<e.length;s++){let a=this._buildBatchItem(e[s],n,s);o[s]=a,a&&r.push(a.payload)}return{items:o,payload:r}}_buildBatchItem(e,n,o){let r=this._mediator.execute(new An(e,n));return r?{connection:e,geometry:r,payload:this._mediator.execute(new Aa(e,r,o))}:null}static \u0275fac=function(n){return new(n||Go)};static \u0275prov=f({token:Go,factory:Go.\u0275fac})};return t=p([_(La)],t),t})(),za=class{error;static fToken=Symbol("DisableConnectionWorkerRequest");constructor(i){this.error=i}},Hn=class{error;static fToken=Symbol("ResetConnectionWorkerRuntimeRequest");constructor(i){this.error=i}},Pm=(()=>{let t=class jo{_state=d(Vt);handle({error:e}){this._state.resetRuntime(e)}static \u0275fac=function(n){return new(n||jo)};static \u0275prov=f({token:jo,factory:jo.\u0275fac})};return t=p([_(Hn)],t),t})(),Mm=(()=>{let t=class Ho{_state=d(Vt);_mediator=d(b);handle({error:e}){this._state.isDisabled=!0,this._mediator.execute(new Hn(e))}static \u0275fac=function(n){return new(n||Ho)};static \u0275prov=f({token:Ho,factory:Ho.\u0275fac})};return t=p([_(za)],t),t})(),Ba=class{message;static fToken=Symbol("HandleConnectionWorkerMessageRequest");constructor(i){this.message=i}},Rm=(()=>{let t=class Vo{_state=d(Vt);handle({message:e}){if(!e||typeof e.requestId!="number")return;let n=this._state.pending.get(e.requestId);if(n){if(this._state.pending.delete(e.requestId),e.error){n.reject(new Error(e.error));return}n.resolve(e.results??[])}}static \u0275fac=function(n){return new(n||Vo)};static \u0275prov=f({token:Vo,factory:Vo.\u0275fac})};return t=p([_(Ba)],t),t})(),Ga=class{static fToken=Symbol("EnsureConnectionWorkerRequest")},Nm=(()=>{let t=class Uo{_browser=d(ce);_state=d(Vt);_mediator=d(b);handle(e){if(this._state.worker)return this._state.worker;let n=this._browser.document.defaultView;if(!pf(n))return null;let o=_f(n);if(!o)return null;let r=q_(o);try{let s=new o.workerCtor(r,{name:"f-flow-connection-worker"});return s.onmessage=a=>{this._mediator.execute(new Ba(a.data))},s.onerror=()=>{this._resetWorkerAfterRuntimeError(new Error("Connection worker runtime error."))},s.onmessageerror=()=>{this._resetWorkerAfterRuntimeError(new Error("Connection worker message deserialization error."))},this._state.workerUrl=r,this._state.worker=s,s}catch(s){return mf(r,o.urlApi),this._disableWorker(s instanceof Error?s:new Error("Connection worker initialization failed.")),null}}_disableWorker(e){this._mediator.execute(new za(e))}_resetWorkerAfterRuntimeError(e){this._mediator.execute(new Hn(e))}static \u0275fac=function(n){return new(n||Uo)};static \u0275prov=f({token:Uo,factory:Uo.\u0275fac})};return t=p([_(Ga)],t),t})(),ja=class{payload;static fToken=Symbol("RunConnectionWorkerRequest");constructor(i){this.payload=i}},km=(()=>{let t=class Wo{_state=d(Vt);_mediator=d(b);handle({payload:e}){if(!e.length)return Promise.resolve([]);if(!this._mediator.execute(new jn))return Promise.reject(new Error("Connection worker is disabled."));this._interruptPendingRequests();let n=this._mediator.execute(new Ga);if(!n)return Promise.reject(new Error("Unable to initialize connection worker."));let o=++this._state.nextRequestId;return new Promise((r,s)=>{this._state.pending.set(o,{resolve:r,reject:s});try{n.postMessage({requestId:o,items:e})}catch(a){this._state.pending.delete(o),s(a instanceof Error?a:new Error("Unknown error while posting message to connection worker."))}})}_interruptPendingRequests(){if(!this._state.pending.size)return;let e=new Error("Connection worker request was superseded by a newer redraw.");this._state.pending.forEach(n=>n.reject(e)),this._state.pending.clear()}static \u0275fac=function(n){return new(n||Wo)};static \u0275prov=f({token:Wo,factory:Wo.\u0275fac})};return t=p([_(ja)],t),t})(),Ha=class{batch;static fToken=Symbol("RunConnectionWorkerBatchRequest");constructor(i){this.batch=i}},Om=(()=>{let t=class $o{_mediator=d(b);handle({batch:e}){return e.payload.length?this._mediator.execute(new ja(e.payload)):Promise.resolve([])}static \u0275fac=function(n){return new(n||$o)};static \u0275prov=f({token:$o,factory:$o.\u0275fac})};return t=p([_(Ha)],t),t})(),Va=class{connections;cache;session;static fToken=Symbol("StartConnectionWorkerRedrawRequest");constructor(i,e,n){this.connections=i,this.cache=e,this.session=n}},Fm=(()=>{let t=class Yo{_mediator=d(b);handle({connections:e,cache:n,session:o}){let r=this._mediator.execute(new La(e,n));if(!r.payload.length){this._mediator.execute(new _t(e,n,0,o,r.items));return}this._mediator.execute(new Ha(r)).then(s=>{this._mediator.execute(new zt(o))&&this._mediator.execute(new _t(e,n,0,o,r.items,this._alignWorkerResults(s,e.length)))}).catch(()=>{this._mediator.execute(new zt(o))&&this._mediator.execute(new _t(e,n,0,o,r.items))})}_alignWorkerResults(e,n){let o=new Array(n);for(let r of e){let s=r.originalIndex;s<0||s>=n||(o[s]=r)}return o}static \u0275fac=function(n){return new(n||Yo)};static \u0275prov=f({token:Yo,factory:Yo.\u0275fac})};return t=p([_(Va)],t),t})(),Am=(()=>{let t=class qo{_mediator=d(b);_store=d(C);handle(e){let n=this._mediator.execute(new Oa);this._createMarkersForCreate(),this._createMarkersForSnap();let o=[...this._store.connections.getAll()],r=new Map;if(!o.length){this._mediator.execute(new Bn(n));return}this._shouldUseConnectionWorker(o.length)?this._redrawUsingWorker(o,r,n):this._redrawWithoutWorker(o,r,n)}_createMarkersForCreate(){let e=this._store.connections.getForCreate();e&&this._mediator.execute(new on(e))}_createMarkersForSnap(){let e=this._store.connections.getForSnap();e&&this._mediator.execute(new on(e))}_shouldUseConnectionWorker(e){return this._mediator.execute(new Fa(e))}_redrawUsingWorker(e,n,o){this._mediator.execute(new Va(e,n,o))}_redrawWithoutWorker(e,n,o){this._mediator.execute(new _t(e,n,0,o))}static \u0275fac=function(n){return new(n||qo)};static \u0275prov=f({token:qo,factory:qo.\u0275fac})};return t=p([_(Gn)],t),t})(),Yl=class{static fToken=Symbol("RemoveConnectionForCreateFromStoreRequest")},Lm=(()=>{let t=class Xo{_store=d(C);handle(e){this._store.connections.removeInstanceForCreate()}static \u0275fac=function(n){return new(n||Xo)};static \u0275prov=f({token:Xo,factory:Xo.\u0275fac})};return t=p([_(Yl)],t),t})(),Ua=class{connection;static fToken=Symbol("RemoveConnectionFromStoreRequest");constructor(i){this.connection=i}},zm=(()=>{let t=class Ko{_store=d(C);handle({connection:e}){this._store.connections.remove(e),this._store.emitConnectionChanges()}static \u0275fac=function(n){return new(n||Ko)};static \u0275prov=f({token:Ko,factory:Ko.\u0275fac})};return t=p([_(Ua)],t),t})(),ql=class{instance;static fToken=Symbol("RemoveConnectionMarkerFromStoreRequest");constructor(i){this.instance=i}},Bm=(()=>{let t=class Zo{_store=d(C);handle({instance:e}){this._store.connectionMarkers.remove(e),this._store.emitNodeChanges()}static \u0275fac=function(n){return new(n||Zo)};static \u0275prov=f({token:Zo,factory:Zo.\u0275fac})};return t=p([_(ql)],t),t})(),Xl=class{waypointIndex;connectionId;static fToken=Symbol("RemoveConnectionWaypointRequest");constructor(i,e){this.waypointIndex=i,this.connectionId=e}},Wa=class{static fToken=Symbol("EmitEndDragSequenceEventRequest")},Gm=(()=>{let t=class Qo{_store=d(C);_dragSession=d(G);handle(e){this._store.flowHost.classList.remove(pe.DRAG_AND_DROP.DRAGGING),this._dragSession.reset(),this._emitEvent()}_emitEvent(){this._store.fDraggable?.fDragEnded?.emit()}static \u0275fac=function(n){return new(n||Qo)};static \u0275prov=f({token:Qo,factory:Qo.\u0275fac})};return t=p([_(Wa)],t),t})(),$a=class{static fToken=Symbol("EmitStartDragSequenceEventRequest")},jm=(()=>{let t=class Jo{_mediator=d(b);_store=d(C);_dragContext=d(G);handle(e){this._dragContext.draggableItems.length>0&&(this._store.flowHost.classList.add(pe.DRAG_AND_DROP.DRAGGING),this._mediator.execute(new Vn),this._emitDragStarted())}_emitDragStarted(){let e=this._dragContext.draggableItems[0].getEvent();this._store.fDraggable?.fDragStarted?.emit(new Qa(e.kind,e.data?W({},e.data):void 0,e.fEventType))}static \u0275fac=function(n){return new(n||Jo)};static \u0275prov=f({token:Jo,factory:Jo.\u0275fac})};return t=p([_($a)],t),t})(),Vn=class{static fToken=Symbol("EmitSelectionChangeEventRequest")},Bt=class{_event;_target;get originalEvent(){return this._event}get targetElement(){return this._target||this.originalEvent.target}get touchEvent(){return this._event}get touches(){return this.touchEvent.touches}constructor(i,e){this._event=i,this._target=e}setTarget(i){this._target=i}preventDefault(){this.originalEvent.preventDefault()}get isEventInLockedContext(){return this.targetElement.closest("[fLockedContext]")!==null}},Ya=class extends Bt{constructor(i,e){super(i,e)}isMouseLeftButton(){return this.originalEvent.button===0}isMouseRightButton(){return this.originalEvent.buttons===2}getPosition(){return{x:this.originalEvent.clientX,y:this.originalEvent.clientY}}},Kl=class extends Bt{constructor(i,e){super(i,e)}isMouseLeftButton(){let i=this.originalEvent;return i.pointerType==="mouse"&&i.button===0||i.pointerType==="touch"}isMouseRightButton(){let i=this.originalEvent;return i.pointerType==="mouse"&&i.button===2||i.pointerType==="touch"}getPosition(){let i=this.originalEvent;return{x:i.clientX,y:i.clientY}}getPointerType(){return this.originalEvent.pointerType}getPointerId(){return this.originalEvent.pointerId}},Zl=class extends Bt{constructor(i){super(i)}isMouseLeftButton(){return!0}isMouseRightButton(){return!1}getPosition(){let i=this.originalEvent.touches;return{x:i[0].clientX,y:i[0].clientY}}},Ql=class extends Bt{constructor(i,e){super(i,e)}isMouseLeftButton(){return!0}isMouseRightButton(){return!1}getPosition(){let i=this.originalEvent.targetTouches[0];return{x:i.clientX,y:i.clientY}}},Y=(()=>{class t{static _isSupported;static _isPassiveEventListenerSupported(){if(t._isSupported==null&&typeof window<"u")try{window.addEventListener("test",t.emptyListener,{passive:!0}),t._isSupported=!0}catch{t._isSupported=!1}return t._isSupported}static _passiveEventListener(e){return t._isPassiveEventListenerSupported()?e:!!e.capture}static activeListener(){return t._passiveEventListener({passive:!1})}static passiveListener(){return t._passiveEventListener({passive:!0})}static activeCaptureListener(){return t._passiveEventListener({passive:!1,capture:!0})}static emptyListener(){return()=>{}}}return t})(),Hm=800,Jl=class{_document=d(yi);_ngZone=d(Sn,{optional:!0});_mouseListeners=Y.emptyListener();_touchListeners=Y.emptyListener();_startListeners=Y.emptyListener();isSyntheticEvent(i){return!!this._lastTouchEventTime&&this._lastTouchEventTime+Hm>Date.now()}_lastTouchEventTime=0;isDragStarted=!1;_dragStartThreshold=3;_dragStartDelay=0;_dragStartTime=0;_dragStartPosition={x:0,y:0};_moveHandler=this._checkDragSequenceToStart;_pointerDownElement=null;_onMouseDown=i=>{let e=this.isSyntheticEvent(i),n=Um(i),o=new Ya(i);if(e||n||this.disabled||this.isDragStarted)return;this._pointerDownElement=o.targetElement,this.onPointerDown(o)&&(this._dragStartTime=Date.now(),this._dragStartPosition=o.getPosition(),this._ngZone?.runOutsideAngular(()=>{this._listen("selectstart",this._onSelectStart,Y.activeListener()),this._listen("mousemove",this._onMouseMove),this._listen("pointerup",this._onPointerUpEvent),this._listen("pointercancel",this._onPointerUpEvent,Y.activeCaptureListener()),this._listen("contextmenu",this._preventDuringDrag,Y.activeCaptureListener())}),this._mouseListeners=()=>{this._unlisten("selectstart",this._onSelectStart,Y.activeListener()),this._unlisten("mousemove",this._onMouseMove),this._unlisten("pointerup",this._onPointerUpEvent),this._unlisten("pointercancel",this._onPointerUpEvent,Y.activeCaptureListener()),this._unlisten("contextmenu",this._preventDuringDrag,Y.activeCaptureListener())})};_onTouchDown=i=>{let e=Wm(i),n=new Zl(i);if(e||this.disabled||this.isDragStarted)return;this._pointerDownElement=n.targetElement,this.onPointerDown(n)&&(this._dragStartTime=Date.now(),this._dragStartPosition=n.getPosition(),this._ngZone?.runOutsideAngular(()=>{this._listen("selectstart",this._onSelectStart,Y.activeListener()),this._listen("touchmove",this._onTouchMove),this._listen("pointerup",this._onPointerUpEvent),this._listen("pointercancel",this._onPointerUpEvent,Y.activeCaptureListener()),this._listen("contextmenu",this._preventDuringDrag,Y.activeCaptureListener())}),this._touchListeners=()=>{this._unlisten("selectstart",this._onSelectStart,Y.activeListener()),this._unlisten("touchmove",this._onTouchMove),this._unlisten("pointerup",this._onPointerUpEvent),this._unlisten("pointercancel",this._onPointerUpEvent,Y.activeCaptureListener()),this._unlisten("contextmenu",this._preventDuringDrag,Y.activeCaptureListener())})};_onSelectStart=i=>{this.onSelect(i)};_onMouseMove=i=>{this._moveHandler(new Ya(i))};_onTouchMove=i=>{this._moveHandler(new Ql(i))};_checkDragSequenceToStart(i){let e=i.getPosition();if(!this.isDragStarted&&this._pointerDownElement){i.setTarget(this._pointerDownElement);let n=Math.abs(e.x-this._dragStartPosition.x),o=Math.abs(e.y-this._dragStartPosition.y);if(n+o>=this._dragStartThreshold){if(!(Date.now()>=this._dragStartTime+this._dragStartDelay)){this._endDragSequence();return}i.preventDefault(),this.prepareDragSequence(i),this.isDragStarted=!0,this._moveHandler=this.onPointerMove,Vm(i.originalEvent)&&(this._lastTouchEventTime=Date.now())}}}_onPointerUpEvent=i=>{this.isDragStarted&&this.onPointerUp(new Kl(i)),this._endDragSequence()};_endDragSequence(){this.isDragStarted=!1,this._pointerDownElement=null,this._moveHandler=this._checkDragSequenceToStart,this._mouseListeners(),this._mouseListeners=Y.emptyListener(),this._touchListeners(),this._touchListeners=Y.emptyListener(),this.finalizeDragSequence()}subscribe(){this.unsubscribe(),this._ngZone?.runOutsideAngular(()=>{this._listen("mousedown",this._onMouseDown,Y.activeListener()),this._listen("touchstart",this._onTouchDown,Y.passiveListener())}),this._startListeners=()=>{this._unlisten("mousedown",this._onMouseDown,Y.activeListener()),this._unlisten("touchstart",this._onTouchDown,Y.passiveListener())}}unsubscribe(){this._startListeners(),this._startListeners=Y.emptyListener(),this._touchListeners(),this._touchListeners=Y.emptyListener(),this._mouseListeners(),this._mouseListeners=Y.emptyListener()}_listen(i,e,n){this._document.addEventListener(i,e,n)}_unlisten(i,e,n){this._document.removeEventListener(i,e,n)}_preventDuringDrag=i=>{this.isDragStarted&&i.preventDefault()}};function Vm(t){return t.type[0]==="t"}function Um(t){return t.buttons===0||t.offsetX===0&&t.offsetY===0}function Wm(t){let i=t.touches&&t.touches[0]||t.changedTouches&&t.changedTouches[0];return!!i&&i.identifier===-1&&(i.radiusX==null||i.radiusX===1)&&(i.radiusY==null||i.radiusY===1)}var eu=class extends Bt{_position;_isMouseLeftButton;_isMouseRightButton;constructor(i){super(i.originalEvent,i.targetElement),this._position=i.getPosition(),this._isMouseLeftButton=i.isMouseLeftButton(),this._isMouseRightButton=i.isMouseRightButton()}isMouseLeftButton(){return this._isMouseLeftButton}isMouseRightButton(){return this._isMouseRightButton}getPosition(){return W({},this._position)}};function $m(t){return new eu(t)}var G=(()=>{class t{selectedItems=[];isSelectedChanged=!1;onPointerDownScale=1;onPointerDownPosition=new B(0,0);draggableItems=[];autoPanFrameId=null;lastPointerEvent=null;lastPointerPosition=null;isAutoPanCanvasMoved=!1;reset(){for(let e of this.draggableItems)try{e.destroy?.()}catch{console.error(`Error while destroying drag handler of type ${e.type}`)}this.draggableItems=[],this.onPointerDownScale=1,this.onPointerDownPosition=new B(0,0),this.autoPanFrameId=null,this.lastPointerEvent=null,this.lastPointerPosition=null,this.isAutoPanCanvasMoved=!1}markSelectionAsChanged(){this.isSelectedChanged=!0}rememberPointerEvent(e){this.lastPointerEvent=$m(e),this.lastPointerPosition=this.lastPointerEvent.getPosition()}isEmpty(){return!this.draggableItems.length}static \u0275fac=function(n){return new(n||t)};static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})(),tu=class{nodeIds;groupIds;connectionIds;get fNodeIds(){return this.nodeIds}get fGroupIds(){return this.groupIds}get fConnectionIds(){return this.connectionIds}constructor(i,e,n){this.nodeIds=i,this.groupIds=e,this.connectionIds=n}},Ym=(()=>{let t=class er{_mediator=d(b);_store=d(C);_dragSession=d(G);handle(e){this._dragSession.isSelectedChanged&&(this._emitSelectionChange(this._getSelection()),this._dragSession.isSelectedChanged=!1,this._mediator.execute(new mt))}_getSelection(){return this._mediator.execute(new hi)}_emitSelectionChange(e){this._store.fDraggable?.fSelectionChange.emit(new tu(e.fNodeIds,e.fGroupIds,e.fConnectionIds))}static \u0275fac=function(n){return new(n||er)};static \u0275prov=f({token:er,factory:er.\u0275fac})};return t=p([_(Vn)],t),t})(),nu=class{nodeOrGroup;static fToken=Symbol("GetNormalizedParentNodeRectRequest");constructor(i){this.nodeOrGroup=i}},qm=(()=>{let t=class tr{_store=d(C);_mediator=d(b);handle({nodeOrGroup:e}){let n=A.initialize(-1/0,-1/0,1/0,1/0),o=this._getNode(e.fParentId());return o&&(n=this._getParentRect(o)),n}_getNode(e){return this._store.nodes.get(e)}_getParentRect(e){let n=this._getNodeRect(e),o=this._getNodePadding(e,n);return A.initialize(n.x+o[0],n.y+o[1],n.width-o[0]-o[2],n.height-o[1]-o[3])}_getNodeRect(e){return this._mediator.execute(new ie(e.hostElement))}_getNodePadding(e,n){return this._mediator.execute(new jt(e,n))}static \u0275fac=function(n){return new(n||tr)};static \u0275prov=f({token:tr,factory:tr.\u0275fac})};return t=p([_(nu)],t),t})(),iu=class{fParentNodes;fDraggedNodes;static fToken=Symbol("IsArrayHasParentNodeRequest");constructor(i,e){this.fParentNodes=i,this.fDraggedNodes=e}},Xm=(()=>{let t=class nr{handle(e){return this._isParentNodeInArray(this._getParentNodeIds(e.fParentNodes),e.fDraggedNodes)}_getParentNodeIds(e){return e.map(n=>n.fId())}_isParentNodeInArray(e,n){return n.some(o=>e.includes(o.fId()))}static \u0275fac=function(n){return new(n||nr)};static \u0275prov=f({token:nr,factory:nr.\u0275fac})};return t=p([_(iu)],t),t})(),ou=class{fNodeId;fConnectionIds;constructor(i,e){this.fNodeId=i,this.fConnectionIds=e}},qa=class extends ou{nodeId;connectionIds;constructor(i,e){super(i,e),this.nodeId=i,this.connectionIds=e}},Xa=class{nodeOrGroup;static fToken=Symbol("DetectConnectionsUnderDragNodeRequest");constructor(i){this.nodeOrGroup=i}},Km=(()=>{let t=class ir{_mediator=d(b);_store=d(C);handle({nodeOrGroup:e}){let n=this._collectConnectableConnectorIds(e,"source"),o=this._collectConnectableConnectorIds(e,"target");if(!n.size||!o.size)return;let r=this._collectAttachedConnectionIds(n,o),s=this._collectConnectionsUnderNode(e),a=[];for(let c of s){let l=c.fId();r.has(l)||a.push(l)}a.length&&(this._store.fDraggable?.fNodeIntersectedWithConnections.emit(new qa(e.fId(),a)),this._store.fDraggable?.fNodeConnectionsIntersection.emit(new qa(e.fId(),a)))}_collectConnectableConnectorIds(e,n){let o=n==="source"?this._store.outputs.getAll():this._store.inputs.getAll(),r=new Set;for(let s of o)s.canBeConnected&&e.isContains(s.hostElement)&&r.add(s.fId());return r}_collectAttachedConnectionIds(e,n){let o=new Set;for(let r of this._store.connections.getAll())(e.has(r.fOutputId())||n.has(r.fInputId()))&&o.add(r.fId());return o}_collectConnectionsUnderNode(e){let n=this._mediator.execute(new yt(e.hostElement,!1)),o=[];for(let r of this._store.connections.getAll())this._hasIntersection(r,n)&&o.push(r);return o}_hasIntersection(e,n){return Kt.getRoundedRectIntersectionsWithSVGPath(e.fPath().hostElement,n).length>0}static \u0275fac=function(n){return new(n||ir)};static \u0275prov=f({token:ir,factory:ir.\u0275fac})};return t=p([_(Xa)],t),t})(),Zm=[jm,Gm,Ym,qm,Xm,Km],Qm=new Set(["create-connection","reassign-connection","drag-node"]),Jm=new Set(["selection-area"]),e0=new Set(["assign-to-container"]);function vf(t){let i=null;for(let e of t){if(e0.has(e))continue;let n=Qm.has(e)?"rebase":Jm.has(e)?"direct":null;if(!n)return null;if(!i){i=n;continue}if(i!==n)return null}return i}function Cf(t,i,e,n,o){return E.initialize(Fh(t.x,i.left,i.right,e,n,o),Fh(t.y,i.top,i.bottom,e,n,o))}function Fh(t,i,e,n,o,r){let s=Math.max(0,n),a=Math.max(0,o);if(!s||!a)return 0;if(t<=i+s){let c=Lh((i+s-t)/s,0,1);return Ah(c,a,r)}if(t>=e-s){let c=Lh((t-(e-s))/s,0,1);return-Ah(c,a,r)}return 0}function t0(t,i,e){let n=e||1;return B.fromPoint(t).add(B.fromPoint(i).div(n))}function Ah(t,i,e){return e?i*t:i}function Lh(t,i,e){return Math.max(i,Math.min(e,t))}var Ka=class{static fToken=Symbol("RunAutoPanFrameRequest")},vt=class{static fToken=Symbol("StopAutoPanRequest")},n0=(()=>{let t=class or{_store=d(C);_dragContext=d(G);handle(e){this._dragContext.autoPanFrameId!==null&&(cancelAnimationFrame(this._dragContext.autoPanFrameId),this._dragContext.autoPanFrameId=null),this._dragContext.isAutoPanCanvasMoved&&(this._store.fCanvas?.emitCanvasChangeEvent(),this._dragContext.isAutoPanCanvasMoved=!1)}static \u0275fac=function(n){return new(n||or)};static \u0275prov=f({token:or,factory:or.\u0275fac})};return t=p([_(vt)],t),t})(),Un=class{static fToken=Symbol("SyncAutoPanRequest")},i0=(()=>{let t=class rr{_mediator=d(b);_store=d(C);_dragContext=d(G);handle(e){if(!this._canAutoPan()||!this._hasAutoPanDelta()){this._mediator.execute(new vt);return}this._dragContext.autoPanFrameId===null&&(this._dragContext.autoPanFrameId=requestAnimationFrame(()=>{this._dragContext.autoPanFrameId=null,this._mediator.execute(new Ka)}))}_canAutoPan(){return!!this._store.fFlow&&!!this._store.fCanvas&&!!this._store.fDraggable?.isDragStarted&&!!this._autoPan()&&!!this._getAutoPanMode()&&this._edgeThreshold()>0&&this._speed()>0}_hasAutoPanDelta(){let e=this._getAutoPanDelta();return!!e.x||!!e.y}_getAutoPanDelta(){let e=this._dragContext.lastPointerPosition,n=this._store.fFlow?.hostElement;return!e||!n?E.initialize():Cf(e,n.getBoundingClientRect(),this._edgeThreshold(),this._speed(),this._acceleration())}_getAutoPanMode(){return vf(this._dragContext.draggableItems.map(e=>e.getEvent().kind))}_edgeThreshold(){return Math.max(0,this._autoPan()?.fEdgeThreshold()??0)}_speed(){return Math.max(0,this._autoPan()?.fSpeed()??0)}_acceleration(){return!!this._autoPan()?.fAcceleration()}_autoPan(){return this._store.instances.get(te.AUTO_PAN)}static \u0275fac=function(n){return new(n||rr)};static \u0275prov=f({token:rr,factory:rr.\u0275fac})};return t=p([_(Un)],t),t})(),o0=(()=>{let t=class sr{_mediator=d(b);_store=d(C);_dragContext=d(G);handle(e){let n=this._getAutoPanMode();if(!this._canAutoPan(n)){this._mediator.execute(new vt);return}let o=this._getAutoPanDelta();if(!o.x&&!o.y){this._mediator.execute(new vt);return}this._applyCanvasDelta(o,n),this._replayLastPointerMove(),this._mediator.execute(new Un)}_applyCanvasDelta(e,n){let o=this._store.transform;n==="rebase"&&(this._dragContext.onPointerDownPosition=t0(this._dragContext.onPointerDownPosition,e,this._dragContext.onPointerDownScale||o.scale||1)),o.position=B.fromPoint(o.position).add(e),this._store.fCanvas?.redraw(),this._dragContext.isAutoPanCanvasMoved=!0}_replayLastPointerMove(){let e=this._dragContext.lastPointerEvent;if(!e)return;let n=this._getPointerPositionInCanvas(e).div(this._dragContext.onPointerDownScale).sub(this._dragContext.onPointerDownPosition);this._dragContext.draggableItems.forEach(o=>{o.onPointerMove(W({},n),e)})}_getPointerPositionInCanvas(e){return B.fromPoint(e.getPosition()).elementTransform(this._store.flowHost)}_canAutoPan(e){return!!this._store.fFlow&&!!this._store.fCanvas&&!!this._store.fDraggable?.isDragStarted&&!!this._autoPan()&&!!e&&this._edgeThreshold()>0&&this._speed()>0}_getAutoPanMode(){return vf(this._dragContext.draggableItems.map(e=>e.getEvent().kind))}_getAutoPanDelta(){let e=this._dragContext.lastPointerPosition,n=this._store.fFlow?.hostElement;return!e||!n?E.initialize():Cf(e,n.getBoundingClientRect(),this._edgeThreshold(),this._speed(),this._acceleration())}_edgeThreshold(){return Math.max(0,this._autoPan()?.fEdgeThreshold()??0)}_speed(){return Math.max(0,this._autoPan()?.fSpeed()??0)}_acceleration(){return!!this._autoPan()?.fAcceleration()}_autoPan(){return this._store.instances.get(te.AUTO_PAN)}static \u0275fac=function(n){return new(n||sr)};static \u0275prov=f({token:sr,factory:sr.\u0275fac})};return t=p([_(Ka)],t),t})(),r0=[i0,o0,n0],Za=class{event;static fToken=Symbol("DragCanvasFinalizeRequest");constructor(i){this.event=i}},Qa=class{kind;data;fEventType;get fData(){return this.data}constructor(i,e,n){this.kind=i,this.data=e,this.fEventType=n??i}},Te=class{data(){}_features=[];getEvent(){return new Qa(this.kind,this.data(),this.type)}attachFeature(i){this._features.push(i)}featuresPrepare(i){for(let e of this._features)e.onPrepare?.(i)}featuresMove(i,e){for(let n of this._features)n.onMove?.(i,e)}featuresFinalize(i,e){for(let n of this._features)n.onFinalize?.(i,e)}featuresEnd(i){for(let e of this._features)e.onEnd?.(i)}},Ja=class{_isConnected=!1;get isConnected(){return this._isConnected}toConnector=[];isSelfConnectable=!0;fConnectableSide=D.AUTO;userFConnectableSide=D.AUTO;isContains(i){return this.hostElement.contains(i)}setConnected(i){this._isConnected=!0,this.toConnector.push(i)}resetConnected(){this._isConnected=!1,this.toConnector=[]}},s0=new X("F_NODE_INPUT"),a0=(()=>{class t extends Ja{kind="input";get canBeConnected(){return!this.disabled()&&(this.multiple()?!0:!this.isConnected)}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275dir=le({type:t,standalone:!1,features:[ne]})}return t})(),Ke=(function(t){return t.LEFT="left",t.LEFT_TOP="left-top",t.TOP="top",t.RIGHT_TOP="right-top",t.RIGHT="right",t.RIGHT_BOTTOM="right-bottom",t.BOTTOM="bottom",t.LEFT_BOTTOM="left-bottom",t})(Ke||{});function c0(t){return Tn(t,".f-rotate-handle")}var wf=(()=>{class t{static \u0275fac=function(n){return new(n||t)};static \u0275dir=le({type:t,selectors:[["","fDragHandle",""]],hostAttrs:[1,"f-drag-handle","f-component"],standalone:!1})}return t})(),Bd=new X("F_NODE"),d0=hf(class{hostElement;constructor(t){this.hostElement=t}}),ec=class extends d0{_injector=d(Pe);renderer=d(dh);browser=d(ce);stateChanges=new Fe;_position=E.initialize();_rotate=0;_size;connectors=[];positionChanges(){Se(()=>{let i=this.position();Et(()=>{E.isEqual(this._position,i)||(this._position=i,this.redraw(),this.refresh())})},{injector:this._injector})}sizeChanges(){Se(()=>{let i=this.size();Et(()=>{this._isSizeEqual(i)||(this._size=i,this.redraw(),this.refresh())})},{injector:this._injector})}rotateChanges(){Se(()=>{let i=this.rotate();Et(()=>{this._rotate!==i&&(this._rotate=i,this.redraw(),this.refresh())})},{injector:this._injector})}parentChanges(){Se(()=>{this.fParentId(),this.fIncludePadding(),this.fAutoSizeToFitChildren(),Et(()=>this.refresh())},{injector:this._injector})}_isSizeEqual(i){return this._size?.width===i?.width&&this._size?.height===i?.height}isContains(i){return this.hostElement.contains(i)}redraw(){this._size&&(this.setStyle("width",""+this._size.width+"px"),this.setStyle("height",""+this._size.height+"px")),this.setStyle("transform",`translate(${this._position.x}px,${this._position.y}px) rotate(${this._rotate}deg)`)}resetSize(){this.removeStyle("width"),this.removeStyle("height")}updatePosition(i){this._position=i}updateRotate(i){this._rotate=i}updateSize(i){this._size=i}setClass(i){this.hostElement.classList.add(i)}removeClass(i){this.hostElement.classList.remove(i)}addConnector(i){this.connectors.push(i),this.refresh()}removeConnector(i){let e=this.connectors.indexOf(i);e!==-1&&this.connectors.splice(e,1),this.refresh()}},l0=0,u0=3,ru=(()=>{class t extends ec{_debounceTimer=null;_destroyRef=d(We);_mediator=d(b);fId=R(`f-group-${l0++}`,{alias:"fGroupId"});fParentId=R(null,{alias:"fGroupParentId"});position=Dt(E.initialize(),{alias:"fGroupPosition"});size=R(void 0,{alias:"fGroupSize"});sizeChange=rt({alias:"fGroupSizeChange"});rotate=Dt(0,{alias:"fGroupRotate"});fConnectOnNode=R(!0,{transform:Q});fMinimapClass=R([]);fDraggingDisabled=R(!1,{alias:"fGroupDraggingDisabled",transform:Q});fSelectionDisabled=R(!1,{alias:"fGroupSelectionDisabled",transform:Q});fIncludePadding=R(!0,{transform:Q});fAutoExpandOnChildHit=R(!1,{transform:Q});fAutoSizeToFitChildren=R(!1,{transform:Q});constructor(e){super(e.nativeElement),super.positionChanges(),super.sizeChanges(),super.rotateChanges(),super.parentChanges()}ngOnInit(){super.redraw(),this._mediator.execute(new ri(this))}setStyle(e,n){this.renderer.setStyle(this.hostElement,e,n)}removeStyle(e){this.renderer.removeStyle(this.hostElement,e)}redraw(){super.redraw(),this._mediator.execute(new mt),this._updateConnectorsSides()}_updateConnectorsSides(){this.connectors.length&&(this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>this._calculateNodeConnectorsConnectableSides(),u0))}_calculateNodeConnectorsConnectableSides(){this._mediator.execute(new dn(this))}ngAfterViewInit(){this.browser.isBrowser()&&this._listenStateSizeChanges()}_listenStateSizeChanges(){this._mediator.execute(new ai(this,this._destroyRef))}refresh(){this.stateChanges.notify()}ngOnDestroy(){this._mediator.execute(new ci(this))}static \u0275fac=function(n){return new(n||t)(il(se))};static \u0275dir=le({type:t,selectors:[["","fGroup",""]],hostAttrs:[1,"f-group","f-component"],hostVars:5,hostBindings:function(n,o){n&2&&(K("data-f-group-id",o.fId()),Be("f-group-dragging-disabled",o.fDraggingDisabled())("f-group-selection-disabled",o.fSelectionDisabled()))},inputs:{fId:[1,"fGroupId","fId"],fParentId:[1,"fGroupParentId","fParentId"],position:[1,"fGroupPosition","position"],size:[1,"fGroupSize","size"],rotate:[1,"fGroupRotate","rotate"],fConnectOnNode:[1,"fConnectOnNode"],fMinimapClass:[1,"fMinimapClass"],fDraggingDisabled:[1,"fGroupDraggingDisabled","fDraggingDisabled"],fSelectionDisabled:[1,"fGroupSelectionDisabled","fSelectionDisabled"],fIncludePadding:[1,"fIncludePadding"],fAutoExpandOnChildHit:[1,"fAutoExpandOnChildHit"],fAutoSizeToFitChildren:[1,"fAutoSizeToFitChildren"]},outputs:{position:"fGroupPositionChange",sizeChange:"fGroupSizeChange",rotate:"fGroupRotateChange"},exportAs:["fComponent"],standalone:!1,features:[me([{provide:Bd,useExisting:t}]),ne]})}return t})(),zh=0,h0=3,Gd=(()=>{class t extends ec{_debounceTimer=null;_destroyRef=d(We);_mediator=d(b);fId=R(`f-node-${zh++}`,{alias:"fNodeId",transform:e=>an(e)||`f-node-${zh++}`});fParentId=R(null,{alias:"fNodeParentId"});position=Dt(E.initialize(),{alias:"fNodePosition"});size=R(void 0,{alias:"fNodeSize"});sizeChange=rt({alias:"fNodeSizeChange"});rotate=Dt(0,{alias:"fNodeRotate"});fConnectOnNode=R(!0,{transform:Q});fMinimapClass=R([]);fDraggingDisabled=R(!1,{alias:"fNodeDraggingDisabled",transform:Q});fSelectionDisabled=R(!1,{alias:"fNodeSelectionDisabled",transform:Q});fIncludePadding=R(!0,{transform:Q});fAutoExpandOnChildHit=R(!1,{transform:Q});fAutoSizeToFitChildren=R(!1,{transform:Q});constructor(e){super(e.nativeElement),super.positionChanges(),super.sizeChanges(),super.rotateChanges(),super.parentChanges()}ngOnInit(){super.redraw(),this._mediator.execute(new ri(this))}setStyle(e,n){this.renderer.setStyle(this.hostElement,e,n)}removeStyle(e){this.renderer.removeStyle(this.hostElement,e)}redraw(){super.redraw(),this._mediator.execute(new mt),this._updateConnectorsSides()}_updateConnectorsSides(){this.connectors.length&&(this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>this._calculateNodeConnectorsConnectableSides(),h0))}_calculateNodeConnectorsConnectableSides(){this._mediator.execute(new dn(this))}ngAfterViewInit(){this.browser.isBrowser()&&this._listenStateSizeChanges()}_listenStateSizeChanges(){this._mediator.execute(new ai(this,this._destroyRef))}refresh(){this.stateChanges.notify()}ngOnDestroy(){this._mediator.execute(new ci(this))}static \u0275fac=function(n){return new(n||t)(il(se))};static \u0275dir=le({type:t,selectors:[["","fNode",""]],hostAttrs:[1,"f-node","f-component"],hostVars:5,hostBindings:function(n,o){n&2&&(K("data-f-node-id",o.fId()),Be("f-node-dragging-disabled",o.fDraggingDisabled())("f-node-selection-disabled",o.fSelectionDisabled()))},inputs:{fId:[1,"fNodeId","fId"],fParentId:[1,"fNodeParentId","fParentId"],position:[1,"fNodePosition","position"],size:[1,"fNodeSize","size"],rotate:[1,"fNodeRotate","rotate"],fConnectOnNode:[1,"fConnectOnNode"],fMinimapClass:[1,"fMinimapClass"],fDraggingDisabled:[1,"fNodeDraggingDisabled","fDraggingDisabled"],fSelectionDisabled:[1,"fNodeSelectionDisabled","fSelectionDisabled"],fIncludePadding:[1,"fIncludePadding"],fAutoExpandOnChildHit:[1,"fAutoExpandOnChildHit"],fAutoSizeToFitChildren:[1,"fAutoSizeToFitChildren"]},outputs:{position:"fNodePositionChange",sizeChange:"fNodeSizeChange",rotate:"fNodeRotateChange"},exportAs:["fComponent"],standalone:!1,features:[me([{provide:Bd,useExisting:t}]),ne]})}return t})();function f0(t){return!!t.closest("[fNode]")}var Bh=0,bf=(()=>{class t extends a0{hostElement=d(se).nativeElement;_mediator=d(b);_node=d(Bd);fId=R(`f-node-input-${Bh++}`,{alias:"fInputId",transform:e=>an(e)||`f-node-input-${Bh++}`});category=R(void 0,{alias:"fInputCategory",transform:an});multiple=R(!0,{alias:"fInputMultiple",transform:Q});disabled=R(!1,{alias:"fInputDisabled",transform:Q});userFConnectableSide=D.AUTO;get fNodeId(){return this._node.fId()}get fNodeHost(){return this._node.hostElement}ngOnInit(){this._mediator.execute(new ni(this)),this._node.addConnector(this)}ngOnChanges(e){e.userFConnectableSide&&this._node.refresh()}setConnected(e){super.setConnected(e),this.hostElement.classList.toggle(pe.CONNECTOR.INPUT_CONNECTED,!0),this.hostElement.classList.toggle(pe.CONNECTOR.INPUT_NOT_CONNECTABLE,!this.canBeConnected)}resetConnected(){super.resetConnected(),this.hostElement.classList.toggle(pe.CONNECTOR.INPUT_CONNECTED,!1),this.hostElement.classList.toggle(pe.CONNECTOR.INPUT_NOT_CONNECTABLE,!this.canBeConnected)}ngOnDestroy(){this._node.removeConnector(this),this._mediator.execute(new di(this))}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275dir=le({type:t,selectors:[["","fNodeInput",""]],hostAttrs:[1,"f-component","f-node-input"],hostVars:5,hostBindings:function(n,o){n&2&&(K("data-f-input-id",o.fId()),Be("f-node-input-multiple",o.multiple)("f-node-input-disabled",o.disabled()))},inputs:{fId:[1,"fInputId","fId"],category:[1,"fInputCategory","category"],multiple:[1,"fInputMultiple","multiple"],disabled:[1,"fInputDisabled","disabled"],userFConnectableSide:[2,"fInputConnectableSide","userFConnectableSide",e=>Zt(e,"fInputConnectableSide",D)]},exportAs:["fNodeInput"],standalone:!1,features:[me([{provide:s0,useExisting:t}]),ne,$t]})}return t})(),g0=(()=>{class t extends Ja{get hasConnectionLimits(){return!!this.canBeConnectedInputs&&this.canBeConnectedInputs.length>0}canConnectTo(e){return[e.fId(),e.category()].some(o=>o&&this.canBeConnectedInputs?.includes(o))}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275dir=le({type:t,standalone:!1,features:[ne]})}return t})();function xf(t){return!!t.closest("[fNodeOutlet]")}var p0=new X("F_NODE_OUTPUT"),_0=(()=>{class t extends g0{kind="output";get canBeConnected(){return!this.disabled()&&(this.multiple()?!0:!this.isConnected)}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275dir=le({type:t,standalone:!1,features:[ne]})}return t})();function If(t){return!!t.closest("[fNodeOutput]")}var Gh=0,Sf=(()=>{class t extends _0{hostElement=d(se).nativeElement;_mediator=d(b);_node=d(Bd);fId=R(`f-node-output-${Gh++}`,{alias:"fOutputId",transform:e=>an(e)||`f-node-output-${Gh++}`});multiple=R(!1,{alias:"fOutputMultiple",transform:Q});disabled=R(!1,{alias:"fOutputDisabled",transform:Q});userFConnectableSide=D.AUTO;isSelfConnectable=!0;canBeConnectedInputs=[];get fNodeId(){return this._node.fId()}get fNodeHost(){return this._node.hostElement}ngOnInit(){this._mediator.execute(new ni(this)),this._node.addConnector(this)}ngOnChanges(e){e.userFConnectableSide&&this._node.refresh()}setConnected(e){super.setConnected(e),this.hostElement.classList.toggle(pe.CONNECTOR.OUTPUT_CONNECTED,!0),this.hostElement.classList.toggle(pe.CONNECTOR.OUTPUT_NOT_CONNECTABLE,!this.canBeConnected)}resetConnected(){super.resetConnected(),this.hostElement.classList.toggle(pe.CONNECTOR.OUTPUT_CONNECTED,!1),this.hostElement.classList.toggle(pe.CONNECTOR.OUTPUT_NOT_CONNECTABLE,!this.canBeConnected)}ngOnDestroy(){this._node.removeConnector(this),this._mediator.execute(new di(this))}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275dir=le({type:t,selectors:[["","fNodeOutput",""]],hostAttrs:[1,"f-component","f-node-output"],hostVars:7,hostBindings:function(n,o){n&2&&(K("data-f-output-id",o.fId()),Be("f-node-output-multiple",o.multiple)("f-node-output-disabled",o.disabled())("f-node-output-self-connectable",o.isSelfConnectable))},inputs:{fId:[1,"fOutputId","fId"],multiple:[1,"fOutputMultiple","multiple"],disabled:[1,"fOutputDisabled","disabled"],userFConnectableSide:[2,"fOutputConnectableSide","userFConnectableSide",e=>Zt(e,"fOutputConnectableSide",D)],isSelfConnectable:"isSelfConnectable",canBeConnectedInputs:[0,"fCanBeConnectedInputs","canBeConnectedInputs"]},exportAs:["fNodeOutput"],standalone:!1,features:[me([{provide:p0,useExisting:t}]),ne,$t]})}return t})();var tc=class{event;static fToken=Symbol("CreateConnectionFinalizeRequest");constructor(i){this.event=i}},Wn=class{outlet;static fToken=Symbol("ResolveConnectableOutputForOutletRequest");constructor(i){this.outlet=i}},m0=(()=>{let t=class ar{_store=d(C);handle({outlet:e}){let n=this._findOwnerNode(e);if(!n)throw new Error("The fOutlet must belong to an fNode");let o=this._findFirstConnectableOutputInNode(n);if(!o)throw new Error("Outlet requires at least one connectable output in the same node.");return o}_findOwnerNode(e){let n=e.hostElement;return this._store.nodes.getAll().find(o=>o.isContains(n))}_findFirstConnectableOutputInNode(e){return this._store.outputs.getAll().find(n=>e.isContains(n.hostElement)&&n.canBeConnected)}static \u0275fac=function(n){return new(n||ar)};static \u0275prov=f({token:ar,factory:ar.\u0275fac})};return t=p([_(Wn)],t),t})(),su=class{sourceId;targetId;dropPosition;fOutputId;fInputId;fDropPosition;constructor(i,e,n){this.sourceId=i,this.targetId=e,this.dropPosition=n,this.fOutputId=i,this.fInputId=e,this.fDropPosition=n}},nc=(()=>{class t extends Te{type="create-connection";kind="create-connection";data(){return{fOutputOrOutletId:this._sourceRef.connector.fId()}}_result=d(wt);_mediator=d(b);_connectionBehaviour=d(_n);_store=d(C);get _connection(){return this._store.connections.getForCreate()}get _snapConnection(){return this._store.connections.getForSnap()}_targets=[];_sourceRef;_pointerDown=new ae;initialize(e,n){this._sourceRef=this._mediator.execute(new Oe(e)),this._pointerDown=ae.fromRect(A.initialize(n.x,n.y))}prepareDragSequence(){this._collectAndMarkTargets(),this._initSnapConnection(),this._initCreateConnection(),this._connection.show(),this.onPointerMove(E.initialize()),this._result.setData({toConnectorRect:this._pointerDown,canBeConnectedInputs:this._targets,fOutputId:this._sourceRef.connector.fId()})}_collectAndMarkTargets(){this._targets=this._mediator.execute(new oi(this._sourceRef.connector,this._sourceRef.rect.gravityCenter)),this._mediator.execute(new hn(this._targets.map(e=>e.connector)))}_initSnapConnection(){this._snapConnection&&(this._snapConnection.fOutputId.set(this._sourceRef.connector.fId()),this._snapConnection.initialize())}_initCreateConnection(){this._connection.fOutputId.set(this._sourceRef.connector.fId()),this._connection.initialize()}onPointerMove(e){let n=this._pointerDown.addPoint(e),o=this._findClosestTarget(n),r=o?.connector.fConnectableSide||D.TOP;this._drawCreateConnection(n,r);let s=this._snapConnection;if(!s)return;let a=o&&o.distance<s.fSnapThreshold?o:void 0;this._drawSnapConnection(a)}_findClosestTarget(e){return this._mediator.execute(new Gt(e,this._targets))}_drawCreateConnection(e,n){let o=this._connectionBehaviour.handle(new He(this._sourceRef.rect,e,this._connection,this._sourceRef.connector.fConnectableSide,n,this._resolveRotationContext(this._sourceRef.connector)));this._connection.setLine(o),this._connection.redraw()}_drawSnapConnection(e){let n=this._snapConnection;if(!n)return;if(!e){n.hide();return}let o=this._connectionBehaviour.handle(new He(this._sourceRef.rect,e.rect,n,this._sourceRef.connector.fConnectableSide,e.connector.fConnectableSide,this._resolveRotationContext(this._sourceRef.connector),this._resolveRotationContext(e.connector)));n.show(),n.setLine(o),n.redraw()}onPointerUp(){this._connection.redraw(),this._connection.hide(),this._snapConnection?.hide(),this._mediator.execute(new fn(this._targets.map(e=>e.connector)))}_resolveRotationContext(e){return this._mediator.execute(new ct(e))}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})(),y0=(()=>{let t=class cr{_result=d(wt);_mediator=d(b);_store=d(C);_dragContext=d(G);get _dragHandler(){return this._dragContext.draggableItems[0]}handle(e){this._isValid()&&(this._emitEvent(e.event),this._dragHandler.onPointerUp())}_isValid(){return this._dragContext.draggableItems.some(e=>e instanceof nc)}_getTargetOutput(e){if(!e)throw new Error(`Output with fOutputId ${this._result.getData().fOutputId} not found. Make sure there is no f-connection to a non-existent fOutput.`);return xf(e.hostElement)?this._mediator.execute(new Wn(e)):e}_getOutput(){return this._store.outputs.get(this._result.getData().fOutputId)}_getOutlet(){return this._store.outlets.get(this._result.getData().fOutputId)}_emitEvent(e){this._store.fDraggable?.fCreateConnection.emit(new su(this._getTargetOutput(this._getOutput()||this._getOutlet()).fId(),this._getInputUnderPointer(e)?.fId(),e.getPosition()))}_getInputUnderPointer(e){return this._mediator.execute(new ii(e.getPosition(),this._result.getData().canBeConnectedInputs))}static \u0275fac=function(n){return new(n||cr)};static \u0275prov=f({token:cr,factory:cr.\u0275fac})};return t=p([_(tc)],t),t})(),$n=class{eventPosition;source;static fToken=Symbol("CreateConnectionCreateDragHandlerRequest");constructor(i,e){this.eventPosition=i,this.source=e}},v0=(()=>{let t=class dr{_store=d(C);_dragContext=d(G);_dragInjector=d(we);get _transform(){return this._store.transform}handle({source:e,eventPosition:n}){this._dragContext.onPointerDownScale=this._transform.scale;let o=this._toFlowSpace(n);this._dragContext.onPointerDownPosition=o;let r=this._toCanvasSpace(o),s=this._dragInjector.get(nc);s.initialize(e,r),this._dragContext.draggableItems=[s]}_toFlowSpace(e){return B.fromPoint(e).elementTransform(this._store.flowHost).div(this._transform.scale)}_toCanvasSpace(e){return B.fromPoint(e).mult(this._transform.scale).sub(this._transform.position).sub(this._transform.scaledPosition).div(this._transform.scale)}static \u0275fac=function(n){return new(n||dr)};static \u0275prov=f({token:dr,factory:dr.\u0275fac})};return t=p([_($n)],t),t})(),ic=class{event;node;static fToken=Symbol("CreateConnectionFromOutletPreparationRequest");constructor(i,e){this.event=i,this.node=e}},C0=(()=>{let t=class lr{_mediator=d(b);_store=d(C);handle({event:e,node:n}){let o=this._findOutlet(n);if(!o||(o.setOutputs(this._getOutputs(n)),!o.canBeConnected))return;let r=o.isConnectionFromOutlet?o:this._resolveOutput(o);!r||!r.canBeConnected||this._startDrag(e.getPosition(),r)}_findOutlet(e){return this._store.outlets.getAll().find(n=>e.isContains(n.hostElement))}_getOutputs(e){return this._store.outputs.getAll().filter(n=>e.isContains(n.hostElement))}_resolveOutput(e){return this._mediator.execute(new Wn(e))}_startDrag(e,n){this._mediator.execute(new $n(e,n))}static \u0275fac=function(n){return new(n||lr)};static \u0275prov=f({token:lr,factory:lr.\u0275fac})};return t=p([_(ic)],t),t})(),oc=class{event;node;static fToken=Symbol("CreateConnectionFromOutputPreparationRequest");constructor(i,e){this.event=i,this.node=e}},w0=(()=>{let t=class ur{_mediator=d(b);_store=d(C);handle({event:e,node:n}){if(!If(e.targetElement)||this._hasOutlet(n))return;let o=this._findOutput(e.targetElement);!o||!o.canBeConnected||this._startDrag(e.getPosition(),o)}_hasOutlet(e){return this._store.outlets.getAll().some(n=>e.isContains(n.hostElement))}_findOutput(e){return this._store.outputs.getAll().find(n=>n.hostElement.contains(e))}_startDrag(e,n){this._mediator.execute(new $n(e,n))}static \u0275fac=function(n){return new(n||ur)};static \u0275prov=f({token:ur,factory:ur.\u0275fac})};return t=p([_(oc)],t),t})(),rc=class{event;fTrigger;static fToken=Symbol("CreateConnectionPreparationRequest");constructor(i,e){this.event=i,this.fTrigger=e}},b0=(()=>{let t=class hr{_mediator=d(b);_store=d(C);_dragContext=d(G);handle({event:e,fTrigger:n}){if(!this._isValidConditions()||!this._isValidTrigger(e,n))return;let o=xf(e.targetElement),r=!o&&If(e.targetElement);if(!o&&!r)return;let s=this._findOwnerNode(e.targetElement);s&&(o?this._mediator.execute(new ic(e,s)):this._mediator.execute(new oc(e,s)))}_findOwnerNode(e){return this._store.nodes.getAll().find(n=>n.isContains(e))}_isValidConditions(){return this._dragContext.isEmpty()&&!!this._store.connections.getForCreate()}_isValidTrigger(e,n){return Ae(e.originalEvent,n)}static \u0275fac=function(n){return new(n||hr)};static \u0275prov=f({token:hr,factory:hr.\u0275fac})};return t=p([_(rc)],t),t})(),sc=class{event;static fToken=Symbol("ReassignConnectionFinalizeRequest");constructor(i){this.event=i}},au=class{connectionId;endpoint;previousSourceId;nextSourceId;previousTargetId;nextTargetId;dropPosition;isSourceReassign;isTargetReassign;oldSourceId;newSourceId;oldTargetId;newTargetId;dropPoint;constructor(i,e,n,o,r,s,a){this.connectionId=i,this.endpoint=e,this.previousSourceId=n,this.nextSourceId=o,this.previousTargetId=r,this.nextTargetId=s,this.dropPosition=a,this.isSourceReassign=e==="source",this.isTargetReassign=e==="target",this.oldSourceId=n,this.newSourceId=o,this.oldTargetId=r,this.newTargetId=s,this.dropPoint=a}},x0=(()=>{let t=class fr{_dragResult=d(wt);_mediator=d(b);_store=d(C);_dragContext=d(G);get _dragDirective(){return this._store.fDraggable}handle({event:e}){let n=this._findReassignHandler();n&&(this._emitIfChanged(e),n.onPointerUp())}_findReassignHandler(){return this._dragContext.draggableItems.find(n=>n.getEvent().fEventType==="reassign-connection")}_emitIfChanged(e){let n=this._dragResult.getData(),o=this._findConnectableConnector(e,n.candidates);o&&!this._isReassignedToDifferentConnector(n,o)||this._dragDirective.fReassignConnection.emit(this._buildEvent(n,e,o))}_findConnectableConnector(e,n){return this._mediator.execute(new ii(e.getPosition(),n))}_isReassignedToDifferentConnector(e,n){let o=e.connection;return e.draggedEnd==="target"?o.fInputId()!==n.fId():o.fOutputId()!==n.fId()}_buildEvent(e,n,o){let r=e.connection;return new au(r.fId(),e.draggedEnd,r.fOutputId(),e.draggedEnd==="source"?o?.fId():void 0,r.fInputId(),e.draggedEnd==="target"?o?.fId():void 0,n.getPosition())}static \u0275fac=function(n){return new(n||fr)};static \u0275prov=f({token:fr,factory:fr.\u0275fac})};return t=p([_(sc)],t),t})(),ac=class{event;fTrigger;static fToken=Symbol("ReassignConnectionPreparationRequest");constructor(i,e){this.event=i,this.fTrigger=e}};function I0(t,i){return Ef(t,i)||S0(t,i)}function Ef(t,i){return t.fDragHandleEnd()?.point&&Df(i,t.fDragHandleEnd().point)&&!t.fDraggingDisabled()}function S0(t,i){return!!t.fDragHandleStart()?.point&&Df(i,t.fDragHandleStart().point)&&!t.fDraggingDisabled()&&t.fReassignableStart()}function Df(t,i){return(t.x-i.x)**2+(t.y-i.y)**2<=8**2}function Tf(t,i){return t&&t.distance<i.fSnapThreshold?t:void 0}function cc(t){return ae.fromRect(A.initialize(t.x,t.y))}var cu=class{_mediator;_behaviour;_connection;_sourceRef;_targetRef;_candidates=[];_snap;_anchorRect;get _source(){return this._sourceRef.connector}get _target(){return this._targetRef.connector}constructor(i,e,n,o,r){this._mediator=i,this._behaviour=e,this._connection=n,this._sourceRef=o,this._targetRef=r,this._anchorRect=cc(this._connection.line.point1)}candidates(){return this._candidates}collectAndMarkCandidates(){this._candidates=this._mediator.execute(new ud(this._target,this._targetRef.rect.gravityCenter)),this._candidates.some(i=>i.connector.fId()===this._source.fId())||this._candidates.push(this._sourceRef),this._mediator.execute(new hn(this._candidates.map(i=>i.connector)))}setSnapConnection(i){this._snap=i,i&&(i.fInputId.set(this._connection.fInputId()),i.initialize())}onPointerMove(i){let e=this._anchorRect.addPoint(i),n=this._findClosest(e.gravityCenter),o=n?.connector.fConnectableSide??this._source.fConnectableSide;this._draw(e,o);let r=this._snap;r&&this._drawSnap(Tf(n,r))}_findClosest(i){return this._mediator.execute(new Gt(i,this._candidates))}_draw(i,e){let n=this._behaviour.handle(new He(i,this._targetRef.rect,this._connection,e,this._targetRef.connector.fConnectableSide,void 0,this._resolveRotationContext(this._targetRef.connector)));this._connection.setLine(n),this._connection.redraw()}_drawSnap(i){let e=this._snap;if(!e)return;if(!i){e.hide();return}let n=this._behaviour.handle(new He(i.rect,this._targetRef.rect,e,i.connector.fConnectableSide,this._target.fConnectableSide,this._resolveRotationContext(i.connector),this._resolveRotationContext(this._targetRef.connector)));e.show(),e.setLine(n),e.redraw()}onPointerUp(){this._draw(this._anchorRect,this._sourceRef.connector.fConnectableSide),this._snap?.hide(),this._mediator.execute(new fn(this._candidates.map(i=>i.connector)))}_resolveRotationContext(i){return this._mediator.execute(new ct(i))}},du=class{_mediator;_behaviour;_connection;_sourceRef;_targetRef;_candidates=[];_snap;_anchorRect;get _source(){return this._sourceRef.connector}get _target(){return this._targetRef.connector}constructor(i,e,n,o,r){this._mediator=i,this._behaviour=e,this._connection=n,this._sourceRef=o,this._targetRef=r,this._anchorRect=cc(this._connection.line.point2)}candidates(){return this._candidates}collectAndMarkCandidates(){this._candidates=this._mediator.execute(new oi(this._source,this._sourceRef.rect.gravityCenter));let i=this._connection.fInputId();i&&!this._candidates.some(e=>e.connector.fId()===i)&&this._candidates.push(this._targetRef),this._mediator.execute(new hn(this._candidates.map(e=>e.connector)))}setSnapConnection(i){this._snap=i,i&&(i.fOutputId.set(this._connection.fOutputId()),i.initialize())}onPointerMove(i){let e=this._anchorRect.addPoint(i),n=this._findClosest(e.gravityCenter),o=n?.connector.fConnectableSide??this._target.fConnectableSide;this._draw(e,o);let r=this._snap;r&&this._drawSnap(Tf(n,r))}onPointerUp(){this._draw(this._anchorRect,this._targetRef.connector.fConnectableSide),this._snap?.hide(),this._mediator.execute(new fn(this._candidates.map(i=>i.connector)))}_findClosest(i){return this._mediator.execute(new Gt(i,this._candidates))}_draw(i,e){let n=this._behaviour.handle(new He(this._sourceRef.rect,i,this._connection,this._source.fConnectableSide,e,this._resolveRotationContext(this._sourceRef.connector),void 0));this._connection.setLine(n),this._connection.redraw()}_drawSnap(i){let e=this._snap;if(!e)return;if(!i){e.hide();return}let n=this._behaviour.handle(new He(this._sourceRef.rect,i.rect,e,this._source.fConnectableSide,i.connector.fConnectableSide,this._resolveRotationContext(this._sourceRef.connector),this._resolveRotationContext(i.connector)));e.show(),e.setLine(n),e.redraw()}_resolveRotationContext(i){return this._mediator.execute(new ct(i))}},lu=(()=>{class t extends Te{type="reassign-connection";kind="reassign-connection";data(){return{fConnectionId:this._connection.fId()}}_result=d(wt);_mediator=d(b);_connectionBehaviour=d(_n);_store=d(C);get _snapConnection(){return this._store.connections.getForSnap()}_connection;_draggedEnd;_sourceRef;_targetRef;_reassignHandler;initialize(e,n){this._connection=e,this._draggedEnd=n?"target":"source",this._sourceRef=this._mediator.execute(new Oe(this._store.outputs.require(this._connection.fOutputId()))),this._targetRef=this._mediator.execute(new Oe(this._store.inputs.require(this._connection.fInputId()))),this._reassignHandler=this._draggedEnd==="target"?this._createTargetHandler():this._createSourceHandler()}_createSourceHandler(){return new cu(this._mediator,this._connectionBehaviour,this._connection,this._sourceRef,this._targetRef)}_createTargetHandler(){return new du(this._mediator,this._connectionBehaviour,this._connection,this._sourceRef,this._targetRef)}prepareDragSequence(){this._reassignHandler.collectAndMarkCandidates(),this._reassignHandler.setSnapConnection(this._snapConnection),this._result.setData({draggedEnd:this._draggedEnd,sourceAnchorRect:cc(this._connection.line.point1),targetAnchorRect:cc(this._connection.line.point2),candidates:this._reassignHandler.candidates(),connection:this._connection})}onPointerMove(e){this._reassignHandler.onPointerMove(e)}onPointerUp(){this._reassignHandler.onPointerUp()}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})(),E0=(()=>{let t=class gr{_mediator=d(b);_store=d(C);_dragContext=d(G);_dragInjector=d(we);get _canvas(){return this._store.fCanvas}get _transform(){return this._store.transform}get _connections(){return this._store.connections.getAll()}handle(e){if(!this._dragContext.isEmpty()||!this._isValidTrigger(e))return;let n=mn(e.event.getPosition(),this._store.flowHost,this._transform),o=this._findConnectionAt(n);o&&(this._capturePointerDown(e),this._startDrag(o,n),queueMicrotask(()=>this._bringToFront(o)))}_findConnectionAt(e){return this._connections.find(n=>I0(n,e))}_capturePointerDown(e){this._dragContext.onPointerDownScale=this._transform.scale,this._dragContext.onPointerDownPosition=B.fromPoint(e.event.getPosition()).elementTransform(this._store.flowHost).div(this._transform.scale)}_startDrag(e,n){let o=this._dragInjector.get(lu);o.initialize(e,Ef(e,n)),this._dragContext.draggableItems=[o]}_isValidTrigger(e){return Ae(e.event.originalEvent,e.fTrigger)}_bringToFront(e){this._mediator.execute(new Ht(e,this._canvas.fConnectionsContainer().nativeElement))}static \u0275fac=function(n){return new(n||gr)};static \u0275prov=f({token:gr,factory:gr.\u0275fac})};return t=p([_(ac)],t),t})(),dc=class{event;static fToken=Symbol("DragConnectionWaypointFinalizeRequest");constructor(i){this.event=i}},lc=class{connectionId;waypoints;constructor(i,e){this.connectionId=i,this.waypoints=e}},uc=(()=>{class t extends Te{type="move-connection-waypoint";kind="drag-connection-waypoint";_store=d(C);_point;_pick;get _waypointsComponent(){return this._pick?.connection.fWaypoints()}get _connection(){return this._pick?.connection}setPick(e){this._pick=e}prepareDragSequence(){this._pick?.candidate?(this._point=W({},this._pick.candidate),this._waypointsComponent.insert(this._pick.candidate)):this._pick?.waypoint&&(this._point=W({},this._pick.waypoint),this._waypointsComponent.select(this._pick.waypoint)),this._redrawConnection()}onPointerMove(e){this._waypointsComponent.move(E.sum(this._point,e)),this._redrawConnection()}onPointerUp(){this._waypointsComponent.update(),this._store.fDraggable?.fConnectionWaypointsChanged.emit(this._eventFromPick())}_redrawConnection(){this._connection.setLine(this._connection.line),this._connection.redraw()}_eventFromPick(){return new lc(this._connection.fId(),this._connection.fWaypoints()?.waypoints()||[])}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})(),D0=(()=>{let t=class pr{_dragContext=d(G);get _fDragHandler(){return this._dragContext.draggableItems[0]}handle(e){this._isDroppedConnectionReassignEvent()&&this._fDragHandler.onPointerUp()}_isDroppedConnectionReassignEvent(){return this._dragContext.draggableItems.some(e=>e instanceof uc)}static \u0275fac=function(n){return new(n||pr)};static \u0275prov=f({token:pr,factory:pr.\u0275fac})};return t=p([_(dc)],t),t})(),hc=class{event;fTrigger;static fToken=Symbol("DragConnectionWaypointPreparationRequest");constructor(i,e){this.event=i,this.fTrigger=e}},T0=(()=>{let t=class _r{_mediator=d(b);_store=d(C);_dragContext=d(G);_dragInjector=d(we);get _canvas(){return this._store.fCanvas}get _transform(){return this._canvas.transform}get _flowHost(){return this._store.flowHost}get _connections(){return this._store.connections.getAll()}handle(e){let n=mn(e.event.getPosition(),this._flowHost,this._transform),o=this._pickControlPoint(n);if(!o||!this._isValidTrigger(e))return;let r=this._dragInjector.get(uc);r.setPick(o),this._dragContext.onPointerDownScale=this._transform.scale,this._dragContext.onPointerDownPosition=B.fromPoint(e.event.getPosition()).elementTransform(this._flowHost).div(this._transform.scale),this._dragContext.draggableItems=[r],queueMicrotask(()=>this._updateConnectionLayer(o.connection))}_pickControlPoint(e){if(this._dragContext.isEmpty())return e_(this._connections,e)}_isValidTrigger(e){return Ae(e.event.originalEvent,e.fTrigger)}_updateConnectionLayer(e){this._mediator.execute(new Ht(e,this._canvas.fConnectionsContainer().nativeElement))}static \u0275fac=function(n){return new(n||_r)};static \u0275prov=f({token:_r,factory:_r.\u0275fac})};return t=p([_(hc)],t),t})(),P0=[y0,v0,C0,m0,w0,b0,x0,E0,T0,D0],fc=class{event;static fToken=Symbol("DropToGroupFinalizeRequest");constructor(i){this.event=i}},M0=1,Yn=(()=>{class t extends Te{type="move-node-to-parent";kind="assign-to-container";_store=d(C);_dragSession=d(G);get _transform(){return this._store.transform}_candidateGroups=[];_debounceTimer=null;_activeTarget=null;get activeTarget(){return this._activeTarget}initialize(e){this._candidateGroups=e}prepareDragSequence(){for(let{node:e}of this._candidateGroups)e.hostElement.classList.add(pe.GROUPING.DROP_ACTIVE)}onPointerMove(e){this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>this._updateActiveTarget(e),M0)}onPointerUp(){this._clearActiveTarget();for(let{node:e}of this._candidateGroups)e.hostElement.classList.remove(pe.GROUPING.DROP_ACTIVE);this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=null)}_updateActiveTarget(e){let n=this._getPointerInFlow(e),o=this._findTargetUnderPointer(n);o?this._setActiveTarget(o):this._clearActiveTarget()}_getPointerInFlow(e){let n=B.fromPoint(this._dragSession.onPointerDownPosition).add(e),o=B.fromPoint(this._transform.position).add(this._transform.scaledPosition).div(this._transform.scale);return n.sub(o)}_findTargetUnderPointer(e){return this._candidateGroups.find(n=>A.isIncludePoint(n.rect,e))}_setActiveTarget(e){this._activeTarget?.node!==e.node&&(this._clearActiveTarget(),this._activeTarget=e,e.node.setClass(pe.GROUPING.OVER_BOUNDARY))}_clearActiveTarget(){this._activeTarget?.node.removeClass(pe.GROUPING.OVER_BOUNDARY),this._activeTarget=null}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})(),gc=class{nodesAndGroups;static fToken=Symbol("CreateDragNodeHierarchyRequest");constructor(i){this.nodesAndGroups=i}},uu=class{rootHandlers;participants;constructor(i,e){this.rootHandlers=i,this.participants=e}},hu=class{fNodeIds;constructor(i){this.fNodeIds=i}},zu="move-node",Bu="drag-node";function R0(t){return t.getEvent().kind===Bu||t.getEvent().fEventType===zu}var Ct=(()=>{class t extends Te{type=zu;kind=Bu;data(){return new hu(this.items.map(e=>e.nodeOrGroup.fId()))}_magneticLines=null;_magneticRects=null;items;roots;initialize(e,n){this.items=e,this.roots=n}setMagneticLines(e){this._magneticLines=e}setMagneticRects(e){this._magneticRects=e}calculateMagneticLinesGuides(e){return this.calculateMagneticSnaps(e).lines}calculateMagneticSnaps(e){this._previewRoots(e);let n=this._rootsUnionRect();return{lines:this._magneticLines?._computeGuides(n),rects:this._magneticRects?._computeRects(n)}}prepareDragSequence(){for(let e of this.roots)e.prepareDragSequence()}onPointerMove(e){this._previewRoots(e);let n=this._rootsUnionRect();this._magneticLines?.scheduleRender(n),this._magneticRects?.scheduleRender(n)}onPointerUp(){for(let e of this.roots)e.onPointerUp();this._magneticLines?.clearGuides(),this._magneticRects?.clearGuides(),requestAnimationFrame(()=>this._refreshDraggedNodes())}_previewRoots(e){for(let n of this.roots)n.onPointerMove(e)}_rootsUnionRect(){let e=null;for(let n of this.roots){let o=n.getLastRect();e=e?A.union([e,o]):o}return e??A.initialize()}_refreshDraggedNodes(){for(let{nodeOrGroup:e}of this.roots)e.refresh()}destroy(){for(let e of this.roots??[])e.destroy?.()}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})(),pc=class{_limits;_quantizeStep;constructor(i,e=.5){this._limits=i,this._quantizeStep=e}applyInto(i,e){let{min:n,max:o}=this._limits,r=this._clamp(i.x,n.x,o.x),s=this._clamp(i.y,n.y,o.y),a=i.x-r,c=i.y-s,l=this._quantizeSigned(a,this._quantizeStep),u=this._quantizeSigned(c,this._quantizeStep);e.value.x=r,e.value.y=s,e.edges.left=l<0,e.edges.right=l>0,e.edges.top=u<0,e.edges.bottom=u>0,e.overflow.x=Math.abs(l),e.overflow.y=Math.abs(u)}_quantizeSigned(i,e){if(e<=0||i===0)return 0;let n=i/e;return(i>0?Math.ceil(n):Math.floor(n))*e}_clamp(i,e,n){return Math.min(Math.max(i,e),n)}},fu=class{_pointerDown;_vCellSize;_hCellSize;_snapWhileDragging;constructor(i,e){this._pointerDown=e,this._vCellSize=i.vCellSize(),this._hCellSize=i.hCellSize(),this._snapWhileDragging=i.fCellSizeWhileDragging()}snap(i,e){let n=e||this._snapWhileDragging;return this._strategies[+n](i)}_strategies={0:this._noSnap.bind(this),1:this._snapWithCellSize.bind(this)};_snapWithCellSize(i){return{x:this._snapToGrid(this._pointerDown.x+i.x,this._hCellSize)-this._pointerDown.x,y:this._snapToGrid(this._pointerDown.y+i.y,this._vCellSize)-this._pointerDown.y}}_noSnap(i){return i}_snapToGrid(i,e){return Math.round(i/e)*e}};function jh(){return{value:{x:0,y:0},overflow:{x:0,y:0},edges:{left:!1,right:!1,top:!1,bottom:!1}}}var gu=class{_snapper;_hardClamp;_hardResult=jh();_softClamps=[];_softResults=[];constructor(i,e,n){let o=i.get(C).fDraggable;this._snapper=new fu(o,e),this._hardClamp=new pc(n.hard,.5);for(let r of n.soft)this._softClamps.push(new pc(r.limits,.5)),this._softResults.push(jh())}apply(i,e=!1){let n=this._snapper.snap(i,e);this._hardClamp.applyInto(n,this._hardResult);let o={x:this._hardResult.value.x,y:this._hardResult.value.y};for(let r=0;r<this._softClamps.length;r++)this._softClamps[r].applyInto(o,this._softResults[r]);return{hardDelta:o,soft:this._softResults}}finalize(i){return this.apply(i,!0)}};function Hh(t,i,e){let{x:n,y:o,width:r,height:s}=t;return e.right&&i.x>0&&(r+=i.x),e.left&&i.x>0&&(n-=i.x,r+=i.x),e.bottom&&i.y>0&&(s+=i.y),e.top&&i.y>0&&(o-=i.y,s+=i.y),A.initialize(n,o,r,s)}var pu=class extends Te{_injector;nodeOrGroup;children;sourceConnectionHandlers;targetConnectionHandlers;type=zu;kind=Bu;_startPosition=E.initialize();_startRect=A.initialize();_applyConstraints=i=>i;_lastSoftResults=[];_deltaConstraints;_constraints;_lastPosition=E.initialize();_softParentConnectionHandlers=[];_mediator;constructor(i,e,n=[],o=[],r=[]){super(),this._injector=i,this.nodeOrGroup=e,this.children=n,this.sourceConnectionHandlers=o,this.targetConnectionHandlers=r,this._mediator=i.get(b),this._startRect=this._mediator.execute(new ie(e.hostElement)),this._startPosition=W({},e._position)}setConstraints(i){this._constraints=i,this._deltaConstraints=new gu(this._injector,this._startPosition,i),this._applyConstraints=e=>{let n=this._deltaConstraints.apply(e);return this._applySoftExpansions(n.soft),n.hardDelta}}setSoftParentConnectionHandlers(i){this._softParentConnectionHandlers=i}finalizeConstraints(){this._applyConstraints=i=>{let e=this._deltaConstraints.finalize(i);return this._applySoftExpansions(e.soft),e.hardDelta}}getLastRect(){return A.initialize(this._lastPosition.x,this._lastPosition.y,this._startRect.width,this._startRect.height)}prepareDragSequence(){for(let i of this.children)i.prepareDragSequence();this.nodeOrGroup.hostElement.classList.add(pe.DRAG_AND_DROP.DRAGGING)}onPointerMove(i){let e=this._applyConstraints(i);for(let n of this.children)n.onPointerMove(e);this._redraw(this._startPlus(e));for(let n of this.sourceConnectionHandlers)n.setSourceDelta(e);for(let n of this.targetConnectionHandlers)n.setTargetDelta(e)}onPointerUp(){for(let i of this.children)i.onPointerUp();this.nodeOrGroup.position.set(this.nodeOrGroup._position),this.nodeOrGroup.hostElement.classList.remove(pe.DRAG_AND_DROP.DRAGGING),this._emitExpandedEvent()}_startPlus(i){return E.sum(this._startPosition,i)}_redraw(i){this._lastPosition=i,this.nodeOrGroup.updatePosition(i),this._mediator.execute(new Lt(this.nodeOrGroup.fId(),A.initialize(i.x,i.y,this._startRect.width,this._startRect.height))),this.nodeOrGroup.redraw()}_applySoftExpansions(i){this._lastSoftResults=i;for(let e=0;e<i.length;e++){let n=i[e],o=this._constraints.soft[e],r=Hh(o.boundingRect,n.overflow,n.edges);this._commitParentRect(o.nodeOrGroup,r)&&this._updateParentConnectionHandlers(e)}}_commitParentRect(i,e){let n=i._position.x!==e.x||i._position.y!==e.y||i._size?.width!==e.width||i._size?.height!==e.height;return i.updateSize({width:e.width,height:e.height}),i.updatePosition({x:e.x,y:e.y}),this._mediator.execute(new Lt(i.fId(),e)),i.redraw(),n}_updateParentConnectionHandlers(i){let e=this._softParentConnectionHandlers[i];if(!e)return;let n=new Map;for(let o of e.source){let r=this._readConnectorRect(o.connector,n);o.handler.setSourceDelta(this._buildDelta(o.baselineRect,r))}for(let o of e.target){let r=this._readConnectorRect(o.connector,n);o.handler.setTargetDelta(this._buildDelta(o.baselineRect,r))}}_readConnectorRect(i,e){let n=`${i.kind}::${i.fId()}`,o=e.get(n);if(o)return o;let r=this._mediator.execute(new Oe(i)).rect;return e.set(n,r),r}_buildDelta(i,e){return E.initialize(e.x-i.x,e.y-i.y)}_emitExpandedEvent(){for(let i=0;i<this._lastSoftResults.length;i++){let e=this._lastSoftResults[i];if(!e.overflow.x&&!e.overflow.y)continue;let n=this._constraints.soft[i],o=Hh(n.boundingRect,e.overflow,e.edges);n.nodeOrGroup.sizeChange.emit(o)}}destroy(){for(let i of this.children)i.destroy?.();this.children=[],this.sourceConnectionHandlers=[],this.targetConnectionHandlers=[],this._lastSoftResults=[],this._applyConstraints=i=>i,this._softParentConnectionHandlers=[]}},N0=(()=>{let t=class mr{_injector=d(Pe);handle({nodesAndGroups:e}){let n=this._createHandlerByNodeId(e),o=this._linkParentsAndCollectRoots(e,n);return new uu(o,Array.from(n.values()))}_createHandlerByNodeId(e){let n=new Map;for(let o of e)n.set(o.fId(),new pu(this._injector,o));return n}_linkParentsAndCollectRoots(e,n){let o=[];for(let r of e){let s=n.get(r.fId());if(!s)continue;let a=r.fParentId(),c=a?n.get(a):void 0;c?c.children.push(s):o.push(s)}return o}static \u0275fac=function(n){return new(n||mr)};static \u0275prov=f({token:mr,factory:mr.\u0275fac})};return t=p([_(gc)],t),t})(),_c=class{nodeOrGroup;static fToken=Symbol("BuildDragNodeConstraintsRequest");constructor(i){this.nodeOrGroup=i}},qn=class{nodeOrGroup;childrenPaddings;static fToken=Symbol("ReadNodeBoundsWithPaddingsRequest");constructor(i,e){this.nodeOrGroup=i,this.childrenPaddings=e}},_u=class{nodeOrGroup;boundingRect;innerRect;paddings;constructor(i,e,n,o){this.nodeOrGroup=i,this.boundingRect=e,this.innerRect=n,this.paddings=o}},k0=(()=>{let t=class yr{_mediator=d(b);handle({nodeOrGroup:e,childrenPaddings:n}){let o=this._readBoundingRect(e),r=this._readOwnPaddings(e,o),s=[r[0]+n[0],r[1]+n[1],r[2]+n[2],r[3]+n[3]],a=A.initialize(o.x+s[0],o.y+s[1],o.width-s[0]-s[2],o.height-s[1]-s[3]);return new _u(e,o,a,s)}_readBoundingRect(e){return this._mediator.execute(new ie(e.hostElement))}_readOwnPaddings(e,n){return this._mediator.execute(new jt(e,n))}static \u0275fac=function(n){return new(n||yr)};static \u0275prov=f({token:yr,factory:yr.\u0275fac})};return t=p([_(qn)],t),t})(),O0=(()=>{let t=class vr{_mediator=d(b);handle({nodeOrGroup:e}){let n=this._readCurrentRect(e),o=this._readParentsChain(e);return this._buildConstraints(o,n)}_readCurrentRect(e){return this._mediator.execute(new ie(e.hostElement))}_readParentsChain(e){return this._mediator.execute(new un(e))??[]}_buildConstraints(e,n){let o=[],r=yf(),s=[0,0,0,0];for(let a of e){let c=this._readParentBounds(a,s);s=c.paddings;let l=this._calculateDifference(c.innerRect,n);if(this._isAutoExpand(a))o.push(this._makeSoftLimit(a,c.boundingRect,l));else{r=l;break}}return{soft:o,hard:r}}_readParentBounds(e,n){return this._mediator.execute(new qn(e,n))}_calculateDifference(e,n){return{min:this._calculateMinimumDifference(e,n),max:this._calculateMaximumDifference(e,n)}}_calculateMinimumDifference(e,n){return E.initialize(e.x-n.x,e.y-n.y)}_calculateMaximumDifference(e,n){return E.initialize(e.x+e.width-(n.x+n.width),e.y+e.height-(n.y+n.height))}_isAutoExpand(e){return e.fAutoExpandOnChildHit()}_makeSoftLimit(e,n,o){return{nodeOrGroup:e,boundingRect:n,initialSize:e._size,limits:o}}static \u0275fac=function(n){return new(n||vr)};static \u0275prov=f({token:vr,factory:vr.\u0275fac})};return t=p([_(_c)],t),t})(),mc=class{rootHandlers;participants;static fToken=Symbol("CreateDragNodeHandlerRequest");constructor(i,e){this.rootHandlers=i,this.participants=e}},yc=class{dragHandler;constraints;handlerPool;static fToken=Symbol("AttachSoftParentConnectionDragHandlersToNodeRequest");constructor(i,e,n){this.dragHandler=i,this.constraints=e,this.handlerPool=n}},Xn=class{_mediator=d(b);_store=d(C);_behaviour=d(_n);_source;_target;_sourceRef;_targetRef;_sourceDelta=E.initialize();_targetDelta=E.initialize();connection;initialize(i){this.connection=i,this._source=this._store.outputs.require(this.connection.fOutputId()),this._target=this._store.inputs.require(this.connection.fInputId()),this._sourceRef=this._readRectRef(this._source),this._targetRef=this._readRectRef(this._target)}setSourceDelta(i){this._sourceDelta=i,this._mediator.execute(new At(this._source.fId(),this._source.kind,this._withDelta(this._sourceRef.rect,i)))}setTargetDelta(i){this._targetDelta=i,this._mediator.execute(new At(this._target.fId(),this._target.kind,this._withDelta(this._targetRef.rect,i)))}redraw(){let i=this._buildLine();this.connection.setLine(i),this.connection.redraw()}_buildLine(){let i=ae.fromRoundedRect(this._sourceRef.rect).addPoint(this._sourceDelta),e=ae.fromRoundedRect(this._targetRef.rect).addPoint(this._targetDelta);return this._behaviour.handle(new He(i,e,this.connection,this._sourceRef.connector.fConnectableSide,this._targetRef.connector.fConnectableSide,this._resolveRotationContext(this._sourceRef.connector),this._resolveRotationContext(this._targetRef.connector)))}_readRectRef(i){return this._mediator.execute(new Oe(i))}_withDelta(i,e){return ae.fromRoundedRect(i).addPoint(e)}_resolveRotationContext(i){return this._mediator.execute(new ct(i))}},Kn=(()=>{class t extends Xn{setSourceDelta(e){super.setSourceDelta(e),super.redraw()}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})(),Zn=(()=>{class t extends Xn{_sourceUpdated=!1;_targetUpdated=!1;setSourceDelta(e){super.setSourceDelta(e),this._sourceUpdated=!0,this._redrawIfReady()}setTargetDelta(e){super.setTargetDelta(e),this._targetUpdated=!0,this._redrawIfReady()}_redrawIfReady(){!this._sourceUpdated||!this._targetUpdated||(this._sourceUpdated=!1,this._targetUpdated=!1,this.redraw())}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})(),Qn=(()=>{class t extends Xn{setTargetDelta(e){super.setTargetDelta(e),this.redraw()}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})(),F0=(()=>{let t=class Cr{_store=d(C);_mediator=d(b);_dragInjector=d(we);handle({dragHandler:e,constraints:n,handlerPool:o}){let r=n.soft.map(s=>this._buildParentConnectionHandlers(s.nodeOrGroup,o));e.setSoftParentConnectionHandlers(r)}_buildParentConnectionHandlers(e,n){let o=this._store.outputs.getAll().filter(u=>u.fNodeId===e.fId()),r=this._store.inputs.getAll().filter(u=>u.fNodeId===e.fId());if(!o.length&&!r.length)return{source:[],target:[]};let s=new Set(o.map(u=>u.fId())),a=new Set(r.map(u=>u.fId())),c=new Map,l={source:[],target:[]};for(let u of this._store.connections.getAll()){let h=s.has(u.fOutputId()),v=a.has(u.fInputId());if(!h&&!v)continue;let w=this._getExistingConnectionHandler(n,u);if(w||(w=this._createConnectionHandler(u,h,v),n.push(w)),h){let S=this._store.outputs.require(u.fOutputId());l.source.push({handler:w,connector:S,baselineRect:this._readConnectorRect(S,c)})}if(v){let S=this._store.inputs.require(u.fInputId());l.target.push({handler:w,connector:S,baselineRect:this._readConnectorRect(S,c)})}}return l}_getExistingConnectionHandler(e,n){return e.find(o=>o.connection.fId()===n.fId())}_createConnectionHandler(e,n,o){let r;return n&&o?r=this._dragInjector.createInstance(Zn):n?r=this._dragInjector.createInstance(Kn):r=this._dragInjector.createInstance(Qn),r.initialize(e),r}_readConnectorRect(e,n){let o=`${e.kind}::${e.fId()}`,r=n.get(o);if(r)return r;let s=this._mediator.execute(new Oe(e)).rect;return n.set(o,s),s}static \u0275fac=function(n){return new(n||Cr)};static \u0275prov=f({token:Cr,factory:Cr.\u0275fac})};return t=p([_(yc)],t),t})(),A0=(()=>{let t=class wr{_dragInjector=d(we);_mediator=d(b);handle({rootHandlers:e,participants:n}){let o=this._collectConnectionHandlers(n);this._applyConstraintsToRoots(e,o);let r=this._dragInjector.createInstance(Ct);return r.initialize(n,e),r}_applyConstraintsToRoots(e,n){for(let o of e){let r=this._calculateConstraints(o.nodeOrGroup);o.setConstraints(r),this._attachSoftParentConnectionHandlers(o,r,n)}}_collectConnectionHandlers(e){let n=new Map;for(let o of e){for(let r of o.sourceConnectionHandlers)n.set(r.connection.fId(),r);for(let r of o.targetConnectionHandlers)n.set(r.connection.fId(),r)}return Array.from(n.values())}_attachSoftParentConnectionHandlers(e,n,o){this._mediator.execute(new yc(e,n,o))}_calculateConstraints(e){return this._mediator.execute(new _c(e))}static \u0275fac=function(n){return new(n||wr)};static \u0275prov=f({token:wr,factory:wr.\u0275fac})};return t=p([_(mc)],t),t})(),vc=class{dragHandler;sourceIds;handlerPool;static fToken=Symbol("AttachTargetConnectionDragHandlersToNodeRequest");constructor(i,e,n){this.dragHandler=i,this.sourceIds=e,this.handlerPool=n}},L0=(()=>{let t=class br{_store=d(C);_dragInjector=d(we);get _connections(){return this._store.connections.getAll()}handle(e){this._getInputConnections(e.dragHandler.nodeOrGroup).forEach(n=>{this._createAndSetConnectionToNodeHandler(n,e)})}_getInputConnections(e){let n=new Set(this._getNodeInputIds(e));return this._connections.filter(o=>n.has(o.fInputId()))}_getNodeInputIds(e){return this._store.inputs.getAll().filter(n=>e.isContains(n.hostElement)).map(n=>n.fId())}_createAndSetConnectionToNodeHandler(e,n){let o=this._getExistingConnectionHandler(n.handlerPool,e);o||(o=this._createConnectionHandler(n.sourceIds,e),n.handlerPool.push(o)),n.dragHandler.targetConnectionHandlers.push(o)}_getExistingConnectionHandler(e,n){return e.find(o=>o.connection.fId()===n.fId())}_createConnectionHandler(e,n){let o;return e.includes(n.fOutputId())?o=this._dragInjector.createInstance(Zn):o=this._dragInjector.createInstance(Qn),o.initialize(n),o}static \u0275fac=function(n){return new(n||br)};static \u0275prov=f({token:br,factory:br.\u0275fac})};return t=p([_(vc)],t),t})(),Cc=class{dragHandler;targetIds;handlerPool;static fToken=Symbol("AttachSourceConnectionDragHandlersToNodeRequest");constructor(i,e,n){this.dragHandler=i,this.targetIds=e,this.handlerPool=n}},z0=(()=>{let t=class xr{_store=d(C);_dragInjector=d(we);get _connections(){return this._store.connections.getAll()}handle(e){this._getOutputConnections(e.dragHandler.nodeOrGroup).forEach(n=>{this._createAndSetConnectionToNodeHandler(n,e)})}_getOutputConnections(e){let n=new Set(this._getNodeOutputIds(e));return this._connections.filter(o=>n.has(o.fOutputId()))}_getNodeOutputIds(e){return this._store.outputs.getAll().filter(n=>e.isContains(n.hostElement)).map(n=>n.fId())}_createAndSetConnectionToNodeHandler(e,n){let o=this._getExistingConnectionHandler(n.handlerPool,e);o||(o=this._createConnectionHandler(n.targetIds,e),n.handlerPool.push(o)),n.dragHandler.sourceConnectionHandlers.push(o)}_getExistingConnectionHandler(e,n){return e.find(o=>o.connection.fId()===n.fId())}_createConnectionHandler(e,n){let o;return e.includes(n.fInputId())?o=this._dragInjector.createInstance(Zn):o=this._dragInjector.createInstance(Kn),o.initialize(n),o}static \u0275fac=function(n){return new(n||xr)};static \u0275prov=f({token:xr,factory:xr.\u0275fac})};return t=p([_(Cc)],t),t})(),wc=class{nodeOrGroup;static fToken=Symbol("AttachDragNodeHandlerFromSelectionRequest");constructor(i){this.nodeOrGroup=i}},B0=(()=>{let t=class Ir{_mediator=d(b);_store=d(C);_dragSession=d(G);handle({nodeOrGroup:e}){let n=this._collectSelected(e),o=this._withDeepChildren(n),r=this._mediator.execute(new gc(o)),s=this._collectSourceConnectorIds(o),a=this._collectTargetConnectorIds(o);return this._attachConnectionHandlers(r.participants,s,a),this._mediator.execute(new mc(r.rootHandlers,r.participants))}_collectSelected(e){let n=[];for(let o of this._dragSession.selectedItems){let r=this._findNodeByHost(o.hostElement);r&&n.push(r)}return e&&!n.includes(e)&&n.push(e),n}_findNodeByHost(e){return this._store.nodes.getAll().find(n=>n.isContains(e))}_withDeepChildren(e){let n=[];for(let o of e){n.push(o);let r=this._mediator.execute(new pn(o.fId()));n.push(...r)}return n}_collectSourceConnectorIds(e){return ul(e,n=>this._store.outputs.getAll().filter(o=>o.fNodeId===n.fId()).map(o=>o.fId()))}_collectTargetConnectorIds(e){return ul(e,n=>this._store.inputs.getAll().filter(o=>o.fNodeId===n.fId()).map(o=>o.fId()))}_attachConnectionHandlers(e,n,o){let r=[];for(let s of e)this._mediator.execute(new Cc(s,o,r)),this._mediator.execute(new vc(s,n,r))}static \u0275fac=function(n){return new(n||Ir)};static \u0275prov=f({token:Ir,factory:Ir.\u0275fac})};return t=p([_(wc)],t),t})(),G0=[N0,O0,A0,L0,z0,F0,k0,B0];function j0(t,i,e=10){let n=i.x,o=i.y,r=n+i.width,s=o+i.height,a=i.gravityCenter.x,c=i.gravityCenter.y,l,u,h=1/0,v,w,S=1/0,P=(M,k)=>{let H=k<0?-k:k;H<=e&&H<h&&(h=H,l=M,u=k)},L=(M,k)=>{let H=k<0?-k:k;H<=e&&H<S&&(S=H,v=M,w=k)};for(let M=0;M<t.length;M++){let k=t[M],H=k.x,xe=k.y,$=H+k.width,ue=xe+k.height,dt=k.gravityCenter.x,Ue=k.gravityCenter.y;P(H,n-H),P($,n-$),P(dt,a-dt),P(H,r-H),P($,r-$),L(xe,o-xe),L(ue,o-ue),L(Ue,c-Ue),L(xe,s-xe),L(ue,s-ue)}return{x:{guide:l,delta:u},y:{guide:v,delta:w}}}var Vh=["left","top","width","height"],bc=class{_element;constructor(i,e,n="f-line"){this._element=i.document.createElement("div"),this._element.classList.add(n),this._element.style.position="absolute",this._element.style.display="none",e.appendChild(this._element)}show(){this._element.style.display="block"}hide(){this._element.style.display="none"}render(i){for(let e of Vh){let n=i[e];n!=null&&(this._element.style[e]=`${n}px`)}}clearRect(){for(let i of Vh)this._element.style.removeProperty(i)}destroy(){this._element.remove()}},mu=class{_horizontal;_vertical;constructor(i,e){this._horizontal=new bc(i,e),this._vertical=new bc(i,e),this._horizontal.hide(),this._vertical.hide()}drawVerticalLine(i,e,n){this._vertical.show(),this._vertical.render({left:i*n.scale+n.position.x+n.scaledPosition.x,top:0,width:1,height:e.height})}drawHorizontalLine(i,e,n){this._horizontal.show(),this._horizontal.render({left:0,top:i*n.scale+n.position.y+n.scaledPosition.y,width:e.width,height:1})}hideVertical(){this._vertical.hide()}hideHorizontal(){this._horizontal.hide()}hideAll(){this._vertical.hide(),this._horizontal.hide()}destroy(){this._vertical.destroy(),this._horizontal.destroy()}},xc=class{static fToken=Symbol("MagneticLinesPreparationRequest")},H0=(()=>{let t=class Sr{_mediator=d(b);_store=d(C);_browser=d(ce);_injector=d(Pe);_dragSession=d(G);_renderer;handle(e){let n=this._store.instances.get(te.MAGNETIC_LINES);if(!n)return;let o=this._dragSession.draggableItems.find(r=>r instanceof Ct);o&&o.setMagneticLines(new yu(this._injector,this._renderer??this._createRenderer(n),this._flowHostSize(),this._notDraggedRects(this._draggedNodes(o.items))))}_draggedNodes(e){return e.map(n=>n.nodeOrGroup)}_flowHostSize(){return this._store.flowHost.getBoundingClientRect()}_createRenderer({hostElement:e}){return this._renderer=new mu(this._browser,e),this._renderer}_notDraggedRects(e){let n=new Set(e);return this._store.nodes.getAll().filter(r=>!n.has(r)).map(r=>this._mediator.execute(new ie(r.hostElement)))}static \u0275fac=function(n){return new(n||Sr)};static \u0275prov=f({token:Sr,factory:Sr.\u0275fac})};return t=p([_(xc)],t),t})(),yu=class{_renderer;_size;_rects;_timerId=null;_canvasTransform;_alignThreshold=10;constructor(i,e,n,o){this._renderer=e,this._size=n,this._rects=o;let r=i.get(C);this._alignThreshold=r.instances.require(te.MAGNETIC_LINES).threshold(),this._canvasTransform=r.transform}scheduleRender(i){this._timerId&&clearTimeout(this._timerId),this._timerId=setTimeout(()=>this._renderGuides(this._computeGuides(i)),15)}_renderGuides(i){this._renderVertical(i),this._renderHorizontal(i)}_renderVertical(i){i.x.guide!==void 0?this._renderer.drawVerticalLine(i.x.guide,this._size,this._canvasTransform):this._renderer.hideVertical()}_renderHorizontal(i){i.y.guide!==void 0?this._renderer.drawHorizontalLine(i.y.guide,this._size,this._canvasTransform):this._renderer.hideHorizontal()}_computeGuides(i){return j0(this._rects,i,this._alignThreshold)}clearGuides(){this._renderer.hideAll(),this._timerId&&(clearTimeout(this._timerId),this._timerId=null)}},Uh=["top","center","bottom"],Wh=["left","center","right"];function V0(t,i,e=10,n=10){let o=i.x,r=i.y,s=o+i.width,a=r+i.height,c=i.gravityCenter.x,l=i.gravityCenter.y,u=U0(t,i,o,r,s,a,c,l,e,n),h=W0(t,i,o,r,s,a,c,l,e,n);return u&&(!h||u.absDelta<=h.absDelta)?{axis:"x",delta:u.delta,gap:u.gap,rects:u.rects,alignMode:u.alignMode,crossDelta:u.crossDelta}:h?{axis:"y",delta:h.delta,gap:h.gap,rects:h.rects,alignMode:h.alignMode,crossDelta:h.crossDelta}:{rects:[]}}function U0(t,i,e,n,o,r,s,a,c,l){let u=1/0,h,v=0,w,S=[],P=0,L=[],M=[],k=[];for(let H=0;H<Uh.length;H++){let xe=H===0?n:H===1?a:r;L.length=0,M.length=0,k.length=0;let $=1/0,ue=-1/0,dt=0,Ue=1/0,Cn=1/0;for(let q=0;q<t.length;q++){let U=t[q],bn=H===0?U.y:H===1?U.gravityCenter.y:U.y+U.height,tl=xe-bn,tt=Jt(tl);if(tt>c)continue;L.push(q),M.push(U.x),k.push(U.x+U.width);let xn=U.y,In=U.y+U.height;xn<$&&($=xn),In>ue&&(ue=In),(tt<Ue||tt===Ue&&q<Cn)&&(Ue=tt,dt=bn,Cn=q)}let Ce=L.length;if(Ce<2)continue;Pf(L,M,k);let de=0;for(;de<Ce&&M[de]<=s;)de++;let xt=de>0&&de<Ce,Ie,Re;xt?(Ie=de-1,Re=de):de<=0?(Ie=0,Re=1):(Ie=Ce-2,Re=Ce-1);let Ne=M[Re]-k[Ie];if(Ne<0)continue;let _e;if(xt){_e=k[Ie]+Ne;let q=_e+i.width,U=M[Re]-q;if(Jt(U-Ne)>l)continue}else de<=0?_e=M[0]-Ne-i.width:_e=k[Ce-1]+Ne;let wn=e-_e,It=Jt(wn);if(It>l||It>=u)continue;let Le=$0(L,M,k,$,ue);if(xt){let q=_e,U=_e+i.width;Le.push({left:k[Ie],top:$,width:q-k[Ie],height:ue-$}),Le.push({left:U,top:$,width:M[Re]-U,height:ue-$})}else if(de<=0){let q=_e+i.width;Le.push({left:q,top:$,width:M[0]-q,height:ue-$})}else Le.push({left:k[Ce-1],top:$,width:_e-k[Ce-1],height:ue-$});let el=xe-dt;u=It,h=wn,v=Ne,w=Uh[H],S=Le,P=el}if(!(h===void 0||w===void 0))return{delta:h,absDelta:u,gap:v,rects:S,alignMode:w,crossDelta:P}}function W0(t,i,e,n,o,r,s,a,c,l){let u=1/0,h,v=0,w,S=[],P=0,L=[],M=[],k=[];for(let H=0;H<Wh.length;H++){let xe=H===0?e:H===1?s:o;L.length=0,M.length=0,k.length=0;let $=1/0,ue=-1/0,dt=0,Ue=1/0,Cn=1/0;for(let q=0;q<t.length;q++){let U=t[q],bn=H===0?U.x:H===1?U.gravityCenter.x:U.x+U.width,tl=xe-bn,tt=Jt(tl);if(tt>c)continue;L.push(q),M.push(U.y),k.push(U.y+U.height);let xn=U.x,In=U.x+U.width;xn<$&&($=xn),In>ue&&(ue=In),(tt<Ue||tt===Ue&&q<Cn)&&(Ue=tt,dt=bn,Cn=q)}let Ce=L.length;if(Ce<2)continue;Pf(L,M,k);let de=0;for(;de<Ce&&M[de]<=a;)de++;let xt=de>0&&de<Ce,Ie,Re;xt?(Ie=de-1,Re=de):de<=0?(Ie=0,Re=1):(Ie=Ce-2,Re=Ce-1);let Ne=M[Re]-k[Ie];if(Ne<0)continue;let _e;if(xt){_e=k[Ie]+Ne;let q=_e+i.height,U=M[Re]-q;if(Jt(U-Ne)>l)continue}else de<=0?_e=M[0]-Ne-i.height:_e=k[Ce-1]+Ne;let wn=n-_e,It=Jt(wn);if(It>l||It>=u)continue;let Le=Y0(L,M,k,$,ue);if(xt){let q=_e,U=_e+i.height;Le.push({left:$,top:k[Ie],width:ue-$,height:q-k[Ie]}),Le.push({left:$,top:U,width:ue-$,height:M[Re]-U})}else if(de<=0){let q=_e+i.height;Le.push({left:$,top:q,width:ue-$,height:M[0]-q})}else Le.push({left:$,top:k[Ce-1],width:ue-$,height:_e-k[Ce-1]});let el=xe-dt;u=It,h=wn,v=Ne,w=Wh[H],S=Le,P=el}if(!(h===void 0||w===void 0))return{delta:h,absDelta:u,gap:v,rects:S,alignMode:w,crossDelta:P}}function $0(t,i,e,n,o){let r=[],s=o-n;for(let a=0;a<t.length-1;a++){let c=i[a+1]-e[a];c<0||r.push({left:e[a],top:n,width:c,height:s})}return r}function Y0(t,i,e,n,o){let r=[],s=o-n;for(let a=0;a<t.length-1;a++){let c=i[a+1]-e[a];c<0||r.push({left:n,top:e[a],width:s,height:c})}return r}function Pf(t,i,e){for(let n=1;n<i.length;n++){let o=i[n],r=e[n],s=t[n],a=n-1;for(;a>=0;){let c=i[a],l=t[a];if(c<o||c===o&&l<s)break;i[a+1]=c,e[a+1]=e[a],t[a+1]=l,a--}i[a+1]=o,e[a+1]=r,t[a+1]=s}}function Jt(t){return t<0?-t:t}var vu=class{_element;_isVisible=!1;_left=Number.NaN;_top=Number.NaN;_width=Number.NaN;_height=Number.NaN;constructor(i,e,n="f-rect"){this._element=i.document.createElement("div"),this._element.classList.add(n);let o=this._element.style;o.position="absolute",o.display="none",o.boxSizing="border-box",o.pointerEvents="none",e.appendChild(this._element)}show(){this._isVisible||(this._isVisible=!0,this._element.style.display="block")}hide(){this._isVisible&&(this._isVisible=!1,this._element.style.display="none")}render(i,e,n,o){let r=this._element.style;i!==this._left&&(this._left=i,r.left=i+"px"),e!==this._top&&(this._top=e,r.top=e+"px"),n!==this._width&&(this._width=n,r.width=n+"px"),o!==this._height&&(this._height=o,r.height=o+"px")}clearRect(){this._left=Number.NaN,this._top=Number.NaN,this._width=Number.NaN,this._height=Number.NaN;let i=this._element.style;i.removeProperty("left"),i.removeProperty("top"),i.removeProperty("width"),i.removeProperty("height")}destroy(){this._element.remove()}},Cu=class{_browser;_hostElement;_className;_pool=[];_activeCount=0;constructor(i,e,n="f-rect"){this._browser=i,this._hostElement=e,this._className=n}draw(i,e){let n=e.scale,o=e.position.x+e.scaledPosition.x,r=e.position.y+e.scaledPosition.y;for(let s=0;s<i.length;s++){let a=this._getOrCreate(s),c=i[s];a.show(),a.render(c.left*n+o,c.top*n+r,c.width*n,c.height*n)}for(let s=i.length;s<this._activeCount;s++)this._pool[s].hide();this._activeCount=i.length}hideAll(){for(let i=0;i<this._activeCount;i++)this._pool[i].hide();this._activeCount=0}destroy(){for(let i of this._pool)i.destroy();this._pool.length=0,this._activeCount=0}_getOrCreate(i){if(i<this._pool.length)return this._pool[i];let e=new vu(this._browser,this._hostElement,this._className);return this._pool.push(e),e}},Ic=class{static fToken=Symbol("MagneticRectsPreparationRequest")},q0=(()=>{let t=class Er{_mediator=d(b);_store=d(C);_browser=d(ce);_injector=d(Pe);_dragSession=d(G);_renderer;handle(e){let n=this._store.instances.get(te.MAGNETIC_RECTS);if(!n)return;let o=this._dragSession.draggableItems.find(r=>r instanceof Ct);o&&o.setMagneticRects(new wu(this._injector,this._getRenderer(n),this._notDraggedRects(this._draggedNodes(o.items))))}_draggedNodes(e){return e.map(n=>n.nodeOrGroup)}_getRenderer(e){return this._renderer||(this._renderer=new Cu(this._browser,e.hostElement)),this._renderer?.destroy(),this._renderer}_notDraggedRects(e){let n=new Set(e);return this._store.nodes.getAll().filter(r=>!n.has(r)).map(r=>this._mediator.execute(new ie(r.hostElement)))}static \u0275fac=function(n){return new(n||Er)};static \u0275prov=f({token:Er,factory:Er.\u0275fac})};return t=p([_(Ic)],t),t})(),wu=class{_renderer;_rects;_timerId=null;_canvasTransform;_alignThreshold=10;_spacingThreshold=10;constructor(i,e,n){this._renderer=e,this._rects=n;let o=i.get(C),r=o.instances.require(te.MAGNETIC_RECTS);this._alignThreshold=r.alignThreshold(),this._spacingThreshold=r.spacingThreshold(),this._canvasTransform=o.transform}scheduleRender(i){this._timerId&&clearTimeout(this._timerId),this._timerId=setTimeout(()=>this._renderRects(this._computeRects(i)),15)}_renderRects(i){if(i.axis!==void 0&&i.delta!==void 0&&i.rects.length>0){this._renderer.draw(i.rects,this._canvasTransform);return}this._renderer.hideAll()}_computeRects(i){return V0(this._rects,i,this._alignThreshold,this._spacingThreshold)}clearGuides(){this._renderer.hideAll(),this._timerId&&(clearTimeout(this._timerId),this._timerId=null)}},Sc=class{event;static fToken=Symbol("DragNodeFinalizeRequest");constructor(i){this.event=i}},bu=class{nodes;fNodes;constructor(i){this.nodes=i,this.fNodes=i}},X0=(()=>{let t=class Dr{_mediator=d(b);_store=d(C);_dragSession=d(G);_dragHandler;handle({event:e}){if(this._dragHandler=this._getDragHandler(),!this._dragHandler)return;let n=this._buildDragDelta(e.getPosition()),o=this._dragHandler.calculateMagneticSnaps(n),r=this._applySnapToDelta(n,o.lines,o.rects);this._finalizeMove(this._dragHandler,r),this._emitNodeIntersectIfNeeded(this._dragHandler)}_getDragHandler(){return this._dragSession.draggableItems.find(R0)}_buildDragDelta(e){return B.fromPoint(e).elementTransform(this._store.flowHost).div(this._dragSession.onPointerDownScale).sub(this._dragSession.onPointerDownPosition)}_applySnapToDelta(e,n,o){let r=e.x,s=e.y;return n&&(r=this._hasLineSnapValue(n.x)?e.x-(n.x.delta||0):r,s=this._hasLineSnapValue(n.y)?e.y-(n.y.delta||0):s),this._hasRectSnapValue(o)&&(o.axis==="x"?(r=e.x-o.delta,s=e.y-(o.crossDelta??0)):(s=e.y-o.delta,r=e.x-(o.crossDelta??0))),{x:r,y:s}}_hasLineSnapValue(e){return e.guide!==void 0&&e.guide!==null}_hasRectSnapValue(e){return!!e&&e.axis!==void 0&&e.delta!==void 0}_finalizeMove(e,n){for(let o of e.roots)o.finalizeConstraints();e.onPointerMove(n),e.onPointerUp?.(),this._store.fDraggable?.fMoveNodes.emit(this._buildMoveNodesEvent(e))}_buildMoveNodesEvent(e){let n=e.getEvent(),s=((n.data??n.fData)?.fNodeIds??[]).map(a=>({id:a,position:this._store.nodes.get(a)?._position}));return new bu(s)}_emitNodeIntersectIfNeeded(e){if(!this._isDraggedJustOneNode(e)||!this._store.fDraggable?.fEmitOnNodeIntersect)return;let n=e.roots[0].nodeOrGroup;queueMicrotask(()=>this._mediator.execute(new Xa(n)))}_isDraggedJustOneNode(e){return e.roots.length===1}static \u0275fac=function(n){return new(n||Dr)};static \u0275prov=f({token:Dr,factory:Dr.\u0275fac})};return t=p([_(Sc)],t),t})(),Ec=class{event;trigger;static fToken=Symbol("DragNodePreparationRequest");constructor(i,e){this.event=i,this.trigger=e}},K0=(()=>{let t=class Tr{_mediator=d(b);_store=d(C);_dragSession=d(G);handle({event:e,trigger:n}){if(!this._canStartDrag(e,n))return;let o=this._findDraggableNode(e.targetElement);o&&(this._storePointerDownContext(e),this._dragSession.draggableItems=[this._buildDragNodeHandler(o)],this._mediator.execute(new xc),this._mediator.execute(new Ic))}_canStartDrag(e,n){return this._dragSession.isEmpty()&&this._isDragHandle(e.targetElement)&&Ae(e.originalEvent,n)}_isDragHandle(e){return Tn(e,".f-drag-handle")}_findDraggableNode(e){let n=this._store.nodes.getAll();for(let o of n)if(!o.fDraggingDisabled()&&o.isContains(e))return o}_storePointerDownContext(e){this._dragSession.onPointerDownScale=this._store.transform.scale,this._dragSession.onPointerDownPosition=B.fromPoint(e.getPosition()).elementTransform(this._store.flowHost).div(this._store.transform.scale)}_buildDragNodeHandler(e){return(e.fSelectionDisabled()||!e.isSelected())&&queueMicrotask(()=>{this._mediator.execute(new gn(e))}),this._mediator.execute(new wc(e))}static \u0275fac=function(n){return new(n||Tr)};static \u0275prov=f({token:Tr,factory:Tr.\u0275fac})};return t=p([_(Ec)],t),t})(),Z0=[...G0,H0,q0,X0,K0],xu=class{targetGroupId;nodeIds;dropPosition;fTargetNode;fNodes;fDropPosition;constructor(i,e,n){this.targetGroupId=i,this.nodeIds=e,this.dropPosition=n,this.fTargetNode=i,this.fNodes=e,this.fDropPosition=n}},Q0=(()=>{let t=class Pr{_dragSession=d(G);_store=d(C);handle({event:e}){let n=this._findDropHandler();if(!n)return;let o=n.activeTarget?.node;o&&this._emitDropToGroupEvent(o.fId(),e),n.onPointerUp?.()}_findDropHandler(){return this._dragSession.draggableItems.find(e=>e instanceof Yn)}_emitDropToGroupEvent(e,n){this._store.fDraggable?.fDropToGroup.emit(new xu(e,this._getTopLevelDraggedIds(),n.getPosition()))}_getTopLevelDraggedIds(){let n=this._getMoveSummaryHandler().items.map(s=>s.nodeOrGroup),o=new Set(n.map(s=>s.fId())),r=[];for(let s of n){let a=s.fParentId();(!a||!o.has(a))&&r.push(s.fId())}return r}_getMoveSummaryHandler(){let e=this._dragSession.draggableItems.find(n=>n instanceof Ct);if(!e)throw new Error("DropToGroup requires DragNodeHandler.");return e}static \u0275fac=function(n){return new(n||Pr)};static \u0275prov=f({token:Pr,factory:Pr.\u0275fac})};return t=p([_(fc)],t),t})(),Dc=class{event;static fToken=Symbol("DropToGroupPreparationRequest");constructor(i){this.event=i}},Tc=class{candidates;static fToken=Symbol("SortDropCandidatesByLayerRequest");constructor(i){this.candidates=i}},J0=(()=>{let t=class Mr{handle({candidates:e}){let n=e.map((o,r)=>({candidate:o,index:r}));return n.sort((o,r)=>{let s=this._compareDomOrder(o.candidate.node.hostElement,r.candidate.node.hostElement);return s!==0?-s:o.index-r.index}),n.map(o=>o.candidate)}_compareDomOrder(e,n){if(e===n)return 0;let o=e.compareDocumentPosition(n);if((o&Node.DOCUMENT_POSITION_FOLLOWING)!==0)return-1;if((o&Node.DOCUMENT_POSITION_PRECEDING)!==0)return 1;if(o&Node.DOCUMENT_POSITION_DISCONNECTED){let r=e.getBoundingClientRect?.()??{top:0,left:0},s=n.getBoundingClientRect?.()??{top:0,left:0};return r.top!==s.top?r.top<s.top?-1:1:r.left!==s.left?r.left<s.left?-1:1:0}return 0}static \u0275fac=function(n){return new(n||Mr)};static \u0275prov=f({token:Mr,factory:Mr.\u0275fac})};return t=p([_(Tc)],t),t})(),Iu=class{_onPointerDown;_limit;_vCellSize;_hCellSize;_adjustCellSize;constructor(i,e,n){this._onPointerDown=e,this._limit=n;let o=i.get(C);this._vCellSize=o.fDraggable.vCellSize(),this._hCellSize=o.fDraggable.hCellSize(),this._adjustCellSize=o.fDraggable.fCellSizeWhileDragging()}limit(i){let{min:e,max:n}=this._limit,{x:o,y:r}=this._cellSizeStrategies[+this._adjustCellSize](i);return{x:this._clamp(o,e.x,n.x),y:this._clamp(r,e.y,n.y)}}_cellSizeStrategies={0:this._skipCellSize.bind(this),1:this._applyCellSize.bind(this)};_applyCellSize(i){return{x:this._snapToGrid(this._onPointerDown.x+i.x,this._hCellSize)-this._onPointerDown.x,y:this._snapToGrid(this._onPointerDown.y+i.y,this._vCellSize)-this._onPointerDown.y}}_skipCellSize(i){return i}_clamp(i,e,n){return Math.min(Math.max(i,e),n)}_snapToGrid(i,e){return Math.round(i/e)*e}},Pc=class{externalItem;static fToken=Symbol("DragExternalItemCreatePlaceholderRequest");constructor(i){this.externalItem=i}},ey=(()=>{let t=class Rr{_browser=d(ce);_containerRef=d(Ci);handle({externalItem:e}){let{hostElement:n,placeholder:o}=e,r=o(),s=r?this._fromTemplate(r):this._fromHost(n);return s.classList.add("f-external-item-placeholder"),s.style.pointerEvents="none",s}_fromTemplate(e){return gl(this._createViewRef(e),this._browser.document)}_fromHost(e){return hl(e)}_createViewRef(e){let n=this._containerRef.createEmbeddedView(e);return n.detectChanges(),n}static \u0275fac=function(n){return new(n||Rr)};static \u0275prov=f({token:Rr,factory:Rr.\u0275fac})};return t=p([_(Pc)],t),t})(),Mc=class{externalItem;static fToken=Symbol("DragExternalItemCreatePreviewRequest");constructor(i){this.externalItem=i}},ty=(()=>{let t=class Nr{_browser=d(ce);_containerRef=d(Ci);handle({externalItem:e}){let{hostElement:n,preview:o}=e,r=o(),s=r?this._fromTemplate(r):this._fromHost(n);return this._setPreviewStyles(s),Ih(s),s.classList.add("f-external-item-preview"),s}_fromTemplate(e){return gl(this._createViewRef(e),this._browser.document)}_fromHost(e){return hl(e)}_createViewRef(e){let n=this._containerRef.createEmbeddedView(e);return n.detectChanges(),n}_setPreviewStyles(e){fl(e.style,{"pointer-events":"none",margin:"showPopover"in e?"0 auto 0 0":"0",position:"fixed",top:"0",left:"0","z-index":"1000"},new Set(["position"]))}static \u0275fac=function(n){return new(n||Nr)};static \u0275prov=f({token:Nr,factory:Nr.\u0275fac})};return t=p([_(Mc)],t),t})(),Rc=class{event;static fToken=Symbol("DragExternalItemFinalizeRequest");constructor(i){this.event=i}},Su=class{externalItemRect;data;targetContainerId;dropPosition;rect;fTargetNode;fDropPosition;constructor(i,e,n,o){this.externalItemRect=i,this.data=e,this.targetContainerId=n,this.dropPosition=o,this.rect=i,this.fTargetNode=n,this.fDropPosition=o}},ny="external-item",iy="drag-external-item";function oy(t){return t.getEvent().kind===iy||t.getEvent().fEventType===ny}var ry=(()=>{let t=class kr{_result=d(wt);_mediator=d(b);_store=d(C);_dragSession=d(G);_browser=d(ce);get _createNodeEmitter(){return this._store.fDraggable?.fCreateNode}handle(e){let n=this._findExternalItemHandler();if(!n)return;let o=this._getDestinationNodeOrGroupId();this._emitEvent(this._getElementsFromPoint(e.event.getPosition()),o,e.event.getPosition()),n.onPointerUp(),this._dragSession.draggableItems=[]}_findExternalItemHandler(){return this._dragSession.draggableItems.find(e=>oy(e))}_getDestinationNodeOrGroupId(){let e=this._getDropToGroupHandler(),n=e.activeTarget?.node.fId();return e.onPointerUp?.(),n}_getDropToGroupHandler(){let e=this._dragSession.draggableItems.find(n=>n instanceof Yn);if(!e)throw new Error("NodeDragToParentDragHandler not found");return e}_getElementsFromPoint(e){return this._browser.document.elementsFromPoint(e.x,e.y).filter(n=>!n.closest(".f-external-item")&&!n.closest(".f-external-item-preview"))}_emitEvent(e,n,o){this._isPointerInCanvasRect(e)&&this._createNodeEmitter?.emit(new Su(this._getPreviewRect(),this._result.getData().externalItem.data(),n,n?o:void 0))}_isPointerInCanvasRect(e){return e.length?this._store.flowHost.contains(e[0]):!1}_getPreviewRect(){return this._mediator.execute(new ie(this._result.getData().preview))}static \u0275fac=function(n){return new(n||kr)};static \u0275prov=f({token:kr,factory:kr.\u0275fac})};return t=p([_(Rc)],t),t})(),Eu=class{data;constructor(i){this.data=i}},Nc=class extends Te{_externalItem;_pointerDownClientPosition;type="external-item";kind="drag-external-item";data(){return new Eu(this._externalItem.data())}_result;_mediator;_browser;_store;_previewEl;_placeholderEl;_startRect=A.initialize();_pointerDownRect=A.initialize();_absoluteOffsetFromFlow=E.initialize();_grabOffsetFromPointer=E.initialize();_originalParent;_originalNextSibling;_originalDisplay;_applyConstraints=i=>i;constructor(i,e,n){super(),this._externalItem=e,this._pointerDownClientPosition=n,this._store=i.get(C),this._result=i.get(wt),this._mediator=i.get(b),this._browser=i.get(ce),this._originalDisplay=this._host.style.display,this._initConstraints(i)}get _host(){return this._externalItem.hostElement}get _overlayRoot(){return this._browser.document.fullscreenElement??this._browser.document.body}get _transform(){return this._store.transform}_initConstraints(i){this._startRect=this._getStartRect();let e=new Iu(i,this._startRect,yf());this._applyConstraints=n=>e.limit(n)}_getStartRect(){return this._mediator.execute(new ie(this._externalItem.hostElement))}prepareDragSequence(){this._pointerDownRect=this._readAbsoluteRect(this._host),this._absoluteOffsetFromFlow=B.fromPoint(this._pointerDownRect).sub(this._toAbsolutePoint(this._startRect)),this._grabOffsetFromPointer=this._clientToAbsolute(this._pointerDownClientPosition).sub(this._pointerDownRect),this._rememberOriginalPlacement(),this._previewEl=this._createPreview(),this._placeholderEl=this._createPlaceholder(),this._placePreviewIntoOverlay(),this._swapOriginalWithPlaceholderAndMoveOriginalIntoOverlay(),this._result.setData({preview:this._previewEl,externalItem:this._externalItem})}_rememberOriginalPlacement(){let i=this._host.parentNode;if(!i){this._originalParent=void 0,this._originalNextSibling=null;return}this._originalParent=i,this._originalNextSibling=this._host.nextSibling}_createPreview(){let i=this._mediator.execute(new Mc(this._externalItem));return this._externalItem.previewMatchSize()&&this._matchSize(i,this._pointerDownRect),i.style.transform=$h(this._pointerDownRect),i}_createPlaceholder(){return this._mediator.execute(new Pc(this._externalItem))}_placePreviewIntoOverlay(){this._overlayRoot.appendChild(this._previewEl)}_swapOriginalWithPlaceholderAndMoveOriginalIntoOverlay(){let i=this._originalParent,e=this._placeholderEl;if(!i||!e)return;let n=i.replaceChild(e,this._host);this._overlayRoot.appendChild(n),this._host.style.display="none"}onPointerMove(i,e){if(!this._previewEl)return;let n=this._resolveDeltaFromPointer(i,e),o=this._applyConstraints(n),r=B.fromPoint(this._startRect).add(o),s=this._toAbsolutePoint(r).add(this._absoluteOffsetFromFlow);this._previewEl.style.transform=$h(s)}onPointerUp(){this._previewEl&&this._previewEl.parentNode&&this._previewEl.parentNode.removeChild(this._previewEl),this._restoreOriginalInParent(),this._host.style.display=this._originalDisplay||"block",this._previewEl=void 0,this._placeholderEl=void 0,this._originalParent=void 0,this._originalNextSibling=null}_restoreOriginalInParent(){let i=this._originalParent,e=this._placeholderEl;if(!(!i||!e)){if(e.parentNode===i){i.replaceChild(this._host,e);return}this._originalNextSibling&&this._originalNextSibling.parentNode===i?i.insertBefore(this._host,this._originalNextSibling):i.appendChild(this._host)}}_matchSize(i,e){i.style.width=`${e.width}px`,i.style.height=`${e.height}px`}_readAbsoluteRect(i){let e=i.getBoundingClientRect(),n=this._browser.window.pageYOffset||this._browser.document.documentElement.scrollTop,o=this._browser.window.pageXOffset||this._browser.document.documentElement.scrollLeft;return A.initialize(e.left+o,e.top+n,e.width,e.height)}_toAbsolutePoint(i){let e=B.fromPoint(this._transform.position).add(this._transform.scaledPosition);return B.fromPoint(i).mult(this._transform.scale).add(e).add(this._getFlowHostAbsolutePosition())}_resolveDeltaFromPointer(i,e){let n=e?.getPosition();if(!n)return i;let o=this._clientToAbsolute(n).sub(this._grabOffsetFromPointer),r=this._toFlowPoint(o);return B.fromPoint(r).sub(this._startRect)}_toFlowPoint(i){let e=this._getFlowHostAbsolutePosition(),n=B.fromPoint(this._transform.position).add(this._transform.scaledPosition);return B.fromPoint(i).sub(e).sub(n).div(this._transform.scale)}_getFlowHostAbsolutePosition(){let i=this._store.flowHost.getBoundingClientRect(),e=this._browser.window.pageYOffset||this._browser.document.documentElement.scrollTop,n=this._browser.window.pageXOffset||this._browser.document.documentElement.scrollLeft;return E.initialize(i.left+n,i.top+e)}_clientToAbsolute(i){let e=this._browser.window.pageYOffset||this._browser.document.documentElement.scrollTop,n=this._browser.window.pageXOffset||this._browser.document.documentElement.scrollLeft;return B.fromPoint(i).add(E.initialize(n,e))}};function $h({x:t,y:i}){return`translate3d(${Math.round(t)}px, ${Math.round(i)}px, 0)`}var kc=class{event;fTrigger;static fToken=Symbol("DragExternalItemPreparationRequest");constructor(i,e){this.event=i,this.fTrigger=e}};function sy(t){return!!t.closest?.("[fExternalItem]")}function ay(t){return t.closest("[fExternalItem]")}var cy=(()=>{class t{_byHost=new Map;_items=J([]);items=z(()=>this._items());getByElement(e){let n=ay(e);return n?this._byHost.get(n):void 0}getByHost(e){return this._byHost.get(e)}register(e){let n=e.hostElement,o=this._byHost.get(n);o!==e&&(o&&o!==e&&this._byHost.delete(n),this._byHost.set(n,e),this._sync())}remove(e){let n=e.hostElement;this._byHost.get(n)===e&&(this._byHost.delete(n),this._sync())}_sync(){this._items.set([...this._byHost.values()])}static \u0275fac=function(n){return new(n||t)};static \u0275prov=f({token:t,factory:t.\u0275fac,providedIn:"root"})}return t})();var dy=(()=>{let t=class Or{_apiService=d(cy);_dragSession=d(G);_store=d(C);_injector=d(Pe);get _flowHost(){return this._store.flowHost}get _transform(){return this._store.transform}handle({event:e,fTrigger:n}){if(!this._dragSession.isEmpty()||!Ae(e.originalEvent,n))return;let o=this._resolveExternalItem(e.targetElement);if(!o||o.disabled())return;let r=this._transform.scale??1;this._dragSession.onPointerDownScale=r,this._dragSession.onPointerDownPosition=B.fromPoint(e.getPosition()).elementTransform(this._flowHost).div(r),this._dragSession.draggableItems=[new Nc(this._injector,o,e.getPosition())]}_resolveExternalItem(e){return this._apiService.getByElement(e)}static \u0275fac=function(n){return new(n||Or)};static \u0275prov=f({token:Or,factory:Or.\u0275fac})};return t=p([_(kc)],t),t})(),Oc=class{event;static fToken=Symbol("PreventDefaultIsExternalItemRequest");constructor(i){this.event=i}},ly=(()=>{let t=class Fr{handle(e){this._isTargetItemExternal(e.event)&&e.event.preventDefault()}_isTargetItemExternal(e){let n=this._isExternalItem(e.target),o=this._isExternalItem(e.target.parentNode);return n||o}_isExternalItem(e){let n=!1;try{n=sy(e)}catch{}return n}static \u0275fac=function(n){return new(n||Fr)};static \u0275prov=f({token:Fr,factory:Fr.\u0275fac})};return t=p([_(Oc)],t),t})(),uy=[ey,ty,ry,dy,ly],hy=(()=>{let t=class Ar{_mediator=d(b);_dragContext=d(G);_store=d(C);_dragInjector=d(we);get _allNodes(){return this._store.nodes.getAll()}handle({event:e}){if(!this._canPrepare())return;let n=this._allNodes.find(s=>s.isContains(e.targetElement));if(!n&&!this._hasExternalDrag())throw new Error("Drag target node not found");let o=this._sortedTargetsForDrop();if(n){let s=n.fParentId(),a=this._mediator.execute(new ld(s));a.length&&(o=o.filter(c=>a.includes(c.node.fId())))}let r=this._dragInjector.get(Yn);r.initialize(o),this._dragContext.draggableItems.push(r)}_canPrepare(){return this._hasMoveDrag()||this._hasExternalDrag()}_hasMoveDrag(){return this._dragContext.draggableItems.some(e=>e instanceof Ct)}_hasExternalDrag(){return this._dragContext.draggableItems.some(e=>e instanceof Nc)}_sortedTargetsForDrop(){let e=this._getDraggedNodes(),n=e.some(a=>a instanceof ru),o=this._withParents(e),s=this._eligibleTargets(o,n).map(a=>{let c=this._mediator.execute(new ie(a.hostElement));return{node:a,rect:c}});return this._mediator.execute(new Tc(s))}_getDraggedNodes(){let e=this._dragContext.draggableItems.find(n=>n instanceof Ct);return e?e.items.map(n=>n.nodeOrGroup):[]}_withParents(e){return e.reduce((n,o)=>{n.push(o);let r=this._mediator.execute(new un(o));return n.push(...r),n},[])}_eligibleTargets(e,n){let o=this._allNodes.filter(r=>!e.includes(r));return n?o.filter(r=>r instanceof ru):o}static \u0275fac=function(n){return new(n||Ar)};static \u0275prov=f({token:Ar,factory:Ar.\u0275fac})};return t=p([_(Dc)],t),t})(),fy=[J0,hy,Q0],Fc=class{event;static fToken=Symbol("PinchToZoomFinalizeRequest");constructor(i){this.event=i}},gy=.5,Ac=(()=>{class t extends Te{type="pinch-to-zoom";kind="pinch-to-zoom";_store=d(C);get _flowHost(){return this._store.flowHost}get _canvas(){return this._store.fCanvas}get _zoomComponent(){return this._store.instances.require(te.ZOOM)}_startDistance=null;_startScale=null;_touches;initialize(e){this._touches=e}prepareDragSequence(){let e=Yh(this._touches);e!=null&&(this._startDistance=e,this._startScale=this._canvas.transform.scale)}onPointerMove(e,n){if(n.touches.length!==2||this._startDistance==null||this._startScale==null)return;let o=Yh(n.touches),r=py(n.touches);if(o==null||r==null){this._reset();return}if(Math.abs(o-this._startDistance)<gy)return;n.preventDefault();let s=o/this._startDistance,a=this._clamp(this._startScale*s);this._canvas.setScale(a,this._castPositionToFlow(r)),this._canvas.redraw()}_clamp(e){return Math.max(this._zoomComponent.minimum,Math.min(e,this._zoomComponent.maximum))}_castPositionToFlow(e){return B.fromPoint(e).elementTransform(this._flowHost)}_reset(){this._startScale=null,this._startDistance=null}onPointerUp(){this._reset(),this._canvas.emitCanvasChangeEvent()}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})();function py(t){if(t.length!==2)return null;let i=t[0],e=t[1];return E.initialize((i.clientX+e.clientX)/2,(i.clientY+e.clientY)/2)}function Yh(t){if(t.length!==2)return null;let i=t[0],e=t[1];return Math.hypot(e.clientX-i.clientX,e.clientY-i.clientY)}var _y=(()=>{let t=class Lr{_dragSession=d(G);handle(e){if(this._hasPinchZoomHandler())for(let n of this._dragSession.draggableItems)n.onPointerUp?.()}_hasPinchZoomHandler(){return this._dragSession.draggableItems.some(e=>e instanceof Ac)}static \u0275fac=function(n){return new(n||Lr)};static \u0275prov=f({token:Lr,factory:Lr.\u0275fac})};return t=p([_(Fc)],t),t})(),Lc=class{event;static fToken=Symbol("PinchToZoomPreparationRequest");constructor(i){this.event=i}},my=(()=>{let t=class zr{_dragInjector=d(we);_store=d(C);_dragSession=d(G);handle({event:e}){this._canStart(e)&&(this._dragSession.onPointerDownScale=1,this._dragSession.onPointerDownPosition=new B,this._dragSession.draggableItems=[this._getHandler(e)])}_canStart(e){return this._dragSession.isEmpty()&&e.touches?.length===2&&!e.isEventInLockedContext&&this._hasZoomComponent()}_hasZoomComponent(){return this._store.instances.has(te.ZOOM)}_getHandler(e){let n=this._dragInjector.get(Ac);return n.initialize(e.touches),n}static \u0275fac=function(n){return new(n||zr)};static \u0275prov=f({token:zr,factory:zr.\u0275fac})};return t=p([_(Lc)],t),t})(),yy=[my,_y],zc=class{event;static fToken=Symbol("SelectionAreaFinalizeRequest");constructor(i){this.event=i}},vy=(()=>{let t=class Br{_dragSession=d(G);handle(e){this._isValid()&&this._dragSession.draggableItems.forEach(n=>{n.onPointerUp?.()})}_isValid(){return this._dragSession.draggableItems.some(e=>e.getEvent().kind==="selection-area")}static \u0275fac=function(n){return new(n||Br)};static \u0275prov=f({token:Br,factory:Br.\u0275fac})};return t=p([_(zc)],t),t})(),Du=(()=>{class t extends Te{type="selection-area";kind="selection-area";_store=d(C);_dragSession=d(G);_mediator=d(b);_canBeSelected=[];_selectedByMove=[];get _transform(){return this._store.transform}get _canvasPosition(){return B.fromPoint(this._transform.position).add(this._transform.scaledPosition)}get _instance(){return this._store.instances.require(te.SELECTION_AREA)}prepareDragSequence(){this._canBeSelected=this._mediator.execute(new bd),this._show(),this._draw(A.initialize(this._dragSession.onPointerDownPosition.x,this._dragSession.onPointerDownPosition.y))}onPointerMove(e){let n=B.fromPoint(e).add(this._dragSession.onPointerDownPosition),o=this._getMinimumPoint(this._dragSession.onPointerDownPosition,n),r=Math.abs(e.x),s=Math.abs(e.y),a=A.initialize(o.x,o.y,r,s);this._draw(a),this._selectedByMove=[],this._canBeSelected.forEach(c=>{c.element.unmarkAsSelected();let l=A.addPoint(A.mult(c.fRect,this._transform.scale),this._canvasPosition);A.intersectionWithRect(l,a)&&(c.element.markAsSelected(),this._selectedByMove.push(c.element))}),this._mediator.execute(new mt)}_getMinimumPoint(e,n){return E.initialize(Math.min(e.x,n.x),Math.min(e.y,n.y))}onPointerUp(){this._hide(),this._dragSession.selectedItems.push(...this._selectedByMove),this._selectedByMove.length>0&&(this._dragSession.isSelectedChanged=!0)}_draw(e){let n=this._instance.hostElement.style;n.left=e.x+"px",n.top=e.y+"px",n.width=e.width+"px",n.height=e.height+"px"}_show(){this._instance.hostElement.style.display="block"}_hide(){this._instance.hostElement.style.display="none"}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})(),Bc=class{event;static fToken=Symbol("SelectionAreaPreparationRequest");constructor(i){this.event=i}},Cy=(()=>{let t=class Gr{_store=d(C);_dragSession=d(G);_dragInjector=d(we);get _instance(){return this._store.instances.get(te.SELECTION_AREA)}handle(e){this._isValid(e)&&(this._dragSession.onPointerDownScale=1,this._dragSession.onPointerDownPosition=B.fromPoint(e.event.getPosition()).elementTransform(this._store.flowHost),this._dragSession.draggableItems=[this._dragInjector.createInstance(Du)])}_isValid(e){return!!this._instance&&this._dragSession.isEmpty()&&Ae(e.event.originalEvent,this._instance.fTrigger)}static \u0275fac=function(n){return new(n||Gr)};static \u0275prov=f({token:Gr,factory:Gr.\u0275fac})};return t=p([_(Bc)],t),t})(),wy=[Cy,vy],Gc=class{rect;childrenBounds;static fToken=Symbol("ApplyChildResizeConstraintsRequest");constructor(i,e){this.rect=i,this.childrenBounds=e}},by=(()=>{let t=class jr{handle({rect:e,childrenBounds:n}){n&&this._apply(e,n)}_apply(e,n){this._restrictLeft(e,n),this._restrictTop(e,n),this._restrictRight(e,n),this._restrictBottom(e,n),e.width=Math.max(0,e.width),e.height=Math.max(0,e.height)}_restrictLeft(e,n){let o=e.x-n.x;o>0&&(e.x-=o,e.width+=o)}_restrictTop(e,n){let o=e.y-n.y;o>0&&(e.y-=o,e.height+=o)}_restrictRight(e,n){let o=n.x+n.width;e.x+e.width<=o&&(e.width=o-e.x)}_restrictBottom(e,n){let o=n.y+n.height;e.y+e.height<=o&&(e.height=o-e.y)}static \u0275fac=function(n){return new(n||jr)};static \u0275prov=f({token:jr,factory:jr.\u0275fac})};return t=p([_(Gc)],t),t})(),jc=class{rect;limits;static fToken=Symbol("ApplyParentResizeConstraintsRequest");constructor(i,e){this.rect=i,this.limits=e}},xy=(()=>{let t=class Hr{_mediator=d(b);handle({rect:e,limits:n}){this._applyResizeConstraints(e,n)}_applyResizeConstraints(e,n){if(!n)return;let o=this._clampedCopyForCalculation(e,n);this._applySoftParentExpansions(o,n.softLimits),n.hardLimit&&this._clampRectToInner(e,n.hardLimit.innerRect)}_clampedCopyForCalculation(e,n){let o=W({},e);return n.hardLimit&&this._clampRectToInner(o,n.hardLimit.innerRect),o}_clampRectToInner(e,n){if(e.x<n.x){let s=n.x-e.x;e.x+=s,e.width-=s}if(e.y<n.y){let s=n.y-e.y;e.y+=s,e.height-=s}let o=n.x+n.width;e.x+e.width>o&&(e.width=o-e.x);let r=n.y+n.height;e.y+e.height>r&&(e.height=r-e.y),e.width=Math.max(0,e.width),e.height=Math.max(0,e.height)}_applySoftParentExpansions(e,n){if(n?.length)for(let o of n)this._expandParentFromOriginalIfOverflow(e,o)}_expandParentFromOriginalIfOverflow(e,n){let o=n.innerRect,r=n.boundingRect,s=this._computeOverflow(o,e);if(!this._hasOverflow(s)){this._applyParentRect(n,r);return}let a=this._buildExpandedParentRect(r,s);this._applyParentRect(n,a)}_hasOverflow(e){return!!(e.left||e.top||e.right||e.bottom)}_computeOverflow(e,n){let o=Math.max(0,e.x-n.x),r=Math.max(0,e.y-n.y),s=Math.max(0,n.x+n.width-(e.x+e.width)),a=Math.max(0,n.y+n.height-(e.y+e.height));return{left:o,top:r,right:s,bottom:a}}_buildExpandedParentRect(e,n){let o=W({},e);return n.left&&(o.x=e.x-n.left,o.width=e.width+n.left),n.top&&(o.y=e.y-n.top,o.height=e.height+n.top),n.right&&(o.width=(o.width??e.width)+n.right),n.bottom&&(o.height=(o.height??e.height)+n.bottom),o}_applyParentRect(e,n){e.nodeOrGroup.updatePosition(n),e.nodeOrGroup.updateSize(n),this._mediator.execute(new Lt(e.nodeOrGroup.fId(),n)),e.nodeOrGroup.redraw()}static \u0275fac=function(n){return new(n||Hr)};static \u0275prov=f({token:Hr,factory:Hr.\u0275fac})};return t=p([_(jc)],t),t})(),Hc=class{originalRect;difference;handleType;minimumSize;static fToken=Symbol("CalculateChangedRectFromDifferenceRequest");constructor(i,e,n,o){this.originalRect=i,this.difference=e,this.handleType=n,this.minimumSize=o}},qh={[Ke.LEFT]:{x:-1,y:0},[Ke.LEFT_TOP]:{x:-1,y:-1},[Ke.TOP]:{x:0,y:-1},[Ke.RIGHT_TOP]:{x:1,y:-1},[Ke.RIGHT]:{x:1,y:0},[Ke.RIGHT_BOTTOM]:{x:1,y:1},[Ke.BOTTOM]:{x:0,y:1},[Ke.LEFT_BOTTOM]:{x:-1,y:1}},Iy=(()=>{let t=class Vr{handle({originalRect:e,difference:n,handleType:o,minimumSize:r}){let s=this._changeSizeInRect(e,n,qh[o],r);return this._changePosition(e,n,qh[o],s)}_changeSizeInRect(e,n,o,r){let s=e.width+o.x*n.x,a=e.height+o.y*n.y,c=0,l=0;return s<0&&(c=s,s=Math.abs(s)),s<r.width&&(o.x===-1&&(c+=s-r.width),s=r.width),a<0&&(l=a,a=Math.abs(a)),a<r.height&&(o.y===-1&&(l+=a-r.height),a=r.height),A.initialize(c,l,s,a)}_changePosition(e,n,o,r){let s=e.x+(o.x===-1?n.x:0)+r.x,a=e.y+(o.y===-1?n.y:0)+r.y;return A.initialize(s,a,r.width,r.height)}static \u0275fac=function(n){return new(n||Vr)};static \u0275prov=f({token:Vr,factory:Vr.\u0275fac})};return t=p([_(Hc)],t),t})(),Vc=class{nodeOrGroup;paddings;static fToken=Symbol("CalculateDirectChildrenUnionRectRequest");constructor(i,e){this.nodeOrGroup=i,this.paddings=e}},Sy=(()=>{let t=class Ur{_mediator=d(b);_store=d(C);get _allNodesAndGroups(){return this._store.nodes.getAll()}handle({nodeOrGroup:e,paddings:n}){let o=A.union(this._calculateDirectChildren(e.fId()).map(r=>this._normalizeRect(r)));return o?this._concatRectWithParentPadding(o,n):null}_calculateDirectChildren(e){return this._allNodesAndGroups.filter(n=>n.fParentId()===e)}_normalizeRect(e){return this._mediator.execute(new ie(e.hostElement))}_concatRectWithParentPadding(e,n){return A.initialize(e.x-n[0],e.y-n[1],e.width+n[0]+n[2],e.height+n[1]+n[3])}static \u0275fac=function(n){return new(n||Ur)};static \u0275prov=f({token:Ur,factory:Ur.\u0275fac})};return t=p([_(Vc)],t),t})(),Jn=class{nodeOrGroup;rect;static fToken=Symbol("CalculateResizeLimitsRequest");constructor(i,e){this.nodeOrGroup=i,this.rect=e}},Ey=(()=>{let t=class Wr{_mediator=d(b);handle({nodeOrGroup:e,rect:n}){let o=this._getParentsChain(e),r=this._calculateNodePaddings(e,n);return{limits:this._buildSoftHardLimits(o),childrenBounds:this._getNormalizedChildrenBounds(e,r),minimumSize:Ge.initialize(r[0]+r[2],r[1]+r[3])}}_calculateNodePaddings(e,n){return this._mediator.execute(new jt(e,n))}_getNormalizedChildrenBounds(e,n){return this._mediator.execute(new Vc(e,n))}_getParentsChain(e){return this._mediator.execute(new un(e))??[]}_buildSoftHardLimits(e){let n=[],o,r=[0,0,0,0];for(let s of e){let a=this._getParentInfo(s,r);if(r=a.paddings,this._isAutoExpand(s))n.push(this._makeLimit(s,a));else{o=this._makeLimit(s,a);break}}return{softLimits:n,hardLimit:o}}_getParentInfo(e,n){return this._mediator.execute(new qn(e,n))}_isAutoExpand(e){return e.fAutoExpandOnChildHit()}_makeLimit(e,{boundingRect:n,innerRect:o}){return{nodeOrGroup:e,boundingRect:n,innerRect:o}}static \u0275fac=function(n){return new(n||Wr)};static \u0275prov=f({token:Wr,factory:Wr.\u0275fac})};return t=p([_(Jn)],t),t})(),Uc=class{event;static fToken=Symbol("ResizeNodeFinalizeRequest");constructor(i){this.event=i}},Mf="node-resize",Rf="resize-node";function Dy(t){return t.getEvent().kind===Rf||t.getEvent().fEventType===Mf}var Ty=(()=>{let t=class $r{_dragSession=d(G);handle(e){this._isNodeResizeHandler()&&this._dragSession.draggableItems.forEach(n=>n.onPointerUp?.())}_isNodeResizeHandler(){return this._dragSession.draggableItems.some(e=>Dy(e))}static \u0275fac=function(n){return new(n||$r)};static \u0275prov=f({token:$r,factory:$r.\u0275fac})};return t=p([_(Uc)],t),t})(),Tu=class{fNodeId;constructor(i){this.fNodeId=i}},Pu=(()=>{class t extends Te{type=Mf;kind=Rf;data(){return new Tu(this._nodeOrGroup.fId())}_mediator=d(b);_baselineRect;_constraints;_lastRect=null;_nodeOrGroup;_handleType;_nodeConnections={source:[],target:[]};_softParentConnections=[];initialize(e,n){this._nodeOrGroup=e,this._handleType=n}setNodeConnectionHandlers(e){this._nodeConnections=e}setSoftParentConnectionHandlers(e){this._softParentConnections=e}prepareDragSequence(){this._baselineRect=this._readBaselineRect(),this._constraints=this._buildConstraints(this._baselineRect),this._lastRect=this._baselineRect}onPointerMove(e){let n=this._calcNextRect(e);this._applyConstraints(n),this._commitRect(n),this._applyConnectionHandlers(this._nodeConnections);for(let o of this._softParentConnections)this._applyConnectionHandlers(o);this._lastRect=n}onPointerUp(){let e=this._lastRect??this._fallbackRectFromModel();this._nodeOrGroup.sizeChange.emit(e),requestAnimationFrame(()=>this._nodeOrGroup.refresh())}_readBaselineRect(){return this._mediator.execute(new ie(this._nodeOrGroup.hostElement))}_buildConstraints(e){return this._mediator.execute(new Jn(this._nodeOrGroup,e))}_calcNextRect(e){return this._mediator.execute(new Hc(this._baselineRect,e,this._handleType,this._constraints.minimumSize))}_applyConstraints(e){this._mediator.execute(new Gc(e,this._constraints.childrenBounds)),this._mediator.execute(new jc(e,this._constraints.limits))}_commitRect(e){this._nodeOrGroup.updatePosition({x:e.x,y:e.y}),this._nodeOrGroup.updateSize({width:e.width,height:e.height}),this._mediator.execute(new Lt(this._nodeOrGroup.fId(),e)),this._nodeOrGroup.redraw()}_fallbackRectFromModel(){return A.initialize(this._nodeOrGroup._position.x,this._nodeOrGroup._position.y,this._nodeOrGroup._size?.width,this._nodeOrGroup._size?.height)}_applyConnectionHandlers(e){if(!e.source.length&&!e.target.length)return;let n=new Map;for(let o of e.source){let r=this._readConnectorRect(o.connector,n);o.handler.setSourceRect(r)}for(let o of e.target){let r=this._readConnectorRect(o.connector,n);o.handler.setTargetRect(r)}}_readConnectorRect(e,n){let o=`${e.kind}::${e.fId()}`,r=n.get(o);if(r)return r;let s=this._mediator.execute(new yt(e.hostElement,!1));return n.set(o,s),s}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})(),ei=class{_mediator=d(b);_store=d(C);_behaviour=d(_n);_source;_target;_sourceRef;_targetRef;_sourceRect;_targetRect;connection;initialize(i){this.connection=i,this._source=this._store.outputs.require(this.connection.fOutputId()),this._target=this._store.inputs.require(this.connection.fInputId()),this._sourceRef=this._readRectRef(this._source),this._targetRef=this._readRectRef(this._target),this._sourceRect=ae.fromRoundedRect(this._sourceRef.rect),this._targetRect=ae.fromRoundedRect(this._targetRef.rect)}setSourceRect(i){this._sourceRect=ae.fromRoundedRect(i),this._mediator.execute(new At(this._source.fId(),this._source.kind,this._sourceRect))}setTargetRect(i){this._targetRect=ae.fromRoundedRect(i),this._mediator.execute(new At(this._target.fId(),this._target.kind,this._targetRect))}redraw(){let i=this._buildLine();this.connection.setLine(i),this.connection.redraw()}_buildLine(){let i=ae.fromRoundedRect(this._sourceRect),e=ae.fromRoundedRect(this._targetRect);return this._behaviour.handle(new He(i,e,this.connection,this._sourceRef.connector.fConnectableSide,this._targetRef.connector.fConnectableSide,this._resolveRotationContext(this._sourceRef.connector),this._resolveRotationContext(this._targetRef.connector)))}_readRectRef(i){return{connector:i,rect:this._mediator.execute(new yt(i.hostElement,!1))}}_resolveRotationContext(i){return this._mediator.execute(new ct(i))}},Py=(()=>{class t extends ei{_sourceUpdated=!1;_targetUpdated=!1;setSourceRect(e){super.setSourceRect(e),this._sourceUpdated=!0,this._redrawIfReady()}setTargetRect(e){super.setTargetRect(e),this._targetUpdated=!0,this._redrawIfReady()}_redrawIfReady(){!this._sourceUpdated||!this._targetUpdated||(this._sourceUpdated=!1,this._targetUpdated=!1,super.redraw())}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})(),My=(()=>{class t extends ei{setSourceRect(e){super.setSourceRect(e),super.redraw()}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})(),Ry=(()=>{class t extends ei{setTargetRect(e){super.setTargetRect(e),super.redraw()}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})(),Wc=class{event;fTrigger;static fToken=Symbol("ResizeNodePreparationRequest");constructor(i,e){this.event=i,this.fTrigger=e}},$c=class{handler;nodeOrGroup;static fToken=Symbol("AttachResizeConnectionDragHandlersToNodeRequest");constructor(i,e){this.handler=i,this.nodeOrGroup=e}},Ny=(()=>{let t=class Yr{_store=d(C);_mediator=d(b);_dragInjector=d(we);handle({handler:e,nodeOrGroup:n}){let o=this._readSoftParents(n),r=[n,...o],s=this._collectSourceConnectorIds(r),a=this._collectTargetConnectorIds(r),c=new Map;e.setNodeConnectionHandlers(this._buildConnectionHandlersForNode(n,s,a,c)),e.setSoftParentConnectionHandlers(o.map(l=>this._buildConnectionHandlersForNode(l,s,a,c)))}_readSoftParents(e){let n=this._mediator.execute(new ie(e.hostElement));return this._mediator.execute(new Jn(e,n)).limits.softLimits.map(r=>r.nodeOrGroup)}_collectSourceConnectorIds(e){let n=new Set(e.map(o=>o.fId()));return new Set(this._store.outputs.getAll().filter(o=>n.has(o.fNodeId)).map(o=>o.fId()))}_collectTargetConnectorIds(e){let n=new Set(e.map(o=>o.fId()));return new Set(this._store.inputs.getAll().filter(o=>n.has(o.fNodeId)).map(o=>o.fId()))}_buildConnectionHandlersForNode(e,n,o,r){let s=this._store.outputs.getAll().filter(h=>h.fNodeId===e.fId()),a=this._store.inputs.getAll().filter(h=>h.fNodeId===e.fId());if(!s.length&&!a.length)return{source:[],target:[]};let c=new Set(s.map(h=>h.fId())),l=new Set(a.map(h=>h.fId())),u={source:[],target:[]};for(let h of this._store.connections.getAll()){let v=c.has(h.fOutputId()),w=l.has(h.fInputId());if(!v&&!w)continue;let S=r.get(h.fId())??this._createConnectionHandler(h,n,o);if(r.set(h.fId(),S),v){let P=this._store.outputs.require(h.fOutputId());u.source.push({handler:S,connector:P})}if(w){let P=this._store.inputs.require(h.fInputId());u.target.push({handler:S,connector:P})}}return u}_createConnectionHandler(e,n,o){let r=n.has(e.fOutputId()),s=o.has(e.fInputId()),a=r&&s?this._dragInjector.createInstance(Py):r?this._dragInjector.createInstance(My):this._dragInjector.createInstance(Ry);return a.initialize(e),a}static \u0275fac=function(n){return new(n||Yr)};static \u0275prov=f({token:Yr,factory:Yr.\u0275fac})};return t=p([_($c)],t),t})(),ky=(()=>{let t=class qr{_mediator=d(b);_store=d(C);_dragSession=d(G);_dragInjector=d(we);get _transform(){return this._store.transform}handle({event:e,fTrigger:n}){if(!this._dragSession.isEmpty()||!this._isResizeHandle(e.targetElement)||!Ae(e.originalEvent,n))return;let o=this._findResizableNode(e.targetElement);if(!o)return;this._selectBeforeResize(o);let r=this._transform.scale??1;this._dragSession.onPointerDownScale=r,this._dragSession.onPointerDownPosition=B.fromPoint(e.getPosition()).elementTransform(this._store.flowHost).div(r);let s=this._dragInjector.createInstance(Pu);s.initialize(o,this._readResizeHandleType(e.targetElement)),this._mediator.execute(new $c(s,o)),this._dragSession.draggableItems=[s]}_isResizeHandle(e){return Tn(e,".f-resize-handle")}_findResizableNode(e){let n=this._store.nodes.getAll().find(o=>o.isContains(e));if(n)return n.fDraggingDisabled()?void 0:n}_selectBeforeResize(e){queueMicrotask(()=>{this._mediator.execute(new gn(e))})}_readResizeHandleType(e){let n=Sh(e,"fResizeHandleType",".f-resize-handle");return Ke[n]}static \u0275fac=function(n){return new(n||qr)};static \u0275prov=f({token:qr,factory:qr.\u0275fac})};return t=p([_(Wc)],t),t})(),Oy=[by,xy,Iy,Sy,Ey,Ny,Ty,ky],Yc=class{event;static fToken=Symbol("RotateNodeFinalizeRequest");constructor(i){this.event=i}},Nf="node-rotate",kf="rotate-node";function Fy(t){return t.getEvent().kind===kf||t.getEvent().fEventType===Nf}var Ay=(()=>{let t=class Xr{_dragSession=d(G);handle(e){this._isValid()&&this._dragSession.draggableItems.forEach(n=>{n.onPointerUp?.()})}_isValid(){return this._dragSession.draggableItems.some(e=>Fy(e))}static \u0275fac=function(n){return new(n||Xr)};static \u0275prov=f({token:Xr,factory:Xr.\u0275fac})};return t=p([_(Yc)],t),t})(),qc=class{event;fTrigger;static fToken=Symbol("RotateNodePreparationRequest");constructor(i,e){this.event=i,this.fTrigger=e}},Mu=class{fNodeId;constructor(i){this.fNodeId=i}};function Ly(t,i,e){let{x:n,y:o}=zy(t,i,e),r=n-t.x,s=o-t.y;return{x:r,y:s}}function zy(t,i,e){let n=t.x-e.x,o=t.y-e.y,r=i*Math.PI/180,s=Math.cos(r),a=Math.sin(r),c=n*s-o*a,l=n*a+o*s,u=c+e.x,h=l+e.y;return{x:u,y:h}}var Ru=(()=>{class t extends Te{type=Nf;kind=kf;data(){return new Mu(this._nodeOrGroup.fId())}_store=d(C);_mediator=d(b);_dragSession=d(G);_nodeOrGroup;_sourceConnections;_targetConnections;_startRotation=0;_nodeRect;_nodeCenter;_pointerDownInFlow;_rotationOffsetDeg=0;get _transform(){return this._store.transform}initialize(e,n,o){this._nodeOrGroup=e,this._sourceConnections=n,this._targetConnections=o,this._startRotation=this._nodeOrGroup._rotate}prepareDragSequence(){this._nodeRect=this._readNodeRect(),this._nodeCenter=this._nodeRect.gravityCenter,this._pointerDownInFlow=this._calculatePointerDownInFlow();let e=this._angleDeg(this._pointerDownInFlow);this._rotationOffsetDeg=e-this._startRotation}onPointerMove(e){let n=E.sum(this._pointerDownInFlow,e),r=this._angleDeg(n)-this._rotationOffsetDeg;this._applyRotation(r);let s=r-this._startRotation;for(let a of this._sourceConnections)a.connection.setSourceDelta(this._deltaAfterRotation(a.connector,s));for(let a of this._targetConnections)a.connection.setTargetDelta(this._deltaAfterRotation(a.connector,s))}onPointerUp(){this._nodeOrGroup.rotate.set(this._nodeOrGroup._rotate),this._nodeOrGroup.refresh()}_readNodeRect(){return this._mediator.execute(new ie(this._nodeOrGroup.hostElement))}_calculatePointerDownInFlow(){return E.sub(this._dragSession.onPointerDownPosition,E.sum(this._transform.position,this._transform.scaledPosition))}_angleDeg(e){return Math.atan2(e.y-this._nodeCenter.y,e.x-this._nodeCenter.x)*(180/Math.PI)}_applyRotation(e){this._nodeOrGroup.updateRotate(e),this._nodeOrGroup.redraw()}_deltaAfterRotation(e,n){return Ly(e,n,this._nodeCenter)}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})(),By=(()=>{let t=class Kr{_mediator=d(b);_store=d(C);_dragContext=d(G);_dragInjector=d(we);get _transform(){return this._store.transform}handle(e){if(!this._isPreparationAllowed(e))return;let n=this._findRotatableNode(e.event.targetElement);if(!n)return;this._selectBeforeRotate(n);let o=this._transform.scale;this._dragContext.onPointerDownScale=o,this._dragContext.onPointerDownPosition=B.fromPoint(e.event.getPosition()).elementTransform(this._store.flowHost).div(o);let r=this._dragInjector.createInstance(Ru);r.initialize(n,this._buildOutputConnectionHandlers(n),this._buildInputConnectionHandlers(n)),this._dragContext.draggableItems=[r]}_isPreparationAllowed({event:e,fTrigger:n}){return this._dragContext.isEmpty()&&c0(e.targetElement)&&Ae(e.originalEvent,n)}_findRotatableNode(e){for(let n of this._store.nodes.getAll())if(!n.fDraggingDisabled()&&n.isContains(e))return n}_selectBeforeRotate(e){queueMicrotask(()=>{this._mediator.execute(new gn(e))})}_buildInputConnectionHandlers(e){return this._mediator.execute(new ed(e)).map(n=>{let o=this._store.inputs.require(n.fInputId()),r=this._mediator.execute(new Oe(o)),s=this._dragInjector.get(Qn);return s.initialize(n),{connection:s,connector:r.rect.gravityCenter}})}_buildOutputConnectionHandlers(e){return this._mediator.execute(new dd(e)).map(n=>{let o=this._store.outputs.require(n.fOutputId()),r=this._mediator.execute(new Oe(o)),s=this._dragInjector.get(Kn);return s.initialize(n),{connection:s,connector:r.rect.gravityCenter}})}static \u0275fac=function(n){return new(n||Kr)};static \u0275prov=f({token:Kr,factory:Kr.\u0275fac})};return t=p([_(qc)],t),t})(),Gy=[Ay,By],ti=class{flowRect;canvasPosition;eventPoint;minimap;static fToken=Symbol("CalculateFlowPointFromMinimapPointRequest");constructor(i,e,n,o){this.flowRect=i,this.canvasPosition=e,this.eventPoint=n,this.minimap=o}},jy=(()=>{let t=class Zr{_store=d(C);get _canvasScale(){return this._store.transform.scale||1}handle(e){return E.sub(e.canvasPosition,E.sub(this._getPositionInViewBox(e.eventPoint,e.minimap),this._getNormalizedFlowCenter(e.flowRect)))}_getNormalizedFlowCenter(e){return B.fromPoint(e.gravityCenter).sub(e)}_getPositionInViewBox(e,n){let o=this.normalizeEventPoint(e,n);return E.sum(o,A.mult(n.viewBox,this._canvasScale))}normalizeEventPoint(e,n){return this._getEventPointInMinimap(e,n).mult(n.scale).mult(this._canvasScale)}_getEventPointInMinimap(e,n){return B.fromPoint(e).elementTransform(n.element)}static \u0275fac=function(n){return new(n||Zr)};static \u0275prov=f({token:Zr,factory:Zr.\u0275fac})};return t=p([_(ti)],t),t})(),Xc=class{event;static fToken=Symbol("DragMinimapFinalizeRequest");constructor(i){this.event=i}},Hy=(()=>{let t=class Qr{_dragSession=d(G);handle(e){this._isValid()&&this._dragSession.draggableItems.forEach(n=>{n.onPointerUp?.()})}_isValid(){return this._dragSession.draggableItems.some(Vy)}static \u0275fac=function(n){return new(n||Qr)};static \u0275prov=f({token:Qr,factory:Qr.\u0275fac})};return t=p([_(Xc)],t),t})(),Of="minimap",Ff="minimap";function Vy(t){return t.getEvent().kind===Ff||t.getEvent().fEventType===Of}var Nu=(()=>{class t extends Te{type=Of;kind=Ff;_store=d(C);_mediator=d(b);_lastDelta=null;_flowRect;_startCanvasPosition;_eventPoint;_minimap;initialize(e,n,o,r){this._flowRect=e,this._startCanvasPosition=n,this._eventPoint=o,this._minimap=r}prepareDragSequence(){this._store.fCanvas?.hostElement.classList.add("f-scaled-animate")}onPointerMove(e){this._lastDelta&&this._isSamePoint(e,this._lastDelta)||(this._lastDelta=e,this._store.fCanvas?.setPosition(this._getNewPosition(B.fromPoint(this._eventPoint).add(e))),this._store.fCanvas?.redraw())}_isSamePoint(e,n){return e.x===n.x&&e.y===n.y}_getNewPosition(e){return this._mediator.execute(new ti(this._flowRect,this._startCanvasPosition,e,this._minimap))}onPointerUp(){this._store.fCanvas?.hostElement.classList.remove("f-scaled-animate"),this._store.fCanvas?.emitCanvasChangeEvent()}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})(),Kc=class{event;static fToken=Symbol("DragMinimapPreparationRequest");constructor(i){this.event=i}},Uy=(()=>{let t=class Jr{_store=d(C);_mediator=d(b);_dragSession=d(G);_dragInjector=d(we);get _canvas(){return this._store.fCanvas}get _flowHost(){return this._store.flowHost}handle({event:e}){if(!this._isValid(e))return;let n=this._store.instances.require(te.MINIMAP).state,o=e.getPosition(),r=B.fromPoint(this._store.transform.position),s=A.fromElement(this._flowHost);this._canvas.setPosition(this._calculateCanvasPosition(s,o,n)),this._canvas.redraw(),this._canvas.emitCanvasChangeEvent(),this._dragSession.onPointerDownScale=1,this._dragSession.onPointerDownPosition=B.fromPoint(o).elementTransform(this._flowHost);let a=this._dragInjector.createInstance(Nu);a.initialize(s,r,o,n),this._dragSession.draggableItems=[a]}_isValid(e){return!(!this._dragSession.isEmpty()||!this._flowHost.contains(e.targetElement)||!e.targetElement.closest(".f-minimap")||!this._store.instances.get(te.MINIMAP))}_calculateCanvasPosition(e,n,o){return this._mediator.execute(new ti(e,B.fromPoint(this._canvas.transform.position),n,o))}static \u0275fac=function(n){return new(n||Jr)};static \u0275prov=f({token:Jr,factory:Jr.\u0275fac})};return t=p([_(Kc)],t),t})(),Wy=[jy,Hy,Uy];function $y(t){return!!t&&typeof t.destroy=="function"}var we=(()=>{class t{_injector=d(Pe);_dragInjector=null;_created=[];create(){this._dragInjector=Pe.create({providers:[{provide:Zc,useClass:Zc},{provide:uc,useClass:uc},{provide:nc,useClass:nc},{provide:lu,useClass:lu},{provide:Yn,useClass:Yn},{provide:Kn,useClass:Kn},{provide:Qn,useClass:Qn},{provide:Zn,useClass:Zn},{provide:Ct,useClass:Ct},{provide:Ac,useClass:Ac},{provide:Du,useClass:Du},{provide:Pu,useClass:Pu},{provide:Ru,useClass:Ru},{provide:Nu,useClass:Nu}],parent:this._injector}),this._created=[]}get(e){if(!this._dragInjector)throw new Error("DragHandlerInjector has not been created. Call create() before using get().");return this._dragInjector.get(e)}createInstance(e){if(!this._dragInjector)throw new Error("DragHandlerInjector is not created");let n=sh(this._dragInjector,()=>new e);return this._created.push(n),n}destroy(){for(let e of this._created)$y(e)&&e.destroy();this._created=[],this._dragInjector?.destroy?.(),this._dragInjector=null}static \u0275fac=function(n){return new(n||t)};static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})(),wt=(()=>{class t{_data;setData(e){this._data=W(W({},this._data),e)}getData(){return this._data}clear(){this._data=void 0}static \u0275fac=function(n){return new(n||t)};static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})(),Xh="f-canvas-dragging",Kh="canvas-dragging",Zc=(()=>{class t extends Te{type="canvas-move";kind="drag-canvas";_store=d(C);_onPointerDownPosition=E.initialize();constructor(){super(),this._store.fCanvas?.hostElement.classList.add(Xh,Kh)}prepareDragSequence(){this._onPointerDownPosition=this._store.transform.position}onPointerMove(e){this._store.fCanvas?.setPosition(B.fromPoint(this._onPointerDownPosition).add(e)),this._store.fCanvas?.redraw()}onPointerUp(){this._store.fCanvas?.emitCanvasChangeEvent(),this._store.fCanvas?.hostElement.classList.remove(Xh,Kh)}static \u0275fac=function(n){return new(n||t)};static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})(),Yy=(()=>{let t=class es{_dragContext=d(G);handle(e){this._isValid()&&this._dragContext.draggableItems.forEach(n=>n.onPointerUp?.())}_isValid(){return this._dragContext.draggableItems.some(e=>e instanceof Zc)}static \u0275fac=function(n){return new(n||es)};static \u0275prov=f({token:es,factory:es.\u0275fac})};return t=p([_(Za)],t),t})(),Qc=class{event;fTrigger;static fToken=Symbol("DragCanvasPreparationRequest");constructor(i,e){this.event=i,this.fTrigger=e}},qy=(()=>{let t=class ts{_store=d(C);_dragContext=d(G);_dragInjector=d(we);handle({event:e,fTrigger:n}){!this._isValid(e)||!this._isValidTrigger(e,n)||(this._dragContext.onPointerDownScale=1,this._dragContext.onPointerDownPosition=B.fromPoint(e.getPosition()).elementTransform(this._store.flowHost),this._dragContext.draggableItems=[this._dragInjector.get(Zc)])}_isValid(e){return this._dragContext.isEmpty()&&(this._isBackgroundElement(e.targetElement)||this._isDragOnHost(e.targetElement))}_isBackgroundElement(e){return this._store.instances.get(te.BACKGROUND)?.hostElement.contains(e)}_isDragOnHost(e){return this._store.flowHost.contains(e)&&!this._getNode(e)}_getNode(e){let n=this._store.nodes.getAll().find(o=>o.isContains(e));return n&&n.fDraggingDisabled()&&(n=void 0),n}_isValidTrigger(e,n){return Ae(e.originalEvent,n)}static \u0275fac=function(n){return new(n||ts)};static \u0275prov=f({token:ts,factory:ts.\u0275fac})};return t=p([_(Qc)],t),t})(),Xy=[Yy,qy],Jc=class{event;trigger;static fToken=Symbol("SelectByPointerRequest");constructor(i,e){this.event=i,this.trigger=e}},Ky=(()=>{let t=class ns{_mediator=d(b);_store=d(C);_dragSession=d(G);handle({event:e,trigger:n}){if(!this._isSelectionAllowed(e))return;let o=this._resolveSelectable(e.targetElement);this._deferRaiseLayerFor(o),Ae(e.originalEvent,n)?this._applyToggleSelect(o):this._applySingleSelect(o)}_isSelectionAllowed(e){return this._store.flowHost.contains(e.targetElement)&&this._dragSession.isEmpty()}_resolveSelectable(e){return this._findNodeOrGroupAt(e)??this._findConnectionAt(e)}_findNodeOrGroupAt(e){return this._store.nodes.getAll().find(n=>n.isContains(e))}_findConnectionAt(e){return this._store.connections.getAll().find(n=>n.isContains(e))}_deferRaiseLayerFor(e){e&&queueMicrotask(()=>{this._mediator.execute(new Ht(e,e.hostElement.parentElement))})}_applySingleSelect(e){if(!e||e.fSelectionDisabled()){this._clearSelection();return}e.isSelected()||(this._clearSelection(),this._select(e))}_applyToggleSelect(e){!e||e.fSelectionDisabled()||(e.isSelected()?this._deselect(e):this._select(e))}_clearSelection(){if(this._dragSession.selectedItems.length){for(let e of this._dragSession.selectedItems)e.unmarkAsSelected();this._dragSession.markSelectionAsChanged(),this._dragSession.selectedItems=[]}}_select(e){this._dragSession.selectedItems.push(e),e.markAsSelected(),this._dragSession.markSelectionAsChanged()}_deselect(e){let n=this._dragSession.selectedItems.indexOf(e);n>=0&&this._dragSession.selectedItems.splice(n,1),e.unmarkAsSelected(),this._dragSession.markSelectionAsChanged()}static \u0275fac=function(n){return new(n||ns)};static \u0275prov=f({token:ns,factory:ns.\u0275fac})};return t=p([_(Jc)],t),t})(),Zy=[Ky];var ku=class extends Jl{hostElement=d(se).nativeElement};function Qy(t){return Tn(t,".f-drag-blocker")}var Af=(()=>{class t extends ku{_result=d(wt);_mediator=d(b);_platform=d(ll);disabled=!1;fMultiSelectTrigger=e=>this._platform.getOS()===ft.MAC_OS?e.metaKey:e.ctrlKey;fReassignConnectionTrigger=je;fCreateConnectionTrigger=je;fConnectionWaypointsTrigger=R(je);fMoveControlPointTrigger=je;fNodeResizeTrigger=je;fNodeRotateTrigger=je;fNodeMoveTrigger=je;fCanvasMoveTrigger=je;fExternalItemTrigger=je;fSelectionChange=new $e;fNodeIntersectedWithConnections=new $e;fNodeConnectionsIntersection=rt();fEmitOnNodeIntersect=!1;fCreateNode=new $e;fMoveNodes=new $e;fReassignConnection=new $e;fCreateConnection=new $e;fConnectionWaypointsChanged=rt();fDropToGroup=new $e;vCellSize=R(1,{transform:e=>Ee(e,1)});hCellSize=R(1,{transform:e=>Ee(e,1)});fCellSizeWhileDragging=R(!1,{transform:e=>Q(e)});fDragStarted=new $e;fDragEnded=new $e;_dragHandlerInjector=d(we);ngOnInit(){this._mediator.execute(new id(this))}ngAfterViewInit(){super.subscribe()}onPointerDown(e){if(Qy(e.targetElement))return!1;this._dragHandlerInjector.create(),this._result.clear(),this._mediator.execute(new rd),this._mediator.execute(new Bc(e)),this._mediator.execute(new Kc(e)),this._mediator.execute(new Lc(e)),this._mediator.execute(new Jc(e,this.fMultiSelectTrigger)),this._mediator.execute(new ac(e,this.fReassignConnectionTrigger)),this._mediator.execute(new rc(e,this.fCreateConnectionTrigger)),this._mediator.execute(new hc(e,this.fConnectionWaypointsTrigger()));let n=e.isMouseLeftButton();return n||this.finalizeDragSequence(),n}prepareDragSequence(e){this._mediator.execute(new Wc(e,this.fNodeResizeTrigger)),this._mediator.execute(new qc(e,this.fNodeRotateTrigger)),this._mediator.execute(new Ec(e,this.fNodeMoveTrigger)),this._mediator.execute(new kc(e,this.fExternalItemTrigger)),this._mediator.execute(new Dc(e)),this._mediator.execute(new Qc(e,this.fCanvasMoveTrigger)),this._mediator.execute(new sd)}onSelect(e){this._mediator.execute(new Oc(e))}onPointerMove(e){this._mediator.execute(new od(e))}onPointerUp(e){this._mediator.execute(new Xc(e)),this._mediator.execute(new zc(e)),this._mediator.execute(new sc(e)),this._mediator.execute(new tc(e)),this._mediator.execute(new Uc(e)),this._mediator.execute(new Yc(e)),this._mediator.execute(new Sc(e)),this._mediator.execute(new Rc(e)),this._mediator.execute(new fc(e)),this._mediator.execute(new Za(e)),this._mediator.execute(new Fc(e)),this._mediator.execute(new dc(e)),this._mediator.execute(new Wa)}finalizeDragSequence(){this._mediator.execute(new vt),this._mediator.execute(new Vn),this._result.clear(),this._dragHandlerInjector.destroy()}ngOnDestroy(){this._mediator.execute(new vt),this._mediator.execute(new ad),super.unsubscribe()}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275dir=le({type:t,selectors:[["f-flow","fDraggable",""]],inputs:{disabled:[2,"fDraggableDisabled","disabled",Q],fMultiSelectTrigger:"fMultiSelectTrigger",fReassignConnectionTrigger:"fReassignConnectionTrigger",fCreateConnectionTrigger:"fCreateConnectionTrigger",fConnectionWaypointsTrigger:[1,"fConnectionWaypointsTrigger"],fMoveControlPointTrigger:"fMoveControlPointTrigger",fNodeResizeTrigger:"fNodeResizeTrigger",fNodeRotateTrigger:"fNodeRotateTrigger",fNodeMoveTrigger:"fNodeMoveTrigger",fCanvasMoveTrigger:"fCanvasMoveTrigger",fExternalItemTrigger:"fExternalItemTrigger",fEmitOnNodeIntersect:[2,"fEmitOnNodeIntersect","fEmitOnNodeIntersect",Q],vCellSize:[1,"vCellSize"],hCellSize:[1,"hCellSize"],fCellSizeWhileDragging:[1,"fCellSizeWhileDragging"]},outputs:{fSelectionChange:"fSelectionChange",fNodeIntersectedWithConnections:"fNodeIntersectedWithConnections",fNodeConnectionsIntersection:"fNodeConnectionsIntersection",fCreateNode:"fCreateNode",fMoveNodes:"fMoveNodes",fReassignConnection:"fReassignConnection",fCreateConnection:"fCreateConnection",fConnectionWaypointsChanged:"fConnectionWaypointsChanged",fDropToGroup:"fDropToGroup",fDragStarted:"fDragStarted",fDragEnded:"fDragEnded"},exportAs:["fDraggable"],standalone:!1,features:[me([wt,we]),ne]})}return t})(),Jy=[...Xy,...P0,...Zm,...Zy,...uy,...r0,...Wy,...Z0,...fy,...Oy,...Gy,...wy,...yy],ev=(()=>{let t=class is{_store=d(C);handle({waypointIndex:e,connectionId:n}){let o=this._store.connections.require(n),r=o.fWaypoints()?.waypoints().slice();if(!r)throw new Error("Connection waypoints not found");r.splice(e,1),o.fWaypoints()?.waypoints.set(r),this._store.fDraggable?.fConnectionWaypointsChanged.emit(this._changeEvent(o))}_changeEvent(e){return new lc(e.fId(),e.fWaypoints()?.waypoints()||[])}static \u0275fac=function(n){return new(n||is)};static \u0275prov=f({token:is,factory:is.\u0275fac})};return t=p([_(Xl)],t),t})(),Ou=class{static fToken=Symbol("RemoveSnapConnectionFromStoreRequest")},tv=(()=>{let t=class os{_store=d(C);handle(e){this._store.connections.removeInstanceForSnap()}static \u0275fac=function(n){return new(n||os)};static \u0275prov=f({token:os,factory:os.\u0275fac})};return t=p([_(Ou)],t),t})(),nv=[zd,Vt,qp,Xp,Kp,Zp,U_,Cm,X_,gm,Tm,Dm,vm,Mm,Nm,Rm,ym,Sm,K_,Am,mm,_m,pm,dm,fm,lm,um,Pm,xm,km,Om,Em,Im,Fm,Lm,zm,Bm,tv,ev],ni=class{instance;static fToken=Symbol("AddConnectorToStoreRequest");constructor(i){this.instance=i}},iv=(()=>{let t=class rs{_store=d(C);_mediator=d(b);handle({instance:e}){switch(e.kind){case"input":this._addInput(e);break;case"output":this._addOutput(e);break;case"outlet":this._addOutlet(e);break;default:throw new Error(`Unknown connector kind: ${e.kind}`)}}_addInput(e){this._store.inputs.add(e),this._store.emitNodeChanges(),this._geometryRegister(e)}_addOutput(e){this._store.outputs.add(e),this._store.emitNodeChanges(),this._geometryRegister(e)}_addOutlet(e){this._store.outlets.add(e),this._store.emitNodeChanges(),this._geometryRegister(e)}_geometryRegister(e){this._mediator.execute(new Ea(e.fId(),e.fNodeId,e.kind,e.hostElement))}static \u0275fac=function(n){return new(n||rs)};static \u0275prov=f({token:rs,factory:rs.\u0275fac})};return t=p([_(ni)],t),t})(),Gt=class{position;connectorRefs;static fToken=Symbol("CalculateClosestConnectorRequest");constructor(i,e){this.position=i,this.connectorRefs=e}},ov=(()=>{let t=class ss{handle({position:e,connectorRefs:n}){let o,r=1/0;for(let s of n){let a=this._distanceToRect(e,s.rect);a<r&&(r=a,o=s)}return o?nl(W({},o),{distance:r}):void 0}_distanceToRect(e,{x:n,y:o,width:r,height:s}){let a=this._clamp(e.x,n,n+r),c=this._clamp(e.y,o,o+s),l=e.x-a,u=e.y-c;return Math.sqrt(l*l+u*u)}_clamp(e,n,o){return Math.max(n,Math.min(o,e))}static \u0275fac=function(n){return new(n||ss)};static \u0275prov=f({token:ss,factory:ss.\u0275fac})};return t=p([_(Gt)],t),t})(),ii=class{pointerPosition;connectableConnectors;static fToken=Symbol("FindConnectableConnectorUsingPriorityAndPositionRequest");constructor(i,e){this.pointerPosition=i,this.connectableConnectors=e}},rv=(()=>{let t=class as{_mediator=d(b);_store=d(C);_browser=d(ce);get _transform(){return this._store.transform}get _flowHost(){return this._store.flowHost}get _fNodes(){return this._store.nodes.getAll()}get _snapConnection(){return this._store.connections.getForSnap()}handle(e){let n=this._findConnectorAtPosition(e);return n.length>0?n[0]:void 0}_findConnectorAtPosition(e){let n=[];n.push(...this._filterConnectorsThatLocatedAtPosition(e));let o=this._isSnapConnectionEnabledAndHasClosestConnector(e);o&&n.unshift(o.connector);let r=this._getFirstConnectableConnectorOfNodeAtPosition(e);return r&&n.push(r),n}_filterConnectorsThatLocatedAtPosition(e){return e.connectableConnectors.filter(n=>A.isIncludePoint(n.rect,this._calculatePointerInFlow(e.pointerPosition))).map(n=>n.connector)}_calculatePointerInFlow(e){return mn(e,this._flowHost,this._transform)}_isSnapConnectionEnabledAndHasClosestConnector(e){if(!this._snapConnection)return;let n=this._mediator.execute(new Gt(this._calculatePointerInFlow(e.pointerPosition),e.connectableConnectors));return this._isValidClosestInput(n)?n:void 0}_isValidClosestInput(e){return!!e&&e.distance<this._snapConnection.fSnapThreshold}_getFirstConnectableConnectorOfNodeAtPosition(e){return this._getElementsFromPoint(e.pointerPosition).map(n=>this._findConnectableNode(n)).filter(n=>!!n).map(n=>this._findFirstConnectableConnectorOfNode(e.connectableConnectors,n)).find(n=>!!n)}_getElementsFromPoint(e){return this._browser.document.elementsFromPoint(e.x,e.y)}_findConnectableNode(e){return this._fNodes.find(n=>n.isContains(e)&&n.fConnectOnNode())}_findFirstConnectableConnectorOfNode(e,n){return e.find(o=>o.connector.fNodeId===n.fId())?.connector}static \u0275fac=function(n){return new(n||as)};static \u0275prov=f({token:as,factory:as.\u0275fac})};return t=p([_(ii)],t),t})(),oi=class{source;pointer;static fToken=Symbol("CalculateTargetConnectorsToConnectRequest");constructor(i,e){this.source=i,this.pointer=e}},Oe=class{connector;static fToken=Symbol("GetConnectorRectReferenceRequest");constructor(i){this.connector=i}},sv=(()=>{let t=class cs{_mediator=d(b);handle({connector:e}){return{connector:e,rect:this._getRect(e)}}_getRect(e){return this._mediator.execute(new yt(e.hostElement))}static \u0275fac=function(n){return new(n||cs)};static \u0275prov=f({token:cs,factory:cs.\u0275fac})};return t=p([_(Oe)],t),t})(),ri=class{nodeOrGroup;static fToken=Symbol("AddNodeToStoreRequest");constructor(i){this.nodeOrGroup=i}},av=(()=>{let t=class ds{_store=d(C);_mediator=d(b);handle({nodeOrGroup:e}){this._store.nodes.add(e),this._mediator.execute(new Da(e.fId(),e.hostElement,e)),this._store.emitNodeChanges()}static \u0275fac=function(n){return new(n||ds)};static \u0275prov=f({token:ds,factory:ds.\u0275fac})};return t=p([_(ri)],t),t})(),ed=class{nodeOrGroup;static fToken=Symbol("CalculateInputConnectionsRequest");constructor(i){this.nodeOrGroup=i}},cv=(()=>{let t=class ls{_store=d(C);handle({nodeOrGroup:e}){let n=this._collectInputIds(e);return this._collectConnections(n)}_collectInputIds(e){let n=new Set,o=this._store.inputs.getAll();for(let r of o)e.isContains(r.hostElement)&&n.add(r.fId());return n}_collectConnections(e){let n=[],o=this._store.connections.getAll();for(let r of o)e.has(r.fInputId())&&n.push(r);return n}static \u0275fac=function(n){return new(n||ls)};static \u0275prov=f({token:ls,factory:ls.\u0275fac})};return t=p([_(ed)],t),t})(),cn=class{connector;pointerPosition;static fToken=Symbol("CalculateConnectableSideByConnectedPositionsRequest");constructor(i,e){this.connector=i,this.pointerPosition=e}},Zh=2,be=(function(t){return t[t.NONE=0]="NONE",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT",t[t.TOP=4]="TOP",t[t.BOTTOM=8]="BOTTOM",t[t.ALL=15]="ALL",t})(be||{});function dv(t,i,e,n,o){let r=lv(o),s=e-t,a=n-i,c=uv(s,a);return hv(c,r)?c:fv(s,a,r,c)}function lv(t){if(!t||t.length===0)return be.ALL;let i=be.NONE;for(let e=0;e<t.length;e++)switch(t[e]){case D.LEFT:i|=be.LEFT;break;case D.RIGHT:i|=be.RIGHT;break;case D.TOP:i|=be.TOP;break;case D.BOTTOM:i|=be.BOTTOM;break}return i||be.ALL}function uv(t,i){let e=t<0?-t:t,n=i<0?-i:i;return e-n>Zh?t<0?D.LEFT:D.RIGHT:(n-e>Zh,i<0?D.TOP:D.BOTTOM)}function hv(t,i){switch(t){case D.LEFT:return(i&be.LEFT)!==0;case D.RIGHT:return(i&be.RIGHT)!==0;case D.TOP:return(i&be.TOP)!==0;case D.BOTTOM:return(i&be.BOTTOM)!==0;default:return!0}}function fv(t,i,e,n){let o=n,r=-1/0;if(e&be.RIGHT){let s=t;s>r&&(r=s,o=D.RIGHT)}if(e&be.LEFT){let s=-t;s>r&&(r=s,o=D.LEFT)}if(e&be.BOTTOM){let s=i;s>r&&(r=s,o=D.BOTTOM)}if(e&be.TOP){let s=-i;s>r&&(r=s,o=D.TOP)}return o}function td(t){return t===D.CALCULATE||t===D.CALCULATE_HORIZONTAL||t===D.CALCULATE_VERTICAL}var gv={[D.CALCULATE]:[D.TOP,D.BOTTOM,D.LEFT,D.RIGHT],[D.CALCULATE_HORIZONTAL]:[D.LEFT,D.RIGHT],[D.CALCULATE_VERTICAL]:[D.TOP,D.BOTTOM]},pv=(()=>{let t=class us{_mediator=d(b);handle({connector:e,pointerPosition:n}){let o=e.userFConnectableSide,r=this._getConnectorRect(e.hostElement).gravityCenter,s=this._accumulateConnectedCenters(e.hostElement,e.toConnector,n),a=s.sumX/s.count,c=s.sumY/s.count;return dv(r.x,r.y,a,c,gv[o])}_accumulateConnectedCenters(e,n,o){let r=o?.x||0,s=o?.y||0,a=o?1:0;if(n&&n.length)for(let c=0;c<n.length;c++){let l=n[c].hostElement;if(l===e)continue;let u=this._getConnectorRect(l).gravityCenter;r+=u.x,s+=u.y,a++}return{sumX:r,sumY:s,count:a}}_getConnectorRect(e){return this._mediator.execute(new ie(e))}static \u0275fac=function(n){return new(n||us)};static \u0275prov=f({token:us,factory:us.\u0275fac})};return t=p([_(cn)],t),t})(),nd=class{connector;static fToken=Symbol("CalculateConnectableSideByInternalPositionRequest");constructor(i){this.connector=i}},id=class{fComponent;static fToken=Symbol("AddDndToStoreRequest");constructor(i){this.fComponent=i}},_v=(()=>{let t=class hs{_store=d(C);handle(e){this._store.fDraggable=e.fComponent}static \u0275fac=function(n){return new(n||hs)};static \u0275prov=f({token:hs,factory:hs.\u0275fac})};return t=p([_(id)],t),t})(),od=class{event;static fToken=Symbol("OnPointerMoveRequest");constructor(i){this.event=i}},mv=(()=>{let t=class fs{_mediator=d(b);_store=d(C);get _hostElement(){return this._store.fDraggable?.hostElement}_dragContext=d(G);handle({event:e}){this._dragContext.rememberPointerEvent(e),this._setDifferenceToDraggableItems(this._getDifferenceBetweenPointerAndPointerDown(e),e),this._mediator.execute(new Un)}_setDifferenceToDraggableItems(e,n){this._dragContext.draggableItems.forEach(o=>{o.onPointerMove(W({},e),n)})}_getDifferenceBetweenPointerAndPointerDown(e){return this._getPointerPositionInCanvas(e).div(this._dragContext.onPointerDownScale).sub(this._dragContext.onPointerDownPosition)}_getPointerPositionInCanvas(e){return B.fromPoint(e.getPosition()).elementTransform(this._hostElement)}static \u0275fac=function(n){return new(n||fs)};static \u0275prov=f({token:fs,factory:fs.\u0275fac})};return t=p([_(od)],t),t})(),rd=class{static fToken=Symbol("InitializeDragSequenceRequest")},yv=(()=>{let t=class gs{_dragContext=d(G);handle(e){this._dragContext.reset()}static \u0275fac=function(n){return new(n||gs)};static \u0275prov=f({token:gs,factory:gs.\u0275fac})};return t=p([_(rd)],t),t})(),bt=class{static fToken=Symbol("IsDragStartedRequest")},vv=(()=>{let t=class ps{_store=d(C);handle(e){return!!this._store.fDraggable?.isDragStarted}static \u0275fac=function(n){return new(n||ps)};static \u0275prov=f({token:ps,factory:ps.\u0275fac})};return t=p([_(bt)],t),t})(),sd=class{static fToken=Symbol("PrepareDragSequenceRequest")},Cv=(()=>{let t=class _s{_mediator=d(b);_dragContext=d(G);handle(e){this._callPrepareDragSequence(),this._mediator.execute(new $a)}_callPrepareDragSequence(){this._dragContext.draggableItems.forEach(e=>e.prepareDragSequence?.())}static \u0275fac=function(n){return new(n||_s)};static \u0275prov=f({token:_s,factory:_s.\u0275fac})};return t=p([_(sd)],t),t})(),ad=class{static fToken=Symbol("RemoveDndFromStoreRequest")},wv=(()=>{let t=class ms{_store=d(C);handle(e){this._store.fDraggable=void 0}static \u0275fac=function(n){return new(n||ms)};static \u0275prov=f({token:ms,factory:ms.\u0275fac})};return t=p([_(ad)],t),t})(),bv=[_v,mv,yv,Cv,vv,wv],xv=new X("CONNECTABLE_SIDE_EPSILON"),Iv=(()=>{let t=class ys{_mediator=d(b);_lastSide=new WeakMap;_epsilon=Math.max(0,d(xv,{optional:!0})??2);handle({connector:e}){if(this._isDragging()){let o=this._lastSide.get(e);if(o!==void 0)return o;let r=this._getSideByDelta(e.hostElement,e.fNodeHost,e);return this._lastSide.set(e,r),r}let n=this._getSideByDelta(e.hostElement,e.fNodeHost,e);return this._lastSide.set(e,n),n}_getSideByDelta(e,n,o){let r=A.fromElement(e),s=n.getBoundingClientRect(),a=r.gravityCenter.x,c=r.gravityCenter.y,l=a-s.left,u=s.right-a,h=c-s.top,v=s.bottom-c,w=0,S=l,P=[l,u,h,v];for(let k=1;k<4;k++){let H=P[k];H<S&&(S=H,w=k)}let L=w===0?D.LEFT:w===1?D.RIGHT:w===2?D.TOP:D.BOTTOM,M=this._lastSide.get(o);if(M!==void 0&&M!==L){let k=M===D.LEFT?0:M===D.RIGHT?1:M===D.TOP?2:3;(k===0?l:k===1?u:k===2?h:v)-S<=this._epsilon&&(L=M)}return L}_isDragging(){return this._mediator.execute(new bt)}static \u0275fac=function(n){return new(n||ys)};static \u0275prov=f({token:ys,factory:ys.\u0275fac})};return t=p([_(nd)],t),t})(),dn=class{nodeOrGroup;static fToken=Symbol("CalculateConnectorsConnectableSidesRequest");constructor(i){this.nodeOrGroup=i}},Sv=(()=>{let t=class vs{_mediator=d(b);handle({nodeOrGroup:e}){let n=e.connectors,o=n.length;for(let s=0;s<o;s++){let a=n[s];a.fConnectableSide=this._resolveSideForConnectorFast(a)}let r=new Set;for(let s=0;s<o;s++){let c=n[s].toConnector;if(c&&c.length)for(let l=0,u=c.length;l<u;l++){let h=c[l],v=h.userFConnectableSide;td(v)&&r.add(h)}}r.size>0&&r.forEach(s=>{s.fConnectableSide=this._calculateByConnectedPositions(s)})}_resolveSideForConnectorFast(e){let n=e.userFConnectableSide;return n===D.AUTO?this._mediator.execute(new nd(e)):td(n)?this._calculateByConnectedPositions(e):n}_calculateByConnectedPositions(e){return this._mediator.execute(new cn(e))}static \u0275fac=function(n){return new(n||vs)};static \u0275prov=f({token:vs,factory:vs.\u0275fac})};return t=p([_(dn)],t),t})(),ln=class{static fToken=Symbol("CalculateNodesBoundingBoxRequest")},Ev=(()=>{let t=class Cs{_store=d(C);handle(e){return A.union(this._nodesRects())}_nodesRects(){return this._store.nodes.getAll().map(e=>A.fromElement(e.hostElement))}static \u0275fac=function(n){return new(n||Cs)};static \u0275prov=f({token:Cs,factory:Cs.\u0275fac})};return t=p([_(ln)],t),t})(),cd=class{fNodes;static fToken=Symbol("CalculateNodesBoundingBoxNormalizedPositionRequest");constructor(i){this.fNodes=i}},Dv=(()=>{let t=class ws{_store=d(C);_mediator=d(b);handle(e){return A.union(this._getNodesRects(e.fNodes||this._store.nodes.getAll()))}_getNodesRects(e){return e.map(n=>this._getNodeRect(n))}_getNodeRect(e){let n=this._mediator.execute(new sn(e.hostElement));if(n)return this._getElementRect(e,n);let o=this._mediator.execute(new ie(e.hostElement));return this._getElementRect(e,o)}_getElementRect(e,n){return A.initialize(e._position.x,e._position.y,n.width,n.height)}static \u0275fac=function(n){return new(n||ws)};static \u0275prov=f({token:ws,factory:ws.\u0275fac})};return t=p([_(cd)],t),t})(),dd=class{nodeOrGroup;static fToken=Symbol("CalculateOutputConnectionsRequest");constructor(i){this.nodeOrGroup=i}},Tv=(()=>{let t=class bs{_store=d(C);handle({nodeOrGroup:e}){let n=this._collectOutputIds(e);return this._collectConnections(n)}_collectOutputIds(e){let n=new Set,o=this._store.outputs.getAll();for(let r of o)e.isContains(r.hostElement)&&n.add(r.fId());return n}_collectConnections(e){let n=[],o=this._store.connections.getAll();for(let r of o)e.has(r.fOutputId())&&n.push(r);return n}static \u0275fac=function(n){return new(n||bs)};static \u0275prov=f({token:bs,factory:bs.\u0275fac})};return t=p([_(dd)],t),t})(),si=class{nodeOrGroup;static fToken=Symbol("FitToChildNodesAndGroupsRequest");constructor(i){this.nodeOrGroup=i}},jt=class{fNode;rect;static fToken=Symbol("GetNodePaddingRequest");constructor(i,e){this.fNode=i,this.rect=e}},Pv=(()=>{let t=class xs{_browser=d(ce);handle(e){return e.fNode.fIncludePadding()?this._getPaddingData(e.fNode,e.rect):[0,0,0,0]}_getPaddingData(e,n){let o=this._browser.window.getComputedStyle(e.hostElement);return[this._browser.toPixels(o.paddingLeft,n.width,n.height,o.fontSize),this._browser.toPixels(o.paddingTop,n.width,n.height,o.fontSize),this._browser.toPixels(o.paddingRight,n.width,n.height,o.fontSize),this._browser.toPixels(o.paddingBottom,n.width,n.height,o.fontSize)]}static \u0275fac=function(n){return new(n||xs)};static \u0275prov=f({token:xs,factory:xs.\u0275fac})};return t=p([_(jt)],t),t})(),Mv=(()=>{let t=class Is{_mediator=d(b);_store=d(C);get _nodes(){return this._store.nodes.getAll()}handle({nodeOrGroup:e}){if(e.fAutoSizeToFitChildren()){let r=this._calculateDirectChildren(e);if(r.length){let s=this._boundingRect(e),a=this._calculateChildrenBounding(r,this._paddings(e,s));e.updatePosition(a),e.updateSize(a),e.redraw()}}let n=e.fParentId();if(!n)return;let o=this._nodes.find(r=>r.fId()===n);o&&this._mediator.execute(new si(o))}_calculateDirectChildren(e){return this._nodes.filter(n=>n.fParentId()===e.fId())}_unionRect(e){return A.union(e.map(n=>this._boundingRect(n)))||A.initialize()}_boundingRect(e){return this._mediator.execute(new ie(e.hostElement))}_paddings(e,n){return this._mediator.execute(new jt(e,n))}_calculateChildrenBounding(e,[n,o,r,s]){let a=this._unionRect(e);return a=A.initialize(a.x-n,a.y-o,a.width+n+r,a.height+o+s),a}static \u0275fac=function(n){return new(n||Is)};static \u0275prov=f({token:Is,factory:Is.\u0275fac})};return t=p([_(si)],t),t})(),ld=class{id;static fToken=Symbol("GetChildNodeIdsRequest");constructor(i){this.id=i}},Rv=(()=>{let t=class Ss{_store=d(C);get _allNodesAndGroups(){return this._store.nodes.getAll()}handle(e){if(!e.id)return[];let n=new Set,o=[];return this._collectDescendants(e.id,o,n),o}_collectDescendants(e,n,o){if(o.has(e))throw new Error(`Circular reference detected in the node hierarchy. Node id: ${e}`);o.add(e);let r=this._allNodesAndGroups.filter(s=>s.fParentId()===e).map(s=>s.fId());n.push(...r);for(let s of r)this._collectDescendants(s,n,o)}static \u0275fac=function(n){return new(n||Ss)};static \u0275prov=f({token:Ss,factory:Ss.\u0275fac})};return t=p([_(ld)],t),t})(),un=class{nodeOrGroup;static fToken=Symbol("GetParentNodesRequest");constructor(i){this.nodeOrGroup=i}},Nv=(()=>{let t=class Es{_store=d(C);handle({nodeOrGroup:e}){return this._getParentNodes(e,new Set,[])}_getParentNodes(e,n,o){if(n.has(e.fId()))throw new Error("Circular reference detected in the node hierarchy. Node id: "+e.fId());n.add(e.fId());let r=this._store.nodes.get(e.fParentId());return r?(o.push(r),this._getParentNodes(r,n,o)):o}static \u0275fac=function(n){return new(n||Es)};static \u0275prov=f({token:Es,factory:Es.\u0275fac})};return t=p([_(un)],t),t})(),ai=class{nodeOrGroup;destroyRef;static fToken=Symbol("UpdateNodeWhenStateOrSizeChangedRequest");constructor(i,e){this.nodeOrGroup=i,this.destroyRef=e}},kv=(()=>{let t=class Ds{_mediator=d(b);handle({nodeOrGroup:e,destroyRef:n}){let{hostElement:o,stateChanges:r}=e;new Ze(new Il(o),r).listen(n,()=>{this._mediator.execute(new Nt),this._isDragging()||(this._mediator.execute(new rn(e.fId(),"UpdateNodeWhenStateOrSizeChanged")),this._mediator.execute(new dn(e)),this._mediator.execute(new si(e)))})}_isDragging(){return this._mediator.execute(new bt)}static \u0275fac=function(n){return new(n||Ds)};static \u0275prov=f({token:Ds,factory:Ds.\u0275fac})};return t=p([_(ai)],t),t})(),ci=class{instance;static fToken=Symbol("RemoveNodeFromStoreRequest");constructor(i){this.instance=i}},Ov=(()=>{let t=class Ts{_store=d(C);_mediator=d(b);handle({instance:e}){this._store.nodes.remove(e),this._mediator.execute(new Ta(e.fId())),this._store.emitNodeChanges()}static \u0275fac=function(n){return new(n||Ts)};static \u0275prov=f({token:Ts,factory:Ts.\u0275fac})};return t=p([_(ci)],t),t})(),Fv=[av,pv,Iv,cv,Sv,Ev,Dv,Tv,Mv,Rv,Pv,Nv,kv,Ov],Av=(()=>{let t=class Ps{_mediator=d(b);_store=d(C);get _targets(){return this._store.inputs.getAll()}handle({source:e,pointer:n}){let o=this._getConnectableTargets(e),r=[];for(let s of o)r.push(this._mediator.execute(new Oe(s)));return this._scheduleApplyCalculatedSides(r,n),r}_getConnectableTargets(e){if(e.hasConnectionLimits)return this._targets.filter(o=>e.canConnectTo(o));let n=this._targets.filter(o=>o.canBeConnected);return e.isSelfConnectable||(n=n.filter(o=>o.fNodeId!==e.fNodeId)),n}_scheduleApplyCalculatedSides(e,n){queueMicrotask(()=>this._applyCalculatedConnectableSides(e,n))}_applyCalculatedConnectableSides(e,n){for(let{connector:o}of e)td(o.userFConnectableSide)&&(o.fConnectableSide=this._calculateByConnectedPositions(o,n))}_calculateByConnectedPositions(e,n){return this._mediator.execute(new cn(e,n))}static \u0275fac=function(n){return new(n||Ps)};static \u0275prov=f({token:Ps,factory:Ps.\u0275fac})};return t=p([_(oi)],t),t})(),ud=class{target;pointer;static fToken=Symbol("CalculateSourceConnectorsToConnectRequest");constructor(i,e){this.target=i,this.pointer=e}},Lv=(()=>{let t=class Ms{_mediator=d(b);_store=d(C);get _sources(){return this._store.outputs.getAll()}handle({target:e,pointer:n}){let o=this._getConnectableSources(e),r=[];for(let s of o)r.push(this._mediator.execute(new Oe(s)));return this._scheduleApplyCalculatedSides(r,n),r}_getConnectableSources(e){return this._sources.filter(n=>{let o=n.canBeConnected;return o&&n.hasConnectionLimits&&(o=n.canConnectTo(e)),o})}_scheduleApplyCalculatedSides(e,n){queueMicrotask(()=>this._applyCalculatedConnectableSides(e,n))}_applyCalculatedConnectableSides(e,n){for(let{connector:o}of e)td(o.userFConnectableSide)&&(o.fConnectableSide=this._calculateByConnectedPositions(o,n))}_calculateByConnectedPositions(e,n){return this._mediator.execute(new cn(e,n))}static \u0275fac=function(n){return new(n||Ms)};static \u0275prov=f({token:Ms,factory:Ms.\u0275fac})};return t=p([_(ud)],t),t})(),hn=class{connectors;static fToken=Symbol("MarkConnectableConnectorsRequest");constructor(i){this.connectors=i}},pe={DRAG_AND_DROP:{DRAGGING:"f-dragging",CONNECTIONS_DRAGGING:"f-connections-dragging"},GROUPING:{OVER_BOUNDARY:"f-grouping-over-boundary",DROP_ACTIVE:"f-grouping-drop-active"},CONNECTOR:{OUTPUT_CONNECTED:"f-node-output-connected",OUTPUT_NOT_CONNECTABLE:"f-node-output-not-connectable",INPUT_CONNECTED:"f-node-input-connected",INPUT_NOT_CONNECTABLE:"f-node-input-not-connectable",CONNECTABLE:"f-connector-connectable"}},zv=(()=>{let t=class Rs{_store=d(C);handle({connectors:e}){this._store.flowHost.classList.add(pe.DRAG_AND_DROP.CONNECTIONS_DRAGGING),e.forEach(n=>this._markConnector(n))}_markConnector({hostElement:e}){e.classList.add(pe.CONNECTOR.CONNECTABLE)}static \u0275fac=function(n){return new(n||Rs)};static \u0275prov=f({token:Rs,factory:Rs.\u0275fac})};return t=p([_(hn)],t),t})(),di=class{instance;static fToken=Symbol("RemoveConnectorFromStoreRequest");constructor(i){this.instance=i}},Bv=(()=>{let t=class Ns{_store=d(C);_mediator=d(b);handle({instance:e}){switch(e.kind){case"input":this._removeInput(e);break;case"output":this._removeOutput(e);break;case"outlet":this._removeOutlet(e);break;default:throw new Error(`Unknown connector kind: ${e.kind}`)}}_removeInput(e){this._store.inputs.removeById(e.fId()),this._store.emitNodeChanges(),this._geometryUnregister(e)}_removeOutput(e){this._store.outputs.removeById(e.fId()),this._store.emitNodeChanges(),this._geometryUnregister(e)}_removeOutlet(e){this._store.outlets.removeById(e.fId()),this._store.emitNodeChanges(),this._geometryUnregister(e)}_geometryUnregister(e){this._mediator.execute(new On(e.fId(),e.kind))}static \u0275fac=function(n){return new(n||Ns)};static \u0275prov=f({token:Ns,factory:Ns.\u0275fac})};return t=p([_(di)],t),t})(),fn=class{connectors;static fToken=Symbol("UnmarkConnectableConnectorsRequest");constructor(i){this.connectors=i}},Gv=(()=>{let t=class ks{_store=d(C);handle({connectors:e}){this._store.flowHost.classList.remove(pe.DRAG_AND_DROP.CONNECTIONS_DRAGGING),e.forEach(n=>this._unmarkConnector(n))}_unmarkConnector({hostElement:e}){e.classList.remove(pe.CONNECTOR.CONNECTABLE)}static \u0275fac=function(n){return new(n||ks)};static \u0275prov=f({token:ks,factory:ks.\u0275fac})};return t=p([_(fn)],t),t})(),jv=[iv,Bv,ov,rv,Lv,Av,sv,zv,Gv],hd=class{instance;static fToken=Symbol("AddFlowToStoreRequest");constructor(i){this.instance=i}};var Mn=(function(t){return t.MANUAL="manual",t.AUTO="auto",t})(Mn||{});function Hv(t){let i=[...t.nodes.map(Qh),...t.groups.map(Qh)],e=new Set(t.nodes.map(a=>a.id)),n=new Set(t.groups.map(a=>a.id)),o=new Map,r=new Map;for(let a of[...t.nodes,...t.groups]){for(let c of a.fOutputs)o.set(c.id,a.id);for(let c of a.fInputs)r.set(c.id,a.id)}let s=t.connections.reduce((a,c)=>{let l=o.get(c.fOutputId),u=r.get(c.fInputId);return!l||!u||a.push({source:l,target:u}),a},[]);return{nodes:i,connections:s,nodeIds:e,groupIds:n}}function Qh(t){return{id:t.id,size:t.measuredSize?W({},t.measuredSize):t.size?W({},t.size):void 0}}var Vv=1,Lf=(()=>{class t{_destroyRef=d(We);_flows=new Map;_engine;constructor(){this._destroyRef.onDestroy(()=>{Array.from(this._flows.keys()).forEach(e=>this.unregisterFlow(e)),this._engine=void 0})}attachEngine(e){this._engine=e}registerFlow(e,n){let o=e.fId();this.unregisterFlow(o);let r={flow:e,store:n,nodeSignature:this._buildNodeSignature(n),connectionSignature:this._buildConnectionSignature(n),timeoutId:null,raf1:null,raf2:null,unsubs:[],runId:0,isApplying:!1};r.unsubs.push(n.nodesChanges$.listen(()=>this._handleNodesChanges(o)),n.connectionsChanges$.listen(()=>this._handleConnectionsChanges(o))),this._flows.set(o,r),this._engine?.getMode()===Mn.AUTO&&this._scheduleRelayout(o)}unregisterFlow(e){let n=this._flows.get(e);n&&(n.unsubs.forEach(o=>o()),this._clearScheduledWork(n),this._flows.delete(e))}handleModeChanged(e){if(e===Mn.AUTO)for(let n of this._flows.keys())this._scheduleRelayout(n)}async relayout(e){if(this._engine){if(e){let n=this._flows.get(e);n&&await this._relayoutRegisteredFlow(e,n);return}for(let[n,o]of this._flows.entries())await this._relayoutRegisteredFlow(n,o)}}_handleNodesChanges(e){let n=this._flows.get(e);if(!n||n.isApplying)return;let o=this._buildNodeSignature(n.store);o!==n.nodeSignature&&(n.nodeSignature=o,this._scheduleRelayout(e))}_handleConnectionsChanges(e){let n=this._flows.get(e);if(!n||n.isApplying)return;let o=this._buildConnectionSignature(n.store);o!==n.connectionSignature&&(n.connectionSignature=o,this._scheduleRelayout(e))}_scheduleRelayout(e){let n=this._flows.get(e);!n||!this._engine||this._engine.getMode()!==Mn.AUTO||(n.timeoutId!==null&&clearTimeout(n.timeoutId),this._cancelAnimationFrames(n),n.timeoutId=setTimeout(()=>{n.timeoutId=null,this._runAfterNextPaint(n,()=>{this._relayoutFlowIfReady(e)})},Vv))}async _relayoutFlowIfReady(e){let n=this._flows.get(e);if(!(!n||!this._engine||this._engine.getMode()!==Mn.AUTO)){if(n.store.hasPendingProgressiveRender){this._scheduleRelayout(e);return}await this._relayoutRegisteredFlow(e,n)}}async _relayoutRegisteredFlow(e,n){if(!this._engine)return;let o=Hv(n.flow.getState({measuredSize:!0})),r=++n.runId,s=await this._engine.calculate(o.nodes,o.connections,{flowId:e,mode:this._engine.getMode()}),a=this._flows.get(e);if(!(!a||a.runId!==r||!this._applyPositions(a.store,s.nodes).length)){a.isApplying=!0;try{a.flow.redraw(),this._emitWriteback(e,s.nodes,o.nodeIds,o.groupIds)}finally{queueMicrotask(()=>{let l=this._flows.get(e);l&&(l.isApplying=!1)})}}}_emitWriteback(e,n,o,r){let s=this._engine?.getWriteback();s&&s({flowId:e,nodes:n.filter(a=>o.has(a.id)),groups:n.filter(a=>r.has(a.id))})}_applyPositions(e,n){return n.filter(o=>{let r=e.nodes.get(o.id);return!r||E.isEqual(r._position,o.position)?!1:(r.position.set(W({},o.position)),!0)})}_buildNodeSignature(e){return e.nodes.getAll().map(n=>n.fId()).sort().join("|")}_buildConnectionSignature(e){return e.connections.getAll().map(n=>`${n.fId()}:${n.fOutputId()}:${n.fInputId()}`).sort().join("|")}_runAfterNextPaint(e,n){if(this._cancelAnimationFrames(e),typeof requestAnimationFrame!="function"){n();return}e.raf1=requestAnimationFrame(()=>{e.raf1=null,e.raf2=requestAnimationFrame(()=>{e.raf2=null,n()})})}_clearScheduledWork(e){e.timeoutId!==null&&(clearTimeout(e.timeoutId),e.timeoutId=null),this._cancelAnimationFrames(e)}_cancelAnimationFrames(e){e.raf1!==null&&typeof cancelAnimationFrame=="function"&&(cancelAnimationFrame(e.raf1),e.raf1=null),e.raf2!==null&&typeof cancelAnimationFrame=="function"&&(cancelAnimationFrame(e.raf2),e.raf2=null)}static \u0275fac=function(n){return new(n||t)};static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})();var Uv=(()=>{let t=class Os{_store=d(C);_layoutController=d(Lf,{optional:!0});handle({instance:e}){this._store.fFlow=e,this._layoutController?.registerFlow(e,this._store)}static \u0275fac=function(n){return new(n||Os)};static \u0275prov=f({token:Os,factory:Os.\u0275fac})};return t=p([_(hd)],t),t})(),fd=class{static fToken=Symbol("GetFlowRequest")},Wv=(()=>{let t=class Fs{_store=d(C);handle(e){let n=this._store.fFlow;if(!n)throw new Error("Flow not found in store");return n}static \u0275fac=function(n){return new(n||Fs)};static \u0275prov=f({token:Fs,factory:Fs.\u0275fac})};return t=p([_(fd)],t),t})(),gd=class{static fToken=Symbol("CalculateConnectionsStateRequest")},$v=(()=>{let t=class As{_store=d(C);handle(e){return this._store.connections.getAll().map(this._mapToConnectionState)}_mapToConnectionState(e){return{id:e.fId(),fOutputId:e.fOutputId(),fInputId:e.fInputId(),fType:e.fType,fBehavior:e.fBehavior,isSelected:e.isSelected(),waypoints:e.fWaypoints()?.waypoints()||[],fInputSide:e.fInputSide(),fOutputSide:e.fOutputSide()}}static \u0275fac=function(n){return new(n||As)};static \u0275prov=f({token:As,factory:As.\u0275fac})};return t=p([_(gd)],t),t})(),li=class{component;measuredSize;static fToken=Symbol("CalculateNodesStateRequest");constructor(i,e=!1){this.component=i,this.measuredSize=e}},Yv=(()=>{let t=class Ls{_store=d(C);_mediator=d(b);handle({component:e,measuredSize:n}){return this._store.nodes.getAll().filter(o=>o instanceof e).map(o=>{let r=n?this._mediator.execute(new ie(o.hostElement)):null;return{id:o.fId(),parentId:o.fParentId()??void 0,position:W({},o._position),size:o._size?W({},o._size):void 0,measuredSize:r?{width:r.width,height:r.height}:void 0,rotate:o._rotate,fOutputs:this._getOutputs(o.hostElement),fInputs:this._getInputs(o.hostElement),isSelected:o.isSelected()}})}_getOutputs(e){return this._store.outputs.getAll().filter(n=>e.contains(n.hostElement)).map(n=>({id:n.fId(),fConnectableSide:n.fConnectableSide}))}_getInputs(e){return this._store.inputs.getAll().filter(n=>e.contains(n.hostElement)).map(n=>({id:n.fId(),fConnectableSide:n.fConnectableSide}))}static \u0275fac=function(n){return new(n||Ls)};static \u0275prov=f({token:Ls,factory:Ls.\u0275fac})};return t=p([_(li)],t),t})(),pd=class{measuredSize;static fToken=Symbol("CalculateFlowStateRequest");constructor(i=!1){this.measuredSize=i}},qv=(()=>{let t=class zs{_mediator=d(b);_store=d(C);get _canvas(){return this._store.fCanvas}get _transform(){return this._canvas.transform}get _canvasPosition(){return E.sum(this._transform.position,this._transform.scaledPosition)}handle({measuredSize:e}){return{position:this._canvasPosition,scale:this._canvas.transform.scale,nodes:this._mediator.execute(new li(Gd,e)),groups:this._mediator.execute(new li(ru,e)),connections:this._mediator.execute(new gd)}}static \u0275fac=function(n){return new(n||zs)};static \u0275prov=f({token:zs,factory:zs.\u0275fac})};return t=p([_(pd)],t),t})(),Xv=[qv,Yv,$v],_d=class{instance;static fToken=Symbol("RemoveFlowFromStoreRequest");constructor(i){this.instance=i}},Kv=(()=>{let t=class Bs{_store=d(C);_layoutController=d(Lf,{optional:!0});handle({instance:e}){this._layoutController?.unregisterFlow(e.fId()),this._store.fFlow=void 0}static \u0275fac=function(n){return new(n||Bs)};static \u0275prov=f({token:Bs,factory:Bs.\u0275fac})};return t=p([_(_d)],t),t})(),jd=(()=>{class t{isNodesRendered=!1;isFullRendered=!1;static \u0275fac=function(n){return new(n||t)};static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})(),md=class{static fToken=Symbol("NotifyNodesRenderedRequest")},Gu=new X("F_FLOW"),Fu=class{},Zv=(()=>{let t=class Gs{_state=d(jd);_fFlow=d(Gu);handle(e){this._state.isNodesRendered||(this._state.isNodesRendered=!0,this._fFlow.fNodesRendered.emit(this._fFlow.fId()))}static \u0275fac=function(n){return new(n||Gs)};static \u0275prov=f({token:Gs,factory:Gs.\u0275fac})};return t=p([_(md)],t),t})(),yd=class{static fToken=Symbol("NotifyFullRenderedRequest")},Qv=(()=>{let t=class js{_state=d(jd);_fFlow=d(Gu);handle(e){this._state.isFullRendered||(this._state.isFullRendered=!0,this._fFlow.fFullRendered.emit(this._fFlow.fId()),this._fFlow.fLoaded.emit(this._fFlow.fId()))}static \u0275fac=function(n){return new(n||js)};static \u0275prov=f({token:js,factory:js.\u0275fac})};return t=p([_(yd)],t),t})(),ui=class{targetConnectionsRevision;targetNodesRevision;callback;destroyRef;static fToken=Symbol("WaitForConnectionsRenderedRequest");constructor(i,e,n,o){this.targetConnectionsRevision=i,this.targetNodesRevision=e,this.callback=n,this.destroyRef=o}},Jv=(()=>{let t=class Hs{_store=d(C);handle({targetConnectionsRevision:e,targetNodesRevision:n,callback:o,destroyRef:r}){if(this._store.connectionsRenderedRevision>=e&&this._store.connectionsRenderedNodesRevision>=n){o();return}let s=this._store.connectionsRenderedChanges$.listen(()=>{this._store.connectionsRenderedRevision<e||this._store.connectionsRenderedNodesRevision<n||(s(),o())});r.onDestroy(s)}static \u0275fac=function(n){return new(n||Hs)};static \u0275prov=f({token:Hs,factory:Hs.\u0275fac})};return t=p([_(ui)],t),t})(),vd=class{static fToken=Symbol("ResetRenderLifecycleRequest")},eC=(()=>{let t=class Vs{_state=d(jd);handle(e){this._state.isNodesRendered=!1,this._state.isFullRendered=!1}static \u0275fac=function(n){return new(n||Vs)};static \u0275prov=f({token:Vs,factory:Vs.\u0275fac})};return t=p([_(vd)],t),t})(),Cd=class{destroyRef;static fToken=Symbol("QueueConnectionRedrawRequest");constructor(i){this.destroyRef=i}},zf=(()=>{class t{isWaitingForViewportAnimation=!1;pendingRedraw=!1;static \u0275fac=function(n){return new(n||t)};static \u0275prov=f({token:t,factory:t.\u0275fac})}return t})(),tC=(()=>{let t=class Us{_state=d(zf);_store=d(C);_mediator=d(b);handle(e){if(this._state.pendingRedraw=!0,this._state.isWaitingForViewportAnimation)return;this._state.isWaitingForViewportAnimation=!0;let n=this._store.viewportAnimationChanges$.listen(()=>{if(this._store.isViewportAnimating)return;let o=this._state.pendingRedraw;n(),this._state.isWaitingForViewportAnimation=!1,this._state.pendingRedraw=!1,o&&this._mediator.execute(new Gn)});e.destroyRef.onDestroy(n)}static \u0275fac=function(n){return new(n||Us)};static \u0275prov=f({token:Us,factory:Us.\u0275fac})};return t=p([_(Cd)],t),t})(),nC=[Uv,Wv,...Xv,Kv,jd,Zv,Qv,Jv,eC,zf,tC],wd=class{static fToken=Symbol("ClearSelectionRequest")},iC=(()=>{let t=class Ws{_dragContext=d(G);handle(e){this._dragContext.selectedItems.forEach(n=>n.unmarkAsSelected()),this._dragContext.selectedItems=[],this._dragContext.isSelectedChanged=!0}static \u0275fac=function(n){return new(n||Ws)};static \u0275prov=f({token:Ws,factory:Ws.\u0275fac})};return t=p([_(wd)],t),t})(),bd=class{static fToken=Symbol("CalculateSelectableItemsRequest")},oC=(()=>{let t=class $s{_mediator=d(b);_store=d(C);_dragContext=d(G);get _nodes(){return this._store.nodes.getAll()}get _connections(){return this._store.connections.getAll()}handle(){return[...this._nodeRects(),...this._connectionRects()].filter(e=>!this._dragContext.selectedItems.includes(e.element))}_nodeRects(){return this._nodes.filter(e=>!e.fSelectionDisabled()).map(e=>({element:e,fRect:this._mediator.execute(new ie(e.hostElement))}))}_connectionRects(){return this._connections.filter(e=>!e.fSelectionDisabled()).map(e=>({element:e,fRect:this._mediator.execute(new ie(e.boundingElement))}))}static \u0275fac=function(n){return new(n||$s)};static \u0275prov=f({token:$s,factory:$s.\u0275fac})};return t=p([_(bd)],t),t})(),hi=class{static fToken=Symbol("GetCurrentSelectionRequest")},rC=(()=>{let t=class Ys{_dragContext=d(G);handle(){return{fNodeIds:this._getSelectedNodes(),fGroupIds:this._getSelectedGroups(),fConnectionIds:this._getSelectedConnections()}}_getSelectedNodes(){return this._dragContext.selectedItems.filter(e=>e.hostElement.classList.contains("f-node")).map(e=>e.hostElement.dataset.fNodeId)}_getSelectedGroups(){return this._dragContext.selectedItems.filter(e=>e.hostElement.classList.contains("f-group")).map(e=>e.hostElement.dataset.fGroupId)}_getSelectedConnections(){return this._dragContext.selectedItems.filter(e=>!e.hostElement.classList.contains("f-node")&&!e.hostElement.classList.contains("f-group")).map(e=>e.hostElement.id)}static \u0275fac=function(n){return new(n||Ys)};static \u0275prov=f({token:Ys,factory:Ys.\u0275fac})};return t=p([_(hi)],t),t})(),xd=class{nodes;connections;isSelectedChanged;static fToken=Symbol("SelectRequest");constructor(i,e,n=!0){this.nodes=i,this.connections=e,this.isSelectedChanged=n}},sC=(()=>{let t=class qs{_dragContext=d(G);_store=d(C);handle(e){this._dragContext.selectedItems.forEach(n=>{n.unmarkAsSelected()}),this._dragContext.selectedItems=[],e.nodes.forEach(n=>{let o=this._store.nodes.get(n);o&&(o.markAsSelected(),this._dragContext.selectedItems.push(o))}),e.connections.forEach(n=>{let o=this._store.connections.get(n);o&&(o.markAsSelected(),this._dragContext.selectedItems.push(o))}),this._dragContext.isSelectedChanged=e.isSelectedChanged}static \u0275fac=function(n){return new(n||qs)};static \u0275prov=f({token:qs,factory:qs.\u0275fac})};return t=p([_(xd)],t),t})(),Id=class{static fToken=Symbol("SelectAllRequest")},aC=(()=>{let t=class Xs{_dragSession=d(G);_store=d(C);handle(e){this._dragSession.selectedItems.forEach(n=>{n.unmarkAsSelected()}),this._dragSession.selectedItems=[],this._store.nodes.getAll().forEach(n=>{n.markAsSelected(),this._dragSession.selectedItems.push(n)}),this._store.connections.getAll().forEach(n=>{n.markAsSelected(),this._dragSession.selectedItems.push(n)}),this._dragSession.isSelectedChanged=!0}static \u0275fac=function(n){return new(n||Xs)};static \u0275prov=f({token:Xs,factory:Xs.\u0275fac})};return t=p([_(Id)],t),t})(),gn=class{nodeOrGroup;static fToken=Symbol("SelectAndUpdateNodeLayerRequest");constructor(i){this.nodeOrGroup=i}},Sd=class{fItemsContainer;allElements;elementsThatShouldBeInFront;targetIndex;static fToken=Symbol("MoveFrontElementsBeforeTargetElementRequest");constructor(i,e,n,o){this.fItemsContainer=i,this.allElements=e,this.elementsThatShouldBeInFront=n,this.targetIndex=o}},cC=(()=>{let t=class Ks{handle(e){let n=[];for(let o=e.targetIndex+1;o<e.allElements.length;o++){let r=e.allElements[o];e.elementsThatShouldBeInFront.includes(r)||n.push(r)}n.forEach(o=>{e.fItemsContainer.removeChild(o),e.fItemsContainer.insertBefore(o,e.allElements[e.targetIndex])})}static \u0275fac=function(n){return new(n||Ks)};static \u0275prov=f({token:Ks,factory:Ks.\u0275fac})};return t=p([_(Sd)],t),t})(),Ht=class{item;itemContainer;static fToken=Symbol("UpdateItemAndChildrenLayersRequest");constructor(i,e){this.item=i,this.itemContainer=e}},pn=class{nodeOrGroupId;static fToken=Symbol("GetDeepChildrenNodesAndGroupsRequest");constructor(i){this.nodeOrGroupId=i}},dC=(()=>{let t=class Zs{_store=d(C);handle({nodeOrGroupId:e}){return this._getChildrenNodes(e)}_getChildrenNodes(e,n=new Set){if(n.has(e))throw new Error("Circular reference detected in the node hierarchy. Node id: "+e);n.add(e);let o=this._store.nodes.getAll().filter(r=>r.fParentId()===e);return o.reduce((r,s)=>r.concat(this._getChildrenNodes(s.fId(),n)),o)}static \u0275fac=function(n){return new(n||Zs)};static \u0275prov=f({token:Zs,factory:Zs.\u0275fac})};return t=p([_(pn)],t),t})(),lC=(()=>{let t=class Qs{_store=d(C);_mediator=d(b);get _canvas(){return this._store.fCanvas}get _groupsContainer(){return this._canvas.fGroupsContainer().nativeElement}get _nodesContainer(){return this._canvas.fNodesContainer().nativeElement}get _connectionsContainer(){return this._canvas.fConnectionsContainer().nativeElement}handle(e){switch(e.itemContainer){case this._groupsContainer:this._handleGroup(e);break;case this._nodesContainer:this._handleNode(e);break;case this._connectionsContainer:this._handleConnection(e);break;default:throw new Error("Unknown container")}}_handleGroup(e){let n=this._getChildrenNodesAndGroups(e.item.fId()),o=this._getChildrenGroups(n);this._updateLayers(this._groupsContainer,e.item.hostElement,o);let r=this._getChildrenNodes(n);r.length&&this._updateLayers(this._nodesContainer,r[0],r)}_handleNode(e){let n=this._getChildrenNodesAndGroups(e.item.fId()),o=this._getChildrenNodes(n);this._updateLayers(e.itemContainer,e.item.hostElement,o)}_handleConnection(e){this._updateLayers(e.itemContainer,e.item.hostElement,[])}_updateLayers(e,n,o){let r=Array.from(e.children),s=r.findIndex(a=>a===n);this._isAnythingNeedToBeMoved(r,s,o)&&this._mediator.execute(new Sd(e,r,o,s))}_isAnythingNeedToBeMoved(e,n,o){for(let r=n+1;r<e.length;r++)if(!o.includes(e[r]))return!0;return!1}_getChildrenGroups(e){let n=Array.from(this._groupsContainer.children);return e.filter(o=>this._groupsContainer.contains(o)).sort((o,r)=>n.indexOf(o)-n.indexOf(r))}_getChildrenNodes(e){let n=Array.from(this._nodesContainer.children);return e.filter(o=>this._nodesContainer.contains(o)).sort((o,r)=>n.indexOf(o)-n.indexOf(r))}_getChildrenNodesAndGroups(e){return this._mediator.execute(new pn(e)).map(n=>n.hostElement)}static \u0275fac=function(n){return new(n||Qs)};static \u0275prov=f({token:Qs,factory:Qs.\u0275fac})};return t=p([_(Ht)],t),t})(),uC=(()=>{let t=class Js{_dragSession=d(G);_mediator=d(b);handle({nodeOrGroup:e}){this._selectNodeIfNotSelected(e),this._mediator.execute(new Ht(e,e.hostElement.parentElement))}_selectNodeIfNotSelected(e){e.fSelectionDisabled()||this._dragSession.selectedItems.includes(e)||(this._dragSession.selectedItems.push(e),e.markAsSelected(),this._dragSession.isSelectedChanged=!0)}static \u0275fac=function(n){return new(n||Js)};static \u0275prov=f({token:Js,factory:Js.\u0275fac})};return t=p([_(gn)],t),t})(),hC=[iC,oC,rC,sC,aC,uC],Ed=class{static fToken=Symbol("ResetZoomRequest")},fC=(()=>{let t=class ea{_store=d(C);get _canvas(){return this._store.fCanvas}handle(e){this._canvas.resetScale(),this._canvas.redraw(),this._canvas.emitCanvasChangeEvent()}static \u0275fac=function(n){return new(n||ea)};static \u0275prov=f({token:ea,factory:ea.\u0275fac})};return t=p([_(Ed)],t),t})(),Dd=class{position;step;direction;animate;static fToken=Symbol("SetZoomRequest");constructor(i,e,n,o=!1){this.position=i,this.step=e,this.direction=n,this.animate=o}},gC=new Set(["drag-node","drag-external-item","resize-node","rotate-node","create-connection","reassign-connection","drag-connection-waypoint","assign-to-container"]),pC=new Set(["drag-canvas","selection-area"]),_C=(()=>{let t=class ta{_mediator=d(b);_store=d(C);_dragContext=d(G,{optional:!0});get _flowHost(){return this._store.flowHost}get _canvas(){return this._store.fCanvas}get _zoomComponent(){return this._store.instances.get(te.ZOOM)}get _isDragStarted(){return this._mediator.execute(new bt)}handle(e){if(!this._zoomComponent)return;let n=this._canvas.transform.scale,o=this._clamp(n+e.step*e.direction);if(o===n)return;let r=this._castPositionToFlow(e.position);if(this._isDragStarted){let s=this._getDragZoomMode();if(s==="blocked")return;s==="rebase"&&this._rebaseDragContext(r,o)}this._canvas.setScale(o,r),e.animate?this._canvas.redrawWithAnimation():this._canvas.redraw(),this._canvas.emitCanvasChangeEvent()}_clamp(e){return Math.max(this._zoomComponent?.minimum||1,Math.min(e,this._zoomComponent?.maximum||1))}_castPositionToFlow(e){return B.fromPoint(e).elementTransform(this._flowHost)}_getDragZoomMode(){if(this._dragContext?.isEmpty())return"blocked";let e=!1;for(let n of this._dragContext?.draggableItems??[]){let o=n.getEvent().kind;if(gC.has(o)){e=!0;continue}if(!pC.has(o))return"blocked"}return e?"rebase":"direct"}_rebaseDragContext(e,n){if(!this._dragContext)return;let o=this._dragContext.onPointerDownScale;if(!o||o===n){this._dragContext.onPointerDownScale=n;return}let r=1/n-1/o;this._dragContext.onPointerDownPosition=B.fromPoint(this._dragContext.onPointerDownPosition).add(B.fromPoint(e).mult(r)),this._dragContext.onPointerDownScale=n}static \u0275fac=function(n){return new(n||ta)};static \u0275prov=f({token:ta,factory:ta.\u0275fac})};return t=p([_(Dd)],t),t})(),mC=[fC,_C],Td=class{static fToken=Symbol("MinimapDrawNodesRequest")},yC=(()=>{let t=class na{_browser=d(ce);_store=d(C);handle(e){let n=this._store.fFlow,o=this._store.fCanvas;return!n||!o?[]:this._store.nodes.getAll().map(s=>this._renderNode(s,n,o))}_renderNode(e,n,o){let r=en("rect",this._browser);al(this._nodeRect(e,n,o),r);let s=e instanceof Gd;return r.classList.add("f-component",s?"f-minimap-node":"f-minimap-group"),r.classList.add(...this._minimapClasses(e)),e.isSelected()&&r.classList.add("f-selected"),r}_nodeRect(e,n,o){let r=A.elementTransform(A.fromElement(e.hostElement),n.hostElement);return A.div(r,o.transform.scale)}_minimapClasses(e){let n=e.fMinimapClass();return Array.isArray(n)?n:[n]}static \u0275fac=function(n){return new(n||na)};static \u0275prov=f({token:na,factory:na.\u0275fac})};return t=p([_(Td)],t),t})(),Pd=class{svg;minSize;static fToken=Symbol("MinimapCalculateViewportRequest");constructor(i,e){this.svg=i,this.minSize=e}},vC=(()=>{let t=class ia{_mediator=d(b);_store=d(C);handle({svg:e,minSize:n}){let o=this._store.fFlow,r=this._store.fCanvas;if(!o||!r)return{scale:1,viewBox:A.initialize(0,0,0,0)};let s=this._contentRectInMinimapSpace(o,r,n),a=this._minimapRectInFlowSpace(e,o),c=this._viewportScale(s,a),l=this._viewportViewBox(s,a,c);return{scale:c,viewBox:l}}_contentRectInMinimapSpace(e,n,o){let r=this._nodesBoundingBox(),s=A.elementTransform(r,e.hostElement),a=A.div(s,n.transform.scale);return vh(a,o)}_nodesBoundingBox(){return this._mediator.execute(new ln)??A.initialize(0,0,0,0)}_minimapRectInFlowSpace(e,n){return A.elementTransform(A.fromElement(e),n.hostElement)}_viewportScale(e,n){let o=n.width||1,r=n.height||1;return Math.max(e.width/o,e.height/r)}_viewportViewBox(e,n,o){let r=this._viewportSize(n,o),s=e.x-(r.width-e.width)/2,a=e.y-(r.height-e.height)/2;return A.initialize(s,a,r.width,r.height)}_viewportSize(e,n){return Ge.initialize(e.width*n||0,e.height*n||0)}static \u0275fac=function(n){return new(n||ia)};static \u0275prov=f({token:ia,factory:ia.\u0275fac})};return t=p([_(Pd)],t),t})(),Md=class{static fToken=Symbol("MinimapCalculateViewRectRequest")},CC=(()=>{let t=class oa{_store=d(C);handle(e){let n=this._store.fFlow,o=this._store.fCanvas;if(!n||!o)return A.initialize();let r=A.div(A.fromElement(n.hostElement),o.transform.scale);return r.x=0,r.y=0,r}static \u0275fac=function(n){return new(n||oa)};static \u0275prov=f({token:oa,factory:oa.\u0275fac})};return t=p([_(Md)],t),t})(),Rd=class{element;scale;viewBox;constructor(i,e=1,n=A.initialize(0,0,0,0)){this.element=i,this.scale=e,this.viewBox=n}},wC=[yC,vC,CC],Nd=class{position;static fToken=Symbol("GetNormalizedPointRequest");constructor(i){this.position=i}},bC=(()=>{let t=class ra{_store=d(C);handle({position:e}){return mn(e,this._store.flowHost,this._store.transform)}static \u0275fac=function(n){return new(n||ra)};static \u0275prov=f({token:ra,factory:ra.\u0275fac})};return t=p([_(Nd)],t),t})(),kd=class{static fToken=Symbol("SortNodeLayersRequest")},xC=(()=>{let t=class sa{_store=d(C);_mediator=d(b);_browser=d(ce);get _canvas(){return this._store.fCanvas}get _groupsContainer(){return this._canvas.fGroupsContainer().nativeElement}get _nodesContainer(){return this._canvas.fNodesContainer().nativeElement}get _fNodeElements(){return Array.from(this._nodesContainer.children)}handle(e){this._getGroups().forEach(n=>{this._moveChildrenNodes(this._getSortedChildrenNodes(n))})}_getGroups(){return this._store.nodes.getAll().filter(e=>this._groupsContainer.contains(e.hostElement))}_getSortedChildrenNodes(e){let n=this._fNodeElements;return this._getChildrenNodes(e.fId()).sort((o,r)=>n.indexOf(o)-n.indexOf(r))}_getChildrenNodes(e){return this._mediator.execute(new pn(e)).filter(n=>this._nodesContainer.contains(n.hostElement)).map(n=>n.hostElement)}_moveChildrenNodes(e){let n=this._browser.document.createDocumentFragment();e.forEach(o=>{n.appendChild(o)}),this._nodesContainer.appendChild(n)}static \u0275fac=function(n){return new(n||sa)};static \u0275prov=f({token:sa,factory:sa.\u0275fac})};return t=p([_(kd)],t),t})(),fi=class{itemsContainer;static fToken=Symbol("SortItemsByParentRequest");constructor(i){this.itemsContainer=i}},IC=(()=>{let t=class aa{_store=d(C);_browser=d(ce);handle({itemsContainer:e}){let n=Array.from(e.children);if(n.length<2)return;let o=this._buildPositions(n),r=this._store.nodes.getAll().filter(c=>e.contains(c.hostElement));if(r.length<2||!r.some(c=>!!c.fParentId()))return;let s=this._buildChildrenByParentId(r),a=new Map;for(let c of r){let l=this._getSortedChildrenBeforeParent(e,o,c,s,a);l.length&&this._moveBeforeNextSibling(e,l,c.hostElement.nextElementSibling)}}_buildPositions(e){let n=new Map;for(let o=0;o<e.length;o++)n.set(e[o],o);return n}_getSortedChildrenBeforeParent(e,n,o,r,s){let a=n.get(o.hostElement);if(a===void 0)return[];let c=this._getDeepChildren(o.fId(),r,s);if(!c.length)return[];let l=[];for(let u of c){let h=u.hostElement;if(!e.contains(h))continue;let v=n.get(h);v===void 0||v>=a||l.push(h)}return l.sort((u,h)=>(n.get(u)??0)-(n.get(h)??0)),l}_buildChildrenByParentId(e){let n=new Map;for(let o of e){let r=o.fParentId();if(!r)continue;let s=n.get(r)??[];s.push(o),n.set(r,s)}return n}_getDeepChildren(e,n,o){let r=o.get(e);if(r)return r;let s=[],a=[...n.get(e)??[]],c=new Set([e]);for(;a.length;){let l=a.pop();if(!l)continue;let u=l.fId();if(c.has(u))continue;c.add(u),s.push(l);let h=n.get(u);h?.length&&a.push(...h)}return o.set(e,s),s}_moveBeforeNextSibling(e,n,o){let r=this._browser.document.createDocumentFragment();for(let s of n)r.appendChild(s);e.insertBefore(r,o)}static \u0275fac=function(n){return new(n||aa)};static \u0275prov=f({token:aa,factory:aa.\u0275fac})};return t=p([_(fi)],t),t})(),Od=class{static fToken=Symbol("SortItemLayersRequest")},SC=(()=>{let t=class ca{_store=d(C);_mediator=d(b);get _canvas(){return this._store.fCanvas}handle(e){if(!this._canvas)return;let n=this._store.nodes.getAll();n.length<2||!n.some(o=>!!o.fParentId())||(this._mediator.execute(new fi(this._canvas.fGroupsContainer().nativeElement)),this._mediator.execute(new kd),this._mediator.execute(new fi(this._canvas.fNodesContainer().nativeElement)))}static \u0275fac=function(n){return new(n||ca)};static \u0275prov=f({token:ca,factory:ca.\u0275fac})};return t=p([_(Od)],t),t})();function en(t,i){return i.document.createElementNS("http://www.w3.org/2000/svg",t)}function Ae(t,i){return i(t)}function je(t){return!0}function EC(){return/android|iPad|iPhone|iPod/i.test(navigator.userAgent||navigator.vendor||window.opera)}var DC=[...Yp,...nv,...Ap,...jv,...bv,...nC,...Fv,...hC,...mC,...wC,...am,dC,cm,hm,bC,SC,IC,xC,lC,cC],TC=0,Bf=(()=>{class t{_destroyRef=d(We);_elementReference=d(se);_fBrowser=d(ce);_stateChanges=new Fe;get hostElement(){return this._elementReference.nativeElement}id=R(`f-pattern-${TC++}`);vColor=R("rgba(0,0,0,0.1)");hColor=R("rgba(0,0,0,0.1)");vSize=R(20,{transform:Ee});hSize=R(20,{transform:Ee});_transform=ht.default();_position=E.initialize();_size=Ge.initialize(this.hSize(),this.vSize());_pattern;_vLine;_hLine;constructor(){this._createPattern()}_createPattern(){this._pattern=en("pattern",this._fBrowser),this._pattern.setAttribute("patternUnits","userSpaceOnUse"),this.hostElement.appendChild(this._pattern),this._vLine=en("line",this._fBrowser),this._pattern.appendChild(this._vLine),this._hLine=en("line",this._fBrowser),this._pattern.appendChild(this._hLine)}ngOnInit(){this._listenStateChanges()}_listenStateChanges(){new Ze(this._stateChanges).pipe(Fd()).listen(this._destroyRef,()=>this._redraw())}ngOnChanges(e){(e.vSize||e.hSize||e.vColor||e.hColor)&&this._refresh()}_redraw(){this._calculatePattern(),this._redrawPattern(),this._redrawLine(this._vLine,this.vColor(),this._size.width,0,this._size.width,this._size.height),this._redrawLine(this._hLine,this.hColor(),0,this._size.height,this._size.width,this._size.height)}_calculatePattern(){this._position.x=this._transform.position.x+this._transform.scaledPosition.x,this._position.y=this._transform.position.y+this._transform.scaledPosition.y,this._size=Ge.initialize(this.hSize()*this._transform.scale,this.vSize()*this._transform.scale)}_redrawPattern(){this._pattern.setAttribute("x",`${this._position.x}`),this._pattern.setAttribute("y",`${this._position.y}`),this._pattern.setAttribute("width",`${this._size.width}`),this._pattern.setAttribute("height",`${this._size.height}`)}_redrawLine(e,n,o,r,s,a){e.setAttribute("stroke",`${n}`),e.setAttribute("x1",`${o}`),e.setAttribute("x2",`${s}`),e.setAttribute("y1",`${r}`),e.setAttribute("y2",`${a}`)}setTransform(e){this._transform=e,this._refresh()}_refresh(){this._stateChanges.notify()}static \u0275fac=function(n){return new(n||t)};static \u0275cmp=ee({type:t,selectors:[["f-rect-pattern"]],hostVars:1,hostBindings:function(n,o){n&2&&K("id",o.id)},inputs:{id:[1,"id"],vColor:[1,"vColor"],hColor:[1,"hColor"],vSize:[1,"vSize"],hSize:[1,"hSize"]},features:[me([{provide:vl,useExisting:t}]),$t],decls:0,vars:0,template:function(n,o){},encapsulation:2,changeDetection:0})}return t})();var PC=new X("F_BACKGROUND"),MC=(()=>{class t{hostElement=d(se).nativeElement;static \u0275fac=function(n){return new(n||t)};static \u0275dir=le({type:t,standalone:!1})}return t})(),Gf=(()=>{class t extends MC{_mediator=d(b);fBackgroundPattern=Di(vl);ngOnInit(){this._mediator.execute(new kt(te.BACKGROUND,this))}ngAfterContentInit(){this._mediator.execute(new da(this.fBackgroundPattern()))}setTransform(e){this.fBackgroundPattern()?.setTransform(e)}ngOnDestroy(){this._mediator.execute(new Ot(te.BACKGROUND))}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275cmp=ee({type:t,selectors:[["f-background"]],contentQueries:function(n,o,r){n&1&&ol(r,o.fBackgroundPattern,vl,5),n&2&&ze()},hostAttrs:[1,"f-component","f-background"],features:[me([{provide:PC,useExisting:t}]),ne],ngContentSelectors:dp,decls:2,vars:0,template:function(n,o){n&1&&(En(),ke(),Ye(0,"svg"),ve(1),qe())},styles:["[_nghost-%COMP%]{position:absolute;width:100%;height:100%;left:0;top:0;transform-origin:0 0;pointer-events:none}[_nghost-%COMP%] svg[_ngcontent-%COMP%]{width:100%;height:100%}"],changeDetection:0})}return t})();var Au=class{position;scale;constructor(i,e){this.position=i,this.scale=e}},RC=new X("F_CANVAS"),NC=(()=>{class t{transform=ht.default();_fCanvasChange=new Fe;destroyRef=d(We);getPosition(){return this.transform.position}setPosition(e){this.transform.position=e}emitCanvasChangeEvent(){this._fCanvasChange.notify()}subscribeOnCanvasChange(){new Ze(this._fCanvasChange).pipe(la(this.debounce())).listen(this.destroyRef,()=>{this.fCanvasChange.emit(new Au(E.sum(this.transform.position,this.transform.scaledPosition),this.transform.scale))})}static \u0275fac=function(n){return new(n||t)};static \u0275dir=le({type:t,standalone:!1})}return t})(),gi=(()=>{class t extends NC{_mediator=d(b);_componentsStore=d(C);_elementReference=d(se);_injector=d(Pe);_flowId;fCanvasChange=rt();position=R(E.initialize(),{transform:E.castToPoint});scale=R(1,{transform:Ee});debounceTime=R(0,{transform:Ee});debounce=z(()=>this.debounceTime()<0?0:this.debounceTime());get hostElement(){return this._elementReference.nativeElement}fGroupsContainer=ge.required("fGroupsContainer");fNodesContainer=ge.required("fNodesContainer");fConnectionsContainer=ge.required("fConnectionsContainer");get flowId(){return this._flowId||""}ngOnInit(){this._flowId=this._mediator.execute(new fd).fId(),this._mediator.execute(new ha(this)),this._positionChange(),this._scaleChange(),super.subscribeOnCanvasChange()}_positionChange(){Se(()=>{this._mediator.execute(new pa(this.transform,this.position()))},{injector:this._injector})}_scaleChange(){Se(()=>{this._mediator.execute(new _a(this.transform,this.scale()))},{injector:this._injector})}redraw(){this._mediator.execute(new Nn(this.transform)),this.hostElement.style.removeProperty("transition"),this.hostElement.style.transform=ht.toString(this.transform),this._mediator.execute(new mt)}redrawWithAnimation(){this._mediator.execute(new Nn(this.transform)),this.hostElement.style.transition=`transform ${EC()?80:150}ms ease-in-out`,this.hostElement.style.transform=ht.toString(this.transform),Jh(this.hostElement,()=>this.redraw())}centerGroupOrNode(e,n=!0){this._afterRedraw(()=>{this._mediator.execute(new fa(e,n))})}fitToScreen(e=E.initialize(),n=!0){this._afterRedraw(()=>{this._mediator.execute(new ga(e,n))})}resetScaleAndCenter(e=!0){this._afterRedraw(()=>{this._mediator.execute(new va(e))})}getScale(){return this.transform.scale||1}setScale(e,n=E.initialize()){this._mediator.execute(new Ca(e,n))}resetScale(){this._mediator.execute(new ya)}ngOnDestroy(){this._mediator.execute(new ma)}_afterRedraw(e){this._mediator.execute(new ui(this._componentsStore.connectionsRevision,this._componentsStore.nodesRevision,()=>ah(e,{injector:this._injector}),this.destroyRef))}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275cmp=ee({type:t,selectors:[["f-canvas"]],viewQuery:function(n,o){n&1&&it(o.fGroupsContainer,lp,5)(o.fNodesContainer,up,5)(o.fConnectionsContainer,hp,5),n&2&&ze(3)},hostAttrs:[1,"f-component","f-canvas"],inputs:{position:[1,"position"],scale:[1,"scale"],debounceTime:[1,"debounceTime"]},outputs:{fCanvasChange:"fCanvasChange"},features:[me([{provide:RC,useExisting:t}]),ne],ngContentSelectors:gp,decls:12,vars:0,consts:[["fGroupsContainer",""],["fConnectionsContainer",""],["fNodesContainer",""],[1,"f-connections-container"]],template:function(n,o){n&1&&(En(fp),Ii(0),Ye(1,"div",null,0),ve(3),qe(),Ye(4,"div",3,1),ve(6,1),ve(7,2),ve(8,3),qe(),Ye(9,"div",null,2),ve(11,4),qe(),Si())},styles:["[_nghost-%COMP%]{position:absolute;overflow:visible;width:100%;height:100%;left:0;top:0;transform-origin:0 0;pointer-events:none}.f-canvas-dragging[_nghost-%COMP%], .canvas-dragging[_nghost-%COMP%]{transform:translateZ(0)}.f-connections-container[_ngcontent-%COMP%]{position:absolute;z-index:2}"],changeDetection:0})}return t})();var kC=0,jf=(()=>{class t extends V_{fId=R(`f-connection-${kC++}`,{alias:"fConnectionId"});fOutputId=R("",{transform:e=>an(e)||""});fInputId=R("",{transform:e=>an(e)||""});fRadius=8;fOffset=12;fBehavior=pt.FIXED;fType=gt.STRAIGHT;fSelectionDisabled=R(!1,{transform:Q});fReassignableStart=R(!1,{transform:Q});fDraggingDisabled=R(!1,{alias:"fReassignDisabled",transform:Q});fInputSide=R(De.DEFAULT,{transform:e=>Zt(e,"fInputSide",De)});fOutputSide=R(De.DEFAULT,{transform:e=>Zt(e,"fOutputSide",De)});get boundingElement(){return this.fPath().hostElement}_mediator=d(b);ngOnInit(){this._mediator.execute(new wa(this))}ngOnChanges(){this._mediator.execute(new Nt)}ngOnDestroy(){this._mediator.execute(new Ua(this))}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275cmp=ee({type:t,selectors:[["f-connection"]],hostAttrs:[1,"f-component","f-connection"],hostVars:5,hostBindings:function(n,o){n&2&&(K("id",o.fId()),Be("f-connection-selection-disabled",o.fSelectionDisabled())("f-connection-reassign-disabled",o.fDraggingDisabled()))},inputs:{fId:[1,"fConnectionId","fId"],fOutputId:[1,"fOutputId"],fInputId:[1,"fInputId"],fRadius:[2,"fRadius","fRadius",Ee],fOffset:[2,"fOffset","fOffset",Ee],fBehavior:[2,"fBehavior","fBehavior",e=>Zt(e,"fBehavior",pt)],fType:"fType",fSelectionDisabled:[1,"fSelectionDisabled"],fReassignableStart:[1,"fReassignableStart"],fDraggingDisabled:[1,"fReassignDisabled","fDraggingDisabled"],fInputSide:[1,"fInputSide"],fOutputSide:[1,"fOutputSide"]},exportAs:["fComponent"],standalone:!1,features:[me([{provide:Ad,useExisting:t}]),ne,$t],ngContentSelectors:_p,decls:15,vars:6,consts:[["defs",""],["xmlns","http://www.w3.org/2000/svg"],[1,"f-connection-group"],["fConnectionGradientRenderer","",3,"fConnectionGradientRendererFor"],["fConnectionSelection",""],["f-connection-path","",3,"useGradient"],["f-connection-drag-handle-start","","r","8"],["f-connection-drag-handle-end","","r","8"]],template:function(n,o){if(n&1&&(En(pp),ke(),m(0,"svg",1),j(1,"defs",null,0),ve(3),m(4,"g",2),O(5,mp,1,1,":svg:linearGradient",3),j(6,"path",4),m(7,"g"),j(8,"path",5),O(9,yp,1,0,":svg:circle",6),j(10,"circle",7),y()()(),ve(11,1),ve(12,2),ve(13,3),O(14,vp,1,0)),n&2){let r;g(5),F((r=o.fGradient())?5:-1,r),g(),K("d",o.path),g(2),N("useGradient",!!o.fGradient()),K("d",o.path),g(),F(o.fReassignableStart()?9:-1),g(5),F(o.fContents().length?14:-1)}},dependencies:[zl,B_,G_,k_,z_],styles:["[_nghost-%COMP%]{pointer-events:none}[_nghost-%COMP%] svg[_ngcontent-%COMP%]{display:block;vertical-align:middle;overflow:visible!important;position:absolute}[_nghost-%COMP%] svg[_ngcontent-%COMP%] .f-connection-group[_ngcontent-%COMP%]{pointer-events:all}[_nghost-%COMP%] .f-connection-content[_ngcontent-%COMP%]{pointer-events:all}"],changeDetection:0})}return t})();var OC=new X("F_MAGNETIC_LINES"),FC=(()=>{class t{hostElement=d(se).nativeElement;static \u0275fac=function(n){return new(n||t)};static \u0275dir=le({type:t,standalone:!1})}return t})();var Hf=(()=>{class t extends FC{threshold=R(10,{transform:Ee,alias:"fAlignThreshold"});_mediator=d(b);ngOnInit(){this._mediator.execute(new kt(te.MAGNETIC_LINES,this))}ngOnDestroy(){this._mediator.execute(new Ot(te.MAGNETIC_LINES))}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275cmp=ee({type:t,selectors:[["f-line-alignment"]],hostAttrs:[1,"f-line-alignment","f-component"],inputs:{threshold:[1,"fAlignThreshold","threshold"]},exportAs:["fComponent"],standalone:!1,features:[me([{provide:OC,useExisting:t}]),ne],decls:0,vars:0,template:function(n,o){},styles:[Cp]})}return t})();var _l=(()=>{class t{fMinSize=R(1e3);_mediator=d(b);hostElement=d(se).nativeElement;model=new Rd(this.hostElement);redraw(){let{scale:e,viewBox:n}=this._mediator.execute(new Pd(this.hostElement,this.fMinSize()));this.model=new Rd(this.hostElement,e,n),Ch(n,this.hostElement)}static \u0275fac=function(n){return new(n||t)};static \u0275dir=le({type:t,selectors:[["svg","fMinimapFlow",""]],inputs:{fMinSize:[1,"fMinSize"]}})}return t})(),ml=(()=>{class t{_mediator=d(b);_elementRef=d(se);hostElement=this._elementRef.nativeElement;redraw(){this.clear();let e=this._elementRef.nativeElement.ownerDocument.createDocumentFragment();this._mediator.execute(new Td).forEach(n=>{e.appendChild(n)}),this.hostElement.appendChild(e)}clear(){this.hostElement.replaceChildren()}static \u0275fac=function(n){return new(n||t)};static \u0275dir=le({type:t,selectors:[["g","fMinimapCanvas",""]]})}return t})(),yl=(()=>{class t{_mediator=d(b);hostElement=d(se).nativeElement;redraw(){al(this._mediator.execute(new Md),this.hostElement)}static \u0275fac=function(n){return new(n||t)};static \u0275dir=le({type:t,selectors:[["rect","fMinimapView",""]],hostAttrs:[1,"f-component","f-minimap-view"]})}return t})(),AC=new X("F_MINIMAP_BASE"),LC=(()=>{class t{hostElement=d(se).nativeElement;static \u0275fac=function(n){return new(n||t)};static \u0275dir=le({type:t,standalone:!1})}return t})(),Vf=(()=>{class t extends LC{_destroyRef=d(We);_mediator=d(b);_browser=d(ce);_store=d(C);_canvas=ge.required(ml);_flow=ge.required(_l);_minimapView=ge.required(yl);fMinSize=R(1e3);fNodeRenderLimit=R(1500,{transform:Ee});get state(){return this._flow().model}ngOnInit(){this._mediator.execute(new kt(te.MINIMAP,this))}ngAfterViewInit(){this._listenTransformChanges()}_listenTransformChanges(){this._mediator.execute(new ua).pipe(Fd(),Ip()).listen(this._destroyRef,()=>{this._redraw()})}_redraw(){if(this._browser.isBrowser()){if(this._isOverNodeRenderLimit()){this._canvas().clear();return}this._flow().redraw(),this._minimapView().redraw(),this._canvas().redraw()}}_isOverNodeRenderLimit(){let e=this.fNodeRenderLimit();return e>0&&this._store.nodes.size()>e}ngOnDestroy(){this._mediator.execute(new Ot(te.MINIMAP))}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275cmp=ee({type:t,selectors:[["f-minimap"]],viewQuery:function(n,o){n&1&&it(o._canvas,ml,5)(o._flow,_l,5)(o._minimapView,yl,5),n&2&&ze(3)},hostAttrs:[1,"f-component","f-minimap"],inputs:{fMinSize:[1,"fMinSize"],fNodeRenderLimit:[1,"fNodeRenderLimit"]},exportAs:["fComponent"],features:[me([{provide:AC,useExisting:t}]),ne],decls:3,vars:1,consts:[["fMinimapFlow","","width","100%","height","100%","fLockedContext","",3,"fMinSize"],["fMinimapCanvas",""],["fMinimapView","","x","0","y","0","width","100%","height","100%","stroke","none"]],template:function(n,o){n&1&&(ke(),m(0,"svg",0),j(1,"g",1)(2,"rect",2),y()),n&2&&N("fMinSize",o.fMinSize())},dependencies:[_l,ml,yl],styles:["[_nghost-%COMP%]{display:block;position:absolute}[_nghost-%COMP%] svg[_ngcontent-%COMP%]{overflow:hidden}"],changeDetection:0})}return t})();var zC=0,BC=120,Uf=(()=>{class t extends Fu{_destroyRef=d(We);_mediator=d(b);_browser=d(ce);_componentsStore=d(C);_cache=d(Qe);_injector=d(Pe);fId=R(`f-flow-${zC++}`,{alias:"fFlowId"});fCache=R(!1,{transform:Q});hostElement=d(se).nativeElement;fNodesRendered=rt();fFullRendered=rt();fLoaded=rt();ngOnInit(){this._mediator.execute(new hd(this)),this._listenCacheChanges()}ngAfterContentInit(){this._browser.isBrowser()&&(this._listenNodesChanges(),this._listenConnectionsChanges())}_listenCacheChanges(){Se(()=>{this._cache.enabled=this.fCache()},{injector:this._injector})}_listenNodesChanges(){new Ze(this._componentsStore.nodesChanges$,this._componentsStore.progressiveRenderChanges$).pipe(Fd(),la(BC),xp()).listen(this._destroyRef,()=>{this._mediator.execute(new bt)||this._componentsStore.hasPendingProgressiveRender||(this._mediator.execute(new Od),this._mediator.execute(new md),this._mediator.execute(new ui(this._componentsStore.connectionsRevision+1,this._componentsStore.nodesRevision,()=>this._mediator.execute(new yd),this._destroyRef)),this._mediator.execute(new Nt))})}_listenConnectionsChanges(){this._mediator.execute(new Qt).listen(this._destroyRef,()=>{if(!this._mediator.execute(new bt)){if(this._componentsStore.isViewportAnimating){this._mediator.execute(new Cd(this._destroyRef));return}this._mediator.execute(new Gn)}})}redraw(){this._mediator.execute(new Nt)}reset(){this._mediator.execute(new vd)}getNodesBoundingBox(){return this._mediator.execute(new cd)}getSelection(){return this._mediator.execute(new hi)}getPositionInFlow(e){return this._mediator.execute(new Nd(e))}getState(e){return this._mediator.execute(new pd(e?.measuredSize??!1))}selectAll(){this._mediator.execute(new Qt).pipe(Eh()).listen(this._destroyRef,()=>{this._mediator.execute(new Id)})}select(e,n,o=!0){this._mediator.execute(new Qt).pipe(Eh()).listen(this._destroyRef,()=>{this._mediator.execute(new xd(e,n,o))})}clearSelection(){this._mediator.execute(new wd)}ngOnDestroy(){this._mediator.execute(new _d(this))}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275cmp=ee({type:t,selectors:[["f-flow"]],hostAttrs:[1,"f-component","f-flow"],hostVars:1,hostBindings:function(n,o){n&2&&K("id",o.fId())},inputs:{fId:[1,"fFlowId","fId"],fCache:[1,"fCache"]},outputs:{fNodesRendered:"fNodesRendered",fFullRendered:"fFullRendered",fLoaded:"fLoaded"},features:[me([b,...Np,lf,_n,...DC,G,...Jy,{provide:Gu,useExisting:t}]),ne],ngContentSelectors:bp,decls:7,vars:0,template:function(n,o){n&1&&(En(wp),Ii(0),ve(1),ve(2,1),ve(3,2),ve(4,3),ve(5,4),ve(6,5),Si())},styles:["[_nghost-%COMP%]{display:block;position:relative;width:100%;height:100%;overflow:hidden;pointer-events:all;-webkit-user-select:none;user-select:none;touch-action:none} .f-connection-content{position:absolute;left:0;top:0;inline-size:max-content;pointer-events:all;transform-origin:50% 50%} .f-node, .f-group{position:absolute!important;transform-origin:center;-webkit-user-select:none;user-select:none;pointer-events:all;left:0!important;top:0!important;box-sizing:border-box} .f-group{z-index:1} .f-connection-content{z-index:3} .f-node{z-index:4}.hidden[_ngcontent-%COMP%]{opacity:0}"],changeDetection:0})}return t})();var Wf=(()=>{class t{fVirtualForOf=[];fVirtualForTrackBy;_vc=d(Ci);_tpl=d(ch);_zone=d(Sn);_componentsStore=d(C,{optional:!0});_views=[];_rafId=null;_isProgressiveRenderActive=!1;ngOnChanges(e){e.fVirtualForOf&&(this._reset(),this._renderProgressively())}ngOnDestroy(){this._reset()}_reset(){this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null),this._finishProgressiveRender(),this._vc.clear(),this._views.length=0}_renderProgressively(){let n=0;this._startProgressiveRender(),this._zone.runOutsideAngular(()=>{let o=()=>{let r=performance.now();for(;n<this.fVirtualForOf.length&&performance.now()-r<10;){let s=this.fVirtualForOf[n],a=this._vc.createEmbeddedView(this._tpl,{$implicit:s,index:n});this._views.push(a),n++}if(n<this.fVirtualForOf.length){this._rafId=requestAnimationFrame(o);return}this._rafId=null,this._finishProgressiveRender()};this._rafId=requestAnimationFrame(o)})}_startProgressiveRender(){this._isProgressiveRenderActive||(this._isProgressiveRenderActive=!0,this._componentsStore?.beginProgressiveRender())}_finishProgressiveRender(){this._isProgressiveRenderActive&&(this._isProgressiveRenderActive=!1,this._componentsStore?.endProgressiveRender())}static \u0275fac=function(n){return new(n||t)};static \u0275dir=le({type:t,selectors:[["","fVirtualFor","","fVirtualForOf",""]],inputs:{fVirtualForOf:"fVirtualForOf",fVirtualForTrackBy:"fVirtualForTrackBy"},features:[$t]})}return t})();var at=(function(t){return t[t.ZOOM_IN=1]="ZOOM_IN",t[t.ZOOM_OUT=-1]="ZOOM_OUT",t})(at||{}),GC=new X("F_ZOOM"),Lu=class{},jC=.1,HC=1,VC=.5,UC=60,WC=.5;function $C(t){return Math.abs(t.deltaY)>=Math.abs(t.deltaX)?t.deltaY:t.deltaX}function YC(t,i,e){return qC(t)?KC(i,e):XC(i,e)}function qC(t){return(t.ctrlKey||t.metaKey)&&t.deltaMode===WheelEvent.DOM_DELTA_PIXEL}function XC(t,i){let e=Math.abs(t)/100,n=$f(e,jC,HC);return i*n}function KC(t,i){if(Math.abs(t)<VC)return 0;let e=Math.abs(t)/UC,n=$f(e,0,WC);return i*n}function $f(t,i,e){return Math.max(i,Math.min(e,t))}var pi=(()=>{class t extends Lu{_mediator=d(b);_injector=d(Pe);_store=d(C);_triggersListener=Y.emptyListener();isEnabled=R(!1,{alias:"fZoom",transform:Q});fWheelTrigger=je;fDblClickTrigger=je;minimum=.1;maximum=4;step=.1;dblClickStep=.5;get _flowHost(){return this._store.flowHost}get _canvas(){return this._store.fCanvas}ngOnInit(){this._mediator.execute(new kt(te.ZOOM,this))}ngAfterViewInit(){this._listenZoomEnabledChanges()}_listenZoomEnabledChanges(){Se(()=>{this.isEnabled(),Et(()=>this._listenTriggers())},{injector:this._injector})}_listenTriggers(){this._flowHost&&(this._disposeListeners(),this.isEnabled()&&(this._listen("wheel",this._onWheel,Y.activeListener()),this._listen("dblclick",this._onDoubleClick),this._triggersListener=()=>{this._unlisten("wheel",this._onWheel,Y.activeListener()),this._unlisten("dblclick",this._onDoubleClick)}))}_onWheel=e=>{if(!Ae(e,this.fWheelTrigger)||(e.preventDefault(),e.target?.closest("[fLockedContext]")))return;let o=$C(e);if(o===0)return;let r=this._normalizeWheelStep(e,o);r!==0&&this.setZoom(E.initialize(e.clientX,e.clientY),r,this._calculateDirection(o),!1)};_normalizeWheelStep(e,n){return YC(e,n,this.step)}_calculateDirection(e){return e>0?at.ZOOM_OUT:at.ZOOM_IN}_onDoubleClick=e=>{if(!Ae(e,this.fDblClickTrigger))return;e.preventDefault();let n=e.target;f0(n)||n?.closest("[fLockedContext]")||this.setZoom(E.initialize(e.clientX,e.clientY),this.dblClickStep,at.ZOOM_IN,!0)};_getToCenterPosition(e,n){return E.initialize(e?.x||n.gravityCenter.x,e?.y||n.gravityCenter.y)}zoomIn(e){this._onZoomToCenter(at.ZOOM_IN,e)}zoomOut(e){this._onZoomToCenter(at.ZOOM_OUT,e)}_onZoomToCenter(e,n){this.setZoom(this._getToCenterPosition(n,A.fromElement(this._flowHost)),this.step,e,!1)}setZoom(e,n,o,r){this._mediator.execute(new Dd(e,n,o,r))}getZoomValue(){return this._canvas.transform.scale||1}reset(){this._mediator.execute(new Ed)}_disposeListeners(){this._triggersListener(),this._triggersListener=Y.emptyListener()}ngOnDestroy(){this._disposeListeners(),this._mediator.execute(new Ot(te.ZOOM))}_listen(e,n,o){this._flowHost.addEventListener(e,n,o)}_unlisten(e,n,o){this._flowHost.removeEventListener(e,n,o)}static \u0275fac=(()=>{let e;return function(o){return(e||(e=V(t)))(o||t)}})();static \u0275dir=le({type:t,selectors:[["f-canvas","fZoom",""]],hostAttrs:[1,"f-zoom","f-component"],inputs:{isEnabled:[1,"fZoom","isEnabled"],fWheelTrigger:"fWheelTrigger",fDblClickTrigger:"fDblClickTrigger",minimum:[2,"fZoomMinimum","minimum",Ee],maximum:[2,"fZoomMaximum","maximum",Ee],step:[2,"fZoomStep","step",Ee],dblClickStep:[2,"fZoomDblClickStep","dblClickStep",Ee]},features:[me([{provide:GC,useExisting:t}]),ne]})}return t})();var Yf=(()=>{class t{static \u0275fac=function(n){return new(n||t)};static \u0275mod=lh({type:t});static \u0275inj=rh({imports:[gh]})}return t})();var ag=Object.defineProperty,QC=(t,i,e)=>i in t?ag(t,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[i]=e,JC=(t,i)=>{for(var e in i)ag(t,e,{get:i[e],enumerable:!0})},ew=(t,i,e)=>QC(t,typeof i!="symbol"?i+"":i,e),qu={};JC(qu,{Graph:()=>Ve,alg:()=>Xu,json:()=>dg,version:()=>iw});var tw=Object.defineProperty,cg=(t,i)=>{for(var e in i)tw(t,e,{get:i[e],enumerable:!0})},Ve=class{constructor(t){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},t&&(this._isDirected="directed"in t?t.directed:!0,this._isMultigraph="multigraph"in t?t.multigraph:!1,this._isCompound="compound"in t?t.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(t){return this._label=t,this}graph(){return this._label}setDefaultNodeLabel(t){return typeof t!="function"?this._defaultNodeLabelFn=()=>t:this._defaultNodeLabelFn=t,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(t=>Object.keys(this._in[t]).length===0)}sinks(){return this.nodes().filter(t=>Object.keys(this._out[t]).length===0)}setNodes(t,i){return t.forEach(e=>{i!==void 0?this.setNode(e,i):this.setNode(e)}),this}setNode(t,i){return t in this._nodes?(arguments.length>1&&(this._nodes[t]=i),this):(this._nodes[t]=arguments.length>1?i:this._defaultNodeLabelFn(t),this._isCompound&&(this._parent[t]="\0",this._children[t]={},this._children["\0"][t]=!0),this._in[t]={},this._preds[t]={},this._out[t]={},this._sucs[t]={},++this._nodeCount,this)}node(t){return this._nodes[t]}hasNode(t){return t in this._nodes}removeNode(t){if(t in this._nodes){let i=e=>this.removeEdge(this._edgeObjs[e]);delete this._nodes[t],this._isCompound&&(this._removeFromParentsChildList(t),delete this._parent[t],this.children(t).forEach(e=>{this.setParent(e)}),delete this._children[t]),Object.keys(this._in[t]).forEach(i),delete this._in[t],delete this._preds[t],Object.keys(this._out[t]).forEach(i),delete this._out[t],delete this._sucs[t],--this._nodeCount}return this}setParent(t,i){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(i===void 0)i="\0";else{i+="";for(let e=i;e!==void 0;e=this.parent(e))if(e===t)throw new Error("Setting "+i+" as parent of "+t+" would create a cycle");this.setNode(i)}return this.setNode(t),this._removeFromParentsChildList(t),this._parent[t]=i,this._children[i][t]=!0,this}parent(t){if(this._isCompound){let i=this._parent[t];if(i!=="\0")return i}}children(t="\0"){if(this._isCompound){let i=this._children[t];if(i)return Object.keys(i)}else{if(t==="\0")return this.nodes();if(this.hasNode(t))return[]}return[]}predecessors(t){let i=this._preds[t];if(i)return Object.keys(i)}successors(t){let i=this._sucs[t];if(i)return Object.keys(i)}neighbors(t){let i=this.predecessors(t);if(i){let e=new Set(i);for(let n of this.successors(t))e.add(n);return Array.from(e.values())}}isLeaf(t){let i;return this.isDirected()?i=this.successors(t):i=this.neighbors(t),i.length===0}filterNodes(t){let i=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});i.setGraph(this.graph()),Object.entries(this._nodes).forEach(([o,r])=>{t(o)&&i.setNode(o,r)}),Object.values(this._edgeObjs).forEach(o=>{i.hasNode(o.v)&&i.hasNode(o.w)&&i.setEdge(o,this.edge(o))});let e={},n=o=>{let r=this.parent(o);return!r||i.hasNode(r)?(e[o]=r??void 0,r??void 0):r in e?e[r]:n(r)};return this._isCompound&&i.nodes().forEach(o=>i.setParent(o,n(o))),i}setDefaultEdgeLabel(t){return typeof t!="function"?this._defaultEdgeLabelFn=()=>t:this._defaultEdgeLabelFn=t,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(t,i){return t.reduce((e,n)=>(i!==void 0?this.setEdge(e,n,i):this.setEdge(e,n),n)),this}setEdge(t,i,e,n){let o,r,s,a,c=!1;typeof t=="object"&&t!==null&&"v"in t?(o=t.v,r=t.w,s=t.name,arguments.length===2&&(a=i,c=!0)):(o=t,r=i,s=n,arguments.length>2&&(a=e,c=!0)),o=""+o,r=""+r,s!==void 0&&(s=""+s);let l=_i(this._isDirected,o,r,s);if(l in this._edgeLabels)return c&&(this._edgeLabels[l]=a),this;if(s!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(o),this.setNode(r),this._edgeLabels[l]=c?a:this._defaultEdgeLabelFn(o,r,s);let u=nw(this._isDirected,o,r,s);return o=u.v,r=u.w,Object.freeze(u),this._edgeObjs[l]=u,qf(this._preds[r],o),qf(this._sucs[o],r),this._in[r][l]=u,this._out[o][l]=u,this._edgeCount++,this}edge(t,i,e){let n=arguments.length===1?ju(this._isDirected,t):_i(this._isDirected,t,i,e);return this._edgeLabels[n]}edgeAsObj(t,i,e){let n=arguments.length===1?this.edge(t):this.edge(t,i,e);return typeof n!="object"?{label:n}:n}hasEdge(t,i,e){return(arguments.length===1?ju(this._isDirected,t):_i(this._isDirected,t,i,e))in this._edgeLabels}removeEdge(t,i,e){let n=arguments.length===1?ju(this._isDirected,t):_i(this._isDirected,t,i,e),o=this._edgeObjs[n];if(o){let r=o.v,s=o.w;delete this._edgeLabels[n],delete this._edgeObjs[n],Xf(this._preds[s],r),Xf(this._sucs[r],s),delete this._in[s][n],delete this._out[r][n],this._edgeCount--}return this}inEdges(t,i){return this.isDirected()?this.filterEdges(this._in[t],t,i):this.nodeEdges(t,i)}outEdges(t,i){return this.isDirected()?this.filterEdges(this._out[t],t,i):this.nodeEdges(t,i)}nodeEdges(t,i){if(t in this._nodes)return this.filterEdges(W(W({},this._in[t]),this._out[t]),t,i)}_removeFromParentsChildList(t){delete this._children[this._parent[t]][t]}filterEdges(t,i,e){if(!t)return;let n=Object.values(t);return e?n.filter(o=>o.v===i&&o.w===e||o.v===e&&o.w===i):n}};function qf(t,i){t[i]?t[i]++:t[i]=1}function Xf(t,i){t[i]!==void 0&&!--t[i]&&delete t[i]}function _i(t,i,e,n){let o=""+i,r=""+e;if(!t&&o>r){let s=o;o=r,r=s}return o+""+r+""+(n===void 0?"\0":n)}function nw(t,i,e,n){let o=""+i,r=""+e;if(!t&&o>r){let a=o;o=r,r=a}let s={v:o,w:r};return n&&(s.name=n),s}function ju(t,i){return _i(t,i.v,i.w,i.name)}var iw="4.0.1",dg={};cg(dg,{read:()=>aw,write:()=>ow});function ow(t){let i={options:{directed:t.isDirected(),multigraph:t.isMultigraph(),compound:t.isCompound()},nodes:rw(t),edges:sw(t)},e=t.graph();return e!==void 0&&(i.value=structuredClone(e)),i}function rw(t){return t.nodes().map(i=>{let e=t.node(i),n=t.parent(i),o={v:i};return e!==void 0&&(o.value=e),n!==void 0&&(o.parent=n),o})}function sw(t){return t.edges().map(i=>{let e=t.edge(i),n={v:i.v,w:i.w};return i.name!==void 0&&(n.name=i.name),e!==void 0&&(n.value=e),n})}function aw(t){let i=new Ve(t.options);return t.value!==void 0&&i.setGraph(t.value),t.nodes.forEach(e=>{i.setNode(e.v,e.value),e.parent&&i.setParent(e.v,e.parent)}),t.edges.forEach(e=>{i.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),i}var Xu={};cg(Xu,{CycleException:()=>Vd,bellmanFord:()=>lg,components:()=>lw,dijkstra:()=>Hd,dijkstraAll:()=>fw,findCycles:()=>gw,floydWarshall:()=>_w,isAcyclic:()=>yw,postorder:()=>Cw,preorder:()=>ww,prim:()=>bw,shortestPaths:()=>xw,tarjan:()=>hg,topsort:()=>fg});var cw=()=>1;function lg(t,i,e,n){return dw(t,String(i),e||cw,n||function(o){return t.outEdges(o)})}function dw(t,i,e,n){let o={},r,s=0,a=t.nodes(),c=function(h){let v=e(h);o[h.v].distance+v<o[h.w].distance&&(o[h.w]={distance:o[h.v].distance+v,predecessor:h.v},r=!0)},l=function(){a.forEach(function(h){n(h).forEach(function(v){let w=v.v===h?v.v:v.w,S=w===v.v?v.w:v.v;c({v:w,w:S})})})};a.forEach(function(h){let v=h===i?0:Number.POSITIVE_INFINITY;o[h]={distance:v,predecessor:""}});let u=a.length;for(let h=1;h<u&&(r=!1,s++,l(),!!r);h++);if(s===u-1&&(r=!1,l(),r))throw new Error("The graph contains a negative weight cycle");return o}function lw(t){let i={},e=[],n;function o(r){r in i||(i[r]=!0,n.push(r),t.successors(r).forEach(o),t.predecessors(r).forEach(o))}return t.nodes().forEach(function(r){n=[],o(r),n.length&&e.push(n)}),e}var ug=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(t=>t.key)}has(t){return t in this._keyIndices}priority(t){let i=this._keyIndices[t];if(i!==void 0)return this._arr[i].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(t,i){let e=this._keyIndices,n=String(t);if(!(n in e)){let o=this._arr,r=o.length;return e[n]=r,o.push({key:n,priority:i}),this._decrease(r),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);let t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key}decrease(t,i){let e=this._keyIndices[t];if(e===void 0)throw new Error(`Key not found: ${t}`);let n=this._arr[e].priority;if(i>n)throw new Error(`New priority is greater than current priority. Key: ${t} Old: ${n} New: ${i}`);this._arr[e].priority=i,this._decrease(e)}_heapify(t){let i=this._arr,e=2*t,n=e+1,o=t;e<i.length&&(o=i[e].priority<i[o].priority?e:o,n<i.length&&(o=i[n].priority<i[o].priority?n:o),o!==t&&(this._swap(t,o),this._heapify(o)))}_decrease(t){let i=this._arr,e=i[t].priority,n;for(;t!==0&&(n=t>>1,!(i[n].priority<e));)this._swap(t,n),t=n}_swap(t,i){let e=this._arr,n=this._keyIndices,o=e[t],r=e[i];e[t]=r,e[i]=o,n[r.key]=t,n[o.key]=i}},uw=()=>1;function Hd(t,i,e,n){let o=function(r){return t.outEdges(r)};return hw(t,String(i),e||uw,n||o)}function hw(t,i,e,n){let o={},r=new ug,s,a,c=function(l){let u=l.v!==s?l.v:l.w,h=o[u],v=e(l),w=a.distance+v;if(v<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+l+" Weight: "+v);w<h.distance&&(h.distance=w,h.predecessor=s,r.decrease(u,w))};for(t.nodes().forEach(function(l){let u=l===i?0:Number.POSITIVE_INFINITY;o[l]={distance:u,predecessor:""},r.add(l,u)});r.size()>0&&(s=r.removeMin(),a=o[s],a.distance!==Number.POSITIVE_INFINITY);)n(s).forEach(c);return o}function fw(t,i,e){return t.nodes().reduce(function(n,o){return n[o]=Hd(t,o,i,e),n},{})}function hg(t){let i=0,e=[],n={},o=[];function r(s){let a=n[s]={onStack:!0,lowlink:i,index:i++};if(e.push(s),t.successors(s).forEach(function(c){c in n?n[c].onStack&&(a.lowlink=Math.min(a.lowlink,n[c].index)):(r(c),a.lowlink=Math.min(a.lowlink,n[c].lowlink))}),a.lowlink===a.index){let c=[],l;do l=e.pop(),n[l].onStack=!1,c.push(l);while(s!==l);o.push(c)}}return t.nodes().forEach(function(s){s in n||r(s)}),o}function gw(t){return hg(t).filter(function(i){return i.length>1||i.length===1&&t.hasEdge(i[0],i[0])})}var pw=()=>1;function _w(t,i,e){return mw(t,i||pw,e||function(n){return t.outEdges(n)})}function mw(t,i,e){let n={},o=t.nodes();return o.forEach(function(r){n[r]={},n[r][r]={distance:0,predecessor:""},o.forEach(function(s){r!==s&&(n[r][s]={distance:Number.POSITIVE_INFINITY,predecessor:""})}),e(r).forEach(function(s){let a=s.v===r?s.w:s.v,c=i(s);n[r][a]={distance:c,predecessor:r}})}),o.forEach(function(r){let s=n[r];o.forEach(function(a){let c=n[a];o.forEach(function(l){let u=c[r],h=s[l],v=c[l],w=u.distance+h.distance;w<v.distance&&(v.distance=w,v.predecessor=h.predecessor)})})}),n}var Vd=class extends Error{constructor(...t){super(...t)}};function fg(t){let i={},e={},n=[];function o(r){if(r in e)throw new Vd;r in i||(e[r]=!0,i[r]=!0,t.predecessors(r).forEach(o),delete e[r],n.push(r))}if(t.sinks().forEach(o),Object.keys(i).length!==t.nodeCount())throw new Vd;return n}function yw(t){try{fg(t)}catch(i){if(i instanceof Vd)return!1;throw i}return!0}function vw(t,i,e,n,o){Array.isArray(i)||(i=[i]);let r=a=>{var c;return(c=t.isDirected()?t.successors(a):t.neighbors(a))!=null?c:[]},s={};return i.forEach(function(a){if(!t.hasNode(a))throw new Error("Graph does not have node: "+a);o=gg(t,a,e==="post",s,r,n,o)}),o}function gg(t,i,e,n,o,r,s){return i in n||(n[i]=!0,e||(s=r(s,i)),o(i).forEach(function(a){s=gg(t,a,e,n,o,r,s)}),e&&(s=r(s,i))),s}function pg(t,i,e){return vw(t,i,e,function(n,o){return n.push(o),n},[])}function Cw(t,i){return pg(t,i,"post")}function ww(t,i){return pg(t,i,"pre")}function bw(t,i){let e=new Ve,n={},o=new ug,r;function s(c){let l=c.v===r?c.w:c.v,u=o.priority(l);if(u!==void 0){let h=i(c);h<u&&(n[l]=r,o.decrease(l,h))}}if(t.nodeCount()===0)return e;t.nodes().forEach(function(c){o.add(c,Number.POSITIVE_INFINITY),e.setNode(c)}),o.decrease(t.nodes()[0],0);let a=!1;for(;o.size()>0;){if(r=o.removeMin(),r in n)e.setEdge(r,n[r]);else{if(a)throw new Error("Input graph is not connected: "+t);a=!0}t.nodeEdges(r).forEach(s)}return e}function xw(t,i,e,n){return Iw(t,i,e,n??(o=>{let r=t.outEdges(o);return r??[]}))}function Iw(t,i,e,n){if(e===void 0)return Hd(t,i,e,n);let o=!1,r=t.nodes();for(let s=0;s<r.length;s++){let a=n(r[s]);for(let c=0;c<a.length;c++){let l=a[c],u=l.v===r[s]?l.v:l.w,h=u===l.v?l.w:l.v;e({v:u,w:h})<0&&(o=!0)}if(o)return lg(t,i,e,n)}return Hd(t,i,e,n)}function vn(t,i,e,n){let o=n;for(;t.hasNode(o);)o=Ku(n);return e.dummy=i,t.setNode(o,e),o}function Sw(t){let i=new Ve().setGraph(t.graph());return t.nodes().forEach(e=>i.setNode(e,t.node(e))),t.edges().forEach(e=>{let n=i.edge(e.v,e.w)||{weight:0,minlen:1},o=t.edge(e);i.setEdge(e.v,e.w,{weight:n.weight+o.weight,minlen:Math.max(n.minlen,o.minlen)})}),i}function _g(t){let i=new Ve({multigraph:t.isMultigraph()}).setGraph(t.graph());return t.nodes().forEach(e=>{t.children(e).length||i.setNode(e,t.node(e))}),t.edges().forEach(e=>{i.setEdge(e,t.edge(e))}),i}function Kf(t,i){let e=t.x,n=t.y,o=i.x-e,r=i.y-n,s=t.width/2,a=t.height/2;if(!o&&!r)throw new Error("Not possible to find intersection inside of the rectangle");let c,l;return Math.abs(r)*s>Math.abs(o)*a?(r<0&&(a=-a),c=a*o/r,l=a):(o<0&&(s=-s),c=s,l=s*r/o),{x:e+c,y:n+l}}function Wd(t){let i=mi(yg(t)+1).map(()=>[]);return t.nodes().forEach(e=>{let n=t.node(e),o=n.rank;o!==void 0&&(i[o]||(i[o]=[]),i[o][n.order]=e)}),i}function Ew(t){let i=t.nodes().map(n=>{let o=t.node(n).rank;return o===void 0?Number.MAX_VALUE:o}),e=et(Math.min,i);t.nodes().forEach(n=>{let o=t.node(n);Object.hasOwn(o,"rank")&&(o.rank-=e)})}function Dw(t){let i=t.nodes().map(s=>t.node(s).rank).filter(s=>s!==void 0),e=et(Math.min,i),n=[];t.nodes().forEach(s=>{let a=t.node(s).rank-e;n[a]||(n[a]=[]),n[a].push(s)});let o=0,r=t.graph().nodeRankFactor;Array.from(n).forEach((s,a)=>{s===void 0&&a%r!==0?--o:s!==void 0&&o&&s.forEach(c=>t.node(c).rank+=o)})}function Zf(t,i,e,n){let o={width:0,height:0};return arguments.length>=4&&(o.rank=e,o.order=n),vn(t,"border",o,i)}function Tw(t,i=mg){let e=[];for(let n=0;n<t.length;n+=i){let o=t.slice(n,n+i);e.push(o)}return e}var mg=65535;function et(t,i){if(i.length>mg){let e=Tw(i);return t(...e.map(n=>t(...n)))}else return t(...i)}function yg(t){let i=t.nodes().map(e=>{let n=t.node(e).rank;return n===void 0?Number.MIN_VALUE:n});return et(Math.max,i)}function Pw(t,i){let e={lhs:[],rhs:[]};return t.forEach(n=>{i(n)?e.lhs.push(n):e.rhs.push(n)}),e}function Mw(t,i){let e=Date.now();try{return i()}finally{console.log(t+" time: "+(Date.now()-e)+"ms")}}function Rw(t,i){return i()}var Nw=0;function Ku(t){let i=++Nw;return t+(""+i)}function mi(t,i,e=1){i==null&&(i=t,t=0);let n=r=>r<i;e<0&&(n=r=>i<r);let o=[];for(let r=t;n(r);r+=e)o.push(r);return o}function Ud(t,i){let e={};for(let n of i)t[n]!==void 0&&(e[n]=t[n]);return e}function $d(t,i){let e;return typeof i=="string"?e=n=>n[i]:e=i,Object.entries(t).reduce((n,[o,r])=>(n[o]=e(r,o),n),{})}function kw(t,i){return t.reduce((e,n,o)=>(e[n]=i[o],e),{})}var Yd="\0";var Ow=class{constructor(){ew(this,"_sentinel");let t={};t._next=t._prev=t,this._sentinel=t}dequeue(){let t=this._sentinel,i=t._prev;if(i!==t)return Qf(i),i}enqueue(t){let i=this._sentinel;t._prev&&t._next&&Qf(t),t._next=i._next,i._next._prev=t,i._next=t,t._prev=i}toString(){let t=[],i=this._sentinel,e=i._prev;for(;e!==i;)t.push(JSON.stringify(e,Fw)),e=e._prev;return"["+t.join(", ")+"]"}};function Qf(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function Fw(t,i){if(t!=="_next"&&t!=="_prev")return i}var Aw=Ow,Lw=()=>1;function zw(t,i){if(t.nodeCount()<=1)return[];let e=Gw(t,i||Lw);return Bw(e.graph,e.buckets,e.zeroIdx).flatMap(n=>t.outEdges(n.v,n.w)||[])}function Bw(t,i,e){var n;let o=[],r=i[i.length-1],s=i[0],a;for(;t.nodeCount();){for(;a=s.dequeue();)Hu(t,i,e,a);for(;a=r.dequeue();)Hu(t,i,e,a);if(t.nodeCount()){for(let c=i.length-2;c>0;--c)if(a=(n=i[c])==null?void 0:n.dequeue(),a){o=o.concat(Hu(t,i,e,a,!0)||[]);break}}}return o}function Hu(t,i,e,n,o){let r=[],s=o?r:void 0;return(t.inEdges(n.v)||[]).forEach(a=>{let c=t.edge(a),l=t.node(a.v);o&&r.push({v:a.v,w:a.w}),l.out-=c,Yu(i,e,l)}),(t.outEdges(n.v)||[]).forEach(a=>{let c=t.edge(a),l=a.w,u=t.node(l);u.in-=c,Yu(i,e,u)}),t.removeNode(n.v),s}function Gw(t,i){let e=new Ve,n=0,o=0;t.nodes().forEach(a=>{e.setNode(a,{v:a,in:0,out:0})}),t.edges().forEach(a=>{let c=e.edge(a.v,a.w)||0,l=i(a),u=c+l;e.setEdge(a.v,a.w,u);let h=e.node(a.v),v=e.node(a.w);o=Math.max(o,h.out+=l),n=Math.max(n,v.in+=l)});let r=jw(o+n+3).map(()=>new Aw),s=n+1;return e.nodes().forEach(a=>{Yu(r,s,e.node(a))}),{graph:e,buckets:r,zeroIdx:s}}function Yu(t,i,e){var n,o,r;e.out?e.in?(r=t[e.out-e.in+i])==null||r.enqueue(e):(o=t[t.length-1])==null||o.enqueue(e):(n=t[0])==null||n.enqueue(e)}function jw(t){let i=[];for(let e=0;e<t;e++)i.push(e);return i}function Hw(t){(t.graph().acyclicer==="greedy"?zw(t,i(t)):Vw(t)).forEach(e=>{let n=t.edge(e);t.removeEdge(e),n.forwardName=e.name,n.reversed=!0,t.setEdge(e.w,e.v,n,Ku("rev"))});function i(e){return n=>e.edge(n).weight}}function Vw(t){let i=[],e={},n={};function o(r){Object.hasOwn(n,r)||(n[r]=!0,e[r]=!0,t.outEdges(r).forEach(s=>{Object.hasOwn(e,s.w)?i.push(s):o(s.w)}),delete e[r])}return t.nodes().forEach(o),i}function Uw(t){t.edges().forEach(i=>{let e=t.edge(i);if(e.reversed){t.removeEdge(i);let n=e.forwardName;delete e.reversed,delete e.forwardName,t.setEdge(i.w,i.v,e,n)}})}function Ww(t){t.graph().dummyChains=[],t.edges().forEach(i=>$w(t,i))}function $w(t,i){let e=i.v,n=t.node(e).rank,o=i.w,r=t.node(o).rank,s=i.name,a=t.edge(i),c=a.labelRank;if(r===n+1)return;t.removeEdge(i);let l,u,h;for(h=0,++n;n<r;++h,++n)a.points=[],u={width:0,height:0,edgeLabel:a,edgeObj:i,rank:n},l=vn(t,"edge",u,"_d"),n===c&&(u.width=a.width,u.height=a.height,u.dummy="edge-label",u.labelpos=a.labelpos),t.setEdge(e,l,{weight:a.weight},s),h===0&&t.graph().dummyChains.push(l),e=l;t.setEdge(e,o,{weight:a.weight},s)}function Yw(t){t.graph().dummyChains.forEach(i=>{let e=t.node(i),n=e.edgeLabel,o;for(t.setEdge(e.edgeObj,n);e.dummy;)o=t.successors(i)[0],t.removeNode(i),n.points.push({x:e.x,y:e.y}),e.dummy==="edge-label"&&(n.x=e.x,n.y=e.y,n.width=e.width,n.height=e.height),i=o,e=t.node(i)})}function Zu(t){let i={};function e(n){let o=t.node(n);if(Object.hasOwn(i,n))return o.rank;i[n]=!0;let r=t.outEdges(n),s=r?r.map(c=>c==null?Number.POSITIVE_INFINITY:e(c.w)-t.edge(c).minlen):[],a=et(Math.min,s);return a===Number.POSITIVE_INFINITY&&(a=0),o.rank=a}t.sources().forEach(e)}function yn(t,i){return t.node(i.w).rank-t.node(i.v).rank-t.edge(i).minlen}var vg=qw;function qw(t){let i=new Ve({directed:!1}),e=t.nodes();if(e.length===0)throw new Error("Graph must have at least one node");let n=e[0],o=t.nodeCount();i.setNode(n,{});let r,s;for(;Xw(i,t)<o&&(r=Kw(i,t),!!r);)s=i.hasNode(r.v)?yn(t,r):-yn(t,r),Zw(i,t,s);return i}function Xw(t,i){function e(n){let o=i.nodeEdges(n);o&&o.forEach(r=>{let s=r.v,a=n===s?r.w:s;!t.hasNode(a)&&!yn(i,r)&&(t.setNode(a,{}),t.setEdge(n,a,{}),e(a))})}return t.nodes().forEach(e),t.nodeCount()}function Kw(t,i){return i.edges().reduce((e,n)=>{let o=Number.POSITIVE_INFINITY;return t.hasNode(n.v)!==t.hasNode(n.w)&&(o=yn(i,n)),o<e[0]?[o,n]:e},[Number.POSITIVE_INFINITY,null])[1]}function Zw(t,i,e){t.nodes().forEach(n=>i.node(n).rank+=e)}var{preorder:Qw,postorder:Jw}=Xu,eb=Ut;Ut.initLowLimValues=Ju;Ut.initCutValues=Qu;Ut.calcCutValue=Cg;Ut.leaveEdge=bg;Ut.enterEdge=xg;Ut.exchangeEdges=Ig;function Ut(t){t=Sw(t),Zu(t);let i=vg(t);Ju(i),Qu(i,t);let e,n;for(;e=bg(i);)n=xg(i,t,e),Ig(i,t,e,n)}function Qu(t,i){let e=Jw(t,t.nodes());e=e.slice(0,e.length-1),e.forEach(n=>tb(t,i,n))}function tb(t,i,e){let n=t.node(e).parent,o=t.edge(e,n);o.cutvalue=Cg(t,i,e)}function Cg(t,i,e){let n=t.node(e).parent,o=!0,r=i.edge(e,n),s=0;r||(o=!1,r=i.edge(n,e)),s=r.weight;let a=i.nodeEdges(e);return a&&a.forEach(c=>{let l=c.v===e,u=l?c.w:c.v;if(u!==n){let h=l===o,v=i.edge(c).weight;if(s+=h?v:-v,ib(t,e,u)){let w=t.edge(e,u).cutvalue;s+=h?-w:w}}}),s}function Ju(t,i){arguments.length<2&&(i=t.nodes()[0]),wg(t,{},1,i)}function wg(t,i,e,n,o){let r=e,s=t.node(n);i[n]=!0;let a=t.neighbors(n);return a&&a.forEach(c=>{Object.hasOwn(i,c)||(e=wg(t,i,e,c,n))}),s.low=r,s.lim=e++,o?s.parent=o:delete s.parent,e}function bg(t){return t.edges().find(i=>t.edge(i).cutvalue<0)}function xg(t,i,e){let n=e.v,o=e.w;i.hasEdge(n,o)||(n=e.w,o=e.v);let r=t.node(n),s=t.node(o),a=r,c=!1;return r.lim>s.lim&&(a=s,c=!0),i.edges().filter(l=>c===Jf(t,t.node(l.v),a)&&c!==Jf(t,t.node(l.w),a)).reduce((l,u)=>yn(i,u)<yn(i,l)?u:l)}function Ig(t,i,e,n){let o=e.v,r=e.w;t.removeEdge(o,r),t.setEdge(n.v,n.w,{}),Ju(t),Qu(t,i),nb(t,i)}function nb(t,i){let e=t.nodes().find(o=>!t.node(o).parent);if(!e)return;let n=Qw(t,[e]);n=n.slice(1),n.forEach(o=>{let r=t.node(o).parent,s=i.edge(o,r),a=!1;s||(s=i.edge(r,o),a=!0),i.node(o).rank=i.node(r).rank+(a?s.minlen:-s.minlen)})}function ib(t,i,e){return t.hasEdge(i,e)}function Jf(t,i,e){return e.low<=i.lim&&i.lim<=e.lim}var ob=rb;function rb(t){let i=t.graph().ranker;if(typeof i=="function")return i(t);switch(i){case"network-simplex":eg(t);break;case"tight-tree":ab(t);break;case"longest-path":sb(t);break;case"none":break;default:eg(t)}}var sb=Zu;function ab(t){Zu(t),vg(t)}function eg(t){eb(t)}var cb=db;function db(t){let i=ub(t);t.graph().dummyChains.forEach(e=>{let n=t.node(e),o=n.edgeObj,r=lb(t,i,o.v,o.w),s=r.path,a=r.lca,c=0,l=s[c],u=!0;for(;e!==o.w;){if(n=t.node(e),u){for(;(l=s[c])!==a&&t.node(l).maxRank<n.rank;)c++;l===a&&(u=!1)}if(!u){for(;c<s.length-1&&t.node(s[c+1]).minRank<=n.rank;)c++;l=s[c]}l!==void 0&&t.setParent(e,l),e=t.successors(e)[0]}})}function lb(t,i,e,n){let o=[],r=[],s=Math.min(i[e].low,i[n].low),a=Math.max(i[e].lim,i[n].lim),c;c=e;do c=t.parent(c),o.push(c);while(c&&(i[c].low>s||a>i[c].lim));let l=c,u=n;for(;(u=t.parent(u))!==l;)r.push(u);return{path:o.concat(r.reverse()),lca:l}}function ub(t){let i={},e=0;function n(o){let r=e;t.children(o).forEach(n),i[o]={low:r,lim:e++}}return t.children(Yd).forEach(n),i}function hb(t){let i=vn(t,"root",{},"_root"),e=fb(t),n=Object.values(e),o=et(Math.max,n)-1,r=2*o+1;t.graph().nestingRoot=i,t.edges().forEach(a=>t.edge(a).minlen*=r);let s=gb(t)+1;t.children(Yd).forEach(a=>Sg(t,i,r,s,o,e,a)),t.graph().nodeRankFactor=r}function Sg(t,i,e,n,o,r,s){var a;let c=t.children(s);if(!c.length){s!==i&&t.setEdge(i,s,{weight:0,minlen:e});return}let l=Zf(t,"_bt"),u=Zf(t,"_bb"),h=t.node(s);t.setParent(l,s),h.borderTop=l,t.setParent(u,s),h.borderBottom=u,c.forEach(v=>{var w;Sg(t,i,e,n,o,r,v);let S=t.node(v),P=S.borderTop?S.borderTop:v,L=S.borderBottom?S.borderBottom:v,M=S.borderTop?n:2*n,k=P!==L?1:o-((w=r[s])!=null?w:0)+1;t.setEdge(l,P,{weight:M,minlen:k,nestingEdge:!0}),t.setEdge(L,u,{weight:M,minlen:k,nestingEdge:!0})}),t.parent(s)||t.setEdge(i,l,{weight:0,minlen:o+((a=r[s])!=null?a:0)})}function fb(t){let i={};function e(n,o){let r=t.children(n);r&&r.length&&r.forEach(s=>e(s,o+1)),i[n]=o}return t.children(Yd).forEach(n=>e(n,1)),i}function gb(t){return t.edges().reduce((i,e)=>i+t.edge(e).weight,0)}function pb(t){let i=t.graph();t.removeNode(i.nestingRoot),delete i.nestingRoot,t.edges().forEach(e=>{t.edge(e).nestingEdge&&t.removeEdge(e)})}var _b=mb;function mb(t){function i(e){let n=t.children(e),o=t.node(e);if(n.length&&n.forEach(i),Object.hasOwn(o,"minRank")){o.borderLeft=[],o.borderRight=[];for(let r=o.minRank,s=o.maxRank+1;r<s;++r)tg(t,"borderLeft","_bl",e,o,r),tg(t,"borderRight","_br",e,o,r)}}t.children(Yd).forEach(i)}function tg(t,i,e,n,o,r){let s={width:0,height:0,rank:r,borderType:i},a=o[i][r-1],c=vn(t,"border",s,e);o[i][r]=c,t.setParent(c,n),a&&t.setEdge(a,c,{weight:1})}function yb(t){var i;let e=(i=t.graph().rankdir)==null?void 0:i.toLowerCase();(e==="lr"||e==="rl")&&Eg(t)}function vb(t){var i;let e=(i=t.graph().rankdir)==null?void 0:i.toLowerCase();(e==="bt"||e==="rl")&&Cb(t),(e==="lr"||e==="rl")&&(wb(t),Eg(t))}function Eg(t){t.nodes().forEach(i=>ng(t.node(i))),t.edges().forEach(i=>ng(t.edge(i)))}function ng(t){let i=t.width;t.width=t.height,t.height=i}function Cb(t){t.nodes().forEach(i=>Vu(t.node(i))),t.edges().forEach(i=>{var e;let n=t.edge(i);(e=n.points)==null||e.forEach(Vu),Object.hasOwn(n,"y")&&Vu(n)})}function Vu(t){t.y=-t.y}function wb(t){t.nodes().forEach(i=>Uu(t.node(i))),t.edges().forEach(i=>{var e;let n=t.edge(i);(e=n.points)==null||e.forEach(Uu),Object.hasOwn(n,"x")&&Uu(n)})}function Uu(t){let i=t.x;t.x=t.y,t.y=i}function bb(t){let i={},e=t.nodes().filter(a=>!t.children(a).length),n=e.map(a=>t.node(a).rank),o=et(Math.max,n),r=mi(o+1).map(()=>[]);function s(a){if(i[a])return;i[a]=!0;let c=t.node(a);r[c.rank].push(a);let l=t.successors(a);l&&l.forEach(s)}return e.sort((a,c)=>t.node(a).rank-t.node(c).rank).forEach(s),r}function xb(t,i){let e=0;for(let n=1;n<i.length;++n)e+=Ib(t,i[n-1],i[n]);return e}function Ib(t,i,e){let n=kw(e,e.map((l,u)=>u)),o=i.flatMap(l=>{let u=t.outEdges(l);return u?u.map(h=>({pos:n[h.w],weight:t.edge(h).weight})).sort((h,v)=>h.pos-v.pos):[]}),r=1;for(;r<e.length;)r<<=1;let s=2*r-1;r-=1;let a=new Array(s).fill(0),c=0;return o.forEach(l=>{let u=l.pos+r;a[u]+=l.weight;let h=0;for(;u>0;)u%2&&(h+=a[u+1]),u=u-1>>1,a[u]+=l.weight;c+=l.weight*h}),c}function Sb(t,i=[]){return i.map(e=>{let n=t.inEdges(e);if(!n||!n.length)return{v:e};{let o=n.reduce((r,s)=>{let a=t.edge(s),c=t.node(s.v);return{sum:r.sum+a.weight*c.order,weight:r.weight+a.weight}},{sum:0,weight:0});return{v:e,barycenter:o.sum/o.weight,weight:o.weight}}})}function Eb(t,i){let e={};t.forEach((o,r)=>{let s={indegree:0,in:[],out:[],vs:[o.v],i:r};o.barycenter!==void 0&&(s.barycenter=o.barycenter,s.weight=o.weight),e[o.v]=s}),i.edges().forEach(o=>{let r=e[o.v],s=e[o.w];r!==void 0&&s!==void 0&&(s.indegree++,r.out.push(s))});let n=Object.values(e).filter(o=>!o.indegree);return Db(n)}function Db(t){let i=[];function e(o){return r=>{r.merged||(r.barycenter===void 0||o.barycenter===void 0||r.barycenter>=o.barycenter)&&Tb(o,r)}}function n(o){return r=>{r.in.push(o),--r.indegree===0&&t.push(r)}}for(;t.length;){let o=t.pop();i.push(o),o.in.reverse().forEach(e(o)),o.out.forEach(n(o))}return i.filter(o=>!o.merged).map(o=>Ud(o,["vs","i","barycenter","weight"]))}function Tb(t,i){let e=0,n=0;t.weight&&(e+=t.barycenter*t.weight,n+=t.weight),i.weight&&(e+=i.barycenter*i.weight,n+=i.weight),t.vs=i.vs.concat(t.vs),t.barycenter=e/n,t.weight=n,t.i=Math.min(i.i,t.i),i.merged=!0}function Pb(t,i){let e=Pw(t,u=>Object.hasOwn(u,"barycenter")),n=e.lhs,o=e.rhs.sort((u,h)=>h.i-u.i),r=[],s=0,a=0,c=0;n.sort(Mb(!!i)),c=ig(r,o,c),n.forEach(u=>{c+=u.vs.length,r.push(u.vs),s+=u.barycenter*u.weight,a+=u.weight,c=ig(r,o,c)});let l={vs:r.flat(1)};return a&&(l.barycenter=s/a,l.weight=a),l}function ig(t,i,e){let n;for(;i.length&&(n=i[i.length-1]).i<=e;)i.pop(),t.push(n.vs),e++;return e}function Mb(t){return(i,e)=>i.barycenter<e.barycenter?-1:i.barycenter>e.barycenter?1:t?e.i-i.i:i.i-e.i}function Dg(t,i,e,n){let o=t.children(i),r=t.node(i),s=r?r.borderLeft:void 0,a=r?r.borderRight:void 0,c={};s&&(o=o.filter(v=>v!==s&&v!==a));let l=Sb(t,o);l.forEach(v=>{if(t.children(v.v).length){let w=Dg(t,v.v,e,n);c[v.v]=w,Object.hasOwn(w,"barycenter")&&Nb(v,w)}});let u=Eb(l,e);Rb(u,c);let h=Pb(u,n);if(s&&a){h.vs=[s,h.vs,a].flat(1);let v=t.predecessors(s);if(v&&v.length){let w=t.node(v[0]),S=t.predecessors(a),P=t.node(S[0]);Object.hasOwn(h,"barycenter")||(h.barycenter=0,h.weight=0),h.barycenter=(h.barycenter*h.weight+w.order+P.order)/(h.weight+2),h.weight+=2}}return h}function Rb(t,i){t.forEach(e=>{e.vs=e.vs.flatMap(n=>i[n]?i[n].vs:n)})}function Nb(t,i){t.barycenter!==void 0?(t.barycenter=(t.barycenter*t.weight+i.barycenter*i.weight)/(t.weight+i.weight),t.weight+=i.weight):(t.barycenter=i.barycenter,t.weight=i.weight)}function kb(t,i,e,n){n||(n=t.nodes());let o=Ob(t),r=new Ve({compound:!0}).setGraph({root:o}).setDefaultNodeLabel(s=>t.node(s));return n.forEach(s=>{let a=t.node(s),c=t.parent(s);if(a.rank===i||a.minRank<=i&&i<=a.maxRank){r.setNode(s),r.setParent(s,c||o);let l=t[e](s);l&&l.forEach(u=>{let h=u.v===s?u.w:u.v,v=r.edge(h,s),w=v!==void 0?v.weight:0;r.setEdge(h,s,{weight:t.edge(u).weight+w})}),Object.hasOwn(a,"minRank")&&r.setNode(s,{borderLeft:a.borderLeft[i],borderRight:a.borderRight[i]})}}),r}function Ob(t){let i;for(;t.hasNode(i=Ku("_root")););return i}function Fb(t,i,e){let n={},o;e.forEach(r=>{let s=t.parent(r),a,c;for(;s;){if(a=t.parent(s),a?(c=n[a],n[a]=s):(c=o,o=s),c&&c!==s){i.setEdge(c,s);return}s=a}})}function Tg(t,i={}){if(typeof i.customOrder=="function"){i.customOrder(t,Tg);return}let e=yg(t),n=og(t,mi(1,e+1),"inEdges"),o=og(t,mi(e-1,-1,-1),"outEdges"),r=bb(t);if(rg(t,r),i.disableOptimalOrderHeuristic)return;let s=Number.POSITIVE_INFINITY,a,c=i.constraints||[];for(let l=0,u=0;u<4;++l,++u){Ab(l%2?n:o,l%4>=2,c),r=Wd(t);let h=xb(t,r);h<s?(u=0,a=Object.assign({},r),s=h):h===s&&(a=structuredClone(r))}rg(t,a)}function og(t,i,e){let n=new Map,o=(r,s)=>{n.has(r)||n.set(r,[]),n.get(r).push(s)};for(let r of t.nodes()){let s=t.node(r);if(typeof s.rank=="number"&&o(s.rank,r),typeof s.minRank=="number"&&typeof s.maxRank=="number")for(let a=s.minRank;a<=s.maxRank;a++)a!==s.rank&&o(a,r)}return i.map(function(r){return kb(t,r,e,n.get(r)||[])})}function Ab(t,i,e){let n=new Ve;t.forEach(function(o){e.forEach(a=>n.setEdge(a.left,a.right));let r=o.graph().root,s=Dg(o,r,n,i);s.vs.forEach((a,c)=>o.node(a).order=c),Fb(o,n,s.vs)})}function rg(t,i){Object.values(i).forEach(e=>e.forEach((n,o)=>t.node(n).order=o))}function Lb(t,i){let e={};function n(o,r){let s=0,a=0,c=o.length,l=r[r.length-1];return r.forEach((u,h)=>{let v=Bb(t,u),w=v?t.node(v).order:c;(v||u===l)&&(r.slice(a,h+1).forEach(S=>{let P=t.predecessors(S);P&&P.forEach(L=>{let M=t.node(L),k=M.order;(k<s||w<k)&&!(M.dummy&&t.node(S).dummy)&&Pg(e,L,S)})}),a=h+1,s=w)}),r}return i.length&&i.reduce(n),e}function zb(t,i){let e={};function n(r,s,a,c,l){mi(s,a).forEach(u=>{let h=r[u];if(h!==void 0&&t.node(h).dummy){let v=t.predecessors(h);v&&v.forEach(w=>{if(w===void 0)return;let S=t.node(w);S.dummy&&(S.order<c||S.order>l)&&Pg(e,w,h)})}})}function o(r,s){let a=-1,c=-1,l=0;return s.forEach((u,h)=>{if(t.node(u).dummy==="border"){let v=t.predecessors(u);if(v&&v.length){let w=v[0];if(w===void 0)return;c=t.node(w).order,n(s,l,h,a,c),l=h,a=c}}n(s,l,s.length,c,r.length)}),s}return i.length&&i.reduce(o),e}function Bb(t,i){if(t.node(i).dummy){let e=t.predecessors(i);if(e)return e.find(n=>t.node(n).dummy)}}function Pg(t,i,e){if(i>e){let o=i;i=e,e=o}let n=t[i];n||(t[i]=n={}),n[e]=!0}function Gb(t,i,e){if(i>e){let o=i;i=e,e=o}let n=t[i];return n!==void 0&&Object.hasOwn(n,e)}function jb(t,i,e,n){let o={},r={},s={};return i.forEach(a=>{a.forEach((c,l)=>{o[c]=c,r[c]=c,s[c]=l})}),i.forEach(a=>{let c=-1;a.forEach(l=>{let u=n(l);if(u&&u.length){let h=u.sort((w,S)=>{let P=s[w],L=s[S];return(P!==void 0?P:0)-(L!==void 0?L:0)}),v=(h.length-1)/2;for(let w=Math.floor(v),S=Math.ceil(v);w<=S;++w){let P=h[w];if(P===void 0)continue;let L=s[P];if(L!==void 0&&r[l]===l&&c<L&&!Gb(e,l,P)){let M=o[P];M!==void 0&&(r[P]=l,r[l]=o[l]=M,c=L)}}}})}),{root:o,align:r}}function Hb(t,i,e,n,o=!1){let r={},s=Vb(t,i,e,o),a=o?"borderLeft":"borderRight";function c(w,S){let P=s.nodes().slice(),L={},M=P.pop();for(;M;){if(L[M])w(M);else{L[M]=!0,P.push(M);for(let k of S(M))P.push(k)}M=P.pop()}}function l(w){let S=s.inEdges(w);S?r[w]=S.reduce((P,L)=>{var M;let k=(M=r[L.v])!=null?M:0,H=s.edge(L);return Math.max(P,k+(H!==void 0?H:0))},0):r[w]=0}function u(w){let S=s.outEdges(w),P=Number.POSITIVE_INFINITY;S&&(P=S.reduce((M,k)=>{let H=r[k.w],xe=s.edge(k);return Math.min(M,(H!==void 0?H:0)-(xe!==void 0?xe:0))},Number.POSITIVE_INFINITY));let L=t.node(w);P!==Number.POSITIVE_INFINITY&&L.borderType!==a&&(r[w]=Math.max(r[w]!==void 0?r[w]:0,P))}function h(w){return s.predecessors(w)||[]}function v(w){return s.successors(w)||[]}return c(l,h),c(u,v),Object.keys(n).forEach(w=>{var S;let P=e[w];P!==void 0&&(r[w]=(S=r[P])!=null?S:0)}),r}function Vb(t,i,e,n){let o=new Ve,r=t.graph(),s=qb(r.nodesep,r.edgesep,n);return i.forEach(a=>{let c;a.forEach(l=>{let u=e[l];if(u!==void 0){if(o.setNode(u),c!==void 0){let h=e[c];if(h!==void 0){let v=o.edge(h,u);o.setEdge(h,u,Math.max(s(t,l,c),v||0))}}c=l}})}),o}function Ub(t,i){return Object.values(i).reduce((e,n)=>{let o=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY;Object.entries(n).forEach(([a,c])=>{let l=Xb(t,a)/2;o=Math.max(c+l,o),r=Math.min(c-l,r)});let s=o-r;return s<e[0]&&(e=[s,n]),e},[Number.POSITIVE_INFINITY,null])[1]}function Wb(t,i){let e=Object.values(i),n=et(Math.min,e),o=et(Math.max,e);["u","d"].forEach(r=>{["l","r"].forEach(s=>{let a=r+s,c=t[a];if(!c||c===i)return;let l=Object.values(c),u=n-et(Math.min,l);s!=="l"&&(u=o-et(Math.max,l)),u&&(t[a]=$d(c,h=>h+u))})})}function $b(t,i=void 0){let e=t.ul;return e?$d(e,(n,o)=>{var r,s;if(i){let c=i.toLowerCase(),l=t[c];if(l&&l[o]!==void 0)return l[o]}let a=Object.values(t).map(c=>{let l=c[o];return l!==void 0?l:0}).sort((c,l)=>c-l);return(((r=a[1])!=null?r:0)+((s=a[2])!=null?s:0))/2}):{}}function Yb(t){let i=Wd(t),e=Object.assign(Lb(t,i),zb(t,i)),n={},o;["u","d"].forEach(s=>{o=s==="u"?i:Object.values(i).reverse(),["l","r"].forEach(a=>{a==="r"&&(o=o.map(u=>Object.values(u).reverse()));let c=jb(t,o,e,u=>(s==="u"?t.predecessors(u):t.successors(u))||[]),l=Hb(t,o,c.root,c.align,a==="r");a==="r"&&(l=$d(l,u=>-u)),n[s+a]=l})});let r=Ub(t,n);return Wb(n,r),$b(n,t.graph().align)}function qb(t,i,e){return(n,o,r)=>{let s=n.node(o),a=n.node(r),c=0,l;if(c+=s.width/2,Object.hasOwn(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":l=-s.width/2;break;case"r":l=s.width/2;break}if(l&&(c+=e?l:-l),l=void 0,c+=(s.dummy?i:t)/2,c+=(a.dummy?i:t)/2,c+=a.width/2,Object.hasOwn(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":l=a.width/2;break;case"r":l=-a.width/2;break}return l&&(c+=e?l:-l),c}}function Xb(t,i){return t.node(i).width}function Kb(t){t=_g(t),Zb(t),Object.entries(Yb(t)).forEach(([i,e])=>t.node(i).x=e)}function Zb(t){let i=Wd(t),e=t.graph(),n=e.ranksep,o=e.rankalign,r=0;i.forEach(s=>{let a=s.reduce((c,l)=>{var u;let h=(u=t.node(l).height)!=null?u:0;return c>h?c:h},0);s.forEach(c=>{let l=t.node(c);o==="top"?l.y=r+l.height/2:o==="bottom"?l.y=r+a-l.height/2:l.y=r+a/2}),r+=a+n})}function Mg(t,i={}){let e=i.debugTiming?Mw:Rw;return e("layout",()=>{let n=e(" buildLayoutGraph",()=>ax(t));return e(" runLayout",()=>Qb(n,e,i)),e(" updateInputGraph",()=>Jb(t,n)),n})}function Qb(t,i,e){i(" makeSpaceForEdgeLabels",()=>cx(t)),i(" removeSelfEdges",()=>mx(t)),i(" acyclic",()=>Hw(t)),i(" nestingGraph.run",()=>hb(t)),i(" rank",()=>ob(_g(t))),i(" injectEdgeLabelProxies",()=>dx(t)),i(" removeEmptyRanks",()=>Dw(t)),i(" nestingGraph.cleanup",()=>pb(t)),i(" normalizeRanks",()=>Ew(t)),i(" assignRankMinMax",()=>lx(t)),i(" removeEdgeLabelProxies",()=>ux(t)),i(" normalize.run",()=>Ww(t)),i(" parentDummyChains",()=>cb(t)),i(" addBorderSegments",()=>_b(t)),i(" order",()=>Tg(t,e)),i(" insertSelfEdges",()=>yx(t)),i(" adjustCoordinateSystem",()=>yb(t)),i(" position",()=>Kb(t)),i(" positionSelfEdges",()=>vx(t)),i(" removeBorderNodes",()=>_x(t)),i(" normalize.undo",()=>Yw(t)),i(" fixupEdgeLabelCoords",()=>gx(t)),i(" undoCoordinateSystem",()=>vb(t)),i(" translateGraph",()=>hx(t)),i(" assignNodeIntersects",()=>fx(t)),i(" reversePoints",()=>px(t)),i(" acyclic.undo",()=>Uw(t))}function Jb(t,i){t.nodes().forEach(e=>{let n=t.node(e),o=i.node(e);n&&(n.x=o.x,n.y=o.y,n.order=o.order,n.rank=o.rank,i.children(e).length&&(n.width=o.width,n.height=o.height))}),t.edges().forEach(e=>{let n=t.edge(e),o=i.edge(e);n.points=o.points,Object.hasOwn(o,"x")&&(n.x=o.x,n.y=o.y)}),t.graph().width=i.graph().width,t.graph().height=i.graph().height}var ex=["nodesep","edgesep","ranksep","marginx","marginy"],tx={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},nx=["acyclicer","ranker","rankdir","align","rankalign"],ix=["width","height","rank"],sg={width:0,height:0},ox=["minlen","weight","width","height","labeloffset"],rx={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},sx=["labelpos"];function ax(t){let i=new Ve({multigraph:!0,compound:!0}),e=$u(t.graph());return i.setGraph(Object.assign({},tx,Wu(e,ex),Ud(e,nx))),t.nodes().forEach(n=>{let o=$u(t.node(n)),r=Wu(o,ix);Object.keys(sg).forEach(a=>{r[a]===void 0&&(r[a]=sg[a])}),i.setNode(n,r);let s=t.parent(n);s!==void 0&&i.setParent(n,s)}),t.edges().forEach(n=>{let o=$u(t.edge(n));i.setEdge(n,Object.assign({},rx,Wu(o,ox),Ud(o,sx)))}),i}function cx(t){let i=t.graph();i.ranksep/=2,t.edges().forEach(e=>{let n=t.edge(e);n.minlen*=2,n.labelpos.toLowerCase()!=="c"&&(i.rankdir==="TB"||i.rankdir==="BT"?n.width+=n.labeloffset:n.height+=n.labeloffset)})}function dx(t){t.edges().forEach(i=>{let e=t.edge(i);if(e.width&&e.height){let n=t.node(i.v),o={rank:(t.node(i.w).rank-n.rank)/2+n.rank,e:i};vn(t,"edge-proxy",o,"_ep")}})}function lx(t){let i=0;t.nodes().forEach(e=>{let n=t.node(e);n.borderTop&&(n.minRank=t.node(n.borderTop).rank,n.maxRank=t.node(n.borderBottom).rank,i=Math.max(i,n.maxRank))}),t.graph().maxRank=i}function ux(t){t.nodes().forEach(i=>{let e=t.node(i);if(e.dummy==="edge-proxy"){let n=e;t.edge(n.e).labelRank=e.rank,t.removeNode(i)}})}function hx(t){let i=Number.POSITIVE_INFINITY,e=0,n=Number.POSITIVE_INFINITY,o=0,r=t.graph(),s=r.marginx||0,a=r.marginy||0;function c(l){let u=l.x,h=l.y,v=l.width,w=l.height;i=Math.min(i,u-v/2),e=Math.max(e,u+v/2),n=Math.min(n,h-w/2),o=Math.max(o,h+w/2)}t.nodes().forEach(l=>c(t.node(l))),t.edges().forEach(l=>{let u=t.edge(l);Object.hasOwn(u,"x")&&c(u)}),i-=s,n-=a,t.nodes().forEach(l=>{let u=t.node(l);u.x-=i,u.y-=n}),t.edges().forEach(l=>{let u=t.edge(l);u.points.forEach(h=>{h.x-=i,h.y-=n}),Object.hasOwn(u,"x")&&(u.x-=i),Object.hasOwn(u,"y")&&(u.y-=n)}),r.width=e-i+s,r.height=o-n+a}function fx(t){t.edges().forEach(i=>{let e=t.edge(i),n=t.node(i.v),o=t.node(i.w),r,s;e.points?(r=e.points[0],s=e.points[e.points.length-1]):(e.points=[],r=o,s=n),e.points.unshift(Kf(n,r)),e.points.push(Kf(o,s))})}function gx(t){t.edges().forEach(i=>{let e=t.edge(i);if(Object.hasOwn(e,"x"))switch((e.labelpos==="l"||e.labelpos==="r")&&(e.width-=e.labeloffset),e.labelpos){case"l":e.x-=e.width/2+e.labeloffset;break;case"r":e.x+=e.width/2+e.labeloffset;break}})}function px(t){t.edges().forEach(i=>{let e=t.edge(i);e.reversed&&e.points.reverse()})}function _x(t){t.nodes().forEach(i=>{if(t.children(i).length){let e=t.node(i),n=t.node(e.borderTop),o=t.node(e.borderBottom),r=t.node(e.borderLeft[e.borderLeft.length-1]),s=t.node(e.borderRight[e.borderRight.length-1]);e.width=Math.abs(s.x-r.x),e.height=Math.abs(o.y-n.y),e.x=r.x+e.width/2,e.y=n.y+e.height/2}}),t.nodes().forEach(i=>{t.node(i).dummy==="border"&&t.removeNode(i)})}function mx(t){t.edges().forEach(i=>{if(i.v===i.w){let e=t.node(i.v);e.selfEdges||(e.selfEdges=[]),e.selfEdges.push({e:i,label:t.edge(i)}),t.removeEdge(i)}})}function yx(t){Wd(t).forEach(i=>{let e=0;i.forEach((n,o)=>{let r=t.node(n);r.order=o+e,(r.selfEdges||[]).forEach(s=>{vn(t,"selfedge",{width:s.label.width,height:s.label.height,rank:r.rank,order:o+ ++e,e:s.e,label:s.label},"_se")}),delete r.selfEdges})})}function vx(t){t.nodes().forEach(i=>{let e=t.node(i);if(e.dummy==="selfedge"){let n=e,o=t.node(n.e.v),r=o.x+o.width/2,s=o.y,a=e.x-r,c=o.height/2;t.setEdge(n.e,n.label),t.removeNode(i),n.label.points=[{x:r+2*a/3,y:s-c},{x:r+5*a/6,y:s-c},{x:r+a,y:s},{x:r+5*a/6,y:s+c},{x:r+2*a/3,y:s+c}],n.label.x=e.x,n.label.y=e.y}})}function Wu(t,i){return $d(Ud(t,i),Number)}function $u(t){let i={};return t&&Object.entries(t).forEach(([e,n])=>{typeof e=="string"&&(e=e.toLowerCase()),i[e]=n}),i}var eh={title:"Graph",subtitlePrefix:"Auto-laid-out (Dagre, top-bottom) \xB7 connections show how each node refers to another: ",subtitleSuffix:". Click to highlight neighbors, double-click to inspect.",loading:"Loading collection",errorTitle:"Failed to load",emptyTitle:"No nodes match",emptyDesc:"Adjust or reset the filters above.",legend:{invokes:"invokes",references:"references",mentions:"mentions",supersedes:"supersedes"},legendTooltip:{invokes:"Execution-level call (e.g. /command in body)",references:"Explicit reference (e.g. @handle or [[wikilink]])",mentions:"Plain-text mention of another node by name",supersedes:"Lifecycle replacement (declared in metadata.supersedes)"},a11y:{toolbar:"Graph controls",edgeLegend:"Edge legend"},toolbar:{zoomIn:"Zoom in",zoomOut:"Zoom out",fitToScreen:"Fit to screen",resetLayoutLabel:"Reset layout",resetLayoutTooltip:"Reset layout (re-run auto layout, clear saved positions)"},resetLayoutConfirm:"Reset all node positions to the automatic layout? This cannot be undone."};var th={graph:{perf:{cache:!0,virtualization:!1},perfHud:!0}};var Rg={a11y:{toolbarLabel:"Toggle node kinds"}};var bx=(t,i)=>i.kind;function xx(t,i){if(t&1){let e=St();m(0,"p-togglebutton",2),ye("ngModelChange",function(){let o=oe(e).$implicit,r=I();return re(r.toggle(o.kind))}),y()}if(t&2){let e=i.$implicit,n=I();N("ngModel",n.isActive(e.kind))("onIcon",e.icon)("offIcon",e.icon)("onLabel",e.count.toString())("offLabel",e.count.toString())("pTooltip",e.label)("styleClass","kind-palette__btn kind-palette__btn--"+e.kind),K("data-testid","kind-palette-"+e.kind)}}var qd=class t{loader=d(Oi);filters=d(Ai);kindRegistry=d(Fi);texts=Rg;entries=z(()=>{let i=new Map;for(let e of this.loader.nodes())i.set(e.kind,(i.get(e.kind)??0)+1);return this.kindRegistry.kinds().map(e=>({kind:e.name,icon:e.icon?.kind==="pi"?`pi ${e.icon.id}`:"pi pi-tag",label:e.label,count:i.get(e.name)??0}))});isActive(i){return this.filters.isKindActive(i)}toggle(i){this.filters.toggleKind(i)}static \u0275fac=function(e){return new(e||t)};static \u0275cmp=ee({type:t,selectors:[["app-kind-palette"]],decls:3,vars:1,consts:[["role","toolbar","data-testid","kind-palette",1,"kind-palette"],[3,"ngModel","onIcon","offIcon","onLabel","offLabel","pTooltip","styleClass"],[3,"ngModelChange","ngModel","onIcon","offIcon","onLabel","offLabel","pTooltip","styleClass"]],template:function(e,n){e&1&&(m(0,"div",0),he(1,xx,1,8,"p-togglebutton",1,bx),y()),e&2&&(K("aria-label",n.texts.a11y.toolbarLabel),g(),fe(n.entries()))},dependencies:[Ri,Pi,Mi,ki,Ni,Xt,qt],styles:["[_nghost-%COMP%]{position:absolute;top:16px;left:16px;z-index:2;pointer-events:none}.kind-palette[_ngcontent-%COMP%]{pointer-events:auto;display:flex;flex-direction:column;gap:2px;padding:4px;background:var(--sm-bg-content);border:1px solid var(--sm-border);border-radius:.65rem;box-shadow:var(--sm-shadow-floating)}.kind-palette__btn[_ngcontent-%COMP%]{--p-togglebutton-padding: 0;--p-togglebutton-content-padding: 0 .55rem;--p-togglebutton-border-radius: 999px;--p-togglebutton-content-border-radius: 999px;--p-togglebutton-gap: .4rem;--p-togglebutton-background: transparent;--p-togglebutton-checked-background: transparent;--p-togglebutton-hover-background: transparent;--p-togglebutton-border-color: transparent;--p-togglebutton-checked-border-color: transparent;--p-togglebutton-content-checked-background: var(--sm-bg-hover);--p-togglebutton-color: var(--p-text-muted-color);--p-togglebutton-hover-color: var(--p-text-color);--p-togglebutton-checked-color: var(--p-text-color);--p-togglebutton-icon-color: var(--p-text-muted-color);--p-togglebutton-icon-hover-color: var(--p-text-color);--p-togglebutton-icon-checked-color: var(--p-text-color);width:56px;height:30px;font-size:.72rem;font-weight:600;font-variant-numeric:tabular-nums}[_nghost-%COMP%] .kind-palette__btn .p-togglebutton-content{width:100%;height:100%;justify-content:flex-start}[_nghost-%COMP%] .kind-palette__btn .p-togglebutton-label{flex:1;text-align:right}[_nghost-%COMP%] .kind-palette__btn .p-togglebutton-icon{font-size:.95rem}.kind-palette__btn--skill[_ngcontent-%COMP%]{--p-togglebutton-icon-checked-color: var(--sm-kind-skill)}.kind-palette__btn--agent[_ngcontent-%COMP%]{--p-togglebutton-icon-checked-color: var(--sm-kind-agent)}.kind-palette__btn--command[_ngcontent-%COMP%]{--p-togglebutton-icon-checked-color: var(--sm-kind-command)}.kind-palette__btn--hook[_ngcontent-%COMP%]{--p-togglebutton-icon-checked-color: var(--sm-kind-hook)}.kind-palette__btn--note[_ngcontent-%COMP%]{--p-togglebutton-icon-checked-color: var(--sm-kind-note)}"],changeDetection:0})};var kg={llm:{what:{label:"what",tooltip:"What it does (LLM-inferred summary)"},when:{label:"when",tooltip:"When to use (LLM-inferred)"},style:{label:"style",tooltip:"Interaction style (LLM-inferred)"},does:{label:"does",tooltip:"Capabilities (LLM-inferred)"},steps:{label:"steps",tooltip:"Recipe / ordered steps (LLM-inferred)"},pre:{label:"pre",tooltip:"Preconditions (LLM-inferred)"},out:{label:"out",tooltip:"Outputs / produced artifacts (LLM-inferred)"},fx:{label:"fx",tooltip:"Side effects (LLM-inferred)"},eg:{label:"eg",tooltip:"Invocation example (LLM-inferred)"},trigger:{label:"trigger",tooltip:"Inferred trigger (LLM-inferred from body)"},topics:{label:"topics",tooltip:"Topics covered (LLM-inferred)"},facts:{label:"facts",tooltip:"Key facts (LLM-inferred discrete claims)"}},meta:{model:"model",inputs:"inputs",outputs:"outputs",args:"args",shortcut:"shortcut",event:"event",cond:"cond",flags:"flags",blocking:{label:"blocking",tooltip:"blocking: host waits for hook to finish before proceeding"},idempotent:{label:"idempotent",tooltip:"idempotent: safe to run multiple times with the same input"},allowed:"allowed",tools:"tools",tags:"tags"},stats:{errors:t=>`${t} error${t===1?"":"s"}`,warns:t=>`${t} warning${t===1?"":"s"}`,tools:t=>`${t} tool${t===1?"":"s"}`,toolsBreakdown:(t,i)=>`${t} allowlist + ${i} pre-approved`,linksIn:t=>`${t} incoming link${t===1?"":"s"}`,linksOut:t=>`${t} outgoing link${t===1?"":"s"}`,extRefs:t=>`${t} external URL${t===1?"":"s"} in body`,bytes:t=>`${t.toLocaleString("en-US")} bytes`,tokens:t=>`${t.toLocaleString("en-US")} tokens`,daysAgo:(t,i)=>`updated ${t} (${i} day${i===1?"":"s"} ago)`},stability:{experimental:"experimental",deprecated:"deprecated"},safety:{injection:t=>`injection${t?`: ${t}`:""}`},confidence:t=>`LLM summary \xB7 confidence ${t.toFixed(2)}`,ariaExpand:"Expand"};function Ix(t,i){if(t&1&&Yt(0,"i",4),t&2){let e=I();Xe(e.piClass()),lt("font-size",e.size(),"px")}}function Sx(t,i){if(t&1&&(ke(),Ye(0,"svg",1),Yt(1,"path"),qe()),t&2){let e=I();K("width",e.size())("height",e.size()),g(),K("d",e.svgPath())}}function Ex(t,i){if(t&1&&(Ye(0,"span",4),x(1),qe()),t&2){let e=I();lt("font-size",e.size(),"px")("line-height",e.size(),"px"),g(),T(e.emoji())}}function Dx(t,i){if(t&1&&(Ye(0,"span",5),x(1),qe()),t&2){let e=I();lt("font-size",e.size(),"px")("line-height",e.size(),"px"),g(),T(e.letter())}}var Kd=class t{kindRegistry=d(Fi);kind=R.required();size=R(18);variant=z(()=>{let i=this.kindRegistry.lookup(this.kind());return i?.icon?.kind==="pi"?"pi":i?.icon?.kind==="svg"?"svg":i?.emoji?"emoji":"letter"});piClass=z(()=>{let i=this.kindRegistry.lookup(this.kind())?.icon;return i?.kind==="pi"?`pi ${i.id}`:""});svgPath=z(()=>{let i=this.kindRegistry.lookup(this.kind())?.icon;return i?.kind==="svg"?i.path:""});emoji=z(()=>this.kindRegistry.lookup(this.kind())?.emoji??"");letter=z(()=>this.kindRegistry.labelOf(this.kind()).charAt(0).toUpperCase());static \u0275fac=function(e){return new(e||t)};static \u0275cmp=ee({type:t,selectors:[["sm-kind-icon"]],inputs:{kind:[1,"kind"],size:[1,"size"]},decls:4,vars:1,consts:[["aria-hidden","true",3,"class","font-size"],["viewBox","0 0 24 24","fill","none","stroke","currentColor","stroke-width","2.2","stroke-linecap","round","stroke-linejoin","round","aria-hidden","true"],["aria-hidden","true",3,"font-size","line-height"],["aria-hidden","true",1,"kind-icon__letter",3,"font-size","line-height"],["aria-hidden","true"],["aria-hidden","true",1,"kind-icon__letter"]],template:function(e,n){if(e&1&&O(0,Ix,1,4,"i",0)(1,Sx,2,3,":svg:svg",1)(2,Ex,2,5,"span",2)(3,Dx,2,5,"span",3),e&2){let o;F((o=n.variant())==="pi"?0:o==="svg"?1:o==="emoji"?2:o==="letter"?3:-1)}},styles:["[_nghost-%COMP%]{display:inline-flex;align-items:center;justify-content:center;line-height:1}"],changeDetection:0})};var Tx=(t,i)=>i.step,nh=(t,i)=>i.name,Px=(t,i)=>i.ruleId+i.message;function Mx(t,i){if(t&1&&(m(0,"span",25),x(1),y()),t&2){let e=I(),n=ut(0),o=ut(2);Xe("sm-gnode__llm-marker--"+o),N("pTooltip",e.texts.confidence(n.confidence)),g(),ot("",e.confidencePct(),"%")}}function Rx(t,i){if(t&1&&(m(0,"span",11)(1,"span",26),x(2,"T"),y(),x(3),y()),t&2){let e=I(),n=ut(1);N("pTooltip",e.texts.stats.tokens(n.tokensTotal)),g(3),T(e.tokensShort())}}function Nx(t,i){if(t&1&&(m(0,"span",12)(1,"span",26),x(2,"B"),y(),x(3),y()),t&2){let e=I(),n=ut(1);N("pTooltip",e.texts.stats.bytes(n.bytesTotal)),g(3),T(e.bytesShort())}}function kx(t,i){if(t&1&&(m(0,"span",13),j(1,"i",27),x(2),y()),t&2){let e=i,n=I();N("pTooltip",n.texts.stats.daysAgo(e.iso,e.days)),g(2),T(e.short)}}function Ox(t,i){t&1&&(m(0,"span",14),x(1),y()),t&2&&(g(),T(i))}function Fx(t,i){if(t&1&&(m(0,"span",31),x(1),y()),t&2){let e=i.$implicit;g(),T(e)}}function Ax(t,i){if(t&1&&(m(0,"div",28)(1,"span",29),x(2),y(),m(3,"div",30),he(4,Fx,2,1,"span",31,nt),y()()),t&2){let e=I(),n=I(2);g(),N("pTooltip",n.texts.llm.topics.tooltip),g(),T(n.texts.llm.topics.label),g(2),fe(e.topics)}}function Lx(t,i){if(t&1&&(m(0,"span",31),x(1),y()),t&2){let e=i.$implicit;g(),T(e)}}function zx(t,i){if(t&1&&(m(0,"div",28)(1,"span",29),x(2),y(),m(3,"div",30),he(4,Lx,2,1,"span",31,nt),y()()),t&2){let e=I(),n=I(2);g(),N("pTooltip",n.texts.llm.facts.tooltip),g(),T(n.texts.llm.facts.label),g(2),fe(e.keyFacts)}}function Bx(t,i){if(t&1&&(m(0,"div",28)(1,"span",29),x(2),y(),m(3,"span"),x(4),y()(),O(5,Ax,6,2,"div",28),O(6,zx,6,2,"div",28)),t&2){let e=i,n=I(2);g(),N("pTooltip",n.texts.llm.what.tooltip),g(),T(n.texts.llm.what.label),g(2),T(e.whatItCovers),g(),F(e.topics!=null&&e.topics.length?5:-1),g(),F(e.keyFacts!=null&&e.keyFacts.length?6:-1)}}function Gx(t,i){if(t&1&&(m(0,"div",28)(1,"span",29),x(2),y(),m(3,"span"),x(4),y()()),t&2){let e=I(),n=I(2);g(),N("pTooltip",n.texts.llm.when.tooltip),g(),T(n.texts.llm.when.label),g(2),T(e.whenToUse)}}function jx(t,i){if(t&1&&(m(0,"div",28)(1,"span",29),x(2),y(),m(3,"span"),x(4),y()()),t&2){let e=I(),n=I(2);g(),N("pTooltip",n.texts.llm.style.tooltip),g(),T(n.texts.llm.style.label),g(2),T(e.interactionStyle)}}function Hx(t,i){if(t&1&&(m(0,"span",31),x(1),y()),t&2){let e=i.$implicit;g(),T(e)}}function Vx(t,i){if(t&1&&(m(0,"div",28)(1,"span",29),x(2),y(),m(3,"div",30),he(4,Hx,2,1,"span",31,nt),y()()),t&2){let e=I(),n=I(2);g(),N("pTooltip",n.texts.llm.does.tooltip),g(),T(n.texts.llm.does.label),g(2),fe(e.capabilities)}}function Ux(t,i){if(t&1&&(m(0,"div",28)(1,"span",29),x(2),y(),m(3,"span"),x(4),y()(),O(5,Gx,5,3,"div",28),O(6,jx,5,3,"div",28),O(7,Vx,6,2,"div",28)),t&2){let e=i,n=I(2);g(),N("pTooltip",n.texts.llm.what.tooltip),g(),T(n.texts.llm.what.label),g(2),T(e.whatItDoes),g(),F(e.whenToUse?5:-1),g(),F(e.interactionStyle?6:-1),g(),F(e.capabilities!=null&&e.capabilities.length?7:-1)}}function Wx(t,i){if(t&1&&x(0),t&2){let e=i.$implicit,n=i.$index,o=i.$count;uh("",e.step,". ",e.description,"",n===o-1?"":" \xB7 ")}}function $x(t,i){if(t&1&&(m(0,"div",28)(1,"span",29),x(2),y(),m(3,"span"),he(4,Wx,1,3,null,null,Tx),y()()),t&2){let e=I(),n=I(2);g(),N("pTooltip",n.texts.llm.steps.tooltip),g(),T(n.texts.llm.steps.label),g(2),fe(e.recipe)}}function Yx(t,i){if(t&1&&(m(0,"span",31),x(1),y()),t&2){let e=i.$implicit;g(),T(e)}}function qx(t,i){if(t&1&&(m(0,"div",28)(1,"span",29),x(2),y(),m(3,"div",30),he(4,Yx,2,1,"span",31,nt),y()()),t&2){let e=I(),n=I(2);g(),N("pTooltip",n.texts.llm.pre.tooltip),g(),T(n.texts.llm.pre.label),g(2),fe(e.preconditions)}}function Xx(t,i){if(t&1&&(m(0,"span",31),x(1),y()),t&2){let e=i.$implicit;g(),T(e)}}function Kx(t,i){if(t&1&&(m(0,"div",28)(1,"span",29),x(2),y(),m(3,"div",30),he(4,Xx,2,1,"span",31,nt),y()()),t&2){let e=I(),n=I(2);g(),N("pTooltip",n.texts.llm.out.tooltip),g(),T(n.texts.llm.out.label),g(2),fe(e.outputs)}}function Zx(t,i){if(t&1&&(m(0,"span",31),x(1),y()),t&2){let e=i.$implicit;g(),T(e)}}function Qx(t,i){if(t&1&&(m(0,"div",28)(1,"span",29),x(2),y(),m(3,"div",30),he(4,Zx,2,1,"span",31,nt),y()()),t&2){let e=I(),n=I(2);g(),N("pTooltip",n.texts.llm.fx.tooltip),g(),T(n.texts.llm.fx.label),g(2),fe(e.sideEffects)}}function Jx(t,i){if(t&1&&(m(0,"div",28)(1,"span",29),x(2),y(),m(3,"span"),x(4),y()(),O(5,$x,6,2,"div",28),O(6,qx,6,2,"div",28),O(7,Kx,6,2,"div",28),O(8,Qx,6,2,"div",28)),t&2){let e=i,n=I(2);g(),N("pTooltip",n.texts.llm.what.tooltip),g(),T(n.texts.llm.what.label),g(2),T(e.whatItDoes),g(),F(e.recipe!=null&&e.recipe.length?5:-1),g(),F(e.preconditions!=null&&e.preconditions.length?6:-1),g(),F(e.outputs!=null&&e.outputs.length?7:-1),g(),F(e.sideEffects!=null&&e.sideEffects.length?8:-1)}}function eI(t,i){if(t&1&&(m(0,"div",28)(1,"span",29),x(2),y(),m(3,"code",32),x(4),y()()),t&2){let e=I(),n=I(2);g(),N("pTooltip",n.texts.llm.eg.tooltip),g(),T(n.texts.llm.eg.label),g(2),T(e.invocationExample)}}function tI(t,i){if(t&1&&(m(0,"span",31),x(1),y()),t&2){let e=i.$implicit;g(),T(e)}}function nI(t,i){if(t&1&&(m(0,"div",28)(1,"span",29),x(2),y(),m(3,"div",30),he(4,tI,2,1,"span",31,nt),y()()),t&2){let e=I(),n=I(2);g(),N("pTooltip",n.texts.llm.fx.tooltip),g(),T(n.texts.llm.fx.label),g(2),fe(e.sideEffects)}}function iI(t,i){if(t&1&&(m(0,"div",28)(1,"span",29),x(2),y(),m(3,"span"),x(4),y()(),O(5,eI,5,3,"div",28),O(6,nI,6,2,"div",28)),t&2){let e=i,n=I(2);g(),N("pTooltip",n.texts.llm.what.tooltip),g(),T(n.texts.llm.what.label),g(2),T(e.whatItDoes),g(),F(e.invocationExample?5:-1),g(),F(e.sideEffects!=null&&e.sideEffects.length?6:-1)}}function oI(t,i){if(t&1&&(m(0,"div",28)(1,"span",29),x(2),y(),m(3,"span"),x(4),y()()),t&2){let e=I(),n=I(2);g(),N("pTooltip",n.texts.llm.trigger.tooltip),g(),T(n.texts.llm.trigger.label),g(2),T(e.triggerInferred)}}function rI(t,i){if(t&1&&(m(0,"span",31),x(1),y()),t&2){let e=i.$implicit;g(),T(e)}}function sI(t,i){if(t&1&&(m(0,"div",28)(1,"span",29),x(2),y(),m(3,"div",30),he(4,rI,2,1,"span",31,nt),y()()),t&2){let e=I(),n=I(2);g(),N("pTooltip",n.texts.llm.fx.tooltip),g(),T(n.texts.llm.fx.label),g(2),fe(e.sideEffects)}}function aI(t,i){if(t&1&&(m(0,"div",28)(1,"span",29),x(2),y(),m(3,"span"),x(4),y()(),O(5,oI,5,3,"div",28),O(6,sI,6,2,"div",28)),t&2){let e=i,n=I(2);g(),N("pTooltip",n.texts.llm.what.tooltip),g(),T(n.texts.llm.what.label),g(2),T(e.whatItDoes),g(),F(e.triggerInferred?5:-1),g(),F(e.sideEffects!=null&&e.sideEffects.length?6:-1)}}function cI(t,i){if(t&1&&(m(0,"div",16),O(1,Bx,7,5),O(2,Ux,8,6),O(3,Jx,9,7),O(4,iI,7,5),O(5,aI,7,5),y()),t&2){let e,n,o,r,s,a=I();g(),F((e=a.summaryNote())?1:-1,e),g(),F((n=a.summaryAgent())?2:-1,n),g(),F((o=a.summarySkill())?3:-1,o),g(),F((r=a.summaryCommand())?4:-1,r),g(),F((s=a.summaryHook())?5:-1,s)}}function dI(t,i){if(t&1&&(m(0,"div",17),x(1),y()),t&2){let e=I();g(),T(e.description())}}function lI(t,i){if(t&1&&(m(0,"div",18)(1,"div",33)(2,"span",34),x(3),y(),m(4,"span",35),x(5),y()()()),t&2){let e=I(),n=I();g(3),T(n.texts.meta.model),g(2),T(e.model)}}function uI(t,i){t&1&&O(0,lI,6,2,"div",18),t&2&&F(i.model?0:-1)}function hI(t,i){t&1&&(m(0,"span",37),x(1,"*"),y())}function fI(t,i){if(t&1&&(m(0,"span",36),x(1),O(2,hI,2,0,"span",37),y()),t&2){let e=i.$implicit;N("pTooltip",e.description??e.name),g(),T(e.name),g(),F(e.required?2:-1)}}function gI(t,i){if(t&1&&(m(0,"div",33)(1,"span",34),x(2),y(),m(3,"div",30),he(4,fI,3,3,"span",36,nh),y()()),t&2){let e=I(2),n=I();g(2),T(n.texts.meta.inputs),g(2),fe(e.inputs)}}function pI(t,i){if(t&1&&(m(0,"span",36),x(1),y()),t&2){let e=i.$implicit;N("pTooltip",e.description??e.name),g(),T(e.name)}}function _I(t,i){if(t&1&&(m(0,"div",33)(1,"span",34),x(2),y(),m(3,"div",30),he(4,pI,2,2,"span",36,nh),y()()),t&2){let e=I(2),n=I();g(2),T(n.texts.meta.outputs),g(2),fe(e.outputs)}}function mI(t,i){if(t&1&&(m(0,"div",18),O(1,gI,6,1,"div",33),O(2,_I,6,1,"div",33),y()),t&2){let e=I();g(),F(e.inputs!=null&&e.inputs.length?1:-1),g(),F(e.outputs!=null&&e.outputs.length?2:-1)}}function yI(t,i){if(t&1&&O(0,mI,3,2,"div",18),t&2){let e=i;F(e.inputs!=null&&e.inputs.length||e.outputs!=null&&e.outputs.length?0:-1)}}function vI(t,i){t&1&&(m(0,"span",37),x(1,"*"),y())}function CI(t,i){if(t&1&&(m(0,"span",36),x(1),O(2,vI,2,0,"span",37),y()),t&2){let e=i.$implicit;N("pTooltip",e.description??e.name),g(),T(e.name),g(),F(e.required?2:-1)}}function wI(t,i){if(t&1&&(m(0,"div",33)(1,"span",34),x(2),y(),m(3,"div",30),he(4,CI,3,3,"span",36,nh),y()()),t&2){let e=I(2),n=I();g(2),T(n.texts.meta.args),g(2),fe(e.args)}}function bI(t,i){if(t&1&&(m(0,"div",33)(1,"span",34),x(2),y(),m(3,"span",35),x(4),y()()),t&2){let e=I(2),n=I();g(2),T(n.texts.meta.shortcut),g(2),T(e.shortcut)}}function xI(t,i){if(t&1&&(m(0,"div",18),O(1,wI,6,1,"div",33),O(2,bI,5,2,"div",33),y()),t&2){let e=I();g(),F(e.args!=null&&e.args.length?1:-1),g(),F(e.shortcut?2:-1)}}function II(t,i){if(t&1&&O(0,xI,3,2,"div",18),t&2){let e=i;F(e.args!=null&&e.args.length||e.shortcut?0:-1)}}function SI(t,i){if(t&1&&(m(0,"div",33)(1,"span",34),x(2),y(),m(3,"span",35),x(4),y()()),t&2){let e=I(),n=I();g(2),T(n.texts.meta.event),g(2),T(e.event)}}function EI(t,i){if(t&1&&(m(0,"div",33)(1,"span",34),x(2),y(),m(3,"span",35),x(4),y()()),t&2){let e=I(),n=I();g(2),T(n.texts.meta.cond),g(2),T(e.condition)}}function DI(t,i){if(t&1&&(m(0,"span",38),x(1),y()),t&2){let e=I(3);N("pTooltip",e.texts.meta.blocking.tooltip),g(),T(e.texts.meta.blocking.label)}}function TI(t,i){if(t&1&&(m(0,"span",38),x(1),y()),t&2){let e=I(3);N("pTooltip",e.texts.meta.idempotent.tooltip),g(),T(e.texts.meta.idempotent.label)}}function PI(t,i){if(t&1&&(m(0,"div",33)(1,"span",34),x(2),y(),m(3,"div",30),O(4,DI,2,2,"span",38),O(5,TI,2,2,"span",38),y()()),t&2){let e=I(),n=I();g(2),T(n.texts.meta.flags),g(2),F(e.blocking?4:-1),g(),F(e.idempotent?5:-1)}}function MI(t,i){if(t&1&&(m(0,"div",18),O(1,SI,5,2,"div",33),O(2,EI,5,2,"div",33),O(3,PI,6,3,"div",33),y()),t&2){let e=i;g(),F(e.event?1:-1),g(),F(e.condition?2:-1),g(),F(e.blocking||e.idempotent?3:-1)}}function RI(t,i){if(t&1&&(m(0,"div",40),j(1,"i",41),m(2,"code",42),x(3),y(),m(4,"span",43),x(5),y()()),t&2){let e=i.$implicit;Xe("sm-gnode__issue--"+e.severity),N("pTooltip",e.detail??e.ruleId+" \xB7 "+e.message),g(),Be("pi",!0)("pi-times-circle",e.severity==="error")("pi-exclamation-triangle",e.severity==="warn"),g(2),T(e.ruleId),g(2),T(e.message)}}function NI(t,i){if(t&1&&(m(0,"div",19),he(1,RI,6,11,"div",39,Px),y()),t&2){let e=I();g(),fe(e.visibleIssues())}}function kI(t,i){if(t&1&&(m(0,"span",21),j(1,"i",44),m(2,"span",45),x(3),y()()),t&2){let e=I();N("pTooltip",e.texts.stats.errors(e.errorCount())),g(3),T(e.errorCount())}}function OI(t,i){if(t&1&&(m(0,"span",22),j(1,"i",46),m(2,"span",45),x(3),y()()),t&2){let e=I();N("pTooltip",e.texts.stats.warns(e.warnCount())),g(3),T(e.warnCount())}}function FI(t,i){if(t&1&&(m(0,"span",23),j(1,"i",47),m(2,"span",45),x(3),y()()),t&2){let e=I();N("pTooltip",e.toolsTooltip()),g(3),T(e.toolsCount())}}function AI(t,i){if(t&1&&(m(0,"span",23)(1,"span",48),x(2,"\u2193"),y(),m(3,"span",45),x(4),y()()),t&2){let e=I(),n=ut(1);N("pTooltip",e.texts.stats.linksIn(n.linksIn)),g(4),T(n.linksIn)}}function LI(t,i){if(t&1&&(m(0,"span",23)(1,"span",48),x(2,"\u2191"),y(),m(3,"span",45),x(4),y()()),t&2){let e=I(),n=ut(1);N("pTooltip",e.texts.stats.linksOut(n.linksOut)),g(4),T(n.linksOut)}}function zI(t,i){if(t&1&&(m(0,"span",23),j(1,"i",49),m(2,"span",45),x(3),y()()),t&2){let e=I(),n=ut(1);N("pTooltip",e.texts.stats.extRefs(n.externalRefsCount)),g(3),T(n.externalRefsCount)}}function BI(t,i){if(t&1&&(m(0,"span",23),ke(),m(1,"svg",51),j(2,"path",52)(3,"path",53)(4,"path",54),y()()),t&2){let e=I(2);N("pTooltip",e.texts.stability.experimental)}}function GI(t,i){if(t&1&&(m(0,"span",23),j(1,"i",55),y()),t&2){let e=I(2);N("pTooltip",e.texts.stability.deprecated)}}function jI(t,i){if(t&1&&(m(0,"span",50),ke(),m(1,"svg",51),j(2,"path",56)(3,"line",57)(4,"line",58),y()()),t&2){let e=I(2);N("pTooltip",e.texts.safety.injection(e.injectionType()))}}function HI(t,i){if(t&1&&(m(0,"div",24),O(1,BI,5,1,"span",23),O(2,GI,2,1,"span",23),O(3,jI,5,1,"span",50),y()),t&2){let e=I();g(),F(e.stability()==="experimental"?1:-1),g(),F(e.stability()==="deprecated"?2:-1),g(),F(e.hasInjection()?3:-1)}}var Zd=class t{node=R.required();stats=R({linksIn:0,linksOut:0});summary=R(null);issues=R([]);selected=R(!1);highlighted=R(!1);dimmed=R(!1);texts=kg;expanded=Dt(!1);fmAgent=z(()=>{let i=this.node();return i.kind==="agent"?i.frontmatter:null});fmSkill=z(()=>{let i=this.node();return i.kind==="skill"?i.frontmatter:null});fmCommand=z(()=>{let i=this.node();return i.kind==="command"?i.frontmatter:null});fmHook=z(()=>{let i=this.node();return i.kind==="hook"?i.frontmatter:null});summaryAgent=z(()=>{let i=this.summary();return i?.kind==="agent"?i:null});summarySkill=z(()=>{let i=this.summary();return i?.kind==="skill"?i:null});summaryCommand=z(()=>{let i=this.summary();return i?.kind==="command"?i:null});summaryHook=z(()=>{let i=this.summary();return i?.kind==="hook"?i:null});summaryNote=z(()=>{let i=this.summary();return i?.kind==="note"?i:null});hasLlmCluster=z(()=>this.summary()!==null);hasInjection=z(()=>this.summary()?.safety.injectionDetected===!0);confidenceTier=z(()=>{let i=this.summary();return i?i.confidence>.8?"high":i.confidence>=.5?"med":"low":null});confidencePct=z(()=>{let i=this.summary();return i?Math.round(i.confidence*100):null});injectionType=z(()=>{let i=this.summary();return i?.safety.injectionDetected?i.safety.injectionType??null:null});visibleIssues=z(()=>this.issues().filter(i=>i.severity==="error"||i.severity==="warn"));errorCount=z(()=>this.visibleIssues().filter(i=>i.severity==="error").length);warnCount=z(()=>this.visibleIssues().filter(i=>i.severity==="warn").length);nodeColor=z(()=>{let i=this.node().frontmatter.metadata.color;return typeof i=="string"&&i.length>0?i:null});bytesShort=z(()=>{let i=this.stats().bytesTotal;return i===void 0?null:Og(i)});tokensShort=z(()=>{let i=this.stats().tokensTotal;return i===void 0?null:Og(i)});daysAgo=z(()=>{let i=this.node().frontmatter.metadata.updated;if(!i)return null;let e=new Date(i);if(isNaN(e.getTime()))return null;let n=Math.max(0,Math.floor((Date.now()-e.getTime())/864e5));return{short:`${n}d`,iso:typeof i=="string"?i:e.toISOString(),days:n}});version=z(()=>{let i=this.node().frontmatter.metadata.version;return i?`v${i}`:null});stability=z(()=>this.node().frontmatter.metadata.stability??null);displayName=z(()=>this.node().frontmatter.name||this.node().path);description=z(()=>this.node().frontmatter.description??"");toolsCount=z(()=>{let i=this.node().frontmatter,e=Array.isArray(i.tools)?i.tools.length:0,n=Array.isArray(i.allowedTools)?i.allowedTools.length:0;return e+n});toolsTooltip=z(()=>{let i=this.node().frontmatter,e=Array.isArray(i.tools)?i.tools.length:0,n=Array.isArray(i.allowedTools)?i.allowedTools.length:0;return this.texts.stats.toolsBreakdown(e,n)});toggleExpanded(i){i.stopPropagation(),this.expanded.update(e=>!e)}static \u0275fac=function(e){return new(e||t)};static \u0275cmp=ee({type:t,selectors:[["sm-node-card"]],hostAttrs:[1,"sm-gnode"],hostVars:26,hostBindings:function(e,n){e&2&&(lt("--node-color",n.nodeColor()),Be("sm-gnode--skill",n.node().kind==="skill")("sm-gnode--agent",n.node().kind==="agent")("sm-gnode--command",n.node().kind==="command")("sm-gnode--hook",n.node().kind==="hook")("sm-gnode--note",n.node().kind==="note")("sm-gnode--danger",n.hasInjection())("sm-gnode--with-color",!!n.nodeColor())("sm-gnode--deprecated",n.stability()==="deprecated")("sm-gnode--expanded",n.expanded())("sm-gnode--selected",n.selected())("sm-gnode--highlighted",n.highlighted())("sm-gnode--dimmed",n.dimmed()))},inputs:{node:[1,"node"],stats:[1,"stats"],summary:[1,"summary"],issues:[1,"issues"],selected:[1,"selected"],highlighted:[1,"highlighted"],dimmed:[1,"dimmed"],expanded:[1,"expanded"]},outputs:{expanded:"expandedChange"},decls:35,vars:27,consts:[[1,"sm-gnode__main"],["aria-hidden","true",1,"sm-gnode__icon-box"],[3,"kind","size"],[1,"sm-gnode__content"],[1,"sm-gnode__name-row"],[1,"sm-gnode__name",3,"pTooltip"],[1,"sm-gnode__actions"],[1,"sm-gnode__confidence",3,"class","pTooltip"],["type","button",1,"sm-gnode__chevron",3,"click"],["aria-hidden","true",1,"pi","pi-chevron-down"],[1,"sm-gnode__sub"],[1,"sm-gnode__sub-stat","sm-gnode__sub-stat--tokens",3,"pTooltip"],[1,"sm-gnode__sub-stat","sm-gnode__sub-stat--bytes",3,"pTooltip"],[1,"sm-gnode__sub-stat","sm-gnode__sub-stat--date",3,"pTooltip"],[1,"sm-gnode__sub-version"],[1,"sm-gnode__panel"],[1,"sm-gnode__llm"],[1,"sm-gnode__desc"],[1,"sm-gnode__meta"],[1,"sm-gnode__issues-block"],[1,"sm-gnode__footer"],[1,"sm-gnode__stat","sm-gnode__stat--error",3,"pTooltip"],[1,"sm-gnode__stat","sm-gnode__stat--warn",3,"pTooltip"],[1,"sm-gnode__stat",3,"pTooltip"],[1,"sm-gnode__footer-end"],[1,"sm-gnode__confidence",3,"pTooltip"],[1,"sm-gnode__sub-key"],["aria-hidden","true",1,"pi","pi-calendar"],[1,"sm-gnode__llm-line"],[1,"sm-gnode__llm-label",3,"pTooltip"],[1,"sm-gnode__chips"],[1,"sm-gnode__chip","sm-gnode__chip--llm"],[1,"sm-gnode__llm-code"],[1,"sm-gnode__meta-row"],[1,"sm-gnode__meta-label"],[1,"sm-gnode__meta-value","sm-gnode__meta-value--mono"],[1,"sm-gnode__chip","sm-gnode__chip--mono",3,"pTooltip"],[1,"sm-gnode__chip-required"],[1,"sm-gnode__chip",3,"pTooltip"],[1,"sm-gnode__issue",3,"class","pTooltip"],[1,"sm-gnode__issue",3,"pTooltip"],["aria-hidden","true",1,"sm-gnode__issue-icon"],[1,"sm-gnode__issue-rule"],[1,"sm-gnode__issue-msg"],["aria-hidden","true",1,"pi","pi-times-circle"],[1,"sm-gnode__stat-num"],["aria-hidden","true",1,"pi","pi-exclamation-triangle"],["aria-hidden","true",1,"pi","pi-wrench"],["aria-hidden","true"],["aria-hidden","true",1,"pi","pi-link"],[1,"sm-gnode__stat","sm-gnode__stat--danger",3,"pTooltip"],["width","14","height","14","viewBox","0 0 24 24","fill","none","stroke","currentColor","stroke-width","2","stroke-linecap","round","stroke-linejoin","round","aria-hidden","true"],["d","M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2"],["d","M6.453 15h11.094"],["d","M8.5 2h7"],["aria-hidden","true",1,"pi","pi-ban"],["d","M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"],["x1","12","y1","8","x2","12","y2","12"],["x1","12","y1","16","x2","12.01","y2","16"]],template:function(e,n){if(e&1&&(hh(0)(1)(2),m(3,"div",0)(4,"div",1),j(5,"sm-kind-icon",2),y(),m(6,"div",3)(7,"div",4)(8,"span",5),x(9),y()()(),m(10,"div",6),O(11,Mx,2,4,"span",7),m(12,"button",8),ye("click",function(r){return n.toggleExpanded(r)}),j(13,"i",9),y()(),m(14,"div",10),O(15,Rx,4,2,"span",11),O(16,Nx,4,2,"span",12),O(17,kx,3,2,"span",13),O(18,Ox,2,1,"span",14),y()(),m(19,"div",15),O(20,cI,6,5,"div",16),O(21,dI,2,1,"div",17),O(22,uI,1,1),O(23,yI,1,1),O(24,II,1,1),O(25,MI,4,3,"div",18),O(26,NI,3,0,"div",19),y(),m(27,"div",20),O(28,kI,4,2,"span",21),O(29,OI,4,2,"span",22),O(30,FI,4,2,"span",23),O(31,AI,5,2,"span",23),O(32,LI,5,2,"span",23),O(33,zI,4,2,"span",23),O(34,HI,4,3,"div",24),y()),e&2){let o,r,s,a,c,l,u=n.node(),h=Ei(n.summary());g();let v=Ei(n.stats());g();let w=Ei(n.confidenceTier());g(3),N("kind",u.kind)("size",18),g(3),N("pTooltip",n.displayName()),g(),T(n.displayName()),g(2),F(h!==null&&w!==null?11:-1),g(),K("aria-label",n.texts.ariaExpand),g(3),F(n.tokensShort()!==null?15:-1),g(),F(n.bytesShort()!==null?16:-1),g(),F((o=n.daysAgo())?17:-1,o),g(),F((r=n.version())?18:-1,r),g(2),F(n.hasLlmCluster()?20:-1),g(),F(n.description()?21:-1),g(),F((s=n.fmAgent())?22:-1,s),g(),F((a=n.fmSkill())?23:-1,a),g(),F((c=n.fmCommand())?24:-1,c),g(),F((l=n.fmHook())?25:-1,l),g(),F(n.visibleIssues().length?26:-1),g(2),F(n.errorCount()>0?28:-1),g(),F(n.warnCount()>0?29:-1),g(),F(n.toolsCount()>0?30:-1),g(),F(v.linksIn>0?31:-1),g(),F(v.linksOut>0?32:-1),g(),F(v.externalRefsCount&&v.externalRefsCount>0?33:-1),g(),F(n.stability()==="experimental"||n.stability()==="deprecated"||n.hasInjection()?34:-1)}},dependencies:[Kd,Xt,qt],styles:['[_nghost-%COMP%]{position:relative;display:inline-block;width:260px;background:var(--sm-bg-content);border:1px solid var(--sm-border);border-radius:8px;box-shadow:var(--sm-shadow-card);overflow:hidden;transition:box-shadow .12s ease,transform .12s ease;-webkit-user-select:none;user-select:none;text-align:start}[_nghost-%COMP%]:hover{box-shadow:var(--sm-shadow-card-hover)}[_nghost-%COMP%]:before{content:"";position:absolute;top:0;left:0;right:0;height:3px;background:var(--accent, var(--sm-kind-note))}.sm-gnode--skill[_nghost-%COMP%]{--accent: var(--sm-kind-skill)}.sm-gnode--agent[_nghost-%COMP%]{--accent: var(--sm-kind-agent)}.sm-gnode--command[_nghost-%COMP%]{--accent: var(--sm-kind-command)}.sm-gnode--hook[_nghost-%COMP%]{--accent: var(--sm-kind-hook)}.sm-gnode--note[_nghost-%COMP%]{--accent: var(--sm-kind-note)}.sm-gnode--danger[_nghost-%COMP%]{--accent: var(--sm-severity-error)}.sm-gnode--deprecated[_nghost-%COMP%]{opacity:.55}.sm-gnode--selected[_nghost-%COMP%]{border-color:var(--p-primary-color);box-shadow:0 0 0 2px var(--p-primary-color),0 4px 16px color-mix(in srgb,var(--p-primary-color) 25%,transparent)}.sm-gnode--highlighted[_nghost-%COMP%]{border-color:var(--p-primary-color);box-shadow:var(--sm-shadow-card-hover)}.sm-gnode--dimmed[_nghost-%COMP%]{opacity:.25}.sm-gnode__main[_ngcontent-%COMP%]{display:grid;grid-template-columns:auto minmax(0,1fr) auto;column-gap:.6rem;row-gap:.3rem;align-items:start;padding:.6rem .65rem}.sm-gnode__icon-box[_ngcontent-%COMP%]{width:38px;height:38px;border-radius:8px;display:flex;align-items:center;justify-content:center;background:var(--kind-bg, var(--sm-kind-note-bg));color:var(--kind-fg, var(--sm-kind-note-fg));flex:none;font-size:1.05rem;grid-row:1 / span 2;align-self:center}.sm-gnode--skill[_nghost-%COMP%] .sm-gnode__icon-box[_ngcontent-%COMP%]{--kind-bg: var(--sm-kind-skill-bg);--kind-fg: var(--sm-kind-skill-fg)}.sm-gnode--agent[_nghost-%COMP%] .sm-gnode__icon-box[_ngcontent-%COMP%]{--kind-bg: var(--sm-kind-agent-bg);--kind-fg: var(--sm-kind-agent-fg)}.sm-gnode--command[_nghost-%COMP%] .sm-gnode__icon-box[_ngcontent-%COMP%]{--kind-bg: var(--sm-kind-command-bg);--kind-fg: var(--sm-kind-command-fg)}.sm-gnode--hook[_nghost-%COMP%] .sm-gnode__icon-box[_ngcontent-%COMP%]{--kind-bg: var(--sm-kind-hook-bg);--kind-fg: var(--sm-kind-hook-fg)}.sm-gnode--note[_nghost-%COMP%] .sm-gnode__icon-box[_ngcontent-%COMP%]{--kind-bg: var(--sm-kind-note-bg);--kind-fg: var(--sm-kind-note-fg)}.sm-gnode__content[_ngcontent-%COMP%]{min-width:0;width:100%;justify-self:stretch;display:flex;flex-direction:column;gap:.15rem}.sm-gnode__name-row[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.4rem;min-width:0}.sm-gnode__name[_ngcontent-%COMP%]{font-size:.9rem;font-weight:600;line-height:1.2;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--p-text-color);flex:0 1 auto;min-width:0}.sm-gnode--with-color[_nghost-%COMP%] .sm-gnode__name[_ngcontent-%COMP%]{background:color-mix(in srgb,var(--node-color) 7%,transparent);padding:.05rem .4rem;border-radius:3px}.sm-gnode__actions[_ngcontent-%COMP%]{display:flex;align-items:flex-start;gap:.2rem}.sm-gnode__confidence[_ngcontent-%COMP%]{display:flex;align-items:flex-start;font-size:.65rem;font-weight:600;font-variant-numeric:tabular-nums;line-height:1;flex:none;cursor:help;padding-top:.35rem}.sm-gnode__llm-marker--high[_ngcontent-%COMP%]{color:var(--sm-severity-success)}.sm-gnode__llm-marker--med[_ngcontent-%COMP%]{color:var(--sm-severity-warn)}.sm-gnode__llm-marker--low[_ngcontent-%COMP%]{color:var(--sm-severity-error)}.sm-gnode__chevron[_ngcontent-%COMP%]{width:22px;height:22px;display:inline-flex;align-items:center;justify-content:center;border:none;background:transparent;cursor:pointer;color:var(--sm-text-muted);border-radius:4px;transition:transform .16s ease,background .12s ease,color .12s ease}.sm-gnode__chevron[_ngcontent-%COMP%] .pi[_ngcontent-%COMP%]{font-size:.7rem;line-height:1}.sm-gnode__chevron[_ngcontent-%COMP%]:hover{background:var(--sm-bg-hover);color:var(--p-text-color)}.sm-gnode--expanded[_nghost-%COMP%] .sm-gnode__chevron[_ngcontent-%COMP%]{transform:rotate(180deg)}.sm-gnode__sub[_ngcontent-%COMP%]{grid-column:2 / -1;grid-row:2;display:flex;flex-wrap:nowrap;align-items:center;gap:6px;font-family:var(--sm-font-mono);font-size:.6rem;color:var(--sm-text-muted);line-height:1.2;margin-top:.1rem;min-width:0;width:100%}.sm-gnode__sub-version[_ngcontent-%COMP%]{margin-left:auto}.sm-gnode__sub-stat[_ngcontent-%COMP%], .sm-gnode__sub-version[_ngcontent-%COMP%]{padding:.08rem .35rem;border-radius:3px;background:var(--sm-bg-hover);font-family:var(--sm-font-mono);font-size:.6rem;color:var(--sm-text-muted);font-weight:400;flex:none}.sm-gnode__sub-stat[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.15rem;cursor:help}.sm-gnode__sub-stat[_ngcontent-%COMP%] i[_ngcontent-%COMP%]{font-size:.65rem}.sm-gnode__sub-key[_ngcontent-%COMP%]{font-weight:700}.sm-gnode__sub-stat--tokens[_ngcontent-%COMP%]{background:color-mix(in srgb,var(--sm-kind-agent) 7%,transparent)}.sm-gnode__sub-stat--bytes[_ngcontent-%COMP%]{background:color-mix(in srgb,var(--sm-kind-command) 7%,transparent)}.sm-gnode__sub-stat--date[_ngcontent-%COMP%]{background:color-mix(in srgb,var(--sm-kind-skill) 7%,transparent)}.app-dark[_nghost-%COMP%] .sm-gnode__sub-stat--tokens[_ngcontent-%COMP%], .app-dark [_nghost-%COMP%] .sm-gnode__sub-stat--tokens[_ngcontent-%COMP%]{background:color-mix(in srgb,var(--sm-kind-agent) 22%,transparent);color:var(--sm-kind-agent-fg)}.app-dark[_nghost-%COMP%] .sm-gnode__sub-stat--bytes[_ngcontent-%COMP%], .app-dark [_nghost-%COMP%] .sm-gnode__sub-stat--bytes[_ngcontent-%COMP%]{background:color-mix(in srgb,var(--sm-kind-command) 22%,transparent);color:var(--sm-kind-command-fg)}.app-dark[_nghost-%COMP%] .sm-gnode__sub-stat--date[_ngcontent-%COMP%], .app-dark [_nghost-%COMP%] .sm-gnode__sub-stat--date[_ngcontent-%COMP%]{background:color-mix(in srgb,var(--sm-kind-skill) 22%,transparent);color:var(--sm-kind-skill-fg)}.sm-gnode__panel[_ngcontent-%COMP%]{display:none;border-top:1px solid var(--sm-border)}.sm-gnode--expanded[_nghost-%COMP%] .sm-gnode__panel[_ngcontent-%COMP%]{display:block}.sm-gnode__llm[_ngcontent-%COMP%]{padding:.5rem .7rem;display:flex;flex-direction:column;gap:.25rem;font-size:.75rem;line-height:1.4}.sm-gnode__llm-line[_ngcontent-%COMP%]{display:flex;gap:.4rem;align-items:baseline;color:var(--p-text-color);font-style:italic;min-width:0}.sm-gnode__llm-label[_ngcontent-%COMP%]{flex:none;font-style:normal;color:var(--sm-text-muted);font-size:.6rem;letter-spacing:.04em;text-transform:uppercase;font-weight:600;min-width:2.2rem;padding-top:.2rem;cursor:help}.sm-gnode__chips[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;gap:.25rem;flex:1;min-width:0}.sm-gnode__chip[_ngcontent-%COMP%]{font-size:.65rem;padding:.1rem .4rem;border-radius:3px;border:1px solid var(--sm-border);background:var(--sm-bg-hover);color:var(--p-text-color);line-height:1.3}.sm-gnode__chip--mono[_ngcontent-%COMP%]{font-family:var(--sm-font-mono)}.sm-gnode__chip--allowed[_ngcontent-%COMP%]{border-style:dashed;background:transparent;color:var(--sm-text-muted)}.sm-gnode__chip--llm[_ngcontent-%COMP%]{font-style:italic}.sm-gnode__chip-required[_ngcontent-%COMP%]{color:var(--sm-severity-error);margin-left:2px}.sm-gnode__llm-code[_ngcontent-%COMP%]{font-family:var(--sm-font-mono);background:var(--sm-bg-hover);padding:.1rem .4rem;border-radius:3px;font-size:.7rem;font-style:normal;color:var(--p-text-color)}.sm-gnode__desc[_ngcontent-%COMP%]{padding:.55rem .7rem;font-size:.78rem;line-height:1.45;color:var(--p-text-color);max-height:140px;overflow-y:auto;overscroll-behavior:contain;border-top:1px solid var(--sm-border);scrollbar-width:thin;scrollbar-color:var(--sm-border) transparent}.sm-gnode__desc[_ngcontent-%COMP%]::-webkit-scrollbar{width:6px}.sm-gnode__desc[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:transparent}.sm-gnode__desc[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:var(--sm-border);border-radius:3px}.sm-gnode__meta[_ngcontent-%COMP%]{padding:.5rem .7rem;border-top:1px solid var(--sm-border);display:flex;flex-direction:column;gap:.35rem}.sm-gnode__meta-row[_ngcontent-%COMP%]{display:flex;align-items:flex-start;gap:.5rem;font-size:.7rem;min-width:0}.sm-gnode__meta-label[_ngcontent-%COMP%]{color:var(--sm-text-muted);text-transform:uppercase;letter-spacing:.04em;font-weight:600;font-size:.6rem;flex:none;min-width:60px;padding-top:.15rem}.sm-gnode__meta-value[_ngcontent-%COMP%]{color:var(--p-text-color);font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.sm-gnode__meta-value--mono[_ngcontent-%COMP%]{font-family:var(--sm-font-mono);background:var(--sm-bg-hover);padding:.08rem .4rem;border-radius:3px;font-size:.68rem}.sm-gnode__issues-block[_ngcontent-%COMP%]{padding:.5rem .7rem;border-top:1px solid var(--sm-border);display:flex;flex-direction:column;gap:.25rem}.sm-gnode__issue[_ngcontent-%COMP%]{display:flex;align-items:baseline;gap:.35rem;font-size:.7rem;line-height:1.35;min-width:0}.sm-gnode__issue-icon[_ngcontent-%COMP%]{font-size:.7rem;flex:none}.sm-gnode__issue--error[_ngcontent-%COMP%] .sm-gnode__issue-icon[_ngcontent-%COMP%]{color:var(--sm-severity-error)}.sm-gnode__issue--warn[_ngcontent-%COMP%] .sm-gnode__issue-icon[_ngcontent-%COMP%]{color:var(--sm-severity-warn)}.sm-gnode__issue-rule[_ngcontent-%COMP%]{font-family:var(--sm-font-mono);color:var(--sm-text-muted);flex:none;font-size:.65rem}.sm-gnode__issue-msg[_ngcontent-%COMP%]{color:var(--p-text-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0}.sm-gnode__footer[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.7rem;padding:.4rem .7rem;border-top:1px solid var(--sm-border);background:var(--sm-bg-hover);font-size:.7rem;color:var(--sm-text-muted)}.sm-gnode__footer[_ngcontent-%COMP%]:empty{display:none}.sm-gnode__footer-end[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.7rem;margin-left:auto}.sm-gnode__stat[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.3rem;line-height:1}.sm-gnode__stat[_ngcontent-%COMP%] i[_ngcontent-%COMP%], .sm-gnode__stat[_ngcontent-%COMP%] svg[_ngcontent-%COMP%]{font-size:.85rem}.sm-gnode__stat-num[_ngcontent-%COMP%]{font-weight:600;color:var(--p-text-color)}.sm-gnode__stat--error[_ngcontent-%COMP%]{background:var(--sm-severity-error-bg);color:var(--sm-severity-error);padding:.1rem .4rem;border-radius:3px}.sm-gnode__stat--error[_ngcontent-%COMP%] .sm-gnode__stat-num[_ngcontent-%COMP%]{color:var(--sm-severity-error)}.sm-gnode__stat--warn[_ngcontent-%COMP%]{background:var(--sm-severity-warn-bg);color:var(--sm-severity-warn);padding:.1rem .4rem;border-radius:3px}.sm-gnode__stat--warn[_ngcontent-%COMP%] .sm-gnode__stat-num[_ngcontent-%COMP%]{color:var(--sm-severity-warn)}.sm-gnode__stat--danger[_ngcontent-%COMP%]{color:var(--sm-severity-error)}'],changeDetection:0})};function Og(t){return t<1e3?`${t}`:t<1e4?`${(t/1e3).toFixed(1).replace(/\.0$/,"")}k`:`${Math.round(t/1e3)}k`}var Fg={a11y:{expand:"Expand performance HUD",collapse:"Collapse performance HUD"},units:{fps:t=>`${t} fps`,ms:t=>`${t}ms`,mb:t=>`${t} MB`,longTasks:t=>`${t} long`,domNodes:t=>`${t} dom`,nodes:(t,i)=>`${t}/${i} nodes`,edges:t=>`${t} edges`,cacheAge:t=>`cache ${t}s`}};var VI=["sparkline"];function UI(t,i){if(t&1&&(m(0,"span",5),x(1,"\xB7"),y(),m(2,"span",3),x(3),y()),t&2){let e=I(3);g(3),T(e.texts.units.mb(e.heapMb()))}}function WI(t,i){if(t&1&&(m(0,"span",5),x(1,"\xB7"),y(),m(2,"span",3),x(3),y()),t&2){let e=I(3);g(3),T(e.texts.units.cacheAge(e.cacheAgeSec()))}}function $I(t,i){if(t&1&&(j(0,"canvas",4,1),m(2,"span",5),x(3,"\xB7"),y(),m(4,"span",3),x(5),y(),O(6,UI,4,1),m(7,"span",5),x(8,"\xB7"),y(),m(9,"span",3),x(10),y(),m(11,"span",5),x(12,"\xB7"),y(),m(13,"span",3),x(14),y(),m(15,"span",5),x(16,"\xB7"),y(),m(17,"span",3),x(18),y(),m(19,"span",5),x(20,"\xB7"),y(),m(21,"span",3),x(22),y(),O(23,WI,4,1)),t&2){let e=I(2);g(5),T(e.texts.units.ms(e.frameTimeMs())),g(),F(e.hasHeap()?6:-1),g(4),T(e.texts.units.longTasks(e.longTasks())),g(4),T(e.texts.units.domNodes(e.domNodes())),g(4),T(e.texts.units.nodes(e.visible(),e.total())),g(4),T(e.texts.units.edges(e.edges())),g(),F(e.cacheAgeSec()!==null?23:-1)}}function YI(t,i){if(t&1&&(m(0,"span",3),x(1),y(),O(2,$I,24,7)),t&2){let e=I();g(),T(e.texts.units.fps(e.fps())),g(),F(e.expanded()?2:-1)}}var qI=30,ih=60,Qd=14,Jd=class t{visible=R(0);total=R(0);edges=R(0);cacheAt=R(null);texts=Fg;destroyRef=d(We);zone=d(Sn);fps=J(0);frameTimeMs=J(0);fpsSamples=J([]);sparklineCanvas=ge("sparkline");heapMb=J(null);longTasks=J(0);domNodes=J(0);nowTick=J(performance.now());expanded=J(XI());cacheAgeSec=z(()=>{let i=this.cacheAt();return i===null?null:Math.max(0,Math.floor((this.nowTick()-i)/1e3))});hasHeap=z(()=>this.heapMb()!==null);constructor(){let i=0,e=0,n=performance.now(),o=n,r=0,s=c=>{let l=c-n;if(n=c,i+=1,e+=l,c-o>=1e3){let u=(c-o)/1e3,h=Math.round(i/u);this.fps.set(h),this.frameTimeMs.set(Math.round(e/Math.max(i,1))),this.heapMb.set(ZI()),this.domNodes.set(document.querySelectorAll("*").length),this.nowTick.set(c),this.fpsSamples.update(v=>{let w=v.length>=qI?v.slice(1):v.slice();return w.push(h),w}),i=0,e=0,o=c}r=requestAnimationFrame(s)};this.zone.runOutsideAngular(()=>{r=requestAnimationFrame(s)});let a=null;if(typeof PerformanceObserver<"u")try{a=new PerformanceObserver(c=>{this.longTasks.update(l=>l+c.getEntries().length)}),a.observe({type:"longtask",buffered:!0})}catch{}this.destroyRef.onDestroy(()=>{cancelAnimationFrame(r),a?.disconnect()}),Se(()=>{let c=this.sparklineCanvas(),l=this.fpsSamples();c&&QI(c.nativeElement,l)})}setExpanded(i){this.expanded.set(i),KI(i)}static \u0275fac=function(e){return new(e||t)};static \u0275cmp=ee({type:t,selectors:[["app-perf-hud"]],viewQuery:function(e,n){e&1&&it(n.sparklineCanvas,VI,5),e&2&&ze()},inputs:{visible:[1,"visible"],total:[1,"total"],edges:[1,"edges"],cacheAt:[1,"cacheAt"]},decls:3,vars:2,consts:[["content",""],["sparkline",""],["styleClass","perf-hud","data-testid","perf-hud",3,"ngModelChange","ngModel","ariaLabel"],[1,"perf-hud__cell"],["aria-hidden","true",1,"perf-hud__sparkline"],["aria-hidden","true",1,"perf-hud__sep"]],template:function(e,n){e&1&&(m(0,"p-togglebutton",2),ye("ngModelChange",function(r){return n.setExpanded(r)}),wi(1,YI,3,2,"ng-template",null,0,fh),y()),e&2&&N("ngModel",n.expanded())("ariaLabel",n.expanded()?n.texts.a11y.collapse:n.texts.a11y.expand)},dependencies:[Ri,Pi,Mi,ki,Ni],styles:["[_nghost-%COMP%]{position:absolute;bottom:16px;left:16px;z-index:2;pointer-events:none}.perf-hud[_ngcontent-%COMP%]{pointer-events:auto;--p-togglebutton-padding: 0;--p-togglebutton-content-padding: .25rem .7rem;--p-togglebutton-border-radius: 999px;--p-togglebutton-content-border-radius: 999px;--p-togglebutton-gap: .4rem;--p-togglebutton-background: var(--sm-bg-content);--p-togglebutton-checked-background: var(--sm-bg-content);--p-togglebutton-hover-background: var(--sm-bg-content);--p-togglebutton-border-color: var(--sm-border);--p-togglebutton-checked-border-color: var(--sm-border);--p-togglebutton-content-checked-background: transparent;--p-togglebutton-color: var(--p-text-muted-color);--p-togglebutton-hover-color: var(--p-text-color);--p-togglebutton-checked-color: var(--p-text-muted-color);box-shadow:var(--sm-shadow-floating);font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:.7rem;font-weight:500;line-height:14px;opacity:.75;transition:opacity .15s ease,color .15s ease}.perf-hud[_ngcontent-%COMP%]:hover{opacity:1}[_nghost-%COMP%] .perf-hud .p-togglebutton-content{display:inline-flex;align-items:center;gap:.4rem}.perf-hud__cell[_ngcontent-%COMP%]{white-space:nowrap;font-variant-numeric:tabular-nums}.perf-hud__sep[_ngcontent-%COMP%]{opacity:.45}.perf-hud__sparkline[_ngcontent-%COMP%]{width:60px;height:14px;opacity:.6}"],changeDetection:0})},Ag="sm.perf-hud.expanded";function XI(){try{return localStorage.getItem(Ag)==="1"}catch{return!1}}function KI(t){try{localStorage.setItem(Ag,t?"1":"0")}catch{}}function ZI(){let t=performance.memory;return t?Math.round(t.usedJSHeapSize/1024/1024):null}function QI(t,i){let e=window.devicePixelRatio||1,n=ih*e,o=Qd*e;(t.width!==n||t.height!==o)&&(t.width=n,t.height=o);let r=t.getContext("2d");if(!r||(r.setTransform(e,0,0,e,0,0),r.clearRect(0,0,ih,Qd),i.length<2))return;let s=Math.max(60,...i),a=ih/(i.length-1);r.beginPath();for(let c=0;c<i.length;c+=1){let l=c*a,u=Qd-i[c]/s*Qd;c===0?r.moveTo(l,u):r.lineTo(l,u)}r.strokeStyle=getComputedStyle(t).color,r.lineWidth=1,r.stroke()}var JI=["canvasWrap"],jg=(t,i)=>i.id;function eS(t,i){if(t&1&&(m(0,"div",5),j(1,"span",8),m(2,"p",9),x(3),y()()),t&2){let e=I();g(3),T(e.texts.loading)}}function tS(t,i){if(t&1&&(m(0,"div",6),j(1,"span",10),m(2,"p",9),x(3),y(),m(4,"p",11),x(5),y()()),t&2){let e=I();g(3),T(e.texts.errorTitle),g(2),T(e.error())}}function nS(t,i){if(t&1&&(m(0,"div",7),j(1,"span",12),m(2,"p",9),x(3),y(),m(4,"p",11),x(5),y()()),t&2){let e=I();g(3),T(e.texts.emptyTitle),g(2),T(e.texts.emptyDesc)}}function iS(t,i){if(t&1&&(m(0,"f-connection",33),j(1,"f-connection-marker-arrow",34),y()),t&2){let e=i.$implicit,n=I(2);Xe("f-conn--"+e.kind),Be("f-conn--highlighted",n.isEdgeHighlighted(e))("f-conn--dimmed",n.isEdgeDimmed(e)),N("fOutputId",e.from+"-out")("fInputId",e.to+"-in")("fType",n.connectionType)("fBehavior",n.connectionBehavior)("fOffset",4)("fReassignDisabled",!0)("fSelectionDisabled",!0),g(),N("type",n.markerEnd)}}function oS(t,i){if(t&1){let e=St();bi(0,19),m(1,"div",36),ye("fNodePositionChange",function(o){let r=oe(e).$implicit,s=I(3);return re(s.onNodePositionChange(r.id,o))})("pointerdown",function(o){oe(e);let r=I(3);return re(r.onNodePointerDown(o))})("click",function(o){let r=oe(e).$implicit,s=I(3);return re(s.selectNode(r,o))})("dblclick",function(){let o=oe(e).$implicit,r=I(3);return re(r.openNode(o))}),j(2,"div",37),m(3,"sm-node-card",38),ye("expandedChange",function(o){let r=oe(e).$implicit,s=I(3);return re(s.setExpanded(r.id,o))}),y(),j(4,"div",39),y(),xi()}if(t&2){let e=i.$implicit,n=I(3);g(),N("fNodeId",e.id)("fNodePosition",e.position),K("data-testid","graph-node-"+e.id),g(),N("fInputId",e.id+"-in")("fInputConnectableSide",n.inputSide),g(),N("node",e.view)("stats",e.stats)("summary",e.summary)("selected",n.isSelected(e.id))("highlighted",n.isHighlighted(e.id))("dimmed",n.isDimmed(e.id))("expanded",n.isExpanded(e.id)),g(),N("fOutputId",e.id+"-out")("fOutputConnectableSide",n.outputSide)}}function rS(t,i){if(t&1&&wi(0,oS,5,14,"ng-container",35),t&2){let e=I(2);N("fVirtualForOf",e.graph().nodes)}}function sS(t,i){if(t&1){let e=St();m(0,"div",36),ye("fNodePositionChange",function(o){let r=oe(e).$implicit,s=I(3);return re(s.onNodePositionChange(r.id,o))})("pointerdown",function(o){oe(e);let r=I(3);return re(r.onNodePointerDown(o))})("click",function(o){let r=oe(e).$implicit,s=I(3);return re(s.selectNode(r,o))})("dblclick",function(){let o=oe(e).$implicit,r=I(3);return re(r.openNode(o))}),j(1,"div",37),m(2,"sm-node-card",38),ye("expandedChange",function(o){let r=oe(e).$implicit,s=I(3);return re(s.setExpanded(r.id,o))}),y(),j(3,"div",39),y()}if(t&2){let e=i.$implicit,n=I(3);N("fNodeId",e.id)("fNodePosition",e.position),K("data-testid","graph-node-"+e.id),g(),N("fInputId",e.id+"-in")("fInputConnectableSide",n.inputSide),g(),N("node",e.view)("stats",e.stats)("summary",e.summary)("selected",n.isSelected(e.id))("highlighted",n.isHighlighted(e.id))("dimmed",n.isDimmed(e.id))("expanded",n.isExpanded(e.id)),g(),N("fOutputId",e.id+"-out")("fOutputConnectableSide",n.outputSide)}}function aS(t,i){if(t&1&&(bi(0,19),he(1,sS,4,14,"div",40,jg),xi()),t&2){let e=I(2);g(),fe(e.graph().nodes)}}function cS(t,i){if(t&1&&j(0,"app-perf-hud",20),t&2){let e=I(2);N("visible",e.visibleCount())("total",e.totalCount())("edges",e.edgeCount())("cacheAt",e.layoutComputedAt())}}function dS(t,i){if(t&1){let e=St();m(0,"div",13,0),ye("mousedown",function(o){oe(e);let r=I();return re(r.onCanvasMouseDown(o))})("click",function(o){oe(e);let r=I();return re(r.onCanvasClick(o))}),m(2,"f-flow",14),ye("fLoaded",function(){oe(e);let o=I();return re(o.onLoaded())}),m(3,"f-background"),j(4,"f-rect-pattern"),y(),j(5,"f-line-alignment",15),m(6,"f-canvas",16),ye("fCanvasChange",function(o){oe(e);let r=I();return re(r.onCanvasChange(o))}),bi(7,17),he(8,iS,2,14,"f-connection",18,jg),xi(),O(10,rS,1,1,"ng-container",19)(11,aS,3,0,"ng-container",19),y(),j(12,"f-minimap"),y(),j(13,"app-kind-palette"),O(14,cS,1,4,"app-perf-hud",20),m(15,"div",21)(16,"p-button",22),ye("onClick",function(){oe(e);let o=I();return re(o.zoomIn())}),y(),m(17,"p-button",23),ye("onClick",function(){oe(e);let o=I();return re(o.zoomOut())}),y(),m(18,"p-button",24),ye("onClick",function(){oe(e);let o=I();return re(o.fitToScreen())}),y(),j(19,"span",25),m(20,"p-button",26),ye("onClick",function(){oe(e);let o=I();return re(o.resetLayout())}),y()()(),m(21,"aside",27)(22,"span",28),j(23,"span",29),x(24),y(),m(25,"span",28),j(26,"span",30),x(27),y(),m(28,"span",28),j(29,"span",31),x(30),y(),m(31,"span",28),j(32,"span",32),x(33),y()()}if(t&2){let e=I();g(2),N("fCache",e.perf.cache),g(3),N("fAlignThreshold",20),g(),N("position",e.initialPosition)("scale",e.initialScale)("fZoomStep",.06)("fZoomDblClickStep",.35)("debounceTime",150),g(2),fe(e.graph().edges),g(2),F(e.perf.virtualization?10:11),g(4),F(e.perfHud?14:-1),g(),K("aria-label",e.texts.a11y.toolbar),g(),N("ariaLabel",e.texts.toolbar.zoomIn)("pTooltip",e.texts.toolbar.zoomIn)("text",!0)("rounded",!0)("disabled",!e.canZoomIn()),g(),N("ariaLabel",e.texts.toolbar.zoomOut)("pTooltip",e.texts.toolbar.zoomOut)("text",!0)("rounded",!0)("disabled",!e.canZoomOut()),g(),N("ariaLabel",e.texts.toolbar.fitToScreen)("pTooltip",e.texts.toolbar.fitToScreen)("text",!0)("rounded",!0),g(2),N("ariaLabel",e.texts.toolbar.resetLayoutLabel)("pTooltip",e.texts.toolbar.resetLayoutTooltip)("text",!0)("rounded",!0),g(),K("aria-label",e.texts.a11y.edgeLegend),g(),N("pTooltip",e.texts.legendTooltip.invokes),g(2),ot(" ",e.texts.legend.invokes),g(),N("pTooltip",e.texts.legendTooltip.references),g(2),ot(" ",e.texts.legend.references),g(),N("pTooltip",e.texts.legendTooltip.mentions),g(2),ot(" ",e.texts.legend.mentions),g(),N("pTooltip",e.texts.legendTooltip.supersedes),g(2),ot(" ",e.texts.legend.supersedes)}}var Lg=260,zg=120,lS=.1,uS=4,Bg=.2,Hg="sm.graph.viewport",oh="sm.graph.node-positions",Vg="sm.graph.node-expanded",Gg=class t{loader=d(Oi);filters=d(Ai);router=d(ph);canvas=ge(gi);zoom=ge(pi);canvasWrap=ge("canvasWrap");outputSide=D.BOTTOM;inputSide=D.TOP;connectionType=gt.SEGMENT;connectionBehavior=pt.FIXED;markerEnd=Z.END_ALL_STATES;perf=th.graph.perf;perfHud=th.graph.perfHud;pointerDownAt=null;savedViewport=pS();hasCompletedInitialLayout=!1;initialPosition=this.savedViewport?{x:this.savedViewport.x,y:this.savedViewport.y}:{x:0,y:0};initialScale=this.savedViewport?.scale??1;scale=J(this.initialScale);canZoomIn=z(()=>this.scale()<uS-1e-6);canZoomOut=z(()=>this.scale()>lS+1e-6);texts=eh;middlePanOrigin=null;nodePositions=J(_S());expandedNodeIds=J(yS());loading=this.loader.loading;error=this.loader.error;visibleNodes=z(()=>this.filters.apply(this.loader.nodes()));fullLayout=z(()=>hS(this.loader.nodes(),this.loader.scan()));graph=z(()=>{let i=new Set(this.visibleNodes().map(e=>e.path));return fS(this.fullLayout(),i,this.nodePositions())});hasData=z(()=>this.graph().nodes.length>0);visibleCount=z(()=>this.graph().nodes.length);totalCount=z(()=>this.loader.nodes().length);edgeCount=z(()=>this.graph().edges.length);layoutComputedAt=z(()=>this.fullLayout().computedAt);selectedNodeId=J(null);adjacency=z(()=>{let i=new Map;for(let e of this.graph().edges)i.has(e.from)||i.set(e.from,new Set),i.has(e.to)||i.set(e.to,new Set),i.get(e.from).add(e.to),i.get(e.to).add(e.from);return i});selectionGuard=Se(()=>{let i=this.selectedNodeId();if(i===null)return;this.graph().nodes.some(n=>n.id===i)||this.selectedNodeId.set(null)});constructor(){Se(()=>{let i=this.visibleNodes();this.hasCompletedInitialLayout||i.length!==0&&queueMicrotask(()=>{this.hasCompletedInitialLayout=!0,this.savedViewport||this.canvas()?.fitToScreen({x:40,y:40},!1)})})}ngOnInit(){this.loader.nodes().length===0&&!this.loader.loading()&&this.loader.load()}onLoaded(){}onCanvasChange(i){if(this.scale.set(i.scale),!this.hasCompletedInitialLayout)return;let e={x:i.position.x,y:i.position.y,scale:i.scale};try{localStorage.setItem(Hg,JSON.stringify(e))}catch{}}onNodePositionChange(i,e){this.dragBuffer||(this.dragBuffer=W({},this.nodePositions())),this.dragBuffer[i]={x:e.x,y:e.y},this.nodeDragInProgress=!0}zoomIn(){this.zoom()?.setZoom(this.getViewportCenter(),Bg,at.ZOOM_IN,!0)}zoomOut(){this.zoom()?.setZoom(this.getViewportCenter(),Bg,at.ZOOM_OUT,!0)}fitToScreen(){this.canvas()?.fitToScreen({x:40,y:40},!0)}resetLayout(){if(Object.keys(this.nodePositions()).length===0){this.canvas()?.fitToScreen({x:40,y:40},!0);return}if(window.confirm(eh.resetLayoutConfirm)){this.nodePositions.set({});try{localStorage.removeItem(oh)}catch{}queueMicrotask(()=>this.canvas()?.fitToScreen({x:40,y:40},!0))}}getViewportCenter(){let i=this.canvasWrap()?.nativeElement;if(!i)return{x:0,y:0};let e=i.getBoundingClientRect();return{x:e.width/2,y:e.height/2}}onCanvasMouseDown(i){if(i.button!==1)return;i.preventDefault();let e=this.canvas()?.getPosition()??{x:0,y:0};this.middlePanOrigin={mouseX:i.clientX,mouseY:i.clientY,canvasX:e.x,canvasY:e.y},document.addEventListener("mousemove",this.onMiddlePanMove),document.addEventListener("mouseup",this.onMiddlePanEnd)}middlePanRafId=null;pendingPanPosition=null;onMiddlePanMove=i=>{this.middlePanOrigin&&(this.pendingPanPosition={x:this.middlePanOrigin.canvasX+(i.clientX-this.middlePanOrigin.mouseX),y:this.middlePanOrigin.canvasY+(i.clientY-this.middlePanOrigin.mouseY)},this.middlePanRafId===null&&(this.middlePanRafId=requestAnimationFrame(()=>{this.middlePanRafId=null;let e=this.canvas();!e||!this.pendingPanPosition||(e.setPosition(this.pendingPanPosition),e.redraw())})))};onMiddlePanEnd=()=>{this.middlePanRafId!==null&&(cancelAnimationFrame(this.middlePanRafId),this.middlePanRafId=null),this.pendingPanPosition=null,this.middlePanOrigin=null,document.removeEventListener("mousemove",this.onMiddlePanMove),document.removeEventListener("mouseup",this.onMiddlePanEnd),this.canvas()?.emitCanvasChangeEvent()};ngOnDestroy(){this.onMiddlePanEnd()}onNodePointerDown(i){this.pointerDownAt={x:i.clientX,y:i.clientY},document.addEventListener("mouseup",this.onNodeMouseUp,{once:!0})}nodeDragInProgress=!1;dragBuffer=null;onNodeMouseUp=()=>{queueMicrotask(()=>{if(!this.nodeDragInProgress){this.dragBuffer=null;return}this.nodeDragInProgress=!1,this.dragBuffer&&(this.nodePositions.set(this.dragBuffer),this.dragBuffer=null),mS(this.nodePositions())})};selectNode(i,e){this.isClickWithoutDrag(e)&&this.selectedNodeId.set(i.id)}openNode(i){this.router.navigate(["/inspector"],{queryParams:{path:i.path}})}onCanvasClick(i){let e=i.target;e?.closest(".sm-gnode")||e?.closest(".graph__toolbar")||e?.closest(".perf-hud")||e?.closest(".kind-palette")||this.selectedNodeId.set(null)}isSelected(i){return this.selectedNodeId()===i}isHighlighted(i){let e=this.selectedNodeId();return e===null||e===i?!1:this.adjacency().get(e)?.has(i)??!1}isDimmed(i){let e=this.selectedNodeId();return e===null||e===i?!1:!(this.adjacency().get(e)?.has(i)??!1)}isExpanded(i){return this.expandedNodeIds().has(i)}setExpanded(i,e){let n=this.expandedNodeIds();if(n.has(i)===e)return;let o=new Set(n);e?o.add(i):o.delete(i),this.expandedNodeIds.set(o),vS(o)}isEdgeHighlighted(i){let e=this.selectedNodeId();return e!==null&&(i.from===e||i.to===e)}isEdgeDimmed(i){let e=this.selectedNodeId();return e===null?!1:i.from!==e&&i.to!==e}isClickWithoutDrag(i){let e=this.pointerDownAt;if(this.pointerDownAt=null,!e)return!0;let n=i.clientX-e.x,o=i.clientY-e.y;return Math.hypot(n,o)<=4}static \u0275fac=function(e){return new(e||t)};static \u0275cmp=ee({type:t,selectors:[["app-graph-view"]],viewQuery:function(e,n){e&1&&it(n.canvas,gi,5)(n.zoom,pi,5)(n.canvasWrap,JI,5),e&2&&ze(3)},decls:24,vars:9,consts:[["canvasWrap",""],["data-testid","graph-view",1,"graph"],[1,"graph__header"],[1,"graph__sub"],[3,"showKinds"],["data-testid","graph-loading",1,"empty-state"],["data-testid","graph-error",1,"empty-state"],["data-testid","graph-empty",1,"empty-state"],[1,"empty-state__icon","pi","pi-spin","pi-spinner"],[1,"empty-state__title"],[1,"empty-state__icon","pi","pi-exclamation-circle",2,"color","var(--sm-severity-error)","opacity","1"],[1,"empty-state__desc"],[1,"empty-state__icon","pi","pi-filter-slash"],["data-testid","graph-canvas-wrap",1,"graph__canvas-wrap",3,"mousedown","click"],["fDraggable","",3,"fLoaded","fCache"],[3,"fAlignThreshold"],["fZoom","",3,"fCanvasChange","position","scale","fZoomStep","fZoomDblClickStep","debounceTime"],["ngProjectAs","[fConnections]",5,["","fConnections",""]],[3,"fOutputId","fInputId","fType","fBehavior","fOffset","fReassignDisabled","fSelectionDisabled","class","f-conn--highlighted","f-conn--dimmed"],["ngProjectAs","[fNodes]",5,["","fNodes",""]],[3,"visible","total","edges","cacheAt"],["role","toolbar","data-testid","graph-toolbar",1,"graph__toolbar"],["icon","pi pi-search-plus","severity","secondary","size","small","data-testid","graph-zoom-in",3,"onClick","ariaLabel","pTooltip","text","rounded","disabled"],["icon","pi pi-search-minus","severity","secondary","size","small","data-testid","graph-zoom-out",3,"onClick","ariaLabel","pTooltip","text","rounded","disabled"],["icon","pi pi-stop","severity","secondary","size","small","data-testid","graph-fit-to-screen",3,"onClick","ariaLabel","pTooltip","text","rounded"],["aria-hidden","true",1,"graph__toolbar-sep"],["icon","pi pi-refresh","severity","secondary","size","small","data-testid","graph-reset-layout",3,"onClick","ariaLabel","pTooltip","text","rounded"],["data-testid","graph-legend",1,"graph__legend"],[3,"pTooltip"],[1,"swatch","swatch--invokes"],[1,"swatch","swatch--references"],[1,"swatch","swatch--mentions"],[1,"swatch","swatch--supersedes"],[3,"fOutputId","fInputId","fType","fBehavior","fOffset","fReassignDisabled","fSelectionDisabled"],[3,"type"],["ngProjectAs","[fNodes]",5,["","fNodes",""],4,"fVirtualFor","fVirtualForOf"],["fNode","","fDragHandle","",1,"sm-gnode-host",3,"fNodePositionChange","pointerdown","click","dblclick","fNodeId","fNodePosition"],["fNodeInput","",1,"sm-gnode__connector","sm-gnode__connector--in",3,"fInputId","fInputConnectableSide"],[3,"expandedChange","node","stats","summary","selected","highlighted","dimmed","expanded"],["fNodeOutput","",1,"sm-gnode__connector","sm-gnode__connector--out",3,"fOutputId","fOutputConnectableSide"],["fNode","","fDragHandle","",1,"sm-gnode-host",3,"fNodeId","fNodePosition"]],template:function(e,n){e&1&&(m(0,"section",1)(1,"header",2)(2,"div")(3,"h2"),x(4),y(),m(5,"p",3),x(6),m(7,"code"),x(8),y(),x(9,", "),m(10,"code"),x(11),y(),x(12,", "),m(13,"code"),x(14),y(),x(15,", "),m(16,"code"),x(17),y(),x(18),y()()(),j(19,"app-filter-bar",4),O(20,eS,4,1,"div",5)(21,tS,6,2,"div",6)(22,nS,6,2,"div",7)(23,dS,34,37),y()),e&2&&(g(4),T(n.texts.title),g(2),ot(" ",n.texts.subtitlePrefix),g(2),T(n.texts.legend.invokes),g(3),T(n.texts.legend.references),g(3),T(n.texts.legend.mentions),g(3),T(n.texts.legend.supersedes),g(),ot("",n.texts.subtitleSuffix," "),g(),N("showKinds",!1),g(),F(n.loading()?20:n.error()?21:n.hasData()?23:22))},dependencies:[yh,Yf,Uf,gi,Gf,Bf,pi,nf,jf,bf,Sf,Hf,Vf,Gd,wf,Wf,Af,qd,Zd,Jd,mh,_h,Xt,qt],styles:["[_nghost-%COMP%]{display:block;height:100%}.graph[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1rem;height:100%}.graph__header[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:flex-start;gap:1rem}.graph__header[_ngcontent-%COMP%] h2[_ngcontent-%COMP%]{margin:0;font-size:1.25rem;font-weight:600}.graph__sub[_ngcontent-%COMP%]{margin:.25rem 0 0;color:var(--p-text-muted-color);font-size:.9rem}.graph__sub[_ngcontent-%COMP%] code[_ngcontent-%COMP%]{background:var(--sm-bg-hover);padding:.05rem .3rem;border-radius:.25rem;font-size:.8rem}.graph__hint[_ngcontent-%COMP%]{padding:2rem;text-align:center;color:var(--p-text-muted-color)}.graph__hint--error[_ngcontent-%COMP%]{color:var(--sm-severity-error)}.graph__canvas-wrap[_ngcontent-%COMP%]{position:relative;flex:1;min-height:0;border:1px solid var(--sm-border);border-radius:.75rem;background:var(--sm-bg-content);overflow:hidden;--ff-connection-drag-handle-stroke: transparent;--ff-connector-background-color: transparent;--ff-connector-border-color: transparent;--ff-connector-connected-color: transparent;--ff-connector-node-ring-color: transparent;--ff-canvas-background-color: transparent}.graph__canvas-wrap[_ngcontent-%COMP%] f-flow[_ngcontent-%COMP%]{width:100%;height:100%}.graph__toolbar[_ngcontent-%COMP%]{position:absolute;bottom:16px;left:50%;transform:translate(-50%);display:flex;align-items:center;gap:2px;padding:4px;background:var(--sm-bg-content);border:1px solid var(--sm-border);border-radius:999px;box-shadow:var(--sm-shadow-floating);z-index:2;pointer-events:auto}.graph__toolbar-sep[_ngcontent-%COMP%]{width:1px;height:18px;margin:0 2px;background:var(--sm-border);flex-shrink:0}.graph__legend[_ngcontent-%COMP%]{display:flex;gap:1.5rem;font-size:.85rem;color:var(--p-text-muted-color)}.graph__legend[_ngcontent-%COMP%] .swatch[_ngcontent-%COMP%]{display:inline-block;width:18px;height:3px;vertical-align:middle;margin-right:.4rem;border-radius:2px}.swatch--invokes[_ngcontent-%COMP%]{background:var(--sm-edge-invokes)}.swatch--references[_ngcontent-%COMP%]{background:var(--sm-edge-references)}.swatch--mentions[_ngcontent-%COMP%]{background:var(--sm-edge-mentions)}.swatch--supersedes[_ngcontent-%COMP%]{background:var(--sm-edge-supersedes)}.sm-gnode-host[_ngcontent-%COMP%]{position:relative;display:inline-block;cursor:pointer;--ff-node-width: auto;--ff-node-min-height: 0;--ff-node-padding: 0;--ff-node-background-color: transparent;--ff-node-border-color: transparent;--ff-node-border-color-selected: transparent;--ff-node-border-radius: 0;--ff-node-shadow: none;--ff-node-shadow-selected: none}.sm-gnode__connector[_ngcontent-%COMP%]{position:absolute;pointer-events:none}.sm-gnode__connector--out[_ngcontent-%COMP%]{bottom:calc(var(--ff-connector-size) / -2);left:50%;transform:translate(-50%)}.sm-gnode__connector--in[_ngcontent-%COMP%]{top:calc(var(--ff-connector-size) / -2);left:50%;transform:translate(-50%)}.f-conn--invokes[_ngcontent-%COMP%]{--ff-connection-color: var(--sm-edge-invokes);--ff-connection-width: 2.5px;--ff-marker-color: var(--sm-edge-invokes)}.f-conn--references[_ngcontent-%COMP%]{--ff-connection-color: var(--sm-edge-references);--ff-connection-width: 2px;--ff-marker-color: var(--sm-edge-references)}.f-conn--mentions[_ngcontent-%COMP%]{--ff-connection-color: var(--sm-edge-mentions);--ff-connection-width: 1.5px;--ff-marker-color: var(--sm-edge-mentions)}.f-conn--supersedes[_ngcontent-%COMP%]{--ff-connection-color: var(--sm-edge-supersedes);--ff-connection-width: 2px;--ff-marker-color: var(--sm-edge-supersedes)}.graph__canvas-wrap[_ngcontent-%COMP%] .f-conn--supersedes .f-connection-path{stroke-dasharray:8 4}.f-conn--highlighted[_ngcontent-%COMP%]{--ff-connection-width: 3px}.f-conn--dimmed[_ngcontent-%COMP%]{opacity:.15}"],changeDetection:0})};function hS(t,i){let e=new Set(t.map(u=>u.path)),n=new Map,o=i?.links??[];for(let u of o){if(!e.has(u.source)||!e.has(u.target)||u.source===u.target)continue;let h=bS(u.kind,u.source,u.target);n.has(h)||n.set(h,{id:h,from:u.source,to:u.target,kind:u.kind})}let r=[...n.values()],s=new qu.Graph;s.setGraph({rankdir:"TB",nodesep:50,ranksep:80,marginx:20,marginy:20}),s.setDefaultEdgeLabel(()=>({}));for(let u of t)s.setNode(u.path,{width:Lg,height:zg});for(let u of r)s.setEdge(u.from,u.to);Mg(s);let a=new Map;for(let u of t){let h=s.node(u.path);a.set(u.path,{x:(h?.x??0)-Lg/2,y:(h?.y??0)-zg/2})}let c=new Map;for(let u of t)c.set(u.path,u);let l=new Map;for(let u of i?.nodes??[])l.set(u.path,u);return{nodesByPath:c,apiNodesByPath:l,edges:r,positions:a,computedAt:performance.now()}}function fS(t,i,e){let n=t.edges.filter(a=>i.has(a.from)&&i.has(a.to)),o=new Map,r=new Map;for(let a of n)o.set(a.from,(o.get(a.from)??0)+1),r.set(a.to,(r.get(a.to)??0)+1);let s=[];for(let a of i){let c=t.nodesByPath.get(a);if(!c)continue;let l=t.apiNodesByPath.get(a),u=e[a],h=t.positions.get(a)??{x:0,y:0},v=u?{x:u.x,y:u.y}:h;s.push({id:a,path:a,view:c,kind:c.kind,position:v,stats:{linksIn:r.get(a)??0,linksOut:o.get(a)??0,bytesTotal:l?.bytes.total,tokensTotal:l?.tokens?.total,externalRefsCount:l?.externalRefsCount},summary:gS(c)})}return{nodes:s,edges:n}}function gS(t){let i={injectionDetected:!1,contentQuality:"clean"},e=(t.frontmatter.description??t.frontmatter.name??"").trim();return{kind:"note",confidence:.6,safety:i,whatItCovers:e||`${t.kind} entry`,topics:[],keyFacts:[]}}function pS(){let t=null;try{t=localStorage.getItem(Hg)}catch{return null}if(!t)return null;let i;try{i=JSON.parse(t)}catch{return null}return wS(i)?i:null}function _S(){let t=null;try{t=localStorage.getItem(oh)}catch{return{}}if(!t)return{};let i;try{i=JSON.parse(t)}catch{return{}}if(typeof i!="object"||i===null)return{};let e={};for(let[n,o]of Object.entries(i))CS(o)&&(e[n]={x:o.x,y:o.y});return e}function mS(t){try{localStorage.setItem(oh,JSON.stringify(t))}catch{}}function yS(){let t=null;try{t=localStorage.getItem(Vg)}catch{return new Set}if(!t)return new Set;let i;try{i=JSON.parse(t)}catch{return new Set}if(!Array.isArray(i))return new Set;let e=new Set;for(let n of i)typeof n=="string"&&n.length>0&&e.add(n);return e}function vS(t){try{localStorage.setItem(Vg,JSON.stringify([...t]))}catch{}}function CS(t){if(typeof t!="object"||t===null)return!1;let i=t;return typeof i.x=="number"&&typeof i.y=="number"&&Number.isFinite(i.x)&&Number.isFinite(i.y)}function wS(t){if(typeof t!="object"||t===null)return!1;let i=t;return typeof i.x=="number"&&typeof i.y=="number"&&typeof i.scale=="number"&&Number.isFinite(i.x)&&Number.isFinite(i.y)&&Number.isFinite(i.scale)&&i.scale>0}function bS(t,i,e){let[n,o]=[i,e].sort();return`${t}:${n}::${o}`}export{Gg as GraphView};