| 4087 | `],encapsulation:2,changeDetection:0})}return i})(),PW=(()=>{class i{static \u0275fac=function(t){return new(t||i)};static \u0275mod=et({type:i});static \u0275inj=At({imports:[Di]})}return i})();var m5=class i{themeService=w(og);get currentTheme(){return this.themeService.currentTheme()}get themeIcon(){return this.currentTheme==="light"?"dark_mode":"light_mode"}get themeTooltip(){return this.currentTheme==="light"?"Switch to dark mode":"Switch to light mode"}toggleTheme(){this.themeService.toggleTheme()}static \u0275fac=function(A){return new(A||i)};static \u0275cmp=vA({type:i,selectors:[["app-theme-toggle"]],decls:3,vars:2,consts:[["mat-icon-button","","aria-label","Toggle theme",1,"theme-toggle-button",3,"click","matTooltip"]],template:function(A,t){A&1&&(I(0,"button",0),U("click",function(){return t.toggleTheme()}),I(1,"mat-icon"),D(2),h()()),A&2&&(H("matTooltip",t.themeTooltip),Q(2),nA(t.themeIcon))},dependencies:[Un,zt,qi,yi,Ha,rn],styles:[".theme-toggle-button[_ngcontent-%COMP%]{color:var(--side-panel-mat-icon-color);width:24px;height:24px;padding:0}.theme-toggle-button[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px}.theme-toggle-button[_ngcontent-%COMP%]:hover{opacity:.8}.builder-mode-action-button[_nghost-%COMP%] .theme-toggle-button[_ngcontent-%COMP%]{color:var(--builder-text-tertiary-color);border-radius:50%;transition:all .2s ease;margin-right:0!important}.builder-mode-action-button[_nghost-%COMP%] .theme-toggle-button[_ngcontent-%COMP%]:hover{color:var(--builder-text-primary-color);opacity:1}.builder-mode-action-button[_nghost-%COMP%] .theme-toggle-button[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px}"]})};var jW=(i,e)=>e.name;function CuA(i,e){if(i&1&&D(0),i&2){let A=p().$implicit;Ee(" AgentTool: ",A.name," ")}}function duA(i,e){if(i&1&&D(0),i&2){let A=p().$implicit;Ee(" ",A.name," ")}}function IuA(i,e){i&1&&(I(0,"mat-icon",28),D(1,"chevron_right"),h())}function BuA(i,e){if(i&1){let A=aA();I(0,"div",27),U("click",function(){let n=L(A).$implicit,o=p(2);return G(o.selectAgentFromBreadcrumb(n))}),T(1,CuA,1,1)(2,duA,1,1),h(),T(3,IuA,2,0,"mat-icon",28)}if(i&2){let A=e.$implicit,t=e.$index,n=p(2);_A("current-agent",(n.currentSelectedAgent==null?null:n.currentSelectedAgent.name)===A.name),Q(),O(t===0&&n.isInAgentToolContext()?1:2),Q(2),O(t<n.hierarchyPath.length-1?3:-1)}}function huA(i,e){if(i&1&&(I(0,"div",13),ke(1,BuA,4,4,null,null,jW),h()),i&2){let A=p();Q(),_e(A.hierarchyPath)}}function EuA(i,e){if(i&1&&(I(0,"mat-option",34),D(1),h()),i&2){let A=e.$implicit;H("value",A),Q(),nA(A)}}function QuA(i,e){if(i&1&&(I(0,"mat-option",34),D(1),h()),i&2){let A=e.$implicit;H("value",A),Q(),nA(A)}}function uuA(i,e){if(i&1){let A=aA();I(0,"mat-form-field")(1,"mat-label"),D(2,"Model"),h(),I(3,"mat-select",36),Ni("ngModelChange",function(n){L(A);let o=p(2);return wi(o.agentConfig.model,n)||(o.agentConfig.model=n),G(n)}),ke(4,QuA,2,2,"mat-option",34,ni),h()()}if(i&2){let A=p(2);Q(3),Ri("ngModel",A.agentConfig.model),Q(),_e(A.models)}}function puA(i,e){if(i&1){let A=aA();I(0,"mat-form-field")(1,"mat-label"),D(2,"Instructions"),h(),I(3,"textarea",37),Ni("ngModelChange",function(n){L(A);let o=p(2);return wi(o.agentConfig.instruction,n)||(o.agentConfig.instruction=n),G(n)}),h()(),I(4,"mat-form-field")(5,"mat-label"),D(6,"Description (optional)"),h(),I(7,"textarea",38),Ni("ngModelChange",function(n){L(A);let o=p(2);return wi(o.agentConfig.description,n)||(o.agentConfig.description=n),G(n)}),h()()}if(i&2){let A=p(2);Q(3),Ri("ngModel",A.agentConfig.instruction),Q(4),Ri("ngModel",A.agentConfig.description)}}function fuA(i,e){if(i&1){let A=aA();I(0,"mat-form-field")(1,"mat-label"),D(2,"Max Iteration"),h(),I(3,"input",39),Ni("ngModelChange",function(n){L(A);let o=p(2);return wi(o.agentConfig.max_iterations,n)||(o.agentConfig.max_iterations=n),G(n)}),h()()}if(i&2){let A=p(2);Q(3),Ri("ngModel",A.agentConfig.max_iterations)}}function muA(i,e){if(i&1){let A=aA();I(0,"mat-checkbox",36),Ni("ngModelChange",function(n){L(A);let o=p(2);return wi(o.agentConfig.skip_summarization,n)||(o.agentConfig.skip_summarization=n),G(n)}),D(1,"Skip summarization"),h()}if(i&2){let A=p(2);Ri("ngModel",A.agentConfig.skip_summarization)}}function wuA(i,e){if(i&1){let A=aA();I(0,"div",17)(1,"div",29)(2,"mat-form-field",30)(3,"mat-label"),D(4,"Agent Name"),h(),I(5,"input",31),Ni("ngModelChange",function(n){L(A);let o=p();return wi(o.agentConfig.name,n)||(o.agentConfig.name=n),G(n)}),h()(),I(6,"mat-form-field",32)(7,"mat-label"),D(8,"Agent Type"),h(),I(9,"mat-select",33),Ni("ngModelChange",function(n){L(A);let o=p();return wi(o.agentConfig.agent_class,n)||(o.agentConfig.agent_class=n),G(n)}),ke(10,EuA,2,2,"mat-option",34,ni),h()()(),T(12,uuA,6,1,"mat-form-field"),T(13,puA,8,2),T(14,fuA,4,1,"mat-form-field"),T(15,muA,2,1,"mat-checkbox",35),h()}if(i&2){let A=p();Q(5),Ri("ngModel",A.agentConfig.name),H("disabled",A.agentConfig.isRoot),Q(4),Ri("ngModel",A.agentConfig.agent_class),Q(),_e(A.agentTypes),Q(2),O(A.agentConfig.agent_class==="LlmAgent"?12:-1),Q(),O(A.agentConfig.agent_class==="LlmAgent"?13:-1),Q(),O(A.agentConfig.agent_class==="LoopAgent"?14:-1),Q(),O(A.agentConfig.isAgentTool?15:-1)}}function yuA(i,e){if(i&1){let A=aA();I(0,"mat-chip",43),U("click",function(){let n=L(A).$implicit,o=p(4);return G(o.selectTool(n))}),I(1,"mat-icon",44),D(2),h(),I(3,"span",45),D(4),h(),I(5,"button",46),U("click",function(n){let o=L(A).$implicit,a=p(4);return a.deleteTool(a.agentConfig.name,o),G(n.stopPropagation())}),I(6,"mat-icon"),D(7,"cancel"),h()()()}if(i&2){let A=e.$implicit,t=p(4);Q(2),nA(t.getToolIcon(A)),Q(2),nA(A.name)}}function DuA(i,e){if(i&1&&(I(0,"div",20)(1,"mat-chip-set",41),ke(2,yuA,8,2,"mat-chip",42,ni),h()()),i&2){let A=p(),t=p(2);Q(2),_e(A.get(t.agentConfig.name))}}function vuA(i,e){if(i&1&&T(0,DuA,4,0,"div",20),i&2){let A=e,t=p(2);O(t.agentConfig&&A.get(t.agentConfig.name)&&A.get(t.agentConfig.name).length>0?0:-1)}}function buA(i,e){if(i&1){let A=aA();I(0,"div",15)(1,"div",16)(2,"div"),D(3," Tools "),h(),I(4,"div")(5,"button",40,2)(7,"mat-icon"),D(8,"add"),h()(),I(9,"mat-menu",null,3)(11,"button",23),U("click",function(){L(A);let n=p();return G(n.addTool("Function tool"))}),I(12,"span"),D(13,"Function tool"),h()(),I(14,"button",23),U("click",function(){L(A);let n=p();return G(n.addTool("Built-in tool"))}),I(15,"span"),D(16,"Built-in tool"),h()(),I(17,"button",23),U("click",function(){L(A);let n=p();return G(n.createAgentTool())}),I(18,"span"),D(19,"Agent tool"),h()()()()(),T(20,vuA,1,1),mt(21,"async"),h()}if(i&2){let A,t=Bi(10),n=p();Q(5),H("matMenuTriggerFor",t),Q(6),H("matTooltip",n.toolMenuTooltips("Function tool")),Q(3),H("matTooltip",n.toolMenuTooltips("Built-in tool")),Q(3),H("matTooltip",n.toolMenuTooltips("Agent tool")),Q(3),O((A=Ft(21,5,n.toolsMap$))?20:-1,A)}}function MuA(i,e){if(i&1){let A=aA();I(0,"mat-chip",43),U("click",function(){let n=L(A).$implicit,o=p(2);return G(o.selectAgent(n))}),I(1,"mat-icon",44),D(2),h(),I(3,"span",45),D(4),h(),I(5,"button",48),U("click",function(n){let o=L(A).$implicit;return p(2).deleteSubAgent(o.name),G(n.stopPropagation())}),I(6,"mat-icon"),D(7,"cancel"),h()()()}if(i&2){let A=e.$implicit,t=p(2);Q(2),nA(t.getAgentIcon(A.agent_class)),Q(2),nA(A.name)}}function SuA(i,e){if(i&1&&(I(0,"div",20)(1,"mat-chip-set",47),ke(2,MuA,8,2,"mat-chip",42,jW),h()()),i&2){let A=p();Q(2),_e(A.agentConfig.sub_agents)}}function kuA(i,e){if(i&1){let A=aA();lA(0,"mat-divider"),I(1,"div",22),D(2,"Model (LLM) Interaction"),h(),I(3,"button",23),U("click",function(){L(A);let n=p();return G(n.addCallback("before_model"))}),I(4,"span"),D(5,"Before Model"),h()(),I(6,"button",23),U("click",function(){L(A);let n=p();return G(n.addCallback("after_model"))}),I(7,"span"),D(8,"After Model"),h()(),lA(9,"mat-divider"),I(10,"div",22),D(11,"Tool Execution"),h(),I(12,"button",23),U("click",function(){L(A);let n=p();return G(n.addCallback("before_tool"))}),I(13,"span"),D(14,"Before Tool"),h()(),I(15,"button",23),U("click",function(){L(A);let n=p();return G(n.addCallback("after_tool"))}),I(16,"span"),D(17,"After Tool"),h()()}if(i&2){let A=p();Q(3),H("matTooltip",A.callbackMenuTooltips("before_model")),Q(3),H("matTooltip",A.callbackMenuTooltips("after_model")),Q(6),H("matTooltip",A.callbackMenuTooltips("before_tool")),Q(3),H("matTooltip",A.callbackMenuTooltips("after_tool"))}}function _uA(i,e){if(i&1){let A=aA();I(0,"div",52),U("click",function(){let n=L(A).$implicit,o=p(3);return G(o.editCallback(n))}),I(1,"mat-chip",53)(2,"span",54)(3,"span",55),D(4),h(),I(5,"span",56),D(6),h()()(),I(7,"button",57),U("click",function(n){let o=L(A).$implicit,a=p(3);return a.deleteCallback(a.agentConfig.name,o),G(n.stopPropagation())}),I(8,"mat-icon"),D(9,"remove"),h()()()}if(i&2){let A=e.$implicit;Q(4),nA(A.type),Q(2),nA(A.name)}}function xuA(i,e){if(i&1&&(I(0,"div",49)(1,"mat-chip-set",50),ke(2,_uA,10,2,"div",51,ni),h()()),i&2){let A=p(),t=p();Q(2),_e(A.get(t.agentConfig.name))}}function RuA(i,e){if(i&1&&T(0,xuA,4,0,"div",49),i&2){let A=e,t=p();O(t.agentConfig&&A.get(t.agentConfig.name)&&A.get(t.agentConfig.name).length>0?0:-1)}}var w5=class i{CALLBACKS_TAB_INDEX=3;jsonEditorComponent;appNameInput="";exitBuilderMode=new FA;closePanel=new FA;featureFlagService=w(Nr);isAlwaysOnSidePanelEnabledObs=this.featureFlagService.isAlwaysOnSidePanelEnabled();toolArgsString=mA("");editingToolArgs=mA(!1);editingTool=null;selectedTabIndex=0;agentConfig={isRoot:!1,name:"",agent_class:"",model:"",instruction:"",sub_agents:[],tools:[],callbacks:[]};hierarchyPath=[];currentSelectedAgent=void 0;isRootAgentEditable=!0;models=["gemini-2.5-flash","gemini-2.5-pro"];agentTypes=["LlmAgent","LoopAgent","ParallelAgent","SequentialAgent"];agentBuilderService=w($c);dialog=w(Xa);agentService=w(el);snackBar=w(Xc);router=w(Is);cdr=w(Mt);selectedTool=void 0;toolAgentName="";toolTypes=["Custom tool","Function tool","Built-in tool","Agent Tool"];editingCallback=null;selectedCallback=void 0;callbackTypes=["before_agent","before_model","before_tool","after_tool","after_model","after_agent"];builtInTools=["EnterpriseWebSearchTool","exit_loop","FilesRetrieval","get_user_choice","google_search","load_artifacts","load_memory","LongRunningFunctionTool","preload_memory","url_context","VertexAiRagRetrieval","VertexAiSearchTool"];builtInToolArgs=new Map([["EnterpriseWebSearchTool",[]],["exit_loop",[]],["FilesRetrieval",["name","description","input_dir"]],["get_user_choice",[]],["google_search",[]],["load_artifacts",[]],["load_memory",[]],["LongRunningFunctionTool",["func"]],["preload_memory",[]],["url_context",[]],["VertexAiRagRetrieval",["name","description","rag_corpora","rag_resources","similarity_top_k","vector_distance_threshold"]],["VertexAiSearchTool",["data_store_id","data_store_specs","search_engine_id","filter","max_results"]]]);header="Select an agent or tool to edit";toolsMap$;callbacksMap$;getJsonStringForEditor(e){if(!e)return"{}";let A=P({},e);return delete A.skip_summarization,JSON.stringify(A,null,2)}constructor(){this.toolsMap$=this.agentBuilderService.getAgentToolsMap(),this.callbacksMap$=this.agentBuilderService.getAgentCallbacksMap(),this.agentBuilderService.getSelectedNode().subscribe(e=>{this.agentConfig=e,this.currentSelectedAgent=e,e&&(this.editingTool=null,this.editingCallback=null,this.header="Agent configuration",this.updateBreadcrumb(e)),this.cdr.markForCheck()}),this.agentBuilderService.getSelectedTool().subscribe(e=>{this.selectedTool=e,!(e&&e.toolType==="Agent Tool")&&(e?(this.editingTool=e,this.editingToolArgs.set(!1),setTimeout(()=>{let A=e.toolType=="Function tool"?"Function tool":e.name;if(e.toolType=="Function tool"&&!e.name&&(e.name="Function tool"),e.toolType==="Custom tool")e.args||(e.args={}),this.toolArgsString.set(this.getJsonStringForEditor(e.args)),this.editingToolArgs.set(!0);else{let t=this.builtInToolArgs.get(A);if(t){e.args||(e.args={});for(let n of t)e.args&&(e.args[n]="")}this.toolArgsString.set(this.getJsonStringForEditor(e.args)),e.args&&this.getObjectKeys(e.args).length>0&&this.editingToolArgs.set(!0)}this.cdr.markForCheck()}),this.selectedTabIndex=2):this.editingTool=null,this.cdr.markForCheck())}),this.agentBuilderService.getSelectedCallback().subscribe(e=>{this.selectedCallback=e,e?(this.selectCallback(e),this.selectedTabIndex=this.CALLBACKS_TAB_INDEX):this.editingCallback=null,this.cdr.markForCheck()}),this.agentBuilderService.getAgentCallbacks().subscribe(e=>{this.agentConfig&&e&&this.agentConfig.name===e.agentName&&(this.agentConfig=$A(P({},this.agentConfig),{callbacks:e.callbacks}),this.cdr.markForCheck())}),this.agentBuilderService.getSideTabChangeRequest().subscribe(e=>{e==="tools"?this.selectedTabIndex=2:e==="config"&&(this.selectedTabIndex=0)})}getObjectKeys(e){return e?Object.keys(e).filter(A=>A!=="skip_summarization"):[]}getCallbacksByType(){let e=new Map;return this.callbackTypes.forEach(A=>{e.set(A,[])}),this.agentConfig?.callbacks&&this.agentConfig.callbacks.forEach(A=>{let t=e.get(A.type);t&&t.push(A)}),e}updateBreadcrumb(e){this.hierarchyPath=this.buildHierarchyPath(e)}buildHierarchyPath(e){let A=[],t=this.findContextualRoot(e);return t?e.name===t.name?[t]:this.findPathToAgent(t,e,[t])||[e]:[e]}isInAgentToolContext(){return!this.hierarchyPath||this.hierarchyPath.length===0?!1:this.hierarchyPath[0]?.isAgentTool===!0}findContextualRoot(e){if(e.isAgentTool)return e;let A=this.agentBuilderService.getNodes();for(let n of A)if(n.isAgentTool&&this.findPathToAgent(n,e,[n]))return n;let t=this.agentBuilderService.getRootNode();if(t&&this.findPathToAgent(t,e,[t]))return t;if(e.isRoot)return e;for(let n of A)if(n.isRoot&&this.findPathToAgent(n,e,[n]))return n;return t}findPathToAgent(e,A,t){if(e.name===A.name)return t;for(let n of e.sub_agents){let o=[...t,n],a=this.findPathToAgent(n,A,o);if(a)return a}return null}selectAgentFromBreadcrumb(e){this.agentBuilderService.setSelectedNode(e),this.selectedTabIndex=0}selectAgent(e){this.agentBuilderService.setSelectedNode(e),this.selectedTabIndex=0}selectTool(e){if(e.toolType==="Agent Tool"){let A=e.name;this.agentBuilderService.requestNewTab(A);return}if(e.toolType==="Function tool"||e.toolType==="Built-in tool"){this.editTool(e);return}this.agentBuilderService.setSelectedTool(e)}editTool(e){if(!this.agentConfig)return;let A;e.toolType==="Built-in tool"?A=this.dialog.open(sI,{width:"700px",maxWidth:"90vw",data:{toolName:e.name,isEditMode:!0,toolArgs:e.args}}):A=this.dialog.open(Q2,{width:"500px",data:{toolType:e.toolType,toolName:e.name,isEditMode:!0}}),A.afterClosed().subscribe(t=>{if(t&&t.isEditMode){let n=this.agentConfig.tools?.findIndex(o=>o.name===e.name);n!==void 0&&n!==-1&&this.agentConfig.tools&&(this.agentConfig.tools[n].name=t.name,t.args&&(this.agentConfig.tools[n].args=t.args),this.agentBuilderService.setAgentTools(this.agentConfig.name,this.agentConfig.tools))}})}addTool(e){if(this.agentConfig){let A;e==="Built-in tool"?A=this.dialog.open(sI,{width:"700px",maxWidth:"90vw",data:{}}):A=this.dialog.open(Q2,{width:"500px",data:{toolType:e}}),A.afterClosed().subscribe(t=>{if(t){let n={toolType:t.toolType,name:t.name};this.agentBuilderService.addTool(this.agentConfig.name,n),this.agentBuilderService.setSelectedTool(n)}})}}addCallback(e){if(this.agentConfig){let A=this.agentConfig?.callbacks?.map(n=>n.name)??[];this.dialog.open(Mu,{width:"500px",data:{callbackType:e,existingCallbackNames:A}}).afterClosed().subscribe(n=>{if(n){let o={name:n.name,type:n.type};this.agentBuilderService.addCallback(this.agentConfig.name,o)}})}}editCallback(e){if(!this.agentConfig)return;let A=this.agentConfig.callbacks?.map(n=>n.name)??[];this.dialog.open(Mu,{width:"500px",data:{callbackType:e.type,existingCallbackNames:A,isEditMode:!0,callback:e,availableCallbackTypes:this.callbackTypes}}).afterClosed().subscribe(n=>{if(n&&n.isEditMode){let o=this.agentBuilderService.updateCallback(this.agentConfig.name,e.name,$A(P({},e),{name:n.name,type:n.type}));o.success?this.cdr.markForCheck():console.error("Failed to update callback:",o.error)}})}deleteCallback(e,A){this.dialog.open(vc,{data:{title:"Delete Callback",message:`Are you sure you want to delete ${A.name}?`,confirmButtonText:"Delete"}}).afterClosed().subscribe(n=>{if(n==="confirm"){let o=this.agentBuilderService.deleteCallback(e,A);o.success?this.cdr.markForCheck():console.error("Failed to delete callback:",o.error)}})}addSubAgent(e){e&&this.agentBuilderService.setAddSubAgentSubject(e)}deleteSubAgent(e){this.agentBuilderService.setDeleteSubAgentSubject(e)}deleteTool(e,A){let t=A.toolType==="Agent Tool",n=t&&A.toolAgentName||A.name;this.dialog.open(vc,{data:{title:t?"Delete Agent Tool":"Delete Tool",message:t?`Are you sure you want to delete the agent tool "${n}"? This will also delete the corresponding board.`:`Are you sure you want to delete ${n}?`,confirmButtonText:"Delete"}}).afterClosed().subscribe(a=>{if(a==="confirm")if(A.toolType==="Agent Tool"){let r=A.toolAgentName||A.name;this.deleteAgentToolAndBoard(e,A,r)}else this.agentBuilderService.deleteTool(e,A)})}deleteAgentToolAndBoard(e,A,t){this.agentBuilderService.deleteTool(e,A),this.agentBuilderService.requestTabDeletion(t)}backToToolList(){this.editingTool=null,this.agentBuilderService.setSelectedTool(void 0)}editToolArgs(){this.editingToolArgs.set(!0)}cancelEditToolArgs(e){this.editingToolArgs.set(!1),this.toolArgsString.set(this.getJsonStringForEditor(e?.args))}saveToolArgs(e){if(this.jsonEditorComponent&&e)try{let A=JSON.parse(this.jsonEditorComponent.getJsonString()),t=e.args?e.args.skip_summarization:!1;e.args=A,e.args.skip_summarization=t,this.toolArgsString.set(JSON.stringify(e.args,null,2)),this.editingToolArgs.set(!1)}catch(A){console.error("Error parsing tool arguments JSON",A)}}onToolTypeSelectionChange(e){e?.toolType==="Built-in tool"?(e.name="google_search",this.onBuiltInToolSelectionChange(e)):e?.toolType==="Custom tool"?(e.args={},this.toolArgsString.set(this.getJsonStringForEditor(e.args)),this.editingToolArgs.set(!0)):e&&(e.name="",e.args={skip_summarization:!1},this.toolArgsString.set("{}"),this.editingToolArgs.set(!1))}onBuiltInToolSelectionChange(e){e&&(this.editingToolArgs.set(!1),setTimeout(()=>{e.args={skip_summarization:!1};let A=this.builtInToolArgs.get(e.name);if(A)for(let t of A)e.args&&(e.args[t]="");this.toolArgsString.set(this.getJsonStringForEditor(e.args)),e.args&&this.getObjectKeys(e.args).length>0&&this.editingToolArgs.set(!0),this.cdr.markForCheck()}))}selectCallback(e){this.editingCallback=e}backToCallbackList(){this.editingCallback=null}onCallbackTypeChange(e){}createAgentTool(){this.dialog.open(vc,{width:"750px",height:"450px",data:{title:"Create Agent Tool",message:"Please enter a name for the agent tool:",confirmButtonText:"Create",showInput:!0,inputLabel:"Agent Tool Name",inputPlaceholder:"Enter agent tool name",showToolInfo:!0,toolType:"Agent tool"}}).afterClosed().subscribe(A=>{if(A&&typeof A=="string"){let t=this.agentConfig?.name||"root_agent";this.agentBuilderService.requestNewTab(A,t)}})}saveChanges(){if(!this.agentBuilderService.getRootNode()){this.snackBar.open("Please create an agent first.","OK");return}this.appNameInput?this.saveAgent(this.appNameInput):this.agentService.getApp().subscribe(A=>{A?this.saveAgent(A):this.snackBar.open("No agent selected. Please select an agent first.","OK")})}cancelChanges(){this.agentService.agentChangeCancel(this.appNameInput).subscribe(e=>{}),this.exitBuilderMode.emit()}saveAgent(e){let A=this.agentBuilderService.getRootNode();if(!A){this.snackBar.open("Please create an agent first.","OK");return}let t=new FormData,n=this.agentBuilderService.getCurrentAgentToolBoards();a0.generateYamlFile(A,t,e,n),this.agentService.agentBuildTmp(e,t).subscribe(o=>{o&&this.agentService.agentBuild(e,t).subscribe(a=>{a?this.router.navigate(["/"],{queryParams:{app:e}}).then(()=>{window.location.reload()}):this.snackBar.open("Something went wrong, please try again","OK")})})}getToolIcon(e){return UB(e.name,e.toolType)}getAgentIcon(e){switch(e){case"SequentialAgent":return"more_horiz";case"LoopAgent":return"sync";case"ParallelAgent":return"density_medium";default:return"psychology"}}addSubAgentWithType(e){if(!this.agentConfig?.name)return;let A=this.agentConfig.agent_class!=="LlmAgent";this.agentBuilderService.setAddSubAgentSubject(this.agentConfig.name,e,A)}callbackMenuTooltips(e){return nc.getCallbackMenuTooltips(e)}toolMenuTooltips(e){return nc.getToolMenuTooltips(e)}static \u0275fac=function(A){return new(A||i)};static \u0275cmp=vA({type:i,selectors:[["app-builder-tabs"]],viewQuery:function(A,t){if(A&1&&Wt(Dc,5),A&2){let n;se(n=le())&&(t.jsonEditorComponent=n.first)}},inputs:{appNameInput:"appNameInput"},outputs:{exitBuilderMode:"exitBuilderMode",closePanel:"closePanel"},decls:77,vars:12,consts:[["subAgentMenu","matMenu"],["callbacksMenu","matMenu"],["agentMenuTrigger","matMenuTrigger"],["toolsMenu","matMenu"],[2,"margin-top","20px","margin-left","20px","display","flex"],[2,"width","100%"],[1,"drawer-header"],[1,"drawer-logo"],["src","assets/ADK-512-color.svg","width","32px","height","32px"],[2,"display","flex","align-items","center","gap","8px","margin-right","15px"],["matTooltip","Collapse panel",1,"material-symbols-outlined",2,"color","#c4c7c5","cursor","pointer",3,"click"],[1,"builder-tabs-container"],[1,"builder-tab-content"],[1,"agent-breadcrumb-container"],[1,"content-wrapper"],[1,"builder-panel-wrapper"],[1,"panel-title"],[1,"config-form"],["mat-icon-button","","type","button","aria-label","Add sub agent",1,"panel-action-button",3,"matMenuTriggerFor"],["mat-menu-item","",3,"click"],[1,"tools-chips-container"],["mat-icon-button","","type","button","aria-label","Add callback",1,"panel-action-button",3,"matMenuTriggerFor"],[1,"menu-header"],["mat-menu-item","","matTooltipPosition","right",3,"click","matTooltip"],[1,"action-buttons"],["mat-raised-button","","color","secondary",1,"save-button",3,"click"],["mat-button","",1,"cancel-button",3,"click"],[1,"breadcrumb-chip",3,"click"],[1,"breadcrumb-arrow"],[1,"form-row"],[1,"agent-name-field"],["matInput","",3,"ngModelChange","ngModel","disabled"],[1,"agent-type-field"],["disabled","",3,"ngModelChange","ngModel"],[3,"value"],[3,"ngModel"],[3,"ngModelChange","ngModel"],["matInput","","rows","5",3,"ngModelChange","ngModel"],["matInput","","rows","3",3,"ngModelChange","ngModel"],["matInput","","type","number","min","1",3,"ngModelChange","ngModel"],["mat-icon-button","","type","button","aria-label","Add tool",1,"panel-action-button",3,"matMenuTriggerFor"],["aria-label","Tools"],[1,"tool-chip"],[1,"tool-chip",3,"click"],["matChipAvatar","",1,"tool-icon"],[1,"tool-chip-name"],["matChipRemove","","aria-label","Remove tool",3,"click"],["aria-label","Sub Agents"],["matChipRemove","","aria-label","Remove sub agent",3,"click"],[1,"tools-chips-container","callbacks-list"],["aria-label","Callbacks"],[1,"callback-row"],[1,"callback-row",3,"click"],[1,"callback-chip"],[1,"chip-content"],[1,"chip-type"],[1,"chip-name"],["mat-icon-button","","aria-label","Remove callback",1,"callback-remove",3,"click"]],template:function(A,t){if(A&1&&(I(0,"div",4)(1,"div",5)(2,"div",6)(3,"div",7),lA(4,"img",8),D(5," Agent Development Kit "),h(),I(6,"div",9),lA(7,"app-theme-toggle"),I(8,"span",10),U("click",function(){return t.closePanel.emit()}),D(9,"left_panel_close"),h()()()()(),I(10,"div",11)(11,"div",12),T(12,huA,3,0,"div",13),I(13,"div",14)(14,"div",15)(15,"div",16),D(16," Configuration "),h(),I(17,"div"),T(18,wuA,16,7,"div",17),h()(),T(19,buA,22,7,"div",15),I(20,"div",15)(21,"div",16)(22,"div"),D(23," Sub Agents "),h(),I(24,"div")(25,"button",18)(26,"mat-icon"),D(27,"add"),h()(),I(28,"mat-menu",null,0)(30,"button",19),U("click",function(){return t.addSubAgentWithType("LlmAgent")}),I(31,"mat-icon"),D(32,"psychology"),h(),I(33,"span"),D(34,"LLM Agent"),h()(),I(35,"button",19),U("click",function(){return t.addSubAgentWithType("SequentialAgent")}),I(36,"mat-icon"),D(37,"more_horiz"),h(),I(38,"span"),D(39,"Sequential Agent"),h()(),I(40,"button",19),U("click",function(){return t.addSubAgentWithType("LoopAgent")}),I(41,"mat-icon"),D(42,"sync"),h(),I(43,"span"),D(44,"Loop Agent"),h()(),I(45,"button",19),U("click",function(){return t.addSubAgentWithType("ParallelAgent")}),I(46,"mat-icon"),D(47,"density_medium"),h(),I(48,"span"),D(49,"Parallel Agent"),h()()()()(),T(50,SuA,4,0,"div",20),h(),I(51,"div",15)(52,"div",16)(53,"div"),D(54," Callbacks "),h(),I(55,"div")(56,"button",21)(57,"mat-icon"),D(58,"add"),h()(),I(59,"mat-menu",null,1)(61,"div",22),D(62,"Agent Lifecycle"),h(),I(63,"button",23),U("click",function(){return t.addCallback("before_agent")}),I(64,"span"),D(65,"Before Agent"),h()(),I(66,"button",23),U("click",function(){return t.addCallback("after_agent")}),I(67,"span"),D(68,"After Agent"),h()(),T(69,kuA,18,4),h()()(),T(70,RuA,1,1),mt(71,"async"),h()(),I(72,"div",24)(73,"button",25),U("click",function(){return t.saveChanges()}),D(74," Save "),h(),I(75,"button",26),U("click",function(){return t.cancelChanges()}),D(76," Cancel "),h()()()()),A&2){let n,o=Bi(29),a=Bi(60);Q(12),O(t.hierarchyPath.length>0?12:-1),Q(6),O(t.agentConfig?18:-1),Q(),O((t.agentConfig==null?null:t.agentConfig.agent_class)==="LlmAgent"?19:-1),Q(6),H("matMenuTriggerFor",o),Q(25),O(t.agentConfig&&t.agentConfig.sub_agents&&t.agentConfig.sub_agents.length>0?50:-1),Q(6),H("matMenuTriggerFor",a),Q(7),H("matTooltip",t.callbackMenuTooltips("before_agent")),Q(3),H("matTooltip",t.callbackMenuTooltips("after_agent")),Q(3),O((t.agentConfig==null?null:t.agentConfig.agent_class)==="LlmAgent"?69:-1),Q(),O((n=Ft(71,10,t.callbacksMap$))?70:-1,n)}},dependencies:[li,fn,Gn,gQ,Kn,dv,Ho,ki,ic,fO,Zo,zt,ka,yi,xs,Vr,ig,rn,hs,tg,Gs,f5,Qp,JW,YW,Gx,PW,zW,m5,gs],styles:[".builder-tabs-container[_ngcontent-%COMP%]{width:100%;margin-top:40px;height:calc(95vh - 20px);display:flex;flex-direction:column}.agent-breadcrumb-container[_ngcontent-%COMP%]{padding:2px 20px 8px;display:flex;align-items:center;gap:6px;flex-wrap:wrap;border-bottom:1px solid var(--builder-border-color)}.breadcrumb-chip[_ngcontent-%COMP%]{color:var(--builder-text-muted-color);font-family:Google Sans;font-size:16px;font-weight:500;border:none;cursor:pointer;transition:all .2s ease;padding:4px 8px;border-radius:4px;display:inline-block;-webkit-user-select:none;user-select:none}.breadcrumb-chip[_ngcontent-%COMP%]:hover{color:var(--builder-text-link-color)}.breadcrumb-chip.current-agent[_ngcontent-%COMP%]{color:var(--builder-text-primary-color);font-weight:500}.breadcrumb-arrow[_ngcontent-%COMP%]{color:var(--builder-breadcrumb-separator-color);font-size:16px;width:16px;height:16px}.builder-tab-content[_ngcontent-%COMP%]{color:var(--builder-text-secondary-color);display:flex;flex-direction:column;flex:1;overflow:hidden}.builder-tab-content[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:8px 0;font-size:14px;line-height:1.5}.components-section[_ngcontent-%COMP%]{margin-bottom:32px}.components-section[_ngcontent-%COMP%] h4[_ngcontent-%COMP%]{color:var(--builder-text-primary-color);font-size:14px;font-weight:500;margin:0 0 16px;text-transform:uppercase;letter-spacing:.5px}.config-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:16px;margin-top:20px}.config-form[_ngcontent-%COMP%] .form-row[_ngcontent-%COMP%]{display:flex;gap:16px;align-items:flex-start}.config-form[_ngcontent-%COMP%] .form-row[_ngcontent-%COMP%] .agent-name-field[_ngcontent-%COMP%]{flex:1}.config-form[_ngcontent-%COMP%] .form-row[_ngcontent-%COMP%] .agent-type-field[_ngcontent-%COMP%]{width:32%}.config-form[_ngcontent-%COMP%] mat-form-field[_ngcontent-%COMP%]{width:100%}.config-form[_ngcontent-%COMP%] mat-checkbox[_ngcontent-%COMP%]{margin-bottom:8px}.config-form[_ngcontent-%COMP%] .tool-code-section[_ngcontent-%COMP%]{margin-top:16px}.config-form[_ngcontent-%COMP%] .tool-code-section[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:0 0 8px;color:var(--builder-text-secondary-color);font-size:14px;font-weight:500}.config-form[_ngcontent-%COMP%] .tool-args-header[_ngcontent-%COMP%]{color:var(--builder-text-primary-color);font-size:14px;font-weight:500;letter-spacing:.5px;text-transform:uppercase}.json-editor-wrapper[_ngcontent-%COMP%]{height:300px;max-height:300px}.tab-content-container[_ngcontent-%COMP%]{margin-top:20px;overflow-y:auto}.agent-list-row[_ngcontent-%COMP%]{display:flex;margin-top:10px}.sub-agent-list-row[_ngcontent-%COMP%]{display:flex;margin-top:10px;margin-left:16px}.tree-view[_ngcontent-%COMP%] expand-button[_ngcontent-%COMP%]{border:0}.node-item[_ngcontent-%COMP%]{display:flex;align-items:center}.node-icon[_ngcontent-%COMP%]{margin-right:14px}.node-name[_ngcontent-%COMP%]{margin-top:2px;display:flex;align-items:center}.no-tools-message[_ngcontent-%COMP%]{display:block;color:var(--builder-text-secondary-color);font-size:16px;margin-top:16px;margin-bottom:16px;text-align:center}.tools-list[_ngcontent-%COMP%]{list-style:none;padding:0}.tool-name[_ngcontent-%COMP%]{cursor:pointer;padding:11px;border-radius:8px;display:flex;justify-content:space-between;align-items:center;margin-bottom:4px;color:var(--builder-text-primary-color);font-family:Google Sans Mono,monospace;font-size:14px;font-style:normal;font-weight:500;line-height:20px;letter-spacing:.25px}.tool-name[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{visibility:hidden}.tool-name[_ngcontent-%COMP%]:hover button[_ngcontent-%COMP%]{visibility:visible}.tool-list-item-name[_ngcontent-%COMP%]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;padding-right:8px}.tools-chips-container[_ngcontent-%COMP%]{margin-top:12px;padding:0 4px}.tools-chips-container.callbacks-list[_ngcontent-%COMP%]{padding-right:0;padding-left:0}.callback-row[_ngcontent-%COMP%]{display:flex;align-items:center;gap:12px;width:100%;cursor:pointer}.callback-remove[_ngcontent-%COMP%]{color:var(--builder-icon-color);cursor:pointer;width:32px;height:32px;min-width:32px;min-height:32px;display:inline-flex;align-items:center;justify-content:center;padding:0}.callback-remove[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:18px;width:18px;height:18px;line-height:1;display:flex;align-items:center;justify-content:center;transform:translateY(.5px)}.back-button[_ngcontent-%COMP%]{margin-bottom:16px}.add-tool-button[_ngcontent-%COMP%]{width:100%;border:none;border-radius:4px;margin-top:12px;cursor:pointer}.add-tool-button-detail[_ngcontent-%COMP%]{display:flex;padding:8px 16px 8px 12px;justify-content:center}.add-tool-button-text[_ngcontent-%COMP%]{padding-top:2px;color:var(--builder-add-button-text-color);font-family:Google Sans;font-size:14px;font-style:normal;font-weight:500;line-height:20px;letter-spacing:.25px}.agent-tool-section[_ngcontent-%COMP%]{margin-top:16px;padding:16px;border:1px solid var(--builder-border-color);border-radius:8px}.agent-tool-section[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{color:var(--builder-text-primary-color);font-size:16px;font-weight:500;margin:0 0 8px}.agent-tool-section[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{color:var(--builder-text-secondary-color);font-size:14px;margin:0 0 16px;line-height:1.5}.agent-tool-section[_ngcontent-%COMP%] .create-agent-tool-btn[_ngcontent-%COMP%]{color:var(--builder-button-primary-text-color);font-weight:500}.no-callbacks-message[_ngcontent-%COMP%]{color:var(--builder-text-secondary-color);font-size:16px;margin-top:16px;text-align:center}.callback-name[_ngcontent-%COMP%]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;padding-right:8px}.callback-section[_ngcontent-%COMP%]{margin-top:16px}.callback-section[_ngcontent-%COMP%] .callback-section-label[_ngcontent-%COMP%]{margin:0 0 8px;color:var(--builder-text-secondary-color);font-size:14px;font-weight:500;text-transform:none}.callback-groups-wrapper[_ngcontent-%COMP%]{margin-top:16px}.callback-group[_ngcontent-%COMP%]{margin-top:5px}.callback-list[_ngcontent-%COMP%]{padding:8px 0}.no-callbacks-in-type[_ngcontent-%COMP%]{color:var(--builder-text-secondary-color);font-size:14px;font-style:italic;padding:12px;text-align:center}.callback-item[_ngcontent-%COMP%]{cursor:pointer;padding:8px 12px;border-radius:4px;display:flex;justify-content:space-between;align-items:center;margin-bottom:4px;color:var(--builder-text-primary-color);font-family:Google Sans Mono,monospace;font-size:14px;font-style:normal;font-weight:500;line-height:20px;letter-spacing:.25px}.callback-item[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{visibility:hidden}.callback-item[_ngcontent-%COMP%]:hover button[_ngcontent-%COMP%]{visibility:visible}.add-callback-icon[_ngcontent-%COMP%]{color:var(--builder-button-primary-background-color)}mat-tab-group[_ngcontent-%COMP%]{flex:1;display:flex;flex-direction:column;overflow:hidden;padding:16px 20px 0;min-height:0}mat-tab-group[_ngcontent-%COMP%]{flex:1;padding-bottom:0;display:flex;flex-direction:column;overflow:hidden}.action-buttons[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:8px;padding:16px 20px;border-top:1px solid var(--builder-border-color);flex-shrink:0;margin-top:auto}.action-buttons[_ngcontent-%COMP%] .save-button[_ngcontent-%COMP%]{color:var(--builder-button-primary-text-color);font-weight:500}.action-buttons[_ngcontent-%COMP%] .cancel-button[_ngcontent-%COMP%]{color:var(--builder-button-secondary-text-color);border:1px solid var(--builder-button-secondary-border-color)}.action-buttons[_ngcontent-%COMP%] .cancel-button[_ngcontent-%COMP%]:hover{color:var(--builder-button-secondary-hover-text-color)}.builder-panel-wrapper[_ngcontent-%COMP%]{border-bottom:1px solid var(--builder-border-color);padding:12px 24px}.panel-title[_ngcontent-%COMP%]{color:var(--builder-text-tertiary-color);font-family:Google Sans;font-size:16px;font-style:normal;font-weight:500;line-height:24px;display:flex;justify-content:space-between}.panel-title[_ngcontent-%COMP%] .panel-action-button[_ngcontent-%COMP%]{color:var(--builder-icon-color);width:32px;height:32px;min-width:32px;min-height:32px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;padding:0}.panel-title[_ngcontent-%COMP%] .panel-action-button[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:18px;width:18px;height:18px;line-height:1;display:flex;align-items:center;justify-content:center}.content-wrapper[_ngcontent-%COMP%]{flex:1;overflow-y:auto}.drawer-logo[_ngcontent-%COMP%]{margin-left:9px;display:flex;align-items:center}.drawer-logo[_ngcontent-%COMP%] img[_ngcontent-%COMP%]{margin-right:9px}.drawer-logo[_ngcontent-%COMP%]{font-size:16px;font-style:normal;font-weight:500;line-height:24px;letter-spacing:.1px}.drawer-header[_ngcontent-%COMP%]{width:100%;display:flex;justify-content:space-between;align-items:center}"],changeDetection:0})};var g1=new MA("MARKDOWN_COMPONENT");var NuA=["chatMessages"],FuA=(i,e)=>({"user-message":i,"bot-message":e}),LuA=i=>({text:i,thought:!1});function GuA(i,e){i&1&&(I(0,"div",7)(1,"mat-icon",12),D(2,"smart_toy"),h(),I(3,"h3"),D(4,"Assistant Ready"),h(),I(5,"p"),D(6,"Your builder assistant is ready to help you build agents."),h()())}function KuA(i,e){i&1&&(I(0,"div",15)(1,"span",16),D(2,"\u30FB\u30FB\u30FB"),h()())}function UuA(i,e){if(i&1&&(I(0,"div",19),D(1),h()),i&2){let A=p(3).$implicit;Q(),nA(A.text)}}function TuA(i,e){if(i&1&&dn(0,20),i&2){let A=p(3).$implicit,t=p(2);H("ngComponentOutlet",t.markdownComponent)("ngComponentOutletInputs",jl(2,LuA,A.text))}}function OuA(i,e){if(i&1&&(I(0,"div",18),D(1,"Assistant"),h(),T(2,UuA,2,1,"div",19)(3,TuA,1,4,"ng-container",20)),i&2){let A=p(2).$implicit;Q(2),O(A.isError?2:3)}}function JuA(i,e){if(i&1&&(I(0,"div",17),D(1),h()),i&2){let A=p(2).$implicit;Q(),nA(A.text)}}function YuA(i,e){if(i&1&&T(0,OuA,4,1)(1,JuA,2,1,"div",17),i&2){let A=p().$implicit;O(A.role==="bot"?0:1)}}function HuA(i,e){if(i&1&&(I(0,"div",13)(1,"mat-card",14),T(2,KuA,3,0,"div",15)(3,YuA,2,1),h()()),i&2){let A=e.$implicit;H("ngClass",L0(2,FuA,A.role==="user",A.role==="bot")),Q(2),O(A.isLoading?2:3)}}function zuA(i,e){if(i&1&&ke(0,HuA,4,5,"div",13,ni),i&2){let A=p();_e(A.messages)}}var y5=class i{isVisible=!0;appName="";closePanel=new FA;reloadCanvas=new FA;assistantAppName="__adk_agent_builder_assistant";userId="user";currentSession="";userMessage="";messages=[];shouldAutoScroll=!1;isGenerating=!1;chatMessages;markdownComponent=w(g1);agentService=w(el);sessionService=w(tl);agentBuilderService=w($c);constructor(){}ngOnInit(){this.sessionService.createSession(this.userId,this.assistantAppName).subscribe(e=>{this.currentSession=e.id;let A={appName:this.assistantAppName,userId:this.userId,sessionId:e.id,newMessage:{role:"user",parts:[{text:"hello"}]},streaming:!1,stateDelta:{root_directory:`${this.appName}/tmp/${this.appName}`}};this.messages.push({role:"bot",text:"",isLoading:!0}),this.shouldAutoScroll=!0,this.isGenerating=!0,this.agentService.runSse(A).subscribe({next:t=>re(this,null,function*(){if(t.errorCode){let n=this.messages[this.messages.length-1];n.role==="bot"&&n.isLoading&&(n.text=`Error Code: ${t.errorCode}`,n.isLoading=!1,n.isError=!0,this.shouldAutoScroll=!0),this.isGenerating=!1;return}if(t.content){let n="";for(let o of t.content.parts)o.text&&(n+=o.text);if(n){let o=this.messages[this.messages.length-1];o.role==="bot"&&o.isLoading&&(o.text=n,o.isLoading=!1,this.shouldAutoScroll=!0)}}}),error:t=>{console.error("SSE error:",t);let n=this.messages[this.messages.length-1];n.role==="bot"&&n.isLoading&&(n.text="Sorry, I encountered an error. Please try again.",n.isLoading=!1,this.shouldAutoScroll=!0),this.isGenerating=!1},complete:()=>{this.isGenerating=!1}})})}onClosePanel(){this.closePanel.emit()}sendMessage(e){if(e.trim()){this.saveAgent(this.appName),e!="____Something went wrong, please try again"&&this.messages.push({role:"user",text:e});let A=e;this.userMessage="",this.messages.push({role:"bot",text:"",isLoading:!0}),this.shouldAutoScroll=!0,this.isGenerating=!0;let t={appName:this.assistantAppName,userId:this.userId,sessionId:this.currentSession,newMessage:{role:"user",parts:[{text:A}]},streaming:!1};this.agentService.runSse(t).subscribe({next:n=>re(this,null,function*(){if(n.errorCode){let o=this.messages[this.messages.length-1];o.role==="bot"&&o.isLoading&&(o.text=`Error Code: ${n.errorCode}`,o.isLoading=!1,o.isError=!0,this.shouldAutoScroll=!0),this.isGenerating=!1;return}if(n.content){let o="";for(let a of n.content.parts)a.text&&(o+=a.text);if(o){let a=this.messages[this.messages.length-1];a.role==="bot"&&a.isLoading&&(a.text=o,a.isLoading=!1,this.shouldAutoScroll=!0,this.reloadCanvas.emit())}}}),error:n=>{console.error("SSE error:",n);let o=this.messages[this.messages.length-1];o.role==="bot"&&o.isLoading&&(o.text="Sorry, I encountered an error. Please try again.",o.isLoading=!1,this.shouldAutoScroll=!0),this.isGenerating=!1},complete:()=>{this.isGenerating=!1}})}}ngAfterViewChecked(){this.shouldAutoScroll&&(this.scrollToBottom(),this.shouldAutoScroll=!1)}scrollToBottom(){try{this.chatMessages&&setTimeout(()=>{this.chatMessages.nativeElement.scrollTop=this.chatMessages.nativeElement.scrollHeight},50)}catch(e){console.error("Error scrolling to bottom:",e)}}onKeyDown(e){if(e.key==="Enter"){if(e.shiftKey)return;this.userMessage?.trim()&&this.currentSession&&(e.preventDefault(),this.sendMessage(this.userMessage))}}saveAgent(e){let A=this.agentBuilderService.getRootNode();if(!A)return;let t=new FormData,n=this.agentBuilderService.getCurrentAgentToolBoards();a0.generateYamlFile(A,t,e,n),this.agentService.agentBuildTmp(e,t).subscribe(o=>{console.log(o?"save to tmp":"something went wrong")})}static \u0275fac=function(A){return new(A||i)};static \u0275cmp=vA({type:i,selectors:[["app-builder-assistant"]],viewQuery:function(A,t){if(A&1&&Wt(NuA,5),A&2){let n;se(n=le())&&(t.chatMessages=n.first)}},inputs:{isVisible:"isVisible",appName:"appName"},outputs:{closePanel:"closePanel",reloadCanvas:"reloadCanvas"},decls:21,vars:6,consts:[["chatMessages",""],[1,"builder-assistant-panel"],[1,"panel-header"],[1,"panel-title"],["mat-icon-button","","matTooltip","Close assistant panel",1,"close-btn",3,"click"],[1,"panel-content"],[1,"chat-messages"],[1,"assistant-placeholder"],[1,"chat-input-container"],[1,"input-wrapper"],["cdkTextareaAutosize","","cdkAutosizeMinRows","1","cdkAutosizeMaxRows","5","placeholder","Ask Gemini to build your agent",1,"assistant-input-box",3,"ngModelChange","keydown","ngModel","disabled"],["mat-icon-button","","matTooltip","Send message",1,"send-button",3,"click","disabled"],[1,"large-icon"],[3,"ngClass"],[1,"message-card"],[1,"loading-message"],[1,"dots"],[1,"message-text"],[1,"bot-label"],[1,"error-message"],[3,"ngComponentOutlet","ngComponentOutletInputs"]],template:function(A,t){if(A&1){let n=aA();I(0,"div",1)(1,"div",2)(2,"div",3)(3,"mat-icon"),D(4,"auto_awesome"),h(),I(5,"span"),D(6,"Assistant"),h()(),I(7,"button",4),U("click",function(){return t.onClosePanel()}),I(8,"mat-icon"),D(9,"close"),h()()(),I(10,"div",5)(11,"div",6,0),T(13,GuA,7,0,"div",7)(14,zuA,2,0),h(),I(15,"div",8)(16,"div",9)(17,"textarea",10),Ni("ngModelChange",function(a){return L(n),wi(t.userMessage,a)||(t.userMessage=a),G(a)}),U("keydown",function(a){return t.onKeyDown(a)}),h(),I(18,"button",11),U("click",function(){return t.sendMessage(t.userMessage.trim())}),I(19,"mat-icon"),D(20,"send"),h()()()()()()}A&2&&(_A("hidden",!t.isVisible),Q(13),O(t.messages.length===0?13:14),Q(4),Ri("ngModel",t.userMessage),H("disabled",t.isGenerating),Q(),H("disabled",!t.userMessage.trim()||t.isGenerating))},dependencies:[li,Vl,Kc,fn,Gn,Kn,Ho,zt,yi,rn,qf,YI,P3],styles:[".builder-assistant-panel[_ngcontent-%COMP%]{position:fixed;right:0;top:72px;width:400px;height:calc(100vh - 72px);background-color:var(--mat-sys-surface-container);border-left:1px solid var(--mat-sys-outline-variant);box-shadow:-2px 0 10px #0006;display:flex;flex-direction:column;transition:transform .3s ease}.builder-assistant-panel.hidden[_ngcontent-%COMP%]{transform:translate(100%)}.panel-header[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--mat-sys-outline-variant)}.panel-title[_ngcontent-%COMP%]{display:flex;align-items:center;gap:8px;font-weight:400;font-size:16px;color:var(--mat-sys-on-surface);font-family:Google Sans,Helvetica Neue,sans-serif}.panel-title[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{color:var(--mat-sys-on-surface);font-size:20px;width:20px;height:20px}.close-btn[_ngcontent-%COMP%]{color:var(--mat-sys-on-surface-variant)}.close-btn[_ngcontent-%COMP%]:hover{color:var(--mat-sys-on-surface)}.panel-content[_ngcontent-%COMP%]{flex:1;display:flex;flex-direction:column;overflow:hidden}.assistant-placeholder[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;height:300px;color:var(--mat-sys-on-surface-variant)}.assistant-placeholder[_ngcontent-%COMP%] .large-icon[_ngcontent-%COMP%]{font-size:64px;width:64px;height:64px;margin-bottom:16px;color:var(--mat-sys-primary)}.assistant-placeholder[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{margin:0 0 8px;font-size:20px;font-weight:500;color:var(--mat-sys-on-surface);font-family:Google Sans,Helvetica Neue,sans-serif}.assistant-placeholder[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:0;font-size:14px;line-height:1.5;color:var(--mat-sys-on-surface-variant)}.chat-messages[_ngcontent-%COMP%]{flex:1;padding:20px;overflow-y:auto;display:flex;flex-direction:column}.chat-input-container[_ngcontent-%COMP%]{padding:16px 20px 20px;border-top:none}.input-wrapper[_ngcontent-%COMP%]{display:flex;align-items:center;background-color:var(--mat-sys-surface-container-highest);border:1px solid var(--mat-sys-outline-variant);border-radius:50px;padding:10px 6px 10px 18px;gap:8px}.assistant-input-box[_ngcontent-%COMP%]{flex:1;color:var(--mat-sys-on-surface);background-color:transparent;border:none;padding:0;resize:none;overflow:hidden;font-family:Google Sans,Helvetica Neue,sans-serif;font-size:14px;line-height:20px;min-height:20px;max-height:120px}.assistant-input-box[_ngcontent-%COMP%]::placeholder{color:var(--mat-sys-on-surface-variant);font-size:14px}.assistant-input-box[_ngcontent-%COMP%]:focus{outline:none}.assistant-input-box[_ngcontent-%COMP%]::-webkit-scrollbar{width:4px}.assistant-input-box[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background-color:var(--mat-sys-outline);border-radius:4px}.send-button[_ngcontent-%COMP%]{color:var(--mat-sys-primary);width:36px;height:36px;min-width:36px;flex-shrink:0;margin:0;padding:0}.send-button[_ngcontent-%COMP%]:disabled{color:var(--mat-sys-outline)}.send-button[_ngcontent-%COMP%]:hover:not(:disabled){color:var(--mat-sys-primary);border-radius:50%}.send-button[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px}.message-card[_ngcontent-%COMP%]{padding:10px 16px;margin:6px 0;font-size:14px;font-weight:400;position:relative;display:block;box-shadow:none;line-height:1.5;width:100%}.user-message[_ngcontent-%COMP%]{display:block;width:100%;margin-bottom:12px}.user-message[_ngcontent-%COMP%] .message-card[_ngcontent-%COMP%]{border:1px solid var(--mat-sys-outline-variant);border-radius:4px;color:var(--mat-sys-on-surface);padding:8px 12px}.bot-message[_ngcontent-%COMP%]{display:block;width:100%;margin-bottom:0}.bot-message[_ngcontent-%COMP%] .message-card[_ngcontent-%COMP%]{border:none;border-radius:0;color:var(--mat-sys-on-surface);padding:0;margin:0}.bot-label[_ngcontent-%COMP%]{font-size:12px;font-weight:500;color:var(--mat-sys-on-surface-variant);margin-bottom:8px;font-family:Google Sans,Helvetica Neue,sans-serif}.error-message[_ngcontent-%COMP%]{color:var(--mat-app-warn, #d32f2f);font-family:Google Sans,Helvetica Neue,sans-serif;font-size:14px;white-space:pre-line;word-break:break-word;padding:8px 12px}.message-text[_ngcontent-%COMP%]{white-space:pre-line;word-break:break-word;overflow-wrap:break-word;font-family:Google Sans,Helvetica Neue,sans-serif}.message-text[_ngcontent-%COMP%] p{margin:0;line-height:1.4}.message-text[_ngcontent-%COMP%] p:first-child{margin-top:0}.message-text[_ngcontent-%COMP%] p:last-child{margin-bottom:0}.message-text[_ngcontent-%COMP%] ul, .message-text[_ngcontent-%COMP%] ol{margin:0;padding-left:1.5em}.message-text[_ngcontent-%COMP%] li{margin:0}.message-text[_ngcontent-%COMP%] code{padding:2px 4px;border-radius:3px;font-family:Monaco,Menlo,Ubuntu Mono,monospace;font-size:.9em}.message-text[_ngcontent-%COMP%] pre{padding:8px 12px;border-radius:6px;overflow-x:auto;margin:.5em 0}.message-text[_ngcontent-%COMP%] pre code{padding:0}.message-text[_ngcontent-%COMP%] blockquote{border-left:3px solid var(--mat-sys-primary);padding-left:12px;margin:.5em 0;font-style:italic;color:var(--mat-sys-on-surface-variant)}.message-text[_ngcontent-%COMP%] strong{font-weight:600}.message-text[_ngcontent-%COMP%] em{font-style:italic}.loading-message[_ngcontent-%COMP%]{display:flex;align-items:center;color:var(--mat-sys-on-surface-variant);font-family:Google Sans,Helvetica Neue,sans-serif;padding:0;margin:0}.loading-message[_ngcontent-%COMP%] .dots[_ngcontent-%COMP%]{font-size:24px;letter-spacing:-12px;animation:_ngcontent-%COMP%_pulse 1.4s ease-in-out infinite;display:inline-block;line-height:1}@keyframes _ngcontent-%COMP%_pulse{0%,to{opacity:.3}50%{opacity:1}}"]})};var dE=class i{constructor(e,A){this.http=e;this.zone=A}apiServerDomain=Rr.getApiServerBaseUrl();_currentApp=new gi("");currentApp=this._currentApp.asObservable();isLoading=new gi(!1);getApp(){return this.currentApp}setApp(e){this._currentApp.next(e)}getLoadingState(){return this.isLoading}runSse(e){let A=this.apiServerDomain+"/run_sse";return this.isLoading.next(!0),new Fi(t=>{let n=this,o=new AbortController,a=o.signal,r;return fetch(A,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(e),signal:a}).then(s=>{r=s.body?.getReader();let l=new TextDecoder("utf-8"),g="",C=()=>{r?.read().then(({done:d,value:B})=>{if(this.isLoading.next(!0),d)return this.isLoading.next(!1),t.complete();let u=l.decode(B,{stream:!0});g+=u;try{g.split(/\r?\n/).filter(f=>f.startsWith("data:")).forEach(f=>{let m=f.replace(/^data:\s*/,""),v=JSON.parse(m);n.zone.run(()=>t.next(v))}),g=""}catch(E){E instanceof SyntaxError&&C()}C()}).catch(d=>{a.aborted||n.zone.run(()=>t.error(d))})};C()}).catch(s=>{a.aborted||n.zone.run(()=>t.error(s))}),()=>{o.abort(),r?.cancel(),this.isLoading.next(!1)}})}listApps(){if(this.apiServerDomain!=null){let e=this.apiServerDomain+"/list-apps?relative_path=./";return this.http.get(e)}return new Fi}getVersion(){if(this.apiServerDomain!=null){let e=this.apiServerDomain+"/version";return this.http.get(e)}return new Fi}agentBuild(e,A){if(this.apiServerDomain!=null){let t=this.apiServerDomain+`/dev/apps/${e}/builder/save`;return this.http.post(t,A)}return new Fi}agentBuildTmp(e,A){if(this.apiServerDomain!=null){let t=this.apiServerDomain+`/dev/apps/${e}/builder/save?tmp=true`;return this.http.post(t,A)}return new Fi}getAgentBuilder(e){if(this.apiServerDomain!=null){let A=this.apiServerDomain+`/dev/apps/${e}/builder?ts=${Date.now()}`;return this.http.get(A,{responseType:"text"})}return new Fi}getAgentBuilderTmp(e){if(this.apiServerDomain!=null){let A=this.apiServerDomain+`/dev/apps/${e}/builder?ts=${Date.now()}&tmp=true`;return this.http.get(A,{responseType:"text"})}return new Fi}getSubAgentBuilder(e,A){if(this.apiServerDomain!=null){let t=this.apiServerDomain+`/dev/apps/${e}/builder?ts=${Date.now()}&file_path=${A}&tmp=true`;return this.http.get(t,{responseType:"text"})}return new Fi}agentChangeCancel(e){if(this.apiServerDomain!=null){let A=this.apiServerDomain+`/dev/apps/${e}/builder/cancel`;return this.http.post(A,{})}return new Fi}getAppInfo(e){if(this.apiServerDomain!=null){let A=this.apiServerDomain+`/dev/apps/${e}/build_graph`;return this.http.get(A)}return new Fi}getAppGraphImage(e,A,t){if(this.apiServerDomain!=null){let n=this.apiServerDomain+`/dev/apps/${e}/build_graph_image`,o={dark_mode:A};return t&&(o.node=t),this.http.get(n,{params:o})}return new Fi}static \u0275fac=function(A){return new(A||i)(Wo(Mr),Wo(We))};static \u0275prov=jA({token:i,factory:i.\u0275fac,providedIn:"root"})};var juA=["edgeLabelWrapper"],VuA=["edgeLabel",""];function quA(i,e){i&1&&dn(0)}function WuA(i,e){if(i&1&&(Et(),I(0,"foreignObject"),hr(),I(1,"div",1,0),kt(3,quA,1,0,"ng-container",2),h()()),i&2){let A=p(2),t=p();ie("x",t.edgeLabelPoint().x)("y",t.edgeLabelPoint().y)("width",A.size().width)("height",A.size().height),Q(3),H("ngTemplateOutlet",e)("ngTemplateOutletContext",t.getLabelContext())}}function ZuA(i,e){if(i&1&&T(0,WuA,4,6,":svg:foreignObject"),i&2){let A,t=p(2);O((A=t.htmlTemplate())?0:-1,A)}}function XuA(i,e){if(i&1&&(Et(),I(0,"foreignObject"),hr(),I(1,"div",1,0),D(3),h()()),i&2){let A=p(),t=p();ie("x",t.edgeLabelPoint().x)("y",t.edgeLabelPoint().y)("width",A.size().width)("height",A.size().height),Q(),kN(t.edgeLabelStyle()),Q(2),Ee(" ",A.edgeLabel.text," ")}}function $uA(i,e){if(i&1&&(T(0,ZuA,1,1),T(1,XuA,4,7,":svg:foreignObject")),i&2){let A=e,t=p();O(A.edgeLabel.type==="html-template"&&t.htmlTemplate()?0:-1),Q(),O(A.edgeLabel.type==="default"?1:-1)}}var A4A=["edge",""];function e4A(i,e){if(i&1){let A=aA();Et(),lA(0,"path",0),I(1,"path",1),U("click",function(){L(A);let n=p();return n.select(),G(n.pull())}),h()}if(i&2){let A=p();_A("edge_selected",A.model().selected()),ie("d",A.model().path().path)("marker-start",A.model().markerStartUrl())("marker-end",A.model().markerEndUrl()),Q(),ie("d",A.model().path().path)}}function t4A(i,e){if(i&1&&dn(0,2),i&2){let A=p(2);H("ngTemplateOutlet",e)("ngTemplateOutletContext",A.model().context)("ngTemplateOutletInjector",A.injector)}}function i4A(i,e){if(i&1&&T(0,t4A,1,3,"ng-container",2),i&2){let A,t=p();O((A=t.edgeTemplate())?0:-1,A)}}function n4A(i,e){if(i&1&&(Et(),lA(0,"g",3)),i&2){let A=p(),t=p();H("model",A)("point",e)("edgeModel",t.model())("htmlTemplate",t.edgeLabelHtmlTemplate())}}function o4A(i,e){if(i&1&&T(0,n4A,1,4,":svg:g",3),i&2){let A,t=p();O((A=(A=t.model().path().labelPoints)==null?null:A.start)?0:-1,A)}}function a4A(i,e){if(i&1&&(Et(),lA(0,"g",3)),i&2){let A=p(),t=p();H("model",A)("point",e)("edgeModel",t.model())("htmlTemplate",t.edgeLabelHtmlTemplate())}}function r4A(i,e){if(i&1&&T(0,a4A,1,4,":svg:g",3),i&2){let A,t=p();O((A=(A=t.model().path().labelPoints)==null?null:A.center)?0:-1,A)}}function s4A(i,e){if(i&1&&(Et(),lA(0,"g",3)),i&2){let A=p(),t=p();H("model",A)("point",e)("edgeModel",t.model())("htmlTemplate",t.edgeLabelHtmlTemplate())}}function l4A(i,e){if(i&1&&T(0,s4A,1,4,":svg:g",3),i&2){let A,t=p();O((A=(A=t.model().path().labelPoints)==null?null:A.end)?0:-1,A)}}function g4A(i,e){if(i&1){let A=aA();Et(),I(0,"circle",5),U("pointerStart",function(n){L(A);let o=p(2);return G(o.startReconnection(n,o.model().targetHandle()))}),h()}if(i&2){let A=p(2);ie("cx",A.model().sourceHandle().pointAbsolute().x)("cy",A.model().sourceHandle().pointAbsolute().y)}}function c4A(i,e){if(i&1){let A=aA();Et(),I(0,"circle",5),U("pointerStart",function(n){L(A);let o=p(2);return G(o.startReconnection(n,o.model().sourceHandle()))}),h()}if(i&2){let A=p(2);ie("cx",A.model().targetHandle().pointAbsolute().x)("cy",A.model().targetHandle().pointAbsolute().y)}}function C4A(i,e){if(i&1&&(T(0,g4A,1,2,":svg:circle",4),T(1,c4A,1,2,":svg:circle",4)),i&2){let A=p();O(A.model().reconnectable===!0||A.model().reconnectable==="source"?0:-1),Q(),O(A.model().reconnectable===!0||A.model().reconnectable==="target"?1:-1)}}var Xx=["*"],d4A=["resizer"],I4A=["resizable",""];function B4A(i,e){if(i&1){let A=aA();Et(),I(0,"g")(1,"line",1),U("pointerStart",function(n){L(A);let o=p();return G(o.startResize("top",n))}),h(),I(2,"line",2),U("pointerStart",function(n){L(A);let o=p();return G(o.startResize("left",n))}),h(),I(3,"line",3),U("pointerStart",function(n){L(A);let o=p();return G(o.startResize("bottom",n))}),h(),I(4,"line",4),U("pointerStart",function(n){L(A);let o=p();return G(o.startResize("right",n))}),h(),I(5,"rect",5),U("pointerStart",function(n){L(A);let o=p();return G(o.startResize("top-left",n))}),h(),I(6,"rect",6),U("pointerStart",function(n){L(A);let o=p();return G(o.startResize("top-right",n))}),h(),I(7,"rect",7),U("pointerStart",function(n){L(A);let o=p();return G(o.startResize("bottom-left",n))}),h(),I(8,"rect",8),U("pointerStart",function(n){L(A);let o=p();return G(o.startResize("bottom-right",n))}),h()()}if(i&2){let A=p();Q(),ie("x1",A.lineGap)("y1",-A.gap())("x2",A.model.size().width-A.lineGap)("y2",-A.gap())("stroke",A.resizerColor()),Q(),ie("x1",-A.gap())("y1",A.lineGap)("x2",-A.gap())("y2",A.model.size().height-A.lineGap)("stroke",A.resizerColor()),Q(),ie("x1",A.lineGap)("y1",A.model.size().height+A.gap())("x2",A.model.size().width-A.lineGap)("y2",A.model.size().height+A.gap())("stroke",A.resizerColor()),Q(),ie("x1",A.model.size().width+A.gap())("y1",A.lineGap)("x2",A.model.size().width+A.gap())("y2",A.model.size().height-A.lineGap)("stroke",A.resizerColor()),Q(),ie("x",-(A.handleSize/2)-A.gap())("y",-(A.handleSize/2)-A.gap())("width",A.handleSize)("height",A.handleSize)("fill",A.resizerColor()),Q(),ie("x",A.model.size().width-A.handleSize/2+A.gap())("y",-(A.handleSize/2)-A.gap())("width",A.handleSize)("height",A.handleSize)("fill",A.resizerColor()),Q(),ie("x",-(A.handleSize/2)-A.gap())("y",A.model.size().height-A.handleSize/2+A.gap())("width",A.handleSize)("height",A.handleSize)("fill",A.resizerColor()),Q(),ie("x",A.model.size().width-A.handleSize/2+A.gap())("y",A.model.size().height-A.handleSize/2+A.gap())("width",A.handleSize)("height",A.handleSize)("fill",A.resizerColor())}}var h4A=["node",""];function E4A(i,e){if(i&1){let A=aA();Et(),I(0,"foreignObject",3),U("click",function(){L(A);let n=p();return n.pullNode(),G(n.selectNode())}),hr(),I(1,"default-node",4),lA(2,"div",5)(3,"handle",6)(4,"handle",7),h()()}if(i&2){let A=p();ie("width",A.model().foWidth())("height",A.model().foHeight()),Q(),ft("width",A.model().styleWidth())("height",A.model().styleHeight())("max-width",A.model().styleWidth())("max-height",A.model().styleHeight()),H("selected",A.model().selected()),Q(),H("outerHTML",A.model().text(),Fc)}}function Q4A(i,e){if(i&1){let A=aA();Et(),I(0,"foreignObject",3),U("click",function(){L(A);let n=p();return G(n.pullNode())}),hr(),I(1,"div",8),dn(2,9),h()()}if(i&2){let A=p();ie("width",A.model().foWidth())("height",A.model().foHeight()),Q(),ft("width",A.model().styleWidth())("height",A.model().styleHeight()),Q(),H("ngTemplateOutlet",A.nodeTemplate()??null)("ngTemplateOutletContext",A.model().context)("ngTemplateOutletInjector",A.injector)}}function u4A(i,e){if(i&1){let A=aA();Et(),I(0,"g",10),U("click",function(){L(A);let n=p();return G(n.pullNode())}),dn(1,9),h()}if(i&2){let A=p();Q(),H("ngTemplateOutlet",A.nodeSvgTemplate()??null)("ngTemplateOutletContext",A.model().context)("ngTemplateOutletInjector",A.injector)}}function p4A(i,e){if(i&1){let A=aA();Et(),I(0,"foreignObject",3),U("click",function(){L(A);let n=p(2);return G(n.pullNode())}),hr(),I(1,"div",8),dn(2,11),h()()}if(i&2){let A=p(2);ie("width",A.model().foWidth())("height",A.model().foHeight()),Q(),ft("width",A.model().styleWidth())("height",A.model().styleHeight()),Q(),H("ngComponentOutlet",e)("ngComponentOutletInputs",A.model().componentTypeInputs)("ngComponentOutletInjector",A.injector)}}function f4A(i,e){if(i&1&&(T(0,p4A,3,9,":svg:foreignObject",0),mt(1,"async")),i&2){let A,t=p();O((A=Ft(1,1,t.model().componentInstance$))?0:-1,A)}}function m4A(i,e){if(i&1){let A=aA();Et(),I(0,"rect",12),U("click",function(){L(A);let n=p();return n.pullNode(),G(n.selectNode())}),h()}if(i&2){let A=p();ft("stroke",A.model().color())("fill",A.model().color()),_A("default-group-node_selected",A.model().selected()),H("resizable",A.model().resizable())("gap",3)("resizerColor",A.model().color()),ie("width",A.model().size().width)("height",A.model().size().height)}}function w4A(i,e){if(i&1){let A=aA();Et(),I(0,"g",10),U("click",function(){L(A);let n=p();return G(n.pullNode())}),dn(1,9),h()}if(i&2){let A=p();Q(),H("ngTemplateOutlet",A.groupNodeTemplate()??null)("ngTemplateOutletContext",A.model().context)("ngTemplateOutletInjector",A.injector)}}function y4A(i,e){}function D4A(i,e){if(i&1&&kt(0,y4A,0,0,"ng-template",13),i&2){let A=p();H("ngTemplateOutlet",A)}}function v4A(i,e){if(i&1&&T(0,D4A,1,1,null,13),i&2){let A=p();O(A.model().resizable()?0:-1)}}function b4A(i,e){if(i&1){let A=aA();Et(),I(0,"circle",17),U("pointerStart",function(n){L(A);let o=p().$implicit,a=p();return G(a.startConnection(n,o))})("pointerEnd",function(){L(A);let n=p(2);return G(n.endConnection())}),h()}if(i&2){let A=p().$implicit;ie("cx",A.hostOffset().x)("cy",A.hostOffset().y)("stroke-width",A.strokeWidth)}}function M4A(i,e){if(i&1){let A=aA();Et(),I(0,"g",18),U("pointerStart",function(n){L(A);let o=p().$implicit,a=p();return G(a.startConnection(n,o))})("pointerEnd",function(){L(A);let n=p(2);return G(n.endConnection())}),h()}if(i&2){let A=p().$implicit;H("handleSizeController",A)}}function S4A(i,e){i&1&&(Et(),dn(0))}function k4A(i,e){if(i&1){let A=aA();Et(),I(0,"g",18),U("pointerStart",function(n){L(A);let o=p().$implicit,a=p();return G(a.startConnection(n,o))})("pointerEnd",function(){L(A);let n=p(2);return G(n.endConnection())}),kt(1,S4A,1,0,"ng-container",19),h()}if(i&2){let A=p().$implicit;H("handleSizeController",A),Q(),H("ngTemplateOutlet",A.template)("ngTemplateOutletContext",A.templateContext)}}function _4A(i,e){if(i&1){let A=aA();Et(),I(0,"circle",20),U("pointerEnd",function(){L(A);let n=p().$implicit,o=p();return o.endConnection(),G(o.resetValidateConnection(n))})("pointerOver",function(){L(A);let n=p().$implicit,o=p();return G(o.validateConnection(n))})("pointerOut",function(){L(A);let n=p().$implicit,o=p();return G(o.resetValidateConnection(n))}),h()}if(i&2){let A=p().$implicit,t=p();ie("r",t.model().magnetRadius)("cx",A.hostOffset().x)("cy",A.hostOffset().y)}}function x4A(i,e){if(i&1&&(T(0,b4A,1,3,":svg:circle",14),T(1,M4A,1,1,":svg:g",15),T(2,k4A,2,3,":svg:g",15),T(3,_4A,1,3,":svg:circle",16)),i&2){let A=e.$implicit,t=p();O(A.template===void 0?0:-1),Q(),O(A.template===null?1:-1),Q(),O(A.template?2:-1),Q(),O(t.showMagnet()?3:-1)}}function R4A(i,e){if(i&1&&(Et(),I(0,"foreignObject"),hr(),dn(1,13),h()),i&2){let A=e.$implicit;ie("width",A.size().width)("height",A.size().height)("transform",A.transform()),Q(),H("ngTemplateOutlet",A.template())}}var N4A=["connection",""];function F4A(i,e){if(i&1&&(Et(),lA(0,"path",0)),i&2){let A=p(2);ie("d",e)("marker-end",A.markerUrl())("stroke",A.defaultColor)}}function L4A(i,e){if(i&1&&T(0,F4A,1,3,":svg:path",0),i&2){let A,t=p();O((A=t.path())?0:-1,A)}}function G4A(i,e){i&1&&dn(0)}function K4A(i,e){if(i&1&&kt(0,G4A,1,0,"ng-container",1),i&2){let A=p(2);H("ngTemplateOutlet",e)("ngTemplateOutletContext",A.getContext())}}function U4A(i,e){if(i&1&&T(0,K4A,1,2,"ng-container"),i&2){let A,t=p();O((A=t.template())?0:-1,A)}}var T4A=["background",""];function O4A(i,e){if(i&1&&(Et(),Ln(0,"pattern",0),$n(1,"circle"),Xn(),$n(2,"rect",1)),i&2){let A=p();ie("id",A.patternId)("x",A.x())("y",A.y())("width",A.scaledGap())("height",A.scaledGap()),Q(),ie("cx",A.patternSize())("cy",A.patternSize())("r",A.patternSize())("fill",A.patternColor()),Q(),ie("fill",A.patternUrl)}}function J4A(i,e){if(i&1&&(Et(),Ln(0,"pattern",0),$n(1,"image"),Xn(),$n(2,"rect",1)),i&2){let A=p(2);ie("id",A.patternId)("x",A.imageX())("y",A.imageY())("width",A.scaledImageWidth())("height",A.scaledImageHeight()),Q(),ie("href",A.bgImageSrc())("width",A.scaledImageWidth())("height",A.scaledImageHeight()),Q(),ie("fill",A.patternUrl)}}function Y4A(i,e){if(i&1&&(Et(),$n(0,"image")),i&2){let A=p(2);ie("x",A.imageX())("y",A.imageY())("width",A.scaledImageWidth())("height",A.scaledImageHeight())("href",A.bgImageSrc())}}function H4A(i,e){if(i&1&&(T(0,J4A,3,9),T(1,Y4A,1,5,":svg:image")),i&2){let A=p();O(A.repeated()?0:-1),Q(),O(A.repeated()?-1:1)}}var z4A=["flowDefs",""];function P4A(i,e){if(i&1&&(Et(),$n(0,"polyline",3)),i&2){let A=p().$implicit,t=p();ft("stroke",A.value.color??t.defaultColor)("stroke-width",A.value.strokeWidth??2)("fill",A.value.color??t.defaultColor)}}function j4A(i,e){if(i&1&&(Et(),$n(0,"polyline",4)),i&2){let A=p().$implicit,t=p();ft("stroke",A.value.color??t.defaultColor)("stroke-width",A.value.strokeWidth??2)}}function V4A(i,e){if(i&1&&(Et(),Ln(0,"marker",0),T(1,P4A,1,6,":svg:polyline",1),T(2,j4A,1,4,":svg:polyline",2),Xn()),i&2){let A=e.$implicit;ie("id",A.key)("markerWidth",A.value.width??16.5)("markerHeight",A.value.height??16.5)("orient",A.value.orient??"auto-start-reverse")("markerUnits",A.value.markerUnits??"userSpaceOnUse"),Q(),O(A.value.type==="arrow-closed"||!A.value.type?1:-1),Q(),O(A.value.type==="arrow"?2:-1)}}var q4A=["previewFlow",""],W4A=["alignmentHelper",""];function Z4A(i,e){if(i&1&&(Et(),$n(0,"line")),i&2){let A=e.$implicit,t=p(3);ie("stroke",t.lineColor())("stroke-dasharray",A.isCenter?4:null)("x1",A.x)("y1",A.y)("x2",A.x2)("y2",A.y2)}}function X4A(i,e){i&1&&ke(0,Z4A,1,6,":svg:line",null,Ja),i&2&&_e(e.lines)}function $4A(i,e){if(i&1&&T(0,X4A,2,0),i&2){let A,t=p();O((A=t.intersections())?0:-1,A)}}function ApA(i,e){i&1&&(Et(),lA(0,"g",8))}function epA(i,e){if(i&1&&(Et(),lA(0,"g",9)),i&2){let A=p();H("tolerance",A.tolerance)("lineColor",A.lineColor)}}function tpA(i,e){i&1&&T(0,ApA,1,0,":svg:g",8)(1,epA,1,2,":svg:g",9),i&2&&O(e===!0?0:1)}function ipA(i,e){if(i&1&&(Et(),lA(0,"g",10)),i&2){let A,t=e.$implicit,n=p(2);H("model",t)("groupNodeTemplate",(A=n.groupNodeTemplateDirective())==null?null:A.templateRef),ie("transform",t.pointTransform())}}function npA(i,e){if(i&1&&(Et(),lA(0,"g",11)),i&2){let A,t,n=e.$implicit,o=p(2);H("model",n)("edgeTemplate",(A=o.edgeTemplateDirective())==null?null:A.templateRef)("edgeLabelHtmlTemplate",(t=o.edgeLabelHtmlDirective())==null?null:t.templateRef)}}function opA(i,e){if(i&1&&(Et(),lA(0,"g",12)),i&2){let A,t,n=e.$implicit,o=p(2);H("model",n)("nodeTemplate",(A=o.nodeTemplateDirective())==null?null:A.templateRef)("nodeSvgTemplate",(t=o.nodeSvgTemplateDirective())==null?null:t.templateRef),ie("transform",n.pointTransform())}}function apA(i,e){if(i&1&&(ke(0,ipA,1,3,":svg:g",10,wI().trackNodes,!0),ke(2,npA,1,3,":svg:g",11,wI().trackEdges,!0),ke(4,opA,1,4,":svg:g",12,wI().trackNodes,!0)),i&2){let A=p();_e(A.groups()),Q(2),_e(A.edgeModels()),Q(2),_e(A.nonGroups())}}function rpA(i,e){if(i&1&&(Et(),lA(0,"g",11)),i&2){let A,t,n=e.$implicit,o=p(2);H("model",n)("edgeTemplate",(A=o.edgeTemplateDirective())==null?null:A.templateRef)("edgeLabelHtmlTemplate",(t=o.edgeLabelHtmlDirective())==null?null:t.templateRef)}}function spA(i,e){if(i&1&&(Et(),lA(0,"g",13)),i&2){let A,t,n,o=e.$implicit,a=p(2);H("model",o)("nodeTemplate",(A=a.nodeTemplateDirective())==null?null:A.templateRef)("nodeSvgTemplate",(t=a.nodeSvgTemplateDirective())==null?null:t.templateRef)("groupNodeTemplate",(n=a.groupNodeTemplateDirective())==null?null:n.templateRef),ie("transform",o.pointTransform())}}function lpA(i,e){if(i&1&&(ke(0,rpA,1,3,":svg:g",11,wI().trackEdges,!0),ke(2,spA,1,5,":svg:g",13,wI().trackNodes,!0)),i&2){let A=p();_e(A.edgeModels()),Q(2),_e(A.nodeModels())}}function gpA(i,e){i&1&&(Et(),dn(0,6)),i&2&&H("ngTemplateOutlet",e.template())}function cpA(i,e){if(i&1&&lA(0,"canvas",7),i&2){let A=p();H("width",A.flowWidth())("height",A.flowHeight())}}var CpA=["customTemplateEdge",""],dpA=(i,e)=>{let A=Math.max(0,Math.min(i.x+i.width,e.x+e.width)-Math.max(i.x,e.x)),t=Math.max(0,Math.min(i.y+i.height,e.y+e.height)-Math.max(i.y,e.y));return Math.ceil(A*t)};function sZ(i){if(i.length===0)return{x:0,y:0,width:0,height:0};let e={x:1/0,y:1/0,x2:-1/0,y2:-1/0};return i.forEach(A=>{let t=BpA(A);e=EpA(e,t)}),hpA(e)}function IpA(i,e,A){let t=e.find(o=>o.rawNode.id===i);if(!t)return[];let n=v5(t);return e.filter(o=>{if(o.rawNode.id===i)return!1;let a=dpA(v5(o),n);return A?.partially?a>0:a>=n.width*n.height})}function BpA(i){return{x:i.point().x,y:i.point().y,x2:i.point().x+i.size().width,y2:i.point().y+i.size().height}}function v5(i){return{x:i.globalPoint().x,y:i.globalPoint().y,width:i.width(),height:i.height()}}function hpA({x:i,y:e,x2:A,y2:t}){return{x:i,y:e,width:A-i,height:t-e}}function EpA(i,e){return{x:Math.min(i.x,e.x),y:Math.min(i.y,e.y),x2:Math.max(i.x2,e.x2),y2:Math.max(i.y2,e.y2)}}var b5=class{constructor(e){this.settings=e,this.curve=e.curve??"bezier",this.type=e.type??"default",this.mode=e.mode??"strict";let A=this.getValidators(e);this.validator=t=>A.every(n=>n(t))}getValidators(e){let A=[];return A.push(QpA),this.mode==="loose"&&A.push(upA),e.validator&&A.push(e.validator),A}},QpA=i=>i.source!==i.target,upA=i=>i.sourceHandle!==void 0&&i.targetHandle!==void 0;function BE(i){return i.split("").reduce((e,A)=>(e=(e<<5)-e+A.charCodeAt(0),e&e),0)}var pl=(()=>{class i{constructor(){this.nodes=mA([],{equal:(A,t)=>!A.length&&!t.length?!0:A===t}),this.rawNodes=ye(()=>this.nodes().map(A=>A.rawNode)),this.edges=mA([],{equal:(A,t)=>!A.length&&!t.length?!0:A===t}),this.rawEdges=ye(()=>this.edges().map(A=>A.edge)),this.validEdges=ye(()=>{let A=this.nodes();return this.edges().filter(t=>A.includes(t.source())&&A.includes(t.target()))}),this.connection=mA(new b5({})),this.markers=ye(()=>{let A=new Map;this.validEdges().forEach(n=>{if(n.edge.markers?.start){let o=BE(JSON.stringify(n.edge.markers.start));A.set(o,n.edge.markers.start)}if(n.edge.markers?.end){let o=BE(JSON.stringify(n.edge.markers.end));A.set(o,n.edge.markers.end)}});let t=this.connection().settings.marker;if(t){let n=BE(JSON.stringify(t));A.set(n,t)}return A}),this.entities=ye(()=>[...this.nodes(),...this.edges()]),this.minimap=mA(null)}getNode(A){return this.nodes().find(({rawNode:t})=>t.id===A)}getDetachedEdges(){return this.edges().filter(A=>A.detached())}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275prov=jA({token:i,factory:i.\u0275fac})}}return i})();function ppA(i,e,A,t,n,o){let a=e/(i.width*(1+o)),r=A/(i.height*(1+o)),s=Math.min(a,r),l=fpA(s,t,n),g=i.x+i.width/2,C=i.y+i.height/2,d=e/2-g*l,B=A/2-C*l;return{x:d,y:B,zoom:l}}function fpA(i,e=0,A=1){return Math.min(Math.max(i,e),A)}function mpA(i,e,A){let t=i.zoom;return{x:-i.x/t,y:-i.y/t,width:e/t,height:A/t}}function wpA(i,e,A,t){let n=mpA(e,A,t);return!(i.x+i.width<n.x||i.x>n.x+n.width||i.y+i.height<n.y||i.y>n.y+n.height)}var ypA={detachedGroupsLayer:!1,virtualization:!1,virtualizationZoomThreshold:.5,lazyLoadTrigger:"immediate"},as=(()=>{class i{constructor(){this.entitiesSelectable=mA(!0),this.elevateNodesOnSelect=mA(!0),this.elevateEdgesOnSelect=mA(!0),this.view=mA([400,400]),this.computedFlowWidth=mA(0),this.computedFlowHeight=mA(0),this.minZoom=mA(.5),this.maxZoom=mA(3),this.background=mA({type:"solid",color:"#fff"}),this.snapGrid=mA([1,1]),this.optimization=mA(ypA)}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275prov=jA({token:i,factory:i.\u0275fac})}}return i})(),lI=(()=>{class i{constructor(){this.entitiesService=w(pl),this.flowSettingsService=w(as),this.writableViewport=mA({changeType:"initial",state:i.getDefaultViewport(),duration:0}),this.readableViewport=mA(i.getDefaultViewport()),this.viewportChangeEnd$=new ne}static getDefaultViewport(){return{zoom:1,x:0,y:0}}fitView(A={padding:.1,duration:0,nodes:[]}){let t=this.getBoundsNodes(A.nodes??[]),n=ppA(sZ(t),this.flowSettingsService.computedFlowWidth(),this.flowSettingsService.computedFlowHeight(),this.flowSettingsService.minZoom(),this.flowSettingsService.maxZoom(),A.padding??.1),o=A.duration??0;this.writableViewport.set({changeType:"absolute",state:n,duration:o})}triggerViewportChangeEvent(A){A==="end"&&this.viewportChangeEnd$.next()}getBoundsNodes(A){return A?.length?A.map(t=>this.entitiesService.nodes().find(({rawNode:n})=>n.id===t)).filter(t=>!!t):this.entitiesService.nodes()}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275prov=jA({token:i,factory:i.\u0275fac})}}return i})();function LC(i){return i!==void 0}var F5=(()=>{class i{constructor(){this.element=w(ce).nativeElement}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275dir=VA({type:i,selectors:[["svg","rootSvgRef",""]]})}}return i})();function VW(){let i=window.navigator.userAgent.toLowerCase(),e=/(macintosh|macintel|macppc|mac68k|macos)/i,A=/(win32|win64|windows|wince)/i,t=/(iphone|ipad|ipod)/i,n=null;return e.test(i)?n="macos":t.test(i)?n="ios":A.test(i)?n="windows":/android/.test(i)?n="android":!n&&/linux/.test(i)&&(n="linux"),n}var Jx=(()=>{class i{constructor(){this.actions=mA({multiSelection:[VW()==="macos"?"MetaLeft":"ControlLeft",VW()==="macos"?"MetaRight":"ControlRight"]}),this.actionsActive={multiSelection:!1},Fo(this.actions).pipe(Mi(()=>Vi(Nc(document,"keydown").pipe(mi(A=>{for(let t in this.actions())(this.actions()[t]??[]).includes(A.code)&&(this.actionsActive[t]=!0)})),Nc(document,"keyup").pipe(mi(A=>{for(let t in this.actions())(this.actions()[t]??[]).includes(A.code)&&(this.actionsActive[t]=!1)})))),xr()).subscribe()}setShortcuts(A){this.actions.update(t=>P(P({},t),A))}isActiveAction(A){return this.actionsActive[A]}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275prov=jA({token:i,factory:i.\u0275fac})}}return i})(),yp=(()=>{class i{constructor(){this.flowEntitiesService=w(pl),this.keyboardService=w(Jx),this.viewport$=new ne,this.resetSelection=this.viewport$.pipe(mi(({start:A,end:t,target:n})=>{if(A&&t&&n){let o=i.delta,a=Math.abs(t.x-A.x),r=Math.abs(t.y-A.y),s=a<o&&r<o,l=!n.closest(".selectable");s&&l&&this.select(null)}}),xr()).subscribe()}static{this.delta=6}setViewport(A){this.viewport$.next(A)}select(A){A?.selected()||(this.keyboardService.isActiveAction("multiSelection")||this.flowEntitiesService.entities().forEach(t=>t.selected.set(!1)),A&&A.selected.set(!0))}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275prov=jA({token:i,factory:i.\u0275fac})}}return i})(),Ux=(()=>{class i{constructor(){this.rootSvg=w(F5).element,this.host=w(ce).nativeElement,this.selectionService=w(yp),this.viewportService=w(lI),this.flowSettingsService=w(as),this.zone=w(We),this.rootSvgSelection=zs(this.rootSvg),this.transform=mA(""),this.viewportForSelection={},this.manualViewportChangeEffect=Fn(()=>{let A=this.viewportService.writableViewport(),t=A.state;if(A.changeType!=="initial"){if(LC(t.zoom)&&!LC(t.x)&&!LC(t.y)){this.rootSvgSelection.transition().duration(A.duration).call(this.zoomBehavior.scaleTo,t.zoom);return}if(LC(t.x)&&LC(t.y)&&!LC(t.zoom)){let n=wa(this.viewportService.readableViewport).zoom;this.rootSvgSelection.transition().duration(A.duration).call(this.zoomBehavior.transform,zD.translate(t.x,t.y).scale(n));return}if(LC(t.x)&&LC(t.y)&&LC(t.zoom)){this.rootSvgSelection.transition().duration(A.duration).call(this.zoomBehavior.transform,zD.translate(t.x,t.y).scale(t.zoom));return}}},{allowSignalWrites:!0}),this.handleZoom=({transform:A})=>{this.viewportService.readableViewport.set(Tx(A)),this.transform.set(A.toString())},this.handleZoomStart=({transform:A})=>{this.viewportForSelection={start:Tx(A)}},this.handleZoomEnd=({transform:A,sourceEvent:t})=>{this.zone.run(()=>{this.viewportForSelection=$A(P({},this.viewportForSelection),{end:Tx(A),target:DpA(t)}),this.viewportService.triggerViewportChangeEvent("end"),this.selectionService.setViewport(this.viewportForSelection)})},this.filterCondition=A=>A.type==="mousedown"||A.type==="touchstart"?A.target.closest(".vflow-node")===null:!0}ngOnInit(){this.zone.runOutsideAngular(()=>{this.zoomBehavior=lF().scaleExtent([this.flowSettingsService.minZoom(),this.flowSettingsService.maxZoom()]).filter(this.filterCondition).on("start",this.handleZoomStart).on("zoom",this.handleZoom).on("end",this.handleZoomEnd),this.rootSvgSelection.call(this.zoomBehavior).on("dblclick.zoom",null)})}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275dir=VA({type:i,selectors:[["g","mapContext",""]],hostVars:1,hostBindings:function(t,n){t&2&&ie("transform",n.transform())}})}}return i})(),Tx=i=>({zoom:i.k,x:i.x,y:i.y}),DpA=i=>{if(i instanceof Event&&i.target instanceof Element)return i.target},M5=i=>Math.round(i*100)/100;function ul(i,e){return Math.ceil(i/e)*e}var c1=(()=>{class i{constructor(){this.status=mA({state:"idle",payload:null})}setIdleStatus(){this.status.set({state:"idle",payload:null})}setConnectionStartStatus(A,t){this.status.set({state:"connection-start",payload:{source:A,sourceHandle:t}})}setReconnectionStartStatus(A,t,n){this.status.set({state:"reconnection-start",payload:{source:A,sourceHandle:t,oldEdge:n}})}setConnectionValidationStatus(A,t,n,o,a){this.status.set({state:"connection-validation",payload:{source:t,target:n,sourceHandle:o,targetHandle:a,valid:A}})}setReconnectionValidationStatus(A,t,n,o,a,r){this.status.set({state:"reconnection-validation",payload:{source:t,target:n,sourceHandle:o,targetHandle:a,valid:A,oldEdge:r}})}setConnectionEndStatus(A,t,n,o){this.status.set({state:"connection-end",payload:{source:A,target:t,sourceHandle:n,targetHandle:o}})}setReconnectionEndStatus(A,t,n,o,a){this.status.set({state:"reconnection-end",payload:{source:A,target:t,sourceHandle:n,targetHandle:o,oldEdge:a}})}setNodeDragStartStatus(A){this.status.set({state:"node-drag-start",payload:{node:A}})}setNodeDragEndStatus(A){this.status.set({state:"node-drag-end",payload:{node:A}})}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275prov=jA({token:i,factory:i.\u0275fac})}}return i})();function qW(i){return i.state==="node-drag-start"}function vpA(i){return i.state==="node-drag-end"}var lZ=(()=>{class i{constructor(){this.entitiesService=w(pl),this.settingsService=w(as),this.flowStatusService=w(c1)}enable(A,t){zs(A).call(this.getDragBehavior(t))}disable(A){zs(A).call(HD().on("drag",null))}destroy(A){zs(A).on(".drag",null)}getDragBehavior(A){let t=[],n=[],o=a=>A.dragHandlesCount()?!!a.target.closest(".vflow-drag-handle"):!0;return HD().filter(o).on("start",a=>{t=this.getDragNodes(A),this.flowStatusService.setNodeDragStartStatus(A),n=t.map(r=>({x:r.point().x-a.x,y:r.point().y-a.y}))}).on("drag",a=>{t.forEach((r,s)=>{let l={x:M5(a.x+n[s].x),y:M5(a.y+n[s].y)};this.moveNode(r,l)})}).on("end",()=>{this.flowStatusService.setNodeDragEndStatus(A)})}getDragNodes(A){return A.selected()?this.entitiesService.nodes().filter(t=>t.selected()&&t.draggable()):[A]}moveNode(A,t){t=this.alignToGrid(t);let n=A.parent();n&&(t.x=Math.min(n.width()-A.width(),t.x),t.x=Math.max(0,t.x),t.y=Math.min(n.height()-A.height(),t.y),t.y=Math.max(0,t.y)),A.setPoint(t)}alignToGrid(A){let[t,n]=this.settingsService.snapGrid();return t>1&&(A.x=ul(A.x,t)),n>1&&(A.y=ul(A.y,n)),A}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275prov=jA({token:i,factory:i.\u0275fac})}}return i})(),S5=(()=>{class i{constructor(){this.templateRef=w(wo)}static ngTemplateContextGuard(A,t){return!0}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275dir=VA({type:i,selectors:[["ng-template","edge",""]]})}}return i})(),WW=(()=>{class i{constructor(){this.templateRef=w(wo)}static ngTemplateContextGuard(A,t){return!0}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275dir=VA({type:i,selectors:[["ng-template","connection",""]]})}}return i})(),ZW=(()=>{class i{constructor(){this.templateRef=w(wo)}static ngTemplateContextGuard(A,t){return!0}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275dir=VA({type:i,selectors:[["ng-template","edgeLabelHtml",""]]})}}return i})(),hE=(()=>{class i{constructor(){this.templateRef=w(wo)}static ngTemplateContextGuard(A,t){return!0}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275dir=VA({type:i,selectors:[["ng-template","nodeHtml",""]]})}}return i})(),XW=(()=>{class i{constructor(){this.templateRef=w(wo)}static ngTemplateContextGuard(A,t){return!0}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275dir=VA({type:i,selectors:[["ng-template","nodeSvg",""]]})}}return i})(),k5=(()=>{class i{constructor(){this.templateRef=w(wo)}static ngTemplateContextGuard(A,t){return!0}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275dir=VA({type:i,selectors:[["ng-template","groupNode",""]]})}}return i})();function $W(i,e){let A=i.reduce((t,n)=>(t[n.rawNode.id]=n,t),{});e.forEach(t=>{t.source.set(A[t.edge.source]),t.target.set(A[t.edge.target])})}function fp(i){try{return new Proxy(i,{apply:()=>{}})(),!0}catch(e){return!1}}var Yx=(()=>{class i{constructor(){this._event$=new ne,this.event$=this._event$.asObservable()}pushEvent(A){this._event$.next(A)}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275prov=jA({token:i,factory:i.\u0275fac})}}return i})(),EE=(()=>{class i{constructor(){this.model=mA(null)}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275prov=jA({token:i,factory:i.\u0275fac})}}return i})(),gZ=(()=>{class i{constructor(){this.eventBus=w(Yx),this.nodeService=w(EE),this.destroyRef=w(Er),this.selected=this.nodeService.model().selected,this.data=mA(void 0)}ngOnInit(){this.trackEvents().pipe(xr(this.destroyRef)).subscribe()}trackEvents(){let A=Object.getOwnPropertyNames(this),t=new Map;for(let n of A){let o=this[n];o instanceof FA&&t.set(o,n),o instanceof RN&&t.set(bpA(o),n)}return Vi(...Array.from(t.keys()).map(n=>n.pipe(mi(o=>{this.eventBus.pushEvent({nodeId:this.nodeService.model()?.rawNode.id??"",eventName:t.get(n),eventPayload:o})}))))}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275dir=VA({type:i,standalone:!1})}}return i})();function bpA(i){return new Fi(e=>{let A=i.subscribe(t=>{e.next(t)});return()=>{A.unsubscribe()}})}var MpA=(()=>{class i extends gZ{constructor(){super(...arguments),this.node=ve.required()}ngOnInit(){let A=this.node().data;A&&(this.data=A),super.ngOnInit()}static{this.\u0275fac=(()=>{let A;return function(n){return(A||(A=Li(i)))(n||i)}})()}static{this.\u0275dir=VA({type:i,inputs:{node:[1,"node"]},standalone:!1,features:[bt]})}}return i})(),SpA=(()=>{class i extends gZ{constructor(){super(...arguments),this.node=ve.required()}ngOnInit(){this.node().data&&this.data.set(this.node().data),super.ngOnInit()}static{this.\u0275fac=(()=>{let A;return function(n){return(A||(A=Li(i)))(n||i)}})()}static{this.\u0275dir=VA({type:i,inputs:{node:[1,"node"]},standalone:!1,features:[bt]})}}return i})();function cZ(i){return Object.prototype.isPrototypeOf.call(SpA,i)}function CZ(i){return Object.prototype.isPrototypeOf.call(MpA,i)}function kpA(i){return typeof i.point=="function"}function _pA(i){return cZ(i.type)?!0:fp(i.type)&&!fp(i.point)}function xpA(i){return CZ(i.type)?!0:fp(i.type)&&fp(i.point)}var _5=2;function RpA(i){return kpA(i)?i:$A(P({},NpA(i)),{id:i.id,type:i.type})}function NpA(i){let e={};for(let A in i)Object.prototype.hasOwnProperty.call(i,A)&&(e[A]=mA(i[A]));return e}function FpA(i,e,A){!e&&wN(i);let t=e??w(St);return A?vr(t,A):t}function mp(i,e){let A=FpA(mp,e?.injector),t;return ye(()=>(t||(t=wa(()=>sr(i,$A(P({},e),{injector:A})))),t()))}function LpA(i){return i.rawNode.type==="default-group"||i.rawNode.type==="template-group"}var gI=(()=>{class i{constructor(){this.flowEntitiesService=w(pl),this.flowSettingsService=w(as),this.viewportService=w(lI),this.nodes=ye(()=>this.flowSettingsService.optimization().virtualization?this.viewportNodesAfterInteraction().sort((A,t)=>A.renderOrder()-t.renderOrder()):[...this.flowEntitiesService.nodes()].sort((A,t)=>A.renderOrder()-t.renderOrder())),this.groups=ye(()=>this.nodes().filter(A=>!!A.children().length||LpA(A))),this.nonGroups=ye(()=>this.nodes().filter(A=>!this.groups().includes(A))),this.viewportNodes=ye(()=>{let A=this.flowEntitiesService.nodes(),t=this.viewportService.readableViewport(),n=this.flowSettingsService.computedFlowWidth(),o=this.flowSettingsService.computedFlowHeight();return A.filter(a=>{let{x:r,y:s}=a.globalPoint(),l=a.width(),g=a.height();return wpA({x:r,y:s,width:l,height:g},t,n,o)})}),this.viewportNodesAfterInteraction=mp(Vi(Fo(this.flowEntitiesService.nodes).pipe(pI(qp),Bt(A=>!!A.length)),this.viewportService.viewportChangeEnd$.pipe(Os(300))).pipe(Se(()=>{let A=this.viewportService.readableViewport(),t=this.flowSettingsService.optimization().virtualizationZoomThreshold;return A.zoom<t?[]:this.viewportNodes()})),{initialValue:[]}),this.maxOrder=ye(()=>Math.max(...this.flowEntitiesService.nodes().map(A=>A.renderOrder())))}pullNode(A){A.renderOrder.set(this.maxOrder()+1),A.children().forEach(t=>this.pullNode(t))}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275prov=jA({token:i,factory:i.\u0275fac})}}return i})();function x5(i,e){e||(e={equal:Object.is});let A;return ye(()=>A=i(A),e)}var GpA=(()=>{class i{static{this.defaultWidth=100}static{this.defaultHeight=50}static{this.defaultColor="#1b262c"}constructor(A){this.rawNode=A,this.entitiesService=w(pl),this.settingsService=w(as),this.nodeRenderingService=w(gI),this.isVisible=mA(!1),this.point=mA({x:0,y:0}),this.width=mA(i.defaultWidth),this.height=mA(i.defaultHeight),this.size=ye(()=>({width:this.width(),height:this.height()})),this.styleWidth=ye(()=>this.controlledByResizer()?`${this.width()}px`:"100%"),this.styleHeight=ye(()=>this.controlledByResizer()?`${this.height()}px`:"100%"),this.foWidth=ye(()=>this.width()+_5),this.foHeight=ye(()=>this.height()+_5),this.renderOrder=mA(0),this.selected=mA(!1),this.preview=mA({style:{}}),this.globalPoint=ye(()=>{let n=this.parent(),o=this.point().x,a=this.point().y;for(;n!==null;)o+=n.point().x,a+=n.point().y,n=n.parent();return{x:o,y:a}}),this.pointTransform=ye(()=>`translate(${this.globalPoint().x}, ${this.globalPoint().y})`),this.handles=mA([]),this.draggable=mA(!0),this.dragHandlesCount=mA(0),this.magnetRadius=20,this.isComponentType=_pA(this.rawNode)||xpA(this.rawNode),this.shouldLoad=x5(n=>{if(n||this.settingsService.optimization().lazyLoadTrigger==="immediate")return!0;if(this.settingsService.optimization().lazyLoadTrigger==="viewport"){if(cZ(this.rawNode.type)||CZ(this.rawNode.type))return!0;if(fp(this.rawNode.type)||this.rawNode.type==="html-template"||this.rawNode.type==="svg-template"||this.rawNode.type==="template-group")return this.nodeRenderingService.viewportNodes().includes(this)}return!0}),this.componentInstance$=Fo(this.shouldLoad).pipe(Bt(Boolean),Mi(()=>this.rawNode.type()),aa(()=>oe(this.rawNode.type)),Js(1)),this.text=mA(""),this.componentTypeInputs={node:this.rawNode},this.parent=ye(()=>this.entitiesService.nodes().find(n=>n.rawNode.id===this.parentId())??null),this.children=ye(()=>this.entitiesService.nodes().filter(n=>n.parentId()===this.rawNode.id)),this.color=mA(i.defaultColor),this.controlledByResizer=mA(!1),this.resizable=mA(!1),this.resizing=mA(!1),this.resizerTemplate=mA(null),this.context={$implicit:{}},this.parentId=mA(null);let t=RpA(A);t.point&&(this.point=t.point),t.width&&(this.width=t.width),t.height&&(this.height=t.height),t.draggable&&(this.draggable=t.draggable),t.parentId&&(this.parentId=t.parentId),t.preview&&(this.preview=t.preview),t.type==="default-group"&&t.color&&(this.color=t.color),t.type==="default-group"&&t.resizable&&(this.resizable=t.resizable),t.type==="default"&&t.text&&(this.text=t.text),t.type==="html-template"&&(this.context={$implicit:{node:A,selected:this.selected.asReadonly(),shouldLoad:this.shouldLoad}}),t.type==="svg-template"&&(this.context={$implicit:{node:A,selected:this.selected.asReadonly(),width:this.width.asReadonly(),height:this.height.asReadonly(),shouldLoad:this.shouldLoad}}),t.type==="template-group"&&(this.context={$implicit:{node:A,selected:this.selected.asReadonly(),width:this.width.asReadonly(),height:this.height.asReadonly(),shouldLoad:this.shouldLoad}}),this.point$=Fo(this.point),this.width$=Fo(this.width),this.height$=Fo(this.height),this.size$=Fo(this.size),this.selected$=Fo(this.selected),this.handles$=Fo(this.handles)}setPoint(A){this.point.set(A)}}return i})(),up=class{constructor(e){this.edgeLabel=e,this.size=mA({width:0,height:0})}};function GC(i,e,A){return{x:(1-A)*i.x+A*e.x,y:(1-A)*i.y+A*e.y}}function Hx({sourcePoint:i,targetPoint:e}){return{path:`M ${i.x},${i.y}L ${e.x},${e.y}`,labelPoints:{start:GC(i,e,.15),center:GC(i,e,.5),end:GC(i,e,.85)}}}function zx({sourcePoint:i,targetPoint:e,sourcePosition:A,targetPosition:t}){let n={x:i.x-e.x,y:i.y-e.y},o=AZ(i,A,n),a=AZ(e,t,n),r=`M${i.x},${i.y} C${o.x},${o.y} ${a.x},${a.y} ${e.x},${e.y}`;return KpA(r,i,e,o,a)}function AZ(i,e,A){let t={x:0,y:0};switch(e){case"top":t.y=1;break;case"bottom":t.y=-1;break;case"right":t.x=1;break;case"left":t.x=-1;break}let n={x:A.x*Math.abs(t.x),y:A.y*Math.abs(t.y)},a=.25*25*Math.sqrt(Math.abs(n.x+n.y));return{x:i.x+t.x*a,y:i.y-t.y*a}}function KpA(i,e,A,t,n){return{path:i,labelPoints:{start:Ox(e,A,t,n,.1),center:Ox(e,A,t,n,.5),end:Ox(e,A,t,n,.9)}}}function Ox(i,e,A,t,n){let o=GC(i,A,n),a=GC(A,t,n),r=GC(t,e,n);return GC(GC(o,a,n),GC(a,r,n),n)}var eZ={left:{x:-1,y:0},right:{x:1,y:0},top:{x:0,y:-1},bottom:{x:0,y:1}};function UpA(i,e){let A=Math.abs(e.x-i.x)/2,t=e.x<i.x?e.x+A:e.x-A,n=Math.abs(e.y-i.y)/2,o=e.y<i.y?e.y+n:e.y-n;return[t,o,A,n]}var TpA=({source:i,sourcePosition:e="bottom",target:A})=>e==="left"||e==="right"?i.x<A.x?{x:1,y:0}:{x:-1,y:0}:i.y<A.y?{x:0,y:1}:{x:0,y:-1},tZ=(i,e)=>Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2));function OpA({source:i,sourcePosition:e="bottom",target:A,targetPosition:t="top",offset:n}){let o=eZ[e],a=eZ[t],r={x:i.x+o.x*n,y:i.y+o.y*n},s={x:A.x+a.x*n,y:A.y+a.y*n},l=TpA({source:r,sourcePosition:e,target:s}),g=l.x!==0?"x":"y",C=l[g],d=[],B,u,E={x:0,y:0},f={x:0,y:0},[m,v]=UpA(i,A);if(o[g]*a[g]===-1){B=m,u=v;let k=[{x:B,y:r.y},{x:B,y:s.y}],M=[{x:r.x,y:u},{x:s.x,y:u}];o[g]===C?d=g==="x"?k:M:d=g==="x"?M:k}else{let k=[{x:r.x,y:s.y}],M=[{x:s.x,y:r.y}];if(g==="x"?d=o.x===C?M:k:d=o.y===C?k:M,e===t){let X=Math.abs(i[g]-A[g]);if(X<=n){let eA=Math.min(n-1,n-X);o[g]===C?E[g]=(r[g]>i[g]?-1:1)*eA:f[g]=(s[g]>A[g]?-1:1)*eA}}if(e!==t){let X=g==="x"?"y":"x",eA=o[g]===a[X],Z=r[X]>s[X],CA=r[X]<s[X];(o[g]===1&&(!eA&&Z||eA&&CA)||o[g]!==1&&(!eA&&CA||eA&&Z))&&(d=g==="x"?k:M)}let x={x:r.x+E.x,y:r.y+E.y},F={x:s.x+f.x,y:s.y+f.y},z=Math.max(Math.abs(x.x-d[0].x),Math.abs(F.x-d[0].x)),j=Math.max(Math.abs(x.y-d[0].y),Math.abs(F.y-d[0].y));z>=j?(B=(x.x+F.x)/2,u=d[0].y):(B=d[0].x,u=(x.y+F.y)/2)}return[[i,{x:r.x+E.x,y:r.y+E.y},...d,{x:s.x+f.x,y:s.y+f.y},A],B,u]}function JpA(i,e,A,t){let n=Math.min(tZ(i,e)/2,tZ(e,A)/2,t),{x:o,y:a}=e;if(i.x===o&&o===A.x||i.y===a&&a===A.y)return`L${o} ${a}`;if(i.y===a){let l=i.x<A.x?-1:1,g=i.y<A.y?1:-1;return`L ${o+n*l},${a}Q ${o},${a} ${o},${a+n*g}`}let r=i.x<A.x?1:-1,s=i.y<A.y?-1:1;return`L ${o},${a+n*s}Q ${o},${a} ${o+n*r},${a}`}function IE({sourcePoint:i,targetPoint:e,sourcePosition:A,targetPosition:t},n=5){let[o,a,r]=OpA({source:i,sourcePosition:A,target:e,targetPosition:t,offset:20}),s=o.reduce((u,E,f)=>{let m="";return f>0&&f<o.length-1?m=JpA(o[f-1],E,o[f+1],n):m=`${f===0?"M":"L"}${E.x} ${E.y}`,u+=m,u},""),l=o.length;if(l<2)return{path:s,labelPoints:{start:{x:a,y:r},center:{x:a,y:r},end:{x:a,y:r}}};let g=new Array(l-1),C=new Array(l);C[0]=0;let d=0;for(let u=0;u<l-1;u++){let E=o[u+1].x-o[u].x,f=o[u+1].y-o[u].y,m=Math.sqrt(E*E+f*f);g[u]=m,d+=m,C[u+1]=d}let B=u=>{let E=d*u;if(E<=0)return o[0];if(E>=d)return o[l-1];let f=0,m=l-1;for(;f<m-1;){let F=f+m>>>1;C[F]<E?f=F:m=F}let v=C[f],k=(E-v)/g[f],M=o[f],x=o[f+1];return{x:M.x+(x.x-M.x)*k,y:M.y+(x.y-M.y)*k}};return{path:s,labelPoints:{start:B(.15),center:{x:a,y:r},end:B(.85)}}}var Px=class{constructor(e){this.edge=e,this.flowEntitiesService=w(pl),this.source=mA(void 0),this.target=mA(void 0),this.selected=mA(!1),this.selected$=Fo(this.selected),this.shouldLoad=ye(()=>(this.source()?.shouldLoad()??!1)&&(this.target()?.shouldLoad()??!1)),this.renderOrder=mA(0),this.detached=ye(()=>{let A=this.source(),t=this.target();if(!A||!t)return!0;let n=!1,o=!1;return this.edge.sourceHandle?n=!!A.handles().find(a=>a.rawHandle.id===this.edge.sourceHandle):n=!!A.handles().find(a=>a.rawHandle.type==="source"),this.edge.targetHandle?o=!!t.handles().find(a=>a.rawHandle.id===this.edge.targetHandle):o=!!t.handles().find(a=>a.rawHandle.type==="target"),!n||!o}),this.detached$=Fo(this.detached),this.path=ye(()=>{let A=this.sourceHandle(),t=this.targetHandle();if(!A||!t)return{path:""};let n=this.getPathFactoryParams(A,t);switch(this.curve){case"straight":return Hx(n);case"bezier":return zx(n);case"smooth-step":return IE(n);case"step":return IE(n,0);default:return this.curve(n)}}),this.sourceHandle=x5(A=>{let t=null;return this.floating?t=this.closestHandles().sourceHandle:this.edge.sourceHandle?t=this.source()?.handles().find(n=>n.rawHandle.id===this.edge.sourceHandle)??null:t=this.source()?.handles().find(n=>n.rawHandle.type==="source")??null,t===null?A:t}),this.targetHandle=x5(A=>{let t=null;return this.floating?t=this.closestHandles().targetHandle:this.edge.targetHandle?t=this.target()?.handles().find(n=>n.rawHandle.id===this.edge.targetHandle)??null:t=this.target()?.handles().find(n=>n.rawHandle.type==="target")??null,t===null?A:t}),this.closestHandles=ye(()=>{let A=this.source(),t=this.target();if(!A||!t)return{sourceHandle:null,targetHandle:null};let n=this.flowEntitiesService.connection().mode==="strict"?A.handles().filter(l=>l.rawHandle.type==="source"):A.handles(),o=this.flowEntitiesService.connection().mode==="strict"?t.handles().filter(l=>l.rawHandle.type==="target"):t.handles();if(n.length===0||o.length===0)return{sourceHandle:null,targetHandle:null};let a=1/0,r=null,s=null;for(let l of n)for(let g of o){let C=l.pointAbsolute(),d=g.pointAbsolute(),B=Math.sqrt(Math.pow(C.x-d.x,2)+Math.pow(C.y-d.y,2));B<a&&(a=B,r=l,s=g)}return{sourceHandle:r,targetHandle:s}}),this.markerStartUrl=ye(()=>{let A=this.edge.markers?.start;return A?`url(#${BE(JSON.stringify(A))})`:""}),this.markerEndUrl=ye(()=>{let A=this.edge.markers?.end;return A?`url(#${BE(JSON.stringify(A))})`:""}),this.context={$implicit:{edge:this.edge,path:ye(()=>this.path().path),markerStart:this.markerStartUrl,markerEnd:this.markerEndUrl,selected:this.selected.asReadonly(),shouldLoad:this.shouldLoad}},this.edgeLabels={},this.type=e.type??"default",this.curve=e.curve??"bezier",this.reconnectable=e.reconnectable??!1,this.floating=e.floating??!1,e.edgeLabels?.start&&(this.edgeLabels.start=new up(e.edgeLabels.start)),e.edgeLabels?.center&&(this.edgeLabels.center=new up(e.edgeLabels.center)),e.edgeLabels?.end&&(this.edgeLabels.end=new up(e.edgeLabels.end))}getPathFactoryParams(e,A){return{mode:"edge",edge:this.edge,sourcePoint:e.pointAbsolute(),targetPoint:A.pointAbsolute(),sourcePosition:e.rawHandle.position,targetPosition:A.rawHandle.position,allEdges:this.flowEntitiesService.rawEdges(),allNodes:this.flowEntitiesService.rawNodes()}}},R5=class{static nodes(e,A){let t=new Map;return A.forEach(n=>t.set(n.rawNode,n)),e.map(n=>t.get(n)??new GpA(n))}static edges(e,A){let t=new Map;return A.forEach(n=>t.set(n.edge,n)),e.map(n=>t.has(n)?t.get(n):new Px(n))}},YpA=25,jx=(()=>{class i{constructor(){this.entitiesService=w(pl),this.nodesPositionChange$=Fo(this.entitiesService.nodes).pipe(Mi(A=>Vi(...A.map(t=>t.point$.pipe(Dl(1),Se(()=>t))))),Se(A=>[{type:"position",id:A.rawNode.id,point:A.point()},...this.entitiesService.nodes().filter(t=>t!==A&&t.selected()).map(t=>({type:"position",id:t.rawNode.id,point:t.point()}))])),this.nodeSizeChange$=Fo(this.entitiesService.nodes).pipe(Mi(A=>Vi(...A.map(t=>t.size$.pipe(Dl(1),Se(()=>t))))),Se(A=>[{type:"size",id:A.rawNode.id,size:A.size()}])),this.nodeAddChange$=Fo(this.entitiesService.nodes).pipe(YC(),Se(([A,t])=>t.filter(n=>!A.includes(n))),Bt(A=>!!A.length),Se(A=>A.map(t=>({type:"add",id:t.rawNode.id})))),this.nodeRemoveChange$=Fo(this.entitiesService.nodes).pipe(YC(),Se(([A,t])=>A.filter(n=>!t.includes(n))),Bt(A=>!!A.length),Se(A=>A.map(t=>({type:"remove",id:t.rawNode.id})))),this.nodeSelectedChange$=Fo(this.entitiesService.nodes).pipe(Mi(A=>Vi(...A.map(t=>t.selected$.pipe(xg(),Dl(1),Se(()=>t))))),Se(A=>[{type:"select",id:A.rawNode.id,selected:A.selected()}])),this.changes$=Vi(this.nodesPositionChange$,this.nodeSizeChange$,this.nodeAddChange$,this.nodeRemoveChange$,this.nodeSelectedChange$).pipe(pI(qp,YpA))}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275prov=jA({token:i,factory:i.\u0275fac})}}return i})(),HpA=(i,e)=>i.length===e.length&&[...new Set([...i,...e])].every(A=>i.filter(t=>t===A).length===e.filter(t=>t===A).length),Vx=(()=>{class i{constructor(){this.entitiesService=w(pl),this.edgeDetachedChange$=Vi(Fo(ye(()=>{let A=this.entitiesService.nodes();return wa(this.entitiesService.edges).filter(({source:n,target:o})=>!A.includes(n())||!A.includes(o()))})),Fo(this.entitiesService.edges).pipe(Mi(A=>QN(...A.map(t=>t.detached$.pipe(Se(()=>t))))),Se(A=>A.filter(t=>t.detached())),Dl(2))).pipe(xg(HpA),Bt(A=>!!A.length),Se(A=>A.map(({edge:t})=>({type:"detached",id:t.id})))),this.edgeAddChange$=Fo(this.entitiesService.edges).pipe(YC(),Se(([A,t])=>t.filter(n=>!A.includes(n))),Bt(A=>!!A.length),Se(A=>A.map(({edge:t})=>({type:"add",id:t.id})))),this.edgeRemoveChange$=Fo(this.entitiesService.edges).pipe(YC(),Se(([A,t])=>A.filter(n=>!t.includes(n))),Bt(A=>!!A.length),Se(A=>A.map(({edge:t})=>({type:"remove",id:t.id})))),this.edgeSelectChange$=Fo(this.entitiesService.edges).pipe(Mi(A=>Vi(...A.map(t=>t.selected$.pipe(xg(),Dl(1),Se(()=>t))))),Se(A=>[{type:"select",id:A.edge.id,selected:A.selected()}])),this.changes$=Vi(this.edgeDetachedChange$,this.edgeAddChange$,this.edgeRemoveChange$,this.edgeSelectChange$).pipe(pI(qp))}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275prov=jA({token:i,factory:i.\u0275fac})}}return i})(),zpA=(()=>{class i{constructor(){this.nodesChangeService=w(jx),this.edgesChangeService=w(Vx),this.onNodesChange=Hn(this.nodesChangeService.changes$),this.onNodesChangePosition=Hn(this.nodeChangesOfType("position"),{alias:"onNodesChange.position"}),this.onNodesChangePositionSignle=Hn(this.singleChange(this.nodeChangesOfType("position")),{alias:"onNodesChange.position.single"}),this.onNodesChangePositionMany=Hn(this.manyChanges(this.nodeChangesOfType("position")),{alias:"onNodesChange.position.many"}),this.onNodesChangeSize=Hn(this.nodeChangesOfType("size"),{alias:"onNodesChange.size"}),this.onNodesChangeSizeSingle=Hn(this.singleChange(this.nodeChangesOfType("size")),{alias:"onNodesChange.size.single"}),this.onNodesChangeSizeMany=Hn(this.manyChanges(this.nodeChangesOfType("size")),{alias:"onNodesChange.size.many"}),this.onNodesChangeAdd=Hn(this.nodeChangesOfType("add"),{alias:"onNodesChange.add"}),this.onNodesChangeAddSingle=Hn(this.singleChange(this.nodeChangesOfType("add")),{alias:"onNodesChange.add.single"}),this.onNodesChangeAddMany=Hn(this.manyChanges(this.nodeChangesOfType("add")),{alias:"onNodesChange.add.many"}),this.onNodesChangeRemove=Hn(this.nodeChangesOfType("remove"),{alias:"onNodesChange.remove"}),this.onNodesChangeRemoveSingle=Hn(this.singleChange(this.nodeChangesOfType("remove")),{alias:"onNodesChange.remove.single"}),this.onNodesChangeRemoveMany=Hn(this.manyChanges(this.nodeChangesOfType("remove")),{alias:"onNodesChange.remove.many"}),this.onNodesChangeSelect=Hn(this.nodeChangesOfType("select"),{alias:"onNodesChange.select"}),this.onNodesChangeSelectSingle=Hn(this.singleChange(this.nodeChangesOfType("select")),{alias:"onNodesChange.select.single"}),this.onNodesChangeSelectMany=Hn(this.manyChanges(this.nodeChangesOfType("select")),{alias:"onNodesChange.select.many"}),this.onEdgesChange=Hn(this.edgesChangeService.changes$),this.onNodesChangeDetached=Hn(this.edgeChangesOfType("detached"),{alias:"onEdgesChange.detached"}),this.onNodesChangeDetachedSingle=Hn(this.singleChange(this.edgeChangesOfType("detached")),{alias:"onEdgesChange.detached.single"}),this.onNodesChangeDetachedMany=Hn(this.manyChanges(this.edgeChangesOfType("detached")),{alias:"onEdgesChange.detached.many"}),this.onEdgesChangeAdd=Hn(this.edgeChangesOfType("add"),{alias:"onEdgesChange.add"}),this.onEdgeChangeAddSingle=Hn(this.singleChange(this.edgeChangesOfType("add")),{alias:"onEdgesChange.add.single"}),this.onEdgeChangeAddMany=Hn(this.manyChanges(this.edgeChangesOfType("add")),{alias:"onEdgesChange.add.many"}),this.onEdgeChangeRemove=Hn(this.edgeChangesOfType("remove"),{alias:"onEdgesChange.remove"}),this.onEdgeChangeRemoveSingle=Hn(this.singleChange(this.edgeChangesOfType("remove")),{alias:"onEdgesChange.remove.single"}),this.onEdgeChangeRemoveMany=Hn(this.manyChanges(this.edgeChangesOfType("remove")),{alias:"onEdgesChange.remove.many"}),this.onEdgeChangeSelect=Hn(this.edgeChangesOfType("select"),{alias:"onEdgesChange.select"}),this.onEdgeChangeSelectSingle=Hn(this.singleChange(this.edgeChangesOfType("select")),{alias:"onEdgesChange.select.single"}),this.onEdgeChangeSelectMany=Hn(this.manyChanges(this.edgeChangesOfType("select")),{alias:"onEdgesChange.select.many"})}nodeChangesOfType(A){return this.nodesChangeService.changes$.pipe(Se(t=>t.filter(n=>n.type===A)),Bt(t=>!!t.length))}edgeChangesOfType(A){return this.edgesChangeService.changes$.pipe(Se(t=>t.filter(n=>n.type===A)),Bt(t=>!!t.length))}singleChange(A){return A.pipe(Bt(t=>t.length===1),Se(([t])=>t))}manyChanges(A){return A.pipe(Bt(t=>t.length>1))}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275dir=VA({type:i,selectors:[["","changesController",""]],outputs:{onNodesChange:"onNodesChange",onNodesChangePosition:"onNodesChange.position",onNodesChangePositionSignle:"onNodesChange.position.single",onNodesChangePositionMany:"onNodesChange.position.many",onNodesChangeSize:"onNodesChange.size",onNodesChangeSizeSingle:"onNodesChange.size.single",onNodesChangeSizeMany:"onNodesChange.size.many",onNodesChangeAdd:"onNodesChange.add",onNodesChangeAddSingle:"onNodesChange.add.single",onNodesChangeAddMany:"onNodesChange.add.many",onNodesChangeRemove:"onNodesChange.remove",onNodesChangeRemoveSingle:"onNodesChange.remove.single",onNodesChangeRemoveMany:"onNodesChange.remove.many",onNodesChangeSelect:"onNodesChange.select",onNodesChangeSelectSingle:"onNodesChange.select.single",onNodesChangeSelectMany:"onNodesChange.select.many",onEdgesChange:"onEdgesChange",onNodesChangeDetached:"onEdgesChange.detached",onNodesChangeDetachedSingle:"onEdgesChange.detached.single",onNodesChangeDetachedMany:"onEdgesChange.detached.many",onEdgesChangeAdd:"onEdgesChange.add",onEdgeChangeAddSingle:"onEdgesChange.add.single",onEdgeChangeAddMany:"onEdgesChange.add.many",onEdgeChangeRemove:"onEdgesChange.remove",onEdgeChangeRemoveSingle:"onEdgesChange.remove.single",onEdgeChangeRemoveMany:"onEdgesChange.remove.many",onEdgeChangeSelect:"onEdgesChange.select",onEdgeChangeSelectSingle:"onEdgesChange.select.single",onEdgeChangeSelectMany:"onEdgesChange.select.many"}})}}return i})(),L5=(()=>{class i{constructor(){this.host=w(ce).nativeElement,this.initialTouch$=new ne,this.prevTouchEvent=null,this.mouseMovement$=Nc(this.host,"mousemove").pipe(Se(A=>({x:A.clientX,y:A.clientY,movementX:A.movementX,movementY:A.movementY,target:A.target,originalEvent:A})),pI(uI),HC()),this.touchMovement$=Vi(this.initialTouch$,Nc(this.host,"touchmove")).pipe(mi(A=>A.preventDefault()),Se(A=>{let t=A.touches[0]?.clientX??0,n=A.touches[0]?.clientY??0,o=this.prevTouchEvent?A.touches[0].pageX-this.prevTouchEvent.touches[0].pageX:0,a=this.prevTouchEvent?A.touches[0].pageY-this.prevTouchEvent.touches[0].pageY:0,r=document.elementFromPoint(t,n);return{x:t,y:n,movementX:o,movementY:a,target:r,originalEvent:A}}),mi(A=>this.prevTouchEvent=A.originalEvent),pI(uI),HC()),this.pointerMovement$=Vi(this.mouseMovement$,this.touchMovement$),this.touchEnd$=Nc(this.host,"touchend").pipe(Se(A=>{let t=A.changedTouches[0]?.clientX??0,n=A.changedTouches[0]?.clientY??0,o=document.elementFromPoint(t,n);return{x:t,y:n,target:o,originalEvent:A}}),mi(()=>this.prevTouchEvent=null),HC()),this.mouseUp$=Nc(this.host,"mouseup").pipe(Se(A=>{let t=A.clientX,n=A.clientY,o=A.target;return{x:t,y:n,target:o,originalEvent:A}}),HC()),this.documentPointerEnd$=Vi(Nc(document,"mouseup"),Nc(document,"touchend")).pipe(HC())}setInitialTouch(A){this.initialTouch$.next(A)}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275dir=VA({type:i,selectors:[["svg","rootPointer",""]]})}}return i})(),pp=(()=>{class i{constructor(){this.pointerMovementDirective=w(L5),this.rootSvg=w(F5).element,this.host=w(ce).nativeElement,this.svgCurrentSpacePoint=ye(()=>{let A=this.pointerMovement();return A?this.documentPointToFlowPoint({x:A.x,y:A.y}):{x:0,y:0}}),this.pointerMovement=sr(this.pointerMovementDirective.pointerMovement$)}documentPointToFlowPoint(A){let t=this.rootSvg.createSVGPoint();return t.x=A.x,t.y=A.y,t.matrixTransform(this.host.getScreenCTM().inverse())}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275dir=VA({type:i,selectors:[["g","spacePointContext",""]]})}}return i})();function PpA(i){return typeof i=="string"?{type:"solid",color:i}:i}function N5(i,e,A){let t=A.value;return A.value=function(...n){queueMicrotask(()=>{t?.apply(this,n)})},A}var dZ=(()=>{class i{constructor(){this.toolbars=mA([]),this.nodeToolbarsMap=ye(()=>{let A=new Map;return this.toolbars().forEach(t=>{let n=A.get(t.node)??[];A.set(t.node,[...n,t])}),A})}addToolbar(A){this.toolbars.update(t=>[...t,A])}removeToolbar(A){this.toolbars.update(t=>t.filter(n=>n!==A))}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275prov=jA({token:i,factory:i.\u0275fac})}}return jE([N5],i.prototype,"addToolbar",null),jE([N5],i.prototype,"removeToolbar",null),i})();function G5(i,e){return new Fi(A=>{let t=new ResizeObserver(n=>{e.run(()=>A.next(n))});return i.forEach(n=>t.observe(n)),()=>t.disconnect()})}var jpA=(()=>{class i{constructor(){this.zone=w(We),this.destroyRef=w(Er),this.settingsService=w(as),this.model=ve.required(),this.edgeModel=ve.required(),this.point=ve({x:0,y:0}),this.htmlTemplate=ve(),this.edgeLabelWrapperRef=Yo.required("edgeLabelWrapper"),this.edgeLabelPoint=ye(()=>{let A=this.point(),{width:t,height:n}=this.model().size();return{x:A.x-t/2,y:A.y-n/2}}),this.edgeLabelStyle=ye(()=>{let A=this.model().edgeLabel;if(A.type==="default"&&A.style){let t=this.settingsService.background(),n="transparent";return t.type==="dots"&&(n=t.backgroundColor??"#fff"),t.type==="solid"&&(n=t.color),A.style.backgroundColor=A.style.backgroundColor??n,A.style}return null})}ngAfterViewInit(){let A=this.edgeLabelWrapperRef().nativeElement;G5([A],this.zone).pipe(Yn(null),mi(()=>{let t=A.clientWidth+_5,n=A.clientHeight+_5;this.model().size.set({width:t,height:n})}),xr(this.destroyRef)).subscribe()}getLabelContext(){return{$implicit:{edge:this.edgeModel().edge,label:this.model().edgeLabel}}}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275cmp=vA({type:i,selectors:[["g","edgeLabel",""]],viewQuery:function(t,n){t&1&&ls(n.edgeLabelWrapperRef,juA,5),t&2&&br()},inputs:{model:[1,"model"],edgeModel:[1,"edgeModel"],point:[1,"point"],htmlTemplate:[1,"htmlTemplate"]},attrs:VuA,decls:1,vars:1,consts:[["edgeLabelWrapper",""],[1,"edge-label-wrapper"],[4,"ngTemplateOutlet","ngTemplateOutletContext"]],template:function(t,n){if(t&1&&T(0,$uA,2,2),t&2){let o;O((o=n.model())?0:-1,o)}},dependencies:[Uc],styles:[".edge-label-wrapper[_ngcontent-%COMP%]{width:max-content;margin-top:1px;margin-left:1px}"],changeDetection:0})}}return i})();function IZ(i){let e={};return i.sourceHandle.rawHandle.type==="source"?(e.source=i.source,e.sourceHandle=i.sourceHandle):(e.source=i.target,e.sourceHandle=i.targetHandle),i.targetHandle.rawHandle.type==="target"?(e.target=i.target,e.targetHandle=i.targetHandle):(e.target=i.source,e.targetHandle=i.sourceHandle),e}var BZ=(()=>{class i{constructor(){this.statusService=w(c1),this.flowEntitiesService=w(pl),this.onConnect=Hn(Fo(this.statusService.status).pipe(Bt(A=>A.state==="connection-end"),Se(A=>D5(A,this.isStrictMode())),mi(()=>this.statusService.setIdleStatus()),Bt(A=>this.flowEntitiesService.connection().validator(A)))),this.connect=Hn(Fo(this.statusService.status).pipe(Bt(A=>A.state==="connection-end"),Se(A=>D5(A,this.isStrictMode())),mi(()=>this.statusService.setIdleStatus()),Bt(A=>this.flowEntitiesService.connection().validator(A)))),this.onReconnect=Hn(Fo(this.statusService.status).pipe(Bt(A=>A.state==="reconnection-end"),Se(A=>{let t=D5(A,this.isStrictMode()),n=A.payload.oldEdge.edge;return{connection:t,oldEdge:n}}),mi(()=>this.statusService.setIdleStatus()),Bt(({connection:A})=>this.flowEntitiesService.connection().validator(A)))),this.reconnect=Hn(Fo(this.statusService.status).pipe(Bt(A=>A.state==="reconnection-end"),Se(A=>{let t=D5(A,this.isStrictMode()),n=A.payload.oldEdge.edge;return{connection:t,oldEdge:n}}),mi(()=>this.statusService.setIdleStatus()),Bt(({connection:A})=>this.flowEntitiesService.connection().validator(A)))),this.isStrictMode=ye(()=>this.flowEntitiesService.connection().mode==="strict")}startConnection(A){this.statusService.setConnectionStartStatus(A.parentNode,A)}startReconnection(A,t){this.statusService.setReconnectionStartStatus(A.parentNode,A,t)}validateConnection(A){let t=this.statusService.status();if(t.state==="connection-start"||t.state==="reconnection-start"){let n=t.state==="reconnection-start",o=t.payload.source,a=A.parentNode,r=t.payload.sourceHandle,s=A;if(this.isStrictMode()){let g=IZ({source:t.payload.source,sourceHandle:t.payload.sourceHandle,target:A.parentNode,targetHandle:A});o=g.source,a=g.target,r=g.sourceHandle,s=g.targetHandle}let l=this.flowEntitiesService.connection().validator({source:o.rawNode.id,target:a.rawNode.id,sourceHandle:r.rawHandle.id,targetHandle:s.rawHandle.id});A.state.set(l?"valid":"invalid"),n?this.statusService.setReconnectionValidationStatus(l,t.payload.source,A.parentNode,t.payload.sourceHandle,A,t.payload.oldEdge):this.statusService.setConnectionValidationStatus(l,t.payload.source,A.parentNode,t.payload.sourceHandle,A)}}resetValidateConnection(A){A.state.set("idle");let t=this.statusService.status();(t.state==="connection-validation"||t.state==="reconnection-validation")&&(t.state==="reconnection-validation"?this.statusService.setReconnectionStartStatus(t.payload.source,t.payload.sourceHandle,t.payload.oldEdge):this.statusService.setConnectionStartStatus(t.payload.source,t.payload.sourceHandle))}endConnection(){let A=this.statusService.status();if(A.state==="connection-validation"||A.state==="reconnection-validation"){let t=A.state==="reconnection-validation",n=A.payload.source,o=A.payload.sourceHandle,a=A.payload.target,r=A.payload.targetHandle;t?this.statusService.setReconnectionEndStatus(n,a,o,r,A.payload.oldEdge):this.statusService.setConnectionEndStatus(n,a,o,r)}}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275dir=VA({type:i,selectors:[["","onConnect",""],["","onReconnect",""],["","connect",""],["","reconnect",""]],outputs:{onConnect:"onConnect",connect:"connect",onReconnect:"onReconnect",reconnect:"reconnect"}})}}return i})();function D5(i,e){let A=i.payload.source,t=i.payload.target,n=i.payload.sourceHandle,o=i.payload.targetHandle;if(e){let g=IZ({source:i.payload.source,sourceHandle:i.payload.sourceHandle,target:i.payload.target,targetHandle:i.payload.targetHandle});A=g.source,t=g.target,n=g.sourceHandle,o=g.targetHandle}let a=A.rawNode.id,r=t.rawNode.id,s=n.rawHandle.id,l=o.rawHandle.id;return{source:a,target:r,sourceHandle:s,targetHandle:l}}var wp=(()=>{class i{constructor(){this.flowEntitiesService=w(pl),this.flowSettingsService=w(as),this.edges=ye(()=>this.flowSettingsService.optimization().virtualization?this.viewportEdges().sort((A,t)=>A.renderOrder()-t.renderOrder()):[...this.flowEntitiesService.validEdges()].sort((A,t)=>A.renderOrder()-t.renderOrder())),this.viewportEdges=ye(()=>this.flowEntitiesService.validEdges().filter(A=>{let t=A.sourceHandle(),n=A.targetHandle();return t&&n})),this.maxOrder=ye(()=>Math.max(...this.flowEntitiesService.validEdges().map(A=>A.renderOrder())))}pull(A){A.renderOrder()!==0&&this.maxOrder()===A.renderOrder()||A.renderOrder.set(this.maxOrder()+1)}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275prov=jA({token:i,factory:i.\u0275fac})}}return i})();function VpA(i){return window.TouchEvent&&i instanceof TouchEvent}var $x=(()=>{class i{constructor(){this.hostElement=w(ce).nativeElement,this.pointerMovementDirective=w(L5),this.pointerOver=Si(),this.pointerOut=Si(),this.pointerStart=Si(),this.pointerEnd=Si(),this.wasPointerOver=!1,this.touchEnd=this.pointerMovementDirective.touchEnd$.pipe(Bt(({target:A})=>A===this.hostElement),mi(({originalEvent:A})=>this.pointerEnd.emit(A)),xr()).subscribe(),this.touchOverOut=this.pointerMovementDirective.touchMovement$.pipe(mi(({target:A,originalEvent:t})=>{this.handleTouchOverAndOut(A,t)}),xr()).subscribe()}onPointerStart(A){this.pointerStart.emit(A),VpA(A)&&this.pointerMovementDirective.setInitialTouch(A)}onPointerEnd(A){this.pointerEnd.emit(A)}onMouseOver(A){this.pointerOver.emit(A)}onMouseOut(A){this.pointerOut.emit(A)}handleTouchOverAndOut(A,t){A===this.hostElement?(this.pointerOver.emit(t),this.wasPointerOver=!0):(this.wasPointerOver&&this.pointerOut.emit(t),this.wasPointerOver=!1)}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275dir=VA({type:i,selectors:[["","pointerStart",""],["","pointerEnd",""],["","pointerOver",""],["","pointerOut",""]],hostBindings:function(t,n){t&1&&U("mousedown",function(a){return n.onPointerStart(a)})("touchstart",function(a){return n.onPointerStart(a)})("mouseup",function(a){return n.onPointerEnd(a)})("mouseover",function(a){return n.onMouseOver(a)})("mouseout",function(a){return n.onMouseOut(a)})},outputs:{pointerOver:"pointerOver",pointerOut:"pointerOut",pointerStart:"pointerStart",pointerEnd:"pointerEnd"}})}}return i})(),AR=(()=>{class i{constructor(){this.injector=w(St),this.selectionService=w(yp),this.flowSettingsService=w(as),this.flowStatusService=w(c1),this.edgeRenderingService=w(wp),this.connectionController=w(BZ,{optional:!0}),this.model=ve.required(),this.edgeTemplate=ve(),this.edgeLabelHtmlTemplate=ve(),this.isReconnecting=ye(()=>{let A=this.flowStatusService.status();return(A.state==="reconnection-start"||A.state==="reconnection-validation")&&A.payload.oldEdge===this.model()})}select(){this.flowSettingsService.entitiesSelectable()&&this.selectionService.select(this.model())}pull(){this.flowSettingsService.elevateEdgesOnSelect()&&this.edgeRenderingService.pull(this.model())}startReconnection(A,t){A.stopPropagation(),this.connectionController?.startReconnection(t,this.model())}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275cmp=vA({type:i,selectors:[["g","edge",""]],hostAttrs:[1,"selectable"],hostVars:2,hostBindings:function(t,n){t&2&&ft("visibility",n.isReconnecting()?"hidden":"visible")},inputs:{model:[1,"model"],edgeTemplate:[1,"edgeTemplate"],edgeLabelHtmlTemplate:[1,"edgeLabelHtmlTemplate"]},attrs:A4A,decls:6,vars:6,consts:[[1,"edge"],[1,"interactive-edge",3,"click"],[3,"ngTemplateOutlet","ngTemplateOutletContext","ngTemplateOutletInjector"],["edgeLabel","",3,"model","point","edgeModel","htmlTemplate"],["r","10",1,"reconnect-handle"],["r","10",1,"reconnect-handle",3,"pointerStart"]],template:function(t,n){if(t&1&&(T(0,e4A,2,6),T(1,i4A,1,1),T(2,o4A,1,1),T(3,r4A,1,1),T(4,l4A,1,1),T(5,C4A,2,2)),t&2){let o,a,r;O(n.model().type==="default"?0:-1),Q(),O(n.model().type==="template"&&n.edgeTemplate()?1:-1),Q(),O((o=n.model().edgeLabels.start)?2:-1,o),Q(),O((a=n.model().edgeLabels.center)?3:-1,a),Q(),O((r=n.model().edgeLabels.end)?4:-1,r),Q(),O(n.model().sourceHandle()&&n.model().targetHandle()?5:-1)}},dependencies:[Uc,jpA,$x],styles:[".edge[_ngcontent-%COMP%]{fill:none;stroke-width:2;stroke:#b1b1b7}.edge_selected[_ngcontent-%COMP%]{stroke-width:2.5;stroke:#0f4c75}.interactive-edge[_ngcontent-%COMP%]{fill:none;stroke-width:20;stroke:transparent}.reconnect-handle[_ngcontent-%COMP%]{fill:transparent;cursor:move}"],changeDetection:0})}}return i})(),qx=(()=>{class i{constructor(){this.node=mA(null)}createHandle(A){let t=this.node();t&&t.handles.update(n=>[...n,A])}destroyHandle(A){let t=this.node();t&&t.handles.update(n=>n.filter(o=>o!==A))}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275prov=jA({token:i,factory:i.\u0275fac})}}return jE([N5],i.prototype,"createHandle",null),i})(),qpA=(()=>{class i{constructor(){this.handleModel=ve.required({alias:"handleSizeController"}),this.handleWrapper=w(ce)}ngAfterViewInit(){let A=this.handleWrapper.nativeElement,t=A.getBBox(),n=WpA(A);this.handleModel().size.set({width:t.width+n,height:t.height+n})}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275dir=VA({type:i,selectors:[["","handleSizeController",""]],inputs:{handleModel:[1,"handleSizeController","handleModel"]}})}}return i})();function WpA(i){let e=i.firstElementChild;if(e){let A=getComputedStyle(e).strokeWidth,t=Number(A.replace("px",""));return isNaN(t)?0:t}return 0}var ZpA=(()=>{class i{constructor(){this.selected=ve(!1)}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275cmp=vA({type:i,selectors:[["default-node"]],hostVars:2,hostBindings:function(t,n){t&2&&_A("selected",n.selected())},inputs:{selected:[1,"selected"]},ngContentSelectors:Xx,decls:1,vars:0,template:function(t,n){t&1&&(Ot(),Ze(0))},styles:["[_nghost-%COMP%]{border:1.5px solid #1b262c;border-radius:5px;display:flex;align-items:center;justify-content:center;color:#000;background-color:#fff}.selected[_nghost-%COMP%]{border-width:2px}"],changeDetection:0})}}return i})(),XpA=(()=>{class i{get model(){return this.nodeAccessor.model()}constructor(){this.nodeAccessor=w(EE),this.rootPointer=w(L5),this.viewportService=w(lI),this.spacePointContext=w(pp),this.settingsService=w(as),this.hostRef=w(ce),this.resizable=ve(),this.resizerColor=ve("#2e414c"),this.gap=ve(1.5),this.resizer=Yo.required("resizer"),this.lineGap=3,this.handleSize=6,this.resizeSide=null,this.zoom=ye(()=>this.viewportService.readableViewport().zoom??0),this.minWidth=0,this.minHeight=0,this.maxWidth=1/0,this.maxHeight=1/0,this.resizeOnGlobalMouseMove=this.rootPointer.pointerMovement$.pipe(Bt(()=>this.resizeSide!==null),Bt(A=>A.movementX!==0||A.movementY!==0),mi(A=>this.resize(A)),xr()).subscribe(),this.endResizeOnGlobalMouseUp=this.rootPointer.documentPointerEnd$.pipe(mi(()=>this.endResize()),xr()).subscribe(),Fn(()=>{let A=this.resizable();typeof A=="boolean"?this.model.resizable.set(A):this.model.resizable.set(!0)},{allowSignalWrites:!0})}ngOnInit(){this.model.controlledByResizer.set(!0),this.model.resizerTemplate.set(this.resizer())}ngOnDestroy(){this.model.controlledByResizer.set(!1)}ngAfterViewInit(){this.minWidth=+getComputedStyle(this.hostRef.nativeElement).minWidth.replace("px","")||0,this.minHeight=+getComputedStyle(this.hostRef.nativeElement).minHeight.replace("px","")||0,this.maxWidth=+getComputedStyle(this.hostRef.nativeElement).maxWidth.replace("px","")||1/0,this.maxHeight=+getComputedStyle(this.hostRef.nativeElement).maxHeight.replace("px","")||1/0}startResize(A,t){t.stopPropagation(),this.resizeSide=A,this.model.resizing.set(!0)}resize(A){if(!this.resizeSide)return;let t=$pA(A.movementX,A.movementY,this.zoom()),n=this.applyResize(this.resizeSide,this.model,t,this.getDistanceToEdge(A)),{x:o,y:a,width:r,height:s}=A3A(n,this.model,this.resizeSide,this.minWidth,this.minHeight,this.maxWidth,this.maxHeight);this.model.setPoint({x:o,y:a}),this.model.width.set(r),this.model.height.set(s)}endResize(){this.resizeSide=null,this.model.resizing.set(!1)}getDistanceToEdge(A){let t=this.spacePointContext.documentPointToFlowPoint({x:A.x,y:A.y}),{x:n,y:o}=this.model.globalPoint();return{left:t.x-n,right:t.x-(n+this.model.width()),top:t.y-o,bottom:t.y-(o+this.model.height())}}applyResize(A,t,n,o){let{x:a,y:r}=t.point(),s=t.width(),l=t.height(),[g,C]=this.settingsService.snapGrid();switch(A){case"left":{let d=n.x+o.left,B=ul(a+d,g),u=B-a;return{x:B,y:r,width:s-u,height:l}}case"right":{let d=n.x+o.right,B=ul(s+d,g);return{x:a,y:r,width:B,height:l}}case"top":{let d=n.y+o.top,B=ul(r+d,C),u=B-r;return{x:a,y:B,width:s,height:l-u}}case"bottom":{let d=n.y+o.bottom,B=ul(l+d,C);return{x:a,y:r,width:s,height:B}}case"top-left":{let d=n.x+o.left,B=n.y+o.top,u=ul(a+d,g),E=ul(r+B,C),f=u-a,m=E-r;return{x:u,y:E,width:s-f,height:l-m}}case"top-right":{let d=n.x+o.right,B=n.y+o.top,u=ul(r+B,C),E=u-r;return{x:a,y:u,width:ul(s+d,g),height:l-E}}case"bottom-left":{let d=n.x+o.left,B=n.y+o.bottom,u=ul(a+d,g),E=u-a;return{x:u,y:r,width:s-E,height:ul(l+B,C)}}case"bottom-right":{let d=n.x+o.right,B=n.y+o.bottom;return{x:a,y:r,width:ul(s+d,g),height:ul(l+B,C)}}}}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275cmp=vA({type:i,selectors:[["","resizable",""]],viewQuery:function(t,n){t&1&&ls(n.resizer,d4A,5),t&2&&br()},inputs:{resizable:[1,"resizable"],resizerColor:[1,"resizerColor"],gap:[1,"gap"]},attrs:I4A,ngContentSelectors:Xx,decls:3,vars:0,consts:[["resizer",""],["stroke-width","2",1,"top",3,"pointerStart"],["stroke-width","2",1,"left",3,"pointerStart"],["stroke-width","2",1,"bottom",3,"pointerStart"],["stroke-width","2",1,"right",3,"pointerStart"],[1,"top-left",3,"pointerStart"],[1,"top-right",3,"pointerStart"],[1,"bottom-left",3,"pointerStart"],[1,"bottom-right",3,"pointerStart"]],template:function(t,n){t&1&&(Ot(),kt(0,B4A,9,40,"ng-template",null,0,PC),Ze(2))},dependencies:[$x],styles:[".top[_ngcontent-%COMP%]{cursor:n-resize}.left[_ngcontent-%COMP%]{cursor:w-resize}.right[_ngcontent-%COMP%]{cursor:e-resize}.bottom[_ngcontent-%COMP%]{cursor:s-resize}.top-left[_ngcontent-%COMP%]{cursor:nw-resize}.top-right[_ngcontent-%COMP%]{cursor:ne-resize}.bottom-left[_ngcontent-%COMP%]{cursor:sw-resize}.bottom-right[_ngcontent-%COMP%]{cursor:se-resize}"],changeDetection:0})}}return jE([N5],i.prototype,"ngAfterViewInit",null),i})();function $pA(i,e,A){return{x:M5(i/A),y:M5(e/A)}}function A3A(i,e,A,t,n,o,a){let{x:r,y:s,width:l,height:g}=i;l=Math.max(l,0),g=Math.max(g,0),l=Math.max(t,l),g=Math.max(n,g),l=Math.min(o,l),g=Math.min(a,g),r=Math.min(r,e.point().x+e.width()-t),s=Math.min(s,e.point().y+e.height()-n),r=Math.max(r,e.point().x+e.width()-o),s=Math.max(s,e.point().y+e.height()-a);let C=e.parent();if(C){let B=C.width(),u=C.height(),E=e.point().x,f=e.point().y;r=Math.max(r,0),s=Math.max(s,0),A.includes("left")&&r===0&&(l=Math.min(l,E+e.width())),A.includes("top")&&s===0&&(g=Math.min(g,f+e.height())),l=Math.min(l,B-r),g=Math.min(g,u-s)}let d=sZ(e.children());return d&&(A.includes("left")&&(r=Math.min(r,e.point().x+e.width()-(d.x+d.width)),l=Math.max(l,d.x+d.width)),A.includes("right")&&(l=Math.max(l,d.x+d.width)),A.includes("bottom")&&(g=Math.max(g,d.y+d.height)),A.includes("top")&&(s=Math.min(s,e.point().y+e.height()-(d.y+d.height)),g=Math.max(g,d.y+d.height))),{x:r,y:s,width:l,height:g}}var Wx=class{constructor(e,A){this.rawHandle=e,this.parentNode=A,this.strokeWidth=2,this.size=mA({width:10+2*this.strokeWidth,height:10+2*this.strokeWidth}),this.pointAbsolute=ye(()=>({x:this.parentNode.globalPoint().x+this.hostOffset().x+this.sizeOffset().x,y:this.parentNode.globalPoint().y+this.hostOffset().y+this.sizeOffset().y})),this.state=mA("idle"),this.updateHostSizeAndPosition$=new ne,this.hostSize=sr(this.updateHostSizeAndPosition$.pipe(Se(()=>this.getHostSize())),{initialValue:{width:0,height:0}}),this.hostPosition=sr(this.updateHostSizeAndPosition$.pipe(Se(()=>({x:this.hostReference instanceof HTMLElement?this.hostReference.offsetLeft:0,y:this.hostReference instanceof HTMLElement?this.hostReference.offsetTop:0}))),{initialValue:{x:0,y:0}}),this.hostOffset=ye(()=>{switch(this.rawHandle.position){case"left":return{x:-this.rawHandle.userOffsetX,y:-this.rawHandle.userOffsetY+this.hostPosition().y+this.hostSize().height/2};case"right":return{x:-this.rawHandle.userOffsetX+this.parentNode.size().width,y:-this.rawHandle.userOffsetY+this.hostPosition().y+this.hostSize().height/2};case"top":return{x:-this.rawHandle.userOffsetX+this.hostPosition().x+this.hostSize().width/2,y:-this.rawHandle.userOffsetY};case"bottom":return{x:-this.rawHandle.userOffsetX+this.hostPosition().x+this.hostSize().width/2,y:-this.rawHandle.userOffsetY+this.parentNode.size().height}}}),this.sizeOffset=ye(()=>{switch(this.rawHandle.position){case"left":return{x:-(this.size().width/2),y:0};case"right":return{x:this.size().width/2,y:0};case"top":return{x:0,y:-(this.size().height/2)};case"bottom":return{x:0,y:this.size().height/2}}}),this.hostReference=this.rawHandle.hostReference,this.template=this.rawHandle.template,this.templateContext={$implicit:{point:this.hostOffset,state:this.state,node:this.parentNode.rawNode}}}updateHost(){this.updateHostSizeAndPosition$.next()}getHostSize(){return this.hostReference instanceof HTMLElement?{width:this.hostReference.offsetWidth,height:this.hostReference.offsetHeight}:this.hostReference instanceof SVGGraphicsElement?this.hostReference.getBBox():{width:0,height:0}}},Dp=(()=>{class i{constructor(){this.injector=w(St),this.handleService=w(qx),this.element=w(ce).nativeElement,this.destroyRef=w(Er),this.position=ve.required(),this.type=ve.required(),this.id=ve(),this.template=ve(),this.offsetX=ve(0),this.offsetY=ve(0)}ngOnInit(){vr(this.injector,()=>{let A=this.handleService.node();if(A){let t=new Wx({position:this.position(),type:this.type(),id:this.id(),hostReference:this.element.parentElement,template:this.template(),userOffsetX:this.offsetX(),userOffsetY:this.offsetY()},A);this.handleService.createHandle(t),requestAnimationFrame(()=>t.updateHost()),this.destroyRef.onDestroy(()=>this.handleService.destroyHandle(t))}})}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275cmp=vA({type:i,selectors:[["handle"]],inputs:{position:[1,"position"],type:[1,"type"],id:[1,"id"],template:[1,"template"],offsetX:[1,"offsetX"],offsetY:[1,"offsetY"]},decls:0,vars:0,template:function(t,n){},encapsulation:2,changeDetection:0})}}return i})(),e3A=(()=>{class i{constructor(){this.nodeAccessor=w(EE),this.zone=w(We),this.destroyRef=w(Er),this.hostElementRef=w(ce)}ngOnInit(){this.nodeAccessor.model().handles$.pipe(Mi(t=>G5([...t.map(n=>n.hostReference),this.hostElementRef.nativeElement],this.zone).pipe(Se(()=>t))),mi(t=>{t.forEach(n=>n.updateHost())}),xr(this.destroyRef)).subscribe()}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275dir=VA({type:i,selectors:[["","nodeHandlesController",""]]})}}return i})(),t3A=(()=>{class i{constructor(){this.nodeAccessor=w(EE),this.zone=w(We),this.destroyRef=w(Er),this.hostElementRef=w(ce)}ngOnInit(){let A=this.nodeAccessor.model(),t=this.hostElementRef.nativeElement;Vi(G5([t],this.zone)).pipe(Yn(null),Bt(()=>!A.resizing()),mi(()=>{A.width.set(t.clientWidth),A.height.set(t.clientHeight)}),xr(this.destroyRef)).subscribe()}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275dir=VA({type:i,selectors:[["","nodeResizeController",""]]})}}return i})(),hZ=(()=>{class i{constructor(){this.injector=w(St),this.handleService=w(qx),this.draggableService=w(lZ),this.flowStatusService=w(c1),this.nodeRenderingService=w(gI),this.flowSettingsService=w(as),this.selectionService=w(yp),this.hostRef=w(ce),this.nodeAccessor=w(EE),this.overlaysService=w(dZ),this.connectionController=w(BZ,{optional:!0}),this.model=ve.required(),this.nodeTemplate=ve(),this.nodeSvgTemplate=ve(),this.groupNodeTemplate=ve(),this.showMagnet=ye(()=>this.flowStatusService.status().state==="connection-start"||this.flowStatusService.status().state==="connection-validation"||this.flowStatusService.status().state==="reconnection-start"||this.flowStatusService.status().state==="reconnection-validation"),this.toolbars=ye(()=>this.overlaysService.nodeToolbarsMap().get(this.model()))}ngOnInit(){this.model().isVisible.set(!0),this.nodeAccessor.model.set(this.model()),this.handleService.node.set(this.model()),Fn(()=>{this.model().draggable()?this.draggableService.enable(this.hostRef.nativeElement,this.model()):this.draggableService.disable(this.hostRef.nativeElement)},{injector:this.injector})}ngOnDestroy(){this.model().isVisible.set(!1),this.draggableService.destroy(this.hostRef.nativeElement)}startConnection(A,t){A.stopPropagation(),this.connectionController?.startConnection(t)}validateConnection(A){this.connectionController?.validateConnection(A)}resetValidateConnection(A){this.connectionController?.resetValidateConnection(A)}endConnection(){this.connectionController?.endConnection()}pullNode(){this.flowSettingsService.elevateNodesOnSelect()&&this.nodeRenderingService.pullNode(this.model())}selectNode(){this.flowSettingsService.entitiesSelectable()&&this.selectionService.select(this.model())}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275cmp=vA({type:i,selectors:[["g","node",""]],hostAttrs:[1,"vflow-node"],inputs:{model:[1,"model"],nodeTemplate:[1,"nodeTemplate"],nodeSvgTemplate:[1,"nodeSvgTemplate"],groupNodeTemplate:[1,"groupNodeTemplate"]},features:[pt([qx,EE])],attrs:h4A,decls:11,vars:7,consts:[[1,"selectable"],["nodeHandlesController","",1,"selectable"],["rx","5","ry","5",1,"default-group-node",3,"resizable","gap","resizerColor","default-group-node_selected","stroke","fill"],[1,"selectable",3,"click"],["nodeHandlesController","",3,"selected"],[3,"outerHTML"],["type","source","position","right"],["type","target","position","left"],["nodeHandlesController","","nodeResizeController","",1,"wrapper"],[3,"ngTemplateOutlet","ngTemplateOutletContext","ngTemplateOutletInjector"],["nodeHandlesController","",1,"selectable",3,"click"],[3,"ngComponentOutlet","ngComponentOutletInputs","ngComponentOutletInjector"],["rx","5","ry","5",1,"default-group-node",3,"click","resizable","gap","resizerColor"],[3,"ngTemplateOutlet"],["r","5",1,"default-handle"],[3,"handleSizeController"],[1,"magnet"],["r","5",1,"default-handle",3,"pointerStart","pointerEnd"],[3,"pointerStart","pointerEnd","handleSizeController"],[4,"ngTemplateOutlet","ngTemplateOutletContext"],[1,"magnet",3,"pointerEnd","pointerOver","pointerOut"]],template:function(t,n){if(t&1&&(T(0,E4A,5,12,":svg:foreignObject",0),T(1,Q4A,3,9,":svg:foreignObject",0),T(2,u4A,2,3,":svg:g",1),T(3,f4A,2,3),T(4,m4A,1,11,":svg:rect",2),T(5,w4A,2,3,":svg:g",1),T(6,v4A,1,1),ke(7,x4A,4,4,null,null,ni),ke(9,R4A,2,4,":svg:foreignObject",null,ni)),t&2){let o;O(n.model().rawNode.type==="default"?0:-1),Q(),O(n.model().rawNode.type==="html-template"&&n.nodeTemplate()?1:-1),Q(),O(n.model().rawNode.type==="svg-template"&&n.nodeSvgTemplate()?2:-1),Q(),O(n.model().isComponentType?3:-1),Q(),O(n.model().rawNode.type==="default-group"?4:-1),Q(),O(n.model().rawNode.type==="template-group"&&n.groupNodeTemplate()?5:-1),Q(),O((o=n.model().resizerTemplate())?6:-1,o),Q(),_e(n.model().handles()),Q(2),_e(n.toolbars())}},dependencies:[$x,ZpA,Dp,Uc,Kc,XpA,qpA,e3A,t3A,gs],styles:[".magnet[_ngcontent-%COMP%]{opacity:0}.wrapper[_ngcontent-%COMP%]{display:table-cell}.default-group-node[_ngcontent-%COMP%]{stroke-width:1.5px;fill-opacity:.05}.default-group-node_selected[_ngcontent-%COMP%]{stroke-width:2px}.default-handle[_ngcontent-%COMP%]{stroke:#fff;fill:#1b262c}"],changeDetection:0})}}return i})(),i3A=(()=>{class i{constructor(){this.flowStatusService=w(c1),this.spacePointContext=w(pp),this.flowEntitiesService=w(pl),this.model=ve.required(),this.template=ve(),this.path=ye(()=>{let A=this.flowStatusService.status(),t=this.model().curve;if(A.state==="connection-start"||A.state==="reconnection-start"){let n=A.payload.sourceHandle,o=n.pointAbsolute(),a=n.rawHandle.position,r=this.spacePointContext.svgCurrentSpacePoint(),s=iZ(n.rawHandle.position),l=this.getPathFactoryParams(o,r,a,s);switch(t){case"straight":return Hx(l).path;case"bezier":return zx(l).path;case"smooth-step":return IE(l).path;case"step":return IE(l,0).path;default:return t(l).path}}if(A.state==="connection-validation"||A.state==="reconnection-validation"){let n=A.payload.sourceHandle,o=n.pointAbsolute(),a=n.rawHandle.position,r=A.payload.targetHandle,s=A.payload.valid?r.pointAbsolute():this.spacePointContext.svgCurrentSpacePoint(),l=A.payload.valid?r.rawHandle.position:iZ(n.rawHandle.position),g=this.getPathFactoryParams(o,s,a,l);switch(t){case"straight":return Hx(g).path;case"bezier":return zx(g).path;case"smooth-step":return IE(g).path;case"step":return IE(g,0).path;default:return t(g).path}}return null}),this.markerUrl=ye(()=>{let A=this.model().settings.marker;return A?`url(#${BE(JSON.stringify(A))})`:""}),this.defaultColor="rgb(177, 177, 183)"}getContext(){return{$implicit:{path:this.path,marker:this.markerUrl}}}getPathFactoryParams(A,t,n,o){return{mode:"connection",sourcePoint:A,targetPoint:t,sourcePosition:n,targetPosition:o,allEdges:this.flowEntitiesService.rawEdges(),allNodes:this.flowEntitiesService.rawNodes()}}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275cmp=vA({type:i,selectors:[["g","connection",""]],inputs:{model:[1,"model"],template:[1,"template"]},attrs:N4A,decls:2,vars:2,consts:[["fill","none","stroke-width","2"],[4,"ngTemplateOutlet","ngTemplateOutletContext"]],template:function(t,n){t&1&&(T(0,L4A,1,1),T(1,U4A,1,1)),t&2&&(O(n.model().type==="default"?0:-1),Q(),O(n.model().type==="template"?1:-1))},dependencies:[Uc],encapsulation:2,changeDetection:0})}}return i})();function iZ(i){switch(i){case"top":return"bottom";case"bottom":return"top";case"left":return"right";case"right":return"left"}}function n3A(){return String.fromCharCode(65+Math.floor(Math.random()*26))+Date.now()}var o3A="#fff",a3A=20,r3A=2,nZ="rgb(177, 177, 183)",oZ=.1,s3A=!0,l3A=(()=>{class i{constructor(){this.viewportService=w(lI),this.rootSvg=w(F5).element,this.settingsService=w(as),this.backgroundSignal=this.settingsService.background,this.scaledGap=ye(()=>{let A=this.backgroundSignal();return A.type==="dots"?this.viewportService.readableViewport().zoom*(A.gap??a3A):0}),this.x=ye(()=>this.viewportService.readableViewport().x%this.scaledGap()),this.y=ye(()=>this.viewportService.readableViewport().y%this.scaledGap()),this.patternColor=ye(()=>{let A=this.backgroundSignal();return A.type==="dots"?A.color??nZ:nZ}),this.patternSize=ye(()=>{let A=this.backgroundSignal();return A.type==="dots"?this.viewportService.readableViewport().zoom*(A.size??r3A)/2:0}),this.bgImageSrc=ye(()=>{let A=this.backgroundSignal();return A.type==="image"?A.src:""}),this.imageSize=mp(Fo(this.backgroundSignal).pipe(Mi(()=>g3A(this.bgImageSrc())),Se(A=>({width:A.naturalWidth,height:A.naturalHeight}))),{initialValue:{width:0,height:0}}),this.scaledImageWidth=ye(()=>{let A=this.backgroundSignal();if(A.type==="image"){let t=A.fixed?1:this.viewportService.readableViewport().zoom;return this.imageSize().width*t*(A.scale??oZ)}return 0}),this.scaledImageHeight=ye(()=>{let A=this.backgroundSignal();if(A.type==="image"){let t=A.fixed?1:this.viewportService.readableViewport().zoom;return this.imageSize().height*t*(A.scale??oZ)}return 0}),this.imageX=ye(()=>{let A=this.backgroundSignal();return A.type==="image"?A.repeat?A.fixed?0:this.viewportService.readableViewport().x%this.scaledImageWidth():A.fixed?0:this.viewportService.readableViewport().x:0}),this.imageY=ye(()=>{let A=this.backgroundSignal();return A.type==="image"?A.repeat?A.fixed?0:this.viewportService.readableViewport().y%this.scaledImageHeight():A.fixed?0:this.viewportService.readableViewport().y:0}),this.repeated=ye(()=>{let A=this.backgroundSignal();return A.type==="image"&&(A.repeat??s3A)}),this.patternId=n3A(),this.patternUrl=`url(#${this.patternId})`,Fn(()=>{let A=this.backgroundSignal();A.type==="dots"&&(this.rootSvg.style.backgroundColor=A.backgroundColor??o3A),A.type==="solid"&&(this.rootSvg.style.backgroundColor=A.color)})}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275cmp=vA({type:i,selectors:[["g","background",""]],attrs:T4A,decls:2,vars:2,consts:[["patternUnits","userSpaceOnUse"],["x","0","y","0","width","100%","height","100%"]],template:function(t,n){t&1&&(T(0,O4A,3,10),T(1,H4A,2,2)),t&2&&(O(n.backgroundSignal().type==="dots"?0:-1),Q(),O(n.backgroundSignal().type==="image"?1:-1))},encapsulation:2,changeDetection:0})}}return i})();function g3A(i){let e=new Image;return e.src=i,new Promise(A=>{e.onload=()=>A(e)})}var c3A=(()=>{class i{constructor(){this.markers=ve.required(),this.defaultColor="rgb(177, 177, 183)"}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275cmp=vA({type:i,selectors:[["defs","flowDefs",""]],inputs:{markers:[1,"markers"]},attrs:z4A,decls:3,vars:2,consts:[["viewBox","-10 -10 20 20","refX","0","refY","0"],["points","-5,-4 1,0 -5,4 -5,-4",1,"marker__arrow_closed",3,"stroke","stroke-width","fill"],["points","-5,-4 0,0 -5,4",1,"marker__arrow_default",3,"stroke","stroke-width"],["points","-5,-4 1,0 -5,4 -5,-4",1,"marker__arrow_closed"],["points","-5,-4 0,0 -5,4",1,"marker__arrow_default"]],template:function(t,n){t&1&&(ke(0,V4A,3,7,":svg:marker",0,ni),mt(2,"keyvalue")),t&2&&_e(Ft(2,0,n.markers()))},dependencies:[HN],styles:[".marker__arrow_default[_ngcontent-%COMP%]{stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;fill:none}.marker__arrow_closed[_ngcontent-%COMP%]{stroke-linecap:round;stroke-linejoin:round}"],changeDetection:0})}}return i})(),C3A=(()=>{class i{constructor(){this.host=w(ce),this.flowSettingsService=w(as),this.flowWidth=ye(()=>{let A=this.flowSettingsService.view();return A==="auto"?"100%":A[0]}),this.flowHeight=ye(()=>{let A=this.flowSettingsService.view();return A==="auto"?"100%":A[1]}),G5([this.host.nativeElement],w(We)).pipe(mi(([A])=>{this.flowSettingsService.computedFlowWidth.set(A.contentRect.width),this.flowSettingsService.computedFlowHeight.set(A.contentRect.height)}),xr()).subscribe()}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275dir=VA({type:i,selectors:[["svg","flowSizeController",""]],hostVars:2,hostBindings:function(t,n){t&2&&ie("width",n.flowWidth())("height",n.flowHeight())}})}}return i})(),d3A=(()=>{class i{constructor(){this.flowStatusService=w(c1)}resetConnection(){let A=this.flowStatusService.status();(A.state==="connection-start"||A.state==="reconnection-start")&&this.flowStatusService.setIdleStatus()}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275dir=VA({type:i,selectors:[["svg","rootSvgContext",""]],hostBindings:function(t,n){t&1&&U("mouseup",function(){return n.resetConnection()},mI)("touchend",function(){return n.resetConnection()},mI)("contextmenu",function(){return n.resetConnection()})}})}}return i})();function Zx(i,e){let A=[];for(let t of e){let{x:n,y:o}=t.globalPoint();i.x>=n&&i.x<=n+t.width()&&i.y>=o&&i.y<=o+t.height()&&A.push({x:i.x-n,y:i.y-o,spaceNodeId:t.rawNode.id})}return A.reverse(),A.push({spaceNodeId:null,x:i.x,y:i.y}),A}var eR=(()=>{class i{static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275prov=jA({token:i,factory:i.\u0275fac})}}return i})(),I3A=(()=>{class i extends eR{shouldRenderNode(A){return!A.isVisible()}static{this.\u0275fac=(()=>{let A;return function(n){return(A||(A=Li(i)))(n||i)}})()}static{this.\u0275prov=jA({token:i,factory:i.\u0275fac})}}return i})();function B3A(i,e){if(Object.keys(e.preview().style).length){Q3A(i,e);return}if(e.rawNode.type==="default"){h3A(i,e);return}if(e.rawNode.type==="default-group"){E3A(i,e);return}u3A(i,e)}function h3A(i,e){let A=e.globalPoint(),t=e.width(),n=e.height();EZ(i,e,5),i.fillStyle="white",i.fill(),i.strokeStyle="#1b262c",i.lineWidth=1.5,i.stroke(),i.fillStyle="black",i.font="14px Arial",i.textAlign="center",i.textBaseline="middle";let o=A.x+t/2,a=A.y+n/2;i.fillText(e.text(),o,a)}function E3A(i,e){let A=e.globalPoint(),t=e.width(),n=e.height();i.globalAlpha=.05,i.fillStyle=e.color(),i.fillRect(A.x,A.y,t,n),i.globalAlpha=1,i.strokeStyle=e.color(),i.lineWidth=1.5,i.strokeRect(A.x,A.y,t,n)}function Q3A(i,e){let A=e.globalPoint(),t=e.width(),n=e.height(),o=e.preview().style;if(o.borderRadius){let a=parseFloat(o.borderRadius);EZ(i,e,a)}else i.beginPath(),i.rect(A.x,A.y,t,n),i.closePath();o.backgroundColor&&(i.fillStyle=o.backgroundColor),o.borderColor&&(i.strokeStyle=o.borderColor),o.borderWidth&&(i.lineWidth=parseFloat(o.borderWidth)),i.fill(),i.stroke()}function u3A(i,e){let A=e.globalPoint(),t=e.width(),n=e.height();i.fillStyle="rgb(0 0 0 / 10%)",i.fillRect(A.x,A.y,t,n)}function EZ(i,e,A){let t=e.globalPoint(),n=e.width(),o=e.height();i.beginPath(),i.moveTo(t.x+A,t.y),i.lineTo(t.x+n-A,t.y),i.quadraticCurveTo(t.x+n,t.y,t.x+n,t.y+A),i.lineTo(t.x+n,t.y+o-A),i.quadraticCurveTo(t.x+n,t.y+o,t.x+n-A,t.y+o),i.lineTo(t.x+A,t.y+o),i.quadraticCurveTo(t.x,t.y+o,t.x,t.y+o-A),i.lineTo(t.x,t.y+A),i.quadraticCurveTo(t.x,t.y,t.x+A,t.y),i.closePath()}var p3A=(()=>{class i{constructor(){this.viewportService=w(lI),this.renderStrategy=w(eR),this.nodeRenderingService=w(gI),this.renderer2=w(on),this.element=w(ce).nativeElement,this.ctx=this.element.getContext("2d"),this.width=ve(0),this.height=ve(0),this.dpr=window.devicePixelRatio,Fn(()=>{this.renderer2.setProperty(this.element,"width",this.width()*this.dpr),this.renderer2.setProperty(this.element,"height",this.height()*this.dpr),this.renderer2.setStyle(this.element,"width",`${this.width()}px`),this.renderer2.setStyle(this.element,"height",`${this.height()}px`),this.ctx.scale(this.dpr,this.dpr)}),Fn(()=>{let A=this.viewportService.readableViewport();this.ctx.clearRect(0,0,this.width(),this.height()),this.ctx.save(),this.ctx.setTransform(A.zoom*this.dpr,0,0,A.zoom*this.dpr,A.x*this.dpr,A.y*this.dpr);for(let t=0;t<this.nodeRenderingService.viewportNodes().length;t++){let n=this.nodeRenderingService.viewportNodes()[t];this.renderStrategy.shouldRenderNode(n)&&B3A(this.ctx,n)}this.ctx.restore()})}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275cmp=vA({type:i,selectors:[["canvas","previewFlow",""]],inputs:{width:[1,"width"],height:[1,"height"]},attrs:q4A,decls:0,vars:0,template:function(t,n){},encapsulation:2,changeDetection:0})}}return i})(),aZ=(()=>{class i{constructor(){this.nodeRenderingService=w(gI),this.edgeRenderingService=w(wp),this.flowEntitiesService=w(pl),this.settingsService=w(as),this.flowInitialized=mA(!1),w(We).runOutsideAngular(()=>re(this,null,function*(){yield f3A(2),this.flowInitialized.set(!0)}))}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275prov=jA({token:i,factory:i.\u0275fac})}}return i})();function f3A(i){return new Promise(e=>{let A=0;function t(){A++,A<i?requestAnimationFrame(t):e()}requestAnimationFrame(t)})}function rZ(i){return $A(P({},i),{left:i.x,right:i.x+i.width,top:i.y,bottom:i.y+i.height})}var m3A=(()=>{class i{constructor(){this.nodeRenderingService=w(gI),this.flowStatus=w(c1),this.tolerance=ve(10),this.lineColor=ve("#1b262c"),this.isNodeDragging=ye(()=>qW(this.flowStatus.status())),this.intersections=x5(A=>{let t=this.flowStatus.status();if(qW(t)){let n=t.payload.node,o=rZ(v5(n)),a=this.nodeRenderingService.viewportNodes().filter(d=>d!==n).filter(d=>!n.children().includes(d)).map(d=>rZ(v5(d))),r=[],s=o.x,l=o.y,g=1/0,C=1/0;return a.forEach(d=>{let B=o.left+o.width/2,u=d.left+d.width/2;for(let[m,v,S,k]of[[B,u,u-o.width/2,!0],[o.left,d.left,d.left,!1],[o.left,d.right,d.right,!1],[o.right,d.left,d.left-o.width,!1],[o.right,d.right,d.right-o.width,!1]]){let M=Math.abs(m-v);if(M<=this.tolerance()){let x=Math.min(o.top,d.top),F=Math.max(o.bottom,d.bottom);if(r.push({x:v,y:x,x2:v,y2:F,isCenter:k}),M<g&&(g=M,s=S),k)break}}let E=o.top+o.height/2,f=d.top+d.height/2;for(let[m,v,S,k]of[[E,f,f-o.height/2,!0],[o.top,d.top,d.top,!1],[o.top,d.bottom,d.bottom,!1],[o.bottom,d.top,d.top-o.height,!1],[o.bottom,d.bottom,d.bottom-o.height,!1]]){let M=Math.abs(m-v);if(M<=this.tolerance()){let x=Math.min(o.left,d.left),F=Math.max(o.right,d.right);if(r.push({x,y:v,x2:F,y2:v,isCenter:k}),M<C&&(C=M,l=S),k)break}}}),{lines:r,snappedX:s,snappedY:l}}return A}),Fo(this.flowStatus.status).pipe(Bt(vpA),Se(A=>A.payload.node),Se(A=>[A,this.intersections()]),mi(([A,t])=>{if(t){let n={x:t.snappedX,y:t.snappedY},o=A.parent()?[A.parent()]:[];A.setPoint(Zx(n,o)[0])}}),xr()).subscribe()}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275cmp=vA({type:i,selectors:[["g","alignmentHelper",""]],inputs:{tolerance:[1,"tolerance"],lineColor:[1,"lineColor"]},attrs:W4A,decls:1,vars:1,template:function(t,n){t&1&&T(0,$4A,1,1),t&2&&O(n.isNodeDragging()?0:-1)},encapsulation:2,changeDetection:0})}}return i})();var K5=(()=>{class i{constructor(){this.viewportService=w(lI),this.flowEntitiesService=w(pl),this.nodesChangeService=w(jx),this.edgesChangeService=w(Vx),this.nodeRenderingService=w(gI),this.edgeRenderingService=w(wp),this.flowSettingsService=w(as),this.componentEventBusService=w(Yx),this.keyboardService=w(Jx),this.injector=w(St),this.flowRenderingService=w(aZ),this.alignmentHelper=ve(!1),this.nodeModels=this.nodeRenderingService.nodes,this.groups=this.nodeRenderingService.groups,this.nonGroups=this.nodeRenderingService.nonGroups,this.edgeModels=this.edgeRenderingService.edges,this.onComponentNodeEvent=Hn(this.componentEventBusService.event$),this.nodeTemplateDirective=K0(hE),this.nodeSvgTemplateDirective=K0(XW),this.groupNodeTemplateDirective=K0(k5),this.edgeTemplateDirective=K0(S5),this.edgeLabelHtmlDirective=K0(ZW),this.connectionTemplateDirective=K0(WW),this.mapContext=Yo(Ux),this.spacePointContext=Yo.required(pp),this.viewport=this.viewportService.readableViewport.asReadonly(),this.nodesChange=mp(this.nodesChangeService.changes$,{initialValue:[]}),this.edgesChange=mp(this.edgesChangeService.changes$,{initialValue:[]}),this.initialized=this.flowRenderingService.flowInitialized.asReadonly(),this.viewportChange$=Fo(this.viewportService.readableViewport).pipe(Dl(1)),this.nodesChange$=this.nodesChangeService.changes$,this.edgesChange$=this.edgesChangeService.changes$,this.initialized$=Fo(this.flowRenderingService.flowInitialized),this.markers=this.flowEntitiesService.markers,this.minimap=this.flowEntitiesService.minimap,this.flowOptimization=this.flowSettingsService.optimization,this.flowWidth=this.flowSettingsService.computedFlowWidth,this.flowHeight=this.flowSettingsService.computedFlowHeight}set view(A){this.flowSettingsService.view.set(A)}set minZoom(A){this.flowSettingsService.minZoom.set(A)}set maxZoom(A){this.flowSettingsService.maxZoom.set(A)}set background(A){this.flowSettingsService.background.set(PpA(A))}set optimization(A){this.flowSettingsService.optimization.update(t=>P(P({},t),A))}set entitiesSelectable(A){this.flowSettingsService.entitiesSelectable.set(A)}set keyboardShortcuts(A){this.keyboardService.setShortcuts(A)}set connection(A){this.flowEntitiesService.connection.set(A)}get connection(){return this.flowEntitiesService.connection()}set snapGrid(A){this.flowSettingsService.snapGrid.set(A)}set elevateNodesOnSelect(A){this.flowSettingsService.elevateNodesOnSelect.set(A)}set elevateEdgesOnSelect(A){this.flowSettingsService.elevateEdgesOnSelect.set(A)}set nodes(A){let t=vr(this.injector,()=>R5.nodes(A,this.flowEntitiesService.nodes()));$W(t,this.flowEntitiesService.edges()),this.flowEntitiesService.nodes.set(t),t.forEach(n=>this.nodeRenderingService.pullNode(n))}set edges(A){let t=vr(this.injector,()=>R5.edges(A,this.flowEntitiesService.edges()));$W(this.flowEntitiesService.nodes(),t),this.flowEntitiesService.edges.set(t)}viewportTo(A){this.viewportService.writableViewport.set({changeType:"absolute",state:A,duration:0})}zoomTo(A){this.viewportService.writableViewport.set({changeType:"absolute",state:{zoom:A},duration:0})}panTo(A){this.viewportService.writableViewport.set({changeType:"absolute",state:A,duration:0})}fitView(A){this.viewportService.fitView(A)}getNode(A){return this.flowEntitiesService.getNode(A)?.rawNode}getDetachedEdges(){return this.flowEntitiesService.getDetachedEdges().map(A=>A.edge)}documentPointToFlowPoint(A,t){let n=this.spacePointContext().documentPointToFlowPoint(A);return t?.spaces?Zx(n,this.nodeRenderingService.groups()):n}getIntesectingNodes(A,t={partially:!0}){return IpA(A,this.nodeModels(),t).map(n=>n.rawNode)}toNodeSpace(A,t){let n=this.nodeModels().find(a=>a.rawNode.id===A);if(!n)return{x:1/0,y:1/0};if(t===null)return n.globalPoint();let o=this.nodeModels().find(a=>a.rawNode.id===t);return o?Zx(n.globalPoint(),[o])[0]:{x:1/0,y:1/0}}trackNodes(A,{rawNode:t}){return t}trackEdges(A,{edge:t}){return t}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275cmp=vA({type:i,selectors:[["vflow"]],contentQueries:function(t,n,o){t&1&&c3(o,n.nodeTemplateDirective,hE,5)(o,n.nodeSvgTemplateDirective,XW,5)(o,n.groupNodeTemplateDirective,k5,5)(o,n.edgeTemplateDirective,S5,5)(o,n.edgeLabelHtmlDirective,ZW,5)(o,n.connectionTemplateDirective,WW,5),t&2&&br(6)},viewQuery:function(t,n){t&1&&ls(n.mapContext,Ux,5)(n.spacePointContext,pp,5),t&2&&br(2)},inputs:{view:"view",minZoom:"minZoom",maxZoom:"maxZoom",background:"background",optimization:"optimization",entitiesSelectable:"entitiesSelectable",keyboardShortcuts:"keyboardShortcuts",connection:[2,"connection","connection",A=>new b5(A)],snapGrid:"snapGrid",elevateNodesOnSelect:"elevateNodesOnSelect",elevateEdgesOnSelect:"elevateEdgesOnSelect",nodes:"nodes",alignmentHelper:[1,"alignmentHelper"],edges:"edges"},outputs:{onComponentNodeEvent:"onComponentNodeEvent"},features:[pt([lZ,lI,c1,pl,jx,Vx,gI,wp,yp,as,Yx,Jx,dZ,{provide:eR,useClass:I3A},aZ]),r3([{directive:zpA,outputs:["onNodesChange","onNodesChange","onNodesChange.position","onNodesChange.position","onNodesChange.position.single","onNodesChange.position.single","onNodesChange.position.many","onNodesChange.position.many","onNodesChange.size","onNodesChange.size","onNodesChange.size.single","onNodesChange.size.single","onNodesChange.size.many","onNodesChange.size.many","onNodesChange.add","onNodesChange.add","onNodesChange.add.single","onNodesChange.add.single","onNodesChange.add.many","onNodesChange.add.many","onNodesChange.remove","onNodesChange.remove","onNodesChange.remove.single","onNodesChange.remove.single","onNodesChange.remove.many","onNodesChange.remove.many","onNodesChange.select","onNodesChange.select","onNodesChange.select.single","onNodesChange.select.single","onNodesChange.select.many","onNodesChange.select.many","onEdgesChange","onEdgesChange","onEdgesChange.detached","onEdgesChange.detached","onEdgesChange.detached.single","onEdgesChange.detached.single","onEdgesChange.detached.many","onEdgesChange.detached.many","onEdgesChange.add","onEdgesChange.add","onEdgesChange.add.single","onEdgesChange.add.single","onEdgesChange.add.many","onEdgesChange.add.many","onEdgesChange.remove","onEdgesChange.remove","onEdgesChange.remove.single","onEdgesChange.remove.single","onEdgesChange.remove.many","onEdgesChange.remove.many","onEdgesChange.select","onEdgesChange.select","onEdgesChange.select.single","onEdgesChange.select.single","onEdgesChange.select.many","onEdgesChange.select.many"]}])],decls:11,vars:8,consts:[["flow",""],["rootSvgRef","","rootSvgContext","","rootPointer","","flowSizeController","",1,"root-svg"],["flowDefs","",3,"markers"],["background",""],["mapContext","","spacePointContext",""],["connection","",3,"model","template"],[3,"ngTemplateOutlet"],["previewFlow","",1,"preview-flow",3,"width","height"],["alignmentHelper",""],["alignmentHelper","",3,"tolerance","lineColor"],["node","",3,"model","groupNodeTemplate"],["edge","",3,"model","edgeTemplate","edgeLabelHtmlTemplate"],["node","",3,"model","nodeTemplate","nodeSvgTemplate"],["node","",3,"model","nodeTemplate","nodeSvgTemplate","groupNodeTemplate"]],template:function(t,n){if(t&1&&(Et(),I(0,"svg",1,0),lA(2,"defs",2)(3,"g",3),I(4,"g",4),T(5,tpA,2,1),lA(6,"g",5),T(7,apA,6,0),T(8,lpA,4,0),h(),T(9,gpA,1,1,":svg:ng-container",6),h(),T(10,cpA,1,2,"canvas",7)),t&2){let o,a,r;Q(2),H("markers",n.markers()),Q(3),O((o=n.alignmentHelper())?5:-1,o),Q(),H("model",n.connection)("template",(a=n.connectionTemplateDirective())==null?null:a.templateRef),Q(),O(n.flowOptimization().detachedGroupsLayer?7:-1),Q(),O(n.flowOptimization().detachedGroupsLayer?-1:8),Q(),O((r=n.minimap())?9:-1,r),Q(),O(n.flowOptimization().virtualization?10:-1)}},dependencies:[F5,d3A,L5,C3A,c3A,l3A,Ux,pp,i3A,hZ,AR,Uc,p3A,m3A],styles:["[_nghost-%COMP%]{display:grid;grid-template-columns:1fr;width:100%;height:100%;-webkit-user-select:none;user-select:none}[_nghost-%COMP%] *{box-sizing:border-box}.root-svg[_ngcontent-%COMP%]{grid-row-start:1;grid-column-start:1}.preview-flow[_ngcontent-%COMP%]{pointer-events:none;grid-row-start:1;grid-column-start:1}"],changeDetection:0})}}return i})();var U5=(()=>{class i{constructor(){this.flowSettingsService=w(as),this.selectionService=w(yp),this.parentEdge=w(AR,{optional:!0}),this.parentNode=w(hZ,{optional:!0}),this.host=w(ce),this.selectOnEvent=this.getEvent$().pipe(mi(()=>this.select()),xr()).subscribe()}select(){let A=this.entity();A&&this.flowSettingsService.entitiesSelectable()&&this.selectionService.select(A)}entity(){return this.parentNode?this.parentNode.model():this.parentEdge?this.parentEdge.model():null}getEvent$(){return Nc(this.host.nativeElement,"click")}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275dir=VA({type:i,selectors:[["","selectable",""]]})}}return i})();var QZ=(()=>{class i{constructor(){this.edge=w(AR),this.flowSettingsService=w(as),this.edgeRenderingService=w(wp),this.model=this.edge.model(),this.context=this.model.context.$implicit}pull(){this.flowSettingsService.elevateEdgesOnSelect()&&this.edgeRenderingService.pull(this.model)}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275cmp=vA({type:i,selectors:[["g","customTemplateEdge",""]],hostBindings:function(t,n){t&1&&U("mousedown",function(){return n.pull()})("touchstart",function(){return n.pull()})},attrs:CpA,ngContentSelectors:Xx,decls:3,vars:1,consts:[["interactiveEdge",""],[1,"interactive-edge"]],template:function(t,n){t&1&&(Ot(),Ze(0),Et(),$n(1,"path",1,0)),t&2&&(Q(),ie("d",n.context.path()))},styles:[".interactive-edge[_ngcontent-%COMP%]{fill:none;stroke-width:20;stroke:transparent}"],changeDetection:0})}}return i})();var w3A=["canvas"],y3A=["svgCanvas"],D3A=()=>({type:"dots",color:"#424242",size:1,gap:12}),v3A=()=>[12,12],b3A=(i,e)=>e.name;function M3A(i,e){if(i&1){let A=aA();I(0,"div",6)(1,"div",11)(2,"button",12),U("click",function(){L(A);let n=p();return G(n.backToMainCanvas())}),I(3,"mat-icon"),D(4,"arrow_back"),h()(),I(5,"div",13)(6,"span",14),D(7,"smart_toy"),h(),I(8,"div",15)(9,"h3",16),D(10),h(),I(11,"p",17),D(12,"Agent Tool"),h()()()()()}if(i&2){let A=p();Q(2),H("matTooltip",A.getBackButtonTooltip()),Q(8),nA(A.currentAgentTool())}}function S3A(i,e){if(i&1){let A=aA();I(0,"span",18),U("click",function(){L(A);let n=p();return G(n.toggleSidePanelRequest.emit())}),D(1,"left_panel_open"),h()}}function k3A(i,e){if(i&1){let A=aA();Et(),I(0,"foreignObject"),hr(),I(1,"div",27),U("click",function(n){return n.stopPropagation()}),I(2,"button",28,0),U("click",function(n){return n.stopPropagation()}),I(4,"mat-icon"),D(5,"add"),h()(),I(6,"span",29),D(7,"Add sub-agent"),h(),I(8,"mat-menu",null,1)(10,"button",30),U("click",function(n){let o;L(A);let a=Bi(3),r=p().$implicit,s=p(2);return G(s.handleAgentTypeSelection("LlmAgent",r.node.data==null||(o=r.node.data())==null?null:o.name,a,n,!0))}),I(11,"mat-icon"),D(12,"psychology"),h(),I(13,"span"),D(14,"LLM Agent"),h()(),I(15,"button",30),U("click",function(n){let o;L(A);let a=Bi(3),r=p().$implicit,s=p(2);return G(s.handleAgentTypeSelection("SequentialAgent",r.node.data==null||(o=r.node.data())==null?null:o.name,a,n,!0))}),I(16,"mat-icon"),D(17,"more_horiz"),h(),I(18,"span"),D(19,"Sequential Agent"),h()(),I(20,"button",30),U("click",function(n){let o;L(A);let a=Bi(3),r=p().$implicit,s=p(2);return G(s.handleAgentTypeSelection("LoopAgent",r.node.data==null||(o=r.node.data())==null?null:o.name,a,n,!0))}),I(21,"mat-icon"),D(22,"sync"),h(),I(23,"span"),D(24,"Loop Agent"),h()(),I(25,"button",30),U("click",function(n){let o;L(A);let a=Bi(3),r=p().$implicit,s=p(2);return G(s.handleAgentTypeSelection("ParallelAgent",r.node.data==null||(o=r.node.data())==null?null:o.name,a,n,!0))}),I(26,"mat-icon"),D(27,"density_medium"),h(),I(28,"span"),D(29,"Parallel Agent"),h()()()()()}if(i&2){let A=Bi(9),t=p().$implicit;ie("width",200)("height",100)("x",t.width()/2-100)("y",t.height()/2-40),Q(2),H("matMenuTriggerFor",A)}}function _3A(i,e){i&1&&(Et(),lA(0,"handle",26))}function x3A(i,e){if(i&1){let A=aA();Et(),I(0,"g")(1,"rect",21),U("click",function(n){let o=L(A).$implicit,a=p(2);return G(a.onGroupClick(o.node,n))})("pointerdown",function(n){let o=L(A).$implicit,a=p(2);return G(a.onGroupPointerDown(o.node,n))}),h(),I(2,"foreignObject",22),hr(),I(3,"div",23)(4,"mat-icon",24),D(5),h(),I(6,"span",25),D(7),h()()(),T(8,k3A,30,5,":svg:foreignObject"),T(9,_3A,1,0,":svg:handle",26),h()}if(i&2){let A,t,n=e.$implicit,o=p(2);Q(),ft("stroke",o.isGroupSelected(n.node)?"rgba(0, 187, 234, 0.8)":"rgba(0, 187, 234, 0.3)")("fill",o.isGroupSelected(n.node)?"rgba(0, 187, 234, 0.1)":"rgba(0, 187, 234, 0.03)")("stroke-width",o.isGroupSelected(n.node)?3:2),ie("width",n.width())("height",n.height()),Q(),ie("width",200)("height",32),Q(3),nA(o.getAgentIcon(n.node.data==null||(A=n.node.data())==null?null:A.agent_class)),Q(2),nA(n.node.data==null||(t=n.node.data())==null?null:t.agent_class),Q(),O(o.isGroupEmpty(n.node.id)?8:-1),Q(),O(o.shouldShowTopHandle(n.node)?9:-1)}}function R3A(i,e){i&1&&(I(0,"span",35),D(1,"Root"),h())}function N3A(i,e){if(i&1){let A=aA();I(0,"button",43),U("click",function(n){L(A),p();let o=Ki(0);return p(2).openDeleteSubAgentDialog(o),G(n.stopPropagation())}),I(1,"mat-icon"),D(2,"delete"),h()()}}function F3A(i,e){if(i&1){let A=aA();I(0,"div",46),U("click",function(n){let o=L(A).$implicit,a=p(2).$implicit;return p(2).selectTool(o,a.node),G(n.stopPropagation())}),I(1,"mat-icon",47),D(2),h(),I(3,"span",48),D(4),h()()}if(i&2){let A=e.$implicit,t=p(4);Q(2),nA(t.getToolIcon(A)),Q(2),nA(A.name)}}function L3A(i,e){if(i&1&&(I(0,"div",38)(1,"div",44),ke(2,F3A,5,2,"div",45,b3A),h()()),i&2){p();let A=Ki(3);Q(2),_e(A)}}function G3A(i,e){if(i&1){let A=aA();I(0,"div",39)(1,"button",49,2),U("click",function(n){return n.stopPropagation()}),I(3,"span",50),D(4,"+"),h()(),I(5,"mat-menu",null,3)(7,"button",30),U("click",function(n){let o;L(A);let a=Bi(2),r=p().$implicit,s=p(2);return G(s.handleAgentTypeSelection("LlmAgent",(o=r.node.data())==null?null:o.name,a,n))}),I(8,"mat-icon"),D(9,"psychology"),h(),I(10,"span"),D(11,"LLM Agent"),h()(),I(12,"button",30),U("click",function(n){let o;L(A);let a=Bi(2),r=p().$implicit,s=p(2);return G(s.handleAgentTypeSelection("SequentialAgent",(o=r.node.data())==null?null:o.name,a,n))}),I(13,"mat-icon"),D(14,"more_horiz"),h(),I(15,"span"),D(16,"Sequential Agent"),h()(),I(17,"button",30),U("click",function(n){let o;L(A);let a=Bi(2),r=p().$implicit,s=p(2);return G(s.handleAgentTypeSelection("LoopAgent",(o=r.node.data())==null?null:o.name,a,n))}),I(18,"mat-icon"),D(19,"sync"),h(),I(20,"span"),D(21,"Loop Agent"),h()(),I(22,"button",30),U("click",function(n){let o;L(A);let a=Bi(2),r=p().$implicit,s=p(2);return G(s.handleAgentTypeSelection("ParallelAgent",(o=r.node.data())==null?null:o.name,a,n))}),I(23,"mat-icon"),D(24,"density_medium"),h(),I(25,"span"),D(26,"Parallel Agent"),h()()()()}if(i&2){let A=Bi(6);Q(),H("matMenuTriggerFor",A)}}function K3A(i,e){i&1&&lA(0,"handle",40)}function U3A(i,e){i&1&&lA(0,"handle",26)}function T3A(i,e){i&1&&lA(0,"handle",41)}function O3A(i,e){i&1&&lA(0,"handle",42)}function J3A(i,e){if(i&1){let A=aA();ro(0)(1),mt(2,"async"),ro(3),I(4,"div",31),U("click",function(n){let o=L(A).$implicit,a=p(2);return G(a.onCustomTemplateNodeClick(o.node,n))})("pointerdown",function(n){let o=L(A).$implicit,a=p(2);return G(a.onNodePointerDown(o.node,n))}),I(5,"div",32)(6,"div",33)(7,"mat-icon",34),D(8),h(),D(9),T(10,R3A,2,0,"span",35),h(),I(11,"div",36),T(12,N3A,3,0,"button",37),h()(),T(13,L3A,4,0,"div",38),T(14,G3A,27,1,"div",39),T(15,K3A,1,0,"handle",40),T(16,U3A,1,0,"handle",26),T(17,T3A,1,0,"handle",41),T(18,O3A,1,0,"handle",42),h()}if(i&2){let A=e.$implicit,t=p(2),n=A.node.data==null?null:A.node.data(),o=so((n==null?null:n.name)||"root_agent"),a=Ft(2,17,t.toolsMap$);Q(3);let s=so(t.getToolsForNode(o,a)).length>0;Q(),_A("custom-node_selected",t.isNodeSelected(A.node))("custom-node_has-tools",s)("in-group",A.node.parentId&&A.node.parentId()),Q(4),nA(t.getAgentIcon(n==null?null:n.agent_class)),Q(),Ee(" ",o," "),Q(),O(t.isRootAgent(o)?10:-1),Q(2),O(t.isRootAgentForCurrentTab(o)?-1:12),Q(),O(s?13:-1),Q(),O(t.shouldShowAddButton(A.node)?14:-1),Q(),O(t.shouldShowLeftHandle(A.node)?15:-1),Q(),O(t.shouldShowTopHandle(A.node)?16:-1),Q(),O(t.shouldShowRightHandle(A.node)?17:-1),Q(),O(t.shouldShowBottomHandle(A.node)?18:-1)}}function Y3A(i,e){if(i&1&&(I(0,"vflow",8),kt(1,x3A,10,14,"ng-template",19)(2,J3A,19,20,"ng-template",20),h()),i&2){let A=p();H("nodes",A.vflowNodes())("edges",A.edges())("background",Lc(4,D3A))("snapGrid",Lc(5,v3A))}}function H3A(i,e){i&1&&(I(0,"div",9)(1,"div",51)(2,"mat-icon",52),D(3,"touch_app"),h(),I(4,"h4"),D(5,"Start Building Your ADK"),h(),I(6,"p"),D(7,"Drag components from the left panel to create your workflow"),h(),I(8,"div",53)(9,"div",54)(10,"mat-icon"),D(11,"drag_indicator"),h(),I(12,"span"),D(13,"Drag to move nodes"),h()(),I(14,"div",54)(15,"mat-icon"),D(16,"link"),h(),I(17,"span"),D(18,"Shift + Click to connect nodes"),h()()()()())}var QE=class i{constructor(e,A,t){this.dialog=e;this.agentService=A;this.router=t;this.toolsMap$=this.agentBuilderService.getAgentToolsMap(),this.agentBuilderService.getSelectedTool().subscribe(n=>{this.selectedTool=n})}_snackbarService=w(Xc);canvasRef;svgCanvasRef;agentBuilderService=w($c);cdr=w(Mt);showSidePanel=!0;showBuilderAssistant=!1;appNameInput="";toggleSidePanelRequest=new FA;builderAssistantCloseRequest=new FA;ctx;connections=mA([]);nodeId=1;edgeId=1;callbackId=1;toolId=1;appName="";nodes=mA([]);edges=mA([]);workflowShellWidth=340;workflowGroupWidth=420;workflowGroupHeight=220;workflowGroupYOffset=180;workflowGroupXOffset=-40;workflowInnerNodePoint={x:40,y:80};groupNodes=mA([]);vflowNodes=ye(()=>[...this.groupNodes(),...this.nodes()]);selectedAgents=[];selectedTool;selectedCallback;currentAgentTool=mA(null);agentToolBoards=mA(new Map);isAgentToolMode=!1;navigationStack=[];existingAgent=void 0;toolsMap$;nodePositions=new Map;ngOnInit(){this.agentService.getApp().subscribe(e=>{e&&(this.appName=e)}),this.appNameInput&&(this.appName=this.appNameInput),this.agentBuilderService.getNewTabRequest().subscribe(e=>{if(e){let{tabName:A,currentAgentName:t}=e;this.switchToAgentToolBoard(A,t)}}),this.agentBuilderService.getTabDeletionRequest().subscribe(e=>{e&&this.deleteAgentToolBoard(e)}),this.agentBuilderService.getSelectedCallback().subscribe(e=>{this.selectedCallback=e}),this.agentBuilderService.getAgentCallbacks().subscribe(e=>{if(e){let A=this.nodes().find(t=>t.data?t.data().name===e.agentName:void 0);if(A&&A.data){let t=A.data();t.callbacks=e.callbacks,A.data.set(t)}}}),this.agentBuilderService.getDeleteSubAgentSubject().subscribe(e=>{e&&this.openDeleteSubAgentDialog(e)}),this.agentBuilderService.getAddSubAgentSubject().subscribe(e=>{e.parentAgentName&&this.addSubAgent(e.parentAgentName,e.agentClass,e.isFromEmptyGroup)}),this.agentBuilderService.getSelectedNode().subscribe(e=>{this.selectedAgents=this.nodes().filter(A=>A.data&&A.data().name===e?.name)}),this.toolsMap$.subscribe(e=>{this.nodes().some(t=>t.parentId&&t.parentId())&&this.groupNodes().length>0&&this.updateGroupDimensions()})}ngOnChanges(e){e.appNameInput&&e.appNameInput.currentValue&&(this.appName=e.appNameInput.currentValue)}ngAfterViewInit(){}onCustomTemplateNodeClick(e,A){this.shouldIgnoreNodeInteraction(A.target)||this.selectAgentNode(e,{openConfig:!0})}onNodePointerDown(e,A){this.shouldIgnoreNodeInteraction(A.target)||this.selectAgentNode(e,{openConfig:!1})}onGroupClick(e,A){if(A.stopPropagation(),!e?.data)return;let t=e.data().name,n=this.nodes().find(o=>o.data&&o.data().name===t);n&&this.selectAgentNode(n,{openConfig:!0})}onGroupPointerDown(e,A){if(A.stopPropagation(),!e?.data)return;let t=e.data().name,n=this.nodes().find(o=>o.data&&o.data().name===t);n&&this.selectAgentNode(n,{openConfig:!1})}onCanvasClick(e){let A=e.target;if(!A)return;let t=[".custom-node",".action-button-bar",".add-subagent-btn",".open-panel-btn",".agent-tool-banner",".mat-mdc-menu-panel"];A.closest(t.join(","))||this.clearCanvasSelection()}shouldIgnoreNodeInteraction(e){return e?!!e.closest("mat-chip, .add-subagent-btn, .mat-mdc-menu-panel"):!1}selectAgentNode(e,A={}){if(!e?.data)return;let t=this.agentBuilderService.getNode(e.data().name);t&&(this.agentBuilderService.setSelectedTool(void 0),this.agentBuilderService.setSelectedNode(t),this.nodePositions.set(t.name,P({},e.point())),A.openConfig&&this.agentBuilderService.requestSideTabChange("config"))}handleAgentTypeSelection(e,A,t,n,o=!1){n.stopPropagation(),t?.closeMenu(),this.onAgentTypeSelected(e,A,o)}clearCanvasSelection(){!this.selectedAgents.length&&!this.selectedTool&&!this.selectedCallback||(this.selectedAgents=[],this.selectedTool=void 0,this.selectedCallback=void 0,this.agentBuilderService.setSelectedNode(void 0),this.agentBuilderService.setSelectedTool(void 0),this.agentBuilderService.setSelectedCallback(void 0),this.cdr.markForCheck())}onAddResource(e){}onAgentTypeSelected(e,A,t=!1){A&&this.addSubAgent(A,e,t)}generateNodeId(){return this.nodeId+=1,this.nodeId.toString()}generateEdgeId(){return this.edgeId+=1,this.edgeId.toString()}createNode(e,A,t){let n=mA(e),a={id:this.generateNodeId(),point:mA(P({},A)),type:"html-template",data:n};return t&&(a.parentId=mA(t)),this.nodePositions.set(e.name,P({},a.point())),a}createWorkflowGroup(e,A,t,n,o,a){let r,s=null;if(n){let B=(o||this.groupNodes()).find(u=>u.id===n);if(B){let u=B.point(),E=B.height?B.height():this.workflowGroupHeight;if(a&&o){let f=a.filter(m=>m.parentId&&m.parentId()===B.id);if(f.length>0){let z=0;for(let j of f){let X=j.data?j.data():void 0,eA=120;X&&X.tools&&X.tools.length>0&&(eA+=20+X.tools.length*36),z=Math.max(z,eA)}E=Math.max(220,80+z+40)}}r={x:u.x,y:u.y+E+60},s=null}else r={x:t.x+this.workflowGroupXOffset,y:t.y+this.workflowGroupYOffset}}else r={x:t.x+this.workflowGroupXOffset,y:t.y+this.workflowGroupYOffset};let l=this.generateNodeId(),g={id:l,point:mA(r),type:"template-group",data:mA(e),parentId:mA(s),width:mA(this.workflowGroupWidth),height:mA(this.workflowGroupHeight)},C=e.agent_class==="SequentialAgent"?{id:this.generateEdgeId(),source:A.id,sourceHandle:"source-bottom",target:l,targetHandle:"target-top"}:null;return{groupNode:g,edge:C}}calculateWorkflowChildPosition(e,A){let r=(A-20)/2;return{x:45+e*428,y:r}}createAgentNodeWithGroup(e,A,t,n,o){let a=this.createNode(e,A,t),r=null,s=null;if(this.isWorkflowAgent(e.agent_class)){let l=this.createWorkflowGroup(e,a,A,t,n,o);r=l.groupNode,s=l.edge}return{shellNode:a,groupNode:r,groupEdge:s}}createWorkflowChildEdge(e,A){return this.createWorkflowChildEdgeFromArrays(e,A,this.nodes(),this.groupNodes())}createWorkflowChildEdgeFromArrays(e,A,t,n){if(!A)return null;let o=n.find(r=>r.id===A);if(!o||!o.data)return null;let a=o.data().agent_class;if(a==="LoopAgent"||a==="ParallelAgent"){let r=t.find(s=>s.data&&s.data().name===o.data().name);if(r)return{id:this.generateEdgeId(),source:r.id,sourceHandle:"source-bottom",target:e.id,targetHandle:"target-top"}}if(a==="SequentialAgent"){let r=t.filter(g=>g.parentId&&g.parentId()===A);if(r.length===0)return null;r.sort((g,C)=>g.point().x-C.point().x);let s=r.findIndex(g=>g.id===e.id);if(s<=0)return null;let l=r[s-1];return{id:this.generateEdgeId(),source:l.id,sourceHandle:"source-right",target:e.id,targetHandle:"target-left"}}return null}isWorkflowAgent(e){return e?e==="SequentialAgent"||e==="ParallelAgent"||e==="LoopAgent":!1}addSubAgent(e,A="LlmAgent",t=!1){let n=this.nodes().find(C=>C.data&&C.data().name===e);if(!n||!n.data)return;let a={name:this.agentBuilderService.getNextSubAgentName(),agent_class:A,model:"gemini-2.5-flash",instruction:"You are a sub-agent that performs specialized tasks.",isRoot:!1,sub_agents:[],tools:[]},r=this.isWorkflowAgent(n.data().agent_class),s=n.parentId&&n.parentId()&&this.groupNodes().some(C=>C.id===n.parentId()),l,g=null;if(t&&r){let C=n.data();if(!C)return;let d=this.groupNodes().find(v=>v.data&&v.data()?.name===C.name);if(!d){console.error("Could not find group for workflow node");return}let B=this.agentBuilderService.getNode(n.data().name);if(!B){console.error("Could not find clicked agent data");return}let u=B.sub_agents.length,E=d.height?d.height():this.workflowGroupHeight,f=this.calculateWorkflowChildPosition(u,E),m=this.createAgentNodeWithGroup(a,f,d.id);l=m.shellNode,g=m.groupNode,B.sub_agents.push(a),g&&this.groupNodes.set([...this.groupNodes(),g]),m.groupEdge&&this.edges.set([...this.edges(),m.groupEdge])}else if(s){let C=n.parentId()??void 0,d=this.groupNodes().find(S=>S.id===C);if(!d||!d.data){console.error("Could not find parent group node");return}let B=d.data().name,u=this.agentBuilderService.getNode(B);if(!u){console.error("Could not find workflow parent agent");return}let E=u.sub_agents.length,f=d.height?d.height():this.workflowGroupHeight,m=this.calculateWorkflowChildPosition(E,f),v=this.createAgentNodeWithGroup(a,m,C);l=v.shellNode,g=v.groupNode,u.sub_agents.push(a),g&&this.groupNodes.set([...this.groupNodes(),g]),v.groupEdge&&this.edges.set([...this.edges(),v.groupEdge])}else{let C=n.data().sub_agents.length,d={x:n.point().x+C*400,y:n.point().y+300},B=this.createAgentNodeWithGroup(a,d);l=B.shellNode,g=B.groupNode;let u=this.agentBuilderService.getNode(n.data().name);u&&u.sub_agents.push(a),g&&this.groupNodes.set([...this.groupNodes(),g]),B.groupEdge&&this.edges.set([...this.edges(),B.groupEdge])}if(this.agentBuilderService.addNode(a),this.nodes.set([...this.nodes(),l]),this.selectedAgents=[l],(s||r)&&this.updateGroupDimensions(),r||s){let C=l.parentId?l.parentId()??void 0:void 0,d=this.createWorkflowChildEdge(l,C);d&&this.edges.set([...this.edges(),d])}else{let C={id:this.generateEdgeId(),source:n.id,sourceHandle:"source-bottom",target:l.id,targetHandle:"target-top"};this.edges.set([...this.edges(),C])}this.agentBuilderService.setSelectedNode(a),this.agentBuilderService.requestSideTabChange("config")}addTool(e){let A=this.nodes().find(o=>o.id===e);if(!A||!A.data)return;let t=A.data();if(!t)return;this.dialog.open(Q2,{width:"500px"}).afterClosed().subscribe(o=>{if(o)if(o.toolType==="Agent Tool")this.createAgentTool(t.name);else{let a={toolType:o.toolType,name:o.name};this.agentBuilderService.addTool(t.name,a),this.agentBuilderService.setSelectedTool(a)}})}addCallback(e){let A=this.nodes().find(o=>o.id===e);if(!A||!A.data)return;let t={name:`callback_${this.callbackId}`,type:"before_agent",code:`def callback_function(callback_context): |