@field/cascade 0.2.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +168 -0
- package/ARCHITECTURE.md +137 -0
- package/DESIGN.md +161 -0
- package/LICENSE +21 -0
- package/README.md +229 -0
- package/dist/assets/CodeEditor-DR7u0q7p.css +1 -0
- package/dist/assets/CodeEditor-DoaNEUaM.js +641 -0
- package/dist/assets/CodePanel-B0_2XJ-t.js +2 -0
- package/dist/assets/CodePanel-IT1secyI.css +1 -0
- package/dist/assets/CustomNodeDialog-026lzecD.js +1 -0
- package/dist/assets/CustomNodeDialog-JGYnWY6m.css +1 -0
- package/dist/assets/ExportDialog-DOq0flMV.css +1 -0
- package/dist/assets/ExportDialog-DWN4nhXI.js +358 -0
- package/dist/assets/ProjectSettings-BzT164Yx.js +2 -0
- package/dist/assets/ProjectSettings-DdO9xoQz.css +1 -0
- package/dist/assets/SettingsDialog-CeK7ytpY.css +1 -0
- package/dist/assets/SettingsDialog-DmHb1V0r.js +1 -0
- package/dist/assets/VersionHistoryDialog-CWNmHQ-P.css +1 -0
- package/dist/assets/VersionHistoryDialog-hH6VsXLX.js +3 -0
- package/dist/assets/abap-08VXUWAP.js +1 -0
- package/dist/assets/apex-BWPQTe0t.js +1 -0
- package/dist/assets/azcli-Bc_sGQ0U.js +1 -0
- package/dist/assets/bat-i0X4ZdIN.js +1 -0
- package/dist/assets/bicep-B5-_aFwp.js +2 -0
- package/dist/assets/cameligo-DMUM7wLl.js +1 -0
- package/dist/assets/cascade.jpg +0 -0
- package/dist/assets/clojure-Cm7r79vr.js +1 -0
- package/dist/assets/codicon-Brq4_Ui5.ttf +0 -0
- package/dist/assets/coffee-Ba7i2nA0.js +1 -0
- package/dist/assets/core-Bji4aZUU.js +965 -0
- package/dist/assets/cpp-C7h46wYY.js +1 -0
- package/dist/assets/csharp-BKxtCVv1.js +1 -0
- package/dist/assets/csp-bTuwJoIa.js +1 -0
- package/dist/assets/css-DIMkf-bt.js +3 -0
- package/dist/assets/css.worker-B3ciXF_0.js +93 -0
- package/dist/assets/cssMode-B6Z_Q1Kh.js +1 -0
- package/dist/assets/cypher-CVaqCwHa.js +1 -0
- package/dist/assets/dart-onAF5SnQ.js +1 -0
- package/dist/assets/dockerfile-DZFCIeNp.js +1 -0
- package/dist/assets/ecl-D05T4iGw.js +1 -0
- package/dist/assets/editor-1FQrmyyI.css +1 -0
- package/dist/assets/editor.api-jMoW_43X.js +847 -0
- package/dist/assets/editor.worker-q-txB4vs.js +30 -0
- package/dist/assets/elixir-6RTg0lbw.js +1 -0
- package/dist/assets/flow9-C5_-GSwl.js +1 -0
- package/dist/assets/freemarker2-DvvPV6m5.js +3 -0
- package/dist/assets/fsharp-C8Ef5oNN.js +1 -0
- package/dist/assets/geo-CXmCtzMM.js +2 -0
- package/dist/assets/go-C-y9NEjX.js +1 -0
- package/dist/assets/graphql-fmXr3nnJ.js +1 -0
- package/dist/assets/handlebars-B8rfuSIa.js +1 -0
- package/dist/assets/hcl-CpzslTdj.js +1 -0
- package/dist/assets/html-DyHm6JCp.js +1 -0
- package/dist/assets/html.worker-C93Ht9o9.js +506 -0
- package/dist/assets/htmlMode-E9XLWE5u.js +1 -0
- package/dist/assets/image-BUcQC7PG.js +2076 -0
- package/dist/assets/index-BXYXSdgh.js +224 -0
- package/dist/assets/index-CrNke7SW.css +1 -0
- package/dist/assets/index-client-DN_FvjN8.js +1 -0
- package/dist/assets/ini-sBoK_t0W.js +1 -0
- package/dist/assets/java-BEtHBSE6.js +1 -0
- package/dist/assets/javascript-C_bM5PCN.js +1 -0
- package/dist/assets/json.worker-B2V3pomh.js +62 -0
- package/dist/assets/jsonMode-BdyVS7G4.js +7 -0
- package/dist/assets/julia-Bri6UV-V.js +1 -0
- package/dist/assets/kotlin-BOotOW0E.js +1 -0
- package/dist/assets/legacy-DIu3XRwl.js +2 -0
- package/dist/assets/less-B9JPFI3C.js +2 -0
- package/dist/assets/lexon-CfSJPG6W.js +1 -0
- package/dist/assets/liquid-CDkn3spA.js +1 -0
- package/dist/assets/lspLanguageFeatures-AB5DMAsr.js +4 -0
- package/dist/assets/lua-CsQS60Ue.js +1 -0
- package/dist/assets/m3-D-oSqn_W.js +1 -0
- package/dist/assets/markdown-Cimd5fb3.js +1 -0
- package/dist/assets/mdx-BvH_NjDN.js +1 -0
- package/dist/assets/mips-CIPQ_RoX.js +1 -0
- package/dist/assets/msdax-DauUninz.js +1 -0
- package/dist/assets/mysql-SOo6toE5.js +1 -0
- package/dist/assets/nodeTypeUtils-CweA3NHd.js +1 -0
- package/dist/assets/objective-c-FvmIjYaQ.js +1 -0
- package/dist/assets/pascal-DrH0SRf2.js +1 -0
- package/dist/assets/pascaligo-D-ptJ9y-.js +1 -0
- package/dist/assets/perl-oz_6vUea.js +1 -0
- package/dist/assets/pgsql-DTj74zXo.js +1 -0
- package/dist/assets/php-nr791fC2.js +1 -0
- package/dist/assets/pla-CopQ2nXW.js +1 -0
- package/dist/assets/postiats-43DmfD33.js +1 -0
- package/dist/assets/powerquery-D3hlyOfw.js +1 -0
- package/dist/assets/powershell-DmHpPYUd.js +1 -0
- package/dist/assets/projectSettingsApi-C1WvIwfP.js +1 -0
- package/dist/assets/protobuf-C531GsRP.js +2 -0
- package/dist/assets/pug-Z5eAx3Zn.js +1 -0
- package/dist/assets/python-B7uii4fi.js +1 -0
- package/dist/assets/qsharp-DkqhCAOL.js +1 -0
- package/dist/assets/quill-DjZ69wL_.js +121 -0
- package/dist/assets/r-BwWrilGY.js +1 -0
- package/dist/assets/razor-Z48fWdJc.js +1 -0
- package/dist/assets/redis-ClamHrr6.js +1 -0
- package/dist/assets/redshift-DT7zqm-g.js +1 -0
- package/dist/assets/restructuredtext-BYgofb2h.js +1 -0
- package/dist/assets/ruby-DezsRK8O.js +1 -0
- package/dist/assets/rust-DdL9SqIa.js +1 -0
- package/dist/assets/sb-CcwsVR0C.js +1 -0
- package/dist/assets/scala-DHpiXF5c.js +1 -0
- package/dist/assets/scheme-BeGwcela.js +1 -0
- package/dist/assets/scss-gp-XZpBa.js +3 -0
- package/dist/assets/shell-CC2rA5mh.js +1 -0
- package/dist/assets/solidity-BEEn4gHE.js +1 -0
- package/dist/assets/sophia-CRfGWb83.js +1 -0
- package/dist/assets/sparql-D_Lu-MrJ.js +1 -0
- package/dist/assets/sql-NEE52Syq.js +1 -0
- package/dist/assets/st-DbInun42.js +1 -0
- package/dist/assets/swift-Bxkupp3x.js +1 -0
- package/dist/assets/systemverilog-Bz4Y3fRF.js +1 -0
- package/dist/assets/tcl-DISqw1ZD.js +1 -0
- package/dist/assets/ts.worker-D7T1-Ig5.js +67738 -0
- package/dist/assets/tsMode-BDgacVG4.js +11 -0
- package/dist/assets/twig-De2hgUGE.js +1 -0
- package/dist/assets/typescript-Derb6Oqa.js +1 -0
- package/dist/assets/typespec-B8J7ngcE.js +1 -0
- package/dist/assets/vb-DV3o63ZY.js +1 -0
- package/dist/assets/wgsl-DpFanUEy.js +298 -0
- package/dist/assets/workers-BtoMX_pm.js +1 -0
- package/dist/assets/xml-B1CaFSrG.js +1 -0
- package/dist/assets/yaml-HmIeA0KH.js +1 -0
- package/dist/cli/index.js +11377 -0
- package/dist/cli/index.js.map +7 -0
- package/dist/cli/runtime/io.ts +445 -0
- package/dist/cli/runtime/net.ts +19 -0
- package/dist/cli/runtime/shell.ts +46 -0
- package/dist/cli/runtime/stage.ts +132 -0
- package/dist/contracts/capabilities.d.ts +109 -0
- package/dist/contracts/capabilities.d.ts.map +1 -0
- package/dist/contracts/capabilities.js +11 -0
- package/dist/contracts/capabilities.js.map +1 -0
- package/dist/contracts/color.d.ts +67 -0
- package/dist/contracts/color.d.ts.map +1 -0
- package/dist/contracts/color.js +83 -0
- package/dist/contracts/color.js.map +1 -0
- package/dist/contracts/definition.d.ts +118 -0
- package/dist/contracts/definition.d.ts.map +1 -0
- package/dist/contracts/definition.js +2 -0
- package/dist/contracts/definition.js.map +1 -0
- package/dist/contracts/document.d.ts +50 -0
- package/dist/contracts/document.d.ts.map +1 -0
- package/dist/contracts/document.js +2 -0
- package/dist/contracts/document.js.map +1 -0
- package/dist/contracts/geometry.d.ts +301 -0
- package/dist/contracts/geometry.d.ts.map +1 -0
- package/dist/contracts/geometry.js +604 -0
- package/dist/contracts/geometry.js.map +1 -0
- package/dist/contracts/index.d.ts +8 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +8 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/contracts/schema.d.ts +6 -0
- package/dist/contracts/schema.d.ts.map +1 -0
- package/dist/contracts/schema.js +85 -0
- package/dist/contracts/schema.js.map +1 -0
- package/dist/contracts/validate.d.ts +13 -0
- package/dist/contracts/validate.d.ts.map +1 -0
- package/dist/contracts/validate.js +202 -0
- package/dist/contracts/validate.js.map +1 -0
- package/dist/contracts/values.d.ts +100 -0
- package/dist/contracts/values.d.ts.map +1 -0
- package/dist/contracts/values.js +59 -0
- package/dist/contracts/values.js.map +1 -0
- package/dist/graphs/default-orig.cascade +128 -0
- package/dist/graphs/default.cascade +21 -0
- package/dist/index.html +19 -0
- package/dist/runtime/browser.d.ts +3 -0
- package/dist/runtime/browser.d.ts.map +1 -0
- package/dist/runtime/browser.js +12 -0
- package/dist/runtime/browser.js.map +1 -0
- package/dist/runtime/builtins/core/index.d.ts +9 -0
- package/dist/runtime/builtins/core/index.d.ts.map +1 -0
- package/dist/runtime/builtins/core/index.js +21 -0
- package/dist/runtime/builtins/core/index.js.map +1 -0
- package/dist/runtime/builtins/core/random.d.ts +66 -0
- package/dist/runtime/builtins/core/random.d.ts.map +1 -0
- package/dist/runtime/builtins/core/random.js +46 -0
- package/dist/runtime/builtins/core/random.js.map +1 -0
- package/dist/runtime/builtins/core/remap.d.ts +105 -0
- package/dist/runtime/builtins/core/remap.d.ts.map +1 -0
- package/dist/runtime/builtins/core/remap.js +43 -0
- package/dist/runtime/builtins/core/remap.js.map +1 -0
- package/dist/runtime/builtins/core/routing.d.ts +117 -0
- package/dist/runtime/builtins/core/routing.d.ts.map +1 -0
- package/dist/runtime/builtins/core/routing.js +114 -0
- package/dist/runtime/builtins/core/routing.js.map +1 -0
- package/dist/runtime/builtins/core/structural.d.ts +86 -0
- package/dist/runtime/builtins/core/structural.d.ts.map +1 -0
- package/dist/runtime/builtins/core/structural.js +63 -0
- package/dist/runtime/builtins/core/structural.js.map +1 -0
- package/dist/runtime/builtins/geo/copyToPoints.d.ts +58 -0
- package/dist/runtime/builtins/geo/copyToPoints.d.ts.map +1 -0
- package/dist/runtime/builtins/geo/copyToPoints.js +35 -0
- package/dist/runtime/builtins/geo/copyToPoints.js.map +1 -0
- package/dist/runtime/builtins/geo/definitions.d.ts +526 -0
- package/dist/runtime/builtins/geo/definitions.d.ts.map +1 -0
- package/dist/runtime/builtins/geo/definitions.js +182 -0
- package/dist/runtime/builtins/geo/definitions.js.map +1 -0
- package/dist/runtime/builtins/geo/generators.d.ts +94 -0
- package/dist/runtime/builtins/geo/generators.d.ts.map +1 -0
- package/dist/runtime/builtins/geo/generators.js +41 -0
- package/dist/runtime/builtins/geo/generators.js.map +1 -0
- package/dist/runtime/builtins/geo/index.d.ts +23 -0
- package/dist/runtime/builtins/geo/index.d.ts.map +1 -0
- package/dist/runtime/builtins/geo/index.js +35 -0
- package/dist/runtime/builtins/geo/index.js.map +1 -0
- package/dist/runtime/builtins/geo/merge.d.ts +40 -0
- package/dist/runtime/builtins/geo/merge.d.ts.map +1 -0
- package/dist/runtime/builtins/geo/merge.js +24 -0
- package/dist/runtime/builtins/geo/merge.js.map +1 -0
- package/dist/runtime/builtins/geo/namespace.d.ts +15 -0
- package/dist/runtime/builtins/geo/namespace.d.ts.map +1 -0
- package/dist/runtime/builtins/geo/namespace.js +17 -0
- package/dist/runtime/builtins/geo/namespace.js.map +1 -0
- package/dist/runtime/builtins/geo/svgExport.d.ts +130 -0
- package/dist/runtime/builtins/geo/svgExport.d.ts.map +1 -0
- package/dist/runtime/builtins/geo/svgExport.js +50 -0
- package/dist/runtime/builtins/geo/svgExport.js.map +1 -0
- package/dist/runtime/builtins/geo/transform.d.ts +60 -0
- package/dist/runtime/builtins/geo/transform.d.ts.map +1 -0
- package/dist/runtime/builtins/geo/transform.js +32 -0
- package/dist/runtime/builtins/geo/transform.js.map +1 -0
- package/dist/runtime/builtins/index.d.ts +9 -0
- package/dist/runtime/builtins/index.d.ts.map +1 -0
- package/dist/runtime/builtins/index.js +16 -0
- package/dist/runtime/builtins/index.js.map +1 -0
- package/dist/runtime/definition/architecture.d.ts +8 -0
- package/dist/runtime/definition/architecture.d.ts.map +1 -0
- package/dist/runtime/definition/architecture.js +112 -0
- package/dist/runtime/definition/architecture.js.map +1 -0
- package/dist/runtime/definition/extract.d.ts +12 -0
- package/dist/runtime/definition/extract.d.ts.map +1 -0
- package/dist/runtime/definition/extract.js +151 -0
- package/dist/runtime/definition/extract.js.map +1 -0
- package/dist/runtime/error.d.ts +8 -0
- package/dist/runtime/error.d.ts.map +1 -0
- package/dist/runtime/error.js +11 -0
- package/dist/runtime/error.js.map +1 -0
- package/dist/runtime/geometry/attributes.d.ts +65 -0
- package/dist/runtime/geometry/attributes.d.ts.map +1 -0
- package/dist/runtime/geometry/attributes.js +201 -0
- package/dist/runtime/geometry/attributes.js.map +1 -0
- package/dist/runtime/geometry/builder.d.ts +57 -0
- package/dist/runtime/geometry/builder.d.ts.map +1 -0
- package/dist/runtime/geometry/builder.js +153 -0
- package/dist/runtime/geometry/builder.js.map +1 -0
- package/dist/runtime/geometry/copy.d.ts +36 -0
- package/dist/runtime/geometry/copy.d.ts.map +1 -0
- package/dist/runtime/geometry/copy.js +68 -0
- package/dist/runtime/geometry/copy.js.map +1 -0
- package/dist/runtime/geometry/generate.d.ts +43 -0
- package/dist/runtime/geometry/generate.d.ts.map +1 -0
- package/dist/runtime/geometry/generate.js +76 -0
- package/dist/runtime/geometry/generate.js.map +1 -0
- package/dist/runtime/geometry/groups.d.ts +18 -0
- package/dist/runtime/geometry/groups.d.ts.map +1 -0
- package/dist/runtime/geometry/groups.js +69 -0
- package/dist/runtime/geometry/groups.js.map +1 -0
- package/dist/runtime/geometry/index.d.ts +23 -0
- package/dist/runtime/geometry/index.d.ts.map +1 -0
- package/dist/runtime/geometry/index.js +23 -0
- package/dist/runtime/geometry/index.js.map +1 -0
- package/dist/runtime/geometry/matrix.d.ts +26 -0
- package/dist/runtime/geometry/matrix.d.ts.map +1 -0
- package/dist/runtime/geometry/matrix.js +27 -0
- package/dist/runtime/geometry/matrix.js.map +1 -0
- package/dist/runtime/geometry/merge.d.ts +33 -0
- package/dist/runtime/geometry/merge.d.ts.map +1 -0
- package/dist/runtime/geometry/merge.js +185 -0
- package/dist/runtime/geometry/merge.js.map +1 -0
- package/dist/runtime/geometry/primitives.d.ts +41 -0
- package/dist/runtime/geometry/primitives.d.ts.map +1 -0
- package/dist/runtime/geometry/primitives.js +131 -0
- package/dist/runtime/geometry/primitives.js.map +1 -0
- package/dist/runtime/geometry/promote.d.ts +44 -0
- package/dist/runtime/geometry/promote.d.ts.map +1 -0
- package/dist/runtime/geometry/promote.js +203 -0
- package/dist/runtime/geometry/promote.js.map +1 -0
- package/dist/runtime/geometry/resample.d.ts +29 -0
- package/dist/runtime/geometry/resample.d.ts.map +1 -0
- package/dist/runtime/geometry/resample.js +165 -0
- package/dist/runtime/geometry/resample.js.map +1 -0
- package/dist/runtime/geometry/svg.d.ts +91 -0
- package/dist/runtime/geometry/svg.d.ts.map +1 -0
- package/dist/runtime/geometry/svg.js +216 -0
- package/dist/runtime/geometry/svg.js.map +1 -0
- package/dist/runtime/geometry/transform.d.ts +18 -0
- package/dist/runtime/geometry/transform.d.ts.map +1 -0
- package/dist/runtime/geometry/transform.js +56 -0
- package/dist/runtime/geometry/transform.js.map +1 -0
- package/dist/runtime/index.d.ts +5 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +4 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/node.d.ts +4 -0
- package/dist/runtime/node.d.ts.map +1 -0
- package/dist/runtime/node.js +12 -0
- package/dist/runtime/node.js.map +1 -0
- package/dist/runtime/runtime.d.ts +3 -0
- package/dist/runtime/runtime.d.ts.map +1 -0
- package/dist/runtime/runtime.js +1198 -0
- package/dist/runtime/runtime.js.map +1 -0
- package/dist/runtime/types.d.ts +241 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +2 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/shell.d.ts +8 -0
- package/dist/shell.js +54 -0
- package/dist/shell.js.map +7 -0
- package/dist/stage.d.ts +7 -0
- package/dist/stage.js +84 -0
- package/dist/stage.js.map +7 -0
- package/dist/studio/panel.d.ts +48 -0
- package/doc/PROJECT_AUTHORING.md +360 -0
- package/package.json +126 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CodePanel-B0_2XJ-t.js","assets/legacy-DIu3XRwl.js","assets/CodePanel-IT1secyI.css","assets/CustomNodeDialog-026lzecD.js","assets/CustomNodeDialog-JGYnWY6m.css","assets/VersionHistoryDialog-hH6VsXLX.js","assets/VersionHistoryDialog-CWNmHQ-P.css","assets/ExportDialog-DWN4nhXI.js","assets/ExportDialog-DOq0flMV.css","assets/SettingsDialog-DmHb1V0r.js","assets/SettingsDialog-CeK7ytpY.css","assets/ProjectSettings-BzT164Yx.js","assets/projectSettingsApi-C1WvIwfP.js","assets/ProjectSettings-DdO9xoQz.css","assets/core-Bji4aZUU.js","assets/nodeTypeUtils-CweA3NHd.js","assets/geo-CXmCtzMM.js","assets/image-BUcQC7PG.js","assets/quill-DjZ69wL_.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{$ as e,A as t,B as n,Ct as r,D as i,Dt as a,E as o,Et as s,F as c,G as l,H as u,I as d,J as f,K as p,L as m,M as h,N as g,O as _,P as v,Q as y,R as b,S as x,St as S,T as C,Tt as w,U as T,V as E,W as D,X as O,Y as k,Z as ee,_ as te,_t as A,a as j,at as M,b as N,bt as P,c as F,ct as I,d as ne,dt as re,et as ie,f as ae,ft as L,gt as oe,h as R,ht as se,i as z,it as B,j as ce,k as V,l as le,lt as H,m as ue,mt as U,n as de,nt as fe,o as W,ot as G,p as pe,pt as me,q as K,r as he,rt as q,s as ge,st as _e,t as ve,tt as J,u as ye,ut as Y,v as be,vt as xe,w as Se,wt as Ce,x as we,xt as Te,y as Ee,yt as De,z as X}from"./legacy-DIu3XRwl.js";import"./index-client-DN_FvjN8.js";import{a as Oe,i as ke,l as Ae,n as je,t as Me}from"./nodeTypeUtils-CweA3NHd.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Ne,Pe=class{constructor(){}},Fe=class extends Pe{constructor(e,t,n,r){super(),this.viewId=e,this.groupId=t,this.panelId=n,this.tabGroupId=r}},Ie=class e{constructor(){}static getInstance(){return e.INSTANCE}hasData(e){return e&&e===this.proto}clearData(e){this.hasData(e)&&(this.proto=void 0,this.data=void 0)}getData(e){if(this.hasData(e))return this.data}setData(e,t){t&&(this.data=e,this.proto=t)}};Ne=Ie,Ie.INSTANCE=new Ne;function Le(){let e=Ie.getInstance();if(e.hasData(Fe.prototype))return e.getData(Fe.prototype)[0]}var Re;(function(e){e.NONE={dispose:()=>{}};function t(e){return{dispose:()=>{e()}}}e.from=t})(Re||={});var ze=class{get isDisposed(){return this._isDisposed}constructor(...e){this._isDisposed=!1,this._disposables=new Set(e)}addDisposables(...e){e.forEach(e=>this._disposables.add(e))}removeDisposable(e){this._disposables.delete(e)}dispose(){this._isDisposed||(this._isDisposed=!0,this._disposables.forEach(e=>e.dispose()),this._disposables.clear())}},Be=class{constructor(){this._disposable=Re.NONE}get value(){return this._disposable===Re.NONE?void 0:this._disposable}set value(e){this._disposable&&this._disposable.dispose(),this._disposable=e}dispose(){this._disposable&&=(this._disposable.dispose(),Re.NONE)}},Ve;(function(e){e.any=(...e)=>t=>{let n=e.map(e=>e(t));return{dispose:()=>{n.forEach(e=>{e.dispose()})}}}})(Ve||={});var He=class{constructor(){this._defaultPrevented=!1}get defaultPrevented(){return this._defaultPrevented}preventDefault(){this._defaultPrevented=!0}},Ue=class{constructor(){this._isAccepted=!1}get isAccepted(){return this._isAccepted}accept(){this._isAccepted=!0}},We=class{constructor(){this.events=new Map}get size(){return this.events.size}add(e,t){this.events.set(e,t)}delete(e){this.events.delete(e)}clear(){this.events.clear()}},Ge=class e{static create(){return new e(Error(`listener stacktrace`).stack??``)}constructor(e){this.value=e}print(){console.warn(`dockview: stacktrace`,this.value)}},Ke=class{constructor(e,t){this.callback=e,this.stacktrace=t}},Z=class e{static setLeakageMonitorEnabled(t){t!==e.ENABLE_TRACKING&&e.MEMORY_LEAK_WATCHER.clear(),e.ENABLE_TRACKING=t}get value(){return this._last}constructor(e){this.options=e,this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=t=>{this.options?.replay&&this._last!==void 0&&t(this._last);let n=new Ke(t,e.ENABLE_TRACKING?Ge.create():void 0);return this._listeners.push(n),{dispose:()=>{let t=this._listeners.indexOf(n);t>-1?this._listeners.splice(t,1):e.ENABLE_TRACKING}}},e.ENABLE_TRACKING&&e.MEMORY_LEAK_WATCHER.add(this._event,Ge.create())),this._event}fire(e){if(this._pauseTokens!==void 0&&this._pauseTokens.size>0)return;this.options?.replay&&(this._last=e);let t=this._listeners,n=t.length;if(n!==0){if(n===1){t[0].callback(e);return}for(let n of t.slice())n.callback(e)}}pause(){let e={};return this._pauseTokens??=new Set,this._pauseTokens.add(e),Re.from(()=>this._pauseTokens?.delete(e))}dispose(){this._disposed||(this._disposed=!0,this._listeners.length>0&&(e.ENABLE_TRACKING?queueMicrotask(()=>{for(let e of this._listeners)console.warn(`dockview: stacktrace`,e.stacktrace?.print());this._listeners=[]}):this._listeners=[]),e.ENABLE_TRACKING&&this._event&&e.MEMORY_LEAK_WATCHER.delete(this._event))}};Z.ENABLE_TRACKING=!1,Z.MEMORY_LEAK_WATCHER=new We;function Q(e,t,n,r){return e.addEventListener(t,n,r),{dispose:()=>{e.removeEventListener(t,n,r)}}}var qe=class{constructor(){this._onFired=new Z,this._currentFireCount=0,this._queued=!1,this.onEvent=e=>{let t=this._currentFireCount;return this._onFired.event(()=>{this._currentFireCount>t&&e()})}}fire(){this._currentFireCount++,!this._queued&&(this._queued=!0,queueMicrotask(()=>{this._queued=!1,this._onFired.fire()}))}dispose(){this._onFired.dispose()}},Je=class extends ze{constructor(e){super(),this._onDidChange=new Z,this.onDidChange=this._onDidChange.event,this._value=null,this.addDisposables(this._onDidChange,Ye(e,e=>{let t=e.target.scrollWidth>e.target.clientWidth,n=e.target.scrollHeight>e.target.clientHeight;this._value={hasScrollX:t,hasScrollY:n},this._onDidChange.fire(this._value)}))}};function Ye(e,t){let n=new ResizeObserver(e=>{requestAnimationFrame(()=>{let n=e[0];t(n)})});return n.observe(e),{dispose:()=>{n.unobserve(e),n.disconnect()}}}var Xe=(e,...t)=>{for(let n of t)e.classList.contains(n)&&e.classList.remove(n)},Ze=(e,...t)=>{for(let n of t)e.classList.contains(n)||e.classList.add(n)},$=(e,t,n)=>{let r=e.classList.contains(t);n&&!r&&e.classList.add(t),!n&&r&&e.classList.remove(t)};function Qe(e,t){for(;e;){if(e===t)return!0;e=e.parentNode}return!1}function $e(e){return new et(e)}var et=class extends ze{constructor(e){super(),this._onDidFocus=new Z,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new Z,this.onDidBlur=this._onDidBlur.event,this.addDisposables(this._onDidFocus,this._onDidBlur);let t=Qe(document.activeElement,e),n=!1,r=()=>{n=!1,t||(t=!0,this._onDidFocus.fire())},i=()=>{t&&(n=!0,globalThis.setTimeout(()=>{n&&(n=!1,t=!1,this._onDidBlur.fire())},0))};this._refreshStateHandler=()=>{Qe(document.activeElement,e)!==t&&(t?i():r())},this.addDisposables(Q(e,`focus`,r,!0)),this.addDisposables(Q(e,`blur`,i,!0))}refreshState(){this._refreshStateHandler()}},tt=`dv-quasiPreventDefault`;function nt(e){e[tt]=!0}function rt(e){return e[tt]}function it(e,t,n={}){let r=Array.from(t),{nonce:i}=n,a=typeof i==`function`?i(e):i;for(let t of r){if(t.href){let n=e.createElement(`link`);n.href=t.href,n.type=t.type,n.rel=`stylesheet`,e.head.appendChild(n);continue}let n=[];try{t.cssRules&&(n=Array.from(t.cssRules).map(e=>e.cssText))}catch(e){console.warn(`dockview: failed to access stylesheet rules due to security restrictions`,e)}let r=e.createDocumentFragment();for(let t of n){let n=e.createElement(`style`);a&&n.setAttribute(`nonce`,a),n.appendChild(e.createTextNode(t)),r.appendChild(n)}e.head.appendChild(r)}}function at(e){let{left:t,top:n,width:r,height:i}=e.getBoundingClientRect();return{left:t+window.scrollX,top:n+window.scrollY,width:r,height:i}}function ot(e){let t=e;for(;t?.parentNode;)if(t.parentNode===document)return!0;else t=t.parentNode instanceof DocumentFragment?t.parentNode.host:t.parentNode;return!1}function st(e,t){e.dataset.testid=t}function ct(e,t){let n=[];function r(t){if(t.nodeType===Node.ELEMENT_NODE){e.includes(t.tagName)&&n.push(t),t.shadowRoot&&r(t.shadowRoot);for(let e of t.children)r(e)}}return r(t instanceof Document?t.documentElement:t),n}function lt(e=document){let t=ct([`IFRAME`,`WEBVIEW`],e),n=new WeakMap;for(let e of t)n.set(e,e.style.pointerEvents),e.style.pointerEvents=`none`;return{release:()=>{for(let e of t)e.style.pointerEvents=n.get(e)??`auto`;t.splice(0,t.length)}}}function ut(e){function t(e){let t=[];for(let n=0;n<e.classList.length;n++)t.push(e.classList.item(n));return t}let n,r=e;for(;r!==null&&(n=t(r).find(e=>e.startsWith(`dockview-theme-`)),typeof n!=`string`);)r=r.parentElement;return n}var dt=class{constructor(e){this.element=e,this._classNames=[]}setClassNames(e){for(let e of this._classNames)$(this.element,e,!1);this._classNames=e.split(` `).filter(e=>e.trim().length>0);for(let e of this._classNames)$(this.element,e,!0)}},ft=100;function pt(e,t){let n=at(e),r=at(t);return!(n.left<r.left||n.left+n.width>r.left+r.width||n.top<r.top||n.top+n.height>r.top+r.height)}function mt(e){let t=new Z,n=e.screenX,r=e.screenY,i,a=0,o=!1,s=()=>{if(o||e.closed)return;let c=e.screenX,l=e.screenY;(c!==n||l!==r)&&(clearTimeout(i),i=setTimeout(()=>{t.fire()},ft),n=c,r=l),a=requestAnimationFrame(s)};s();let c=t.dispose.bind(t);return t.dispose=()=>{o||(o=!0,cancelAnimationFrame(a),clearTimeout(i)),c()},t}function ht(e,t){let n;return new ze(Q(e,`resize`,()=>{clearTimeout(n),n=setTimeout(()=>{t()},ft)}))}function gt(e,t,n){let r=n?.buffer??10,i=e.getBoundingClientRect(),a=t.getBoundingClientRect(),o=0,s=0,c=i.left-a.left,l=i.top-a.top,u=i.bottom-a.bottom,d=i.right-a.right;c<r?o=r-c:d>r&&(o=-r-d),l<r?s=r-l:u>r&&(s=-u-r),(o!==0||s!==0)&&(e.style.transform=`translate(${o}px, ${s}px)`)}function _t(e){let t=e;for(;t&&(t.style.zIndex===`auto`||t.style.zIndex===``);)t=t.parentElement;return t}function vt(e){if(e.length===0)throw Error(`Invalid tail call`);return[e.slice(0,e.length-1),e[e.length-1]]}function yt(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function bt(e,t){let n=e.indexOf(t);n>-1&&(e.splice(n,1),e.unshift(t))}function xt(e,t){let n=e.indexOf(t);n>-1&&(e.splice(n,1),e.push(t))}function St(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(t(r))return n}return-1}function Ct(e,t){let n=e.indexOf(t);return n>-1&&(e.splice(n,1),!0)}var wt=(e,t,n)=>t>n?t:Math.min(n,Math.max(e,t)),Tt=()=>{let e=1;return{next:()=>(e++).toString()}},Et=(e,t)=>{let n=[];if(typeof t!=`number`&&(t=e,e=0),e<=t)for(let r=e;r<t;r++)n.push(r);else for(let r=e;r>t;r--)n.push(r);return n},Dt=class{set size(e){this._size=e}setContainerGeometry(e,t){this._appliedStyles[e]!==t&&(this._appliedStyles[e]=t,this.container.style[e]=t)}get size(){return this._size}get cachedVisibleSize(){return this._cachedVisibleSize}get visible(){return this._cachedVisibleSize===void 0}get minimumSize(){return this.visible?this.view.minimumSize:0}get viewMinimumSize(){return this.view.minimumSize}get maximumSize(){return this.visible?this.view.maximumSize:0}get viewMaximumSize(){return this.view.maximumSize}get priority(){return this.view.priority}get snap(){return!!this.view.snap}set enabled(e){this.container.style.pointerEvents=e?``:`none`}constructor(e,t,n,r){this.container=e,this.view=t,this.disposable=r,this._cachedVisibleSize=void 0,this._appliedStyles={},typeof n==`number`?(this._size=n,this._cachedVisibleSize=void 0,e.classList.add(`visible`)):(this._size=0,this._cachedVisibleSize=n.cachedVisibleSize)}setVisible(e,t){e!==this.visible&&(e?(this.size=wt(this._cachedVisibleSize??0,this.viewMinimumSize,this.viewMaximumSize),this._cachedVisibleSize=void 0):(this._cachedVisibleSize=typeof t==`number`?t:this.size,this.size=0),this.container.classList.toggle(`visible`,e),this.view.setVisible&&this.view.setVisible(e))}dispose(){return this.disposable.dispose(),this.view}},Ot=function(e){return e.HORIZONTAL=`HORIZONTAL`,e.VERTICAL=`VERTICAL`,e}({});function kt(e,t,n){e.appliedLeft!==t&&(e.appliedLeft=t,e.container.style.left=t),e.appliedTop!==n&&(e.appliedTop=n,e.container.style.top=n)}var At;(function(e){e.Distribute={type:`distribute`};function t(e){return{type:`split`,index:e}}e.Split=t;function n(e){return{type:`invisible`,cachedVisibleSize:e}}e.Invisible=n})(At||={});var jt=class{get contentSize(){return this._contentSize}get size(){return this._size}set size(e){this._size=e}get orthogonalSize(){return this._orthogonalSize}set orthogonalSize(e){this._orthogonalSize=e}get length(){return this.viewItems.length}get proportions(){return this._proportions?[...this._proportions]:void 0}get orientation(){return this._orientation}set orientation(e){this._orientation=e;let t=this.size;this.size=this.orthogonalSize,this.orthogonalSize=t,Xe(this.element,`dv-horizontal`,`dv-vertical`),this.element.classList.add(this.orientation==`HORIZONTAL`?`dv-horizontal`:`dv-vertical`)}get minimumSize(){return this.viewItems.reduce((e,t)=>e+t.minimumSize,0)}get maximumSize(){return this.length===0?1/0:this.viewItems.reduce((e,t)=>e+t.maximumSize,0)}get startSnappingEnabled(){return this._startSnappingEnabled}set startSnappingEnabled(e){this._startSnappingEnabled!==e&&(this._startSnappingEnabled=e,this.updateSashEnablement())}get endSnappingEnabled(){return this._endSnappingEnabled}set endSnappingEnabled(e){this._endSnappingEnabled!==e&&(this._endSnappingEnabled=e,this.updateSashEnablement())}get disabled(){return this._disabled}set disabled(e){this._disabled=e,$(this.element,`dv-splitview-disabled`,e)}get margin(){return this._margin}set margin(e){this._margin=e,$(this.element,`dv-splitview-has-margin`,e!==0)}constructor(e,t){this.container=e,this.viewItems=[],this.sashes=[],this._size=0,this._orthogonalSize=0,this._contentSize=0,this._proportions=void 0,this._startSnappingEnabled=!0,this._endSnappingEnabled=!0,this._disabled=!1,this._margin=0,this._onDidSashEnd=new Z,this.onDidSashEnd=this._onDidSashEnd.event,this._onDidAddView=new Z,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new Z,this.onDidRemoveView=this._onDidRemoveView.event,this.resize=(e,t,n=this.viewItems.map(e=>e.size),r,i,a=-1/0,o=1/0,s,c)=>{if(e<0||e>this.viewItems.length)return 0;let l=Et(e,-1),u=Et(e+1,this.viewItems.length);if(i)for(let e of i)bt(l,e),bt(u,e);if(r)for(let e of r)xt(l,e),xt(u,e);let d=l.reduce((e,t)=>e+this.viewItems[t].minimumSize-n[t],0),f=l.reduce((e,t)=>e+this.viewItems[t].maximumSize-n[t],0),p=u.length===0?1/0:u.reduce((e,t)=>e+n[t]-this.viewItems[t].minimumSize,0),m=u.length===0?-1/0:u.reduce((e,t)=>e+n[t]-this.viewItems[t].maximumSize,0),h=Math.max(d,m),g=Math.min(p,f),_=!1;if(s){let e=this.viewItems[s.index],n=t>=s.limitDelta;_=n!==e.visible,e.setVisible(n,s.size)}if(!_&&c){let e=this.viewItems[c.index],n=t<c.limitDelta;_=n!==e.visible,e.setVisible(n,c.size)}if(_)return this.resize(e,t,n,r,i,a,o);let v=wt(t,h,g),y=0,b=v;for(let e of l){let t=this.viewItems[e],r=n[e],i=wt(r+b,t.minimumSize,t.maximumSize),a=i-r;y+=a,b-=a,t.size=i}let x=y;for(let e of u){let t=this.viewItems[e],r=n[e],i=wt(r-x,t.minimumSize,t.maximumSize),a=i-r;x+=a,t.size=i}return t},this._orientation=t.orientation??`VERTICAL`,this.element=this.createContainer(),this.margin=t.margin??0,this.proportionalLayout=t.proportionalLayout===void 0||!!t.proportionalLayout,this.viewContainer=this.createViewContainer(),this.sashContainer=this.createSashContainer(),this.element.appendChild(this.sashContainer),this.element.appendChild(this.viewContainer),this.container.appendChild(this.element),this.style(t.styles),t.descriptor&&(this._size=t.descriptor.size,t.descriptor.views.forEach((e,t)=>{let n=e.visible===void 0||e.visible?e.size:{type:`invisible`,cachedVisibleSize:e.size},r=e.view;this.addView(r,n,t,!0)}),this._contentSize=this.viewItems.reduce((e,t)=>e+t.size,0),this.saveProportions())}style(e){e?.separatorBorder===`transparent`?(Xe(this.element,`dv-separator-border`),this.element.style.removeProperty(`--dv-separator-border`)):(Ze(this.element,`dv-separator-border`),e?.separatorBorder&&this.element.style.setProperty(`--dv-separator-border`,e.separatorBorder))}isViewVisible(e){if(e<0||e>=this.viewItems.length)throw Error(`Index out of bounds`);return this.viewItems[e].visible}setViewVisible(e,t){if(e<0||e>=this.viewItems.length)throw Error(`Index out of bounds`);let n=this.viewItems[e];n.setVisible(t,n.size),this.distributeEmptySpace(e),this.layoutViews(),this.saveProportions()}getViewSize(e){return e<0||e>=this.viewItems.length?-1:this.viewItems[e].size}resizeView(e,t){if(e<0||e>=this.viewItems.length)return;let n=Et(this.viewItems.length).filter(t=>t!==e),r=[...n.filter(e=>this.viewItems[e].priority===`low`),e],i=n.filter(e=>this.viewItems[e].priority===`high`),a=this.viewItems[e];t=Math.round(t),t=wt(t,a.minimumSize,Math.min(a.maximumSize,this._size)),a.size=t,this.relayout(r,i)}getViews(){return this.viewItems.map(e=>e.view)}onDidChange(e,t){let n=this.viewItems.indexOf(e);if(n<0||n>=this.viewItems.length)return;t=typeof t==`number`?t:e.size,t=wt(t,e.minimumSize,e.maximumSize),e.size=t;let r=Et(this.viewItems.length).filter(e=>e!==n),i=[...r.filter(e=>this.viewItems[e].priority===`low`),n],a=r.filter(e=>this.viewItems[e].priority===`high`);this.relayout([...i,n],a)}addView(e,t=At.Distribute,n=this.viewItems.length,r){let i=document.createElement(`div`);i.className=`dv-view`,i.appendChild(e.element);let a;a=typeof t==`number`?t:t.type===`split`?this.getViewSize(t.index)/2:t.type===`invisible`?{cachedVisibleSize:t.cachedVisibleSize}:e.minimumSize;let o=e.onDidChange(e=>this.onDidChange(s,e.size)),s=new Dt(i,e,a,{dispose:()=>{o.dispose(),i.remove()}});if(n===this.viewItems.length?this.viewContainer.appendChild(i):this.viewContainer.insertBefore(i,this.viewContainer.children.item(n)),this.viewItems.splice(n,0,s),this.viewItems.length>1){let e=document.createElement(`div`);e.className=`dv-sash`;let t=t=>{for(let e of this.viewItems)e.enabled=!1;let n=e.ownerDocument??document,r=lt(n),i=this._orientation===`HORIZONTAL`?t.clientX:t.clientY,a=St(this.sashes,t=>t.container===e),o=this.viewItems.map(e=>e.size),s,c,l=Et(a,-1),u=Et(a+1,this.viewItems.length),d=l.reduce((e,t)=>e+(this.viewItems[t].minimumSize-o[t]),0),f=l.reduce((e,t)=>e+(this.viewItems[t].viewMaximumSize-o[t]),0),p=u.length===0?1/0:u.reduce((e,t)=>e+(o[t]-this.viewItems[t].minimumSize),0),m=u.length===0?-1/0:u.reduce((e,t)=>e+(o[t]-this.viewItems[t].viewMaximumSize),0),h=Math.max(d,m),g=Math.min(p,f),_=this.findFirstSnapIndex(l),v=this.findFirstSnapIndex(u);if(typeof _==`number`){let e=this.viewItems[_],t=Math.floor(e.viewMinimumSize/2);s={index:_,limitDelta:e.visible?h-t:h+t,size:e.size}}if(typeof v==`number`){let e=this.viewItems[v],t=Math.floor(e.viewMinimumSize/2);c={index:v,limitDelta:e.visible?g+t:g-t,size:e.size}}let y=e=>{let t=(this._orientation===`HORIZONTAL`?e.clientX:e.clientY)-i;this.resize(a,t,o,void 0,void 0,h,g,s,c),this.distributeEmptySpace(),this.layoutViews()},b=()=>{for(let e of this.viewItems)e.enabled=!0;r.release(),this.saveProportions(),n.removeEventListener(`pointermove`,y),n.removeEventListener(`pointerup`,b),n.removeEventListener(`pointercancel`,b),n.removeEventListener(`contextmenu`,b),this._onDidSashEnd.fire(void 0)};n.addEventListener(`pointermove`,y),n.addEventListener(`pointerup`,b),n.addEventListener(`pointercancel`,b),n.addEventListener(`contextmenu`,b)};e.addEventListener(`pointerdown`,t);let n={container:e,disposable:()=>{e.removeEventListener(`pointerdown`,t),e.remove()}};this.sashContainer.appendChild(e),this.sashes.push(n)}r||this.relayout([n]),!r&&typeof t!=`number`&&t.type===`distribute`&&this.distributeViewSizes(),this._onDidAddView.fire(e)}distributeViewSizes(){let e=[],t=0;for(let n of this.viewItems)n.maximumSize-n.minimumSize>0&&(e.push(n),t+=n.size);let n=Math.floor(t/e.length);for(let t of e)t.size=wt(n,t.minimumSize,t.maximumSize);let r=Et(this.viewItems.length),i=r.filter(e=>this.viewItems[e].priority===`low`),a=r.filter(e=>this.viewItems[e].priority===`high`);this.relayout(i,a)}removeView(e,t,n=!1){let r=this.viewItems.splice(e,1)[0];if(r.dispose(),this.viewItems.length>=1){let t=Math.max(e-1,0);this.sashes.splice(t,1)[0].disposable()}return n||this.relayout(),t?.type===`distribute`&&this.distributeViewSizes(),this._onDidRemoveView.fire(r.view),r.view}getViewCachedVisibleSize(e){if(e<0||e>=this.viewItems.length)throw Error(`Index out of bounds`);return this.viewItems[e].cachedVisibleSize}moveView(e,t){let n=this.getViewCachedVisibleSize(e),r=n===void 0?this.getViewSize(e):At.Invisible(n),i=this.removeView(e,void 0,!0);this.addView(i,r,t)}layout(e,t){let n=Math.max(this.size,this._contentSize);if(this.size=e,this.orthogonalSize=t,this.proportions){let t=0;for(let n=0;n<this.viewItems.length;n++){let r=this.viewItems[n],i=this.proportions[n];typeof i==`number`?t+=i:e-=r.size}for(let n=0;n<this.viewItems.length;n++){let r=this.viewItems[n],i=this.proportions[n];typeof i==`number`&&t>0&&(r.size=wt(Math.round(i*e/t),r.minimumSize,r.maximumSize))}}else{let t=Et(this.viewItems.length),r=t.filter(e=>this.viewItems[e].priority===`low`),i=t.filter(e=>this.viewItems[e].priority===`high`);this.resize(this.viewItems.length-1,e-n,void 0,r,i)}this.distributeEmptySpace(),this.layoutViews()}relayout(e,t){let n=this.viewItems.reduce((e,t)=>e+t.size,0);this.resize(this.viewItems.length-1,this._size-n,void 0,e,t),this.distributeEmptySpace(),this.layoutViews(),this.saveProportions()}distributeEmptySpace(e){let t=0;for(let e of this.viewItems)t+=e.size;let n=this.size-t;if(n===0)return;let r=Et(this.viewItems.length-1,-1),i=!1;for(let e of this.viewItems)if(e.priority===`low`||e.priority===`high`){i=!0;break}if(i){let e=r.filter(e=>this.viewItems[e].priority===`low`),t=r.filter(e=>this.viewItems[e].priority===`high`);for(let e of t)bt(r,e);for(let t of e)xt(r,t)}typeof e==`number`&&xt(r,e);for(let e=0;n!==0&&e<r.length;e++){let t=this.viewItems[r[e]],i=wt(t.size+n,t.minimumSize,t.maximumSize),a=i-t.size;n-=a,t.size=i}}saveProportions(){this.proportionalLayout&&this._contentSize>0&&(this._proportions=this.viewItems.map(e=>e.visible?e.size/this._contentSize:void 0))}layoutViews(){let e=0,t=0;for(let n of this.viewItems)e+=n.size,n.visible&&t++;if(this._contentSize=e,this.updateSashEnablement(),this.viewItems.length===0)return;let n=Math.max(0,t-1),r=this.margin*n/Math.max(1,t),i=0,a=[],o=0;this.viewItems.forEach((e,t)=>{i+=this.viewItems[t].size,a.push(i),o+=+!!e.visible;let s=e.visible?e.size-r:0,c=Math.max(0,o-1),l=t===0||c===0?0:a[t-1]+c/n*r;if(t<this.viewItems.length-1){let n=e.visible?l+s-2+this.margin/2:l,r=this.sashes[t];this._orientation===`HORIZONTAL`&&kt(r,`${n}px`,`0px`),this._orientation===`VERTICAL`&&kt(r,`0px`,`${n}px`)}this._orientation===`HORIZONTAL`&&(e.setContainerGeometry(`width`,`${s}px`),e.setContainerGeometry(`left`,`${l}px`),e.setContainerGeometry(`top`,``),e.setContainerGeometry(`height`,``)),this._orientation===`VERTICAL`&&(e.setContainerGeometry(`height`,`${s}px`),e.setContainerGeometry(`top`,`${l}px`),e.setContainerGeometry(`width`,``),e.setContainerGeometry(`left`,``)),e.view.layout(e.size-r,this._orthogonalSize)})}findFirstSnapIndex(e){for(let t of e){let e=this.viewItems[t];if(e.visible&&e.snap)return t}for(let t of e){let e=this.viewItems[t];if(e.visible&&e.maximumSize-e.minimumSize>0)return;if(!e.visible&&e.snap)return t}}updateSashEnablement(){if(this.sashes.length===0)return;let e=!1,t=this.viewItems.map(t=>e=t.size-t.minimumSize>0||e);e=!1;let n=this.viewItems.map(t=>e=t.maximumSize-t.size>0||e),r=[...this.viewItems].reverse();e=!1;let i=r.map(t=>e=t.size-t.minimumSize>0||e).reverse();e=!1;let a=r.map(t=>e=t.maximumSize-t.size>0||e).reverse(),o=0;for(let e=0;e<this.sashes.length;e++){let r=this.sashes[e],s=this.viewItems[e];o+=s.size;let c=!(t[e]&&a[e+1]),l=!(n[e]&&i[e+1]);if(c&&l){let n=Et(e,-1),a=Et(e+1,this.viewItems.length),s=this.findFirstSnapIndex(n),c=this.findFirstSnapIndex(a),l=typeof s==`number`&&!this.viewItems[s].visible,u=typeof c==`number`&&!this.viewItems[c].visible;l&&i[e]&&(o>0||this.startSnappingEnabled)?this.updateSash(r,1):u&&t[e]&&(o<this._contentSize||this.endSnappingEnabled)?this.updateSash(r,0):this.updateSash(r,2)}else c&&!l?this.updateSash(r,1):!c&&l?this.updateSash(r,0):this.updateSash(r,3)}}updateSash(e,t){$(e.container,`dv-disabled`,t===2),$(e.container,`dv-enabled`,t===3),$(e.container,`dv-maximum`,t===0),$(e.container,`dv-minimum`,t===1)}createViewContainer(){let e=document.createElement(`div`);return e.className=`dv-view-container`,e}createSashContainer(){let e=document.createElement(`div`);return e.className=`dv-sash-container`,e}createContainer(){let e=document.createElement(`div`);return e.className=`dv-split-view-container ${this._orientation===`HORIZONTAL`?`dv-horizontal`:`dv-vertical`}`,e}dispose(){this._onDidSashEnd.dispose(),this._onDidAddView.dispose(),this._onDidRemoveView.dispose();for(let e=0;e<this.element.children.length;e++)if(this.element.children.item(e)===this.element){this.element.remove();break}for(let e of this.viewItems)e.dispose();this.element.remove()}},Mt=class{get minimumWidth(){return this.view.minimumWidth}get maximumWidth(){return this.view.maximumWidth}get minimumHeight(){return this.view.minimumHeight}get maximumHeight(){return this.view.maximumHeight}get priority(){return this.view.priority}get snap(){return this.view.snap}get minimumSize(){return this.orientation===`HORIZONTAL`?this.minimumHeight:this.minimumWidth}get maximumSize(){return this.orientation===`HORIZONTAL`?this.maximumHeight:this.maximumWidth}get minimumOrthogonalSize(){return this.orientation===`HORIZONTAL`?this.minimumWidth:this.minimumHeight}get maximumOrthogonalSize(){return this.orientation===`HORIZONTAL`?this.maximumWidth:this.maximumHeight}get orthogonalSize(){return this._orthogonalSize}get size(){return this._size}get element(){return this.view.element}get width(){return this.orientation===`HORIZONTAL`?this.orthogonalSize:this.size}get height(){return this.orientation===`HORIZONTAL`?this.size:this.orthogonalSize}constructor(e,t,n,r=0){this.view=e,this.orientation=t,this._onDidChange=new Z,this.onDidChange=this._onDidChange.event,this._orthogonalSize=n,this._size=r,this._disposable=this.view.onDidChange(e=>{e?this._onDidChange.fire({size:this.orientation===`VERTICAL`?e.width:e.height,orthogonalSize:this.orientation===`VERTICAL`?e.height:e.width}):this._onDidChange.fire({})})}setVisible(e){this.view.setVisible&&this.view.setVisible(e)}layout(e,t){this._size=e,this._orthogonalSize=t,this.view.layout(this.width,this.height)}dispose(){this._onDidChange.dispose(),this._disposable.dispose()}},Nt=class e extends ze{get width(){return this.orientation===`HORIZONTAL`?this.size:this.orthogonalSize}get height(){return this.orientation===`HORIZONTAL`?this.orthogonalSize:this.size}get minimumSize(){if(this._cachedMinimumSize===void 0){let e=0;for(let t=0;t<this.children.length;t++)this.splitview.isViewVisible(t)&&(e=Math.max(e,this.children[t].minimumOrthogonalSize));this._cachedMinimumSize=e}return this._cachedMinimumSize}get maximumSize(){if(this._cachedMaximumSize===void 0){let e=1/0;for(let t=0;t<this.children.length;t++)this.splitview.isViewVisible(t)&&(e=Math.min(e,this.children[t].maximumOrthogonalSize));this._cachedMaximumSize=e}return this._cachedMaximumSize}get minimumOrthogonalSize(){return this.splitview.minimumSize}get maximumOrthogonalSize(){return this.splitview.maximumSize}get orthogonalSize(){return this._orthogonalSize}get size(){return this._size}get minimumWidth(){return this.orientation===`HORIZONTAL`?this.minimumOrthogonalSize:this.minimumSize}get minimumHeight(){return this.orientation===`HORIZONTAL`?this.minimumSize:this.minimumOrthogonalSize}get maximumWidth(){return this.orientation===`HORIZONTAL`?this.maximumOrthogonalSize:this.maximumSize}get maximumHeight(){return this.orientation===`HORIZONTAL`?this.maximumSize:this.maximumOrthogonalSize}get priority(){return this._cachedPriority??=this.computePriority(),this._cachedPriority}computePriority(){if(this.children.length===0)return`normal`;let e=!1,t=!1;for(let n of this.children){let r=n.priority??`normal`;r===`high`?e=!0:r===`low`&&(t=!0)}return e?`high`:t?`low`:`normal`}invalidateCachedSizes(){this._cachedMinimumSize=void 0,this._cachedMaximumSize=void 0,this._cachedPriority=void 0}get disabled(){return this.splitview.disabled}set disabled(e){this.splitview.disabled=e}get margin(){return this.splitview.margin}set margin(t){this.splitview.margin=t,this.children.forEach(n=>{n instanceof e&&(n.margin=t)})}constructor(e,t,n,r,i,a,o,s){if(super(),this.orientation=e,this.proportionalLayout=t,this.styles=n,this._childrenDisposable=Re.NONE,this.children=[],this._onDidChange=new Z,this.onDidChange=this._onDidChange.event,this._onDidVisibilityChange=new Z,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._orthogonalSize=i,this._size=r,this.element=document.createElement(`div`),this.element.className=`dv-branch-node`,s){let e={views:s.map(e=>({view:e.node,size:e.node.size,visible:e.visible??!0})),size:this.orthogonalSize};this.children=s.map(e=>e.node),this.splitview=new jt(this.element,{orientation:this.orientation,descriptor:e,proportionalLayout:t,styles:n,margin:o})}else this.splitview=new jt(this.element,{orientation:this.orientation,proportionalLayout:t,styles:n,margin:o}),this.splitview.layout(this.size,this.orthogonalSize);this.disabled=a,this.addDisposables(this._onDidChange,this._onDidVisibilityChange,this.splitview.onDidSashEnd(()=>{this._onDidChange.fire({})})),this.setupChildrenEvents()}setVisible(e){}isChildVisible(e){if(e<0||e>=this.children.length)throw Error(`Invalid index`);return this.splitview.isViewVisible(e)}setChildVisible(e,t){if(e<0||e>=this.children.length)throw Error(`Invalid index`);if(this.splitview.isViewVisible(e)===t)return;let n=this.splitview.contentSize===0;this.splitview.setViewVisible(e,t),this.invalidateCachedSizes();let r=this.splitview.contentSize===0;(t&&n||!t&&r)&&this._onDidVisibilityChange.fire({visible:t})}moveChild(e,t){if(e===t)return;if(e<0||e>=this.children.length)throw Error(`Invalid from index`);e<t&&t--,this.splitview.moveView(e,t);let n=this._removeChild(e);this._addChild(n,t)}getChildSize(e){if(e<0||e>=this.children.length)throw Error(`Invalid index`);return this.splitview.getViewSize(e)}resizeChild(e,t){if(e<0||e>=this.children.length)throw Error(`Invalid index`);this.splitview.resizeView(e,t)}layout(e,t){this._size=t,this._orthogonalSize=e,this.splitview.layout(t,e)}addChild(e,t,n,r){if(n<0||n>this.children.length)throw Error(`Invalid index`);this.splitview.addView(e,t,n,r),this._addChild(e,n)}getChildCachedVisibleSize(e){if(e<0||e>=this.children.length)throw Error(`Invalid index`);return this.splitview.getViewCachedVisibleSize(e)}removeChild(e,t){if(e<0||e>=this.children.length)throw Error(`Invalid index`);return this.splitview.removeView(e,t),this._removeChild(e)}_addChild(e,t){this.children.splice(t,0,e),this.setupChildrenEvents()}_removeChild(e){let[t]=this.children.splice(e,1);return this.setupChildrenEvents(),t}setupChildrenEvents(){this.invalidateCachedSizes(),this._childrenDisposable.dispose(),this._childrenDisposable=new ze(Ve.any(...this.children.map(e=>e.onDidChange))(e=>{this.invalidateCachedSizes(),this._onDidChange.fire({size:e.orthogonalSize})}),...this.children.map((t,n)=>t instanceof e?t.onDidVisibilityChange(({visible:e})=>{this.setChildVisible(n,e)}):Re.NONE))}dispose(){this._childrenDisposable.dispose(),this.splitview.dispose(),this.children.forEach(e=>e.dispose()),super.dispose()}};function Pt(e,t){if(e instanceof Mt)return e;if(e instanceof Nt)return Pt(e.children[t?e.children.length-1:0],t);throw Error(`invalid node`)}function Ft(e,t,n){if(e instanceof Nt){let r=new Nt(e.orientation,e.proportionalLayout,e.styles,t,n,e.disabled,e.margin);for(let t=e.children.length-1;t>=0;t--){let n=e.children[t];r.addChild(Ft(n,n.size,n.orthogonalSize),n.size,0,!0)}return r}return new Mt(e.view,e.orientation,n)}function It(e,t,n){if(e instanceof Nt){let r=new Nt(Ht(e.orientation),e.proportionalLayout,e.styles,t,n,e.disabled,e.margin),i=0;for(let a=e.children.length-1;a>=0;a--){let o=e.children[a],s=o instanceof Nt?o.orthogonalSize:o.size,c=e.size===0?0:Math.round(t*s/e.size);i+=c,a===0&&(c+=t-i),r.addChild(It(o,n,c),c,0,!0)}return r}return new Mt(e.view,Ht(e.orientation),n)}function Lt(e){let t=e.parentElement;if(!t)throw Error(`Invalid grid element`);let n=t.firstElementChild,r=0;for(;n!==e&&n!==t.lastElementChild&&n;)n=n.nextElementSibling,r++;return r}function Rt(e){let t=e.parentElement;if(!t)throw Error(`Invalid grid element`);if(/\bdv-grid-view\b/.test(t.className))return[];let n=Lt(t),r=t.parentElement.parentElement.parentElement;return[...Rt(r),n]}function zt(e,t,n){if(Vt(e,t)===Bt(n)){let[e,r]=vt(t),i=r;return(n===`right`||n===`bottom`)&&(i+=1),[...e,i]}{let e=+(n===`right`||n===`bottom`);return[...t,e]}}function Bt(e){return e===`top`||e===`bottom`?`VERTICAL`:`HORIZONTAL`}function Vt(e,t){return t.length%2==0?Ht(e):e}var Ht=e=>e===`HORIZONTAL`?`VERTICAL`:`HORIZONTAL`;function Ut(e){return!!e.children}var Wt=(e,t)=>{let n=t===`VERTICAL`?e.box.width:e.box.height;if(!Ut(e))return typeof e.cachedVisibleSize==`number`?{type:`leaf`,data:e.view.toJSON(),size:e.cachedVisibleSize,visible:!1}:{type:`leaf`,data:e.view.toJSON(),size:n};let r=e.children.map(e=>Wt(e,Ht(t)));return typeof e.cachedVisibleSize==`number`?{type:`branch`,data:r,size:e.cachedVisibleSize,visible:!1}:{type:`branch`,data:r,size:n}},Gt=class{get length(){return this._root?this._root.children.length:0}get orientation(){return this.root.orientation}set orientation(e){if(this.root.orientation===e)return;let{size:t,orthogonalSize:n}=this.root;this.root=It(this.root,n,t),this.root.layout(t,n)}get width(){return this.root.width}get height(){return this.root.height}get minimumWidth(){return this.root.minimumWidth}get minimumHeight(){return this.root.minimumHeight}get maximumWidth(){return this.root.maximumWidth}get maximumHeight(){return this.root.maximumHeight}get locked(){return this._locked}set locked(e){this._locked=e;let t=[this.root];for(;t.length>0;){let n=t.pop();n instanceof Nt&&(n.disabled=e,t.push(...n.children))}}get margin(){return this._margin}set margin(e){this._margin=e,this.root.margin=e}maximizedView(){return this._maximizedNode?.leaf.view}hasMaximizedView(){return this._maximizedNode!==void 0}maximizeView(e){let t=Rt(e.element),[n,r]=this.getNode(t);if(!(r instanceof Mt)||this._maximizedNode?.leaf===r)return;this.hasMaximizedView()&&this.exitMaximizedView(),Wt(this.getView(),this.orientation);let i=[];function a(e,t){for(let n=0;n<e.children.length;n++){let r=e.children[n];r instanceof Mt?r!==t&&(e.isChildVisible(n)?e.setChildVisible(n,!1):i.push(r)):a(r,t)}}a(this.root,r),this._maximizedNode={leaf:r,hiddenOnMaximize:i},this._onDidMaximizedNodeChange.fire({view:r.view,isMaximized:!0})}exitMaximizedView(){if(!this._maximizedNode)return;let e=this._maximizedNode.hiddenOnMaximize;function t(n){for(let r=n.children.length-1;r>=0;r--){let i=n.children[r];i instanceof Mt?e.includes(i)||n.setChildVisible(r,!0):t(i)}}t(this.root);let n=this._maximizedNode.leaf;this._maximizedNode=void 0,this._onDidMaximizedNodeChange.fire({view:n.view,isMaximized:!1})}serialize(){let e=this.maximizedView(),t;e&&(t=Rt(e.element));let n=this._onDidMaximizedNodeChange.pause();try{this.hasMaximizedView()&&this.exitMaximizedView();let n={root:Wt(this.getView(),this.orientation),width:this.width,height:this.height,orientation:this.orientation};return t&&(n.maximizedNode={location:t}),e&&this.maximizeView(e),n}finally{n.dispose()}}dispose(){this.disposable.dispose(),this._onDidChange.dispose(),this._onDidMaximizedNodeChange.dispose(),this._onDidViewVisibilityChange.dispose(),this.root.dispose(),this._maximizedNode=void 0,this.element.remove()}clear(){let e=this.root.orientation;this.root=new Nt(e,this.proportionalLayout,this.styles,this.root.size,this.root.orthogonalSize,this.locked,this.margin)}deserialize(e,t){let n=e.orientation,r=n===`VERTICAL`?e.height:e.width;if(this._deserialize(e.root,n,t,r),this.layout(e.width,e.height),e.maximizedNode){let t=e.maximizedNode.location,[n,r]=this.getNode(t);if(!(r instanceof Mt))return;this.maximizeView(r.view)}}_deserialize(e,t,n,r){this.root=this._deserializeNode(e,t,n,r)}_deserializeNode(e,t,n,r){let i;if(e.type===`branch`){let a=e.data.map(r=>({node:this._deserializeNode(r,Ht(t),n,e.size),visible:r.visible}));i=new Nt(t,this.proportionalLayout,this.styles,e.size,r,this.locked,this.margin,a)}else{let o=n.fromJSON(e);if(typeof e.visible==`boolean`){var a;(a=o.setVisible)==null||a.call(o,e.visible)}i=new Mt(o,t,r,e.size)}return i}get root(){return this._root}set root(e){let t=this._root;t&&(t.dispose(),this._maximizedNode=void 0,t.element.remove()),this._root=e,this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(e=>{this._onDidChange.fire(e)})}normalize(){if(!this._root||this._root.children.length!==1)return;let e=this.root,t=e.children[0];if(t instanceof Mt)return;e.element.remove();let n=e.removeChild(0);e.dispose(),n.dispose(),this._root=Ft(t,t.size,t.orthogonalSize),this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(e=>{this._onDidChange.fire(e)})}insertOrthogonalSplitviewAtRoot(){if(!this._root)return;let e=this.root;if(e.element.remove(),this._root=new Nt(Ht(e.orientation),this.proportionalLayout,this.styles,this.root.orthogonalSize,this.root.size,this.locked,this.margin),e.children.length!==0){if(e.children.length===1){let t=e.children[0];e.removeChild(0).dispose(),e.dispose(),this._root.addChild(It(t,t.orthogonalSize,t.size),At.Distribute,0)}else this._root.addChild(e,At.Distribute,0)}this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(e=>{this._onDidChange.fire(e)})}next(e){return this.progmaticSelect(e)}previous(e){return this.progmaticSelect(e,!0)}getView(e){let t=e?this.getNode(e)[1]:this.root;return this._getViews(t,this.orientation)}_getViews(e,t,n){let r={height:e.height,width:e.width};if(e instanceof Mt)return{box:r,view:e.view,cachedVisibleSize:n};let i=[];for(let n=0;n<e.children.length;n++){let r=e.children[n],a=e.getChildCachedVisibleSize(n);i.push(this._getViews(r,Ht(t),a))}return{box:r,children:i,cachedVisibleSize:n}}progmaticSelect(e,t=!1){let[n,r]=this.getNode(e);if(!(r instanceof Mt))throw TypeError(`invalid location`);for(let r=n.length-1;r>-1;r--){let i=n[r],a=e[r]||0;if(t?a-1>-1:a+1<i.children.length)return Pt(i.children[t?a-1:a+1],t)}return Pt(this.root,t)}constructor(e,t,n,r,i){this.proportionalLayout=e,this.styles=t,this._locked=!1,this._margin=0,this._maximizedNode=void 0,this.disposable=new Be,this._onDidChange=new Z,this.onDidChange=this._onDidChange.event,this._onDidViewVisibilityChange=new Z,this.onDidViewVisibilityChange=this._onDidViewVisibilityChange.event,this._onDidMaximizedNodeChange=new Z,this.onDidMaximizedNodeChange=this._onDidMaximizedNodeChange.event,this.element=document.createElement(`div`),this.element.className=`dv-grid-view`,this._locked=r??!1,this._margin=i??0,this.root=new Nt(n,e,t,0,0,this.locked,this.margin)}isViewVisible(e){let[t,n]=vt(e),[,r]=this.getNode(t);if(!(r instanceof Nt))throw TypeError(`Invalid from location`);return r.isChildVisible(n)}setViewVisible(e,t){this.hasMaximizedView()&&this.exitMaximizedView();let[n,r]=vt(e),[,i]=this.getNode(n);if(!(i instanceof Nt))throw TypeError(`Invalid from location`);this._onDidViewVisibilityChange.fire(),i.setChildVisible(r,t)}moveView(e,t,n){this.hasMaximizedView()&&this.exitMaximizedView();let[,r]=this.getNode(e);if(!(r instanceof Nt))throw TypeError(`Invalid location`);r.moveChild(t,n)}addView(e,t,n){this.hasMaximizedView()&&this.exitMaximizedView();let[r,i]=vt(n),[a,o]=this.getNode(r);if(o instanceof Nt){let n=new Mt(e,Ht(o.orientation),o.orthogonalSize);o.addChild(n,t,i)}else{let[n,...s]=[...a].reverse(),[c,...l]=[...r].reverse(),u=0,d=n.getChildCachedVisibleSize(c);typeof d==`number`&&(u=At.Invisible(d)),n.removeChild(c).dispose();let f=new Nt(o.orientation,this.proportionalLayout,this.styles,o.size,o.orthogonalSize,this.locked,this.margin);n.addChild(f,o.size,c);let p=new Mt(o.view,n.orientation,o.size);f.addChild(p,u,0),typeof t!=`number`&&t.type===`split`&&(t={type:`split`,index:0});let m=new Mt(e,n.orientation,o.size);f.addChild(m,t,i)}}remove(e,t){let n=Rt(e.element);return this.removeView(n,t)}removeView(e,t){this.hasMaximizedView()&&this.exitMaximizedView();let[n,r]=vt(e),[i,a]=this.getNode(n);if(!(a instanceof Nt))throw TypeError(`Invalid location`);let o=a.children[r];if(!(o instanceof Mt))throw TypeError(`Invalid location`);if(a.removeChild(r,t),o.dispose(),a.children.length!==1)return o.view;let s=a.children[0];if(i.length===0)return s instanceof Mt?o.view:(a.removeChild(0,t),this.root=s,o.view);let[c,...l]=[...i].reverse(),[u,...d]=[...n].reverse(),f=a.isChildVisible(0);a.removeChild(0,t);let p=c.children.map((e,t)=>c.getChildSize(t));if(c.removeChild(u,t).dispose(),s instanceof Nt){p.splice(u,1,...s.children.map(e=>e.size));for(let e=0;e<s.children.length;e++){let t=s.children[e];c.addChild(t,t.size,u+e)}for(;s.children.length>0;)s.removeChild(0)}else{let e=new Mt(s.view,Ht(s.orientation),s.size),t=f?s.orthogonalSize:At.Invisible(s.orthogonalSize);c.addChild(e,t,u)}s.dispose();for(let e=0;e<p.length;e++)c.resizeChild(e,p[e]);return o.view}layout(e,t){let[n,r]=this.root.orientation===`HORIZONTAL`?[t,e]:[e,t];this.root.layout(n,r)}getNode(e,t=this.root,n=[]){if(e.length===0)return[n,t];if(!(t instanceof Nt))throw TypeError(`Invalid location`);let[r,...i]=e;if(r<0||r>=t.children.length)throw Error(`Invalid location`);let a=t.children[r];return n.push(t),this.getNode(i,a,n)}},Kt=class extends ze{get element(){return this._element}get disableResizing(){return this._disableResizing}set disableResizing(e){this._disableResizing=e}constructor(e,t=!1){super(),this._lastWidth=-1,this._lastHeight=-1,this._disableResizing=t,this._element=e,this.addDisposables(Ye(this._element,e=>{if(this.isDisposed||this.disableResizing||!this._element.offsetParent||!ot(this._element))return;let t=Math.round(e.contentRect.width),n=Math.round(e.contentRect.height);(t!==this._lastWidth||n!==this._lastHeight)&&(this._lastWidth=t,this._lastHeight=n,this.layout(t,n))}))}},qt=Tt();function Jt(e){switch(e){case`left`:return`left`;case`right`:return`right`;case`above`:return`top`;case`below`:return`bottom`;default:return`center`}}var Yt=class extends Kt{get id(){return this._id}get size(){return this._groups.size}get groups(){return Array.from(this._groups.values()).map(e=>e.value)}get width(){return this.gridview.width}get height(){return this.gridview.height}get minimumHeight(){return this.gridview.minimumHeight}get maximumHeight(){return this.gridview.maximumHeight}get minimumWidth(){return this.gridview.minimumWidth}get maximumWidth(){return this.gridview.maximumWidth}get activeGroup(){return this._activeGroup}get locked(){return this.gridview.locked}set locked(e){this.gridview.locked=e}constructor(e,t){super(document.createElement(`div`),t.disableAutoResizing),this._id=qt.next(),this._groups=new Map,this._onDidRemove=new Z,this.onDidRemove=this._onDidRemove.event,this._onDidAdd=new Z,this.onDidAdd=this._onDidAdd.event,this._onDidMaximizedChange=new Z,this.onDidMaximizedChange=this._onDidMaximizedChange.event,this._onDidActiveChange=new Z,this.onDidActiveChange=this._onDidActiveChange.event,this._bufferOnDidLayoutChange=new qe,this.onDidLayoutChange=this._bufferOnDidLayoutChange.onEvent,this._onDidViewVisibilityChangeMicroTaskQueue=new qe,this.onDidViewVisibilityChangeMicroTaskQueue=this._onDidViewVisibilityChangeMicroTaskQueue.onEvent,this.element.style.height=`100%`,this.element.style.width=`100%`,this._classNames=new dt(this.element),this._classNames.setClassNames(t.className??``),e.appendChild(this.element),this.gridview=new Gt(!!t.proportionalLayout,t.styles,t.orientation,t.locked,t.margin),this.gridview.locked=!!t.locked,this.element.appendChild(this.gridview.element),this.layout(0,0,!0),this.addDisposables(this.gridview.onDidMaximizedNodeChange(e=>{this._onDidMaximizedChange.fire({panel:e.view,isMaximized:e.isMaximized})}),this.gridview.onDidViewVisibilityChange(()=>this._onDidViewVisibilityChangeMicroTaskQueue.fire()),this.onDidViewVisibilityChangeMicroTaskQueue(()=>{this.forceRelayout()}),Re.from(()=>{this.element.remove()}),this.gridview.onDidChange(()=>{this._bufferOnDidLayoutChange.fire()}),Ve.any(this.onDidAdd,this.onDidRemove,this.onDidActiveChange)(()=>{this._bufferOnDidLayoutChange.fire()}),this._onDidMaximizedChange,this._onDidViewVisibilityChangeMicroTaskQueue,this._bufferOnDidLayoutChange)}setVisible(e,t){this.gridview.setViewVisible(Rt(e.element),t),this._bufferOnDidLayoutChange.fire()}isVisible(e){return this.gridview.isViewVisible(Rt(e.element))}updateOptions(e){e.proportionalLayout,e.orientation&&(this.gridview.orientation=e.orientation),`styles`in e,`disableAutoResizing`in e&&(this.disableResizing=e.disableAutoResizing??!1),`locked`in e&&(this.locked=e.locked??!1),`margin`in e&&(this.gridview.margin=e.margin??0),`className`in e&&this._classNames.setClassNames(e.className??``)}maximizeGroup(e){this.gridview.maximizeView(e),this.doSetGroupActive(e)}isMaximizedGroup(e){return this.gridview.maximizedView()===e}exitMaximizedGroup(){this.gridview.exitMaximizedView()}hasMaximizedGroup(){return this.gridview.hasMaximizedView()}doAddGroup(e,t=[0],n,r=this.gridview){r.addView(e,n??At.Distribute,t),this._onDidAdd.fire(e)}doRemoveGroup(e,t){if(!this._groups.has(e.id))throw Error(`invalid operation`);let n=this._groups.get(e.id),r=this.gridview.remove(e,At.Distribute);if(n&&!t?.skipDispose&&(n.disposable.dispose(),n.value.dispose(),this._groups.delete(e.id),this._onDidRemove.fire(e)),!t?.skipActive&&this._activeGroup===e){let e=Array.from(this._groups.values());this.doSetGroupActive(e.length>0?e[0].value:void 0)}return r}getPanel(e){return this._groups.get(e)?.value}doSetGroupActive(e){this._activeGroup!==e&&(this._activeGroup&&this._activeGroup.setActive(!1),e&&e.setActive(!0),this._activeGroup=e,this._onDidActiveChange.fire(e))}removeGroup(e){this.doRemoveGroup(e)}activateNext(e){if(e??={},!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}let t=Rt(e.group.element),n=this.gridview.next(t)?.view;this.doSetGroupActive(n)}activatePrevious(e){if(e??={},!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}let t=Rt(e.group.element),n=this.gridview.previous(t)?.view;this.doSetGroupActive(n)}forceRelayout(){this.layout(this.width,this.height,!0)}layout(e,t,n){(n||e!==this.width||t!==this.height)&&(this.gridview.element.style.height=`${t}px`,this.gridview.element.style.width=`${e}px`,this.gridview.layout(e,t))}dispose(){this._onDidActiveChange.dispose(),this._onDidAdd.dispose(),this._onDidRemove.dispose();for(let e of this.groups)e.dispose();this.gridview.dispose(),super.dispose()}};function Xt(e){"@babel/helpers - typeof";return Xt=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Xt(e)}function Zt(e,t){if(Xt(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Xt(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Qt(e){var t=Zt(e,`string`);return Xt(t)==`symbol`?t:t+``}function $t(e,t,n){return(t=Qt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function en(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function tn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?en(Object(n),!0).forEach(function(t){$t(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):en(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function nn(e,t){return e===`center`?`Tab into ${t}`:`Split ${e} of ${t}`}function rn(e,t){return e===`center`?`docked into ${t}`:`split ${e} of ${t}`}var an={panelOpened:e=>`${e} opened`,panelClosed:e=>`${e} closed`,groupMaximized:e=>`${e} maximized`,groupRestored:e=>`${e} restored`,groupFloated:e=>`${e} floated`,groupDocked:e=>`${e} docked`,groupPoppedOut:e=>`${e} opened in a new window`,closeTab:e=>`Close ${e}`,closeTabPlain:()=>`Close`,movePickTarget:(e,t,n,r)=>`Moving ${e}. Target ${t}, ${n} of ${r}. Enter to choose where, Escape to cancel.`,movePickEdge:(e,t)=>`${nn(e,t)}. Arrows to change, Enter to confirm, Escape to go back.`,moveCommitted:(e,t,n)=>`${e} ${rn(n,t)}.`,moveCancelled:()=>`Move cancelled.`,moveNotAllowed:()=>`That move is not allowed.`,moveFloated:e=>`${e} floated.`};function on(e){return e?tn(tn({},an),e):an}var sn=class{get id(){return this.component.id}get width(){return this.component.width}get height(){return this.component.height}get minimumHeight(){return this.component.minimumHeight}get maximumHeight(){return this.component.maximumHeight}get minimumWidth(){return this.component.minimumWidth}get maximumWidth(){return this.component.maximumWidth}get size(){return this.component.size}get tabGroupColors(){return this.component.tabGroupColorPalette.entries()}get totalPanels(){return this.component.totalPanels}get onDidActiveGroupChange(){return this.component.onDidActiveGroupChange}get onDidAddGroup(){return this.component.onDidAddGroup}get onDidRemoveGroup(){return this.component.onDidRemoveGroup}get onDidActivePanelChange(){return this.component.onDidActivePanelChange}get onDidPanelPinnedChange(){return this.component.onDidPanelPinnedChange}get onDidAddPanel(){return this.component.onDidAddPanel}get onDidRemovePanel(){return this.component.onDidRemovePanel}get onDidMovePanel(){return this.component.onDidMovePanel}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidDrop(){return this.component.onDidDrop}get onWillDrop(){return this.component.onWillDrop}get onWillMutateLayout(){return this.component.onWillMutateLayout}get onDidMutateLayout(){return this.component.onDidMutateLayout}get onWillShowOverlay(){return this.component.onWillShowOverlay}get onWillDragGroup(){return this.component.onWillDragGroup}get onWillDragPanel(){return this.component.onWillDragPanel}get onUnhandledDragOver(){return this.component.onUnhandledDragOver}get onDidPopoutGroupSizeChange(){return this.component.onDidPopoutGroupSizeChange}get onDidPopoutGroupPositionChange(){return this.component.onDidPopoutGroupPositionChange}get onDidAddPopoutGroup(){return this.component.onDidAddPopoutGroup}get onDidRemovePopoutGroup(){return this.component.onDidRemovePopoutGroup}get onDidOpenPopoutWindowFail(){return this.component.onDidOpenPopoutWindowFail}getPopouts(){return this.component.getPopouts()}get onDidCreateTabGroup(){return this.component.onDidCreateTabGroup}get onDidDestroyTabGroup(){return this.component.onDidDestroyTabGroup}get onDidAddPanelToTabGroup(){return this.component.onDidAddPanelToTabGroup}get onDidRemovePanelFromTabGroup(){return this.component.onDidRemovePanelFromTabGroup}get onDidTabGroupChange(){return this.component.onDidTabGroupChange}get onDidTabGroupCollapsedChange(){return this.component.onDidTabGroupCollapsedChange}get panels(){return this.component.panels}get groups(){return this.component.groups}adjacentGroupInDirection(e,t){return this.component.adjacentGroupInDirection(e,t)}get activePanel(){return this.component.activePanel}get activeGroup(){return this.component.activeGroup}get messages(){return on(this.component.options.messages)}constructor(e){this.component=e}focus(){this.component.focus()}getPanel(e){return this.component.getGroupPanel(e)}layout(e,t,n=!1){this.component.layout(e,t,n)}addPanel(e){return this.component.withOrigin(`api`,()=>this.component.addPanel(e))}removePanel(e){this.component.withOrigin(`api`,()=>this.component.removePanel(e))}addGroup(e){return this.component.withOrigin(`api`,()=>this.component.addGroup(e))}closeAllGroups(){return this.component.withOrigin(`api`,()=>this.component.closeAllGroups())}removeGroup(e){this.component.withOrigin(`api`,()=>this.component.removeGroup(e))}getGroup(e){return this.component.getPanel(e)}addFloatingGroup(e,t){return this.component.withOrigin(`api`,()=>this.component.addFloatingGroup(e,t))}fromJSON(e,t){this.component.withOrigin(`api`,()=>this.component.fromJSON(e,t))}toJSON(){return this.component.toJSON()}clear(){this.component.withOrigin(`api`,()=>this.component.clear())}undo(){this.component.undo()}redo(){this.component.redo()}get canUndo(){return this.component.canUndo}get canRedo(){return this.component.canRedo}clearHistory(){this.component.clearHistory()}get onDidChangeHistory(){return this.component.onDidChangeHistory}get smartGuidesEnabled(){return this.component.smartGuidesEnabled}setSmartGuidesEnabled(e){this.component.setSmartGuidesEnabled(e)}updateSmartGuidesOptions(e){this.component.updateSmartGuidesOptions(e)}get onDidSnapFloat(){return this.component.onDidSnapFloat}get onDidSnapTogether(){return this.component.onDidSnapTogether}get popoutRestorationPromise(){return this.component.popoutRestorationPromise}activateNext(e){this.component.activateNext(e)}activatePrevious(e){this.component.activatePrevious(e)}moveToNext(e){this.activateNext(e)}moveToPrevious(e){this.activatePrevious(e)}maximizeGroup(e){this.component.withOrigin(`api`,()=>this.component.maximizeGroup(e.group))}hasMaximizedGroup(){return this.component.hasMaximizedGroup()}exitMaximizedGroup(){this.component.withOrigin(`api`,()=>this.component.exitMaximizedGroup())}get onDidMaximizedGroupChange(){return this.component.onDidMaximizedGroupChange}addPopoutGroup(e,t){return this.component.withOrigin(`api`,()=>this.component.addPopoutGroup(e,t))}addEdgeGroup(e,t){return this.component.addEdgeGroup(e,t)}revealEdgeGroupWithData(e,t,n){this.component.revealEdgeGroupWithData(e,t,n)}getEdgeGroup(e){return this.component.getEdgeGroup(e)}setEdgeGroupVisible(e,t){this.component.setEdgeGroupVisible(e,t)}isEdgeGroupVisible(e){return this.component.isEdgeGroupVisible(e)}removeEdgeGroup(e){this.component.removeEdgeGroup(e)}pinEdgeGroup(e){this.component.pinEdgeGroup(e)}autoHideEdgeGroup(e){this.component.autoHideEdgeGroup(e)}peekEdgeGroup(e,t){this.component.peekEdgeGroup(e,t)}updateOptions(e){this.component.updateOptions(e)}_getGroupModel(e){let t=this.component.getPanel(e);if(!t)throw Error(`dockview: group '${e}' not found`);return t.model}createTabGroup(e){let t=this._getGroupModel(e.groupId);return this.component.withOrigin(`api`,()=>t.createTabGroup({label:e.label,color:e.color,componentParams:e.componentParams}))}dissolveTabGroup(e){let t=this._getGroupModel(e.groupId);this.component.withOrigin(`api`,()=>t.dissolveTabGroup(e.tabGroupId))}addPanelToTabGroup(e){let t=this._getGroupModel(e.groupId);this.component.withOrigin(`api`,()=>t.addPanelToTabGroup(e.tabGroupId,e.panelId,e.index))}removePanelFromTabGroup(e){let t=this._getGroupModel(e.groupId);this.component.withOrigin(`api`,()=>t.removePanelFromTabGroup(e.panelId))}getTabGroups(e){return this._getGroupModel(e.groupId).getTabGroups()}getTabGroupForPanel(e){return this._getGroupModel(e.groupId).getTabGroupForPanel(e.panelId)}moveTabGroup(e){this._getGroupModel(e.groupId).moveTabGroup(e.tabGroupId,e.index)}dispose(){this.component.dispose()}},cn=class extends ze{constructor(e,t){super(),this.element=e,this.callbacks=t,this.target=null,this.registerListeners()}onDragEnter(e){this.target=e.target,this.callbacks.onDragEnter(e)}onDragOver(e){e.preventDefault(),this.callbacks.onDragOver&&this.callbacks.onDragOver(e)}onDragLeave(e){this.target===e.target&&(this.target=null,this.callbacks.onDragLeave(e))}onDragEnd(e){this.target=null,this.callbacks.onDragEnd(e)}onDrop(e){this.callbacks.onDrop(e)}registerListeners(){this.addDisposables(Q(this.element,`dragenter`,e=>{this.onDragEnter(e)},!0)),this.addDisposables(Q(this.element,`dragover`,e=>{this.onDragOver(e)},!0)),this.addDisposables(Q(this.element,`dragleave`,e=>{this.onDragLeave(e)})),this.addDisposables(Q(this.element,`dragend`,e=>{this.onDragEnd(e)})),this.addDisposables(Q(this.element,`drop`,e=>{this.onDrop(e)}))}},ln={value:50,type:`percentage`},un=100,dn=100;function fn(){let e=document.createElement(`div`);e.className=`dv-drop-target-dropzone`;let t=document.createElement(`div`);return t.className=`dv-drop-target-selection`,e.appendChild(t),{dropzone:e,selection:t}}function pn(e,t,n,r){let i=r?.smallWidthBoundary??un,a=r?.smallHeightBoundary??dn,o=t<i,s=n<a,c=e===`left`,l=e===`right`,u=e===`top`,d=e===`bottom`,f=!o&&l,p=!o&&c,m=!s&&u,h=!s&&d,g=1,_=r?.size??ln;return _.type===`percentage`?g=wt(_.value,0,100)/100:((f||p)&&(g=wt(0,_.value,t)/t),(m||h)&&(g=wt(0,_.value,n)/n)),{isSmallX:o,isSmallY:s,isLeft:c,isRight:l,isTop:u,isBottom:d,rightClass:f,leftClass:p,topClass:m,bottomClass:h,size:g}}function mn(e,t,n,r,i){let a=pn(t,n,r,i),{rightClass:o,leftClass:s,topClass:c,bottomClass:l,size:u}=a,d={top:`0px`,left:`0px`,width:`100%`,height:`100%`};o?(d.left=`${100*(1-u)}%`,d.width=`${100*u}%`):s?d.width=`${100*u}%`:c?d.height=`${100*u}%`:l&&(d.top=`${100*(1-u)}%`,d.height=`${100*u}%`),a.isSmallX&&a.isLeft&&(d.width=`4px`),a.isSmallX&&a.isRight&&(d.left=`${n-4}px`,d.width=`4px`),a.isSmallY&&a.isTop&&(d.height=`4px`),a.isSmallY&&a.isBottom&&(d.top=`${r-4}px`,d.height=`4px`),e.style.top=d.top,e.style.left=d.left,e.style.width=d.width,e.style.height=d.height,e.style.visibility=`visible`,(!e.style.transform||e.style.transform===``)&&(e.style.transform=`translate3d(0, 0, 0)`);let f=a.isSmallX&&(a.isLeft||a.isRight)||a.isSmallY&&(a.isTop||a.isBottom);$(e,`dv-drop-target-small-vertical`,a.isSmallY),$(e,`dv-drop-target-small-horizontal`,a.isSmallX),$(e,`dv-drop-target-selection-line`,f),$(e,`dv-drop-target-left`,a.isLeft),$(e,`dv-drop-target-right`,a.isRight),$(e,`dv-drop-target-top`,a.isTop),$(e,`dv-drop-target-bottom`,a.isBottom),$(e,`dv-drop-target-center`,t===`center`)}function hn(e,t){let n=`${Math.round(t.top)}px`,r=`${Math.round(t.left)}px`,i=`${Math.round(t.width)}px`,a=`${Math.round(t.height)}px`;return e.style.top!==n||e.style.left!==r||e.style.width!==i||e.style.height!==a}function gn(e,t){e.style.top=`${Math.round(t.top)}px`,e.style.left=`${Math.round(t.left)}px`,e.style.width=`${Math.round(t.width)}px`,e.style.height=`${Math.round(t.height)}px`,e.style.visibility=`visible`,(!e.style.transform||e.style.transform===``)&&(e.style.transform=`translate3d(0, 0, 0)`)}function _n(e){let t=pn(e.quadrant,e.width,e.height,e.overlayModel),{rightClass:n,leftClass:r,topClass:i,bottomClass:a,size:o}=t,s=e.outlineElement.getBoundingClientRect(),c=e.targetModel.getElements(void 0,e.outlineElement),l=c.root,u=c.overlay,d=l.getBoundingClientRect(),f=s.top-d.top,p=s.left-d.left,m={top:f,left:p,width:e.width,height:e.height};return n?(m.left=p+e.width*(1-o),m.width=e.width*o):r?m.width=e.width*o:i?m.height=e.height*o:a&&(m.top=f+e.height*(1-o),m.height=e.height*o),t.isSmallX&&t.isLeft&&(m.width=4),t.isSmallX&&t.isRight&&(m.left=p+e.width-4,m.width=4),t.isSmallY&&t.isTop&&(m.height=4),t.isSmallY&&t.isBottom&&(m.top=f+e.height-4,m.height=4),hn(u,m)?(gn(u,m),u.className=`dv-drop-target-anchor${e.className?` ${e.className}`:``}`,$(u,`dv-drop-target-left`,t.isLeft),$(u,`dv-drop-target-right`,t.isRight),$(u,`dv-drop-target-top`,t.isTop),$(u,`dv-drop-target-bottom`,t.isBottom),$(u,`dv-drop-target-anchor-line`,t.isSmallX&&(t.isLeft||t.isRight)||t.isSmallY&&(t.isTop||t.isBottom)),$(u,`dv-drop-target-center`,e.quadrant===`center`),c.changed&&($(u,`dv-drop-target-anchor-container-changed`,!0),setTimeout(()=>{$(u,`dv-drop-target-anchor-container-changed`,!1)},10)),{boundsChanged:!0,targetChanged:c.changed}):{boundsChanged:!1,targetChanged:c.changed}}var vn=class extends He{get nativeEvent(){return this.options.nativeEvent}get position(){return this.options.position}get edge(){return!!this.options.edge}get edgeGroup(){return!!this.options.edgeGroup}constructor(e){super(),this.options=e}};function yn(e){switch(e){case`above`:return`top`;case`below`:return`bottom`;case`left`:return`left`;case`right`:return`right`;case`within`:return`center`;default:throw Error(`invalid direction '${e}'`)}}function bn(e){switch(e){case`top`:return`above`;case`bottom`:return`below`;case`left`:return`left`;case`right`:return`right`;case`center`:return`within`;default:throw Error(`invalid position '${e}'`)}}var xn={value:20,type:`percentage`},Sn=class e extends ze{get disabled(){return this._disabled}set disabled(e){this._disabled=e}get state(){return this._state}constructor(t,n){super(),this.element=t,this.options=n,this._edge=!1,this._onDrop=new Z,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new Z,this.onWillShowOverlay=this._onWillShowOverlay.event,this._disabled=!1,this._acceptedTargetZonesSet=new Set(this.options.acceptedTargetZones),this.dnd=new cn(this.element,{onDragEnter:()=>{var e,t;(e=(t=this.options).getOverrideTarget)==null||(e=e.call(t))==null||e.getElements()},onDragOver:t=>{var n,r;if(this._disabled){this.clearOwnOverlay();return}e.ACTUAL_TARGET=this;let i=(n=this.options).getOverrideTarget?.call(n);if(this._acceptedTargetZonesSet.size===0){this.clearOwnOverlay();return}let a=(r=this.options).getOverlayOutline?.call(r)??this.element,o=a.offsetWidth,s=a.offsetHeight;if(o===0||s===0)return;let c=a.getBoundingClientRect(),l=(t.clientX??0)-c.left,u=(t.clientY??0)-c.top,d=this.resolvePosition(l,u,o,s,t);if(this.isAlreadyUsed(t)){this.removeDropTarget();return}if(d===null){this.clearOwnOverlay();return}let f=d.position;if(!this.options.canDisplayOverlay(t,f)){this.clearOwnOverlay();return}let p=new vn({nativeEvent:t,position:f,edge:d.edge,edgeGroup:d.edgeGroup});if(this._onWillShowOverlay.fire(p),p.defaultPrevented){this.clearOwnOverlay();return}if(this.markAsUsed(t),d.edge){this.clearOwnOverlay(),this._state=f,this._edge=!0;return}if(this._edge=!1,!i&&!this.targetElement){let e=fn();this.targetElement=e.dropzone,this.overlayElement=e.selection,this._state=`center`,a.classList.add(`dv-drop-target`),a.append(this.targetElement)}this.toggleClasses(f,o,s),this._state=f},onDragLeave:()=>{var e;let t=(e=this.options).getOverrideTarget?.call(e);if(t){var n;this._state=void 0,this._edge=!1,(n=t.scheduleClear)==null||n.call(t);return}this.removeDropTarget()},onDragEnd:t=>{var n;let r=(n=this.options).getOverrideTarget?.call(n);r&&e.ACTUAL_TARGET===this&&this._state&&(t.stopPropagation(),this._onDrop.fire({position:this._state,nativeEvent:t,edge:this._edge})),this.removeDropTarget(),r?.clear()},onDrop:e=>{var t,n;e.preventDefault();let r=this._state,i=this._edge;this.removeDropTarget(),(t=(n=this.options).getOverrideTarget)==null||(t=t.call(n))==null||t.clear(),r&&(e.stopPropagation(),this._onDrop.fire({position:r,nativeEvent:e,edge:i}))}}),this.addDisposables(this._onDrop,this._onWillShowOverlay,this.dnd)}setTargetZones(e){this._acceptedTargetZonesSet=new Set(e)}setOverlayModel(e){this.options.overlayModel=e}dispose(){this.removeDropTarget(),super.dispose()}markAsUsed(t){t[e.USED_EVENT_ID]=!0}isAlreadyUsed(t){let n=t[e.USED_EVENT_ID];return typeof n==`boolean`&&n}toggleClasses(e,t,n){var r;let i=(r=this.options).getOverrideTarget?.call(r);if(i){var a;_n({outlineElement:(a=this.options).getOverlayOutline?.call(a)??this.element,targetModel:i,quadrant:e,width:t,height:n,overlayModel:this.options.overlayModel,className:this.options.className});return}this.overlayElement&&mn(this.overlayElement,e,t,n,this.options.overlayModel)}resolvePosition(e,t,n,r,i){var a;let o=(a=this.options).getPositionResolver?.call(a);if(o){let a=o.resolve({x:e,y:t,width:n,height:r,zones:this._acceptedTargetZonesSet,event:i});return a?{position:a.position,edge:!!a.edge,edgeGroup:!!a.edgeGroup}:null}let s=this.calculateQuadrant(this._acceptedTargetZonesSet,e,t,n,r);return s?{position:s,edge:!1,edgeGroup:!1}:null}calculateQuadrant(e,t,n,r,i){let a=this.options.overlayModel?.activationSize??xn;return a.type===`percentage`?Cn(e,t,n,r,i,a.value):wn(e,t,n,r,i,a.value)}clearOwnOverlay(){let e=this._state!==void 0;if(this.removeDropTarget(),e){var t,n;(t=(n=this.options).getOverrideTarget)==null||(t=t.call(n))==null||t.clear()}}removeDropTarget(){if(this._state=void 0,this._edge=!1,this.targetElement){var e;(e=this.targetElement.parentElement)==null||e.classList.remove(`dv-drop-target`),this.targetElement.remove(),this.targetElement=void 0,this.overlayElement=void 0}}showOverlay(e){var t,n;let r=(t=this.options).getOverrideTarget?.call(t),i=(n=this.options).getOverlayOutline?.call(n)??this.element,a=i.offsetWidth,o=i.offsetHeight;if(!r&&!this.targetElement){let e=fn();this.targetElement=e.dropzone,this.overlayElement=e.selection,i.classList.add(`dv-drop-target`),i.append(this.targetElement)}this.toggleClasses(e,a,o),this._state=e}clearOverlay(){var e,t;this.removeDropTarget(),(e=(t=this.options).getOverrideTarget)==null||(e=e.call(t))==null||e.clear(),this._state=void 0}};Sn.USED_EVENT_ID=`__dockview_droptarget_event_is_used__`;function Cn(e,t,n,r,i,a){let o=100*t/r,s=100*n/i;return e.has(`left`)&&o<a?`left`:e.has(`right`)&&o>100-a?`right`:e.has(`top`)&&s<a?`top`:e.has(`bottom`)&&s>100-a?`bottom`:e.has(`center`)?`center`:null}function wn(e,t,n,r,i,a){return e.has(`left`)&&t<a?`left`:e.has(`right`)&&t>r-a?`right`:e.has(`top`)&&n<a?`top`:e.has(`bottom`)&&n>i-a?`bottom`:e.has(`center`)?`center`:null}function Tn(e,t,n){Ze(t,`dv-dragged`),t.style.top=`-9999px`,(n?.ownerDocument??document).body.appendChild(t),e.setDragImage(t,n?.x??0,n?.y??0),setTimeout(()=>{Xe(t,`dv-dragged`),t.remove()},0)}var En=class e extends ze{static getInstance(){return e._instance??=new e,e._instance}constructor(){super(),this._targets=new Set,this._targetByElement=new Map,this._onDragStart=new Z,this.onDragStart=this._onDragStart.event,this._onDragMove=new Z,this.onDragMove=this._onDragMove.event,this._onDragEnd=new Z,this.onDragEnd=this._onDragEnd.event,this.addDisposables(this._onDragStart,this._onDragMove,this._onDragEnd)}get active(){return this._active}registerTarget(e){return this._targets.add(e),this._targetByElement.set(e.element,e),{dispose:()=>{this._targets.delete(e),this._targetByElement.get(e.element)===e&&this._targetByElement.delete(e.element),this._currentTarget===e&&(this._currentTarget=void 0)}}}beginDrag(e){this._active&&this.cancel();let{pointerEvent:t,source:n}=e,r=e.getData();this._active={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,source:n},this._lastPointerEvent=t,this._onDragMoveCallback=e.onDragMove,this._onDragEndCallback=e.onDragEnd,this._dataDisposable=r,this._ghost=e.ghost,this._iframeShield=lt(n.ownerDocument??document);let i={clientX:t.clientX,clientY:t.clientY,pointerEvent:t};this._onDragStart.fire(i);let a=n.ownerDocument?.defaultView??globalThis.window;this._moveListener=Q(a,`pointermove`,e=>{e.pointerId===this._active?.pointerId&&this._handleMove(e)}),this._upListener=Q(a,`pointerup`,e=>{e.pointerId===this._active?.pointerId&&this._handleEnd(e,!0)}),this._cancelListener=Q(a,`pointercancel`,e=>{e.pointerId===this._active?.pointerId&&this._handleEnd(e,!1)})}cancel(){var e,t;if(!this._active)return;let n=this._onDragEndCallback,r=this._lastPointerEvent;if((e=this._currentTarget)==null||e.handleDragLeave(),this._teardown(),(t=this._dataDisposable)==null||t.dispose(),this._dataDisposable=void 0,r){let e={clientX:r.clientX,clientY:r.clientY,pointerEvent:r};n?.(e,!1),this._onDragEnd.fire(e)}}_findTargetUnder(e,t){let n=(this._active?.source.ownerDocument??document).elementsFromPoint(e,t);for(let e of n){let t=e;for(;t;){let e=this._targetByElement.get(t);if(e)return e;t=t.parentElement}}}_handleMove(e){var t,n;this._lastPointerEvent=e,(t=this._ghost)==null||t.update(e.clientX,e.clientY);let r={clientX:e.clientX,clientY:e.clientY,pointerEvent:e},i=this._findTargetUnder(e.clientX,e.clientY);if(i!==this._currentTarget){var a;(a=this._currentTarget)==null||a.handleDragLeave(),this._currentTarget=i}i&&i.handleDragOver(r),(n=this._onDragMoveCallback)==null||n.call(this,r),this._onDragMove.fire(r)}_handleEnd(e,t){let n={clientX:e.clientX,clientY:e.clientY,pointerEvent:e};if(t&&this._currentTarget)this._currentTarget.handleDrop(n);else{var r;(r=this._currentTarget)==null||r.handleDragLeave()}let i=this._onDragEndCallback,a=this._dataDisposable;this._teardown(),this._dataDisposable=void 0,setTimeout(()=>a?.dispose(),0),i?.(n,t),this._onDragEnd.fire(n)}_teardown(){var e,t,n,r,i;this._currentTarget=void 0,this._active=void 0,this._lastPointerEvent=void 0,this._onDragMoveCallback=void 0,this._onDragEndCallback=void 0,(e=this._ghost)==null||e.dispose(),this._ghost=void 0,(t=this._iframeShield)==null||t.release(),this._iframeShield=void 0,(n=this._moveListener)==null||n.dispose(),(r=this._upListener)==null||r.dispose(),(i=this._cancelListener)==null||i.dispose(),this._moveListener=void 0,this._upListener=void 0,this._cancelListener=void 0}},Dn={value:20,type:`percentage`},On=class extends ze{get disabled(){return this._disabled}set disabled(e){this._disabled=e,e&&this._removeOverlay()}get state(){return this._state}constructor(e,t){super(),this.element=e,this.options=t,this._edge=!1,this._onDrop=new Z,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new Z,this.onWillShowOverlay=this._onWillShowOverlay.event,this._disabled=!1,this._acceptedTargetZonesSet=new Set(t.acceptedTargetZones);let n={element:this.element,handleDragOver:e=>this._onDragOver(e),handleDragLeave:()=>this._onDragLeave(),handleDrop:e=>this._onDropEvent(e)};this.addDisposables(this._onDrop,this._onWillShowOverlay,En.getInstance().registerTarget(n))}setTargetZones(e){this._acceptedTargetZonesSet=new Set(e)}setOverlayModel(e){this.options.overlayModel=e}dispose(){this._removeOverlay(),super.dispose()}_onDragOver(e){var t,n;if(this._disabled){this._clearOwnOverlay();return}let r=(t=this.options).getOverrideTarget?.call(t);if(this._acceptedTargetZonesSet.size===0){this._clearOwnOverlay();return}let i=(n=this.options).getOverlayOutline?.call(n)??this.element,a=i.offsetWidth,o=i.offsetHeight;if(a===0||o===0)return;let s=i.getBoundingClientRect(),c=e.clientX-s.left,l=e.clientY-s.top,u=this._resolvePosition(c,l,a,o,e.pointerEvent);if(u===null){this._clearOwnOverlay();return}let d=u.position;if(!this.options.canDisplayOverlay(e.pointerEvent,d)){this._clearOwnOverlay();return}let f=new vn({nativeEvent:e.pointerEvent,position:d,edge:u.edge});if(this._onWillShowOverlay.fire(f),f.defaultPrevented){this._clearOwnOverlay();return}if(u.edge){this._clearOwnOverlay(),this._state=d,this._edge=!0;return}if(this._edge=!1,r){_n({outlineElement:i,targetModel:r,quadrant:d,width:a,height:o,overlayModel:this.options.overlayModel,className:this.options.className}),this._state=d;return}if(!this._targetElement){let e=fn();this._targetElement=e.dropzone,this._overlayElement=e.selection,this._state=`center`,this.element.classList.add(`dv-drop-target`),this.element.append(this._targetElement)}this._overlayElement&&mn(this._overlayElement,d,a,o,this.options.overlayModel),this._state=d}_onDragLeave(){var e;let t=(e=this.options).getOverrideTarget?.call(e);if(t){this._state=void 0,t.clear();return}this._removeOverlay()}_onDropEvent(e){var t;let n=this._state,r=this._edge,i=(t=this.options).getOverrideTarget?.call(t);this._removeOverlay(),i?.clear(),n&&this._onDrop.fire({position:n,nativeEvent:e.pointerEvent,edge:r})}_resolvePosition(e,t,n,r,i){var a;let o=(a=this.options).getPositionResolver?.call(a);if(o){let a=o.resolve({x:e,y:t,width:n,height:r,zones:this._acceptedTargetZonesSet,event:i});return a?{position:a.position,edge:!!a.edge}:null}let s=this._calculateQuadrant(e,t,n,r);return s?{position:s,edge:!1}:null}_calculateQuadrant(e,t,n,r){let i=this.options.overlayModel?.activationSize??Dn;return i.type===`percentage`?Cn(this._acceptedTargetZonesSet,e,t,n,r,i.value):wn(this._acceptedTargetZonesSet,e,t,n,r,i.value)}_clearOwnOverlay(){let e=this._state!==void 0;if(this._removeOverlay(),e){var t,n;(t=(n=this.options).getOverrideTarget)==null||(t=t.call(n))==null||t.clear()}}_removeOverlay(){if(this._edge=!1,this._targetElement){var e;this._state=void 0,(e=this._targetElement.parentElement)==null||e.classList.remove(`dv-drop-target`),this._targetElement.remove(),this._targetElement=void 0,this._overlayElement=void 0}else this._state=void 0}},kn=5,An=250,jn=8,Mn=class extends ze{constructor(e,t){super(),this.element=e,this.options=t,this._disabled=!1,this._armed=!1,this._startX=0,this._startY=0,this._touchOnly=t.touchOnly??!0,this.addDisposables(Q(this.element,`pointerdown`,e=>{this._onPointerDown(e)}))}setDisabled(e){this._disabled=e,e&&this._cancelPending()}setTouchOnly(e){this._touchOnly!==e&&(this._touchOnly=e,e&&this._cancelPending())}_shouldHandle(e){var t;return!(this._disabled||this._touchOnly&&e.pointerType!==`touch`&&e.pointerType!==`pen`||(t=this.options).isCancelled?.call(t,e))}_onPointerDown(e){if(!this._shouldHandle(e))return;this._cancelPending(),this._pendingPointerId=e.pointerId,this._startX=e.clientX,this._startY=e.clientY,this._startEvent=e;let t=e.pointerType===`touch`||e.pointerType===`pen`,n=this.options.touchInitiationDelay,r=(typeof n==`function`?n():n)??An;this._armed=!t||r<=0,t&&r>0&&Number.isFinite(r)&&(this._armTimer=setTimeout(()=>{this._armTimer=void 0,this._armed=!0},r));let i=this.options.threshold??kn,a=this.options.pressTolerance,o=(typeof a==`function`?a():a)??jn,s=this.element.ownerDocument?.defaultView??globalThis.window;this._pendingMoveListener=Q(s,`pointermove`,e=>{if(e.pointerId!==this._pendingPointerId)return;let t=e.clientX-this._startX,n=e.clientY-this._startY,r=Math.hypot(t,n);if(this._armed){r>=i&&this._beginDrag(e);return}r>o&&this._beginDrag(e)}),this._pendingUpListener=Q(s,`pointerup`,e=>{e.pointerId===this._pendingPointerId&&this._cancelPending()}),this._pendingCancelListener=Q(s,`pointercancel`,e=>{e.pointerId===this._pendingPointerId&&this._cancelPending()})}cancelPending(){this._cancelPending()}_cancelPending(){var e,t,n;this._pendingPointerId=void 0,this._armTimer!==void 0&&(clearTimeout(this._armTimer),this._armTimer=void 0),this._armed=!1,(e=this._pendingMoveListener)==null||e.dispose(),(t=this._pendingUpListener)==null||t.dispose(),(n=this._pendingCancelListener)==null||n.dispose(),this._pendingMoveListener=void 0,this._pendingUpListener=void 0,this._pendingCancelListener=void 0,this._startEvent=void 0}_beginDrag(e){var t,n,r;let i=this._startEvent??e;this._cancelPending(),(t=(n=this.options).onDragStart)==null||t.call(n,i);let a=(r=this.options).createGhost?.call(r,i);En.getInstance().beginDrag({pointerEvent:e,source:this.element,getData:()=>this.options.getData(i),ghost:a,onDragMove:this.options.onDragMove,onDragEnd:this.options.onDragEnd})}dispose(){this._cancelPending(),super.dispose()}},Nn=class{constructor(e){this._disposed=!1,this.element=e.element,this.offsetX=e.offsetX??0,this.offsetY=e.offsetY??0,this.element.style.position=`fixed`,this.element.style.left=`0px`,this.element.style.top=`0px`,this.element.style.pointerEvents=`none`,this.element.style.zIndex=`99999`,this.element.style.opacity=String(e.opacity??.8),this.element.style.willChange=`transform`,this.element.style.transform=`translate3d(${e.initialX-this.offsetX}px, ${e.initialY-this.offsetY}px, 0)`,(e.owner?.ownerDocument??document).body.appendChild(this.element)}update(e,t){this._disposed||(this.element.style.transform=`translate3d(${e-this.offsetX}px, ${t-this.offsetY}px, 0)`)}dispose(){this._disposed||(this._disposed=!0,this.element.remove())}},Pn=class extends ze{constructor(e,t){super(),this.el=e,this.opts=t,this._dataDisposable=new Be,this._pointerEventsDisposable=new Be,this._disabled=!!t.disabled,this.addDisposables(this._dataDisposable,this._pointerEventsDisposable,Q(this.el,`dragstart`,e=>{var t,n,r,i;if(e.defaultPrevented||this._disabled||(t=this.opts).isCancelled?.call(t,e)){e.preventDefault();return}let a=lt(this.el.ownerDocument??document);this._pointerEventsDisposable.value={dispose:()=>a.release()},this.el.classList.add(`dv-dragged`),setTimeout(()=>this.el.classList.remove(`dv-dragged`),0),this._dataDisposable.value=this.opts.getData(e);let o=(n=this.opts).createGhost?.call(n,e);if(o&&e.dataTransfer&&(Tn(e.dataTransfer,o.element,{x:o.offsetX??0,y:o.offsetY??0,ownerDocument:this.el.ownerDocument??void 0}),o.dispose)){let e=o.dispose;setTimeout(()=>e(),0)}e.dataTransfer&&(e.dataTransfer.effectAllowed=`move`,e.dataTransfer.items.length===0&&e.dataTransfer.setData(`text/plain`,``)),(r=(i=this.opts).onDragStart)==null||r.call(i,e)}),Q(this.el,`dragend`,e=>{var t,n;this._pointerEventsDisposable.dispose(),setTimeout(()=>this._dataDisposable.dispose(),0),(t=(n=this.opts).onDragEnd)==null||t.call(n,e)}))}setDisabled(e){this._disabled=e}setTouchOnly(e){}cancelPending(){}},Fn=class{constructor(){this.kind=`html5`}createDropTarget(e,t){return new Sn(e,t)}createDragSource(e,t){return new Pn(e,t)}},In=class{constructor(){this.kind=`pointer`}createDropTarget(e,t){return new On(e,t)}createDragSource(e,t){let n=t.createGhost?n=>{let r=t.createGhost(n);if(!r)return;let i=new Nn({element:r.element,initialX:n.clientX,initialY:n.clientY,offsetX:r.offsetX,offsetY:r.offsetY,owner:e});if(r.dispose){let e=i.dispose.bind(i),t=r.dispose;i.dispose=()=>{e(),t()}}return i}:void 0,r=new Mn(e,{getData:t.getData,isCancelled:t.isCancelled,onDragStart:t.onDragStart,onDragEnd:t.onDragEnd?e=>t.onDragEnd(e.pointerEvent):void 0,createGhost:n,touchOnly:t.touchOnly,touchInitiationDelay:t.touchInitiationDelay,pressTolerance:t.pressTolerance,threshold:t.threshold});return t.disabled&&r.setDisabled(!0),r}},Ln=new Fn,Rn=new In,zn=class extends He{constructor(){super()}},Bn=class extends ze{get isFocused(){return this._isFocused}get isActive(){return this._isActive}get isVisible(){return this._isVisible}get width(){return this._width}get height(){return this._height}constructor(e,t){super(),this.id=e,this.component=t,this._isFocused=!1,this._isActive=!1,this._isVisible=!0,this._width=0,this._height=0,this._parameters={},this.panelUpdatesDisposable=new Be,this._onDidDimensionChange=new Z,this.onDidDimensionsChange=this._onDidDimensionChange.event,this._onDidChangeFocus=new Z,this.onDidFocusChange=this._onDidChangeFocus.event,this._onWillFocus=new Z,this.onWillFocus=this._onWillFocus.event,this._onDidVisibilityChange=new Z,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._onWillVisibilityChange=new Z,this.onWillVisibilityChange=this._onWillVisibilityChange.event,this._onDidActiveChange=new Z,this.onDidActiveChange=this._onDidActiveChange.event,this._onActiveChange=new Z,this.onActiveChange=this._onActiveChange.event,this._onDidParametersChange=new Z,this.onDidParametersChange=this._onDidParametersChange.event,this.addDisposables(this.onDidFocusChange(e=>{this._isFocused=e.isFocused}),this.onDidActiveChange(e=>{this._isActive=e.isActive}),this.onDidVisibilityChange(e=>{this._isVisible=e.isVisible}),this.onDidDimensionsChange(e=>{this._width=e.width,this._height=e.height}),this.panelUpdatesDisposable,this._onDidDimensionChange,this._onDidChangeFocus,this._onDidVisibilityChange,this._onDidActiveChange,this._onWillFocus,this._onActiveChange,this._onWillFocus,this._onWillVisibilityChange,this._onDidParametersChange)}getParameters(){return this._parameters}initialize(e){this.panelUpdatesDisposable.value=this._onDidParametersChange.event(t=>{this._parameters=t,e.update({params:t})})}setVisible(e){this._onWillVisibilityChange.fire({isVisible:e})}setActive(){this._onActiveChange.fire()}updateParameters(e){this._onDidParametersChange.fire(e)}},Vn=class extends ze{get element(){return this._element}get width(){return this._width}get height(){return this._height}get params(){return this._params?.params}constructor(e,t,n){super(),this.id=e,this.component=t,this.api=n,this._height=0,this._width=0,this._element=document.createElement(`div`),this._element.tabIndex=-1,this._element.style.outline=`none`,this._element.style.height=`100%`,this._element.style.width=`100%`,this._element.style.overflow=`hidden`;let r=$e(this._element);this.addDisposables(this.api,r.onDidFocus(()=>{this.api._onDidChangeFocus.fire({isFocused:!0})}),r.onDidBlur(()=>{this.api._onDidChangeFocus.fire({isFocused:!1})}),r)}focus(){let e=new zn;this.api._onWillFocus.fire(e),!e.defaultPrevented&&this._element.focus()}layout(e,t){this._width=e,this._height=t,this.api._onDidDimensionChange.fire({width:e,height:t}),this.part&&this._params&&this.part.update(this._params.params)}init(e){this._params=e,this.part=this.getComponent()}update(e){var t;this._params=tn(tn({},this._params),{},{params:tn(tn({},this._params?.params),e.params)});for(let t of Object.keys(e.params))e.params[t]===void 0&&delete this._params.params[t];(t=this.part)==null||t.update({params:this._params.params})}toJSON(){let e=this._params?.params??{};return{id:this.id,component:this.component,params:Object.keys(e).length>0?e:void 0}}dispose(){var e;this.api.dispose(),(e=this.part)==null||e.dispose(),super.dispose()}},Hn=0,Un=()=>`dv-tabpanel-${Hn++}`,Wn=class extends ze{get element(){return this._element}constructor(e,t){var n,r,i;super(),this.accessor=e,this.group=t,this.disposable=new Be,this._onDidFocus=new Z,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new Z,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement(`div`),this._element.className=`dv-content-container`,this._element.tabIndex=-1,this._element.id=Un(),this._element.setAttribute(`role`,`tabpanel`),this.addDisposables(this._onDidFocus,this._onDidBlur);let a=()=>t.dropTargetContainer?.model,o=(e,t)=>this.group.canDisplayContentOverlay(e,t);this.dropTarget=new Sn(this.element,{getOverlayOutline:()=>e.options.theme?.dndPanelOverlay===`group`?this.element.parentElement:null,className:`dv-drop-target-content`,acceptedTargetZones:[`top`,`bottom`,`left`,`right`,`center`],canDisplayOverlay:o,getOverrideTarget:a,overlayModel:(n=this.accessor).resolveDropOverlayModel?.call(n,`content`),getPositionResolver:()=>e.getDropPositionResolver?.call(e)}),this.pointerDropTarget=Rn.createDropTarget(this.element,{acceptedTargetZones:[`top`,`bottom`,`left`,`right`,`center`],canDisplayOverlay:o,getOverlayOutline:()=>e.options.theme?.dndPanelOverlay===`group`?this.element.parentElement:null,className:`dv-drop-target-content`,getOverrideTarget:a,overlayModel:(r=this.accessor).resolveDropOverlayModel?.call(r,`content`),getPositionResolver:()=>e.getDropPositionResolver?.call(e)}),this.addDisposables(this.dropTarget,this.pointerDropTarget,(i=this.accessor).onDidOptionsChange?.call(i,()=>{var e;let t=(e=this.accessor).resolveDropOverlayModel?.call(e,`content`)??{};this.dropTarget.setOverlayModel(t),this.pointerDropTarget.setOverlayModel(t)})??Re.NONE)}show(){this.element.style.display=``}hide(){this.element.style.display=`none`}setLabelledBy(e){e?this._element.setAttribute(`aria-labelledby`,e):this._element.removeAttribute(`aria-labelledby`)}renderPanel(e,t){let n=(t?.asActive??!0)||this.panel&&this.group.isPanelActive(this.panel);if(this.panel?.view.content.element.parentElement===this._element){var r,i;this.panel.view.content.element.remove(),(r=(i=this.panel.view.content).onHide)==null||r.call(i)}this.panel=e;let a;switch(e.api.renderer){case`onlyWhenVisible`:if(this.group.renderContainer.detatch(e),this.panel&&n){var o,s;this._element.appendChild(this.panel.view.content.element),(o=(s=this.panel.view.content).onShow)==null||o.call(s)}a=this._element;break;case`always`:e.view.content.element.parentElement===this._element&&e.view.content.element.remove(),a=this.group.renderContainer.attach({panel:e,referenceContainer:this});break;default:throw Error(`dockview: invalid renderer type '${e.api.renderer}'`)}if(n){let e=$e(a);this.focusTracker=e;let t=new ze;t.addDisposables(e,e.onDidFocus(()=>this._onDidFocus.fire()),e.onDidBlur(()=>this._onDidBlur.fire())),this.disposable.value=t}}openPanel(e){this.panel!==e&&this.renderPanel(e)}layout(e,t){}closePanel(){if(this.panel&&this.panel.api.renderer===`onlyWhenVisible`){var e,t;this.panel.view.content.element.remove(),(e=(t=this.panel.view.content).onHide)==null||e.call(t)}this.panel=void 0}dispose(){this.disposable.dispose(),super.dispose()}refreshFocusState(){this.focusTracker?.refreshState&&this.focusTracker.refreshState()}},Gn=e=>{let t=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);t.setAttributeNS(null,`height`,e.height),t.setAttributeNS(null,`width`,e.width),t.setAttributeNS(null,`viewBox`,e.viewbox),t.setAttributeNS(null,`aria-hidden`,`false`),t.setAttributeNS(null,`focusable`,`false`),t.classList.add(`dv-svg`);let n=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);return n.setAttributeNS(null,`d`,e.path),t.appendChild(n),t},Kn=()=>Gn({width:`11`,height:`11`,viewbox:`0 0 28 28`,path:`M2.1 27.3L0 25.2L11.55 13.65L0 2.1L2.1 0L13.65 11.55L25.2 0L27.3 2.1L15.75 13.65L27.3 25.2L25.2 27.3L13.65 15.75L2.1 27.3Z`}),qn=()=>Gn({width:`11`,height:`11`,viewbox:`0 0 24 24`,path:`M16 9V4h1c.55 0 1-.45 1-1s-.45-1-1-1H6c-.55 0-1 .45-1 1s.45 1 1 1h1v5c0 1.66-1.34 3-3 3v2h5.97v7l1 1 1-1v-7H19v-2c-1.66 0-3-1.34-3-3z`}),Jn=()=>Gn({width:`11`,height:`11`,viewbox:`0 0 15 25`,path:`M2.15 24.1L0 21.95L9.9 12.05L0 2.15L2.15 0L14.2 12.05L2.15 24.1Z`}),Yn=500,Xn=8,Zn=class extends ze{constructor(e,t){super(),this.element=e,this.options=t,this._startX=0,this._startY=0,this.addDisposables(Q(this.element,`pointerdown`,e=>{this._onPointerDown(e)}))}_onPointerDown(e){if((this.options.touchOnly??!0)&&e.pointerType!==`touch`&&e.pointerType!==`pen`)return;this._cancelPending(),this._pointerId=e.pointerId,this._startX=e.clientX,this._startY=e.clientY;let t=this.options.delay??Yn,n=this.options.tolerance??Xn,r=this.element.ownerDocument?.defaultView??globalThis.window;this._timer=setTimeout(()=>{this._timer=void 0,this._cancelPending(),this._installContextMenuGuard(r),this._installClickGuard(r),this.options.onLongPress(e)},t),this._moveListener=Q(r,`pointermove`,e=>{if(e.pointerId!==this._pointerId)return;let t=e.clientX-this._startX,r=e.clientY-this._startY;Math.hypot(t,r)>n&&this._cancelPending()}),this._upListener=Q(r,`pointerup`,e=>{e.pointerId===this._pointerId&&this._cancelPending()}),this._cancelListener=Q(r,`pointercancel`,e=>{e.pointerId===this._pointerId&&this._cancelPending()})}_installContextMenuGuard(e){let t,n=setTimeout(()=>t?.dispose(),500);t=Q(e,`contextmenu`,e=>{e.preventDefault(),clearTimeout(n),t?.dispose()},{capture:!0})}_installClickGuard(e){let t,n=setTimeout(()=>t?.dispose(),500);t=Q(e,`click`,e=>{let r=e.target;r&&this.element.contains(r)&&(e.preventDefault(),e.stopPropagation()),clearTimeout(n),t?.dispose()},{capture:!0})}_cancelPending(){var e,t,n;this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0),this._pointerId=void 0,(e=this._moveListener)==null||e.dispose(),(t=this._upListener)==null||t.dispose(),(n=this._cancelListener)==null||n.dispose(),this._moveListener=void 0,this._upListener=void 0,this._cancelListener=void 0}dispose(){this._cancelPending(),super.dispose()}};function Qn(e){if(e.disableDnd)return{html5:!1,pointer:!1,pointerHandlesMouse:!1};switch(e.dndStrategy){case`pointer`:return{html5:!1,pointer:!0,pointerHandlesMouse:!0};case`html5`:return{html5:!0,pointer:!1,pointerHandlesMouse:!1};case`auto`:case void 0:default:return $n()?{html5:!1,pointer:!0,pointerHandlesMouse:!0}:{html5:!0,pointer:!0,pointerHandlesMouse:!1}}}function $n(){if(globalThis.window===void 0||!globalThis.matchMedia)return!1;let e=globalThis.matchMedia(`(pointer: coarse)`).matches,t=globalThis.matchMedia(`(pointer: fine)`).matches;return e&&!t}var er=0,tr=()=>`dv-tab-${er++}`,nr=class extends ze{get element(){return this._element}constructor(e,t,n){var r,i,a,o,s;super(),this.panel=e,this.accessor=t,this.group=n,this.content=void 0,this.panelTransfer=Ie.getInstance(),this._direction=`horizontal`,this._pinIndicator=void 0,this._onPointDown=new Z,this.onPointerDown=this._onPointDown.event,this._onTabClick=new Z,this.onTabClick=this._onTabClick.event,this._onDropped=new Z,this.onDrop=this._onDropped.event,this._onDragStart=new Z,this.onDragStart=this._onDragStart.event,this._onDragEnd=new Z,this.onDragEnd=this._onDragEnd.event;let c=Qn(this.accessor.options);this._element=document.createElement(`div`),this._element.className=`dv-tab`,this._element.tabIndex=-1,this._element.draggable=c.html5,this._element.id=tr(),this._element.setAttribute(`role`,`tab`),this._element.setAttribute(`aria-selected`,`false`),this._element.setAttribute(`aria-label`,this.panel.title??this.panel.id),this._element.dataset.tabPanelId=this.panel.id;let l=(r=this.group)==null||(r=r.model)==null?void 0:r.contentContainerId;l&&this._element.setAttribute(`aria-controls`,l),$(this.element,`dv-inactive-tab`,!0),this._updatePinnedClasses();let u=(e,t)=>{if(this.group.locked)return!1;let n=Le();return this.accessor.id===n?.viewId?this.accessor.options.theme?.tabAnimation!==`smooth`:this.group.model.canDisplayOverlay(e,t,`tab`)};this.dropTarget=Ln.createDropTarget(this._element,{acceptedTargetZones:[`left`,`right`],overlayModel:this._buildOverlayModel(),canDisplayOverlay:u,getOverrideTarget:()=>n.model.dropTargetContainer?.model}),this.pointerDropTarget=Rn.createDropTarget(this._element,{acceptedTargetZones:[`left`,`right`],overlayModel:this._buildOverlayModel(),canDisplayOverlay:u,getOverrideTarget:()=>n.model.dropTargetContainer?.model});let d={getData:()=>(this.panelTransfer.setData([new Fe(this.accessor.id,this.group.id,this.panel.id)],Fe.prototype),{dispose:()=>{this.panelTransfer.clearData(Fe.prototype)}}),createGhost:()=>({element:this._buildGhostElement(),offsetX:30,offsetY:-10}),onDragStart:e=>{this._onDragStart.fire(e),!(e instanceof PointerEvent)&&this.accessor.options.theme?.tabAnimation===`smooth`&&requestAnimationFrame(()=>{$(this.element,`dv-tab--dragging`,!0)})},onDragEnd:e=>{this._onDragEnd.fire(e)}};this.html5DragSource=Ln.createDragSource(this._element,tn(tn({},d),{},{disabled:!c.html5})),this.pointerDragSource=Rn.createDragSource(this._element,tn(tn({},d),{},{disabled:!c.pointer,touchOnly:!c.pointerHandlesMouse,isCancelled:()=>!Qn(this.accessor.options).pointer})),this.onWillShowOverlay=Ve.any(this.dropTarget.onWillShowOverlay,this.pointerDropTarget.onWillShowOverlay),this.addDisposables(this._onPointDown,this._onTabClick,this._onDropped,this._onDragStart,this._onDragEnd,this.accessor.onDidOptionsChange(()=>{let e=this._buildOverlayModel();this.dropTarget.setOverlayModel(e),this.pointerDropTarget.setOverlayModel(e),this._updatePinnedClasses()}),((i=this.panel.api)==null||(a=i.onDidChangePinned)==null?void 0:a.call(i,()=>{this._updatePinnedClasses()}))??{dispose:()=>{}},((o=this.panel.api)==null||(s=o.onDidTitleChange)==null?void 0:s.call(o,e=>{this._element.setAttribute(`aria-label`,e.title??this.panel.id)}))??{dispose:()=>{}},Q(this._element,`dragend`,()=>{$(this.element,`dv-tab--dragging`,!1)}),this.html5DragSource,Q(this._element,`pointerdown`,e=>{this._onPointDown.fire(e)}),Q(this._element,`click`,e=>{this._onTabClick.fire(e)}),Q(this._element,`contextmenu`,e=>{var t;(t=this.accessor.contextMenuService)==null||t.show(this.panel,this.group,e)}),new Zn(this._element,{onLongPress:e=>{var t;this.pointerDragSource.cancelPending(),(t=this.accessor.contextMenuService)==null||t.show(this.panel,this.group,e)}}),this.dropTarget.onDrop(e=>{this._onDropped.fire(e)}),this.pointerDropTarget.onDrop(e=>{this._onDropped.fire(e)}),this.dropTarget,this.pointerDropTarget,this.pointerDragSource)}_updatePinnedClasses(){let e=this.panel.api?.isPinned??!1,t=e&&this.accessor.options.pinnedTabs?.compact===!0;$(this.element,`dv-tab--pinned`,e),$(this.element,`dv-tab--pinned-compact`,t);let n=e&&!this.panel.api?.tabComponent;if(n&&!this._pinIndicator){let e=document.createElement(`div`);e.className=`dv-tab-pin`,e.appendChild(qn()),this._element.insertBefore(e,this._element.firstChild),this._pinIndicator=e}else!n&&this._pinIndicator&&(this._pinIndicator.remove(),this._pinIndicator=void 0)}setActive(e){$(this.element,`dv-active-tab`,e),$(this.element,`dv-inactive-tab`,!e),this._element.setAttribute(`aria-selected`,e?`true`:`false`),this._element.tabIndex=e?0:-1}setContent(e){this.content&&this.content.element.remove(),this.content=e,this._element.appendChild(this.content.element)}_buildOverlayModel(){var e;let t=(e=this.accessor).resolveDropOverlayModel?.call(e,`tab`,this.group);if(t)return t;let n=this.accessor.options.theme?.dndTabIndicator===`line`?1/0:0;return{activationSize:{value:50,type:`percentage`},smallWidthBoundary:n,smallHeightBoundary:n}}setDirection(e){this._direction=e;let t=e===`vertical`?[`top`,`bottom`]:[`left`,`right`];this.dropTarget.setTargetZones(t),this.pointerDropTarget.setTargetZones(t)}updateDragAndDropState(){let e=Qn(this.accessor.options);this._element.draggable=e.html5,this.html5DragSource.setDisabled(!e.html5),this.pointerDragSource.setDisabled(!e.pointer),this.pointerDragSource.setTouchOnly(!e.pointerHandlesMouse)}_buildGhostElement(){let e=getComputedStyle(this.element),t=this.element.cloneNode(!0),n=this._direction===`vertical`,r=new Set([`writing-mode`,`inline-size`,`block-size`,`min-inline-size`,`min-block-size`,`max-inline-size`,`max-block-size`,`margin-inline`,`margin-inline-start`,`margin-inline-end`,`margin-block`,`margin-block-start`,`margin-block-end`,`padding-inline`,`padding-inline-start`,`padding-inline-end`,`padding-block`,`padding-block-start`,`padding-block-end`]);return Array.from(e).forEach(i=>{n&&r.has(i)||t.style.setProperty(i,e.getPropertyValue(i),e.getPropertyPriority(i))}),n&&(t.style.setProperty(`writing-mode`,`horizontal-tb`),t.style.setProperty(`width`,e.height),t.style.setProperty(`height`,e.width)),t.style.position=`absolute`,t.classList.add(`dv-tab-ghost-drag`),t}},rr=class{get kind(){return this.options.kind}get nativeEvent(){return this.event.nativeEvent}get position(){return this.event.position}get edge(){return this.event.edge}get edgeGroup(){return this.event.edgeGroup}get defaultPrevented(){return this.event.defaultPrevented}get panel(){return this.options.panel}get api(){return this.options.api}get group(){return this.options.group}preventDefault(){this.event.preventDefault()}getData(){return this.options.getData()}constructor(e,t){this.event=e,this.options=t}},ir=class extends ze{get group(){return this.groupAccessor()}constructor(e){var t;super(),this.panelTransfer=Ie.getInstance(),this._onDragStart=new Z,this.onDragStart=this._onDragStart.event,this._element=e.element,this.accessor=e.accessor;let n=e.group;this.groupAccessor=typeof n==`function`?n:()=>n,this.isFloatingMoveHandle=e.isFloatingMoveHandle??(()=>!0);let r=Qn(this.accessor.options);this._element.draggable=r.html5,$(this._element,`dv-draggable`,r.html5||r.pointer),this.addDisposables(this._onDragStart);let i=()=>{let e=document.createElement(`div`),t=globalThis.getComputedStyle(this._element),n=t.getPropertyValue(`--dv-activegroup-visiblepanel-tab-background-color`),r=t.getPropertyValue(`--dv-activegroup-visiblepanel-tab-color`);return e.style.backgroundColor=n,e.style.color=r,e.style.padding=`2px 8px`,e.style.height=`24px`,e.style.fontSize=`11px`,e.style.lineHeight=`20px`,e.style.borderRadius=`12px`,e.style.whiteSpace=`nowrap`,e.style.boxSizing=`border-box`,e.style.display=`inline-block`,e.textContent=`Multiple Panels (${this.group.size})`,e},a={getData:()=>(this.panelTransfer.setData([new Fe(this.accessor.id,this.group.id,null)],Fe.prototype),{dispose:()=>{this.panelTransfer.clearData(Fe.prototype)}}),createGhost:()=>{var e;return(e=this.accessor).buildGroupDragGhost?.call(e,this.group)||{element:i(),offsetX:30,offsetY:-10}},onDragStart:e=>{this._onDragStart.fire(e)}};this.html5DragSource=Ln.createDragSource(this._element,tn(tn({},a),{},{disabled:!r.html5,isCancelled:e=>!!(this.group.api.location.type===`floating`&&this.isFloatingMoveHandle()&&!e.shiftKey||this.group.api.location.type===`edge`&&this.group.size===0)}));let o=()=>{var e;return((e=this.group)==null||(e=e.api)==null||(e=e.location)==null?void 0:e.type)===`floating`&&this.isFloatingMoveHandle()};this.pointerDragSource=Rn.createDragSource(this._element,tn(tn({},a),{},{disabled:!r.pointer,touchOnly:!r.pointerHandlesMouse,touchInitiationDelay:()=>o()?500:250,pressTolerance:()=>o()?1/0:8,isCancelled:()=>!Qn(this.accessor.options).pointer||this.group.api.location.type===`edge`&&this.group.size===0,onDragStart:e=>{var t;(t=this.getFloatingOverlay())==null||t.cancelPendingDrag(),this._onDragStart.fire(e)}}));let s=new Be,c=()=>{let e=this.getFloatingOverlay();s.value=e?e.onDidStartMoving(()=>{this.pointerDragSource.cancelPending()}):Re.NONE};c(),this.addDisposables(s);let l=(t=this.group)==null||(t=t.api)==null?void 0:t.onDidLocationChange;l&&this.addDisposables(l(c)),this.addDisposables(this.html5DragSource,this.pointerDragSource)}updateDragAndDropState(){let e=Qn(this.accessor.options);this._element.draggable=e.html5,$(this._element,`dv-draggable`,e.html5||e.pointer),this.html5DragSource.setDisabled(!e.html5),this.pointerDragSource.setDisabled(!e.pointer),this.pointerDragSource.setTouchOnly(!e.pointerHandlesMouse)}getFloatingOverlay(){var e;if(this.group)return(e=this.accessor.floatingGroups)==null||(e=e.find(e=>e.group===this.group))==null?void 0:e.overlay}},ar=class extends ze{get element(){return this._element}constructor(e,t){var n,r,i;super(),this.accessor=e,this.group=t,this._onDrop=new Z,this.onDrop=this._onDrop.event,this._onDragStart=new Z,this.onDragStart=this._onDragStart.event,this._element=document.createElement(`div`),this._element.className=`dv-void-container`,this.addDisposables(this._onDrop,this._onDragStart,Q(this._element,`pointerdown`,()=>{this.accessor.doSetGroupActive(this.group)}),Q(this._element,`pointerdown`,e=>{e.shiftKey&&nt(e)},!0)),this.dragSource=new ir({element:this._element,accessor:this.accessor,group:this.group,isFloatingMoveHandle:()=>!this._element.closest(`.dv-resize-container-with-titlebar`)});let a=(e,n)=>{if(this.group.api.locked)return!1;let r=Le();return this.accessor.id===r?.viewId||t.model.canDisplayOverlay(e,n,`header_space`)};this.dropTarget=Ln.createDropTarget(this._element,{acceptedTargetZones:[`center`],canDisplayOverlay:a,getOverrideTarget:()=>t.model.dropTargetContainer?.model,overlayModel:(n=this.accessor).resolveDropOverlayModel?.call(n,`header_space`,this.group)}),this.pointerDropTarget=Rn.createDropTarget(this._element,{acceptedTargetZones:[`center`],canDisplayOverlay:a,getOverrideTarget:()=>t.model.dropTargetContainer?.model,overlayModel:(r=this.accessor).resolveDropOverlayModel?.call(r,`header_space`,this.group)}),this.onWillShowOverlay=Ve.any(this.dropTarget.onWillShowOverlay,this.pointerDropTarget.onWillShowOverlay),this.addDisposables(this.dragSource,this.dragSource.onDragStart(e=>{this._onDragStart.fire(e)}),this.dropTarget.onDrop(e=>{this._onDrop.fire(e)}),this.pointerDropTarget.onDrop(e=>{this._onDrop.fire(e)}),this.dropTarget,this.pointerDropTarget,(i=this.accessor).onDidOptionsChange?.call(i,()=>{var e;let t=(e=this.accessor).resolveDropOverlayModel?.call(e,`header_space`,this.group)??{};this.dropTarget.setOverlayModel(t),this.pointerDropTarget.setOverlayModel(t)})??Re.NONE)}updateDragAndDropState(){this.dragSource.updateDragAndDropState()}},or=class e extends ze{get element(){return this._element}get orientation(){return this._orientation}set orientation(e){this._orientation!==e&&(this._scrollOffset=0,this._orientation=e,Xe(this._scrollbar,`dv-scrollbar-vertical`,`dv-scrollbar-horizontal`),e===`vertical`?Ze(this._scrollbar,`dv-scrollbar-vertical`):Ze(this._scrollbar,`dv-scrollbar-horizontal`))}constructor(t){super(),this.scrollableElement=t,this._scrollOffset=0,this._orientation=`horizontal`,this._element=document.createElement(`div`),this._element.className=`dv-scrollable`,this._scrollbar=document.createElement(`div`),this._scrollbar.className=`dv-scrollbar dv-scrollbar-horizontal`,this.element.appendChild(t),this.element.appendChild(this._scrollbar),this.addDisposables(Q(this.element,`wheel`,t=>{this._scrollOffset+=t.deltaY*e.MouseWheelSpeed,this.scheduleStyleUpdate()}),Q(this._scrollbar,`pointerdown`,e=>{e.preventDefault();let t=this._scrollbar.ownerDocument??document;$(this.element,`dv-scrollable-scrolling`,!0);let n=this._orientation===`horizontal`?e.clientX:e.clientY,r=this._scrollOffset,i=e=>{let t=this._orientation===`horizontal`?e.clientX-n:e.clientY-n,i=(this._orientation===`horizontal`?this.element.clientWidth:this.element.clientHeight)/(this._orientation===`horizontal`?this.scrollableElement.scrollWidth:this.scrollableElement.scrollHeight);this._scrollOffset=r+t/i,this.scheduleStyleUpdate()},a=()=>{$(this.element,`dv-scrollable-scrolling`,!1),t.removeEventListener(`pointermove`,i),t.removeEventListener(`pointerup`,a),t.removeEventListener(`pointercancel`,a)};t.addEventListener(`pointermove`,i),t.addEventListener(`pointerup`,a),t.addEventListener(`pointercancel`,a)}),Q(this.element,`scroll`,()=>{this.scheduleStyleUpdate()}),Q(this.scrollableElement,`scroll`,()=>{this._scrollOffset=this._orientation===`horizontal`?this.scrollableElement.scrollLeft:this.scrollableElement.scrollTop,this.scheduleStyleUpdate()}),Ye(this.element,()=>{$(this.element,`dv-scrollable-resizing`,!0),this._animationTimer&&clearTimeout(this._animationTimer),this._animationTimer=setTimeout(()=>{clearTimeout(this._animationTimer),$(this.element,`dv-scrollable-resizing`,!1)},500),this.scheduleStyleUpdate()}),Re.from(()=>{this._pendingStyleFrame!==void 0&&(cancelAnimationFrame(this._pendingStyleFrame),this._pendingStyleFrame=void 0)}))}scheduleStyleUpdate(){this._pendingStyleFrame===void 0&&(this._pendingStyleFrame=requestAnimationFrame(()=>{this._pendingStyleFrame=void 0,this.calculateScrollbarStyles()}))}calculateScrollbarStyles(){let e=this._orientation===`horizontal`?this.element.clientWidth:this.element.clientHeight,t=this._orientation===`horizontal`?this.scrollableElement.scrollWidth:this.scrollableElement.scrollHeight;if(t>e){let n=e/t*e;this._orientation===`horizontal`?(this._scrollbar.style.width=`${n}px`,this._scrollbar.style.height=``):(this._scrollbar.style.height=`${n}px`,this._scrollbar.style.width=``),this._scrollOffset=wt(this._scrollOffset,0,t-e),this._orientation===`horizontal`?this.scrollableElement.scrollLeft=this._scrollOffset:this.scrollableElement.scrollTop=this._scrollOffset;let r=this._scrollOffset/(t-e);this._orientation===`horizontal`?(this._scrollbar.style.left=`${(e-n)*r}px`,this._scrollbar.style.top=``):(this._scrollbar.style.top=`${(e-n)*r}px`,this._scrollbar.style.left=``)}else this._orientation===`horizontal`?(this._scrollbar.style.width=`0px`,this._scrollbar.style.left=`0px`):(this._scrollbar.style.height=`0px`,this._scrollbar.style.top=`0px`),this._scrollOffset=0}};or.MouseWheelSpeed=1;var sr=`dv-tabs-container--wrap`;function cr(e,t){return typeof e==`boolean`?e:!!e?.[t]}function lr(e){return typeof e==`boolean`?e:e?Object.values(e).some(Boolean):!1}var ur=class extends Ue{constructor(e,t,n,r,i){super(),this.nativeEvent=e,this.target=t,this.position=n,this.getData=r,this.group=i}};function dr(e){return!!e.referencePanel}function fr(e){return!!e.referenceGroup}function pr(e){return!!e.referencePanel}function mr(e){return!!e.referenceGroup}var hr=[{id:`grey`,value:`var(--dv-tab-group-color-grey)`,label:`Grey`},{id:`blue`,value:`var(--dv-tab-group-color-blue)`,label:`Blue`},{id:`red`,value:`var(--dv-tab-group-color-red)`,label:`Red`},{id:`yellow`,value:`var(--dv-tab-group-color-yellow)`,label:`Yellow`},{id:`green`,value:`var(--dv-tab-group-color-green)`,label:`Green`},{id:`pink`,value:`var(--dv-tab-group-color-pink)`,label:`Pink`},{id:`purple`,value:`var(--dv-tab-group-color-purple)`,label:`Purple`},{id:`cyan`,value:`var(--dv-tab-group-color-cyan)`,label:`Cyan`},{id:`orange`,value:`var(--dv-tab-group-color-orange)`,label:`Orange`}],gr=class{constructor(e,t=!0){this._entries=e.slice(),this._byId=new Map(e.map(e=>[e.id,e])),this._enabled=t}get enabled(){return this._enabled}set enabled(e){this._enabled=e}setEntries(e){this._entries=e.slice(),this._byId=new Map(e.map(e=>[e.id,e]))}entries(){return this._entries}has(e){return this._byId.has(e)}get(e){return this._byId.get(e)}defaultId(){return this._entries[0]?.id}resolveValue(e){if(!this._enabled||!e)return;let t=this._byId.get(e);return t?t.value:e}},_r;function vr(){return _r??=new gr(hr,!0),_r}function yr(e,t,n){let r=(n??vr()).resolveValue(t);r===void 0?e.style.removeProperty(`--dv-tab-group-color`):e.style.setProperty(`--dv-tab-group-color`,r)}function br(e,t){return(t??vr()).resolveValue(e)}var xr=class extends ze{get element(){return this._element}constructor(e){super(),this._palette=e,this._onClick=new Z,this.onClick=this._onClick.event,this._onContextMenu=new Z,this.onContextMenu=this._onContextMenu.event,this._element=document.createElement(`div`),this._element.className=`dv-tab-group-chip`,this._element.tabIndex=0,this._label=document.createElement(`span`),this._label.className=`dv-tab-group-chip-label`,this._element.appendChild(this._label),this.addDisposables(this._onClick,this._onContextMenu,new Zn(this._element,{onLongPress:e=>{this._onContextMenu.fire(e)}}),Q(this._element,`click`,e=>{this._onClick.fire(e)}),Q(this._element,`contextmenu`,e=>{this._onContextMenu.fire(e)}))}init(e){this._tabGroup=e.tabGroup,this.updateColor(e.tabGroup.color),this.updateLabel(e.tabGroup.label),this.updateCollapsed(e.tabGroup.collapsed),this.addDisposables(e.tabGroup.onDidChange(()=>{this._tabGroup&&(this.updateColor(this._tabGroup.color),this.updateLabel(this._tabGroup.label))}),e.tabGroup.onDidCollapseChange(e=>{this.updateCollapsed(e)}),this._onClick.event(()=>{var e;(e=this._tabGroup)==null||e.toggle()}))}update(e){this._tabGroup=e.tabGroup,this.updateColor(e.tabGroup.color),this.updateLabel(e.tabGroup.label),this.updateCollapsed(e.tabGroup.collapsed)}updateColor(e){yr(this._element,e,this._palette),$(this._element,`dv-tab-group-chip--accent-off`,this._palette?.enabled===!1)}updateLabel(e){this._label.textContent=e,$(this._label,`dv-tab-group-chip-label--empty`,!e)}updateCollapsed(e){$(this._element,`dv-tab-group-chip--collapsed`,e)}},Sr=`dv-tab-group-chip-continuation`,Cr=8,wr=class{get underlines(){return this._underlines}constructor(e){this._ctx=e,this._underlines=new Map,this._continuationMarkers=new Map,this._rafId=null}positionUnderlines(){requestAnimationFrame(()=>{this._positionUnderlinesSync()})}trackUnderlines(){this._rafId!==null&&cancelAnimationFrame(this._rafId);let e=performance.now(),t=()=>{this._positionUnderlinesSync(),this._rafId=performance.now()-e<250?requestAnimationFrame(t):null};this._rafId=requestAnimationFrame(t)}syncUnderlineElements(e){for(let t of e)if(!this._underlines.has(t)){let e=document.createElement(`div`);e.className=`dv-tab-group-underline`,this._ctx.tabsList.appendChild(e),this._underlines.set(t,e)}for(let[t,n]of this._underlines)e.has(t)||(n.remove(),this._underlines.delete(t),this._clearContinuationMarkers(t))}getUnderline(e){return this._underlines.get(e)}dispose(){this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null);for(let[,e]of this._underlines)e.remove();this._underlines.clear(),this._clearContinuationMarkers()}_syncContinuationMarkers(e,t){let n=this._continuationMarkers.get(e);for(n||(n=[],this._continuationMarkers.set(e,n));n.length<t;){let e=document.createElement(`div`);e.className=Sr,this._ctx.tabsList.appendChild(e),n.push(e)}for(;n.length>t;)n.pop()?.remove();return n}_clearContinuationMarkers(e){if(e===void 0){for(let[,e]of this._continuationMarkers)for(let t of e)t.remove();this._continuationMarkers.clear();return}let t=this._continuationMarkers.get(e);if(t){for(let e of t)e.remove();this._continuationMarkers.delete(e)}}_positionUnderlinesSync(){let e=this._ctx.tabsList.getBoundingClientRect(),t=this._ctx.getTabGroups(),n=this._ctx.getDirection()===`vertical`,r=this._ctx.tabsList.classList.contains(sr);r||this._clearContinuationMarkers();let i=n?e.width:e.height,a=this._ctx.getActivePanelId(),o=this._ctx.getTabMap();for(let s of t){let t=this._underlines.get(s.id);if(!t)continue;let c=s.panelIds;if(c.length===0){t.style.display=`none`;continue}if(t.style.display=``,r){this._positionWrappedUnderline(t,s,e,o,n);continue}let l=this._ctx.getChipElement(s.id),u;if(l){let t=l.getBoundingClientRect(),r=getComputedStyle(l),i=n?Number.parseFloat(r.marginTop)||0:Number.parseFloat(r.marginLeft)||0;u=n?t.top-e.top-i:t.left-e.left-i}else{let t=c[0],r=o.get(t);if(r){let t=r.value.element.getBoundingClientRect();u=n?t.top-e.top:t.left-e.left}else u=0}let d=c[c.length-1],f=o.get(d);if(!f){n?(t.style.top=`${u}px`,t.style.height=`0px`,t.style.left=``,t.style.width=``):(t.style.left=`${u}px`,t.style.width=`0px`,t.style.top=``,t.style.height=``);continue}let p=f.value.element.getBoundingClientRect(),m=n?p.bottom-e.top:p.right-e.left,h=m-u;if((s.collapsed||s.panelIds.some(e=>o.get(e)?.value.element.classList.contains(`dv-tab--group-expanding`)))&&l){let t=l.getBoundingClientRect(),r=n?t.top+t.height/2-e.top:t.left+t.width/2-e.left,i=0,a=0;for(let e of s.panelIds){let t=o.get(e);if(!t)continue;let r=t.value.element;n?(i+=r.getBoundingClientRect().height,a+=r.scrollHeight):(i+=r.getBoundingClientRect().width,a+=r.scrollWidth)}let c=a>0?Math.min(1,i/a):0;u=r+(u-r)*c,m=r+(m-r)*c,h=Math.max(0,m-u)}n?(t.style.top=`${u}px`,t.style.height=`${Math.max(0,h)}px`,t.style.left=``,t.style.width=``,t.style.bottom=``):(t.style.left=`${u}px`,t.style.width=`${Math.max(0,h)}px`,t.style.top=``,t.style.height=``,t.style.bottom=``),this.applyShape(t,s,u,h,i,a,e,n)}}_positionWrappedUnderline(e,t,n,r,i){let a=br(t.color,this._ctx.getColorPalette());if(a===void 0){e.style.display=`none`,this._clearContinuationMarkers(t.id);return}let{runs:o,firstRun:s}=this._computeWrappedRuns(t,n,r,i);if(o.length===0){e.style.display=`none`,this._clearContinuationMarkers(t.id);return}this._positionContinuationMarkers(t.id,o,s,a,i);let c=Math.min(...o.map(e=>e.left)),l=Math.max(...o.map(e=>e.right)),u=Math.min(...o.map(e=>e.top)),d=Math.max(...o.map(e=>e.bottom)),f=i?Math.max(0,l-c):n.width,p=i?n.height:Math.max(0,d-u);e.style.left=i?`${c}px`:`0px`,e.style.top=i?`0px`:`${u}px`,e.style.bottom=`auto`,e.style.width=`${f}px`,e.style.height=`${p}px`,e.style.backgroundColor=``;let{svg:m,path:h}=this.ensureSvgPath(e);m.setAttribute(`width`,String(f)),m.setAttribute(`height`,String(p)),h.setAttribute(`stroke`,a),h.setAttribute(`stroke-width`,`2`);let g=this._ctx.getHeaderPosition(),_=i?g===`right`:g===`bottom`;h.setAttribute(`d`,this._wrappedPathData(o,i,_,c,u,2))}_computeWrappedRuns(e,t,n,r){let i=[],a;for(let o of e.panelIds){let e=n.get(o);if(!e)continue;let s=e.value.element.getBoundingClientRect();if(s.width===0&&s.height===0)continue;let c=s.top-t.top,l=s.bottom-t.top,u=s.left-t.left,d=s.right-t.left,f=r?u:c,p=i.find(e=>Math.abs((r?e.left:e.top)-f)<=2);p?(p.top=Math.min(p.top,c),p.bottom=Math.max(p.bottom,l),p.left=Math.min(p.left,u),p.right=Math.max(p.right,d)):(p={top:c,bottom:l,left:u,right:d},i.push(p)),a??=p}return{runs:i,firstRun:a}}_wrappedPathData(e,t,n,r,i,a){let o=``;for(let s of e)if(t){let e=n?s.right-r-a/2:s.left-r+a/2;o+=`M ${e},${s.top} L ${e},${s.bottom} `}else{let e=n?s.top-i+a/2:s.bottom-i-a/2;o+=`M ${s.left},${e} L ${s.right},${e} `}return o.trim()}_positionContinuationMarkers(e,t,n,r,i){let a=t.filter(e=>e!==n),o=this._syncContinuationMarkers(e,a.length);a.forEach((e,t)=>{let n=o[t];if(n.style.backgroundColor=r,i){let t=(e.left+e.right)/2;n.style.left=`${t-Cr/2}px`,n.style.top=`${e.top}px`}else{let t=(e.top+e.bottom)/2;n.style.left=`${e.left}px`,n.style.top=`${t-Cr/2}px`}})}ensureSvgPath(e){let t=e.firstElementChild;if(t?.tagName===`svg`)return{svg:t,path:t.firstElementChild};e.replaceChildren();let n=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);n.style.display=`block`;let r=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);return r.setAttribute(`fill`,`none`),n.appendChild(r),e.appendChild(n),{svg:n,path:r}}},Tr=class extends wr{_applyStraightLine(e,t,n,r,i,a,o){let s=o?i:r,c=o?r:i;e.setAttribute(`width`,String(s)),e.setAttribute(`height`,String(c)),n.style.width=`${s}px`,n.style.height=`${c}px`,t.setAttribute(`d`,o?`M ${a},0 L ${a},${r}`:`M 0,${a} L ${r},${a}`)}applyShape(e,t,n,r,i,a,o,s){let c=i,l=r,u=br(t.color,this._ctx.getColorPalette());if(l<=0||c<=0||u===void 0){e.style.display=`none`;return}e.style.display=``;let d;a&&t.panelIds.includes(a)&&(d=this._ctx.getTabMap().get(a));let{svg:f,path:p}=this.ensureSvgPath(e);p.setAttribute(`stroke`,u),p.setAttribute(`stroke-width`,`2`);let m=this._ctx.getHeaderPosition(),h=!s&&m===`bottom`,g=s&&m===`right`,_,v;if(s?(_=g?c-2:2,v=g?2:c-2):(_=h?2:c-2,v=h?c-2:2),!d){this._applyStraightLine(f,p,e,l,c,_,s);return}let y=d.value.element.getBoundingClientRect(),b,x;if(s?(b=Math.max(0,y.top-o.top-n),x=Math.min(l,y.bottom-o.top-n)):(b=Math.max(0,y.left-o.left-n),x=Math.min(l,y.right-o.left-n)),x<=b){this._applyStraightLine(f,p,e,l,c,_,s);return}let S=v>_?1:-1;if(s){let t=c,n=l;f.setAttribute(`width`,String(t)),f.setAttribute(`height`,String(n)),e.style.width=`${t}px`,e.style.height=`${n}px`;let r=[`M ${_},0`,`L ${_},${b-6}`,`Q ${_},${b} ${_+S*6},${b}`,`L ${v-S*6},${b}`,`Q ${v},${b} ${v},${b+6}`,`L ${v},${x-6}`,`Q ${v},${x} ${v-S*6},${x}`,`L ${_+S*6},${x}`,`Q ${_},${x} ${_},${x+6}`,`L ${_},${n}`].join(` `);p.setAttribute(`d`,r)}else{let t=l,n=c;f.setAttribute(`width`,String(t)),f.setAttribute(`height`,String(n)),e.style.width=`${t}px`,e.style.height=`${n}px`;let r=[`M 0,${_}`,`L ${b-6},${_}`,`Q ${b},${_} ${b},${_+S*6}`,`L ${b},${v-S*6}`,`Q ${b},${v} ${b+6},${v}`,`L ${x-6},${v}`,`Q ${x},${v} ${x},${v-S*6}`,`L ${x},${_+S*6}`,`Q ${x},${_} ${x+6},${_}`,`L ${t},${_}`].join(` `);p.setAttribute(`d`,r)}}},Er=class extends wr{applyShape(e,t,n,r,i,a,o,s){let c=br(t.color,this._ctx.getColorPalette());if(r<=0||c===void 0){e.style.display=`none`;return}e.style.display=``,e.firstElementChild&&e.replaceChildren(),e.style.backgroundColor=c,s?(e.style.width=`2px`,e.style.height=`${r}px`):(e.style.width=`${r}px`,e.style.height=`2px`)}},Dr=new Map,Or=class{get chipRenderers(){return this._chipRenderers}get groupUnderlines(){return this._indicator?.underlines??Dr}get skipNextCollapseAnimation(){return this._skipNextCollapseAnimation}set skipNextCollapseAnimation(e){this._skipNextCollapseAnimation=e}constructor(e,t){this._ctx=e,this._callbacks=t,this._chipRenderers=new Map,this._indicator=null,this._skipNextCollapseAnimation=!1,this._pendingTransitionCleanups=new Map}update(){let e=this._ctx.group.model.getTabGroups(),t=new Set;for(let n of e)t.add(n.id),this._ensureChipForGroup(n),this._positionChipForGroup(n);for(let[e,r]of this._chipRenderers)if(!t.has(e)){var n;r.chip.element.remove(),r.chip.dispose(),(n=r.dragSourcesDisposable)==null||n.dispose(),r.disposable.dispose(),this._chipRenderers.delete(e)}this._updateTabGroupClasses()}refreshAccents(){for(let n of this._ctx.group.model.getTabGroups()){var e,t;let r=this._chipRenderers.get(n.id);r==null||(t=(e=r.chip).update)==null||t.call(e,{tabGroup:n})}this._updateTabGroupClasses()}positionAllChips(){if(this._chipRenderers.size!==0)for(let e of this._ctx.group.model.getTabGroups())this._positionChipForGroup(e)}updateDirection(){let e=this._ctx.getDirection()===`vertical`;for(let[,t]of this._chipRenderers)t.dropTarget.setTargetZones(e?[`top`]:[`left`])}snapshotChipWidths(){let e=new Map;for(let[t,n]of this._chipRenderers)e.set(t,n.chip.element.getBoundingClientRect().width);return e}positionUnderlines(){var e;(e=this._indicator)==null||e.positionUnderlines()}trackUnderlines(){var e;(e=this._indicator)==null||e.trackUnderlines()}setGroupDragImage(e,t,n){if(!e.dataTransfer)return;let r=this._ctx.getDirection()===`vertical`,i=this._ctx.tabsList.cloneNode(!0);r?(i.classList.remove(`dv-tabs-container-vertical`,`dv-vertical`),i.classList.add(`dv-horizontal`),i.style.writingMode=`horizontal-tb`,i.style.height=`${this._ctx.tabsList.offsetWidth}px`):i.style.height=`${this._ctx.tabsList.offsetHeight}px`,i.style.width=`auto`,i.style.overflow=`visible`,i.style.pointerEvents=`none`;let a=Array.from(i.children),o=Array.from(this._ctx.tabsList.children);for(let e=a.length-1;e>=0;e--)o[e]!==n&&a[e].remove();let s=document.createElement(`div`);s.className=`dv-groupview dv-active-group`,s.style.position=`fixed`,s.style.top=`-10000px`,s.style.left=`0px`,s.style.height=`auto`,s.style.width=`auto`,s.style.pointerEvents=`none`;let c=document.createElement(`div`);c.className=`dv-tabs-and-actions-container`,c.style.height=`auto`,c.style.width=`auto`,s.appendChild(c),c.appendChild(i),this._ctx.accessor.element.appendChild(s);let l=i.querySelector(`.dv-tab-group-chip`),u=n.getBoundingClientRect(),d=e.clientX-u.left,f=e.clientY-u.top;if(l){let t=l.getBoundingClientRect(),n=s.getBoundingClientRect(),r=t.left-n.left+d,i=t.top-n.top+f;e.dataTransfer.setDragImage(s,r,i)}else e.dataTransfer.setDragImage(s,d,f);requestAnimationFrame(()=>{s.remove()})}cleanupTransition(e){var t;(t=this._pendingTransitionCleanups.get(e))==null||t(),this._pendingTransitionCleanups.delete(e)}updateDragAndDropState(){let e=Qn(this._ctx.accessor.options);for(let i of this._chipRenderers.values()){var t,n,r;i.chip.element.draggable=e.html5,(t=i.html5DragSource)==null||t.setDisabled(!e.html5),(n=i.pointerDragSource)==null||n.setDisabled(!e.pointer),(r=i.pointerDragSource)==null||r.setTouchOnly(!e.pointerHandlesMouse)}}disposeChipDrag(e){var t;let n=this._chipRenderers.get(e);n&&((t=n.dragSourcesDisposable)==null||t.dispose(),n.html5DragSource=void 0,n.pointerDragSource=void 0,n.dragSourcesDisposable=void 0)}_buildChipGhostElement(e){let t=getComputedStyle(e),n=e.cloneNode(!0);return Array.from(t).forEach(e=>{n.style.setProperty(e,t.getPropertyValue(e),t.getPropertyPriority(e))}),n.style.position=`absolute`,n}disposeAll(){var e;(e=this._indicator)==null||e.dispose(),this._indicator=null;for(let[,e]of this._pendingTransitionCleanups)e();this._pendingTransitionCleanups.clear();for(let[,e]of this._chipRenderers){var t;e.chip.element.remove(),e.chip.dispose(),(t=e.dragSourcesDisposable)==null||t.dispose(),e.disposable.dispose()}this._chipRenderers.clear()}_ensureIndicator(){let e=(this._ctx.accessor.options.theme?.tabGroupIndicator??`wrap`)===`none`?Er:Tr;this._indicator&&!(this._indicator instanceof e)&&(this._indicator.dispose(),this._indicator=null),this._indicator??=new e({tabsList:this._ctx.tabsList,getTabGroups:()=>this._ctx.group.model.getTabGroups(),getActivePanelId:()=>this._ctx.group.activePanel?.id,getTabMap:()=>this._ctx.getTabMap(),getChipElement:e=>this._chipRenderers.get(e)?.chip.element,getDirection:()=>this._ctx.getDirection(),getHeaderPosition:()=>this._ctx.group.model.headerPosition,getColorPalette:()=>this._ctx.accessor.tabGroupColorPalette})}_createChipDragSources(e,t){let n=Qn(this._ctx.accessor.options);e.element.draggable=n.html5;let r=Ie.getInstance(),i=()=>(r.setData([new Fe(this._ctx.accessor.id,this._ctx.group.id,null,t.id)],Fe.prototype),{dispose:()=>{r.clearData(Fe.prototype)}}),a=Ln.createDragSource(e.element,{getData:i,disabled:!n.html5,isCancelled:()=>!Qn(this._ctx.accessor.options).html5,onDragStart:n=>{`dataTransfer`in n&&n.dataTransfer&&this.setGroupDragImage(n,t,e.element),this._callbacks.onChipDragStart(t,e,n)},onDragEnd:n=>{var r,i;(r=(i=this._callbacks).onChipDragEnd)==null||r.call(i,t,e,n)}}),o=()=>{r.clearData(Fe.prototype)};e.element.addEventListener(`dragend`,o,{once:!0});let s=Rn.createDragSource(e.element,{getData:i,disabled:!n.pointer,touchOnly:!n.pointerHandlesMouse,isCancelled:()=>!Qn(this._ctx.accessor.options).pointer,createGhost:()=>({element:this._buildChipGhostElement(e.element),offsetX:8,offsetY:8}),onDragStart:n=>{this._callbacks.onChipDragStart(t,e,n)}});return{html5DragSource:a,pointerDragSource:s,disposable:{dispose:()=>{a.dispose(),s.dispose(),e.element.removeEventListener(`dragend`,o)}}}}_ensureChipForGroup(e){let t=this._chipRenderers.get(e.id);if(t){if(!t.html5DragSource){let n=this._createChipDragSources(t.chip,e);t.html5DragSource=n.html5DragSource,t.pointerDragSource=n.pointerDragSource,t.dragSourcesDisposable=n.disposable}return}let n=this._ctx.accessor.options.createTabGroupChipComponent,r=n?n(e):new xr(this._ctx.accessor.tabGroupColorPalette);r.init({tabGroup:e,api:this._ctx.accessor.api});let i=this._createChipDragSources(r,e),a=[e.onDidChange(()=>{var t;(t=r.update)==null||t.call(r,{tabGroup:e}),this._updateTabGroupClasses()}),e.onDidPanelChange(()=>{this._positionChipForGroup(e),this._updateTabGroupClasses()}),e.onDidCollapseChange(()=>{this._updateTabGroupClasses()})],o=t=>{var n;(n=this._chipRenderers.get(e.id))==null||(n=n.pointerDragSource)==null||n.cancelPending(),this._callbacks.onChipContextMenu(e,t)};r instanceof xr?a.push(r.onContextMenu(o)):a.push(new Zn(r.element,{onLongPress:o}),Q(r.element,`contextmenu`,o));let s=this._ctx.getDirection()===`vertical`,c=new Sn(r.element,{acceptedTargetZones:s?[`top`]:[`left`],overlayModel:{activationSize:{value:100,type:`percentage`}},canDisplayOverlay:(e,t)=>{if(this._ctx.group.locked||this._ctx.accessor.options.disableDnd)return!1;let n=Le();return this._ctx.accessor.id===n?.viewId?this._ctx.accessor.options.theme?.tabAnimation!==`smooth`:this._ctx.group.model.canDisplayOverlay(e,t,`tab`)}});a.push(c,c.onDrop(t=>{this._callbacks.onChipDrop(e,t)}));let l=new ze(...a);this._chipRenderers.set(e.id,{chip:r,html5DragSource:i.html5DragSource,pointerDragSource:i.pointerDragSource,dragSourcesDisposable:i.disposable,disposable:l,dropTarget:c}),e.collapsed&&(this._skipNextCollapseAnimation=!0)}_positionChipForGroup(e){let t=this._chipRenderers.get(e.id);if(!t)return;let n=t.chip.element,r=e.panelIds;if(r.length===0){n.remove();return}let i=r[0],a=this._ctx.getTabMap().get(i);if(!a){n.remove();return}let o=a.value.element;n.nextSibling!==o&&this._ctx.tabsList.insertBefore(n,o)}_updateTabGroupClasses(){let e=this._ctx.group.model.getTabGroups(),t=this._ctx.getTabs(),n=this._ctx.getTabMap(),r=!1,i=new Map;for(let t of e)for(let e of t.panelIds)i.set(e,t);for(let e of t){let t=e.value,n=t.panel.id,o=i.get(n),s=!!o;if($(t.element,`dv-tab--grouped`,s),o){let e=o.panelIds,i=e[0]===n,s=e[e.length-1]===n;$(t.element,`dv-tab--group-first`,i),$(t.element,`dv-tab--group-last`,s),yr(t.element,o.color,this._ctx.accessor.tabGroupColorPalette);let c=t.element.classList.contains(`dv-tab--group-collapsed`);if(!o.collapsed&&c){var a;r=!0,t.element.classList.remove(`dv-tab--group-collapsed`),t.element.classList.add(`dv-tab--group-expanding`),(a=this._pendingTransitionCleanups.get(n))==null||a();let e=()=>{t.element.classList.remove(`dv-tab--group-expanding`),t.element.style.removeProperty(`width`),t.element.removeEventListener(`transitionend`,e),clearTimeout(i),this._pendingTransitionCleanups.delete(n)},i=setTimeout(e,300);this._pendingTransitionCleanups.set(n,e),t.element.addEventListener(`transitionend`,e)}}else $(t.element,`dv-tab--group-first`,!1),$(t.element,`dv-tab--group-last`,!1),t.element.classList.remove(`dv-tab--group-collapsed`,`dv-tab--group-expanding`),t.element.style.removeProperty(`width`),t.element.style.removeProperty(`--dv-tab-group-color`)}let o=new Set;for(let t of e)if(o.add(t.id),t.collapsed&&t.panelIds.some(e=>{let t=n.get(e);return t&&!t.value.element.classList.contains(`dv-tab--group-collapsed`)})){if(this._skipNextCollapseAnimation){let e=[];for(let r of t.panelIds){let t=n.get(r);t&&(t.value.element.style.transition=`none`,t.value.element.classList.add(`dv-tab--group-collapsed`),e.push(t.value.element))}if(e.length>0){e[0].offsetHeight;for(let t of e)t.style.removeProperty(`transition`)}}else{r=!0;let e=this._ctx.getDirection()===`vertical`;for(let r of t.panelIds){let t=n.get(r);if(t&&!t.value.element.classList.contains(`dv-tab--group-collapsed`)){let n=t.value.element.getBoundingClientRect();e?t.value.element.style.height=`${n.height}px`:t.value.element.style.width=`${n.width}px`,t.value.element.offsetHeight,t.value.element.classList.add(`dv-tab--group-collapsed`)}}}}this._skipNextCollapseAnimation=!1,this._ensureIndicator(),this._indicator&&(this._indicator.syncUnderlineElements(o),r?this._indicator.trackUnderlines():this._indicator.positionUnderlines())}},kr=class extends ze{get _tabs(){return this.host.tabItems}get _tabMap(){return this.host.tabMap}get _tabsList(){return this.host.tabsList}get _direction(){return this.host.direction}get group(){return this.host.groupPanel}get accessor(){return this.host.component}get _tabGroupManager(){return this.host.tabGroupManager}get _wrapMode(){return this._tabsList.classList.contains(sr)}get animState(){return this._animState}set animState(e){this._animState=e}get pendingCollapse(){return this._pendingCollapse}set pendingCollapse(e){this._pendingCollapse=e}set voidContainerElement(e){this._voidContainer=e}constructor(e){super(),this.host=e,this._animState=null,this._pendingMarginCleanups=new Map,this._pendingCollapse=!1,this._flipTransitionCleanup=null,this._voidContainer=null,this._extendedDropZone=null,this._pointerInsideTabsList=!1,this._wrapIndicatorEl=null,this.addDisposables({dispose:()=>{var e;(e=this._flipTransitionCleanup)==null||e.call(this)}})}setExtendedDropZone(e){this._extendedDropZone=e}setExternalInsertionIndex(e){this._animState&&e!==this._animState.currentInsertionIndex&&(this._animState.currentInsertionIndex=e,this.applyDragOverTransforms())}clearExternalAnimState(){this._animState&&(this.resetTabTransforms(),this._animState.sourceIndex===-1?this._animState=null:this._animState.currentInsertionIndex=null)}snapshotTabPositions(){let e=new Map;for(let t of this._tabs)e.set(t.value.panel.id,t.value.element.getBoundingClientRect());return e}getAverageTabWidth(){if(this._tabs.length===0)return 0;let e=this._direction===`vertical`,t=0;for(let n of this._tabs){let r=n.value.element.getBoundingClientRect();t+=e?r.height:r.width}return t/this._tabs.length}handlePointerDragMove(e,t){let n=(this._tabsList.ownerDocument??document).elementFromPoint(e,t);if(!(n&&(this._tabsList.contains(n)||this._extendedDropZone&&this._extendedDropZone.contains(n)))){this._pointerInsideTabsList&&(this._pointerInsideTabsList=!1,this.processDragLeave(n));return}this._pointerInsideTabsList=!0,this.processDragOver(e,t)}handlePointerDragEnd(e){e&&this._animState&&this._animState.sourceIndex!==-1&&!this._animState.sourceTabGroupId&&this._animState.currentInsertionIndex!==null&&this.isPointInsideTabsList(e.clientX,e.clientY)&&this.commitPointerReorder(e.pointerEvent),this._pointerInsideTabsList=!1,this.resetDragAnimation()}isPointInsideTabsList(e,t){let n=(this._tabsList.ownerDocument??document).elementFromPoint(e,t);return!!n&&this._tabsList.contains(n)}commitPointerReorder(e){let t=this._animState;if(t?.currentInsertionIndex==null)return;let n=t.currentInsertionIndex,r=t.sourceIndex,i=n-+(r!==-1&&r<n);this._animState=null,this.clearWrapDropIndicator(),this.uncollapseSourceTab(t.sourceTabId),i!==r&&this.host.fireDrop({event:e,index:i,targetTabGroupId:null})}processDragOver(e,t){if(this.accessor.options.disableDnd||(this._dropStaleAnimState(),!this._animState&&!this._initAnimStateForExternalDrag()))return!1;if(this._animState.sourceIndex!==-1){var n;(n=this.group.model.dropTargetContainer)==null||(n=n.model)==null||n.clear()}return this.handleDragOver({clientX:e,clientY:t}),!0}_dropStaleAnimState(){if(!this._animState)return;let e=Le();e?.tabGroupId&&e.groupId!==this.group.id&&this._animState.sourceTabGroupId!==e.tabGroupId&&(this._animState=null)}_initAnimStateForExternalDrag(){let e=Le();if(this.accessor.options.theme?.tabAnimation==="default"&&!e?.tabGroupId||!e||!(e.panelId||e.tabGroupId)||e.groupId===this.group.id)return!1;let t=this.getAverageTabWidth();return this._animState=e.tabGroupId?this._makeGroupDragAnimState(e,t):this._makeTabDragAnimState(e,t),!0}_makeGroupDragAnimState(e,t){let n=this.accessor.getPanel(e.groupId)?.model.getTabGroups().find(t=>t.id===e.tabGroupId),r=t*(n?.panelIds.length??1)+t;return{sourceTabId:``,sourceIndex:-1,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:e.tabGroupId,sourceGroupPanelIds:n?new Set(n.panelIds):new Set,sourceChipWidth:t,cursorOffsetFromDragLeft:r/2,sourceGapWidth:r,containerLeft:this._tabsList.getBoundingClientRect().left}}_makeTabDragAnimState(e,t){return{sourceTabId:e.panelId,sourceIndex:-1,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:null,sourceGroupPanelIds:null,sourceChipWidth:0,cursorOffsetFromDragLeft:t/2,sourceGapWidth:t,containerLeft:this._tabsList.getBoundingClientRect().left}}processDragLeave(e){if(this._animState&&!(e&&this._tabsList.contains(e))){if(e&&this._extendedDropZone?.contains(e)){this.resetTabTransforms(),this._animState.currentInsertionIndex=null;return}if(!(this._voidContainer&&e&&(e===this._voidContainer||this._voidContainer.contains(e)))){if(this.resetTabTransforms(),this._animState.sourceIndex===-1){var t;(t=this.group.model.dropTargetContainer)==null||(t=t.model)==null||t.clear(),this._animState=null}else this._animState.currentInsertionIndex=null}}}handleDragOver(e){if(!this._animState)return;if(this._wrapMode&&!this._animState.sourceTabGroupId){this.handleWrappedDragOver(e.clientX,e.clientY??0);return}let t=e.clientX,n=this._buildFirstPanelToGroupMap(),r=this._computeDragOverInsertionIndex(t,n),i=null;if(r!==null&&this._tabGroupManager.chipRenderers.size>0){let e=this._resolveInsertionAgainstTabGroups(t,r,n);r=e.insertionIndex,i=e.targetTabGroupId}(r!==this._animState.currentInsertionIndex||i!==this._animState.targetTabGroupId)&&(this._animState.currentInsertionIndex=r,this._animState.targetTabGroupId=i,this.accessor.options.theme?.tabAnimation===`smooth`&&this.applyDragOverTransforms())}_buildFirstPanelToGroupMap(){let e=new Map;if(this._tabGroupManager.chipRenderers.size===0)return e;for(let t of this.group.model.getTabGroups())t.id!==this._animState.sourceTabGroupId&&t.panelIds.length>0&&e.set(t.panelIds[0],t.id);return e}_computeDragOverInsertionIndex(e,t){let n=this._animState,r=n.sourceGroupPanelIds,i=e-n.cursorOffsetFromDragLeft-n.containerLeft,a=0,o=null;for(let e=0;e<this._tabs.length;e++){let s=this._tabs[e].value;if(s.panel.id===n.sourceTabId||r?.has(s.panel.id))continue;let c=t.get(s.panel.id);if(c){let t=n.chipPositions.get(c)??0;if(a+t>i){o??=e;break}a+=t}let l=n.tabPositions.get(s.panel.id),u=l?l.width:s.element.getBoundingClientRect().width;if(a+u/2<=i)a+=u,o=e+1;else{o??=e;break}}return o}_accumulatedWidthUpTo(e,t){let n=this._animState,r=n.sourceGroupPanelIds,i=0;for(let a=0;a<this._tabs.length;a++){let o=this._tabs[a].value;if(o.panel.id===n.sourceTabId||r?.has(o.panel.id))continue;if(a>=e)break;let s=t.get(o.panel.id);s&&(i+=n.chipPositions.get(s)??0);let c=n.tabPositions.get(o.panel.id);i+=c?c.width:o.element.getBoundingClientRect().width}return i}_resolveInsertionAgainstTabGroups(e,t,n){let r=!!this._animState.sourceTabGroupId,i=this._accumulatedWidthUpTo(t,n);for(let n of this.group.model.getTabGroups()){let a=this._evaluateTabGroupForInsertion(n,e,t,i,r);if(a)return a}return{insertionIndex:t,targetTabGroupId:null}}_evaluateTabGroupForInsertion(e,t,n,r,i){let a=this._resolveGroupRange(e);if(!a)return null;let{firstIdx:o,lastIdx:s}=a,c=n>=o&&n<=s,l=!c&&n===o-1;return!c&&!l?null:i?this._resolveGroupDragTarget(n,o,s,c):this._resolveTabDragTarget(e,t,n,r,o,l)}_resolveGroupRange(e){let t=this._animState,n=t.sourceGroupPanelIds,r=e.panelIds.filter(e=>e!==t.sourceTabId&&!n?.has(e));if(r.length===0)return null;let i=this._tabs.findIndex(e=>e.value.panel.id===r[0]),a=this._tabs.findIndex(e=>e.value.panel.id===r[r.length-1]);return i===-1||a===-1?null:{firstIdx:i,lastIdx:a}}_resolveGroupDragTarget(e,t,n,r){return r?{insertionIndex:e<(t+n+1)/2?t:n+1,targetTabGroupId:null}:{insertionIndex:e,targetTabGroupId:null}}_resolveTabDragTarget(e,t,n,r,i,a){let o=this._animState,s=o.chipPositions.get(e.id)??0;if(a)return this._onlySourceBetween(n,i)?t>=(e.collapsed?o.containerLeft+r+s/2:o.containerLeft+r+s)?{insertionIndex:i,targetTabGroupId:e.id}:{insertionIndex:n,targetTabGroupId:null}:null;let c=o.containerLeft+r+s;return n===i?{insertionIndex:n,targetTabGroupId:t>=c?e.id:null}:{insertionIndex:n,targetTabGroupId:e.id}}_onlySourceBetween(e,t){let n=this._animState;for(let r=e;r<t;r++){let e=this._tabs[r].value.panel.id;if(e!==n.sourceTabId&&!n.sourceGroupPanelIds?.has(e))return!1}return!0}handleWrappedDragOver(e,t){if(!this._animState)return;let n=this.computeWrappedInsertionIndex(e,t);(n!==this._animState.currentInsertionIndex||this._animState.targetTabGroupId!==null)&&(this._animState.currentInsertionIndex=n,this._animState.targetTabGroupId=null,this.updateWrapDropIndicator(n))}computeWrappedInsertionIndex(e,t){let n=this._direction===`vertical`,r=this._wrappedDragEntries();if(r.length===0)return this._tabs.length;let i=n?e:t,a=n?t:e,o=e=>n?e.left:e.top,s=e=>n?e.right:e.bottom,c=e=>n?e.top:e.left,l=e=>n?e.height:e.width,u=this._bucketWrappedLines(r,o,s),d=[...(u.find(e=>i>=e.start&&i<=e.end)??this._nearestWrappedLine(u,i)).items].sort((e,t)=>c(e.rect)-c(t.rect));for(let e of d)if(a<c(e.rect)+l(e.rect)/2)return e.index;return d[d.length-1].index+1}_wrappedDragEntries(){let e=this._animState?.sourceTabId,t=this._animState?.sourceGroupPanelIds,n=[];for(let r=0;r<this._tabs.length;r++){let i=this._tabs[r].value;i.panel.id!==e&&(t?.has(i.panel.id)||n.push({index:r,rect:i.element.getBoundingClientRect()}))}return n}_bucketWrappedLines(e,t,n){let r=[];for(let i of e){let e=t(i.rect),a=r.find(t=>Math.abs(t.start-e)<=2);a?(a.items.push(i),a.end=Math.max(a.end,n(i.rect))):r.push({start:e,end:n(i.rect),items:[i]})}return r.sort((e,t)=>e.start-t.start),r}_nearestWrappedLine(e,t){let n=e=>t<e.start?e.start-t:t-e.end;return e.reduce((e,t)=>n(t)<n(e)?t:e,e[0])}updateWrapDropIndicator(e){this.clearWrapDropIndicator();let t=this._tabs.length;if(t===0)return;let n=this._animState?.sourceTabId;if(e<t){let t=this._tabs[e].value.element;if(this._tabs[e].value.panel.id===n)return;t.classList.add(`dv-tab--reorder-before`),this._wrapIndicatorEl=t}else{let e=this._tabs[t-1].value.element;e.classList.add(`dv-tab--reorder-after`),this._wrapIndicatorEl=e}}clearWrapDropIndicator(){var e;(e=this._wrapIndicatorEl)==null||e.classList.remove(`dv-tab--reorder-before`,`dv-tab--reorder-after`),this._wrapIndicatorEl=null}_removeClassInstantlyBatch(e,t){let n=[];for(let r of e)r.classList.contains(t)&&(r.style.transition=`none`,$(r,t,!1),n.push(r));if(n.length>0){n[0].getBoundingClientRect();for(let e of n)e.style.removeProperty(`transition`)}}uncollapseSourceTab(e){let t=this._tabMap.get(e);t&&this._removeClassInstantlyBatch([t.value.element],`dv-tab--dragging`)}applyDragOverTransforms(e=!1){if(this._wrapMode)return;if(this._animState?.currentInsertionIndex==null){this.resetTabTransforms();return}if(this._pendingCollapse)return;let t=this._animState.currentInsertionIndex,n=this._computeGapWidth(),r=this._computeChipToShift(t);this._applyGapMargins(t,n,r,e)}_computeGapWidth(){let e=this._animState;if(e.sourceTabGroupId&&e.sourceGroupPanelIds)return e.sourceGapWidth;let t=e.tabPositions.get(e.sourceTabId);return t?t.width:this.getAverageTabWidth()}_computeChipToShift(e){if(this._tabGroupManager.chipRenderers.size===0)return null;for(let t of this.group.model.getTabGroups()){let n=this._chipToShiftForGroup(t,e);if(n!==void 0)return n}return null}_chipToShiftForGroup(e,t){let n=this._animState;if(e.id===n.sourceTabGroupId||e.panelIds.includes(n.sourceTabId))return;let r=e.panelIds.filter(e=>e!==n.sourceTabId&&!n.sourceGroupPanelIds?.has(e));if(r.length===0)return;let i=this._tabs.findIndex(e=>e.value.panel.id===r[0]);if((!n.targetTabGroupId||n.targetTabGroupId===e.id&&e.collapsed)&&!(i<t)){if(this._onlySourceBetween(t,i)){let t=this._tabGroupManager.chipRenderers.get(e.id);if(t)return t.chip.element}return null}}_applyGapMargins(e,t,n,r){let i=this._animState,a=i.sourceGroupPanelIds,o=!1;for(let[e,t]of this._tabGroupManager.chipRenderers)e!==i.sourceTabGroupId&&this._clearMargin(t.chip.element,r);n&&(this._setMargin(n,`${t}px`,r),o=!0);for(let n=0;n<this._tabs.length;n++){let s=this._tabs[n].value;s.panel.id!==i.sourceTabId&&(a?.has(s.panel.id)||(!o&&n>=e?(this._setMargin(s.element,`${t}px`,r),o=!0):this._clearMargin(s.element,r)))}this._tabGroupManager.trackUnderlines()}_shiftingClass(e){return e.classList.contains(`dv-tab-group-chip`)?`dv-tab-group-chip--shifting`:`dv-tab--shifting`}_setMargin(e,t,n){n?(e.style.transition=`none`,e.style.marginLeft=t,e.getBoundingClientRect(),e.style.removeProperty(`transition`)):e.style.marginLeft=t,$(e,this._shiftingClass(e),!0)}_clearMargin(e,t){let n=this._shiftingClass(e),r=this._pendingMarginCleanups.get(e);if(r&&r(),t||!e.style.marginLeft)e.style.removeProperty(`margin-left`),$(e,n,!1);else{e.style.marginLeft=`0px`,$(e,n,!0);let t=()=>{e.style.removeProperty(`margin-left`),$(e,n,!1),e.removeEventListener(`transitionend`,t),clearTimeout(r),this._pendingMarginCleanups.delete(e)},r=setTimeout(t,300);this._pendingMarginCleanups.set(e,t),e.addEventListener(`transitionend`,t)}}resetTabTransforms(){this.clearWrapDropIndicator();for(let[,e]of this._pendingMarginCleanups)e();this._pendingMarginCleanups.clear();for(let e of this._tabs)e.value.element.style.removeProperty(`margin-left`),e.value.element.style.removeProperty(`margin-right`),e.value.element.style.removeProperty(`margin-top`),e.value.element.style.removeProperty(`margin-bottom`),e.value.element.style.removeProperty(`transform`),$(e.value.element,`dv-tab--shifting`,!1);for(let[,e]of this._tabGroupManager.chipRenderers)e.chip.element.style.removeProperty(`margin-left`),$(e.chip.element,`dv-tab-group-chip--shifting`,!1);this._tabGroupManager.positionUnderlines()}commitGroupMove(e,t){let n=Le();if(this._tabGroupManager.disposeChipDrag(e),this.group.model.getTabGroups().some(t=>t.id===e)){if(this.accessor.options.theme?.tabAnimation===`smooth`){this._clearGroupDragClasses(e);let n=this.snapshotTabPositions();this.resetTabTransforms(),this.group.model.moveTabGroup(e,t),this.runFlipAnimation(n,``,!1)}else this._tabGroupManager.skipNextCollapseAnimation=!0,this.group.model.moveTabGroup(e,t)}else n&&(this.resetTabTransforms(),this.accessor.moveGroupOrPanel({from:{groupId:n.groupId,tabGroupId:n.tabGroupId??e},to:{group:this.group,position:`center`,index:t}}))}_clearGroupDragClasses(e){let t=this._tabGroupManager.chipRenderers.get(e);t&&this._removeClassInstantlyBatch([t.chip.element],`dv-tab-group-chip--dragging`),this._removeClassInstantlyBatch(this._tabs.map(e=>e.value.element),`dv-tab--dragging`);let n=this._tabGroupManager.groupUnderlines.get(e);n&&n.style.removeProperty(`display`),this._tabGroupManager.skipNextCollapseAnimation=!0}resetDragAnimation(){if(this._pendingCollapse=!1,this._animState){this.resetTabTransforms(),this._animState.sourceTabGroupId?this._clearGroupDragClasses(this._animState.sourceTabGroupId):this._removeClassInstantlyBatch(this._tabs.map(e=>e.value.element),`dv-tab--dragging`),this._animState=null;for(let[,e]of this._tabGroupManager.groupUnderlines)e.style.removeProperty(`display`)}}runFlipAnimation(e,t,n=!1,r){if(this._wrapMode)return;let i=!1;for(let a=0;a<this._tabs.length;a++)this._applyFlipTransform(this._tabs[a],a,t,n,e,r)&&(i=!0);i&&this._scheduleFlipReset()}_applyFlipTransform(e,t,n,r,i,a){let o=this._direction===`vertical`,s=e.value.panel.id;if(s===n){if(!r)return!1;let t=e.value.element.getBoundingClientRect();return e.value.element.style.transform=o?`translateY(${t.height}px)`:`translateX(${t.width}px)`,$(e.value.element,`dv-tab--shifting`,!0),!0}if(a!==void 0&&(t<a.from||t>a.to))return!1;let c=i.get(s);if(!c)return!1;let l=e.value.element.getBoundingClientRect(),u=o?c.top-l.top:c.left-l.left;return Math.abs(u)<1?!1:(e.value.element.style.transform=o?`translateY(${u}px)`:`translateX(${u}px)`,$(e.value.element,`dv-tab--shifting`,!0),!0)}_scheduleFlipReset(){requestAnimationFrame(()=>{var e;for(let e of this._tabs)e.value.element.style.transform&&(e.value.element.style.transform=``);this._tabGroupManager.trackUnderlines(),(e=this._flipTransitionCleanup)==null||e.call(this);let t=e=>{if(e.propertyName===`transform`){n();for(let e of this._tabs)$(e.value.element,`dv-tab--shifting`,!1);this._tabGroupManager.positionUnderlines()}},n=()=>{this._tabsList.removeEventListener(`transitionend`,t),this._flipTransitionCleanup=null};this._flipTransitionCleanup=n,this._tabsList.addEventListener(`transitionend`,t)})}},Ar=class extends ze{get _animState(){return this._reorder.animState}set _animState(e){this._reorder.animState=e}get _pendingCollapse(){return this._reorder.pendingCollapse}set _pendingCollapse(e){this._reorder.pendingCollapse=e}get tabItems(){return this._tabs}get tabMap(){return this._tabMap}get tabsList(){return this._tabsList}get groupPanel(){return this.group}get component(){return this.accessor}get tabGroupManager(){return this._tabGroupManager}fireDrop(e){this._onDrop.fire(e)}setOverflowExclude(e){this._overflowExclude=e,this.refreshOverflow()}setForcedOverflow(e){this._forcedOverflow=e,this.refreshOverflow()}refreshOverflow(){this._showTabsOverflowControl&&this.toggleDropdown({reset:!1}),this._applyPinnedSticky()}setPinnedSticky(e){this._pinnedSticky!==e&&(this._pinnedSticky=e,this._applyPinnedSticky())}_applyPinnedSticky(){let e=this._pinnedSticky?this._tabs.filter(e=>this._overflowExclude(e.value.panel.id)):[];if(e.length===0&&!this._hasPinnedStickyStyling)return;for(let e of this._tabs){let t=e.value.element;t.classList.contains(`dv-tab--pinned-sticky`)&&(t.classList.remove(`dv-tab--pinned-sticky`),t.style.removeProperty(`--dv-pinned-sticky-left`))}if(e.length===0){this._hasPinnedStickyStyling=!1;return}let t=e.map(e=>e.value.element.offsetLeft);e.forEach((e,n)=>{let r=e.value.element;r.classList.add(`dv-tab--pinned-sticky`),r.style.setProperty(`--dv-pinned-sticky-left`,`${t[n]}px`)}),this._hasPinnedStickyStyling=!0}get showTabsOverflowControl(){return this._showTabsOverflowControl}set showTabsOverflowControl(e){if(this._showTabsOverflowControl!=e){if(this._showTabsOverflowControl=e,e){let e=new Je(this._tabsList);this._observerDisposable.value=new ze(e,e.onDidChange(e=>{let t=e.hasScrollX||e.hasScrollY;this.toggleDropdown({reset:!t}),this._applyPinnedSticky(),this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}),Q(this._tabsList,`scroll`,()=>{this.toggleDropdown({reset:!1}),this._applyPinnedSticky(),this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}))}else this._observerDisposable.value=Re.NONE}}get element(){return this._element}get tabsListElement(){return this._tabsList}set voidContainer(e){var t;(t=this._voidContainerListeners)==null||t.dispose(),this._voidContainerListeners=null,this._reorder.voidContainerElement=e,e&&(this._voidContainerListeners=new ze(Q(e,`dragover`,e=>{this._animState&&e.preventDefault()}),Q(e,`drop`,e=>{this._animState?.sourceTabGroupId&&this._animState.currentInsertionIndex!==null&&(e.preventDefault(),e.stopPropagation(),this.handleVoidDrop())})))}handleVoidDrop(){if(!this._animState?.sourceTabGroupId)return!1;let e=this._animState.sourceTabGroupId,t=this._animState.currentInsertionIndex??this._tabs.length;return this._animState=null,this._commitGroupMove(e,t),!0}get panels(){return this._tabs.map(e=>e.value.panel.id)}get size(){return this._tabs.length}get tabs(){return this._tabs.map(e=>e.value)}get direction(){return this._direction}set direction(e){if(this._direction!==e){this._direction=e,this._tabsList.setAttribute(`aria-orientation`,e===`vertical`?`vertical`:`horizontal`),this._scrollbar&&(this._scrollbar.orientation=e),Xe(this._tabsList,`dv-horizontal`,`dv-vertical`),e===`vertical`?Ze(this._tabsList,`dv-tabs-container-vertical`,`dv-vertical`):(Xe(this._tabsList,`dv-tabs-container-vertical`),Ze(this._tabsList,`dv-horizontal`));for(let t of this._tabs)t.value.setDirection(e);this._tabGroupManager.updateDirection()}}constructor(e,t,n){super(),this.group=e,this.accessor=t,this._observerDisposable=new Be,this._pointerActivation=new Be,this._scrollbar=null,this._tabs=[],this._tabMap=new Map,this.selectedIndex=-1,this._showTabsOverflowControl=!1,this._overflowExclude=()=>!1,this._forcedOverflow=()=>!1,this._pinnedSticky=!1,this._hasPinnedStickyStyling=!1,this._direction=`horizontal`,this._voidContainerListeners=null,this._onTabDragStart=new Z,this.onTabDragStart=this._onTabDragStart.event,this._onDrop=new Z,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new Z,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onOverflowTabsChange=new Z,this.onOverflowTabsChange=this._onOverflowTabsChange.event,this._tabsList=document.createElement(`div`),this._tabsList.className=`dv-tabs-container`,this._tabsList.setAttribute(`role`,`tablist`),this._tabsList.setAttribute(`aria-orientation`,this._direction===`vertical`?`vertical`:`horizontal`),this.showTabsOverflowControl=n.showTabsOverflowControl,t.options.scrollbars===`native`?this._element=this._tabsList:(this._scrollbar=new or(this._tabsList),this._scrollbar.orientation=this.direction,this._element=this._scrollbar.element,this.addDisposables(this._scrollbar)),this._tabGroupManager=new Or({group:this.group,accessor:this.accessor,tabsList:this._tabsList,getTabs:()=>this._tabs,getTabMap:()=>this._tabMap,getDirection:()=>this._direction},{onChipContextMenu:(e,t)=>{var n;(n=this.accessor.contextMenuService)==null||n.showForChip(e,this.group,t)},onChipDragStart:(e,t,n)=>{this._handleChipDragStart(e,t,n)},onChipDragEnd:()=>{this._reorder.resetDragAnimation()},onChipDrop:(e,t)=>{this._handleChipDrop(e,t)}}),this._reorder=new kr(this),this.addDisposables(this._onOverflowTabsChange,this._observerDisposable,this._pointerActivation,this._onWillShowOverlay,this._onDrop,this._onTabDragStart,this._reorder,En.getInstance().onDragEnd(e=>{this._reorder.handlePointerDragEnd(e)}),En.getInstance().onDragMove(e=>{this._reorder.handlePointerDragMove(e.clientX,e.clientY)}),Q(this.element,`pointerdown`,e=>{e.defaultPrevented||e.button===0&&this.accessor.doSetGroupActive(this.group)}),Q(this._tabsList,`wheel`,e=>{let t=this._direction===`vertical`,n=t?e.deltaY||e.deltaX:e.deltaX||e.deltaY;if(n===0)return;let r=t?this._tabsList.scrollHeight-this._tabsList.clientHeight:this._tabsList.scrollWidth-this._tabsList.clientWidth;if(r<=0)return;let i=t?this._tabsList.scrollTop:this._tabsList.scrollLeft;n<0&&i<=0||n>0&&i>=r||(e.preventDefault(),e.stopPropagation(),t?this._tabsList.scrollTop=i+n:this._tabsList.scrollLeft=i+n)},{passive:!1}),Q(this._tabsList,`keydown`,e=>{this._onKeyDown(e)}),Q(this._tabsList,`dragover`,e=>{this._reorder.processDragOver(e.clientX,e.clientY)&&e.preventDefault()},!0),Q(this._tabsList,`dragleave`,e=>{this._reorder.processDragLeave(e.relatedTarget)},!0),Q(this._tabsList,`dragend`,()=>{this._reorder.resetDragAnimation()}),Q(this._tabsList,`drop`,e=>{var t;if(this._animState?.currentInsertionIndex==null||this.accessor.options.theme?.tabAnimation!==`smooth`&&!this._animState.sourceTabGroupId)return;e.stopPropagation(),e.preventDefault(),(t=this.group.model.dropTargetContainer)==null||(t=t.model)==null||t.clear();let n=this._animState;if(this._animState=null,this._pendingCollapse=!1,n.sourceTabGroupId){this._commitGroupMove(n.sourceTabGroupId,n.currentInsertionIndex);return}let r=n.currentInsertionIndex,i=n.sourceIndex,a=r-+(i!==-1&&i<r),o=this.group.model.getTabGroupForPanel(n.sourceTabId);if(a===i&&!n.targetTabGroupId&&!o){this._reorder.uncollapseSourceTab(n.sourceTabId),this.resetTabTransforms();return}this._reorder.uncollapseSourceTab(n.sourceTabId);let s=this.snapshotTabPositions();this.resetTabTransforms(),this._onDrop.fire({event:e,index:a,targetTabGroupId:n.targetTabGroupId}),this.runFlipAnimation(s,n.sourceTabId,n.sourceIndex===-1,{from:Math.min(i,a),to:Math.max(i,a)})},!0),Re.from(()=>{var e;(e=this._voidContainerListeners)==null||e.dispose(),this._reorder.resetDragAnimation(),this._tabGroupManager.disposeAll();for(let{value:e,disposable:t}of this._tabs)t.dispose(),e.dispose();this._tabs=[],this._tabMap.clear()}))}indexOf(e){return this._tabs.findIndex(t=>t.value.panel.id===e)}getTabId(e){return this._tabMap.get(e)?.value.element.id}getPanelForTab(e){for(let{value:t}of this._tabs)if(t.element===e||t.element.contains(e))return t.panel}isActive(e){return this.selectedIndex>-1&&this._tabs[this.selectedIndex].value===e}_onKeyDown(e){let t=this._tabs.findIndex(t=>t.value.element===e.target);if(t===-1)return;let n=this._direction===`vertical`,r=n?`ArrowDown`:`ArrowRight`,i=n?`ArrowUp`:`ArrowLeft`,a=this._tabs.length-1;switch(e.key){case r:e.preventDefault(),this._focusTab(Math.min(t+1,a));break;case i:e.preventDefault(),this._focusTab(Math.max(t-1,0));break;case`Home`:e.preventDefault(),this._focusTab(0);break;case`End`:e.preventDefault(),this._focusTab(a);break;case`Enter`:case` `:e.preventDefault(),this.accessor.withOrigin(`user`,()=>this._tabs[t].value.panel.api.setActive());break;case`Delete`:case`Backspace`:e.preventDefault(),this._closeTab(t)}}_closeTab(e){let t=this._tabs[e]?.value;if(!t)return;let n=(this._tabs[e+1]?.value??this._tabs[e-1]?.value)?.panel.id;if(t.panel.api.close(),n!==void 0){let e=this._tabs.findIndex(e=>e.value.panel.id===n);e>-1&&this._focusTab(e)}}_focusTab(e){for(let t=0;t<this._tabs.length;t++)this._tabs[t].value.element.tabIndex=t===e?0:-1;this._tabs[e].value.element.focus()}focusActiveTab(){if(this._tabs.length===0)return;let e=this.group.activePanel?.id,t=e?this._tabs.findIndex(t=>t.value.panel.id===e):-1;this._focusTab(t>-1?t:0)}setActivePanel(e){let t=this._direction===`vertical`;for(let n of this._tabs){let r=e.id===n.value.panel.id;n.value.setActive(r),r&&this._scrollTabIntoView(n.value.element,t)}this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}_scrollTabIntoView(e,t){let n=e.parentElement;if(!n)return;let r=t?e.offsetTop:e.offsetLeft,i=t?e.offsetHeight:e.offsetWidth,a=t?n.scrollTop:n.scrollLeft,o=t?n.clientHeight:n.clientWidth;(r<a||r+i>a+o)&&(t?n.scrollTop=r:n.scrollLeft=r)}_activateOnPointerDown(e){if(!Qn(this.accessor.options).html5){this.group.model.openPanel(e);return}let t=requestAnimationFrame(()=>{this._tabMap.has(e.id)&&this.group.model.openPanel(e)});this._pointerActivation.value={dispose:()=>cancelAnimationFrame(t)}}openPanel(e,t=this._tabs.length){if(this._tabMap.has(e.id))return;let n=new nr(e,this.accessor,this.group);n.setContent(e.view.tab),this._direction!==`horizontal`&&n.setDirection(this._direction);let r={value:n,disposable:new ze(n.onDragStart(t=>{if(this._onTabDragStart.fire({nativeEvent:t,panel:e}),this.accessor.options.theme?.tabAnimation===`smooth`){let t=n.element.getBoundingClientRect().width,r=this._tabs.findIndex(e=>e.value===n);this._animState={sourceTabId:e.id,sourceIndex:r,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:null,sourceGroupPanelIds:null,sourceChipWidth:0,cursorOffsetFromDragLeft:t/2,sourceGapWidth:t,containerLeft:this._tabsList.getBoundingClientRect().left},this._pendingCollapse=!0,requestAnimationFrame(()=>{var e;this._pendingCollapse=!1,this._animState&&(this._tabsList.classList.contains(`dv-tabs-container--wrap`)||(n.element.style.transition=`none`,$(n.element,`dv-tab--dragging`,!0),n.element.offsetHeight),(e=this._animState).currentInsertionIndex??(e.currentInsertionIndex=r),this.applyDragOverTransforms(!0),n.element.style.removeProperty(`transition`))})}}),n.onTabClick(t=>{t.defaultPrevented||this.group.api.location.type===`edge`&&(this.group.activePanel===e?this.group.api.isCollapsed()?this.group.api.expand():this.group.api.collapse():(this.group.model.openPanel(e),this.group.api.isCollapsed()&&this.group.api.expand()))}),n.onPointerDown(t=>{if(t.defaultPrevented)return;let r=!this.accessor.options.disableFloatingGroups,i=this.group.api.location.type===`floating`&&this.size===1;if(r&&!i&&t.shiftKey){t.preventDefault();let e=this.accessor.getGroupPanel(n.panel.id),{top:r,left:i}=n.element.getBoundingClientRect(),{top:a,left:o}=this.accessor.element.getBoundingClientRect();this.accessor.addFloatingGroup(e,{x:i-o,y:r-a,inDragMode:!0});return}t.button===0&&this.group.api.location.type!==`edge`&&this.group.activePanel!==e&&this._activateOnPointerDown(e)}),n.onDrop(e=>{let t=this._animState;this._animState=null,this._pendingCollapse=!1;let r=this._tabs.findIndex(e=>e.value===n);if(t){let n=e.position===`right`?r+1:r;if(t.sourceTabGroupId){this._commitGroupMove(t.sourceTabGroupId,t.currentInsertionIndex??n);return}this._reorder.uncollapseSourceTab(t.sourceTabId);let i=this.snapshotTabPositions();this.resetTabTransforms(),this._onDrop.fire({event:e.nativeEvent,index:n,targetTabGroupId:t.targetTabGroupId}),this.accessor.options.theme?.tabAnimation===`smooth`&&this.runFlipAnimation(i,t.sourceTabId,t.sourceIndex===-1,t.sourceIndex===-1?void 0:{from:Math.min(t.sourceIndex,n),to:Math.max(t.sourceIndex,n)})}else{let t=this._direction===`vertical`?`bottom`:`right`,i=e.position===t?r+1:r,a=Le(),o=a?this._tabs.findIndex(e=>e.value.panel.id===a.panelId):-1,s=i-+(o!==-1&&o<i),c=this.group.model.getTabGroupForPanel(n.panel.id)?.id??null;this._onDrop.fire({event:e.nativeEvent,index:s,targetTabGroupId:c})}}),n.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new rr(e,{kind:`tab`,panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:Le}))}))};this.addTab(r,t),this._tabGroupManager.positionAllChips(),this._animState&&(this._animState.tabPositions=this.snapshotTabPositions(),this._animState.chipPositions=this._tabGroupManager.snapshotChipWidths(),this.applyDragOverTransforms())}delete(e){this._animState?.sourceTabId===e&&(this.resetTabTransforms(),this._animState=null),this._tabGroupManager.cleanupTransition(e);let t=this.indexOf(e),n=this._tabs.splice(t,1)[0];if(this._tabMap.delete(e),n){let{value:e,disposable:t}=n;t.dispose(),e.dispose(),e.element.remove()}this._animState&&(this._animState.tabPositions=this.snapshotTabPositions(),this._animState.chipPositions=this._tabGroupManager.snapshotChipWidths(),this.applyDragOverTransforms())}addTab(e,t=this._tabs.length){if(t<0||t>this._tabs.length)throw Error(`invalid location`);let n=t<this._tabs.length?this._tabs[t].value.element:null;this._tabsList.insertBefore(e.value.element,n),this._tabs=[...this._tabs.slice(0,t),e,...this._tabs.slice(t)],this._tabMap.set(e.value.panel.id,e),this.selectedIndex<0&&(this.selectedIndex=t)}toggleDropdown(e){let t=this._tabs.some(e=>!this._overflowExclude(e.value.panel.id)&&this._forcedOverflow(e.value.panel.id));if(e.reset&&!t){this._onOverflowTabsChange.fire({tabs:[],tabGroups:[],pinnedTabs:[],reset:!0});return}let n=this._tabs.filter(t=>!this._overflowExclude(t.value.panel.id)&&(this._forcedOverflow(t.value.panel.id)||!e.reset&&!pt(t.value.element,this._tabsList))).map(e=>e.value.panel.id),r=e.reset?[]:this._tabs.filter(e=>this._overflowExclude(e.value.panel.id)&&e.value.element.getBoundingClientRect().width>0&&!pt(e.value.element,this._tabsList)).map(e=>e.value.panel.id),i=new Set(n),a=[];for(let e of this.group.model.getTabGroups()){let t=this._tabGroupManager.chipRenderers.get(e.id),r=t&&!pt(t.chip.element,this._tabsList),o=e.panelIds.length>0&&e.panelIds.every(e=>i.has(e));if((r||o)&&(a.push(e.id),e.collapsed))for(let t of e.panelIds)i.has(t)||(i.add(t),n.push(t))}this._onOverflowTabsChange.fire({tabs:n,tabGroups:a,pinnedTabs:r,reset:!1})}updateDragAndDropState(){for(let e of this._tabs)e.value.updateDragAndDropState();this._tabGroupManager.updateDragAndDropState()}updateTabGroups(){this._tabGroupManager.update()}refreshTabGroupAccent(){this._tabGroupManager.refreshAccents()}_handleChipDragStart(e,t,n){let r=e.panelIds[0],i=r?this._tabs.findIndex(e=>e.value.panel.id===r):-1,a=t.element.getBoundingClientRect(),o=a.width;for(let t of e.panelIds){let e=this._tabMap.get(t);e&&(o+=e.value.element.getBoundingClientRect().width)}if(this._animState={sourceTabId:``,sourceIndex:i,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:e.id,sourceGroupPanelIds:new Set(e.panelIds),sourceChipWidth:a.width,cursorOffsetFromDragLeft:n.clientX-a.left,sourceGapWidth:o,containerLeft:this._tabsList.getBoundingClientRect().left},this.accessor.options.theme?.tabAnimation!==`smooth`)return;let s=new Set(e.panelIds);this._pendingCollapse=!0,requestAnimationFrame(()=>{var t;if(this._pendingCollapse=!1,!this._animState)return;for(let e of this._tabs)s.has(e.value.panel.id)&&(e.value.element.style.transition=`none`,$(e.value.element,`dv-tab--dragging`,!0));let n=this._tabGroupManager.chipRenderers.get(e.id);n&&(n.chip.element.style.transition=`none`,$(n.chip.element,`dv-tab-group-chip--dragging`,!0)),this._tabsList.offsetHeight;let r=this._tabGroupManager.groupUnderlines.get(e.id);r&&(r.style.display=`none`),(t=this._animState).currentInsertionIndex??(t.currentInsertionIndex=i),this.applyDragOverTransforms(!0);for(let e of this._tabs)s.has(e.value.panel.id)&&e.value.element.style.removeProperty(`transition`);n&&n.chip.element.style.removeProperty(`transition`)})}_handleChipDrop(e,t){let n=e.panelIds[0];if(!n)return;let r=this._tabs.findIndex(e=>e.value.panel.id===n);if(r===-1)return;let i=Le(),a=i?.groupId===this.group.id&&i?.panelId?this._tabs.findIndex(e=>e.value.panel.id===i.panelId):-1,o=r-+(a!==-1&&a<r);this._onDrop.fire({event:t.nativeEvent,index:o,targetTabGroupId:null})}setExtendedDropZone(e){this._reorder.setExtendedDropZone(e)}setExternalInsertionIndex(e){this._reorder.setExternalInsertionIndex(e)}clearExternalAnimState(){this._reorder.clearExternalAnimState()}snapshotTabPositions(){return this._reorder.snapshotTabPositions()}handleDragOver(e){this._reorder.handleDragOver(e)}applyDragOverTransforms(e=!1){this._reorder.applyDragOverTransforms(e)}resetTabTransforms(){this._reorder.resetTabTransforms()}_commitGroupMove(e,t){this._reorder.commitGroupMove(e,t)}runFlipAnimation(e,t,n=!1,r){this._reorder.runFlipAnimation(e,t,n,r)}};function jr(){let e=document.createElement(`div`);e.className=`dv-tabs-overflow-dropdown-default`;let t=document.createElement(`span`);t.textContent=``;let n=Jn();return e.appendChild(n),e.appendChild(t),{element:e,update:e=>{t.textContent=`${e.tabs}`}}}var Mr=class extends ze{get onTabDragStart(){return this.tabs.onTabDragStart}get panels(){return this.tabs.panels}get size(){return this.tabs.size}get hidden(){return this._hidden}set hidden(e){this._hidden=e,this.element.style.display=e?`none`:``}get direction(){return this._direction}set direction(e){this._direction=e,e===`vertical`?(Ze(this._element,`dv-groupview-header-vertical`),Ze(this.rightActionsContainer,`dv-right-actions-container-vertical`),this.tabs.direction=e):(Xe(this._element,`dv-groupview-header-vertical`),Xe(this.rightActionsContainer,`dv-right-actions-container-vertical`),this.tabs.direction=e)}get element(){return this._element}get tabsListElement(){return this.tabs.tabsListElement}constructor(e,t){super(),this.accessor=e,this.group=t,this._hidden=!1,this._direction=`horizontal`,this._dropIndexResolver=(e,t)=>t,this._pinnedRow=void 0,this.dropdownPart=null,this._overflowTabs=[],this._overflowTabGroups=[],this._overflowPinnedTabs=[],this._dropdownDisposable=new Be,this._onDrop=new Z,this.onDrop=this._onDrop.event,this._onGroupDragStart=new Z,this.onGroupDragStart=this._onGroupDragStart.event,this._onWillShowOverlay=new Z,this.onWillShowOverlay=this._onWillShowOverlay.event,this._element=document.createElement(`div`),this._element.className=`dv-tabs-and-actions-container`,$(this._element,`dv-full-width-single-tab`,this.accessor.options.singleTabMode===`fullwidth`),this.rightActionsContainer=document.createElement(`div`),this.rightActionsContainer.className=`dv-right-actions-container`,this.leftActionsContainer=document.createElement(`div`),this.leftActionsContainer.className=`dv-left-actions-container`,this.preActionsContainer=document.createElement(`div`),this.preActionsContainer.className=`dv-pre-actions-container`,this.tabs=new Ar(t,e,{showTabsOverflowControl:!e.options.disableTabsOverflowList}),this.voidContainer=new ar(this.accessor,this.group),this.tabs.voidContainer=this.voidContainer.element,this._element.appendChild(this.preActionsContainer),this._element.appendChild(this.tabs.element),this._element.appendChild(this.leftActionsContainer),this._element.appendChild(this.voidContainer.element),this._element.appendChild(this.rightActionsContainer),this.tabs.setExtendedDropZone(this._element),this.addDisposables(this.tabs.onDrop(e=>this._onDrop.fire(e)),this.tabs.onWillShowOverlay(e=>this._onWillShowOverlay.fire(e)),e.onDidOptionsChange(()=>{this.tabs.showTabsOverflowControl=!e.options.disableTabsOverflowList}),this.tabs.onOverflowTabsChange(e=>{this.toggleDropdown(e)}),this.tabs,this._onWillShowOverlay,this._onDrop,this._onGroupDragStart,this.voidContainer,this.voidContainer.onDragStart(e=>{this._onGroupDragStart.fire({nativeEvent:e,group:this.group})}),this.voidContainer.onDrop(e=>{this.tabs.handleVoidDrop()||this._onDrop.fire({event:e.nativeEvent,index:this.tabs.size})}),this.voidContainer.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new rr(e,{kind:`header_space`,panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:Le}))}),Q(this.leftActionsContainer,`dragleave`,e=>{let t=e.relatedTarget;!this.leftActionsContainer.contains(t)&&!this._element.contains(t)&&this.tabs.clearExternalAnimState()}),Q(this.voidContainer.element,`dragleave`,e=>{let t=e.relatedTarget;this.voidContainer.element.contains(t)||(this._element.contains(t)?this.tabs.setExternalInsertionIndex(null):this.tabs.clearExternalAnimState())}),Q(this.voidContainer.element,`pointerdown`,e=>{if(!e.defaultPrevented&&!this.accessor.options.disableFloatingGroups&&e.shiftKey&&this.group.api.location.type!==`floating`&&this.group.api.location.type!==`edge`){e.preventDefault();let{top:t,left:n}=this.element.getBoundingClientRect(),{top:r,left:i}=this.accessor.element.getBoundingClientRect();this.accessor.addFloatingGroup(this.group,{x:n-i+20,y:t-r+20,inDragMode:!0})}}))}show(){this.hidden||(this.element.style.display=``)}hide(){this._element.style.display=`none`}setRightActionsElement(e){this.rightActions!==e&&(this.rightActions&&=(this.rightActions.remove(),void 0),e&&(this.rightActionsContainer.appendChild(e),this.rightActions=e))}setLeftActionsElement(e){this.leftActions!==e&&(this.leftActions&&=(this.leftActions.remove(),void 0),e&&(this.leftActionsContainer.appendChild(e),this.leftActions=e))}setPrefixActionsElement(e){this.preActions!==e&&(this.preActions&&=(this.preActions.remove(),void 0),e&&(this.preActionsContainer.appendChild(e),this.preActions=e))}isActive(e){return this.tabs.isActive(e)}indexOf(e){return this.tabs.indexOf(e)}getTabId(e){return this.tabs.getTabId(e)}getPanelForTab(e){return this.tabs.getPanelForTab(e)}setActive(e){}delete(e){this.tabs.delete(e),this.updateClassnames()}setActivePanel(e){this.tabs.setActivePanel(e)}focusActiveTab(){this.tabs.focusActiveTab()}openPanel(e,t=this.tabs.size){this.tabs.openPanel(e,t),this.updateClassnames()}closePanel(e){this.delete(e.id)}setOverflowExclude(e){this.tabs.setOverflowExclude(e)}setForcedOverflow(e){this.tabs.setForcedOverflow(e)}setPinnedSticky(e){this.tabs.setPinnedSticky(e)}refreshOverflow(){this.tabs.refreshOverflow()}setPinnedRow(e){this._pinnedRow!==e&&(this._pinnedRow&&this._pinnedRow.remove(),this._pinnedRow=e,e&&(e.classList.add(`dv-pinned-row`),this._element.insertBefore(e,this._element.firstChild)),$(this._element,`dv-tabs-and-actions-container--pinned-row`,!!e))}setDropIndexResolver(e){this._dropIndexResolver=e}resolveDropIndex(e,t){return this._dropIndexResolver(e,t)}updateClassnames(){$(this._element,`dv-single-tab`,this.size===1)}toggleDropdown(e){let t=e.reset?[]:e.tabs,n=e.reset?[]:e.tabGroups,r=e.reset?[]:e.pinnedTabs;this._overflowTabs=t,this._overflowTabGroups=n,this._overflowPinnedTabs=r;let i=this._overflowTabs.length+this._overflowPinnedTabs.length;if(i>0&&this.dropdownPart){this.dropdownPart.update({tabs:i});return}if(i===0){this._dropdownDisposable.dispose();return}let a=document.createElement(`div`);a.className=`dv-tabs-overflow-dropdown-root`;let o=jr();o.update({tabs:i}),this.dropdownPart=o,a.appendChild(o.element),this.rightActionsContainer.prepend(a),this._dropdownDisposable.value=new ze(Re.from(()=>{var e,t;a.remove(),(e=this.dropdownPart)==null||(t=e.dispose)==null||t.call(e),this.dropdownPart=null}),Q(a,`pointerdown`,e=>{e.preventDefault()},{capture:!0}),Q(a,`click`,e=>{let t=_t(a),n={x:e.clientX,y:e.clientY,zIndex:t?.style.zIndex?`calc(${t.style.zIndex} * 2)`:void 0},r=this.createOverflowRenderContext(a,n),i=this.accessor.advancedOverflowService;i?i.renderOverflow({group:this.group,overflowTabs:[...this._overflowTabs],overflowTabGroups:[...this._overflowTabGroups],pinnedOverflowTabs:[...this._overflowPinnedTabs],context:r}):r.open(this.renderFreeOverflowList(r))}))}createOverflowRenderContext(e,t){let n=new Set(this._overflowTabGroups),r=this.group.model.getTabGroups(),i=new Map,a=new Map;for(let e of r)if(a.set(e.id,e),n.has(e.id))for(let t of e.panelIds)i.set(t,e);let o=()=>this.accessor.getPopupServiceForGroup(this.group),s=e=>{let t=document.createElement(`div`);t.className=`dv-tabs-overflow-group-header`;let n=document.createElement(`span`);n.className=`dv-tabs-overflow-group-color`,yr(n,e.color,this.accessor.tabGroupColorPalette),t.appendChild(n);let r=document.createElement(`span`);if(r.className=`dv-tabs-overflow-group-label`,r.textContent=e.label||e.id,t.appendChild(r),e.collapsed){let n=document.createElement(`span`);n.className=`dv-tabs-overflow-group-collapsed-badge`,n.textContent=`${e.panelIds.length}`,t.appendChild(n)}return t.addEventListener(`click`,()=>{o().close(),e.collapsed&&e.expand();let t=e.panelIds[0];if(t){let e=this.group.panels.find(e=>e.id===t);this.accessor.withOrigin(`user`,()=>e?.api.setActive())}}),t};return{overflowGroupIdForPanel:e=>i.get(e)?.id,buildGroupHeader:e=>{let t=a.get(e);if(!(!t||!n.has(t.id)))return s(t)},buildPinnedHeader:()=>{let e=document.createElement(`div`);e.className=`dv-tabs-overflow-group-header dv-tabs-overflow-pinned-header`;let t=qn();t.classList.add(`dv-tabs-overflow-pinned-icon`),e.appendChild(t);let n=document.createElement(`span`);return n.className=`dv-tabs-overflow-group-label`,n.textContent=`Pinned`,e.appendChild(n),e},buildRow:e=>{let t=this.group.panels.find(t=>t.id===e);if(!t)return;let n=this.tabs.tabs.find(t=>t.panel.id===e),r=i.get(e),a=t.view.createTabRenderer(`headerOverflow`).element,s=document.createElement(`div`);$(s,`dv-tab`,!0),$(s,`dv-active-tab`,t.api.isActive),$(s,`dv-inactive-tab`,!t.api.isActive),r&&$(s,`dv-tab--grouped`,!0);let c=()=>{r?.collapsed&&r.expand(),n?.element.scrollIntoView({block:`nearest`,inline:`nearest`}),this.accessor.withOrigin(`user`,()=>t.api.setActive())};return s.addEventListener(`click`,e=>{o().close(),!e.defaultPrevented&&c()}),s.appendChild(a),{element:s,panel:t,activate:()=>{o().close(),c()}}},open:e=>{o().openPopover(e,t)},close:()=>o().close(),focusTrigger:()=>{e.tabIndex=-1,e.focus()}}}renderFreeOverflowList(e){let t=document.createElement(`div`);t.style.overflow=`auto`,t.className=`dv-tabs-overflow-container`;let n=this._overflowPinnedTabs.map(t=>e.buildRow(t)).filter(e=>e!=null);if(n.length>0){t.appendChild(e.buildPinnedHeader());for(let e of n)t.appendChild(e.element)}let r=new Set;for(let n of this.tabs.tabs.filter(e=>this._overflowTabs.includes(e.panel.id))){let i=e.overflowGroupIdForPanel(n.panel.id);if(i&&!r.has(i)){r.add(i);let n=e.buildGroupHeader(i);n&&t.appendChild(n)}let a=e.buildRow(n.panel.id);a&&t.appendChild(a.element)}return t}updateDragAndDropState(){this.tabs.updateDragAndDropState(),this.voidContainer.updateDragAndDropState()}updateTabGroups(){this.tabs.updateTabGroups()}refreshTabGroupAccent(){this.tabs.refreshTabGroupAccent()}},Nr=class extends ze{get label(){return this._label}get color(){return this._color}get componentParams(){return this._componentParams}setLabel(e){this.isDisposed||this._label===e||(this._label=e,this._onDidChange.fire())}setColor(e){if(this.isDisposed)return;let t=e===``?void 0:e;this._color!==t&&(this._color=t,this._onDidChange.fire())}setComponentParams(e){this.isDisposed||(this._componentParams=e,this._onDidChange.fire())}get collapsed(){return this._collapsed}get panelIds(){return this._panelIds}get size(){return this._panelIds.length}get isEmpty(){return this._panelIds.length===0}constructor(e,t){super(),this.id=e,this._collapsed=!1,this._panelIds=[],this._onDidChange=new Z,this.onDidChange=this._onDidChange.event,this._onDidPanelChange=new Z,this.onDidPanelChange=this._onDidPanelChange.event,this._onDidCollapseChange=new Z,this.onDidCollapseChange=this._onDidCollapseChange.event,this._onDidDestroy=new Z,this.onDidDestroy=this._onDidDestroy.event,this._label=t?.label??``,this._color=t?.color===``?void 0:t?.color,this._collapsed=t?.collapsed??!1,this._componentParams=t?.componentParams,this.addDisposables(this._onDidChange,this._onDidPanelChange,this._onDidCollapseChange,this._onDidDestroy)}addPanel(e,t){if(this.isDisposed||this._panelIds.includes(e))return;let n=t===void 0?this._panelIds.length:Math.max(0,Math.min(t,this._panelIds.length));this._panelIds.splice(n,0,e),this._onDidPanelChange.fire({panelId:e,type:`add`})}removePanel(e){if(this.isDisposed)return!1;let t=this._panelIds.indexOf(e);return t!==-1&&(this._panelIds.splice(t,1),this._onDidPanelChange.fire({panelId:e,type:`remove`}),!0)}indexOfPanel(e){return this._panelIds.indexOf(e)}containsPanel(e){return this._panelIds.includes(e)}collapse(){this.isDisposed||this._collapsed||(this._collapsed=!0,this._onDidCollapseChange.fire(!0))}expand(){this.isDisposed||!this._collapsed||(this._collapsed=!1,this._onDidCollapseChange.fire(!1))}toggle(){this._collapsed?this.expand():this.collapse()}toJSON(){let e={id:this.id,collapsed:this._collapsed,panelIds:[...this._panelIds]};return this._label&&(e.label=this._label),this._color!==void 0&&(e.color=this._color),this._componentParams!==void 0&&(e.componentParams=this._componentParams),e}dispose(){this._onDidDestroy.fire(),super.dispose()}},Pr=class extends He{get nativeEvent(){return this.options.nativeEvent}get position(){return this.options.position}get panel(){return this.options.panel}get group(){return this.options.group}get api(){return this.options.api}constructor(e){super(),this.options=e}getData(){return this.options.getData()}},Fr=class extends Pr{get kind(){return this._kind}constructor(e){super(e),this._kind=e.kind}},Ir=class extends ze{get tabGroups(){return this._tabGroups}get element(){throw Error(`dockview: not supported`)}get activePanel(){return this._activePanel}get contentContainerId(){return this.contentContainer.element.id}get contentDropTarget(){return this.contentContainer.dropTarget}get locked(){return this._locked}set locked(e){this._locked=e,$(this.container,`dv-locked-groupview`,e===`no-drop-target`||e)}get isActive(){return this._isGroupActive}get panels(){return this._panels}get size(){return this._panels.length}get isEmpty(){return this._panels.length===0}get hasWatermark(){return!!(this.watermark&&this.container.contains(this.watermark.element))}get header(){return this.tabsContainer}get tabsListElement(){return this.tabsContainer.tabsListElement}getPanelForTab(e){return this.tabsContainer.getPanelForTab(e)}get isContentFocused(){return document.activeElement?Qe(document.activeElement,this.contentContainer.element):!1}get headerPosition(){return this._headerPosition??`top`}set headerPosition(e){this._headerPosition=e,this.invalidateHeaderSize(),Xe(this.container,`dv-groupview-header-top`,`dv-groupview-header-bottom`,`dv-groupview-header-left`,`dv-groupview-header-right`),Ze(this.container,`dv-groupview-header-${e}`);let t=e===`top`||e===`bottom`?`horizontal`:`vertical`,n=this._headerDirection;if(this._headerDirection=t,this.tabsContainer.direction=t,this.header.direction=t,this._activePanel?.layout){let{width:e,height:t}=this.contentDimensions();this._activePanel.layout(e,t)}if(this.updateHeaderActions(),n!==void 0&&n!==t){var r;(r=this.groupPanel)==null||r.api._onDidHeaderDirectionChange.fire({direction:t,position:e})}}get location(){return this._location}set location(e){this._location=e,$(this.container,`dv-groupview-floating`,!1),$(this.container,`dv-groupview-popout`,!1),$(this.container,`dv-groupview-edge`,!1);let t=e=>{this.contentContainer.dropTarget.setTargetZones(e),this.contentContainer.pointerDropTarget.setTargetZones(e)};switch(e.type){case`grid`:t([`top`,`bottom`,`left`,`right`,`center`]);break;case`floating`:t([`top`,`bottom`,`left`,`right`,`center`]),$(this.container,`dv-groupview-floating`,!0);break;case`popout`:t([`top`,`bottom`,`left`,`right`,`center`]),$(this.container,`dv-groupview-popout`,!0);break;case`edge`:t([`center`]),$(this.container,`dv-groupview-edge`,!0)}this.groupPanel.api._onDidLocationChange.fire({location:this.location})}constructor(e,t,n,r,i){super(),this.container=e,this.accessor=t,this.id=n,this.options=r,this.groupPanel=i,this._isGroupActive=!1,this._locked=!1,this._location={type:`grid`},this.mostRecentlyUsed=[],this._overwriteRenderContainer=null,this._overwriteDropTargetContainer=null,this._onDidChange=new Z,this.onDidChange=this._onDidChange.event,this._width=0,this._height=0,this._panels=[],this._panelDisposables=new Map,this._tabGroupDisposables=new Map,this._pendingMicrotaskDisposables=new Set,this._onMove=new Z,this.onMove=this._onMove.event,this._onDidDrop=new Z,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new Z,this.onWillDrop=this._onWillDrop.event,this._onWillShowOverlay=new Z,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onTabDragStart=new Z,this.onTabDragStart=this._onTabDragStart.event,this._onGroupDragStart=new Z,this.onGroupDragStart=this._onGroupDragStart.event,this._onDidAddPanel=new Z,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPanelTitleChange=new Z,this.onDidPanelTitleChange=this._onDidPanelTitleChange.event,this._onDidPanelParametersChange=new Z,this.onDidPanelParametersChange=this._onDidPanelParametersChange.event,this._onDidRemovePanel=new Z,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidActivePanelChange=new Z,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onUnhandledDragOver=new Z,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this._tabGroups=[],this._tabGroupMap=new Map,this._panelToTabGroup=new Map,this._tabGroupIdCounter=0,this._pendingTabGroupUpdate=!1,this._onDidCreateTabGroup=new Z,this.onDidCreateTabGroup=this._onDidCreateTabGroup.event,this._onDidDestroyTabGroup=new Z,this.onDidDestroyTabGroup=this._onDidDestroyTabGroup.event,this._onDidAddPanelToTabGroup=new Z,this.onDidAddPanelToTabGroup=this._onDidAddPanelToTabGroup.event,this._onDidRemovePanelFromTabGroup=new Z,this.onDidRemovePanelFromTabGroup=this._onDidRemovePanelFromTabGroup.event,this._onDidTabGroupChange=new Z,this.onDidTabGroupChange=this._onDidTabGroupChange.event,this._onDidTabGroupCollapsedChange=new Z,this.onDidTabGroupCollapsedChange=this._onDidTabGroupCollapsedChange.event,$(this.container,`dv-groupview`,!0),this.container.setAttribute(`role`,`region`),this._api=new sn(this.accessor),this.tabsContainer=new Mr(this.accessor,this.groupPanel),this.contentContainer=new Wn(this.accessor,this),e.append(this.tabsContainer.element,this.contentContainer.element),this.header.hidden=!!r.hideHeader,this.locked=r.locked??!1,this.headerPosition=r.headerPosition??t.defaultHeaderPosition,this.addDisposables(Ye(this.tabsContainer.element,()=>{if(this.isDisposed)return;let e=this.measureHeaderSize();e!==this._cachedHeaderSize&&(this._cachedHeaderSize=e,this.layout(this._width,this._height))}),this._onDidPanelTitleChange.event(()=>this.updateAccessibleLabel()),this._onTabDragStart,this._onGroupDragStart,this._onWillShowOverlay,this.tabsContainer.onTabDragStart(e=>{this._onTabDragStart.fire(e)}),this.tabsContainer.onGroupDragStart(e=>{this._onGroupDragStart.fire(e)}),this.tabsContainer.onDrop(e=>{let t=Le()?.panelId??null,n=t?this.tabsContainer.resolveDropIndex(t,e.index):e.index;if(this.handleDropEvent(`header`,e.event,`center`,n),t&&e.targetTabGroupId){let n=this._tabGroupMap.get(e.targetTabGroupId),r;if(n){let e=this._panels.findIndex(e=>e.id===t);if(e!==-1){r=0;for(let t of n.panelIds)this._panels.findIndex(e=>e.id===t)<e&&r++}}this.addPanelToTabGroup(e.targetTabGroupId,t,r)}else t&&e.targetTabGroupId===null&&this.removePanelFromTabGroup(t)}),this.contentContainer.onDidFocus(()=>{this.accessor.doSetGroupActive(this.groupPanel)}),this.contentContainer.onDidBlur(()=>{}),this.contentContainer.dropTarget.onDrop(e=>{this.handleDropEvent(`content`,e.nativeEvent,e.position,void 0,e.edge)}),this.contentContainer.pointerDropTarget.onDrop(e=>{this.handleDropEvent(`content`,e.nativeEvent,e.position,void 0,e.edge)}),this.tabsContainer.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(e)}),this.contentContainer.dropTarget.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new rr(e,{kind:`content`,panel:this.activePanel,api:this._api,group:this.groupPanel,getData:Le}))}),this.contentContainer.pointerDropTarget.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new rr(e,{kind:`content`,panel:this.activePanel,api:this._api,group:this.groupPanel,getData:Le}))}),this._onMove,this._onDidChange,this._onDidDrop,this._onWillDrop,this._onDidAddPanel,this._onDidRemovePanel,this._onDidActivePanelChange,this._onUnhandledDragOver,this._onDidPanelTitleChange,this._onDidPanelParametersChange,this._onDidCreateTabGroup,this._onDidDestroyTabGroup,this._onDidAddPanelToTabGroup,this._onDidRemovePanelFromTabGroup,this._onDidTabGroupChange,this._onDidTabGroupCollapsedChange,this._onDidCreateTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidDestroyTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidAddPanelToTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidRemovePanelFromTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidTabGroupChange.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidTabGroupCollapsedChange.event(()=>{this._scheduleTabGroupUpdate()}))}_scheduleTabGroupUpdate(){this._pendingTabGroupUpdate||(this._pendingTabGroupUpdate=!0,queueMicrotask(()=>{this._pendingTabGroupUpdate=!1,this.isDisposed||this.tabsContainer.updateTabGroups()}))}_bracketTabGroupMutation(e){return this.accessor.mutation?this.accessor.mutation(`tab-group`,e):e()}createTabGroup(e){return this._bracketTabGroupMutation(()=>this._doCreateTabGroup(e))}_doCreateTabGroup(e){let t=e?.id??`tg-${this.id}-${this._tabGroupIdCounter++}`,n=new Nr(t,{label:e?.label,color:e?.color,collapsed:e?.collapsed,componentParams:e?.componentParams});return this._tabGroups.push(n),this._tabGroupMap.set(t,n),this._tabGroupDisposables.set(t,new ze(n.onDidChange(()=>{this._onDidTabGroupChange.fire({tabGroup:n})}),n.onDidCollapseChange(e=>{e?this._handleGroupCollapse(n):this._handleGroupExpand(n),this._onDidTabGroupCollapsedChange.fire({tabGroup:n})}),n.onDidDestroy(()=>{this._removeTabGroupInternal(n)}))),this._onDidCreateTabGroup.fire({tabGroup:n}),n}dissolveTabGroup(e){let t=this._tabGroupMap.get(e);t&&this._bracketTabGroupMutation(()=>{let e=[...t.panelIds];for(let n of e)t.removePanel(n),this._panelToTabGroup.delete(n),this._onDidRemovePanelFromTabGroup.fire({tabGroup:t,panelId:n});t.dispose()})}addPanelToTabGroup(e,t,n){let r=this._tabGroupMap.get(e);if(!r||!this._panels.some(e=>e.id===t))return;let i=this.getTabGroupForPanel(t);i?.id!==e&&this._bracketTabGroupMutation(()=>{i&&this.removePanelFromTabGroup(t),r.addPanel(t,n),this._panelToTabGroup.set(t,r),this._enforceContiguity(r,t),this._onDidAddPanelToTabGroup.fire({tabGroup:r,panelId:t})})}movePanelWithinGroup(e,t,n){let r=this._tabGroupMap.get(e);r?.containsPanel(t)&&(r.removePanel(t),r.addPanel(t,n),this._enforceContiguity(r,t),this.tabsContainer.updateTabGroups())}movePanelBetweenGroups(e,t,n){let r=this._findTabGroupForPanel(e),i=this._tabGroupMap.get(t);i&&(r&&(r.removePanel(e),this._panelToTabGroup.delete(e),this._onDidRemovePanelFromTabGroup.fire({tabGroup:r,panelId:e}),r.isEmpty&&r.dispose()),i.addPanel(e,n),this._panelToTabGroup.set(e,i),this._enforceContiguity(i,e),this._onDidAddPanelToTabGroup.fire({tabGroup:i,panelId:e}))}moveTabGroup(e,t){let n=this._tabGroupMap.get(e);if(!n||n.panelIds.length===0)return;let r=new Set(n.panelIds),i=n.panelIds.map(e=>this._panels.find(t=>t.id===e)).filter(e=>e!==void 0);if(i.length===0)return;let a=0;for(let e=0;e<Math.min(t,this._panels.length);e++)r.has(this._panels[e].id)&&a++;for(let e of i){let t=this._panels.indexOf(e);t!==-1&&this._panels.splice(t,1)}let o=t-a,s=Math.max(0,Math.min(o,this._panels.length));this._panels.splice(s,0,...i);for(let e of this._panels)this.tabsContainer.delete(e.id);for(let e=0;e<this._panels.length;e++)this.tabsContainer.openPanel(this._panels[e],e);this.tabsContainer.updateTabGroups()}_enforceContiguity(e,t){let n=this._panels.find(e=>e.id===t);if(!n)return;let r=e.indexOfPanel(t),i=this._computeGlobalIndex(e,r),a=this._panels.indexOf(n);if(a===i)return;this._panels.splice(a,1);let o=i>a?i-1:i;this._panels.splice(o,0,n),this.tabsContainer.delete(t),this.tabsContainer.openPanel(n,o)}_computeGlobalIndex(e,t){let n=e.panelIds;if(n.length<=1){let e=this._panels.find(e=>e.id===n[0]);return e?this._panels.indexOf(e):this._panels.length}for(let e=0;e<n.length;e++){if(e===t)continue;let r=this._panels.find(t=>t.id===n[e]);if(r){let n=this._panels.indexOf(r);return Math.max(0,n+(t-e))}}return this._panels.length}removePanelFromTabGroup(e){let t=this._findTabGroupForPanel(e);t&&this._bracketTabGroupMutation(()=>{t.removePanel(e),this._panelToTabGroup.delete(e),this._onDidRemovePanelFromTabGroup.fire({tabGroup:t,panelId:e}),t.isEmpty&&t.dispose()})}getTabGroups(){return this._tabGroups}updateTabGroups(){this.tabsContainer.updateTabGroups()}refreshTabGroupAccent(){this.tabsContainer.refreshTabGroupAccent()}refreshWatermark(){if(this.watermark){var e,t;this.watermark.element.remove(),(e=(t=this.watermark).dispose)==null||e.call(t),this.watermark=void 0}this.updateContainer()}getTabGroupForPanel(e){return this._findTabGroupForPanel(e)}_findTabGroupForPanel(e){return this._panelToTabGroup.get(e)}_removeTabGroupInternal(e){let t=this._tabGroups.indexOf(e);if(t!==-1){this._tabGroups.splice(t,1),this._tabGroupMap.delete(e.id);for(let t of e.panelIds)this._panelToTabGroup.delete(t);this._onDidDestroyTabGroup.fire({tabGroup:e});let n=this._tabGroupDisposables.get(e.id);this._tabGroupDisposables.delete(e.id),n&&(this._pendingMicrotaskDisposables.add(n),queueMicrotask(()=>{this._pendingMicrotaskDisposables.delete(n),n.dispose()}))}}_handleGroupCollapse(e){if(!this._activePanel||!e.containsPanel(this._activePanel.id))return;let t=this._panels.indexOf(this._activePanel);for(let e=t+1;e<this._panels.length;e++){let t=this._panels[e];if(!this._findTabGroupForPanel(t.id)?.collapsed){this.doSetActivePanel(t),this.updateContainer();return}}for(let e=t-1;e>=0;e--){let t=this._panels[e];if(!this._findTabGroupForPanel(t.id)?.collapsed){this.doSetActivePanel(t),this.updateContainer();return}}this.contentContainer.closePanel(),this.doSetActivePanel(void 0),this.updateContainer()}_handleGroupExpand(e){if(this._activePanel)return;let t=e.panelIds[0];if(t){let e=this._panels.find(e=>e.id===t);e&&(this.doSetActivePanel(e),this.updateContainer())}}restoreTabGroups(e){for(let t of e){let e=/-(\d+)$/.exec(t.id);if(e){let t=Number.parseInt(e[1],10)+1;t>this._tabGroupIdCounter&&(this._tabGroupIdCounter=t)}}for(let t of e){let e=this.createTabGroup({id:t.id,label:t.label,color:t.color,componentParams:t.componentParams}),n=this._tabGroupMap.get(e.id);for(let r of t.panelIds)this._panels.some(e=>e.id===r)&&(e.addPanel(r),this._panelToTabGroup.set(r,n),this._enforceContiguity(n,r));t.collapsed&&e.collapse(),e.isEmpty&&e.dispose()}}focusContent(){this.contentContainer.element.focus()}focusActiveTab(){this.tabsContainer.focusActiveTab()}set renderContainer(e){if(this.panels.forEach(e=>{this.renderContainer.detatch(e)}),this._overwriteRenderContainer=e,this.panels.forEach(e=>{this.rerender(e)}),this._activePanel){this.contentContainer.renderPanel(this._activePanel,{asActive:!0});let{width:e,height:t}=this.contentDimensions();this._activePanel.layout(e,t)}}get renderContainer(){return this._overwriteRenderContainer??this.accessor.overlayRenderContainer}set dropTargetContainer(e){this._overwriteDropTargetContainer=e}get dropTargetContainer(){return this._location.type===`floating`&&this.accessor.rootDropTargetContainer.disabled?this.accessor.floatingDropTargetContainer:this._overwriteDropTargetContainer??this.accessor.rootDropTargetContainer}initialize(){this.options.panels&&this.options.panels.forEach(e=>{this.doAddPanel(e)}),this.options.activePanel&&this.openPanel(this.options.activePanel),this.setActive(this.isActive,!0),this.updateContainer(),this.updateHeaderActions()}updateHeaderActions(){var e;(e=this.accessor.headerActionsService)==null||e.refresh(this.groupPanel)}attachHeaderAction(e,t){switch(e){case`left`:this.tabsContainer.setLeftActionsElement(t);break;case`right`:this.tabsContainer.setRightActionsElement(t);break;case`prefix`:this.tabsContainer.setPrefixActionsElement(t)}}rerender(e){this.contentContainer.renderPanel(e,{asActive:!1})}indexOf(e){return this.tabsContainer.indexOf(e.id)}toJSON(){let e={views:this.tabsContainer.panels,activeView:this._activePanel?.id,id:this.id};return this.locked!==!1&&(e.locked=this.locked),this.header.hidden&&(e.hideHeader=!0),this.headerPosition!==`top`&&(e.headerPosition=this.headerPosition),this._tabGroups.length>0&&(e.tabGroups=this._tabGroups.map(e=>e.toJSON())),e}moveToNext(e){var t;e??={},(t=e).panel??(t.panel=this.activePanel);let n=e.panel?this.panels.indexOf(e.panel):-1,r;if(n<this.panels.length-1)r=n+1;else if(e.suppressRoll)return;else r=0;this.openPanel(this.panels[r])}moveToPrevious(e){var t;if(e??={},(t=e).panel??(t.panel=this.activePanel),!e.panel)return;let n=this.panels.indexOf(e.panel),r;if(n>0)r=n-1;else if(e.suppressRoll)return;else r=this.panels.length-1;this.openPanel(this.panels[r])}containsPanel(e){return this.panels.includes(e)}init(e){}update(e){}focus(){var e;(e=this._activePanel)==null||e.focus()}openPanel(e,t={}){(typeof t.index!=`number`||t.index>this.panels.length)&&(t.index=this.panels.length);let n=!!t.skipSetActive;if(e.updateParentGroup(this.groupPanel,{skipSetActive:t.skipSetActive}),this.doAddPanel(e,t.index,{skipSetActive:n}),this.invalidateHeaderSize(),this._activePanel===e){this.contentContainer.renderPanel(e,{asActive:!0});return}n||this.doSetActivePanel(e),t.skipSetGroupActive||this.accessor.doSetGroupActive(this.groupPanel),t.skipSetActive||this.updateContainer()}removePanel(e,t){let n=typeof e==`string`?e:e.id,r=this._panels.find(e=>e.id===n);if(!r)throw Error(`invalid operation`);return this._removePanel(r,t)}closeAllPanels(){if(this.panels.length>0){let e=[...this.panels];for(let t of e)this.doClose(t)}else this.accessor.removeGroup(this.groupPanel)}closePanel(e){this.doClose(e)}doClose(e){let t=this.panels.length===1&&this.accessor.groups.length===1;this.accessor.removePanel(e,t&&this.accessor.options.noPanelsOverlay===`emptyGroup`?{removeEmptyGroup:!1}:void 0)}isPanelActive(e){return this._activePanel===e}updateActions(e){this.tabsContainer.setRightActionsElement(e)}setActive(e,t=!1){if(!(!t&&this.isActive===e)){if(this._isGroupActive=e,$(this.container,`dv-active-group`,e),$(this.container,`dv-inactive-group`,!e),this.tabsContainer.setActive(this.isActive),!this._activePanel&&this.panels.length>0){let e=this._panels.find(e=>!this._findTabGroupForPanel(e.id)?.collapsed);e&&this.doSetActivePanel(e)}this.updateContainer()}}layout(e,t){this._width=e,this._height=t;let{width:n,height:r}=this.contentDimensions();this.contentContainer.layout(n,r),this._activePanel?.layout&&this._activePanel.layout(n,r)}relayout(){this.invalidateHeaderSize(),this.layout(this._width,this._height)}measureHeaderSize(){let e=this.tabsContainer.element;return this.headerPosition===`top`||this.headerPosition===`bottom`?e.offsetHeight:e.offsetWidth}invalidateHeaderSize(){this._cachedHeaderSize=void 0}contentDimensions(){let e=this.headerPosition===`top`||this.headerPosition===`bottom`,t=this._cachedHeaderSize??=this.measureHeaderSize();return{width:e?this._width:Math.max(0,this._width-t),height:e?Math.max(0,this._height-t):this._height}}_removePanel(e,t){let n=this._activePanel===e;if(this.doRemovePanel(e),this.invalidateHeaderSize(),n&&this.panels.length>0){let e=this.mostRecentlyUsed[0];this.openPanel(e,{skipSetActive:t?.skipSetActive,skipSetGroupActive:t?.skipSetActiveGroup})}return this._activePanel&&this.panels.length===0&&this.doSetActivePanel(void 0),t?.skipSetActive||this.updateContainer(),e}doRemovePanel(e){let t=this.panels.indexOf(e);if(this._activePanel===e&&this.contentContainer.closePanel(),this.tabsContainer.delete(e.id),this._panels.splice(t,1),this.mostRecentlyUsed.includes(e)){let t=this.mostRecentlyUsed.indexOf(e);this.mostRecentlyUsed.splice(t,1)}let n=this._panelDisposables.get(e.id);n&&(n.dispose(),this._panelDisposables.delete(e.id)),this.removePanelFromTabGroup(e.id),this._onDidRemovePanel.fire({panel:e})}doAddPanel(e,t=this.panels.length,n){let r=this._panels.indexOf(e)>-1;this.tabsContainer.show(),this.contentContainer.show(),this.tabsContainer.openPanel(e,t),n?.skipSetActive?e.api.renderer===`always`&&this.contentContainer.renderPanel(e,{asActive:!1}):this.contentContainer.openPanel(e),!r&&(this.updateMru(e),this.panels.splice(t,0,e),this._panelDisposables.set(e.id,new ze(e.api.onDidTitleChange(e=>this._onDidPanelTitleChange.fire(e)),e.api.onDidParametersChange(e=>this._onDidPanelParametersChange.fire(e)))),this._onDidAddPanel.fire({panel:e}))}doSetActivePanel(e){if(this._activePanel!==e){if(this._activePanel=e,e){var t;this.tabsContainer.setActivePanel(e),this.contentContainer.setLabelledBy(this.tabsContainer.getTabId(e.id)),this.contentContainer.openPanel(e);let{width:n,height:r}=this.contentDimensions();e.layout(n,r),this.updateMru(e),this.contentContainer.refreshFocusState(),this._onDidActivePanelChange.fire({panel:e,origin:(t=this.accessor).currentOrigin?.call(t)??`user`})}this.updateAccessibleLabel()}}updateAccessibleLabel(){let e=this._activePanel?.title;e?this.container.setAttribute(`aria-label`,e):this.container.removeAttribute(`aria-label`)}updateMru(e){this.mostRecentlyUsed.includes(e)&&this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(e),1),this.mostRecentlyUsed=[e,...this.mostRecentlyUsed]}updateContainer(){this.panels.forEach(e=>e.runEvents());let e=this.isEmpty||!this._activePanel;if(e&&!this.watermark){let e=this.accessor.createWatermarkComponent();e.init({containerApi:this._api,group:this.groupPanel}),this.watermark=e,Q(this.watermark.element,`pointerdown`,()=>{this.isActive||this.accessor.doSetGroupActive(this.groupPanel)}),this.contentContainer.element.appendChild(this.watermark.element)}if(!e&&this.watermark){var t,n;this.watermark.element.remove(),(t=(n=this.watermark).dispose)==null||t.call(n),this.watermark=void 0}}canDisplayOverlay(e,t,n){let r=new ur(e,n,t,Le,this.accessor.getPanel(this.id));return this._onUnhandledDragOver.fire(r),r.isAccepted}canDisplayContentOverlay(e,t){if(this.locked===`no-drop-target`||this.locked&&t===`center`)return!1;let n=Le();return!n&&e.shiftKey&&this.location.type!==`floating`?!1:n?.viewId===this.accessor.id||this.canDisplayOverlay(e,t,`content`)}handleDropEvent(e,t,n,r,i){if(this.locked===`no-drop-target`)return;if(e===`content`&&i){this.accessor.dockToLayoutEdge(t,n);return}function a(){switch(e){case`header`:return typeof r==`number`?`tab`:`header_space`;case`content`:return`content`}}let o=typeof r==`number`?this.panels[r]:void 0,s=new Fr({nativeEvent:t,position:n,panel:o,getData:()=>Le(),kind:a(),group:this.groupPanel,api:this._api});if(this._onWillDrop.fire(s),s.defaultPrevented)return;let c=Le();if(c?.viewId===this.accessor.id){if(e===`content`&&c.groupId===this.id&&(n===`center`||c.panelId===null&&!c.tabGroupId)||e===`header`&&c.groupId===this.id&&c.panelId===null&&!c.tabGroupId)return;if(c.panelId===null){let{groupId:e}=c;this._onMove.fire({target:n,groupId:e,index:r,tabGroupId:c.tabGroupId});return}if(this.tabsContainer.indexOf(c.panelId)!==-1&&this.tabsContainer.size===1)return;let{groupId:t,panelId:i}=c;if(this.id===t&&!n&&this.tabsContainer.indexOf(i)===r)return;this._onMove.fire({target:n,groupId:c.groupId,itemId:c.panelId,index:r})}else this._onDidDrop.fire(new Pr({nativeEvent:t,position:n,panel:o,getData:()=>Le(),group:this.groupPanel,api:this._api}))}updateDragAndDropState(){this.tabsContainer.updateDragAndDropState()}dispose(){var e,t,n;super.dispose(),(e=this.watermark)==null||e.element.remove(),(t=this.watermark)==null||(n=t.dispose)==null||n.call(t),this.watermark=void 0;for(let e of[...this._tabGroups])e.dispose();for(let e of this._tabGroupDisposables.values())e.dispose();this._tabGroupDisposables.clear();for(let e of this._pendingMicrotaskDisposables)e.dispose();this._pendingMicrotaskDisposables.clear();for(let e of this.panels)e.dispose();this.tabsContainer.dispose(),this.contentContainer.dispose()}},Lr=class extends Bn{constructor(e,t,n){super(e,t),this._onDidConstraintsChangeInternal=new Z,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new Z,this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new Z,this.onDidSizeChange=this._onDidSizeChange.event,this.addDisposables(this._onDidConstraintsChangeInternal,this._onDidConstraintsChange,this._onDidSizeChange),n&&this.initialize(n)}setConstraints(e){this._onDidConstraintsChangeInternal.fire(e)}setSize(e){this._onDidSizeChange.fire(e)}},Rr=class extends Vn{get priority(){return this._priority}get snap(){return this._snap}get minimumWidth(){return this.__minimumWidth()}get minimumHeight(){return this.__minimumHeight()}get maximumHeight(){return this.__maximumHeight()}get maximumWidth(){return this.__maximumWidth()}__minimumWidth(){let e=typeof this._minimumWidth==`function`?this._minimumWidth():this._minimumWidth;return e!==this._evaluatedMinimumWidth&&(this._evaluatedMinimumWidth=e,this.updateConstraints()),e}__maximumWidth(){let e=typeof this._maximumWidth==`function`?this._maximumWidth():this._maximumWidth;return e!==this._evaluatedMaximumWidth&&(this._evaluatedMaximumWidth=e,this.updateConstraints()),e}__minimumHeight(){let e=typeof this._minimumHeight==`function`?this._minimumHeight():this._minimumHeight;return e!==this._evaluatedMinimumHeight&&(this._evaluatedMinimumHeight=e,this.updateConstraints()),e}__maximumHeight(){let e=typeof this._maximumHeight==`function`?this._maximumHeight():this._maximumHeight;return e!==this._evaluatedMaximumHeight&&(this._evaluatedMaximumHeight=e,this.updateConstraints()),e}get isActive(){return this.api.isActive}get isVisible(){return this.api.isVisible}constructor(e,t,n,r){super(e,t,r??new Lr(e,t)),this._evaluatedMinimumWidth=0,this._evaluatedMaximumWidth=2**53-1,this._evaluatedMinimumHeight=0,this._evaluatedMaximumHeight=2**53-1,this._minimumWidth=0,this._minimumHeight=0,this._maximumWidth=2**53-1,this._maximumHeight=2**53-1,this._snap=!1,this._onDidChange=new Z,this.onDidChange=this._onDidChange.event,typeof n?.minimumWidth==`number`&&(this._minimumWidth=n.minimumWidth),typeof n?.maximumWidth==`number`&&(this._maximumWidth=n.maximumWidth),typeof n?.minimumHeight==`number`&&(this._minimumHeight=n.minimumHeight),typeof n?.maximumHeight==`number`&&(this._maximumHeight=n.maximumHeight),this.api.initialize(this),this.addDisposables(this.api.onWillVisibilityChange(e=>{let{isVisible:t}=e,{accessor:n}=this._params;n.setVisible(this,t)}),this.api.onActiveChange(()=>{let{accessor:e}=this._params;e.doSetGroupActive(this)}),this.api.onDidConstraintsChangeInternal(e=>{(typeof e.minimumWidth==`number`||typeof e.minimumWidth==`function`)&&(this._minimumWidth=e.minimumWidth),(typeof e.minimumHeight==`number`||typeof e.minimumHeight==`function`)&&(this._minimumHeight=e.minimumHeight),(typeof e.maximumWidth==`number`||typeof e.maximumWidth==`function`)&&(this._maximumWidth=e.maximumWidth),(typeof e.maximumHeight==`number`||typeof e.maximumHeight==`function`)&&(this._maximumHeight=e.maximumHeight),this._onDidChange.fire(void 0)}),this.api.onDidSizeChange(e=>{this._onDidChange.fire({height:e.height,width:e.width})}),this._onDidChange)}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}init(e){e.maximumHeight&&(this._maximumHeight=e.maximumHeight),e.minimumHeight&&(this._minimumHeight=e.minimumHeight),e.maximumWidth&&(this._maximumWidth=e.maximumWidth),e.minimumWidth&&(this._minimumWidth=e.minimumWidth),this._priority=e.priority,this._snap=!!e.snap,super.init(e),typeof e.isVisible==`boolean`&&this.setVisible(e.isVisible)}updateConstraints(){this.api._onDidConstraintsChange.fire({minimumWidth:this._evaluatedMinimumWidth,maximumWidth:this._evaluatedMaximumWidth,minimumHeight:this._evaluatedMinimumHeight,maximumHeight:this._evaluatedMaximumHeight})}toJSON(){let e=super.toJSON(),t=e=>e===2**53-1?void 0:e,n=e=>e<=0?void 0:e;return tn(tn({},e),{},{minimumHeight:n(this.minimumHeight),maximumHeight:t(this.maximumHeight),minimumWidth:n(this.minimumWidth),maximumWidth:t(this.maximumWidth),snap:this.snap,priority:this.priority})}},zr=`dockview: DockviewGroupPanelApiImpl not initialized`,Br=class extends Lr{get location(){if(!this._group)throw Error(zr);return this._group.model.location}get boundingBox(){if(!this._group||this._group.model.location.type===`popout`)return;let e=this.accessor.element.getBoundingClientRect(),t=this._group.element.getBoundingClientRect();return{left:t.left-e.left,top:t.top-e.top,width:t.width,height:t.height}}get locked(){if(!this._group)throw Error(zr);return this._group.locked}set locked(e){if(!this._group)throw Error(zr);this._group.locked=e}constructor(e,t){super(e,`__dockviewgroup__`),this.accessor=t,this._onDidLocationChange=new Z,this.onDidLocationChange=this._onDidLocationChange.event,this._onDidActivePanelChange=new Z,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidCollapsedChange=new Z,this.onDidCollapsedChange=this._onDidCollapsedChange.event,this._onDidPeekChange=new Z,this.onDidPeekChange=this._onDidPeekChange.event,this._onDidHeaderDirectionChange=new Z,this.onDidHeaderDirectionChange=this._onDidHeaderDirectionChange.event,this.addDisposables(this._onDidLocationChange,this._onDidActivePanelChange,this._onDidCollapsedChange,this._onDidPeekChange,this._onDidHeaderDirectionChange,this._onDidVisibilityChange.event(e=>{e.isVisible&&this._pendingSize&&(super.setSize(this._pendingSize),this._pendingSize=void 0)}))}setSize(e){this._pendingSize=tn({},e),super.setSize(e)}close(){if(this._group)return this.accessor.removeGroup(this._group)}getWindow(){return this.location.type===`popout`?this.location.getWindow():globalThis.window}setHeaderPosition(e){if(!this._group)throw Error(zr);this._group.model.headerPosition=e}getHeaderPosition(){if(!this._group)throw Error(zr);return this._group.model.headerPosition}moveTo(e){if(!this._group)throw Error(zr);this.accessor.withOrigin(`api`,()=>{let t=e.group??this.accessor.addGroup({direction:bn(e.position??`right`),skipSetActive:e.skipSetActive??!1});this.accessor.moveGroupOrPanel({from:{groupId:this._group.id},to:{group:t,position:e.group?e.position??`center`:`center`,index:e.index},skipSetActive:e.skipSetActive})})}maximize(){if(!this._group)throw Error(zr);this.location.type===`grid`&&this.accessor.maximizeGroup(this._group)}isMaximized(){if(!this._group)throw Error(zr);return this.accessor.isMaximizedGroup(this._group)}exitMaximized(){if(!this._group)throw Error(zr);this.isMaximized()&&this.accessor.exitMaximizedGroup()}collapse(){this._group&&this.accessor.setEdgeGroupCollapsed(this._group,!0)}expand(){this._group&&this.accessor.setEdgeGroupCollapsed(this._group,!1)}isCollapsed(){return this._group?this.accessor.isEdgeGroupCollapsed(this._group):!1}isPeeking(){return this._group?this.accessor.isEdgeGroupPeeking(this._group):!1}setAutoHide(e){this._group&&this.accessor.setEdgeGroupAutoHide(this._group,e)}isAutoHide(){return this._group?this.accessor.isEdgeGroupAutoHide(this._group):!1}initialize(e){this._group=e}},Vr=100,Hr=100,Ur=class extends Rr{get minimumWidth(){if(typeof this._explicitConstraints.minimumWidth==`number`)return this._explicitConstraints.minimumWidth;let e=this.activePanel?.minimumWidth;return typeof e==`number`?e:super.__minimumWidth()}get minimumHeight(){if(typeof this._explicitConstraints.minimumHeight==`number`)return this._explicitConstraints.minimumHeight;let e=this.activePanel?.minimumHeight;return typeof e==`number`?e:super.__minimumHeight()}get maximumWidth(){if(typeof this._explicitConstraints.maximumWidth==`number`)return this._explicitConstraints.maximumWidth;let e=this.activePanel?.maximumWidth;return typeof e==`number`?e:super.__maximumWidth()}get maximumHeight(){if(typeof this._explicitConstraints.maximumHeight==`number`)return this._explicitConstraints.maximumHeight;let e=this.activePanel?.maximumHeight;return typeof e==`number`?e:super.__maximumHeight()}get panels(){return this._model.panels}get activePanel(){return this._model.activePanel}get size(){return this._model.size}get model(){return this._model}get locked(){return this._model.locked}set locked(e){this._model.locked=e}get header(){return this._model.header}constructor(e,t,n){super(t,`groupview_default`,{minimumHeight:n.constraints?.minimumHeight??Hr,minimumWidth:n.constraints?.minimumWidth??Vr,maximumHeight:n.constraints?.maximumHeight,maximumWidth:n.constraints?.maximumWidth},new Br(t,e)),this._explicitConstraints={},this.api.initialize(this),this._model=new Ir(this.element,e,t,n,this),this.addDisposables(this.model.onDidActivePanelChange(e=>{this.api._onDidActivePanelChange.fire(e)}),this.api.onDidConstraintsChangeInternal(e=>{e.minimumWidth!==void 0&&(this._explicitConstraints.minimumWidth=typeof e.minimumWidth==`function`?e.minimumWidth():e.minimumWidth),e.minimumHeight!==void 0&&(this._explicitConstraints.minimumHeight=typeof e.minimumHeight==`function`?e.minimumHeight():e.minimumHeight),e.maximumWidth!==void 0&&(this._explicitConstraints.maximumWidth=typeof e.maximumWidth==`function`?e.maximumWidth():e.maximumWidth),e.maximumHeight!==void 0&&(this._explicitConstraints.maximumHeight=typeof e.maximumHeight==`function`?e.maximumHeight():e.maximumHeight)}))}focus(){this.api.isActive||this.api.setActive(),super.focus()}initialize(){this._model.initialize()}setActive(e){super.setActive(e),this.model.setActive(e)}layout(e,t){super.layout(e,t),this.model.layout(e,t)}relayout(){this.model.relayout()}getComponent(){return this._model}toJSON(){return this.model.toJSON()}},Wr={name:`abyss`,className:`dockview-theme-abyss`,colorScheme:`dark`,tabGroupIndicator:`none`},Gr=class extends Lr{get location(){return this.group.api.location}get title(){return this.panel.title}get isPinned(){return this.panel.isPinned}get isGroupActive(){return this.group.isActive}get renderer(){return this.panel.renderer}set group(e){let t=this._group;this._group!==e&&(this._group=e,this._onDidGroupChange.fire({}),this.setupGroupEventListeners(t),this.fireLocationChange())}get group(){return this._group}get tabComponent(){return this._tabComponent}constructor(e,t,n,r,i){super(e.id,r),this.panel=e,this.accessor=n,this._onDidTitleChange=new Z,this.onDidTitleChange=this._onDidTitleChange.event,this._onDidChangePinned=new Z,this.onDidChangePinned=this._onDidChangePinned.event,this._onDidActiveGroupChange=new Z,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._onDidGroupChange=new Z,this.onDidGroupChange=this._onDidGroupChange.event,this._onDidRendererChange=new Z,this.onDidRendererChange=this._onDidRendererChange.event,this._onDidLocationChange=new Z,this.onDidLocationChange=this._onDidLocationChange.event,this.groupEventsDisposable=new Be,this._tabComponent=i,this.initialize(e),this._group=t,this.setupGroupEventListeners(),this.addDisposables(this.groupEventsDisposable,this._onDidRendererChange,this._onDidTitleChange,this._onDidChangePinned,this._onDidGroupChange,this._onDidActiveGroupChange,this._onDidLocationChange)}getWindow(){return this.group.api.getWindow()}setActive(){this.accessor.withOrigin(`api`,()=>super.setActive())}moveTo(e){this.accessor.withOrigin(`api`,()=>this.accessor.moveGroupOrPanel({from:{groupId:this._group.id,panelId:this.panel.id},to:{group:e.group??this._group,position:e.group?e.position??`center`:`center`,index:e.index},skipSetActive:e.skipSetActive}))}setTitle(e){this.panel.setTitle(e)}setPinned(e){this.accessor.setPanelPinned(this.panel,e)}setRenderer(e){this.panel.setRenderer(e)}close(){this.group.model.closePanel(this.panel)}maximize(){this.group.api.maximize()}isMaximized(){return this.group.api.isMaximized()}exitMaximized(){this.group.api.exitMaximized()}fireLocationChange(){this.accessor.deferLocationChange(this,()=>{this.isDisposed||this._onDidLocationChange.fire({location:this.location})})}setupGroupEventListeners(e){let t=e?.isActive??!1;this.groupEventsDisposable.value=new ze(this.group.api.onDidVisibilityChange(e=>{let t=!e.isVisible&&this.isVisible,n=e.isVisible&&!this.isVisible,r=this.group.model.isPanelActive(this.panel);(t||n&&r)&&this._onDidVisibilityChange.fire(e)}),this.group.api.onDidLocationChange(()=>{this.group===this.panel.group&&this.fireLocationChange()}),this.group.api.onDidActiveChange(()=>{this.group===this.panel.group&&t!==this.isGroupActive&&(t=this.isGroupActive,this._onDidActiveGroupChange.fire({isActive:this.isGroupActive}))}))}},Kr=class extends ze{get params(){return this._params}get title(){return this._title}get isPinned(){return this._pinned}get group(){return this._group}get renderer(){return this._renderer??this.accessor.renderer}get minimumWidth(){return this._minimumWidth}get minimumHeight(){return this._minimumHeight}get maximumWidth(){return this._maximumWidth}get maximumHeight(){return this._maximumHeight}constructor(e,t,n,r,i,a,o,s){super(),this.id=e,this.accessor=r,this.containerApi=i,this.view=o,this._pinned=!1,this._renderer=s.renderer,this._group=a,this._minimumWidth=s.minimumWidth,this._minimumHeight=s.minimumHeight,this._maximumWidth=s.maximumWidth,this._maximumHeight=s.maximumHeight,this.api=new Gr(this,this._group,r,t,n),this.addDisposables(this.api.onActiveChange(()=>{r.setActivePanel(this)}),this.api.onDidSizeChange(e=>{this.group.api.setSize(e)}),this.api.onDidRendererChange(()=>{this.group.model.rerender(this)}))}init(e){this._params=e.params,this.view.init(tn(tn({},e),{},{api:this.api,containerApi:this.containerApi})),this.setTitle(e.title)}focus(){let e=new zn;this.api._onWillFocus.fire(e),!e.defaultPrevented&&(this.api.isActive||this.api.setActive())}toJSON(){return{id:this.id,contentComponent:this.view.contentComponent,tabComponent:this.view.tabComponent,params:Object.keys(this._params||{}).length>0?this._params:void 0,title:this.title,renderer:this._renderer,minimumHeight:this._minimumHeight,maximumHeight:this._maximumHeight,minimumWidth:this._minimumWidth,maximumWidth:this._maximumWidth,pinned:this._pinned?!0:void 0}}setTitle(e){e!==this.title&&(this._title=e,this.view.setTitle(e),this.api._onDidTitleChange.fire({title:e}))}setPinned(e){this._pinned!==e&&(this._pinned=e,this.api._onDidChangePinned.fire({isPinned:e}))}setRenderer(e){e!==this.renderer&&(this._renderer=e,this.api._onDidRendererChange.fire({renderer:e}))}update(e){this._params=tn(tn({},this._params),e.params);for(let t of Object.keys(e.params))e.params[t]===void 0&&delete this._params[t];this.view.update({params:this._params})}updateFromStateModel(e){this._maximumHeight=e.maximumHeight,this._minimumHeight=e.minimumHeight,this._maximumWidth=e.maximumWidth,this._minimumWidth=e.minimumWidth,this._params=e.params??{},this.view.update({params:this._params}),this.setTitle(e.title??this.id),this.setRenderer(e.renderer??this.accessor.renderer),this.setPinned((e.pinned??!1)&&!!this.accessor.options.pinnedTabs?.enabled)}updateParentGroup(e,t){this._group=e,this.api.group=this._group;let n=this._group.model.isPanelActive(this),r=this.group.api.isActive&&n;t?.skipSetActive||this.api.isActive!==r&&this.api._onDidActiveChange.fire({isActive:this.group.api.isActive&&n}),this.api.isVisible!==n&&this.api._onDidVisibilityChange.fire({isVisible:n})}runEvents(){let e=this._group.model.isPanelActive(this),t=this.group.api.isActive&&e;this.api.isActive!==t&&this.api._onDidActiveChange.fire({isActive:this.group.api.isActive&&e}),this.api.isVisible!==e&&this.api._onDidVisibilityChange.fire({isVisible:e})}layout(e,t){this.api._onDidDimensionChange.fire({width:e,height:t}),this.view.layout(e,t)}dispose(){this.api.dispose(),this.view.dispose()}},qr=class extends ze{get element(){return this._element}constructor(){super(),this._messages=an,this._element=document.createElement(`div`),this._element.className=`dv-default-tab`,this._content=document.createElement(`div`),this._content.className=`dv-default-tab-content`,this.action=document.createElement(`div`),this.action.className=`dv-default-tab-action`,this.action.setAttribute(`role`,`button`),this.action.setAttribute(`tabindex`,`-1`);let e=Kn();e.setAttribute(`aria-hidden`,`true`),this.action.appendChild(e),this._element.appendChild(this._content),this._element.appendChild(this.action),this.render()}init(e){this._title=e.title,this._messages=e.containerApi.messages??an,this.addDisposables(e.api.onDidTitleChange(e=>{this._title=e.title,this.render()}),Q(this.action,`pointerdown`,e=>{e.preventDefault()}),Q(this.action,`click`,t=>{t.defaultPrevented||(t.preventDefault(),e.api.close())})),this.render()}render(){this._content.textContent!==this._title&&(this._content.textContent=this._title??``),this.action.setAttribute(`aria-label`,this._title?this._messages.closeTab(this._title):this._messages.closeTabPlain())}},Jr=class{get content(){return this._content}get tab(){return this._tab}constructor(e,t,n,r){this.accessor=e,this.id=t,this.contentComponent=n,this.tabComponent=r,this._content=this.createContentComponent(this.id,n),this._tab=this.createTabComponent(this.id,r)}createTabRenderer(e){let t=this.createTabComponent(this.id,this.tabComponent);if(this._params&&t.init(tn(tn({},this._params),{},{tabLocation:e})),this._updateEvent){var n;(n=t.update)==null||n.call(t,this._updateEvent)}return t}init(e){this._params=e,this.content.init(e),this.tab.init(tn(tn({},e),{},{tabLocation:`header`}))}setTitle(e){this._params&&(this._params.title=e)}layout(e,t){var n,r;(n=(r=this.content).layout)==null||n.call(r,e,t)}update(e){var t,n,r,i;this._updateEvent=e,(t=(n=this.content).update)==null||t.call(n,e),(r=(i=this.tab).update)==null||r.call(i,e)}dispose(){var e,t,n,r;(e=(t=this.content).dispose)==null||e.call(t),(n=(r=this.tab).dispose)==null||n.call(r)}createContentComponent(e,t){return this.accessor.options.createComponent({id:e,name:t})}createTabComponent(e,t){let n=t??this.accessor.options.defaultTabComponent;if(n){if(this.accessor.options.createTabComponent)return this.accessor.options.createTabComponent({id:e,name:n})||new qr;console.warn(`dockview: tabComponent '${t}' was not found. falling back to the default tab.`)}return new qr}},Yr=class{constructor(e){this.accessor=e}fromJSON(e,t){let n=e.id,r=e.params,i=e.title,a=e.view,o=a?a.content.id:e.contentComponent??`unknown`,s=a?a.tab?.id:e.tabComponent,c=new Jr(this.accessor,n,o,s),l=new Kr(n,o,s,this.accessor,new sn(this.accessor),t,c,{renderer:e.renderer,minimumWidth:e.minimumWidth,minimumHeight:e.minimumHeight,maximumWidth:e.maximumWidth,maximumHeight:e.maximumHeight});return l.init({title:i??n,params:r??{}}),e.pinned&&this.accessor.options.pinnedTabs?.enabled&&l.setPinned(!0),l}},Xr=class extends ze{get element(){return this._element}constructor(){super(),this._element=document.createElement(`div`),this._element.className=`dv-watermark`}init(e){}},Zr=new class{constructor(){this._orderedList=[]}push(e){this._orderedList=[...this._orderedList.filter(t=>t!==e),e],this.update()}destroy(e){this._orderedList=this._orderedList.filter(t=>t!==e),this.update()}update(){for(let e=0;e<this._orderedList.length;e++)this._orderedList[e].setAttribute(`aria-level`,`${e}`),this._orderedList[e].style.zIndex=`calc(var(--dv-overlay-z-index, 999) + ${e*2})`}},Qr=class e extends ze{set minimumInViewportWidth(e){this.options.minimumInViewportWidth=e}set minimumInViewportHeight(e){this.options.minimumInViewportHeight=e}get element(){return this._element}get isVisible(){return this._isVisible}get headerHeight(){return this.options.header?.offsetHeight??0}constructor(e){super(),this.options=e,this._element=document.createElement(`div`),this._onDidChange=new Z,this.onDidChange=this._onDidChange.event,this._onDidChangeEnd=new Z,this.onDidChangeEnd=this._onDidChangeEnd.event,this._onDidStartMoving=new Z,this.onDidStartMoving=this._onDidStartMoving.event,this._dragMove=new Be,this._dragCancelled=!1,this.addDisposables(this._onDidChange,this._onDidChangeEnd,this._onDidStartMoving,this._dragMove),this._element.className=`dv-resize-container`,this._element.setAttribute(`role`,`dialog`),this._element.setAttribute(`aria-modal`,`false`),this._isVisible=!0,this.setupResize(`top`),this.setupResize(`bottom`),this.setupResize(`left`),this.setupResize(`right`),this.setupResize(`topleft`),this.setupResize(`topright`),this.setupResize(`bottomleft`),this.setupResize(`bottomright`),this.options.header&&($(this._element,`dv-resize-container-with-titlebar`,!0),this._element.appendChild(this.options.header)),this._element.appendChild(this.options.content),this.options.container.appendChild(this._element),this.setBounds(tn(tn(tn(tn({height:this.options.height,width:this.options.width},`top`in this.options&&{top:this.options.top}),`bottom`in this.options&&{bottom:this.options.bottom}),`left`in this.options&&{left:this.options.left}),`right`in this.options&&{right:this.options.right})),Zr.push(this._element)}setVisible(e){e!==this.isVisible&&(this._isVisible=e,$(this.element,`dv-hidden`,!this.isVisible))}bringToFront(){Zr.push(this._element)}setBounds(e={}){typeof e.height==`number`&&(this._element.style.height=`${e.height}px`),typeof e.width==`number`&&(this._element.style.width=`${e.width}px`),`top`in e&&typeof e.top==`number`&&(this._element.style.top=`${e.top}px`,this._element.style.bottom=`auto`,this.verticalAlignment=`top`),`bottom`in e&&typeof e.bottom==`number`&&(this._element.style.bottom=`${e.bottom}px`,this._element.style.top=`auto`,this.verticalAlignment=`bottom`),`left`in e&&typeof e.left==`number`&&(this._element.style.left=`${e.left}px`,this._element.style.right=`auto`,this.horiziontalAlignment=`left`),`right`in e&&typeof e.right==`number`&&(this._element.style.right=`${e.right}px`,this._element.style.left=`auto`,this.horiziontalAlignment=`right`);let t=this.options.container.getBoundingClientRect(),n=this._element.getBoundingClientRect(),r=Math.max(0,this.getMinimumWidth(n.width)),i=Math.max(0,this.getMinimumHeight(n.height));if(this.verticalAlignment===`top`){let e=wt(n.top-t.top,-i,Math.max(0,t.height-n.height+i));this._element.style.top=`${e}px`,this._element.style.bottom=`auto`}if(this.verticalAlignment===`bottom`){let e=wt(t.bottom-n.bottom,-i,Math.max(0,t.height-n.height+i));this._element.style.bottom=`${e}px`,this._element.style.top=`auto`}if(this.horiziontalAlignment===`left`){let e=wt(n.left-t.left,-r,Math.max(0,t.width-n.width+r));this._element.style.left=`${e}px`,this._element.style.right=`auto`}if(this.horiziontalAlignment===`right`){let e=wt(t.right-n.right,-r,Math.max(0,t.width-n.width+r));this._element.style.right=`${e}px`,this._element.style.left=`auto`}this._onDidChange.fire()}toJSON(){let e=this.options.container.getBoundingClientRect(),t=this._element.getBoundingClientRect(),n={};return this.verticalAlignment===`top`?n.top=Number.parseFloat(this._element.style.top):this.verticalAlignment===`bottom`?n.bottom=Number.parseFloat(this._element.style.bottom):n.top=t.top-e.top,this.horiziontalAlignment===`left`?n.left=Number.parseFloat(this._element.style.left):this.horiziontalAlignment===`right`?n.right=Number.parseFloat(this._element.style.right):n.left=t.left-e.left,n.width=t.width,n.height=t.height,n}cancelPendingDrag(){this._dragMove.value&&(this._dragCancelled=!0,$(this._element,`dv-resize-container-dragging`,!1),this._dragMove.value=Re.NONE)}setupDrag(e,t){let n=(e,t)=>{var n;let r=null,i=!1;this._dragCancelled=!1;let a=this.options.transformDragPosition?(n=this.options).getSiblingBoxes?.call(n)??[]:[],o=lt();if(e&&typeof t==`number`&&typeof e.setPointerCapture==`function`)try{e.setPointerCapture(t)}catch{}let s=()=>{$(this._element,`dv-resize-container-dragging`,!1),this._dragMove.value=Re.NONE,this._onDidChangeEnd.fire()};this._dragMove.value=new ze({dispose:()=>{if(o.release(),e&&typeof t==`number`&&typeof e.releasePointerCapture==`function`)try{e.releasePointerCapture(t)}catch{}}},Q(globalThis.window,`pointermove`,e=>{if(this._dragCancelled)return;let t=this.options.container.getBoundingClientRect(),n=e.clientX-t.left,o=e.clientY-t.top;$(this._element,`dv-resize-container-dragging`,!0);let s=this._element.getBoundingClientRect();r??={x:e.clientX-s.left,y:e.clientY-s.top};let c=Math.max(0,this.getMinimumWidth(s.width)),l=Math.max(0,this.getMinimumHeight(s.height)),u=o-r.y,d=n-r.x;if(this.options.transformDragPosition){let n=this.options.transformDragPosition({proposed:{top:u,left:d,width:s.width,height:s.height},container:{width:t.width,height:t.height},others:a,modifiers:{altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey}});n&&(u=n.top,d=n.left)}let f=Math.max(0,t.height-s.height+l),p=Math.max(0,t.width-s.width+c),m=wt(u,-l,f),h=wt(t.height-s.height-u,-l,f),g=wt(d,-c,p),_=wt(t.width-s.width-d,-c,p),v={};m<=h?v.top=m:v.bottom=h,g<=_?v.left=g:v.right=_,this.setBounds(v),i||(i=!0,this._onDidStartMoving.fire())}),Q(globalThis.window,`pointerup`,s),Q(globalThis.window,`pointercancel`,s))};this.addDisposables(Q(e,`pointerdown`,t=>{if(t.defaultPrevented){t.preventDefault();return}rt(t)||n(e,t.pointerId)}),Q(this.options.content,`pointerdown`,e=>{e.defaultPrevented||rt(e)||e.shiftKey&&n(this.options.content,e.pointerId)}),Q(this.options.content,`pointerdown`,()=>{Zr.push(this._element)},!0)),t?.inDragMode&&n()}setupResize(t){let n=document.createElement(`div`);n.className=`dv-resize-handle-${t}`,this._element.appendChild(n);let r=new Be;this.addDisposables(r,Q(n,`pointerdown`,i=>{i.preventDefault();let a=null,o=lt(),s=i.pointerId;if(typeof n.setPointerCapture==`function`)try{n.setPointerCapture(s)}catch{}let c=()=>{r.dispose(),this._onDidChangeEnd.fire()};r.value=new ze(Q(globalThis.window,`pointermove`,n=>{let r=this.options.container.getBoundingClientRect(),i=this._element.getBoundingClientRect(),o=n.clientY-r.top,s=n.clientX-r.left;a??={originalY:o,originalHeight:i.height,originalX:s,originalWidth:i.width};let c,l,u,d,f,p,m=()=>{let t=a.originalY+a.originalHeight>r.height?Math.max(0,r.height-e.MINIMUM_HEIGHT):Math.max(0,a.originalY+a.originalHeight-e.MINIMUM_HEIGHT);c=wt(o,0,t),u=a.originalY+a.originalHeight-c,l=r.height-c-u},h=()=>{c=a.originalY-a.originalHeight;let t=c<0&&typeof this.options.minimumInViewportHeight==`number`?-c+this.options.minimumInViewportHeight:e.MINIMUM_HEIGHT,n=r.height-Math.max(0,c);u=wt(o-c,t,n),l=r.height-c-u},g=()=>{let t=a.originalX+a.originalWidth>r.width?Math.max(0,r.width-e.MINIMUM_WIDTH):Math.max(0,a.originalX+a.originalWidth-e.MINIMUM_WIDTH);d=wt(s,0,t),p=a.originalX+a.originalWidth-d,f=r.width-d-p},_=()=>{d=a.originalX-a.originalWidth;let t=d<0&&typeof this.options.minimumInViewportWidth==`number`?-d+this.options.minimumInViewportWidth:e.MINIMUM_WIDTH,n=r.width-Math.max(0,d);p=wt(s-d,t,n),f=r.width-d-p};switch(t){case`top`:m();break;case`bottom`:h();break;case`left`:g();break;case`right`:_();break;case`topleft`:m(),g();break;case`topright`:m(),_();break;case`bottomleft`:h(),g();break;case`bottomright`:h(),_()}let v={};c<=l?v.top=c:v.bottom=l,d<=f?v.left=d:v.right=f,v.height=u,v.width=p,this.setBounds(v)}),{dispose:()=>{if(o.release(),typeof n.releasePointerCapture==`function`)try{n.releasePointerCapture(s)}catch{}}},Q(globalThis.window,`pointerup`,c),Q(globalThis.window,`pointercancel`,c))}))}getMinimumWidth(e){return typeof this.options.minimumInViewportWidth==`number`?e-this.options.minimumInViewportWidth:0}getMinimumHeight(e){return typeof this.options.minimumInViewportHeight==`number`?e-this.options.minimumInViewportHeight:0}dispose(){Zr.destroy(this._element),this._element.remove(),super.dispose()}};Qr.MINIMUM_HEIGHT=20,Qr.MINIMUM_WIDTH=20;var $r=class extends ze{get element(){return this._element}get group(){return this._group}setGroup(e){this._group=e}constructor(e,t){super(),this.accessor=e,this._onDragStart=new Z,this.onDragStart=this._onDragStart.event,this._group=t,this._element=document.createElement(`div`),this._element.className=`dv-floating-titlebar`,this.addDisposables(this._onDragStart,Q(this._element,`pointerdown`,()=>{this.accessor.doSetGroupActive(this._group)}),Q(this._element,`pointerdown`,e=>{e.shiftKey&&nt(e)},!0)),this.dragSource=new ir({element:this._element,accessor:this.accessor,group:()=>this._group}),this.addDisposables(this.dragSource,this.dragSource.onDragStart(e=>{this._onDragStart.fire(e)}))}updateDragAndDropState(){this.dragSource.updateDragAndDropState()}};function ei(e){return{moduleName:e.name,options:e.options,services:{[e.serviceKey]:e.create},init:e.init?(t,n)=>e.init(t,n[e.serviceKey]):void 0,dependsOn:e.dependsOn}}var ti=new Set([`AdvancedOverflow`,`AutoEdgeGroup`,`AutoHideEdgeGroup`,`ContextMenu`,`DndCompass`,`KeyboardDocking`,`KeyboardNavigation`,`LayoutHistory`,`License`,`MultiRowTabs`,`PinnedTabs`,`SmartGuides`]),ni=new Set;function ri(e,t){let n=t===void 0?[]:[].concat(t),r=n.map(e=>`\`${e}\``).join(`, `),i=n.length>1?`require`:`requires`,a=n.length?`${r} ${i} the "${e}" module`:`The "${e}" module is required`;return ti.has(e)?`dockview: ${a}, which ships in dockview-enterprise.\n\n npm install dockview-enterprise\n import 'dockview-enterprise'; // self-registers every enterprise module\n`:`dockview: ${a}, but it is not registered.`}function ii(e,t){let n=`${e}|${(t===void 0?[]:[].concat(t)).join(`|`)}`;ni.has(n)||(ni.add(n),console.error(ri(e,t)))}function ai(e,t,n){if(e!==void 0)return e;ii(t,n)}var oi=class{constructor(){this._modules=new Map,this._services={},this._initDisposables=[]}get services(){return this._services}register(e){if(!this._modules.has(e.moduleName)){if(e.dependsOn)for(let t of e.dependsOn)this.register(t);this._modules.set(e.moduleName,e)}}initialize(e){for(let t of this._modules.values())if(t.services)for(let[n,r]of Object.entries(t.services))this._services[n]=r(e)}postConstruct(e){for(let t of this._modules.values())t.init&&this._initDisposables.push(t.init(e,this._services))}has(e){return this._modules.has(e)}dispose(){for(let e of this._initDisposables)e.dispose();this._initDisposables.length=0;for(let e of Object.values(this._services))e!==void 0&&typeof e.dispose==`function`&&e.dispose()}},si=[];function ci(){return[...si]}var li=[{optionKey:`smartGuides`,reason:`smartGuides`,moduleName:`SmartGuides`,when:e=>!!e.smartGuides&&e.smartGuides.enabled!==!1},{optionKey:`layoutHistory`,reason:`layoutHistory.enabled: true`,moduleName:`LayoutHistory`,when:e=>e.layoutHistory?.enabled===!0},{optionKey:`pinnedTabs`,reason:`pinnedTabs.enabled: true`,moduleName:`PinnedTabs`,when:e=>e.pinnedTabs?.enabled===!0},{optionKey:`overflow`,reason:`overflow.mode: 'wrap'`,moduleName:`MultiRowTabs`,when:e=>e.overflow?.mode===`wrap`},{optionKey:`overflow`,reason:`overflow.maxRows`,moduleName:`MultiRowTabs`,when:e=>e.overflow?.maxRows!=null},{optionKey:`overflow`,reason:`overflow.search`,moduleName:`AdvancedOverflow`,when:e=>!!e.overflow?.search},{optionKey:`overflow`,reason:`overflow.mru`,moduleName:`AdvancedOverflow`,when:e=>!!e.overflow?.mru},{optionKey:`autoHideEdgeGroups`,reason:`autoHideEdgeGroups`,moduleName:`AutoHideEdgeGroup`,when:e=>lr(e.autoHideEdgeGroups)},{optionKey:`dockToEdgeGroups`,reason:`dockToEdgeGroups`,moduleName:`AutoEdgeGroup`,when:e=>lr(e.dockToEdgeGroups)},{optionKey:`getTabContextMenuItems`,reason:`getTabContextMenuItems`,moduleName:`ContextMenu`,when:e=>e.getTabContextMenuItems!=null},{optionKey:`getTabGroupChipContextMenuItems`,reason:`getTabGroupChipContextMenuItems`,moduleName:`ContextMenu`,when:e=>e.getTabGroupChipContextMenuItems!=null},{optionKey:`dndCompass`,reason:`dndCompass`,moduleName:`DndCompass`,when:e=>!!e.dndCompass},{optionKey:`keyboardNavigation`,reason:`keyboardNavigation`,moduleName:`KeyboardNavigation`,when:e=>!!e.keyboardNavigation}];function ui(e,t){let n=new Map;for(let r of li){if(!r.when(e)||t(r.moduleName))continue;let i=n.get(r.moduleName);i?i.push(r.reason):n.set(r.moduleName,[r.reason])}for(let[e,t]of n)ii(e,t)}var di={left:100,top:100,width:300,height:300},fi=class extends ze{get group(){return this._group}setTitleBar(e){this._titleBar=e}setAnchorGroup(e){var t;this._group=e,(t=this._titleBar)==null||t.setGroup(e)}constructor(e,t,n){super(),this.overlay=t,this.gridview=n,this._group=e,this.addDisposables(t,{dispose:()=>this.gridview.dispose()})}position(e){this.overlay.setBounds(e)}},pi=class{get floatingGroups(){return this._floatingGroups}constructor(e){this._floatingGroups=[],this._host=e}add(e,t,n){let r=new fi(e,t,n),i=new ze(e.api.onDidActiveChange(e=>{e.isActive&&t.bringToFront()}),(()=>{let e=-1,t=-1;return Ye(n.element,r=>{let i=Math.round(r.contentRect.width),a=Math.round(r.contentRect.height);(i!==e||a!==t)&&(e=i,t=a,n.layout(i,a))})})()),a=()=>{let n=e.activePanel?.title;n?t.element.setAttribute(`aria-label`,n):t.element.removeAttribute(`aria-label`)};return a(),r.addDisposables(e.api.onDidActivePanelChange(()=>a()),t.onDidChange(()=>{n.layout(n.width,n.height)}),t.onDidChangeEnd(()=>{this._host.fireLayoutChange()}),e.onDidChange(e=>{t.setBounds({height:typeof e?.height==`number`?e.height+t.headerHeight:e?.height,width:e?.width})}),{dispose:()=>{i.dispose(),Ct(this._floatingGroups,r),e.model.location={type:`grid`}}}),this._floatingGroups.push(r),r}findByGroup(e){return this._floatingGroups.find(t=>t.group===e||t.gridview.element.contains(e.element))}serialize(){return this._floatingGroups.map(e=>{let t=e.gridview.serialize(),n=e.overlay.toJSON(),r=t.root;return r.type===`branch`&&r.data.length===1&&r.data[0].type===`leaf`?{data:r.data[0].data,position:n}:{grid:t,position:n}})}constrainBounds(){for(let e of this._floatingGroups)e.overlay.setBounds()}updateBounds(e){if(`floatingGroupBounds`in e)for(let t of this._floatingGroups){switch(e.floatingGroupBounds){case`boundedWithinViewport`:t.overlay.minimumInViewportHeight=void 0,t.overlay.minimumInViewportWidth=void 0;break;case void 0:t.overlay.minimumInViewportHeight=100,t.overlay.minimumInViewportWidth=100;break;default:t.overlay.minimumInViewportHeight=e.floatingGroupBounds?.minimumHeightWithinViewport,t.overlay.minimumInViewportWidth=e.floatingGroupBounds?.minimumWidthWithinViewport}t.overlay.setBounds()}}disposeAll(){for(let e of[...this._floatingGroups])e.dispose()}dispose(){this.disposeAll()}},mi=ei({name:`FloatingGroup`,serviceKey:`floatingGroupService`,create:e=>new pi(e)}),hi=class{constructor(e){this._entries=[],this._restorationCleanups=new Set,this._restorationPromise=Promise.resolve(),this._onDidRemove=new Z,this.onDidRemove=this._onDidRemove.event,this._host=e}get entries(){return this._entries}get restorationPromise(){return this._restorationPromise}add(e){this._entries.push(e)}remove(e){Ct(this._entries,e)&&!this._host.isDisposed&&this._onDidRemove.fire(e)}findByGroup(e){return this._entries.find(t=>t.popoutGroup===e||t.gridview.element.contains(e.element))}findReferenceGroupId(e){return this._entries.find(t=>t.popoutGroup===e)?.referenceGroup}observeGridviewSize(e,t,n){let r=e.window?.ResizeObserver;if(!r)return;let i=-1,a=-1,o=()=>{let r=e.window;if(this._host.isDisposed||!r||r.closed)return;let o=Math.round(t.element.clientWidth),s=Math.round(t.element.clientHeight);(o!==i||s!==a)&&(i=o,a=s,o>0&&s>0&&t.layout(o,s),n.updateAllPositions())},s=new r(()=>{let t=e.window?.requestAnimationFrame;t?t.call(e.window,o):o()});return s.observe(t.element),{dispose:()=>s.disconnect()}}scheduleRestoration(e,t,n){return new Promise(r=>{let i=()=>{this._restorationCleanups.delete(i),clearTimeout(a),n?.(),r()},a=setTimeout(()=>{if(this._restorationCleanups.delete(i),this._host.isDisposed){r();return}t(),r()},e);this._restorationCleanups.add(i)})}finishRestoration(e){this._restorationPromise=Promise.all(e).then(()=>void 0)}cancelPendingRestorations(){for(let e of[...this._restorationCleanups])e();this._restorationCleanups.clear()}serialize(){return this._entries.map(e=>{let t=e.gridview.serialize(),n=t.root,r=e.popoutGroup.api.location.type===`popout`?e.popoutGroup.api.location.popoutUrl:void 0,i={gridReferenceGroup:e.referenceGroup,position:e.window.dimensions(),url:r};return n.type===`branch`&&n.data.length===1&&n.data[0].type===`leaf`?tn(tn({},i),{},{data:n.data[0].data}):tn(tn({},i),{},{grid:t})})}disposeAll(){for(let e of[...this._entries])e.disposable.dispose()}dispose(){this.cancelPendingRestorations(),this.disposeAll(),this._onDidRemove.dispose()}},gi=ei({name:`PopoutWindow`,serviceKey:`popoutWindowService`,create:e=>new hi(e)}),_i=class{constructor(e){this._watermark=null,this._host=e}update(){if(this._host.hasVisibleGridGroup()){this._unmount();return}if(this._watermark)return;this._watermark=this._host.createWatermarkComponent(),this._watermark.init({containerApi:this._host.api});let e=document.createElement(`div`);e.className=`dv-watermark-container`,st(e,`watermark-component`),e.appendChild(this._watermark.element),this._host.mountElement.appendChild(e)}refresh(){this._unmount(),this.update()}_unmount(){var e,t;this._watermark&&=(this._watermark.element.parentElement.remove(),(e=(t=this._watermark).dispose)==null||e.call(t),null)}dispose(){this._unmount()}},vi=ei({name:`Watermark`,serviceKey:`watermarkService`,create:e=>new _i(e),init:(e,t)=>(t.update(),new ze(Ve.any(e.onDidAdd,e.onDidRemove)(()=>{t.update()}),e.onDidViewVisibilityChangeMicroTaskQueue(()=>{t.update()})))}),yi=class{constructor(){this._edgeGroups=new Map,this._edgeGroupDisposables=new Map,this._autoHide=new WeakMap,this._autoReveal=new WeakMap}add(e,t,n){this._edgeGroups.set(e,t),this._edgeGroupDisposables.set(e,n)}remove(e){var t;(t=this._edgeGroupDisposables.get(e))==null||t.dispose(),this._edgeGroupDisposables.delete(e),this._edgeGroups.delete(e)}get(e){return this._edgeGroups.get(e)}has(e){return this._edgeGroups.has(e)}hasAny(){return this._edgeGroups.size>0}entries(){return this._edgeGroups.entries()}includes(e){for(let t of this._edgeGroups.values())if(t===e)return!0;return!1}findPositionOf(e){for(let[t,n]of this._edgeGroups)if(n===e)return t}setAutoHide(e,t){t===void 0?this._autoHide.delete(e):this._autoHide.set(e,t)}isAutoHide(e){return this._autoHide.get(e)}setAutoReveal(e,t){this._autoReveal.set(e,t)}isAutoReveal(e){return this._autoReveal.get(e)??!1}disposeAll(){for(let e of this._edgeGroupDisposables.values())e.dispose();this._edgeGroupDisposables.clear(),this._edgeGroups.clear()}dispose(){this.disposeAll()}},bi=ei({name:`EdgeGroup`,serviceKey:`edgeGroupService`,create:()=>new yi}),xi={activationSize:{type:`pixels`,value:10},size:{type:`pixels`,value:20}},Si={activationSize:{type:`pixels`,value:32},size:{type:`pixels`,value:20}};function Ci(e,t){return typeof e.dndEdges==`object`&&e.dndEdges!==null?e.dndEdges:t&&lr(e.dockToEdgeGroups)?Si:xi}var wi=class{constructor(e){this._host=e;let t=(t,n)=>{let r=Le();return r?r.viewId===e.id?n!==`center`||e.isGridEmpty():!1:n===`center`&&!e.isGridEmpty()?!1:e.dispatchUnhandledDragOver(t,n)},n=Ci(e.options,!1);this._html5Target=Ln.createDropTarget(e.element,{className:`dv-drop-target-edge`,canDisplayOverlay:t,acceptedTargetZones:[`top`,`bottom`,`left`,`right`,`center`],overlayModel:n,getOverrideTarget:()=>e.rootDropTargetOverrideTarget(),getPositionResolver:()=>e.options.dropPositionResolver}),this._pointerTarget=Rn.createDropTarget(e.element,{className:`dv-drop-target-edge`,canDisplayOverlay:t,acceptedTargetZones:[`top`,`bottom`,`left`,`right`,`center`],overlayModel:n,getOverrideTarget:()=>e.rootDropTargetOverrideTarget(),getPositionResolver:()=>e.options.dropPositionResolver}),this.onWillShowOverlay=Ve.any(this._html5Target.onWillShowOverlay,this._pointerTarget.onWillShowOverlay),this.onDrop=Ve.any(this._html5Target.onDrop,this._pointerTarget.onDrop),this.setOptions(e.options)}setOptions(e){if(`dndEdges`in e){let t=typeof e.dndEdges==`boolean`&&e.dndEdges===!1;this._html5Target.disabled=t,this._pointerTarget.disabled=t}if(`dndEdges`in e||`dockToEdgeGroups`in e){let t=Ci({dndEdges:`dndEdges`in e?e.dndEdges:this._host.options.dndEdges,dockToEdgeGroups:`dockToEdgeGroups`in e?e.dockToEdgeGroups:this._host.options.dockToEdgeGroups},this._host.hasEdgeDragReveal);this._html5Target.setOverlayModel(t),this._pointerTarget.setOverlayModel(t)}}dispose(){this._html5Target.dispose(),this._pointerTarget.dispose()}},Ti=ei({name:`RootDropTarget`,serviceKey:`rootDropTargetService`,create:e=>new wi(e),init:(e,t)=>(t.setOptions(e.options),Re.NONE)}),Ei={left:`createLeftHeaderActionComponent`,right:`createRightHeaderActionComponent`,prefix:`createPrefixHeaderActionComponent`},Di=class{constructor(e){this._perGroup=new Map,this._host=e}refresh(e){if(!e?.model)return;let t=this._ensureState(e);this._refreshSlot(`left`,e,t.left),this._refreshSlot(`right`,e,t.right),this._refreshSlot(`prefix`,e,t.prefix)}refreshAll(){for(let e of this._host.groups)this.refresh(e)}disposeGroup(e){let t=this._perGroup.get(e);t&&(t.left.dispose(),t.right.dispose(),t.prefix.dispose(),this._perGroup.delete(e))}dispose(){for(let e of[...this._perGroup.keys()])this.disposeGroup(e)}_ensureState(e){let t=this._perGroup.get(e);return t||(t={left:new Be,right:new Be,prefix:new Be},this._perGroup.set(e,t)),t}_refreshSlot(e,t,n){let r=this._host.options[Ei[e]];if(r){let i=r(t);n.value=i,i.init({containerApi:this._host.api,api:t.api,group:t}),t.model.attachHeaderAction(e,i.element)}else n.dispose(),t.model.attachHeaderAction(e,void 0)}},Oi=ei({name:`HeaderActions`,serviceKey:`headerActionsService`,create:e=>new Di(e),init:(e,t)=>new ze(e.onDidRemoveGroup(e=>{t.disposeGroup(e)}))}),ki=e=>e===`load`||e===`clear`;function Ai(e,t){let n=e.createElement(`div`);return n.className=t===`assertive`?`dv-live-region-assertive`:`dv-live-region`,n.setAttribute(`role`,t===`assertive`?`alert`:`status`),n.setAttribute(`aria-live`,t),n.setAttribute(`aria-atomic`,`true`),Object.assign(n.style,{position:`absolute`,width:`1px`,height:`1px`,margin:`-1px`,padding:`0`,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(50%)`,whiteSpace:`nowrap`,border:`0`}),n}var ji=class extends ze{constructor(e){super(),this._regions=new Map,this._suppressDepth=0,this._locationSubs=new Map,this._host=e;let t=e.element.ownerDocument;this._mainWindow=t.defaultView??window;let n={polite:Ai(t,`polite`),assertive:Ai(t,`assertive`)};e.element.appendChild(n.polite),e.element.appendChild(n.assertive),this._regions.set(this._mainWindow,n),this._syncPopoutRegions(),this.addDisposables({dispose:()=>this._disposeRegions()},e.onDidChangePopouts(()=>this._syncPopoutRegions()),e.onDidAddPanel(e=>this._announce(e,`open`)),e.onDidRemovePanel(e=>this._announce(e,`close`)),e.onWillMutateLayout(e=>{ki(e.kind)&&this._suppressDepth++}),e.onDidMutateLayout(e=>{ki(e.kind)&&(this._suppressDepth=Math.max(0,this._suppressDepth-1))}),e.onDidMaximizedGroupChange(e=>{let t=e.group.activePanel;t&&this._announce(t,e.isMaximized?`maximize`:`restore`)}),e.onDidAddGroup(e=>this._trackLocation(e)),e.onDidRemoveGroup(e=>{var t;(t=this._locationSubs.get(e.id))==null||t.dispose(),this._locationSubs.delete(e.id)}),{dispose:()=>{this._locationSubs.forEach(e=>e.dispose()),this._locationSubs.clear()}})}_syncPopoutRegions(){let e=this._host.element.ownerDocument,t=new Set([this._mainWindow]);for(let n of this._host.getPopoutWindows()){if(n.document===e||(t.add(n),this._regions.has(n)))continue;let r=n.document,i=r.body??r.documentElement,a={polite:Ai(r,`polite`),assertive:Ai(r,`assertive`)};i.appendChild(a.polite),i.appendChild(a.assertive),this._regions.set(n,a)}for(let[e,n]of this._regions)t.has(e)||(n.polite.remove(),n.assertive.remove(),this._regions.delete(e))}_disposeRegions(){for(let e of this._regions.values())e.polite.remove(),e.assertive.remove();this._regions.clear()}_focusedRegions(){for(let[e,t]of this._regions)if(e!==this._mainWindow)try{if(e.document.hasFocus())return t}catch{}return this._regions.get(this._mainWindow)}_trackLocation(e){let t=e.api.location.type,n=e.api.onDidLocationChange(n=>{let r=n.location.type;if(r===t)return;t=r;let i=e.activePanel;if(!i)return;let a;switch(r){case`floating`:a=`float`;break;case`popout`:a=`popout`;break;default:a=`dock`}this._announce(i,a)});this._locationSubs.set(e.id,n)}announce(e,t=`polite`){if(this._host.options.announcements===!1||this._suppressDepth>0||!e)return;let n=this._host.options.announcer;if(n){n({message:e,politeness:t});return}let r=this._focusedRegions(),i=t===`assertive`?r.assertive:r.polite;i.textContent=``,i.textContent=e}_announce(e,t){var n;let r=(n=this._host.options).getAnnouncement?.call(n,{kind:t,panel:e});r!==null&&r!==``&&this.announce(r??this._defaultMessage(e,t))}_defaultMessage(e,t){let n=on(this._host.options.messages),r=e.title??e.id;switch(t){case`open`:return n.panelOpened(r);case`close`:return n.panelClosed(r);case`maximize`:return n.groupMaximized(r);case`restore`:return n.groupRestored(r);case`float`:return n.groupFloated(r);case`dock`:return n.groupDocked(r);case`popout`:return n.groupPoppedOut(r)}}},Mi=ei({name:`LiveRegion`,serviceKey:`liveRegionService`,create:e=>new ji(e)}),Ni=30,Pi=-10,Fi=class{constructor(e){this.host=e}dispatchWillDragPanel(e){this.host.fireWillDragPanel(e)}dispatchWillDragGroup(e){this.host.fireWillDragGroup(e)}dispatchWillDrop(e){this.host.fireWillDrop(e)}dispatchWillShowOverlay(e){this.host.fireWillShowOverlay(e)}buildGroupDragGhost(e){let t=this.host.options.createGroupDragGhostComponent;if(!t)return;let n=t(e);return n.init({group:e,api:this.host.api}),{element:n.element,offsetX:Ni,offsetY:Pi,dispose:n.dispose?()=>n.dispose?.call(n):void 0}}resolveOverlayModel(e,t){var n;return(n=this.host.options).dropOverlayModel?.call(n,{location:e,group:t})}showPreviewOverlay(e,t){let n=e.model.contentDropTarget;return n.showOverlay(t),Re.from(()=>n.clearOverlay())}dispose(){}},Ii=ei({name:`AdvancedDnD`,serviceKey:`advancedDnDService`,create:e=>new Fi(e)}),Li=class{constructor(e){this._host=e}attachToGroup(e){return new ze(e.model.onDidCreateTabGroup(e=>{this._host.fireDidCreateTabGroup(e)}),e.model.onDidDestroyTabGroup(e=>{this._host.fireDidDestroyTabGroup(e)}),e.model.onDidAddPanelToTabGroup(e=>{this._host.fireDidAddPanelToTabGroup(e)}),e.model.onDidRemovePanelFromTabGroup(e=>{this._host.fireDidRemovePanelFromTabGroup(e)}),e.model.onDidTabGroupChange(e=>{this._host.fireDidTabGroupChange(e)}),e.model.onDidTabGroupCollapsedChange(e=>{this._host.fireDidTabGroupCollapsedChange(e)}))}dispose(){}},Ri=[mi,gi,vi,bi,Ti,Oi,Mi,Ii,ei({name:`TabGroupChips`,serviceKey:`tabGroupChipsService`,create:e=>new Li(e),init:(e,t)=>{let n=new Map;return new ze(e.onDidAddGroup(e=>{n.set(e,t.attachToGroup(e))}),e.onDidRemoveGroup(e=>{var t;(t=n.get(e))==null||t.dispose(),n.delete(e)}),{dispose:()=>{for(let e of n.values())e.dispose();n.clear()}})}})],zi=class{constructor(){this.cache=new WeakMap,this.currentFrameId=0,this.rafId=null}getPosition(e){let t=this.cache.get(e);if(t?.frameId===this.currentFrameId)return t.rect;this.scheduleFrameUpdate();let n=at(e);return this.cache.set(e,{rect:n,frameId:this.currentFrameId}),n}invalidate(){this.currentFrameId++}scheduleFrameUpdate(){this.rafId||=requestAnimationFrame(()=>{this.currentFrameId++,this.rafId=null})}},Bi=-1;function Vi(){let e=document.createElement(`div`);return e.tabIndex=-1,e}var Hi=class extends ze{constructor(e,t){super(),this.element=e,this.accessor=t,this.map={},this._disposed=!1,this._generation=0,this.positionCache=new zi,this.addDisposables(Re.from(()=>{for(let e of Object.values(this.map))e.disposable.dispose(),e.destroy.dispose(),this.cancelPendingUpdate(e);this._disposed=!0}))}updateAllPositions(){if(!this._disposed){this.positionCache.invalidate();for(let e of Object.values(this.map))e.panel.api.isVisible&&e.resize&&e.resize()}}repositionPanelOverlay(e,t=!1,n){var r;if(this._disposed)return;let i=this.map[e];i&&(i.forceVisible=t,i.clip=n,this.positionCache.invalidate(),(r=i.resize)==null||r.call(i))}cancelPendingUpdate(e){e.pendingUpdate!==void 0&&(cancelAnimationFrame(e.pendingUpdate),e.pendingUpdate=void 0)}detatch(e){if(this.map[e.api.id]){let t=this.map[e.api.id];return t.disposable.dispose(),t.destroy.dispose(),this.cancelPendingUpdate(t),delete this.map[e.api.id],!0}return!1}attach(e){let{panel:t,referenceContainer:n}=e;if(!this.map[t.api.id]){let e=Vi();e.className=`dv-render-overlay`,e.style.visibility=`hidden`,this.map[t.api.id]={panel:t,disposable:Re.NONE,destroy:Re.NONE,element:e,retainPreviousGeometry:!1,positioned:!1,generation:++this._generation}}let r=this.map[t.api.id];r.referenceContainer!==n&&(r.generation=++this._generation,this.cancelPendingUpdate(r),r.referenceContainer=n,r.retainPreviousGeometry=r.positioned);let i=r.generation,a=r.element,o=t.view.content.element;o.parentElement!==a&&a.appendChild(o),a.parentElement!==this.element&&this.element.appendChild(a);let s=()=>{let e=t.api.id,r=this.map[e];if(r?.generation!==i||r.pendingUpdate!==void 0)return;r.pendingUpdate=Bi;let o=requestAnimationFrame(()=>{let r=this.map[e];if(r&&(r.pendingUpdate=void 0),this.isDisposed||r?.generation!==i)return;let o=r.forceVisible??!1,s=r.clip,c=this.positionCache.getPosition(n.element),l=this.positionCache.getPosition(this.element),u=c.left-l.left,d=c.top-l.top,f=c.width,p=c.height;if(r.retainPreviousGeometry&&(f===0||p===0)){!t.api.isVisible&&!o&&(a.style.visibility=`hidden`,a.style.pointerEvents=`none`);return}if(r.retainPreviousGeometry=!1,r.positioned=!0,a.style.left=`${u}px`,a.style.top=`${d}px`,a.style.width=`${f}px`,a.style.height=`${p}px`,t.api.isVisible||o?(a.style.visibility=``,a.style.pointerEvents=``):(a.style.visibility=`hidden`,a.style.pointerEvents=`none`),o?a.style.zIndex=`1000`:t.api.location.type!==`floating`&&(a.style.zIndex=``),s){let e=this.element.ownerDocument.defaultView,t=e?.scrollX??0,n=e?.scrollY??0,r=s.top+n,i=s.left+t,o=Math.max(0,r-c.top),l=Math.max(0,i-c.left),u=Math.max(0,c.left+f-(s.right+t)),d=Math.max(0,c.top+p-(s.bottom+n));a.style.clipPath=`inset(${o}px ${u}px ${d}px ${l}px)`}else a.style.clipPath=``;$(a,`dv-render-overlay-float`,t.group.api.location.type===`floating`)});r.pendingUpdate===Bi&&(r.pendingUpdate=o)},c=()=>{t.api.isVisible?(this.positionCache.invalidate(),s(),this.map[t.api.id]?.retainPreviousGeometry&&(a.style.visibility=``),a.style.pointerEvents=``):(a.style.visibility=`hidden`,a.style.pointerEvents=`none`)},l=new Be,u=()=>{t.api.location.type===`floating`?queueMicrotask(()=>{let e=this.accessor.getFloatingWindowForGroup(t.api.group);if(!e)return;let n=e.overlay.element,r=()=>{let e=Number(n.getAttribute(`aria-level`));a.style.zIndex=`calc(var(--dv-overlay-z-index, 999) + ${e*2+1})`},i=new MutationObserver(()=>{r()});l.value=Re.from(()=>i.disconnect()),i.observe(n,{attributeFilter:[`aria-level`],attributes:!0}),r()}):a.style.zIndex=``},d=new ze(l,new cn(a,{onDragEnd:e=>{n.dropTarget.dnd.onDragEnd(e)},onDragEnter:e=>{n.dropTarget.dnd.onDragEnter(e)},onDragLeave:e=>{n.dropTarget.dnd.onDragLeave(e)},onDrop:e=>{n.dropTarget.dnd.onDrop(e)},onDragOver:e=>{n.dropTarget.dnd.onDragOver(e)}}),t.api.onDidVisibilityChange(()=>{c()}),t.api.onDidDimensionsChange(()=>{t.api.isVisible&&s()}),t.api.onDidLocationChange(()=>{u()}));return this.map[t.api.id].destroy=Re.from(()=>{o.parentElement===a&&o.remove(),a.remove()}),u(),queueMicrotask(()=>{this.isDisposed||c()}),this.map[t.api.id].disposable.dispose(),this.map[t.api.id].disposable=d,this.map[t.api.id].resize=s,a}};function Ui(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function Wi(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){Ui(a,r,i,o,s,`next`,e)}function s(e){Ui(a,r,i,o,s,`throw`,e)}o(void 0)})}}function Gi(e){let t;try{t=new URL(e,globalThis.location.href)}catch{throw Error(`dockview: invalid popout URL: ${e}`)}if(t.protocol!==`http:`&&t.protocol!==`https:`||t.origin!==globalThis.location.origin)throw Error(`dockview: popout URL must be same-origin http(s); got: ${e}`)}var Ki=class extends ze{get window(){return this._window?.value??null}constructor(e,t,n){super(),this.target=e,this.className=t,this.options=n,this._onWillClose=new Z,this.onWillClose=this._onWillClose.event,this._onDidClose=new Z,this.onDidClose=this._onDidClose.event,this._window=null,this.addDisposables(this._onWillClose,this._onDidClose,{dispose:()=>{this.close()}})}dimensions(){if(!this._window)return null;let e=this._window.value.screenX;return{top:this._window.value.screenY,left:e,width:this._window.value.innerWidth,height:this._window.value.innerHeight}}close(){if(this._window){var e,t;this._onWillClose.fire(),(e=(t=this.options).onWillClose)==null||e.call(t,{id:this.target,window:this._window.value}),this._window.disposable.dispose(),this._window=null,this._onDidClose.fire()}}open(){var e=this;return Wi(function*(){var t,n;if(e._window)throw Error(`instance of popout window is already open`);let r=`${e.options.url}`;Gi(r);let i=Object.entries({top:e.options.top,left:e.options.left,width:e.options.width,height:e.options.height}).map(([e,t])=>`${e}=${t}`).join(`,`),a=window.open(r,e.target,i);if(!a)return null;let o=new ze;e._window={value:a,disposable:o},o.addDisposables(Re.from(()=>{a.close()}),Q(globalThis.window,`beforeunload`,()=>{e.close()}));let s=e.createPopoutWindowContainer();return e.className&&s.classList.add(e.className),(t=(n=e.options).onDidOpen)==null||t.call(n,{id:e.target,window:a}),new Promise((t,n)=>{a.addEventListener(`unload`,()=>{}),o.addDisposables(e.onWillClose(()=>t(null))),a.addEventListener(`load`,()=>{try{let n=a.document;n.title=document.title,n.body.appendChild(s),it(n,globalThis.document.styleSheets,{nonce:e.options.nonce}),Q(a,`beforeunload`,()=>{e.close()}),t(s)}catch(e){n(e)}})})})()}createPopoutWindowContainer(){let e=document.createElement(`div`);return e.classList.add(`dv-popout-window`),e.id=`dv-popout-window`,e.style.position=`absolute`,e.style.width=`100%`,e.style.height=`100%`,e.style.top=`0px`,e.style.left=`0px`,e}},qi=class extends ze{constructor(e){super(),this.accessor=e,this.init()}init(){let e=new Set,t=new Set;this.addDisposables(this.accessor.onDidAddPanel(t=>{if(e.has(t.api.id))throw Error(`dockview: Invalid event sequence. [onDidAddPanel] called for panel ${t.api.id} but panel already exists`);e.add(t.api.id)}),this.accessor.onDidRemovePanel(t=>{if(e.has(t.api.id))e.delete(t.api.id);else throw Error(`dockview: Invalid event sequence. [onDidRemovePanel] called for panel ${t.api.id} but panel does not exists`)}),this.accessor.onDidAddGroup(e=>{if(t.has(e.api.id))throw Error(`dockview: Invalid event sequence. [onDidAddGroup] called for group ${e.api.id} but group already exists`);t.add(e.api.id)}),this.accessor.onDidRemoveGroup(e=>{if(t.has(e.api.id))t.delete(e.api.id);else throw Error(`dockview: Invalid event sequence. [onDidRemoveGroup] called for group ${e.api.id} but group does not exists`)}))}};function Ji(e){if(!e.matchMedia)return!1;let t=e.matchMedia(`(pointer: coarse)`).matches,n=e.matchMedia(`(pointer: fine)`).matches;return t&&!n}function Yi(e){let t=e.window??window,n=e.capture??!1,r=e.escape??!0,i=e.keys??[],a=e.outsidePointerDown??!0,o=e.pointerDownGraceMs??0,s=e.now??Date.now,c=s(),l=new ze,u=t=>{if(e.isInside)return e.isInside(t);let n=t.target;return n instanceof Node&&(e.elements?.call(e)??[]).some(e=>e.contains(n))};if((r||i.length>0)&&l.addDisposables(Q(t,`keydown`,t=>{(r&&t.key===`Escape`||i.includes(t.key))&&e.onDismiss()},n)),(a||e.onInsidePointerDown)&&l.addDisposables(Q(t,`pointerdown`,t=>{if(u(t)){var n;(n=e.onInsidePointerDown)==null||n.call(e,t);return}!a||s()-c<o||e.onDismiss()},n)),e.resize&&l.addDisposables(Q(t,`resize`,()=>{Ji(t)||e.onDismiss()})),e.focusOut){let r=t=>e.isFocusInside?e.isFocusInside(t):(e.elements?.call(e)??[]).some(e=>e.contains(t)),i=t=>{let n=t.target;n instanceof Element&&!r(n)&&e.onDismiss()};t.addEventListener(`focusin`,i,n),l.addDisposables({dispose:()=>t.removeEventListener(`focusin`,i,n)})}return l}var Xi=class extends ze{constructor(e,t=globalThis.window){super(),this._active=null,this._activeDisposable=new Be,this._root=e,this._window=t,this._element=t.document.createElement(`div`),this._element.className=`dv-popover-anchor`,this._element.style.position=`relative`,this._root.prepend(this._element),this.addDisposables(Re.from(()=>{this.close()}),this._activeDisposable)}updateRoot(e){e.prepend(this._element),this._root=e}openPopover(e,t){this.close();let n=this._window.document.createElement(`div`);n.style.position=`absolute`,n.style.zIndex=t.zIndex??`var(--dv-overlay-z-index)`,n.appendChild(e);let r=this._element.getBoundingClientRect(),i=r.left,a=r.top;n.style.top=`${t.y-a}px`,n.style.left=`${t.x-i}px`,this._element.appendChild(n),this._active=n,this._activeDisposable.value=Yi({window:this._window,onDismiss:()=>this.close(),elements:()=>this._active?[this._active]:[],keys:[`Enter`],pointerDownGraceMs:200,resize:!0}),this._window.requestAnimationFrame(()=>{gt(n,this._root)})}close(){this._active&&=(this._active.remove(),this._activeDisposable.dispose(),null)}},Zi=class extends ze{get disabled(){return this._disabled}set disabled(e){this.disabled!==e&&(this._disabled=e,e&&this._clearNow())}_cancelPendingClear(){this._pendingClear!==void 0&&(clearTimeout(this._pendingClear),this._pendingClear=void 0)}_clearNow(){this._cancelPendingClear(),this._model&&this._model.root.remove(),this._model=void 0}get model(){if(!this.disabled)return{clear:()=>{this._clearNow()},scheduleClear:()=>{this._pendingClear!==void 0||!this._model||(this._pendingClear=setTimeout(()=>{this._pendingClear=void 0,this._clearNow()},0))},exists:()=>!!this._model,getElements:(e,t)=>{this._cancelPendingClear();let n=this._outline!==t;if(this._outline=t,this._model)return this._model.changed=n,this._model;let r=this.createContainer(),i=this.createAnchor();if(this._model={root:r,overlay:i,changed:n},r.appendChild(i),this.element.appendChild(r),e?.target instanceof HTMLElement){let t=e.target.getBoundingClientRect(),n=this.element.getBoundingClientRect();i.style.left=`${t.left-n.left}px`,i.style.top=`${t.top-n.top}px`}return this._model}}}constructor(e,t){super(),this.element=e,this._disabled=!1,this._disabled=t.disabled,this.addDisposables(Re.from(()=>{var e;(e=this.model)==null||e.clear()}))}createContainer(){let e=document.createElement(`div`);return e.className=`dv-drop-target-container`,e}createAnchor(){let e=document.createElement(`div`);return e.className=`dv-drop-target-anchor`,e.style.visibility=`hidden`,e}},Qi=class{get _effectiveBaseCollapsed(){return this._measuredTabSize??this._baseCollapsedSize}get minimumSize(){return this._isCollapsed?this.collapsedSize:this._baseMinimumSize===void 0?this._effectiveBaseCollapsed+50+this._gapAdd:this._baseMinimumSize+this._gapAdd}get maximumSize(){return this._isCollapsed?this.collapsedSize:this._expandedMaximumSize}get element(){return this._group.element}get isCollapsed(){return this._isCollapsed}get lastExpandedSize(){return this._lastExpandedSize}get collapsedSize(){return this._effectiveBaseCollapsed+this._gapAdd}get configuredMinimumSize(){return this._baseMinimumSize}get configuredMaximumSize(){return this._expandedMaximumSize}get configuredCollapsedSize(){return this._baseCollapsedSize}constructor(e,t,n,r=0){this._onDidChange=new Z,this.onDidChange=this._onDidChange.event,this.snap=!1,this.priority=`low`,this._isCollapsed=!1,this._tabSizeDisposables=new ze,this._group=t,this._orientation=n,t.element.classList.add(`dv-edge-group`),t.element.dataset.testid=`dv-edge-group-${e.id}`,this._baseCollapsedSize=e.collapsedSize??35,this._baseMinimumSize=e.minimumSize,this._gapAdd=r,this._expandedMaximumSize=e.maximumSize??1/0,this._lastExpandedSize=e.initialSize??200,e.collapsed&&(this._isCollapsed=!0,t.element.classList.add(`dv-edge-collapsed`)),this._observeTabStrip()}_observeTabStrip(){let e=this._group.element.querySelector(`.dv-tabs-and-actions-container`);e&&this._tabSizeDisposables.addDisposables(Ye(e,()=>{this._applyMeasuredTabSize(this._orientation===`vertical`?e.offsetHeight:e.offsetWidth)}))}_applyMeasuredTabSize(e){e<=0||e===this._measuredTabSize||(this._measuredTabSize=e,this._isCollapsed&&this._onDidChange.fire({size:this.collapsedSize}))}layout(e,t){this._isCollapsed||(this._lastExpandedSize=e),this._orientation===`horizontal`?this._group.layout(e,t):this._group.layout(t,e)}setCollapsed(e){this._isCollapsed!==e&&(this._isCollapsed=e,this._group.element.classList.toggle(`dv-edge-collapsed`,e))}setVisible(e){}restoreExpandedSize(e){this._lastExpandedSize=e}updateSizing(e,t,n){this._baseCollapsedSize=e,this._baseMinimumSize=t,this._gapAdd=n}dispose(){this._tabSizeDisposables.dispose(),this._onDidChange.dispose()}},$i=class{get element(){return this._dockviewElement}constructor(e,t){this._dockviewElement=e,this._layoutDockview=t,this.priority=`high`,this.minimumSize=100,this.maximumSize=1/0,this._onDidChange=new Z,this.onDidChange=this._onDidChange.event}layout(e,t){this._layoutDockview(t,e)}setVisible(e){}dispose(){this._onDidChange.dispose()}},ea=class{get element(){return this._element}constructor(e,t=0){this._onDidChange=new Z,this.onDidChange=this._onDidChange.event,this.minimumSize=100,this.maximumSize=1/0,this.priority=`high`,this._element=document.createElement(`div`),this._element.className=`dv-shell-middle-column`,this._element.style.height=`100%`,this._element.style.width=`100%`,this._splitview=new jt(this._element,{orientation:`VERTICAL`,proportionalLayout:!1,margin:t}),this._centerIndex=0,this._splitview.addView(e,{type:`distribute`},0)}addTopView(e,t){this._splitview.addView(e,t,0),this._topIndex=0,this._centerIndex+=1,this._bottomIndex!==void 0&&(this._bottomIndex+=1)}addBottomView(e,t){let n=this._splitview.length;this._splitview.addView(e,t,n),this._bottomIndex=n}removeView(e){let t=e===`top`?this._topIndex:this._bottomIndex;t!==void 0&&(this._splitview.removeView(t),e===`top`?(this._topIndex=void 0,--this._centerIndex,this._bottomIndex!==void 0&&--this._bottomIndex):this._bottomIndex=void 0)}layout(e,t){this._splitview.layout(t,e)}setVisible(e){}setViewVisible(e,t){let n=e===`top`?this._topIndex:this._bottomIndex;n!==void 0&&this._splitview.setViewVisible(n,t)}isViewVisible(e){let t=e===`top`?this._topIndex:this._bottomIndex;return t!==void 0&&this._splitview.isViewVisible(t)}getViewSize(e){let t=e===`top`?this._topIndex:this._bottomIndex;return t===void 0?0:this._splitview.getViewSize(t)}getViewCachedVisibleSize(e){let t=e===`top`?this._topIndex:this._bottomIndex;if(t!==void 0)return this._splitview.getViewCachedVisibleSize(t)}resizeView(e,t){let n=e===`top`?this._topIndex:this._bottomIndex;n!==void 0&&this._splitview.resizeView(n,t)}updateMargin(e){this._splitview.margin=e}dispose(){this._onDidChange.dispose(),this._splitview.dispose()}},ta=class{constructor(e,t,n,r=0,i=35){this._disposables=new ze,this._viewConfigs=new Map,this._currentWidth=0,this._currentHeight=0,this._gap=r,this._defaultCollapsedSize=i,this._shellElement=document.createElement(`div`),this._shellElement.className=`dv-shell`,this._shellElement.style.height=`100%`,this._shellElement.style.width=`100%`,this._shellElement.style.position=`relative`,e.appendChild(this._shellElement);let a=new $i(t,n);this._middleColumn=new ea(a,r),this._outerSplitview=new jt(this._shellElement,{orientation:`HORIZONTAL`,proportionalLayout:!1,margin:r}),this._middleIndex=0,this._outerSplitview.addView(this._middleColumn,{type:`distribute`},0),this._disposables.addDisposables(Ye(this._shellElement,e=>{if(!this._shellElement.offsetParent||!ot(this._shellElement))return;let t=Math.round(e.contentRect.width),n=Math.round(e.contentRect.height);(t!==this._currentWidth||n!==this._currentHeight)&&(this._currentWidth=t,this._currentHeight=n,this.layout(t,n))}),this._outerSplitview,this._middleColumn,a)}get element(){return this._shellElement}addEdgeView(e,t,n){if(this.hasEdgeGroup(e))throw Error(`dockview: edge group already registered at position '${e}'`);this._viewConfigs.set(e,t);let r=1+ +!!this._viewConfigs.has(`left`)+ +!!this._viewConfigs.has(`right`),i=1+ +!!this._viewConfigs.has(`top`)+ +!!this._viewConfigs.has(`bottom`),a=r>1?this._gap*(r-1)/r:0,o=i>1?this._gap*(i-1)/i:0,s=e===`left`||e===`right`,c=s?a:o,l=s?`horizontal`:`vertical`,u=new Qi(tn({collapsedSize:this._defaultCollapsedSize},t),n,l,c),d=u.isCollapsed?u.collapsedSize:u.lastExpandedSize;switch(e){case`left`:this._outerSplitview.addView(u,d,0),this._leftIndex=0,this._middleIndex+=1,this._rightIndex!==void 0&&(this._rightIndex+=1),this._leftView=u;break;case`right`:{let e=this._outerSplitview.length;this._outerSplitview.addView(u,d,e),this._rightIndex=e,this._rightView=u}break;case`top`:this._middleColumn.addTopView(u,d),this._topView=u;break;case`bottom`:this._middleColumn.addBottomView(u,d),this._bottomView=u}return this._disposables.addDisposables(u),this.updateTheme(this._gap,this._defaultCollapsedSize),u}layout(e,t){this._outerSplitview.layout(e,t)}updateTheme(e,t){this._gap=e,this._defaultCollapsedSize=t;let n=1+ +!!this._viewConfigs.has(`left`)+ +!!this._viewConfigs.has(`right`),r=1+ +!!this._viewConfigs.has(`top`)+ +!!this._viewConfigs.has(`bottom`),i=n>1?e*(n-1)/n:0,a=r>1?e*(r-1)/r:0;this._outerSplitview.margin=e,this._middleColumn.updateMargin(e);let o=(e,n,r)=>{let i=n.collapsedSize??t;e.updateSizing(i,n.minimumSize,r)},s=this._viewConfigs.get(`top`);this._topView&&s&&o(this._topView,s,a);let c=this._viewConfigs.get(`bottom`);this._bottomView&&c&&o(this._bottomView,c,a);let l=this._viewConfigs.get(`left`);this._leftView&&l&&o(this._leftView,l,i);let u=this._viewConfigs.get(`right`);this._rightView&&u&&o(this._rightView,u,i),this._leftView?.isCollapsed&&this._leftIndex!==void 0&&this._outerSplitview.resizeView(this._leftIndex,this._leftView.collapsedSize),this._rightView?.isCollapsed&&this._rightIndex!==void 0&&this._outerSplitview.resizeView(this._rightIndex,this._rightView.collapsedSize),this._topView?.isCollapsed&&this._middleColumn.resizeView(`top`,this._topView.collapsedSize),this._bottomView?.isCollapsed&&this._middleColumn.resizeView(`bottom`,this._bottomView.collapsedSize),this._currentWidth>0&&this._currentHeight>0&&this.layout(this._currentWidth,this._currentHeight)}removeEdgeView(e){let t=this._getView(e);if(t){switch(e){case`left`:this._outerSplitview.removeView(this._leftIndex),this._leftIndex=void 0,this._leftView=void 0,--this._middleIndex,this._rightIndex!==void 0&&--this._rightIndex;break;case`right`:this._outerSplitview.removeView(this._rightIndex),this._rightIndex=void 0,this._rightView=void 0;break;case`top`:this._middleColumn.removeView(`top`),this._topView=void 0;break;case`bottom`:this._middleColumn.removeView(`bottom`),this._bottomView=void 0}this._disposables.removeDisposable(t),t.dispose(),this._viewConfigs.delete(e),this.updateTheme(this._gap,this._defaultCollapsedSize)}}hasEdgeGroup(e){switch(e){case`top`:return this._topView!==void 0;case`bottom`:return this._bottomView!==void 0;case`left`:return this._leftView!==void 0;case`right`:return this._rightView!==void 0}}setEdgeGroupVisible(e,t){switch(e){case`left`:this._leftIndex!==void 0&&this._outerSplitview.setViewVisible(this._leftIndex,t);break;case`right`:this._rightIndex!==void 0&&this._outerSplitview.setViewVisible(this._rightIndex,t);break;case`top`:case`bottom`:this._middleColumn.setViewVisible(e,t)}}isEdgeGroupVisible(e){switch(e){case`left`:return this._leftIndex!==void 0&&this._outerSplitview.isViewVisible(this._leftIndex);case`right`:return this._rightIndex!==void 0&&this._outerSplitview.isViewVisible(this._rightIndex);case`top`:case`bottom`:return this._middleColumn.isViewVisible(e)}}setEdgeGroupCollapsed(e,t){let n=this._getView(e);if(!n)return;n.setCollapsed(t);let r=t?n.collapsedSize:n.lastExpandedSize;switch(e){case`left`:this._leftIndex!==void 0&&this._outerSplitview.resizeView(this._leftIndex,r);break;case`right`:this._rightIndex!==void 0&&this._outerSplitview.resizeView(this._rightIndex,r);break;case`top`:case`bottom`:this._middleColumn.resizeView(e,r)}}isEdgeGroupCollapsed(e){return this._getView(e)?.isCollapsed??!1}getEdgeGroupExpandedSize(e){return this._getView(e)?.lastExpandedSize??0}_getView(e){switch(e){case`top`:return this._topView;case`bottom`:return this._bottomView;case`left`:return this._leftView;case`right`:return this._rightView}}toJSON(){let e={},t=e=>({minimumSize:e.configuredMinimumSize,maximumSize:Number.isFinite(e.configuredMaximumSize)?e.configuredMaximumSize:void 0,collapsedSize:e.configuredCollapsedSize}),n=(e,t,n,r)=>e.isCollapsed?e.lastExpandedSize:t?n:r??e.lastExpandedSize;if(this._leftView&&this._leftIndex!==void 0){let r=this._outerSplitview.isViewVisible(this._leftIndex);e.left=tn({size:n(this._leftView,r,this._outerSplitview.getViewSize(this._leftIndex),this._outerSplitview.getViewCachedVisibleSize(this._leftIndex)),visible:r,collapsed:this._leftView.isCollapsed||void 0},t(this._leftView))}if(this._rightView&&this._rightIndex!==void 0){let r=this._outerSplitview.isViewVisible(this._rightIndex);e.right=tn({size:n(this._rightView,r,this._outerSplitview.getViewSize(this._rightIndex),this._outerSplitview.getViewCachedVisibleSize(this._rightIndex)),visible:r,collapsed:this._rightView.isCollapsed||void 0},t(this._rightView))}if(this._topView){let r=this._middleColumn.isViewVisible(`top`);e.top=tn({size:n(this._topView,r,this._middleColumn.getViewSize(`top`),this._middleColumn.getViewCachedVisibleSize(`top`)),visible:r,collapsed:this._topView.isCollapsed||void 0},t(this._topView))}if(this._bottomView){let r=this._middleColumn.isViewVisible(`bottom`);e.bottom=tn({size:n(this._bottomView,r,this._middleColumn.getViewSize(`bottom`),this._middleColumn.getViewCachedVisibleSize(`bottom`)),visible:r,collapsed:this._bottomView.isCollapsed||void 0},t(this._bottomView))}return e}fromJSON(e){if(e.left&&this._leftIndex!==void 0){var t,n;(t=this._leftView)==null||t.restoreExpandedSize(e.left.size),(n=this._leftView)==null||n.setCollapsed(e.left.collapsed??!1),this._outerSplitview.resizeView(this._leftIndex,e.left.collapsed?this._leftView?.collapsedSize??e.left.size:e.left.size),e.left.visible||this._outerSplitview.setViewVisible(this._leftIndex,!1)}if(e.right&&this._rightIndex!==void 0){var r,i;(r=this._rightView)==null||r.restoreExpandedSize(e.right.size),(i=this._rightView)==null||i.setCollapsed(e.right.collapsed??!1),this._outerSplitview.resizeView(this._rightIndex,e.right.collapsed?this._rightView?.collapsedSize??e.right.size:e.right.size),e.right.visible||this._outerSplitview.setViewVisible(this._rightIndex,!1)}if(e.top){var a,o;(a=this._topView)==null||a.restoreExpandedSize(e.top.size),(o=this._topView)==null||o.setCollapsed(e.top.collapsed??!1),this._middleColumn.resizeView(`top`,e.top.collapsed?this._topView?.collapsedSize??e.top.size:e.top.size),e.top.visible||this._middleColumn.setViewVisible(`top`,!1)}if(e.bottom){var s,c;(s=this._bottomView)==null||s.restoreExpandedSize(e.bottom.size),(c=this._bottomView)==null||c.setCollapsed(e.bottom.collapsed??!1),this._middleColumn.resizeView(`bottom`,e.bottom.collapsed?this._bottomView?.collapsedSize??e.bottom.size:e.bottom.size),e.bottom.visible||this._middleColumn.setViewVisible(`bottom`,!1)}}dispose(){this._disposables.dispose(),this._shellElement.remove()}};function na(e){return new gr(e.tabGroupColors??hr,e.tabGroupAccent!==`off`)}function ra(e){let t=e.from.activePanel;[...e.from.panels].map(t=>{let n=e.from.model.removePanel(t);return e.from.model.renderContainer.detatch(t),n}).forEach(n=>{e.to.model.openPanel(n,{skipSetActive:t!==n,skipSetGroupActive:!0})})}var ia=()=>({dispose:()=>{}}),aa=ia,oa=class extends Yt{fireDidCreateTabGroup(e){this._onDidCreateTabGroup.fire(e)}fireDidDestroyTabGroup(e){this._onDidDestroyTabGroup.fire(e)}fireDidAddPanelToTabGroup(e){this._onDidAddPanelToTabGroup.fire(e)}fireDidRemovePanelFromTabGroup(e){this._onDidRemovePanelFromTabGroup.fire(e)}fireDidTabGroupChange(e){this._onDidTabGroupChange.fire(e)}fireDidTabGroupCollapsedChange(e){this._onDidTabGroupCollapsedChange.fire(e)}get orientation(){return this.gridview.orientation}get totalPanels(){return this.panels.length}get panels(){return this.groups.flatMap(e=>e.panels)}get options(){return this._options}get tabGroupColorPalette(){return this._tabGroupColorPalette}get activePanel(){let e=this.activeGroup;if(e)return e.activePanel}get renderer(){return this.options.defaultRenderer??`onlyWhenVisible`}get defaultHeaderPosition(){return this.options.defaultHeaderPosition??`top`}get api(){return this._api}get floatingGroups(){var e;return((e=this._moduleRegistry)==null||(e=e.services.floatingGroupService)==null?void 0:e.floatingGroups)??[]}getFloatingWindowForGroup(e){return this._floatingGroupService?.findByGroup(e)}_gatherFloatingGroupBoxes(e){return this.getFloatingGroupSnapshots(e).map(e=>e.box)}getFloatingContainer(){return this._floatingOverlayHost??this.gridview.element}getFloatingGroupSnapshots(e){let t=this.getFloatingContainer().getBoundingClientRect();return this.floatingGroups.filter(t=>t.group!==e).map(e=>{let n=e.overlay.element.getBoundingClientRect();return{group:e.group,box:{left:n.left-t.left,top:n.top-t.top,width:n.width,height:n.height}}})}mergeFloatInto(e,t,n){e===t||!this.getPanel(t.id)||this.moveGroupOrPanel({from:{groupId:e.id},to:{group:t,position:n}})}getGridSplitterRects(){let e=this.getFloatingContainer().getBoundingClientRect(),t=[];return this.gridview.element.querySelectorAll(`.dv-sash`).forEach(n=>{let r=n.getBoundingClientRect();t.push({left:r.left-e.left,top:r.top-e.top,width:r.width,height:r.height})}),t}get _smartGuidesService(){return this._moduleRegistry.services.smartGuidesService}get smartGuidesEnabled(){return this._smartGuidesService?.enabled??!1}setSmartGuidesEnabled(e){var t;(t=ai(this._smartGuidesService,`SmartGuides`,`api.setSmartGuidesEnabled`))==null||t.setEnabled(e)}updateSmartGuidesOptions(e){var t;(t=ai(this._smartGuidesService,`SmartGuides`,`api.updateSmartGuidesOptions`))==null||t.updateOptions(e)}get onDidSnapFloat(){return this._smartGuidesService?.onDidSnapFloat??ia}get onDidSnapTogether(){return this._smartGuidesService?.onDidSnapTogether??ia}_buildFloatingDragTransform(e,t){let n=this.options.transformFloatingGroupDrag,r=!t;if(!(!n&&!(r&&this._smartGuidesService)))return t=>{let i=n?.({group:e,proposed:t.proposed,container:t.container,others:t.others,modifiers:t.modifiers}),a=i?tn(tn({},t.proposed),i):t.proposed;return(r?this._smartGuidesService?.transformFloatingGroupDrag({group:e,proposed:a,container:t.container,others:t.others,modifiers:t.modifiers}):void 0)??i??void 0}}get _floatingGroupService(){return this._moduleRegistry.services.floatingGroupService}get _popoutWindowService(){return this._moduleRegistry.services.popoutWindowService}get _watermarkService(){return this._moduleRegistry.services.watermarkService}get _edgeGroupService(){return this._moduleRegistry.services.edgeGroupService}get _rootDropTargetService(){return this._moduleRegistry.services.rootDropTargetService}get _advancedDnDService(){return this._moduleRegistry.services.advancedDnDService}get _dndCompassService(){return this._moduleRegistry.services.dndCompassService}canDropOnGroup(e,t,n){return e.model.canDisplayContentOverlay(n,t)}getDropOverlayElement(e){let t=e.element.querySelector(`.dv-content-container`);if(t)return this.options.theme?.dndPanelOverlay===`group`?t.parentElement??t:t}getTabsListElement(e){return e.model.header.hidden?void 0:e.model.tabsListElement}relayoutGroup(e){e.relayout()}setForcedOverflow(e,t){e.model.header.setForcedOverflow(t)}getLayoutElement(){return this.gridview.element}getDropPositionResolver(){if(this.options.dropPositionResolver)return this.options.dropPositionResolver;let e=this._dndCompassService?.resolver,t=this._moduleRegistry.services.autoEdgeGroupService;return e&&t?{resolve:n=>t.resolveEdge(n)??e.resolve(n)}:e??t?.resolver}dockToLayoutEdge(e,t){let n=new Fr({nativeEvent:e,position:t,panel:void 0,api:this._api,group:void 0,getData:Le,kind:`edge`});if(this._onWillDrop.fire(n),n.defaultPrevented)return;let r=Le();r?this.moveGroupOrPanel({from:{groupId:r.groupId,panelId:r.panelId??void 0},to:{group:this.orthogonalize(t),position:`center`}}):this._onDidDrop.fire(new Pr({nativeEvent:e,position:t,panel:void 0,api:this._api,group:void 0,getData:Le}))}get headerActionsService(){return this._moduleRegistry.services.headerActionsService}get _layoutHistoryService(){return this._moduleRegistry.services.layoutHistoryService}undo(){var e;(e=ai(this._layoutHistoryService,`LayoutHistory`,`api.undo`))==null||e.undo()}redo(){var e;(e=ai(this._layoutHistoryService,`LayoutHistory`,`api.redo`))==null||e.redo()}get canUndo(){return this._layoutHistoryService?.canUndo??!1}get canRedo(){return this._layoutHistoryService?.canRedo??!1}clearHistory(){var e;(e=this._layoutHistoryService)==null||e.clear()}get onDidChangeHistory(){return this._layoutHistoryService?.onDidChangeHistory??aa}get hasEdgeDragReveal(){return!!this._moduleRegistry.services.autoEdgeGroupService}isGridEmpty(){return this.gridview.length===0}rootDropTargetOverrideTarget(){return this.rootDropTargetContainer?.model}dispatchUnhandledDragOver(e,t){let n=new ur(e,`edge`,t,Le);return this._onUnhandledDragOver.fire(n),n.isAccepted}fireWillDragPanel(e){this._onWillDragPanel.fire(e)}fireWillDragGroup(e){this._onWillDragGroup.fire(e)}fireWillDrop(e){this._onWillDrop.fire(e)}fireWillShowOverlay(e){this._onWillShowOverlay.fire(e)}buildGroupDragGhost(e){return this._advancedDnDService?.buildGroupDragGhost(e)}resolveDropOverlayModel(e,t){return this._advancedDnDService?.resolveOverlayModel(e,t)}get rootElement(){return this._shellManager?.element??this.element}ownsElement(e){if(this.rootElement.contains(e))return!0;let t=this.rootElement.ownerDocument,n=e.ownerDocument;return!n||n===t?!1:this.getPopoutWindows().some(e=>e.document===n)}adjacentGroup(e,t){if(e.api.location.type!==`grid`)return;let n=Rt(e.element);return(t?this.gridview.previous(n):this.gridview.next(n))?.view}adjacentGroupInDirection(e,t){if(e.api.location.type!==`grid`)return;let n=e.element.getBoundingClientRect(),r=n.left+n.width/2,i=n.top+n.height/2,a,o=1/0;for(let n of this.groups){if(n===e||n.api.location.type!==`grid`)continue;let s=n.element.getBoundingClientRect(),c=s.left+s.width/2-r,l=s.top+s.height/2-i,u;switch(t){case`left`:u=c<0&&Math.abs(c)>=Math.abs(l);break;case`right`:u=c>0&&Math.abs(c)>=Math.abs(l);break;case`up`:u=l<0&&Math.abs(l)>=Math.abs(c);break;default:u=l>0&&Math.abs(l)>=Math.abs(c)}if(!u)continue;let d=c*c+l*l;d<o&&(o=d,a=n)}return a}showDropPreview(e,t){return this._advancedDnDService?.showPreviewOverlay(e,t)??Re.NONE}announce(e){var t;(t=this._moduleRegistry.services.liveRegionService)==null||t.announce(e)}dockPanel(e,t,n){this.moveGroupOrPanel({from:{groupId:e.group.id,panelId:e.id},to:{group:t,position:n}})}floatPanel(e){this.addFloatingGroup(e)}get contextMenuService(){return this._moduleRegistry.services.contextMenuService}get pinnedTabsService(){return this._moduleRegistry.services.pinnedTabsService}get advancedOverflowService(){return this._moduleRegistry.services.advancedOverflowService}setPanelPinned(e,t){e.isPinned!==t&&this.options.pinnedTabs?.enabled&&this.pinnedTabsService&&(e.setPinned(t),this._onDidPanelPinnedChange.fire({panel:e,isPinned:t}))}get mountElement(){return this.gridview.element}hasVisibleGridGroup(){return this.groups.some(e=>e.api.location.type===`grid`&&e.api.isVisible)}fireLayoutChange(){this._bufferOnDidLayoutChange.fire()}get popoutRestorationPromise(){return this._popoutWindowService?.restorationPromise??Promise.resolve()}constructor(e,t){super(e,{proportionalLayout:!0,orientation:`HORIZONTAL`,styles:t.hideBorders?{separatorBorder:`transparent`}:void 0,disableAutoResizing:t.disableAutoResizing,locked:t.locked,margin:t.theme?.gap??0,className:t.className}),this.nextGroupId=Tt(),this._deserializer=new Yr(this),this._moduleRegistry=new oi,this._onWillDragPanel=new Z,this.onWillDragPanel=this._onWillDragPanel.event,this._onWillDragGroup=new Z,this.onWillDragGroup=this._onWillDragGroup.event,this._onDidDrop=new Z,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new Z,this.onWillDrop=this._onWillDrop.event,this._mutationDepth=0,this._pendingLocationChanges=new Map,this._origin=`user`,this._originDepth=0,this._onWillMutateLayout=new Z,this.onWillMutateLayout=this._onWillMutateLayout.event,this._onDidMutateLayout=new Z,this.onDidMutateLayout=this._onDidMutateLayout.event,this._onWillShowOverlay=new Z,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onUnhandledDragOver=new Z,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this._onDidRemovePanel=new Z,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidAddPanel=new Z,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPopoutGroupSizeChange=new Z,this.onDidPopoutGroupSizeChange=this._onDidPopoutGroupSizeChange.event,this._onDidPopoutGroupPositionChange=new Z,this.onDidPopoutGroupPositionChange=this._onDidPopoutGroupPositionChange.event,this._onDidAddPopoutGroup=new Z,this.onDidAddPopoutGroup=this._onDidAddPopoutGroup.event,this._onDidRemovePopoutGroup=new Z,this.onDidRemovePopoutGroup=this._onDidRemovePopoutGroup.event,this._onDidChangePopouts=new Z,this.onDidChangePopouts=this._onDidChangePopouts.event,this._onDidOpenPopoutWindowFail=new Z,this.onDidOpenPopoutWindowFail=this._onDidOpenPopoutWindowFail.event,this._onDidStartFloatingGroupDrag=new Z,this.onDidStartFloatingGroupDrag=this._onDidStartFloatingGroupDrag.event,this._onDidEndFloatingGroupDrag=new Z,this.onDidEndFloatingGroupDrag=this._onDidEndFloatingGroupDrag.event,this._onDidLayoutFromJSON=new Z,this.onDidLayoutFromJSON=this._onDidLayoutFromJSON.event,this._onDidActivePanelChange=new Z({replay:!0}),this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidPanelPinnedChange=new Z,this.onDidPanelPinnedChange=this._onDidPanelPinnedChange.event,this._onDidMovePanel=new Z,this.onDidMovePanel=this._onDidMovePanel.event,this._onDidCreateTabGroup=new Z,this.onDidCreateTabGroup=this._onDidCreateTabGroup.event,this._onDidDestroyTabGroup=new Z,this.onDidDestroyTabGroup=this._onDidDestroyTabGroup.event,this._onDidAddPanelToTabGroup=new Z,this.onDidAddPanelToTabGroup=this._onDidAddPanelToTabGroup.event,this._onDidRemovePanelFromTabGroup=new Z,this.onDidRemovePanelFromTabGroup=this._onDidRemovePanelFromTabGroup.event,this._onDidTabGroupChange=new Z,this.onDidTabGroupChange=this._onDidTabGroupChange.event,this._onDidTabGroupCollapsedChange=new Z,this.onDidTabGroupCollapsedChange=this._onDidTabGroupCollapsedChange.event,this._onDidMaximizedGroupChange=new Z,this.onDidMaximizedGroupChange=this._onDidMaximizedGroupChange.event,this._inShellLayout=!1,this._onDidRemoveGroup=new Z,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidEdgeGroupAutoHideChange=new Z,this.onDidEdgeGroupAutoHideChange=this._onDidEdgeGroupAutoHideChange.event,this._onDidAddGroup=new Z,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidOptionsChange=new Z,this.onDidOptionsChange=this._onDidOptionsChange.event,this._onDidActiveGroupChange=new Z,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._peekingGroups=new Set,this._moving=!1,this._options=t,this._tabGroupColorPalette=na(t);let n=t.modules??[...Ri,...ci()];for(let e of n)this._moduleRegistry.register(e);this._moduleRegistry.initialize(this),this.reportMissingOptionModules(t);let r=this._popoutWindowService;r&&this.addDisposables(r.onDidRemove(e=>{this._onDidRemovePopoutGroup.fire({id:e.popoutGroup.id,group:e.popoutGroup,window:e.getWindow()})})),this.popupService=new Xi(this.element),this._api=new sn(this),this.disableResizing=!0,this.element.remove(),this._shellManager=new ta(e,this.element,(e,t)=>this._layoutFromShell(e,t),t.theme?.gap??0,t.theme?.edgeGroupCollapsedSize),this.popupService.updateRoot(this._shellManager.element),this._shellThemeClassnames=new dt(this._shellManager.element),this.rootDropTargetContainer=new Zi(this._shellManager.element,{disabled:!0}),this.floatingDropTargetContainer=new Zi(this._shellManager.element,{disabled:!1}),this.overlayRenderContainer=new Hi(this._shellManager.element,this),this._floatingOverlayHost=document.createElement(`div`),this._floatingOverlayHost.className=`dv-floating-overlay-host`,this._shellManager.element.appendChild(this._floatingOverlayHost),$(this.gridview.element,`dv-dockview`,!0),$(this.element,`dv-debug`,!!t.debug),this.updateTheme(),t.debug&&this.addDisposables(new qi(this)),this.addDisposables(Re.from(()=>this._pendingLocationChanges.clear()),this.rootDropTargetContainer,this.floatingDropTargetContainer,Q(this._shellManager.element,`dragend`,()=>{var e,t;(e=this.rootDropTargetContainer.model)==null||e.clear(),(t=this.floatingDropTargetContainer.model)==null||t.clear()},!0),this.overlayRenderContainer,this._onWillDragPanel,this._onWillDragGroup,this._onWillShowOverlay,this._onDidActivePanelChange,this._onDidPanelPinnedChange,this._onDidAddPanel,this._onDidRemovePanel,this._onDidLayoutFromJSON,this._onDidDrop,this._onWillDrop,this._onWillMutateLayout,this._onDidMutateLayout,this._onDidMovePanel,this._onDidMovePanel.event(()=>{this.debouncedUpdateAllPositions()}),this._onDidAddGroup,this._onDidRemoveGroup,this._onDidEdgeGroupAutoHideChange,this._onDidActiveGroupChange,this._onUnhandledDragOver,this._onDidMaximizedGroupChange,this._onDidPopoutGroupSizeChange,this._onDidPopoutGroupPositionChange,this._onDidAddPopoutGroup,this._onDidRemovePopoutGroup,this._onDidChangePopouts,this._onDidAddPopoutGroup.event(()=>this._onDidChangePopouts.fire()),this._onDidRemovePopoutGroup.event(()=>this._onDidChangePopouts.fire()),this._onDidOpenPopoutWindowFail,this._onDidStartFloatingGroupDrag,this._onDidEndFloatingGroupDrag,this._onDidCreateTabGroup,this._onDidDestroyTabGroup,this._onDidAddPanelToTabGroup,this._onDidRemovePanelFromTabGroup,this._onDidTabGroupChange,this._onDidTabGroupCollapsedChange,Ve.any(this.onDidPopoutGroupSizeChange,this.onDidPopoutGroupPositionChange,this.onDidCreateTabGroup,this.onDidDestroyTabGroup,this.onDidAddPanelToTabGroup,this.onDidRemovePanelFromTabGroup,this.onDidTabGroupChange,this.onDidTabGroupCollapsedChange)(()=>{this.fireLayoutChange()}),this._onDidOptionsChange,this.onDidAdd(e=>{this._moving||this._onDidAddGroup.fire(e)}),this.onDidRemove(e=>{this._moving||this._onDidRemoveGroup.fire(e)}),this.onDidActiveChange(e=>{this._moving||this._onDidActiveGroupChange.fire(e)}),this.onDidMaximizedChange(e=>{this._onDidMaximizedGroupChange.fire({group:e.panel,isMaximized:e.isMaximized})}),Ve.any(this.onDidAddPanel,this.onDidRemovePanel,this.onDidAddGroup,this.onDidRemove,this.onDidRemoveGroup,this.onDidMovePanel,this.onDidActivePanelChange)(()=>{this._bufferOnDidLayoutChange.fire()}),Re.from(()=>{var e;this._moduleRegistry.dispose(),(e=this._shellManager)==null||e.dispose()}));let i=this._rootDropTargetService;i&&this.addDisposables(i.onWillShowOverlay(e=>{this.gridview.length>0&&e.position===`center`||this._onWillShowOverlay.fire(new rr(e,{kind:`edge`,panel:void 0,api:this._api,group:void 0,getData:Le}))}),i.onDrop(e=>this.dockToLayoutEdge(e.nativeEvent,e.position))),this._moduleRegistry.postConstruct(this)}setVisible(e,t){switch(e.api.location.type){case`grid`:super.setVisible(e,t);break;case`floating`:{let n=this.floatingGroups.find(t=>t.group===e);n&&(n.overlay.setVisible(t),e.api._onDidVisibilityChange.fire({isVisible:t}));break}case`popout`:console.warn(`dockview: You cannot hide a group that is in a popout window`)}}getPopupServiceForGroup(e){var t;return((t=this._popoutWindowService)==null||(t=t.findByGroup(e))==null?void 0:t.popupService)??this.popupService}addPopoutGroup(e,t){return this.mutationAsync(`popout`,()=>this._doAddPopoutGroup(e,t))}getPopouts(){return this._popoutWindowService?.entries.map(e=>({id:e.popoutGroup.id,group:e.popoutGroup,window:e.getWindow()}))??[]}getPopoutWindows(){return this.getPopouts().map(e=>e.window)}_doAddPopoutGroup(e,t){var n;let r=ai(this._popoutWindowService,`PopoutWindow`,`api.addPopoutGroup`);if(!r||e instanceof Ur&&e.model.location.type===`edge`)return Promise.resolve(!1);if(e instanceof Kr&&e.group.size===1)return this.addPopoutGroup(e.group,t);let i=ut(this.gridview.element),a=this.element;function o(){if(t?.position)return t.position;let n=(e instanceof Ur?e.element:e.group?.element??a).getBoundingClientRect();return{left:window.screenX+n.left,top:window.screenY+n.top,width:n.width,height:n.height}}let s=o(),c=(t==null||(n=t.overridePopoutGroup)==null?void 0:n.id)??this.getNextGroupId(),l=t?.popoutUrl??this.options?.popoutUrl,u=new Ki(`${this.id}-${c}`,i??``,{url:l??`/popout.html`,left:s.left,top:s.top,width:s.width,height:s.height,onDidOpen:t?.onDidOpen,onWillClose:t?.onWillClose,nonce:this.options?.nonce}),d=new ze(u,u.onDidClose(()=>{d.dispose()}));return u.open().then(n=>{if(u.isDisposed)return!1;let i=t?.referenceGroup??(e instanceof Kr?e.group:e),a=e.api.location.type,o=i.element.parentElement!==null,s;if(t?.overridePopoutGridview?s=t.overridePopoutGroup??i:o?t?.overridePopoutGroup?s=t.overridePopoutGroup:(s=this.createGroup({id:c}),n&&this._onDidAddGroup.fire(s)):s=i,n===null)return this.handleBlockedPopout({group:s,referenceGroup:i,options:t,popoutWindowDisposable:d}),!1;let f=document.createElement(`div`);f.className=`dv-overlay-render-container`;let p=new Hi(f,this);s.model.renderContainer=p;let m=t?.overridePopoutGridview??this.createNestedGridview();t?.overridePopoutGridview||m.addView(s,At.Distribute,[0]),m.element.style.width=`100%`,m.element.style.height=`100%`,m.layout(u.window.innerWidth,u.window.innerHeight);let h=!1,g=()=>{h||(h=!0,m.dispose())},_,v=[];if(!t?.overridePopoutGroup&&!t?.overridePopoutGridview&&o){if(e instanceof Kr){let t=e.group;this.movingLock(()=>{let t=i.model.removePanel(e);s.model.openPanel(t)}),v=[{panel:e,from:t}]}else switch(this.movingLock(()=>ra({from:i,to:s})),v=s.panels.map(e=>({panel:e,from:i})),a){case`grid`:i.api.setVisible(!1);break;case`floating`:case`popout`:_=this.floatingGroups.find(t=>t.group.api.id===e.api.id)?.overlay.toJSON(),this.removeGroup(i)}}n.classList.add(`dv-dockview`),n.style.overflow=`hidden`,n.appendChild(f),n.appendChild(m.element);let y=document.createElement(`div`),b=new Zi(y,{disabled:this.rootDropTargetContainer.disabled});n.appendChild(y),s.model.dropTargetContainer=b;let x=new Xi(n,u.window);if(d.addDisposables(x),s.model.location={type:`popout`,getWindow:()=>u.window,popoutUrl:l},t?.overridePopoutGridview){let e=this.groups.filter(e=>m.element.contains(e.element));for(let t of e)t.model.renderContainer=p,t.model.dropTargetContainer=b,t.model.location={type:`popout`,getWindow:()=>u.window,popoutUrl:l}}o&&e.api.location.type===`grid`&&e.api.setVisible(!1),this.doSetGroupAndPanelActive(s);let S=r.observeGridviewSize(u,m,p);S&&d.addDisposables(S);let C=new Be;d.addDisposables(C);let w=e=>{C.value=new ze(e.api.onDidActiveChange(e=>{if(e.isActive){var t;(t=u.window)==null||t.focus()}}),e.api.onWillFocus(()=>{var e;(e=u.window)==null||e.focus()}))};w(s);let T={},E=o&&i&&this.getPanel(i.id),D={window:u,popoutGroup:s,gridview:m,overlayRenderContainer:p,dropTargetContainer:b,getWindow:()=>u.window,popoutUrl:l,referenceGroup:E?i.id:void 0,popupService:x,setAnchorGroup:e=>{D.popoutGroup=e,w(e)},disposable:{dispose:()=>(d.dispose(),T.returnedGroup)}},O=mt(u.window);d.addDisposables(O,ht(u.window,()=>{this._onDidPopoutGroupSizeChange.fire({width:u.window.innerWidth,height:u.window.innerHeight,group:D.popoutGroup})}),O.event(()=>{this._onDidPopoutGroupPositionChange.fire({screenX:u.window.screenX,screenY:u.window.screenY,group:D.popoutGroup})}),Q(u.window,`resize`,()=>{m.layout(u.window.innerWidth,u.window.innerHeight)}),p,Re.from(()=>this.disposePopoutWindow({group:s,referenceGroup:i,popoutGridview:m,isGroupAddedToDom:o,floatingBox:_,disposePopoutGridview:g,closeResult:T}))),r.add(D),this._onDidAddPopoutGroup.fire({id:D.popoutGroup.id,group:D.popoutGroup,window:D.getWindow()});for(let{panel:e,from:t}of v)this.fireDidMovePanel(e,t);return!0}).catch(e=>(console.error(`dockview: failed to create popout.`,e),!1))}handleBlockedPopout(e){let{group:t,referenceGroup:n,options:r,popoutWindowDisposable:i}=e;if(console.error(`dockview: failed to create popout. perhaps you need to allow pop-ups for this website`),i.dispose(),this._onDidOpenPopoutWindowFail.fire(),r?.overridePopoutGridview){let e=r.overridePopoutGridview,t=this.groups.filter(t=>e.element.contains(t.element));for(let n of t)this.movingLock(()=>{e.remove(n),this.redockGroupToMainGrid(n)});e.dispose(),n&&!n.api.isVisible&&n.api.setVisible(!0);return}t===n?this.gridview.element.contains(t.element)||(this.movingLock(()=>this.doAddGroup(t,[0])),t.model.location={type:`grid`}):(this.movingLock(()=>ra({from:t,to:n})),t.model.size===0&&this._groups.has(t.id)&&(t.dispose(),this._groups.delete(t.id),this._onDidRemoveGroup.fire(t))),n.api.isVisible||n.api.setVisible(!0)}redockGroupToMainGrid(e){e.model.renderContainer=this.overlayRenderContainer,e.model.dropTargetContainer=this.rootDropTargetContainer,e.model.location={type:`grid`},this.doAddGroup(e,[0])}disposePopoutWindow(e){let{group:t,referenceGroup:n,popoutGridview:r,isGroupAddedToDom:i,floatingBox:a,disposePopoutGridview:o,closeResult:s}=e;if(this.isDisposed){o();return}let c=!!this._popoutWindowService?.entries.find(e=>e.gridview===r),l=this.groups.filter(e=>r.element.contains(e.element)),u=l.includes(t),d=u&&l.length===1,f=[];if(c){for(let e of l)if(e!==t){this.movingLock(()=>{this.doRemoveGroup(e,{skipDispose:!0,skipActive:!0,skipPopoutReturn:!0}),this.redockGroupToMainGrid(e)});for(let t of e.panels)f.push({panel:t,from:e})}}if(u&&i&&this.getPanel(n.id)){let e=[...t.panels];this.movingLock(()=>ra({from:t,to:n}));for(let n of e)f.push({panel:n,from:t});n.api.isVisible||n.api.setVisible(!0),this.getPanel(t.id)&&this.doRemoveGroup(t,{skipPopoutAssociated:!0})}else if(u&&this.getPanel(t.id)){if(t.model.renderContainer=this.overlayRenderContainer,t.model.dropTargetContainer=this.rootDropTargetContainer,s.returnedGroup=t,!c){o();return}if(a&&d)this.addFloatingGroup(t,{height:a.height,width:a.width,position:a});else{this.doRemoveGroup(t,{skipDispose:!0,skipActive:!0,skipPopoutReturn:!0}),t.model.location={type:`grid`},this.movingLock(()=>{this.doAddGroup(t,[0])});for(let e of t.panels)f.push({panel:e,from:t})}this.doSetGroupAndPanelActive(t)}o();for(let{panel:e,from:t}of f)this.fireDidMovePanel(e,t)}addFloatingGroup(e,t){this.mutation(`float`,()=>this._doAddFloatingGroup(e,t))}_doAddFloatingGroup(e,t){if(!ai(this._floatingGroupService,`FloatingGroup`,`api.addFloatingGroup`)||e instanceof Ur&&e.model.location.type===`edge`)return;let n,r=[];if(e instanceof Kr){let t=e.group;n=this.createGroup(),this._onDidAddGroup.fire(n),this.movingLock(()=>this.removePanel(e,{removeEmptyGroup:!0,skipDispose:!0,skipSetActiveGroup:!0})),this.movingLock(()=>n.model.openPanel(e,{skipSetGroupActive:!0})),r=[{panel:e,from:t}]}else{n=e;let i=this._popoutWindowService?.findReferenceGroupId(n),a=i?this.getPanel(i):void 0;typeof t?.skipRemoveGroup==`boolean`&&t.skipRemoveGroup||(a?(this.movingLock(()=>ra({from:e,to:a})),this.doRemoveGroup(e,{skipPopoutReturn:!0,skipPopoutAssociated:!0}),this.doRemoveGroup(a,{skipDispose:!0}),n=a,r=n.panels.map(t=>({panel:t,from:e}))):(this.doRemoveGroup(e,{skipDispose:!0,skipPopoutReturn:!0,skipPopoutAssociated:!1}),r=n.panels.map(e=>({panel:e,from:n}))))}function i(){if(t?.position){let e={};return`left`in t.position?e.left=Math.max(t.position.left,0):`right`in t.position?e.right=Math.max(t.position.right,0):e.left=di.left,`top`in t.position?e.top=Math.max(t.position.top,0):`bottom`in t.position?e.bottom=Math.max(t.position.bottom,0):e.top=di.top,e.width=typeof t.width==`number`?Math.max(t.width,0):di.width,e.height=typeof t.height==`number`?Math.max(t.height,0):di.height,e}return{left:typeof t?.x==`number`?Math.max(t.x,0):di.left,top:typeof t?.y==`number`?Math.max(t.y,0):di.top,width:typeof t?.width==`number`?Math.max(t.width,0):di.width,height:typeof t?.height==`number`?Math.max(t.height,0):di.height}}let a=i(),o=this.createNestedGridview();o.addView(n,At.Distribute,[0]),this.mountFloatingWindow(o,n,[n],a,{dragHandle:t?.dragHandle,inDragMode:t?.inDragMode,skipActiveGroup:t?.skipActiveGroup,disableSmartGuides:t?.disableSmartGuides});for(let{panel:e,from:t}of r)this.fireDidMovePanel(e,t)}createNestedGridview(e=`HORIZONTAL`){return new Gt(!0,this.options.hideBorders?{separatorBorder:`transparent`}:void 0,e,!1,this.options.theme?.gap??0)}mountFloatingWindow(e,t,n,r,i){let a=ai(this._floatingGroupService,`FloatingGroup`,`api.addFloatingGroup`);if(!a)return;let o=(i?.dragHandle??this.options.floatingGroupDragHandle??`titlebar`)===`titlebar`?new $r(this,t):void 0,s=new Qr(tn(tn({container:this._floatingOverlayHost??this.gridview.element,content:e.element,header:o?.element},r),{},{minimumInViewportWidth:this.options.floatingGroupBounds===`boundedWithinViewport`?void 0:this.options.floatingGroupBounds?.minimumWidthWithinViewport??100,minimumInViewportHeight:this.options.floatingGroupBounds===`boundedWithinViewport`?void 0:this.options.floatingGroupBounds?.minimumHeightWithinViewport??100,transformDragPosition:this._buildFloatingDragTransform(t,i?.disableSmartGuides??!1),getSiblingBoxes:()=>this._gatherFloatingGroupBoxes(t)})),c=o?.element??t.element.querySelector(`.dv-void-container`);if(!c)throw Error(`dockview: failed to find drag handle`);s.setupDrag(c,{inDragMode:typeof i?.inDragMode==`boolean`&&i.inDragMode});let l=a.add(t,s,e);l.addDisposables(s.onDidStartMoving(()=>this._onDidStartFloatingGroupDrag.fire(t)),s.onDidChangeEnd(()=>this._onDidEndFloatingGroupDrag.fire(t))),o&&(l.setTitleBar(o),l.addDisposables(o,Re.from(()=>l.setTitleBar(void 0)),o.onDragStart(e=>{this._onWillDragGroup.fire({nativeEvent:e,group:l.group})})));for(let e of n)e.model.location={type:`floating`};i?.skipActiveGroup||this.doSetGroupAndPanelActive(t)}orthogonalize(e,t){switch(this.gridview.normalize(),e){case`top`:case`bottom`:this.gridview.orientation===`HORIZONTAL`&&this.gridview.insertOrthogonalSplitviewAtRoot();break;case`left`:case`right`:this.gridview.orientation===`VERTICAL`&&this.gridview.insertOrthogonalSplitviewAtRoot()}switch(e){case`top`:case`left`:case`center`:return this.createGroupAtLocation([0],void 0,t);case`bottom`:case`right`:return this.createGroupAtLocation([this.gridview.length],void 0,t);default:throw Error(`dockview: unsupported position ${e}`)}}updateOptions(e){var t,n;super.updateOptions(e),this.reportMissingOptionModules(e),(t=this._floatingGroupService)==null||t.updateBounds(e),(n=this._rootDropTargetService)==null||n.setOptions(e);let r=this.options.disableDnd,i=this.options.dndStrategy;this._options=tn(tn({},this.options),e);let a=this.options.disableDnd,o=this.options.dndStrategy;if((r!==a||i!==o)&&this.updateDragAndDropState(),`theme`in e&&this.updateTheme(),`createRightHeaderActionComponent`in e||`createLeftHeaderActionComponent`in e||`createPrefixHeaderActionComponent`in e){var s;(s=this.headerActionsService)==null||s.refreshAll()}if(`createWatermarkComponent`in e){var c;(c=this._watermarkService)==null||c.refresh();for(let e of this.groups)e.model.refreshWatermark()}if(`tabGroupColors`in e||`tabGroupAccent`in e){this._tabGroupColorPalette.setEntries(this._options.tabGroupColors??hr),this._tabGroupColorPalette.enabled=this._options.tabGroupAccent!==`off`;for(let e of this.groups)e.model.refreshTabGroupAccent()}this._onDidOptionsChange.fire(),this._layoutFromShell(this.gridview.width,this.gridview.height)}reportMissingOptionModules(e){ui(e,e=>this._moduleRegistry.has(e))}layout(e,t,n){var r;this._shellManager&&!this._inShellLayout?this._shellManager.layout(e,t):super.layout(e,t,n),this._syncFloatingOverlayHost(),(r=this._moduleRegistry)==null||(r=r.services.floatingGroupService)==null||r.constrainBounds()}_syncFloatingOverlayHost(){if(!this._floatingOverlayHost||!this._shellManager)return;let e=this._shellManager.element.getBoundingClientRect(),t=this.element.getBoundingClientRect(),n=this._floatingOverlayHost;n.style.left=`${t.left-e.left}px`,n.style.top=`${t.top-e.top}px`,n.style.width=`${t.width}px`,n.style.height=`${t.height}px`}_layoutFromShell(e,t){this._inShellLayout=!0,this.layout(e,t,!0),this._inShellLayout=!1}forceRelayout(){this._shellManager?this._layoutFromShell(this.width,this.height):super.forceRelayout()}addEdgeGroup(e,t){let n=this._edgeGroupService;if(!n)throw Error(ri(`EdgeGroup`,`api.addEdgeGroup`));if(n.has(e))throw Error(`dockview: edge group already exists at position '${e}'`);return this.mutation(`add`,()=>{let r=this.createGroup({id:t.id});r.model.location={type:`edge`,position:e},r.model.headerPosition=e;let i=r.model.onDidRemovePanel(()=>{r.model.isEmpty&&(n.isAutoReveal(r)?queueMicrotask(()=>{r.model.isEmpty&&this._edgeGroupService?.includes(r)&&this.removeEdgeGroup(e)}):this.setEdgeGroupCollapsed(r,!0))});return n.add(e,r,i),t.autoHide!==void 0&&n.setAutoHide(r,t.autoHide),t.autoReveal!==void 0&&n.setAutoReveal(r,t.autoReveal),this._onDidAddGroup.fire(r),this._shellManager.addEdgeView(e,t,r),r.api})}revealEdgeGroupWithData(e,t,n){let r=this._edgeGroupService;r&&this.mutation(`add`,()=>{let i=r.get(e);i||=(this.addEdgeGroup(e,{id:this.getNextGroupId(),autoReveal:!0,autoHide:n?.autoHide,collapsed:!0}),r.get(e)),i&&this.moveGroupOrPanel({from:{groupId:t.groupId,panelId:t.panelId??void 0},to:{group:i,position:`center`}})})}getEdgeGroup(e){var t;return(t=this._edgeGroupService)==null||(t=t.get(e))==null?void 0:t.api}getEdgeGroupPanel(e){return this._edgeGroupService?.get(e)}pinEdgeGroup(e){var t;(t=ai(this._moduleRegistry.services.autoHideEdgeGroupService,`AutoHideEdgeGroup`,`api.pinEdgeGroup`))==null||t.pin(e)}autoHideEdgeGroup(e){var t;(t=ai(this._moduleRegistry.services.autoHideEdgeGroupService,`AutoHideEdgeGroup`,`api.autoHideEdgeGroup`))==null||t.autoHide(e)}peekEdgeGroup(e,t){var n;(n=ai(this._moduleRegistry.services.autoHideEdgeGroupService,`AutoHideEdgeGroup`,`api.peekEdgeGroup`))==null||n.peek(e,t)}get overlayRoot(){return this.rootElement}getDropZoneRect(){return this.element.getBoundingClientRect()}getEdgeGroupExpandedSize(e){return this._shellManager?.getEdgeGroupExpandedSize(e)??0}repositionPanelOverlay(e,t,n){this.overlayRenderContainer.repositionPanelOverlay(e.api.id,t,n)}setEdgeGroupVisible(e,t){this._shellManager.setEdgeGroupVisible(e,t)}isEdgeGroupVisible(e){return this._shellManager.isEdgeGroupVisible(e)}removeEdgeGroup(e){let t=ai(this._edgeGroupService,`EdgeGroup`,`api.removeEdgeGroup`);if(!t)return;let n=t.get(e);if(!n)throw Error(`dockview: no edge group exists at position '${e}'`);this.mutation(`remove`,()=>{for(let e of[...n.panels])this.removePanel(e,{removeEmptyGroup:!1,skipDispose:!1});this._shellManager.removeEdgeView(e),t.remove(e),n.dispose(),this._groups.delete(n.id),this._onDidRemoveGroup.fire(n)})}setEdgeGroupCollapsed(e,t){let n=this._edgeGroupService?.findPositionOf(e);n&&this._shellManager.isEdgeGroupCollapsed(n)!==t&&(this._shellManager.setEdgeGroupCollapsed(n,t),e.api._onDidCollapsedChange.fire({isCollapsed:t}))}isEdgeGroupCollapsed(e){let t=this._edgeGroupService?.findPositionOf(e);return t?this._shellManager.isEdgeGroupCollapsed(t):!1}isEdgeGroupPeeking(e){return this._peekingGroups.has(e)}setEdgeGroupPeeking(e,t){this._peekingGroups.has(e)!==t&&(t?this._peekingGroups.add(e):this._peekingGroups.delete(e),e.api._onDidPeekChange.fire({isPeeking:t}))}isEdgeGroupAutoHide(e){let t=this._edgeGroupService?.isAutoHide(e);if(t!==void 0)return t;let n=this._edgeGroupService?.findPositionOf(e);return n!==void 0&&cr(this.options.autoHideEdgeGroups,n)}setEdgeGroupAutoHide(e,t){let n=this._edgeGroupService;n?.includes(e)&&(n.setAutoHide(e,t),this._onDidEdgeGroupAutoHideChange.fire(e))}updateDragAndDropState(){for(let e of this.groups)e.model.updateDragAndDropState()}focus(){var e;(e=this.activeGroup)==null||e.focus()}getGroupPanel(e){return this.panels.find(t=>t.id===e)}setActivePanel(e){e.group.model.openPanel(e),this.doSetGroupAndPanelActive(e.group)}activateNext(e={}){if(!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}if(e.includePanel&&e.group&&e.group.activePanel!==e.group.panels[e.group.panels.length-1]){e.group.model.moveToNext({suppressRoll:!0});return}let t=Rt(e.group.element),n=this.gridview.next(t)?.view;this.doSetGroupAndPanelActive(n)}activatePrevious(e={}){if(!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}if(e.includePanel&&e.group&&e.group.activePanel!==e.group.panels[0]){e.group.model.moveToPrevious({suppressRoll:!0});return}let t=Rt(e.group.element),n=this.gridview.previous(t)?.view;n&&this.doSetGroupAndPanelActive(n)}toJSON(){let e=this.gridview.serialize(),t=this.panels.reduce((e,t)=>(e[t.id]=t.toJSON(),e),{}),n=this._floatingGroupService?.serialize()??[],r=this._popoutWindowService?.serialize()??[],i={grid:e,panels:t,activeGroup:this.activeGroup?.id};n.length>0&&(i.floatingGroups=n),r.length>0&&(i.popoutGroups=r);let a=this._serializeEdgeGroups();return a&&(i.edgeGroups=a),i}_serializeEdgeGroups(){if(!this._edgeGroupService?.hasAny())return;let e=this._shellManager.toJSON();for(let[t,n]of this._edgeGroupService.entries()){let r=e[t];if(!r)continue;if(this._edgeGroupService.isAutoReveal(n)&&n.model.isEmpty){delete e[t];continue}r.group=n.toJSON(),this._edgeGroupService.isAutoReveal(n)&&(r.autoReveal=!0);let i=this._edgeGroupService.isAutoHide(n);i!==void 0&&(r.autoHide=i)}return e}fromJSON(e,t){this.mutation(`load`,()=>this._doFromJSON(e,t))}_doFromJSON(e,t){var n;if((n=this._popoutWindowService)==null||n.cancelPendingRestorations(),typeof e!=`object`||!e)throw Error(`dockview: serialized layout must be a non-null object`);if(!e.grid||e.grid.root?.type!==`branch`||!Array.isArray(e.grid.root.data))throw Error(`dockview: root must be of type branch`);let r=new Map,i=new Map,a=[],o=[],s=()=>{for(let e of o)try{e.dispose()}catch(e){console.error(`dockview: failed to dispose a temporary group created for reuseExistingPanels`,e)}o.length=0};if(t?.reuseExistingPanels){let t=Object.keys(e.panels),n,c=()=>{let e=this.createGroup(),t=this._groups.get(e.api.id);return this._groups.delete(e.api.id),o.push(Re.from(()=>{this.movingLock(()=>{for(let t of e.panels.slice())e.model.removePanel(t)}),t?.disposable.dispose(),e.dispose()})),e};try{for(let e of this.panels)if(t.includes(e.api.id)){r.set(e.api.id,e);let t;e.api.renderer===`always`&&e.api.isVisible?t=c():(n??=c(),t=n),i.set(e.api.id,t),a.push({panel:e,temporaryGroup:t})}this.movingLock(()=>{a.forEach(({panel:e,temporaryGroup:t})=>{this.moveGroupOrPanel({from:{groupId:e.api.group.api.id,panelId:e.api.id},to:{group:t,position:`center`},keepEmptyGroups:!0})})}),this.clear()}catch(e){throw s(),e}}else this.clear();let{grid:c,panels:l,activeGroup:u}=e;try{var d,f,p;let t=this.width,n=this.height,a=e=>{let{id:t,locked:n,hideHeader:a,headerPosition:o,views:s,activeView:c}=e;if(typeof t!=`string`)throw TypeError(`dockview: group id must be of type string`);let u=this.createGroup({id:t,locked:!!n,hideHeader:!!a,headerPosition:o});this._onDidAddGroup.fire(u);let d=[],f=s.filter(e=>l[e]);for(let e of f){let t=r.get(e),n=i.get(e);if(n&&t)this.movingLock(()=>{n.model.removePanel(t)}),d.push(t),t.updateFromStateModel(l[e]);else{let t=this._deserializer.fromJSON(l[e],u);d.push(t)}}for(let e of d){let t=typeof c==`string`&&c===e.id;r.has(e.api.id)?this.movingLock(()=>{u.model.openPanel(e,{skipSetActive:!t,skipSetGroupActive:!0})}):u.model.openPanel(e,{skipSetActive:!t,skipSetGroupActive:!0})}return e.tabGroups&&e.tabGroups.length>0&&u.model.restoreTabGroups(e.tabGroups),!u.activePanel&&u.panels.length>0&&u.model.openPanel(u.panels[u.panels.length-1],{skipSetGroupActive:!0}),u};this.gridview.deserialize(c,{fromJSON:e=>a(e.data)}),this._layoutFromShell(t,n),e.edgeGroups&&this.deserializeEdgeGroups(e.edgeGroups,l,r,i),this.deserializeFloatingWindows(e.floatingGroups??[],a);let o=this.deserializePopoutWindows(e.popoutGroups??[],a);if((d=this._popoutWindowService)==null||d.finishRestoration(o),(f=this._floatingGroupService)==null||f.constrainBounds(),typeof u==`string`){let e=this.getPanel(u);e&&this.doSetGroupAndPanelActive(e)}(p=this._watermarkService)==null||p.update()}catch(e){var m;console.error(`dockview: failed to deserialize layout. Reverting changes`,e);for(let e of this.groups)for(let t of e.panels)this.removePanel(t,{removeEmptyGroup:!1,skipDispose:!1});for(let e of this.groups)e.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e);throw(m=this._floatingGroupService)==null||m.disposeAll(),this.clear(),e}finally{s()}this.debouncedUpdateAllPositions(),this._onDidLayoutFromJSON.fire()}deserializeNestedGridview(e,t){let n=this.createNestedGridview(e.orientation),r=[];return n.deserialize(e,{fromJSON:e=>{let n=t(e.data);return r.push(n),n}}),{gridview:n,members:r}}deserializeEdgeGroups(e,t,n,r){let i=ai(this._edgeGroupService,`EdgeGroup`,`fromJSON edge restoration`);if(i){for(let t of[`top`,`bottom`,`left`,`right`]){let n=e[t];if(n&&!i.has(t)){let e=n.group?.id??`${t}-group`;this.addEdgeGroup(t,{id:e,autoReveal:n.autoReveal,autoHide:n.autoHide,minimumSize:n.minimumSize,maximumSize:n.maximumSize,collapsedSize:n.collapsedSize})}}for(let[a,o]of i.entries()){let i=e[a]?.group;if(i){let{views:e,activeView:a}=i,s=[];for(let i of e){if(!t[i])continue;let e=n.get(i),a=r.get(i);if(a&&e)this.movingLock(()=>{a.model.removePanel(e)}),s.push(e),e.updateFromStateModel(t[i]);else{let e=this._deserializer.fromJSON(t[i],o);s.push(e)}}for(let e of s){let t=a===e.id;n.has(e.api.id)?this.movingLock(()=>{o.model.openPanel(e,{skipSetActive:!t,skipSetGroupActive:!0})}):o.model.openPanel(e,{skipSetActive:!t,skipSetGroupActive:!0})}i.tabGroups&&i.tabGroups.length>0&&o.model.restoreTabGroups(i.tabGroups),!o.activePanel&&o.panels.length>0&&o.model.openPanel(o.panels[o.panels.length-1],{skipSetGroupActive:!0})}}this._shellManager.fromJSON(e)}}deserializeFloatingWindows(e,t){for(let n of e){let{data:e,grid:r,position:i}=n;if(r){let{gridview:e,members:n}=this.deserializeNestedGridview(r,t);if(n.length===0)continue;this.mountFloatingWindow(e,n[0],n,i,{inDragMode:!1})}else if(e){let n=t(e);this.addFloatingGroup(n,{position:i,width:i.width,height:i.height,skipRemoveGroup:!0,inDragMode:!1})}}}deserializePopoutWindows(e,t){let n=e.length>0?ai(this._popoutWindowService,`PopoutWindow`,`fromJSON popout restoration`):this._popoutWindowService;return n?e.flatMap((e,r)=>{let{data:i,grid:a,position:o,gridReferenceGroup:s,url:c}=e,l,u=[];if(a){let e=this.deserializeNestedGridview(a,t);if(l=e.gridview,u=e.members,u.length===0)return l.dispose(),[]}let d=a?u[0]:t(i);return n.scheduleRestoration(r*100,()=>{this.addPopoutGroup(d,{position:o??void 0,overridePopoutGroup:s?d:void 0,overridePopoutGridview:l,referenceGroup:s?this.getPanel(s):void 0,popoutUrl:c})},()=>{for(let e of u.length>0?u:[d])if(!this.isDisposed&&this._groups.has(e.id)&&e.element.parentElement===null){for(let t of[...e.panels])this.removePanel(t,{removeEmptyGroup:!1});e.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)}})}):[]}clear(){this.mutation(`clear`,()=>this._doClear())}_doClear(){let e=Array.from(this._groups.values()).map(e=>e.value),t=!!this.activeGroup;for(let t of e){if(this._edgeGroupService?.includes(t)){let e=[...t.panels];for(let t of e)this.removePanel(t,{removeEmptyGroup:!1});continue}this.removeGroup(t,{skipActive:!0})}t&&this.doSetGroupAndPanelActive(void 0),this.gridview.clear()}closeAllGroups(){this.mutation(`remove`,()=>{for(let e of this._groups.entries()){let[t,n]=e;n.value.model.closeAllPanels()}})}addPanel(e){return this.mutation(`add`,()=>this._doAddPanel(e))}_doAddPanel(e){if(this.panels.some(t=>t.id===e.id))throw Error(`dockview: panel with id ${e.id} already exists`);let t;if(e.position&&e.floating)throw Error(`dockview: you can only provide one of: position, floating as arguments to .addPanel(...)`);let n={width:e.initialWidth,height:e.initialHeight},r,i=t=>!!e.inactive&&t.model.size>0;if(e.position){if(dr(e.position)){let n=typeof e.position.referencePanel==`string`?this.getGroupPanel(e.position.referencePanel):e.position.referencePanel;if(r=e.position.index,!n){let t=typeof e.position.referencePanel==`string`?e.position.referencePanel:e.position.referencePanel?.id;throw Error(`dockview: referencePanel '${t}' does not exist`)}t=this.findGroup(n)}else if(fr(e.position)){if(t=typeof e.position.referenceGroup==`string`?this._groups.get(e.position.referenceGroup)?.value:e.position.referenceGroup,r=e.position.index,!t){let t=typeof e.position.referenceGroup==`string`?e.position.referenceGroup:e.position.referenceGroup?.id;throw Error(`dockview: referenceGroup '${t}' does not exist`)}}else{let t=this.orthogonalize(yn(e.position.direction)),a=this.createPanel(e,t);return t.model.openPanel(a,{skipSetActive:i(t),skipSetGroupActive:e.inactive,index:r}),e.inactive||this.doSetGroupAndPanelActive(t),t.api.setSize({height:n?.height,width:n?.width}),a}}else t=this.activeGroup;let a;if(t){let o=Jt(e.position?.direction||`within`);if(e.floating){let t=this.createGroup();this._onDidAddGroup.fire(t);let n=typeof e.floating==`object`&&e.floating!==null?e.floating:{};this.addFloatingGroup(t,tn(tn({},n),{},{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),a=this.createPanel(e,t),t.model.openPanel(a,{skipSetActive:i(t),skipSetGroupActive:e.inactive,index:r})}else if(t.api.location.type===`floating`||t.api.location.type===`edge`||o===`center`)a=this.createPanel(e,t),t.model.openPanel(a,{skipSetActive:i(t),skipSetGroupActive:e.inactive,index:r}),t.api.setSize({width:n?.width,height:n?.height}),e.inactive||this.doSetGroupAndPanelActive(t);else{let s=Rt(t.element),c=zt(this.gridview.orientation,s,o),l=this.createGroupAtLocation(c,this.orientationAtLocation(c)===`VERTICAL`?n?.height:n?.width);a=this.createPanel(e,l),l.model.openPanel(a,{skipSetActive:i(l),skipSetGroupActive:e.inactive,index:r}),e.inactive||this.doSetGroupAndPanelActive(l)}}else if(e.floating){let t=this.createGroup();this._onDidAddGroup.fire(t);let n=typeof e.floating==`object`&&e.floating!==null?e.floating:{};this.addFloatingGroup(t,tn(tn({},n),{},{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),a=this.createPanel(e,t),t.model.openPanel(a,{skipSetActive:i(t),skipSetGroupActive:e.inactive,index:r})}else{let t=this.createGroupAtLocation([0],this.gridview.orientation===`VERTICAL`?n?.height:n?.width);a=this.createPanel(e,t),t.model.openPanel(a,{skipSetActive:i(t),skipSetGroupActive:e.inactive,index:r}),e.inactive||this.doSetGroupAndPanelActive(t)}return a}removePanel(e,t){this.mutation(`remove`,()=>this._doRemovePanel(e,{removeEmptyGroup:t?.removeEmptyGroup??!0,skipDispose:t?.skipDispose,skipSetActiveGroup:t?.skipSetActiveGroup}))}_doRemovePanel(e,t){let n=e.group;if(!n)throw Error(`dockview: cannot remove panel ${e.id}. it's missing a group.`);n.model.removePanel(e,{skipSetActiveGroup:t.skipSetActiveGroup}),t.skipDispose||(e.group.model.renderContainer.detatch(e),e.dispose()),n.size===0&&t.removeEmptyGroup&&this.removeGroup(n,{skipActive:t.skipSetActiveGroup})}createWatermarkComponent(){return this.options.createWatermarkComponent?this.options.createWatermarkComponent():new Xr}addGroup(e){return this.mutation(`add`,()=>this._doAddGroup(e))}_doAddGroup(e){if(e){let t;if(pr(e)){let n=typeof e.referencePanel==`string`?this.panels.find(t=>t.id===e.referencePanel):e.referencePanel,r=typeof e.referencePanel==`string`?e.referencePanel:e.referencePanel?.id;if(!n)throw Error(`dockview: reference panel ${r} does not exist`);if(t=this.findGroup(n),!t)throw Error(`dockview: reference group for reference panel ${r} does not exist`)}else if(mr(e)){if(t=typeof e.referenceGroup==`string`?this._groups.get(e.referenceGroup)?.value:e.referenceGroup,!t){let t=typeof e.referenceGroup==`string`?e.referenceGroup:e.referenceGroup?.id;throw Error(`dockview: reference group ${t} does not exist`)}}else{let t=this.orthogonalize(yn(e.direction),e);return e.skipSetActive||this.doSetGroupAndPanelActive(t),t}let n=Jt(e.direction||`within`),r=Rt(t.element),i=zt(this.gridview.orientation,r,n),a=this.createGroup(e),o=this.getLocationOrientation(i)===`VERTICAL`?e.initialHeight:e.initialWidth;return this.doAddGroup(a,i,o),e.skipSetActive||this.doSetGroupAndPanelActive(a),a}{let t=this.createGroup(e);return this.doAddGroup(t),this.doSetGroupAndPanelActive(t),t}}getLocationOrientation(e){return e.length%2==0&&this.gridview.orientation===`HORIZONTAL`?`HORIZONTAL`:`VERTICAL`}removeGroup(e,t){this.mutation(`remove`,()=>this.doRemoveGroup(e,t))}detachFromNestedWindow(e){let t=this._floatingGroupService?.findByGroup(e);if(t){let n=this.nestedWindowMembers(e);return n.length<=1?!1:(t.gridview.remove(e),t.group===e&&t.setAnchorGroup(n.find(t=>t!==e)),!0)}let n=this._popoutWindowService?.findByGroup(e);if(n){let t=this.nestedWindowMembers(e);return t.length<=1?!1:(n.gridview.remove(e),n.popoutGroup===e&&n.setAnchorGroup(t.find(t=>t!==e)),!0)}return!1}disposeGroupRecord(e){e.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)}activateFallbackGroupIfRemoved(e,t){if(!t&&this._activeGroup===e){let e=Array.from(this._groups.values());this.doSetGroupAndPanelActive(e.length>0?e[0].value:void 0)}}doRemoveGroup(e,t){if(this._edgeGroupService?.includes(e))return e;let n=[...e.panels];if(!t?.skipDispose)for(let e of n)this.removePanel(e,{removeEmptyGroup:!1,skipDispose:t?.skipDispose??!1});let r=this.activePanel;if(e.api.location.type===`floating`){let n=this._floatingGroupService?.findByGroup(e);if(!n)throw Error(`dockview: failed to find floating group`);return this.detachFromNestedWindow(e)?(t?.skipDispose?e.model.location={type:`grid`}:this.disposeGroupRecord(e),this.activateFallbackGroupIfRemoved(e,t?.skipActive),e):(t?.skipDispose||this.disposeGroupRecord(e),n.dispose(),this.activateFallbackGroupIfRemoved(e,t?.skipActive),e)}if(e.api.location.type===`popout`){var i;let n=this._popoutWindowService?.findByGroup(e);if(!n)throw Error(`dockview: failed to find popout group`);if(this.detachFromNestedWindow(e))return t?.skipDispose?e.model.location={type:`grid`}:this.disposeGroupRecord(e),this.activateFallbackGroupIfRemoved(e,t?.skipActive),e;if(!t?.skipDispose){if(!t?.skipPopoutAssociated){let e=n.referenceGroup?this.getPanel(n.referenceGroup):void 0;e?.panels.length===0&&this.removeGroup(e)}n.popoutGroup.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)}(i=this._popoutWindowService)==null||i.remove(n);let r=n.disposable.dispose();return!t?.skipPopoutReturn&&r&&(this.doAddGroup(r,[0]),this.doSetGroupAndPanelActive(r)),this.activateFallbackGroupIfRemoved(e,t?.skipActive),n.popoutGroup}if(!this.gridview.element.contains(e.element))return t?.skipDispose||(this._groups.get(e.id)?.disposable.dispose(),this.disposeGroupRecord(e)),this.activateFallbackGroupIfRemoved(e,t?.skipActive),e;let a=super.doRemoveGroup(e,t);return t?.skipActive||this.activePanel!==r&&this.fireActivePanelChange(this.activePanel),a}debouncedUpdateAllPositions(){this._updatePositionsFrameId!==void 0&&cancelAnimationFrame(this._updatePositionsFrameId),this._updatePositionsFrameId=requestAnimationFrame(()=>{this._updatePositionsFrameId=void 0,this.overlayRenderContainer.updateAllPositions();for(let e of this._popoutWindowService?.entries??[])e.overlayRenderContainer.updateAllPositions()})}movingLock(e){let t=this._moving;try{return this._moving=!0,e()}finally{this._moving=t}}mutation(e,t){let n=this.openMutation(e);try{return t()}finally{n()}}mutationAsync(e,t){var n=this;return Wi(function*(){let r=n.openMutation(e);try{return yield t()}finally{r()}})()}openMutation(e){let t=this._origin;return this._mutationDepth===0&&this._onWillMutateLayout.fire({kind:e,origin:t}),this._mutationDepth++,()=>{this._mutationDepth--,this._mutationDepth===0&&(this.flushLocationChanges(),this._onDidMutateLayout.fire({kind:e,origin:t}))}}deferLocationChange(e,t){if(this._mutationDepth===0){t();return}this._pendingLocationChanges.set(e,t)}flushLocationChanges(){if(this._pendingLocationChanges.size===0)return;let e=Array.from(this._pendingLocationChanges.values());this._pendingLocationChanges.clear();for(let t of e)t()}currentOrigin(){return this._origin}withOrigin(e,t){if(this._originDepth>0||this._mutationDepth>0)return t();let n=this._origin;this._origin=e,this._originDepth++;try{return t()}finally{this._originDepth--,this._origin=n}}fireActivePanelChange(e){this._onDidActivePanelChange.fire({panel:e,origin:this._origin})}fireDidMovePanel(e,t){this._onDidMovePanel.fire({panel:e,from:t,to:e.group})}moveGroupOrPanel(e){this.mutation(`move`,()=>this._doMoveGroupOrPanel(e))}_doMoveGroupOrPanel(e){let t=e.to.group,n=e.from.groupId,r=e.from.panelId,i=e.to.position,a=e.to.index,o=n?this._groups.get(n)?.value:void 0;if(!o)throw Error(`dockview: Failed to find group id ${n}`);if(r===void 0){e.from.tabGroupId?this.moveTabGroupToGroup({sourceGroup:o,tabGroupId:e.from.tabGroupId,destinationGroup:t,destinationTarget:i,destinationIndex:a,skipSetActive:e.skipSetActive,keepEmptyGroups:e.keepEmptyGroups}):this.moveGroup({from:{group:o},to:{group:t,position:i},skipSetActive:e.skipSetActive});return}if(!i||i===`center`){let n=this.movingLock(()=>o.model.removePanel(r,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!n)throw Error(`dockview: No panel with id ${r}`);!e.keepEmptyGroups&&o.model.size===0&&this.doRemoveGroup(o,{skipActive:!0});let i=t.model.size===0;this.movingLock(()=>t.model.openPanel(n,{index:a,skipSetActive:(e.skipSetActive??!1)&&!i,skipSetGroupActive:!0})),e.skipSetActive||this.doSetGroupAndPanelActive(t),this.fireDidMovePanel(n,o)}else{let e=this.getGridviewForGroup(t),n=Rt(t.element),a=zt(e.orientation,n,i);if(o.size<2){let[n,s]=vt(a);if(o.api.location.type===`grid`&&e===this.gridview){let[e,t]=vt(Rt(o.element));if(yt(e,n)){this.gridview.moveView(e,t,s),this.fireDidMovePanel(this.getGroupPanel(r),o);return}}if(o.api.location.type===`popout`&&this.nestedWindowMembers(o).length<=1){let n=this._popoutWindowService?.findByGroup(o);if(!n)return;let a=this.movingLock(()=>n.popoutGroup.model.removePanel(n.popoutGroup.panels[0],{skipSetActive:!0,skipSetActiveGroup:!0}));this.doRemoveGroup(o,{skipActive:!0});let s=zt(e.orientation,Rt(t.element),i),c=this.createGroupAtLocation(s,void 0,void 0,e);this.movingLock(()=>c.model.openPanel(a,{skipSetActive:!0})),this.doSetGroupAndPanelActive(c),this.fireDidMovePanel(this.getGroupPanel(r),o);return}if(o.api.location.type===`edge`){let t=this.movingLock(()=>o.model.removePanel(r,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!t)throw Error(`dockview: No panel with id ${r}`);let n=this.createGroupAtLocation(a,void 0,void 0,e);this.movingLock(()=>n.model.openPanel(t,{skipSetGroupActive:!0})),this.doSetGroupAndPanelActive(n),this.fireDidMovePanel(t,o);return}let c=this.movingLock(()=>this.doRemoveGroup(o,{skipActive:!0,skipDispose:!0})),l=Rt(t.element),u=zt(e.orientation,l,i);this.movingLock(()=>this.doAddGroup(c,u,void 0,e)),this.setGroupLocationForRoot(c,e),this.doSetGroupAndPanelActive(c),this.fireDidMovePanel(this.getGroupPanel(r),o)}else{let t=this.movingLock(()=>o.model.removePanel(r,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!t)throw Error(`dockview: No panel with id ${r}`);let a=zt(e.orientation,n,i),s=this.createGroupAtLocation(a,void 0,void 0,e);this.movingLock(()=>s.model.openPanel(t,{skipSetGroupActive:!0})),this.doSetGroupAndPanelActive(s),this.fireDidMovePanel(t,o)}}}moveTabGroupToGroup(e){let{sourceGroup:t,tabGroupId:n,destinationGroup:r,destinationTarget:i,destinationIndex:a}=e,o=t.model.getTabGroups().find(e=>e.id===n);if(!o||o.panelIds.length===0)return;let s=o.label,c=o.color,l=o.collapsed,u=o.componentParams,d=[...o.panelIds],f=i&&i!==`center`?Rt(r.element):void 0,p=this.movingLock(()=>d.map(e=>t.model.removePanel(e,{skipSetActive:!1,skipSetActiveGroup:!0})).filter(e=>e!==void 0));if(p.length===0)return;let m=n=>{this.movingLock(()=>{for(let e of p)n.model.openPanel(e,{index:a,skipSetActive:!0,skipSetGroupActive:!0})});let r=n.model.createTabGroup({label:s,color:c,collapsed:l,componentParams:u});for(let e of p)n.model.addPanelToTabGroup(r.id,e.id);e.skipSetActive||this.doSetGroupAndPanelActive(n);for(let e of p)this.fireDidMovePanel(e,t)},h;if(!i||i===`center`||!f)h=r;else{let e=zt(this.gridview.orientation,f,i);h=this.createGroupAtLocation(e)}!e.keepEmptyGroups&&t.model.size===0&&t!==h&&this.doRemoveGroup(t,{skipActive:!0}),m(h)}moveGroup(e){this.mutation(`move`,()=>this._doMoveGroup(e))}maximizeGroup(e){this.mutation(`maximize`,()=>super.maximizeGroup(e))}exitMaximizedGroup(){this.mutation(`maximize`,()=>super.exitMaximizedGroup())}_doMoveGroup(e){let t=e.from.group,n=e.to.group,r=e.to.position,i=t,a;if(r===`center`){let r=t.activePanel,i=t.model.getTabGroups().map(e=>({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams,panelIds:[...e.panelIds]})),o=this.movingLock(()=>[...t.panels].map(e=>t.model.removePanel(e.id,{skipSetActive:!0})));t?.model.size===0&&this.doRemoveGroup(t,{skipActive:!0}),this.movingLock(()=>{for(let e of o)n.model.openPanel(e,{skipSetActive:e!==r,skipSetGroupActive:!0})}),a=o;for(let e of i){let t=n.model.createTabGroup({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams});for(let r of e.panelIds)n.model.addPanelToTabGroup(t.id,r)}e.skipSetActive===!0&&this.activePanel||this.doSetGroupAndPanelActive(n)}else{if(t.api.location.type===`edge`){let e=t.activePanel,n=t.model.getTabGroups().map(e=>({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams,panelIds:[...e.panelIds]})),r=this.movingLock(()=>[...t.panels].map(e=>t.model.removePanel(e.id,{skipSetActive:!0})));i=this.createGroup(),this._onDidAddGroup.fire(i),this.movingLock(()=>{for(let t of r)i.model.openPanel(t,{skipSetActive:t!==e,skipSetGroupActive:!0})});for(let e of n){let t=i.model.createTabGroup({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams});for(let n of e.panelIds)i.model.addPanelToTabGroup(t.id,n)}}else switch(t.api.location.type){case`grid`:this.gridview.removeView(Rt(t.element));break;case`floating`:{let e=this._floatingGroupService?.findByGroup(t);if(!e)throw Error(`dockview: failed to find floating group`);this.detachFromNestedWindow(t)||e.dispose();break}case`popout`:{var o;let e=this._popoutWindowService?.findByGroup(t);if(!e)throw Error(`dockview: failed to find popout group`);if(this.detachFromNestedWindow(t))break;if((o=this._popoutWindowService)==null||o.remove(e),e.referenceGroup){let t=this.getPanel(e.referenceGroup);t&&!t.api.isVisible&&this.doRemoveGroup(t,{skipActive:!0})}e.window.dispose();break}}if(n.api.location.type===`grid`||n.api.location.type===`floating`||n.api.location.type===`popout`){let e=this.getGridviewForGroup(n),a=Rt(n.element),o=zt(e.orientation,a,r),s;switch(e.orientation){case`VERTICAL`:s=a.length%2==0?t.api.width:t.api.height;break;case`HORIZONTAL`:s=a.length%2==0?t.api.height:t.api.width}e.addView(i,s,o),this.setGroupLocationForRoot(i,e)}}if((a??i.panels).forEach(e=>{this.fireDidMovePanel(e,t)}),this.debouncedUpdateAllPositions(),e.skipSetActive===!1){let e=n??t;this.doSetGroupAndPanelActive(e)}else i!==t&&e.skipSetActive!==!0&&this.doSetGroupAndPanelActive(i)}doSetGroupActive(e){super.doSetGroupActive(e);let t=this.activePanel;!this._moving&&t!==this._onDidActivePanelChange.value?.panel&&this.fireActivePanelChange(t)}doSetGroupAndPanelActive(e){super.doSetGroupActive(e);let t=this.activePanel;e&&this.hasMaximizedGroup()&&!this.isMaximizedGroup(e)&&this.exitMaximizedGroup(),!this._moving&&t!==this._onDidActivePanelChange.value?.panel&&this.fireActivePanelChange(t)}getNextGroupId(){let e=this.nextGroupId.next();for(;this._groups.has(e);)e=this.nextGroupId.next();return e}createGroup(e){e??={};let t=e?.id;if(t&&this._groups.has(e.id)&&(console.warn(`dockview: Duplicate group id ${e?.id}. reassigning group id to avoid errors`),t=void 0),!t)for(t=this.nextGroupId.next();this._groups.has(t);)t=this.nextGroupId.next();let n=new Ur(this,t,e);if(n.init({params:{},accessor:this}),!this._groups.has(n.id)){let e=new ze(n.model.onTabDragStart(e=>{var t;(t=this._advancedDnDService)==null||t.dispatchWillDragPanel(e)}),n.model.onGroupDragStart(e=>{var t;(t=this._advancedDnDService)==null||t.dispatchWillDragGroup(e)}),n.model.onMove(e=>{let{groupId:t,itemId:r,target:i,index:a,tabGroupId:o}=e;this.moveGroupOrPanel({from:{groupId:t,panelId:r,tabGroupId:o},to:{group:n,position:i,index:a}})}),n.model.onDidDrop(e=>{this._onDidDrop.fire(e)}),n.model.onWillDrop(e=>{var t;(t=this._advancedDnDService)==null||t.dispatchWillDrop(e)}),n.model.onWillShowOverlay(e=>{var t;if(this.options.disableDnd){e.preventDefault();return}(t=this._advancedDnDService)==null||t.dispatchWillShowOverlay(e)}),n.model.onUnhandledDragOver(e=>{this._onUnhandledDragOver.fire(e)}),n.model.onDidAddPanel(e=>{this._moving||this._onDidAddPanel.fire(e.panel)}),n.model.onDidRemovePanel(e=>{this._moving||this._onDidRemovePanel.fire(e.panel)}),n.model.onDidActivePanelChange(e=>{this._moving||e.panel===this.activePanel&&this._onDidActivePanelChange.value?.panel!==e.panel&&this.fireActivePanelChange(e.panel)}),Ve.any(n.model.onDidPanelTitleChange,n.model.onDidPanelParametersChange)(()=>{this._bufferOnDidLayoutChange.fire()}));this._groups.set(n.id,{value:n,disposable:e})}return n.initialize(),n}createPanel(e,t){let n=e.component,r=e.tabComponent??this.options.defaultTabComponent,i=new Jr(this,e.id,n,r),a=new Kr(e.id,n,r,this,this._api,t,i,{renderer:e.renderer,minimumWidth:e.minimumWidth,minimumHeight:e.minimumHeight,maximumWidth:e.maximumWidth,maximumHeight:e.maximumHeight});return a.init({title:e.title??e.id,params:e?.params??{}}),a}createGroupAtLocation(e,t,n,r=this.gridview){let i=this.createGroup(n);return this.doAddGroup(i,e,t,r),this.setGroupLocationForRoot(i,r),i}setGroupLocationForRoot(e,t){let n=this._popoutWindowService?.entries.find(e=>e.gridview===t);if(n){e.model.renderContainer!==n.overlayRenderContainer&&(e.model.renderContainer=n.overlayRenderContainer),e.model.dropTargetContainer=n.dropTargetContainer,e.model.location={type:`popout`,getWindow:n.getWindow,popoutUrl:n.popoutUrl};return}e.model.renderContainer!==this.overlayRenderContainer&&(e.model.renderContainer=this.overlayRenderContainer),e.model.dropTargetContainer=this.rootDropTargetContainer,e.model.location=t===this.gridview?{type:`grid`}:{type:`floating`}}getGridviewForGroup(e){let t=this._floatingGroupService?.findByGroup(e);if(t)return t.gridview;let n=this._popoutWindowService?.findByGroup(e);return n?n.gridview:this.gridview}nestedWindowMembers(e){let t=this.getGridviewForGroup(e);return t===this.gridview?[]:this.groups.filter(e=>t.element.contains(e.element))}findGroup(e){return Array.from(this._groups.values()).find(t=>t.value.model.containsPanel(e))?.value}orientationAtLocation(e){let t=this.gridview.orientation;return e.length%2==1?t:Ht(t)}updateTheme(){var e,t;let n=this._options.theme??Wr;(e=this._shellThemeClassnames)==null||e.setClassNames(n.className);let r=n.gap??0;this.gridview.margin=r;for(let e of this.floatingGroups)e.gridview.margin=r;for(let e of this._popoutWindowService?.entries??[])e.gridview.margin=r;if((t=this._shellManager)==null||t.updateTheme(r,n.edgeGroupCollapsedSize??35),n.dndOverlayBorder===void 0){var i;this.element.style.removeProperty(`--dv-drag-over-border`),(i=this._shellManager)==null||i.element.style.removeProperty(`--dv-drag-over-border`)}else{var a;this.element.style.setProperty(`--dv-drag-over-border`,n.dndOverlayBorder),(a=this._shellManager)==null||a.element.style.setProperty(`--dv-drag-over-border`,n.dndOverlayBorder)}switch(n.dndOverlayMounting){case`absolute`:this.rootDropTargetContainer.disabled=!1;break;default:this.rootDropTargetContainer.disabled=!0}let o=(n.tabGroupIndicator??`wrap`)===`none`;$(this.element,`dv-tab-group-indicator-none`,o),this._shellManager&&$(this._shellManager.element,`dv-tab-group-indicator-none`,o);for(let e of this.groups)e.model.updateTabGroups()}};function sa(e,t){return new oa(e,t).api}var ca=new Map,la=P(null),ua=P(new Map);function da(e){let t=xe(la);ua.update(n=>{let r=new Map(n);return r.get(e)?.isLocked?r.delete(e):(t?.selectedNode||t?.selectedAnnotation)&&r.set(e,{isLocked:!0,lockedNode:t.selectedNode,lockedAnnotationId:t.selectedAnnotation}),r})}function fa(e){la.set(e)}function pa(){let e=null;return la.subscribe(t=>e=t)(),e}function ma(e,t,n){ca.set(e,{lazy:!1,component:t,defaultTitle:n})}function ha(e,t,n){ca.set(e,{lazy:!0,loader:t,defaultTitle:n})}function ga(e,t){let n=t.params;return{...e,...n,id:t.api.id,type:n?.type??e.type,title:n?.title??t.api.title??e.title}}function _a(e){let t=e,r=null,i=null,a=!1;function o(e){let n=pa();return{panelId:t.id,panelParams:t,panelApi:e.api,containerApi:e.containerApi,graph:n?.graph,selectedNode:n?.selectedNode,selectedAnnotation:n?.selectedAnnotation,activeTool:n?.activeTool||`select`,presentationMode:n?.presentationMode||!1,onRecordHistory:n?.onRecordHistory,onNodeSelect:n?.onNodeSelect,onAnnotationSelect:n?.onAnnotationSelect,onToolChange:n?.onToolChange,onOpenNodePanel:n?.onOpenNodePanel,onPanelAction:n?.onPanelAction}}return{element:document.createElement(`div`),init(e){if(t=ga(t,e),i=this.element,i.style.height=`100%`,i.style.width=`100%`,i.style.overflow=`hidden`,i.classList.add(`dockview-panel-content`),!t||!t.type){console.error(`Panel params missing or invalid:`,t),i.innerHTML=`<div style="padding: 16px; color: var(--status-error);">Invalid panel configuration</div>`;return}let n=ca.get(t.type);if(!n){console.error(`Unknown panel type: ${t.type}`),i.innerHTML=`<div style="padding: 16px; color: var(--status-error);">Unknown panel type: ${t.type}</div>`;return}if(!n.lazy){r=b(n.component,{target:i,props:o(e)});return}i.innerHTML=`<div style="padding: 16px; color: var(--text-subtle);">Loading ${n.defaultTitle}…</div>`,n.loader().then(t=>{a||!i||(i.innerHTML=``,r=b(t.default,{target:i,props:o(e)}))}).catch(e=>{console.error(`Failed to load panel component for type ${t.type}:`,e),!(a||!i)&&(i.innerHTML=`<div style="padding: 16px; color: var(--status-error);">Failed to load ${n.defaultTitle}: ${String(e)}</div>`)})},update(e){},dispose(){a=!0,r&&i&&(n(r),r=null)}}}var va={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`},ya=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},ba=Symbol(`lucide-context`),xa=()=>Te(ba),Sa=new Set([`$$slots`,`$$events`,`$$legacy`,`name`,`color`,`size`,`strokeWidth`,`absoluteStrokeWidth`,`iconNode`,`children`]),Ca=D(`<svg><!><!></svg>`);function wa(e,t){r(t,!0);let n=xa()??{},i=z(t,`color`,19,()=>n.color??`currentColor`),o=z(t,`size`,19,()=>n.size??24),l=z(t,`strokeWidth`,19,()=>n.strokeWidth??2),d=z(t,`absoluteStrokeWidth`,19,()=>n.absoluteStrokeWidth??!1),f=z(t,`iconNode`,19,()=>[]),p=j(t,Sa),m=me(()=>d()?Number(l())*24/Number(o()):l());var h=Ca();be(h,e=>({...va,...e,...p,width:o(),height:o(),stroke:i(),"stroke-width":O(m),class:[`lucide-icon lucide`,n.class,t.name&&`lucide-${t.name}`,t.class]}),[()=>!t.children&&!ya(p)&&{"aria-hidden":`true`}]);var g=q(h);v(g,17,f,c,(e,t)=>{var n=me(()=>a(O(t),2));let r=()=>O(n)[0],i=()=>O(n)[1];var o=u(),s=B(o);V(s,r,!0,(e,t)=>{be(e,()=>({...i()}))}),E(e,o)});var _=G(g);ce(_,()=>t.children??s),w(h),E(e,h),S()}var Ta=new Set([`$$slots`,`$$events`,`$$legacy`]);function Ea(e,t){let n=j(t,Ta),r=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`m14.31 8 5.74 9.94`}],[`path`,{d:`M9.69 8h11.48`}],[`path`,{d:`m7.38 12 5.74-9.94`}],[`path`,{d:`M9.69 16 3.95 6.06`}],[`path`,{d:`M14.31 16H2.83`}],[`path`,{d:`m16.62 12-5.74 9.94`}]];wa(e,W({name:`aperture`},()=>n,{get iconNode(){return r}}))}var Da=new Set([`$$slots`,`$$events`,`$$legacy`]);function Oa(e,t){let n=j(t,Da),r=[[`path`,{d:`m16 3 4 4-4 4`}],[`path`,{d:`M20 7H4`}],[`path`,{d:`m8 21-4-4 4-4`}],[`path`,{d:`M4 17h16`}]];wa(e,W({name:`arrow-right-left`},()=>n,{get iconNode(){return r}}))}var ka=new Set([`$$slots`,`$$events`,`$$legacy`]);function Aa(e,t){let n=j(t,ka),r=[[`path`,{d:`m5 12 7-7 7 7`}],[`path`,{d:`M12 19V5`}]];wa(e,W({name:`arrow-up`},()=>n,{get iconNode(){return r}}))}var ja=new Set([`$$slots`,`$$events`,`$$legacy`]);function Ma(e,t){let n=j(t,ja),r=[[`rect`,{x:`14`,y:`14`,width:`4`,height:`6`,rx:`2`}],[`rect`,{x:`6`,y:`4`,width:`4`,height:`6`,rx:`2`}],[`path`,{d:`M6 20h4`}],[`path`,{d:`M14 10h4`}],[`path`,{d:`M6 14h2v6`}],[`path`,{d:`M14 4h2v6`}]];wa(e,W({name:`binary`},()=>n,{get iconNode(){return r}}))}var Na=new Set([`$$slots`,`$$events`,`$$legacy`]);function Pa(e,t){let n=j(t,Na),r=[[`circle`,{cx:`15`,cy:`9`,r:`7`}],[`circle`,{cx:`9`,cy:`15`,r:`7`}]];wa(e,W({name:`blend`},()=>n,{get iconNode(){return r}}))}var Fa=new Set([`$$slots`,`$$events`,`$$legacy`]);function Ia(e,t){let n=j(t,Fa),r=[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`}],[`path`,{d:`M12 22V12`}]];wa(e,W({name:`box`},()=>n,{get iconNode(){return r}}))}var La=new Set([`$$slots`,`$$events`,`$$legacy`]);function Ra(e,t){let n=j(t,La),r=[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`}],[`circle`,{cx:`12`,cy:`13`,r:`3`}]];wa(e,W({name:`camera`},()=>n,{get iconNode(){return r}}))}var za=new Set([`$$slots`,`$$events`,`$$legacy`]);function Ba(e,t){let n=j(t,za),r=[[`path`,{d:`M20 6 9 17l-5-5`}]];wa(e,W({name:`check`},()=>n,{get iconNode(){return r}}))}var Va=new Set([`$$slots`,`$$events`,`$$legacy`]);function Ha(e,t){let n=j(t,Va),r=[[`path`,{d:`m6 9 6 6 6-6`}]];wa(e,W({name:`chevron-down`},()=>n,{get iconNode(){return r}}))}var Ua=new Set([`$$slots`,`$$events`,`$$legacy`]);function Wa(e,t){let n=j(t,Ua),r=[[`path`,{d:`m9 18 6-6-6-6`}]];wa(e,W({name:`chevron-right`},()=>n,{get iconNode(){return r}}))}var Ga=new Set([`$$slots`,`$$events`,`$$legacy`]);function Ka(e,t){let n=j(t,Ga),r=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`}]];wa(e,W({name:`circle-alert`},()=>n,{get iconNode(){return r}}))}var qa=new Set([`$$slots`,`$$events`,`$$legacy`]);function Ja(e,t){let n=j(t,qa),r=[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`}],[`path`,{d:`m9 11 3 3L22 4`}]];wa(e,W({name:`circle-check-big`},()=>n,{get iconNode(){return r}}))}var Ya=new Set([`$$slots`,`$$events`,`$$legacy`]);function Xa(e,t){let n=j(t,Ya),r=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`m15 9-6 6`}],[`path`,{d:`m9 9 6 6`}]];wa(e,W({name:`circle-x`},()=>n,{get iconNode(){return r}}))}var Za=new Set([`$$slots`,`$$events`,`$$legacy`]);function Qa(e,t){let n=j(t,Za),r=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M12 6v6l4 2`}]];wa(e,W({name:`clock`},()=>n,{get iconNode(){return r}}))}var $a=new Set([`$$slots`,`$$events`,`$$legacy`]);function eo(e,t){let n=j(t,$a),r=[[`path`,{d:`M12 2v2`}],[`path`,{d:`m4.93 4.93 1.41 1.41`}],[`path`,{d:`M20 12h2`}],[`path`,{d:`m19.07 4.93-1.41 1.41`}],[`path`,{d:`M15.947 12.65a4 4 0 0 0-5.925-4.128`}],[`path`,{d:`M13 22H7a5 5 0 1 1 4.9-6H13a3 3 0 0 1 0 6Z`}]];wa(e,W({name:`cloud-sun`},()=>n,{get iconNode(){return r}}))}var to=new Set([`$$slots`,`$$events`,`$$legacy`]);function no(e,t){let n=j(t,to),r=[[`path`,{d:`M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z`}]];wa(e,W({name:`cloud`},()=>n,{get iconNode(){return r}}))}var ro=new Set([`$$slots`,`$$events`,`$$legacy`]);function io(e,t){let n=j(t,ro),r=[[`path`,{d:`M14 3a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1`}],[`path`,{d:`M19 3a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1`}],[`path`,{d:`m7 15 3 3`}],[`path`,{d:`m7 21 3-3H5a2 2 0 0 1-2-2v-2`}],[`rect`,{x:`14`,y:`14`,width:`7`,height:`7`,rx:`1`}],[`rect`,{x:`3`,y:`3`,width:`7`,height:`7`,rx:`1`}]];wa(e,W({name:`combine`},()=>n,{get iconNode(){return r}}))}var ao=new Set([`$$slots`,`$$events`,`$$legacy`]);function oo(e,t){let n=j(t,ao),r=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M12 18a6 6 0 0 0 0-12v12z`}]];wa(e,W({name:`contrast`},()=>n,{get iconNode(){return r}}))}var so=new Set([`$$slots`,`$$events`,`$$legacy`]);function co(e,t){let n=j(t,so),r=[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`}]];wa(e,W({name:`copy`},()=>n,{get iconNode(){return r}}))}var lo=new Set([`$$slots`,`$$events`,`$$legacy`]);function uo(e,t){let n=j(t,lo),r=[[`path`,{d:`M6 2v14a2 2 0 0 0 2 2h14`}],[`path`,{d:`M18 22V8a2 2 0 0 0-2-2H2`}]];wa(e,W({name:`crop`},()=>n,{get iconNode(){return r}}))}var fo=new Set([`$$slots`,`$$events`,`$$legacy`]);function po(e,t){let n=j(t,fo),r=[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`}],[`path`,{d:`M16 8h.01`}],[`path`,{d:`M8 8h.01`}],[`path`,{d:`M8 16h.01`}],[`path`,{d:`M16 16h.01`}],[`path`,{d:`M12 12h.01`}]];wa(e,W({name:`dice-5`},()=>n,{get iconNode(){return r}}))}var mo=new Set([`$$slots`,`$$events`,`$$legacy`]);function ho(e,t){let n=j(t,mo),r=[[`circle`,{cx:`12`,cy:`12`,r:`1`}]];wa(e,W({name:`dot`},()=>n,{get iconNode(){return r}}))}var go=new Set([`$$slots`,`$$events`,`$$legacy`]);function _o(e,t){let n=j(t,go),r=[[`path`,{d:`M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z`}],[`path`,{d:`M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97`}]];wa(e,W({name:`droplets`},()=>n,{get iconNode(){return r}}))}var vo=new Set([`$$slots`,`$$events`,`$$legacy`]);function yo(e,t){let n=j(t,vo),r=[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]];wa(e,W({name:`eye`},()=>n,{get iconNode(){return r}}))}var bo=new Set([`$$slots`,`$$events`,`$$legacy`]);function xo(e,t){let n=j(t,bo),r=[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`}],[`circle`,{cx:`10`,cy:`12`,r:`2`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`}]];wa(e,W({name:`file-image`},()=>n,{get iconNode(){return r}}))}var So=new Set([`$$slots`,`$$events`,`$$legacy`]);function Co(e,t){let n=j(t,So),r=[[`path`,{d:`M4.226 20.925A2 2 0 0 0 6 22h12a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v3.127`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`}],[`path`,{d:`m5 11-3 3`}],[`path`,{d:`m5 17-3-3h10`}]];wa(e,W({name:`file-output`},()=>n,{get iconNode(){return r}}))}var wo=new Set([`$$slots`,`$$events`,`$$legacy`]);function To(e,t){let n=j(t,wo),r=[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`}],[`path`,{d:`M10 9H8`}],[`path`,{d:`M16 13H8`}],[`path`,{d:`M16 17H8`}]];wa(e,W({name:`file-text`},()=>n,{get iconNode(){return r}}))}var Eo=new Set([`$$slots`,`$$events`,`$$legacy`]);function Do(e,t){let n=j(t,Eo),r=[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`}]];wa(e,W({name:`folder-open`},()=>n,{get iconNode(){return r}}))}var Oo=new Set([`$$slots`,`$$events`,`$$legacy`]);function ko(e,t){let n=j(t,Oo),r=[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`}]];wa(e,W({name:`folder`},()=>n,{get iconNode(){return r}}))}var Ao=new Set([`$$slots`,`$$events`,`$$legacy`]);function jo(e,t){let n=j(t,Ao),r=[[`path`,{d:`m12 14 4-4`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`}]];wa(e,W({name:`gauge`},()=>n,{get iconNode(){return r}}))}var Mo=new Set([`$$slots`,`$$events`,`$$legacy`]);function No(e,t){let n=j(t,Mo),r=[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`}],[`circle`,{cx:`18`,cy:`6`,r:`3`}],[`circle`,{cx:`6`,cy:`18`,r:`3`}]];wa(e,W({name:`git-branch`},()=>n,{get iconNode(){return r}}))}var Po=new Set([`$$slots`,`$$events`,`$$legacy`]);function Fo(e,t){let n=j(t,Po),r=[[`circle`,{cx:`18`,cy:`18`,r:`3`}],[`circle`,{cx:`6`,cy:`6`,r:`3`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`}]];wa(e,W({name:`git-merge`},()=>n,{get iconNode(){return r}}))}var Io=new Set([`$$slots`,`$$events`,`$$legacy`]);function Lo(e,t){let n=j(t,Io),r=[[`path`,{d:`M12 3v18`}],[`path`,{d:`M3 12h18`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`}]];wa(e,W({name:`grid-2x2`},()=>n,{get iconNode(){return r}}))}var Ro=new Set([`$$slots`,`$$events`,`$$legacy`]);function zo(e,t){let n=j(t,Ro),r=[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}],[`path`,{d:`M3 9h18`}],[`path`,{d:`M3 15h18`}],[`path`,{d:`M9 3v18`}],[`path`,{d:`M15 3v18`}]];wa(e,W({name:`grid-3x3`},()=>n,{get iconNode(){return r}}))}var Bo=new Set([`$$slots`,`$$events`,`$$legacy`]);function Vo(e,t){let n=j(t,Bo),r=[[`path`,{d:`M3 7V5c0-1.1.9-2 2-2h2`}],[`path`,{d:`M17 3h2c1.1 0 2 .9 2 2v2`}],[`path`,{d:`M21 17v2c0 1.1-.9 2-2 2h-2`}],[`path`,{d:`M7 21H5c-1.1 0-2-.9-2-2v-2`}],[`rect`,{width:`7`,height:`5`,x:`7`,y:`7`,rx:`1`}],[`rect`,{width:`7`,height:`5`,x:`10`,y:`12`,rx:`1`}]];wa(e,W({name:`group`},()=>n,{get iconNode(){return r}}))}var Ho=new Set([`$$slots`,`$$events`,`$$legacy`]);function Uo(e,t){let n=j(t,Ho),r=[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`}]];wa(e,W({name:`hand`},()=>n,{get iconNode(){return r}}))}var Wo=new Set([`$$slots`,`$$events`,`$$legacy`]);function Go(e,t){let n=j(t,Wo),r=[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`}],[`circle`,{cx:`9`,cy:`9`,r:`2`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`}]];wa(e,W({name:`image`},()=>n,{get iconNode(){return r}}))}var Ko=new Set([`$$slots`,`$$events`,`$$legacy`]);function qo(e,t){let n=j(t,Ko),r=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M12 16v-4`}],[`path`,{d:`M12 8h.01`}]];wa(e,W({name:`info`},()=>n,{get iconNode(){return r}}))}var Jo=new Set([`$$slots`,`$$events`,`$$legacy`]);function Yo(e,t){let n=j(t,Jo),r=[[`path`,{d:`M10 8h.01`}],[`path`,{d:`M12 12h.01`}],[`path`,{d:`M14 8h.01`}],[`path`,{d:`M16 12h.01`}],[`path`,{d:`M18 8h.01`}],[`path`,{d:`M6 8h.01`}],[`path`,{d:`M7 16h10`}],[`path`,{d:`M8 12h.01`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`}]];wa(e,W({name:`keyboard`},()=>n,{get iconNode(){return r}}))}var Xo=new Set([`$$slots`,`$$events`,`$$legacy`]);function Zo(e,t){let n=j(t,Xo),r=[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`}]];wa(e,W({name:`layers`},()=>n,{get iconNode(){return r}}))}var Qo=new Set([`$$slots`,`$$events`,`$$legacy`]);function $o(e,t){let n=j(t,Qo),r=[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`}],[`path`,{d:`M9 18h6`}],[`path`,{d:`M10 22h4`}]];wa(e,W({name:`lightbulb`},()=>n,{get iconNode(){return r}}))}var es=new Set([`$$slots`,`$$events`,`$$legacy`]);function ts(e,t){let n=j(t,es),r=[[`path`,{d:`M2 5h20`}],[`path`,{d:`M6 12h12`}],[`path`,{d:`M9 19h6`}]];wa(e,W({name:`list-filter`},()=>n,{get iconNode(){return r}}))}var ns=new Set([`$$slots`,`$$events`,`$$legacy`]);function rs(e,t){let n=j(t,ns),r=[[`path`,{d:`m10 17 5-5-5-5`}],[`path`,{d:`M15 12H3`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`}]];wa(e,W({name:`log-in`},()=>n,{get iconNode(){return r}}))}var is=new Set([`$$slots`,`$$events`,`$$legacy`]);function as(e,t){let n=j(t,is),r=[[`path`,{d:`m16 17 5-5-5-5`}],[`path`,{d:`M21 12H9`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`}]];wa(e,W({name:`log-out`},()=>n,{get iconNode(){return r}}))}var os=new Set([`$$slots`,`$$events`,`$$legacy`]);function ss(e,t){let n=j(t,os),r=[[`path`,{d:`M15 3h6v6`}],[`path`,{d:`m21 3-7 7`}],[`path`,{d:`m3 21 7-7`}],[`path`,{d:`M9 21H3v-6`}]];wa(e,W({name:`maximize-2`},()=>n,{get iconNode(){return r}}))}var cs=new Set([`$$slots`,`$$events`,`$$legacy`]);function ls(e,t){let n=j(t,cs),r=[[`path`,{d:`M5 12h14`}]];wa(e,W({name:`minus`},()=>n,{get iconNode(){return r}}))}var us=new Set([`$$slots`,`$$events`,`$$legacy`]);function ds(e,t){let n=j(t,us),r=[[`path`,{d:`m8 3 4 8 5-5 5 15H2L8 3z`}]];wa(e,W({name:`mountain`},()=>n,{get iconNode(){return r}}))}var fs=new Set([`$$slots`,`$$events`,`$$legacy`]);function ps(e,t){let n=j(t,fs),r=[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`}]];wa(e,W({name:`mouse-pointer-2`},()=>n,{get iconNode(){return r}}))}var ms=new Set([`$$slots`,`$$events`,`$$legacy`]);function hs(e,t){let n=j(t,ms),r=[[`path`,{d:`M5 11V5H11`}],[`path`,{d:`M5 5L19 19`}]];wa(e,W({name:`move-up-left`},()=>n,{get iconNode(){return r}}))}var gs=new Set([`$$slots`,`$$events`,`$$legacy`]);function _s(e,t){let n=j(t,gs),r=[[`path`,{d:`M12 2v20`}],[`path`,{d:`m15 19-3 3-3-3`}],[`path`,{d:`m19 9 3 3-3 3`}],[`path`,{d:`M2 12h20`}],[`path`,{d:`m5 9-3 3 3 3`}],[`path`,{d:`m9 5 3-3 3 3`}]];wa(e,W({name:`move`},()=>n,{get iconNode(){return r}}))}var vs=new Set([`$$slots`,`$$events`,`$$legacy`]);function ys(e,t){let n=j(t,vs),r=[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`}],[`path`,{d:`M12 12V8`}]];wa(e,W({name:`network`},()=>n,{get iconNode(){return r}}))}var bs=new Set([`$$slots`,`$$events`,`$$legacy`]);function xs(e,t){let n=j(t,bs),r=[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`}],[`path`,{d:`M12 22V12`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`}],[`path`,{d:`m7.5 4.27 9 5.15`}]];wa(e,W({name:`package`},()=>n,{get iconNode(){return r}}))}var Ss=new Set([`$$slots`,`$$events`,`$$legacy`]);function Cs(e,t){let n=j(t,Ss),r=[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`}]];wa(e,W({name:`palette`},()=>n,{get iconNode(){return r}}))}var ws=new Set([`$$slots`,`$$events`,`$$legacy`]);function Ts(e,t){let n=j(t,ws),r=[[`path`,{d:`M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z`}],[`path`,{d:`m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18`}],[`path`,{d:`m2.3 2.3 7.286 7.286`}],[`circle`,{cx:`11`,cy:`11`,r:`2`}]];wa(e,W({name:`pen-tool`},()=>n,{get iconNode(){return r}}))}var Es=new Set([`$$slots`,`$$events`,`$$legacy`]);function Ds(e,t){let n=j(t,Es),r=[[`path`,{d:`M5 12h14`}],[`path`,{d:`M12 5v14`}]];wa(e,W({name:`plus`},()=>n,{get iconNode(){return r}}))}var Os=new Set([`$$slots`,`$$events`,`$$legacy`]);function ks(e,t){let n=j(t,Os),r=[[`path`,{d:`M19.07 4.93A10 10 0 0 0 6.99 3.34`}],[`path`,{d:`M4 6h.01`}],[`path`,{d:`M2.29 9.62A10 10 0 1 0 21.31 8.35`}],[`path`,{d:`M16.24 7.76A6 6 0 1 0 8.23 16.67`}],[`path`,{d:`M12 18h.01`}],[`path`,{d:`M17.99 11.66A6 6 0 0 1 15.77 16.67`}],[`circle`,{cx:`12`,cy:`12`,r:`2`}],[`path`,{d:`m13.41 10.59 5.66-5.66`}]];wa(e,W({name:`radar`},()=>n,{get iconNode(){return r}}))}var As=new Set([`$$slots`,`$$events`,`$$legacy`]);function js(e,t){let n=j(t,As),r=[[`path`,{d:`M22 17a10 10 0 0 0-20 0`}],[`path`,{d:`M6 17a6 6 0 0 1 12 0`}],[`path`,{d:`M10 17a2 2 0 0 1 4 0`}]];wa(e,W({name:`rainbow`},()=>n,{get iconNode(){return r}}))}var Ms=new Set([`$$slots`,`$$events`,`$$legacy`]);function Ns(e,t){let n=j(t,Ms),r=[[`path`,{d:`M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z`}],[`path`,{d:`m14.5 12.5 2-2`}],[`path`,{d:`m11.5 9.5 2-2`}],[`path`,{d:`m8.5 6.5 2-2`}],[`path`,{d:`m17.5 15.5 2-2`}]];wa(e,W({name:`ruler`},()=>n,{get iconNode(){return r}}))}var Ps=new Set([`$$slots`,`$$events`,`$$legacy`]);function Fs(e,t){let n=j(t,Ps),r=[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`}]];wa(e,W({name:`save`},()=>n,{get iconNode(){return r}}))}var Is=new Set([`$$slots`,`$$events`,`$$legacy`]);function Ls(e,t){let n=j(t,Is),r=[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`}]];wa(e,W({name:`scan`},()=>n,{get iconNode(){return r}}))}var Rs=new Set([`$$slots`,`$$events`,`$$legacy`]);function zs(e,t){let n=j(t,Rs),r=[[`path`,{d:`M15 12h-5`}],[`path`,{d:`M15 8h-5`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`}]];wa(e,W({name:`scroll-text`},()=>n,{get iconNode(){return r}}))}var Bs=new Set([`$$slots`,`$$events`,`$$legacy`]);function Vs(e,t){let n=j(t,Bs),r=[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]];wa(e,W({name:`settings`},()=>n,{get iconNode(){return r}}))}var Hs=new Set([`$$slots`,`$$events`,`$$legacy`]);function Us(e,t){let n=j(t,Hs),r=[[`path`,{d:`M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2`}]];wa(e,W({name:`sigma`},()=>n,{get iconNode(){return r}}))}var Ws=new Set([`$$slots`,`$$events`,`$$legacy`]);function Gs(e,t){let n=j(t,Ws),r=[[`path`,{d:`M10 5H3`}],[`path`,{d:`M12 19H3`}],[`path`,{d:`M14 3v4`}],[`path`,{d:`M16 17v4`}],[`path`,{d:`M21 12h-9`}],[`path`,{d:`M21 19h-5`}],[`path`,{d:`M21 5h-7`}],[`path`,{d:`M8 10v4`}],[`path`,{d:`M8 12H3`}]];wa(e,W({name:`sliders-horizontal`},()=>n,{get iconNode(){return r}}))}var Ks=new Set([`$$slots`,`$$events`,`$$legacy`]);function qs(e,t){let n=j(t,Ks),r=[[`path`,{d:`M10 8h4`}],[`path`,{d:`M12 21v-9`}],[`path`,{d:`M12 8V3`}],[`path`,{d:`M17 16h4`}],[`path`,{d:`M19 12V3`}],[`path`,{d:`M19 21v-5`}],[`path`,{d:`M3 14h4`}],[`path`,{d:`M5 10V3`}],[`path`,{d:`M5 21v-7`}]];wa(e,W({name:`sliders-vertical`},()=>n,{get iconNode(){return r}}))}var Js=new Set([`$$slots`,`$$events`,`$$legacy`]);function Ys(e,t){let n=j(t,Js),r=[[`path`,{d:`m10 20-1.25-2.5L6 18`}],[`path`,{d:`M10 4 8.75 6.5 6 6`}],[`path`,{d:`m14 20 1.25-2.5L18 18`}],[`path`,{d:`m14 4 1.25 2.5L18 6`}],[`path`,{d:`m17 21-3-6h-4`}],[`path`,{d:`m17 3-3 6 1.5 3`}],[`path`,{d:`M2 12h6.5L10 9`}],[`path`,{d:`m20 10-1.5 2 1.5 2`}],[`path`,{d:`M22 12h-6.5L14 15`}],[`path`,{d:`m4 10 1.5 2L4 14`}],[`path`,{d:`m7 21 3-6-1.5-3`}],[`path`,{d:`m7 3 3 6h4`}]];wa(e,W({name:`snowflake`},()=>n,{get iconNode(){return r}}))}var Xs=new Set([`$$slots`,`$$events`,`$$legacy`]);function Zs(e,t){let n=j(t,Xs),r=[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`}],[`path`,{d:`M20 2v4`}],[`path`,{d:`M22 4h-4`}],[`circle`,{cx:`4`,cy:`20`,r:`2`}]];wa(e,W({name:`sparkles`},()=>n,{get iconNode(){return r}}))}var Qs=new Set([`$$slots`,`$$events`,`$$legacy`]);function $s(e,t){let n=j(t,Qs),r=[[`circle`,{cx:`19`,cy:`5`,r:`2`}],[`circle`,{cx:`5`,cy:`19`,r:`2`}],[`path`,{d:`M5 17A12 12 0 0 1 17 5`}]];wa(e,W({name:`spline`},()=>n,{get iconNode(){return r}}))}var ec=new Set([`$$slots`,`$$events`,`$$legacy`]);function tc(e,t){let n=j(t,ec),r=[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}]];wa(e,W({name:`square`},()=>n,{get iconNode(){return r}}))}var nc=new Set([`$$slots`,`$$events`,`$$legacy`]);function rc(e,t){let n=j(t,nc),r=[[`path`,{d:`M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z`}],[`path`,{d:`M15 3v5a1 1 0 0 0 1 1h5`}]];wa(e,W({name:`sticky-note`},()=>n,{get iconNode(){return r}}))}var ic=new Set([`$$slots`,`$$events`,`$$legacy`]);function ac(e,t){let n=j(t,ic),r=[[`circle`,{cx:`12`,cy:`12`,r:`4`}],[`path`,{d:`M12 2v2`}],[`path`,{d:`M12 20v2`}],[`path`,{d:`m4.93 4.93 1.41 1.41`}],[`path`,{d:`m17.66 17.66 1.41 1.41`}],[`path`,{d:`M2 12h2`}],[`path`,{d:`M20 12h2`}],[`path`,{d:`m6.34 17.66-1.41 1.41`}],[`path`,{d:`m19.07 4.93-1.41 1.41`}]];wa(e,W({name:`sun`},()=>n,{get iconNode(){return r}}))}var oc=new Set([`$$slots`,`$$events`,`$$legacy`]);function sc(e,t){let n=j(t,oc),r=[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`}]];wa(e,W({name:`tag`},()=>n,{get iconNode(){return r}}))}var cc=new Set([`$$slots`,`$$events`,`$$legacy`]);function lc(e,t){let n=j(t,cc),r=[[`path`,{d:`m10.065 12.493-6.18 1.318a.934.934 0 0 1-1.108-.702l-.537-2.15a1.07 1.07 0 0 1 .691-1.265l13.504-4.44`}],[`path`,{d:`m13.56 11.747 4.332-.924`}],[`path`,{d:`m16 21-3.105-6.21`}],[`path`,{d:`M16.485 5.94a2 2 0 0 1 1.455-2.425l1.09-.272a1 1 0 0 1 1.212.727l1.515 6.06a1 1 0 0 1-.727 1.213l-1.09.272a2 2 0 0 1-2.425-1.455z`}],[`path`,{d:`m6.158 8.633 1.114 4.456`}],[`path`,{d:`m8 21 3.105-6.21`}],[`circle`,{cx:`12`,cy:`13`,r:`2`}]];wa(e,W({name:`telescope`},()=>n,{get iconNode(){return r}}))}var uc=new Set([`$$slots`,`$$events`,`$$legacy`]);function dc(e,t){let n=j(t,uc),r=[[`path`,{d:`M12 19h8`}],[`path`,{d:`m4 17 6-6-6-6`}]];wa(e,W({name:`terminal`},()=>n,{get iconNode(){return r}}))}var fc=new Set([`$$slots`,`$$events`,`$$legacy`]);function pc(e,t){let n=j(t,fc),r=[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`}],[`circle`,{cx:`12`,cy:`14`,r:`8`}]];wa(e,W({name:`timer`},()=>n,{get iconNode(){return r}}))}var mc=new Set([`$$slots`,`$$events`,`$$legacy`]);function hc(e,t){let n=j(t,mc),r=[[`path`,{d:`M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z`}]];wa(e,W({name:`triangle`},()=>n,{get iconNode(){return r}}))}var gc=new Set([`$$slots`,`$$events`,`$$legacy`]);function _c(e,t){let n=j(t,gc),r=[[`path`,{d:`M12 4v16`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`}],[`path`,{d:`M9 20h6`}]];wa(e,W({name:`type`},()=>n,{get iconNode(){return r}}))}var vc=new Set([`$$slots`,`$$events`,`$$legacy`]);function yc(e,t){let n=j(t,vc),r=[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`}]];wa(e,W({name:`volume-2`},()=>n,{get iconNode(){return r}}))}var bc=new Set([`$$slots`,`$$events`,`$$legacy`]);function xc(e,t){let n=j(t,bc),r=[[`path`,{d:`M2 12q2.5 2 5 0t5 0 5 0 5 0`}],[`path`,{d:`M2 19q2.5 2 5 0t5 0 5 0 5 0`}],[`path`,{d:`M2 5q2.5 2 5 0t5 0 5 0 5 0`}]];wa(e,W({name:`waves-horizontal`},()=>n,{get iconNode(){return r}}))}var Sc=new Set([`$$slots`,`$$events`,`$$legacy`]);function Cc(e,t){let n=j(t,Sc),r=[[`path`,{d:`M12.8 19.6A2 2 0 1 0 14 16H2`}],[`path`,{d:`M17.5 8a2.5 2.5 0 1 1 2 4H2`}],[`path`,{d:`M9.8 4.4A2 2 0 1 1 11 8H2`}]];wa(e,W({name:`wind`},()=>n,{get iconNode(){return r}}))}var wc=new Set([`$$slots`,`$$events`,`$$legacy`]);function Tc(e,t){let n=j(t,wc),r=[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`}]];wa(e,W({name:`workflow`},()=>n,{get iconNode(){return r}}))}var Ec=new Set([`$$slots`,`$$events`,`$$legacy`]);function Dc(e,t){let n=j(t,Ec),r=[[`path`,{d:`M18 6 6 18`}],[`path`,{d:`m6 6 12 12`}]];wa(e,W({name:`x`},()=>n,{get iconNode(){return r}}))}var Oc=new Set([`$$slots`,`$$events`,`$$legacy`]);function kc(e,t){let n=j(t,Oc),r=[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`}]];wa(e,W({name:`zap`},()=>n,{get iconNode(){return r}}))}function Ac(n,i){r(i,!1);let a=I(),o=z(i,`name`,8),s=z(i,`size`,8,16),c=z(i,`color`,8,void 0),l=z(i,`strokeWidth`,8,2),d=z(i,`class`,8,``),f={Settings:Vs,Plus:Ds,X:Dc,Triangle:hc,Ruler:Ns,Timer:pc,MousePointer2:ps,Keyboard:Yo,Eye:yo,Save:Fs,Palette:Cs,Droplets:_o,Sun:ac,Sliders:qs,Camera:Ra,Volume2:yc,Zap:kc,FileText:To,FolderOpen:Do,Copy:co,Package:xs,Info:qo,Clock:Qa,Check:Ba,CheckCircle:Ja,XCircle:Xa,MoveUpLeft:hs,Hand:Uo,Waves:xc,ChevronDown:Ha,ChevronRight:Wa,SlidersHorizontal:Gs,Network:ys,Workflow:Tc,ScrollText:zs,Type:_c,Image:Go,Folder:ko,Minus:ls,PenTool:Ts,StickyNote:rc,FileImage:xo,Square:tc,Box:Ia,Move:_s,Maximize2:ss,Layers:Zo,GitMerge:Fo,Dice5:po,ListFilter:ts,Snowflake:Ys,LogIn:rs,LogOut:as,ArrowUp:Aa,CloudSun:eo,Telescope:lc,Rainbow:js,Mountain:ds,Crop:uo,Contrast:oo,Scan:Ls,Spline:$s,Dot:ho,Grid2x2:Lo,Tag:sc,Aperture:Ea,Gauge:jo,Wind:Cc,Combine:io,Group:Vo,FileOutput:Co,Sparkles:Zs,Binary:Ma,Radar:ks,ArrowRightLeft:Oa,Cloud:no,Blend:Pa,Lightbulb:$o,Grid3x3:zo,Terminal:dc,View:yo,GitGraph:No,Logs:dc,Grid:zo,Gradient:Pa,GitBranch:No};e(()=>(k(o()),Vs),()=>{Y(a,f[o()]||Vs)}),ie();var p=u(),m=B(p);t(m,()=>O(a),(e,t)=>{t(e,{get size(){return s()},get color(){return c()},get strokeWidth(){return l()},get class(){return d()}})}),E(n,p),S()}var jc=T(`<span aria-hidden="true"><!></span>`);function Mc(t,n){r(n,!1);let a=I(),o=z(n,`icon`,8),s=z(n,`size`,8,14),c=z(n,`class`,8,``);e(()=>k(o()),()=>{Y(a,/^[A-Z][A-Za-z0-9]+$/.test(o()))}),ie(),le();var u=jc(),d=q(u),f=e=>{Ac(e,{get name(){return o()},get size(){return s()}})},p=e=>{var t=l();J(()=>X(t,o())),E(e,t)};m(d,e=>{O(a)?e(f):e(p,-1)}),w(u),J(()=>i(u,1,_(c()),`svelte-4q1po5`)),E(t,u),S()}var Nc=`cascade-dockview-layout`;function Pc(e){return e.panel?.id??null}function Fc(e,t){let n=(e,r)=>{if(e?.type===`leaf`)return e.data?.id===t?r:null;if(e?.type!==`branch`||!Array.isArray(e.data))return null;let i=r===`width`?`height`:`width`;for(let t of e.data){let e=n(t,i);if(e)return e}return null},r=e.orientation===Ot.HORIZONTAL?`width`:`height`;return n(e.root,r)}var Ic=[{type:`graph`,label:`Graph`,icon:`⬡`},{type:`viewer`,label:`Viewer`,icon:`👁`},{type:`inspector`,label:`Inspector`,icon:`⚙`},{type:`info`,label:`Node Info`,icon:`ℹ`},{type:`log`,label:`Log`,icon:`📋`}],Lc=P([...Ic]);function Rc(e){Lc.set([...Ic,...e.map(e=>({type:`project:${e.name}`,label:e.title,icon:e.icon??`▣`}))])}function zc(e,t){let r=xe(Lc).find(e=>e.type===t)?.icon;if(!r)return;let i=b(Mc,{target:e,props:{icon:r,size:14}});return()=>{n(i)}}var Bc=new class{#e;get _api(){return O(this.#e)}set _api(e){Y(this.#e,e,!0)}#t;get _activePanel(){return O(this.#t)}set _activePanel(e){Y(this.#t,e,!0)}#n;get _panels(){return O(this.#n)}set _panels(e){Y(this.#n,e,!0)}#r;get _isReady(){return O(this.#r)}set _isReady(e){Y(this.#r,e,!0)}#i;get _minimizedGroups(){return O(this.#i)}set _minimizedGroups(e){Y(this.#i,e,!0)}constructor(){this.#e=re(null),this.#t=re(null),this.#n=re(_e(new Map)),this.#r=re(!1),this.#i=re(_e(new Map)),this.onAddPanelClick=null}get api(){return this._api}get activePanel(){return this._activePanel}get panels(){return this._panels}get isReady(){return this._isReady}get minimizedGroups(){return this._minimizedGroups}initialize(e){let t=this,n=sa(e,{createComponent:e=>_a({id:e.id,type:e.name,title:e.name.charAt(0).toUpperCase()+e.name.slice(1)}),createRightHeaderActionComponent:e=>({element:(()=>{let n=document.createElement(`div`);n.className=`cascade-header-actions`;let r=document.createElement(`button`);return r.className=`cascade-add-panel-btn`,r.innerHTML=`+`,r.title=`Add panel`,r.onclick=n=>{n.stopPropagation();let i=r.getBoundingClientRect(),a=e.id;t.onAddPanelClick&&t.onAddPanelClick(a,{x:i.left,y:i.bottom})},n.appendChild(r),n})(),init:()=>{},dispose:()=>{}}),createTabComponent:e=>{let n=document.createElement(`div`);n.className=`cascade-tab`;let r=document.createElement(`button`);r.className=`cascade-tab-lock`,r.innerHTML=`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>`,r.title=`Lock to current node`,r.style.display=`none`,n.appendChild(r);let i=document.createElement(`span`);i.className=`cascade-tab-title`;let a=document.createElement(`span`);a.className=`cascade-tab-icon`,n.appendChild(a),n.appendChild(i);let o=document.createElement(`button`);o.className=`cascade-tab-close`,o.innerHTML=`×`,o.title=`Close`,n.appendChild(o);let s=null,c=``,l=``,u=null,d=null,f,p=()=>{let e=xe(ua).get(c),t=xe(la),n=!!(t?.selectedNode||t?.selectedAnnotation);e?.isLocked?(r.classList.add(`locked`),r.innerHTML=`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>`,r.title=`Unlock (follow selection)`,r.disabled=!1):(r.classList.remove(`locked`),r.innerHTML=`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 5-5 5 5 0 0 1 5 5v4"/><line x1="17" y1="7" x2="21" y2="3"/></svg>`,r.title=n?`Lock to current node`:`Lock to empty view`,r.disabled=!1)};return{element:n,init:e=>{s=e.api,c=e.api.id,l=e.params?.type||``,f=zc(a,l),f||a.remove(),(l===`viewer`||l===`inspector`)&&(r.style.display=`flex`,u=ua.subscribe(()=>{p()}),d=la.subscribe(()=>{p()}),r.onclick=e=>{e.stopPropagation(),da(c)},p()),i.textContent=s.title||`Untitled`,s.onDidTitleChange(()=>{i.textContent=s.title||`Untitled`}),i.ondblclick=e=>{e.stopPropagation();let n=s?.group;n?.id&&t.toggleMinimizeGroup(n.id)},o.onclick=e=>{e.stopPropagation(),s.close()}},dispose:()=>{s=null,u&&u(),d&&d(),f?.()}}},disableFloatingGroups:!0,defaultTabComponent:`cascadeTab`});this._api=n,n.onDidActivePanelChange(e=>{this._activePanel=Pc(e)}),n.onDidAddPanel(e=>{let t=e.params;t&&(this._panels=new Map(this._panels).set(e.id,t))}),n.onDidRemovePanel(e=>{let t=new Map(this._panels);t.delete(e.id),this._panels=t}),this.loadLayout(),this._isReady=!0}addPanel(e){if(!this._api)return;let t={id:e.id,type:e.type,title:e.title,...e.params},n={id:e.id,component:e.type,title:e.title,params:t};if(e.referencePanel&&e.position){let t=this._api.getPanel(e.referencePanel);t&&(n.position={referencePanel:t,direction:e.position===`within`?void 0:e.position})}this._api.addPanel(n)}removePanel(e){if(!this._api)return;let t=this._api.getPanel(e);t&&t.api.close()}focusPanel(e){if(!this._api)return;let t=this._api.getPanel(e);t&&t.api.setActive()}hasPanel(e){return this._panels.has(e)}addPanelToGroup(e,t){if(!this._api)return;let n=e.startsWith(`project:`)?e.slice(8):void 0,r=n?e:`${e}-${Date.now()}`;if(n&&this._panels.has(r)){this.focusPanel(r);return}let i=xe(Lc).find(t=>t.type===e)?.label??e.charAt(0).toUpperCase()+e.slice(1),a=this._api.getGroup(t);if(!a)return;let o=a.panels,s=o.length>0?o[0]:null;this.addPanel({id:r,type:e,title:i,position:`within`,referencePanel:s?.id,params:n?{projectPanelName:n}:void 0})}openProjectPanel(e,t){let n=`project:${e}`,r=t?`${n}:${t}`:n;if(this._panels.has(r)){this.focusPanel(r);return}let i=this._activePanel||[...this._panels.keys()][0];this.addPanel({id:r,type:n,title:xe(Lc).find(e=>e.type===n)?.label??e,position:i?`within`:void 0,referencePanel:i,params:{projectPanelName:e,sourceNodeId:t}})}isActivePanelMaximized(){return this._api?this._api.hasMaximizedGroup?.()??!1:!1}toggleMaximizeActivePanel(){if(this._api){if(this._api.hasMaximizedGroup())this._api.exitMaximizedGroup();else{let e=this._api.getPanel(this._activePanel||``);e&&this._api.maximizeGroup(e)}}}toggleMinimizeGroup(e){if(!this._api)return;let t=this._api.getGroup(e);if(!t)return;let n=this._minimizedGroups.has(e),r=this._minimizedGroups.get(e),i=Fc(this._api.toJSON().grid,e);if(i){if(n&&r){t.api.setConstraints(r.axis===`width`?{minimumWidth:r.minimum}:{minimumHeight:r.minimum}),t.api.setSize({[r.axis]:r.size});let n=new Map(this._minimizedGroups);n.delete(e),this._minimizedGroups=n}else{let n=new Map(this._minimizedGroups);n.set(e,{size:t[i]||200,minimum:i===`width`?t.minimumWidth:t.minimumHeight,axis:i}),this._minimizedGroups=n,t.api.setConstraints(i===`width`?{minimumWidth:35}:{minimumHeight:35}),t.api.setSize({[i]:35})}}}openCodeEditor(e,t){let n=`code-${e}`;if(this._panels.has(n)){this.focusPanel(n);return}this.addPanel({id:n,type:`code`,title:`Code: ${t}`,position:`within`,referencePanel:`graph-main`,params:{nodeId:e}})}filterCodePanelsFromLayout(e){let t=new Set(xe(Lc).map(e=>e.type));if(e.panels){let n={};for(let[r,i]of Object.entries(e.panels)){let e=i?.contentComponent;!r.startsWith(`code-`)&&(!String(e).startsWith(`project:`)||t.has(e))&&(n[r]=i)}e.panels=n}e.grid?.root&&this.filterCodePanelsFromGridNode(e.grid.root,new Set(Object.keys(e.panels??{})))}filterCodePanelsFromGridNode(e,t){if(e){if(e.type===`leaf`&&e.data?.views)e.data.views=e.data.views.filter(e=>!e.startsWith(`code-`)&&(!t||t.has(e))),e.data.activeView?.startsWith(`code-`)&&(e.data.activeView=e.data.views[0]||null);else if(e.type===`branch`&&e.data)for(let n of e.data)this.filterCodePanelsFromGridNode(n,t)}}saveLayout(){if(this._api)try{let e=this._api.toJSON();localStorage.setItem(Nc,JSON.stringify(e))}catch(e){console.warn(`Failed to save layout:`,e)}}loadLayout(e){if(!this._api)return;let t=e,n=!1;if(!t)try{let e=localStorage.getItem(Nc);e&&(t=JSON.parse(e),n=!0,t&&this.filterCodePanelsFromLayout(t))}catch(e){console.warn(`Failed to parse saved layout:`,e),localStorage.removeItem(Nc)}t||=this.getDefaultLayout();try{this._api.fromJSON(t)}catch(e){if(console.warn(`Failed to load layout:`,e),n){localStorage.removeItem(Nc);try{this._api.fromJSON(this.getDefaultLayout())}catch(e){console.error(`Failed to load default layout:`,e),this.createDefaultPanels()}}else console.error(`Default layout failed, creating panels manually`),this.createDefaultPanels()}}createDefaultPanels(){if(this._api)try{this._api.addPanel({id:`graph-main`,component:`graph`,title:`Graph`,params:{id:`graph-main`,type:`graph`,title:`Graph`}}),this._api.addPanel({id:`viewer-main`,component:`viewer`,title:`Viewer`,position:{referencePanel:`graph-main`,direction:`right`},params:{id:`viewer-main`,type:`viewer`,title:`Viewer`}}),this._api.addPanel({id:`log-main`,component:`log`,title:`Log`,position:{referencePanel:`viewer-main`,direction:`below`},params:{id:`log-main`,type:`log`,title:`Log`}}),this._api.addPanel({id:`inspector-main`,component:`inspector`,title:`Inspector`,position:{referencePanel:`viewer-main`,direction:`right`},params:{id:`inspector-main`,type:`inspector`,title:`Inspector`}})}catch(e){console.error(`Failed to create default panels:`,e)}}resetLayout(){this._api&&(this._api.clear(),this._api.fromJSON(this.getDefaultLayout()),this.saveLayout())}getDefaultLayout(){return{grid:{root:{type:`branch`,data:[{type:`leaf`,data:{views:[`graph-main`],activeView:`graph-main`,id:`group-graph`},size:500},{type:`branch`,data:[{type:`leaf`,data:{views:[`viewer-main`],activeView:`viewer-main`,id:`group-viewer`},size:600},{type:`leaf`,data:{views:[`log-main`],activeView:`log-main`,id:`group-log`},size:200}],size:250},{type:`leaf`,data:{views:[`inspector-main`],activeView:`inspector-main`,id:`group-inspector`},size:250}]},width:1e3,height:800,orientation:Ot.HORIZONTAL},panels:{"graph-main":{id:`graph-main`,contentComponent:`graph`,title:`Graph`,params:{id:`graph-main`,type:`graph`,title:`Graph`}},"viewer-main":{id:`viewer-main`,contentComponent:`viewer`,title:`Viewer`,params:{id:`viewer-main`,type:`viewer`,title:`Viewer`}},"inspector-main":{id:`inspector-main`,contentComponent:`inspector`,title:`Inspector`,params:{id:`inspector-main`,type:`inspector`,title:`Inspector`}},"log-main":{id:`log-main`,contentComponent:`log`,title:`Log`,params:{id:`log-main`,type:`log`,title:`Log`}}},activeGroup:`group-graph`}}exportLayout(){return this._api?.toJSON()??null}dispose(){this.saveLayout(),this._api?.dispose(),this._api=null,this._activePanel=null,this._isReady=!1,this._panels=new Map,this._minimizedGroups=new Map}};function Vc(e){if(typeof e==`object`&&!Array.isArray(e)&&`r`in e&&`g`in e&&`b`in e){let t=e,n=t.r<=1&&t.g<=1&&t.b<=1;return{r:n?t.r:t.r/255,g:n?t.g:t.g/255,b:n?t.b:t.b/255,a:t.a===void 0?1:n?t.a:t.a/255}}if(Array.isArray(e)){let t=e.every(e=>e<=1);return{r:t?e[0]:e[0]/255,g:t?e[1]:e[1]/255,b:t?e[2]:e[2]/255,a:e[3]===void 0?1:t?e[3]:e[3]/255}}if(typeof e==`string`){let t=e.match(/rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);if(t)return{r:parseInt(t[1],10)/255,g:parseInt(t[2],10)/255,b:parseInt(t[3],10)/255,a:1};let n=e.replace(`#`,``);if(n.length===3||n.length===6){let e=n.length===3?n.split(``).map(e=>e+e).join(``):n,t=/^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(t)return{r:parseInt(t[1],16)/255,g:parseInt(t[2],16)/255,b:parseInt(t[3],16)/255,a:1}}}return{r:0,g:0,b:0,a:1}}function Hc(e){let t=Math.round(e.r*255),n=Math.round(e.g*255),r=Math.round(e.b*255),i=e.a===void 0?1:e.a;return i<1?`rgba(${t},${n},${r},${i})`:`rgb(${t},${n},${r})`}function Uc(e){return`#${Math.round(e.r*255).toString(16).padStart(2,`0`)}${Math.round(e.g*255).toString(16).padStart(2,`0`)}${Math.round(e.b*255).toString(16).padStart(2,`0`)}`.toUpperCase()}function Wc(e){if(typeof e==`string`)return e.startsWith(`#`)||e.startsWith(`rgb(`);if(typeof e==`object`&&e){if(`r`in e&&`g`in e&&`b`in e)return!0;if(Array.isArray(e)&&(e.length===3||e.length===4))return e.every(e=>typeof e==`number`)}return!1}var Gc=class{constructor(){this.compiledCache=new Map,this.graph=null,this._frame=1,this._fps=30}setGraph(e){this.graph=e}setFrame(e){this._frame=Math.max(1,Math.floor(e))}setFps(e){this._fps=Math.max(1,e)}get time(){return this._frame/this._fps}get frame(){return this._frame}get fps(){return this._fps}compile(e){let t=this.compiledCache.get(e);if(t)return t;let n=this.extractDependencies(e),r=this.hasTimeReference(e);try{let t=`
|
|
3
|
+
with (context) {
|
|
4
|
+
return (${e});
|
|
5
|
+
}
|
|
6
|
+
`,i={source:e,evaluate:Function(`context`,t),dependencies:n,isTimeDependent:r};return this.compiledCache.set(e,i),i}catch(t){return{source:e,evaluate:()=>void 0,dependencies:n,isTimeDependent:r,error:t instanceof Error?t.message:String(t)}}}evaluate(e,t){let n=this.compile(e);if(n.error)return{value:void 0,error:n.error};try{let e=this.createContext(t);return{value:n.evaluate(e)}}catch(e){return{value:void 0,error:e instanceof Error?e.message:String(e)}}}createContext(e){let t=this;return{time:this.time,frame:this._frame,fps:this._fps,self:e,ch:n=>t.ch(e,n),chs:n=>t.chs(e,n),chv:n=>t.chv(e,n),opexist:n=>t.opexist(e,n),opinput:n=>t.opinput(e,n),fit:this.fit,fit01:this.fit01,clamp:this.clamp,lerp:this.lerp,smooth:this.smooth,noise:this.noise,random:this.random,padzero:this.padzero,Math}}ch(e,t){let n=this.resolvePath(e,t);if(!n)return 0;let r=n.value;return typeof r==`number`?r:typeof r==`string`?parseFloat(r)||0:typeof r==`boolean`?+!!r:0}chs(e,t){let n=this.resolvePath(e,t);return n?String(n.value??``):``}chv(e,t){let n=this.resolvePath(e,t);if(!n)return[];let r=n.value;return Array.isArray(r)?r.map(e=>typeof e==`number`?e:parseFloat(e)||0):typeof r==`number`?[r]:[]}resolvePath(e,t){let n=t.lastIndexOf(`/`);if(n===-1||t.startsWith(`./`)){let n=t.replace(`./`,``),r=e.props[n];return r?{value:r.value}:null}let r=t.substring(0,n)||`.`,i=t.substring(n+1),a=e.node(r);if(!a)return null;let o=a.props[i];return o?{value:o.value}:null}validatePath(e,t){return this.resolvePath(e,t)!==null}validateAllPaths(){if(!this.graph)return[];let e=[];for(let t of this.graph.nodes)for(let[n,r]of Object.entries(t.props)){if(!r.expression)continue;let i=this.extractDependencies(r.expression);for(let a of i)this.validatePath(t,a)||e.push({nodeId:t.id,nodePath:t.path(),propName:n,expression:r.expression,brokenPath:a})}return e}opexist(e,t){return+!!e.node(t)}opinput(e,t){if(!this.graph)return null;let n=e.inputs[t];if(!n||n.connections.length===0)return null;let r=n.connections[0];return this.graph.getNode(r.from.nodeId)}fit(e,t,n,r,i){return n===t?r:r+(e-t)/(n-t)*(i-r)}fit01(e,t,n){return t+e*(n-t)}clamp(e,t,n){return Math.max(t,Math.min(n,e))}lerp(e,t,n){return e+(t-e)*n}smooth(e,t,n){if(e<=t)return 0;if(e>=n)return 1;let r=(e-t)/(n-t);return r*r*(3-2*r)}noise(...e){if(e.length===0)return 0;let t=0,n=[1,2.3,4.7,8.1],r=[1,.5,.25,.125];for(let i=0;i<n.length;i++){let a=0;for(let t=0;t<e.length;t++)a+=Math.sin(e[t]*n[i]*(t+1)*1.7+t*3.14159);t+=a*r[i]}return Math.sin(t*.5)}random(e){let t=Math.sin(e*12.9898)*43758.5453;return t-Math.floor(t)}padzero(e,t){return String(Math.floor(t)).padStart(e,`0`)}extractDependencies(e){let t=[],n=/\b(?:ch|chs|chv)\s*\(\s*['"]([^'"]+)['"]\s*\)/g,r;for(;(r=n.exec(e))!==null;)t.push(r[1]);return t}hasTimeReference(e){return/\b(time|frame|fps)\b/.test(e)}clearCache(){this.compiledCache.clear()}},Kc=new Gc;function qc(e){if(typeof e==`number`)return Number.isInteger(e)?`int`:`float`;if(typeof e==`boolean`)return`bool`;if(typeof e==`string`)return`string`;if(Array.isArray(e)&&e.every(e=>typeof e==`number`)){if(e.length===2)return`vec2`;if(e.length===3)return`vec3`;if(e.length===4)return`vec4`}return`any`}var Jc=class e{constructor(t,n,r){this.inputs=[],this.outputs=[],this.props={},this.propWatchers=new Map,this.actions={},this.parameters=[],this.parametersUsedDuringSetup=new Set,this.variadic=!1,this.variadicDefault=null,this.variadicOptions={},this.preview=null,this.comment=``,this.error=null,this.warning=null,this.code=``,this.bypass=!1,this.cook=!1,this.parent=null,this._children=[],this.hasExecuted=!1,this.lastInputHash=``,this.cookState=`stale`,this.cookGeneration=0,this.stagedOutputs=null,this.executionTimeout=3e4,this.cookInfo={lastCookTime:0,totalCookTime:0,cookCount:0,averageCookTime:0,lastCookTimestamp:0,peakMemory:0},this.isTimeDependent=!1,this.portsUsedDuringSetup=new Set,this._portMap=new Map,this.id=t,this.type=n,this.graph=r,this.position={x:0,y:0},this.constructor!==e&&(this.setup(),queueMicrotask(()=>{if(this.onReady)try{this.onReady()}catch(e){console.error(`Error in onReady for node ${this.id}:`,e)}}))}in(e,t,n={}){let r=e===`trigger`?`trigger`:`param`,i=this.inputs.find(t=>t.name===e);if(i)return this.portsUsedDuringSetup.add(`input_${e}`),n.type&&(i.dataType=n.type),t!==void 0&&i.defaultValue!==t&&(i.defaultValue=t,(i.value===void 0||i.value===i.defaultValue)&&(i.value=t)),i.options=Object.assign(i.options??{},n),i;let a=this.inputs.length,o={id:`${this.id}_in_${a}`,name:e,portType:r,dataType:n.type||`any`,value:t,defaultValue:t,options:n,connections:[]};return this.inputs.push(o),this._portMap.set(o.id,o),this.portsUsedDuringSetup.add(`input_${e}`),o}out(e,t=`param`,n={}){let r=this.outputs.find(t=>t.name===e);if(r)return this.portsUsedDuringSetup.add(`output_${e}`),r.portType!==t&&(r.portType=t),n.type&&(r.dataType=n.type),r.options={...r.options??{},...n},r;let i=this.outputs.length,a={id:`${this.id}_out_${i}`,name:e,portType:t,dataType:n.type||`any`,value:void 0,connections:[],options:n,setValue:e=>this.setOutputValue(a,e),trigger:e=>{a.connections.forEach(t=>{let n=this.graph.getNode(t.to.nodeId);if(n){let r=n.getInputPortById(t.to.portId);r&&r.onTrigger&&r.onTrigger(e)}})}};return this.outputs.push(a),this._portMap.set(a.id,a),this.portsUsedDuringSetup.add(`output_${e}`),a}getInputPort(e){return e>=0&&e<this.inputs.length?this.inputs[e]:null}getOutputPort(e){return e>=0&&e<this.outputs.length?this.outputs[e]:null}renameId(e){let t=this.id,n=new Map;this.id=e,this._portMap.clear();for(let r of[...this.inputs,...this.outputs]){let i=r.id;r.id=i.startsWith(`${t}_`)?`${e}${i.slice(t.length)}`:i,n.set(i,r.id),this._portMap.set(r.id,r)}return n}getPort(e){return this._portMap.get(e)||null}getInputPortById(e){let t=this._portMap.get(e);return t&&`defaultValue`in t?t:null}setOutputValue(e,t){if(this.stagedOutputs){this.stagedOutputs.set(e,t);return}this.commitOutputValue(e,t)}commitOutputValue(e,t){e.value=t;for(let n of e.connections){let e=this.graph.getNode(n.to.nodeId)?.getInputPortById(n.to.portId);e&&(e.value=t,e.onChange?.(t))}}addParm(e,t){this.props[e]=t,this.cookState!==`cooking`&&this.markDirty()}defineProp(e,t){this.addParm(e,t)}addAction(e,t){this.actions[e]=t}async executeAction(e){let t=this.actions[e];t&&(t.condition&&!t.condition()||await t.callback())}updateProp(t,n){if(!this.props[t])return;let r=Array.isArray(n)?[...n]:n;if(this.props[t]={...this.props[t],value:r},this.props[t].onChange)try{this.props[t].onChange(this.props[t],this)}catch(e){console.error(`Error in prop onChange for ${t}:`,e)}let i=this.propWatchers.get(t);i&&i.forEach(e=>{try{e(r,this.props[t])}catch(e){console.error(`Error in prop watcher for ${t}:`,e)}}),this.props={...this.props},this.markDirty(),e.onPropParamsChanged?.(this.id)}updatePropParams(t,n){this.props[t]&&(this.props[t]={...this.props[t],params:{...this.props[t].params,...n}},this.props={...this.props},e.onPropParamsChanged?.(this.id))}watchProp(e,t){this.propWatchers.has(e)||this.propWatchers.set(e,[]),this.propWatchers.get(e).push(t)}parm(e){let t=this.props[e];if(!t)return null;let n=this;return{name:()=>e,path:()=>`${n.path()}/${e}`,node:()=>n,eval:()=>t.value,evalAsFloat:()=>parseFloat(t.value)||0,evalAsInt:()=>parseInt(t.value,10)||0,evalAsString:()=>String(t.value??``),rawValue:()=>t.value,set:t=>n.updateProp(e,t),parmType:()=>t.type||`any`,expression:()=>t.expression??null,setExpression:t=>{n.props[e]={...n.props[e],expression:t},n.updateTimeDependent(),n.markDirty()},deleteExpression:()=>{let{expression:t,expressionError:r,...i}=n.props[e];n.props[e]=i,n.updateTimeDependent(),n.markDirty()},hasExpression:()=>!!t.expression,expressionError:()=>t.expressionError??null}}evalParm(e){let t=this.props[e];if(t)return t.expression?this.evaluateExpression(e):t.value}setParm(e,t){this.updateProp(e,t)}evaluateExpression(e){let t=this.props[e];if(!t?.expression)return t?.value;Kc.setGraph(this.graph);let n=Kc.evaluate(t.expression,this);if(n.error)return this.props[e]={...this.props[e],expressionError:n.error},t.value;if(t.expressionError){let{expressionError:t,...n}=this.props[e];this.props[e]=n}return n.value}evaluateAllExpressions(){for(let[e,t]of Object.entries(this.props))if(t.expression){let t=this.evaluateExpression(e);t!==void 0&&(this.props[e]={...this.props[e],value:t})}this.updateTimeDependent()}param(e,t,n={}){let r=this.parameters.find(t=>t.name===e);if(r?(n.type&&(r.dataType=n.type),r.defaultValue=t,Object.assign(r.options,n)):(r={name:e,value:t,defaultValue:t,dataType:n.type||qc(t),promoted:!1,options:n},this.parameters.push(r)),this.parametersUsedDuringSetup.add(e),r.promoted){let t=this.in(e,r.value,{...r.options,type:r.dataType,promoted:!0});if(t.fromParameter=e,t.connections.length>0&&t.value!==void 0&&t.value!==null)return{...r,value:t.value}}return r}setParameterPromoted(e,t){let n=this.parameters.find(t=>t.name===e);if(!(!n||n.promoted===t)){if(n.promoted=t,t){let t=this.in(e,n.value,{...n.options,type:n.dataType,promoted:!0});t.fromParameter=e}else{let t=this.inputs.findIndex(t=>t.name===e);t>=0&&([...this.inputs[t].connections].forEach(e=>this.graph?.disconnect(e.id)),this.inputs.splice(t,1))}this.markDirty()}}setParameter(e,t){let n=this.parameters.find(t=>t.name===e);n&&(n.value=t,this.markDirty())}setVariadic(e=null,t={}){this.variadic=!0,this.variadicDefault=e,this.variadicOptions=t,this.syncVariadicPorts()}getVariadicInputs(){return this.inputs.filter(e=>e.variadic&&!e.options.hidden)}syncVariadicPorts(){if(!this.variadic)return;let e=this.inputs.filter(e=>e.variadic),t=e.filter(e=>e.connections.length>0||e.value!==null&&e.value!==this.variadicDefault).length;for(let e=0;e<t+1;e++){let t=this.in(`input_${e}`,this.variadicDefault,{...this.variadicOptions,hidden:!1});t.variadic=!0,t.onChange||=()=>this.onUpdate?.()}for(let n=t+1;n<e.length;n++)e[n]&&(e[n].options.hidden=!0)}path(){let e=[this.id],t=this.parent;for(;t;)e.unshift(t.id),t=t.parent;return`/`+e.join(`/`)}children(){return this._children}isNetwork(){return!1}node(e){if(!e)return null;if(e.startsWith(`/`))return this.graph.nodeByPath(e);let t=e.split(`/`).filter(e=>e.length>0),n=this;for(let e of t){if(!n)return null;if(e!==`.`){if(e===`..`){n=n.parent;continue}if(n.isNetwork()){let t=n.children().find(t=>t.id===e);if(t){n=t;continue}}return null}}return n}relativePathTo(e){let t=this.path().split(`/`).filter(e=>e),n=e.path().split(`/`).filter(e=>e),r=0;for(;r<t.length&&r<n.length&&t[r]===n[r];)r++;let i=t.length-r,a=n.slice(r),o=[];for(let e=0;e<i;e++)o.push(`..`);return o.push(...a),o.join(`/`)||`.`}inputNodes(){let e=[];for(let t of this.inputs)for(let n of t.connections){let t=this.graph.getNode(n.from.nodeId);t&&!e.includes(t)&&e.push(t)}return e}outputNodes(){let e=[];for(let t of this.outputs)for(let n of t.connections){let t=this.graph.getNode(n.to.nodeId);t&&!e.includes(t)&&e.push(t)}return e}globToRegex(e){let t=``,n=0;for(;n<e.length;){let r=e[n];switch(r){case`*`:t+=`.*`;break;case`?`:t+=`.`;break;case`[`:let i=n+1,a=``;for(e[i]===`!`&&(a=`^`,i++);i<e.length&&e[i]!==`]`;)a+=e[i],i++;t+=`[`+a+`]`,n=i;break;case`.`:case`+`:case`^`:case`$`:case`(`:case`)`:case`{`:case`}`:case`|`:case`\\`:t+=`\\`+r;break;default:t+=r}n++}return RegExp(`^`+t+`$`)}glob(e){let t=this.children();if(!e||e===`*`)return[...t];let n=e.split(/\s+/),r=[],i=[];for(let e of n)e.startsWith(`^`)?i.push(this.globToRegex(e.slice(1))):r.push(this.globToRegex(e));return t.filter(e=>{let t=r.length===0||r.some(t=>t.test(e.id)),n=i.some(t=>t.test(e.id));return t&&!n})}recursiveGlob(e){let t=[],n=e.startsWith(`**/`),r=n?e.slice(3):e,i=(e,a)=>{let o=e.children();for(let e of o)n?this.globToRegex(r).test(e.id)&&t.push(e):a===0&&this.globToRegex(r).test(e.id)&&t.push(e),e.isNetwork()&&i(e,n?a:a-1)};if(e===`**`){let e=n=>{for(let r of n.children())t.push(r),r.isNetwork()&&e(r)};return e(this),t}let a=n?0:e.split(`/`).length-1;return i(this,a),t}setBypass(e){this.bypass=e,this.markDirty()}setCook(e){e&&this.parent&&this.parent.children().filter(e=>e!==this&&e.cook).forEach(e=>e.setCook(!1)),this.cook=e,e?this.graph.cookingNodes.add(this):this.graph.cookingNodes.delete(this),this.markDirty()}setTimeDependent(e){this.isTimeDependent=e}updateTimeDependent(){let e=Object.values(this.props).some(e=>e.expression&&Kc.hasTimeReference(e.expression));this.setTimeDependent(e)}shouldExecute(){return this.bypass?!1:this.graph.cookingNodes.size>0?this.cook||this.graph.isDownstreamOfCooking(this):!0}executeBypass(){this.inputs.forEach(e=>{if(e.portType===`param`){let t=this.outputs.find(t=>t.name===e.name||this.outputs.length===1);t&&t.setValue(e.value)}})}markDirty(){this.graph.scheduler.markStale(this)}invalidateCook(){this.cookGeneration++,this.setCookState(`stale`)}setCookState(e){this.cookState!==e&&(this.cookState=e,this.graph.scheduler.notifyNodeStateChange())}getValueFingerprint(e){if(e==null)return`null`;if(typeof e!=`object`)return String(e);if(ArrayBuffer.isView(e)){let t=e,n=t.length;return n===0?`empty`:`f32[${n}]:${t[0]?.toFixed(4)},${t[Math.floor(n/2)]?.toFixed(4)},${t[n-1]?.toFixed(4)}`}if(e.width!==void 0&&e.height!==void 0){let t=e.channelCount||e.channels?.length||0;return`img:${e.width}x${e.height}x${t}`}if(typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement)return`el:${e.width}x${e.height}`;try{let t=JSON.stringify(e);return t.length<500?t:`obj:${t.length}:${t.slice(0,100)}`}catch{return`obj:${typeof e}`}}calculateInputHash(){return this.inputs.map(e=>this.getValueFingerprint(e.value)).join(`|`)}get isDirty(){return!this.hasExecuted||this.cookState!==`clean`||this.calculateInputHash()!==this.lastInputHash}markDownstreamDirty(){this.graph.scheduler.markDownstreamStale(this)}async requestOutput(){this.isDirty&&(this.cookState===`clean`&&this.markDirty(),await this.graph.scheduler.flush())}setup(){}setFunction(e){this.nodeFunction=e,this.hasExecuted=!1,this.markDirty()}async execute(){if(!(this.nodeFunction||this.onCook!==e.prototype.onCook)){this.hasExecuted=!0,this.setCookState(`clean`);return}let t=!this.hasExecuted;if(!this.shouldExecute()&&!t&&!this.isDirty){this.executeBypass(),this.setCookState(`clean`);return}if(!t&&!this.isDirty)return;this.evaluateAllExpressions();let n=performance.now(),r=performance.memory?.usedJSHeapSize??0,i=this.cookGeneration;this.stagedOutputs=new Map,this.setCookState(`cooking`);let a;try{if(await Promise.race([Promise.resolve(this.onCook()),new Promise((e,t)=>{a=setTimeout(()=>t(Error(`Node execution timeout after ${this.executionTimeout}ms`)),this.executionTimeout)})]),i===this.cookGeneration){await this.callLifecycleHooks(t);for(let[e,t]of this.stagedOutputs)this.commitOutputValue(e,t);this.error=null,this.hasExecuted=!0,this.lastInputHash=this.calculateInputHash(),this.setCookState(`clean`)}else this.setCookState(`stale`);this.updateCookInfo(n,r)}catch(e){i===this.cookGeneration?(this.error=e,this.setCookState(`error`)):this.setCookState(`stale`),this.updateCookInfo(n,r),e.message?.includes(`timeout`)||console.error(`Error executing node ${this.id}:`,e)}finally{a!==void 0&&clearTimeout(a),this.stagedOutputs=null}}onCook(){if(this.nodeFunction)return this.nodeFunction(this,this.graph)}updateCookInfo(e,t=0){let n=performance.now()-e;this.cookInfo.lastCookTime=n,this.cookInfo.totalCookTime+=n,this.cookInfo.cookCount++,this.cookInfo.averageCookTime=this.cookInfo.totalCookTime/this.cookInfo.cookCount,this.cookInfo.lastCookTimestamp=Date.now();let r=performance.memory?.usedJSHeapSize??0;if(t&&r){let e=r-t;e>this.cookInfo.peakMemory&&(this.cookInfo.peakMemory=e)}}startCook(){return performance.now()}endCook(e){this.updateCookInfo(e,0)}resetCookInfo(){this.cookInfo={lastCookTime:0,totalCookTime:0,cookCount:0,averageCookTime:0,lastCookTimestamp:0,peakMemory:0}}async callLifecycleHooks(e){let t=e=>{let t=e?.message||String(e);return t.includes(`document is not defined`)||t.includes(`window is not defined`)||t.includes(`HTMLCanvasElement`)||t.includes(`HTMLImageElement`)};if(e&&this.onSetup)try{await this.onSetup()}catch(e){t(e)||console.error(`Error in onSetup for ${this.id}:`,e)}if(this.onUpdate)try{await this.onUpdate()}catch(e){t(e)||console.error(`Error in onUpdate for ${this.id}:`,e)}if(this.onRender)try{await this.onRender()}catch(e){t(e)||console.error(`Error in onRender for ${this.id}:`,e)}if(e&&this.onReady)try{this.onReady()}catch(e){t(e)||console.error(`Error in onReady for ${this.id}:`,e)}}rename(e){if(!e?.trim())return this.id;let t=e.trim().replace(/\s+/g,``);if(!t)return this.id;let n=this.graph.generateUniqueNodeId(t,this.id);return this.graph.renameElement(this.id,n)&&this.markDirty(),this.id}isPreviewValue(e){return typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement}async require(e,t){if(!this.graph.packageManager)throw Error(`PackageManager not initialized`);return this.graph.packageManager.load(e,t)}get assets(){return this.graph.assetManager}log(...e){console.log(`[${this.id}]`,...e)}resetPortTracking(){this.portsUsedDuringSetup.clear()}preserveState(){return{inputs:this.inputs.map(e=>({id:e.id,name:e.name,value:e.value,connections:e.connections.map(e=>e.id)})),outputs:this.outputs.map(e=>({id:e.id,name:e.name,value:e.value,connections:e.connections.map(e=>e.id)})),props:Object.fromEntries(Object.entries(this.props).map(([e,t])=>[e,t.value])),bypass:this.bypass,cook:this.cook}}restoreState(e){e.inputs?.forEach(e=>{let t=this.inputs.find(t=>t.id===e.id||t.name===e.name);t&&(t.value=e.value)}),e.outputs?.forEach(e=>{let t=this.outputs.find(t=>t.id===e.id||t.name===e.name);t&&(t.value=e.value)}),e.props&&Object.entries(e.props).forEach(([e,t])=>{this.props[e]&&(this.props[e].value=t)}),e.bypass!==void 0&&this.setBypass(e.bypass),e.cook!==void 0&&this.setCook(e.cook)}cleanupUnusedPorts(){let e=this.portsUsedDuringSetup;this.inputs=this.inputs.filter(t=>e.has(`input_${t.name}`)?!0:(t.connections.forEach(e=>this.graph.disconnect(e.id)),this._portMap.delete(t.id),!1)),this.outputs=this.outputs.filter(t=>e.has(`output_${t.name}`)?!0:(t.connections.forEach(e=>this.graph.disconnect(e.id)),this._portMap.delete(t.id),!1)),this.portsUsedDuringSetup.clear()}toJSON(){let e=Ae(this.type),t={id:this.id,type:e,position:[this.position.x,this.position.y]};!ke(e)&&this.code&&(t.code=this.code),this.comment?.trim()&&(t.comment=this.comment);let n=Object.fromEntries(Object.entries(this.props).map(([e,t])=>{let n=t.value;if(t.type===`color`&&Wc(n)){let e=Vc(n);n=[e.r,e.g,e.b,e.a??1]}return t.expression?[e,{value:n,expression:t.expression}]:[e,n]}));return Object.keys(n).length>0&&(t.props=n),this.bypass&&(t.bypass=!0),this.cook&&(t.cook=!0),t}},Yc=class extends Jc{constructor(e,t,n){super(e,t,n),this.isAnnotation=!0}getOutput(){return this.getOutputPort(0)}async execute(){}},Xc=class extends Yc{constructor(e,t){super(e,`Image`,t)}},Zc=class extends Yc{constructor(e,t){super(e,`Text`,t)}},Qc=class extends Yc{constructor(e,t){super(e,`Group`,t)}},$c=class extends Yc{constructor(e,t){super(e,`Line`,t)}},el=class extends Yc{constructor(e,t){super(e,`Polyline`,t)}},tl=class{async loadImage(e){return new Promise((t,n)=>{if(typeof Image>`u`){n(Error(`Image API not available (not in browser environment)`));return}let r=new Image;r.onload=()=>t(r),r.onerror=()=>n(Error(`Failed to load image: ${e}`)),r.src=e})}async loadJSON(e){if(typeof fetch>`u`)throw Error(`fetch API not available (not in browser environment)`);let t=await fetch(e);if(!t.ok)throw Error(`Failed to load JSON: ${e} - ${t.statusText}`);return t.json()}async loadText(e){if(typeof fetch>`u`)throw Error(`fetch API not available (not in browser environment)`);let t=await fetch(e);if(!t.ok)throw Error(`Failed to load text: ${e} - ${t.statusText}`);return t.text()}async loadBinary(e){if(typeof fetch>`u`)throw Error(`fetch API not available (not in browser environment)`);let t=await fetch(e);if(!t.ok)throw Error(`Failed to load binary: ${e} - ${t.statusText}`);return t.arrayBuffer()}},nl=class{constructor(e=``,t){this.cache=new Map,this.projectRoot=e,this.loader=t??new tl}async load(e){if(this.cache.has(e))return this.cache.get(e);let t=this.resolve(e),n=this.getAssetType(e),r;switch(n){case`image`:r=await this.loader.loadImage(t);break;case`json`:r=await this.loader.loadJSON(t);break;case`text`:r=await this.loader.loadText(t);break;default:throw Error(`Unsupported asset type: ${n}`)}let i={id:this.generateId(e),path:e,type:n,data:r,size:0,metadata:{}};return this.cache.set(e,i),i}resolve(e){return e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`/`)?e:`${this.projectRoot}${e}`}getAssetType(e){let t=e.split(`.`).pop()?.toLowerCase();return[`jpg`,`jpeg`,`png`,`gif`,`webp`,`svg`].includes(t||``)?`image`:[`mp3`,`wav`,`ogg`,`m4a`].includes(t||``)?`audio`:[`mp4`,`webm`,`mov`].includes(t||``)?`video`:t===`json`?`json`:[`txt`,`md`,`csv`].includes(t||``)?`text`:`binary`}generateId(e){return e.replace(/[^a-zA-Z0-9]/g,`_`)}getAsset(e){return this.cache.get(e)}clearCache(){this.cache.clear()}removeAsset(e){this.cache.delete(e)}async reloadAsset(e){return this.cache.delete(e),this.load(e)}async reloadAll(){let e=Array.from(this.cache.keys());this.cache.clear(),await Promise.all(e.map(e=>this.load(e).catch(t=>{console.warn(`Failed to reload asset ${e}:`,t)})))}list(){return Array.from(this.cache.values())}},rl=`modulepreload`,il=function(e){return`/`+e},al={},ol=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=il(t,n),t=s(t),t in al)return;al[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:rl,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},sl=class{constructor(){this.cache=new Map,this.loadingPromises=new Map,this.cdnBaseUrl=`https://esm.sh`}async load(e,t=`latest`){let n=`${e}@${t}`;if(this.cache.has(n))return this.cache.get(n);if(this.loadingPromises.has(n))return this.loadingPromises.get(n);let r=this.loadPackage(n,e,t);this.loadingPromises.set(n,r);try{let e=await r;return this.cache.set(n,e),e}catch(e){throw this.loadingPromises.delete(n),e}}async loadPackage(e,t,n){let r=n===`latest`?``:`@${n}`,i=`${this.cdnBaseUrl}/${t}${r}`;try{let e=await ol(()=>import(i),[]);return e.default&&typeof e.default==`object`||e.default!==void 0?e.default:e}catch(t){throw Error(`Failed to load package ${e}: ${t.message||`Unknown error`}\nURL: ${i}`)}}async search(e,t=20){try{let n=`https://registry.npmjs.org/-/v1/search?text=${encodeURIComponent(e)}&size=${t}`,r=await fetch(n,{method:`GET`,headers:{Accept:`application/json`}});if(!r.ok){if(r.status===0||r.status===403||r.status===404)return console.warn(`NPM registry search may be blocked by CORS. Using fallback.`),[];throw Error(`Search failed: ${r.statusText}`)}return(await r.json()).objects?.map(e=>({name:e.package.name,version:e.package.version,description:e.package.description,keywords:e.package.keywords||[],author:e.package.author,homepage:e.package.links?.homepage,repository:e.package.links?.repository?{url:e.package.links.repository}:void 0}))||[]}catch(e){if(e.message?.includes(`CORS`)||e.message?.includes(`Failed to fetch`))return console.warn(`NPM registry search unavailable:`,e.message),[];throw Error(`Failed to search packages: ${e.message||`Unknown error`}`)}}async getPackageInfo(e){try{let t=`https://registry.npmjs.org/${encodeURIComponent(e)}`,n=await fetch(t);if(!n.ok){if(n.status===404)return null;throw Error(`Failed to fetch package info: ${n.statusText}`)}let r=await n.json(),i=r[`dist-tags`]?.latest||Object.keys(r.versions).pop(),a=r.versions[i];return{name:r.name,version:i,description:a.description,keywords:a.keywords||[],author:a.author,homepage:r.homepage||a.homepage,repository:a.repository}}catch(e){throw Error(`Failed to get package info: ${e.message||`Unknown error`}`)}}clearCache(){this.cache.clear(),this.loadingPromises.clear()}removeFromCache(e,t){if(t){let n=`${e}@${t}`;this.cache.delete(n),this.loadingPromises.delete(n)}else for(let t of this.cache.keys())t.startsWith(`${e}@`)&&(this.cache.delete(t),this.loadingPromises.delete(t))}getCachedPackages(){return Array.from(this.cache.keys())}},cl=class{constructor(e){this.config=e}setFileSystemFunctions(e,t){this.fileReadFn=e,this.fileExistsFn=t}async resolve(e){if(e.startsWith(`cascade.`))return this.resolveStdlib(e);if(e.startsWith(`local.`))return this.resolveEmbedded(e);for(let t of this.config.projectPackages)if(e.startsWith(`${t.alias}.`))return this.resolveProject(e,t);return this.config.embeddedModules.has(e)?this.resolveEmbedded(e):null}resolveStdlib(e){return Me(e)?{source:{type:`stdlib`,module:e},code:``,displayPath:`<cascade>/${e.split(`.`).slice(1).join(`/`)}.ts`,editable:!1}:null}resolveEmbedded(e){let t=this.config.embeddedModules.get(e);return t?{source:{type:`embedded`,module:e,code:t.code,history:t.history||[]},code:t.code,displayPath:`<embedded>`,editable:!0}:null}async resolveProject(e,t){let n=e.replace(`${t.alias}.`,``).split(`.`),r=`${t.path}/${n.join(`/`)}.ts`,i=this.config.externalModules.get(e),a=null,o=`synced`;if(this.fileReadFn&&this.fileExistsFn){let e=this.resolvePath(r);await this.fileExistsFn(e)?(a=await this.fileReadFn(e),a!==null&&i&&i.cachedCode!==a&&(o=`modified-external`)):(o=`missing`,a=i?.cachedCode||null)}else i&&(a=i.cachedCode);return a===null?null:{source:{type:`project`,module:e,file:r,cachedCode:a,lastSync:new Date().toISOString(),status:o},code:a,displayPath:r,editable:!0}}resolvePath(e){return this.config.basePath?e.startsWith(`./`)?`${this.config.basePath}/${e.slice(2)}`:e.startsWith(`/`)?e:`${this.config.basePath}/${e}`:e}getSourceType(e){if(e.startsWith(`cascade.`))return`stdlib`;if(e.startsWith(`local.`))return`embedded`;for(let t of this.config.projectPackages)if(e.startsWith(`${t.alias}.`))return`project`;return this.config.embeddedModules.has(e)?`embedded`:null}createEmbeddedModule(e,t,n=`user`){let r=new Date().toISOString(),i={code:t,history:[{code:t,timestamp:r,author:n}],created:r,modified:r};return this.config.embeddedModules.set(e,i),{modulePath:e,module:i}}duplicateToEmbedded(e,t){let n=this.resolveStdlib(e);if(!n)return null;let r=e.split(`.`).pop()||`Custom`,i=t||r,a=`local.${i}`,o=1;for(;this.config.embeddedModules.has(a);)a=`local.${i}${o}`,o++;let s=new Date().toISOString(),c={code:n.code,timestamp:s,author:`user`},l={code:n.code,history:[c],created:s,modified:s};return this.config.embeddedModules.set(a,l),{modulePath:a,module:l}}async extractToProject(e,t,n){let r=this.config.embeddedModules.get(e);if(!r)return null;let i=`${t.path}/${n}.ts`,a=`${t.alias}.${n.replace(/\//g,`.`)}`,o={file:i,cachedCode:r.code,lastSync:new Date().toISOString()};return this.config.externalModules.set(a,o),{modulePath:a,filePath:i}}updateEmbeddedCode(e,t,n=`user`,r){let i=this.config.embeddedModules.get(e);if(!i)return!1;let a=new Date().toISOString(),o={code:t,timestamp:a,author:n,prompt:r};return i.history.push(o),i.code=t,i.modified=a,!0}restoreVersion(e,t){let n=this.config.embeddedModules.get(e);if(!n||t<0||t>=n.history.length)return!1;let r=n.history[t];return n.code=r.code,n.modified=new Date().toISOString(),n.history.push({code:r.code,timestamp:n.modified,author:`user`}),!0}getProjectPackages(){return[...this.config.projectPackages]}addProjectPackage(e){let t=this.config.projectPackages.find(t=>t.alias===e.alias);t?t.path=e.path:this.config.projectPackages.push(e)}removeProjectPackage(e){let t=this.config.projectPackages.findIndex(t=>t.alias===e);return t>=0&&(this.config.projectPackages.splice(t,1),!0)}async syncExternalModule(e){let t=this.config.externalModules.get(e);if(!t||!this.fileReadFn||!this.fileExistsFn)return`missing`;let n=this.resolvePath(t.file);if(!await this.fileExistsFn(n))return`missing`;let r=await this.fileReadFn(n);return r===null?`missing`:(t.cachedCode=r,t.lastSync=new Date().toISOString(),`synced`)}exportConfig(){return{projectPackages:[...this.config.projectPackages],embeddedModules:Object.fromEntries(this.config.embeddedModules),externalModules:Object.fromEntries(this.config.externalModules)}}importConfig(e){e.projectPackages&&(this.config.projectPackages=[...e.projectPackages]),e.embeddedModules&&(this.config.embeddedModules=new Map(Object.entries(e.embeddedModules))),e.externalModules&&(this.config.externalModules=new Map(Object.entries(e.externalModules)))}};function ll(e){return new cl({projectPackages:[],embeddedModules:new Map,externalModules:new Map,basePath:e})}var ul=class{static detectCycles(e){let t=[],n=new Set,r=new Set,i=[],a=o=>{if(r.has(o)){let e=i.indexOf(o);return e!==-1&&t.push([...i.slice(e),o]),!0}if(n.has(o))return!1;n.add(o),r.add(o),i.push(o);let s=e.getNode(o);if(s)for(let e of s.outputs)for(let t of e.connections)a(t.to.nodeId);return r.delete(o),i.pop(),!1},o=e.nodes;for(let e of o)n.has(e.id)||a(e.id);return t}static wouldCreateCycle(e,t,n){if(t===n)return!0;let r=new Set,i=(t,n)=>{if(t===n)return!0;if(r.has(t))return!1;r.add(t);let a=e.getNode(t);if(!a)return!1;for(let e of a.outputs)for(let t of e.connections)if(i(t.to.nodeId,n))return!0;return!1};return i(n,t)}static topologicalSort(e){let t=this.detectCycles(e);if(t.length>0)throw Error(`Graph contains cycles: ${t.map(e=>e.join(` -> `)).join(`, `)}`);let n=[],r=new Set,i=new Set,a=t=>{if(i.has(t))throw Error(`Cycle detected involving node ${t}`);if(r.has(t))return;i.add(t);let o=e.getNode(t);if(o)for(let e of o.inputs)for(let t of e.connections)a(t.from.nodeId);i.delete(t),r.add(t),n.push(t)},o=e.nodes;for(let e of o)r.has(e.id)||a(e.id);return n}static validateConnection(e,t,n,r,i){let a=e.getNode(t),o=e.getNode(n);if(!a||!o)return{type:`invalid_connection`,message:`Invalid connection: node not found`,nodeIds:[t,n]};let s=a.outputs.find(e=>e.id===r),c=o.inputs.find(e=>e.id===i);return!s||!c?{type:`invalid_connection`,message:`Invalid connection: port not found`,nodeIds:[t,n]}:s.portType===c.portType?this.wouldCreateCycle(e,t,n)?{type:`cycle`,message:`Connection would create a cycle: ${t} -> ${n}`,nodeIds:[t,n]}:null:{type:`invalid_connection`,message:`Port type mismatch: cannot connect ${s.portType} to ${c.portType}`,nodeIds:[t,n]}}static validateGraph(e){let t=[],n=[],r=this.detectCycles(e);r.length>0&&r.forEach(e=>{t.push({type:`cycle`,message:`Cycle detected: ${e.join(` -> `)}`,nodeIds:e})});for(let n of e.connections){let r=e.getNode(n.from.nodeId),i=e.getNode(n.to.nodeId);if(!r||!i){t.push({type:`invalid_connection`,message:`Connection references non-existent node`,connectionId:n.id,nodeIds:[n.from.nodeId,n.to.nodeId]});continue}let a=r.outputs.find(e=>e.id===n.from.portId),o=i.inputs.find(e=>e.id===n.to.portId);if(!a||!o){t.push({type:`invalid_connection`,message:`Connection references non-existent port`,connectionId:n.id,nodeIds:[n.from.nodeId,n.to.nodeId]});continue}a.portType!==o.portType&&t.push({type:`invalid_connection`,message:`Port type mismatch in connection`,connectionId:n.id,nodeIds:[n.from.nodeId,n.to.nodeId]})}let i=new Set;for(let t of e.connections)i.add(t.from.nodeId),i.add(t.to.nodeId);let a=e.nodes,o=a.filter(e=>{let t=!i.has(e.id),n=e.inputs.every(e=>e.connections.length===0);return t&&!n});return o.length>0&&n.push({type:`orphaned_node`,message:`Found ${o.length} orphaned node(s) with no connections`,nodeIds:o.map(e=>e.id)}),a.filter(e=>e.inputs.every(e=>e.connections.length===0)).length===0&&a.length>0&&n.push({type:`invalid_entry_point`,message:`No entry points found (all nodes have input connections)`}),{valid:t.length===0,errors:t,warnings:n}}},dl=new Map;async function fl(e){let t=typeof document<`u`?URL.createObjectURL(new Blob([e],{type:`text/javascript`})):`data:text/javascript;base64,${Buffer.from(e,`utf-8`).toString(`base64`)}`;try{let e=await ol(()=>import(t),[]);if(typeof e.execute!=`function`)throw Error(`node module has no execute(node, graph) export`);return{execute:e.execute}}finally{t.startsWith(`blob:`)&&URL.revokeObjectURL(t)}}function pl(e){let t=e.replace(/^project\./,``),n=`project:${t}`,r=dl.get(n);return r||(r=fetch(`/api/nodes/${encodeURIComponent(t)}/compiled`).then(async e=>{if(!e.ok)throw Error(await e.text());return fl(await e.text())}),dl.set(n,r)),r}function ml(e){let t=`embedded:${gl(e)}`,n=dl.get(t);return n||(n=fetch(`/api/nodes/compile-embedded`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({code:e})}).then(async e=>{if(!e.ok)throw Error(await e.text());return fl(await e.text())}),dl.set(t,n)),n}function hl(e){dl.delete(`project:${e}`)}function gl(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return t.toString(36)}var _l=`float.int.bool.string.vec2.vec3.vec4.vec2i.vec3i.vec4i.mat2.mat3.mat4.image.texture.geometry.points.lines.polyline.mesh.rects.color.asset.array.object.any`.split(`.`),vl={number:`float`,boolean:`bool`,curves:`polyline`},yl={int:[`float`,`string`],float:[`string`],bool:[`int`,`float`,`string`],vec2i:[`vec2`],vec3i:[`vec3`],vec4i:[`vec4`],vec4:[`color`],color:[`vec4`]};function bl(e){return e?vl[e]??e:`any`}function xl(e,t){let n=bl(e),r=bl(t);return n===r||n===`any`||r===`any`||(yl[n]?.includes(r)??!1)}var Sl=_l,Cl=new Set(Sl);function wl(e){return Cl.has(e)}function Tl(e){let t=e.indexOf(`.`);return t>0?e.slice(0,t):null}var El={vec2:2,vec3:3,vec4:4,vec2i:2,vec3i:3,vec4i:4,mat2:4,mat3:9,mat4:16,color:4};function Dl(e){return e===`int`||e.endsWith(`i`)}var Ol=bl;function kl(e,t){return xl(e,t)}var Al={float:`#4A9EFF`,int:`#4A9EFF`,bool:`#F472B6`,string:`#A78BFA`,vec2:`#38BDF8`,vec3:`#38BDF8`,vec4:`#38BDF8`,vec2i:`#38BDF8`,vec3i:`#38BDF8`,vec4i:`#38BDF8`,mat2:`#818CF8`,mat3:`#818CF8`,mat4:`#818CF8`,image:`#FFD700`,texture:`#FB7185`,asset:`#FFD700`,points:`#4ADE80`,lines:`#4ADE80`,polyline:`#4ADE80`,mesh:`#22C55E`,rects:`#4ADE80`,curves:`#4ADE80`,color:`#EC4899`,array:`#F87171`,object:`#FB923C`,any:`#9CA3AF`};function jl(e){if(!e)return Al.any;if(Al[e])return Al[e];let t=Tl(e);if(!t)return Al.any;let n=0;for(let e=0;e<t.length;e++)n=n*31+t.charCodeAt(e)>>>0;return`hsl(${n%360}, 65%, 62%)`}function Ml(e){return!!(e&&typeof e==`object`&&typeof e.path==`string`&&Array.isArray(e.size))}function Nl(e){if(Ml(e))return e;if(typeof e!=`string`||!e)return null;let t=e.endsWith(`.npy`);return{path:e,size:[0,0],channels:t?`a`:`rgb`,depth:t?`f32`:`u8`,space:t?`linear`:`srgb`}}var Pl=class{constructor(e,t=50){this.graph=e,this.debounceMs=t,this.timer=null,this.activeRun=null,this.rerunRequested=!1,this.listeners=new Set,this.idleResolvers=new Set,this._status={phase:`idle`,total:0,completed:0,currentNode:null,startedAt:null,elapsed:0}}get status(){return this._status}get isRunning(){return this.activeRun!==null}subscribe(e){return this.listeners.add(e),e(this._status),()=>this.listeners.delete(e)}notifyNodeStateChange(){this.emit()}markStale(e){let t=new Set,n=e=>{if(!t.has(e.id)){t.add(e.id),e.cookState!==`stale`&&e.invalidateCook();for(let t of e.outputs)for(let e of t.connections){let t=this.graph.getNode(e.to.nodeId);t&&n(t)}}};n(e),this.graph.getNode(e.id)===e&&this.schedule()}markDownstreamStale(e){for(let t of e.outputs)for(let e of t.connections){let t=this.graph.getNode(e.to.nodeId);t&&this.markStale(t)}}schedule(){if(this.activeRun){this.rerunRequested=!0;return}this.timer&&clearTimeout(this.timer);let e=this.graph.nodes.filter(e=>e.cookState===`stale`||e.cookState===`queued`).length;this.setStatus({phase:`scheduled`,total:e,completed:0,currentNode:null,startedAt:null,elapsed:0}),this.timer=setTimeout(()=>{this.timer=null,this.flushScheduled()},this.debounceMs)}async flush(e){await this.flushInternal(e,!0)}async flushScheduled(){await this.flushInternal(void 0,!1)}async flushInternal(e,t){if(this.timer&&=(clearTimeout(this.timer),null),t&&this.prepareErrorRetry(e),this.activeRun){this.rerunRequested=!0,await this.activeRun;return}this.activeRun=this.run(e).finally(()=>{this.activeRun=null}),await this.activeRun}prepareErrorRetry(e){let t=e?this.collectDownstream(e):null;for(let e of this.graph.nodes)e.cookState===`error`&&(!t||t.has(e.id))&&e.invalidateCook()}async whenIdle(){!this.activeRun&&!this.timer||await new Promise(e=>this.idleResolvers.add(e))}dispose(){this.timer&&clearTimeout(this.timer),this.timer=null,this.listeners.clear();for(let e of this.idleResolvers)e();this.idleResolvers.clear()}async run(e){let t=e?this.collectDownstream(e):null;do{this.rerunRequested=!1;let e=this.graph.nodes.filter(e=>(e.cookState===`stale`||e.cookState===`queued`)&&(!t||t.has(e.id)));if(t=null,e.length===0)break;let n=new Set(e.map(e=>e.id)),r=this.graph.getTopologicalOrder().map(e=>this.graph.getNode(e)).filter(e=>!!e&&n.has(e.id)),i=new Set(r.map(e=>e.id));for(let t of e)i.has(t.id)||r.push(t);for(let e of r)e.setCookState(`queued`);let a=performance.now();this.setStatus({phase:`cooking`,total:r.length,completed:0,currentNode:null,startedAt:a,elapsed:0});let o=new Set,s=!1;for(let e of r){if(e.inputs.some(e=>e.connections.some(e=>n.has(e.from.nodeId)&&(o.has(e.from.nodeId)||this.graph.getNode(e.from.nodeId)?.cookState===`error`)))){e.setCookState(`stale`),o.add(e.id),this.setStatus({...this._status,completed:this._status.completed+1,currentNode:null,elapsed:performance.now()-a});continue}e.setCookState(`cooking`),this.setStatus({...this._status,currentNode:e,elapsed:performance.now()-a}),await e.execute(),e.cookState===`error`&&o.add(e.id),e.cookState===`stale`&&(o.add(e.id),s=!0),this.setStatus({...this._status,completed:this._status.completed+1,currentNode:null,elapsed:performance.now()-a})}s&&(this.rerunRequested=!0)}while(this.rerunRequested);this.setStatus({phase:`idle`,total:0,completed:0,currentNode:null,startedAt:null,elapsed:0});for(let e of this.idleResolvers)e();this.idleResolvers.clear()}collectDownstream(e){let t=new Set,n=e=>{if(!t.has(e.id)){t.add(e.id);for(let t of e.outputs)for(let e of t.connections){let t=this.graph.getNode(e.to.nodeId);t&&n(t)}}};return n(e),t}setStatus(e){this._status=Object.freeze(e),this.emit()}emit(){for(let e of this.listeners)e(this._status)}};function Fl(e){let t=e.split(`_`);if(t.length<3)throw Error(`Invalid port ID format: ${e}`);let n=t[t.length-2],r=parseInt(t[t.length-1],10);if(isNaN(r))throw Error(`Invalid port index in port ID: ${e}`);return{elementId:t.slice(0,-2).join(`_`),portType:n,index:r}}function Il(e,t,n){return`${e}_${t}_${n}`}var Ll=class e{get created(){return this.createdAt}get elements(){return this._elements}set elements(e){this._elements=e,this._elementMap.clear();for(let t of e)this._elementMap.set(t.id,t)}constructor(e,t,n){this._elements=[],this._elementMap=new Map,this.connections=[],this._connectionMap=new Map,this.connectionIdCounter=0,this.project={packages:[]},this.createdAt=new Date().toISOString(),this.cookingNodes=new Set,this.executionState=`idle`,this.cachedTopologicalOrder=null,this.assetManager=e||new nl,this.packageManager=t||new sl,this.moduleResolver=n||ll(),this.scheduler=new Pl(this)}isAnnotation(e){return e.isAnnotation===!0}get nodes(){return this._elements.filter(e=>!this.isAnnotation(e))}set nodes(e){this._elements=[...this._elements.filter(e=>this.isAnnotation(e)),...e]}get annotations(){return this._elements.filter(e=>this.isAnnotation(e))}set annotations(e){this._elements=[...this._elements.filter(e=>!this.isAnnotation(e)),...e]}generateUniqueNodeId(e,t){let n=e.replace(/\s+/g,``),r=n.match(/^(.+?)(\d+)?$/),i=r?r[1]:n,a=1,o=`${i}${a}`;for(;this._elements.some(e=>e.id===o&&(!t||e.id!==t));)a++,o=`${i}${a}`;return o}getElement(e){return this._elementMap.get(e)||null}getNode(e){let t=this.getElement(e);return t&&!this.isAnnotation(t)?t:null}getAnnotation(e){let t=this.getElement(e);return t&&this.isAnnotation(t)?t:null}nodeByPath(e){if(!e.startsWith(`/`))return null;let t=e.slice(1).split(`/`).filter(e=>e.length>0);if(t.length===0)return null;let n=this.nodes.find(e=>!e.parent&&e.id===t[0])??null;for(let e=1;n&&e<t.length;e++){if(!n.isNetwork())return null;n=n.children().find(n=>n.id===t[e])??null}return n}addElement(e){this._elements.push(e),this._elementMap.set(e.id,e),this.invalidateTopologicalOrder()}reparentElement(e,t){if(t){if(!t.isNetwork()||t===e)return!1;for(let n=t;n;n=n.parent)if(n===e)return!1}if(e.parent===t)return!0;let n=e.parent;if(n){let t=n.removeChild;typeof t==`function`?t.call(n,e):(n._children=n.children().filter(t=>t!==e),e.parent=null)}if(t){let n=t.addChild;typeof n==`function`?n.call(t,e):(e.parent=t,t._children.push(e))}return this.invalidateTopologicalOrder(),!0}removeElement(e){let t=this._elementMap.get(e);if(!t)return;let n=[],r=new Set,i=e=>{r.has(e)||(r.add(e),e.children().forEach(i),n.push(e))};i(t);let a=new Set(n.map(e=>e.id));this.connections.filter(e=>a.has(e.from.nodeId)||a.has(e.to.nodeId)).forEach(e=>this.disconnect(e.id));let o=this._connectionsToRestore;Array.isArray(o)&&(this._connectionsToRestore=o.filter(e=>{let t=Array.isArray(e?.[0])?e[0][0]:void 0,n=Array.isArray(e?.[1])?e[1][0]:void 0;return!a.has(t)&&!a.has(n)})),this._elements=this._elements.filter(e=>!a.has(e.id));for(let e of n)this._elementMap.delete(e.id),this.cookingNodes.delete(e);for(let e of n){let t=e.parent;if(t){let n=t.removeChild;typeof n==`function`?n.call(t,e):e.parent=null}}this.invalidateTopologicalOrder();for(let e of n)e.onDestroy?.()}renameElement(e,t){let n=this._elementMap.get(e);if(!n||!t||e!==t&&this._elementMap.has(t))return!1;if(e===t)return!0;let r=n.renameId(t);this._elementMap.delete(e),this._elementMap.set(t,n);for(let n of this.connections)n.from.nodeId===e&&(n.from.nodeId=t),n.to.nodeId===e&&(n.to.nodeId=t),n.from.portId=r.get(n.from.portId)??n.from.portId,n.to.portId=r.get(n.to.portId)??n.to.portId;let i=this._connectionsToRestore;if(Array.isArray(i))for(let n of i)for(let r of Array.isArray(n)?n:[])Array.isArray(r)&&r[0]===e&&(r[0]=t);for(let n of this.annotations)Array.isArray(n.containedElements)&&(n.containedElements=n.containedElements.map(n=>n===e?t:n));return this.invalidateTopologicalOrder(),!0}addNode(e,t){let n=je(e).toLowerCase().replace(/\s+/g,`_`),r=this.generateUniqueNodeId(n),i=Me(e),a;if(a=i?new i(r,this):new Jc(r,Oe(e),this),a.modulePath=e,ke(e))a.sourceType=`stdlib`;else if(e.startsWith(`local.`))a.sourceType=`embedded`;else{let t=this.moduleResolver.getSourceType(e);a.sourceType=t||`embedded`}return a.position=t,this.addElement(a),a}retargetModule(e,t,n,r){let i=this.getNode(e);if(!i)return!1;i.modulePath=t,i.sourceType=n,n===`embedded`&&r!==void 0&&(i.code=r);let a=n===`project`?pl(t):ml(r??i.code);return i.setFunction((e,t)=>a.then(n=>n.execute(e,t))),a.catch(e=>console.warn(`Failed to compile `+t+`:`,e)),i.markDirty(),!0}removeNode(e){this.removeElement(e)}validateConnection(e,t){let n,r;try{let i=Fl(e.id),a=Fl(t.id);n=i.elementId,r=a.elementId}catch(e){return{valid:!1,error:`Invalid port ID format: ${e}`}}let i=this.getElement(n),a=this.getElement(r);if(!i||!a)return{valid:!1,error:`Element not found`};if(!this.isAnnotation(i)&&!this.isAnnotation(a)){let i=ul.validateConnection(this,n,r,e.id,t.id);if(i)return{valid:!1,error:i.message}}return{valid:!0}}checkDataTypeCompatibility(e,t){let n=Ol(e.dataType),r=Ol(t.dataType);return kl(n,r)||{number:[`number[]`,`string`],float:[`number[]`],int:[`number[]`],string:[`number`,`float`,`int`]}[n]?.includes(r)?null:`Type mismatch: connecting ${n} to ${r}`}updateTypeMismatchWarnings(e){let t=this.getNode(e);if(!t)return;let n=[];for(let e of t.inputs)for(let t of e.connections){let r=this.getNode(t.from.nodeId);if(!r)continue;let i=r.outputs.find(e=>e.id===t.from.portId);if(!i)continue;let a=this.checkDataTypeCompatibility(i,e);a&&n.push(a)}n.length>0?t.warning=n.join(`; `):t.warning?.startsWith(`Type mismatch`)&&(t.warning=null)}connect(e,t){let n=this.validateConnection(e,t);if(!n.valid)throw Error(`Invalid connection: ${n.error}`);if(!t.variadic&&t.connections&&t.connections.length>0){let e=[...t.connections];for(let t of e)this.disconnect(t.id)}let r=Fl(e.id),i=Fl(t.id),a={id:`conn_${Date.now()}_${++this.connectionIdCounter}`,from:{nodeId:r.elementId,portId:e.id},to:{nodeId:i.elementId,portId:t.id},type:e.portType},o=this.connections.find(e=>e.from.nodeId===a.from.nodeId&&e.from.portId===a.from.portId&&e.to.nodeId===a.to.nodeId&&e.to.portId===a.to.portId);if(o)return o;if(this.connections.push(a),this._connectionMap.set(a.id,a),e.connections.push(a),t.connections.push(a),this.invalidateTopologicalOrder(),e.value!==void 0&&e.value!==null&&(t.value=e.value,t.onChange))try{t.onChange(e.value)}catch(e){console.error(`Error in onChange callback for port ${t.name}:`,e)}return this.syncVariadicPortsOnNode(i.elementId),this.updateTypeMismatchWarnings(i.elementId),this.getNode(i.elementId)?.markDirty(),a}disconnect(e){let t=this._connectionMap.get(e);if(!t)return;let n=this.getElement(t.from.nodeId),r=this.getElement(t.to.nodeId);if(n){let r=n.getPort(t.from.portId);r&&(r.connections=r.connections.filter(t=>t.id!==e))}if(r){let n=r.getPort(t.to.portId);if(n&&(n.connections=n.connections.filter(t=>t.id!==e),n.connections.length===0)){n.value=n.defaultValue;try{n.onChange?.(n.defaultValue)}catch(e){console.error(`Error in onChange callback for port ${n.name}:`,e)}}}let i=this.connections.findIndex(t=>t.id===e);i>=0&&this.connections.splice(i,1),this._connectionMap.delete(e),this.invalidateTopologicalOrder(),this.syncVariadicPortsOnNode(t.to.nodeId),this.updateTypeMismatchWarnings(t.to.nodeId),this.getNode(t.to.nodeId)?.markDirty()}syncVariadicPortsOnNode(e){let t=this.getNode(e);t&&t.syncVariadicPorts()}validate(){return ul.validateGraph(this)}async execute(e){this.executionState=`running`;try{await this.scheduler.flush(e)}finally{this.executionState=`idle`}}getTopologicalOrder(){return this.cachedTopologicalOrder||=ul.topologicalSort(this),this.cachedTopologicalOrder}invalidateTopologicalOrder(){this.cachedTopologicalOrder=null}stop(){this.executionState=`stopped`}reset(){this.nodes.forEach(e=>{e.error=null,e.warning=null,e.markDirty()}),this.cookingNodes.clear(),this.executionState=`idle`}clearCookingNodes(e){e?this.cookingNodes.forEach(t=>{t!==e&&t.setCook(!1)}):this.cookingNodes.forEach(e=>{e.setCook(!1)})}isDownstreamOfCooking(e){let t=new Set,n=e=>{if(t.has(e.id))return!1;if(t.add(e.id),this.cookingNodes.has(e))return!0;for(let t of e.inputs)for(let e of t.connections){let t=this.getNode(e.from.nodeId);if(t&&n(t))return!0}return!1};return n(e)}addAnnotation(e){let t;if(this.isAnnotation(e))t=e;else{let n=e;switch(n.type.charAt(0).toUpperCase()+n.type.slice(1).toLowerCase()){case`Image`:t=new Xc(n.id,this),t.src=n.src;break;case`Text`:t=new Zc(n.id,this),t.content=n.content;break;case`Group`:t=new Qc(n.id,this),t.content=n.content;break;case`Line`:t=new $c(n.id,this),n.endPosition&&(t.endPosition=n.endPosition);break;case`Polyline`:t=new el(n.id,this),n.points&&(t.points=n.points);break;default:t=new Yc(n.id,n.type,this),n.content!==void 0&&(t.content=n.content),n.src!==void 0&&(t.src=n.src),n.endPosition&&(t.endPosition=n.endPosition),n.points&&(t.points=n.points)}t.position=n.position||{x:0,y:0},n.size&&(t.size=n.size),n.style&&(t.style={...n.style}),n.caption!==void 0&&(t.caption=n.caption),n.containedElements&&(t.containedElements=n.containedElements)}this.addElement(t),this.initializeAnnotationPorts(t).catch(e=>{console.error(`Failed to initialize ports for annotation ${t.id}:`,e)})}removeAnnotation(e){this.removeElement(e)}async initializeAnnotationPorts(e){if(e.outputs=[],e.type===`Image`){let t=e,n={id:Il(e.id,`output`,0),name:`image`,portType:`param`,dataType:`asset`,value:null,connections:[],setValue:e=>{n.value=e,n.connections.forEach(t=>{let n=Fl(t.to.portId),r=this.getElement(n.elementId);if(r&&!this.isAnnotation(r)){let t=r.getInputPort(n.index);t&&(t.value=e,t.onChange?.(e))}})},trigger:e=>{n.connections.forEach(t=>{let n=Fl(t.to.portId),r=this.getElement(n.elementId);r&&!this.isAnnotation(r)&&r.getInputPort(n.index)?.onTrigger?.(e)})}};e.outputs.push(n);let r=t.src;if(r)try{let e=new Image;e.crossOrigin=`anonymous`,await new Promise((t,i)=>{e.onload=()=>{n.setValue(e),t()},e.onerror=i,e.src=r.startsWith(`/`)||r.startsWith(`http`)||r.startsWith(`data:`)?r:`/${r}`})}catch(t){console.error(`Failed to load image for annotation ${e.id}:`,t)}}else if(e.type===`Text`){let t=e;if(t.content!==void 0){let n={id:Il(e.id,`output`,0),name:`text`,portType:`param`,dataType:`string`,value:t.content,connections:[],setValue:e=>{n.value=e,n.connections.forEach(t=>{let n=Fl(t.to.portId),r=this.getElement(n.elementId);if(r&&!this.isAnnotation(r)){let t=r.getInputPort(n.index);t&&(t.value=e,t.onChange?.(e))}})},trigger:e=>{n.connections.forEach(t=>{let n=Fl(t.to.portId),r=this.getElement(n.elementId);r&&!this.isAnnotation(r)&&r.getInputPort(n.index)?.onTrigger?.(e)})}};e.outputs.push(n)}}}validateExpressionPaths(){let e=[],t=/\b(?:ch|chs|chv)\s*\(\s*['"]([^'"]+)['"]\s*\)/g;for(let n of this.nodes)for(let[r,i]of Object.entries(n.props)){if(!i.expression)continue;let a=`${n.path()}/${r}`,o=i.expression.matchAll(t);for(let t of o){let r=t[1],o=this.resolvePathFromNode(n,r);o.node?o.parmName&&!o.node.props[o.parmName]&&e.push({location:a,expression:i.expression,brokenPath:r,suggestion:`Parameter "${o.parmName}" not found on node "${o.node.id}"`}):e.push({location:a,expression:i.expression,brokenPath:r,suggestion:this.suggestPathFix(n,r)})}}return{valid:e.length===0,warnings:e}}resolvePathFromNode(e,t){let n=t.lastIndexOf(`/`);if(n>0){let r=t.substring(n+1),i=t.substring(0,n),a=e.node(t);if(a)return{node:a};let o=e.node(i);if(o)return{node:o,parmName:r}}return{node:e.node(t)}}suggestPathFix(e,t){let n=t.replace(/^\.?\.?\//,``).split(`/`),r=n[n.length-1],i=this.nodes.filter(e=>e.id.toLowerCase().includes(r.toLowerCase())||r.toLowerCase().includes(e.id.toLowerCase()));if(i.length>0)return`Did you mean "${i[0].path()}"?`}toJSON(){let e={version:`0.2`,metadata:{name:this.project.name||`Cascade Graph`,created:this.createdAt,modified:new Date().toISOString(),...this.project.description?{description:this.project.description}:{},...this.project.author?{author:this.project.author}:{}}};this.project.packages.length>0&&(e.project={packages:this.project.packages.map(e=>({path:e.path,alias:e.alias}))});let t=this.moduleResolver.exportConfig();Object.keys(t.embeddedModules).length>0&&(e.embeddedModules=t.embeddedModules),Object.keys(t.externalModules).length>0&&(e.externalModules=t.externalModules);let n=this.packageManager.getCachedPackages().map(e=>{let[t,n]=e.split(`@`);return{name:t,version:n||`latest`}});n.length>0&&(e.packages=n);let r=this.assetManager.list().map(e=>({id:e.id,path:e.path,type:e.type,size:e.size}));r.length>0&&(e.assets={manifest:r});let i=this.annotations,a=this.nodes;i.length>0&&(e.annotations=i.map(e=>{let t={id:e.id,type:e.type,position:[e.position.x,e.position.y]},n=e;return n.content!==void 0&&(t.content=n.content),n.src!==void 0&&(t.src=n.src),e.size&&(t.size=e.size),n.points&&(t.points=n.points.map(e=>[e.x,e.y])),n.endPosition&&(t.endPosition=[n.endPosition.x,n.endPosition.y]),e.style&&(t.style=e.style),e.caption!==void 0&&(t.caption=e.caption),e.containedElements&&(t.containedElements=e.containedElements),e.parent&&(t.parent=e.parent.id),t})),e.nodes=a.map(e=>this.nodeToJSON(e));let o=this.connections.map(e=>{try{let t=Fl(e.from.portId),n=Fl(e.to.portId),r=this.getElement(t.elementId),i=this.getElement(n.elementId);if(!r||!i)return null;let a=r.outputs?.[t.index],o=i.inputs?.[n.index];return!a||!o?null:[[t.elementId,t.index,a.name],[n.elementId,n.index,o.name]]}catch(e){return console.warn(`Failed to parse port ID in connection: ${e}`),null}}).filter(e=>e!==null);return o.length>0&&(e.connections=o),e}nodeToJSON(e){let t=e,n=t.modulePath||(e.type.includes(`.`)?e.type:`cascade.image.${e.type}`),r=t.sourceType;r||=ke(n)?`stdlib`:n.startsWith(`local.`)?`embedded`:this.moduleResolver.getSourceType(n)||`embedded`;let i={id:e.id,module:n,position:[e.position.x,e.position.y],source:r};if(r===`project`){let e=this.moduleResolver.exportConfig().externalModules[n];e&&(i.file=e.file)}i.source===`embedded`&&e.code&&(i.code=e.code),e.comment&&e.comment.trim()&&(i.comment=e.comment),e.color&&(i.color=e.color),e.parent&&(i.parent=e.parent.id);let a=(e.parameters??[]).filter(e=>e.promoted||JSON.stringify(e.value)!==JSON.stringify(e.defaultValue)),o=a.filter(e=>e.documentField!==`props`).map(e=>e.promoted?{name:e.name,value:e.value,promoted:!0}:{name:e.name,value:e.value});o.length>0&&(i.params=o);let s=e.inputs.filter(e=>(e.connections?.length??0)===0).filter(e=>e.value!==void 0&&e.value!==null).filter(e=>typeof e.value!=`function`).map(e=>({name:e.name,defaultValue:e.value,dataType:e.dataType})).filter(e=>e.defaultValue!==``||e.dataType===`string`);s.length>0&&(i.inputs=s);let c=Object.entries(e.props).reduce((e,[t,n])=>{let r=n.value;if(n.type===`color`&&Wc(r)){let e=Vc(r);r=[e.r,e.g,e.b,e.a??1]}return e[t]=n.expression?{value:r,expression:n.expression}:r,e},{});for(let e of a)e.documentField===`props`&&(c[e.name]=e.value);if(Object.keys(c).length>0&&(i.props=c),e.bypass&&(i.bypass=!0),e.cook&&(i.cook=!0),typeof e.serialize==`function`){let t=e.serialize();t&&Object.keys(t).length>0&&(i.state=t)}return i}static fromJSON(t,n,r){let i=new e(n,r);t.version,typeof t.metadata?.created==`string`&&(i.createdAt=t.metadata.created),i.project={...i.project,...typeof t.metadata?.name==`string`?{name:t.metadata.name}:{},...typeof t.metadata?.description==`string`?{description:t.metadata.description}:{},...typeof t.metadata?.author==`string`?{author:t.metadata.author}:{}},t.project&&(i.project={...i.project,name:t.metadata?.name??i.project.name,description:t.metadata?.description??i.project.description,author:t.metadata?.author??i.project.author,packages:t.project.packages||[]},t.project.packages?.forEach(e=>{i.moduleResolver.addProjectPackage(e)})),t.embeddedModules&&i.moduleResolver.importConfig({embeddedModules:t.embeddedModules}),t.externalModules&&i.moduleResolver.importConfig({externalModules:t.externalModules}),t.packages&&Array.isArray(t.packages),t.nodes.forEach(e=>{let n=e.id;if(n){let e=1,t=n;for(;i.elements.some(e=>e.id===t);)e++,t=`${n}${e}`;n=t}else{let t=e.name||e.type||e.module;n=i.generateUniqueNodeId(t)}let r=e.module||e.type;if(!r||!r.includes(`.`)){console.warn(`Invalid node type format: ${r}. Expected package path (e.g., "cascade.image.Color"). Skipping node.`);return}let a=Oe(r),o=e.source||(ke(r)?`stdlib`:`embedded`),s=``;o===`embedded`?s=t.embeddedModules?.[r]?.code||e.code||``:o===`project`&&(s=t.externalModules?.[r]?.cachedCode||e.code||``);let c=Me(r),l;if(c)l=new c(n,i);else if(r.startsWith(`cascade.`))throw Error(`Unknown Cascade node type: ${r}`);else l=new Jc(n,a,i);l.modulePath=r,l.sourceType=o,Array.isArray(e.position)?l.position={x:e.position[0]||0,y:e.position[1]||0}:e.position&&typeof e.position==`object`?l.position={x:e.position.x||0,y:e.position.y||0}:l.position={x:0,y:0},l.code=s,l.comment=e.comment||``,e.color&&(l.color=e.color),Array.isArray(e.params)&&e.params.forEach(e=>{if(!e?.name)return;let t=l.parameters.find(t=>t.name===e.name);if(t?(t.value=e.value,t.promoted=!!e.promoted):l.parameters.push({name:e.name,value:e.value,defaultValue:e.value,dataType:`any`,promoted:!!e.promoted,options:{}}),e.promoted){let t=l.in(e.name,e.value);t.fromParameter=e.name}}),i.addElement(l);let u=(e,t,n,r={})=>{if(!e)return;let i=l.inputs.find(t=>t.name===e),a=i??l.in(e,n?t:void 0,r.dataType?{type:r.dataType}:{});i&&n&&(i.value=t),r.id&&a.id!==r.id&&(a.id=r.id)};if(Array.isArray(e.inputs)?e.inputs.forEach(e=>{if(!e||typeof e!=`object`)return;let t=Object.prototype.hasOwnProperty.call(e,`defaultValue`),n=Object.prototype.hasOwnProperty.call(e,`value`);u(e.name,t?e.defaultValue:e.value,t||n,e)}):e.inputs&&typeof e.inputs==`object`&&Object.entries(e.inputs).forEach(([e,t])=>{u(e,t,!0)}),e.outputs&&Array.isArray(e.outputs)&&e.outputs.forEach(e=>{let t=l.out(e.name,e.portType||`param`);e.id&&t.id!==e.id&&(t.id=e.id)}),e.props&&Object.entries(e.props).forEach(([e,t])=>{let n,r;t&&typeof t==`object`&&`value`in t?(n=t.value,r=t.expression):n=t;let i=n;if(Wc(n)){let e=Vc(n);i=e.a!==void 0&&e.a!==1?{r:e.r,g:e.g,b:e.b,a:e.a}:{r:e.r,g:e.g,b:e.b}}let a=l.parameters.find(t=>t.name===e&&t.documentField===`props`);a?a.value=n:l.props[e]?l.props[e].value=i:l.props[e]={value:i},r&&!a&&(l.props[e].expression=r)}),e.bypass!==void 0&&l.setBypass(e.bypass),e.cook!==void 0&&l.setCook(e.cook),!c&&(o===`project`||l.code)){let e=o===`project`?pl(r):ml(l.code);l.setFunction((t,n)=>e.then(e=>e.execute(t,n))),e.catch(e=>{console.warn(`Failed to compile node `+l.id+`:`,e)})}if(e.state&&typeof l.deserialize==`function`)try{l.deserialize(e.state)}catch(e){console.warn(`Failed to deserialize state for node `+l.id+`:`,e)}});let a=t.connections||[];if(t.annotations&&Array.isArray(t.annotations)){let e=t.annotations.map(e=>{let t,n=Array.isArray(e.position)?{x:e.position[0]||0,y:e.position[1]||0}:{x:e.position?.x||0,y:e.position?.y||0};switch(e.type.charAt(0).toUpperCase()+e.type.slice(1).toLowerCase()){case`Image`:t=new Xc(e.id,i),t.src=e.src;break;case`Text`:t=new Zc(e.id,i),t.content=e.content;break;case`Group`:t=new Qc(e.id,i),t.content=e.content;break;case`Line`:t=new $c(e.id,i),e.endPosition&&(t.endPosition=Array.isArray(e.endPosition)?{x:e.endPosition[0]||0,y:e.endPosition[1]||0}:{x:e.endPosition.x||0,y:e.endPosition.y||0});break;case`Polyline`:t=new el(e.id,i),e.points&&(t.points=e.points.map(e=>Array.isArray(e)?{x:e[0]||0,y:e[1]||0}:{x:e.x||0,y:e.y||0}));break;default:t=new Yc(e.id,e.type,i)}return t.position=n,e.size&&(t.size={width:e.size.width,height:e.size.height}),e.style&&(t.style={...e.style}),e.caption!==void 0&&(t.caption=e.caption),e.containedElements&&(t.containedElements=e.containedElements),t});e.forEach(e=>i.addElement(e)),i._annotationPortsInitialized=Promise.all(e.map(e=>i.initializeAnnotationPorts(e))).catch(e=>{console.error(`Failed to initialize some annotation ports:`,e)})}else i._annotationPortsInitialized=Promise.resolve();let o=[...Array.isArray(t.nodes)?t.nodes:[],...Array.isArray(t.annotations)?t.annotations:[]];for(let e of o){if(typeof e?.parent!=`string`)continue;let t=i.getElement(e.id),n=i.getElement(e.parent),r=t=>console.warn(`Parent link for "${e.id}" to "${e.parent}" ignored: ${t}; element loaded at root.`);if(!t)continue;if(!n){r(`parent does not exist`);continue}if(t===n){r(`self-parenting is invalid`);continue}if(!n.isNetwork()){r(`parent is not a network`);continue}let a=n,o=!1,s=new Set;for(;a&&!s.has(a);){if(a===t){o=!0;break}s.add(a),a=a.parent}if(o){r(`parent cycle detected`);continue}i.reparentElement(t,n)}let s=e=>{let t=0,n=e.parent,r=new Set;for(;n&&!r.has(n);)r.add(n),t++,n=n.parent;return t};return i.nodes.filter(e=>e.isNetwork()).sort((e,t)=>s(t)-s(e)).forEach(e=>e.syncPorts?.()),i._connectionsToRestore=a,a.forEach(e=>{i.tryRestoreConnection(e,!1)}),i}async waitForAnnotationPorts(){let e=this._annotationPortsInitialized;e&&await e}tryRestoreConnection(e,t=!1){if(!Array.isArray(e)||!Array.isArray(e[0])||!Array.isArray(e[1]))return!1;let[n,r,i]=e[0],[a,o,s]=e[1];if(typeof r!=`number`||typeof o!=`number`)return!1;let c=this.getElement(n),l=this.getElement(a);if(!c||!l)return!1;let u=(e,t)=>typeof t==`string`?e?.find(e=>e.name===t):void 0,d=(e,t,n)=>typeof t==`string`?u(e,t):e?.[n],f=d(c.outputs,i,r),p=d(l.inputs,s,o);if(!f||!p)return!1;if(t&&this.connections.some(e=>e.from.nodeId===n&&e.from.portId===f.id&&e.to.nodeId===a&&e.to.portId===p.id))return!0;try{return this.connect(f,p),!0}catch(e){return console.warn(`[connect] ${n}[${r}] -> ${a}[${o}] rejected:`,e),!1}}restoreConnections(){let e=this._connectionsToRestore||[];if(e.length===0)return;let t=e.filter(e=>!this.tryRestoreConnection(e,!0));t.length>0?this._connectionsToRestore=t:delete this._connectionsToRestore}};function Rl(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function zl(e){if(Array.isArray(e))return e}function Bl(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Vl(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
7
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Hl(e,t){return zl(e)||Bl(e,t)||Ul(e,t)||Vl()}function Ul(e,t){if(e){if(typeof e==`string`)return Rl(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Rl(e,t):void 0}}var Wl=Object.entries,Gl=Object.setPrototypeOf,Kl=Object.isFrozen,ql=Object.getPrototypeOf,Jl=Object.getOwnPropertyDescriptor,Yl=Object.freeze,Xl=Object.seal,Zl=Object.create,Ql=typeof Reflect<`u`&&Reflect,$l=Ql.apply,eu=Ql.construct;Yl||=function(e){return e},Xl||=function(e){return e},$l||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},eu||=function(e){return new e(...[...arguments].slice(1))};var tu=xu(Array.prototype.forEach),nu=xu(Array.prototype.lastIndexOf),ru=xu(Array.prototype.pop),iu=xu(Array.prototype.push),au=xu(Array.prototype.splice),ou=Array.isArray,su=xu(String.prototype.toLowerCase),cu=xu(String.prototype.toString),lu=xu(String.prototype.match),uu=xu(String.prototype.replace),du=xu(String.prototype.indexOf),fu=xu(String.prototype.trim),pu=xu(Number.prototype.toString),mu=xu(Boolean.prototype.toString),hu=typeof BigInt>`u`?null:xu(BigInt.prototype.toString),gu=typeof Symbol>`u`?null:xu(Symbol.prototype.toString),_u=xu(Object.prototype.hasOwnProperty),vu=xu(Object.prototype.toString),yu=xu(RegExp.prototype.test),bu=Su(TypeError);function xu(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return $l(e,t,n)}}function Su(e){return function(){return eu(e,[...arguments])}}function Cu(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:su;if(Gl&&Gl(e,null),!ou(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(Kl(t)||(t[r]=e),i=e)}e[i]=!0}return e}function wu(e){for(let t=0;t<e.length;t++)_u(e,t)||(e[t]=null);return e}function Tu(e){let t=Zl(null);for(let r of Wl(e)){var n=Hl(r,2);let i=n[0],a=n[1];_u(e,i)&&(t[i]=ou(a)?wu(a):a&&typeof a==`object`&&a.constructor===Object?Tu(a):a)}return t}function Eu(e){switch(typeof e){case`string`:return e;case`number`:return pu(e);case`boolean`:return mu(e);case`bigint`:return hu?hu(e):`0`;case`symbol`:return gu?gu(e):`Symbol()`;case`undefined`:return vu(e);case`function`:case`object`:{if(e===null)return vu(e);let t=e,n=Du(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:vu(e)}return vu(e)}default:return vu(e)}}function Du(e,t){for(;e!==null;){let n=Jl(e,t);if(n){if(n.get)return xu(n.get);if(typeof n.value==`function`)return xu(n.value)}e=ql(e)}function n(){return null}return n}function Ou(e){try{return yu(e,``),!0}catch{return!1}}var ku=Yl(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),Au=Yl(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),ju=Yl([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),Mu=Yl([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),Nu=Yl(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),Pu=Yl([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Fu=Yl([`#text`]),Iu=Yl(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),Lu=Yl(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.pointer-events.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),Ru=Yl(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),zu=Yl([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Bu=Xl(/{{[\w\W]*|^[\w\W]*}}/g),Vu=Xl(/<%[\w\W]*|^[\w\W]*%>/g),Hu=Xl(/\${[\w\W]*/g),Uu=Xl(/^data-[\-\w.\u00B7-\uFFFF]+$/),Wu=Xl(/^aria-[\-\w]+$/),Gu=Xl(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ku=Xl(/^(?:\w+script|data):/i),qu=Xl(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ju=Xl(/^html$/i),Yu=Xl(/^[a-z][.\w]*(-[.\w]+)+$/i),Xu=Xl(/<[/\w!]/g),Zu=Xl(/<[/\w]/g),Qu=Xl(/<\/no(script|embed|frames)/i),$u=Xl(/\/>/i),ed={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},td=[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`],nd=Yl(Cu({},td)),rd=function(){let e={};return tu(td,t=>{e[t]=Xl(RegExp(`</`+t+`(?=[\\t\\n\\f\\r />])`,`i`))}),Yl(e)}(),id=function(){return typeof window>`u`?null:window},ad=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},od=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},sd=function(e,t,n,r){return _u(e,t)&&ou(e[t])?Cu(r.base?Tu(r.base):{},e[t],r.transform):n},cd=function(e,t,n){let r=_u(e,t)?e[t]:void 0;return r&&typeof r==`object`?Tu(r):n()};function ld(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:id(),t=e=>ld(e);if(t.version=`3.4.14`,t.removed=[],!e||!e.document||e.document.nodeType!==ed.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=Du(d,`cloneNode`),p=Du(d,`remove`),m=Du(d,`nextSibling`),h=Du(d,`childNodes`),g=Du(d,`parentNode`),_=Du(d,`shadowRoot`),v=Du(d,`attributes`),y=o&&o.prototype?Du(o.prototype,`nodeType`):null,b=o&&o.prototype?Du(o.prototype,`nodeName`):null,x=o&&o.prototype?Du(o.prototype,`ownerDocument`):null,S=function(e){return y?y(e):e.nodeType},C=function(e){return b?b(e):e.nodeName};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let w,T=``,E,D=!1,O=0,k=function(){if(O>0)throw bu(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},ee=function(e){k(),O++;try{return w.createHTML(e)}finally{O--}},te=function(e){k(),O++;try{return w.createScriptURL(e)}finally{O--}},A=function(){return D||=(E=ad(u,i),!0),E},j=n,M=j.implementation,N=j.createNodeIterator,P=j.createDocumentFragment,F=j.getElementsByTagName,I=r.importNode,ne=od();t.isSupported=typeof Wl==`function`&&typeof g==`function`&&M&&M.createHTMLDocument!==void 0;let re=Bu,ie=Vu,ae=Hu,L=Uu,oe=Wu,R=Ku,se=qu,z=Yu,B=Gu,ce=null,V=Cu({},[...ku,...Au,...ju,...Nu,...Fu]),le=null,H=Cu({},[...Iu,...Lu,...Ru,...zu]),ue=Object.seal(Zl(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),U=null,de=null,fe=Object.seal(Zl(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),W=!0,G=!0,pe=!1,me=!0,K=!1,he=!0,q=!1,ge=!1,_e=null,ve=null,J=!1,ye=!1,Y=!1,be=!1,xe=!0,Se=!1,Ce=`user-content-`,we=!0,Te=!1,Ee={},De=null,X=Cu({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),Oe=null,ke=Cu({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Ae=null,je=Cu({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Me=`http://www.w3.org/1998/Math/MathML`,Ne=`http://www.w3.org/2000/svg`,Pe=`http://www.w3.org/1999/xhtml`,Fe=Pe,Ie=!1,Le=null,Re=Cu({},[Me,Ne,Pe],cu),ze=Yl([`mi`,`mo`,`mn`,`ms`,`mtext`]),Be=Cu({},ze),Ve=Yl([`annotation-xml`]),He=Cu({},Ve),Ue=Cu({},[`title`,`style`,`font`,`a`,`script`]),We=null,Ge=[`application/xhtml+xml`,`text/html`],Ke=null,Z=null,Q=n.createElement(`form`),qe=function(e){return e instanceof RegExp||e instanceof Function},Je=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Z&&Z===e)return;(!e||typeof e!=`object`)&&(e={}),e=Tu(e),We=Ge.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,Ke=We===`application/xhtml+xml`?cu:su,ce=sd(e,`ALLOWED_TAGS`,V,{transform:Ke}),le=sd(e,`ALLOWED_ATTR`,H,{transform:Ke}),Le=sd(e,`ALLOWED_NAMESPACES`,Re,{transform:cu}),Ae=sd(e,`ADD_URI_SAFE_ATTR`,je,{transform:Ke,base:je}),Oe=sd(e,`ADD_DATA_URI_TAGS`,ke,{transform:Ke,base:ke}),De=sd(e,`FORBID_CONTENTS`,X,{transform:Ke}),U=sd(e,`FORBID_TAGS`,Tu({}),{transform:Ke}),de=sd(e,`FORBID_ATTR`,Tu({}),{transform:Ke}),Ee=_u(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?Tu(e.USE_PROFILES):e.USE_PROFILES:!1,W=e.ALLOW_ARIA_ATTR!==!1,G=e.ALLOW_DATA_ATTR!==!1,pe=e.ALLOW_UNKNOWN_PROTOCOLS||!1,me=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,K=e.SAFE_FOR_TEMPLATES||!1,he=e.SAFE_FOR_XML!==!1,q=e.WHOLE_DOCUMENT||!1,ye=e.RETURN_DOM||!1,Y=e.RETURN_DOM_FRAGMENT||!1,be=e.RETURN_TRUSTED_TYPE||!1,J=e.FORCE_BODY||!1,xe=e.SANITIZE_DOM!==!1,Se=e.SANITIZE_NAMED_PROPS||!1,we=e.KEEP_CONTENT!==!1,Te=e.IN_PLACE||!1,B=Ou(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Gu,Fe=typeof e.NAMESPACE==`string`?e.NAMESPACE:Pe,Be=cd(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>Cu({},ze)),He=cd(e,`HTML_INTEGRATION_POINTS`,()=>Cu({},Ve));let t=cd(e,`CUSTOM_ELEMENT_HANDLING`,()=>Zl(null));if(ue=Zl(null),_u(t,`tagNameCheck`)&&qe(t.tagNameCheck)&&(ue.tagNameCheck=t.tagNameCheck),_u(t,`attributeNameCheck`)&&qe(t.attributeNameCheck)&&(ue.attributeNameCheck=t.attributeNameCheck),_u(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(ue.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),Xl(ue),K&&(G=!1),Y&&(ye=!0),Ee&&(ce=Cu({},Fu),le=Zl(null),Ee.html===!0&&(Cu(ce,ku),Cu(le,Iu)),Ee.svg===!0&&(Cu(ce,Au),Cu(le,Lu),Cu(le,zu)),Ee.svgFilters===!0&&(Cu(ce,ju),Cu(le,Lu),Cu(le,zu)),Ee.mathMl===!0&&(Cu(ce,Nu),Cu(le,Ru),Cu(le,zu))),fe.tagCheck=null,fe.attributeCheck=null,_u(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?fe.tagCheck=e.ADD_TAGS:ou(e.ADD_TAGS)&&(ce===V&&(ce=Tu(ce)),Cu(ce,e.ADD_TAGS,Ke))),_u(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?fe.attributeCheck=e.ADD_ATTR:ou(e.ADD_ATTR)&&(le===H&&(le=Tu(le)),Cu(le,e.ADD_ATTR,Ke))),_u(e,`ADD_FORBID_CONTENTS`)&&ou(e.ADD_FORBID_CONTENTS)&&(De===X&&(De=Tu(De)),Cu(De,e.ADD_FORBID_CONTENTS,Ke)),we&&(ce[`#text`]=!0),q&&Cu(ce,[`html`,`head`,`body`]),ce.table&&(Cu(ce,[`tbody`]),delete U.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw bu(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw bu(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=w;w=e.TRUSTED_TYPES_POLICY;try{T=ee(``)}catch(e){throw w=t,e}}else e.TRUSTED_TYPES_POLICY===null?(w=void 0,T=``):(w===void 0&&(w=A()),w&&typeof T==`string`&&(T=ee(``)));Yl&&Yl(e),Z=e},Ye=Cu({},[...Au,...ju,...Mu]),Xe=Cu({},[...Nu,...Pu]),Ze=function(e,t,n){return t.namespaceURI===Pe?e===`svg`:t.namespaceURI===Me?e===`svg`&&(n===`annotation-xml`||Be[n]):!!Ye[e]},$=function(e,t,n){return t.namespaceURI===Pe?e===`math`:t.namespaceURI===Ne?e===`math`&&He[n]:!!Xe[e]},Qe=function(e,t,n){return t.namespaceURI===Ne&&!He[n]||t.namespaceURI===Me&&!Be[n]?!1:!Xe[e]&&(Ue[e]||!Ye[e])},$e=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:Fe,tagName:`template`});let n=su(e.tagName),r=su(t.tagName);return Le[e.namespaceURI]?e.namespaceURI===Ne?Ze(n,t,r):e.namespaceURI===Me?$(n,t,r):e.namespaceURI===Pe?Qe(n,t,r):!!(We===`application/xhtml+xml`&&Le[e.namespaceURI]):!1},et=function(e){iu(t.removed,{element:e});try{g(e).removeChild(e)}catch{if(p(e),!g(e))throw bu(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},tt=function(e,t,n){try{e.removeAttributeNode(t)}catch{try{e.removeAttribute(n)}catch{}}},nt=function(e){at(e);let t=h(e);if(t){let e=[];tu(t,t=>{iu(e,t)}),tu(e,e=>{try{p(e)}catch{}})}let n=v(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&tt(e,r,i)}},rt=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}iu(t.removed,{attribute:r||null,from:n});try{r?n.removeAttributeNode(r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`){if(ye||Y)try{et(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},it=function(e){let t=v(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||le[Ke(i)]||tt(e,r,i)}},at=function(e){let t=[e];for(;t.length>0;){let e=t.pop();S(e)===ed.element&&it(e);let n=h(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},ot=function(e,t){return he?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},st=function(e){if(!he)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=S(e);if(n===ed.processingInstruction||n===ed.comment&&yu(Zu,e.data)){try{p(e)}catch{}continue}if(n===ed.element){let t=e,n=Ke(C(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&ot(`for`,n)&&t.removeAttribute(`for`)}catch{}}let r=h(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},ct=function(e){let t=null,r=null;if(J)e=`<remove></remove>`+e;else{let t=lu(e,/^[\r\n\t ]+/);r=t&&t[0]}We===`application/xhtml+xml`&&Fe===Pe&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=w?ee(e):e;if(Fe===Pe)try{t=new l().parseFromString(i,We)}catch{}if(!t||!t.documentElement){t=M.createDocument(Fe,`template`,null);try{t.documentElement.innerHTML=Ie?T:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Fe===Pe?F.call(t,q?`html`:`body`)[0]:q?t.documentElement:a},lt=function(e){let t=x?x(e):e.ownerDocument;return N.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ut=function(e){return e=uu(e,re,` `),e=uu(e,ie,` `),e=uu(e,ae,` `),e},dt=function(e){e.normalize();let t=x?x(e):e.ownerDocument,n=N.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=ut(r.data),r=n.nextNode();let i=e.querySelectorAll?.call(e,`template`);i&&tu(i,e=>{pt(e.content)&&dt(e.content)})},ft=function(e){let t=b?b(e):null;return typeof t!=`string`||Ke(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==v(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==y(e)||e.childNodes!==h(e)},pt=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return y(e)===ed.documentFragment}catch{return!1}},mt=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return typeof y(e)==`number`}catch{return!1}};function ht(e,n,r){e.length!==0&&tu(e,e=>{e.call(t,n,r,Z)})}let gt=function(e,t){return!!(he&&e.hasChildNodes()&&!mt(e.firstElementChild)&&yu(Xu,e.textContent)&&yu(Xu,e.innerHTML)||he&&e.namespaceURI===Pe&&nd[t]&&(mt(e.firstElementChild)||typeof e.textContent==`string`&&yu(rd[t],e.textContent))||e.nodeType===ed.processingInstruction||he&&e.nodeType===ed.comment&&yu(Zu,e.data))},_t=function(e,t){return e instanceof RegExp?yu(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},vt=function(e,t,n){if(!U[t]&&wt(t)&&_t(ue.tagNameCheck,t))return!1;if(we&&!De[t]){let t=g(e),r=h(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,m(e))}}}return et(e),!0},yt=function(e,t,n,r){return e.length===0?t:t===n||t===r?Tu(t):t},bt=function(e,t){return e===t||g(e)!==null?!1:(Te&&at(e),!0)},xt=function(e,n){if(ht(ne.beforeSanitizeElements,e,null),bt(e,n))return!0;if(ft(e))return et(e),!0;let r=Ke(C(e));if(ce=yt(ne.uponSanitizeElement,ce,V,_e),ht(ne.uponSanitizeElement,e,{tagName:r,allowedTags:ce}),bt(e,n))return!0;if(gt(e,r))return et(e),!0;if(U[r]||!(fe.tagCheck instanceof Function&&fe.tagCheck(r))&&!ce[r]){let t=vt(e,r,n);return t===!1&&ht(ne.afterSanitizeElements,e,null),t}if(S(e)===ed.element&&!$e(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&yu(Qu,e.innerHTML))return et(e),!0;if(K&&e.nodeType===ed.text){let n=ut(e.textContent);e.textContent!==n&&(iu(t.removed,{element:e.cloneNode()}),e.textContent=n)}return ht(ne.afterSanitizeElements,e,null),!1},St=function(e,t,r){if(de[t]||ot(t,e)||xe&&(t===`id`||t===`name`)&&(r in n||r in Q))return!1;let i=le[t]||fe.attributeCheck instanceof Function&&fe.attributeCheck(t,e);return G&&yu(L,t)||W&&yu(oe,t)?!0:i?Ae[t]||yu(B,uu(r,se,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&du(r,`data:`)===0&&Oe[e]||pe&&!yu(R,uu(r,se,``))?!0:!r:wt(e)&&_t(ue.tagNameCheck,e)&&_t(ue.attributeNameCheck,t,e)||t===`is`&&ue.allowCustomizedBuiltInElements&&_t(ue.tagNameCheck,r)},Ct=Cu({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),wt=function(e){return!Ct[su(e)]&&yu(z,e)},Tt=function(e,t,n,r){if(w&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return ee(r);case`TrustedScriptURL`:return te(r)}return r},Et=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),ft(e)?et(e):ru(t.removed)}catch{rt(n,e)}},Dt=function(e){ht(ne.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||ft(e))return;le=yt(ne.uponSanitizeAttribute,le,H,ve);let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:le,forceKeepAttr:void 0},r=t.length,i=Ke(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=Ke(o),u=c,d=o===`value`?u:fu(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,ht(ne.uponSanitizeAttribute,e,n),d=n.attrValue,Se&&(l===`id`||l===`name`)&&du(d,Ce)!==0&&(rt(o,e,a),d=Ce+d),he&&yu(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){rt(o,e,a);continue}if(l===`attributename`&&lu(d,`href`)){rt(o,e,a);continue}if(!n.forceKeepAttr){if(!n.keepAttr){rt(o,e,a);continue}if(!me&&yu($u,d)){rt(o,e,a);continue}if(K&&(d=ut(d)),!St(i,l,d)){rt(o,e,a);continue}d=Tt(i,l,s,d),d!==u&&Et(e,o,s,d)}}ht(ne.afterSanitizeAttributes,e,null)},Ot=function(e){let t=null,n=lt(e);for(ht(ne.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(ht(ne.uponSanitizeShadowNode,t,null),xt(t,e),Dt(t),pt(t.content)&&Ot(t.content),S(t)===ed.element){let e=_(t);pt(e)&&(kt(e),Ot(e))}ht(ne.afterSanitizeShadowDOM,e,null)},kt=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Ot(e.shadow);continue}let n=e.node,r=S(n)===ed.element,i=h(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=b?b(n):null;if(typeof e==`string`&&Ke(e)===`template`){let e=n.content;pt(e)&&t.push({node:e,shadow:null})}}if(r){let e=_(n);pt(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(Ie=!e,Ie&&(e=`<!-->`),typeof e!=`string`&&!mt(e)&&(e=Eu(e),typeof e!=`string`))throw bu(`dirty is not a string, aborting`);if(!t.isSupported)return e;ge?(ce=_e,le=ve):Je(n),(ne.uponSanitizeElement.length>0||ne.uponSanitizeAttribute.length>0)&&(ce=Tu(ce)),ne.uponSanitizeAttribute.length>0&&(le=Tu(le)),t.removed=[];let c=Te&&typeof e!=`string`&&mt(e);if(c){st(e);let t=C(e);if(typeof t==`string`){let n=Ke(t);if(!ce[n]||U[n])throw nt(e),bu(`root node is forbidden and cannot be sanitized in-place`)}if(ft(e))throw nt(e),bu(`root node is clobbered and cannot be sanitized in-place`);try{kt(e)}catch(t){throw nt(e),t}}else if(mt(e))i=ct(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===ed.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),kt(a);else{if(!ye&&!K&&!q&&e.indexOf(`<`)===-1)return w&&be?ee(e):e;if(i=ct(e),!i)return ye?null:be?T:``}i&&J&&et(i.firstChild);let l=c?e:i;try{let e=lt(l);for(;o=e.nextNode();)xt(o,l),Dt(o),pt(o.content)&&Ot(o.content)}catch(n){throw c&&(nt(e),tu(t.removed,e=>{e.element&&at(e.element)})),n}if(c)return tu(t.removed,e=>{e.element&&at(e.element)}),K&&dt(e),e;if(ye){if(K&&dt(i),Y)for(s=P.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(le.shadowroot||le.shadowrootmode)&&(s=I.call(r,s,!0)),s}let u=q?i.outerHTML:i.innerHTML;return q&&ce[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&yu(Ju,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
8
|
+
`+u),K&&(u=ut(u)),w&&be?ee(u):u},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Je(e),ge=!0,_e=ce,ve=le},t.clearConfig=function(){Z=null,ge=!1,_e=null,ve=null,w=E,T=``},t.isValidAttribute=function(e,t,n){Z||Je({});let r=Ke(e),i=Ke(t);return St(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&_u(ne,e)&&iu(ne[e],t)},t.removeHook=function(e,t){if(_u(ne,e)){if(t!==void 0){let n=nu(ne[e],t);return n===-1?void 0:au(ne[e],n,1)[0]}return ru(ne[e])}},t.removeHooks=function(e){_u(ne,e)&&(ne[e]=[])},t.removeAllHooks=function(){ne=od()},t}var ud=ld();function dd(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var fd=dd();function pd(e){fd=e}var md={exec:()=>null};function hd(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function gd(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(vd.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var _d=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),vd={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:hd(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:hd(e=>RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:hd(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:hd(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:hd(e=>RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,`i`)),blockquoteBeginRegex:hd(e=>RegExp(`^ {0,${e}}>`))},yd=/^(?:[ \t]*(?:\n|$))+/,bd=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,xd=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Sd=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Cd=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,wd=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Td=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ed=gd(Td).replace(/bull/g,wd).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Dd=gd(Td).replace(/bull/g,wd).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Od=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,kd=/^[^\n]+/,Ad=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,jd=gd(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Ad).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Md=gd(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,wd).getRegex(),Nd=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,Pd=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Fd=gd(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Pd).replace(`tag`,Nd).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Id=e=>gd(Od).replace(`hr`,Sd).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,e).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Nd).getRegex(),Ld=Id(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Rd=Id(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),zd={blockquote:gd(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Rd).getRegex(),code:bd,def:jd,fences:xd,heading:Cd,hr:Sd,html:Fd,lheading:Ed,list:Md,newline:yd,paragraph:Ld,table:md,text:kd},Bd=gd(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Sd).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Nd).getRegex(),Vd={...zd,lheading:Dd,table:Bd,paragraph:gd(Od).replace(`hr`,Sd).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Bd).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Nd).getRegex()},Hd={...zd,html:gd(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Pd).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:md,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:gd(Od).replace(`hr`,Sd).replace(`heading`,` *#{1,6} *[^
|
|
9
|
+
]`).replace(`lheading`,Ed).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Ud=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Wd=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Gd=/^( {2,}|\\)\n(?!\s*$)/,Kd=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,qd=/[\p{P}\p{S}]/u,Jd=/[\s\p{P}\p{S}]/u,Yd=/[^\s\p{P}\p{S}]/u,Xd=gd(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Jd).getRegex(),Zd=/[\p{Pi}\p{Ps}"']/u,Qd=/(?!~)[\p{P}\p{S}]/u,$d=/(?!~)[\s\p{P}\p{S}]/u,ef=/(?:[^\s\p{P}\p{S}]|~)/u,tf=gd(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,_d?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),nf=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,rf=gd(nf,`u`).replace(/punct/g,qd).getRegex(),af=gd(nf,`u`).replace(/punct/g,Qd).getRegex(),of=gd(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,Zd).replace(/punct/g,qd).getRegex(),sf=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,cf=gd(sf,`gu`).replace(/notPunctSpace/g,Yd).replace(/punctSpace/g,Jd).replace(/punct/g,qd).getRegex(),lf=gd(sf,`gu`).replace(/notPunctSpace/g,ef).replace(/punctSpace/g,$d).replace(/punct/g,Qd).getRegex(),uf=gd(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Yd).replace(/punctSpace/g,Jd).replace(/punct/g,qd).getRegex(),df=gd(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Yd).replace(/punctSpace/g,Jd).replace(/punct/g,qd).getRegex(),ff=gd(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Yd).replace(/punctSpace/g,Jd).replace(/punct/g,qd).getRegex(),pf=gd(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,qd).getRegex(),mf=gd(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Yd).replace(/punctSpace/g,Jd).replace(/punct/g,qd).getRegex(),hf=gd(/\\(punct)/,`gu`).replace(/punct/g,qd).getRegex(),gf=gd(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),_f=gd(Pd).replace(`(?:-->|$)`,`-->`).getRegex(),vf=gd(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,_f).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),yf=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,bf=gd(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,yf).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),xf=gd(/^!?\[(label)\]\[(ref)\]/).replace(`label`,yf).replace(`ref`,Ad).getRegex(),Sf=gd(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Ad).getRegex(),Cf=gd(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,xf).replace(`nolink`,Sf).getRegex(),wf=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Tf={_backpedal:md,anyPunctuation:hf,autolink:gf,blockSkip:tf,br:Gd,code:Wd,del:md,delLDelim:md,delRDelim:md,emStrongLDelim:rf,emStrongRDelimAst:cf,emStrongRDelimUnd:df,escape:Ud,link:bf,nolink:Sf,punctuation:Xd,reflink:xf,reflinkSearch:Cf,tag:vf,text:Kd,url:md},Ef={...Tf,emStrongLDelim:of,emStrongRDelimAst:uf,emStrongRDelimUnd:ff,link:gd(/^!?\[(label)\]\((.*?)\)/).replace(`label`,yf).getRegex(),reflink:gd(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,yf).getRegex()},Df={...Tf,emStrongRDelimAst:lf,emStrongLDelim:af,delLDelim:pf,delRDelim:mf,url:gd(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,wf).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:gd(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,wf).getRegex()},Of={...Df,br:gd(Gd).replace(`{2,}`,`*`).getRegex(),text:gd(Df.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},kf={normal:zd,gfm:Vd,pedantic:Hd},Af={normal:Tf,gfm:Df,breaks:Of,pedantic:Ef},jf={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},Mf=e=>jf[e];function Nf(e,t){if(t){if(vd.escapeTest.test(e))return e.replace(vd.escapeReplace,Mf)}else if(vd.escapeTestNoEncode.test(e))return e.replace(vd.escapeReplaceNoEncode,Mf);return e}function Pf(e){try{e=encodeURI(e).replace(vd.percentDecode,`%`)}catch{return null}return e}function Ff(e,t){let n=e.replace(vd.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(vd.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``)}for(;r<n.length;r++)n[r]=n[r].trim().replace(vd.slashPipe,`|`);return n}function If(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Lf(e){let t=e.split(`
|
|
10
|
+
`),n=t.length-1;for(;n>=0&&vd.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
11
|
+
`)}function Rf(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function zf(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function Bf(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`),c=e[0].charAt(0)===`!`;r.state.inLink=!0;let l=r.state.linkEmitted,u=r.state.inRawBlock;r.state.linkEmitted=!1;let d=r.inlineTokens(s),f=r.state.linkEmitted;if(r.state.linkEmitted=l,r.state.inLink=!1,!c){if(f){r.state.inRawBlock=u;return}r.state.linkEmitted=!0}return{type:c?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:d}}function Vf(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
12
|
+
`).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
|
|
13
|
+
`)}var Hf=class{options;rules;lexer;constructor(e){this.options=e||fd}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=this.options.pedantic?t[0]:Lf(t[0]);return{type:`code`,raw:e,codeBlockStyle:`indented`,text:e.replace(this.rules.other.codeRemoveIndent,``)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=Vf(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=If(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:If(t[0],`
|
|
14
|
+
`),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:If(t[0],`
|
|
15
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=If(t[0],`
|
|
16
|
+
`).split(`
|
|
17
|
+
`),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o;for(o=0;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
|
|
18
|
+
`),c=s.replace(this.rules.other.blockquoteSetextReplace,`
|
|
19
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
|
|
20
|
+
${s}`:s,r=r?`${r}
|
|
21
|
+
${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=l,e.length===0)break;let u=i.at(-1);if(u?.type===`code`)break;if(u?.type===`blockquote`){let t=u,a=e.join(`
|
|
22
|
+
`),o=t.raw+`
|
|
23
|
+
`+a.replace(this.rules.other.blockquoteSetextReplace2,``),s=this.blockquote(o);i[i.length-1]=s,n=`${n}
|
|
24
|
+
${a}`,r=r.substring(0,r.length-t.text.length)+s.text;break}if(u?.type===`list`){let t=u,a=t.raw+`
|
|
25
|
+
`+e.join(`
|
|
26
|
+
`),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
|
|
27
|
+
`);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=zf(t[2].split(`
|
|
28
|
+
`,1)[0],t[1].length),l=e.split(`
|
|
29
|
+
`,1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,s=c.trimStart()):u?d=t[1].length+1:(d=c.search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+`
|
|
30
|
+
`,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d),f=this.rules.other.blockquoteBeginRegex(d);for(;e;){let p=e.split(`
|
|
31
|
+
`,1)[0],m;if(l=p,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),m=l):m=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||f.test(l)||t.test(l)||n.test(l))break;if(m.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
|
|
32
|
+
`+m.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
|
|
33
|
+
`+l}u=!l.trim(),r+=p+`
|
|
34
|
+
`,e=e.substring(p.length+1),c=m.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items)if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}for(let e of i.items){let t=e.tokens[0];if(e.task&&(t?.type===`text`||t?.type===`paragraph`)){e.text=e.text.replace(this.rules.other.listReplaceTask,``),t.raw=t.raw.replace(this.rules.other.listReplaceTask,``),t.text=t.text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:`checkbox`,raw:n[0]+` `,checked:n[0]!==`[ ]`};e.checked=t.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:`paragraph`,raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}else e.task&&=!1}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=Lf(t[0]);return{type:`html`,block:!0,raw:e,pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:e}}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:If(t[0],`
|
|
35
|
+
`),href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Ff(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
|
|
36
|
+
`):[],a={type:`table`,raw:If(t[0],`
|
|
37
|
+
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(Ff(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:If(t[0],`
|
|
38
|
+
`),depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
39
|
+
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=If(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=Rf(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),Bf(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return Bf(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,a,o,s=i,c=0,l=r[0][0],u=n===l,d=l===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*e.length+i);(r=d.exec(t))!==null;){if(a=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!a)continue;if(o=[...a].length,r[3]||r[4]){s+=o;continue}if(r[5]||r[6]){if(i%3&&!((i+o)%3)){c+=o;continue}if(u)break}if(s-=o,s>0)continue;o=Math.min(o,o+s+c);let t=[...r[0]][0].length,n=e.slice(0,i+r.index+t+o);if(Math.min(i,o)%2){let e=n.slice(1,-1);return{type:`em`,raw:n,text:e,tokens:this.lexer.inlineTokens(e)}}let l=n.slice(2,-2);return{type:`strong`,raw:n,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},Uf=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||fd,this.options.tokenizer=this.options.tokenizer||new Hf,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,top:!0};let t={other:vd,block:kf.normal,inline:Af.normal};this.options.pedantic?(t.block=kf.pedantic,t.inline=Af.pedantic):this.options.gfm&&(t.block=kf.gfm,t.inline=this.options.breaks?Af.breaks:Af.gfm),this.tokenizer.rules=t}static get rules(){return{block:kf,inline:Af}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(vd.carriageReturn,`
|
|
40
|
+
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(vd.tabCharGlobal,` `).replace(vd.spaceLine,``));let r=1/0;for(;e;){if(e.length<r)r=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(n=>(i=n.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let n=t.at(-1);i.raw.length===1&&n!==void 0?n.raw+=`
|
|
41
|
+
`:t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
42
|
+
`)?``:`
|
|
43
|
+
`)+i.raw,n.text+=`
|
|
44
|
+
`+i.text,this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
45
|
+
`)?``:`
|
|
46
|
+
`)+i.raw,n.text+=`
|
|
47
|
+
`+i.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},t.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),t.push(i);continue}let a=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(a=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(a))){let r=t.at(-1);n&&r?.type===`paragraph`?(r.raw+=(r.raw.endsWith(`
|
|
48
|
+
`)?``:`
|
|
49
|
+
`)+i.raw,r.text+=`
|
|
50
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(i),n=a.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
51
|
+
`)?``:`
|
|
52
|
+
`)+i.raw,n.text+=`
|
|
53
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}linkInText(e){if(!e.includes(`[`))return!1;let t=this.tokenizer.rules.inline.link;for(let n of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(t.test(n[0])&&e.charAt(n.index-1)!==`!`)return!0;for(let t of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let e=t[0],n=e.lastIndexOf(`[`);if(!(e.charAt(0)===`!`||!Object.hasOwn(this.tokens.links,e.slice(n+1,-1)))&&!(n>1&&this.linkInText(e.slice(1,n-1))))return!0}return!1}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e;if(this.tokens.links&&e.includes(`[`)){let e=this.tokenizer.rules.inline.reflinkSearch,t=n=>{let r=n.lastIndexOf(`[`);if(!Object.hasOwn(this.tokens.links,n.slice(r+1,-1)))return n;if(r>1&&n.charAt(0)!==`!`){let i=n.slice(1,r-1);if(this.linkInText(i))return`[`+i.replace(e,t)+`][`+`a`.repeat(n.length-r-2)+`]`}return`[`+`a`.repeat(n.length-2)+`]`};n=n.replace(e,t)}n=n.replace(this.tokenizer.rules.inline.anyPunctuation,e=>`+`.repeat(e.length)),n=n.replace(this.tokenizer.rules.inline.blockSkip,(e,t,n)=>{let r=n?n.length:0;return e.slice(0,r)+`[`+`a`.repeat(e.length-r-2)+`]`}),n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let r=!1,i=``,a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}r||(i=``),r=!1;let o;if(this.options.extensions?.inline?.some(n=>(o=n.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let n=t.at(-1);o.type===`text`&&n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,n,i)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e,n,i)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let s=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(s=e.substring(0,t+1))}if(o=this.tokenizer.inlineText(s)){e=e.substring(o.raw.length),o.raw.slice(-1)!==`_`&&(i=o.raw.slice(-1)),r=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t=`Infinite loop on byte: `+e;if(this.options.silent)console.error(t);else throw Error(t)}},Wf=class{options;parser;constructor(e){this.options=e||fd}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(vd.notSpaceStart)?.[0],i=e.replace(vd.endingNewline,``)+`
|
|
54
|
+
`;return r?`<pre><code class="language-`+Nf(r)+`">`+(n?i:Nf(i,!0))+`</code></pre>
|
|
55
|
+
`:`<pre><code>`+(n?i:Nf(i,!0))+`</code></pre>
|
|
56
|
+
`}blockquote({tokens:e}){return`<blockquote>
|
|
57
|
+
${this.parser.parse(e)}</blockquote>
|
|
58
|
+
`}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
59
|
+
`}hr(e){return`<hr>
|
|
60
|
+
`}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?`ol`:`ul`,a=t&&n!==1?` start="`+n+`"`:``;return`<`+i+a+`>
|
|
61
|
+
`+r+`</`+i+`>
|
|
62
|
+
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
63
|
+
`}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox"> `}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
64
|
+
`}table(e){let t=``,n=``;for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r=``;for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n=``;for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&=`<tbody>${r}</tbody>`,`<table>
|
|
65
|
+
<thead>
|
|
66
|
+
`+t+`</thead>
|
|
67
|
+
`+r+`</table>
|
|
68
|
+
`}tablerow({text:e}){return`<tr>
|
|
69
|
+
${e}</tr>
|
|
70
|
+
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
71
|
+
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Nf(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=Pf(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+Nf(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Pf(e);if(i===null)return Nf(n);e=i;let a=`<img src="${e}" alt="${Nf(n)}"`;return t&&(a+=` title="${Nf(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:Nf(e.text)}},Gf=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},Kf=class e{options;renderer;textRenderer;constructor(e){this.options=e||fd,this.options.renderer=this.options.renderer||new Wf,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Gf}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`checkbox`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`checkbox`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},qf=class{options;block;constructor(e){this.options=e||fd}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Uf.lex:Uf.lexInline}provideParser(e=this.block){return e?Kf.parse:Kf.parseInline}},Jf=class{defaults=dd();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Kf;Renderer=Wf;TextRenderer=Gf;Lexer=Uf;Tokenizer=Hf;Hooks=qf;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new Wf(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Hf(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new qf;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=qf.passThroughHooks.has(n)?e=>{if(this.defaults.async&&qf.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Uf.lex(e,t??this.defaults)}parser(e,t){return Kf.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?Uf.lex:Uf.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?Kf.parse:Kf.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?Uf.lex:Uf.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?Kf.parse:Kf.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
|
|
72
|
+
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+Nf(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},Yf=new Jf;function Xf(e,t){return Yf.parse(e,t)}Xf.options=Xf.setOptions=function(e){return Yf.setOptions(e),Xf.defaults=Yf.defaults,pd(Xf.defaults),Xf},Xf.getDefaults=dd,Xf.defaults=fd;function Zf(...e){return Yf.use(...e),Xf.defaults=Yf.defaults,pd(Xf.defaults),Xf}Xf.use=Zf,Xf.walkTokens=function(e,t){return Yf.walkTokens(e,t)},Xf.parseInline=Yf.parseInline,Xf.Parser=Kf,Xf.parser=Kf.parse,Xf.Renderer=Wf,Xf.TextRenderer=Gf,Xf.Lexer=Uf,Xf.lexer=Uf.lex,Xf.Tokenizer=Hf,Xf.Hooks=qf,Xf.parse=Xf,Xf.options,Xf.setOptions,Xf.walkTokens,Xf.parseInline,Kf.parse,Uf.lex;var Qf=new Jf({breaks:!0,gfm:!0});function $f(e){if(!e)return``;let t=Qf.parse(e,{async:!1});return ud.sanitize(t)}function ep(e,t){let n=e*t;if(!Number.isSafeInteger(e)||!Number.isSafeInteger(t)||e<1||t<1||!Number.isSafeInteger(n))throw RangeError(`Image dimensions must be positive safe integers; received ${e}×${t}`);return n}var tp=class e{constructor(e,t,n,r=`srgb`){this._canvas=null,this._imageData=null,this._dirty=!0,ep(e,t),this.width=e,this.height=t,this.channels=n,this.colorSpace=r,this._memoryBytes=n.reduce((e,t)=>e+t.byteLength,0)}get memoryBytes(){return this._memoryBytes}get memorySizeStr(){let e=this._memoryBytes;return e<1024?`${e}B`:e<1048576?`${(e/1024).toFixed(1)}KB`:`${(e/1048576).toFixed(2)}MB`}static grayscale(t,n){let r=ep(t,n);return new e(t,n,[new Float32Array(r)])}static rgb(t,n){let r=ep(t,n);return new e(t,n,[new Float32Array(r),new Float32Array(r),new Float32Array(r)])}static rgba(t,n){let r=ep(t,n);return new e(t,n,[new Float32Array(r),new Float32Array(r),new Float32Array(r),new Float32Array(r)])}static fromCanvas(t){let n,r,i;t instanceof HTMLImageElement?(n=t.naturalWidth||t.width,r=t.naturalHeight||t.height,i=document.createElement(`canvas`),i.width=n,i.height=r,i.getContext(`2d`).drawImage(t,0,0)):(n=t.width,r=t.height,i=t);let a=i.getContext(`2d`).getImageData(0,0,n,r);return e.fromImageData(a)}static fromImageData(t){let{width:n,height:r,data:i}=t,a=n*r,o=new Float32Array(a),s=new Float32Array(a),c=new Float32Array(a),l=new Float32Array(a),u=1/255;for(let e=0;e<a;e++){let t=e*4;o[e]=i[t]*u,s[e]=i[t+1]*u,c[e]=i[t+2]*u,l[e]=i[t+3]*u}return new e(n,r,[o,s,c,l])}static solid(t,n,r){let i=e.rgba(t,n);return i.fill(0,r.r),i.fill(1,r.g),i.fill(2,r.b),i.fill(3,r.a??1),i}get channelCount(){return this.channels.length}get layout(){switch(this.channels.length){case 1:return`gray`;case 3:return`rgb`;default:return`rgba`}}get pixelCount(){return this.width*this.height}getChannel(e){if(e<0||e>=this.channels.length)throw Error(`Channel index ${e} out of bounds (0-${this.channels.length-1})`);return this.channels[e]}r(){return this.channels[0]}g(){return this.channels[Math.min(1,this.channels.length-1)]}b(){return this.channels[Math.min(2,this.channels.length-1)]}a(){return this.channels.length>=4?this.channels[3]:this.createOpaqueAlpha()}createOpaqueAlpha(){let e=new Float32Array(this.pixelCount);return e.fill(1),e}index(e,t){return t*this.width+e}getPixel(e,t){let n=this.index(e,t);return this.channels.map(e=>e[n])}setPixel(e,t,n){let r=this.index(e,t);for(let e=0;e<Math.min(n.length,this.channels.length);e++)this.channels[e][r]=n[e];this._dirty=!0}getValue(e,t,n=0){return this.channels[n][this.index(e,t)]}setValue(e,t,n,r){this.channels[n][this.index(e,t)]=r,this._dirty=!0}fill(e,t){this.channels[e].fill(t),this._dirty=!0}fillAll(e){for(let t=0;t<this.channels.length;t++)this.channels[t].fill(e[t]??0);this._dirty=!0}clone(){let t=this.channels.map(e=>new Float32Array(e));return new e(this.width,this.height,t,this.colorSpace)}emptyClone(){return new e(this.width,this.height,this.channels.map(()=>new Float32Array(this.pixelCount)),this.colorSpace)}markDirty(){this._dirty=!0}toGrayscale(){if(this.channels.length===1)return this.clone();let t=e.grayscale(this.width,this.height),n=t.channels[0],r=this.channels[0],i=this.channels[1],a=this.channels[2];for(let e=0;e<this.pixelCount;e++)n[e]=.2126*r[e]+.7152*i[e]+.0722*a[e];return t}toRGBA(){if(this.channels.length>=4)return this.clone();let t=e.rgba(this.width,this.height);if(this.channels.length===1){let e=this.channels[0];t.channels[0].set(e),t.channels[1].set(e),t.channels[2].set(e),t.channels[3].fill(1)}else this.channels.length===3&&(t.channels[0].set(this.channels[0]),t.channels[1].set(this.channels[1]),t.channels[2].set(this.channels[2]),t.channels[3].fill(1));return t}toImageData(){if(this._imageData&&!this._dirty)return this._imageData;let e=new ImageData(this.width,this.height),t=e.data,n=this.pixelCount,r=this.channels[0],i=this.channels.length>1?this.channels[1]:r,a=this.channels.length>2?this.channels[2]:r,o=this.channels.length>3,s=o?this.channels[3]:null;for(let e=0;e<n;e++){let n=e<<2,c;c=r[e]*255+.5|0,t[n]=c<0?0:c>255?255:c,c=i[e]*255+.5|0,t[n+1]=c<0?0:c>255?255:c,c=a[e]*255+.5|0,t[n+2]=c<0?0:c>255?255:c,o?(c=s[e]*255+.5|0,t[n+3]=c<0?0:c>255?255:c):t[n+3]=255}return this._imageData=e,e}toCanvas(){return this._canvas&&!this._dirty?this._canvas:(this._canvas||(this._canvas=document.createElement(`canvas`),this._canvas.width=this.width,this._canvas.height=this.height),this._canvas.getContext(`2d`).putImageData(this.toImageData(),0,0),this._dirty=!1,this._canvas)}inBounds(e,t){return e>=0&&e<this.width&&t>=0&&t<this.height}wrapCoord(e,t,n){return n?(e%t+t)%t:Math.max(0,Math.min(t-1,e))}sample(e,t,n=0,r=!1){let i=Math.floor(e),a=Math.floor(t),o=i+1,s=a+1,c=e-i,l=t-a,u=this.channels[n],d=this.width,f=this.height,p=this.wrapCoord(i,d,r),m=this.wrapCoord(o,d,r),h=this.wrapCoord(a,f,r),g=this.wrapCoord(s,f,r),_=u[h*d+p],v=u[h*d+m],y=u[g*d+p],b=u[g*d+m],x=_*(1-c)+v*c,S=y*(1-c)+b*c;return x*(1-l)+S*l}samplePixel(e,t,n=!1){return this.channels.map((r,i)=>this.sample(e,t,i,n))}},np={number:`#4A9EFF`,image:`#FFD700`,asset:`#FFD700`,geometry:`#4ADE80`,array:`#F87171`,object:`#FB923C`,string:`#A78BFA`,boolean:`#F472B6`,color:`#EC4899`,trigger:`#FFFFFF`,any:`#9CA3AF`,inactive:`#4B5563`};function rp(e){return e.portType===`trigger`?np.trigger:e.value instanceof tp||e.value instanceof HTMLCanvasElement||e.value instanceof HTMLImageElement||e.value instanceof OffscreenCanvas?np.image:e.dataType&&e.dataType!==`any`?jl(e.dataType):Ml(e.value)?Al.image:typeof e.value==`number`?np.number:typeof e.value==`string`?np.string:typeof e.value==`boolean`?np.boolean:Array.isArray(e.value)?np.array:e.value!==null&&typeof e.value==`object`?np.object:np.any}var ip=T(`<textarea class="annotation-input svelte-hiih8o" placeholder="Enter text..."></textarea>`),ap=T(`<div class="annotation-content svelte-hiih8o"><!></div>`),op=T(`<div class="port annotation-port svelte-hiih8o" data-port-type="output" role="button" tabindex="0"><div class="port-dot svelte-hiih8o"></div></div>`),sp=T(`<div role="textbox" aria-label="Text annotation" tabindex="0"><!> <!></div>`);function cp(t,n){r(n,!1);let a=I(),s=I(),c=I(),l=I(),d=z(n,`annotation`,8),p=z(n,`isSelected`,8,!1),h=z(n,`isEditing`,8,!1),_=z(n,`isDragging`,8,!1),b=ve(),C=I();function T(){O(C)?.focus()}function D(){return O(C)}e(()=>k(d()),()=>{Y(a,d().style||{})}),e(()=>k(d()),()=>{Y(s,d().size?.width||540)}),e(()=>k(d()),()=>{Y(c,d().size?.height||`auto`)}),e(()=>(O(a),O(s),O(c)),()=>{Y(l,[`font-size: ${O(a).fontSize||14}px`,`font-weight: ${O(a).fontWeight||`normal`}`,`font-style: ${O(a).fontStyle||`normal`}`,`text-align: ${O(a).textAlign||`left`}`,`color: ${O(a).color||`var(--text-default)`}`,O(a).backgroundColor?`background-color: ${O(a).backgroundColor}`:``,`padding: ${O(a).padding||0}px`,`border-radius: ${O(a).borderRadius||0}px`,O(a).borderLeft?`border-left: ${O(a).borderLeft}`:``,`width: ${O(s)}px`,typeof O(c)==`number`?`min-height: ${O(c)}px`:``].filter(Boolean).join(`; `))}),ie();var ee={focusInput:T,getInputElement:D};le();var te=sp();let A;var j=q(te),P=e=>{var t=ip();U(t),pe(t,e=>Y(C,e),()=>O(C)),J(()=>{x(t,(k(d()),y(()=>d().content||``))),o(t,`width: ${O(s),O(a),y(()=>O(s)-(O(a).padding||8)*2)??``}px; min-height: ${O(c),O(a),y(()=>typeof O(c)==`number`?O(c)-(O(a).padding||8)*2:60)??``}px`)}),f(`blur`,t,()=>b(`finishEdit`)),f(`keydown`,t,e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)||e.key===`Escape`?b(`finishEdit`):e.key===`Delete`&&(e.metaKey||e.ctrlKey)&&b(`delete`,{id:d().id})}),f(`input`,t,e=>b(`input`,{id:d().id,event:e})),E(e,t)},F=e=>{var t=ap(),n=q(t),r=e=>{var t=u(),n=B(t);g(n,()=>(k($f),k(d()),y(()=>$f(d().content)))),E(e,t)};m(n,e=>{k(d()),y(()=>d().content)&&e(r)}),w(t),E(e,t)};m(j,e=>{h()?e(P):e(F,-1)});var ne=G(j,2),re=e=>{var t=u(),n=B(t);v(n,1,()=>(k(d()),y(()=>d().outputs)),e=>e.id,(e,t)=>{let n=L(()=>(k(d()),y(()=>d().size?.width||540))),r=L(()=>(k(d()),y(()=>typeof d().size?.height==`number`?d().size.height:60))),i=L(()=>(k(rp),O(t),y(()=>rp(O(t)))));var a=op(),s=M(a);J(()=>{N(a,`data-node-id`,(k(d()),y(()=>d().id))),N(a,`data-port-id`,(O(t),y(()=>O(t).id))),o(a,`position: absolute; left: ${O(n)/2}px; top: ${O(r)??``}px; transform: translate(-50%, -50%);`),N(a,`aria-label`,`Output port ${O(t),y(()=>O(t).name)??``}`),o(s,`background-color: ${O(i)??``};`)}),f(`mousedown`,a,e=>b(`portMouseDown`,{nodeId:d().id,portId:O(t).id,portType:`output`,event:e})),E(e,a)}),E(e,t)};return m(ne,e=>{k(d()),y(()=>d().outputs&&d().outputs.length>0)&&e(re)}),w(te),J(()=>{A=i(te,1,`annotation annotation-text svelte-hiih8o`,null,A,{selected:p(),editing:h(),dragging:_()}),N(te,`data-annotation-id`,(k(d()),y(()=>d().id))),o(te,`left: ${k(d()),y(()=>d().position.x)??``}px; top: ${k(d()),y(()=>d().position.y)??``}px; ${O(l)??``}`)}),f(`click`,te,e=>b(`click`,{id:d().id,event:e})),f(`dblclick`,te,e=>b(`dblclick`,{id:d().id,event:e})),f(`mousedown`,te,e=>b(`mousedown`,{id:d().id,event:e,width:O(s),height:typeof O(c)==`number`?O(c):60})),f(`mousemove`,te,e=>b(`mousemove`,{id:d().id,event:e,width:O(s),height:typeof O(c)==`number`?O(c):60})),f(`keydown`,te,e=>b(`keydown`,{id:d().id,event:e})),E(t,te),ue(n,`focusInput`,T),ue(n,`getInputElement`,D),S(ee)}var lp=T(`<div class="annotation-caption svelte-3d90za"> </div>`),up=T(`<div class="port annotation-port svelte-3d90za" data-port-type="output" role="button" tabindex="0"><div class="port-dot svelte-3d90za"></div></div>`),dp=T(`<div role="button" aria-label="Image annotation" tabindex="0"><img draggable="false" class="svelte-3d90za"/> <!> <!></div>`);function fp(t,n){r(n,!1);let a=I(),s=I(),c=I(),l=I(),d=z(n,`annotation`,8),p=z(n,`isSelected`,8,!1),h=z(n,`isDragging`,8,!1),g=ve();e(()=>k(d()),()=>{Y(a,d().size?.width||200)}),e(()=>k(d()),()=>{Y(s,d().size?.height||150)}),e(()=>k(d()),()=>{Y(c,d().src||``)}),e(()=>k(d()),()=>{Y(l,d().caption||``)}),ie(),le();var _=dp();let b;var x=q(_),C=G(x,2),T=e=>{var t=lp(),n=M(t,!0);J(()=>X(n,O(l))),E(e,t)};m(C,e=>{O(l)&&e(T)});var D=G(C,2),ee=e=>{var t=u(),n=B(t);v(n,1,()=>(k(d()),y(()=>d().outputs)),e=>e.id,(e,t)=>{let n=L(()=>(k(rp),O(t),y(()=>rp(O(t)))));var r=up(),i=M(r);J(()=>{N(r,`data-node-id`,(k(d()),y(()=>d().id))),N(r,`data-port-id`,(O(t),y(()=>O(t).id))),o(r,`position: absolute; left: ${O(a)/2}px; top: ${O(s)??``}px; transform: translate(-50%, -50%);`),N(r,`aria-label`,`Output port ${O(t),y(()=>O(t).name)??``}`),o(i,`background-color: ${O(n)??``};`)}),f(`mousedown`,r,e=>g(`portMouseDown`,{nodeId:d().id,portId:O(t).id,portType:`output`,event:e})),E(e,r)}),E(e,t)};m(D,e=>{k(d()),y(()=>d().outputs&&d().outputs.length>0)&&e(ee)}),w(_),J(()=>{b=i(_,1,`annotation annotation-image svelte-3d90za`,null,b,{selected:p(),dragging:h()}),N(_,`data-annotation-id`,(k(d()),y(()=>d().id))),o(_,`left: ${k(d()),y(()=>d().position.x)??``}px; top: ${k(d()),y(()=>d().position.y)??``}px; width: ${O(a)??``}px; height: ${O(s)??``}px`),N(x,`src`,O(c)),N(x,`alt`,O(l))}),f(`dragstart`,x,e=>e.preventDefault()),f(`click`,_,e=>g(`click`,{id:d().id,event:e})),f(`dblclick`,_,e=>g(`dblclick`,{id:d().id,event:e})),f(`mousedown`,_,e=>{e.button===0&&(e.preventDefault(),g(`mousedown`,{id:d().id,event:e}))}),f(`dragstart`,_,e=>e.preventDefault()),f(`keydown`,_,e=>g(`keydown`,{id:d().id,event:e})),E(t,_),S()}var pp=T(`<input type="text" class="annotation-input svelte-xr9cig" placeholder="Group name..."/>`),mp=T(`<div class="group-header svelte-xr9cig"> </div>`),hp=T(`<div class="resize-handle resize-se svelte-xr9cig" role="button" aria-label="Resize southeast" tabindex="0"></div> <div class="resize-handle resize-sw svelte-xr9cig" role="button" aria-label="Resize southwest" tabindex="0"></div> <div class="resize-handle resize-ne svelte-xr9cig" role="button" aria-label="Resize northeast" tabindex="0"></div> <div class="resize-handle resize-nw svelte-xr9cig" role="button" aria-label="Resize northwest" tabindex="0"></div>`,1),gp=T(`<div role="button" aria-label="Group annotation" tabindex="0"><!> <!></div>`);function _p(t,n){r(n,!1);let a=I(),s=I(),c=I(),l=z(n,`annotation`,8),u=z(n,`isSelected`,8,!1),d=z(n,`isEditing`,8,!1),p=z(n,`isDragging`,8,!1),h=ve(),g=I();function _(){O(g)?.focus(),O(g)?.select()}function v(){return O(g)}e(()=>k(l()),()=>{Y(a,l().size?.width||300)}),e(()=>k(l()),()=>{Y(s,l().size?.height||200)}),e(()=>k(l()),()=>{Y(c,l().content||`Group`)}),ie();var b={focusInput:_,getInputElement:v};le();var C=gp();let T;var D=q(C),ee=e=>{var t=pp();Ee(t),pe(t,e=>Y(g,e),()=>O(g)),J(()=>x(t,O(c))),f(`blur`,t,()=>h(`finishEdit`)),f(`keydown`,t,e=>{e.key===`Enter`||e.key===`Escape`?h(`finishEdit`):e.key===`Delete`&&(e.metaKey||e.ctrlKey)&&h(`delete`,{id:l().id})}),f(`input`,t,e=>h(`input`,{id:l().id,event:e})),E(e,t)},te=e=>{var t=mp(),n=M(t,!0);J(()=>X(n,O(c))),E(e,t)};m(D,e=>{d()?e(ee):e(te,-1)});var A=G(D,2),j=e=>{var t=hp(),n=B(t),r=G(n,2),i=G(r,2),a=G(i,2);f(`mousedown`,n,e=>h(`resizeStart`,{id:l().id,handle:`se`,event:e})),f(`mousedown`,r,e=>h(`resizeStart`,{id:l().id,handle:`sw`,event:e})),f(`mousedown`,i,e=>h(`resizeStart`,{id:l().id,handle:`ne`,event:e})),f(`mousedown`,a,e=>h(`resizeStart`,{id:l().id,handle:`nw`,event:e})),E(e,t)};return m(A,e=>{u()&&!d()&&e(j)}),w(C),J(()=>{T=i(C,1,`annotation annotation-group svelte-xr9cig`,null,T,{selected:u(),editing:d(),dragging:p()}),N(C,`data-annotation-id`,(k(l()),y(()=>l().id))),o(C,`left: ${k(l()),y(()=>l().position.x)??``}px; top: ${k(l()),y(()=>l().position.y)??``}px; width: ${O(a)??``}px; height: ${O(s)??``}px`)}),f(`click`,C,e=>h(`click`,{id:l().id,event:e})),f(`dblclick`,C,e=>h(`dblclick`,{id:l().id,event:e})),f(`mousedown`,C,e=>{e.button===0&&h(`mousedown`,{id:l().id,event:e})}),f(`keydown`,C,e=>h(`keydown`,{id:l().id,event:e})),E(t,C),ue(n,`focusInput`,_),ue(n,`getInputElement`,v),S(b)}var vp=D(`<svg role="button" aria-label="Line annotation" tabindex="0" style="position: absolute; left: 0; top: 0; pointer-events: none;"><line pointer-events="stroke" style="cursor: pointer;" class="svelte-os8h5j"></line></svg>`);function yp(t,n){r(n,!1);let a=I(),o=I(),s=I(),c=I(),l=I(),u=I(),d=I(),p=z(n,`annotation`,8),m=z(n,`isSelected`,8,!1),h=ve();e(()=>k(p()),()=>{Y(a,p().style||{})}),e(()=>k(p()),()=>{Y(o,p().position.x)}),e(()=>k(p()),()=>{Y(s,p().position.y)}),e(()=>k(p()),()=>{Y(c,p().endPosition?.x||p().position.x)}),e(()=>k(p()),()=>{Y(l,p().endPosition?.y||p().position.y)}),e(()=>O(a),()=>{Y(u,O(a).strokeWidth||2)}),e(()=>O(a),()=>{Y(d,O(a).strokeColor||`var(--text-default)`)}),ie(),le();var g=vp();let _;var v=M(g);J(()=>{_=i(g,0,`annotation annotation-line svelte-os8h5j`,null,_,{selected:m()}),N(g,`data-annotation-id`,(k(p()),y(()=>p().id))),N(v,`x1`,O(o)),N(v,`y1`,O(s)),N(v,`x2`,O(c)),N(v,`y2`,O(l)),N(v,`stroke`,O(d)),N(v,`stroke-width`,O(u))}),f(`click`,g,e=>h(`click`,{id:p().id,event:e})),f(`mousedown`,g,e=>h(`mousedown`,{id:p().id,event:e})),f(`keydown`,g,e=>h(`keydown`,{id:p().id,event:e})),E(t,g),S()}var bp=D(`<svg role="button" aria-label="Polyline annotation" tabindex="0" style="position: absolute; left: 0; top: 0; pointer-events: none;"><path fill="none" pointer-events="stroke" style="cursor: pointer;" class="svelte-3cc9ql"></path></svg>`);function xp(t,n){r(n,!1);let a=I(),o=I(),s=I(),c=I(),l=I(),d=z(n,`annotation`,8),p=z(n,`isSelected`,8,!1),h=ve();e(()=>k(d()),()=>{Y(a,d().style||{})}),e(()=>k(d()),()=>{Y(o,d().points||[])}),e(()=>O(a),()=>{Y(s,O(a).strokeWidth||2)}),e(()=>O(a),()=>{Y(c,O(a).strokeColor||`var(--text-default)`)}),e(()=>O(o),()=>{Y(l,O(o).map((e,t)=>`${t===0?`M`:`L`} ${e.x} ${e.y}`).join(` `))}),ie(),le();var g=u(),_=B(g),v=e=>{var t=bp();let n;var r=M(t);J(()=>{n=i(t,0,`annotation annotation-polyline svelte-3cc9ql`,null,n,{selected:p()}),N(t,`data-annotation-id`,(k(d()),y(()=>d().id))),N(r,`d`,O(l)),N(r,`stroke`,O(c)),N(r,`stroke-width`,O(s))}),f(`click`,t,e=>h(`click`,{id:d().id,event:e})),f(`mousedown`,t,e=>h(`mousedown`,{id:d().id,event:e})),f(`keydown`,t,e=>h(`keydown`,{id:d().id,event:e})),E(e,t)};m(_,e=>{O(o),y(()=>O(o).length>0)&&e(v)}),E(t,g),S()}var Sp=new Map([[`Text`,cp],[`text`,cp],[`Image`,fp],[`image`,fp],[`Group`,_p],[`group`,_p],[`Line`,yp],[`line`,yp],[`Polyline`,xp],[`polyline`,xp]]),Cp={id:`image`,label:`Image`,icon:`Palette`,categories:[{id:`create`,label:`Create`,nodes:[{name:`File`,icon:`FileImage`,description:`Load images from files`,type:`Image`},{name:`Color`,icon:`Square`,description:`Create a solid color canvas`,type:`Color`},{name:`Checkers`,icon:`Grid`,description:`Generate a checkerboard pattern`,type:`Checkers`},{name:`Noise`,icon:`Cloud`,description:`Generate procedural noise patterns`,type:`Noise`},{name:`Ramp`,icon:`Gradient`,description:`Generate color ramps`,type:`Ramp`},{name:`Text`,icon:`Type`,description:`Render text with customizable font and style`,type:`Text`}]},{id:`filter`,label:`Filter`,nodes:[{name:`Blur`,icon:`Droplets`,description:`Gaussian blur`,type:`Blur`},{name:`Normal Map`,icon:`Box`,description:`Compute normal map from height map`,type:`NormalMap`}]},{id:`transform`,label:`Transform`,nodes:[{name:`Transform`,icon:`Move`,description:`2D rotation, translation, and scaling`,type:`Transform`},{name:`Resize`,icon:`Maximize2`,description:`Scale or resize an image`,type:`Resize`}]},{id:`composite`,label:`Composite`,nodes:[{name:`Composite`,icon:`Layers`,description:`Blend two images together`,type:`Composite`}]}]},wp={id:`core`,label:`Core`,icon:`Workflow`,categories:[{id:`routing`,label:`Routing`,nodes:[{name:`Switch`,icon:`GitBranch`,description:`Switch between multiple inputs by index`,type:`Switch`},{name:`Merge`,icon:`GitMerge`,description:`Combine multiple inputs into an array`,type:`Merge`},{name:`Null`,icon:`Circle`,description:`Pass an input through unchanged`,type:`Null`}]},{id:`utility`,label:`Utility`,nodes:[{name:`Random`,icon:`Dice5`,description:`Generate a deterministic value from a seed`,type:`Random`},{name:`Remap`,icon:`ArrowRightLeft`,description:`Map a number from one range into another`,type:`Remap`},{name:`Select`,icon:`ListFilter`,description:`Pick an item from an array by index`,type:`Select`},{name:`Freeze`,icon:`Snowflake`,description:`Capture and lock a value`,type:`Freeze`}]},{id:`network`,label:`Network`,nodes:[{name:`Subnet`,icon:`Folder`,description:`Network container for organizing nodes`,type:`Subnet`},{name:`Input`,icon:`LogIn`,description:`External input to a subnet`,type:`Input`},{name:`Output`,icon:`LogOut`,description:`Defines subnet output`,type:`Output`}]}]},Tp={apiVersion:1,label:`Rectangle`,description:`A closed four-point polygon, counter-clockwise from bottom-left.`,icon:`Square`,runsOn:`portable`,inputs:{size:{kind:`data`,type:`vec2`,default:[1,1]},center:{kind:`data`,type:`vec2`,default:[0,0]}},outputs:{geometry:{kind:`data`,type:`geometry`}}},Ep={apiVersion:1,label:`Circle`,description:`A closed circle, as one cubic Bezier chain or as a polygon of divisions segments.`,icon:`Circle`,runsOn:`portable`,inputs:{center:{kind:`data`,type:`vec2`,default:[0,0]},radius:{kind:`data`,type:`vec2`,default:[1,1]},divisions:{kind:`data`,type:`int`,default:32,min:3,step:1,description:`Segments of the polygonal form. Ignored by the Bezier form.`}},outputs:{geometry:{kind:`data`,type:`geometry`}},props:{type:{type:`string`,default:`bezier`,label:`Primitive Type`,control:`select`,options:[`bezier`,`poly`],description:`A Bezier circle is a circle; a polygon of any division count is visibly a polygon in print.`}}},Dp={apiVersion:1,label:`Transform`,description:`Translate, rotate and scale geometry about a pivot.`,icon:`Move`,runsOn:`portable`,inputs:{geometry:{kind:`data`,type:`geometry`},translate:{kind:`data`,type:`vec2`,default:[0,0]},rotate:{kind:`data`,type:`float`,default:0,description:`Degrees, counter-clockwise.`},scale:{kind:`data`,type:`vec2`,default:[1,1]},pivot:{kind:`data`,type:`vec2`,default:[0,0]}},outputs:{geometry:{kind:`data`,type:`geometry`}}},Op={apiVersion:1,label:`Merge`,description:`Concatenate geometries, taking the union of their attributes.`,icon:`GitMerge`,runsOn:`portable`,inputs:{inputs:{kind:`data`,type:`geometry`,variadic:!0}},outputs:{geometry:{kind:`data`,type:`geometry`}}},kp={apiVersion:1,label:`Copy to Points`,description:`Instance one geometry onto every point of another.`,icon:`Copy`,runsOn:`portable`,inputs:{source:{kind:`data`,type:`geometry`},target:{kind:`data`,type:`geometry`}},outputs:{geometry:{kind:`data`,type:`geometry`}},props:{targetGroup:{type:`string`,default:``,label:`Target Group`,description:`Copy onto this point group only; empty means every point.`},useTargetOrientations:{type:`bool`,default:!0,label:`Transform Using Target Point Orientations`,description:`Read pscale and N from the target points.`}}},Ap={apiVersion:1,label:`SVG Export`,description:`Write geometry as an SVG document, one group element per group.`,icon:`FileDown`,runsOn:`portable`,capabilities:[`assets`],inputs:{geometry:{kind:`data`,type:`geometry`}},outputs:{svg:{kind:`data`,type:`string`},asset:{kind:`data`,type:`asset`}},props:{filename:{type:`string`,default:`geometry.svg`,label:`Filename`},width:{type:`float`,default:0,min:0,label:`Width`,description:`0 derives the width from the geometry bounds.`},height:{type:`float`,default:0,min:0,label:`Height`},margin:{type:`float`,default:0,label:`Margin`},stroke:{type:`color`,default:[0,0,0,1],label:`Stroke`,description:`Fallback for a primitive with no Cd attribute.`},strokeWidth:{type:`float`,default:1,min:0,label:`Stroke Width`,description:`Fallback for a primitive with no width attribute.`},opacity:{type:`float`,default:1,min:0,max:1,label:`Opacity`,description:`Fallback for a primitive with no opacity attribute.`},fillMode:{type:`string`,default:`none`,label:`Fill Mode`,control:`select`,options:[`none`,`solid`],description:`none leaves primitives unfilled, which is what plotter work wants.`},fill:{type:`color`,default:[1,1,1,1],label:`Fill`,description:`Fill colour, used only when Fill Mode is solid.`},pointRadius:{type:`float`,default:.5,min:0,label:`Point Radius`,description:`Fallback radius for a loose point with no pscale.`},precision:{type:`int`,default:3,min:0,max:15,step:1,label:`Precision`,description:`Decimal places on emitted coordinates.`}}},jp={id:`geo`,label:`Geometry`,icon:`Shapes`,categories:[{id:`geometry`,label:`Geometry`,nodes:Object.freeze([[`cascade.geo.Rectangle`,Tp],[`cascade.geo.Circle`,Ep],[`cascade.geo.Transform`,Dp],[`cascade.geo.Merge`,Op],[`cascade.geo.CopyToPoints`,kp],[`cascade.geo.SvgExport`,Ap]]).map(([e,t])=>({name:t.label??e.split(`.`).pop(),icon:t.icon??`Shapes`,description:t.description??``,type:e}))}]},Mp={id:`quill`,label:`Quill`,icon:`Feather`,categories:[{id:`text`,label:`Text`,nodes:[{name:`Prompt`,icon:`FileText`,description:`Text template with dynamic placeholders`,type:`Prompt`}]}]},Np=[{id:`annotations`,label:`Annotations`,icon:`StickyNote`,categories:[{id:`annotations`,label:`Annotations`,nodes:[{name:`Text`,icon:`Type`,description:`Add text annotation`,type:`annotation:text`},{name:`Image`,icon:`Image`,description:`Add image annotation`,type:`annotation:image`},{name:`Group`,icon:`Folder`,description:`Group elements together`,type:`annotation:group`},{name:`Line`,icon:`Minus`,description:`Draw a line`,type:`annotation:line`},{name:`Draw`,icon:`PenTool`,description:`Freehand drawing`,type:`annotation:polyline`}]}]},wp,jp,Cp,Mp];function Pp(e,t={}){return{id:`project`,label:`Project`,icon:`Package`,categories:[{id:`nodes`,label:`Nodes`,nodes:e.map(e=>({name:e.split(/[-_]/).filter(Boolean).map(e=>e[0]?.toUpperCase()+e.slice(1)).join(` `),icon:t[e]??`Settings`,description:`Project node · ${e}`,type:`project.${e}`}))}]}}var Fp={name:`Custom`,icon:`Zap`,description:`Create custom node with your own code`,type:`Custom`},Ip={node:e=>`// ${e} - Custom Node
|
|
73
|
+
//
|
|
74
|
+
// Define inputs
|
|
75
|
+
const input = node.in('input', null);
|
|
76
|
+
|
|
77
|
+
// Define properties (shown in inspector)
|
|
78
|
+
node.addParm('value', {
|
|
79
|
+
value: 1.0,
|
|
80
|
+
type: 'slider',
|
|
81
|
+
params: { min: 0, max: 10, step: 0.1 },
|
|
82
|
+
displayName: 'Value',
|
|
83
|
+
onChange: () => process()
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// Define outputs
|
|
87
|
+
const output = node.out('output');
|
|
88
|
+
|
|
89
|
+
// Process function
|
|
90
|
+
function process() {
|
|
91
|
+
output.setValue(node.props.value.value);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// React to input changes
|
|
95
|
+
input.onChange = (value) => {
|
|
96
|
+
// Process input and set output
|
|
97
|
+
output.setValue(value);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// Watch property changes (use with onChange for reliability)
|
|
101
|
+
node.watchProp('value', () => process());
|
|
102
|
+
|
|
103
|
+
// Called once when node is ready
|
|
104
|
+
node.onReady = () => process();
|
|
105
|
+
`,image:e=>`// ${e} - Image Processing Node
|
|
106
|
+
// Extends ImageNodeBase for canvas/image utilities
|
|
107
|
+
//
|
|
108
|
+
// Available helpers from ImageNodeBase:
|
|
109
|
+
// this.createCanvas(width, height) - Create a canvas
|
|
110
|
+
// this.getImageSize(img) - Get {width, height} from image/canvas
|
|
111
|
+
// this.getImageData(img, w?, h?) - Get ImageData from image
|
|
112
|
+
// this.putImageData(imageData) - Create canvas from ImageData
|
|
113
|
+
// this.colorToCss(color) - Convert {r,g,b,a} to CSS string
|
|
114
|
+
// this.normalizeColor(color) - Normalize color values to 0-1
|
|
115
|
+
// this.setOutputAndPreview(output, canvas) - Set output and preview
|
|
116
|
+
|
|
117
|
+
// Define image input
|
|
118
|
+
const imageInput = node.in('image', null);
|
|
119
|
+
|
|
120
|
+
// Define properties (use both onChange and watchProp for reliability)
|
|
121
|
+
node.addParm('intensity', {
|
|
122
|
+
value: 1.0,
|
|
123
|
+
type: 'slider',
|
|
124
|
+
params: { min: 0, max: 2, step: 0.01 },
|
|
125
|
+
displayName: 'Intensity',
|
|
126
|
+
onChange: () => process()
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
node.addParm('width', {
|
|
130
|
+
value: 512,
|
|
131
|
+
type: 'int',
|
|
132
|
+
params: { min: 1, max: 4096, step: 1 },
|
|
133
|
+
displayName: 'Width',
|
|
134
|
+
onChange: () => process()
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
node.addParm('height', {
|
|
138
|
+
value: 512,
|
|
139
|
+
type: 'int',
|
|
140
|
+
params: { min: 1, max: 4096, step: 1 },
|
|
141
|
+
displayName: 'Height',
|
|
142
|
+
onChange: () => process()
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// Define output
|
|
146
|
+
const output = node.out('image');
|
|
147
|
+
|
|
148
|
+
// Process function
|
|
149
|
+
function process() {
|
|
150
|
+
const width = node.props.width.value;
|
|
151
|
+
const height = node.props.height.value;
|
|
152
|
+
const intensity = node.props.intensity.value;
|
|
153
|
+
|
|
154
|
+
// Create output canvas
|
|
155
|
+
const canvas = document.createElement('canvas');
|
|
156
|
+
canvas.width = width;
|
|
157
|
+
canvas.height = height;
|
|
158
|
+
const ctx = canvas.getContext('2d');
|
|
159
|
+
if (!ctx) return;
|
|
160
|
+
|
|
161
|
+
// If we have an input image, process it
|
|
162
|
+
const inputImage = imageInput.value;
|
|
163
|
+
if (inputImage) {
|
|
164
|
+
ctx.drawImage(inputImage, 0, 0, width, height);
|
|
165
|
+
// Add your image processing here
|
|
166
|
+
} else {
|
|
167
|
+
// Generate pattern if no input
|
|
168
|
+
// Example: simple gradient
|
|
169
|
+
const gradient = ctx.createLinearGradient(0, 0, width, height);
|
|
170
|
+
gradient.addColorStop(0, \`rgba(255, 0, 0, \${intensity})\`);
|
|
171
|
+
gradient.addColorStop(1, \`rgba(0, 0, 255, \${intensity})\`);
|
|
172
|
+
ctx.fillStyle = gradient;
|
|
173
|
+
ctx.fillRect(0, 0, width, height);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
output.setValue(canvas);
|
|
177
|
+
node.preview = canvas;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// React to changes (watchProp used with onChange for reliability)
|
|
181
|
+
imageInput.onChange = process;
|
|
182
|
+
node.watchProp('intensity', () => process());
|
|
183
|
+
node.watchProp('width', () => process());
|
|
184
|
+
node.watchProp('height', () => process());
|
|
185
|
+
|
|
186
|
+
node.onReady = () => process();
|
|
187
|
+
`};function Lp(e){for(let t of Np)for(let n of t.categories){let t=n.nodes.find(t=>t.type===e);if(t)return t.icon}return`Settings`}function Rp(e,t,n){if(e.startsWith(`annotation:`))return`cascade.annotations.${e.split(`:`)[1]}`;if(e.startsWith(`project.`)||e.startsWith(`cascade.`))return e;for(let t of Np)for(let n of t.categories){let r=n.nodes.find(t=>t.type===e);if(r)return t.id===`core`?`cascade.core.${r.name}`:`cascade.${t.id}.${n.id}.${r.name}`}return t&&n?t===`core`?`cascade.core.${e}`:`cascade.${t}.${n}.${e}`:`custom.${e}`}function zp(e){let t=Rp(e);return t.startsWith(`cascade.`)?t.substring(8):t}var Bp=P(new Map);function Vp(e){Bp.update(t=>{let n=new Map(t);return n.set(e,(n.get(e)||0)+1),n})}var Hp=P({}),Up=P({}),Wp=P([]),Gp=null;function Kp(e=!1){return Gp&&!e||(Gp=(async()=>{try{let e=await fetch(`/api/nodes`);if(!e.ok)return;let t=await e.json();Array.isArray(t?.modules)&&Wp.set(t.modules),t?.runsOn&&Hp.set(t.runsOn),t?.icons&&Up.set(t.icons)}catch{}})()),Gp}function qp(e){if(!e)return null;let t=e.split(`.`);return t.length>1?t.slice(1).join(`.`):e}var Jp=P(0);function Yp(){Jp.update(e=>e+1)}var Xp=T(`<div role="button" tabindex="0" data-port-type="input"><span class="port-dot svelte-qglm8b"></span></div>`),Zp=T(`<div role="button" tabindex="0" data-port-type="input"><span class="port-pill svelte-qglm8b"></span></div>`),Qp=T(`<div class="variadic-item svelte-qglm8b"><span class="variadic-source svelte-qglm8b"> </span> <button class="variadic-remove svelte-qglm8b" title="Disconnect">×</button></div>`),$p=T(`<div class="variadic-list svelte-qglm8b" role="list"></div>`),em=T(`<span> </span>`),tm=T(`<div role="button" tabindex="0" data-port-type="output"><span class="port-dot svelte-qglm8b"></span></div>`),nm=T(`<input type="text" class="node-name-input svelte-qglm8b"/>`),rm=T(`<span class="node-name svelte-qglm8b" role="button" tabindex="0" title="Click to rename (Enter or Space)"> </span>`),im=T(`<div class="comment svelte-qglm8b"> </div>`),am=T(`<div class="error-message svelte-qglm8b"> </div>`),om=T(`<div role="tooltip"><span class="tooltip-name svelte-qglm8b"> </span> <span class="tooltip-type svelte-qglm8b"> </span></div>`),sm=T(`<div role="application" tabindex="-1"><div class="node-container svelte-qglm8b"><div class="node-content svelte-qglm8b"><div class="port-row inputs svelte-qglm8b"></div> <!> <div><button aria-label="Bypass node" title="Bypass (B)"></button> <span class="node-icon svelte-qglm8b"><!></span> <!> <button aria-label="Cook node" title="Cook (C)"></button></div> <div class="port-row outputs svelte-qglm8b"></div></div> <div class="label svelte-qglm8b"><!></div></div> <!> <!></div> <!>`,1);function cm(t,n){r(n,!1);let a=()=>oe(Hp,`$runsOnByModule`,p),s=()=>oe(Bp,`$propUpdateCounters`,p),l=()=>oe(Up,`$iconByModule`,p),d=()=>oe(Jp,`$graphStructure`,p),[p,h]=se(),g=I(),_=I(),b=I(),x=I(),C=I(),T=I(),D=I(),ee=I(),A=I(),j=I(),P=I(),F=I(),ne=I(),re=I(),R=z(n,`node`,8),ce=z(n,`selected`,8,!1),V=z(n,`canvasTransform`,24,()=>({x:0,y:0,zoom:1})),H=ve(),ue=I(0);function U(e,t){return t}function de(e,t){t.stopPropagation(),t.preventDefault(),H(`disconnect`,{connectionId:e})}let fe=I(!1),W=I(null),me=I(!1),K=I(),he=I(R().id);function _e(e,t,n,r,i){let a=e.currentTarget.getBoundingClientRect(),o=a.left+a.width/2,s=i===`input`?a.bottom:a.top,c=(o-V().x)/V().zoom,l=(s-V().y)/V().zoom;Y(W,{name:t,dataType:n,color:r,x:c,y:i===`input`?l+2:l-2,type:i})}function ye(){Y(W,null)}function be(e,t,n){H(`portClick`,{nodeId:R().id,portId:e,portType:t,event:n})}function xe(e,t,n){n.button===0&&(n.stopPropagation(),H(`portMouseDown`,{nodeId:R().id,portId:e,portType:t,event:n}))}function Se(e){e.target.closest(`.port`)||e.target.closest(`.node-name-input`)||e.target.closest(`.node-name`)||(e.preventDefault(),Y(fe,!0),H(`nodeMouseDown`,{nodeId:R().id,event:e}))}function Ce(){Y(fe,!1)}function we(e){e.target.closest(`.port`)||(e.stopPropagation(),R().isNetwork()?H(`diveInto`,{node:R()}):H(`edit`,{node:R()}))}function Te(e,t,n){n.key===`Enter`&&(n.preventDefault(),be(e,t,new MouseEvent(`click`,{bubbles:!0,cancelable:!0})))}function De(e){e.stopPropagation(),e.preventDefault(),H(`bypassToggle`,{nodeId:R().id,event:e})}function Oe(e){e.stopPropagation(),e.preventDefault(),H(`cookToggle`,{nodeId:R().id,event:e})}function ke(e){e.stopPropagation(),e.preventDefault(),Y(me,!0),Y(he,R().id),setTimeout(()=>{O(K)?.focus(),O(K)?.select()},0)}function Ae(){if(O(he).trim()){let e=O(he).trim().replace(/\s+/g,``);if(e){let t=R().rename(e);Y(he,t)}else Y(he,R().id)}else Y(he,R().id);Y(me,!1)}function je(){Y(he,R().id),Y(me,!1)}function Me(e){e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),Ae()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),je())}function Ne(e){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),ke(e))}e(()=>(k(R()),a()),()=>{Y(g,(()=>{let e=qp(R().modulePath);return e?a()[e]??null:null})())}),e(()=>(s(),k(R())),()=>{let e=s();Y(ue,R()&&e.get(R().id)||0)}),e(()=>k(R()),()=>{Y(_,R().cookState)}),e(()=>(O(_),k(R())),()=>{Y(b,O(_)===`error`||R().error!==null)}),e(()=>(k(R()),l(),Lp),()=>{Y(x,(()=>{let e=qp(R().modulePath);return e&&l()[e]||Lp(R().type)})())}),e(()=>k(R()),()=>{Y(C,R().color||null)}),e(()=>k(R()),()=>{Y(T,R().bypass)}),e(()=>k(R()),()=>{Y(D,R().cook)}),e(()=>O(_),()=>{Y(ee,O(_)===`cooking`)}),e(()=>(d(),k(R())),()=>{Y(A,U(d(),R().inputs))}),e(()=>(d(),k(R())),()=>{Y(j,U(d(),R().outputs))}),e(()=>(d(),k(R())),()=>{Y(P,U(d(),R().position))}),e(()=>O(A),()=>{Y(F,O(A).some(e=>e.variadic))}),e(()=>O(A),()=>{Y(ne,(()=>{let e=[],t=new Set;for(let n of O(A))if(n.variadic){let r=n.name.match(/^(.+)_\d+$/),i=r?r[1]:n.name;if(!t.has(i)){t.add(i);let n=O(A).filter(e=>e.variadic&&e.name.startsWith(`${i}_`));e.push({type:`variadic`,baseName:i,ports:n,firstPort:n[0]})}}else e.push({type:`single`,port:n});return e})())}),e(()=>(O(F),O(A)),()=>{Y(re,(()=>{if(!O(F))return[];let e=[];for(let t of O(A))if(t.variadic&&t.connections.length>0)for(let n of t.connections)e.push({portId:t.id,portName:t.name,connectionId:n.id,sourceNodeId:n.from.nodeId});return e})())}),e(()=>(k(R()),O(me)),()=>{R().id&&!O(me)&&Y(he,R().id)}),ie(),le();var Pe=sm(),Fe=B(Pe);let Ie;var Le=q(Fe),Re=q(Le),ze=q(Re);v(ze,5,()=>O(ne),c,(e,t)=>{var n=u(),r=B(n),a=e=>{let n=L(()=>(O(t),y(()=>O(t).port))),r=L(()=>(k(rp),k(O(n)),y(()=>rp(O(n)))));var a=Xp(),s=M(a);J(()=>{i(a,1,`port port-${k(O(n)),y(()=>O(n).portType)??``}`,`svelte-qglm8b`),N(a,`data-node-id`,(k(R()),y(()=>R().id))),N(a,`data-port-id`,(k(O(n)),y(()=>O(n).id))),o(s,`background-color: ${O(r)??``};`)}),f(`click`,a,e=>be(O(n).id,`input`,e)),f(`mousedown`,a,e=>xe(O(n).id,`input`,e)),f(`keydown`,a,e=>Te(O(n).id,`input`,e)),f(`mouseenter`,a,e=>_e(e,O(n).name,O(n).dataType||`any`,O(r),`input`)),f(`mouseleave`,a,ye),E(e,a)},s=e=>{let n=L(()=>(k(rp),O(t),y(()=>rp(O(t).firstPort))));L(()=>(O(t),y(()=>O(t).ports.filter(e=>e.connections.length>0).length)));var r=u(),a=B(r),s=e=>{var r=Zp(),a=M(r);J(e=>{i(r,1,`port port-${O(t),y(()=>O(t).firstPort.portType)??``} variadic`,`svelte-qglm8b`),N(r,`data-node-id`,(k(R()),y(()=>R().id))),N(r,`data-port-id`,(O(t),y(()=>O(t).firstPort.id))),N(r,`data-variadic-base`,(O(t),y(()=>O(t).baseName))),N(r,`data-variadic-ports`,e),o(a,`background-color: ${O(n)??``};`)},[()=>(O(t),y(()=>O(t).ports.map(e=>e.id).join(`,`)))]),f(`click`,r,e=>be(O(t).firstPort.id,`input`,e)),f(`mousedown`,r,e=>xe(O(t).firstPort.id,`input`,e)),f(`keydown`,r,e=>Te(O(t).firstPort.id,`input`,e)),f(`mouseenter`,r,e=>_e(e,O(t).baseName,O(t).firstPort.dataType||`any`,O(n),`input`)),f(`mouseleave`,r,ye),E(e,r)};m(a,e=>{O(F)&&e(s)}),E(e,r)};m(r,e=>{O(t),y(()=>O(t).type===`single`)?e(a):e(s,-1)}),E(e,n)}),w(ze);var Be=G(ze,2),Ve=e=>{var t=$p();v(t,5,()=>O(re),c,(e,t)=>{var r=Qp(),i=q(r),a=M(i,!0),o=G(i,2);w(r),J(()=>X(a,(O(t),y(()=>O(t).sourceNodeId)))),f(`click`,o,e=>de(O(t).connectionId,e)),f(`mousedown`,o,ae(function(e){ge.call(this,n,e)})),E(e,r)}),w(t),f(`mousedown`,t,ae(function(e){ge.call(this,n,e)})),E(e,t)};m(Be,e=>{O(F),O(re),y(()=>O(F)&&O(re).length>0)&&e(Ve)});var He=G(Be,2);let Ue;var We=q(He);let Ge;var Ke=G(We,2);Ac(q(Ke),{get name(){return O(x)},size:12,strokeWidth:2}),w(Ke);var Z=G(Ke,2),Q=e=>{let t=L(()=>O(g)===`server`?`S`:O(g)===`browser`?`B`:`P`),n=L(()=>O(g)===`server`?`Runs on the server`:O(g)===`browser`?`Runs in the browser`:`Portable: browser or server implementation`);var r=em(),a=M(r,!0);J(()=>{i(r,1,`locus-badge locus-${O(g)??``}`,`svelte-qglm8b`),N(r,`title`,O(n)),X(a,O(t))}),E(e,r)};m(Z,e=>{O(g)&&e(Q)});var qe=G(Z,2);let Je;w(He);var Ye=G(He,2);v(Ye,5,()=>O(j),c,(e,t)=>{let n=L(()=>(k(rp),O(t),y(()=>rp(O(t)))));var r=tm(),a=M(r);J(()=>{i(r,1,`port port-${O(t),y(()=>O(t).portType)??``}`,`svelte-qglm8b`),N(r,`data-node-id`,(k(R()),y(()=>R().id))),N(r,`data-port-id`,(O(t),y(()=>O(t).id))),o(a,`background-color: ${O(n)??``};`)}),f(`click`,r,e=>be(O(t).id,`output`,e)),f(`mousedown`,r,e=>xe(O(t).id,`output`,e)),f(`keydown`,r,e=>Te(O(t).id,`output`,e)),f(`mouseenter`,r,e=>_e(e,O(t).name,O(t).dataType||`any`,O(n),`output`)),f(`mouseleave`,r,ye),E(e,r)}),w(Ye),w(Re);var Xe=G(Re,2),Ze=q(Xe),$=e=>{var t=nm();Ee(t),pe(t,e=>Y(K,e),()=>O(K)),te(t,()=>O(he),e=>Y(he,e)),f(`blur`,t,Ae),f(`keydown`,t,Me),f(`click`,t,ae(function(e){ge.call(this,n,e)})),f(`mousedown`,t,ae(function(e){ge.call(this,n,e)})),E(e,t)},Qe=e=>{var t=rm(),n=M(t,!0);J(()=>X(n,(k(R()),y(()=>R().id)))),f(`click`,t,ke),f(`keydown`,t,Ne),E(e,t)};m(Ze,e=>{O(me)?e($):e(Qe,-1)}),w(Xe),w(Le);var $e=G(Le,2),et=e=>{var t=im(),n=M(t,!0);J(()=>X(n,(k(R()),y(()=>R().comment)))),E(e,t)};m($e,e=>{k(R()),y(()=>R().comment)&&e(et)});var tt=G($e,2),nt=e=>{var t=am(),n=M(t,!0);J(()=>X(n,(k(R()),y(()=>R().error?.message)))),E(e,t)};m(tt,e=>{O(b)&&e(nt)}),w(Fe);var rt=G(Fe,2),it=e=>{var t=om(),n=q(t),r=M(n,!0),a=G(n,2),s=M(a,!0);w(t),J(()=>{i(t,1,`port-tooltip port-tooltip-${O(W),y(()=>O(W).type)??``}`,`svelte-qglm8b`),o(t,`left: ${O(W),y(()=>O(W).x)??``}px; top: ${O(W),y(()=>O(W).y)??``}px; border-color: ${O(W),y(()=>O(W).color)??``};`),X(r,(O(W),y(()=>O(W).name))),o(a,`color: ${O(W),y(()=>O(W).color)??``};`),X(s,(O(W),y(()=>O(W).dataType)))}),E(e,t)};m(rt,e=>{O(W)&&e(it)}),J(()=>{Ie=i(Fe,1,`node svelte-qglm8b`,null,Ie,{selected:ce(),error:O(b),dragging:O(fe),bypassed:O(T),stale:O(_)===`stale`,queued:O(_)===`queued`,cooking:O(ee)}),N(Fe,`aria-label`,`Node: ${k(R()),y(()=>R().id)??``}`),N(Fe,`data-cook-state`,O(_)),o(Fe,`left: ${O(P),y(()=>O(P).x)??``}px; top: ${O(P),y(()=>O(P).y)??``}px; opacity: ${k(R()),y(()=>R().bypass?.5:1)??``}`),N(Fe,`data-node-id`,(k(R()),y(()=>R().id))),Ue=i(He,1,`body svelte-qglm8b`,null,Ue,{tinted:!!O(C)}),o(He,O(C)?`--node-fill:${O(C)}`:``),Ge=i(We,1,`node-button bypass-button svelte-qglm8b`,null,Ge,{active:O(T)}),Je=i(qe,1,`node-button cook-button svelte-qglm8b`,null,Je,{active:O(D)})}),f(`click`,We,De),f(`mousedown`,We,e=>e.stopPropagation()),f(`click`,qe,Oe),f(`mousedown`,qe,e=>e.stopPropagation()),f(`click`,Fe,e=>{e.stopPropagation(),H(`nodeClick`,{event:e})}),f(`mousedown`,Fe,Se),f(`mouseup`,Fe,Ce),f(`mouseleave`,Fe,Ce),f(`dblclick`,Fe,we),E(t,Pe),S(),h()}var lm={connections:!0},um={connections:!0,elements:!0,nodes:!0},dm=class{constructor(e,t=Yp){this.resolveGraph=e,this.invalidate=t}restoreConnections(){let e=this.resolveGraph();return e?(e.restoreConnections(),this.publish(e,{connections:!0,elements:!0}),!0):!1}connect(e,t){let n=this.requireGraph(),r=n.connect(e,t);return this.publish(n,lm),r}disconnect(e){let t=this.resolveGraph();return t?(t.disconnect(e),this.publish(t,lm),!0):!1}disconnectMany(e){let t=this.resolveGraph();if(!t)return!1;for(let n of e)t.disconnect(n);return this.publish(t,lm),!0}renameElement(e,t){let n=this.resolveGraph();return!n||!n.renameElement(e,t)?!1:(this.publish(n,um),!0)}removeElement(e){let t=this.resolveGraph();return!t||!t.getElement(e)?!1:(t.removeElement(e),this.publish(t,um),!0)}reparentElement(e,t){let n=this.resolveGraph(),r=n?.getElement(e),i=t?n?.getNode(t)??null:null;return!n||!r||t&&!i||!n.reparentElement(r,i)?!1:(this.publish(n,{elements:!0,nodes:!0}),!0)}refresh(e=um){let t=this.resolveGraph();return t?(this.publish(t,e),!0):!1}requireGraph(){let e=this.resolveGraph();if(!e)throw Error(`No graph is loaded`);return e}publish(e,t){t.connections&&(e.connections=[...e.connections]),t.elements&&(e.elements=[...e.elements]),t.nodes&&(e.nodes=[...e.nodes]),this.invalidate()}};function fm(e){let t=e.dataTransfer?.types;return t?Array.from(t).includes(`Files`):!1}var pm=50,mm=P({past:[],future:[]}),hm=A(mm,e=>e.past.length>0),gm=A(mm,e=>e.future.length>0),_m=0,vm=null,ym=300;function bm(e,t,n,r={}){let{debounce:i=!1,immediate:a=!1}=r;vm&&=(clearTimeout(vm),null);let o=()=>{let r={json:e.toJSON(),selectedNodeId:t,selectedAnnotationId:n,timestamp:Date.now()};mm.update(e=>{let t=[...e.past,r];return t.length>pm&&t.shift(),{past:t,future:[]}}),_m=Date.now()};a?o():i&&Date.now()-_m<ym?vm=setTimeout(o,ym):o()}function xm(e,t,n){bm(e,t,n,{immediate:!0})}function Sm(e,t,n){let r=xe(mm);if(r.past.length===0)return null;let i={json:e.toJSON(),selectedNodeId:t,selectedAnnotationId:n,timestamp:Date.now()},a=r.past[r.past.length-1];return mm.update(e=>({past:e.past.slice(0,-1),future:[i,...e.future]})),a}function Cm(e,t,n){let r=xe(mm);if(r.future.length===0)return null;let i={json:e.toJSON(),selectedNodeId:t,selectedAnnotationId:n,timestamp:Date.now()},a=r.future[0];return mm.update(e=>({past:[...e.past,i],future:e.future.slice(1)})),a}function wm(){vm&&=(clearTimeout(vm),null),mm.set({past:[],future:[]}),_m=0}var Tm=P([]);function Em(e){Tm.update(t=>t.length===e.length&&t.every((t,n)=>t===e[n])?t:[...e])}function Dm(e,t,n){if(!e)return n?[n]:[];let r=new Set(t);if(r.size>0){let t=e.nodes.filter(e=>r.has(e.id));if(t.length>0)return t}let i=e.nodes.filter(e=>e.selected||e.id===n?.id);return i.length>0?i:n?[n]:[]}var Om=``;async function km(e){Om=e;let t=globalThis.navigator?.clipboard;if(t?.writeText)try{await t.writeText(e);return}catch{}if(typeof document>`u`||typeof document.execCommand!=`function`)return;let n=document.createElement(`textarea`);n.value=e,n.style.position=`fixed`,n.style.opacity=`0`,document.body.appendChild(n),n.select();try{document.execCommand(`copy`)}finally{n.remove()}}async function Am(){let e=globalThis.navigator?.clipboard;if(e?.readText)try{let t=await e.readText();if(t)return t}catch{}return Om}var jm=T(`<input type="text" class="path-input svelte-p2f6pl" placeholder="Enter path (e.g., /subnet1/node1)"/>`),Mm=T(`<span class="path-separator svelte-p2f6pl">›</span>`),Nm=T(`<!> <button> </button>`,1),Pm=T(`<!> <button class="path-edit-btn svelte-p2f6pl" title="Press / to navigate by path">/</button>`,1),Fm=T(`<div class="selection-rectangle svelte-p2f6pl"></div>`),Im=D(`<path fill="none" stroke="transparent" stroke-width="12" class="connection-hit-area"></path><path fill="none" stroke-width="2"></path>`,1),Lm=D(`<g><circle class="endpoint-marker svelte-p2f6pl" cx="0" cy="0" r="12" stroke-width="1" opacity="0.9"></circle><path class="endpoint-icon svelte-p2f6pl" d="M -6,-4 L -6,4 M 6,-4 L 6,4 M -4,-6 L 4,6 M -4,6 L 4,-6" stroke-width="1.5" stroke-linecap="round" fill="none"></path></g>`),Rm=D(`<path fill="none" stroke-width="2" class="connection-preview svelte-p2f6pl"></path>`),zm=T(`<div class="annotation-debug"> </div>`),Bm=T(`<div role="application" aria-label="Graph canvas" tabindex="0"><div class="network-path-bar svelte-p2f6pl"><!></div> <!> <svg class="grid svelte-p2f6pl"><defs><pattern id="dots" width="20" height="20" patternUnits="userSpaceOnUse"><circle class="grid-dot svelte-p2f6pl" cx="10" cy="10" r="0.5"></circle></pattern></defs><rect class="grid-ground svelte-p2f6pl" width="100%" height="100%"></rect><rect width="100%" height="100%" fill="url(#dots)"></rect></svg> <svg class="connections-layer svelte-p2f6pl"><!><!><!></svg> <div class="annotations-container svelte-p2f6pl"></div> <div class="nodes-container svelte-p2f6pl"></div></div>`);function Vm(n,a){r(a,!1);let s=()=>oe(Jp,`$graphStructure`,l),[l,d]=se(),p=I(),h=I(),g=I(),_=I(),b=I(),x=I(),C=I(),T=ve(),D=z(a,`activeTool`,12,`select`),A=z(a,`selectedNode`,12,null),j=z(a,`graph`,28,()=>new Ll),P=z(a,`selectedAnnotation`,12,null),F=z(a,`transform`,8,void 0);z(a,`onRecordHistory`,8,void 0);let ne=new dm(()=>j()),re=I(),ae=I(),R=I(0);de(()=>O(ae)?.());function ce(){xm(j(),A()?.id||null,P())}let V=I(),U=I(F()?{...F()}:{x:0,y:0,zoom:1}),fe=I(F()?{...F()}:null),W=I({...O(U)}),me=!1,K=I([]),ge=I([]);function _e(e,t){if(t){let n=new Set(e);for(let e of t.nodes)e.selected=n.has(e.id)}Em(e)}let ye=I(null);function be(e){let t=[{id:`root`,label:`/`,node:null}];if(!e)return t;let n=[],r=e;for(;r;)n.unshift(r),r=r.parent;for(let e of n)t.push({id:e.id,label:e.id,node:e});return t}function xe(e){e.isNetwork()&&(Y(ye,e),Y(K,[]),A(null),T(`nodeSelect`,{node:null}))}function Se(){if(O(ye)){let e=O(ye);Y(ye,O(ye).parent),Y(K,[e.id]),A(e),T(`nodeSelect`,{node:e})}}function Ce(e){Y(ye,e),Y(K,[]),A(null),T(`nodeSelect`,{node:null})}let we=I(!1),Te=I(``),De=I(null);function ke(){Y(Te,O(ye)?O(ye).path():`/`),Y(we,!0),setTimeout(()=>{O(De)?.focus(),O(De)?.select()},10)}function Ae(){Y(we,!1),Y(Te,``)}function je(e){if(!e||e===`/`)Y(ye,null);else{let t=null,n=e.replace(/^\//,``).split(`/`).filter(e=>e),r=null;for(let e of n){let t=(r?r.children():j().nodes.filter(e=>!e.parent)).find(t=>t.id===e);if(t)r=t;else{console.warn(`Path segment not found: ${e}`);return}}if(t=r,t&&t.isNetwork())Y(ye,t);else if(t){Y(ye,t.parent),Y(K,[t.id]),A(t),T(`nodeSelect`,{node:t}),Ae();return}}Y(K,[]),A(null),T(`nodeSelect`,{node:null}),Ae()}function Ne(e){e.key===`Enter`?(e.preventDefault(),je(O(Te))):e.key===`Escape`&&(e.preventDefault(),Ae())}function Pe(e,t){return t?e.filter(e=>e.parent===t):e.filter(e=>!e.parent)}let Fe=null,Ie=I(!1);function Le(){return O(Ie)||(Fe=Gt(),Y(Ie,!0)),Fe}function Re(e,t){j().reparentElement(t,e)}function ze(){if(O(K).length===0)return;ce();let e=O(K).map(e=>j().getNode(e)).filter(Boolean);if(e.length===0)return;let t=new Set(e.map(e=>e.id)),n={minX:Math.min(...e.map(e=>e.position.x)),minY:Math.min(...e.map(e=>e.position.y)),maxX:Math.max(...e.map(e=>e.position.x)),maxY:Math.max(...e.map(e=>e.position.y))},r=[],i=[];j().connections.forEach(e=>{let n=t.has(e.from.nodeId),a=t.has(e.to.nodeId);if(!n&&a){let t=j().getNode(e.to.nodeId),n=t?.inputs.find(t=>t.id===e.to.portId);t&&n&&r.push({conn:e,targetNode:t,targetPort:n})}else if(n&&!a){let t=j().getNode(e.from.nodeId),n=t?.outputs.find(t=>t.id===e.from.portId),r=j().getNode(e.to.nodeId),a=r?.inputs.find(t=>t.id===e.to.portId);t&&n&&r&&a&&i.push({conn:e,sourceNode:t,sourcePort:n,targetNode:r,targetPort:a})}});let a=j().addNode(`Subnet`,{x:(n.minX+n.maxX)/2,y:(n.minY+n.maxY)/2});O(ye)&&Re(O(ye),a),e.forEach(e=>{e.position={x:e.position.x-a.position.x,y:e.position.y-a.position.y},Re(a,e)});let o=new Map;if(r.forEach((e,t)=>{let r=j().addNode(`Input`,{x:n.minX-a.position.x-150,y:n.minY-a.position.y+t*80});Re(a,r),r.props.inputIndex&&r.updateProp(`inputIndex`,t),j().disconnect(e.conn.id);let i=r.outputs[0];i&&e.targetPort&&j().connect(i,e.targetPort),o.set(e.conn.from.portId,r)}),r.length>0){let e=r[0],t=j().getNode(e.conn.from.nodeId)?.outputs.find(t=>t.id===e.conn.from.portId);t&&a.inputs[0]&&j().connect(t,a.inputs[0])}let s=null;if(i.length>0)s=i[0].sourceNode,s.setCook(!0);else if(e.length>0){let t=e[e.length-1];t.setCook(!0),s=t}i.forEach(e=>{j().disconnect(e.conn.id);let t=a.outputs[0];t&&e.targetPort&&j().connect(t,e.targetPort)}),ne.refresh({nodes:!0,connections:!0}),Y(K,[a.id]),A(a),T(`nodeSelect`,{node:a})}function Be(){if(O(K).length!==1)return;let e=j().getNode(O(K)[0]);if(!e||!e.isNetwork()||e.children().length===0)return;ce();let t=[...e.children()],n=e.parent,r=t.filter(e=>e.type===`Input`),i=t.filter(e=>e.type===`Output`),a=t.filter(e=>e.type!==`Input`&&e.type!==`Output`);if(a.length===0)return;let o=[];j().connections.forEach(t=>{if(t.to.nodeId===e.id){let n=e.inputs.findIndex(e=>e.id===t.to.portId);n!==-1&&o.push({conn:t,inputIndex:n})}});let s=[];j().connections.forEach(t=>{if(t.from.nodeId===e.id){let n=e.outputs.findIndex(e=>e.id===t.from.portId);n!==-1&&s.push({conn:t,outputIndex:n})}});let c=new Map;r.forEach(e=>{let t=e.evalParm(`inputIndex`)??0,n=[];j().connections.forEach(t=>{if(t.from.nodeId===e.id){let e=j().getNode(t.to.nodeId),r=e?.inputs.find(e=>e.id===t.to.portId);e&&r&&n.push({node:e,port:r})}}),c.has(t)||c.set(t,[]),c.get(t).push(...n)});let l=null,u=e.children().find(e=>e.cook),d=i[0];d?j().connections.forEach(e=>{if(e.to.nodeId===d.id){let t=j().getNode(e.from.nodeId),n=t?.outputs.find(t=>t.id===e.from.portId);t&&n&&(l=n)}}):u&&(l=u.outputs[0]),a.forEach(t=>{t.position={x:t.position.x+e.position.x,y:t.position.y+e.position.y},j().reparentElement(t,n)}),[...r,...i].forEach(e=>{j().connections.filter(t=>t.from.nodeId===e.id||t.to.nodeId===e.id).forEach(e=>j().disconnect(e.id)),j().removeNode(e.id)}),o.forEach(({conn:e,inputIndex:t})=>{let n=c.get(t)||[],r=j().getNode(e.from.nodeId)?.outputs.find(t=>t.id===e.from.portId);j().disconnect(e.id),r&&n.forEach(({port:e})=>{j().connect(r,e)})}),s.forEach(({conn:e})=>{let t=j().getNode(e.to.nodeId)?.inputs.find(t=>t.id===e.to.portId);j().disconnect(e.id),l&&t&&j().connect(l,t)}),j().connections.filter(t=>t.from.nodeId===e.id||t.to.nodeId===e.id).forEach(e=>j().disconnect(e.id)),j().removeNode(e.id),ne.refresh({nodes:!0,connections:!0}),Y(K,a.map(e=>e.id)),A(a[0]??null),T(`nodeSelect`,{node:A()})}let Ve=!1,He=I(!1),Ue=I(null),We=I(null),Ge=I(null),Ke=!1,Z=I(null),Q=I(null),qe=I({x:0,y:0}),Je=null,Ye=I(null),Xe=I(!1),Ze=null,$=null,Qe=null,$e=null;function et(e,t){return t.filter(e=>e&&e.position).map(e=>({id:e.id,x:e.position.x,y:e.position.y}))}let tt=I([]);function nt(e,t,n){return e.id===n?!0:t.length===0?!1:t.includes(e.from.nodeId)||t.includes(e.to.nodeId)}function rt(e){let t=j().getNode(e.to.nodeId);return t?.cookState===`queued`||t?.cookState===`cooking`}function it(e){if(O(V)){if(e.button===0&&(e.ctrlKey||e.metaKey)&&!e.target.closest(`.node, .annotation`)){let t=O(V).getBoundingClientRect(),n=ot((e.clientX-t.left-O(U).x)/O(U).zoom,(e.clientY-t.top-O(U).y)/O(U).zoom);if(n){e.preventDefault(),e.stopPropagation(),ce(),ne.disconnect(n.id),Y(Ye,null);return}}if(e.button===1)me=!0,e.preventDefault();else if(e.button===0&&(Ve||D()===`hand`))me=!0;else if(e.button===0&&D()===`select`&&!Ze){if(!e.target.closest(`.node, .annotation`)){let t=O(V).getBoundingClientRect();Y(Ue,{x:(e.clientX-t.left-O(U).x)/O(U).zoom,y:(e.clientY-t.top-O(U).y)/O(U).zoom}),Y(We,{x:e.clientX-t.left,y:e.clientY-t.top}),Y(qe,{...O(Ue)}),Y(Ge,{...O(We)}),Y(He,!0),Ke=!1,e.shiftKey||(Y(K,[]),Y(ge,[]),A(null),P(null),T(`nodeSelect`,{node:null}),T(`annotationSelect`,{annotationId:null}))}}else if(e.button===0&&D()===`line`){if(e.target.closest(`.annotation, .node`))return;let t=O(V).getBoundingClientRect(),n=(e.clientX-t.left-O(U).x)/O(U).zoom,r=(e.clientY-t.top-O(U).y)/O(U).zoom,i=`line_${Date.now().toString(36)}`,a={id:i,type:`Line`,position:{x:n,y:r},endPosition:{x:n,y:r},style:{strokeWidth:2,strokeColor:`#ffffff`}};if(ce(),j().addAnnotation(a),O(ye)){let e=j().getAnnotation(i);e&&Re(O(ye),e)}j(j().annotations=[...j().annotations],!0),vt={annotationId:i,startPos:{x:n,y:r}},e.stopPropagation()}else if(e.button===0&&D()===`polyline`){if(e.target.closest(`.annotation, .node`))return;let t=O(V).getBoundingClientRect(),n=(e.clientX-t.left-O(U).x)/O(U).zoom,r=(e.clientY-t.top-O(U).y)/O(U).zoom,i=`polyline_${Date.now().toString(36)}`,a={id:i,type:`Polyline`,position:{x:n,y:r},points:[{x:n,y:r}],style:{strokeWidth:2,strokeColor:`#ffffff`}};if(ce(),j().addAnnotation(a),O(ye)){let e=j().getAnnotation(i);e&&Re(O(ye),e)}j(j().annotations=[...j().annotations],!0),yt={annotationId:i,points:[{x:n,y:r}]},e.stopPropagation()}}}function at(e){if(me&&(H(U,O(U).x+=e.movementX),H(U,O(U).y+=e.movementY),Y(U,{...O(U)})),O(He)&&O(Ue)){let t=O(V).getBoundingClientRect(),n=(e.clientX-t.left-O(U).x)/O(U).zoom,r=(e.clientY-t.top-O(U).y)/O(U).zoom;Y(qe,{x:n,y:r}),Y(Ge,{x:e.clientX-t.left,y:e.clientY-t.top})}if(Ze){let t=j().getNode(Ze.nodeId);if(t){let n=O(V).getBoundingClientRect(),r=(e.clientX-n.left-O(U).x)/O(U).zoom-Ze.offset.x,i=(e.clientY-n.top-O(U).y)/O(U).zoom-Ze.offset.y;if((O(K).length>1||O(ge).length>0)&&$&&Ze){let e=$.nodes.find(e=>e.nodeId===Ze.nodeId);if(!e){t.position={x:r,y:i},j(j().nodes=[...j().nodes],!0);return}let n=r-e.startPos.x,a=i-e.startPos.y;$.nodes.forEach(({nodeId:e,startPos:t})=>{let r=j().getNode(e);r&&(r.position={x:t.x+n,y:t.y+a})}),j(j().annotations=j().annotations.map(e=>{let t=$?.annotations.find(t=>t.annotationId===e.id);if(!t)return e;let r=t.startPos.x+n,i=t.startPos.y+a;return{...e,position:{x:r,y:i},style:e.style?{...e.style}:void 0,outputs:e.outputs?e.outputs.map(e=>({...e})):void 0}}),!0)}else t.position={x:r,y:i};j(j().nodes=[...j().nodes],!0),j(j().annotations=[...j().annotations],!0)}}if(O(gt)&&!_t){let t=j().getAnnotation(O(gt).annotationId);if(t){let n=O(V).getBoundingClientRect(),r=(e.clientX-n.left-O(U).x)/O(U).zoom-O(gt).offset.x,i=(e.clientY-n.top-O(U).y)/O(U).zoom-O(gt).offset.y;if((O(ge).length>1||O(K).length>0)&&$&&O(gt)){let e=$.annotations.find(e=>e.annotationId===O(gt).annotationId);if(!e){j(j().annotations=j().annotations.map(e=>{if(e.id!==t.id)return e;let n=e.position.x,a=e.position.y,o=r-n,s=i-a;return e.type===`Line`?{...e,position:{x:r,y:i},endPosition:e.endPosition?{x:e.endPosition.x+o,y:e.endPosition.y+s}:void 0}:e.type===`Polyline`?{...e,position:{x:r,y:i},points:e.points?e.points.map(e=>({x:e.x+o,y:e.y+s})):void 0}:{...e,position:{x:r,y:i}}}),!0);return}let n=r-e.startPos.x,a=i-e.startPos.y;$.nodes.forEach(({nodeId:e,startPos:t})=>{let r=j().getNode(e);r&&(r.position={x:t.x+n,y:t.y+a})}),j(j().annotations=j().annotations.map(e=>{let t=$?.annotations.find(t=>t.annotationId===e.id);if(!t)return e;let r=t.startPos.x+n,i=t.startPos.y+a,o=e.position.x,s=e.position.y,c=r-o,l=i-s;return e.type===`Line`?{...e,position:{x:r,y:i},endPosition:e.endPosition?{x:e.endPosition.x+c,y:e.endPosition.y+l}:void 0}:e.type===`Polyline`?{...e,position:{x:r,y:i},points:e.points?e.points.map(e=>({x:e.x+c,y:e.y+l})):void 0}:{...e,position:{x:r,y:i}}}),!0),j(j().nodes=[...j().nodes],!0);return}j(j().annotations=j().annotations.map(e=>{if(e.id!==t.id)return e;let n=e.position.x,a=e.position.y,o=r-n,s=i-a;return e.type===`Line`?{...e,position:{x:r,y:i},endPosition:e.endPosition?{x:e.endPosition.x+o,y:e.endPosition.y+s}:void 0,style:e.style?{...e.style}:void 0,outputs:e.outputs?e.outputs.map(e=>({...e})):void 0}:e.type===`Polyline`?{...e,position:{x:r,y:i},points:e.points?e.points.map(e=>({x:e.x+o,y:e.y+s})):void 0,style:e.style?{...e.style}:void 0,outputs:e.outputs?e.outputs.map(e=>({...e})):void 0}:{...e,position:{x:r,y:i},style:e.style?{...e.style}:void 0,outputs:e.outputs?e.outputs.map(e=>({...e})):void 0}}),!0),j(j().nodes=[...j().nodes],!0)}}if(_t){let t=_t;if(j().getAnnotation(t.annotationId)){let n=O(V).getBoundingClientRect(),r=(e.clientX-n.left-O(U).x)/O(U).zoom,i=(e.clientY-n.top-O(U).y)/O(U).zoom,a=r-t.startPos.x,o=i-t.startPos.y,s=t.startSize.width,c=t.startSize.height,l=t.startPosition.x,u=t.startPosition.y,d=t.handle;d.includes(`e`)?s=Math.max(100,t.startSize.width+a):d.includes(`w`)&&(s=Math.max(100,t.startSize.width-a),l=t.startPosition.x+(t.startSize.width-s)),d.includes(`s`)?c=Math.max(40,t.startSize.height+o):d.includes(`n`)&&(c=Math.max(40,t.startSize.height-o),u=t.startPosition.y+(t.startSize.height-c)),j(j().annotations=j().annotations.map(e=>e.id===t.annotationId?{...e,position:{x:l,y:u},size:{width:s,height:c},style:e.style?{...e.style}:void 0,outputs:e.outputs?e.outputs.map(e=>({...e})):e.outputs,points:e.points?e.points.map(e=>({...e})):void 0,endPosition:e.endPosition?{...e.endPosition}:void 0}:e),!0)}}if(vt){let t=vt;if(j().getAnnotation(t.annotationId)){let n=O(V).getBoundingClientRect(),r=(e.clientX-n.left-O(U).x)/O(U).zoom,i=(e.clientY-n.top-O(U).y)/O(U).zoom;j(j().annotations=j().annotations.map(e=>e.id===t.annotationId?{...e,endPosition:{x:r,y:i}}:e),!0)}}if(yt){let t=yt;if(j().getAnnotation(t.annotationId)){let n=O(V).getBoundingClientRect(),r=(e.clientX-n.left-O(U).x)/O(U).zoom,i=(e.clientY-n.top-O(U).y)/O(U).zoom,a=t.points[t.points.length-1];Math.sqrt((r-a.x)**2+(i-a.y)**2)>3&&(t.points.push({x:r,y:i}),j(j().annotations=j().annotations.map(e=>e.id===t.annotationId?{...e,points:[...t.points]}:e),!0))}}if(O(Z)){let t=O(V).getBoundingClientRect();Y(qe,{x:(e.clientX-t.left-O(U).x)/O(U).zoom,y:(e.clientY-t.top-O(U).y)/O(U).zoom})}if(!O(Z)&&!Ze&&!O(gt)&&!O(He)){let t=O(V).getBoundingClientRect(),n=(e.clientX-t.left-O(U).x)/O(U).zoom,r=(e.clientY-t.top-O(U).y)/O(U).zoom,i=e.ctrlKey||e.metaKey,a=ot(n,r);a&&i?Y(Ye,{connectionId:a.id,position:{x:n,y:r}}):Y(Ye,null)}else Y(Ye,null)}function ot(e,t){let n=8/O(U).zoom;for(let r of O(tt)){let i=Qt(r.from.nodeId,r.from.portId,`output`),a=Qt(r.to.nodeId,r.to.portId,`input`);if(!i||!a)continue;let o=Math.abs(a.y-i.y)*.5;for(let s=0;s<=1;s+=.05){let c=i.x,l=i.y,u=i.x,d=i.y+o,f=a.x,p=a.y-o,m=a.x,h=a.y,g=1-s,_=g*g*g*c+3*g*g*s*u+3*g*s*s*f+s*s*s*m,v=g*g*g*l+3*g*g*s*d+3*g*s*s*p+s*s*s*h;if(Math.sqrt((e-_)**2+(t-v)**2)<n)return r}}return null}function st(e){if(e.button===1?(me=!1,e.preventDefault()):me=!1,O(Z)&&e.button===0){let t=e.target.closest(`.port`);if(t){let e=t.getAttribute(`data-node-id`),n=t.getAttribute(`data-port-id`),r=t.getAttribute(`data-port-type`),i=t.getAttribute(`data-variadic-base`);if(e&&n&&r){let t=O(Z);if(t.portType===`output`&&r===`input`&&t.nodeId!==e){let r=j().getElement(t.nodeId),a=j().getElement(e);if(r&&a){let e=r.outputs.find(e=>e.id===t.portId),o;if(i?(o=a.inputs.filter(e=>e.variadic&&e.name.startsWith(`${i}_`)&&!e.options?.hidden).find(e=>e.connections.length===0),!o&&a.syncVariadicPorts&&(a.syncVariadicPorts(),o=a.inputs.filter(e=>e.variadic&&e.name.startsWith(`${i}_`)&&!e.options?.hidden).find(e=>e.connections.length===0)),o||=a.inputs.find(e=>e.id===n)):o=a.inputs.find(e=>e.id===n),e&&o)try{ce();let n=o.variadic===!0,i=[];if(n){let e=a.id;O(K).forEach(n=>{if(n!==t.nodeId&&n!==e){let e=j().getNode(n);e&&e.outputs.length>0&&i.push({element:e,output:e.outputs[0]})}}),O(ge).forEach(n=>{if(n!==t.nodeId&&n!==e){let e=j().getAnnotation(n);e&&e.outputs&&e.outputs.length>0&&i.push({element:e,output:e.outputs[0]})}})}if(a.isNetwork&&a.isNetwork()){let t=j().addNode(`Input`,{x:-200,y:(a.children().length-a.children().filter(e=>e.type===`Input`).length)*80});t.id=j().generateUniqueNodeId(`input`),Re(a,t);let n=a.children().filter(e=>e.type===`Input`).length-1;t.props.inputIndex&&t.updateProp(`inputIndex`,n),j().connect(e,o),j(j().nodes=[...j().nodes],!0)}else r.isNetwork&&r.isNetwork(),j().connect(e,o);if(n&&i.length>0){let e=o.name.match(/^(.+)_(\d+)$/);if(e&&a.syncVariadicPorts){let t=e[1],n=parseInt(e[2],10)+1;for(let{output:e}of i){a.syncVariadicPorts();let r=`${t}_${n}`,i=a.inputs.find(e=>e.name===r&&!e.options?.hidden);if(i||=(a.syncVariadicPorts(),a.inputs.find(e=>e.name===r&&!e.options?.hidden)),i)try{j().connect(e,i),n++}catch(e){console.warn(`Failed to connect additional element:`,e)}}}}ne.refresh({connections:!0})}catch(e){console.error(`Failed to connect:`,e)}}}}Y(Z,null),Y(Q,null),Je=null}else Je&&=(ce(),ne.disconnectMany(Je.connectionIds),null),Y(Z,null),Y(Q,null)}if(Ze=null,Y(gt,null),$=null,_t=null,vt&&(vt=null,D(`select`),T(`toolChange`,`select`)),yt&&(yt=null,D(`select`),T(`toolChange`,`select`)),O(He)&&O(Ue)){let t=O(V).getBoundingClientRect(),n=(e.clientX-t.left-O(U).x)/O(U).zoom,r=(e.clientY-t.top-O(U).y)/O(U).zoom,i=Math.min(O(Ue).x,n),a=Math.max(O(Ue).x,n),o=Math.min(O(Ue).y,r),s=Math.max(O(Ue).y,r),c=[];j().nodes.forEach(e=>{let t=e.position.x,n=e.position.x+120,r=e.position.y,l=e.position.y+80;n>=i&&t<=a&&l>=o&&r<=s&&c.push(e.id)});let l=[];j().annotations.forEach(e=>{let t,n,r,c;if(e.type===`Line`){let i=e.position.x,a=e.position.y,o=e.endPosition?.x??e.position.x,s=e.endPosition?.y??e.position.y;t=Math.min(i,o),n=Math.max(i,o),r=Math.min(a,s),c=Math.max(a,s);let l=(e.style?.strokeWidth||2)+5;t-=l,n+=l,r-=l,c+=l}else if(e.type===`Polyline`){if(e.points&&e.points.length>0){let i=e.points.map(e=>e.x),a=e.points.map(e=>e.y);t=Math.min(...i),n=Math.max(...i),r=Math.min(...a),c=Math.max(...a);let o=(e.style?.strokeWidth||2)+5;t-=o,n+=o,r-=o,c+=o}else return}else{let i=e.size?.width||(e.type===`Text`?540:e.type===`Image`?200:300),a=e.size?.height||(e.type===`Text`?60:e.type===`Image`?150:200);t=e.position.x,n=e.position.x+i,r=e.position.y,c=e.position.y+a}n>=i&&t<=a&&c>=o&&r<=s&&l.push(e.id)}),e.shiftKey?(Y(K,[...O(K),...c.filter(e=>!O(K).includes(e))]),l.forEach(e=>{O(ge).includes(e)||O(ge).push(e)}),l.length>0&&(P(l[0]),T(`annotationSelect`,{annotationId:P()}))):(Y(K,c),Y(ge,l),l.length>0?(P(l[0]),T(`annotationSelect`,{annotationId:P()})):(P(null),T(`annotationSelect`,{annotationId:null}))),O(K).length>0?(A(j().getNode(O(K)[0])),A()&&T(`nodeSelect`,{node:A()})):(A(null),T(`nodeSelect`,{node:null})),Y(He,!1),Ke=!0,Y(Ue,null),Y(We,null),Y(Ge,null),setTimeout(()=>{Ke=!1},100)}}function ct(e,t,n){n.stopPropagation();let r=j().getAnnotation(e);if(r){let i=O(V).getBoundingClientRect(),a=(n.clientX-i.left-O(U).x)/O(U).zoom,o=(n.clientY-i.top-O(U).y)/O(U).zoom,s=r.size||{width:200,height:150},c=r.position;_t={annotationId:e,handle:t,startPos:{x:a,y:o},startSize:{width:s.width,height:s.height},startPosition:{x:c.x,y:c.y}}}}async function lt(e,t){if(t.target.closest(`.port`)||t.button===1)return;let n=j().getNode(e);if(!n)return;ce();let r=O(V).getBoundingClientRect(),i=(t.clientX-r.left-O(U).x)/O(U).zoom,a=(t.clientY-r.top-O(U).y)/O(U).zoom;if(t.altKey){let n=[...O(K)],r=[...O(ge)];n.includes(e)||(n=[e],r=[]);let o=new Map,s=[],c=[];for(let e of n){let t=j().getNode(e);if(!t)continue;let n=t.modulePath||t.type,r=j().addNode(n,{...t.position}),i=r.id,a=j().generateUniqueNodeId(t.id,i);if(o.set(e,a),ne.renameElement(i,a),r.code=t.code||``,r.comment=t.comment||``,r.bypass=t.bypass||!1,O(ye)&&j().reparentElement(r,O(ye)),s.push(a),r.code)try{await j().execute(r)}catch(e){console.warn(`Failed to execute duplicated node:`,e)}}for(let e=0;e<n.length;e++){let t=n[e],r=s[e],i=j().getNode(t),a=j().getNode(r);i&&a&&Object.keys(i.props).length>0&&Object.entries(i.props).forEach(([e,t])=>{if(a.props[e]&&(a.props[e].value=t.value,t.expression)){let n=t.expression;o.forEach((e,t)=>{[RegExp(`(ch[sv]?\\s*\\(\\s*['"][^'"]*/)${t}(/[^'"]*['"]\\s*\\))`,`g`),RegExp(`(ch[sv]?\\s*\\(\\s*['"]\\.\\./)${t}(['"]\\s*\\))`,`g`)].forEach(t=>{n=n.replace(t,`$1${e}$2`)})}),a.props[e].expression=n}})}for(let e of n){let t=j().getNode(e);if(t)for(let n of t.outputs)for(let r of n.connections){let i=r.to.nodeId,a=r.to.portId,s=o.get(e),c=o.get(i);if(s&&c){let e=j().getNode(s),r=j().getNode(c),o=j().getNode(i);if(e&&r&&o){let i=t.outputs.indexOf(n),s=o.getInputPortById(a),c=s?o.inputs.indexOf(s):-1;if(i>=0&&c>=0){let t=e.outputs[i],n=r.inputs[c];if(t&&n)try{j().connect(t,n)}catch{}}}}}}for(let e of r){let t=j().getAnnotation(e);if(!t)continue;let n=`${t.type}_${Date.now().toString(36)}_${Math.random().toString(36).substr(2,5)}`,r={...t,id:n,position:{...t.position}};O(ye)&&j().reparentElement(r,O(ye)),j().addAnnotation(r),c.push(n)}j(j().nodes=[...j().nodes],!0),j(j().annotations=[...j().annotations],!0),Y(K,s),Y(ge,c);let l=o.get(e);if(l){let e=j().getNode(l);if(e){A(e),T(`nodeSelect`,{node:e});let t={x:i-e.position.x,y:a-e.position.y};Ze={nodeId:l,offset:t},(s.length>1||c.length>0)&&($={nodes:s.map(e=>{let t=j().getNode(e);return{nodeId:e,startPos:t?{...t.position}:{x:0,y:0}}}),annotations:c.map(e=>{let t=j().getAnnotation(e);return{annotationId:e,startPos:t?{...t.position}:{x:0,y:0}}}),offset:t})}}t.stopPropagation();return}let o={x:i-n.position.x,y:a-n.position.y};Ze={nodeId:e,offset:o},(O(K).length>1||O(ge).length>0)&&($={nodes:O(K).map(e=>{let t=j().getNode(e);return{nodeId:e,startPos:t?{...t.position}:{x:0,y:0}}}),annotations:O(ge).map(e=>{let t=j().getAnnotation(e);return{annotationId:e,startPos:t?{...t.position}:{x:0,y:0}}}),offset:o}),t.stopPropagation()}function ut(e){T(`nodeEdit`,{node:e.detail.node})}function dt(e,t){let n=t.event;if(D()===`select`){n.stopPropagation();let t=j().getNode(e);t&&(n.shiftKey?O(K).includes(e)?Y(K,O(K).filter(t=>t!==e)):Y(K,[...O(K),e]):Y(K,[e]),A(t),T(`nodeSelect`,{node:t}))}}function ft(e,t){let n=j().getNode(e);n&&(n.setBypass(!n.bypass),j(j().nodes=[...j().nodes],!0))}function pt(e,t){let n=j().getNode(e);if(n){if(t.shiftKey){n.setCook(!0);let e=t=>{t.outputs.forEach(t=>{t.connections.forEach(t=>{let n=j().getNode(t.to.nodeId);n&&(n.setCook(!0),e(n))})})};e(n)}else n.cook?n.setCook(!1):(j().clearCookingNodes(),n.setCook(!0));j(j().nodes=[...j().nodes],!0)}}function mt(e){ce(),ne.disconnect(e)}let ht=I(null),gt=I(null),_t=null,vt=null,yt=null;function bt(e){e.key!==`Enter`&&e.key}function xt(e){}function St(e){if((e.ctrlKey||e.metaKey)&&e.target&&!e.target.closest(`.node, .annotation`)){let t=O(V).getBoundingClientRect(),n=ot((e.clientX-t.left-O(U).x)/O(U).zoom,(e.clientY-t.top-O(U).y)/O(U).zoom);if(n){e.preventDefault(),e.stopPropagation(),ce(),ne.disconnect(n.id),Y(Ye,null);return}}if(!(e.target&&e.target.closest(`.annotation`))){if(D()===`select`&&e.target&&!e.target.closest(`.node`)&&!Ke)Y(K,[]),Y(ge,[]),A(null),P(null),Y(ht,null),T(`nodeSelect`,{node:null});else if([`text`,`image`,`group`].includes(D())){let t=O(V).getBoundingClientRect(),n=(e.clientX-t.left-O(U).x)/O(U).zoom,r=(e.clientY-t.top-O(U).y)/O(U).zoom;Ct(D(),n,r),D(`select`),T(`toolChange`,`select`)}}}function Ct(e,t,n){let r=`${e}_${Date.now().toString(36)}`;ce();let i=e=>{if(O(ye)){let t=j().getAnnotation(e);t&&Re(O(ye),t)}};if(e===`image`){let e=document.createElement(`input`);e.type=`file`,e.accept=`image/*`,e.onchange=async e=>{let a=e.target.files?.[0];if(a){let e=new FileReader;e.onload=e=>{let a=e.target?.result,o={id:r,type:`Image`,src:a,position:{x:t,y:n},size:{width:200,height:150}};j().addAnnotation(o),i(r),j(j().annotations=[...j().annotations],!0)},e.readAsDataURL(a)}},e.click()}else if(e===`group`){let e={id:r,type:`Group`,content:`Group`,position:{x:t,y:n},containedElements:[]};j().addAnnotation(e),i(r),j(j().annotations=[...j().annotations],!0),Y(ht,r),setTimeout(()=>{if(!O(V))return;let e=O(V).querySelector(`[data-annotation-id="${r}"]`);if(e){let t=e.querySelector(`input, textarea`);t&&(t.focus(),t.select())}},10)}else if(e===`text`){let e={id:r,type:`Text`,content:``,position:{x:t,y:n},size:{width:540,height:60},style:{fontSize:14,fontWeight:`normal`,fontStyle:`normal`,textAlign:`left`,color:`#ffffff`,padding:0,borderRadius:0}};j().addAnnotation(e),i(r),j(j().annotations=[...j().annotations],!0),Y(ht,r),setTimeout(()=>{if(!O(V))return;let e=O(V).querySelector(`[data-annotation-id="${r}"]`);if(e){let t=e.querySelector(`input, textarea`);t&&t.focus()}},10)}}function wt(e,t){t.stopPropagation(),D()===`select`&&!O(ht)&&(t.shiftKey?O(ge).includes(e)?Y(ge,O(ge).filter(t=>t!==e)):Y(ge,[...O(ge),e]):(Y(ge,[e]),Y(K,[]),A(null)),P(e),T(`annotationSelect`,{annotationId:e}))}function Tt(e,t){if(t.stopPropagation(),D()===`select`&&!O(ht)&&t.button===0){if(t.target.closest(`input, textarea, button, .resize-handle`))return;ce();let n=j().getAnnotation(e);if(n){O(ge).includes(e)||(t.shiftKey?Y(ge,[...O(ge),e]):(Y(ge,[e]),Y(K,[]),A(null))),P(e),T(`annotationSelect`,{annotationId:e});let r=O(V).getBoundingClientRect(),i=(t.clientX-r.left-O(U).x)/O(U).zoom,a=(t.clientY-r.top-O(U).y)/O(U).zoom,o={x:i-n.position.x,y:a-n.position.y};Y(gt,{annotationId:e,offset:o}),(O(K).length>0||O(ge).length>1)&&($={nodes:O(K).map(e=>{let t=j().getNode(e);return{nodeId:e,startPos:t?{...t.position}:{x:0,y:0}}}),annotations:O(ge).map(e=>{let t=j().getAnnotation(e);return{annotationId:e,startPos:t?{...t.position}:{x:0,y:0}}}),offset:o})}}}function Et(e,t,n,r){t.target.closest(`input, textarea, button`)||Tt(e,t),_t||kt(e,t,n,r)}function Dt(e,t){(t.key===`Enter`||t.key===` `)&&wt(e,new MouseEvent(`click`,{bubbles:!0,cancelable:!0}))}function Ot(e,t,n,r){if(!P()||P()!==e||O(ht)===e)return;let i=j().getAnnotation(e);if(!i)return;let a=O(V).getBoundingClientRect(),o=(t.clientX-a.left-O(U).x)/O(U).zoom-i.position.x,s=(t.clientY-a.top-O(U).y)/O(U).zoom-i.position.y,c=o<8,l=o>n-8,u=s<8,d=s>r-8,f=`default`;c&&u||l&&d?f=`nwse-resize`:c&&d||l&&u?f=`nesw-resize`:c||l?f=`ew-resize`:(u||d)&&(f=`ns-resize`),t.currentTarget.style.cursor=f}function kt(e,t,n,r){if(!P()||P()!==e||O(ht)===e)return;let i=O(V).getBoundingClientRect(),a=(t.clientX-i.left-O(U).x)/O(U).zoom,o=(t.clientY-i.top-O(U).y)/O(U).zoom,s=j().getAnnotation(e);if(!s)return;let c=a-s.position.x,l=o-s.position.y,u=c<8,d=c>n-8,f=l<8,p=l>r-8;if(u||d||f||p){t.stopPropagation(),ce();let i=`se`;u&&f?i=`nw`:u&&p?i=`sw`:d&&f?i=`ne`:d&&p?i=`se`:u?i=`w`:d?i=`e`:f?i=`n`:p&&(i=`s`),_t={annotationId:e,handle:i,startPos:{x:a,y:o},startSize:s.size||{width:n,height:r},startPosition:{...s.position}}}}function At(e,t){t.stopPropagation(),Y(ht,e)}function jt(e,t=!1){t||ce(),j().removeAnnotation(e),j(j().annotations=[...j().annotations],!0),P()===e&&P(null),Y(ge,O(ge).filter(t=>t!==e)),O(ht)===e&&Y(ht,null)}async function Mt(){let e=document.activeElement;if(e&&(e.tagName===`INPUT`||e.tagName===`TEXTAREA`))return;let t=[],n=[];if(O(K).length>0&&O(K).forEach(e=>{let n=j().getNode(e);n&&t.push(n)}),O(ge).length>0)O(ge).forEach(e=>{let t=j().getAnnotation(e);t&&n.push(t)});else if(P()){let e=j().getAnnotation(P());e&&n.push(e)}if(t.length===0&&n.length===0)return;ce();let r=t.map(e=>e.toJSON()),i=new Set(t.map(e=>e.id)),a={type:`cascade/cut`,nodes:r,connections:j().connections.filter(e=>i.has(e.from.nodeId)&&i.has(e.to.nodeId)),annotations:n};try{await km(JSON.stringify(a)),t.forEach(e=>{j().removeNode(e.id)}),n.forEach(e=>{j().removeAnnotation(e.id)}),j(j().nodes=[...j().nodes],!0),j(j().annotations=[...j().annotations],!0),Y(K,[]),Y(ge,[]),A(null),P(null),T(`nodeSelect`,{node:null}),T(`annotationSelect`,{annotationId:null})}catch(e){console.error(`Failed to cut to clipboard:`,e)}}async function Nt(){let e=document.activeElement;if(e&&(e.tagName===`INPUT`||e.tagName===`TEXTAREA`))return;let t=[],n=[];if(O(K).length>0&&O(K).forEach(e=>{let n=j().getNode(e);n&&t.push(n)}),O(ge).length>0)O(ge).forEach(e=>{let t=j().getAnnotation(e);t&&n.push(t)});else if(P()){let e=j().getAnnotation(P());e&&n.push(e)}if(t.length===0&&n.length===0)return;let r=t.map(e=>e.toJSON()),i=new Set(t.map(e=>e.id)),a={type:`cascade/copy`,nodes:r,connections:j().connections.filter(e=>i.has(e.from.nodeId)&&i.has(e.to.nodeId)),annotations:n};try{await km(JSON.stringify(a))}catch(e){console.error(`Failed to copy to clipboard:`,e)}}async function Pt(){let e=document.activeElement;if(!(e&&(e.tagName===`INPUT`||e.tagName===`TEXTAREA`)))try{let e=await Am(),t=JSON.parse(e);if(!t.type||!t.type.startsWith(`cascade/`))return;ce();let n=new Map,r=[];if(t.nodes&&t.nodes.length>0){for(let e of t.nodes){let t=Array.isArray(e.position)?e.position[0]:e.position.x,i=Array.isArray(e.position)?e.position[1]:e.position.y,a=j().addNode(e.type,{x:t+50,y:i+50}),o=a.id,s=j().generateUniqueNodeId(e.id,o);if(n.set(e.id,s),ne.renameElement(o,s),a.code=e.code||``,a.comment=e.comment||``,a.bypass=e.bypass||!1,O(ye)&&j().reparentElement(a,O(ye)),r.push(a),a.code)try{await j().execute(a)}catch(e){console.warn(`Failed to execute pasted node:`,e)}}for(let e=0;e<t.nodes.length;e++){let i=t.nodes[e],a=r[e];i.props&&Object.entries(i.props).forEach(([e,t])=>{if(a.props[e]){if(t&&typeof t==`object`&&`expression`in t){let r=t.expression;n.forEach((e,t)=>{[RegExp(`(ch[sv]?\\s*\\(\\s*['"][^'"]*/)${t}(/[^'"]*['"]\\s*\\))`,`g`),RegExp(`(ch[sv]?\\s*\\(\\s*['"]\\.\\./)${t}(['"]\\s*\\))`,`g`)].forEach(t=>{r=r.replace(t,`$1${e}$2`)})}),a.props[e]={...a.props[e],value:t.value,expression:r}}else a.updateProp(e,t)}})}}if(t.connections&&t.connections.length>0)for(let e of t.connections){let t=n.get(e.from.nodeId),r=n.get(e.to.nodeId);if(t&&r){let n=j().getNode(t),i=j().getNode(r);if(n&&i){let t=n.outputs.find(t=>t.id===e.from.portId),r=i.inputs.find(t=>t.id===e.to.portId);t&&r&&j().connect(t,r)}}}if(t.annotations&&t.annotations.length>0)for(let e of t.annotations){let t=`${e.type}_${Date.now().toString(36)}_${Math.random().toString(36).substr(2,5)}`,n={...e,id:t,position:{x:e.position.x+50,y:e.position.y+50}};O(ye)&&j().reparentElement(n,O(ye)),j().addAnnotation(n)}j(j().nodes=[...j().nodes],!0),j(j().annotations=[...j().annotations],!0),r.length>0&&(Y(K,r.map(e=>e.id)),A(r[0]),T(`nodeSelect`,{node:r[0]}))}catch(e){console.debug(`Paste failed or not Cascade data:`,e)}}function Ft(e,t){let n=j().getAnnotation(e);n&&(n.content=t,j(j().annotations=[...j().annotations],!0))}function It(e,t){let n=t.target;Ft(e,n.value)}function Lt(e,t){let n=t.target;Ft(e,n.value)}function Rt(){Y(ht,null)}function zt(e){fm(e)&&(e.preventDefault(),e.stopPropagation())}function Bt(e){if(!fm(e)||(e.preventDefault(),e.stopPropagation(),O(gt)))return;let t=Array.from(e.dataTransfer?.files||[]);if(t.length===0)return;let n=O(V).getBoundingClientRect(),r=(e.clientX-n.left-O(U).x)/O(U).zoom,i=(e.clientY-n.top-O(U).y)/O(U).zoom;t.forEach(async(e,t)=>{let n=r+t*30,a=i+t*30;if(e.type.startsWith(`image/`)){let t=new FileReader;t.onload=t=>{let r=t.target?.result,i=`${e.name.replace(/\.[^/.]+$/,``).replace(/[^a-zA-Z0-9_-]/g,`_`)}_${Date.now().toString(36)}`,o={id:i,type:`Image`,src:r,position:{x:n,y:a},size:{width:200,height:150},caption:e.name};if(j().addAnnotation(o),O(ye)){let e=j().getAnnotation(i);e&&Re(O(ye),e)}j(j().annotations=[...j().annotations],!0),j().assetManager.cache.set(e.name,{id:e.name,path:r,type:`image`,data:r,size:e.size,metadata:{name:e.name}})},t.readAsDataURL(e)}else try{let t=await e.text();j().assetManager.cache.set(e.name,{id:e.name,path:e.name,type:e.type.includes(`json`)?`json`:`text`,data:e.type.includes(`json`)?JSON.parse(t):t,size:e.size,metadata:{name:e.name}})}catch(e){console.warn(`Failed to load file as asset:`,e)}})}function Vt(e){e.target.closest(`.node`)||(e.preventDefault(),T(`openNodePanel`,{x:e.clientX,y:e.clientY}))}function Ht(e,t){if(!j())return;let n=e.map(e=>e.outputs.find(e=>e.name===`output`)||e.outputs[0]).filter(Boolean);if(n.length!==0){if(t.variadic)n.forEach((e,n)=>{t.syncVariadicPorts();let r=t.getVariadicInputs()[n];if(r&&e)try{j().connect(e,r)}catch{}});else{let e=t.inputs.filter(e=>e.connections.length===0&&!e.options?.hidden);n.forEach((t,n)=>{let r=e[n];if(r&&t)try{j().connect(t,r)}catch{}})}}}async function Ut(e){ce();let t=[...O(K)],n=[...O(ge)],r=e.type,i=e.customConfig,a=O(V).getBoundingClientRect(),o=a.width/2,s=a.height/2,c=(o-O(U).x)/O(U).zoom,l=(s-O(U).y)/O(U).zoom;if(r.startsWith(`annotation:`)){let e=r.replace(`annotation:`,``);if(e===`line`||e===`polyline`){D(e),T(`toolChange`,e);return}Ct(e,c,l);return}j().nodes.find(e=>{let t=Math.abs(e.position.x-c),n=Math.abs(e.position.y-l);return t<50&&n<50})&&(c+=50,l+=33);let u=j().addNode(r,{x:c,y:l});if(O(ye)&&O(ye).isNetwork()&&Re(O(ye),u),Me(r)===null){let e=i?.code||Wt(r);u.code=e,r.startsWith(`local.`)&&j().moduleResolver.createEmbeddedModule(r,e,`user`);try{u.resetPortTracking();let t=await ml(e);u.setFunction(t.execute);let n=u.bypass,i=u.cook;n&&u.setBypass(!1),i||u.setCook(!0),console.log(`Executing node ${r}, props before:`,Object.keys(u.props).length),await j().execute(u),console.log(`Node ${r} executed, props after:`,Object.keys(u.props).length,Object.keys(u.props)),u.error&&console.error(`Node ${r} execution error:`,u.error),n&&u.setBypass(!0),i||u.setCook(!1),u.cleanupUnusedPorts(),u.inputs=[...u.inputs],u.outputs=[...u.outputs];let a={...u.props};u.props=a,u.markDirty(),console.log(`Node ${r} initialized with ${Object.keys(a).length} props:`,Object.keys(a)),Object.keys(a).length===0&&(console.warn(`Warning: Node ${r} has no props after execution.`),console.warn(`Code snippet:`,e.substring(0,300)),u.error&&console.error(`Node execution error:`,u.error))}catch(e){console.error(`Failed to initialize node:`,e),u.error=e}}let d=t.map(e=>j().getNode(e)).filter(e=>e!==null),f=n.map(e=>j().getAnnotation(e)).filter(e=>e!==null),p=[...d,...f];p.length>0&&Ht(p,u),ne.refresh({nodes:!0,connections:!0});let m=c*O(U).zoom+O(U).x,h=l*O(U).zoom+O(U).y,g=o-m,_=s-h;H(U,O(U).x+=g),H(U,O(U).y+=_),Y(U,{...O(U)}),await ee(),Y(K,[u.id]),A(u),T(`nodeSelect`,{node:u})}function Wt(e){return`// ${Oe(e)} - Custom Node
|
|
188
|
+
//
|
|
189
|
+
// Define inputs
|
|
190
|
+
const input = node.in('input', null);
|
|
191
|
+
|
|
192
|
+
// Define properties (shown in inspector)
|
|
193
|
+
node.defineProp('value', {
|
|
194
|
+
value: 1.0,
|
|
195
|
+
params: { min: 0, max: 10, step: 0.1 },
|
|
196
|
+
displayName: 'Value'
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// Define outputs
|
|
200
|
+
const output = node.out('output');
|
|
201
|
+
|
|
202
|
+
// React to input changes
|
|
203
|
+
input.onChange = (value) => {
|
|
204
|
+
output.setValue(value);
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
// React to property changes
|
|
208
|
+
node.watchProp('value', (newValue) => {
|
|
209
|
+
output.setValue(newValue);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
// Called once when node is ready
|
|
213
|
+
node.onReady = () => {
|
|
214
|
+
output.setValue(node.props.value.value);
|
|
215
|
+
};
|
|
216
|
+
`}function Gt(){let e=1/0,t=1/0,n=-1/0,r=-1/0;return O(h).forEach(i=>{e=Math.min(e,i.position.x),t=Math.min(t,i.position.y),n=Math.max(n,i.position.x+120),r=Math.max(r,i.position.y+80)}),O(C).forEach(i=>{if(i.type===`Line`){let a=i.position.x,o=i.position.y,s=i.endPosition?.x??i.position.x,c=i.endPosition?.y??i.position.y;e=Math.min(e,a,s),t=Math.min(t,o,c),n=Math.max(n,a,s),r=Math.max(r,o,c)}else if(i.type===`Polyline`)i.points&&i.points.length>0?i.points.forEach(i=>{e=Math.min(e,i.x),t=Math.min(t,i.y),n=Math.max(n,i.x),r=Math.max(r,i.y)}):(e=Math.min(e,i.position.x),t=Math.min(t,i.position.y),n=Math.max(n,i.position.x),r=Math.max(r,i.position.y));else{let a=i.size?.width||(i.type===`Text`?540:i.type===`Image`?200:300),o=i.size?.height||(i.type===`Text`?60:i.type===`Image`?150:200);e=Math.min(e,i.position.x),t=Math.min(t,i.position.y),n=Math.max(n,i.position.x+a),r=Math.max(r,i.position.y+o)}}),e===1/0?null:{x:(e+n)/2,y:(t+r)/2}}function Kt(){if(!O(V))return;let e=Gt();if(!e)return;let t=e.x,n=e.y,r=O(V).getBoundingClientRect(),i=r.width,a=r.height,o=1/0,s=1/0,c=-1/0,l=-1/0;O(h).forEach(e=>{o=Math.min(o,e.position.x),s=Math.min(s,e.position.y),c=Math.max(c,e.position.x+120),l=Math.max(l,e.position.y+80)}),O(C).forEach(e=>{if(e.type===`Line`){let t=e.position.x,n=e.position.y,r=e.endPosition?.x??e.position.x,i=e.endPosition?.y??e.position.y;o=Math.min(o,t,r),s=Math.min(s,n,i),c=Math.max(c,t,r),l=Math.max(l,n,i)}else if(e.type===`Polyline`)e.points&&e.points.length>0?e.points.forEach(e=>{o=Math.min(o,e.x),s=Math.min(s,e.y),c=Math.max(c,e.x),l=Math.max(l,e.y)}):(o=Math.min(o,e.position.x),s=Math.min(s,e.position.y),c=Math.max(c,e.position.x),l=Math.max(l,e.position.y));else{let t=e.size?.width||(e.type===`Text`?540:e.type===`Image`?200:300),n=e.size?.height||(e.type===`Text`?60:e.type===`Image`?150:200);o=Math.min(o,e.position.x),s=Math.min(s,e.position.y),c=Math.max(c,e.position.x+t),l=Math.max(l,e.position.y+n)}});let u=c-o,d=l-s,f=u*1.4,p=d*1.4,m=i/f,g=a/p,_=Math.min(m,g,1);H(U,O(U).zoom=_);let v=i/2,y=a/2,b=t*_,x=n*_;H(U,O(U).x=v-b),H(U,O(U).y=y-x),Y(U,{...O(U)})}function qt(){let e=j().nodes.length>0&&j().nodes.every(e=>O(K).includes(e.id)),t=j().annotations.length===0||j().annotations.every(e=>O(ge).includes(e.id));e&&t&&O(K).length>0?Jt():(Y(K,j().nodes.map(e=>e.id)),Y(ge,j().annotations.map(e=>e.id)),j().nodes.length>0&&(A(j().nodes[0]),T(`nodeSelect`,{node:j().nodes[0]})))}function Jt(){Y(K,[]),Y(ge,[]),A(null),T(`nodeSelect`,{node:null}),T(`annotationSelect`,{annotationId:null})}function Yt(){let e=O(K).length>0,t=O(ge).length>0||P();!e&&!t||(ce(),e&&(O(K).forEach(e=>{j().removeNode(e)}),Y(K,[]),A(null),j(j().nodes=[...j().nodes],!0),T(`nodeSelect`,{node:null})),O(ge).length>0?(O(ge).forEach(e=>{jt(e,!0)}),T(`annotationSelect`,{annotationId:null})):P()&&(jt(P()),T(`annotationSelect`,{annotationId:null})))}function Xt(e){e.preventDefault(),!(e.ctrlKey||e.metaKey)&&(e.target.closest(`.node, .annotation`)||T(`openNodePanel`,{x:e.clientX,y:e.clientY}))}function Zt(e,t){if(!O(V))return null;let n=O(V).querySelector(`[data-node-id="${e}"][data-port-id="${t}"]`);if(n)return n;let r=O(V).querySelectorAll(`[data-node-id="${e}"][data-variadic-ports]`);for(let e of r){let n=e.getAttribute(`data-variadic-ports`);if(n&&n.split(`,`).includes(t))return e}return null}function Qt(e,t,n){let r=j().getElement(e);if(r?.isAnnotation===!0){let n=Zt(e,t);if(n&&O(V)){let e=n.getBoundingClientRect(),t=O(V).getBoundingClientRect(),r=n.querySelector(`.port-dot, .port-pill`);if(r){let e=r.getBoundingClientRect();return{x:(e.left+e.width/2-t.left-O(U).x)/O(U).zoom,y:(e.top+e.height/2-t.top-O(U).y)/O(U).zoom}}return{x:(e.left+e.width/2-t.left-O(U).x)/O(U).zoom,y:(e.top+e.height/2-t.top-O(U).y)/O(U).zoom}}let i=r;if(!i||!i.outputs||!i.outputs.find(e=>e.id===t))return null;let a=i.size?.width??(i.type===`Text`?540:i.type===`Image`?200:300),o=i.size?.height??(i.type===`Text`?60:i.type===`Image`?150:200);return{x:i.position.x+a/2,y:i.position.y+o}}let i=Zt(e,t);if(!i){let r=j().getNode(e);if(!r)return null;let i=n===`output`?r.outputs.findIndex(e=>e.id===t):r.inputs.findIndex(e=>e.id===t);if(i===-1)return null;i*16;let a=r.position.x+40,o=r.position.y+6,s=r.position.y+12+36+6;return{x:a-(n===`input`?r.inputs.length:r.outputs.length)*16/2+8+i*16,y:n===`input`?o:s}}let a=i.getBoundingClientRect(),o=O(V).getBoundingClientRect(),s=i.querySelector(`.port-dot, .port-pill`);if(s){let e=s.getBoundingClientRect();return{x:(e.left+e.width/2-o.left-O(U).x)/O(U).zoom,y:(e.top+e.height/2-o.top-O(U).y)/O(U).zoom}}return{x:(a.left+a.width/2-o.left-O(U).x)/O(U).zoom,y:(a.top+a.height/2-o.top-O(U).y)/O(U).zoom}}function $t(e,t,n,r){r.stopPropagation();let i=j().getElement(e);if(i?.isAnnotation===!0){let a=i;if(!a||!a.outputs)return;let o=a.outputs.find(e=>e.id===t);if(!o)return;if(o.connections.length>0&&(Je={nodeId:e,portId:t,portType:n,connectionIds:o.connections.map(e=>e.id)}),n===`output`&&!O(Z)){let i=Qt(e,t,n);if(i){Y(Z,{nodeId:e,portId:t,portType:n}),Y(Q,i);let a=O(V).getBoundingClientRect();Y(qe,{x:(r.clientX-a.left-O(U).x)/O(U).zoom,y:(r.clientY-a.top-O(U).y)/O(U).zoom})}}return}let a=j().getNode(e);if(!a)return;let o=n===`output`?a.outputs.find(e=>e.id===t):a.inputs.find(e=>e.id===t);if(o){if(o.connections.length>0&&(Je={nodeId:e,portId:t,portType:n,connectionIds:o.connections.map(e=>e.id)}),n===`output`&&!O(Z)){let i=Qt(e,t,n);if(i){Y(Z,{nodeId:e,portId:t,portType:n}),Y(Q,i);let a=O(V).getBoundingClientRect();Y(qe,{x:(r.clientX-a.left-O(U).x)/O(U).zoom,y:(r.clientY-a.top-O(U).y)/O(U).zoom})}}if(n===`input`&&o.connections.length>0&&!O(Z)){let i=Qt(e,t,n);if(i){Y(Z,{nodeId:e,portId:t,portType:n}),Y(Q,i);let a=O(V).getBoundingClientRect();Y(qe,{x:(r.clientX-a.left-O(U).x)/O(U).zoom,y:(r.clientY-a.top-O(U).y)/O(U).zoom})}}}}function en(e,t,n,r){r.stopPropagation();let i=j().getNode(e);if(!i)return;let a=n===`output`?i.outputs.find(e=>e.id===t):i.inputs.find(e=>e.id===t);if(a){if(O(Z)){let t=O(Z);if(t.nodeId!==e&&t.portType!==n){let r=j().getElement(t.nodeId),o=t.portType===`output`?r?.outputs.find(e=>e.id===t.portId):r?.inputs.find(e=>e.id===t.portId);if(o&&a&&t.portType===`output`&&n===`input`){ce();let n=`variadic`in a&&a.variadic===!0,r=[];if(n){let n=e;O(K).forEach(e=>{if(e!==t.nodeId&&e!==n){let t=j().getNode(e);t&&t.outputs.length>0&&r.push({element:t,output:t.outputs[0]})}}),O(ge).forEach(e=>{if(e!==t.nodeId&&e!==n){let t=j().getAnnotation(e);t&&t.outputs&&t.outputs.length>0&&r.push({element:t,output:t.outputs[0]})}})}if(j().connect(o,a),n&&r.length>0){let e=a.name.match(/^(.+)_(\d+)$/);if(e&&i.syncVariadicPorts){let t=e[1],n=parseInt(e[2],10)+1;for(let{output:e}of r){i.syncVariadicPorts();let r=`${t}_${n}`,a=i.inputs.find(e=>e.name===r&&!e.options?.hidden);if(a||=(i.syncVariadicPorts(),i.inputs.find(e=>e.name===r&&!e.options?.hidden)),a)try{j().connect(e,a),n++}catch(e){console.warn(`Failed to connect additional element:`,e)}}}}ne.refresh({connections:!0})}}Y(Z,null),Y(Q,null),Je=null}else if(n===`output`){let i=Qt(e,t,n);if(i){Y(Z,{nodeId:e,portId:t,portType:n}),Y(Q,i);let a=O(V).getBoundingClientRect();Y(qe,{x:(r.clientX-a.left-O(U).x)/O(U).zoom,y:(r.clientY-a.top-O(U).y)/O(U).zoom})}}}}function tn(e){e.preventDefault();let t=(e.deltaY===0?e.deltaX:e.deltaY)*-.005,n=O(U).zoom,r=Math.max(.1,Math.min(2,n+t)),i=Le();i&&(H(U,O(U).x=O(U).x+i.x*(n-r)),H(U,O(U).y=O(U).y+i.y*(n-r))),H(U,O(U).zoom=r),Y(U,{...O(U)})}function nn(e){if(e.touches.length===2){let t=e.touches[0],n=e.touches[1];Qe={x:(t.clientX+n.clientX)/2,y:(t.clientY+n.clientY)/2,touches:e.touches},e.preventDefault()}}function rn(e){if(e.touches.length===2&&Qe){let t=e.touches[0],n=e.touches[1],r=(t.clientX+n.clientX)/2,i=(t.clientY+n.clientY)/2,a=r-Qe.x,o=i-Qe.y;H(U,O(U).x+=a),H(U,O(U).y+=o),Y(U,{...O(U)}),Qe.x=r,Qe.y=i,e.preventDefault()}}function an(e){e.touches.length<2&&(Qe=null)}function on(e){if($e||={x:e.clientX,y:e.clientY,pointers:new Map},$e.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),$e.pointers.size===2){let t=Array.from($e.pointers.values());$e.x=(t[0].x+t[1].x)/2,$e.y=(t[0].y+t[1].y)/2,e.preventDefault()}}function sn(e){if($e&&$e.pointers.has(e.pointerId)&&($e.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),$e.pointers.size===2)){let t=Array.from($e.pointers.values()),n=(t[0].x+t[1].x)/2,r=(t[0].y+t[1].y)/2,i=n-$e.x,a=r-$e.y;H(U,O(U).x+=i),H(U,O(U).y+=a),Y(U,{...O(U)}),$e.x=n,$e.y=r,e.preventDefault()}}function cn(e){$e&&($e.pointers.delete(e.pointerId),$e.pointers.size===0&&($e=null))}function ln(e){let t=document.activeElement,n=t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t?.getAttribute(`contenteditable`)===`true`;if(e.code===`Space`&&!n&&(Ve=!0,e.preventDefault()),(e.key===`Control`||e.key===`Meta`||e.ctrlKey||e.metaKey)&&Y(Xe,!0),!n&&(e.key===`+`||e.key===`=`||e.code===`NumpadAdd`)){e.preventDefault();let t=O(U).zoom,n=Math.min(2,t+.1),r=Le();r&&(H(U,O(U).x=O(U).x+r.x*(t-n)),H(U,O(U).y=O(U).y+r.y*(t-n))),H(U,O(U).zoom=n),Y(U,{...O(U)})}if(!n&&(e.key===`-`||e.key===`_`||e.code===`NumpadSubtract`)){e.preventDefault();let t=O(U).zoom,n=Math.max(.1,t-.1),r=Le();r&&(H(U,O(U).x=O(U).x+r.x*(t-n)),H(U,O(U).y=O(U).y+r.y*(t-n))),H(U,O(U).zoom=n),Y(U,{...O(U)})}if((e.metaKey||e.ctrlKey)&&e.key===`0`&&(e.preventDefault(),Kt()),!n&&!e.metaKey&&!e.ctrlKey&&(e.key===`0`||e.code===`Numpad0`)){e.preventDefault();let t=O(U).zoom;if(t!==1){let e=Le();e&&(H(U,O(U).x=O(U).x+e.x*(t-1)),H(U,O(U).y=O(U).y+e.y*(t-1))),H(U,O(U).zoom=1),Y(U,{...O(U)})}}if(e.key===`h`||e.key===`H`){let t=e.target;t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`&&(e.preventDefault(),Kt())}if(e.key===`Escape`){let t=e.target;t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`&&(O(ht)?Y(ht,null):(P()||O(ge).length>0)&&(e.preventDefault(),P(null),Y(ge,[]),T(`annotationSelect`,{annotationId:null})))}if(e.key===`Delete`||e.key===`Backspace`){let t=e.target;t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`&&(O(K).length>0||O(ge).length>0||P())&&(e.preventDefault(),Yt())}if((e.metaKey||e.ctrlKey)&&e.key===`x`){let t=e.target;t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`&&(e.preventDefault(),Mt())}if((e.metaKey||e.ctrlKey)&&e.key===`c`){let t=e.target;t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`&&(e.preventDefault(),Nt())}if((e.metaKey||e.ctrlKey)&&e.key===`v`){let t=e.target;t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`&&(e.preventDefault(),Pt())}if((e.metaKey||e.ctrlKey)&&e.key===`a`){let t=e.target;t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`&&(e.preventDefault(),qt())}if((e.metaKey||e.ctrlKey)&&e.key===`d`&&(e.preventDefault(),O(K).length>0)){ce();let e=O(K).map(e=>j().getNode(e)).filter(Boolean),t=[];e.forEach(e=>{let n=j().addNode(e.type,{x:e.position.x+50,y:e.position.y+50});n.code=e.code,n.id=j().generateUniqueNodeId(e.id),n.comment=e.comment,n.bypass=e.bypass,O(ye)&&j().reparentElement(n,O(ye)),t.push(n)}),j(j().nodes=[...j().nodes],!0),t.length>0&&(Y(K,t.map(e=>e.id)),A(t[0]),T(`nodeSelect`,{node:t[0]}))}let r=e.target;r.tagName!==`INPUT`&&r.tagName!==`TEXTAREA`&&((e.key===`Enter`||e.key===`i`)&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&A()&&A().isNetwork()&&(e.preventDefault(),xe(A())),(e.key===`o`||e.key===`u`)&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&O(ye)&&(e.preventDefault(),Se()),(e.metaKey||e.ctrlKey)&&!e.shiftKey&&e.key===`g`&&O(K).length>0&&(e.preventDefault(),ze()),(e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key===`G`&&O(K).length===1&&j().getNode(O(K)[0])?.isNetwork()&&(e.preventDefault(),Be()),e.key===`/`&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&(e.preventDefault(),ke()),e.key===`c`&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&A()&&(e.preventDefault(),A().setCook(!A().cook),j(j().nodes=[...j().nodes],!0)),e.key===`b`&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&A()&&(e.preventDefault(),A().setBypass(!A().bypass),j(j().nodes=[...j().nodes],!0)))}function un(e){e.code===`Space`&&(Ve=!1),(e.key===`Control`||e.key===`Meta`||!e.ctrlKey&&!e.metaKey)&&(Y(Xe,!1),Y(Ye,null))}he(()=>(j().nodes.length>0&&j(j().nodes=[...j().nodes],!0),window.addEventListener(`keydown`,ln),window.addEventListener(`keyup`,un),()=>{window.removeEventListener(`keydown`,ln),window.removeEventListener(`keyup`,un)})),e(()=>(k(j()),O(re),O(ae),O(R)),()=>{let e=j().scheduler;e!==O(re)&&(O(ae)?.(),Y(re,e),Y(ae,e.subscribe(()=>{Y(R,O(R)+1)})))}),e(()=>(k(F()),O(fe)),()=>{F()&&(!O(fe)||O(fe).x!==F().x||O(fe).y!==F().y||O(fe).zoom!==F().zoom)&&(Y(U,{...F()}),Y(fe,{...F()}))}),e(()=>(k(F()),O(W),O(U),O(fe)),()=>{F()!==void 0&&(O(W).x!==O(U).x||O(W).y!==O(U).y||O(W).zoom!==O(U).zoom)&&(O(fe)&&O(fe).x===O(U).x&&O(fe).y===O(U).y&&O(fe).zoom===O(U).zoom?Y(W,{...O(U)}):(Y(W,{...O(U)}),T(`transformChange`,{transform:{...O(U)}})))}),e(()=>(k(A()),O(K)),()=>{A()&&A().id&&!O(K).includes(A().id)&&Y(K,[A().id])}),e(()=>(k(A()),O(K)),()=>{!A()&&O(K).length>0&&Y(K,[])}),e(()=>(O(K),k(j())),()=>{_e(O(K),j())}),e(()=>O(ye),()=>{Y(p,be(O(ye)))}),e(()=>(k(j()),O(ye)),()=>{Y(h,Pe(j().nodes,O(ye)))}),e(()=>(k(j()),O(ye)),()=>{Y(C,Pe(j().annotations,O(ye)))}),e(()=>(O(h),O(C)),()=>{O(h),O(C),Y(Ie,!1)}),e(()=>(O(R),O(h)),()=>{Y(g,(O(R),O(h)))}),e(()=>O(g),()=>{Y(_,O(g).filter(e=>e&&e.inputs&&e.outputs).map(e=>({id:e.id,inputs:e.inputs.length,outputs:e.outputs.length})))}),e(()=>(s(),O(g)),()=>{Y(b,et(s(),O(g)))}),e(()=>(O(R),O(b),O(_),O(C),O(g),k(j())),()=>{O(R),O(b),O(_),O(C);let e=new Set(O(g).map(e=>e.id)),t=new Set(O(C).map(e=>e.id)),n=new Set([...e,...t]);Y(tt,j().connections.filter((e,t,r)=>r.findIndex(t=>t.id===e.id)===t&&n.has(e.from.nodeId)&&n.has(e.to.nodeId)))}),e(()=>(O(tt),O(K),O(Ye)),()=>{Y(x,[...O(tt).filter(e=>!nt(e,O(K),O(Ye)?.connectionId)),...O(tt).filter(e=>nt(e,O(K),O(Ye)?.connectionId))])}),ie();var dn={addNode:Ut,centerOnNodes:Kt,selectAll:qt,deselectAll:Jt,deleteSelected:Yt};le();var fn=Bm();let pn;var mn=q(fn),hn=q(mn),gn=e=>{var t=jm();Ee(t),pe(t,e=>Y(De,e),()=>O(De)),te(t,()=>O(Te),e=>Y(Te,e)),f(`keydown`,t,Ne),f(`blur`,t,Ae),E(e,t)},_n=e=>{var t=Pm(),n=B(t);v(n,1,()=>O(p),c,(e,t,n)=>{var r=Nm(),a=B(r),o=e=>{var t=Mm();E(e,t)};m(a,e=>{n>0&&e(o)});var s=G(a,2);let c;var l=M(s,!0);J(()=>{c=i(s,1,`path-segment svelte-p2f6pl`,null,c,{current:n===O(p).length-1}),X(l,(O(t),y(()=>O(t).label)))}),f(`click`,s,()=>Ce(O(t).node)),E(e,r)});var r=G(n,2);f(`click`,r,ke),E(e,t)};m(hn,e=>{O(we)?e(gn):e(_n,-1)}),w(mn);var vn=G(mn,2),yn=e=>{let t=L(()=>(O(We),O(Ge),y(()=>({x:Math.min(O(We).x,O(Ge).x),y:Math.min(O(We).y,O(Ge).y),width:Math.abs(O(Ge).x-O(We).x),height:Math.abs(O(Ge).y-O(We).y)}))));var n=Fm();J(()=>o(n,`left: ${k(O(t)),y(()=>O(t).x)??``}px; top: ${k(O(t)),y(()=>O(t).y)??``}px; width: ${k(O(t)),y(()=>O(t).width)??``}px; height: ${k(O(t)),y(()=>O(t).height)??``}px;`)),E(e,n)};m(vn,e=>{O(He)&&O(Ue)&&O(We)&&O(Ge)&&e(yn)});var bn=G(vn,4),xn=q(bn);v(xn,1,()=>O(x),e=>e.id,(e,t)=>{L(()=>(O(b),O(t),y(()=>O(b).find(e=>e.id===O(t).from.nodeId)))),L(()=>(O(b),O(t),y(()=>O(b).find(e=>e.id===O(t).to.nodeId))));let n=L(()=>(O(t),y(()=>Qt(O(t).from.nodeId,O(t).from.portId,`output`)))),r=L(()=>(O(t),y(()=>Qt(O(t).to.nodeId,O(t).to.portId,`input`))));var a=u(),s=B(a),c=e=>{let a=L(()=>(k(j()),O(t),y(()=>j().getElement(O(t).from.nodeId)))),s=L(()=>(k(j()),O(t),y(()=>j().getElement(O(t).to.nodeId)))),c=L(()=>(k(O(a)),y(()=>O(a)&&!O(a)?.isAnnotation?O(a):null))),l=L(()=>(k(O(s)),y(()=>O(s)&&!O(s)?.isAnnotation?O(s):null))),u=L(()=>(k(O(a)),y(()=>O(a)?.isAnnotation?O(a):null))),d=L(()=>(k(O(c)),O(t),k(O(u)),y(()=>O(c)?.outputs.find(e=>e.id===O(t).from.portId)||O(u)?.outputs?.find(e=>e.id===O(t).from.portId)))),f=L(()=>(k(O(l)),O(t),y(()=>!O(l)?.isInputActive||O(l).isInputActive(O(t).to.portId)))),p=L(()=>(k(O(f)),k(O(d)),k(rp),k(np),y(()=>O(f)?O(d)?rp(O(d)):`#888`:np.inactive))),m=L(()=>(O(t),O(K),O(Ye),y(()=>nt(O(t),O(K),O(Ye)?.connectionId))));L(()=>(k(O(n)),k(O(r)),y(()=>(O(n).y+O(r).y)/2)));let h=L(()=>(k(O(r)),k(O(n)),y(()=>Math.abs(O(r).y-O(n).y)*.5))),g=L(()=>(O(t),y(()=>O(t).type===`trigger`))),_=L(()=>(O(t),y(()=>rt(O(t)))));var v=Im(),b=B(v),x=G(b);let S;J(()=>{N(b,`d`,`M ${k(O(n)),y(()=>O(n).x)??``} ${k(O(n)),y(()=>O(n).y)??``} C ${k(O(n)),y(()=>O(n).x)??``} ${k(O(n)),k(O(h)),y(()=>O(n).y+O(h))??``} ${k(O(r)),y(()=>O(r).x)??``} ${k(O(r)),k(O(h)),y(()=>O(r).y-O(h))??``} ${k(O(r)),y(()=>O(r).x)??``} ${k(O(r)),y(()=>O(r).y)??``}`),o(b,`cursor: ${O(Ye),O(t),O(Xe),y(()=>O(Ye)?.connectionId===O(t).id&&O(Xe)?`pointer`:`default`)??``};`),N(x,`d`,`M ${k(O(n)),y(()=>O(n).x)??``} ${k(O(n)),y(()=>O(n).y)??``} C ${k(O(n)),y(()=>O(n).x)??``} ${k(O(n)),k(O(h)),y(()=>O(n).y+O(h))??``} ${k(O(r)),y(()=>O(r).x)??``} ${k(O(r)),k(O(h)),y(()=>O(r).y-O(h))??``} ${k(O(r)),y(()=>O(r).x)??``} ${k(O(r)),y(()=>O(r).y)??``}`),N(x,`stroke`,O(p)),N(x,`stroke-opacity`,O(m)?1:.5),N(x,`stroke-dasharray`,O(_)?`8 6`:O(g)?`3 3`:`none`),S=i(x,0,`connection svelte-p2f6pl`,null,S,{"trigger-connection":O(g),"processing-connection":O(_),inactive:!O(f)})}),E(e,v)};m(s,e=>{O(n)&&O(r)&&e(c)}),E(e,a)});var Sn=G(xn),Cn=e=>{let t=L(()=>(O(Ye),y(()=>O(Ye).position)));var n=Lm();J(()=>N(n,`transform`,`translate(${k(O(t)),y(()=>O(t).x)??``}, ${k(O(t)),y(()=>O(t).y)??``})`)),E(e,n)};m(Sn,e=>{O(Ye)&&e(Cn)});var wn=G(Sn),Tn=e=>{let t=L(()=>O(Z)),n=L(()=>(k(j()),k(O(t)),y(()=>j().getElement(O(t).nodeId)))),r=L(()=>(k(O(n)),y(()=>O(n)&&!O(n)?.isAnnotation?O(n):null))),i=L(()=>(k(O(n)),y(()=>O(n)?.isAnnotation?O(n):null))),a=L(()=>(k(O(t)),k(O(r)),k(O(i)),y(()=>O(t).portType===`output`?O(r)?.outputs.find(e=>e.id===O(t).portId)||O(i)?.outputs?.find(e=>e.id===O(t).portId):O(r)?.inputs.find(e=>e.id===O(t).portId)))),o=L(()=>(k(O(a)),k(rp),y(()=>O(a)?rp(O(a)):`#888`))),s=L(()=>(O(qe),O(Q),y(()=>Math.abs(O(qe).y-O(Q).y)*.5))),c=L(()=>(k(O(t)),k(O(r)),y(()=>O(t).portType===`output`&&(O(r)?O(r).outputs.find(e=>e.id===O(t).portId)?.portType===`trigger`:!1))));var l=Rm();J(()=>{N(l,`d`,`M ${O(Q),y(()=>O(Q).x)??``} ${O(Q),y(()=>O(Q).y)??``} C ${O(Q),y(()=>O(Q).x)??``} ${O(Q),k(O(s)),y(()=>O(Q).y+O(s))??``} ${O(qe),y(()=>O(qe).x)??``} ${O(qe),k(O(s)),y(()=>O(qe).y-O(s))??``} ${O(qe),y(()=>O(qe).x)??``} ${O(qe),y(()=>O(qe).y)??``}`),N(l,`stroke`,O(o)),N(l,`stroke-dasharray`,O(c)?`3 3`:`4 4`)}),E(e,l)};m(wn,e=>{O(Z)&&O(Q)&&e(Tn)}),w(bn);var En=G(bn,2);v(En,5,()=>O(C),e=>e.id,(e,n)=>{let r=L(()=>(O(ht),O(n),y(()=>O(ht)===O(n).id))),i=L(()=>(O(ge),O(n),k(P()),y(()=>O(ge).includes(O(n).id)||P()===O(n).id))),a=L(()=>(O(gt),O(n),y(()=>O(gt)?.annotationId===O(n).id))),s=L(()=>(k(Sp),O(n),y(()=>Sp.get(O(n).type))));var c=u(),l=B(c),d=e=>{var o=u(),c=B(o);t(c,()=>O(s),(e,t)=>{t(e,{get annotation(){return O(n)},get isSelected(){return O(i)},get isEditing(){return O(r)},get isDragging(){return O(a)},$$events:{click:e=>wt(e.detail.id,e.detail.event),dblclick:e=>At(e.detail.id,e.detail.event),mousedown:e=>{let{id:t,event:r,width:i,height:a}=e.detail;O(n)instanceof Zc?Et(t,r,i||540,a||60):Tt(t,r)},mousemove:e=>{let{id:t,event:n,width:r,height:i}=e.detail;Ot(t,n,r||540,i||60)},keydown:e=>Dt(e.detail.id,e.detail.event),finishEdit:Rt,delete:e=>jt(e.detail.id),input:e=>{let{id:t,event:r}=e.detail;O(n)instanceof Zc?It(t,r):Lt(t,r)},portMouseDown:e=>$t(e.detail.nodeId,e.detail.portId,e.detail.portType,e.detail.event),resizeStart:e=>ct(e.detail.id,e.detail.handle,e.detail.event)}})}),E(e,o)},f=e=>{var t=zm(),r=M(t);J(()=>{o(t,`position: absolute; left: ${O(n),y(()=>O(n).position.x)??``}px; top: ${O(n),y(()=>O(n).position.y)??``}px; background: var(--status-error-strong); color: var(--text-on-accent); padding: 8px; border-radius: 4px; font-size: 12px;`),X(r,`Unknown type: ${O(n),y(()=>O(n).type)??``}`)}),E(e,t)};m(l,e=>{O(s)?e(d):e(f,-1)}),E(e,c)}),w(En);var Dn=G(En,2);v(Dn,5,()=>O(g),e=>e.id,(e,t)=>{{let n=L(()=>(O(K),O(t),y(()=>O(K).includes(O(t).id))));cm(e,{get node(){return O(t)},get selected(){return O(n)},get canvasTransform(){return O(U)},$$events:{portClick:e=>en(e.detail.nodeId,e.detail.portId,e.detail.portType,e.detail.event),portMouseDown:e=>$t(e.detail.nodeId,e.detail.portId,e.detail.portType,e.detail.event),nodeMouseDown:e=>lt(e.detail.nodeId,e.detail.event),nodeClick:e=>dt(O(t).id,e.detail),edit:ut,diveInto:e=>xe(e.detail.node),bypassToggle:e=>ft(e.detail.nodeId,e.detail.event),cookToggle:e=>pt(e.detail.nodeId,e.detail.event),disconnect:e=>mt(e.detail.connectionId)}})}}),w(Dn),w(fn),pe(fn,e=>Y(V,e),()=>O(V)),J(()=>{pn=i(fn,1,`canvas svelte-p2f6pl`,null,pn,{"select-tool":D()===`select`,"hand-tool":D()===`hand`}),o(bn,`transform: translate(${O(U),y(()=>O(U).x)??``}px, ${O(U),y(()=>O(U).y)??``}px) scale(${O(U),y(()=>O(U).zoom)??``})`),o(En,`transform: translate(${O(U),y(()=>O(U).x)??``}px, ${O(U),y(()=>O(U).y)??``}px) scale(${O(U),y(()=>O(U).zoom)??``})`),o(Dn,`transform: translate(${O(U),y(()=>O(U).x)??``}px, ${O(U),y(()=>O(U).y)??``}px) scale(${O(U),y(()=>O(U).zoom)??``})`)}),f(`mousedown`,fn,it),f(`mousemove`,fn,at),f(`mouseup`,fn,st),f(`click`,fn,St),f(`dblclick`,fn,Vt),f(`wheel`,fn,tn),f(`contextmenu`,fn,Xt),f(`touchstart`,fn,nn),f(`touchmove`,fn,rn),f(`touchend`,fn,an),f(`touchcancel`,fn,an),f(`pointerdown`,fn,on),f(`pointermove`,fn,sn),f(`pointerup`,fn,cn),f(`pointercancel`,fn,cn),f(`dragover`,fn,zt),f(`drop`,fn,Bt),f(`keydown`,fn,bt),f(`keyup`,fn,xt),E(n,fn),ue(a,`addNode`,Ut),ue(a,`centerOnNodes`,Kt),ue(a,`selectAll`,qt),ue(a,`deselectAll`,Jt),ue(a,`deleteSelected`,Yt);var On=S(dn);return d(),On}var Hm=T(`<div class="empty-state svelte-qbjsq3">Loading graph...</div>`),Um=T(`<div class="panel-wrapper svelte-qbjsq3" data-panel-type="graph" data-window-id="graph"><!></div>`);function Wm(t,n){r(n,!1);let i=()=>oe(la,`$sharedContextStore`,a),[a,o]=se();z(n,`panelId`,8),z(n,`panelParams`,8);let s=z(n,`panelApi`,8);z(n,`containerApi`,8);let c=z(n,`graph`,12,void 0),l=z(n,`selectedNode`,12,null),u=z(n,`selectedAnnotation`,12,null),d=z(n,`activeTool`,12,`select`),f=z(n,`presentationMode`,12,!1),p=z(n,`onRecordHistory`,12,void 0),h=z(n,`onNodeSelect`,12,void 0),g=z(n,`onAnnotationSelect`,12,void 0),_=z(n,`onToolChange`,12,void 0),v=z(n,`onOpenNodePanel`,12,void 0);ve();let y=I(null),b=I(),x=I({x:0,y:0,zoom:1});function C(e){h()&&h()(e.detail.node)}function T(e){g()&&g()(e.detail.annotationId)}function D(e){Y(x,e.detail.transform)}function k(e){v()&&v()(e.detail)}function ee(e){}function te(e){O(y)&&O(y).addNode&&O(y).addNode(e)}function A(){O(y)&&O(y).centerOnNodes&&O(y).centerOnNodes()}function j(){O(y)&&O(y).selectAll&&O(y).selectAll()}function M(){O(y)&&O(y).deselectAll&&O(y).deselectAll()}function N(){O(y)&&O(y).deleteSelected&&O(y).deleteSelected()}he(()=>{if(O(b)?.addEventListener(`addNode`,e=>{te(e.detail)}),O(b)?.addEventListener(`centerOnNodes`,()=>{A()}),O(b)?.addEventListener(`selectAll`,()=>{j()}),O(b)?.addEventListener(`deselectAll`,()=>{M()}),O(b)?.addEventListener(`deleteSelected`,()=>{N()}),s()){let e=s().onDidDimensionsChange?.(e=>{e.width,e.height});return()=>{e?.dispose?.()}}}),e(()=>i(),()=>{i()&&(c(i().graph),l(i().selectedNode),u(i().selectedAnnotation),d(i().activeTool||`select`),f(i().presentationMode||!1),p(i().onRecordHistory),h(i().onNodeSelect),g(i().onAnnotationSelect),_(i().onToolChange),v(i().onOpenNodePanel))}),ie();var P={addNode:te,centerOnNodes:A,selectAll:j,deselectAll:M,deleteSelected:N};le();var F=Um(),ne=q(F),re=e=>{pe(Vm(e,{get graph(){return c()},get activeTool(){return d()},get selectedNode(){return l()},get selectedAnnotation(){return u()},get transform(){return O(x)},get onRecordHistory(){return p()},$$events:{nodeSelect:C,annotationSelect:T,transformChange:D,openNodePanel:k,nodeEdit:ee},$$legacy:!0}),e=>Y(y,e),()=>O(y))},ae=e=>{var t=Hm();E(e,t)};m(ne,e=>{c()?e(re):e(ae,-1)}),w(F),pe(F,e=>Y(b,e),()=>O(b)),E(t,F),ue(n,`addNode`,te),ue(n,`centerOnNodes`,A),ue(n,`selectAll`,j),ue(n,`deselectAll`,M),ue(n,`deleteSelected`,N);var L=S(P);return o(),L}function Gm(e){return Number.isInteger(e)}function Km(e){if(e.type)return e.type;let t=e.value,n=e.params,r=n?.integer===!0||n?.step===1&&typeof t==`number`&&Gm(t);if(typeof t==`number`)return n?.min!==void 0&&n?.max!==void 0?r?`int`:`slider`:r?`int`:`number`;if(typeof t==`string`)return/^#([0-9A-F]{3}|[0-9A-F]{6})$/i.test(t)?`color`:n?.accept===`image/*`||t.match(/\.(jpg|jpeg|png|gif|webp|svg)$/i)||t.startsWith(`data:image/`)?`image`:n?.options&&n.options.length>0?`select`:t.includes(`
|
|
217
|
+
`)||t.length>100?`textarea`:`text`;if(typeof t==`boolean`)return`boolean`;if(Array.isArray(t)){if(t.length>0&&typeof t[0]==`object`&&t[0]!==null&&`position`in t[0]&&`color`in t[0])return`colorramp`;if(t.length===2&&n?.min!==void 0&&n?.max!==void 0&&typeof n.min==`number`&&typeof n.max==`number`)return`range`;let e=t.length>0&&t.every(e=>typeof e==`number`&&Gm(e)),r=e&&t.every(e=>e>=1&&e<=8192)&&n?.min!==void 0&&n?.max!==void 0,i=n?.integer===!0||n?.step===1&&e||r;return t.length===2?i?`vec2i`:`vec2`:t.length===3?i?`vec3i`:`vec3`:`vector`}return typeof t==`function`?`button`:`text`}var qm=1,Jm=1e5;function Ym(e){return typeof e==`object`&&e?e:null}function Xm(e){return Array.isArray(e)?e.every(Number.isFinite)?e:null:!ArrayBuffer.isView(e)||e instanceof DataView?null:e}function Zm(e,t,n){let r=e[n*t],i=e[n*t+1];return Number.isFinite(r)&&Number.isFinite(i)?[r,i]:null}function Qm(e,t,n,r,i){let a=1-i,o=a*a*a,s=3*a*a*i,c=3*a*i*i,l=i*i*i;return[o*e[0]+s*t[0]+c*n[0]+l*r[0],o*e[1]+s*t[1]+c*n[1]+l*r[1]]}function $m(e,t=1200){if(!Number.isSafeInteger(t)||t<1||t>Jm)return null;let n=Ym(e),r=n?.pointCount,i=n?.primitiveCount;if(n?.kind!==`geometry`||typeof r!=`number`||!Number.isSafeInteger(r)||r<0||typeof i!=`number`||!Number.isSafeInteger(i)||i<0)return null;let a=Ym(Ym(n.point)?.P),o=a?.size,s=Xm(a?.data);if(o!==2&&o!==3||!s||s.length!==r*o)return null;let c=null,l=1/0,u=1/0,d=-1/0,f=-1/0;for(let e=0;e<r;e+=1){let t=Zm(s,o,e);if(!t)return null;let[n,r]=t;n<l&&(l=n),r<u&&(u=r),n>d&&(d=n),r>f&&(f=r)}r>0&&(c={min:[l,u],max:[d,f]});let p=e=>Zm(s,o,e),m=Ym(n.topology),h=Xm(m?.vertexPoints),g=Xm(m?.offsets),_=Xm(m?.kinds),v=Xm(m?.closed);if(!h||!g||!_||!v||g.length!==i+1||_.length!==i||v.length!==i||g[0]!==0||g[g.length-1]!==h.length)return null;let y=new Uint8Array(r);for(let e=0;e<h.length;e+=1){let t=h[e];if(!Number.isSafeInteger(t)||t<0||t>=r)return null;y[t]=1}let b=[],x=Math.max(1,Math.floor(t/Math.max(i,1)));for(let e=0;e<i&&b.length<t;e+=1){let t=g[e],n=g[e+1],r=_[e],i=v[e];if(!Number.isSafeInteger(t)||!Number.isSafeInteger(n)||t<0||n<t||n>h.length||!Number.isSafeInteger(r)||r<0||r>3||i!==0&&i!==1)return null;let a=n-t,o=e=>p(h[t+e]),s;if(r===qm){let e=i?a/3:(a-1)/3;if(!Number.isSafeInteger(e)||e<1)return null;s=[];for(let t=0;t<e;t+=1){let n=t*3,r=[o(n),o(n+1),o(n+2),o((n+3)%a)];if(r.some(e=>!e))return null;let i=Math.max(2,Math.min(16,Math.floor(x/Math.max(e,1))));for(let e=t===0?0:1;e<=i;e+=1)s.push(Qm(r[0],r[1],r[2],r[3],e/i))}}else{let e=Math.min(a,x);s=[];for(let t=0;t<e;t+=1){let n=o(Math.floor(t*a/e));if(!n)return null;s.push(n)}i===1&&s.length>1&&s.push(s[0])}s.length>0&&b.push(s)}let S=[],C=Math.max(0,Math.floor(t));if(C>0){let e=r-y.reduce((e,t)=>e+t,0),t=Math.max(1,e/C),n=0,i=0;for(let e=0;e<r&&S.length<C;e+=1)if(!y[e]){if(n>=i){let n=p(e);n&&S.push(n),i+=t}n+=1}}return{bounds:c,points:S,paths:b,summary:`${r} ${r===1?`point`:`points`} · ${i} ${i===1?`primitive`:`primitives`}`}}var eh=/\.(png|jpe?g|webp|gif|tiff?|avif|svg|npy)$/i,th=1200;function nh(e){if(typeof e==`number`)return Number.isInteger(e)?`int`:`float`;if(typeof e==`boolean`)return`bool`;if(typeof e==`string`)return eh.test(e)?`image`:`string`;if(Ml(e))return`image`;if(typeof e==`object`&&e&&e.kind===`geometry`)return`geometry`;if(Array.isArray(e)){if(e.every(e=>typeof e==`number`)){if(e.length===2)return`vec2`;if(e.length===3)return`vec3`;if(e.length===4)return`vec4`;if(e.length===9)return`mat3`;if(e.length===16)return`mat4`}return`array`}return typeof e==`object`&&e?`object`:`any`}function rh(e,t={}){if(/^(https?:|data:|blob:)/.test(e))return e;let n=e.replace(/^\.?\//,``),r=n.split(`/`).map(encodeURIComponent).join(`/`),i=new URLSearchParams;t.raw||/\.svg$/i.test(n)?i.set(`raw`,`1`):t.width&&i.set(`w`,String(t.width)),t.version&&i.set(`v`,String(t.version));let a=i.toString();return`/api/media/${r}${a?`?${a}`:``}`}function ih(e,t=0){let n=Number(e);return Number.isFinite(n)?n:t}function ah(e,t=0){return Math.max(0,Math.min(1,ih(e,t)))}function oh(e){if(Array.isArray(e))return[ah(e[0]),ah(e[1]),ah(e[2]),ah(e[3],1)];if(e&&typeof e==`object`){let t=e;return[ah(t.r),ah(t.g),ah(t.b),ah(t.a,1)]}if(typeof e==`string`){let t=/^#([\da-f]{6})([\da-f]{2})?$/i.exec(e.trim());if(t){let e=t[1];return[parseInt(e.slice(0,2),16)/255,parseInt(e.slice(2,4),16)/255,parseInt(e.slice(4,6),16)/255,t[2]?parseInt(t[2],16)/255:1]}}return[0,0,0,1]}function sh(e){let[t,n,r,i]=oh(e);return`rgba(${Math.round(t*255)}, ${Math.round(n*255)}, ${Math.round(r*255)}, ${Number(i.toFixed(3))})`}function ch(e){let[t,n,r]=oh(e),i=e=>Math.round(e*255).toString(16).padStart(2,`0`);return`#${i(t)}${i(n)}${i(r)}`}function lh(e,t){if(e===void 0)return`—`;if(e===null)return`null`;let n=Nl(e);if(t===`image`&&n){let[e,t]=n.size;return`${e||`?`}×${t||`?`} · ${n.channels} · ${n.depth} · ${n.space}`}if(t===`texture`&&typeof e==`object`){let t=e,n=t.size??[t.width,t.height];return`${Array.isArray(n)?`${n[0]??`?`}×${n[1]??`?`}`:`?×?`} · ${t.format??(t.float?`float`:`GPU texture`)} · browser session`}if([`geometry`,`points`,`lines`,`polyline`,`mesh`,`rects`].includes(t))return ph(e,t).countLabel;if(Array.isArray(e))return`${e.length} ${e.length===1?`item`:`items`}`;if(typeof e==`object`){let t=Object.keys(e);return`{${t.slice(0,4).join(`, `)}${t.length>4?`, …`:``}}`}let r=String(e);return r.length>100?`${r.slice(0,97)}…`:r}function uh(e){if(!Array.isArray(e)||e.length<2)return null;let t=Number(e[0]),n=Number(e[1]);return Number.isFinite(t)&&Number.isFinite(n)?[t,n]:null}function dh(e){return Array.isArray(e)?e.slice(0,th).map(uh).filter(e=>!!e):[]}function fh(e,t){return t&&e.length>1?[...e,e[0]]:e}function ph(e,t){let n={countLabel:`No geometry`,bounds:null,points:[],paths:[],rects:[]},r=e;if(t===`geometry`){let t=$m(e,th);return t?(n.points=t.points,n.paths=t.paths,n.bounds=t.bounds,n.countLabel=t.summary,n):n}if(t===`points`)n.points=dh(Array.isArray(r)?r:r?.points),n.countLabel=`${n.points.length} ${n.points.length===1?`point`:`points`}`;else if(t===`lines`){let e=Array.isArray(r)?r:r?.lines;Array.isArray(e)&&(n.paths=e.slice(0,th).map(e=>dh(e)).filter(e=>e.length>=2)),n.countLabel=`${n.paths.length} ${n.paths.length===1?`segment`:`segments`}`}else if(t===`polyline`){n.paths=(Array.isArray(r)&&uh(r[0])?[{points:r}]:Array.isArray(r)?r:[r]).slice(0,th).map(e=>fh(dh(e?.points??e),!!e?.closed)).filter(e=>e.length>0);let e=n.paths.reduce((e,t)=>e+t.length,0);n.countLabel=`${n.paths.length} ${n.paths.length===1?`chain`:`chains`} · ${e} vertices`}else if(t===`mesh`){let e=Array.isArray(r?.positions)?r.positions:[],t=[];for(let n=0;n+1<e.length&&t.length<th;n+=3){let r=uh([e[n],e[n+1]]);r&&t.push(r)}let i=Array.isArray(r?.indices)?r.indices:[];for(let e=0;e+2<i.length&&n.paths.length<th;e+=3){let r=[t[i[e]],t[i[e+1]],t[i[e+2]]];r.every(Boolean)&&n.paths.push([...r,r[0]])}n.points=t,n.countLabel=`${Math.floor(e.length/3)} vertices · ${Math.floor(i.length/3)} ${i.length===3?`triangle`:`triangles`}`}else if(t===`rects`){let e=Array.isArray(r)?r:r?.rects;Array.isArray(e)&&(n.rects=e.slice(0,th).map(e=>({x:ih(Array.isArray(e)?e[0]:e?.x),y:ih(Array.isArray(e)?e[1]:e?.y),width:ih(Array.isArray(e)?e[2]:e?.width),height:ih(Array.isArray(e)?e[3]:e?.height)}))),n.countLabel=`${n.rects.length} ${n.rects.length===1?`rect`:`rects`}`}let i=[...n.points,...n.paths.flat(),...n.rects.flatMap(e=>[[e.x,e.y],[e.x+e.width,e.y+e.height]])];return i.length>0&&(n.bounds={min:[Math.min(...i.map(e=>e[0])),Math.min(...i.map(e=>e[1]))],max:[Math.max(...i.map(e=>e[0])),Math.max(...i.map(e=>e[1]))]}),n}var mh=D(`<rect class="svelte-k5ygks"></rect>`),hh=D(`<polyline class="svelte-k5ygks"></polyline>`),gh=D(`<circle class="svelte-k5ygks"></circle>`),_h=D(`<svg role="img" preserveAspectRatio="xMidYMid meet" class="svelte-k5ygks"><!><!><!></svg>`),vh=T(`<div class="empty svelte-k5ygks">No previewable geometry</div>`),yh=T(`<span> </span>`),bh=T(`<div class="geometry-preview svelte-k5ygks"><!> <div class="meta svelte-k5ygks"><span> </span> <!></div></div>`);function xh(t,n){r(n,!1);let i=I(),a=I(),o=I(),s=I(),l=I(),u=I(),d=I(),f=I(),p=z(n,`value`,8),h=z(n,`type`,8);e(()=>(k(p()),k(h())),()=>{Y(i,ph(p(),h()))}),e(()=>O(i),()=>{Y(a,O(i).bounds?.min[0]??0)}),e(()=>O(i),()=>{Y(o,O(i).bounds?.min[1]??0)}),e(()=>(O(i),O(a)),()=>{Y(s,Math.max(O(i).bounds?O(i).bounds.max[0]-O(a):1,1e-6))}),e(()=>(O(i),O(o)),()=>{Y(l,Math.max(O(i).bounds?O(i).bounds.max[1]-O(o):1,1e-6))}),e(()=>(O(s),O(l)),()=>{Y(u,Math.max(O(s),O(l))*.04)}),e(()=>(O(a),O(u),O(o),O(s),O(l)),()=>{Y(d,`${O(a)-O(u)} ${O(o)-O(u)} ${O(s)+O(u)*2} ${O(l)+O(u)*2}`)}),e(()=>(O(s),O(l)),()=>{Y(f,Math.max(O(s),O(l))*.008)}),ie(),le();var g=bh(),_=q(g),b=e=>{var t=_h(),n=q(t);v(n,1,()=>(O(i),y(()=>O(i).rects)),c,(e,t)=>{var n=mh();J(()=>{N(n,`x`,(O(t),y(()=>O(t).x))),N(n,`y`,(O(t),y(()=>O(t).y))),N(n,`width`,(O(t),y(()=>O(t).width))),N(n,`height`,(O(t),y(()=>O(t).height)))}),E(e,n)});var r=G(n);v(r,1,()=>(O(i),y(()=>O(i).paths)),c,(e,t)=>{var n=hh();J(e=>N(n,`points`,e),[()=>(O(t),y(()=>O(t).map(e=>e.join(`,`)).join(` `)))]),E(e,n)});var a=G(r);v(a,1,()=>(O(i),y(()=>O(i).points)),c,(e,t)=>{var n=gh();J(()=>{N(n,`cx`,(O(t),y(()=>O(t)[0]))),N(n,`cy`,(O(t),y(()=>O(t)[1]))),N(n,`r`,O(f))}),E(e,n)}),w(t),J(()=>{N(t,`viewBox`,O(d)),N(t,`aria-label`,`${h()??``} preview`)}),E(e,t)},x=e=>{var t=vh();E(e,t)};m(_,e=>{O(i),y(()=>O(i).bounds)?e(b):e(x,-1)});var C=G(_,2),T=q(C),D=M(T,!0),ee=G(T,2),te=e=>{var t=yh(),n=M(t);J((e,t)=>X(n,`${e??``}×${t??``}`),[()=>(O(s),y(()=>Number(O(s).toFixed(2)))),()=>(O(l),y(()=>Number(O(l).toFixed(2))))]),E(e,t)};m(ee,e=>{O(i),y(()=>O(i).bounds)&&e(te)}),w(C),w(g),J(()=>X(D,(O(i),y(()=>O(i).countLabel)))),E(t,g),S()}var Sh=T(`<button class="twisty svelte-1juqkku"> </button>`),Ch=T(`<span class="twisty spacer svelte-1juqkku"></span>`),wh=T(`<span class="key svelte-1juqkku"> </span>`),Th=T(`<span class="count svelte-1juqkku"> </span>`),Eh=T(`<span> </span>`),Dh=T(`<button class="more svelte-1juqkku"> </button>`),Oh=T(`<!> <!>`,1),kh=T(`<div class="row svelte-1juqkku"><!> <!> <!></div> <!>`,1);function Ah(t,n){r(n,!1);let s=I(),c=I(),l=I(),d=I(),p=I(),h=z(n,`value`,8),g=z(n,`name`,8,null),_=z(n,`depth`,8,0),b=z(n,`expanded`,28,()=>_()<1),x=I(50);function C(e){return e===null?`null`:e===void 0?`undefined`:Array.isArray(e)?e.length<=4&&e.every(e=>typeof e==`number`)?`[${e.map(e=>Number.isInteger(e)?e:Number(e.toFixed(4))).join(`, `)}]`:`Array(${e.length})`:typeof e==`object`?`{${Object.keys(e).length}}`:typeof e==`string`?e.length>48?`"${e.slice(0,45)}…"`:`"${e}"`:String(typeof e==`number`?Number.isInteger(e)?e:Number(e.toFixed(6)):e)}function T(e){return e==null?`null`:typeof e==`number`?`number`:typeof e==`string`?`string`:typeof e==`boolean`?`boolean`:`plain`}e(()=>k(h()),()=>{Y(s,Array.isArray(h()))}),e(()=>(k(h()),O(s)),()=>{Y(c,h()!==null&&typeof h()==`object`&&!O(s))}),e(()=>(O(s),O(c)),()=>{Y(l,O(s)||O(c))}),e(()=>(O(s),k(h()),O(c)),()=>{Y(d,O(s)?h().map((e,t)=>[String(t),e]):O(c)?Object.entries(h()):[])}),e(()=>(O(d),O(x)),()=>{Y(p,O(d).slice(0,O(x)))}),ie(),le();var D=kh(),ee=B(D),te=q(ee),A=e=>{var t=Sh(),n=M(t,!0);J(()=>X(n,b()?`▾`:`▸`)),f(`click`,t,()=>b(!b())),E(e,t)},j=e=>{var t=Ch();E(e,t)};m(te,e=>{O(l)?e(A):e(j,-1)});var P=G(te,2),F=e=>{var t=wh(),n=M(t,!0);J(()=>X(n,g())),E(e,t)};m(P,e=>{g()!==null&&e(F)});var ne=G(P,2),re=e=>{var t=Th(),n=M(t,!0);J(()=>X(n,(O(s),O(d),y(()=>O(s)?`${O(d).length} items`:`${O(d).length} keys`)))),E(e,t)},ae=e=>{var t=Eh(),n=M(t,!0);J((e,r)=>{i(t,1,`value ${e??``}`,`svelte-1juqkku`),N(t,`title`,typeof h()==`string`?h():``),X(n,r)},[()=>(k(h()),y(()=>T(h()))),()=>(k(h()),y(()=>C(h())))]),E(e,t)};m(ne,e=>{O(l)?e(re):e(ae,-1)}),w(ee);var oe=G(ee,2),R=e=>{var t=Oh(),n=B(t);v(n,1,()=>O(p),([e,t])=>e,(e,t)=>{var n=me(()=>a(O(t),2));let r=()=>O(n)[0],i=()=>O(n)[1];var o=u(),s=B(o);{let e=L(()=>_()+1);Ah(s,{get value(){return i()},get name(){return r()},get depth(){return O(e)}})}E(e,o)});var r=G(n,2),i=e=>{var t=Dh(),n=M(t);J(()=>{o(t,`padding-left: ${(_()+1)*10}px`),X(n,`${O(d),O(x),y(()=>O(d).length-O(x))??``} more…`)}),f(`click`,t,()=>Y(x,O(x)+200)),E(e,t)};m(r,e=>{O(d),O(x),y(()=>O(d).length>O(x))&&e(i)}),E(e,t)};m(oe,e=>{O(l)&&b()&&e(R)}),J(()=>o(ee,`padding-left: ${_()*10}px`)),E(t,D),S()}var jh=T(`<div class="tree svelte-2vu630"><!></div>`),Mh=T(`<div class="error svelte-2vu630" role="alert"> </div>`),Nh=T(`<textarea spellcheck="false" class="svelte-2vu630"></textarea> <!> <div class="hint svelte-2vu630">Apply with blur or ⌘/Ctrl Enter</div>`,1);function Ph(t,n){r(n,!1);let i=z(n,`value`,8),a=z(n,`type`,8,`object`),o=z(n,`readOnly`,8,!1),s=z(n,`onChange`,8,null),c=I(``),l=I(),d=I(``);function p(e){if(e===void 0)return``;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function h(){if(!(o()||!s()))try{let e=JSON.parse(O(c));if(a()===`array`&&!Array.isArray(e)){Y(d,`Expected an array`);return}if(a()===`object`&&(e===null||Array.isArray(e)||typeof e!=`object`)){Y(d,`Expected an object`);return}Y(d,``),Y(l,e),s()(e)}catch{Y(d,`Invalid JSON`)}}function g(e){(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),h())}e(()=>(k(i()),O(l)),()=>{i()!==O(l)&&(Y(l,i()),Y(c,p(i())),Y(d,``))}),ie(),le();var _=u(),v=B(_),y=e=>{var t=jh();Ah(q(t),{get value(){return i()}}),w(t),E(e,t)},b=e=>{var t=Nh(),n=B(t);U(n);var r=G(n,2),i=e=>{var t=Mh(),n=M(t,!0);J(()=>X(n,O(d))),E(e,t)};m(r,e=>{O(d)&&e(i)}),Ce(2),J(()=>N(n,`aria-label`,`${a()??``} JSON`)),te(n,()=>O(c),e=>Y(c,e)),f(`blur`,n,h),f(`keydown`,n,g),E(e,t)};m(v,e=>{o()?e(y):e(b,-1)}),E(t,_),S()}function Fh(e,t,n,r){let i=e?.parameters.find(e=>e.name===t);if(!e||!i)throw Error(`Unknown parameter ${e?.id??`<missing>`}.${t}`);r?.(),e.setParameter(t,n)}async function Ih(e=fetch){let t=await e(`/api/panels`);if(!t.ok)throw Error(`Cannot list project panels (${t.status})`);let n=await t.json();return Array.isArray(n.panels)?n.panels:[]}async function Lh(e){let t=await ol(()=>import(`/api/panels/${encodeURIComponent(e)}/compiled`),[]);if(typeof t.mount!=`function`)throw Error(`Project panel "${e}" must export mount(element, api)`);return t}var Rh;async function zh(){return Rh??=fetch(`/api/exec/capability`,{cache:`no-store`}).then(async e=>{if(!e.ok)throw Error(`Cascade project execution capability is unavailable`);return(await e.json()).capability}).catch(e=>{throw Rh=void 0,e}),Rh}async function Bh(e,t){let n=n=>fetch(`/api/exec`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Cascade-Exec-Capability":n},body:JSON.stringify({stage:e,args:t})}),r=await n(await zh());r.status===403&&(Rh=void 0,r=await n(await zh()));let i=await r.json();if(!r.ok||!i.ok)throw Error(`Stage "${e}" failed: ${i.stderr||i.error||`unknown error`}`);let a=String(i.stdout).trim().split(`
|
|
218
|
+
`).pop()??`{}`;return JSON.parse(a)}function Vh(e){let t=t=>e.context()?.graph?.getNode(t)??null;return{runStage:e.runStage??Bh,mediaUrl:rh,getParam(e,n){return t(e)?.parameters.find(e=>e.name===n)?.value},setParam(n,r,i){let a=t(n),o=a?.parameters.find(e=>e.name===r);if(!a||!o)throw Error(`Unknown parameter ${n}.${r}`);Fh(a,r,i,e.context()?.onRecordHistory)},selectedNodeId(){return e.context()?.selectedNode?.id??null},sourceNodeId:e.sourceNodeId??null,signal:e.signal??new AbortController().signal,close:e.close}}var Hh=T(`<span class="renderer-error svelte-qxatjj" role="alert"> </span>`),Uh=T(`<div></div>`);function Wh(t,n){r(n,!1);let i=I(),a=z(n,`panelName`,8),o=z(n,`rendererType`,8),s=z(n,`value`,8),c=z(n,`readOnly`,8,!0),l=z(n,`mode`,8,`inspect`),d=z(n,`onChange`,8,null),f=z(n,`loader`,8,Lh),p=I(),h=I(null),g=I(``);he(()=>{let e=!1,t=null;return f()(a()).then(async n=>{if(e)return;let r=n.renderers?.[o()];if(!r)throw Error(`Project module "${a()}" does not export renderer "${o()}"`);let s=await r.mount(O(p),O(i));typeof s==`function`?t=s:s&&Y(h,s),e&&(t?.(),O(h)?.dispose())}).catch(t=>{e||Y(g,t instanceof Error?t.message:String(t))}),()=>{e=!0,t?.(),O(h)?.dispose()}}),e(()=>(k(s()),k(c()),k(l()),k(d())),()=>{Y(i,{value:s(),readOnly:c(),mode:l(),onChange:d()})}),e(()=>(O(h),O(i)),()=>{O(h)?.update?.(O(i))}),ie(),le();var _=u(),v=B(_),y=e=>{var t=Hh(),n=M(t,!0);J(()=>X(n,O(g))),E(e,t)},b=e=>{var t=Uh();pe(t,e=>Y(p,e),()=>O(p)),E(e,t)};m(v,e=>{O(g)?e(y):e(b,-1)}),E(t,_),S()}var Gh=new Map;function Kh(e,t){Gh.set(e,{kind:`svelte`,component:t})}function qh(e,t){Gh.set(e,{kind:`project`,component:Wh,panelName:t,rendererType:e})}function Jh(e){return e?Gh.get(e)??null:null}Kh(`object`,Ah),Kh(`array`,Ah);var Yh=T(`<input type="number" class="cell svelte-1b37oh8"/>`),Xh=T(`<button class="reset svelte-1b37oh8">Identity</button>`),Zh=T(`<div class="matrix svelte-1b37oh8"></div> <!>`,1),Qh=T(`<span class="swatch svelte-1b37oh8"></span>`),$h=T(`<input aria-label="Color" type="color" class="svelte-1b37oh8"/>`),eg=T(`<label class="component svelte-1b37oh8"><span class="svelte-1b37oh8"> </span> <input type="number" min="0" max="1" step="0.01" class="svelte-1b37oh8"/></label>`),tg=T(`<div class="vector svelte-1b37oh8"></div>`),ng=T(`<div class="color-row svelte-1b37oh8"><!> <span class="color-css svelte-1b37oh8"> </span></div> <!>`,1),rg=T(`<label class="component svelte-1b37oh8"><span class="svelte-1b37oh8"> </span> <input type="number" class="svelte-1b37oh8"/></label>`),ig=T(`<option> </option>`),ag=T(`<select class="single svelte-1b37oh8"></select>`),og=T(`<label class="boolean svelte-1b37oh8"><input type="checkbox" class="svelte-1b37oh8"/> </label>`),sg=T(`<div class="slider-row svelte-1b37oh8"><input type="range" class="svelte-1b37oh8"/> <input type="number" class="slider-number svelte-1b37oh8"/></div>`),cg=T(`<input type="number" class="single svelte-1b37oh8"/>`),lg=T(`<pre class="text-value svelte-1b37oh8"> </pre>`),ug=T(`<input aria-label="string" type="text" class="single svelte-1b37oh8"/>`),dg=T(`<img loading="lazy" class="svelte-1b37oh8"/> <div class="meta svelte-1b37oh8"> </div> <div class="path svelte-1b37oh8"> </div>`,1),fg=T(`<div class="summary svelte-1b37oh8">No image reference</div>`),pg=T(`<input aria-label="image path" type="text" class="single svelte-1b37oh8"/>`),mg=T(`<div class="structured svelte-1b37oh8"><!></div>`),hg=T(`<div class="image svelte-1b37oh8"><!> <!></div>`),gg=T(`<div class="texture"><div class="meta svelte-1b37oh8"> </div> <div class="notice svelte-1b37oh8">Live browser resource · convert to image to cross runtimes</div></div>`),_g=T(`<!> <!>`,1),vg=T(`<input aria-label="asset path" type="text" class="single svelte-1b37oh8"/>`),yg=T(`<div class="summary svelte-1b37oh8"> </div>`),bg=T(`<div><!></div>`);function xg(n,a){r(a,!1);let s=I(),l=I(),d=I(),p=I(),h=I(),g=I(),_=I(),b=I(),T=I(),D=I(),ee=I(),te=I(),A=I(),j=I(),P=z(a,`type`,8,`any`),F=z(a,`value`,8),ne=z(a,`mode`,8,`inspect`),re=z(a,`readOnly`,8,!1),ae=z(a,`port`,8,null),oe=z(a,`node`,8,null),R=z(a,`onChange`,8,null),se=new Set([`geometry`,`points`,`lines`,`polyline`,`mesh`,`rects`]);function ce(e){if(!Number.isFinite(e))return O(T).min;let t=Math.min(O(T).max,Math.max(O(T).min,e));return O(l)===`int`?Math.round(t):t}function V(e){!re()&&R()&&R()(e)}function H(e,t){let n=Number(t);if(!Number.isFinite(n))return;let r=Array.isArray(F())?[...F()]:Array(O(d)).fill(0);r[e]=O(g)?Math.round(n):n,V(r)}function ue(){let e=Array(O(d)).fill(0);for(let t=0;t<O(h);t++)e[t*O(h)+t]=1;V(e)}function U(e,t){let n=[...O(j)];n[e]=Math.max(0,Math.min(1,Number(t))),V(n)}function de(e){let t=oh(e);t[3]=O(j)[3],V(t)}function fe(e){let t=O(ee).find(t=>String(t.value)===e);t&&V(t.value)}e(()=>k(P()),()=>{Y(s,Ol(P()))}),e(()=>(O(s),k(F())),()=>{Y(l,O(s)===`any`?nh(F()):O(s))}),e(()=>O(l),()=>{Y(d,El[O(l)]??0)}),e(()=>O(l),()=>{Y(p,O(l).startsWith(`mat`))}),e(()=>(O(p),O(d)),()=>{Y(h,O(p)?Math.sqrt(O(d)):0)}),e(()=>O(l),()=>{Y(g,Dl(O(l)))}),e(()=>(O(l),O(d)),()=>{Y(_,O(l)===`color`?[`R`,`G`,`B`,`A`]:[`X`,`Y`,`Z`,`W`].slice(0,O(d)))}),e(()=>(k(re()),O(l),Jh),()=>{Y(b,!re()&&(O(l)===`object`||O(l)===`array`)?null:Jh(O(l)))}),e(()=>(k(ae()),O(l)),()=>{Y(T,{min:Number(ae()?.options?.min),max:Number(ae()?.options?.max),step:ae()?.options?.step??(O(l)===`int`?1:`any`)})}),e(()=>O(T),()=>{Y(D,Number.isFinite(O(T).min)&&Number.isFinite(O(T).max)&&O(T).max>O(T).min)}),e(()=>k(ae()),()=>{Y(ee,Array.isArray(ae()?.options?.choices)?ae().options.choices:[])}),e(()=>(O(l),k(F())),()=>{Y(te,O(l)===`image`?Nl(F()):null)}),e(()=>(O(te),k(ne())),()=>{Y(A,O(te)?rh(O(te).path,{width:ne()===`view`?1800:320}):``)}),e(()=>k(F()),()=>{Y(j,oh(F()))}),ie(),le();var W=bg(),pe=q(W),K=e=>{var n=u(),r=B(n),i=e=>{var n=u(),r=B(n);{let e=L(()=>re()?null:V);t(r,()=>O(b).component,(t,n)=>{n(t,{get value(){return F()},get readOnly(){return re()},get mode(){return ne()},get onChange(){return O(e)},get panelName(){return O(b),y(()=>O(b).panelName)},get rendererType(){return O(b),y(()=>O(b).rendererType)}})})}E(e,n)},a=e=>{var n=u(),r=B(n);{let e=L(()=>re()?null:V);t(r,()=>O(b).component,(t,n)=>{n(t,{get value(){return F()},get port(){return ae()},get readOnly(){return re()},get mode(){return ne()},get node(){return oe()},get onChange(){return O(e)}})})}E(e,n)};m(r,e=>{O(b),y(()=>O(b).kind===`project`)?e(i):e(a,-1)}),E(e,n)},he=e=>{var t=Zh(),n=B(t);v(n,5,()=>(O(d),y(()=>Array(O(d)))),c,(e,t,n)=>{var r=Yh();Ee(r),J((e,t)=>{N(r,`aria-label`,`Row ${e??``}, column ${n%O(h)+1}`),r.disabled=re(),x(r,t)},[()=>(O(h),y(()=>Math.floor(n/O(h))+1)),()=>(k(F()),y(()=>Array.isArray(F())?F()[n]??0:0))]),f(`change`,r,e=>H(n,e.currentTarget.value)),E(e,r)}),w(n);var r=G(n,2),i=e=>{var t=Xh();f(`click`,t,ue),E(e,t)};m(r,e=>{re()||e(i)}),J(()=>o(n,`grid-template-columns: repeat(${O(h)??``}, minmax(0, 1fr))`)),E(e,t)},ge=e=>{var t=ng(),n=B(t),r=q(n),i=e=>{var t=Qh();J(e=>o(t,`background:${e??``}`),[()=>(k(sh),O(j),y(()=>sh(O(j))))]),E(e,t)},a=e=>{var t=$h();Ee(t),J(e=>x(t,e),[()=>(k(ch),O(j),y(()=>ch(O(j))))]),f(`input`,t,e=>de(e.currentTarget.value)),E(e,t)};m(r,e=>{re()?e(i):e(a,-1)});var s=G(r,2),l=M(s,!0);w(n);var u=G(n,2),d=e=>{var t=tg();v(t,5,()=>O(j),c,(e,t,n)=>{var r=eg(),i=q(r),a=M(i,!0),o=G(i,2);Ee(o),w(r),J(()=>{X(a,(O(_),y(()=>O(_)[n]))),N(o,`aria-label`,(O(_),y(()=>O(_)[n]))),o.disabled=re(),x(o,O(t))}),f(`change`,o,e=>U(n,e.currentTarget.value)),E(e,r)}),w(t),E(e,t)};m(u,e=>{(!re()||ne()===`view`)&&e(d)}),J(e=>X(l,e),[()=>(k(sh),O(j),y(()=>sh(O(j))))]),E(e,t)},_e=e=>{var t=tg();v(t,5,()=>(O(d),y(()=>Array(O(d)))),c,(e,t,n)=>{var r=rg(),i=q(r),a=M(i,!0),o=G(i,2);Ee(o),w(r),J(e=>{X(a,(O(_),y(()=>O(_)[n]))),N(o,`aria-label`,(O(_),y(()=>O(_)[n]))),N(o,`step`,O(g)?1:`any`),o.disabled=re(),x(o,e)},[()=>(k(F()),y(()=>Array.isArray(F())?F()[n]??0:0))]),f(`change`,o,e=>H(n,e.currentTarget.value)),E(e,r)}),w(t),E(e,t)},ve=e=>{var t=ag();v(t,5,()=>O(ee),c,(e,t)=>{var n=ig(),r=M(n,!0),i={};J(e=>{X(r,(O(t),y(()=>O(t).label))),i!==(i=e)&&(n.value=(n.__value=i)??``)},[()=>(O(t),y(()=>String(O(t).value)))]),E(e,n)}),w(t);var n;Se(t),J(e=>{N(t,`aria-label`,(k(ae()),y(()=>ae()?.name??`choice`))),t.disabled=re(),n!==(n=e)&&(t.value=(t.__value=n)??``,C(t,n))},[()=>(k(F()),y(()=>String(F()??``)))]),f(`change`,t,e=>fe(e.currentTarget.value)),E(e,t)},ye=e=>{var t=og(),n=q(t);Ee(n);var r=G(n);w(t),J((e,t)=>{n.disabled=re(),we(n,e),X(r,` ${t??``}`)},[()=>(k(F()),y(()=>!!F())),()=>(k(F()),y(()=>F()?`true`:`false`))]),f(`change`,n,e=>V(e.currentTarget.checked)),E(e,t)},be=e=>{var t=sg(),n=q(t);Ee(n);var r=G(n,2);Ee(r),w(t),J(()=>{N(n,`aria-label`,O(l)),N(n,`min`,(O(T),y(()=>O(T).min))),N(n,`max`,(O(T),y(()=>O(T).max))),N(n,`step`,(O(T),y(()=>O(T).step))),n.disabled=re(),x(n,(k(F()),O(T),y(()=>F()??O(T).min))),N(r,`aria-label`,`${O(l)??``} value`),N(r,`min`,(O(T),y(()=>O(T).min))),N(r,`max`,(O(T),y(()=>O(T).max))),N(r,`step`,(O(T),y(()=>O(T).step))),r.disabled=re(),x(r,(k(F()),O(T),y(()=>F()??O(T).min)))}),f(`input`,n,e=>V(ce(Number(e.currentTarget.value)))),f(`change`,r,e=>V(ce(Number(e.currentTarget.value)))),E(e,t)},xe=e=>{var t=cg();Ee(t),J(()=>{N(t,`aria-label`,O(l)),N(t,`step`,O(l)===`int`?1:`any`),t.disabled=re(),x(t,F()??0)}),f(`change`,t,e=>V(O(l)===`int`?Math.round(Number(e.currentTarget.value)):Number(e.currentTarget.value))),E(e,t)},Te=e=>{var t=u(),n=B(t),r=e=>{var t=lg(),n=M(t,!0);J(()=>X(n,F()??``)),E(e,t)},i=e=>{var t=ug();Ee(t),J(()=>{t.disabled=re(),x(t,F()??``)}),f(`change`,t,e=>V(e.currentTarget.value)),E(e,t)};m(n,e=>{ne()===`view`&&re()?e(r):e(i,-1)}),E(e,t)},De=e=>{var t=hg(),n=q(t),r=e=>{var t=dg(),n=B(t),r=G(n,2),i=M(r,!0),a=G(r,2),o=M(a,!0);J(e=>{N(n,`src`,O(A)),N(n,`alt`,(O(te),y(()=>O(te).path))),X(i,e),N(a,`title`,(O(te),y(()=>O(te).path))),X(o,(O(te),y(()=>O(te).path)))},[()=>(k(lh),O(te),O(l),y(()=>lh(O(te),O(l))))]),E(e,t)},i=e=>{var t=fg();E(e,t)};m(n,e=>{O(te)?e(r):e(i,-1)});var a=G(n,2),o=e=>{var t=mg(),n=q(t),r=e=>{var t=pg();Ee(t),J(()=>x(t,F())),f(`change`,t,e=>V(e.currentTarget.value)),E(e,t)},i=e=>{Ph(e,{get value(){return F()},type:`image`,get onChange(){return R()}})};m(n,e=>{typeof F()==`string`?e(r):e(i,-1)}),w(t),E(e,t)};m(a,e=>{re()||e(o)}),w(t),E(e,t)},Oe=e=>{var t=gg(),n=q(t),r=M(n,!0);Ce(2),w(t),J(e=>X(r,e),[()=>(k(lh),k(F()),O(l),y(()=>lh(F(),O(l))))]),E(e,t)},ke=e=>{var t=_g(),n=B(t);xh(n,{get value(){return F()},get type(){return O(l)}});var r=G(n,2),i=e=>{var t=mg();Ph(q(t),{get value(){return F()},get type(){return O(l)},get onChange(){return R()}}),w(t),E(e,t)};m(r,e=>{re()||e(i)}),E(e,t)},Ae=me(()=>(O(l),y(()=>se.has(O(l))))),je=e=>{var t=vg();Ee(t),J(()=>{t.disabled=re(),x(t,F())}),f(`change`,t,e=>V(e.currentTarget.value)),E(e,t)},Me=e=>{Ph(e,{get value(){return F()},get type(){return O(l)},get readOnly(){return re()},get onChange(){return R()}})},Ne=e=>{var t=yg(),n=M(t,!0);J(e=>X(n,e),[()=>(k(lh),k(F()),O(l),y(()=>lh(F(),O(l))))]),E(e,t)};m(pe,e=>{O(b)?e(K):O(p)?e(he,1):O(l)===`color`?e(ge,2):O(d)>0?e(_e,3):(O(ee),y(()=>O(ee).length>0)?e(ve,4):O(l)===`bool`?e(ye,5):(O(l)===`float`||O(l)===`int`)&&O(D)?e(be,6):O(l)===`float`||O(l)===`int`?e(xe,7):O(l)===`string`?e(Te,8):O(l)===`image`?e(De,9):O(l)===`texture`?e(Oe,10):O(Ae)?e(ke,11):O(l)===`asset`&&typeof F()==`string`?e(je,12):O(l)===`array`||O(l)===`object`||O(l)===`any`||O(l)===`asset`?e(Me,13):e(Ne,-1))}),w(W),J(()=>{i(W,1,`core-value mode-${ne()??``}`,`svelte-1b37oh8`),N(W,`data-type`,O(l))}),E(n,W),S()}var Sg=T(`<div class="source svelte-1boj9ce"> </div>`),Cg=T(`<div><div class="row svelte-1boj9ce"><span class="dot svelte-1boj9ce"></span> <span class="name svelte-1boj9ce"> </span></div> <!> <div class="value svelte-1boj9ce"><!></div></div>`);function wg(t,n){r(n,!1);let a=I(),s=I(),c=I(),l=I(),u=I(),d=z(n,`port`,8),f=z(n,`node`,8,null),p=z(n,`direction`,8,`input`),h=z(n,`onChange`,8,null);e(()=>k(d()),()=>{Y(a,Ol(d()?.dataType))}),e(()=>k(d()),()=>{Y(s,d()?.value)}),e(()=>(O(a),O(s)),()=>{Y(c,O(a)===`any`?nh(O(s)):O(a))}),e(()=>k(d()),()=>{Y(l,(d()?.connections?.length??0)>0)}),e(()=>(k(p()),O(l)),()=>{Y(u,p()===`output`||O(l))}),ie(),le();var g=Cg();let _;var v=q(g),b=q(v),x=G(b,2),C=M(x,!0);w(v);var T=G(v,2),D=e=>{var t=Sg(),n=M(t);J(()=>X(n,`from ${k(d()),y(()=>d().connections[0]?.from?.nodeId??`upstream`)??``}`)),E(e,t)};m(T,e=>{O(l)&&p()===`input`&&e(D)});var ee=G(T,2),te=q(ee);{let e=L(()=>O(u)?null:h());xg(te,{get type(){return O(c)},get value(){return O(s)},get port(){return d()},get node(){return f()},mode:`inspect`,get readOnly(){return O(u)},get onChange(){return O(e)}})}w(ee),w(g),J(e=>{_=i(g,1,`port-editor svelte-1boj9ce`,null,_,{"read-only":O(u)}),o(b,`background:${e??``}`),N(x,`title`,(k(d()),O(c),y(()=>`${d()?.name} · ${O(c)}`))),X(C,(k(d()),y(()=>d()?.name)))},[()=>(k(jl),k(d()),y(()=>jl(d()?.dataType)))]),E(t,g),S()}var Tg=T(`<input type="number" class="number-input svelte-368zap"/>`),Eg=T(`<div class="slider-wrapper svelte-368zap"><input type="range" class="slider svelte-368zap"/> <!></div>`),Dg=T(`<input type="number" class="number-input-full svelte-368zap"/>`),Og=T(`<div class="number-input-container svelte-368zap"><!></div>`);function kg(t,n){r(n,!1);let i=I(),a=I(),o=I(),s=I(),c=I(),l=I(),u=I(),p=I(),h=z(n,`prop`,8),g=z(n,`id`,8),_=z(n,`onValueChange`,8);function v(e){let t=parseFloat(e.target.value),n=O(c)?Math.round(t):t;_()(n)}function y(e){let t=e.target,n=parseFloat(t.value);if(isNaN(n)){t.value=String(O(i));return}O(a)!==void 0&&n<O(a)&&(n=O(a)),O(o)!==void 0&&n>O(o)&&(n=O(o)),_()(O(c)?Math.round(n):n)}function b(e){let t=e.target;(t.value===``||isNaN(parseFloat(t.value)))&&(t.value=String(O(i)))}e(()=>k(h()),()=>{Y(i,typeof h().value==`number`?h().value:0)}),e(()=>k(h()),()=>{Y(a,typeof h().params?.min==`number`?h().params.min:void 0)}),e(()=>k(h()),()=>{Y(o,typeof h().params?.max==`number`?h().params.max:void 0)}),e(()=>k(h()),()=>{Y(s,h().params?.step??(h().params?.integer?1:.01))}),e(()=>(k(h()),O(s)),()=>{Y(c,h().params?.integer===!0||O(s)===1)}),e(()=>(O(a),O(o)),()=>{Y(l,O(a)!==void 0&&O(o)!==void 0)}),e(()=>k(h()),()=>{Y(u,typeof h().disabled==`function`?h().disabled():h().disabled)}),e(()=>(O(c),O(i)),()=>{Y(p,O(c)?Math.round(O(i)):O(i))}),ie(),le();var C=Og(),T=q(C),D=e=>{var t=Eg(),n=q(t);Ee(n);var r=G(n,2);d(r,()=>O(p),e=>{var t=Tg();Ee(t),J(()=>{N(t,`min`,O(a)),N(t,`max`,O(o)),N(t,`step`,O(s)),x(t,O(p)),t.disabled=O(u)}),f(`input`,t,y),f(`blur`,t,b),E(e,t)}),w(t),J(()=>{N(n,`id`,g()),N(n,`min`,O(a)),N(n,`max`,O(o)),N(n,`step`,O(s)),x(n,O(i)),n.disabled=O(u)}),f(`input`,n,v),E(e,t)},ee=e=>{var t=Dg();Ee(t),J(()=>{N(t,`id`,g()),N(t,`min`,O(a)),N(t,`max`,O(o)),N(t,`step`,O(s)),x(t,O(p)),t.disabled=O(u)}),f(`input`,t,y),f(`blur`,t,b),E(e,t)};m(T,e=>{O(l)?e(D):e(ee,-1)}),w(C),E(t,C),S()}var Ag=T(`<input type="number" class="number-input svelte-zpm8xr"/>`),jg=T(`<button class="preset-option svelte-zpm8xr"> </button>`),Mg=T(`<div class="preset-dropdown svelte-zpm8xr" role="menu" tabindex="-1"></div>`),Ng=T(`<div class="preset-container svelte-zpm8xr"><button class="preset-button svelte-zpm8xr" title="Resolution presets"><svg width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M2 3h8M2 6h8M2 9h8"></path></svg></button> <!></div>`),Pg=D(`<path d="M3 5.5 V4 a3 3 0 0 1 6 0 v1.5 M6 8.5 v2 M2.5 5.5 h7 a1 1 0 0 1 1 1 v4 a1 1 0 0 1 -1 1 h-7 a1 1 0 0 1 -1 -1 v-4 a1 1 0 0 1 1 -1 z"></path>`),Fg=D(`<path d="M3 5.5 V4 a3 3 0 0 1 6 0 v1.5 M6 8.5 v2 M2.5 5.5 h7 a1 1 0 0 1 1 1 v4 a1 1 0 0 1 -1 1 h-7 a1 1 0 0 1 -1 -1 v-4 a1 1 0 0 1 1 -1 z" stroke-dasharray="2 2"></path>`),Ig=T(`<button><svg width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.5"><!></svg></button>`),Lg=T(`<div class="vector-input-container svelte-zpm8xr"><div class="vector-row svelte-zpm8xr"><!> <!> <!></div></div>`);function Rg(t,n){r(n,!1);let a=I(),o=I(),s=I(),l=I(),u=I(),d=I(),p=I(),h=z(n,`prop`,12),g=z(n,`id`,8),_=z(n,`onValueChange`,8),b=I(Array.isArray(h().value)?[...h().value]:[0,0,0]),C=I([]),T=I(h().params?.locked??!1),D=I(!1),te=I(),A=I(),j=[{label:`256 × 256`,value:[256,256]},{label:`512 × 512`,value:[512,512]},{label:`1024 × 1024`,value:[1024,1024]},{label:`2048 × 2048`,value:[2048,2048]},{label:`640 × 480`,value:[640,480]},{label:`1280 × 720`,value:[1280,720]},{label:`1920 × 1080`,value:[1920,1080]},{label:`3840 × 2160`,value:[3840,2160]}];function P(e){O(a)===2?_()([e[0],e[1]]):O(a)===3&&_()([e[0],e[1],O(b)[2]]),Y(D,!1)}function F(e){O(A)&&!O(A).contains(e.target)&&O(te)&&!O(te).contains(e.target)&&Y(D,!1)}function ne(e,t){let n=[...O(b)];if(O(d)&&(t=Math.round(t)),O(s)!==void 0){let n=Array.isArray(O(s))?O(s)[e]:O(s);n!==void 0&&t<n&&(t=n)}if(O(l)!==void 0){let n=Array.isArray(O(l))?O(l)[e]:O(l);n!==void 0&&t>n&&(t=n)}O(T)?n.fill(t):n[e]=t,_()(n)}function re(e,t){let n=e.target,r=parseFloat(n.value);if(isNaN(r)){n.value=String(O(b)[t]);return}ne(t,r)}function oe(e,t){let n=e.target;(n.value===``||isNaN(parseFloat(n.value)))&&(n.value=String(O(b)[t]))}he(()=>(document.addEventListener(`click`,F),()=>{document.removeEventListener(`click`,F)})),e(()=>(k(h()),O(b)),()=>{let e=h().value,t=Array.isArray(e)?[...e]:[0,0,0];JSON.stringify(O(b))!==JSON.stringify(t)&&Y(b,t)}),e(()=>k(h()),()=>{Y(u,h().params?.step??(h().params?.integer?1:.01))}),e(()=>(k(h()),O(u)),()=>{Y(d,h().params?.integer===!0||O(u)===1)}),e(()=>(O(b),O(C),O(d)),()=>{O(b)&&ee().then(()=>{O(b).forEach((e,t)=>{if(O(C)[t]){let n=O(d)?Math.round(e):e;O(C)[t].value!==String(n)&&!isNaN(n)&&H(C,O(C)[t].value=String(n))}})})}),e(()=>O(b),()=>{Y(a,O(b).length)}),e(()=>O(a),()=>{Y(o,O(a)===2?[`X`,`Y`]:[`X`,`Y`,`Z`])}),e(()=>k(h()),()=>{Y(s,typeof h().params?.min==`number`||Array.isArray(h().params?.min)?h().params.min:void 0)}),e(()=>k(h()),()=>{Y(l,typeof h().params?.max==`number`||Array.isArray(h().params?.max)?h().params.max:void 0)}),e(()=>k(h()),()=>{Y(p,typeof h().disabled==`function`?h().disabled():h().disabled)}),e(()=>k(h()),()=>{h().params?.locked!==void 0&&Y(T,h().params.locked)}),ie(),le();var R=Lg(),se=q(R),B=q(se);v(B,1,()=>(O(a),y(()=>Array(O(a)))),c,(e,t,n)=>{let r=L(()=>(O(b),O(d),y(()=>O(b)[n]===void 0?0:O(d)?Math.round(O(b)[n]):O(b)[n])));L(()=>(O(C),y(()=>O(C)[n])));var i=Ag();Ee(i),pe(i,(e,t)=>H(C,O(C)[t]=e),e=>O(C)?.[e],()=>[n]),J((e,t)=>{N(i,`id`,`${g()??``}-${n}`),N(i,`min`,e),N(i,`max`,t),N(i,`step`,O(u)),x(i,O(r)),i.disabled=O(p)},[()=>(O(s),y(()=>O(s)===void 0?void 0:Array.isArray(O(s))?O(s)[n]:O(s))),()=>(O(l),y(()=>O(l)===void 0?void 0:Array.isArray(O(l))?O(l)[n]:O(l)))]),f(`input`,i,e=>re(e,n)),f(`blur`,i,e=>oe(e,n)),E(e,i)});var ce=G(B,2),V=e=>{var t=Ng(),r=q(t);pe(r,e=>Y(te,e),()=>O(te));var i=G(r,2),a=e=>{var t=Mg();v(t,5,()=>j,c,(e,t)=>{var n=jg(),r=M(n,!0);J(()=>X(r,(O(t),y(()=>O(t).label)))),f(`click`,n,ae(()=>P(O(t).value))),E(e,n)}),w(t),pe(t,e=>Y(A,e),()=>O(A)),f(`click`,t,ae(function(e){ge.call(this,n,e)})),f(`keydown`,t,ae(function(e){ge.call(this,n,e)})),E(e,t)};m(i,e=>{O(D)&&e(a)}),w(t),J(()=>r.disabled=O(p)),f(`click`,r,ae(e=>{e.stopPropagation(),Y(D,!O(D))})),E(e,t)};m(ce,e=>{O(a)===2&&e(V)});var ue=G(ce,2),U=e=>{var t=Ig();let n;var r=q(t),a=q(r),o=e=>{var t=Pg();E(e,t)},s=e=>{var t=Fg();E(e,t)};m(a,e=>{O(T)?e(o):e(s,-1)}),w(r),w(t),J(()=>{n=i(t,1,`lock-button svelte-zpm8xr`,null,n,{locked:O(T)}),N(t,`title`,O(T)?`Unlock components`:`Lock components`),t.disabled=O(p)}),f(`click`,t,e=>{e.stopPropagation(),Y(T,!O(T)),h().params&&h(h().params.locked=O(T),!0)}),E(e,t)};m(ue,e=>{O(a)>1&&e(U)}),w(se),w(R),E(t,R),S()}var zg=P(null),Bg=T(`<div class="input-row svelte-1hwwwsb"><label class="svelte-1hwwwsb">H</label> <input type="number" min="0" max="360" class="number-input-small svelte-1hwwwsb"/> <input aria-label="Hue" type="range" min="0" max="360" step="1" class="slider-input svelte-1hwwwsb"/></div> <div class="input-row svelte-1hwwwsb"><label class="svelte-1hwwwsb">S</label> <input type="number" min="0" max="100" class="number-input-small svelte-1hwwwsb"/> <input aria-label="Saturation" type="range" min="0" max="100" step="1" class="slider-input svelte-1hwwwsb"/></div> <div class="input-row svelte-1hwwwsb"><label class="svelte-1hwwwsb">V</label> <input type="number" min="0" max="100" class="number-input-small svelte-1hwwwsb"/> <input aria-label="Value" type="range" min="0" max="100" step="1" class="slider-input svelte-1hwwwsb"/></div>`,1),Vg=T(`<div class="input-row svelte-1hwwwsb"><label class="svelte-1hwwwsb">R</label> <input type="number" min="0" max="255" class="number-input-small svelte-1hwwwsb"/> <input aria-label="Red" type="range" min="0" max="255" step="1" class="slider-input svelte-1hwwwsb"/></div> <div class="input-row svelte-1hwwwsb"><label class="svelte-1hwwwsb">G</label> <input type="number" min="0" max="255" class="number-input-small svelte-1hwwwsb"/> <input aria-label="Green" type="range" min="0" max="255" step="1" class="slider-input svelte-1hwwwsb"/></div> <div class="input-row svelte-1hwwwsb"><label class="svelte-1hwwwsb">B</label> <input type="number" min="0" max="255" class="number-input-small svelte-1hwwwsb"/> <input aria-label="Blue" type="range" min="0" max="255" step="1" class="slider-input svelte-1hwwwsb"/></div>`,1),Hg=T(`<button class="palette-swatch svelte-1hwwwsb"></button>`),Ug=T(`<div class="picker-popover svelte-1hwwwsb" role="dialog" aria-label="Color picker" tabindex="-1"><div class="picker-header svelte-1hwwwsb"><button>HSV</button> <button>RGB</button></div> <div class="picker-content svelte-1hwwwsb"><div class="wheel-section svelte-1hwwwsb"><canvas class="color-wheel svelte-1hwwwsb"></canvas></div> <div class="inputs-section svelte-1hwwwsb"><!> <div class="input-row svelte-1hwwwsb"><label class="svelte-1hwwwsb">Hex</label> <input type="text" class="hex-input svelte-1hwwwsb"/></div></div> <div class="palette-section svelte-1hwwwsb"><div class="color-history svelte-1hwwwsb"><button class="history-swatch svelte-1hwwwsb" title="Swap with previous"></button> <button class="history-swatch svelte-1hwwwsb" aria-label="Current color"></button></div> <div class="palette-grid svelte-1hwwwsb"></div></div></div></div>`),Wg=T(`<div class="color-picker-container svelte-1hwwwsb"><button class="color-swatch svelte-1hwwwsb" aria-label="Choose color"></button> <!></div>`);function Gg(t,n){r(n,!1);let a=z(n,`prop`,8),s=z(n,`id`,8),l=z(n,`onValueChange`,8),d=I(!1),p=null,h=I(),g=I(),_=I(null),b=null,C=null,T=-1,D=null,ee=I(210),te=I(1),A=I(.5),j=I(0),M=I(.25),P=I(.5),F=I(`#003F7F`),ne=I(`#000000`),re=I(`hsv`),L=[[`#FF0000`,`#FF2000`,`#FF4000`,`#FF6000`,`#FF8000`,`#FFA000`,`#FFC000`,`#FFE000`,`#FFFF00`,`#E0FF00`,`#C0FF00`,`#A0FF00`,`#80FF00`,`#60FF00`,`#40FF00`,`#20FF00`],[`#00FF00`,`#00FF20`,`#00FF40`,`#00FF60`,`#00FF80`,`#00FFA0`,`#00FFC0`,`#00FFE0`,`#00FFFF`,`#00E0FF`,`#00C0FF`,`#00A0FF`,`#0080FF`,`#0060FF`,`#0040FF`,`#0020FF`],[`#0000FF`,`#2000FF`,`#4000FF`,`#6000FF`,`#8000FF`,`#A000FF`,`#C000FF`,`#E000FF`,`#FF00FF`,`#FF00E0`,`#FF00C0`,`#FF00A0`,`#FF0080`,`#FF0060`,`#FF0040`,`#FF0020`],[`#000000`,`#111111`,`#222222`,`#333333`,`#444444`,`#555555`,`#666666`,`#777777`,`#888888`,`#999999`,`#AAAAAA`,`#BBBBBB`,`#CCCCCC`,`#DDDDDD`,`#EEEEEE`,`#FFFFFF`]];function oe(e,t,n){let r=Math.max(e,t,n),i=r-Math.min(e,t,n),a=0;i!==0&&(a=r===e?(t-n)/i%6:r===t?(n-e)/i+2:(e-t)/i+4),a=Math.round(a*60),a<0&&(a+=360);let o=r===0?0:i/r;return{h:a,s:o,v:r}}function R(e,t,n){let r=n*t,i=r*(1-Math.abs(e/60%2-1)),a=n-r,o=0,s=0,c=0;return e<60?(o=r,s=i,c=0):e<120?(o=i,s=r,c=0):e<180?(o=0,s=r,c=i):e<240?(o=0,s=i,c=r):e<300?(o=i,s=0,c=r):(o=r,s=0,c=i),{r:o+a,g:s+a,b:c+a}}function se(e,t,n){let r=e=>{let t=Math.round(e*255).toString(16);return t.length===1?`0`+t:t};return`#${r(e)}${r(t)}${r(n)}`.toUpperCase()}function ce(e){let t=Vc(e);Y(F,Uc(t).toUpperCase()),Y(j,t.r),Y(M,t.g),Y(P,t.b);let n=oe(O(j),O(M),O(P));Y(ee,n.h),Y(te,n.s),Y(A,n.v),O(_)&&O(g)&&fe()}function V(){let e=R(O(ee),O(te),O(A));Y(j,e.r),Y(M,e.g),Y(P,e.b),Y(F,se(O(j),O(M),O(P)));let t={r:O(j),g:O(M),b:O(P),a:1};l()(t),requestAnimationFrame(()=>{O(_)&&O(g)&&fe()})}function H(){Y(F,se(O(j),O(M),O(P)));let e=oe(O(j),O(M),O(P));Y(ee,e.h),Y(te,e.s),Y(A,e.v);let t={r:O(j),g:O(M),b:O(P),a:1};l()(t),requestAnimationFrame(()=>{O(_)&&O(g)&&fe()})}function ue(e){let t=document.createElement(`canvas`);t.width=e,t.height=e;let n=t.getContext(`2d`),r=e/2,i=r-2,a=i-9,o=n.createImageData(e,e),s=o.data;for(let t=0;t<e;t++)for(let n=0;n<e;n++){let o=n-r,c=t-r,l=Math.sqrt(o*o+c*c);if(l<=i&&l>a){let r=R((Math.atan2(c,o)*180/Math.PI+90+360)%360,1,1),i=(t*e+n)*4;s[i]=Math.round(r.r*255),s[i+1]=Math.round(r.g*255),s[i+2]=Math.round(r.b*255),s[i+3]=255}}return n.putImageData(o,0,0),t}function U(e,t,n){let r=document.createElement(`canvas`);r.width=e,r.height=e;let i=r.getContext(`2d`),a=e/2,o=a-2-9,s=i.createImageData(e,e),c=s.data;for(let r=0;r<e;r++)for(let i=0;i<e;i++){let s=i-a,l=r-a,u=Math.sqrt(s*s+l*l);if(u<=o){let a=(Math.atan2(l,s)*180/Math.PI+90+360)%360,d=(r*e+i)*4;if(n===`rgb`){let e=a/360,t=0,n=0,r=0;if(e<1/3){let i=e*3;t=1-i,n=i,r=0}else if(e<2/3){let i=(e-1/3)*3;t=0,n=1-i,r=i}else{let i=(e-2/3)*3;t=i,n=0,r=1-i}let i=u/o,s=1-i;t*=s,n*=s,r=r*s+i;let l=u/o;t=t*l+(1-l),n=n*l+(1-l),r=r*l+(1-l),c[d]=Math.round(t*255),c[d+1]=Math.round(n*255),c[d+2]=Math.round(r*255),c[d+3]=255}else{let e=R(a,u/o,t);c[d]=Math.round(e.r*255),c[d+1]=Math.round(e.g*255),c[d+2]=Math.round(e.b*255),c[d+3]=255}}}return i.putImageData(s,0,0),r}function de(e,t){let n=t/2,r=n-2,i=r-9;if(O(re)===`rgb`){let t=(Math.atan2(O(M)-O(j),O(j)-O(P))*180/Math.PI+90+360)%360,a=n+Math.cos((t-90)*Math.PI/180)*(r-4.5),o=n+Math.sin((t-90)*Math.PI/180)*(r-4.5);e.strokeStyle=`#fff`,e.lineWidth=2,e.beginPath(),e.arc(a,o,4,0,Math.PI*2),e.stroke(),e.strokeStyle=`#000`,e.lineWidth=1,e.beginPath(),e.arc(a,o,5,0,Math.PI*2),e.stroke();let s=Math.sqrt(O(j)*O(j)+O(M)*O(M)+O(P)*O(P))/Math.sqrt(3),c=n+Math.cos((t-90)*Math.PI/180)*(s*i),l=n+Math.sin((t-90)*Math.PI/180)*(s*i);e.strokeStyle=`#fff`,e.lineWidth=2,e.beginPath(),e.arc(c,l,6,0,Math.PI*2),e.stroke(),e.strokeStyle=`#000`,e.lineWidth=1,e.beginPath(),e.arc(c,l,7,0,Math.PI*2),e.stroke()}else{let t=n+Math.cos((O(ee)-90)*Math.PI/180)*(r-4.5),a=n+Math.sin((O(ee)-90)*Math.PI/180)*(r-4.5);e.strokeStyle=`#fff`,e.lineWidth=2,e.beginPath(),e.arc(t,a,4,0,Math.PI*2),e.stroke(),e.strokeStyle=`#000`,e.lineWidth=1,e.beginPath(),e.arc(t,a,5,0,Math.PI*2),e.stroke();let o=n+Math.cos((O(ee)-90)*Math.PI/180)*(O(te)*i),s=n+Math.sin((O(ee)-90)*Math.PI/180)*(O(te)*i);e.strokeStyle=`#fff`,e.lineWidth=2,e.beginPath(),e.arc(o,s,6,0,Math.PI*2),e.stroke(),e.strokeStyle=`#000`,e.lineWidth=1,e.beginPath(),e.arc(o,s,7,0,Math.PI*2),e.stroke()}}function fe(){if(!O(_)||!O(g))return;let e=O(g).width;(!b||b.width!==e)&&(b=ue(e)),(!C||C.width!==e||T!==O(A)||D!==O(re))&&(C=U(e,O(A),O(re)),T=O(A),D=O(re)),O(_).clearRect(0,0,e,e),O(_).drawImage(C,0,0),O(_).drawImage(b,0,0),de(O(_),e)}function W(e){if(e.stopPropagation(),!O(g))return;let t=O(g).getBoundingClientRect(),n=O(g).width/t.width,r=O(g).height/t.height,i=(e.clientX-t.left)*n,a=(e.clientY-t.top)*r,o=O(g).width/2,s=i-o,c=a-o,l=Math.sqrt(s*s+c*c),u=o-2,d=u-9,f=(Math.atan2(c,s)*180/Math.PI+90+360)%360;if(O(re)===`rgb`){if(l<=u&&l>d){let e=f/360,t=0,n=0,r=0;if(e<1/3){let i=e*3;t=1-i,n=i,r=0}else if(e<2/3){let i=(e-1/3)*3;t=0,n=1-i,r=i}else{let i=(e-2/3)*3;t=i,n=0,r=1-i}Y(j,t),Y(M,n),Y(P,r),H()}else if(l<=d){let e=f/360,t=0,n=0,r=0;if(e<1/3){let i=e*3;t=1-i,n=i,r=0}else if(e<2/3){let i=(e-1/3)*3;t=0,n=1-i,r=i}else{let i=(e-2/3)*3;t=i,n=0,r=1-i}let i=l/d,a=1-i;t*=a,n*=a,r=r*a+i;let o=l/d;t=t*o+(1-o),n=n*o+(1-o),r=r*o+(1-o),Y(j,Math.max(0,Math.min(1,t))),Y(M,Math.max(0,Math.min(1,n))),Y(P,Math.max(0,Math.min(1,r))),H()}}else l<=u&&l>d?(Y(ee,f),V()):l<=d&&(Y(ee,f),Y(te,Math.min(1,l/d)),V())}function me(e,t){let n=parseFloat(t.target.value)/255;e===`r`&&Y(j,Math.max(0,Math.min(1,n))),e===`g`&&Y(M,Math.max(0,Math.min(1,n))),e===`b`&&Y(P,Math.max(0,Math.min(1,n))),H()}function K(e,t){let n=parseFloat(t.target.value);e===`h`&&Y(ee,Math.max(0,Math.min(360,n))),e===`s`&&Y(te,Math.max(0,Math.min(1,n/100))),e===`v`&&Y(A,Math.max(0,Math.min(1,n/100))),V()}function _e(e){let t=e.target.value;if(/^#([0-9A-F]{3}|[0-9A-F]{6})$/i.test(t)){let e=Vc(t);ce(e),l()(e)}}function ve(e){Y(ne,O(F));let t=Vc(e);ce(t),l()(t)}function ye(){let e=O(ne);Y(ne,O(F));let t=Vc(e);ce(t),l()(t)}function be(e){O(h)&&!O(h).contains(e.target)&&(Y(d,!1),zg.set(null))}he(()=>(a().value&&ce(a().value),p=zg.subscribe(e=>{e!==s()&&O(d)&&Y(d,!1)}),setTimeout(()=>{O(g)&&(Y(_,O(g).getContext(`2d`)),O(_)&&fe())},0),document.addEventListener(`click`,be),()=>{p&&p(),document.removeEventListener(`click`,be)}));let xe=I(null);e(()=>(O(d),O(g),O(xe),O(_)),()=>{O(d)&&O(g)&&(O(xe)&&clearTimeout(O(xe)),O(_)||Y(_,O(g).getContext(`2d`)),O(_)&&Y(xe,setTimeout(()=>{O(g)&&O(_)&&fe()},50)))}),e(()=>(k(a()),O(F)),()=>{if(a().value){let e=Vc(a().value);Uc(e)!==O(F)&&ce(e)}}),e(()=>(O(re),O(_),O(g)),()=>{O(re)&&O(_)&&O(g)&&fe()}),ie(),le();var Se=Wg(),Ce=q(Se),we=G(Ce,2),Te=e=>{var t=Ug(),r=q(t),a=q(r);let l;var d=G(a,2);let p;w(r);var b=G(r,2),S=q(b),C=q(S);N(C,`width`,180),N(C,`height`,180),pe(C,e=>Y(g,e),()=>O(g)),w(S);var T=G(S,2),D=q(T),k=e=>{var t=Bg(),n=B(t),r=q(n),i=G(r,2);Ee(i);var a=G(i,2);Ee(a),w(n);var o=G(n,2),c=q(o),l=G(c,2);Ee(l);var u=G(l,2);Ee(u),w(o);var d=G(o,2),p=q(d),m=G(p,2);Ee(m);var h=G(m,2);Ee(h),w(d),J((e,t,n,o,d,f)=>{N(r,`for`,`${s()}-h`),N(i,`id`,`${s()}-h`),x(i,e),x(a,t),N(c,`for`,`${s()}-s`),N(l,`id`,`${s()}-s`),x(l,n),x(u,o),N(p,`for`,`${s()}-v`),N(m,`id`,`${s()}-v`),x(m,d),x(h,f)},[()=>(O(ee),y(()=>Math.round(O(ee)))),()=>(O(ee),y(()=>Math.round(O(ee)))),()=>(O(te),y(()=>Math.round(O(te)*100))),()=>(O(te),y(()=>Math.round(O(te)*100))),()=>(O(A),y(()=>Math.round(O(A)*100))),()=>(O(A),y(()=>Math.round(O(A)*100)))]),f(`input`,i,e=>K(`h`,e)),f(`input`,a,e=>K(`h`,e)),f(`input`,l,e=>K(`s`,e)),f(`input`,u,e=>K(`s`,e)),f(`input`,m,e=>K(`v`,e)),f(`input`,h,e=>K(`v`,e)),E(e,t)},I=e=>{var t=Vg(),n=B(t),r=q(n),i=G(r,2);Ee(i);var a=G(i,2);Ee(a),w(n);var o=G(n,2),c=q(o),l=G(c,2);Ee(l);var u=G(l,2);Ee(u),w(o);var d=G(o,2),p=q(d),m=G(p,2);Ee(m);var h=G(m,2);Ee(h),w(d),J((e,t,n,o,d,f)=>{N(r,`for`,`${s()}-r`),N(i,`id`,`${s()}-r`),x(i,e),x(a,t),N(c,`for`,`${s()}-g`),N(l,`id`,`${s()}-g`),x(l,n),x(u,o),N(p,`for`,`${s()}-b`),N(m,`id`,`${s()}-b`),x(m,d),x(h,f)},[()=>(O(j),y(()=>Math.round(O(j)*255))),()=>(O(j),y(()=>Math.round(O(j)*255))),()=>(O(M),y(()=>Math.round(O(M)*255))),()=>(O(M),y(()=>Math.round(O(M)*255))),()=>(O(P),y(()=>Math.round(O(P)*255))),()=>(O(P),y(()=>Math.round(O(P)*255)))]),f(`input`,i,e=>me(`r`,e)),f(`input`,a,e=>me(`r`,e)),f(`input`,l,e=>me(`g`,e)),f(`input`,u,e=>me(`g`,e)),f(`input`,m,e=>me(`b`,e)),f(`input`,h,e=>me(`b`,e)),E(e,t)};m(D,e=>{O(re)===`hsv`?e(k):e(I,-1)});var ie=G(D,2),oe=q(ie),R=G(oe,2);Ee(R),w(ie),w(T);var se=G(T,2),z=q(se),ce=q(z),V=G(ce,2);w(z);var le=G(z,2);v(le,5,()=>L,c,(e,t)=>{var n=u(),r=B(n);v(r,1,()=>O(t),c,(e,t)=>{var n=Hg();J(()=>{o(n,`background-color: ${O(t)??``};`),N(n,`aria-label`,`Choose ${O(t)}`)}),f(`click`,n,()=>ve(O(t))),E(e,n)}),E(e,n)}),w(le),w(se),w(b),w(t),pe(t,e=>Y(h,e),()=>O(h)),J(()=>{l=i(a,1,`mode-button svelte-1hwwwsb`,null,l,{active:O(re)===`hsv`}),p=i(d,1,`mode-button svelte-1hwwwsb`,null,p,{active:O(re)===`rgb`}),N(oe,`for`,`${s()}-hex`),N(R,`id`,`${s()}-hex`),x(R,O(F)),o(ce,`background-color: ${O(ne)??``};`),o(V,`background-color: ${O(F)??``};`)}),f(`click`,a,()=>{Y(re,`hsv`),O(_)&&O(g)&&fe()}),f(`click`,d,()=>{Y(re,`rgb`),O(_)&&O(g)&&fe()}),f(`click`,C,ae(W)),f(`mousedown`,C,ae(e=>{W(e)})),f(`mousemove`,C,ae(e=>{e.buttons===1&&W(e)})),f(`input`,R,_e),f(`click`,ce,ye),f(`click`,t,ae(function(e){ge.call(this,n,e)})),f(`keydown`,t,ae(function(e){ge.call(this,n,e)})),E(e,t)};m(we,e=>{O(d)&&e(Te)}),w(Se),J((e,t)=>{o(Ce,`background-color: ${e??``};`),Ce.disabled=t},[()=>(k(Hc),O(j),O(M),O(P),y(()=>Hc({r:O(j),g:O(M),b:O(P),a:1}))),()=>(k(a()),y(()=>typeof a().disabled==`function`?a().disabled():a().disabled))]),f(`click`,Ce,ae(()=>{O(d)?(Y(d,!1),zg.set(null)):(zg.set(s()),Y(d,!0),O(g)&&!O(_)&&Y(_,O(g).getContext(`2d`)))})),E(t,Se),S()}var Kg=T(`<button class="clear-button svelte-1lbwdc6" title="Clear file">×</button>`),qg=T(`<div class="file-info svelte-1lbwdc6"><span class="file-name svelte-1lbwdc6"> </span></div>`),Jg=T(`<div class="preview-container svelte-1lbwdc6"><img alt="Preview" class="preview-image svelte-1lbwdc6"/></div>`),Yg=T(`<div class="preview-container svelte-1lbwdc6"><video class="preview-video svelte-1lbwdc6" controls=""></video></div>`,2),Xg=T(`<span class="drop-hint svelte-1lbwdc6">Drop file here</span>`),Zg=T(`<div class="file-input-container svelte-1lbwdc6"><div class="file-controls svelte-1lbwdc6"><input type="file" style="display: none;"/> <button class="file-button svelte-1lbwdc6">Choose File</button> <!></div> <!> <!> <div role="region" aria-label="File drop zone"><!></div></div>`);function Qg(t,n){r(n,!1);let a=I(),o=I(),s=I(),c=z(n,`prop`,8),l=z(n,`id`,8),u=z(n,`onValueChange`,8),d=I(),p=I(null),h=I(`none`);function g(e){let t=e.target.files?.[0];t&&((t.type.startsWith(`image/`)||t.type.startsWith(`video/`))&&(Y(p,URL.createObjectURL(t)),Y(h,t.type.startsWith(`image/`)?`image`:`video`)),u()(t.name))}function _(){O(p)&&O(p).startsWith(`blob:`)&&URL.revokeObjectURL(O(p)),Y(p,null),Y(h,`none`),u()(``),O(d)&&H(d,O(d).value=``)}function v(e){e.preventDefault();let t=e.dataTransfer?.files[0];t&&((t.type.startsWith(`image/`)||t.type.startsWith(`video/`))&&(Y(p,URL.createObjectURL(t)),Y(h,t.type.startsWith(`image/`)?`image`:`video`)),u()(t.name))}function y(e){e.preventDefault()}e(()=>k(c()),()=>{Y(a,typeof c().value==`string`?c().value:``)}),e(()=>k(c()),()=>{Y(o,c().params?.accept||`*/*`)}),e(()=>k(c()),()=>{Y(s,typeof c().disabled==`function`?c().disabled():c().disabled)}),e(()=>O(a),()=>{if(O(a)){let e=/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(O(a))||O(a).startsWith(`data:image/`),t=/\.(mp4|webm|mov)$/i.test(O(a))||O(a).startsWith(`data:video/`);e?(Y(h,`image`),Y(p,(O(a).startsWith(`data:`)||O(a).startsWith(`http`),O(a)))):t?(Y(h,`video`),Y(p,(O(a).startsWith(`data:`)||O(a).startsWith(`http`),O(a)))):(Y(h,`none`),Y(p,null))}else Y(h,`none`),Y(p,null)}),ie(),le();var b=Zg(),x=q(b),C=q(x);pe(C,e=>Y(d,e),()=>O(d));var T=G(C,2),D=G(T,2),ee=e=>{var t=Kg();J(()=>t.disabled=O(s)),f(`click`,t,_),E(e,t)};m(D,e=>{O(a)&&e(ee)}),w(x);var te=G(x,2),A=e=>{var t=qg(),n=q(t),r=M(n,!0);w(t),J(()=>{N(n,`title`,O(a)),X(r,O(a))}),E(e,t)};m(te,e=>{O(a)&&e(A)});var j=G(te,2),P=e=>{var t=Jg(),n=M(t);J(()=>N(n,`src`,O(p))),E(e,t)},F=e=>{var t=Yg(),n=M(t);J(()=>N(n,`src`,O(p))),E(e,t)};m(j,e=>{O(h)===`image`&&O(p)?e(P):O(h)===`video`&&O(p)&&e(F,1)});var ne=G(j,2);let re;var ae=q(ne),L=e=>{var t=Xg();E(e,t)};m(ae,e=>{O(a)||e(L)}),w(ne),w(b),J(()=>{N(C,`id`,l()),N(C,`accept`,O(o)),C.disabled=O(s),T.disabled=O(s),re=i(ne,1,`drop-zone svelte-1lbwdc6`,null,re,{"has-preview":O(h)!==`none`})}),f(`change`,C,g),f(`click`,T,()=>O(d)?.click()),f(`drop`,ne,v),f(`dragover`,ne,y),E(t,b),S()}var $g=T(`<div class="search-box svelte-bczi6w"><input type="text" class="search-input svelte-bczi6w" placeholder="Search..."/></div>`),e_=T(`<div class="option-group-header svelte-bczi6w"> </div>`),t_=T(`<button> </button>`),n_=T(`<!> <!>`,1),r_=T(`<div class="no-results svelte-bczi6w">No results</div>`),i_=T(`<div class="dropdown-menu svelte-bczi6w"><!> <div class="options-list svelte-bczi6w"><!> <!></div></div>`),a_=T(`<div class="select-input-container svelte-bczi6w"><button><span class="select-value svelte-bczi6w"></span> <svg class="dropdown-icon svelte-bczi6w" width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M3 4.5L6 7.5L9 4.5" stroke-linecap="round" stroke-linejoin="round"></path></svg></button> <!></div>`);function o_(t,n){r(n,!1);let a=I(),o=I(),s=I(),d=I(),p=I(),h=I(),g=z(n,`prop`,8);z(n,`id`,8);let _=z(n,`onValueChange`,8),b=I(!1),x=I(``),C=I();function T(e){let t=typeof e==`object`&&`value`in e?e.value:e;_()(t),Y(b,!1),Y(x,``)}function D(e){O(C)&&!O(C).contains(e.target)&&(Y(b,!1),Y(x,``))}function ee(e){e.key===`Escape`&&(Y(b,!1),Y(x,``))}e(()=>k(g()),()=>{Y(a,g().value)}),e(()=>k(g()),()=>{Y(o,g().params?.options||[])}),e(()=>k(g()),()=>{Y(s,typeof g().disabled==`function`?g().disabled():g().disabled)}),e(()=>(O(x),O(o)),()=>{Y(d,O(x)?O(o).filter(e=>(typeof e==`object`&&`label`in e?e.label:String(e)).toLowerCase().includes(O(x).toLowerCase())):O(o))}),e(()=>O(d),()=>{Y(p,(()=>{let e=new Map,t=[];for(let n of O(d))typeof n==`object`&&`group`in n&&n.group?(e.has(n.group)||e.set(n.group,[]),e.get(n.group).push(n)):t.push(n);let n=Array.from(e.entries()).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({group:e,options:t.sort((e,t)=>{let n=typeof e==`object`&&`label`in e?e.label:String(e),r=typeof t==`object`&&`label`in t?t.label:String(t);return n.localeCompare(r)})}));return t.length>0&&n.push({group:``,options:t}),n})())}),e(()=>O(p),()=>{Y(h,O(p).some(e=>e.group!==``))}),ie(),le();var A=a_();f(`click`,fe,D),f(`keydown`,fe,ee);var j=q(A);let N;var P=q(j);v(P,5,()=>O(o),c,(e,t)=>{let n=L(()=>(O(t),y(()=>typeof O(t)==`object`&&`value`in O(t)?O(t).value:O(t)))),r=L(()=>(O(t),y(()=>typeof O(t)==`object`&&`label`in O(t)?O(t).label:String(O(t)))));var i=u(),o=B(i),s=e=>{var t=l();J(()=>X(t,O(r))),E(e,t)},c=me(()=>(k(O(n)),O(a),y(()=>String(O(n))===String(O(a)))));m(o,e=>{O(c)&&e(s)}),E(e,i)}),w(P),Ce(2),w(j);var F=G(j,2),ne=e=>{var t=i_(),r=q(t),s=e=>{var t=$g(),r=q(t);Ee(r),w(t),te(r,()=>O(x),e=>Y(x,e)),f(`click`,r,ae(function(e){ge.call(this,n,e)})),E(e,t)};m(r,e=>{O(o),y(()=>O(o).length>5)&&e(s)});var l=G(r,2),g=q(l),_=e=>{var t=u(),n=B(t);v(n,1,()=>O(p),c,(e,t)=>{let n=()=>O(t).group,r=()=>O(t).options;var o=n_(),s=B(o),l=e=>{var t=e_(),r=M(t,!0);J(()=>X(r,n())),E(e,t)};m(s,e=>{n()&&e(l)});var u=G(s,2);v(u,1,r,c,(e,t)=>{let r=L(()=>(O(t),y(()=>typeof O(t)==`object`&&`value`in O(t)?O(t).value:O(t)))),o=L(()=>(O(t),y(()=>typeof O(t)==`object`&&`label`in O(t)?O(t).label:String(O(t))))),s=L(()=>(O(t),y(()=>typeof O(t)==`object`&&`disabled`in O(t)&&O(t).disabled)));var c=t_();let l;var u=M(c,!0);J(e=>{l=i(c,1,`option-item svelte-bczi6w`,null,l,{selected:e,grouped:!!n()}),c.disabled=O(s),X(u,O(o))},[()=>String(O(r))===String(O(a))]),f(`click`,c,()=>T(O(t))),E(e,c)}),E(e,o)}),E(e,t)},b=e=>{var t=u(),n=B(t);v(n,1,()=>O(d),c,(e,t)=>{let n=L(()=>(O(t),y(()=>typeof O(t)==`object`&&`value`in O(t)?O(t).value:O(t)))),r=L(()=>(O(t),y(()=>typeof O(t)==`object`&&`label`in O(t)?O(t).label:String(O(t))))),o=L(()=>(O(t),y(()=>typeof O(t)==`object`&&`disabled`in O(t)&&O(t).disabled)));var s=t_();let c;var l=M(s,!0);J(e=>{c=i(s,1,`option-item svelte-bczi6w`,null,c,{selected:e}),s.disabled=O(o),X(l,O(r))},[()=>String(O(n))===String(O(a))]),f(`click`,s,()=>T(O(t))),E(e,s)}),E(e,t)};m(g,e=>{O(h)?e(_):e(b,-1)});var S=G(g,2),C=e=>{var t=r_();E(e,t)};m(S,e=>{O(d),y(()=>O(d).length===0)&&e(C)}),w(l),w(t),E(e,t)};m(F,e=>{O(b),O(o),y(()=>O(b)&&O(o).length>0)&&e(ne)}),w(A),pe(A,e=>Y(C,e),()=>O(C)),J(()=>{N=i(j,1,`select-button svelte-bczi6w`,null,N,{open:O(b)}),j.disabled=O(s)}),f(`click`,j,()=>{O(s)||(Y(b,!O(b)),O(b)&&Y(x,``))}),E(t,A),S()}var s_=T(`<span class="loading-spinner svelte-17d1c14"></span>`),c_=T(`<span> </span>`),l_=T(`<!> <!>`,1),u_=T(`<button><!></button>`);function d_(t,n){r(n,!1);let a=I(),o=I(),s=I(),c=I(),l=I(),u=z(n,`prop`,8),d=z(n,`id`,8),p=z(n,`onValueChange`,8),h=I(!1);async function g(){Y(h,!0);try{p()(!0)}catch(e){console.error(`[ButtonInput] Error:`,e)}finally{Y(h,!1)}}e(()=>k(u()),()=>{Y(a,typeof u().disabled==`function`?u().disabled():u().disabled)}),e(()=>k(u()),()=>{Y(o,typeof u().value==`string`?u().value:u().displayName||`Execute`)}),e(()=>k(u()),()=>{Y(s,u().params?.small??!1)}),e(()=>k(u()),()=>{Y(c,u().params?.icon)}),e(()=>k(u()),()=>{Y(l,u().params?.tooltip)}),ie(),le();var _=u_();let v;var b=q(_),x=e=>{var t=s_();E(e,t)},C=e=>{var t=l_(),n=B(t);{let e=L(()=>O(s)?14:16);Ac(n,{get name(){return O(c)},get size(){return O(e)}})}var r=G(n,2),i=e=>{var t=c_(),n=M(t,!0);J(()=>X(n,O(o))),E(e,t)};m(r,e=>{O(o),k(u()),y(()=>O(o)&&!u().params?.iconOnly)&&e(i)}),E(e,t)},T=e=>{var t=c_(),n=M(t,!0);J(()=>X(n,O(o))),E(e,t)};m(b,e=>{O(h)?e(x):O(c)?e(C,1):e(T,-1)}),w(_),J(()=>{N(_,`id`,d()),v=i(_,1,`button-input svelte-17d1c14`,null,v,{small:O(s),"icon-only":O(c)&&!O(o)}),_.disabled=O(a)||O(h),N(_,`title`,O(l))}),f(`click`,_,g),E(t,_),S()}var f_=T(`<label class="checkbox-label svelte-16zsb4p"><input type="checkbox" class="checkbox-input svelte-16zsb4p"/> <span class="checkbox-slider svelte-16zsb4p"></span> <span class="checkbox-text svelte-16zsb4p"> </span></label>`);function p_(t,n){r(n,!1);let i=I(),a=I(),o=z(n,`prop`,8),s=z(n,`id`,8),c=z(n,`onValueChange`,8);function l(e){let t=e.target.checked;c()(t)}e(()=>k(o()),()=>{Y(i,o().value===!0)}),e(()=>k(o()),()=>{Y(a,typeof o().disabled==`function`?o().disabled():o().disabled)}),ie(),le();var u=f_(),d=q(u);Ee(d);var p=G(d,4),m=M(p,!0);w(u),J(()=>{N(d,`id`,s()),we(d,O(i)),d.disabled=O(a),X(m,O(i)?`On`:`Off`)}),f(`change`,d,l),E(t,u),S()}var m_=T(`<div class="folder-content svelte-1spr549"><!></div>`),h_=T(`<div class="folder-group svelte-1spr549"><button class="folder-header svelte-1spr549"><svg width="10" height="10" viewBox="0 0 10 10" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M2 3L5 1L8 3" stroke-linecap="round" stroke-linejoin="round"></path></svg> <span class="folder-name svelte-1spr549"> </span></button> <!></div>`);function g_(e,t){r(t,!1);let n=z(t,`folderName`,8),a=z(t,`isExpanded`,8,!0),o=ve();function s(){o(`toggle`)}le();var c=h_(),l=q(c),u=q(l);let d;var p=G(u,2),g=M(p,!0);w(l);var _=G(l,2),v=e=>{var n=m_(),r=q(n);h(r,t,`default`,{},null),w(n),E(e,n)};m(_,e=>{a()&&e(v)}),w(c),J(()=>{d=i(u,0,`folder-icon svelte-1spr549`,null,d,{expanded:a()}),X(g,n())}),f(`click`,l,s),E(e,c),S()}var __=T(`<button type="button" class="color-swatch svelte-kla7jy"><div class="swatch-color svelte-kla7jy"></div></button>`),v_=T(`<div class="ramp-handle svelte-kla7jy" role="slider" tabindex="0" aria-label="Color stop position" aria-valuemin="0" aria-valuemax="1"></div>`),y_=T(`<option> </option>`),b_=T(`<div class="table-row svelte-kla7jy"><input type="number" class="position-input svelte-kla7jy" min="0" max="1" step="0.001"/> <button type="button" class="color-cell svelte-kla7jy"></button> <select class="interpolation-select svelte-kla7jy"></select> <div class="table-row-actions svelte-kla7jy"><button class="icon-button svelte-kla7jy" title="Add Point">+</button> <button class="icon-button delete-button svelte-kla7jy" title="Delete Point">×</button></div></div>`),x_=T(`<div class="color-picker-overlay svelte-kla7jy"><div class="color-picker-container svelte-kla7jy" role="dialog" aria-modal="true" aria-label="Edit color stop"><!></div></div>`),S_=T(`<div class="color-ramp-editor svelte-kla7jy"><div class="ramp-header svelte-kla7jy"><span class="ramp-label svelte-kla7jy"> </span> <label class="auto-update-label svelte-kla7jy"><input type="checkbox"/> Auto-update</label></div> <div class="ramp-visualization svelte-kla7jy"><canvas class="ramp-canvas svelte-kla7jy"></canvas> <div class="color-swatches svelte-kla7jy"></div> <div class="ramp-handles svelte-kla7jy"></div></div> <div class="ramp-points-table svelte-kla7jy"><div class="table-header svelte-kla7jy"><span>Position</span> <span>Color</span> <span>Interp.</span> <span class="table-actions svelte-kla7jy"><button class="icon-button svelte-kla7jy" title="Add Point">+</button></span></div> <!></div> <!></div>`);function C_(t,n){r(n,!1);let i=z(n,`prop`,8),a=z(n,`id`,8),s=z(n,`onValueChange`,8),l=I([]),u=I(!0),d=I(),p=null,h=I(null),g=I(0),_=I(null),b=I(!1);function T(e){O(b)&&e.key===`Escape`&&Y(b,!1)}let D=[{value:`linear`,label:`Linear`},{value:`constant`,label:`Constant`},{value:`smooth`,label:`Smooth`}];function ee(){Array.isArray(i().value)&&i().value.length>0?Y(l,i().value.map(e=>({position:e.position,color:(e.color,Vc(e.color)),interpolation:e.interpolation||`linear`})).sort((e,t)=>e.position-t.position)):Y(l,[{position:0,color:{r:0,g:0,b:0},interpolation:`linear`},{position:1,color:{r:1,g:1,b:1},interpolation:`linear`}]),te()}function te(){if(!p||!O(d))return;let e=O(d).width,t=O(d).height;p.clearRect(0,0,e,t);let n=p.createLinearGradient(0,0,e,0),r=[...O(l)].sort((e,t)=>e.position-t.position);for(let e of r)n.addColorStop(e.position,Hc(e.color));p.fillStyle=n,p.fillRect(0,0,e,t);for(let t=0;t<r.length;t++){let n=r[t],i=n.position*e;p.fillStyle=Hc(n.color),p.fillRect(i-6,-14,12,12),p.strokeStyle=`#ffffff`,p.lineWidth=1,p.strokeRect(i-6,-14,12,12)}let i=t+2;for(let t=0;t<r.length;t++){let n=r[t].position*e;p.fillStyle=`#888888`,p.beginPath(),p.moveTo(n,i),p.lineTo(n-4,i+6),p.lineTo(n+4,i+6),p.closePath(),p.fill()}}function A(e){let t=O(d).getBoundingClientRect(),n=e-t.left;Math.max(0,Math.min(1,n/t.width));let r=[...O(l)].sort((e,t)=>e.position-t.position);for(let e=0;e<r.length;e++){let i=r[e],a=i.position*t.width;if(Math.abs(n-a)<10)return O(l).indexOf(i)}return null}function j(e){if(!O(d))return;let t=O(d).getBoundingClientRect(),n=e.clientX-t.left,r=Math.max(0,Math.min(1,n/t.width)),i=A(e.clientX);i===null?e.button===0&&re(r):(Y(h,i),Y(g,e.clientX))}function P(e){if(O(h)!==null&&O(d)){let t=O(d).getBoundingClientRect(),n=e.clientX-t.left,r=Math.max(0,Math.min(1,n/t.width));H(l,O(l)[O(h)].position=r),O(l).sort((e,t)=>e.position-t.position),te(),O(u)&&s()([...O(l)])}}function F(){O(h)!==null&&(Y(h,null),O(u)||s()([...O(l)]))}function re(e){let t=[...O(l)].sort((e,t)=>e.position-t.position),n={r:.5,g:.5,b:.5};for(let r=0;r<t.length-1;r++)if(e>=t[r].position&&e<=t[r+1].position){let i=(e-t[r].position)/(t[r+1].position-t[r].position),a=t[r].color,o=t[r+1].color;n={r:a.r+(o.r-a.r)*i,g:a.g+(o.g-a.g)*i,b:a.b+(o.b-a.b)*i};break}O(l).push({position:e,color:n,interpolation:`linear`}),O(l).sort((e,t)=>e.position-t.position),te(),s()([...O(l)])}function oe(e){O(l).length<=2||(O(l).splice(e,1),te(),s()([...O(l)]))}function se(e,t){H(l,O(l)[e].color=t),te(),s()([...O(l)])}function B(e,t){H(l,O(l)[e].interpolation=t),te(),s()([...O(l)])}function ce(e,t){H(l,O(l)[e].position=Math.max(0,Math.min(1,t))),O(l).sort((e,t)=>e.position-t.position),te(),s()([...O(l)])}function V(e,t){let n=t.key===`ArrowLeft`?-.01:t.key===`ArrowRight`?.01:0;n&&(t.preventDefault(),ce(e,O(l)[e].position+n))}he(()=>(ee(),O(d)&&(p=O(d).getContext(`2d`),H(d,O(d).width=O(d).offsetWidth),H(d,O(d).height=20),te()),window.addEventListener(`mousemove`,P),window.addEventListener(`mouseup`,F),()=>{window.removeEventListener(`mousemove`,P),window.removeEventListener(`mouseup`,F)})),e(()=>k(i()),()=>{i().value&&ee()}),ie(),le();var ue=S_();f(`keydown`,fe,T);var U=q(ue),de=q(U),W=M(de,!0),me=G(de,2),K=q(me);Ee(K),Ce(),w(me),w(U);var ge=G(U,2),_e=q(ge);pe(_e,e=>Y(d,e),()=>O(d));var ve=G(_e,2);v(ve,5,()=>(O(l),y(()=>O(l).sort((e,t)=>e.position-t.position))),c,(e,t)=>{let n=L(()=>(O(l),O(t),y(()=>O(l).indexOf(O(t)))));var r=__(),i=M(r);J(e=>{o(r,`left: ${O(t),y(()=>O(t).position*100)??``}%`),N(r,`aria-label`,e),o(i,`background-color: ${O(t),y(()=>O(t).color)??``}`)},[()=>(O(t),y(()=>`Edit color stop at ${Math.round(O(t).position*100)}%`))]),f(`click`,r,()=>{Y(_,O(n)),Y(b,!0)}),E(e,r)}),w(ve);var be=G(ve,2);v(be,5,()=>(O(l),y(()=>O(l).sort((e,t)=>e.position-t.position))),c,(e,t)=>{let n=L(()=>(O(l),O(t),y(()=>O(l).indexOf(O(t)))));var r=v_();J(()=>{o(r,`left: ${O(t),y(()=>O(t).position*100)??``}%`),N(r,`aria-valuenow`,(O(t),y(()=>O(t).position)))}),f(`keydown`,r,e=>V(O(n),e)),f(`mousedown`,r,ae(e=>{Y(h,O(n)),Y(g,e.clientX)})),E(e,r)}),w(be),w(ge);var xe=G(ge,2),we=q(xe),Te=G(q(we),6),De=M(Te);w(we);var Oe=G(we,2);v(Oe,1,()=>(O(l),y(()=>O(l).sort((e,t)=>e.position-t.position))),c,(e,t)=>{let n=L(()=>(O(l),O(t),y(()=>O(l).indexOf(O(t)))));var r=b_(),i=q(r);Ee(i);var a=G(i,2),s=G(a,2);v(s,5,()=>D,c,(e,t)=>{var n=y_(),r=M(n,!0),i={};J(()=>{X(r,(O(t),y(()=>O(t).label))),i!==(i=(O(t),y(()=>O(t).value)))&&(n.value=(n.__value=i)??``)}),E(e,n)}),w(s);var u;Se(s);var d=G(s,2),p=q(d),m=G(p,2);w(d),w(r),J((e,n)=>{x(i,e),o(a,`background-color: ${O(t),y(()=>O(t).color)??``}`),N(a,`aria-label`,n),u!==(u=(O(t),y(()=>O(t).interpolation)))&&(s.value=(s.__value=u)??``,C(s,u)),m.disabled=(O(l),y(()=>O(l).length<=2))},[()=>(O(t),y(()=>O(t).position.toFixed(3))),()=>(O(t),y(()=>`Edit color stop at ${Math.round(O(t).position*100)}%`))]),f(`input`,i,e=>{let t=e.target;if(t instanceof HTMLInputElement){let e=parseFloat(t.value);ce(O(n),e)}}),f(`click`,a,()=>{Y(_,O(n)),Y(b,!0)}),f(`change`,s,e=>{let t=e.target;t instanceof HTMLSelectElement&&B(O(n),t.value)}),f(`click`,p,()=>re((O(t).position+(O(l)[O(n)+1]?.position||1))/2)),f(`click`,m,()=>oe(O(n))),E(e,r)}),w(xe);var ke=G(xe,2),Ae=e=>{var t=x_(),n=q(t),r=q(n);{let e=L(()=>(O(l),O(_),y(()=>({value:O(l)[O(_)].color,type:`color`})))),t=L(()=>`${a()}-color-picker`);Gg(r,{get prop(){return O(e)},get id(){return O(t)},onValueChange:e=>{O(_)!==null&&se(O(_),e),Y(b,!1)}})}w(n),w(t),f(`click`,t,ne(()=>Y(b,!1))),E(e,t)};m(ke,e=>{O(b)&&O(_)!==null&&e(Ae)}),w(ue),J(()=>X(W,(k(i()),y(()=>i().displayName||`Ramp`)))),R(K,()=>O(u),e=>Y(u,e)),f(`mousedown`,_e,j),f(`contextmenu`,_e,ye(e=>{if(A(e.clientX)===null){let t=O(d).getBoundingClientRect(),n=e.clientX-t.left;re(Math.max(0,Math.min(1,n/t.width)))}})),f(`click`,De,()=>re(.5)),E(t,ue),S()}var w_=T(`<button><span class="item-type svelte-10p3942"> </span> <span class="item-label svelte-10p3942"> </span></button>`),T_=T(`<div class="autocomplete-dropdown svelte-10p3942"></div>`),E_=T(`<div class="expression-input-container svelte-10p3942"><input type="text" placeholder="e.g., ch('../node/value') * 2"/> <!></div>`),D_=T(`<button class="expression-display svelte-10p3942" title="Click to edit expression"><span class="expression-code svelte-10p3942"> </span></button>`),O_=T(`<span class="expression-error svelte-10p3942"><!></span>`),k_=T(`<button class="evaluated-badge svelte-10p3942"> </button>`),A_=T(`<div class="expression-view svelte-10p3942"><!> <div class="expression-actions svelte-10p3942"><!> <button class="remove-expression svelte-10p3942" title="Remove expression"><!></button></div></div>`),j_=T(`<button class="toggle-to-expression svelte-10p3942" title="Click to see expression"><!></button>`),M_=T(`<button class="add-expression svelte-10p3942" title="Add expression"><!></button>`),N_=T(`<div><!> <!></div>`),P_=T(`<div><!></div>`);function F_(t,n){r(n,!1);let a=I(),o=I(),s=I(),l=I(),u=z(n,`prop`,8),d=z(n,`propKey`,8),p=z(n,`node`,8);z(n,`onValueChange`,8);let g=I(`value`),_=I(!1),b=I(u().expression||``),x=I(),C=I(!1),T=I([]),D=I(0),ee=0;function A(e){return e==null?`—`:typeof e==`number`?Number.isInteger(e)?String(e):e.toFixed(4).replace(/\.?0+$/,``):Array.isArray(e)?`[${e.map(e=>typeof e==`number`?Number.isInteger(e)?e:e.toFixed(2):e).join(`, `)}]`:typeof e==`boolean`?e?`true`:`false`:typeof e==`string`?e.length>30?e.slice(0,27)+`...`:e:typeof e==`object`&&e?`r`in e&&`g`in e&&`b`in e?`rgb(${Math.round(e.r*255)}, ${Math.round(e.g*255)}, ${Math.round(e.b*255)})`:JSON.stringify(e).slice(0,30):String(e)}let j=[{label:`ch(path)`,value:`ch("")`,type:`func`,desc:`Get parameter as number`},{label:`chs(path)`,value:`chs("")`,type:`func`,desc:`Get parameter as string`},{label:`chv(path)`,value:`chv("")`,type:`func`,desc:`Get parameter as vector`},{label:`time`,value:`time`,type:`func`,desc:`Current time in seconds`},{label:`frame`,value:`frame`,type:`func`,desc:`Current frame number`},{label:`fps`,value:`fps`,type:`func`,desc:`Frames per second`},{label:`fit(v, oMin, oMax, nMin, nMax)`,value:`fit(, 0, 1, 0, 100)`,type:`func`,desc:`Remap value range`},{label:`clamp(v, min, max)`,value:`clamp(, 0, 1)`,type:`func`,desc:`Clamp value`},{label:`lerp(a, b, t)`,value:`lerp(0, 1, )`,type:`func`,desc:`Linear interpolation`},{label:`noise(x)`,value:`noise()`,type:`func`,desc:`Perlin noise (-1 to 1)`},{label:`random(seed)`,value:`random()`,type:`func`,desc:`Deterministic random (0-1)`},{label:`true`,value:`true`,type:`func`,desc:`Boolean true`},{label:`false`,value:`false`,type:`func`,desc:`Boolean false`},{label:`Math.sin(x)`,value:`Math.sin()`,type:`func`,desc:`Sine function`},{label:`Math.cos(x)`,value:`Math.cos()`,type:`func`,desc:`Cosine function`},{label:`Math.abs(x)`,value:`Math.abs()`,type:`func`,desc:`Absolute value`}];function P(){O(o)&&Y(g,O(g)===`expression`?`value`:`expression`)}function F(e){e.stopPropagation(),Y(_,!0),Y(g,`expression`),Y(b,ne(u().value)),setTimeout(()=>{O(x)?.focus(),O(x)?.select()},0)}function ne(e){return typeof e==`string`?`"${e}"`:typeof e==`boolean`?e?`true`:`false`:Array.isArray(e)?`[${e.join(`, `)}]`:typeof e==`object`&&e&&`r`in e&&`g`in e&&`b`in e?`{ r: ${e.r}, g: ${e.g}, b: ${e.b}${e.a===void 0?``:`, a: ${e.a}`} }`:String(e??``)}function re(){Y(_,!0),Y(b,u().expression||``),setTimeout(()=>{O(x)?.focus()},0)}function L(e){e.stopPropagation();let t=p().parm(d());t&&(t.deleteExpression(),p().markDirty()),Y(_,!1),Y(g,`value`)}function oe(e){let t=e.target;Y(b,t.value),ee=t.selectionStart||0,R()}function R(){if(!O(a)){Y(C,!1);return}let e=O(b).slice(0,ee),t=e.match(/ch[sv]?\s*\(\s*['"]([^'"]*?)$/);if(t){let e=t[1];Y(T,se(e)),Y(C,O(T).length>0),Y(D,0)}else{let t=e.match(/(?:^|[\s(,+\-*/%])(\w*)$/);if(t&&t[1].length>0){let e=t[1].toLowerCase();Y(T,j.filter(t=>t.label.toLowerCase().startsWith(e)||t.value.toLowerCase().startsWith(e)).map(e=>({label:e.label,value:e.value,type:e.type}))),Y(C,O(T).length>0),Y(D,0)}else Y(C,!1)}}function se(e){if(!O(a))return[];let t=[],n=e.startsWith(`/`),r=[],i=``;if(n)r=O(a).nodes.filter(e=>!e.parent),i=`/`;else if(e.startsWith(`../`))p().parent&&(r=p().parent.children().filter(e=>e!==p()),i=`../`);else if(e.startsWith(`./`)){let n=e.slice(2).toLowerCase();return Object.keys(p().props).forEach(e=>{e.toLowerCase().startsWith(n)&&t.push({label:`./${e}`,value:`./${e}`,type:`prop`})}),t}else p().parent?(r=p().parent.children().filter(e=>e!==p()),i=`../`):(r=O(a).nodes.filter(e=>!e.parent&&e!==p()),i=`/`);let o=(n?e.slice(1):e.startsWith(`../`)?e.slice(3):e).split(`/`),s=o[o.length-1].toLowerCase(),c=r;for(let e=0;e<o.length-1;e++){let n=o[e],r=c.find(e=>e.id===n);if(r&&r.isNetwork())c=r.children(),i+=n+`/`;else return t}return c.forEach(e=>{e.id.toLowerCase().startsWith(s)&&(t.push({label:`${i}${e.id}`,value:`${i}${e.id}`,type:`node`}),Object.keys(e.props).forEach(n=>{t.push({label:`${i}${e.id}/${n}`,value:`${i}${e.id}/${n}`,type:`prop`})}))}),t.slice(0,10)}function B(e){let t=O(b).slice(0,ee),n=O(b).slice(ee),r=t.match(/ch[sv]?\s*\(\s*['"]([^'"]*?)$/);if(r){let i=t.slice(0,t.length-r[1].length);Y(b,i+e.value+n)}else{let r=t.match(/(?:^|[\s(,+\-*/%])(\w*)$/);if(r){let i=t.slice(0,t.length-r[1].length);Y(b,i+e.value+n)}}Y(C,!1),O(x)?.focus()}function ce(e){if(O(C)){if(e.key===`ArrowDown`)e.preventDefault(),Y(D,(O(D)+1)%O(T).length);else if(e.key===`ArrowUp`)e.preventDefault(),Y(D,(O(D)-1+O(T).length)%O(T).length);else if(e.key===`Tab`||e.key===`Enter`){if(O(T).length>0){e.preventDefault(),B(O(T)[O(D)]);return}}else if(e.key===`Escape`){Y(C,!1);return}}e.key===`Enter`&&!e.shiftKey&&!O(C)?(e.preventDefault(),V()):e.key===`Escape`&&!O(C)&&H()}function V(){if(Y(C,!1),O(b).trim()){let e=p().parm(d());e&&(e.setExpression(O(b)),p().markDirty())}Y(_,!1)}function H(){Y(C,!1),Y(b,u().expression||``),Y(_,!1),O(o)||Y(g,`value`)}function ue(){setTimeout(()=>{O(C)||(O(b).trim()?V():H())},150)}e(()=>k(p()),()=>{Y(a,p().graph)}),e(()=>k(u()),()=>{Y(o,!!u().expression)}),e(()=>k(u()),()=>{Y(s,u().expressionError)}),e(()=>(O(o),O(g),O(_)),()=>{O(o)&&O(g)===`value`&&!O(_)&&Y(g,`expression`)}),e(()=>(O(o),O(g)),()=>{!O(o)&&O(g)===`expression`&&Y(g,`value`)}),e(()=>k(u()),()=>{u().expression!==void 0&&Y(b,u().expression||``)}),e(()=>(O(o),O(s),k(u())),()=>{Y(l,O(o)&&!O(s)?A(u().value):null)}),ie(),le();var U=P_();let de;var fe=q(U),W=e=>{var t=A_(),n=q(t),r=e=>{var t=E_(),n=q(t);Ee(n);let r;pe(n,e=>Y(x,e),()=>O(x));var a=G(n,2),o=e=>{var t=T_();v(t,5,()=>O(T),c,(e,t,n)=>{var r=w_();let a;var o=q(r),s=M(o,!0),c=G(o,2),l=M(c,!0);w(r),J(()=>{a=i(r,1,`autocomplete-item svelte-10p3942`,null,a,{selected:n===O(D),"type-node":O(t).type===`node`,"type-prop":O(t).type===`prop`,"type-func":O(t).type===`func`}),X(s,(O(t),y(()=>O(t).type===`func`?`ƒ`:O(t).type===`node`?`□`:`•`))),X(l,(O(t),y(()=>O(t).label)))}),f(`mousedown`,r,ye(()=>B(O(t)))),f(`mouseenter`,r,()=>Y(D,n)),E(e,r)}),w(t),E(e,t)};m(a,e=>{O(C),O(T),y(()=>O(C)&&O(T).length>0)&&e(o)}),w(t),J(()=>r=i(n,1,`expression-input svelte-10p3942`,null,r,{error:!!O(s)})),te(n,()=>O(b),e=>Y(b,e)),f(`input`,n,oe),f(`keydown`,n,ce),f(`blur`,n,ue),E(e,t)},a=e=>{var t=D_(),n=q(t),r=M(n,!0);w(t),J(()=>X(r,(k(u()),y(()=>u().expression)))),f(`click`,t,re),E(e,t)};m(n,e=>{O(_)?e(r):e(a,-1)});var o=G(n,2),d=q(o),p=e=>{var t=O_();Ka(q(t),{size:12}),w(t),J(()=>N(t,`title`,O(s))),E(e,t)},h=e=>{var t=k_(),n=M(t);J(()=>{N(t,`title`,`Click to see value: ${O(l)??``}`),X(n,`= ${O(l)??``}`)}),f(`click`,t,ae(P)),E(e,t)};m(d,e=>{O(s)?e(p):O(l)!==null&&e(h,1)});var g=G(d,2);Dc(q(g),{size:12}),w(g),w(o),w(t),f(`click`,g,L),E(e,t)},me=e=>{var t=N_();let r;var a=q(t);h(a,n,`default`,{},null);var s=G(a,2),c=e=>{var t=j_();Us(q(t),{size:10}),w(t),f(`click`,t,ae(P)),E(e,t)},l=e=>{var t=M_();Us(q(t),{size:10}),w(t),f(`click`,t,F),E(e,t)};m(s,e=>{O(o)?e(c):e(l,-1)}),w(t),J(()=>r=i(t,1,`value-view svelte-10p3942`,null,r,{"expression-active":O(o)})),E(e,t)};m(fe,e=>{O(g)===`expression`&&O(o)?e(W):e(me,-1)}),w(U),J(()=>de=i(U,1,`expression-wrapper svelte-10p3942`,null,de,{"has-expression":O(o),"has-error":!!O(s),editing:O(_)})),E(t,U),S()}var I_=T(`<div><div class="content svelte-1nytthg"><div class="section svelte-1nytthg"><div class="section-header svelte-1nytthg"><span class="section-title svelte-1nytthg">Content</span></div> <textarea id="annotation-content" class="content-textarea svelte-1nytthg" placeholder="Enter text..."></textarea></div> <div class="section svelte-1nytthg"><div class="section-header svelte-1nytthg"><span class="section-title svelte-1nytthg">Position</span></div> <!></div> <div class="section svelte-1nytthg"><div class="section-header svelte-1nytthg"><span class="section-title svelte-1nytthg">Layout</span></div> <div class="layout-grid svelte-1nytthg"><div class="layout-input-group svelte-1nytthg"><label class="layout-label svelte-1nytthg" for="annotation-width">W</label> <div class="number-input-with-buttons svelte-1nytthg"><input id="annotation-width" type="number" class="layout-input svelte-1nytthg" min="100"/> <button class="number-button decrement svelte-1nytthg" type="button" title="Decrease">−</button> <button class="number-button increment svelte-1nytthg" type="button" title="Increase">+</button></div></div> <div class="layout-input-group svelte-1nytthg"><label class="layout-label svelte-1nytthg" for="annotation-height">H</label> <div class="number-input-with-buttons svelte-1nytthg"><input id="annotation-height" type="number" class="layout-input svelte-1nytthg" min="20"/> <button class="number-button decrement svelte-1nytthg" type="button" title="Decrease">−</button> <button class="number-button increment svelte-1nytthg" type="button" title="Increase">+</button></div></div></div></div> <div class="section svelte-1nytthg"><div class="section-header svelte-1nytthg"><span class="section-title svelte-1nytthg">Typography</span></div> <div class="typography-presets svelte-1nytthg"><button title="Heading 1">H1</button> <button title="Heading 2">H2</button> <button title="Heading 3">H3</button> <button title="Text">Text</button></div> <div class="typography-row svelte-1nytthg"><div class="typography-input-group svelte-1nytthg"><label class="typography-label svelte-1nytthg" for="annotation-font-size">Size</label> <div class="number-input-with-buttons svelte-1nytthg"><input id="annotation-font-size" type="number" class="typography-number-input svelte-1nytthg" min="8" max="72" step="1"/> <button class="number-button decrement svelte-1nytthg" type="button" title="Decrease">−</button> <button class="number-button increment svelte-1nytthg" type="button" title="Increase">+</button></div></div> <div class="typography-input-group svelte-1nytthg"><label class="typography-label svelte-1nytthg" for="annotation-text-align">Align</label> <div class="align-buttons svelte-1nytthg"><button title="Align left" aria-label="Align left"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M2 3H12M2 7H10M2 11H12" stroke-linecap="round"></path></svg></button> <button title="Align center" aria-label="Align center"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M2 3H12M4 7H10M2 11H12" stroke-linecap="round"></path></svg></button> <button title="Align right" aria-label="Align right"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M2 3H12M4 7H12M2 11H12" stroke-linecap="round"></path></svg></button></div></div></div> <div class="typography-toggles svelte-1nytthg"><button title="Bold"><strong>B</strong></button> <button title="Italic"><em>I</em></button> <button title="Normal">N</button></div></div> <div class="section svelte-1nytthg"><div class="section-header svelte-1nytthg"><span class="section-title svelte-1nytthg">Text Color</span></div> <!></div> <div class="section svelte-1nytthg"><div class="section-header svelte-1nytthg"><span class="section-title svelte-1nytthg">Appearance</span></div> <div class="appearance-row svelte-1nytthg"><div class="appearance-input-group svelte-1nytthg"><label class="appearance-label svelte-1nytthg" for="annotation-border-radius">Radius</label> <div class="number-input-with-buttons svelte-1nytthg"><input id="annotation-border-radius" type="number" class="appearance-number-input svelte-1nytthg" min="0" max="16" step="1"/> <button class="number-button decrement svelte-1nytthg" type="button" title="Decrease">−</button> <button class="number-button increment svelte-1nytthg" type="button" title="Increase">+</button></div></div></div></div> <div class="section svelte-1nytthg"><div class="section-header svelte-1nytthg"><span class="section-title svelte-1nytthg">Background Color</span></div> <!></div></div></div>`),L_=T(`<div><div class="content svelte-1nytthg"><div class="section svelte-1nytthg"><div class="section-header svelte-1nytthg"><span class="section-title svelte-1nytthg">Position</span></div> <div class="position-grid svelte-1nytthg"><div class="position-input-group svelte-1nytthg"><label class="position-label svelte-1nytthg" for="annotation-x">X</label> <input id="annotation-x" type="number" class="position-input svelte-1nytthg"/></div> <div class="position-input-group svelte-1nytthg"><label class="position-label svelte-1nytthg" for="annotation-y">Y</label> <input id="annotation-y" type="number" class="position-input svelte-1nytthg"/></div></div></div> <div class="section svelte-1nytthg"><div class="section-header svelte-1nytthg"><span class="section-title svelte-1nytthg">End Position</span></div> <div class="position-grid svelte-1nytthg"><div class="position-input-group svelte-1nytthg"><label class="position-label svelte-1nytthg" for="annotation-end-x">X</label> <input id="annotation-end-x" type="number" class="position-input svelte-1nytthg"/></div> <div class="position-input-group svelte-1nytthg"><label class="position-label svelte-1nytthg" for="annotation-end-y">Y</label> <input id="annotation-end-y" type="number" class="position-input svelte-1nytthg"/></div></div></div> <div class="section svelte-1nytthg"><div class="section-header svelte-1nytthg"><span class="section-title svelte-1nytthg">Stroke</span></div> <div class="fill-controls svelte-1nytthg"><input id="annotation-stroke-color" type="color" class="color-picker svelte-1nytthg"/> <input id="annotation-stroke-color-hex" type="text" class="color-hex-input svelte-1nytthg" placeholder="#FFFFFF"/></div> <div class="appearance-row svelte-1nytthg" style="margin-top: 8px;"><div class="appearance-input-group svelte-1nytthg"><label class="appearance-label svelte-1nytthg" for="annotation-stroke-width">Width</label> <div class="number-input-with-buttons svelte-1nytthg"><input id="annotation-stroke-width" type="number" class="appearance-number-input svelte-1nytthg" min="1" max="20" step="1"/> <button class="number-button decrement svelte-1nytthg" type="button" title="Decrease">−</button> <button class="number-button increment svelte-1nytthg" type="button" title="Increase">+</button></div></div></div></div></div></div>`),R_=T(`<div><div class="content svelte-1nytthg"><div class="section svelte-1nytthg"><div class="section-header svelte-1nytthg"><span class="section-title svelte-1nytthg">Position</span></div> <div class="position-grid svelte-1nytthg"><div class="position-input-group svelte-1nytthg"><label class="position-label svelte-1nytthg" for="annotation-x">X</label> <input id="annotation-x" type="number" class="position-input svelte-1nytthg"/></div> <div class="position-input-group svelte-1nytthg"><label class="position-label svelte-1nytthg" for="annotation-y">Y</label> <input id="annotation-y" type="number" class="position-input svelte-1nytthg"/></div></div></div> <div class="section svelte-1nytthg"><div class="section-header svelte-1nytthg"><span class="section-title svelte-1nytthg">Stroke</span></div> <div class="fill-controls svelte-1nytthg"><input id="annotation-stroke-color" type="color" class="color-picker svelte-1nytthg"/> <input id="annotation-stroke-color-hex" type="text" class="color-hex-input svelte-1nytthg" placeholder="#FFFFFF"/></div> <div class="appearance-row svelte-1nytthg" style="margin-top: 8px;"><div class="appearance-input-group svelte-1nytthg"><label class="appearance-label svelte-1nytthg" for="annotation-stroke-width">Width</label> <div class="number-input-with-buttons svelte-1nytthg"><input id="annotation-stroke-width" type="number" class="appearance-number-input svelte-1nytthg" min="1" max="20" step="1"/> <button class="number-button decrement svelte-1nytthg" type="button" title="Decrease">−</button> <button class="number-button increment svelte-1nytthg" type="button" title="Increase">+</button></div></div></div></div></div></div>`),z_=T(`<div class="error-badge-container svelte-1nytthg"><span class="error-badge svelte-1nytthg">Error</span></div>`),B_=T(`<label class="prop-label svelte-1nytthg"> </label>`),V_=T(`<textarea class="param-textarea svelte-1nytthg"></textarea>`),H_=T(`<input type="text" class="param-input svelte-1nytthg"/>`),U_=T(`<div><!> <!></div>`),W_=T(`<div class="port-section svelte-1nytthg"><button class="port-heading svelte-1nytthg"><span class="twisty svelte-1nytthg"> </span> Inputs <span class="tally svelte-1nytthg"> </span></button> <!></div>`),G_=T(`<div class="parameter-action-value svelte-1nytthg"><button class="parameter-action"> </button> <!></div>`),K_=T(`<button> </button>`),q_=T(`<div class="parameter svelte-1nytthg"><!> <!></div>`),J_=T(`<div class="port-section svelte-1nytthg"><button class="port-heading svelte-1nytthg"><span class="twisty svelte-1nytthg"> </span> Parameters <span class="tally svelte-1nytthg"> </span></button> <!></div>`),Y_=T(`<div class="port-section svelte-1nytthg"><button class="port-heading svelte-1nytthg"><span class="twisty svelte-1nytthg"> </span> Outputs <span class="tally svelte-1nytthg"> </span></button> <!></div>`),X_=T(`<div class="empty-state svelte-1nytthg">Nothing to show — this node has no parameters or outputs yet</div>`),Z_=T(`<div class="comment-section svelte-1nytthg"><div class="comment svelte-1nytthg"> </div></div>`),Q_=T(`<div><div class="content svelte-1nytthg"><!> <!> <!> <!> <!> <!> <!></div></div>`);function $_(t,n){r(n,!1);let a=()=>oe(Bp,`$propUpdateCounters`,o),[o,s]=se(),l=I(),p=I(),h=I(),g=I(),_=I(),b=I(),C=I(),T=I(),D=I(),ee=I(),te=I(),A=I(),j=z(n,`node`,8,null),P=z(n,`annotation`,12,null),F=z(n,`graph`,12,null),ne=z(n,`position`,8,`right`),re=z(n,`skipAnimation`,8,!1),ae=z(n,`embedded`,8,!1),R=z(n,`onRecordHistory`,8,void 0),ce=z(n,`onAction`,8,void 0),V=!1;function ue(){!V&&R()&&(R()(),V=!0)}function de(){V=!1}he(()=>{let e=()=>de();return window.addEventListener(`mouseup`,e),()=>window.removeEventListener(`mouseup`,e)});let fe=I(0),W=``,pe=new Map,me=I(0);function K(e){return pe.has(e)||pe.set(e,{inputs:!1,params:!0,outputs:!1}),pe.get(e)}function ge(e,t){let n=K(e);n[t]=!n[t],Y(me,O(me)+1)}function _e(e){return j()?K(j().id):{inputs:!1,params:!0,outputs:!1}}he(()=>{let e=setInterval(()=>{if(!j())return;let e=`${j().id}:${j().cookInfo?.cookCount??0}:${j().inputs?.length??0}:${j().outputs?.length??0}`;e!==W&&(W=e,Y(fe,O(fe)+1))},400);return()=>clearInterval(e)});function ve(e,t){return t??[]}function ye(e){return(j()?.parameters??[]).filter(e=>{if(typeof e.options?.visibleWhen!=`function`)return!0;try{let t=Object.fromEntries((j()?.parameters??[]).map(e=>[e.name,e.value]));return e.options.visibleWhen(t)}catch{return!0}})}let be=I(0),xe=I([]);function Se(e,t){if(j()){if(ue(),e.value=t,e.onChange)try{e.onChange(t)}catch(e){console.warn(`port onChange failed:`,e)}j().markDirty?.()}}function Ce(e,t){j()&&Fh(j(),e.name,t,ue)}function we(e){j()&&e.options?.action&&ce()?.(e.options.action,j().id)}function Te(e){j()&&(ue(),j().setParameterPromoted(e.name,!e.promoted),F()&&F(F().elements=[...F().elements],!0),Y(me,O(me)+1),Y(fe,O(fe)+1))}function De([e,t],n){j()&&(ue(),j().updateProp(e,n))}function Oe([e,t],n){let r=n.target.value;De([e,t],r)}function ke([e,t],n){let r=n.target.value;De([e,t],r)}function Ae([e,t]){let n=Km(t),r=t.displayName||e;return(typeof t.disabled==`function`?t.disabled():t.disabled)?null:{key:e,prop:t,controlType:n,displayName:r,folder:t.folder}}let je=I({});function Me(e){H(je,O(je)[e]=!O(je)[e]),Y(je,{...O(je)})}function Ne(e,t){if(P()&&F()){let n={...P().style||{},[e]:t},r=F().getAnnotation(P().id);r&&(r.style=n,F(F().annotations=[...F().annotations],!0))}}function Pe(e,t){if(P()&&F()){let n=F().getAnnotation(P().id);n&&(n.size||={width:540,height:60},n.size[e]=t,F(F().annotations=[...F().annotations],!0))}}function Fe(e){if(P()&&F()){let t=F().getAnnotation(P().id);t&&t.type===`text`&&(t.content=e,F(F().annotations=[...F().annotations],!0),P(P().content=e,!0))}}function Ie(e){let t=e.target.value;Fe(t)}function Le(e,t){Ne(e,parseFloat(t.target.value))}function Re(e,t){let n=t.target.value;Ne(e,n)}function ze(e,t){Pe(e,parseFloat(t.target.value))}function Be(e){let t=parseFloat(e.target.value);if(!isNaN(t)&&P()&&F()){let e=F().getAnnotation(P().id);e&&(e.position.x=t,F(F().annotations=[...F().annotations],!0))}}function Ve(e){let t=parseFloat(e.target.value);if(!isNaN(t)&&P()&&F()){let e=F().getAnnotation(P().id);e&&(e.position.y=t,F(F().annotations=[...F().annotations],!0))}}function He(e){let t=parseFloat(e.target.value);if(!isNaN(t)&&P()&&F()){let e=F().getAnnotation(P().id);e&&e.type===`line`&&(e.endPosition||={...e.position},e.endPosition.x=t,F(F().annotations=[...F().annotations],!0),P().endPosition?P(P().endPosition.x=t,!0):P(P().endPosition={...P().position,x:t},!0))}}function Ue(e){let t=parseFloat(e.target.value);if(!isNaN(t)&&P()&&F()){let e=F().getAnnotation(P().id);e&&e.type===`line`&&(e.endPosition||={...e.position},e.endPosition.y=t,F(F().annotations=[...F().annotations],!0),P().endPosition?P(P().endPosition.y=t,!0):P(P().endPosition={...P().position,y:t},!0))}}function We(e){let t=e.target.value;/^#[0-9A-Fa-f]{6}$/.test(t)&&Ne(`strokeColor`,t)}function Ge(e){if(P()&&F()&&e.length>=2){let t=F().getAnnotation(P().id);t&&(t.position={x:e[0],y:e[1]},F(F().annotations=[...F().annotations],!0))}}function Ke(e){P()&&F()&&Ne(`color`,Uc(Vc(e)))}function Z(e){P()&&F()&&Ne(`backgroundColor`,Uc(Vc(e)))}function Q(e,t,n,r,i=1){let a=document.getElementById(e);if(!a)return;let o=(parseFloat(a.value)||0)+t*i;n!==void 0&&o<n&&(o=n),r!==void 0&&o>r&&(o=r),a.value=String(o),a.dispatchEvent(new Event(`input`,{bubbles:!0}))}function qe(e,t,n,r=1){e.preventDefault();let i=e.target,a=e.deltaY>0?-1:1;Q(i.id,a,t,n,r)}e(()=>O(me),()=>{Y(l,_e(O(me)))}),e(()=>(O(fe),k(j())),()=>{Y(p,ve(O(fe),j()?.inputs))}),e(()=>(O(fe),k(j())),()=>{Y(h,ve(O(fe),j()?.outputs))}),e(()=>O(p),()=>{Y(g,O(p).filter(e=>!e.fromParameter))}),e(()=>O(fe),()=>{Y(_,ye(O(fe)))}),e(()=>{},()=>{Y(b,[])}),e(()=>k(j()),()=>{Y(C,j()?Object.keys(j().props):[])}),e(()=>k(j()),()=>{Y(T,j()?Object.keys(j().props).length:0)}),e(()=>k(j()),()=>{Y(D,j()?.props)}),e(()=>(a(),k(j())),()=>{let e=a();Y(be,j()&&e.get(j().id)||0)}),e(()=>(O(D),O(be)),()=>{Y(ee,O(D)&&O(be)>=0?Object.entries(O(D)).map(([e,t])=>`${e}:${JSON.stringify(t.value)}:${JSON.stringify(t.params)}`).join(`|`)+`|counter:${O(be)}`:``)}),e(()=>(k(j()),O(T),O(ee)),()=>{let e=j()?.props,t=e&&O(T)>=0&&O(ee)!==void 0?Object.entries(e).filter(([e,t])=>typeof t.hidden==`function`?!t.hidden():!t.hidden):[];Y(xe,t)}),e(()=>O(xe),()=>{Y(te,O(xe).map(Ae).filter(e=>e!==null))}),e(()=>O(te),()=>{Y(A,O(te).reduce((e,t)=>{let n=t.folder||`General`;return e[n]||(e[n]=[]),e[n].push(t),e},{}))}),e(()=>(O(A),O(je)),()=>{Object.keys(O(A)).forEach(e=>{e in O(je)||H(je,O(je)[e]=e!==`Settings`)})}),ie(),le();var Je=u(),Ye=B(Je),Xe=e=>{var t=I_();let n;var r=q(t),a=q(r),o=G(q(a),2);U(o),w(a);var s=G(a,2),c=G(q(s),2);d(c,()=>(k(P()),y(()=>`position-${P().id}-${P().position.x}-${P().position.y}`)),e=>{{let t=L(()=>(k(P()),y(()=>({value:[P().position.x,P().position.y],type:`vec2`,params:{integer:!0}}))));Rg(e,{get prop(){return O(t)},id:`annotation-position`,onValueChange:Ge})}}),w(s);var l=G(s,2),u=G(q(l),2),p=q(u),m=G(q(p),2),h=q(m);Ee(h);var g=G(h,2),_=G(g,2);w(m),w(p);var v=G(p,2),b=G(q(v),2),S=q(b);Ee(S);var C=G(S,2),T=G(C,2);w(b),w(v),w(u),w(l);var D=G(l,2),ee=G(q(D),2),te=q(ee);let A;var j=G(te,2);let M;var N=G(j,2);let F;var I=G(N,2);let ie;w(ee);var oe=G(ee,2),R=q(oe),se=G(q(R),2),z=q(se);Ee(z);var B=G(z,2),ce=G(B,2);w(se),w(R);var V=G(R,2),le=G(q(V),2),H=q(le);let ue;var de=G(H,2);let fe;var W=G(de,2);let pe;w(le),w(V),w(oe);var me=G(oe,2),K=q(me);let he;var ge=G(K,2);let _e;var ve=G(ge,2);let ye;w(me),w(D);var Y=G(D,2),be=G(q(Y),2);d(be,()=>(k(P()),y(()=>`text-color-${P().id}-${P().style?.color||`#ffffff`}`)),e=>{{let t=L(()=>(k(P()),y(()=>({value:P().style?.color||`#ffffff`,type:`color`}))));Gg(e,{get prop(){return O(t)},id:`annotation-text-color`,onValueChange:Ke})}}),w(Y);var xe=G(Y,2),Se=G(q(xe),2),Ce=q(Se),we=G(q(Ce),2),Te=q(we);Ee(Te);var De=G(Te,2),X=G(De,2);w(we),w(Ce),w(Se),w(xe);var Oe=G(xe,2),ke=G(q(Oe),2);d(ke,()=>(k(P()),y(()=>`bg-color-${P().id}-${P().style?.backgroundColor||`#000000`}`)),e=>{{let t=L(()=>(k(P()),y(()=>({value:P().style?.backgroundColor||`#000000`,type:`color`}))));Gg(e,{get prop(){return O(t)},id:`annotation-bg-color`,onValueChange:Z})}}),w(Oe),w(r),w(t),J(()=>{n=i(t,1,`inspector svelte-1nytthg`,null,n,{left:ne()===`left`,"no-animation":re(),embedded:ae()}),x(o,(k(P()),y(()=>P().content||``))),x(h,(k(P()),y(()=>P().size?.width||540))),x(S,(k(P()),y(()=>P().size?.height||60))),A=i(te,1,`preset-button svelte-1nytthg`,null,A,{active:(P().style?.fontSize||14)===32&&(P().style?.fontWeight||`normal`)===`bold`}),M=i(j,1,`preset-button svelte-1nytthg`,null,M,{active:(P().style?.fontSize||14)===24&&(P().style?.fontWeight||`normal`)===`bold`}),F=i(N,1,`preset-button svelte-1nytthg`,null,F,{active:(P().style?.fontSize||14)===18&&(P().style?.fontWeight||`normal`)===`bold`}),ie=i(I,1,`preset-button svelte-1nytthg`,null,ie,{active:(P().style?.fontSize||14)===14&&(P().style?.fontWeight||`normal`)===`normal`}),x(z,(k(P()),y(()=>P().style?.fontSize||14))),ue=i(H,1,`align-button svelte-1nytthg`,null,ue,{active:P().style?.textAlign===`left`||!P().style?.textAlign}),fe=i(de,1,`align-button svelte-1nytthg`,null,fe,{active:P().style?.textAlign===`center`}),pe=i(W,1,`align-button svelte-1nytthg`,null,pe,{active:P().style?.textAlign===`right`}),he=i(K,1,`toggle-button svelte-1nytthg`,null,he,{active:(P().style?.fontWeight||`normal`)===`bold`}),_e=i(ge,1,`toggle-button svelte-1nytthg`,null,_e,{active:(P().style?.fontStyle||`normal`)===`italic`}),ye=i(ve,1,`toggle-button svelte-1nytthg`,null,ye,{active:(P().style?.fontWeight||`normal`)===`normal`&&(P().style?.fontStyle||`normal`)===`normal`}),x(Te,(k(P()),y(()=>P().style?.borderRadius||4)))}),f(`input`,o,Ie),f(`input`,h,e=>ze(`width`,e)),f(`wheel`,h,e=>qe(e,100,void 0,10)),f(`click`,g,()=>Q(`annotation-width`,-1,100)),f(`click`,_,()=>Q(`annotation-width`,1,100)),f(`input`,S,e=>ze(`height`,e)),f(`wheel`,S,e=>qe(e,20,void 0,10)),f(`click`,C,()=>Q(`annotation-height`,-1,20)),f(`click`,T,()=>Q(`annotation-height`,1,20)),f(`click`,te,()=>{Ne(`fontSize`,32),Ne(`fontWeight`,`bold`)}),f(`click`,j,()=>{Ne(`fontSize`,24),Ne(`fontWeight`,`bold`)}),f(`click`,N,()=>{Ne(`fontSize`,18),Ne(`fontWeight`,`bold`)}),f(`click`,I,()=>{Ne(`fontSize`,14),Ne(`fontWeight`,`normal`)}),f(`input`,z,e=>Le(`fontSize`,e)),f(`wheel`,z,e=>qe(e,8,72,1)),f(`click`,B,()=>Q(`annotation-font-size`,-1,8,72,1)),f(`click`,ce,()=>Q(`annotation-font-size`,1,8,72,1)),f(`click`,H,()=>Ne(`textAlign`,`left`)),f(`click`,de,()=>Ne(`textAlign`,`center`)),f(`click`,W,()=>Ne(`textAlign`,`right`)),f(`click`,K,()=>{Ne(`fontWeight`,(P().style?.fontWeight||`normal`)===`bold`?`normal`:`bold`)}),f(`click`,ge,()=>{Ne(`fontStyle`,(P().style?.fontStyle||`normal`)===`italic`?`normal`:`italic`)}),f(`click`,ve,()=>{Ne(`fontWeight`,`normal`),Ne(`fontStyle`,`normal`)}),f(`input`,Te,e=>Le(`borderRadius`,e)),f(`wheel`,Te,e=>qe(e,0,16,1)),f(`click`,De,()=>Q(`annotation-border-radius`,-1,0,16,1)),f(`click`,X,()=>Q(`annotation-border-radius`,1,0,16,1)),E(e,t)},Ze=e=>{var t=L_();let n;var r=q(t),a=q(r),o=G(q(a),2),s=q(o),c=G(q(s),2);Ee(c),w(s);var l=G(s,2),u=G(q(l),2);Ee(u),w(l),w(o),w(a);var d=G(a,2),p=G(q(d),2),m=q(p),h=G(q(m),2);Ee(h),w(m);var g=G(m,2),_=G(q(g),2);Ee(_),w(g),w(p),w(d);var v=G(d,2),b=G(q(v),2),S=q(b);Ee(S);var C=G(S,2);Ee(C),w(b);var T=G(b,2),D=q(T),O=G(q(D),2),ee=q(O);Ee(ee);var te=G(ee,2),A=G(te,2);w(O),w(D),w(T),w(v),w(r),w(t),J((e,r,a,o,s)=>{n=i(t,1,`inspector svelte-1nytthg`,null,n,{left:ne()===`left`,"no-animation":re(),embedded:ae()}),x(c,e),x(u,r),x(h,a),x(_,o),x(S,(k(P()),y(()=>P().style?.strokeColor||`#ffffff`))),x(C,s),x(ee,(k(P()),y(()=>P().style?.strokeWidth||2)))},[()=>(k(P()),y(()=>Math.round(P().position.x))),()=>(k(P()),y(()=>Math.round(P().position.y))),()=>(k(P()),y(()=>Math.round(P().endPosition?.x||P().position.x))),()=>(k(P()),y(()=>Math.round(P().endPosition?.y||P().position.y))),()=>(k(P()),y(()=>(P().style?.strokeColor||`#ffffff`).toUpperCase()))]),f(`input`,c,Be),f(`input`,u,Ve),f(`input`,h,He),f(`input`,_,Ue),f(`input`,S,e=>Re(`strokeColor`,e)),f(`input`,C,We),f(`input`,ee,e=>Le(`strokeWidth`,e)),f(`wheel`,ee,e=>qe(e,1,20,1)),f(`click`,te,()=>Q(`annotation-stroke-width`,-1,1,20,1)),f(`click`,A,()=>Q(`annotation-stroke-width`,1,1,20,1)),E(e,t)},$=e=>{var t=R_();let n;var r=q(t),a=q(r),o=G(q(a),2),s=q(o),c=G(q(s),2);Ee(c),w(s);var l=G(s,2),u=G(q(l),2);Ee(u),w(l),w(o),w(a);var d=G(a,2),p=G(q(d),2),m=q(p);Ee(m);var h=G(m,2);Ee(h),w(p);var g=G(p,2),_=q(g),v=G(q(_),2),b=q(v);Ee(b);var S=G(b,2),C=G(S,2);w(v),w(_),w(g),w(d),w(r),w(t),J((e,r,a)=>{n=i(t,1,`inspector svelte-1nytthg`,null,n,{left:ne()===`left`,"no-animation":re(),embedded:ae()}),x(c,e),x(u,r),x(m,(k(P()),y(()=>P().style?.strokeColor||`#ffffff`))),x(h,a),x(b,(k(P()),y(()=>P().style?.strokeWidth||2)))},[()=>(k(P()),y(()=>Math.round(P().position.x))),()=>(k(P()),y(()=>Math.round(P().position.y))),()=>(k(P()),y(()=>(P().style?.strokeColor||`#ffffff`).toUpperCase()))]),f(`input`,c,Be),f(`input`,u,Ve),f(`input`,m,e=>Re(`strokeColor`,e)),f(`input`,h,We),f(`input`,b,e=>Le(`strokeWidth`,e)),f(`wheel`,b,e=>qe(e,1,20,1)),f(`click`,S,()=>Q(`annotation-stroke-width`,-1,1,20,1)),f(`click`,C,()=>Q(`annotation-stroke-width`,1,1,20,1)),E(e,t)},Qe=e=>{var t=Q_();let n;var r=q(t),a=q(r),o=e=>{var t=z_();E(e,t)};m(a,e=>{k(j()),y(()=>j().error)&&e(o)});var s=G(a,2),p=e=>{var t=u(),n=B(t);v(n,1,()=>(O(A),y(()=>Object.entries(O(A)))),c,(e,t)=>{let n=L(()=>{let[e,n]=O(t);return{folder:e,folderProps:n}});var r=u(),a=B(r),o=e=>{{let t=L(()=>(O(je),k(O(n).folder),y(()=>O(je)[O(n).folder]??!0)));g_(e,{get folderName(){return O(n).folder},get isExpanded(){return O(t)},$$events:{toggle:()=>Me(O(n).folder)},children:(e,t)=>{var r=u(),a=B(r);v(a,1,()=>O(n).folderProps,c,(e,t)=>{let r=L(()=>O(t)),a=L(()=>(k(j()),k(O(r).key),k(O(n).folder),y(()=>`prop-${j().id}-${O(r).key}-${O(n).folder}`))),o=L(()=>O(r).controlType===`vec2`||O(r).controlType===`vec3`||O(r).controlType===`vec2i`||O(r).controlType===`vec3i`||O(r).controlType===`vector`);var s=U_();let c;var l=q(s),p=e=>{var t=B_(),n=M(t,!0);J(()=>{N(t,`for`,O(a)),X(n,O(r).displayName)}),E(e,t)};m(l,e=>{O(r).displayName!==null&&e(p)});var h=G(l,2),g=e=>{var t=u(),n=B(t);d(n,()=>(k(O(r).key),k(O(r).prop),y(()=>`${O(r).key}-${O(r).prop.value}-${O(r).prop.expression}-${JSON.stringify(O(r).prop.params)}`)),e=>{F_(e,{get prop(){return O(r).prop},get propKey(){return O(r).key},get node(){return j()},onValueChange:e=>De([O(r).key,O(r).prop],e),children:(e,t)=>{kg(e,{get prop(){return O(r).prop},get id(){return O(a)},onValueChange:e=>De([O(r).key,O(r).prop],e)})},$$slots:{default:!0}})}),E(e,t)},_=e=>{var t=u(),n=B(t);d(n,()=>(k(O(r).key),k(O(r).prop),O(ee),O(be),y(()=>`${O(r).key}-${JSON.stringify(O(r).prop.value)}-${O(r).prop.expression}-${O(ee)}-${O(be)}`)),e=>{F_(e,{get prop(){return O(r).prop},get propKey(){return O(r).key},get node(){return j()},onValueChange:e=>De([O(r).key,O(r).prop],e),children:(e,t)=>{Rg(e,{get prop(){return O(r).prop},get id(){return O(a)},onValueChange:e=>De([O(r).key,O(r).prop],e)})},$$slots:{default:!0}})}),E(e,t)},v=e=>{var t=u(),n=B(t);d(n,()=>(k(O(r).key),k(O(r).prop),y(()=>`${O(r).key}-${JSON.stringify(O(r).prop.value)}-${O(r).prop.expression}`)),e=>{F_(e,{get prop(){return O(r).prop},get propKey(){return O(r).key},get node(){return j()},onValueChange:e=>De([O(r).key,O(r).prop],e),children:(e,t)=>{Gg(e,{get prop(){return O(r).prop},get id(){return O(a)},onValueChange:e=>De([O(r).key,O(r).prop],e)})},$$slots:{default:!0}})}),E(e,t)},b=e=>{C_(e,{get prop(){return O(r).prop},get id(){return O(a)},onValueChange:e=>De([O(r).key,O(r).prop],e)})},S=e=>{Qg(e,{get prop(){return O(r).prop},get id(){return O(a)},onValueChange:e=>De([O(r).key,O(r).prop],e)})},C=e=>{var t=u(),n=B(t);d(n,()=>(k(O(r).key),k(O(r).prop),y(()=>`${O(r).key}-${O(r).prop.expression}`)),e=>{F_(e,{get prop(){return O(r).prop},get propKey(){return O(r).key},get node(){return j()},onValueChange:e=>De([O(r).key,O(r).prop],e),children:(e,t)=>{var n=u(),i=B(n),o=e=>{var t=V_();U(t),J(()=>{N(t,`id`,O(a)),x(t,(k(O(r).prop),y(()=>O(r).prop.value||``)))}),f(`input`,t,e=>ke([O(r).key,O(r).prop],e)),E(e,t)},s=e=>{var t=H_();Ee(t),J(()=>{N(t,`id`,O(a)),x(t,(k(O(r).prop),y(()=>O(r).prop.value||``)))}),f(`input`,t,e=>Oe([O(r).key,O(r).prop],e)),E(e,t)};m(i,e=>{O(r).controlType===`textarea`?e(o):e(s,-1)}),E(e,n)},$$slots:{default:!0}})}),E(e,t)},T=e=>{var t=u(),n=B(t);d(n,()=>(k(O(r).key),k(O(r).prop),y(()=>`${O(r).key}-${O(r).prop.value}-${O(r).prop.expression}`)),e=>{F_(e,{get prop(){return O(r).prop},get propKey(){return O(r).key},get node(){return j()},onValueChange:e=>De([O(r).key,O(r).prop],e),children:(e,t)=>{p_(e,{get prop(){return O(r).prop},get id(){return O(a)},onValueChange:e=>De([O(r).key,O(r).prop],e)})},$$slots:{default:!0}})}),E(e,t)},D=e=>{var t=u(),n=B(t);d(n,()=>(k(O(r).key),k(O(r).prop),y(()=>`${O(r).key}-${O(r).prop.value}-${O(r).prop.expression}`)),e=>{F_(e,{get prop(){return O(r).prop},get propKey(){return O(r).key},get node(){return j()},onValueChange:e=>De([O(r).key,O(r).prop],e),children:(e,t)=>{o_(e,{get prop(){return O(r).prop},get id(){return O(a)},onValueChange:e=>De([O(r).key,O(r).prop],e)})},$$slots:{default:!0}})}),E(e,t)},te=e=>{d_(e,{get prop(){return O(r).prop},get id(){return O(a)},onValueChange:()=>{typeof O(r).prop.value==`function`&&O(r).prop.value(),typeof O(r).prop.onChange==`function`&&O(r).prop.onChange(O(r).prop,!0)}})},A=e=>{var t=H_();Ee(t),J(e=>{N(t,`id`,O(a)),x(t,e)},[()=>(k(O(r).prop),y(()=>String(O(r).prop.value||``)))]),f(`input`,t,e=>Oe([O(r).key,O(r).prop],e)),E(e,t)};m(h,e=>{O(r).controlType===`number`||O(r).controlType===`slider`||O(r).controlType===`int`?e(g):O(o)?e(_,1):O(r).controlType===`color`?e(v,2):O(r).controlType===`colorramp`?e(b,3):(k(O(r).controlType),k(O(r).prop),y(()=>O(r).controlType===`image`||O(r).controlType===`text`&&O(r).prop.params?.accept)?e(S,4):O(r).controlType===`text`||O(r).controlType===`textarea`?e(C,5):O(r).controlType===`boolean`?e(T,6):(k(O(r).controlType),k(O(r).prop),y(()=>O(r).controlType===`select`&&O(r).prop.params?.options)?e(D,7):O(r).controlType===`button`?e(te,8):e(A,-1)))}),w(s),J(()=>c=i(s,1,`prop-group svelte-1nytthg`,null,c,{"prop-group-row":O(o)})),E(e,s)}),E(e,r)},$$slots:{default:!0}})}},s=e=>{var t=u(),r=B(t);v(r,1,()=>O(n).folderProps,c,(e,t)=>{let r=L(()=>O(t)),a=L(()=>(k(j()),k(O(r).key),k(O(n).folder),y(()=>`prop-${j().id}-${O(r).key}-${O(n).folder}`))),o=L(()=>O(r).controlType===`vec2`||O(r).controlType===`vec3`||O(r).controlType===`vec2i`||O(r).controlType===`vec3i`||O(r).controlType===`vector`);var s=U_();let c;var l=q(s),p=e=>{var t=B_(),n=M(t,!0);J(()=>{N(t,`for`,O(a)),X(n,O(r).displayName)}),E(e,t)};m(l,e=>{O(r).displayName!==null&&e(p)});var h=G(l,2),g=e=>{F_(e,{get prop(){return O(r).prop},get propKey(){return O(r).key},get node(){return j()},onValueChange:e=>De([O(r).key,O(r).prop],e),children:(e,t)=>{kg(e,{get prop(){return O(r).prop},get id(){return O(a)},onValueChange:e=>De([O(r).key,O(r).prop],e)})},$$slots:{default:!0}})},_=e=>{var t=u(),n=B(t);d(n,()=>(k(O(r).key),k(O(r).prop),O(ee),O(be),y(()=>`${O(r).key}-${JSON.stringify(O(r).prop.value)}-${O(r).prop.expression}-${O(ee)}-${O(be)}`)),e=>{F_(e,{get prop(){return O(r).prop},get propKey(){return O(r).key},get node(){return j()},onValueChange:e=>De([O(r).key,O(r).prop],e),children:(e,t)=>{Rg(e,{get prop(){return O(r).prop},get id(){return O(a)},onValueChange:e=>De([O(r).key,O(r).prop],e)})},$$slots:{default:!0}})}),E(e,t)},v=e=>{var t=u(),n=B(t);d(n,()=>(k(O(r).key),k(O(r).prop),y(()=>`${O(r).key}-${JSON.stringify(O(r).prop.value)}-${O(r).prop.expression}`)),e=>{F_(e,{get prop(){return O(r).prop},get propKey(){return O(r).key},get node(){return j()},onValueChange:e=>De([O(r).key,O(r).prop],e),children:(e,t)=>{Gg(e,{get prop(){return O(r).prop},get id(){return O(a)},onValueChange:e=>De([O(r).key,O(r).prop],e)})},$$slots:{default:!0}})}),E(e,t)},b=e=>{C_(e,{get prop(){return O(r).prop},get id(){return O(a)},onValueChange:e=>De([O(r).key,O(r).prop],e)})},S=e=>{Qg(e,{get prop(){return O(r).prop},get id(){return O(a)},onValueChange:e=>De([O(r).key,O(r).prop],e)})},C=e=>{var t=u(),n=B(t);d(n,()=>(k(O(r).key),k(O(r).prop),y(()=>`${O(r).key}-${O(r).prop.expression}`)),e=>{F_(e,{get prop(){return O(r).prop},get propKey(){return O(r).key},get node(){return j()},onValueChange:e=>De([O(r).key,O(r).prop],e),children:(e,t)=>{var n=u(),i=B(n),o=e=>{var t=V_();U(t),J(()=>{N(t,`id`,O(a)),x(t,(k(O(r).prop),y(()=>O(r).prop.value||``)))}),f(`input`,t,e=>ke([O(r).key,O(r).prop],e)),E(e,t)},s=e=>{var t=H_();Ee(t),J(()=>{N(t,`id`,O(a)),x(t,(k(O(r).prop),y(()=>O(r).prop.value||``)))}),f(`input`,t,e=>Oe([O(r).key,O(r).prop],e)),E(e,t)};m(i,e=>{O(r).controlType===`textarea`?e(o):e(s,-1)}),E(e,n)},$$slots:{default:!0}})}),E(e,t)},T=e=>{var t=u(),n=B(t);d(n,()=>(k(O(r).key),k(O(r).prop),y(()=>`${O(r).key}-${O(r).prop.value}-${O(r).prop.expression}`)),e=>{F_(e,{get prop(){return O(r).prop},get propKey(){return O(r).key},get node(){return j()},onValueChange:e=>De([O(r).key,O(r).prop],e),children:(e,t)=>{p_(e,{get prop(){return O(r).prop},get id(){return O(a)},onValueChange:e=>De([O(r).key,O(r).prop],e)})},$$slots:{default:!0}})}),E(e,t)},D=e=>{var t=u(),n=B(t);d(n,()=>(k(O(r).key),k(O(r).prop),y(()=>`${O(r).key}-${O(r).prop.value}-${O(r).prop.expression}`)),e=>{F_(e,{get prop(){return O(r).prop},get propKey(){return O(r).key},get node(){return j()},onValueChange:e=>De([O(r).key,O(r).prop],e),children:(e,t)=>{o_(e,{get prop(){return O(r).prop},get id(){return O(a)},onValueChange:e=>De([O(r).key,O(r).prop],e)})},$$slots:{default:!0}})}),E(e,t)},te=e=>{d_(e,{get prop(){return O(r).prop},get id(){return O(a)},onValueChange:()=>{typeof O(r).prop.value==`function`&&O(r).prop.value(),typeof O(r).prop.onChange==`function`&&O(r).prop.onChange(O(r).prop,!0)}})},A=e=>{var t=H_();Ee(t),J(e=>{N(t,`id`,O(a)),x(t,e)},[()=>(k(O(r).prop),y(()=>String(O(r).prop.value||``)))]),f(`input`,t,e=>Oe([O(r).key,O(r).prop],e)),E(e,t)};m(h,e=>{O(r).controlType===`number`||O(r).controlType===`slider`||O(r).controlType===`int`?e(g):O(o)?e(_,1):O(r).controlType===`color`?e(v,2):O(r).controlType===`colorramp`?e(b,3):(k(O(r).controlType),k(O(r).prop),y(()=>O(r).controlType===`image`||O(r).controlType===`text`&&O(r).prop.params?.accept)?e(S,4):O(r).controlType===`text`||O(r).controlType===`textarea`?e(C,5):O(r).controlType===`boolean`?e(T,6):(k(O(r).controlType),k(O(r).prop),y(()=>O(r).controlType===`select`&&O(r).prop.params?.options)?e(D,7):O(r).controlType===`button`?e(te,8):e(A,-1)))}),w(s),J(()=>c=i(s,1,`prop-group svelte-1nytthg`,null,c,{"prop-group-row":O(o)})),E(e,s)}),E(e,t)};m(a,e=>{O(n).folder===`General`?e(s,-1):e(o)}),E(e,r)}),E(e,t)};m(s,e=>{O(te),y(()=>O(te).length>0)&&e(p)});var b=G(s,2),S=e=>{var t=W_(),n=q(t),r=q(n),i=M(r,!0),a=G(r,2),o=M(a,!0);w(n);var s=G(n,2),c=e=>{var t=u(),n=B(t);d(n,()=>(k(j()),O(be),O(ee),O(fe),y(()=>`${j().id}-${O(be)}-${O(ee)}-${O(fe)}`)),e=>{var t=u(),n=B(t);v(n,1,()=>O(g),e=>e.id,(e,t)=>{wg(e,{get port(){return O(t)},get node(){return j()},direction:`input`,onChange:e=>Se(O(t),e)})}),E(e,t)}),E(e,t)};m(s,e=>{O(l),y(()=>O(l).inputs)&&e(c)}),w(t),J(()=>{X(i,(O(l),y(()=>O(l).inputs?`▾`:`▸`))),X(o,(O(g),y(()=>O(g).length)))}),f(`click`,n,()=>ge(j().id,`inputs`)),E(e,t)};m(b,e=>{O(g),y(()=>O(g).length>0)&&e(S)});var C=G(b,2),T=e=>{var t=J_(),n=q(t),r=q(n),a=M(r,!0),o=G(r,2),s=M(o,!0);w(n);var c=G(n,2),p=e=>{var t=u(),n=B(t);d(n,()=>(k(j()),y(()=>j().id)),e=>{var t=u(),n=B(t);v(n,1,()=>O(_),e=>e.name,(e,t)=>{var n=q_(),r=q(n),a=e=>{var n=G_(),r=q(n),i=M(r,!0),a=G(r,2);{let e=L(()=>(O(t),y(()=>({name:`Selected`,dataType:O(t).dataType,value:O(t).value,connections:[],options:{}}))));wg(a,{get port(){return O(e)},get node(){return j()},direction:`output`})}w(n),J(()=>X(i,(O(t),y(()=>O(t).options?.label??O(t).name)))),f(`click`,r,()=>we(O(t))),E(e,n)},o=e=>{{let n=L(()=>(O(t),y(()=>({name:O(t).options?.label??O(t).name,dataType:O(t).dataType,value:O(t).value,connections:[],options:O(t).options??{}}))));wg(e,{get port(){return O(n)},get node(){return j()},direction:`input`,onChange:e=>Ce(O(t),e)})}};m(r,e=>{O(t),y(()=>O(t).options?.action)?e(a):e(o,-1)});var s=G(r,2),c=e=>{var n=K_();let r;var a=M(n,!0);J(()=>{r=i(n,1,`promote svelte-1nytthg`,null,r,{on:O(t).promoted}),N(n,`title`,(O(t),y(()=>O(t).promoted?`Demote back to a parameter — removes the pin and any wire into it`:`Promote to an input pin so it can be driven from another node`))),X(a,(O(t),y(()=>O(t).promoted?`pin ✓`:`pin`)))}),f(`click`,n,()=>Te(O(t))),E(e,n)};m(s,e=>{O(t),y(()=>!O(t).options?.action&&O(t).options?.promotable!==!1)&&e(c)}),w(n),E(e,n)}),E(e,t)}),E(e,t)};m(c,e=>{O(l),y(()=>O(l).params)&&e(p)}),w(t),J(()=>{X(a,(O(l),y(()=>O(l).params?`▾`:`▸`))),X(s,(O(_),y(()=>O(_).length)))}),f(`click`,n,()=>ge(j().id,`params`)),E(e,t)};m(C,e=>{O(_),y(()=>O(_).length>0)&&e(T)});var D=G(C,2),P=e=>{var t=Y_(),n=q(t),r=q(n),i=M(r,!0),a=G(r,2),o=M(a,!0);w(n);var s=G(n,2),c=e=>{var t=u(),n=B(t);d(n,()=>(k(j()),O(be),O(ee),O(fe),y(()=>`${j().id}-${O(be)}-${O(ee)}-${O(fe)}`)),e=>{var t=u(),n=B(t);v(n,1,()=>O(h),e=>e.id,(e,t)=>{wg(e,{get port(){return O(t)},get node(){return j()},direction:`output`,onChange:void 0})}),E(e,t)}),E(e,t)};m(s,e=>{O(l),y(()=>O(l).outputs)&&e(c)}),w(t),J(()=>{X(i,(O(l),y(()=>O(l).outputs?`▾`:`▸`))),X(o,(O(h),y(()=>O(h).length)))}),f(`click`,n,()=>ge(j().id,`outputs`)),E(e,t)};m(D,e=>{O(h),y(()=>O(h).length>0)&&e(P)});var F=G(D,2),I=e=>{var t=X_();E(e,t)};m(F,e=>{O(te),O(g),O(_),O(h),y(()=>O(te).length===0&&O(g).length===0&&O(_).length===0&&O(h).length===0)&&e(I)});var ie=G(F,2),oe=e=>{var t=Z_(),n=q(t),r=M(n,!0);w(t),J(()=>X(r,(k(j()),y(()=>j().comment)))),E(e,t)};m(ie,e=>{k(j()),y(()=>j().comment)&&e(oe)}),w(r),w(t),J(()=>n=i(t,1,`inspector svelte-1nytthg`,null,n,{left:ne()===`left`,"no-animation":re(),embedded:ae()})),E(e,t)};m(Ye,e=>{k(P()),y(()=>P()&&P().type===`text`)?e(Xe):(k(P()),y(()=>P()&&P().type===`line`)?e(Ze,1):(k(P()),y(()=>P()&&P().type===`polyline`)?e($,2):j()&&e(Qe,3)))}),E(t,Je),S(),s()}var ev=T(`<span class="hint svelte-i5w4kg">collapsed, open one to edit it</span>`),tv=T(`<div class="body svelte-i5w4kg"><!></div>`),nv=T(`<section class="section svelte-i5w4kg"><button class="section-heading svelte-i5w4kg"><span class="twisty svelte-i5w4kg"> </span> <span class="label svelte-i5w4kg"> </span> <span class="type svelte-i5w4kg"> </span></button> <!></section>`),rv=T(`<div class="stack svelte-i5w4kg"><div class="summary svelte-i5w4kg"><span class="count"> </span> <!></div> <div class="sections svelte-i5w4kg"></div></div>`);function iv(t,n){r(n,!1);let i=I(),a=z(n,`nodes`,24,()=>[]),o=z(n,`annotation`,8,null),s=z(n,`graph`,8,null),c=z(n,`position`,8,`right`),l=z(n,`skipAnimation`,8,!1),d=z(n,`onRecordHistory`,8,void 0),p=z(n,`onAction`,8,void 0),h=new Map,g=I(0);function _(e){h.set(e,!b(e,O(g),O(i))),Y(g,O(g)+1)}function b(e,t,n){return h.get(e)??!n}function x(e){return e.id}e(()=>k(a()),()=>{Y(i,a().length>12)}),ie(),le();var C=u(),T=B(C),D=e=>{{let t=L(()=>(k(a()),y(()=>a()[0]??null)));$_(e,{get node(){return O(t)},get annotation(){return o()},get graph(){return s()},get position(){return c()},get skipAnimation(){return l()},get onRecordHistory(){return d()},get onAction(){return p()}})}},ee=e=>{var t=rv(),n=q(t),r=q(n),o=M(r),l=G(r,2),u=e=>{var t=ev();E(e,t)};m(l,e=>{O(i)&&e(u)}),w(n);var h=G(n,2);v(h,5,a,e=>e.id,(e,t)=>{let n=L(()=>(O(t),O(g),O(i),y(()=>b(O(t).id,O(g),O(i)))));var r=nv(),a=q(r),o=q(a),l=M(o,!0),u=G(o,2),h=M(u,!0),v=G(u,2),S=M(v,!0);w(a);var C=G(a,2),T=e=>{var n=tv();$_(q(n),{get node(){return O(t)},get graph(){return s()},get position(){return c()},skipAnimation:!0,embedded:!0,get onRecordHistory(){return d()},get onAction(){return p()}}),w(n),E(e,n)};m(C,e=>{O(n)&&e(T)}),w(r),J(e=>{N(a,`aria-expanded`,O(n)),X(l,O(n)?`▾`:`▸`),X(h,e),X(S,(O(t),y(()=>O(t).type??``)))},[()=>(O(t),y(()=>x(O(t))))]),f(`click`,a,()=>_(O(t).id)),E(e,r)}),w(h),w(t),J(()=>X(o,`${k(a()),y(()=>a().length)??``} nodes selected`)),E(e,t)};m(T,e=>{k(a()),y(()=>a().length<=1)?e(D):e(ee,-1)}),E(t,C),S()}var av=T(`<div class="panel-wrapper svelte-z0ewp0"><!></div>`);function ov(t,n){r(n,!1);let i=()=>oe(ua,`$panelLockStore`,s),a=()=>oe(Tm,`$selectedNodeIds`,s),o=()=>oe(la,`$sharedContextStore`,s),[s,c]=se(),l=I(),u=I(),d=I(),f=I(),p=I(),m=z(n,`panelId`,8);z(n,`panelParams`,8);let h=z(n,`panelApi`,8);z(n,`containerApi`,8);let g=z(n,`graph`,12,void 0),_=z(n,`selectedNode`,12,null),v=z(n,`selectedAnnotation`,12,null),y=z(n,`onRecordHistory`,12,void 0),b=z(n,`onPanelAction`,12,void 0),x=I(null);e(()=>(i(),k(m())),()=>{Y(l,i().get(m()))}),e(()=>O(l),()=>{Y(u,O(l)?.isLocked??!1)}),e(()=>o(),()=>{o()&&(g(o().graph),_(o().selectedNode),v(o().selectedAnnotation),y(o().onRecordHistory),b(o().onPanelAction))}),e(()=>(O(u),O(l),k(_())),()=>{Y(d,O(u)?O(l)?.lockedNode:_())}),e(()=>(O(u),O(l),k(v())),()=>{Y(f,O(u)?O(l)?.lockedAnnotationId:v())}),e(()=>(O(u),O(d),k(g()),a(),k(_())),()=>{Y(p,O(u)?O(d)?[O(d)]:[]:Dm(g()??null,a(),_()))}),e(()=>(k(g()),O(f)),()=>{g()&&O(f)?Y(x,g().getAnnotation(O(f))):Y(x,null)}),e(()=>(k(h()),O(u),O(p),O(x)),()=>{if(h()?.setTitle){let e=O(u)?`~ `:``;O(p).length>1?h().setTitle(`${e}Inspector: ${O(p).length} nodes`):O(p).length===1?h().setTitle(`${e}Inspector: ${O(p)[0].id}`):O(x)?h().setTitle(`${e}Inspector: ${O(x).type}`):h().setTitle(`${e}Inspector`)}}),ie(),le();var C=av(),T=q(C);{let e=L(()=>g()??null);iv(T,{get nodes(){return O(p)},get annotation(){return O(x)},get graph(){return O(e)},position:`right`,skipAnimation:!0,get onRecordHistory(){return y()},get onAction(){return b()}})}w(C),E(t,C),S(),c()}function sv(e){let t=new Uint8Array(e);if(String.fromCharCode(...t.subarray(0,6))!==`NUMPY`)throw Error(`not a .npy file`);let n=new DataView(e),r=t[6],i=r>=2?n.getUint32(8,!0):n.getUint16(8,!0),a=r>=2?12:10,o=String.fromCharCode(...t.subarray(a,a+i)),s=o.match(/'descr':\s*'([^']+)'/)?.[1];if(!s)throw Error(`.npy header has no dtype`);if(/'fortran_order':\s*True/.test(o))throw Error(`Fortran-ordered .npy is not supported`);let c=(o.match(/'shape':\s*\(([^)]*)\)/)?.[1]??``).split(`,`).map(e=>e.trim()).filter(Boolean).map(Number),l=a+i,u=c.reduce((e,t)=>e*t,1);if(s===`<f4`||s===`=f4`)return{data:new Float32Array(e,l,u),shape:c,dtype:s};let d=(()=>{switch(s){case`<f8`:case`=f8`:return new Float64Array(e,l,u);case`|u1`:case`<u1`:case`=u1`:case`|b1`:return new Uint8Array(e,l,u);case`|i1`:return new Int8Array(e,l,u);case`<i2`:return new Int16Array(e,l,u);case`<u2`:return new Uint16Array(e,l,u);case`<i4`:return new Int32Array(e,l,u);case`<u4`:return new Uint32Array(e,l,u);default:throw Error(`.npy dtype ${s} is not supported`)}})();return{data:d instanceof Float64Array?d:Float64Array.from(d),shape:c,dtype:s}}var cv=1400,lv=1e5;function uv(e,t,n){t<e.minX&&(e.minX=t),n<e.minY&&(e.minY=n),t>e.maxX&&(e.maxX=t),n>e.maxY&&(e.maxY=n)}function dv(){return{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}async function fv(e){if(e&&typeof e==`object`&&e.kind===`geometry-file`){let t=e;if(t.format!==`npy`||t.attribute?.level!==`point`||t.attribute?.name!==`P`)return[];e=t.path}if(typeof e==`string`){if(!e.endsWith(`.npy`))return[];let t=e.replace(/^\.?\//,``),n=await fetch(`/api/media/${t.split(`/`).map(encodeURIComponent).join(`/`)}?raw=1`);if(!n.ok)return[];let r=sv(await n.arrayBuffer()),i=r.shape.length>1?r.shape[1]:1;if(i<2)return[];let a=[];for(let e=0;e+1<r.data.length;e+=i)a.push([r.data[e],r.data[e+1]]);return a}let t=Array.isArray(e)?e:e?.points;return Array.isArray(t)?t.map(e=>Array.isArray(e)?e:e?.point??e?.position).filter(e=>Array.isArray(e)&&e.length>=2).map(e=>[Number(e[0]),Number(e[1])]):[]}function pv(e){let t=Array.isArray(e)?e:e?.polylines??e?.paths;return Array.isArray(t)?t.map(e=>{let t=Array.isArray(e)?e:e?.points??e?.path;return Array.isArray(t)?t.filter(e=>Array.isArray(e)&&e.length>=2).map(e=>[Number(e[0]),Number(e[1])]):null}).filter(e=>!!(e&&e.length>1)):[]}function mv(e){let t=Array.isArray(e)?e:e?.segments??e?.lines;if(!Array.isArray(t))return[];let n=[];for(let e of t)Array.isArray(e)&&(e.length>=4&&typeof e[0]==`number`?n.push([[Number(e[0]),Number(e[1])],[Number(e[2]),Number(e[3])]]):Array.isArray(e[0])&&e.length>=2&&n.push(e.slice(0,2).map(e=>[Number(e[0]),Number(e[1])])));return n}async function hv(e,t){let n=dv(),r=t===`geometry`?$m(e,lv):null,i=t===`geometry`?r?.points??[]:t===`points`?await fv(e):[],a=t===`geometry`?r?.paths??[]:t===`polyline`?pv(e):[],o=t===`lines`?mv(e):[],s=t===`rects`?Array.isArray(e)?e:e?.rects:[],c=Array.isArray(s)?s.map(e=>Array.isArray(e)?e:e?.rect??[e?.x,e?.y,e?.width,e?.height]).filter(e=>Array.isArray(e)&&e.length>=4&&e.every(Number.isFinite)):[];if(i.forEach(([e,t])=>uv(n,e,t)),a.forEach(e=>e.forEach(([e,t])=>uv(n,e,t))),o.forEach(e=>e.forEach(([e,t])=>uv(n,e,t))),c.forEach(([e,t,r,i])=>{uv(n,e,t),uv(n,e+r,t+i)}),!Number.isFinite(n.minX)||!Number.isFinite(n.maxX))return null;let l=Math.max(n.maxX-n.minX,1),u=Math.max(n.maxY-n.minY,1),d=cv/Math.max(l,u),f=Math.max(1,Math.round(l*d)),p=Math.max(1,Math.round(u*d)),m=document.createElement(`canvas`);m.width=f,m.height=p;let h=m.getContext(`2d`);if(!h)return null;h.fillStyle=`#ffffff`,h.fillRect(0,0,f,p);let g=e=>(e-n.minX)*d,_=e=>(t===`geometry`?n.maxY-e:e-n.minY)*d;h.fillStyle=`#111111`,h.strokeStyle=`#111111`,h.lineWidth=1;let v=i.length>4e3?.6:i.length>800?1:1.8;for(let[e,t]of i)h.beginPath(),h.arc(g(e),_(t),v,0,Math.PI*2),h.fill();for(let e of a)h.beginPath(),e.forEach(([e,t],n)=>n===0?h.moveTo(g(e),_(t)):h.lineTo(g(e),_(t))),h.stroke();for(let[e,t]of o)h.beginPath(),h.moveTo(g(e[0]),_(e[1])),h.lineTo(g(t[0]),_(t[1])),h.stroke();for(let[e,t,n,r]of c)h.strokeRect(g(e),_(t),n*d,r*d);let y=t===`geometry`?r?.summary??`No geometry`:t===`points`?`${i.length.toLocaleString()} points`:t===`polyline`?`${a.length.toLocaleString()} chains · ${a.reduce((e,t)=>e+t.length,0).toLocaleString()} vertices`:t===`lines`?`${o.length.toLocaleString()} segments`:`${c.length.toLocaleString()} rects`;return!i.length&&!a.length&&!o.length&&!c.length?null:{url:m.toDataURL(`image/png`),width:f,height:p,summary:y}}var gv=T(`<button><span class="output-dot svelte-1p3xo7r"></span> </button>`),_v=T(`<div class="output-switcher svelte-1p3xo7r" aria-label="Node outputs"></div>`),vv=T(`<div class="typed-viewer svelte-1p3xo7r"><!></div>`),yv=T(`<div class="viewer-wrapper svelte-1p3xo7r"><!> <div></div> <!></div>`);function bv(t,n){r(n,!1);let a=I(),s=I(),c=I(),l=z(n,`graph`,8),u=z(n,`selectedNode`,8,null),p=z(n,`selectedAnnotation`,8,null),h=I(),g=I(`empty`),_=I(null),b=I(null),x=I(null),C=I(0),T=I(0),D=``,ee=I(null),te=I(null),A=I(null),j=new Map,M=/\.(png|jpe?g|webp|gif|tiff?|avif|svg|npy)$/i,P=[`path`,`preview`,`image`,`png_path`,`output`,`svg_path`,`field`,`mask`,`height`,`shading`,`density`,`points`];function F(e){return O(_)?.outputs?.filter(e=>e.value!==void 0)??[]}function ne(e){if(e===void 0)return`undefined`;if(e===null)return`null`;if(typeof e!=`object`)return`${typeof e}:${String(e).slice(0,80)}`;let t=Nl(e);return t?`image:${t.path}:${t.size.join(`x`)}`:Array.isArray(e)?`array:${e.length}`:`object:${e.width??``}x${e.height??``}:${e.size?.join?.(`x`)??``}`}function re(){let e=O(_)?`${O(_).id}:${O(_).cookInfo?.cookCount??0}:${O(_).outputs?.map(e=>`${e.id}=${ne(e.value)}`).join(`|`)}`:``;e!==D&&(D=e,Y(T,O(T)+1))}function ae(e){let t=Nl(e);return t&&(typeof e!=`string`||M.test(t.path))?t.path:null}function L(e){if(!e?.outputs)return null;if(e===O(_)&&O(s)){let e=ae(O(s).value);if(e)return e}let t=P.map(t=>e.outputs.find(e=>e.name===t)).find(e=>ae(e?.value));if(t)return ae(t.value);let n=e.outputs.find(e=>ae(e?.value));return n?ae(n.value):null}function oe(){let e=O(h)?.clientWidth||800,t=Math.min(window.devicePixelRatio||1,2);return Math.max(320,Math.min(3e3,Math.round(e*t)))}function R(){if(!O(h)||!O(_))return;H(h,O(h).innerHTML=``);let e=null,t=O(s);if(t?.value&&(t.value instanceof HTMLCanvasElement?e=t.value:t.value instanceof tp&&(e=t.value.toCanvas())),!e&&O(_).preview instanceof HTMLCanvasElement&&(e=O(_).preview),e){let t=document.createElement(`div`);t.className=`canvas-viewer`,t.style.width=`100%`,t.style.height=`100%`,t.style.display=`flex`,t.style.alignItems=`center`,t.style.justifyContent=`center`,t.style.background=`var(--surface-void)`;let n=document.createElement(`img`);n.src=e.toDataURL(),n.style.maxWidth=`100%`,n.style.maxHeight=`100%`,n.style.objectFit=`contain`,t.appendChild(n),O(h).appendChild(t)}}let se=new Set([`geometry`,`points`,`lines`,`polyline`,`rects`]),B=I(null),ce=``;async function V(e,t){let n=`${O(_)?.id}:${e?.id}:${t}:${ne(e?.value)}`;if(n!==ce){ce=n;try{let n=await hv(e.value,t);Y(B,n?.url??null),n?.summary}catch(e){console.warn(`[Viewer] could not draw geometry:`,e),Y(B,null)}O(B)&&de()}}function ue(){return O(b)||!O(_)||O(_).preview instanceof HTMLImageElement?null:O(B)&&se.has(O(c))?O(B):L(O(_))}function U(e,t,n){e.style.position=`relative`,e.style.overflow=`hidden`,e.style.cursor=`grab`;let r=document.createElement(`img`);r.alt=t,r.draggable=!1,r.dataset.cascadeSrc=t,r.style.cssText=`position:absolute;top:0;left:0;transform-origin:0 0;user-select:none;visibility:hidden;max-width:100%;max-height:100%;`,e.appendChild(r);let i=document.createElement(`div`);i.style.cssText=`position:absolute;left:8px;bottom:8px;display:flex;gap:6px;align-items:center;font-size:11px;color:var(--text-tertiary);background:var(--shade-strong);padding:3px 8px;border-radius:4px;`,e.appendChild(i);let a=document.createElement(`span`);i.appendChild(a);function o(e,t){let n=document.createElement(`button`);return n.textContent=e,n.style.cssText=`background:none;border:1px solid var(--border);border-radius:3px;color:var(--text-tertiary);font-size:10px;padding:1px 5px;cursor:pointer;`,n.addEventListener(`mousedown`,e=>e.stopPropagation()),n.addEventListener(`click`,e=>{e.stopPropagation(),t()}),i.appendChild(n),n}let s={width:0,height:0},c=1,l=1,u={x:0,y:0},d=0,f=`${O(_)?.id??`view`}:${t}`,p=j.get(f),m=p?.userAdjusted??!1;function h(){j.set(f,{scale:l,offset:{...u},fitScale:c,userAdjusted:m})}function g(){return{width:e.clientWidth||1,height:e.clientHeight||1}}function v(){r.style.maxWidth=`none`,r.style.maxHeight=`none`,r.style.visibility=`visible`}function y(){r.style.width=s.width+`px`,r.style.height=s.height+`px`,r.style.transform=`translate(`+u.x+`px,`+u.y+`px) scale(`+l+`)`,a.textContent=Math.round(l*100)+`%`;let e=Math.min(s.width,Math.ceil(s.width*l*1.2));s.width&&e>d*1.25&&(d=e,r.src=rh(t,{width:e,version:n}))}function b(){let e=g();!s.width||!s.height||(c=Math.min(e.width/s.width,e.height/s.height),l=c,u={x:(e.width-s.width*l)/2,y:(e.height-s.height*l)/2},m=!1,v(),y(),h())}function x(e,t,n){m=!0;let r=l,i=Math.max(c/8,Math.min(c*20,e));i!==r&&(u.x=t-(t-u.x)*i/r,u.y=n-(n-u.y)*i/r,l=i,y(),h())}let S=1.25;function C(e){let t=g();x(l*e,t.width/2,t.height/2)}function w(){if(!s.width||l===1)return;let e=g(),t=e.width/2,n=e.height/2;u.x=t-(t-u.x)/l,u.y=n-(n-u.y)/l,l=1,m=!0,y(),h()}function T(e,t){m=!0,u.x+=e,u.y+=t,y(),h()}e.addEventListener(`wheel`,t=>{t.preventDefault();let n=e.getBoundingClientRect();x(l*Math.exp(-t.deltaY*.0015),t.clientX-n.left,t.clientY-n.top)},{passive:!1});let E=!1,D={x:0,y:0};e.addEventListener(`pointerdown`,t=>{t.target?.closest(`button, a`)||(E=!0,D={x:t.clientX,y:t.clientY},e.style.cursor=`grabbing`,e.setPointerCapture(t.pointerId),t.preventDefault())}),e.addEventListener(`pointermove`,e=>{E&&(m=!0,u.x+=e.clientX-D.x,u.y+=e.clientY-D.y,D={x:e.clientX,y:e.clientY},y(),h())});let k=t=>{E&&(E=!1,e.style.cursor=`grab`,e.hasPointerCapture(t.pointerId)&&e.releasePointerCapture(t.pointerId))};e.addEventListener(`pointerup`,k),e.addEventListener(`pointercancel`,k),e.addEventListener(`dblclick`,()=>b()),e.tabIndex=0,e.style.outline=`none`,e.addEventListener(`pointerenter`,()=>{let t=document.activeElement;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable)||e.focus({preventScroll:!0})}),e.addEventListener(`keydown`,e=>{if(e.altKey)return;let t=e.shiftKey?200:40,n=!0;e.key===`h`||e.key===`H`?b():e.key===`+`||e.key===`=`||e.code===`NumpadAdd`?C(S):e.key===`-`||e.key===`_`||e.code===`NumpadSubtract`?C(1/S):e.key===`0`||e.code===`Numpad0`?w():e.key===`ArrowLeft`?T(t,0):e.key===`ArrowRight`?T(-t,0):e.key===`ArrowUp`?T(0,t):e.key===`ArrowDown`?T(0,-t):n=!1,n&&(e.preventDefault(),e.stopPropagation())}),o(`Fit`,()=>b()).title=`Fit to panel (H)`,o(`1:1`,()=>w()).title=`Actual pixels, 100% (0)`;let ee=document.createElement(`a`);ee.textContent=`Original`,ee.href=rh(t,{raw:!0,version:n}),ee.target=`_blank`,ee.rel=`noopener`,ee.title=t,ee.style.cssText=`color:var(--syntax-variable);text-decoration:none;font-size:10px;`,ee.addEventListener(`mousedown`,e=>e.stopPropagation()),i.appendChild(ee),r.addEventListener(`load`,()=>{s.width||(s={width:r.naturalWidth,height:r.naturalHeight},p&&p.userAdjusted?(l=p.scale,c=p.fitScale,u={...p.offset},v(),y()):b())}),new ResizeObserver(()=>{s.width&&(m||b())}).observe(e),d=oe(),r.src=rh(t,{width:d,version:n})}function de(){if(!O(h))return;let e=O(h).querySelector(`img[data-cascade-src]`),t=ue();if(e&&t&&e.dataset.cascadeSrc===t)return;H(h,O(h).innerHTML=``);let n=null,r=null;if(O(b)&&O(b).type===`Image`){let e=O(b).outputs?.find(e=>e.name===`image`);e?.value instanceof HTMLImageElement?n=e.value:r=O(b).src}else if(O(_)){if(O(_).preview instanceof HTMLImageElement)n=O(_).preview;else{let e=O(s);e?.value instanceof HTMLImageElement?n=e.value:r=(se.has(O(c))?O(B):null)??ae(e?.value)??L(O(_))}}let i=document.createElement(`div`);if(i.className=`image-viewer`,i.style.width=`100%`,i.style.height=`100%`,i.style.display=`flex`,i.style.alignItems=`center`,i.style.justifyContent=`center`,i.style.background=`var(--surface-void)`,n){let e=n.cloneNode(!0);e.style.maxWidth=`100%`,e.style.maxHeight=`100%`,e.style.objectFit=`contain`,i.appendChild(e)}else r&&U(i,r);O(h).appendChild(i)}function fe(){if(!O(h))return;H(h,O(h).innerHTML=``);let e=null;if(O(b)&&O(b).type===`Text`)e=O(b).content||``;else if(O(_)){if(O(_).preview&&!(O(_).preview instanceof HTMLElement))e=O(_).preview;else{let t=O(s);t?.value!==void 0&&(e=t.value)}}if(e!==null){let t=document.createElement(`div`);t.className=`text-viewer`,t.style.width=`100%`,t.style.height=`100%`,t.style.padding=`16px`,t.style.overflow=`auto`,t.style.background=`var(--surface-void)`,t.style.color=`var(--text-bright)`,t.style.fontFamily=`Monaco, Menlo, monospace`,t.style.fontSize=`12px`,t.style.lineHeight=`1.6`;let n=``;if(typeof e==`object`)try{n=JSON.stringify(e,null,2)}catch{n=String(e)}else n=String(e);let r=document.createElement(`pre`);r.style.margin=`0`,r.style.whiteSpace=`pre-wrap`,r.style.wordBreak=`break-word`,r.textContent=n,t.appendChild(r),O(h).appendChild(t)}}function W(){if(!O(h))return;H(h,O(h).innerHTML=``);let e=document.createElement(`div`);e.className=`empty-viewer`;let t=document.createElement(`p`);t.textContent=`No preview available`,e.appendChild(t);let n=document.createElement(`p`);n.className=`hint`,n.textContent=`Select a node or annotation to view its content`,e.appendChild(n),O(h).appendChild(e)}function me(){if(O(b)){if(O(b).type===`Image`){let e=O(b).outputs?.find(e=>e.name===`image`);return e?.value instanceof HTMLImageElement?`img:${e.value.src}`:`img:${O(b).src||`none`}`}return O(b).type===`Text`?`text:${O(b).content||``}`:null}if(!O(_))return null;let e=O(s);if(e?.value instanceof HTMLCanvasElement)return`canvas:${e.value.width}x${e.value.height}:${O(_).id}:${O(_).cookInfo?.cookCount??0}`;if(e?.value instanceof HTMLImageElement)return`img:${e.value.src}`;if(se.has(O(c))&&e?.value!==void 0)return V(e,O(c)),O(B)?`geometry:${ce}`:`data:${e.id}:${ne(e.value)}`;if(e?.value!==void 0)return`data:${e.id}:${ne(e.value)}`;if(O(_).preview instanceof HTMLCanvasElement)return`canvas:${O(_).preview.width}x${O(_).preview.height}:${O(_).id}`;if(O(_).preview instanceof HTMLImageElement)return`img:${O(_).preview.src}`;if(O(_).preview){let e=O(_).preview;return`preview:${ne(e)}`}return null}function K(){if((O(_)||O(b))&&O(g)!==`empty`){let e=O(_)?.id||O(b)?.id||null,t=me();(e!==O(ee)||O(g)!==O(A)||t!==O(te))&&(Y(ee,e),Y(A,O(g)),Y(te,t),O(g)===`canvas`?R():O(g)===`image`?de():O(g)===`text`?fe():O(g)===`typed`&&Y(C,O(C)+1))}}let ge=!1;function _e(){O(g)===`canvas`?R():O(g)===`image`?de():O(g)===`text`?fe():O(g)===`typed`&&Y(C,O(C)+1)}async function ve(){if(O(_)&&O(_).isDirty&&!ge){ge=!0;try{await O(_).requestOutput(),re(),_e()}finally{ge=!1}}else re(),K()}let ye=null,be=I(0);function xe(){ye===null&&(ye=requestAnimationFrame(Se))}function Se(){ye=null;let e=performance.now();e-O(be)>=100&&(Y(be,e),ve()),(O(_)||O(b))&&xe()}he(()=>(xe(),()=>{ye!==null&&(cancelAnimationFrame(ye),ye=null)})),e(()=>(k(p()),k(u()),k(l())),()=>{if(p())Y(b,p()),Y(_,null);else if(u())Y(_,u()),Y(b,null);else if(l()){let e=Array.from(l().cookingNodes||[]);e.length>0?Y(_,e[0]):Y(_,null),Y(b,null)}else Y(_,null),Y(b,null)}),e(()=>k(l()),()=>{l()&&l().cookingNodes?.size}),e(()=>O(T),()=>{Y(a,F(O(T)))}),e(()=>(O(a),O(x)),()=>{if(!O(a).find(e=>e.id===O(x))){let e=P.map(e=>O(a).find(t=>t.name===e)).find(Boolean);Y(x,e?.id??O(a)[0]?.id??null)}}),e(()=>(O(a),O(x)),()=>{Y(s,O(a).find(e=>e.id===O(x))??null)}),e(()=>(O(s),nh),()=>{Y(c,O(s)?Ol(O(s).dataType)===`any`?nh(O(s).value):Ol(O(s).dataType):`any`)}),e(()=>(O(b),O(_),O(T),O(s),O(c),O(B)),()=>{if(O(b)){let e=O(b).type;e===`Image`?O(b).outputs?.find(e=>e.name===`image`)?.value instanceof HTMLImageElement||O(b).src?Y(g,`image`):Y(g,`empty`):e===`Text`?Y(g,`text`):Y(g,`empty`)}else if(!O(_))Y(g,`empty`);else{O(T);let e=O(s);e&&e.value!==void 0?e.value instanceof HTMLCanvasElement||e.value instanceof tp?Y(g,`canvas`):e.value instanceof HTMLImageElement||O(c)===`image`&&ae(e.value)||se.has(O(c))&&O(B)?Y(g,`image`):Y(g,`typed`):O(_).preview?O(_).preview instanceof HTMLCanvasElement?Y(g,`canvas`):O(_).preview instanceof HTMLImageElement?Y(g,`image`):Y(g,`text`):L(O(_))||se.has(O(c))?Y(g,`image`):Y(g,`empty`)}}),e(()=>(O(s),O(c)),()=>{O(s)&&se.has(O(c))&&V(O(s),O(c))}),e(()=>(O(_),O(b),O(g),O(h)),()=>{O(_),O(b),Y(ee,null),Y(te,null),Y(A,null),O(g)===`canvas`?R():O(g)===`image`?de():O(g)===`text`?fe():O(g)===`typed`?O(h)&&H(h,O(h).innerHTML=``):W()}),e(()=>O(_),()=>{O(_)&&(Y(be,0),xe())}),ie(),le();var Ce=yv(),we=q(Ce),Te=e=>{var t=_v();v(t,5,()=>O(a),e=>e.id,(e,t)=>{var n=gv();let r;var a=q(n),s=G(a);w(n),J((e,c)=>{N(n,`title`,e),r=i(n,1,`svelte-1p3xo7r`,null,r,{active:O(t).id===O(x)}),o(a,`background:${c??``}`),X(s,` ${O(t),y(()=>O(t).name)??``}`)},[()=>(O(t),k(Ol),y(()=>`${O(t).name}: ${Ol(O(t).dataType)}`)),()=>(k(jl),O(t),y(()=>jl(O(t).dataType)))]),f(`click`,n,()=>Y(x,O(t).id)),E(e,n)}),w(t),E(e,t)};m(we,e=>{O(a),y(()=>O(a).length>1)&&e(Te)});var Ee=G(we,2);let De;pe(Ee,e=>Y(h,e),()=>O(h));var Oe=G(Ee,2),ke=e=>{var t=vv(),n=q(t);d(n,()=>(O(s),O(C),y(()=>`${O(s).id}-${O(C)}`)),e=>{xg(e,{get type(){return O(c)},get value(){return O(s),y(()=>O(s).value)},get port(){return O(s)},get node(){return O(_)},mode:`view`,readOnly:!0})}),w(t),E(e,t)};m(Oe,e=>{O(g)===`typed`&&O(s)&&e(ke)}),w(Ce),J(()=>De=i(Ee,1,`viewer svelte-1p3xo7r`,null,De,{hidden:O(g)===`typed`})),E(t,Ce),S()}var xv=T(`<div class="panel-wrapper svelte-1qtykx5"><!></div>`);function Sv(t,n){r(n,!1);let i=()=>oe(ua,`$panelLockStore`,o),a=()=>oe(la,`$sharedContextStore`,o),[o,s]=se(),c=I(),l=I(),u=I(),d=z(n,`panelId`,8);z(n,`panelParams`,8);let f=z(n,`panelApi`,8);z(n,`containerApi`,8);let p=z(n,`graph`,12,void 0),m=z(n,`selectedNode`,12,null),h=z(n,`selectedAnnotationId`,12,null),g=I(null);e(()=>(i(),k(d())),()=>{Y(c,i().get(d()))}),e(()=>O(c),()=>{Y(l,O(c)?.isLocked??!1)}),e(()=>a(),()=>{a()&&(p(a().graph),m(a().selectedNode),h(a().selectedAnnotation))}),e(()=>(O(l),O(c),k(m())),()=>{Y(u,O(l)?O(c)?.lockedNode:m())}),e(()=>(k(h()),k(p())),()=>{h()&&p()?Y(g,p().getAnnotation(h())):Y(g,null)}),e(()=>(k(f()),O(l),O(u),O(g)),()=>{if(f()?.setTitle){let e=O(l)?`~ `:``;O(u)?f().setTitle(`${e}Viewer: ${O(u).id}`):O(g)?f().setTitle(`${e}Viewer: ${O(g).caption||O(g).type}`):f().setTitle(`${e}Viewer`)}}),ie(),le();var _=xv();bv(q(_),{get graph(){return p()},get selectedNode(){return O(u)},get selectedAnnotation(){return O(g)}}),w(_),E(t,_),S(),s()}var Cv=T(`<span class="log-source svelte-1hh17sz"> </span>`),wv=T(`<div><!> <span> </span></div>`),Tv=T(`<div class="log svelte-1hh17sz"><div class="log-content svelte-1hh17sz"><!></div></div>`);function Ev(e,t){r(t,!1);let n=I([]),a=I(),o=!0,s;function c(e,t){let n=null,r=t;if(t.length>0&&typeof t[0]==`string`){let e=t[0].match(/^\[([^\]]+)\]/);e&&(n=e[1],r=t.slice(1))}let i=r.map(e=>{if(typeof e==`object`)try{return JSON.stringify(e,null,2)}catch{return String(e)}return String(e)}).join(` `);return{source:n,formatted:i}}function l(e,...t){let{source:r,formatted:i}=c(e,t),l={id:`log_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,timestamp:new Date,level:e,source:r,args:t,formatted:i};Y(n,[...O(n),l]),O(n).length>1e3&&Y(n,O(n).slice(-1e3)),s&&s[e](...t),o&&O(a)&&setTimeout(()=>{O(a)&&H(a,O(a).scrollTop=O(a).scrollHeight)},0)}function d(){O(a)&&(o=O(a).scrollHeight-O(a).scrollTop<=O(a).clientHeight+10)}function f(){Y(n,[])}he(()=>{s={log:console.log.bind(console),warn:console.warn.bind(console),error:console.error.bind(console)},console.log=(...e)=>{l(`log`,...e)},console.warn=(...e)=>{l(`warn`,...e)},console.error=(...e)=>{l(`error`,...e)},O(a)&&O(a).addEventListener(`scroll`,d)}),de(()=>{s&&(console.log=s.log,console.warn=s.warn,console.error=s.error),O(a)&&O(a).removeEventListener(`scroll`,d)});var p={clearLog:f};le();var h=Tv(),g=q(h),_=q(g),y=e=>{var t=u(),r=B(t);v(r,1,()=>O(n),e=>e.id,(e,t)=>{var n=wv();let r;var a=q(n),o=e=>{var n=Cv(),r=M(n);J(()=>X(r,`[${O(t).source??``}]`)),E(e,n)};m(a,e=>{O(t).source&&e(o)});var s=G(a,2);let c;var l=M(s,!0);w(n),J(()=>{r=i(n,1,`log-entry svelte-1hh17sz`,null,r,{error:O(t).level===`error`,warn:O(t).level===`warn`}),c=i(s,1,`log-message svelte-1hh17sz`,null,c,{error:O(t).level===`error`,warn:O(t).level===`warn`}),X(l,O(t).formatted)}),E(e,n)}),E(e,t)};return m(_,e=>{O(n).length>0&&e(y)}),w(g),pe(g,e=>Y(a,e),()=>O(a)),w(h),E(e,h),ue(t,`clearLog`,f),S(p)}var Dv=T(`<div class="panel-wrapper svelte-19qho59"><!></div>`);function Ov(e,t){r(t,!1),z(t,`panelId`,8),z(t,`panelParams`,8),z(t,`panelApi`,8),z(t,`containerApi`,8);let n=I(null);function i(){O(n)?.clearLog&&O(n).clearLog()}var a={clearLog:i},o=Dv(),s=q(o);return pe(Ev(s,{$$legacy:!0}),e=>Y(n,e),()=>O(n)),w(o),E(e,o),ue(t,`clearLog`,i),S(a)}var kv=class e extends Jc{static{this.PREVIEW_INTERVAL=33}constructor(e,t,n){super(e,t,n),this._previewPending=!1,this._previewBuffer=null,this._lastPreviewTime=0}onCook(){return this.render()}requestCook(){this.markDirty()}toImageBuffer(e){return e?e instanceof tp?e:e instanceof HTMLCanvasElement||e instanceof HTMLImageElement?tp.fromCanvas(e):null:null}getImageSize(e){return e?e instanceof tp||e instanceof HTMLCanvasElement?{width:e.width,height:e.height}:e instanceof HTMLImageElement?{width:e.naturalWidth||e.width,height:e.naturalHeight||e.height}:{width:0,height:0}:{width:0,height:0}}addResolutionParm(e=512,t=512){this.addParm(`resolution`,{value:[e,t],params:{min:[1,1],max:[4096,4096],integer:!0},displayName:`Resolution`,onChange:()=>this.requestCook()})}getResolution(){return this.props.resolution?this.props.resolution.value:(console.warn(`${this.type}: getResolution() called but no resolution parameter exists. Call addResolutionParm() in setup().`),[512,512])}resolveOutputSize(e,t,n){let r=t.filter(e=>e!==null);switch(e){case`input`:case`input1`:if(r[0])return{width:r[0].width,height:r[0].height};break;case`input2`:if(r[1])return{width:r[1].width,height:r[1].height};if(r[0])return{width:r[0].width,height:r[0].height};break;case`largest`:if(r.length>0){let e=0,t=r[0];for(let n of r){let r=n.width*n.height;r>e&&(e=r,t=n)}return{width:t.width,height:t.height}}break;case`smallest`:if(r.length>0){let e=1/0,t=r[0];for(let n of r){let r=n.width*n.height;r<e&&(e=r,t=n)}return{width:t.width,height:t.height}}break;case`custom`:if(n)return{width:n[0],height:n[1]}}return r[0]?{width:r[0].width,height:r[0].height}:{width:512,height:512}}resizeToFit(e,t,n,r=`fill`){if(e.width===t&&e.height===n)return e;let i=tp.rgba(t,n),a=e.width/e.height,o=t/n,s=0,c=0,l=e.width,u=e.height,d=0,f=0,p=t,m=n;switch(r){case`fill`:a>o?(l=Math.round(e.height*o),s=Math.round((e.width-l)/2)):(u=Math.round(e.width/o),c=Math.round((e.height-u)/2));break;case`fit`:a>o?(m=Math.round(t/a),f=Math.round((n-m)/2)):(p=Math.round(n*a),d=Math.round((t-p)/2)),i.fill(0,0),i.fill(1,0),i.fill(2,0),i.fill(3,1);break;case`stretch`:break;case`native`:p=Math.min(e.width,t),m=Math.min(e.height,n),l=p,u=m,d=Math.round((t-p)/2),f=Math.round((n-m)/2),s=Math.round((e.width-l)/2),c=Math.round((e.height-u)/2),i.fill(0,0),i.fill(1,0),i.fill(2,0),i.fill(3,1)}let h=l/p,g=u/m;for(let n=0;n<Math.min(e.channelCount,4);n++){let r=i.channels[n];for(let i=0;i<m;i++)for(let a=0;a<p;a++){let o=s+a*h,l=c+i*g;r[(f+i)*t+(d+a)]=e.sample(o,l,n)}}if(e.channelCount<4&&r!==`fit`&&r!==`native`)for(let e=0;e<m;e++)for(let n=0;n<p;n++)i.channels[3][(f+e)*t+(d+n)]=1;return i}prepareInputs(e,t=`input`,n=`fill`,r){let i=e.map(e=>this.toImageBuffer(e)),{width:a,height:o}=this.resolveOutputSize(t,i,r);return{buffers:i.map(e=>e?e.width===a&&e.height===o?e:this.resizeToFit(e,a,o,n):null),width:a,height:o}}setOutput(e,t){e.setValue(t),this._previewBuffer=t,this.updatePreviewThrottled()}updatePreviewThrottled(){let t=performance.now(),n=t-this._lastPreviewTime;if(n>=e.PREVIEW_INTERVAL)this._lastPreviewTime=t,this._previewBuffer&&(this.preview=this._previewBuffer.toCanvas()),this._previewPending=!1;else if(!this._previewPending){this._previewPending=!0;let t=e.PREVIEW_INTERVAL-n;setTimeout(()=>{this._previewPending=!1,this._lastPreviewTime=performance.now(),this._previewBuffer&&(this.preview=this._previewBuffer.toCanvas())},t)}}getBufferInfo(){if(!this._previewBuffer)return null;let e=this._previewBuffer;return{hasOutput:!0,width:e.width,height:e.height,channels:e.channelCount,layout:e.layout,memoryBytes:e.memoryBytes,memorySizeStr:e.memorySizeStr}}},Av=T(`<section class="info-section buffer-section svelte-13kv637"><h3 class="svelte-13kv637">Output Buffer</h3> <div class="info-grid svelte-13kv637"><div class="info-row resolution-row svelte-13kv637"><span class="label svelte-13kv637">Resolution</span> <span class="value mono highlight svelte-13kv637"> </span></div> <div class="info-row svelte-13kv637"><span class="label svelte-13kv637">Format</span> <span class="value svelte-13kv637"> </span></div> <div class="info-row svelte-13kv637"><span class="label svelte-13kv637">Buffer Size</span> <span class="value svelte-13kv637"> </span></div></div></section>`),jv=T(`<div class="issue error svelte-13kv637"><span class="issue-type svelte-13kv637">Error</span> <span class="issue-message svelte-13kv637"> </span></div>`),Mv=T(`<div class="issue warning svelte-13kv637"><span class="issue-type svelte-13kv637">Warning</span> <span class="issue-message svelte-13kv637"> </span></div>`),Nv=T(`<section class="info-section svelte-13kv637"><h3 class="svelte-13kv637">Issues</h3> <div class="issues svelte-13kv637"><!> <!></div></section>`),Pv=T(`<section class="info-section svelte-13kv637"><h3 class="svelte-13kv637">Code</h3> <div class="info-grid svelte-13kv637"><div class="info-row svelte-13kv637"><span class="label svelte-13kv637">Lines</span> <span class="value svelte-13kv637"> </span></div> <div class="info-row svelte-13kv637"><span class="label svelte-13kv637">Characters</span> <span class="value svelte-13kv637"> </span></div></div></section>`),Fv=T(`<div class="info-sections svelte-13kv637"><section class="info-section svelte-13kv637"><h3 class="svelte-13kv637">Node</h3> <div class="info-grid svelte-13kv637"><div class="info-row svelte-13kv637"><span class="label svelte-13kv637">ID</span> <span class="value mono svelte-13kv637"> </span></div> <div class="info-row svelte-13kv637"><span class="label svelte-13kv637">Type</span> <span class="value mono svelte-13kv637"> </span></div> <div class="info-row svelte-13kv637"><span class="label svelte-13kv637">Module</span> <span class="value mono path svelte-13kv637"> </span></div> <div class="info-row svelte-13kv637"><span class="label svelte-13kv637">Class</span> <span class="value mono svelte-13kv637"> </span></div> <div class="info-row svelte-13kv637"><span class="label svelte-13kv637">Path</span> <span class="value mono path svelte-13kv637"> </span></div></div></section> <section class="info-section svelte-13kv637"><h3 class="svelte-13kv637">Cook Performance <button class="reset-btn svelte-13kv637" title="Reset statistics">Reset</button></h3> <div class="info-grid svelte-13kv637"><div class="info-row svelte-13kv637"><span class="label svelte-13kv637">Last Cook</span> <span> </span></div> <div class="info-row svelte-13kv637"><span class="label svelte-13kv637">Average</span> <span> </span></div> <div class="info-row svelte-13kv637"><span class="label svelte-13kv637">Total Time</span> <span class="value svelte-13kv637"> </span></div> <div class="info-row svelte-13kv637"><span class="label svelte-13kv637">Cook Count</span> <span class="value svelte-13kv637"> </span></div> <div class="info-row svelte-13kv637"><span class="label svelte-13kv637">Last Cooked</span> <span class="value svelte-13kv637"> </span></div> <div class="info-row svelte-13kv637"><span class="label svelte-13kv637">Peak Memory</span> <span class="value svelte-13kv637"> </span></div></div></section> <!> <section class="info-section svelte-13kv637"><h3 class="svelte-13kv637">State</h3> <div class="info-grid svelte-13kv637"><div class="info-row svelte-13kv637"><span class="label svelte-13kv637">Bypass</span> <span> </span></div> <div class="info-row svelte-13kv637"><span class="label svelte-13kv637">Cook Flag</span> <span> </span></div> <div class="info-row svelte-13kv637"><span class="label svelte-13kv637">Time Dependent</span> <span> </span></div> <div class="info-row svelte-13kv637"><span class="label svelte-13kv637">Dirty</span> <span> </span></div> <div class="info-row svelte-13kv637"><span class="label svelte-13kv637">Variadic</span> <span class="value svelte-13kv637"> </span></div></div></section> <section class="info-section svelte-13kv637"><h3 class="svelte-13kv637">Ports & Parameters</h3> <div class="info-grid svelte-13kv637"><div class="info-row svelte-13kv637"><span class="label svelte-13kv637">Inputs</span> <span class="value svelte-13kv637"> </span></div> <div class="info-row svelte-13kv637"><span class="label svelte-13kv637">Outputs</span> <span class="value svelte-13kv637"> </span></div> <div class="info-row svelte-13kv637"><span class="label svelte-13kv637">Parameters</span> <span class="value svelte-13kv637"> </span></div> <div class="info-row svelte-13kv637"><span class="label svelte-13kv637">Expressions</span> <span> </span></div></div></section> <!> <!></div>`),Iv=T(`<div class="empty-state svelte-13kv637"><p class="svelte-13kv637">Select a node to view its information</p></div>`),Lv=T(`<div class="cook-info-panel svelte-13kv637"><!></div>`);function Rv(t,n){r(n,!1);let a=()=>oe(ua,`$panelLockStore`,s),o=()=>oe(la,`$sharedContextStore`,s),[s,c]=se(),l=I(),u=I(),d=I(),f=I(),p=z(n,`panelId`,8);z(n,`panelParams`,8);let h=z(n,`panelApi`,8);z(n,`containerApi`,8);let g=z(n,`graph`,12,void 0),_=z(n,`selectedNode`,12,null);function v(e){return e<.01?`< 0.01ms`:e<1?`${e.toFixed(2)}ms`:e<1e3?`${e.toFixed(1)}ms`:`${(e/1e3).toFixed(2)}s`}function b(e){return e===0?`-`:e<1024?`${e}B`:e<1048576?`${(e/1024).toFixed(1)}KB`:`${(e/1048576).toFixed(2)}MB`}function x(e){return e===0?`Never`:new Date(e).toLocaleTimeString()}function C(e){return Ae(e.type)}function T(e){return e.constructor.name}function D(e){return e.inputs.filter(e=>!e.options?.hidden).length}function ee(e){return e.outputs.length}function te(e){return e.inputs.filter(e=>e.connections.length>0).length}function A(e){return e.outputs.filter(e=>e.connections.length>0).length}function j(e){return Object.keys(e.props).length}function N(e){return Object.values(e.props).filter(e=>e.expression).length}function P(){O(d)?.resetCookInfo&&O(d).resetCookInfo()}function F(e){return e instanceof kv}function ne(e){return F(e)?e.getBufferInfo():null}function re(e,t){let n=e*t/1e6;return n>=1?`${e} × ${t} (${n.toFixed(1)}MP)`:`${e} × ${t} (${(e*t/1e3).toFixed(0)}K)`}function ae(e,t){switch(e){case`gray`:return`Grayscale (1ch)`;case`rgb`:return`RGB (3ch)`;case`rgba`:return`RGBA (4ch)`;default:return`${t} channels`}}e(()=>(a(),k(p())),()=>{Y(l,a().get(p()))}),e(()=>O(l),()=>{Y(u,O(l)?.isLocked??!1)}),e(()=>o(),()=>{o()&&(g(o().graph),_(o().selectedNode))}),e(()=>(O(u),O(l),k(_())),()=>{Y(d,O(u)?O(l)?.lockedNode:_())}),e(()=>(k(h()),O(u),O(d)),()=>{if(h()?.setTitle){let e=O(u)?`~ `:``;O(d)?h().setTitle(`${e}Info: ${O(d).id}`):h().setTitle(`${e}Node Info`)}}),e(()=>O(d),()=>{Y(f,O(d)?ne(O(d)):null)}),ie(),le();var L=Lv(),R=q(L),B=e=>{var t=Fv(),n=q(t),r=G(q(n),2),a=q(r),o=G(q(a),2),s=M(o,!0);w(a);var c=G(a,2),l=G(q(c),2),u=M(l,!0);w(c);var p=G(c,2),h=G(q(p),2),g=M(h,!0);w(p);var _=G(p,2),S=G(q(_),2),k=M(S,!0);w(_);var F=G(_,2),I=G(q(F),2),ne=M(I,!0);w(F),w(r),w(n);var ie=G(n,2),L=q(ie),oe=G(q(L));w(L);var R=G(L,2),se=q(R),z=G(q(se),2);let B;var ce=M(z,!0);w(se);var V=G(se,2),le=G(q(V),2);let H;var ue=M(le,!0);w(V);var U=G(V,2),de=G(q(U),2),fe=M(de,!0);w(U);var W=G(U,2),pe=G(q(W),2),me=M(pe,!0);w(W);var he=G(W,2),ge=G(q(he),2),_e=M(ge,!0);w(he);var ve=G(he,2),ye=G(q(ve),2),Y=M(ye,!0);w(ve),w(R),w(ie);var be=G(ie,2),xe=e=>{var t=Av(),n=G(q(t),2),r=q(n),i=G(q(r),2),a=M(i,!0);w(r);var o=G(r,2),s=G(q(o),2),c=M(s,!0);w(o);var l=G(o,2),u=G(q(l),2),d=M(u,!0);w(l),w(n),w(t),J((e,t)=>{X(a,e),X(c,t),X(d,(O(f),y(()=>O(f).memorySizeStr)))},[()=>(O(f),y(()=>re(O(f).width,O(f).height))),()=>(O(f),y(()=>ae(O(f).layout,O(f).channels)))]),E(e,t)};m(be,e=>{O(f)&&e(xe)});var Se=G(be,2),Ce=G(q(Se),2),we=q(Ce),Te=G(q(we),2);let Ee;var De=M(Te,!0);w(we);var Oe=G(we,2),ke=G(q(Oe),2);let Ae;var je=M(ke,!0);w(Oe);var Me=G(Oe,2),Ne=G(q(Me),2);let Pe;var Fe=M(Ne,!0);w(Me);var Ie=G(Me,2),Le=G(q(Ie),2);let Re;var ze=M(Le,!0);w(Ie);var Be=G(Ie,2),Ve=G(q(Be),2),He=M(Ve,!0);w(Be),w(Ce),w(Se);var Ue=G(Se,2),We=G(q(Ue),2),Ge=q(We),Ke=G(q(Ge),2),Z=M(Ke);w(Ge);var Q=G(Ge,2),qe=G(q(Q),2),Je=M(qe);w(Q);var Ye=G(Q,2),Xe=G(q(Ye),2),Ze=M(Xe,!0);w(Ye);var $=G(Ye,2),Qe=G(q($),2);let $e;var et=M(Qe,!0);w($),w(We),w(Ue);var tt=G(Ue,2),nt=e=>{var t=Nv(),n=G(q(t),2),r=q(n),i=e=>{var t=jv(),n=G(q(t),2),r=M(n,!0);w(t),J(()=>X(r,(O(d),y(()=>O(d).error.message)))),E(e,t)};m(r,e=>{O(d),y(()=>O(d).error)&&e(i)});var a=G(r,2),o=e=>{var t=Mv(),n=G(q(t),2),r=M(n,!0);w(t),J(()=>X(r,(O(d),y(()=>O(d).warning)))),E(e,t)};m(a,e=>{O(d),y(()=>O(d).warning)&&e(o)}),w(n),w(t),E(e,t)};m(tt,e=>{O(d),y(()=>O(d).error||O(d).warning)&&e(nt)});var rt=G(tt,2),it=e=>{var t=Pv(),n=G(q(t),2),r=q(n),i=G(q(r),2),a=M(i,!0);w(r);var o=G(r,2),s=G(q(o),2),c=M(s,!0);w(o),w(n),w(t),J(e=>{X(a,e),X(c,(O(d),y(()=>O(d).code.length)))},[()=>(O(d),y(()=>O(d).code.split(`
|
|
219
|
+
`).length))]),E(e,t)};m(rt,e=>{O(d),y(()=>O(d).code)&&e(it)}),w(t),J((e,t,n,r,a,o,c,l,f,p,m,h,_,v,b)=>{X(s,(O(d),y(()=>O(d).id))),X(u,(O(d),y(()=>O(d).type))),X(g,e),X(k,t),X(ne,n),B=i(z,1,`value svelte-13kv637`,null,B,{slow:O(d).cookInfo.lastCookTime>100}),X(ce,r),H=i(le,1,`value svelte-13kv637`,null,H,{slow:O(d).cookInfo.averageCookTime>100}),X(ue,a),X(fe,o),X(me,(O(d),y(()=>O(d).cookInfo.cookCount))),X(_e,c),X(Y,l),Ee=i(Te,1,`value svelte-13kv637`,null,Ee,{active:O(d).bypass}),X(De,(O(d),y(()=>O(d).bypass?`Yes`:`No`))),Ae=i(ke,1,`value svelte-13kv637`,null,Ae,{active:O(d).cook}),X(je,(O(d),y(()=>O(d).cook?`Yes`:`No`))),Pe=i(Ne,1,`value svelte-13kv637`,null,Pe,{active:O(d).isTimeDependent}),X(Fe,(O(d),y(()=>O(d).isTimeDependent?`Yes`:`No`))),Re=i(Le,1,`value svelte-13kv637`,null,Re,{warning:O(d).isDirty}),X(ze,(O(d),y(()=>O(d).isDirty?`Yes`:`No`))),X(He,(O(d),y(()=>O(d).variadic?`Yes`:`No`))),X(Z,`${f??``} / ${p??``} connected`),X(Je,`${m??``} / ${h??``} connected`),X(Ze,_),$e=i(Qe,1,`value svelte-13kv637`,null,$e,{active:v}),X(et,b)},[()=>(O(d),y(()=>C(O(d)))),()=>(O(d),y(()=>T(O(d)))),()=>(O(d),y(()=>O(d).path())),()=>(O(d),y(()=>v(O(d).cookInfo.lastCookTime))),()=>(O(d),y(()=>v(O(d).cookInfo.averageCookTime))),()=>(O(d),y(()=>v(O(d).cookInfo.totalCookTime))),()=>(O(d),y(()=>x(O(d).cookInfo.lastCookTimestamp))),()=>(O(d),y(()=>b(O(d).cookInfo.peakMemory))),()=>(O(d),y(()=>te(O(d)))),()=>(O(d),y(()=>D(O(d)))),()=>(O(d),y(()=>A(O(d)))),()=>(O(d),y(()=>ee(O(d)))),()=>(O(d),y(()=>j(O(d)))),()=>N(O(d))>0,()=>(O(d),y(()=>N(O(d))))]),K(`click`,oe,P),E(e,t)},ce=e=>{var t=Iv();E(e,t)};m(R,e=>{O(d)?e(B):e(ce,-1)}),w(L),E(t,L),S(),c()}p([`click`]);var zv=T(`<div class="panel-error svelte-1tj4xha" role="alert"> </div>`),Bv=T(`<div class="project-panel svelte-1tj4xha"></div>`);function Vv(e,t){r(t,!1);let n=z(t,`panelParams`,8),i=z(t,`panelApi`,8),a=z(t,`loader`,8,Lh),o=I(),s=I(``);he(()=>{let e=!1,t,r=new AbortController,c=n().projectPanelName;if(!c){Y(s,`Project panel name is missing`);return}return a()(c).then(async a=>{if(e)return;let s=await a.mount(O(o),Vh({context:pa,close:()=>i().close(),sourceNodeId:n().sourceNodeId,signal:r.signal}));e?s?.():t=s}).catch(t=>{e||Y(s,t instanceof Error?t.message:String(t))}),()=>{e=!0,r.abort(),t?.()}}),le();var c=u(),l=B(c),d=e=>{var t=zv(),n=M(t,!0);J(()=>X(n,O(s))),E(e,t)},f=e=>{var t=Bv();pe(t,e=>Y(o,e),()=>O(o)),E(e,t)};m(l,e=>{O(s)?e(d):e(f,-1)}),E(e,c),S()}function Hv(e,t,n,r=8){return{x:Math.max(r,Math.min(e.x,n.width-t.width-r)),y:Math.max(r,Math.min(e.y,n.height-t.height-r))}}var Uv=F(()=>Bc),Wv=T(`<button class="add-panel-option svelte-1vs60xl"><!> <span class="panel-label svelte-1vs60xl"> </span></button>`),Gv=T(`<div class="add-panel-menu svelte-1vs60xl"></div>`),Kv=T(`<div class="dockview-container cascade-theme svelte-1vs60xl"></div> <!>`,1);function qv(t,n){r(n,!1);let i=()=>oe(Lc,`$panelTypes`,a),[a,s]=se(),l=I(),u=ve(),d=I(!1),p={x:0,y:0},h=I(),g=I(``),_=``,b=z(n,`graph`,8,void 0),x=z(n,`selectedNode`,8,null),C=z(n,`selectedAnnotation`,8,null),T=z(n,`activeTool`,8,`select`),D=z(n,`activeLibrary`,8,null),te=z(n,`documentName`,8,`Untitled`),A=z(n,`presentationMode`,8,!1),j=z(n,`onRecordHistory`,8,void 0),N=I(),P=null;function F(e){let t=document.querySelector(`[data-panel-type="graph"]`);t&&t.dispatchEvent(new CustomEvent(`addNode`,{detail:e}))}function ne(){let e=document.querySelector(`[data-panel-type="graph"]`);e&&e.dispatchEvent(new CustomEvent(`centerOnNodes`))}function re(){let e=document.querySelector(`[data-panel-type="graph"]`);e&&e.dispatchEvent(new CustomEvent(`selectAll`))}function L(){let e=document.querySelector(`[data-panel-type="graph"]`);e&&e.dispatchEvent(new CustomEvent(`deselectAll`))}function R(){let e=document.querySelector(`[data-panel-type="graph"]`);e&&e.dispatchEvent(new CustomEvent(`deleteSelected`))}function ce(e,t){Uv().openCodeEditor(e,t)}function V(){Uv().resetLayout()}function H(e){Uv().focusPanel(e)}async function U(e,t){_=e,p=t,Y(d,!0),await W()}async function W(){if(Y(g,`left: ${p.x}px; top: ${p.y}px; visibility: hidden`),await ee(),!O(h))return;let{width:e,height:t}=O(h).getBoundingClientRect(),n=Hv(p,{width:e,height:t},{width:window.innerWidth,height:window.innerHeight});Y(g,`left: ${n.x}px; top: ${n.y}px`)}function me(e){Uv().addPanelToGroup(e,_),Y(d,!1)}function K(){Y(d,!1)}he(async()=>{ma(`graph`,Wm,`Graph`),ma(`inspector`,ov,`Inspector`),ma(`viewer`,Sv,`Viewer`),ma(`log`,Ov,`Log`),ha(`code`,()=>ol(()=>import(`./CodePanel-B0_2XJ-t.js`),__vite__mapDeps([0,1,2])),`Code`),ma(`info`,Rv,`Node Info`);try{let e=await Ih();Rc(e);for(let t of e){ma(`project:${t.name}`,Vv,t.title);for(let e of t.rendererTypes??[])qh(e,t.name)}}catch(e){console.warn(`Failed to discover project panels:`,e),Rc([])}Uv(Uv().onAddPanelClick=U),Uv().initialize(O(N)),P=setInterval(()=>{Uv().saveLayout()},3e4)}),de(()=>{P&&clearInterval(P),Uv(Uv().onAddPanelClick=null),Uv().dispose()}),e(()=>(k(b()),k(x()),k(C()),k(T()),k(D()),k(te()),k(A()),k(j()),Uv()),()=>{Y(l,{graph:b(),selectedNode:x(),selectedAnnotation:C(),activeTool:T(),activeLibrary:D(),documentName:te(),presentationMode:A(),onRecordHistory:j(),onNodeSelect:e=>{u(`nodeSelect`,{node:e})},onAnnotationSelect:e=>{u(`annotationSelect`,{annotationId:e})},onToolChange:e=>{u(`toolChange`,e)},onLibraryToggle:e=>{u(`libraryToggle`,e)},onAction:e=>{u(`action`,e)},onNameChange:e=>{u(`nameChange`,e)},onOpenNodePanel:e=>{u(`openNodePanel`,e)},onPanelAction:(e,t)=>{e.startsWith(`panel:`)?Uv().openProjectPanel(e.slice(6),t):u(`action`,{action:e,nodeId:t})}})}),e(()=>O(l),()=>{fa(O(l))}),ie();var _e={addNode:F,centerOnNodes:ne,selectAll:re,deselectAll:L,deleteSelected:R,openCodeEditor:ce,resetLayout:V,focusPanel:H};le();var ye=Kv();f(`click`,fe,K);var be=B(ye);pe(be,e=>Y(N,e),()=>O(N));var xe=G(be,2),Se=e=>{var t=Gv();v(t,5,i,c,(e,t)=>{var n=Wv(),r=q(n);Mc(r,{get icon(){return O(t),y(()=>O(t).icon)},size:14,class:`panel-icon`});var i=G(r,2),a=M(i,!0);w(n),J(()=>X(a,(O(t),y(()=>O(t).label)))),f(`click`,n,()=>me(O(t).type)),E(e,n)}),w(t),pe(t,e=>Y(h,e),()=>O(h)),J(()=>o(t,O(g))),f(`click`,t,ae(function(e){ge.call(this,n,e)})),E(e,t)};m(xe,e=>{O(d)&&e(Se)}),E(t,ye),ue(n,`addNode`,F),ue(n,`centerOnNodes`,ne),ue(n,`selectAll`,re),ue(n,`deselectAll`,L),ue(n,`deleteSelected`,R),ue(n,`openCodeEditor`,ce),ue(n,`resetLayout`,V),ue(n,`focusPanel`,H);var Ce=S(_e);return s(),Ce}var Jv=T(`<div class="separator svelte-1tlamc9"></div>`),Yv=T(`<span class="item-shortcut svelte-1tlamc9"> </span>`),Xv=T(`<button class="dropdown-item svelte-1tlamc9"><span class="item-label svelte-1tlamc9"> </span> <!></button>`),Zv=T(`<div class="dropdown svelte-1tlamc9"></div>`),Qv=T(`<button><span class="item-label svelte-1tlamc9"> </span> <!></button>`),$v=T(`<input class="name-input svelte-1tlamc9" type="text"/>`),ey=T(`<button class="document-name svelte-1tlamc9" title="Click to rename"> </button>`),ty=T(`<div class="menu-bar svelte-1tlamc9"><div class="menu-left svelte-1tlamc9"><div><button class="menu-button svelte-1tlamc9">File</button> <!></div> <div><button class="menu-button svelte-1tlamc9">Edit</button> <!></div> <div class="menu-item svelte-1tlamc9"><button class="menu-button svelte-1tlamc9">Create</button></div> <div><button class="menu-button svelte-1tlamc9">View</button> <!></div></div> <div class="menu-center svelte-1tlamc9"><!></div> <div class="menu-right svelte-1tlamc9"></div></div>`);function ny(t,n){r(n,!1);let a=I(),o=I(),s=z(n,`documentName`,8,`Untitled`),l=z(n,`canUndo`,8,!1),d=z(n,`canRedo`,8,!1),p=ve(),h=I(null),g=I(!1),_=I(),b=I(s()),x=I();function C(e){O(h)===e?Y(h,null):Y(h,e)}function T(e){p(`action`,e),Y(h,null)}function D(){if(O(x)){let e=O(x).getBoundingClientRect();p(`openNodePanel`,{x:e.left,y:e.bottom+4})}else p(`action`,`addNode`);Y(h,null)}function ee(e){e.target.closest(`.menu-bar`)||Y(h,null)}function A(){Y(g,!0),Y(b,s()),setTimeout(()=>{O(_)?.focus(),O(_)?.select()},0)}function j(){Y(g,!1),O(b).trim()&&O(b)!==s()&&p(`nameChange`,O(b).trim())}function N(e){e.key===`Enter`?j():e.key===`Escape`&&(Y(g,!1),Y(b,s()))}let P=[{label:`Clean Up Layout`,action:`cleanUpLayout`,shortcut:`⇧L`},{label:`Center on Nodes`,action:`centerOnNodes`,shortcut:`H`},{label:`Reset Layout`,action:`resetLayout`,shortcut:`⇧⌘P`},{type:`separator`},{label:`Maximize Tab`,action:`maximizeTab`,shortcut:`⌘B`},{label:`Presentation Mode`,action:`presentationMode`,shortcut:`⌘.`},{type:`separator`},{label:`Focus Graph`,action:`focusGraph`,shortcut:`⌘1`},{label:`Focus Viewer`,action:`focusViewer`,shortcut:`⌘2`},{label:`Focus Inspector`,action:`focusInspector`,shortcut:`⌘3`},{label:`Focus Log`,action:`focusLog`,shortcut:`⌘4`}];e(()=>k(s()),()=>{Y(b,s())}),e(()=>{},()=>{Y(a,[{label:`New Project`,action:`new`,shortcut:`⌥N`},{label:`Open...`,action:`open`,shortcut:`⌥O`},{type:`separator`},{label:`Save`,action:`save`,shortcut:`⌥S`},{label:`Save As...`,action:`saveAs`,shortcut:`⇧⌥S`},{label:`Version History...`,action:`versionHistory`},{type:`separator`},{label:`Export...`,action:`export`,shortcut:`⌘E`},{type:`separator`},{label:`Project Settings...`,action:`projectSettings`,shortcut:`⇧⌘,`},{label:`Settings...`,action:`settings`,shortcut:`⌘,`},{type:`separator`},{label:`About Cascade`,action:`about`}])}),e(()=>(k(l()),k(d())),()=>{Y(o,[{label:`Undo`,action:`undo`,shortcut:`⌘Z`,disabled:!l()},{label:`Redo`,action:`redo`,shortcut:`⇧⌘Z`,disabled:!d()},{type:`separator`},{label:`Select All`,action:`selectAll`,shortcut:`⌘A`},{label:`Deselect All`,action:`deselectAll`,shortcut:`⇧⌘A`},{type:`separator`},{label:`Delete Selected`,action:`delete`,shortcut:`⌫`}])}),ie(),le();var F=ty();f(`click`,fe,ee);var ne=q(F),re=q(ne);let ae;var L=q(re),oe=G(L,2),R=e=>{var t=Zv();v(t,5,()=>O(a),c,(e,t)=>{var n=u(),r=B(n),i=e=>{var t=Jv();E(e,t)},a=e=>{var n=Xv(),r=q(n),i=M(r,!0),a=G(r,2),o=e=>{var n=Yv(),r=M(n,!0);J(()=>X(r,(O(t),y(()=>O(t).shortcut)))),E(e,n)};m(a,e=>{O(t),y(()=>O(t).shortcut)&&e(o)}),w(n),J(()=>X(i,(O(t),y(()=>O(t).label)))),f(`click`,n,()=>O(t).action&&T(O(t).action)),E(e,n)};m(r,e=>{O(t),y(()=>O(t).type===`separator`)?e(i):e(a,-1)}),E(e,n)}),w(t),E(e,t)};m(oe,e=>{O(h)===`file`&&e(R)}),w(re);var se=G(re,2);let ce;var V=q(se),H=G(V,2),ue=e=>{var t=Zv();v(t,5,()=>O(o),c,(e,t)=>{var n=u(),r=B(n),a=e=>{var t=Jv();E(e,t)},o=e=>{var n=Qv();let r;var a=q(n),o=M(a,!0),s=G(a,2),c=e=>{var n=Yv(),r=M(n,!0);J(()=>X(r,(O(t),y(()=>O(t).shortcut)))),E(e,n)};m(s,e=>{O(t),y(()=>O(t).shortcut)&&e(c)}),w(n),J(()=>{r=i(n,1,`dropdown-item svelte-1tlamc9`,null,r,{disabled:O(t).disabled}),n.disabled=(O(t),y(()=>O(t).disabled)),X(o,(O(t),y(()=>O(t).label)))}),f(`click`,n,()=>!O(t).disabled&&O(t).action&&T(O(t).action)),E(e,n)};m(r,e=>{O(t),y(()=>O(t).type===`separator`)?e(a):e(o,-1)}),E(e,n)}),w(t),E(e,t)};m(H,e=>{O(h)===`edit`&&e(ue)}),w(se);var U=G(se,2),de=q(U);pe(de,e=>Y(x,e),()=>O(x)),w(U);var W=G(U,2);let me;var K=q(W),he=G(K,2),ge=e=>{var t=Zv();v(t,5,()=>P,c,(e,t)=>{var n=u(),r=B(n),i=e=>{var t=Jv();E(e,t)},a=e=>{var n=Xv(),r=q(n),i=M(r,!0),a=G(r,2),o=e=>{var n=Yv(),r=M(n,!0);J(()=>X(r,(O(t),y(()=>O(t).shortcut)))),E(e,n)};m(a,e=>{O(t),y(()=>O(t).shortcut)&&e(o)}),w(n),J(()=>X(i,(O(t),y(()=>O(t).label)))),f(`click`,n,()=>O(t).action&&T(O(t).action)),E(e,n)};m(r,e=>{O(t),y(()=>O(t).type===`separator`)?e(i):e(a,-1)}),E(e,n)}),w(t),E(e,t)};m(he,e=>{O(h)===`view`&&e(ge)}),w(W),w(ne);var _e=G(ne,2),ye=q(_e),be=e=>{var t=$v();Ee(t),pe(t,e=>Y(_,e),()=>O(_)),te(t,()=>O(b),e=>Y(b,e)),f(`blur`,t,j),f(`keydown`,t,N),E(e,t)},xe=e=>{var t=ey(),n=M(t,!0);J(()=>X(n,s())),f(`click`,t,A),E(e,t)};m(ye,e=>{O(g)?e(be):e(xe,-1)}),w(_e),Ce(2),w(F),J(()=>{ae=i(re,1,`menu-item svelte-1tlamc9`,null,ae,{active:O(h)===`file`}),ce=i(se,1,`menu-item svelte-1tlamc9`,null,ce,{active:O(h)===`edit`}),me=i(W,1,`menu-item svelte-1tlamc9`,null,me,{active:O(h)===`view`})}),f(`click`,L,()=>C(`file`)),f(`click`,V,()=>C(`edit`)),f(`click`,de,D),f(`click`,K,()=>C(`view`)),E(t,F),S()}var ry=`cascade-node-history`,iy=5;function ay(){try{let e=localStorage.getItem(ry);if(e)return JSON.parse(e)}catch(e){console.warn(`Failed to load node history:`,e)}return[]}function oy(e){try{localStorage.setItem(ry,JSON.stringify(e))}catch(e){console.warn(`Failed to save node history:`,e)}}function sy(){let{subscribe:e,set:t,update:n}=P(ay());return{subscribe:e,addToHistory(e){n(t=>{let n=[e,...t.filter(t=>t.type!==e.type)].slice(0,iy);return oy(n),n})},clear(){t([]),localStorage.removeItem(ry)}}}var cy=sy(),ly=T(`<button><span class="node-icon svelte-dm3w9n"><!></span> <span class="node-name svelte-dm3w9n"> </span> <span class="node-path svelte-dm3w9n"> </span></button>`),uy=T(`<div class="empty-state svelte-dm3w9n">No nodes found</div>`),dy=T(`<!> <!>`,1),fy=T(`<button><span class="label svelte-dm3w9n"> </span> <span class="arrow-icon svelte-dm3w9n"><!></span></button>`),py=T(`<button class="node-item history-item svelte-dm3w9n"><span class="node-icon svelte-dm3w9n"><!></span> <span class="node-name svelte-dm3w9n"> </span> <span class="node-path svelte-dm3w9n"> </span></button>`),my=T(`<div class="separator svelte-dm3w9n"></div> <div class="section-label svelte-dm3w9n">Recent</div> <!>`,1),hy=T(`<!> <div class="separator svelte-dm3w9n"></div> <button><span class="label svelte-dm3w9n">All</span> <span class="arrow-icon svelte-dm3w9n"><!></span></button> <div class="separator svelte-dm3w9n"></div> <button class="library-item svelte-dm3w9n"><span class="node-icon"><!></span> <span class="label svelte-dm3w9n"> </span></button> <!>`,1),gy=T(`<div class="menu-column submenu-column svelte-dm3w9n" role="group" aria-label="All nodes"></div>`),_y=T(`<div class="separator svelte-dm3w9n"></div>`),vy=T(`<button class="node-item svelte-dm3w9n"><span class="node-icon svelte-dm3w9n"><!></span> <span class="node-name svelte-dm3w9n"> </span></button>`),yy=T(`<button><span class="node-icon svelte-dm3w9n"><!></span> <span class="node-name svelte-dm3w9n"> </span></button>`),by=T(`<div class="menu-column submenu-column nodes-submenu svelte-dm3w9n" role="group"></div>`),xy=T(`<div class="menu-column submenu-column svelte-dm3w9n" role="group"><!> <!> <!></div> <!>`,1),Sy=T(`<div class="menu-column main-column svelte-dm3w9n" role="dialog" aria-label="Create node" tabindex="-1"><div class="search svelte-dm3w9n"><input type="text" placeholder="Type to search..." class="search-input svelte-dm3w9n"/></div> <!></div> <!>`,1);function Cy(n,a){r(a,!1);let s=()=>oe(Wp,`$projectNodeModules`,p),l=()=>oe(Up,`$iconByModule`,p),d=()=>oe(cy,`$nodeHistoryStore`,p),[p,h]=se(),g=I(),_=I(),b=I(),x=I(),C=I(),T=I(),D=I(),ee=I(),A=I(),j=I(),P=I(),F=I(),re=I(),ae=I(),L=I(!1),R=I(null);async function ce(){Y(R,O(R)??(await ol(async()=>{let{default:e}=await import(`./CustomNodeDialog-026lzecD.js`);return{default:e}},__vite__mapDeps([3,1,4]))).default),Y(L,!0)}let V=z(a,`libraryId`,8,null),H=z(a,`categoryId`,12,null),ue=z(a,`centerPosition`,24,()=>({x:0,y:0})),U=z(a,`fixedPosition`,8,null),de=ve(),W=I(),me=I(``),K=I(),ge=I(),_e=I({x:0,y:0}),ye=I(!1),be=I(160),xe=I(180),Se=I(-1),Ce=I(-1),we=I(-1),Te=I(`library`),De=I(void 0),Oe=I(null),ke=I(0),je=I(0);function Me(){if(U()){Y(_e,{x:U().x,y:U().y}),Y(ye,!0);return}if(!O(K)){(ue().x!==0||ue().y!==0)&&Y(_e,{x:ue().x,y:ue().y});return}let e=document.querySelector(`[data-window-id="graph"]`);if(!e){Y(_e,{x:ue().x-80,y:ue().y-200}),Y(ye,!0);return}let t=e.getBoundingClientRect(),n=O(K).getBoundingClientRect(),r=n.width||160,i=n.height||400,a=ue().x-t.left-r/2,o=ue().y-t.top-i/2,s=t.width-r-10,c=t.height-i-10;a=Math.max(10,Math.min(s,a)),o=Math.max(10,Math.min(c,o)),Y(_e,{x:t.left+a,y:t.top+o}),Y(ye,!0)}he(()=>{let e=()=>{(V()||H())&&Me()};window.addEventListener(`resize`,e);let t=e=>{if(!O(L)&&(V()||H())){let t=e.target,n=document.querySelectorAll(`.menu-column`),r=!1;n.forEach(e=>{e.contains(t)&&(r=!0)}),document.querySelector(`.dialog-overlay`)?.contains(t)&&(r=!0),r||Re()}};return document.addEventListener(`mousedown`,t,!0),()=>{window.removeEventListener(`resize`,e),document.removeEventListener(`mousedown`,t,!0)}});function Ne(e){let t=O(g).find(t=>t.id===e);if(!t)return[];let n=[];return t.categories.forEach(e=>{n.push(...e.nodes)}),n}function Pe(e){let t=e.categoryId||H(),n=e.type.startsWith(`annotation:`)?e.type:Ae(e.type);cy.addToHistory({name:e.name,icon:e.icon,description:e.description,type:e.type}),de(`addNode`,{type:n,libraryId:V(),categoryId:t})}function Fe(e,t){de(`selectCategory`,{libraryId:e,categoryId:t})}function Ie(e){let{name:t,modulePath:n,baseClass:r,template:i}=e.detail,a=(Ip[i]||Ip.node)(t);cy.addToHistory({name:t,icon:`Zap`,description:`Custom node based on ${r}`,type:n}),de(`addNode`,{type:n,libraryId:null,categoryId:null,customConfig:{name:t,modulePath:n,baseClass:r,code:a}}),Y(L,!1),Re()}function Le(e){e===`all`?(de(`selectLibrary`,{libraryId:null}),Y(Te,`node`)):(de(`selectLibrary`,{libraryId:e}),Y(Te,`node`))}function Re(){de(`close`)}function ze(e){return e.data}function Be(e){if(!(!V()&&!H())&&[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Enter`,`Escape`].includes(e.key)){if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),Re();return}if(document.activeElement===O(W)&&e.key!==`Escape`){if(O(me)&&(e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Enter`))e.preventDefault(),e.stopPropagation(),O(W).blur();else return}if(e.preventDefault(),e.stopPropagation(),e.key===`ArrowLeft`){if(O(me))return;O(Te)===`category`&&V()?H()?(Y(Te,`category`),Y(we,-1),H(null)):(Y(Te,`library`),Y(Ce,-1)):O(Te)===`node`&&H()&&(Y(Te,`category`),Y(we,-1))}else if(e.key===`ArrowRight`){if(O(me))return;if(O(Te)===`library`&&V())(O(F).length>0||O(re).length>0)&&(Y(Te,`category`),O(Ce)===-1&&Y(Ce,0));else if(O(Te)===`category`&&!H()&&O(Ce)>=0&&O(Ce)<O(ae).length){let e=O(ae)[O(Ce)];e.type===`category`&&`id`in e.data&&(V()&&`id`in e.data&&Fe(V(),e.data.id),Y(Te,`node`),O(we)===-1&&Y(we,0))}}else if(e.key===`ArrowUp`){if(O(me))Y(Te,`node`),Y(we,Math.max(0,O(we)-1));else if(O(Te)===`library`)Y(Se,Math.max(0,O(Se)-1)),O(Se)>=0&&O(Se)<O(P).length&&Le(O(P)[O(Se)].id);else if(O(Te)===`category`){if(H())Y(we,Math.max(0,O(we)-1));else if(Y(Ce,Math.max(0,O(Ce)-1)),O(Ce)>=0&&O(Ce)<O(ae).length&&V()){let e=O(ae)[O(Ce)];e.type===`category`&&`id`in e.data&&Fe(V(),e.data.id)}}else O(Te)===`node`&&Y(we,Math.max(0,O(we)-1))}else if(e.key===`ArrowDown`){if(O(me))Y(Te,`node`),Y(we,Math.min(O(j).length-1,O(we)+1));else if(O(Te)===`library`)Y(Se,Math.min(O(P).length-1,O(Se)+1)),O(Se)>=0&&O(Se)<O(P).length&&Le(O(P)[O(Se)].id);else if(O(Te)===`category`){if(H())Y(we,Math.min(O(j).length-1,O(we)+1));else if(Y(Ce,Math.min(O(ae).length-1,O(Ce)+1)),O(Ce)>=0&&O(Ce)<O(ae).length&&V()){let e=O(ae)[O(Ce)];e.type===`category`&&`id`in e.data&&Fe(V(),e.data.id)}}else O(Te)===`node`&&Y(we,Math.min(O(j).length-1,O(we)+1))}else if(e.key===`Enter`){if(O(me))O(Te)===`node`&&O(we)>=0&&O(we)<O(j).length&&Pe(O(j)[O(we)]);else if(O(Te)===`node`&&H())O(we)>=0&&O(we)<O(j).length&&Pe(O(j)[O(we)]);else if(O(Te)===`category`&&!H()){if(O(Ce)>=0&&O(Ce)<O(ae).length&&V()){let e=O(ae)[O(Ce)];e.type===`category`&&`id`in e.data?(Fe(V(),e.data.id),Y(Te,`node`),Y(we,0)):e.type===`computation`&&Pe(ze(e))}}else O(Te)===`library`&&O(Se)>=0&&O(Se)<O(P).length&&(Le(O(P)[O(Se)].id),(O(F).length>0||O(re).length>0)&&(Y(Te,`category`),Y(Ce,0)))}}}function Ve(e){e.stopPropagation(),[`ArrowUp`,`ArrowDown`,`Enter`,`Escape`].includes(e.key)&&Be(e)}e(()=>(s(),l()),()=>{Y(g,[...Np,...s().length?[Pp(s(),l())]:[]])}),e(()=>(k(V()),k(H()),k(U())),()=>{(V()||H())&&(U()?(Y(_e,{x:U().x,y:U().y}),Y(ye,!0)):setTimeout(()=>{Me(),setTimeout(()=>{Me()},50)},0))}),e(()=>(k(V()),O(g)),()=>{Y(_,V()&&V()!==`all`?O(g).find(e=>e.id===V()):null)}),e(()=>(O(_),k(H())),()=>{Y(b,O(_)&&H()?O(_).categories.find(e=>e.id===H()):null)}),e(()=>(O(De),O(g)),()=>{Y(x,O(De)&&O(De)!==`all`?O(g).find(e=>e.id===O(De)):null)}),e(()=>O(x),()=>{Y(C,O(x)?O(x).categories.length===1:!1)}),e(()=>(O(x),O(C)),()=>{Y(T,O(x)?O(C)?[]:O(x).categories.filter(e=>e.nodes.length>1):[])}),e(()=>(O(x),O(C)),()=>{Y(D,O(x)?O(C)?O(x).categories[0].nodes:O(x).categories.filter(e=>e.nodes.length===1).map(e=>e.nodes[0]):[])}),e(()=>O(De),()=>{O(De)&&Y(Oe,null)}),e(()=>(O(Oe),O(x)),()=>{Y(ee,O(Oe)&&O(x)&&O(x).categories.find(e=>e.id===O(Oe))?.nodes||[])}),e(()=>(O(De),O(g)),()=>{Y(A,O(De)===null?O(g).flatMap(e=>e.categories.flatMap(e=>e.nodes)).sort((e,t)=>e.name.localeCompare(t.name)):[])}),e(()=>(O(De),O(K)),()=>{O(De)!==void 0&&O(K)&&Y(be,O(K).getBoundingClientRect().width)}),e(()=>(O(Oe),O(ge)),()=>{O(Oe)&&O(ge)&&Y(xe,O(ge).getBoundingClientRect().width)}),e(()=>(O(me),O(g),k(V()),k(H())),()=>{Y(j,O(me)?O(g).flatMap(e=>e.categories.flatMap(e=>e.nodes)).filter(e=>e.name.toLowerCase().includes(O(me).toLowerCase())||e.description.toLowerCase().includes(O(me).toLowerCase())).sort((e,t)=>e.name.localeCompare(t.name)):V()===`all`||V()===null&&!H()?O(g).flatMap(e=>e.categories.flatMap(e=>e.nodes)).sort((e,t)=>e.name.localeCompare(t.name)):V()&&!H()?Ne(V()).sort((e,t)=>e.name.localeCompare(t.name)):H()&&V()?(O(g).find(e=>e.id===V())?.categories.find(e=>e.id===H())?.nodes??[]).sort((e,t)=>e.name.localeCompare(t.name)):[])}),e(()=>O(g),()=>{Y(P,O(g).filter(e=>e.categories.some(e=>e.nodes.length>0)).sort((e,t)=>e.label.localeCompare(t.label)))}),e(()=>O(_),()=>{Y(F,O(_)?O(_).categories.filter(e=>e.nodes.length>1):[])}),e(()=>(O(_),k(H()),O(me)),()=>{Y(re,O(_)&&!H()&&!O(me)?O(_).categories.filter(e=>e.nodes.length===1).map(e=>({...e.nodes[0],categoryId:e.id})):[])}),e(()=>(O(_),k(H()),O(me),O(F),O(re)),()=>{Y(ae,O(_)&&!H()&&!O(me)?[...O(F).map(e=>({type:`category`,data:e})),...O(re).map(e=>({type:`node`,data:e}))]:[])}),e(()=>(k(V()),k(H()),O(me),O(Te),O(j),O(we),O(Se),O(P),O(_),O(Ce),O(F),O(ae)),()=>{(V()||H())&&(O(me)?(Y(Te,`node`),O(j).length>0?(O(we)<0||O(we)>=O(j).length)&&Y(we,0):Y(we,-1)):(O(Se)===-1&&(V()&&V()!==`all`?(Y(Se,O(P).findIndex(e=>e.id===V())),O(Se)===-1&&Y(Se,0)):Y(Se,0),Y(Te,`library`)),H()&&O(_)&&O(Ce)===-1&&(Y(Ce,O(F).findIndex(e=>e.id===H())),O(Ce)===-1&&Y(Ce,0),H()&&Y(Te,`node`)),O(Ce)===-1&&O(ae).length>0&&O(Te)===`category`&&!H()?Y(Ce,0):O(Te)===`category`&&O(Ce)>=O(ae).length&&Y(Ce,Math.max(0,O(ae).length-1)),O(we)===-1&&O(j).length>0&&O(Te)===`node`&&H()?Y(we,0):O(Te)===`node`&&O(we)>=O(j).length&&H()&&Y(we,Math.max(0,O(j).length-1))))}),e(()=>(k(V()),k(H())),()=>{!V()&&!H()&&(Y(Se,-1),Y(Ce,-1),Y(we,-1),Y(Te,`library`))}),e(()=>(O(Te),O(Se),O(K)),()=>{O(Te)===`library`&&O(Se)>=0&&setTimeout(()=>{let e=(O(K)?.querySelector(`.main-column .column-content`))?.children[O(Se)+1];e&&e.scrollIntoView({block:`nearest`,behavior:`smooth`})},0)}),e(()=>(O(Te),O(Ce),k(H()),O(K)),()=>{O(Te)===`category`&&O(Ce)>=0&&!H()&&setTimeout(()=>{let e=(O(K)?.querySelector(`.main-column .column-content`))?.children[O(Ce)];e&&e.scrollIntoView({block:`nearest`,behavior:`smooth`})},0)}),e(()=>(O(Te),O(we),O(K)),()=>{O(Te)===`node`&&O(we)>=0&&setTimeout(()=>{let e=document.querySelector(`.nodes-column .column-content`);if(e){let t=e.children[O(we)];t&&t.scrollIntoView({block:`nearest`,behavior:`smooth`})}else{let e=(O(K)?.querySelector(`.main-column .column-content`))?.children[O(we)];e&&e.scrollIntoView({block:`nearest`,behavior:`smooth`})}},0)}),e(()=>(k(V()),k(H()),O(W)),()=>{(V()||H())&&O(W)&&setTimeout(()=>{O(W)?.focus()},0)}),e(()=>(k(V()),k(H()),O(K),O(W)),()=>{(V()||H())&&O(K)&&setTimeout(()=>{document.activeElement!==O(W)&&O(K)?.focus()},50)}),ie(),le();var He=dy();f(`keydown`,fe,Be);var Ue=B(He),We=e=>{var t=Sy(),n=B(t),r=q(n),a=q(r);Ee(a),pe(a,e=>Y(W,e),()=>O(W)),w(r);var s=G(r,2),l=e=>{var t=dy(),n=B(t);v(n,1,()=>O(j),c,(e,t,n)=>{var r=ly();let a;var o=q(r);Ac(q(o),{get name(){return O(t),y(()=>O(t).icon)},size:16}),w(o);var s=G(o,2),c=M(s,!0),l=G(s,2),u=M(l,!0);w(r),J(e=>{a=i(r,1,`node-item svelte-dm3w9n`,null,a,{"keyboard-selected":O(Te)===`node`&&O(we)===n}),N(r,`title`,(O(t),y(()=>O(t).description))),X(c,(O(t),y(()=>O(t).name))),X(u,e)},[()=>(k(zp),O(t),y(()=>zp(O(t).type)))]),f(`click`,r,()=>{Y(we,n),Pe(O(t))}),f(`mouseenter`,r,()=>{Y(we,n)}),E(e,r)});var r=G(n,2),a=e=>{var t=uy();E(e,t)};m(r,e=>{O(j),y(()=>O(j).length===0)&&e(a)}),E(e,t)},p=e=>{var t=hy(),n=B(t);v(n,1,()=>O(P),c,(e,t,n)=>{var r=fy();let a;var o=q(r),s=M(o,!0),c=G(o,2);Ac(q(c),{name:`ChevronRight`,size:12}),w(c),w(r),J(()=>{a=i(r,1,`library-item svelte-dm3w9n`,null,a,{active:O(De)===O(t).id,"keyboard-selected":O(Te)===`library`&&O(Se)===n}),X(s,(O(t),y(()=>O(t).label)))}),f(`click`,r,()=>{Y(Se,n),Le(O(t).id)}),f(`mouseenter`,r,e=>{Y(Se,n),Y(De,O(t).id),Y(ke,e.currentTarget.getBoundingClientRect().top)}),E(e,r)});var r=G(n,4);let a;var o=G(q(r),2);Ac(q(o),{name:`ChevronRight`,size:12}),w(o),w(r);var s=G(r,4),l=q(s);Ac(q(l),{get name(){return k(Fp),y(()=>Fp.icon)},size:16}),w(l);var u=G(l,2),p=M(u,!0);w(s);var h=G(s,2),g=e=>{var t=my(),n=G(B(t),4);v(n,1,d,c,(e,t)=>{var n=py(),r=q(n);Ac(q(r),{get name(){return O(t),y(()=>O(t).icon)},size:16}),w(r);var i=G(r,2),a=M(i,!0),o=G(i,2),s=M(o,!0);w(n),J(e=>{N(n,`title`,(O(t),y(()=>O(t).description))),X(a,(O(t),y(()=>O(t).name))),X(s,e)},[()=>(k(zp),O(t),y(()=>zp(O(t).type)))]),f(`click`,n,()=>Pe(O(t))),E(e,n)}),E(e,t)};m(h,e=>{d(),y(()=>d().length>0)&&e(g)}),J(()=>{a=i(r,1,`library-item svelte-dm3w9n`,null,a,{active:O(De)===null,"keyboard-selected":O(Te)===`library`&&O(Se)===O(P).length}),N(s,`title`,(k(Fp),y(()=>Fp.description))),X(p,(k(Fp),y(()=>Fp.name)))}),f(`click`,r,()=>{Y(Se,O(P).length),Le(`all`)}),f(`mouseenter`,r,e=>{Y(Se,O(P).length),Y(De,null),Y(ke,e.currentTarget.getBoundingClientRect().top)}),f(`click`,s,ce),E(e,t)};m(s,e=>{O(me)?e(l):e(p,-1)}),w(n),pe(n,e=>Y(K,e),()=>O(K));var h=G(n,2),g=e=>{var t=u(),n=B(t),r=e=>{var t=gy();v(t,5,()=>O(A),c,(e,t,n)=>{var r=ly();let a;var o=q(r);Ac(q(o),{get name(){return O(t),y(()=>O(t).icon)},size:16}),w(o);var s=G(o,2),c=M(s,!0),l=G(s,2),u=M(l,!0);w(r),J(e=>{a=i(r,1,`node-item svelte-dm3w9n`,null,a,{"keyboard-selected":O(Te)===`node`&&O(we)===n}),N(r,`title`,(O(t),y(()=>O(t).description))),X(c,(O(t),y(()=>O(t).name))),X(u,e)},[()=>(k(zp),O(t),y(()=>zp(O(t).type)))]),f(`click`,r,()=>{Y(we,n),Pe(O(t))}),f(`mouseenter`,r,()=>{Y(we,n)}),E(e,r)}),w(t),J(e=>o(t,`left: ${O(_e),O(be),y(()=>O(_e).x+O(be))??``}px; top: ${O(ke)??``}px; max-height: ${e??``}px;`),[()=>(O(ke),y(()=>Math.max(200,window.innerHeight-O(ke)-20)))]),f(`mouseenter`,t,()=>{}),f(`mouseleave`,t,ne(()=>{setTimeout(()=>{document.querySelector(`.menu-column:hover`)||Y(De,void 0)},50)})),E(e,t)},a=e=>{var t=xy(),n=B(t),r=q(n);v(r,1,()=>O(T),c,(e,t)=>{var n=fy();let r;var a=q(n),o=M(a,!0),s=G(a,2);Ac(q(s),{name:`ChevronRight`,size:12}),w(s),w(n),J(()=>{r=i(n,1,`library-item svelte-dm3w9n`,null,r,{active:O(Oe)===O(t).id}),X(o,(O(t),y(()=>O(t).label)))}),f(`click`,n,()=>{}),f(`mouseenter`,n,e=>{Y(Oe,O(t).id),Y(je,e.currentTarget.getBoundingClientRect().top)}),E(e,n)});var a=G(r,2),s=e=>{var t=_y();E(e,t)};m(a,e=>{O(T),O(D),y(()=>O(T).length>0&&O(D).length>0)&&e(s)});var l=G(a,2);v(l,1,()=>O(D),c,(e,t)=>{var n=vy(),r=q(n);Ac(q(r),{get name(){return O(t),y(()=>O(t).icon)},size:16}),w(r);var i=G(r,2),a=M(i,!0);w(n),J(()=>{N(n,`title`,(O(t),y(()=>O(t).description))),X(a,(O(t),y(()=>O(t).name)))}),f(`click`,n,()=>Pe(O(t))),f(`mouseenter`,n,()=>{Y(Oe,null)}),E(e,n)}),w(n),pe(n,e=>Y(ge,e),()=>O(ge));var u=G(n,2),d=e=>{var t=by();v(t,5,()=>O(ee),c,(e,t,n)=>{var r=yy();let a;var o=q(r);Ac(q(o),{get name(){return O(t),y(()=>O(t).icon)},size:16}),w(o);var s=G(o,2),c=M(s,!0);w(r),J(()=>{a=i(r,1,`node-item svelte-dm3w9n`,null,a,{"keyboard-selected":O(Te)===`node`&&O(we)===n}),N(r,`title`,(O(t),y(()=>O(t).description))),X(c,(O(t),y(()=>O(t).name)))}),f(`click`,r,()=>{Y(we,n),Pe(O(t))}),f(`mouseenter`,r,()=>{Y(we,n)}),E(e,r)}),w(t),J(e=>{N(t,`aria-label`,`${O(Oe)} nodes`),o(t,`left: ${O(_e),O(be),O(xe),y(()=>O(_e).x+O(be)+O(xe))??``}px; top: ${O(je)??``}px; max-height: ${e??``}px;`)},[()=>(O(je),y(()=>Math.max(200,window.innerHeight-O(je)-20)))]),f(`mouseenter`,t,()=>{}),f(`mouseleave`,t,ne(()=>{setTimeout(()=>{document.querySelector(`.menu-column:hover`)||Y(Oe,null)},50)})),E(e,t)};m(u,e=>{O(Oe),O(ee),y(()=>O(Oe)&&O(ee).length>0)&&e(d)}),J(e=>{N(n,`aria-label`,(O(x),y(()=>`${O(x).label} nodes`))),o(n,`left: ${O(_e),O(be),y(()=>O(_e).x+O(be))??``}px; top: ${O(ke)??``}px; max-height: ${e??``}px;`)},[()=>(O(ke),y(()=>Math.max(200,window.innerHeight-O(ke)-20)))]),f(`mouseenter`,n,()=>{}),f(`mouseleave`,n,ne(()=>{setTimeout(()=>{document.querySelector(`.menu-column:hover`)||(Y(De,void 0),Y(Oe,null))},50)})),E(e,t)};m(n,e=>{O(De),O(A),y(()=>O(De)===null&&O(A).length>0)?e(r):(O(x),O(T),O(D),y(()=>O(x)&&(O(T).length>0||O(D).length>0))&&e(a,1))}),E(e,t)};m(h,e=>{!O(me)&&O(De)!==void 0&&e(g)}),J(()=>o(n,`left: ${O(_e),y(()=>O(_e).x)??``}px; top: ${O(_e),y(()=>O(_e).y)??``}px`)),te(a,()=>O(me),e=>Y(me,e)),f(`keydown`,a,Ve),f(`keydown`,n,Be),f(`mouseleave`,n,ne(e=>{setTimeout(()=>{if(O(L))return;let e=document.querySelector(`.menu-column:hover`),t=document.querySelector(`.dialog-overlay`);!e&&!t&&Re()},100)})),E(e,t)};m(Ue,e=>{(V()||H())&&e(We)});var Ge=G(Ue,2),Ke=e=>{var n=u(),r=B(n);t(r,()=>O(R),(e,t)=>{t(e,{get open(){return O(L)},set open(e){Y(L,e)},$$events:{create:Ie,close:()=>Y(L,!1)},$$legacy:!0})}),E(e,n)};m(Ge,e=>{O(R)&&e(Ke)}),E(n,He),S(),h()}var wy=P(!1);function Ty(){wy.set(!1)}var Ey=T(`<button class="swatch svelte-tkyoee"></button>`),Dy=T(`<div class="palette svelte-tkyoee"><div class="head svelte-tkyoee"><span>Node colour</span> <span class="count svelte-tkyoee"> </span></div> <div class="grid svelte-tkyoee"></div> <div class="foot svelte-tkyoee"><button class="clear svelte-tkyoee">Clear</button> <button class="clear svelte-tkyoee">Close</button></div></div>`);function Oy(e,t){r(t,!1);let n=z(t,`open`,8,!1),i=z(t,`selectionCount`,8,0),a=ve(),s=[[`#3a3a3a`,`#454545`,`#505050`,`#5c5c5c`,`#686868`,`#757575`,`#828282`,`#909090`],...[0,28,45,140,190,215,265,320].slice(1).map(e=>[20,26,32,38,44,50,56,62].map(t=>`hsl(${e}, 42%, ${t/2+12}%)`))];function l(e){a(`choose`,e)}function d(e){e.key===`Escape`&&a(`close`)}le();var p=u();f(`keydown`,fe,d);var h=B(p),g=e=>{var t=Dy(),n=q(t),r=G(q(n),2),d=M(r);w(n);var p=G(n,2);v(p,5,()=>s,c,(e,t)=>{var n=u(),r=B(n);v(r,1,()=>O(t),c,(e,t)=>{var n=Ey();J(()=>{o(n,`background:${O(t)??``}`),N(n,`title`,O(t))}),f(`click`,n,()=>l(O(t))),E(e,n)}),E(e,n)}),w(p);var m=G(p,2),h=q(m),g=G(h,2);w(m),w(t),J(()=>X(d,`${i()??``} selected`)),f(`click`,h,()=>l(null)),f(`click`,g,()=>a(`close`)),E(e,t)};m(h,e=>{n()&&e(g)}),E(e,p),S()}var ky=`*`;function Ay(e){if(typeof EventSource>`u`)return()=>{};let t=new EventSource(`/api/nodes/events`);return t.addEventListener(`module-changed`,t=>{let n;try{n=String(JSON.parse(t.data)?.module??``)}catch{return}if(!n)return;let r=e.getTarget()?.nodes??[],i=n===ky?r.filter(e=>e.modulePath?.startsWith(`project.`)):r.filter(e=>e.modulePath===`project.${n}`);if(n===ky)for(let e of i)hl(e.modulePath.slice(8));else hl(n);for(let e of i)e.markDirty();e.onReload?.(n,i.length)}),t.addEventListener(`error`,()=>console.debug(`[node watch] stream interrupted, reconnecting`)),()=>t.close()}var jy=12e4;async function My(){try{let e=await fetch(`/api/build`,{cache:`no-store`});if(e.status===404)return{kind:`unsupported`};if(!e.ok)return{kind:`unknown`};let{id:t}=await e.json();return typeof t==`string`?{kind:`id`,id:t}:{kind:`unknown`}}catch{return{kind:`unknown`}}}function Ny(e){let t=null,n=!1;async function r(){if(n)return;let r=await My();if(n)return;if(r.kind===`unsupported`){n=!0;return}if(r.kind===`unknown`)return;let i=r.id;if(t===null){t=i;return}i!==t&&(n=!0,e())}r();let i=setInterval(r,jy),a=()=>{document.visibilityState===`visible`&&r()};return document.addEventListener(`visibilitychange`,a),()=>{n=!0,clearInterval(i),document.removeEventListener(`visibilitychange`,a)}}function Py(e){let t=e?.nodes;if(!Array.isArray(t))return[];let n=new Set;for(let e of t){let t=e?.module??e?.type;typeof t==`string`&&t.startsWith(`project.`)&&n.add(t)}return[...n]}function Fy(e,t){let n=new Set(t);return Py(e).filter(e=>!n.has(e.slice(8)))}function Iy(e){return`cascade ${e||`<project directory>`} --host ${location.hostname} --port <free port>`}var Ly=`\0lane:`,Ry=28,zy={columnGap:260,rowGap:190,originX:40,originY:40};function By(e,t,n={}){let{columnGap:r,rowGap:i,originX:a,originY:o}={...zy,...n},s=n.widths,c=e=>s?.get(e)??r-60,l=new Map,u=new Map;for(let t of e)l.set(t,[]),u.set(t,[]);for(let e of t)!l.has(e.to)||!u.has(e.from)||(l.get(e.to).push(e.from),u.get(e.from).push(e.to));let d=new Map,f=new Set;function p(e){let t=d.get(e);if(t!==void 0)return t;if(f.has(e))return 0;f.add(e);let n=l.get(e)??[],r=n.length?Math.max(...n.map(p))+1:0;return f.delete(e),d.set(e,r),r}e.forEach(p);for(let t=0;t<e.length&&t<32;t++){let t=!1;for(let n of e){let e=u.get(n)??[];if(!e.length)continue;let r=l.get(n)??[],i=r.length?Math.max(...r.map(e=>d.get(e)??0))+1:0,a=Math.min(...e.map(e=>d.get(e)??0))-1,o=Math.max(i,a);o>(d.get(n)??0)&&(d.set(n,o),t=!0)}if(!t)break}let m=[];for(let t of e){let e=d.get(t)??0;for(;m.length<=e;)m.push([]);m[e].push(t)}let h=e=>e.startsWith(Ly),g=new Map(l),_=new Map(u);t.forEach((e,t)=>{let n=d.get(e.from),r=d.get(e.to);if(n===void 0||r===void 0||r-n<=1)return;g.set(e.to,(g.get(e.to)??[]).filter(t=>t!==e.from)),_.set(e.from,(_.get(e.from)??[]).filter(t=>t!==e.to));let i=e.from;for(let e=n+1;e<r;e++){let n=`${Ly}${t}:${e}`;m[e].push(n),g.set(n,[i]),_.set(n,[]),_.set(i,[..._.get(i)??[],n]),i=n}_.set(i,[..._.get(i)??[],e.to]),g.set(e.to,[...g.get(e.to)??[],i])}),m.forEach(e=>e.sort());let v=(e,t)=>e.indexOf(t);function y(e,t,n){let r=new Map;e.forEach((e,i)=>{let a=(n.get(e)??[]).map(e=>v(t,e)).filter(e=>e>=0);r.set(e,a.length?a.reduce((e,t)=>e+t,0)/a.length:i)}),e.sort((e,t)=>r.get(e)-r.get(t)||e.localeCompare(t))}function b(e,t){let n=[];t.forEach((t,r)=>{for(let i of g.get(t)??[]){let t=e.indexOf(i);t>=0&&n.push([t,r])}});let r=0;for(let e=0;e<n.length;e++)for(let t=e+1;t<n.length;t++)(n[e][0]-n[t][0])*(n[e][1]-n[t][1])<0&&r++;return r}let x=e=>(e>0?b(m[e-1],m[e]):0)+(e<m.length-1?b(m[e],m[e+1]):0);for(let e=0;e<8;e++){for(let e=1;e<m.length;e++)y(m[e],m[e-1],g);for(let e=m.length-2;e>=0;e--)y(m[e],m[e+1],_);let e=!0;for(let t=0;t<4&&e;t++){e=!1;for(let t=0;t<m.length;t++){let n=m[t];for(let r=0;r+1<n.length;r++){let i=x(t);[n[r],n[r+1]]=[n[r+1],n[r]],x(t)<i?e=!0:[n[r],n[r+1]]=[n[r+1],n[r]]}}}}let S=e=>h(e)?Ry:c(e),C=e=>h(e)?45:90,w=m.map(e=>e.reduce((e,t)=>e+S(t),0)+Math.max(0,e.length-1)*90),T=Math.max(1,...w),E=new Map;m.forEach((e,t)=>{let n=a+(T-w[t])/2;e.forEach(e=>{E.set(e,n+S(e)/2),n+=S(e)+90})});for(let e=0;e<6;e++){let t=e%2==0?g:_;for(let e of m)for(let n=0;n<e.length;n++){let r=e[n],i=(t.get(r)??[]).map(e=>E.get(e)).filter(e=>e!==void 0);if(!i.length)continue;let a=i.reduce((e,t)=>e+t,0)/i.length,o=S(r)/2,s=e[n-1],c=e[n+1],l=s===void 0?-1/0:E.get(s)+S(s)/2+C(r)+o,u=c===void 0?1/0:E.get(c)-S(c)/2-C(r)-o;E.set(r,Math.min(Math.max(a,l),u))}}for(let e of m)for(let t=0;t<e.length;t++){let n=e[t],r=(g.get(n)??[]).map(e=>E.get(e)).filter(e=>e!==void 0);if(!r.length)continue;let i=r.reduce((e,t)=>e+t,0)/r.length,a=S(n)/2,o=e[t-1],s=e[t+1],c=o===void 0?-1/0:E.get(o)+S(o)/2+C(n)+a,l=s===void 0?1/0:E.get(s)-S(s)/2-C(n)-a;E.set(n,Math.min(Math.max(i,c),l))}let D=new Map;return m.forEach((e,t)=>{for(let n of e)h(n)||D.set(n,{x:Math.round(E.get(n)-S(n)/2),y:Math.round(o+t*i)})}),D}function Vy(e){return e.map(e=>({from:e.from.nodeId,to:e.to.nodeId}))}var Hy=T(`<div class="cook-status loading svelte-16g4g59" role="status" aria-live="polite" data-phase="loading"><span class="status-mark svelte-16g4g59" aria-hidden="true"></span> <strong class="svelte-16g4g59">Loading graph</strong> <span class="svelte-16g4g59">Fetching and compiling nodes…</span></div>`),Uy=T(`<strong class="svelte-16g4g59"> </strong>`),Wy=T(`<span class="current-node svelte-16g4g59"> </span>`),Gy=T(`<strong class="svelte-16g4g59"> </strong> <!> <time class="svelte-16g4g59"> </time>`,1),Ky=T(`<div class="cook-status svelte-16g4g59" role="status" aria-live="polite"><span class="status-mark svelte-16g4g59" aria-hidden="true"></span> <!></div>`);function qy(t,n){r(n,!1);let i=I(),a=I(),o=z(n,`loading`,8,!1),s=z(n,`status`,8),c=I(Date.now()),l=I(O(c)),d=I(s()),f=I();de(()=>O(f)&&clearInterval(O(f)));function p(e){return e<1e3?`${Math.max(0,Math.round(e))} ms`:`${(e/1e3).toFixed(1)} s`}e(()=>(k(s()),O(d),O(l)),()=>{s()!==O(d)&&(Y(d,s()),Y(l,Date.now()),Y(c,O(l)))}),e(()=>(k(o()),k(s()),O(f)),()=>{let e=!o()&&s().phase===`cooking`;e&&!O(f)?Y(f,setInterval(()=>{Y(c,Date.now())},100)):!e&&O(f)&&(clearInterval(O(f)),Y(f,void 0))}),e(()=>(k(s()),O(c),O(l)),()=>{Y(i,s().elapsed+(s().phase===`cooking`?O(c)-O(l):0))}),e(()=>k(s()),()=>{Y(a,Math.min(s().total,s().completed+ +!!s().currentNode))}),ie(),le();var h=u(),g=B(h),_=e=>{var t=Hy();E(e,t)},v=e=>{var t=Ky(),n=G(q(t),2),r=e=>{var t=Uy(),n=M(t);J(()=>X(n,`Queued ${k(s()),y(()=>s().total)??``} ${k(s()),y(()=>s().total===1?`node`:`nodes`)??``}`)),E(e,t)},o=e=>{var t=Gy(),n=B(t),r=M(n),o=G(n,2),c=e=>{var t=Wy(),n=M(t,!0);J(()=>X(n,(k(s()),y(()=>s().currentNode.id)))),E(e,t)};m(o,e=>{k(s()),y(()=>s().currentNode)&&e(c)});var l=G(o,2),u=M(l,!0);J(e=>{X(r,`Cooking ${O(a)??``} of ${k(s()),y(()=>s().total)??``}`),X(u,e)},[()=>(O(i),y(()=>p(O(i))))]),E(e,t)};m(n,e=>{k(s()),y(()=>s().phase===`scheduled`)?e(r):e(o,-1)}),w(t),J(()=>N(t,`data-phase`,(k(s()),y(()=>s().phase)))),E(e,t)};m(g,e=>{o()?e(_):(k(s()),y(()=>s().phase!==`idle`)&&e(v,1))}),E(t,h),S()}function Jy(e,t=2){let n=e,r=``;for(;n!==r;)r=n,n=Yy(n,t);return n}function Yy(e,t=2){let n=e.split(`
|
|
220
|
+
`),r=[],i=0;for(;i<n.length;){let e=n[i],t=e.trim();if(t.endsWith(`[`)&&(t.includes(`:`)||t===`[`)){let a=[e],o=1,s=i+1;for(;s<n.length&&o>0;){let e=n[s];a.push(e);for(let t of e)t===`[`&&o++,t===`]`&&o--;s++}let c=[],l=1;for(;l<a.length-1;){let e=a[l].trim();if(e.endsWith(`[`)||e.startsWith(`[`)&&!e.endsWith(`]`)){let e=[a[l]],t=1,n=l+1;for(;n<a.length-1&&t>0;){e.push(a[n]);for(let e of a[n])e===`[`&&t++,e===`]`&&t--;n++}let r=[];for(let t=1;t<e.length-1;t++){let n=e[t].trim().replace(/,$/,``).trim();n&&r.push(n)}let i=`[`+r.map(e=>e.trim()).join(`, `)+`]`;c.push(i),l=n}else{let t=e.replace(/,$/,``).trim();t&&c.push(t),l++}}let u=c.length>=2&&c.length<=4&&c.every(e=>{let t=e.trim();return/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/.test(t)}),d=!1;if(c.length>=2&&c.length<=20&&c.every(e=>{let t=e.trim();if(t.startsWith(`[`)&&t.endsWith(`]`)){let e=t.slice(1,-1).trim().split(`,`).map(e=>e.trim()).filter(e=>e);return e.length>=2&&e.length<=4}return!!t.endsWith(`[`)})){let e=!0;for(let t of c){let n=t.trim();if(n.startsWith(`[`)&&n.endsWith(`]`)){let t=n.slice(1,-1).trim().split(`,`).map(e=>e.trim()).filter(e=>e);if(t.length<2||t.length>4){e=!1;break}}else if(!n.endsWith(`[`)){e=!1;break}}d=e}if(u||d){let n=(e.match(/^(\s*)/)?.[1]||``).length,o=t.match(/^(.+?)\s*\[\s*$/),l=o?o[1]:``,u=a[a.length-1].trim().endsWith(`,`),f;f=d?c.map(e=>{let t=e.trim();return t.startsWith(`[`)&&t.endsWith(`]`),t}).join(`, `):c.map(e=>e.trim()).join(`, `);let p=l+` [`+f+`]`+(u?`,`:``);r.push(` `.repeat(n)+p),i=s;continue}}r.push(e),i++}return r.join(`
|
|
221
|
+
`)}function Xy(e){let t=e.toJSON();return Jy(JSON.stringify(t,null,2),2)}function Zy(e,t=`graph.cascade`){let n=Xy(e),r=new Blob([n],{type:`application/json`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}async function Qy(e,t=`graph.cascade`){if(!(`showSaveFilePicker`in window))return Zy(e,t),t;try{let n=await window.showSaveFilePicker({suggestedName:t,types:[{description:`Cascade Files`,accept:{"application/json":[`.cascade`]}}]}),r=await n.createWritable(),i=Xy(e);return await r.write(i),await r.close(),n.name}catch(e){if(e.name===`AbortError`)return null;throw e}}function $y(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=e=>{try{t(JSON.parse(e.target?.result))}catch{n(Error(`Failed to parse JSON file`))}},r.onerror=()=>n(Error(`Failed to read file`)),r.readAsText(e)})}function eb(e=`.cascade`){return new Promise(t=>{let n=document.createElement(`input`);n.type=`file`,n.accept=e,n.onchange=e=>{t(e.target.files?.[0]||null)},n.click()})}function tb(e){return e.replace(/\.[^/.]+$/,``)}var nb=class e{constructor(e){if(this.sceneContainer=null,e)this.graph=e;else{let e=new nl(``,new tl),t=new sl;this.graph=new Ll(e,t)}typeof document<`u`&&(this.sceneContainer=document.createElement(`div`),this.sceneContainer.id=`cascade-scene`)}getGraph(){return this.graph}getSceneContainer(){return this.sceneContainer}static create(){return new e}static fromJSON(t){let n=new nl(``,new tl),r=new sl,i=Ll.fromJSON(t,n,r);return new e(i)}},rb=F(()=>Jc),ib=T(`<div class="build-stale svelte-1n46o8q" role="status"><span>Cascade updated. This tab is running the previous build.</span> <button class="svelte-1n46o8q">Reload</button></div>`),ab=T(`<div class="project-mismatch svelte-1n46o8q" role="alert"><span> </span> <code class="svelte-1n46o8q"> </code> <button class="svelte-1n46o8q">Dismiss</button></div>`),ob=T(`<div class="credential-warning svelte-1n46o8q" role="alert"> <button class="svelte-1n46o8q">Open Project Settings</button></div>`),sb=T(`<div><!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!></div>`);function cb(n,a){r(a,!1);let o=()=>oe(Tm,`$selectedNodeIds`,l),s=()=>oe(hm,`$canUndo`,l),c=()=>oe(gm,`$canRedo`,l),[l,d]=se(),p=I(),h=I(),g=I(),_=I(null),v=I(null),b=I(null),x=I(null);async function C(){if(!O(b)){let e=await ol(()=>import(`./VersionHistoryDialog-hH6VsXLX.js`),__vite__mapDeps([5,1,6]));Y(b,e.default)}}async function T(){if(!O(_)){let e=await ol(()=>import(`./ExportDialog-DWN4nhXI.js`),__vite__mapDeps([7,1,8]));Y(_,e.default)}}async function D(){if(!O(v)){let e=await ol(()=>import(`./SettingsDialog-DmHb1V0r.js`),__vite__mapDeps([9,1,10]));Y(v,e.default)}}async function te(){O(x)||Y(x,(await ol(async()=>{let{default:e}=await import(`./ProjectSettings-BzT164Yx.js`);return{default:e}},__vite__mapDeps([11,1,12,13]))).default)}let A=I(!1),j=I(null),N=I(null),P=I(null),F=I(null),ne=I(!1),re=I(null),ae=I(`select`),R=I({x:0,y:0}),z={x:0,y:0},ce=I(!1),V=I(!1),ue=I(!1),U=I(void 0),fe=new dm(()=>O(U)),W=I(!0),me=I(),K=I(),ge=I({phase:`idle`,total:0,completed:0,currentNode:null,startedAt:null,elapsed:0});de(()=>O(K)?.());let _e=I(`Untitled`),ve=I(null),ye=I(null),be=I(!1),xe=I(!1),Se=I(null),Ce=I([]),we=I(``),Te=I(!1);function Ee(e){if(!O(U))return;let t=Dm(O(U),o(),O(P));t.length!==0&&(Je(),t.forEach(t=>{e?t.color=e:delete t.color}),H(U,O(U).elements=[...O(U).elements]),Y(De,!0),Ke())}let De=I(!1);function Oe(){Y(A,!O(A)),O(A)&&(Y(j,null),Y(N,null))}function ke(e){Y(j,e),Y(N,null)}function Ae(e){Y(j,e.detail.libraryId),Y(N,e.detail.categoryId)}function je(e){Y(j,e.detail.libraryId),Y(N,null)}function Me(e){Y(ae,e)}let Ne=I(null);function Pe(e){O(Ne)&&O(Ne).addNode&&O(Ne).addNode({type:e.detail.type,category:e.detail.categoryId,customConfig:e.detail.customConfig}),Y(j,null),Y(N,null)}function Fe(e){Y(P,e),e&&Y(F,null)}function Ie(e){Y(F,e.detail.annotationId),e.detail.annotationId&&Y(P,null)}function Le(e){switch(e){case`new`:Ve();break;case`open`:He();break;case`save`:Ue();break;case`versionHistory`:if(!O(ye)){alert(`Version history is for a project opened by the cascade CLI — this document has none.`);break}C().then(()=>Y(be,!0));break;case`saveAs`:We();break;case`duplicate`:Ge();break;case`export`:T().then(()=>Y(ce,!0));break;case`settings`:D().then(()=>Y(V,!0));break;case`projectSettings`:te().then(()=>Y(ue,!0));break;case`about`:alert(`Cascade - Visual Programming Framework
|
|
222
|
+
Version 1.0.0`);break;case`undo`:Q();break;case`redo`:qe();break;case`selectAll`:O(Ne)?.selectAll&&O(Ne).selectAll();break;case`deselectAll`:O(Ne)?.deselectAll&&O(Ne).deselectAll(),Y(P,null),Y(F,null);break;case`delete`:O(Ne)?.deleteSelected&&O(Ne).deleteSelected(),Y(P,null),Y(F,null);break;case`addNode`:Y(re,null),Y(j,`core`),Y(R,{x:window.innerWidth/2,y:window.innerHeight/2});break;case`addText`:Y(ae,`text`);break;case`addImage`:Y(ae,`image`);break;case`addGroup`:Y(ae,`group`);break;case`addLine`:Y(ae,`line`);break;case`addPolyline`:Y(ae,`polyline`);break;case`cleanUpLayout`:Qe();break;case`centerOnNodes`:O(Ne)?.centerOnNodes&&O(Ne).centerOnNodes();break;case`resetLayout`:Bc.resetLayout();break;case`presentationMode`:Oe();break;case`maximizeTab`:Bc.toggleMaximizeActivePanel();break;case`focusGraph`:Bc.focusPanel(`graph-main`);break;case`focusViewer`:Bc.focusPanel(`viewer-main`);break;case`focusInspector`:Bc.focusPanel(`inspector-main`);break;case`focusLog`:Bc.focusPanel(`log-main`)}}async function Re(e){let t=nb.fromJSON(e).getGraph();try{await t.waitForAnnotationPorts();for(let e of t.nodes)if(e.code)try{let t=`return (async function(node, graph) {\n${e.code}\n})(node, graph);`,n=Function(`node`,`graph`,t);e.setFunction(n)}catch(t){console.warn(`Failed to set function for node ${e.id}:`,t)}}catch(e){throw ze(t),e}return t}function ze(e){e.nodes.forEach(e=>{try{e.onDestroy?.()}catch(t){console.warn(`Failed to dispose node ${e.id}:`,t)}})}async function Be(e,t=!1){let n=O(U);Y(U,e);try{fe.restoreConnections(),await ee()}catch(t){throw Y(U,n),ze(e),t}t&&wm(),n&&ze(n)}async function Ve(){if(!(!(O(U)&&confirm(`Create a new project? Unsaved changes will be lost.`))&&O(U)))try{let e=await fetch(`/graphs/default.cascade`);if(!e.ok)throw Error(`Failed to load default graph`);await Be(await Re(await e.json()),!0),Y(_e,`Untitled`),Y(ve,null),Y(ye,null),Y(De,!1),Ke(),Ye().catch(e=>console.warn(`Graph execution failed:`,e)),setTimeout(()=>{O(Ne)&&O(Ne).centerOnNodes&&O(Ne).centerOnNodes()},100)}catch(e){console.error(`Failed to load default graph:`,e),O(U)||(Y(U,nb.create().getGraph()),Y(_e,`Untitled`),Y(ve,null),Y(ye,null),Y(De,!1),Ke())}}async function He(){try{let e=await eb(`.cascade`);if(!e)return;let t=await $y(e);await Be(await Re(t),!0),Y(_e,tb(e.name)),Y(ve,e.name),Y(ye,null),Y(De,!1),Ke(),await Ze(t),await Ye().catch(e=>console.warn(`Graph execution failed:`,e)),setTimeout(()=>{O(Ne)&&O(Ne).centerOnNodes&&O(Ne).centerOnNodes()},100)}catch(e){alert(`Failed to open project: `+e.message)}}async function Ue(){if(O(U)){if(O(ve)){if(O(ye)){let e=await fetch(`/api/graph/${encodeURIComponent(O(ye))}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:Xy(O(U))});if(!e.ok){let t=await e.text();alert(`Failed to save ${O(ye)}: ${t}`);return}}else if(!await Qy(O(U),O(ve)))return;Y(De,!1),Ke()}else We()}}async function We(){if(!O(U))return;let e=O(_e)===`Untitled`?`my-project.cascade`:`${O(_e)}.cascade`,t=await Qy(O(U),e);t&&(Y(_e,t.replace(/\.cascade$/,``)),Y(ve,t),Y(ye,null),Y(De,!1),Ke())}function Ge(){if(!O(U))return;let e=O(U).toJSON(),t=nb.fromJSON(e).getGraph();t.nodes.forEach(e=>{e.position.x+=50,e.position.y+=50}),Y(U,t),Y(_e,O(_e)+` Copy`),Y(ve,null),Y(ye,null),Ke(),t.nodes.forEach(e=>{if(e.code)try{let t=Function(`node`,`graph`,e.code);e.setFunction(t)}catch(t){console.warn(`Failed to execute node `+e.id+`:`,t)}}),Ye().catch(e=>console.warn(`Failed to initialize duplicated graph:`,e)),setTimeout(()=>{O(Ne)&&O(Ne).centerOnNodes&&O(Ne).centerOnNodes()},100)}function Ke(){if(typeof document<`u`){let e=O(De)?` *`:``,t=O(U)?.project?.name&&O(U).project.name!==`Cascade Graph`?O(U).project.name:O(we)?O(we):O(_e)&&O(_e)!==`Untitled`?O(_e):`Untitled`;document.title=`${t}${e} - Cascade`}}async function Z(e){O(U)&&(await Be(await Re(e.json)),Y(P,e.selectedNodeId?O(U).getNode(e.selectedNodeId):null),Y(F,e.selectedAnnotationId),Ye().catch(e=>console.warn(`Graph execution failed:`,e)))}async function Q(){if(!O(U))return;let e=Sm(O(U),O(P)?.id||null,O(F));e&&await Z(e)}async function qe(){if(!O(U))return;let e=Cm(O(U),O(P)?.id||null,O(F));e&&await Z(e)}function Je(){O(U)&&(xm(O(U),O(P)?.id||null,O(F)),Y(De,!0),Ke())}async function Ye(e=16){if(!O(U))return;let t=-1,n=-1;for(let r=0;r<e;r++){await O(U).execute(),fe.restoreConnections(),await ee();let e=O(U).nodes.reduce((e,t)=>e+t.outputs.filter(e=>e.value!==void 0&&e.value!==null).length,0),i=(O(U)._connectionsToRestore??[]).length;if(e===t&&i===n){console.log(`[Cook] settled after ${r+1} passes: ${e} outputs`+(i?`, ${i} connections unresolved (bypassed or unrunnable upstream)`:``)),i&&console.log(`[Cook] unresolved:`,(O(U)._connectionsToRestore??[]).map(e=>`${e[0][0]}.${e[0][2]??e[0][1]}->${e[1][0]}.${e[1][2]??e[1][1]}`).join(` `));return}t=e,n=i}console.warn(`[Cook] still changing after ${e} passes — stopping`)}async function Xe(){try{let e=await fetch(`/api/graph`);if(!e.ok)return null;let{default:t}=await e.json();if(!t)return null;let n=await fetch(`/api/graph/${encodeURIComponent(t)}`);return n.ok?{filename:t,json:await n.json()}:null}catch(e){return console.warn(`[Startup] No project graph available from the server:`,e),null}}async function Ze(e){Y(Se,null);try{let[t,n]=await Promise.all([fetch(`/api/nodes`),fetch(`/api/graph`)]);if(!t.ok)return;let r=Fy(e,(await t.json())?.modules??[]);if(!r.length)return;let i=n.ok?(await n.json())?.root??``:``;Y(Se,{missing:r,root:i})}catch{}}async function $(e){let{json:t,version:n}=e.detail,r=O(ye);await Be(await Re(t),!0),Y(be,!1),Y(ye,r),Y(ve,r),Y(De,!0),Ke(),Ye().catch(e=>console.warn(`Graph execution failed:`,e)),console.log(`[Version] Restored ${r} at ${n.shortSha} — unsaved until you save`)}async function Qe(){if(!O(U))return;Je();let e=new Map;document.querySelectorAll(`.node`).forEach(t=>{let n=t.querySelector(`.node-name`)?.textContent?.trim();n&&e.set(n,Math.max(t.offsetWidth,90))});let t=By(O(U).nodes.map(e=>e.id),Vy(O(U).connections),{widths:e});O(U).nodes.forEach(e=>{let n=t.get(e.id);n&&(e.position=n)}),H(U,O(U).elements=[...O(U).elements]),Yp(),Y(De,!0),Ke(),requestAnimationFrame(()=>requestAnimationFrame(()=>{Yp(),O(Ne)?.centerOnNodes?.(),requestAnimationFrame(()=>requestAnimationFrame(()=>Yp()))}))}he(()=>{rb(rb().onPropParamsChanged=Vp),Ke(),Kp();let e=Ay({getTarget:()=>O(U)??null}),t=Ny(()=>{Y(xe,!0)}),n=wy.subscribe(e=>{e&&(D().then(()=>Y(V,!0)),Ty())});(async()=>{if(!O(U))try{let e,t=`Untitled`,n=null,r=null,i=await Xe();if(i&&(console.log(`[Startup] Loading project graph from server:`,i.filename),e=i.json,n=i.filename,t=i.filename,r=i.filename),!e){let t=await fetch(`/graphs/default.cascade`);if(!t.ok)throw Error(`Failed to load default graph`);e=await t.json()}if(await Be(await Re(e)),Y(_e,t),Y(ve,n),Y(ye,r),Y(De,!1),Ke(),await Ze(e),O(ye))try{let{loadProjectSettings:e}=await ol(async()=>{let{loadProjectSettings:e}=await import(`./projectSettingsApi-C1WvIwfP.js`);return{loadProjectSettings:e}},[]),t=await e();Y(Ce,t.missingCredentials),Y(we,t.manifest.name),Ke()}catch{Y(Ce,[])}O(Ce).length===0?await Ye().catch(e=>console.warn(`Graph execution failed:`,e)):console.warn(`[Startup] Cook deferred until required credentials are set: ${O(Ce).join(`, `)}`),setTimeout(()=>{O(Ne)&&O(Ne).centerOnNodes&&O(Ne).centerOnNodes()},100)}catch(e){console.error(`Failed to load default graph:`,e);let t=nb.create();Y(U,t.getGraph()),Y(_e,`Untitled`),Y(ve,null),Y(ye,null),Ke()}Y(W,!1)})();function r(e){z={x:e.clientX,y:e.clientY}}window.addEventListener(`mousemove`,r);function i(e){if((e.key===`c`||e.key===`C`)&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey){let t=e.target;if(t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`&&!t.isContentEditable){e.preventDefault(),Y(Te,!O(Te));return}}if((e.metaKey||e.ctrlKey)&&e.key===`.`&&(e.preventDefault(),Oe()),(e.metaKey||e.ctrlKey)&&e.key===`z`&&!e.shiftKey){e.preventDefault(),Q();return}if((e.metaKey||e.ctrlKey)&&e.key===`z`&&e.shiftKey){e.preventDefault(),qe();return}let t=e.target;if(t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`&&((e.key===`v`||e.key===`V`)&&!e.metaKey&&!e.ctrlKey&&Y(ae,`select`),(e.key===`h`||e.key===`H`)&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&(e.preventDefault(),O(Ne)&&O(Ne).centerOnNodes&&O(Ne).centerOnNodes()),e.altKey&&!e.metaKey&&!e.ctrlKey&&((e.key===`t`||e.key===`T`)&&(e.preventDefault(),Y(ae,`text`)),(e.key===`i`||e.key===`I`)&&(e.preventDefault(),Y(ae,`image`)),(e.key===`g`||e.key===`G`)&&(e.preventDefault(),Y(ae,`group`)),(e.key===`l`||e.key===`L`)&&(e.preventDefault(),Y(ae,`line`)),(e.key===`p`||e.key===`P`)&&(e.preventDefault(),Y(ae,`polyline`)))),e.key===`Tab`&&!e.metaKey&&!e.ctrlKey&&!e.altKey){let t=e.target;if(t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`){if(e.preventDefault(),O(j)||O(N))Y(j,null),Y(N,null),Y(re,null);else{Y(re,null);let e=document.querySelector(`[data-window-id="graph"]`);if(e){let t=e.getBoundingClientRect();z.x>=t.left&&z.x<=t.right&&z.y>=t.top&&z.y<=t.bottom?Y(R,{...z}):Y(R,{x:t.left+t.width/2,y:t.top+t.height/2})}else Y(R,{x:window.innerWidth/2,y:window.innerHeight/2});Y(j,`core`)}}}if(e.key===`Escape`&&(O(j)||O(N))&&(Y(j,null),Y(N,null),Y(re,null)),(e.metaKey||e.ctrlKey)&&e.key===`b`&&(e.preventDefault(),Bc.toggleMaximizeActivePanel()),(e.metaKey||e.ctrlKey)&&e.key===`/`){e.preventDefault();let t=e.target;t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`&&(O(j)||O(N)?(Y(j,null),Y(N,null),Y(re,null)):(Y(re,null),Y(R,{x:window.innerWidth/2,y:window.innerHeight/2}),Y(j,`core`)))}(e.metaKey||e.ctrlKey)&&e.key===`;`&&(e.preventDefault(),(O(P)||O(P)===null)&&Y(P,null)),(e.metaKey||e.ctrlKey)&&e.key===`e`&&(e.preventDefault(),T().then(()=>Y(ce,!0))),(e.metaKey||e.ctrlKey)&&e.key===`,`&&(e.preventDefault(),D().then(()=>Y(V,!0)));let n=e.altKey;if(n&&e.key===`n`&&!e.shiftKey&&(e.preventDefault(),Ve()),n&&e.key===`o`&&!e.shiftKey&&(e.preventDefault(),He()),n&&e.key===`s`&&(e.preventDefault(),e.shiftKey?We():Ue()),(e.metaKey||e.ctrlKey)&&e.key===`d`){let t=e.target;t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`&&(e.preventDefault(),Ge())}let r=e.target;if(r.tagName!==`INPUT`&&r.tagName!==`TEXTAREA`&&O(U)&&O(P)){if((e.key===`b`||e.key===`B`)&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&(e.preventDefault(),O(P).setBypass(!O(P).bypass)),(e.key===`k`||e.key===`K`)&&!e.metaKey&&!e.ctrlKey){if(e.preventDefault(),e.shiftKey){O(P).setCook(!0);let e=t=>{t.outputs.forEach(t=>{t.connections.forEach(t=>{let n=O(U)?.getNode(t.to.nodeId);n&&(n.setCook(!0),e(n))})})};e(O(P))}else O(P).cook?O(P).setCook(!1):(O(U).clearCookingNodes(),O(P).setCook(!0))}e.altKey&&(e.key===`b`||e.key===`B`)&&(e.preventDefault(),O(U).nodes.forEach(e=>{e.bypass&&e.setBypass(!1)})),e.altKey&&(e.key===`k`||e.key===`K`)&&(e.preventDefault(),O(U).clearCookingNodes())}if(e.key===`Delete`&&O(U)&&O(P)){let t=e.target;t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`&&(e.preventDefault(),Je(),O(U).removeNode(O(P).id),Y(P,null))}if(e.altKey&&(e.key===`h`||e.key===`H`)){let t=e.target;t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`&&(e.preventDefault(),O(Ne)&&O(Ne).centerOnNodes&&O(Ne).centerOnNodes())}if((e.ctrlKey||e.metaKey)&&!e.shiftKey&&!e.altKey&&(e.key===`1`?(e.preventDefault(),Bc.focusPanel(`graph-main`)):e.key===`2`?(e.preventDefault(),Bc.focusPanel(`viewer-main`)):e.key===`3`?(e.preventDefault(),Bc.focusPanel(`inspector-main`)):e.key===`4`&&(e.preventDefault(),Bc.focusPanel(`log-main`))),(e.ctrlKey||e.metaKey)&&e.key===`w`&&!e.shiftKey){let t=Bc.activePanel;t&&t!==`graph-main`&&(e.preventDefault(),Bc.removePanel(t))}(e.ctrlKey||e.metaKey)&&e.shiftKey&&e.key===`P`&&(e.preventDefault(),Bc.resetLayout())}return window.addEventListener(`keydown`,i),()=>{window.removeEventListener(`keydown`,i),window.removeEventListener(`mousemove`,r),n(),e(),t()}}),e(()=>(O(P),O(F)),()=>{Y(p,O(P)!==null||O(F)!==null)}),e(()=>O(p),()=>{Y(ne,O(p))}),e(()=>(O(ne),O(p)),()=>{Y(h,O(ne)&&O(p))}),e(()=>(O(U),O(me),O(K)),()=>{O(U)!==O(me)&&(O(K)?.(),Y(me,O(U)),Y(ge,O(U)?.scheduler.status??{phase:`idle`,total:0,completed:0,currentNode:null,startedAt:null,elapsed:0}),Y(K,O(U)?.scheduler.subscribe(e=>{Y(ge,e)})))}),e(()=>(O(De),O(ve),O(_e)),()=>{Y(g,O(De)||O(ve)===null?`${O(_e)} *`:O(_e))}),e(()=>O(_e),()=>{O(_e)&&Ke()}),e(()=>O(De),()=>{O(De)!==void 0&&Ke()}),ie(),le();var $e=sb();let et;var tt=q($e),nt=e=>{var t=ib(),n=G(q(t),2);w(t),f(`click`,n,()=>location.reload()),E(e,t)};m(tt,e=>{O(xe)&&e(nt)});var rt=G(tt,2),it=e=>{var t=ab(),n=q(t),r=M(n),i=G(n,2),a=M(i,!0),o=G(i,2);w(t),J((e,t)=>{X(r,`This graph needs project nodes this server does not have
|
|
223
|
+
(${e??``}${O(Se),y(()=>O(Se).missing.length>3?`, and ${O(Se).missing.length-3} more`:``)??``}), so they cannot cook here. This server serves
|
|
224
|
+
${O(Se),y(()=>O(Se).root||`another project`)??``}. Launch the graph's own project from the CLI:`),X(a,t)},[()=>(O(Se),y(()=>O(Se).missing.slice(0,3).map(e=>e.slice(8)).join(`, `))),()=>(k(Iy),y(()=>Iy(``)))]),f(`click`,o,()=>Y(Se,null)),E(e,t)};m(rt,e=>{O(Se)&&e(it)});var at=G(rt,2),ot=e=>{ny(e,{get documentName(){return O(g)},get canUndo(){return s()},get canRedo(){return c()},$$events:{action:e=>Le(e.detail),openNodePanel:e=>{Y(j,`core`),Y(re,{x:e.detail.x,y:e.detail.y})},nameChange:e=>{Y(_e,e.detail),Y(De,!0),Ke()}}})};m(at,e=>{O(A)||e(ot)});var st=G(at,2);pe(qv(st,{get graph(){return O(U)},get selectedNode(){return O(P)},get selectedAnnotation(){return O(F)},get activeTool(){return O(ae)},get activeLibrary(){return O(j)},get documentName(){return O(g)},get presentationMode(){return O(A)},onRecordHistory:Je,$$events:{nodeSelect:e=>Fe(e.detail.node),annotationSelect:e=>Ie(e),libraryToggle:e=>ke(e.detail),toolChange:e=>Me(e.detail),action:e=>Le(e.detail),nameChange:e=>{Y(_e,e.detail),Y(De,!0),Ke()},openNodePanel:e=>{e.detail?.x&&e.detail?.y?Y(R,{x:e.detail.x,y:e.detail.y}):Y(R,{x:window.innerWidth/2,y:window.innerHeight/2}),Y(j,O(j)?null:`core`),Y(N,null)}},$$legacy:!0}),e=>Y(Ne,e),()=>O(Ne));var ct=G(st,2);qy(ct,{get loading(){return O(W)},get status(){return O(ge)}});var lt=G(ct,2),ut=e=>{var t=ob(),n=q(t),r=G(n);w(t),J(e=>X(n,`Missing project credentials: ${e??``}. `),[()=>(O(Ce),y(()=>O(Ce).join(`, `)))]),f(`click`,r,()=>te().then(()=>Y(ue,!0))),E(e,t)};m(lt,e=>{O(Ce),y(()=>O(Ce).length)&&e(ut)});var dt=G(lt,2),ft=e=>{Cy(e,{get libraryId(){return O(j)},get categoryId(){return O(N)},get centerPosition(){return O(R)},get fixedPosition(){return O(re)},$$events:{addNode:Pe,selectCategory:Ae,selectLibrary:je,close:()=>{Y(j,null),Y(N,null),Y(re,null)}}})};m(dt,e=>{(O(j)||O(N))&&e(ft)});var pt=G(dt,2),mt=e=>{var n=u(),r=B(n);t(r,()=>O(_),(e,t)=>{t(e,{get graph(){return O(U)},get open(){return O(ce)},set open(e){Y(ce,e)},$$events:{close:()=>Y(ce,!1)},$$legacy:!0})}),E(e,n)};m(pt,e=>{O(U)&&O(_)&&e(mt)});var ht=G(pt,2);{let e=L(()=>(k(Dm),O(U),o(),O(P),y(()=>Dm(O(U),o(),O(P)).length)));Oy(ht,{get open(){return O(Te)},get selectionCount(){return O(e)},$$events:{choose:e=>{Ee(e.detail),Y(Te,!1)},close:()=>Y(Te,!1)}})}var gt=G(ht,2),_t=e=>{var n=u(),r=B(n);t(r,()=>O(b),(e,t)=>{t(e,{get filename(){return O(ye)},get open(){return O(be)},set open(e){Y(be,e)},$$events:{restore:$,close:()=>Y(be,!1)},$$legacy:!0})}),E(e,n)};m(gt,e=>{O(b)&&e(_t)});var vt=G(gt,2),yt=e=>{var n=u(),r=B(n);t(r,()=>O(v),(e,t)=>{t(e,{get open(){return O(V)},set open(e){Y(V,e)},$$events:{close:()=>Y(V,!1)},$$legacy:!0})}),E(e,n)};m(vt,e=>{O(v)&&e(yt)});var bt=G(vt,2),xt=e=>{var n=u(),r=B(n);t(r,()=>O(x),(e,t)=>{t(e,{get graph(){return O(U)},get open(){return O(ue)},set open(e){Y(ue,e)},$$events:{save:e=>{Y(_e,e.detail.graphName||O(_e)),Y(we,e.detail.projectName),Y(Ce,e.detail.missingCredentials),Y(De,!0),Ke()},close:()=>Y(ue,!1)},$$legacy:!0})}),E(e,n)};m(bt,e=>{O(U)&&O(x)&&e(xt)}),w($e),J(()=>et=i($e,1,`app svelte-1n46o8q`,null,et,{"presentation-mode":O(A)})),E(n,$e),S(),d()}var lb=[`auto`,`dark`,`light`],ub=`auto`,db=`dark`;function fb(e){return typeof e==`string`&&lb.includes(e)}function pb(e){return fb(e)?e:ub}function mb(e,t){return e===`dark`||e===`light`?e:t===void 0?db:t?`dark`:`light`}function hb(e){return e===`light`?`vs`:`vs-dark`}var gb=`cascade-user-settings`,_b=12,vb=10,yb=24;function bb(e){return typeof e==`number`&&Number.isFinite(e)?Math.min(yb,Math.max(vb,Math.round(e))):_b}function xb(e){let t=e&&typeof e==`object`?e:{};return{appearance:{theme:pb(t.appearance?.theme)},editor:{fontSize:bb(t.editor?.fontSize)}}}function Sb(){try{let e=localStorage.getItem(gb);return xb(e?JSON.parse(e):void 0)}catch(e){return console.warn(`Failed to load settings:`,e),xb(void 0)}}function Cb(e){try{localStorage.setItem(gb,JSON.stringify(xb(e)))}catch(e){console.warn(`Failed to save settings:`,e)}}var wb=P(Sb());wb.subscribe(Cb);function Tb(e){wb.set(xb(e))}var Eb=P(db),Db=De(Eb),Ob=`(prefers-color-scheme: dark)`;function kb(e,t){e.setAttribute(`data-theme`,t)}function Ab(){return typeof window>`u`||typeof window.matchMedia!=`function`?null:window.matchMedia(Ob)}function jb(e,t){return typeof e.addEventListener==`function`?(e.addEventListener(`change`,t),()=>e.removeEventListener?.(`change`,t)):typeof e.addListener==`function`?(e.addListener(t),()=>e.removeListener?.(t)):()=>{}}function Mb(e={}){let t=e.root??(typeof document>`u`?void 0:document.documentElement),n=e.query===void 0?Ab():e.query,r=e.preferences??{subscribe:e=>wb.subscribe(t=>e(t.appearance.theme))},i=`auto`,a=()=>{let e=mb(i,n?n.matches:void 0);Eb.set(e),t&&kb(t,e)},o=r.subscribe(e=>{i=e,a()}),s=n?jb(n,a):()=>{};return()=>{s(),o()}}var Nb=!1;async function Pb(){Nb||=(await Promise.all([ol(()=>import(`./core-Bji4aZUU.js`),__vite__mapDeps([14,15])),ol(()=>import(`./geo-CXmCtzMM.js`),__vite__mapDeps([16,15])),ol(()=>import(`./image-BUcQC7PG.js`),__vite__mapDeps([17,15])),ol(()=>import(`./quill-DjZ69wL_.js`),__vite__mapDeps([18,15]))]),!0)}async function Fb(){Mb(),await Pb(),b(cb,{target:document.getElementById(`app`)})}Fb();export{xs as A,Gc as C,Ac as D,Vc as E,Xa as F,Ka as I,Ba as L,Co as M,co as N,Dc as O,Qa as P,wa as R,Jc as S,Hc as T,tp as _,hb as a,wl as b,jp as c,Op as d,Tp as f,Cp as g,wp as h,lb as i,Do as j,Ds as k,Ep as l,Dp as m,Tb as n,kv as o,Ap as p,wb as r,Mp as s,Db as t,kp as u,Ll as v,Kc as w,ol as x,Sl as y,la as z};
|